@agimon-ai/po-workflow 0.0.0-alpha.40 → 0.0.0-alpha.42

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 CHANGED
@@ -61,6 +61,19 @@ Core tools are:
61
61
  Launch returns after the run is registered, not after all jobs complete. Use status for progress
62
62
  and wait for a completion notification.
63
63
 
64
+ ## Dynamic workflows
65
+
66
+ The package also supplies the `dynamicWorkflow` code-mode namespace (formerly
67
+ `@agimon-ai/po-dynamic-workflow`): tracked Mastra workflows composed with `then`, `parallel`,
68
+ `branch` and bounded `foreach`, with live `team.run` transcripts. It is available in every
69
+ agent session, without Workflow mode. Inside a YAML run, a `customRun` step's agent can use it
70
+ for fan-out whose shape is only known at run time, and the run view shows those runs under
71
+ that step. See the [code-mode guide](src/prompts/codemode-how-to-dynamic-workflow/SKILL.md).
72
+ Tracker state is in memory per session; it is not persisted with the run record.
73
+
74
+ If an older `modes.yaml` still names the `dynamic-workflow` layer, remove that layer and its
75
+ mentions under `majorMode`. Until then it resolves to an empty compatibility package.
76
+
64
77
  ## Storage, concurrency, and lifecycle
65
78
 
66
79
  Registry data defaults to `$HOME/.workflow-mcp`; set `WORKFLOW_MCP_HOME` to relocate it. Persisted
@@ -4,6 +4,85 @@ Object.defineProperties(exports, {
4
4
  });
5
5
  let _agimon_ai_po_core_apiContracts = require("@agimon-ai/po-core/apiContracts");
6
6
  let typebox = require("typebox");
7
+ //#region src/schemas/dynamicWorkflowSnapshot.ts
8
+ const state = typebox.Type.Union([
9
+ "pending",
10
+ "running",
11
+ "completed",
12
+ "failed",
13
+ "stopped",
14
+ "skipped"
15
+ ].map((value) => typebox.Type.Literal(value)));
16
+ const time = typebox.Type.Optional(typebox.Type.Number());
17
+ const phase = typebox.Type.Object({
18
+ key: typebox.Type.String(),
19
+ label: typebox.Type.String(),
20
+ status: state,
21
+ executionStatus: state,
22
+ startedAt: time,
23
+ finishedAt: time,
24
+ error: typebox.Type.Optional(typebox.Type.String()),
25
+ agents: typebox.Type.Array(typebox.Type.Object({
26
+ runId: typebox.Type.String(),
27
+ status: typebox.Type.Union([
28
+ "running",
29
+ "completed",
30
+ "failed",
31
+ "stopped"
32
+ ].map((value) => typebox.Type.Literal(value)))
33
+ }))
34
+ });
35
+ const shape = typebox.Type.Object({
36
+ key: typebox.Type.String(),
37
+ label: typebox.Type.String(),
38
+ kind: typebox.Type.Union([
39
+ "step",
40
+ "sequence",
41
+ "parallel",
42
+ "branch",
43
+ "foreach"
44
+ ].map((value) => typebox.Type.Literal(value))),
45
+ children: typebox.Type.Array(typebox.Type.Ref("#/$defs/Shape"))
46
+ });
47
+ const DynamicWorkflowSnapshotSchema = typebox.Type.Object({
48
+ version: typebox.Type.Literal(1),
49
+ revision: typebox.Type.Number(),
50
+ sessionId: typebox.Type.String(),
51
+ runs: typebox.Type.Array(typebox.Type.Object({
52
+ key: typebox.Type.String(),
53
+ workflowId: typebox.Type.String(),
54
+ label: typebox.Type.String(),
55
+ status: state,
56
+ executionStatus: state,
57
+ startedAt: typebox.Type.Number(),
58
+ finishedAt: time,
59
+ error: typebox.Type.Optional(typebox.Type.String()),
60
+ shape: typebox.Type.Ref("#/$defs/Shape"),
61
+ groups: typebox.Type.Array(typebox.Type.Object({
62
+ key: typebox.Type.String(),
63
+ label: typebox.Type.String(),
64
+ concurrency: typebox.Type.Optional(typebox.Type.Number()),
65
+ total: typebox.Type.Number(),
66
+ truncated: typebox.Type.Boolean(),
67
+ counts: typebox.Type.Object({
68
+ pending: typebox.Type.Number(),
69
+ running: typebox.Type.Number(),
70
+ completed: typebox.Type.Number(),
71
+ failed: typebox.Type.Number(),
72
+ stopped: typebox.Type.Number(),
73
+ skipped: typebox.Type.Number()
74
+ }),
75
+ items: typebox.Type.Array(typebox.Type.Object({
76
+ key: typebox.Type.String(),
77
+ label: typebox.Type.String(),
78
+ index: typebox.Type.Number(),
79
+ status: state,
80
+ phases: typebox.Type.Array(phase)
81
+ }))
82
+ }))
83
+ }))
84
+ }, { $defs: { Shape: shape } });
85
+ //#endregion
7
86
  //#region src/schemas/apiContracts.ts
8
87
  const S = typebox.Type.String();
9
88
  const N = typebox.Type.Number();
@@ -338,25 +417,38 @@ const apiContracts = (0, _agimon_ai_po_core_apiContracts.defineApiContract)({
338
417
  }
339
418
  }
340
419
  ]),
341
- sockets: ["global", "workspace"].flatMap((scope) => [{
342
- id: "workflow.runs",
343
- scope,
344
- service: "po.hub",
345
- member: "workflow_runs",
346
- kind: "channel",
347
- direction: "server-to-client",
348
- description: "Workflow runs channel payload.",
349
- input: WorkflowRunsSchema
350
- }, {
351
- id: "workflow.catalog",
352
- scope,
353
- service: "po.hub",
354
- member: "workflow_catalog",
355
- kind: "channel",
356
- direction: "server-to-client",
357
- description: "Workflow catalog channel payload.",
358
- input: WorkflowCatalogSchema
359
- }])
420
+ sockets: ["global", "workspace"].flatMap((scope) => [
421
+ {
422
+ id: "workflow.runs",
423
+ scope,
424
+ service: "po.hub",
425
+ member: "workflow_runs",
426
+ kind: "channel",
427
+ direction: "server-to-client",
428
+ description: "Workflow runs channel payload.",
429
+ input: WorkflowRunsSchema
430
+ },
431
+ {
432
+ id: "workflow.catalog",
433
+ scope,
434
+ service: "po.hub",
435
+ member: "workflow_catalog",
436
+ kind: "channel",
437
+ direction: "server-to-client",
438
+ description: "Workflow catalog channel payload.",
439
+ input: WorkflowCatalogSchema
440
+ },
441
+ {
442
+ id: "dynamic-workflow.runs",
443
+ scope,
444
+ service: "po.hub",
445
+ member: "dynamic_workflow_runs",
446
+ kind: "channel",
447
+ direction: "server-to-client",
448
+ description: "Tracked workflow state for one session, without callback source or input/output data.",
449
+ input: DynamicWorkflowSnapshotSchema
450
+ }
451
+ ])
360
452
  });
361
453
  //#endregion
