@playcraft/cli 0.1.45-beta → 0.1.47-beta
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/dist/commands/tools-batch.js +1 -3
- package/dist/workspace-runtime/{production → batch}/content-changes.js +6 -12
- package/dist/workspace-runtime/batch/deliver.js +5 -0
- package/dist/workspace-runtime/batch/freeze.js +61 -62
- package/dist/workspace-runtime/batch/generate.js +24 -3
- package/dist/workspace-runtime/batch/occupancy.js +1 -1
- package/dist/workspace-runtime/batch/prepare.js +2 -0
- package/dist/workspace-runtime/batch/routes.js +3 -0
- package/dist/workspace-runtime/batch/source-candidate.js +86 -0
- package/dist/workspace-runtime/batch/source-failure.js +43 -0
- package/dist/workspace-runtime/batch/source-publish.js +132 -0
- package/dist/workspace-runtime/server/dispatch.js +17 -8
- package/dist/workspace-runtime/server/http.js +10 -24
- package/dist/workspace-runtime/server/terminal-host.js +2 -2
- package/dist/workspace-runtime/verify-artifact.js +59 -0
- package/dist/workspace-runtime/workspaces/cli-credentials.js +6 -2
- package/dist/workspace-runtime/workspaces/directories.js +10 -20
- package/dist/workspace-runtime/workspaces/directory-maintenance.js +3 -3
- package/package.json +3 -3
- package/dist/workspace-runtime/production/contracts.js +0 -19
- package/dist/workspace-runtime/production/controller.js +0 -228
- package/dist/workspace-runtime/production/dependencies.js +0 -60
- package/dist/workspace-runtime/production/native.js +0 -239
- package/dist/workspace-runtime/production/processes.js +0 -102
- package/dist/workspace-runtime/production/save-command.js +0 -35
- package/dist/workspace-runtime/production/source-archive.js +0 -137
- package/dist/workspace-runtime/production/source-copy.js +0 -92
- package/dist/workspace-runtime/production/stages.js +0 -354
- package/dist/workspace-runtime/production/storage.js +0 -75
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
const taskUrl = (input) => `${input.callbackUrl.replace(/\/+$/, '')}/internal/cloud-production/tasks/${input.task.taskId}`;
|
|
2
|
-
async function objectFailure(response, input, operation) {
|
|
3
|
-
const value = await response.json().catch(() => undefined);
|
|
4
|
-
const body = value && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
5
|
-
const reason = [body.reason, body.code, body.message, body.error]
|
|
6
|
-
.find((value) => typeof value === 'string' && /^[a-z0-9_]{1,128}$/.test(value)
|
|
7
|
-
&& !value.includes(input.runnerToken));
|
|
8
|
-
// Keep callback status and machine codes; never record its URL, headers, or response body.
|
|
9
|
-
try {
|
|
10
|
-
console.error(JSON.stringify({ event: 'production.object_transfer_failed', taskId: input.task.taskId,
|
|
11
|
-
attemptId: input.task.attemptId, workspaceId: input.task.workspaceId, directoryName: input.directoryName,
|
|
12
|
-
stage: input.stage, leaseFence: input.lease.fence, operation, status: response.status, reason }));
|
|
13
|
-
}
|
|
14
|
-
catch { /* Diagnostics must preserve the original failure. */ }
|
|
15
|
-
return new Error(operation === 'get'
|
|
16
|
-
? response.status === 404 ? 'object_missing' : 'object_get_failed'
|
|
17
|
-
: response.status === 409 ? 'object_conflict' : 'object_put_failed');
|
|
18
|
-
}
|
|
19
|
-
/** Build output travels through the Runtime that leased the task; engineering files travel through Git. */
|
|
20
|
-
export function productionOutputStore(input) {
|
|
21
|
-
const object = (key) => `${taskUrl(input)}/objects/${key.split('/').map(encodeURIComponent).join('/')}`;
|
|
22
|
-
const headers = { authorization: `Bearer ${input.runnerToken}`, 'x-playcraft-object-client': 'cli' };
|
|
23
|
-
return {
|
|
24
|
-
async get(key) {
|
|
25
|
-
const response = await fetch(object(key), { headers, redirect: 'error', signal: AbortSignal.timeout(60_000) });
|
|
26
|
-
if (!response.ok)
|
|
27
|
-
throw await objectFailure(response, input, 'get');
|
|
28
|
-
return Buffer.from(await response.arrayBuffer());
|
|
29
|
-
},
|
|
30
|
-
async put(key, body) {
|
|
31
|
-
const response = await fetch(object(key), { method: 'PUT', body: new Uint8Array(body), redirect: 'error', signal: AbortSignal.timeout(60_000),
|
|
32
|
-
headers: { ...headers, 'content-type': 'application/octet-stream' } });
|
|
33
|
-
if (!response.ok)
|
|
34
|
-
throw await objectFailure(response, input, 'put');
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
export async function verifyProductionLease(input) {
|
|
39
|
-
let status;
|
|
40
|
-
let reason;
|
|
41
|
-
try {
|
|
42
|
-
const response = await fetch(`${taskUrl(input)}/runner`, {
|
|
43
|
-
headers: { authorization: `Bearer ${input.runnerToken}` }, redirect: 'error', signal: AbortSignal.timeout(10_000),
|
|
44
|
-
});
|
|
45
|
-
status = response.status;
|
|
46
|
-
if (!response.ok) {
|
|
47
|
-
const value = await response.json().catch(() => undefined);
|
|
48
|
-
const body = value && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
49
|
-
reason = [body.reason, body.code, body.message, body.error]
|
|
50
|
-
.find((value) => typeof value === 'string' && /^[a-z0-9_]{1,128}$/.test(value)
|
|
51
|
-
&& !value.includes(input.runnerToken));
|
|
52
|
-
throw new Error('production_lease_unavailable');
|
|
53
|
-
}
|
|
54
|
-
reason = 'production_lease_invalid_response';
|
|
55
|
-
const { task } = await response.json();
|
|
56
|
-
if (!task || task.taskId !== input.task.taskId || task.attemptId !== input.task.attemptId || task.leaseOwner !== input.lease.owner || task.leaseFence !== input.lease.fence || task.status !== 'running' || task.cancelRequested) {
|
|
57
|
-
reason = 'production_lease_mismatch';
|
|
58
|
-
throw new Error('production_lease_unavailable');
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
const cause = error instanceof Error ? error.cause : undefined;
|
|
63
|
-
const causeCode = cause && typeof cause === 'object' && 'code' in cause && typeof cause.code === 'string'
|
|
64
|
-
&& /^[A-Za-z0-9_]{1,64}$/.test(cause.code) ? cause.code : undefined;
|
|
65
|
-
// Callback diagnostics retain machine codes only; responses and credentials stay private.
|
|
66
|
-
try {
|
|
67
|
-
console.error(JSON.stringify({ event: 'production.lease_verification_failed', taskId: input.task.taskId,
|
|
68
|
-
attemptId: input.task.attemptId, workspaceId: input.task.workspaceId, directoryName: input.directoryName,
|
|
69
|
-
stage: input.stage, leaseFence: input.lease.fence, status, reason,
|
|
70
|
-
errorType: error instanceof Error && /^[A-Za-z0-9_]{1,64}$/.test(error.name) ? error.name : 'UnknownError', causeCode }));
|
|
71
|
-
}
|
|
72
|
-
catch { /* Diagnostics must preserve the original failure. */ }
|
|
73
|
-
throw error;
|
|
74
|
-
}
|
|
75
|
-
}
|