@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.
@@ -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
  },