362
454
  exports.apiContracts = apiContracts;
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.cjs","names":["Type","defineApiContract","jsonApiResponses"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type PoHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst S = Type.String();\nconst N = Type.Number();\nconst B = Type.Boolean();\nconst O = Type.Optional;\nconst values = <T extends string>(items: T[]) => Type.Union(items.map((item) => Type.Literal(item)));\nconst Progress = values(['running', 'completed', 'skipped', 'failed', 'pause_requested', 'paused', 'resumed']);\nconst Step = { name: S, status: Progress, reason: O(S), group: O(S), startedAt: O(S), endedAt: O(S) };\nconst Run = Type.Object({\n runKey: S,\n routeKey: O(S),\n runId: O(S),\n ownerSessionId: O(S),\n launcherSessionId: O(S),\n workspace: S,\n displayName: S,\n workflowName: O(S),\n workflowPath: S,\n stage: values(['running', 'completed', 'error']),\n outcome: O(values(['success', 'skipped', 'failed', 'interrupted'])),\n executionState: O(values(['running', 'pause_requested', 'paused', 'resume_requested'])),\n prompt: O(S),\n startedAt: S,\n finishedAt: O(S),\n errorMessage: O(S),\n failedJob: O(S),\n stale: O(B),\n staleReason: O(S),\n worktreeBranch: O(S),\n position: O(Type.Object({ job: S, step: O(S), index: O(N), total: O(N) })),\n jobs: Type.Array(\n Type.Object({\n ...Step,\n phase: values(['pre', 'job', 'post']),\n index: O(N),\n total: O(N),\n steps: Type.Array(Type.Object(Step)),\n }),\n ),\n});\nexport const WorkflowRunsSchema = Type.Object({ runs: Type.Array(Run) });\nconst Artifact = { path: S, kind: values(['file', 'directory']), description: S, producedBy: Type.Array(S) };\nexport const WorkflowCatalogSchema = Type.Object({\n cwd: S,\n warning: O(S),\n workflows: Type.Array(\n Type.Object({\n path: S,\n relativePath: S,\n name: S,\n description: S,\n tags: Type.Array(S),\n triggers: Type.Array(S),\n inputs: Type.Array(\n Type.Object({\n name: S,\n description: O(S),\n required: O(B),\n default: O(S),\n type: O(S),\n options: O(Type.Array(S)),\n }),\n ),\n jobs: Type.Array(Type.Object({ name: S, steps: Type.Array(S) })),\n artifacts: Type.Array(Type.Object(Artifact)),\n runners: O(Type.Array(S)),\n commands: O(Type.Array(S)),\n choices: O(Type.Array(S)),\n error: O(S),\n }),\n ),\n});\nconst Screen = Type.Object({\n lines: Type.Array(S),\n capabilities: Type.Object({ readable: B, writable: B, resizable: B, reason: O(S) }),\n ended: O(B),\n});\nconst Control = Type.Object({ held: B, token: O(S), reason: O(S) });\nconst root = '/runs/{workspace}/{runKey}';\nexport const apiContracts = defineApiContract({\n version: 1,\n dynamic: [],\n http: (['global', 'workspace', 'session'] as const).flatMap((scope): PoHttpContract[] => [\n {\n id: 'workflow.screen',\n scope,\n basePath: 'workflow',\n path: `${root}/screen/stream`,\n method: 'GET',\n authentication: 'owner',\n description: 'Follow the workflow terminal.',\n responses: {\n '200': {\n description: 'SSE stream with JSON screen events.',\n contentType: 'text/event-stream',\n schema: S,\n events: { screen: Screen },\n },\n '404': { description: 'Run unavailable.', schema: Type.Object({ error: S }) },\n },\n },\n {\n id: 'workflow.control',\n scope,\n basePath: 'workflow',\n path: `${root}/control`,\n method: 'POST',\n authentication: 'owner',\n description: 'Take or release the keyboard.',\n body: { required: true, contentType: 'application/json', schema: Type.Object({ release: O(B), token: O(S) }) },\n responses: { ...jsonApiResponses(Control), '409': { description: 'Keyboard unavailable.', schema: Control } },\n },\n {\n id: 'workflow.keys',\n scope,\n basePath: 'workflow',\n path: `${root}/keys`,\n method: 'POST',\n authentication: 'owner',\n description: 'Write terminal data with the control token.',\n body: { required: true, contentType: 'application/json', schema: Type.Object({ token: S, data: S }) },\n responses: {\n '204': { description: 'Data written.' },\n '400': { description: 'Invalid request.', schema: Type.Object({ error: S }) },\n '409': { description: 'Write refused.', schema: Type.Object({ error: S }) },\n },\n },\n {\n id: 'workflow.resize',\n scope,\n basePath: 'workflow',\n path: `${root}/resize`,\n method: 'POST',\n authentication: 'owner',\n description: 'Resize the terminal.',\n body: { required: true, contentType: 'application/json', schema: Type.Object({ token: S, columns: N, rows: N }) },\n responses: jsonApiResponses(Type.Object({ resized: B })),\n },\n {\n id: 'workflow.delete',\n scope,\n basePath: 'workflow',\n path: root,\n method: 'DELETE',\n authentication: 'owner',\n description: 'Delete a settled run and its directory.',\n responses: jsonApiResponses(Type.Object({ deleted: Type.Literal(true) })),\n },\n {\n id: 'workflow.openRunDirectory',\n scope,\n basePath: 'workflow',\n path: `${root}/open-directory`,\n method: 'POST',\n authentication: 'owner',\n description: 'Open the registered run folder in Finder. Local callers only.',\n responses: {\n ...jsonApiResponses(Type.Object({ opened: Type.Literal(true) })),\n '403': { description: 'Local caller required.', schema: Type.Object({ error: S }) },\n '409': { description: 'Folder opening unavailable.', schema: Type.Object({ error: S }) },\n },\n },\n {\n id: 'workflow.artifacts',\n scope,\n basePath: 'workflow',\n path: `${root}/artifacts`,\n method: 'GET',\n authentication: 'owner',\n description: 'List declared and discovered artifacts, or immediate children of a directory.',\n parameters: [{ name: 'directory', in: 'query', required: false, schema: S }],\n responses: jsonApiResponses(\n Type.Object({\n runDir: S,\n description: S,\n artifacts: Type.Array(\n Type.Object({\n ...Artifact,\n declared: B,\n state: values(['written', 'empty', 'pending', 'unreadable']),\n size: O(N),\n modifiedAt: O(S),\n }),\n ),\n }),\n ),\n },\n {\n id: 'workflow.artifact',\n scope,\n basePath: 'workflow',\n path: `${root}/artifacts/{name}`,\n method: 'GET',\n authentication: 'owner',\n description:\n 'Read artifact metadata and text. name may contain nested path segments. raw=1 streams binary with its media type and supports byte ranges.',\n parameters: [\n { name: 'raw', in: 'query', required: false, schema: values(['0', '1']) },\n { name: 'download', in: 'query', required: false, schema: values(['0', '1']) },\n { name: 'range', in: 'header', required: false, schema: S },\n ],\n responses: {\n ...jsonApiResponses(\n Type.Union([Type.Object({ path: S, size: N, modifiedAt: S, mimeType: O(S), text: O(S), truncated: B }), S]),\n ),\n '206': { description: 'Partial raw bytes.', contentType: 'application/octet-stream', schema: S },\n '416': { description: 'Unsatisfiable byte range.' },\n },\n },\n ]),\n sockets: (['global', 'workspace'] as const).flatMap((scope) => [\n {\n id: 'workflow.runs',\n scope,\n service: 'po.hub',\n member: 'workflow_runs',\n kind: 'channel',\n direction: 'server-to-client',\n description: 'Workflow runs channel payload.',\n input: WorkflowRunsSchema,\n },\n {\n id: 'workflow.catalog',\n scope,\n service: 'po.hub',\n member: 'workflow_catalog',\n kind: 'channel',\n direction: 'server-to-client',\n description: 'Workflow catalog channel payload.',\n input: WorkflowCatalogSchema,\n },\n ]),\n});\nexport default apiContracts;\n"],"mappings":";;;;;;;AAGA,MAAM,IAAIA,QAAAA,KAAK,OAAO;AACtB,MAAM,IAAIA,QAAAA,KAAK,OAAO;AACtB,MAAM,IAAIA,QAAAA,KAAK,QAAQ;AACvB,MAAM,IAAIA,QAAAA,KAAK;AACf,MAAM,UAA4B,UAAeA,QAAAA,KAAK,MAAM,MAAM,KAAK,SAASA,QAAAA,KAAK,QAAQ,IAAI,CAAC,CAAC;AAEnG,MAAM,OAAO;CAAE,MAAM;CAAG,QADP,OAAO;EAAC;EAAW;EAAa;EAAW;EAAU;EAAmB;EAAU;CAAS,CACrE;CAAG,QAAQ,EAAE,CAAC;CAAG,OAAO,EAAE,CAAC;CAAG,WAAW,EAAE,CAAC;CAAG,SAAS,EAAE,CAAC;AAAE;AACpG,MAAM,MAAMA,QAAAA,KAAK,OAAO;CACtB,QAAQ;CACR,UAAU,EAAE,CAAC;CACb,OAAO,EAAE,CAAC;CACV,gBAAgB,EAAE,CAAC;CACnB,mBAAmB,EAAE,CAAC;CACtB,WAAW;CACX,aAAa;CACb,cAAc,EAAE,CAAC;CACjB,cAAc;CACd,OAAO,OAAO;EAAC;EAAW;EAAa;CAAO,CAAC;CAC/C,SAAS,EAAE,OAAO;EAAC;EAAW;EAAW;EAAU;CAAa,CAAC,CAAC;CAClE,gBAAgB,EAAE,OAAO;EAAC;EAAW;EAAmB;EAAU;CAAkB,CAAC,CAAC;CACtF,QAAQ,EAAE,CAAC;CACX,WAAW;CACX,YAAY,EAAE,CAAC;CACf,cAAc,EAAE,CAAC;CACjB,WAAW,EAAE,CAAC;CACd,OAAO,EAAE,CAAC;CAC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AAE,MAAM;KAAG,MAAM;KAAG,YAAY;KAAG,UAAU,EAAE,CAAC;KAAG,MAAM,EAAE,CAAC;KAAG,WAAW;IAAE,CAAC,GAAG,CAAC,CAAC,CAC5G;IACA,OAAO;KAAE,aAAa;KAAsB,aAAa;KAA4B,QAAQ;IAAE;IAC/F,OAAO,EAAE,aAAa,4BAA4B;GACpD;EACF;CACF,CAAC;CACD,SAAU,CAAC,UAAU,WAAW,CAAC,CAAW,SAAS,UAAU,CAC7D;EACE,IAAI;EACJ;EACA,SAAS;EACT,QAAQ;EACR,MAAM;EACN,WAAW;EACX,aAAa;EACb,OAAO;CACT,GACA;EACE,IAAI;EACJ;EACA,SAAS;EACT,QAAQ;EACR,MAAM;EACN,WAAW;EACX,aAAa;EACb,OAAO;CACT,CACF,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"apiContracts.cjs","names":["Type","Type","defineApiContract","jsonApiResponses"],"sources":["../src/schemas/dynamicWorkflowSnapshot.ts","../src/schemas/apiContracts.ts"],"sourcesContent":["import { Type } from 'typebox';\n\nconst state = Type.Union(\n ['pending', 'running', 'completed', 'failed', 'stopped', 'skipped'].map((value) => Type.Literal(value)),\n);\nconst time = Type.Optional(Type.Number());\nconst phase = Type.Object({\n key: Type.String(),\n label: Type.String(),\n status: state,\n executionStatus: state,\n startedAt: time,\n finishedAt: time,\n error: Type.Optional(Type.String()),\n agents: Type.Array(\n Type.Object({\n runId: Type.String(),\n status: Type.Union(['running', 'completed', 'failed', 'stopped'].map((value) => Type.Literal(value))),\n }),\n ),\n});\nconst shape = Type.Object({\n key: Type.String(),\n label: Type.String(),\n kind: Type.Union(['step', 'sequence', 'parallel', 'branch', 'foreach'].map((value) => Type.Literal(value))),\n children: Type.Array(Type.Ref('#/$defs/Shape')),\n});\nexport const DynamicWorkflowSnapshotSchema = Type.Object(\n {\n version: Type.Literal(1),\n revision: Type.Number(),\n sessionId: Type.String(),\n runs: Type.Array(\n Type.Object({\n key: Type.String(),\n workflowId: Type.String(),\n label: Type.String(),\n status: state,\n executionStatus: state,\n startedAt: Type.Number(),\n finishedAt: time,\n error: Type.Optional(Type.String()),\n shape: Type.Ref('#/$defs/Shape'),\n groups: Type.Array(\n Type.Object({\n key: Type.String(),\n label: Type.String(),\n concurrency: Type.Optional(Type.Number()),\n total: Type.Number(),\n truncated: Type.Boolean(),\n counts: Type.Object({\n pending: Type.Number(),\n running: Type.Number(),\n completed: Type.Number(),\n failed: Type.Number(),\n stopped: Type.Number(),\n skipped: Type.Number(),\n }),\n items: Type.Array(\n Type.Object({\n key: Type.String(),\n label: Type.String(),\n index: Type.Number(),\n status: state,\n phases: Type.Array(phase),\n }),\n ),\n }),\n ),\n }),\n ),\n },\n { $defs: { Shape: shape } },\n);\n","import { defineApiContract, jsonApiResponses, type PoHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nimport { DynamicWorkflowSnapshotSchema } from './dynamicWorkflowSnapshot';\n\nconst S = Type.String();\nconst N = Type.Number();\nconst B = Type.Boolean();\nconst O = Type.Optional;\nconst values = <T extends string>(items: T[]) => Type.Union(items.map((item) => Type.Literal(item)));\nconst Progress = values(['running', 'completed', 'skipped', 'failed', 'pause_requested', 'paused', 'resumed']);\nconst Step = { name: S, status: Progress, reason: O(S), group: O(S), startedAt: O(S), endedAt: O(S) };\nconst Run = Type.Object({\n runKey: S,\n routeKey: O(S),\n runId: O(S),\n ownerSessionId: O(S),\n launcherSessionId: O(S),\n workspace: S,\n displayName: S,\n workflowName: O(S),\n workflowPath: S,\n stage: values(['running', 'completed', 'error']),\n outcome: O(values(['success', 'skipped', 'failed', 'interrupted'])),\n executionState: O(values(['running', 'pause_requested', 'paused', 'resume_requested'])),\n prompt: O(S),\n startedAt: S,\n finishedAt: O(S),\n errorMessage: O(S),\n failedJob: O(S),\n stale: O(B),\n staleReason: O(S),\n worktreeBranch: O(S),\n position: O(Type.Object({ job: S, step: O(S), index: O(N), total: O(N) })),\n jobs: Type.Array(\n Type.Object({\n ...Step,\n phase: values(['pre', 'job', 'post']),\n index: O(N),\n total: O(N),\n steps: Type.Array(Type.Object(Step)),\n }),\n ),\n});\nexport const WorkflowRunsSchema = Type.Object({ runs: Type.Array(Run) });\nconst Artifact = { path: S, kind: values(['file', 'directory']), description: S, producedBy: Type.Array(S) };\nexport const WorkflowCatalogSchema = Type.Object({\n cwd: S,\n warning: O(S),\n workflows: Type.Array(\n Type.Object({\n path: S,\n relativePath: S,\n name: S,\n description: S,\n tags: Type.Array(S),\n triggers: Type.Array(S),\n inputs: Type.Array(\n Type.Object({\n name: S,\n description: O(S),\n required: O(B),\n default: O(S),\n type: O(S),\n options: O(Type.Array(S)),\n }),\n ),\n jobs: Type.Array(Type.Object({ name: S, steps: Type.Array(S) })),\n artifacts: Type.Array(Type.Object(Artifact)),\n runners: O(Type.Array(S)),\n commands: O(Type.Array(S)),\n choices: O(Type.Array(S)),\n error: O(S),\n }),\n ),\n});\nconst Screen = Type.Object({\n lines: Type.Array(S),\n capabilities: Type.Object({ readable: B, writable: B, resizable: B, reason: O(S) }),\n ended: O(B),\n});\nconst Control = Type.Object({ held: B, token: O(S), reason: O(S) });\nconst root = '/runs/{workspace}/{runKey}';\nexport const apiContracts = defineApiContract({\n version: 1,\n dynamic: [],\n http: (['global', 'workspace', 'session'] as const).flatMap((scope): PoHttpContract[] => [\n {\n id: 'workflow.screen',\n scope,\n basePath: 'workflow',\n path: `${root}/screen/stream`,\n method: 'GET',\n authentication: 'owner',\n description: 'Follow the workflow terminal.',\n responses: {\n '200': {\n description: 'SSE stream with JSON screen events.',\n contentType: 'text/event-stream',\n schema: S,\n events: { screen: Screen },\n },\n '404': { description: 'Run unavailable.', schema: Type.Object({ error: S }) },\n },\n },\n {\n id: 'workflow.control',\n scope,\n basePath: 'workflow',\n path: `${root}/control`,\n method: 'POST',\n authentication: 'owner',\n description: 'Take or release the keyboard.',\n body: { required: true, contentType: 'application/json', schema: Type.Object({ release: O(B), token: O(S) }) },\n responses: { ...jsonApiResponses(Control), '409': { description: 'Keyboard unavailable.', schema: Control } },\n },\n {\n id: 'workflow.keys',\n scope,\n basePath: 'workflow',\n path: `${root}/keys`,\n method: 'POST',\n authentication: 'owner',\n description: 'Write terminal data with the control token.',\n body: { required: true, contentType: 'application/json', schema: Type.Object({ token: S, data: S }) },\n responses: {\n '204': { description: 'Data written.' },\n '400': { description: 'Invalid request.', schema: Type.Object({ error: S }) },\n '409': { description: 'Write refused.', schema: Type.Object({ error: S }) },\n },\n },\n {\n id: 'workflow.resize',\n scope,\n basePath: 'workflow',\n path: `${root}/resize`,\n method: 'POST',\n authentication: 'owner',\n description: 'Resize the terminal.',\n body: { required: true, contentType: 'application/json', schema: Type.Object({ token: S, columns: N, rows: N }) },\n responses: jsonApiResponses(Type.Object({ resized: B })),\n },\n {\n id: 'workflow.delete',\n scope,\n basePath: 'workflow',\n path: root,\n method: 'DELETE',\n authentication: 'owner',\n description: 'Delete a settled run and its directory.',\n responses: jsonApiResponses(Type.Object({ deleted: Type.Literal(true) })),\n },\n {\n id: 'workflow.openRunDirectory',\n scope,\n basePath: 'workflow',\n path: `${root}/open-directory`,\n method: 'POST',\n authentication: 'owner',\n description: 'Open the registered run folder in Finder. Local callers only.',\n responses: {\n ...jsonApiResponses(Type.Object({ opened: Type.Literal(true) })),\n '403': { description: 'Local caller required.', schema: Type.Object({ error: S }) },\n '409': { description: 'Folder opening unavailable.', schema: Type.Object({ error: S }) },\n },\n },\n {\n id: 'workflow.artifacts',\n scope,\n basePath: 'workflow',\n path: `${root}/artifacts`,\n method: 'GET',\n authentication: 'owner',\n description: 'List declared and discovered artifacts, or immediate children of a directory.',\n parameters: [{ name: 'directory', in: 'query', required: false, schema: S }],\n responses: jsonApiResponses(\n Type.Object({\n runDir: S,\n description: S,\n artifacts: Type.Array(\n Type.Object({\n ...Artifact,\n declared: B,\n state: values(['written', 'empty', 'pending', 'unreadable']),\n size: O(N),\n modifiedAt: O(S),\n }),\n ),\n }),\n ),\n },\n {\n id: 'workflow.artifact',\n scope,\n basePath: 'workflow',\n path: `${root}/artifacts/{name}`,\n method: 'GET',\n authentication: 'owner',\n description:\n 'Read artifact metadata and text. name may contain nested path segments. raw=1 streams binary with its media type and supports byte ranges.',\n parameters: [\n { name: 'raw', in: 'query', required: false, schema: values(['0', '1']) },\n { name: 'download', in: 'query', required: false, schema: values(['0', '1']) },\n { name: 'range', in: 'header', required: false, schema: S },\n ],\n responses: {\n ...jsonApiResponses(\n Type.Union([Type.Object({ path: S, size: N, modifiedAt: S, mimeType: O(S), text: O(S), truncated: B }), S]),\n ),\n '206': { description: 'Partial raw bytes.', contentType: 'application/octet-stream', schema: S },\n '416': { description: 'Unsatisfiable byte range.' },\n },\n },\n ]),\n sockets: (['global', 'workspace'] as const).flatMap((scope) => [\n {\n id: 'workflow.runs',\n scope,\n service: 'po.hub',\n member: 'workflow_runs',\n kind: 'channel',\n direction: 'server-to-client',\n description: 'Workflow runs channel payload.',\n input: WorkflowRunsSchema,\n },\n {\n id: 'workflow.catalog',\n scope,\n service: 'po.hub',\n member: 'workflow_catalog',\n kind: 'channel',\n direction: 'server-to-client',\n description: 'Workflow catalog channel payload.',\n input: WorkflowCatalogSchema,\n },\n {\n id: 'dynamic-workflow.runs',\n scope,\n service: 'po.hub',\n member: 'dynamic_workflow_runs',\n kind: 'channel',\n direction: 'server-to-client',\n description: 'Tracked workflow state for one session, without callback source or input/output data.',\n input: DynamicWorkflowSnapshotSchema,\n },\n ]),\n});\nexport default apiContracts;\n"],"mappings":";;;;;;;AAEA,MAAM,QAAQA,QAAAA,KAAK,MACjB;CAAC;CAAW;CAAW;CAAa;CAAU;CAAW;AAAS,CAAC,CAAC,KAAK,UAAUA,QAAAA,KAAK,QAAQ,KAAK,CAAC,CACxG;AACA,MAAM,OAAOA,QAAAA,KAAK,SAASA,QAAAA,KAAK,OAAO,CAAC;AACxC,MAAM,QAAQA,QAAAA,KAAK,OAAO;CACxB,KAAKA,QAAAA,KAAK,OAAO;CACjB,OAAOA,QAAAA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AAU;GACV,MAAM,GAAG,KAAK;GACd,QAAQ;GACR,gBAAgB;GAChB,aACE;GACF,YAAY;IACV;KAAE,MAAM;KAAO,IAAI;KAAS,UAAU;KAAO,QAAQ,OAAO,CAAC,KAAK,GAAG,CAAC;IAAE;IACxE;KAAE,MAAM;KAAY,IAAI;KAAS,UAAU;KAAO,QAAQ,OAAO,CAAC,KAAK,GAAG,CAAC;IAAE;IAC7E;KAAE,MAAM;KAAS,IAAI;KAAU,UAAU;KAAO,QAAQ;IAAE;GAC5D;GACA,WAAW;IACT,IAAA,GAAGE,gCAAAA,iBAAAA,CACDF,QAAAA,KAAK,MAAM,CAACA,QAAAA,KAAK,OAAO;KAAE,MAAM;KAAG,MAAM;KAAG,YAAY;KAAG,UAAU,EAAE,CAAC;KAAG,MAAM,EAAE,CAAC;KAAG,WAAW;IAAE,CAAC,GAAG,CAAC,CAAC,CAC5G;IACA,OAAO;KAAE,aAAa;KAAsB,aAAa;KAA4B,QAAQ;IAAE;IAC/F,OAAO,EAAE,aAAa,4BAA4B;GACpD;EACF;CACF,CAAC;CACD,SAAU,CAAC,UAAU,WAAW,CAAC,CAAW,SAAS,UAAU;EAC7D;GACE,IAAI;GACJ;GACA,SAAS;GACT,QAAQ;GACR,MAAM;GACN,WAAW;GACX,aAAa;GACb,OAAO;EACT;EACA;GACE,IAAI;GACJ;GACA,SAAS;GACT,QAAQ;GACR,MAAM;GACN,WAAW;GACX,aAAa;GACb,OAAO;EACT;EACA;GACE,IAAI;GACJ;GACA,SAAS;GACT,QAAQ;GACR,MAAM;GACN,WAAW;GACX,aAAa;GACb,OAAO;EACT;CACF,CAAC;AACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.d.mts","names":[],"sources":["../src/schemas/apiContracts.ts"],"mappings":";;qBAiFa"}
1
+ {"version":3,"file":"apiContracts.d.mts","names":[],"sources":["../src/schemas/apiContracts.ts"],"mappings":";;qBAmFa"}
@@ -1,5 +1,84 @@
1
1
  import { defineApiContract, jsonApiResponses } from "@agimon-ai/po-core/apiContracts";
2
2
  import { Type } from "typebox";
3
+ //#region src/schemas/dynamicWorkflowSnapshot.ts
4
+ const state = Type.Union([
5
+ "pending",
6
+ "running",
7
+ "completed",
8
+ "failed",
9
+ "stopped",
10
+ "skipped"
11
+ ].map((value) => Type.Literal(value)));
12
+ const time = Type.Optional(Type.Number());
13
+ const phase = Type.Object({
14
+ key: Type.String(),
15
+ label: Type.String(),
16
+ status: state,
17
+ executionStatus: state,
18
+ startedAt: time,
19
+ finishedAt: time,
20
+ error: Type.Optional(Type.String()),
21
+ agents: Type.Array(Type.Object({
22
+ runId: Type.String(),
23
+ status: Type.Union([
24
+ "running",
25
+ "completed",
26
+ "failed",
27
+ "stopped"
28
+ ].map((value) => Type.Literal(value)))
29
+ }))
30
+ });
31
+ const shape = Type.Object({
32
+ key: Type.String(),
33
+ label: Type.String(),
34
+ kind: Type.Union([
35
+ "step",
36
+ "sequence",
37
+ "parallel",
38
+ "branch",
39
+ "foreach"
40
+ ].map((value) => Type.Literal(value))),
41
+ children: Type.Array(Type.Ref("#/$defs/Shape"))
42
+ });
43
+ const DynamicWorkflowSnapshotSchema = Type.Object({
44
+ version: Type.Literal(1),
45
+ revision: Type.Number(),
46
+ sessionId: Type.String(),
47
+ runs: Type.Array(Type.Object({
48
+ key: Type.String(),
49
+ workflowId: Type.String(),
50
+ label: Type.String(),
51
+ status: state,
52
+ executionStatus: state,
53
+ startedAt: Type.Number(),
54
+ finishedAt: time,
55
+ error: Type.Optional(Type.String()),
56
+ shape: Type.Ref("#/$defs/Shape"),
57
+ groups: Type.Array(Type.Object({
58
+ key: Type.String(),
59
+ label: Type.String(),
60
+ concurrency: Type.Optional(Type.Number()),
61
+ total: Type.Number(),
62
+ truncated: Type.Boolean(),
63
+ counts: Type.Object({
64
+ pending: Type.Number(),
65
+ running: Type.Number(),
66
+ completed: Type.Number(),
67
+ failed: Type.Number(),
68
+ stopped: Type.Number(),
69
+ skipped: Type.Number()
70
+ }),
71
+ items: Type.Array(Type.Object({
72
+ key: Type.String(),
73
+ label: Type.String(),
74
+ index: Type.Number(),
75
+ status: state,
76
+ phases: Type.Array(phase)
77
+ }))
78
+ }))
79
+ }))
80
+ }, { $defs: { Shape: shape } });
81
+ //#endregion
3
82
  //#region src/schemas/apiContracts.ts
4
83
  const S = Type.String();
5
84
  const N = Type.Number();
@@ -334,25 +413,38 @@ const apiContracts = defineApiContract({
334
413
  }
335
414
  }
336
415
  ]),
