@responsibleai/agent-hooks 0.1.0-beta.1 → 0.1.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,7 +5,8 @@ TypeScript implementation of
5
5
  over the canonical Rust core (napi-rs native module): interception
6
6
  points, `AgentContextBuilder`, `Verdict` types, host-side
7
7
  `InterceptionEmitter` with the four composition profiles, the
8
- identity-provider seam, and the CTK runner.
8
+ identity-provider seam, the host declaration loader, and the CTK
9
+ runner.
9
10
 
10
11
  > **Trust model.** agent-hooks is a *cooperative contract*, not a security
11
12
  > boundary: the host framework is fully trusted, interceptors run in-process
@@ -15,13 +16,13 @@ identity-provider seam, and the CTK runner.
15
16
  > before relying on it.
16
17
 
17
18
  ```bash
18
- npm install @responsibleai/agent-hooks@alpha
19
+ npm install @responsibleai/agent-hooks
19
20
  ```
20
21
 
21
- Keep the `@alpha` tag (or pin an exact published version) while the
22
- package is pre-release: npm's `latest` tag can lag the newest
23
- pre-release, so a plain `npm install` may fetch an older build. Check
24
- what the tags resolve to with
22
+ A plain install gets the newest release, pre-releases included. The
23
+ channel tags `alpha`, `beta` and `rc` exist for pinning to one line
24
+ (`@responsibleai/agent-hooks@beta`); or pin an exact published
25
+ version. Check what the tags resolve to with
25
26
  `npm view @responsibleai/agent-hooks dist-tags`.
26
27
 
27
28
  ## Usage
@@ -44,11 +45,75 @@ const ctx = builder.preToolCall("tc-1", "http_get", { url });
44
45
  await emitter.emit(ctx); // throws InterceptionBlocked on a combined deny
