codex-chatgpt-control 0.5.1-alpha.2 → 0.5.1-alpha.4
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 +42 -0
- package/README.md +43 -0
- package/contracts/v1/fixtures/backend-capabilities.json +40 -1
- package/contracts/v1/fixtures/backend-compatibility.json +21 -0
- package/contracts/v1/fixtures/backend-version.json +6 -1
- package/contracts/v1/fixtures/download-blocked-by-browser.json +22 -0
- package/contracts/v1/fixtures/download-receipt-failed.json +22 -0
- package/contracts/v1/fixtures/download-receipt-timeout.json +22 -0
- package/contracts/v1/fixtures/journal-rpc-indeterminate.json +32 -0
- package/contracts/v1/fixtures/journal-rpc-unsupported-platform.json +32 -0
- package/contracts/v1/fixtures/journal-runtime-unavailable.json +32 -0
- package/contracts/v1/fixtures/operation-action-prepared-event.json +42 -0
- package/contracts/v1/fixtures/operation-action.json +13 -0
- package/contracts/v1/fixtures/operation-artifact-receipt.json +14 -0
- package/contracts/v1/fixtures/operation-artifact-transfer-intent-event.json +24 -0
- package/contracts/v1/fixtures/operation-artifact-transfer-receipt-event.json +26 -0
- package/contracts/v1/fixtures/operation-artifact-transfer-state.json +178 -0
- package/contracts/v1/fixtures/operation-blocker.json +10 -0
- package/contracts/v1/fixtures/operation-collect-request.json +17 -0
- package/contracts/v1/fixtures/operation-collect-result.json +42 -0
- package/contracts/v1/fixtures/operation-control-receipt.json +13 -0
- package/contracts/v1/fixtures/operation-control-request.json +18 -0
- package/contracts/v1/fixtures/operation-control-result.json +31 -0
- package/contracts/v1/fixtures/operation-event.json +18 -0
- package/contracts/v1/fixtures/operation-handle.json +10 -0
- package/contracts/v1/fixtures/operation-inspect-request.json +13 -0
- package/contracts/v1/fixtures/operation-inspect-result.json +205 -0
- package/contracts/v1/fixtures/operation-ownership-baseline-event.json +34 -0
- package/contracts/v1/fixtures/operation-receipt.json +32 -0
- package/contracts/v1/fixtures/operation-recovery-decision.json +7 -0
- package/contracts/v1/fixtures/operation-recovery-observation.json +12 -0
- package/contracts/v1/fixtures/operation-request.json +33 -0
- package/contracts/v1/fixtures/operation-state.json +144 -0
- package/contracts/v1/fixtures/operation-submission-witness-event.json +20 -0
- package/contracts/v1/fixtures/operation-submission-witness.json +11 -0
- package/contracts/v1/fixtures/operation-submit-result.json +16 -0
- package/contracts/v1/fixtures/operation-target-established-event.json +21 -0
- package/contracts/v1/manifest.json +185 -1
- package/contracts/v1/parity-suite.json +106 -8
- package/contracts/v1/schemas/backend-compatibility.schema.json +65 -0
- package/contracts/v1/schemas/backend-request.schema.json +8 -2
- package/contracts/v1/schemas/capabilities.schema.json +81 -1
- package/contracts/v1/schemas/manifest.schema.json +57 -0
- package/contracts/v1/schemas/operation-action.schema.json +155 -0
- package/contracts/v1/schemas/operation-artifact-receipt.schema.json +89 -0
- package/contracts/v1/schemas/operation-blocker.schema.json +70 -0
- package/contracts/v1/schemas/operation-collect-request.schema.json +46 -0
- package/contracts/v1/schemas/operation-collect-result.schema.json +74 -0
- package/contracts/v1/schemas/operation-control-receipt.schema.json +108 -0
- package/contracts/v1/schemas/operation-control-request.schema.json +111 -0
- package/contracts/v1/schemas/operation-control-result.schema.json +112 -0
- package/contracts/v1/schemas/operation-event.schema.json +756 -0
- package/contracts/v1/schemas/operation-handle.schema.json +55 -0
- package/contracts/v1/schemas/operation-inspect-request.schema.json +42 -0
- package/contracts/v1/schemas/operation-inspect-result.schema.json +1662 -0
- package/contracts/v1/schemas/operation-receipt.schema.json +153 -0
- package/contracts/v1/schemas/operation-recovery.schema.json +314 -0
- package/contracts/v1/schemas/operation-request.schema.json +158 -0
- package/contracts/v1/schemas/operation-state.schema.json +691 -0
- package/contracts/v1/schemas/operation-submission-witness.schema.json +48 -0
- package/contracts/v1/schemas/operation-submit-result.schema.json +94 -0
- package/contracts/v1/surface-drift-policy.json +50 -0
- package/contracts/v1/vectors/operation-request-digest-v1.json +43 -0
- package/dist/codex-chatgpt-control-backend.mjs +45882 -9361
- package/dist/codex-chatgpt-control-journal.mjs +5547 -0
- package/dist/codex-chatgpt-control-live-smoke.bundle.mjs +51677 -0
- package/dist/codex-chatgpt-control-release-canary.bundle.mjs +52104 -0
- package/dist/codex-chatgpt-control.bundle.mjs +48392 -10260
- package/dist/src/backend/client.d.ts +103 -2
- package/dist/src/backend/client.js +1436 -97
- package/dist/src/backend/compatibility.d.ts +12 -0
- package/dist/src/backend/compatibility.js +208 -0
- package/dist/src/backend/protocol.d.ts +84 -1
- package/dist/src/backend/protocol.js +31 -5
- package/dist/src/backend/runtime-identity.d.ts +10 -0
- package/dist/src/backend/runtime-identity.js +141 -0
- package/dist/src/backend/session.d.ts +10 -2
- package/dist/src/backend/session.js +478 -7
- package/dist/src/backend/stdio-server.d.ts +4 -1
- package/dist/src/backend/stdio-server.js +240 -28
- package/dist/src/browser/active-composer-file-input.d.ts +9 -0
- package/dist/src/browser/active-composer-file-input.js +33 -0
- package/dist/src/browser/attach.d.ts +4 -1
- package/dist/src/browser/attach.js +136 -28
- package/dist/src/browser/chatgpt-url.d.ts +2 -0
- package/dist/src/browser/chatgpt-url.js +9 -0
- package/dist/src/browser/downloads.d.ts +17 -1
- package/dist/src/browser/downloads.js +150 -28
- package/dist/src/browser/page-state.js +6 -0
- package/dist/src/client.d.ts +43 -0
- package/dist/src/client.js +1279 -59
- package/dist/src/commands/artifacts.js +6 -4
- package/dist/src/commands/chat-popover.d.ts +37 -0
- package/dist/src/commands/chat-popover.js +537 -0
- package/dist/src/commands/configuration.d.ts +5 -0
- package/dist/src/commands/configuration.js +134 -21
- package/dist/src/commands/context.js +10 -3
- package/dist/src/commands/doctor.d.ts +1 -1
- package/dist/src/commands/doctor.js +27 -4
- package/dist/src/commands/experience.d.ts +5 -0
- package/dist/src/commands/experience.js +104 -21
- package/dist/src/commands/files.js +14 -33
- package/dist/src/commands/modes.js +85 -21
- package/dist/src/commands/power-discovery.d.ts +130 -0
- package/dist/src/commands/power-discovery.js +669 -0
- package/dist/src/commands/project-sources.js +325 -31
- package/dist/src/commands/sequence.js +59 -32
- package/dist/src/commands/session.js +19 -6
- package/dist/src/commands/work.js +31 -0
- package/dist/src/dom/composer-text.d.ts +6 -0
- package/dist/src/dom/composer-text.js +85 -0
- package/dist/src/errors.d.ts +9 -0
- package/dist/src/errors.js +22 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.js +9 -0
- package/dist/src/operations/artifact-output.d.ts +69 -0
- package/dist/src/operations/artifact-output.js +1748 -0
- package/dist/src/operations/artifact-stream.d.ts +19 -0
- package/dist/src/operations/artifact-stream.js +35 -0
- package/dist/src/operations/artifact-transfer.d.ts +149 -0
- package/dist/src/operations/artifact-transfer.js +1312 -0
- package/dist/src/operations/browser-adapter.d.ts +167 -0
- package/dist/src/operations/browser-adapter.js +2103 -0
- package/dist/src/operations/browser-observation.d.ts +110 -0
- package/dist/src/operations/browser-observation.js +1256 -0
- package/dist/src/operations/browser-target.d.ts +105 -0
- package/dist/src/operations/browser-target.js +531 -0
- package/dist/src/operations/canonical.d.ts +4 -0
- package/dist/src/operations/canonical.js +412 -0
- package/dist/src/operations/chatgpt-runtime.d.ts +72 -0
- package/dist/src/operations/chatgpt-runtime.js +1232 -0
- package/dist/src/operations/client.d.ts +138 -0
- package/dist/src/operations/client.js +1145 -0
- package/dist/src/operations/collector.d.ts +195 -0
- package/dist/src/operations/collector.js +1039 -0
- package/dist/src/operations/configuration-routing.d.ts +4 -0
- package/dist/src/operations/configuration-routing.js +14 -0
- package/dist/src/operations/control.d.ts +372 -0
- package/dist/src/operations/control.js +1498 -0
- package/dist/src/operations/file-identity.d.ts +33 -0
- package/dist/src/operations/file-identity.js +153 -0
- package/dist/src/operations/handle.d.ts +19 -0
- package/dist/src/operations/handle.js +727 -0
- package/dist/src/operations/index.d.ts +25 -0
- package/dist/src/operations/index.js +25 -0
- package/dist/src/operations/journal-authority.d.ts +12 -0
- package/dist/src/operations/journal-authority.js +1 -0
- package/dist/src/operations/journal-rpc-client.d.ts +12 -0
- package/dist/src/operations/journal-rpc-client.js +225 -0
- package/dist/src/operations/journal-rpc-protocol.d.ts +32 -0
- package/dist/src/operations/journal-rpc-protocol.js +214 -0
- package/dist/src/operations/journal-rpc-server.d.ts +15 -0
- package/dist/src/operations/journal-rpc-server.js +272 -0
- package/dist/src/operations/journal.d.ts +143 -0
- package/dist/src/operations/journal.js +1957 -0
- package/dist/src/operations/production-attachments.d.ts +118 -0
- package/dist/src/operations/production-attachments.js +1035 -0
- package/dist/src/operations/production-chatgpt-artifacts.d.ts +74 -0
- package/dist/src/operations/production-chatgpt-artifacts.js +1146 -0
- package/dist/src/operations/production-chatgpt-attachments.d.ts +80 -0
- package/dist/src/operations/production-chatgpt-attachments.js +1639 -0
- package/dist/src/operations/production-configuration.d.ts +42 -0
- package/dist/src/operations/production-configuration.js +1544 -0
- package/dist/src/operations/production-primitives.d.ts +53 -0
- package/dist/src/operations/production-primitives.js +856 -0
- package/dist/src/operations/production-work-steer.d.ts +203 -0
- package/dist/src/operations/production-work-steer.js +1218 -0
- package/dist/src/operations/recovery.d.ts +80 -0
- package/dist/src/operations/recovery.js +174 -0
- package/dist/src/operations/runtime-adapter.d.ts +126 -0
- package/dist/src/operations/runtime-adapter.js +802 -0
- package/dist/src/operations/send-once.d.ts +224 -0
- package/dist/src/operations/send-once.js +1081 -0
- package/dist/src/operations/service.d.ts +286 -0
- package/dist/src/operations/service.js +2831 -0
- package/dist/src/operations/staging.d.ts +136 -0
- package/dist/src/operations/staging.js +630 -0
- package/dist/src/operations/state-machine.d.ts +29 -0
- package/dist/src/operations/state-machine.js +2047 -0
- package/dist/src/operations/submission.d.ts +423 -0
- package/dist/src/operations/submission.js +1676 -0
- package/dist/src/operations/transactional-chat-power.d.ts +17 -0
- package/dist/src/operations/transactional-chat-power.js +212 -0
- package/dist/src/operations/turn-ownership.d.ts +202 -0
- package/dist/src/operations/turn-ownership.js +700 -0
- package/dist/src/operations/types.d.ts +454 -0
- package/dist/src/operations/types.js +20 -0
- package/dist/src/operations/wire-requests.d.ts +21 -0
- package/dist/src/operations/wire-requests.js +396 -0
- package/dist/src/operations/wire-results.d.ts +97 -0
- package/dist/src/operations/wire-results.js +818 -0
- package/dist/src/runner/responses.d.ts +3 -1
- package/dist/src/runner/responses.js +19 -1
- package/dist/src/runner/result.js +227 -55
- package/dist/src/runner/types.d.ts +12 -0
- package/dist/src/runtime/command-routing.d.ts +149 -0
- package/dist/src/runtime/command-routing.js +431 -0
- package/dist/src/runtime/coordinated-browser.d.ts +24 -0
- package/dist/src/runtime/coordinated-browser.js +315 -0
- package/dist/src/runtime/coordinated-page.d.ts +41 -0
- package/dist/src/runtime/coordinated-page.js +651 -0
- package/dist/src/runtime/operation-context.d.ts +142 -0
- package/dist/src/runtime/operation-context.js +410 -0
- package/dist/src/runtime/runtime-session.d.ts +95 -0
- package/dist/src/runtime/runtime-session.js +314 -0
- package/dist/src/runtime/tab-coordinator.d.ts +200 -0
- package/dist/src/runtime/tab-coordinator.js +1200 -0
- package/dist/src/runtime/value-boundaries.d.ts +18 -0
- package/dist/src/runtime/value-boundaries.js +49 -0
- package/dist/src/safety/blockers.js +8 -1
- package/dist/src/safety/untrusted-output.js +2 -1
- package/dist/src/scripts/backend-server.js +4 -1
- package/dist/src/scripts/capture-surface-profile.js +7 -2
- package/dist/src/scripts/journal-server.d.ts +2 -0
- package/dist/src/scripts/journal-server.js +37 -0
- package/dist/src/scripts/live-smoke/harness.js +79 -7
- package/dist/src/scripts/live-smoke/scenarios.d.ts +42 -1
- package/dist/src/scripts/live-smoke/scenarios.js +147 -30
- package/dist/src/scripts/live-smoke/transactional.d.ts +17 -0
- package/dist/src/scripts/live-smoke/transactional.js +254 -0
- package/dist/src/scripts/live-smoke/types.d.ts +3 -0
- package/dist/src/scripts/release-canary-module.js +17 -4
- package/dist/src/types.d.ts +38 -1
- package/package.json +8 -3
- package/references/2026-08-16-transactional-operations.md +459 -0
- package/references/2026-09-06-journal-service.md +140 -0
- package/references/agents-runner.md +34 -0
- package/references/backend-protocol.md +176 -0
- package/references/python-parity.md +137 -0
- package/references/responses-adapter.md +19 -0
- package/references/streaming.md +6 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-serialized, bounded reader for the text inserted into a composer.
|
|
3
|
+
* Keep this self-contained: the Chrome bridge transfers the function, not its
|
|
4
|
+
* module. Contenteditable paragraph boundaries are part of the prompt.
|
|
5
|
+
*/
|
|
6
|
+
export function inspectComposerText(element) {
|
|
7
|
+
const maximum = 8 * 1024 * 1024;
|
|
8
|
+
const candidate = element;
|
|
9
|
+
const tag = typeof candidate.tagName === "string" ? candidate.tagName.toLowerCase() : "";
|
|
10
|
+
if (tag === "input" || tag === "textarea" || tag === "select") {
|
|
11
|
+
const value = candidate.value;
|
|
12
|
+
return typeof value === "string" && value.length <= maximum ? value : undefined;
|
|
13
|
+
}
|
|
14
|
+
const chunks = [];
|
|
15
|
+
let total = 0;
|
|
16
|
+
let visited = 0;
|
|
17
|
+
let lastCharacter = "";
|
|
18
|
+
const append = (text) => {
|
|
19
|
+
total += text.length;
|
|
20
|
+
if (total > maximum)
|
|
21
|
+
throw new Error("composer text limit exceeded");
|
|
22
|
+
if (text.length > 0) {
|
|
23
|
+
chunks.push(text);
|
|
24
|
+
lastCharacter = text.slice(-1);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const walk = (node, depth) => {
|
|
28
|
+
visited += 1;
|
|
29
|
+
if (visited > 4096 || depth > 128)
|
|
30
|
+
throw new Error("composer node limit exceeded");
|
|
31
|
+
if (node.nodeType === 3) {
|
|
32
|
+
append(node.nodeValue ?? "");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const current = node;
|
|
36
|
+
const currentTag = typeof current.tagName === "string" ? current.tagName.toUpperCase() : "";
|
|
37
|
+
if (currentTag === "BR") {
|
|
38
|
+
const classes = (current.getAttribute("class") ?? "").split(/\s+/u);
|
|
39
|
+
// ProseMirror adds a caret placeholder after a real trailing hard break.
|
|
40
|
+
const soleChild = node.parentNode?.firstChild === node && node.nextSibling === null;
|
|
41
|
+
if (!classes.includes("ProseMirror-trailingBreak") && !soleChild)
|
|
42
|
+
append("\n");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
let previousBlock = false;
|
|
46
|
+
let previousEmptyBlock = false;
|
|
47
|
+
let hasPrevious = false;
|
|
48
|
+
let child = node.firstChild;
|
|
49
|
+
while (child !== null) {
|
|
50
|
+
const childTag = child.nodeType === 1 ? child.tagName.toUpperCase() : "";
|
|
51
|
+
const block = childTag === "P" || childTag === "DIV" || childTag === "LI";
|
|
52
|
+
const boundary = hasPrevious && (block || previousBlock)
|
|
53
|
+
&& (lastCharacter !== "\n" || previousEmptyBlock);
|
|
54
|
+
// Reserve a position before walking the child. Empty inline nodes have
|
|
55
|
+
// no rendered text and must not create a paragraph boundary.
|
|
56
|
+
const boundaryIndex = chunks.length;
|
|
57
|
+
if (boundary)
|
|
58
|
+
chunks.push("");
|
|
59
|
+
const before = total;
|
|
60
|
+
walk(child, depth + 1);
|
|
61
|
+
const emitted = total > before;
|
|
62
|
+
if (emitted || block) {
|
|
63
|
+
if (boundary) {
|
|
64
|
+
chunks[boundaryIndex] = "\n";
|
|
65
|
+
total += 1;
|
|
66
|
+
if (total > maximum)
|
|
67
|
+
throw new Error("composer text limit exceeded");
|
|
68
|
+
if (!emitted)
|
|
69
|
+
lastCharacter = "\n";
|
|
70
|
+
}
|
|
71
|
+
hasPrevious = true;
|
|
72
|
+
previousBlock = block;
|
|
73
|
+
previousEmptyBlock = block && !emitted;
|
|
74
|
+
}
|
|
75
|
+
child = child.nextSibling;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
try {
|
|
79
|
+
walk(candidate, 0);
|
|
80
|
+
return chunks.join("");
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
}
|
package/dist/src/errors.d.ts
CHANGED
|
@@ -2,6 +2,15 @@ import type { BlockerKind, CommandContext, CommandResult } from "./types.js";
|
|
|
2
2
|
type BlockerDetails = Partial<Omit<NonNullable<CommandResult["blocker"]>, "kind" | "message" | "visibleText">>;
|
|
3
3
|
export declare const BROWSER_BRIDGE_UNAVAILABLE_MESSAGE = "Codex cannot access the ChatGPT browser bridge from this backend process. In an ordinary shell this is expected; for a live Codex Chrome run, assign the Chrome plugin runtime returned by setupBrowserRuntime() to globalThis.agent before using it.";
|
|
4
4
|
export declare const BROWSER_BRIDGE_REMEDIATION: NonNullable<NonNullable<CommandResult["blocker"]>["remediation"]>;
|
|
5
|
+
/**
|
|
6
|
+
* Read a Node-style errno code without relying on realm-sensitive
|
|
7
|
+
* `instanceof Error` checks or invoking an untrusted accessor.
|
|
8
|
+
*
|
|
9
|
+
* Browser-hosted modules can receive filesystem errors created by the host
|
|
10
|
+
* realm. Those values are genuine Node errno objects but are not necessarily
|
|
11
|
+
* instances of this bundle's `Error` constructor.
|
|
12
|
+
*/
|
|
13
|
+
export declare function nodeErrorCode(error: unknown): string | undefined;
|
|
5
14
|
export declare class ChatGPTControlError extends Error {
|
|
6
15
|
readonly kind: BlockerKind;
|
|
7
16
|
readonly recoverable: boolean;
|
package/dist/src/errors.js
CHANGED
|
@@ -21,6 +21,28 @@ export const BROWSER_BRIDGE_REMEDIATION = [
|
|
|
21
21
|
userActionRequired: true
|
|
22
22
|
}
|
|
23
23
|
];
|
|
24
|
+
/**
|
|
25
|
+
* Read a Node-style errno code without relying on realm-sensitive
|
|
26
|
+
* `instanceof Error` checks or invoking an untrusted accessor.
|
|
27
|
+
*
|
|
28
|
+
* Browser-hosted modules can receive filesystem errors created by the host
|
|
29
|
+
* realm. Those values are genuine Node errno objects but are not necessarily
|
|
30
|
+
* instances of this bundle's `Error` constructor.
|
|
31
|
+
*/
|
|
32
|
+
export function nodeErrorCode(error) {
|
|
33
|
+
if (error === null || (typeof error !== "object" && typeof error !== "function"))
|
|
34
|
+
return undefined;
|
|
35
|
+
try {
|
|
36
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, "code");
|
|
37
|
+
if (descriptor === undefined || !("value" in descriptor) || typeof descriptor.value !== "string") {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
return descriptor.value;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
24
46
|
export class ChatGPTControlError extends Error {
|
|
25
47
|
kind;
|
|
26
48
|
recoverable;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -40,3 +40,9 @@ export * from "./runner/index.js";
|
|
|
40
40
|
export * from "./backend/client.js";
|
|
41
41
|
export * from "./backend/protocol.js";
|
|
42
42
|
export * from "./backend/session.js";
|
|
43
|
+
export * from "./runtime/runtime-session.js";
|
|
44
|
+
export * from "./runtime/tab-coordinator.js";
|
|
45
|
+
export * from "./runtime/operation-context.js";
|
|
46
|
+
export * from "./runtime/coordinated-page.js";
|
|
47
|
+
export * from "./runtime/coordinated-browser.js";
|
|
48
|
+
export * from "./operations/index.js";
|
package/dist/src/index.js
CHANGED
|
@@ -40,3 +40,12 @@ export * from "./runner/index.js";
|
|
|
40
40
|
export * from "./backend/client.js";
|
|
41
41
|
export * from "./backend/protocol.js";
|
|
42
42
|
export * from "./backend/session.js";
|
|
43
|
+
export * from "./runtime/runtime-session.js";
|
|
44
|
+
// Public adapter options accept injected coordinator/context instances. Keep
|
|
45
|
+
// their constructors and factories available alongside the facades so custom
|
|
46
|
+
// integrations do not need an undocumented private-subpath import.
|
|
47
|
+
export * from "./runtime/tab-coordinator.js";
|
|
48
|
+
export * from "./runtime/operation-context.js";
|
|
49
|
+
export * from "./runtime/coordinated-page.js";
|
|
50
|
+
export * from "./runtime/coordinated-browser.js";
|
|
51
|
+
export * from "./operations/index.js";
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** Fault boundaries are intentionally coarse: they model durable transitions,
|
|
2
|
+
* rather than exposing implementation-specific filesystem calls. */
|
|
3
|
+
export type ArtifactOutputFaultPoint = "before_temp_open" | "after_temp_open" | "before_write" | "after_write" | "before_file_sync" | "after_file_sync" | "before_final_link" | "after_final_link" | "before_temp_cleanup" | "after_temp_cleanup" | "before_directory_sync" | "after_directory_sync";
|
|
4
|
+
export type ArtifactOutputEntropy = (byteLength: number) => Uint8Array | Promise<Uint8Array>;
|
|
5
|
+
export type ArtifactOutputHooks = {
|
|
6
|
+
entropy?: ArtifactOutputEntropy;
|
|
7
|
+
faultInjector?: (point: ArtifactOutputFaultPoint) => void | Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
export type ArtifactOutputKeyInput = {
|
|
10
|
+
/** Opaque operation identity. It is hashed and never copied to the key. */
|
|
11
|
+
operationId: string;
|
|
12
|
+
/** Opaque source/artifact identity. It is hashed and never copied to the key. */
|
|
13
|
+
artifactIdentity: string;
|
|
14
|
+
/** Optional public filename extension, with or without a leading dot. */
|
|
15
|
+
extensionHint?: string;
|
|
16
|
+
/** Optional public MIME hint used only for vetted extension selection. */
|
|
17
|
+
mimeTypeHint?: string;
|
|
18
|
+
};
|
|
19
|
+
export type ArtifactOutputCommitOptions = ArtifactOutputKeyInput & {
|
|
20
|
+
/** Already-authorized destination. It must be absolute, existing, and real. */
|
|
21
|
+
outputDirectory: string;
|
|
22
|
+
source: AsyncIterable<Uint8Array>;
|
|
23
|
+
/** Durable browser/download receipt used to reconcile crash leftovers. */
|
|
24
|
+
expected?: Readonly<{
|
|
25
|
+
bytes: number;
|
|
26
|
+
sha256: string;
|
|
27
|
+
}>;
|
|
28
|
+
maxBytes?: number;
|
|
29
|
+
signal?: AbortSignal;
|
|
30
|
+
hooks?: ArtifactOutputHooks;
|
|
31
|
+
/** Optional absolute deadline for the local effect. */
|
|
32
|
+
deadlineAt?: number;
|
|
33
|
+
/** Optional relative deadline, evaluated by `now` at invocation start. */
|
|
34
|
+
timeoutMs?: number;
|
|
35
|
+
/** Injectable monotonic-ish wall clock used only for bounded checks. */
|
|
36
|
+
now?: () => number;
|
|
37
|
+
};
|
|
38
|
+
export type ArtifactOutputStatus = "committed" | "reconciled" | "collision" | "blocked";
|
|
39
|
+
export type ArtifactOutputReason = "created" | "recovered_after_crash" | "already_present" | "existing_mismatch" | "existing_target_not_regular" | "destination_invalid" | "ambiguous_temp" | "byte_limit_exceeded" | "source_aborted" | "source_invalid" | "source_mismatch" | "source_read_failed" | "write_failed" | "file_sync_failed" | "commit_indeterminate" | "directory_sync_failed" | "temp_cleanup_pending" | "temp_cleanup_ambiguous" | "entropy_failed" | "operation_timeout" | "clock_invalid";
|
|
40
|
+
/**
|
|
41
|
+
* A redacted, receipt-ready output result. The destination path and all
|
|
42
|
+
* source content are deliberately absent. For a blocked stream result,
|
|
43
|
+
* bytes/sha256 describe only the observed prefix (never a claimed final
|
|
44
|
+
* artifact); consumers must only create a durable transfer receipt for
|
|
45
|
+
* committed or reconciled results.
|
|
46
|
+
*/
|
|
47
|
+
export type ArtifactOutputResult = {
|
|
48
|
+
outputKey: string;
|
|
49
|
+
bytes: number;
|
|
50
|
+
sha256: string;
|
|
51
|
+
status: ArtifactOutputStatus;
|
|
52
|
+
reason: ArtifactOutputReason;
|
|
53
|
+
};
|
|
54
|
+
export declare class ArtifactOutputError extends Error {
|
|
55
|
+
readonly code: string;
|
|
56
|
+
constructor(code: string, message: string);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Derive one deterministic, path-safe output component from opaque identities.
|
|
60
|
+
* The only human-readable portion is the vetted public extension.
|
|
61
|
+
*/
|
|
62
|
+
export declare function deriveOperationOutputKey(input: ArtifactOutputKeyInput): string;
|
|
63
|
+
/**
|
|
64
|
+
* Stream one artifact into an operation-owned temporary file, then install it
|
|
65
|
+
* from the retained source descriptor into an exclusive destination file.
|
|
66
|
+
* Existing byte-identical finals are reconciled; any other existing target is
|
|
67
|
+
* never overwritten.
|
|
68
|
+
*/
|
|
69
|
+
export declare function commitOperationOutput(options: ArtifactOutputCommitOptions): Promise<ArtifactOutputResult>;
|