@agimon-ai/po-workflow 0.0.0-alpha.180 → 0.0.0-alpha.181
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/extensions/server.cjs +209 -71
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.mjs +210 -72
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/{index-BFCOJNHk.d.mts → index-DeGT2yvi.d.mts} +10 -1
- package/dist/index-DeGT2yvi.d.mts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/po-runtime-identity.json +1 -1
- package/dist/{workflowHost-Btb8JrvA.mjs → workflowHost-B-B6BIeD.mjs} +8 -1
- package/dist/workflowHost-B-B6BIeD.mjs.map +1 -0
- package/dist/{workflowHost-BZETMrK7.cjs → workflowHost-d3yIgFif.cjs} +8 -1
- package/dist/workflowHost-d3yIgFif.cjs.map +1 -0
- package/dist/workflowHost.d.mts +1 -1
- package/package.json +10 -10
- package/dist/index-BFCOJNHk.d.mts.map +0 -1
- package/dist/workflowHost-BZETMrK7.cjs.map +0 -1
- package/dist/workflowHost-Btb8JrvA.mjs.map +0 -1
|
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_workflowHost = require("../workflowHost-
|
|
5
|
+
const require_workflowHost = require("../workflowHost-d3yIgFif.cjs");
|
|
6
6
|
const require_contract = require("../contract-D80yV2d-.cjs");
|
|
7
7
|
const require_workflowServices = require("../workflowServices-DYXhIDVE.cjs");
|
|
8
8
|
let _agimon_ai_po_core_platform = require("@agimon-ai/po-core/platform");
|
|
@@ -1477,6 +1477,10 @@ var WorkflowRegistryService = class {
|
|
|
1477
1477
|
async rejectAdmission(intent, errors) {
|
|
1478
1478
|
await this.store.rejectAdmission(this.authorityId, intent.metadata.launcherSessionId, intent.metadata.attemptId, errors);
|
|
1479
1479
|
}
|
|
1480
|
+
recordRef(run) {
|
|
1481
|
+
const record = this.tryRecord(run);
|
|
1482
|
+
return record ? this.runRef(record) : void 0;
|
|
1483
|
+
}
|
|
1480
1484
|
runRef(record) {
|
|
1481
1485
|
const ownerSessionId = record.admission?.ownerSessionId ?? record.env?.PO_SESSION_ID;
|
|
1482
1486
|
return record.runId && ownerSessionId ? {
|
|
@@ -1528,6 +1532,15 @@ var WorkflowRegistryService = class {
|
|
|
1528
1532
|
archivedProgress: state.archivedProgress
|
|
1529
1533
|
} : record;
|
|
1530
1534
|
}
|
|
1535
|
+
/** Every generation sharing the run's lineage, oldest first. A reused run key shares it, so links must be checked. */
|
|
1536
|
+
async readLineageEvidence(runId) {
|
|
1537
|
+
const run = await this.ownRun(runId);
|
|
1538
|
+
if (!run) return [];
|
|
1539
|
+
return (await this.store.listLineage(run.lineageId)).flatMap((generation) => {
|
|
1540
|
+
const record = generation.authorityId === this.authorityId ? this.tryRecord(generation) : void 0;
|
|
1541
|
+
return record ? [record] : [];
|
|
1542
|
+
});
|
|
1543
|
+
}
|
|
1531
1544
|
async listRunEvidence() {
|
|
1532
1545
|
return (await this.store.listRuns({
|
|
1533
1546
|
authorityId: this.authorityId,
|
|
@@ -1656,7 +1669,9 @@ var WorkflowRegistryService = class {
|
|
|
1656
1669
|
await this.removeFileIfExists((0, node_path.resolve)(runDir, PROCEED_FILENAME$1));
|
|
1657
1670
|
}
|
|
1658
1671
|
const runId = (0, node_crypto.randomUUID)();
|
|
1672
|
+
const recoveredFrom = claim && previous ? this.recordRef(previous) : void 0;
|
|
1659
1673
|
const runRecord = {
|
|
1674
|
+
...recoveredFrom ? { recoveredFrom } : {},
|
|
1660
1675
|
activeRepairId: input.activeRepairId,
|
|
1661
1676
|
admission: input.admission,
|
|
1662
1677
|
configuration: input.configuration,
|
|
@@ -4788,7 +4803,7 @@ async function sweepWorkflowRestarts(runtime, activation, notice) {
|
|
|
4788
4803
|
try {
|
|
4789
4804
|
const scope = sessions.scopes?.().find((item) => item.sessionId === id);
|
|
4790
4805
|
const dormant = sessions.dormant?.().find((item) => item.sessionId === id);
|
|
4791
|
-
if (!runtime.workflowHost.durable && isWorkflowSession(scope ?? { sessionContext: { provenance: dormant?.sessionProvenance } })) continue;
|
|
4806
|
+
if (owner.yaml.length === 0 && !runtime.workflowHost.durable && isWorkflowSession(scope ?? { sessionContext: { provenance: dormant?.sessionProvenance } })) continue;
|
|
4792
4807
|
const result = await sessions.revive(id, { automatic: true });
|
|
4793
4808
|
if (signal.aborted) return;
|
|
4794
4809
|
if (result === "paused") notice(`Workflow restart for ${id} is paused by crash recovery. Use Wake to resume.`);
|
|
@@ -6800,6 +6815,8 @@ const WorkflowInspectRunSchema = zod.z.strictObject({
|
|
|
6800
6815
|
runKey: zod.z.string().min(1),
|
|
6801
6816
|
workspace: zod.z.string().min(1)
|
|
6802
6817
|
});
|
|
6818
|
+
/** JSON-only record comparison for approvals; unsupported values must never disappear silently. */
|
|
6819
|
+
const WorkflowRepairRecordJsonSchema = zod.z.record(zod.z.string(), zod.z.json());
|
|
6803
6820
|
const WorkflowRepairRunSchema = zod.z.strictObject({
|
|
6804
6821
|
...WorkflowInspectRunSchema.shape,
|
|
6805
6822
|
stage: require_workflowHost.WorkflowStageSchema,
|
|
@@ -10339,13 +10356,16 @@ function createStepExecutor(dependencies) {
|
|
|
10339
10356
|
let failure;
|
|
10340
10357
|
try {
|
|
10341
10358
|
child.signal.throwIfAborted();
|
|
10342
|
-
const env =
|
|
10343
|
-
|
|
10344
|
-
|
|
10345
|
-
|
|
10346
|
-
|
|
10347
|
-
|
|
10348
|
-
|
|
10359
|
+
const env = {
|
|
10360
|
+
...Object.fromEntries(Object.entries(workflow.env ?? {}).map(([key, value]) => [key, String(value)])),
|
|
10361
|
+
...Object.fromEntries([
|
|
10362
|
+
"WORKFLOW_RUN_ID",
|
|
10363
|
+
"WORKFLOW_RUN_KEY",
|
|
10364
|
+
"WORKFLOW_RUN_DIR",
|
|
10365
|
+
"WORKFLOW_WORKSPACE",
|
|
10366
|
+
"WORKFLOW_NAME"
|
|
10367
|
+
].flatMap((key) => child.context.jobEnvironment[key] === void 0 ? [] : [[key, child.context.jobEnvironment[key]]]))
|
|
10368
|
+
};
|
|
10349
10369
|
env.WORKFLOW_PHASE = "job";
|
|
10350
10370
|
const admitIdentity = createJobIdentityAdmission({
|
|
10351
10371
|
allocation: child.context.allocation,
|
|
@@ -13100,7 +13120,7 @@ async function streamArtifact(runtime, resolved, requested, rangeHeader, downloa
|
|
|
13100
13120
|
* This package's API, mounted by a session with its runtime's `launch` and by
|
|
13101
13121
|
* the hub without one.
|
|
13102
13122
|
*/
|
|
13103
|
-
function createWorkflowApi(runtime, launch) {
|
|
13123
|
+
function createWorkflowApi(runtime, launch, resolveHome) {
|
|
13104
13124
|
return {
|
|
13105
13125
|
basePath: WORKFLOW_API_BASE_PATH,
|
|
13106
13126
|
start(context) {
|
|
@@ -13132,7 +13152,7 @@ function createWorkflowApi(runtime, launch) {
|
|
|
13132
13152
|
const pathname = new URL(request.url).pathname;
|
|
13133
13153
|
const operation = Object.entries(routes).find(([, route]) => route.method === request.method && new RegExp(`^${route.path.replace(":name{.+}", ".+").replace(/:[a-zA-Z]+/gu, "[^/]+")}$`, "u").test(pathname))?.[0] ?? "other";
|
|
13134
13154
|
return telemetry.runInSpan("po_workflow.request", { operation }, async () => {
|
|
13135
|
-
const locations = await workflowRunLocations(runtime, [context.sessionId === void 0 || homeDirectory === void 0 ? new WorkflowRegistryService(runtime).authorityId : sessionWorkflowHome(environment, homeDirectory, context.sessionId)]);
|
|
13155
|
+
const locations = await workflowRunLocations(runtime, [context.sessionId === void 0 || homeDirectory === void 0 ? new WorkflowRegistryService(runtime).authorityId : await resolveHome?.(context.sessionId) ?? sessionWorkflowHome(environment, homeDirectory, context.sessionId)]);
|
|
13136
13156
|
const url = new URL(request.url);
|
|
13137
13157
|
const stepRuns = request.method === routes.stepRuns.method ? STEP_RUNS_PATH.exec(url.pathname) : null;
|
|
13138
13158
|
if (stepRuns !== null) {
|
|
@@ -13171,6 +13191,60 @@ function createWorkflowApi(runtime, launch) {
|
|
|
13171
13191
|
};
|
|
13172
13192
|
}
|
|
13173
13193
|
//#endregion
|
|
13194
|
+
//#region src/services/workflowOutcome/index.ts
|
|
13195
|
+
const PENDING = { pending: true };
|
|
13196
|
+
const MAX_HOPS = 64;
|
|
13197
|
+
const sameRef = (a, b) => a !== void 0 && a.runId === b.runId && a.runKey === b.runKey && a.ownerSessionId === b.ownerSessionId && a.registryWorkspace === b.registryWorkspace;
|
|
13198
|
+
/** Parked on approval or awaiting automatic recovery: the run will continue, so nothing is final. */
|
|
13199
|
+
async function settled(registry, record) {
|
|
13200
|
+
if (record.stage === "running") return void 0;
|
|
13201
|
+
if (record.stage === "completed") {
|
|
13202
|
+
if (record.outcome === "success") return "succeeded";
|
|
13203
|
+
if (record.outcome === "skipped") return "cancelled";
|
|
13204
|
+
if (record.outcome === "failed") return "failed";
|
|
13205
|
+
return;
|
|
13206
|
+
}
|
|
13207
|
+
const stopped = record.runId !== void 0 && await registry.hasStopRequest({ runId: record.runId });
|
|
13208
|
+
if (record.outcome === "failed") return "failed";
|
|
13209
|
+
if (record.outcome === "interrupted") {
|
|
13210
|
+
if (stopped) return "interrupted";
|
|
13211
|
+
return record.resume !== void 0 || record.wait !== void 0 ? void 0 : "interrupted";
|
|
13212
|
+
}
|
|
13213
|
+
return stopped ? "interrupted" : void 0;
|
|
13214
|
+
}
|
|
13215
|
+
/**
|
|
13216
|
+
* Outcome-only evidence for a launch receipt, read from the host's durable store. The receipt (exact run ID,
|
|
13217
|
+
* owner, workspace and run key) is the capability. It follows only host-written recovery links naming the exact
|
|
13218
|
+
* prior run, and answers `pending` for anything it cannot prove.
|
|
13219
|
+
*/
|
|
13220
|
+
function createWorkflowOutcomeReader({ registries }) {
|
|
13221
|
+
return { async read(receipt) {
|
|
13222
|
+
for (const registry of await registries(receipt.runId)) {
|
|
13223
|
+
const first = await registry.readRunEvidence(receipt.runId);
|
|
13224
|
+
if (!first) continue;
|
|
13225
|
+
if (!sameRef(registry.runRef(first), receipt)) return PENDING;
|
|
13226
|
+
const lineage = await registry.readLineageEvidence(receipt.runId);
|
|
13227
|
+
let current = first;
|
|
13228
|
+
for (let hop = 0; hop < MAX_HOPS; hop += 1) {
|
|
13229
|
+
const ref = registry.runRef(current);
|
|
13230
|
+
if (!ref) return PENDING;
|
|
13231
|
+
const next = lineage.filter((candidate) => {
|
|
13232
|
+
const own = registry.runRef(candidate);
|
|
13233
|
+
return own !== void 0 && own.runId !== ref.runId && own.ownerSessionId === ref.ownerSessionId && own.registryWorkspace === ref.registryWorkspace && own.runKey === ref.runKey && sameRef(candidate.recoveredFrom ?? candidate.admission?.previousRun, ref);
|
|
13234
|
+
});
|
|
13235
|
+
if (next.length > 1) return PENDING;
|
|
13236
|
+
if (next.length === 0) {
|
|
13237
|
+
const outcome = await settled(registry, current);
|
|
13238
|
+
return outcome === void 0 ? PENDING : { outcome };
|
|
13239
|
+
}
|
|
13240
|
+
current = next[0];
|
|
13241
|
+
}
|
|
13242
|
+
return PENDING;
|
|
13243
|
+
}
|
|
13244
|
+
return PENDING;
|
|
13245
|
+
} };
|
|
13246
|
+
}
|
|
13247
|
+
//#endregion
|
|
13174
13248
|
//#region src/services/workflowsHubChannel/index.ts
|
|
13175
13249
|
function isWorkflowRunsPayload(value) {
|
|
13176
13250
|
return typeof value === "object" && value !== null && Array.isArray(value.runs);
|
|
@@ -14264,6 +14338,13 @@ var index_server_default$1 = (async ({ host, context }) => {
|
|
|
14264
14338
|
workflowHost,
|
|
14265
14339
|
workflowStore: () => store
|
|
14266
14340
|
});
|
|
14341
|
+
if (host.scope === "host") {
|
|
14342
|
+
const admitted = runtime;
|
|
14343
|
+
injected.provide(_agimon_ai_po_core_workflow.PO_WORKFLOW_OUTCOME_SERVICE, createWorkflowOutcomeReader({ registries: async (runId) => {
|
|
14344
|
+
const run = await admitted.workflowStore?.()?.readRun(runId);
|
|
14345
|
+
return run ? [new WorkflowRegistryService(admitted, run.authorityId)] : [];
|
|
14346
|
+
} }));
|
|
14347
|
+
}
|
|
14267
14348
|
});
|
|
14268
14349
|
});
|
|
14269
14350
|
await provider.await();
|
|
@@ -18551,6 +18632,18 @@ function createWorkflowOperations(options) {
|
|
|
18551
18632
|
}, { helpActive: options.isHelpActive });
|
|
18552
18633
|
});
|
|
18553
18634
|
},
|
|
18635
|
+
/** Resolve the approval target through the same failed-run lookup used by abandon. */
|
|
18636
|
+
abandonTarget(parameters, signal) {
|
|
18637
|
+
const input = WorkflowRunSelectorSchema.parse(parameters);
|
|
18638
|
+
return perform("abandonTarget", false, signal, async () => {
|
|
18639
|
+
const { record } = await failedRun(input);
|
|
18640
|
+
return {
|
|
18641
|
+
runKey: record.runKey,
|
|
18642
|
+
workspace: record.workspace,
|
|
18643
|
+
job: record.failedJob ?? record.job
|
|
18644
|
+
};
|
|
18645
|
+
});
|
|
18646
|
+
},
|
|
18554
18647
|
/**
|
|
18555
18648
|
* Gives up a failed run that holds a lock: its coordinator releases the lock and the run can never be
|
|
18556
18649
|
* recovered. The only way to free a held lock without recovering, so a failed run never blocks its job.
|
|
@@ -18788,61 +18881,74 @@ function recordedResult(member, value) {
|
|
|
18788
18881
|
details: value
|
|
18789
18882
|
};
|
|
18790
18883
|
}
|
|
18791
|
-
/**
|
|
18792
|
-
function
|
|
18793
|
-
|
|
18794
|
-
|
|
18795
|
-
|
|
18796
|
-
|
|
18884
|
+
/** Refuse facts the gate would clip rather than silently hiding part of a change. */
|
|
18885
|
+
function approvalDetail(label, value) {
|
|
18886
|
+
if (label.length > 60 || value.length > 300) throw new Error("Workflow approval detail is too long to represent safely.");
|
|
18887
|
+
return {
|
|
18888
|
+
label,
|
|
18889
|
+
value
|
|
18797
18890
|
};
|
|
18798
|
-
|
|
18799
|
-
|
|
18800
|
-
|
|
18801
|
-
|
|
18802
|
-
|
|
18803
|
-
|
|
18804
|
-
|
|
18891
|
+
}
|
|
18892
|
+
/** Keep the stored replacement identical to the record validation execution uses. */
|
|
18893
|
+
function resolveRepair(input) {
|
|
18894
|
+
const repair = WorkflowRepairRunSchema.parse(input);
|
|
18895
|
+
if (repair.record !== void 0) {
|
|
18896
|
+
WorkflowRepairRecordJsonSchema.parse(repair.record);
|
|
18897
|
+
repair.record = require_workflowHost.WorkflowRunRecordSchema.parse(repair.record);
|
|
18898
|
+
}
|
|
18899
|
+
return repair;
|
|
18900
|
+
}
|
|
18901
|
+
/** Show each changed field, including fields removed by a full record replacement. */
|
|
18902
|
+
async function describeRepair(input, operations) {
|
|
18903
|
+
const repair = resolveRepair(input);
|
|
18904
|
+
if (repair.fix !== void 0 && repair.fix !== null && repair.fix.length > 65536) throw new Error("Replacement fix.md exceeds the approval content limit.");
|
|
18905
|
+
if (repair.fix !== void 0 && repair.fix !== null && repair.remove?.includes("fix.md")) throw new Error("Cannot approve both replacing and removing fix.md.");
|
|
18906
|
+
const details = [
|
|
18907
|
+
approvalDetail("Run", repair.runKey),
|
|
18908
|
+
approvalDetail("Workspace", repair.workspace),
|
|
18909
|
+
approvalDetail("Stage", repair.stage),
|
|
18910
|
+
approvalDetail("Reason", repair.reason)
|
|
18911
|
+
];
|
|
18912
|
+
if (repair.record !== void 0) {
|
|
18913
|
+
const states = (await operations.inspectRun({
|
|
18914
|
+
runKey: repair.runKey,
|
|
18915
|
+
workspace: repair.workspace
|
|
18916
|
+
})).filter((state) => state.stage === repair.stage);
|
|
18917
|
+
if (states.length !== 1 || states[0].revision !== repair.revision) throw new Error("Repair target changed or is ambiguous; inspect it again.");
|
|
18918
|
+
const raw = states[0].files["run.json"];
|
|
18919
|
+
if (raw === void 0) throw new Error("Cannot safely compare a missing run record.");
|
|
18920
|
+
const before = WorkflowRepairRecordJsonSchema.parse(JSON.parse(raw));
|
|
18921
|
+
const after = WorkflowRepairRecordJsonSchema.parse(repair.record);
|
|
18922
|
+
for (const key of /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])) {
|
|
18923
|
+
const oldValue = Object.hasOwn(before, key) ? JSON.stringify(before[key]) : "(not set)";
|
|
18924
|
+
const newValue = Object.hasOwn(after, key) ? JSON.stringify(after[key]) : "(not set)";
|
|
18925
|
+
if (oldValue !== newValue) details.push(approvalDetail(key, `${oldValue} → ${newValue}`));
|
|
18926
|
+
}
|
|
18927
|
+
}
|
|
18928
|
+
if (repair.fix !== void 0) details.push(approvalDetail("fix.md", repair.fix === null ? "Remove" : "Replace with the exact content below"));
|
|
18929
|
+
for (const file of repair.remove ?? []) details.push(approvalDetail(file, "Remove"));
|
|
18930
|
+
if (repair.force) details.push(approvalDetail("Force", "Allow repair even if the run process is still alive."));
|
|
18931
|
+
if (details.length > 12) throw new Error("Too many repair changes to represent safely in an approval.");
|
|
18805
18932
|
return {
|
|
18933
|
+
source: "Workflow",
|
|
18806
18934
|
title: clip(`Repair workflow run ${repair.runKey}`, 120),
|
|
18807
|
-
summary:
|
|
18808
|
-
details
|
|
18809
|
-
|
|
18810
|
-
label: "Reason",
|
|
18811
|
-
value: clip(repair.reason, 300)
|
|
18812
|
-
},
|
|
18813
|
-
{
|
|
18814
|
-
label: "Workspace",
|
|
18815
|
-
value: clip(repair.workspace, 300)
|
|
18816
|
-
},
|
|
18817
|
-
{
|
|
18818
|
-
label: "Stage",
|
|
18819
|
-
value: nextStage === repair.stage ? repair.stage : `${repair.stage} → ${nextStage}`
|
|
18820
|
-
},
|
|
18821
|
-
...repair.fix ? [{
|
|
18822
|
-
label: "fix.md",
|
|
18823
|
-
value: clip(repair.fix, 300)
|
|
18824
|
-
}] : [],
|
|
18825
|
-
...repair.force ? [{
|
|
18826
|
-
label: "Force",
|
|
18827
|
-
value: "Repairs even though the run process is still alive."
|
|
18828
|
-
}] : []
|
|
18829
|
-
]
|
|
18935
|
+
summary: "Repair the selected run state and apply the changes listed below. The repair requires the inspected revision to remain unchanged.",
|
|
18936
|
+
details,
|
|
18937
|
+
...typeof repair.fix === "string" ? { content: repair.fix } : {}
|
|
18830
18938
|
};
|
|
18831
18939
|
}
|
|
18832
18940
|
/** What the person approves when a failed run is given up. */
|
|
18833
|
-
function describeAbandon(input) {
|
|
18834
|
-
const
|
|
18835
|
-
if (!parsed.success) return {
|
|
18836
|
-
title: "Abandon a workflow run (invalid request)",
|
|
18837
|
-
summary: clip(parsed.error.message, 600)
|
|
18838
|
-
};
|
|
18941
|
+
async function describeAbandon(input, operations) {
|
|
18942
|
+
const target = await operations.abandonTarget(input);
|
|
18839
18943
|
return {
|
|
18840
|
-
|
|
18841
|
-
|
|
18842
|
-
|
|
18843
|
-
|
|
18844
|
-
|
|
18845
|
-
|
|
18944
|
+
source: "Workflow",
|
|
18945
|
+
title: clip(`Abandon workflow run ${target.runKey}`, 120),
|
|
18946
|
+
summary: "Give up this failed run and ask its coordinator to release its lock. The run can never be recovered afterwards.",
|
|
18947
|
+
details: [
|
|
18948
|
+
approvalDetail("Run", target.runKey),
|
|
18949
|
+
approvalDetail("Workspace", target.workspace),
|
|
18950
|
+
approvalDetail("Job", target.job ?? "No job recorded")
|
|
18951
|
+
]
|
|
18846
18952
|
};
|
|
18847
18953
|
}
|
|
18848
18954
|
/** Record fields that bind a run to a person or policy; changing them always needs that person. */
|
|
@@ -18856,24 +18962,38 @@ function touchesIdentity(input) {
|
|
|
18856
18962
|
return typeof record === "object" && record !== null && IDENTITY_RECORD_KEYS.some((key) => Object.hasOwn(record, key));
|
|
18857
18963
|
}
|
|
18858
18964
|
/** The approvals the namespace members and their direct-tool actions share. */
|
|
18859
|
-
function workflowApprovalPolicies(isHelpActive) {
|
|
18965
|
+
function workflowApprovalPolicies(isHelpActive, operations) {
|
|
18860
18966
|
return {
|
|
18861
18967
|
repairRun: {
|
|
18862
18968
|
requirement: "human",
|
|
18863
|
-
|
|
18969
|
+
resolve: ([input]) => [resolveRepair(input)],
|
|
18970
|
+
describe: (input) => describeRepair(input, operations),
|
|
18864
18971
|
applies: (input) => !isHelpActive() || touchesIdentity(input)
|
|
18865
18972
|
},
|
|
18866
18973
|
abandon: {
|
|
18867
18974
|
requirement: "human",
|
|
18868
|
-
|
|
18975
|
+
async resolve([input]) {
|
|
18976
|
+
const { runKey, workspace } = await operations.abandonTarget(input);
|
|
18977
|
+
return [{
|
|
18978
|
+
runKey,
|
|
18979
|
+
workspace
|
|
18980
|
+
}];
|
|
18981
|
+
},
|
|
18982
|
+
describe: (input) => describeAbandon(input, operations)
|
|
18869
18983
|
},
|
|
18870
18984
|
deleteDefinition: {
|
|
18871
18985
|
requirement: "human",
|
|
18872
18986
|
describe(input) {
|
|
18873
18987
|
const { source, key } = WorkflowDeleteDefinitionSchema.parse(input);
|
|
18874
18988
|
return {
|
|
18989
|
+
source: "Workflow",
|
|
18875
18990
|
title: "Delete a stored workflow definition",
|
|
18876
|
-
summary:
|
|
18991
|
+
summary: "Delete one stored workflow definition. Repository files and run history are unchanged.",
|
|
18992
|
+
details: [
|
|
18993
|
+
approvalDetail("Source", source),
|
|
18994
|
+
approvalDetail("Definition", key),
|
|
18995
|
+
approvalDetail("Recovery", "This operation removes the file without creating a backup or providing an undo.")
|
|
18996
|
+
]
|
|
18877
18997
|
};
|
|
18878
18998
|
}
|
|
18879
18999
|
}
|
|
@@ -18886,7 +19006,7 @@ function createWorkflowNamespace(options) {
|
|
|
18886
19006
|
const childNames = new Set(Object.keys(childMethods));
|
|
18887
19007
|
const stepMethods = createWorkflowStepMethods(options.outcome);
|
|
18888
19008
|
const stepNames = new Set(Object.keys(stepMethods));
|
|
18889
|
-
const { deleteDefinition, ...otherApprovals } = workflowApprovalPolicies(isHelpActive);
|
|
19009
|
+
const { deleteDefinition, ...otherApprovals } = workflowApprovalPolicies(isHelpActive, options.operations);
|
|
18890
19010
|
const declarations = [
|
|
18891
19011
|
...options.storedDefinitions ? [WORKFLOW_DELETE_DEFINITION_DECLARATION] : [],
|
|
18892
19012
|
...Object.keys(childMethods).map((name) => WORKFLOW_CHILD_DECLARATIONS[name]),
|
|
@@ -19081,7 +19201,8 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
|
|
|
19081
19201
|
const environment = host.context.environment;
|
|
19082
19202
|
const homeDirectory = runtime.homeDirectory;
|
|
19083
19203
|
if (homeDirectory === void 0) throw new Error("Workflow storage requires the admitted host home directory.");
|
|
19084
|
-
|
|
19204
|
+
/** Reconstructed until onStart replaces it with the effective artifact root's workflow folder. */
|
|
19205
|
+
let ownHome = sessionWorkflowHome(environment, homeDirectory, host.context.sessionId);
|
|
19085
19206
|
let registryObserver;
|
|
19086
19207
|
let artifactStorage;
|
|
19087
19208
|
let serverScope;
|
|
@@ -19934,7 +20055,9 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
|
|
|
19934
20055
|
waitForReadiness,
|
|
19935
20056
|
snapshot,
|
|
19936
20057
|
controls: controlsByHome,
|
|
19937
|
-
ownHome
|
|
20058
|
+
get ownHome() {
|
|
20059
|
+
return ownHome;
|
|
20060
|
+
},
|
|
19938
20061
|
async registries() {
|
|
19939
20062
|
return new Map((await knownLocations()).map(({ homeDir }) => [featureFor(homeDir).registry, homeDir]));
|
|
19940
20063
|
},
|
|
@@ -20119,7 +20242,9 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
|
|
|
20119
20242
|
const policies = /* @__PURE__ */ new Map();
|
|
20120
20243
|
const admissions = createWorkflowAdmissions({
|
|
20121
20244
|
sessionId: host.context.sessionId,
|
|
20122
|
-
journal
|
|
20245
|
+
get journal() {
|
|
20246
|
+
return featureFor(ownHome).registry;
|
|
20247
|
+
},
|
|
20123
20248
|
registries: admissionRegistries,
|
|
20124
20249
|
validate: validateAdmission,
|
|
20125
20250
|
async requirements(definition, options = {}) {
|
|
@@ -20190,11 +20315,15 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
|
|
|
20190
20315
|
api: [createWorkflowApi(runtime, async (parameters) => {
|
|
20191
20316
|
await waitForReadiness();
|
|
20192
20317
|
return launchFromApi(parameters);
|
|
20318
|
+
}, async (sessionId) => {
|
|
20319
|
+
const root = await artifactStorage?.rootForSession(sessionId, environment);
|
|
20320
|
+
return root === void 0 ? void 0 : (0, node_path.join)(root, "workflow");
|
|
20193
20321
|
})],
|
|
20194
20322
|
async onStart() {
|
|
20195
20323
|
const artifactRoot = await artifactStorage?.rootForSession(host.context.sessionId, environment);
|
|
20196
20324
|
if (artifactRoot !== void 0) {
|
|
20197
20325
|
const registryHome = (0, node_path.join)(artifactRoot, "workflow");
|
|
20326
|
+
ownHome = registryHome;
|
|
20198
20327
|
feature = featureFor(registryHome);
|
|
20199
20328
|
launcher = launcherFor(registryHome);
|
|
20200
20329
|
}
|
|
@@ -20517,7 +20646,7 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
|
|
|
20517
20646
|
],
|
|
20518
20647
|
parameters: zod.z.toJSONSchema(workflowToolsInputSchema),
|
|
20519
20648
|
executionMode: "serial",
|
|
20520
|
-
approval: workflowToolsApproval(isHelpActive),
|
|
20649
|
+
approval: workflowToolsApproval(isHelpActive, operations),
|
|
20521
20650
|
async execute(_toolCallId, parameters, signal, _onUpdate, context) {
|
|
20522
20651
|
return operationResult(async () => {
|
|
20523
20652
|
const input = workflowToolsInputSchema.parse(parameters);
|
|
@@ -20548,7 +20677,7 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
|
|
|
20548
20677
|
parameters: zod.z.toJSONSchema(WorkflowDeleteDefinitionSchema),
|
|
20549
20678
|
mainAgentOnly: true,
|
|
20550
20679
|
executionMode: "serial",
|
|
20551
|
-
approval: workflowApprovalPolicies(isHelpActive).deleteDefinition,
|
|
20680
|
+
approval: workflowApprovalPolicies(isHelpActive, operations).deleteDefinition,
|
|
20552
20681
|
async execute(_toolCallId, parameters, signal) {
|
|
20553
20682
|
return operationResult(() => operations.deleteDefinition(parameters, signal));
|
|
20554
20683
|
}
|
|
@@ -20684,8 +20813,8 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
|
|
|
20684
20813
|
};
|
|
20685
20814
|
}
|
|
20686
20815
|
/** The namespace's approvals, keyed by the workflow_tools action that calls the same member. */
|
|
20687
|
-
function workflowToolsApproval(isHelpActive) {
|
|
20688
|
-
const policies = workflowApprovalPolicies(isHelpActive);
|
|
20816
|
+
function workflowToolsApproval(isHelpActive, operations) {
|
|
20817
|
+
const policies = workflowApprovalPolicies(isHelpActive, operations);
|
|
20689
20818
|
const policyOf = (input) => {
|
|
20690
20819
|
const action = input?.action;
|
|
20691
20820
|
const member = action === void 0 ? void 0 : WORKFLOW_TOOLS_MEMBER_ACTIONS[action];
|
|
@@ -20697,6 +20826,15 @@ function workflowToolsApproval(isHelpActive) {
|
|
|
20697
20826
|
};
|
|
20698
20827
|
return {
|
|
20699
20828
|
requirement: "human",
|
|
20829
|
+
async resolve([input]) {
|
|
20830
|
+
const policy = policyOf(input);
|
|
20831
|
+
if (!policy) return [input];
|
|
20832
|
+
const [resolved] = await policy.resolve([memberInput(input)]);
|
|
20833
|
+
return [{
|
|
20834
|
+
...resolved,
|
|
20835
|
+
action: input.action
|
|
20836
|
+
}];
|
|
20837
|
+
},
|
|
20700
20838
|
describe: (input) => policyOf(input).describe(memberInput(input)),
|
|
20701
20839
|
applies: (input) => {
|
|
20702
20840
|
const policy = policyOf(input);
|