@inquir/compute 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +159 -1
- package/dist/app-observability.d.ts +69 -0
- package/dist/app-observability.d.ts.map +1 -0
- package/dist/app-observability.js +65 -0
- package/dist/app-observability.js.map +1 -0
- package/dist/app-observability.types.d.ts +358 -0
- package/dist/app-observability.types.d.ts.map +1 -0
- package/dist/app-observability.types.js +2 -0
- package/dist/app-observability.types.js.map +1 -0
- package/dist/apps.d.ts +304 -6
- package/dist/apps.d.ts.map +1 -1
- package/dist/apps.js +89 -7
- package/dist/apps.js.map +1 -1
- package/dist/build-timeout-policy.d.ts +13 -0
- package/dist/build-timeout-policy.d.ts.map +1 -0
- package/dist/build-timeout-policy.js +11 -0
- package/dist/build-timeout-policy.js.map +1 -0
- package/dist/discovery.d.ts +9 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +74 -7
- package/dist/discovery.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/invocation-observation.d.ts +23 -0
- package/dist/invocation-observation.d.ts.map +1 -0
- package/dist/invocation-observation.js +79 -0
- package/dist/invocation-observation.js.map +1 -0
- package/dist/local-runner-harness.js +28 -6
- package/dist/local-runner-harness.js.map +1 -1
- package/dist/local-runner.d.ts.map +1 -1
- package/dist/local-runner.js +103 -6
- package/dist/local-runner.js.map +1 -1
- package/dist/projects.d.ts +147 -0
- package/dist/projects.d.ts.map +1 -0
- package/dist/projects.js +64 -0
- package/dist/projects.js.map +1 -0
- package/dist/release-commands.d.ts +80 -0
- package/dist/release-commands.d.ts.map +1 -0
- package/dist/release-commands.js +147 -0
- package/dist/release-commands.js.map +1 -0
- package/dist/source-command-http.d.ts +7 -0
- package/dist/source-command-http.d.ts.map +1 -0
- package/dist/source-command-http.js +87 -0
- package/dist/source-command-http.js.map +1 -0
- package/dist/source-command-protocol.d.ts +137 -0
- package/dist/source-command-protocol.d.ts.map +1 -0
- package/dist/source-command-protocol.js +311 -0
- package/dist/source-command-protocol.js.map +1 -0
- package/dist/source-commands.d.ts +33 -0
- package/dist/source-commands.d.ts.map +1 -0
- package/dist/source-commands.js +116 -0
- package/dist/source-commands.js.map +1 -0
- package/dist/transport.d.ts +63 -2
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +237 -14
- package/dist/transport.js.map +1 -1
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -3
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
export class SourceCommandClientError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
uncertain;
|
|
5
|
+
constructor(code, message, uncertain, cause) {
|
|
6
|
+
super(message, { cause });
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.uncertain = uncertain;
|
|
9
|
+
this.name = 'SourceCommandClientError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const UUID = /^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/;
|
|
13
|
+
const DIGEST = /^[a-f0-9]{64}$/;
|
|
14
|
+
const STATES = ['PREPARING', 'CANCEL_REQUESTED', 'RESERVED', 'CREATE_INTENT', 'CREATED', 'START_INTENT', 'RUNNING', 'EXITED', 'CLEANUP_PENDING', 'REMOVED'];
|
|
15
|
+
const FAILURE_CODES = ['UNSAFE_PATH', 'UNSAFE_LINK', 'UNSUPPORTED_ENTRY', 'INVALID_METADATA', 'TREE_LIMIT_EXCEEDED'];
|
|
16
|
+
const LOG_FAILURE_CODES = ['LOG_LAYOUT_INVALID', 'LOG_RECORD_INVALID', 'LOG_RECORD_INCOMPLETE', 'LOG_LIMIT_EXCEEDED'];
|
|
17
|
+
function object(value) {
|
|
18
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
19
|
+
throw new Error('Expected object');
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
function exact(value, keys) {
|
|
23
|
+
if (Object.keys(value).some(key => !keys.includes(key)))
|
|
24
|
+
throw new Error('Unexpected field');
|
|
25
|
+
}
|
|
26
|
+
function identifier(value) {
|
|
27
|
+
if (typeof value !== 'string' || !value || value.length > 256
|
|
28
|
+
|| Array.from(value).some(character => character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127))
|
|
29
|
+
throw new Error('Invalid identifier');
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
function match(value, pattern) {
|
|
33
|
+
if (typeof value !== 'string' || !pattern.test(value))
|
|
34
|
+
throw new Error('Invalid identity');
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
function integer(value, minimum, maximum = Number.MAX_SAFE_INTEGER) {
|
|
38
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < minimum || value > maximum)
|
|
39
|
+
throw new Error('Invalid integer');
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
function parseRecord(value) {
|
|
43
|
+
try {
|
|
44
|
+
const record = object(value), scope = object(record.scope), input = object(record.input);
|
|
45
|
+
exact(record, ['version', 'scope', 'requestId', 'input', 'acceptedManifestDigest']);
|
|
46
|
+
exact(scope, ['tenantId', 'functionId']);
|
|
47
|
+
exact(input, ['command', 'timeoutMs', 'env']);
|
|
48
|
+
if (record.version !== 1 || typeof input.command !== 'string' || !input.command.trim() || input.command.includes('\0')
|
|
49
|
+
|| Buffer.byteLength(input.command) > 8192)
|
|
50
|
+
throw new Error('Invalid command');
|
|
51
|
+
const env = object(input.env ?? {});
|
|
52
|
+
if (Object.keys(env).length > 64 || Object.entries(env).some(([key, item]) => !/^[A-Za-z_][A-Za-z0-9_]{0,127}$/.test(key)
|
|
53
|
+
|| typeof item !== 'string' || item.length > 2048 || /[\0\r\n]/.test(item) || item.trim() !== item))
|
|
54
|
+
throw new Error('Invalid environment');
|
|
55
|
+
const parsed = { version: 1, scope: { tenantId: identifier(scope.tenantId), functionId: identifier(scope.functionId) },
|
|
56
|
+
requestId: match(record.requestId, UUID), input: { command: input.command, timeoutMs: integer(input.timeoutMs ?? 60_000, 1, 900_000),
|
|
57
|
+
env: Object.fromEntries(Object.entries(env).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) },
|
|
58
|
+
...(record.acceptedManifestDigest === undefined ? {} : { acceptedManifestDigest: match(record.acceptedManifestDigest, DIGEST) }) };
|
|
59
|
+
if (Buffer.byteLength(JSON.stringify({ version: 1, id: parsed.requestId, scope: parsed.scope, input: parsed.input })) > 12 * 1024)
|
|
60
|
+
throw new Error('Request exceeds bound');
|
|
61
|
+
return parsed;
|
|
62
|
+
}
|
|
63
|
+
catch (cause) {
|
|
64
|
+
throw new SourceCommandClientError('INVALID_RECORD', 'Invalid retained source command', false, cause);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function command(value, record) {
|
|
68
|
+
const parsed = object(value);
|
|
69
|
+
if (parsed.requestId !== record.requestId || parsed.functionId !== record.scope.functionId || parsed.kind !== 'EXEC_SOURCE')
|
|
70
|
+
throw new Error('Command identity mismatch');
|
|
71
|
+
return { requestId: record.requestId, functionId: record.scope.functionId, kind: 'EXEC_SOURCE' };
|
|
72
|
+
}
|
|
73
|
+
function publication(value, record) {
|
|
74
|
+
if (value === null)
|
|
75
|
+
return null;
|
|
76
|
+
const parsed = object(value);
|
|
77
|
+
if (parsed.id !== record.requestId || parsed.captureId !== record.requestId || !['APPLIED', 'CONFLICT'].includes(String(parsed.status)))
|
|
78
|
+
throw new Error('Publication identity mismatch');
|
|
79
|
+
const status = parsed.status;
|
|
80
|
+
const revision = status === 'APPLIED' ? match(parsed.revision, UUID) : null;
|
|
81
|
+
if (status === 'CONFLICT' && parsed.revision !== null)
|
|
82
|
+
throw new Error('Invalid conflict revision');
|
|
83
|
+
return { id: record.requestId, captureId: record.requestId, status, revision, outputDigest: match(parsed.outputDigest, DIGEST),
|
|
84
|
+
baseSnapshotDigest: match(parsed.baseSnapshotDigest, DIGEST), sizeBytes: integer(parsed.sizeBytes, 1, 512 * 1024 * 1024) };
|
|
85
|
+
}
|
|
86
|
+
function result(value) {
|
|
87
|
+
if (value === null)
|
|
88
|
+
return null;
|
|
89
|
+
const parsed = object(value);
|
|
90
|
+
if (typeof parsed.termination !== 'string' || !['EXITED', 'TIMEOUT', 'CANCELLED', 'HOST_REBOOT'].includes(parsed.termination) || parsed.outputSource !== 'nerdctl-json-file'
|
|
91
|
+
|| typeof parsed.truncated !== 'boolean' || typeof parsed.stdoutBase64 !== 'string' || typeof parsed.stderrBase64 !== 'string')
|
|
92
|
+
throw new Error('Invalid result');
|
|
93
|
+
const exitCode = parsed.exitCode === null ? null : integer(parsed.exitCode, 0, 255);
|
|
94
|
+
if (parsed.termination === 'EXITED' && exitCode === null)
|
|
95
|
+
throw new Error('Missing exited result code');
|
|
96
|
+
const outputLimit = 1024 * 1024;
|
|
97
|
+
let outputBytes = 0;
|
|
98
|
+
for (const encoded of [parsed.stdoutBase64, parsed.stderrBase64]) {
|
|
99
|
+
// Bound allocation before decoding as well as the combined decoded output.
|
|
100
|
+
if (encoded.length > 4 * Math.ceil(outputLimit / 3))
|
|
101
|
+
throw new Error('Result output exceeds bound');
|
|
102
|
+
const bytes = Buffer.from(encoded, 'base64');
|
|
103
|
+
outputBytes += bytes.length;
|
|
104
|
+
if (bytes.toString('base64') !== encoded || outputBytes > outputLimit)
|
|
105
|
+
throw new Error('Invalid result output encoding or size');
|
|
106
|
+
}
|
|
107
|
+
let workspaceOutput = null, workspaceFailure = null;
|
|
108
|
+
if (parsed.workspaceOutput != null) {
|
|
109
|
+
const output = object(parsed.workspaceOutput);
|
|
110
|
+
workspaceOutput = { baseSnapshotDigest: match(output.baseSnapshotDigest, DIGEST), snapshotDigest: match(output.snapshotDigest, DIGEST), sizeBytes: integer(output.sizeBytes, 1, 512 * 1024 * 1024) };
|
|
111
|
+
}
|
|
112
|
+
if (parsed.workspaceFailure != null) {
|
|
113
|
+
const failure = object(parsed.workspaceFailure);
|
|
114
|
+
if (!FAILURE_CODES.includes(String(failure.code)) || workspaceOutput)
|
|
115
|
+
throw new Error('Invalid workspace failure');
|
|
116
|
+
workspaceFailure = { baseSnapshotDigest: match(failure.baseSnapshotDigest, DIGEST), code: failure.code };
|
|
117
|
+
}
|
|
118
|
+
let logFailure;
|
|
119
|
+
if (Object.hasOwn(parsed, 'logFailure')) {
|
|
120
|
+
exact(parsed, ['attemptId', 'manifestDigest', 'termination', 'exitCode', 'durationMs', 'stdoutBase64', 'stderrBase64',
|
|
121
|
+
'truncated', 'outputSource', 'workspaceOutput', 'workspaceFailure', 'logFailure']);
|
|
122
|
+
const failure = object(parsed.logFailure);
|
|
123
|
+
exact(failure, ['code']);
|
|
124
|
+
if (typeof failure.code !== 'string' || !LOG_FAILURE_CODES.includes(failure.code) || parsed.workspaceOutput !== null || parsed.workspaceFailure !== null
|
|
125
|
+
|| parsed.stdoutBase64 !== '' || parsed.stderrBase64 !== '' || parsed.truncated !== true)
|
|
126
|
+
throw new Error('Invalid log capture failure');
|
|
127
|
+
logFailure = { code: failure.code };
|
|
128
|
+
}
|
|
129
|
+
return { attemptId: match(parsed.attemptId, UUID), manifestDigest: match(parsed.manifestDigest, DIGEST),
|
|
130
|
+
termination: parsed.termination, exitCode,
|
|
131
|
+
durationMs: integer(parsed.durationMs, 0), stdoutBase64: parsed.stdoutBase64, stderrBase64: parsed.stderrBase64,
|
|
132
|
+
truncated: parsed.truncated, outputSource: 'nerdctl-json-file', workspaceOutput, workspaceFailure,
|
|
133
|
+
...(logFailure ? { logFailure } : {}) };
|
|
134
|
+
}
|
|
135
|
+
function outcome(value, record, readOnly) {
|
|
136
|
+
const parsed = object(value), meta = object(parsed.command), identity = command(meta, record);
|
|
137
|
+
if (!STATES.includes(String(meta.state)) || typeof meta.cancelled !== 'boolean')
|
|
138
|
+
throw new Error('Invalid command state');
|
|
139
|
+
const output = result(parsed.result), receipt = publication(parsed.publication, record);
|
|
140
|
+
let binding = null;
|
|
141
|
+
if (parsed.publicationBinding != null) {
|
|
142
|
+
const candidate = object(parsed.publicationBinding);
|
|
143
|
+
exact(candidate, ['tenantId', 'functionId', 'requestId', 'manifestDigest', 'baseSnapshotDigest']);
|
|
144
|
+
if (!receipt || candidate.tenantId !== record.scope.tenantId || candidate.functionId !== record.scope.functionId
|
|
145
|
+
|| candidate.requestId !== record.requestId || candidate.baseSnapshotDigest !== receipt.baseSnapshotDigest)
|
|
146
|
+
throw new Error('Publication binding mismatch');
|
|
147
|
+
binding = { tenantId: record.scope.tenantId, functionId: record.scope.functionId, requestId: record.requestId,
|
|
148
|
+
manifestDigest: match(candidate.manifestDigest, DIGEST), baseSnapshotDigest: match(candidate.baseSnapshotDigest, DIGEST) };
|
|
149
|
+
if (output && binding.manifestDigest !== output.manifestDigest)
|
|
150
|
+
throw new Error('Publication manifest mismatch');
|
|
151
|
+
}
|
|
152
|
+
if (readOnly && (receipt || parsed.publicationBinding !== undefined) || receipt && (meta.state !== 'REMOVED'
|
|
153
|
+
|| !output && !binding || parsed.publicationBinding !== undefined && !binding
|
|
154
|
+
|| output && (!output.workspaceOutput || receipt.outputDigest !== output.workspaceOutput.snapshotDigest
|
|
155
|
+
|| receipt.baseSnapshotDigest !== output.workspaceOutput.baseSnapshotDigest || receipt.sizeBytes !== output.workspaceOutput.sizeBytes)
|
|
156
|
+
|| meta.cancelled && receipt.status === 'APPLIED'))
|
|
157
|
+
throw new Error('Invalid publication outcome');
|
|
158
|
+
if (output || binding)
|
|
159
|
+
bindManifest(record, output?.manifestDigest ?? binding.manifestDigest);
|
|
160
|
+
return { command: { ...identity, state: meta.state, cancelled: meta.cancelled }, result: output, publication: receipt,
|
|
161
|
+
...(parsed.publicationBinding === undefined ? {} : { publicationBinding: binding }) };
|
|
162
|
+
}
|
|
163
|
+
function bindManifest(record, digest) {
|
|
164
|
+
if (record.acceptedManifestDigest !== undefined && record.acceptedManifestDigest !== digest)
|
|
165
|
+
throw new Error('Accepted manifest changed');
|
|
166
|
+
record.acceptedManifestDigest = digest;
|
|
167
|
+
}
|
|
168
|
+
/** Execution and publication are separate: a nonzero exit alone does not describe source publication. */
|
|
169
|
+
export function sourcePublicationState(value) {
|
|
170
|
+
return value.result?.logFailure ? 'CAPTURE_FAILED' : value.publication?.status ?? (value.result?.workspaceFailure ? 'OUTPUT_FAILED' : 'NOT_PUBLISHED');
|
|
171
|
+
}
|
|
172
|
+
function operation(record, transport, retainAcceptance) {
|
|
173
|
+
const base = `/functions/${encodeURIComponent(record.scope.functionId)}/source-commands`, url = `${base}/${record.requestId}`;
|
|
174
|
+
let pending = false, retainedDigest = record.acceptedManifestDigest, tail = Promise.resolve();
|
|
175
|
+
const persist = async () => {
|
|
176
|
+
if (!pending)
|
|
177
|
+
return;
|
|
178
|
+
try {
|
|
179
|
+
await retainAcceptance?.(structuredClone(record));
|
|
180
|
+
}
|
|
181
|
+
catch (cause) {
|
|
182
|
+
throw new SourceCommandClientError('RETENTION', 'Accepted source identity could not be retained; persist it before another request', true, cause);
|
|
183
|
+
}
|
|
184
|
+
retainedDigest = record.acceptedManifestDigest;
|
|
185
|
+
pending = false;
|
|
186
|
+
};
|
|
187
|
+
const serialized = (work) => {
|
|
188
|
+
const result = tail.then(work);
|
|
189
|
+
tail = result.then(() => undefined, () => undefined);
|
|
190
|
+
return result;
|
|
191
|
+
};
|
|
192
|
+
const call = (path, init, decode) => {
|
|
193
|
+
const queued = serialized(async () => {
|
|
194
|
+
init.signal?.throwIfAborted();
|
|
195
|
+
await persist();
|
|
196
|
+
init.signal?.throwIfAborted();
|
|
197
|
+
let response;
|
|
198
|
+
try {
|
|
199
|
+
init.signal?.throwIfAborted();
|
|
200
|
+
const pending = transport(structuredClone(record.scope), path, init);
|
|
201
|
+
// Even an adapter that cannot abort its HTTP request must let the caller
|
|
202
|
+
// stop waiting. Its eventual reply never triggers another action here.
|
|
203
|
+
response = !init.signal ? await pending : await new Promise((resolve, reject) => {
|
|
204
|
+
const signal = init.signal;
|
|
205
|
+
const abort = () => { signal.removeEventListener('abort', abort); reject(signal.reason); };
|
|
206
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
207
|
+
pending.then(value => { signal.removeEventListener('abort', abort); resolve(value); }, error => { signal.removeEventListener('abort', abort); reject(error); });
|
|
208
|
+
if (signal.aborted)
|
|
209
|
+
abort();
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
catch (cause) {
|
|
213
|
+
const status = cause && typeof cause === 'object' && 'status' in cause ? Number(cause.status) : 0;
|
|
214
|
+
if (status === 409)
|
|
215
|
+
throw new SourceCommandClientError('CONFLICT', 'Request ID or source revision conflict; inspect this operation', false, cause);
|
|
216
|
+
if (status >= 400 && status < 500)
|
|
217
|
+
throw new SourceCommandClientError('REJECTED', 'Source command request rejected', false, cause);
|
|
218
|
+
throw new SourceCommandClientError('UNCERTAIN', 'Reply unavailable; retain this request ID and inspect or retry the same action', true, cause);
|
|
219
|
+
}
|
|
220
|
+
let decoded;
|
|
221
|
+
try {
|
|
222
|
+
decoded = decode(response);
|
|
223
|
+
}
|
|
224
|
+
catch (cause) {
|
|
225
|
+
throw new SourceCommandClientError('PROTOCOL', 'Invalid source command response; retain this request ID', true, cause);
|
|
226
|
+
}
|
|
227
|
+
if (record.acceptedManifestDigest !== retainedDigest) {
|
|
228
|
+
pending = true;
|
|
229
|
+
await persist();
|
|
230
|
+
}
|
|
231
|
+
return decoded;
|
|
232
|
+
});
|
|
233
|
+
// Ending observation must not wait for an earlier HTTP/storage operation.
|
|
234
|
+
// The queued transaction still checks this signal before any later dispatch.
|
|
235
|
+
if (!init.signal)
|
|
236
|
+
return queued;
|
|
237
|
+
return new Promise((resolve, reject) => {
|
|
238
|
+
const signal = init.signal, abort = () => { signal.removeEventListener('abort', abort); reject(new SourceCommandClientError('UNCERTAIN', 'Observation stopped; retain this request ID', true, signal.reason)); };
|
|
239
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
240
|
+
queued.then(value => { signal.removeEventListener('abort', abort); resolve(value); }, error => { signal.removeEventListener('abort', abort); reject(error); });
|
|
241
|
+
if (signal.aborted)
|
|
242
|
+
abort();
|
|
243
|
+
});
|
|
244
|
+
};
|
|
245
|
+
const post = (signal, body = {}) => ({ method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body), signal });
|
|
246
|
+
const status = (signal) => call(url, { method: 'GET', signal }, value => outcome(value, record, true));
|
|
247
|
+
return {
|
|
248
|
+
record: () => structuredClone(record),
|
|
249
|
+
persist: () => serialized(persist),
|
|
250
|
+
submit: signal => call(base, post(signal, { requestId: record.requestId, ...record.input }), value => {
|
|
251
|
+
const meta = object(object(value).command), identity = command(meta, record);
|
|
252
|
+
if (!STATES.includes(String(meta.state)) || typeof meta.cancelled !== 'boolean')
|
|
253
|
+
throw new Error('Invalid assignment');
|
|
254
|
+
const attemptId = match(meta.attemptId, UUID), manifestDigest = match(meta.manifestDigest, DIGEST);
|
|
255
|
+
bindManifest(record, manifestDigest);
|
|
256
|
+
return { command: { ...identity, state: meta.state, cancelled: meta.cancelled,
|
|
257
|
+
attemptId, manifestDigest } };
|
|
258
|
+
}),
|
|
259
|
+
status,
|
|
260
|
+
reconcile: signal => call(`${url}/reconcile`, post(signal), value => outcome(value, record, false)),
|
|
261
|
+
cancel: signal => call(`${url}/cancel`, post(signal), value => {
|
|
262
|
+
const parsed = object(value), identity = command(parsed.command, record), receipt = publication(parsed.publication, record);
|
|
263
|
+
if (parsed.state === 'PUBLICATION_COMMITTED' ? receipt?.status !== 'APPLIED'
|
|
264
|
+
: parsed.state !== 'CANCEL_REQUESTED' || receipt?.status === 'APPLIED')
|
|
265
|
+
throw new Error('Invalid cancellation outcome');
|
|
266
|
+
return { command: identity, state: parsed.state, publication: receipt };
|
|
267
|
+
}),
|
|
268
|
+
async poll(options = {}) {
|
|
269
|
+
const timeout = integer(options.maxWaitMs ?? 60_000, 1, 900_000), interval = integer(options.intervalMs ?? 1000, 1, 60_000);
|
|
270
|
+
const signal = AbortSignal.any([AbortSignal.timeout(timeout), ...(options.signal ? [options.signal] : [])]);
|
|
271
|
+
try {
|
|
272
|
+
for (;;) {
|
|
273
|
+
signal.throwIfAborted();
|
|
274
|
+
const observed = await status(signal);
|
|
275
|
+
signal.throwIfAborted();
|
|
276
|
+
// CANCEL_REQUESTED without an observable attempt is durable intent,
|
|
277
|
+
// not a removal/capacity receipt. Return it without claiming quiescence.
|
|
278
|
+
if (observed.command.state === 'REMOVED' || observed.command.state === 'CANCEL_REQUESTED')
|
|
279
|
+
return observed;
|
|
280
|
+
await new Promise((resolve, reject) => {
|
|
281
|
+
const abort = () => { clearTimeout(timer); signal.removeEventListener('abort', abort); reject(signal.reason); };
|
|
282
|
+
const timer = setTimeout(() => { signal.removeEventListener('abort', abort); resolve(); }, interval);
|
|
283
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
284
|
+
if (signal.aborted)
|
|
285
|
+
abort();
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
catch (cause) {
|
|
290
|
+
if (signal.aborted)
|
|
291
|
+
throw new SourceCommandClientError('WAIT_ENDED', 'Observation stopped; this does not cancel the command', true, cause);
|
|
292
|
+
throw cause;
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
/** Retain must durably store the record (including secrets securely) before any HTTP call. */
|
|
298
|
+
export async function prepareSourceCommand(options) {
|
|
299
|
+
const record = parseRecord({ version: 1, scope: options.scope, requestId: options.requestId ?? randomUUID(), input: options.input });
|
|
300
|
+
await options.retain(structuredClone(record));
|
|
301
|
+
return operation(record, options.transport, options.retainAcceptance);
|
|
302
|
+
}
|
|
303
|
+
/** Restoring an operation never submits it; callers explicitly choose observe/retry/reconcile/cancel. */
|
|
304
|
+
export function restoreSourceCommand(value, options) {
|
|
305
|
+
const record = parseRecord(value);
|
|
306
|
+
if (record.scope.tenantId !== options.scope.tenantId || record.scope.functionId !== options.scope.functionId) {
|
|
307
|
+
throw new SourceCommandClientError('INVALID_RECORD', 'Retained source command belongs to another scope', false);
|
|
308
|
+
}
|
|
309
|
+
return operation(record, options.transport, options.retainAcceptance);
|
|
310
|
+
}
|
|
311
|
+
//# sourceMappingURL=source-command-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-command-protocol.js","sourceRoot":"","sources":["../src/source-command-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAsDzC,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACrB;IACO;IADnC,YAA4B,IAAwG,EAClI,OAAe,EAAkB,SAAkB,EAAE,KAAe;QACpE,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAFA,SAAI,GAAJ,IAAI,CAAoG;QACjG,cAAS,GAAT,SAAS,CAAS;QACxB,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACpE,CAAC;CACF;AACD,MAAM,IAAI,GAAG,uEAAuE,CAAC;AACrF,MAAM,MAAM,GAAG,gBAAgB,CAAC;AAChC,MAAM,MAAM,GAAsB,CAAC,WAAW,EAAE,kBAAkB,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,SAAS,CAAC,CAAC;AAC/K,MAAM,aAAa,GAAsB,CAAC,aAAa,EAAE,aAAa,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,qBAAqB,CAAC,CAAC;AACxI,MAAM,iBAAiB,GAAsB,CAAC,oBAAoB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,oBAAoB,CAAC,CAAC;AACzI,SAAS,MAAM,CAAC,KAAc;IAC5B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;Q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AAO,CAAC,SAAS,EAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACvE,CAAC;AACD,yGAAyG;AACzG,MAAM,UAAU,oBAAoB,CAAC,KAAc,EAAE,OAAsI;IACzL,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IAClC,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,KAAK,OAAO,CAAC,KAAK,CAAC,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,UAAU,KAAK,OAAO,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QAC7G,MAAM,IAAI,wBAAwB,CAAC,gBAAgB,EAAE,kDAAkD,EAAE,KAAK,CAAC,CAAC;IAClH,CAAC;IACD,OAAO,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,EAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type TransportClient } from './transport.js';
|
|
2
|
+
import { type SourceCommandRecord as ProtocolRecord, type SourceCommandOperation as ProtocolOperation, type SourceCommandInput } from './source-command-protocol.js';
|
|
3
|
+
export { SourceCommandClientError, sourcePublicationState, prepareSourceCommand as prepareSourceCommandProtocol, restoreSourceCommand as restoreSourceCommandProtocol } from './source-command-protocol.js';
|
|
4
|
+
export type { SourceCommandScope, SourceCommandInput, SourceCommandState, SourceCommandResult, SourceCommandOutcome, SourceCommandCancellation, SourceCommandPublication, SourceCommandPublicationBinding, SourceWorkspaceOutput, SourceWorkspaceFailure, SourceLogFailure, SourceCommandTransport, SourceCommandRecord as SourceCommandProtocolRecord, SourceCommandOperation as SourceCommandProtocolOperation } from './source-command-protocol.js';
|
|
5
|
+
export interface SourceCommandRecord extends ProtocolRecord {
|
|
6
|
+
apiUrl: string;
|
|
7
|
+
/** Raw secret hash; credentials themselves are never stored in the record. */
|
|
8
|
+
credentialHash: string;
|
|
9
|
+
/** Original selector. Actions use the resolved immutable scope.tenantId. */
|
|
10
|
+
selector: string | null;
|
|
11
|
+
}
|
|
12
|
+
export interface SourceCommandOperation extends Omit<ProtocolOperation, 'record'> {
|
|
13
|
+
record(): SourceCommandRecord;
|
|
14
|
+
}
|
|
15
|
+
export type SourceCommandRetain = (record: SourceCommandRecord) => Promise<void>;
|
|
16
|
+
/** Securely persist every supplied record, atomically binding UUID to its input.
|
|
17
|
+
* This prepares only; caller explicitly invokes submit. The callback also persists
|
|
18
|
+
* learned acceptance before an action/poll can return or issue another request.
|
|
19
|
+
*/
|
|
20
|
+
export declare function prepareSourceCommand(client: TransportClient, options: {
|
|
21
|
+
function: string;
|
|
22
|
+
requestId: string;
|
|
23
|
+
input: SourceCommandInput;
|
|
24
|
+
retain: SourceCommandRetain;
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
}): Promise<SourceCommandOperation>;
|
|
27
|
+
/** No discovery or submission. The current selector/context must match the record;
|
|
28
|
+
* all subsequent actions use its retained resolved workspace and function IDs.
|
|
29
|
+
*/
|
|
30
|
+
export declare function restoreSourceCommand(client: TransportClient, value: unknown, options: {
|
|
31
|
+
retain: SourceCommandRetain;
|
|
32
|
+
}): Promise<SourceCommandOperation>;
|
|
33
|
+
//# sourceMappingURL=source-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-commands.d.ts","sourceRoot":"","sources":["../src/source-commands.ts"],"names":[],"mappings":"AACA,OAAO,EAA+D,KAAK,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAElH,OAAO,EACL,KAAK,mBAAmB,IAAI,cAAc,EAAC,KAAK,sBAAsB,IAAI,iBAAiB,EAAC,KAAK,kBAAkB,EAAC,MAAM,8BAA8B,CAAC;AAC3J,OAAO,EAAC,wBAAwB,EAAC,sBAAsB,EACrD,oBAAoB,IAAI,4BAA4B,EAAC,oBAAoB,IAAI,4BAA4B,EAAC,MAAM,8BAA8B,CAAC;AACjJ,YAAY,EAAC,kBAAkB,EAAC,kBAAkB,EAAC,kBAAkB,EAAC,mBAAmB,EAAC,oBAAoB,EAC5G,yBAAyB,EAAC,wBAAwB,EAAC,+BAA+B,EAAC,qBAAqB,EAAC,sBAAsB,EAAC,gBAAgB,EAChJ,sBAAsB,EAAC,mBAAmB,IAAI,2BAA2B,EAAC,sBAAsB,IAAI,8BAA8B,EAAC,MAAM,8BAA8B,CAAC;AAE1K,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IACzD,MAAM,EAAC,MAAM,CAAC;IACd,8EAA8E;IAC9E,cAAc,EAAC,MAAM,CAAC;IACtB,4EAA4E;IAC5E,QAAQ,EAAC,MAAM,GAAC,IAAI,CAAC;CACtB;AACD,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAAC,iBAAiB,EAAC,QAAQ,CAAC;IAAE,MAAM,IAAG,mBAAmB,CAAA;CAAC;AAC/G,MAAM,MAAM,mBAAmB,GAAC,CAAC,MAAM,EAAC,mBAAmB,KAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAkD5E;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAC,eAAe,EAAC,OAAO,EAAC;IAAC,QAAQ,EAAC,MAAM,CAAC;IAAA,SAAS,EAAC,MAAM,CAAC;IAAA,KAAK,EAAC,kBAAkB,CAAC;IACnI,MAAM,EAAC,mBAAmB,CAAC;IAAA,MAAM,CAAC,EAAC,WAAW,CAAA;CAAC,GAAE,OAAO,CAAC,sBAAsB,CAAC,CAqBjF;AACD;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAC,eAAe,EAAC,KAAK,EAAC,OAAO,EAAC,OAAO,EAAC;IAAC,MAAM,EAAC,mBAAmB,CAAA;CAAC,GAAE,OAAO,CAAC,sBAAsB,CAAC,CAOpJ"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { createClient, authHeaders, getMe, listRemoteFunctions, toApiError } from './transport.js';
|
|
3
|
+
import { boundedSourceCommandFetch } from './source-command-http.js';
|
|
4
|
+
import { prepareSourceCommand as prepareProtocol, restoreSourceCommand as restoreProtocol, SourceCommandClientError } from './source-command-protocol.js';
|
|
5
|
+
export { SourceCommandClientError, sourcePublicationState, prepareSourceCommand as prepareSourceCommandProtocol, restoreSourceCommand as restoreSourceCommandProtocol } from './source-command-protocol.js';
|
|
6
|
+
function identifier(value) {
|
|
7
|
+
if (typeof value !== 'string' || !value.trim() || value.length > 256 || /[\x00-\x1f\x7f]/.test(value))
|
|
8
|
+
throw new SourceCommandClientError('INVALID_RECORD', 'Invalid source command scope', false);
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
function context(source) {
|
|
12
|
+
let api;
|
|
13
|
+
try {
|
|
14
|
+
api = new URL(source.baseUrl);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
throw new SourceCommandClientError('INVALID_RECORD', 'Invalid source command API URL', false);
|
|
18
|
+
}
|
|
19
|
+
if (!['http:', 'https:'].includes(api.protocol) || api.username || api.password || api.search || api.hash || source.baseUrl.length > 2048
|
|
20
|
+
|| !source.apiKey)
|
|
21
|
+
throw new SourceCommandClientError('INVALID_RECORD', 'Source commands require a plain HTTP(S) API and credential', false);
|
|
22
|
+
const apiUrl = api.toString().replace(/\/+$/, ''), credentialHash = createHash('sha256').update(source.apiKey, 'utf8').digest('hex');
|
|
23
|
+
const selector = source.workspaceId === undefined ? null : identifier(source.workspaceId);
|
|
24
|
+
return { apiUrl, credentialHash, selector, client: createClient({ baseUrl: apiUrl, apiKey: source.apiKey, workspaceId: selector ?? undefined,
|
|
25
|
+
fetchImpl: boundedSourceCommandFetch(source.fetchImpl) }) };
|
|
26
|
+
}
|
|
27
|
+
function retainedContext(value, current) {
|
|
28
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
29
|
+
throw new SourceCommandClientError('INVALID_RECORD', 'Invalid retained source command', false);
|
|
30
|
+
const record = value;
|
|
31
|
+
const allowed = ['version', 'apiUrl', 'credentialHash', 'selector', 'scope', 'requestId', 'input', 'acceptedManifestDigest'];
|
|
32
|
+
if (Object.keys(record).some(key => !allowed.includes(key)) || record.apiUrl !== current.apiUrl || record.credentialHash !== current.credentialHash
|
|
33
|
+
|| record.selector !== current.selector)
|
|
34
|
+
throw new SourceCommandClientError('INVALID_RECORD', 'Retained source command belongs to a different API, credential or workspace selector', false);
|
|
35
|
+
const input = record.input;
|
|
36
|
+
if (!input || typeof input !== 'object' || Array.isArray(input) || Object.keys(input).sort().join(',') !== 'command,env,timeoutMs'
|
|
37
|
+
|| typeof input.timeoutMs !== 'number' || !input.env || typeof input.env !== 'object' || Array.isArray(input.env)) {
|
|
38
|
+
throw new SourceCommandClientError('INVALID_RECORD', 'Retained source command must contain exact normalized input', false);
|
|
39
|
+
}
|
|
40
|
+
const { apiUrl: _, credentialHash: __, selector: ___, ...protocol } = record;
|
|
41
|
+
return { record: structuredClone(protocol), binding: { apiUrl: current.apiUrl, credentialHash: current.credentialHash, selector: current.selector } };
|
|
42
|
+
}
|
|
43
|
+
function bound(current, scope) {
|
|
44
|
+
const client = createClient({ baseUrl: current.apiUrl, apiKey: current.client.apiKey, workspaceId: scope.tenantId, fetchImpl: current.client.fetchImpl });
|
|
45
|
+
return async (received, pathname, init) => {
|
|
46
|
+
if (received.tenantId !== scope.tenantId || received.functionId !== scope.functionId)
|
|
47
|
+
throw new Error('Source command scope changed');
|
|
48
|
+
const headers = new Headers(init.headers);
|
|
49
|
+
for (const [name, value] of Object.entries(authHeaders(client)))
|
|
50
|
+
headers.set(name, value);
|
|
51
|
+
const response = await client.fetchImpl(`${client.baseUrl}${pathname}`, { ...init, headers, redirect: 'error' });
|
|
52
|
+
const text = await response.text();
|
|
53
|
+
let payload;
|
|
54
|
+
try {
|
|
55
|
+
payload = text ? JSON.parse(text) : undefined;
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
payload = undefined;
|
|
59
|
+
}
|
|
60
|
+
if (!response.ok)
|
|
61
|
+
throw toApiError(response, payload);
|
|
62
|
+
return payload;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function envelope(record, current) {
|
|
66
|
+
// Property order matches the shared SDK record contract; never share caller references.
|
|
67
|
+
return { version: 1, apiUrl: current.apiUrl, credentialHash: current.credentialHash, selector: current.selector, scope: structuredClone(record.scope),
|
|
68
|
+
requestId: record.requestId, input: structuredClone(record.input), ...(record.acceptedManifestDigest ? { acceptedManifestDigest: record.acceptedManifestDigest } : {}) };
|
|
69
|
+
}
|
|
70
|
+
function wrapped(protocol, current) {
|
|
71
|
+
return { ...protocol, record: () => envelope(protocol.record(), current) };
|
|
72
|
+
}
|
|
73
|
+
/** Securely persist every supplied record, atomically binding UUID to its input.
|
|
74
|
+
* This prepares only; caller explicitly invokes submit. The callback also persists
|
|
75
|
+
* learned acceptance before an action/poll can return or issue another request.
|
|
76
|
+
*/
|
|
77
|
+
export async function prepareSourceCommand(client, options) {
|
|
78
|
+
if (typeof options.retain !== 'function')
|
|
79
|
+
throw new SourceCommandClientError('INVALID_RECORD', 'A durable retain callback is required', false);
|
|
80
|
+
if (typeof options.requestId !== 'string' || !/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/.test(options.requestId))
|
|
81
|
+
throw new SourceCommandClientError('INVALID_RECORD', 'A caller-retained lowercase UUID is required', false);
|
|
82
|
+
const retainCallback = options.retain, functionRef = identifier(options.function), current = context(client), signal = options.signal;
|
|
83
|
+
// Validate bounded input before discovery, without any dispatch.
|
|
84
|
+
const candidate = await prepareProtocol({ scope: { tenantId: 'unresolved', functionId: 'unresolved' }, requestId: options.requestId, input: options.input,
|
|
85
|
+
retain: async () => undefined, transport: async () => { throw new Error('Validation cannot dispatch'); } });
|
|
86
|
+
signal?.throwIfAborted();
|
|
87
|
+
const discovery = createClient({ ...current.client, fetchImpl: (input, init) => current.client.fetchImpl(input, { ...init, signal }) });
|
|
88
|
+
const me = await getMe(discovery), tenantId = identifier(me.activeWorkspace?.id);
|
|
89
|
+
signal?.throwIfAborted();
|
|
90
|
+
const pinned = createClient({ ...discovery, workspaceId: tenantId });
|
|
91
|
+
const functions = await listRemoteFunctions(pinned);
|
|
92
|
+
const named = functions.find(item => item.id === functionRef) ?? functions.find(item => item.name === functionRef);
|
|
93
|
+
const linked = named ? [] : functions.filter(item => item.linkedLocalName === functionRef);
|
|
94
|
+
const fn = named ?? (linked.length === 1 ? linked[0] : undefined);
|
|
95
|
+
if (!fn)
|
|
96
|
+
throw new SourceCommandClientError('INVALID_RECORD', 'Source function resolution is absent or ambiguous', false);
|
|
97
|
+
signal?.throwIfAborted();
|
|
98
|
+
const scope = { tenantId, functionId: identifier(fn.id) };
|
|
99
|
+
const retain = (record) => retainCallback(envelope(record, current));
|
|
100
|
+
const operation = await prepareProtocol({ scope, requestId: candidate.record().requestId, input: candidate.record().input, retain, retainAcceptance: retain, transport: bound(current, scope) });
|
|
101
|
+
return wrapped(operation, current);
|
|
102
|
+
}
|
|
103
|
+
/** No discovery or submission. The current selector/context must match the record;
|
|
104
|
+
* all subsequent actions use its retained resolved workspace and function IDs.
|
|
105
|
+
*/
|
|
106
|
+
export async function restoreSourceCommand(client, value, options) {
|
|
107
|
+
if (typeof options.retain !== 'function')
|
|
108
|
+
throw new SourceCommandClientError('INVALID_RECORD', 'A durable retain callback is required', false);
|
|
109
|
+
const retainCallback = options.retain;
|
|
110
|
+
const current = context(client), retained = retainedContext(value, current);
|
|
111
|
+
const retain = (record) => retainCallback(envelope(record, retained.binding));
|
|
112
|
+
const operation = restoreProtocol(retained.record, { scope: retained.record.scope, transport: bound(current, retained.record.scope), retainAcceptance: retain });
|
|
113
|
+
await retain(operation.record());
|
|
114
|
+
return wrapped(operation, retained.binding);
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=source-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-commands.js","sourceRoot":"","sources":["../src/source-commands.ts"],"names":[],"mappings":"A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AAK,CAAC,CAAC;IAC1I,MAAM,cAAc,GAAC,OAAO,CAAC,MAAM,CAAC;IACpC,MAAM,OAAO,GAAC,OAAO,CAAC,MAAM,CAAC,EAAC,QAAQ,GAAC,eAAe,CAAC,KAAK,EAAC,OAAO,CAAC,CAAC;IACtE,MAAM,MAAM,GAAC,CAAC,MAAqB,EAAC,EAAE,CAAA,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IACxF,MAAM,SAAS,GAAC,eAAe,CAAC,QAAQ,CAAC,MAAM,EAAC,EAAC,KAAK,EAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAC,SAAS,EAAC,KAAK,CAAC,OAAO,EAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,EAAC,gBAAgB,EAAC,MAAM,EAAC,CAAC,CAAC;IACtJ,MAAM,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IAAA,OAAO,OAAO,CAAC,SAAS,EAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAC9E,CAAC"}
|
package/dist/transport.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PendingRemoteInvocation } from './invocation-observation.js';
|
|
1
2
|
import type { RemoteFunctionRecord, RemoteInvocationRecord, RemoteInvocationResult } from './types.js';
|
|
2
3
|
export interface TransportClientOptions {
|
|
3
4
|
baseUrl: string;
|
|
@@ -13,6 +14,10 @@ export interface TransportClientOptions {
|
|
|
13
14
|
}
|
|
14
15
|
export interface InvokeRemoteOptions {
|
|
15
16
|
context?: Record<string, unknown>;
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
timeoutMs?: number;
|
|
19
|
+
intervalMs?: number;
|
|
20
|
+
onPending?: (pending: PendingRemoteInvocation) => void;
|
|
16
21
|
}
|
|
17
22
|
export interface CreateRemoteFunctionInput {
|
|
18
23
|
name: string;
|
|
@@ -164,14 +169,66 @@ export declare function toApiError(response: Response, payload: unknown, fallbac
|
|
|
164
169
|
* Same auth, error mapping, and JSON handling as every typed helper above.
|
|
165
170
|
*/
|
|
166
171
|
export declare function rawRequest<TResponse>(client: TransportClient, method: string, pathname: string, body?: unknown): Promise<TResponse>;
|
|
172
|
+
/**
|
|
173
|
+
* List the functions visible to the credential, walking `limit`/`offset` pages
|
|
174
|
+
* until the server runs out of rows.
|
|
175
|
+
*
|
|
176
|
+
* What the result guarantees: it is complete, or this throws. The scan compares
|
|
177
|
+
* the rows it collected against the `total` the server reported and refuses to
|
|
178
|
+
* return a list it can tell is short, so a `find()` by name over the result
|
|
179
|
+
* cannot report an existing function as missing and turn an update into a
|
|
180
|
+
* create (which the server rejects with 409 "name already exists"). That covers
|
|
181
|
+
* the page cap, a server that ignores `offset`, a create burst that slides the
|
|
182
|
+
* paging window backwards over rows already read, and a single create landing
|
|
183
|
+
* behind the read cursor.
|
|
184
|
+
*
|
|
185
|
+
* What it cannot guarantee: the server sorts with `ORDER BY createdAt DESC` and
|
|
186
|
+
* no unique tiebreaker (functions-prisma-repository.ts `list()`), and
|
|
187
|
+
* `createdAt` defaults to now(), so rows written in one batch tie. LIMIT/OFFSET
|
|
188
|
+
* over a non-unique sort is not stable, and rows are deleted concurrently. Two
|
|
189
|
+
* consequences:
|
|
190
|
+
* - Tied rows straddling a page boundary can come back in a different order for
|
|
191
|
+
* the offset=0 and offset=N queries: one row is returned twice (deduped
|
|
192
|
+
* above) and its twin never is. That leaves the scan one row short of
|
|
193
|
+
* `total`, so it is retried and, if still short, reported — not hidden.
|
|
194
|
+
* - A row DELETED after it was scanned shifts the rows behind it to a LOWER
|
|
195
|
+
* offset, so the next page starts one row too late and one row is skipped for
|
|
196
|
+
* good. `total` drops by one at the same moment, so `items.length === total`
|
|
197
|
+
* still holds: this is the one case that stays silent, and re-running the
|
|
198
|
+
* command against the settled list is the only cure here. Closing it needs a
|
|
199
|
+
* stable cursor or a server-side lookup by name, neither of which the API
|
|
200
|
+
* offers today.
|
|
201
|
+
*
|
|
202
|
+
* The result is unbounded up to FUNCTIONS_PAGE_SIZE * FUNCTIONS_MAX_PAGES rows.
|
|
203
|
+
* Callers feeding it into a size-limited sink — the CLI's MCP `list_functions`
|
|
204
|
+
* tool serialises it straight into a model's context, where it used to be capped
|
|
205
|
+
* at the server's default 50 — have to cap it themselves; this function will not
|
|
206
|
+
* quietly do it for them, since quiet truncation is the bug it exists to fix.
|
|
207
|
+
*/
|
|
167
208
|
export declare function listRemoteFunctions(client: TransportClient): Promise<RemoteFunctionRecord[]>;
|
|
168
209
|
export declare function resolveRemoteFunction(client: TransportClient, functionName: string): Promise<RemoteFunctionRecord>;
|
|
169
210
|
export declare function invokeRemote<TPayload = unknown, TResult = unknown>(client: TransportClient, functionName: string, payload: TPayload, options?: InvokeRemoteOptions): Promise<RemoteInvocationResult<TResult>>;
|
|
211
|
+
/** Resume never resolves current function names/configuration and never calls start. */
|
|
212
|
+
export declare function resumeRemoteInvocation<TResult = unknown>(client: TransportClient, pending: PendingRemoteInvocation, options?: Omit<InvokeRemoteOptions, 'context'>): Promise<RemoteInvocationResult<TResult>>;
|
|
213
|
+
/** Explicit cancellation records intent; a cancellation receipt is not a terminal result. */
|
|
214
|
+
export declare function cancelRemoteInvocation(client: TransportClient, pending: PendingRemoteInvocation): Promise<{
|
|
215
|
+
invocationId: string;
|
|
216
|
+
functionId: string;
|
|
217
|
+
state: 'CANCEL_REQUESTED' | 'ALREADY_TERMINAL';
|
|
218
|
+
}>;
|
|
170
219
|
export declare function createRemoteFunction(client: TransportClient, input: CreateRemoteFunctionInput): Promise<RemoteFunctionRecord>;
|
|
171
220
|
export declare function updateRemoteFunction(client: TransportClient, functionId: string, input: UpdateRemoteFunctionInput): Promise<RemoteFunctionRecord>;
|
|
172
221
|
export declare function deployRemoteFunction(client: TransportClient, functionId: string, options?: DeployRemoteFunctionOptions): Promise<Record<string, unknown>>;
|
|
173
|
-
|
|
174
|
-
|
|
222
|
+
export interface PendingFunctionDeletion {
|
|
223
|
+
state: 'DELETING';
|
|
224
|
+
functionId: string;
|
|
225
|
+
functionRemoved: boolean;
|
|
226
|
+
warmPoolRetirement: 'pending' | 'verified-absent';
|
|
227
|
+
reason?: string;
|
|
228
|
+
}
|
|
229
|
+
/** Delete by id. A retained pending response means physical cleanup continues;
|
|
230
|
+
* repeat this scoped DELETE to observe completion without starting a new job. */
|
|
231
|
+
export declare function deleteRemoteFunction(client: TransportClient, functionId: string): Promise<PendingFunctionDeletion | undefined>;
|
|
175
232
|
/** Queue an async deploy. Resolves by `functionId` or `name`. */
|
|
176
233
|
export declare function queueDeploy(client: TransportClient, input: QueueDeployInput): Promise<QueuedDeployResponse>;
|
|
177
234
|
export interface OidcExchangeInput {
|
|
@@ -249,6 +306,8 @@ export type CliPairingPollResponse = {
|
|
|
249
306
|
} | {
|
|
250
307
|
status: 'approved';
|
|
251
308
|
token: string;
|
|
309
|
+
tokenId?: string;
|
|
310
|
+
expiresAt?: string;
|
|
252
311
|
user: {
|
|
253
312
|
id: string;
|
|
254
313
|
email: string;
|
|
@@ -269,6 +328,8 @@ export declare function pollCliAuth(baseUrl: string, input: {
|
|
|
269
328
|
pairingId: string;
|
|
270
329
|
deviceSecret: string;
|
|
271
330
|
}, fetchImpl?: typeof fetch): Promise<CliPairingPollResponse>;
|
|
331
|
+
/** Revoke exactly this PAT, without a workspace selector or ambient credentials. */
|
|
332
|
+
export declare function logoutCliAuth(baseUrl: string, token: string, fetchImpl?: typeof fetch): Promise<void>;
|
|
272
333
|
export interface WorkspaceSummary {
|
|
273
334
|
id: string;
|
|
274
335
|
name: string;
|