@workglow/ai 0.0.125 → 0.1.0

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 (143) hide show
  1. package/README.md +218 -47
  2. package/dist/browser.d.ts +7 -0
  3. package/dist/browser.d.ts.map +1 -0
  4. package/dist/browser.js +565 -1277
  5. package/dist/browser.js.map +56 -61
  6. package/dist/{types.d.ts → bun.d.ts} +1 -1
  7. package/dist/bun.d.ts.map +1 -0
  8. package/dist/bun.js +565 -1277
  9. package/dist/bun.js.map +56 -61
  10. package/dist/common.d.ts +3 -1
  11. package/dist/common.d.ts.map +1 -1
  12. package/dist/execution/DirectExecutionStrategy.d.ts +20 -0
  13. package/dist/execution/DirectExecutionStrategy.d.ts.map +1 -0
  14. package/dist/execution/IAiExecutionStrategy.d.ts +33 -0
  15. package/dist/execution/IAiExecutionStrategy.d.ts.map +1 -0
  16. package/dist/execution/QueuedExecutionStrategy.d.ts +50 -0
  17. package/dist/execution/QueuedExecutionStrategy.d.ts.map +1 -0
  18. package/dist/job/AiJob.d.ts +6 -0
  19. package/dist/job/AiJob.d.ts.map +1 -1
  20. package/dist/node.d.ts +7 -0
  21. package/dist/node.d.ts.map +1 -0
  22. package/dist/node.js +565 -1277
  23. package/dist/node.js.map +56 -61
  24. package/dist/provider/AiProvider.d.ts +16 -2
  25. package/dist/provider/AiProvider.d.ts.map +1 -1
  26. package/dist/provider/AiProviderRegistry.d.ts +20 -0
  27. package/dist/provider/AiProviderRegistry.d.ts.map +1 -1
  28. package/dist/provider/QueuedAiProvider.d.ts +23 -2
  29. package/dist/provider/QueuedAiProvider.d.ts.map +1 -1
  30. package/dist/task/BackgroundRemovalTask.d.ts +3 -3
  31. package/dist/task/BackgroundRemovalTask.d.ts.map +1 -1
  32. package/dist/task/ChunkRetrievalTask.d.ts +4 -4
  33. package/dist/task/ChunkRetrievalTask.d.ts.map +1 -1
  34. package/dist/task/ChunkToVectorTask.d.ts +4 -4
  35. package/dist/task/ChunkToVectorTask.d.ts.map +1 -1
  36. package/dist/task/ChunkVectorHybridSearchTask.d.ts +4 -4
  37. package/dist/task/ChunkVectorHybridSearchTask.d.ts.map +1 -1
  38. package/dist/task/ChunkVectorSearchTask.d.ts +4 -4
  39. package/dist/task/ChunkVectorSearchTask.d.ts.map +1 -1
  40. package/dist/task/ChunkVectorUpsertTask.d.ts +4 -4
  41. package/dist/task/ChunkVectorUpsertTask.d.ts.map +1 -1
  42. package/dist/task/ContextBuilderTask.d.ts +4 -4
  43. package/dist/task/ContextBuilderTask.d.ts.map +1 -1
  44. package/dist/task/CountTokensTask.d.ts +11 -29
  45. package/dist/task/CountTokensTask.d.ts.map +1 -1
  46. package/dist/task/DocumentEnricherTask.d.ts +4 -4
  47. package/dist/task/DocumentEnricherTask.d.ts.map +1 -1
  48. package/dist/task/DownloadModelTask.d.ts +5 -5
  49. package/dist/task/DownloadModelTask.d.ts.map +1 -1
  50. package/dist/task/FaceDetectorTask.d.ts +4 -4
  51. package/dist/task/FaceDetectorTask.d.ts.map +1 -1
  52. package/dist/task/FaceLandmarkerTask.d.ts +4 -4
  53. package/dist/task/FaceLandmarkerTask.d.ts.map +1 -1
  54. package/dist/task/GestureRecognizerTask.d.ts +4 -4
  55. package/dist/task/GestureRecognizerTask.d.ts.map +1 -1
  56. package/dist/task/HandLandmarkerTask.d.ts +4 -4
  57. package/dist/task/HandLandmarkerTask.d.ts.map +1 -1
  58. package/dist/task/HierarchicalChunkerTask.d.ts +4 -4
  59. package/dist/task/HierarchicalChunkerTask.d.ts.map +1 -1
  60. package/dist/task/HierarchyJoinTask.d.ts +4 -4
  61. package/dist/task/HierarchyJoinTask.d.ts.map +1 -1
  62. package/dist/task/ImageClassificationTask.d.ts +4 -4
  63. package/dist/task/ImageClassificationTask.d.ts.map +1 -1
  64. package/dist/task/ImageEmbeddingTask.d.ts +203 -89
  65. package/dist/task/ImageEmbeddingTask.d.ts.map +1 -1
  66. package/dist/task/ImageSegmentationTask.d.ts +4 -4
  67. package/dist/task/ImageSegmentationTask.d.ts.map +1 -1
  68. package/dist/task/ImageToTextTask.d.ts +4 -4
  69. package/dist/task/ImageToTextTask.d.ts.map +1 -1
  70. package/dist/task/ModelInfoTask.d.ts +5 -5
  71. package/dist/task/ModelInfoTask.d.ts.map +1 -1
  72. package/dist/task/ModelSearchTask.d.ts +3 -3
  73. package/dist/task/ModelSearchTask.d.ts.map +1 -1
  74. package/dist/task/ObjectDetectionTask.d.ts +4 -4
  75. package/dist/task/ObjectDetectionTask.d.ts.map +1 -1
  76. package/dist/task/PoseLandmarkerTask.d.ts +4 -4
  77. package/dist/task/PoseLandmarkerTask.d.ts.map +1 -1
  78. package/dist/task/QueryExpanderTask.d.ts +4 -4
  79. package/dist/task/QueryExpanderTask.d.ts.map +1 -1
  80. package/dist/task/RerankerTask.d.ts +4 -4
  81. package/dist/task/RerankerTask.d.ts.map +1 -1
  82. package/dist/task/StructuralParserTask.d.ts +4 -4
  83. package/dist/task/StructuralParserTask.d.ts.map +1 -1
  84. package/dist/task/StructuredGenerationTask.d.ts +4 -4
  85. package/dist/task/StructuredGenerationTask.d.ts.map +1 -1
  86. package/dist/task/TextChunkerTask.d.ts +4 -4
  87. package/dist/task/TextChunkerTask.d.ts.map +1 -1
  88. package/dist/task/TextClassificationTask.d.ts +24 -62
  89. package/dist/task/TextClassificationTask.d.ts.map +1 -1
  90. package/dist/task/TextEmbeddingTask.d.ts +3 -3
  91. package/dist/task/TextEmbeddingTask.d.ts.map +1 -1
  92. package/dist/task/TextFillMaskTask.d.ts +29 -73
  93. package/dist/task/TextFillMaskTask.d.ts.map +1 -1
  94. package/dist/task/TextGenerationTask.d.ts +13 -32
  95. package/dist/task/TextGenerationTask.d.ts.map +1 -1
  96. package/dist/task/TextLanguageDetectionTask.d.ts +24 -62
  97. package/dist/task/TextLanguageDetectionTask.d.ts.map +1 -1
  98. package/dist/task/TextNamedEntityRecognitionTask.d.ts +29 -73
  99. package/dist/task/TextNamedEntityRecognitionTask.d.ts.map +1 -1
  100. package/dist/task/TextQuestionAnswerTask.d.ts +17 -45
  101. package/dist/task/TextQuestionAnswerTask.d.ts.map +1 -1
  102. package/dist/task/TextRewriterTask.d.ts +12 -31
  103. package/dist/task/TextRewriterTask.d.ts.map +1 -1
  104. package/dist/task/TextSummaryTask.d.ts +12 -31
  105. package/dist/task/TextSummaryTask.d.ts.map +1 -1
  106. package/dist/task/TextTranslationTask.d.ts +12 -31
  107. package/dist/task/TextTranslationTask.d.ts.map +1 -1
  108. package/dist/task/TopicSegmenterTask.d.ts +4 -4
  109. package/dist/task/TopicSegmenterTask.d.ts.map +1 -1
  110. package/dist/task/UnloadModelTask.d.ts +4 -4
  111. package/dist/task/UnloadModelTask.d.ts.map +1 -1
  112. package/dist/task/VectorQuantizeTask.d.ts +4 -4
  113. package/dist/task/VectorQuantizeTask.d.ts.map +1 -1
  114. package/dist/task/VectorSimilarityTask.d.ts +4 -4
  115. package/dist/task/VectorSimilarityTask.d.ts.map +1 -1
  116. package/dist/task/base/AiTask.d.ts +12 -31
  117. package/dist/task/base/AiTask.d.ts.map +1 -1
  118. package/dist/task/base/AiVisionTask.d.ts +7 -12
  119. package/dist/task/base/AiVisionTask.d.ts.map +1 -1
  120. package/dist/task/base/StreamingAiTask.d.ts +7 -4
  121. package/dist/task/base/StreamingAiTask.d.ts.map +1 -1
  122. package/dist/task/index.d.ts +1 -13
  123. package/dist/task/index.d.ts.map +1 -1
  124. package/dist/worker.d.ts +0 -2
  125. package/dist/worker.d.ts.map +1 -1
  126. package/dist/worker.js +217 -233
  127. package/dist/worker.js.map +7 -7
  128. package/package.json +24 -15
  129. package/dist/queue/createDefaultQueue.d.ts +0 -17
  130. package/dist/queue/createDefaultQueue.d.ts.map +0 -1
  131. package/dist/task/AgentTask.d.ts +0 -524
  132. package/dist/task/AgentTask.d.ts.map +0 -1
  133. package/dist/task/AgentTypes.d.ts +0 -181
  134. package/dist/task/AgentTypes.d.ts.map +0 -1
  135. package/dist/task/AgentUtils.d.ts +0 -50
  136. package/dist/task/AgentUtils.d.ts.map +0 -1
  137. package/dist/task/MessageConversion.d.ts +0 -52
  138. package/dist/task/MessageConversion.d.ts.map +0 -1
  139. package/dist/task/ToolCallingTask.d.ts +0 -385
  140. package/dist/task/ToolCallingTask.d.ts.map +0 -1
  141. package/dist/task/ToolCallingUtils.d.ts +0 -65
  142. package/dist/task/ToolCallingUtils.d.ts.map +0 -1
  143. package/dist/types.d.ts.map +0 -1
