zeitlich 0.2.20 → 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.
Files changed (46) hide show
  1. package/dist/adapters/sandbox/virtual/index.d.cts +3 -3
  2. package/dist/adapters/sandbox/virtual/index.d.ts +3 -3
  3. package/dist/adapters/thread/google-genai/index.cjs +70 -23
  4. package/dist/adapters/thread/google-genai/index.cjs.map +1 -1
  5. package/dist/adapters/thread/google-genai/index.d.cts +10 -10
  6. package/dist/adapters/thread/google-genai/index.d.ts +10 -10
  7. package/dist/adapters/thread/google-genai/index.js +70 -23
  8. package/dist/adapters/thread/google-genai/index.js.map +1 -1
  9. package/dist/adapters/thread/langchain/index.cjs +75 -70
  10. package/dist/adapters/thread/langchain/index.cjs.map +1 -1
  11. package/dist/adapters/thread/langchain/index.d.cts +10 -10
  12. package/dist/adapters/thread/langchain/index.d.ts +10 -10
  13. package/dist/adapters/thread/langchain/index.js +75 -70
  14. package/dist/adapters/thread/langchain/index.js.map +1 -1
  15. package/dist/index.cjs +54 -9
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +6 -6
  18. package/dist/index.d.ts +6 -6
  19. package/dist/index.js +54 -9
  20. package/dist/index.js.map +1 -1
  21. package/dist/{queries-KHj5Otv7.d.ts → queries-6Avfh74U.d.ts} +1 -1
  22. package/dist/{queries-nIdzTCDS.d.cts → queries-CHa2iv_I.d.cts} +1 -1
  23. package/dist/{types-By80IE1x.d.ts → types-BkAYmc96.d.ts} +4 -4
  24. package/dist/{types-DZ7BkA3-.d.cts → types-CES_30qx.d.cts} +4 -4
  25. package/dist/{types-Ct2igz9y.d.ts → types-YbL7JpEA.d.cts} +1 -1
  26. package/dist/{types-Ct2igz9y.d.cts → types-YbL7JpEA.d.ts} +1 -1
  27. package/dist/workflow.cjs +7 -8
  28. package/dist/workflow.cjs.map +1 -1
  29. package/dist/workflow.d.cts +6 -6
  30. package/dist/workflow.d.ts +6 -6
  31. package/dist/workflow.js +7 -8
  32. package/dist/workflow.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/adapters/thread/google-genai/activities.ts +11 -9
  35. package/src/adapters/thread/google-genai/model-invoker.ts +6 -11
  36. package/src/adapters/thread/google-genai/thread-manager.ts +44 -29
  37. package/src/adapters/thread/langchain/activities.ts +6 -4
  38. package/src/adapters/thread/langchain/thread-manager.ts +46 -22
  39. package/src/lib/session/session.ts +5 -4
  40. package/src/lib/session/types.ts +7 -2
  41. package/src/lib/tool-router/auto-append-sandbox.integration.test.ts +20 -21
  42. package/src/lib/tool-router/auto-append.ts +3 -2
  43. package/src/lib/tool-router/router-edge-cases.integration.test.ts +59 -23
  44. package/src/lib/tool-router/router.integration.test.ts +55 -23
  45. package/src/lib/tool-router/router.ts +4 -3
  46. package/src/lib/tool-router/types.ts +1 -1
@@ -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-Ct2igz9y.js';
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-Ct2igz9y.cjs';
2
+ import { R as RouterContext } from './types-YbL7JpEA.cjs';
3
3
 
4
4
  /**
5
5
  * Ephemeral {@link SandboxFileSystem} backed by a {@link FileResolver}.
@@ -1,5 +1,5 @@
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-Ct2igz9y.js';
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
5
  import { QueryDefinition, ActivityInterfaceFor } from '@temporalio/workflow';
@@ -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
  }
@@ -1,5 +1,5 @@
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-Ct2igz9y.cjs';
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
5
  import { QueryDefinition, ActivityInterfaceFor } from '@temporalio/workflow';
@@ -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
  }
@@ -200,7 +200,7 @@ type ParsedToolCallUnion<T extends ToolMap> = {
200
200
  /**
201
201
  * Function signature for appending tool results to a thread.
202
202
  */
