@agimon-ai/doompi-workflow 0.0.1-alpha.113 → 0.0.1-alpha.115
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/dist/apiContracts.cjs +27 -1
- package/dist/apiContracts.cjs.map +1 -1
- package/dist/apiContracts.mjs +27 -1
- package/dist/apiContracts.mjs.map +1 -1
- package/dist/extensions/server.cjs +144 -31
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.mjs +144 -31
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +180 -55
- package/dist/extensions/web.mjs.map +1 -1
- package/package.json +13 -13
- package/src/types/webWorkflowTerminal.ts +5 -0
- package/src/types/webWorkflows.ts +2 -1
package/dist/apiContracts.cjs
CHANGED
|
@@ -237,6 +237,26 @@ const apiContracts = (0, _agimon_ai_doompi_core_apiContracts.defineApiContract)(
|
|
|
237
237
|
description: "Delete a settled run and its directory.",
|
|
238
238
|
responses: (0, _agimon_ai_doompi_core_apiContracts.jsonApiResponses)(typebox.Type.Object({ deleted: typebox.Type.Literal(true) }))
|
|
239
239
|
},
|
|
240
|
+
{
|
|
241
|
+
id: "workflow.openRunDirectory",
|
|
242
|
+
scope,
|
|
243
|
+
basePath: "workflow",
|
|
244
|
+
path: `${root}/open-directory`,
|
|
245
|
+
method: "POST",
|
|
246
|
+
authentication: "owner",
|
|
247
|
+
description: "Open the registered run folder in Finder. Local callers only.",
|
|
248
|
+
responses: {
|
|
249
|
+
...(0, _agimon_ai_doompi_core_apiContracts.jsonApiResponses)(typebox.Type.Object({ opened: typebox.Type.Literal(true) })),
|
|
250
|
+
"403": {
|
|
251
|
+
description: "Local caller required.",
|
|
252
|
+
schema: typebox.Type.Object({ error: S })
|
|
253
|
+
},
|
|
254
|
+
"409": {
|
|
255
|
+
description: "Folder opening unavailable.",
|
|
256
|
+
schema: typebox.Type.Object({ error: S })
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
},
|
|
240
260
|
{
|
|
241
261
|
id: "workflow.artifacts",
|
|
242
262
|
scope,
|
|
@@ -244,7 +264,13 @@ const apiContracts = (0, _agimon_ai_doompi_core_apiContracts.defineApiContract)(
|
|
|
244
264
|
path: `${root}/artifacts`,
|
|
245
265
|
method: "GET",
|
|
246
266
|
authentication: "owner",
|
|
247
|
-
description: "List declared and discovered artifacts.",
|
|
267
|
+
description: "List declared and discovered artifacts, or immediate children of a directory.",
|
|
268
|
+
parameters: [{
|
|
269
|
+
name: "directory",
|
|
270
|
+
in: "query",
|
|
271
|
+
required: false,
|
|
272
|
+
schema: S
|
|
273
|
+
}],
|
|
248
274
|
responses: (0, _agimon_ai_doompi_core_apiContracts.jsonApiResponses)(typebox.Type.Object({
|
|
249
275
|
runDir: S,
|
|
250
276
|
description: S,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiContracts.cjs","names":["Type","defineApiContract","jsonApiResponses"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type DoomHttpContract } from '@agimon-ai/doompi-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 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): DoomHttpContract[] => [\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.artifacts',\n scope,\n basePath: 'workflow',\n path: `${root}/artifacts`,\n method: 'GET',\n authentication: 'owner',\n description: 'List declared and discovered artifacts.',\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: 'doompi.hub.v1',\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: 'doompi.hub.v1',\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,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,E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ACE,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","defineApiContract","jsonApiResponses"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type DoomHttpContract } from '@agimon-ai/doompi-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 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): DoomHttpContract[] => [\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: 'doompi.hub.v1',\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: 'doompi.hub.v1',\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,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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AC;IAAE;IAC7E;KAAE,MAAM;KAAS,IAAI;KAAU,UAAU;KAAO,QAAQ;IAAE;GAC5D;GACA,WAAW;IACT,IAAA,GAAGE,oCAAAA,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,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"}
|
package/dist/apiContracts.mjs
CHANGED
|
@@ -233,6 +233,26 @@ const apiContracts = defineApiContract({
|
|
|
233
233
|
description: "Delete a settled run and its directory.",
|
|
234
234
|
responses: jsonApiResponses(Type.Object({ deleted: Type.Literal(true) }))
|
|
235
235
|
},
|
|
236
|
+
{
|
|
237
|
+
id: "workflow.openRunDirectory",
|
|
238
|
+
scope,
|
|
239
|
+
basePath: "workflow",
|
|
240
|
+
path: `${root}/open-directory`,
|
|
241
|
+
method: "POST",
|
|
242
|
+
authentication: "owner",
|
|
243
|
+
description: "Open the registered run folder in Finder. Local callers only.",
|
|
244
|
+
responses: {
|
|
245
|
+
...jsonApiResponses(Type.Object({ opened: Type.Literal(true) })),
|
|
246
|
+
"403": {
|
|
247
|
+
description: "Local caller required.",
|
|
248
|
+
schema: Type.Object({ error: S })
|
|
249
|
+
},
|
|
250
|
+
"409": {
|
|
251
|
+
description: "Folder opening unavailable.",
|
|
252
|
+
schema: Type.Object({ error: S })
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
},
|
|
236
256
|
{
|
|
237
257
|
id: "workflow.artifacts",
|
|
238
258
|
scope,
|
|
@@ -240,7 +260,13 @@ const apiContracts = defineApiContract({
|
|
|
240
260
|
path: `${root}/artifacts`,
|
|
241
261
|
method: "GET",
|
|
242
262
|
authentication: "owner",
|
|
243
|
-
description: "List declared and discovered artifacts.",
|
|
263
|
+
description: "List declared and discovered artifacts, or immediate children of a directory.",
|
|
264
|
+
parameters: [{
|
|
265
|
+
name: "directory",
|
|
266
|
+
in: "query",
|
|
267
|
+
required: false,
|
|
268
|
+
schema: S
|
|
269
|
+
}],
|
|
244
270
|
responses: jsonApiResponses(Type.Object({
|
|
245
271
|
runDir: S,
|
|
246
272
|
description: S,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type DoomHttpContract } from '@agimon-ai/doompi-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 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): DoomHttpContract[] => [\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.artifacts',\n scope,\n basePath: 'workflow',\n path: `${root}/artifacts`,\n method: 'GET',\n authentication: 'owner',\n description: 'List declared and discovered artifacts.',\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: 'doompi.hub.v1',\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: 'doompi.hub.v1',\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,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,CA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AI;GACJ;GACA,UAAU;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,GAAG,iBACD,KAAK,MAAM,CAAC,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,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.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type DoomHttpContract } from '@agimon-ai/doompi-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 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): DoomHttpContract[] => [\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: 'doompi.hub.v1',\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: 'doompi.hub.v1',\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,OA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,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,GAAG,iBACD,KAAK,MAAM,CAAC,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,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"}
|
|
@@ -14,12 +14,14 @@ node_path = require_workflowTerminal.__toESM(node_path, 1);
|
|
|
14
14
|
let _agimon_ai_workflow_mcp = require("@agimon-ai/workflow-mcp");
|
|
15
15
|
let zod = require("zod");
|
|
16
16
|
let node_crypto = require("node:crypto");
|
|
17
|
+
let node_child_process = require("node:child_process");
|
|
17
18
|
let _agimon_ai_doompi_minor_mode = require("@agimon-ai/doompi-minor-mode");
|
|
18
19
|
let _agimon_ai_doompi_telemetry = require("@agimon-ai/doompi-telemetry");
|
|
19
20
|
let _agimon_ai_doompi_core_serverFacet = require("@agimon-ai/doompi-core/serverFacet");
|
|
20
21
|
let _agimon_ai_doompi_core_notification = require("@agimon-ai/doompi-core/notification");
|
|
21
22
|
let _agimon_ai_doompi_core_hubChannel = require("@agimon-ai/doompi-core/hubChannel");
|
|
22
23
|
let node_stream = require("node:stream");
|
|
24
|
+
let _agimon_ai_doompi_core_packageApi = require("@agimon-ai/doompi-core/packageApi");
|
|
23
25
|
let hono = require("hono");
|
|
24
26
|
let hono_streaming = require("hono/streaming");
|
|
25
27
|
let _agimon_ai_doompi_core_web = require("@agimon-ai/doompi-core/web");
|
|
@@ -223,14 +225,56 @@ function jobPhase(name) {
|
|
|
223
225
|
if (name === PHASE_JOB_POST) return PHASE_JOB_POST;
|
|
224
226
|
return "job";
|
|
225
227
|
}
|
|
226
|
-
/**
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
228
|
+
/** Names match the engine's progress log, including unnamed parallel children. */
|
|
229
|
+
function plannedSteps(steps = []) {
|
|
230
|
+
return steps.flatMap((step, index) => {
|
|
231
|
+
const name = step.name ?? `step ${index + 1}`;
|
|
232
|
+
return step.parallel === void 0 ? [{
|
|
233
|
+
name,
|
|
234
|
+
status: "pending"
|
|
235
|
+
}] : step.parallel.map((child, childIndex) => ({
|
|
236
|
+
name: child.name ?? `${name} ${childIndex + 1}`,
|
|
237
|
+
status: "pending",
|
|
238
|
+
group: name
|
|
239
|
+
}));
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
/** The whole declared route, before any job or step has emitted progress. */
|
|
243
|
+
function planWorkflowJobs(workflow, order) {
|
|
244
|
+
const jobs = order.map((name) => {
|
|
245
|
+
const job = workflow.jobs[name];
|
|
246
|
+
return {
|
|
247
|
+
name,
|
|
248
|
+
phase: "job",
|
|
249
|
+
status: "pending",
|
|
250
|
+
steps: [
|
|
251
|
+
...plannedSteps(job.preJob?.steps),
|
|
252
|
+
...plannedSteps(job.steps),
|
|
253
|
+
...plannedSteps(job.postJob?.steps)
|
|
254
|
+
]
|
|
255
|
+
};
|
|
256
|
+
});
|
|
257
|
+
if (workflow.pre !== void 0) jobs.unshift({
|
|
258
|
+
name: PHASE_JOB_PRE,
|
|
259
|
+
phase: "pre",
|
|
260
|
+
status: "pending",
|
|
261
|
+
steps: plannedSteps(workflow.pre.steps)
|
|
262
|
+
});
|
|
263
|
+
if (workflow.post !== void 0) jobs.push({
|
|
264
|
+
name: PHASE_JOB_POST,
|
|
265
|
+
phase: "post",
|
|
266
|
+
status: "pending",
|
|
267
|
+
steps: plannedSteps(workflow.post.steps)
|
|
268
|
+
});
|
|
269
|
+
return jobs;
|
|
270
|
+
}
|
|
271
|
+
/** Overlay progress on the plan, retaining recorded jobs and steps absent from the current definition. */
|
|
272
|
+
function foldWorkflowProgress(events, plan = []) {
|
|
273
|
+
const jobs = plan.map((job) => ({
|
|
274
|
+
...job,
|
|
275
|
+
steps: job.steps.map((step) => ({ ...step }))
|
|
276
|
+
}));
|
|
277
|
+
const jobByName = new Map(jobs.map((job) => [job.name, job]));
|
|
234
278
|
for (const event of events) {
|
|
235
279
|
let job = jobByName.get(event.job);
|
|
236
280
|
if (job === void 0) {
|
|
@@ -258,6 +302,7 @@ function foldWorkflowProgress(events) {
|
|
|
258
302
|
continue;
|
|
259
303
|
}
|
|
260
304
|
if (event.step === void 0) continue;
|
|
305
|
+
if (job.status === "pending") job.status = event.status;
|
|
261
306
|
let step = job.steps.find((candidate) => candidate.name === event.step);
|
|
262
307
|
if (step === void 0) {
|
|
263
308
|
step = {
|
|
@@ -278,6 +323,9 @@ function foldWorkflowProgress(events) {
|
|
|
278
323
|
if (event.status === "running" && step.startedAt === void 0) step.startedAt = event.at;
|
|
279
324
|
if (STEP_TERMINAL_STATES.has(event.status)) step.endedAt = event.at;
|
|
280
325
|
}
|
|
326
|
+
for (const job of jobs) if (job.status === "skipped") {
|
|
327
|
+
for (const step of job.steps) if (step.status === "pending") step.status = "skipped";
|
|
328
|
+
}
|
|
281
329
|
return jobs;
|
|
282
330
|
}
|
|
283
331
|
const ACTIVE_PROGRESS_STATES = /* @__PURE__ */ new Set([
|
|
@@ -1368,9 +1416,15 @@ var apiRoutes_default = (0, _agimon_ai_doompi_core_web.defineApiRoutes)({
|
|
|
1368
1416
|
path: "/launch",
|
|
1369
1417
|
response: (0, _agimon_ai_doompi_core_web.apiResponse)()
|
|
1370
1418
|
},
|
|
1419
|
+
openRunDirectory: {
|
|
1420
|
+
method: "POST",
|
|
1421
|
+
path: `${RUN}/open-directory`,
|
|
1422
|
+
response: (0, _agimon_ai_doompi_core_web.apiResponse)()
|
|
1423
|
+
},
|
|
1371
1424
|
artifacts: {
|
|
1372
1425
|
method: "GET",
|
|
1373
1426
|
path: `${RUN}/artifacts`,
|
|
1427
|
+
query: ["directory"],
|
|
1374
1428
|
response: (0, _agimon_ai_doompi_core_web.apiResponse)()
|
|
1375
1429
|
},
|
|
1376
1430
|
/** One artifact: its metadata and text, or its raw bytes under `raw=1`. */
|
|
@@ -1681,18 +1735,49 @@ function createWorkflowHubApi(options = {}) {
|
|
|
1681
1735
|
}
|
|
1682
1736
|
return context.json({ deleted: true });
|
|
1683
1737
|
});
|
|
1738
|
+
app.post(apiRoutes_default.openRunDirectory.path, async (context) => {
|
|
1739
|
+
if ((0, _agimon_ai_doompi_core_packageApi.doomApiCallerFrom)(context.req.raw.headers)?.locality !== "local") return context.json({ error: "Opening Finder is only available on the host." }, 403);
|
|
1740
|
+
const workspace = context.req.param("workspace");
|
|
1741
|
+
const runKey = context.req.param("runKey");
|
|
1742
|
+
const record = await runOf(workspace, runKey);
|
|
1743
|
+
if (record === void 0) return context.json(missing(workspace, runKey), 404);
|
|
1744
|
+
if (process.platform !== "darwin") return context.json({ error: "Finder is only available on macOS." }, 409);
|
|
1745
|
+
try {
|
|
1746
|
+
const runDir = node_path.default.resolve(registry.runDirectoryFor(record));
|
|
1747
|
+
if (!node_fs.default.statSync(runDir).isDirectory()) return context.json({ error: "The run directory is not a folder." }, 409);
|
|
1748
|
+
await new Promise((resolve, reject) => {
|
|
1749
|
+
(0, node_child_process.execFile)("/usr/bin/open", [
|
|
1750
|
+
"-a",
|
|
1751
|
+
"Finder",
|
|
1752
|
+
runDir
|
|
1753
|
+
], { timeout: 5e3 }, (error) => {
|
|
1754
|
+
if (error) reject(error);
|
|
1755
|
+
else resolve();
|
|
1756
|
+
});
|
|
1757
|
+
});
|
|
1758
|
+
return context.json({ opened: true });
|
|
1759
|
+
} catch (error) {
|
|
1760
|
+
return context.json({ error: error instanceof Error ? error.message : String(error) }, 409);
|
|
1761
|
+
}
|
|
1762
|
+
});
|
|
1684
1763
|
app.get(apiRoutes_default.artifacts.path, async (context) => {
|
|
1685
1764
|
const workspace = context.req.param("workspace");
|
|
1686
1765
|
const runKey = context.req.param("runKey");
|
|
1687
1766
|
const record = await runOf(workspace, runKey);
|
|
1688
1767
|
if (record === void 0) return context.json(missing(workspace, runKey), 404);
|
|
1689
1768
|
const runDir = registry.runDirectoryFor(record);
|
|
1690
|
-
const
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1769
|
+
const directory = context.req.query("directory") ?? "";
|
|
1770
|
+
if (resolveInside(runDir, directory) === void 0) return context.json({ error: "That folder is not inside this run." }, 400);
|
|
1771
|
+
try {
|
|
1772
|
+
const body = {
|
|
1773
|
+
runDir,
|
|
1774
|
+
description: record.runDirectory?.description ?? "",
|
|
1775
|
+
artifacts: readArtifacts(runDir, record, directory)
|
|
1776
|
+
};
|
|
1777
|
+
return context.json(body);
|
|
1778
|
+
} catch (error) {
|
|
1779
|
+
return context.json({ error: error instanceof Error ? error.message : String(error) }, 409);
|
|
1780
|
+
}
|
|
1696
1781
|
});
|
|
1697
1782
|
app.get(apiRoutes_default.artifact.path, async (context) => {
|
|
1698
1783
|
const workspace = context.req.param("workspace");
|
|
@@ -1721,7 +1806,20 @@ function resolveInside(runDir, requested) {
|
|
|
1721
1806
|
const resolved = node_path.default.resolve(runDir, requested);
|
|
1722
1807
|
const root = node_path.default.resolve(runDir);
|
|
1723
1808
|
if (resolved !== root && !resolved.startsWith(`${root}${node_path.default.sep}`)) return void 0;
|
|
1724
|
-
|
|
1809
|
+
try {
|
|
1810
|
+
const realRoot = node_fs.default.realpathSync(root);
|
|
1811
|
+
let ancestor = resolved;
|
|
1812
|
+
while (!node_fs.default.existsSync(ancestor)) {
|
|
1813
|
+
const parent = node_path.default.dirname(ancestor);
|
|
1814
|
+
if (parent === ancestor) return void 0;
|
|
1815
|
+
ancestor = parent;
|
|
1816
|
+
}
|
|
1817
|
+
const real = node_fs.default.realpathSync(ancestor);
|
|
1818
|
+
if (real !== realRoot && !real.startsWith(`${realRoot}${node_path.default.sep}`)) return void 0;
|
|
1819
|
+
return resolved;
|
|
1820
|
+
} catch {
|
|
1821
|
+
return;
|
|
1822
|
+
}
|
|
1725
1823
|
}
|
|
1726
1824
|
/** Size and modification time of one path, or undefined when it is not there. */
|
|
1727
1825
|
function statOf(target) {
|
|
@@ -1737,10 +1835,12 @@ function stateOf(stats) {
|
|
|
1737
1835
|
return stats.size === 0 ? "empty" : "written";
|
|
1738
1836
|
}
|
|
1739
1837
|
function viewOf(runDir, entry) {
|
|
1740
|
-
const
|
|
1838
|
+
const target = resolveInside(runDir, entry.path);
|
|
1839
|
+
const stats = target === void 0 ? void 0 : statOf(target);
|
|
1741
1840
|
return {
|
|
1742
1841
|
...entry,
|
|
1743
|
-
|
|
1842
|
+
kind: stats?.isDirectory() ? "directory" : entry.kind,
|
|
1843
|
+
state: target === void 0 ? "unreadable" : stateOf(stats),
|
|
1744
1844
|
...stats === void 0 ? {} : {
|
|
1745
1845
|
size: stats.size,
|
|
1746
1846
|
modifiedAt: stats.mtime.toISOString()
|
|
@@ -1756,7 +1856,7 @@ function viewOf(runDir, entry) {
|
|
|
1756
1856
|
* hidden: the engine's own context.md and progress log are often exactly what a
|
|
1757
1857
|
* reader is looking for.
|
|
1758
1858
|
*/
|
|
1759
|
-
function readArtifacts(runDir, record) {
|
|
1859
|
+
function readArtifacts(runDir, record, directory = "") {
|
|
1760
1860
|
const declared = (record.runDirectory?.entries ?? []).map((entry) => viewOf(runDir, {
|
|
1761
1861
|
path: entry.path,
|
|
1762
1862
|
kind: entry.kind,
|
|
@@ -1764,21 +1864,16 @@ function readArtifacts(runDir, record) {
|
|
|
1764
1864
|
producedBy: entry["produced-by"] ?? [],
|
|
1765
1865
|
declared: true
|
|
1766
1866
|
}));
|
|
1767
|
-
const
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
} catch {
|
|
1772
|
-
return declared;
|
|
1773
|
-
}
|
|
1774
|
-
const found = names.filter((entry) => !claimed.has(entry.name)).map((entry) => viewOf(runDir, {
|
|
1775
|
-
path: entry.name,
|
|
1867
|
+
const children = declared.filter((entry) => node_path.default.posix.dirname(entry.path) === (directory || "."));
|
|
1868
|
+
const claimed = new Set(children.map((entry) => entry.path));
|
|
1869
|
+
const found = node_fs.default.readdirSync(node_path.default.join(runDir, directory), { withFileTypes: true }).filter((entry) => !claimed.has(node_path.default.posix.join(directory, entry.name))).map((entry) => viewOf(runDir, {
|
|
1870
|
+
path: node_path.default.posix.join(directory, entry.name),
|
|
1776
1871
|
kind: entry.isDirectory() ? "directory" : "file",
|
|
1777
1872
|
description: "",
|
|
1778
1873
|
producedBy: [],
|
|
1779
1874
|
declared: false
|
|
1780
1875
|
})).sort((left, right) => left.path.localeCompare(right.path));
|
|
1781
|
-
return [...declared, ...found];
|
|
1876
|
+
return [...directory === "" ? declared : children, ...found];
|
|
1782
1877
|
}
|
|
1783
1878
|
/** Browser content type inferred from a filename without trusting client input. */
|
|
1784
1879
|
function artifactMimeType(requested) {
|
|
@@ -2079,6 +2174,7 @@ function createWorkflowSessionLifecycle(deps) {
|
|
|
2079
2174
|
}
|
|
2080
2175
|
//#endregion
|
|
2081
2176
|
//#region src/services/workflowWatcher/index.ts
|
|
2177
|
+
const { parser } = (0, _agimon_ai_workflow_mcp.createEmbeddedWorkflowFeature)();
|
|
2082
2178
|
/**
|
|
2083
2179
|
* Read the durable workflow registry once.
|
|
2084
2180
|
*
|
|
@@ -2126,6 +2222,18 @@ function readWorkflowRuns(options = {}) {
|
|
|
2126
2222
|
return [];
|
|
2127
2223
|
}
|
|
2128
2224
|
};
|
|
2225
|
+
const plans = /* @__PURE__ */ new Map();
|
|
2226
|
+
const planFor = (workflowPath) => {
|
|
2227
|
+
const cached = plans.get(workflowPath);
|
|
2228
|
+
if (cached !== void 0) return cached;
|
|
2229
|
+
let plan = [];
|
|
2230
|
+
try {
|
|
2231
|
+
const workflow = parser.parseWorkflowFile(workflowPath);
|
|
2232
|
+
plan = planWorkflowJobs(workflow, parser.resolveJobOrder(workflow.jobs, null));
|
|
2233
|
+
} catch {}
|
|
2234
|
+
plans.set(workflowPath, plan);
|
|
2235
|
+
return plan;
|
|
2236
|
+
};
|
|
2129
2237
|
const runs = [];
|
|
2130
2238
|
for (const workspace of listDir(workspacesDir)) for (const stage of WORKFLOW_STAGES) {
|
|
2131
2239
|
const stageDir = node_path.default.join(workspacesDir, workspace, stage);
|
|
@@ -2135,7 +2243,7 @@ function readWorkflowRuns(options = {}) {
|
|
|
2135
2243
|
const progressPath = node_path.default.join(runDir, PROGRESS_FILE_NAME);
|
|
2136
2244
|
const parsed = cachedParse(recordCache, recordPath, parseWorkflowRunRecord, void 0);
|
|
2137
2245
|
if (parsed === void 0) continue;
|
|
2138
|
-
const jobs = cachedParse(progressCache, progressPath,
|
|
2246
|
+
const jobs = foldWorkflowProgress(cachedParse(progressCache, progressPath, parseWorkflowProgress, []), planFor(parsed.view.workflowPath));
|
|
2139
2247
|
runs.push({
|
|
2140
2248
|
...parsed,
|
|
2141
2249
|
view: completeWorkflowRunView(parsed.view, jobs)
|
|
@@ -2741,8 +2849,13 @@ function createWorkflowServerRuntime(host, serverHost) {
|
|
|
2741
2849
|
},
|
|
2742
2850
|
name: LAUNCH_TOOL,
|
|
2743
2851
|
label: "Launch Workflow",
|
|
2744
|
-
description: "Start a workflow run. A successful launch is not a completed workflow.",
|
|
2745
|
-
promptGuidelines: [
|
|
2852
|
+
description: "Start a workflow run. Prefer in-process Pi execution with command: \"pi\" when supported; runner: \"codex\" is not an alias for it. A successful launch is not a completed workflow.",
|
|
2853
|
+
promptGuidelines: [
|
|
2854
|
+
"Before launching, inspect the workflow and its imports for commands and interactiveRun choices. Prefer a supported Pi template with inProcess: true, selected explicitly with command: \"pi\" (or a supported in-process \"pi-claude\" command when requested). Only use an external CLI when the user requests it or no in-process option exists.",
|
|
2855
|
+
"command selects the exact template. Without it, runner only matches an exact command name; otherwise each step uses its first command. runner: \"codex\" does not imply command: \"pi\", so pass command explicitly to avoid switching to \"claude\" on later steps.",
|
|
2856
|
+
"Launch returns when a run starts, not when it finishes. Use the exact run key and separate workspace from its launch result for workflow_run status, not Agiflow project or job identifiers.",
|
|
2857
|
+
"Do not relaunch a healthy running workflow merely because it has not completed."
|
|
2858
|
+
],
|
|
2746
2859
|
parameters: zod.z.toJSONSchema(feature.runTool.getInputSchema()),
|
|
2747
2860
|
executionMode: "serial",
|
|
2748
2861
|
async execute(_toolCallId, parameters, signal, _onUpdate, context) {
|