@sema-agent/settings-schema 1.10.0 → 2.0.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.
- package/CHANGELOG.md +137 -3
- package/README.md +29 -2
- package/dist/config-fns.d.ts +72 -4
- package/dist/config-fns.js +204 -6
- package/dist/cross-domain.d.ts +8 -4
- package/dist/cross-domain.js +6 -2
- package/dist/fleet.d.ts +1 -1
- package/dist/fleet.js +1 -1
- package/dist/hooks.d.ts +367 -19
- package/dist/hooks.js +76 -8
- package/dist/remote-exec.d.ts +4 -4
- package/dist/remote-exec.js +1 -1
- package/dist/resolve-roster.d.ts +1 -1
- package/dist/scheduler-store.d.ts +13 -3
- package/dist/scheduler-store.js +13 -3
- package/dist/skills-manifest.js +1 -1
- package/dist/types.d.ts +663 -642
- package/dist/types.js +95 -46
- package/package.json +2 -1
package/dist/cross-domain.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/** A resolver over the reader, optionally shadowed by pending (same-operation) writes keyed by domain.
|
|
2
2
|
* Widened from the fat ConfigStore to the narrow {@link ConfigReader} (it only calls `getDomain`) so a TOC
|
|
3
|
-
* file source can use it without the full store.
|
|
4
|
-
|
|
3
|
+
* file source can use it without the full store.
|
|
4
|
+
*
|
|
5
|
+
* 1.11.0 renamed this from `siblingResolver` (BREAKING, zero aliases): the naming law is `build*` returns
|
|
6
|
+
* plain DATA and `create*` returns a LIVE object — this returns a closure, so it was on the wrong side of
|
|
7
|
+
* the line and carried neither prefix. A consumer's compile error IS the notice; the fix is the new name. */
|
|
8
|
+
export function createSiblingResolver(store, pending) {
|
|
5
9
|
return async (domain) => {
|
|
6
10
|
if (pending && Object.prototype.hasOwnProperty.call(pending, domain))
|
|
7
11
|
return pending[domain];
|
package/dist/fleet.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @sema-agent/settings-schema/fleet — the PURE scheduling/fleet contract for the sema-center control plane
|
|
3
|
-
* (design: cc-parity
|
|
3
|
+
* (design: the cc-parity control-plane scheduling design note, 产品拍板 2026-07-04 — "one contract, three orchestrators").
|
|
4
4
|
*
|
|
5
5
|
* Seven domains (rolling update / discovery / traffic / failover / LB / quota / token governance) are ONE
|
|
6
6
|
* data-plane lifecycle contract reused by three deployment forms — whoever HOLDS the engine handle orchestrates,
|
package/dist/fleet.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @sema-agent/settings-schema/fleet — the PURE scheduling/fleet contract for the sema-center control plane
|
|
3
|
-
* (design: cc-parity
|
|
3
|
+
* (design: the cc-parity control-plane scheduling design note, 产品拍板 2026-07-04 — "one contract, three orchestrators").
|
|
4
4
|
*
|
|
5
5
|
* Seven domains (rolling update / discovery / traffic / failover / LB / quota / token governance) are ONE
|
|
6
6
|
* data-plane lifecycle contract reused by three deployment forms — whoever HOLDS the engine handle orchestrates,
|
package/dist/hooks.d.ts
CHANGED
|
@@ -2,10 +2,15 @@
|
|
|
2
2
|
* `hooks` — the CC-parity hooks contract (incl. stop attribution).
|
|
3
3
|
*
|
|
4
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) +
|
|
6
|
-
*
|
|
7
|
-
* from day one; the engine hook-runner (service) and the shell light events
|
|
8
|
-
* later is pure implementation, never a schema change.
|
|
5
|
+
* claude-cli-2.1.198.pretty.js) + 6 post-198 events (CwdChanged / FileChanged / MessageDisplay, DirectoryAdded
|
|
6
|
+
* from CC 2.1.219, and the model-switch pair PreModelSwitch / PostModelSwitch from CC 2.1.259). Per the product
|
|
7
|
+
* ruling: the CONTRACT is the full set from day one; the engine hook-runner (service) and the shell light events
|
|
8
|
+
* up in PHASES — adding an event later is pure implementation, never a schema change.
|
|
9
|
+
*
|
|
10
|
+
* DRIFT: this package OWNS the hooks contract, so it owns noticing that CC moved. `test/upstream-drift.test.ts`
|
|
11
|
+
* compares {@link HOOK_EVENTS} against a CC anchor snapshot that `scripts/extract-cc-hook-events.mjs` extracts
|
|
12
|
+
* from the CLI bundle — a word CC has and this set does not is a RED test naming it, instead of a consumer
|
|
13
|
+
* discovering it the hard way (the 1.3.0 / 1.6.0 / 1.8.0 / 1.11.0 pattern).
|
|
9
14
|
*
|
|
10
15
|
* CONSUMERS
|
|
11
16
|
* - service (the worker server): `TaskRequest.settings.hooks` wire face = `HooksConfig` below; the worker-side
|
|
@@ -27,14 +32,20 @@ import { z } from "zod";
|
|
|
27
32
|
/** CC 2.1.198 full hook-event set (jP array) — 27 events. Order matches the shell's HOOK_EVENTS. */
|
|
28
33
|
export declare const CC_198_HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "Notification", "UserPromptSubmit", "UserPromptExpansion", "SessionStart", "SessionEnd", "Stop", "StopFailure", "SubagentStart", "SubagentStop", "PreCompact", "PostCompact", "PermissionRequest", "PermissionDenied", "Setup", "TeammateIdle", "TaskCreated", "TaskCompleted", "Elicitation", "ElicitationResult", "ConfigChange", "WorktreeCreate", "WorktreeRemove", "InstructionsLoaded"];
|
|
29
34
|
/**
|
|
30
|
-
* Post-CC-2.1.198 additions
|
|
35
|
+
* Post-CC-2.1.198 additions (sema superset; CC added them after 198).
|
|
31
36
|
* APPEND-ONLY: new members go at the tail (1.3.0 `DirectoryAdded`, CC 2.1.219 — CC's own tuple places it
|
|
32
37
|
* between FileChanged and MessageDisplay; the declaration order here is not normative, the enum is a set).
|
|
38
|
+
* 1.11.0 appends the model-switch pair (`PreModelSwitch` / `PostModelSwitch`, CC 2.1.259 — absent from the
|
|
39
|
+
* 2.1.250 corpus, so 250→259 is when they landed upstream).
|
|
40
|
+
*
|
|
41
|
+
* 🔴 This list is no longer maintained by hand-reading a CLI bundle: `test/upstream-drift.test.ts` fails
|
|
42
|
+
* (naming the missing words) whenever the CC anchor snapshot in `test/fixtures/cc-hook-events.json` holds an
|
|
43
|
+
* event this set does not, and that snapshot is produced by `scripts/extract-cc-hook-events.mjs`, never typed.
|
|
33
44
|
*/
|
|
34
|
-
export declare const POST_198_HOOK_EVENTS: readonly ["CwdChanged", "FileChanged", "MessageDisplay", "DirectoryAdded"];
|
|
35
|
-
/** The full
|
|
36
|
-
export declare const HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "Notification", "UserPromptSubmit", "UserPromptExpansion", "SessionStart", "SessionEnd", "Stop", "StopFailure", "SubagentStart", "SubagentStop", "PreCompact", "PostCompact", "PermissionRequest", "PermissionDenied", "Setup", "TeammateIdle", "TaskCreated", "TaskCompleted", "Elicitation", "ElicitationResult", "ConfigChange", "WorktreeCreate", "WorktreeRemove", "InstructionsLoaded", "CwdChanged", "FileChanged", "MessageDisplay", "DirectoryAdded"];
|
|
37
|
-
export declare const HookEventName: z.ZodEnum<["PreToolUse", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "Notification", "UserPromptSubmit", "UserPromptExpansion", "SessionStart", "SessionEnd", "Stop", "StopFailure", "SubagentStart", "SubagentStop", "PreCompact", "PostCompact", "PermissionRequest", "PermissionDenied", "Setup", "TeammateIdle", "TaskCreated", "TaskCompleted", "Elicitation", "ElicitationResult", "ConfigChange", "WorktreeCreate", "WorktreeRemove", "InstructionsLoaded", "CwdChanged", "FileChanged", "MessageDisplay", "DirectoryAdded"]>;
|
|
45
|
+
export declare const POST_198_HOOK_EVENTS: readonly ["CwdChanged", "FileChanged", "MessageDisplay", "DirectoryAdded", "PreModelSwitch", "PostModelSwitch"];
|
|
46
|
+
/** The full 33-event contract set = CC 198's 27 + the 6 post-198 events. */
|
|
47
|
+
export declare const HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "Notification", "UserPromptSubmit", "UserPromptExpansion", "SessionStart", "SessionEnd", "Stop", "StopFailure", "SubagentStart", "SubagentStop", "PreCompact", "PostCompact", "PermissionRequest", "PermissionDenied", "Setup", "TeammateIdle", "TaskCreated", "TaskCompleted", "Elicitation", "ElicitationResult", "ConfigChange", "WorktreeCreate", "WorktreeRemove", "InstructionsLoaded", "CwdChanged", "FileChanged", "MessageDisplay", "DirectoryAdded", "PreModelSwitch", "PostModelSwitch"];
|
|
48
|
+
export declare const HookEventName: z.ZodEnum<["PreToolUse", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "Notification", "UserPromptSubmit", "UserPromptExpansion", "SessionStart", "SessionEnd", "Stop", "StopFailure", "SubagentStart", "SubagentStop", "PreCompact", "PostCompact", "PermissionRequest", "PermissionDenied", "Setup", "TeammateIdle", "TaskCreated", "TaskCompleted", "Elicitation", "ElicitationResult", "ConfigChange", "WorktreeCreate", "WorktreeRemove", "InstructionsLoaded", "CwdChanged", "FileChanged", "MessageDisplay", "DirectoryAdded", "PreModelSwitch", "PostModelSwitch"]>;
|
|
38
49
|
export type HookEventName = z.infer<typeof HookEventName>;
|
|
39
50
|
export declare const HookOwner: z.ZodEnum<["engine", "shell"]>;
|
|
40
51
|
export type HookOwner = z.infer<typeof HookOwner>;
|
|
@@ -1263,8 +1274,8 @@ export declare const ElicitationHookInput: z.ZodObject<{
|
|
|
1263
1274
|
transcript_path: string;
|
|
1264
1275
|
cwd: string;
|
|
1265
1276
|
hook_event_name: "Elicitation";
|
|
1266
|
-
mode?: "url" | "form" | undefined;
|
|
1267
1277
|
url?: string | undefined;
|
|
1278
|
+
mode?: "url" | "form" | undefined;
|
|
1268
1279
|
agent_type?: string | undefined;
|
|
1269
1280
|
permission_mode?: string | undefined;
|
|
1270
1281
|
agent_id?: string | undefined;
|
|
@@ -1277,8 +1288,8 @@ export declare const ElicitationHookInput: z.ZodObject<{
|
|
|
1277
1288
|
transcript_path: string;
|
|
1278
1289
|
cwd: string;
|
|
1279
1290
|
hook_event_name: "Elicitation";
|
|
1280
|
-
mode?: "url" | "form" | undefined;
|
|
1281
1291
|
url?: string | undefined;
|
|
1292
|
+
mode?: "url" | "form" | undefined;
|
|
1282
1293
|
agent_type?: string | undefined;
|
|
1283
1294
|
permission_mode?: string | undefined;
|
|
1284
1295
|
agent_id?: string | undefined;
|
|
@@ -1309,8 +1320,8 @@ export declare const ElicitationResultHookInput: z.ZodObject<{
|
|
|
1309
1320
|
cwd: string;
|
|
1310
1321
|
hook_event_name: "ElicitationResult";
|
|
1311
1322
|
action: "accept" | "decline" | "cancel";
|
|
1312
|
-
mode?: "url" | "form" | undefined;
|
|
1313
1323
|
content?: Record<string, unknown> | undefined;
|
|
1324
|
+
mode?: "url" | "form" | undefined;
|
|
1314
1325
|
agent_type?: string | undefined;
|
|
1315
1326
|
permission_mode?: string | undefined;
|
|
1316
1327
|
agent_id?: string | undefined;
|
|
@@ -1322,8 +1333,8 @@ export declare const ElicitationResultHookInput: z.ZodObject<{
|
|
|
1322
1333
|
cwd: string;
|
|
1323
1334
|
hook_event_name: "ElicitationResult";
|
|
1324
1335
|
action: "accept" | "decline" | "cancel";
|
|
1325
|
-
mode?: "url" | "form" | undefined;
|
|
1326
1336
|
content?: Record<string, unknown> | undefined;
|
|
1337
|
+
mode?: "url" | "form" | undefined;
|
|
1327
1338
|
agent_type?: string | undefined;
|
|
1328
1339
|
permission_mode?: string | undefined;
|
|
1329
1340
|
agent_id?: string | undefined;
|
|
@@ -1631,7 +1642,132 @@ export declare const DirectoryAddedHookInput: z.ZodObject<{
|
|
|
1631
1642
|
agent_id?: string | undefined;
|
|
1632
1643
|
}>;
|
|
1633
1644
|
export type DirectoryAddedHookInput = z.infer<typeof DirectoryAddedHookInput>;
|
|
1634
|
-
/**
|
|
1645
|
+
/**
|
|
1646
|
+
* What triggered a model switch (CC 2.1.259). The two events carry DIFFERENT vocabularies and that is
|
|
1647
|
+
* deliberate upstream: `PreModelSwitch` only fires for a REQUESTED switch (slash command / picker / headless
|
|
1648
|
+
* set_model), while `PostModelSwitch` also reports changes nobody requested (`auto` = automatic fallback,
|
|
1649
|
+
* `resume` = model restored while resuming a session) — those have no "before" to gate.
|
|
1650
|
+
*/
|
|
1651
|
+
export declare const MODEL_SWITCH_SOURCES: {
|
|
1652
|
+
readonly pre: readonly ["command", "picker", "sdk"];
|
|
1653
|
+
readonly post: readonly ["command", "picker", "sdk", "auto", "resume"];
|
|
1654
|
+
};
|
|
1655
|
+
/** Fires BEFORE a requested model switch; its `hookSpecificOutput.permissionDecision` can deny/ask (same
|
|
1656
|
+
* contract as PreToolUse — DESIGN POINT ① applies: the engine clamps `allow` to the policy floor). */
|
|
1657
|
+
export declare const PreModelSwitchHookInput: z.ZodObject<{
|
|
1658
|
+
session_id: z.ZodString;
|
|
1659
|
+
transcript_path: z.ZodString;
|
|
1660
|
+
cwd: z.ZodString;
|
|
1661
|
+
permission_mode: z.ZodOptional<z.ZodString>;
|
|
1662
|
+
/** Subagent id — present only when the hook fires from within a subagent. */
|
|
1663
|
+
agent_id: z.ZodOptional<z.ZodString>;
|
|
1664
|
+
/** Agent type name (e.g. "general-purpose") — present alongside agent_id, or on --agent main threads. */
|
|
1665
|
+
agent_type: z.ZodOptional<z.ZodString>;
|
|
1666
|
+
} & {
|
|
1667
|
+
source: z.ZodEnum<["command", "picker", "sdk"]>;
|
|
1668
|
+
from_model: z.ZodString;
|
|
1669
|
+
to_model: z.ZodString;
|
|
1670
|
+
requested_model: z.ZodNullable<z.ZodString>;
|
|
1671
|
+
context_tokens: z.ZodNumber;
|
|
1672
|
+
prompt_cache_warm: z.ZodBoolean;
|
|
1673
|
+
cache_ttl: z.ZodEnum<["5m", "1h"]>;
|
|
1674
|
+
estimated_cache_write_usd: z.ZodNumber;
|
|
1675
|
+
pricing: z.ZodEnum<["configured", "catalog", "default"]>;
|
|
1676
|
+
hook_event_name: z.ZodLiteral<"PreModelSwitch">;
|
|
1677
|
+
}, "strip", z.ZodTypeAny, {
|
|
1678
|
+
source: "command" | "picker" | "sdk";
|
|
1679
|
+
to_model: string;
|
|
1680
|
+
session_id: string;
|
|
1681
|
+
transcript_path: string;
|
|
1682
|
+
cwd: string;
|
|
1683
|
+
hook_event_name: "PreModelSwitch";
|
|
1684
|
+
from_model: string;
|
|
1685
|
+
requested_model: string | null;
|
|
1686
|
+
context_tokens: number;
|
|
1687
|
+
prompt_cache_warm: boolean;
|
|
1688
|
+
cache_ttl: "5m" | "1h";
|
|
1689
|
+
estimated_cache_write_usd: number;
|
|
1690
|
+
pricing: "default" | "catalog" | "configured";
|
|
1691
|
+
agent_type?: string | undefined;
|
|
1692
|
+
permission_mode?: string | undefined;
|
|
1693
|
+
agent_id?: string | undefined;
|
|
1694
|
+
}, {
|
|
1695
|
+
source: "command" | "picker" | "sdk";
|
|
1696
|
+
to_model: string;
|
|
1697
|
+
session_id: string;
|
|
1698
|
+
transcript_path: string;
|
|
1699
|
+
cwd: string;
|
|
1700
|
+
hook_event_name: "PreModelSwitch";
|
|
1701
|
+
from_model: string;
|
|
1702
|
+
requested_model: string | null;
|
|
1703
|
+
context_tokens: number;
|
|
1704
|
+
prompt_cache_warm: boolean;
|
|
1705
|
+
cache_ttl: "5m" | "1h";
|
|
1706
|
+
estimated_cache_write_usd: number;
|
|
1707
|
+
pricing: "default" | "catalog" | "configured";
|
|
1708
|
+
agent_type?: string | undefined;
|
|
1709
|
+
permission_mode?: string | undefined;
|
|
1710
|
+
agent_id?: string | undefined;
|
|
1711
|
+
}>;
|
|
1712
|
+
export type PreModelSwitchHookInput = z.infer<typeof PreModelSwitchHookInput>;
|
|
1713
|
+
/** Fires AFTER the session model changed, whatever the cause (informational; may add context). */
|
|
1714
|
+
export declare const PostModelSwitchHookInput: z.ZodObject<{
|
|
1715
|
+
session_id: z.ZodString;
|
|
1716
|
+
transcript_path: z.ZodString;
|
|
1717
|
+
cwd: z.ZodString;
|
|
1718
|
+
permission_mode: z.ZodOptional<z.ZodString>;
|
|
1719
|
+
/** Subagent id — present only when the hook fires from within a subagent. */
|
|
1720
|
+
agent_id: z.ZodOptional<z.ZodString>;
|
|
1721
|
+
/** Agent type name (e.g. "general-purpose") — present alongside agent_id, or on --agent main threads. */
|
|
1722
|
+
agent_type: z.ZodOptional<z.ZodString>;
|
|
1723
|
+
} & {
|
|
1724
|
+
source: z.ZodEnum<["command", "picker", "sdk", "auto", "resume"]>;
|
|
1725
|
+
from_model: z.ZodString;
|
|
1726
|
+
to_model: z.ZodString;
|
|
1727
|
+
requested_model: z.ZodNullable<z.ZodString>;
|
|
1728
|
+
context_tokens: z.ZodNumber;
|
|
1729
|
+
prompt_cache_warm: z.ZodBoolean;
|
|
1730
|
+
cache_ttl: z.ZodEnum<["5m", "1h"]>;
|
|
1731
|
+
estimated_cache_write_usd: z.ZodNumber;
|
|
1732
|
+
pricing: z.ZodEnum<["configured", "catalog", "default"]>;
|
|
1733
|
+
hook_event_name: z.ZodLiteral<"PostModelSwitch">;
|
|
1734
|
+
}, "strip", z.ZodTypeAny, {
|
|
1735
|
+
source: "command" | "auto" | "resume" | "picker" | "sdk";
|
|
1736
|
+
to_model: string;
|
|
1737
|
+
session_id: string;
|
|
1738
|
+
transcript_path: string;
|
|
1739
|
+
cwd: string;
|
|
1740
|
+
hook_event_name: "PostModelSwitch";
|
|
1741
|
+
from_model: string;
|
|
1742
|
+
requested_model: string | null;
|
|
1743
|
+
context_tokens: number;
|
|
1744
|
+
prompt_cache_warm: boolean;
|
|
1745
|
+
cache_ttl: "5m" | "1h";
|
|
1746
|
+
estimated_cache_write_usd: number;
|
|
1747
|
+
pricing: "default" | "catalog" | "configured";
|
|
1748
|
+
agent_type?: string | undefined;
|
|
1749
|
+
permission_mode?: string | undefined;
|
|
1750
|
+
agent_id?: string | undefined;
|
|
1751
|
+
}, {
|
|
1752
|
+
source: "command" | "auto" | "resume" | "picker" | "sdk";
|
|
1753
|
+
to_model: string;
|
|
1754
|
+
session_id: string;
|
|
1755
|
+
transcript_path: string;
|
|
1756
|
+
cwd: string;
|
|
1757
|
+
hook_event_name: "PostModelSwitch";
|
|
1758
|
+
from_model: string;
|
|
1759
|
+
requested_model: string | null;
|
|
1760
|
+
context_tokens: number;
|
|
1761
|
+
prompt_cache_warm: boolean;
|
|
1762
|
+
cache_ttl: "5m" | "1h";
|
|
1763
|
+
estimated_cache_write_usd: number;
|
|
1764
|
+
pricing: "default" | "catalog" | "configured";
|
|
1765
|
+
agent_type?: string | undefined;
|
|
1766
|
+
permission_mode?: string | undefined;
|
|
1767
|
+
agent_id?: string | undefined;
|
|
1768
|
+
}>;
|
|
1769
|
+
export type PostModelSwitchHookInput = z.infer<typeof PostModelSwitchHookInput>;
|
|
1770
|
+
/** Any hook input — discriminated on `hook_event_name` (all 33 events). */
|
|
1635
1771
|
export declare const HookInput: z.ZodDiscriminatedUnion<"hook_event_name", [z.ZodObject<{
|
|
1636
1772
|
session_id: z.ZodString;
|
|
1637
1773
|
transcript_path: z.ZodString;
|
|
@@ -2616,8 +2752,8 @@ export declare const HookInput: z.ZodDiscriminatedUnion<"hook_event_name", [z.Zo
|
|
|
2616
2752
|
transcript_path: string;
|
|
2617
2753
|
cwd: string;
|
|
2618
2754
|
hook_event_name: "Elicitation";
|
|
2619
|
-
mode?: "url" | "form" | undefined;
|
|
2620
2755
|
url?: string | undefined;
|
|
2756
|
+
mode?: "url" | "form" | undefined;
|
|
2621
2757
|
agent_type?: string | undefined;
|
|
2622
2758
|
permission_mode?: string | undefined;
|
|
2623
2759
|
agent_id?: string | undefined;
|
|
@@ -2630,8 +2766,8 @@ export declare const HookInput: z.ZodDiscriminatedUnion<"hook_event_name", [z.Zo
|
|
|
2630
2766
|
transcript_path: string;
|
|
2631
2767
|
cwd: string;
|
|
2632
2768
|
hook_event_name: "Elicitation";
|
|
2633
|
-
mode?: "url" | "form" | undefined;
|
|
2634
2769
|
url?: string | undefined;
|
|
2770
|
+
mode?: "url" | "form" | undefined;
|
|
2635
2771
|
agent_type?: string | undefined;
|
|
2636
2772
|
permission_mode?: string | undefined;
|
|
2637
2773
|
agent_id?: string | undefined;
|
|
@@ -2660,8 +2796,8 @@ export declare const HookInput: z.ZodDiscriminatedUnion<"hook_event_name", [z.Zo
|
|
|
2660
2796
|
cwd: string;
|
|
2661
2797
|
hook_event_name: "ElicitationResult";
|
|
2662
2798
|
action: "accept" | "decline" | "cancel";
|
|
2663
|
-
mode?: "url" | "form" | undefined;
|
|
2664
2799
|
content?: Record<string, unknown> | undefined;
|
|
2800
|
+
mode?: "url" | "form" | undefined;
|
|
2665
2801
|
agent_type?: string | undefined;
|
|
2666
2802
|
permission_mode?: string | undefined;
|
|
2667
2803
|
agent_id?: string | undefined;
|
|
@@ -2673,8 +2809,8 @@ export declare const HookInput: z.ZodDiscriminatedUnion<"hook_event_name", [z.Zo
|
|
|
2673
2809
|
cwd: string;
|
|
2674
2810
|
hook_event_name: "ElicitationResult";
|
|
2675
2811
|
action: "accept" | "decline" | "cancel";
|
|
2676
|
-
mode?: "url" | "form" | undefined;
|
|
2677
2812
|
content?: Record<string, unknown> | undefined;
|
|
2813
|
+
mode?: "url" | "form" | undefined;
|
|
2678
2814
|
agent_type?: string | undefined;
|
|
2679
2815
|
permission_mode?: string | undefined;
|
|
2680
2816
|
agent_id?: string | undefined;
|
|
@@ -2962,6 +3098,114 @@ export declare const HookInput: z.ZodDiscriminatedUnion<"hook_event_name", [z.Zo
|
|
|
2962
3098
|
agent_type?: string | undefined;
|
|
2963
3099
|
permission_mode?: string | undefined;
|
|
2964
3100
|
agent_id?: string | undefined;
|
|
3101
|
+
}>, z.ZodObject<{
|
|
3102
|
+
session_id: z.ZodString;
|
|
3103
|
+
transcript_path: z.ZodString;
|
|
3104
|
+
cwd: z.ZodString;
|
|
3105
|
+
permission_mode: z.ZodOptional<z.ZodString>;
|
|
3106
|
+
/** Subagent id — present only when the hook fires from within a subagent. */
|
|
3107
|
+
agent_id: z.ZodOptional<z.ZodString>;
|
|
3108
|
+
/** Agent type name (e.g. "general-purpose") — present alongside agent_id, or on --agent main threads. */
|
|
3109
|
+
agent_type: z.ZodOptional<z.ZodString>;
|
|
3110
|
+
} & {
|
|
3111
|
+
source: z.ZodEnum<["command", "picker", "sdk"]>;
|
|
3112
|
+
from_model: z.ZodString;
|
|
3113
|
+
to_model: z.ZodString;
|
|
3114
|
+
requested_model: z.ZodNullable<z.ZodString>;
|
|
3115
|
+
context_tokens: z.ZodNumber;
|
|
3116
|
+
prompt_cache_warm: z.ZodBoolean;
|
|
3117
|
+
cache_ttl: z.ZodEnum<["5m", "1h"]>;
|
|
3118
|
+
estimated_cache_write_usd: z.ZodNumber;
|
|
3119
|
+
pricing: z.ZodEnum<["configured", "catalog", "default"]>;
|
|
3120
|
+
hook_event_name: z.ZodLiteral<"PreModelSwitch">;
|
|
3121
|
+
}, "strip", z.ZodTypeAny, {
|
|
3122
|
+
source: "command" | "picker" | "sdk";
|
|
3123
|
+
to_model: string;
|
|
3124
|
+
session_id: string;
|
|
3125
|
+
transcript_path: string;
|
|
3126
|
+
cwd: string;
|
|
3127
|
+
hook_event_name: "PreModelSwitch";
|
|
3128
|
+
from_model: string;
|
|
3129
|
+
requested_model: string | null;
|
|
3130
|
+
context_tokens: number;
|
|
3131
|
+
prompt_cache_warm: boolean;
|
|
3132
|
+
cache_ttl: "5m" | "1h";
|
|
3133
|
+
estimated_cache_write_usd: number;
|
|
3134
|
+
pricing: "default" | "catalog" | "configured";
|
|
3135
|
+
agent_type?: string | undefined;
|
|
3136
|
+
permission_mode?: string | undefined;
|
|
3137
|
+
agent_id?: string | undefined;
|
|
3138
|
+
}, {
|
|
3139
|
+
source: "command" | "picker" | "sdk";
|
|
3140
|
+
to_model: string;
|
|
3141
|
+
session_id: string;
|
|
3142
|
+
transcript_path: string;
|
|
3143
|
+
cwd: string;
|
|
3144
|
+
hook_event_name: "PreModelSwitch";
|
|
3145
|
+
from_model: string;
|
|
3146
|
+
requested_model: string | null;
|
|
3147
|
+
context_tokens: number;
|
|
3148
|
+
prompt_cache_warm: boolean;
|
|
3149
|
+
cache_ttl: "5m" | "1h";
|
|
3150
|
+
estimated_cache_write_usd: number;
|
|
3151
|
+
pricing: "default" | "catalog" | "configured";
|
|
3152
|
+
agent_type?: string | undefined;
|
|
3153
|
+
permission_mode?: string | undefined;
|
|
3154
|
+
agent_id?: string | undefined;
|
|
3155
|
+
}>, z.ZodObject<{
|
|
3156
|
+
session_id: z.ZodString;
|
|
3157
|
+
transcript_path: z.ZodString;
|
|
3158
|
+
cwd: z.ZodString;
|
|
3159
|
+
permission_mode: z.ZodOptional<z.ZodString>;
|
|
3160
|
+
/** Subagent id — present only when the hook fires from within a subagent. */
|
|
3161
|
+
agent_id: z.ZodOptional<z.ZodString>;
|
|
3162
|
+
/** Agent type name (e.g. "general-purpose") — present alongside agent_id, or on --agent main threads. */
|
|
3163
|
+
agent_type: z.ZodOptional<z.ZodString>;
|
|
3164
|
+
} & {
|
|
3165
|
+
source: z.ZodEnum<["command", "picker", "sdk", "auto", "resume"]>;
|
|
3166
|
+
from_model: z.ZodString;
|
|
3167
|
+
to_model: z.ZodString;
|
|
3168
|
+
requested_model: z.ZodNullable<z.ZodString>;
|
|
3169
|
+
context_tokens: z.ZodNumber;
|
|
3170
|
+
prompt_cache_warm: z.ZodBoolean;
|
|
3171
|
+
cache_ttl: z.ZodEnum<["5m", "1h"]>;
|
|
3172
|
+
estimated_cache_write_usd: z.ZodNumber;
|
|
3173
|
+
pricing: z.ZodEnum<["configured", "catalog", "default"]>;
|
|
3174
|
+
hook_event_name: z.ZodLiteral<"PostModelSwitch">;
|
|
3175
|
+
}, "strip", z.ZodTypeAny, {
|
|
3176
|
+
source: "command" | "auto" | "resume" | "picker" | "sdk";
|
|
3177
|
+
to_model: string;
|
|
3178
|
+
session_id: string;
|
|
3179
|
+
transcript_path: string;
|
|
3180
|
+
cwd: string;
|
|
3181
|
+
hook_event_name: "PostModelSwitch";
|
|
3182
|
+
from_model: string;
|
|
3183
|
+
requested_model: string | null;
|
|
3184
|
+
context_tokens: number;
|
|
3185
|
+
prompt_cache_warm: boolean;
|
|
3186
|
+
cache_ttl: "5m" | "1h";
|
|
3187
|
+
estimated_cache_write_usd: number;
|
|
3188
|
+
pricing: "default" | "catalog" | "configured";
|
|
3189
|
+
agent_type?: string | undefined;
|
|
3190
|
+
permission_mode?: string | undefined;
|
|
3191
|
+
agent_id?: string | undefined;
|
|
3192
|
+
}, {
|
|
3193
|
+
source: "command" | "auto" | "resume" | "picker" | "sdk";
|
|
3194
|
+
to_model: string;
|
|
3195
|
+
session_id: string;
|
|
3196
|
+
transcript_path: string;
|
|
3197
|
+
cwd: string;
|
|
3198
|
+
hook_event_name: "PostModelSwitch";
|
|
3199
|
+
from_model: string;
|
|
3200
|
+
requested_model: string | null;
|
|
3201
|
+
context_tokens: number;
|
|
3202
|
+
prompt_cache_warm: boolean;
|
|
3203
|
+
cache_ttl: "5m" | "1h";
|
|
3204
|
+
estimated_cache_write_usd: number;
|
|
3205
|
+
pricing: "default" | "catalog" | "configured";
|
|
3206
|
+
agent_type?: string | undefined;
|
|
3207
|
+
permission_mode?: string | undefined;
|
|
3208
|
+
agent_id?: string | undefined;
|
|
2965
3209
|
}>]>;
|
|
2966
3210
|
export type HookInput = z.infer<typeof HookInput>;
|
|
2967
3211
|
/** Legacy top-level decision (CC): "approve" ≈ allow, "block" feeds `reason` back to the model. */
|
|
@@ -3666,6 +3910,30 @@ export declare const HookSpecificOutput: z.ZodUnion<[z.ZodObject<{
|
|
|
3666
3910
|
}, {
|
|
3667
3911
|
hookEventName: "WorktreeCreate";
|
|
3668
3912
|
worktreePath: string;
|
|
3913
|
+
}>, z.ZodObject<{
|
|
3914
|
+
hookEventName: z.ZodLiteral<"PreModelSwitch">;
|
|
3915
|
+
/** CC: `allow` proceeds (skipping the interactive cache-miss confirm), `deny` cancels the switch, `ask`
|
|
3916
|
+
* asks the user to confirm (a headless session refuses instead). Same wording as PreToolUse — DESIGN
|
|
3917
|
+
* POINT ① applies: a hook `allow` never overrides a policy floor. */
|
|
3918
|
+
permissionDecision: z.ZodOptional<z.ZodEnum<["allow", "deny", "ask"]>>;
|
|
3919
|
+
permissionDecisionReason: z.ZodOptional<z.ZodString>;
|
|
3920
|
+
}, "strip", z.ZodTypeAny, {
|
|
3921
|
+
hookEventName: "PreModelSwitch";
|
|
3922
|
+
permissionDecision?: "ask" | "allow" | "deny" | undefined;
|
|
3923
|
+
permissionDecisionReason?: string | undefined;
|
|
3924
|
+
}, {
|
|
3925
|
+
hookEventName: "PreModelSwitch";
|
|
3926
|
+
permissionDecision?: "ask" | "allow" | "deny" | undefined;
|
|
3927
|
+
permissionDecisionReason?: string | undefined;
|
|
3928
|
+
}>, z.ZodObject<{
|
|
3929
|
+
hookEventName: z.ZodLiteral<"PostModelSwitch">;
|
|
3930
|
+
additionalContext: z.ZodOptional<z.ZodString>;
|
|
3931
|
+
}, "strip", z.ZodTypeAny, {
|
|
3932
|
+
hookEventName: "PostModelSwitch";
|
|
3933
|
+
additionalContext?: string | undefined;
|
|
3934
|
+
}, {
|
|
3935
|
+
hookEventName: "PostModelSwitch";
|
|
3936
|
+
additionalContext?: string | undefined;
|
|
3669
3937
|
}>]>;
|
|
3670
3938
|
export type HookSpecificOutput = z.infer<typeof HookSpecificOutput>;
|
|
3671
3939
|
/**
|
|
@@ -4163,6 +4431,30 @@ export declare const SyncHookOutput: z.ZodObject<{
|
|
|
4163
4431
|
}, {
|
|
4164
4432
|
hookEventName: "WorktreeCreate";
|
|
4165
4433
|
worktreePath: string;
|
|
4434
|
+
}>, z.ZodObject<{
|
|
4435
|
+
hookEventName: z.ZodLiteral<"PreModelSwitch">;
|
|
4436
|
+
/** CC: `allow` proceeds (skipping the interactive cache-miss confirm), `deny` cancels the switch, `ask`
|
|
4437
|
+
* asks the user to confirm (a headless session refuses instead). Same wording as PreToolUse — DESIGN
|
|
4438
|
+
* POINT ① applies: a hook `allow` never overrides a policy floor. */
|
|
4439
|
+
permissionDecision: z.ZodOptional<z.ZodEnum<["allow", "deny", "ask"]>>;
|
|
4440
|
+
permissionDecisionReason: z.ZodOptional<z.ZodString>;
|
|
4441
|
+
}, "strip", z.ZodTypeAny, {
|
|
4442
|
+
hookEventName: "PreModelSwitch";
|
|
4443
|
+
permissionDecision?: "ask" | "allow" | "deny" | undefined;
|
|
4444
|
+
permissionDecisionReason?: string | undefined;
|
|
4445
|
+
}, {
|
|
4446
|
+
hookEventName: "PreModelSwitch";
|
|
4447
|
+
permissionDecision?: "ask" | "allow" | "deny" | undefined;
|
|
4448
|
+
permissionDecisionReason?: string | undefined;
|
|
4449
|
+
}>, z.ZodObject<{
|
|
4450
|
+
hookEventName: z.ZodLiteral<"PostModelSwitch">;
|
|
4451
|
+
additionalContext: z.ZodOptional<z.ZodString>;
|
|
4452
|
+
}, "strip", z.ZodTypeAny, {
|
|
4453
|
+
hookEventName: "PostModelSwitch";
|
|
4454
|
+
additionalContext?: string | undefined;
|
|
4455
|
+
}, {
|
|
4456
|
+
hookEventName: "PostModelSwitch";
|
|
4457
|
+
additionalContext?: string | undefined;
|
|
4166
4458
|
}>]>>;
|
|
4167
4459
|
}, "strip", z.ZodTypeAny, {
|
|
4168
4460
|
reason?: string | undefined;
|
|
@@ -4268,6 +4560,13 @@ export declare const SyncHookOutput: z.ZodObject<{
|
|
|
4268
4560
|
} | {
|
|
4269
4561
|
hookEventName: "WorktreeCreate";
|
|
4270
4562
|
worktreePath: string;
|
|
4563
|
+
} | {
|
|
4564
|
+
hookEventName: "PreModelSwitch";
|
|
4565
|
+
permissionDecision?: "ask" | "allow" | "deny" | undefined;
|
|
4566
|
+
permissionDecisionReason?: string | undefined;
|
|
4567
|
+
} | {
|
|
4568
|
+
hookEventName: "PostModelSwitch";
|
|
4569
|
+
additionalContext?: string | undefined;
|
|
4271
4570
|
} | undefined;
|
|
4272
4571
|
}, {
|
|
4273
4572
|
reason?: string | undefined;
|
|
@@ -4373,6 +4672,13 @@ export declare const SyncHookOutput: z.ZodObject<{
|
|
|
4373
4672
|
} | {
|
|
4374
4673
|
hookEventName: "WorktreeCreate";
|
|
4375
4674
|
worktreePath: string;
|
|
4675
|
+
} | {
|
|
4676
|
+
hookEventName: "PreModelSwitch";
|
|
4677
|
+
permissionDecision?: "ask" | "allow" | "deny" | undefined;
|
|
4678
|
+
permissionDecisionReason?: string | undefined;
|
|
4679
|
+
} | {
|
|
4680
|
+
hookEventName: "PostModelSwitch";
|
|
4681
|
+
additionalContext?: string | undefined;
|
|
4376
4682
|
} | undefined;
|
|
4377
4683
|
}>;
|
|
4378
4684
|
export type SyncHookOutput = z.infer<typeof SyncHookOutput>;
|
|
@@ -4882,6 +5188,30 @@ export declare const HookOutput: z.ZodUnion<[z.ZodObject<{
|
|
|
4882
5188
|
}, {
|
|
4883
5189
|
hookEventName: "WorktreeCreate";
|
|
4884
5190
|
worktreePath: string;
|
|
5191
|
+
}>, z.ZodObject<{
|
|
5192
|
+
hookEventName: z.ZodLiteral<"PreModelSwitch">;
|
|
5193
|
+
/** CC: `allow` proceeds (skipping the interactive cache-miss confirm), `deny` cancels the switch, `ask`
|
|
5194
|
+
* asks the user to confirm (a headless session refuses instead). Same wording as PreToolUse — DESIGN
|
|
5195
|
+
* POINT ① applies: a hook `allow` never overrides a policy floor. */
|
|
5196
|
+
permissionDecision: z.ZodOptional<z.ZodEnum<["allow", "deny", "ask"]>>;
|
|
5197
|
+
permissionDecisionReason: z.ZodOptional<z.ZodString>;
|
|
5198
|
+
}, "strip", z.ZodTypeAny, {
|
|
5199
|
+
hookEventName: "PreModelSwitch";
|
|
5200
|
+
permissionDecision?: "ask" | "allow" | "deny" | undefined;
|
|
5201
|
+
permissionDecisionReason?: string | undefined;
|
|
5202
|
+
}, {
|
|
5203
|
+
hookEventName: "PreModelSwitch";
|
|
5204
|
+
permissionDecision?: "ask" | "allow" | "deny" | undefined;
|
|
5205
|
+
permissionDecisionReason?: string | undefined;
|
|
5206
|
+
}>, z.ZodObject<{
|
|
5207
|
+
hookEventName: z.ZodLiteral<"PostModelSwitch">;
|
|
5208
|
+
additionalContext: z.ZodOptional<z.ZodString>;
|
|
5209
|
+
}, "strip", z.ZodTypeAny, {
|
|
5210
|
+
hookEventName: "PostModelSwitch";
|
|
5211
|
+
additionalContext?: string | undefined;
|
|
5212
|
+
}, {
|
|
5213
|
+
hookEventName: "PostModelSwitch";
|
|
5214
|
+
additionalContext?: string | undefined;
|
|
4885
5215
|
}>]>>;
|
|
4886
5216
|
}, "strip", z.ZodTypeAny, {
|
|
4887
5217
|
reason?: string | undefined;
|
|
@@ -4987,6 +5317,13 @@ export declare const HookOutput: z.ZodUnion<[z.ZodObject<{
|
|
|
4987
5317
|
} | {
|
|
4988
5318
|
hookEventName: "WorktreeCreate";
|
|
4989
5319
|
worktreePath: string;
|
|
5320
|
+
} | {
|
|
5321
|
+
hookEventName: "PreModelSwitch";
|
|
5322
|
+
permissionDecision?: "ask" | "allow" | "deny" | undefined;
|
|
5323
|
+
permissionDecisionReason?: string | undefined;
|
|
5324
|
+
} | {
|
|
5325
|
+
hookEventName: "PostModelSwitch";
|
|
5326
|
+
additionalContext?: string | undefined;
|
|
4990
5327
|
} | undefined;
|
|
4991
5328
|
}, {
|
|
4992
5329
|
reason?: string | undefined;
|
|
@@ -5092,6 +5429,13 @@ export declare const HookOutput: z.ZodUnion<[z.ZodObject<{
|
|
|
5092
5429
|
} | {
|
|
5093
5430
|
hookEventName: "WorktreeCreate";
|
|
5094
5431
|
worktreePath: string;
|
|
5432
|
+
} | {
|
|
5433
|
+
hookEventName: "PreModelSwitch";
|
|
5434
|
+
permissionDecision?: "ask" | "allow" | "deny" | undefined;
|
|
5435
|
+
permissionDecisionReason?: string | undefined;
|
|
5436
|
+
} | {
|
|
5437
|
+
hookEventName: "PostModelSwitch";
|
|
5438
|
+
additionalContext?: string | undefined;
|
|
5095
5439
|
} | undefined;
|
|
5096
5440
|
}>]>;
|
|
5097
5441
|
export type HookOutput = z.infer<typeof HookOutput>;
|
|
@@ -5525,8 +5869,12 @@ export declare const HookMatcherEntry: z.ZodObject<{
|
|
|
5525
5869
|
export type HookMatcherEntry = z.infer<typeof HookMatcherEntry>;
|
|
5526
5870
|
/**
|
|
5527
5871
|
* The hooks config record — the shape `TaskRequest.settings.hooks` carries on the wire and the shell
|
|
5528
|
-
* reads from settings JSON: `{ [eventName]: [{ matcher?, hooks: [...] }] }`. Keys limited to the
|
|
5872
|
+
* reads from settings JSON: `{ [eventName]: [{ matcher?, hooks: [...] }] }`. Keys limited to the 33
|
|
5529
5873
|
* contract events (an unknown event name fails parse — catch typos at the wire); all keys optional.
|
|
5874
|
+
*
|
|
5875
|
+
* 🔴 The closed set is what makes a typo loud, and it is ALSO what makes falling behind CC expensive: an
|
|
5876
|
+
* event this package has not adopted yet takes the WHOLE settings file down with it, not just its own key.
|
|
5877
|
+
* That blast radius is why {@link HOOK_EVENTS} now has an upstream drift gate rather than a human promise.
|
|
5530
5878
|
*/
|
|
5531
5879
|
export type HooksConfig = Partial<Record<HookEventName, HookMatcherEntry[]>>;
|
|
5532
5880
|
export declare const HooksConfig: z.ZodType<HooksConfig>;
|