337
- sockets: ["global", "workspace"].flatMap((scope) => [{
338
- id: "workflow.runs",
339
- scope,
340
- service: "po.hub",
341
- member: "workflow_runs",
342
- kind: "channel",
343
- direction: "server-to-client",
344
- description: "Workflow runs channel payload.",
345
- input: WorkflowRunsSchema
346
- }, {
347
- id: "workflow.catalog",
348
- scope,
349
- service: "po.hub",
350
- member: "workflow_catalog",
351
- kind: "channel",
352
- direction: "server-to-client",
353
- description: "Workflow catalog channel payload.",
354
- input: WorkflowCatalogSchema
355
- }])
416
+ sockets: ["global", "workspace"].flatMap((scope) => [
417
+ {
418
+ id: "workflow.runs",
419
+ scope,
420
+ service: "po.hub",
421
+ member: "workflow_runs",
422
+ kind: "channel",
423
+ direction: "server-to-client",
424
+ description: "Workflow runs channel payload.",
425
+ input: WorkflowRunsSchema
426
+ },
427
+ {
428
+ id: "workflow.catalog",
429
+ scope,
430
+ service: "po.hub",
431
+ member: "workflow_catalog",
432
+ kind: "channel",
433
+ direction: "server-to-client",
434
+ description: "Workflow catalog channel payload.",
435
+ input: WorkflowCatalogSchema
436
+ },
437
+ {
438
+ id: "dynamic-workflow.runs",
439
+ scope,
440
+ service: "po.hub",
441
+ member: "dynamic_workflow_runs",
442
+ kind: "channel",
443
+ direction: "server-to-client",
444
+ description: "Tracked workflow state for one session, without callback source or input/output data.",
445
+ input: DynamicWorkflowSnapshotSchema
446
+ }
447
+ ])
356
448
  });
