@namzu/sdk 0.4.3 → 0.4.5

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 (108) hide show
  1. package/CHANGELOG.md +129 -0
  2. package/dist/bridge/tools/connector/adapter.d.ts +2 -2
  3. package/dist/bus/index.d.ts +3 -1
  4. package/dist/bus/index.d.ts.map +1 -1
  5. package/dist/bus/index.js +18 -11
  6. package/dist/bus/index.js.map +1 -1
  7. package/dist/config/runtime.d.ts +28 -28
  8. package/dist/probe/context.d.ts +8 -0
  9. package/dist/probe/context.d.ts.map +1 -0
  10. package/dist/probe/context.js +7 -0
  11. package/dist/probe/context.js.map +1 -0
  12. package/dist/probe/errors.d.ts +12 -0
  13. package/dist/probe/errors.d.ts.map +1 -0
  14. package/dist/probe/errors.js +21 -0
  15. package/dist/probe/errors.js.map +1 -0
  16. package/dist/probe/index.d.ts +5 -0
  17. package/dist/probe/index.d.ts.map +1 -0
  18. package/dist/probe/index.js +4 -0
  19. package/dist/probe/index.js.map +1 -0
  20. package/dist/probe/registry.d.ts +24 -0
  21. package/dist/probe/registry.d.ts.map +1 -0
  22. package/dist/probe/registry.js +228 -0
  23. package/dist/probe/registry.js.map +1 -0
  24. package/dist/probe/registry.test.d.ts +7 -0
  25. package/dist/probe/registry.test.d.ts.map +1 -0
  26. package/dist/probe/registry.test.js +310 -0
  27. package/dist/probe/registry.test.js.map +1 -0
  28. package/dist/provider/instrumentation.d.ts +9 -0
  29. package/dist/provider/instrumentation.d.ts.map +1 -0
  30. package/dist/provider/instrumentation.js +104 -0
  31. package/dist/provider/instrumentation.js.map +1 -0
  32. package/dist/provider/instrumentation.test.d.ts +2 -0
  33. package/dist/provider/instrumentation.test.d.ts.map +1 -0
  34. package/dist/provider/instrumentation.test.js +152 -0
  35. package/dist/provider/instrumentation.test.js.map +1 -0
  36. package/dist/public-runtime.d.ts +5 -0
  37. package/dist/public-runtime.d.ts.map +1 -1
  38. package/dist/public-runtime.js +8 -0
  39. package/dist/public-runtime.js.map +1 -1
  40. package/dist/public-types.d.ts +3 -0
  41. package/dist/public-types.d.ts.map +1 -1
  42. package/dist/runtime/query/events.d.ts +3 -1
  43. package/dist/runtime/query/events.d.ts.map +1 -1
  44. package/dist/runtime/query/events.js +6 -1
  45. package/dist/runtime/query/events.js.map +1 -1
  46. package/dist/runtime/query/executor.d.ts +3 -1
  47. package/dist/runtime/query/executor.d.ts.map +1 -1
  48. package/dist/runtime/query/executor.js +30 -1
  49. package/dist/runtime/query/executor.js.map +1 -1
  50. package/dist/types/bus/index.d.ts +46 -2
  51. package/dist/types/bus/index.d.ts.map +1 -1
  52. package/dist/types/doctor/check.d.ts +41 -0
  53. package/dist/types/doctor/check.d.ts.map +1 -0
  54. package/dist/types/doctor/check.js +2 -0
  55. package/dist/types/doctor/check.js.map +1 -0
  56. package/dist/types/doctor/index.d.ts +2 -0
  57. package/dist/types/doctor/index.d.ts.map +1 -0
  58. package/dist/types/doctor/index.js +2 -0
  59. package/dist/types/doctor/index.js.map +1 -0
  60. package/dist/types/probe/event-kind.d.ts +6 -0
  61. package/dist/types/probe/event-kind.d.ts.map +1 -0
  62. package/dist/types/probe/event-kind.js +2 -0
  63. package/dist/types/probe/event-kind.js.map +1 -0
  64. package/dist/types/probe/event-of.d.ts +5 -0
  65. package/dist/types/probe/event-of.d.ts.map +1 -0
  66. package/dist/types/probe/event-of.js +2 -0
  67. package/dist/types/probe/event-of.js.map +1 -0
  68. package/dist/types/probe/index.d.ts +4 -0
  69. package/dist/types/probe/index.d.ts.map +1 -0
  70. package/dist/types/probe/index.js +2 -0
  71. package/dist/types/probe/index.js.map +1 -0
  72. package/dist/types/probe/registry.d.ts +27 -0
  73. package/dist/types/probe/registry.d.ts.map +1 -0
  74. package/dist/types/probe/registry.js +2 -0
  75. package/dist/types/probe/registry.js.map +1 -0
  76. package/dist/types/provider/interface.d.ts +10 -0
  77. package/dist/types/provider/interface.d.ts.map +1 -1
  78. package/dist/vault/instrumentation.d.ts +11 -0
  79. package/dist/vault/instrumentation.d.ts.map +1 -0
  80. package/dist/vault/instrumentation.js +32 -0
  81. package/dist/vault/instrumentation.js.map +1 -0
  82. package/dist/vault/instrumentation.test.d.ts +2 -0
  83. package/dist/vault/instrumentation.test.d.ts.map +1 -0
  84. package/dist/vault/instrumentation.test.js +80 -0
  85. package/dist/vault/instrumentation.test.js.map +1 -0
  86. package/package.json +1 -1
  87. package/src/bus/index.ts +21 -10
  88. package/src/probe/context.ts +14 -0
  89. package/src/probe/errors.ts +27 -0
  90. package/src/probe/index.ts +4 -0
  91. package/src/probe/registry.test.ts +480 -0
  92. package/src/probe/registry.ts +276 -0
  93. package/src/provider/instrumentation.test.ts +192 -0
  94. package/src/provider/instrumentation.ts +139 -0
  95. package/src/public-runtime.ts +22 -0
  96. package/src/public-types.ts +3 -0
  97. package/src/runtime/query/events.ts +6 -1
  98. package/src/runtime/query/executor.ts +34 -0
  99. package/src/types/bus/index.ts +54 -2
  100. package/src/types/doctor/check.ts +53 -0
  101. package/src/types/doctor/index.ts +9 -0
  102. package/src/types/probe/event-kind.ts +8 -0
  103. package/src/types/probe/event-of.ts +3 -0
  104. package/src/types/probe/index.ts +11 -0
  105. package/src/types/probe/registry.ts +36 -0
  106. package/src/types/provider/interface.ts +12 -0
  107. package/src/vault/instrumentation.test.ts +98 -0
  108. package/src/vault/instrumentation.ts +56 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,134 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.5
