@jini-ai/core 0.3.1 → 0.4.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/CHANGELOG.md +131 -0
- package/LICENSE +201 -0
- package/README.md +154 -14
- package/dist/agent-tools.d.ts +29 -0
- package/dist/agent-tools.js +2 -0
- package/dist/api-token-auth.d.ts +12 -5
- package/dist/api-token-auth.js +7 -7
- package/dist/bindings.d.ts +16 -5
- package/dist/bindings.js +7 -6
- package/dist/composition.d.ts +41 -0
- package/dist/composition.js +39 -0
- package/dist/contribution-registry.d.ts +16 -0
- package/dist/contribution-registry.js +12 -0
- package/dist/daemon.d.ts +12 -7
- package/dist/daemon.js +21 -9
- package/dist/gated-mutations/actor-identity.d.ts +20 -0
- package/dist/gated-mutations/actor-identity.js +31 -0
- package/dist/gated-mutations/gateway.d.ts +115 -0
- package/dist/gated-mutations/gateway.js +123 -0
- package/dist/gated-mutations/ports.d.ts +27 -0
- package/dist/gated-mutations/ports.js +2 -0
- package/dist/gated-mutations/token.d.ts +95 -0
- package/dist/gated-mutations/token.js +87 -0
- package/dist/gated-mutations.d.ts +5 -0
- package/dist/gated-mutations.js +5 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.js +5 -0
- package/dist/model-facing-tool-errors.d.ts +37 -0
- package/dist/model-facing-tool-errors.js +71 -0
- package/dist/naming.d.ts +31 -0
- package/dist/naming.js +33 -0
- package/dist/origin-validation.d.ts +64 -19
- package/dist/origin-validation.js +43 -33
- package/dist/pack-lifecycle.d.ts +19 -12
- package/dist/pack-lifecycle.js +14 -14
- package/dist/pack.d.ts +41 -13
- package/dist/pack.js +2 -2
- package/dist/primitives/http.d.ts +57 -0
- package/dist/primitives/http.js +2 -0
- package/dist/primitives/ids.d.ts +8 -0
- package/dist/primitives/ids.js +5 -0
- package/dist/primitives/index.d.ts +8 -0
- package/dist/primitives/index.js +8 -0
- package/dist/primitives/json.d.ts +10 -0
- package/dist/primitives/json.js +2 -0
- package/dist/primitives/logger.d.ts +26 -0
- package/dist/primitives/logger.js +17 -0
- package/dist/primitives/paths.d.ts +16 -0
- package/dist/primitives/paths.js +38 -0
- package/dist/primitives/result.d.ts +9 -0
- package/dist/primitives/result.js +2 -0
- package/dist/primitives/time.d.ts +17 -0
- package/dist/primitives/time.js +13 -0
- package/dist/redact.d.ts +43 -8
- package/dist/redact.js +121 -50
- package/dist/registration-kit.d.ts +323 -0
- package/dist/registration-kit.js +396 -0
- package/dist/text/index.d.ts +3 -0
- package/dist/text/index.js +2 -0
- package/dist/text/sanitize-untrusted-text.d.ts +22 -0
- package/dist/text/sanitize-untrusted-text.js +108 -0
- package/dist/token.d.ts +29 -2
- package/dist/token.js +22 -2
- package/dist/tool-registry.d.ts +32 -16
- package/dist/tool-registry.js +11 -11
- package/dist/tool-tokens.js +1 -1
- package/package.json +55 -11
- package/dist/api-token-auth.d.ts.map +0 -1
- package/dist/api-token-auth.js.map +0 -1
- package/dist/bindings.d.ts.map +0 -1
- package/dist/bindings.js.map +0 -1
- package/dist/compose.typecheck.d.ts +0 -2
- package/dist/compose.typecheck.d.ts.map +0 -1
- package/dist/compose.typecheck.js +0 -29
- package/dist/compose.typecheck.js.map +0 -1
- package/dist/daemon.d.ts.map +0 -1
- package/dist/daemon.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal.d.ts.map +0 -1
- package/dist/internal.js.map +0 -1
- package/dist/origin-validation.d.ts.map +0 -1
- package/dist/origin-validation.js.map +0 -1
- package/dist/pack-lifecycle.d.ts.map +0 -1
- package/dist/pack-lifecycle.js.map +0 -1
- package/dist/pack.d.ts.map +0 -1
- package/dist/pack.js.map +0 -1
- package/dist/principal.d.ts.map +0 -1
- package/dist/principal.js.map +0 -1
- package/dist/redact.d.ts.map +0 -1
- package/dist/redact.js.map +0 -1
- package/dist/token.d.ts.map +0 -1
- package/dist/token.js.map +0 -1
- package/dist/tool-registry.d.ts.map +0 -1
- package/dist/tool-registry.js.map +0 -1
- package/dist/tool-tokens.d.ts.map +0 -1
- package/dist/tool-tokens.js.map +0 -1
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The cross-domain half of the agent-tool wiring split: everything a domain's own
|
|
3
|
+
* `tool-registrations.ts` needs that is NOT specific to that domain.
|
|
4
|
+
*
|
|
5
|
+
* Why this file exists at all. Every domain's wiring repeats the same five moves — index its
|
|
6
|
+
* catalog by id, read a handful of fields off `ctx.input`, run the tool's permission check,
|
|
7
|
+
* decorate a shape rejection with the published schema, and then loop the handler map into
|
|
8
|
+
* `ToolRegistration`s behind a build-time risk/schema gate. Those five moves were previously copied
|
|
9
|
+
* per domain inside one shared `assistant/tool-registrations.ts`, which is exactly why that file
|
|
10
|
+
* grew past 2000 lines and why three independent domain slices could not be developed in parallel
|
|
11
|
+
* without colliding on it. Each domain now owns a `tool-registrations.ts` next to its own code and
|
|
12
|
+
* imports the shared moves from here; `assistant/tool-registrations.ts` is reduced to the
|
|
13
|
+
* aggregator that assembles them.
|
|
14
|
+
*
|
|
15
|
+
* The membership test for anything in this file is "would a fourth, not-yet-written domain need
|
|
16
|
+
* it?". Domain-shaped things deliberately stay out: each domain's model-facing `to*View`
|
|
17
|
+
* projections, its dependency-bag builder, its own `DERIVED_RISK_BY_TOOL_ID` slice (a claim about
|
|
18
|
+
* that domain's handlers, so it is maintained where those handlers live), and its unwired-tool set.
|
|
19
|
+
*
|
|
20
|
+
* What is deliberately NOT abstracted here is the authorization DECISION. The host's permission helper
|
|
21
|
+
* performs a check a caller asks for; it never decides that a check is needed. The "one
|
|
22
|
+
* evaluator" rule is a per-tool fact — some domains self-enforce inside their service function and
|
|
23
|
+
* must NOT be double-checked here, others have no service-layer gate at all and must be checked at
|
|
24
|
+
* the handler — and that judgement stays recorded in the domain file next to the handler it
|
|
25
|
+
* describes, where a reviewer reading the handler can see it.
|
|
26
|
+
*/
|
|
27
|
+
import { type ToolExecutionOptions, type ToolHandler, type ToolRegistration } from "./tool-registry.js";
|
|
28
|
+
import type { Result } from "./primitives/index.js";
|
|
29
|
+
import type { AgentToolSideEffect, AgentToolDefinition } from "./agent-tools.js";
|
|
30
|
+
/**
|
|
31
|
+
* Catalog entries use the kernel's AgentToolDefinition. The distinct deletion classification
|
|
32
|
+
* and its rationale live beside that contract in agent-tools.ts: every wiring gate compares
|
|
33
|
+
* classifications for equality, so deleting durable state cannot pass as a milder edit.
|
|
34
|
+
*
|
|
35
|
+
* This remains a structural minimum. A domain may tighten its own catalog, for example by
|
|
36
|
+
* requiring inputSchema for every wired entry or declaring authorization.orPermission for
|
|
37
|
+
* real OR gates. Neither requires importing another domain or loosening its own contract.
|
|
38
|
+
*
|
|
39
|
+
* A domain's independent classification of what its own handlers actually do, keyed by tool id.
|
|
40
|
+
*
|
|
41
|
+
* The point of the type is the point of the pattern: a tool's risk must not be self-declared. A
|
|
42
|
+
* catalog entry that quietly downgraded itself to `sideEffects:'none'` would otherwise become
|
|
43
|
+
* "safe" by editing one word in a file that carries no knowledge of which domain function runs.
|
|
44
|
+
* Each domain's `tool-registrations.ts` maintains its slice next to the handlers it describes, and
|
|
45
|
+
* {@link assertToolIsWirable} refuses to build when the two disagree. An id absent from the map
|
|
46
|
+
* cannot be wired at all, so the conservative default is "refuse", not "assume safe".
|
|
47
|
+
*/
|
|
48
|
+
export type DerivedRiskByToolId = ReadonlyMap<string, AgentToolSideEffect>;
|
|
49
|
+
/**
|
|
50
|
+
* Audit provenance stamped onto every revision row a tool handler writes.
|
|
51
|
+
*
|
|
52
|
+
* A constant, not `ctx.principal`'s own kind, and that is the point: `ctx.principal.id` is the
|
|
53
|
+
* HUMAN admin's principal id — the host's proxy reads it from the browser session and stamps it
|
|
54
|
+
* into the run's `contextRef`, and the daemon hands it back to the handler. So a content-type change made by the assistant and one the same person made by clicking
|
|
55
|
+
* through the admin UI record an identical `actorId`. What distinguishes them is the path, and
|
|
56
|
+
* reaching a `tool-registrations.ts` handler IS the agent path — those handlers are only ever
|
|
57
|
+
* invoked by `@jini-ai/daemon`'s `ToolExecutor` during a run. `'agent'` is therefore a fact about
|
|
58
|
+
* the call site, not a default.
|
|
59
|
+
*/
|
|
60
|
+
export declare const AGENT_TOOL_PRINCIPAL_KIND: "agent";
|
|
61
|
+
/**
|
|
62
|
+
* Actor-class rules that need a human confirmer.
|
|
63
|
+
*
|
|
64
|
+
* `confirmer-must-equal-own-delegatedBy` means "a human must confirm this, and the confirmer must
|
|
65
|
+
* be the principal who delegated". The kit never delivers that through `descriptor.requiresConfirmation`:
|
|
66
|
+
* without a host `ExecutionDelegate`, that flag parks the execution on a promise only
|
|
67
|
+
* `resumeConfirmation` can settle, and nothing would call it (unbounded, too, because
|
|
68
|
+
* `descriptor.timeoutMs`'s timer is armed only AFTER the confirmation await).
|
|
69
|
+
*
|
|
70
|
+
* So a tool carrying this rule is wirable only when its handler was built with
|
|
71
|
+
* {@link humanConfirmedHandler}, which asks the human through the host's own confirmation transport
|
|
72
|
+
* and runs the action only on an explicit yes. Any other handler fails the build.
|
|
73
|
+
*/
|
|
74
|
+
export declare const ACTOR_CLASS_RULES_REQUIRING_CONFIRMATION_TRANSPORT: Set<string>;
|
|
75
|
+
/**
|
|
76
|
+
* The human who confirmed, as {@link humanConfirmedHandler} hands it to `run`: always the run's own
|
|
77
|
+
* delegating principal (`ctx.principal.id`, see {@link AGENT_TOOL_PRINCIPAL_KIND}), always
|
|
78
|
+
* `kind: "user"`. The only thing a `run` step may pass to a confirm step as its confirmer.
|
|
79
|
+
*/
|
|
80
|
+
export interface HumanConfirmer {
|
|
81
|
+
readonly id: string;
|
|
82
|
+
readonly kind: "user";
|
|
83
|
+
}
|
|
84
|
+
/** What the host's transport reports back. Only exactly `confirmed: true` counts as a yes. */
|
|
85
|
+
export type HumanConfirmationAnswer = {
|
|
86
|
+
confirmed: true;
|
|
87
|
+
} | {
|
|
88
|
+
confirmed: false;
|
|
89
|
+
result: unknown;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Builds the one kind of handler a `confirmer-must-equal-own-delegatedBy` tool may be wired with
|
|
93
|
+
* (see {@link ACTOR_CLASS_RULES_REQUIRING_CONFIRMATION_TRANSPORT}).
|
|
94
|
+
*
|
|
95
|
+
* The order is fixed here, not left to each domain: `prepare` (validate, pre-authorize, derive what
|
|
96
|
+
* the human will see) → `askHuman` (the host's transport, e.g. an MCP-UI dialog) → `run`, only when
|
|
97
|
+
* the answer is exactly `{ confirmed: true }`. The decision never comes from `ctx.input`, so nothing
|
|
98
|
+
* the model sends can stand in for the human. `run` gets the confirmer as the delegating human.
|
|
99
|
+
*
|
|
100
|
+
* @param steps.prepare - Reads input and derives what the human is asked about. May throw.
|
|
101
|
+
* @param steps.askHuman - Asks the human through the host's transport. Throws when no human can be
|
|
102
|
+
* asked; a no-answer returns `{ confirmed: false, result }` and `result` is the tool's result.
|
|
103
|
+
* @param steps.run - Performs the action on a yes.
|
|
104
|
+
* Each step receives the invoking transport's execution options as its second argument so
|
|
105
|
+
* the confirmation dialog can be emitted before awaiting the human's answer.
|
|
106
|
+
* @returns A handler {@link assertToolIsWirable} accepts for a tool carrying the rule.
|
|
107
|
+
* @complexity O(1) plus the three steps.
|
|
108
|
+
*/
|
|
109
|
+
export declare function humanConfirmedHandler<TPrepared>(steps: {
|
|
110
|
+
prepare: (required: {
|
|
111
|
+
ctx: Parameters<ToolHandler>[0];
|
|
112
|
+
}, optional?: ToolExecutionOptions) => Promise<TPrepared>;
|
|
113
|
+
askHuman: (required: {
|
|
114
|
+
ctx: Parameters<ToolHandler>[0];
|
|
115
|
+
prepared: TPrepared;
|
|
116
|
+
}, optional?: ToolExecutionOptions) => Promise<HumanConfirmationAnswer>;
|
|
117
|
+
run: (required: {
|
|
118
|
+
ctx: Parameters<ToolHandler>[0];
|
|
119
|
+
prepared: TPrepared;
|
|
120
|
+
confirmer: HumanConfirmer;
|
|
121
|
+
}, optional?: ToolExecutionOptions) => Promise<unknown>;
|
|
122
|
+
}, _optional?: Record<string, never>): ToolHandler;
|
|
123
|
+
/**
|
|
124
|
+
* Indexes a domain catalog by tool id — the single lookup used for descriptors, risk metadata, and
|
|
125
|
+
* schema-bearing error messages.
|
|
126
|
+
*
|
|
127
|
+
* @param required.catalog - The domain's own `agent-tools.ts` catalog array.
|
|
128
|
+
* @returns The catalog keyed by `name`.
|
|
129
|
+
* @complexity O(n) once at module load, O(1) per subsequent lookup.
|
|
130
|
+
* @overallScore 100
|
|
131
|
+
*/
|
|
132
|
+
export declare function indexCatalogById<T extends {
|
|
133
|
+
name: string;
|
|
134
|
+
}>(required: {
|
|
135
|
+
catalog: readonly T[];
|
|
136
|
+
}, _optional?: Record<string, never>): ReadonlyMap<string, T>;
|
|
137
|
+
export declare function isRecord(required: {
|
|
138
|
+
value: unknown;
|
|
139
|
+
}, _optional?: Record<string, never>): required is {
|
|
140
|
+
value: Record<string, unknown>;
|
|
141
|
+
};
|
|
142
|
+
/** Narrows `ctx.input` to a record, refusing anything else. The first line of most handlers. */
|
|
143
|
+
export declare function requireInputRecord(required: {
|
|
144
|
+
input: unknown;
|
|
145
|
+
}, _optional?: Record<string, never>): Record<string, unknown>;
|
|
146
|
+
export declare function requireString(required: {
|
|
147
|
+
input: Record<string, unknown>;
|
|
148
|
+
key: string;
|
|
149
|
+
}, _optional?: Record<string, never>): string;
|
|
150
|
+
export declare function requireNumber(requiredArgs: {
|
|
151
|
+
input: Record<string, unknown>;
|
|
152
|
+
key: string;
|
|
153
|
+
}, optionalArgs?: Record<string, never>): number;
|
|
154
|
+
export declare function requireObject(requiredArgs: {
|
|
155
|
+
input: Record<string, unknown>;
|
|
156
|
+
key: string;
|
|
157
|
+
}, optionalArgs?: Record<string, never>): Record<string, unknown>;
|
|
158
|
+
export declare function optionalString(required: {
|
|
159
|
+
input: Record<string, unknown>;
|
|
160
|
+
key: string;
|
|
161
|
+
}, _optional?: Record<string, never>): string | undefined;
|
|
162
|
+
export declare function optionalNumber(requiredArgs: {
|
|
163
|
+
input: Record<string, unknown>;
|
|
164
|
+
key: string;
|
|
165
|
+
}, optionalArgs?: Record<string, never>): number | undefined;
|
|
166
|
+
export declare function optionalBoolean(requiredArgs: {
|
|
167
|
+
input: Record<string, unknown>;
|
|
168
|
+
key: string;
|
|
169
|
+
}, optionalArgs?: Record<string, never>): boolean | undefined;
|
|
170
|
+
/**
|
|
171
|
+
* The reader for a parameterless tool: `ctx.input` may be omitted entirely or passed as `{}`,
|
|
172
|
+
* nothing else. Refusing a populated object is deliberate — silently ignoring keys would teach a
|
|
173
|
+
* model that a filter it invented was applied.
|
|
174
|
+
*/
|
|
175
|
+
export declare function requireNoInput(required: {
|
|
176
|
+
input: unknown;
|
|
177
|
+
}, _optional?: Record<string, never>): void;
|
|
178
|
+
/**
|
|
179
|
+
* Wraps a `Result<T, Error>`-returning domain call as a value: `ToolExecutor` treats a thrown error
|
|
180
|
+
* as a `'failed'` execution, so an `{ok:false}` becomes a throw rather than a silently-swallowed
|
|
181
|
+
* value.
|
|
182
|
+
*/
|
|
183
|
+
export declare function fromResult<T>(requiredArgs: {
|
|
184
|
+
fn: () => Promise<Result<T>>;
|
|
185
|
+
}, optionalArgs?: Record<string, never>): Promise<T>;
|
|
186
|
+
/**
|
|
187
|
+
* Re-throws a rejection with the tool's published `inputSchema` appended, so a model can correct
|
|
188
|
+
* its call in a single turn instead of guessing the rest of the shape from one field's complaint.
|
|
189
|
+
*
|
|
190
|
+
* `isShapeRejection` is the domain's own decision and has no default: only errors a DIFFERENT input
|
|
191
|
+
* would fix are decorated. A `ForbiddenError` or a slug conflict is not a shape problem, and
|
|
192
|
+
* appending a schema to one would be noise the model must read past — worse, it would imply the
|
|
193
|
+
* call is retryable when it is not.
|
|
194
|
+
*
|
|
195
|
+
* @param spec.toolId - The tool whose schema is published with the failure.
|
|
196
|
+
* @param spec.catalog - The domain catalog, consulted for that schema.
|
|
197
|
+
* @param spec.isShapeRejection - Predicate selecting the errors worth decorating.
|
|
198
|
+
* @param spec.fn - The domain call.
|
|
199
|
+
* @throws The original error unchanged when it is not a shape rejection, or a decorated `Error`
|
|
200
|
+
* when it is. A tool whose catalog entry publishes no schema still gets the retry-is-futile note.
|
|
201
|
+
* @complexity O(1) beyond the wrapped call, plus the schema's own serialization on the failure path.
|
|
202
|
+
* @overallScore 100
|
|
203
|
+
*/
|
|
204
|
+
export declare function withSchemaOnRejection<T>(spec: {
|
|
205
|
+
toolId: string;
|
|
206
|
+
catalog: ReadonlyMap<string, AgentToolDefinition>;
|
|
207
|
+
isShapeRejection: (required: {
|
|
208
|
+
error: unknown;
|
|
209
|
+
}) => boolean;
|
|
210
|
+
fn: () => Promise<T>;
|
|
211
|
+
}, _optional?: Record<string, never>): Promise<T>;
|
|
212
|
+
/**
|
|
213
|
+
* The synchronous half of {@link withSchemaOnRejection}, for a domain that validates BEFORE the
|
|
214
|
+
* call rather than inside it (content-types parses `fields` at a boundary parser, so its rejection
|
|
215
|
+
* never reaches a `try` around a domain call).
|
|
216
|
+
*
|
|
217
|
+
* @returns The `Error` to throw — returned rather than thrown so the caller's own `throw` keeps
|
|
218
|
+
* TypeScript's control-flow narrowing at the call site.
|
|
219
|
+
* @complexity O(s) in the serialized schema size, on the failure path only.
|
|
220
|
+
* @overallScore 100
|
|
221
|
+
*/
|
|
222
|
+
export declare function decorateWithSchema(params: {
|
|
223
|
+
toolId: string;
|
|
224
|
+
catalog: ReadonlyMap<string, AgentToolDefinition>;
|
|
225
|
+
message: string;
|
|
226
|
+
}): Error;
|
|
227
|
+
/**
|
|
228
|
+
* Build-time gate on a single tool's risk metadata: refuses to wire a tool whose declared
|
|
229
|
+
* `sideEffects` disagrees with the wiring layer's own {@link DerivedRiskByToolId} classification,
|
|
230
|
+
* whose id that layer has not classified at all, or whose `actorClassRule` needs a human confirmer
|
|
231
|
+
* its handler does not ask for.
|
|
232
|
+
*
|
|
233
|
+
* Throws rather than warning, and at registration time rather than call time: a metadata
|
|
234
|
+
* inconsistency is a developer error that should stop the daemon booting, not a runtime condition
|
|
235
|
+
* to degrade around.
|
|
236
|
+
*
|
|
237
|
+
* @param params.toolId - The wired tool id.
|
|
238
|
+
* @param params.catalogEntry - Its `agent-tools.ts` entry, the declared side of the comparison.
|
|
239
|
+
* @param params.derivedRisk - The wiring layer's independent classification, the derived side.
|
|
240
|
+
* @param params.handler - The handler being wired; checked only for a tool carrying a rule in
|
|
241
|
+
* {@link ACTOR_CLASS_RULES_REQUIRING_CONFIRMATION_TRANSPORT}.
|
|
242
|
+
* @throws {Error} If the tool is unclassified, misclassified, or needs a human confirmer its handler
|
|
243
|
+
* does not ask for.
|
|
244
|
+
* @complexity O(1) — two map/set lookups.
|
|
245
|
+
* @overallScore 100
|
|
246
|
+
*/
|
|
247
|
+
export declare function assertToolIsWirable(params: {
|
|
248
|
+
toolId: string;
|
|
249
|
+
catalogEntry: AgentToolDefinition;
|
|
250
|
+
derivedRisk: DerivedRiskByToolId;
|
|
251
|
+
}, optional?: {
|
|
252
|
+
handler?: ToolHandler;
|
|
253
|
+
}): void;
|
|
254
|
+
/**
|
|
255
|
+
* Turns one domain's handler map into `ToolRegistration`s, applying every build-time gate the
|
|
256
|
+
* wiring layer owes each tool, and tripwiring on any catalog entry that is neither wired nor
|
|
257
|
+
* explicitly declared unwired.
|
|
258
|
+
*
|
|
259
|
+
* The tripwire is the reason this is one shared function rather than a loop each domain copies.
|
|
260
|
+
* "Add a catalog entry, forget to wire it" is the failure this layer is meant to make impossible,
|
|
261
|
+
* and a per-domain copy of the check is a per-domain opportunity to get it subtly wrong — one of
|
|
262
|
+
* the copies this replaced omitted the schema assertion, another omitted the unwired-set escape
|
|
263
|
+
* hatch. Silence is never the outcome: an unwired entry either appears in `unwiredToolIds` with a
|
|
264
|
+
* recorded reason next to it, or the build fails.
|
|
265
|
+
*
|
|
266
|
+
* `policy.authorize` is a pass-through `'allow'` for every registration, and that is by design
|
|
267
|
+
* rather than an omission: each tool's permission is evaluated exactly once — inside its domain
|
|
268
|
+
* function for the self-enforcing domains, or by the handler's own host permission helper
|
|
269
|
+
* call for the domains whose gate lives in the route. A check here would be a SECOND evaluator of
|
|
270
|
+
* the same rule, and a `ToolPolicy`-only check would be bypassable by any future non-tool caller of
|
|
271
|
+
* the same domain function, which is precisely why the chokepoint owns the gate.
|
|
272
|
+
*
|
|
273
|
+
* `descriptor.requiresConfirmation` is deliberately never set — a tool that needs a human confirm
|
|
274
|
+
* asks inside its own {@link humanConfirmedHandler}; see
|
|
275
|
+
* {@link ACTOR_CLASS_RULES_REQUIRING_CONFIRMATION_TRANSPORT}.
|
|
276
|
+
*
|
|
277
|
+
* @param spec.domain - Human-readable domain name, used only in failure messages.
|
|
278
|
+
* @param spec.catalogModule - Path of the catalog file, named in the drift message so the failure
|
|
279
|
+
* points at the file to edit.
|
|
280
|
+
* @param spec.catalog - That domain's catalog indexed by id (see {@link indexCatalogById}).
|
|
281
|
+
* @param spec.handlers - Tool id to handler. Registration order follows this map's key order.
|
|
282
|
+
* @param spec.derivedRisk - The domain's own risk classification (see {@link DerivedRiskByToolId}).
|
|
283
|
+
* @param optional.unwiredToolIds - Catalog ids deliberately not wired. Omit when the domain wires its
|
|
284
|
+
* entire catalog, which makes ANY unwired entry a build failure.
|
|
285
|
+
* @throws {Error} On catalog drift, an unclassified/misclassified tool, a wired tool publishing no
|
|
286
|
+
* `inputSchema`, or a catalog entry that is neither wired nor declared unwired.
|
|
287
|
+
* @complexity O(h + c) in the handler and catalog counts.
|
|
288
|
+
* @overallScore 100
|
|
289
|
+
*/
|
|
290
|
+
export declare function buildDomainRegistrations(spec: {
|
|
291
|
+
domain: string;
|
|
292
|
+
catalogModule: string;
|
|
293
|
+
catalog: ReadonlyMap<string, AgentToolDefinition>;
|
|
294
|
+
handlers: Record<string, ToolHandler>;
|
|
295
|
+
derivedRisk: DerivedRiskByToolId;
|
|
296
|
+
}, optional?: {
|
|
297
|
+
unwiredToolIds?: ReadonlySet<string>;
|
|
298
|
+
}): ToolRegistration[];
|
|
299
|
+
/**
|
|
300
|
+
* Folds every domain's risk slice into the one map the assistant-level
|
|
301
|
+
* `assertRiskMetadataIsWirable(toolId, catalogEntry)` consults, refusing any id two domains both
|
|
302
|
+
* claim.
|
|
303
|
+
*
|
|
304
|
+
* That refusal is the structural answer to the failure this restructure was prompted by: three
|
|
305
|
+
* domain slices were developed in parallel, each checking its new ids only against the ids that
|
|
306
|
+
* existed before it started, so a name two of them both picked would have been discovered at
|
|
307
|
+
* runtime as a silently double-registered tool. A cross-domain id collision now fails the build.
|
|
308
|
+
* The one real collision in the current catalogs — `backup_create_restore_point`, declared by both
|
|
309
|
+
* Database and Recovery — passes because Recovery declares it unwired and therefore contributes no
|
|
310
|
+
* risk entry for it, which is exactly the resolution this check is meant to force.
|
|
311
|
+
*
|
|
312
|
+
* @param slices - Each domain's name (for the failure message) and its own risk map.
|
|
313
|
+
* @throws {Error} If two domains classify the same tool id.
|
|
314
|
+
* @complexity O(t) in the total classified-tool count.
|
|
315
|
+
* @overallScore 100
|
|
316
|
+
*/
|
|
317
|
+
export declare function mergeDerivedRiskMaps(requiredArgs: {
|
|
318
|
+
slices: readonly {
|
|
319
|
+
domain: string;
|
|
320
|
+
risk: DerivedRiskByToolId;
|
|
321
|
+
}[];
|
|
322
|
+
}, optionalArgs?: Record<string, never>): DerivedRiskByToolId;
|
|
323
|
+
//# sourceMappingURL=registration-kit.d.ts.map
|