@vibefield/puppeteer-adapter-claude 0.0.0-stage → 0.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 (215) hide show
  1. package/LICENSE +21 -0
  2. package/dist/detection.d.ts +78 -0
  3. package/dist/detection.d.ts.map +1 -0
  4. package/dist/detection.js +167 -0
  5. package/dist/detection.js.map +1 -0
  6. package/dist/driver.d.ts +145 -0
  7. package/dist/driver.d.ts.map +1 -0
  8. package/dist/driver.js +840 -0
  9. package/dist/driver.js.map +1 -0
  10. package/dist/generated/detection-surface.d.ts +30 -0
  11. package/dist/generated/detection-surface.d.ts.map +1 -0
  12. package/dist/generated/detection-surface.js +34 -0
  13. package/dist/generated/detection-surface.js.map +1 -0
  14. package/dist/generated/registry.d.ts +45 -0
  15. package/dist/generated/registry.d.ts.map +1 -0
  16. package/dist/generated/registry.js +287 -0
  17. package/dist/generated/registry.js.map +1 -0
  18. package/dist/index.d.ts +27 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +27 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/launch/hook-switches.d.ts +32 -0
  23. package/dist/launch/hook-switches.d.ts.map +1 -0
  24. package/dist/launch/hook-switches.js +56 -0
  25. package/dist/launch/hook-switches.js.map +1 -0
  26. package/dist/launch/invocation-grammar.d.ts +196 -0
  27. package/dist/launch/invocation-grammar.d.ts.map +1 -0
  28. package/dist/launch/invocation-grammar.js +857 -0
  29. package/dist/launch/invocation-grammar.js.map +1 -0
  30. package/dist/launch/native-invocation.d.ts +42 -0
  31. package/dist/launch/native-invocation.d.ts.map +1 -0
  32. package/dist/launch/native-invocation.js +130 -0
  33. package/dist/launch/native-invocation.js.map +1 -0
  34. package/dist/launch/prepare.d.ts +137 -0
  35. package/dist/launch/prepare.d.ts.map +1 -0
  36. package/dist/launch/prepare.js +317 -0
  37. package/dist/launch/prepare.js.map +1 -0
  38. package/dist/launch/settings.d.ts +63 -0
  39. package/dist/launch/settings.d.ts.map +1 -0
  40. package/dist/launch/settings.js +94 -0
  41. package/dist/launch/settings.js.map +1 -0
  42. package/dist/normalization/adapter.d.ts +3 -0
  43. package/dist/normalization/adapter.d.ts.map +1 -0
  44. package/dist/normalization/adapter.js +4 -0
  45. package/dist/normalization/adapter.js.map +1 -0
  46. package/dist/normalization/compaction.d.ts +4 -0
  47. package/dist/normalization/compaction.d.ts.map +1 -0
  48. package/dist/normalization/compaction.js +7 -0
  49. package/dist/normalization/compaction.js.map +1 -0
  50. package/dist/normalization/context-window.d.ts +3 -0
  51. package/dist/normalization/context-window.d.ts.map +1 -0
  52. package/dist/normalization/context-window.js +4 -0
  53. package/dist/normalization/context-window.js.map +1 -0
  54. package/dist/normalization/conversation.d.ts +3 -0
  55. package/dist/normalization/conversation.d.ts.map +1 -0
  56. package/dist/normalization/conversation.js +4 -0
  57. package/dist/normalization/conversation.js.map +1 -0
  58. package/dist/normalization/delegation.d.ts +4 -0
  59. package/dist/normalization/delegation.d.ts.map +1 -0
  60. package/dist/normalization/delegation.js +7 -0
  61. package/dist/normalization/delegation.js.map +1 -0
  62. package/dist/normalization/effort.d.ts +8 -0
  63. package/dist/normalization/effort.d.ts.map +1 -0
  64. package/dist/normalization/effort.js +16 -0
  65. package/dist/normalization/effort.js.map +1 -0
  66. package/dist/normalization/environment.d.ts +5 -0
  67. package/dist/normalization/environment.d.ts.map +1 -0
  68. package/dist/normalization/environment.js +10 -0
  69. package/dist/normalization/environment.js.map +1 -0
  70. package/dist/normalization/index.d.ts +20 -0
  71. package/dist/normalization/index.d.ts.map +1 -0
  72. package/dist/normalization/index.js +20 -0
  73. package/dist/normalization/index.js.map +1 -0
  74. package/dist/normalization/interaction.d.ts +38 -0
  75. package/dist/normalization/interaction.d.ts.map +1 -0
  76. package/dist/normalization/interaction.js +60 -0
  77. package/dist/normalization/interaction.js.map +1 -0
  78. package/dist/normalization/mode.d.ts +11 -0
  79. package/dist/normalization/mode.d.ts.map +1 -0
  80. package/dist/normalization/mode.js +37 -0
  81. package/dist/normalization/mode.js.map +1 -0
  82. package/dist/normalization/model.d.ts +5 -0
  83. package/dist/normalization/model.d.ts.map +1 -0
  84. package/dist/normalization/model.js +7 -0
  85. package/dist/normalization/model.js.map +1 -0
  86. package/dist/normalization/monitor-capabilities.d.ts +4 -0
  87. package/dist/normalization/monitor-capabilities.d.ts.map +1 -0
  88. package/dist/normalization/monitor-capabilities.js +121 -0
  89. package/dist/normalization/monitor-capabilities.js.map +1 -0
  90. package/dist/normalization/monitor.d.ts +46 -0
  91. package/dist/normalization/monitor.d.ts.map +1 -0
  92. package/dist/normalization/monitor.js +332 -0
  93. package/dist/normalization/monitor.js.map +1 -0
  94. package/dist/normalization/notification.d.ts +4 -0
  95. package/dist/normalization/notification.d.ts.map +1 -0
  96. package/dist/normalization/notification.js +9 -0
  97. package/dist/normalization/notification.js.map +1 -0
  98. package/dist/normalization/pipeline.d.ts +56 -0
  99. package/dist/normalization/pipeline.d.ts.map +1 -0
  100. package/dist/normalization/pipeline.js +472 -0
  101. package/dist/normalization/pipeline.js.map +1 -0
  102. package/dist/normalization/session.d.ts +6 -0
  103. package/dist/normalization/session.d.ts.map +1 -0
  104. package/dist/normalization/session.js +17 -0
  105. package/dist/normalization/session.js.map +1 -0
  106. package/dist/normalization/tool.d.ts +8 -0
  107. package/dist/normalization/tool.d.ts.map +1 -0
  108. package/dist/normalization/tool.js +64 -0
  109. package/dist/normalization/tool.js.map +1 -0
  110. package/dist/normalization/turn.d.ts +6 -0
  111. package/dist/normalization/turn.d.ts.map +1 -0
  112. package/dist/normalization/turn.js +15 -0
  113. package/dist/normalization/turn.js.map +1 -0
  114. package/dist/normalization/types.d.ts +47 -0
  115. package/dist/normalization/types.d.ts.map +1 -0
  116. package/dist/normalization/types.js +2 -0
  117. package/dist/normalization/types.js.map +1 -0
  118. package/dist/normalization/wire.d.ts +10 -0
  119. package/dist/normalization/wire.d.ts.map +1 -0
  120. package/dist/normalization/wire.js +75 -0
  121. package/dist/normalization/wire.js.map +1 -0
  122. package/dist/normalization/workspace.d.ts +5 -0
  123. package/dist/normalization/workspace.d.ts.map +1 -0
  124. package/dist/normalization/workspace.js +68 -0
  125. package/dist/normalization/workspace.js.map +1 -0
  126. package/dist/observation/hook-bridge.d.ts +72 -0
  127. package/dist/observation/hook-bridge.d.ts.map +1 -0
  128. package/dist/observation/hook-bridge.js +250 -0
  129. package/dist/observation/hook-bridge.js.map +1 -0
  130. package/dist/observation/otel/actor.d.ts +14 -0
  131. package/dist/observation/otel/actor.d.ts.map +1 -0
  132. package/dist/observation/otel/actor.js +44 -0
  133. package/dist/observation/otel/actor.js.map +1 -0
  134. package/dist/observation/otel/capability.d.ts +4 -0
  135. package/dist/observation/otel/capability.d.ts.map +1 -0
  136. package/dist/observation/otel/capability.js +24 -0
  137. package/dist/observation/otel/capability.js.map +1 -0
  138. package/dist/observation/otel/index.d.ts +6 -0
  139. package/dist/observation/otel/index.d.ts.map +1 -0
  140. package/dist/observation/otel/index.js +6 -0
  141. package/dist/observation/otel/index.js.map +1 -0
  142. package/dist/observation/otel/model.d.ts +9 -0
  143. package/dist/observation/otel/model.d.ts.map +1 -0
  144. package/dist/observation/otel/model.js +16 -0
  145. package/dist/observation/otel/model.js.map +1 -0
  146. package/dist/observation/otel/usage.d.ts +16 -0
  147. package/dist/observation/otel/usage.d.ts.map +1 -0
  148. package/dist/observation/otel/usage.js +75 -0
  149. package/dist/observation/otel/usage.js.map +1 -0
  150. package/dist/observation/otel/wire.d.ts +15 -0
  151. package/dist/observation/otel/wire.d.ts.map +1 -0
  152. package/dist/observation/otel/wire.js +147 -0
  153. package/dist/observation/otel/wire.js.map +1 -0
  154. package/dist/observation/semantic-provider.d.ts +45 -0
  155. package/dist/observation/semantic-provider.d.ts.map +1 -0
  156. package/dist/observation/semantic-provider.js +8 -0
  157. package/dist/observation/semantic-provider.js.map +1 -0
  158. package/dist/observation/status-channel.d.ts +70 -0
  159. package/dist/observation/status-channel.d.ts.map +1 -0
  160. package/dist/observation/status-channel.js +268 -0
  161. package/dist/observation/status-channel.js.map +1 -0
  162. package/dist/observation/transcript/conversation.d.ts +6 -0
  163. package/dist/observation/transcript/conversation.d.ts.map +1 -0
  164. package/dist/observation/transcript/conversation.js +170 -0
  165. package/dist/observation/transcript/conversation.js.map +1 -0
  166. package/dist/observation/transcript/index.d.ts +5 -0
  167. package/dist/observation/transcript/index.d.ts.map +1 -0
  168. package/dist/observation/transcript/index.js +5 -0
  169. package/dist/observation/transcript/index.js.map +1 -0
  170. package/dist/observation/transcript/provider.d.ts +7 -0
  171. package/dist/observation/transcript/provider.d.ts.map +1 -0
  172. package/dist/observation/transcript/provider.js +132 -0
  173. package/dist/observation/transcript/provider.js.map +1 -0
  174. package/dist/observation/transcript/services/jsonl-reader.d.ts +12 -0
  175. package/dist/observation/transcript/services/jsonl-reader.d.ts.map +1 -0
  176. package/dist/observation/transcript/services/jsonl-reader.js +140 -0
  177. package/dist/observation/transcript/services/jsonl-reader.js.map +1 -0
  178. package/dist/observation/transcript/services/yield.d.ts +3 -0
  179. package/dist/observation/transcript/services/yield.d.ts.map +1 -0
  180. package/dist/observation/transcript/services/yield.js +15 -0
  181. package/dist/observation/transcript/services/yield.js.map +1 -0
  182. package/dist/observation/transcript/wire.d.ts +26 -0
  183. package/dist/observation/transcript/wire.d.ts.map +1 -0
  184. package/dist/observation/transcript/wire.js +89 -0
  185. package/dist/observation/transcript/wire.js.map +1 -0
  186. package/dist/services/account-usage.d.ts +86 -0
  187. package/dist/services/account-usage.d.ts.map +1 -0
  188. package/dist/services/account-usage.js +813 -0
  189. package/dist/services/account-usage.js.map +1 -0
  190. package/dist/services/distribution.d.ts +64 -0
  191. package/dist/services/distribution.d.ts.map +1 -0
  192. package/dist/services/distribution.js +255 -0
  193. package/dist/services/distribution.js.map +1 -0
  194. package/dist/services/event-source.d.ts +29 -0
  195. package/dist/services/event-source.d.ts.map +1 -0
  196. package/dist/services/event-source.js +38 -0
  197. package/dist/services/event-source.js.map +1 -0
  198. package/dist/services/extensions.d.ts +46 -0
  199. package/dist/services/extensions.d.ts.map +1 -0
  200. package/dist/services/extensions.js +1263 -0
  201. package/dist/services/extensions.js.map +1 -0
  202. package/dist/services/models.d.ts +6 -0
  203. package/dist/services/models.d.ts.map +1 -0
  204. package/dist/services/models.js +90 -0
  205. package/dist/services/models.js.map +1 -0
  206. package/dist/services/profiles.d.ts +48 -0
  207. package/dist/services/profiles.d.ts.map +1 -0
  208. package/dist/services/profiles.js +176 -0
  209. package/dist/services/profiles.js.map +1 -0
  210. package/dist/services/prompt.d.ts +39 -0
  211. package/dist/services/prompt.d.ts.map +1 -0
  212. package/dist/services/prompt.js +107 -0
  213. package/dist/services/prompt.js.map +1 -0
  214. package/package.json +46 -3
  215. package/README.md +0 -3