4
+
5
+ ### Patch Changes
6
+
7
+ - aead3a8: Doctor registry runtime + 5 built-in checks — ses_007 Phase 4.
8
+
9
+ `runDoctor(opts?)` aggregates registered checks into a `DoctorReport` with per-check status + summary + sysexits exit code. `registerDoctorCheck(check)` is the programmatic registration entry point.
10
+
11
+ **New runtime exports (12 names):**
12
+
13
+ - `doctor` (singleton `DoctorRegistry`), `DoctorRegistry`, `createDoctorRegistry`
14
+ - `registerDoctorCheck(check)` — programmatic registration
15
+ - `runDoctor(opts?)` → `Promise<DoctorReport>`
16
+ - `builtInDoctorChecks` — readonly list of the six shipped checks
17
+ - Six individual built-in checks: `sandboxPlatformCheck`, `cwdWritableCheck`, `tmpdirWritableCheck`, `vaultRegisteredCheck`, `providersRegisteredCheck`, `telemetryInstalledCheck`
18
+
19
+ **LLMProvider interface gains optional `doctorCheck?(): Promise<DoctorCheckResult>`.** Non-breaking — existing providers don't need to implement it. Consumers wanting provider health probes register a custom check that walks `ProviderRegistry.getAll()` and calls `provider.doctorCheck?.()` per provider.
20
+
21
+ **Built-in checks ship intentionally conservative for v1.** `sandbox.platform` passes on darwin if `/usr/bin/sandbox-exec` is executable; inconclusive on linux (proc namespace probe deferred); warn on win32; inconclusive elsewhere. `runtime.cwd-writable` + `runtime.tmpdir-writable` are real `fs.access(W_OK)` probes. `telemetry.installed` dynamic-imports `@namzu/telemetry` (specifier-variable to evade TS resolution since SDK doesn't depend on telemetry); pass if installed, inconclusive if not. `vault.registered` + `providers.registered` are intentionally inconclusive with explicit "register your own check" guidance — vault and provider registries are module-private and aren't auto-discoverable from a standalone process.
22
+
23
+ **Failure isolation:** a thrown check is recorded as `fail` with the throw message; other checks still run. A check exceeding `perCheckTimeoutMs` (default 5000ms) becomes `inconclusive`. Wall-clock timeout (default 10000ms) marks not-yet-completed checks as `inconclusive`. Status set: `pass | fail | inconclusive | warn`. Only `fail` affects the exit code (1); `inconclusive` and `warn` are informational. Empty registry → exit 2 (no config).
24
+
25
+ **Embedded usage today, CLI command in the next patch.** Consumers can `import { runDoctor, registerDoctorCheck } from '@namzu/sdk'` and integrate the doctor in their own process where their checks have already executed. The standalone `namzu doctor` CLI command lands in the next patch (Phase 5).
26
+
27
+ - 8f076e5: ses_007 Phase 5 — doctor runtime moved from `@namzu/sdk` to `@namzu/cli`. Architectural pivot: kernel = SDK (pure runtime primitives), operator surface = CLI (presentation + tooling).
28
+
29
+ ## Breaking changes — `@namzu/sdk`
30
+
31
+ The following 12 runtime exports have been **removed** from `@namzu/sdk`. They now live in `@namzu/cli`:
32
+
33
+ - `doctor` (singleton), `DoctorRegistry`, `createDoctorRegistry`
34
+ - `registerDoctorCheck`, `runDoctor`
35
+ - `builtInDoctorChecks`
36
+ - `sandboxPlatformCheck`, `cwdWritableCheck`, `tmpdirWritableCheck`
37
+ - `vaultRegisteredCheck`, `providersRegisteredCheck`, `telemetryInstalledCheck`
38
+
39
+ The `RunDoctorOptions` type has also been removed from `@namzu/sdk` exports.
40
+
41
+ **What stays in `@namzu/sdk`:**
42
+
43
+ - The protocol types — `DoctorCheck`, `DoctorCheckResult`, `DoctorCheckContext`, `DoctorCheckRecord`, `DoctorReport`, `DoctorStatus`, `DoctorCategory` — remain in `types/doctor/` so kernel components can implement custom checks against them.
44
+ - `LLMProvider.doctorCheck?(): Promise<DoctorCheckResult>` — the kernel hook that lets a provider expose its own healthcheck stays on the interface.
45
+
46
+ ## Migration
47
+
48
+ If you were calling the doctor in your own process:
49
+
50
+ ```diff
51
+ - import { runDoctor, registerDoctorCheck } from '@namzu/sdk'
52
+ + import { runDoctor, registerDoctorCheck } from '@namzu/cli'
53
+ ```
54
+
55
+ If you were running it from the command line:
56
+
57
+ ```bash
58
+ # Before — required a custom CLI bin or `pnpm dlx tsx packages/sdk/src/doctor/...`
59
+ # After:
60
+ pnpm dlx @namzu/cli doctor
61
+ # or, after install: namzu doctor
62
+ ```
63
+
64
+ Custom check authors continue to import the protocol types from `@namzu/sdk`:
65
+
66
+ ```ts
67
+ import type { DoctorCheck, DoctorCheckResult } from "@namzu/sdk";
68
+ import { registerDoctorCheck } from "@namzu/cli";
69
+
70
+ const myCheck: DoctorCheck = {
71
+ id: "app.db.reachable",
72
+ category: "custom",
73
+ run: async (): Promise<DoctorCheckResult> => {
74
+ // your probe
75
+ },
76
+ };
77
+ registerDoctorCheck(myCheck);
78
+ ```
79
+
80
+ ## New — `@namzu/cli` (initial public release)
81
+
82
+ `@namzu/cli` v0.1.0 ships as a public package for the first time. Dual-purpose:
83
+
84
+ - **Standalone bin** — `npx @namzu/cli doctor`, or after install: `namzu doctor`. Supports `--json`, `--verbose`, `--category <a,b,c>`, `--per-check-timeout <ms>`, `--wall-clock-timeout <ms>`. Sysexits-aligned exit codes (`0` ok, `1` fail, `2` no config, `70` internal error).
85
+ - **Library** — `import { runDoctor, registerDoctorCheck, builtInDoctorChecks } from '@namzu/cli'` for embedded usage where consumer code wants to invoke the doctor in its own process so app-registered checks are visible.
86
+
87
+ **What ships built-in:**
88
+
89
+ - `sandbox.platform` (darwin sandbox-exec presence + win32 warn + linux/other inconclusive)
90
+ - `runtime.cwd-writable` + `runtime.tmpdir-writable` (real `fs.access(W_OK)` probes)
91
+ - `telemetry.installed` (dynamic-import probe for `@namzu/telemetry`)
92
+ - `vault.registered` + `providers.registered` (intentionally inconclusive — consumers register their own walking their setup)
93
+
94
+ **Why patch-bump-equivalent:** `@namzu/sdk: minor` carries the breaking removal (pre-1.0 cadence); `@namzu/cli: minor` carries the new package's first feature release. Together they make the next release a coordinated cut.
95
+
96
+ ## 0.4.4
97
+
98
+ ### Patch Changes
99
+
100
+ - ffe516c: Probe layer (typed observation + narrow veto) over AgentBus + RunEvent stream — ses_007 phases 0–3.
101
+
102
+ Public surface additions:
103
+
104
+ - **Typed probe observation.** `probe.on(kind | kind[], handler, opts?)` registers a typed handler scoped to one or more event kinds. `probe.onAny(handler, opts?)` is the catch-all tier preserving legacy `AgentBus.on` semantics. Options: `{ where, priority, name, override }`. Events are frozen at the registry boundary; throws are isolated per probe.
105
+ - **Narrow veto on tool execution.** `probe.veto('tool_executing', handler, opts?)` registers a veto handler. Handler returns `'allow' | 'deny' | { action: 'deny', reason }`. `VetoableEventKind = 'tool_executing'` in v1 (additive minor adds more kinds later). First-deny wins by ascending priority; subsequent veto handlers still fire for audit. Tool executor short-circuits before `tools.execute(...)` on deny: returns a synthetic tool failure carrying `ProbeVetoError.message` so the LLM sees a normal tool-call failure with the probe name + reason.
106
+ - **5 new bus event variants.** `provider_call_start`, `provider_call_completed`, `provider_call_failed`, `vault_lookup`, `sandbox_decision`. Joined to the existing `AgentBusEvent` discriminated union. Snake_case real discriminants — no rename pass on existing events.
107
+ - **Opt-in instrumentation wrappers.** `wrapProviderWithProbes(provider, opts?)` returns an `LLMProvider` that emits `provider_call_*` around every `chat`/`chatStream` call (correlated by a `pcall_${string}` callId, with optional usage telemetry). `wrapVaultWithProbes(vault, opts?)` emits `vault_lookup` on every `retrieve()`; the secret value is never included in the event payload (covered by a "no leakage" test).
108
+ - **First-time public exposure of bus event types.** `AgentBusEvent`, `AgentBusEventListener`, `CircuitBreakerSnapshot`, `FileLock`, etc. were already reachable via `AgentBus.on(listener)` at runtime but couldn't be statically typed by consumers. Now in `public-types.ts`. Pre-existing duplicate `LockId` declaration in `types/bus/` was deduplicated to a re-export from `types/ids/` in passing.
109
+ - **Replay-aware probe context.** `ProbeContext.isReplay: boolean` flag wired through `buildProbeContext({ runId?, isReplay? })` so probes that bill or call external services can opt out on replayed runs (`ctx.isReplay === true`). Replay-execution wiring lands in a future session; the accessor is ready.
110
+
111
+ Integration:
112
+
113
+ - `AgentBus.emit` dispatches through `ProbeRegistry` first (typed-priority probes → legacy `bus.on` listeners → `onAny` catch-all). Existing `bus.on(listener)` consumers see every event in unchanged relative order.
114
+ - `EventTranslator.emitEvent` dispatches every `RunEvent` through the same registry before the existing pendingEvents push + persist flow.
115
+ - `ToolExecutor.executeSingle` calls `probes.queryVeto({type: 'tool_executing', ...})` immediately after the existing `tool_executing` emit, before `tools.execute(...)`.
116
+
117
+ Not yet wired (follow-up commits):
118
+
119
+ - Per-run probes via `createRun({ probes: [...] })` — the registry has the foundation; createRun plumbing lands in a follow-up.
120
+ - `wrapProviderWithProbes` / `wrapVaultWithProbes` are opt-in helpers; the SDK's own `ProviderRegistry` does not auto-wrap registered providers yet.
121
+ - `sandbox_decision` ships as a type only; emit site lands when a real sandbox provider exists (current `LocalSandboxProvider` is a stub).
122
+
123
+ Public surface delta: `380 → 392` runtime keys (verified against the regenerated baseline). Net new symbols added by this changeset:
124
+
125
+ - `probe`, `ProbeRegistry`, `createProbeRegistry`, `buildProbeContext`, `ProbeNameCollisionError`, `ProbeVetoError`
126
+ - `wrapProviderWithProbes`, `wrapVaultWithProbes`
127
+
128
+ Non-runtime (types-only) additions: `ProbeEventKind`, `ProbeEventOf<K>`, `ProbeContext`, `ProbeHandler<K>`, `ProbeOptions<K>`, `Unsubscribe`, `VetoableEventKind`, `VetoDecision`, `VetoHandler<K>`, `VetoOutcome`, `DoctorStatus`, `DoctorCategory`, `DoctorCheck`, `DoctorCheckContext`, `DoctorCheckResult`, `DoctorCheckRecord`, `DoctorReport`, `ProviderCallId`, `ProviderCallUsage`, `SandboxDecisionAction`, plus first-time exposure of all `AgentBusEvent` shape types.
129
+
130
+ Doctor types ship in this release; the runtime registry + CLI command land in a subsequent ses_007 patch.
131
+
3
132
  ## 0.4.3
4
133
 
5
134
  ### Patch Changes
@@ -12,13 +12,13 @@ declare const ConnectorRouterInputSchema: z.ZodObject<{
12
12
  method: z.ZodString;
13
13
  input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
14
14
  }, "strip", z.ZodTypeAny, {
15
- method: string;
16
15
  input: Record<string, unknown>;
16
+ method: string;
17
17
  connectorId: string;
18
18
  instanceId: string;
19
19
  }, {
20
- method: string;
21
20
  input: Record<string, unknown>;
21
+ method: string;
22
22
  connectorId: string;
23
23
  instanceId: string;
24
24
  }>;
@@ -1,3 +1,4 @@
1
+ import { type ProbeRegistry } from '../probe/registry.js';
1
2
  import type { AgentBusEventListener } from '../types/bus/index.js';
2
3
  import type { RunId } from '../types/ids/index.js';
3
4
  import type { Logger } from '../utils/logger.js';
@@ -19,7 +20,8 @@ export declare class AgentBus {
19
20
  private readonly listeners;
20
21
  private readonly log;
21
22
  private readonly config;
22
- constructor(log: Logger, config?: Partial<AgentBusConfig>);
23
+ private readonly probes;
24
+ constructor(log: Logger, config?: Partial<AgentBusConfig>, probeRegistry?: ProbeRegistry);
23
25
  on(listener: AgentBusEventListener): () => void;
24
26
  private emit;
25
27
  cleanupAgent(runId: RunId): void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bus/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAiB,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AACjF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAErD,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,MAAM,CAAA;IACrB,oBAAoB,EAAE,MAAM,CAAA;IAC5B,gBAAgB,EAAE,MAAM,CAAA;IACxB,uBAAuB,EAAE,MAAM,CAAA;IAC/B,qBAAqB,EAAE,MAAM,CAAA;CAC7B;AAWD,qBAAa,QAAQ;IACpB,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAA;IAC/B,QAAQ,CAAC,SAAS,EAAE,oBAAoB,CAAA;IACxC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAA;IAEhC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAwC;IAClE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;gBAE3B,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,CAAC,cAAc,CAAM;IAsB7D,EAAE,CAAC,QAAQ,EAAE,qBAAqB,GAAG,MAAM,IAAI;IAO/C,OAAO,CAAC,IAAI;IAaZ,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAahC,WAAW,IAAI,IAAI;CAMnB;AAED,O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ClE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAGrC,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,OAAO,CAAC,cAAc,CAAM,EACpC,aAAa,GAAE,aAAoC;IAyBpD,EAAE,CAAC,QAAQ,EAAE,qBAAqB,GAAG,MAAM,IAAI;IAO/C,OAAO,CAAC,IAAI;IAeZ,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAahC,WAAW,IAAI,IAAI;CAMnB;AAED,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3C,YAAY,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AACrD,YAAY,EACX,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,QAAQ,EACR,aAAa,EACb,iBAAiB,EACjB,MAAM,EACN,oBAAoB,GACpB,MAAM,uBAAuB,CAAA"}
package/dist/bus/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { DEFAULT_BREAKER_FAILURE_THRESHOLD, DEFAULT_BREAKER_RESET_TIMEOUT_MS, DEFAULT_LOCK_ACQUIRE_TIMEOUT_MS, DEFAULT_LOCK_TIMEOUT_MS, DEFAULT_MAX_LOCKS_PER_AGENT, } from '../constants/bus/index.js';
2
+ import { buildProbeContext } from '../probe/context.js';
3
+ import { probe as defaultProbeRegistry } from '../probe/registry.js';
2
4
  import { CircuitBreaker } from './breaker.js';
3
5
  import { FileLockManager } from './lock.js';
4
6
  import { EditOwnershipTracker } from './ownership.js';
@@ -17,9 +19,12 @@ export class AgentBus {
17
19
  listeners = new Set();
18
20
  log;
19
21
  config;
20
- constructor(log, config = {}) {
22
+ probes;
23
+ constructor(log, config = {}, probeRegistry = defaultProbeRegistry) {
21
24
  this.config = { ...DEFAULT_AGENT_BUS_CONFIG, ...config };
22
25
  this.log = log.child({ component: 'AgentBus' });
26
+ this.probes = probeRegistry;
27
+ this.probes.setLogger(log);
23
28
  const emitFn = (event) => this.emit(event);
24
29
  this.locks = new FileLockManager(this.log, emitFn, {
25
30
  lockTimeoutMs: this.config.lockTimeoutMs,
@@ -36,17 +41,19 @@ export class AgentBus {
36
41
  };
37
42
  }
38
43
  emit(event) {
39
- for (const listener of this.listeners) {
40
- try {
41
- listener(event);
44
+ this.probes.dispatch(event, buildProbeContext(), () => {
45
+ for (const listener of this.listeners) {
46
+ try {
47
+ listener(event);
48
+ }
49
+ catch (error) {
50
+ this.log.error('event listener threw', {
51
+ eventType: event.type,
52
+ error: error instanceof Error ? error.message : String(error),
53
+ });
54
+ }
42
55
  }
43
- catch (error) {
44
- this.log.error('event listener threw', {
45
- eventType: event.type,
46
- error: error instanceof Error ? error.message : String(error),
47
- });
48
- }
49
- }
56
+ });
50
57
  }
51
58
  cleanupAgent(runId) {
52
59
  this.log.info('cleaning up agent resources', { runId });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bus/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iCAAiC,EACjC,gCAAgC,EAChC,+BAA+B,EAC/B,uBAAuB,EACvB,2BAA2B,GAC3B,MAAM,2BAA2B,CAAA;AAKlC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAWrD,MAAM,wBAAwB,GAAmB;IAChD,OAAO,EAAE,IAAI;IACb,aAAa,EAAE,uBAAuB;IACtC,oBAAoB,EAAE,+BAA+B;IACrD,gBAAgB,EAAE,2BAA2B;IAC7C,uBAAuB,EAAE,iCAAiC;IAC1D,qBAAqB,EAA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AAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;qBAC7D,CAAC,CAAA;gBACH,CAAC;YACF,CAAC;QACF,CAAC,CAAC,CAAA;IACH,CAAC;IAED,YAAY,CAAC,KAAY;QACxB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,6BAA6B,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;QACvD,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;QAClD,MAAM,kBAAkB,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;QAC3D,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAEzB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,wBAAwB,EAAE;YACvC,KAAK;YACL,aAAa;YACb,kBAAkB;SAClB,CAAC,CAAA;IACH,CAAC;IAED,WAAW;QACV,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAA;QACxC,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YACjB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,kCAAkC,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAA;QACtE,CAAC;IACF,CAAC;CACD;AAED,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA"}
@@ -294,6 +294,20 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
294
294
  tokenBudget: number;
295
295
  maxResponseTokens: number;
296
296
  maxIterations: number;
297
+ sandbox?: {
298
+ enabled: boolean;
299
+ provider: "local";
300
+ timeoutMs: number;
301
+ memoryLimitMb: number;
302
+ maxProcesses: number;
303
+ cleanupOnDestroy: boolean;
304
+ } | undefined;
305
+ plugins?: {
306
+ enabled: boolean;
307
+ autoDiscovery: boolean;
308
+ allowedScopes: ("user" | "project")[];
309
+ hookTimeoutMs: number;
310
+ } | undefined;
297
311
  taskRouter?: {
298
312
  default?: string | null | undefined;
299
313
  compaction?: string | null | undefined;
@@ -315,22 +329,22 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
315
329
  enabled: boolean;
316
330
  strategy: "auto" | "disabled";
317
331
  } | undefined;
318
- plugins?: {
319
- enabled: boolean;
320
- autoDiscovery: boolean;
321
- allowedScopes: ("user" | "project")[];
322
- hookTimeoutMs: number;
323
- } | undefined;
324
- sandbox?: {
325
- enabled: boolean;
326
- provider: "local";
327
- timeoutMs: number;
328
- memoryLimitMb: number;
329
- maxProcesses: number;
330
- cleanupOnDestroy: boolean;
331
- } | undefined;
332
332
  }, {
333
333
  timeoutMs?: number | undefined;
334
+ sandbox?: {
335
+ enabled?: boolean | undefined;
336
+ provider?: "local" | undefined;
337
+ timeoutMs?: number | undefined;
338
+ memoryLimitMb?: number | undefined;
339
+ maxProcesses?: number | undefined;
340
+ cleanupOnDestroy?: boolean | undefined;
341
+ } | undefined;
342
+ plugins?: {
343
+ enabled?: boolean | undefined;
344
+ autoDiscovery?: boolean | undefined;
345
+ allowedScopes?: ("user" | "project")[] | undefined;
346
+ hookTimeoutMs?: number | undefined;
347
+ } | undefined;
334
348
  compaction?: {
335
349
  strategy?: "disabled" | "structured" | "sliding-window" | undefined;
336
350
  triggerThreshold?: number | undefined;
@@ -373,20 +387,6 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
373
387
  enabled?: boolean | undefined;
374
388
  strategy?: "auto" | "disabled" | undefined;
375
389
  } | undefined;
376
- plugins?: {
377
- enabled?: boolean | undefined;
378
- autoDiscovery?: boolean | undefined;
379
- allowedScopes?: ("user" | "project")[] | undefined;
380
- hookTimeoutMs?: number | undefined;
381
- } | undefined;
382
- sandbox?: {
383
- enabled?: boolean | undefined;
384
- provider?: "local" | undefined;
385
- timeoutMs?: number | undefined;
386
- memoryLimitMb?: number | undefined;
387
- maxProcesses?: number | undefined;
388
- cleanupOnDestroy?: boolean | undefined;
389
- } | undefined;
390
390
  }>;
391
391
  export type RuntimeConfig = z.infer<typeof RuntimeConfigSchema>;
392
392
  export declare const RUNTIME_DEFAULTS: Readonly<RuntimeConfig>;
@@ -0,0 +1,8 @@
1
+ import type { RunId } from '../types/ids/index.js';
2
+ import type { ProbeContext } from '../types/probe/index.js';
3
+ export interface ProbeContextInput {
4
+ readonly runId?: RunId;
5
+ readonly isReplay?: boolean;
6
+ }
7
+ export declare function buildProbeContext(input?: ProbeContextInput): ProbeContext;
8
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/probe/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAE3D,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAA;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAC3B;AAED,wBAAgB,iBAAiB,CAAC,KAAK,GAAE,iBAAsB,GAAG,YAAY,CAK7E"}
@@ -0,0 +1,7 @@
1
+ export function buildProbeContext(input = {}) {
2
+ return Object.freeze({
3
+ runId: input.runId,
4
+ isReplay: input.isReplay ?? false,
5
+ });
6
+ }
7
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/probe/context.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,iBAAiB,CAAC,QAA2B,EAAE;IAC9D,OAAO,MAAM,CAAC,MAAM,CAAC;QACpB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,KAAK;KACjC,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { VetoableEventKind } from '../types/probe/index.js';
2
+ export declare class ProbeNameCollisionError extends Error {
3
+ readonly probeName: string;
4
+ constructor(probeName: string);
5
+ }
6
+ export declare class ProbeVetoError extends Error {
7
+ readonly probeName: string;
8
+ readonly reason: string;
9
+ readonly eventKind: VetoableEventKind;
10
+ constructor(probeName: string, reason: string, eventKind: VetoableEventKind);
11
+ }
12
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/probe/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE,qBAAa,uBAAwB,SAAQ,KAAK;IACjD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;gBAEd,SAAS,EAAE,MAAM;CAO7B;AAED,qBAAa,cAAe,SAAQ,KAAK;IACxC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAA;gBAEzB,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB;CAO3E"}
@@ -0,0 +1,21 @@
1
+ export class ProbeNameCollisionError extends Error {
2
+ probeName;
3
+ constructor(probeName) {
4
+ super(`Probe name "${probeName}" is already registered. Pass { override: true } to replace, or pick a different name.`);
5
+ this.name = 'ProbeNameCollisionError';
6
+ this.probeName = probeName;
7
+ }
8
+ }
9
+ export class ProbeVetoError extends Error {
10
+ probeName;
11
+ reason;
12
+ eventKind;
13
+ constructor(probeName, reason, eventKind) {
14
+ super(`Operation denied by probe "${probeName}" on ${eventKind}: ${reason}`);
15
+ this.name = 'ProbeVetoError';
16
+ this.probeName = probeName;
17
+ this.reason = reason;
18
+ this.eventKind = eventKind;
19
+ }
20
+ }
21
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/probe/errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACxC,SAAS,CAAQ;IAE1B,YAAY,SAAiB;QAC5B,KAAK,CACJ,eAAe,SAAS,wFAAwF,CAChH,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAA;QACrC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC3B,CAAC;CACD;AAED,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC/B,SAAS,CAAQ;IACjB,MAAM,CAAQ;IACd,SAAS,CAAmB;IAErC,YAAY,SAAiB,EAAE,MAAc,EAAE,SAA4B;QAC1E,KAAK,CAAC,8BAA8B,SAAS,QAAQ,SAAS,KAAK,MAAM,EAAE,CAAC,CAAA;QAC5E,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAA;QAC5B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC3B,CAAC;CACD"}
@@ -0,0 +1,5 @@
1
+ export { ProbeNameCollisionError, ProbeVetoError } from './errors.js';
2
+ export { buildProbeContext } from './context.js';
3
+ export type { ProbeContextInput } from './context.js';
4
+ export { ProbeRegistry, createProbeRegistry, probe } from './registry.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/probe/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA"}
@@ -0,0 +1,4 @@
1
+ export { ProbeNameCollisionError, ProbeVetoError } from './errors.js';
2
+ export { buildProbeContext } from './context.js';
3
+ export { ProbeRegistry, createProbeRegistry, probe } from './registry.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/probe/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEhD,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA"}
@@ -0,0 +1,24 @@
1
+ import type { ProbeContext, ProbeEvent, ProbeEventKind, ProbeEventOf, ProbeHandler, ProbeOptions, Unsubscribe, VetoHandler, VetoOutcome, VetoableEventKind } from '../types/probe/index.js';
2
+ import type { Logger } from '../utils/logger.js';
3
+ export declare class ProbeRegistry {
4
+ private readonly typedByKind;
5
+ private readonly vetoByKind;
6
+ private readonly catchAll;
7
+ private readonly byName;
8
+ private nextId;
9
+ private log?;
10
+ setLogger(log: Logger): void;
11
+ on<K extends ProbeEventKind>(kind: K | readonly K[], handler: ProbeHandler<K>, opts?: ProbeOptions<K>): Unsubscribe;
12
+ onAny(handler: (event: ProbeEvent, ctx: ProbeContext) => void, opts?: ProbeOptions): Unsubscribe;
13
+ dispatch(event: ProbeEvent, ctx: ProbeContext, betweenTier?: () => void): void;
14
+ veto<K extends VetoableEventKind>(kind: K, handler: VetoHandler<K>, opts?: ProbeOptions<K>): Unsubscribe;
15
+ queryVeto<K extends VetoableEventKind>(event: ProbeEventOf<K>, ctx: ProbeContext): VetoOutcome;
16
+ clear(): void;
17
+ private runTier;
18
+ private makeEntry;
19
+ private removeAnywhere;
20
+ private logThrow;
21
+ }
22
+ export declare const probe: ProbeRegistry;
23
+ export declare function createProbeRegistry(): ProbeRegistry;
24
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/probe/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,YAAY,EACZ,UAAU,EACV,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,EAEX,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAoEhD,qBAAa,aAAa;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA+C;IAC3E,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiD;IAC5E,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmB;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiD;IACxE,OAAO,CAAC,MAAM,CAAI;IAClB,OAAO,CAAC,GAAG,CAAC,CAAQ;IAEpB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI5B,EAAE,CAAC,CAAC,SAAS,cAAc,EAC1B,IAAI,EAAE,CAAC,GAAG,SAAS,CAAC,EAAE,EACtB,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EACxB,IAAI,GAAE,YAAY,CAAC,CAAC,CAAM,GACxB,WAAW;IAyBd,KAAK,CACJ,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,YAAY,KAAK,IAAI,EACvD,IAAI,GAAE,YAAiB,GACrB,WAAW;IASd,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,YAAY,EAAE,WAAW,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI;IAa9E,IAAI,CAAC,CAAC,SAAS,iBAAiB,EAC/B,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,WAAW,CAAC,CAAC,CAA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