@loopstack/advanced-workflows-examples 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/dist/workflows/agent-error-handling/agent-error-handling-failing-sub.workflow.d.ts +1 -1
- package/dist/workflows/agent-error-handling/agent-error-handling-failing-sub.workflow.d.ts.map +1 -1
- package/dist/workflows/agent-error-handling/agent-error-handling-failing-sub.workflow.js +2 -2
- package/dist/workflows/agent-error-handling/agent-error-handling-failing-sub.workflow.js.map +1 -1
- package/dist/workflows/agent-error-handling/agent-error-handling.workflow.d.ts +4 -4
- package/dist/workflows/agent-error-handling/agent-error-handling.workflow.d.ts.map +1 -1
- package/dist/workflows/agent-error-handling/agent-error-handling.workflow.js +8 -8
- package/dist/workflows/agent-error-handling/agent-error-handling.workflow.js.map +1 -1
- package/dist/workflows/agent-error-handling/tools/failing-sub-workflow.tool.d.ts +4 -0
- package/dist/workflows/agent-error-handling/tools/failing-sub-workflow.tool.d.ts.map +1 -1
- package/dist/workflows/agent-error-handling/tools/failing-sub-workflow.tool.js +4 -1
- package/dist/workflows/agent-error-handling/tools/failing-sub-workflow.tool.js.map +1 -1
- package/dist/workflows/agent-error-handling/tools/runtime-error.tool.d.ts +2 -0
- package/dist/workflows/agent-error-handling/tools/runtime-error.tool.d.ts.map +1 -1
- package/dist/workflows/agent-error-handling/tools/runtime-error.tool.js +4 -1
- package/dist/workflows/agent-error-handling/tools/runtime-error.tool.js.map +1 -1
- package/dist/workflows/agent-error-handling/tools/strict-schema.tool.d.ts +2 -0
- package/dist/workflows/agent-error-handling/tools/strict-schema.tool.d.ts.map +1 -1
- package/dist/workflows/agent-error-handling/tools/strict-schema.tool.js +4 -1
- package/dist/workflows/agent-error-handling/tools/strict-schema.tool.js.map +1 -1
- package/dist/workflows/custom-tool/custom-tool-example.workflow.d.ts +1 -1
- package/dist/workflows/custom-tool/custom-tool-example.workflow.d.ts.map +1 -1
- package/dist/workflows/custom-tool/custom-tool-example.workflow.js +2 -2
- package/dist/workflows/custom-tool/custom-tool-example.workflow.js.map +1 -1
- package/dist/workflows/custom-tool/tools/counter.tool.d.ts +2 -0
- package/dist/workflows/custom-tool/tools/counter.tool.d.ts.map +1 -1
- package/dist/workflows/custom-tool/tools/counter.tool.js +5 -1
- package/dist/workflows/custom-tool/tools/counter.tool.js.map +1 -1
- package/dist/workflows/custom-tool/tools/math-sum.tool.d.ts +1 -0
- package/dist/workflows/custom-tool/tools/math-sum.tool.d.ts.map +1 -1
- package/dist/workflows/custom-tool/tools/math-sum.tool.js +4 -1
- package/dist/workflows/custom-tool/tools/math-sum.tool.js.map +1 -1
- package/dist/workflows/dynamic-routing/dynamic-routing-example.workflow.d.ts +7 -7
- package/dist/workflows/dynamic-routing/dynamic-routing-example.workflow.d.ts.map +1 -1
- package/dist/workflows/dynamic-routing/dynamic-routing-example.workflow.js +15 -15
- package/dist/workflows/dynamic-routing/dynamic-routing-example.workflow.js.map +1 -1
- package/dist/workflows/error-retry/error-retry-example.workflow.d.ts +15 -15
- package/dist/workflows/error-retry/error-retry-example.workflow.d.ts.map +1 -1
- package/dist/workflows/error-retry/error-retry-example.workflow.js +30 -30
- package/dist/workflows/error-retry/error-retry-example.workflow.js.map +1 -1
- package/dist/workflows/error-retry/failing-child.workflow.d.ts +1 -1
- package/dist/workflows/error-retry/failing-child.workflow.d.ts.map +1 -1
- package/dist/workflows/error-retry/failing-child.workflow.js +2 -2
- package/dist/workflows/error-retry/failing-child.workflow.js.map +1 -1
- package/dist/workflows/error-retry/tools/slow.tool.d.ts +2 -0
- package/dist/workflows/error-retry/tools/slow.tool.d.ts.map +1 -1
- package/dist/workflows/error-retry/tools/slow.tool.js +5 -1
- package/dist/workflows/error-retry/tools/slow.tool.js.map +1 -1
- package/dist/workflows/error-retry/tools/step1.tool.d.ts +2 -0
- package/dist/workflows/error-retry/tools/step1.tool.d.ts.map +1 -1
- package/dist/workflows/error-retry/tools/step1.tool.js +5 -1
- package/dist/workflows/error-retry/tools/step1.tool.js.map +1 -1
- package/dist/workflows/error-retry/tools/step2.tool.d.ts +2 -0
- package/dist/workflows/error-retry/tools/step2.tool.d.ts.map +1 -1
- package/dist/workflows/error-retry/tools/step2.tool.js +5 -1
- package/dist/workflows/error-retry/tools/step2.tool.js.map +1 -1
- package/dist/workflows/fan-out/fan-out-example.workflow.d.ts +1 -1
- package/dist/workflows/fan-out/fan-out-example.workflow.d.ts.map +1 -1
- package/dist/workflows/fan-out/fan-out-example.workflow.js +2 -2
- package/dist/workflows/fan-out/fan-out-example.workflow.js.map +1 -1
- package/dist/workflows/module-config/consumers/default-greeting.workflow.d.ts +2 -2
- package/dist/workflows/module-config/consumers/default-greeting.workflow.d.ts.map +1 -1
- package/dist/workflows/module-config/consumers/default-greeting.workflow.js +4 -4
- package/dist/workflows/module-config/consumers/default-greeting.workflow.js.map +1 -1
- package/dist/workflows/module-config/consumers/french-greeting.workflow.d.ts +2 -2
- package/dist/workflows/module-config/consumers/french-greeting.workflow.d.ts.map +1 -1
- package/dist/workflows/module-config/consumers/french-greeting.workflow.js +4 -4
- package/dist/workflows/module-config/consumers/french-greeting.workflow.js.map +1 -1
- package/dist/workflows/module-config/consumers/german-greeting.workflow.d.ts +2 -2
- package/dist/workflows/module-config/consumers/german-greeting.workflow.d.ts.map +1 -1
- package/dist/workflows/module-config/consumers/german-greeting.workflow.js +4 -4
- package/dist/workflows/module-config/consumers/german-greeting.workflow.js.map +1 -1
- package/dist/workflows/module-config/consumers/nested-greeting.workflow.d.ts +2 -2
- package/dist/workflows/module-config/consumers/nested-greeting.workflow.d.ts.map +1 -1
- package/dist/workflows/module-config/consumers/nested-greeting.workflow.js +4 -4
- package/dist/workflows/module-config/consumers/nested-greeting.workflow.js.map +1 -1
- package/dist/workflows/module-config/greeter/greeter.tool.d.ts +5 -0
- package/dist/workflows/module-config/greeter/greeter.tool.d.ts.map +1 -1
- package/dist/workflows/module-config/greeter/greeter.tool.js +8 -1
- package/dist/workflows/module-config/greeter/greeter.tool.js.map +1 -1
- package/dist/workflows/sequence/sequence-example.workflow.d.ts +1 -1
- package/dist/workflows/sequence/sequence-example.workflow.d.ts.map +1 -1
- package/dist/workflows/sequence/sequence-example.workflow.js +2 -2
- package/dist/workflows/sequence/sequence-example.workflow.js.map +1 -1
- package/dist/workflows/sub-workflow/sub-workflow-error-handling.workflow.d.ts +1 -1
- package/dist/workflows/sub-workflow/sub-workflow-error-handling.workflow.d.ts.map +1 -1
- package/dist/workflows/sub-workflow/sub-workflow-error-handling.workflow.js +2 -2
- package/dist/workflows/sub-workflow/sub-workflow-error-handling.workflow.js.map +1 -1
- package/dist/workflows/sub-workflow/sub-workflow-failing-sub.workflow.d.ts +1 -1
- package/dist/workflows/sub-workflow/sub-workflow-failing-sub.workflow.d.ts.map +1 -1
- package/dist/workflows/sub-workflow/sub-workflow-failing-sub.workflow.js +2 -2
- package/dist/workflows/sub-workflow/sub-workflow-failing-sub.workflow.js.map +1 -1
- package/dist/workflows/sub-workflow/sub-workflow-parent.workflow.d.ts +2 -2
- package/dist/workflows/sub-workflow/sub-workflow-parent.workflow.d.ts.map +1 -1
- package/dist/workflows/sub-workflow/sub-workflow-parent.workflow.js +4 -4
- package/dist/workflows/sub-workflow/sub-workflow-parent.workflow.js.map +1 -1
- package/dist/workflows/sub-workflow/sub-workflow-show-modes.workflow.d.ts +1 -1
- package/dist/workflows/sub-workflow/sub-workflow-show-modes.workflow.d.ts.map +1 -1
- package/dist/workflows/sub-workflow/sub-workflow-show-modes.workflow.js +2 -2
- package/dist/workflows/sub-workflow/sub-workflow-show-modes.workflow.js.map +1 -1
- package/dist/workflows/sub-workflow/sub-workflow-sub.workflow.d.ts +1 -1
- package/dist/workflows/sub-workflow/sub-workflow-sub.workflow.d.ts.map +1 -1
- package/dist/workflows/sub-workflow/sub-workflow-sub.workflow.js +2 -2
- package/dist/workflows/sub-workflow/sub-workflow-sub.workflow.js.map +1 -1
- package/dist/workflows/ui-documents/ui-documents-example.workflow.d.ts +2 -2
- package/dist/workflows/ui-documents/ui-documents-example.workflow.d.ts.map +1 -1
- package/dist/workflows/ui-documents/ui-documents-example.workflow.js +4 -4
- package/dist/workflows/ui-documents/ui-documents-example.workflow.js.map +1 -1
- package/dist/workflows/workflow-state/tool-results-example.workflow.d.ts +1 -1
- package/dist/workflows/workflow-state/tool-results-example.workflow.d.ts.map +1 -1
- package/dist/workflows/workflow-state/tool-results-example.workflow.js +2 -2
- package/dist/workflows/workflow-state/tool-results-example.workflow.js.map +1 -1
- package/dist/workflows/workflow-state/workflow-state-example.workflow.d.ts +1 -1
- package/dist/workflows/workflow-state/workflow-state-example.workflow.d.ts.map +1 -1
- package/dist/workflows/workflow-state/workflow-state-example.workflow.js +2 -2
- package/dist/workflows/workflow-state/workflow-state-example.workflow.js.map +1 -1
- package/package.json +1 -1
- package/src/workflows/agent-error-handling/agent-error-handling-failing-sub.workflow.ts +1 -1
- package/src/workflows/agent-error-handling/agent-error-handling.workflow.ts +5 -5
- package/src/workflows/agent-error-handling/tools/failing-sub-workflow.tool.ts +4 -0
- package/src/workflows/agent-error-handling/tools/runtime-error.tool.ts +4 -0
- package/src/workflows/agent-error-handling/tools/strict-schema.tool.ts +4 -0
- package/src/workflows/custom-tool/__tests__/custom-tool-facade.spec.ts +142 -0
- package/src/workflows/custom-tool/__tests__/trace-consumers.spec.ts +123 -0
- package/src/workflows/custom-tool/custom-tool-example.workflow.ts +1 -1
- package/src/workflows/custom-tool/tools/counter.tool.ts +5 -0
- package/src/workflows/custom-tool/tools/math-sum.tool.ts +4 -0
- package/src/workflows/dynamic-routing/dynamic-routing-example.workflow.ts +8 -8
- package/src/workflows/error-retry/error-retry-example.workflow.ts +15 -15
- package/src/workflows/error-retry/failing-child.workflow.ts +1 -1
- package/src/workflows/error-retry/tools/slow.tool.ts +5 -0
- package/src/workflows/error-retry/tools/step1.tool.ts +5 -0
- package/src/workflows/error-retry/tools/step2.tool.ts +5 -0
- package/src/workflows/fan-out/fan-out-example.workflow.ts +1 -1
- package/src/workflows/module-config/consumers/default-greeting.workflow.ts +2 -2
- package/src/workflows/module-config/consumers/french-greeting.workflow.ts +2 -2
- package/src/workflows/module-config/consumers/german-greeting.workflow.ts +2 -2
- package/src/workflows/module-config/consumers/nested-greeting.workflow.ts +2 -2
- package/src/workflows/module-config/greeter/greeter.tool.ts +8 -0
- package/src/workflows/sequence/sequence-example.workflow.ts +1 -1
- package/src/workflows/sub-workflow/__tests__/sub-workflow-stateless.spec.ts +80 -0
- package/src/workflows/sub-workflow/sub-workflow-error-handling.workflow.ts +1 -1
- package/src/workflows/sub-workflow/sub-workflow-failing-sub.workflow.ts +1 -1
- package/src/workflows/sub-workflow/sub-workflow-parent.workflow.ts +2 -2
- package/src/workflows/sub-workflow/sub-workflow-show-modes.workflow.ts +1 -1
- package/src/workflows/sub-workflow/sub-workflow-sub.workflow.ts +1 -1
- package/src/workflows/ui-documents/ui-documents-example.workflow.ts +2 -2
- package/src/workflows/workflow-state/tool-results-example.workflow.ts +1 -1
- package/src/workflows/workflow-state/workflow-state-example.workflow.ts +1 -1
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.WorkflowToolResultsWorkflow = void 0;
|
|
13
13
|
const common_1 = require("@loopstack/common");
|
|
14
14
|
let WorkflowToolResultsWorkflow = class WorkflowToolResultsWorkflow extends common_1.BaseWorkflow {
|
|
15
|
-
async createSomeData(
|
|
15
|
+
async createSomeData() {
|
|
16
16
|
await this.documentStore.save(common_1.MessageDocument, {
|
|
17
17
|
role: 'assistant',
|
|
18
18
|
text: `Stored in initial transition: Hello World.`,
|
|
@@ -30,7 +30,7 @@ exports.WorkflowToolResultsWorkflow = WorkflowToolResultsWorkflow;
|
|
|
30
30
|
__decorate([
|
|
31
31
|
(0, common_1.Transition)({ to: 'data_created' }),
|
|
32
32
|
__metadata("design:type", Function),
|
|
33
|
-
__metadata("design:paramtypes", [
|
|
33
|
+
__metadata("design:paramtypes", []),
|
|
34
34
|
__metadata("design:returntype", Promise)
|
|
35
35
|
], WorkflowToolResultsWorkflow.prototype, "createSomeData", null);
|
|
36
36
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-results-example.workflow.js","sourceRoot":"","sources":["../../../src/workflows/workflow-state/tool-results-example.workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAAwF;AAUjF,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,qBAAY;IAErD,AAAN,KAAK,CAAC,cAAc
|
|
1
|
+
{"version":3,"file":"tool-results-example.workflow.js","sourceRoot":"","sources":["../../../src/workflows/workflow-state/tool-results-example.workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAAwF;AAUjF,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,qBAAY;IAErD,AAAN,KAAK,CAAC,cAAc;QAClB,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,wBAAe,EAAE;YAC7C,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,4CAA4C;SACnD,CAAC,CAAC;QACH,IAAI,CAAC,WAAW,CAAC,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC,CAAC;IACtD,CAAC;IAGK,AAAN,KAAK,CAAC,UAAU,CAAC,KAAuB;QACtC,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,wBAAe,EAAE;YAC7C,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,sCAAsC,KAAK,CAAC,aAAa,EAAE;SAClE,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAjBY,kEAA2B;AAEhC;IADL,IAAA,mBAAU,EAAC,EAAE,EAAE,EAAE,cAAc,EAAE,CAAC;;;;iEAOlC;AAGK;IADL,IAAA,mBAAU,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;;;;6DAM/C;sCAhBU,2BAA2B;IAJvC,IAAA,iBAAQ,EAAC;QACR,KAAK,EAAE,yCAAyC;QAChD,WAAW,EAAE,iFAAiF;KAC/F,CAAC;GACW,2BAA2B,CAiBvC"}
|
|
@@ -3,7 +3,7 @@ interface WorkflowStateState {
|
|
|
3
3
|
message?: string;
|
|
4
4
|
}
|
|
5
5
|
export declare class WorkflowStateWorkflow extends BaseWorkflow {
|
|
6
|
-
createSomeData(
|
|
6
|
+
createSomeData(): void;
|
|
7
7
|
showResults(state: WorkflowStateState): Promise<void>;
|
|
8
8
|
private messageInUpperCase;
|
|
9
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-state-example.workflow.d.ts","sourceRoot":"","sources":["../../../src/workflows/workflow-state/workflow-state-example.workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAyC,MAAM,mBAAmB,CAAC;AAExF,UAAU,kBAAkB;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAIa,qBAAsB,SAAQ,YAAY;IAErD,cAAc
|
|
1
|
+
{"version":3,"file":"workflow-state-example.workflow.d.ts","sourceRoot":"","sources":["../../../src/workflows/workflow-state/workflow-state-example.workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAyC,MAAM,mBAAmB,CAAC;AAExF,UAAU,kBAAkB;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAIa,qBAAsB,SAAQ,YAAY;IAErD,cAAc;IAKR,WAAW,CAAC,KAAK,EAAE,kBAAkB;IAY3C,OAAO,CAAC,kBAAkB;CAG3B"}
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.WorkflowStateWorkflow = void 0;
|
|
13
13
|
const common_1 = require("@loopstack/common");
|
|
14
14
|
let WorkflowStateWorkflow = class WorkflowStateWorkflow extends common_1.BaseWorkflow {
|
|
15
|
-
createSomeData(
|
|
15
|
+
createSomeData() {
|
|
16
16
|
this.assignState({ message: 'Hello :)' });
|
|
17
17
|
}
|
|
18
18
|
async showResults(state) {
|
|
@@ -33,7 +33,7 @@ exports.WorkflowStateWorkflow = WorkflowStateWorkflow;
|
|
|
33
33
|
__decorate([
|
|
34
34
|
(0, common_1.Transition)({ to: 'data_created' }),
|
|
35
35
|
__metadata("design:type", Function),
|
|
36
|
-
__metadata("design:paramtypes", [
|
|
36
|
+
__metadata("design:paramtypes", []),
|
|
37
37
|
__metadata("design:returntype", void 0)
|
|
38
38
|
], WorkflowStateWorkflow.prototype, "createSomeData", null);
|
|
39
39
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-state-example.workflow.js","sourceRoot":"","sources":["../../../src/workflows/workflow-state/workflow-state-example.workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAAwF;AAUjF,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,qBAAY;IAErD,cAAc
|
|
1
|
+
{"version":3,"file":"workflow-state-example.workflow.js","sourceRoot":"","sources":["../../../src/workflows/workflow-state/workflow-state-example.workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAAwF;AAUjF,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,qBAAY;IAErD,cAAc;QACZ,IAAI,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;IAC5C,CAAC;IAGK,AAAN,KAAK,CAAC,WAAW,CAAC,KAAyB;QACzC,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,wBAAe,EAAE;YAC7C,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,oBAAoB,KAAK,CAAC,OAAO,EAAE;SAC1C,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,wBAAe,EAAE;YAC7C,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,+BAA+B,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,OAAQ,CAAC,EAAE;SAC/E,CAAC,CAAC;IACL,CAAC;IAEO,kBAAkB,CAAC,OAAe;QACxC,OAAO,OAAO,EAAE,WAAW,EAAE,CAAC;IAChC,CAAC;CACF,CAAA;AAtBY,sDAAqB;AAEhC;IADC,IAAA,mBAAU,EAAC,EAAE,EAAE,EAAE,cAAc,EAAE,CAAC;;;;2DAGlC;AAGK;IADL,IAAA,mBAAU,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;;;;wDAW/C;gCAjBU,qBAAqB;IAJjC,IAAA,iBAAQ,EAAC;QACR,KAAK,EAAE,mCAAmC;QAC1C,WAAW,EAAE,6FAA6F;KAC3G,CAAC;GACW,qBAAqB,CAsBjC"}
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ import { BaseWorkflow, Transition, Workflow } from '@loopstack/common';
|
|
|
7
7
|
@Workflow({ title: 'Agent Error Handling - Failing Sub-Workflow' })
|
|
8
8
|
export class AgentErrorHandlingFailingSubWorkflow extends BaseWorkflow {
|
|
9
9
|
@Transition({ to: 'done' })
|
|
10
|
-
start(
|
|
10
|
+
start() {
|
|
11
11
|
return Promise.reject(new Error('Simulated sub-workflow failure.'));
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -47,7 +47,7 @@ export class AgentErrorHandlingWorkflow extends BaseWorkflow {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
@Transition({ to: 'ready' })
|
|
50
|
-
async setup(
|
|
50
|
+
async setup() {
|
|
51
51
|
await this.documentStore.save(MessageDocument, {
|
|
52
52
|
role: 'assistant',
|
|
53
53
|
text:
|
|
@@ -105,7 +105,7 @@ export class AgentErrorHandlingWorkflow extends BaseWorkflow {
|
|
|
105
105
|
|
|
106
106
|
@Transition({ from: 'awaiting_tools', to: 'ready' })
|
|
107
107
|
@Guard('allToolsComplete')
|
|
108
|
-
toolsComplete(
|
|
108
|
+
toolsComplete() {}
|
|
109
109
|
|
|
110
110
|
@Transition({ from: 'awaiting_tools', to: 'ready', wait: true })
|
|
111
111
|
async cancelPendingTools(state: AgentErrorHandlingState, ctx: RunContext) {
|
|
@@ -113,8 +113,8 @@ export class AgentErrorHandlingWorkflow extends BaseWorkflow {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
@Transition({ from: 'prompt_executed', to: 'end' })
|
|
116
|
-
@Guard('
|
|
117
|
-
respond(
|
|
116
|
+
@Guard('isDone')
|
|
117
|
+
respond() {}
|
|
118
118
|
|
|
119
119
|
private hasToolCalls(state: AgentErrorHandlingState): boolean {
|
|
120
120
|
return state.llmResult?.message.stopReason === 'tool_use';
|
|
@@ -124,7 +124,7 @@ export class AgentErrorHandlingWorkflow extends BaseWorkflow {
|
|
|
124
124
|
return !!state.delegateResult?.allCompleted;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
private
|
|
127
|
+
private isDone(state: AgentErrorHandlingState): boolean {
|
|
128
128
|
return state.llmResult?.message.stopReason === 'end_turn';
|
|
129
129
|
}
|
|
130
130
|
}
|
|
@@ -5,12 +5,16 @@ import { AgentErrorHandlingFailingSubWorkflow } from '../agent-error-handling-fa
|
|
|
5
5
|
|
|
6
6
|
export type FailingSubWorkflowToolResult = { workflowId: string };
|
|
7
7
|
|
|
8
|
+
export const FailingSubWorkflowToolResultSchema = z.strictObject({ workflowId: z.string() });
|
|
9
|
+
|
|
8
10
|
@Tool({
|
|
9
11
|
name: 'failing_sub_workflow',
|
|
10
12
|
description:
|
|
11
13
|
'Launch an async sub-workflow that always fails. ' +
|
|
12
14
|
'Used to test that failed sub-workflow errors propagate back to the parent.',
|
|
13
15
|
schema: z.object({}),
|
|
16
|
+
resultSchema: FailingSubWorkflowToolResultSchema,
|
|
17
|
+
effects: 'none',
|
|
14
18
|
})
|
|
15
19
|
export class FailingSubWorkflowTool extends BaseTool<object, object, FailingSubWorkflowToolResult> {
|
|
16
20
|
constructor(private readonly failingWorkflow: AgentErrorHandlingFailingSubWorkflow) {
|
|
@@ -4,6 +4,8 @@ import type { RunContext } from '@loopstack/common';
|
|
|
4
4
|
|
|
5
5
|
export type RuntimeErrorToolResult = string;
|
|
6
6
|
|
|
7
|
+
export const RuntimeErrorToolResultSchema = z.string();
|
|
8
|
+
|
|
7
9
|
@Tool({
|
|
8
10
|
name: 'runtime_error',
|
|
9
11
|
description:
|
|
@@ -12,6 +14,8 @@ export type RuntimeErrorToolResult = string;
|
|
|
12
14
|
schema: z.object({
|
|
13
15
|
shouldFail: z.boolean().describe('Whether the tool should simulate a runtime failure.'),
|
|
14
16
|
}),
|
|
17
|
+
resultSchema: RuntimeErrorToolResultSchema,
|
|
18
|
+
effects: 'none',
|
|
15
19
|
})
|
|
16
20
|
export class RuntimeErrorTool extends BaseTool<{ shouldFail: boolean }, object, RuntimeErrorToolResult> {
|
|
17
21
|
protected async handle(
|
|
@@ -3,6 +3,8 @@ import { BaseTool, Tool, ToolEnvelope } from '@loopstack/common';
|
|
|
3
3
|
|
|
4
4
|
export type StrictSchemaToolResult = string;
|
|
5
5
|
|
|
6
|
+
export const StrictSchemaToolResultSchema = z.string();
|
|
7
|
+
|
|
6
8
|
@Tool({
|
|
7
9
|
name: 'strict_schema',
|
|
8
10
|
description: 'Greet a person by name. Requires a name argument. ' + 'Returns a greeting message.',
|
|
@@ -11,6 +13,8 @@ export type StrictSchemaToolResult = string;
|
|
|
11
13
|
name: z.string().describe('The name of the person to greet.'),
|
|
12
14
|
})
|
|
13
15
|
.strict(),
|
|
16
|
+
resultSchema: StrictSchemaToolResultSchema,
|
|
17
|
+
effects: 'none',
|
|
14
18
|
})
|
|
15
19
|
export class StrictSchemaTool extends BaseTool<{ name: string }, object, StrictSchemaToolResult> {
|
|
16
20
|
protected async handle(args: { name: string }): Promise<ToolEnvelope<StrictSchemaToolResult>> {
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { BaseTool, BaseWorkflow, Tool, ToolCallOptions, ToolEnvelope, Transition, Workflow } from '@loopstack/common';
|
|
4
|
+
import type { RunContext } from '@loopstack/common';
|
|
5
|
+
import { replay, runWorkflow } from '@loopstack/testing';
|
|
6
|
+
import { CustomToolExampleWorkflow } from '../custom-tool-example.workflow';
|
|
7
|
+
import { MathService } from '../services/math.service';
|
|
8
|
+
import { CounterTool, MathSumTool } from '../tools';
|
|
9
|
+
|
|
10
|
+
describe('CustomToolExampleWorkflow — runWorkflow facade', () => {
|
|
11
|
+
it('runs live tools, answers the wait transition, and completes', async () => {
|
|
12
|
+
const run = await runWorkflow(
|
|
13
|
+
CustomToolExampleWorkflow,
|
|
14
|
+
{ a: 2, b: 3 },
|
|
15
|
+
{
|
|
16
|
+
providers: [CounterTool, MathSumTool, MathService],
|
|
17
|
+
answers: { userContinue: {} },
|
|
18
|
+
},
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
// Assert outcomes, not mechanics: where the run ended, the path it took, and what it
|
|
22
|
+
// produced. (For inspecting the trace itself — tool calls, park settles, coverage — see
|
|
23
|
+
// trace-consumers.spec.ts.)
|
|
24
|
+
expect(run.error).toBeUndefined();
|
|
25
|
+
expect(run.status).toBe('completed');
|
|
26
|
+
expect(run.path).toEqual(['calculate', 'userContinue', 'continueCount']);
|
|
27
|
+
expect(run.result).toEqual({ total: 5 });
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('replays the scripted tool responses strictly in sequence', async () => {
|
|
31
|
+
const run = await runWorkflow(
|
|
32
|
+
CustomToolExampleWorkflow,
|
|
33
|
+
{ a: 2, b: 3 },
|
|
34
|
+
{
|
|
35
|
+
providers: [CounterTool, MathSumTool, MathService],
|
|
36
|
+
answers: { userContinue: {} },
|
|
37
|
+
replay: replay({
|
|
38
|
+
version: 3,
|
|
39
|
+
recordings: [
|
|
40
|
+
// The strict response sequence, in call order; transition names are assertions.
|
|
41
|
+
{ tool: 'math_sum', transition: 'calculate', args: { a: 2, b: 3 }, envelope: { data: 999 } },
|
|
42
|
+
{ tool: 'counter', transition: 'calculate', envelope: { data: 101 } },
|
|
43
|
+
{ tool: 'counter', transition: 'calculate', envelope: { data: 102 } },
|
|
44
|
+
{ tool: 'counter', transition: 'calculate', envelope: { data: 103 } },
|
|
45
|
+
{ tool: 'counter', transition: 'continueCount', envelope: { data: 104 } },
|
|
46
|
+
{ tool: 'counter', transition: 'continueCount', envelope: { data: 105 } },
|
|
47
|
+
{ tool: 'counter', transition: 'continueCount', envelope: { data: 106 } },
|
|
48
|
+
],
|
|
49
|
+
}),
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
expect(run.error).toBeUndefined();
|
|
54
|
+
expect(run.status).toBe('completed');
|
|
55
|
+
// The replayed math_sum envelope (999) replaced the live 2+3 result
|
|
56
|
+
expect(run.result).toEqual({ total: 999 });
|
|
57
|
+
|
|
58
|
+
// The replayed counter sequence is transition-scoped: 101-103 before the wait, 104-106 after
|
|
59
|
+
const texts = run.documents.map((d) => (d.content as { text?: string }).text ?? '');
|
|
60
|
+
expect(texts.some((t) => t.includes('Counter before pause: 101, 102, 103'))).toBe(true);
|
|
61
|
+
expect(texts.some((t) => t.includes('Counter after resume: 104, 105, 106'))).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// --- Fixture v3: config capture and drift detection ---------------------------------------
|
|
66
|
+
|
|
67
|
+
const PrefixConfigSchema = z.object({ prefix: z.string() });
|
|
68
|
+
type PrefixConfig = z.infer<typeof PrefixConfigSchema>;
|
|
69
|
+
|
|
70
|
+
@Tool({
|
|
71
|
+
name: 'prefixer',
|
|
72
|
+
schema: z.object({ word: z.string() }),
|
|
73
|
+
configSchema: PrefixConfigSchema,
|
|
74
|
+
resultSchema: z.string(),
|
|
75
|
+
})
|
|
76
|
+
class PrefixerTool extends BaseTool<{ word: string }, PrefixConfig, string> {
|
|
77
|
+
protected async handle(
|
|
78
|
+
args: { word: string },
|
|
79
|
+
_ctx: RunContext,
|
|
80
|
+
options?: ToolCallOptions<PrefixConfig>,
|
|
81
|
+
): Promise<ToolEnvelope<string>> {
|
|
82
|
+
return Promise.resolve({ data: `${options?.config?.prefix ?? ''}${args.word}` });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// The config the workflow sends — mutated between record and replay to simulate a prompt change.
|
|
87
|
+
let currentPrefix = 'hello-';
|
|
88
|
+
|
|
89
|
+
@Workflow({ title: 'Config Replay Probe' })
|
|
90
|
+
class ConfigReplayWorkflow extends BaseWorkflow {
|
|
91
|
+
constructor(private readonly prefixer: PrefixerTool) {
|
|
92
|
+
super();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@Transition({ to: 'end' })
|
|
96
|
+
async greet() {
|
|
97
|
+
const result = await this.prefixer.call({ word: 'world' }, { config: { prefix: currentPrefix } });
|
|
98
|
+
this.setResult({ message: result.data });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
describe('fixture v3 — config capture and drift', () => {
|
|
103
|
+
it('records config, replays to the identical result, and fails on config drift', async () => {
|
|
104
|
+
currentPrefix = 'hello-';
|
|
105
|
+
const recorded = await runWorkflow(ConfigReplayWorkflow, undefined, {
|
|
106
|
+
providers: [PrefixerTool],
|
|
107
|
+
record: true,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
expect(recorded.status).toBe('completed');
|
|
111
|
+
expect(recorded.result).toEqual({ message: 'hello-world' });
|
|
112
|
+
expect(recorded.recordings?.version).toBe(3);
|
|
113
|
+
expect(recorded.recordings?.recordings[0]).toMatchObject({
|
|
114
|
+
tool: 'prefixer',
|
|
115
|
+
args: { word: 'world' },
|
|
116
|
+
config: { prefix: 'hello-' },
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Same config → the fixture replays to the identical result.
|
|
120
|
+
const replayed = await runWorkflow(ConfigReplayWorkflow, undefined, {
|
|
121
|
+
providers: [PrefixerTool],
|
|
122
|
+
replay: replay(recorded.recordings!),
|
|
123
|
+
});
|
|
124
|
+
expect(replayed.status).toBe('completed');
|
|
125
|
+
expect(replayed.result).toEqual({ message: 'hello-world' });
|
|
126
|
+
|
|
127
|
+
// Changed config — the drift the feature exists to catch: the run fails naming the config.
|
|
128
|
+
currentPrefix = 'changed-';
|
|
129
|
+
const drifted = await runWorkflow(ConfigReplayWorkflow, undefined, {
|
|
130
|
+
providers: [PrefixerTool],
|
|
131
|
+
replay: replay(recorded.recordings!),
|
|
132
|
+
});
|
|
133
|
+
expect(drifted.status).toBe('failed');
|
|
134
|
+
expect(drifted.error).toMatch(/config for 'prefixer'/);
|
|
135
|
+
expect(drifted.error).toContain('hello-');
|
|
136
|
+
expect(drifted.error).toContain('changed-');
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('rejects version 2 fixtures outright', () => {
|
|
140
|
+
expect(() => replay({ version: 2, recordings: [] } as never)).toThrow(/version: 2.*Expected 3/s);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { coverage, createContractFake, diffTraces, runWorkflow } from '@loopstack/testing';
|
|
3
|
+
import { CustomToolExampleWorkflow } from '../custom-tool-example.workflow';
|
|
4
|
+
import { MathService } from '../services/math.service';
|
|
5
|
+
import { CounterTool, MathSumTool } from '../tools';
|
|
6
|
+
|
|
7
|
+
const PROVIDERS = [CounterTool, MathSumTool, MathService];
|
|
8
|
+
|
|
9
|
+
describe('coverage — state-machine coverage over run traces', () => {
|
|
10
|
+
it('reports full coverage when runs exercise every transition and park', async () => {
|
|
11
|
+
const completed = await runWorkflow(
|
|
12
|
+
CustomToolExampleWorkflow,
|
|
13
|
+
{ a: 2, b: 3 },
|
|
14
|
+
{
|
|
15
|
+
providers: PROVIDERS,
|
|
16
|
+
answers: { userContinue: {} },
|
|
17
|
+
},
|
|
18
|
+
);
|
|
19
|
+
const parked = await runWorkflow(CustomToolExampleWorkflow, { a: 1, b: 1 }, { providers: PROVIDERS });
|
|
20
|
+
|
|
21
|
+
const cov = coverage([completed, parked], CustomToolExampleWorkflow);
|
|
22
|
+
|
|
23
|
+
expect(cov.missingTransitions).toEqual([]);
|
|
24
|
+
expect(cov.missingParks).toEqual([]);
|
|
25
|
+
expect(cov.complete).toBe(true);
|
|
26
|
+
expect(cov.parkedOn).toContain('userContinue');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('names what a partial suite leaves untested', async () => {
|
|
30
|
+
// Only the parked run: the wait transition and everything after it never execute.
|
|
31
|
+
const parked = await runWorkflow(CustomToolExampleWorkflow, { a: 1, b: 1 }, { providers: PROVIDERS });
|
|
32
|
+
|
|
33
|
+
const cov = coverage([parked], CustomToolExampleWorkflow);
|
|
34
|
+
|
|
35
|
+
expect(cov.complete).toBe(false);
|
|
36
|
+
expect(cov.missingTransitions).toContain('userContinue');
|
|
37
|
+
expect(cov.missingTransitions).toContain('continueCount');
|
|
38
|
+
expect(cov.executedTransitions).toContain('calculate');
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe('diffTraces — first divergence between two runs', () => {
|
|
43
|
+
it('diffs clean for two runs of identical behavior despite differing timings', async () => {
|
|
44
|
+
const first = await runWorkflow(
|
|
45
|
+
CustomToolExampleWorkflow,
|
|
46
|
+
{ a: 2, b: 3 },
|
|
47
|
+
{
|
|
48
|
+
providers: PROVIDERS,
|
|
49
|
+
answers: { userContinue: {} },
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
const second = await runWorkflow(
|
|
53
|
+
CustomToolExampleWorkflow,
|
|
54
|
+
{ a: 2, b: 3 },
|
|
55
|
+
{
|
|
56
|
+
providers: PROVIDERS,
|
|
57
|
+
answers: { userContinue: {} },
|
|
58
|
+
},
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
expect(diffTraces(first.trace, second.trace)).toBeNull();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('reports the first point where two runs stopped doing the same thing', async () => {
|
|
65
|
+
const completed = await runWorkflow(
|
|
66
|
+
CustomToolExampleWorkflow,
|
|
67
|
+
{ a: 2, b: 3 },
|
|
68
|
+
{
|
|
69
|
+
providers: PROVIDERS,
|
|
70
|
+
answers: { userContinue: {} },
|
|
71
|
+
},
|
|
72
|
+
);
|
|
73
|
+
const parked = await runWorkflow(CustomToolExampleWorkflow, { a: 2, b: 3 }, { providers: PROVIDERS });
|
|
74
|
+
|
|
75
|
+
const divergence = diffTraces(completed.trace, parked.trace);
|
|
76
|
+
|
|
77
|
+
expect(divergence).not.toBeNull();
|
|
78
|
+
expect(divergence!.reason).toBeTruthy();
|
|
79
|
+
// Both runs agree up to the park — the divergence is at or after the settle.
|
|
80
|
+
expect(divergence!.index).toBeGreaterThan(0);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe('createContractFake — contract-validated DI mocks', () => {
|
|
85
|
+
it('validates scripted envelopes against the resultSchema at scripting time', () => {
|
|
86
|
+
const fake = createContractFake(MathSumTool);
|
|
87
|
+
|
|
88
|
+
expect(() => fake.returns({ data: 'not-a-number' })).toThrow(/result violates its resultSchema/);
|
|
89
|
+
expect(() => fake.returns({ data: 42 })).not.toThrow();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('feeds validated responses into the workflow and supports interaction assertions', async () => {
|
|
93
|
+
const fake = createContractFake(MathSumTool).returns({ data: 999 });
|
|
94
|
+
|
|
95
|
+
const run = await runWorkflow(
|
|
96
|
+
CustomToolExampleWorkflow,
|
|
97
|
+
{ a: 2, b: 3 },
|
|
98
|
+
{
|
|
99
|
+
providers: [{ provide: MathSumTool, useValue: fake }, CounterTool, MathService],
|
|
100
|
+
answers: { userContinue: {} },
|
|
101
|
+
},
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
expect(run.status).toBe('completed');
|
|
105
|
+
expect(run.result).toEqual({ total: 999 });
|
|
106
|
+
expect(fake.call).toHaveBeenCalledWith({ a: 2, b: 3 });
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('rejects unscripted calls loudly', async () => {
|
|
110
|
+
const fake = createContractFake(MathSumTool);
|
|
111
|
+
|
|
112
|
+
const run = await runWorkflow(
|
|
113
|
+
CustomToolExampleWorkflow,
|
|
114
|
+
{ a: 2, b: 3 },
|
|
115
|
+
{
|
|
116
|
+
providers: [{ provide: MathSumTool, useValue: fake }, CounterTool, MathService],
|
|
117
|
+
},
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
expect(run.status).toBe('failed');
|
|
121
|
+
expect(run.error).toMatch(/Unscripted contract fake call on 'math_sum'/);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
@@ -62,7 +62,7 @@ export class CustomToolExampleWorkflow extends BaseWorkflow<CustomToolExampleArg
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
@Transition({ from: 'waiting_for_user', to: 'resumed', wait: true })
|
|
65
|
-
userContinue(
|
|
65
|
+
userContinue() {
|
|
66
66
|
// User pressed Next — counter state should persist from checkpoint
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import { BaseTool, Tool, ToolEnvelope } from '@loopstack/common';
|
|
2
3
|
|
|
3
4
|
export type CounterToolResult = number;
|
|
4
5
|
|
|
6
|
+
export const CounterToolResultSchema = z.number();
|
|
7
|
+
|
|
5
8
|
@Tool({
|
|
6
9
|
name: 'counter',
|
|
7
10
|
description: 'Counter tool.',
|
|
11
|
+
resultSchema: CounterToolResultSchema,
|
|
12
|
+
effects: 'none',
|
|
8
13
|
})
|
|
9
14
|
export class CounterTool extends BaseTool<object, object, CounterToolResult> {
|
|
10
15
|
count: number = 0;
|
|
@@ -13,10 +13,14 @@ type MathSumArgs = z.infer<typeof MathSumSchema>;
|
|
|
13
13
|
|
|
14
14
|
export type MathSumToolResult = number;
|
|
15
15
|
|
|
16
|
+
export const MathSumToolResultSchema = z.number();
|
|
17
|
+
|
|
16
18
|
@Tool({
|
|
17
19
|
name: 'math_sum',
|
|
18
20
|
description: 'Math tool calculating the sum of two arguments by using an injected service.',
|
|
19
21
|
schema: MathSumSchema,
|
|
22
|
+
resultSchema: MathSumToolResultSchema,
|
|
23
|
+
effects: 'none',
|
|
20
24
|
})
|
|
21
25
|
export class MathSumTool extends BaseTool<MathSumArgs, object, MathSumToolResult> {
|
|
22
26
|
constructor(private readonly mathService: MathService) {
|
|
@@ -27,7 +27,7 @@ export class DynamicRoutingExampleWorkflow extends BaseWorkflow<DynamicRoutingAr
|
|
|
27
27
|
async createMockData(state: DynamicRoutingState, ctx: RunContext<DynamicRoutingArgs>) {
|
|
28
28
|
await this.documentStore.save(MessageDocument, {
|
|
29
29
|
role: 'assistant',
|
|
30
|
-
text: `
|
|
30
|
+
text: `Analyzing value = ${ctx.args.value}`,
|
|
31
31
|
});
|
|
32
32
|
this.assignState({ value: ctx.args.value });
|
|
33
33
|
}
|
|
@@ -36,32 +36,32 @@ export class DynamicRoutingExampleWorkflow extends BaseWorkflow<DynamicRoutingAr
|
|
|
36
36
|
|
|
37
37
|
@Transition({ from: 'prepared', to: 'placeA', priority: 10 })
|
|
38
38
|
@Guard('isAbove100')
|
|
39
|
-
routeToPlaceA(
|
|
39
|
+
routeToPlaceA() {}
|
|
40
40
|
|
|
41
41
|
isAbove100(state: DynamicRoutingState): boolean {
|
|
42
42
|
return state.value > 100;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
@Transition({ from: 'prepared', to: 'placeB' })
|
|
46
|
-
routeToPlaceB(
|
|
46
|
+
routeToPlaceB() {} // no priority -> evaluated last, acts as fallback
|
|
47
47
|
|
|
48
48
|
// --- Second routing fork (from 'placeA') ---
|
|
49
49
|
|
|
50
50
|
@Transition({ from: 'placeA', to: 'placeC', priority: 10 })
|
|
51
51
|
@Guard('isAbove200')
|
|
52
|
-
routeToPlaceC(
|
|
52
|
+
routeToPlaceC() {}
|
|
53
53
|
|
|
54
54
|
isAbove200(state: DynamicRoutingState): boolean {
|
|
55
55
|
return state.value > 200;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
@Transition({ from: 'placeA', to: 'placeD' })
|
|
59
|
-
routeToPlaceD(
|
|
59
|
+
routeToPlaceD() {} // no priority -> evaluated last, acts as fallback
|
|
60
60
|
|
|
61
61
|
// --- Terminal transitions ---
|
|
62
62
|
|
|
63
63
|
@Transition({ from: 'placeB', to: 'end' })
|
|
64
|
-
async showMessagePlaceB(
|
|
64
|
+
async showMessagePlaceB() {
|
|
65
65
|
await this.documentStore.save(MessageDocument, {
|
|
66
66
|
role: 'assistant',
|
|
67
67
|
text: 'Value is less or equal 100',
|
|
@@ -69,7 +69,7 @@ export class DynamicRoutingExampleWorkflow extends BaseWorkflow<DynamicRoutingAr
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
@Transition({ from: 'placeC', to: 'end' })
|
|
72
|
-
async showMessagePlaceC(
|
|
72
|
+
async showMessagePlaceC() {
|
|
73
73
|
await this.documentStore.save(MessageDocument, {
|
|
74
74
|
role: 'assistant',
|
|
75
75
|
text: 'Value is greater than 200',
|
|
@@ -77,7 +77,7 @@ export class DynamicRoutingExampleWorkflow extends BaseWorkflow<DynamicRoutingAr
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
@Transition({ from: 'placeD', to: 'end' })
|
|
80
|
-
async showMessagePlaceD(
|
|
80
|
+
async showMessagePlaceD() {
|
|
81
81
|
await this.documentStore.save(MessageDocument, {
|
|
82
82
|
role: 'assistant',
|
|
83
83
|
text: 'Value is less or equal 200, but greater than 100',
|