zeitlich 0.2.19 → 0.2.20
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 +0 -2
- package/dist/adapters/thread/google-genai/index.cjs.map +1 -1
- package/dist/adapters/thread/google-genai/index.d.cts +2 -2
- package/dist/adapters/thread/google-genai/index.d.ts +2 -2
- package/dist/adapters/thread/google-genai/index.js +0 -2
- package/dist/adapters/thread/google-genai/index.js.map +1 -1
- package/dist/adapters/thread/langchain/index.cjs +3 -1
- package/dist/adapters/thread/langchain/index.cjs.map +1 -1
- package/dist/adapters/thread/langchain/index.d.cts +3 -3
- package/dist/adapters/thread/langchain/index.d.ts +3 -3
- package/dist/adapters/thread/langchain/index.js +3 -1
- package/dist/adapters/thread/langchain/index.js.map +1 -1
- package/dist/index.cjs +145 -110
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.js +145 -110
- package/dist/index.js.map +1 -1
- package/dist/{queries-D8T4pEeu.d.ts → queries-KHj5Otv7.d.ts} +1 -1
- package/dist/{queries-D22uWTOb.d.cts → queries-nIdzTCDS.d.cts} +1 -1
- package/dist/{types-CxWLeJTB.d.ts → types-By80IE1x.d.ts} +3 -3
- package/dist/{types-DjT78Sdp.d.cts → types-Ct2igz9y.d.cts} +4 -2
- package/dist/{types-DjT78Sdp.d.ts → types-Ct2igz9y.d.ts} +4 -2
- package/dist/{types-CCfJb5Jl.d.cts → types-DZ7BkA3-.d.cts} +3 -3
- package/dist/workflow.cjs +62 -27
- 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 +62 -27
- 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/langchain/thread-manager.ts +11 -7
- 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 +2 -1
- package/src/lib/session/types.ts +2 -1
- 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/router-edge-cases.integration.test.ts +8 -3
- package/src/lib/tool-router/router.integration.test.ts +8 -3
- package/src/lib/tool-router/router.ts +55 -27
- 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-Ct2igz9y.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-Ct2igz9y.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-Ct2igz9y.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
|
/**
|
|
@@ -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<(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<(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,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-Ct2igz9y.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
|
/**
|
|
@@ -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 */
|
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 }),
|
|
@@ -110,7 +116,10 @@ function createToolRouter(options) {
|
|
|
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
|
+
[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,28 @@ 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
|
+
{
|
|
269
|
+
threadId: options.threadId,
|
|
270
|
+
toolCallId: toolCall.id,
|
|
271
|
+
toolName: toolCall.name,
|
|
272
|
+
content: response.toolResponse
|
|
273
|
+
}
|
|
274
|
+
]
|
|
275
|
+
);
|
|
245
276
|
}
|
|
246
277
|
return {
|
|
247
278
|
toolCallId: toolCall.id,
|
|
@@ -316,7 +347,7 @@ function createSubagentTool(subagents) {
|
|
|
316
347
|
const schema = hasThreadContinuation ? z14__default.default.object({
|
|
317
348
|
...baseFields,
|
|
318
349
|
threadId: z14__default.default.string().nullable().describe(
|
|
319
|
-
"Thread ID to continue an existing conversation, or null to start a new one"
|
|
350
|
+
"Thread ID to continue an existing conversation from the same subagent, or null to start a new one"
|
|
320
351
|
)
|
|
321
352
|
}) : z14__default.default.object(baseFields);
|
|
322
353
|
return {
|
|
@@ -373,7 +404,7 @@ function createSubagentHandler(subagents) {
|
|
|
373
404
|
if (config.allowThreadContinuation && childThreadId) {
|
|
374
405
|
finalToolResponse = typeof toolResponse === "string" ? `${toolResponse}
|
|
375
406
|
|
|
376
|
-
[Thread ID: ${childThreadId}]` : toolResponse;
|
|
407
|
+
[${config.agentName} Thread ID: ${childThreadId}]` : toolResponse;
|
|
377
408
|
}
|
|
378
409
|
return {
|
|
379
410
|
toolResponse: finalToolResponse,
|
|
@@ -696,8 +727,8 @@ function proxySandboxOps(options) {
|
|
|
696
727
|
}
|
|
697
728
|
|
|
698
729
|
// src/lib/workflow.ts
|
|
699
|
-
function defineWorkflow(fn) {
|
|
700
|
-
|
|
730
|
+
function defineWorkflow(config, fn) {
|
|
731
|
+
const workflow = async (input, workflowInput = {}) => {
|
|
701
732
|
const sessionInput = {
|
|
702
733
|
...workflowInput.previousThreadId && {
|
|
703
734
|
threadId: workflowInput.previousThreadId,
|
|
@@ -707,6 +738,8 @@ function defineWorkflow(fn) {
|
|
|
707
738
|
};
|
|
708
739
|
return fn(input, sessionInput);
|
|
709
740
|
};
|
|
741
|
+
Object.defineProperty(workflow, "name", { value: config.name });
|
|
742
|
+
return workflow;
|
|
710
743
|
}
|
|
711
744
|
|
|
712
745
|
// src/lib/types.ts
|
|
@@ -1273,10 +1306,12 @@ var taskCreateTool = {
|
|
|
1273
1306
|
metadata: z14__default.default.record(z14__default.default.string(), z14__default.default.string()).describe("Arbitrary key-value pairs for tracking")
|
|
1274
1307
|
})
|
|
1275
1308
|
};
|
|
1309
|
+
|
|
1310
|
+
// src/tools/task-create/handler.ts
|
|
1276
1311
|
function createTaskCreateHandler(stateManager) {
|
|
1277
1312
|
return (args) => {
|
|
1278
1313
|
const task = {
|
|
1279
|
-
id:
|
|
1314
|
+
id: getShortId(),
|
|
1280
1315
|
subject: args.subject,
|
|
1281
1316
|
description: args.description,
|
|
1282
1317
|
activeForm: args.activeForm,
|