@provos/ironcurtain 0.7.2 → 0.9.0

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.
Files changed (259) hide show
  1. package/README.md +29 -100
  2. package/dist/auth/auth-command.d.ts +15 -0
  3. package/dist/auth/auth-command.js +424 -0
  4. package/dist/auth/auth-command.js.map +1 -0
  5. package/dist/auth/oauth-flow.d.ts +46 -0
  6. package/dist/auth/oauth-flow.js +279 -0
  7. package/dist/auth/oauth-flow.js.map +1 -0
  8. package/dist/auth/oauth-provider.d.ts +55 -0
  9. package/dist/auth/oauth-provider.js +73 -0
  10. package/dist/auth/oauth-provider.js.map +1 -0
  11. package/dist/auth/oauth-registry.d.ts +34 -0
  12. package/dist/auth/oauth-registry.js +69 -0
  13. package/dist/auth/oauth-registry.js.map +1 -0
  14. package/dist/auth/oauth-token-provider.d.ts +52 -0
  15. package/dist/auth/oauth-token-provider.js +159 -0
  16. package/dist/auth/oauth-token-provider.js.map +1 -0
  17. package/dist/auth/oauth-token-store.d.ts +30 -0
  18. package/dist/auth/oauth-token-store.js +93 -0
  19. package/dist/auth/oauth-token-store.js.map +1 -0
  20. package/dist/auth/providers/google-scopes.d.ts +35 -0
  21. package/dist/auth/providers/google-scopes.js +183 -0
  22. package/dist/auth/providers/google-scopes.js.map +1 -0
  23. package/dist/auth/providers/google.d.ts +2 -0
  24. package/dist/auth/providers/google.js +28 -0
  25. package/dist/auth/providers/google.js.map +1 -0
  26. package/dist/cli.js +6 -0
  27. package/dist/cli.js.map +1 -1
  28. package/dist/config/config-command.js +39 -1
  29. package/dist/config/config-command.js.map +1 -1
  30. package/dist/config/constitution-readonly.md +14 -11
  31. package/dist/config/constitution-user-base.md +15 -0
  32. package/dist/config/first-start.js +4 -1
  33. package/dist/config/first-start.js.map +1 -1
  34. package/dist/config/generated/test-scenarios.json +1 -1
  35. package/dist/config/generated/tool-annotations.json +10617 -296
  36. package/dist/config/generated-readonly/compiled-policy.json +787 -244
  37. package/dist/config/index.d.ts +2 -2
  38. package/dist/config/index.js +8 -0
  39. package/dist/config/index.js.map +1 -1
  40. package/dist/config/mcp-servers.json +31 -2
  41. package/dist/config/paths.d.ts +20 -0
  42. package/dist/config/paths.js +43 -0
  43. package/dist/config/paths.js.map +1 -1
  44. package/dist/config/types.d.ts +8 -0
  45. package/dist/config/user-config.d.ts +29 -0
  46. package/dist/config/user-config.js +30 -0
  47. package/dist/config/user-config.js.map +1 -1
  48. package/dist/cron/constitution-generator.d.ts +2 -1
  49. package/dist/cron/constitution-generator.js +35 -36
  50. package/dist/cron/constitution-generator.js.map +1 -1
  51. package/dist/cron/headless-transport.d.ts +4 -0
  52. package/dist/cron/headless-transport.js +1 -1
  53. package/dist/cron/headless-transport.js.map +1 -1
  54. package/dist/daemon/ironcurtain-daemon.js +7 -1
  55. package/dist/daemon/ironcurtain-daemon.js.map +1 -1
  56. package/dist/docker/adapters/claude-code.js +32 -5
  57. package/dist/docker/adapters/claude-code.js.map +1 -1
  58. package/dist/docker/agent-adapter.d.ts +40 -0
  59. package/dist/docker/claude-md-seed.d.ts +27 -0
  60. package/dist/docker/claude-md-seed.js +42 -0
  61. package/dist/docker/claude-md-seed.js.map +1 -0
  62. package/dist/docker/docker-agent-session.d.ts +3 -1
  63. package/dist/docker/docker-agent-session.js +51 -28
  64. package/dist/docker/docker-agent-session.js.map +1 -1
  65. package/dist/docker/docker-infrastructure.d.ts +15 -1
  66. package/dist/docker/docker-infrastructure.js +105 -9
  67. package/dist/docker/docker-infrastructure.js.map +1 -1
  68. package/dist/docker/docker-manager.d.ts +2 -0
  69. package/dist/docker/docker-manager.js +9 -1
  70. package/dist/docker/docker-manager.js.map +1 -1
  71. package/dist/docker/mitm-proxy.d.ts +65 -0
  72. package/dist/docker/mitm-proxy.js +288 -31
  73. package/dist/docker/mitm-proxy.js.map +1 -1
  74. package/dist/docker/package-types.d.ts +127 -0
  75. package/dist/docker/package-types.js +8 -0
  76. package/dist/docker/package-types.js.map +1 -0
  77. package/dist/docker/package-validator.d.ts +41 -0
  78. package/dist/docker/package-validator.js +90 -0
  79. package/dist/docker/package-validator.js.map +1 -0
  80. package/dist/docker/platform.d.ts +6 -6
  81. package/dist/docker/platform.js +8 -6
  82. package/dist/docker/platform.js.map +1 -1
  83. package/dist/docker/proxy-tools.d.ts +80 -0
  84. package/dist/docker/proxy-tools.js +248 -0
  85. package/dist/docker/proxy-tools.js.map +1 -0
  86. package/dist/docker/pty-session.d.ts +15 -0
  87. package/dist/docker/pty-session.js +253 -73
  88. package/dist/docker/pty-session.js.map +1 -1
  89. package/dist/docker/pty-types.d.ts +28 -0
  90. package/dist/docker/pty-types.js +2 -0
  91. package/dist/docker/pty-types.js.map +1 -1
  92. package/dist/docker/registry-proxy.d.ts +142 -0
  93. package/dist/docker/registry-proxy.js +856 -0
  94. package/dist/docker/registry-proxy.js.map +1 -0
  95. package/dist/escalation/escalation-watcher.d.ts +3 -1
  96. package/dist/escalation/escalation-watcher.js +6 -2
  97. package/dist/escalation/escalation-watcher.js.map +1 -1
  98. package/dist/escalation/listener-command.js +24 -10
  99. package/dist/escalation/listener-command.js.map +1 -1
  100. package/dist/escalation/listener-lock.d.ts +5 -0
  101. package/dist/escalation/listener-lock.js +14 -0
  102. package/dist/escalation/listener-lock.js.map +1 -1
  103. package/dist/index.js +16 -3
  104. package/dist/index.js.map +1 -1
  105. package/dist/memory/auto-save.d.ts +25 -0
  106. package/dist/memory/auto-save.js +89 -0
  107. package/dist/memory/auto-save.js.map +1 -0
  108. package/dist/memory/memory-annotations.d.ts +47 -0
  109. package/dist/memory/memory-annotations.js +87 -0
  110. package/dist/memory/memory-annotations.js.map +1 -0
  111. package/dist/memory/memory-prompt.d.ts +12 -0
  112. package/dist/memory/memory-prompt.js +20 -0
  113. package/dist/memory/memory-prompt.js.map +1 -0
  114. package/dist/memory/resolve-memory-path.d.ts +20 -0
  115. package/dist/memory/resolve-memory-path.js +30 -0
  116. package/dist/memory/resolve-memory-path.js.map +1 -0
  117. package/dist/mux/mux-app.d.ts +4 -0
  118. package/dist/mux/mux-app.js +246 -28
  119. package/dist/mux/mux-app.js.map +1 -1
  120. package/dist/mux/mux-command.d.ts +2 -2
  121. package/dist/mux/mux-command.js +14 -22
  122. package/dist/mux/mux-command.js.map +1 -1
  123. package/dist/mux/mux-escalation-manager.d.ts +9 -3
  124. package/dist/mux/mux-escalation-manager.js +69 -19
  125. package/dist/mux/mux-escalation-manager.js.map +1 -1
  126. package/dist/mux/mux-input-handler.d.ts +59 -3
  127. package/dist/mux/mux-input-handler.js +270 -32
  128. package/dist/mux/mux-input-handler.js.map +1 -1
  129. package/dist/mux/mux-renderer.d.ts +19 -1
  130. package/dist/mux/mux-renderer.js +466 -11
  131. package/dist/mux/mux-renderer.js.map +1 -1
  132. package/dist/mux/persona-scanner.d.ts +19 -0
  133. package/dist/mux/persona-scanner.js +53 -0
  134. package/dist/mux/persona-scanner.js.map +1 -0
  135. package/dist/mux/pty-bridge.d.ts +8 -0
  136. package/dist/mux/pty-bridge.js +19 -1
  137. package/dist/mux/pty-bridge.js.map +1 -1
  138. package/dist/mux/session-scanner.d.ts +18 -0
  139. package/dist/mux/session-scanner.js +65 -0
  140. package/dist/mux/session-scanner.js.map +1 -0
  141. package/dist/mux/types.d.ts +36 -1
  142. package/dist/mux/types.js +14 -1
  143. package/dist/mux/types.js.map +1 -1
  144. package/dist/persona/persona-command.js +130 -93
  145. package/dist/persona/persona-command.js.map +1 -1
  146. package/dist/persona/persona-prompt.d.ts +7 -7
  147. package/dist/persona/persona-prompt.js +14 -29
  148. package/dist/persona/persona-prompt.js.map +1 -1
  149. package/dist/persona/resolve.js +5 -2
  150. package/dist/persona/resolve.js.map +1 -1
  151. package/dist/pipeline/annotate.js +1 -7
  152. package/dist/pipeline/annotate.js.map +1 -1
  153. package/dist/pipeline/compile.d.ts +5 -2
  154. package/dist/pipeline/compile.js +23 -11
  155. package/dist/pipeline/compile.js.map +1 -1
  156. package/dist/pipeline/constitution-compiler.d.ts +302 -3
  157. package/dist/pipeline/constitution-compiler.js +285 -23
  158. package/dist/pipeline/constitution-compiler.js.map +1 -1
  159. package/dist/pipeline/generate-with-repair.d.ts +2 -2
  160. package/dist/pipeline/generate-with-repair.js +2 -2
  161. package/dist/pipeline/handwritten-scenarios.d.ts +20 -7
  162. package/dist/pipeline/handwritten-scenarios.js +20 -41
  163. package/dist/pipeline/handwritten-scenarios.js.map +1 -1
  164. package/dist/pipeline/list-resolver.d.ts +18 -20
  165. package/dist/pipeline/list-resolver.js +28 -36
  166. package/dist/pipeline/list-resolver.js.map +1 -1
  167. package/dist/pipeline/pipeline-runner.d.ts +102 -13
  168. package/dist/pipeline/pipeline-runner.js +497 -237
  169. package/dist/pipeline/pipeline-runner.js.map +1 -1
  170. package/dist/pipeline/pipeline-shared.d.ts +7 -9
  171. package/dist/pipeline/pipeline-shared.js +8 -18
  172. package/dist/pipeline/pipeline-shared.js.map +1 -1
  173. package/dist/pipeline/policy-verifier.d.ts +32 -5
  174. package/dist/pipeline/policy-verifier.js +137 -8
  175. package/dist/pipeline/policy-verifier.js.map +1 -1
  176. package/dist/pipeline/proxy-mcp-connections.d.ts +25 -0
  177. package/dist/pipeline/proxy-mcp-connections.js +121 -0
  178. package/dist/pipeline/proxy-mcp-connections.js.map +1 -0
  179. package/dist/pipeline/refresh-lists.js +21 -13
  180. package/dist/pipeline/refresh-lists.js.map +1 -1
  181. package/dist/pipeline/scenario-generator.d.ts +29 -49
  182. package/dist/pipeline/scenario-generator.js +180 -143
  183. package/dist/pipeline/scenario-generator.js.map +1 -1
  184. package/dist/pipeline/scenario-schema-validator.d.ts +51 -0
  185. package/dist/pipeline/scenario-schema-validator.js +132 -0
  186. package/dist/pipeline/scenario-schema-validator.js.map +1 -0
  187. package/dist/pipeline/tool-annotator.d.ts +9 -8
  188. package/dist/pipeline/tool-annotator.js +48 -95
  189. package/dist/pipeline/tool-annotator.js.map +1 -1
  190. package/dist/pipeline/types.d.ts +31 -24
  191. package/dist/sandbox/index.d.ts +26 -10
  192. package/dist/sandbox/index.js +151 -40
  193. package/dist/sandbox/index.js.map +1 -1
  194. package/dist/servers/fetch-server.js +10 -5
  195. package/dist/servers/fetch-server.js.map +1 -1
  196. package/dist/session/agent-session.d.ts +8 -20
  197. package/dist/session/agent-session.js +22 -70
  198. package/dist/session/agent-session.js.map +1 -1
  199. package/dist/session/base-transport.d.ts +17 -1
  200. package/dist/session/base-transport.js +25 -1
  201. package/dist/session/base-transport.js.map +1 -1
  202. package/dist/session/cli-transport.d.ts +5 -0
  203. package/dist/session/cli-transport.js +48 -25
  204. package/dist/session/cli-transport.js.map +1 -1
  205. package/dist/session/index.d.ts +25 -1
  206. package/dist/session/index.js +57 -8
  207. package/dist/session/index.js.map +1 -1
  208. package/dist/session/prompts.js +8 -9
  209. package/dist/session/prompts.js.map +1 -1
  210. package/dist/session/session-manager.d.ts +6 -0
  211. package/dist/session/session-manager.js +12 -0
  212. package/dist/session/session-manager.js.map +1 -1
  213. package/dist/session/types.d.ts +11 -1
  214. package/dist/session/types.js.map +1 -1
  215. package/dist/session/workspace-validation.js +37 -6
  216. package/dist/session/workspace-validation.js.map +1 -1
  217. package/dist/signal/signal-bot-daemon.js +24 -8
  218. package/dist/signal/signal-bot-daemon.js.map +1 -1
  219. package/dist/signal/signal-transport.d.ts +5 -2
  220. package/dist/signal/signal-transport.js +3 -3
  221. package/dist/signal/signal-transport.js.map +1 -1
  222. package/dist/trusted-process/approval-whitelist.d.ts +117 -0
  223. package/dist/trusted-process/approval-whitelist.js +237 -0
  224. package/dist/trusted-process/approval-whitelist.js.map +1 -0
  225. package/dist/trusted-process/gworkspace-credentials.d.ts +40 -0
  226. package/dist/trusted-process/gworkspace-credentials.js +45 -0
  227. package/dist/trusted-process/gworkspace-credentials.js.map +1 -0
  228. package/dist/trusted-process/index.d.ts +11 -1
  229. package/dist/trusted-process/index.js +83 -53
  230. package/dist/trusted-process/index.js.map +1 -1
  231. package/dist/trusted-process/mcp-proxy-server.d.ts +23 -0
  232. package/dist/trusted-process/mcp-proxy-server.js +409 -94
  233. package/dist/trusted-process/mcp-proxy-server.js.map +1 -1
  234. package/dist/trusted-process/policy-engine.d.ts +12 -3
  235. package/dist/trusted-process/policy-engine.js +33 -23
  236. package/dist/trusted-process/policy-engine.js.map +1 -1
  237. package/dist/trusted-process/policy-types.d.ts +17 -0
  238. package/dist/trusted-process/sandbox-integration.d.ts +23 -0
  239. package/dist/trusted-process/sandbox-integration.js +115 -3
  240. package/dist/trusted-process/sandbox-integration.js.map +1 -1
  241. package/dist/trusted-process/token-file-refresher.d.ts +69 -0
  242. package/dist/trusted-process/token-file-refresher.js +120 -0
  243. package/dist/trusted-process/token-file-refresher.js.map +1 -0
  244. package/dist/types/argument-roles.d.ts +7 -1
  245. package/dist/types/argument-roles.js +50 -0
  246. package/dist/types/argument-roles.js.map +1 -1
  247. package/dist/types/audit.d.ts +11 -0
  248. package/docker/Dockerfile.base +22 -0
  249. package/docker/Dockerfile.base.arm64 +44 -4
  250. package/docker/Dockerfile.claude-code +2 -2
  251. package/docker/entrypoint-claude-code.sh +24 -6
  252. package/package.json +8 -2
  253. package/src/config/constitution-user-base.md +15 -0
  254. package/src/config/generated/test-scenarios.json +1 -1
  255. package/src/config/generated/tool-annotations.json +10617 -296
  256. package/src/config/mcp-servers.json +31 -2
  257. package/dist/pipeline/mcp-connections.d.ts +0 -16
  258. package/dist/pipeline/mcp-connections.js +0 -61
  259. package/dist/pipeline/mcp-connections.js.map +0 -1