@@ -0,0 +1,317 @@
1
+ /**
2
+ * Native Claude session preparation (DESIGN §16.2 steps 4–5, 8; §11
3
+ * PreparedNativeSession). Allocates the runtime session UUID used by hooks,
4
+ * OTLP records and transcripts, writes the generated hook
5
+ * settings to a per-session file, and builds the interactive spawn command.
6
+ *
7
+ * The command is native-interactive ONLY (§16.3): never -p/--print/
8
+ * --output-format/--input-format — those select structured print mode, a
9
+ * different process class. A typed launch's own arguments ride after the
10
+ * managed flags, and invocation-grammar.ts carries none of those. The token
11
+ * VALUE rides `env` (injected into the process, resolved by Claude's env
12
+ * interpolation), never the on-disk settings.
13
+ */
14
+ import { randomUUID } from 'node:crypto';
15
+ import { Buffer } from 'node:buffer';
16
+ import { constants, accessSync, existsSync, readdirSync } from 'node:fs';
17
+ import { mkdtemp, rm, writeFile } from 'node:fs/promises';
18
+ import { homedir, tmpdir } from 'node:os';
19
+ import { delimiter, join, resolve } from 'node:path';
20
+ import { AgentLaunchRefusedError } from '@vibefield/puppeteer-core';
21
+ import { CLAUDE_HOOK_FORWARDER_SOURCE, generateHookSettings } from './settings.js';
22
+ import { readClaudeHookSwitches } from './hook-switches.js';
23
+ import { CLAUDE_STATUS_CHANNEL_FORWARDER_SOURCE, resolveClaudeStatusChannels, } from '../observation/status-channel.js';
24
+ /**
25
+ * Where Claude keeps a conversation: `<root>/projects/<cwd slug>/<id>.jsonl`,
26
+ * the root being the config dir (the imposter mirrors the layout under its
27
+ * state root). Claude finds a session by id from any directory (probed
28
+ * 2.1.269, 2026-09-11), so every project folder is searched.
29
+ */
30
+ export function locateClaudeTranscript(sessionId, root) {
31
+ const projects = join(root, 'projects');
32
+ let folders;
33
+ try {
34
+ folders = readdirSync(projects);
35
+ }
36
+ catch {
37
+ return undefined;
38
+ }
39
+ for (const folder of folders) {
40
+ const candidate = join(projects, folder, `${sessionId}.jsonl`);
41
+ if (existsSync(candidate))
42
+ return candidate;
43
+ }
44
+ return undefined;
45
+ }
46
+ /**
47
+ * A resume of a conversation that is not on disk: refused before launch rather than crashed after it.
48
+ * Not an adapter's refusal whose words reach a person: its message names where the transcripts are
49
+ * kept (a profile's root among them), so it stays text for logs. A host's restore falls back on it.
50
+ */
51
+ export class ClaudeConversationMissingError extends Error {
52
+ sessionId;
53
+ root;
54
+ code = 'CLAUDE_CONVERSATION_MISSING';
55
+ constructor(sessionId, root) {
56
+ super(`Claude conversation ${sessionId} is not on disk under ${join(root, 'projects')}; it cannot be resumed`);
57
+ this.sessionId = sessionId;
58
+ this.root = root;
59
+ this.name = 'ClaudeConversationMissingError';
60
+ }
61
+ }
62
+ /**
63
+ * A launch whose person's settings switch every hook off (`disableAllHooks: true`): the managed
64
+ * hooks would never fire (probed 2.1.283, findings.md §7.5), so it is refused before launch, typed
65
+ * or a host's own spawn, rather than run as a session the host cannot observe. The adapter's own refusal
66
+ * ({@link AgentLaunchRefusedError}): the runtime carries its sentence and code to the person.
67
+ */
68
+ export class ClaudeHooksOffError extends AgentLaunchRefusedError {
69
+ source;
70
+ settingsPath;
71
+ constructor(source, settingsPath) {
72
+ super('CLAUDE_HOOKS_OFF', `your ${source} settings turn hooks off (disableAllHooks), and a managed session is observed through hooks`);
73
+ this.source = source;
74
+ this.settingsPath = settingsPath;
75
+ this.name = 'ClaudeHooksOffError';
76
+ }
77
+ }
78
+ const CLAUDE_OTEL_CONFLICT_KEYS = [
79
+ 'OTEL_LOGS_EXPORTER',
80
+ 'OTEL_EXPORTER_OTLP_ENDPOINT',
81
+ 'OTEL_EXPORTER_OTLP_LOGS_ENDPOINT',
82
+ 'OTEL_EXPORTER_OTLP_PROTOCOL',
83
+ 'OTEL_EXPORTER_OTLP_LOGS_PROTOCOL',
84
+ 'OTEL_EXPORTER_OTLP_COMPRESSION',
85
+ 'OTEL_EXPORTER_OTLP_LOGS_COMPRESSION',
86
+ 'OTEL_EXPORTER_OTLP_HEADERS',
87
+ 'OTEL_EXPORTER_OTLP_LOGS_HEADERS',
88
+ 'OTEL_LOGS_EXPORT_INTERVAL',
89
+ ];
90
+ /** Preserve a caller's exporter; conflicting routes disable Puppeteer's OTLP observation. */
91
+ export function hasClaudeOtelExporterConflict(environment = process.env) {
92
+ return CLAUDE_OTEL_CONFLICT_KEYS.some((key) => Boolean(environment[key]?.trim()));
93
+ }
94
+ // A script executable (the emulator bin, PATH shims) is not directly
95
+ // exec-able: POSIX needs an exec bit the repo can't guarantee, Windows has
96
+ // no shebang handling. Run it under node so the recipe is a real binary on
97
+ // every platform and through every spawn path (PTY spawn, spawn-through
98
+ // execve, test harnesses). Under Electron `process.execPath` is the electron
99
+ // binary, so resolve a real node from PATH instead (electron-as-node has
100
+ // stdin/event-loop quirks that break the bin's control channel — probed
101
+ // 2026-08-07); ELECTRON_RUN_AS_NODE is the documented fallback.
102
+ const SCRIPT_EXECUTABLE = /\.(mjs|cjs|js|ts)$/;
103
+ function resolveNodeBinary() {
104
+ const names = process.platform === 'win32' ? ['node.exe', 'node'] : ['node'];
105
+ for (const directory of (process.env.PATH ?? '').split(delimiter)) {
106
+ if (!directory)
107
+ continue;
108
+ for (const name of names) {
109
+ const candidate = resolve(directory, name);
110
+ try {
111
+ accessSync(candidate, constants.X_OK);
112
+ return candidate;
113
+ }
114
+ catch {
115
+ // next PATH entry
116
+ }
117
+ }
118
+ }
119
+ return undefined;
120
+ }
121
+ function posixQuote(value) {
122
+ return `'${value.replaceAll("'", "'\\''")}'`;
123
+ }
124
+ function powershellLiteral(value) {
125
+ return `'${value.replaceAll("'", "''")}'`;
126
+ }
127
+ /** Status lines are shell commands, so render one platform-specific, injection-safe invocation. */
128
+ export function statusLineForwarderCommand(executable, scriptPath, targetPlatform = process.platform, channel = 'root') {
129
+ const args = channel === 'subagent' ? [scriptPath, 'subagent'] : [scriptPath];
130
+ if (targetPlatform === 'win32') {
131
+ const encoded = Buffer.from(`& ${powershellLiteral(executable)} ${args.map(powershellLiteral).join(' ')}`, 'utf16le').toString('base64');
132
+ // Explicit PowerShell works whether Claude selected Git Bash or PowerShell
133
+ // as its outer Windows shell; encoded input keeps path metacharacters inert.
134
+ return `powershell.exe -NoProfile -NonInteractive -EncodedCommand ${encoded}`;
135
+ }
136
+ return [posixQuote(executable), ...args.map(posixQuote)].join(' ');
137
+ }
138
+ export async function prepareClaudeSession(options) {
139
+ if (options.resume && options.resumeInvocation) {
140
+ throw new Error('Claude preparation accepts resume or resumeInvocation, not both');
141
+ }
142
+ if (options.settingSources !== undefined && options.settingSources.length === 0) {
143
+ throw new Error('Claude settingSources must contain at least one source');
144
+ }
145
+ // On resume the session keeps its own id + transcript, so that id IS the
146
+ // session id; otherwise reuse a caller-chosen id or mint one.
147
+ const sessionId = options.resume ?? options.sessionId ?? randomUUID();
148
+ const rawClaudeConfigDir = (options.configDir ?? process.env.CLAUDE_CONFIG_DIR)?.trim() || undefined;
149
+ // Claude interprets a relative CLAUDE_CONFIG_DIR from the launched process's
150
+ // cwd. Resolve it at that same boundary before both discovery and spawn so
151
+ // an Electron/main-process cwd cannot select a different delegate.
152
+ const claudeConfigDir = rawClaudeConfigDir ? resolve(options.cwd, rawClaudeConfigDir) : undefined;
153
+ // The person's own settings layers, as the launch will read them. Their hook switches decide what
154
+ // the managed settings must restate, and whether the launch may start at all, before anything is
155
+ // written. The imposter reads none of them.
156
+ const personLayers = { settingSources: options.settingSources, configDir: claudeConfigDir, home: options.home };
157
+ const hookSwitches = options.readsNoSettingsFiles || options.env?.PUPPETEER_IMPOSTER_HOME !== undefined
158
+ ? {}
159
+ : await readClaudeHookSwitches(options.cwd, personLayers);
160
+ if (options.refuseHooksOff !== false && hookSwitches.hooksOff) {
161
+ throw new ClaudeHooksOffError(hookSwitches.hooksOff.source, hookSwitches.hooksOff.path);
162
+ }
163
+ // Own the temp dir only when we create it; a caller-supplied settingsDir is
164
+ // the caller's to clean, so it stays out of filesToCleanup (§23: no
165
+ // destroying state we didn't create).
166
+ const ownsDir = options.settingsDir === undefined;
167
+ const dir = options.settingsDir ?? (await mkdtemp(join(tmpdir(), 'puppeteer-claude-')));
168
+ const settingsPath = join(dir, `${sessionId}.settings.json`);
169
+ const hookForwarderPath = join(dir, `${sessionId}.hooks.mjs`);
170
+ const statusLineForwarderPath = options.statusLineEndpoint || options.subagentStatusLineEndpoint
171
+ ? join(dir, `${sessionId}.statusline.mjs`)
172
+ : undefined;
173
+ const runningUnderElectron = process.versions.electron !== undefined;
174
+ const resolvedNode = runningUnderElectron ? resolveNodeBinary() : undefined;
175
+ const electronAsNodeFallback = runningUnderElectron && resolvedNode === undefined;
176
+ const nodeRunner = resolvedNode ?? process.execPath;
177
+ if (options.resume !== undefined) {
178
+ // `claude --resume <id>` for an id with no transcript exits at once with
179
+ // "No conversation found", which a host can only read as a crash. A
180
+ // provisional identity (a picker that was never answered, a session that
181
+ // never took a turn) is the usual way a persisted continuation gets here.
182
+ // Refuse before launch so the caller can fall back instead.
183
+ const root = options.env?.PUPPETEER_IMPOSTER_HOME ?? claudeConfigDir ?? join(homedir(), '.claude');
184
+ if (!locateClaudeTranscript(sessionId, root))
185
+ throw new ClaudeConversationMissingError(sessionId, root);
186
+ }
187
+ const discoveredStatusChannels = statusLineForwarderPath && !options.readsNoSettingsFiles
188
+ ? await resolveClaudeStatusChannels(options.cwd, personLayers)
189
+ : {};
190
+ const existingStatusLine = options.statusLineEndpoint
191
+ ? options.existingStatusLine === undefined
192
+ ? discoveredStatusChannels.statusLine
193
+ : (options.existingStatusLine ?? undefined)
194
+ : undefined;
195
+ const existingSubagentStatusLine = options.subagentStatusLineEndpoint
196
+ ? options.existingSubagentStatusLine === undefined
197
+ ? discoveredStatusChannels.subagentStatusLine
198
+ : (options.existingSubagentStatusLine ?? undefined)
199
+ : undefined;
200
+ const statusLine = statusLineForwarderPath && options.statusLineEndpoint
201
+ ? {
202
+ type: 'command',
203
+ command: statusLineForwarderCommand(nodeRunner, statusLineForwarderPath),
204
+ padding: existingStatusLine?.padding,
205
+ refreshInterval: existingStatusLine?.refreshInterval,
206
+ hideVimModeIndicator: existingStatusLine?.hideVimModeIndicator,
207
+ }
208
+ : undefined;
209
+ const subagentStatusLine = statusLineForwarderPath && options.subagentStatusLineEndpoint
210
+ ? {
211
+ type: 'command',
212
+ command: statusLineForwarderCommand(nodeRunner, statusLineForwarderPath, process.platform, 'subagent'),
213
+ padding: existingSubagentStatusLine?.padding,
214
+ refreshInterval: existingSubagentStatusLine?.refreshInterval,
215
+ hideVimModeIndicator: existingSubagentStatusLine?.hideVimModeIndicator,
216
+ }
217
+ : undefined;
218
+ const settings = {
219
+ ...generateHookSettings({
220
+ endpoint: options.endpoint,
221
+ tokenEnvVar: options.tokenEnvVar,
222
+ commandForwarderPath: hookForwarderPath,
223
+ commandExecutable: nodeRunner,
224
+ ...(options.fileChangeMatcher !== undefined ? { matchers: { FileChanged: options.fileChangeMatcher } } : {}),
225
+ statusLine,
226
+ subagentStatusLine,
227
+ }),
228
+ // A person's allow-list would block the managed HTTP hooks, or strip their bearer (probed
229
+ // 2.1.283: F09, F10). These settings rank above the person's layers, so each list is restated
230
+ // with the bridge's entry added (F11): every HTTP hook of theirs is allowed and interpolated as before.
231
+ ...(hookSwitches.allowedHttpHookUrls
232
+ ? { allowedHttpHookUrls: [...hookSwitches.allowedHttpHookUrls, `${new URL(options.endpoint).origin}/*`] }
233
+ : {}),
234
+ ...(hookSwitches.httpHookAllowedEnvVars
235
+ ? { httpHookAllowedEnvVars: [...hookSwitches.httpHookAllowedEnvVars, options.tokenEnvVar] }
236
+ : {}),
237
+ };
238
+ await writeFile(hookForwarderPath, CLAUDE_HOOK_FORWARDER_SOURCE, 'utf8');
239
+ if (statusLineForwarderPath) {
240
+ await writeFile(statusLineForwarderPath, CLAUDE_STATUS_CHANNEL_FORWARDER_SOURCE, 'utf8');
241
+ }
242
+ await writeFile(settingsPath, JSON.stringify(settings, null, 2), 'utf8');
243
+ // --resume and --session-id are mutually exclusive: resume continues an
244
+ // existing id, so passing --session-id would fight it. --settings composes
245
+ // with both (the hook bridge attaches to resumed sessions too — probed §6).
246
+ const args = options.resumeInvocation
247
+ ? [...options.resumeInvocation]
248
+ : options.resume
249
+ ? ['--resume', sessionId]
250
+ : ['--session-id', sessionId];
251
+ if (options.title !== undefined)
252
+ args.push('--name', options.title);
253
+ if (options.model !== undefined)
254
+ args.push('--model', options.model);
255
+ if (options.effort !== undefined)
256
+ args.push('--effort', options.effort);
257
+ if (options.settingSources !== undefined) {
258
+ args.push('--setting-sources', options.settingSources.join(','));
259
+ }
260
+ args.push('--settings', settingsPath);
261
+ if (options.permissionMode !== null)
262
+ args.push('--permission-mode', options.permissionMode ?? 'default');
263
+ args.push(...(options.carriedArgs ?? []));
264
+ if (options.prompt !== undefined && options.prompt.length > 0)
265
+ args.push('--', ...options.prompt);
266
+ const executable = options.executable ?? 'claude';
267
+ const isScript = SCRIPT_EXECUTABLE.test(executable);
268
+ const command = isScript ? nodeRunner : executable;
269
+ return {
270
+ sessionId,
271
+ command,
272
+ args: isScript ? [executable, ...args] : args,
273
+ cwd: options.cwd,
274
+ env: {
275
+ ...(options.env ?? {}),
276
+ [options.tokenEnvVar]: options.token,
277
+ ...(options.otelLogsEndpoint
278
+ ? {
279
+ CLAUDE_CODE_ENABLE_TELEMETRY: '1',
280
+ OTEL_LOGS_EXPORTER: 'otlp',
281
+ OTEL_EXPORTER_OTLP_PROTOCOL: 'http/json',
282
+ OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: options.otelLogsEndpoint,
283
+ OTEL_EXPORTER_OTLP_LOGS_HEADERS: `Authorization=Bearer%20${encodeURIComponent(options.token)}`,
284
+ OTEL_LOGS_EXPORT_INTERVAL: '1000',
285
+ }
286
+ : {}),
287
+ ...(claudeConfigDir ? { CLAUDE_CONFIG_DIR: claudeConfigDir } : {}),
288
+ ...(electronAsNodeFallback ? { ELECTRON_RUN_AS_NODE: '1' } : {}),
289
+ ...(options.statusLineEndpoint
290
+ ? {
291
+ PUPPETEER_STATUSLINE_ENDPOINT: options.statusLineEndpoint,
292
+ PUPPETEER_STATUSLINE_DELEGATE: existingStatusLine?.command ?? '',
293
+ }
294
+ : {}),
295
+ ...(options.subagentStatusLineEndpoint
296
+ ? {
297
+ PUPPETEER_SUBAGENT_STATUSLINE_ENDPOINT: options.subagentStatusLineEndpoint,
298
+ PUPPETEER_SUBAGENT_STATUSLINE_DELEGATE: existingSubagentStatusLine?.command ?? '',
299
+ }
300
+ : {}),
301
+ ...(statusLineForwarderPath ? { PUPPETEER_STATUSLINE_TOKEN_ENV_VAR: options.tokenEnvVar } : {}),
302
+ },
303
+ settingsPath,
304
+ hookForwarderPath,
305
+ statusLineForwarderPath,
306
+ filesToCleanup: ownsDir
307
+ ? [settingsPath, hookForwarderPath, ...(statusLineForwarderPath ? [statusLineForwarderPath] : []), dir]
308
+ : [settingsPath, hookForwarderPath, ...(statusLineForwarderPath ? [statusLineForwarderPath] : [])],
309
+ };
310
+ }
311
+ /** Remove the session's generated files; tolerant of already-gone paths. */
312
+ export async function cleanupClaudeSession(prepared) {
313
+ for (const path of prepared.filesToCleanup) {
314
+ await rm(path, { recursive: true, force: true });
315
+ }
316
+ }
317
+ //# sourceMappingURL=prepare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare.js","sourceRoot":"","sources":["../../src/launch/prepare.ts"],"names":[],"m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AAC,CAAC;KACrG,CAAC;AACJ,CAAC;AAED,4EAA4E;AAC5E,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,QAA+B;IACxE,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,cAAc,EAAE,CAAC;QAC3C,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Generated Claude Code hook settings (DESIGN §16.5: settings are generated
3
+ * from the registry, never handwritten). The passively observable subset of
4
+ * the candidate's complete official event set is wired; confidence remains available to
5
+ * consumers and tests so documentation-backed hooks cannot be mistaken for
6
+ * runtime captures. Matcher-gated and behavior-replacing hooks stay explicit.
7
+ *
8
+ * Transport split follows the hybrid bridge (DESIGN §16.4): http events POST
9
+ * straight to the loopback bridge; command-only events run a generated Node
10
+ * forwarder that relays stdin JSON to the same bridge on every platform.
11
+ *
12
+ * SECURITY (DESIGN §16.5, §23): settings land on disk, so the token VALUE is
13
+ * never written here. Only the `$<VAR>` reference goes in, resolved at hook
14
+ * time via Claude's `allowedEnvVars` env interpolation.
15
+ */
16
+ import { type HookEventSpec } from '../generated/registry.js';
17
+ import type { ClaudeStatusLineConfig } from '../observation/status-channel.js';
18
+ export interface HttpHookHandler {
19
+ type: 'http';
20
+ url: string;
21
+ headers: Record<string, string>;
22
+ allowedEnvVars: string[];
23
+ timeout: number;
24
+ }
25
+ export interface CommandHookHandler {
26
+ type: 'command';
27
+ /** Absolute Node executable; `args` makes this Claude's shell-free exec form. */
28
+ command: string;
29
+ args: string[];
30
+ timeout: number;
31
+ }
32
+ export type HookHandler = HttpHookHandler | CommandHookHandler;
33
+ /** One matcher block; Claude nests handlers under `hooks` (`[{ hooks: [...] }]`). */
34
+ export interface HookMatcher {
35
+ matcher?: string;
36
+ hooks: HookHandler[];
37
+ }
38
+ export interface ClaudeHookSettings {
39
+ hooks: Record<string, HookMatcher[]>;
40
+ statusLine?: ClaudeStatusLineConfig | undefined;
41
+ subagentStatusLine?: ClaudeStatusLineConfig | undefined;
42
+ }
43
+ export interface GenerateHookSettingsOptions {
44
+ /** Loopback bridge endpoint, e.g. http://127.0.0.1:<port>/hooks. */
45
+ endpoint: string;
46
+ /** Env var NAME holding the bearer token; only `$<name>` is written. */
47
+ tokenEnvVar: string;
48
+ /** Per-session, generated Node command-hook forwarder. */
49
+ commandForwarderPath: string;
50
+ /** Absolute Node executable used for shell-free command hooks; defaults to this process's executable. */
51
+ commandExecutable?: string | undefined;
52
+ /** Native matcher values. A FileChanged matcher also opts that event in. */
53
+ matchers?: Readonly<Record<string, string>> | undefined;
54
+ /** Events to wire; defaults to passively observable events in the pinned Surface. */
55
+ events?: readonly HookEventSpec[] | undefined;
56
+ /** Internal multiplexer command plus presentation fields copied from the user's line. */
57
+ statusLine?: ClaudeStatusLineConfig | undefined;
58
+ /** Internal child-row multiplexer command plus fields copied from the user's line. */
59
+ subagentStatusLine?: ClaudeStatusLineConfig | undefined;
60
+ }
61
+ export declare const CLAUDE_HOOK_FORWARDER_SOURCE = "const [endpoint, tokenEnvVar, timeoutText] = process.argv.slice(2);\nlet input = '';\nprocess.stdin.setEncoding('utf8');\nfor await (const chunk of process.stdin) input += chunk;\nconst token = process.env[tokenEnvVar];\nif (!endpoint || !tokenEnvVar || !token) process.exit(2);\ntry {\n const response = await fetch(endpoint, {\n method: 'POST',\n headers: { 'content-type': 'application/json', authorization: `Bearer ${token}` },\n body: input,\n signal: AbortSignal.timeout(Number(timeoutText)),\n });\n if (!response.ok) process.exitCode = 1;\n} catch {\n process.exitCode = 1;\n}\n";
62
+ export declare function generateHookSettings(options: GenerateHookSettingsOptions): ClaudeHookSettings;
63
+ //# sourceMappingURL=settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/launch/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;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CAAC;IACxD,qFAAqF;IACrF,MAAM,CAAC,EAAE,SAAS,aAAa,EAAE,GAAG,SAAS,CAAC;IAC9C,yFAAyF;IACzF,UAAU,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC;IAChD,sFAAsF;IACtF,kBAAkB,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC;CACzD;AAED,eAAO,MAAM,4BAA4B,+lBAiBxC,CAAC;AA0CF,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,kBAAkB,CAmB7F"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Generated Claude Code hook settings (DESIGN §16.5: settings are generated
3
+ * from the registry, never handwritten). The passively observable subset of
4
+ * the candidate's complete official event set is wired; confidence remains available to
5
+ * consumers and tests so documentation-backed hooks cannot be mistaken for
6
+ * runtime captures. Matcher-gated and behavior-replacing hooks stay explicit.
7
+ *
8
+ * Transport split follows the hybrid bridge (DESIGN §16.4): http events POST
9
+ * straight to the loopback bridge; command-only events run a generated Node
10
+ * forwarder that relays stdin JSON to the same bridge on every platform.
11
+ *
12
+ * SECURITY (DESIGN §16.5, §23): settings land on disk, so the token VALUE is
13
+ * never written here. Only the `$<VAR>` reference goes in, resolved at hook
14
+ * time via Claude's `allowedEnvVars` env interpolation.
15
+ */
16
+ import { defaultHookEvents, supportedHookEvents } from '../generated/registry.js';
17
+ export const CLAUDE_HOOK_FORWARDER_SOURCE = `const [endpoint, tokenEnvVar, timeoutText] = process.argv.slice(2);
18
+ let input = '';
19
+ process.stdin.setEncoding('utf8');
20
+ for await (const chunk of process.stdin) input += chunk;
21
+ const token = process.env[tokenEnvVar];
22
+ if (!endpoint || !tokenEnvVar || !token) process.exit(2);
23
+ try {
24
+ const response = await fetch(endpoint, {
25
+ method: 'POST',
26
+ headers: { 'content-type': 'application/json', authorization: \`Bearer \${token}\` },
27
+ body: input,
28
+ signal: AbortSignal.timeout(Number(timeoutText)),
29
+ });
30
+ if (!response.ok) process.exitCode = 1;
31
+ } catch {
32
+ process.exitCode = 1;
33
+ }
34
+ `;
35
+ function handlerFor(spec, options) {
36
+ if (spec.transport === 'http') {
37
+ return {
38
+ type: 'http',
39
+ url: options.endpoint,
40
+ headers: { Authorization: `Bearer $${options.tokenEnvVar}` },
41
+ allowedEnvVars: [options.tokenEnvVar],
42
+ timeout: spec.timeoutSec,
43
+ };
44
+ }
45
+ return {
46
+ type: 'command',
47
+ command: options.commandExecutable ?? process.execPath,
48
+ args: [options.commandForwarderPath, options.endpoint, options.tokenEnvVar, String(spec.timeoutSec * 1000)],
49
+ timeout: spec.timeoutSec,
50
+ };
51
+ }
52
+ function selectedEvents(options) {
53
+ const supported = supportedHookEvents();
54
+ const specs = new Map(supported.map((spec) => [spec.event, spec]));
55
+ for (const [event, matcher] of Object.entries(options.matchers ?? {})) {
56
+ if (!specs.has(event))
57
+ throw new Error(`Claude hook matcher references unsupported event ${event}`);
58
+ if (!matcher.trim())
59
+ throw new Error(`Claude hook matcher for ${event} must be non-empty`);
60
+ }
61
+ if (options.events) {
62
+ return options.events.map((requested) => {
63
+ const canonical = specs.get(requested.event);
64
+ if (!canonical)
65
+ throw new Error(`Claude settings reference unsupported event ${requested.event}`);
66
+ // Selection may override transport/timeout after a runtime probe, but it
67
+ // cannot downgrade Surface-owned native behavior semantics.
68
+ return { ...requested, registration: canonical.registration };
69
+ });
70
+ }
71
+ return [
72
+ ...defaultHookEvents(),
73
+ ...supported.filter((spec) => spec.registration === 'matcher-required' && options.matchers?.[spec.event]?.trim()),
74
+ ];
75
+ }
76
+ export function generateHookSettings(options) {
77
+ const hooks = {};
78
+ for (const spec of selectedEvents(options)) {
79
+ if (spec.registration === 'response-required') {
80
+ throw new Error(`Claude hook ${spec.event} replaces native behavior and requires a response; it cannot be passively observed`);
81
+ }
82
+ const matcher = options.matchers?.[spec.event];
83
+ if (spec.registration === 'matcher-required' && !matcher?.trim()) {
84
+ throw new Error(`Claude hook ${spec.event} requires a non-empty matcher`);
85
+ }
86
+ hooks[spec.event] = [{ ...(matcher ? { matcher } : {}), hooks: [handlerFor(spec, options)] }];
87
+ }
88
+ return {
89
+ hooks,
90
+ statusLine: options.statusLine,
91
+ subagentStatusLine: options.subagentStatusLine,
92
+ };
93
+ }
94
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/launch/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAsB,MAAM,0BAA0B,CAAC;AAoDtG,MAAM,CAAC,MAAM,4BAA4B,GAAG;;;;;;;;;;;;;;;;;CAiB3C,CAAC;AAEF,SAAS,UAAU,CAAC,IAAmB,EAAE,OAAoC;IAC3E,IAAI,IAAI,CAAC,SAAS,KAAK,MAAM,EAAE,CAAC;QAC9B,OAAO;YACL,IAAI,EAAE,MAAM;YACZ,GAAG,EAAE,OAAO,CAAC,QAAQ;YACrB,OAAO,EAAE,EAAE,aAAa,EAAE,WAAW,OAAO,CAAC,WAAW,EAAE,EAAE;YAC5D,cAAc,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC;YACrC,OAAO,EAAE,IAAI,CAAC,UAAU;SACzB,CAAC;IACJ,CAAC;IACD,OAAO;QACL,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,OAAO,CAAC,iBAAiB,IAAI,OAAO,CAAC,QAAQ;QACtD,IAAI,EAAE,CAAC,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;QAC3G,OAAO,EAAE,IAAI,CAAC,UAAU;KACzB,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,OAAoC;IAC1D,MAAM,SAAS,GAAG,mBAAmB,EAAE,CAAC;IACxC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG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AM,IAAI,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3C,IAAI,IAAI,CAAC,YAAY,KAAK,mBAAmB,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CACb,eAAe,IAAI,CAAC,KAAK,oFAAoF,CAC9G,CAAC;QACJ,CAAC;QACD,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/C,IAAI,IAAI,CAAC,YAAY,KAAK,kBAAkB,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;YACjE,MAAM,IAAI,KAAK,CAAC,eAAe,IAAI,CAAC,KAAK,+BAA+B,CAAC,CAAC;QAC5E,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IAChG,CAAC;IACD,OAAO;QACL,KAAK;QACL,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;KAC/C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { AgentEvent } from '@vibefield/puppeteer-core';
2
+ export declare function normalizeClaudeNativeEvent(nativeType: string): AgentEvent;
3
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/normalization/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAEzE"}
@@ -0,0 +1,4 @@
1
+ export function normalizeClaudeNativeEvent(nativeType) {
2
+ return { type: 'adapter:native-event', adapter: 'claude-code', nativeType };
3
+ }
4
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/normalization/adapter.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,0BAA0B,CAAC,UAAkB;IAC3D,OAAO,EAAE,IAAI,EAAE,sBAAsB,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { CompactionCompletedEvent, CompactionStartedEvent } from '@vibefield/puppeteer-core';
2
+ export declare function normalizeClaudeCompactionStarted(compactionId: string, trigger?: string): CompactionStartedEvent;
3
+ export declare function normalizeClaudeCompactionCompleted(compactionId: string, trigger: string | undefined, outcome: CompactionCompletedEvent['outcome']): CompactionCompletedEvent;
4
+ //# sourceMappingURL=compaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compaction.d.ts","sourceRoot":"","sources":["../../src/normalization/compaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAElG,wBAAgB,gCAAgC,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,sBAAsB,CAE/G;AAED,wBAAgB,kCAAkC,CAChD,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,wBAAwB,CAAC,SAAS,CAAC,GAC3C,wBAAwB,CAE1B"}
@@ -0,0 +1,7 @@
1
+ export function normalizeClaudeCompactionStarted(compactionId, trigger) {
2
+ return { type: 'compaction:started', compactionId, trigger };
3
+ }
4
+ export function normalizeClaudeCompactionCompleted(compactionId, trigger, outcome) {
5
+ return { type: 'compaction:completed', compactionId, trigger, outcome };
6
+ }
7
+ //# sourceMappingURL=compaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compaction.js","sourceRoot":"","sources":["../../src/normalization/compaction.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gCAAgC,CAAC,YAAoB,EAAE,OAAgB;IACrF,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,kCAAkC,CAChD,YAAoB,EACpB,OAA2B,EAC3B,OAA4C;IAE5C,OAAO,EAAE,IAAI,EAAE,sBAAsB,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC1E,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { AgentEvent } from '@vibefield/puppeteer-core';
2
+ export declare function normalizeClaudeContextInvalidated(reason: 'compacted' | 'history-changed' | 'model-changed' | 'provider-reset'): AgentEvent;
3
+ //# sourceMappingURL=context-window.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-window.d.ts","sourceRoot":"","sources":["../../src/normalization/context-window.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,WAAW,GAAG,iBAAiB,GAAG,eAAe,GAAG,gBAAgB,GAC3E,UAAU,CAEZ"}
@@ -0,0 +1,4 @@
1
+ export function normalizeClaudeContextInvalidated(reason) {
2
+ return { type: 'context-window:invalidated', reason };
3
+ }
4
+ //# sourceMappingURL=context-window.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-window.js","sourceRoot":"","sources":["../../src/normalization/context-window.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,iCAAiC,CAC/C,MAA4E;IAE5E,OAAO,EAAE,IAAI,EAAE,4BAA4B,EAAE,MAAM,EAAE,CAAC;AACxD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { AgentEvent } from '@vibefield/puppeteer-core';
2
+ export declare function normalizeClaudeAssistantMessage(messageId: string, turnId: string | undefined, text: string, final: boolean): AgentEvent;
3
+ //# sourceMappingURL=conversation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../src/normalization/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,GACb,UAAU,CAEZ"}
@@ -0,0 +1,4 @@
1
+ export function normalizeClaudeAssistantMessage(messageId, turnId, text, final) {
2
+ return { type: 'conversation:assistant-message', messageId, turnId, text, final, displayOnly: true };
3
+ }
4
+ //# sourceMappingURL=conversation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation.js","sourceRoot":"","sources":["../../src/normalization/conversation.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,+BAA+B,CAC7C,SAAiB,EACjB,MAA0B,EAC1B,IAAY,EACZ,KAAc;IAEd,OAAO,EAAE,IAAI,EAAE,gCAAgC,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AACvG,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { DelegationEvent } from '@vibefield/puppeteer-core';
2
+ export declare function normalizeClaudeSubagentStarted(subagentId: string, agentType?: string): DelegationEvent;
3
+ export declare function normalizeClaudeSubagentStopped(subagentId: string): DelegationEvent;
4
+ //# sourceMappingURL=delegation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegation.d.ts","sourceRoot":"","sources":["../../src/normalization/delegation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE,wBAAgB,8BAA8B,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,eAAe,CAEtG;AAED,wBAAgB,8BAA8B,CAAC,UAAU,EAAE,MAAM,GAAG,eAAe,CAElF"}
@@ -0,0 +1,7 @@
1
+ export function normalizeClaudeSubagentStarted(subagentId, agentType) {
2
+ return { type: 'delegation:subagent-started', subagentId, agentType };
3
+ }
4
+ export function normalizeClaudeSubagentStopped(subagentId) {
5
+ return { type: 'delegation:subagent-stopped', subagentId };
6
+ }
7
+ //# sourceMappingURL=delegation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegation.js","sourceRoot":"","sources":["../../src/normalization/delegation.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,8BAA8B,CAAC,UAAkB,EAAE,SAAkB;IACnF,OAAO,EAAE,IAAI,EAAE,6BAA6B,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,UAAkB;IAC/D,OAAO,EAAE,IAAI,EAAE,6BAA6B,EAAE,UAAU,EAAE,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { NormalizedHook, ClaudeHookPayload } from './types.js';
2
+ /** Deduplicates observed Claude effort facts for the Core effort service. */
3
+ export declare class ClaudeEffortNormalizer {
4
+ private effort;
5
+ append(result: NormalizedHook, body: ClaudeHookPayload): void;
6
+ reset(): void;
7
+ }
8
+ //# sourceMappingURL=effort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effort.d.ts","sourceRoot":"","sources":["../../src/normalization/effort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGpE,6EAA6E;AAC7E,qBAAa,sBAAsB;IACjC,OAAO,CAAC,MAAM,CAAqB;IAEnC,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,iBAAiB,GAAG,IAAI;IAO7D,KAAK,IAAI,IAAI;CAGd"}