zeitlich 0.2.5 → 0.2.7
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/index.cjs +142 -97
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -11
- package/dist/index.d.ts +4 -11
- package/dist/index.js +121 -75
- package/dist/index.js.map +1 -1
- package/dist/{workflow-Dg5JMeOC.d.cts → workflow-CyYHDbrr.d.cts} +86 -26
- package/dist/{workflow-Dg5JMeOC.d.ts → workflow-CyYHDbrr.d.ts} +86 -26
- package/dist/workflow.cjs +132 -82
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +1 -1
- package/dist/workflow.d.ts +1 -1
- package/dist/workflow.js +109 -60
- package/dist/workflow.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +0 -2
- package/src/lib/model-invoker.ts +2 -3
- package/src/lib/session.ts +42 -5
- package/src/lib/state-manager.ts +28 -7
- package/src/lib/thread-manager.ts +13 -0
- package/src/lib/types.ts +56 -3
- package/src/tools/ask-user-question/handler.ts +19 -20
- package/src/workflow.ts +5 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { A as AgentResponse, a as ActivityToolHandler,
|
|
2
|
-
export {
|
|
1
|
+
import { A as AgentResponse, a as ActivityToolHandler, G as GlobArgs, F as FileEditArgs, B as BashArgs } from './workflow-CyYHDbrr.cjs';
|
|
2
|
+
export { b as AGENT_HANDLER_NAMES, c as AgentConfig, d as AgentFile, e as AgentState, f as AgentStateManager, g as AgentStatus, h as AppendToolResultFn, i as AskUserQuestionArgs, j as BaseAgentState, k as BaseThreadManager, l as FileReadArgs, m as FileWriteArgs, n as GrepArgs, I as InferToolResults, J as JsonPrimitive, o as JsonSerializable, p as JsonValue, P as ParsedToolCall, q as ParsedToolCallUnion, r as PostToolUseFailureHook, s as PostToolUseFailureHookContext, t as PostToolUseFailureHookResult, u as PostToolUseHook, v as PostToolUseHookContext, w as PreToolUseHook, x as PreToolUseHookContext, y as PreToolUseHookResult, z as ProcessToolCallsContext, R as RawToolCall, C as RunAgentActivity, D as RunAgentConfig, S as SessionEndHook, E as SessionEndHookContext, H as SessionExitReason, K as SessionLifecycleHooks, L as SessionStartHook, M as SessionStartHookContext, N as SubagentArgs, O as SubagentConfig, Q as SubagentHooks, T as SubagentInput, U as TaskCreateArgs, V as TaskGetArgs, W as TaskListArgs, X as TaskStatus, Y as TaskUpdateArgs, Z as ThreadManager, _ as ThreadManagerConfig, $ as ThreadOps, a0 as ToolArgs, a1 as ToolCallResult, a2 as ToolCallResultUnion, a3 as ToolDefinition, a4 as ToolHandler, a5 as ToolHandlerContext, a6 as ToolHandlerResponse, a7 as ToolHooks, a8 as ToolMap, a9 as ToolMessageContent, aa as ToolNames, ab as ToolResult, ac as ToolResultConfig, ad as ToolRouter, ae as ToolWithHandler, af as WorkflowTask, ag as ZeitlichSession, ah as ZeitlichSharedActivities, ai as askUserQuestionTool, aj as bashTool, ak as createAgentStateManager, al as createAskUserQuestionHandler, am as createBashToolDescription, an as createSession, ao as createSharedActivities, ap as createSubagentTool, aq as createTaskCreateHandler, ar as createTaskGetHandler, as as createTaskListHandler, at as createTaskUpdateHandler, au as createThreadManager, av as createToolRouter, aw as defineSubagent, ax as defineTool, ay as editTool, az as globTool, aA as grepTool, aB as hasNoOtherToolCalls, aC as isTerminalStatus, aD as proxyDefaultThreadOps, aE as readTool, aF as taskCreateTool, aG as taskGetTool, aH as taskListTool, aI as taskUpdateTool, aJ as withAutoAppend, aK as writeTool } from './workflow-CyYHDbrr.cjs';
|
|
3
3
|
import { SimplePlugin } from '@temporalio/plugin';
|
|
4
4
|
import Redis from 'ioredis';
|
|
5
5
|
import { WorkflowClient } from '@temporalio/client';
|
|
6
6
|
import { BaseChatModel, BaseChatModelCallOptions, BindToolsInput } from '@langchain/core/language_models/chat_models';
|
|
7
|
-
import { StoredMessage } from '@langchain/core/messages';
|
|
8
7
|
import { IFileSystem, BashOptions } from 'just-bash';
|
|
9
8
|
import '@temporalio/workflow';
|
|
9
|
+
import '@langchain/core/messages';
|
|
10
10
|
import 'zod';
|
|
11
11
|
import '@temporalio/common';
|
|
12
12
|
|
|
@@ -55,13 +55,6 @@ declare function invokeModel({ redis, model, client, config: { threadId, agentNa
|
|
|
55
55
|
}>;
|
|
56
56
|
}): Promise<AgentResponse>;
|
|
57
57
|
|
|
58
|
-
/**
|
|
59
|
-
* Creates handler for user interaction tool - creates AI messages for display.
|
|
60
|
-
*/
|
|
61
|
-
declare const createAskUserQuestionHandler: () => ActivityToolHandler<AskUserQuestionArgs, {
|
|
62
|
-
chatMessages: StoredMessage[];
|
|
63
|
-
}>;
|
|
64
|
-
|
|
65
58
|
/**
|
|
66
59
|
* Result of a glob operation
|
|
67
60
|
*/
|
|
@@ -109,4 +102,4 @@ declare const toTree: (fs: IFileSystem, opts?: {
|
|
|
109
102
|
sort?: boolean;
|
|
110
103
|
}) => Promise<string>;
|
|
111
104
|
|
|
112
|
-
export { ActivityToolHandler, AgentResponse,
|
|
105
|
+
export { ActivityToolHandler, AgentResponse, BashArgs, FileEditArgs, GlobArgs, type InvokeModelConfig, ZeitlichPlugin, type ZeitlichPluginOptions, createBashHandler, createEditHandler, createGlobHandler, invokeModel, toTree };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { A as AgentResponse, a as ActivityToolHandler,
|
|
2
|
-
export {
|
|
1
|
+
import { A as AgentResponse, a as ActivityToolHandler, G as GlobArgs, F as FileEditArgs, B as BashArgs } from './workflow-CyYHDbrr.js';
|
|
2
|
+
export { b as AGENT_HANDLER_NAMES, c as AgentConfig, d as AgentFile, e as AgentState, f as AgentStateManager, g as AgentStatus, h as AppendToolResultFn, i as AskUserQuestionArgs, j as BaseAgentState, k as BaseThreadManager, l as FileReadArgs, m as FileWriteArgs, n as GrepArgs, I as InferToolResults, J as JsonPrimitive, o as JsonSerializable, p as JsonValue, P as ParsedToolCall, q as ParsedToolCallUnion, r as PostToolUseFailureHook, s as PostToolUseFailureHookContext, t as PostToolUseFailureHookResult, u as PostToolUseHook, v as PostToolUseHookContext, w as PreToolUseHook, x as PreToolUseHookContext, y as PreToolUseHookResult, z as ProcessToolCallsContext, R as RawToolCall, C as RunAgentActivity, D as RunAgentConfig, S as SessionEndHook, E as SessionEndHookContext, H as SessionExitReason, K as SessionLifecycleHooks, L as SessionStartHook, M as SessionStartHookContext, N as SubagentArgs, O as SubagentConfig, Q as SubagentHooks, T as SubagentInput, U as TaskCreateArgs, V as TaskGetArgs, W as TaskListArgs, X as TaskStatus, Y as TaskUpdateArgs, Z as ThreadManager, _ as ThreadManagerConfig, $ as ThreadOps, a0 as ToolArgs, a1 as ToolCallResult, a2 as ToolCallResultUnion, a3 as ToolDefinition, a4 as ToolHandler, a5 as ToolHandlerContext, a6 as ToolHandlerResponse, a7 as ToolHooks, a8 as ToolMap, a9 as ToolMessageContent, aa as ToolNames, ab as ToolResult, ac as ToolResultConfig, ad as ToolRouter, ae as ToolWithHandler, af as WorkflowTask, ag as ZeitlichSession, ah as ZeitlichSharedActivities, ai as askUserQuestionTool, aj as bashTool, ak as createAgentStateManager, al as createAskUserQuestionHandler, am as createBashToolDescription, an as createSession, ao as createSharedActivities, ap as createSubagentTool, aq as createTaskCreateHandler, ar as createTaskGetHandler, as as createTaskListHandler, at as createTaskUpdateHandler, au as createThreadManager, av as createToolRouter, aw as defineSubagent, ax as defineTool, ay as editTool, az as globTool, aA as grepTool, aB as hasNoOtherToolCalls, aC as isTerminalStatus, aD as proxyDefaultThreadOps, aE as readTool, aF as taskCreateTool, aG as taskGetTool, aH as taskListTool, aI as taskUpdateTool, aJ as withAutoAppend, aK as writeTool } from './workflow-CyYHDbrr.js';
|
|
3
3
|
import { SimplePlugin } from '@temporalio/plugin';
|
|
4
4
|
import Redis from 'ioredis';
|
|
5
5
|
import { WorkflowClient } from '@temporalio/client';
|
|
6
6
|
import { BaseChatModel, BaseChatModelCallOptions, BindToolsInput } from '@langchain/core/language_models/chat_models';
|
|
7
|
-
import { StoredMessage } from '@langchain/core/messages';
|
|
8
7
|
import { IFileSystem, BashOptions } from 'just-bash';
|
|
9
8
|
import '@temporalio/workflow';
|
|
9
|
+
import '@langchain/core/messages';
|
|
10
10
|
import 'zod';
|
|
11
11
|
import '@temporalio/common';
|
|
12
12
|
|
|
@@ -55,13 +55,6 @@ declare function invokeModel({ redis, model, client, config: { threadId, agentNa
|
|
|
55
55
|
}>;
|
|
56
56
|
}): Promise<AgentResponse>;
|
|
57
57
|
|
|
58
|
-
/**
|
|
59
|
-
* Creates handler for user interaction tool - creates AI messages for display.
|
|
60
|
-
*/
|
|
61
|
-
declare const createAskUserQuestionHandler: () => ActivityToolHandler<AskUserQuestionArgs, {
|
|
62
|
-
chatMessages: StoredMessage[];
|
|
63
|
-
}>;
|
|
64
|
-
|
|
65
58
|
/**
|
|
66
59
|
* Result of a glob operation
|
|
67
60
|
*/
|
|
@@ -109,4 +102,4 @@ declare const toTree: (fs: IFileSystem, opts?: {
|
|
|
109
102
|
sort?: boolean;
|
|
110
103
|
}) => Promise<string>;
|
|
111
104
|
|
|
112
|
-
export { ActivityToolHandler, AgentResponse,
|
|
105
|
+
export { ActivityToolHandler, AgentResponse, BashArgs, FileEditArgs, GlobArgs, type InvokeModelConfig, ZeitlichPlugin, type ZeitlichPluginOptions, createBashHandler, createEditHandler, createGlobHandler, invokeModel, toTree };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { setHandler, defineUpdate, condition, proxyActivities, defineQuery, uuid4, workflowInfo, executeChild } from '@temporalio/workflow';
|
|
2
|
+
import z13, { z } from 'zod';
|
|
3
3
|
import { SimplePlugin } from '@temporalio/plugin';
|
|
4
|
-
import { mapStoredMessagesToChatMessages, AIMessage,
|
|
4
|
+
import { mapStoredMessagesToChatMessages, ToolMessage, AIMessage, SystemMessage, HumanMessage } from '@langchain/core/messages';
|
|
5
5
|
import crypto from 'crypto';
|
|
6
6
|
import { Context } from '@temporalio/activity';
|
|
7
7
|
import { Bash } from 'just-bash';
|
|
@@ -39,10 +39,10 @@ function createSubagentTool(subagents) {
|
|
|
39
39
|
return {
|
|
40
40
|
name: SUBAGENT_TOOL,
|
|
41
41
|
description: buildSubagentDescription(subagents),
|
|
42
|
-
schema:
|
|
43
|
-
subagent:
|
|
44
|
-
description:
|
|
45
|
-
prompt:
|
|
42
|
+
schema: z13.object({
|
|
43
|
+
subagent: z13.enum(names).describe("The type of subagent to launch"),
|
|
44
|
+
description: z13.string().describe("A short (3-5 word) description of the task"),
|
|
45
|
+
prompt: z13.string().describe("The task for the agent to perform")
|
|
46
46
|
})
|
|
47
47
|
};
|
|
48
48
|
}
|
|
@@ -414,7 +414,8 @@ var createSession = async ({
|
|
|
414
414
|
processToolsInParallel = true,
|
|
415
415
|
hooks = {},
|
|
416
416
|
appendSystemPrompt = true,
|
|
417
|
-
systemPrompt
|
|
417
|
+
systemPrompt,
|
|
418
|
+
waitForInputTimeout = "48h"
|
|
418
419
|
}) => {
|
|
419
420
|
const {
|
|
420
421
|
appendToolResult,
|
|
@@ -443,6 +444,25 @@ var createSession = async ({
|
|
|
443
444
|
};
|
|
444
445
|
return {
|
|
445
446
|
runSession: async ({ stateManager }) => {
|
|
447
|
+
setHandler(
|
|
448
|
+
defineUpdate(`add${agentName}Message`),
|
|
449
|
+
async (message) => {
|
|
450
|
+
if (hooks.onPreHumanMessageAppend) {
|
|
451
|
+
await hooks.onPreHumanMessageAppend({
|
|
452
|
+
message,
|
|
453
|
+
threadId
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
await appendHumanMessage(threadId, message);
|
|
457
|
+
if (hooks.onPostHumanMessageAppend) {
|
|
458
|
+
await hooks.onPostHumanMessageAppend({
|
|
459
|
+
message,
|
|
460
|
+
threadId
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
stateManager.run();
|
|
464
|
+
}
|
|
465
|
+
);
|
|
446
466
|
if (hooks.onSessionStart) {
|
|
447
467
|
await hooks.onSessionStart({
|
|
448
468
|
threadId,
|
|
@@ -490,8 +510,15 @@ var createSession = async ({
|
|
|
490
510
|
turn: currentTurn
|
|
491
511
|
});
|
|
492
512
|
if (stateManager.getStatus() === "WAITING_FOR_INPUT") {
|
|
493
|
-
|
|
494
|
-
|
|
513
|
+
const conditionMet = await condition(
|
|
514
|
+
() => stateManager.getStatus() === "RUNNING",
|
|
515
|
+
waitForInputTimeout
|
|
516
|
+
);
|
|
517
|
+
if (!conditionMet) {
|
|
518
|
+
stateManager.cancel();
|
|
519
|
+
await condition(() => false, "2s");
|
|
520
|
+
break;
|
|
521
|
+
}
|
|
495
522
|
}
|
|
496
523
|
}
|
|
497
524
|
if (stateManager.getTurns() >= maxTurns && stateManager.isRunning()) {
|
|
@@ -532,8 +559,10 @@ function proxyDefaultThreadOps(options) {
|
|
|
532
559
|
function isTerminalStatus(status) {
|
|
533
560
|
return status === "COMPLETED" || status === "FAILED" || status === "CANCELLED";
|
|
534
561
|
}
|
|
535
|
-
|
|
536
|
-
|
|
562
|
+
function createAgentStateManager({
|
|
563
|
+
initialState,
|
|
564
|
+
agentConfig
|
|
565
|
+
}) {
|
|
537
566
|
let status = initialState?.status ?? "RUNNING";
|
|
538
567
|
let version = initialState?.version ?? 0;
|
|
539
568
|
let turns = initialState?.turns ?? 0;
|
|
@@ -557,9 +586,21 @@ function createAgentStateManager(initialState) {
|
|
|
557
586
|
...customState
|
|
558
587
|
};
|
|
559
588
|
}
|
|
560
|
-
setHandler(
|
|
589
|
+
setHandler(defineQuery(`get${agentConfig.agentName}State`), () => {
|
|
561
590
|
return buildState();
|
|
562
591
|
});
|
|
592
|
+
setHandler(
|
|
593
|
+
defineUpdate(
|
|
594
|
+
`waitFor${agentConfig.agentName}StateChange`
|
|
595
|
+
),
|
|
596
|
+
async (lastKnownVersion) => {
|
|
597
|
+
await condition(
|
|
598
|
+
() => version > lastKnownVersion || isTerminalStatus(status),
|
|
599
|
+
"55s"
|
|
600
|
+
);
|
|
601
|
+
return buildState();
|
|
602
|
+
}
|
|
603
|
+
);
|
|
563
604
|
return {
|
|
564
605
|
getStatus() {
|
|
565
606
|
return status;
|
|
@@ -648,38 +689,6 @@ var AGENT_HANDLER_NAMES = {
|
|
|
648
689
|
waitForStateChange: "waitForStateChange",
|
|
649
690
|
addMessage: "addMessage"
|
|
650
691
|
};
|
|
651
|
-
var askUserQuestionTool = {
|
|
652
|
-
name: "AskUserQuestion",
|
|
653
|
-
description: `Use this tool when you need to ask the user questions during execution. This allows you to:
|
|
654
|
-
|
|
655
|
-
1. Gather user preferences or requirements
|
|
656
|
-
2. Clarify ambiguous instructions
|
|
657
|
-
3. Get decisions on implementation choices as you work
|
|
658
|
-
4. Offer choices to the user about what direction to take.
|
|
659
|
-
|
|
660
|
-
Usage notes:
|
|
661
|
-
|
|
662
|
-
* Users will always be able to select "Other" to provide custom text input
|
|
663
|
-
* Use multiSelect: true to allow multiple answers to be selected for a question
|
|
664
|
-
* If you recommend a specific option, make that the first option in the list and add "(Recommended)" at the end of the label
|
|
665
|
-
`,
|
|
666
|
-
schema: z3.object({
|
|
667
|
-
questions: z3.array(
|
|
668
|
-
z3.object({
|
|
669
|
-
question: z3.string().describe("The full question text to display"),
|
|
670
|
-
header: z3.string().describe("Short label for the question (max 12 characters)"),
|
|
671
|
-
options: z3.array(
|
|
672
|
-
z3.object({
|
|
673
|
-
label: z3.string(),
|
|
674
|
-
description: z3.string()
|
|
675
|
-
})
|
|
676
|
-
).min(0).max(4).describe("Array of 0-4 choices, each with label and description"),
|
|
677
|
-
multiSelect: z3.boolean().describe("If true, users can select multiple options")
|
|
678
|
-
})
|
|
679
|
-
)
|
|
680
|
-
}),
|
|
681
|
-
strict: true
|
|
682
|
-
};
|
|
683
692
|
var globTool = {
|
|
684
693
|
name: "Glob",
|
|
685
694
|
description: `Search for files matching a glob pattern within the available file system.
|
|
@@ -836,17 +845,17 @@ var taskCreateTool = {
|
|
|
836
845
|
- Include enough detail in the description for another agent to understand and complete the task
|
|
837
846
|
- After creating tasks, use TaskUpdate to set up dependencies (blocks/blockedBy) if needed
|
|
838
847
|
- Check TaskList first to avoid creating duplicate tasks`,
|
|
839
|
-
schema:
|
|
840
|
-
subject:
|
|
848
|
+
schema: z13.object({
|
|
849
|
+
subject: z13.string().describe(
|
|
841
850
|
'A brief, actionable title in imperative form (e.g., "Fix authentication bug in login flow")'
|
|
842
851
|
),
|
|
843
|
-
description:
|
|
852
|
+
description: z13.string().describe(
|
|
844
853
|
"Detailed description of what needs to be done, including context and acceptance criteria"
|
|
845
854
|
),
|
|
846
|
-
activeForm:
|
|
855
|
+
activeForm: z13.string().describe(
|
|
847
856
|
'Present continuous form shown in spinner when task is in_progress (e.g., "Fixing authentication bug"). This is displayed to the user while you work on the task.'
|
|
848
857
|
),
|
|
849
|
-
metadata:
|
|
858
|
+
metadata: z13.record(z13.string(), z13.string()).describe("Arbitrary key-value pairs for tracking")
|
|
850
859
|
})
|
|
851
860
|
};
|
|
852
861
|
function createTaskCreateHandler(stateManager) {
|
|
@@ -871,8 +880,8 @@ function createTaskCreateHandler(stateManager) {
|
|
|
871
880
|
var taskGetTool = {
|
|
872
881
|
name: "TaskGet",
|
|
873
882
|
description: `Retrieve full task details including dependencies.`,
|
|
874
|
-
schema:
|
|
875
|
-
taskId:
|
|
883
|
+
schema: z13.object({
|
|
884
|
+
taskId: z13.string().describe("The ID of the task to get")
|
|
876
885
|
})
|
|
877
886
|
};
|
|
878
887
|
|
|
@@ -895,7 +904,7 @@ function createTaskGetHandler(stateManager) {
|
|
|
895
904
|
var taskListTool = {
|
|
896
905
|
name: "TaskList",
|
|
897
906
|
description: `List all tasks with current state.`,
|
|
898
|
-
schema:
|
|
907
|
+
schema: z13.object({})
|
|
899
908
|
};
|
|
900
909
|
|
|
901
910
|
// src/tools/task-list/handler.ts
|
|
@@ -911,11 +920,11 @@ function createTaskListHandler(stateManager) {
|
|
|
911
920
|
var taskUpdateTool = {
|
|
912
921
|
name: "TaskUpdate",
|
|
913
922
|
description: `Update status, add blockers, modify details.`,
|
|
914
|
-
schema:
|
|
915
|
-
taskId:
|
|
916
|
-
status:
|
|
917
|
-
addBlockedBy:
|
|
918
|
-
addBlocks:
|
|
923
|
+
schema: z13.object({
|
|
924
|
+
taskId: z13.string().describe("The ID of the task to get"),
|
|
925
|
+
status: z13.enum(["pending", "in_progress", "completed"]).describe("The status of the task"),
|
|
926
|
+
addBlockedBy: z13.array(z13.string()).describe("The IDs of the tasks that are blocking this task"),
|
|
927
|
+
addBlocks: z13.array(z13.string()).describe("The IDs of the tasks that this task is blocking")
|
|
919
928
|
})
|
|
920
929
|
};
|
|
921
930
|
|
|
@@ -983,13 +992,53 @@ Use this tool to:
|
|
|
983
992
|
- Execute scripts and chain commands with pipes (|) or logical operators (&&, ||)
|
|
984
993
|
- Inspect files and directories
|
|
985
994
|
`,
|
|
986
|
-
schema:
|
|
987
|
-
command:
|
|
995
|
+
schema: z13.object({
|
|
996
|
+
command: z13.string().describe(
|
|
988
997
|
"The bash command to execute. Can include pipes (|), redirects (>, >>), logical operators (&&, ||), and shell features like command substitution $(...)."
|
|
989
998
|
)
|
|
990
999
|
}),
|
|
991
1000
|
strict: true
|
|
992
1001
|
};
|
|
1002
|
+
var askUserQuestionTool = {
|
|
1003
|
+
name: "AskUserQuestion",
|
|
1004
|
+
description: `Use this tool when you need to ask the user questions during execution. This allows you to:
|
|
1005
|
+
|
|
1006
|
+
1. Gather user preferences or requirements
|
|
1007
|
+
2. Clarify ambiguous instructions
|
|
1008
|
+
3. Get decisions on implementation choices as you work
|
|
1009
|
+
4. Offer choices to the user about what direction to take.
|
|
1010
|
+
|
|
1011
|
+
Usage notes:
|
|
1012
|
+
|
|
1013
|
+
* Users will always be able to select "Other" to provide custom text input
|
|
1014
|
+
* Use multiSelect: true to allow multiple answers to be selected for a question
|
|
1015
|
+
* If you recommend a specific option, make that the first option in the list and add "(Recommended)" at the end of the label
|
|
1016
|
+
`,
|
|
1017
|
+
schema: z13.object({
|
|
1018
|
+
questions: z13.array(
|
|
1019
|
+
z13.object({
|
|
1020
|
+
question: z13.string().describe("The full question text to display"),
|
|
1021
|
+
header: z13.string().describe("Short label for the question (max 12 characters)"),
|
|
1022
|
+
options: z13.array(
|
|
1023
|
+
z13.object({
|
|
1024
|
+
label: z13.string(),
|
|
1025
|
+
description: z13.string()
|
|
1026
|
+
})
|
|
1027
|
+
).min(0).max(4).describe("Array of 0-4 choices, each with label and description"),
|
|
1028
|
+
multiSelect: z13.boolean().describe("If true, users can select multiple options")
|
|
1029
|
+
})
|
|
1030
|
+
)
|
|
1031
|
+
}),
|
|
1032
|
+
strict: true
|
|
1033
|
+
};
|
|
1034
|
+
|
|
1035
|
+
// src/tools/ask-user-question/handler.ts
|
|
1036
|
+
var createAskUserQuestionHandler = () => (args) => {
|
|
1037
|
+
return {
|
|
1038
|
+
toolResponse: "Question submitted",
|
|
1039
|
+
data: { questions: args.questions }
|
|
1040
|
+
};
|
|
1041
|
+
};
|
|
993
1042
|
|
|
994
1043
|
// node_modules/uuid/dist/esm-node/stringify.js
|
|
995
1044
|
var byteToHex = [];
|
|
@@ -1071,6 +1120,12 @@ function createThreadManager(config) {
|
|
|
1071
1120
|
content
|
|
1072
1121
|
}).toDict();
|
|
1073
1122
|
},
|
|
1123
|
+
createSystemMessage(content) {
|
|
1124
|
+
return new SystemMessage({
|
|
1125
|
+
id: v4_default(),
|
|
1126
|
+
content
|
|
1127
|
+
}).toDict();
|
|
1128
|
+
},
|
|
1074
1129
|
createAIMessage(content, kwargs) {
|
|
1075
1130
|
return new AIMessage({
|
|
1076
1131
|
id: v4_default(),
|
|
@@ -1099,6 +1154,10 @@ function createThreadManager(config) {
|
|
|
1099
1154
|
async appendAIMessage(content) {
|
|
1100
1155
|
const message = helpers.createAIMessage(content);
|
|
1101
1156
|
await base.append([message]);
|
|
1157
|
+
},
|
|
1158
|
+
async appendSystemMessage(content) {
|
|
1159
|
+
const message = helpers.createSystemMessage(content);
|
|
1160
|
+
await base.append([message]);
|
|
1102
1161
|
}
|
|
1103
1162
|
};
|
|
1104
1163
|
return Object.assign(base, helpers);
|
|
@@ -1152,7 +1211,7 @@ async function invokeModel({
|
|
|
1152
1211
|
const parentWorkflowId = info.workflowExecution.workflowId;
|
|
1153
1212
|
const parentRunId = info.workflowExecution.runId;
|
|
1154
1213
|
const handle = client.getHandle(parentWorkflowId, parentRunId);
|
|
1155
|
-
const { tools } = await handle.query(
|
|
1214
|
+
const { tools } = await handle.query(`get${agentName}State`);
|
|
1156
1215
|
const messages = await thread.load();
|
|
1157
1216
|
const response = await model.invoke(
|
|
1158
1217
|
[...mapStoredMessagesToChatMessages(messages)],
|
|
@@ -1179,19 +1238,6 @@ async function invokeModel({
|
|
|
1179
1238
|
}
|
|
1180
1239
|
};
|
|
1181
1240
|
}
|
|
1182
|
-
var createAskUserQuestionHandler = () => async (args) => {
|
|
1183
|
-
const messages = args.questions.map(
|
|
1184
|
-
({ question, header, options, multiSelect }) => new AIMessage({
|
|
1185
|
-
content: question,
|
|
1186
|
-
additional_kwargs: {
|
|
1187
|
-
header,
|
|
1188
|
-
options,
|
|
1189
|
-
multiSelect
|
|
1190
|
-
}
|
|
1191
|
-
}).toDict()
|
|
1192
|
-
);
|
|
1193
|
-
return { toolResponse: "Question submitted", data: { chatMessages: messages } };
|
|
1194
|
-
};
|
|
1195
1241
|
function createGlobHandler(fs) {
|
|
1196
1242
|
return async (_args) => {
|
|
1197
1243
|
new Bash({ fs });
|
|
@@ -1361,6 +1407,6 @@ var toTree = async (fs, opts = {}) => {
|
|
|
1361
1407
|
return base + subtree;
|
|
1362
1408
|
};
|
|
1363
1409
|
|
|
1364
|
-
export { AGENT_HANDLER_NAMES, ZeitlichPlugin, askUserQuestionTool, bashTool, createAgentStateManager, createAskUserQuestionHandler, createBashHandler, createBashToolDescription, createEditHandler, createGlobHandler, createSession, createSharedActivities, createSubagentTool, createTaskCreateHandler, createTaskGetHandler, createTaskListHandler, createTaskUpdateHandler, createThreadManager, createToolRouter, defineSubagent, defineTool, editTool,
|
|
1410
|
+
export { AGENT_HANDLER_NAMES, ZeitlichPlugin, askUserQuestionTool, bashTool, createAgentStateManager, createAskUserQuestionHandler, createBashHandler, createBashToolDescription, createEditHandler, createGlobHandler, createSession, createSharedActivities, createSubagentTool, createTaskCreateHandler, createTaskGetHandler, createTaskListHandler, createTaskUpdateHandler, createThreadManager, createToolRouter, defineSubagent, defineTool, editTool, globTool, grepTool, hasNoOtherToolCalls, invokeModel, isTerminalStatus, proxyDefaultThreadOps, readTool, taskCreateTool, taskGetTool, taskListTool, taskUpdateTool, toTree, withAutoAppend, writeTool };
|
|
1365
1411
|
//# sourceMappingURL=index.js.map
|
|
1366
1412
|
//# sourceMappingURL=index.js.map
|