@aaac/runtime 0.1.55 → 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 (71) hide show
  1. package/README.md +6 -11
  2. package/dist/adapters/adk-sdk.d.ts +3 -3
  3. package/dist/adapters/adk-sdk.js +6 -8
  4. package/dist/adapters/adk-sdk.js.map +1 -1
  5. package/dist/adapters/claude-agent-sdk.d.ts +3 -3
  6. package/dist/adapters/claude-agent-sdk.js +22 -23
  7. package/dist/adapters/claude-agent-sdk.js.map +1 -1
  8. package/dist/adapters/mock.d.ts +2 -3
  9. package/dist/adapters/openai-agents-sdk.d.ts +3 -3
  10. package/dist/adapters/openai-agents-sdk.js +6 -5
  11. package/dist/adapters/openai-agents-sdk.js.map +1 -1
  12. package/dist/chunk-2INQL5TG.js +298 -0
  13. package/dist/chunk-2INQL5TG.js.map +1 -0
  14. package/dist/chunk-3CLWG72V.js +47 -0
  15. package/dist/chunk-3CLWG72V.js.map +1 -0
  16. package/dist/chunk-3DDB34BU.js +237 -0
  17. package/dist/chunk-3DDB34BU.js.map +1 -0
  18. package/dist/chunk-ABXDSTUV.js +685 -0
  19. package/dist/chunk-ABXDSTUV.js.map +1 -0
  20. package/dist/{chunk-3H3PVPPF.js → chunk-F5R46S7I.js} +151 -204
  21. package/dist/chunk-F5R46S7I.js.map +1 -0
  22. package/dist/chunk-FKAI54OM.js +234 -0
  23. package/dist/chunk-FKAI54OM.js.map +1 -0
  24. package/dist/chunk-KTVMMG33.js +1111 -0
  25. package/dist/chunk-KTVMMG33.js.map +1 -0
  26. package/dist/chunk-MSVIEEGR.js +269 -0
  27. package/dist/chunk-MSVIEEGR.js.map +1 -0
  28. package/dist/chunk-VJXGCWSZ.js +36 -0
  29. package/dist/chunk-VJXGCWSZ.js.map +1 -0
  30. package/dist/claude-bundles/full.js +311 -309
  31. package/dist/claude-bundles/lean.js +6 -6
  32. package/dist/claude-bundles/prompt.js +17 -0
  33. package/dist/generator/index.d.ts +2 -2
  34. package/dist/generator/index.js +8 -7
  35. package/dist/guardrail-hooks-CB23nhZV.d.ts +202 -0
  36. package/dist/hook-protocol-CFnNudiV.d.ts +96 -0
  37. package/dist/hooks-lite-CoWWnCRH.d.ts +428 -0
  38. package/dist/index-BlSepCSZ.d.ts +296 -0
  39. package/dist/index.d.ts +785 -105
  40. package/dist/index.js +2189 -634
  41. package/dist/index.js.map +1 -1
  42. package/dist/lib/claude-native/hooks-lite.d.ts +3 -26
  43. package/dist/lib/claude-native/hooks-lite.js +18 -36
  44. package/dist/lib/claude-native/hooks-prompt.d.ts +5 -0
  45. package/dist/lib/claude-native/hooks-prompt.js +33 -0
  46. package/dist/lib/claude-native/hooks-prompt.js.map +1 -0
  47. package/dist/lib/claude-native/index.d.ts +56 -214
  48. package/dist/lib/claude-native/index.js +79 -280
  49. package/dist/lib/claude-native/index.js.map +1 -1
  50. package/dist/{navigation-context-D_E1NIUf.d.ts → navigation-context-B-RpUg3_.d.ts} +1 -1
  51. package/dist/navigation-index-prompt-CbrS5laO.d.ts +43 -0
  52. package/dist/{task-runner-DfIEorkU.d.ts → task-runner-GWoI7_71.d.ts} +100 -493
  53. package/dist/workspace-user-prompt-submit-D11Iu0zO.d.ts +269 -0
  54. package/package.json +15 -6
  55. package/dist/chunk-3H3PVPPF.js.map +0 -1
  56. package/dist/chunk-DBM5XN67.js +0 -354
  57. package/dist/chunk-DBM5XN67.js.map +0 -1
  58. package/dist/chunk-KXGUWBGK.js +0 -370
  59. package/dist/chunk-KXGUWBGK.js.map +0 -1
  60. package/dist/chunk-LDCQZPDG.js +0 -11
  61. package/dist/chunk-LDCQZPDG.js.map +0 -1
  62. package/dist/chunk-N4KNGDYY.js +0 -1963
  63. package/dist/chunk-N4KNGDYY.js.map +0 -1
  64. package/dist/chunk-NMX4C6LC.js +0 -332
  65. package/dist/chunk-NMX4C6LC.js.map +0 -1
  66. package/dist/chunk-QVH5KKBR.js +0 -374
  67. package/dist/chunk-QVH5KKBR.js.map +0 -1
  68. package/dist/context-DKkamYX_.d.ts +0 -31
  69. package/dist/guardrail-hooks-slK-z0Dz.d.ts +0 -83
  70. package/dist/index-LqEvaRk-.d.ts +0 -299
  71. package/dist/workspace-pre-tool-use-C6nidc0q.d.ts +0 -333