@@ -17,9 +17,9 @@ export class SignalSessionTransport extends BaseTransport {
17
17
  exitResolve = null;
18
18
  /** Session label assigned by the daemon after construction. */
19
19
  sessionLabel = 0;
20
- constructor(daemon) {
21
- super();
22
- this.daemon = daemon;
20
+ constructor(options) {
21
+ super(options);
22
+ this.daemon = options.daemon;
23
23
  }
24
24
  /**
25
25
  * Implements the session lifecycle. The returned promise resolves when
@@ -1 +1 @@
1
- {"version":3,"file":"signal-transport.js","sourceRoot":"","sources":["../../src/signal/sign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ACV,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC;YAChC,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;YAC1C,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,KAAK,mCAAmC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAC/F,CAAC,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Ephemeral approval whitelist -- session-scoped in-memory store
3
+ * of approval patterns extracted from user-approved escalations.
4
+ *
5
+ * Security invariant: only converts escalate -> allow, never overrides deny.
6
+ * Entries are never persisted to disk.
7
+ */
8
+ import type { ArgumentRole } from '../types/argument-roles.js';
9
+ import type { ToolAnnotation } from '../pipeline/types.js';
10
+ /** Unique identifier for a whitelist entry, for audit trail linkage. */
11
+ export type WhitelistEntryId = string & {
12
+ readonly __brand: 'WhitelistEntryId';
13
+ };
14
+ /**
15
+ * A constraint on a single argument role's value.
16
+ * Discriminated union by `kind`.
17
+ */
18
+ export type WhitelistConstraint = {
19
+ readonly kind: 'directory';
20
+ readonly role: ArgumentRole;
21
+ /** Resolved real path of the containing directory. */
22
+ readonly directory: string;
23
+ } | {
24
+ readonly kind: 'domain';
25
+ readonly role: ArgumentRole;
26
+ /** Extracted domain (e.g., "github.com"). */
27
+ readonly domain: string;
28
+ } | {
29
+ readonly kind: 'exact';
30
+ readonly role: ArgumentRole;
31
+ /** Exact value to match (case-insensitive for identifier roles). */
32
+ readonly value: string;
33
+ };
34
+ /**
35
+ * A whitelist pattern extracted from an approved escalation.
36
+ * Matches future calls to the same server/tool with arguments
37
+ * satisfying all constraints.
38
+ */
39
+ export interface WhitelistPattern {
40
+ readonly id: WhitelistEntryId;
41
+ readonly serverName: string;
42
+ readonly toolName: string;
43
+ readonly constraints: readonly WhitelistConstraint[];
44
+ /** ISO 8601 timestamp when the pattern was created. */
45
+ readonly createdAt: string;
46
+ /** The escalation ID that produced this pattern (for audit linkage). */
47
+ readonly sourceEscalationId: string;
48
+ /** The original escalation reason (preserved for audit). */
49
+ readonly originalReason: string;
50
+ /** Human-readable description of the pattern. */
51
+ readonly description: string;
52
+ }
53
+ /**
54
+ * JSON-serializable candidate description for IPC.
55
+ * Included in the escalation request file so the user sees
56
+ * exactly what will be whitelisted.
57
+ */
58
+ export interface WhitelistCandidateIpc {
59
+ /** Human-readable summary, e.g. "Allow write_file within /home/user/Documents" */
60
+ readonly description: string;
61
+ /** Warning for zero-constraint side-effectful patterns. */
62
+ readonly warning?: string;
63
+ }
64
+ /**
65
+ * Result of a whitelist match check.
66
+ */
67
+ export type WhitelistMatchResult = {
68
+ readonly matched: false;
69
+ } | {
70
+ readonly matched: true;
71
+ readonly patternId: WhitelistEntryId;
72
+ readonly pattern: WhitelistPattern;
73
+ };
74
+ /** Default whitelist options: select the first (and currently only) candidate. */
75
+ export declare const DEFAULT_WHITELIST_OPTIONS: {
76
+ readonly whitelistSelection: 0;
77
+ };
78
+ /**
79
+ * The ephemeral whitelist store. Session-scoped, in-memory only.
80
+ */
81
+ export interface ApprovalWhitelist {
82
+ /**
83
+ * Adds a pattern to the whitelist.
84
+ * Returns the pattern ID for audit linkage.
85
+ */
86
+ add(pattern: Omit<WhitelistPattern, 'id'>): WhitelistEntryId;
87
+ /**
88
+ * Checks whether a tool call matches any whitelist pattern.
89
+ * Returns the matching pattern if found.
90
+ */
91
+ match(serverName: string, toolName: string, resolvedArgs: Record<string, unknown>, annotation: ToolAnnotation): WhitelistMatchResult;
92
+ /** Returns all active patterns (for diagnostics/testing). */
93
+ entries(): readonly WhitelistPattern[];
94
+ /** Number of active patterns. */
95
+ readonly size: number;
96
+ }
97
+ /**
98
+ * Extracts whitelist candidate patterns from an escalated tool call.
99
+ *
100
+ * Only generates constraints for the role(s) that caused the escalation,
101
+ * as identified by `escalatedRoles` on the EvaluationResult.
102
+ *
103
+ * Falls back to all resource-identifier roles when `escalatedRoles` is
104
+ * undefined (defensive robustness for future structural escalation paths).
105
+ *
106
+ * Returns both:
107
+ * - WhitelistPattern[] (full patterns, stored in proxy memory -- without id, added on whitelist.add())
108
+ * - WhitelistCandidateIpc[] (descriptions, serialized into IPC file)
109
+ */
110
+ export declare function extractWhitelistCandidates(serverName: string, toolName: string, args: Record<string, unknown>, annotation: ToolAnnotation, escalatedRoles: readonly ArgumentRole[] | undefined, escalationId: string, escalationReason: string): {
111
+ patterns: Array<Omit<WhitelistPattern, 'id'>>;
112
+ ipcs: WhitelistCandidateIpc[];
113
+ };
114
+ /**
115
+ * Creates an in-memory approval whitelist.
116
+ */
117
+ export declare function createApprovalWhitelist(): ApprovalWhitelist;
@@ -0,0 +1,237 @@
1
+ /**
2
+ * Ephemeral approval whitelist -- session-scoped in-memory store
3
+ * of approval patterns extracted from user-approved escalations.
4
+ *
5
+ * Security invariant: only converts escalate -> allow, never overrides deny.
6
+ * Entries are never persisted to disk.
7
+ */
8
+ import { dirname } from 'node:path';
9
+ import { v4 as uuidv4 } from 'uuid';
10
+ import { resolveRealPath, getRoleDefinition, isWithinDirectory } from '../types/argument-roles.js';
11
+ import { extractDomainForRole } from './domain-utils.js';
12
+ import { extractAnnotatedPaths, collectDistinctRoles } from './policy-engine.js';
13
+ /** Default whitelist options: select the first (and currently only) candidate. */
14
+ export const DEFAULT_WHITELIST_OPTIONS = { whitelistSelection: 0 };
15
+ // ---------------------------------------------------------------------------
16
+ // History-rewriting roles excluded from directory generalization
17
+ // ---------------------------------------------------------------------------
18
+ const HISTORY_REWRITING_ROLES = new Set(['write-history', 'delete-history']);
19
+ // ---------------------------------------------------------------------------
20
+ // Constraint matching
21
+ // ---------------------------------------------------------------------------
22
+ /**
23
+ * Checks whether a single constraint is satisfied by the tool call's arguments.
24
+ */
25
+ function constraintMatches(constraint, args, annotation) {
26
+ // Find all argument values for the constraint's role
27
+ const values = extractAnnotatedPaths(args, annotation, [constraint.role]);
28
+ if (values.length === 0)
29
+ return false;
30
+ switch (constraint.kind) {
31
+ case 'directory':
32
+ return values.every((v) => {
33
+ try {
34
+ return isWithinDirectory(v, constraint.directory);
35
+ }
36
+ catch {
37
+ return false;
38
+ }
39
+ });
40
+ case 'domain': {
41
+ const roleDef = getRoleDefinition(constraint.role);
42
+ return values.every((v) => {
43
+ try {
44
+ const normalized = roleDef.canonicalize(v);
45
+ const domain = extractDomainForRole(normalized, constraint.role);
46
+ return domain.toLowerCase() === constraint.domain.toLowerCase();
47
+ }
48
+ catch {
49
+ return false;
50
+ }
51
+ });
52
+ }
53
+ case 'exact':
54
+ return values.every((v) => v.toLowerCase() === constraint.value.toLowerCase());
55
+ }
56
+ }
57
+ // ---------------------------------------------------------------------------
58
+ // Pattern extraction
59
+ // ---------------------------------------------------------------------------
60
+ /**
61
+ * Extracts whitelist candidate patterns from an escalated tool call.
62
+ *
63
+ * Only generates constraints for the role(s) that caused the escalation,
64
+ * as identified by `escalatedRoles` on the EvaluationResult.
65
+ *
66
+ * Falls back to all resource-identifier roles when `escalatedRoles` is
67
+ * undefined (defensive robustness for future structural escalation paths).
68
+ *
69
+ * Returns both:
70
+ * - WhitelistPattern[] (full patterns, stored in proxy memory -- without id, added on whitelist.add())
71
+ * - WhitelistCandidateIpc[] (descriptions, serialized into IPC file)
72
+ */
73
+ export function extractWhitelistCandidates(serverName, toolName, args, annotation, escalatedRoles, escalationId, escalationReason) {
74
+ // Determine which roles to extract constraints for
75
+ const rolesToExtract = escalatedRoles ?? collectDistinctRoles(annotation);
76
+ const constraints = buildConstraints(rolesToExtract, args, annotation);
77
+ const description = buildDescription(serverName, toolName, constraints);
78
+ const warning = buildWarning(constraints);
79
+ const pattern = {
80
+ serverName,
81
+ toolName,
82
+ constraints,
83
+ createdAt: new Date().toISOString(),
84
+ sourceEscalationId: escalationId,
85
+ originalReason: escalationReason,
86
+ description,
87
+ };
88
+ const ipc = {
89
+ description,
90
+ ...(warning ? { warning } : {}),
91
+ };
92
+ // Phase 1: returns a single candidate pattern. The array-based return type and
93
+ // whitelistSelection index in the IPC protocol are designed to support future
94
+ // multi-candidate expansion (e.g., "allow this directory" vs "allow this exact file").
95
+ return { patterns: [pattern], ipcs: [ipc] };
96
+ }
97
+ /**
98
+ * Builds constraints from escalated roles and argument values.
99
+ */
100
+ function buildConstraints(roles, args, annotation) {
101
+ const constraints = [];
102
+ const seen = new Set();
103
+ for (const role of roles) {
104
+ const roleDef = getRoleDefinition(role);
105
+ const values = extractAnnotatedPaths(args, annotation, [role]);
106
+ for (const value of values) {
107
+ const constraint = buildConstraintForRole(role, roleDef.category, value);
108
+ if (!constraint)
109
+ continue;
110
+ // Deduplicate constraints with identical kind/role/value
111
+ const key = constraintKey(constraint);
112
+ if (seen.has(key))
113
+ continue;
114
+ seen.add(key);
115
+ constraints.push(constraint);
116
+ }
117
+ }
118
+ return constraints;
119
+ }
120
+ /** Returns a stable string key for deduplication. */
121
+ function constraintKey(c) {
122
+ switch (c.kind) {
123
+ case 'directory':
124
+ return `dir:${c.role}:${c.directory}`;
125
+ case 'domain':
126
+ return `dom:${c.role}:${c.domain}`;
127
+ case 'exact':
128
+ return `exact:${c.role}:${c.value}`;
129
+ }
130
+ }
131
+ /**
132
+ * Builds a single constraint for a role and value, applying the
133
+ * appropriate generalization for the role's category.
134
+ */
135
+ function buildConstraintForRole(role, category, value) {
136
+ switch (category) {
137
+ case 'path': {
138
+ // History-rewriting roles are excluded from directory generalization
139
+ if (HISTORY_REWRITING_ROLES.has(role))
140
+ return undefined;
141
+ try {
142
+ // Note: resolveRealPath uses realpath for existing paths and path.resolve
143
+ // for non-existent ones. If a file is created after whitelisting, the resolved
144
+ // real path at match time may differ (e.g., through new symlinks). This is
145
+ // acceptable for phase 1 -- the constraint still provides meaningful scoping.
146
+ const resolvedPath = resolveRealPath(value);
147
+ const dir = dirname(resolvedPath);
148
+ return { kind: 'directory', role, directory: dir };
149
+ }
150
+ catch {
151
+ return undefined;
152
+ }
153
+ }
154
+ case 'url': {
155
+ try {
156
+ const roleDef = getRoleDefinition(role);
157
+ const normalized = roleDef.canonicalize(value);
158
+ const domain = extractDomainForRole(normalized, role);
159
+ return { kind: 'domain', role, domain };
160
+ }
161
+ catch {
162
+ return undefined;
163
+ }
164
+ }
165
+ case 'identifier':
166
+ return { kind: 'exact', role, value: value.toLowerCase() };
167
+ default:
168
+ return undefined;
169
+ }
170
+ }
171
+ /**
172
+ * Builds a human-readable description from constraints.
173
+ */
174
+ function buildDescription(serverName, toolName, constraints) {
175
+ if (constraints.length === 0) {
176
+ return `Allow ${serverName}/${toolName} (exact tool match only)`;
177
+ }
178
+ const parts = constraints.map((c) => {
179
+ switch (c.kind) {
180
+ case 'directory':
181
+ return `${c.role} within ${c.directory}`;
182
+ case 'domain':
183
+ return `${c.role} domain ${c.domain}`;
184
+ case 'exact':
185
+ return `${c.role}=${c.value}`;
186
+ }
187
+ });
188
+ return `Allow ${serverName}/${toolName} ${parts.join(', ')}`;
189
+ }
190
+ /**
191
+ * Generates a warning for zero-constraint tools.
192
+ */
193
+ function buildWarning(constraints) {
194
+ if (constraints.length === 0) {
195
+ return 'Whitelisting will auto-approve ALL future calls to this tool for this session.';
196
+ }
197
+ return undefined;
198
+ }
199
+ // ---------------------------------------------------------------------------
200
+ // Factory
201
+ // ---------------------------------------------------------------------------
202
+ /**
203
+ * Creates an in-memory approval whitelist.
204
+ */
205
+ export function createApprovalWhitelist() {
206
+ const patterns = [];
207
+ return {
208
+ add(patternData) {
209
+ const id = uuidv4();
210
+ const pattern = { ...patternData, id };
211
+ patterns.push(pattern);
212
+ return id;
213
+ },
214
+ match(serverName, toolName, resolvedArgs, annotation) {
215
+ for (const pattern of patterns) {
216
+ if (pattern.serverName !== serverName)
217
+ continue;
218
+ if (pattern.toolName !== toolName)
219
+ continue;
220
+ // All constraints must match (AND semantics)
221
+ const allMatch = pattern.constraints.length === 0 ||
222
+ pattern.constraints.every((c) => constraintMatches(c, resolvedArgs, annotation));
223
+ if (allMatch) {
224
+ return { matched: true, patternId: pattern.id, pattern };
225
+ }
226
+ }
227
+ return { matched: false };
228
+ },
229
+ entries() {
230
+ return patterns;
231
+ },
232
+ get size() {
233
+ return patterns.length;
234
+ },
235
+ };
236
+ }
237
+ //# sourceMappingURL=approval-whitelist.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-whitelist.js","sourceRoot":"","sources":["../../src/trusted-process/approval-whitelist.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACnG,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAyEjF,kFAAkF;AAClF,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,kBAAkB,EAAE,CAAC,EAAW,CAAC;AA8B5E,8EAA8E;AAC9E,iEAAiE;AACjE,8EAA8E;AAE9E,MAAM,uBAAuB,GAA8B,IAAI,GAAG,CAAC,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAExG,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E;;GAEG;AACH,SAAS,iBAAiB,CACxB,UAA+B,EAC/B,IAA6B,EAC7B,UAA0B;IAE1B,qDAAqD;IACrD,MAAM,MAAM,GAAG,qBAAqB,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1E,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAEtC,QAAQ,UAAU,CAAC,IAAI,EAAE,CAAC;QACxB,KAAK,WAAW;YACd,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;gBACxB,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C;QAClB,CAAC;QAED,IAAI,IAAI;YACN,OAAO,QAAQ,CAAC,MAAM,CAAC;QACzB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Google Workspace credential file management.
3
+ *
4
+ * Writes credential files in the format expected by
5
+ * @alanse/mcp-server-google-workspace's auth.ts.
6
+ *
7
+ * SECURITY: The refresh_token field is intentionally omitted.
8
+ * This prevents the MCP server from independently refreshing tokens,
9
+ * which would cause refresh token rotation races in multi-session
10
+ * environments. IronCurtain's OAuthTokenProvider is the sole token
11
+ * authority.
12
+ *
13
+ * The file is written atomically (write to .tmp, rename) to prevent
14
+ * the MCP server from reading a partial file during a refresh cycle.
15
+ */
16
+ /** The filename the MCP server expects in its GWORKSPACE_CREDS_DIR. */
17
+ export declare const GWORKSPACE_CREDENTIAL_FILENAME = ".gworkspace-credentials.json";
18
+ /**
19
+ * Shape of the credential file read by the MCP server's auth.ts.
20
+ * Mirrors the subset of Google OAuth2 token response that the server needs.
21
+ */
22
+ export interface GWorkspaceCredentialFile {
23
+ readonly access_token: string;
24
+ readonly expiry_date: number;
25
+ readonly token_type: 'Bearer';
26
+ readonly scope: string;
27
+ }
28
+ /**
29
+ * Writes a Google Workspace credential file for the MCP server.
30
+ *
31
+ * Creates the directory if it does not exist. Writes atomically via
32
+ * a temporary file + rename to prevent the MCP server from reading
33
+ * a partial file. File permissions are set to 0o600 (owner-only).
34
+ *
35
+ * @param credsDir - Directory to write the credential file into
36
+ * @param accessToken - OAuth2 access token (short-lived)
37
+ * @param expiresAt - Token expiry timestamp in milliseconds since epoch
38
+ * @param scopes - OAuth2 scopes granted to this token
39
+ */
40
+ export declare function writeGWorkspaceCredentialFile(credsDir: string, accessToken: string, expiresAt: number, scopes: readonly string[]): void;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Google Workspace credential file management.
3
+ *
4
+ * Writes credential files in the format expected by
5
+ * @alanse/mcp-server-google-workspace's auth.ts.
6
+ *
7
+ * SECURITY: The refresh_token field is intentionally omitted.
8
+ * This prevents the MCP server from independently refreshing tokens,
9
+ * which would cause refresh token rotation races in multi-session
10
+ * environments. IronCurtain's OAuthTokenProvider is the sole token
11
+ * authority.
12
+ *
13
+ * The file is written atomically (write to .tmp, rename) to prevent
14
+ * the MCP server from reading a partial file during a refresh cycle.
15
+ */
16
+ import { mkdirSync, renameSync, writeFileSync } from 'node:fs';
17
+ import { join } from 'node:path';
18
+ /** The filename the MCP server expects in its GWORKSPACE_CREDS_DIR. */
19
+ export const GWORKSPACE_CREDENTIAL_FILENAME = '.gworkspace-credentials.json';
20
+ /**
21
+ * Writes a Google Workspace credential file for the MCP server.
22
+ *
23
+ * Creates the directory if it does not exist. Writes atomically via
24
+ * a temporary file + rename to prevent the MCP server from reading
25
+ * a partial file. File permissions are set to 0o600 (owner-only).
26
+ *
27
+ * @param credsDir - Directory to write the credential file into
28
+ * @param accessToken - OAuth2 access token (short-lived)
29
+ * @param expiresAt - Token expiry timestamp in milliseconds since epoch
30
+ * @param scopes - OAuth2 scopes granted to this token
31
+ */
32
+ export function writeGWorkspaceCredentialFile(credsDir, accessToken, expiresAt, scopes) {
33
+ mkdirSync(credsDir, { recursive: true });
34
+ const credential = {
35
+ access_token: accessToken,
36
+ expiry_date: expiresAt,
37
+ token_type: 'Bearer',
38
+ scope: scopes.join(' '),
39
+ };
40
+ const filePath = join(credsDir, GWORKSPACE_CREDENTIAL_FILENAME);
41
+ const tmpPath = filePath + '.tmp';
42
+ writeFileSync(tmpPath, JSON.stringify(credential, null, 2), { mode: 0o600 });
43
+ renameSync(tmpPath, filePath);
44
+ }
45
+ //# sourceMappingURL=gworkspace-credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gworkspace-credentials.js","sourceRoot":"","sources":["../../src/trusted-process/gworkspace-credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,uEAAuE;AACvE,MAAM,CAAC,MAAM,8BAA8B,GAAG,8BAA8B,CAAC;AAe7E;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,6BAA6B,CAC3C,QAAgB,EAChB,WAAmB,EACnB,SAAiB,EACjB,MAAyB;IAEzB,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEzC,MAAM,UAAU,GAA6B;QAC3C,YAAY,EAAE,WAAW;QACzB,WAAW,EAAE,SAAS;QACtB,UAAU,EAAE,QAAQ;QACpB,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;KACxB,CAAC;IAEF,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,8BAA8B,CAAC,CAAC;IAChE,MAAM,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAElC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7E,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAChC,CAAC"}
@@ -1,6 +1,15 @@
1
1
  import type { IronCurtainConfig } from '../config/types.js';
2
2
  import type { ToolCallRequest, ToolCallResult } from '../types/mcp.js';
3
- export type EscalationPromptFn = (request: ToolCallRequest, reason: string, context?: Readonly<Record<string, string>>) => Promise<'approved' | 'denied'>;
3
+ import { type WhitelistCandidateIpc } from './approval-whitelist.js';
4
+ /** Result from an escalation callback, optionally including whitelist selection. */
5
+ export interface EscalationResult {
6
+ readonly decision: 'approved' | 'denied';
7
+ /** Index into whitelistCandidates to whitelist. Absent = no whitelisting. */
8
+ readonly whitelistSelection?: number;
9
+ }
10
+ export type EscalationPromptFn = (request: ToolCallRequest, reason: string, context?: Readonly<Record<string, string>>,
11
+ /** Whitelist candidates for display to the user. */
12
+ whitelistCandidates?: readonly WhitelistCandidateIpc[]) => Promise<EscalationResult>;
4
13
  export interface TrustedProcessOptions {
5
14
  onEscalation?: EscalationPromptFn;
6
15
  }
@@ -12,6 +21,7 @@ export declare class TrustedProcess {
12
21
  private auditLog;
13
22
  private escalation;
14
23
  private onEscalation?;
24
+ private readonly whitelist;
15
25
  private autoApproveModel;
16
26
  private lastUserMessage;
17
27
  private serverContextMap;