@nextclaw/ncp-agent-runtime 0.1.0 → 0.1.1
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.js +7 -7
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -162,7 +162,7 @@ function* emitReasoningDelta(delta, ctx) {
|
|
|
162
162
|
if (typeof reasoning !== "string" || !reasoning) return;
|
|
163
163
|
yield { type: NcpEventType.MessageReasoningDelta, payload: { ...ctx, delta: reasoning } };
|
|
164
164
|
}
|
|
165
|
-
function* emitToolCallDeltas(delta, buffers,
|
|
165
|
+
function* emitToolCallDeltas(delta, buffers, ctx) {
|
|
166
166
|
const toolDeltas = delta.tool_calls;
|
|
167
167
|
if (!Array.isArray(toolDeltas)) return;
|
|
168
168
|
for (const toolDelta of toolDeltas) {
|
|
@@ -172,7 +172,7 @@ function* emitToolCallDeltas(delta, buffers, sessionId) {
|
|
|
172
172
|
if (current.id && current.name && !current.emittedStart) {
|
|
173
173
|
yield {
|
|
174
174
|
type: NcpEventType.MessageToolCallStart,
|
|
175
|
-
payload: {
|
|
175
|
+
payload: { ...ctx, toolCallId: current.id, toolName: current.name }
|
|
176
176
|
};
|
|
177
177
|
buffers.set(index, { ...current, emittedStart: true });
|
|
178
178
|
} else {
|
|
@@ -180,17 +180,17 @@ function* emitToolCallDeltas(delta, buffers, sessionId) {
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
function* flushToolCalls(buffers,
|
|
183
|
+
function* flushToolCalls(buffers, ctx) {
|
|
184
184
|
const ordered = Array.from(buffers.entries()).sort(([a], [b]) => a - b);
|
|
185
185
|
for (const [, buf] of ordered) {
|
|
186
186
|
if (!buf.id || !buf.name) continue;
|
|
187
187
|
yield {
|
|
188
188
|
type: NcpEventType.MessageToolCallArgs,
|
|
189
|
-
payload: {
|
|
189
|
+
payload: { ...ctx, toolCallId: buf.id, args: buf.argumentsText }
|
|
190
190
|
};
|
|
191
191
|
yield {
|
|
192
192
|
type: NcpEventType.MessageToolCallEnd,
|
|
193
|
-
payload: {
|
|
193
|
+
payload: { ...ctx, toolCallId: buf.id }
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
196
|
}
|
|
@@ -209,11 +209,11 @@ var DefaultNcpStreamEncoder = class {
|
|
|
209
209
|
const nextState = yield* emitTextDeltas(delta, { sessionId, messageId }, state);
|
|
210
210
|
state = nextState;
|
|
211
211
|
yield* emitReasoningDelta(delta, { sessionId, messageId });
|
|
212
|
-
yield* emitToolCallDeltas(delta, toolCallBuffers, sessionId);
|
|
212
|
+
yield* emitToolCallDeltas(delta, toolCallBuffers, { sessionId, messageId });
|
|
213
213
|
}
|
|
214
214
|
const finishReason = choice.finish_reason;
|
|
215
215
|
if (typeof finishReason === "string" && finishReason.trim().length > 0) {
|
|
216
|
-
yield* flushToolCalls(toolCallBuffers, sessionId);
|
|
216
|
+
yield* flushToolCalls(toolCallBuffers, { sessionId, messageId });
|
|
217
217
|
if (state.textStarted) {
|
|
218
218
|
yield { type: NcpEventType2.MessageTextEnd, payload: { sessionId, messageId } };
|
|
219
219
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/ncp-agent-runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Default agent runtime implementation built on NCP interfaces.",
|
|
6
6
|
"type": "module",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@nextclaw/ncp": "0.
|
|
18
|
+
"@nextclaw/ncp": "0.2.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/node": "^20.17.6",
|