@@ -1,299 +0,0 @@
1
- import { z } from 'zod';
2
- import './context-DKkamYX_.js';
3
-
4
- /**
5
- * Generator configuration — loads and validates agents.conf.yaml
6
- */
7
-
8
- declare const DEFAULT_CONFIG_PATH = "./agents.conf.yaml";
9
- /**
10
- * Project manifest filename — resolved under a project root, and under each
11
- * workspace member root. Single definition for the whole runtime package.
12
- */
13
- declare const PROJECT_CONFIG_FILENAME = "project.yaml";
14
- declare const RuntimeConfigSchema: z.ZodObject<{
15
- dsl: z.ZodDefault<z.ZodString>;
16
- generated_dir: z.ZodDefault<z.ZodString>;
17
- bindings: z.ZodDefault<z.ZodArray<z.ZodString>>;
18
- active_guardrail_policy: z.ZodOptional<z.ZodString>;
19
- templates_dir: z.ZodOptional<z.ZodString>;
20
- plugins: z.ZodDefault<z.ZodArray<z.ZodString>>;
21
- recovery: z.ZodDefault<z.ZodObject<{
22
- max_follow_ups: z.ZodDefault<z.ZodNumber>;
23
- max_retries: z.ZodDefault<z.ZodNumber>;
24
- }, z.core.$strip>>;
25
- model_mapping: z.ZodDefault<z.ZodObject<{
26
- fast: z.ZodOptional<z.ZodObject<{
27
- adapter: z.ZodString;
28
- model: z.ZodOptional<z.ZodString>;
29
- }, z.core.$strip>>;
30
- standard: z.ZodOptional<z.ZodObject<{
31
- adapter: z.ZodString;
32
- model: z.ZodOptional<z.ZodString>;
33
- }, z.core.$strip>>;
34
- thinking: z.ZodOptional<z.ZodObject<{
35
- adapter: z.ZodString;
36
- model: z.ZodOptional<z.ZodString>;
37
- }, z.core.$strip>>;
38
- }, z.core.$strip>>;
39
- logging: z.ZodDefault<z.ZodObject<{
40
- progress_log: z.ZodDefault<z.ZodObject<{
41
- destination: z.ZodDefault<z.ZodEnum<{
42
- file: "file";
43
- both: "both";
44
- stderr: "stderr";
45
- none: "none";
46
- }>>;
47
- file: z.ZodOptional<z.ZodString>;
48
- naming: z.ZodDefault<z.ZodEnum<{
49
- single: "single";
50
- "per-invocation": "per-invocation";
51
- daily: "daily";
52
- }>>;
53
- }, z.core.$strip>>;
54
- }, z.core.$strip>>;
55
- }, z.core.$strip>;
56
- type RuntimeConfig = z.infer<typeof RuntimeConfigSchema>;
57
- declare const ComponentOverrideSchema: z.ZodObject<{
58
- agents: z.ZodOptional<z.ZodString>;
59
- dsl: z.ZodOptional<z.ZodString>;
60
- component_contract: z.ZodOptional<z.ZodString>;
61
- generated_dir: z.ZodOptional<z.ZodString>;
62
- bindings: z.ZodOptional<z.ZodObject<{
63
- guardrail: z.ZodOptional<z.ZodArray<z.ZodString>>;
64
- hooks: z.ZodOptional<z.ZodArray<z.ZodString>>;
65
- observability: z.ZodOptional<z.ZodObject<{
66
- event_mapping: z.ZodOptional<z.ZodString>;
67
- recorder: z.ZodOptional<z.ZodString>;
68
- enabled: z.ZodOptional<z.ZodBoolean>;
69
- db_path: z.ZodOptional<z.ZodString>;
70
- otel: z.ZodOptional<z.ZodObject<{
71
- endpoint: z.ZodString;
72
- }, z.core.$strip>>;
73
- }, z.core.$strip>>;
74
- }, z.core.$strip>>;
75
- plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
76
- model_mapping: z.ZodOptional<z.ZodDefault<z.ZodObject<{
77
- fast: z.ZodOptional<z.ZodObject<{
78
- adapter: z.ZodString;
79
- model: z.ZodOptional<z.ZodString>;
80
- }, z.core.$strip>>;
81
- standard: z.ZodOptional<z.ZodObject<{
82
- adapter: z.ZodString;
83
- model: z.ZodOptional<z.ZodString>;
84
- }, z.core.$strip>>;
85
- thinking: z.ZodOptional<z.ZodObject<{
86
- adapter: z.ZodString;
87
- model: z.ZodOptional<z.ZodString>;
88
- }, z.core.$strip>>;
89
- }, z.core.$strip>>>;
90
- recovery: z.ZodOptional<z.ZodDefault<z.ZodObject<{
91
- max_follow_ups: z.ZodDefault<z.ZodNumber>;
92
- max_retries: z.ZodDefault<z.ZodNumber>;
93
- }, z.core.$strip>>>;
94
- templates_dir: z.ZodOptional<z.ZodString>;
95
- }, z.core.$strict>;
96
- type ComponentOverride = z.infer<typeof ComponentOverrideSchema>;
97
- declare const ProjectConfigSchema: z.ZodObject<{
98
- schema: z.ZodOptional<z.ZodString>;
99
- agents: z.ZodOptional<z.ZodString>;
100
- dsl: z.ZodOptional<z.ZodString>;
101
- generated_dir: z.ZodOptional<z.ZodString>;
102
- bindings: z.ZodOptional<z.ZodObject<{
103
- guardrail: z.ZodOptional<z.ZodArray<z.ZodString>>;
104
- hooks: z.ZodOptional<z.ZodArray<z.ZodString>>;
105
- observability: z.ZodOptional<z.ZodObject<{
106
- event_mapping: z.ZodOptional<z.ZodString>;
107
- recorder: z.ZodOptional<z.ZodString>;
108
- enabled: z.ZodOptional<z.ZodBoolean>;
109
- db_path: z.ZodOptional<z.ZodString>;
110
- otel: z.ZodOptional<z.ZodObject<{
111
- endpoint: z.ZodString;
112
- }, z.core.$strip>>;
113
- }, z.core.$strip>>;
114
- }, z.core.$strip>>;
115
- active_guardrail_policy: z.ZodOptional<z.ZodString>;
116
- templates_dir: z.ZodOptional<z.ZodString>;
117
- plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
118
- recovery: z.ZodDefault<z.ZodObject<{
119
- max_follow_ups: z.ZodDefault<z.ZodNumber>;
120
- max_retries: z.ZodDefault<z.ZodNumber>;
121
- }, z.core.$strip>>;
122
- model_mapping: z.ZodDefault<z.ZodObject<{
123
- fast: z.ZodOptional<z.ZodObject<{
124
- adapter: z.ZodString;
125
- model: z.ZodOptional<z.ZodString>;
126
- }, z.core.$strip>>;
127
- standard: z.ZodOptional<z.ZodObject<{
128
- adapter: z.ZodString;
129
- model: z.ZodOptional<z.ZodString>;
130
- }, z.core.$strip>>;
131
- thinking: z.ZodOptional<z.ZodObject<{
132
- adapter: z.ZodString;
133
- model: z.ZodOptional<z.ZodString>;
134
- }, z.core.$strip>>;
135
- }, z.core.$strip>>;
136
- logging: z.ZodDefault<z.ZodObject<{
137
- progress_log: z.ZodDefault<z.ZodObject<{
138
- destination: z.ZodDefault<z.ZodEnum<{
139
- file: "file";
140
- both: "both";
141
- stderr: "stderr";
142
- none: "none";
143
- }>>;
144
- file: z.ZodOptional<z.ZodString>;
145
- naming: z.ZodDefault<z.ZodEnum<{
146
- single: "single";
147
- "per-invocation": "per-invocation";
148
- daily: "daily";
149
- }>>;
150
- }, z.core.$strip>>;
151
- }, z.core.$strip>>;
152
- artifacts: z.ZodOptional<z.ZodString>;
153
- toolchains: z.ZodOptional<z.ZodString>;
154
- components: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
155
- agents: z.ZodOptional<z.ZodString>;
156
- dsl: z.ZodOptional<z.ZodString>;
157
- component_contract: z.ZodOptional<z.ZodString>;
158
- generated_dir: z.ZodOptional<z.ZodString>;
159
- bindings: z.ZodOptional<z.ZodObject<{
160
- guardrail: z.ZodOptional<z.ZodArray<z.ZodString>>;
161
- hooks: z.ZodOptional<z.ZodArray<z.ZodString>>;
162
- observability: z.ZodOptional<z.ZodObject<{
163
- event_mapping: z.ZodOptional<z.ZodString>;
164
- recorder: z.ZodOptional<z.ZodString>;
165
- enabled: z.ZodOptional<z.ZodBoolean>;
166
- db_path: z.ZodOptional<z.ZodString>;
167
- otel: z.ZodOptional<z.ZodObject<{
168
- endpoint: z.ZodString;
169
- }, z.core.$strip>>;
170
- }, z.core.$strip>>;
171
- }, z.core.$strip>>;
172
- plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
173
- model_mapping: z.ZodOptional<z.ZodDefault<z.ZodObject<{
174
- fast: z.ZodOptional<z.ZodObject<{
175
- adapter: z.ZodString;
176
- model: z.ZodOptional<z.ZodString>;
177
- }, z.core.$strip>>;
178
- standard: z.ZodOptional<z.ZodObject<{
179
- adapter: z.ZodString;
180
- model: z.ZodOptional<z.ZodString>;
181
- }, z.core.$strip>>;
182
- thinking: z.ZodOptional<z.ZodObject<{
183
- adapter: z.ZodString;
184
- model: z.ZodOptional<z.ZodString>;
185
- }, z.core.$strip>>;
186
- }, z.core.$strip>>>;
187
- recovery: z.ZodOptional<z.ZodDefault<z.ZodObject<{
188
- max_follow_ups: z.ZodDefault<z.ZodNumber>;
189
- max_retries: z.ZodDefault<z.ZodNumber>;
190
- }, z.core.$strip>>>;
191
- templates_dir: z.ZodOptional<z.ZodString>;
192
- }, z.core.$strict>>>;
193
- environments: z.ZodOptional<z.ZodObject<{
194
- git: z.ZodOptional<z.ZodObject<{
195
- hooks: z.ZodOptional<z.ZodArray<z.ZodString>>;
196
- }, z.core.$strip>>;
197
- cursor: z.ZodOptional<z.ZodObject<{
198
- hooks_json: z.ZodOptional<z.ZodString>;
199
- }, z.core.$strip>>;
200
- ci: z.ZodOptional<z.ZodObject<{
201
- provider: z.ZodOptional<z.ZodString>;
202
- }, z.core.$strip>>;
203
- }, z.core.$strip>>;
204
- cli: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
205
- agents: z.ZodOptional<z.ZodString>;
206
- dsl: z.ZodOptional<z.ZodString>;
207
- generated_dir: z.ZodOptional<z.ZodString>;
208
- plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
209
- bindings: z.ZodOptional<z.ZodObject<{
210
- guardrail: z.ZodOptional<z.ZodArray<z.ZodString>>;
211
- hooks: z.ZodOptional<z.ZodArray<z.ZodString>>;
212
- observability: z.ZodOptional<z.ZodObject<{
213
- event_mapping: z.ZodOptional<z.ZodString>;
214
- recorder: z.ZodOptional<z.ZodString>;
215
- enabled: z.ZodOptional<z.ZodBoolean>;
216
- db_path: z.ZodOptional<z.ZodString>;
217
- otel: z.ZodOptional<z.ZodObject<{
218
- endpoint: z.ZodString;
219
- }, z.core.$strip>>;
220
- }, z.core.$strip>>;
221
- }, z.core.$strip>>;
222
- }, z.core.$strict>>>;
223
- workspace: z.ZodOptional<z.ZodObject<{
224
- members: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
225
- path: z.ZodString;
226
- }, z.core.$strip>, z.ZodObject<{
227
- glob: z.ZodString;
228
- }, z.core.$strip>]>>;
229
- runtime: z.ZodOptional<z.ZodObject<{
230
- resolve_from: z.ZodOptional<z.ZodString>;
231
- }, z.core.$strip>>;
232
- discovery: z.ZodDefault<z.ZodObject<{
233
- max_depth: z.ZodDefault<z.ZodNumber>;
234
- }, z.core.$strip>>;
235
- }, z.core.$strip>>;
236
- }, z.core.$strip>;
237
- type ProjectConfig = z.infer<typeof ProjectConfigSchema>;
238
- interface ResolvedProgressLog {
239
- destination: "stderr" | "file" | "both" | "none";
240
- file: string | undefined;
241
- naming: "single" | "per-invocation" | "daily";
242
- }
243
- interface ResolvedEnvironments {
244
- git?: {
245
- hooks: string[];
246
- };
247
- cursor?: {
248
- hooks_json: string;
249
- };
250
- ci?: {
251
- provider: string;
252
- };
253
- }
254
- interface ResolvedObservability {
255
- eventMappingPath?: string;
256
- recorder?: string;
257
- /** Whether in-process agent-axis recording is enabled (default true when binding present). */
258
- enabled?: boolean;
259
- /** Resolved override for the SQLite DB path (undefined → DEFAULT_DB_PATH). */
260
- dbPath?: string;
261
- /**
262
- * OTel Collector endpoint configuration.
263
- * When present, OtelEmitter is configured with this endpoint at pipeline creation.
264
- * Falls back to OTEL_EXPORTER_OTLP_ENDPOINT env var when absent.
265
- */
266
- otel?: {
267
- endpoint: string;
268
- };
269
- }
270
- interface ResolvedConfig extends RuntimeConfig {
271
- configDir: string;
272
- dslPath: string;
273
- /**
274
- * True when the manifest (or the applied component override) EXPLICITLY
275
- * declares `agents:` / `dsl:`. When false, `dslPath` is only the
276
- * `RuntimeConfigSchema` default (`./agent-contracts.yaml`) and must NOT be
277
- * treated as a project overlay — the bundled `/$embedded/` DSL is used as-is.
278
- */
279
- dslDeclared: boolean;
280
- generatedDir: string;
281
- /** Resolved guardrail_impl matcher files (machine enforcement). */
282
- bindingPaths: string[];
283
- /** Resolved git-hook binding files (governance materialize, #68). */
284
- hookBindingPaths: string[];
285
- /** Observability event mapping + recorder, if configured. */
286
- observability?: ResolvedObservability;
287
- templatesDir: string | undefined;
288
- pluginPaths: string[];
289
- resolvedLogging: {
290
- progressLog: ResolvedProgressLog;
291
- };
292
- artifactsPath?: string;
293
- toolchainsPath?: string;
294
- environments?: ResolvedEnvironments;
295
- componentOverrides?: Record<string, ComponentOverride>;
296
- }
297
- declare function loadProjectConfig(configPath: string, target?: string): Promise<ResolvedConfig>;
298
-
299
- export { type ComponentOverride as C, DEFAULT_CONFIG_PATH as D, PROJECT_CONFIG_FILENAME as P, type ResolvedConfig as R, ComponentOverrideSchema as a, type ProjectConfig as b, ProjectConfigSchema as c, type ResolvedEnvironments as d, loadProjectConfig as l };
@@ -1,333 +0,0 @@
1
- import { a as GuardrailRuleData } from './guardrail-hooks-slK-z0Dz.js';
2
-
3
- /**
4
- * Claude Code Hook Protocol — parse stdin JSON input and emit hook response JSON.
5
- *
6
- * Implements the protocol defined at https://code.claude.com/docs/en/hooks
7
- * for SessionStart, UserPromptSubmit, and PreToolUse hook events.
8
- */
9
- type HookEventName = "SessionStart" | "UserPromptSubmit" | "PreToolUse";
10
- interface SessionStartInput {
11
- hookEventName: "SessionStart";
12
- session_id?: string;
13
- type?: "new" | "resume" | "clear" | "compact";
14
- }
15
- interface UserPromptSubmitInput {
16
- hookEventName: "UserPromptSubmit";
17
- session_id?: string;
18
- prompt?: string;
19
- }
20
- interface PreToolUseInput {
21
- hookEventName: "PreToolUse";
22
- session_id?: string;
23
- tool_name?: string;
24
- tool_input?: {
25
- file_path?: string;
26
- path?: string;
27
- command?: string;
28
- content?: string;
29
- [key: string]: unknown;
30
- };
31
- }
32
- type HookInput = SessionStartInput | UserPromptSubmitInput | PreToolUseInput;
33
- type PermissionDecision = "allow" | "deny" | "ask";
34
- interface HookOutput {
35
- /** Hook-specific output envelope. */
36
- hookSpecificOutput?: {
37
- hookEventName: HookEventName;
38
- /** Additional context injected into the session. */
39
- additionalContext?: string;
40
- /** Permission decision for PreToolUse hooks. */
41
- permissionDecision?: PermissionDecision;
42
- /** Reason for the permission decision. */
43
- permissionDecisionReason?: string;
44
- };
45
- }
46
- /**
47
- * Parse hook input from a raw JSON string (typically from stdin).
48
- * Throws on invalid JSON but not on missing fields — callers handle defaults.
49
- */
50
- declare function parseHookInput(raw: string): HookInput;
51
- /**
52
- * Read all of stdin and parse as hook input JSON.
53
- */
54
- declare function readHookInput(): Promise<HookInput>;
55
- /**
56
- * Emit a hook response as JSON to stdout.
57
- */
58
- declare function emitHookOutput(output: HookOutput): void;
59
- /**
60
- * Build a response that injects additional context into the session.
61
- */
62
- declare function buildContextResponse(eventName: HookEventName, additionalContext: string): HookOutput;
63
- /**
64
- * Build a deny response for PreToolUse hooks.
65
- */
66
- declare function buildDenyResponse(reason: string): HookOutput;
67
- /**
68
- * Build an allow response (empty output = allow by default).
69
- */
70
- declare function buildAllowResponse(): HookOutput;
71
-
72
- /**
73
- * Cache Store — read/write `.claude/cache/` directory.
74
- *
75
- * Stores navigation-index.json and metadata for graph cache invalidation.
76
- * Uses atomic write (write-to-temp + rename) for concurrent-access safety.
77
- */
78
- interface CacheEntry<T = unknown> {
79
- data: T;
80
- /** ISO timestamp of when the cache was written. */
81
- writtenAt: string;
82
- /** Hash of source inputs used for invalidation. */
83
- sourceHash: string;
84
- }
85
- interface CacheStoreOptions {
86
- /** Absolute path to the `.claude/cache/` directory. */
87
- cacheDir: string;
88
- }
89
- interface CacheStore {
90
- read<T = unknown>(key: string): Promise<CacheEntry<T> | null>;
91
- write<T = unknown>(key: string, data: T, sourceHash: string): Promise<void>;
92
- /**
93
- * Check if a cache entry is fresh by comparing its sourceHash.
94
- * Returns the cached data if fresh, null if stale or missing.
95
- */
96
- readIfFresh<T = unknown>(key: string, currentHash: string): Promise<T | null>;
97
- /** Get the mtime of a file (for invalidation checks). */
98
- getFileMtime(filePath: string): Promise<number | null>;
99
- }
100
- declare function createCacheStore(options: CacheStoreOptions): CacheStore;
101
- /**
102
- * Compute a simple hash string from an array of file mtimes and content strings.
103
- * Not cryptographic — used only for cache invalidation.
104
- */
105
- declare function computeSourceHash(inputs: Array<string | number>): string;
106
-
107
- /**
108
- * Latency utilities — timeout wrapper, graph build exclusion, degrade policy.
109
- *
110
- * Mirrors the Promise-sharing pattern from analyzer-bridge.ts for concurrent
111
- * graph build exclusion.
112
- */
113
- declare class TimeoutError extends Error {
114
- constructor(ms: number);
115
- }
116
- /**
117
- * Race a promise against a timeout. Resolves with the promise result or
118
- * rejects with TimeoutError.
119
- */
120
- declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T>;
121
- /**
122
- * Creates an exclusive async lock that ensures only one invocation runs at a
123
- * time. Subsequent callers await the same Promise (analyzer-bridge pattern).
124
- */
125
- declare function createExclusiveLock<T>(): {
126
- run: (fn: () => Promise<T>) => Promise<T>;
127
- };
128
- interface DegradeResult<T> {
129
- value: T;
130
- degraded: boolean;
131
- reason?: string;
132
- }
133
- /**
134
- * Attempt an operation with timeout; if it fails or times out, return the
135
- * fallback value with `degraded: true`.
136
- */
137
- declare function withDegrade<T>(operation: () => Promise<T>, fallback: T, timeoutMs: number): Promise<DegradeResult<T>>;
138
-
139
- /**
140
- * Artifact Resolver — reverse-lookup path to artifact_id using navigation-index.
141
- *
142
- * Uses glob matching from guardrail-hooks.ts to match file paths against
143
- * artifact path_patterns defined in the navigation index.
144
- */
145
- /** Minimal shape of a navigation-index artifact node. */
146
- interface NavigationArtifact {
147
- properties?: {
148
- type?: string;
149
- authority?: string;
150
- manual_edit?: string;
151
- [key: string]: unknown;
152
- };
153
- files?: {
154
- path_patterns?: string[];
155
- [key: string]: unknown;
156
- };
157
- agents?: {
158
- owners?: string[];
159
- editors?: string[];
160
- [key: string]: unknown;
161
- };
162
- routes?: {
163
- regenerate?: string;
164
- [key: string]: unknown;
165
- };
166
- relations?: {
167
- derived_artifacts?: string[];
168
- [key: string]: unknown;
169
- };
170
- }
171
- interface ArtifactMatch {
172
- artifactId: string;
173
- artifact: NavigationArtifact;
174
- /** The glob pattern that matched. */
175
- matchedPattern: string;
176
- }
177
- /**
178
- * Resolve a file path to its artifact(s) in the navigation index.
179
- * Returns all matching artifacts (a file may belong to multiple artifacts).
180
- */
181
- declare function resolvePathToArtifacts(filePath: string, navigationIndex: Record<string, unknown>): ArtifactMatch[];
182
- /**
183
- * Check if a file path targets a protected artifact (generated or manual_edit: forbidden).
184
- */
185
- declare function isProtectedArtifact(match: ArtifactMatch): {
186
- protected: boolean;
187
- reason: string;
188
- };
189
- /**
190
- * Get all artifact entries from a navigation index as a flat list.
191
- */
192
- declare function listArtifacts(navigationIndex: Record<string, unknown>): Array<{
193
- id: string;
194
- artifact: NavigationArtifact;
195
- }>;
196
-
197
- /**
198
- * PreToolUse Hook Handler — artifact guardrail + DSL guardrail enforcement.
199
- *
200
- * Executed before tool use (Edit, Write, Bash, etc.). Checks:
201
- * 1. Edit/Write tools: file path → artifact reverse lookup → deny if protected
202
- * 2. Bash tool: apply DSL guardrail rules via GuardrailHooks
203
- */
204
-
205
- interface PreToolUseHandlerConfig {
206
- /** Navigation index for artifact resolution. */
207
- navigationIndex: Record<string, unknown>;
208
- /** DSL guardrail rules for Bash command evaluation. */
209
- guardrailRules?: GuardrailRuleData;
210
- }
211
- /**
212
- * Create a PreToolUse hook handler.
213
- */
214
- declare function createPreToolUseHandler(config: PreToolUseHandlerConfig): (input: PreToolUseInput) => Promise<HookOutput>;
215
-
216
- /**
217
- * Workspace Router — route a file path to the owning workspace member.
218
- *
219
- * Pure path-manipulation module. No imports from navigation-context,
220
- * agent-contracts, or any heavy dependency — safe for the lean hooks-lite
221
- * entry point.
222
- *
223
- * Algorithm: longest-prefix match among member absolute root paths.
224
- *
225
- * C4 resolution: stripMemberPrefix converts a workspace-relative path
226
- * (`aaac/packages/runtime/x.ts`) into a repo-relative path
227
- * (`packages/runtime/x.ts`) so existing member DSL path_patterns work
228
- * without modification.
229
- */
230
- interface WorkspaceMember {
231
- /** Human-readable member name (e.g. `"aaac"`). */
232
- name: string;
233
- /** Absolute path to the member root directory. */
234
- root: string;
235
- }
236
- /**
237
- * Route a file path to the workspace member whose root is the longest
238
- * matching prefix of that path.
239
- *
240
- * Generic over `T extends WorkspaceMember` so callers that pass a richer
241
- * member type (e.g. `WorkspaceMemberPreToolUseConfig`) get back that type
242
- * without a cast.
243
- *
244
- * @param filePath - Absolute or workspace-root-relative file path (as
245
- * received from Claude Code's `tool_input.file_path`).
246
- * @param members - Workspace members with **absolute** root paths.
247
- * @param workspaceRoot - Absolute path to the workspace root directory.
248
- * Used to resolve relative `filePath` values.
249
- * @returns The owning member, or `null` when no member claims this path.
250
- */
251
- declare function routePathToMember<T extends WorkspaceMember>(filePath: string, members: T[], workspaceRoot: string): T | null;
252
- /**
253
- * Strip the member root prefix from `filePath` to obtain a repo-relative
254
- * path that member DSL `path_patterns` can match against unchanged (C4).
255
- *
256
- * Example:
257
- * filePath = "aaac/packages/runtime/x.ts" (workspace-relative)
258
- * memberRoot = "/abs/workspace/aaac"
259
- * workspaceRoot = "/abs/workspace"
260
- * → returns "packages/runtime/x.ts"
261
- *
262
- * @param filePath - Absolute or workspace-root-relative path.
263
- * @param memberRoot - Absolute path to the member root.
264
- * @param workspaceRoot - Absolute path to the workspace root.
265
- * @returns Repo-relative path (no leading slash/dot).
266
- * Falls back to the original `filePath` when stripping is not possible.
267
- */
268
- declare function stripMemberPrefix(filePath: string, memberRoot: string, workspaceRoot: string): string;
269
-
270
- /**
271
- * Workspace PreToolUse Hook Handler — routes edits to the owning member
272
- * and enforces that member's artifact guardrails.
273
- *
274
- * Hot-path module. Does NOT import navigation-context or agent-contracts —
275
- * it only reads an already-built navigation index from the cache. Suitable
276
- * for inclusion in the lean hooks-lite entry point.
277
- *
278
- * Flow (per PreToolUse invocation):
279
- * 1. Extract file path from tool input.
280
- * 2. Route to owning member via longest-prefix match (workspace-router).
281
- * 3. Read member's navigation-index from cache (cache-store).
282
- * 4. Strip member-root prefix → repo-relative path (C4 resolution).
283
- * 5. Resolve path to artifacts; deny if protected.
284
- */
285
-
286
- interface WorkspaceMemberPreToolUseConfig extends WorkspaceMember {
287
- /**
288
- * Cache key for this member's navigation-index JSON.
289
- * Format: `navigation-index.<name>` (e.g. `navigation-index.aaac`).
290
- */
291
- cacheKey: string;
292
- /**
293
- * Cache key for this member's DSL guardrail rules (#238 / C5).
294
- *
295
- * Defaults to `guardrailCacheKey(cacheKey)` (i.e. `<cacheKey>.guardrails`)
296
- * when omitted, matching what `ensureNavigationIndex` persists during the
297
- * SessionStart warm-up. Provided explicitly only for tests / custom layouts.
298
- */
299
- guardrailCacheKey?: string;
300
- }
301
- interface WorkspacePreToolUseConfig {
302
- /** Absolute path to the workspace root directory. */
303
- workspaceRoot: string;
304
- /** Absolute path to the shared `.claude/cache/` directory. */
305
- cacheDir: string;
306
- /** Workspace members to route edits to. */
307
- members: WorkspaceMemberPreToolUseConfig[];
308
- }
309
- /**
310
- * Create a workspace-aware PreToolUse hook handler.
311
- *
312
- * On each invocation the handler:
313
- * - Edit/Write tools:
314
- * - Routes the target path to the owning member by longest-prefix match.
315
- * - Reads the member's cached navigation-index (allows if no cache yet).
316
- * - Strips the member-root prefix so `resolvePathToArtifacts` receives the
317
- * same repo-relative path the member DSL's `path_patterns` expect (C4).
318
- * - Denies if any matched artifact is protected (Phase 1).
319
- * - Bash tools (#238 / C5, Phase 3):
320
- * - Routes the command to the owning member via a path token in the command
321
- * (longest-prefix match); when no member path is present, evaluates the
322
- * command against every member's rules so safety guardrails are never
323
- * silently skipped.
324
- * - Loads that member's DSL guardrail rules from the companion cache entry
325
- * and denies blocking command violations.
326
- *
327
- * Artifact protection (Phase 1) and Bash guardrails (Phase 3) are independent
328
- * and coexist: a member with only artifact rules keeps working unchanged, and
329
- * a member with only guardrail rules still enforces Bash safety.
330
- */
331
- declare function createWorkspacePreToolUseHandler(config: WorkspacePreToolUseConfig): (input: PreToolUseInput) => Promise<HookOutput>;
332
-
333
- export { type ArtifactMatch as A, type CacheEntry as C, type DegradeResult as D, type HookEventName as H, type NavigationArtifact as N, type PermissionDecision as P, type SessionStartInput as S, TimeoutError as T, type UserPromptSubmitInput as U, type WorkspaceMember as W, type CacheStore as a, type CacheStoreOptions as b, type HookInput as c, type HookOutput as d, type PreToolUseHandlerConfig as e, type PreToolUseInput as f, type WorkspaceMemberPreToolUseConfig as g, type WorkspacePreToolUseConfig as h, buildAllowResponse as i, buildContextResponse as j, buildDenyResponse as k, computeSourceHash as l, createCacheStore as m, createExclusiveLock as n, createPreToolUseHandler as o, createWorkspacePreToolUseHandler as p, emitHookOutput as q, isProtectedArtifact as r, listArtifacts as s, parseHookInput as t, readHookInput as u, resolvePathToArtifacts as v, routePathToMember as w, stripMemberPrefix as x, withDegrade as y, withTimeout as z };