@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 +72 -7
- package/binding.d.ts +27 -0
- package/binding.js +59 -54
- package/dist/builder.js +3 -4
- package/dist/ctk/index.d.ts +44 -5
- package/dist/ctk/index.js +6 -10
- package/dist/ctk/reference.d.ts +8 -8
- package/dist/ctk/reference.declaration.json +33 -0
- package/dist/ctk/reference.js +86 -34
- package/dist/ctk/runner.d.ts +30 -10
- package/dist/ctk/runner.js +569 -42
- package/dist/declaration.d.ts +378 -0
- package/dist/declaration.js +752 -0
- package/dist/emitter.d.ts +68 -14
- package/dist/emitter.js +281 -45
- package/dist/index.d.ts +23 -3
- package/dist/index.js +49 -8
- package/dist/native.d.ts +9 -8
- package/dist/native.js +13 -5
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft
|
|
3
|
-
// Licensed under the MIT License.
|
|
4
|
-
/**
|
|
5
|
-
* agent-hooks: framework-neutral agent lifecycle hook contract.
|
|
6
|
-
* Implements AGENT-HOOKS-0.1. Lifted and adapted from
|
|
7
|
-
* `policy-engine/sdk/node/src/index.ts`.
|
|
8
|
-
*/
|
|
2
|
+
// Copyright (c) Microsoft. All rights reserved.
|
|
9
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.InterceptionBlocked = exports.InterceptionEmitter = exports.AgentContextBuilder = exports.ApprovalOutcome = exports.Composition = exports.CompositionProfile = exports.ALLOW = exports.Verdict = exports.HostError = exports.EnforcementMode = exports.Decision = exports.InterceptionPoint = exports.JCS_SHA256 = exports.SPEC_VERSION = exports.AgentHooksCoreError = void 0;
|
|
4
|
+
exports.InterceptionBlocked = exports.validReference = exports.validKind = exports.fullKnobSupport = exports.declarationVersions = exports.canonicalDeclaration = exports.SUPPORTED_DECLARATION_VERSIONS = exports.MAX_TIMEOUT_MS = exports.MAX_KIND_LEN = exports.MAX_ID_LEN = exports.MAX_DOCUMENT_BYTES = exports.MAX_DETAIL_LEN = exports.MAX_DEPTH = exports.MAX_BINDINGS = exports.HostSurface = exports.HostRegistryError = exports.HostRegistry = exports.HostDeclaration = exports.DeclarationErrorClass = exports.DeclarationError = exports.DeclarationBuilder = exports.DECLARATION_VERSION = exports.CAPABILITIES = exports.EmitterSealed = exports.InterceptionEmitter = exports.AgentContextBuilder = exports.ApprovalOutcome = exports.Composition = exports.CompositionProfile = exports.ALLOW = exports.Verdict = exports.HostError = exports.EnforcementMode = exports.Decision = exports.InterceptionPoint = exports.JCS_SHA256 = exports.SPEC_VERSION = exports.AgentHooksCoreError = void 0;
|
|
11
5
|
exports.transformPermitted = transformPermitted;
|
|
12
6
|
exports.permits = permits;
|
|
13
7
|
exports.hostErrorVerdict = hostErrorVerdict;
|
|
@@ -19,11 +13,18 @@ exports.nonFiniteDetail = nonFiniteDetail;
|
|
|
19
13
|
exports.canonicalJson = canonicalJson;
|
|
20
14
|
exports.contextIdentity = contextIdentity;
|
|
21
15
|
exports.validateVerdict = validateVerdict;
|
|
16
|
+
exports.parseInterceptorResponse = parseInterceptorResponse;
|
|
17
|
+
exports.serializeInterceptorResponse = serializeInterceptorResponse;
|
|
22
18
|
exports.applyTransform = applyTransform;
|
|
23
19
|
exports.applyTransformCtx = applyTransformCtx;
|
|
24
20
|
exports.validateTransformCtx = validateTransformCtx;
|
|
25
21
|
exports.finalize = finalize;
|
|
26
22
|
exports.composeAggregate = composeAggregate;
|
|
23
|
+
/**
|
|
24
|
+
* agent-hooks: framework-neutral agent lifecycle hook contract.
|
|
25
|
+
* Implements AGENT-HOOKS-0.1. Lifted and adapted from
|
|
26
|
+
* `policy-engine/sdk/node/src/index.ts`.
|
|
27
|
+
*/
|
|
27
28
|
const native_1 = require("./native");
|
|
28
29
|
Object.defineProperty(exports, "AgentHooksCoreError", { enumerable: true, get: function () { return native_1.AgentHooksCoreError; } });
|
|
29
30
|
/** Spec version this SDK implements (§4.1 `spec` field). */
|
|
@@ -225,6 +226,21 @@ function contextIdentity(ctx) {
|
|
|
225
226
|
function validateVerdict(v) {
|
|
226
227
|
native_1.native.validateVerdict(marshal(v));
|
|
227
228
|
}
|
|
229
|
+
/** Parse a bare Verdict or §5.5 response envelope. */
|
|
230
|
+
function parseInterceptorResponse(value) {
|
|
231
|
+
const wire = typeof value === "string" ? value : marshal(value);
|
|
232
|
+
return JSON.parse(native_1.native.normalizeInterceptorResponse(wire));
|
|
233
|
+
}
|
|
234
|
+
/** Emit a bare Verdict when the response carries no transport metadata. */
|
|
235
|
+
function serializeInterceptorResponse(response) {
|
|
236
|
+
if (response.extensions == null || Object.keys(response.extensions).length === 0) {
|
|
237
|
+
return response.verdict;
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
verdict: response.verdict,
|
|
241
|
+
extensions: response.extensions,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
228
244
|
/** §5.2: apply a `$target`-rooted transform. Returns a new object. Rust core. */
|
|
229
245
|
function applyTransform(target, path, value) {
|
|
230
246
|
return JSON.parse(native_1.native.applyTransform(marshal(target), path, marshal(value)));
|
|
@@ -251,6 +267,7 @@ function finalize(ctx, verdict, mode, meta) {
|
|
|
251
267
|
enforced_identity: meta.enforced_identity ?? null,
|
|
252
268
|
decided_by: meta.decided_by ?? null,
|
|
253
269
|
composition: meta.composition,
|
|
270
|
+
declaration: meta.declaration ?? null,
|
|
254
271
|
verdicts: meta.verdicts ?? null,
|
|
255
272
|
fold_truncated: meta.fold_truncated ?? null,
|
|
256
273
|
resolved_by: meta.resolved_by ?? null,
|
|
@@ -267,6 +284,30 @@ var builder_1 = require("./builder");
|
|
|
267
284
|
Object.defineProperty(exports, "AgentContextBuilder", { enumerable: true, get: function () { return builder_1.AgentContextBuilder; } });
|
|
268
285
|
var emitter_1 = require("./emitter");
|
|
269
286
|
Object.defineProperty(exports, "InterceptionEmitter", { enumerable: true, get: function () { return emitter_1.InterceptionEmitter; } });
|
|
287
|
+
Object.defineProperty(exports, "EmitterSealed", { enumerable: true, get: function () { return emitter_1.EmitterSealed; } });
|
|
288
|
+
var declaration_1 = require("./declaration");
|
|
289
|
+
Object.defineProperty(exports, "CAPABILITIES", { enumerable: true, get: function () { return declaration_1.CAPABILITIES; } });
|
|
290
|
+
Object.defineProperty(exports, "DECLARATION_VERSION", { enumerable: true, get: function () { return declaration_1.DECLARATION_VERSION; } });
|
|
291
|
+
Object.defineProperty(exports, "DeclarationBuilder", { enumerable: true, get: function () { return declaration_1.DeclarationBuilder; } });
|
|
292
|
+
Object.defineProperty(exports, "DeclarationError", { enumerable: true, get: function () { return declaration_1.DeclarationError; } });
|
|
293
|
+
Object.defineProperty(exports, "DeclarationErrorClass", { enumerable: true, get: function () { return declaration_1.DeclarationErrorClass; } });
|
|
294
|
+
Object.defineProperty(exports, "HostDeclaration", { enumerable: true, get: function () { return declaration_1.HostDeclaration; } });
|
|
295
|
+
Object.defineProperty(exports, "HostRegistry", { enumerable: true, get: function () { return declaration_1.HostRegistry; } });
|
|
296
|
+
Object.defineProperty(exports, "HostRegistryError", { enumerable: true, get: function () { return declaration_1.HostRegistryError; } });
|
|
297
|
+
Object.defineProperty(exports, "HostSurface", { enumerable: true, get: function () { return declaration_1.HostSurface; } });
|
|
298
|
+
Object.defineProperty(exports, "MAX_BINDINGS", { enumerable: true, get: function () { return declaration_1.MAX_BINDINGS; } });
|
|
299
|
+
Object.defineProperty(exports, "MAX_DEPTH", { enumerable: true, get: function () { return declaration_1.MAX_DEPTH; } });
|
|
300
|
+
Object.defineProperty(exports, "MAX_DETAIL_LEN", { enumerable: true, get: function () { return declaration_1.MAX_DETAIL_LEN; } });
|
|
301
|
+
Object.defineProperty(exports, "MAX_DOCUMENT_BYTES", { enumerable: true, get: function () { return declaration_1.MAX_DOCUMENT_BYTES; } });
|
|
302
|
+
Object.defineProperty(exports, "MAX_ID_LEN", { enumerable: true, get: function () { return declaration_1.MAX_ID_LEN; } });
|
|
303
|
+
Object.defineProperty(exports, "MAX_KIND_LEN", { enumerable: true, get: function () { return declaration_1.MAX_KIND_LEN; } });
|
|
304
|
+
Object.defineProperty(exports, "MAX_TIMEOUT_MS", { enumerable: true, get: function () { return declaration_1.MAX_TIMEOUT_MS; } });
|
|
305
|
+
Object.defineProperty(exports, "SUPPORTED_DECLARATION_VERSIONS", { enumerable: true, get: function () { return declaration_1.SUPPORTED_DECLARATION_VERSIONS; } });
|
|
306
|
+
Object.defineProperty(exports, "canonicalDeclaration", { enumerable: true, get: function () { return declaration_1.canonicalDeclaration; } });
|
|
307
|
+
Object.defineProperty(exports, "declarationVersions", { enumerable: true, get: function () { return declaration_1.declarationVersions; } });
|
|
308
|
+
Object.defineProperty(exports, "fullKnobSupport", { enumerable: true, get: function () { return declaration_1.fullKnobSupport; } });
|
|
309
|
+
Object.defineProperty(exports, "validKind", { enumerable: true, get: function () { return declaration_1.validKind; } });
|
|
310
|
+
Object.defineProperty(exports, "validReference", { enumerable: true, get: function () { return declaration_1.validReference; } });
|
|
270
311
|
class InterceptionBlocked extends Error {
|
|
271
312
|
result;
|
|
272
313
|
constructor(result) {
|
package/dist/native.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Loader for the napi-rs native module + typed re-export.
|
|
3
|
-
*
|
|
4
|
-
* `@napi-rs/cli build` emits `agent-hooks.<platform>.node` alongside a
|
|
5
|
-
* generated `index.js` loader; this module re-exports it with types and
|
|
6
|
-
* the `AgentHooksCoreError` unwrapping so callers get `.code`.
|
|
7
|
-
*/
|
|
8
1
|
/** Thrown by every native function on failure. `.code` is the §11
|
|
9
|
-
* `host_error:*` wire string.
|
|
2
|
+
* `host_error:*` wire string, or a §7.7.6 `declaration_error:*`
|
|
3
|
+
* string from the declaration functions (the detail is then JSON
|
|
4
|
+
* findings, which `declaration.ts` retypes as `DeclarationError`). */
|
|
10
5
|
export declare class AgentHooksCoreError extends Error {
|
|
11
6
|
readonly code: string;
|
|
7
|
+
readonly detail: string;
|
|
12
8
|
constructor(code: string, detail: string);
|
|
13
9
|
}
|
|
14
10
|
export declare const native: {
|
|
@@ -16,6 +12,7 @@ export declare const native: {
|
|
|
16
12
|
canonicalJson: (valueJson: string) => string;
|
|
17
13
|
contextIdentity: (ctxJson: string) => string;
|
|
18
14
|
validateVerdict: (verdictJson: string) => string;
|
|
15
|
+
normalizeInterceptorResponse: (responseJson: string) => string;
|
|
19
16
|
validateEnvelope: (ctxJson: string) => string;
|
|
20
17
|
applyTransform: (targetJson: string, path: string, valueJson: string) => string;
|
|
21
18
|
applyTransformCtx: (ctxJson: string, path: string, valueJson: string) => string;
|
|
@@ -26,4 +23,8 @@ export declare const native: {
|
|
|
26
23
|
ctkScriptedResolve: (rulesJson: string, ctxJson: string, identity: string) => string;
|
|
27
24
|
ctkShouldSkip: (vectorJson: string, capsJson: string) => string;
|
|
28
25
|
ctkAssert: (vectorJson: string, recordedJson: string, runRecordJson: string) => string;
|
|
26
|
+
declarationVersions: () => string;
|
|
27
|
+
declarationValidate: (documentJson: string) => string;
|
|
28
|
+
declarationResolve: (documentJson: string, hostJson: string) => string;
|
|
29
|
+
declarationResolveSurface: (documentJson: string, surfaceJson: string) => string;
|
|
29
30
|
};
|
package/dist/native.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft
|
|
3
|
-
|
|
2
|
+
// Copyright (c) Microsoft. All rights reserved.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.native = exports.AgentHooksCoreError = void 0;
|
|
4
5
|
/**
|
|
5
6
|
* Loader for the napi-rs native module + typed re-export.
|
|
6
7
|
*
|
|
@@ -8,19 +9,21 @@
|
|
|
8
9
|
* generated `index.js` loader; this module re-exports it with types and
|
|
9
10
|
* the `AgentHooksCoreError` unwrapping so callers get `.code`.
|
|
10
11
|
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.native = exports.AgentHooksCoreError = void 0;
|
|
13
12
|
// napi-rs emits a platform-detecting loader at ../binding.js (see
|
|
14
13
|
// package.json scripts.build:native --js binding.js).
|
|
15
14
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
16
15
|
const binding = require("../binding.js");
|
|
17
16
|
/** Thrown by every native function on failure. `.code` is the §11
|
|
18
|
-
* `host_error:*` wire string.
|
|
17
|
+
* `host_error:*` wire string, or a §7.7.6 `declaration_error:*`
|
|
18
|
+
* string from the declaration functions (the detail is then JSON
|
|
19
|
+
* findings, which `declaration.ts` retypes as `DeclarationError`). */
|
|
19
20
|
class AgentHooksCoreError extends Error {
|
|
20
21
|
code;
|
|
22
|
+
detail;
|
|
21
23
|
constructor(code, detail) {
|
|
22
24
|
super(`${code}: ${detail}`);
|
|
23
25
|
this.code = code;
|
|
26
|
+
this.detail = detail;
|
|
24
27
|
this.name = "AgentHooksCoreError";
|
|
25
28
|
}
|
|
26
29
|
}
|
|
@@ -44,6 +47,7 @@ exports.native = {
|
|
|
44
47
|
canonicalJson: wrap(binding.canonicalJson),
|
|
45
48
|
contextIdentity: wrap(binding.contextIdentity),
|
|
46
49
|
validateVerdict: wrap(binding.validateVerdict),
|
|
50
|
+
normalizeInterceptorResponse: wrap(binding.normalizeInterceptorResponse),
|
|
47
51
|
validateEnvelope: wrap(binding.validateEnvelope),
|
|
48
52
|
applyTransform: wrap(binding.applyTransform),
|
|
49
53
|
applyTransformCtx: wrap(binding.applyTransformCtx),
|
|
@@ -54,4 +58,8 @@ exports.native = {
|
|
|
54
58
|
ctkScriptedResolve: wrap(binding.ctkScriptedResolve),
|
|
55
59
|
ctkShouldSkip: wrap(binding.ctkShouldSkip),
|
|
56
60
|
ctkAssert: wrap(binding.ctkAssert),
|
|
61
|
+
declarationVersions: binding.declarationVersions,
|
|
62
|
+
declarationValidate: wrap(binding.declarationValidate),
|
|
63
|
+
declarationResolve: wrap(binding.declarationResolve),
|
|
64
|
+
declarationResolveSurface: wrap(binding.declarationResolveSurface),
|
|
57
65
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@responsibleai/agent-hooks",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.3",
|
|
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-beta.
|
|
48
|
-
"@responsibleai/agent-hooks-linux-arm64-gnu": "0.1.0-beta.
|
|
49
|
-
"@responsibleai/agent-hooks-darwin-x64": "0.1.0-beta.
|
|
50
|
-
"@responsibleai/agent-hooks-darwin-arm64": "0.1.0-beta.
|
|
51
|
-
"@responsibleai/agent-hooks-win32-x64-msvc": "0.1.0-beta.
|
|
47
|
+
"@responsibleai/agent-hooks-linux-x64-gnu": "0.1.0-beta.3",
|
|
48
|
+
"@responsibleai/agent-hooks-linux-arm64-gnu": "0.1.0-beta.3",
|
|
49
|
+
"@responsibleai/agent-hooks-darwin-x64": "0.1.0-beta.3",
|
|
50
|
+
"@responsibleai/agent-hooks-darwin-arm64": "0.1.0-beta.3",
|
|
51
|
+
"@responsibleai/agent-hooks-win32-x64-msvc": "0.1.0-beta.3"
|
|
52
52
|
}
|
|
53
53
|
}
|