@intutic/sync-daemon 2.0.0 → 2.2.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 (206) hide show
  1. package/dist/agentReporter.d.ts +5 -12
  2. package/dist/agentReporter.d.ts.map +1 -1
  3. package/dist/agentReporter.js +25 -4
  4. package/dist/agentReporter.js.map +1 -1
  5. package/dist/configReader.d.ts +44 -22
  6. package/dist/configReader.d.ts.map +1 -1
  7. package/dist/configReader.js +70 -44
  8. package/dist/configReader.js.map +1 -1
  9. package/dist/configWriter.d.ts +29 -41
  10. package/dist/configWriter.d.ts.map +1 -1
  11. package/dist/configWriter.js +28 -625
  12. package/dist/configWriter.js.map +1 -1
  13. package/dist/disconnect/harnesses.d.ts +31 -0
  14. package/dist/disconnect/harnesses.d.ts.map +1 -0
  15. package/dist/disconnect/harnesses.js +728 -0
  16. package/dist/disconnect/harnesses.js.map +1 -0
  17. package/dist/disconnect/index.d.ts +25 -0
  18. package/dist/disconnect/index.d.ts.map +1 -0
  19. package/dist/disconnect/index.js +82 -0
  20. package/dist/disconnect/index.js.map +1 -0
  21. package/dist/disconnect/mcp.d.ts +60 -0
  22. package/dist/disconnect/mcp.d.ts.map +1 -0
  23. package/dist/disconnect/mcp.js +283 -0
  24. package/dist/disconnect/mcp.js.map +1 -0
  25. package/dist/disconnect/originals.d.ts +88 -0
  26. package/dist/disconnect/originals.d.ts.map +1 -0
  27. package/dist/disconnect/originals.js +257 -0
  28. package/dist/disconnect/originals.js.map +1 -0
  29. package/dist/disconnect/plan.d.ts +175 -0
  30. package/dist/disconnect/plan.d.ts.map +1 -0
  31. package/dist/disconnect/plan.js +580 -0
  32. package/dist/disconnect/plan.js.map +1 -0
  33. package/dist/disconnect/recognise.d.ts +43 -0
  34. package/dist/disconnect/recognise.d.ts.map +1 -0
  35. package/dist/disconnect/recognise.js +98 -0
  36. package/dist/disconnect/recognise.js.map +1 -0
  37. package/dist/disconnect/tomlLines.d.ts +39 -0
  38. package/dist/disconnect/tomlLines.d.ts.map +1 -0
  39. package/dist/disconnect/tomlLines.js +105 -0
  40. package/dist/disconnect/tomlLines.js.map +1 -0
  41. package/dist/harness/aiderConfigMerger.d.ts +42 -5
  42. package/dist/harness/aiderConfigMerger.d.ts.map +1 -1
  43. package/dist/harness/aiderConfigMerger.js +113 -86
  44. package/dist/harness/aiderConfigMerger.js.map +1 -1
  45. package/dist/harness/antigravityHooks.d.ts +13 -8
  46. package/dist/harness/antigravityHooks.d.ts.map +1 -1
  47. package/dist/harness/antigravityHooks.js +53 -39
  48. package/dist/harness/antigravityHooks.js.map +1 -1
  49. package/dist/harness/claudeCodeHooks.d.ts +1 -2
  50. package/dist/harness/claudeCodeHooks.d.ts.map +1 -1
  51. package/dist/harness/claudeCodeHooks.js +61 -34
  52. package/dist/harness/claudeCodeHooks.js.map +1 -1
  53. package/dist/harness/claudeDesktopHooks.d.ts +3 -0
  54. package/dist/harness/claudeDesktopHooks.d.ts.map +1 -1
  55. package/dist/harness/claudeDesktopHooks.js +3 -1
  56. package/dist/harness/claudeDesktopHooks.js.map +1 -1
  57. package/dist/harness/claudeProjectApproval.d.ts +53 -0
  58. package/dist/harness/claudeProjectApproval.d.ts.map +1 -0
  59. package/dist/harness/claudeProjectApproval.js +159 -0
  60. package/dist/harness/claudeProjectApproval.js.map +1 -0
  61. package/dist/harness/clineHooks.d.ts +39 -9
  62. package/dist/harness/clineHooks.d.ts.map +1 -1
  63. package/dist/harness/clineHooks.js +142 -60
  64. package/dist/harness/clineHooks.js.map +1 -1
  65. package/dist/harness/codexConfigMerger.d.ts +38 -0
  66. package/dist/harness/codexConfigMerger.d.ts.map +1 -0
  67. package/dist/harness/codexConfigMerger.js +105 -0
  68. package/dist/harness/codexConfigMerger.js.map +1 -0
  69. package/dist/harness/codexHooks.d.ts +4 -2
  70. package/dist/harness/codexHooks.d.ts.map +1 -1
  71. package/dist/harness/codexHooks.js +14 -11
  72. package/dist/harness/codexHooks.js.map +1 -1
  73. package/dist/harness/continueConfigMerger.d.ts +46 -0
  74. package/dist/harness/continueConfigMerger.d.ts.map +1 -0
  75. package/dist/harness/continueConfigMerger.js +94 -0
  76. package/dist/harness/continueConfigMerger.js.map +1 -0
  77. package/dist/harness/continueHooks.d.ts +15 -25
  78. package/dist/harness/continueHooks.d.ts.map +1 -1
  79. package/dist/harness/continueHooks.js +25 -119
  80. package/dist/harness/continueHooks.js.map +1 -1
  81. package/dist/harness/cursorHooks.d.ts +33 -16
  82. package/dist/harness/cursorHooks.d.ts.map +1 -1
  83. package/dist/harness/cursorHooks.js +69 -25
  84. package/dist/harness/cursorHooks.js.map +1 -1
  85. package/dist/harness/dshHooks.d.ts +59 -52
  86. package/dist/harness/dshHooks.d.ts.map +1 -1
  87. package/dist/harness/dshHooks.js +152 -147
  88. package/dist/harness/dshHooks.js.map +1 -1
  89. package/dist/harness/gateBody.d.ts +11 -2
  90. package/dist/harness/gateBody.d.ts.map +1 -1
  91. package/dist/harness/gateBody.js +33 -6
  92. package/dist/harness/gateBody.js.map +1 -1
  93. package/dist/harness/gateKind.d.ts.map +1 -1
  94. package/dist/harness/gateKind.js +1 -0
  95. package/dist/harness/gateKind.js.map +1 -1
  96. package/dist/harness/githubCopilotHooks.d.ts.map +1 -1
  97. package/dist/harness/githubCopilotHooks.js +5 -10
  98. package/dist/harness/githubCopilotHooks.js.map +1 -1
  99. package/dist/harness/gooseHooks.d.ts +15 -0
  100. package/dist/harness/gooseHooks.d.ts.map +1 -1
  101. package/dist/harness/gooseHooks.js +55 -43
  102. package/dist/harness/gooseHooks.js.map +1 -1
  103. package/dist/harness/grokHooks.d.ts.map +1 -1
  104. package/dist/harness/grokHooks.js +14 -12
  105. package/dist/harness/grokHooks.js.map +1 -1
  106. package/dist/harness/hermesHooks.d.ts +9 -0
  107. package/dist/harness/hermesHooks.d.ts.map +1 -1
  108. package/dist/harness/hermesHooks.js +39 -33
  109. package/dist/harness/hermesHooks.js.map +1 -1
  110. package/dist/harness/holdRedaction.d.ts +4 -1
  111. package/dist/harness/holdRedaction.d.ts.map +1 -1
  112. package/dist/harness/holdRedaction.js +32 -8
  113. package/dist/harness/holdRedaction.js.map +1 -1
  114. package/dist/harness/jetbrainsXmlConfig.d.ts +20 -0
  115. package/dist/harness/jetbrainsXmlConfig.d.ts.map +1 -1
  116. package/dist/harness/jetbrainsXmlConfig.js +39 -18
  117. package/dist/harness/jetbrainsXmlConfig.js.map +1 -1
  118. package/dist/harness/jsonMergeTarget.d.ts +23 -0
  119. package/dist/harness/jsonMergeTarget.d.ts.map +1 -0
  120. package/dist/harness/jsonMergeTarget.js +50 -0
  121. package/dist/harness/jsonMergeTarget.js.map +1 -0
  122. package/dist/harness/mcpAutoWrite.d.ts +64 -20
  123. package/dist/harness/mcpAutoWrite.d.ts.map +1 -1
  124. package/dist/harness/mcpAutoWrite.js +429 -85
  125. package/dist/harness/mcpAutoWrite.js.map +1 -1
  126. package/dist/harness/museHooks.d.ts.map +1 -1
  127. package/dist/harness/museHooks.js +6 -2
  128. package/dist/harness/museHooks.js.map +1 -1
  129. package/dist/harness/n8nHooks.d.ts.map +1 -1
  130. package/dist/harness/n8nHooks.js +6 -7
  131. package/dist/harness/n8nHooks.js.map +1 -1
  132. package/dist/harness/openCodeHooks.d.ts +37 -6
  133. package/dist/harness/openCodeHooks.d.ts.map +1 -1
  134. package/dist/harness/openCodeHooks.js +103 -13
  135. package/dist/harness/openCodeHooks.js.map +1 -1
  136. package/dist/harness/openWebuiHooks.d.ts.map +1 -1
  137. package/dist/harness/openWebuiHooks.js +10 -5
  138. package/dist/harness/openWebuiHooks.js.map +1 -1
  139. package/dist/harness/openclawHooks.d.ts +5 -0
  140. package/dist/harness/openclawHooks.d.ts.map +1 -1
  141. package/dist/harness/openclawHooks.js +3 -1
  142. package/dist/harness/openclawHooks.js.map +1 -1
  143. package/dist/harness/openhandsHooks.d.ts +26 -1
  144. package/dist/harness/openhandsHooks.d.ts.map +1 -1
  145. package/dist/harness/openhandsHooks.js +160 -40
  146. package/dist/harness/openhandsHooks.js.map +1 -1
  147. package/dist/harness/piHooks.d.ts +17 -0
  148. package/dist/harness/piHooks.d.ts.map +1 -1
  149. package/dist/harness/piHooks.js +31 -29
  150. package/dist/harness/piHooks.js.map +1 -1
  151. package/dist/harness/protectedPaths.d.ts +64 -6
  152. package/dist/harness/protectedPaths.d.ts.map +1 -1
  153. package/dist/harness/protectedPaths.js +161 -11
  154. package/dist/harness/protectedPaths.js.map +1 -1
  155. package/dist/harness/rooCodeHooks.d.ts.map +1 -1
  156. package/dist/harness/rooCodeHooks.js +5 -10
  157. package/dist/harness/rooCodeHooks.js.map +1 -1
  158. package/dist/harness/windsurfHooks.d.ts +21 -3
  159. package/dist/harness/windsurfHooks.d.ts.map +1 -1
  160. package/dist/harness/windsurfHooks.js +96 -44
  161. package/dist/harness/windsurfHooks.js.map +1 -1
  162. package/dist/harness/windsurfJetBrainsProxy.d.ts +10 -7
  163. package/dist/harness/windsurfJetBrainsProxy.d.ts.map +1 -1
  164. package/dist/harness/windsurfJetBrainsProxy.js +22 -7
  165. package/dist/harness/windsurfJetBrainsProxy.js.map +1 -1
  166. package/dist/index.d.ts +12 -12
  167. package/dist/index.d.ts.map +1 -1
  168. package/dist/index.js +11 -10
  169. package/dist/index.js.map +1 -1
  170. package/dist/lib/decisionsDigest.d.ts +1 -1
  171. package/dist/lib/decisionsDigest.js +1 -1
  172. package/dist/lib/policySnapshot.d.ts +37 -0
  173. package/dist/lib/policySnapshot.d.ts.map +1 -1
  174. package/dist/lib/policySnapshot.js +170 -8
  175. package/dist/lib/policySnapshot.js.map +1 -1
  176. package/dist/sessionReporter.d.ts +2 -2
  177. package/dist/sessionReporter.js +2 -2
  178. package/dist/syncCycle.d.ts +142 -0
  179. package/dist/syncCycle.d.ts.map +1 -0
  180. package/dist/syncCycle.js +315 -0
  181. package/dist/syncCycle.js.map +1 -0
  182. package/dist/trajectoryMonitor.d.ts +1 -1
  183. package/dist/trajectoryMonitor.d.ts.map +1 -1
  184. package/dist/trajectoryMonitor.js +1 -1
  185. package/dist/trajectoryMonitor.js.map +1 -1
  186. package/dist/watcher/settingsGuard.d.ts +4 -1
  187. package/dist/watcher/settingsGuard.d.ts.map +1 -1
  188. package/dist/watcher/settingsGuard.js +42 -18
  189. package/dist/watcher/settingsGuard.js.map +1 -1
  190. package/package.json +6 -6
  191. package/dist/hashReporter.d.ts +0 -33
  192. package/dist/hashReporter.d.ts.map +0 -1
  193. package/dist/hashReporter.js +0 -69
  194. package/dist/hashReporter.js.map +0 -1
  195. package/dist/integrityStore.d.ts +0 -35
  196. package/dist/integrityStore.d.ts.map +0 -1
  197. package/dist/integrityStore.js +0 -71
  198. package/dist/integrityStore.js.map +0 -1
  199. package/dist/lib/gitWorktrees.d.ts +0 -140
  200. package/dist/lib/gitWorktrees.d.ts.map +0 -1
  201. package/dist/lib/gitWorktrees.js +0 -191
  202. package/dist/lib/gitWorktrees.js.map +0 -1
  203. package/dist/syncLoop.d.ts +0 -172
  204. package/dist/syncLoop.d.ts.map +0 -1
  205. package/dist/syncLoop.js +0 -878
  206. package/dist/syncLoop.js.map +0 -1
