@molecule/api-ai-agents-llm 1.0.3 → 1.0.4
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/README.md +6 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +14 -5
- package/dist/types.d.ts +11 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-10-
|
|
6
|
+
Generated: 2026-10-26T04:27:09.169Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-ai-agents-llm
|
|
@@ -173,6 +173,11 @@ prefix on each of up to `maxSteps` turns. Note `onEvent` is only an
|
|
|
173
173
|
INCREMENTAL live hook while streaming — with `stream: false` it fires once
|
|
174
174
|
per turn with the whole response.
|
|
175
175
|
|
|
176
|
+
`input.thinking` forwards the core chat contract's native thinking settings
|
|
177
|
+
on every turn. Streamed reasoning is retained in `ChatMessage.reasoning`
|
|
178
|
+
across tool calls, separately from assistant text and tool arguments.
|
|
179
|
+
Omitting the option does not enable thinking or manufacture reasoning.
|
|
180
|
+
|
|
176
181
|
Failure semantics (how to tell failure modes apart):
|
|
177
182
|
|
|
178
183
|
- **Tool failure** (throwing `execute()`, unknown tool name) — NON-fatal:
|
package/dist/index.d.ts
CHANGED
|
@@ -62,6 +62,11 @@
|
|
|
62
62
|
* INCREMENTAL live hook while streaming — with `stream: false` it fires once
|
|
63
63
|
* per turn with the whole response.
|
|
64
64
|
*
|
|
65
|
+
* `input.thinking` forwards the core chat contract's native thinking settings
|
|
66
|
+
* on every turn. Streamed reasoning is retained in `ChatMessage.reasoning`
|
|
67
|
+
* across tool calls, separately from assistant text and tool arguments.
|
|
68
|
+
* Omitting the option does not enable thinking or manufacture reasoning.
|
|
69
|
+
*
|
|
65
70
|
* Failure semantics (how to tell failure modes apart):
|
|
66
71
|
* - **Tool failure** (throwing `execute()`, unknown tool name) — NON-fatal:
|
|
67
72
|
* recorded on the step with `isError: true` and fed back to the model.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -62,6 +62,11 @@
|
|
|
62
62
|
* INCREMENTAL live hook while streaming — with `stream: false` it fires once
|
|
63
63
|
* per turn with the whole response.
|
|
64
64
|
*
|
|
65
|
+
* `input.thinking` forwards the core chat contract's native thinking settings
|
|
66
|
+
* on every turn. Streamed reasoning is retained in `ChatMessage.reasoning`
|
|
67
|
+
* across tool calls, separately from assistant text and tool arguments.
|
|
68
|
+
* Omitting the option does not enable thinking or manufacture reasoning.
|
|
69
|
+
*
|
|
65
70
|
* Failure semantics (how to tell failure modes apart):
|
|
66
71
|
* - **Tool failure** (throwing `execute()`, unknown tool name) — NON-fatal:
|
|
67
72
|
* recorded on the step with `isError: true` and fed back to the model.
|
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,YAAY,CAAA;AAOnB,OAAO,KAAK,EAKV,gBAAgB,EACjB,MAAM,yBAAyB,CAAA;AAuHhC;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,gBAiLtB,CAAA"}
|
package/dist/provider.js
CHANGED
|
@@ -11,9 +11,8 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @module
|
|
13
13
|
*/
|
|
14
|
-
// Side-effect import:
|
|
15
|
-
//
|
|
16
|
-
// `input.cacheControl` below are typed, not `any`.
|
|
14
|
+
// Side-effect import: augments AgentRunInput with this bond's typed request
|
|
15
|
+
// options (see types.ts).
|
|
17
16
|
import './types.js';
|
|
18
17
|
import { getProviderByName as getAiProviderByName, requireProvider as requireAiProvider, } from '@molecule/api-ai';
|
|
19
18
|
import { t } from '@molecule/api-i18n';
|
|
@@ -66,6 +65,7 @@ function stringifyResult(result) {
|
|
|
66
65
|
*/
|
|
67
66
|
async function drainStream(stream, onEvent) {
|
|
68
67
|
let text = '';
|
|
68
|
+
let reasoning;
|
|
69
69
|
const toolUses = [];
|
|
70
70
|
const usage = { inputTokens: 0, outputTokens: 0 };
|
|
71
71
|
let errorMessage;
|
|
@@ -77,6 +77,9 @@ async function drainStream(stream, onEvent) {
|
|
|
77
77
|
case 'text':
|
|
78
78
|
text += event.content;
|
|
79
79
|
break;
|
|
80
|
+
case 'thinking':
|
|
81
|
+
reasoning = (reasoning ?? '') + event.content;
|
|
82
|
+
break;
|
|
80
83
|
case 'tool_use':
|
|
81
84
|
toolUses.push({ id: event.id, name: event.name, input: event.input });
|
|
82
85
|
break;
|
|
@@ -103,7 +106,7 @@ async function drainStream(stream, onEvent) {
|
|
|
103
106
|
if (!sawDone && lastSnapshot) {
|
|
104
107
|
addUsage(usage, lastSnapshot);
|
|
105
108
|
}
|
|
106
|
-
return { text, toolUses, usage, errorMessage };
|
|
109
|
+
return { text, reasoning, toolUses, usage, errorMessage };
|
|
107
110
|
}
|
|
108
111
|
/**
|
|
109
112
|
* The LLM-backed AI agents provider: a tool-calling loop over the bonded `ai`
|
|
@@ -158,6 +161,8 @@ export const provider = {
|
|
|
158
161
|
model: input.model,
|
|
159
162
|
maxTokens: input.maxTokens,
|
|
160
163
|
temperature: input.temperature,
|
|
164
|
+
// Keep the caller's native thinking settings on every tool turn.
|
|
165
|
+
...(input.thinking === undefined ? {} : { thinking: input.thinking }),
|
|
161
166
|
// Defaults to streaming (see the `stream` augmentation in
|
|
162
167
|
// types.ts): onEvent is a LIVE hook, and non-streaming requests
|
|
163
168
|
// with large outputs (a big tool input at a raised maxTokens) are
|
|
@@ -194,7 +199,11 @@ export const provider = {
|
|
|
194
199
|
for (const tu of turn.toolUses) {
|
|
195
200
|
assistantContent.push({ type: 'tool_use', id: tu.id, name: tu.name, input: tu.input });
|
|
196
201
|
}
|
|
197
|
-
messages.push({
|
|
202
|
+
messages.push({
|
|
203
|
+
role: 'assistant',
|
|
204
|
+
content: assistantContent,
|
|
205
|
+
...(turn.reasoning === undefined ? {} : { reasoning: turn.reasoning }),
|
|
206
|
+
});
|
|
198
207
|
if (turn.toolUses.length === 0) {
|
|
199
208
|
// No tools requested — the model is done.
|
|
200
209
|
return { output: turn.text, steps, usage };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Module augmentation: extends the core `@molecule/api-ai-agents` contract's
|
|
3
|
-
* `AgentRunInput` with
|
|
3
|
+
* `AgentRunInput` with options this bond's `run()` honors.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
*
|
|
6
|
+
* These fields are ADDITIVE ONLY — they never widen or erase an existing
|
|
7
7
|
* `AgentRunInput` field — and are consumed exclusively by this bond's `run()`
|
|
8
8
|
* implementation; a different `AIAgentsProvider` bond is free to ignore them.
|
|
9
9
|
* Any file that imports `@molecule/api-ai-agents-llm` (directly, or
|
|
10
10
|
* transitively by bonding its `provider`) sees the merged `AgentRunInput`
|
|
11
11
|
* type, matching the shape `@molecule/api-ai`'s `ChatParams` already accepts
|
|
12
|
-
* for `stream` and `
|
|
12
|
+
* for `stream`, `cacheControl`, and `thinking`.
|
|
13
13
|
*
|
|
14
14
|
* @module
|
|
15
15
|
*/
|
|
16
16
|
import '@molecule/api-ai-agents';
|
|
17
|
+
import type { ChatParams } from '@molecule/api-ai';
|
|
17
18
|
declare module '@molecule/api-ai-agents' {
|
|
18
19
|
interface AgentRunInput {
|
|
20
|
+
/**
|
|
21
|
+
* Native thinking settings forwarded unchanged on every model turn.
|
|
22
|
+
* Streamed thinking is retained as `ChatMessage.reasoning` when a tool
|
|
23
|
+
* call continues, so providers that replay reasoning receive it intact.
|
|
24
|
+
* Omitting this option does not enable thinking.
|
|
25
|
+
*/
|
|
26
|
+
thinking?: ChatParams['thinking'];
|
|
19
27
|
/**
|
|
20
28
|
* Whether each model turn streams its response (default `true`).
|
|
21
29
|
*
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,yBAAyB,CAAA;AAEhC,OAAO,QAAQ,yBAAyB,CAAC;IACvC,UAAU,aAAa;QACrB;;;;;;;;;;;;;;WAcG;QACH,MAAM,CAAC,EAAE,OAAO,CAAA;QAChB;;;;;;WAMG;QACH,YAAY,CAAC,EAAE;YAAE,IAAI,EAAE,WAAW,CAAA;SAAE,CAAA;KACrC;CACF"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,OAAO,QAAQ,yBAAyB,CAAC;IACvC,UAAU,aAAa;QACrB;;;;;WAKG;QACH,QAAQ,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAA;QACjC;;;;;;;;;;;;;;WAcG;QACH,MAAM,CAAC,EAAE,OAAO,CAAA;QAChB;;;;;;WAMG;QACH,YAAY,CAAC,EAAE;YAAE,IAAI,EAAE,WAAW,CAAA;SAAE,CAAA;KACrC;CACF"}
|
package/dist/types.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Module augmentation: extends the core `@molecule/api-ai-agents` contract's
|
|
3
|
-
* `AgentRunInput` with
|
|
3
|
+
* `AgentRunInput` with options this bond's `run()` honors.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
*
|
|
6
|
+
* These fields are ADDITIVE ONLY — they never widen or erase an existing
|
|
7
7
|
* `AgentRunInput` field — and are consumed exclusively by this bond's `run()`
|
|
8
8
|
* implementation; a different `AIAgentsProvider` bond is free to ignore them.
|
|
9
9
|
* Any file that imports `@molecule/api-ai-agents-llm` (directly, or
|
|
10
10
|
* transitively by bonding its `provider`) sees the merged `AgentRunInput`
|
|
11
11
|
* type, matching the shape `@molecule/api-ai`'s `ChatParams` already accepts
|
|
12
|
-
* for `stream` and `
|
|
12
|
+
* for `stream`, `cacheControl`, and `thinking`.
|
|
13
13
|
*
|
|
14
14
|
* @module
|
|
15
15
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/api-ai-agents-llm",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "LLM-backed AI agents provider for molecule.dev — a tool-calling loop over the swappable @molecule/api-ai chat bond",
|
|
5
5
|
"homepage": "https://www.molecule.dev/packages/api-ai-agents-llm",
|
|
6
6
|
"type": "module",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"@molecule/api-i18n": "^1.0.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@molecule/api-ai": "1.
|
|
44
|
+
"@molecule/api-ai": "1.4.0",
|
|
45
45
|
"@molecule/api-ai-agents": "1.0.3",
|
|
46
|
-
"@molecule/api-bond": "1.0.
|
|
47
|
-
"@molecule/api-i18n": "1.0.
|
|
46
|
+
"@molecule/api-bond": "1.0.4",
|
|
47
|
+
"@molecule/api-i18n": "1.0.5",
|
|
48
48
|
"@types/node": "26.6.5",
|
|
49
49
|
"typescript": "6.0.3",
|
|
50
50
|
"vitest": "4.1.12"
|