@loopstack/agent-example-workflow 0.3.0 → 0.3.1
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.
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { AgentWorkflow } from '@loopstack/agent';
|
|
3
3
|
import { BaseWorkflow } from '@loopstack/common';
|
|
4
|
-
import type { TemplateRenderFn } from '@loopstack/common';
|
|
5
4
|
declare const AgentCallbackSchema: z.ZodObject<{
|
|
6
5
|
workflowId: z.ZodString;
|
|
7
6
|
status: z.ZodString;
|
|
@@ -12,8 +11,7 @@ declare const AgentCallbackSchema: z.ZodObject<{
|
|
|
12
11
|
type AgentCallback = z.infer<typeof AgentCallbackSchema>;
|
|
13
12
|
export declare class AgentExampleWorkflow extends BaseWorkflow {
|
|
14
13
|
private readonly agentWorkflow;
|
|
15
|
-
|
|
16
|
-
constructor(agentWorkflow: AgentWorkflow, render: TemplateRenderFn);
|
|
14
|
+
constructor(agentWorkflow: AgentWorkflow);
|
|
17
15
|
start(state: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
18
16
|
agentComplete(state: Record<string, unknown>, payload: AgentCallback): Promise<unknown>;
|
|
19
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-example.workflow.d.ts","sourceRoot":"","sources":["../src/agent-example.workflow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent-example.workflow.d.ts","sourceRoot":"","sources":["../src/agent-example.workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EACL,YAAY,EAOb,MAAM,mBAAmB,CAAC;AAE3B,QAAA,MAAM,mBAAmB;;;;;;iBAEvB,CAAC;AAEH,KAAK,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEzD,qBAIa,oBAAqB,SAAQ,YAAY;IACxC,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAAb,aAAa,EAAE,aAAa;IAKnD,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAwBvE,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;CAa9F"}
|
|
@@ -8,25 +8,19 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.AgentExampleWorkflow = void 0;
|
|
16
|
-
const common_1 = require("@nestjs/common");
|
|
17
13
|
const zod_1 = require("zod");
|
|
18
14
|
const agent_1 = require("@loopstack/agent");
|
|
19
|
-
const
|
|
20
|
-
const AgentCallbackSchema =
|
|
15
|
+
const common_1 = require("@loopstack/common");
|
|
16
|
+
const AgentCallbackSchema = common_1.CallbackSchema.extend({
|
|
21
17
|
data: zod_1.z.object({ response: zod_1.z.string() }),
|
|
22
18
|
});
|
|
23
|
-
let AgentExampleWorkflow = class AgentExampleWorkflow extends
|
|
19
|
+
let AgentExampleWorkflow = class AgentExampleWorkflow extends common_1.BaseWorkflow {
|
|
24
20
|
agentWorkflow;
|
|
25
|
-
|
|
26
|
-
constructor(agentWorkflow, render) {
|
|
21
|
+
constructor(agentWorkflow) {
|
|
27
22
|
super();
|
|
28
23
|
this.agentWorkflow = agentWorkflow;
|
|
29
|
-
this.render = render;
|
|
30
24
|
}
|
|
31
25
|
async start(state) {
|
|
32
26
|
const result = await this.agentWorkflow.run({
|
|
@@ -34,12 +28,12 @@ let AgentExampleWorkflow = class AgentExampleWorkflow extends common_2.BaseWorkf
|
|
|
34
28
|
tools: ['weather_lookup', 'calculator'],
|
|
35
29
|
userMessage: "What's the weather in Tokyo? Also, what is 42 * 17?",
|
|
36
30
|
}, { callback: { transition: 'agentComplete' } });
|
|
37
|
-
await this.documentStore.save(
|
|
31
|
+
await this.documentStore.save(common_1.LinkDocument, { label: 'Agent working...', workflowId: result.workflowId, embed: true, expanded: true }, { id: `link_${result.workflowId}` });
|
|
38
32
|
return state;
|
|
39
33
|
}
|
|
40
34
|
async agentComplete(state, payload) {
|
|
41
|
-
await this.documentStore.save(
|
|
42
|
-
await this.documentStore.save(
|
|
35
|
+
await this.documentStore.save(common_1.LinkDocument, { label: 'Agent complete', status: 'success', workflowId: payload.workflowId }, { id: `link_${payload.workflowId}` });
|
|
36
|
+
await this.documentStore.save(common_1.MessageDocument, {
|
|
43
37
|
role: 'assistant',
|
|
44
38
|
content: payload.data.response,
|
|
45
39
|
});
|
|
@@ -48,13 +42,13 @@ let AgentExampleWorkflow = class AgentExampleWorkflow extends common_2.BaseWorkf
|
|
|
48
42
|
};
|
|
49
43
|
exports.AgentExampleWorkflow = AgentExampleWorkflow;
|
|
50
44
|
__decorate([
|
|
51
|
-
(0,
|
|
45
|
+
(0, common_1.Transition)({ to: 'running' }),
|
|
52
46
|
__metadata("design:type", Function),
|
|
53
47
|
__metadata("design:paramtypes", [Object]),
|
|
54
48
|
__metadata("design:returntype", Promise)
|
|
55
49
|
], AgentExampleWorkflow.prototype, "start", null);
|
|
56
50
|
__decorate([
|
|
57
|
-
(0,
|
|
51
|
+
(0, common_1.Transition)({
|
|
58
52
|
from: 'running',
|
|
59
53
|
to: 'end',
|
|
60
54
|
wait: true,
|
|
@@ -65,11 +59,10 @@ __decorate([
|
|
|
65
59
|
__metadata("design:returntype", Promise)
|
|
66
60
|
], AgentExampleWorkflow.prototype, "agentComplete", null);
|
|
67
61
|
exports.AgentExampleWorkflow = AgentExampleWorkflow = __decorate([
|
|
68
|
-
(0,
|
|
62
|
+
(0, common_1.Workflow)({
|
|
69
63
|
title: 'Agent Example',
|
|
70
64
|
description: 'Launches a generic agent sub-workflow with weather and calculator tools.',
|
|
71
65
|
}),
|
|
72
|
-
|
|
73
|
-
__metadata("design:paramtypes", [agent_1.AgentWorkflow, Function])
|
|
66
|
+
__metadata("design:paramtypes", [agent_1.AgentWorkflow])
|
|
74
67
|
], AgentExampleWorkflow);
|
|
75
68
|
//# sourceMappingURL=agent-example.workflow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-example.workflow.js","sourceRoot":"","sources":["../src/agent-example.workflow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent-example.workflow.js","sourceRoot":"","sources":["../src/agent-example.workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6BAAwB;AACxB,4CAAiD;AACjD,8CAQ2B;AAE3B,MAAM,mBAAmB,GAAG,uBAAc,CAAC,MAAM,CAAC;IAChD,IAAI,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC;CACzC,CAAC,CAAC;AAQI,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,qBAAY;IACvB;IAA7B,YAA6B,aAA4B;QACvD,KAAK,EAAE,CAAC;QADmB,kBAAa,GAAb,aAAa,CAAe;IAEzD,CAAC;IAGK,AAAN,KAAK,CAAC,KAAK,CAAC,KAA8B;QACxC,MAAM,MAAM,GAAgB,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CACtD;YACE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,sBAAsB,CAAC;YACvD,KAAK,EAAE,CAAC,gB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E,0EAA0E;KACxF,CAAC;qCAE4C,qBAAa;GAD9C,oBAAoB,CA2ChC"}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"claude",
|
|
10
10
|
"sub-workflow"
|
|
11
11
|
],
|
|
12
|
-
"version": "0.3.
|
|
12
|
+
"version": "0.3.1",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"author": {
|
|
15
15
|
"name": "Jakob Klippel",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@loopstack/agent": "^0.5.0",
|
|
34
|
-
"@loopstack/common": "^0.32.
|
|
34
|
+
"@loopstack/common": "^0.32.1",
|
|
35
35
|
"@nestjs/common": "^11.1.19",
|
|
36
36
|
"zod": "^4.3.6"
|
|
37
37
|
},
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Inject } from '@nestjs/common';
|
|
2
1
|
import { z } from 'zod';
|
|
3
2
|
import { AgentWorkflow } from '@loopstack/agent';
|
|
4
3
|
import {
|
|
@@ -7,11 +6,9 @@ import {
|
|
|
7
6
|
LinkDocument,
|
|
8
7
|
MessageDocument,
|
|
9
8
|
QueueResult,
|
|
10
|
-
TEMPLATE_RENDERER,
|
|
11
9
|
Transition,
|
|
12
10
|
Workflow,
|
|
13
11
|
} from '@loopstack/common';
|
|
14
|
-
import type { TemplateRenderFn } from '@loopstack/common';
|
|
15
12
|
|
|
16
13
|
const AgentCallbackSchema = CallbackSchema.extend({
|
|
17
14
|
data: z.object({ response: z.string() }),
|
|
@@ -24,10 +21,7 @@ type AgentCallback = z.infer<typeof AgentCallbackSchema>;
|
|
|
24
21
|
description: 'Launches a generic agent sub-workflow with weather and calculator tools.',
|
|
25
22
|
})
|
|
26
23
|
export class AgentExampleWorkflow extends BaseWorkflow {
|
|
27
|
-
constructor(
|
|
28
|
-
private readonly agentWorkflow: AgentWorkflow,
|
|
29
|
-
@Inject(TEMPLATE_RENDERER) private readonly render: TemplateRenderFn,
|
|
30
|
-
) {
|
|
24
|
+
constructor(private readonly agentWorkflow: AgentWorkflow) {
|
|
31
25
|
super();
|
|
32
26
|
}
|
|
33
27
|
|