@@ -1,13 +1,9 @@
1
1
  /**
2
- * configWriter.ts — Write SOP content to harness config files.
2
+ * configWriter.ts — the harness rules-file map, local SOP loading, SkillOpt
3
+ * config edits and the atomic write they share.
3
4
  *
4
- * Each harness (Cursor, Claude Code, Antigravity, Windsurf, Aider,
5
- * OpenHands, Codex) has a distinct config file format. This module
6
- * resolves paths, formats content, and performs atomic writes
7
- * (write-to-tmp → rename) to prevent partial/corrupt files.
8
- *
9
- * HLD §3.14 — Real-Time State Mirroring
10
- * LLD #8 — Sync Daemon / CLI
5
+ * The harness config files themselves are written by the CLI's adapters
6
+ * (tools/cli/src/harness), which `intutic connect` runs.
11
7
  *
12
8
  * @module
13
9
  */
@@ -15,14 +11,13 @@ import * as node_fs from 'node:fs/promises';
15
11
  import * as node_path from 'node:path';
16
12
  import { execFile as _execFile } from 'node:child_process';
17
13
  import { promisify } from 'node:util';
18
- import { newIso } from '@intutic/id';
19
14
  const execFile = promisify(_execFile);
20
15
  /**
21
- * Clear the macOS user-immutable flag before writing a file.
22
- * No-op on non-macOS platforms or if the file doesn't exist yet.
23
- * Called when bypassEnforcementTier === 'immutable'. (WS-5 Q3)
16
+ * Clear the macOS user-immutable flag so the daemon can rewrite a file it
17
+ * write-protected (the workspace's `bypassEnforcementTier: 'immutable'`).
18
+ * No-op on other platforms or if the file does not exist yet.
24
19
  */
