@pasko70/pibo 3.2.7 → 3.4.0
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/agent-runtime/capabilities.js +5 -0
- package/dist/agent-runtime/contract.js +2 -0
- package/dist/agent-runtime/routed-session.js +68 -11
- package/dist/agent-runtimes/codex-native/adapter.js +4 -1
- package/dist/agent-runtimes/codex-native/process.js +1 -1
- package/dist/agent-runtimes/codex-native/protocol-version.js +6 -6
- package/dist/agent-runtimes/codex-native/thread.js +26 -4
- package/dist/agent-runtimes/omp/adapter.js +1 -0
- package/dist/agent-runtimes/omp/process.js +23 -3
- package/dist/agent-runtimes/omp/protocol-version.js +2 -0
- package/dist/agent-runtimes/pi/adapter.js +5 -1
- package/dist/agent-runtimes/pi/model-catalog.js +2 -2
- package/dist/agent-runtimes/pi/routed-session.js +53 -5
- package/dist/agent-runtimes/pi/runtime.js +6 -3
- package/dist/apps/chat/chat-api-routes.js +12 -38
- package/dist/apps/chat/chat-request-normalizers.js +15 -50
- package/dist/apps/chat/data/legacy-project-migration.js +492 -0
- package/dist/apps/chat/data/room-service.js +2 -2
- package/dist/apps/chat/data/workflow-session-model.js +1 -0
- package/dist/apps/chat/data/workflow-session-service.js +352 -0
- package/dist/apps/chat/rooms.js +1 -1
- package/dist/apps/chat/session-metadata.js +30 -0
- package/dist/apps/chat/trace.js +15 -2
- package/dist/apps/chat/types/rooms.js +30 -0
- package/dist/apps/chat/web-app.js +355 -651
- package/dist/apps/chat/workflow-catalog.js +18 -18
- package/dist/apps/chat/{project-workflow-human-actions.js → workflow-human-actions.js} +14 -14
- package/dist/apps/chat/workflow-manual-trigger-runtime.js +5 -1
- package/dist/apps/chat/workflow-persistence.js +20 -28
- package/dist/apps/chat/{project-workflow-sessions.js → workflow-sessions.js} +18 -17
- package/dist/apps/chat-ui/assets/{dist-ENXYFYda.js → dist-AhtdAETR.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-CGgUuVB6.js → dist-Bk_L1qbJ.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-DG6T1maU.js → dist-Dyp6sLQn.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-CFtZTGHa.js → dist-jVaiGXFD.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-BikaGikn.js → dist-t25moyJS.js} +1 -1
- package/dist/apps/chat-ui/assets/index-CZjNw-aK.js +228 -0
- package/dist/apps/chat-ui/assets/index-CcEjFITM.css +1 -0
- package/dist/apps/chat-ui/index.html +2 -2
- package/dist/apps/chat-vscode-web/assets/index-Spj6M0tn.js +43 -0
- package/dist/apps/chat-vscode-web/index.html +1 -1
- package/dist/compute/pool/cli.js +1 -1
- package/dist/compute/pool/seeds.js +2 -3
- package/dist/config/config.js +1 -1
- package/dist/core/session-router.js +19 -10
- package/dist/debug/agents.js +9 -3
- package/dist/plugins/builtin.js +2 -0
- package/dist/plugins/registry.js +1 -0
- package/dist/previews/cli.js +154 -79
- package/dist/previews/compute-worker.js +37 -0
- package/dist/previews/config.js +2 -1
- package/dist/previews/migrations/session-ownership.js +7 -0
- package/dist/previews/proxy.js +4 -2
- package/dist/previews/public-setup.js +108 -0
- package/dist/previews/store.js +20 -13
- package/dist/previews/web-app.js +12 -2
- package/dist/providers/openai-gpt56.js +41 -3
- package/dist/sessions/workflow-session-kind.js +0 -3
- package/dist/subagents/context.js +2 -2
- package/dist/subagents/observation-query.js +49 -6
- package/dist/subagents/observation-text-regex.js +124 -0
- package/dist/subagents/tool.js +3 -2
- package/dist/tools/hashline.js +64 -0
- package/npm-shrinkwrap.json +786 -284
- package/package.json +11 -6
- package/packages/workflows/README.md +21 -0
- package/packages/workflows/dist/api/index.d.ts +48 -0
- package/packages/workflows/dist/api/index.d.ts.map +1 -0
- package/packages/workflows/dist/api/index.js +96 -0
- package/packages/workflows/dist/api/index.js.map +1 -0
- package/packages/workflows/dist/definition-hash.d.ts +4 -0
- package/packages/workflows/dist/definition-hash.d.ts.map +1 -0
- package/packages/workflows/dist/definition-hash.js +27 -0
- package/packages/workflows/dist/definition-hash.js.map +1 -0
- package/packages/workflows/dist/fixtures/index.d.ts +39 -0
- package/packages/workflows/dist/fixtures/index.d.ts.map +1 -0
- package/packages/workflows/dist/fixtures/index.js +608 -0
- package/packages/workflows/dist/fixtures/index.js.map +1 -0
- package/packages/workflows/dist/index.d.ts +16 -0
- package/packages/workflows/dist/index.d.ts.map +1 -0
- package/packages/workflows/dist/index.js +10 -0
- package/packages/workflows/dist/index.js.map +1 -0
- package/packages/workflows/dist/inspection/index.d.ts +47 -0
- package/packages/workflows/dist/inspection/index.d.ts.map +1 -0
- package/packages/workflows/dist/inspection/index.js +131 -0
- package/packages/workflows/dist/inspection/index.js.map +1 -0
- package/packages/workflows/dist/registry/index.d.ts +30 -0
- package/packages/workflows/dist/registry/index.d.ts.map +1 -0
- package/packages/workflows/dist/registry/index.js +161 -0
- package/packages/workflows/dist/registry/index.js.map +1 -0
- package/packages/workflows/dist/runtime/adapter-node.d.ts +28 -0
- package/packages/workflows/dist/runtime/adapter-node.d.ts.map +1 -0
- package/packages/workflows/dist/runtime/adapter-node.js +172 -0
- package/packages/workflows/dist/runtime/adapter-node.js.map +1 -0
- package/packages/workflows/dist/runtime/agent-node.d.ts +32 -0
- package/packages/workflows/dist/runtime/agent-node.d.ts.map +1 -0
- package/packages/workflows/dist/runtime/agent-node.js +231 -0
- package/packages/workflows/dist/runtime/agent-node.js.map +1 -0
- package/packages/workflows/dist/runtime/agent-runtime.d.ts +25 -0
- package/packages/workflows/dist/runtime/agent-runtime.d.ts.map +1 -0
- package/packages/workflows/dist/runtime/agent-runtime.js +111 -0
- package/packages/workflows/dist/runtime/agent-runtime.js.map +1 -0
- package/packages/workflows/dist/runtime/code-node.d.ts +31 -0
- package/packages/workflows/dist/runtime/code-node.d.ts.map +1 -0
- package/packages/workflows/dist/runtime/code-node.js +223 -0
- package/packages/workflows/dist/runtime/code-node.js.map +1 -0
- package/packages/workflows/dist/runtime/dispatch-failures.d.ts +36 -0
- package/packages/workflows/dist/runtime/dispatch-failures.d.ts.map +1 -0
- package/packages/workflows/dist/runtime/dispatch-failures.js +80 -0
- package/packages/workflows/dist/runtime/dispatch-failures.js.map +1 -0
- package/packages/workflows/dist/runtime/edge-payloads.d.ts +3 -0
- package/packages/workflows/dist/runtime/edge-payloads.d.ts.map +1 -0
- package/packages/workflows/dist/runtime/edge-payloads.js +11 -0
- package/packages/workflows/dist/runtime/edge-payloads.js.map +1 -0
- package/packages/workflows/dist/runtime/edge-transfer.d.ts +39 -0
- package/packages/workflows/dist/runtime/edge-transfer.d.ts.map +1 -0
- package/packages/workflows/dist/runtime/edge-transfer.js +356 -0
- package/packages/workflows/dist/runtime/edge-transfer.js.map +1 -0
- package/packages/workflows/dist/runtime/human-action.d.ts +43 -0
- package/packages/workflows/dist/runtime/human-action.d.ts.map +1 -0
- package/packages/workflows/dist/runtime/human-action.js +231 -0
- package/packages/workflows/dist/runtime/human-action.js.map +1 -0
- package/packages/workflows/dist/runtime/human-node.d.ts +27 -0
- package/packages/workflows/dist/runtime/human-node.d.ts.map +1 -0
- package/packages/workflows/dist/runtime/human-node.js +126 -0
- package/packages/workflows/dist/runtime/human-node.js.map +1 -0
- package/packages/workflows/dist/runtime/ids.d.ts +2 -0
- package/packages/workflows/dist/runtime/ids.d.ts.map +1 -0
- package/packages/workflows/dist/runtime/ids.js +4 -0
- package/packages/workflows/dist/runtime/ids.js.map +1 -0
- package/packages/workflows/dist/runtime/index.d.ts +23 -0
- package/packages/workflows/dist/runtime/index.d.ts.map +1 -0
- package/packages/workflows/dist/runtime/index.js +12 -0
- package/packages/workflows/dist/runtime/index.js.map +1 -0
- package/packages/workflows/dist/runtime/manual-trigger.d.ts +51 -0
- package/packages/workflows/dist/runtime/manual-trigger.d.ts.map +1 -0
- package/packages/workflows/dist/runtime/manual-trigger.js +403 -0
- package/packages/workflows/dist/runtime/manual-trigger.js.map +1 -0
- package/packages/workflows/dist/runtime/nested-workflow-node.d.ts +48 -0
- package/packages/workflows/dist/runtime/nested-workflow-node.d.ts.map +1 -0
- package/packages/workflows/dist/runtime/nested-workflow-node.js +246 -0
- package/packages/workflows/dist/runtime/nested-workflow-node.js.map +1 -0
- package/packages/workflows/dist/runtime/one-node-agent.d.ts +34 -0
- package/packages/workflows/dist/runtime/one-node-agent.d.ts.map +1 -0
- package/packages/workflows/dist/runtime/one-node-agent.js +334 -0
- package/packages/workflows/dist/runtime/one-node-agent.js.map +1 -0
- package/packages/workflows/dist/runtime/persistence.d.ts +9 -0
- package/packages/workflows/dist/runtime/persistence.d.ts.map +1 -0
- package/packages/workflows/dist/runtime/persistence.js +67 -0
- package/packages/workflows/dist/runtime/persistence.js.map +1 -0
- package/packages/workflows/dist/runtime/pibo-routing.d.ts +126 -0
- package/packages/workflows/dist/runtime/pibo-routing.d.ts.map +1 -0
- package/packages/workflows/dist/runtime/pibo-routing.js +96 -0
- package/packages/workflows/dist/runtime/pibo-routing.js.map +1 -0
- package/packages/workflows/dist/runtime/prompts.d.ts +20 -0
- package/packages/workflows/dist/runtime/prompts.d.ts.map +1 -0
- package/packages/workflows/dist/runtime/prompts.js +235 -0
- package/packages/workflows/dist/runtime/prompts.js.map +1 -0
- package/packages/workflows/dist/runtime/retry.d.ts +35 -0
- package/packages/workflows/dist/runtime/retry.d.ts.map +1 -0
- package/packages/workflows/dist/runtime/retry.js +80 -0
- package/packages/workflows/dist/runtime/retry.js.map +1 -0
- package/packages/workflows/dist/runtime/state.d.ts +14 -0
- package/packages/workflows/dist/runtime/state.d.ts.map +1 -0
- package/packages/workflows/dist/runtime/state.js +139 -0
- package/packages/workflows/dist/runtime/state.js.map +1 -0
- package/packages/workflows/dist/runtime/time.d.ts +6 -0
- package/packages/workflows/dist/runtime/time.d.ts.map +1 -0
- package/packages/workflows/dist/runtime/time.js +42 -0
- package/packages/workflows/dist/runtime/time.js.map +1 -0
- package/packages/workflows/dist/store/catalog-records.d.ts +18 -0
- package/packages/workflows/dist/store/catalog-records.d.ts.map +1 -0
- package/packages/workflows/dist/store/catalog-records.js +59 -0
- package/packages/workflows/dist/store/catalog-records.js.map +1 -0
- package/packages/workflows/dist/store/contracts.d.ts +149 -0
- package/packages/workflows/dist/store/contracts.d.ts.map +1 -0
- package/packages/workflows/dist/store/contracts.js +2 -0
- package/packages/workflows/dist/store/contracts.js.map +1 -0
- package/packages/workflows/dist/store/draft-writes.d.ts +7 -0
- package/packages/workflows/dist/store/draft-writes.d.ts.map +1 -0
- package/packages/workflows/dist/store/draft-writes.js +18 -0
- package/packages/workflows/dist/store/draft-writes.js.map +1 -0
- package/packages/workflows/dist/store/index.d.ts +55 -0
- package/packages/workflows/dist/store/index.d.ts.map +1 -0
- package/packages/workflows/dist/store/index.js +650 -0
- package/packages/workflows/dist/store/index.js.map +1 -0
- package/packages/workflows/dist/store/list-query.d.ts +13 -0
- package/packages/workflows/dist/store/list-query.d.ts.map +1 -0
- package/packages/workflows/dist/store/list-query.js +20 -0
- package/packages/workflows/dist/store/list-query.js.map +1 -0
- package/packages/workflows/dist/store/row-mappers.d.ts +206 -0
- package/packages/workflows/dist/store/row-mappers.d.ts.map +1 -0
- package/packages/workflows/dist/store/row-mappers.js +262 -0
- package/packages/workflows/dist/store/row-mappers.js.map +1 -0
- package/packages/workflows/dist/store/schema.d.ts +13 -0
- package/packages/workflows/dist/store/schema.d.ts.map +1 -0
- package/packages/workflows/dist/store/schema.js +458 -0
- package/packages/workflows/dist/store/schema.js.map +1 -0
- package/packages/workflows/dist/store/write-values.d.ts +18 -0
- package/packages/workflows/dist/store/write-values.d.ts.map +1 -0
- package/packages/workflows/dist/store/write-values.js +227 -0
- package/packages/workflows/dist/store/write-values.js.map +1 -0
- package/packages/workflows/dist/types/index.d.ts +1202 -0
- package/packages/workflows/dist/types/index.d.ts.map +1 -0
- package/packages/workflows/dist/types/index.js +8 -0
- package/packages/workflows/dist/types/index.js.map +1 -0
- package/packages/workflows/dist/validation/diagnostics.d.ts +27 -0
- package/packages/workflows/dist/validation/diagnostics.d.ts.map +1 -0
- package/packages/workflows/dist/validation/diagnostics.js +104 -0
- package/packages/workflows/dist/validation/diagnostics.js.map +1 -0
- package/packages/workflows/dist/validation/graph-cycles.d.ts +4 -0
- package/packages/workflows/dist/validation/graph-cycles.d.ts.map +1 -0
- package/packages/workflows/dist/validation/graph-cycles.js +130 -0
- package/packages/workflows/dist/validation/graph-cycles.js.map +1 -0
- package/packages/workflows/dist/validation/graph-edges.d.ts +5 -0
- package/packages/workflows/dist/validation/graph-edges.d.ts.map +1 -0
- package/packages/workflows/dist/validation/graph-edges.js +48 -0
- package/packages/workflows/dist/validation/graph-edges.js.map +1 -0
- package/packages/workflows/dist/validation/graph-ports.d.ts +5 -0
- package/packages/workflows/dist/validation/graph-ports.d.ts.map +1 -0
- package/packages/workflows/dist/validation/graph-ports.js +55 -0
- package/packages/workflows/dist/validation/graph-ports.js.map +1 -0
- package/packages/workflows/dist/validation/index.d.ts +18 -0
- package/packages/workflows/dist/validation/index.d.ts.map +1 -0
- package/packages/workflows/dist/validation/index.js +175 -0
- package/packages/workflows/dist/validation/index.js.map +1 -0
- package/packages/workflows/dist/validation/json-schema.d.ts +12 -0
- package/packages/workflows/dist/validation/json-schema.d.ts.map +1 -0
- package/packages/workflows/dist/validation/json-schema.js +556 -0
- package/packages/workflows/dist/validation/json-schema.js.map +1 -0
- package/packages/workflows/dist/validation/registry-refs.d.ts +21 -0
- package/packages/workflows/dist/validation/registry-refs.d.ts.map +1 -0
- package/packages/workflows/dist/validation/registry-refs.js +283 -0
- package/packages/workflows/dist/validation/registry-refs.js.map +1 -0
- package/packages/workflows/dist/validation/retry-policy.d.ts +3 -0
- package/packages/workflows/dist/validation/retry-policy.d.ts.map +1 -0
- package/packages/workflows/dist/validation/retry-policy.js +114 -0
- package/packages/workflows/dist/validation/retry-policy.js.map +1 -0
- package/packages/workflows/dist/validation/schema-declarations.d.ts +5 -0
- package/packages/workflows/dist/validation/schema-declarations.d.ts.map +1 -0
- package/packages/workflows/dist/validation/schema-declarations.js +36 -0
- package/packages/workflows/dist/validation/schema-declarations.js.map +1 -0
- package/packages/workflows/dist/validation/state-access.d.ts +4 -0
- package/packages/workflows/dist/validation/state-access.d.ts.map +1 -0
- package/packages/workflows/dist/validation/state-access.js +121 -0
- package/packages/workflows/dist/validation/state-access.js.map +1 -0
- package/packages/workflows/dist/xstate/index.d.ts +73 -0
- package/packages/workflows/dist/xstate/index.d.ts.map +1 -0
- package/packages/workflows/dist/xstate/index.js +728 -0
- package/packages/workflows/dist/xstate/index.js.map +1 -0
- package/packages/workflows/package.json +23 -0
- package/dist/apps/chat/data/project-service.js +0 -1029
- package/dist/apps/chat-ui/assets/index-BwT5grLv.css +0 -1
- package/dist/apps/chat-ui/assets/index-PTJanD3E.js +0 -228
- package/dist/apps/chat-vscode-web/assets/index-D1bpAUkR.js +0 -43
|
@@ -2,22 +2,22 @@ import { PiboWebHttpError } from "../../web/http.js";
|
|
|
2
2
|
import { compareWorkflowSemver, hashWorkflowDefinitionJson, parseWorkflowSemver, sanitizeWorkflowDiagnostics, } from "./workflow-persistence.js";
|
|
3
3
|
export const STATIC_WORKFLOW_VERSION_CATALOG = [
|
|
4
4
|
{
|
|
5
|
-
id: "standard-
|
|
5
|
+
id: "standard-workflow",
|
|
6
6
|
version: "1.0.0",
|
|
7
|
-
title: "Standard
|
|
8
|
-
description: "Configured workflow-backed
|
|
7
|
+
title: "Standard Workflow",
|
|
8
|
+
description: "Configured workflow-backed Workflow Session for feature, bugfix, and review work. Creation saves the configuration without starting a run.",
|
|
9
9
|
source: "code",
|
|
10
10
|
status: "published",
|
|
11
|
-
tags: ["
|
|
11
|
+
tags: ["session", "workflow"],
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
id: "simple-chat",
|
|
15
15
|
version: "1.0.0",
|
|
16
16
|
title: "Simple Chat",
|
|
17
|
-
description: "Baseline
|
|
17
|
+
description: "Baseline normal Session chat workflow that preserves the existing one-session chat behavior.",
|
|
18
18
|
source: "code",
|
|
19
19
|
status: "published",
|
|
20
|
-
tags: ["
|
|
20
|
+
tags: ["session", "chat"],
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
id: "ui-review-workflow",
|
|
@@ -32,7 +32,7 @@ export const STATIC_WORKFLOW_VERSION_CATALOG = [
|
|
|
32
32
|
id: "ui-draft-workflow",
|
|
33
33
|
version: "0.1.0-draft",
|
|
34
34
|
title: "UI Draft Workflow",
|
|
35
|
-
description: "Unpublished fixture used to enforce
|
|
35
|
+
description: "Unpublished fixture used to enforce Workflow Session creation boundaries.",
|
|
36
36
|
source: "ui",
|
|
37
37
|
status: "draft",
|
|
38
38
|
tags: ["workflow-ui", "draft"],
|
|
@@ -41,14 +41,14 @@ export const STATIC_WORKFLOW_VERSION_CATALOG = [
|
|
|
41
41
|
id: "archived-review-workflow",
|
|
42
42
|
version: "1.0.0",
|
|
43
43
|
title: "Archived Review Workflow",
|
|
44
|
-
description: "Archived fixture omitted from default
|
|
44
|
+
description: "Archived fixture omitted from default Workflow Session creation choices.",
|
|
45
45
|
source: "ui",
|
|
46
46
|
status: "archived",
|
|
47
47
|
tags: ["workflow-ui", "archived"],
|
|
48
48
|
},
|
|
49
49
|
];
|
|
50
50
|
export function buildWorkflowVersionPicker(state, selectedWorkflowId, selectedWorkflowVersion) {
|
|
51
|
-
const options =
|
|
51
|
+
const options = buildWorkflowVersionOptions(state);
|
|
52
52
|
const normalizedWorkflowId = selectedWorkflowId?.trim() || undefined;
|
|
53
53
|
const normalizedWorkflowVersion = selectedWorkflowVersion?.trim() || undefined;
|
|
54
54
|
const selected = normalizedWorkflowId
|
|
@@ -58,7 +58,7 @@ export function buildWorkflowVersionPicker(state, selectedWorkflowId, selectedWo
|
|
|
58
58
|
if (normalizedWorkflowId && !selected) {
|
|
59
59
|
diagnostics.push({
|
|
60
60
|
code: "WorkflowCatalogError.unknownWorkflowVersion",
|
|
61
|
-
message: `Workflow version '${normalizedWorkflowId}${normalizedWorkflowVersion ? `@${normalizedWorkflowVersion}` : ""}' is not available for
|
|
61
|
+
message: `Workflow version '${normalizedWorkflowId}${normalizedWorkflowVersion ? `@${normalizedWorkflowVersion}` : ""}' is not available for Workflow Session creation.`,
|
|
62
62
|
severity: "error",
|
|
63
63
|
path: "$.workflow",
|
|
64
64
|
registryRef: normalizedWorkflowVersion ? `${normalizedWorkflowId}@${normalizedWorkflowVersion}` : normalizedWorkflowId,
|
|
@@ -73,7 +73,7 @@ export function buildWorkflowVersionPicker(state, selectedWorkflowId, selectedWo
|
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
75
|
export function buildWorkflowVersionHistory(state, selectedWorkflowId, selectedWorkflowVersion) {
|
|
76
|
-
const options = [...
|
|
76
|
+
const options = [...buildWorkflowVersionCatalog(state)]
|
|
77
77
|
.filter((option) => option.status !== "deleted")
|
|
78
78
|
.sort(compareWorkflowCatalogVersionRecords)
|
|
79
79
|
.map(workflowVersionHistoryOptionFromCatalogRecord);
|
|
@@ -100,8 +100,8 @@ export function buildWorkflowVersionHistory(state, selectedWorkflowId, selectedW
|
|
|
100
100
|
diagnostics,
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
export function
|
|
104
|
-
return
|
|
103
|
+
export function buildWorkflowVersionOptions(state) {
|
|
104
|
+
return buildWorkflowVersionCatalog(state)
|
|
105
105
|
.filter((option) => option.status === "published")
|
|
106
106
|
.map(workflowVersionPickerOptionFromCatalogRecord);
|
|
107
107
|
}
|
|
@@ -120,7 +120,7 @@ function workflowVersionHistoryOptionFromCatalogRecord(record) {
|
|
|
120
120
|
editability: workflowCatalogEditability(actions),
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
-
export function
|
|
123
|
+
export function buildWorkflowVersionCatalog(state) {
|
|
124
124
|
const recordsByKey = new Map();
|
|
125
125
|
for (const record of STATIC_WORKFLOW_VERSION_CATALOG) {
|
|
126
126
|
const projected = workflowCatalogRecordWithArchiveState(record, state);
|
|
@@ -346,7 +346,7 @@ export function workflowCatalogActionsFor(record) {
|
|
|
346
346
|
return ["view", "version_history"];
|
|
347
347
|
if (record.status === "deleted")
|
|
348
348
|
return ["view"];
|
|
349
|
-
const actions = ["view", "duplicate", "
|
|
349
|
+
const actions = ["view", "duplicate", "create_workflow_session", "version_history"];
|
|
350
350
|
if (record.source === "ui")
|
|
351
351
|
actions.push("create_next_draft", "archive", "delete");
|
|
352
352
|
return actions;
|
|
@@ -361,7 +361,7 @@ export function workflowCatalogEditability(actions) {
|
|
|
361
361
|
canPublish: actions.includes("publish"),
|
|
362
362
|
canArchive: actions.includes("archive"),
|
|
363
363
|
canDelete: actions.includes("delete"),
|
|
364
|
-
|
|
364
|
+
canCreateWorkflowSession: actions.includes("create_workflow_session"),
|
|
365
365
|
};
|
|
366
366
|
}
|
|
367
367
|
function workflowCatalogValidationStateFromDiagnostics(diagnostics, fallback = "unknown") {
|
|
@@ -537,11 +537,11 @@ function createRunnableWorkflowDefinition(input) {
|
|
|
537
537
|
description: input.description,
|
|
538
538
|
input: {
|
|
539
539
|
kind: "text",
|
|
540
|
-
description: "Workflow input provided when a
|
|
540
|
+
description: "Workflow input provided when a Workflow Session starts.",
|
|
541
541
|
},
|
|
542
542
|
output: {
|
|
543
543
|
kind: "text",
|
|
544
|
-
description: "Workflow output returned to the
|
|
544
|
+
description: "Workflow output returned to the Workflow Session.",
|
|
545
545
|
},
|
|
546
546
|
initial: "agent",
|
|
547
547
|
nodes: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { responseJson } from "../../web/http.js";
|
|
2
2
|
import { sanitizeWorkflowDiagnostics } from "./workflow-persistence.js";
|
|
3
|
-
export function
|
|
3
|
+
export function workflowPendingHumanActionFromToken(token, humanActionOptions) {
|
|
4
4
|
const diagnostics = [];
|
|
5
5
|
const availableActions = token.actions.map((action, index) => {
|
|
6
6
|
const registered = humanActionOptions.find((option) => option.id === action.id);
|
|
@@ -54,7 +54,7 @@ export function projectWorkflowPendingHumanActionFromToken(token, humanActionOpt
|
|
|
54
54
|
...(token.expiresAt ? { expiresAt: token.expiresAt } : {}),
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
export function
|
|
57
|
+
export function workflowHumanActionLifecyclePayload(request) {
|
|
58
58
|
const payload = { waitTokenId: request.waitTokenId };
|
|
59
59
|
if (request.actionId)
|
|
60
60
|
payload.actionId = request.actionId;
|
|
@@ -62,7 +62,7 @@ export function projectWorkflowHumanActionLifecyclePayload(request) {
|
|
|
62
62
|
payload.kind = request.kind;
|
|
63
63
|
return payload;
|
|
64
64
|
}
|
|
65
|
-
export function
|
|
65
|
+
export function workflowHumanActionSubmittedLifecyclePayload(waitTokenId, action) {
|
|
66
66
|
const payload = {
|
|
67
67
|
waitTokenId,
|
|
68
68
|
kind: action.kind,
|
|
@@ -72,7 +72,7 @@ export function projectWorkflowHumanActionSubmittedLifecyclePayload(waitTokenId,
|
|
|
72
72
|
payload.actionId = action.actionId;
|
|
73
73
|
return payload;
|
|
74
74
|
}
|
|
75
|
-
export function
|
|
75
|
+
export function normalizeWorkflowHumanActionBody(body) {
|
|
76
76
|
const diagnostics = [];
|
|
77
77
|
const waitTokenId = typeof body.waitTokenId === "string" && body.waitTokenId.trim() ? body.waitTokenId.trim() : undefined;
|
|
78
78
|
const actionId = typeof body.actionId === "string" && body.actionId.trim() ? body.actionId.trim() : undefined;
|
|
@@ -83,7 +83,7 @@ export function normalizeProjectWorkflowHumanActionBody(body) {
|
|
|
83
83
|
message: "Human action requests must include a waitTokenId.",
|
|
84
84
|
severity: "error",
|
|
85
85
|
path: "$.waitTokenId",
|
|
86
|
-
hint: "Submit a pending wait token returned by
|
|
86
|
+
hint: "Submit a pending wait token returned by Workflow session inspection.",
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
if (!actionId && !kind) {
|
|
@@ -116,7 +116,7 @@ export function normalizeProjectWorkflowHumanActionBody(body) {
|
|
|
116
116
|
diagnostics,
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
|
-
export function
|
|
119
|
+
export function validateWorkflowHumanActionRequest(input) {
|
|
120
120
|
const checkedAt = new Date().toISOString();
|
|
121
121
|
const diagnostics = [];
|
|
122
122
|
if (!input.waitToken) {
|
|
@@ -125,18 +125,18 @@ export function validateProjectWorkflowHumanActionRequest(input) {
|
|
|
125
125
|
message: `Workflow wait token '${input.request.waitTokenId}' does not exist.`,
|
|
126
126
|
severity: "error",
|
|
127
127
|
path: "$.waitTokenId",
|
|
128
|
-
hint: "Refresh the
|
|
128
|
+
hint: "Refresh the Workflow run view and submit one of its pending wait tokens.",
|
|
129
129
|
});
|
|
130
130
|
return { diagnostics, httpStatus: 404, checkedAt };
|
|
131
131
|
}
|
|
132
|
-
if (input.waitToken.
|
|
132
|
+
if (input.waitToken.piboSessionId !== input.workflowSession.piboSessionId || input.waitToken.workflowRunId !== input.workflowSession.workflowRunId) {
|
|
133
133
|
diagnostics.push({
|
|
134
134
|
code: "WorkflowRuntimeError.waitTokenSessionMismatch",
|
|
135
|
-
message: `Workflow wait token '${input.waitToken.id}' does not belong to this
|
|
135
|
+
message: `Workflow wait token '${input.waitToken.id}' does not belong to this Workflow session.`,
|
|
136
136
|
severity: "error",
|
|
137
137
|
path: "$.waitTokenId",
|
|
138
138
|
registryRef: input.waitToken.id,
|
|
139
|
-
hint: "Use only wait tokens shown in the selected
|
|
139
|
+
hint: "Use only wait tokens shown in the selected Workflow run view.",
|
|
140
140
|
});
|
|
141
141
|
return { diagnostics, httpStatus: 403, checkedAt };
|
|
142
142
|
}
|
|
@@ -224,7 +224,7 @@ export function validateProjectWorkflowHumanActionRequest(input) {
|
|
|
224
224
|
actionKind: registered.kind,
|
|
225
225
|
};
|
|
226
226
|
}
|
|
227
|
-
export function
|
|
227
|
+
export function workflowHumanActionRuntimeDiagnostic(error, waitTokenId) {
|
|
228
228
|
const message = error instanceof Error ? error.message : String(error);
|
|
229
229
|
let code = "WorkflowRuntimeError.humanActionRejected";
|
|
230
230
|
if (/not found/i.test(message))
|
|
@@ -243,14 +243,14 @@ export function projectWorkflowHumanActionRuntimeDiagnostic(error, waitTokenId)
|
|
|
243
243
|
severity: "error",
|
|
244
244
|
path: "$.waitTokenId",
|
|
245
245
|
registryRef: waitTokenId,
|
|
246
|
-
hint: "Refresh the
|
|
246
|
+
hint: "Refresh the Workflow run view and retry with a currently pending wait token/action ref.",
|
|
247
247
|
};
|
|
248
248
|
}
|
|
249
|
-
export function
|
|
249
|
+
export function workflowHumanActionDiagnosticResponse(message, diagnostics, status, waitToken, humanActionOptions) {
|
|
250
250
|
return responseJson({
|
|
251
251
|
error: message,
|
|
252
252
|
diagnostics: sanitizeWorkflowDiagnostics(diagnostics),
|
|
253
|
-
...(waitToken?.status === "pending" ? { waitToken:
|
|
253
|
+
...(waitToken?.status === "pending" ? { waitToken: workflowPendingHumanActionFromToken(waitToken, humanActionOptions) } : {}),
|
|
254
254
|
}, { status });
|
|
255
255
|
}
|
|
256
256
|
function validateWorkflowHumanActionPayloadAgainstSchema(value, schema, path, diagnostics, context) {
|
|
@@ -150,11 +150,15 @@ async function runAgentNode(options) {
|
|
|
150
150
|
try {
|
|
151
151
|
const session = options.channelContext.createSession({
|
|
152
152
|
channel: options.channel,
|
|
153
|
-
kind: "
|
|
153
|
+
kind: "chat",
|
|
154
154
|
profile: resolvedProfile,
|
|
155
155
|
workspace: options.defaultWorkspace,
|
|
156
156
|
title: `${stringValue(options.definition.id) || "Workflow"} · ${stringValue(node.label) || options.nodeId}`,
|
|
157
157
|
metadata: {
|
|
158
|
+
...(options.roomId ? { chatRoomId: options.roomId } : {}),
|
|
159
|
+
workflowId: stringValue(options.definition.id) || "workflow",
|
|
160
|
+
workflowVersion: stringValue(options.definition.version) || "draft",
|
|
161
|
+
workflowSessionKind: "agent_node",
|
|
158
162
|
workflowRunId: options.runId,
|
|
159
163
|
workflowRunSource: "manual.editor",
|
|
160
164
|
...(options.draftId ? { workflowDraftId: options.draftId } : {}),
|
|
@@ -7,7 +7,7 @@ export class ChatWorkflowDraftStore {
|
|
|
7
7
|
constructor(dataStore) {
|
|
8
8
|
this.dataStore = dataStore;
|
|
9
9
|
this.dataStore.db.exec(`
|
|
10
|
-
CREATE TABLE IF NOT EXISTS
|
|
10
|
+
CREATE TABLE IF NOT EXISTS workflow_drafts (
|
|
11
11
|
draft_id TEXT PRIMARY KEY,
|
|
12
12
|
workflow_id TEXT NOT NULL,
|
|
13
13
|
source TEXT NOT NULL,
|
|
@@ -26,43 +26,43 @@ export class ChatWorkflowDraftStore {
|
|
|
26
26
|
updated_at TEXT NOT NULL
|
|
27
27
|
);
|
|
28
28
|
|
|
29
|
-
CREATE UNIQUE INDEX IF NOT EXISTS
|
|
30
|
-
ON
|
|
29
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_workflow_drafts_one_active
|
|
30
|
+
ON workflow_drafts(workflow_id)
|
|
31
31
|
WHERE status = 'draft';
|
|
32
|
-
CREATE INDEX IF NOT EXISTS
|
|
33
|
-
ON
|
|
32
|
+
CREATE INDEX IF NOT EXISTS idx_workflow_drafts_updated
|
|
33
|
+
ON workflow_drafts(updated_at, draft_id);
|
|
34
34
|
`);
|
|
35
35
|
}
|
|
36
36
|
getDraft(draftId) {
|
|
37
|
-
const row = this.dataStore.db.prepare("SELECT * FROM
|
|
37
|
+
const row = this.dataStore.db.prepare("SELECT * FROM workflow_drafts WHERE draft_id = ?").get(draftId);
|
|
38
38
|
return row ? workflowDraftFromStoreRow(row) : undefined;
|
|
39
39
|
}
|
|
40
40
|
findActiveDraftByWorkflowId(workflowId) {
|
|
41
41
|
const row = this.dataStore.db
|
|
42
|
-
.prepare("SELECT * FROM
|
|
42
|
+
.prepare("SELECT * FROM workflow_drafts WHERE workflow_id = ? AND status = 'draft' ORDER BY updated_at DESC, draft_id ASC LIMIT 1")
|
|
43
43
|
.get(workflowId);
|
|
44
44
|
return row ? workflowDraftFromStoreRow(row) : undefined;
|
|
45
45
|
}
|
|
46
46
|
listDrafts(filter = {}) {
|
|
47
47
|
const rows = filter.workflowId
|
|
48
48
|
? this.dataStore.db
|
|
49
|
-
.prepare("SELECT * FROM
|
|
49
|
+
.prepare("SELECT * FROM workflow_drafts WHERE workflow_id = ? ORDER BY updated_at DESC, draft_id ASC")
|
|
50
50
|
.all(filter.workflowId)
|
|
51
51
|
: this.dataStore.db
|
|
52
|
-
.prepare("SELECT * FROM
|
|
52
|
+
.prepare("SELECT * FROM workflow_drafts ORDER BY workflow_id ASC, updated_at DESC, draft_id ASC")
|
|
53
53
|
.all();
|
|
54
54
|
return rows.map(workflowDraftFromStoreRow);
|
|
55
55
|
}
|
|
56
56
|
saveDraft(record) {
|
|
57
57
|
this.dataStore.transaction(() => {
|
|
58
58
|
const conflict = this.dataStore.db
|
|
59
|
-
.prepare("SELECT draft_id FROM
|
|
59
|
+
.prepare("SELECT draft_id FROM workflow_drafts WHERE workflow_id = ? AND status = 'draft' AND draft_id <> ? LIMIT 1")
|
|
60
60
|
.get(record.workflowId, record.draftId);
|
|
61
61
|
if (conflict) {
|
|
62
62
|
throw new PiboWebHttpError(`Workflow '${record.workflowId}' already has an active draft '${conflict.draft_id}'`, 409);
|
|
63
63
|
}
|
|
64
64
|
this.dataStore.db.prepare(`
|
|
65
|
-
INSERT INTO
|
|
65
|
+
INSERT INTO workflow_drafts (
|
|
66
66
|
draft_id,
|
|
67
67
|
workflow_id,
|
|
68
68
|
source,
|
|
@@ -440,11 +440,11 @@ export class ChatWorkflowTombstoneStore {
|
|
|
440
440
|
last_known_title TEXT NOT NULL,
|
|
441
441
|
last_known_version TEXT,
|
|
442
442
|
last_definition_hash TEXT,
|
|
443
|
-
|
|
443
|
+
created_at TEXT NOT NULL
|
|
444
444
|
);
|
|
445
445
|
|
|
446
446
|
CREATE INDEX IF NOT EXISTS idx_workflow_delete_tombstones_deleted
|
|
447
|
-
ON workflow_delete_tombstones(deleted,
|
|
447
|
+
ON workflow_delete_tombstones(deleted, created_at);
|
|
448
448
|
`);
|
|
449
449
|
}
|
|
450
450
|
setWorkflowDeleted(input) {
|
|
@@ -479,7 +479,7 @@ export class ChatWorkflowTombstoneStore {
|
|
|
479
479
|
last_known_title,
|
|
480
480
|
last_known_version,
|
|
481
481
|
last_definition_hash,
|
|
482
|
-
|
|
482
|
+
created_at
|
|
483
483
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
484
484
|
ON CONFLICT(workflow_id) DO UPDATE SET
|
|
485
485
|
source = excluded.source,
|
|
@@ -489,7 +489,7 @@ export class ChatWorkflowTombstoneStore {
|
|
|
489
489
|
last_known_title = excluded.last_known_title,
|
|
490
490
|
last_known_version = excluded.last_known_version,
|
|
491
491
|
last_definition_hash = excluded.last_definition_hash,
|
|
492
|
-
|
|
492
|
+
created_at = excluded.created_at
|
|
493
493
|
`).run(record.workflowId, record.source, record.deleted ? 1 : 0, record.deletedAt, record.deletedBy, record.lastKnownTitle, record.lastKnownVersion ?? null, record.lastDefinitionHash ?? null, record.updatedAt);
|
|
494
494
|
}
|
|
495
495
|
}
|
|
@@ -503,7 +503,7 @@ function workflowTombstoneFromStoreRow(row) {
|
|
|
503
503
|
lastKnownTitle: row.last_known_title,
|
|
504
504
|
...(row.last_known_version ? { lastKnownVersion: row.last_known_version } : {}),
|
|
505
505
|
...(row.last_definition_hash ? { lastDefinitionHash: row.last_definition_hash } : {}),
|
|
506
|
-
updatedAt: row.
|
|
506
|
+
updatedAt: row.created_at,
|
|
507
507
|
};
|
|
508
508
|
}
|
|
509
509
|
export class ChatWorkflowLifecycleEventStore {
|
|
@@ -518,7 +518,6 @@ export class ChatWorkflowLifecycleEventStore {
|
|
|
518
518
|
workflow_id TEXT,
|
|
519
519
|
workflow_version TEXT,
|
|
520
520
|
draft_id TEXT,
|
|
521
|
-
project_id TEXT,
|
|
522
521
|
pibo_session_id TEXT,
|
|
523
522
|
workflow_run_id TEXT,
|
|
524
523
|
status TEXT,
|
|
@@ -532,8 +531,8 @@ export class ChatWorkflowLifecycleEventStore {
|
|
|
532
531
|
ON workflow_lifecycle_events(type, created_at);
|
|
533
532
|
CREATE INDEX IF NOT EXISTS idx_workflow_lifecycle_events_workflow
|
|
534
533
|
ON workflow_lifecycle_events(workflow_id, workflow_version, created_at);
|
|
535
|
-
CREATE INDEX IF NOT EXISTS
|
|
536
|
-
ON workflow_lifecycle_events(
|
|
534
|
+
CREATE INDEX IF NOT EXISTS idx_workflow_lifecycle_events_session
|
|
535
|
+
ON workflow_lifecycle_events(pibo_session_id, created_at);
|
|
537
536
|
`);
|
|
538
537
|
}
|
|
539
538
|
record(input) {
|
|
@@ -544,7 +543,6 @@ export class ChatWorkflowLifecycleEventStore {
|
|
|
544
543
|
...(input.workflowId ? { workflowId: input.workflowId } : {}),
|
|
545
544
|
...(input.workflowVersion ? { workflowVersion: input.workflowVersion } : {}),
|
|
546
545
|
...(input.draftId ? { draftId: input.draftId } : {}),
|
|
547
|
-
...(input.projectId ? { projectId: input.projectId } : {}),
|
|
548
546
|
...(input.piboSessionId ? { piboSessionId: input.piboSessionId } : {}),
|
|
549
547
|
...(input.workflowRunId ? { workflowRunId: input.workflowRunId } : {}),
|
|
550
548
|
...(input.status ? { status: input.status } : {}),
|
|
@@ -561,7 +559,6 @@ export class ChatWorkflowLifecycleEventStore {
|
|
|
561
559
|
workflow_id,
|
|
562
560
|
workflow_version,
|
|
563
561
|
draft_id,
|
|
564
|
-
project_id,
|
|
565
562
|
pibo_session_id,
|
|
566
563
|
workflow_run_id,
|
|
567
564
|
status,
|
|
@@ -569,8 +566,8 @@ export class ChatWorkflowLifecycleEventStore {
|
|
|
569
566
|
diagnostics_json,
|
|
570
567
|
payload_json,
|
|
571
568
|
created_at
|
|
572
|
-
) VALUES (${Array.from({ length:
|
|
573
|
-
`).run(event.id, event.type, event.actorId ?? null, event.workflowId ?? null, event.workflowVersion ?? null, event.draftId ?? null, event.
|
|
569
|
+
) VALUES (${Array.from({ length: 13 }, () => "?").join(", ")})
|
|
570
|
+
`).run(event.id, event.type, event.actorId ?? null, event.workflowId ?? null, event.workflowVersion ?? null, event.draftId ?? null, event.piboSessionId ?? null, event.workflowRunId ?? null, event.status ?? null, event.validation ? JSON.stringify(event.validation) : null, JSON.stringify(event.diagnostics), event.payload ? JSON.stringify(event.payload) : null, event.createdAt);
|
|
574
571
|
return event;
|
|
575
572
|
}
|
|
576
573
|
listEvents(filter) {
|
|
@@ -588,10 +585,6 @@ export class ChatWorkflowLifecycleEventStore {
|
|
|
588
585
|
clauses.push("draft_id = ?");
|
|
589
586
|
values.push(filter.draftId);
|
|
590
587
|
}
|
|
591
|
-
if (filter.projectId) {
|
|
592
|
-
clauses.push("project_id = ?");
|
|
593
|
-
values.push(filter.projectId);
|
|
594
|
-
}
|
|
595
588
|
if (filter.piboSessionId) {
|
|
596
589
|
clauses.push("pibo_session_id = ?");
|
|
597
590
|
values.push(filter.piboSessionId);
|
|
@@ -618,7 +611,6 @@ function workflowLifecycleEventFromStoreRow(row) {
|
|
|
618
611
|
...(row.workflow_id ? { workflowId: row.workflow_id } : {}),
|
|
619
612
|
...(row.workflow_version ? { workflowVersion: row.workflow_version } : {}),
|
|
620
613
|
...(row.draft_id ? { draftId: row.draft_id } : {}),
|
|
621
|
-
...(row.project_id ? { projectId: row.project_id } : {}),
|
|
622
614
|
...(row.pibo_session_id ? { piboSessionId: row.pibo_session_id } : {}),
|
|
623
615
|
...(row.workflow_run_id ? { workflowRunId: row.workflow_run_id } : {}),
|
|
624
616
|
...(row.status ? { status: row.status } : {}),
|
|
@@ -3,7 +3,9 @@ import { isPiboThinkingLevel } from "../../core/thinking.js";
|
|
|
3
3
|
import { PiboWebHttpError } from "../../web/http.js";
|
|
4
4
|
import { hashWorkflowDefinitionJson, sanitizeWorkflowDiagnostics, } from "./workflow-persistence.js";
|
|
5
5
|
import { workflowVersionPickerOptionFromCatalogRecord, } from "./workflow-catalog.js";
|
|
6
|
-
const
|
|
6
|
+
const WORKFLOW_SESSION_CREATE_FIELDS = new Set([
|
|
7
|
+
"roomId",
|
|
8
|
+
"workspace",
|
|
7
9
|
"profile",
|
|
8
10
|
"workflowId",
|
|
9
11
|
"workflowVersion",
|
|
@@ -14,7 +16,7 @@ const PROJECT_WORKFLOW_SESSION_CREATE_FIELDS = new Set([
|
|
|
14
16
|
"thinkingLevel",
|
|
15
17
|
"fastMode",
|
|
16
18
|
]);
|
|
17
|
-
const
|
|
19
|
+
const WORKFLOW_SESSION_DISALLOWED_FIELDS = new Map([
|
|
18
20
|
["agentProfileOverrides", "Agent profile overrides are not supported for V2 workflow sessions"],
|
|
19
21
|
["profileOverrides", "Agent profile overrides are not supported for V2 workflow sessions"],
|
|
20
22
|
["profileOverride", "Agent profile overrides are not supported for V2 workflow sessions"],
|
|
@@ -34,11 +36,11 @@ const PROJECT_WORKFLOW_SESSION_DISALLOWED_FIELDS = new Map([
|
|
|
34
36
|
["options", "Arbitrary options are not supported for V2 workflow sessions"],
|
|
35
37
|
["arbitraryOptions", "Arbitrary options are not supported for V2 workflow sessions"],
|
|
36
38
|
]);
|
|
37
|
-
export function
|
|
38
|
-
|
|
39
|
-
const inputValues =
|
|
39
|
+
export function normalizeWorkflowSessionConfiguration(body, definition) {
|
|
40
|
+
assertWorkflowSessionCreateFields(body);
|
|
41
|
+
const inputValues = normalizeWorkflowInputValues(body.inputValues);
|
|
40
42
|
const promptOverrideEligibleNodeIds = workflowPromptOverrideEligibleNodeIds(definition);
|
|
41
|
-
const promptOverrides =
|
|
43
|
+
const promptOverrides = normalizeWorkflowPromptOverrides(body.promptOverrides, promptOverrideEligibleNodeIds);
|
|
42
44
|
const model = normalizeWorkflowSessionModel(body.model);
|
|
43
45
|
const thinkingLevel = normalizeThinkingLevel(body.thinkingLevel, "thinkingLevel");
|
|
44
46
|
const fastMode = normalizeOptionalBoolean(body.fastMode, "fastMode");
|
|
@@ -57,9 +59,9 @@ export function normalizeProjectWorkflowSessionConfiguration(body, definition) {
|
|
|
57
59
|
...(fastMode !== undefined ? { fastMode } : {}),
|
|
58
60
|
};
|
|
59
61
|
}
|
|
60
|
-
export function
|
|
62
|
+
export function createWorkflowSessionSnapshot(input) {
|
|
61
63
|
const baseDefinition = cloneJsonObject(input.baseDefinition);
|
|
62
|
-
const effectiveDefinition =
|
|
64
|
+
const effectiveDefinition = applyWorkflowPromptOverrides(baseDefinition, input.configuration.promptOverrides);
|
|
63
65
|
const baseDefinitionHash = hashWorkflowDefinitionJson(baseDefinition);
|
|
64
66
|
const effectiveDefinitionHash = hashWorkflowDefinitionJson(effectiveDefinition);
|
|
65
67
|
const now = new Date().toISOString();
|
|
@@ -68,7 +70,6 @@ export function createProjectWorkflowSessionSnapshot(input) {
|
|
|
68
70
|
schemaVersion: 1,
|
|
69
71
|
createdAt: now,
|
|
70
72
|
createdBy: input.webSession.authSession.identity.userId,
|
|
71
|
-
projectId: input.project.id,
|
|
72
73
|
piboSessionId: input.session.id,
|
|
73
74
|
workflow: {
|
|
74
75
|
id: input.workflow.id,
|
|
@@ -115,34 +116,34 @@ export function workflowVersionFromSnapshot(snapshot) {
|
|
|
115
116
|
tags: [...snapshot.workflow.tags],
|
|
116
117
|
});
|
|
117
118
|
}
|
|
118
|
-
export function
|
|
119
|
+
export function createWorkflowRunCurrent(definition) {
|
|
119
120
|
const initialNodeIds = workflowInitialNodeIds(definition);
|
|
120
121
|
return {
|
|
121
|
-
status: "
|
|
122
|
+
status: "pending",
|
|
122
123
|
initialNodeIds,
|
|
123
124
|
...(initialNodeIds.length === 1 ? { nodeId: initialNodeIds[0] } : {}),
|
|
124
125
|
};
|
|
125
126
|
}
|
|
126
|
-
function
|
|
127
|
+
function assertWorkflowSessionCreateFields(body) {
|
|
127
128
|
if (!body || typeof body !== "object" || Array.isArray(body))
|
|
128
129
|
throw new PiboWebHttpError("Invalid JSON body", 400);
|
|
129
130
|
for (const key of Object.keys(body)) {
|
|
130
|
-
const disallowedMessage =
|
|
131
|
+
const disallowedMessage = WORKFLOW_SESSION_DISALLOWED_FIELDS.get(key);
|
|
131
132
|
if (disallowedMessage)
|
|
132
133
|
throw new PiboWebHttpError(disallowedMessage, 400);
|
|
133
|
-
if (!
|
|
134
|
+
if (!WORKFLOW_SESSION_CREATE_FIELDS.has(key)) {
|
|
134
135
|
throw new PiboWebHttpError(`Unsupported workflow session creation field: ${key}`, 400);
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
|
-
function
|
|
139
|
+
function normalizeWorkflowInputValues(value) {
|
|
139
140
|
if (value === undefined || value === null)
|
|
140
141
|
return {};
|
|
141
142
|
if (!isJsonObject(value))
|
|
142
143
|
throw new PiboWebHttpError("inputValues must be a JSON object", 400);
|
|
143
144
|
return value;
|
|
144
145
|
}
|
|
145
|
-
function
|
|
146
|
+
function normalizeWorkflowPromptOverrides(value, eligibleNodeIds) {
|
|
146
147
|
if (value === undefined || value === null)
|
|
147
148
|
return {};
|
|
148
149
|
if (!isJsonObject(value))
|
|
@@ -224,7 +225,7 @@ function isWorkflowPromptOverrideEligibleNode(value) {
|
|
|
224
225
|
&& typeof value.promptTemplate === "string"
|
|
225
226
|
&& sessionOverrides?.prompt === true;
|
|
226
227
|
}
|
|
227
|
-
function
|
|
228
|
+
function applyWorkflowPromptOverrides(definition, promptOverrides) {
|
|
228
229
|
const effectiveDefinition = cloneJsonObject(definition);
|
|
229
230
|
const nodes = isJsonObject(effectiveDefinition.nodes) ? effectiveDefinition.nodes : undefined;
|
|
230
231
|
if (!nodes)
|