|
|
@@ -149,36 +149,49 @@ export const Plugin = {
|
|
|
(invocation) =>
|
|
|
Effect.gen(function* () {
|
|
|
const target = yield* mutation.resolve({ path: invocation.cwd, kind: "directory" })
|
|
|
- const parsed = yield* ShellParse.scan(invocation.command, invocation.shell, target.absolute)
|
|
|
- const directories = yield* Effect.forEach(parsed.directories, (directory) =>
|
|
|
- mutation.resolve({ path: path.resolve(target.absolute, directory), kind: "directory" }),
|
|
|
- )
|
|
|
- invocation.cwd = target.absolute
|
|
|
- finalTimeout = invocation.timeout
|
|
|
- const external = [target, ...directories]
|
|
|
- .map((item) => item.externalDirectory)
|
|
|
- .filter((item) => item !== undefined)
|
|
|
- .filter(
|
|
|
- (item, index, items) => items.findIndex((other) => other.resource === item.resource) === index,
|
|
|
- )
|
|
|
- if (external.length > 0)
|
|
|
- yield* permission.assert({
|
|
|
- action: "external_directory",
|
|
|
- resources: external.map((item) => item.resource),
|
|
|
- save: external.map((item) => item.save),
|
|
|
+ const unrestricted =
|
|
|
+ (yield* permission.allowsAll({
|
|
|
sessionID: context.sessionID,
|
|
|
- agent: context.agent,
|
|
|
- source,
|
|
|
- })
|
|
|
- if (parsed.commands.length > 0)
|
|
|
- yield* permission.assert({
|
|
|
action: name,
|
|
|
- resources: parsed.commands.map((command) => command.resource),
|
|
|
- save: parsed.commands.map((command) => command.save),
|
|
|
+ agent: context.agent,
|
|
|
+ })) &&
|
|
|
+ (yield* permission.allowsAll({
|
|
|
sessionID: context.sessionID,
|
|
|
+ action: "external_directory",
|
|
|
agent: context.agent,
|
|
|
- source,
|
|
|
- })
|
|
|
+ }))
|
|
|
+ invocation.cwd = target.absolute
|
|
|
+ finalTimeout = invocation.timeout
|
|
|
+ if (!unrestricted) {
|
|
|
+ const parsed = yield* ShellParse.scan(invocation.command, invocation.shell, target.absolute)
|
|
|
+ const directories = yield* Effect.forEach(parsed.directories, (directory) =>
|
|
|
+ mutation.resolve({ path: path.resolve(target.absolute, directory), kind: "directory" }),
|
|
|
+ )
|
|
|
+ const external = [target, ...directories]
|
|
|
+ .map((item) => item.externalDirectory)
|
|
|
+ .filter((item) => item !== undefined)
|
|
|
+ .filter(
|
|
|
+ (item, index, items) => items.findIndex((other) => other.resource === item.resource) === index,
|
|
|
+ )
|
|
|
+ if (external.length > 0)
|
|
|
+ yield* permission.assert({
|
|
|
+ action: "external_directory",
|
|
|
+ resources: external.map((item) => item.resource),
|
|
|
+ save: external.map((item) => item.save),
|
|
|
+ sessionID: context.sessionID,
|
|
|
+ agent: context.agent,
|
|
|
+ source,
|
|
|
+ })
|
|
|
+ if (parsed.commands.length > 0)
|
|
|
+ yield* permission.assert({
|
|
|
+ action: name,
|
|
|
+ resources: parsed.commands.map((command) => command.resource),
|
|
|
+ save: parsed.commands.map((command) => command.save),
|
|
|
+ sessionID: context.sessionID,
|
|
|
+ agent: context.agent,
|
|
|
+ source,
|
|
|
+ })
|
|
|
+ }
|
|
|
const workdir = yield* Environment.typeFollowing(environment.files, target.absolute).pipe(
|
|
|
Effect.catchTag("Environment.NotFound", () =>
|
|
|
Effect.fail(new Error(`Working directory does not exist: ${target.absolute}`)),
|