@responsibleai/agent-hooks 0.1.0-alpha.5 → 0.1.0-beta.1

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
@@ -15,11 +15,15 @@ identity-provider seam, and the CTK runner.
15
15
  > before relying on it.
16
16
 
17
17
  ```bash
18
- # Not yet published to npm — install from source:
19
- git clone https://github.com/responsibleai/agent-hooks && cd agent-hooks/sdk/typescript
20
- npm install && npm run build # builds the native module (needs a Rust toolchain)
18
+ npm install @responsibleai/agent-hooks@alpha
21
19
  ```
22
20
 
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
25
+ `npm view @responsibleai/agent-hooks dist-tags`.
26
+
23
27
  ## Usage
24
28
 
25
29
  ```ts
package/binding.d.ts CHANGED
@@ -1,5 +1,14 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
+
4
+ /**
5
+ * Which binding artifact the generated loader actually loaded: `'native'` for
6
+ * a native addon, otherwise the `platformArchABI` of the WASI flavor. Every
7
+ * flavor napi-rs can build is listed, because `NAPI_RS_NATIVE_LIBRARY_PATH`
8
+ * can point the loader at a WASI artifact this package does not build itself.
9
+ */
10
+ export declare const __napiBindingTarget: 'native' | 'wasm32-wasi' | 'wasm32-wasip1'
11
+
3
12
  export declare function applyTransform(targetJson: string, path: string, valueJson: string): string
4
13
 
5
14
  export declare function applyTransformCtx(ctxJson: string, path: string, valueJson: string): string
package/binding.js CHANGED
@@ -1,10 +1,13 @@
1
- // prettier-ignore
2
1
  /* eslint-disable */
3
2
  // @ts-nocheck
4
3
  /* auto-generated by NAPI-RS */
5
4
 
6
5
  const { readFileSync } = require('fs')
7
6
  let nativeBinding = null
7
+ // Which artifact actually loaded. The WASI fallback chain overwrites it with
8
+ // the flavor it resolved; the late native retry below leaves it alone because
9
+ // it only runs while no WASI candidate has been loaded.
10
+ let __napiLoadedBindingTarget = 'native'
8
11
  const loadErrors = []
9
12
 
10
13
  const isMusl = () => {
@@ -63,7 +66,16 @@ const isMuslFromChildProcess = () => {
63
66
  function requireNative() {
64
67
  if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
65
68
  try {
66
- return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
69
+ const overrideBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH)
70
+ // The override may be a generated WASI loader, which already reports its
71
+ // own flavor. Adopt it: `module.exports` aliases this object, so claiming
72
+ // 'native' would both misreport the artifact and overwrite the loader's
73
+ // marker through the alias.
74
+ __napiLoadedBindingTarget =
75
+ overrideBinding && typeof overrideBinding.__napiBindingTarget === 'string'
76
+ ? overrideBinding.__napiBindingTarget
77
+ : 'native'
78
+ return overrideBinding
67
79
  } catch (err) {
68
80
  loadErrors.push(err)
69
81
  }
@@ -77,8 +89,8 @@ function requireNative() {
77
89
  try {
78
90
  const binding = require('@responsibleai/agent-hooks-android-arm64')
79
91
  const bindingPackageVersion = require('@responsibleai/agent-hooks-android-arm64/package.json').version
80
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
82
94
  }
83
95
  return binding
84
96
  } catch (e) {
@@ -93,8 +105,8 @@ function requireNative() {
93
105
  try {
94
106
  const binding = require('@responsibleai/agent-hooks-android-arm-eabi')
95
107
  const bindingPackageVersion = require('@responsibleai/agent-hooks-android-arm-eabi/package.json').version
96
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
98
110
  }
99
111
  return binding
100
112
  } catch (e) {
@@ -107,36 +119,36 @@ function requireNative() {
107
119
  if (process.arch === 'x64') {
108
120
  if ((process.config && process.config.variables && process.config.variables.shlib_suffix === 'dll.a') || (process.config && process.config.variables && process.config.variables.node_target_type === 'shared_library')) {
109
121
  try {
110
- return require('./agent-hooks.win32-x64-gnu.node')
111
- } catch (e) {
112
- loadErrors.push(e)
113
- }
114
- try {
115
- const binding = require('@responsibleai/agent-hooks-win32-x64-gnu')
116
- const bindingPackageVersion = require('@responsibleai/agent-hooks-win32-x64-gnu/package.json').version
117
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
122
+ return require('./agent-hooks.win32-x64-gnu.node')
123
+ } catch (e) {
124
+ loadErrors.push(e)
125
+ }
126
+ try {
127
+ const binding = require('@responsibleai/agent-hooks-win32-x64-gnu')
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.`)
131
+ }
132
+ return binding
133
+ } catch (e) {
134
+ loadErrors.push(e)
119
135
  }