203
- type AppendToolResultFn = ActivityFunctionWithOptions<(config: ToolResultConfig) => Promise<void>>;
203
+ type AppendToolResultFn = ActivityFunctionWithOptions<(id: string, config: ToolResultConfig) => Promise<void>>;
204
204
  /**
205
205
  * The response from a tool handler.
206
206
  * Contains the content for the tool message and the result to return from processToolCalls.
@@ -200,7 +200,7 @@ type ParsedToolCallUnion<T extends ToolMap> = {
200
200
  /**
201
201
  * Function signature for appending tool results to a thread.
202
202
  */
203
- type AppendToolResultFn = ActivityFunctionWithOptions<(config: ToolResultConfig) => Promise<void>>;
203
+ type AppendToolResultFn = ActivityFunctionWithOptions<(id: string, config: ToolResultConfig) => Promise<void>>;
204
204
  /**
205
205
  * The response from a tool handler.
206
206
  * Contains the content for the tool message and the result to return from processToolCalls.
package/dist/workflow.cjs CHANGED
@@ -112,7 +112,7 @@ function createToolRouter(options) {
112
112
  const tool = toolMap.get(toolCall.name);
113
113
  const preResult = await runPreHooks(toolCall, tool, turn);
114
114
  if (preResult.skip) {
115
- await appendToolResult({
115
+ await appendToolResult(workflow.uuid4(), {
116
116
  threadId: options.threadId,
117
117
  toolCallId: toolCall.id,
118
118
  toolName: toolCall.name,
@@ -168,7 +168,7 @@ function createToolRouter(options) {
168
168
  {
169
169
  summary: `Append ${toolCall.name} result`
170
170
  },
171
- [config]
171
+ [workflow.uuid4(), config]
172
172
  );
173
173
  }
174
174
  const toolResult = {
@@ -265,6 +265,7 @@ function createToolRouter(options) {
265
265
  summary: `Append ${toolCall.name} result`
266
266
  },
267
267
  [
268
+ workflow.uuid4(),
268
269
  {
269
270
  threadId: options.threadId,
270
271
  toolCallId: toolCall.id,
@@ -500,8 +501,6 @@ function buildSkillRegistration(skills) {
500
501
  handler: createReadSkillHandler(skills)
501
502
  };
502
503
  }
503
-
504
- // src/lib/session/session.ts
505
504
  var createSession = async ({
506
505
  threadId: providedThreadId,
507
506
  agentName,
@@ -571,7 +570,7 @@ var createSession = async ({
571
570
  threadId
572
571
  });
573
572
  }
574
- await appendHumanMessage(threadId, message);
573
+ await appendHumanMessage(threadId, workflow.uuid4(), message);
575
574
  if (hooks.onPostHumanMessageAppend) {
576
575
  await hooks.onPostHumanMessageAppend({
577
576
  message,
@@ -608,12 +607,12 @@ var createSession = async ({
608
607
  nonRetryable: true
609
608
  });
610
609
  }
611
- await appendSystemMessage(threadId, systemPrompt);
610
+ await appendSystemMessage(threadId, workflow.uuid4(), systemPrompt);
612
611
  } else {
613
612
  await initializeThread(threadId);
614
613
  }
615
614
  }
616
- await appendHumanMessage(threadId, await buildContextMessage());
615
+ await appendHumanMessage(threadId, workflow.uuid4(), await buildContextMessage());
617
616
  let exitReason = "completed";
618
617
  try {
619
618
  while (stateManager.isRunning() && !stateManager.isTerminal() && stateManager.getTurns() < maxTurns) {
@@ -643,7 +642,7 @@ var createSession = async ({
643
642
  try {
644
643
  parsedToolCalls.push(toolRouter.parseToolCall(tc));
645
644
  } catch (error) {
646
- await appendToolResult({
645
+ await appendToolResult(workflow.uuid4(), {
647
646
  threadId,
648
647
  toolCallId: tc.id ?? "",
649
648
  toolName: tc.name,