@sema-ai/registry-core 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +131 -0
- package/README.md +84 -0
- package/dist/api/auth-bridge.d.ts +332 -0
- package/dist/api/auth-bridge.d.ts.map +1 -0
- package/dist/api/auth-bridge.js +211 -0
- package/dist/api/auth-bridge.js.map +1 -0
- package/dist/api/auth.d.ts +258 -0
- package/dist/api/auth.d.ts.map +1 -0
- package/dist/api/auth.js +204 -0
- package/dist/api/auth.js.map +1 -0
- package/dist/api/scopes.d.ts +353 -0
- package/dist/api/scopes.d.ts.map +1 -0
- package/dist/api/scopes.js +229 -0
- package/dist/api/scopes.js.map +1 -0
- package/dist/bundle.d.ts +14 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +68 -0
- package/dist/bundle.js.map +1 -0
- package/dist/config-fns.d.ts +236 -0
- package/dist/config-fns.d.ts.map +1 -0
- package/dist/config-fns.js +272 -0
- package/dist/config-fns.js.map +1 -0
- package/dist/cross-domain.d.ts +35 -0
- package/dist/cross-domain.d.ts.map +1 -0
- package/dist/cross-domain.js +119 -0
- package/dist/cross-domain.js.map +1 -0
- package/dist/file-edit.d.ts +37 -0
- package/dist/file-edit.d.ts.map +1 -0
- package/dist/file-edit.js +126 -0
- package/dist/file-edit.js.map +1 -0
- package/dist/file-store.d.ts +39 -0
- package/dist/file-store.d.ts.map +1 -0
- package/dist/file-store.js +142 -0
- package/dist/file-store.js.map +1 -0
- package/dist/fleet.d.ts +479 -0
- package/dist/fleet.d.ts.map +1 -0
- package/dist/fleet.js +303 -0
- package/dist/fleet.js.map +1 -0
- package/dist/hash.d.ts +33 -0
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +60 -0
- package/dist/hash.js.map +1 -0
- package/dist/hooks.d.ts +5478 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +628 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/local-load.d.ts +33 -0
- package/dist/local-load.d.ts.map +1 -0
- package/dist/local-load.js +164 -0
- package/dist/local-load.js.map +1 -0
- package/dist/migrate.d.ts +245 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/migrate.js +543 -0
- package/dist/migrate.js.map +1 -0
- package/dist/node.d.ts +12 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +12 -0
- package/dist/node.js.map +1 -0
- package/dist/reader.d.ts +19 -0
- package/dist/reader.d.ts.map +1 -0
- package/dist/reader.js +2 -0
- package/dist/reader.js.map +1 -0
- package/dist/remote-exec.d.ts +275 -0
- package/dist/remote-exec.d.ts.map +1 -0
- package/dist/remote-exec.js +183 -0
- package/dist/remote-exec.js.map +1 -0
- package/dist/resolve-roster.d.ts +29 -0
- package/dist/resolve-roster.d.ts.map +1 -0
- package/dist/resolve-roster.js +105 -0
- package/dist/resolve-roster.js.map +1 -0
- package/dist/safety-merge-spec.d.ts +328 -0
- package/dist/safety-merge-spec.d.ts.map +1 -0
- package/dist/safety-merge-spec.js +65 -0
- package/dist/safety-merge-spec.js.map +1 -0
- package/dist/scheduler-store-node.d.ts +15 -0
- package/dist/scheduler-store-node.d.ts.map +1 -0
- package/dist/scheduler-store-node.js +43 -0
- package/dist/scheduler-store-node.js.map +1 -0
- package/dist/scheduler-store.d.ts +65 -0
- package/dist/scheduler-store.d.ts.map +1 -0
- package/dist/scheduler-store.js +59 -0
- package/dist/scheduler-store.js.map +1 -0
- package/dist/secret-refs.d.ts +34 -0
- package/dist/secret-refs.d.ts.map +1 -0
- package/dist/secret-refs.js +49 -0
- package/dist/secret-refs.js.map +1 -0
- package/dist/sha256.d.ts +17 -0
- package/dist/sha256.d.ts.map +1 -0
- package/dist/sha256.js +115 -0
- package/dist/sha256.js.map +1 -0
- package/dist/skills-manifest.d.ts +13 -0
- package/dist/skills-manifest.d.ts.map +1 -0
- package/dist/skills-manifest.js +55 -0
- package/dist/skills-manifest.js.map +1 -0
- package/dist/types.d.ts +9911 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1727 -0
- package/dist/types.js.map +1 -0
- package/package.json +130 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,oGAAoG;AACpG,eAAO,MAAM,kBAAkB,6cA4BrB,CAAC;AAEX,kGAAkG;AAClG,eAAO,MAAM,oBAAoB,0DAA2D,CAAC;AAE7F,kFAAkF;AAClF,eAAO,MAAM,WAAW,4fAA4D,CAAC;AAErF,eAAO,MAAM,aAAa,8fAAsB,CAAC;AACjD,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAI1D,eAAO,MAAM,SAAS,gCAA8B,CAAC;AACrD,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAElD;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,uJAUQ,CAAC;AAE9C,6FAA6F;AAC7F,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,SAAS,CAAC,CAEnC,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC,CA+BnF,CAAC;AAIF,eAAO,MAAM,kBAAkB,qCAAmC,CAAC;AACnE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE,eAAO,MAAM,cAAc,+EAA6E,CAAC;AACzG,MAAM,MA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,GAAG,IAAI,GAAG,MAAM,CASxE"}
|
package/dist/hooks.js
ADDED
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `hooks` — the CC-parity hooks contract (blackboard [473]/[474]/[475], stop attribution [476]).
|
|
3
|
+
*
|
|
4
|
+
* ONE definition of the FULL hook-event set — 27 CC 2.1.198 events (REF: the `jP` array in
|
|
5
|
+
* claude-cli-2.1.198.pretty.js) + 3 post-198 events the shell already ships (CwdChanged / FileChanged /
|
|
6
|
+
* MessageDisplay). Per clay's ruling ([474]): the CONTRACT is the full set from day one; the engine
|
|
7
|
+
* hook-runner (service) and the shell light events up in PHASES — adding an event later is pure
|
|
8
|
+
* implementation, never a schema change.
|
|
9
|
+
*
|
|
10
|
+
* CONSUMERS
|
|
11
|
+
* - service (sema-server): `TaskRequest.settings.hooks` wire face = `HooksConfig` below; the worker-side
|
|
12
|
+
* hook-runner translates matching entries into core `TaskSpec.hooks` in-process callbacks. Single-user
|
|
13
|
+
* gate first (requirePrincipal semantics, same as MCP injection — [473]).
|
|
14
|
+
* - core (engine): per-event input/output shapes for the engine-owned events; `stoppedBy` on settle.
|
|
15
|
+
* - shell (sema-shell): fires the shell-owned events locally (utils/hooks.ts); its zod schemas
|
|
16
|
+
* (src/entrypoints/sdk/coreSchemas.ts + src/schemas/hooks.ts) are the alignment reference for this
|
|
17
|
+
* file — field names and shapes here were ported 1:1 from the shell's CC-verified schemas.
|
|
18
|
+
*
|
|
19
|
+
* OWNERSHIP ([475], owner-single rule): every event has exactly ONE trigger owner — `engine` or `shell`.
|
|
20
|
+
* Events both sides COULD observe (e.g. UserPromptSubmit — the shell could intercept before send) fire
|
|
21
|
+
* only from their owner; the shell must NOT double-fire engine-owned events. Configuring an event whose
|
|
22
|
+
* owner hasn't shipped its runner yet is LEGAL (no validation error) — it fires when that half ships.
|
|
23
|
+
*
|
|
24
|
+
* Pure zod contract — zero runtime deps beyond zod, browser-safe, same as the rest of this package.
|
|
25
|
+
*/
|
|
26
|
+
import { z } from "zod";
|
|
27
|
+
// ── event set ──────────────────────────────────────────────────────────────────────────────────────────
|
|
28
|
+
/** CC 2.1.198 full hook-event set (jP array) — 27 events. Order matches the shell's HOOK_EVENTS. */
|
|
29
|
+
export const CC_198_HOOK_EVENTS = [
|
|
30
|
+
"PreToolUse",
|
|
31
|
+
"PostToolUse",
|
|
32
|
+
"PostToolUseFailure",
|
|
33
|
+
"PostToolBatch",
|
|
34
|
+
"Notification",
|
|
35
|
+
"UserPromptSubmit",
|
|
36
|
+
"UserPromptExpansion",
|
|
37
|
+
"SessionStart",
|
|
38
|
+
"SessionEnd",
|
|
39
|
+
"Stop",
|
|
40
|
+
"StopFailure",
|
|
41
|
+
"SubagentStart",
|
|
42
|
+
"SubagentStop",
|
|
43
|
+
"PreCompact",
|
|
44
|
+
"PostCompact",
|
|
45
|
+
"PermissionRequest",
|
|
46
|
+
"PermissionDenied",
|
|
47
|
+
"Setup",
|
|
48
|
+
"TeammateIdle",
|
|
49
|
+
"TaskCreated",
|
|
50
|
+
"TaskCompleted",
|
|
51
|
+
"Elicitation",
|
|
52
|
+
"ElicitationResult",
|
|
53
|
+
"ConfigChange",
|
|
54
|
+
"WorktreeCreate",
|
|
55
|
+
"WorktreeRemove",
|
|
56
|
+
"InstructionsLoaded",
|
|
57
|
+
];
|
|
58
|
+
/** Post-CC-2.1.198 additions the shell already ships (sema superset; CC added them after 198). */
|
|
59
|
+
export const POST_198_HOOK_EVENTS = ["CwdChanged", "FileChanged", "MessageDisplay"];
|
|
60
|
+
/** The full 30-event contract set = CC 198's 27 + the 3 post-198 shell events. */
|
|
61
|
+
export const HOOK_EVENTS = [...CC_198_HOOK_EVENTS, ...POST_198_HOOK_EVENTS];
|
|
62
|
+
export const HookEventName = z.enum(HOOK_EVENTS);
|
|
63
|
+
// ── ownership ([475] owner-single) ─────────────────────────────────────────────────────────────────────
|
|
64
|
+
export const HookOwner = z.enum(["engine", "shell"]);
|
|
65
|
+
/**
|
|
66
|
+
* Events whose TRIGGER lives in the engine half of sema's two-process wire ([475] corrected mapping):
|
|
67
|
+
* - tool-execution chain: PreToolUse / PostToolUse / PostToolUseFailure / PostToolBatch
|
|
68
|
+
* - compaction (runs engine-side): PreCompact / PostCompact
|
|
69
|
+
* - model-turn boundary (run-end is only known to the engine): Stop / StopFailure / UserPromptSubmit
|
|
70
|
+
* Everything else is shell-owned (UI / lifecycle; the permission UI, sessions, teams, worktrees, files
|
|
71
|
+
* live in the shell). Matches the shell's ENGINE_OWNED_HOOK_EVENTS verbatim.
|
|
72
|
+
*/
|
|
73
|
+
export const ENGINE_OWNED_HOOK_EVENTS = [
|
|
74
|
+
"PreToolUse",
|
|
75
|
+
"PostToolUse",
|
|
76
|
+
"PostToolUseFailure",
|
|
77
|
+
"PostToolBatch",
|
|
78
|
+
"PreCompact",
|
|
79
|
+
"PostCompact",
|
|
80
|
+
"Stop",
|
|
81
|
+
"StopFailure",
|
|
82
|
+
"UserPromptSubmit",
|
|
83
|
+
];
|
|
84
|
+
/** owner per event — single owner; the non-owner side never fires it (dedup rule, [475]). */
|
|
85
|
+
export const HOOK_EVENT_OWNER = Object.fromEntries(HOOK_EVENTS.map((e) => [e, ENGINE_OWNED_HOOK_EVENTS.includes(e) ? "engine" : "shell"]));
|
|
86
|
+
/**
|
|
87
|
+
* Which INPUT FIELD an entry's `matcher` string is matched against, per event (`null` = matchers are
|
|
88
|
+
* ignored for the event; every entry matches). Ported from the shell's getMatchingHooks switch (CC
|
|
89
|
+
* semantics: exact name, `a|b` alternation, or a JS regex; empty / `*` matches everything).
|
|
90
|
+
*/
|
|
91
|
+
export const HOOK_EVENT_MATCHER_FIELD = {
|
|
92
|
+
PreToolUse: "tool_name",
|
|
93
|
+
PostToolUse: "tool_name",
|
|
94
|
+
PostToolUseFailure: "tool_name",
|
|
95
|
+
PostToolBatch: null,
|
|
96
|
+
Notification: "notification_type",
|
|
97
|
+
UserPromptSubmit: null,
|
|
98
|
+
UserPromptExpansion: null,
|
|
99
|
+
SessionStart: "source",
|
|
100
|
+
SessionEnd: "reason",
|
|
101
|
+
Stop: null,
|
|
102
|
+
StopFailure: "error",
|
|
103
|
+
SubagentStart: "agent_type",
|
|
104
|
+
SubagentStop: "agent_type",
|
|
105
|
+
PreCompact: "trigger",
|
|
106
|
+
PostCompact: "trigger",
|
|
107
|
+
PermissionRequest: "tool_name",
|
|
108
|
+
PermissionDenied: "tool_name",
|
|
109
|
+
Setup: "trigger",
|
|
110
|
+
TeammateIdle: null,
|
|
111
|
+
TaskCreated: null,
|
|
112
|
+
TaskCompleted: null,
|
|
113
|
+
Elicitation: "mcp_server_name",
|
|
114
|
+
ElicitationResult: "mcp_server_name",
|
|
115
|
+
ConfigChange: "source",
|
|
116
|
+
WorktreeCreate: null,
|
|
117
|
+
WorktreeRemove: null,
|
|
118
|
+
InstructionsLoaded: "load_reason",
|
|
119
|
+
CwdChanged: null,
|
|
120
|
+
FileChanged: "file_path", // matched against basename(file_path)
|
|
121
|
+
MessageDisplay: null,
|
|
122
|
+
};
|
|
123
|
+
// ── shared enums (CC-verbatim) ─────────────────────────────────────────────────────────────────────────
|
|
124
|
+
export const PermissionBehavior = z.enum(["allow", "deny", "ask"]);
|
|
125
|
+
export const PermissionMode = z.enum(["default", "acceptEdits", "bypassPermissions", "plan", "dontAsk"]);
|
|
126
|
+
export const PermissionUpdateDestination = z.enum([
|
|
127
|
+
"userSettings",
|
|
128
|
+
"projectSettings",
|
|
129
|
+
"localSettings",
|
|
130
|
+
"session",
|
|
131
|
+
"cliArg",
|
|
132
|
+
]);
|
|
133
|
+
export const PermissionRuleValue = z.object({
|
|
134
|
+
toolName: z.string(),
|
|
135
|
+
ruleContent: z.string().optional(),
|
|
136
|
+
});
|
|
137
|
+
/** CC PermissionUpdate — carried in PermissionRequest inputs (suggestions) and allow decisions. */
|
|
138
|
+
export const PermissionUpdate = z.discriminatedUnion("type", [
|
|
139
|
+
z.object({ type: z.literal("addRules"), rules: z.array(PermissionRuleValue), behavior: PermissionBehavior, destination: PermissionUpdateDestination }),
|
|
140
|
+
z.object({ type: z.literal("replaceRules"), rules: z.array(PermissionRuleValue), behavior: PermissionBehavior, destination: PermissionUpdateDestination }),
|
|
141
|
+
z.object({ type: z.literal("removeRules"), rules: z.array(PermissionRuleValue), behavior: PermissionBehavior, destination: PermissionUpdateDestination }),
|
|
142
|
+
z.object({ type: z.literal("setMode"), mode: PermissionMode, destination: PermissionUpdateDestination }),
|
|
143
|
+
z.object({ type: z.literal("addDirectories"), directories: z.array(z.string()), destination: PermissionUpdateDestination }),
|
|
144
|
+
z.object({ type: z.literal("removeDirectories"), directories: z.array(z.string()), destination: PermissionUpdateDestination }),
|
|
145
|
+
]);
|
|
146
|
+
/** Assistant-turn error classes (StopFailure `error` field; CC SDKAssistantMessageError). */
|
|
147
|
+
export const AssistantTurnError = z.enum([
|
|
148
|
+
"authentication_failed",
|
|
149
|
+
"billing_error",
|
|
150
|
+
"rate_limit",
|
|
151
|
+
"invalid_request",
|
|
152
|
+
"server_error",
|
|
153
|
+
"unknown",
|
|
154
|
+
"max_output_tokens",
|
|
155
|
+
]);
|
|
156
|
+
/** SessionEnd `reason` values (CC EXIT_REASONS). */
|
|
157
|
+
export const SESSION_EXIT_REASONS = [
|
|
158
|
+
"clear",
|
|
159
|
+
"resume",
|
|
160
|
+
"logout",
|
|
161
|
+
"prompt_input_exit",
|
|
162
|
+
"other",
|
|
163
|
+
"bypass_permissions_disabled",
|
|
164
|
+
];
|
|
165
|
+
export const SessionExitReason = z.enum(SESSION_EXIT_REASONS);
|
|
166
|
+
// ── per-event input payloads (CC-verbatim field names: hook_event_name / session_id / cwd + extras) ────
|
|
167
|
+
/**
|
|
168
|
+
* Fields common to every hook input. `transcript_path` is CC-verbatim; on the engine side it resolves to
|
|
169
|
+
* the engine's session jsonl for the run (the runner fills it — the contract only fixes the field name).
|
|
170
|
+
*/
|
|
171
|
+
export const BaseHookInput = z.object({
|
|
172
|
+
session_id: z.string(),
|
|
173
|
+
transcript_path: z.string(),
|
|
174
|
+
cwd: z.string(),
|
|
175
|
+
permission_mode: z.string().optional(),
|
|
176
|
+
/** Subagent id — present only when the hook fires from within a subagent. */
|
|
177
|
+
agent_id: z.string().optional(),
|
|
178
|
+
/** Agent type name (e.g. "general-purpose") — present alongside agent_id, or on --agent main threads. */
|
|
179
|
+
agent_type: z.string().optional(),
|
|
180
|
+
});
|
|
181
|
+
export const PreToolUseHookInput = BaseHookInput.extend({
|
|
182
|
+
hook_event_name: z.literal("PreToolUse"),
|
|
183
|
+
tool_name: z.string(),
|
|
184
|
+
tool_input: z.unknown(),
|
|
185
|
+
tool_use_id: z.string(),
|
|
186
|
+
});
|
|
187
|
+
export const PostToolUseHookInput = BaseHookInput.extend({
|
|
188
|
+
hook_event_name: z.literal("PostToolUse"),
|
|
189
|
+
tool_name: z.string(),
|
|
190
|
+
tool_input: z.unknown(),
|
|
191
|
+
tool_response: z.unknown(),
|
|
192
|
+
tool_use_id: z.string(),
|
|
193
|
+
});
|
|
194
|
+
export const PostToolUseFailureHookInput = BaseHookInput.extend({
|
|
195
|
+
hook_event_name: z.literal("PostToolUseFailure"),
|
|
196
|
+
tool_name: z.string(),
|
|
197
|
+
tool_input: z.unknown(),
|
|
198
|
+
tool_use_id: z.string(),
|
|
199
|
+
error: z.string(),
|
|
200
|
+
is_interrupt: z.boolean().optional(),
|
|
201
|
+
});
|
|
202
|
+
/** One resolved tool call inside a PostToolBatch payload. */
|
|
203
|
+
export const PostToolBatchToolCall = z.object({
|
|
204
|
+
tool_name: z.string(),
|
|
205
|
+
tool_input: z.unknown(),
|
|
206
|
+
tool_use_id: z.string(),
|
|
207
|
+
tool_response: z.unknown().optional(),
|
|
208
|
+
});
|
|
209
|
+
/** Fires ONCE after every tool call in a batch resolved, before the next model request (PostToolUse is per-tool). */
|
|
210
|
+
export const PostToolBatchHookInput = BaseHookInput.extend({
|
|
211
|
+
hook_event_name: z.literal("PostToolBatch"),
|
|
212
|
+
tool_calls: z.array(PostToolBatchToolCall),
|
|
213
|
+
});
|
|
214
|
+
export const NotificationHookInput = BaseHookInput.extend({
|
|
215
|
+
hook_event_name: z.literal("Notification"),
|
|
216
|
+
message: z.string(),
|
|
217
|
+
title: z.string().optional(),
|
|
218
|
+
notification_type: z.string(),
|
|
219
|
+
});
|
|
220
|
+
export const UserPromptSubmitHookInput = BaseHookInput.extend({
|
|
221
|
+
hook_event_name: z.literal("UserPromptSubmit"),
|
|
222
|
+
prompt: z.string(),
|
|
223
|
+
});
|
|
224
|
+
/** Fired when a prompt-type slash command or MCP prompt is expanded, before the expanded prompt submits. */
|
|
225
|
+
export const UserPromptExpansionHookInput = BaseHookInput.extend({
|
|
226
|
+
hook_event_name: z.literal("UserPromptExpansion"),
|
|
227
|
+
expansion_type: z.enum(["slash_command", "mcp_prompt"]),
|
|
228
|
+
command_name: z.string(),
|
|
229
|
+
command_args: z.string(),
|
|
230
|
+
command_source: z.string().optional(),
|
|
231
|
+
prompt: z.string(),
|
|
232
|
+
});
|
|
233
|
+
export const SessionStartHookInput = BaseHookInput.extend({
|
|
234
|
+
hook_event_name: z.literal("SessionStart"),
|
|
235
|
+
source: z.enum(["startup", "resume", "clear", "compact"]),
|
|
236
|
+
model: z.string().optional(),
|
|
237
|
+
});
|
|
238
|
+
export const SessionEndHookInput = BaseHookInput.extend({
|
|
239
|
+
hook_event_name: z.literal("SessionEnd"),
|
|
240
|
+
reason: SessionExitReason,
|
|
241
|
+
});
|
|
242
|
+
export const StopHookInput = BaseHookInput.extend({
|
|
243
|
+
hook_event_name: z.literal("Stop"),
|
|
244
|
+
/** true when this Stop fired from a continuation a previous Stop hook forced (CC loop guard, cap 8). */
|
|
245
|
+
stop_hook_active: z.boolean(),
|
|
246
|
+
/** Text of the last assistant message — saves hooks a transcript read. */
|
|
247
|
+
last_assistant_message: z.string().optional(),
|
|
248
|
+
});
|
|
249
|
+
export const StopFailureHookInput = BaseHookInput.extend({
|
|
250
|
+
hook_event_name: z.literal("StopFailure"),
|
|
251
|
+
error: AssistantTurnError,
|
|
252
|
+
error_details: z.string().optional(),
|
|
253
|
+
last_assistant_message: z.string().optional(),
|
|
254
|
+
});
|
|
255
|
+
export const SubagentStartHookInput = BaseHookInput.extend({
|
|
256
|
+
hook_event_name: z.literal("SubagentStart"),
|
|
257
|
+
agent_id: z.string(),
|
|
258
|
+
agent_type: z.string(),
|
|
259
|
+
});
|
|
260
|
+
export const SubagentStopHookInput = BaseHookInput.extend({
|
|
261
|
+
hook_event_name: z.literal("SubagentStop"),
|
|
262
|
+
stop_hook_active: z.boolean(),
|
|
263
|
+
agent_id: z.string(),
|
|
264
|
+
agent_transcript_path: z.string(),
|
|
265
|
+
agent_type: z.string(),
|
|
266
|
+
last_assistant_message: z.string().optional(),
|
|
267
|
+
});
|
|
268
|
+
export const PreCompactHookInput = BaseHookInput.extend({
|
|
269
|
+
hook_event_name: z.literal("PreCompact"),
|
|
270
|
+
trigger: z.enum(["manual", "auto"]),
|
|
271
|
+
custom_instructions: z.string().nullable(),
|
|
272
|
+
});
|
|
273
|
+
export const PostCompactHookInput = BaseHookInput.extend({
|
|
274
|
+
hook_event_name: z.literal("PostCompact"),
|
|
275
|
+
trigger: z.enum(["manual", "auto"]),
|
|
276
|
+
/** The conversation summary produced by compaction. */
|
|
277
|
+
compact_summary: z.string(),
|
|
278
|
+
});
|
|
279
|
+
export const PermissionRequestHookInput = BaseHookInput.extend({
|
|
280
|
+
hook_event_name: z.literal("PermissionRequest"),
|
|
281
|
+
tool_name: z.string(),
|
|
282
|
+
tool_input: z.unknown(),
|
|
283
|
+
permission_suggestions: z.array(PermissionUpdate).optional(),
|
|
284
|
+
});
|
|
285
|
+
export const PermissionDeniedHookInput = BaseHookInput.extend({
|
|
286
|
+
hook_event_name: z.literal("PermissionDenied"),
|
|
287
|
+
tool_name: z.string(),
|
|
288
|
+
tool_input: z.unknown(),
|
|
289
|
+
tool_use_id: z.string(),
|
|
290
|
+
reason: z.string(),
|
|
291
|
+
});
|
|
292
|
+
export const SetupHookInput = BaseHookInput.extend({
|
|
293
|
+
hook_event_name: z.literal("Setup"),
|
|
294
|
+
trigger: z.enum(["init", "maintenance"]),
|
|
295
|
+
});
|
|
296
|
+
export const TeammateIdleHookInput = BaseHookInput.extend({
|
|
297
|
+
hook_event_name: z.literal("TeammateIdle"),
|
|
298
|
+
teammate_name: z.string(),
|
|
299
|
+
team_name: z.string(),
|
|
300
|
+
});
|
|
301
|
+
export const TaskCreatedHookInput = BaseHookInput.extend({
|
|
302
|
+
hook_event_name: z.literal("TaskCreated"),
|
|
303
|
+
task_id: z.string(),
|
|
304
|
+
task_subject: z.string(),
|
|
305
|
+
task_description: z.string().optional(),
|
|
306
|
+
teammate_name: z.string().optional(),
|
|
307
|
+
team_name: z.string().optional(),
|
|
308
|
+
});
|
|
309
|
+
export const TaskCompletedHookInput = BaseHookInput.extend({
|
|
310
|
+
hook_event_name: z.literal("TaskCompleted"),
|
|
311
|
+
task_id: z.string(),
|
|
312
|
+
task_subject: z.string(),
|
|
313
|
+
task_description: z.string().optional(),
|
|
314
|
+
teammate_name: z.string().optional(),
|
|
315
|
+
team_name: z.string().optional(),
|
|
316
|
+
});
|
|
317
|
+
/** MCP server requests user input; hooks can auto-respond (accept/decline) instead of showing the dialog. */
|
|
318
|
+
export const ElicitationHookInput = BaseHookInput.extend({
|
|
319
|
+
hook_event_name: z.literal("Elicitation"),
|
|
320
|
+
mcp_server_name: z.string(),
|
|
321
|
+
message: z.string(),
|
|
322
|
+
mode: z.enum(["form", "url"]).optional(),
|
|
323
|
+
url: z.string().optional(),
|
|
324
|
+
elicitation_id: z.string().optional(),
|
|
325
|
+
requested_schema: z.record(z.string(), z.unknown()).optional(),
|
|
326
|
+
});
|
|
327
|
+
/** After the user responds to an MCP elicitation; hooks can observe/override before it reaches the server. */
|
|
328
|
+
export const ElicitationResultHookInput = BaseHookInput.extend({
|
|
329
|
+
hook_event_name: z.literal("ElicitationResult"),
|
|
330
|
+
mcp_server_name: z.string(),
|
|
331
|
+
elicitation_id: z.string().optional(),
|
|
332
|
+
mode: z.enum(["form", "url"]).optional(),
|
|
333
|
+
action: z.enum(["accept", "decline", "cancel"]),
|
|
334
|
+
content: z.record(z.string(), z.unknown()).optional(),
|
|
335
|
+
});
|
|
336
|
+
export const CONFIG_CHANGE_SOURCES = ["user_settings", "project_settings", "local_settings", "policy_settings", "skills"];
|
|
337
|
+
export const ConfigChangeHookInput = BaseHookInput.extend({
|
|
338
|
+
hook_event_name: z.literal("ConfigChange"),
|
|
339
|
+
source: z.enum(CONFIG_CHANGE_SOURCES),
|
|
340
|
+
file_path: z.string().optional(),
|
|
341
|
+
});
|
|
342
|
+
export const WorktreeCreateHookInput = BaseHookInput.extend({
|
|
343
|
+
hook_event_name: z.literal("WorktreeCreate"),
|
|
344
|
+
name: z.string(),
|
|
345
|
+
});
|
|
346
|
+
export const WorktreeRemoveHookInput = BaseHookInput.extend({
|
|
347
|
+
hook_event_name: z.literal("WorktreeRemove"),
|
|
348
|
+
worktree_path: z.string(),
|
|
349
|
+
});
|
|
350
|
+
export const INSTRUCTIONS_LOAD_REASONS = ["session_start", "nested_traversal", "path_glob_match", "include", "compact"];
|
|
351
|
+
export const INSTRUCTIONS_MEMORY_TYPES = ["User", "Project", "Local", "Managed"];
|
|
352
|
+
export const InstructionsLoadedHookInput = BaseHookInput.extend({
|
|
353
|
+
hook_event_name: z.literal("InstructionsLoaded"),
|
|
354
|
+
file_path: z.string(),
|
|
355
|
+
memory_type: z.enum(INSTRUCTIONS_MEMORY_TYPES),
|
|
356
|
+
load_reason: z.enum(INSTRUCTIONS_LOAD_REASONS),
|
|
357
|
+
globs: z.array(z.string()).optional(),
|
|
358
|
+
trigger_file_path: z.string().optional(),
|
|
359
|
+
parent_file_path: z.string().optional(),
|
|
360
|
+
});
|
|
361
|
+
// ── post-198 shell events (sema superset; CC added after 2.1.198) ──
|
|
362
|
+
export const CwdChangedHookInput = BaseHookInput.extend({
|
|
363
|
+
hook_event_name: z.literal("CwdChanged"),
|
|
364
|
+
old_cwd: z.string(),
|
|
365
|
+
new_cwd: z.string(),
|
|
366
|
+
});
|
|
367
|
+
export const FileChangedHookInput = BaseHookInput.extend({
|
|
368
|
+
hook_event_name: z.literal("FileChanged"),
|
|
369
|
+
file_path: z.string(),
|
|
370
|
+
event: z.enum(["change", "add", "unlink"]),
|
|
371
|
+
});
|
|
372
|
+
/** Streams display deltas of an assistant message. Display-only: stored message & model view untouched. */
|
|
373
|
+
export const MessageDisplayHookInput = BaseHookInput.extend({
|
|
374
|
+
hook_event_name: z.literal("MessageDisplay"),
|
|
375
|
+
turn_id: z.string(),
|
|
376
|
+
/** Stable per-message UUID across flushes (not the API msg_… id). */
|
|
377
|
+
message_id: z.string(),
|
|
378
|
+
/** Zero-based flush index within the message. */
|
|
379
|
+
index: z.number().int(),
|
|
380
|
+
/** True on the message's last flush (exactly one per message). */
|
|
381
|
+
final: z.boolean(),
|
|
382
|
+
/** Newly completed lines since the prior flush (final flush may end mid-line / be empty). */
|
|
383
|
+
delta: z.string(),
|
|
384
|
+
});
|
|
385
|
+
/** Any hook input — discriminated on `hook_event_name` (all 30 events). */
|
|
386
|
+
export const HookInput = z.discriminatedUnion("hook_event_name", [
|
|
387
|
+
PreToolUseHookInput,
|
|
388
|
+
PostToolUseHookInput,
|
|
389
|
+
PostToolUseFailureHookInput,
|
|
390
|
+
PostToolBatchHookInput,
|
|
391
|
+
NotificationHookInput,
|
|
392
|
+
UserPromptSubmitHookInput,
|
|
393
|
+
UserPromptExpansionHookInput,
|
|
394
|
+
SessionStartHookInput,
|
|
395
|
+
SessionEndHookInput,
|
|
396
|
+
StopHookInput,
|
|
397
|
+
StopFailureHookInput,
|
|
398
|
+
SubagentStartHookInput,
|
|
399
|
+
SubagentStopHookInput,
|
|
400
|
+
PreCompactHookInput,
|
|
401
|
+
PostCompactHookInput,
|
|
402
|
+
PermissionRequestHookInput,
|
|
403
|
+
PermissionDeniedHookInput,
|
|
404
|
+
SetupHookInput,
|
|
405
|
+
TeammateIdleHookInput,
|
|
406
|
+
TaskCreatedHookInput,
|
|
407
|
+
TaskCompletedHookInput,
|
|
408
|
+
ElicitationHookInput,
|
|
409
|
+
ElicitationResultHookInput,
|
|
410
|
+
ConfigChangeHookInput,
|
|
411
|
+
WorktreeCreateHookInput,
|
|
412
|
+
WorktreeRemoveHookInput,
|
|
413
|
+
InstructionsLoadedHookInput,
|
|
414
|
+
CwdChangedHookInput,
|
|
415
|
+
FileChangedHookInput,
|
|
416
|
+
MessageDisplayHookInput,
|
|
417
|
+
]);
|
|
418
|
+
// ── hook output / decision semantics (CC-verbatim, with the [473]-receipt design points pinned) ────────
|
|
419
|
+
//
|
|
420
|
+
// DESIGN POINT ① (allow semantics — service [473] receipt): CC's PreToolUse `allow` means "skip the
|
|
421
|
+
// permission prompt". In sema the engine's two-phase invariant is the FLOOR: a hook `allow` can never
|
|
422
|
+
// override a toolPolicy `deny`/`ask` — it at most ADDS NO prompt on top of what policy already allows.
|
|
423
|
+
// `deny`/`block` always wins over policy. The enum below is CC's wording; the engine clamps to policy.
|
|
424
|
+
//
|
|
425
|
+
// DESIGN POINT ② (execution plane): hook COMMANDS execute on the WORKER HOST (CC semantics: the user's
|
|
426
|
+
// machine ≙ the engine's host process), NOT inside the task sandbox — that is precisely why the
|
|
427
|
+
// single-user gate exists (requirePrincipal !== true; multi-tenant default-deny). See the config section
|
|
428
|
+
// below for the declared cwd/env/timeout injection surface.
|
|
429
|
+
/** Legacy top-level decision (CC): "approve" ≈ allow, "block" feeds `reason` back to the model. */
|
|
430
|
+
export const HookDecision = z.enum(["approve", "block"]);
|
|
431
|
+
/** PermissionRequest hook decision — mirrors CC PermissionResult (allow may rewrite input/permissions). */
|
|
432
|
+
export const HookPermissionRequestDecision = z.union([
|
|
433
|
+
z.object({
|
|
434
|
+
behavior: z.literal("allow"),
|
|
435
|
+
updatedInput: z.record(z.string(), z.unknown()).optional(),
|
|
436
|
+
updatedPermissions: z.array(PermissionUpdate).optional(),
|
|
437
|
+
}),
|
|
438
|
+
z.object({
|
|
439
|
+
behavior: z.literal("deny"),
|
|
440
|
+
message: z.string().optional(),
|
|
441
|
+
interrupt: z.boolean().optional(),
|
|
442
|
+
}),
|
|
443
|
+
]);
|
|
444
|
+
/** Per-event `hookSpecificOutput` payloads (only events with event-specific output appear here). */
|
|
445
|
+
export const HookSpecificOutput = z.union([
|
|
446
|
+
z.object({
|
|
447
|
+
hookEventName: z.literal("PreToolUse"),
|
|
448
|
+
/** See DESIGN POINT ① — CC wording, engine clamps `allow` to the toolPolicy floor. */
|
|
449
|
+
permissionDecision: PermissionBehavior.optional(),
|
|
450
|
+
permissionDecisionReason: z.string().optional(),
|
|
451
|
+
/** Hook-rewritten tool input (CC updatedInput). */
|
|
452
|
+
updatedInput: z.record(z.string(), z.unknown()).optional(),
|
|
453
|
+
additionalContext: z.string().optional(),
|
|
454
|
+
}),
|
|
455
|
+
z.object({
|
|
456
|
+
hookEventName: z.literal("PostToolUse"),
|
|
457
|
+
additionalContext: z.string().optional(),
|
|
458
|
+
/** Rewrites the tool output the model sees (CC: MCP tools). */
|
|
459
|
+
updatedMCPToolOutput: z.unknown().optional(),
|
|
460
|
+
}),
|
|
461
|
+
z.object({ hookEventName: z.literal("PostToolUseFailure"), additionalContext: z.string().optional() }),
|
|
462
|
+
z.object({ hookEventName: z.literal("UserPromptSubmit"), additionalContext: z.string().optional() }),
|
|
463
|
+
z.object({
|
|
464
|
+
hookEventName: z.literal("SessionStart"),
|
|
465
|
+
additionalContext: z.string().optional(),
|
|
466
|
+
initialUserMessage: z.string().optional(),
|
|
467
|
+
/** Absolute paths to watch for FileChanged hooks. */
|
|
468
|
+
watchPaths: z.array(z.string()).optional(),
|
|
469
|
+
}),
|
|
470
|
+
z.object({ hookEventName: z.literal("Setup"), additionalContext: z.string().optional() }),
|
|
471
|
+
z.object({ hookEventName: z.literal("SubagentStart"), additionalContext: z.string().optional() }),
|
|
472
|
+
z.object({ hookEventName: z.literal("Notification"), additionalContext: z.string().optional() }),
|
|
473
|
+
z.object({ hookEventName: z.literal("PermissionDenied"), retry: z.boolean().optional() }),
|
|
474
|
+
z.object({ hookEventName: z.literal("PermissionRequest"), decision: HookPermissionRequestDecision }),
|
|
475
|
+
z.object({
|
|
476
|
+
hookEventName: z.literal("Elicitation"),
|
|
477
|
+
action: z.enum(["accept", "decline", "cancel"]).optional(),
|
|
478
|
+
content: z.record(z.string(), z.unknown()).optional(),
|
|
479
|
+
}),
|
|
480
|
+
z.object({
|
|
481
|
+
hookEventName: z.literal("ElicitationResult"),
|
|
482
|
+
action: z.enum(["accept", "decline", "cancel"]).optional(),
|
|
483
|
+
content: z.record(z.string(), z.unknown()).optional(),
|
|
484
|
+
}),
|
|
485
|
+
z.object({ hookEventName: z.literal("CwdChanged"), watchPaths: z.array(z.string()).optional() }),
|
|
486
|
+
z.object({ hookEventName: z.literal("FileChanged"), watchPaths: z.array(z.string()).optional() }),
|
|
487
|
+
z.object({ hookEventName: z.literal("WorktreeCreate"), worktreePath: z.string() }),
|
|
488
|
+
]);
|
|
489
|
+
/**
|
|
490
|
+
* Synchronous hook JSON output (stdout of a command hook, CC-verbatim). Exit-code semantics ride
|
|
491
|
+
* alongside: exit 0 = success (stdout parsed as this shape when JSON), exit 2 = BLOCKING error (stderr
|
|
492
|
+
* fed back to the model), any other exit = non-blocking error (stderr shown to the user).
|
|
493
|
+
*/
|
|
494
|
+
export const SyncHookOutput = z.object({
|
|
495
|
+
/** Whether the run should continue after the hook (default true). */
|
|
496
|
+
continue: z.boolean().optional(),
|
|
497
|
+
/** Hide stdout from the transcript (default false). */
|
|
498
|
+
suppressOutput: z.boolean().optional(),
|
|
499
|
+
/** Message shown when continue === false. */
|
|
500
|
+
stopReason: z.string().optional(),
|
|
501
|
+
decision: HookDecision.optional(),
|
|
502
|
+
/** Explanation for the decision (fed to the model on "block"). */
|
|
503
|
+
reason: z.string().optional(),
|
|
504
|
+
/** Warning shown to the user. */
|
|
505
|
+
systemMessage: z.string().optional(),
|
|
506
|
+
hookSpecificOutput: HookSpecificOutput.optional(),
|
|
507
|
+
});
|
|
508
|
+
/** `{"async": true}` — the hook keeps running in the background (CC async hook protocol). */
|
|
509
|
+
export const AsyncHookOutput = z.object({
|
|
510
|
+
async: z.literal(true),
|
|
511
|
+
asyncTimeout: z.number().optional(),
|
|
512
|
+
});
|
|
513
|
+
export const HookOutput = z.union([AsyncHookOutput, SyncHookOutput]);
|
|
514
|
+
// ── hooks CONFIG surface (what `TaskRequest.settings.hooks` carries; CC settings-JSON shaped) ──────────
|
|
515
|
+
//
|
|
516
|
+
// DESIGN POINT ② (execution plane, declared): the runner executes `command` hooks on the WORKER HOST:
|
|
517
|
+
// - cwd = the task's workspace root (CC: the project dir)
|
|
518
|
+
// - env = the worker host process env, PLUS the injected names in HOOK_INJECTED_ENV below
|
|
519
|
+
// - timeout = per-entry `timeout` (seconds), else DEFAULT_HOOK_TIMEOUT_SECONDS
|
|
520
|
+
// - stdin = the HookInput JSON; stdout parsed as HookOutput (see exit-code semantics above)
|
|
521
|
+
// `prompt` / `agent` / `http` hook types are part of the config contract (the shell already parses
|
|
522
|
+
// them); the service runner may phase them in after `command` — config validity is not phased.
|
|
523
|
+
/** Env names the hook runner injects into a command hook's environment (CC-parity). */
|
|
524
|
+
export const HOOK_INJECTED_ENV = [
|
|
525
|
+
/** Absolute path of the project/workspace root. */
|
|
526
|
+
"CLAUDE_PROJECT_DIR",
|
|
527
|
+
/** SessionStart only: file a hook may append `KEY=value` lines to, persisted into the session env. */
|
|
528
|
+
"CLAUDE_ENV_FILE",
|
|
529
|
+
];
|
|
530
|
+
/** Default per-hook timeout when an entry does not set one (seconds; CC default). */
|
|
531
|
+
export const DEFAULT_HOOK_TIMEOUT_SECONDS = 60;
|
|
532
|
+
/** A non-empty string with no NUL byte (spawn()/JSON-safe). */
|
|
533
|
+
const hookStr = z.string().min(1).refine((s) => !s.includes("\0"), "must not contain a NUL byte");
|
|
534
|
+
/**
|
|
535
|
+
* `if` condition — permission-rule syntax (e.g. "Bash(git *)") evaluated against tool_name/tool_input
|
|
536
|
+
* BEFORE spawning the hook (only meaningful on tool events). Shell superset field, CC-compatible.
|
|
537
|
+
*/
|
|
538
|
+
const IfCondition = z.string().optional();
|
|
539
|
+
const HookEntryCommon = {
|
|
540
|
+
if: IfCondition,
|
|
541
|
+
/** Timeout in seconds for this entry (default DEFAULT_HOOK_TIMEOUT_SECONDS). */
|
|
542
|
+
timeout: z.number().positive().optional(),
|
|
543
|
+
/** Spinner status message (shell superset). */
|
|
544
|
+
statusMessage: z.string().optional(),
|
|
545
|
+
/** Run once, then remove (shell superset). */
|
|
546
|
+
once: z.boolean().optional(),
|
|
547
|
+
};
|
|
548
|
+
/** `command` — shell command on the worker host (DESIGN POINT ②). First runner phase. */
|
|
549
|
+
export const CommandHookEntry = z.object({
|
|
550
|
+
type: z.literal("command"),
|
|
551
|
+
command: hookStr,
|
|
552
|
+
/** 'bash' = the user's $SHELL family; 'powershell' = pwsh. Default bash. */
|
|
553
|
+
shell: z.enum(["bash", "powershell"]).optional(),
|
|
554
|
+
/** Run in background without blocking (shell superset). */
|
|
555
|
+
async: z.boolean().optional(),
|
|
556
|
+
/** Background + wake the model on exit 2 (implies async; shell superset). */
|
|
557
|
+
asyncRewake: z.boolean().optional(),
|
|
558
|
+
...HookEntryCommon,
|
|
559
|
+
});
|
|
560
|
+
/** `prompt` — one-shot LLM evaluation of the hook input ($ARGUMENTS = input JSON). */
|
|
561
|
+
export const PromptHookEntry = z.object({
|
|
562
|
+
type: z.literal("prompt"),
|
|
563
|
+
prompt: hookStr,
|
|
564
|
+
model: z.string().optional(),
|
|
565
|
+
...HookEntryCommon,
|
|
566
|
+
});
|
|
567
|
+
/** `agent` — agentic verifier loop over the hook input ($ARGUMENTS = input JSON). */
|
|
568
|
+
export const AgentHookEntry = z.object({
|
|
569
|
+
type: z.literal("agent"),
|
|
570
|
+
prompt: hookStr,
|
|
571
|
+
model: z.string().optional(),
|
|
572
|
+
...HookEntryCommon,
|
|
573
|
+
});
|
|
574
|
+
/** `http` — POST the hook input JSON to a URL. Headers may reference $NAMEs listed in allowedEnvVars
|
|
575
|
+
* (env-NAME interpolation only — the config NEVER carries a secret value; same boundary as the rest
|
|
576
|
+
* of this package). */
|
|
577
|
+
export const HttpHookEntry = z.object({
|
|
578
|
+
type: z.literal("http"),
|
|
579
|
+
url: hookStr,
|
|
580
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
581
|
+
allowedEnvVars: z.array(z.string()).optional(),
|
|
582
|
+
...HookEntryCommon,
|
|
583
|
+
});
|
|
584
|
+
/** One configured hook (CC settings shape + shell superset fields; discriminated on `type`). */
|
|
585
|
+
export const HookEntry = z.discriminatedUnion("type", [CommandHookEntry, PromptHookEntry, AgentHookEntry, HttpHookEntry]);
|
|
586
|
+
/** One matcher group: `matcher` (see HOOK_EVENT_MATCHER_FIELD) + the hooks it fires. */
|
|
587
|
+
export const HookMatcherEntry = z.object({
|
|
588
|
+
/** Exact name, `a|b` alternation, or JS regex; empty/`*`/absent matches everything. */
|
|
589
|
+
matcher: z.string().optional(),
|
|
590
|
+
hooks: z.array(HookEntry),
|
|
591
|
+
});
|
|
592
|
+
export const HooksConfig = z.record(HookEventName, z.array(HookMatcherEntry));
|
|
593
|
+
/**
|
|
594
|
+
* DESIGN POINT ③ (slot semantics — RESERVED, core to finalize): how `spec.hooks` composes with the
|
|
595
|
+
* engine's own `deps.hooks` (e.g. the service's process-level toolTracer). "override" = the spec slot
|
|
596
|
+
* replaces deps wholesale (the toolPolicy precedent); "compose" = user hooks run first, deps observers
|
|
597
|
+
* retained. The service runner needs "compose" for tracer survival — pinned here as the reserved wire
|
|
598
|
+
* vocabulary so the field (`TaskRequest.settings.hooksSlotSemantics`) can land without a schema rev
|
|
599
|
+
* once core rules on it. NOT yet consumed — do not gate on it.
|
|
600
|
+
*/
|
|
601
|
+
export const HooksSlotSemantics = z.enum(["override", "compose"]);
|
|
602
|
+
// ── stop attribution ([476]: settle/terminal events + TaskResult + the cancel verb) ────────────────────
|
|
603
|
+
/**
|
|
604
|
+
* Who stopped a run/subagent (CC "was stopped by …" parity):
|
|
605
|
+
* - "user" — the human (shell cancel, Esc, /stop). CC: "was stopped by user".
|
|
606
|
+
* - "parent" — the parent agent stopped its subtask (engine-internal; only core can attribute this). CC: "was stopped by Claude".
|
|
607
|
+
* - "system" — infrastructure (timeout, drain, budget, crash-stop).
|
|
608
|
+
* Wire contract ([476], service ack'd): ① the cancel verb (`runs/:id/cancel` / tasks equivalent) accepts
|
|
609
|
+
* an OPTIONAL `source` of this enum — absent ⇒ "user" (back-compat); ② task settle / task_progress
|
|
610
|
+
* terminal events and TaskResult carry `stoppedBy` (only when the run was stopped, not on natural end);
|
|
611
|
+
* ③ core stamps the origin into settle for engine-internal stops (parent) — service passes it through.
|
|
612
|
+
*/
|
|
613
|
+
export const StoppedBy = z.enum(["user", "parent", "system"]);
|
|
614
|
+
/** Cancel-verb `source` param — same vocabulary; absent on the wire means DEFAULT_CANCEL_SOURCE. */
|
|
615
|
+
export const CancelSource = StoppedBy;
|
|
616
|
+
export const DEFAULT_CANCEL_SOURCE = "user";
|
|
617
|
+
/** CC-parity attribution text (REF ~"was stopped by": parent→"by Claude", user→"by user", else bare). */
|
|
618
|
+
export function stopAttributionText(stoppedBy) {
|
|
619
|
+
switch (stoppedBy) {
|
|
620
|
+
case "user":
|
|
621
|
+
return "was stopped by user";
|
|
622
|
+
case "parent":
|
|
623
|
+
return "was stopped by Claude";
|
|
624
|
+
default:
|
|
625
|
+
return "was stopped";
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
//# sourceMappingURL=hooks.js.map
|