25
- async function clearImmutable(filePath) {
20
+ export async function clearImmutable(filePath) {
26
21
  if (process.platform !== 'darwin')
27
22
  return;
28
23
  try {
@@ -31,12 +26,11 @@ async function clearImmutable(filePath) {
31
26
  catch { /* file may not exist yet */ }
32
27
  }
33
28
  /**
34
- * Set the macOS user-immutable flag after writing a file.
35
- * Prevents direct edits from succeeding — any attempt gets EPERM.
36
- * The flag is cleared before the next sync write.
37
- * No-op on non-macOS platforms. (WS-5 Q3)
29
+ * Set the macOS user-immutable flag (`chflags uchg`), so a hand edit of a
30
+ * managed file fails with EPERM. The flag needs no root to set or clear; it
31
+ * stops casual editing, not a determined user. No-op on other platforms.
38
32
  */
39
- async function setImmutable(filePath) {
33
+ export async function setImmutable(filePath) {
40
34
  if (process.platform !== 'darwin')
41
35
  return;
42
36
  try {
@@ -44,25 +38,16 @@ async function setImmutable(filePath) {
44
38
  }
45
39
  catch { /* non-fatal */ }
46
40
  }
47
- import { writeAntigravityHooks } from './harness/antigravityHooks.js';
48
- import { writeClaudeDesktopHooks } from './harness/claudeDesktopHooks.js';
49
- import { writeRooCodeHooks } from './harness/rooCodeHooks.js';
50
- import { writeContinueHooks } from './harness/continueHooks.js';
51
- import { writeOpenWebuiHooks } from './harness/openWebuiHooks.js';
52
- import { writeN8nHooks } from './harness/n8nHooks.js';
53
- import { writeHermesHooks } from './harness/hermesHooks.js';
54
- import { writeOpenclawHooks } from './harness/openclawHooks.js';
55
- import { writePiHooks } from './harness/piHooks.js';
56
- import { writeCodexHooks } from './harness/codexHooks.js';
57
- import { writeGithubCopilotHooks } from './harness/githubCopilotHooks.js';
58
- import { writeMuseHooks } from './harness/museHooks.js';
59
- import { writeOpenCodeHooks } from './harness/openCodeHooks.js';
60
- import { writeGrokHooks } from './harness/grokHooks.js';
61
41
  // ─── Harness config file mapping ─────────────────────────────────────
62
42
  /**
63
- * Maps each harness type to its expected config filename relative to
64
- * the workspace root. Empty string means the harness is deferred to
65
- * Phase 2 (e.g., n8n — TD-037).
43
+ * Each harness's rules file, relative to the workspace root: the file the
44
+ * drift watcher watches, config capture uploads, and SkillOpt edits and the
45
+ * decisions log write into. An empty string means the harness has no
46
+ * workspace rules file: its governance lives elsewhere (dsh under $DSH_HOME),
47
+ * or it writes no config of its own because it delegates to a wrapped
48
+ * harness's gate (Xirp, Agentic Orchestrator, AgentCore Runtime) or is gated
49
+ * by a service (TrueForge server). The SDK-gated frameworks share
50
+ * `.env.intutic`, which carries the proxy variables.
66
51
  */
67
52
  export const HARNESS_FILES = {
68
53
  cursor: '.cursorrules',
@@ -77,46 +62,20 @@ export const HARNESS_FILES = {
77
62
  hermes: '.hermes/config.yaml',
78
63
  pi: '.pi/hooks.json',
79
64
  'github-copilot': '.github/copilot-instructions.md',
80
- cline: '.cline/hooks/hooks.json',
65
+ cline: '.clinerules/intutic-governance.md',
81
66
  'roo-code': '.roorules',
82
67
  continue: '.continue/config.json',
83
68
  'claude-desktop': 'claude_desktop_config.json',
84
69
  goose: '.agents/plugins/intutic-governance/hooks/hooks.json',
85
70
  'open-webui': '.open-webui/intutic-governance-filter.py',
86
71
  langgraph: '.env.intutic',
87
- // Muse Code reads AGENTS.md (falling back to CLAUDE.md) — see muse.ts (CLI)
88
- // and museHooks.ts (the hook writer invoked below, same split codex uses).
72
+ // Muse Code, Grok Build and OpenCode all read AGENTS.md.
89
73
  'muse-code': 'AGENTS.md',
90
- // Grok Build's native rules file — same cross-tool convention Codex/Amp
91
- // read. Formatted by `formatMarkdown`, the same `---`-separated formatter
92
- // Cursor/Claude Code/Windsurf/GitHub Copilot already share below.
93
74
  grok: 'AGENTS.md',
94
- // OpenCode reads AGENTS.md (CLAUDE.md fallback) — the same markdown rules
95
- // file Muse/Grok get. The gate is the plugin `writeOpenCodeHooks` writes
96
- // below, not this file.
97
75
  opencode: 'AGENTS.md',
98
- // dsh has no workspace-relative rules file (governance lives entirely
99
- // under $DSH_HOME) — empty, same as goose/openhands below: this writer's
100
- // per-harness chain deliberately does not call writeDshHooks either (see
101
- // the "goose and openhands are deliberately absent here" comment above);
102
- // dshHooks.ts is invoked by tools/cli/src/harness/dsh.ts's own
103
- // writeConfig() and re-run on tamper by settingsGuard.ts, the same
104
- // two-path coverage goose/openhands rely on instead of this loop.
105
76
  dsh: '',
106
- // Xirp writes no config of its own (orchestrates other already-gated
107
- // harnesses — see gateRegistry.ts's NO_GATE row and tools/cli/src/harness/
108
- // xirp.ts). Empty filename => the loop below reports it `(deferred)`,
109
- // same as n8n before it gained a writer.
110
77
  xirp: '',
111
- // Agentic Orchestrator writes no config of its own either — same
112
- // "delegated" shape as Xirp (orchestrates already-gated Claude Code, Codex
113
- // and OpenCode — see gateRegistry.ts's NO_GATE row and
114
- // tools/cli/src/harness/agenticOrchestrator.ts).
115
78
  'agentic-orchestrator': '',
116
- // Wave 1 SDK-gated frameworks — same rationale as langgraph: no on-disk
117
- // hook/config file exists to gate tool calls, so each writes .env.intutic
118
- // (proxy base-URL vars + an SDK-gate pointer comment). See formatContent's
119
- // switch below and SDK_GATED_FRAMEWORKS.
120
79
  langchain: '.env.intutic',
121
80
  crewai: '.env.intutic',
122
81
  autogen: '.env.intutic',
@@ -125,54 +84,21 @@ export const HARNESS_FILES = {
125
84
  'openai-agents': '.env.intutic',
126
85
  'pydantic-ai': '.env.intutic',
127
86
  smolagents: '.env.intutic',
128
- // A4: AWS Strands Agents — same Python SDK-gated rationale as the Wave 1
129
- // family above (gate ships in intutic_clawde.gate.adapters.strands).
130
87
  strands: '.env.intutic',
131
- // T2: JS/TS SDK-gated frameworks — same rationale as the Wave 1 Python
132
- // family above, but the blocking gate ships in @intutic/gate
133
- // (packages/gate-js) rather than intutic-clawde. See formatContent's
134
- // switch below and JS_SDK_GATED_FRAMEWORKS.
88
+ 'agent-framework': '.env.intutic',
135
89
  mastra: '.env.intutic',
136
90
  'vercel-ai-sdk': '.env.intutic',
137
- // eve (Vercel, PREVIEW) — same JS/TS SDK-gated family: the gate is
138
- // @intutic/gate/eve's per-tool/per-connection approval policies, attached
139
- // in the developer's own agent/ directory; this file only carries the
140
- // proxy vars + pointer comment. See JS_SDK_GATED_FRAMEWORKS below.
141
91
  eve: '.env.intutic',
142
- // TrueForge (embedded-library mode only — see its HarnessType doc) — same
143
- // JS/TS SDK-gated family, gate ships in @intutic/gate/trueforge. See
144
- // formatContent's switch below and JS_SDK_GATED_FRAMEWORKS.
145
92
  trueforge: '.env.intutic',
146
- // A3: Vercel platform-agent runtimes — same @intutic/gate family as the T2
147
- // rows above. For ai-sdk-harness the env vars are weaker still: tool
148
- // execution is server-side in Vercel Sandbox microVMs the local proxy
149
- // never sees (the generated comment says so — see JS_SDK_GATED_FRAMEWORKS'
150
- // preamble override below and @intutic/gate/harness's module doc).
151
93
  'ai-sdk-harness': '.env.intutic',
152
94
  'ai-sdk-workflow': '.env.intutic',
153
- // B2: AWS Bedrock AgentCore Runtime — hosts the customer's own framework
154
- // code unchanged, so it writes no config of its own; the real tool-call
155
- // gate belongs to whichever already-supported framework adapter that code
156
- // uses (Strands, LangGraph, ...). Same 'delegated'/empty-filename shape as
157
- // xirp/agentic-orchestrator above — see tools/cli/src/harness/agentcore.ts
158
- // and gateKind.ts's DELEGATED_GATE_HARNESSES.
159
95
  'agentcore-runtime': '',
160
- // B3: TrueForge, standalone/hosted server (see its HarnessType doc) —
161
- // writes no config of its own: it is not detected by intutic init at all
162
- // (an operator-configured deployment, not a repo dependency this daemon's
163
- // scanner can find), and its gate is entirely out-of-process in
164
- // services/trueforge-bridge, not a file this daemon writes. Empty filename
165
- // => the loop below reports it `(deferred)`, same shape as
166
- // xirp/agentic-orchestrator/agentcore-runtime above, though for a
167
- // genuinely different reason — those are 'delegated' (governed by a
168
- // wrapped harness's own gate); this is 'bridge' (governed by a service
169
- // this repo ships and operates). See gateKind.ts's BRIDGE_GATED_HARNESSES.
170
96
  'trueforge-server': '',
171
97
  };
172
98
  /**
173
99
  * The workspace's local SOPs (`.intutic/sops/<dir>/*.md`, narrowed by
174
- * `session-context.json`'s `activeLocalSops` when present). Shared by the
175
- * config writer and by the gate-cache refresh, which compiles their
100
+ * `session-context.json`'s `activeLocalSops` when present). Read by the
101
+ * gate-cache refresh, which compiles their
176
102
  * `review_before:` tokens into hold rules (TD-474 item 4). A missing
177
103
  * directory is an empty list.
178
104
  */
@@ -217,215 +143,6 @@ export async function loadLocalSopEntries(workspaceRoot, harnesses) {
217
143
  }
218
144
  return localSopEntries;
219
145
  }
220
- /**
221
- * Write SOP content to all targeted harness config files.
222
- *
223
- * For each harness type, resolves the config file path, formats the
224
- * content according to the harness-specific format, and performs an
225
- * atomic write (tmp file → rename).
226
- *
227
- * @param workspaceRoot - Absolute path to the workspace root.
228
- * @param sops - SOPs to write, each specifying which harnesses to target.
229
- * @param proxyUrl - Intutic proxy URL for LLM API redirect.
230
- * @param harnesses - Harness types detected in the workspace.
231
- * @returns WriteResult with written and skipped file paths.
232
- */
233
- export async function writeConfigFiles(workspaceRoot, sops, proxyUrl, harnesses, workspaceId = '',
234
- /** WS-5 Q3: 'rewrite' (default) | 'immutable' | 'alert-only' */
235
- bypassEnforcementTier) {
236
- const filesWritten = [];
237
- const filesSkipped = [];
238
- // Bundled agent skills — write-if-missing, not drift-enforced
239
- try {
240
- const { writeBundledSkills } = await import('./skillWriter.js');
241
- await writeBundledSkills(workspaceRoot);
242
- }
243
- catch (e) {
244
- console.warn('[sync-daemon] writeBundledSkills failed (non-fatal):', e);
245
- }
246
- const localSopEntries = await loadLocalSopEntries(workspaceRoot, harnesses);
247
- const combinedSops = [...sops, ...localSopEntries];
248
- for (const harness of harnesses) {
249
- const filename = HARNESS_FILES[harness];
250
- // Phase 3 proprietary harnesses — no config file path needed (handled below)
251
- if (harness === 'hermes') {
252
- try {
253
- await writeHermesHooks(workspaceRoot, proxyUrl, workspaceId);
254
- }
255
- catch (e) {
256
- console.warn('[sync-daemon] writeHermesHooks failed (non-fatal):', e);
257
- }
258
- continue;
259
- }
260
- if (harness === 'openclaw') {
261
- try {
262
- await writeOpenclawHooks(workspaceRoot, proxyUrl, workspaceId);
263
- }
264
- catch (e) {
265
- console.warn('[sync-daemon] writeOpenclawHooks failed (non-fatal):', e);
266
- }
267
- continue;
268
- }
269
- if (harness === 'pi') {
270
- try {
271
- await writePiHooks(workspaceRoot, proxyUrl, workspaceId);
272
- }
273
- catch (e) {
274
- console.warn('[sync-daemon] writePiHooks failed (non-fatal):', e);
275
- }
276
- continue;
277
- }
278
- // cursor is deliberately absent here, for the same reason goose and
279
- // openhands are below.
280
- //
281
- // `cursorHooksJson` was a second writer of `.cursor/hooks.json`, and the two
282
- // disagreed about the file's schema: `cursorHooks` writes an object per
283
- // event carrying `failClosed: true`, while `cursorHooksJson.mergeHooks`
284
- // tested `Array.isArray(existing[event])`, found false, and REPLACED it with
285
- // a bare `{command}` array. So it silently dropped fail-closed and repointed
286
- // the user-level shell and MCP gates at `~/.intutic/hooks/cursor-check.js`,
287
- // a path no writer produces. `cursorHooks` already registers a superset of
288
- // its events at both levels, so it is deleted rather than repaired.
289
- // goose and openhands are deliberately absent here.
290
- //
291
- // They each used to get a *second* gate from this call site —
292
- // gooseHooksWriter.ts and openhandsHooksWriter.ts — installed alongside the
293
- // one their own writer produces. The two had contradictory models: the
294
- // survivors enforce locally and fail closed, these POSTed every tool call to
295
- // the control plane and failed open on any error or timeout. For openhands
296
- // both wrote `.openhands/hooks.json`, so whichever ran last silently won.
297
- //
298
- // Deleted rather than deprecated: two modules exporting the same symbol for
299
- // one harness *is* the defect. And they are not replaced by calls to the
300
- // survivors here — a second call site is how this started.
301
- // Phase 2 deferred or unknown harness
302
- if (!filename) {
303
- filesSkipped.push(`[${harness}] (deferred)`);
304
- continue;
305
- }
306
- const configPath = node_path.join(workspaceRoot, filename);
307
- // Filter SOPs that target this harness
308
- const targetedSops = combinedSops.filter((sop) => sop.harnessTargets.includes(harness));
309
- if (targetedSops.length === 0) {
310
- filesSkipped.push(configPath);
311
- continue;
312
- }
313
- const content = formatContent(harness, targetedSops, proxyUrl);
314
- try {
315
- await atomicWrite(configPath, content, bypassEnforcementTier);
316
- filesWritten.push(configPath);
317
- // For 'antigravity', also write the governance hook script and settings.json merge.
318
- // This is separate from the SOP content write above (which writes customInstructions).
319
- if (harness === 'antigravity') {
320
- try {
321
- await writeAntigravityHooks(workspaceRoot, proxyUrl, workspaceId);
322
- }
323
- catch (hookErr) {
324
- // Non-fatal — SOP content was written, only the hook script failed
325
- console.warn('[sync-daemon] writeAntigravityHooks failed (non-fatal):', hookErr);
326
- }
327
- }
328
- if (harness === 'claude-desktop') {
329
- try {
330
- await writeClaudeDesktopHooks(workspaceRoot, proxyUrl, workspaceId);
331
- }
332
- catch (e) {
333
- console.warn('[sync-daemon] writeClaudeDesktopHooks failed (non-fatal):', e);
334
- }
335
- }
336
- if (harness === 'roo-code') {
337
- try {
338
- await writeRooCodeHooks(workspaceRoot, proxyUrl, workspaceId);
339
- }
340
- catch (e) {
341
- console.warn('[sync-daemon] writeRooCodeHooks failed (non-fatal):', e);
342
- }
343
- }
344
- if (harness === 'continue') {
345
- try {
346
- await writeContinueHooks(workspaceRoot, proxyUrl, workspaceId);
347
- }
348
- catch (e) {
349
- console.warn('[sync-daemon] writeContinueHooks failed (non-fatal):', e);
350
- }
351
- }
352
- if (harness === 'open-webui') {
353
- try {
354
- await writeOpenWebuiHooks(workspaceRoot, proxyUrl, workspaceId);
355
- }
356
- catch (e) {
357
- console.warn('[sync-daemon] writeOpenWebuiHooks failed (non-fatal):', e);
358
- }
359
- }
360
- if (harness === 'n8n') {
361
- try {
362
- await writeN8nHooks(workspaceRoot, proxyUrl, workspaceId);
363
- }
364
- catch (e) {
365
- console.warn('[sync-daemon] writeN8nHooks failed (non-fatal):', e);
366
- }
367
- }
368
- // The .env.intutic proxy routing above governs LLM egress only; the gate
369
- // is what refuses tool calls. Written alongside, same as claude-desktop.
370
- if (harness === 'codex') {
371
- try {
372
- await writeCodexHooks(workspaceRoot, proxyUrl, workspaceId);
373
- }
374
- catch (e) {
375
- console.warn('[sync-daemon] writeCodexHooks failed (non-fatal):', e);
376
- }
377
- }
378
- // Preview mechanism (VS Code agent hooks) — the writer's header says so,
379
- // and the gate fails closed if the stdin shape shifts.
380
- if (harness === 'github-copilot') {
381
- try {
382
- await writeGithubCopilotHooks(workspaceRoot, proxyUrl, workspaceId);
383
- }
384
- catch (e) {
385
- console.warn('[sync-daemon] writeGithubCopilotHooks failed (non-fatal):', e);
386
- }
387
- }
388
- // Same split as codex/claude-desktop: AGENTS.md above carries the rules
389
- // text, this installs the PreToolUse/PermissionRequest gate (project +
390
- // managed tiers) and the managed_hooks_path merge into settings.json.
391
- if (harness === 'muse-code') {
392
- try {
393
- await writeMuseHooks(workspaceRoot, proxyUrl, workspaceId);
394
- }
395
- catch (e) {
396
- console.warn('[sync-daemon] writeMuseHooks failed (non-fatal):', e);
397
- }
398
- }
399
- // AGENTS.md above carries the rules text; this writes the plugin
400
- // OpenCode loads into its own process, which is the gate (TD-397).
401
- if (harness === 'opencode') {
402
- try {
403
- await writeOpenCodeHooks(workspaceRoot, proxyUrl, workspaceId);
404
- }
405
- catch (e) {
406
- console.warn('[sync-daemon] writeOpenCodeHooks failed (non-fatal):', e);
407
- }
408
- }
409
- // AGENTS.md above governs prompt-level rules only; the gate is what
410
- // refuses tool calls, and the config.toml model base_url merge is what
411
- // routes LLM egress. Written alongside, same as codex/claude-desktop.
412
- if (harness === 'grok') {
413
- try {
414
- await writeGrokHooks(workspaceRoot, proxyUrl, workspaceId);
415
- }
416
- catch (e) {
417
- console.warn('[sync-daemon] writeGrokHooks failed (non-fatal):', e);
418
- }
419
- }
420
- }
421
- catch (err) {
422
- console.warn(`[sync-daemon] writeConfigFiles failed for ${filename}:`, err);
423
- // Don't crash the loop — report as skipped
424
- filesSkipped.push(configPath);
425
- }
426
- }
427
- return { filesWritten, filesSkipped };
428
- }
429
146
  /**
430
147
  * Finds a match for a target block in content, tolerating line ending and whitespace variations.
431
148
  */
@@ -464,7 +181,7 @@ function findFuzzyMatch(content, target) {
464
181
  * of `void` — every operation's real fate (fuzzy-match miss on DELETE/
465
182
  * REPLACE, an unresolvable target file, or the final `atomicWrite` itself
466
183
  * failing) is recorded here rather than only `console.warn`'d, so the caller
467
- * (syncLoop.ts) can ack the daemon's actual outcome back to control-plane
184
+ * (`applySkillOptEdits`, syncCycle.ts) can ack the daemon's actual outcome back to control-plane
468
185
  * instead of the daemon-side write being invisible to it.
469
186
  */
470
187
  export async function applyConfigEdits(workspaceRoot, appliedEdits, bypassEnforcementTier) {
@@ -586,318 +303,6 @@ export async function applyConfigEdits(workspaceRoot, appliedEdits, bypassEnforc
586
303
  }
587
304
  return outcomes;
588
305
  }
589
- // ─── Formatters ──────────────────────────────────────────────────────
590
- /** Standard file header injected at the top of every auto-generated file. */
591
- function fileHeader() {
592
- return [
593
- '# Intutic Governance Rules (auto-generated)',
594
- '# DO NOT EDIT — managed by intutic sync daemon',
595
- `# Last sync: ${newIso()}`,
596
- '',
597
- '',
598
- ].join('\n');
599
- }
600
- /**
601
- * Format SOP content for a specific harness type.
602
- *
603
- * Each harness has a distinct format:
604
- * - Cursor / Claude Code / Windsurf → Markdown with `---` separators
605
- * - Antigravity → JSON with `customInstructions` field
606
- * - Aider → YAML with `extra-instructions` field
607
- * - OpenHands → TOML with `[intutic]` section
608
- * - Codex → `.env.intutic` with proxy URL vars
609
- */
610
- function formatContent(harness, sops, proxyUrl) {
611
- switch (harness) {
612
- case 'cursor':
613
- case 'claude-code':
614
- case 'windsurf':
615
- case 'github-copilot':
616
- case 'grok':
617
- return formatMarkdown(sops);
618
- case 'antigravity':
619
- return formatAntigravity(sops);
620
- case 'aider':
621
- return formatAider(sops);
622
- case 'openhands':
623
- return formatOpenHands(sops);
624
- case 'codex':
625
- return formatCodex(sops, proxyUrl);
626
- case 'langgraph':
627
- return formatLanggraph(sops, proxyUrl);
628
- case 'muse-code':
629
- case 'opencode':
630
- // AGENTS.md — same markdown shape as CLAUDE.md/.cursorrules/.windsurfrules.
631
- return formatMarkdown(sops);
632
- case 'langchain':
633
- case 'crewai':
634
- case 'autogen':
635
- case 'ag2':
636
- case 'google-adk':
637
- case 'openai-agents':
638
- case 'pydantic-ai':
639
- case 'smolagents':
640
- case 'strands':
641
- return formatSdkGatedEnv(sops, proxyUrl, SDK_GATED_FRAMEWORKS[harness]);
642
- case 'mastra':
643
- case 'vercel-ai-sdk':
644
- case 'eve':
645
- case 'trueforge':
646
- case 'ai-sdk-harness':
647
- case 'ai-sdk-workflow':
648
- return formatJsSdkGatedEnv(sops, proxyUrl, JS_SDK_GATED_FRAMEWORKS[harness]);
649
- default:
650
- return formatMarkdown(sops);
651
- }
652
- }
653
- /** Cursor / Claude Code / Windsurf: Markdown with `---` separators. */
654
- function formatMarkdown(sops) {
655
- const header = fileHeader();
656
- const sections = sops.map((sop) => {
657
- // Hybrid approach: full SOP content + sop:// pointer comment for traceability
658
- const ref = sop.sopRef ? `\n${sop.sopRef}` : '';
659
- return [`## ${sop.title}`, '', sop.content + ref].join('\n');
660
- });
661
- return header + sections.join('\n\n---\n\n') + '\n';
662
- }
663
- /** Antigravity: JSON with `customInstructions` field. */
664
- function formatAntigravity(sops) {
665
- const combinedContent = sops
666
- .map((sop) => `## ${sop.title}\n\n${sop.content}`)
667
- .join('\n\n---\n\n');
668
- const payload = {
669
- _comment: 'Intutic Governance Rules (auto-generated) — DO NOT EDIT',
670
- _lastSync: newIso(),
671
- customInstructions: combinedContent,
672
- };
673
- return JSON.stringify(payload, null, 2) + '\n';
674
- }
675
- /** Aider: YAML with `extra-instructions` field. */
676
- function formatAider(sops) {
677
- const header = fileHeader();
678
- const combinedContent = sops
679
- .map((sop) => `## ${sop.title}\n\n${sop.content}`)
680
- .join('\n\n---\n\n');
681
- // YAML multiline block scalar using `|`
682
- const indented = combinedContent
683
- .split('\n')
684
- .map((line) => ` ${line}`)
685
- .join('\n');
686
- return header + `extra-instructions: |\n${indented}\n`;
687
- }
688
- /** OpenHands: TOML with `[intutic]` section. */
689
- function formatOpenHands(sops) {
690
- const header = fileHeader();
691
- const combinedContent = sops
692
- .map((sop) => `## ${sop.title}\n\n${sop.content}`)
693
- .join('\n\n---\n\n');
694
- // TOML multiline basic string uses triple quotes
695
- const escaped = combinedContent
696
- .replace(/\\/g, '\\\\')
697
- .replace(/"""/g, '\\"\\"\\"');
698
- return (header +
699
- `[intutic]\n` +
700
- `last_sync = "${newIso()}"\n` +
701
- `governance_rules = """\n${escaped}\n"""\n`);
702
- }
703
- /** Codex: `.env.intutic` with proxy URL vars. */
704
- function formatCodex(sops, proxyUrl) {
705
- const header = fileHeader();
706
- const sopIds = sops.map((sop) => sop.sopId).join(',');
707
- return (header +
708
- `INTUTIC_PROXY_URL=${proxyUrl}\n` +
709
- `INTUTIC_SOP_IDS=${sopIds}\n` +
710
- `INTUTIC_LAST_SYNC=${newIso()}\n`);
711
- }
712
- /**
713
- * LangGraph: `.env.intutic` with proxy URL vars, plus a pointer at the
714
- * SDK-side tool gate. LangGraph tools are plain Python callables in the
715
- * agent's own process — there is no config or hook file this daemon could
716
- * write a tool-call gate into, so the env vars govern LLM egress only and
717
- * the blocking gate ships in `intutic-clawde` (`intutic_clawde.gate`).
718
- */
719
- function formatLanggraph(sops, proxyUrl) {
720
- return (formatCodex(sops, proxyUrl) +
721
- '\n' +
722
- '# These env vars govern LLM egress only. LangGraph tools run in your own\n' +
723
- '# Python process, where no config or hook file can gate them — the\n' +
724
- '# blocking tool gate ships SDK-side:\n' +
725
- '# pip install intutic-clawde\n' +
726
- '# from intutic_clawde.gate import guard_tools\n');
727
- }
728
- /**
729
- * Wave 1: seven more frameworks in LangGraph's family — tools are plain
730
- * Python callables/objects in the agent's own process, so the daemon has no
731
- * on-disk hook/config file to gate a call with, and every one of these
732
- * writes the same `.env.intutic` shape `formatLanggraph` does (proxy URL
733
- * vars + a comment pointing at the SDK-side gate). Declared as data here,
734
- * rather than as seven more hand-copied `formatXxx` functions, so the shape
735
- * cannot drift per-framework the way `gateBody.ts`'s module doc warns
736
- * hand-copied gate logic does.
737
- *
738
- * `pipExtra` is omitted for the three frameworks with no dedicated
739
- * `intutic_clawde.gate.adapters.*` module yet (autogen, ag2, pydantic-ai,
740
- * smolagents ship in a later wave — see `gateRegistry.ts`'s NO_GATE rows) —
741
- * their tools are governed today through the framework-agnostic
742
- * `@guard`/`guard_tools` helpers, which need no optional import.
743
- */
744
- const SDK_GATED_FRAMEWORKS = {
745
- langchain: {
746
- label: 'LangChain',
747
- pipExtra: 'langchain',
748
- importLine: 'from intutic_clawde.gate.adapters.langchain import IntuticMiddleware',
749
- docsSlug: 'langchain',
750
- },
751
- crewai: {
752
- label: 'CrewAI',
753
- pipExtra: 'crewai',
754
- importLine: 'from intutic_clawde.gate.adapters.crewai import install',
755
- docsSlug: 'crewai',
756
- },
757
- autogen: {
758
- label: 'AutoGen',
759
- importLine: 'from intutic_clawde.gate import guard, guard_tools',
760
- docsSlug: 'autogen',
761
- },
762
- ag2: {
763
- label: 'AG2',
764
- importLine: 'from intutic_clawde.gate import guard, guard_tools',
765
- docsSlug: 'ag2',
766
- },
767
- 'google-adk': {
768
- label: 'Google ADK',
769
- pipExtra: 'google-adk',
770
- importLine: 'from intutic_clawde.gate.adapters.google_adk import IntuticPlugin',
771
- docsSlug: 'google-adk',
772
- },
773
- 'openai-agents': {
774
- label: 'OpenAI Agents SDK',
775
- pipExtra: 'openai-agents',
776
- importLine: 'from intutic_clawde.gate.adapters.openai_agents import intutic_tool_guardrail',
777
- docsSlug: 'openai-agents',
778
- },
779
- 'pydantic-ai': {
780
- label: 'Pydantic AI',
781
- importLine: 'from intutic_clawde.gate import guard, guard_tools',
782
- docsSlug: 'pydantic-ai',
783
- },
784
- smolagents: {
785
- label: 'smolagents',
786
- importLine: 'from intutic_clawde.gate import guard, guard_tools',
787
- docsSlug: 'smolagents',
788
- },
789
- // A4: AWS Strands Agents — dedicated adapter module from day one
790
- // (intutic_clawde.gate.adapters.strands), unlike the four `pipExtra`-less
791
- // rows above that started on the framework-agnostic helpers.
792
- strands: {
793
- label: 'Strands Agents',
794
- pipExtra: 'strands',
795
- importLine: 'from intutic_clawde.gate.adapters.strands import IntuticHookProvider',
796
- docsSlug: 'strands',
797
- },
798
- };
799
- /** Shared formatter for every Wave 1 SDK-gated framework — see SDK_GATED_FRAMEWORKS. */
800
- function formatSdkGatedEnv(sops, proxyUrl, info) {
801
- const pipInstall = info.pipExtra ? `intutic-clawde[${info.pipExtra}]` : 'intutic-clawde';
802
- return (formatCodex(sops, proxyUrl) +
803
- '\n' +
804
- `# These env vars govern LLM egress only. ${info.label} tools run in your own\n` +
805
- '# Python process, where no config or hook file can gate them — the\n' +
806
- '# blocking tool gate ships SDK-side:\n' +
807
- `# pip install ${pipInstall}\n` +
808
- `# ${info.importLine}\n` +
809
- `# See https://docs.intutic.ai/integrations/${info.docsSlug}\n`);
810
- }
811
- /**
812
- * T2: two more frameworks in LangGraph's family — tools are plain
813
- * objects/callables in the agent's own Node.js process, so the daemon has no
814
- * on-disk hook/config file to gate a call with, and both write the same
815
- * `.env.intutic` shape the Python family does. JS/TS-native, so the pointer
816
- * comment reads `npm install`/`import { ... } from '@intutic/gate/<subpath>'`
817
- * rather than `pip install`/`from intutic_clawde...` — see
818
- * `formatJsSdkGatedEnv`.
819
- */
820
- const JS_SDK_GATED_FRAMEWORKS = {
821
- mastra: {
822
- label: 'Mastra',
823
- importLine: "import { intuticHooks } from '@intutic/gate/mastra'",
824
- usageSummary: "new Agent({ ..., hooks: intuticHooks() }) — Mastra's beforeToolCall veto point. NOTE: " +
825
- 'per-call `hooks` on .generate()/.stream() OVERRIDE this, not merge with it.',
826
- docsSlug: 'mastra',
827
- },
828
- 'vercel-ai-sdk': {
829
- label: 'Vercel AI SDK',
830
- importLine: "import { intuticToolApproval, withIntuticProxy } from '@intutic/gate/vercel'",
831
- usageSummary: 'generateText({ ..., toolApproval: intuticToolApproval() }) — the toolApproval veto ' +
832
- 'point. NOTE: this framework has NO env-var LLM-egress routing; the vars above do not ' +
833
- 'route it — use withIntuticProxy(createOpenAI)(...) or equivalent in code.',
834
- docsSlug: 'vercel-ai-sdk',
835
- },
836
- eve: {
837
- label: 'eve',
838
- importLine: "import { intuticApproval, intuticAuditHooks } from '@intutic/gate/eve'",
839
- usageSummary: 'defineTool({ ..., approval: intuticApproval() }) per tool (and intuticConnectionApproval() ' +
840
- "per MCP/OpenAPI connection) — eve has no agent-level default approval field. NOTE: eve's " +
841
- 'default AI Gateway model routing is NOT proxy-governable; the vars above only reach a ' +
842
- 'direct-provider model built in code via withIntuticProxy(...). PREVIEW product.',
843
- docsSlug: 'eve',
844
- },
845
- trueforge: {
846
- label: 'TrueForge (embedded)',
847
- importLine: "import { intuticApprovalResponder } from '@intutic/gate/trueforge'",
848
- usageSummary: 'intuticApprovalResponder() answers tool.approval_required pauses with a real ' +
849
- 'Gate.guard() verdict, producing user.tool_approval items for your next ' +
850
- 'session.createTurn() call — TrueForge has no synchronous approval callback to hang a ' +
851
- "function off (confirmed against a real install); see that module's doc. Covers ONLY " +
852
- 'the embedded-library deployment mode — TrueForge run as its own standalone/hosted ' +
853
- 'server is not yet supported.',
854
- docsSlug: 'trueforge',
855
- },
856
- 'ai-sdk-harness': {
857
- label: 'AI SDK Harness',
858
- importLine: "import { intuticApprovalResponder, intuticStaticApprovals, recommendedHarnessSettings } from '@intutic/gate/harness'",
859
- usageSummary: 'toolApproval: intuticStaticApprovals(tools) routes every custom tool through the approval ' +
860
- 'flow; answer pauses with intuticApprovalResponder(). NOTE: built-in sandbox tools ignore ' +
861
- "toolApproval entirely — set permissionMode (defaults to 'allow-all') via " +
862
- 'recommendedHarnessSettings(); sandbox egress never crosses this proxy — set a sandbox ' +
863
- 'networkPolicy.',
864
- docsSlug: 'ai-sdk-harness',
865
- envPreamble: [
866
- 'These env vars govern LLM egress from THIS process only. AI SDK Harness',
867
- 'agents execute their tools server-side in Vercel Sandbox microVMs — that',
868
- 'traffic never crosses this proxy, and no config or hook file can gate the',
869
- 'sandbox from here. The blocking tool gate (custom host-executed tools',
870
- 'only) ships SDK-side:',
871
- ],
872
- },
873
- 'ai-sdk-workflow': {
874
- label: 'AI SDK Workflow',
875
- importLine: "import { intuticNeedsApproval, withIntuticApproval } from '@intutic/gate/workflow'",
876
- usageSummary: 'new WorkflowAgent({ ..., tools: withIntuticApproval(tools) }) — attaches an async ' +
877
- 'needsApproval per tool (WorkflowAgent itself has no approval option). BLOCK throws a ' +
878
- 'FatalError-compatible refusal so the durable runtime aborts instead of retry-looping ' +
879
- "the denial; ALLOW resolves false (or true with { onAllow: 'human' }).",
880
- docsSlug: 'ai-sdk-workflow',
881
- },
882
- };
883
- /** Shared formatter for every T2 JS/TS SDK-gated framework — see
884
- * JS_SDK_GATED_FRAMEWORKS. Same env-var block `formatSdkGatedEnv` writes,
885
- * but "npm install"/an ESM import line/"Node.js process" in the pointer
886
- * comment, not "pip install"/"Python process". */
887
- function formatJsSdkGatedEnv(sops, proxyUrl, info) {
888
- const preamble = info.envPreamble ?? [
889
- `These env vars govern LLM egress only. ${info.label} tools run in your own`,
890
- 'Node.js process, where no config or hook file can gate them — the',
891
- 'blocking tool gate ships SDK-side:',
892
- ];
893
- return (formatCodex(sops, proxyUrl) +
894
- '\n' +
895
- preamble.map((line) => `# ${line}\n`).join('') +
896
- `# npm install @intutic/gate\n` +
897
- `# ${info.importLine}\n` +
898
- `# ${info.usageSummary}\n` +
899
- `# See https://docs.intutic.ai/integrations/${info.docsSlug}\n`);
900
- }
901
306
  // ─── Atomic file write ───────────────────────────────────────────────
902
307
  /**
903
308
  * Write content to a file atomically.
@@ -906,11 +311,9 @@ function formatJsSdkGatedEnv(sops, proxyUrl, info) {
906
311
  * This prevents partial/corrupt files if the process is interrupted mid-write.
907
312
  *
908
313
  * If bypassEnforcementTier === 'immutable', clears the macOS user-immutable
909
- * flag before writing and re-sets it after (WS-5 Q3).
314
+ * flag before writing and re-sets it after.
910
315
  *
911
- * Exported for reuse by other full-regenerate writers in this daemon (e.g.
912
- * `lib/decisionsDigest.ts`) that want the same write-tmp-then-rename
913
- * atomicity without duplicating it.
316
+ * Exported for `lib/decisionsDigest.ts`, which regenerates whole files too.
914
317
  */
915
318
  export async function atomicWrite(filePath, content, bypassEnforcementTier) {
916
319
  const dir = node_path.dirname(filePath);