@nifrajs/agent 2.14.1 → 3.2.0
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 +36 -0
- package/dist/deployment.d.ts +157 -0
- package/dist/deployment.d.ts.map +1 -0
- package/dist/deployment.js +374 -0
- package/dist/deployment.js.map +1 -0
- package/dist/events.d.ts +41 -0
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +75 -0
- package/dist/events.js.map +1 -1
- package/dist/execution-policy.d.ts.map +1 -1
- package/dist/execution-policy.js +11 -7
- package/dist/execution-policy.js.map +1 -1
- package/dist/gateway.d.ts +153 -0
- package/dist/gateway.d.ts.map +1 -0
- package/dist/gateway.js +409 -0
- package/dist/gateway.js.map +1 -0
- package/dist/index.d.ts +86 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +163 -1
- package/dist/index.js.map +1 -1
- package/dist/mount.d.ts +59 -0
- package/dist/mount.d.ts.map +1 -0
- package/dist/mount.js +247 -0
- package/dist/mount.js.map +1 -0
- package/dist/registry.d.ts +112 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +326 -0
- package/dist/registry.js.map +1 -0
- package/package.json +12 -2
- package/src/deployment.ts +621 -0
- package/src/events.ts +125 -0
- package/src/execution-policy.ts +9 -5
- package/src/gateway.ts +607 -0
- package/src/index.ts +303 -1
- package/src/mount.ts +344 -0
- package/src/registry.ts +444 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified capability descriptor registry.
|
|
3
|
+
*
|
|
4
|
+
* A {@link CapabilityDescriptor} is the content-free identity card of one invokable capability - a
|
|
5
|
+
* core tool, an MCP tool, a coding-agent extension, a model adapter, or a deployment adapter. It
|
|
6
|
+
* carries a stable name, a version, a kind, a schema digest, the capabilities it requires, and the
|
|
7
|
+
* host-policy classes (approval, retry, idempotency, isolation) the host uses to admit it. It never
|
|
8
|
+
* carries a description, an input or output payload, a prompt, or any other content: the digest is
|
|
9
|
+
* taken over the input JSON schema, so two producers of the same capability agree on identity
|
|
10
|
+
* without either exposing a request body.
|
|
11
|
+
*
|
|
12
|
+
* A {@link RegistrySnapshot} composes many descriptors into a deterministic, collision-checked set
|
|
13
|
+
* with a single snapshot digest. Canonical ordering makes the digest independent of input order, so
|
|
14
|
+
* reordering declarations can never change it. Every failure raises a {@link RegistryError} with a
|
|
15
|
+
* stable {@link RegistryErrorCode}; nothing here throws a message that could carry content.
|
|
16
|
+
*
|
|
17
|
+
* The package depends only on `@nifrajs/core`. The MCP and coding-agent adapters live in their own
|
|
18
|
+
* packages and consume these contracts through the declared `@nifrajs/agent` edge - never the
|
|
19
|
+
* reverse - so neither this package nor the protocol ever imports MCP transport or the coding agent.
|
|
20
|
+
*/
|
|
21
|
+
import type { ToolContract } from "@nifrajs/core/tool-contract";
|
|
22
|
+
export declare const CAPABILITY_DESCRIPTOR_VERSION: 1;
|
|
23
|
+
export declare const REGISTRY_SNAPSHOT_VERSION: 1;
|
|
24
|
+
/** Producer families a descriptor can describe. A value outside this set fails `unsupported_kind`. */
|
|
25
|
+
export type CapabilityKind = "tool" | "mcp-tool" | "extension" | "model-adapter" | "deployment-adapter";
|
|
26
|
+
/** Host approval requirement. Mirrors the core tool approval policy; a numeric level is not content. */
|
|
27
|
+
export type ApprovalClass = {
|
|
28
|
+
readonly kind: "none";
|
|
29
|
+
} | {
|
|
30
|
+
readonly kind: "required";
|
|
31
|
+
} | {
|
|
32
|
+
readonly kind: "threshold";
|
|
33
|
+
readonly level: number;
|
|
34
|
+
};
|
|
35
|
+
/** Whether a failed invocation may be retried. A capability is retry-eligible only when idempotent. */
|
|
36
|
+
export type RetryClass = "none" | "idempotent";
|
|
37
|
+
/** Idempotency guarantee a capability declares, mirroring the tool idempotency scope. */
|
|
38
|
+
export type IdempotencyClass = "none" | "request" | "durable";
|
|
39
|
+
/** Isolation the host must provide to invoke the capability. */
|
|
40
|
+
export type IsolationClass = "inherit" | "process" | "sandbox";
|
|
41
|
+
export interface CapabilityDescriptor {
|
|
42
|
+
readonly descriptorVersion: typeof CAPABILITY_DESCRIPTOR_VERSION;
|
|
43
|
+
readonly kind: CapabilityKind;
|
|
44
|
+
readonly name: string;
|
|
45
|
+
readonly version: string;
|
|
46
|
+
/** SHA-256 hex over the canonical input JSON schema. Identity without exposing a request body. */
|
|
47
|
+
readonly schemaDigest: string;
|
|
48
|
+
readonly requiredCapabilities: readonly string[];
|
|
49
|
+
readonly approval: ApprovalClass;
|
|
50
|
+
readonly retry: RetryClass;
|
|
51
|
+
readonly idempotency: IdempotencyClass;
|
|
52
|
+
readonly isolation: IsolationClass;
|
|
53
|
+
}
|
|
54
|
+
export interface RegistrySnapshot {
|
|
55
|
+
readonly version: typeof REGISTRY_SNAPSHOT_VERSION;
|
|
56
|
+
/** SHA-256 hex over the canonically ordered descriptor set. Independent of input order. */
|
|
57
|
+
readonly digest: string;
|
|
58
|
+
readonly descriptors: readonly CapabilityDescriptor[];
|
|
59
|
+
}
|
|
60
|
+
export type RegistryErrorCode = "invalid_descriptor" | "unsupported_kind" | "missing_version" | "invalid_name" | "invalid_capability" | "content_field" | "invalid_schema_digest" | "invalid_approval" | "descriptor_collision" | "schema_drift" | "capability_escalation";
|
|
61
|
+
/** A stable, content-free failure. `code` is the machine-addressable reason; the message is generic. */
|
|
62
|
+
export declare class RegistryError extends Error {
|
|
63
|
+
readonly code: RegistryErrorCode;
|
|
64
|
+
constructor(code: RegistryErrorCode, message?: RegistryErrorCode);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Validate an untrusted value as a {@link CapabilityDescriptor}, normalizing capability order. Missing,
|
|
68
|
+
* unknown, or content-bearing fields are rejected with a stable code. This is the single admission
|
|
69
|
+
* point: every adapter output and every wire value passes through it before it enters a snapshot.
|
|
70
|
+
*/
|
|
71
|
+
export declare function parseCapabilityDescriptor(value: unknown): CapabilityDescriptor;
|
|
72
|
+
/** The fields an adapter supplies. The schema digest is derived from `inputSchema`, never passed in. */
|
|
73
|
+
export interface DescriptorInput {
|
|
74
|
+
readonly kind: CapabilityKind;
|
|
75
|
+
readonly name: string;
|
|
76
|
+
readonly version?: string;
|
|
77
|
+
/** The capability's input JSON schema. Digested for identity; the schema itself is not stored. */
|
|
78
|
+
readonly inputSchema: Record<string, unknown>;
|
|
79
|
+
readonly requiredCapabilities?: readonly string[];
|
|
80
|
+
readonly approval?: ApprovalClass;
|
|
81
|
+
readonly retry?: RetryClass;
|
|
82
|
+
readonly idempotency?: IdempotencyClass;
|
|
83
|
+
readonly isolation?: IsolationClass;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Build a validated descriptor from adapter fields, digesting the input schema. Two adapters that
|
|
87
|
+
* describe the same capability (same kind, name, version, schema, and classes) produce byte-identical
|
|
88
|
+
* descriptors and therefore the same digest, which is what makes cross-package parity checkable.
|
|
89
|
+
*/
|
|
90
|
+
export declare function composeDescriptor(input: DescriptorInput): Promise<CapabilityDescriptor>;
|
|
91
|
+
export interface ToolDescriptorOptions {
|
|
92
|
+
/** Kind to record. Defaults to `tool`; the MCP adapter passes `mcp-tool` for the same contract. */
|
|
93
|
+
readonly kind?: CapabilityKind;
|
|
94
|
+
readonly version?: string;
|
|
95
|
+
readonly isolation?: IsolationClass;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Adapt a Nifra core {@link ToolContract} into a descriptor without touching its execution contract.
|
|
99
|
+
* The schema digest is taken over the tool's own input JSON schema, retry follows idempotency, and
|
|
100
|
+
* the approval policy is carried through unchanged, so the descriptor is a faithful, content-free
|
|
101
|
+
* projection of the contract the runtime already enforces.
|
|
102
|
+
*/
|
|
103
|
+
export declare function descriptorFromTool<Input, Output>(tool: ToolContract<Input, Output>, options?: ToolDescriptorOptions): Promise<CapabilityDescriptor>;
|
|
104
|
+
/**
|
|
105
|
+
* Compose a deterministic registry snapshot. Descriptors are validated, checked for identity
|
|
106
|
+
* collisions, canonically ordered, and digested. Two descriptors that share a (kind, name) identity
|
|
107
|
+
* fail `descriptor_collision` when their schema digests agree and `schema_drift` when they differ -
|
|
108
|
+
* a drifted schema is a distinct, addressable failure from a duplicate registration. Because the set
|
|
109
|
+
* is sorted before it is digested, the snapshot digest is independent of the input order.
|
|
110
|
+
*/
|
|
111
|
+
export declare function composeRegistrySnapshot(descriptors: readonly CapabilityDescriptor[]): Promise<RegistrySnapshot>;
|
|
112
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAG/D,eAAO,MAAM,6BAA6B,EAAG,CAAU,CAAA;AACvD,eAAO,MAAM,yBAAyB,EAAG,CAAU,CAAA;AAEnD,sGAAsG;AACtG,MAAM,MAAM,cAAc,GACtB,MAAM,GACN,UAAU,GACV,WAAW,GACX,eAAe,GACf,oBAAoB,CAAA;AAUxB,wGAAwG;AACxG,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAE1D,uGAAuG;AACvG,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,YAAY,CAAA;AAG9C,yFAAyF;AACzF,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;AAO7D,gEAAgE;AAChE,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAA;AAO9D,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,iBAAiB,EAAE,OAAO,6BAA6B,C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,kGAAkG;IAClG,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7C,QAAQ,CAAC,oBAAoB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACjD,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAA;IACjC,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,CAAA;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,gBAAgB,CAAA;IACvC,QAAQ,CAAC,SAAS,CAAC,EAAE,cAAc,CAAA;CACpC;AAID;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAiC7F;AAED,MAAM,WAAW,qBAAqB;IACpC,mGAAmG;IACnG,QAAQ,CAAC,IAAI,CAAC,EAAE,cAAc,CAAA;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,cAAc,CAAA;CACpC;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAC9C,IAAI,EAAE,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,EACjC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,oBAAoB,CAAC,CAY/B;AA4BD;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,SAAS,oBAAoB,EAAE,GAC3C,OAAO,CAAC,gBAAgB,CAAC,CAyB3B"}
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified capability descriptor registry.
|
|
3
|
+
*
|
|
4
|
+
* A {@link CapabilityDescriptor} is the content-free identity card of one invokable capability - a
|
|
5
|
+
* core tool, an MCP tool, a coding-agent extension, a model adapter, or a deployment adapter. It
|
|
6
|
+
* carries a stable name, a version, a kind, a schema digest, the capabilities it requires, and the
|
|
7
|
+
* host-policy classes (approval, retry, idempotency, isolation) the host uses to admit it. It never
|
|
8
|
+
* carries a description, an input or output payload, a prompt, or any other content: the digest is
|
|
9
|
+
* taken over the input JSON schema, so two producers of the same capability agree on identity
|
|
10
|
+
* without either exposing a request body.
|
|
11
|
+
*
|
|
12
|
+
* A {@link RegistrySnapshot} composes many descriptors into a deterministic, collision-checked set
|
|
13
|
+
* with a single snapshot digest. Canonical ordering makes the digest independent of input order, so
|
|
14
|
+
* reordering declarations can never change it. Every failure raises a {@link RegistryError} with a
|
|
15
|
+
* stable {@link RegistryErrorCode}; nothing here throws a message that could carry content.
|
|
16
|
+
*
|
|
17
|
+
* The package depends only on `@nifrajs/core`. The MCP and coding-agent adapters live in their own
|
|
18
|
+
* packages and consume these contracts through the declared `@nifrajs/agent` edge - never the
|
|
19
|
+
* reverse - so neither this package nor the protocol ever imports MCP transport or the coding agent.
|
|
20
|
+
*/
|
|
21
|
+
import { toolInputJsonSchema } from "@nifrajs/core/tool-contract";
|
|
22
|
+
export const CAPABILITY_DESCRIPTOR_VERSION = 1;
|
|
23
|
+
export const REGISTRY_SNAPSHOT_VERSION = 1;
|
|
24
|
+
const CAPABILITY_KINDS = new Set([
|
|
25
|
+
"tool",
|
|
26
|
+
"mcp-tool",
|
|
27
|
+
"extension",
|
|
28
|
+
"model-adapter",
|
|
29
|
+
"deployment-adapter",
|
|
30
|
+
]);
|
|
31
|
+
const RETRY_CLASSES = new Set(["none", "idempotent"]);
|
|
32
|
+
const IDEMPOTENCY_CLASSES = new Set([
|
|
33
|
+
"none",
|
|
34
|
+
"request",
|
|
35
|
+
"durable",
|
|
36
|
+
]);
|
|
37
|
+
const ISOLATION_CLASSES = new Set([
|
|
38
|
+
"inherit",
|
|
39
|
+
"process",
|
|
40
|
+
"sandbox",
|
|
41
|
+
]);
|
|
42
|
+
/** A stable, content-free failure. `code` is the machine-addressable reason; the message is generic. */
|
|
43
|
+
export class RegistryError extends Error {
|
|
44
|
+
code;
|
|
45
|
+
constructor(code, message = code) {
|
|
46
|
+
super(message);
|
|
47
|
+
this.code = code;
|
|
48
|
+
this.name = "RegistryError";
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const NAME_TOKEN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
|
|
52
|
+
const CAPABILITY_TOKEN = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/;
|
|
53
|
+
const VERSION_TOKEN = /^[A-Za-z0-9][A-Za-z0-9._:+-]{0,63}$/;
|
|
54
|
+
const SCHEMA_DIGEST = /^[0-9a-f]{64}$/;
|
|
55
|
+
const DESCRIPTOR_KEYS = new Set([
|
|
56
|
+
"descriptorVersion",
|
|
57
|
+
"kind",
|
|
58
|
+
"name",
|
|
59
|
+
"version",
|
|
60
|
+
"schemaDigest",
|
|
61
|
+
"requiredCapabilities",
|
|
62
|
+
"approval",
|
|
63
|
+
"retry",
|
|
64
|
+
"idempotency",
|
|
65
|
+
"isolation",
|
|
66
|
+
]);
|
|
67
|
+
/**
|
|
68
|
+
* Keys that would carry content or a payload. Their mere presence on a descriptor object is a
|
|
69
|
+
* boundary violation and fails `content_field`, distinct from an unknown structural field.
|
|
70
|
+
*/
|
|
71
|
+
const CONTENT_KEYS = new Set([
|
|
72
|
+
"description",
|
|
73
|
+
"instruction",
|
|
74
|
+
"input",
|
|
75
|
+
"output",
|
|
76
|
+
"inputSchema",
|
|
77
|
+
"outputSchema",
|
|
78
|
+
"content",
|
|
79
|
+
"prompt",
|
|
80
|
+
"text",
|
|
81
|
+
"message",
|
|
82
|
+
"arguments",
|
|
83
|
+
"args",
|
|
84
|
+
"params",
|
|
85
|
+
"parameters",
|
|
86
|
+
"result",
|
|
87
|
+
"payload",
|
|
88
|
+
"body",
|
|
89
|
+
"data",
|
|
90
|
+
]);
|
|
91
|
+
const encoder = new TextEncoder();
|
|
92
|
+
/** SHA-256 hex of a UTF-8 string. Collision-resistant, so a digest cannot be forged from content. */
|
|
93
|
+
async function sha256HexOf(text) {
|
|
94
|
+
const digest = await crypto.subtle.digest("SHA-256", encoder.encode(text));
|
|
95
|
+
const view = new Uint8Array(digest);
|
|
96
|
+
let hex = "";
|
|
97
|
+
for (let i = 0; i < view.length; i++)
|
|
98
|
+
hex += view[i].toString(16).padStart(2, "0");
|
|
99
|
+
return hex;
|
|
100
|
+
}
|
|
101
|
+
/** Deterministic JSON with recursively sorted object keys. Arrays keep order; non-finite rejected. */
|
|
102
|
+
function canonicalJson(value) {
|
|
103
|
+
if (value === null || typeof value === "boolean" || typeof value === "string")
|
|
104
|
+
return JSON.stringify(value);
|
|
105
|
+
if (typeof value === "number") {
|
|
106
|
+
if (!Number.isFinite(value))
|
|
107
|
+
throw new TypeError("non-finite JSON number");
|
|
108
|
+
return JSON.stringify(value);
|
|
109
|
+
}
|
|
110
|
+
if (Array.isArray(value))
|
|
111
|
+
return `[${value.map(canonicalJson).join(",")}]`;
|
|
112
|
+
if (typeof value === "object") {
|
|
113
|
+
const record = value;
|
|
114
|
+
const keys = Object.keys(record)
|
|
115
|
+
.filter((key) => record[key] !== undefined)
|
|
116
|
+
.sort();
|
|
117
|
+
return `{${keys.map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`).join(",")}}`;
|
|
118
|
+
}
|
|
119
|
+
throw new TypeError(`cannot canonicalize ${typeof value}`);
|
|
120
|
+
}
|
|
121
|
+
function isRecord(value) {
|
|
122
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
123
|
+
}
|
|
124
|
+
function parseKind(value) {
|
|
125
|
+
if (typeof value !== "string" || !CAPABILITY_KINDS.has(value))
|
|
126
|
+
throw new RegistryError("unsupported_kind");
|
|
127
|
+
return value;
|
|
128
|
+
}
|
|
129
|
+
function parseName(value) {
|
|
130
|
+
if (typeof value !== "string" || !NAME_TOKEN.test(value))
|
|
131
|
+
throw new RegistryError("invalid_name");
|
|
132
|
+
return value;
|
|
133
|
+
}
|
|
134
|
+
function parseVersion(value) {
|
|
135
|
+
if (typeof value !== "string" || value.length === 0)
|
|
136
|
+
throw new RegistryError("missing_version");
|
|
137
|
+
if (!VERSION_TOKEN.test(value))
|
|
138
|
+
throw new RegistryError("missing_version");
|
|
139
|
+
return value;
|
|
140
|
+
}
|
|
141
|
+
function parseRequiredCapabilities(value) {
|
|
142
|
+
if (value === undefined)
|
|
143
|
+
return Object.freeze([]);
|
|
144
|
+
if (!Array.isArray(value))
|
|
145
|
+
throw new RegistryError("invalid_capability");
|
|
146
|
+
const seen = new Set();
|
|
147
|
+
for (const entry of value) {
|
|
148
|
+
if (typeof entry !== "string" || !CAPABILITY_TOKEN.test(entry))
|
|
149
|
+
throw new RegistryError("invalid_capability");
|
|
150
|
+
seen.add(entry);
|
|
151
|
+
}
|
|
152
|
+
return Object.freeze([...seen].sort());
|
|
153
|
+
}
|
|
154
|
+
function parseApproval(value) {
|
|
155
|
+
if (value === undefined)
|
|
156
|
+
return { kind: "none" };
|
|
157
|
+
if (!isRecord(value))
|
|
158
|
+
throw new RegistryError("invalid_approval");
|
|
159
|
+
if (value.kind === "none")
|
|
160
|
+
return { kind: "none" };
|
|
161
|
+
if (value.kind === "required")
|
|
162
|
+
return { kind: "required" };
|
|
163
|
+
if (value.kind === "threshold") {
|
|
164
|
+
const level = value.level;
|
|
165
|
+
if (typeof level !== "number" || !Number.isInteger(level) || level < 0)
|
|
166
|
+
throw new RegistryError("invalid_approval");
|
|
167
|
+
return { kind: "threshold", level };
|
|
168
|
+
}
|
|
169
|
+
throw new RegistryError("invalid_approval");
|
|
170
|
+
}
|
|
171
|
+
function parseMember(value, members, fallback, code) {
|
|
172
|
+
if (value === undefined)
|
|
173
|
+
return fallback;
|
|
174
|
+
if (typeof value !== "string" || !members.has(value))
|
|
175
|
+
throw new RegistryError(code);
|
|
176
|
+
return value;
|
|
177
|
+
}
|
|
178
|
+
function assertNoContentFields(record) {
|
|
179
|
+
for (const key of Object.keys(record)) {
|
|
180
|
+
if (DESCRIPTOR_KEYS.has(key))
|
|
181
|
+
continue;
|
|
182
|
+
if (CONTENT_KEYS.has(key))
|
|
183
|
+
throw new RegistryError("content_field");
|
|
184
|
+
throw new RegistryError("invalid_descriptor");
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Validate an untrusted value as a {@link CapabilityDescriptor}, normalizing capability order. Missing,
|
|
189
|
+
* unknown, or content-bearing fields are rejected with a stable code. This is the single admission
|
|
190
|
+
* point: every adapter output and every wire value passes through it before it enters a snapshot.
|
|
191
|
+
*/
|
|
192
|
+
export function parseCapabilityDescriptor(value) {
|
|
193
|
+
if (!isRecord(value))
|
|
194
|
+
throw new RegistryError("invalid_descriptor");
|
|
195
|
+
assertNoContentFields(value);
|
|
196
|
+
if (value.descriptorVersion !== CAPABILITY_DESCRIPTOR_VERSION)
|
|
197
|
+
throw new RegistryError("invalid_descriptor");
|
|
198
|
+
const kind = parseKind(value.kind);
|
|
199
|
+
const name = parseName(value.name);
|
|
200
|
+
const version = parseVersion(value.version);
|
|
201
|
+
if (typeof value.schemaDigest !== "string" || !SCHEMA_DIGEST.test(value.schemaDigest))
|
|
202
|
+
throw new RegistryError("invalid_schema_digest");
|
|
203
|
+
const requiredCapabilities = parseRequiredCapabilities(value.requiredCapabilities);
|
|
204
|
+
const approval = parseApproval(value.approval);
|
|
205
|
+
const retry = parseMember(value.retry, RETRY_CLASSES, "none", "invalid_descriptor");
|
|
206
|
+
const idempotency = parseMember(value.idempotency, IDEMPOTENCY_CLASSES, "none", "invalid_descriptor");
|
|
207
|
+
const isolation = parseMember(value.isolation, ISOLATION_CLASSES, "inherit", "invalid_descriptor");
|
|
208
|
+
return Object.freeze({
|
|
209
|
+
descriptorVersion: CAPABILITY_DESCRIPTOR_VERSION,
|
|
210
|
+
kind,
|
|
211
|
+
name,
|
|
212
|
+
version,
|
|
213
|
+
schemaDigest: value.schemaDigest,
|
|
214
|
+
requiredCapabilities,
|
|
215
|
+
approval: Object.freeze(approval),
|
|
216
|
+
retry,
|
|
217
|
+
idempotency,
|
|
218
|
+
isolation,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
const DEFAULT_DESCRIPTOR_VERSION = "1.0.0";
|
|
222
|
+
/**
|
|
223
|
+
* Build a validated descriptor from adapter fields, digesting the input schema. Two adapters that
|
|
224
|
+
* describe the same capability (same kind, name, version, schema, and classes) produce byte-identical
|
|
225
|
+
* descriptors and therefore the same digest, which is what makes cross-package parity checkable.
|
|
226
|
+
*/
|
|
227
|
+
export async function composeDescriptor(input) {
|
|
228
|
+
const kind = parseKind(input.kind);
|
|
229
|
+
const name = parseName(input.name);
|
|
230
|
+
const version = parseVersion(input.version ?? DEFAULT_DESCRIPTOR_VERSION);
|
|
231
|
+
if (!isRecord(input.inputSchema))
|
|
232
|
+
throw new RegistryError("invalid_descriptor");
|
|
233
|
+
const schemaDigest = await sha256HexOf(canonicalJson(input.inputSchema));
|
|
234
|
+
const requiredCapabilities = parseRequiredCapabilities(input.requiredCapabilities);
|
|
235
|
+
const approval = parseApproval(input.approval);
|
|
236
|
+
const retry = parseMember(input.retry, RETRY_CLASSES, "none", "invalid_descriptor");
|
|
237
|
+
const idempotency = parseMember(input.idempotency, IDEMPOTENCY_CLASSES, "none", "invalid_descriptor");
|
|
238
|
+
const isolation = parseMember(input.isolation, ISOLATION_CLASSES, "inherit", "invalid_descriptor");
|
|
239
|
+
return Object.freeze({
|
|
240
|
+
descriptorVersion: CAPABILITY_DESCRIPTOR_VERSION,
|
|
241
|
+
kind,
|
|
242
|
+
name,
|
|
243
|
+
version,
|
|
244
|
+
schemaDigest,
|
|
245
|
+
requiredCapabilities,
|
|
246
|
+
approval: Object.freeze(approval),
|
|
247
|
+
retry,
|
|
248
|
+
idempotency,
|
|
249
|
+
isolation,
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Adapt a Nifra core {@link ToolContract} into a descriptor without touching its execution contract.
|
|
254
|
+
* The schema digest is taken over the tool's own input JSON schema, retry follows idempotency, and
|
|
255
|
+
* the approval policy is carried through unchanged, so the descriptor is a faithful, content-free
|
|
256
|
+
* projection of the contract the runtime already enforces.
|
|
257
|
+
*/
|
|
258
|
+
export function descriptorFromTool(tool, options = {}) {
|
|
259
|
+
return composeDescriptor({
|
|
260
|
+
kind: options.kind ?? "tool",
|
|
261
|
+
name: tool.name,
|
|
262
|
+
...(options.version === undefined ? {} : { version: options.version }),
|
|
263
|
+
inputSchema: toolInputJsonSchema(tool),
|
|
264
|
+
requiredCapabilities: [tool.capability],
|
|
265
|
+
approval: tool.approval,
|
|
266
|
+
retry: tool.idempotency === undefined ? "none" : "idempotent",
|
|
267
|
+
idempotency: tool.idempotency === undefined ? "none" : tool.idempotency.scope,
|
|
268
|
+
isolation: options.isolation ?? "inherit",
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
function identityKey(descriptor) {
|
|
272
|
+
return `${descriptor.kind}${descriptor.name}`;
|
|
273
|
+
}
|
|
274
|
+
function compareDescriptors(a, b) {
|
|
275
|
+
if (a.kind !== b.kind)
|
|
276
|
+
return a.kind < b.kind ? -1 : 1;
|
|
277
|
+
if (a.name !== b.name)
|
|
278
|
+
return a.name < b.name ? -1 : 1;
|
|
279
|
+
if (a.version !== b.version)
|
|
280
|
+
return a.version < b.version ? -1 : 1;
|
|
281
|
+
return 0;
|
|
282
|
+
}
|
|
283
|
+
function canonicalDescriptor(descriptor) {
|
|
284
|
+
return {
|
|
285
|
+
descriptorVersion: descriptor.descriptorVersion,
|
|
286
|
+
kind: descriptor.kind,
|
|
287
|
+
name: descriptor.name,
|
|
288
|
+
version: descriptor.version,
|
|
289
|
+
schemaDigest: descriptor.schemaDigest,
|
|
290
|
+
requiredCapabilities: [...descriptor.requiredCapabilities],
|
|
291
|
+
approval: { ...descriptor.approval },
|
|
292
|
+
retry: descriptor.retry,
|
|
293
|
+
idempotency: descriptor.idempotency,
|
|
294
|
+
isolation: descriptor.isolation,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Compose a deterministic registry snapshot. Descriptors are validated, checked for identity
|
|
299
|
+
* collisions, canonically ordered, and digested. Two descriptors that share a (kind, name) identity
|
|
300
|
+
* fail `descriptor_collision` when their schema digests agree and `schema_drift` when they differ -
|
|
301
|
+
* a drifted schema is a distinct, addressable failure from a duplicate registration. Because the set
|
|
302
|
+
* is sorted before it is digested, the snapshot digest is independent of the input order.
|
|
303
|
+
*/
|
|
304
|
+
export async function composeRegistrySnapshot(descriptors) {
|
|
305
|
+
const validated = descriptors.map((descriptor) => parseCapabilityDescriptor(descriptor));
|
|
306
|
+
const byIdentity = new Map();
|
|
307
|
+
for (const descriptor of validated) {
|
|
308
|
+
const key = identityKey(descriptor);
|
|
309
|
+
const existing = byIdentity.get(key);
|
|
310
|
+
if (existing !== undefined) {
|
|
311
|
+
throw new RegistryError(existing.schemaDigest === descriptor.schemaDigest ? "descriptor_collision" : "schema_drift");
|
|
312
|
+
}
|
|
313
|
+
byIdentity.set(key, descriptor);
|
|
314
|
+
}
|
|
315
|
+
const ordered = [...validated].sort(compareDescriptors);
|
|
316
|
+
const digest = await sha256HexOf(canonicalJson({
|
|
317
|
+
version: REGISTRY_SNAPSHOT_VERSION,
|
|
318
|
+
descriptors: ordered.map(canonicalDescriptor),
|
|
319
|
+
}));
|
|
320
|
+
return Object.freeze({
|
|
321
|
+
version: REGISTRY_SNAPSHOT_VERSION,
|
|
322
|
+
digest,
|
|
323
|
+
descriptors: Object.freeze(ordered),
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAEjE,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAU,CAAA;AACvD,MAAM,CAAC,MA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AAU,CAAC,CAAA;IACjC,CAAC;IACD,MAAM,OAAO,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;IACvD,MAAM,MAAM,GAAG,MAAM,WAAW,CAC9B,aAAa,CAAC;QACZ,OAAO,EAAE,yBAAyB;QAClC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;KAC9C,CAAC,CACH,CAAA;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,OAAO,EAAE,yBAAyB;QAClC,MAAM;QACN,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;KACpC,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nifrajs/agent",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Provider-neutral, typed, resumable agent turns built on Nifra tool contracts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -25,6 +25,16 @@
|
|
|
25
25
|
"bun": "./src/events.ts",
|
|
26
26
|
"types": "./dist/events.d.ts",
|
|
27
27
|
"default": "./dist/events.js"
|
|
28
|
+
},
|
|
29
|
+
"./mount": {
|
|
30
|
+
"bun": "./src/mount.ts",
|
|
31
|
+
"types": "./dist/mount.d.ts",
|
|
32
|
+
"default": "./dist/mount.js"
|
|
33
|
+
},
|
|
34
|
+
"./registry": {
|
|
35
|
+
"bun": "./src/registry.ts",
|
|
36
|
+
"types": "./dist/registry.d.ts",
|
|
37
|
+
"default": "./dist/registry.js"
|
|
28
38
|
}
|
|
29
39
|
},
|
|
30
40
|
"files": [
|
|
@@ -40,7 +50,7 @@
|
|
|
40
50
|
"access": "public"
|
|
41
51
|
},
|
|
42
52
|
"dependencies": {
|
|
43
|
-
"@nifrajs/core": "2.
|
|
53
|
+
"@nifrajs/core": "3.2.0"
|
|
44
54
|
},
|
|
45
55
|
"repository": {
|
|
46
56
|
"type": "git",
|