@agimon-ai/po-workflow 0.0.0-alpha.2 → 0.0.0-alpha.200
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/LICENSE +95 -14
- package/README.md +134 -47
- package/dist/apiContracts.cjs +209 -36
- package/dist/apiContracts.cjs.map +1 -1
- package/dist/apiContracts.d.mts +2 -2
- package/dist/apiContracts.d.mts.map +1 -1
- package/dist/apiContracts.mjs +209 -36
- package/dist/apiContracts.mjs.map +1 -1
- package/dist/contract-BpzJeyjh.mjs +33 -0
- package/dist/contract-BpzJeyjh.mjs.map +1 -0
- package/dist/contract-D80yV2d-.cjs +68 -0
- package/dist/contract-D80yV2d-.cjs.map +1 -0
- package/dist/extensions/native.mjs +4580 -997
- package/dist/extensions/native.mjs.map +1 -1
- package/dist/extensions/server.cjs +20921 -3342
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts +2 -2
- package/dist/extensions/server.d.mts.map +1 -1
- package/dist/extensions/server.mjs +20934 -3331
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +5694 -3127
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/index--C-zOl9A.d.mts +5107 -0
- package/dist/index--C-zOl9A.d.mts.map +1 -0
- package/dist/index.cjs +41 -3
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +104 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +38 -2
- package/dist/index.mjs.map +1 -0
- package/dist/po-runtime-identity.json +1 -0
- package/dist/workflowHost-B-B6BIeD.mjs +3969 -0
- package/dist/workflowHost-B-B6BIeD.mjs.map +1 -0
- package/dist/workflowHost-d3yIgFif.cjs +4185 -0
- package/dist/workflowHost-d3yIgFif.cjs.map +1 -0
- package/dist/workflowHost.cjs +7 -0
- package/dist/workflowHost.d.mts +29 -0
- package/dist/workflowHost.d.mts.map +1 -0
- package/dist/workflowHost.mjs +3 -0
- package/dist/workflowServices-CSHleLJo.mjs +273 -0
- package/dist/workflowServices-CSHleLJo.mjs.map +1 -0
- package/dist/workflowServices-DYXhIDVE.cjs +350 -0
- package/dist/workflowServices-DYXhIDVE.cjs.map +1 -0
- package/llms.txt +11 -10
- package/package.json +140 -31
- package/src/prompts/codemode-how-to-workflow/SKILL.md +226 -0
- package/src/prompts/help-how-to-workflow/SKILL.md +191 -0
- package/src/types/webWorkflowTerminal.ts +21 -0
- package/src/types/webWorkflows.ts +54 -2
- package/LICENSE.web +0 -29
- package/dist/workflowLaunchCommand-C69Nn3k5.cjs +0 -139
- package/dist/workflowLaunchCommand-C69Nn3k5.cjs.map +0 -1
- package/dist/workflowLaunchCommand-GGqimmTC.mjs +0 -122
- package/dist/workflowLaunchCommand-GGqimmTC.mjs.map +0 -1
- package/skills/workflow-recovery/SKILL.md +0 -85
- package/src/prompts/po-author-workflow/SKILL.md +0 -64
- package/src/prompts/po-use-workflow/SKILL.md +0 -21
package/dist/apiContracts.mjs
CHANGED
|
@@ -1,6 +1,87 @@
|
|
|
1
1
|
import { defineApiContract, jsonApiResponses } from "@agimon-ai/po-core/apiContracts";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
|
+
//#region src/schemas/dynamicWorkflowSnapshot.ts
|
|
4
|
+
const state = Type.Union([
|
|
5
|
+
"pending",
|
|
6
|
+
"running",
|
|
7
|
+
"completed",
|
|
8
|
+
"failed",
|
|
9
|
+
"stopped",
|
|
10
|
+
"skipped"
|
|
11
|
+
].map((value) => Type.Literal(value)));
|
|
12
|
+
const time = Type.Optional(Type.Number());
|
|
13
|
+
const phase = Type.Object({
|
|
14
|
+
key: Type.String(),
|
|
15
|
+
label: Type.String(),
|
|
16
|
+
status: state,
|
|
17
|
+
executionStatus: state,
|
|
18
|
+
startedAt: time,
|
|
19
|
+
finishedAt: time,
|
|
20
|
+
error: Type.Optional(Type.String()),
|
|
21
|
+
agents: Type.Array(Type.Object({
|
|
22
|
+
runId: Type.String(),
|
|
23
|
+
status: Type.Union([
|
|
24
|
+
"running",
|
|
25
|
+
"completed",
|
|
26
|
+
"failed",
|
|
27
|
+
"stopped"
|
|
28
|
+
].map((value) => Type.Literal(value)))
|
|
29
|
+
}))
|
|
30
|
+
});
|
|
31
|
+
const shape = Type.Object({
|
|
32
|
+
key: Type.String(),
|
|
33
|
+
label: Type.String(),
|
|
34
|
+
kind: Type.Union([
|
|
35
|
+
"step",
|
|
36
|
+
"sequence",
|
|
37
|
+
"parallel",
|
|
38
|
+
"branch",
|
|
39
|
+
"foreach"
|
|
40
|
+
].map((value) => Type.Literal(value))),
|
|
41
|
+
children: Type.Array(Type.Ref("#/$defs/Shape"))
|
|
42
|
+
});
|
|
43
|
+
const DynamicWorkflowSnapshotSchema = Type.Object({
|
|
44
|
+
version: Type.Literal(1),
|
|
45
|
+
revision: Type.Number(),
|
|
46
|
+
sessionId: Type.String(),
|
|
47
|
+
runs: Type.Array(Type.Object({
|
|
48
|
+
key: Type.String(),
|
|
49
|
+
workflowId: Type.String(),
|
|
50
|
+
label: Type.String(),
|
|
51
|
+
status: state,
|
|
52
|
+
executionStatus: state,
|
|
53
|
+
startedAt: Type.Number(),
|
|
54
|
+
finishedAt: time,
|
|
55
|
+
error: Type.Optional(Type.String()),
|
|
56
|
+
shape: Type.Ref("#/$defs/Shape"),
|
|
57
|
+
groups: Type.Array(Type.Object({
|
|
58
|
+
key: Type.String(),
|
|
59
|
+
label: Type.String(),
|
|
60
|
+
concurrency: Type.Optional(Type.Number()),
|
|
61
|
+
total: Type.Number(),
|
|
62
|
+
truncated: Type.Boolean(),
|
|
63
|
+
counts: Type.Object({
|
|
64
|
+
pending: Type.Number(),
|
|
65
|
+
running: Type.Number(),
|
|
66
|
+
completed: Type.Number(),
|
|
67
|
+
failed: Type.Number(),
|
|
68
|
+
stopped: Type.Number(),
|
|
69
|
+
skipped: Type.Number()
|
|
70
|
+
}),
|
|
71
|
+
items: Type.Array(Type.Object({
|
|
72
|
+
key: Type.String(),
|
|
73
|
+
label: Type.String(),
|
|
74
|
+
index: Type.Number(),
|
|
75
|
+
status: state,
|
|
76
|
+
phases: Type.Array(phase)
|
|
77
|
+
}))
|
|
78
|
+
}))
|
|
79
|
+
}))
|
|
80
|
+
}, { $defs: { Shape: shape } });
|
|
81
|
+
//#endregion
|
|
3
82
|
//#region src/schemas/apiContracts.ts
|
|
83
|
+
const API_BASE_PATH = "workflow";
|
|
84
|
+
const OWNER_AUTHENTICATION = "owner";
|
|
4
85
|
const S = Type.String();
|
|
5
86
|
const N = Type.Number();
|
|
6
87
|
const B = Type.Boolean();
|
|
@@ -22,8 +103,55 @@ const Step = {
|
|
|
22
103
|
startedAt: O(S),
|
|
23
104
|
endedAt: O(S)
|
|
24
105
|
};
|
|
106
|
+
const Usage = Type.Object({
|
|
107
|
+
tokens: O(Type.Object({
|
|
108
|
+
input: N,
|
|
109
|
+
output: N,
|
|
110
|
+
cacheRead: N,
|
|
111
|
+
cacheWrite: N,
|
|
112
|
+
total: N
|
|
113
|
+
})),
|
|
114
|
+
costUsd: O(N),
|
|
115
|
+
toolCount: O(N)
|
|
116
|
+
});
|
|
117
|
+
const Children = Type.Array(Type.Object({
|
|
118
|
+
lead: S,
|
|
119
|
+
continuations: N,
|
|
120
|
+
maxContinuations: N,
|
|
121
|
+
criteria: Type.Array(Type.Object({
|
|
122
|
+
key: S,
|
|
123
|
+
description: S,
|
|
124
|
+
verifiedBy: S,
|
|
125
|
+
status: values([
|
|
126
|
+
"unchecked",
|
|
127
|
+
"checked",
|
|
128
|
+
"not-met"
|
|
129
|
+
]),
|
|
130
|
+
feedback: O(S),
|
|
131
|
+
invocationId: O(S)
|
|
132
|
+
})),
|
|
133
|
+
invocations: Type.Array(Type.Object({
|
|
134
|
+
invocationId: S,
|
|
135
|
+
job: S,
|
|
136
|
+
state: values([
|
|
137
|
+
"running",
|
|
138
|
+
"completed",
|
|
139
|
+
"failed",
|
|
140
|
+
"interrupted"
|
|
141
|
+
]),
|
|
142
|
+
sessionIds: Type.Array(S),
|
|
143
|
+
startedAt: S,
|
|
144
|
+
endedAt: O(S),
|
|
145
|
+
error: O(S),
|
|
146
|
+
usage: O(Usage)
|
|
147
|
+
}))
|
|
148
|
+
}));
|
|
25
149
|
const Run = Type.Object({
|
|
26
150
|
runKey: S,
|
|
151
|
+
routeKey: O(S),
|
|
152
|
+
runId: O(S),
|
|
153
|
+
ownerSessionId: O(S),
|
|
154
|
+
launcherSessionId: O(S),
|
|
27
155
|
workspace: S,
|
|
28
156
|
displayName: S,
|
|
29
157
|
workflowName: O(S),
|
|
@@ -50,6 +178,7 @@ const Run = Type.Object({
|
|
|
50
178
|
finishedAt: O(S),
|
|
51
179
|
errorMessage: O(S),
|
|
52
180
|
failedJob: O(S),
|
|
181
|
+
waiting: O(Type.Literal(true)),
|
|
53
182
|
stale: O(B),
|
|
54
183
|
staleReason: O(S),
|
|
55
184
|
worktreeBranch: O(S),
|
|
@@ -59,6 +188,27 @@ const Run = Type.Object({
|
|
|
59
188
|
index: O(N),
|
|
60
189
|
total: O(N)
|
|
61
190
|
})),
|
|
191
|
+
children: O(Children),
|
|
192
|
+
childUsage: O(Type.Object({
|
|
193
|
+
complete: B,
|
|
194
|
+
invocationCount: N,
|
|
195
|
+
tokensKnown: N,
|
|
196
|
+
costKnown: N,
|
|
197
|
+
toolCountKnown: N,
|
|
198
|
+
tokens: O(Type.Object({
|
|
199
|
+
input: N,
|
|
200
|
+
output: N,
|
|
201
|
+
cacheRead: N,
|
|
202
|
+
cacheWrite: N,
|
|
203
|
+
total: N
|
|
204
|
+
})),
|
|
205
|
+
costUsd: O(N),
|
|
206
|
+
toolCount: O(N)
|
|
207
|
+
})),
|
|
208
|
+
childStatusErrors: O(Type.Array(Type.Object({
|
|
209
|
+
lead: O(S),
|
|
210
|
+
message: S
|
|
211
|
+
}))),
|
|
62
212
|
jobs: Type.Array(Type.Object({
|
|
63
213
|
...Step,
|
|
64
214
|
phase: values([
|
|
@@ -127,17 +277,27 @@ const apiContracts = defineApiContract({
|
|
|
127
277
|
version: 1,
|
|
128
278
|
dynamic: [],
|
|
129
279
|
http: [
|
|
130
|
-
"
|
|
280
|
+
"host",
|
|
131
281
|
"workspace",
|
|
132
282
|
"session"
|
|
133
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
|
+
},
|
|
134
294
|
{
|
|
135
295
|
id: "workflow.screen",
|
|
136
296
|
scope,
|
|
137
|
-
basePath:
|
|
297
|
+
basePath: API_BASE_PATH,
|
|
138
298
|
path: `${root}/screen/stream`,
|
|
139
299
|
method: "GET",
|
|
140
|
-
authentication:
|
|
300
|
+
authentication: OWNER_AUTHENTICATION,
|
|
141
301
|
description: "Follow the workflow terminal.",
|
|
142
302
|
responses: {
|
|
143
303
|
"200": {
|
|
@@ -155,10 +315,10 @@ const apiContracts = defineApiContract({
|
|
|
155
315
|
{
|
|
156
316
|
id: "workflow.control",
|
|
157
317
|
scope,
|
|
158
|
-
basePath:
|
|
318
|
+
basePath: API_BASE_PATH,
|
|
159
319
|
path: `${root}/control`,
|
|
160
320
|
method: "POST",
|
|
161
|
-
authentication:
|
|
321
|
+
authentication: OWNER_AUTHENTICATION,
|
|
162
322
|
description: "Take or release the keyboard.",
|
|
163
323
|
body: {
|
|
164
324
|
required: true,
|
|
@@ -179,10 +339,10 @@ const apiContracts = defineApiContract({
|
|
|
179
339
|
{
|
|
180
340
|
id: "workflow.keys",
|
|
181
341
|
scope,
|
|
182
|
-
basePath:
|
|
342
|
+
basePath: API_BASE_PATH,
|
|
183
343
|
path: `${root}/keys`,
|
|
184
344
|
method: "POST",
|
|
185
|
-
authentication:
|
|
345
|
+
authentication: OWNER_AUTHENTICATION,
|
|
186
346
|
description: "Write terminal data with the control token.",
|
|
187
347
|
body: {
|
|
188
348
|
required: true,
|
|
@@ -207,10 +367,10 @@ const apiContracts = defineApiContract({
|
|
|
207
367
|
{
|
|
208
368
|
id: "workflow.resize",
|
|
209
369
|
scope,
|
|
210
|
-
basePath:
|
|
370
|
+
basePath: API_BASE_PATH,
|
|
211
371
|
path: `${root}/resize`,
|
|
212
372
|
method: "POST",
|
|
213
|
-
authentication:
|
|
373
|
+
authentication: OWNER_AUTHENTICATION,
|
|
214
374
|
description: "Resize the terminal.",
|
|
215
375
|
body: {
|
|
216
376
|
required: true,
|
|
@@ -226,20 +386,20 @@ const apiContracts = defineApiContract({
|
|
|
226
386
|
{
|
|
227
387
|
id: "workflow.delete",
|
|
228
388
|
scope,
|
|
229
|
-
basePath:
|
|
389
|
+
basePath: API_BASE_PATH,
|
|
230
390
|
path: root,
|
|
231
391
|
method: "DELETE",
|
|
232
|
-
authentication:
|
|
392
|
+
authentication: OWNER_AUTHENTICATION,
|
|
233
393
|
description: "Delete a settled run and its directory.",
|
|
234
394
|
responses: jsonApiResponses(Type.Object({ deleted: Type.Literal(true) }))
|
|
235
395
|
},
|
|
236
396
|
{
|
|
237
397
|
id: "workflow.openRunDirectory",
|
|
238
398
|
scope,
|
|
239
|
-
basePath:
|
|
399
|
+
basePath: API_BASE_PATH,
|
|
240
400
|
path: `${root}/open-directory`,
|
|
241
401
|
method: "POST",
|
|
242
|
-
authentication:
|
|
402
|
+
authentication: OWNER_AUTHENTICATION,
|
|
243
403
|
description: "Open the registered run folder in Finder. Local callers only.",
|
|
244
404
|
responses: {
|
|
245
405
|
...jsonApiResponses(Type.Object({ opened: Type.Literal(true) })),
|
|
@@ -256,10 +416,10 @@ const apiContracts = defineApiContract({
|
|
|
256
416
|
{
|
|
257
417
|
id: "workflow.artifacts",
|
|
258
418
|
scope,
|
|
259
|
-
basePath:
|
|
419
|
+
basePath: API_BASE_PATH,
|
|
260
420
|
path: `${root}/artifacts`,
|
|
261
421
|
method: "GET",
|
|
262
|
-
authentication:
|
|
422
|
+
authentication: OWNER_AUTHENTICATION,
|
|
263
423
|
description: "List declared and discovered artifacts, or immediate children of a directory.",
|
|
264
424
|
parameters: [{
|
|
265
425
|
name: "directory",
|
|
@@ -287,10 +447,10 @@ const apiContracts = defineApiContract({
|
|
|
287
447
|
{
|
|
288
448
|
id: "workflow.artifact",
|
|
289
449
|
scope,
|
|
290
|
-
basePath:
|
|
450
|
+
basePath: API_BASE_PATH,
|
|
291
451
|
path: `${root}/artifacts/{name}`,
|
|
292
452
|
method: "GET",
|
|
293
|
-
authentication:
|
|
453
|
+
authentication: OWNER_AUTHENTICATION,
|
|
294
454
|
description: "Read artifact metadata and text. name may contain nested path segments. raw=1 streams binary with its media type and supports byte ranges.",
|
|
295
455
|
parameters: [
|
|
296
456
|
{
|
|
@@ -330,25 +490,38 @@ const apiContracts = defineApiContract({
|
|
|
330
490
|
}
|
|
331
491
|
}
|
|
332
492
|
]),
|
|
333
|
-
sockets: ["
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
493
|
+
sockets: ["host", "workspace"].flatMap((scope) => [
|
|
494
|
+
{
|
|
495
|
+
id: "workflow.runs",
|
|
496
|
+
scope,
|
|
497
|
+
service: "po.hub",
|
|
498
|
+
member: "workflow_runs",
|
|
499
|
+
kind: "channel",
|
|
500
|
+
direction: "server-to-client",
|
|
501
|
+
description: "Workflow runs channel payload.",
|
|
502
|
+
input: WorkflowRunsSchema
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
id: "workflow.catalog",
|
|
506
|
+
scope,
|
|
507
|
+
service: "po.hub",
|
|
508
|
+
member: "workflow_catalog",
|
|
509
|
+
kind: "channel",
|
|
510
|
+
direction: "server-to-client",
|
|
511
|
+
description: "Workflow catalog channel payload.",
|
|
512
|
+
input: WorkflowCatalogSchema
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
id: "dynamic-workflow.runs",
|
|
516
|
+
scope,
|
|
517
|
+
service: "po.hub",
|
|
518
|
+
member: "dynamic_workflow_runs",
|
|
519
|
+
kind: "channel",
|
|
520
|
+
direction: "server-to-client",
|
|
521
|
+
description: "Tracked workflow state for one session, without callback source or input/output data.",
|
|
522
|
+
input: DynamicWorkflowSnapshotSchema
|
|
523
|
+
}
|
|
524
|
+
])
|
|
352
525
|
});
|
|
353
526
|
//#endregion
|
|
354
527
|
export { apiContracts, apiContracts as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses, type DoomHttpContract } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst S = Type.String();\nconst N = Type.Number();\nconst B = Type.Boolean();\nconst O = Type.Optional;\nconst values = <T extends string>(items: T[]) => Type.Union(items.map((item) => Type.Literal(item)));\nconst Progress = values(['running', 'completed', 'skipped', 'failed', 'pause_requested', 'paused', 'resumed']);\nconst Step = { name: S, status: Progress, reason: O(S), group: O(S), startedAt: O(S), endedAt: O(S) };\nconst Run = Type.Object({\n runKey: S,\n 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: 'po.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: 'po.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,QAA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AAsB,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/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;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ACE;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,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"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { relative } from "node:path";
|
|
2
|
+
//#region src/services/workflowLibrary/index.ts
|
|
3
|
+
/** Bound at host scope by a host that keeps workflows outside the session's repository; a computer binds nothing. */
|
|
4
|
+
const PO_WORKFLOW_LIBRARY_SERVICE = "po/workflow-library";
|
|
5
|
+
const REPO_SOURCE = "repo";
|
|
6
|
+
function readWorkflowLibrary(context) {
|
|
7
|
+
return (context.get("po/workflow-library")?.sources ?? []).filter((entry) => entry.source !== REPO_SOURCE);
|
|
8
|
+
}
|
|
9
|
+
/** The library source a workflow file lives in, if any. */
|
|
10
|
+
function librarySourceOf(workflowPath, library) {
|
|
11
|
+
return library?.find((entry) => workflowPath.startsWith(`${entry.directory}/`));
|
|
12
|
+
}
|
|
13
|
+
/** The definition a workflow file names: its library source's when it lives in one, else the repository's. */
|
|
14
|
+
function workflowDefinitionRef(workflowPath, repoRoot, library) {
|
|
15
|
+
const owner = librarySourceOf(workflowPath, library) ?? {
|
|
16
|
+
source: REPO_SOURCE,
|
|
17
|
+
directory: repoRoot
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
source: owner.source,
|
|
21
|
+
key: relative(owner.directory, workflowPath).split("\\").join("/")
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/services/workflowHost/contract.ts
|
|
26
|
+
const PO_WORKFLOW_HOST_SERVICE = "po/workflow-host";
|
|
27
|
+
function readPoWorkflowHost(context) {
|
|
28
|
+
return context.get(PO_WORKFLOW_HOST_SERVICE);
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { readWorkflowLibrary as a, librarySourceOf as i, readPoWorkflowHost as n, workflowDefinitionRef as o, PO_WORKFLOW_LIBRARY_SERVICE as r, PO_WORKFLOW_HOST_SERVICE as t };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=contract-BpzJeyjh.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-BpzJeyjh.mjs","names":[],"sources":["../src/services/workflowLibrary/index.ts","../src/services/workflowHost/contract.ts"],"sourcesContent":["import { relative } from 'node:path';\n\nimport type { PoWorkflowDefinitionRef, PoWorkflowDefinitionSource } from '@agimon-ai/po-core/workflow';\nimport type { Context } from '@deepseek-ai/cordis';\n\n/** Bound at host scope by a host that keeps workflows outside the session's repository; a computer binds nothing. */\nexport const PO_WORKFLOW_LIBRARY_SERVICE = 'po/workflow-library';\n\nconst REPO_SOURCE = 'repo';\n\n/**\n * Workflow folders beside the repository, such as Po Cloud's org and personal sets. Each folder is a named source, so a\n * run started from one is recorded and admitted by that source's name rather than as a path outside the repository.\n */\nexport interface WorkflowLibrary {\n readonly sources: readonly PoWorkflowDefinitionSource[];\n}\n\nexport function readWorkflowLibrary(context: Context): readonly PoWorkflowDefinitionSource[] {\n const library = context.get(PO_WORKFLOW_LIBRARY_SERVICE) as WorkflowLibrary | undefined;\n return (library?.sources ?? []).filter((entry) => entry.source !== REPO_SOURCE);\n}\n\n/** The library source a workflow file lives in, if any. */\nexport function librarySourceOf(\n workflowPath: string,\n library: readonly PoWorkflowDefinitionSource[] | undefined,\n): PoWorkflowDefinitionSource | undefined {\n return library?.find((entry) => workflowPath.startsWith(`${entry.directory}/`));\n}\n\n/** The definition a workflow file names: its library source's when it lives in one, else the repository's. */\nexport function workflowDefinitionRef(\n workflowPath: string,\n repoRoot: string,\n library?: readonly PoWorkflowDefinitionSource[],\n): PoWorkflowDefinitionRef {\n const owner = librarySourceOf(workflowPath, library) ?? { source: REPO_SOURCE, directory: repoRoot };\n return { source: owner.source, key: relative(owner.directory, workflowPath).split('\\\\').join('/') };\n}\n","import type { Context } from '@deepseek-ai/cordis';\n\nimport type { WorkflowHost } from './type';\n\nexport const PO_WORKFLOW_HOST_SERVICE = 'po/workflow-host';\n\nexport function readPoWorkflowHost(context: Context): WorkflowHost | undefined {\n return context.get(PO_WORKFLOW_HOST_SERVICE) as WorkflowHost | undefined;\n}\n\nexport function requirePoWorkflowHost(context: Context): WorkflowHost {\n const host = readPoWorkflowHost(context);\n if (host === undefined) throw new Error('The workflow host capability is not bound on this Cordis root.');\n return host;\n}\n"],"mappings":";;;AAMA,MAAa,8BAA8B;AAE3C,MAAM,cAAc;AAUpB,SAAgB,oBAAoB,SAAyD;CAE3F,QADgB,QAAQ,IAAA,qBACV,CAAC,EAAE,WAAW,CAAC,EAAA,CAAG,QAAQ,UAAU,MAAM,WAAW,WAAW;AAChF;;AAGA,SAAgB,gBACd,cACA,SACwC;CACxC,OAAO,SAAS,MAAM,UAAU,aAAa,WAAW,GAAG,MAAM,UAAU,EAAE,CAAC;AAChF;;AAGA,SAAgB,sBACd,cACA,UACA,SACyB;CACzB,MAAM,QAAQ,gBAAgB,cAAc,OAAO,KAAK;EAAE,QAAQ;EAAa,WAAW;CAAS;CACnG,OAAO;EAAE,QAAQ,MAAM;EAAQ,KAAK,SAAS,MAAM,WAAW,YAAY,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,GAAG;CAAE;AACpG;;;ACnCA,MAAa,2BAA2B;AAExC,SAAgB,mBAAmB,SAA4C;CAC7E,OAAO,QAAQ,IAAI,wBAAwB;AAC7C"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
let node_path = require("node:path");
|
|
2
|
+
//#region src/services/workflowLibrary/index.ts
|
|
3
|
+
/** Bound at host scope by a host that keeps workflows outside the session's repository; a computer binds nothing. */
|
|
4
|
+
const PO_WORKFLOW_LIBRARY_SERVICE = "po/workflow-library";
|
|
5
|
+
const REPO_SOURCE = "repo";
|
|
6
|
+
function readWorkflowLibrary(context) {
|
|
7
|
+
return (context.get("po/workflow-library")?.sources ?? []).filter((entry) => entry.source !== REPO_SOURCE);
|
|
8
|
+
}
|
|
9
|
+
/** The library source a workflow file lives in, if any. */
|
|
10
|
+
function librarySourceOf(workflowPath, library) {
|
|
11
|
+
return library?.find((entry) => workflowPath.startsWith(`${entry.directory}/`));
|
|
12
|
+
}
|
|
13
|
+
/** The definition a workflow file names: its library source's when it lives in one, else the repository's. */
|
|
14
|
+
function workflowDefinitionRef(workflowPath, repoRoot, library) {
|
|
15
|
+
const owner = librarySourceOf(workflowPath, library) ?? {
|
|
16
|
+
source: REPO_SOURCE,
|
|
17
|
+
directory: repoRoot
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
source: owner.source,
|
|
21
|
+
key: (0, node_path.relative)(owner.directory, workflowPath).split("\\").join("/")
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/services/workflowHost/contract.ts
|
|
26
|
+
const PO_WORKFLOW_HOST_SERVICE = "po/workflow-host";
|
|
27
|
+
function readPoWorkflowHost(context) {
|
|
28
|
+
return context.get(PO_WORKFLOW_HOST_SERVICE);
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
Object.defineProperty(exports, "PO_WORKFLOW_HOST_SERVICE", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function() {
|
|
34
|
+
return PO_WORKFLOW_HOST_SERVICE;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, "PO_WORKFLOW_LIBRARY_SERVICE", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function() {
|
|
40
|
+
return PO_WORKFLOW_LIBRARY_SERVICE;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "librarySourceOf", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function() {
|
|
46
|
+
return librarySourceOf;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(exports, "readPoWorkflowHost", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function() {
|
|
52
|
+
return readPoWorkflowHost;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(exports, "readWorkflowLibrary", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function() {
|
|
58
|
+
return readWorkflowLibrary;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(exports, "workflowDefinitionRef", {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function() {
|
|
64
|
+
return workflowDefinitionRef;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=contract-D80yV2d-.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-D80yV2d-.cjs","names":["relative"],"sources":["../src/services/workflowLibrary/index.ts","../src/services/workflowHost/contract.ts"],"sourcesContent":["import { relative } from 'node:path';\n\nimport type { PoWorkflowDefinitionRef, PoWorkflowDefinitionSource } from '@agimon-ai/po-core/workflow';\nimport type { Context } from '@deepseek-ai/cordis';\n\n/** Bound at host scope by a host that keeps workflows outside the session's repository; a computer binds nothing. */\nexport const PO_WORKFLOW_LIBRARY_SERVICE = 'po/workflow-library';\n\nconst REPO_SOURCE = 'repo';\n\n/**\n * Workflow folders beside the repository, such as Po Cloud's org and personal sets. Each folder is a named source, so a\n * run started from one is recorded and admitted by that source's name rather than as a path outside the repository.\n */\nexport interface WorkflowLibrary {\n readonly sources: readonly PoWorkflowDefinitionSource[];\n}\n\nexport function readWorkflowLibrary(context: Context): readonly PoWorkflowDefinitionSource[] {\n const library = context.get(PO_WORKFLOW_LIBRARY_SERVICE) as WorkflowLibrary | undefined;\n return (library?.sources ?? []).filter((entry) => entry.source !== REPO_SOURCE);\n}\n\n/** The library source a workflow file lives in, if any. */\nexport function librarySourceOf(\n workflowPath: string,\n library: readonly PoWorkflowDefinitionSource[] | undefined,\n): PoWorkflowDefinitionSource | undefined {\n return library?.find((entry) => workflowPath.startsWith(`${entry.directory}/`));\n}\n\n/** The definition a workflow file names: its library source's when it lives in one, else the repository's. */\nexport function workflowDefinitionRef(\n workflowPath: string,\n repoRoot: string,\n library?: readonly PoWorkflowDefinitionSource[],\n): PoWorkflowDefinitionRef {\n const owner = librarySourceOf(workflowPath, library) ?? { source: REPO_SOURCE, directory: repoRoot };\n return { source: owner.source, key: relative(owner.directory, workflowPath).split('\\\\').join('/') };\n}\n","import type { Context } from '@deepseek-ai/cordis';\n\nimport type { WorkflowHost } from './type';\n\nexport const PO_WORKFLOW_HOST_SERVICE = 'po/workflow-host';\n\nexport function readPoWorkflowHost(context: Context): WorkflowHost | undefined {\n return context.get(PO_WORKFLOW_HOST_SERVICE) as WorkflowHost | undefined;\n}\n\nexport function requirePoWorkflowHost(context: Context): WorkflowHost {\n const host = readPoWorkflowHost(context);\n if (host === undefined) throw new Error('The workflow host capability is not bound on this Cordis root.');\n return host;\n}\n"],"mappings":";;;AAMA,MAAa,8BAA8B;AAE3C,MAAM,cAAc;AAUpB,SAAgB,oBAAoB,SAAyD;CAE3F,QADgB,QAAQ,IAAA,qBACV,CAAC,EAAE,WAAW,CAAC,EAAA,CAAG,QAAQ,UAAU,MAAM,WAAW,WAAW;AAChF;;AAGA,SAAgB,gBACd,cACA,SACwC;CACxC,OAAO,SAAS,MAAM,UAAU,aAAa,WAAW,GAAG,MAAM,UAAU,EAAE,CAAC;AAChF;;AAGA,SAAgB,sBACd,cACA,UACA,SACyB;CACzB,MAAM,QAAQ,gBAAgB,cAAc,OAAO,KAAK;EAAE,QAAQ;EAAa,WAAW;CAAS;CACnG,OAAO;EAAE,QAAQ,MAAM;EAAQ,MAAA,GAAKA,UAAAA,SAAAA,CAAS,MAAM,WAAW,YAAY,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,GAAG;CAAE;AACpG;;;ACnCA,MAAa,2BAA2B;AAExC,SAAgB,mBAAmB,SAA4C;CAC7E,OAAO,QAAQ,IAAI,wBAAwB;AAC7C"}
|