357
449
  //#endregion
358
450
  export { apiContracts, apiContracts as default };
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type PoHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst S = Type.String();\nconst N = Type.Number();\nconst B = Type.Boolean();\nconst O = Type.Optional;\nconst values = <T extends string>(items: T[]) => Type.Union(items.map((item) => Type.Literal(item)));\nconst Progress = values(['running', 'completed', 'skipped', 'failed', 'pause_requested', 'paused', 'resumed']);\nconst Step = { name: S, status: Progress, reason: O(S), group: O(S), startedAt: O(S), endedAt: O(S) };\nconst Run = Type.Object({\n runKey: S,\n routeKey: O(S),\n runId: O(S),\n ownerSessionId: O(S),\n launcherSessionId: O(S),\n workspace: S,\n displayName: S,\n workflowName: O(S),\n workflowPath: S,\n stage: values(['running', 'completed', 'error']),\n outcome: O(values(['success', 'skipped', 'failed', 'interrupted'])),\n executionState: O(values(['running', 'pause_requested', 'paused', 'resume_requested'])),\n prompt: O(S),\n startedAt: S,\n finishedAt: O(S),\n errorMessage: O(S),\n failedJob: O(S),\n stale: O(B),\n staleReason: O(S),\n worktreeBranch: O(S),\n position: O(Type.Object({ job: S, step: O(S), index: O(N), total: O(N) })),\n jobs: Type.Array(\n Type.Object({\n ...Step,\n phase: values(['pre', 'job', 'post']),\n index: O(N),\n total: O(N),\n steps: Type.Array(Type.Object(Step)),\n }),\n ),\n});\nexport const WorkflowRunsSchema = Type.Object({ runs: Type.Array(Run) });\nconst Artifact = { path: S, kind: values(['file', 'directory']), description: S, producedBy: Type.Array(S) };\nexport const WorkflowCatalogSchema = Type.Object({\n cwd: S,\n warning: O(S),\n workflows: Type.Array(\n Type.Object({\n path: S,\n relativePath: S,\n name: S,\n description: S,\n tags: Type.Array(S),\n triggers: Type.Array(S),\n inputs: Type.Array(\n Type.Object({\n name: S,\n description: O(S),\n required: O(B),\n default: O(S),\n type: O(S),\n options: O(Type.Array(S)),\n }),\n ),\n jobs: Type.Array(Type.Object({ name: S, steps: Type.Array(S) })),\n artifacts: Type.Array(Type.Object(Artifact)),\n runners: O(Type.Array(S)),\n commands: O(Type.Array(S)),\n choices: O(Type.Array(S)),\n error: O(S),\n }),\n ),\n});\nconst Screen = Type.Object({\n lines: Type.Array(S),\n capabilities: Type.Object({ readable: B, writable: B, resizable: B, reason: O(S) }),\n ended: O(B),\n});\nconst Control = Type.Object({ held: B, token: O(S), reason: O(S) });\nconst root = '/runs/{workspace}/{runKey}';\nexport const apiContracts = defineApiContract({\n version: 1,\n dynamic: [],\n http: (['global', 'workspace', 'session'] as const).flatMap((scope): PoHttpContract[] => [\n {\n id: 'workflow.screen',\n scope,\n basePath: 'workflow',\n path: `${root}/screen/stream`,\n method: 'GET',\n authentication: 'owner',\n description: 'Follow the workflow terminal.',\n responses: {\n '200': {\n description: 'SSE stream with JSON screen events.',\n contentType: 'text/event-stream',\n schema: S,\n events: { screen: Screen },\n },\n '404': { description: 'Run unavailable.', schema: Type.Object({ error: S }) },\n },\n },\n {\n id: 'workflow.control',\n scope,\n basePath: 'workflow',\n path: `${root}/control`,\n method: 'POST',\n authentication: 'owner',\n description: 'Take or release the keyboard.',\n body: { required: true, contentType: 'application/json', schema: Type.Object({ release: O(B), token: O(S) }) },\n responses: { ...jsonApiResponses(Control), '409': { description: 'Keyboard unavailable.', schema: Control } },\n },\n {\n id: 'workflow.keys',\n scope,\n basePath: 'workflow',\n path: `${root}/keys`,\n method: 'POST',\n authentication: 'owner',\n description: 'Write terminal data with the control token.',\n body: { required: true, contentType: 'application/json', schema: Type.Object({ token: S, data: S }) },\n responses: {\n '204': { description: 'Data written.' },\n '400': { description: 'Invalid request.', schema: Type.Object({ error: S }) },\n '409': { description: 'Write refused.', schema: Type.Object({ error: S }) },\n },\n },\n {\n id: 'workflow.resize',\n scope,\n basePath: 'workflow',\n path: `${root}/resize`,\n method: 'POST',\n authentication: 'owner',\n description: 'Resize the terminal.',\n body: { required: true, contentType: 'application/json', schema: Type.Object({ token: S, columns: N, rows: N }) },\n responses: jsonApiResponses(Type.Object({ resized: B })),\n },\n {\n id: 'workflow.delete',\n scope,\n basePath: 'workflow',\n path: root,\n method: 'DELETE',\n authentication: 'owner',\n description: 'Delete a settled run and its directory.',\n responses: jsonApiResponses(Type.Object({ deleted: Type.Literal(true) })),\n },\n {\n id: 'workflow.openRunDirectory',\n scope,\n basePath: 'workflow',\n path: `${root}/open-directory`,\n method: 'POST',\n authentication: 'owner',\n description: 'Open the registered run folder in Finder. Local callers only.',\n responses: {\n ...jsonApiResponses(Type.Object({ opened: Type.Literal(true) })),\n '403': { description: 'Local caller required.', schema: Type.Object({ error: S }) },\n '409': { description: 'Folder opening unavailable.', schema: Type.Object({ error: S }) },\n },\n },\n {\n id: 'workflow.artifacts',\n scope,\n basePath: 'workflow',\n path: `${root}/artifacts`,\n method: 'GET',\n authentication: 'owner',\n description: 'List declared and discovered artifacts, or immediate children of a directory.',\n parameters: [{ name: 'directory', in: 'query', required: false, schema: S }],\n responses: jsonApiResponses(\n Type.Object({\n runDir: S,\n description: S,\n artifacts: Type.Array(\n Type.Object({\n ...Artifact,\n declared: B,\n state: values(['written', 'empty', 'pending', 'unreadable']),\n size: O(N),\n modifiedAt: O(S),\n }),\n ),\n }),\n ),\n },\n {\n id: 'workflow.artifact',\n scope,\n basePath: 'workflow',\n path: `${root}/artifacts/{name}`,\n method: 'GET',\n authentication: 'owner',\n description:\n 'Read artifact metadata and text. name may contain nested path segments. raw=1 streams binary with its media type and supports byte ranges.',\n parameters: [\n { name: 'raw', in: 'query', required: false, schema: values(['0', '1']) },\n { name: 'download', in: 'query', required: false, schema: values(['0', '1']) },\n { name: 'range', in: 'header', required: false, schema: S },\n ],\n responses: {\n ...jsonApiResponses(\n Type.Union([Type.Object({ path: S, size: N, modifiedAt: S, mimeType: O(S), text: O(S), truncated: B }), S]),\n ),\n '206': { description: 'Partial raw bytes.', contentType: 'application/octet-stream', schema: S },\n '416': { description: 'Unsatisfiable byte range.' },\n },\n },\n ]),\n sockets: (['global', 'workspace'] as const).flatMap((scope) => [\n {\n id: 'workflow.runs',\n scope,\n service: 'po.hub',\n member: 'workflow_runs',\n kind: 'channel',\n direction: 'server-to-client',\n description: 'Workflow runs channel payload.',\n input: WorkflowRunsSchema,\n },\n {\n id: 'workflow.catalog',\n scope,\n service: 'po.hub',\n member: 'workflow_catalog',\n kind: 'channel',\n direction: 'server-to-client',\n description: 'Workflow catalog channel payload.',\n input: WorkflowCatalogSchema,\n },\n ]),\n});\nexport default apiContracts;\n"],"mappings":";;;AAGA,MAAM,IAAI,KAAK,OAAO;AACtB,MAAM,IAAI,KAAK,OAAO;AACtB,MAAM,IAAI,KAAK,QAAQ;AACvB,MAAM,IAAI,KAAK;AACf,MAAM,UAA4B,UAAe,KAAK,MAAM,MAAM,KAAK,SAAS,KAAK,QAAQ,IAAI,CAAC,CAAC;AAEnG,MAAM,OAAO;CAAE,MAAM;CAAG,QADP,OAAO;EAAC;EAAW;EAAa;EAAW;EAAU;EAAmB;EAAU;CAAS,CACrE;CAAG,QAAQ,EAAE,CAAC;CAAG,OAAO,EAAE,CAAC;CAAG,WAAW,EAAE,CAAC;CAAG,SAAS,EAAE,CAAC;AAAE;AACpG,MAAM,MAAM,KAAK,OAAO;CACtB,QAAQ;CACR,UAAU,EAAE,CAAC;CACb,OAAO,EAAE,CAAC;CACV,gBAAgB,EAAE,CAAC;CACnB,mBAAmB,EAAE,CAAC;CACtB,WAAW;CACX,aAAa;CACb,cAAc,EAAE,CAAC;CACjB,cAAc;CACd,OAAO,OAAO;EAAC;EAAW;EAAa;CAAO,CAAC;CAC/C,SAAS,EAAE,OAAO;EAAC;EAAW;EAAW;EAAU;CAAa,CAAC,CAAC;CAClE,gBAAgB,EAAE,OAAO;EAAC;EAAW;EAAmB;EAAU;CAAkB,CAAC,CAAC;CACtF,QAAQ,EAAE,CAAC;CACX,WAAW;CACX,YAAY,EAAE,CAAC;CACf,cAAc,EAAE,CAAC;CACjB,WAAW,EAAE,CAAC;CACd,OAAO,EAAE,C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apiContracts.mjs","names":[],"sources":["../src/schemas/dynamicWorkflowSnapshot.ts","../src/schemas/apiContracts.ts"],"sourcesContent":["import { Type } from 'typebox';\n\nconst state = Type.Union(\n ['pending', 'running', 'completed', 'failed', 'stopped', 'skipped'].map((value) => Type.Literal(value)),\n);\nconst time = Type.Optional(Type.Number());\nconst phase = Type.Object({\n key: Type.String(),\n label: Type.String(),\n status: state,\n executionStatus: state,\n startedAt: time,\n finishedAt: time,\n error: Type.Optional(Type.String()),\n agents: Type.Array(\n Type.Object({\n runId: Type.String(),\n status: Type.Union(['running', 'completed', 'failed', 'stopped'].map((value) => Type.Literal(value))),\n }),\n ),\n});\nconst shape = Type.Object({\n key: Type.String(),\n label: Type.String(),\n kind: Type.Union(['step', 'sequence', 'parallel', 'branch', 'foreach'].map((value) => Type.Literal(value))),\n children: Type.Array(Type.Ref('#/$defs/Shape')),\n});\nexport const DynamicWorkflowSnapshotSchema = Type.Object(\n {\n version: Type.Literal(1),\n revision: Type.Number(),\n sessionId: Type.String(),\n runs: Type.Array(\n Type.Object({\n key: Type.String(),\n workflowId: Type.String(),\n label: Type.String(),\n status: state,\n executionStatus: state,\n startedAt: Type.Number(),\n finishedAt: time,\n error: Type.Optional(Type.String()),\n shape: Type.Ref('#/$defs/Shape'),\n groups: Type.Array(\n Type.Object({\n key: Type.String(),\n label: Type.String(),\n concurrency: Type.Optional(Type.Number()),\n total: Type.Number(),\n truncated: Type.Boolean(),\n counts: Type.Object({\n pending: Type.Number(),\n running: Type.Number(),\n completed: Type.Number(),\n failed: Type.Number(),\n stopped: Type.Number(),\n skipped: Type.Number(),\n }),\n items: Type.Array(\n Type.Object({\n key: Type.String(),\n label: Type.String(),\n index: Type.Number(),\n status: state,\n phases: Type.Array(phase),\n }),\n ),\n }),\n ),\n }),\n ),\n },\n { $defs: { Shape: shape } },\n);\n","import { defineApiContract, jsonApiResponses, type PoHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nimport { DynamicWorkflowSnapshotSchema } from './dynamicWorkflowSnapshot';\n\nconst S = Type.String();\nconst N = Type.Number();\nconst B = Type.Boolean();\nconst O = Type.Optional;\nconst values = <T extends string>(items: T[]) => Type.Union(items.map((item) => Type.Literal(item)));\nconst Progress = values(['running', 'completed', 'skipped', 'failed', 'pause_requested', 'paused', 'resumed']);\nconst Step = { name: S, status: Progress, reason: O(S), group: O(S), startedAt: O(S), endedAt: O(S) };\nconst Run = Type.Object({\n runKey: S,\n routeKey: O(S),\n runId: O(S),\n ownerSessionId: O(S),\n launcherSessionId: O(S),\n workspace: S,\n displayName: S,\n workflowName: O(S),\n workflowPath: S,\n stage: values(['running', 'completed', 'error']),\n outcome: O(values(['success', 'skipped', 'failed', 'interrupted'])),\n executionState: O(values(['running', 'pause_requested', 'paused', 'resume_requested'])),\n prompt: O(S),\n startedAt: S,\n finishedAt: O(S),\n errorMessage: O(S),\n failedJob: O(S),\n stale: O(B),\n staleReason: O(S),\n worktreeBranch: O(S),\n position: O(Type.Object({ job: S, step: O(S), index: O(N), total: O(N) })),\n jobs: Type.Array(\n Type.Object({\n ...Step,\n phase: values(['pre', 'job', 'post']),\n index: O(N),\n total: O(N),\n steps: Type.Array(Type.Object(Step)),\n }),\n ),\n});\nexport const WorkflowRunsSchema = Type.Object({ runs: Type.Array(Run) });\nconst Artifact = { path: S, kind: values(['file', 'directory']), description: S, producedBy: Type.Array(S) };\nexport const WorkflowCatalogSchema = Type.Object({\n cwd: S,\n warning: O(S),\n workflows: Type.Array(\n Type.Object({\n path: S,\n relativePath: S,\n name: S,\n description: S,\n tags: Type.Array(S),\n triggers: Type.Array(S),\n inputs: Type.Array(\n Type.Object({\n name: S,\n description: O(S),\n required: O(B),\n default: O(S),\n type: O(S),\n options: O(Type.Array(S)),\n }),\n ),\n jobs: Type.Array(Type.Object({ name: S, steps: Type.Array(S) })),\n artifacts: Type.Array(Type.Object(Artifact)),\n runners: O(Type.Array(S)),\n commands: O(Type.Array(S)),\n choices: O(Type.Array(S)),\n error: O(S),\n }),\n ),\n});\nconst Screen = Type.Object({\n lines: Type.Array(S),\n capabilities: Type.Object({ readable: B, writable: B, resizable: B, reason: O(S) }),\n ended: O(B),\n});\nconst Control = Type.Object({ held: B, token: O(S), reason: O(S) });\nconst root = '/runs/{workspace}/{runKey}';\nexport const apiContracts = defineApiContract({\n version: 1,\n dynamic: [],\n http: (['global', 'workspace', 'session'] as const).flatMap((scope): PoHttpContract[] => [\n {\n id: 'workflow.screen',\n scope,\n basePath: 'workflow',\n path: `${root}/screen/stream`,\n method: 'GET',\n authentication: 'owner',\n description: 'Follow the workflow terminal.',\n responses: {\n '200': {\n description: 'SSE stream with JSON screen events.',\n contentType: 'text/event-stream',\n schema: S,\n events: { screen: Screen },\n },\n '404': { description: 'Run unavailable.', schema: Type.Object({ error: S }) },\n },\n },\n {\n id: 'workflow.control',\n scope,\n basePath: 'workflow',\n path: `${root}/control`,\n method: 'POST',\n authentication: 'owner',\n description: 'Take or release the keyboard.',\n body: { required: true, contentType: 'application/json', schema: Type.Object({ release: O(B), token: O(S) }) },\n responses: { ...jsonApiResponses(Control), '409': { description: 'Keyboard unavailable.', schema: Control } },\n },\n {\n id: 'workflow.keys',\n scope,\n basePath: 'workflow',\n path: `${root}/keys`,\n method: 'POST',\n authentication: 'owner',\n description: 'Write terminal data with the control token.',\n body: { required: true, contentType: 'application/json', schema: Type.Object({ token: S, data: S }) },\n responses: {\n '204': { description: 'Data written.' },\n '400': { description: 'Invalid request.', schema: Type.Object({ error: S }) },\n '409': { description: 'Write refused.', schema: Type.Object({ error: S }) },\n },\n },\n {\n id: 'workflow.resize',\n scope,\n basePath: 'workflow',\n path: `${root}/resize`,\n method: 'POST',\n authentication: 'owner',\n description: 'Resize the terminal.',\n body: { required: true, contentType: 'application/json', schema: Type.Object({ token: S, columns: N, rows: N }) },\n responses: jsonApiResponses(Type.Object({ resized: B })),\n },\n {\n id: 'workflow.delete',\n scope,\n basePath: 'workflow',\n path: root,\n method: 'DELETE',\n authentication: 'owner',\n description: 'Delete a settled run and its directory.',\n responses: jsonApiResponses(Type.Object({ deleted: Type.Literal(true) })),\n },\n {\n id: 'workflow.openRunDirectory',\n scope,\n basePath: 'workflow',\n path: `${root}/open-directory`,\n method: 'POST',\n authentication: 'owner',\n description: 'Open the registered run folder in Finder. Local callers only.',\n responses: {\n ...jsonApiResponses(Type.Object({ opened: Type.Literal(true) })),\n '403': { description: 'Local caller required.', schema: Type.Object({ error: S }) },\n '409': { description: 'Folder opening unavailable.', schema: Type.Object({ error: S }) },\n },\n },\n {\n id: 'workflow.artifacts',\n scope,\n basePath: 'workflow',\n path: `${root}/artifacts`,\n method: 'GET',\n authentication: 'owner',\n description: 'List declared and discovered artifacts, or immediate children of a directory.',\n parameters: [{ name: 'directory', in: 'query', required: false, schema: S }],\n responses: jsonApiResponses(\n Type.Object({\n runDir: S,\n description: S,\n artifacts: Type.Array(\n Type.Object({\n ...Artifact,\n declared: B,\n state: values(['written', 'empty', 'pending', 'unreadable']),\n size: O(N),\n modifiedAt: O(S),\n }),\n ),\n }),\n ),\n },\n {\n id: 'workflow.artifact',\n scope,\n basePath: 'workflow',\n path: `${root}/artifacts/{name}`,\n method: 'GET',\n authentication: 'owner',\n description:\n 'Read artifact metadata and text. name may contain nested path segments. raw=1 streams binary with its media type and supports byte ranges.',\n parameters: [\n { name: 'raw', in: 'query', required: false, schema: values(['0', '1']) },\n { name: 'download', in: 'query', required: false, schema: values(['0', '1']) },\n { name: 'range', in: 'header', required: false, schema: S },\n ],\n responses: {\n ...jsonApiResponses(\n Type.Union([Type.Object({ path: S, size: N, modifiedAt: S, mimeType: O(S), text: O(S), truncated: B }), S]),\n ),\n '206': { description: 'Partial raw bytes.', contentType: 'application/octet-stream', schema: S },\n '416': { description: 'Unsatisfiable byte range.' },\n },\n },\n ]),\n sockets: (['global', 'workspace'] as const).flatMap((scope) => [\n {\n id: 'workflow.runs',\n scope,\n service: 'po.hub',\n member: 'workflow_runs',\n kind: 'channel',\n direction: 'server-to-client',\n description: 'Workflow runs channel payload.',\n input: WorkflowRunsSchema,\n },\n {\n id: 'workflow.catalog',\n scope,\n service: 'po.hub',\n member: 'workflow_catalog',\n kind: 'channel',\n direction: 'server-to-client',\n description: 'Workflow catalog channel payload.',\n input: WorkflowCatalogSchema,\n },\n {\n id: 'dynamic-workflow.runs',\n scope,\n service: 'po.hub',\n member: 'dynamic_workflow_runs',\n kind: 'channel',\n direction: 'server-to-client',\n description: 'Tracked workflow state for one session, without callback source or input/output data.',\n input: DynamicWorkflowSnapshotSchema,\n },\n ]),\n});\nexport default apiContracts;\n"],"mappings":";;;AAEA,MAAM,QAAQ,KAAK,MACjB;CAAC;CAAW;CAAW;CAAa;CAAU;CAAW;AAAS,CAAC,CAAC,KAAK,UAAU,KAAK,QAAQ,KAAK,CAAC,CACxG;AACA,MAAM,OAAO,KAAK,SAAS,KAAK,OAAO,CAAC;AACxC,MAAM,QAAQ,KAAK,OAAO;CACxB,KAAK,KAAK,OAAO;CACjB,OAAO,KAAK,OAAO;CACnB,QAAQ;CACR,iBAAiB;CACjB,WAAW;CACX,YAAY;CACZ,OAAO,KAAK,SAAS,KAAK,OAAO,CAAC;CAClC,QAAQ,KAAK,MACX,KAAK,OAAO;EACV,OAAO,KAAK,OAAO;EACnB,QAAQ,KAAK,MAAM;GAAC;GAAW;GAAa;GAAU;EAAS,CAAC,CAAC,KAAK,UAAU,KAAK,QAAQ,KAAK,CAAC,CAAC;CACtG,CAAC,CACH;AACF,CAAC;AACD,MAAM,QAAQ,KAAK,OAAO;CACxB,KAAK,KAAK,OAAO;CACjB,OAAO,KAAK,OAAO;CACnB,MAAM,KAAK,MAAM;EAAC;EAAQ;EAAY;EAAY;EAAU;CAAS,CAAC,CAAC,KAAK,UAAU,KAAK,QAAQ,KAAK,CAAC,CAAC;CAC1G,UAAU,KAAK,MAAM,KAAK,IAAI,eAAe,CAAC;AAChD,CAAC;AACD,MAAa,gCAAgC,KAAK,OAChD;CACE,SAAS,KAAK,QAAQ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