@jini-ai/core 0.3.0 → 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/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 +9 -3
- package/dist/index.js +6 -1
- 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 +60 -14
- package/dist/tool-registry.js +24 -9
- package/dist/tool-tokens.js +1 -1
- package/package.json +51 -7
- 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
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# @jini-ai/core
|
|
2
|
+
|
|
3
|
+
## 0.4.0 — 2026-10-02
|
|
4
|
+
|
|
5
|
+
### BREAKING
|
|
6
|
+
|
|
7
|
+
- Canonical primitive ports, JSON/time/HTTP types and tool contracts now live in core; use ./composition instead of ./internal and ./text for untrusted-text handling.
|
|
8
|
+
- Distribution includes runtime output, release documentation and required assets only. Process records and per-job neutrality checks are no longer part of the package surface.
|
|
9
|
+
|
|
10
|
+
## Unreleased
|
|
11
|
+
|
|
12
|
+
- Add browser-safe `pathContains` to `./primitives` for absolute lexical paths, with host-selected case sensitivity and complete directory-segment boundaries.
|
|
13
|
+
|
|
14
|
+
### Shared registration wiring
|
|
15
|
+
|
|
16
|
+
- Move the domain-independent catalog/input/schema/risk/confirmation registration kit into the root entry, with its behavior contracts. Domain-specific authorization and denial errors remain outside the kernel.
|
|
17
|
+
- Use the existing named argument surface directly; primitive, Result and tool catalog types remain canonical in core.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Shared kernel
|
|
21
|
+
|
|
22
|
+
- Add `./primitives` with canonical time, ID, JSON, HTTP, logger and result contracts,
|
|
23
|
+
system/crypto/console default adapters, and UTC time helpers. No runtime dependencies.
|
|
24
|
+
- Add root agent-tool catalog types, preserving delete as a distinct risk classification.
|
|
25
|
+
- Add `./text` with the unchanged bounded terminal sanitizer and its behavior tests.
|
|
26
|
+
- Expand telemetry redaction to the union of core, CLI and provider rules, with literal
|
|
27
|
+
exact-secret masking and named extra patterns. Export the eleven diagnostics credential
|
|
28
|
+
regexes unchanged. Broader opaque/short bearer/header/query rules can mask more input;
|
|
29
|
+
union vectors and existing category tests document the behavior.
|
|
30
|
+
- Add UTF-8 `timingSafeTokenMatch` with a required injected native comparison port so the
|
|
31
|
+
kernel stays universal. Both original native comparators have identical results.
|
|
32
|
+
|
|
33
|
+
### BREAKING — shared kernel
|
|
34
|
+
|
|
35
|
+
- Rename `./internal` to `./composition` without an alias. Authorized tool invocation and
|
|
36
|
+
pack binding derivation keep their implementation and security boundary.
|
|
37
|
+
- Gated mutations now require `Clock.nowMs()` and `IdGenerator.newId()` from primitives,
|
|
38
|
+
replacing the local `ClockPort.nowIso({})` and `IdGeneratorPort.newId({})`. Format clock
|
|
39
|
+
samples with `nowIso({ clock })`; approval order, TTL and wire timestamps are unchanged.
|
|
40
|
+
- Origin diagnostics use `Pick<Logger, 'warn'>` rather than a duplicate logger interface.
|
|
41
|
+
The alias name `OriginValidationLoggerPort` remains available with the shared shape.
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
- Add transport-neutral gated mutations with required token generation/TTL and async
|
|
45
|
+
authorization, identity and token-store ports; preserve verified-plan handoff and
|
|
46
|
+
single-use redemption, with atomic explicit expiry and duplicate-issuance rejection.
|
|
47
|
+
- Add domain-owned model-facing error allowlists, an instance-owned contribution
|
|
48
|
+
registry, and bounded naming with required collision, suffix and message policies.
|
|
49
|
+
- Add generalized approval, disclosure, registry and naming contract tests plus a
|
|
50
|
+
package-wide source-neutrality guard. Verification is deferred by owner directive;
|
|
51
|
+
the four subpath manifest exports are listed in `extraction-w4a.md` for coordination.
|
|
52
|
+
|
|
53
|
+
### Extraction integration
|
|
54
|
+
|
|
55
|
+
- Publish `./gated-mutations`, `./model-facing-tool-errors`, `./contribution-registry`
|
|
56
|
+
and `./naming`, with universal runtime metadata and matching root barrel exports.
|
|
57
|
+
These entries implement the earlier manifest follow-ups in `extraction-w4a.md`;
|
|
58
|
+
no runtime dependency or version change is required.
|
|
59
|
+
- BREAKING: Existing core APIs now accept a required-args object and a separate
|
|
60
|
+
optional-args object. Tokens, bindings, registry lookups, pack callbacks/lifecycle,
|
|
61
|
+
redaction, auth/origin helpers, ToolInputError and internal authorization changed
|
|
62
|
+
shape with no compatibility adapters. Environment snapshots are explicit, origin
|
|
63
|
+
logging uses a supplied port, and optional handler emitSurface moved to the second
|
|
64
|
+
argument. Update consumers before adopting this release. Version unchanged.
|
|
65
|
+
- BREAKING: New extraction APIs follow the same convention: contribution
|
|
66
|
+
`list({})`/`clear({})`, `new InMemoryTokenStore({})`/`count({})`, approval
|
|
67
|
+
`computePlan({})`, `nowIso({})`, `newId({})` and `generateToken({})`, and marker-error
|
|
68
|
+
constructors `new ErrorClass({ message }, { cause? })`. `ForbiddenError` additionally
|
|
69
|
+
requires `reasonCode`; naming exhaustion callbacks receive `{ base, maxAttempts }`.
|
|
70
|
+
`AuthorizeFn` moves optional `entityType`/`entityId` selectors to its second object.
|
|
71
|
+
- Add package-entry identity, manifest/runtime, approval-port, error-cause and
|
|
72
|
+
convention contract tests. Extend the source-neutrality guard to the manifest.
|
|
73
|
+
All verification remains not run (owner directive).
|
|
74
|
+
|
|
75
|
+
## 0.1.2
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- Add top-level `main`/`types` fields alongside the existing `exports` map. A consumer on
|
|
80
|
+
TypeScript's classic `moduleResolution: "node"` (node10) — which ignores `package.json#exports`
|
|
81
|
+
entirely — could not resolve this package's types at all (`TS2307: Cannot find module`) even
|
|
82
|
+
after the previous exports-map fix restored `require()` at runtime; type resolution and runtime
|
|
83
|
+
resolution are separate algorithms. Verified against a real external consumer (whose
|
|
84
|
+
tsconfig uses this legacy resolution mode): adding these two fields, with its tsconfig completely
|
|
85
|
+
unchanged, made the error disappear. Also fixes absolute-path `require()` (distinct from a bare
|
|
86
|
+
specifier, which already worked) for the same reason — `main` was previously absent.
|
|
87
|
+
|
|
88
|
+
Purely additive: every modern resolver (Node's own runtime `exports` resolution, TypeScript's
|
|
89
|
+
`bundler`/`node16`/`nodenext`) prefers `exports` over `main`/`types` when both are present, so
|
|
90
|
+
this changes nothing for a consumer already on a modern resolver.
|
|
91
|
+
|
|
92
|
+
## 0.1.1
|
|
93
|
+
|
|
94
|
+
### Patch Changes
|
|
95
|
+
|
|
96
|
+
- Add a `"default"` export condition to every published package's `exports` map — every one of
|
|
97
|
+
them lacked it, which meant `require()` failed with `ERR_PACKAGE_PATH_NOT_EXPORTED` for any
|
|
98
|
+
CommonJS consumer (found via a real external integration attempt; Node needs `require(esm)`
|
|
99
|
+
support, i.e. Node >=22.12, for this to resolve).
|
|
100
|
+
|
|
101
|
+
`@jini-ai/agent-runtime`:
|
|
102
|
+
|
|
103
|
+
- **New**: `RuntimeBuildOptions.permissionMode` (`'bypass' | 'restricted'`) lets a caller opt a
|
|
104
|
+
run OUT of the auto-approve-every-permission-prompt flag every def with one
|
|
105
|
+
(`bypassPermissions` / `--yolo` / `--dangerously-skip-permissions`) previously pushed
|
|
106
|
+
unconditionally, with no way to turn it off. Omitting it keeps today's default (bypass)
|
|
107
|
+
behavior unchanged.
|
|
108
|
+
- **New**: `ClaudeStreamEvent`, `CopilotStreamEvent`, and `QoderEvent` are now real exported
|
|
109
|
+
discriminated unions instead of `Record<string, unknown>` — a real external consumer guessed a
|
|
110
|
+
nonexistent field name (`event.text` instead of the actual `event.delta`) against the old
|
|
111
|
+
untyped sink and silently lost every streamed token with no compile or runtime error.
|
|
112
|
+
- Fixed a doc/implementation mismatch in `claude-stream.ts`: the module doc claimed `tool_result`
|
|
113
|
+
events carry `{ tool_use_id, content, is_error }`; the actual emitted shape is
|
|
114
|
+
`{ toolUseId, content, isError }`.
|
|
115
|
+
|
|
116
|
+
`@jini-ai/daemon`: `AgentExecutorRunInput.permissionMode` forwards the new
|
|
117
|
+
`RuntimeBuildOptions.permissionMode` through to `buildArgs`, so a host can actually reach the new
|
|
118
|
+
opt-out from the daemon's real run-input surface, not just from `@jini-ai/agent-runtime` in
|
|
119
|
+
isolation.
|
|
120
|
+
|
|
121
|
+
`@jini-ai/agentic`: `setAtPointer` no longer throws on a malformed (e.g. missing leading `/`)
|
|
122
|
+
`updateDataModel` path — degrades to a no-op like its sibling `getAtPointer`, matching this
|
|
123
|
+
package's own "a bad binding must not crash the renderer" contract. That path is agent-authored
|
|
124
|
+
wire data with no error boundary above it in any host, so the uncaught throw could unmount an
|
|
125
|
+
entire chat UI from ~40 bytes of malformed input.
|
|
126
|
+
|
|
127
|
+
`@jini-ai/chat-react`: a local (client-resolved) A2UI button action is no longer a silent no-op —
|
|
128
|
+
`A2uiSurfaceCard` now surfaces the resolved value. New `ExtEventErrorBoundary` confines a
|
|
129
|
+
`kind: 'ext'` event group's renderer to its own card instead of letting a render/effect-phase
|
|
130
|
+
throw from agent-controlled content unmount the whole chat root (there was no error boundary
|
|
131
|
+
anywhere in this package or its hosts before this).
|
package/README.md
CHANGED
|
@@ -19,17 +19,17 @@ No peer dependencies — this package is pure TypeScript with no runtime depende
|
|
|
19
19
|
|
|
20
20
|
## What you get
|
|
21
21
|
|
|
22
|
-
- **DI tokens** — `token<T>(id)` / `manyToken<T>(id)`, nominal and versioned, plus `bindings()`
|
|
22
|
+
- **DI tokens** — `token<T>({ id }, { version? })` / `manyToken<T>({ id }, { version? })`, nominal and versioned, plus `bindings({})`
|
|
23
23
|
building a typed `Bindings<BoundIds>` set (`.bind`, `.bindMany`) that tracks which ids are bound
|
|
24
24
|
in its own type parameter.
|
|
25
|
-
- **Pack composition** — `definePack({ name, deps, services, tools?, http?, cli?, dispose? })`,
|
|
26
|
-
the `Pack`/`PackContainer` types, and `createDaemon({ packs, bindings, transports? })`, which
|
|
25
|
+
- **Pack composition** — `definePack({ name, deps, services }, { tools?, http?, cli?, dispose? })`,
|
|
26
|
+
the `Pack`/`PackContainer` types, and `createDaemon({ packs, bindings }, { transports? })`, which
|
|
27
27
|
composes packs against bound tokens and resolves each pack's `services` against a container
|
|
28
28
|
scoped to only that pack's declared `deps`.
|
|
29
29
|
- **Pack lifecycle helpers** — `registerPackTools` (walks composed packs' `tools()` into a shared
|
|
30
30
|
`ToolRegistry`) and `disposePacks` (best-effort reverse-order teardown; one pack's `dispose`
|
|
31
31
|
failure never blocks another's, recorded as `PackDisposalFailure`).
|
|
32
|
-
- **Tool registry** — `createToolRegistry()` and the `ToolRegistry`/`ToolDescriptor`/`ToolPolicy`/
|
|
32
|
+
- **Tool registry** — `createToolRegistry({})` and the `ToolRegistry`/`ToolDescriptor`/`ToolPolicy`/
|
|
33
33
|
`ToolHandler`/`ToolRegistration`/`ToolAuthorizationContext`/`AuthorizationDecision` types. The
|
|
34
34
|
registry's public surface (`register`/`has`/`list`) exposes descriptors only — handlers and
|
|
35
35
|
policies are never publicly retrievable, so holding a `ToolRegistry` reference lets you enumerate
|
|
@@ -47,45 +47,59 @@ No peer dependencies — this package is pure TypeScript with no runtime depende
|
|
|
47
47
|
import { bindings, definePack, createDaemon, token, createToolRegistry, registerPackTools } from '@jini-ai/core';
|
|
48
48
|
|
|
49
49
|
interface Logger {
|
|
50
|
-
log(
|
|
50
|
+
log(required: { message: string }): void;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
const LoggerToken = token<Logger>('app.logger');
|
|
53
|
+
const LoggerToken = token<Logger>({ id: 'app.logger' });
|
|
54
54
|
|
|
55
55
|
const loggerPack = definePack({
|
|
56
56
|
name: 'logger',
|
|
57
57
|
deps: [],
|
|
58
|
-
services: () => ({ logger: { log: (
|
|
58
|
+
services: () => ({ logger: { log: ({ message }: { message: string }) => console.log(message) } }),
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
const consumerPack = definePack({
|
|
62
62
|
name: 'consumer',
|
|
63
63
|
deps: [LoggerToken],
|
|
64
|
-
services: (c) => ({ logger: c.get(LoggerToken) }),
|
|
64
|
+
services: (c) => ({ logger: c.get({ token: LoggerToken }) }),
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
const bound = bindings().bind(LoggerToken, { log: (
|
|
67
|
+
const bound = bindings({}).bind({ token: LoggerToken, impl: { log: ({ message }: { message: string }) => console.log(message) } });
|
|
68
68
|
|
|
69
69
|
const daemon = createDaemon({
|
|
70
70
|
packs: [loggerPack, consumerPack] as const,
|
|
71
71
|
bindings: bound,
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
-
const registry = createToolRegistry();
|
|
75
|
-
registerPackTools([loggerPack, consumerPack], daemon
|
|
74
|
+
const registry = createToolRegistry({});
|
|
75
|
+
registerPackTools({ registry, packs: [loggerPack, consumerPack], daemon });
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
+
Every callable takes a required object and, when needed, a separate optional object. Factories
|
|
79
|
+
with no required values take `{}`. Registry lookups use `registry.has({ toolId })` and
|
|
80
|
+
`registry.list({})`; registration already takes the required `{ descriptor, handler, policy }`.
|
|
81
|
+
Pack tools/disposal callbacks receive `{ services }`; HTTP and CLI callbacks receive
|
|
82
|
+
`{ app, services }` and `{ reg, services }`. A pack's services factory still receives its scoped
|
|
83
|
+
`PackContainer` port object directly.
|
|
84
|
+
|
|
85
|
+
Auth and origin helpers require `{ config, env }`, with `env` supplied by the host. For example,
|
|
86
|
+
`apiTokenFromEnv({ config, env: environmentSnapshot })`. `isLocalSameOrigin` additionally requires
|
|
87
|
+
`req` and `port`. Malformed-origin diagnostics go through the optional `{ logger }` port, whose
|
|
88
|
+
`warn({ message })` method the host supplies. No process environment or console logger is read.
|
|
89
|
+
Redaction takes `{ input }` and optional `{ exactSecrets, extraPatterns }`, and `ToolInputError` takes `{ message }` plus optional `{ cause }`.
|
|
90
|
+
Tool handlers receive required execution context first and optional `{ emitSurface }` second.
|
|
91
|
+
|
|
78
92
|
## Entry points
|
|
79
93
|
|
|
80
94
|
| subpath | what's behind it |
|
|
81
95
|
|---|---|
|
|
82
96
|
| `.` | The public surface above: tokens, packs, daemon composition, tool registry (descriptors only), principal, redact, auth primitives. |
|
|
83
|
-
| `./
|
|
97
|
+
| `./composition` | **Not part of the public contract.** Exposes `authorizeToolInvocation` (resolves a registry's tool and runs its authorization gate — a security-sensitive value export, but one that only ever hands back a handler alongside an `'allow'` decision) plus type-only `AnyPack`/`RequiredTokenIds`/`MissingTokenIds` re-derivation helpers. Its sole intended consumers are `@jini-ai/daemon`'s `ToolExecutor` and `@jini-ai/server`'s `createLocalNodeDaemon`. Node's resolver will happily let any consumer import it — the boundary is enforced by `scripts/check-engine-boundaries.ts`, not by the exports map — so external adopters should treat it as off-limits regardless. |
|
|
84
98
|
|
|
85
99
|
## What's swappable
|
|
86
100
|
|
|
87
101
|
Everything a pack declares as a `deps` token is a swap point by construction: bind any
|
|
88
|
-
implementation that satisfies the token's type via `bindings().bind(...)`, and `createDaemon`
|
|
102
|
+
implementation that satisfies the token's type via `bindings({}).bind(...)`, and `createDaemon`
|
|
89
103
|
resolves it into that pack's `PackContainer` with no other change. `ToolPolicy.authorize` is
|
|
90
104
|
likewise a seam you supply per tool registration. The kernel logic itself (composition ordering,
|
|
91
105
|
the missing-binding compile-time gate, the tool registry's append-only enforcement) is fixed and
|
|
@@ -98,4 +112,130 @@ ESM only — ships `"type": "module"` with no CommonJS `require` build.
|
|
|
98
112
|
|
|
99
113
|
## Provenance
|
|
100
114
|
|
|
101
|
-
See
|
|
115
|
+
See the archived provenance ledger for per-file provenance and scope decisions. Apache-2.0.
|
|
116
|
+
|
|
117
|
+
## Additional entry points
|
|
118
|
+
|
|
119
|
+
The four entries below also have named exports from the package root. Each is universal
|
|
120
|
+
and has no runtime dependency. Importing the root and a subpath shares the same
|
|
121
|
+
class and factory identities.
|
|
122
|
+
|
|
123
|
+
| Subpath | API and required ports |
|
|
124
|
+
|---|---|
|
|
125
|
+
| `./gated-mutations` | `plan`, `confirm`, `execute`, `authorizeForHooks`; authorization, clock, ID generation, complete opaque token generation, TTL, token store and mutation hooks. Includes token lifecycle and composite actor-reference helpers. |
|
|
126
|
+
| `./model-facing-tool-errors` | `forbiddenRule`, `reclassifyToolError`, `withModelFacingErrors`, `withModelFacingRegistrationErrors`, `callerSafeErrorMessage`; callers own ordered error allowlists and fallback wording. |
|
|
127
|
+
| `./contribution-registry` | `createContributionRegistry({ keyOf })`; instance-owned replacement by key, with detached array snapshots. |
|
|
128
|
+
| `./naming` | `deriveAvailableName`, `deriveDuplicateName`, `MAX_SUFFIX_ATTEMPTS`; required collision predicate, suffix formatter and exhaustion message policy. |
|
|
129
|
+
|
|
130
|
+
Contribution registries use `register({ contribution })`, `list({})` and `clear({})`.
|
|
131
|
+
Approval clock/ID ports use the shared zero-argument `Clock.nowMs()` and
|
|
132
|
+
`IdGenerator.newId()` getters. Token generation and `hooks.computePlan` still receive
|
|
133
|
+
an empty required object. `AuthorizeFn` takes `{ principalId, permission, workspaceId }` with optional
|
|
134
|
+
`{ entityType, entityId }` in the second object. The memory token adapter uses
|
|
135
|
+
`new InMemoryTokenStore({})` and `count({})`;
|
|
136
|
+
its persistence methods already accept named objects. Marker errors use
|
|
137
|
+
`new TokenExpiredError({ message }, { cause })` (and the same shape for the other
|
|
138
|
+
approval/actor marker errors). `ForbiddenError` also requires a `reasonCode`.
|
|
139
|
+
Error class identity, existing messages and authorization/redemption ordering are
|
|
140
|
+
preserved. The host supplies transaction/locking policy and hashes the full intent.
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
import { createContributionRegistry } from '@jini-ai/core/contribution-registry';
|
|
144
|
+
import { deriveDuplicateName } from '@jini-ai/core/naming';
|
|
145
|
+
|
|
146
|
+
const registry = createContributionRegistry({
|
|
147
|
+
keyOf: ({ contribution }: { contribution: { domain: string } }) => contribution.domain,
|
|
148
|
+
});
|
|
149
|
+
registry.register({ contribution: { domain: 'example' } });
|
|
150
|
+
const snapshot = registry.list({});
|
|
151
|
+
registry.clear({});
|
|
152
|
+
|
|
153
|
+
const existing = new Set(['Example', 'Example 2']);
|
|
154
|
+
const duplicateName = await deriveDuplicateName({
|
|
155
|
+
sourceName: 'Example',
|
|
156
|
+
isTaken: async ({ candidate }) => existing.has(candidate),
|
|
157
|
+
withSuffix: ({ base, suffix }) => `${base} ${suffix}`,
|
|
158
|
+
exhaustionMessage: ({ base, maxAttempts }) => `No name available for ${base} after ${maxAttempts} attempts`,
|
|
159
|
+
}, { maxAttempts: 1000 }); // 'Example 3'
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Naming's optional `onExhausted({ base, maxAttempts })` port must throw. Approval token
|
|
163
|
+
stores must insert without overwriting issuance and atomically redeem/expire tokens;
|
|
164
|
+
`InMemoryTokenStore` provides that contract for tests and requires host retention policy
|
|
165
|
+
for long-lived use. There is no application layout, environment name or storage default.
|
|
166
|
+
|
|
167
|
+
The existing kernel APIs have also changed to object arguments. Update token/binding
|
|
168
|
+
calls, pack contributions, handler emitters and explicit environment snapshots before
|
|
169
|
+
using this unreleased version; see [CHANGELOG.md](./CHANGELOG.md) for BREAKING notes.
|
|
170
|
+
|
|
171
|
+
## Design decisions
|
|
172
|
+
|
|
173
|
+
- [Confirmation checks have a fixed order and atomic redemption](docs/decisions/DR-001-gated-mutation-check-order.md).
|
|
174
|
+
|
|
175
|
+
## Shared kernel contracts
|
|
176
|
+
|
|
177
|
+
Import `Clock`, `IdGenerator`, `UUID`, `ISODateTime`, `JsonPrimitive`, `JsonValue`,
|
|
178
|
+
`JsonObject`, `JsonArray`, `HttpRequest`, `HttpResponse`, `RequestRedirect`, `HttpClientPort`,
|
|
179
|
+
`Logger` and `Result` from `@jini-ai/core/primitives`. They are canonical structural types;
|
|
180
|
+
UUIDs and timestamps remain unbranded strings. The HTTP contract includes binary response
|
|
181
|
+
bytes, redirect provenance, socket idle budgets and an optional total deadline. Platform
|
|
182
|
+
supplies the guarded HTTP implementation; core defines the port only.
|
|
183
|
+
|
|
184
|
+
Default adapters are `createSystemClock()`, `createRandomUuidGenerator()` and
|
|
185
|
+
`createConsoleLogger({ prefix })`. Clock/ID getters take no arguments. Time helpers are
|
|
186
|
+
`toIsoDateTime({ epochMs })` and `nowIso({ clock })`. The UUID adapter requires a host
|
|
187
|
+
cryptographic UUID implementation and fails if unavailable. The console adapter routes
|
|
188
|
+
info/warn/error with optional `{ meta, error }` to the same console severity.
|
|
189
|
+
|
|
190
|
+
Agent-tool catalogs import `AgentToolSideEffect`, `AgentToolActorClassRule` and
|
|
191
|
+
`AgentToolDefinition` from the core root. Delete is a separate side-effect classification;
|
|
192
|
+
domains may tighten the shared interface, including making `inputSchema` required.
|
|
193
|
+
|
|
194
|
+
`@jini-ai/core/text` exports `sanitizeUntrustedText({ text }, { maxLength? })` and
|
|
195
|
+
`SanitizeTextOptions`. This terminal-boundary policy strips C0/C1 and ANSI control
|
|
196
|
+
sequences, masks labeled/opaque credentials and caps the complete output at 500 characters
|
|
197
|
+
by default. Correlation IDs and the delegated-tool route remain visible. This sanitizer
|
|
198
|
+
keeps its existing policy; the telemetry redactor additionally masks PII.
|
|
199
|
+
|
|
200
|
+
`redactSecrets` and `redactSecretsWithCounts` cover the core, CLI and provider rule union.
|
|
201
|
+
Exact secrets are literal strings (including regex metacharacters), applied longest first;
|
|
202
|
+
null/undefined/empty entries are ignored. Extra patterns are `{ name, regex }` entries, cloned
|
|
203
|
+
and made global so caller `lastIndex` state is unchanged. `SECRET_SHAPE_PATTERNS` exports
|
|
204
|
+
the eleven unchanged diagnostics vendor regexes; diagnostics retains its secret-only policy.
|
|
205
|
+
Core's full redactor is conservative and can mask long ordinary identifiers as opaque tokens.
|
|
206
|
+
|
|
207
|
+
`timingSafeTokenMatch({ presented, expected, timingSafeEqual })` encodes UTF-8, rejects unequal
|
|
208
|
+
byte lengths, and calls the required native byte comparator with `{ left, right }`.
|
|
209
|
+
Node hosts inject `({ left, right }) => crypto.timingSafeEqual(left, right)`; this keeps the
|
|
210
|
+
universal root free of Node imports while preserving native timing guarantees. No JavaScript
|
|
211
|
+
equality fallback is provided. The root does not expose `authorizeToolInvocation`; that gate
|
|
212
|
+
and the pack binding derivation types live at `@jini-ai/core/composition`.
|
|
213
|
+
|
|
214
|
+
Origin classifiers implement the dev-browser LAN allow-list. They allow private addresses
|
|
215
|
+
for local development; use `@jini-ai/platform/net` for SSRF classification. Origin validation
|
|
216
|
+
uses only an injected environment snapshot and optional `Pick<Logger, 'warn'>` diagnostics.
|
|
217
|
+
|
|
218
|
+
## Agent tool registration
|
|
219
|
+
|
|
220
|
+
The root exports `AgentToolDefinition`, `AgentToolSideEffect`, `AgentToolActorClassRule` and
|
|
221
|
+
the shared registration kit: catalog indexing, named input readers, schema-bearing refusals,
|
|
222
|
+
independent risk gates, registration assembly, risk-map merging and human-confirmed handlers.
|
|
223
|
+
This wiring is domain-independent. A domain may require `inputSchema` through an intersection
|
|
224
|
+
with `AgentToolDefinition`; it must still independently classify the effects its handlers perform.
|
|
225
|
+
|
|
226
|
+
Use `indexCatalogById({ catalog })`, `requireInputRecord({ input })`,
|
|
227
|
+
`requireString({ input, key })`, `optionalString({ input, key })`, and
|
|
228
|
+
`withSchemaOnRejection({ toolId, catalog, isShapeRejection: ({ error }) => predicate(error), fn })`.
|
|
229
|
+
`buildDomainRegistrations(required, { unwiredToolIds })` refuses metadata/schema drift and
|
|
230
|
+
unclassified or accidentally unwired tools. Domain-specific authorization decisions and denial
|
|
231
|
+
classes remain in the domain or host; registration policy is pass-through after those gates.
|
|
232
|
+
|
|
233
|
+
## Pure path containment
|
|
234
|
+
|
|
235
|
+
`@jini-ai/core/primitives` exports `pathContains({ root, target }, { caseSensitive?, separator? })`.
|
|
236
|
+
Both paths must already be absolute; the host resolves cwd-relative paths and
|
|
237
|
+
symlinks. The helper performs lexical segment normalization without importing
|
|
238
|
+
Node or reading a working directory. Equality counts as contained. Directory
|
|
239
|
+
prefix siblings and traversal escapes are rejected; a legal `..name` segment is
|
|
240
|
+
allowed. Windows hosts pass `{ caseSensitive: false, separator: "\\\\" }`; POSIX hosts
|
|
241
|
+
retain the default slash separator so backslashes in directory names remain literal.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared vocabulary for independently classified agent-tool catalogs.
|
|
3
|
+
*
|
|
4
|
+
* `deletes-durable-state` is a distinct member rather than a flavor of `mutates-durable-state`, and
|
|
5
|
+
* the distinction is load-bearing rather than cosmetic. Wiring gates compare the two
|
|
6
|
+
* classifications for EQUALITY, so the strength of the check is exactly the resolution of the
|
|
7
|
+
* vocabulary: folding a delete into `mutates-durable-state` would let a tool that removes content
|
|
8
|
+
* from every read path carry the same declared risk as one that edits a title, and
|
|
9
|
+
* the wiring gate would have nothing to object to. A separate member means a delete tool
|
|
10
|
+
* whose declaration drifts toward the milder classification fails the build.
|
|
11
|
+
*
|
|
12
|
+
* Narrower domain-owned unions remain assignable to this shared vocabulary. Domains may tighten
|
|
13
|
+
* their own catalogs without loosening the classification required by the wiring gate.
|
|
14
|
+
*/
|
|
15
|
+
export type AgentToolSideEffect = "none" | "mutates-durable-state" | "deletes-durable-state" | "mints-token";
|
|
16
|
+
export type AgentToolActorClassRule = "confirmer-must-equal-own-delegatedBy" | "user-only" | "none";
|
|
17
|
+
/** Structural catalog contract. Domains may require inputSchema or tighten their own metadata. */
|
|
18
|
+
export interface AgentToolDefinition {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
sideEffects: AgentToolSideEffect;
|
|
22
|
+
authorization: {
|
|
23
|
+
permission: string;
|
|
24
|
+
orPermission?: string;
|
|
25
|
+
};
|
|
26
|
+
actorClassRule?: AgentToolActorClassRule;
|
|
27
|
+
inputSchema?: Readonly<Record<string, unknown>>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=agent-tools.d.ts.map
|
package/dist/api-token-auth.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Whether a bearer-style API token gate should be enforced, and what the
|
|
5
5
|
* expected token value is. Generalized from an upstream flat daemon module:
|
|
6
6
|
* the origin hardcoded its host product's env-var names, now fields on
|
|
7
|
-
* {@link ApiTokenAuthEnvConfig} — see `
|
|
7
|
+
* {@link ApiTokenAuthEnvConfig} — see `archived provenance ledger` for the exact mapping.
|
|
8
8
|
*/
|
|
9
9
|
/** Names the env vars this port reads. */
|
|
10
10
|
export interface ApiTokenAuthEnvConfig {
|
|
@@ -18,11 +18,18 @@ export interface ApiTokenAuthEnvConfig {
|
|
|
18
18
|
* (case-insensitive, trimmed). Anything else, including `undefined`, is
|
|
19
19
|
* falsy.
|
|
20
20
|
*/
|
|
21
|
-
export declare function isTruthyEnvFlag(value
|
|
21
|
+
export declare function isTruthyEnvFlag({ value }: {
|
|
22
|
+
value: unknown;
|
|
23
|
+
}): boolean;
|
|
24
|
+
/** Explicit environment snapshot; no process-global reads. */
|
|
25
|
+
export interface ApiTokenAuthArgs {
|
|
26
|
+
config: ApiTokenAuthEnvConfig;
|
|
27
|
+
env: Readonly<Record<string, string | undefined>>;
|
|
28
|
+
}
|
|
22
29
|
/** Whether the API auth gate has been explicitly force-disabled. */
|
|
23
|
-
export declare function isApiAuthDisabled(config
|
|
30
|
+
export declare function isApiAuthDisabled({ config, env }: ApiTokenAuthArgs): boolean;
|
|
24
31
|
/** The configured expected token value, trimmed; `''` when unset. */
|
|
25
|
-
export declare function apiTokenFromEnv(config
|
|
32
|
+
export declare function apiTokenFromEnv({ config, env }: ApiTokenAuthArgs): string;
|
|
26
33
|
/** Whether the token gate should actually run: a token is configured and it hasn't been disabled. */
|
|
27
|
-
export declare function isApiTokenMiddlewareEnabled(config
|
|
34
|
+
export declare function isApiTokenMiddlewareEnabled({ config, env }: ApiTokenAuthArgs): boolean;
|
|
28
35
|
//# sourceMappingURL=api-token-auth.d.ts.map
|
package/dist/api-token-auth.js
CHANGED
|
@@ -4,27 +4,27 @@
|
|
|
4
4
|
* Whether a bearer-style API token gate should be enforced, and what the
|
|
5
5
|
* expected token value is. Generalized from an upstream flat daemon module:
|
|
6
6
|
* the origin hardcoded its host product's env-var names, now fields on
|
|
7
|
-
* {@link ApiTokenAuthEnvConfig} — see `
|
|
7
|
+
* {@link ApiTokenAuthEnvConfig} — see `archived provenance ledger` for the exact mapping.
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
10
|
* Interprets `value` as a truthy flag: `'1'`, `'true'`, `'yes'`, or `'on'`
|
|
11
11
|
* (case-insensitive, trimmed). Anything else, including `undefined`, is
|
|
12
12
|
* falsy.
|
|
13
13
|
*/
|
|
14
|
-
export function isTruthyEnvFlag(value) {
|
|
14
|
+
export function isTruthyEnvFlag({ value }) {
|
|
15
15
|
const normalized = String(value || '').trim().toLowerCase();
|
|
16
16
|
return normalized === '1' || normalized === 'true' || normalized === 'yes' || normalized === 'on';
|
|
17
17
|
}
|
|
18
18
|
/** Whether the API auth gate has been explicitly force-disabled. */
|
|
19
|
-
export function isApiAuthDisabled(config, env
|
|
20
|
-
return isTruthyEnvFlag(env[config.disableEnvVar]);
|
|
19
|
+
export function isApiAuthDisabled({ config, env }) {
|
|
20
|
+
return isTruthyEnvFlag({ value: env[config.disableEnvVar] });
|
|
21
21
|
}
|
|
22
22
|
/** The configured expected token value, trimmed; `''` when unset. */
|
|
23
|
-
export function apiTokenFromEnv(config, env
|
|
23
|
+
export function apiTokenFromEnv({ config, env }) {
|
|
24
24
|
return (env[config.tokenEnvVar] ?? '').trim();
|
|
25
25
|
}
|
|
26
26
|
/** Whether the token gate should actually run: a token is configured and it hasn't been disabled. */
|
|
27
|
-
export function isApiTokenMiddlewareEnabled(config, env
|
|
28
|
-
return apiTokenFromEnv(config, env).length > 0 && !isApiAuthDisabled(config, env);
|
|
27
|
+
export function isApiTokenMiddlewareEnabled({ config, env }) {
|
|
28
|
+
return apiTokenFromEnv({ config, env }).length > 0 && !isApiAuthDisabled({ config, env });
|
|
29
29
|
}
|
|
30
30
|
//# sourceMappingURL=api-token-auth.js.map
|
package/dist/bindings.d.ts
CHANGED
|
@@ -5,14 +5,25 @@ import type { ManyToken, Token } from './token.js';
|
|
|
5
5
|
* `Exclude<RequiredTokenIds<Packs>, BoundIds>` at compile time (see daemon.ts).
|
|
6
6
|
*/
|
|
7
7
|
export declare class Bindings<BoundIds extends string = never> {
|
|
8
|
+
constructor(_required: Record<string, never>);
|
|
8
9
|
private readonly one;
|
|
9
10
|
private readonly many;
|
|
10
|
-
bind<T, Id extends string>(
|
|
11
|
-
|
|
11
|
+
bind<T, Id extends string>({ token: t, impl }: {
|
|
12
|
+
token: Token<T, Id>;
|
|
13
|
+
impl: T;
|
|
14
|
+
}): Bindings<BoundIds | Id>;
|
|
15
|
+
bindMany<T, Id extends string>({ token: t, impl }: {
|
|
16
|
+
token: ManyToken<T, Id>;
|
|
17
|
+
impl: T;
|
|
18
|
+
}): Bindings<BoundIds | Id>;
|
|
12
19
|
/** @internal */
|
|
13
|
-
resolveOne<T>(
|
|
20
|
+
resolveOne<T>({ token: t }: {
|
|
21
|
+
token: Token<T, string>;
|
|
22
|
+
}): T;
|
|
14
23
|
/** @internal */
|
|
15
|
-
resolveMany<T>(
|
|
24
|
+
resolveMany<T>({ token: t }: {
|
|
25
|
+
token: ManyToken<T, string>;
|
|
26
|
+
}): T[];
|
|
16
27
|
}
|
|
17
|
-
export declare function bindings(): Bindings<never>;
|
|
28
|
+
export declare function bindings(required: Record<string, never>): Bindings<never>;
|
|
18
29
|
//# sourceMappingURL=bindings.d.ts.map
|
package/dist/bindings.js
CHANGED
|
@@ -4,23 +4,24 @@
|
|
|
4
4
|
* `Exclude<RequiredTokenIds<Packs>, BoundIds>` at compile time (see daemon.ts).
|
|
5
5
|
*/
|
|
6
6
|
export class Bindings {
|
|
7
|
+
constructor(_required) { }
|
|
7
8
|
one = new Map();
|
|
8
9
|
many = new Map();
|
|
9
|
-
bind(t, impl) {
|
|
10
|
+
bind({ token: t, impl }) {
|
|
10
11
|
if (this.one.has(t.id)) {
|
|
11
12
|
throw new Error(`duplicate binding: ${t.id} is already bound (a singleton token accepts exactly one binding)`);
|
|
12
13
|
}
|
|
13
14
|
this.one.set(t.id, { value: impl, version: t.version });
|
|
14
15
|
return this;
|
|
15
16
|
}
|
|
16
|
-
bindMany(t, impl) {
|
|
17
|
+
bindMany({ token: t, impl }) {
|
|
17
18
|
const list = this.many.get(t.id) ?? [];
|
|
18
19
|
list.push(impl);
|
|
19
20
|
this.many.set(t.id, list);
|
|
20
21
|
return this;
|
|
21
22
|
}
|
|
22
23
|
/** @internal */
|
|
23
|
-
resolveOne(t) {
|
|
24
|
+
resolveOne({ token: t }) {
|
|
24
25
|
const entry = this.one.get(t.id);
|
|
25
26
|
if (!entry) {
|
|
26
27
|
throw new Error(`missing binding: ${t.id}`);
|
|
@@ -31,11 +32,11 @@ export class Bindings {
|
|
|
31
32
|
return entry.value;
|
|
32
33
|
}
|
|
33
34
|
/** @internal */
|
|
34
|
-
resolveMany(t) {
|
|
35
|
+
resolveMany({ token: t }) {
|
|
35
36
|
return (this.many.get(t.id) ?? []);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
export function bindings() {
|
|
39
|
-
return new Bindings();
|
|
39
|
+
export function bindings(required) {
|
|
40
|
+
return new Bindings(required);
|
|
40
41
|
}
|
|
41
42
|
//# sourceMappingURL=bindings.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @jini-ai/core/composition
|
|
3
|
+
*
|
|
4
|
+
* Composition boundary for daemon assembly and authorized tool invocation.
|
|
5
|
+
* These capabilities stay off the root entry point; each has its own
|
|
6
|
+
* intended consumer:
|
|
7
|
+
*
|
|
8
|
+
* - {@link authorizeToolInvocation} so `@jini-ai/daemon`'s `ToolExecutor` can
|
|
9
|
+
* resolve a registered tool and run its authorization gate — the tool's
|
|
10
|
+
* own `ToolPolicy`, then an optional transport-level veto — before ever
|
|
11
|
+
* receiving the handler. This is the security-sensitive one: it is a
|
|
12
|
+
* runtime *value* export, but unlike the `getToolRegistration` it
|
|
13
|
+
* replaced (2026-07-29 hardening pass), it only ever returns a handler
|
|
14
|
+
* closure alongside a `decision: 'allow'` — a denied or unauthorized call
|
|
15
|
+
* gets no handler at all, so the authorization gate cannot be bypassed by
|
|
16
|
+
* calling this export directly instead of going through `ToolExecutor`.
|
|
17
|
+
* - `AnyPack`/`RequiredTokenIds`/`MissingTokenIds` so `@jini-ai/server`'s
|
|
18
|
+
* `createLocalNodeDaemon` can re-derive `createDaemon`'s exact
|
|
19
|
+
* compile-time "missing binding" gate on its own wrapper config type,
|
|
20
|
+
* instead of either duplicating the type-level logic or losing the
|
|
21
|
+
* compile-time check through the wrapper. These are `import type`-only —
|
|
22
|
+
* erased at build time, carry no runtime capability, and are not a
|
|
23
|
+
* security boundary the way {@link authorizeToolInvocation} is.
|
|
24
|
+
*
|
|
25
|
+
* **Correction (2026-07-19 hardening pass):** a package.json `exports` map
|
|
26
|
+
* subpath is NOT a language-level or per-consumer access modifier — Node's
|
|
27
|
+
* module resolution will happily resolve `@jini-ai/core/composition` for *any*
|
|
28
|
+
* package that depends on `@jini-ai/core`, not just the intended consumer.
|
|
29
|
+
* Earlier revisions of this doc comment claimed this boundary was
|
|
30
|
+
* "enforced" by the exports map; that was inaccurate and left the leak
|
|
31
|
+
* undetected. The actual enforcement is `scripts/check-engine-boundaries.ts`'s
|
|
32
|
+
* R6-internal-leak rule forbidding any *value* import from `@jini-ai/core/composition` outside
|
|
33
|
+
* `packages/daemon/**` (type-only imports of the DI-token-derivation types
|
|
34
|
+
* remain unrestricted, since they carry no runtime capability). R6 checks this
|
|
35
|
+
* exact composition specifier as a second, independent layer on top of the 2026-07-29
|
|
36
|
+
* structural fix above, not a substitute for it.
|
|
37
|
+
*/
|
|
38
|
+
export { authorizeToolInvocation } from './tool-registry.js';
|
|
39
|
+
export type { ToolAuthorizationDelegate, ToolInvocationAuthorization } from './tool-registry.js';
|
|
40
|
+
export type { AnyPack, MissingTokenIds, RequiredTokenIds } from './daemon.js';
|
|
41
|
+
//# sourceMappingURL=composition.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @jini-ai/core/composition
|
|
3
|
+
*
|
|
4
|
+
* Composition boundary for daemon assembly and authorized tool invocation.
|
|
5
|
+
* These capabilities stay off the root entry point; each has its own
|
|
6
|
+
* intended consumer:
|
|
7
|
+
*
|
|
8
|
+
* - {@link authorizeToolInvocation} so `@jini-ai/daemon`'s `ToolExecutor` can
|
|
9
|
+
* resolve a registered tool and run its authorization gate — the tool's
|
|
10
|
+
* own `ToolPolicy`, then an optional transport-level veto — before ever
|
|
11
|
+
* receiving the handler. This is the security-sensitive one: it is a
|
|
12
|
+
* runtime *value* export, but unlike the `getToolRegistration` it
|
|
13
|
+
* replaced (2026-07-29 hardening pass), it only ever returns a handler
|
|
14
|
+
* closure alongside a `decision: 'allow'` — a denied or unauthorized call
|
|
15
|
+
* gets no handler at all, so the authorization gate cannot be bypassed by
|
|
16
|
+
* calling this export directly instead of going through `ToolExecutor`.
|
|
17
|
+
* - `AnyPack`/`RequiredTokenIds`/`MissingTokenIds` so `@jini-ai/server`'s
|
|
18
|
+
* `createLocalNodeDaemon` can re-derive `createDaemon`'s exact
|
|
19
|
+
* compile-time "missing binding" gate on its own wrapper config type,
|
|
20
|
+
* instead of either duplicating the type-level logic or losing the
|
|
21
|
+
* compile-time check through the wrapper. These are `import type`-only —
|
|
22
|
+
* erased at build time, carry no runtime capability, and are not a
|
|
23
|
+
* security boundary the way {@link authorizeToolInvocation} is.
|
|
24
|
+
*
|
|
25
|
+
* **Correction (2026-07-19 hardening pass):** a package.json `exports` map
|
|
26
|
+
* subpath is NOT a language-level or per-consumer access modifier — Node's
|
|
27
|
+
* module resolution will happily resolve `@jini-ai/core/composition` for *any*
|
|
28
|
+
* package that depends on `@jini-ai/core`, not just the intended consumer.
|
|
29
|
+
* Earlier revisions of this doc comment claimed this boundary was
|
|
30
|
+
* "enforced" by the exports map; that was inaccurate and left the leak
|
|
31
|
+
* undetected. The actual enforcement is `scripts/check-engine-boundaries.ts`'s
|
|
32
|
+
* R6-internal-leak rule forbidding any *value* import from `@jini-ai/core/composition` outside
|
|
33
|
+
* `packages/daemon/**` (type-only imports of the DI-token-derivation types
|
|
34
|
+
* remain unrestricted, since they carry no runtime capability). R6 checks this
|
|
35
|
+
* exact composition specifier as a second, independent layer on top of the 2026-07-29
|
|
36
|
+
* structural fix above, not a substitute for it.
|
|
37
|
+
*/
|
|
38
|
+
export { authorizeToolInvocation } from './tool-registry.js';
|
|
39
|
+
//# sourceMappingURL=composition.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Replace-by-key registry for host-owned contributions; no singleton or execution surface. */
|
|
2
|
+
export interface ContributionRegistry<TContribution> {
|
|
3
|
+
register(required: {
|
|
4
|
+
contribution: TContribution;
|
|
5
|
+
}): void;
|
|
6
|
+
/** Detached array snapshot; contribution values retain their identity. */
|
|
7
|
+
list(_required: Record<string, never>): readonly TContribution[];
|
|
8
|
+
clear(_required: Record<string, never>): void;
|
|
9
|
+
}
|
|
10
|
+
/** O(1) register/clear, O(n) list and O(n) retained entries. Replacement preserves position. */
|
|
11
|
+
export declare function createContributionRegistry<TContribution, TKey>(required: {
|
|
12
|
+
keyOf: (required: {
|
|
13
|
+
contribution: TContribution;
|
|
14
|
+
}) => TKey;
|
|
15
|
+
}): ContributionRegistry<TContribution>;
|
|
16
|
+
//# sourceMappingURL=contribution-registry.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** O(1) register/clear, O(n) list and O(n) retained entries. Replacement preserves position. */
|
|
2
|
+
export function createContributionRegistry(required) {
|
|
3
|
+
const contributions = new Map();
|
|
4
|
+
return {
|
|
5
|
+
register({ contribution }) {
|
|
6
|
+
contributions.set(required.keyOf({ contribution }), contribution);
|
|
7
|
+
},
|
|
8
|
+
list(_required) { return [...contributions.values()]; },
|
|
9
|
+
clear(_required) { contributions.clear(); },
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=contribution-registry.js.map
|