@agimon-ai/po-workflow 0.0.0-alpha.2 → 0.0.0-alpha.3

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.
@@ -1,7 +1,7 @@
1
1
  import { n as resolveWorkflowEntry, r as validateWorkflowLaunch, t as parseWorkflowLaunchCommand } from "../workflowLaunchCommand-GGqimmTC.mjs";
2
2
  import { composeServerProviderOverrides, defineServerPlugin } from "@agimon-ai/po-core/serverFacet";
3
3
  import { composeRootHooks, defineChannel, defineRoot, defineRoutedContribution } from "@agimon-ai/po-core/extensionFile";
4
- import { randomUUID } from "node:crypto";
4
+ import { createHash, randomUUID } from "node:crypto";
5
5
  import { readFile } from "node:fs/promises";
6
6
  import path, { basename, isAbsolute, join, relative, resolve } from "node:path";
7
7
  import { BACKGROUND_WORK_HOLDING_PROVIDERS, DOOM_BACKGROUND_WORK_SERVICE, holdsSettledSession, readDoomBackgroundWorkService } from "@agimon-ai/po-core/backgroundWork";
@@ -14,7 +14,7 @@ import { createDoomTelemetry } from "@agimon-ai/po-telemetry";
14
14
  import { NativeTerminalService, WORKFLOW_DECISION_FILE_ENV, WORKFLOW_DECISION_STEERING_ENV, WORKFLOW_DECISION_STEERING_HOST, WorkflowRegistryService, WorkflowTerminalService, connectNativeTerminal, createEmbeddedWorkflowFeature, diagnoseWorkflow, gateStepDecision, readStepDecision, readWorkflowCatalog, readWorkflowProgress, serveNativeTerminal, summarizeWorkflow, summarizeWorkflowProgress, terminalSocketPath } from "@agimon-ai/workflow-mcp";
15
15
  import { z } from "zod";
16
16
  import fs, { existsSync, statSync } from "node:fs";
17
- import { WORKFLOW_STEP_SESSION_PROVENANCE } from "@agimon-ai/po-core/hubChannel";
17
+ import { HOME_ENTITY_LIMIT, WORKFLOW_STEP_SESSION_PROVENANCE } from "@agimon-ai/po-core/hubChannel";
18
18
  import { execFile } from "node:child_process";
19
19
  import { Readable } from "node:stream";
20
20
  import { doomApiCallerFrom } from "@agimon-ai/po-core/packageApi";
@@ -4146,6 +4146,81 @@ function createWorkflowsChannel(options = {}) {
4146
4146
  }
4147
4147
  };
4148
4148
  return {
4149
+ homeFor(scope) {
4150
+ if (!scopes.has(scope.sessionId)) return {
4151
+ coverage: "unavailable",
4152
+ entities: []
4153
+ };
4154
+ const runs = [];
4155
+ const slices = delegated.get(scope.sessionId);
4156
+ if ((slices?.size ?? 0) > HOME_ENTITY_LIMIT) return {
4157
+ coverage: "partial",
4158
+ entities: []
4159
+ };
4160
+ for (const slice of [own.get(scope.sessionId) ?? [], ...slices?.values() ?? []]) {
4161
+ if (runs.length + slice.length > HOME_ENTITY_LIMIT) return {
4162
+ coverage: "partial",
4163
+ entities: []
4164
+ };
4165
+ for (const run of slice) runs.push(run);
4166
+ }
4167
+ const entities = /* @__PURE__ */ new Map();
4168
+ let partial = false;
4169
+ let remaining = HOME_ENTITY_LIMIT;
4170
+ for (const run of runs) {
4171
+ const owner = run.ownerSessionId ?? scope.sessionId;
4172
+ const refs = /* @__PURE__ */ new Set([owner]);
4173
+ if (run.launcherSessionId) refs.add(run.launcherSessionId);
4174
+ if (run.jobs.length > remaining) {
4175
+ partial = true;
4176
+ break;
4177
+ }
4178
+ remaining -= run.jobs.length;
4179
+ let complete = true;
4180
+ for (const job of run.jobs) {
4181
+ if (job.steps.length > remaining) {
4182
+ complete = false;
4183
+ break;
4184
+ }
4185
+ remaining -= job.steps.length;
4186
+ for (const step of job.steps) {
4187
+ if (step.ref?.kind === "session") refs.add(step.ref.id);
4188
+ if (refs.size > 65) {
4189
+ complete = false;
4190
+ break;
4191
+ }
4192
+ }
4193
+ if (!complete) break;
4194
+ }
4195
+ if (!complete) {
4196
+ partial = true;
4197
+ break;
4198
+ }
4199
+ const id = createHash("sha256").update(JSON.stringify([
4200
+ run.workspace,
4201
+ run.runId ?? run.runKey,
4202
+ run.startedAt
4203
+ ])).digest("hex");
4204
+ if (entities.has(id)) continue;
4205
+ if (entities.size >= HOME_ENTITY_LIMIT) {
4206
+ partial = true;
4207
+ continue;
4208
+ }
4209
+ entities.set(id, {
4210
+ id,
4211
+ 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",
4212
+ title: (run.displayName.trim() || run.runKey).slice(0, 160),
4213
+ ...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) } : {},
4214
+ updatedAt: run.finishedAt ?? run.startedAt,
4215
+ sessionId: owner,
4216
+ relatedSessionIds: [...refs].filter((id) => id !== owner)
4217
+ });
4218
+ }
4219
+ return {
4220
+ coverage: partial ? "partial" : "ready",
4221
+ entities: [...entities.values()]
4222
+ };
4223
+ },
4149
4224
  payloadFor(scope) {
4150
4225
  return scopes.has(scope.sessionId) ? latest.get(scope.sessionId) : void 0;
4151
4226
  },