wave-agent-sdk 1.0.5 → 1.0.6

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 (193) hide show
  1. package/dist/agent.d.ts +23 -1
  2. package/dist/agent.js +34 -4
  3. package/dist/managers/aiManager.d.ts +36 -0
  4. package/dist/managers/aiManager.js +240 -8
  5. package/dist/managers/messageManager.d.ts +1 -3
  6. package/dist/managers/messageManager.js +13 -6
  7. package/dist/managers/slashCommandManager.js +28 -0
  8. package/dist/managers/subagentManager.d.ts +0 -2
  9. package/dist/telemetry/instrumentation.d.ts +1 -1
  10. package/dist/telemetry/instrumentation.js +57 -28
  11. package/dist/tools/bashTool.js +16 -6
  12. package/dist/tools/grepTool.js +11 -3
  13. package/dist/types/index.d.ts +3 -0
  14. package/dist/types/messaging.d.ts +2 -0
  15. package/dist/utils/containerSetup.js +0 -3
  16. package/dist/utils/messageOperations.d.ts +2 -1
  17. package/dist/utils/messageOperations.js +2 -1
  18. package/dist/utils/notificationXml.js +5 -0
  19. package/dist/utils/ripgrep.d.ts +4 -4
  20. package/dist/utils/ripgrep.js +4 -27
  21. package/package.json +20 -8
  22. package/bin/rg +0 -79
  23. package/dist/managers/forkedAgentManager.d.ts +0 -50
  24. package/dist/managers/forkedAgentManager.js +0 -130
  25. package/scripts/install_ripgrep.js +0 -111
  26. package/scripts/postinstall.js +0 -38
  27. package/src/agent.ts +0 -1271
  28. package/src/constants/subagents.ts +0 -4
  29. package/src/constants/toolLimits.ts +0 -15
  30. package/src/constants/tools.ts +0 -24
  31. package/src/core/plugin.ts +0 -237
  32. package/src/core/session.ts +0 -9
  33. package/src/index.ts +0 -38
  34. package/src/managers/MemoryRuleManager.ts +0 -198
  35. package/src/managers/aiManager.ts +0 -2429
  36. package/src/managers/backgroundTaskManager.ts +0 -480
  37. package/src/managers/bangManager.ts +0 -119
  38. package/src/managers/cronManager.ts +0 -401
  39. package/src/managers/foregroundTaskManager.ts +0 -30
  40. package/src/managers/forkedAgentManager.ts +0 -216
  41. package/src/managers/hookManager.ts +0 -1089
  42. package/src/managers/liveConfigManager.ts +0 -445
  43. package/src/managers/lspManager.ts +0 -470
  44. package/src/managers/mcpManager.ts +0 -1010
  45. package/src/managers/messageManager.ts +0 -1184
  46. package/src/managers/messageQueue.ts +0 -157
  47. package/src/managers/permissionManager.ts +0 -1140
  48. package/src/managers/planManager.ts +0 -112
  49. package/src/managers/pluginManager.ts +0 -330
  50. package/src/managers/pluginScopeManager.ts +0 -124
  51. package/src/managers/reversionManager.ts +0 -178
  52. package/src/managers/skillManager.ts +0 -578
  53. package/src/managers/slashCommandManager.ts +0 -564
  54. package/src/managers/subagentManager.ts +0 -915
  55. package/src/managers/toolManager.ts +0 -489
  56. package/src/managers/workflowManager.ts +0 -493
  57. package/src/prompts/autoMemory.ts +0 -33
  58. package/src/prompts/autoMemoryExtraction.ts +0 -146
  59. package/src/prompts/index.ts +0 -506
  60. package/src/prompts/planModeReminders.ts +0 -126
  61. package/src/services/GitService.ts +0 -131
  62. package/src/services/MarketplaceService.ts +0 -1052
  63. package/src/services/MemoryRuleService.ts +0 -71
  64. package/src/services/aiService.ts +0 -919
  65. package/src/services/authService.ts +0 -565
  66. package/src/services/autoMemoryService.ts +0 -280
  67. package/src/services/configurationService.ts +0 -1520
  68. package/src/services/fileWatcher.ts +0 -319
  69. package/src/services/hook.ts +0 -348
  70. package/src/services/initializationService.ts +0 -357
  71. package/src/services/interactionService.ts +0 -229
  72. package/src/services/jsonlHandler.ts +0 -295
  73. package/src/services/memory.ts +0 -234
  74. package/src/services/pluginLoader.ts +0 -252
  75. package/src/services/remoteSettingsService.ts +0 -366
  76. package/src/services/reversionService.ts +0 -122
  77. package/src/services/session.ts +0 -917
  78. package/src/services/taskManager.ts +0 -321
  79. package/src/telemetry/events.ts +0 -65
  80. package/src/telemetry/instrumentation.ts +0 -499
  81. package/src/telemetry/sessionTracing.ts +0 -348
  82. package/src/tools/agentTool.ts +0 -322
  83. package/src/tools/askUserQuestion.ts +0 -160
  84. package/src/tools/bashTool.ts +0 -621
  85. package/src/tools/buildTool.ts +0 -61
  86. package/src/tools/cronCreateTool.ts +0 -161
  87. package/src/tools/cronDeleteTool.ts +0 -51
  88. package/src/tools/cronListTool.ts +0 -47
  89. package/src/tools/editTool.ts +0 -313
  90. package/src/tools/enterPlanMode.ts +0 -124
  91. package/src/tools/enterWorktreeTool.ts +0 -190
  92. package/src/tools/exitPlanMode.ts +0 -139
  93. package/src/tools/exitWorktreeTool.ts +0 -236
  94. package/src/tools/globTool.ts +0 -167
  95. package/src/tools/grepTool.ts +0 -399
  96. package/src/tools/lspTool.ts +0 -883
  97. package/src/tools/readTool.ts +0 -426
  98. package/src/tools/skillTool.ts +0 -248
  99. package/src/tools/taskManagementTools.ts +0 -574
  100. package/src/tools/taskStopTool.ts +0 -78
  101. package/src/tools/types.ts +0 -137
  102. package/src/tools/webFetchTool.ts +0 -373
  103. package/src/tools/workflowTool.ts +0 -205
  104. package/src/tools/writeTool.ts +0 -267
  105. package/src/types/agent.ts +0 -128
  106. package/src/types/auth.ts +0 -19
  107. package/src/types/commands.ts +0 -30
  108. package/src/types/config.ts +0 -43
  109. package/src/types/configuration.ts +0 -168
  110. package/src/types/core.ts +0 -105
  111. package/src/types/cron.ts +0 -13
  112. package/src/types/environment.ts +0 -106
  113. package/src/types/fileSearch.ts +0 -4
  114. package/src/types/history.ts +0 -7
  115. package/src/types/hooks.ts +0 -256
  116. package/src/types/index.ts +0 -41
  117. package/src/types/lsp.ts +0 -98
  118. package/src/types/marketplace.ts +0 -71
  119. package/src/types/mcp.ts +0 -43
  120. package/src/types/memoryRule.ts +0 -31
  121. package/src/types/messaging.ts +0 -114
  122. package/src/types/permissions.ts +0 -80
  123. package/src/types/plugins.ts +0 -39
  124. package/src/types/processes.ts +0 -99
  125. package/src/types/reversion.ts +0 -29
  126. package/src/types/session.ts +0 -12
  127. package/src/types/skills.ts +0 -108
  128. package/src/types/tasks.ts +0 -13
  129. package/src/types/telemetry.ts +0 -98
  130. package/src/types/tools.ts +0 -44
  131. package/src/types/workflow.ts +0 -6
  132. package/src/utils/abortUtils.ts +0 -118
  133. package/src/utils/atomicWrite.ts +0 -61
  134. package/src/utils/bashParser.ts +0 -899
  135. package/src/utils/cacheControlUtils.ts +0 -426
  136. package/src/utils/commandArgumentParser.ts +0 -161
  137. package/src/utils/commandPathResolver.ts +0 -88
  138. package/src/utils/configPaths.ts +0 -220
  139. package/src/utils/configValidator.ts +0 -100
  140. package/src/utils/constants.ts +0 -39
  141. package/src/utils/container.ts +0 -92
  142. package/src/utils/containerSetup.ts +0 -371
  143. package/src/utils/convertMessagesForAPI.ts +0 -326
  144. package/src/utils/cronTasks.ts +0 -128
  145. package/src/utils/cronTasksLock.ts +0 -182
  146. package/src/utils/cronToHuman.ts +0 -99
  147. package/src/utils/customCommands.ts +0 -95
  148. package/src/utils/editUtils.ts +0 -20
  149. package/src/utils/fileFormat.ts +0 -40
  150. package/src/utils/fileSearch.ts +0 -151
  151. package/src/utils/fileUtils.ts +0 -223
  152. package/src/utils/gitUtils.ts +0 -315
  153. package/src/utils/globalLogger.ts +0 -128
  154. package/src/utils/groupMessagesByApiRound.ts +0 -121
  155. package/src/utils/hookMatcher.ts +0 -176
  156. package/src/utils/markdownParser.ts +0 -317
  157. package/src/utils/mcpUtils.ts +0 -138
  158. package/src/utils/messageOperations.ts +0 -659
  159. package/src/utils/modelCapabilities.ts +0 -30
  160. package/src/utils/nameGenerator.ts +0 -99
  161. package/src/utils/notificationXml.ts +0 -57
  162. package/src/utils/openaiClient.ts +0 -251
  163. package/src/utils/parseCronExpression.ts +0 -78
  164. package/src/utils/path.ts +0 -72
  165. package/src/utils/pathEncoder.ts +0 -400
  166. package/src/utils/pathSafety.ts +0 -40
  167. package/src/utils/promptHistory.ts +0 -168
  168. package/src/utils/ripgrep.ts +0 -35
  169. package/src/utils/shellResolver.ts +0 -190
  170. package/src/utils/skillParser.ts +0 -246
  171. package/src/utils/stringUtils.ts +0 -156
  172. package/src/utils/subagentParser.ts +0 -279
  173. package/src/utils/taskReminder.ts +0 -96
  174. package/src/utils/tokenCalculation.ts +0 -43
  175. package/src/utils/tokenEstimate.ts +0 -34
  176. package/src/utils/toolResultStorage.ts +0 -117
  177. package/src/utils/worktreeSession.ts +0 -26
  178. package/src/utils/worktreeUtils.ts +0 -786
  179. package/src/workflow/budgetTracker.ts +0 -34
  180. package/src/workflow/concurrencyLimiter.ts +0 -47
  181. package/src/workflow/journal.ts +0 -95
  182. package/src/workflow/progressReporter.ts +0 -141
  183. package/src/workflow/runState.ts +0 -65
  184. package/src/workflow/scriptRuntime.ts +0 -274
  185. package/src/workflow/structuredOutput.ts +0 -123
  186. package/src/workflow/types.ts +0 -101
  187. package/src/workflow/workflowApis.ts +0 -410
  188. package/vendor/ripgrep/linux-aarch64/rg +0 -0
  189. package/vendor/ripgrep/linux-x86_64/rg +0 -0
  190. package/vendor/ripgrep/macos-aarch64/rg +0 -0
  191. package/vendor/ripgrep/macos-x86_64/rg +0 -0
  192. package/vendor/ripgrep/windows-aarch64/rg.exe +0 -0
  193. package/vendor/ripgrep/windows-x86_64/rg.exe +0 -0
