@workbench-ai/workbench-core 0.0.66 → 0.0.68
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/execution-graph.d.ts +4 -3
- package/dist/execution-graph.d.ts.map +1 -1
- package/dist/execution-graph.js +15 -14
- package/dist/execution-jobs.d.ts +5 -20
- package/dist/execution-jobs.d.ts.map +1 -1
- package/dist/execution-jobs.js +7 -91
- package/dist/execution-outputs.d.ts +2 -2
- package/dist/execution-outputs.d.ts.map +1 -1
- package/dist/execution-outputs.js +10 -10
- package/dist/execution-runtime-types.d.ts +1 -1
- package/dist/execution-runtime-types.d.ts.map +1 -1
- package/dist/execution-scheduler.d.ts.map +1 -1
- package/dist/execution-scheduler.js +4 -1
- package/dist/execution-traces.js +1 -1
- package/dist/generic-spec.d.ts +29 -29
- package/dist/generic-spec.d.ts.map +1 -1
- package/dist/generic-spec.js +94 -92
- package/dist/index.d.ts +325 -220
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5784 -3856
- package/dist/runtime-dockerfile.d.ts +1 -1
- package/dist/runtime-dockerfile.d.ts.map +1 -1
- package/dist/runtime-dockerfile.js +4 -4
- package/dist/runtime-utils.d.ts +1 -1
- package/dist/runtime-utils.d.ts.map +1 -1
- package/dist/runtime-utils.js +3 -3
- package/dist/sandbox-backends/docker.js +7 -5
- package/dist/sandbox-inputs.js +3 -3
- package/dist/sandbox-plane.d.ts.map +1 -1
- package/dist/sandbox-plane.js +13 -9
- package/dist/skill-patch.d.ts +8 -0
- package/dist/skill-patch.d.ts.map +1 -0
- package/dist/{candidate-patch.js → skill-patch.js} +5 -5
- package/package.json +3 -3
- package/worker/sandbox-adapter-runner.cjs +2 -2
- package/dist/candidate-patch.d.ts +0 -8
- package/dist/candidate-patch.d.ts.map +0 -1
- package/dist/execution-evidence.d.ts +0 -22
- package/dist/execution-evidence.d.ts.map +0 -1
- package/dist/execution-evidence.js +0 -302
- package/dist/inspection.d.ts +0 -111
- package/dist/inspection.d.ts.map +0 -1
- package/dist/inspection.js +0 -217
|
@@ -7,7 +7,7 @@ export interface WorkbenchRuntimeAdapterInstallerFile {
|
|
|
7
7
|
export interface WorkbenchRuntimeAdapterInstaller {
|
|
8
8
|
id: string;
|
|
9
9
|
source: string;
|
|
10
|
-
|
|
10
|
+
install: readonly string[];
|
|
11
11
|
files?: readonly WorkbenchRuntimeAdapterInstallerFile[];
|
|
12
12
|
}
|
|
13
13
|
export declare function composeRuntimeDockerfileWithAdapterInstallers(dockerfile: string, adapters: readonly WorkbenchRuntimeAdapterInstaller[]): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-dockerfile.d.ts","sourceRoot":"","sources":["../src/runtime-dockerfile.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,oCAAoC;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,gCAAgC;IAC/C,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,
|
|
1
|
+
{"version":3,"file":"runtime-dockerfile.d.ts","sourceRoot":"","sources":["../src/runtime-dockerfile.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,oCAAoC;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,gCAAgC;IAC/C,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,KAAK,CAAC,EAAE,SAAS,oCAAoC,EAAE,CAAC;CACzD;AAED,wBAAgB,6CAA6C,CAC3D,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,SAAS,gCAAgC,EAAE,GACpD,MAAM,CAiCR"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
export function composeRuntimeDockerfileWithAdapterInstallers(dockerfile, adapters) {
|
|
3
|
-
const installAdapters = adapters.filter((adapter) => adapter.
|
|
3
|
+
const installAdapters = adapters.filter((adapter) => adapter.install.length > 0 || (adapter.files?.length ?? 0) > 0);
|
|
4
4
|
if (installAdapters.length === 0) {
|
|
5
5
|
return dockerfile;
|
|
6
6
|
}
|
|
@@ -8,7 +8,7 @@ export function composeRuntimeDockerfileWithAdapterInstallers(dockerfile, adapte
|
|
|
8
8
|
const lines = [
|
|
9
9
|
dockerfile.trimEnd(),
|
|
10
10
|
"",
|
|
11
|
-
"# Workbench adapter
|
|
11
|
+
"# Workbench adapter install commands. The eval Dockerfile owns case dependencies;",
|
|
12
12
|
"# adapter manifests own adapter runtime dependencies.",
|
|
13
13
|
"USER root",
|
|
14
14
|
];
|
|
@@ -19,13 +19,13 @@ export function composeRuntimeDockerfileWithAdapterInstallers(dockerfile, adapte
|
|
|
19
19
|
lines.push(...adapterSourceDockerfileLines(adapter));
|
|
20
20
|
lines.push(`WORKDIR /opt/workbench-adapters/${adapter.id}`);
|
|
21
21
|
}
|
|
22
|
-
for (const command of adapter.
|
|
22
|
+
for (const command of adapter.install) {
|
|
23
23
|
lines.push(`RUN ${command}`);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
if (finalUser) {
|
|
27
27
|
lines.push("");
|
|
28
|
-
lines.push(`# Restore
|
|
28
|
+
lines.push(`# Restore eval runtime user.`);
|
|
29
29
|
lines.push(`USER ${finalUser}`);
|
|
30
30
|
}
|
|
31
31
|
lines.push("WORKDIR /workspace", "");
|
package/dist/runtime-utils.d.ts
CHANGED
|
@@ -18,6 +18,6 @@ export declare function resolveDockerRuntimeImageRef(imageRef: string, options:
|
|
|
18
18
|
}): string;
|
|
19
19
|
export declare function normalizeRuntimeRegistry(value: string): string;
|
|
20
20
|
export declare function normalizeWorkbenchWorkerId(value: unknown): string | undefined;
|
|
21
|
-
export declare function resolveWorkbenchWorkerId(
|
|
21
|
+
export declare function resolveWorkbenchWorkerId(skills: readonly unknown[], fallback: string): string;
|
|
22
22
|
export declare function quoteShellArg(value: string): string;
|
|
23
23
|
//# sourceMappingURL=runtime-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-utils.d.ts","sourceRoot":"","sources":["../src/runtime-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,mBAAmB,EACpB,MAAM,kCAAkC,CAAC;AAE1C,wBAAsB,gBAAgB,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAEvE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAIvE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAI/D;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAE9D;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAE9D;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAU9D;AAED,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,mBAAmB,EAAE,GACpC,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,CAAC,IAAI,EAA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GAAG,MAAM,CAU9D;AAED,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,mBAAmB,EAAE,GACpC,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAA;CAAO,GACvD,OAAO,CAAC,mBAAmB,EAAE,CAAC,CA+ChC;AAwBD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,kCAAkC,EAAE,IAAI,CAWtG;AAED,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;IAAE,eAAe,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAAE,GAChF,MAAM,CASR;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9D;AAeD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAS7E;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAS7F;AAoBD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKnD"}
|
package/dist/runtime-utils.js
CHANGED
|
@@ -167,9 +167,9 @@ export function normalizeWorkbenchWorkerId(value) {
|
|
|
167
167
|
}
|
|
168
168
|
return NON_IDENTIFYING_WORKER_IDS.has(normalized.toLowerCase()) ? undefined : normalized;
|
|
169
169
|
}
|
|
170
|
-
export function resolveWorkbenchWorkerId(
|
|
171
|
-
for (const
|
|
172
|
-
const normalized = normalizeWorkbenchWorkerId(
|
|
170
|
+
export function resolveWorkbenchWorkerId(skills, fallback) {
|
|
171
|
+
for (const skill of skills) {
|
|
172
|
+
const normalized = normalizeWorkbenchWorkerId(skill);
|
|
173
173
|
if (normalized) {
|
|
174
174
|
return normalized;
|
|
175
175
|
}
|
|
@@ -213,6 +213,8 @@ async function runDockerSandboxExecution(args, sandbox, execution) {
|
|
|
213
213
|
"--env",
|
|
214
214
|
"USER=workbench",
|
|
215
215
|
"--env",
|
|
216
|
+
`PATH=${DOCKER_RUNTIME_MOUNT}/node_modules/.bin:/usr/local/bin:/usr/bin:/bin`,
|
|
217
|
+
"--env",
|
|
216
218
|
`WORKBENCH_WORKSPACE_ROOT=${workspaceRoot}`,
|
|
217
219
|
"--env",
|
|
218
220
|
`WORKBENCH_RUNTIME_IMPORT=${runtimeImport}`,
|
|
@@ -564,17 +566,17 @@ function findDockerSourceRoot() {
|
|
|
564
566
|
}
|
|
565
567
|
const cwd = process.cwd();
|
|
566
568
|
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
567
|
-
const
|
|
569
|
+
const skills = [
|
|
568
570
|
cwd,
|
|
569
571
|
path.resolve(cwd, ".."),
|
|
570
572
|
path.resolve(cwd, "../.."),
|
|
571
573
|
path.resolve(cwd, "../../.."),
|
|
572
574
|
path.resolve(moduleDir, "../../../../../.."),
|
|
573
575
|
];
|
|
574
|
-
for (const
|
|
575
|
-
if (existsSync(path.join(
|
|
576
|
-
existsSync(path.join(
|
|
577
|
-
return
|
|
576
|
+
for (const skill of skills) {
|
|
577
|
+
if (existsSync(path.join(skill, "products/workbench/packages/core/worker/sandbox-adapter-runner.cjs")) &&
|
|
578
|
+
existsSync(path.join(skill, "products/workbench/packages/core/src/index.ts"))) {
|
|
579
|
+
return skill;
|
|
578
580
|
}
|
|
579
581
|
}
|
|
580
582
|
return null;
|
package/dist/sandbox-inputs.js
CHANGED
|
@@ -32,7 +32,7 @@ export function createWorkbenchSandboxFileStore(args) {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
export function materializeWorkbenchSandboxInput(args, execution, input) {
|
|
35
|
-
if (input.name === "
|
|
35
|
+
if (input.name === "skill" || input.name === "skills") {
|
|
36
36
|
return materializedFileInput(input, args.baseFiles);
|
|
37
37
|
}
|
|
38
38
|
if (input.name === "case") {
|
|
@@ -165,8 +165,8 @@ export async function executionResultFromCompletedSandboxJob(args) {
|
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
167
|
export function outputPayloadForContract(output, outputName) {
|
|
168
|
-
if (outputName === "
|
|
169
|
-
return isJsonPayload(output.
|
|
168
|
+
if (outputName === "skill_patch") {
|
|
169
|
+
return isJsonPayload(output.skillPatch) ? output.skillPatch : undefined;
|
|
170
170
|
}
|
|
171
171
|
if (outputName === "result") {
|
|
172
172
|
return isJsonPayload(output.result) ? output.result : undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-plane.d.ts","sourceRoot":"","sources":["../src/sandbox-plane.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,IAAI,EACJ,mBAAmB,EACnB,4BAA4B,EAC5B,0BAA0B,EAC1B,+BAA+B,EAC/B,wBAAwB,EACxB,sBAAsB,EACtB,0BAA0B,EAC1B,iCAAiC,EACjC,sBAAsB,EACvB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAGL,KAAK,gCAAgC,EACtC,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,0BAA0B,CAAC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC9B,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AAED,MAAM,WAAW,yBAAyB;IACxC,iBAAiB,CAAC,SAAS,EAAE,sBAAsB,GAAG,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAAC;IAC1F,WAAW,CAAC,UAAU,EAAE,4BAA4B,EAAE,UAAU,EAAE,MAAM,E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,MAAM,CAAA;CAAO,GAC7B,MAAM,EAAE,CAkCV"}
|
package/dist/sandbox-plane.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assertWorkbenchExecutionIsolation, validateWorkbenchExecutionOutputPayloads, } from "./execution-outputs.js";
|
|
2
|
+
const SANDBOX_SETUP_TTL_BUFFER_MS = 15 * 60_000;
|
|
2
3
|
export async function executeValidatedSandboxExecution(plane, execution, options) {
|
|
3
4
|
assertWorkbenchExecutionIsolation(execution);
|
|
4
5
|
assertSandboxBackendSupportsNetworkPolicy(plane.backend, execution);
|
|
@@ -146,7 +147,7 @@ export function createWorkbenchSandboxExecutionMetadata(args) {
|
|
|
146
147
|
},
|
|
147
148
|
capability: {
|
|
148
149
|
...args.capability,
|
|
149
|
-
|
|
150
|
+
skill: { ...args.capability.skill },
|
|
150
151
|
inputs: args.capability.inputs.map((input) => ({ ...input })),
|
|
151
152
|
network: { ...args.capability.network },
|
|
152
153
|
},
|
|
@@ -178,7 +179,7 @@ export function collectSandboxHandleScopeIssues(sandbox, allocation, execution)
|
|
|
178
179
|
}
|
|
179
180
|
export function createWorkbenchSandboxAllocation(execution, options) {
|
|
180
181
|
const nowMs = options.now ? Date.parse(options.now) : Date.now();
|
|
181
|
-
const ttlMs = options.ttlMs ??
|
|
182
|
+
const ttlMs = options.ttlMs ?? workbenchSandboxLifetimeTtlMs(execution);
|
|
182
183
|
const safeExecutionId = execution.id.replace(/[^a-z0-9_]+/giu, "_");
|
|
183
184
|
const nonce = allocationNonce();
|
|
184
185
|
return {
|
|
@@ -208,14 +209,14 @@ function allocationNonce() {
|
|
|
208
209
|
}
|
|
209
210
|
export function createWorkbenchExecutionCapability(execution, options = {}) {
|
|
210
211
|
const nowMs = options.now ? Date.parse(options.now) : Date.now();
|
|
211
|
-
const ttlMs = options.ttlMs ??
|
|
212
|
+
const ttlMs = options.ttlMs ?? workbenchSandboxLifetimeTtlMs(execution);
|
|
212
213
|
return {
|
|
213
214
|
executionId: execution.id,
|
|
214
|
-
|
|
215
|
+
skill: {
|
|
215
216
|
tenantId: execution.policy.tenantId,
|
|
216
217
|
projectId: execution.projectId,
|
|
217
218
|
runId: execution.runId,
|
|
218
|
-
...(execution.
|
|
219
|
+
...(execution.versionId ? { versionId: execution.versionId } : {}),
|
|
219
220
|
},
|
|
220
221
|
inputs: execution.inputs.map((input) => ({ ...input })),
|
|
221
222
|
outputPrefix: options.outputPrefix ?? `executions/${execution.id}/outputs/`,
|
|
@@ -223,19 +224,22 @@ export function createWorkbenchExecutionCapability(execution, options = {}) {
|
|
|
223
224
|
expiresAt: new Date(nowMs + ttlMs).toISOString(),
|
|
224
225
|
};
|
|
225
226
|
}
|
|
227
|
+
function workbenchSandboxLifetimeTtlMs(execution) {
|
|
228
|
+
return Math.max(60_000, execution.policy.resources.timeoutMinutes * 60_000 + SANDBOX_SETUP_TTL_BUFFER_MS);
|
|
229
|
+
}
|
|
226
230
|
export function collectExecutionCapabilityScopeIssues(capability, execution, options = {}) {
|
|
227
231
|
const issues = [];
|
|
228
232
|
if (capability.executionId !== execution.id) {
|
|
229
233
|
issues.push(`Capability execution id ${capability.executionId} does not match ${execution.id}.`);
|
|
230
234
|
}
|
|
231
|
-
if (capability.
|
|
235
|
+
if (capability.skill.tenantId !== execution.policy.tenantId) {
|
|
232
236
|
issues.push(`Capability tenant id does not match execution ${execution.id}.`);
|
|
233
237
|
}
|
|
234
|
-
if (capability.
|
|
238
|
+
if (capability.skill.projectId !== execution.projectId || capability.skill.runId !== execution.runId) {
|
|
235
239
|
issues.push(`Capability project/run scope does not match execution ${execution.id}.`);
|
|
236
240
|
}
|
|
237
|
-
if ((capability.
|
|
238
|
-
issues.push(`Capability
|
|
241
|
+
if ((capability.skill.versionId ?? null) !== (execution.versionId ?? null)) {
|
|
242
|
+
issues.push(`Capability skill version scope does not match execution ${execution.id}.`);
|
|
239
243
|
}
|
|
240
244
|
if (!capability.outputPrefix.startsWith(`executions/${execution.id}/`)) {
|
|
241
245
|
issues.push(`Capability output prefix must be scoped under executions/${execution.id}/.`);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SurfaceSnapshotFile, WorkbenchSkillPatch } from "@workbench-ai/workbench-contract";
|
|
2
|
+
export interface ApplyWorkbenchSkillPatchInput {
|
|
3
|
+
baseFiles: readonly SurfaceSnapshotFile[];
|
|
4
|
+
patch: WorkbenchSkillPatch;
|
|
5
|
+
edits: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function applyWorkbenchSkillPatch(input: ApplyWorkbenchSkillPatchInput): SurfaceSnapshotFile[];
|
|
8
|
+
//# sourceMappingURL=skill-patch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-patch.d.ts","sourceRoot":"","sources":["../src/skill-patch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,kCAAkC,CAAC;AAE1C,MAAM,WAAW,6BAA6B;IAC5C,SAAS,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAC1C,KAAK,EAAE,mBAAmB,CAAC;IAC3B,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1B;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,GAAG,mBAAmB,EAAE,CAgDpG"}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function applyWorkbenchSkillPatch(input) {
|
|
2
2
|
const issues = [];
|
|
3
3
|
const edits = input.edits.map(normalizeRelativePath).filter(Boolean);
|
|
4
4
|
const patchPaths = new Set();
|
|
5
5
|
for (const file of input.patch.files) {
|
|
6
6
|
const filePath = normalizeRelativePath(file.path);
|
|
7
7
|
if (!isSafeRelativePath(filePath)) {
|
|
8
|
-
issues.push(`
|
|
8
|
+
issues.push(`Skill patch contains unsafe path ${file.path}.`);
|
|
9
9
|
}
|
|
10
10
|
if (!isAllowedEditPath(filePath, edits)) {
|
|
11
|
-
issues.push(`
|
|
11
|
+
issues.push(`Skill patch contains path outside improve edits: ${file.path}.`);
|
|
12
12
|
}
|
|
13
13
|
patchPaths.add(filePath);
|
|
14
14
|
}
|
|
15
15
|
for (const fileChange of input.patch.fileChanges) {
|
|
16
16
|
const filePath = normalizeRelativePath(fileChange);
|
|
17
17
|
if (!isSafeRelativePath(filePath)) {
|
|
18
|
-
issues.push(`
|
|
18
|
+
issues.push(`Skill patch fileChanges contains unsafe path ${fileChange}.`);
|
|
19
19
|
}
|
|
20
20
|
if (!isAllowedEditPath(filePath, edits)) {
|
|
21
|
-
issues.push(`
|
|
21
|
+
issues.push(`Skill patch fileChanges contains path outside improve edits: ${fileChange}.`);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
if (issues.length > 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workbench-ai/workbench-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.68",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/workbench-ai/workbench.git",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"yaml": "^2.8.2",
|
|
25
|
-
"@workbench-ai/workbench-contract": "0.0.
|
|
26
|
-
"@workbench-ai/workbench-protocol": "0.0.
|
|
25
|
+
"@workbench-ai/workbench-contract": "0.0.68",
|
|
26
|
+
"@workbench-ai/workbench-protocol": "0.0.68"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^24.3.1",
|
|
@@ -214,7 +214,7 @@ function runtimeInputsFromInputBundle(bundle) {
|
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
return {
|
|
217
|
-
baseFiles: filesByName.get("
|
|
217
|
+
baseFiles: filesByName.get("skills") || filesByName.get("skill") || [],
|
|
218
218
|
engineResolveFiles: filesByName.get("case") || [],
|
|
219
219
|
traceFiles: filesByName.get("traces") || [],
|
|
220
220
|
};
|
|
@@ -262,7 +262,7 @@ function isJson(value) {
|
|
|
262
262
|
|
|
263
263
|
function collectExecutionMismatchIssues(jobExecution, execution) {
|
|
264
264
|
const issues = [];
|
|
265
|
-
for (const key of ["id", "projectId", "runId", "
|
|
265
|
+
for (const key of ["id", "projectId", "runId", "versionId", "purpose"]) {
|
|
266
266
|
if ((jobExecution[key] ?? null) !== (execution[key] ?? null)) {
|
|
267
267
|
issues.push(`job execution ${key} does not match request execution ${key}.`);
|
|
268
268
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { SurfaceSnapshotFile, WorkbenchCandidatePatch } from "@workbench-ai/workbench-contract";
|
|
2
|
-
export interface ApplyWorkbenchCandidatePatchInput {
|
|
3
|
-
baseFiles: readonly SurfaceSnapshotFile[];
|
|
4
|
-
patch: WorkbenchCandidatePatch;
|
|
5
|
-
edits: readonly string[];
|
|
6
|
-
}
|
|
7
|
-
export declare function applyWorkbenchCandidatePatch(input: ApplyWorkbenchCandidatePatchInput): SurfaceSnapshotFile[];
|
|
8
|
-
//# sourceMappingURL=candidate-patch.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"candidate-patch.d.ts","sourceRoot":"","sources":["../src/candidate-patch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,kCAAkC,CAAC;AAE1C,MAAM,WAAW,iCAAiC;IAChD,SAAS,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAC1C,KAAK,EAAE,uBAAuB,CAAC;IAC/B,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1B;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,iCAAiC,GAAG,mBAAmB,EAAE,CAgD5G"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { CandidateCaseReview, RemoteWorkbenchJob, RemoteWorkbenchJobStatus, WorkbenchExecutionEventRole, WorkbenchExecutionSpec, WorkbenchExecutionTrace, WorkbenchExecutionEvidence, WorkbenchTraceSession } from "@workbench-ai/workbench-contract";
|
|
2
|
-
export declare function buildCandidateCaseExecutionRefs(args: {
|
|
3
|
-
jobs: readonly RemoteWorkbenchJob[];
|
|
4
|
-
candidateId: string;
|
|
5
|
-
caseId: string;
|
|
6
|
-
sampleIndex?: number;
|
|
7
|
-
}): CandidateCaseReview["executions"];
|
|
8
|
-
export declare function buildWorkbenchExecutionEvidence(args: {
|
|
9
|
-
jobs: readonly RemoteWorkbenchJob[];
|
|
10
|
-
traceIdPrefix: string;
|
|
11
|
-
traceForJob: (job: RemoteWorkbenchJob, role: WorkbenchExecutionEventRole) => WorkbenchExecutionTrace;
|
|
12
|
-
traceSessionsForJob?: (job: RemoteWorkbenchJob, role: WorkbenchExecutionEventRole) => WorkbenchTraceSession[];
|
|
13
|
-
}): WorkbenchExecutionEvidence[];
|
|
14
|
-
export declare function readWorkbenchExecutionPurpose(job: RemoteWorkbenchJob): WorkbenchExecutionSpec["purpose"] | null;
|
|
15
|
-
export declare function readWorkbenchExecutionId(job: RemoteWorkbenchJob): string | null;
|
|
16
|
-
export declare function readWorkbenchExecutionMetadataString(job: RemoteWorkbenchJob, key: string): string | null;
|
|
17
|
-
export declare function readWorkbenchExecutionMetadataNumber(job: RemoteWorkbenchJob, key: string): number | null;
|
|
18
|
-
export declare function isWorkbenchExecutionActive(execution: CandidateCaseReview["executions"][number]): boolean;
|
|
19
|
-
export declare function resolveWorkbenchJobGroupStatus(jobs: readonly {
|
|
20
|
-
status: RemoteWorkbenchJobStatus;
|
|
21
|
-
}[]): RemoteWorkbenchJobStatus;
|
|
22
|
-
//# sourceMappingURL=execution-evidence.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"execution-evidence.d.ts","sourceRoot":"","sources":["../src/execution-evidence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,m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AI,EAAE,SAAS;IAAE,MAAM,EAAE,wBAAwB,CAAA;CAAE,EAAE,GACpD,wBAAwB,CAc1B"}
|
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
import { mergeWorkbenchExecutionTracesByJob } from "./execution-traces.js";
|
|
2
|
-
export function buildCandidateCaseExecutionRefs(args) {
|
|
3
|
-
const groups = new Map();
|
|
4
|
-
for (const job of args.jobs) {
|
|
5
|
-
const kind = readWorkbenchExecutionPurpose(job);
|
|
6
|
-
const jobCandidateId = job.candidateId ?? readWorkbenchExecutionMetadataString(job, "candidateId");
|
|
7
|
-
const jobCaseId = readWorkbenchExecutionMetadataString(job, "caseId");
|
|
8
|
-
if (jobCandidateId === args.candidateId &&
|
|
9
|
-
kind === "attempt" &&
|
|
10
|
-
caseReviewCaseIdsMatch(jobCaseId, args.caseId) &&
|
|
11
|
-
caseReviewSampleIndicesMatch(readWorkbenchExecutionMetadataNumber(job, "sampleIndex"), args.sampleIndex)) {
|
|
12
|
-
const key = [
|
|
13
|
-
job.runId,
|
|
14
|
-
kind,
|
|
15
|
-
jobCaseId ?? "",
|
|
16
|
-
readWorkbenchExecutionMetadataNumber(job, "sampleIndex") ?? "",
|
|
17
|
-
].join("\0");
|
|
18
|
-
groups.set(key, [...(groups.get(key) ?? []), job]);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
const executions = [...groups.values()]
|
|
22
|
-
.map((group) => group.slice().sort(compareWorkbenchExecutionJobs))
|
|
23
|
-
.flatMap((group) => {
|
|
24
|
-
const first = group[0];
|
|
25
|
-
if (!first) {
|
|
26
|
-
return [];
|
|
27
|
-
}
|
|
28
|
-
const kind = readWorkbenchExecutionPurpose(first);
|
|
29
|
-
if (kind !== "attempt") {
|
|
30
|
-
return [];
|
|
31
|
-
}
|
|
32
|
-
const startedAt = minTimestamp(group.map((job) => job.startedAt));
|
|
33
|
-
const finishedAt = maxTimestamp(group.map((job) => job.finishedAt));
|
|
34
|
-
const durationMs = startedAt && finishedAt
|
|
35
|
-
? Math.max(0, Date.parse(finishedAt) - Date.parse(startedAt))
|
|
36
|
-
: null;
|
|
37
|
-
return [{
|
|
38
|
-
runId: first.runId,
|
|
39
|
-
kind,
|
|
40
|
-
role: "engine",
|
|
41
|
-
status: resolveWorkbenchJobGroupStatus(group),
|
|
42
|
-
jobIds: group.map((job) => job.id),
|
|
43
|
-
executionIds: group.flatMap((job) => {
|
|
44
|
-
const executionId = readWorkbenchExecutionId(job);
|
|
45
|
-
return executionId ? [executionId] : [];
|
|
46
|
-
}),
|
|
47
|
-
createdAt: minTimestamp(group.map((job) => job.createdAt)) ?? first.createdAt,
|
|
48
|
-
...(startedAt ? { startedAt } : {}),
|
|
49
|
-
...(finishedAt ? { finishedAt } : {}),
|
|
50
|
-
...(durationMs !== null ? { durationMs } : {}),
|
|
51
|
-
...optionalString("caseId", readWorkbenchExecutionMetadataString(first, "caseId")),
|
|
52
|
-
...optionalNumber("sampleIndex", readWorkbenchExecutionMetadataNumber(first, "sampleIndex")),
|
|
53
|
-
...optionalNumber("attemptIndex", readWorkbenchExecutionMetadataNumber(first, "attemptIndex")),
|
|
54
|
-
}];
|
|
55
|
-
})
|
|
56
|
-
.sort(compareCandidateCaseExecutions);
|
|
57
|
-
return selectCurrentExecutionRun(executions);
|
|
58
|
-
}
|
|
59
|
-
export function buildWorkbenchExecutionEvidence(args) {
|
|
60
|
-
const groups = new Map();
|
|
61
|
-
for (const job of args.jobs) {
|
|
62
|
-
if (isBaselineMaterializationJob(job)) {
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
const purpose = readWorkbenchExecutionPurpose(job);
|
|
66
|
-
if (!purpose) {
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
const key = [
|
|
70
|
-
job.runId,
|
|
71
|
-
purpose,
|
|
72
|
-
job.candidateId ?? readWorkbenchExecutionMetadataString(job, "candidateId") ?? "",
|
|
73
|
-
readWorkbenchExecutionMetadataString(job, "caseId") ?? "",
|
|
74
|
-
readWorkbenchExecutionMetadataNumber(job, "sampleIndex") ?? "",
|
|
75
|
-
readWorkbenchExecutionMetadataNumber(job, "attemptIndex") ?? "",
|
|
76
|
-
].join("\0");
|
|
77
|
-
groups.set(key, [...(groups.get(key) ?? []), job]);
|
|
78
|
-
}
|
|
79
|
-
return [...groups.values()]
|
|
80
|
-
.map((group) => group.slice().sort(compareWorkbenchTraceJobs))
|
|
81
|
-
.flatMap((group) => {
|
|
82
|
-
const first = group[0];
|
|
83
|
-
if (!first) {
|
|
84
|
-
return [];
|
|
85
|
-
}
|
|
86
|
-
const purpose = readWorkbenchExecutionPurpose(first);
|
|
87
|
-
if (!purpose) {
|
|
88
|
-
return [];
|
|
89
|
-
}
|
|
90
|
-
const role = traceRoleForPurpose(purpose);
|
|
91
|
-
const sessions = group.flatMap((job) => args.traceSessionsForJob
|
|
92
|
-
? args.traceSessionsForJob(job, role)
|
|
93
|
-
: []);
|
|
94
|
-
const jobIds = group.map((job) => job.id);
|
|
95
|
-
const executionIds = group.flatMap((job) => {
|
|
96
|
-
const executionId = readWorkbenchExecutionId(job);
|
|
97
|
-
return executionId ? [executionId] : [];
|
|
98
|
-
});
|
|
99
|
-
return [{
|
|
100
|
-
id: [
|
|
101
|
-
purpose,
|
|
102
|
-
first.runId,
|
|
103
|
-
readWorkbenchExecutionMetadataString(first, "caseId") ?? "current",
|
|
104
|
-
readWorkbenchExecutionMetadataNumber(first, "sampleIndex") ?? "sample",
|
|
105
|
-
readWorkbenchExecutionMetadataNumber(first, "attemptIndex") ?? "attempt",
|
|
106
|
-
jobIds.join("_"),
|
|
107
|
-
].join(":"),
|
|
108
|
-
kind: purpose,
|
|
109
|
-
executionId: group.length === 1 ? readWorkbenchExecutionId(first) : null,
|
|
110
|
-
role,
|
|
111
|
-
status: resolveWorkbenchJobGroupStatus(group),
|
|
112
|
-
jobIds,
|
|
113
|
-
executionIds,
|
|
114
|
-
...(first.candidateId ? { candidateId: first.candidateId } : {}),
|
|
115
|
-
...optionalString("caseId", readWorkbenchExecutionMetadataString(first, "caseId")),
|
|
116
|
-
...optionalNumber("sampleIndex", readWorkbenchExecutionMetadataNumber(first, "sampleIndex")),
|
|
117
|
-
...optionalNumber("attemptIndex", readWorkbenchExecutionMetadataNumber(first, "attemptIndex")),
|
|
118
|
-
sessions,
|
|
119
|
-
trace: mergeWorkbenchExecutionTracesByJob({
|
|
120
|
-
traceIdPrefix: args.traceIdPrefix,
|
|
121
|
-
stageId: purpose,
|
|
122
|
-
jobs: [
|
|
123
|
-
...group.map((job) => ({
|
|
124
|
-
id: job.id,
|
|
125
|
-
trace: args.traceForJob(job, role),
|
|
126
|
-
})),
|
|
127
|
-
...sessions.map((session) => ({
|
|
128
|
-
id: session.id,
|
|
129
|
-
jobId: session.jobId,
|
|
130
|
-
trace: session.trace,
|
|
131
|
-
})),
|
|
132
|
-
],
|
|
133
|
-
}),
|
|
134
|
-
}];
|
|
135
|
-
})
|
|
136
|
-
.sort(compareWorkbenchExecutionEvidence);
|
|
137
|
-
}
|
|
138
|
-
export function readWorkbenchExecutionPurpose(job) {
|
|
139
|
-
if (job.kind !== "execute") {
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
const purpose = readExecutionRecord(job)?.purpose;
|
|
143
|
-
return purpose === "improve" || purpose === "attempt"
|
|
144
|
-
? purpose
|
|
145
|
-
: null;
|
|
146
|
-
}
|
|
147
|
-
export function readWorkbenchExecutionId(job) {
|
|
148
|
-
const id = readExecutionRecord(job)?.id;
|
|
149
|
-
return typeof id === "string" && id.length > 0 ? id : null;
|
|
150
|
-
}
|
|
151
|
-
export function readWorkbenchExecutionMetadataString(job, key) {
|
|
152
|
-
const raw = readWorkbenchExecutionMetadataValue(job, key);
|
|
153
|
-
return typeof raw === "string" && raw.length > 0 ? raw : null;
|
|
154
|
-
}
|
|
155
|
-
export function readWorkbenchExecutionMetadataNumber(job, key) {
|
|
156
|
-
const raw = readWorkbenchExecutionMetadataValue(job, key);
|
|
157
|
-
return typeof raw === "number" && Number.isFinite(raw) ? raw : null;
|
|
158
|
-
}
|
|
159
|
-
export function isWorkbenchExecutionActive(execution) {
|
|
160
|
-
return execution.status === "queued" || execution.status === "running";
|
|
161
|
-
}
|
|
162
|
-
export function resolveWorkbenchJobGroupStatus(jobs) {
|
|
163
|
-
if (jobs.some((job) => job.status === "running")) {
|
|
164
|
-
return "running";
|
|
165
|
-
}
|
|
166
|
-
if (jobs.some((job) => job.status === "queued")) {
|
|
167
|
-
return "queued";
|
|
168
|
-
}
|
|
169
|
-
if (jobs.some((job) => job.status === "failed")) {
|
|
170
|
-
return "failed";
|
|
171
|
-
}
|
|
172
|
-
if (jobs.some((job) => job.status === "cancelled")) {
|
|
173
|
-
return "cancelled";
|
|
174
|
-
}
|
|
175
|
-
return "succeeded";
|
|
176
|
-
}
|
|
177
|
-
function readWorkbenchExecutionMetadataValue(job, key) {
|
|
178
|
-
const input = asRecord(job.input);
|
|
179
|
-
const execution = asRecord(input?.execution);
|
|
180
|
-
const metadata = asRecord(execution?.metadata);
|
|
181
|
-
return metadata?.[key] ?? input?.[key] ?? null;
|
|
182
|
-
}
|
|
183
|
-
function readExecutionRecord(job) {
|
|
184
|
-
const input = asRecord(job.input);
|
|
185
|
-
return asRecord(input?.execution);
|
|
186
|
-
}
|
|
187
|
-
function isBaselineMaterializationJob(job) {
|
|
188
|
-
const input = asRecord(job.input);
|
|
189
|
-
const execution = asRecord(input?.execution);
|
|
190
|
-
const metadata = asRecord(execution?.metadata);
|
|
191
|
-
return metadata?.baseline === true || input?.baseline === true;
|
|
192
|
-
}
|
|
193
|
-
function caseReviewCaseIdsMatch(jobCaseId, requestedCaseId) {
|
|
194
|
-
return Boolean(jobCaseId) &&
|
|
195
|
-
(jobCaseId === requestedCaseId || requestedCaseId.startsWith(`${jobCaseId}__`));
|
|
196
|
-
}
|
|
197
|
-
function caseReviewSampleIndicesMatch(jobSampleIndex, reviewSampleIndex) {
|
|
198
|
-
return typeof reviewSampleIndex !== "number" || jobSampleIndex === reviewSampleIndex;
|
|
199
|
-
}
|
|
200
|
-
function selectCurrentExecutionRun(executions) {
|
|
201
|
-
if (executions.length <= 1) {
|
|
202
|
-
return executions;
|
|
203
|
-
}
|
|
204
|
-
const activeRunId = executions
|
|
205
|
-
.filter(isWorkbenchExecutionActive)
|
|
206
|
-
.sort(compareExecutionRecency)[0]?.runId;
|
|
207
|
-
const selectedRunId = activeRunId ?? executions.slice().sort(compareExecutionRecency)[0]?.runId;
|
|
208
|
-
return selectedRunId
|
|
209
|
-
? executions.filter((execution) => execution.runId === selectedRunId)
|
|
210
|
-
: executions;
|
|
211
|
-
}
|
|
212
|
-
function compareCandidateCaseExecutions(left, right) {
|
|
213
|
-
return (executionKindOrder(left.kind) - executionKindOrder(right.kind) ||
|
|
214
|
-
(left.sampleIndex ?? -1) - (right.sampleIndex ?? -1) ||
|
|
215
|
-
readExecutionRecencyMs(right) - readExecutionRecencyMs(left));
|
|
216
|
-
}
|
|
217
|
-
function compareExecutionRecency(left, right) {
|
|
218
|
-
return readExecutionRecencyMs(right) - readExecutionRecencyMs(left);
|
|
219
|
-
}
|
|
220
|
-
function compareWorkbenchExecutionJobs(left, right) {
|
|
221
|
-
return (executionKindOrder(readWorkbenchExecutionPurpose(left)) -
|
|
222
|
-
executionKindOrder(readWorkbenchExecutionPurpose(right)) ||
|
|
223
|
-
(readWorkbenchExecutionMetadataNumber(left, "sampleIndex") ?? -1) -
|
|
224
|
-
(readWorkbenchExecutionMetadataNumber(right, "sampleIndex") ?? -1) ||
|
|
225
|
-
readJobRecencyMs(right) - readJobRecencyMs(left) ||
|
|
226
|
-
left.id.localeCompare(right.id));
|
|
227
|
-
}
|
|
228
|
-
function compareWorkbenchTraceJobs(left, right) {
|
|
229
|
-
return (executionKindOrder(readWorkbenchExecutionPurpose(left)) -
|
|
230
|
-
executionKindOrder(readWorkbenchExecutionPurpose(right)) ||
|
|
231
|
-
String(readWorkbenchExecutionMetadataString(left, "caseId") ?? "").localeCompare(String(readWorkbenchExecutionMetadataString(right, "caseId") ?? "")) ||
|
|
232
|
-
(readWorkbenchExecutionMetadataNumber(left, "sampleIndex") ?? -1) -
|
|
233
|
-
(readWorkbenchExecutionMetadataNumber(right, "sampleIndex") ?? -1) ||
|
|
234
|
-
(readWorkbenchExecutionMetadataNumber(left, "attemptIndex") ?? -1) -
|
|
235
|
-
(readWorkbenchExecutionMetadataNumber(right, "attemptIndex") ?? -1) ||
|
|
236
|
-
left.id.localeCompare(right.id));
|
|
237
|
-
}
|
|
238
|
-
function compareWorkbenchExecutionEvidence(left, right) {
|
|
239
|
-
return (executionKindOrder(left.kind) - executionKindOrder(right.kind) ||
|
|
240
|
-
String(left.caseId ?? "").localeCompare(String(right.caseId ?? "")) ||
|
|
241
|
-
(left.sampleIndex ?? -1) - (right.sampleIndex ?? -1) ||
|
|
242
|
-
(left.attemptIndex ?? -1) - (right.attemptIndex ?? -1) ||
|
|
243
|
-
String(left.jobIds[0] ?? "").localeCompare(String(right.jobIds[0] ?? "")));
|
|
244
|
-
}
|
|
245
|
-
function traceRoleForPurpose(purpose) {
|
|
246
|
-
if (purpose === "improve") {
|
|
247
|
-
return "improver";
|
|
248
|
-
}
|
|
249
|
-
return "engine";
|
|
250
|
-
}
|
|
251
|
-
function executionKindOrder(kind) {
|
|
252
|
-
if (kind === "improve") {
|
|
253
|
-
return 0;
|
|
254
|
-
}
|
|
255
|
-
if (kind === "attempt") {
|
|
256
|
-
return 1;
|
|
257
|
-
}
|
|
258
|
-
return 3;
|
|
259
|
-
}
|
|
260
|
-
function readExecutionRecencyMs(execution) {
|
|
261
|
-
return (parseTimestampMs(execution.finishedAt) ??
|
|
262
|
-
parseTimestampMs(execution.startedAt) ??
|
|
263
|
-
parseTimestampMs(execution.createdAt) ??
|
|
264
|
-
0);
|
|
265
|
-
}
|
|
266
|
-
function readJobRecencyMs(job) {
|
|
267
|
-
return (parseTimestampMs(job.finishedAt) ??
|
|
268
|
-
parseTimestampMs(job.startedAt) ??
|
|
269
|
-
parseTimestampMs(job.updatedAt) ??
|
|
270
|
-
parseTimestampMs(job.createdAt) ??
|
|
271
|
-
0);
|
|
272
|
-
}
|
|
273
|
-
function minTimestamp(values) {
|
|
274
|
-
const sorted = values
|
|
275
|
-
.filter((value) => typeof value === "string" && value.length > 0)
|
|
276
|
-
.sort();
|
|
277
|
-
return sorted[0] ?? null;
|
|
278
|
-
}
|
|
279
|
-
function maxTimestamp(values) {
|
|
280
|
-
const sorted = values
|
|
281
|
-
.filter((value) => typeof value === "string" && value.length > 0)
|
|
282
|
-
.sort();
|
|
283
|
-
return sorted[sorted.length - 1] ?? null;
|
|
284
|
-
}
|
|
285
|
-
function parseTimestampMs(value) {
|
|
286
|
-
if (!value) {
|
|
287
|
-
return null;
|
|
288
|
-
}
|
|
289
|
-
const parsed = Date.parse(value);
|
|
290
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
291
|
-
}
|
|
292
|
-
function optionalString(key, value) {
|
|
293
|
-
return value ? { [key]: value } : {};
|
|
294
|
-
}
|
|
295
|
-
function optionalNumber(key, value) {
|
|
296
|
-
return value == null ? {} : { [key]: value };
|
|
297
|
-
}
|
|
298
|
-
function asRecord(value) {
|
|
299
|
-
return value && typeof value === "object" && !Array.isArray(value)
|
|
300
|
-
? value
|
|
301
|
-
: null;
|
|
302
|
-
}
|