120
- return binding
121
- } catch (e) {
122
- loadErrors.push(e)
123
- }
124
136
  } else {
125
137
  try {
126
- return require('./agent-hooks.win32-x64-msvc.node')
127
- } catch (e) {
128
- loadErrors.push(e)
129
- }
130
- try {
131
- const binding = require('@responsibleai/agent-hooks-win32-x64-msvc')
132
- const bindingPackageVersion = require('@responsibleai/agent-hooks-win32-x64-msvc/package.json').version
133
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
138
+ return require('./agent-hooks.win32-x64-msvc.node')
139
+ } catch (e) {
140
+ loadErrors.push(e)
141
+ }
142
+ try {
143
+ const binding = require('@responsibleai/agent-hooks-win32-x64-msvc')
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.`)
147
+ }
148
+ return binding
149
+ } catch (e) {
150
+ loadErrors.push(e)
135
151
  }
136
- return binding
137
- } catch (e) {
138
- loadErrors.push(e)
139
- }
140
152
  }
141
153
  } else if (process.arch === 'ia32') {
142
154
  try {
@@ -147,8 +159,8 @@ function requireNative() {
147
159
  try {
148
160
  const binding = require('@responsibleai/agent-hooks-win32-ia32-msvc')
149
161
  const bindingPackageVersion = require('@responsibleai/agent-hooks-win32-ia32-msvc/package.json').version
150
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
152
164
  }
153
165
  return binding
154
166
  } catch (e) {
@@ -163,8 +175,8 @@ function requireNative() {
163
175
  try {
164
176
  const binding = require('@responsibleai/agent-hooks-win32-arm64-msvc')
165
177
  const bindingPackageVersion = require('@responsibleai/agent-hooks-win32-arm64-msvc/package.json').version
166
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
168
180
  }
169
181
  return binding
170
182
  } catch (e) {
@@ -182,8 +194,8 @@ function requireNative() {
182
194
  try {
183
195
  const binding = require('@responsibleai/agent-hooks-darwin-universal')
184
196
  const bindingPackageVersion = require('@responsibleai/agent-hooks-darwin-universal/package.json').version
185
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
187
199
  }
188
200
  return binding
189
201
  } catch (e) {
@@ -198,8 +210,8 @@ function requireNative() {
198
210
  try {
199
211
  const binding = require('@responsibleai/agent-hooks-darwin-x64')
200
212
  const bindingPackageVersion = require('@responsibleai/agent-hooks-darwin-x64/package.json').version
201
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
203
215
  }
204
216
  return binding
205
217
  } catch (e) {
@@ -214,8 +226,8 @@ function requireNative() {
214
226
  try {
215
227
  const binding = require('@responsibleai/agent-hooks-darwin-arm64')
216
228
  const bindingPackageVersion = require('@responsibleai/agent-hooks-darwin-arm64/package.json').version
217
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
219
231
  }
220
232
  return binding
221
233
  } catch (e) {
@@ -234,8 +246,8 @@ function requireNative() {
234
246
  try {
235
247
  const binding = require('@responsibleai/agent-hooks-freebsd-x64')
236
248
  const bindingPackageVersion = require('@responsibleai/agent-hooks-freebsd-x64/package.json').version
237
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
239
251
  }
240
252
  return binding
241
253
  } catch (e) {
@@ -250,8 +262,8 @@ function requireNative() {
250
262
  try {
251
263
  const binding = require('@responsibleai/agent-hooks-freebsd-arm64')
252
264
  const bindingPackageVersion = require('@responsibleai/agent-hooks-freebsd-arm64/package.json').version
253
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
255
267
  }
256
268
  return binding
257
269
  } catch (e) {
@@ -271,8 +283,8 @@ function requireNative() {
271
283
  try {
272
284
  const binding = require('@responsibleai/agent-hooks-linux-x64-musl')
273
285
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-x64-musl/package.json').version
274
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
276
288
  }
277
289
  return binding
278
290
  } catch (e) {
@@ -287,8 +299,8 @@ function requireNative() {
287
299
  try {
288
300
  const binding = require('@responsibleai/agent-hooks-linux-x64-gnu')
289
301
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-x64-gnu/package.json').version
290
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
292
304
  }
293
305
  return binding
294
306
  } catch (e) {
@@ -305,8 +317,8 @@ function requireNative() {
305
317
  try {
306
318
  const binding = require('@responsibleai/agent-hooks-linux-arm64-musl')
307
319
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-arm64-musl/package.json').version
308
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
310
322
  }
311
323
  return binding
312
324
  } catch (e) {
@@ -321,8 +333,8 @@ function requireNative() {
321
333
  try {
322
334
  const binding = require('@responsibleai/agent-hooks-linux-arm64-gnu')
323
335
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-arm64-gnu/package.json').version
324
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
326
338
  }
327
339
  return binding
328
340
  } catch (e) {
@@ -339,8 +351,8 @@ function requireNative() {
339
351
  try {
340
352
  const binding = require('@responsibleai/agent-hooks-linux-arm-musleabihf')
341
353
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-arm-musleabihf/package.json').version
342
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
344
356
  }
345
357
  return binding
346
358
  } catch (e) {
@@ -355,8 +367,8 @@ function requireNative() {
355
367
  try {
356
368
  const binding = require('@responsibleai/agent-hooks-linux-arm-gnueabihf')
357
369
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-arm-gnueabihf/package.json').version
358
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
360
372
  }
361
373
  return binding
362
374
  } catch (e) {
@@ -373,8 +385,8 @@ function requireNative() {
373
385
  try {
374
386
  const binding = require('@responsibleai/agent-hooks-linux-loong64-musl')
375
387
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-loong64-musl/package.json').version
376
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
378
390
  }
379
391
  return binding
380
392
  } catch (e) {
@@ -389,8 +401,8 @@ function requireNative() {
389
401
  try {
390
402
  const binding = require('@responsibleai/agent-hooks-linux-loong64-gnu')
391
403
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-loong64-gnu/package.json').version
392
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
394
406
  }
395
407
  return binding
396
408
  } catch (e) {
@@ -407,8 +419,8 @@ function requireNative() {
407
419
  try {
408
420
  const binding = require('@responsibleai/agent-hooks-linux-riscv64-musl')
409
421
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-riscv64-musl/package.json').version
410
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
412
424
  }
413
425
  return binding
414
426
  } catch (e) {
@@ -423,8 +435,8 @@ function requireNative() {
423
435
  try {
424
436
  const binding = require('@responsibleai/agent-hooks-linux-riscv64-gnu')
425
437
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-riscv64-gnu/package.json').version
426
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
428
440
  }
429
441
  return binding
430
442
  } catch (e) {
@@ -440,8 +452,8 @@ function requireNative() {
440
452
  try {
441
453
  const binding = require('@responsibleai/agent-hooks-linux-ppc64-gnu')
442
454
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-ppc64-gnu/package.json').version
443
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
445
457
  }
446
458
  return binding
447
459
  } catch (e) {
@@ -456,8 +468,8 @@ function requireNative() {
456
468
  try {
457
469
  const binding = require('@responsibleai/agent-hooks-linux-s390x-gnu')
458
470
  const bindingPackageVersion = require('@responsibleai/agent-hooks-linux-s390x-gnu/package.json').version
459
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
461
473
  }
462
474
  return binding
463
475
  } catch (e) {
@@ -476,8 +488,8 @@ function requireNative() {
476
488
  try {
477
489
  const binding = require('@responsibleai/agent-hooks-openharmony-arm64')
478
490
  const bindingPackageVersion = require('@responsibleai/agent-hooks-openharmony-arm64/package.json').version
479
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
481
493
  }
482
494
  return binding
483
495
  } catch (e) {
@@ -492,8 +504,8 @@ function requireNative() {
492
504
  try {
493
505
  const binding = require('@responsibleai/agent-hooks-openharmony-x64')
494
506
  const bindingPackageVersion = require('@responsibleai/agent-hooks-openharmony-x64/package.json').version
495
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
497
509
  }
498
510
  return binding
499
511
  } catch (e) {
@@ -508,8 +520,8 @@ function requireNative() {
508
520
  try {
509
521
  const binding = require('@responsibleai/agent-hooks-openharmony-arm')
510
522
  const bindingPackageVersion = require('@responsibleai/agent-hooks-openharmony-arm/package.json').version
511
- if (bindingPackageVersion !== '0.1.0-alpha.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
- throw new Error(`Native binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
513
525
  }
514
526
  return binding
515
527
  } catch (e) {
@@ -550,7 +562,7 @@ function createLoadErrorChain(errors) {
550
562
  //
551
563
  // NAPI_RS_WASI_FLAVOR selects one exact generated flavor and implies strict
552
564
  // WASI loading. It never crosses into another flavor or falls back to native.
553
- const __napiWasiFlavors = ["wasm32-wasi"]
565
+ const __napiWasiFlavors = ['wasm32-wasi']
554
566
  const __napiWasiFlavor = process.env.NAPI_RS_WASI_FLAVOR
555
567
  const __napiWasiFlavorRequested =
556
568
  typeof __napiWasiFlavor === 'string' && __napiWasiFlavor.length > 0
@@ -619,15 +631,16 @@ if (!nativeBinding || forceWasi) {
619
631
  }
620
632
  return null
621
633
  }
622
- if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")) {
634
+ if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === 'wasm32-wasi')) {
623
635
  let candidateError = null
624
636
  let candidateFailed = false
625
637
  try {
626
- candidateError = __napiWasiResolveCandidate('./agent-hooks.wasi.cjs', false, ["./agent-hooks.wasm32-wasi.debug.wasm","./agent-hooks.wasm32-wasi.wasm"])
638
+ candidateError = __napiWasiResolveCandidate('./agent-hooks.wasi.cjs', false, ['./agent-hooks.wasm32-wasi.debug.wasm', './agent-hooks.wasm32-wasi.wasm'])
627
639
  candidateFailed = candidateError !== null
628
640
  if (!candidateFailed) {
629
641
  wasiBinding = require('./agent-hooks.wasi.cjs')
630
642
  nativeBinding = wasiBinding
643
+ __napiLoadedBindingTarget = 'wasm32-wasi'
631
644
  wasiBindingLoaded = true
632
645
  }
633
646
  } catch (err) {
@@ -639,7 +652,7 @@ if (!nativeBinding || forceWasi) {
639
652
  loadErrors.push(candidateError)
640
653
  }
641
654
  }
642
- if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")) {
655
+ if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === 'wasm32-wasi')) {
643
656
  let candidateError = null
644
657
  let candidateFailed = false
645
658
  try {
@@ -648,12 +661,13 @@ if (!nativeBinding || forceWasi) {
648
661
  if (!candidateFailed) {
649
662
  if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
650
663
  const bindingPackageVersion = require('@responsibleai/agent-hooks-wasm32-wasi/package.json').version
651
- if (bindingPackageVersion !== '0.1.0-alpha.5') {
652
- throw new Error(`WASI binding package version mismatch, expected 0.1.0-alpha.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
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.`)
653
666
  }
654
667
  }
655
668
  wasiBinding = require('@responsibleai/agent-hooks-wasm32-wasi')
656
669
  nativeBinding = wasiBinding
670
+ __napiLoadedBindingTarget = 'wasm32-wasi'
657
671
  wasiBindingLoaded = true
658
672
  }
659
673
  } catch (err) {
@@ -699,6 +713,70 @@ if (!nativeBinding) {
699
713
  throw new Error(`Failed to load native binding`)
700
714
  }
701
715
 
716
+ function __napiStampBindingTarget(exportsObject, target) {
717
+ if (
718
+ Object.prototype.hasOwnProperty.call(exportsObject, '__napiBindingTarget')
719
+ ) {
720
+ if (exportsObject.__napiBindingTarget === target) {
721
+ // Already ours: the root entry aliases the object it loaded, so a WASI
722
+ // fallback candidate — or a `NAPI_RS_NATIVE_LIBRARY_PATH` override that
723
+ // is a generated loader — arrives already stamped with this same value.
724
+ return target
725
+ }
726
+ const error = new Error(
727
+ '`__napiBindingTarget` is reserved by the generated binding loader, but the loaded binding already exports it. Rename the export, e.g. #[napi(js_name = "...")].',
728
+ )
729
+ error.code = 'ERR_NAPI_BINDING_TARGET_CONFLICT'
730
+ throw error
731
+ }
732
+ if (!Object.isExtensible(exportsObject)) {
733
+ // A `#[napi(module_exports)]` hook may seal or freeze this object
734
+ // (`Object::seal` / `Object::freeze`). Reporting the artifact is metadata,
735
+ // never a reason to fail an otherwise successful load, so the stamp is
736
+ // skipped. What a consumer still sees then follows the entry point: the
737
+ // browser and deferred loaders declare `__napiBindingTarget` at module
738
+ // level and go on reporting it, while the CommonJS entries hand back this
739
+ // very object as `module.exports`, so there the value is absent.
740
+ return target
741
+ }
742
+ try {
743
+ // [[Define]], not [[Set]]: an ordinary assignment walks the prototype
744
+ // chain, so an inherited accessor could swallow the value or throw and
745
+ // fail an otherwise successful load. The descriptor is what a successful
746
+ // assignment would have produced.
747
+ Object.defineProperty(exportsObject, '__napiBindingTarget', {
748
+ configurable: true,
749
+ enumerable: true,
750
+ value: target,
751
+ writable: true,
752
+ })
753
+ } catch {
754
+ // Same rule as the non-extensible skip above: reporting the artifact is
755
+ // metadata, never a reason to fail an otherwise successful load. An exotic
756
+ // object (a Proxy whose defineProperty trap refuses) is skipped, not
757
+ // thrown over.
758
+ }
759
+ // The CommonJS loaders assign this return value so `cjs-module-lexer` — and
760
+ // therefore Node's CJS -> ESM named export detection — can see
761
+ // `__napiBindingTarget` statically.
762
+ return target
763
+ }
764
+ // Stamp before the alias, not after. The guard only reads `nativeBinding`
765
+ // (`hasOwnProperty` plus a comparison), which is safe against any addon
766
+ // accessor; an assignment is not, because a `#[napi(module_exports)]` hook can
767
+ // expose a getter reporting this very value and a setter that throws. So the
768
+ // assignment lands on the loader's own `module.exports`, still the original
769
+ // object here, and the alias below replaces it.
770
+ //
771
+ // The assignment is what keeps the marker a statically visible CommonJS export:
772
+ // `cjs-module-lexer` is Node's CJS -> ESM named export detection, it cannot see
773
+ // a bare call, and the later `module.exports = nativeBinding` does not undo the
774
+ // detection. The assignment itself always succeeds — its target is this
775
+ // loader's own, still extensible `module.exports` — and the alias below then
776
+ // discards the value it wrote. What a consumer reads is whatever the guard put
777
+ // on `nativeBinding`, so on a frozen binding, where the guard skips, the
778
+ // linked import resolves to `undefined`.
779
+ module.exports.__napiBindingTarget = __napiStampBindingTarget(nativeBinding, __napiLoadedBindingTarget)
702
780
  module.exports = nativeBinding
703
781
  module.exports.applyTransform = nativeBinding.applyTransform
704
782
  module.exports.applyTransformCtx = nativeBinding.applyTransformCtx
@@ -59,6 +59,15 @@ export interface RunRecord {
59
59
  export interface Harness {
60
60
  readonly name: string;
61
61
  readonly capabilities: ReadonlySet<Capability>;
62
+ /** Declared §6.2 posture at the tool seam (§13.1): what the host does
63
+ * with the run after a `host_error:*` deny at
64
+ * `pre_tool_call`/`post_tool_call`. `"continue"` (the default —
65
+ * surface a tool error to the model and keep the loop going) or
66
+ * `"terminate"` (the host's own semantics terminate the turn, which
67
+ * §6.2 explicitly permits). The runner forwards this declaration so
68
+ * `expect.run_outcome_by_posture` vectors resolve to the single
69
+ * outcome this surface must produce. */
70
+ readonly toolSeamHostError?: "continue" | "terminate";
62
71
  /** Wire the scenario's mock model + tools into the framework,
63
72
  * register the interceptors and resolver, set the enforcement mode,
64
73
  * the vector's composition profile (§7.1), and its identity provider
@@ -83,7 +83,7 @@ class ScriptedResolver {
83
83
  return r;
84
84
  }
85
85
  }
86
- function runRecordToWire(rr) {
86
+ function runRecordToWire(rr, postures) {
87
87
  return JSON.stringify({
88
88
  outcome: rr.outcome,
89
89
  final_output: rr.final_output ?? null,
@@ -91,6 +91,9 @@ function runRecordToWire(rr) {
91
91
  error: rr.error ?? null,
92
92
  identities: rr.identities.map(([i, e]) => ({ input_identity: i, enforced_identity: e })),
93
93
  records: rr.records,
94
+ // Harness *declarations* (§13.1), not observed behavior: the engine
95
+ // selects expect.run_outcome_by_posture entries by them.
96
+ postures,
94
97
  });
95
98
  }
96
99
  async function runVector(harness, vector) {
@@ -147,7 +150,9 @@ async function runVector(harness, vector) {
147
150
  finally {
148
151
  harness.teardown();
149
152
  }
150
- return JSON.parse(native_1.native.ctkAssert(vectorJson, JSON.stringify(first?.recorded ?? []), runRecordToWire(rr)));
153
+ // §13.1 posture declaration; absent means the spec default.
154
+ const postures = { tool_seam_host_error: harness.toolSeamHostError ?? "continue" };
155
+ return JSON.parse(native_1.native.ctkAssert(vectorJson, JSON.stringify(first?.recorded ?? []), runRecordToWire(rr, postures)));
151
156
  }
152
157
  async function runVectors(harnessFactory, vectors) {
153
158
  const out = [];
package/dist/emitter.d.ts CHANGED
@@ -27,9 +27,29 @@
27
27
  * on the event loop; sequence assignment and record append are atomic on
28
28
  * a single JS thread. Sharing one emitter across workers is unsupported.
29
29
  */
30
- import { AgentContext, ApprovalResolver, CompositionConfig, EnforcementMode, IdentityProvider, EmitOutcome, InterceptionRecord, Interceptor } from "./index";
30
+ import { AgentContext, ApprovalResolver, CompositionConfig, EnforcementMode, IdentityProvider, EmitOutcome, InterceptionPoint, InterceptionRecord, Interceptor } from "./index";
31
31
  /** §7 RECOMMENDED interceptor/resolver timeout (milliseconds). */
32
32
  export declare const DEFAULT_TIMEOUT_MS = 5000;
33
+ /** Envelope facts for {@link InterceptionEmitter.recordHostFailure}:
34
+ * what the host still knows about an emission whose context it could
35
+ * not construct (§10.3 "Host projection failure"). Everything is
36
+ * optional — an absent member records the §10.3 unknown value
37
+ * (`session_id: ""`, `sequence: -1`, `timestamp` absent). */
38
+ export interface HostFailure {
39
+ /** Payload-free failure detail — an exception **type name** or a
40
+ * path, never the content that failed to project (§14 data
41
+ * minimization). Recorded as the verdict `message` (truncated by
42
+ * the §10.3 projection). */
43
+ detail?: string;
44
+ /** `session.id` of the failed emission, when the host knows it. */
45
+ session_id?: string;
46
+ /** The sequence number the failed emission would have carried. The
47
+ * host SHOULD consume the next number from its context source so
48
+ * records stay totally ordered within the session (§10.3). */
49
+ sequence?: number;
50
+ /** RFC 3339 event time, when the host has one. */
51
+ timestamp?: string;
52
+ }
33
53
  export declare class InterceptionEmitter {
34
54
  private readonly mode;
35
55
  private readonly resolver;
@@ -110,6 +130,28 @@ export declare class InterceptionEmitter {
110
130
  * caller MUST inspect `proceeds` and halt the guarded action itself;
111
131
  * prefer {@link emit}. */
112
132
  emitUnchecked(ctx: AgentContext): Promise<InterceptionRecord>;
133
+ /** §10.3/§11 host projection failure: synthesize and deliver the
134
+ * fail-closed record for an emission whose `AgentContext` the host
135
+ * could not construct at all — its own projection to the wire failed
136
+ * before anything existed to {@link emit} (e.g. a tool-call argument
137
+ * getter threw during to-wire conversion at the chat seam). Without
138
+ * this the host can only fail the action closed *recordless*; with
139
+ * it the trail stays complete under host-side faults.
140
+ *
141
+ * The record is the §10.3 rejection shape: the payload-free
142
+ * projection of a `deny host_error:context_invalid` carrying
143
+ * `failure.detail` (payload-free: a type name or path, never
144
+ * content) as its message; `null` identities under the declared
145
+ * provider; `decided_by: null`; no per-interceptor summaries (no
146
+ * interceptor ran); envelope members from {@link HostFailure}, with
147
+ * the §10.3 unknown values (`""`/`-1`) where absent. It takes the
148
+ * next slot in the record stream (sink, then buffer) like any
149
+ * emission. In `enforce` mode the host MUST still fail the action
150
+ * closed; in `evaluate_only` the record documents the host fault
151
+ * without implying enforcement (§8). */
152
+ recordHostFailure(point: InterceptionPoint, failure?: HostFailure): InterceptionRecord;
153
+ /** Deliver a record to the sink and the bounded buffer (§10.3). */
154
+ private deliver;
113
155
  /** Profile dispatch (§7.4–§7.5). Returns the combined verdict and
114
156
  * its record metadata. */
115
157
  private dispatch;
package/dist/emitter.js CHANGED
@@ -320,6 +320,57 @@ class InterceptionEmitter {
320
320
  else {
321
321
  record = (0, index_1.finalize)(ctx, outcome.combined, this.mode, meta);
322
322
  }
323
+ return this.deliver(record);
324
+ }
325
+ /** §10.3/§11 host projection failure: synthesize and deliver the
326
+ * fail-closed record for an emission whose `AgentContext` the host
327
+ * could not construct at all — its own projection to the wire failed
328
+ * before anything existed to {@link emit} (e.g. a tool-call argument
329
+ * getter threw during to-wire conversion at the chat seam). Without
330
+ * this the host can only fail the action closed *recordless*; with
331
+ * it the trail stays complete under host-side faults.
332
+ *
333
+ * The record is the §10.3 rejection shape: the payload-free
334
+ * projection of a `deny host_error:context_invalid` carrying
335
+ * `failure.detail` (payload-free: a type name or path, never
336
+ * content) as its message; `null` identities under the declared
337
+ * provider; `decided_by: null`; no per-interceptor summaries (no
338
+ * interceptor ran); envelope members from {@link HostFailure}, with
339
+ * the §10.3 unknown values (`""`/`-1`) where absent. It takes the
340
+ * next slot in the record stream (sink, then buffer) like any
341
+ * emission. In `enforce` mode the host MUST still fail the action
342
+ * closed; in `evaluate_only` the record documents the host fault
343
+ * without implying enforcement (§8). */
344
+ recordHostFailure(point, failure = {}) {
345
+ // Deliberately partial basis: only the envelope facts the host
346
+ // still knows. It never passes §4 validation (`spec` is absent),
347
+ // so the core's finalize always yields the §10.3 rejection shape —
348
+ // null identities under the declared provider — and keeps the
349
+ // synthesized `context_invalid` deny (with the host's detail)
350
+ // instead of substituting its own.
351
+ const basis = { interception_point: point };
352
+ if (failure.session_id !== undefined)
353
+ basis["session"] = { id: failure.session_id };
354
+ if (failure.sequence !== undefined)
355
+ basis["sequence"] = failure.sequence;
356
+ if (failure.timestamp !== undefined)
357
+ basis["timestamp"] = failure.timestamp;
358
+ const providerName = this.identity === null ? null : this.identity === index_1.JCS_SHA256 ? index_1.JCS_SHA256 : this.identity.name;
359
+ const record = (0, index_1.finalize)(basis, (0, index_1.hostErrorVerdict)(index_1.HostError.ContextInvalid, failure.detail), this.mode, {
360
+ input_identity: null,
361
+ identity_provider: providerName,
362
+ enforced_identity: null,
363
+ decided_by: null,
364
+ composition: this.composition,
365
+ verdicts: null,
366
+ fold_truncated: null,
367
+ resolved_by: null,
368
+ interceptors_registered: this.interceptors.length,
369
+ });
370
+ return this.deliver(record);
371
+ }
372
+ /** Deliver a record to the sink and the bounded buffer (§10.3). */
373
+ deliver(record) {
323
374
  if (this.recordSink) {
324
375
  // Audit delivery must not take down the control plane (§10.3).
325
376
  try {
package/dist/index.d.ts CHANGED
@@ -341,6 +341,7 @@ export declare function composeAggregate(composition: CompositionConfig, verdict
341
341
  };
342
342
  export { AgentContextBuilder } from "./builder";
343
343
  export { InterceptionEmitter } from "./emitter";
344
+ export type { HostFailure } from "./emitter";
344
345
  /** Raised by a host when a verdict blocks the guarded action (§6). */
345
346
  /** Returned by `InterceptionEmitter.emit` on a proceeding emission:
346
347
  * the record plus the **effective** (post-composition) target the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@responsibleai/agent-hooks",
3
- "version": "0.1.0-alpha.5",
3
+ "version": "0.1.0-beta.1",
4
4
  "description": "Framework-neutral agent control contract (AGENT-HOOKS-0.1). TypeScript wrapper over the canonical Rust core. Cooperative contract, not a security boundary: the host is fully trusted (see SECURITY.md).",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
@@ -44,10 +44,10 @@
44
44
  "node": ">=20"
45
45
  },
46
46
  "optionalDependencies": {
47
- "@responsibleai/agent-hooks-linux-x64-gnu": "0.1.0-alpha.5",
48
- "@responsibleai/agent-hooks-linux-arm64-gnu": "0.1.0-alpha.5",
49
- "@responsibleai/agent-hooks-darwin-x64": "0.1.0-alpha.5",
50
- "@responsibleai/agent-hooks-darwin-arm64": "0.1.0-alpha.5",
51
- "@responsibleai/agent-hooks-win32-x64-msvc": "0.1.0-alpha.5"
47
+ "@responsibleai/agent-hooks-linux-x64-gnu": "0.1.0-beta.1",
48
+ "@responsibleai/agent-hooks-linux-arm64-gnu": "0.1.0-beta.1",
49
+ "@responsibleai/agent-hooks-darwin-x64": "0.1.0-beta.1",
50
+ "@responsibleai/agent-hooks-darwin-arm64": "0.1.0-beta.1",
51
+ "@responsibleai/agent-hooks-win32-x64-msvc": "0.1.0-beta.1"
52
52
  }
53
53
  }