@agimon-ai/po-workflow 0.0.0-alpha.2 → 0.0.0-alpha.4
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 +1 -1
- package/dist/apiContracts.cjs +2 -2
- package/dist/apiContracts.cjs.map +1 -1
- package/dist/apiContracts.mjs +2 -2
- package/dist/apiContracts.mjs.map +1 -1
- package/dist/extensions/native.mjs +14 -0
- package/dist/extensions/native.mjs.map +1 -1
- package/dist/extensions/server.cjs +110 -35
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts +1 -1
- package/dist/extensions/server.mjs +118 -43
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +151 -151
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1 -2
- package/llms.txt +2 -2
- package/package.json +20 -19
|
@@ -207,9 +207,9 @@ function registerRunProvider(ctx) {
|
|
|
207
207
|
let items = [];
|
|
208
208
|
let provider;
|
|
209
209
|
let disposed = false;
|
|
210
|
-
ctx.inject([_agimon_ai_po_core_backgroundWork.
|
|
210
|
+
ctx.inject([_agimon_ai_po_core_backgroundWork.PO_BACKGROUND_WORK_SERVICE], (serviceContext) => {
|
|
211
211
|
if (disposed) return void 0;
|
|
212
|
-
const service = (0, _agimon_ai_po_core_backgroundWork.
|
|
212
|
+
const service = (0, _agimon_ai_po_core_backgroundWork.readPoBackgroundWorkService)(serviceContext);
|
|
213
213
|
if (!service) return void 0;
|
|
214
214
|
const registration = service.register({
|
|
215
215
|
provider: PROVIDER_NAME,
|
|
@@ -969,14 +969,14 @@ const PENDING_LINE_LIMIT = 500;
|
|
|
969
969
|
const STOP_TIMEOUT_MS = 1e4;
|
|
970
970
|
const SESSION_CLOSED_REASON = "The session that runs this workflow closed.";
|
|
971
971
|
const RUNNING_STAGE$1 = "running";
|
|
972
|
-
const LAUNCH_REQUESTED_EVENT = "
|
|
973
|
-
const RUN_STARTED_EVENT = "
|
|
974
|
-
const RUN_FINISHED_EVENT = "
|
|
975
|
-
const RUN_FAILED_EVENT = "
|
|
976
|
-
const ENGINE_ERROR_EVENT = "
|
|
977
|
-
const ENGINE_WARNING_EVENT = "
|
|
978
|
-
const RUN_LOG_FAILED_EVENT = "
|
|
979
|
-
const RUN_STOP_FAILED_EVENT = "
|
|
972
|
+
const LAUNCH_REQUESTED_EVENT = "po_workflow.launch_requested";
|
|
973
|
+
const RUN_STARTED_EVENT = "po_workflow.run_started";
|
|
974
|
+
const RUN_FINISHED_EVENT = "po_workflow.run_finished";
|
|
975
|
+
const RUN_FAILED_EVENT = "po_workflow.run_failed";
|
|
976
|
+
const ENGINE_ERROR_EVENT = "po_workflow.engine_error";
|
|
977
|
+
const ENGINE_WARNING_EVENT = "po_workflow.engine_warning";
|
|
978
|
+
const RUN_LOG_FAILED_EVENT = "po_workflow.run_log_failed";
|
|
979
|
+
const RUN_STOP_FAILED_EVENT = "po_workflow.run_stop_failed";
|
|
980
980
|
function delay$1(ms) {
|
|
981
981
|
return new Promise((settle) => {
|
|
982
982
|
setTimeout(settle, ms).unref?.();
|
|
@@ -1208,12 +1208,12 @@ const BUSY_RETRY_MS = 2e3;
|
|
|
1208
1208
|
const RELEASE_TIMEOUT_MS = 1e4;
|
|
1209
1209
|
/** What the runtime says when a turn is already running; the reminder then waits for it. */
|
|
1210
1210
|
const BUSY_SESSION_PATTERN = /\bbusy\b|LaneBusy/i;
|
|
1211
|
-
const STEP_SESSION_STARTED_EVENT = "
|
|
1212
|
-
const STEP_SESSION_FAILED_EVENT = "
|
|
1213
|
-
const STEP_REMINDER_EVENT = "
|
|
1214
|
-
const STEP_WAITING_EVENT = "
|
|
1215
|
-
const STEP_SESSION_RELEASE_FAILED_EVENT = "
|
|
1216
|
-
const STEP_PANE_FAILED_EVENT = "
|
|
1211
|
+
const STEP_SESSION_STARTED_EVENT = "po_workflow.step_session_started";
|
|
1212
|
+
const STEP_SESSION_FAILED_EVENT = "po_workflow.step_session_failed";
|
|
1213
|
+
const STEP_REMINDER_EVENT = "po_workflow.step_reminder";
|
|
1214
|
+
const STEP_WAITING_EVENT = "po_workflow.step_waiting";
|
|
1215
|
+
const STEP_SESSION_RELEASE_FAILED_EVENT = "po_workflow.step_session_release_failed";
|
|
1216
|
+
const STEP_PANE_FAILED_EVENT = "po_workflow.step_pane_failed";
|
|
1217
1217
|
const PO_KEYS = new Set(PO_RUN_CONFIG_KEYS);
|
|
1218
1218
|
/**
|
|
1219
1219
|
* A step's `runConfig`, validated against the keys Po understands.
|
|
@@ -2375,7 +2375,7 @@ function createWorkflowHubApi(options = {}) {
|
|
|
2375
2375
|
return context.json({ deleted: true });
|
|
2376
2376
|
});
|
|
2377
2377
|
app.post(routes.openRunDirectory.path, async (context) => {
|
|
2378
|
-
if ((0, _agimon_ai_po_core_packageApi.
|
|
2378
|
+
if ((0, _agimon_ai_po_core_packageApi.poApiCallerFrom)(context.req.raw.headers)?.locality !== "local") return context.json({ error: "Opening Finder is only available on the host." }, 403);
|
|
2379
2379
|
const workspace = context.req.param("workspace");
|
|
2380
2380
|
const runKey = context.req.param("runKey");
|
|
2381
2381
|
const record = await runOf(workspace, runKey);
|
|
@@ -3074,8 +3074,8 @@ function createWorkflowServerRuntime(host, serverHost) {
|
|
|
3074
3074
|
let deliveryRetry;
|
|
3075
3075
|
const catalogDeps = defaultCatalogDeps();
|
|
3076
3076
|
const catalogReader = createWorkflowCatalogReader(catalogDeps);
|
|
3077
|
-
const telemetry = (0, _agimon_ai_po_telemetry.
|
|
3078
|
-
serviceName: "
|
|
3077
|
+
const telemetry = (0, _agimon_ai_po_telemetry.createPoTelemetry)({
|
|
3078
|
+
serviceName: "po-workflow",
|
|
3079
3079
|
packageName: SOURCE,
|
|
3080
3080
|
cwd: host.context.cwd,
|
|
3081
3081
|
env: host.context.environment,
|
|
@@ -3089,12 +3089,12 @@ function createWorkflowServerRuntime(host, serverHost) {
|
|
|
3089
3089
|
parentSessionId: host.context.sessionContext?.parentSessionId,
|
|
3090
3090
|
publishActivity: (activity) => serverHost.context.publishActivity?.(activity),
|
|
3091
3091
|
postNotice: async (notice) => {
|
|
3092
|
-
const data = (0, _agimon_ai_po_core_notification.
|
|
3092
|
+
const data = (0, _agimon_ai_po_core_notification.createPoNotificationEntryData)({
|
|
3093
3093
|
title: notice.title,
|
|
3094
3094
|
body: notice.body,
|
|
3095
3095
|
level: notice.level
|
|
3096
3096
|
});
|
|
3097
|
-
if (data !== void 0) await host.context.session.appendCustomEntry(_agimon_ai_po_core_notification.
|
|
3097
|
+
if (data !== void 0) await host.context.session.appendCustomEntry(_agimon_ai_po_core_notification.PO_NOTIFICATION_ENTRY_TYPE, data);
|
|
3098
3098
|
},
|
|
3099
3099
|
isIdle: async () => {
|
|
3100
3100
|
const activity = await host.context.session.activity();
|
|
@@ -3106,7 +3106,7 @@ function createWorkflowServerRuntime(host, serverHost) {
|
|
|
3106
3106
|
}
|
|
3107
3107
|
}) : void 0;
|
|
3108
3108
|
const reportLifecycleFailure = (error) => {
|
|
3109
|
-
telemetry.recordWarning("
|
|
3109
|
+
telemetry.recordWarning("po_workflow.session_lifecycle_failed", error);
|
|
3110
3110
|
};
|
|
3111
3111
|
/** This session's runs, published to its panel and counted as its background work. */
|
|
3112
3112
|
const publishRuns = (executionContext) => {
|
|
@@ -3138,9 +3138,9 @@ function createWorkflowServerRuntime(host, serverHost) {
|
|
|
3138
3138
|
const request = (0, _agimon_ai_po_core_narration.createNarrationRequest)(text);
|
|
3139
3139
|
if (request === void 0 || narration === void 0) return;
|
|
3140
3140
|
try {
|
|
3141
|
-
Promise.resolve(narration.request(request)).catch((error) => telemetry.recordWarning("
|
|
3141
|
+
Promise.resolve(narration.request(request)).catch((error) => telemetry.recordWarning("po_workflow.narration_failed", error));
|
|
3142
3142
|
} catch (error) {
|
|
3143
|
-
telemetry.recordWarning("
|
|
3143
|
+
telemetry.recordWarning("po_workflow.narration_failed", error);
|
|
3144
3144
|
}
|
|
3145
3145
|
} }, view, previous, previous === void 0 && (!Number.isFinite(startedAt) || startedAt >= sessionStartedAt));
|
|
3146
3146
|
}
|
|
@@ -3188,7 +3188,7 @@ function createWorkflowServerRuntime(host, serverHost) {
|
|
|
3188
3188
|
} catch (error) {
|
|
3189
3189
|
if (disposed) return;
|
|
3190
3190
|
pending.attempts += 1;
|
|
3191
|
-
await telemetry.recordError("
|
|
3191
|
+
await telemetry.recordError("po_workflow.terminal_delivery_failed", error, { "workflow.pending_terminal_count": pendingCompletions.size });
|
|
3192
3192
|
}
|
|
3193
3193
|
}
|
|
3194
3194
|
for (const quiet of [true, false]) {
|
|
@@ -3236,12 +3236,12 @@ function createWorkflowServerRuntime(host, serverHost) {
|
|
|
3236
3236
|
deliveredCompletions.add(identity);
|
|
3237
3237
|
pendingCompletions.delete(identity);
|
|
3238
3238
|
}
|
|
3239
|
-
for (const outcome of batch.outcomes) telemetry.recordEvent("
|
|
3239
|
+
for (const outcome of batch.outcomes) telemetry.recordEvent("po_workflow.run_transition", { outcome });
|
|
3240
3240
|
publishRuns(host.context);
|
|
3241
3241
|
} catch (error) {
|
|
3242
3242
|
if (disposed) return;
|
|
3243
3243
|
batch.attempts += 1;
|
|
3244
|
-
await telemetry.recordError("
|
|
3244
|
+
await telemetry.recordError("po_workflow.terminal_delivery_failed", error, { "workflow.pending_terminal_count": pendingCompletions.size });
|
|
3245
3245
|
}
|
|
3246
3246
|
}
|
|
3247
3247
|
})().finally(() => {
|
|
@@ -3296,7 +3296,7 @@ function createWorkflowServerRuntime(host, serverHost) {
|
|
|
3296
3296
|
publishRuns(executionContext);
|
|
3297
3297
|
deliverCompletions().then(() => done?.(activeRunCount > 0 || pendingCompletions.size > 0));
|
|
3298
3298
|
} catch (error) {
|
|
3299
|
-
telemetry.recordWarning("
|
|
3299
|
+
telemetry.recordWarning("po_workflow.publish_failed", error);
|
|
3300
3300
|
}
|
|
3301
3301
|
}, RUNS_PUBLISH_DEBOUNCE_MS);
|
|
3302
3302
|
runsTimer.unref?.();
|
|
@@ -3499,7 +3499,7 @@ function createWorkflowServerRuntime(host, serverHost) {
|
|
|
3499
3499
|
if (owned.length === 0 || !owned.every(succeeded)) return;
|
|
3500
3500
|
if (!owned.some((run) => runLaunchedBySession(run, host.context.sessionId))) return;
|
|
3501
3501
|
await sessionService.release(source);
|
|
3502
|
-
telemetry.recordEvent("
|
|
3502
|
+
telemetry.recordEvent("po_workflow.session_released", { outcome: "released" });
|
|
3503
3503
|
};
|
|
3504
3504
|
const stopReleaseRequests = communication?.subscribe(WORKFLOW_SESSION_RELEASE_TYPE, (source) => {
|
|
3505
3505
|
releaseWorkflowSession(source).catch(reportLifecycleFailure);
|
|
@@ -3626,7 +3626,7 @@ function createWorkflowServerRuntime(host, serverHost) {
|
|
|
3626
3626
|
return launchFromApi(parameters);
|
|
3627
3627
|
})],
|
|
3628
3628
|
async onStart() {
|
|
3629
|
-
readiness ??= ownedReadiness = (0, _agimon_ai_po_core_readiness.
|
|
3629
|
+
readiness ??= ownedReadiness = (0, _agimon_ai_po_core_readiness.createPoReadinessCoordinator)({ notify: (notice) => {
|
|
3630
3630
|
host.context.client.notify({
|
|
3631
3631
|
body: `${SOURCE} initialization ${notice.state}: ${notice.error?.message ?? notice.diagnostics.join("; ")}`,
|
|
3632
3632
|
level: "warning"
|
|
@@ -3645,9 +3645,9 @@ function createWorkflowServerRuntime(host, serverHost) {
|
|
|
3645
3645
|
},
|
|
3646
3646
|
services: [
|
|
3647
3647
|
(context) => {
|
|
3648
|
-
readiness = (0, _agimon_ai_po_core_readiness.
|
|
3649
|
-
context.inject([_agimon_ai_po_core_narration.
|
|
3650
|
-
const service = (0, _agimon_ai_po_core_narration.
|
|
3648
|
+
readiness = (0, _agimon_ai_po_core_readiness.readPoReadinessCoordinator)(context);
|
|
3649
|
+
context.inject([_agimon_ai_po_core_narration.PO_NARRATION_SERVICE], (serviceContext) => {
|
|
3650
|
+
const service = (0, _agimon_ai_po_core_narration.requirePoNarrationService)(serviceContext);
|
|
3651
3651
|
narration = service;
|
|
3652
3652
|
return () => {
|
|
3653
3653
|
if (narration === service) narration = void 0;
|
|
@@ -3698,7 +3698,7 @@ function createWorkflowServerRuntime(host, serverHost) {
|
|
|
3698
3698
|
try {
|
|
3699
3699
|
const activity = await execution.session.activity();
|
|
3700
3700
|
if (disposed || !activity.isIdle || activity.hasPendingMessages) return;
|
|
3701
|
-
const snapshot = serviceContext === void 0 ? void 0 : (0, _agimon_ai_po_core_backgroundWork.
|
|
3701
|
+
const snapshot = serviceContext === void 0 ? void 0 : (0, _agimon_ai_po_core_backgroundWork.readPoBackgroundWorkService)(serviceContext)?.snapshot(execution.sessionId);
|
|
3702
3702
|
if (snapshot === void 0 || snapshot.items.some(_agimon_ai_po_core_backgroundWork.holdsSettledSession) || snapshot.errors.some((error) => _agimon_ai_po_core_backgroundWork.BACKGROUND_WORK_HOLDING_PROVIDERS.includes(error.provider))) return;
|
|
3703
3703
|
const gate = await (0, _agimon_ai_workflow_mcp.gateStepDecision)(environment);
|
|
3704
3704
|
if (disposed || gate.action !== "block") return;
|
|
@@ -3933,7 +3933,7 @@ function createWorkflowServerRuntime(host, serverHost) {
|
|
|
3933
3933
|
dryRun: input.dryRun,
|
|
3934
3934
|
runner: input.runner
|
|
3935
3935
|
}));
|
|
3936
|
-
telemetry.recordEvent("
|
|
3936
|
+
telemetry.recordEvent("po_workflow.recovery_evidence_requested", { outcome: "requested" });
|
|
3937
3937
|
const sections = [];
|
|
3938
3938
|
for (const name of [
|
|
3939
3939
|
"changelog.md",
|
|
@@ -4175,6 +4175,81 @@ function createWorkflowsChannel(options = {}) {
|
|
|
4175
4175
|
}
|
|
4176
4176
|
};
|
|
4177
4177
|
return {
|
|
4178
|
+
homeFor(scope) {
|
|
4179
|
+
if (!scopes.has(scope.sessionId)) return {
|
|
4180
|
+
coverage: "unavailable",
|
|
4181
|
+
entities: []
|
|
4182
|
+
};
|
|
4183
|
+
const runs = [];
|
|
4184
|
+
const slices = delegated.get(scope.sessionId);
|
|
4185
|
+
if ((slices?.size ?? 0) > _agimon_ai_po_core_hubChannel.HOME_ENTITY_LIMIT) return {
|
|
4186
|
+
coverage: "partial",
|
|
4187
|
+
entities: []
|
|
4188
|
+
};
|
|
4189
|
+
for (const slice of [own.get(scope.sessionId) ?? [], ...slices?.values() ?? []]) {
|
|
4190
|
+
if (runs.length + slice.length > _agimon_ai_po_core_hubChannel.HOME_ENTITY_LIMIT) return {
|
|
4191
|
+
coverage: "partial",
|
|
4192
|
+
entities: []
|
|
4193
|
+
};
|
|
4194
|
+
for (const run of slice) runs.push(run);
|
|
4195
|
+
}
|
|
4196
|
+
const entities = /* @__PURE__ */ new Map();
|
|
4197
|
+
let partial = false;
|
|
4198
|
+
let remaining = _agimon_ai_po_core_hubChannel.HOME_ENTITY_LIMIT;
|
|
4199
|
+
for (const run of runs) {
|
|
4200
|
+
const owner = run.ownerSessionId ?? scope.sessionId;
|
|
4201
|
+
const refs = /* @__PURE__ */ new Set([owner]);
|
|
4202
|
+
if (run.launcherSessionId) refs.add(run.launcherSessionId);
|
|
4203
|
+
if (run.jobs.length > remaining) {
|
|
4204
|
+
partial = true;
|
|
4205
|
+
break;
|
|
4206
|
+
}
|
|
4207
|
+
remaining -= run.jobs.length;
|
|
4208
|
+
let complete = true;
|
|
4209
|
+
for (const job of run.jobs) {
|
|
4210
|
+
if (job.steps.length > remaining) {
|
|
4211
|
+
complete = false;
|
|
4212
|
+
break;
|
|
4213
|
+
}
|
|
4214
|
+
remaining -= job.steps.length;
|
|
4215
|
+
for (const step of job.steps) {
|
|
4216
|
+
if (step.ref?.kind === "session") refs.add(step.ref.id);
|
|
4217
|
+
if (refs.size > 65) {
|
|
4218
|
+
complete = false;
|
|
4219
|
+
break;
|
|
4220
|
+
}
|
|
4221
|
+
}
|
|
4222
|
+
if (!complete) break;
|
|
4223
|
+
}
|
|
4224
|
+
if (!complete) {
|
|
4225
|
+
partial = true;
|
|
4226
|
+
break;
|
|
4227
|
+
}
|
|
4228
|
+
const id = (0, node_crypto.createHash)("sha256").update(JSON.stringify([
|
|
4229
|
+
run.workspace,
|
|
4230
|
+
run.runId ?? run.runKey,
|
|
4231
|
+
run.startedAt
|
|
4232
|
+
])).digest("hex");
|
|
4233
|
+
if (entities.has(id)) continue;
|
|
4234
|
+
if (entities.size >= _agimon_ai_po_core_hubChannel.HOME_ENTITY_LIMIT) {
|
|
4235
|
+
partial = true;
|
|
4236
|
+
continue;
|
|
4237
|
+
}
|
|
4238
|
+
entities.set(id, {
|
|
4239
|
+
id,
|
|
4240
|
+
kind: run.outcome === "interrupted" ? "paused" : run.stage === "error" || run.outcome === "failed" ? "failure" : run.stale === true ? "blocked" : run.stage === "completed" ? "completed" : run.executionState === "paused" || run.executionState === "pause_requested" ? "paused" : "running",
|
|
4241
|
+
title: (run.displayName.trim() || run.runKey).slice(0, 160),
|
|
4242
|
+
...run.errorMessage?.trim() || (run.stale === true ? run.staleReason?.trim() || "Recorded workflow is stale." : void 0) ? { detail: (run.errorMessage?.trim() || run.staleReason?.trim() || "Recorded workflow is stale.").slice(0, 320) } : {},
|
|
4243
|
+
updatedAt: run.finishedAt ?? run.startedAt,
|
|
4244
|
+
sessionId: owner,
|
|
4245
|
+
relatedSessionIds: [...refs].filter((id) => id !== owner)
|
|
4246
|
+
});
|
|
4247
|
+
}
|
|
4248
|
+
return {
|
|
4249
|
+
coverage: partial ? "partial" : "ready",
|
|
4250
|
+
entities: [...entities.values()]
|
|
4251
|
+
};
|
|
4252
|
+
},
|
|
4178
4253
|
payloadFor(scope) {
|
|
4179
4254
|
return scopes.has(scope.sessionId) ? latest.get(scope.sessionId) : void 0;
|
|
4180
4255
|
},
|