@jini-ai/core 0.7.2 → 0.7.3-next.1
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 +0 -2
- 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 +232 -0
- package/dist/contracts/observability.js +27 -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/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 +234 -13
- 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,20 @@
|
|
|
1
|
+
/** Caller-safe failures never include event values, recipients or credentials. */
|
|
2
|
+
export class EmailSenderError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
constructor(required, _optional = {}) {
|
|
5
|
+
super(`Email sender: ${required.code}`);
|
|
6
|
+
this.code = required.code;
|
|
7
|
+
this.name = "EmailSenderError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/** Refuses unsupported declarations and undeclared placeholders before activation or rendering.
|
|
11
|
+
* @complexity O(f + d + p) source fields, declarations and placeholders; no I/O. */
|
|
12
|
+
export function validateEmailSourceTemplate(required, _optional = {}) {
|
|
13
|
+
const available = new Set(required.fields.map(field => field.token));
|
|
14
|
+
const declared = new Set(required.template.fields);
|
|
15
|
+
if (required.template.fields.some(token => !available.has(token)))
|
|
16
|
+
throw new EmailSenderError({ code: "incompatible" });
|
|
17
|
+
if (required.template.placeholders.some(token => !declared.has(token)))
|
|
18
|
+
throw new EmailSenderError({ code: "incompatible" });
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=email-sender.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface SmtpTransport {
|
|
2
|
+
sendMail(required: {
|
|
3
|
+
mail: SmtpMailPayload;
|
|
4
|
+
}): Promise<{
|
|
5
|
+
messageId: string;
|
|
6
|
+
}>;
|
|
7
|
+
}
|
|
8
|
+
export interface SmtpMailPayload {
|
|
9
|
+
from: {
|
|
10
|
+
name?: string;
|
|
11
|
+
address: string;
|
|
12
|
+
};
|
|
13
|
+
to: {
|
|
14
|
+
name?: string;
|
|
15
|
+
address: string;
|
|
16
|
+
};
|
|
17
|
+
replyTo?: {
|
|
18
|
+
name?: string;
|
|
19
|
+
address: string;
|
|
20
|
+
};
|
|
21
|
+
subject: string;
|
|
22
|
+
html?: string;
|
|
23
|
+
text?: string;
|
|
24
|
+
headers?: Readonly<Record<string, string>>;
|
|
25
|
+
attachments?: {
|
|
26
|
+
filename: string;
|
|
27
|
+
content: string;
|
|
28
|
+
encoding: "base64";
|
|
29
|
+
contentType: string;
|
|
30
|
+
}[];
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=smtp-payload.d.ts.map
|
package/dist/contracts/mail.d.ts
CHANGED
|
@@ -125,4 +125,6 @@ export interface PluginMailHttpClient {
|
|
|
125
125
|
redirect?: import("../primitives/http.js").RequestRedirect;
|
|
126
126
|
}): Promise<import("../primitives/http.js").HttpResponse>;
|
|
127
127
|
}
|
|
128
|
+
export * from "./mail/email-sender.js";
|
|
129
|
+
export type * from "./mail/smtp-payload.js";
|
|
128
130
|
//# sourceMappingURL=mail.d.ts.map
|
package/dist/contracts/mail.js
CHANGED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/** Vendor-neutral inbound request lifecycle. Route patterns, rather than raw paths, label metrics. */
|
|
2
|
+
/**
|
|
3
|
+
* Consumers speak in request lifecycle terms rather than Span/Tracer SDK types. That permits
|
|
4
|
+
* replacing the instrumentation system itself, not merely its exporter backend. Add signals
|
|
5
|
+
* only against real instrumentation call sites; guessed DB/outbound/agent shapes would couple
|
|
6
|
+
* consumers to contracts whose lifecycle has not yet been established.
|
|
7
|
+
* The DB/outbound/agent signals below were each shaped after their first real call site: the
|
|
8
|
+
* storage kernel's run/transaction body, the guarded HTTP client's send, and a host's agent-run
|
|
9
|
+
* watcher. Inputs carry ids and fixed labels only; adapters own redaction of anything raw.
|
|
10
|
+
*/
|
|
11
|
+
export interface RequestTrackingInput {
|
|
12
|
+
method: string;
|
|
13
|
+
path: string;
|
|
14
|
+
}
|
|
15
|
+
export interface RequestTrackingOptions {
|
|
16
|
+
requestId?: string;
|
|
17
|
+
}
|
|
18
|
+
/** The mount-aware pattern is available only after routing; raw paths are known at request start.
|
|
19
|
+
* Use a fixed 'unmatched' label for misses: attacker-controlled paths would make grouping unbounded. */
|
|
20
|
+
export interface RequestTrackingOutcome {
|
|
21
|
+
statusCode: number;
|
|
22
|
+
routePattern: string;
|
|
23
|
+
}
|
|
24
|
+
/** Runs work inside a tracker's scope, so signals that work starts are attributed to it. */
|
|
25
|
+
export interface TrackerScope {
|
|
26
|
+
run<T>(fn: () => T): T;
|
|
27
|
+
}
|
|
28
|
+
export interface RequestTracker {
|
|
29
|
+
readonly requestId?: string;
|
|
30
|
+
end(outcome: RequestTrackingOutcome): void;
|
|
31
|
+
/** Optional so adapters written before scoping still satisfy the port; callers fall back to fn(). */
|
|
32
|
+
run?<T>(fn: () => T): T;
|
|
33
|
+
}
|
|
34
|
+
/** `system` is the engine family (`sqlite`, `postgresql`); statement text never crosses the port. */
|
|
35
|
+
export interface DbQueryTrackingInput {
|
|
36
|
+
system: string;
|
|
37
|
+
}
|
|
38
|
+
/** Like a route pattern, the operation and table are known only once the query has been built. */
|
|
39
|
+
export interface DbQueryTrackingOutcome {
|
|
40
|
+
operation: string;
|
|
41
|
+
table?: string;
|
|
42
|
+
error?: unknown;
|
|
43
|
+
}
|
|
44
|
+
export interface DbQueryTracker extends TrackerScope {
|
|
45
|
+
end(outcome: DbQueryTrackingOutcome): void;
|
|
46
|
+
}
|
|
47
|
+
/** The raw URL is handed over whole; adapters keep scheme/host/port and drop path, query and userinfo. */
|
|
48
|
+
export interface OutboundCallTrackingInput {
|
|
49
|
+
method: string;
|
|
50
|
+
url: string;
|
|
51
|
+
}
|
|
52
|
+
/** `statusCode` when a response arrived, `error` when the call failed before one did. */
|
|
53
|
+
export interface OutboundCallTrackingOutcome {
|
|
54
|
+
statusCode?: number;
|
|
55
|
+
error?: unknown;
|
|
56
|
+
}
|
|
57
|
+
export interface OutboundCallTracker extends TrackerScope {
|
|
58
|
+
end(outcome: OutboundCallTrackingOutcome): void;
|
|
59
|
+
}
|
|
60
|
+
export interface AgentRunTrackingInput {
|
|
61
|
+
runId: string;
|
|
62
|
+
}
|
|
63
|
+
export interface AgentRunTrackingOptions {
|
|
64
|
+
conversationId?: string;
|
|
65
|
+
agentName?: string;
|
|
66
|
+
}
|
|
67
|
+
/** `interrupted`: the run vanished (its process restarted). `abandoned`: the watcher gave up unproven. */
|
|
68
|
+
export type AgentRunStatus = 'succeeded' | 'failed' | 'canceled' | 'interrupted' | 'abandoned';
|
|
69
|
+
export interface AgentRunTrackingOutcome {
|
|
70
|
+
status: AgentRunStatus;
|
|
71
|
+
error?: unknown;
|
|
72
|
+
}
|
|
73
|
+
export interface AgentRunTracker extends TrackerScope {
|
|
74
|
+
end(outcome: AgentRunTrackingOutcome): void;
|
|
75
|
+
}
|
|
76
|
+
/** Fixed labels and ids only (a tool id, a run id): never user text, paths, or values a caller sent. */
|
|
77
|
+
export type OperationAttributes = Readonly<Record<string, string | number>>;
|
|
78
|
+
/**
|
|
79
|
+
* A feature-level unit of work (one tool call, one publish, one backup) that no transport signal
|
|
80
|
+
* names: the HTTP request, DB queries and outbound calls it makes nest under it. `name` is a fixed
|
|
81
|
+
* dotted label (`tool.call`), never per-call text, so grouping stays bounded.
|
|
82
|
+
*/
|
|
83
|
+
export interface OperationTrackingInput {
|
|
84
|
+
name: string;
|
|
85
|
+
attributes?: OperationAttributes;
|
|
86
|
+
}
|
|
87
|
+
/** `outcome` is the feature's own fixed label (`completed`, `denied`, `timed-out`); `failed` says
|
|
88
|
+
* whether that outcome is a failure, which only the feature can judge (a denial is not one). */
|
|
89
|
+
export interface OperationTrackingOutcome {
|
|
90
|
+
outcome: string;
|
|
91
|
+
failed: boolean;
|
|
92
|
+
attributes?: OperationAttributes;
|
|
93
|
+
}
|
|
94
|
+
export interface OperationTracker extends TrackerScope {
|
|
95
|
+
end(outcome: OperationTrackingOutcome): void;
|
|
96
|
+
}
|
|
97
|
+
/** Correlation assigned by an active tracing implementation; readers never generate IDs. */
|
|
98
|
+
export interface TraceIds {
|
|
99
|
+
readonly traceId: string;
|
|
100
|
+
readonly spanId: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* An error worth an incident report (an error tracker's issue; a trace's exception event), as
|
|
104
|
+
* opposed to an expected failure a tracker's outcome already records. `error` is handed over raw:
|
|
105
|
+
* adapters own redaction (see `describeReportedError`), exactly as they do for request targets.
|
|
106
|
+
*/
|
|
107
|
+
export interface ErrorReport {
|
|
108
|
+
error: unknown;
|
|
109
|
+
context: {
|
|
110
|
+
operation: string;
|
|
111
|
+
attributes?: OperationAttributes;
|
|
112
|
+
level?: 'warning' | 'error';
|
|
113
|
+
trace?: TraceIds;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/** Native crash upload configuration. Provider-specific field names stay opaque to hosts. */
|
|
117
|
+
export interface CrashUpload {
|
|
118
|
+
submitURL: string;
|
|
119
|
+
globalExtra: Readonly<Record<string, string>>;
|
|
120
|
+
}
|
|
121
|
+
/** Vendor-neutral numeric measurement; names and units are fixed labels, never user text. */
|
|
122
|
+
export interface MetricInput {
|
|
123
|
+
name: string;
|
|
124
|
+
value: number;
|
|
125
|
+
}
|
|
126
|
+
export interface MetricOptions {
|
|
127
|
+
kind?: 'counter' | 'gauge' | 'histogram';
|
|
128
|
+
unit?: string;
|
|
129
|
+
attributes?: OperationAttributes;
|
|
130
|
+
}
|
|
131
|
+
export interface ObservabilityPort {
|
|
132
|
+
/** Current structural tracing scope, absent outside a trace. Never generates an ID. */
|
|
133
|
+
activeTraceIds?(required?: Record<string, never>, optional?: Record<string, never>): TraceIds | undefined;
|
|
134
|
+
/** Explicit capability: a callable noop metric does not imply local metric admission. */
|
|
135
|
+
readonly supportsMetric?: boolean;
|
|
136
|
+
/** Records one measurement; adapters without a metrics backend use a no-op. */
|
|
137
|
+
metric(input: MetricInput, options?: MetricOptions): void | Promise<void>;
|
|
138
|
+
trackRequest(input: RequestTrackingInput, options?: RequestTrackingOptions): RequestTracker;
|
|
139
|
+
trackDbQuery(input: DbQueryTrackingInput): DbQueryTracker;
|
|
140
|
+
trackOutboundCall(input: OutboundCallTrackingInput): OutboundCallTracker;
|
|
141
|
+
trackAgentRun(input: AgentRunTrackingInput, options?: AgentRunTrackingOptions): AgentRunTracker;
|
|
142
|
+
trackOperation(input: OperationTrackingInput): OperationTracker;
|
|
143
|
+
/** Called inside a tracker's run() it is attributed to that tracker's work. False refuses local admission; void accepts it. */
|
|
144
|
+
reportError(report: ErrorReport): boolean | void | Promise<boolean | void>;
|
|
145
|
+
/** Configuration only; the host owns crash collection, consent and upload lifecycle. */
|
|
146
|
+
crashUpload?(required: {
|
|
147
|
+
release: string;
|
|
148
|
+
environment: string;
|
|
149
|
+
}, optional?: Record<string, never>): CrashUpload;
|
|
150
|
+
}
|
|
151
|
+
/** What a vendor provider subpath returns: the port plus the host-owned lifecycle hook. The host
|
|
152
|
+
* registers `dispose` with its teardown (a closed site, a stopped process) so SDK clients, timers
|
|
153
|
+
* and exit listeners are released (review 2026-10-25 #6). `dispose` never throws. */
|
|
154
|
+
export interface ObservabilityAdapter {
|
|
155
|
+
port: ObservabilityPort;
|
|
156
|
+
dispose(): Promise<void>;
|
|
157
|
+
}
|
|
158
|
+
export type ProductEventProperties = Readonly<Record<string, string | number | boolean>>;
|
|
159
|
+
/** One thing a user did. `name` is a fixed snake_case label (`assistant_tool_call`), never user text. */
|
|
160
|
+
export interface ProductEvent {
|
|
161
|
+
name: string;
|
|
162
|
+
userId: string;
|
|
163
|
+
properties?: ProductEventProperties;
|
|
164
|
+
}
|
|
165
|
+
/** Who the user is, in pseudonymous traits only (a plan, a role, a locale — never a name or e-mail). */
|
|
166
|
+
export interface ProductIdentity {
|
|
167
|
+
userId: string;
|
|
168
|
+
traits?: ProductEventProperties;
|
|
169
|
+
}
|
|
170
|
+
/** A model generation's neutral metadata. Text is separate so metadata-only providers cannot leak it. */
|
|
171
|
+
export interface ProductAiGeneration {
|
|
172
|
+
userId: string;
|
|
173
|
+
properties: ProductEventProperties;
|
|
174
|
+
input?: string;
|
|
175
|
+
output?: string;
|
|
176
|
+
}
|
|
177
|
+
/** The port features call. Never throws, never blocks: delivery is the adapter's background job. */
|
|
178
|
+
export interface ProductAnalyticsPort {
|
|
179
|
+
/** Optional trusted browser contribution; it contains only publishable browser configuration. */
|
|
180
|
+
browserAnalytics?(required: {
|
|
181
|
+
surface: 'site' | 'admin';
|
|
182
|
+
}, optional?: Record<string, never>): BrowserAnalyticsContribution;
|
|
183
|
+
/** Resolves after local consent/admission only; remote delivery remains in the background. */
|
|
184
|
+
capture(event: ProductEvent): void | Promise<void>;
|
|
185
|
+
identify(identity: ProductIdentity): void;
|
|
186
|
+
/** Optional capability; providers without LLM analytics keep their existing contract. */
|
|
187
|
+
captureAiGeneration?(required: ProductAiGeneration, optional?: Record<string, never>): void;
|
|
188
|
+
/** Explicit provider opt-in only. The default records counts and metadata, never transcript text. */
|
|
189
|
+
readonly includeAiContent?: boolean;
|
|
190
|
+
}
|
|
191
|
+
/** What a vendor provider subpath returns: the port plus the host-owned teardown (flush + close). */
|
|
192
|
+
export interface ProductAnalyticsAdapter {
|
|
193
|
+
port: ProductAnalyticsPort;
|
|
194
|
+
dispose(): Promise<void>;
|
|
195
|
+
}
|
|
196
|
+
/** Browser contribution of a product-analytics provider; the port's `browserAnalytics` returns it, so it lives with the port. */
|
|
197
|
+
export interface BrowserAnalyticsContribution {
|
|
198
|
+
/** Trusted plugin code: a function expression returning a `(mode) => void` controller. */
|
|
199
|
+
readonly source: string;
|
|
200
|
+
/** Exact origins required by this contribution, including anonymous delivery. */
|
|
201
|
+
readonly origins: readonly string[];
|
|
202
|
+
readonly supportsStatic: boolean;
|
|
203
|
+
/** Server-only same-origin asset/collection adapter. Never serialized into page source.
|
|
204
|
+
* The host admits collection with its existing consent owner before invoking this port. */
|
|
205
|
+
readonly http?: {
|
|
206
|
+
readonly path: string;
|
|
207
|
+
handle(required: {
|
|
208
|
+
method: string;
|
|
209
|
+
path: string;
|
|
210
|
+
body: Uint8Array;
|
|
211
|
+
contentType: string;
|
|
212
|
+
}, optional?: Record<string, never>): Promise<{
|
|
213
|
+
status: number;
|
|
214
|
+
body: string | Uint8Array;
|
|
215
|
+
contentType?: string;
|
|
216
|
+
cacheControl?: string;
|
|
217
|
+
}>;
|
|
218
|
+
};
|
|
219
|
+
/** Mode changes retire identities/replay synchronously before starting the next mode. */
|
|
220
|
+
readonly supportsLiveConsent?: boolean;
|
|
221
|
+
/** Host-owned live check; a changed revision retires this page's SDKs until reload. */
|
|
222
|
+
readonly configuration?: {
|
|
223
|
+
readonly url: string;
|
|
224
|
+
readonly revision: string;
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/** Creates disabled telemetry; every request shares one frozen tracker without allocation. */
|
|
228
|
+
export declare function createNoopObservabilityPort(_required: Record<string, never>): ObservabilityPort;
|
|
229
|
+
/** True for a port this module built. Decorators use it to skip wrapping entirely when telemetry is
|
|
230
|
+
* off, so a disabled install pays no per-query or per-call indirection, not merely no export. */
|
|
231
|
+
export declare function isNoopObservabilityPort(port: ObservabilityPort): boolean;
|
|
232
|
+
//# sourceMappingURL=observability.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* ---------- the disabled port ---------- */
|
|
2
|
+
const run = (fn) => fn();
|
|
3
|
+
const NOOP_TRACKER = Object.freeze({ end() { }, run });
|
|
4
|
+
// One frozen tracker serves every non-request signal too: their end() outcomes differ only in type.
|
|
5
|
+
const NOOP_SIGNAL_TRACKER = Object.freeze({ end() { }, run });
|
|
6
|
+
// One frozen port, built at module load: identity is the test for "telemetry is off", so no registry of built ports is kept.
|
|
7
|
+
const NOOP_PORT = Object.freeze({
|
|
8
|
+
supportsMetric: false,
|
|
9
|
+
activeTraceIds: () => undefined,
|
|
10
|
+
trackRequest: () => NOOP_TRACKER,
|
|
11
|
+
trackDbQuery: () => NOOP_SIGNAL_TRACKER,
|
|
12
|
+
trackOutboundCall: () => NOOP_SIGNAL_TRACKER,
|
|
13
|
+
trackAgentRun: () => NOOP_SIGNAL_TRACKER,
|
|
14
|
+
trackOperation: () => NOOP_SIGNAL_TRACKER,
|
|
15
|
+
reportError: () => false,
|
|
16
|
+
metric: () => { },
|
|
17
|
+
});
|
|
18
|
+
/** Creates disabled telemetry; every request shares one frozen tracker without allocation. */
|
|
19
|
+
export function createNoopObservabilityPort(_required) {
|
|
20
|
+
return NOOP_PORT;
|
|
21
|
+
}
|
|
22
|
+
/** True for a port this module built. Decorators use it to skip wrapping entirely when telemetry is
|
|
23
|
+
* off, so a disabled install pays no per-query or per-call indirection, not merely no export. */
|
|
24
|
+
export function isNoopObservabilityPort(port) {
|
|
25
|
+
return port === NOOP_PORT;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=observability.js.map
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/** @agent-note Types, one constant, and three pure helpers. The type closure a plugin provider implements against;
|
|
2
|
+
* the manifest validator, provider host and contribution registry stay with the plugin host. */
|
|
3
|
+
import type { PluginLookupPort } from "@jini-ai/core/plugin-directory";
|
|
4
|
+
/** Plain serializable entry envelope; hosts extend it with their own hook payload fields. */
|
|
5
|
+
export interface ContentEntryDraft {
|
|
6
|
+
readonly workspaceId: string;
|
|
7
|
+
readonly ext: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
8
|
+
}
|
|
9
|
+
export interface HookContext {
|
|
10
|
+
readonly pluginId: string;
|
|
11
|
+
readonly workspaceId: string;
|
|
12
|
+
}
|
|
13
|
+
export type ExtPatch = Readonly<Record<string, string | number | boolean>>;
|
|
14
|
+
/** Positional callbacks are the existing plugin wire ABI, not Jini factory boundaries. */
|
|
15
|
+
export type BeforeSaveFilter = (entry: Readonly<ContentEntryDraft>, ctx: HookContext) => ExtPatch | Promise<ExtPatch>;
|
|
16
|
+
export type HookPoints = Readonly<Record<string, unknown>>;
|
|
17
|
+
export interface PluginSdk<H extends HookPoints = HookPoints> {
|
|
18
|
+
readonly providers: PluginProvidersSdk;
|
|
19
|
+
readonly plugins?: PluginLookupPort;
|
|
20
|
+
readonly content: {
|
|
21
|
+
read(): Readonly<ContentEntryDraft>;
|
|
22
|
+
extend(field: string, value: string | number | boolean): void;
|
|
23
|
+
};
|
|
24
|
+
addFilter<K extends keyof H & string>(hookName: K, filter: H[K] extends (...args: never[]) => unknown ? H[K] : BeforeSaveFilter): void;
|
|
25
|
+
readonly routes: {
|
|
26
|
+
add(required: PluginRouteContribution, optional?: Record<string, never>): void;
|
|
27
|
+
};
|
|
28
|
+
readonly tools: {
|
|
29
|
+
add(required: PluginToolContribution, optional?: Record<string, never>): void;
|
|
30
|
+
};
|
|
31
|
+
readonly widgets: {
|
|
32
|
+
add(required: PluginWidgetContribution, optional?: Record<string, never>): void;
|
|
33
|
+
};
|
|
34
|
+
addAction(...args: never[]): void;
|
|
35
|
+
addContribution(required: PluginContribution, optional?: Record<string, never>): void;
|
|
36
|
+
}
|
|
37
|
+
export interface DefinedPlugin<H extends HookPoints = HookPoints> {
|
|
38
|
+
readonly definition: {
|
|
39
|
+
setup(sdk: PluginSdk<H>): void | Promise<void>;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export declare const PLUGIN_PROVIDER_CAPABILITY: "providers.register";
|
|
43
|
+
export interface PluginProviderResource<T = unknown> {
|
|
44
|
+
readonly port: T;
|
|
45
|
+
/** Release owned resources only; borrowed effect ports remain host-owned. */
|
|
46
|
+
readonly dispose: (required: Record<string, never>, optional?: Record<string, never>) => void | Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
export type PluginProviderFactory = (required: Readonly<Record<string, unknown>>, optional?: Readonly<Record<string, unknown>>) => PluginProviderResource | Promise<PluginProviderResource>;
|
|
49
|
+
export interface PluginProviderContribution extends PluginProviderDeclaration {
|
|
50
|
+
readonly factory: PluginProviderFactory;
|
|
51
|
+
}
|
|
52
|
+
export interface PluginProvidersSdk {
|
|
53
|
+
register(required: PluginProviderContribution, optional?: Record<string, never>): void;
|
|
54
|
+
}
|
|
55
|
+
export type PluginRouteAccess = 'public' | 'member' | 'admin';
|
|
56
|
+
export interface PluginAuthContext {
|
|
57
|
+
readonly access: PluginRouteAccess;
|
|
58
|
+
readonly principalId?: string;
|
|
59
|
+
readonly workspaceId: string;
|
|
60
|
+
}
|
|
61
|
+
export interface PluginInvocationContext {
|
|
62
|
+
readonly pluginId: string;
|
|
63
|
+
readonly auth: PluginAuthContext;
|
|
64
|
+
readonly sdk: PluginSdk;
|
|
65
|
+
readonly signal?: AbortSignal;
|
|
66
|
+
}
|
|
67
|
+
export interface PluginRouteInput extends PluginInvocationContext {
|
|
68
|
+
readonly body: unknown;
|
|
69
|
+
readonly params: Readonly<Record<string, string>>;
|
|
70
|
+
readonly query: Readonly<Record<string, unknown>>;
|
|
71
|
+
}
|
|
72
|
+
export interface PluginRouteResult {
|
|
73
|
+
readonly status?: number;
|
|
74
|
+
readonly body?: unknown;
|
|
75
|
+
}
|
|
76
|
+
export interface PluginRouteContribution {
|
|
77
|
+
readonly method: string;
|
|
78
|
+
readonly path: string;
|
|
79
|
+
readonly access: PluginRouteAccess;
|
|
80
|
+
readonly handler: (required: PluginRouteInput, optional?: Record<string, never>) => PluginRouteResult | void | Promise<PluginRouteResult | void>;
|
|
81
|
+
}
|
|
82
|
+
/** Declared change class. Only ever tightens host policy: `destructive` forces confirmation. */
|
|
83
|
+
export type PluginToolEffect = 'read' | 'write' | 'destructive';
|
|
84
|
+
export interface PluginToolContribution {
|
|
85
|
+
readonly name: string;
|
|
86
|
+
readonly description: string;
|
|
87
|
+
readonly inputSchema: Readonly<Record<string, unknown>>;
|
|
88
|
+
readonly effect?: PluginToolEffect;
|
|
89
|
+
readonly handler: (required: PluginInvocationContext & {
|
|
90
|
+
readonly input: unknown;
|
|
91
|
+
}, optional?: Record<string, never>) => unknown | Promise<unknown>;
|
|
92
|
+
}
|
|
93
|
+
export interface PluginWidgetContribution {
|
|
94
|
+
readonly name: string;
|
|
95
|
+
/** Public SSR only. Host sanitizes the bounded HTML before partial placement. */
|
|
96
|
+
readonly render: (required: PluginInvocationContext, optional?: Record<string, never>) => string | Promise<string>;
|
|
97
|
+
}
|
|
98
|
+
export type PluginContribution = {
|
|
99
|
+
readonly kind: 'route';
|
|
100
|
+
readonly value: PluginRouteContribution;
|
|
101
|
+
} | {
|
|
102
|
+
readonly kind: 'tool';
|
|
103
|
+
readonly value: PluginToolContribution;
|
|
104
|
+
} | {
|
|
105
|
+
readonly kind: 'widget';
|
|
106
|
+
readonly value: PluginWidgetContribution;
|
|
107
|
+
};
|
|
108
|
+
export interface PluginProviderDeclaration {
|
|
109
|
+
readonly contract: string;
|
|
110
|
+
readonly id: string;
|
|
111
|
+
readonly contractVersion: 1;
|
|
112
|
+
/**
|
|
113
|
+
* The settings a host collects (on its own secure settings card) and passes to this provider's
|
|
114
|
+
* factory as `required[name]`. Declared here, not in code, so a host can render the card and decide
|
|
115
|
+
* "configured?" without executing the plugin. Secret fields are sealed by the host and never shown back.
|
|
116
|
+
*/
|
|
117
|
+
readonly settings?: readonly PluginProviderSettingField[];
|
|
118
|
+
/** Ordered read-time public-setting migrations; never rewrite persisted rows or secrets. */
|
|
119
|
+
readonly settingsMigrations?: readonly PluginProviderSettingsMigration[];
|
|
120
|
+
}
|
|
121
|
+
/** A plugin-owned migration of retired public choices, applied to a copy on read. */
|
|
122
|
+
export interface PluginProviderSettingsMigration {
|
|
123
|
+
readonly when: {
|
|
124
|
+
readonly field: string;
|
|
125
|
+
readonly in: readonly string[];
|
|
126
|
+
readonly orAbsent?: boolean;
|
|
127
|
+
};
|
|
128
|
+
readonly whenPresent?: string;
|
|
129
|
+
readonly set: Readonly<Record<string, string>>;
|
|
130
|
+
}
|
|
131
|
+
/** One declared provider setting; `name` is the factory input key. */
|
|
132
|
+
export interface PluginProviderSettingField {
|
|
133
|
+
readonly name: string;
|
|
134
|
+
readonly label: string;
|
|
135
|
+
readonly secret?: boolean;
|
|
136
|
+
readonly required?: boolean;
|
|
137
|
+
/** Waive on an exact choice or a nonblank alternative. With `headerNames`, only a listed nonblank Name=Value header qualifies. */
|
|
138
|
+
readonly requiredUnless?: {
|
|
139
|
+
readonly field: string;
|
|
140
|
+
readonly equals: string;
|
|
141
|
+
readonly orPresent?: string;
|
|
142
|
+
readonly headerNames?: readonly string[];
|
|
143
|
+
};
|
|
144
|
+
/** Require this field only when the controlling public setting is one of these values. */
|
|
145
|
+
readonly requiredWhen?: {
|
|
146
|
+
readonly field: string;
|
|
147
|
+
readonly in: readonly string[];
|
|
148
|
+
};
|
|
149
|
+
readonly hint?: string;
|
|
150
|
+
/** Public fields only: the value a host prefills and uses while none is saved (e.g. a vendor's cloud host). */
|
|
151
|
+
readonly default?: string;
|
|
152
|
+
/** Public fields only: a host renders a select of these choices instead of free text. */
|
|
153
|
+
readonly options?: readonly PluginProviderSettingOption[];
|
|
154
|
+
/** With `options`: also offer "Custom…" free text (e.g. a self-hosted URL). */
|
|
155
|
+
readonly allowCustom?: boolean;
|
|
156
|
+
}
|
|
157
|
+
/** One choice of a {@link PluginProviderSettingField}'s `options`. */
|
|
158
|
+
export interface PluginProviderSettingOption {
|
|
159
|
+
readonly value: string;
|
|
160
|
+
readonly label: string;
|
|
161
|
+
}
|
|
162
|
+
/** Explicit plugin-authored startup guidance. Raw SDK errors must never be shown to users. */
|
|
163
|
+
export declare class PluginProviderStartupError extends Error {
|
|
164
|
+
readonly reason: string;
|
|
165
|
+
readonly action: string;
|
|
166
|
+
constructor({ reason, action, cause }: {
|
|
167
|
+
reason: string;
|
|
168
|
+
action: string;
|
|
169
|
+
cause?: unknown;
|
|
170
|
+
}, _optional?: {});
|
|
171
|
+
}
|
|
172
|
+
/** Startup guidance from a {@link PluginProviderStartupError}, matched by shape: each provider plugin
|
|
173
|
+
* artifact bundles its own copy of this class, so `instanceof` against the host's copy is always false. */
|
|
174
|
+
export declare function pluginProviderStartupGuidance({ error }: {
|
|
175
|
+
error: unknown;
|
|
176
|
+
}, _optional?: {}): {
|
|
177
|
+
reason: string;
|
|
178
|
+
action: string;
|
|
179
|
+
} | undefined;
|
|
180
|
+
/** Match only declared nonblank Name=Value headers; malformed lists never waive a requirement.
|
|
181
|
+
* @complexity O(h * n) in header text and the manifest's small name allowlist. */
|
|
182
|
+
export declare function hasProviderAuthHeader({ text, names }: {
|
|
183
|
+
text: string;
|
|
184
|
+
names: readonly string[];
|
|
185
|
+
}, _optional?: {}): boolean;
|
|
186
|
+
//# sourceMappingURL=plugin-sdk.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { captureLineTail } from "../text/index.js";
|
|
2
|
+
export const PLUGIN_PROVIDER_CAPABILITY = 'providers.register';
|
|
3
|
+
/** Explicit plugin-authored startup guidance. Raw SDK errors must never be shown to users. */
|
|
4
|
+
export class PluginProviderStartupError extends Error {
|
|
5
|
+
reason;
|
|
6
|
+
action;
|
|
7
|
+
constructor({ reason, action, cause }, _optional = {}) {
|
|
8
|
+
super(reason, { cause });
|
|
9
|
+
this.name = 'PluginProviderStartupError';
|
|
10
|
+
this.reason = reason;
|
|
11
|
+
this.action = action;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** Startup guidance from a {@link PluginProviderStartupError}, matched by shape: each provider plugin
|
|
15
|
+
* artifact bundles its own copy of this class, so `instanceof` against the host's copy is always false. */
|
|
16
|
+
export function pluginProviderStartupGuidance({ error }, _optional = {}) {
|
|
17
|
+
if (!(error instanceof Error) || error.name !== 'PluginProviderStartupError')
|
|
18
|
+
return undefined;
|
|
19
|
+
const { reason, action } = error;
|
|
20
|
+
return typeof reason === 'string' && typeof action === 'string' ? { reason, action } : undefined;
|
|
21
|
+
}
|
|
22
|
+
/** Match only declared nonblank Name=Value headers; malformed lists never waive a requirement.
|
|
23
|
+
* @complexity O(h * n) in header text and the manifest's small name allowlist. */
|
|
24
|
+
export function hasProviderAuthHeader({ text, names }, _optional = {}) {
|
|
25
|
+
const pairs = text.split(',').map(pair => headerPair(pair.trim()));
|
|
26
|
+
if (pairs.some(pair => !pair))
|
|
27
|
+
return false;
|
|
28
|
+
return pairs.some(pair => names.some(name => name.toLowerCase() === pair[0].toLowerCase()) && pair[1].trim() !== '');
|
|
29
|
+
}
|
|
30
|
+
/** `[name, value]` exactly as /^([^=\s][^=]*?)\s*=\s*(.+)$/ captures them from a trimmed pair, but
|
|
31
|
+
* without that pattern's backtracking: the name runs to the first `=` (trailing spaces dropped). */
|
|
32
|
+
function headerPair(pair) {
|
|
33
|
+
const eq = pair.indexOf('=');
|
|
34
|
+
if (eq <= 0)
|
|
35
|
+
return null;
|
|
36
|
+
const value = captureLineTail({ rest: pair.slice(eq + 1) });
|
|
37
|
+
return value === null ? null : [pair.slice(0, eq).trimEnd(), value];
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=plugin-sdk.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { RuntimePlatform } from "./platform.js";
|
|
2
|
+
export type CommandInvocation = {
|
|
3
|
+
args: string[];
|
|
4
|
+
command: string;
|
|
5
|
+
windowsVerbatimArguments?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type CommandInvocationRequest = {
|
|
8
|
+
args?: string[];
|
|
9
|
+
command: string;
|
|
10
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
11
|
+
};
|
|
12
|
+
export declare function planCmdShimInvocation({ command, args, env }: {
|
|
13
|
+
readonly command: string;
|
|
14
|
+
readonly args: readonly string[];
|
|
15
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
16
|
+
}, { fallbackComSpec }?: {
|
|
17
|
+
readonly fallbackComSpec?: string | undefined;
|
|
18
|
+
}): CommandInvocation;
|
|
19
|
+
/**
|
|
20
|
+
* Pure form of command-invocation construction: platform and environment are arguments, so any host can
|
|
21
|
+
* call it without a process port. On win32, `.bat` / `.cmd` targets are rewrapped as a
|
|
22
|
+
* `cmd.exe /d /s /c "..."` shim with `windowsVerbatimArguments`; every other case passes through.
|
|
23
|
+
*/
|
|
24
|
+
export declare function planCommandInvocation({ command, platform, env }: {
|
|
25
|
+
command: string;
|
|
26
|
+
platform: RuntimePlatform;
|
|
27
|
+
env: Readonly<Record<string, string | undefined>>;
|
|
28
|
+
}, { args, fallbackComSpec }?: {
|
|
29
|
+
args?: string[];
|
|
30
|
+
fallbackComSpec?: string | undefined;
|
|
31
|
+
}): CommandInvocation;
|
|
32
|
+
/** A host may swap the planner; `planCommandInvocation` satisfies it. */
|
|
33
|
+
export type CommandInvocationPort = (required: {
|
|
34
|
+
command: string;
|
|
35
|
+
platform: RuntimePlatform;
|
|
36
|
+
env: Readonly<Record<string, string | undefined>>;
|
|
37
|
+
}, optional?: {
|
|
38
|
+
args?: string[];
|
|
39
|
+
fallbackComSpec?: string | undefined;
|
|
40
|
+
}) => CommandInvocation;
|
|
41
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { trimCharsEnd } from "../../primitives/index.js";
|
|
2
|
+
// `cmd.exe /s /c "..."` runs percent-expansion on the inner line *regardless*
|
|
3
|
+
// of whether the `%name%` pair sits inside a `"..."` quoted segment, so a
|
|
4
|
+
// `.cmd` / `.bat` shim spawn with an attacker-influenced argv (e.g. an LLM
|
|
5
|
+
// adapter that ships the user prompt as a positional argument) lets a stray
|
|
6
|
+
// `%DEEPSEEK_API_KEY%` substring substitute live env values into the line
|
|
7
|
+
// before the child sees it. Plain quote-doubling is not enough on its own.
|
|
8
|
+
//
|
|
9
|
+
// The fix is to break each potential `%var%` pair by toggling out of the
|
|
10
|
+
// outer quote with `"^%"`: cmd treats the `^` as the standard escape for the
|
|
11
|
+
// next char (here, `%`), making it literal and skipping percent-expansion;
|
|
12
|
+
// `CommandLineToArgvW` then concatenates the surrounding quote segments back
|
|
13
|
+
// into one literal arg with the `%` preserved. The two layers cancel, so the
|
|
14
|
+
// child receives the original arg byte-for-byte while cmd never has a chance
|
|
15
|
+
// to expand anything inside it.
|
|
16
|
+
function quoteWindowsCommandArg({ value }, _options = {}) {
|
|
17
|
+
if (/[\r\n]/.test(value))
|
|
18
|
+
throw new Error("Windows command shim arguments cannot contain line breaks");
|
|
19
|
+
if (value !== "" && !/[\s"&<>|^%=,;()]/.test(value))
|
|
20
|
+
return value;
|
|
21
|
+
// Backslashes before the closing quote must survive the child's argv parser.
|
|
22
|
+
const quoted = value.replace(/"/g, '""').replace(/%/g, '"^%"');
|
|
23
|
+
const trailingBackslashes = quoted.slice(trimCharsEnd({ text: quoted, chars: '\\' }).length);
|
|
24
|
+
const escaped = quoted + trailingBackslashes;
|
|
25
|
+
return `"${escaped}"`;
|
|
26
|
+
}
|
|
27
|
+
// Build the `cmd.exe /d /s /c "<line>"` invocation Node uses internally for
|
|
28
|
+
// `shell: true`. The outer `"..."` plus `windowsVerbatimArguments: true` is
|
|
29
|
+
// the only shape that survives both layers of quoting:
|
|
30
|
+
//
|
|
31
|
+
// 1. Node would otherwise escape each argv element with CommandLineToArgvW
|
|
32
|
+
// rules (turning `"path with space"` into `\"path with space\"`), which
|
|
33
|
+
// cmd.exe does not understand.
|
|
34
|
+
// 2. cmd.exe with `/s /c` strips exactly one leading and one trailing `"`
|
|
35
|
+
// from the rest of the command line. The outer wrap absorbs that strip
|
|
36
|
+
// so any inner per-arg quoting stays intact.
|
|
37
|
+
//
|
|
38
|
+
// Without this, paths containing spaces (`C:\Users\First Last\...\foo.cmd`)
|
|
39
|
+
// get split on the first space and cmd.exe reports "not recognized as an
|
|
40
|
+
// internal or external command" — see issue #315.
|
|
41
|
+
export function planCmdShimInvocation({ command, args, env }, { fallbackComSpec } = {}) {
|
|
42
|
+
const inner = [command, ...args].map((value) => quoteWindowsCommandArg({ value })).join(" ");
|
|
43
|
+
return {
|
|
44
|
+
args: ["/d", "/s", "/c", `"${inner}"`],
|
|
45
|
+
command: env.ComSpec ?? fallbackComSpec ?? "cmd.exe",
|
|
46
|
+
windowsVerbatimArguments: true,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Pure form of command-invocation construction: platform and environment are arguments, so any host can
|
|
51
|
+
* call it without a process port. On win32, `.bat` / `.cmd` targets are rewrapped as a
|
|
52
|
+
* `cmd.exe /d /s /c "..."` shim with `windowsVerbatimArguments`; every other case passes through.
|
|
53
|
+
*/
|
|
54
|
+
export function planCommandInvocation({ command, platform, env }, { args = [], fallbackComSpec } = {}) {
|
|
55
|
+
if (platform === "win32" && /\.(bat|cmd)$/i.test(command)) {
|
|
56
|
+
return planCmdShimInvocation({ command, args, env }, { fallbackComSpec });
|
|
57
|
+
}
|
|
58
|
+
return { args, command };
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=command.js.map
|