zeitlich 0.2.19 → 0.2.21
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/adapters/sandbox/daytona/index.cjs +25 -10
- package/dist/adapters/sandbox/daytona/index.cjs.map +1 -1
- package/dist/adapters/sandbox/daytona/index.d.cts +4 -1
- package/dist/adapters/sandbox/daytona/index.d.ts +4 -1
- package/dist/adapters/sandbox/daytona/index.js +25 -10
- package/dist/adapters/sandbox/daytona/index.js.map +1 -1
- package/dist/adapters/sandbox/virtual/index.d.cts +4 -3
- package/dist/adapters/sandbox/virtual/index.d.ts +4 -3
- package/dist/adapters/thread/google-genai/index.cjs +69 -24
- package/dist/adapters/thread/google-genai/index.cjs.map +1 -1
- package/dist/adapters/thread/google-genai/index.d.cts +10 -10
- package/dist/adapters/thread/google-genai/index.d.ts +10 -10
- package/dist/adapters/thread/google-genai/index.js +69 -24
- package/dist/adapters/thread/google-genai/index.js.map +1 -1
- package/dist/adapters/thread/langchain/index.cjs +76 -69
- package/dist/adapters/thread/langchain/index.cjs.map +1 -1
- package/dist/adapters/thread/langchain/index.d.cts +11 -11
- package/dist/adapters/thread/langchain/index.d.ts +11 -11
- package/dist/adapters/thread/langchain/index.js +76 -69
- package/dist/adapters/thread/langchain/index.js.map +1 -1
- package/dist/index.cjs +198 -118
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -14
- package/dist/index.d.ts +14 -14
- package/dist/index.js +198 -118
- package/dist/index.js.map +1 -1
- package/dist/{queries-D8T4pEeu.d.ts → queries-6Avfh74U.d.ts} +1 -1
- package/dist/{queries-D22uWTOb.d.cts → queries-CHa2iv_I.d.cts} +1 -1
- package/dist/{types-CxWLeJTB.d.ts → types-BkAYmc96.d.ts} +6 -6
- package/dist/{types-CCfJb5Jl.d.cts → types-CES_30qx.d.cts} +6 -6
- package/dist/{types-DjT78Sdp.d.cts → types-YbL7JpEA.d.cts} +4 -2
- package/dist/{types-DjT78Sdp.d.ts → types-YbL7JpEA.d.ts} +4 -2
- package/dist/workflow.cjs +68 -34
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +16 -12
- package/dist/workflow.d.ts +16 -12
- package/dist/workflow.js +68 -34
- package/dist/workflow.js.map +1 -1
- package/package.json +1 -1
- package/src/adapters/sandbox/daytona/filesystem.ts +21 -12
- package/src/adapters/sandbox/daytona/index.ts +24 -23
- package/src/adapters/thread/google-genai/activities.ts +11 -9
- package/src/adapters/thread/google-genai/model-invoker.ts +6 -11
- package/src/adapters/thread/google-genai/thread-manager.ts +44 -29
- package/src/adapters/thread/langchain/activities.ts +6 -4
- package/src/adapters/thread/langchain/thread-manager.ts +55 -27
- package/src/lib/session/session-edge-cases.integration.test.ts +20 -2
- package/src/lib/session/session.integration.test.ts +16 -2
- package/src/lib/session/session.ts +7 -5
- package/src/lib/session/types.ts +9 -3
- package/src/lib/subagent/handler.ts +1 -1
- package/src/lib/subagent/subagent.integration.test.ts +5 -4
- package/src/lib/subagent/tool.ts +1 -1
- package/src/lib/thread/index.ts +0 -1
- package/src/lib/tool-router/auto-append-sandbox.integration.test.ts +20 -21
- package/src/lib/tool-router/auto-append.ts +3 -2
- package/src/lib/tool-router/router-edge-cases.integration.test.ts +64 -23
- package/src/lib/tool-router/router.integration.test.ts +60 -23
- package/src/lib/tool-router/router.ts +58 -29
- package/src/lib/tool-router/types.ts +12 -7
- package/src/lib/workflow.test.ts +18 -6
- package/src/lib/workflow.ts +13 -3
- package/src/tools/task-create/handler.ts +3 -6
- package/src/workflow.ts +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as SandboxFileSystem, F as FileStat, D as DirentEntry, S as Sandbox, d as SandboxCreateOptions } from './types-BMRzfELQ.js';
|
|
2
|
-
import { R as RouterContext } from './types-
|
|
2
|
+
import { R as RouterContext } from './types-YbL7JpEA.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Ephemeral {@link SandboxFileSystem} backed by a {@link FileResolver}.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as SandboxFileSystem, F as FileStat, D as DirentEntry, S as Sandbox, d as SandboxCreateOptions } from './types-BMRzfELQ.cjs';
|
|
2
|
-
import { R as RouterContext } from './types-
|
|
2
|
+
import { R as RouterContext } from './types-YbL7JpEA.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Ephemeral {@link SandboxFileSystem} backed by a {@link FileResolver}.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Duration } from '@temporalio/common';
|
|
2
|
-
import { a as ToolMap, b as ToolRouterHooks, M as MessageContent, S as SessionExitReason, c as ToolHandlerResponse, P as PreToolUseHookResult, d as PostToolUseFailureHookResult, e as RawToolCall, f as TokenUsage, B as BaseAgentState, g as RunAgentConfig, h as AgentStatus, W as WorkflowTask, i as ToolDefinition, j as ToolResultConfig, k as ToolCallResultUnion, I as InferToolResults } from './types-
|
|
2
|
+
import { a as ToolMap, b as ToolRouterHooks, M as MessageContent, S as SessionExitReason, c as ToolHandlerResponse, P as PreToolUseHookResult, d as PostToolUseFailureHookResult, e as RawToolCall, f as TokenUsage, B as BaseAgentState, g as RunAgentConfig, h as AgentStatus, W as WorkflowTask, i as ToolDefinition, j as ToolResultConfig, k as ToolCallResultUnion, I as InferToolResults } from './types-YbL7JpEA.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { g as SandboxOps } from './types-BMRzfELQ.js';
|
|
5
|
-
import { QueryDefinition } from '@temporalio/workflow';
|
|
5
|
+
import { QueryDefinition, ActivityInterfaceFor } from '@temporalio/workflow';
|
|
6
6
|
import { UpdateDefinition } from '@temporalio/common/lib/interfaces';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -342,11 +342,11 @@ interface ThreadOps {
|
|
|
342
342
|
/** Initialize an empty thread */
|
|
343
343
|
initializeThread(threadId: string): Promise<void>;
|
|
344
344
|
/** Append a human message to the thread */
|
|
345
|
-
appendHumanMessage(threadId: string, content: string | MessageContent): Promise<void>;
|
|
345
|
+
appendHumanMessage(threadId: string, id: string, content: string | MessageContent): Promise<void>;
|
|
346
346
|
/** Append a tool result to the thread */
|
|
347
|
-
appendToolResult(config: ToolResultConfig): Promise<void>;
|
|
347
|
+
appendToolResult(id: string, config: ToolResultConfig): Promise<void>;
|
|
348
348
|
/** Append a system message to the thread */
|
|
349
|
-
appendSystemMessage(threadId: string, content: string): Promise<void>;
|
|
349
|
+
appendSystemMessage(threadId: string, id: string, content: string): Promise<void>;
|
|
350
350
|
/** Copy all messages from sourceThreadId into a new thread at targetThreadId */
|
|
351
351
|
forkThread(sourceThreadId: string, targetThreadId: string): Promise<void>;
|
|
352
352
|
}
|
|
@@ -367,7 +367,7 @@ interface SessionConfig<T extends ToolMap, M = unknown> {
|
|
|
367
367
|
/** Workflow-specific runAgent activity (with tools pre-bound) */
|
|
368
368
|
runAgent: RunAgentActivity<M>;
|
|
369
369
|
/** Thread operations (initialize, append messages, parse tool calls) */
|
|
370
|
-
threadOps?: ThreadOps
|
|
370
|
+
threadOps?: ActivityInterfaceFor<ThreadOps>;
|
|
371
371
|
/** Tool router for processing tool calls (optional if agent has no tools) */
|
|
372
372
|
tools?: T;
|
|
373
373
|
/** Subagent configurations */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Duration } from '@temporalio/common';
|
|
2
|
-
import { a as ToolMap, b as ToolRouterHooks, M as MessageContent, S as SessionExitReason, c as ToolHandlerResponse, P as PreToolUseHookResult, d as PostToolUseFailureHookResult, e as RawToolCall, f as TokenUsage, B as BaseAgentState, g as RunAgentConfig, h as AgentStatus, W as WorkflowTask, i as ToolDefinition, j as ToolResultConfig, k as ToolCallResultUnion, I as InferToolResults } from './types-
|
|
2
|
+
import { a as ToolMap, b as ToolRouterHooks, M as MessageContent, S as SessionExitReason, c as ToolHandlerResponse, P as PreToolUseHookResult, d as PostToolUseFailureHookResult, e as RawToolCall, f as TokenUsage, B as BaseAgentState, g as RunAgentConfig, h as AgentStatus, W as WorkflowTask, i as ToolDefinition, j as ToolResultConfig, k as ToolCallResultUnion, I as InferToolResults } from './types-YbL7JpEA.cjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { g as SandboxOps } from './types-BMRzfELQ.cjs';
|
|
5
|
-
import { QueryDefinition } from '@temporalio/workflow';
|
|
5
|
+
import { QueryDefinition, ActivityInterfaceFor } from '@temporalio/workflow';
|
|
6
6
|
import { UpdateDefinition } from '@temporalio/common/lib/interfaces';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -342,11 +342,11 @@ interface ThreadOps {
|
|
|
342
342
|
/** Initialize an empty thread */
|
|
343
343
|
initializeThread(threadId: string): Promise<void>;
|
|
344
344
|
/** Append a human message to the thread */
|
|
345
|
-
appendHumanMessage(threadId: string, content: string | MessageContent): Promise<void>;
|
|
345
|
+
appendHumanMessage(threadId: string, id: string, content: string | MessageContent): Promise<void>;
|
|
346
346
|
/** Append a tool result to the thread */
|
|
347
|
-
appendToolResult(config: ToolResultConfig): Promise<void>;
|
|
347
|
+
appendToolResult(id: string, config: ToolResultConfig): Promise<void>;
|
|
348
348
|
/** Append a system message to the thread */
|
|
349
|
-
appendSystemMessage(threadId: string, content: string): Promise<void>;
|
|
349
|
+
appendSystemMessage(threadId: string, id: string, content: string): Promise<void>;
|
|
350
350
|
/** Copy all messages from sourceThreadId into a new thread at targetThreadId */
|
|
351
351
|
forkThread(sourceThreadId: string, targetThreadId: string): Promise<void>;
|
|
352
352
|
}
|
|
@@ -367,7 +367,7 @@ interface SessionConfig<T extends ToolMap, M = unknown> {
|
|
|
367
367
|
/** Workflow-specific runAgent activity (with tools pre-bound) */
|
|
368
368
|
runAgent: RunAgentActivity<M>;
|
|
369
369
|
/** Thread operations (initialize, append messages, parse tool calls) */
|
|
370
|
-
threadOps?: ThreadOps
|
|
370
|
+
threadOps?: ActivityInterfaceFor<ThreadOps>;
|
|
371
371
|
/** Tool router for processing tool calls (optional if agent has no tools) */
|
|
372
372
|
tools?: T;
|
|
373
373
|
/** Subagent configurations */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { ActivityFunctionWithOptions } from '@temporalio/workflow';
|
|
2
3
|
|
|
3
4
|
/** A single content part within a structured message (text, image, etc.) */
|
|
4
5
|
type ContentPart = {
|
|
@@ -199,7 +200,7 @@ type ParsedToolCallUnion<T extends ToolMap> = {
|
|
|
199
200
|
/**
|
|
200
201
|
* Function signature for appending tool results to a thread.
|
|
201
202
|
*/
|
|
202
|
-
type AppendToolResultFn = (config: ToolResultConfig) => Promise<void
|
|
203
|
+
type AppendToolResultFn = ActivityFunctionWithOptions<(id: string, config: ToolResultConfig) => Promise<void>>;
|
|
203
204
|
/**
|
|
204
205
|
* The response from a tool handler.
|
|
205
206
|
* Contains the content for the tool message and the result to return from processToolCalls.
|
|
@@ -415,7 +416,8 @@ interface ToolRouterOptions<T extends ToolMap> {
|
|
|
415
416
|
tools: T;
|
|
416
417
|
/** Thread ID for appending tool results */
|
|
417
418
|
threadId: string;
|
|
418
|
-
/** Function to append tool results to the thread (called automatically after each handler)
|
|
419
|
+
/** Function to append tool results to the thread (called automatically after each handler).
|
|
420
|
+
* Accepts a Temporal activity proxy with {@link ActivityFunctionWithOptions}. */
|
|
419
421
|
appendToolResult: AppendToolResultFn;
|
|
420
422
|
/** Whether to process tools in parallel (default: true) */
|
|
421
423
|
parallel?: boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { ActivityFunctionWithOptions } from '@temporalio/workflow';
|
|
2
3
|
|
|
3
4
|
/** A single content part within a structured message (text, image, etc.) */
|
|
4
5
|
type ContentPart = {
|
|
@@ -199,7 +200,7 @@ type ParsedToolCallUnion<T extends ToolMap> = {
|
|
|
199
200
|
/**
|
|
200
201
|
* Function signature for appending tool results to a thread.
|
|
201
202
|
*/
|
|
202
|
-
type AppendToolResultFn = (config: ToolResultConfig) => Promise<void
|
|
203
|
+
type AppendToolResultFn = ActivityFunctionWithOptions<(id: string, config: ToolResultConfig) => Promise<void>>;
|
|
203
204
|
/**
|
|
204
205
|
* The response from a tool handler.
|
|
205
206
|
* Contains the content for the tool message and the result to return from processToolCalls.
|
|
@@ -415,7 +416,8 @@ interface ToolRouterOptions<T extends ToolMap> {
|
|
|
415
416
|
tools: T;
|
|
416
417
|
/** Thread ID for appending tool results */
|
|
417
418
|
threadId: string;
|
|
418
|
-
/** Function to append tool results to the thread (called automatically after each handler)
|
|
419
|
+
/** Function to append tool results to the thread (called automatically after each handler).
|
|
420
|
+
* Accepts a Temporal activity proxy with {@link ActivityFunctionWithOptions}. */
|
|
419
421
|
appendToolResult: AppendToolResultFn;
|
|
420
422
|
/** Whether to process tools in parallel (default: true) */
|
|
421
423
|
parallel?: boolean;
|
package/dist/workflow.cjs
CHANGED
|
@@ -57,7 +57,10 @@ function createToolRouter(options) {
|
|
|
57
57
|
turn
|
|
58
58
|
});
|
|
59
59
|
if (r?.fallbackContent !== void 0)
|
|
60
|
-
return {
|
|
60
|
+
return {
|
|
61
|
+
content: r.fallbackContent,
|
|
62
|
+
result: { error: errorStr, recovered: true }
|
|
63
|
+
};
|
|
61
64
|
if (r?.suppress)
|
|
62
65
|
return {
|
|
63
66
|
content: JSON.stringify({ error: errorStr, suppressed: true }),
|
|
@@ -72,7 +75,10 @@ function createToolRouter(options) {
|
|
|
72
75
|
turn
|
|
73
76
|
});
|
|
74
77
|
if (r?.fallbackContent !== void 0)
|
|
75
|
-
return {
|
|
78
|
+
return {
|
|
79
|
+
content: r.fallbackContent,
|
|
80
|
+
result: { error: errorStr, recovered: true }
|
|
81
|
+
};
|
|
76
82
|
if (r?.suppress)
|
|
77
83
|
return {
|
|
78
84
|
content: JSON.stringify({ error: errorStr, suppressed: true }),
|
|
@@ -106,11 +112,14 @@ function createToolRouter(options) {
|
|
|
106
112
|
const tool = toolMap.get(toolCall.name);
|
|
107
113
|
const preResult = await runPreHooks(toolCall, tool, turn);
|
|
108
114
|
if (preResult.skip) {
|
|
109
|
-
await appendToolResult({
|
|
115
|
+
await appendToolResult(workflow.uuid4(), {
|
|
110
116
|
threadId: options.threadId,
|
|
111
117
|
toolCallId: toolCall.id,
|
|
112
118
|
toolName: toolCall.name,
|
|
113
|
-
content: JSON.stringify({
|
|
119
|
+
content: JSON.stringify({
|
|
120
|
+
skipped: true,
|
|
121
|
+
reason: "Skipped by PreToolUse hook"
|
|
122
|
+
})
|
|
114
123
|
});
|
|
115
124
|
return null;
|
|
116
125
|
}
|
|
@@ -138,24 +147,43 @@ function createToolRouter(options) {
|
|
|
138
147
|
content = JSON.stringify(result, null, 2);
|
|
139
148
|
}
|
|
140
149
|
} catch (error) {
|
|
141
|
-
const recovery = await runFailureHooks(
|
|
150
|
+
const recovery = await runFailureHooks(
|
|
151
|
+
toolCall,
|
|
152
|
+
tool,
|
|
153
|
+
error,
|
|
154
|
+
effectiveArgs,
|
|
155
|
+
turn
|
|
156
|
+
);
|
|
142
157
|
result = recovery.result;
|
|
143
158
|
content = recovery.content;
|
|
144
159
|
}
|
|
145
160
|
if (!resultAppended) {
|
|
146
|
-
|
|
161
|
+
const config = {
|
|
147
162
|
threadId: options.threadId,
|
|
148
163
|
toolCallId: toolCall.id,
|
|
149
164
|
toolName: toolCall.name,
|
|
150
165
|
content
|
|
151
|
-
}
|
|
166
|
+
};
|
|
167
|
+
await appendToolResult.executeWithOptions(
|
|
168
|
+
{
|
|
169
|
+
summary: `Append ${toolCall.name} result`
|
|
170
|
+
},
|
|
171
|
+
[workflow.uuid4(), config]
|
|
172
|
+
);
|
|
152
173
|
}
|
|
153
174
|
const toolResult = {
|
|
154
175
|
toolCallId: toolCall.id,
|
|
155
176
|
name: toolCall.name,
|
|
156
177
|
data: result
|
|
157
178
|
};
|
|
158
|
-
await runPostHooks(
|
|
179
|
+
await runPostHooks(
|
|
180
|
+
toolCall,
|
|
181
|
+
tool,
|
|
182
|
+
toolResult,
|
|
183
|
+
effectiveArgs,
|
|
184
|
+
turn,
|
|
185
|
+
Date.now() - startTime
|
|
186
|
+
);
|
|
159
187
|
return toolResult;
|
|
160
188
|
}
|
|
161
189
|
return {
|
|
@@ -198,9 +226,7 @@ function createToolRouter(options) {
|
|
|
198
226
|
const sandboxId = context?.sandboxId;
|
|
199
227
|
if (options.parallel) {
|
|
200
228
|
const results2 = await Promise.all(
|
|
201
|
-
toolCalls.map(
|
|
202
|
-
(tc) => processToolCall(tc, turn, sandboxId)
|
|
203
|
-
)
|
|
229
|
+
toolCalls.map((tc) => processToolCall(tc, turn, sandboxId))
|
|
204
230
|
);
|
|
205
231
|
return results2.filter(
|
|
206
232
|
(r) => r !== null
|
|
@@ -208,11 +234,7 @@ function createToolRouter(options) {
|
|
|
208
234
|
}
|
|
209
235
|
const results = [];
|
|
210
236
|
for (const toolCall of toolCalls) {
|
|
211
|
-
const result = await processToolCall(
|
|
212
|
-
toolCall,
|
|
213
|
-
turn,
|
|
214
|
-
sandboxId
|
|
215
|
-
);
|
|
237
|
+
const result = await processToolCall(toolCall, turn, sandboxId);
|
|
216
238
|
if (result !== null) {
|
|
217
239
|
results.push(result);
|
|
218
240
|
}
|
|
@@ -229,19 +251,29 @@ function createToolRouter(options) {
|
|
|
229
251
|
threadId: options.threadId,
|
|
230
252
|
toolCallId: toolCall.id,
|
|
231
253
|
toolName: toolCall.name,
|
|
232
|
-
...context?.sandboxId !== void 0 && {
|
|
254
|
+
...context?.sandboxId !== void 0 && {
|
|
255
|
+
sandboxId: context.sandboxId
|
|
256
|
+
}
|
|
233
257
|
};
|
|
234
258
|
const response = await handler(
|
|
235
259
|
toolCall.args,
|
|
236
260
|
routerContext
|
|
237
261
|
);
|
|
238
262
|
if (!response.resultAppended) {
|
|
239
|
-
await appendToolResult(
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
263
|
+
await appendToolResult.executeWithOptions(
|
|
264
|
+
{
|
|
265
|
+
summary: `Append ${toolCall.name} result`
|
|
266
|
+
},
|
|
267
|
+
[
|
|
268
|
+
workflow.uuid4(),
|
|
269
|
+
{
|
|
270
|
+
threadId: options.threadId,
|
|
271
|
+
toolCallId: toolCall.id,
|
|
272
|
+
toolName: toolCall.name,
|
|
273
|
+
content: response.toolResponse
|
|
274
|
+
}
|
|
275
|
+
]
|
|
276
|
+
);
|
|
245
277
|
}
|
|
246
278
|
return {
|
|
247
279
|
toolCallId: toolCall.id,
|
|
@@ -316,7 +348,7 @@ function createSubagentTool(subagents) {
|
|
|
316
348
|
const schema = hasThreadContinuation ? z14__default.default.object({
|
|
317
349
|
...baseFields,
|
|
318
350
|
threadId: z14__default.default.string().nullable().describe(
|
|
319
|
-
"Thread ID to continue an existing conversation, or null to start a new one"
|
|
351
|
+
"Thread ID to continue an existing conversation from the same subagent, or null to start a new one"
|
|
320
352
|
)
|
|
321
353
|
}) : z14__default.default.object(baseFields);
|
|
322
354
|
return {
|
|
@@ -373,7 +405,7 @@ function createSubagentHandler(subagents) {
|
|
|
373
405
|
if (config.allowThreadContinuation && childThreadId) {
|
|
374
406
|
finalToolResponse = typeof toolResponse === "string" ? `${toolResponse}
|
|
375
407
|
|
|
376
|
-
[Thread ID: ${childThreadId}]` : toolResponse;
|
|
408
|
+
[${config.agentName} Thread ID: ${childThreadId}]` : toolResponse;
|
|
377
409
|
}
|
|
378
410
|
return {
|
|
379
411
|
toolResponse: finalToolResponse,
|
|
@@ -469,8 +501,6 @@ function buildSkillRegistration(skills) {
|
|
|
469
501
|
handler: createReadSkillHandler(skills)
|
|
470
502
|
};
|
|
471
503
|
}
|
|
472
|
-
|
|
473
|
-
// src/lib/session/session.ts
|
|
474
504
|
var createSession = async ({
|
|
475
505
|
threadId: providedThreadId,
|
|
476
506
|
agentName,
|
|
@@ -540,7 +570,7 @@ var createSession = async ({
|
|
|
540
570
|
threadId
|
|
541
571
|
});
|
|
542
572
|
}
|
|
543
|
-
await appendHumanMessage(threadId, message);
|
|
573
|
+
await appendHumanMessage(threadId, workflow.uuid4(), message);
|
|
544
574
|
if (hooks.onPostHumanMessageAppend) {
|
|
545
575
|
await hooks.onPostHumanMessageAppend({
|
|
546
576
|
message,
|
|
@@ -577,12 +607,12 @@ var createSession = async ({
|
|
|
577
607
|
nonRetryable: true
|
|
578
608
|
});
|
|
579
609
|
}
|
|
580
|
-
await appendSystemMessage(threadId, systemPrompt);
|
|
610
|
+
await appendSystemMessage(threadId, workflow.uuid4(), systemPrompt);
|
|
581
611
|
} else {
|
|
582
612
|
await initializeThread(threadId);
|
|
583
613
|
}
|
|
584
614
|
}
|
|
585
|
-
await appendHumanMessage(threadId, await buildContextMessage());
|
|
615
|
+
await appendHumanMessage(threadId, workflow.uuid4(), await buildContextMessage());
|
|
586
616
|
let exitReason = "completed";
|
|
587
617
|
try {
|
|
588
618
|
while (stateManager.isRunning() && !stateManager.isTerminal() && stateManager.getTurns() < maxTurns) {
|
|
@@ -612,7 +642,7 @@ var createSession = async ({
|
|
|
612
642
|
try {
|
|
613
643
|
parsedToolCalls.push(toolRouter.parseToolCall(tc));
|
|
614
644
|
} catch (error) {
|
|
615
|
-
await appendToolResult({
|
|
645
|
+
await appendToolResult(workflow.uuid4(), {
|
|
616
646
|
threadId,
|
|
617
647
|
toolCallId: tc.id ?? "",
|
|
618
648
|
toolName: tc.name,
|
|
@@ -696,8 +726,8 @@ function proxySandboxOps(options) {
|
|
|
696
726
|
}
|
|
697
727
|
|
|
698
728
|
// src/lib/workflow.ts
|
|
699
|
-
function defineWorkflow(fn) {
|
|
700
|
-
|
|
729
|
+
function defineWorkflow(config, fn) {
|
|
730
|
+
const workflow = async (input, workflowInput = {}) => {
|
|
701
731
|
const sessionInput = {
|
|
702
732
|
...workflowInput.previousThreadId && {
|
|
703
733
|
threadId: workflowInput.previousThreadId,
|
|
@@ -707,6 +737,8 @@ function defineWorkflow(fn) {
|
|
|
707
737
|
};
|
|
708
738
|
return fn(input, sessionInput);
|
|
709
739
|
};
|
|
740
|
+
Object.defineProperty(workflow, "name", { value: config.name });
|
|
741
|
+
return workflow;
|
|
710
742
|
}
|
|
711
743
|
|
|
712
744
|
// src/lib/types.ts
|
|
@@ -1273,10 +1305,12 @@ var taskCreateTool = {
|
|
|
1273
1305
|
metadata: z14__default.default.record(z14__default.default.string(), z14__default.default.string()).describe("Arbitrary key-value pairs for tracking")
|
|
1274
1306
|
})
|
|
1275
1307
|
};
|
|
1308
|
+
|
|
1309
|
+
// src/tools/task-create/handler.ts
|
|
1276
1310
|
function createTaskCreateHandler(stateManager) {
|
|
1277
1311
|
return (args) => {
|
|
1278
1312
|
const task = {
|
|
1279
|
-
id:
|
|
1313
|
+
id: getShortId(),
|
|
1280
1314
|
subject: args.subject,
|
|
1281
1315
|
description: args.description,
|
|
1282
1316
|
activeForm: args.activeForm,
|