@@ -1,80 +0,0 @@
1
- /**
2
- * Permission system types for Wave Agent SDK
3
- * Dependencies: None
4
- */
5
-
6
- import {
7
- AskUserQuestion,
8
- AskUserQuestionInput,
9
- AskUserQuestionOption,
10
- } from "./tools.js";
11
- import {
12
- EDIT_TOOL_NAME,
13
- BASH_TOOL_NAME,
14
- WRITE_TOOL_NAME,
15
- ENTER_PLAN_MODE_TOOL_NAME,
16
- EXIT_PLAN_MODE_TOOL_NAME,
17
- ASK_USER_QUESTION_TOOL_NAME,
18
- } from "../constants/tools.js";
19
-
20
- /** Permission mode configuration */
21
- export type PermissionMode =
22
- | "default"
23
- | "bypassPermissions"
24
- | "acceptEdits"
25
- | "plan"
26
- | "dontAsk";
27
-
28
- /** Result of a permission check */
29
- export interface PermissionDecision {
30
- /** Whether to allow or deny the operation */
31
- behavior: "allow" | "deny";
32
- /** Optional message explaining the decision (required for deny) */
33
- message?: string;
34
- /** Signal to change the session's permission mode */
35
- newPermissionMode?: PermissionMode;
36
- /** Signal to persist a new allowed rule */
37
- newPermissionRule?: string;
38
- }
39
-
40
- /** Callback function for custom permission logic */
41
- export type PermissionCallback = (
42
- context: ToolPermissionContext,
43
- ) => Promise<PermissionDecision>;
44
-
45
- /** Internal context passed to PermissionManager */
46
- export interface ToolPermissionContext {
47
- /** Name of the tool being executed */
48
- toolName: string;
49
- /** Current permission mode */
50
- permissionMode: PermissionMode;
51
- /** Custom permission callback if provided */
52
- canUseToolCallback?: PermissionCallback;
53
- /** Tool input parameters for better context */
54
- toolInput?: Record<string, unknown>;
55
- /** Suggested prefix for bash commands */
56
- suggestedPrefix?: string;
57
- /** Whether to hide the persistent permission option (e.g., "Don't ask again") in the UI */
58
- hidePersistentOption?: boolean;
59
- /** The ID of the tool call that triggered this permission request */
60
- toolCallId?: string;
61
- /** The content of the plan being exited from */
62
- planContent?: string;
63
- }
64
-
65
- /** List of tools that require permission checks in default mode */
66
- export const RESTRICTED_TOOLS = [
67
- EDIT_TOOL_NAME,
68
- BASH_TOOL_NAME,
69
- WRITE_TOOL_NAME,
70
- ENTER_PLAN_MODE_TOOL_NAME,
71
- EXIT_PLAN_MODE_TOOL_NAME,
72
- ASK_USER_QUESTION_TOOL_NAME,
73
- ] as const;
74
-
75
- /** Type for restricted tool names */
76
- export type RestrictedTool = (typeof RESTRICTED_TOOLS)[number];
77
-
78
- export const OPERATION_CANCELLED_BY_USER = "Operation cancelled by user";
79
-
80
- export type { AskUserQuestion, AskUserQuestionInput, AskUserQuestionOption };
@@ -1,39 +0,0 @@
1
- import { CustomSlashCommand } from "./commands.js";
2
- import { Skill } from "./skills.js";
3
- import { LspConfig } from "./lsp.js";
4
- import { McpConfig } from "./mcp.js";
5
- import { PartialHookConfiguration } from "./configuration.js";
6
- import { SubagentConfiguration } from "../utils/subagentParser.js";
7
-
8
- /**
9
- * Plugin manifest structure (.wave-plugin/plugin.json)
10
- */
11
- export interface PluginManifest {
12
- name: string;
13
- description: string;
14
- version: string;
15
- author?: {
16
- name: string;
17
- };
18
- }
19
-
20
- /**
21
- * Plugin configuration in AgentOptions or wave.settings.json
22
- */
23
- export interface PluginConfig {
24
- type: "local";
25
- path: string;
26
- }
27
-
28
- /**
29
- * Represents a loaded plugin in the system
30
- */
31
- export interface Plugin extends PluginManifest {
32
- path: string;
33
- commands: CustomSlashCommand[];
34
- skills: Skill[];
35
- agents: SubagentConfiguration[];
36
- lspConfig?: LspConfig;
37
- mcpConfig?: McpConfig;
38
- hooksConfig?: PartialHookConfiguration;
39
- }
@@ -1,99 +0,0 @@
1
- /**
2
- * Background process and shell management types
3
- * Dependencies: None
4
- */
5
-
6
- import type { ChildProcess } from "child_process";
7
-
8
- export type BackgroundTaskStatus =
9
- | "running"
10
- | "completed"
11
- | "failed"
12
- | "killed";
13
- export type BackgroundTaskType = "shell" | "subagent" | "workflow";
14
-
15
- export interface BackgroundTaskBase {
16
- id: string;
17
- type: BackgroundTaskType;
18
- status: BackgroundTaskStatus;
19
- startTime: number;
20
- endTime?: number;
21
- command?: string; // for shell
22
- description?: string; // for subagent
23
- stdout: string;
24
- stderr: string;
25
- exitCode?: number;
26
- runtime?: number;
27
- /**
28
- * Optional callback to be executed when the task is stopped.
29
- * This allows tasks to define their own cleanup/abortion logic.
30
- */
31
- onStop?: () => void | Promise<void>;
32
- /**
33
- * Optional subagent ID associated with this task.
34
- * Used for cleanup when the task is stopped.
35
- */
36
- subagentId?: string;
37
- /**
38
- * Optional path to the real-time output log file.
39
- */
40
- outputPath?: string;
41
- }
42
-
43
- export interface BackgroundShell extends BackgroundTaskBase {
44
- type: "shell";
45
- process: ChildProcess;
46
- }
47
-
48
- export interface BackgroundSubagent extends BackgroundTaskBase {
49
- type: "subagent";
50
- }
51
-
52
- export interface BackgroundWorkflow extends BackgroundTaskBase {
53
- type: "workflow";
54
- runId: string;
55
- }
56
-
57
- export type BackgroundTask =
58
- | BackgroundShell
59
- | BackgroundSubagent
60
- | BackgroundWorkflow;
61
-
62
- /**
63
- * Serializable summary of a BackgroundTask, used for notifications where the
64
- * full stdout/stderr and non-serializable process/onStop fields must be
65
- * stripped to control payload size. Output is fetched on demand via
66
- * getBackgroundTaskOutput.
67
- */
68
- export interface BackgroundTaskSummary {
69
- id: string;
70
- type: BackgroundTaskType;
71
- status: BackgroundTaskStatus;
72
- startTime: number;
73
- endTime?: number;
74
- command?: string;
75
- description?: string;
76
- exitCode?: number;
77
- runtime?: number;
78
- outputPath?: string;
79
- }
80
-
81
- /** Output snapshot returned by getBackgroundTaskOutput. */
82
- export interface BackgroundTaskOutput {
83
- stdout: string;
84
- stderr: string;
85
- status: BackgroundTaskStatus;
86
- outputPath?: string;
87
- type: BackgroundTaskType;
88
- exitCode?: number;
89
- }
90
-
91
- export interface ForegroundTask {
92
- id: string;
93
- backgroundHandler: () => Promise<void>;
94
- }
95
-
96
- export interface IForegroundTaskManager {
97
- registerForegroundTask(task: ForegroundTask): void;
98
- unregisterForegroundTask(id: string): void;
99
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * Represents the state of a file before an agent operation.
3
- */
4
- export interface FileSnapshot {
5
- /** The ID of the message/turn this snapshot is associated with. */
6
- messageId: string;
7
- /** Absolute path to the file. */
8
- filePath: string;
9
- /** Path to the stored snapshot file. */
10
- snapshotPath?: string;
11
- /** When the snapshot was taken. */
12
- timestamp: number;
13
- /** The operation that triggered this snapshot. */
14
- operation: "create" | "modify" | "delete";
15
- }
16
-
17
- /**
18
- * A point in the conversation history that can be reverted to.
19
- */
20
- export interface Checkpoint {
21
- /** The index of the user message in the history. */
22
- index: number;
23
- /** The unique ID of the user message. */
24
- messageId: string;
25
- /** A short snippet of the message content for the UI. */
26
- preview: string;
27
- /** When the message was sent. */
28
- timestamp: number;
29
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * Session management types for project-based organization with JSONL format
3
- * Dependencies: Core messaging types
4
- *
5
- * SIMPLIFIED: Removed unused interfaces to focus on core functionality
6
- */
7
-
8
- // Session filename structure for simple filename-based metadata
9
- export interface SessionFilename {
10
- sessionId: string;
11
- sessionType: "main" | "subagent";
12
- }
@@ -1,108 +0,0 @@
1
- /**
2
- * Skill system types and constants
3
- * Dependencies: Core (Logger)
4
- */
5
-
6
- export interface SkillMetadata {
7
- name: string;
8
- description: string;
9
- type: "personal" | "project" | "builtin";
10
- skillPath: string;
11
- allowedTools?: string[];
12
- context?: "fork";
13
- agent?: string;
14
- model?: string;
15
- disableModelInvocation?: boolean;
16
- userInvocable?: boolean;
17
- pluginName?: string;
18
- pluginRoot?: string;
19
- }
20
-
21
- export interface Skill extends SkillMetadata {
22
- content: string;
23
- frontmatter: SkillFrontmatter;
24
- isValid: boolean;
25
- errors: string[];
26
- }
27
-
28
- export interface SkillFrontmatter {
29
- name: string;
30
- description: string;
31
- "allowed-tools"?: string | string[];
32
- context?: "fork";
33
- agent?: string;
34
- model?: string;
35
- "disable-model-invocation"?: boolean | string;
36
- "user-invocable"?: boolean | string;
37
- [key: string]: unknown;
38
- }
39
-
40
- export interface SkillCollection {
41
- type: "personal" | "project" | "builtin";
42
- basePath: string;
43
- skills: Map<string, SkillMetadata>;
44
- errors: SkillError[];
45
- }
46
-
47
- export interface SkillError {
48
- skillPath: string;
49
- message: string;
50
- }
51
-
52
- export interface SkillValidationResult {
53
- isValid: boolean;
54
- skill?: Skill;
55
- errors: string[];
56
- }
57
-
58
- export interface SkillDiscoveryResult {
59
- personalSkills: Map<string, SkillMetadata>;
60
- projectSkills: Map<string, SkillMetadata>;
61
- builtinSkills: Map<string, SkillMetadata>;
62
- errors: SkillError[];
63
- }
64
-
65
- export interface SkillInvocationContext {
66
- skillName: string;
67
- }
68
-
69
- export interface SkillToolArgs {
70
- skill_name: string;
71
- args?: string;
72
- }
73
-
74
- export interface SkillManagerOptions {
75
- personalSkillsPath?: string;
76
- personalClaudeSkillsPath?: string;
77
- personalAgentsSkillsPath?: string;
78
- scanTimeout?: number;
79
- workdir?: string;
80
- watch?: boolean;
81
- }
82
-
83
- export interface ParsedSkillFile {
84
- frontmatter: SkillFrontmatter;
85
- content: string;
86
- skillMetadata: SkillMetadata;
87
- validationErrors: string[];
88
- isValid: boolean;
89
- }
90
-
91
- export interface SkillParseOptions {
92
- validateMetadata?: boolean;
93
- basePath?: string;
94
- }
95
-
96
- export const SKILL_DEFAULTS = {
97
- PERSONAL_SKILLS_DIR: ".wave/skills",
98
- PROJECT_SKILLS_DIR: ".wave/skills",
99
- SKILL_FILE_NAME: "SKILL.md",
100
- MAX_NAME_LENGTH: 64,
101
- MAX_DESCRIPTION_LENGTH: 1024,
102
- MIN_DESCRIPTION_LENGTH: 1,
103
- NAME_PATTERN: /^[a-z0-9-]+$/,
104
- MAX_METADATA_CACHE: 1000,
105
- MAX_CONTENT_CACHE: 100,
106
- SCAN_TIMEOUT: 5000,
107
- LOAD_TIMEOUT: 2000,
108
- } as const;
@@ -1,13 +0,0 @@
1
- export type TaskStatus = "pending" | "in_progress" | "completed" | "deleted";
2
-
3
- export interface Task {
4
- id: string;
5
- subject: string;
6
- description: string;
7
- status: TaskStatus;
8
- activeForm?: string;
9
- owner?: string;
10
- blocks: string[];
11
- blockedBy: string[];
12
- metadata: Record<string, unknown>;
13
- }
@@ -1,98 +0,0 @@
1
- /**
2
- * OpenTelemetry Integration Types
3
- *
4
- * Type definitions for Wave's OpenTelemetry instrumentation module.
5
- */
6
-
7
- /** Exporter target for telemetry signals */
8
- export type ExporterTarget = "jsonl" | "otlp";
9
-
10
- /** OTLP transport protocol */
11
- export type OTLPProtocol = "http/protobuf" | "http/json" | "grpc";
12
-
13
- /** Resolved telemetry configuration */
14
- export interface TelemetryConfig {
15
- /** Master switch for telemetry */
16
- enabled: boolean;
17
- /** Trace export target */
18
- tracesExporter?: ExporterTarget;
19
- /** Log export target */
20
- logsExporter?: ExporterTarget;
21
- /** OTLP collector URL */
22
- endpoint?: string;
23
- /** OTLP transport protocol */
24
- protocol?: OTLPProtocol;
25
- /** Auth/custom headers */
26
- headers?: Record<string, string>;
27
- /** Include prompt text in events */
28
- logUserPrompts: boolean;
29
- /** Include tool I/O in events */
30
- logToolContent: boolean;
31
- /** Max flush time on exit (default 2000) */
32
- shutdownTimeoutMs: number;
33
- /** Stale span eviction TTL (default 1800000 = 30min) */
34
- spanTtlMs: number;
35
- }
36
-
37
- /** Metadata for LLM request spans */
38
- export interface LLMRequestMetadata {
39
- /** Model identifier */
40
- model: string;
41
- /** Scope context */
42
- context?: "interaction" | "standalone";
43
- /** Prompt tokens consumed */
44
- inputTokens?: number;
45
- /** Completion tokens generated */
46
- outputTokens?: number;
47
- /** Cache hit tokens */
48
- cacheReadTokens?: number;
49
- /** Cache write tokens */
50
- cacheCreationTokens?: number;
51
- /** Time to first token (ms) */
52
- ttftMs?: number;
53
- /** Time to last token / total duration (ms) */
54
- ttltMs?: number;
55
- /** Request succeeded */
56
- success: boolean;
57
- /** Error message if failed */
58
- error?: string;
59
- /** Response included tool calls */
60
- hasToolCall?: boolean;
61
- /** Model text output (recorded when logToolContent is true) */
62
- modelOutput?: string;
63
- }
64
-
65
- /** Input context for an LLM request span (content capture gated by logToolContent) */
66
- export interface LLMRequestInput {
67
- /** Scope context */
68
- context?: "interaction" | "standalone";
69
- /** System prompt string (when available) */
70
- systemPrompt?: string;
71
- /** Messages array sent to the API */
72
- inputMessages?: unknown[];
73
- /** Tool schemas JSON string */
74
- toolsSchema?: string;
75
- }
76
-
77
- /** Metadata for tool execution spans */
78
- export interface ToolMetadata {
79
- /** Tool execution succeeded */
80
- success: boolean;
81
- /** Error message if failed */
82
- error?: string;
83
- /** Execution time (ms) */
84
- durationMs: number;
85
- /** Tool output content (recorded when logToolContent is true) */
86
- output?: string;
87
- }
88
-
89
- /** Event names for OTel structured logging */
90
- export type OTelEventName =
91
- | "session_start"
92
- | "session_end"
93
- | "user_prompt"
94
- | "tool_decision"
95
- | "compaction"
96
- | "error"
97
- | "system_prompt"
98
- | "tool_schema";
@@ -1,44 +0,0 @@
1
- /**
2
- * Tool parameter types for edit and write operations
3
- */
4
-
5
- /**
6
- * Input types for AskUserQuestion tool
7
- */
8
- export interface AskUserQuestionOption {
9
- label: string;
10
- description?: string;
11
- }
12
-
13
- export interface AskUserQuestion {
14
- question: string;
15
- header: string;
16
- options: AskUserQuestionOption[];
17
- multiSelect?: boolean;
18
- }
19
-
20
- export interface AskUserQuestionInput {
21
- questions: AskUserQuestion[];
22
- answers?: Record<string, string>;
23
- metadata?: {
24
- source?: string;
25
- };
26
- }
27
-
28
- /**
29
- * Parameters for the Write tool
30
- */
31
- export interface WriteToolParameters {
32
- file_path: string;
33
- content: string;
34
- }
35
-
36
- /**
37
- * Parameters for the Edit tool
38
- */
39
- export interface EditToolParameters {
40
- file_path: string;
41
- old_string: string;
42
- new_string: string;
43
- replace_all?: boolean;
44
- }
@@ -1,6 +0,0 @@
1
- export type {
2
- WorkflowRun,
3
- WorkflowMeta,
4
- WorkflowPhaseState,
5
- SerializableWorkflowRun,
6
- } from "../workflow/types.js";
@@ -1,118 +0,0 @@
1
- /**
2
- * Utilities for safe AbortSignal listener management to prevent memory leaks
3
- */
4
-
5
- /**
6
- * Safely adds a one-time abort listener that automatically cleans up after firing
7
- * @param signal - The AbortSignal to listen to
8
- * @param callback - The function to call when aborted
9
- * @returns A cleanup function to manually remove the listener if needed
10
- */
11
- export function addOnceAbortListener(
12
- signal: AbortSignal,
13
- callback: () => void,
14
- ): () => void {
15
- if (signal.aborted) {
16
- // Signal already aborted, call immediately
17
- callback();
18
- return () => {}; // No cleanup needed
19
- }
20
-
21
- const handler = () => {
22
- callback();
23
- };
24
-
25
- // Use { once: true } to automatically remove listener after first call
26
- signal.addEventListener("abort", handler, { once: true });
27
-
28
- // Return cleanup function for manual removal if needed
29
- return () => {
30
- signal.removeEventListener("abort", handler);
31
- };
32
- }
33
-
34
- /**
35
- * Creates a Promise that rejects when the AbortSignal is aborted
36
- * Uses once-only listener to prevent accumulation
37
- * @param signal - The AbortSignal to listen to
38
- * @param errorMessage - Optional custom error message
39
- * @returns Promise that rejects on abort
40
- */
41
- export function createAbortPromise(
42
- signal: AbortSignal,
43
- errorMessage: string = "Operation was aborted",
44
- ): Promise<never> {
45
- return new Promise<never>((_, reject) => {
46
- if (signal.aborted) {
47
- reject(new Error(errorMessage));
48
- return;
49
- }
50
-
51
- // Use once-only listener to prevent accumulation
52
- signal.addEventListener(
53
- "abort",
54
- () => {
55
- reject(new Error(errorMessage));
56
- },
57
- { once: true },
58
- );
59
- });
60
- }
61
-
62
- /**
63
- * Wrapper that manages abort signal listeners with automatic cleanup
64
- * @param signal - The AbortSignal to manage
65
- * @param operation - Function that sets up listeners and returns cleanup
66
- * @returns Promise that resolves with the operation result
67
- */
68
- export async function withAbortCleanup<T>(
69
- signal: AbortSignal,
70
- operation: (signal: AbortSignal) => Promise<T>,
71
- ): Promise<T> {
72
- // Track all cleanup functions
73
- const cleanups: (() => void)[] = [];
74
-
75
- try {
76
- const result = await operation(signal);
77
- return result;
78
- } finally {
79
- // Clean up all listeners
80
- cleanups.forEach((cleanup) => cleanup());
81
- }
82
- }
83
-
84
- /**
85
- * Consolidates multiple abort listeners into a single listener
86
- * Useful when multiple handlers need to respond to the same abort signal
87
- * @param signal - The AbortSignal to listen to
88
- * @param callbacks - Array of functions to call when aborted
89
- * @returns Cleanup function to remove the consolidated listener
90
- */
91
- export function addConsolidatedAbortListener(
92
- signal: AbortSignal,
93
- callbacks: (() => void)[],
94
- ): () => void {
95
- if (signal.aborted) {
96
- // Signal already aborted, call all callbacks immediately
97
- callbacks.forEach((cb) => cb());
98
- return () => {}; // No cleanup needed
99
- }
100
-
101
- const handler = () => {
102
- callbacks.forEach((cb) => {
103
- try {
104
- cb();
105
- } catch (error) {
106
- console.error("Error in abort callback:", error);
107
- }
108
- });
109
- };
110
-
111
- // Use { once: true } to automatically remove listener after first call
112
- signal.addEventListener("abort", handler, { once: true });
113
-
114
- // Return cleanup function for manual removal if needed
115
- return () => {
116
- signal.removeEventListener("abort", handler);
117
- };
118
- }