@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,18 @@
|
|
|
1
|
+
/** Environment isolation for child processes; hosts name the settings that belong to one run. */
|
|
2
|
+
/**
|
|
3
|
+
* Copy an environment without host-selected keys. Reports names only, never values; no I/O.
|
|
4
|
+
* Windows callers opt into case-insensitive matching so duplicate spellings cannot survive.
|
|
5
|
+
* @returns A fresh environment and the configured names whose defined values were omitted.
|
|
6
|
+
* @complexity O(e + k) time/space for e environment entries and k configured names.
|
|
7
|
+
* @example omitEnvironmentKeys({ env: parent, keys: ['WORKSPACE_STORAGE'] });
|
|
8
|
+
*/
|
|
9
|
+
export declare function omitEnvironmentKeys({ env, keys }: {
|
|
10
|
+
env: Readonly<Record<string, string | undefined>>;
|
|
11
|
+
keys: readonly string[];
|
|
12
|
+
}, { caseInsensitive }?: {
|
|
13
|
+
caseInsensitive?: boolean;
|
|
14
|
+
}): {
|
|
15
|
+
env: Record<string, string | undefined>;
|
|
16
|
+
omitted: string[];
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Environment isolation for child processes; hosts name the settings that belong to one run. */
|
|
2
|
+
/**
|
|
3
|
+
* Copy an environment without host-selected keys. Reports names only, never values; no I/O.
|
|
4
|
+
* Windows callers opt into case-insensitive matching so duplicate spellings cannot survive.
|
|
5
|
+
* @returns A fresh environment and the configured names whose defined values were omitted.
|
|
6
|
+
* @complexity O(e + k) time/space for e environment entries and k configured names.
|
|
7
|
+
* @example omitEnvironmentKeys({ env: parent, keys: ['WORKSPACE_STORAGE'] });
|
|
8
|
+
*/
|
|
9
|
+
export function omitEnvironmentKeys({ env, keys }, { caseInsensitive = false } = {}) {
|
|
10
|
+
const normalize = (key) => caseInsensitive ? key.toUpperCase() : key;
|
|
11
|
+
const names = new Map(keys.map((key) => [normalize(key), key]));
|
|
12
|
+
const child = {};
|
|
13
|
+
const omitted = new Set();
|
|
14
|
+
for (const [key, value] of Object.entries(env)) {
|
|
15
|
+
const name = names.get(normalize(key));
|
|
16
|
+
if (name !== undefined) {
|
|
17
|
+
if (value !== undefined)
|
|
18
|
+
omitted.add(name);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
child[key] = value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return { env: child, omitted: [...omitted] };
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { Clock } from "../../primitives/index.js";
|
|
2
|
+
export interface FileLockHolder {
|
|
3
|
+
readonly pid: number;
|
|
4
|
+
readonly hostname: string;
|
|
5
|
+
readonly token: string;
|
|
6
|
+
readonly acquiredAt: string;
|
|
7
|
+
readonly bootId?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface HeldFileLock {
|
|
10
|
+
readonly lockPath: string;
|
|
11
|
+
assertHeld(required: Record<string, never>): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export interface HeldFileLockSync {
|
|
14
|
+
readonly lockPath: string;
|
|
15
|
+
assertHeld(required: Record<string, never>): void;
|
|
16
|
+
}
|
|
17
|
+
export interface BootIdentity {
|
|
18
|
+
id: string;
|
|
19
|
+
startedAtMs: number;
|
|
20
|
+
}
|
|
21
|
+
export interface FileLockMessages {
|
|
22
|
+
fileLockTimeout(required: {
|
|
23
|
+
waitedMs: number;
|
|
24
|
+
}): string;
|
|
25
|
+
fileLockLost(): string;
|
|
26
|
+
}
|
|
27
|
+
export declare const DEFAULT_FILE_LOCK_MESSAGES: FileLockMessages;
|
|
28
|
+
/** Options every FileLockPort implementation honours. */
|
|
29
|
+
export interface FileLockPortOptions<Filesystem = never> {
|
|
30
|
+
/** Infinity follows an operation with its own deadline; dead local owners remain reclaimable. */
|
|
31
|
+
timeoutMs?: number;
|
|
32
|
+
/** Age threshold for unknown owners. Proven live owners are never evicted; Infinity disables age recovery. */
|
|
33
|
+
staleMs?: number;
|
|
34
|
+
pollMs?: number;
|
|
35
|
+
clock?: Clock;
|
|
36
|
+
/** Times the wait budget (start and timeout check). Defaults to `clock.nowMs`; hosts with a
|
|
37
|
+
* monotonic source pass it so a wall-clock jump can neither end nor stretch the wait. Stale age
|
|
38
|
+
* stays on `clock.nowMs`, because lock-file mtimes are wall-clock times. */
|
|
39
|
+
monotonicMs?: () => number;
|
|
40
|
+
sleep?: (required: {
|
|
41
|
+
durationMs: number;
|
|
42
|
+
}) => void | Promise<void>;
|
|
43
|
+
process?: {
|
|
44
|
+
pid: number;
|
|
45
|
+
isAlive(required: {
|
|
46
|
+
pid: number;
|
|
47
|
+
}): boolean;
|
|
48
|
+
bootIdentity?: () => BootIdentity | undefined;
|
|
49
|
+
};
|
|
50
|
+
token?: () => string;
|
|
51
|
+
hostname?: () => string;
|
|
52
|
+
onStaleLockRemoved?: (required: {
|
|
53
|
+
holder: FileLockHolder | undefined;
|
|
54
|
+
}) => void;
|
|
55
|
+
createParent?: boolean;
|
|
56
|
+
format?: "json" | "token";
|
|
57
|
+
/** Host stores keep their existing user-facing timeout copy. */
|
|
58
|
+
timeoutMessage?: (required: {
|
|
59
|
+
lockPath: string;
|
|
60
|
+
waitMs: number;
|
|
61
|
+
}) => string;
|
|
62
|
+
/** Durable stores historically ignored release failures to avoid masking their critical section. */
|
|
63
|
+
suppressReleaseErrors?: boolean;
|
|
64
|
+
/** Host-supplied filesystem handle; its shape is the implementation's own. */
|
|
65
|
+
filesystem?: Filesystem;
|
|
66
|
+
}
|
|
67
|
+
export declare class FileLockTimeoutError extends Error {
|
|
68
|
+
readonly lockPath: string;
|
|
69
|
+
readonly holder: FileLockHolder | undefined;
|
|
70
|
+
readonly waitedMs: number;
|
|
71
|
+
constructor(required: {
|
|
72
|
+
lockPath: string;
|
|
73
|
+
holder: FileLockHolder | undefined;
|
|
74
|
+
waitedMs: number;
|
|
75
|
+
}, optional?: {
|
|
76
|
+
message?: string;
|
|
77
|
+
messages?: FileLockMessages;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
export declare class FileLockLostError extends Error {
|
|
81
|
+
readonly lockPath: string;
|
|
82
|
+
constructor({ lockPath }: {
|
|
83
|
+
lockPath: string;
|
|
84
|
+
}, { messages }?: {
|
|
85
|
+
messages?: FileLockMessages;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
export interface FileLockPort<Filesystem = never> {
|
|
89
|
+
withFileLock<T>(required: {
|
|
90
|
+
lockPath: string;
|
|
91
|
+
run: (lock: HeldFileLock) => Promise<T> | T;
|
|
92
|
+
}, optional?: FileLockPortOptions<Filesystem>): Promise<T>;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=file-lock.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const DEFAULT_FILE_LOCK_MESSAGES = {
|
|
2
|
+
fileLockTimeout: ({ waitedMs }) => `exclusive file lock timed out after ${Math.round(waitedMs)}ms`,
|
|
3
|
+
fileLockLost: () => "exclusive file lock lost ownership before the critical section finished",
|
|
4
|
+
};
|
|
5
|
+
export class FileLockTimeoutError extends Error {
|
|
6
|
+
lockPath;
|
|
7
|
+
holder;
|
|
8
|
+
waitedMs;
|
|
9
|
+
constructor(required, optional = {}) {
|
|
10
|
+
super(optional.message ?? (optional.messages ?? DEFAULT_FILE_LOCK_MESSAGES).fileLockTimeout({ waitedMs: required.waitedMs }));
|
|
11
|
+
this.name = "FileLockTimeoutError";
|
|
12
|
+
this.lockPath = required.lockPath;
|
|
13
|
+
this.holder = required.holder;
|
|
14
|
+
this.waitedMs = required.waitedMs;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export class FileLockLostError extends Error {
|
|
18
|
+
lockPath;
|
|
19
|
+
constructor({ lockPath }, { messages = DEFAULT_FILE_LOCK_MESSAGES } = {}) {
|
|
20
|
+
super(messages.fileLockLost());
|
|
21
|
+
this.name = "FileLockLostError";
|
|
22
|
+
this.lockPath = lockPath;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=file-lock.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { RuntimePlatform } from "./platform.js";
|
|
2
|
+
export interface AtomicWritePortOptions<Filesystem = never> {
|
|
3
|
+
mode?: number;
|
|
4
|
+
defaultMode?: number;
|
|
5
|
+
refuseSymlink?: boolean;
|
|
6
|
+
verifyOwnerOnly?: boolean;
|
|
7
|
+
createParent?: boolean;
|
|
8
|
+
platform?: RuntimePlatform;
|
|
9
|
+
tempName?: (required: {
|
|
10
|
+
filePath: string;
|
|
11
|
+
}) => string;
|
|
12
|
+
tempPath?: (required: {
|
|
13
|
+
filePath: string;
|
|
14
|
+
}) => string;
|
|
15
|
+
fs?: Filesystem;
|
|
16
|
+
}
|
|
17
|
+
export interface AtomicFileWriterPort<Filesystem = never> {
|
|
18
|
+
writeText(required: {
|
|
19
|
+
filePath: string;
|
|
20
|
+
content: string | Uint8Array;
|
|
21
|
+
}, optional?: AtomicWritePortOptions<Filesystem>): Promise<void>;
|
|
22
|
+
writeJson(required: {
|
|
23
|
+
filePath: string;
|
|
24
|
+
data: unknown;
|
|
25
|
+
}, optional?: AtomicWritePortOptions<Filesystem> & {
|
|
26
|
+
trailingNewline?: boolean;
|
|
27
|
+
}): Promise<void>;
|
|
28
|
+
/** Preserve the original before a personal-config change; call under the destination's lock. */
|
|
29
|
+
backupOriginalOnce(required: {
|
|
30
|
+
filePath: string;
|
|
31
|
+
}, optional?: Record<string, never>): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=fs.d.ts.map
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { Clock, HttpClientPort, HttpRequest, HttpResponse } from "../../primitives/index.js";
|
|
2
|
+
import type { TextReadOptions } from "../../net/fetch-timeouts.js";
|
|
3
|
+
export interface PinnedPeer {
|
|
4
|
+
ip: string;
|
|
5
|
+
port: number;
|
|
6
|
+
authority: string;
|
|
7
|
+
/** RFC 6066 permits hostnames in SNI, never IP literals. Undefined means omit the extension. */
|
|
8
|
+
tlsServerName: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
/** Resolver returns every peer address; a mixed public/private answer is refused as a whole. */
|
|
11
|
+
export interface DnsResolver {
|
|
12
|
+
resolve(required: {
|
|
13
|
+
hostname: string;
|
|
14
|
+
}): Promise<readonly string[]>;
|
|
15
|
+
}
|
|
16
|
+
/** Supplies time and deadline cancellation without a global timer dependency in the guard. */
|
|
17
|
+
export type GuardedClock = Clock & {
|
|
18
|
+
timeoutSignal(required: {
|
|
19
|
+
timeoutMs: number;
|
|
20
|
+
}): AbortSignal;
|
|
21
|
+
};
|
|
22
|
+
/** Transport must dial the supplied IP, preserve authority/SNI, bound decoded bytes,
|
|
23
|
+
* enforce idleTimeoutMs per socket, and honor request.signal through body completion. */
|
|
24
|
+
export interface PinnedHttpTransport {
|
|
25
|
+
requestPinned(required: {
|
|
26
|
+
request: HttpRequest;
|
|
27
|
+
peer: PinnedPeer;
|
|
28
|
+
}): Promise<HttpResponse>;
|
|
29
|
+
}
|
|
30
|
+
/** Policy must cover IPv4 and IPv6, mapped-address/hostname normalization, URL credentials and
|
|
31
|
+
* redirects. Re-verify each redirected peer and strip sensitive headers across origins. */
|
|
32
|
+
export interface EgressPolicy {
|
|
33
|
+
readonly allowedSchemes: readonly string[];
|
|
34
|
+
readonly denyPrivateAddresses: boolean;
|
|
35
|
+
/** Explicit development capability; IPv6 literals use their bracket-free hostname (e.g. fd00::1). */
|
|
36
|
+
readonly devHostAllowlist: readonly string[];
|
|
37
|
+
/** Trusted host configuration only: exact normalized scheme+host+port origins on localhost
|
|
38
|
+
* or loopback IP literals whose loopback peers may be dialed. Public DNS names cannot rebind
|
|
39
|
+
* to loopback through this exception. Other private classes remain denied, including mixed answers.
|
|
40
|
+
* Rechecked on every redirect; this never grants other ports or hostname aliases. */
|
|
41
|
+
readonly loopbackOriginAllowlist?: readonly string[];
|
|
42
|
+
readonly maxRedirects: number;
|
|
43
|
+
/** Historical name: ceiling on each socket's idle timeout, not total transfer time. */
|
|
44
|
+
readonly connectTimeoutMs: number;
|
|
45
|
+
readonly maxResponseBytes: number;
|
|
46
|
+
readonly maxDecompressedBytes: number;
|
|
47
|
+
/** Reserved descriptor, not an implemented pacing mechanism. Untrusted fan-out requires a host
|
|
48
|
+
* concurrency/budget limiter; omission is appropriate only for trusted low-fan-out callers. */
|
|
49
|
+
readonly rateLimit?: {
|
|
50
|
+
readonly maxConcurrent: number;
|
|
51
|
+
readonly maxPerMinute: number;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export type GuardedHttpRequired = {
|
|
55
|
+
transport: PinnedHttpTransport;
|
|
56
|
+
policy: EgressPolicy;
|
|
57
|
+
dns: DnsResolver;
|
|
58
|
+
clock: GuardedClock;
|
|
59
|
+
userAgent: string;
|
|
60
|
+
};
|
|
61
|
+
export interface HttpFetchPort {
|
|
62
|
+
fetchWithTimeout(required: {
|
|
63
|
+
url: string | URL;
|
|
64
|
+
timeoutMs: number;
|
|
65
|
+
}, optional?: {
|
|
66
|
+
init?: RequestInit;
|
|
67
|
+
}): Promise<Response>;
|
|
68
|
+
readResponseText(required: {
|
|
69
|
+
response: Response;
|
|
70
|
+
}, optional?: TextReadOptions): Promise<string>;
|
|
71
|
+
}
|
|
72
|
+
export interface GuardedHttpPort {
|
|
73
|
+
createClient(required: GuardedHttpRequired): HttpClientPort;
|
|
74
|
+
/** Projects guarded bytes into a Response (adapter for SDK/OAuth fetch signatures). */
|
|
75
|
+
fetch(required: {
|
|
76
|
+
client: HttpClientPort;
|
|
77
|
+
url: string;
|
|
78
|
+
timeoutMs: number;
|
|
79
|
+
}, optional?: {
|
|
80
|
+
method?: string;
|
|
81
|
+
headers?: Record<string, string>;
|
|
82
|
+
body?: string | URLSearchParams;
|
|
83
|
+
signal?: AbortSignal;
|
|
84
|
+
redirect?: "follow" | "error" | "manual";
|
|
85
|
+
idleTimeoutMs?: number;
|
|
86
|
+
totalDeadlineMs?: number;
|
|
87
|
+
}): Promise<Response>;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Literal copy of Node's platform union so core can name a platform without Node types; a platform typecheck test keeps the two in sync. */
|
|
2
|
+
export type RuntimePlatform = 'aix' | 'android' | 'darwin' | 'freebsd' | 'haiku' | 'linux' | 'openbsd' | 'sunos' | 'win32' | 'cygwin' | 'netbsd';
|
|
3
|
+
//# sourceMappingURL=platform.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type ProcessSnapshot = {
|
|
2
|
+
command: string;
|
|
3
|
+
pid: number;
|
|
4
|
+
ppid: number;
|
|
5
|
+
};
|
|
6
|
+
export type StopProcessesResult = {
|
|
7
|
+
alreadyStopped: boolean;
|
|
8
|
+
forcedPids: number[];
|
|
9
|
+
matchedPids: number[];
|
|
10
|
+
remainingPids: number[];
|
|
11
|
+
stoppedPids: number[];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Collect the transitive set of descendant PIDs (including the roots) from a
|
|
15
|
+
* process snapshot list, returned sorted by numeric PID descending for deterministic ordering.
|
|
16
|
+
* PID reuse and wraparound mean this does not guarantee children precede parents.
|
|
17
|
+
*
|
|
18
|
+
* @param processes - The full process snapshot list to walk.
|
|
19
|
+
* @param rootPids - The root PIDs whose subtrees to collect (non-numbers ignored).
|
|
20
|
+
* @returns The unique PIDs of the roots and all their descendants, descending.
|
|
21
|
+
*/
|
|
22
|
+
export declare function collectProcessTreePids({ processes, rootPids }: {
|
|
23
|
+
processes: ProcessSnapshot[];
|
|
24
|
+
rootPids: Array<number | null | undefined>;
|
|
25
|
+
}, _optional?: Record<string, never>): number[];
|
|
26
|
+
export interface ProcessControlPort {
|
|
27
|
+
listProcessSnapshots(required?: Record<string, never>, optional?: {
|
|
28
|
+
timeoutMs?: number;
|
|
29
|
+
commandLines?: boolean;
|
|
30
|
+
}): Promise<ProcessSnapshot[]>;
|
|
31
|
+
stopProcesses(required: {
|
|
32
|
+
readonly pids: ReadonlyArray<number | null | undefined>;
|
|
33
|
+
}): Promise<StopProcessesResult>;
|
|
34
|
+
waitForProcessExit(required: {
|
|
35
|
+
readonly pid: number | null | undefined;
|
|
36
|
+
}, optional?: {
|
|
37
|
+
timeoutMs?: number;
|
|
38
|
+
}): Promise<boolean>;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=process.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collect the transitive set of descendant PIDs (including the roots) from a
|
|
3
|
+
* process snapshot list, returned sorted by numeric PID descending for deterministic ordering.
|
|
4
|
+
* PID reuse and wraparound mean this does not guarantee children precede parents.
|
|
5
|
+
*
|
|
6
|
+
* @param processes - The full process snapshot list to walk.
|
|
7
|
+
* @param rootPids - The root PIDs whose subtrees to collect (non-numbers ignored).
|
|
8
|
+
* @returns The unique PIDs of the roots and all their descendants, descending.
|
|
9
|
+
*/
|
|
10
|
+
export function collectProcessTreePids({ processes, rootPids }, _optional = {}) {
|
|
11
|
+
const queue = [...new Set(rootPids.filter((pid) => typeof pid === "number"))];
|
|
12
|
+
const visited = new Set();
|
|
13
|
+
const childrenByParent = new Map();
|
|
14
|
+
for (const processInfo of processes) {
|
|
15
|
+
const children = childrenByParent.get(processInfo.ppid) ?? [];
|
|
16
|
+
children.push(processInfo.pid);
|
|
17
|
+
childrenByParent.set(processInfo.ppid, children);
|
|
18
|
+
}
|
|
19
|
+
while (queue.length > 0) {
|
|
20
|
+
const pid = queue.shift();
|
|
21
|
+
if (pid == null || visited.has(pid))
|
|
22
|
+
continue;
|
|
23
|
+
visited.add(pid);
|
|
24
|
+
for (const childPid of childrenByParent.get(pid) ?? []) {
|
|
25
|
+
if (!visited.has(childPid))
|
|
26
|
+
queue.push(childPid);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return [...visited].sort((left, right) => right - left);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=process.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DenyRules, GuardedFileReader, GuardedReaderLimits } from "../../filesystem.js";
|
|
2
|
+
export interface GuardedReaderPort {
|
|
3
|
+
createReader(required: {
|
|
4
|
+
rootPath: string;
|
|
5
|
+
denyRules: DenyRules;
|
|
6
|
+
limits: GuardedReaderLimits;
|
|
7
|
+
}, optional?: {
|
|
8
|
+
excludedListingDirs?: ReadonlySet<string>;
|
|
9
|
+
}): GuardedFileReader;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=reader.d.ts.map
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/** A single running PTY child process, however the caller's backend spawns it. */
|
|
2
|
+
export interface PtyProcess {
|
|
3
|
+
onData(cb: (chunk: string) => void): void;
|
|
4
|
+
onExit(cb: (event: {
|
|
5
|
+
exitCode: number;
|
|
6
|
+
signal?: number;
|
|
7
|
+
}) => void): void;
|
|
8
|
+
write(input: string): void;
|
|
9
|
+
resize(cols: number, rows: number): void;
|
|
10
|
+
kill(signal?: string): void;
|
|
11
|
+
}
|
|
12
|
+
export interface PtySpawnOptions {
|
|
13
|
+
name: string;
|
|
14
|
+
cols: number;
|
|
15
|
+
rows: number;
|
|
16
|
+
cwd: string;
|
|
17
|
+
env: Record<string, string>;
|
|
18
|
+
}
|
|
19
|
+
/** Spawns a PTY. The caller supplies this — e.g. a thin wrapper around `node-pty`'s `spawn`. */
|
|
20
|
+
export type PtySpawn = (shell: string, args: string[], options: PtySpawnOptions) => PtyProcess;
|
|
21
|
+
export type TerminalEventData = {
|
|
22
|
+
data: string;
|
|
23
|
+
} | {
|
|
24
|
+
code: number | null;
|
|
25
|
+
signal: string | null;
|
|
26
|
+
};
|
|
27
|
+
export interface TerminalEventRecord {
|
|
28
|
+
id: number;
|
|
29
|
+
event: 'data' | 'exit';
|
|
30
|
+
data: TerminalEventData;
|
|
31
|
+
timestamp: number;
|
|
32
|
+
byteLength: number;
|
|
33
|
+
}
|
|
34
|
+
/** A minimal push sink a transport adapts its live connection to (e.g. SSE). */
|
|
35
|
+
export interface TerminalSseSink {
|
|
36
|
+
send(event: string, data: TerminalEventData, id: number): void;
|
|
37
|
+
end(): void;
|
|
38
|
+
}
|
|
39
|
+
export interface TerminalSessionState {
|
|
40
|
+
readonly id: string;
|
|
41
|
+
readonly cwd: string;
|
|
42
|
+
readonly shell: string;
|
|
43
|
+
readonly cols: number;
|
|
44
|
+
readonly rows: number;
|
|
45
|
+
readonly status: 'running' | 'exited';
|
|
46
|
+
readonly createdAt: number;
|
|
47
|
+
readonly updatedAt: number;
|
|
48
|
+
readonly exitCode: number | null;
|
|
49
|
+
readonly signal: string | null;
|
|
50
|
+
}
|
|
51
|
+
export interface TerminalSession extends TerminalSessionState {
|
|
52
|
+
readonly projectId: string | null;
|
|
53
|
+
}
|
|
54
|
+
export interface CreateTerminalOptions {
|
|
55
|
+
projectId?: string | null;
|
|
56
|
+
cwd: string;
|
|
57
|
+
cols?: number;
|
|
58
|
+
rows?: number;
|
|
59
|
+
shell?: string | null;
|
|
60
|
+
}
|
|
61
|
+
export interface CreateTerminalServiceOptions {
|
|
62
|
+
/** Lazily loads the PTY spawner. Concurrent `create()` calls share one attempt; success is cached, failure permits retry. */
|
|
63
|
+
loadSpawnPty: () => Promise<PtySpawn>;
|
|
64
|
+
/** Count backstop for the per-session output ring-buffer; `maxBufferBytes` is the real ceiling. */
|
|
65
|
+
maxEvents?: number;
|
|
66
|
+
/** UTF-8 byte ceiling for retained reattach scrollback (evicted oldest-first; the newest event is always kept). */
|
|
67
|
+
maxBufferBytes?: number;
|
|
68
|
+
/** Trailing scrollback kept once a shell exits, so an unreaped session doesn't pin memory. */
|
|
69
|
+
exitTailBytes?: number;
|
|
70
|
+
/** Coalesces PTY output for roughly one animation frame before fanning out one `data` event. */
|
|
71
|
+
flushIntervalMs?: number;
|
|
72
|
+
/** Flushes immediately once buffered output crosses this size, bypassing the frame timer. */
|
|
73
|
+
flushThresholdBytes?: number;
|
|
74
|
+
/** Drops an exited session from the registry after this idle window. */
|
|
75
|
+
ttlMs?: number;
|
|
76
|
+
/** Grace window given to children to exit during {@link TerminalService.shutdownActive}. */
|
|
77
|
+
shutdownGraceMs?: number;
|
|
78
|
+
}
|
|
79
|
+
export interface TerminalService {
|
|
80
|
+
create(options: CreateTerminalOptions): Promise<TerminalSession>;
|
|
81
|
+
get(id: string): TerminalSession | null;
|
|
82
|
+
list(filter?: {
|
|
83
|
+
projectId?: string | null;
|
|
84
|
+
}): TerminalSession[];
|
|
85
|
+
write(id: string, input: string): boolean;
|
|
86
|
+
resize(id: string, cols: number, rows: number): boolean;
|
|
87
|
+
kill(id: string, signal?: string): boolean;
|
|
88
|
+
/** Replays scrollback after `lastEventId`, then attaches `sink` for live output if still running. */
|
|
89
|
+
attach(id: string, lastEventId: number, sink: TerminalSseSink): 'attached' | 'ended' | 'not-found';
|
|
90
|
+
detach(id: string, sink: TerminalSseSink): void;
|
|
91
|
+
shutdownActive(options?: {
|
|
92
|
+
graceMs?: number;
|
|
93
|
+
}): Promise<void>;
|
|
94
|
+
isTerminal(status: string): boolean;
|
|
95
|
+
}
|
|
96
|
+
export interface PtyPort {
|
|
97
|
+
createTerminalService(required: CreateTerminalServiceOptions): TerminalService;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=terminal.d.ts.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file In-memory fakes of the runtime ports (`FileLockPort`, `AtomicFileWriterPort`,
|
|
3
|
+
* `ProcessControlPort`, `HttpFetchPort`, `GuardedHttpPort`) for tests of OTHER packages, so a
|
|
4
|
+
* consumer's test passes a fake through the production argument instead of importing the Node
|
|
5
|
+
* implementation from `@jini-ai/platform` or mocking it. Every fake records the arguments it was
|
|
6
|
+
* given, in order, and does no I/O (no `node:` import: core is runtime-neutral).
|
|
7
|
+
*/
|
|
8
|
+
import type { HttpRequest, HttpResponse } from "../../primitives/index.js";
|
|
9
|
+
import type { AtomicFileWriterPort, AtomicWritePortOptions } from "./fs.js";
|
|
10
|
+
import type { FileLockPort, FileLockPortOptions } from "./file-lock.js";
|
|
11
|
+
import type { GuardedHttpPort, GuardedHttpRequired, HttpFetchPort } from "./http.js";
|
|
12
|
+
import { type ProcessControlPort, type ProcessSnapshot } from "./process.js";
|
|
13
|
+
export interface RecordedFileLockCall {
|
|
14
|
+
readonly lockPath: string;
|
|
15
|
+
readonly options: FileLockPortOptions | undefined;
|
|
16
|
+
}
|
|
17
|
+
export interface FakeFileLock extends FileLockPort {
|
|
18
|
+
/** Every `withFileLock` call, in call order. */
|
|
19
|
+
readonly calls: readonly RecordedFileLockCall[];
|
|
20
|
+
/** Lock paths held right now; a path leaves the set when its `run` settles, also when it throws. */
|
|
21
|
+
readonly held: ReadonlySet<string>;
|
|
22
|
+
}
|
|
23
|
+
/** Runs each critical section immediately and records the lock path and options it was asked for. */
|
|
24
|
+
export declare function fakeFileLock(_required?: Record<string, never>, _optional?: Record<string, never>): FakeFileLock;
|
|
25
|
+
export interface RecordedAtomicWrite {
|
|
26
|
+
readonly method: "writeText" | "writeJson";
|
|
27
|
+
readonly filePath: string;
|
|
28
|
+
/** Options as the caller passed them (`createParent`, `mode`, …): recorded, never acted on. */
|
|
29
|
+
readonly options: AtomicWritePortOptions | undefined;
|
|
30
|
+
}
|
|
31
|
+
export interface FakeAtomicWriter extends AtomicFileWriterPort {
|
|
32
|
+
/** File contents by path; JSON is stored as the platform writer serializes it (2-space indent). */
|
|
33
|
+
readonly files: Map<string, string | Uint8Array>;
|
|
34
|
+
readonly writes: readonly RecordedAtomicWrite[];
|
|
35
|
+
/** Paths `backupOriginalOnce` was asked about, in call order. */
|
|
36
|
+
readonly backups: readonly string[];
|
|
37
|
+
}
|
|
38
|
+
/** Writes into a `Map`; `createParent`, `mode` and the other options are recorded, not honoured. */
|
|
39
|
+
export declare function fakeAtomicWriter(_required?: Record<string, never>, _optional?: Record<string, never>): FakeAtomicWriter;
|
|
40
|
+
export interface FakeProcessControl extends ProcessControlPort {
|
|
41
|
+
/** The pid lists `stopProcesses` was asked to stop, in call order. */
|
|
42
|
+
readonly stopRequests: ReadonlyArray<ReadonlyArray<number | null | undefined>>;
|
|
43
|
+
/** The pids `waitForProcessExit` was asked about, in call order. */
|
|
44
|
+
readonly waited: ReadonlyArray<number | null | undefined>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A process table that `stopProcesses` empties: it stops the requested pids and their descendants
|
|
48
|
+
* (the same tree walk the real port uses) and reports them as stopped, none forced.
|
|
49
|
+
* `waitForProcessExit` answers true once the pid is no longer in the table.
|
|
50
|
+
*/
|
|
51
|
+
export declare function fakeProcessControl(_required?: Record<string, never>, optional?: {
|
|
52
|
+
readonly processes?: readonly ProcessSnapshot[];
|
|
53
|
+
}): FakeProcessControl;
|
|
54
|
+
export interface RecordedHttpFetch {
|
|
55
|
+
readonly url: string;
|
|
56
|
+
readonly timeoutMs: number;
|
|
57
|
+
readonly init: RequestInit | undefined;
|
|
58
|
+
}
|
|
59
|
+
export interface FakeHttpFetch extends HttpFetchPort {
|
|
60
|
+
readonly calls: readonly RecordedHttpFetch[];
|
|
61
|
+
}
|
|
62
|
+
/** Answers every request from `respond` (default: `200` with an empty body) and records it. */
|
|
63
|
+
export declare function fakeHttpFetch(_required?: Record<string, never>, optional?: {
|
|
64
|
+
readonly respond?: (request: {
|
|
65
|
+
url: string;
|
|
66
|
+
init: RequestInit | undefined;
|
|
67
|
+
}) => Response | Promise<Response>;
|
|
68
|
+
}): FakeHttpFetch;
|
|
69
|
+
/** A canned answer for one `METHOD url` (method upper-case, e.g. `"GET https://a.test/x"`). */
|
|
70
|
+
export type FakeGuardedRoutes = Readonly<Record<string, Partial<HttpResponse> | ((request: HttpRequest) => Partial<HttpResponse>)>>;
|
|
71
|
+
export interface FakeGuardedHttp extends GuardedHttpPort {
|
|
72
|
+
/** Requests the clients it created were asked to send, in order. */
|
|
73
|
+
readonly requests: readonly HttpRequest[];
|
|
74
|
+
/** The `createClient` arguments, in call order. */
|
|
75
|
+
readonly clients: readonly GuardedHttpRequired[];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Serves `routes` through clients that never open a socket. A request that matches no route gets
|
|
79
|
+
* a `404` so a test fails on the assertion about the answer, not on an exception inside the fake.
|
|
80
|
+
*/
|
|
81
|
+
export declare function fakeGuardedHttp(required: {
|
|
82
|
+
readonly routes: FakeGuardedRoutes;
|
|
83
|
+
}, _optional?: Record<string, never>): FakeGuardedHttp;
|
|
84
|
+
//# sourceMappingURL=testing.d.ts.map
|