@agimon-ai/po-workflow 0.0.0-alpha.84 → 0.0.0-alpha.86
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.
|
@@ -4083,7 +4083,6 @@ function createWorkflowServices() {
|
|
|
4083
4083
|
registerPolicy(session, coordinator, callback, options) {
|
|
4084
4084
|
if (disposed || !session || !coordinator) throw new Error("Workflow policy registration is unavailable.");
|
|
4085
4085
|
const key = JSON.stringify([session, coordinator]);
|
|
4086
|
-
if (policies.has(key)) throw new Error("Workflow policy coordinator is already registered for this session.");
|
|
4087
4086
|
const keys = new Set(options.environmentKeys);
|
|
4088
4087
|
for (const name of keys) if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name) || /^(PO_|WORKFLOW_)/.test(name)) throw new Error("Protected workflow policy environment key.");
|
|
4089
4088
|
const generation = (0, node_crypto.randomUUID)();
|
|
@@ -4130,7 +4129,7 @@ function createWorkflowServices() {
|
|
|
4130
4129
|
return policies.get(key)?.generation === policy.generation ? "delivered" : "unavailable";
|
|
4131
4130
|
},
|
|
4132
4131
|
registerOwner(session, owner) {
|
|
4133
|
-
if (disposed
|
|
4132
|
+
if (disposed) throw new Error("Workflow services are disposed.");
|
|
4134
4133
|
const generation = (0, node_crypto.randomUUID)();
|
|
4135
4134
|
owners.set(session, {
|
|
4136
4135
|
generation,
|
|
@@ -4212,6 +4211,7 @@ function createWorkflowServices() {
|
|
|
4212
4211
|
for (const entry of listeners) if (entry.runId === state.run.runId && read(entry.session, entry.runId) !== void 0) entry.listener(structuredClone(runs.get(state.run.runId).state));
|
|
4213
4212
|
},
|
|
4214
4213
|
withdraw(owner) {
|
|
4214
|
+
if (owners.has(owner)) return;
|
|
4215
4215
|
for (const [id, run] of runs) if (run.owner === owner) runs.delete(id);
|
|
4216
4216
|
for (const entry of listeners) if (entry.session === owner) listeners.delete(entry);
|
|
4217
4217
|
},
|
|
@@ -7186,6 +7186,7 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
|
|
|
7186
7186
|
*/
|
|
7187
7187
|
const launchIn = async (owner, parameters) => {
|
|
7188
7188
|
if (serverHost.context.requestApi === void 0) return textResult(`Error: this host cannot reach session ${owner} to launch the workflow there.`, true);
|
|
7189
|
+
watchOwner(owner);
|
|
7189
7190
|
const response = await serverHost.context.requestApi({
|
|
7190
7191
|
scope: "session",
|
|
7191
7192
|
sessionId: owner
|
|
@@ -7479,11 +7480,24 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
|
|
|
7479
7480
|
...(savedLocations ?? []).map((location) => location.homeDir)
|
|
7480
7481
|
])].map((home) => featureFor(home).registry);
|
|
7481
7482
|
};
|
|
7483
|
+
const settlementDeliveries = /* @__PURE__ */ new Map();
|
|
7482
7484
|
settlement = require_RecoverWorkflowService.createWorkflowSettlement({
|
|
7483
7485
|
sessionId: host.context.sessionId,
|
|
7484
7486
|
signal: startupAbort.signal,
|
|
7485
7487
|
registries: admissionRegistries,
|
|
7486
|
-
settle: async (request) =>
|
|
7488
|
+
settle: async (request) => {
|
|
7489
|
+
const delivery = publicServices ? await publicServices.settle(request) : "unavailable";
|
|
7490
|
+
if (settlementDeliveries.get(request.run.runId) !== delivery) {
|
|
7491
|
+
settlementDeliveries.set(request.run.runId, delivery);
|
|
7492
|
+
telemetry.recordEvent("po_workflow.settlement_delivery", {
|
|
7493
|
+
name: request.binding.association.coordinator,
|
|
7494
|
+
outcome: request.outcome,
|
|
7495
|
+
status: delivery,
|
|
7496
|
+
attached: publicServices !== void 0
|
|
7497
|
+
});
|
|
7498
|
+
}
|
|
7499
|
+
return delivery;
|
|
7500
|
+
},
|
|
7487
7501
|
report: reportLifecycleFailure
|
|
7488
7502
|
});
|
|
7489
7503
|
const rehydrateRun = async (id) => {
|
|
@@ -7600,9 +7614,7 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
|
|
|
7600
7614
|
registries: admissionRegistries,
|
|
7601
7615
|
validate: validateAdmission,
|
|
7602
7616
|
registerPolicy(coordinator, callback, options) {
|
|
7603
|
-
|
|
7604
|
-
if (!publicServices) throw new Error("Workflow policy registration is unavailable.");
|
|
7605
|
-
if (policies.has(coordinator)) throw new Error("Workflow policy coordinator is already registered for this session.");
|
|
7617
|
+
if (disposed) throw new Error(RUNTIME_DISPOSED_MESSAGE);
|
|
7606
7618
|
const registration = {
|
|
7607
7619
|
callback,
|
|
7608
7620
|
options: {
|
|
@@ -7610,11 +7622,15 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
|
|
|
7610
7622
|
environmentKeys: [...options.environmentKeys]
|
|
7611
7623
|
}
|
|
7612
7624
|
};
|
|
7613
|
-
registration.binding = {
|
|
7625
|
+
if (publicServices) registration.binding = {
|
|
7614
7626
|
service: publicServices,
|
|
7615
7627
|
handle: publicServices.registerPolicy(host.context.sessionId, coordinator, callback, registration.options)
|
|
7616
7628
|
};
|
|
7617
7629
|
policies.set(coordinator, registration);
|
|
7630
|
+
telemetry.recordEvent("po_workflow.policy_registered", {
|
|
7631
|
+
name: coordinator,
|
|
7632
|
+
state: registration.binding ? "bound" : "waiting"
|
|
7633
|
+
});
|
|
7618
7634
|
queueMicrotask(deliverSettlements);
|
|
7619
7635
|
return { dispose() {
|
|
7620
7636
|
registration.binding?.handle.dispose();
|
|
@@ -7629,6 +7645,7 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
|
|
|
7629
7645
|
const ownerId = record.admission?.ownerSessionId ?? request.previousRun.ownerSessionId;
|
|
7630
7646
|
const owner = publicServices?.owner(ownerId);
|
|
7631
7647
|
if (!owner) throw new Error("Workflow recovery owner is unavailable; admission remains pending.");
|
|
7648
|
+
watchOwner(ownerId);
|
|
7632
7649
|
await owner.recover(request.previousRun, request.options?.runner, admission);
|
|
7633
7650
|
} else {
|
|
7634
7651
|
const input = await admissionInput(request);
|
|
@@ -7636,6 +7653,7 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
|
|
|
7636
7653
|
if (ownerId !== void 0) {
|
|
7637
7654
|
const owner = publicServices?.owner(ownerId);
|
|
7638
7655
|
if (!owner) throw new Error("Workflow launch owner is unavailable; admission remains pending.");
|
|
7656
|
+
watchOwner(ownerId);
|
|
7639
7657
|
await owner.launch(input, {
|
|
7640
7658
|
...admission,
|
|
7641
7659
|
ownerSessionId: ownerId
|
|
@@ -7836,6 +7854,7 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
|
|
|
7836
7854
|
service,
|
|
7837
7855
|
handle: service.registerPolicy(host.context.sessionId, coordinator, registration.callback, registration.options)
|
|
7838
7856
|
};
|
|
7857
|
+
telemetry.recordEvent("po_workflow.policies_bound", { size: policies.size });
|
|
7839
7858
|
queueMicrotask(deliverSettlements);
|
|
7840
7859
|
} catch (error) {
|
|
7841
7860
|
detach();
|