@responsibleai/agent-hooks 0.1.0-alpha.2

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/dist/native.js ADDED
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ /**
5
+ * Loader for the napi-rs native module + typed re-export.
6
+ *
7
+ * `@napi-rs/cli build` emits `agent-hooks.<platform>.node` alongside a
8
+ * generated `index.js` loader; this module re-exports it with types and
9
+ * the `AgentHooksCoreError` unwrapping so callers get `.code`.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.native = exports.AgentHooksCoreError = void 0;
13
+ // napi-rs emits a platform-detecting loader at ../binding.js (see
14
+ // package.json scripts.build:native --js binding.js).
15
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
16
+ const binding = require("../binding.js");
17
+ /** Thrown by every native function on failure. `.code` is the §11
18
+ * `host_error:*` wire string. */
19
+ class AgentHooksCoreError extends Error {
20
+ code;
21
+ constructor(code, detail) {
22
+ super(`${code}: ${detail}`);
23
+ this.code = code;
24
+ this.name = "AgentHooksCoreError";
25
+ }
26
+ }
27
+ exports.AgentHooksCoreError = AgentHooksCoreError;
28
+ function wrap(fn) {
29
+ return (...a) => {
30
+ try {
31
+ return fn(...a);
32
+ }
33
+ catch (e) {
34
+ const msg = String(e.message ?? e);
35
+ const sep = msg.indexOf("\u001f");
36
+ if (sep > 0)
37
+ throw new AgentHooksCoreError(msg.slice(0, sep), msg.slice(sep + 1));
38
+ throw e;
39
+ }
40
+ };
41
+ }
42
+ exports.native = {
43
+ specVersion: binding.specVersion,
44
+ canonicalJson: wrap(binding.canonicalJson),
45
+ contextIdentity: wrap(binding.contextIdentity),
46
+ validateVerdict: wrap(binding.validateVerdict),
47
+ applyTransform: wrap(binding.applyTransform),
48
+ applyTransformCtx: wrap(binding.applyTransformCtx),
49
+ validateTransformCtx: wrap(binding.validateTransformCtx),
50
+ finalize: wrap(binding.finalize),
51
+ composeAggregate: wrap(binding.composeAggregate),
52
+ ctkScriptedIntercept: wrap(binding.ctkScriptedIntercept),
53
+ ctkScriptedResolve: wrap(binding.ctkScriptedResolve),
54
+ ctkShouldSkip: wrap(binding.ctkShouldSkip),
55
+ ctkAssert: wrap(binding.ctkAssert),
56
+ };
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@responsibleai/agent-hooks",
3
+ "version": "0.1.0-alpha.2",
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
+ "license": "MIT",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": "./dist/index.js",
10
+ "./ctk": "./dist/ctk/index.js"
11
+ },
12
+ "files": ["dist", "binding.js", "binding.d.ts", "*.node"],
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/responsibleai/agent-hooks.git",
16
+ "directory": "sdk/typescript"
17
+ },
18
+ "napi": {
19
+ "name": "agent-hooks",
20
+ "triples": {
21
+ "defaults": true
22
+ }
23
+ },
24
+ "scripts": {
25
+ "build:native": "napi build --release --platform --js binding.js --dts binding.d.ts",
26
+ "build:native:debug": "napi build --platform --js binding.js --dts binding.d.ts",
27
+ "build": "npm run build:native && tsc",
28
+ "test": "npm run build && node --test test/*.mjs"
29
+ },
30
+ "devDependencies": {
31
+ "@napi-rs/cli": "^2.18.0",
32
+ "@types/node": "^22.0.0",
33
+ "typescript": "^5.5.0"
34
+ },
35
+ "engines": { "node": ">=20" }
36
+ }