@jini-ai/core 0.7.2 → 0.7.3-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -12
- package/dist/admin-runtime/admin-api-error.d.ts +68 -0
- package/dist/admin-runtime/admin-api-error.js +72 -0
- package/dist/admin-runtime/admin-config-error.d.ts +8 -0
- package/dist/admin-runtime/admin-config-error.js +11 -0
- package/dist/admin-runtime/controller-store.d.ts +20 -0
- package/dist/admin-runtime/controller-store.js +32 -0
- package/dist/admin-runtime/index.d.ts +13 -0
- package/dist/admin-runtime/index.js +12 -0
- package/dist/admin-runtime/panel-access.d.ts +88 -0
- package/dist/admin-runtime/panel-access.js +76 -0
- package/dist/admin-runtime/query-suffix.d.ts +5 -0
- package/dist/admin-runtime/query-suffix.js +5 -0
- package/dist/agent-handles/element-handles.d.ts +134 -0
- package/dist/agent-handles/element-handles.js +45 -0
- package/dist/agent-handles/field-descriptor.d.ts +28 -0
- package/dist/agent-handles/field-descriptor.js +3 -0
- package/dist/agent-handles/handle.d.ts +109 -0
- package/dist/agent-handles/handle.js +109 -0
- package/dist/agent-handles/index.d.ts +9 -0
- package/dist/agent-handles/index.js +6 -0
- package/dist/agent-handles/list-handles.d.ts +46 -0
- package/dist/agent-handles/list-handles.js +67 -0
- package/dist/agent-handles/secret-attrs.d.ts +14 -0
- package/dist/agent-handles/secret-attrs.js +13 -0
- package/dist/approval-batch-chain.d.ts +45 -0
- package/dist/approval-batch-chain.js +75 -0
- package/dist/approval.d.ts +33 -14
- package/dist/approval.js +57 -43
- package/dist/batch-tool-inputs.js +24 -20
- package/dist/contracts/admin-module.d.ts +166 -0
- package/dist/contracts/admin-module.js +14 -0
- package/dist/contracts/agents/definition.d.ts +459 -0
- package/dist/contracts/agents/definition.js +2 -0
- package/dist/contracts/agents/index.d.ts +7 -0
- package/dist/contracts/agents/index.js +2 -0
- package/dist/contracts/agents/launch.d.ts +64 -0
- package/dist/contracts/agents/launch.js +2 -0
- package/dist/contracts/agents/model-catalog.d.ts +213 -0
- package/dist/contracts/agents/model-catalog.js +4 -0
- package/dist/contracts/agents/native-tool-policy.d.ts +42 -0
- package/dist/contracts/agents/native-tool-policy.js +2 -0
- package/dist/contracts/ai-trace/capture.d.ts +17 -0
- package/dist/contracts/ai-trace/capture.js +43 -0
- package/dist/contracts/ai-trace/classify.d.ts +12 -0
- package/dist/contracts/ai-trace/classify.js +16 -0
- package/dist/contracts/ai-trace/index.d.ts +13 -0
- package/dist/contracts/ai-trace/index.js +6 -0
- package/dist/contracts/ai-trace/recorder.d.ts +64 -0
- package/dist/contracts/ai-trace/recorder.js +283 -0
- package/dist/contracts/ai-trace/sinks.d.ts +51 -0
- package/dist/contracts/ai-trace/sinks.js +153 -0
- package/dist/contracts/ai-trace/types.d.ts +123 -0
- package/dist/contracts/ai-trace/types.js +17 -0
- package/dist/contracts/ai-trace/usage.d.ts +16 -0
- package/dist/contracts/ai-trace/usage.js +45 -0
- package/dist/contracts/blob.d.ts +31 -0
- package/dist/contracts/blob.js +10 -0
- package/dist/contracts/capabilities.d.ts +95 -0
- package/dist/contracts/capabilities.js +111 -0
- package/dist/contracts/charts.d.ts +75 -0
- package/dist/contracts/charts.js +4 -0
- package/dist/contracts/env.d.ts +96 -0
- package/dist/contracts/env.js +6 -0
- package/dist/contracts/events/change-set.d.ts +106 -0
- package/dist/contracts/events/change-set.js +2 -0
- package/dist/contracts/events/command.d.ts +118 -0
- package/dist/contracts/events/command.js +2 -0
- package/dist/contracts/events/ports.d.ts +172 -0
- package/dist/contracts/events/ports.js +2 -0
- package/dist/contracts/events.d.ts +5 -0
- package/dist/contracts/events.js +2 -0
- package/dist/contracts/forms.d.ts +110 -0
- package/dist/contracts/forms.js +4 -0
- package/dist/contracts/hosted-mcp/config.d.ts +19 -0
- package/dist/contracts/hosted-mcp/record.d.ts +61 -4
- package/dist/contracts/mail/email-sender.d.ts +118 -0
- package/dist/contracts/mail/email-sender.js +20 -0
- package/dist/contracts/mail/smtp-payload.d.ts +32 -0
- package/dist/contracts/mail/smtp-payload.js +2 -0
- package/dist/contracts/mail.d.ts +2 -0
- package/dist/contracts/mail.js +1 -1
- package/dist/contracts/observability.d.ts +235 -0
- package/dist/contracts/observability.js +28 -0
- package/dist/contracts/plugin-sdk.d.ts +186 -0
- package/dist/contracts/plugin-sdk.js +39 -0
- package/dist/contracts/runtime/command.d.ts +41 -0
- package/dist/contracts/runtime/command.js +60 -0
- package/dist/contracts/runtime/environment.d.ts +18 -0
- package/dist/contracts/runtime/environment.js +26 -0
- package/dist/contracts/runtime/file-lock.d.ts +94 -0
- package/dist/contracts/runtime/file-lock.js +25 -0
- package/dist/contracts/runtime/fs.d.ts +33 -0
- package/dist/contracts/runtime/fs.js +2 -0
- package/dist/contracts/runtime/http.d.ts +89 -0
- package/dist/contracts/runtime/http.js +2 -0
- package/dist/contracts/runtime/platform.d.ts +3 -0
- package/dist/contracts/runtime/platform.js +2 -0
- package/dist/contracts/runtime/process.d.ts +40 -0
- package/dist/contracts/runtime/process.js +31 -0
- package/dist/contracts/runtime/reader.d.ts +11 -0
- package/dist/contracts/runtime/reader.js +2 -0
- package/dist/contracts/runtime/terminal.d.ts +99 -0
- package/dist/contracts/runtime/terminal.js +2 -0
- package/dist/contracts/runtime/testing.d.ts +84 -0
- package/dist/contracts/runtime/testing.js +116 -0
- package/dist/contracts/runtime.d.ts +10 -0
- package/dist/contracts/runtime.js +10 -0
- package/dist/contracts/server/api-error.d.ts +43 -0
- package/dist/contracts/server/api-error.js +49 -0
- package/dist/contracts/server/auth.d.ts +20 -0
- package/dist/contracts/server/auth.js +21 -0
- package/dist/contracts/server/conformance.d.ts +25 -0
- package/dist/contracts/server/conformance.js +50 -0
- package/dist/contracts/server/json-route.d.ts +176 -0
- package/dist/contracts/server/json-route.js +155 -0
- package/dist/contracts/server/middleware.d.ts +35 -0
- package/dist/contracts/server/middleware.js +56 -0
- package/dist/contracts/server/origin.d.ts +44 -0
- package/dist/contracts/server/origin.js +32 -0
- package/dist/contracts/server/query.d.ts +16 -0
- package/dist/contracts/server/query.js +69 -0
- package/dist/contracts/server/rate-limit.d.ts +20 -0
- package/dist/contracts/server/rate-limit.js +8 -0
- package/dist/contracts/server/request-body.d.ts +26 -0
- package/dist/contracts/server/request-body.js +82 -0
- package/dist/contracts/server/result.d.ts +17 -0
- package/dist/contracts/server/result.js +5 -0
- package/dist/contracts/server/route-table.d.ts +54 -0
- package/dist/contracts/server/route-table.js +119 -0
- package/dist/contracts/server/same-origin-write.d.ts +18 -0
- package/dist/contracts/server/same-origin-write.js +31 -0
- package/dist/contracts/server/security-headers.d.ts +30 -0
- package/dist/contracts/server/security-headers.js +35 -0
- package/dist/contracts/server/sse.d.ts +82 -0
- package/dist/contracts/server/sse.js +103 -0
- package/dist/contracts/server/testing.d.ts +59 -0
- package/dist/contracts/server/testing.js +68 -0
- package/dist/contracts/server/verified-origin/configured-origin.d.ts +37 -0
- package/dist/contracts/server/verified-origin/configured-origin.js +103 -0
- package/dist/contracts/server/verified-origin/index.d.ts +7 -0
- package/dist/contracts/server/verified-origin/index.js +6 -0
- package/dist/contracts/server/verified-origin/loopback-host.d.ts +9 -0
- package/dist/contracts/server/verified-origin/loopback-host.js +17 -0
- package/dist/contracts/server/verified-origin/origin.d.ts +64 -0
- package/dist/contracts/server/verified-origin/origin.js +162 -0
- package/dist/contracts/server/verified-origin/ports.d.ts +38 -0
- package/dist/contracts/server/verified-origin/ports.js +2 -0
- package/dist/contracts/server/verified-origin/repo.memory.d.ts +32 -0
- package/dist/contracts/server/verified-origin/repo.memory.js +34 -0
- package/dist/contracts/server/verified-origin/site-path.d.ts +113 -0
- package/dist/contracts/server/verified-origin/site-path.js +188 -0
- package/dist/contracts/server/verified-origin/types.d.ts +33 -0
- package/dist/contracts/server/verified-origin/types.js +30 -0
- package/dist/contracts/server.d.ts +46 -2
- package/dist/contracts/server.js +17 -3
- package/dist/contracts/storage/kernel.d.ts +86 -0
- package/dist/contracts/storage/kernel.js +38 -0
- package/dist/contracts/storage/migration.d.ts +32 -0
- package/dist/contracts/storage/migration.js +2 -0
- package/dist/contracts/storage/rows.d.ts +33 -0
- package/dist/contracts/storage/rows.js +42 -0
- package/dist/contracts/storage/sqlite.d.ts +113 -0
- package/dist/contracts/storage/sqlite.js +8 -0
- package/dist/contracts/storage/values.d.ts +25 -0
- package/dist/contracts/storage/values.js +25 -0
- package/dist/contracts/storage.d.ts +8 -0
- package/dist/contracts/storage.js +6 -0
- package/dist/contracts/vault/invariants.d.ts +26 -0
- package/dist/contracts/vault/invariants.js +49 -0
- package/dist/contracts/vault.d.ts +1 -0
- package/dist/contracts/vault.js +1 -1
- package/dist/env/coercers.d.ts +21 -0
- package/dist/env/coercers.js +68 -0
- package/dist/env/describe-env-for-diagnostics.d.ts +16 -0
- package/dist/env/describe-env-for-diagnostics.js +23 -0
- package/dist/env/format-env-issue.d.ts +13 -0
- package/dist/env/format-env-issue.js +22 -0
- package/dist/env/parse-env.d.ts +24 -0
- package/dist/env/parse-env.js +102 -0
- package/dist/env/value-echo.d.ts +17 -0
- package/dist/env/value-echo.js +42 -0
- package/dist/errors/approved-cause.d.ts +36 -0
- package/dist/errors/approved-cause.js +17 -0
- package/dist/errors/bindings.d.ts +61 -0
- package/dist/errors/bindings.js +57 -0
- package/dist/errors/catalog.d.ts +84 -0
- package/dist/errors/catalog.js +151 -0
- package/dist/errors/disclosure.d.ts +48 -0
- package/dist/errors/disclosure.js +27 -0
- package/dist/errors/error-id.d.ts +26 -0
- package/dist/errors/error-id.js +23 -0
- package/dist/errors/idioms.d.ts +73 -0
- package/dist/errors/idioms.js +85 -0
- package/dist/errors/incident-text.d.ts +16 -0
- package/dist/errors/incident-text.js +77 -0
- package/dist/errors/reporter.d.ts +94 -0
- package/dist/errors/reporter.js +152 -0
- package/dist/errors/sentences.d.ts +68 -0
- package/dist/errors/sentences.js +93 -0
- package/dist/errors/testing.d.ts +50 -0
- package/dist/errors/testing.js +44 -0
- package/dist/fetch/cache.d.ts +12 -5
- package/dist/fetch/cache.js +46 -47
- package/dist/fetch/index.d.ts +1 -1
- package/dist/fetch/loader-read.d.ts +6 -2
- package/dist/fetch/loader-read.js +4 -4
- package/dist/format-error-for-log.d.ts +15 -0
- package/dist/format-error-for-log.js +55 -0
- package/dist/gated-mutations/gateway.d.ts +2 -0
- package/dist/gated-mutations/gateway.js +4 -1
- package/dist/host-read-vocabulary.d.ts +47 -0
- package/dist/host-read-vocabulary.js +44 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +4 -0
- package/dist/list-page.d.ts +93 -0
- package/dist/list-page.js +154 -0
- package/dist/model-facing-tool-errors.d.ts +67 -5
- package/dist/model-facing-tool-errors.js +155 -19
- package/dist/net/endpoint-policy.d.ts +39 -0
- package/dist/net/endpoint-policy.js +218 -0
- package/dist/net/fetch-timeouts.d.ts +38 -0
- package/dist/net/fetch-timeouts.js +31 -0
- package/dist/net/index.d.ts +4 -0
- package/dist/net/index.js +4 -0
- package/dist/net/loopback.d.ts +13 -0
- package/dist/net/loopback.js +39 -0
- package/dist/optimistic-concurrency.d.ts +183 -0
- package/dist/optimistic-concurrency.js +222 -0
- package/dist/primitives/errors.d.ts +9 -0
- package/dist/primitives/errors.js +12 -0
- package/dist/primitives/ids.d.ts +0 -2
- package/dist/primitives/ids.js +1 -4
- package/dist/primitives/index.d.ts +3 -0
- package/dist/primitives/index.js +2 -0
- package/dist/primitives/logger.d.ts +36 -1
- package/dist/primitives/logger.js +125 -9
- package/dist/primitives/node-shape.d.ts +24 -0
- package/dist/primitives/node-shape.js +21 -0
- package/dist/primitives/time.d.ts +9 -2
- package/dist/primitives/time.js +4 -3
- package/dist/provider-registry.js +26 -20
- package/dist/records.d.ts +40 -7
- package/dist/records.js +37 -3
- package/dist/redact.d.ts +1 -84
- package/dist/redact.js +2 -826
- package/dist/redaction-collectors.d.ts +7 -0
- package/dist/redaction-collectors.js +152 -0
- package/dist/redaction-exact-secrets.d.ts +14 -0
- package/dist/redaction-exact-secrets.js +115 -0
- package/dist/redaction-labels.d.ts +14 -0
- package/dist/redaction-labels.js +156 -0
- package/dist/redaction-patterns.d.ts +54 -0
- package/dist/redaction-patterns.js +178 -0
- package/dist/redaction-spans.d.ts +31 -0
- package/dist/redaction-spans.js +83 -0
- package/dist/registration-kit.d.ts +1 -1
- package/dist/revision-conflict-error.d.ts +18 -0
- package/dist/revision-conflict-error.js +20 -0
- package/dist/secret-shapes.d.ts +50 -0
- package/dist/secret-shapes.js +105 -0
- package/dist/settings/agent-tools.js +22 -8
- package/dist/settings/agent-value-write-tools.d.ts +4 -1
- package/dist/settings/agent-value-write-tools.js +7 -6
- package/dist/settings/agent-writable-preferences.d.ts +3 -1
- package/dist/settings/agent-writable-preferences.js +1 -1
- package/dist/settings/agent-write-denylist.d.ts +7 -4
- package/dist/settings/agent-write-denylist.js +1 -1
- package/dist/settings/{express/cms-adapter.d.ts → cms-adapter.d.ts} +3 -2
- package/dist/settings/{express/cms-adapter.js → cms-adapter.js} +21 -11
- package/dist/settings/definitions-dispatch.js +3 -1
- package/dist/settings/ensure-definitions.js +3 -1
- package/dist/settings/errors.d.ts +1 -13
- package/dist/settings/errors.js +2 -15
- package/dist/settings/index.d.ts +11 -2
- package/dist/settings/index.js +10 -2
- package/dist/settings/purge-service.js +63 -86
- package/dist/settings/{express/contracts.d.ts → route-policy.d.ts} +53 -47
- package/dist/settings/{express/shared.js → route-policy.js} +1 -16
- package/dist/settings/settings.d.ts +19 -11
- package/dist/settings/settings.js +9 -11
- package/dist/settings/tool-registrations.d.ts +3 -3
- package/dist/settings/tool-registrations.js +130 -125
- package/dist/settings/types.d.ts +1 -1
- package/dist/settings/write-definition-rename.d.ts +37 -0
- package/dist/settings/write-definition-rename.js +119 -0
- package/dist/settings/write-definition-retype.d.ts +61 -0
- package/dist/settings/write-definition-retype.js +109 -0
- package/dist/settings/write-definition-status.d.ts +81 -0
- package/dist/settings/write-definition-status.js +121 -0
- package/dist/settings/write-reset.d.ts +34 -0
- package/dist/settings/write-reset.js +73 -0
- package/dist/settings/write-service.d.ts +16 -287
- package/dist/settings/write-service.js +49 -681
- package/dist/settings/write-value-revisions.d.ts +68 -0
- package/dist/settings/write-value-revisions.js +124 -0
- package/dist/settings/write-values.d.ts +96 -0
- package/dist/settings/write-values.js +83 -0
- package/dist/surface-exchanges.d.ts +2 -2
- package/dist/text/dictionary-translator.d.ts +19 -0
- package/dist/text/dictionary-translator.js +14 -0
- package/dist/text/format-byte-size.d.ts +25 -0
- package/dist/text/format-byte-size.js +25 -0
- package/dist/text/format-timestamp.d.ts +22 -0
- package/dist/text/format-timestamp.js +57 -0
- package/dist/text/index.d.ts +12 -0
- package/dist/text/index.js +9 -0
- package/dist/text/is-abort-error.d.ts +5 -0
- package/dist/text/is-abort-error.js +5 -0
- package/dist/text/mime.d.ts +5 -0
- package/dist/text/mime.js +21 -0
- package/dist/text/redact-urls.d.ts +7 -0
- package/dist/text/redact-urls.js +5 -0
- package/dist/text/resolve-active-tab-id.d.ts +13 -0
- package/dist/text/resolve-active-tab-id.js +15 -0
- package/dist/text/sanitize-untrusted-text.d.ts +1 -1
- package/dist/text/sanitize-untrusted-text.js +2 -1
- package/dist/text/tagged-text-suppression.d.ts +103 -0
- package/dist/text/tagged-text-suppression.js +143 -0
- package/dist/text/template-i18n.d.ts +37 -0
- package/dist/text/template-i18n.js +48 -0
- package/dist/tool-call-text.d.ts +59 -0
- package/dist/tool-call-text.js +62 -0
- package/dist/tool-input-envelope.js +8 -4
- package/dist/tool-input-normalization.js +8 -1
- package/dist/tool-input-repairs.d.ts +58 -0
- package/dist/tool-input-repairs.js +154 -0
- package/dist/tool-tokens.js +1 -1
- package/dist/user-facing-error.d.ts +1 -1
- package/dist/user-facing-error.js +3 -1
- package/package.json +235 -14
- package/plugin-directory.d.ts +2 -2
- package/plugin-directory.js +16 -10
- package/dist/settings/express/contracts.js +0 -2
- package/dist/settings/express/http-request.d.ts +0 -33
- package/dist/settings/express/http-request.js +0 -50
- package/dist/settings/express/http.d.ts +0 -10
- package/dist/settings/express/http.js +0 -196
- package/dist/settings/express/index.d.ts +0 -5
- package/dist/settings/express/index.js +0 -4
- package/dist/settings/express/shared.d.ts +0 -68
- package/dist/settings/express/stream.d.ts +0 -24
- package/dist/settings/express/stream.js +0 -171
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createErrorCatalog } from './catalog.js';
|
|
2
|
+
import { createErrorReporter } from './reporter.js';
|
|
3
|
+
/** A logger that keeps every call exactly as made, original error objects included. */
|
|
4
|
+
export function createRecordingLogger() {
|
|
5
|
+
const entries = [];
|
|
6
|
+
const write = (level) => (required, optional = {}) => {
|
|
7
|
+
entries.push({ level, message: required.message, ...optional });
|
|
8
|
+
};
|
|
9
|
+
return { logger: { info: write('info'), warn: write('warn'), error: write('error') }, entries };
|
|
10
|
+
}
|
|
11
|
+
/** A tracker that keeps every report. */
|
|
12
|
+
export function createRecordingTracker() {
|
|
13
|
+
const reports = [];
|
|
14
|
+
return { tracker: { reportError: report => { reports.push(report); } }, reports };
|
|
15
|
+
}
|
|
16
|
+
/** Hands out the given IDs in order; throws when a test asks for more than it listed. */
|
|
17
|
+
export function createSequenceIds(required) {
|
|
18
|
+
let next = 0;
|
|
19
|
+
return {
|
|
20
|
+
newId: () => {
|
|
21
|
+
const id = required.ids[next];
|
|
22
|
+
if (id === undefined)
|
|
23
|
+
throw new RangeError(`createSequenceIds: the test asked for ID ${next + 1} but listed ${required.ids.length}.`);
|
|
24
|
+
next += 1;
|
|
25
|
+
return id;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** A clock fixed at one instant. */
|
|
30
|
+
export function createFixedClock(required) {
|
|
31
|
+
return { nowMs: () => Date.parse(required.iso) };
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A real reporter over recording ports, for a test that needs to see what an incident wrote.
|
|
35
|
+
* @example const { reporter, entries, reports } = createRecordingReporter({ ids: ['ERR-0000-0000-0000-0001'], iso: '2026-01-01T00:00:00.000Z' });
|
|
36
|
+
*/
|
|
37
|
+
export function createRecordingReporter(required, optional = {}) {
|
|
38
|
+
const { logger, entries } = createRecordingLogger();
|
|
39
|
+
const { tracker, reports } = createRecordingTracker();
|
|
40
|
+
const { catalog = createErrorCatalog({ sentences: [], scopes: [] }), versions = { app: '0.0.0-test', jini: '0.0.0-test' }, ...reporterOptions } = optional;
|
|
41
|
+
const reporter = createErrorReporter({ ids: createSequenceIds({ ids: required.ids }), clock: createFixedClock({ iso: required.iso }), logger, tracker, catalog, versions }, reporterOptions);
|
|
42
|
+
return { reporter, entries, reports };
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=testing.js.map
|
package/dist/fetch/cache.d.ts
CHANGED
|
@@ -30,9 +30,11 @@ export interface FetchQueryEnvironmentPort {
|
|
|
30
30
|
listener: () => void;
|
|
31
31
|
}): () => void;
|
|
32
32
|
}
|
|
33
|
+
export interface FetchQueryCacheRequired {
|
|
34
|
+
clock: Clock;
|
|
35
|
+
scheduler: QueryCacheSchedulerPort;
|
|
36
|
+
}
|
|
33
37
|
export interface FetchQueryCacheOptions {
|
|
34
|
-
clock?: Clock;
|
|
35
|
-
scheduler?: QueryCacheSchedulerPort;
|
|
36
38
|
environment?: FetchQueryEnvironmentPort;
|
|
37
39
|
}
|
|
38
40
|
export interface QueryState {
|
|
@@ -63,7 +65,9 @@ export interface CacheEntry {
|
|
|
63
65
|
retention: number;
|
|
64
66
|
eviction: unknown;
|
|
65
67
|
}
|
|
66
|
-
export declare function toQueryError(value
|
|
68
|
+
export declare function toQueryError({ value }: {
|
|
69
|
+
value: unknown;
|
|
70
|
+
}, _optional?: Record<string, never>): Error;
|
|
67
71
|
/** One provider-owned cache. Requests are shared by structural primitive keys.
|
|
68
72
|
* Failed reads retain earlier data; replacement writes supersede older requests.
|
|
69
73
|
* Idle entries live for at least five minutes or their declared freshness period. */
|
|
@@ -76,7 +80,7 @@ export declare class FetchQueryCache {
|
|
|
76
80
|
private online;
|
|
77
81
|
private readonly onlineWaiters;
|
|
78
82
|
private releaseEnvironment;
|
|
79
|
-
constructor(
|
|
83
|
+
constructor({ clock, scheduler }: FetchQueryCacheRequired, { environment }?: FetchQueryCacheOptions);
|
|
80
84
|
entry({ key }: {
|
|
81
85
|
key: QueryKey;
|
|
82
86
|
}, { staleTime }?: {
|
|
@@ -96,13 +100,16 @@ export declare class FetchQueryCache {
|
|
|
96
100
|
}): () => void;
|
|
97
101
|
/** Cache hits respect freshness; explicit refreshes restart background reads.
|
|
98
102
|
* Initial reads still deduplicate because no earlier successful data exists to refresh. */
|
|
99
|
-
load<T>({ entry, fetch, staleTime }: {
|
|
103
|
+
load<T>({ entry, fetch: read, staleTime }: {
|
|
100
104
|
entry: CacheEntry;
|
|
101
105
|
fetch: () => Promise<T>;
|
|
102
106
|
staleTime: number;
|
|
103
107
|
}, { force }?: {
|
|
104
108
|
force?: boolean;
|
|
105
109
|
}): Promise<T>;
|
|
110
|
+
private settleSuccess;
|
|
111
|
+
private settleFailure;
|
|
112
|
+
private finishPending;
|
|
106
113
|
replace({ entry, data }: {
|
|
107
114
|
entry: CacheEntry;
|
|
108
115
|
data: unknown;
|
package/dist/fetch/cache.js
CHANGED
|
@@ -9,13 +9,9 @@
|
|
|
9
9
|
export const DEFAULT_STALE_TIME = 10_000;
|
|
10
10
|
/** Minimum time an unobserved entry is kept; both adapters retain max(this, staleTime). */
|
|
11
11
|
export const IDLE_RETENTION = 5 * 60_000;
|
|
12
|
-
const browserScheduler = {
|
|
13
|
-
schedule: ({ callback, delayMs }) => setTimeout(callback, delayMs),
|
|
14
|
-
cancel: ({ handle }) => clearTimeout(handle),
|
|
15
|
-
};
|
|
16
12
|
// Normalize unknown promise rejections once so consumers receive Error without repeating
|
|
17
13
|
// the same narrowing boilerplate at every read and write call site.
|
|
18
|
-
export function toQueryError(value) {
|
|
14
|
+
export function toQueryError({ value }, _optional = {}) {
|
|
19
15
|
if (value instanceof Error)
|
|
20
16
|
return value;
|
|
21
17
|
return new Error(typeof value === 'string' && value.trim() ? value : 'request failed');
|
|
@@ -32,7 +28,7 @@ export class FetchQueryCache {
|
|
|
32
28
|
online;
|
|
33
29
|
onlineWaiters = new Set();
|
|
34
30
|
releaseEnvironment;
|
|
35
|
-
constructor(
|
|
31
|
+
constructor({ clock, scheduler }, { environment } = {}) {
|
|
36
32
|
this.clock = clock;
|
|
37
33
|
this.scheduler = scheduler;
|
|
38
34
|
this.environment = environment;
|
|
@@ -69,7 +65,7 @@ export class FetchQueryCache {
|
|
|
69
65
|
}
|
|
70
66
|
/** Cache hits respect freshness; explicit refreshes restart background reads.
|
|
71
67
|
* Initial reads still deduplicate because no earlier successful data exists to refresh. */
|
|
72
|
-
load({ entry, fetch, staleTime }, { force = false } = {}) {
|
|
68
|
+
load({ entry, fetch: read, staleTime }, { force = false } = {}) {
|
|
73
69
|
this.cancelEviction(entry);
|
|
74
70
|
if (entry.pending && (!force || entry.state.data === undefined))
|
|
75
71
|
return entry.pending;
|
|
@@ -85,7 +81,7 @@ export class FetchQueryCache {
|
|
|
85
81
|
if (entry.pending !== pending)
|
|
86
82
|
return this.supersedingResult({ entry });
|
|
87
83
|
this.publish(entry, { ...entry.state, isFetching: true });
|
|
88
|
-
return
|
|
84
|
+
return read();
|
|
89
85
|
};
|
|
90
86
|
const pending = Promise.resolve().then(() => {
|
|
91
87
|
if (this.online)
|
|
@@ -98,46 +94,9 @@ export class FetchQueryCache {
|
|
|
98
94
|
if (value === undefined)
|
|
99
95
|
throw new Error(`${JSON.stringify(entry.key)} data is undefined`);
|
|
100
96
|
return value;
|
|
101
|
-
}).then(value => {
|
|
102
|
-
// Only the current request may publish or clear invalidation. An older transport
|
|
103
|
-
// need not support abort: its callers follow the replacement request instead.
|
|
104
|
-
if (entry.pending !== pending)
|
|
105
|
-
return this.supersedingResult({ entry });
|
|
106
|
-
// Arbitration and publication share this continuation: a microtask between them would
|
|
107
|
-
// let an older result overwrite a replacement accepted after arbitration.
|
|
108
|
-
if (replacement !== entry.replacement) {
|
|
109
|
-
this.publish(entry, { ...entry.state, isFetching: false });
|
|
110
|
-
return entry.state.data;
|
|
111
|
-
}
|
|
112
|
-
entry.updatedAt = this.clock.nowMs();
|
|
113
|
-
entry.invalidated = false;
|
|
114
|
-
this.publish(entry, { data: value, error: null, status: 'success', isFetching: false });
|
|
115
|
-
return value;
|
|
116
|
-
}, error => {
|
|
117
|
-
if (entry.pending !== pending)
|
|
118
|
-
return this.supersedingResult({ entry });
|
|
119
|
-
// A replacement write is newer than this read's failure as well as its data.
|
|
120
|
-
// Keep the write's timestamp and freshness; only settle the obsolete fetch flag.
|
|
121
|
-
if (replacement !== entry.replacement) {
|
|
122
|
-
this.publish(entry, { ...entry.state, isFetching: false });
|
|
123
|
-
return entry.state.data;
|
|
124
|
-
}
|
|
125
|
-
entry.invalidated = true;
|
|
126
|
-
this.publish(entry, { ...entry.state, error: toQueryError(error), status: 'error', isFetching: false });
|
|
127
|
-
throw error;
|
|
128
|
-
}).finally(() => {
|
|
129
|
-
if (entry.pending !== pending)
|
|
130
|
-
return;
|
|
131
|
-
entry.pending = undefined;
|
|
132
|
-
entry.pendingRead = undefined;
|
|
133
|
-
if (entry.refreshAfterPending) {
|
|
134
|
-
entry.refreshAfterPending = false;
|
|
135
|
-
this.refresh(entry);
|
|
136
|
-
}
|
|
137
|
-
this.scheduleEviction(entry);
|
|
138
|
-
});
|
|
97
|
+
}).then(value => this.settleSuccess({ entry, pending, replacement, value }), error => this.settleFailure({ entry, pending, replacement, error })).finally(() => this.finishPending({ entry, pending }));
|
|
139
98
|
entry.pending = pending;
|
|
140
|
-
entry.pendingRead = { fetch, staleTime };
|
|
99
|
+
entry.pendingRead = { fetch: read, staleTime };
|
|
141
100
|
// Mark handled even when a UI caller deliberately discards the promise.
|
|
142
101
|
void pending.catch(() => { });
|
|
143
102
|
// Like TanStack's background refetches, retain the last error until success clears it
|
|
@@ -147,6 +106,46 @@ export class FetchQueryCache {
|
|
|
147
106
|
this.publish(entry, { ...state, isFetching: this.online });
|
|
148
107
|
return pending;
|
|
149
108
|
}
|
|
109
|
+
settleSuccess({ entry, pending, replacement, value }) {
|
|
110
|
+
// Only the current request may publish or clear invalidation. An older transport
|
|
111
|
+
// need not support abort: its callers follow the replacement request instead.
|
|
112
|
+
if (entry.pending !== pending)
|
|
113
|
+
return this.supersedingResult({ entry });
|
|
114
|
+
// Arbitration and publication share this continuation: a microtask between them would
|
|
115
|
+
// let an older result overwrite a replacement accepted after arbitration.
|
|
116
|
+
if (replacement !== entry.replacement) {
|
|
117
|
+
this.publish(entry, { ...entry.state, isFetching: false });
|
|
118
|
+
return entry.state.data;
|
|
119
|
+
}
|
|
120
|
+
entry.updatedAt = this.clock.nowMs();
|
|
121
|
+
entry.invalidated = false;
|
|
122
|
+
this.publish(entry, { data: value, error: null, status: 'success', isFetching: false });
|
|
123
|
+
return value;
|
|
124
|
+
}
|
|
125
|
+
settleFailure({ entry, pending, replacement, error }) {
|
|
126
|
+
if (entry.pending !== pending)
|
|
127
|
+
return this.supersedingResult({ entry });
|
|
128
|
+
// A replacement write is newer than this read's failure as well as its data.
|
|
129
|
+
// Keep the write's timestamp and freshness; only settle the obsolete fetch flag.
|
|
130
|
+
if (replacement !== entry.replacement) {
|
|
131
|
+
this.publish(entry, { ...entry.state, isFetching: false });
|
|
132
|
+
return entry.state.data;
|
|
133
|
+
}
|
|
134
|
+
entry.invalidated = true;
|
|
135
|
+
this.publish(entry, { ...entry.state, error: toQueryError({ value: error }), status: 'error', isFetching: false });
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
finishPending({ entry, pending }) {
|
|
139
|
+
if (entry.pending !== pending)
|
|
140
|
+
return;
|
|
141
|
+
entry.pending = undefined;
|
|
142
|
+
entry.pendingRead = undefined;
|
|
143
|
+
if (entry.refreshAfterPending) {
|
|
144
|
+
entry.refreshAfterPending = false;
|
|
145
|
+
this.refresh(entry);
|
|
146
|
+
}
|
|
147
|
+
this.scheduleEviction(entry);
|
|
148
|
+
}
|
|
150
149
|
replace({ entry, data }) {
|
|
151
150
|
entry.replacement += 1;
|
|
152
151
|
entry.updatedAt = this.clock.nowMs();
|
package/dist/fetch/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Framework-neutral query contracts and cache; hosts supply transport callbacks and environment ports. */
|
|
2
2
|
export { DEFAULT_STALE_TIME, IDLE_RETENTION, FetchQueryCache, toQueryError } from './cache.js';
|
|
3
|
-
export type { QueryCacheSchedulerPort, FetchQueryEnvironmentPort, FetchQueryCacheOptions, QueryState, QueryObserver, CacheEntry } from './cache.js';
|
|
3
|
+
export type { QueryCacheSchedulerPort, FetchQueryEnvironmentPort, FetchQueryCacheOptions, FetchQueryCacheRequired, QueryState, QueryObserver, CacheEntry } from './cache.js';
|
|
4
4
|
export type { QueryKey, QueryStatus, QueryResult, FetchQueryOptions, MutationStatus, MutationResult, FetchMutationOptions, CachedLoaderOptions, CachedLoaderDefaults, CachedLoader, FetchQueryAdapter } from './types.js';
|
|
5
5
|
export { missingCachedLoaderFetchError, withCachedLoaderFetch } from './loader-read.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -4,7 +4,9 @@ import type { CachedLoaderDefaults, CachedLoaderOptions, QueryKey } from './type
|
|
|
4
4
|
* `fetch`. Named, rather than left to a `TypeError: fetch is not a function` from deep inside a cache
|
|
5
5
|
* adapter, so the misuse points at the call site that needs to pass `{ key, fetch }`.
|
|
6
6
|
*/
|
|
7
|
-
export declare function missingCachedLoaderFetchError(key
|
|
7
|
+
export declare function missingCachedLoaderFetchError({ key }: {
|
|
8
|
+
key: QueryKey;
|
|
9
|
+
}, _optional?: Record<string, never>): Error;
|
|
8
10
|
/**
|
|
9
11
|
* Runs `read` with a fully specified `{ key, fetch }`, or rejects with
|
|
10
12
|
* {@link missingCachedLoaderFetchError} when `required` (a loader's own defaults, for an argument-less
|
|
@@ -12,5 +14,7 @@ export declare function missingCachedLoaderFetchError(key: QueryKey): Error;
|
|
|
12
14
|
* a failed fetch there would publish an error state to every observer of that key.
|
|
13
15
|
* Shared by every `FetchQueryAdapter` so each adapter's `load` stays a single straight-line call.
|
|
14
16
|
*/
|
|
15
|
-
export declare function withCachedLoaderFetch<T>(required: CachedLoaderDefaults<T
|
|
17
|
+
export declare function withCachedLoaderFetch<T>(required: CachedLoaderDefaults<T> & {
|
|
18
|
+
read: (resolved: Pick<CachedLoaderOptions<T>, 'key' | 'fetch'>) => Promise<T>;
|
|
19
|
+
}, _optional?: Record<string, never>): Promise<T>;
|
|
16
20
|
//# sourceMappingURL=loader-read.d.ts.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* `fetch`. Named, rather than left to a `TypeError: fetch is not a function` from deep inside a cache
|
|
4
4
|
* adapter, so the misuse points at the call site that needs to pass `{ key, fetch }`.
|
|
5
5
|
*/
|
|
6
|
-
export function missingCachedLoaderFetchError(key) {
|
|
6
|
+
export function missingCachedLoaderFetchError({ key }, _optional = {}) {
|
|
7
7
|
return new Error(`Cached loader for key ${JSON.stringify(key)} has no default fetch: call load({ key, fetch }) with a fetch of its own`);
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
@@ -13,10 +13,10 @@ export function missingCachedLoaderFetchError(key) {
|
|
|
13
13
|
* a failed fetch there would publish an error state to every observer of that key.
|
|
14
14
|
* Shared by every `FetchQueryAdapter` so each adapter's `load` stays a single straight-line call.
|
|
15
15
|
*/
|
|
16
|
-
export function withCachedLoaderFetch(required,
|
|
17
|
-
const { key, fetch } = required;
|
|
16
|
+
export function withCachedLoaderFetch(required, _optional = {}) {
|
|
17
|
+
const { key, fetch, read } = required;
|
|
18
18
|
if (fetch === undefined)
|
|
19
|
-
return Promise.reject(missingCachedLoaderFetchError(key));
|
|
19
|
+
return Promise.reject(missingCachedLoaderFetchError({ key }));
|
|
20
20
|
return read({ key, fetch });
|
|
21
21
|
}
|
|
22
22
|
//# sourceMappingURL=loader-read.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SecretRedactionOptions } from './redaction-patterns.js';
|
|
2
|
+
/**
|
|
3
|
+
* Universal diagnostic text for any thrown value. Keeps native stacks and structured metadata,
|
|
4
|
+
* then applies the shared credential policy (PII stays readable unless explicitly requested).
|
|
5
|
+
* Diagnostic getters, serialization and coercion can themselves fail; fixed fallback text keeps
|
|
6
|
+
* those failures from replacing the original error or interrupting the caller's recovery.
|
|
7
|
+
* @param required.error - Untrusted thrown value; never mutated.
|
|
8
|
+
* @param options - Shared redaction options, including caller-owned exact secrets.
|
|
9
|
+
* @returns Redacted text; never throws, including for circular objects and hostile accessors.
|
|
10
|
+
* @complexity O(n) serialization in the diagnostic's fields/characters, plus shared redaction passes.
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatErrorForLog(required: {
|
|
13
|
+
error: unknown;
|
|
14
|
+
}, options?: SecretRedactionOptions): string;
|
|
15
|
+
//# sourceMappingURL=format-error-for-log.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { redactSecrets } from './redact.js';
|
|
2
|
+
/**
|
|
3
|
+
* Universal diagnostic text for any thrown value. Keeps native stacks and structured metadata,
|
|
4
|
+
* then applies the shared credential policy (PII stays readable unless explicitly requested).
|
|
5
|
+
* Diagnostic getters, serialization and coercion can themselves fail; fixed fallback text keeps
|
|
6
|
+
* those failures from replacing the original error or interrupting the caller's recovery.
|
|
7
|
+
* @param required.error - Untrusted thrown value; never mutated.
|
|
8
|
+
* @param options - Shared redaction options, including caller-owned exact secrets.
|
|
9
|
+
* @returns Redacted text; never throws, including for circular objects and hostile accessors.
|
|
10
|
+
* @complexity O(n) serialization in the diagnostic's fields/characters, plus shared redaction passes.
|
|
11
|
+
*/
|
|
12
|
+
export function formatErrorForLog(required, options = {}) {
|
|
13
|
+
try {
|
|
14
|
+
const { error } = required;
|
|
15
|
+
let text;
|
|
16
|
+
if (error instanceof Error) {
|
|
17
|
+
const message = String(error.message);
|
|
18
|
+
text = String(error.stack ?? `${error.name}: ${message}`);
|
|
19
|
+
if (!text.includes(message))
|
|
20
|
+
text += `\n${message}`;
|
|
21
|
+
const fields = Object.fromEntries(Object.getOwnPropertyNames(error)
|
|
22
|
+
.filter(key => !['name', 'message', 'stack'].includes(key)).map(key => [key, Reflect.get(error, key)]));
|
|
23
|
+
if (Object.keys(fields).length)
|
|
24
|
+
text += `\n${diagnosticJson({ error: fields }, options)}`;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
text = error !== null && typeof error === 'object' ? diagnosticJson({ error }, options) : String(error);
|
|
28
|
+
}
|
|
29
|
+
return redactSecrets({ input: text }, { redactPii: false, ...options });
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return '[Unformattable error]';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** JSON preserves structured fields without coercing objects; track cycles and native Error fields.
|
|
36
|
+
* Property access remains inside formatErrorForLog's recovery boundary. O(n) visited fields. */
|
|
37
|
+
function diagnosticJson({ error }, options = {}) {
|
|
38
|
+
const seen = new WeakSet();
|
|
39
|
+
return JSON.stringify(error, (_key, value) => {
|
|
40
|
+
if (value !== null && typeof value === 'object') {
|
|
41
|
+
if (seen.has(value))
|
|
42
|
+
return '[Circular]';
|
|
43
|
+
seen.add(value);
|
|
44
|
+
if (value instanceof Error)
|
|
45
|
+
return Object.fromEntries(Object.getOwnPropertyNames(value).map(key => [key, Reflect.get(value, key)]));
|
|
46
|
+
}
|
|
47
|
+
// Scrub string contents before JSON escapes their credential labels. Exact-only is kept
|
|
48
|
+
// for the final pass so a caller's literal marker is never reprocessed as a supplied secret.
|
|
49
|
+
if (typeof value === 'string' && options.policy !== 'exact-only') {
|
|
50
|
+
return redactSecrets({ input: value }, { redactPii: false, ...options });
|
|
51
|
+
}
|
|
52
|
+
return typeof value === 'bigint' ? String(value) : value;
|
|
53
|
+
}) ?? String(error);
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=format-error-for-log.js.map
|
|
@@ -99,6 +99,7 @@ export declare function confirm(required: {
|
|
|
99
99
|
hooks: GatedMutationHooks<unknown, unknown>;
|
|
100
100
|
planId: string;
|
|
101
101
|
planHash: string;
|
|
102
|
+
signal?: AbortSignal;
|
|
102
103
|
}, _optional?: Record<string, never>): Promise<ConfirmationTokenRecord>;
|
|
103
104
|
/**
|
|
104
105
|
* Rejection precedence is binding when failures co-occur: fresh authorization, token state,
|
|
@@ -112,5 +113,6 @@ export declare function execute<TResult>(required: {
|
|
|
112
113
|
principalKind: PrincipalKind;
|
|
113
114
|
hooks: GatedMutationHooks<unknown, TResult>;
|
|
114
115
|
confirmationToken: string;
|
|
116
|
+
signal?: AbortSignal;
|
|
115
117
|
}, _optional?: Record<string, never>): Promise<TResult>;
|
|
116
118
|
//# sourceMappingURL=gateway.d.ts.map
|
|
@@ -91,6 +91,7 @@ export async function confirm(required, _optional = {}) {
|
|
|
91
91
|
generateToken: deps.generateToken,
|
|
92
92
|
ttlSeconds: deps.ttlSeconds,
|
|
93
93
|
});
|
|
94
|
+
required.signal?.throwIfAborted();
|
|
94
95
|
await deps.tokens.save({ record: token });
|
|
95
96
|
return token;
|
|
96
97
|
}
|
|
@@ -121,7 +122,9 @@ export async function execute(required, _optional = {}) {
|
|
|
121
122
|
}
|
|
122
123
|
// Concurrent executions can pass every earlier check; atomic redemption makes the loser fail
|
|
123
124
|
// before its domain mutation, preventing a second application of the same approval.
|
|
124
|
-
const
|
|
125
|
+
const now = nowIso({ clock: deps.clock });
|
|
126
|
+
required.signal?.throwIfAborted();
|
|
127
|
+
const { redeemed, record: latestRecord } = await deps.tokens.tryRedeem({ token: confirmationToken, now });
|
|
125
128
|
if (!redeemed)
|
|
126
129
|
throw unredeemableTokenError(latestRecord);
|
|
127
130
|
return hooks.executeMutation({ planHash, details });
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The host's read-tool vocabulary: how model-facing domain-package text names the host's tool that reads
|
|
3
|
+
* an entity back ("call X to list valid terms", "as returned by X").
|
|
4
|
+
*
|
|
5
|
+
* Why this is a port: the read tool is a host product's tool id (a host publishes its reads as one
|
|
6
|
+
* family, and the engine may not name any host tool — `scripts/check-engine-boundaries.ts`'s
|
|
7
|
+
* `HOST_TOOL_NAMES`). The package text therefore names an *entity* and the host says how it reads it;
|
|
8
|
+
* a host that binds nothing gets neutral wording, so no tool id the host never registered reaches a
|
|
9
|
+
* model. Same mechanism as the daemon's `ToolFamilyPort`: product names reach a model through a
|
|
10
|
+
* host-supplied port, never through engine source.
|
|
11
|
+
*
|
|
12
|
+
* Architectural role: tool kit (with `model-facing-tool-errors`) — domain catalogs write `{{read:<entity>}}` placeholders
|
|
13
|
+
* in static text and `resolveHostReadRefs` fills them when a domain's registrations are built.
|
|
14
|
+
*/
|
|
15
|
+
/** An entity whose read-back a domain's tool text points a model at, named by the domain (e.g. `redirect`, `seo_entry_meta`). */
|
|
16
|
+
export type HostReadEntity = string;
|
|
17
|
+
/** How the host names the tool call that reads an entity back. */
|
|
18
|
+
export interface HostReadVocabulary {
|
|
19
|
+
/** The text a model should see for "read this entity", e.g. a host tool id. */
|
|
20
|
+
readonly readRef: (required: {
|
|
21
|
+
entity: HostReadEntity;
|
|
22
|
+
}, optional?: Record<string, never>) => string;
|
|
23
|
+
}
|
|
24
|
+
/** Wording for a host that binds no vocabulary: names the read, never a tool id. */
|
|
25
|
+
export declare const NEUTRAL_HOST_READ_VOCABULARY: HostReadVocabulary;
|
|
26
|
+
/** The placeholder a static catalog text carries for `entity`. */
|
|
27
|
+
export declare function hostReadRef({ entity }: {
|
|
28
|
+
entity: HostReadEntity;
|
|
29
|
+
}, _optional?: {}): string;
|
|
30
|
+
/** Resolves every placeholder in `text` through `hostReads`; text without one is returned as is. */
|
|
31
|
+
export declare function resolveHostReadText({ text }: {
|
|
32
|
+
text: string;
|
|
33
|
+
}, { hostReads }?: {
|
|
34
|
+
hostReads?: HostReadVocabulary | undefined;
|
|
35
|
+
}): string;
|
|
36
|
+
/**
|
|
37
|
+
* Deep-copies `value` with every string resolved by {@link resolveHostReadText}. Used on a domain's
|
|
38
|
+
* static catalog when its registrations are built; the input is never mutated.
|
|
39
|
+
*
|
|
40
|
+
* @complexity O(n) in the catalog's nodes.
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveHostReadRefs<T>({ value }: {
|
|
43
|
+
value: T;
|
|
44
|
+
}, optional?: {
|
|
45
|
+
hostReads?: HostReadVocabulary | undefined;
|
|
46
|
+
}): T;
|
|
47
|
+
//# sourceMappingURL=host-read-vocabulary.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The host's read-tool vocabulary: how model-facing domain-package text names the host's tool that reads
|
|
3
|
+
* an entity back ("call X to list valid terms", "as returned by X").
|
|
4
|
+
*
|
|
5
|
+
* Why this is a port: the read tool is a host product's tool id (a host publishes its reads as one
|
|
6
|
+
* family, and the engine may not name any host tool — `scripts/check-engine-boundaries.ts`'s
|
|
7
|
+
* `HOST_TOOL_NAMES`). The package text therefore names an *entity* and the host says how it reads it;
|
|
8
|
+
* a host that binds nothing gets neutral wording, so no tool id the host never registered reaches a
|
|
9
|
+
* model. Same mechanism as the daemon's `ToolFamilyPort`: product names reach a model through a
|
|
10
|
+
* host-supplied port, never through engine source.
|
|
11
|
+
*
|
|
12
|
+
* Architectural role: tool kit (with `model-facing-tool-errors`) — domain catalogs write `{{read:<entity>}}` placeholders
|
|
13
|
+
* in static text and `resolveHostReadRefs` fills them when a domain's registrations are built.
|
|
14
|
+
*/
|
|
15
|
+
/** Wording for a host that binds no vocabulary: names the read, never a tool id. */
|
|
16
|
+
export const NEUTRAL_HOST_READ_VOCABULARY = {
|
|
17
|
+
readRef: ({ entity }) => `the ${entity.replaceAll("_", " ")} read tool`,
|
|
18
|
+
};
|
|
19
|
+
/** The placeholder a static catalog text carries for `entity`. */
|
|
20
|
+
export function hostReadRef({ entity }, _optional = {}) {
|
|
21
|
+
return `{{read:${entity}}}`;
|
|
22
|
+
}
|
|
23
|
+
const PLACEHOLDER = /\{\{read:([a-z_]+)\}\}/g;
|
|
24
|
+
/** Resolves every placeholder in `text` through `hostReads`; text without one is returned as is. */
|
|
25
|
+
export function resolveHostReadText({ text }, { hostReads = NEUTRAL_HOST_READ_VOCABULARY } = {}) {
|
|
26
|
+
return text.replace(PLACEHOLDER, (_whole, entity) => hostReads.readRef({ entity: entity }));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Deep-copies `value` with every string resolved by {@link resolveHostReadText}. Used on a domain's
|
|
30
|
+
* static catalog when its registrations are built; the input is never mutated.
|
|
31
|
+
*
|
|
32
|
+
* @complexity O(n) in the catalog's nodes.
|
|
33
|
+
*/
|
|
34
|
+
export function resolveHostReadRefs({ value }, optional = {}) {
|
|
35
|
+
if (typeof value === "string")
|
|
36
|
+
return resolveHostReadText({ text: value }, optional);
|
|
37
|
+
if (Array.isArray(value))
|
|
38
|
+
return value.map((item) => resolveHostReadRefs({ value: item }, optional));
|
|
39
|
+
if (value !== null && typeof value === "object") {
|
|
40
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, resolveHostReadRefs({ value: item }, optional)]));
|
|
41
|
+
}
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=host-read-vocabulary.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ export { createDaemon } from './daemon.js';
|
|
|
7
7
|
export type { PackDisposalFailure } from './pack-lifecycle.js';
|
|
8
8
|
export { disposePacks, registerPackTools } from './pack-lifecycle.js';
|
|
9
9
|
export * from './redact.js';
|
|
10
|
+
export { type SecretShapePattern, PEM_PATTERN_NAME, SECRET_SHAPE_PATTERNS, createPrivateKeyLineRedactor, AGENT_FAILURE_SECRET_SHAPE_RE, CREDENTIAL_FILE_DENY_SEGMENTS, LOCAL_OWNER_PROXY_MARKER_PREFIXES, LOCAL_OWNER_PROXY_MARKER_HEADERS } from './secret-shapes.js';
|
|
11
|
+
export { type SecretRedactionPattern, GENERATED_MARKER_RE, type SecretRedactionOptions, LABELED_SECRET_RE, OPAQUE_TOKEN_RE, NON_SECRET_TOKEN_RE } from './redaction-patterns.js';
|
|
12
|
+
export { formatErrorForLog } from './format-error-for-log.js';
|
|
10
13
|
export * from './user-facing-error.js';
|
|
11
14
|
export { onTeardown, runTeardownSteps, type TeardownHost, type TeardownStep } from './teardown.js';
|
|
12
15
|
export * from './api-token-auth.js';
|
|
@@ -20,6 +23,7 @@ export * from './tool-tokens.js';
|
|
|
20
23
|
export * from './tool-exposure.js';
|
|
21
24
|
export * from './gated-mutations.js';
|
|
22
25
|
export * from './model-facing-tool-errors.js';
|
|
26
|
+
export * from './host-read-vocabulary.js';
|
|
23
27
|
export { createContributionRegistry } from './contribution-registry.js';
|
|
24
28
|
export type { ContributionRegistry, ToolContributor, DerivedToolContributor, ToolContributions } from './contribution-registry.js';
|
|
25
29
|
export * from './provider-registry.js';
|
|
@@ -30,7 +34,7 @@ export * from "./registration-kit.js";
|
|
|
30
34
|
export * from "./approval.js";
|
|
31
35
|
export * from './target-scope.js';
|
|
32
36
|
export * from "./native-regexp.js";
|
|
33
|
-
export { ForbiddenError as ToolPermissionDeniedError, requireToolPermission, adaptLegacyAuthorize, type LegacyToolAuthorizeFn, type AuthorizationPort as ToolPermissionAuthorizationPort, type RequireToolPermissionRequired, type RequireToolPermissionOptional, } from "./tool-permissions.js";
|
|
37
|
+
export { ForbiddenError as ToolPermissionDeniedError, requireToolPermission, adaptLegacyAuthorize, type LegacyToolAuthorizeFn, type AuthorizationPort as ToolPermissionAuthorizationPort, type AuthorizationRequired as ToolPermissionAuthorizationRequired, type AuthorizationOptional as ToolPermissionAuthorizationOptional, type RequireToolPermissionRequired, type RequireToolPermissionOptional, } from "./tool-permissions.js";
|
|
34
38
|
export { evaluateFeatureFlag, type FeatureFlagDecision } from './feature-flags.js';
|
|
35
39
|
export { normalizeToolInput, withNormalizationNotes, ToolInputNormalizationError, type NormalizedToolInput, type ToolInputNormalizer } from './tool-input-normalization.js';
|
|
36
40
|
export { decodeToolInputObject, unwrapToolInputEnvelope } from './tool-input-envelope.js';
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,9 @@ export * from './bindings.js';
|
|
|
5
5
|
export { createDaemon } from './daemon.js';
|
|
6
6
|
export { disposePacks, registerPackTools } from './pack-lifecycle.js';
|
|
7
7
|
export * from './redact.js';
|
|
8
|
+
export { PEM_PATTERN_NAME, SECRET_SHAPE_PATTERNS, createPrivateKeyLineRedactor, AGENT_FAILURE_SECRET_SHAPE_RE, CREDENTIAL_FILE_DENY_SEGMENTS, LOCAL_OWNER_PROXY_MARKER_PREFIXES, LOCAL_OWNER_PROXY_MARKER_HEADERS } from './secret-shapes.js';
|
|
9
|
+
export { GENERATED_MARKER_RE, LABELED_SECRET_RE, OPAQUE_TOKEN_RE, NON_SECRET_TOKEN_RE } from './redaction-patterns.js';
|
|
10
|
+
export { formatErrorForLog } from './format-error-for-log.js';
|
|
8
11
|
export * from './user-facing-error.js';
|
|
9
12
|
export { onTeardown, runTeardownSteps } from './teardown.js';
|
|
10
13
|
export * from './api-token-auth.js';
|
|
@@ -16,6 +19,7 @@ export * from './tool-tokens.js';
|
|
|
16
19
|
export * from './tool-exposure.js';
|
|
17
20
|
export * from './gated-mutations.js';
|
|
18
21
|
export * from './model-facing-tool-errors.js';
|
|
22
|
+
export * from './host-read-vocabulary.js';
|
|
19
23
|
export { createContributionRegistry } from './contribution-registry.js';
|
|
20
24
|
export * from './provider-registry.js';
|
|
21
25
|
export * from './object-store.js';
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/** One page of a list. `nextCursor === null` means there is nothing after these items. */
|
|
2
|
+
export interface ListPage<T> {
|
|
3
|
+
readonly items: readonly T[];
|
|
4
|
+
readonly nextCursor: string | null;
|
|
5
|
+
}
|
|
6
|
+
/** A keyset position: the row's sort values, ending with its unique id as the tie-breaker. */
|
|
7
|
+
export type ListPosition = readonly (string | number)[];
|
|
8
|
+
/** The type of each position component, sort keys then id. Given by the caller, never learned from a row. */
|
|
9
|
+
export type ListPositionShape = readonly ('string' | 'number')[];
|
|
10
|
+
/** Hard ceiling when a caller names none — big enough for any screen, small enough for one response. */
|
|
11
|
+
export declare const DEFAULT_MAX_LIST_LIMIT = 200;
|
|
12
|
+
/** Default page size when a caller names none. */
|
|
13
|
+
export declare const DEFAULT_LIST_LIMIT = 50;
|
|
14
|
+
/**
|
|
15
|
+
* Builds the opaque cursor for the row a page ended on.
|
|
16
|
+
* @complexity O(position size).
|
|
17
|
+
*/
|
|
18
|
+
export declare function encodeListCursor(required: {
|
|
19
|
+
position: ListPosition;
|
|
20
|
+
}, _optional?: Record<string, never>): string;
|
|
21
|
+
/**
|
|
22
|
+
* Reads a cursor {@link encodeListCursor} built. Refuses anything else instead of restarting from the
|
|
23
|
+
* first page — a silently restarted scan repeats rows forever.
|
|
24
|
+
*
|
|
25
|
+
* @param required.shape - The type of each value in the position (sort keys + id).
|
|
26
|
+
* @throws {ToolInputError} `invalid cursor` (a 400 on HTTP, a correctable input error for a tool).
|
|
27
|
+
* @complexity O(cursor length).
|
|
28
|
+
*/
|
|
29
|
+
export declare function decodeListCursor(required: {
|
|
30
|
+
cursor: string;
|
|
31
|
+
shape: ListPositionShape;
|
|
32
|
+
}, _optional?: Record<string, never>): ListPosition;
|
|
33
|
+
/**
|
|
34
|
+
* Reads `{ limit, cursor }` off an untrusted request (query string or tool input). An absent limit
|
|
35
|
+
* becomes the default; a limit above the ceiling is clamped (a caller asking for "everything" gets
|
|
36
|
+
* the most one page holds plus a cursor, never an error); anything malformed is refused.
|
|
37
|
+
*
|
|
38
|
+
* @throws {ToolInputError} for a non-integer/non-positive limit or a non-string cursor.
|
|
39
|
+
* @complexity O(1).
|
|
40
|
+
*/
|
|
41
|
+
export declare function parseListPageRequest(required: {
|
|
42
|
+
value: {
|
|
43
|
+
limit?: unknown;
|
|
44
|
+
cursor?: unknown;
|
|
45
|
+
};
|
|
46
|
+
}, optional?: {
|
|
47
|
+
defaultLimit?: number;
|
|
48
|
+
maxLimit?: number;
|
|
49
|
+
}): {
|
|
50
|
+
limit: number;
|
|
51
|
+
cursor: string | null;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Cuts a page from a query that fetched `limit + 1` rows in keyset order. The extra row only proves
|
|
55
|
+
* more exist; it is never returned.
|
|
56
|
+
*
|
|
57
|
+
* @complexity O(limit).
|
|
58
|
+
*/
|
|
59
|
+
export declare function pageFromOverfetch<T>(required: {
|
|
60
|
+
rows: readonly T[];
|
|
61
|
+
limit: number;
|
|
62
|
+
positionOf: (row: T) => ListPosition;
|
|
63
|
+
}, _optional?: Record<string, never>): ListPage<T>;
|
|
64
|
+
/**
|
|
65
|
+
* The in-memory twin of a keyset query: sorts by position, keeps rows strictly after the cursor, and
|
|
66
|
+
* cuts a page — so a memory repo and its SQL sibling answer the same contract test identically.
|
|
67
|
+
* Ascending order only; a descending list negates or reverses its sort key in `positionOf`.
|
|
68
|
+
*
|
|
69
|
+
* @complexity O(n log n).
|
|
70
|
+
*/
|
|
71
|
+
export declare function pageFromArray<T>(required: {
|
|
72
|
+
rows: readonly T[];
|
|
73
|
+
limit: number;
|
|
74
|
+
cursor: string | null;
|
|
75
|
+
positionOf: (row: T) => ListPosition;
|
|
76
|
+
shape: ListPositionShape;
|
|
77
|
+
}, _optional?: Record<string, never>): ListPage<T>;
|
|
78
|
+
/**
|
|
79
|
+
* What an assistant tool returns for a page: the items, the cursor, and — only when more exist — a
|
|
80
|
+
* plain sentence telling the model the list is NOT complete and exactly how to continue. Without
|
|
81
|
+
* that sentence a model reads 100 rows as "all members".
|
|
82
|
+
*
|
|
83
|
+
* @complexity O(1).
|
|
84
|
+
*/
|
|
85
|
+
export declare function listPageForModel<T>(required: {
|
|
86
|
+
page: ListPage<T>;
|
|
87
|
+
toolId: string;
|
|
88
|
+
}, _optional?: Record<string, never>): {
|
|
89
|
+
items: readonly T[];
|
|
90
|
+
nextCursor: string | null;
|
|
91
|
+
more?: string;
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=list-page.d.ts.map
|