@zaalipro/dsh-workflows 0.1.0-rc.12
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/LICENSE +21 -0
- package/NOTICE.md +224 -0
- package/README.i18n.yaml +4 -0
- package/README.md +111 -0
- package/README.zh.md +111 -0
- package/cordis.patch.yml +10 -0
- package/docs/architecture.i18n.yaml +4 -0
- package/docs/architecture.md +177 -0
- package/docs/architecture.zh.md +177 -0
- package/docs/testing.i18n.yaml +4 -0
- package/docs/testing.md +125 -0
- package/docs/testing.zh.md +125 -0
- package/docs/user-guide.i18n.yaml +4 -0
- package/docs/user-guide.md +351 -0
- package/docs/user-guide.zh.md +351 -0
- package/lib/client-types/WorkflowMemberInspector.d.ts +28 -0
- package/lib/client-types/WorkflowMemberInspector.d.ts.map +1 -0
- package/lib/client-types/WorkflowMemberInspector.js +181 -0
- package/lib/client-types/WorkflowMemberInspector.js.map +1 -0
- package/lib/client-types/WorkflowRunPanel.d.ts +43 -0
- package/lib/client-types/WorkflowRunPanel.d.ts.map +1 -0
- package/lib/client-types/WorkflowRunPanel.js +130 -0
- package/lib/client-types/WorkflowRunPanel.js.map +1 -0
- package/lib/client-types/WorkflowsDashboard.d.ts +49 -0
- package/lib/client-types/WorkflowsDashboard.d.ts.map +1 -0
- package/lib/client-types/WorkflowsDashboard.js +942 -0
- package/lib/client-types/WorkflowsDashboard.js.map +1 -0
- package/lib/client-types/adapter.d.ts +60 -0
- package/lib/client-types/adapter.d.ts.map +1 -0
- package/lib/client-types/adapter.js +117 -0
- package/lib/client-types/adapter.js.map +1 -0
- package/lib/client-types/chat-renderer.d.ts +10 -0
- package/lib/client-types/chat-renderer.d.ts.map +1 -0
- package/lib/client-types/chat-renderer.js +11 -0
- package/lib/client-types/chat-renderer.js.map +1 -0
- package/lib/client-types/contract.d.ts +210 -0
- package/lib/client-types/contract.d.ts.map +1 -0
- package/lib/client-types/contract.js +37 -0
- package/lib/client-types/contract.js.map +1 -0
- package/lib/client-types/controller.d.ts +83 -0
- package/lib/client-types/controller.d.ts.map +1 -0
- package/lib/client-types/controller.js +705 -0
- package/lib/client-types/controller.js.map +1 -0
- package/lib/client-types/index.d.ts +19 -0
- package/lib/client-types/index.d.ts.map +1 -0
- package/lib/client-types/index.js +731 -0
- package/lib/client-types/index.js.map +1 -0
- package/lib/client-types/locales.d.ts +257 -0
- package/lib/client-types/locales.d.ts.map +1 -0
- package/lib/client-types/locales.js +270 -0
- package/lib/client-types/locales.js.map +1 -0
- package/lib/client-types/slot-components.d.ts +38 -0
- package/lib/client-types/slot-components.d.ts.map +1 -0
- package/lib/client-types/slot-components.js +22 -0
- package/lib/client-types/slot-components.js.map +1 -0
- package/lib/client-types/store.d.ts +69 -0
- package/lib/client-types/store.d.ts.map +1 -0
- package/lib/client-types/store.js +135 -0
- package/lib/client-types/store.js.map +1 -0
- package/lib/client-types/workflow-definition.d.ts +52 -0
- package/lib/client-types/workflow-definition.d.ts.map +1 -0
- package/lib/client-types/workflow-definition.js +135 -0
- package/lib/client-types/workflow-definition.js.map +1 -0
- package/lib/client.js +11065 -0
- package/lib/client.js.map +1 -0
- package/lib/compat-engine/index.js +1926 -0
- package/lib/compat-engine/index.js.map +1 -0
- package/lib/compat-engine/worker.cjs +1500 -0
- package/lib/compat-engine/worker.cjs.map +1 -0
- package/lib/typert.host.d.ts +3 -0
- package/lib/typert.host.js +1709 -0
- package/lib/typert.remote-client.d.ts +57 -0
- package/lib/typert.remote-client.js +1662 -0
- package/lib/types/commands/aliases.d.ts +4 -0
- package/lib/types/commands/aliases.d.ts.map +1 -0
- package/lib/types/commands/aliases.js +25 -0
- package/lib/types/commands/aliases.js.map +1 -0
- package/lib/types/commands/index.d.ts +66 -0
- package/lib/types/commands/index.d.ts.map +1 -0
- package/lib/types/commands/index.js +550 -0
- package/lib/types/commands/index.js.map +1 -0
- package/lib/types/commands/parser.d.ts +17 -0
- package/lib/types/commands/parser.d.ts.map +1 -0
- package/lib/types/commands/parser.js +45 -0
- package/lib/types/commands/parser.js.map +1 -0
- package/lib/types/config.d.ts +71 -0
- package/lib/types/config.d.ts.map +1 -0
- package/lib/types/config.js +109 -0
- package/lib/types/config.js.map +1 -0
- package/lib/types/index.d.ts +41 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +483 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/invariant.d.ts +21 -0
- package/lib/types/invariant.d.ts.map +1 -0
- package/lib/types/invariant.js +85 -0
- package/lib/types/invariant.js.map +1 -0
- package/lib/types/registry/definition.d.ts +24 -0
- package/lib/types/registry/definition.d.ts.map +1 -0
- package/lib/types/registry/definition.js +189 -0
- package/lib/types/registry/definition.js.map +1 -0
- package/lib/types/registry/index.d.ts +100 -0
- package/lib/types/registry/index.d.ts.map +1 -0
- package/lib/types/registry/index.js +899 -0
- package/lib/types/registry/index.js.map +1 -0
- package/lib/types/registry/names.d.ts +19 -0
- package/lib/types/registry/names.d.ts.map +1 -0
- package/lib/types/registry/names.js +69 -0
- package/lib/types/registry/names.js.map +1 -0
- package/lib/types/registry/remote.d.ts +15 -0
- package/lib/types/registry/remote.d.ts.map +1 -0
- package/lib/types/registry/remote.js +128 -0
- package/lib/types/registry/remote.js.map +1 -0
- package/lib/types/registry/roots.d.ts +44 -0
- package/lib/types/registry/roots.d.ts.map +1 -0
- package/lib/types/registry/roots.js +118 -0
- package/lib/types/registry/roots.js.map +1 -0
- package/lib/types/registry/types.d.ts +62 -0
- package/lib/types/registry/types.d.ts.map +1 -0
- package/lib/types/registry/types.js +2 -0
- package/lib/types/registry/types.js.map +1 -0
- package/lib/types/registry/watchers.d.ts +70 -0
- package/lib/types/registry/watchers.d.ts.map +1 -0
- package/lib/types/registry/watchers.js +152 -0
- package/lib/types/registry/watchers.js.map +1 -0
- package/lib/types/remote-events.d.ts +42 -0
- package/lib/types/remote-events.d.ts.map +1 -0
- package/lib/types/remote-events.js +21 -0
- package/lib/types/remote-events.js.map +1 -0
- package/lib/types/run-recorder.d.ts +44 -0
- package/lib/types/run-recorder.d.ts.map +1 -0
- package/lib/types/run-recorder.js +356 -0
- package/lib/types/run-recorder.js.map +1 -0
- package/lib/types/supervisor/canned-validate.d.ts +25 -0
- package/lib/types/supervisor/canned-validate.d.ts.map +1 -0
- package/lib/types/supervisor/canned-validate.js +122 -0
- package/lib/types/supervisor/canned-validate.js.map +1 -0
- package/lib/types/supervisor/completion-notice.d.ts +49 -0
- package/lib/types/supervisor/completion-notice.d.ts.map +1 -0
- package/lib/types/supervisor/completion-notice.js +281 -0
- package/lib/types/supervisor/completion-notice.js.map +1 -0
- package/lib/types/supervisor/cursors.d.ts +68 -0
- package/lib/types/supervisor/cursors.d.ts.map +1 -0
- package/lib/types/supervisor/cursors.js +158 -0
- package/lib/types/supervisor/cursors.js.map +1 -0
- package/lib/types/supervisor/engine-compat.d.ts +48 -0
- package/lib/types/supervisor/engine-compat.d.ts.map +1 -0
- package/lib/types/supervisor/engine-compat.js +116 -0
- package/lib/types/supervisor/engine-compat.js.map +1 -0
- package/lib/types/supervisor/index.d.ts +183 -0
- package/lib/types/supervisor/index.d.ts.map +1 -0
- package/lib/types/supervisor/index.js +2040 -0
- package/lib/types/supervisor/index.js.map +1 -0
- package/lib/types/supervisor/parallel-compat.d.ts +36 -0
- package/lib/types/supervisor/parallel-compat.d.ts.map +1 -0
- package/lib/types/supervisor/parallel-compat.js +180 -0
- package/lib/types/supervisor/parallel-compat.js.map +1 -0
- package/lib/types/supervisor/remote.d.ts +25 -0
- package/lib/types/supervisor/remote.d.ts.map +1 -0
- package/lib/types/supervisor/remote.js +478 -0
- package/lib/types/supervisor/remote.js.map +1 -0
- package/lib/types/supervisor/storage/bounded-file.d.ts +41 -0
- package/lib/types/supervisor/storage/bounded-file.d.ts.map +1 -0
- package/lib/types/supervisor/storage/bounded-file.js +186 -0
- package/lib/types/supervisor/storage/bounded-file.js.map +1 -0
- package/lib/types/supervisor/storage/details-codec.d.ts +14 -0
- package/lib/types/supervisor/storage/details-codec.d.ts.map +1 -0
- package/lib/types/supervisor/storage/details-codec.js +359 -0
- package/lib/types/supervisor/storage/details-codec.js.map +1 -0
- package/lib/types/supervisor/storage/index.d.ts +26 -0
- package/lib/types/supervisor/storage/index.d.ts.map +1 -0
- package/lib/types/supervisor/storage/index.js +100 -0
- package/lib/types/supervisor/storage/index.js.map +1 -0
- package/lib/types/supervisor/storage/lease.d.ts +34 -0
- package/lib/types/supervisor/storage/lease.d.ts.map +1 -0
- package/lib/types/supervisor/storage/lease.js +289 -0
- package/lib/types/supervisor/storage/lease.js.map +1 -0
- package/lib/types/supervisor/storage/manifest-codec.d.ts +10 -0
- package/lib/types/supervisor/storage/manifest-codec.d.ts.map +1 -0
- package/lib/types/supervisor/storage/manifest-codec.js +335 -0
- package/lib/types/supervisor/storage/manifest-codec.js.map +1 -0
- package/lib/types/supervisor/storage/manifest-store.d.ts +99 -0
- package/lib/types/supervisor/storage/manifest-store.d.ts.map +1 -0
- package/lib/types/supervisor/storage/manifest-store.js +1606 -0
- package/lib/types/supervisor/storage/manifest-store.js.map +1 -0
- package/lib/types/supervisor/storage/manifest-types.d.ts +269 -0
- package/lib/types/supervisor/storage/manifest-types.d.ts.map +1 -0
- package/lib/types/supervisor/storage/manifest-types.js +2 -0
- package/lib/types/supervisor/storage/manifest-types.js.map +1 -0
- package/lib/types/supervisor/storage/private-root.d.ts +143 -0
- package/lib/types/supervisor/storage/private-root.d.ts.map +1 -0
- package/lib/types/supervisor/storage/private-root.js +860 -0
- package/lib/types/supervisor/storage/private-root.js.map +1 -0
- package/lib/types/supervisor/storage/recovery.d.ts +14 -0
- package/lib/types/supervisor/storage/recovery.d.ts.map +1 -0
- package/lib/types/supervisor/storage/recovery.js +126 -0
- package/lib/types/supervisor/storage/recovery.js.map +1 -0
- package/lib/types/supervisor/storage/run-files.d.ts +67 -0
- package/lib/types/supervisor/storage/run-files.d.ts.map +1 -0
- package/lib/types/supervisor/storage/run-files.js +346 -0
- package/lib/types/supervisor/storage/run-files.js.map +1 -0
- package/lib/types/supervisor/types.d.ts +295 -0
- package/lib/types/supervisor/types.d.ts.map +1 -0
- package/lib/types/supervisor/types.js +3 -0
- package/lib/types/supervisor/types.js.map +1 -0
- package/lib/types/supervisor/value-view.d.ts +19 -0
- package/lib/types/supervisor/value-view.d.ts.map +1 -0
- package/lib/types/supervisor/value-view.js +183 -0
- package/lib/types/supervisor/value-view.js.map +1 -0
- package/lib/types/tool/index.d.ts +86 -0
- package/lib/types/tool/index.d.ts.map +1 -0
- package/lib/types/tool/index.js +810 -0
- package/lib/types/tool/index.js.map +1 -0
- package/lib/types/tool/schema.d.ts +158 -0
- package/lib/types/tool/schema.d.ts.map +1 -0
- package/lib/types/tool/schema.js +137 -0
- package/lib/types/tool/schema.js.map +1 -0
- package/lib/types/types.d.ts +9 -0
- package/lib/types/types.d.ts.map +1 -0
- package/lib/types/types.js +3 -0
- package/lib/types/types.js.map +1 -0
- package/lib/types/user-questions.d.ts +9 -0
- package/lib/types/user-questions.d.ts.map +1 -0
- package/lib/types/user-questions.js +91 -0
- package/lib/types/user-questions.js.map +1 -0
- package/package.json +291 -0
- package/skills/create-workflow/SKILL.md +166 -0
- package/vendor/workflow-engine/LICENSE +21 -0
- package/vendor/workflow-engine/README.md +1 -0
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { constants } from 'node:fs';
|
|
2
|
+
import { lstat, mkdir, open, readdir } from 'node:fs/promises';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
import { BoundedFileError, assertSafeComponent } from './bounded-file.js';
|
|
5
|
+
const NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/u;
|
|
6
|
+
const decoder = new TextDecoder('utf-8', { fatal: true });
|
|
7
|
+
const encoder = new TextEncoder();
|
|
8
|
+
function checkName(name) {
|
|
9
|
+
if (!NAME.test(name) || name === '.' || name === '..' || name.includes('/') || name.includes('\\')) {
|
|
10
|
+
throw new BoundedFileError(`scratch name "${name}" is invalid`, 'WORKFLOW_STORAGE_UNSAFE');
|
|
11
|
+
}
|
|
12
|
+
return name;
|
|
13
|
+
}
|
|
14
|
+
function errorCode(error) {
|
|
15
|
+
return typeof error === 'object' && error !== null && 'code' in error
|
|
16
|
+
? String(error.code)
|
|
17
|
+
: undefined;
|
|
18
|
+
}
|
|
19
|
+
/** Only explicit filesystem absence codes are allowed to become an
|
|
20
|
+
* `undefined` scratch read. Message matching is intentionally forbidden:
|
|
21
|
+
* provider identity/permission failures often contain the words "not found"
|
|
22
|
+
* and must remain fatal. */
|
|
23
|
+
function isNotFound(error) {
|
|
24
|
+
const code = errorCode(error);
|
|
25
|
+
return code === 'ENOENT' || code === 'FS_NOT_FOUND';
|
|
26
|
+
}
|
|
27
|
+
function hasStableIdentity(identity) {
|
|
28
|
+
if (identity === undefined || !Number.isSafeInteger(Number(identity.size)) || Number(identity.size) < 0)
|
|
29
|
+
return false;
|
|
30
|
+
if (identity.nlink !== undefined && identity.nlink !== 1)
|
|
31
|
+
return false;
|
|
32
|
+
const posix = Number.isSafeInteger(Number(identity.dev)) && Number.isSafeInteger(Number(identity.ino))
|
|
33
|
+
&& !Number.isNaN(Number(identity.dev)) && !Number.isNaN(Number(identity.ino));
|
|
34
|
+
return posix || identity.version !== undefined;
|
|
35
|
+
}
|
|
36
|
+
function assertLimits(limits) {
|
|
37
|
+
for (const [name, value] of Object.entries(limits)) {
|
|
38
|
+
if (!Number.isSafeInteger(value) || value < 1)
|
|
39
|
+
throw new RangeError(`${name} must be a positive safe integer`);
|
|
40
|
+
}
|
|
41
|
+
if (limits.maxPendingOperations > limits.maxOperations)
|
|
42
|
+
throw new RangeError('maxPendingOperations must not exceed maxOperations');
|
|
43
|
+
if (limits.maxFileBytes > limits.maxTotalBytes)
|
|
44
|
+
throw new RangeError('maxFileBytes must not exceed maxTotalBytes');
|
|
45
|
+
}
|
|
46
|
+
/** Run-scoped scratch authority with operation, pending, file, and byte quotas. */
|
|
47
|
+
export class RunScratchStore {
|
|
48
|
+
limits;
|
|
49
|
+
operations = 0;
|
|
50
|
+
pending = 0;
|
|
51
|
+
closed = false;
|
|
52
|
+
initialized = false;
|
|
53
|
+
files = new Map();
|
|
54
|
+
total = 0;
|
|
55
|
+
tail = Promise.resolve();
|
|
56
|
+
inflight = new Set();
|
|
57
|
+
lifetime = new AbortController();
|
|
58
|
+
directory;
|
|
59
|
+
path;
|
|
60
|
+
constructor(directoryOrPath, limits) {
|
|
61
|
+
this.limits = limits;
|
|
62
|
+
assertLimits(limits);
|
|
63
|
+
if (typeof directoryOrPath === 'string')
|
|
64
|
+
this.path = directoryOrPath;
|
|
65
|
+
else {
|
|
66
|
+
this.directory = directoryOrPath;
|
|
67
|
+
this.path = directoryOrPath.path;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
signal(signal) {
|
|
71
|
+
return signal === undefined ? this.lifetime.signal : AbortSignal.any([signal, this.lifetime.signal]);
|
|
72
|
+
}
|
|
73
|
+
/** Wait for a fixed point. A single snapshot of `inflight` is not enough:
|
|
74
|
+
* a queued write can settle the same turn that a read's finally-handler is
|
|
75
|
+
* removing itself. Rechecking the tail, set, and counter prevents list or
|
|
76
|
+
* disposal from inventorying/closing while an admitted operation is still
|
|
77
|
+
* capable of touching scratch. */
|
|
78
|
+
async drain() {
|
|
79
|
+
for (;;) {
|
|
80
|
+
const tail = this.tail;
|
|
81
|
+
const inflight = [...this.inflight];
|
|
82
|
+
await Promise.allSettled([tail, ...inflight]);
|
|
83
|
+
if (tail === this.tail && this.inflight.size === 0 && this.pending === 0)
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
begin(name, supplied) {
|
|
88
|
+
if (this.closed)
|
|
89
|
+
throw new BoundedFileError('scratch store is disposed');
|
|
90
|
+
checkName(name);
|
|
91
|
+
const signal = this.signal(supplied);
|
|
92
|
+
signal.throwIfAborted();
|
|
93
|
+
if (this.operations >= this.limits.maxOperations)
|
|
94
|
+
throw new BoundedFileError('scratch operation quota exceeded', 'WORKFLOW_STORAGE_LIMIT');
|
|
95
|
+
if (this.pending >= this.limits.maxPendingOperations)
|
|
96
|
+
throw new BoundedFileError('scratch pending-operation quota exceeded', 'WORKFLOW_STORAGE_LIMIT');
|
|
97
|
+
this.operations += 1;
|
|
98
|
+
this.pending += 1;
|
|
99
|
+
return signal;
|
|
100
|
+
}
|
|
101
|
+
track(operation) {
|
|
102
|
+
this.inflight.add(operation);
|
|
103
|
+
void operation.finally(() => { this.inflight.delete(operation); this.pending -= 1; }).catch(() => undefined);
|
|
104
|
+
return operation;
|
|
105
|
+
}
|
|
106
|
+
async ensureDirectory(signal) {
|
|
107
|
+
signal.throwIfAborted();
|
|
108
|
+
if (this.directory !== undefined) {
|
|
109
|
+
await this.directory.assertIdentity(signal);
|
|
110
|
+
return this.directory;
|
|
111
|
+
}
|
|
112
|
+
await mkdir(this.path, { recursive: true, mode: 0o700 });
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
async inventory(signal) {
|
|
116
|
+
if (this.initialized)
|
|
117
|
+
return;
|
|
118
|
+
const directory = await this.ensureDirectory(signal);
|
|
119
|
+
const entries = directory?.listEntries !== undefined
|
|
120
|
+
? await directory.listEntries(signal)
|
|
121
|
+
: (await readdir(this.path)).sort().map(name => ({ name, type: 'file' }));
|
|
122
|
+
if (entries.length > this.limits.maxFiles)
|
|
123
|
+
throw new BoundedFileError('scratch file quota exceeded', 'WORKFLOW_STORAGE_LIMIT');
|
|
124
|
+
let total = 0;
|
|
125
|
+
for (const entry of entries) {
|
|
126
|
+
const name = entry.name;
|
|
127
|
+
checkName(name);
|
|
128
|
+
if (entry.type !== 'file' || entry.identity?.nlink !== undefined && entry.identity.nlink !== 1) {
|
|
129
|
+
throw new BoundedFileError(`workflow storage path "${join(this.path, name)}" is unsafe: scratch entry is not a regular file`, 'WORKFLOW_STORAGE_UNSAFE');
|
|
130
|
+
}
|
|
131
|
+
let identity = entry.identity;
|
|
132
|
+
if (identity === undefined && directory !== undefined) {
|
|
133
|
+
if (directory.fileInfo === undefined)
|
|
134
|
+
throw new BoundedFileError('descriptor-rooted scratch metadata is unavailable', 'WORKFLOW_STORAGE_UNSUPPORTED');
|
|
135
|
+
identity = await directory.fileInfo(name, signal);
|
|
136
|
+
}
|
|
137
|
+
if (directory !== undefined && !hasStableIdentity(identity)) {
|
|
138
|
+
throw new BoundedFileError(`descriptor-rooted scratch metadata for "${name}" is unavailable`, 'WORKFLOW_STORAGE_UNSUPPORTED');
|
|
139
|
+
}
|
|
140
|
+
const size = identity?.size ?? (await lstat(join(this.path, name))).size;
|
|
141
|
+
if (!Number.isSafeInteger(Number(size)) || Number(size) < 0)
|
|
142
|
+
throw new BoundedFileError('scratch file metadata is invalid', 'WORKFLOW_STORAGE_UNSUPPORTED');
|
|
143
|
+
if (size > this.limits.maxFileBytes)
|
|
144
|
+
throw new BoundedFileError('scratch file exceeds per-file quota', 'WORKFLOW_STORAGE_LIMIT');
|
|
145
|
+
total += size;
|
|
146
|
+
if (total > this.limits.maxTotalBytes)
|
|
147
|
+
throw new BoundedFileError('scratch total quota exceeded', 'WORKFLOW_STORAGE_LIMIT');
|
|
148
|
+
this.files.set(name, size);
|
|
149
|
+
}
|
|
150
|
+
this.total = total;
|
|
151
|
+
this.initialized = true;
|
|
152
|
+
}
|
|
153
|
+
async read(name, supplied) {
|
|
154
|
+
const signal = this.begin(name, supplied);
|
|
155
|
+
const operation = (async () => {
|
|
156
|
+
await this.inventory(signal);
|
|
157
|
+
const directory = await this.ensureDirectory(signal);
|
|
158
|
+
try {
|
|
159
|
+
let bytes;
|
|
160
|
+
if (directory !== undefined)
|
|
161
|
+
bytes = await directory.readBytes(name, signal, this.limits.maxFileBytes);
|
|
162
|
+
else {
|
|
163
|
+
if (process.platform === 'win32' || !constants.O_NOFOLLOW)
|
|
164
|
+
throw new BoundedFileError(`safe workflow storage is unavailable on ${process.platform}`, 'WORKFLOW_STORAGE_UNSUPPORTED');
|
|
165
|
+
const handle = await open(join(this.path, name), constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
166
|
+
try {
|
|
167
|
+
const info = await handle.stat();
|
|
168
|
+
if (!info.isFile() || info.nlink !== 1 || info.size > this.limits.maxFileBytes)
|
|
169
|
+
throw new BoundedFileError('scratch file is unsafe or oversized', 'WORKFLOW_STORAGE_UNSAFE');
|
|
170
|
+
bytes = new Uint8Array(await handle.readFile());
|
|
171
|
+
}
|
|
172
|
+
finally {
|
|
173
|
+
await handle.close();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
signal.throwIfAborted();
|
|
177
|
+
return decoder.decode(bytes);
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
if (isNotFound(error))
|
|
181
|
+
return undefined;
|
|
182
|
+
throw error;
|
|
183
|
+
}
|
|
184
|
+
})();
|
|
185
|
+
return this.track(operation);
|
|
186
|
+
}
|
|
187
|
+
async write(name, content, supplied) {
|
|
188
|
+
const signal = this.begin(name, supplied);
|
|
189
|
+
const operation = this.tail.then(async () => {
|
|
190
|
+
await this.inventory(signal);
|
|
191
|
+
const bytes = encoder.encode(content);
|
|
192
|
+
if (bytes.byteLength > this.limits.maxFileBytes)
|
|
193
|
+
throw new BoundedFileError('scratch file exceeds per-file quota', 'WORKFLOW_STORAGE_LIMIT');
|
|
194
|
+
const previous = this.files.get(name) ?? 0;
|
|
195
|
+
if (!this.files.has(name) && this.files.size >= this.limits.maxFiles)
|
|
196
|
+
throw new BoundedFileError('scratch file quota exceeded', 'WORKFLOW_STORAGE_LIMIT');
|
|
197
|
+
const nextTotal = this.total - previous + bytes.byteLength;
|
|
198
|
+
if (nextTotal > this.limits.maxTotalBytes)
|
|
199
|
+
throw new BoundedFileError('scratch total quota exceeded', 'WORKFLOW_STORAGE_LIMIT');
|
|
200
|
+
const directory = await this.ensureDirectory(signal);
|
|
201
|
+
if (directory === undefined)
|
|
202
|
+
throw new BoundedFileError('descriptor-rooted scratch publication is unavailable', 'WORKFLOW_STORAGE_UNSUPPORTED');
|
|
203
|
+
let expected;
|
|
204
|
+
if (this.files.has(name)) {
|
|
205
|
+
let info;
|
|
206
|
+
if (directory.fileInfo !== undefined)
|
|
207
|
+
info = await directory.fileInfo(name, signal);
|
|
208
|
+
else
|
|
209
|
+
throw new BoundedFileError('descriptor-rooted scratch metadata is unavailable', 'WORKFLOW_STORAGE_UNSUPPORTED');
|
|
210
|
+
if (!hasStableIdentity(info))
|
|
211
|
+
throw new BoundedFileError('scratch destination changed', 'WORKFLOW_STORAGE_UNSAFE');
|
|
212
|
+
expected = { kind: 'replaceIfVersion', version: info };
|
|
213
|
+
}
|
|
214
|
+
else
|
|
215
|
+
expected = { kind: 'createIfAbsent' };
|
|
216
|
+
await directory.writeText(name, content, expected, signal);
|
|
217
|
+
await directory.assertIdentity(signal);
|
|
218
|
+
this.files.set(name, bytes.byteLength);
|
|
219
|
+
this.total = nextTotal;
|
|
220
|
+
});
|
|
221
|
+
this.tail = operation.catch(() => undefined);
|
|
222
|
+
return this.track(operation);
|
|
223
|
+
}
|
|
224
|
+
async list(supplied) {
|
|
225
|
+
if (this.closed)
|
|
226
|
+
throw new BoundedFileError('scratch store is disposed');
|
|
227
|
+
const signal = this.signal(supplied);
|
|
228
|
+
supplied?.throwIfAborted();
|
|
229
|
+
await this.drain();
|
|
230
|
+
await this.inventory(signal);
|
|
231
|
+
signal.throwIfAborted();
|
|
232
|
+
return [...this.files.keys()].sort();
|
|
233
|
+
}
|
|
234
|
+
cancel(reason = new Error('scratch operation cancelled')) {
|
|
235
|
+
if (!this.lifetime.signal.aborted)
|
|
236
|
+
this.lifetime.abort(reason);
|
|
237
|
+
}
|
|
238
|
+
async dispose() {
|
|
239
|
+
if (this.closed)
|
|
240
|
+
return;
|
|
241
|
+
this.closed = true;
|
|
242
|
+
this.cancel(new Error('scratch store disposed'));
|
|
243
|
+
await this.drain();
|
|
244
|
+
let first;
|
|
245
|
+
try {
|
|
246
|
+
await this.directory?.close();
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
first = error;
|
|
250
|
+
}
|
|
251
|
+
this.directory = undefined;
|
|
252
|
+
if (first !== undefined)
|
|
253
|
+
throw first;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/** Own the run-directory parent for as long as a scratch capability is live.
|
|
257
|
+
* A child PrivateDirectory retains its parent descriptor, but the parent must
|
|
258
|
+
* also receive the caller's close request so its descriptor is eventually
|
|
259
|
+
* released after the child drains. */
|
|
260
|
+
class RetainedScratchStore {
|
|
261
|
+
inner;
|
|
262
|
+
parent;
|
|
263
|
+
disposed = false;
|
|
264
|
+
constructor(inner, parent) {
|
|
265
|
+
this.inner = inner;
|
|
266
|
+
this.parent = parent;
|
|
267
|
+
}
|
|
268
|
+
read(name, signal) { return this.inner.read(name, signal); }
|
|
269
|
+
write(name, content, signal) { return this.inner.write(name, content, signal); }
|
|
270
|
+
list(signal) { return this.inner.list(signal); }
|
|
271
|
+
cancel(reason) { this.inner.cancel?.(reason); }
|
|
272
|
+
async dispose() {
|
|
273
|
+
if (this.disposed)
|
|
274
|
+
return;
|
|
275
|
+
this.disposed = true;
|
|
276
|
+
let first;
|
|
277
|
+
try {
|
|
278
|
+
await this.inner.dispose();
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
first = error;
|
|
282
|
+
}
|
|
283
|
+
try {
|
|
284
|
+
await this.parent.close();
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
first ??= error;
|
|
288
|
+
}
|
|
289
|
+
if (first !== undefined)
|
|
290
|
+
throw first;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
/** Open the scratch component of one already-published run directory. */
|
|
294
|
+
export async function openRunScratch(layout, runDirectory, limits) {
|
|
295
|
+
assertSafeComponent(runDirectory, 'run directory');
|
|
296
|
+
await layout.lease.assertCurrent();
|
|
297
|
+
const run = await layout.runs.openDirectory(runDirectory);
|
|
298
|
+
let transferred = false;
|
|
299
|
+
try {
|
|
300
|
+
const scratch = await run.openDirectory('scratch');
|
|
301
|
+
const result = new RetainedScratchStore(new RunScratchStore(scratch, limits), run);
|
|
302
|
+
transferred = true;
|
|
303
|
+
return result;
|
|
304
|
+
}
|
|
305
|
+
finally {
|
|
306
|
+
if (!transferred)
|
|
307
|
+
await run.close();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
/** Create an immutable projection and descriptor-rooted run scratch authority. */
|
|
311
|
+
export async function createRunFiles(layout, runDirectory, scriptBytes, limits) {
|
|
312
|
+
assertSafeComponent(runDirectory, 'run directory');
|
|
313
|
+
const maxScriptBytes = limits.maxScriptBytes ?? 1_048_576;
|
|
314
|
+
if (scriptBytes.byteLength > maxScriptBytes)
|
|
315
|
+
throw new BoundedFileError('workflow script exceeds configured limit', 'WORKFLOW_STORAGE_LIMIT');
|
|
316
|
+
await layout.lease.assertCurrent();
|
|
317
|
+
const run = await layout.runs.openDirectory(runDirectory, undefined, { create: true });
|
|
318
|
+
let transferred = false;
|
|
319
|
+
try {
|
|
320
|
+
await run.writeText('script.js', decoder.decode(scriptBytes), { kind: 'createIfAbsent' });
|
|
321
|
+
const scratchDirectory = await run.openDirectory('scratch', undefined, { create: true });
|
|
322
|
+
const details = await run.openDirectory('details', undefined, { create: true });
|
|
323
|
+
await details.close();
|
|
324
|
+
const scratch = new RetainedScratchStore(new RunScratchStore(scratchDirectory, limits), run);
|
|
325
|
+
transferred = true;
|
|
326
|
+
let disposed = false;
|
|
327
|
+
return {
|
|
328
|
+
runDirectory,
|
|
329
|
+
scriptPath: join(layout.runs.path, runDirectory, 'script.js'),
|
|
330
|
+
script: new Uint8Array(scriptBytes),
|
|
331
|
+
scratch,
|
|
332
|
+
detailsPath: join(layout.runs.path, runDirectory, 'details'),
|
|
333
|
+
async dispose() { if (disposed)
|
|
334
|
+
return; disposed = true; await scratch.dispose(); },
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
finally {
|
|
338
|
+
if (!transferred)
|
|
339
|
+
await run.close();
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
/** Derive a run directory from an exposed script projection without leaking it to the engine. */
|
|
343
|
+
export function scratchDirectoryFromScriptPath(scriptPath) {
|
|
344
|
+
return dirname(scriptPath);
|
|
345
|
+
}
|
|
346
|
+
//# sourceMappingURL=run-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-files.js","sourceRoot":"","sources":["../../../../src/supervisor/storage/run-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC9D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AA6BzE,MAAM,IAAI,GAAG,+BAA+B,CAAA;AAC5C,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;AACzD,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;AAEjC,SAAS,SAAS,CAAC,IAAY;IAC7B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACnG,MAAM,IAAI,gBAAgB,CAAC,iBAAiB,IAAI,cAAc,EAAE,yBAAyB,CAAC,CAAA;IAC5F,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK;QACnE,CAAC,CAAC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,WAAW,CAAC;YAC7D,MAAM,EAAE,IAAI,UAAU,CAAC,WAAW,CAAC;YACnC,OAAO;YACP,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,SAAS,CAAC;YAC5D,KAAK,CAAC,OAAO,KAAK,IAAI,QAAQ;gBAAE,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA,CAAC,CAAC;SACnF,CAAA;IACH,CAAC;YAAS,CAAC;QAAC,IAAI,CAAC,WAAW;YAAE,MAAM,GAAG,CAAC,KAAK,EAAE,CAAA;IAAC,CAAC;AACnD,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,8BAA8B,CAAC,UAAkB;IAC/D,OAAO,OAAO,CAAC,UAAU,CAAC,CAAA;AAC5B,CAAC"}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import type { JsonValue, WorkflowRunStatus, WorkflowRunOutcomeState } from './storage/manifest-types.js';
|
|
2
|
+
import type { WorkflowScope } from '../registry/types.js';
|
|
3
|
+
export type { WorkflowRunStatus, WorkflowRunOutcomeState };
|
|
4
|
+
/** Plain string on the wire: Typert strict codecs reject TypeScript `__brand` intersections. */
|
|
5
|
+
export type SupervisedWorkflowRunId = string;
|
|
6
|
+
export type WorkflowMemberId = string;
|
|
7
|
+
export type WorkflowGateId = string;
|
|
8
|
+
export type WorkflowRunCursor = string;
|
|
9
|
+
export type WorkflowRunFeedEpoch = string;
|
|
10
|
+
export interface WorkflowPhase {
|
|
11
|
+
readonly title: string;
|
|
12
|
+
readonly detail?: string;
|
|
13
|
+
readonly provider?: string;
|
|
14
|
+
readonly model?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface WorkflowGateInfo {
|
|
17
|
+
readonly id?: WorkflowGateId;
|
|
18
|
+
readonly kind: 'user' | 'back_off' | 'no_progress' | 'verification' | 'infra';
|
|
19
|
+
readonly message: string;
|
|
20
|
+
readonly resumable: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface SupervisedWorkflowRunInfo {
|
|
23
|
+
readonly id: SupervisedWorkflowRunId;
|
|
24
|
+
readonly displayName: string;
|
|
25
|
+
readonly name: string;
|
|
26
|
+
}
|
|
27
|
+
export type SupervisedWorkflowStopReason = 'completed' | 'cancelled' | 'error' | 'interrupted';
|
|
28
|
+
export interface SupervisedWorkflowResultInfo {
|
|
29
|
+
readonly stopReason: SupervisedWorkflowStopReason;
|
|
30
|
+
readonly error?: string;
|
|
31
|
+
readonly agentsStarted: number;
|
|
32
|
+
}
|
|
33
|
+
export interface SupervisedWorkflowMemberLifecycleInfo {
|
|
34
|
+
readonly memberId: WorkflowMemberId;
|
|
35
|
+
readonly seq: number;
|
|
36
|
+
readonly label: string;
|
|
37
|
+
readonly phase?: string;
|
|
38
|
+
readonly childSessionId: string;
|
|
39
|
+
readonly status: 'running' | 'completed' | 'failed' | 'cancelled';
|
|
40
|
+
}
|
|
41
|
+
export interface WorkflowGateRequest {
|
|
42
|
+
readonly info: SupervisedWorkflowRunInfo;
|
|
43
|
+
readonly executionId: string;
|
|
44
|
+
readonly gateId: WorkflowGateId;
|
|
45
|
+
readonly gate: WorkflowGateInfo;
|
|
46
|
+
readonly parent: unknown;
|
|
47
|
+
readonly signal: AbortSignal;
|
|
48
|
+
}
|
|
49
|
+
export interface WorkflowRunRecordingSnapshot {
|
|
50
|
+
readonly info: SupervisedWorkflowRunInfo;
|
|
51
|
+
readonly run: WorkflowRunHead;
|
|
52
|
+
readonly members: readonly SupervisedWorkflowMemberLifecycleInfo[];
|
|
53
|
+
readonly result?: SupervisedWorkflowResultInfo;
|
|
54
|
+
}
|
|
55
|
+
export interface WorkflowRunMemberCounts {
|
|
56
|
+
readonly total: number;
|
|
57
|
+
readonly running: number;
|
|
58
|
+
readonly completed: number;
|
|
59
|
+
readonly failed: number;
|
|
60
|
+
readonly cancelled: number;
|
|
61
|
+
}
|
|
62
|
+
export type WorkflowRunAction = 'pause' | 'resume' | 'stop' | 'save';
|
|
63
|
+
export interface WorkflowRunTerminalSummary {
|
|
64
|
+
readonly stopReason: 'completed' | 'cancelled' | 'error' | 'interrupted';
|
|
65
|
+
readonly resultState: Exclude<WorkflowRunOutcomeState, 'pending'>;
|
|
66
|
+
readonly preview?: string;
|
|
67
|
+
readonly error?: string;
|
|
68
|
+
}
|
|
69
|
+
export interface WorkflowRunHead {
|
|
70
|
+
readonly runId: SupervisedWorkflowRunId;
|
|
71
|
+
readonly displayName: string;
|
|
72
|
+
readonly name: string;
|
|
73
|
+
readonly description: string;
|
|
74
|
+
readonly status: WorkflowRunStatus;
|
|
75
|
+
readonly phase?: string;
|
|
76
|
+
readonly budget: {
|
|
77
|
+
readonly total: number;
|
|
78
|
+
readonly spent: number;
|
|
79
|
+
readonly remaining: number;
|
|
80
|
+
};
|
|
81
|
+
readonly memberCounts: WorkflowRunMemberCounts;
|
|
82
|
+
readonly startedAt: number;
|
|
83
|
+
readonly settledAt?: number;
|
|
84
|
+
readonly terminal?: WorkflowRunTerminalSummary;
|
|
85
|
+
readonly allowedActions: readonly WorkflowRunAction[];
|
|
86
|
+
readonly revision: number;
|
|
87
|
+
readonly detailRevision: number;
|
|
88
|
+
readonly membersRevision: number;
|
|
89
|
+
readonly logsRevision: number;
|
|
90
|
+
readonly resultRevision: number;
|
|
91
|
+
readonly artifactsRevision: number;
|
|
92
|
+
}
|
|
93
|
+
export interface WorkflowRunListRequest {
|
|
94
|
+
readonly cursor?: WorkflowRunCursor;
|
|
95
|
+
readonly limit?: number;
|
|
96
|
+
}
|
|
97
|
+
export interface WorkflowRunListPage {
|
|
98
|
+
readonly epoch: WorkflowRunFeedEpoch;
|
|
99
|
+
readonly sessionRevision: number;
|
|
100
|
+
readonly items: readonly WorkflowRunHead[];
|
|
101
|
+
readonly nextCursor?: WorkflowRunCursor;
|
|
102
|
+
readonly total: number;
|
|
103
|
+
}
|
|
104
|
+
export interface WorkflowRunRequest {
|
|
105
|
+
readonly runId: SupervisedWorkflowRunId;
|
|
106
|
+
}
|
|
107
|
+
export interface WorkflowRunDetail {
|
|
108
|
+
readonly run: WorkflowRunHead;
|
|
109
|
+
readonly phases?: readonly WorkflowPhase[];
|
|
110
|
+
readonly gate?: WorkflowGateInfo;
|
|
111
|
+
readonly error?: string;
|
|
112
|
+
readonly scriptPath?: string;
|
|
113
|
+
}
|
|
114
|
+
export interface WorkflowRunMemberHead {
|
|
115
|
+
readonly memberId: WorkflowMemberId;
|
|
116
|
+
readonly seq: number;
|
|
117
|
+
readonly label: string;
|
|
118
|
+
readonly phase?: string;
|
|
119
|
+
readonly status: 'running' | 'completed' | 'failed' | 'cancelled';
|
|
120
|
+
readonly startedAt?: number;
|
|
121
|
+
readonly settledAt?: number;
|
|
122
|
+
readonly outcome: WorkflowRunOutcomeState;
|
|
123
|
+
readonly childSessionId?: string;
|
|
124
|
+
}
|
|
125
|
+
export interface WorkflowRunMemberPage {
|
|
126
|
+
readonly items: readonly WorkflowRunMemberHead[];
|
|
127
|
+
readonly nextCursor?: WorkflowRunCursor;
|
|
128
|
+
readonly total: number;
|
|
129
|
+
readonly revision: number;
|
|
130
|
+
}
|
|
131
|
+
export interface WorkflowRunMembersRequest extends WorkflowRunRequest {
|
|
132
|
+
readonly cursor?: WorkflowRunCursor;
|
|
133
|
+
readonly limit?: number;
|
|
134
|
+
}
|
|
135
|
+
export type WorkflowRunValueView = {
|
|
136
|
+
readonly state: 'pending' | 'not-produced' | 'evicted';
|
|
137
|
+
} | {
|
|
138
|
+
readonly state: 'available';
|
|
139
|
+
readonly content: {
|
|
140
|
+
readonly kind: 'value';
|
|
141
|
+
readonly value: JsonValue;
|
|
142
|
+
} | {
|
|
143
|
+
readonly kind: 'preview';
|
|
144
|
+
readonly text: string;
|
|
145
|
+
};
|
|
146
|
+
readonly totalBytes: number;
|
|
147
|
+
readonly truncated: boolean;
|
|
148
|
+
};
|
|
149
|
+
export interface WorkflowRunMemberDetail {
|
|
150
|
+
readonly member: WorkflowRunMemberHead;
|
|
151
|
+
readonly childSessionId?: string;
|
|
152
|
+
readonly outcome: WorkflowRunValueView;
|
|
153
|
+
}
|
|
154
|
+
export interface WorkflowRunMemberRequest extends WorkflowRunRequest {
|
|
155
|
+
readonly memberId: WorkflowMemberId;
|
|
156
|
+
}
|
|
157
|
+
export interface WorkflowRunLogLine {
|
|
158
|
+
readonly index: number;
|
|
159
|
+
readonly text: string;
|
|
160
|
+
}
|
|
161
|
+
export interface WorkflowRunLogPage {
|
|
162
|
+
readonly items: readonly WorkflowRunLogLine[];
|
|
163
|
+
readonly nextCursor?: WorkflowRunCursor;
|
|
164
|
+
readonly evicted: number;
|
|
165
|
+
readonly total: number;
|
|
166
|
+
readonly revision: number;
|
|
167
|
+
}
|
|
168
|
+
export interface WorkflowRunLogsRequest extends WorkflowRunRequest {
|
|
169
|
+
readonly cursor?: WorkflowRunCursor;
|
|
170
|
+
readonly limit?: number;
|
|
171
|
+
}
|
|
172
|
+
export interface WorkflowRunResultView {
|
|
173
|
+
readonly value: WorkflowRunValueView;
|
|
174
|
+
readonly error?: string;
|
|
175
|
+
readonly revision: number;
|
|
176
|
+
}
|
|
177
|
+
export interface WorkflowRunArtifactView {
|
|
178
|
+
readonly name: string;
|
|
179
|
+
readonly bytes: number;
|
|
180
|
+
}
|
|
181
|
+
export interface WorkflowRunArtifactChunk {
|
|
182
|
+
readonly artifact: WorkflowRunArtifactView;
|
|
183
|
+
readonly text: string;
|
|
184
|
+
readonly offsetBytes: number;
|
|
185
|
+
readonly returnedBytes: number;
|
|
186
|
+
readonly totalBytes: number;
|
|
187
|
+
readonly revision: number;
|
|
188
|
+
readonly nextCursor?: WorkflowRunCursor;
|
|
189
|
+
}
|
|
190
|
+
export interface WorkflowRunArtifactPage {
|
|
191
|
+
readonly items: readonly WorkflowRunArtifactView[];
|
|
192
|
+
readonly nextCursor?: WorkflowRunCursor;
|
|
193
|
+
readonly omitted: number;
|
|
194
|
+
readonly total: number;
|
|
195
|
+
readonly revision: number;
|
|
196
|
+
}
|
|
197
|
+
export interface WorkflowRunArtifactsRequest extends WorkflowRunRequest {
|
|
198
|
+
readonly cursor?: WorkflowRunCursor;
|
|
199
|
+
readonly limit?: number;
|
|
200
|
+
}
|
|
201
|
+
export interface WorkflowRunArtifactRequest extends WorkflowRunRequest {
|
|
202
|
+
readonly name: string;
|
|
203
|
+
readonly cursor?: WorkflowRunCursor;
|
|
204
|
+
readonly maxBytes?: number;
|
|
205
|
+
readonly expectedRevision?: number;
|
|
206
|
+
}
|
|
207
|
+
export interface WorkflowRunControlRequest extends WorkflowRunRequest {
|
|
208
|
+
readonly action: WorkflowRunAction;
|
|
209
|
+
readonly expectedRevision: number;
|
|
210
|
+
}
|
|
211
|
+
export interface WorkflowRunControlResult {
|
|
212
|
+
readonly run: WorkflowRunHead;
|
|
213
|
+
}
|
|
214
|
+
export type WorkflowRunChange = {
|
|
215
|
+
readonly kind: 'invalidate-all';
|
|
216
|
+
} | {
|
|
217
|
+
readonly kind: 'invalidate';
|
|
218
|
+
readonly sessionId: string;
|
|
219
|
+
readonly revision: number;
|
|
220
|
+
};
|
|
221
|
+
export type WorkflowRemoteFailureCode = 'invalid-page-limit' | 'invalid-artifact-limit' | 'invalid-cursor' | 'stale-cursor' | 'workspace-unavailable' | 'definition-invalid' | 'run-not-found' | 'member-not-found' | 'artifact-not-found' | 'artifact-changed' | 'revision-conflict' | 'action-unavailable' | 'storage-unavailable';
|
|
222
|
+
export type WorkflowRemoteFailure = {
|
|
223
|
+
readonly code: Exclude<WorkflowRemoteFailureCode, 'revision-conflict' | 'action-unavailable'>;
|
|
224
|
+
readonly message: string;
|
|
225
|
+
readonly details?: {
|
|
226
|
+
readonly min?: number;
|
|
227
|
+
readonly max?: number;
|
|
228
|
+
readonly revision?: number;
|
|
229
|
+
};
|
|
230
|
+
} | {
|
|
231
|
+
readonly code: 'revision-conflict';
|
|
232
|
+
readonly message: 'workflow run changed; refresh it before applying a control';
|
|
233
|
+
readonly details: {
|
|
234
|
+
readonly run: WorkflowRunHead;
|
|
235
|
+
};
|
|
236
|
+
} | {
|
|
237
|
+
readonly code: 'action-unavailable';
|
|
238
|
+
readonly message: string;
|
|
239
|
+
readonly details: {
|
|
240
|
+
readonly reason: 'budget-limited' | 'invalid-state' | 'save-ineligible';
|
|
241
|
+
readonly run?: WorkflowRunHead;
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
declare module '@deepseek-ai/cordis' {
|
|
245
|
+
interface Events {
|
|
246
|
+
'workflows/run-start'(info: SupervisedWorkflowRunInfo): void;
|
|
247
|
+
'workflows/member-start'(info: SupervisedWorkflowRunInfo, member: SupervisedWorkflowMemberLifecycleInfo): void;
|
|
248
|
+
'workflows/member-end'(info: SupervisedWorkflowRunInfo, member: SupervisedWorkflowMemberLifecycleInfo): void;
|
|
249
|
+
'workflows/run-end'(info: SupervisedWorkflowRunInfo, result: SupervisedWorkflowResultInfo): void;
|
|
250
|
+
'workflows/gate-request'(request: WorkflowGateRequest): void;
|
|
251
|
+
/**
|
|
252
|
+
* Invalidation-only workflow run hint. Never carries a run head.
|
|
253
|
+
* @mode emit
|
|
254
|
+
*/
|
|
255
|
+
'workflows/run-change'(change: WorkflowRunChange): void;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
259
|
+
interface TypertRemoteEventSelection {
|
|
260
|
+
'workflows/run-change': true;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
export type WorkflowRemoteResult<T> = {
|
|
264
|
+
readonly ok: true;
|
|
265
|
+
readonly value: T;
|
|
266
|
+
} | {
|
|
267
|
+
readonly ok: false;
|
|
268
|
+
readonly error: WorkflowRemoteFailure;
|
|
269
|
+
};
|
|
270
|
+
export interface WorkflowLaunched {
|
|
271
|
+
readonly displayName: string;
|
|
272
|
+
readonly runId: SupervisedWorkflowRunId;
|
|
273
|
+
readonly scriptPath?: string;
|
|
274
|
+
readonly status: 'started';
|
|
275
|
+
}
|
|
276
|
+
/** Success coverage sentence required by 6.5 / SH8; never a live-tool claim. */
|
|
277
|
+
export declare const VALIDATION_NOTE = "Validated one args-selected path with canned agent results; other branches, live tools, and live schema responses were not covered.";
|
|
278
|
+
export type WorkflowValidation = {
|
|
279
|
+
readonly ok: true;
|
|
280
|
+
readonly status: 'completed';
|
|
281
|
+
readonly value: JsonValue;
|
|
282
|
+
readonly note: typeof VALIDATION_NOTE;
|
|
283
|
+
} | {
|
|
284
|
+
readonly ok: true;
|
|
285
|
+
readonly status: 'would-pause';
|
|
286
|
+
readonly value: string;
|
|
287
|
+
readonly note: typeof VALIDATION_NOTE;
|
|
288
|
+
} | {
|
|
289
|
+
readonly ok: false;
|
|
290
|
+
readonly status: 'error';
|
|
291
|
+
readonly error: string;
|
|
292
|
+
readonly errorCode?: string;
|
|
293
|
+
};
|
|
294
|
+
export type WorkflowSaveScope = Extract<WorkflowScope, 'project' | 'user'>;
|
|
295
|
+
//# sourceMappingURL=types.d.ts.map
|