@webpieces/hook-runtime 0.4.1004 → 0.4.1006

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/hook-runtime",
3
- "version": "0.4.1004",
3
+ "version": "0.4.1006",
4
4
  "description": "Agent hook protocol, normalized events, and fail-closed application boundary.",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -22,16 +22,16 @@
22
22
  "dependencies": {
23
23
  "inversify": "7.10.4",
24
24
  "reflect-metadata": "0.2.2",
25
- "@webpieces/rules-config": "0.4.1004",
26
- "@webpieces/tooling-common": "0.4.1004",
25
+ "@webpieces/rules-config": "0.4.1006",
26
+ "@webpieces/tooling-common": "0.4.1006",
27
27
  "tslib": "2.8.1",
28
- "@webpieces/rules-sdk": "0.4.1004"
28
+ "@webpieces/rules-sdk": "0.4.1006"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public"
32
32
  },
33
33
  "devDependencies": {
34
- "@webpieces/tooling-testkit": "0.4.1004"
34
+ "@webpieces/tooling-testkit": "0.4.1006"
35
35
  },
36
36
  "types": "./src/index.d.ts"
37
37
  }
@@ -39,7 +39,10 @@ class CodexAdapter {
39
39
  kindOf(toolName) {
40
40
  if (toolName === CODEX_BASH)
41
41
  return 'Bash';
42
- if (toolName === CODEX_APPLY_PATCH)
42
+ // A namespace-qualified spelling (`functions.apply_patch`, `tools.apply_patch`) is the SAME edit
43
+ // tool — mapping it to `Ignored` would wave a write past every guard on a healthy tree. One
44
+ // canonicalizer, shared with L0's edit escape, so the two cannot recognise different names.
45
+ if (new rules_config_1.ConfigRepairAccess().canonicalTool(toolName) === CODEX_APPLY_PATCH)
43
46
  return 'File';
44
47
  return 'Ignored';
45
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"codex-adapter.js","sourceRoot":"","sources":["../../../../../../packages/tooling/hook-runtime/src/adapters/codex-adapter.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CAAC;QAC1H,MAAM,KAAK,GAAG,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1E,OAAO,IAAI,yBAAc,CACrB,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,SAAS,EAChC,GAAG,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE,EAAE,OAAO,CAAC,QAAQ,IAAI,EAAE,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE,EAC/E,KAAK,EAAE,IAAI,EAAE,KAAK,CACrB,CAAC;IACN,CAAC;IAEO,MAAM,CAAC,QAAgB;QAC3B,IAAI,QAAQ,KAAK,UAAU;YAAE,OAAO,MAAM,CAAC;QAC3C,IAAI,QAAQ,KAAK,iBAAiB;YAAE,OAAO,MAAM,CAAC;QAClD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AAjCD,oCAiCC","sourcesContent":["import { RepoRootFinder } from '@webpieces/rules-config';\n\nimport { AgentPayload } from './agent-payload';\nimport { AgentHookEvent, AgentEventKind } from '../protocol';\nimport { NormalizedBashInput } from '../protocol';\nimport { ApplyPatchParser } from '../core/apply-patch-parse';\nimport { ShellReadParity } from '../core/shell-read-parity';\n\n/** Codex's shell tool. MEASURED: it reuses Claude's name — it is `Bash`, NOT `shell`. */\nconst CODEX_BASH = 'Bash';\n/** Codex's ONLY file-editing tool. One envelope, many files, mixed operations. */\nconst CODEX_APPLY_PATCH = 'apply_patch';\n\n/**\n * Morphs a Codex PreToolUse payload into the one normalized `AgentHookEvent`.\n *\n * Codex exposes exactly two tools this hook has anything to say about. Everything else measured in a\n * live session — `webrun`, `collaborationspawn_agent`, `collaborationwait_agent`, `view_image`,\n * `update_plan` — and every tool not yet seen maps to `Ignored` and is allowed immediately. That\n * default is chosen on purpose: an unknown tool is one we cannot judge, and inventing a mapping for it\n * would apply file rules to bytes that are not a file edit.\n */\nexport class CodexAdapter {\n private readonly patchParser = new ApplyPatchParser();\n private readonly readParity = new ShellReadParity();\n\n /** See ClaudeCodeAdapter.envelope — the pre-normalization shape the crash deny needs. */\n envelope(payload: AgentPayload): AgentHookEvent {\n return new AgentHookEvent(\n 'codex', this.kindOf(payload.tool_name), payload.tool_name,\n payload.cwd ?? '', payload.session_id ?? '', payload.agent_id ?? '', payload.agent_type ?? '',\n [], null, [],\n );\n }\n\n toEvent(payload: AgentPayload, cwd: string): AgentHookEvent {\n const kind = this.kindOf(payload.tool_name);\n const command = payload.tool_input.command ?? '';\n const bash = kind === 'Bash' ? new NormalizedBashInput(command) : null;\n // Read parity: Codex has no Read tool, so a read arrives as `Bash` running a pager. Synthesized\n // reads run the read guard IN ADDITION to the bash guards — see ../core/shell-read-parity.ts.\n const reads = kind === 'Bash' ? this.readParity.readTargets(command, cwd, new RepoRootFinder().resolveRepoRoot(cwd)) : [];\n const files = kind === 'File' ? this.patchParser.parse(command, cwd) : [];\n return new AgentHookEvent(\n 'codex', kind, payload.tool_name,\n cwd, payload.session_id ?? '', payload.agent_id ?? '', payload.agent_type ?? '',\n files, bash, reads,\n );\n }\n\n private kindOf(toolName: string): AgentEventKind {\n if (toolName === CODEX_BASH) return 'Bash';\n if (toolName === CODEX_APPLY_PATCH) return 'File';\n return 'Ignored';\n }\n}\n"]}
1
+ {"version":3,"file":"codex-adapter.js","sourceRoot":"","sources":["../../../../../../packages/tooling/hook-runtime/src/adapters/codex-adapter.ts"],"names":[],"mappings":";;;AAAA,0DAA6E;AAG7E,0CAA6D;AAC7D,0CAAkD;AAClD,iEAA6D;AAC7D,iEAA4D;AAE5D,yFAAyF;AACzF,MAAM,UAAU,GAAG,MAAM,CAAC;AAC1B,kFAAkF;AAClF,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAExC;;;;;;;;GAQG;AACH,MAAa,YAAY;IACJ,WAAW,GAAG,IAAI,oCAAgB,EAAE,CAAC;IACrC,UAAU,GAAG,IAAI,mCAAe,EAAE,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E,OAAO,CAAC,UAAU,IAAI,EAAE,EAC/E,KAAK,EAAE,IAAI,EAAE,KAAK,CACrB,CAAC;IACN,CAAC;IAEO,MAAM,CAAC,QAAgB;QAC3B,IAAI,QAAQ,KAAK,UAAU;YAAE,OAAO,MAAM,CAAC;QAC3C,iGAAiG;QACjG,4FAA4F;QAC5F,4FAA4F;QAC5F,IAAI,IAAI,iCAAkB,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,iBAAiB;YAAE,OAAO,MAAM,CAAC;QAC1F,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AApCD,oCAoCC","sourcesContent":["import { ConfigRepairAccess, RepoRootFinder } from '@webpieces/rules-config';\n\nimport { AgentPayload } from './agent-payload';\nimport { AgentHookEvent, AgentEventKind } from '../protocol';\nimport { NormalizedBashInput } from '../protocol';\nimport { ApplyPatchParser } from '../core/apply-patch-parse';\nimport { ShellReadParity } from '../core/shell-read-parity';\n\n/** Codex's shell tool. MEASURED: it reuses Claude's name — it is `Bash`, NOT `shell`. */\nconst CODEX_BASH = 'Bash';\n/** Codex's ONLY file-editing tool. One envelope, many files, mixed operations. */\nconst CODEX_APPLY_PATCH = 'apply_patch';\n\n/**\n * Morphs a Codex PreToolUse payload into the one normalized `AgentHookEvent`.\n *\n * Codex exposes exactly two tools this hook has anything to say about. Everything else measured in a\n * live session — `webrun`, `collaborationspawn_agent`, `collaborationwait_agent`, `view_image`,\n * `update_plan` — and every tool not yet seen maps to `Ignored` and is allowed immediately. That\n * default is chosen on purpose: an unknown tool is one we cannot judge, and inventing a mapping for it\n * would apply file rules to bytes that are not a file edit.\n */\nexport class CodexAdapter {\n private readonly patchParser = new ApplyPatchParser();\n private readonly readParity = new ShellReadParity();\n\n /** See ClaudeCodeAdapter.envelope — the pre-normalization shape the crash deny needs. */\n envelope(payload: AgentPayload): AgentHookEvent {\n return new AgentHookEvent(\n 'codex', this.kindOf(payload.tool_name), payload.tool_name,\n payload.cwd ?? '', payload.session_id ?? '', payload.agent_id ?? '', payload.agent_type ?? '',\n [], null, [],\n );\n }\n\n toEvent(payload: AgentPayload, cwd: string): AgentHookEvent {\n const kind = this.kindOf(payload.tool_name);\n const command = payload.tool_input.command ?? '';\n const bash = kind === 'Bash' ? new NormalizedBashInput(command) : null;\n // Read parity: Codex has no Read tool, so a read arrives as `Bash` running a pager. Synthesized\n // reads run the read guard IN ADDITION to the bash guards — see ../core/shell-read-parity.ts.\n const reads = kind === 'Bash' ? this.readParity.readTargets(command, cwd, new RepoRootFinder().resolveRepoRoot(cwd)) : [];\n const files = kind === 'File' ? this.patchParser.parse(command, cwd) : [];\n return new AgentHookEvent(\n 'codex', kind, payload.tool_name,\n cwd, payload.session_id ?? '', payload.agent_id ?? '', payload.agent_type ?? '',\n files, bash, reads,\n );\n }\n\n private kindOf(toolName: string): AgentEventKind {\n if (toolName === CODEX_BASH) return 'Bash';\n // A namespace-qualified spelling (`functions.apply_patch`, `tools.apply_patch`) is the SAME edit\n // tool — mapping it to `Ignored` would wave a write past every guard on a healthy tree. One\n // canonicalizer, shared with L0's edit escape, so the two cannot recognise different names.\n if (new ConfigRepairAccess().canonicalTool(toolName) === CODEX_APPLY_PATCH) return 'File';\n return 'Ignored';\n }\n}\n"]}
@@ -23,9 +23,11 @@ class HookFileEvaluation {
23
23
  evaluate(toolKind, input, loaded, contributions) {
24
24
  if (loaded.configPath === null)
25
25
  return null;
26
- if (path.resolve(input.filePath) === path.resolve(loaded.configPath) ||
27
- (0, root_manifest_1.isRootManifest)(input.filePath) ||
28
- new rules_config_1.HomeConfigService().isHomeConfigPath(input.filePath))
26
+ // In-place only: a Move ONTO an exempt file still deletes its source, which must be judged (#1448).
27
+ if (input.sourcePath === input.filePath &&
28
+ (path.resolve(input.filePath) === path.resolve(loaded.configPath) ||
29
+ (0, root_manifest_1.isRootManifest)(input.filePath) ||
30
+ new rules_config_1.HomeConfigService().isHomeConfigPath(input.filePath)))
29
31
  return null;
30
32
  const root = path.dirname(loaded.configPath);
31
33
  const governed = new target_tree_1.TargetTreeResolver().governedPath(input.filePath, root);
@@ -1 +1 @@
1
- {"version":3,"file":"file-evaluation.js","sourceRoot":"","sources":["../../../../../../packages/tooling/hook-runtime/src/core/file-evaluation.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,0DAA0E;AAE1E,mCAA8C;AAE9C,+CAAmD;AACnD,+DAA0D;AAC1D,qDAAyD;AACzD,mDAAgD;AAChD,uDAA+D;AAC/D,qCAAwC;AACxC,mDAAiD;AAEjD,MAAa,WAAW;IACC;IAArB,YAAqB,KAAsB;QAAtB,UAAK,GAAL,KAAK,CAAiB;IAAG,CAAC;CAClD;AAFD,kCAEC;AAED,MAAa,kBAAkB;IAC3B,QAAQ,CACJ,QAAkB,EAClB,KAA0B,EAC1B,MAAoB,EACpB,aAA0B;QAE1B,IAAI,MAAM,CAAC,UAAU,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAC5C,IACI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC;YAChE,IAAA,8BAAc,EAAC,KAAK,CAAC,QAAQ,CAAC;YAC9B,IAAI,gCAAiB,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC;YAExD,OAAO,IAAI,CAAC;QAChB,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC7C,MAAM,QAAQ,GAAG,IAAI,gCAAkB,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC7E,MAAM,KAAK,GAAG,IAAI,uCAAiB,EAAE,CAAC,MAAM,CACxC,QAAQ,EACR,IAAA,sCAAqB,EAAC,aAAa,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,YAAY,CAAC,CAC5E,CAAC;QACF,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QACpC,MAAM,QAAQ,GAAG,IAAA,6BAAa,EAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAChE,MAAM,MAAM,GAAG;YACX,GAAG,IAAA,8BAAY,EAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC;YAC7C,GAAG,IAAA,8BAAY,EAAC,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC;SAC/C,CAAC;QACF,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC;YACtB,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,IAAI,qBAAa,CAAC,IAAA,qBAAY,EAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;IACzE,CAAC;CACJ;AA9BD,gDA8BC","sourcesContent":["import * as path from 'path';\nimport { LoadedConfig, HomeConfigService } from '@webpieces/rules-config';\nimport { ToolKind, NormalizedToolInput } from '../protocol';\nimport { Rule, BlockedResult } from './types';\n\nimport { TargetTreeResolver } from './target-tree';\nimport { DeleteScopedRules } from './delete-scoped-rules';\nimport { filterByExcludedPaths } from './excluded-paths';\nimport { buildContexts } from './build-context';\nimport { runEditRules, runFileRules } from './rule-evaluation';\nimport { formatReport } from './report';\nimport { isRootManifest } from './root-manifest';\n\nexport class HookRuleSet {\n constructor(readonly rules: readonly Rule[]) {}\n}\n\nexport class HookFileEvaluation {\n evaluate(\n toolKind: ToolKind,\n input: NormalizedToolInput,\n loaded: LoadedConfig,\n contributions: HookRuleSet,\n ): BlockedResult | null {\n if (loaded.configPath === null) return null;\n if (\n path.resolve(input.filePath) === path.resolve(loaded.configPath) ||\n isRootManifest(input.filePath) ||\n new HomeConfigService().isHomeConfigPath(input.filePath)\n )\n return null;\n const root = path.dirname(loaded.configPath);\n const governed = new TargetTreeResolver().governedPath(input.filePath, root);\n const rules = new DeleteScopedRules().narrow(\n toolKind,\n filterByExcludedPaths(contributions.rules, governed, loaded.excludePaths),\n );\n if (rules.length === 0) return null;\n const contexts = buildContexts(toolKind, input, root, governed);\n const groups = [\n ...runEditRules(rules, contexts.editContexts),\n ...runFileRules(rules, contexts.fileContext),\n ];\n return groups.length === 0\n ? null\n : new BlockedResult(formatReport(governed.relativePath, groups));\n }\n}\n"]}
1
+ {"version":3,"file":"file-evaluation.js","sourceRoot":"","sources":["../../../../../../packages/tooling/hook-runtime/src/core/file-evaluation.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,0DAA0E;AAE1E,mCAA8C;AAE9C,+CAAmD;AACnD,+DAA0D;AAC1D,qDAAyD;AACzD,mDAAgD;AAChD,uDAA+D;AAC/D,qCAAwC;AACxC,mDAAiD;AAEjD,MAAa,WAAW;IACC;IAArB,YAAqB,KAAsB;QAAtB,UAAK,GAAL,KAAK,CAAiB;IAAG,CAAC;CAClD;AAFD,kCAEC;AAED,MAAa,kBAAkB;IAC3B,QAAQ,CACJ,QAAkB,EAClB,KAA0B,EAC1B,MAAoB,EACpB,aAA0B;QAE1B,IAAI,MAAM,CAAC,UAAU,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAC5C,oGAAoG;QACpG,IACI,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,QAAQ;YACnC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC;gBAC7D,IAAA,8BAAc,EAAC,KAAK,CAAC,QAAQ,CAAC;gBAC9B,IAAI,gCAAiB,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAE7D,OAAO,IAAI,CAAC;QAChB,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC7C,MAAM,QAAQ,GAAG,IAAI,gCAAkB,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC7E,MAAM,KAAK,GAAG,IAAI,uCAAiB,EAAE,CAAC,MAAM,CACxC,QAAQ,EACR,IAAA,sCAAqB,EAAC,aAAa,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,YAAY,CAAC,CAC5E,CAAC;QACF,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QACpC,MAAM,QAAQ,GAAG,IAAA,6BAAa,EAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAChE,MAAM,MAAM,GAAG;YACX,GAAG,IAAA,8BAAY,EAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC;YAC7C,GAAG,IAAA,8BAAY,EAAC,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC;SAC/C,CAAC;QACF,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC;YACtB,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,IAAI,qBAAa,CAAC,IAAA,qBAAY,EAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;IACzE,CAAC;CACJ;AAhCD,gDAgCC","sourcesContent":["import * as path from 'path';\nimport { LoadedConfig, HomeConfigService } from '@webpieces/rules-config';\nimport { ToolKind, NormalizedToolInput } from '../protocol';\nimport { Rule, BlockedResult } from './types';\n\nimport { TargetTreeResolver } from './target-tree';\nimport { DeleteScopedRules } from './delete-scoped-rules';\nimport { filterByExcludedPaths } from './excluded-paths';\nimport { buildContexts } from './build-context';\nimport { runEditRules, runFileRules } from './rule-evaluation';\nimport { formatReport } from './report';\nimport { isRootManifest } from './root-manifest';\n\nexport class HookRuleSet {\n constructor(readonly rules: readonly Rule[]) {}\n}\n\nexport class HookFileEvaluation {\n evaluate(\n toolKind: ToolKind,\n input: NormalizedToolInput,\n loaded: LoadedConfig,\n contributions: HookRuleSet,\n ): BlockedResult | null {\n if (loaded.configPath === null) return null;\n // In-place only: a Move ONTO an exempt file still deletes its source, which must be judged (#1448).\n if (\n input.sourcePath === input.filePath &&\n (path.resolve(input.filePath) === path.resolve(loaded.configPath) ||\n isRootManifest(input.filePath) ||\n new HomeConfigService().isHomeConfigPath(input.filePath))\n )\n return null;\n const root = path.dirname(loaded.configPath);\n const governed = new TargetTreeResolver().governedPath(input.filePath, root);\n const rules = new DeleteScopedRules().narrow(\n toolKind,\n filterByExcludedPaths(contributions.rules, governed, loaded.excludePaths),\n );\n if (rules.length === 0) return null;\n const contexts = buildContexts(toolKind, input, root, governed);\n const groups = [\n ...runEditRules(rules, contexts.editContexts),\n ...runFileRules(rules, contexts.fileContext),\n ];\n return groups.length === 0\n ? null\n : new BlockedResult(formatReport(governed.relativePath, groups));\n }\n}\n"]}