@@ -1,181 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2026 Steven Roussey <sroussey@gmail.com>
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import { DataPorts } from "@workglow/task-graph";
7
- import type { ToolCall, ToolCalls, ToolDefinition } from "./ToolCallingUtils";
8
- /**
9
- * A text content block within a chat message.
10
- */
11
- export interface TextContentBlock {
12
- readonly type: "text";
13
- readonly text: string;
14
- }
15
- /**
16
- * An image content block within a chat message.
17
- */
18
- export interface ImageContentBlock {
19
- readonly type: "image";
20
- readonly mimeType: string;
21
- readonly data: string;
22
- }
23
- /**
24
- * An audio content block within a chat message.
25
- */
26
- export interface AudioContentBlock {
27
- readonly type: "audio";
28
- readonly mimeType: string;
29
- readonly data: string;
30
- }
31
- /**
32
- * A tool-use content block within an assistant message.
33
- * Represents the LLM requesting a tool invocation.
34
- */
35
- export interface ToolUseContentBlock {
36
- readonly type: "tool_use";
37
- readonly id: string;
38
- readonly name: string;
39
- readonly input: Record<string, unknown>;
40
- }
41
- /**
42
- * A tool-result content block within a tool message.
43
- * Represents the result of executing a tool call.
44
- */
45
- export interface ToolResultContentBlock {
46
- readonly type: "tool_result";
47
- readonly tool_use_id: string;
48
- readonly content: string | ReadonlyArray<ToolResultInnerBlock>;
49
- readonly is_error?: boolean;
50
- }
51
- /** Content blocks allowed in user messages */
52
- export type UserContentBlock = TextContentBlock | ImageContentBlock | AudioContentBlock;
53
- /** Content blocks allowed inside tool result content */
54
- export type ToolResultInnerBlock = TextContentBlock | ImageContentBlock | AudioContentBlock;
55
- export type ContentBlock = TextContentBlock | ImageContentBlock | AudioContentBlock | ToolUseContentBlock | ToolResultContentBlock;
56
- /**
57
- * Provider-agnostic chat message for multi-turn conversations.
58
- * Uses a discriminated union on `role` to enforce correct content types.
59
- */
60
- export type ChatMessage = {
61
- readonly role: "user";
62
- readonly content: string | ReadonlyArray<UserContentBlock>;
63
- } | {
64
- readonly role: "assistant";
65
- readonly content: ReadonlyArray<TextContentBlock | ToolUseContentBlock>;
66
- } | {
67
- readonly role: "tool";
68
- readonly content: ReadonlyArray<ToolResultContentBlock>;
69
- };
70
- /**
71
- * A tool backed by a Task in the TaskRegistry. Instantiated and run via
72
- * `TaskRegistry.all.get(taskType)`. Optional `config` is passed to the
73
- * task constructor for configurable tasks (e.g. `McpToolCallTask`,
74
- * `JavaScriptTask`).
75
- */
76
- export interface RegistryToolSource {
77
- readonly type: "registry";
78
- readonly definition: ToolDefinition;
79
- readonly taskType: string;
80
- /** Configuration values passed to the task constructor. */
81
- readonly config?: DataPorts;
82
- }
83
- /**
84
- * A user-provided tool with a custom executor function.
85
- */
86
- export interface FunctionToolSource {
87
- readonly type: "function";
88
- readonly definition: ToolDefinition;
89
- readonly run: (input: DataPorts) => Promise<DataPorts>;
90
- }
91
- export type ToolSource = RegistryToolSource | FunctionToolSource;
92
- export interface ToolResult {
93
- readonly toolCallId: string;
94
- readonly toolName: string;
95
- readonly output: DataPorts;
96
- readonly isError: boolean;
97
- /** Optional media content blocks to include alongside the JSON output. */
98
- readonly mediaContent?: ReadonlyArray<ToolResultInnerBlock>;
99
- }
100
- /**
101
- * Decision returned by the beforeToolCall hook.
102
- * - `"allow"`: proceed with the tool call as-is
103
- * - `"deny"`: skip the tool call and return an error to the LLM
104
- * - `"modify"`: proceed with modified input
105
- */
106
- export type ToolCallDecision = {
107
- readonly action: "allow";
108
- } | {
109
- readonly action: "deny";
110
- readonly reason?: string;
111
- } | {
112
- readonly action: "modify";
113
- readonly input: Record<string, unknown>;
114
- };
115
- /**
116
- * Action returned by the onToolError hook.
117
- * - `"throw"`: report the error to the LLM (default when no hook)
118
- * - `"result"`: use a fallback result instead of reporting the error
119
- */
120
- export type ToolErrorAction = {
121
- readonly action: "throw";
122
- } | {
123
- readonly action: "result";
124
- readonly output: Record<string, unknown>;
125
- };
126
- /**
127
- * Action returned by the onIteration hook.
128
- * - `"continue"`: proceed with the next LLM call
129
- * - `"stop"`: end the agent loop and return current results
130
- */
131
- export type IterationAction = {
132
- readonly action: "continue";
133
- } | {
134
- readonly action: "stop";
135
- };
136
- /**
137
- * Lifecycle hooks for the AgentTask loop.
138
- * All hooks are optional; the agent runs without intervention by default.
139
- */
140
- export interface AgentHooks {
141
- /** Called before each tool call. Can approve, deny, or modify the call. */
142
- readonly beforeToolCall?: (call: ToolCall, source: ToolSource) => Promise<ToolCallDecision>;
143
- /** Called after each successful tool call. Can transform the result. */
144
- readonly afterToolCall?: (call: ToolCall, result: ToolResult) => Promise<ToolResult>;
145
- /** Called when a tool call throws. Can provide a fallback result or re-throw. */
146
- readonly onToolError?: (call: ToolCall, error: Error) => Promise<ToolErrorAction>;
147
- /**
148
- * Called at the start of each iteration, before calling the LLM.
149
- * Can stop the loop or inspect state (e.g. for context trimming).
150
- */
151
- readonly onIteration?: (iteration: number, messages: ReadonlyArray<ChatMessage>, stats: {
152
- readonly totalToolCalls: number;
153
- }) => Promise<IterationAction>;
154
- }
155
- export declare function imageBlock(mimeType: string, data: string): ImageContentBlock;
156
- export declare function audioBlock(mimeType: string, data: string): AudioContentBlock;
157
- export declare function imageBlockFromDataUri(dataUri: string): ImageContentBlock;
158
- export declare function audioBlockFromDataUri(dataUri: string): AudioContentBlock;
159
- /**
160
- * Creates a user message from a prompt string or array of content blocks.
161
- */
162
- export declare function userMessage(prompt: string | ReadonlyArray<UserContentBlock>): ChatMessage;
163
- /**
164
- * Creates an assistant message from text and optional tool calls.
165
- */
166
- export declare function assistantMessage(text: string, toolCalls?: ToolCalls): ChatMessage;
167
- /**
168
- * Creates a tool message from an array of tool results.
169
- * When a result has `mediaContent`, emits content as an array of blocks
170
- * instead of a plain JSON string.
171
- */
172
- export declare function toolMessage(results: ReadonlyArray<ToolResult>): ChatMessage;
173
- /**
174
- * Extracts all ToolDefinitions from an array of ToolSources.
175
- */
176
- export declare function toolSourceDefinitions(sources: ReadonlyArray<ToolSource>): ToolDefinition[];
177
- /**
178
- * Finds the ToolSource matching a tool call name.
179
- */
180
- export declare function findToolSource(sources: ReadonlyArray<ToolSource>, name: string): ToolSource | undefined;
181
- //# sourceMappingURL=AgentTypes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AgentTypes.d.ts","sourceRoot":"","sources":["../../src/task/AgentTypes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAM9E;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ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GAAG,aAAa,CAAC,gBAAgB,CAAC,GAAG,WAAW,CAEzF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,WAAW,CAgBjF;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,WAAW,CAiB3E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,cAAc,EAAE,CAE1F;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,aAAa,CAAC,UAAU,CAAC,EAClC,IAAI,EAAE,MAAM,GACX,UAAU,GAAG,SAAS,CAExB"}
@@ -1,50 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import type { IExecuteContext } from "@workglow/task-graph";
7
- import type { ServiceRegistry } from "@workglow/util";
8
- import type { AgentHooks, ToolResult, ToolSource } from "./AgentTypes";
9
- import type { ToolCall, ToolCalls, ToolDefinition } from "./ToolCallingUtils";
10
- /**
11
- * Builds an array of {@link ToolSource} entries from a unified tools list.
12
- *
13
- * Each entry is either:
14
- * - A **string** — resolved from the TaskRegistry via {@link taskTypesToTools}.
15
- * - A **{@link ToolDefinition}** object — dispatched based on its shape:
16
- * - Has `execute` function → {@link FunctionToolSource}
17
- * - Has a backing task in the task constructors (looked up by `name`) →
18
- * {@link RegistryToolSource} with optional `config` passed through
19
- * - Otherwise → {@link FunctionToolSource} that throws on invocation
20
- *
21
- * This mirrors the model resolution pattern: strings are convenient
22
- * shorthand, objects give full control (including `config` for
23
- * configurable tasks like `McpToolCallTask` or `JavaScriptTask`).
24
- *
25
- * The original order of entries in `tools` is preserved in the returned
26
- * sources array. An optional `registry` can be provided to use a
27
- * DI-scoped constructor map instead of the global TaskRegistry.
28
- */
29
- export declare function buildToolSources(tools?: ReadonlyArray<string | ToolDefinition>, registry?: ServiceRegistry): ToolSource[];
30
- /**
31
- * Executes a single tool call by dispatching to the appropriate handler
32
- * based on the tool source type. Applies beforeToolCall, afterToolCall,
33
- * and onToolError hooks when provided.
34
- */
35
- export declare function executeToolCall(toolCall: ToolCall, sources: ReadonlyArray<ToolSource>, context: IExecuteContext, hooks?: AgentHooks): Promise<ToolResult>;
36
- /**
37
- * Executes multiple tool calls with concurrency control.
38
- *
39
- * Uses the same shared-cursor worker pool pattern as IteratorTaskRunner:
40
- * spawns N workers that pull from a shared cursor until all items are
41
- * processed. Results are returned in the original order.
42
- *
43
- * @param maxConcurrency - Max parallel tool executions (default: 5)
44
- */
45
- export declare function executeToolCalls(toolCalls: ToolCalls, sources: ReadonlyArray<ToolSource>, context: IExecuteContext, hooks?: AgentHooks, maxConcurrency?: number): Promise<ToolResult[]>;
46
- /**
47
- * Checks whether a ToolCallingTask output contains any tool calls.
48
- */
49
- export declare function hasToolCalls(toolCalls: unknown[] | undefined): boolean;
50
- //# sourceMappingURL=AgentUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AgentUtils.d.ts","sourceRoot":"","sources":["../../src/task/AgentUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,KAAK,EACV,UAAU,EAGV,UAAU,EACV,UAAU,EACX,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAM9E;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,CAAC,EAAE,aAAa,CAAC,MAAM,GAAG,cAAc,CAAC,EAC9C,QAAQ,CAAC,EAAE,eAAe,GACzB,UAAU,EAAE,CA+Dd;AAMD;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,aAAa,CAAC,UAAU,CAAC,EAClC,OAAO,EAAE,eAAe,EACxB,KAAK,CAAC,EAAE,UAAU,GACjB,OAAO,CAAC,UAAU,CAAC,CAsFrB;AAED;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,aAAa,CAAC,UAAU,CAAC,EAClC,OAAO,EAAE,eAAe,EACxB,KAAK,CAAC,EAAE,UAAU,EAClB,cAAc,GAAE,MAAU,GACzB,OAAO,CAAC,UAAU,EAAE,CAAC,CA4BvB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,SAAS,GAAG,OAAO,CAEtE"}
@@ -1,52 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- /**
7
- * Shared message conversion utilities for converting provider-agnostic
8
- * ChatMessage arrays to provider-specific formats.
9
- *
10
- * These are pure functions safe for both main-thread and worker contexts.
11
- * Providers with unique requirements (Anthropic, Gemini, LlamaCpp)
12
- * maintain their own conversion logic.
13
- */
14
- import type { ToolCallingTaskInput } from "./ToolCallingTask";
15
- export interface OpenAICompatMessage {
16
- role: string;
17
- content: string | null | Array<{
18
- type: string;
19
- [key: string]: unknown;
20
- }>;
21
- tool_calls?: Array<{
22
- id: string;
23
- type: "function";
24
- function: {
25
- name: string;
26
- arguments: string;
27
- };
28
- }>;
29
- tool_call_id?: string;
30
- }
31
- /**
32
- * Converts ToolCallingTaskInput to OpenAI-compatible message format.
33
- * Used by OpenAI and HuggingFace Inference providers.
34
- *
35
- * Multi-turn capable: preserves full tool call metadata across turns.
36
- */
37
- export declare function toOpenAIMessages(input: ToolCallingTaskInput): OpenAICompatMessage[];
38
- export interface TextFlatMessage {
39
- role: string;
40
- content: string;
41
- }
42
- /**
43
- * Converts ToolCallingTaskInput to a simplified text-only message format.
44
- * Used by providers that don't natively support structured multi-turn
45
- * tool calling (Ollama, HuggingFace Transformers).
46
- *
47
- * NOTE: This format discards tool_use blocks from assistant messages.
48
- * The LLM will not see what tools it previously called. Multi-turn tool
49
- * calling will have degraded quality on these providers.
50
- */
51
- export declare function toTextFlatMessages(input: ToolCallingTaskInput): TextFlatMessage[];
52
- //# sourceMappingURL=MessageConversion.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MessageConversion.d.ts","sourceRoot":"","sources":["../../src/task/MessageConversion.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAsB9D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC,CAAC;IACzE,UAAU,CAAC,EAAE,KAAK,CAAC;QACjB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,UAAU,CAAC;QACjB,QAAQ,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC;KAC/C,CAAC,CAAC;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,oBAAoB,GAAG,mBAAmB,EAAE,CAuInF;AAMD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,oBAAoB,GAAG,eAAe,EAAE,CAqFjF"}