45
46
  ```
46
47
 
48
+ `register(interceptor, name?, at?)` also takes the points an
49
+ interceptor runs at. At a point, `interceptors_registered`,
50
+ `verdicts[].index` and `decided_by` count and index the interceptors
51
+ bound there, in registration order.
52
+
53
+ ## Host declaration
54
+
55
+ A host can load its configuration, declared surface and interceptor
56
+ bindings from one JSON document (spec §7.7) instead of calling the
57
+ setters. The document is a versioned contract,
58
+ `agent-hooks-declaration/1.0`, separate from the wire version
59
+ `agent-hooks/0.1`. The SDK exports the version it writes
60
+ (`DECLARATION_VERSION`) and the set it accepts
61
+ (`SUPPORTED_DECLARATION_VERSIONS`). A document of any other version is
62
+ refused.
63
+
64
+ ```ts
65
+ import {
66
+ HostDeclaration,
67
+ HostRegistry,
68
+ HostSurface,
69
+ InterceptionEmitter,
70
+ } from "@responsibleai/agent-hooks";
71
+
72
+ // What the code can honour. A document may select a subset, never more.
73
+ const surface = HostSurface.fromCapabilities(["model_calls", "tool_calls", "host_declaration"]);
74
+
75
+ // Kind resolvers turn a binding's `config` into an interceptor. A kind
76
+ // is a lookup key the host names; the spec defines none.
77
+ const registry = new HostRegistry(surface)
78
+ .kind("com.example.egress", (config, ctx) => new EgressGuard(config))
79
+ .approvalResolver("operator-queue", queue);
80
+
81
+ const emitter = await InterceptionEmitter.fromDeclarationPath(
82
+ "agent-hooks.declaration.json",
83
+ registry,
84
+ );
85
+ ```
86
+
87
+ The three construction paths yield the same emitter and the same
88
+ records: `fromDeclarationPath` reads a file, `fromDeclarationJson`
89
+ takes the text, `fromDeclarationValue` takes a parsed object, and
90
+ `fromDeclaration` takes a `HostDeclaration` (for example from
91
+ `HostDeclaration.builder()`, one setter per member and `bind(...)` per
92
+ binding). `emitter.declaration` is the resolved form with every default
93
+ filled; `canonicalDeclaration(emitter.declaration)` is its RFC 8785
94
+ canonical JSON, the equivalence oracle.
95
+
96
+ A document that names anything the host cannot honour is refused at
97
+ load, before any emission, with a `DeclarationError`. The error carries
98
+ `code` (one of eleven `declaration_error:*` classes), `findings` (JSON
99
+ pointer plus detail, never binding configuration) and, for
100
+ `version_unsupported`, `accepted`. The Rust core runs every check, so
101
+ the class is the same as in the other SDKs. An emitter built from a
102
+ declaration is sealed: `register` and the setters throw
103
+ `EmitterSealed`; `setRecordSink` and `takeRecords` stay allowed.
104
+ Records from such an emitter carry `declaration:
105
+ "agent-hooks-declaration/1.0"`; records from an emitter configured in
106
+ code do not and are unchanged.
107
+
47
108
  **JavaScript value-domain caveat (spec §4.4):** `JSON.parse` rounds
48
109
  integers beyond 2^53 before any guard can run, so this SDK cannot claim
49
110
  the `int64_json`/`bigint_json` CTK capabilities — string-encode
50
111
  64-bit identifiers at the adapter boundary. Non-finite numbers are
51
- rejected fail-closed by a pre-serialization scan.
112
+ rejected fail-closed by a pre-serialization scan. The same rounding
113
+ applies to `bindings[].config`: the loader hands the core the validated
114
+ text, so the load checks see the integers the file had, but the
115
+ resolved form and a kind resolver receive JavaScript values.
116
+ String-encode 64-bit values in binding configuration too.
52
117
 
53
118
  ## Native module deployment
54
119
 
package/binding.d.ts CHANGED
@@ -27,8 +27,35 @@ export declare function ctkScriptedResolve(rulesJson: string, ctxJson: string, i
27
27
 
28
28
  export declare function ctkShouldSkip(vectorJson: string, harnessCapsJson: string): string
29
29
 
30
+ /**
31
+ * Steps 2 to 10 of §7.7.6 against the wrapper's host description
32
+ * (`{surface, identity_providers, approval_resolvers,
33
+ * approval_redactors, kinds}`). Returns the resolved declaration JSON.
34
+ */
35
+ export declare function declarationResolve(documentJson: string, hostJson: string): string
36
+
37
+ /**
38
+ * Steps 2 to 8 of §7.7.6 against a code surface alone, no registry:
39
+ * what the CTK runner needs to read a harness's own document
40
+ * (§7.7.9). A surface that does not parse or that the core rejects is
41
+ * a wrapper defect and comes back as `marshal_error`, never as a
42
+ * refusal of the document.
43
+ */
44
+ export declare function declarationResolveSurface(documentJson: string, surfaceJson: string): string
45
+
46
+ /**
47
+ * Steps 2 to 7 of §7.7.6 over JSON text. Returns the validated
48
+ * document as JSON (verbatim, `$schema` included).
49
+ */
50
+ export declare function declarationValidate(documentJson: string): string
51
+
52
+ /** `{"current": "...", "supported": [...]}` (§7.7.2). */
53
+ export declare function declarationVersions(): string
54
+
30
55
  export declare function finalize(ctxJson: string, verdictJson: string, mode: string, optionsJson: string): string
31
56
 
57
+ export declare function normalizeInterceptorResponse(responseJson: string): string
58
+
32
59
  export declare function specVersion(): string
33
60
 
34
61
  /** §4/§6.3: envelope validation (fail closed, value-free detail). */
package/binding.js CHANGED
@@ -89,8 +89,8 @@ function requireNative() {
89
89
  try {
90
90
  const binding = require('@responsibleai/agent-hooks-android-arm64')
91
91
  const bindingPackageVersion = require('@responsibleai/agent-hooks-android-arm64/package.json').version
92
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
93
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
92
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
93
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
94
94
  }
95
95
  return binding
96
96
  } catch (e) {
@@ -105,8 +105,8 @@ function requireNative() {
105
105
  try {
106
106
  const binding = require('@responsibleai/agent-hooks-android-arm-eabi')
107
107
  const bindingPackageVersion = require('@responsibleai/agent-hooks-android-arm-eabi/package.json').version
108
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
109
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
108
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
109
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
110
110
  }
111
111
  return binding
112
112
  } catch (e) {
@@ -126,8 +126,8 @@ function requireNative() {
126
126
  try {
127
127
  const binding = require('@responsibleai/agent-hooks-win32-x64-gnu')
128
128
  const bindingPackageVersion = require('@responsibleai/agent-hooks-win32-x64-gnu/package.json').version
129
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
130
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
129
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
130
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
131
131
  }
132
132
  return binding
133
133
  } catch (e) {
@@ -142,8 +142,8 @@ function requireNative() {
142
142
  try {
143
143
  const binding = require('@responsibleai/agent-hooks-win32-x64-msvc')
144
144
  const bindingPackageVersion = require('@responsibleai/agent-hooks-win32-x64-msvc/package.json').version
145
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
146
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
145
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
146
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
147
147
  }
148
148
  return binding
149
149
  } catch (e) {
@@ -159,8 +159,8 @@ function requireNative() {
159
159
  try {
160
160
  const binding = require('@responsibleai/agent-hooks-win32-ia32-msvc')
161
161
  const bindingPackageVersion = require('@responsibleai/agent-hooks-win32-ia32-msvc/package.json').version
162
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
163
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
162
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
163
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
164
164
  }
165
165
  return binding
166
166
  } catch (e) {
@@ -175,8 +175,8 @@ function requireNative() {
175
175
  try {
176
176
  const binding = require('@responsibleai/agent-hooks-win32-arm64-msvc')
177
177
  const bindingPackageVersion = require('@responsibleai/agent-hooks-win32-arm64-msvc/package.json').version
178
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
179
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
178
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
179
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
180
180
  }
181
181
  return binding
182
182
  } catch (e) {
@@ -194,8 +194,8 @@ function requireNative() {
194
194
  try {
195
195
  const binding = require('@responsibleai/agent-hooks-darwin-universal')
196
196
  const bindingPackageVersion = require('@responsibleai/agent-hooks-darwin-universal/package.json').version
197
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
198
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
197
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
198
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
199
199
  }
200
200
  return binding
201
201
  } catch (e) {
@@ -210,8 +210,8 @@ function requireNative() {
210
210
  try {
211
211
  const binding = require('@responsibleai/agent-hooks-darwin-x64')
212
212
  const bindingPackageVersion = require('@responsibleai/agent-hooks-darwin-x64/package.json').version
213
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
214
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
213
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
214
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
215
215
  }
216
216
  return binding
217
217
  } catch (e) {
@@ -226,8 +226,8 @@ function requireNative() {
226
226
  try {
227
227
  const binding = require('@responsibleai/agent-hooks-darwin-arm64')
228
228
  const bindingPackageVersion = require('@responsibleai/agent-hooks-darwin-arm64/package.json').version
229
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
230
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
229
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
230
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
231
231
  }
232
232
  return binding
233
233
  } catch (e) {
@@ -246,8 +246,8 @@ function requireNative() {
246
246
  try {
247
247
  const binding = require('@responsibleai/agent-hooks-freebsd-x64')
248
248
  const bindingPackageVersion = require('@responsibleai/agent-hooks-freebsd-x64/package.json').version
249
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
250
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
249
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
250
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
251
251
  }
252
252
  return binding
253
253
  } catch (e) {
@@ -262,8 +262,8 @@ function requireNative() {
262
262
  try {
263
263
  const binding = require('@responsibleai/agent-hooks-freebsd-arm64')
264
264
  const bindingPackageVersion = require('@responsibleai/agent-hooks-freebsd-arm64/package.json').version
265
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
266
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
265
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
266
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
267
267
  }
268
268
  return binding
269
269
  } catch (e) {
@@ -283,8 +283,8 @@ function requireNative() {
283
283
  try {
284
284
  const binding = require('@responsibleai/agent-hooks-linux-x64-musl')
285
285
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-x64-musl/package.json').version
286
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
287
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
286
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
287
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
288
288
  }
289
289
  return binding
290
290
  } catch (e) {
@@ -299,8 +299,8 @@ function requireNative() {
299
299
  try {
300
300
  const binding = require('@responsibleai/agent-hooks-linux-x64-gnu')
301
301
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-x64-gnu/package.json').version
302
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
303
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
302
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
303
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
304
304
  }
305
305
  return binding
306
306
  } catch (e) {
@@ -317,8 +317,8 @@ function requireNative() {
317
317
  try {
318
318
  const binding = require('@responsibleai/agent-hooks-linux-arm64-musl')
319
319
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-arm64-musl/package.json').version
320
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
321
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
320
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
321
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
322
322
  }
323
323
  return binding
324
324
  } catch (e) {
@@ -333,8 +333,8 @@ function requireNative() {
333
333
  try {
334
334
  const binding = require('@responsibleai/agent-hooks-linux-arm64-gnu')
335
335
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-arm64-gnu/package.json').version
336
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
337
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
336
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
337
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
338
338
  }
339
339
  return binding
340
340
  } catch (e) {
@@ -351,8 +351,8 @@ function requireNative() {
351
351
  try {
352
352
  const binding = require('@responsibleai/agent-hooks-linux-arm-musleabihf')
353
353
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-arm-musleabihf/package.json').version
354
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
355
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
354
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
355
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
356
356
  }
357
357
  return binding
358
358
  } catch (e) {
@@ -367,8 +367,8 @@ function requireNative() {
367
367
  try {
368
368
  const binding = require('@responsibleai/agent-hooks-linux-arm-gnueabihf')
369
369
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-arm-gnueabihf/package.json').version
370
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
371
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
370
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
371
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
372
372
  }
373
373
  return binding
374
374
  } catch (e) {
@@ -385,8 +385,8 @@ function requireNative() {
385
385
  try {
386
386
  const binding = require('@responsibleai/agent-hooks-linux-loong64-musl')
387
387
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-loong64-musl/package.json').version
388
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
389
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
388
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
389
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
390
390
  }
391
391
  return binding
392
392
  } catch (e) {
@@ -401,8 +401,8 @@ function requireNative() {
401
401
  try {
402
402
  const binding = require('@responsibleai/agent-hooks-linux-loong64-gnu')
403
403
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-loong64-gnu/package.json').version
404
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
405
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
404
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
405
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
406
406
  }
407
407
  return binding
408
408
  } catch (e) {
@@ -419,8 +419,8 @@ function requireNative() {
419
419
  try {
420
420
  const binding = require('@responsibleai/agent-hooks-linux-riscv64-musl')
421
421
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-riscv64-musl/package.json').version
422
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
423
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
422
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
423
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
424
424
  }
425
425
  return binding
426
426
  } catch (e) {
@@ -435,8 +435,8 @@ function requireNative() {
435
435
  try {
436
436
  const binding = require('@responsibleai/agent-hooks-linux-riscv64-gnu')
437
437
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-riscv64-gnu/package.json').version
438
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
439
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
438
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
439
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
440
440
  }
441
441
  return binding
442
442
  } catch (e) {
@@ -452,8 +452,8 @@ function requireNative() {
452
452
  try {
453
453
  const binding = require('@responsibleai/agent-hooks-linux-ppc64-gnu')
454
454
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-ppc64-gnu/package.json').version
455
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
456
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
455
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
456
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
457
457
  }
458
458
  return binding
459
459
  } catch (e) {
@@ -468,8 +468,8 @@ function requireNative() {
468
468
  try {
469
469
  const binding = require('@responsibleai/agent-hooks-linux-s390x-gnu')
470
470
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-s390x-gnu/package.json').version
471
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
472
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
471
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
472
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
473
473
  }
474
474
  return binding
475
475
  } catch (e) {
@@ -488,8 +488,8 @@ function requireNative() {
488
488
  try {
489
489
  const binding = require('@responsibleai/agent-hooks-openharmony-arm64')
490
490
  const bindingPackageVersion = require('@responsibleai/agent-hooks-openharmony-arm64/package.json').version
491
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
492
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
491
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
492
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
493
493
  }
494
494
  return binding
495
495
  } catch (e) {
@@ -504,8 +504,8 @@ function requireNative() {
504
504
  try {
505
505
  const binding = require('@responsibleai/agent-hooks-openharmony-x64')
506
506
  const bindingPackageVersion = require('@responsibleai/agent-hooks-openharmony-x64/package.json').version
507
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
508
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
507
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
508
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
509
509
  }
510
510
  return binding
511
511
  } catch (e) {
@@ -520,8 +520,8 @@ function requireNative() {
520
520
  try {
521
521
  const binding = require('@responsibleai/agent-hooks-openharmony-arm')
522
522
  const bindingPackageVersion = require('@responsibleai/agent-hooks-openharmony-arm/package.json').version
523
- if (bindingPackageVersion !== '0.1.0-beta.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
524
- throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
523
+ if (bindingPackageVersion !== '0.1.0-beta.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
524
+ throw new Error(`Native binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
525
525
  }
