opencode-acp-provider 1.0.0 → 1.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/README.md +51 -20
- package/package.json +3 -2
- package/src/acp-client.ts +236 -27
- package/src/acp-tools/antigravity.ts +117 -0
- package/src/acp-tools/claude.ts +105 -0
- package/src/acp-tools/codex.ts +204 -0
- package/src/acp-tools/command-code.ts +135 -0
- package/src/acp-tools/fallback.ts +92 -0
- package/src/acp-tools/shared.ts +436 -0
- package/src/acp-tools.ts +119 -241
- package/src/agent-command.ts +1 -1
- package/src/agent-pool.ts +448 -0
- package/src/index.ts +134 -47
- package/src/inventory.ts +14 -0
- package/src/language-model.ts +27 -13
- package/src/mcp-server.ts +142 -66
- package/src/prompt.ts +22 -5
- package/src/server-manager.ts +651 -113
- package/src/shim.ts +75 -35
- package/src/unsolicited.ts +388 -0
- package/src/mcp-config.ts +0 -198
package/src/index.ts
CHANGED
|
@@ -6,15 +6,17 @@ import { join } from "node:path"
|
|
|
6
6
|
import {
|
|
7
7
|
AcpServerManager,
|
|
8
8
|
type AcpCompactResult,
|
|
9
|
+
type AcpModelInfo,
|
|
9
10
|
type AcpServerConfig,
|
|
10
11
|
type AcpServerState,
|
|
11
12
|
type AcpSessionStore,
|
|
13
|
+
type AcpUnsolicitedTurnInfo,
|
|
12
14
|
} from "./server-manager.ts"
|
|
15
|
+
import { sharedAgentPool } from "./agent-pool.ts"
|
|
13
16
|
import { createShim } from "./shim.ts"
|
|
14
|
-
import { boundedMessages, historyLimits, recentConversation } from "./prompt.ts"
|
|
17
|
+
import { boundedMessages, historyLimits, recentConversation, textOf } from "./prompt.ts"
|
|
15
18
|
import { createAcpLanguageModel } from "./language-model.ts"
|
|
16
19
|
import { createMcpServer } from "./mcp-server.ts"
|
|
17
|
-
import { createOpenCodeMcpSource } from "./mcp-config.ts"
|
|
18
20
|
import { createSteering, type LocalService } from "./steering.ts"
|
|
19
21
|
import { createSkillMirror } from "./skills.ts"
|
|
20
22
|
import { createCommandBridge } from "./commands.ts"
|
|
@@ -87,6 +89,31 @@ function storedSessionKey(poolKey: string) {
|
|
|
87
89
|
return `acp-session/${createHash("sha256").update(poolKey).digest("hex")}`
|
|
88
90
|
}
|
|
89
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Resolve an ACP continuation token when OpenCode is running a turn prompted by
|
|
94
|
+
* a background-completion synthetic message rather than a new user prompt.
|
|
95
|
+
*/
|
|
96
|
+
function continuationTokenOf(
|
|
97
|
+
messages: ReadonlyArray<{
|
|
98
|
+
role: string
|
|
99
|
+
content?: string | ReadonlyArray<{ type?: string; text?: unknown }>
|
|
100
|
+
metadata?: Record<string, unknown>
|
|
101
|
+
}>,
|
|
102
|
+
sessionID: string,
|
|
103
|
+
manager: Pick<AcpServerManager, "findContinuationByText">,
|
|
104
|
+
): string | undefined {
|
|
105
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
106
|
+
const message = messages[i]
|
|
107
|
+
if (!message) continue
|
|
108
|
+
if (message.role === "assistant") return undefined
|
|
109
|
+
if (message.role !== "user") continue
|
|
110
|
+
const token = message.metadata?.source === "acp-background" ? message.metadata.acpContinuation : undefined
|
|
111
|
+
if (typeof token === "string" && token) return token
|
|
112
|
+
return sessionID ? manager.findContinuationByText(sessionID, textOf(message)) : undefined
|
|
113
|
+
}
|
|
114
|
+
return undefined
|
|
115
|
+
}
|
|
116
|
+
|
|
90
117
|
|
|
91
118
|
/**
|
|
92
119
|
* A `serve --service` server records its address and password next to its
|
|
@@ -171,15 +198,6 @@ export default Plugin.define({
|
|
|
171
198
|
}
|
|
172
199
|
}
|
|
173
200
|
|
|
174
|
-
// Forward the MCP servers OpenCode is configured with so a server is set up
|
|
175
|
-
// once and reaches every ACP agent, alongside this plugin's own bridge.
|
|
176
|
-
let openCodeMcp: Awaited<ReturnType<typeof createOpenCodeMcpSource>> | undefined
|
|
177
|
-
try {
|
|
178
|
-
openCodeMcp = await createOpenCodeMcpSource(ctx, log)
|
|
179
|
-
} catch (error) {
|
|
180
|
-
log("warn", `OpenCode MCP servers disabled: ${errorMessage(error)}`)
|
|
181
|
-
}
|
|
182
|
-
|
|
183
201
|
// A plugin reload or a crashed agent starts a new process with no in-memory
|
|
184
202
|
// sessions. Persist which ACP session belongs to each OpenCode session so
|
|
185
203
|
// the next process can resume it instead of losing the conversation.
|
|
@@ -201,34 +219,69 @@ export default Plugin.define({
|
|
|
201
219
|
// Assigned once the agents are up and their skills are known, but the
|
|
202
220
|
// manager reports command updates from the first `session/new` onward.
|
|
203
221
|
let commandBridge: Awaited<ReturnType<typeof createCommandBridge>> | undefined
|
|
222
|
+
const continuations = new Map<string, string>()
|
|
223
|
+
let disposed = false
|
|
224
|
+
let manager: AcpServerManager
|
|
225
|
+
let serverForProvider = new Map<string, string>()
|
|
204
226
|
|
|
205
|
-
const
|
|
227
|
+
const wakeSessionForUnsolicited = async (turn: AcpUnsolicitedTurnInfo) => {
|
|
228
|
+
if (disposed || typeof ctx.session?.synthetic !== "function") {
|
|
229
|
+
manager.dropContinuation(turn.sessionKey, turn.token)
|
|
230
|
+
return
|
|
231
|
+
}
|
|
232
|
+
try {
|
|
233
|
+
if (typeof ctx.session.get === "function") {
|
|
234
|
+
const session = await ctx.session.get({ sessionID: turn.sessionKey as any }).catch(() => undefined)
|
|
235
|
+
const providerID = session?.model?.providerID
|
|
236
|
+
if (providerID && serverForProvider.get(providerID) !== turn.server) {
|
|
237
|
+
log(
|
|
238
|
+
"debug",
|
|
239
|
+
`skipping ACP background wake for ${turn.sessionKey}: session switched to provider ${providerID}`,
|
|
240
|
+
)
|
|
241
|
+
manager.dropContinuation(turn.sessionKey, turn.token)
|
|
242
|
+
return
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
await ctx.session.synthetic({
|
|
246
|
+
sessionID: turn.sessionKey as any,
|
|
247
|
+
text: turn.text,
|
|
248
|
+
description: turn.description,
|
|
249
|
+
metadata: {
|
|
250
|
+
source: "acp-background",
|
|
251
|
+
server: turn.server,
|
|
252
|
+
acpContinuation: turn.token,
|
|
253
|
+
},
|
|
254
|
+
delivery: "queue",
|
|
255
|
+
resume: true,
|
|
256
|
+
})
|
|
257
|
+
} catch (error) {
|
|
258
|
+
log("warn", `could not wake OpenCode session ${turn.sessionKey} for ACP background task: ${errorMessage(error)}`)
|
|
259
|
+
manager.dropContinuation(turn.sessionKey, turn.token)
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
manager = new AcpServerManager({
|
|
206
264
|
servers,
|
|
207
265
|
defaultCwd: ctx.location.directory,
|
|
208
266
|
log,
|
|
209
267
|
sessions: sessionStore,
|
|
268
|
+
agents: sharedAgentPool(),
|
|
269
|
+
discoverCommands: options.commands !== false,
|
|
210
270
|
onCommands: (server) => void commandBridge?.sync(server),
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
} catch (error) {
|
|
226
|
-
lease?.release()
|
|
227
|
-
throw error
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
}
|
|
231
|
-
: undefined,
|
|
271
|
+
// A model's effort levels are learned when it is first selected; refresh its variants.
|
|
272
|
+
onModels: (server) => {
|
|
273
|
+
const state = manager.get(server)
|
|
274
|
+
if (!state || disposed || !registered.has(server)) return
|
|
275
|
+
void publishInventory(state).then(() => persistInventory(state))
|
|
276
|
+
},
|
|
277
|
+
onUnsolicited: (turn) => {
|
|
278
|
+
if (!disposed) void wakeSessionForUnsolicited(turn)
|
|
279
|
+
},
|
|
280
|
+
mcp: mcp
|
|
281
|
+
? {
|
|
282
|
+
servers: async (sessionKey) => mcp.issue(sessionKey),
|
|
283
|
+
}
|
|
284
|
+
: undefined,
|
|
232
285
|
additionalDirectories: skills ? [skills.root] : undefined,
|
|
233
286
|
cmdSkillDir: skills?.agentsDir,
|
|
234
287
|
cmdOrchestration: mcp !== undefined,
|
|
@@ -259,7 +312,6 @@ export default Plugin.define({
|
|
|
259
312
|
const outputLimit = options.outputLimit ?? 32_000
|
|
260
313
|
const shimToken = randomUUID()
|
|
261
314
|
|
|
262
|
-
let disposed = false
|
|
263
315
|
const retryTimers = new Set<ReturnType<typeof setTimeout>>()
|
|
264
316
|
const registrations: Awaited<ReturnType<typeof ctx.provider.transform>>[] = []
|
|
265
317
|
const registered = new Set<string>()
|
|
@@ -280,10 +332,12 @@ export default Plugin.define({
|
|
|
280
332
|
}
|
|
281
333
|
|
|
282
334
|
const providerModels = (state: AcpServerState, providerID: ReturnType<typeof Provider.ID.make>, inventory: AcpInventory) => {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
335
|
+
// Efforts can differ per model, and a model may offer none at all.
|
|
336
|
+
const variantsFor = (model: AcpModelInfo) =>
|
|
337
|
+
effortLevels(model.efforts ?? inventory.efforts).map((effort) => ({
|
|
338
|
+
id: Model.VariantID.make(effort),
|
|
339
|
+
settings: { reasoningEffort: effort },
|
|
340
|
+
}))
|
|
287
341
|
return inventory.models.map((model) => ({
|
|
288
342
|
...Model.Info.default(providerID, Model.ID.make(model.id)),
|
|
289
343
|
modelID: Model.ID.make(`${state.config.id}::${model.id}`),
|
|
@@ -298,7 +352,7 @@ export default Plugin.define({
|
|
|
298
352
|
output: ["text"],
|
|
299
353
|
temperature: false,
|
|
300
354
|
},
|
|
301
|
-
variants,
|
|
355
|
+
variants: variantsFor(model),
|
|
302
356
|
// The agent keeps the conversation in its reused ACP session and
|
|
303
357
|
// compacts it itself. A known window would let OpenCode auto-compact,
|
|
304
358
|
// which only spends a turn on a summary the agent never reads. OpenCode
|
|
@@ -349,7 +403,15 @@ export default Plugin.define({
|
|
|
349
403
|
if (left.models.length !== right.models.length || left.efforts.length !== right.efforts.length) return false
|
|
350
404
|
const modelsMatch = left.models.every((model, index) => {
|
|
351
405
|
const other = right.models[index]
|
|
352
|
-
return
|
|
406
|
+
return (
|
|
407
|
+
other !== undefined &&
|
|
408
|
+
model.id === other.id &&
|
|
409
|
+
model.name === other.name &&
|
|
410
|
+
model.description === other.description &&
|
|
411
|
+
model.defaultEffort === other.defaultEffort &&
|
|
412
|
+
(model.efforts ?? []).join("\u0000") === (other.efforts ?? []).join("\u0000") &&
|
|
413
|
+
(model.efforts === undefined) === (other.efforts === undefined)
|
|
414
|
+
)
|
|
353
415
|
})
|
|
354
416
|
return modelsMatch && left.efforts.every((effort, index) => effort === right.efforts[index])
|
|
355
417
|
}
|
|
@@ -446,12 +508,12 @@ export default Plugin.define({
|
|
|
446
508
|
await manager.stop().catch(() => {})
|
|
447
509
|
await mcp?.close().catch(() => {})
|
|
448
510
|
await skills?.close().catch(() => {})
|
|
449
|
-
await openCodeMcp?.close().catch(() => {})
|
|
450
511
|
throw error
|
|
451
512
|
}
|
|
452
513
|
|
|
453
514
|
const cleanup = async () => {
|
|
454
515
|
disposed = true
|
|
516
|
+
continuations.clear()
|
|
455
517
|
for (const timer of retryTimers) clearTimeout(timer)
|
|
456
518
|
retryTimers.clear()
|
|
457
519
|
for (const registration of registrations) await registration.dispose().catch(() => {})
|
|
@@ -465,7 +527,6 @@ export default Plugin.define({
|
|
|
465
527
|
await manager.stop().catch(() => {})
|
|
466
528
|
await skills?.close().catch(() => {})
|
|
467
529
|
await mcp?.close().catch(() => {})
|
|
468
|
-
await openCodeMcp?.close().catch(() => {})
|
|
469
530
|
})()
|
|
470
531
|
}
|
|
471
532
|
|
|
@@ -474,7 +535,7 @@ export default Plugin.define({
|
|
|
474
535
|
// late cannot steal the id of one that already registered.
|
|
475
536
|
for (const state of manager.list) providerIDForServer(state.config.id)
|
|
476
537
|
// Every provider id is reserved above, so this reverse map is complete.
|
|
477
|
-
|
|
538
|
+
serverForProvider = new Map([...providerIDs].map(([server, providerID]) => [providerID, server]))
|
|
478
539
|
|
|
479
540
|
// A server whose models were discovered before, in another location or an
|
|
480
541
|
// earlier process, is registered now, so this location resolves them
|
|
@@ -521,9 +582,37 @@ export default Plugin.define({
|
|
|
521
582
|
await ctx.session.hook("model.request", (event) => {
|
|
522
583
|
if (!serverForProvider.has(event.model.providerID)) return
|
|
523
584
|
event.headers["x-acp-request-kind"] = event.kind
|
|
585
|
+
if (event.kind === "primary" && event.sessionID) {
|
|
586
|
+
const token = continuations.get(event.sessionID)
|
|
587
|
+
if (token) {
|
|
588
|
+
continuations.delete(event.sessionID)
|
|
589
|
+
event.headers["x-acp-continuation"] = token
|
|
590
|
+
}
|
|
591
|
+
}
|
|
524
592
|
}),
|
|
525
593
|
)
|
|
526
594
|
const limits = historyLimits(options)
|
|
595
|
+
// Detect background continuation turns on every route, and trim fallback
|
|
596
|
+
// HTTP requests when the server cannot register an AI SDK provider.
|
|
597
|
+
registrations.push(
|
|
598
|
+
await ctx.session.hook("context", (event) => {
|
|
599
|
+
if (!serverForProvider.has(event.model.providerID)) return
|
|
600
|
+
if (event.sessionID) {
|
|
601
|
+
const token = continuationTokenOf(event.messages, event.sessionID, manager)
|
|
602
|
+
if (token) continuations.set(event.sessionID, token)
|
|
603
|
+
else continuations.delete(event.sessionID)
|
|
604
|
+
}
|
|
605
|
+
if (!nativeToolParts) {
|
|
606
|
+
const includeSystem = options.includeSystem === true
|
|
607
|
+
if (!includeSystem) event.system = []
|
|
608
|
+
const messages: typeof event.messages = []
|
|
609
|
+
for (const { message, text } of boundedMessages(event.messages, limits, includeSystem)) {
|
|
610
|
+
if (message.role !== "tool") messages.push({ ...message, content: [{ type: "text", text }] })
|
|
611
|
+
}
|
|
612
|
+
event.messages = messages
|
|
613
|
+
}
|
|
614
|
+
}),
|
|
615
|
+
)
|
|
527
616
|
if (nativeToolParts) {
|
|
528
617
|
registrations.push(
|
|
529
618
|
await ctx.aisdk.hook("sdk", (evt) => {
|
|
@@ -549,13 +638,11 @@ export default Plugin.define({
|
|
|
549
638
|
} else {
|
|
550
639
|
// The native HTTP provider serializes these messages itself. Trim
|
|
551
640
|
// its model request before that happens, without changing the transcript.
|
|
552
|
-
for (const kind of ["
|
|
641
|
+
for (const kind of ["generate", "title"] as const) {
|
|
553
642
|
registrations.push(await ctx.session.hook(kind, (event) => {
|
|
554
643
|
if (!serverForProvider.has(event.model.providerID)) return
|
|
555
|
-
const includeSystem = kind !== "context" || options.includeSystem === true
|
|
556
|
-
if (!includeSystem) event.system = []
|
|
557
644
|
const messages: typeof event.messages = []
|
|
558
|
-
for (const { message, text } of boundedMessages(event.messages, limits,
|
|
645
|
+
for (const { message, text } of boundedMessages(event.messages, limits, true)) {
|
|
559
646
|
if (message.role !== "tool") messages.push({ ...message, content: [{ type: "text", text }] })
|
|
560
647
|
}
|
|
561
648
|
event.messages = messages
|
package/src/inventory.ts
CHANGED
|
@@ -11,6 +11,14 @@ export interface AcpInventory {
|
|
|
11
11
|
efforts: string[]
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
/** Live discovery, shared by locations for the lifetime of the service. */
|
|
15
|
+
export interface AcpCatalog extends AcpInventory {
|
|
16
|
+
defaultModel?: string
|
|
17
|
+
modelConfigID?: string
|
|
18
|
+
effortConfigID?: string
|
|
19
|
+
onModels: Set<() => void>
|
|
20
|
+
}
|
|
21
|
+
|
|
14
22
|
/** Bump when the payload shape changes; an older entry is treated as a miss. */
|
|
15
23
|
const VERSION = 1
|
|
16
24
|
const MAX_MODELS = 1_000
|
|
@@ -29,6 +37,8 @@ function cacheInput(config: AcpServerConfig) {
|
|
|
29
37
|
return {
|
|
30
38
|
command: Array.isArray(config.command) ? config.command : [config.command],
|
|
31
39
|
env: Object.entries(config.env ?? {}).sort(([a], [b]) => a.localeCompare(b)),
|
|
40
|
+
...(config.meta ? { meta: config.meta } : {}),
|
|
41
|
+
...(config.setup?.trim() ? { setup: config.setup.trim() } : {}),
|
|
32
42
|
models: config.models ?? null,
|
|
33
43
|
}
|
|
34
44
|
}
|
|
@@ -62,6 +72,10 @@ export function parseInventory(value: unknown): AcpInventory | undefined {
|
|
|
62
72
|
if (typeof entry.name !== "string" || !entry.name) return undefined
|
|
63
73
|
const model: AcpModelInfo = { id: entry.id, name: entry.name }
|
|
64
74
|
if (typeof entry.description === "string" && entry.description) model.description = entry.description
|
|
75
|
+
if (Array.isArray(entry.efforts)) {
|
|
76
|
+
model.efforts = effortLevels(entry.efforts.filter((effort): effort is string => typeof effort === "string"))
|
|
77
|
+
}
|
|
78
|
+
if (typeof entry.defaultEffort === "string" && entry.defaultEffort) model.defaultEffort = entry.defaultEffort
|
|
65
79
|
models.push(model)
|
|
66
80
|
}
|
|
67
81
|
|
package/src/language-model.ts
CHANGED
|
@@ -34,6 +34,7 @@ export function createAcpLanguageModel(options: AcpLanguageModelOptions) {
|
|
|
34
34
|
async doStream(call: CallOptions) {
|
|
35
35
|
const sessionID = header(call.headers, "x-opencode-session-id")
|
|
36
36
|
const requestKind = header(call.headers, "x-acp-request-kind")
|
|
37
|
+
const continuation = header(call.headers, "x-acp-continuation")
|
|
37
38
|
options.log?.(
|
|
38
39
|
"debug",
|
|
39
40
|
`acp language model ${options.server}/${options.model} session=${sessionID ?? "-"} kind=${requestKind ?? "primary"} messages=${call.prompt?.length ?? 0}`,
|
|
@@ -49,6 +50,7 @@ export function createAcpLanguageModel(options: AcpLanguageModelOptions) {
|
|
|
49
50
|
...(options.token ? { authorization: `Bearer ${options.token}` } : {}),
|
|
50
51
|
...(sessionID ? { "x-opencode-session-id": sessionID } : {}),
|
|
51
52
|
...(requestKind ? { "x-acp-request-kind": requestKind } : {}),
|
|
53
|
+
...(continuation ? { "x-acp-continuation": continuation } : {}),
|
|
52
54
|
},
|
|
53
55
|
body: JSON.stringify({
|
|
54
56
|
model: `${options.server}::${options.model}`,
|
|
@@ -270,26 +272,34 @@ function translate(body: ReadableStream<Uint8Array>, log?: LogFn) {
|
|
|
270
272
|
const handleTool = (event: any) => {
|
|
271
273
|
if (!event || typeof event.id !== "string") return
|
|
272
274
|
const existing = tools.get(event.id)
|
|
273
|
-
|
|
275
|
+
if (existing?.settled) return
|
|
276
|
+
const incomingName = typeof event.name === "string" && event.name ? event.name : undefined
|
|
277
|
+
const name = existing?.called ? existing.name : (incomingName ?? existing?.name ?? "unknown")
|
|
274
278
|
const current: ToolProgress = existing ?? { name, started: false, called: false, settled: false }
|
|
275
279
|
if (!existing) tools.set(event.id, current)
|
|
280
|
+
if (!current.called) current.name = name
|
|
276
281
|
if (typeof event.title === "string" && event.title) current.title = event.title
|
|
277
|
-
if (typeof event.output === "string"
|
|
278
|
-
closeText()
|
|
279
|
-
closeReasoning()
|
|
280
|
-
if (!current.started) {
|
|
281
|
-
push({ type: "tool-input-start", id: event.id, toolName: name, providerExecuted: true })
|
|
282
|
-
current.started = true
|
|
283
|
-
}
|
|
282
|
+
if (typeof event.output === "string") current.output = event.output
|
|
284
283
|
const input = event.input && typeof event.input === "object" && !Array.isArray(event.input) ? event.input : {}
|
|
285
284
|
const done = event.done === true
|
|
286
285
|
const keys = Object.keys(input)
|
|
287
|
-
// Agents stream edit/write input in pieces. Wait for the actual
|
|
288
|
-
// the card is created with its diff instead of a path-only
|
|
286
|
+
// Agents stream edit/write/patch input in pieces. Wait for the actual
|
|
287
|
+
// change so the card is created with its diff instead of a path-only
|
|
288
|
+
// placeholder, and so tool-input-start commits the final tool name.
|
|
289
289
|
const partial =
|
|
290
|
-
(name === "edit" && (input.oldString === undefined || input.newString === undefined)) ||
|
|
291
|
-
(name === "write" && input.content === undefined)
|
|
292
|
-
|
|
290
|
+
(current.name === "edit" && (input.oldString === undefined || input.newString === undefined)) ||
|
|
291
|
+
(current.name === "write" && input.content === undefined) ||
|
|
292
|
+
(current.name === "patch" && input.patchText === undefined)
|
|
293
|
+
const ready = done || (keys.length > 0 && !partial)
|
|
294
|
+
if (ready) {
|
|
295
|
+
closeText()
|
|
296
|
+
closeReasoning()
|
|
297
|
+
if (!current.started) {
|
|
298
|
+
push({ type: "tool-input-start", id: event.id, toolName: current.name, providerExecuted: true })
|
|
299
|
+
current.started = true
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
if (!current.called && ready) {
|
|
293
303
|
callTool(event.id, current, input)
|
|
294
304
|
current.called = true
|
|
295
305
|
}
|
|
@@ -355,6 +365,10 @@ function translate(body: ReadableStream<Uint8Array>, log?: LogFn) {
|
|
|
355
365
|
// failed turn cannot leave a card stuck in the streaming state.
|
|
356
366
|
for (const [id, current] of tools) {
|
|
357
367
|
if (current.settled) continue
|
|
368
|
+
if (!current.started) {
|
|
369
|
+
push({ type: "tool-input-start", id, toolName: current.name, providerExecuted: true })
|
|
370
|
+
current.started = true
|
|
371
|
+
}
|
|
358
372
|
if (!current.called) {
|
|
359
373
|
callTool(id, current, {})
|
|
360
374
|
current.called = true
|