{"modulePath":"github.com/lichdotdev/lich","version":"v0.93.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package scope\n\nPackage scope is what a confined session may ask of lich's loopback listener. A session running in the sandbox is handed a token minted for it alone (internal/terminal), never the launch-wide one, and every request made with it is held to this policy: an allowlist of RPC methods, and on the methods that name their caller, the rule that the caller is the session the token was minted for.\n\nDeny by default. The list is derived from what a confined agent legitimately does through lich-plugin's hooks, the \\`lich\\` CLI and \\`lich mcp\\`: talk to the sessions around it, open and steer sessions (which come out confined too, internal/spawn), drive its own browser, read the project's services and its cost. Everything that runs a command on the machine outside the sandbox (services.Start and the other service writes), moves a setting (store.SetSetting), types into another session's PTY (terminal.Write), hands the backend a host path, or belongs to the window alone is out.\n\nThe relay is allowed and held to a second rule where the method resolves its target (Target): text a confined session puts at another session's prompt is carried out by that session as its task, so the target has to be confined too, or the message is terminal.Write under another name. A reply goes to anyone, since the recipient reads it as a result.\n\n## Functions\n\n```go\nfunc Allows(method string) bool\n```\nAllows reports whether a scoped token may call method at all.\n\n```go\nfunc CallerField(method string) string\n```\nCallerField is the options field that must name the calling session, \"\" when the method has none.\n\n```go\nfunc Force(ctx context.Context, force bool) error\n```\nForce refuses a confined caller the force that removes a checkout with uncommitted work: the checkout is outside its sandbox, and what the force discards exists nowhere else.\n\n```go\nfunc Impersonation(method, claimed, session string) string\n```\nImpersonation is the error for an allowed method whose options name another session as the caller.\n\n```go\nfunc Method(path string) string\n```\nMethod is the RPC method a request path names, \"\" for anything that is not an RPC.\n\n```go\nfunc Refusal(method string) string\n```\nRefusal is the error a confined session reads when it calls a method its token does not cover.\n\n```go\nfunc Session(ctx context.Context) string\n```\nSession is the confined session a request was made by, \"\" for the window, the command line outside a sandbox and every other holder of the launch token.\n\n```go\nfunc Target(ctx context.Context, label string, confined bool) error\n```\nTarget refuses a confined caller a session that is not itself confined, for a method that puts text at the target's prompt: the receiving agent carries a message out as its task, so a confined session writing \"run X\" into an unconfined card is terminal.Write under another name. confined is the target's row (store.SessionConfined). A reply is not held to this: the recipient reads it as a result, and it is how a confined worker reports to an unconfined parent.\n\n```go\nfunc With(ctx context.Context, session string) context.Context\n```\nWith marks ctx as a request made with a scoped token minted for session.\n\n","path":"github.com/lichdotdev/lich/internal/scope","name":"scope","synopsis":"Package scope is what a confined session may ask of lich's loopback listener.","isRedistributable":true}