526
526
  return binding
527
527
  } catch (e) {
@@ -661,8 +661,8 @@ if (!nativeBinding || forceWasi) {
661
661
  if (!candidateFailed) {
662
662
  if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
663
663
  const bindingPackageVersion = require('@responsibleai/agent-hooks-wasm32-wasi/package.json').version
664
- if (bindingPackageVersion !== '0.1.0-beta.1') {
665
- throw new Error(`WASI binding package version mismatch, expected 0.1.0-beta.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
664
+ if (bindingPackageVersion !== '0.1.0-beta.3') {
665
+ throw new Error(`WASI binding package version mismatch, expected 0.1.0-beta.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
666
666
  }
667
667
  }
668
668
  wasiBinding = require('@responsibleai/agent-hooks-wasm32-wasi')
@@ -787,7 +787,12 @@ module.exports.ctkAssert = nativeBinding.ctkAssert
787
787
  module.exports.ctkScriptedIntercept = nativeBinding.ctkScriptedIntercept
788
788
  module.exports.ctkScriptedResolve = nativeBinding.ctkScriptedResolve
789
789
  module.exports.ctkShouldSkip = nativeBinding.ctkShouldSkip
790
+ module.exports.declarationResolve = nativeBinding.declarationResolve
791
+ module.exports.declarationResolveSurface = nativeBinding.declarationResolveSurface
792
+ module.exports.declarationValidate = nativeBinding.declarationValidate
793
+ module.exports.declarationVersions = nativeBinding.declarationVersions
790
794
  module.exports.finalize = nativeBinding.finalize
795
+ module.exports.normalizeInterceptorResponse = nativeBinding.normalizeInterceptorResponse
791
796
  module.exports.specVersion = nativeBinding.specVersion
792
797
  module.exports.validateEnvelope = nativeBinding.validateEnvelope
793
798
  module.exports.validateTransformCtx = nativeBinding.validateTransformCtx
package/dist/builder.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
2
+ // Copyright (c) Microsoft. All rights reserved.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.AgentContextBuilder = void 0;
4
5
  /**
5
6
  * `AgentContext` construction (§4).
6
7
  *
@@ -8,8 +9,6 @@
8
9
  * (agent/session/sequence) and exposes one method per interception
9
10
  * point that fills L1 and sets `target`.
10
11
  */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.AgentContextBuilder = void 0;
13
12
  const index_1 = require("./index");
14
13
  function now() {
15
14
  return new Date().toISOString();
@@ -5,11 +5,14 @@
5
5
  * Rust core; this module defines the `Harness` interface framework
6
6
  * adapters implement, plus the runner and reference harness that use it.
7
7
  */
8
- import type { ApprovalResolver, CompositionConfig, EnforcementMode, Interceptor, JsonValue } from "../index";
9
- export { loadVectors, runVector, runVectors, VectorResult } from "./runner";
10
- export { ReferenceHarness } from "./reference";
11
- /** Host-declared capability subset (§3.2). */
12
- export type Capability = "model_calls" | "tool_calls" | "parallel_tool_calls" | "streaming" | "multi_turn";
8
+ import type { ApprovalResolver, CompositionConfig, EnforcementMode, HostRegistry, HostSurface, Interceptor, JsonValue } from "../index";
9
+ export { assessHarness, loadVectors, runVector, runVectors, VectorResult, builderFromValue, provePaths, } from "./runner";
10
+ export type { AssessedSurface } from "./runner";
11
+ export { ReferenceHarness, REFERENCE_DECLARATION } from "./reference";
12
+ /** Host-declared capability subset (§3.2, §13.1): the closed list of
13
+ * `conformance/vectors.schema.json` with `host_declaration` (§7.7.9).
14
+ * `buffered_output` is a value, not a presence, and is not listed. */
15
+ export type Capability = "model_calls" | "tool_calls" | "parallel_tool_calls" | "streaming" | "multi_turn" | "int64_json" | "bigint_json" | "incremental_output" | "host_declaration";
13
16
  export type RunOutcome = "completed" | "blocked" | "suspended" | "error";
14
17
  /** Hermetic scripted run loaded from a CTK vector (wire-shaped). */
15
18
  export interface Scenario {
@@ -38,6 +41,17 @@ export interface Scenario {
38
41
  };
39
42
  }>;
40
43
  }
44
+ /** What loading the vector's host declaration produced (§7.7.9), as
45
+ * the runner records it. */
46
+ export interface LoadRecord {
47
+ outcome: "accepted" | "refused";
48
+ /** The `declaration_error:*` code on refusal. */
49
+ class?: string;
50
+ /** Whether the value, JSON, file and builder paths resolved to one
51
+ * canonical form (or refused with one class). */
52
+ paths_equivalent?: boolean;
53
+ detail?: string;
54
+ }
41
55
  /** What `Harness.run` returns to the CTK runner. */
42
56
  export interface RunRecord {
43
57
  outcome: RunOutcome;
@@ -54,6 +68,9 @@ export interface RunRecord {
54
68
  /** Wire-shaped `InterceptionRecord`s (§10.3), one per emission, in
55
69
  * order. Enables `expect.records` assertions. */
56
70
  records: JsonValue[];
71
+ /** Set by the runner for vectors carrying `host_declaration`
72
+ * (§7.7.9); a harness never fills it. */
73
+ load?: LoadRecord;
57
74
  }
58
75
  /** The single interface a framework adapter implements for the CTK. */
59
76
  export interface Harness {
@@ -81,4 +98,26 @@ export interface Harness {
81
98
  setup(scenario: Scenario, interceptors: Interceptor[], resolver: ApprovalResolver | null, mode: EnforcementMode, composition: CompositionConfig, identityProvider: 'jcs-sha256' | 'ctk-fault' | null, redactForApproval?: string[]): void;
82
99
  run(): Promise<RunRecord>;
83
100
  teardown(): void;
101
+ /** The code surface (§7.7.4) a declaration is resolved against. When
102
+ * absent the runner derives it from `capabilities` and
103
+ * `toolSeamHostError` (`HostSurface.fromCapabilities`): the §3.2
104
+ * floor plus the model points iff `model_calls` plus the tool points
105
+ * iff `tool_calls`, every profile with every knob value. A host
106
+ * declaring `incremental_output` implements this to add its exposure
107
+ * bound; the derived surface alone is refused for such a host. */
108
+ hostSurface?(): HostSurface;
109
+ /** The host's own declaration document (§7.7.9), when it has one.
110
+ * The runner resolves it against the code surface and reads the
111
+ * capabilities and posture a run is assessed against from the
112
+ * resolved form, so what the CTK ran against is what a claim cites.
113
+ * Absent keeps the code-declared surface. */
114
+ declaration?(): JsonValue | undefined;
115
+ /** Wire one declaration vector (§7.7.9): the harness MUST build its
116
+ * emitter from `document` and `registry` through the loader
117
+ * (`InterceptionEmitter.fromDeclarationValue`) and let the
118
+ * `DeclarationError` propagate, never fall back to the field-based
119
+ * `setup`. The document and the registry carry the interceptors,
120
+ * resolver, composition and identity provider. Only harnesses
121
+ * declaring the `host_declaration` capability receive this call. */
122
+ setupDeclared?(scenario: Scenario, document: JsonValue, registry: HostRegistry): void;
84
123
  }
package/dist/ctk/index.js CHANGED
@@ -1,18 +1,14 @@
1
1
  "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
4
- /**
5
- * Conformance Test Kit (§13.2).
6
- *
7
- * The assertion engine and scripted interceptor/resolver live in the
8
- * Rust core; this module defines the `Harness` interface framework
9
- * adapters implement, plus the runner and reference harness that use it.
10
- */
2
+ // Copyright (c) Microsoft. All rights reserved.
11
3
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ReferenceHarness = exports.runVectors = exports.runVector = exports.loadVectors = void 0;
4
+ exports.REFERENCE_DECLARATION = exports.ReferenceHarness = exports.provePaths = exports.builderFromValue = exports.runVectors = exports.runVector = exports.loadVectors = exports.assessHarness = void 0;
13
5
  var runner_1 = require("./runner");
6
+ Object.defineProperty(exports, "assessHarness", { enumerable: true, get: function () { return runner_1.assessHarness; } });
14
7
  Object.defineProperty(exports, "loadVectors", { enumerable: true, get: function () { return runner_1.loadVectors; } });
15
8
  Object.defineProperty(exports, "runVector", { enumerable: true, get: function () { return runner_1.runVector; } });
16
9
  Object.defineProperty(exports, "runVectors", { enumerable: true, get: function () { return runner_1.runVectors; } });
10
+ Object.defineProperty(exports, "builderFromValue", { enumerable: true, get: function () { return runner_1.builderFromValue; } });
11
+ Object.defineProperty(exports, "provePaths", { enumerable: true, get: function () { return runner_1.provePaths; } });
17
12
  var reference_1 = require("./reference");
18
13
  Object.defineProperty(exports, "ReferenceHarness", { enumerable: true, get: function () { return reference_1.ReferenceHarness; } });
14
+ Object.defineProperty(exports, "REFERENCE_DECLARATION", { enumerable: true, get: function () { return reference_1.REFERENCE_DECLARATION; } });
@@ -1,12 +1,8 @@
1
- /**
2
- * Reference in-memory agent + harness.
3
- *
4
- * The simplest possible conformant agent loop; exists so the
5
- * CTK can self-test without a real framework. Port of
6
- * `sdk/python/python/agent_hooks/ctk/reference.py`.
7
- */
8
- import { ApprovalResolver, CompositionConfig, EnforcementMode, Interceptor } from "../index";
1
+ import { ApprovalResolver, CompositionConfig, EnforcementMode, HostRegistry, HostSurface, Interceptor, JsonValue } from "../index";
9
2
  import type { Capability, Harness, RunRecord, Scenario } from "./index";
3
+ /** The reference harness's own declaration (§7.7.9), with an explicit
4
+ * surface a claim can cite. */
5
+ export declare const REFERENCE_DECLARATION: Readonly<Record<string, JsonValue>>;
10
6
  export declare class ReferenceHarness implements Harness {
11
7
  readonly name = "reference-agent";
12
8
  readonly capabilities: ReadonlySet<Capability>;
@@ -14,7 +10,11 @@ export declare class ReferenceHarness implements Harness {
14
10
  private emitter;
15
11
  private builder;
16
12
  private toolLog;
13
+ hostSurface(): HostSurface;
14
+ declaration(): JsonValue;
15
+ private startSession;
17
16
  setup(scenario: Scenario, interceptors: Interceptor[], resolver: ApprovalResolver | null, mode: EnforcementMode, composition: CompositionConfig, identityProvider: 'jcs-sha256' | 'ctk-fault' | null, redactForApproval?: string[]): void;
17
+ setupDeclared(scenario: Scenario, document: JsonValue, registry: HostRegistry): void;
18
18
  run(): Promise<RunRecord>;
19
19
  teardown(): void;
20
20
  }