@agimon-ai/po-workflow 0.0.0-alpha.191 → 0.0.0-alpha.192

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
@@ -213,7 +213,7 @@ Agent steps require an effective `runConfig.preset`; delegated workflows require
213
213
 
214
214
  The native host requires execution-state inspection before creating agent steps. After settlement it waits for idle, no pending messages and a known background snapshot without core holds or holding-provider errors before checking decisions. Unknown ownership waits closed without consuming reminders; stops interrupt reads and retry delays. Running commands stop holding an inline step after five idle minutes, but its decision gate still runs before session release.
215
215
 
216
- Delegated successes are informational. Errors wake the workflow owner through durable custom-message admission; the launcher gets an error notification, not an agent-waking failure completion. Diagnosis stays local. Recovery, pause, resume and stop are request-driven. User-requested stops do not trigger diagnosis or automatic restart.
216
+ A delegated success is informational in the workflow owner and wakes the launcher to continue its applicable playbook. Errors wake the owner through durable custom-message admission; the launcher receives an error notification, not a competing recovery turn. The owner checks evidence and repairs within its authority. A parked run waits for the person's approval decision. User-requested stops do not trigger diagnosis or automatic restart.
217
217
 
218
218
  ## Development
219
219
 
@@ -285,6 +285,16 @@ const apiContracts = (0, _agimon_ai_po_core_apiContracts.defineApiContract)({
285
285
  "workspace",
286
286
  "session"
287
287
  ].flatMap((scope) => [
288
+ {
289
+ id: "workflow.catalog.refresh",
290
+ scope,
291
+ basePath: API_BASE_PATH,
292
+ path: "/catalog",
293
+ method: "GET",
294
+ authentication: OWNER_AUTHENTICATION,
295
+ description: "Refresh launchable definitions from the mounting runtime filesystem.",
296
+ responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(WorkflowCatalogSchema)
297
+ },
288
298
  {
289
299
  id: "workflow.screen",
290
300
  scope,
@@ -1 +1 @@
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 API_BASE_PATH = 'workflow';\nconst OWNER_AUTHENTICATION = 'owner';\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 Usage = Type.Object({\n tokens: O(Type.Object({ input: N, output: N, cacheRead: N, cacheWrite: N, total: N })),\n costUsd: O(N),\n toolCount: O(N),\n});\nconst Children = Type.Array(\n Type.Object({\n lead: S,\n continuations: N,\n maxContinuations: N,\n criteria: Type.Array(\n Type.Object({\n key: S,\n description: S,\n verifiedBy: S,\n status: values(['unchecked', 'checked', 'not-met']),\n feedback: O(S),\n invocationId: O(S),\n }),\n ),\n invocations: Type.Array(\n Type.Object({\n invocationId: S,\n job: S,\n state: values(['running', 'completed', 'failed', 'interrupted']),\n sessionIds: Type.Array(S),\n startedAt: S,\n endedAt: O(S),\n error: O(S),\n usage: O(Usage),\n }),\n ),\n }),\n);\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 waiting: O(Type.Literal(true)),\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 children: O(Children),\n childUsage: O(\n Type.Object({\n complete: B,\n invocationCount: N,\n tokensKnown: N,\n costKnown: N,\n toolCountKnown: N,\n tokens: O(Type.Object({ input: N, output: N, cacheRead: N, cacheWrite: N, total: N })),\n costUsd: O(N),\n toolCount: O(N),\n }),\n ),\n childStatusErrors: O(Type.Array(Type.Object({ lead: O(S), message: S }))),\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: (['host', 'workspace', 'session'] as const).flatMap((scope): PoHttpContract[] => [\n {\n id: 'workflow.screen',\n scope,\n basePath: API_BASE_PATH,\n path: `${root}/screen/stream`,\n method: 'GET',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/control`,\n method: 'POST',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/keys`,\n method: 'POST',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/resize`,\n method: 'POST',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: root,\n method: 'DELETE',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/open-directory`,\n method: 'POST',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/artifacts`,\n method: 'GET',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/artifacts/{name}`,\n method: 'GET',\n authentication: OWNER_AUTHENTICATION,\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: (['host', '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,C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T,QAAQ;GACR,MAAM;GACN,WAAW;GACX,aAAa;GACb,OAAO;EACT;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 API_BASE_PATH = 'workflow';\nconst OWNER_AUTHENTICATION = 'owner';\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 Usage = Type.Object({\n tokens: O(Type.Object({ input: N, output: N, cacheRead: N, cacheWrite: N, total: N })),\n costUsd: O(N),\n toolCount: O(N),\n});\nconst Children = Type.Array(\n Type.Object({\n lead: S,\n continuations: N,\n maxContinuations: N,\n criteria: Type.Array(\n Type.Object({\n key: S,\n description: S,\n verifiedBy: S,\n status: values(['unchecked', 'checked', 'not-met']),\n feedback: O(S),\n invocationId: O(S),\n }),\n ),\n invocations: Type.Array(\n Type.Object({\n invocationId: S,\n job: S,\n state: values(['running', 'completed', 'failed', 'interrupted']),\n sessionIds: Type.Array(S),\n startedAt: S,\n endedAt: O(S),\n error: O(S),\n usage: O(Usage),\n }),\n ),\n }),\n);\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 waiting: O(Type.Literal(true)),\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 children: O(Children),\n childUsage: O(\n Type.Object({\n complete: B,\n invocationCount: N,\n tokensKnown: N,\n costKnown: N,\n toolCountKnown: N,\n tokens: O(Type.Object({ input: N, output: N, cacheRead: N, cacheWrite: N, total: N })),\n costUsd: O(N),\n toolCount: O(N),\n }),\n ),\n childStatusErrors: O(Type.Array(Type.Object({ lead: O(S), message: S }))),\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: (['host', 'workspace', 'session'] as const).flatMap((scope): PoHttpContract[] => [\n {\n id: 'workflow.catalog.refresh',\n scope,\n basePath: API_BASE_PATH,\n path: '/catalog',\n method: 'GET',\n authentication: OWNER_AUTHENTICATION,\n description: 'Refresh launchable definitions from the mounting runtime filesystem.',\n responses: jsonApiResponses(WorkflowCatalogSchema),\n },\n {\n id: 'workflow.screen',\n scope,\n basePath: API_BASE_PATH,\n path: `${root}/screen/stream`,\n method: 'GET',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/control`,\n method: 'POST',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/keys`,\n method: 'POST',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/resize`,\n method: 'POST',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: root,\n method: 'DELETE',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/open-directory`,\n method: 'POST',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/artifacts`,\n method: 'GET',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/artifacts/{name}`,\n method: 'GET',\n authentication: OWNER_AUTHENTICATION,\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: (['host', '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,KAAK,OAAO;CACnB,QAAQ;CACR,iBAAiB;CACjB,WAAW;CACX,YAAY;CACZ,OAAOA,QAAAA,KAAK,SAASA,QAAAA,KAAK,OAAO,CAAC;CAClC,QAAQA,QAAAA,KAAK,MACXA,QAAAA,KAAK,OAAO;EACV,OAAOA,QAAAA,KAAK,OAAO;EACnB,QAAQA,QAAAA,KAAK,MAAM;GAAC;GAAW;GAAa;GAAU;EAAS,CAAC,CAAC,KAAK,UAAUA,QAAAA,KAAK,QAAQ,KAAK,CAAC,CAAC;CACtG,CAAC,CACH;AACF,CAAC;AACD,MAAM,QAAQA,QAAAA,KAAK,OAAO;CACxB,KAAKA,QAAAA,KAAK,OAAO;CACjB,OAAOA,QAAAA,KAAK,OAAO;CACnB,MAAMA,QAAAA,KAAK,MAAM;EAAC;EAAQ;EAAY;EAAY;EAAU;CAAS,CAAC,CAAC,KAAK,UAAUA,QAAAA,KAAK,QAAQ,KAAK,CAAC,CAAC;CAC1G,UAAUA,QAAAA,KAAK,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AAA,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,QAAQ,WAAW,CAAC,CAAW,SAAS,UAAU;EAC3D;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"}
@@ -281,6 +281,16 @@ const apiContracts = defineApiContract({
281
281
  "workspace",
282
282
  "session"
283
283
  ].flatMap((scope) => [
284
+ {
285
+ id: "workflow.catalog.refresh",
286
+ scope,
287
+ basePath: API_BASE_PATH,
288
+ path: "/catalog",
289
+ method: "GET",
290
+ authentication: OWNER_AUTHENTICATION,
291
+ description: "Refresh launchable definitions from the mounting runtime filesystem.",
292
+ responses: jsonApiResponses(WorkflowCatalogSchema)
293
+ },
284
294
  {
285
295
  id: "workflow.screen",
286
296
  scope,
@@ -1 +1 @@
1
- {"version":3,"file":"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 API_BASE_PATH = 'workflow';\nconst OWNER_AUTHENTICATION = 'owner';\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 Usage = Type.Object({\n tokens: O(Type.Object({ input: N, output: N, cacheRead: N, cacheWrite: N, total: N })),\n costUsd: O(N),\n toolCount: O(N),\n});\nconst Children = Type.Array(\n Type.Object({\n lead: S,\n continuations: N,\n maxContinuations: N,\n criteria: Type.Array(\n Type.Object({\n key: S,\n description: S,\n verifiedBy: S,\n status: values(['unchecked', 'checked', 'not-met']),\n feedback: O(S),\n invocationId: O(S),\n }),\n ),\n invocations: Type.Array(\n Type.Object({\n invocationId: S,\n job: S,\n state: values(['running', 'completed', 'failed', 'interrupted']),\n sessionIds: Type.Array(S),\n startedAt: S,\n endedAt: O(S),\n error: O(S),\n usage: O(Usage),\n }),\n ),\n }),\n);\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 waiting: O(Type.Literal(true)),\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 children: O(Children),\n childUsage: O(\n Type.Object({\n complete: B,\n invocationCount: N,\n tokensKnown: N,\n costKnown: N,\n toolCountKnown: N,\n tokens: O(Type.Object({ input: N, output: N, cacheRead: N, cacheWrite: N, total: N })),\n costUsd: O(N),\n toolCount: O(N),\n }),\n ),\n childStatusErrors: O(Type.Array(Type.Object({ lead: O(S), message: S }))),\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: (['host', 'workspace', 'session'] as const).flatMap((scope): PoHttpContract[] => [\n {\n id: 'workflow.screen',\n scope,\n basePath: API_BASE_PATH,\n path: `${root}/screen/stream`,\n method: 'GET',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/control`,\n method: 'POST',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/keys`,\n method: 'POST',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/resize`,\n method: 'POST',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: root,\n method: 'DELETE',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/open-directory`,\n method: 'POST',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/artifacts`,\n method: 'GET',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/artifacts/{name}`,\n method: 'GET',\n authentication: OWNER_AUTHENTICATION,\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: (['host', '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,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,CAAC"}
1
+ {"version":3,"file":"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 API_BASE_PATH = 'workflow';\nconst OWNER_AUTHENTICATION = 'owner';\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 Usage = Type.Object({\n tokens: O(Type.Object({ input: N, output: N, cacheRead: N, cacheWrite: N, total: N })),\n costUsd: O(N),\n toolCount: O(N),\n});\nconst Children = Type.Array(\n Type.Object({\n lead: S,\n continuations: N,\n maxContinuations: N,\n criteria: Type.Array(\n Type.Object({\n key: S,\n description: S,\n verifiedBy: S,\n status: values(['unchecked', 'checked', 'not-met']),\n feedback: O(S),\n invocationId: O(S),\n }),\n ),\n invocations: Type.Array(\n Type.Object({\n invocationId: S,\n job: S,\n state: values(['running', 'completed', 'failed', 'interrupted']),\n sessionIds: Type.Array(S),\n startedAt: S,\n endedAt: O(S),\n error: O(S),\n usage: O(Usage),\n }),\n ),\n }),\n);\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 waiting: O(Type.Literal(true)),\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 children: O(Children),\n childUsage: O(\n Type.Object({\n complete: B,\n invocationCount: N,\n tokensKnown: N,\n costKnown: N,\n toolCountKnown: N,\n tokens: O(Type.Object({ input: N, output: N, cacheRead: N, cacheWrite: N, total: N })),\n costUsd: O(N),\n toolCount: O(N),\n }),\n ),\n childStatusErrors: O(Type.Array(Type.Object({ lead: O(S), message: S }))),\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: (['host', 'workspace', 'session'] as const).flatMap((scope): PoHttpContract[] => [\n {\n id: 'workflow.catalog.refresh',\n scope,\n basePath: API_BASE_PATH,\n path: '/catalog',\n method: 'GET',\n authentication: OWNER_AUTHENTICATION,\n description: 'Refresh launchable definitions from the mounting runtime filesystem.',\n responses: jsonApiResponses(WorkflowCatalogSchema),\n },\n {\n id: 'workflow.screen',\n scope,\n basePath: API_BASE_PATH,\n path: `${root}/screen/stream`,\n method: 'GET',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/control`,\n method: 'POST',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/keys`,\n method: 'POST',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/resize`,\n method: 'POST',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: root,\n method: 'DELETE',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/open-directory`,\n method: 'POST',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/artifacts`,\n method: 'GET',\n authentication: OWNER_AUTHENTICATION,\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: API_BASE_PATH,\n path: `${root}/artifacts/{name}`,\n method: 'GET',\n authentication: OWNER_AUTHENTICATION,\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: (['host', '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,CAAC;CACvB,UAAU,KAAK,OAAO;CACtB,WAAW,KAAK,OAAO;CACvB,MAAM,KAAK,MACT,KAAK,OAAO;EACV,KAAK,KAAK,OAAO;EACjB,YAAY,KAAK,OAAO;EACxB,OAAO,KAAK,OAAO;EACnB,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AG,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,QAAQ,WAAW,CAAC,CAAW,SAAS,UAAU;EAC3D;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"}
@@ -236,143 +236,6 @@ const workflowRunsChannel = workflows.channel({
236
236
  }
237
237
  });
238
238
  //#endregion
239
- //#region src/extensions/workspaces/sessions/(frontend)/_lib/catalogStore.native.ts
240
- const catalog = defineSessionStore({
241
- cwd: "",
242
- workflows: [],
243
- warning: void 0,
244
- open: false,
245
- filter: "",
246
- prompt: "",
247
- selected: void 0,
248
- inspected: void 0,
249
- launch: void 0
250
- });
251
- function isRecord$1(value) {
252
- return typeof value === "object" && value !== null && !Array.isArray(value);
253
- }
254
- function openCatalog(sessionId, prompt = "") {
255
- catalog.update(sessionId, (current) => ({
256
- ...current,
257
- open: true,
258
- prompt
259
- }));
260
- }
261
- function closeCatalog(sessionId) {
262
- catalog.update(sessionId, (current) => ({
263
- ...current,
264
- open: false,
265
- prompt: "",
266
- launch: void 0
267
- }));
268
- }
269
- /** Rows whose name, path, tag or job matches the filter, case-insensitively. */
270
- function filterCatalog(workflows, filter) {
271
- const needle = filter.trim().toLowerCase();
272
- if (needle === "") return [...workflows];
273
- return workflows.filter((workflow) => [
274
- workflow.name,
275
- workflow.relativePath,
276
- workflow.description,
277
- ...workflow.tags,
278
- ...workflow.jobs.map((job) => job.name)
279
- ].join("\n").toLowerCase().includes(needle));
280
- }
281
- /** The plugin's catalog channel: 'workflow_catalog' payloads into the store. */
282
- const workflowCatalogChannel = catalog.channel({
283
- channel: WORKFLOW_CATALOG_TYPE,
284
- parse(input) {
285
- if (!isRecord$1(input) || typeof input.cwd !== "string" || !Array.isArray(input.workflows)) return null;
286
- return {
287
- cwd: input.cwd,
288
- workflows: input.workflows.filter(isRecord$1),
289
- ...typeof input.warning === "string" ? { warning: input.warning } : {}
290
- };
291
- },
292
- reduce(current, payload) {
293
- const paths = new Set(payload.workflows.map((workflow) => workflow.path));
294
- return {
295
- ...current,
296
- cwd: payload.cwd,
297
- workflows: payload.workflows,
298
- warning: payload.warning,
299
- selected: current.selected !== void 0 && paths.has(current.selected) ? current.selected : void 0,
300
- inspected: current.inspected !== void 0 && paths.has(current.inspected) ? current.inspected : void 0,
301
- launch: current.launch !== void 0 && paths.has(current.launch) ? current.launch : void 0
302
- };
303
- }
304
- });
305
- //#endregion
306
- //#region src/extensions/workspaces/sessions/(frontend)/_lib/launchLine.ts
307
- /**
308
- * The `/workflow-launch` line the dialog sends.
309
- *
310
- * WHY THE BUILDER LIVES HERE AND THE PARSER DOES NOT:
311
- * Cockpit code is compiled into the host bundle and may import only this
312
- * package's own web and type modules, so it cannot share the session's parser.
313
- * The two are pinned together by a test that parses what this writes, which is
314
- * the only guarantee that matters: the line has to survive the trip.
315
- */
316
- const WORKFLOW_LAUNCH_VERB = "/workflow-launch";
317
- /** Reserved keys; every other pair is one of the workflow's own inputs. */
318
- const RUNNER_KEY = "runner";
319
- const COMMAND_KEY = "command";
320
- const CHOICE_KEY = "choice";
321
- const PROFILE_KEY = "profile";
322
- /** Reserved key prefix: `assign.<role>=<stable profile ref>`. */
323
- const ASSIGN_PREFIX = "assign.";
324
- /** Quotes a value that carries whitespace, which is how a value survives tokenizing. */
325
- function quote(value) {
326
- return /\s/.test(value) ? `"${value}"` : value;
327
- }
328
- function reservedPair(key, value) {
329
- return value === void 0 || value === "" ? [] : [`${key}=${quote(value)}`];
330
- }
331
- function workflowLaunchLine(request) {
332
- const pairs = [
333
- ...reservedPair(RUNNER_KEY, request.runner),
334
- ...reservedPair(COMMAND_KEY, request.command),
335
- ...reservedPair(CHOICE_KEY, request.choice),
336
- ...reservedPair(PROFILE_KEY, request.profile),
337
- ...Object.entries(request.assignments ?? {}).flatMap(([role, ref]) => reservedPair(`${ASSIGN_PREFIX}${role}`, ref)),
338
- ...Object.entries(request.inputs).filter(([, value]) => value !== "").map(([key, value]) => `${key}=${quote(value)}`)
339
- ];
340
- const prompt = request.prompt?.trim();
341
- return [
342
- WORKFLOW_LAUNCH_VERB,
343
- quote(request.workflow),
344
- ...pairs,
345
- ...prompt ? ["--", prompt] : []
346
- ].join(" ");
347
- }
348
- /** The trigger that makes a prompt mandatory. */
349
- const USER_PROMPT_TRIGGER = "user_prompt";
350
- /** What the dialog will not let a reader send, worded the way the session would answer. */
351
- function launchProblems(workflow, request) {
352
- const problems = [];
353
- if (workflow.triggers.includes(USER_PROMPT_TRIGGER) && (request.prompt ?? "").trim() === "") problems.push("This workflow is triggered by a prompt, so it needs one.");
354
- const missing = workflow.inputs.filter((input) => input.required === true && (request.inputs[input.name] ?? "") === "").map((input) => input.name);
355
- if (missing.length > 0) problems.push(`Missing required input${missing.length > 1 ? "s" : ""}: ${missing.join(", ")}.`);
356
- return problems;
357
- }
358
- /** The default a field starts with: what the workflow declared, or empty. */
359
- function initialInputs(workflow) {
360
- return Object.fromEntries(workflow.inputs.map((input) => [input.name, input.default ?? ""]));
361
- }
362
- /** The runner a launch starts on: the workflow's first declared one, when it declares any. */
363
- function initialRunner(workflow) {
364
- return workflow.runners?.[0];
365
- }
366
- /** The command templated steps start on: the one their steps list first. */
367
- function initialCommand(workflow) {
368
- return workflow.commands?.[0];
369
- }
370
- /** The choice a launch starts on: `default` when declared, else the first. */
371
- function initialChoice(workflow) {
372
- const choices = workflow.choices ?? [];
373
- return choices.includes("default") ? "default" : choices[0];
374
- }
375
- //#endregion
376
239
  //#region src/types/apiRoutes.ts
377
240
  /**
378
241
  * This package's routes, as data.
@@ -410,6 +273,12 @@ const ARTIFACT_NAME_PARAM = ":name{.+}";
410
273
  const STEP_TARGET_PARAM = "step";
411
274
  const ARTIFACT_DOWNLOAD_PARAM = "download";
412
275
  const api = createApiClient({
276
+ /** Refresh the catalog from the mounting runtime, including files written outside agent tools. */
277
+ catalog: {
278
+ method: "GET",
279
+ path: "/catalog",
280
+ response: void 0
281
+ },
413
282
  /**
414
283
  * The terminal, as server-sent events.
415
284
  *
@@ -517,6 +386,153 @@ const api = createApiClient({
517
386
  sessionAddress: sessionApiAddress
518
387
  });
519
388
  //#endregion
389
+ //#region src/extensions/workspaces/sessions/(frontend)/_lib/catalogStore.native.ts
390
+ const catalog = defineSessionStore({
391
+ cwd: "",
392
+ workflows: [],
393
+ warning: void 0,
394
+ open: false,
395
+ filter: "",
396
+ prompt: "",
397
+ selected: void 0,
398
+ inspected: void 0,
399
+ launch: void 0
400
+ });
401
+ function isRecord$1(value) {
402
+ return typeof value === "object" && value !== null && !Array.isArray(value);
403
+ }
404
+ function openCatalog(sessionId, prompt = "") {
405
+ catalog.update(sessionId, (current) => ({
406
+ ...current,
407
+ open: true,
408
+ prompt
409
+ }));
410
+ Promise.resolve().then(() => api.session(sessionId).catalog()).then((result) => {
411
+ if (result.ok) workflowCatalogChannel.apply(sessionId, result.data);
412
+ else catalog.update(sessionId, (current) => ({
413
+ ...current,
414
+ warning: result.error || "The workflow catalog could not be refreshed."
415
+ }));
416
+ }, () => catalog.update(sessionId, (current) => ({
417
+ ...current,
418
+ warning: "The workflow catalog could not be refreshed."
419
+ })));
420
+ }
421
+ function closeCatalog(sessionId) {
422
+ catalog.update(sessionId, (current) => ({
423
+ ...current,
424
+ open: false,
425
+ prompt: "",
426
+ launch: void 0
427
+ }));
428
+ }
429
+ /** Rows whose name, path, tag or job matches the filter, case-insensitively. */
430
+ function filterCatalog(workflows, filter) {
431
+ const needle = filter.trim().toLowerCase();
432
+ if (needle === "") return [...workflows];
433
+ return workflows.filter((workflow) => [
434
+ workflow.name,
435
+ workflow.relativePath,
436
+ workflow.description,
437
+ ...workflow.tags,
438
+ ...workflow.jobs.map((job) => job.name)
439
+ ].join("\n").toLowerCase().includes(needle));
440
+ }
441
+ /** The plugin's catalog channel: 'workflow_catalog' payloads into the store. */
442
+ const workflowCatalogChannel = catalog.channel({
443
+ channel: WORKFLOW_CATALOG_TYPE,
444
+ parse(input) {
445
+ if (!isRecord$1(input) || typeof input.cwd !== "string" || !Array.isArray(input.workflows)) return null;
446
+ return {
447
+ cwd: input.cwd,
448
+ workflows: input.workflows.filter(isRecord$1),
449
+ ...typeof input.warning === "string" ? { warning: input.warning } : {}
450
+ };
451
+ },
452
+ reduce(current, payload) {
453
+ const paths = new Set(payload.workflows.map((workflow) => workflow.path));
454
+ return {
455
+ ...current,
456
+ cwd: payload.cwd,
457
+ workflows: payload.workflows,
458
+ warning: payload.warning,
459
+ selected: current.selected !== void 0 && paths.has(current.selected) ? current.selected : void 0,
460
+ inspected: current.inspected !== void 0 && paths.has(current.inspected) ? current.inspected : void 0,
461
+ launch: current.launch !== void 0 && paths.has(current.launch) ? current.launch : void 0
462
+ };
463
+ }
464
+ });
465
+ //#endregion
466
+ //#region src/extensions/workspaces/sessions/(frontend)/_lib/launchLine.ts
467
+ /**
468
+ * The `/workflow-launch` line the dialog sends.
469
+ *
470
+ * WHY THE BUILDER LIVES HERE AND THE PARSER DOES NOT:
471
+ * Cockpit code is compiled into the host bundle and may import only this
472
+ * package's own web and type modules, so it cannot share the session's parser.
473
+ * The two are pinned together by a test that parses what this writes, which is
474
+ * the only guarantee that matters: the line has to survive the trip.
475
+ */
476
+ const WORKFLOW_LAUNCH_VERB = "/workflow-launch";
477
+ /** Reserved keys; every other pair is one of the workflow's own inputs. */
478
+ const RUNNER_KEY = "runner";
479
+ const COMMAND_KEY = "command";
480
+ const CHOICE_KEY = "choice";
481
+ const PROFILE_KEY = "profile";
482
+ /** Reserved key prefix: `assign.<role>=<stable profile ref>`. */
483
+ const ASSIGN_PREFIX = "assign.";
484
+ /** Quotes a value that carries whitespace, which is how a value survives tokenizing. */
485
+ function quote(value) {
486
+ return /\s/.test(value) ? `"${value}"` : value;
487
+ }
488
+ function reservedPair(key, value) {
489
+ return value === void 0 || value === "" ? [] : [`${key}=${quote(value)}`];
490
+ }
491
+ function workflowLaunchLine(request) {
492
+ const pairs = [
493
+ ...reservedPair(RUNNER_KEY, request.runner),
494
+ ...reservedPair(COMMAND_KEY, request.command),
495
+ ...reservedPair(CHOICE_KEY, request.choice),
496
+ ...reservedPair(PROFILE_KEY, request.profile),
497
+ ...Object.entries(request.assignments ?? {}).flatMap(([role, ref]) => reservedPair(`${ASSIGN_PREFIX}${role}`, ref)),
498
+ ...Object.entries(request.inputs).filter(([, value]) => value !== "").map(([key, value]) => `${key}=${quote(value)}`)
499
+ ];
500
+ const prompt = request.prompt?.trim();
501
+ return [
502
+ WORKFLOW_LAUNCH_VERB,
503
+ quote(request.workflow),
504
+ ...pairs,
505
+ ...prompt ? ["--", prompt] : []
506
+ ].join(" ");
507
+ }
508
+ /** The trigger that makes a prompt mandatory. */
509
+ const USER_PROMPT_TRIGGER = "user_prompt";
510
+ /** What the dialog will not let a reader send, worded the way the session would answer. */
511
+ function launchProblems(workflow, request) {
512
+ const problems = [];
513
+ if (workflow.triggers.includes(USER_PROMPT_TRIGGER) && (request.prompt ?? "").trim() === "") problems.push("This workflow is triggered by a prompt, so it needs one.");
514
+ const missing = workflow.inputs.filter((input) => input.required === true && (request.inputs[input.name] ?? "") === "").map((input) => input.name);
515
+ if (missing.length > 0) problems.push(`Missing required input${missing.length > 1 ? "s" : ""}: ${missing.join(", ")}.`);
516
+ return problems;
517
+ }
518
+ /** The default a field starts with: what the workflow declared, or empty. */
519
+ function initialInputs(workflow) {
520
+ return Object.fromEntries(workflow.inputs.map((input) => [input.name, input.default ?? ""]));
521
+ }
522
+ /** The runner a launch starts on: the workflow's first declared one, when it declares any. */
523
+ function initialRunner(workflow) {
524
+ return workflow.runners?.[0];
525
+ }
526
+ /** The command templated steps start on: the one their steps list first. */
527
+ function initialCommand(workflow) {
528
+ return workflow.commands?.[0];
529
+ }
530
+ /** The choice a launch starts on: `default` when declared, else the first. */
531
+ function initialChoice(workflow) {
532
+ const choices = workflow.choices ?? [];
533
+ return choices.includes("default") ? "default" : choices[0];
534
+ }
535
+ //#endregion
520
536
  //#region src/extensions/workspaces/sessions/(frontend)/_lib/terminalApi.native.ts
521
537
  /**
522
538
  * The page's half of this package's hub API: one run's terminal and the files