@dudousxd/nestjs-agent-opencode 0.4.0 → 0.4.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 +10 -3
- package/dist/durable/index.cjs +261 -12
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +3 -2
- package/dist/durable/index.d.ts +3 -2
- package/dist/durable/index.js +261 -12
- package/dist/durable/index.js.map +1 -1
- package/dist/{engine-BNNxQAFV.d.cts → engine-BX6MLzxs.d.cts} +102 -8
- package/dist/{engine-BNNxQAFV.d.ts → engine-BX6MLzxs.d.ts} +102 -8
- package/dist/index.cjs +257 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +256 -10
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -18,6 +18,10 @@ interface OpenCodeClient {
|
|
|
18
18
|
sessionID: string;
|
|
19
19
|
text: string;
|
|
20
20
|
files?: OpenCodePromptFile[];
|
|
21
|
+
/** Kept on the user message OpenCode records (the engine puts the run id there). */
|
|
22
|
+
metadata?: {
|
|
23
|
+
readonly [key: string]: OpenCodeJson;
|
|
24
|
+
};
|
|
21
25
|
}): Promise<unknown>;
|
|
22
26
|
/** Stops the running execution; OpenCode answers with `session.execution.interrupted`. */
|
|
23
27
|
interrupt(args: {
|
|
@@ -87,17 +91,22 @@ interface OpenCodeClient {
|
|
|
87
91
|
message?: string;
|
|
88
92
|
}): Promise<unknown>;
|
|
89
93
|
};
|
|
90
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* The session's messages, newest first with `order: 'desc'`, a page at a time (`cursor.next`).
|
|
96
|
+
* Optional: rewinds a session (regenerate), and lets a turn resumed after a restart recover what
|
|
97
|
+
* the session said while nobody listened.
|
|
98
|
+
*/
|
|
91
99
|
message?: {
|
|
92
100
|
list(args: {
|
|
93
101
|
sessionID: string;
|
|
94
102
|
order?: 'asc' | 'desc';
|
|
95
103
|
limit?: number;
|
|
104
|
+
cursor?: string;
|
|
96
105
|
}): Promise<{
|
|
97
|
-
data:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
106
|
+
data: OpenCodeMessage[];
|
|
107
|
+
cursor?: {
|
|
108
|
+
next?: string | null;
|
|
109
|
+
};
|
|
101
110
|
}>;
|
|
102
111
|
};
|
|
103
112
|
/** Register an MCP server at a location. Optional (exposing the module's tools). */
|
|
@@ -217,6 +226,39 @@ interface OpenCodeTokens {
|
|
|
217
226
|
write: number;
|
|
218
227
|
};
|
|
219
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* One of a session's messages, as `message.list` returns them — the fields the engine reads. A
|
|
231
|
+
* `user` message carries the prompt (`text`, `metadata`); an `assistant` message is one model step
|
|
232
|
+
* (`content`, `model`, `tokens`, `cost`, `error`); `idle` marks where an execution ended (`outcome`).
|
|
233
|
+
*/
|
|
234
|
+
interface OpenCodeMessage {
|
|
235
|
+
id: string;
|
|
236
|
+
type: string;
|
|
237
|
+
metadata?: {
|
|
238
|
+
readonly [key: string]: OpenCodeJson;
|
|
239
|
+
};
|
|
240
|
+
text?: string;
|
|
241
|
+
content?: OpenCodeMessagePart[];
|
|
242
|
+
model?: {
|
|
243
|
+
providerID: string;
|
|
244
|
+
id: string;
|
|
245
|
+
};
|
|
246
|
+
cost?: number;
|
|
247
|
+
tokens?: OpenCodeTokens;
|
|
248
|
+
error?: {
|
|
249
|
+
message?: string;
|
|
250
|
+
};
|
|
251
|
+
outcome?: string;
|
|
252
|
+
}
|
|
253
|
+
/** A part of an assistant message: its text, its reasoning, or a tool call and how it went. */
|
|
254
|
+
interface OpenCodeMessagePart {
|
|
255
|
+
type: string;
|
|
256
|
+
text?: string;
|
|
257
|
+
id?: string;
|
|
258
|
+
name?: string;
|
|
259
|
+
/** A tool call's `{ status, input, error }` (a text part's is the provider's own: ignored). */
|
|
260
|
+
state?: unknown;
|
|
261
|
+
}
|
|
220
262
|
|
|
221
263
|
/** How an OpenCode execution ended. */
|
|
222
264
|
type TurnOutcome = {
|
|
@@ -263,6 +305,24 @@ interface OpenCodeUsage {
|
|
|
263
305
|
declare function emptyUsage(): OpenCodeUsage;
|
|
264
306
|
/** `a + b`; a missing side (a milestone journaled before usage travelled) counts as nothing. */
|
|
265
307
|
declare function addUsage(a: OpenCodeUsage | undefined, b: OpenCodeUsage | undefined): OpenCodeUsage;
|
|
308
|
+
/**
|
|
309
|
+
* What a turn took from the session's assistant messages (by OpenCode message id), so a turn rebuilt
|
|
310
|
+
* after a restart takes only the rest. Journaled with every `ask` milestone: what was taken up to
|
|
311
|
+
* there is persisted (the message the ask hangs on) and its usage reported.
|
|
312
|
+
*/
|
|
313
|
+
interface TurnProgress {
|
|
314
|
+
/** Characters of text taken, per assistant message. */
|
|
315
|
+
text: Record<string, number>;
|
|
316
|
+
/** Characters of reasoning taken, per assistant message. */
|
|
317
|
+
reasoning: Record<string, number>;
|
|
318
|
+
/** Tool calls taken (OpenCode's call ids), and those whose result was taken too. */
|
|
319
|
+
called: string[];
|
|
320
|
+
settled: string[];
|
|
321
|
+
/** Assistant messages whose step's usage was counted. */
|
|
322
|
+
steps: string[];
|
|
323
|
+
}
|
|
324
|
+
/** What a turn says when it was rebuilt after a restart and the session left no answer for it. */
|
|
325
|
+
declare const LOST_ANSWER_ERROR = "The answer was lost while the agent restarted; ask again.";
|
|
266
326
|
/** The model a step ran on, as OpenCode names it (`session.step.started`). */
|
|
267
327
|
interface StepModel {
|
|
268
328
|
providerID: string;
|
|
@@ -283,6 +343,7 @@ type Milestone = {
|
|
|
283
343
|
ask: PendingAsk;
|
|
284
344
|
timeoutMs?: number;
|
|
285
345
|
usage?: OpenCodeUsage;
|
|
346
|
+
progress?: TurnProgress;
|
|
286
347
|
} | {
|
|
287
348
|
kind: 'finished';
|
|
288
349
|
outcome: TurnOutcome;
|
|
@@ -319,6 +380,14 @@ interface OpenCodeTurnArgs {
|
|
|
319
380
|
}) => Promise<StepCost>;
|
|
320
381
|
/** What the run spent before this turn object existed (an earlier process, an earlier session). */
|
|
321
382
|
carried?: OpenCodeUsage;
|
|
383
|
+
/** What the turn took before this turn object existed (the last `ask` milestone's progress). */
|
|
384
|
+
progress?: TurnProgress;
|
|
385
|
+
/**
|
|
386
|
+
* Rebuilt in a process that was not listening while the session ran (a durable `observe` re-run
|
|
387
|
+
* after a restart): when the execution ends, what the session said in between is read back from
|
|
388
|
+
* its messages.
|
|
389
|
+
*/
|
|
390
|
+
resumed?: boolean;
|
|
322
391
|
logger: Logger;
|
|
323
392
|
/**
|
|
324
393
|
* An action OpenCode was allowed to run (a person approved it, or the policy did): the approval
|
|
@@ -377,6 +446,8 @@ declare class OpenCodeTurn {
|
|
|
377
446
|
private wroteMessage;
|
|
378
447
|
private ended;
|
|
379
448
|
private stepError;
|
|
449
|
+
/** What this turn object took from the session's assistant messages (see {@link TurnProgress}). */
|
|
450
|
+
private readonly took;
|
|
380
451
|
constructor(a: OpenCodeTurnArgs);
|
|
381
452
|
/**
|
|
382
453
|
* What the session had spent before this turn prompted it (`session.get`). When the execution
|
|
@@ -388,6 +459,8 @@ declare class OpenCodeTurn {
|
|
|
388
459
|
cost?: number;
|
|
389
460
|
tokens?: OpenCodeTokens;
|
|
390
461
|
} | undefined): void;
|
|
462
|
+
/** What the turn took so far: carried from before this turn object, plus what it took. */
|
|
463
|
+
progress(): TurnProgress;
|
|
391
464
|
/** What the run spent so far: carried from before this turn object, plus what it saw. */
|
|
392
465
|
totalUsage(): OpenCodeUsage;
|
|
393
466
|
get sessionId(): string;
|
|
@@ -431,6 +504,8 @@ declare class OpenCodeTurn {
|
|
|
431
504
|
private setInput;
|
|
432
505
|
private innerCalls;
|
|
433
506
|
private onEvent;
|
|
507
|
+
/** Characters taken from an assistant message's text or reasoning. */
|
|
508
|
+
private count;
|
|
434
509
|
private settleTool;
|
|
435
510
|
private modelId;
|
|
436
511
|
/** One model call's usage and cost, into the ledger and the run's total. */
|
|
@@ -456,6 +531,23 @@ declare class OpenCodeTurn {
|
|
|
456
531
|
private addResult;
|
|
457
532
|
/** What the session spent since the baseline that no event of this turn reported. */
|
|
458
533
|
private unreported;
|
|
534
|
+
/**
|
|
535
|
+
* The session's messages since this turn's prompt, oldest first: everything after its newest user
|
|
536
|
+
* message. `undefined` when they cannot be read (no `message.list`, no prompt within reach); empty
|
|
537
|
+
* when the newest prompt is another run's (this turn's never reached the session).
|
|
538
|
+
*/
|
|
539
|
+
private messagesSincePrompt;
|
|
540
|
+
/**
|
|
541
|
+
* A turn rebuilt after a restart heard only what the session said once it re-attached: what it
|
|
542
|
+
* said in between — read back from the session's messages since the prompt, less what an earlier
|
|
543
|
+
* process already took ({@link TurnProgress}) and what this one heard — is taken now, as its
|
|
544
|
+
* events would have been: text, reasoning, tool calls and results, each step's usage. A session
|
|
545
|
+
* that left nothing for the turn fails it ({@link LOST_ANSWER_ERROR}) rather than reading as an
|
|
546
|
+
* empty answer.
|
|
547
|
+
*/
|
|
548
|
+
private recover;
|
|
549
|
+
/** A tool part of a message the turn did not hear: its call, its result, whichever it lacks. */
|
|
550
|
+
private missedTool;
|
|
459
551
|
private end;
|
|
460
552
|
}
|
|
461
553
|
/**
|
|
@@ -928,14 +1020,16 @@ declare class OpenCodeTurns implements OnApplicationShutdown {
|
|
|
928
1020
|
*
|
|
929
1021
|
* `spent` is what the run spent before (the sum of the `usage` of its earlier milestones): a turn
|
|
930
1022
|
* rebuilt here starts from it, so the answer it persists carries the whole run's usage.
|
|
1023
|
+
* `progress` is what the turn took before (its last `ask` milestone's): a turn rebuilt here reads
|
|
1024
|
+
* back from the session's messages, when the execution ends, what nobody heard after that.
|
|
931
1025
|
*/
|
|
932
|
-
observe(runId: string, input: AgentRunInput, handle: SessionHandle, spent?: OpenCodeUsage): Promise<Milestone>;
|
|
1026
|
+
observe(runId: string, input: AgentRunInput, handle: SessionHandle, spent?: OpenCodeUsage, progress?: TurnProgress): Promise<Milestone>;
|
|
933
1027
|
/**
|
|
934
1028
|
* Hand a person's answer back to OpenCode. When the server restarted while the turn waited, the
|
|
935
1029
|
* request is gone with it: a new session is opened, told what the person decided, and prompted
|
|
936
1030
|
* to go on.
|
|
937
1031
|
*/
|
|
938
|
-
reply(runId: string, input: AgentRunInput, handle: SessionHandle, ask: PendingAsk, reply: HumanReply, spent?: OpenCodeUsage): Promise<SessionHandle>;
|
|
1032
|
+
reply(runId: string, input: AgentRunInput, handle: SessionHandle, ask: PendingAsk, reply: HumanReply, spent?: OpenCodeUsage, progress?: TurnProgress): Promise<SessionHandle>;
|
|
939
1033
|
private continueAfterRestart;
|
|
940
1034
|
/** What a session spent so far (`session.get`), or nothing when OpenCode does not say. */
|
|
941
1035
|
private sessionUsage;
|
|
@@ -1000,4 +1094,4 @@ declare function openCodeControllers(options: OpenCodeEngineSettings): Type<obje
|
|
|
1000
1094
|
/** The providers every OpenCode engine needs: host, session store, settings and the turn steps. */
|
|
1001
1095
|
declare function openCodeProviders(options: OpenCodeEngineOptions): Provider[];
|
|
1002
1096
|
|
|
1003
|
-
export {
|
|
1097
|
+
export { type OpenCodeToolsOptions as A, OpenCodeToolsTokens as B, OpenCodeTurn as C, type OpenCodeTurnContext as D, type OpenCodeUsage as E, type StepCost as F, type StepModel as G, type TurnProgress as H, InMemoryOpenCodeSessionStore as I, addUsage as J, emptyUsage as K, LOST_ANSWER_ERROR as L, type Milestone as M, keyValueOpenCodeSessionStore as N, OpenCodeTurns as O, type PendingAsk as P, openCode as Q, openCodeControllers as R, type SessionHandle as S, type TurnOutcome as T, openCodeProviders as U, usageOf as V, type OpenCodeEngineSettings as a, type OpenCodeHost as b, type OpenCodeEngineOptions as c, type OpenCodeClient as d, type OpenCodeEvent as e, type OpenCodeForm as f, type OpenCodeFormValue as g, type OpenCodeFormField as h, OpenCodeMcpEndpoint as i, type OpenCodeAmendment as j, type OpenCodeCallContext as k, type OpenCodeKeyValue as l, type OpenCodeMessage as m, type OpenCodeMessagePart as n, type OpenCodeModelRef as o, type OpenCodePermissionRequest as p, type OpenCodePermissionRule as q, OpenCodeReplyMismatchError as r, type OpenCodeRunResult as s, type OpenCodeServer as t, type OpenCodeSessionCreate as u, type OpenCodeSessionRef as v, type OpenCodeSessionStore as w, type OpenCodeToolCall as x, OpenCodeToolRefusedError as y, type OpenCodeToolsClaims as z };
|
|
@@ -18,6 +18,10 @@ interface OpenCodeClient {
|
|
|
18
18
|
sessionID: string;
|
|
19
19
|
text: string;
|
|
20
20
|
files?: OpenCodePromptFile[];
|
|
21
|
+
/** Kept on the user message OpenCode records (the engine puts the run id there). */
|
|
22
|
+
metadata?: {
|
|
23
|
+
readonly [key: string]: OpenCodeJson;
|
|
24
|
+
};
|
|
21
25
|
}): Promise<unknown>;
|
|
22
26
|
/** Stops the running execution; OpenCode answers with `session.execution.interrupted`. */
|
|
23
27
|
interrupt(args: {
|
|
@@ -87,17 +91,22 @@ interface OpenCodeClient {
|
|
|
87
91
|
message?: string;
|
|
88
92
|
}): Promise<unknown>;
|
|
89
93
|
};
|
|
90
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* The session's messages, newest first with `order: 'desc'`, a page at a time (`cursor.next`).
|
|
96
|
+
* Optional: rewinds a session (regenerate), and lets a turn resumed after a restart recover what
|
|
97
|
+
* the session said while nobody listened.
|
|
98
|
+
*/
|
|
91
99
|
message?: {
|
|
92
100
|
list(args: {
|
|
93
101
|
sessionID: string;
|
|
94
102
|
order?: 'asc' | 'desc';
|
|
95
103
|
limit?: number;
|
|
104
|
+
cursor?: string;
|
|
96
105
|
}): Promise<{
|
|
97
|
-
data:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
106
|
+
data: OpenCodeMessage[];
|
|
107
|
+
cursor?: {
|
|
108
|
+
next?: string | null;
|
|
109
|
+
};
|
|
101
110
|
}>;
|
|
102
111
|
};
|
|
103
112
|
/** Register an MCP server at a location. Optional (exposing the module's tools). */
|
|
@@ -217,6 +226,39 @@ interface OpenCodeTokens {
|
|
|
217
226
|
write: number;
|
|
218
227
|
};
|
|
219
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* One of a session's messages, as `message.list` returns them — the fields the engine reads. A
|
|
231
|
+
* `user` message carries the prompt (`text`, `metadata`); an `assistant` message is one model step
|
|
232
|
+
* (`content`, `model`, `tokens`, `cost`, `error`); `idle` marks where an execution ended (`outcome`).
|
|
233
|
+
*/
|
|
234
|
+
interface OpenCodeMessage {
|
|
235
|
+
id: string;
|
|
236
|
+
type: string;
|
|
237
|
+
metadata?: {
|
|
238
|
+
readonly [key: string]: OpenCodeJson;
|
|
239
|
+
};
|
|
240
|
+
text?: string;
|
|
241
|
+
content?: OpenCodeMessagePart[];
|
|
242
|
+
model?: {
|
|
243
|
+
providerID: string;
|
|
244
|
+
id: string;
|
|
245
|
+
};
|
|
246
|
+
cost?: number;
|
|
247
|
+
tokens?: OpenCodeTokens;
|
|
248
|
+
error?: {
|
|
249
|
+
message?: string;
|
|
250
|
+
};
|
|
251
|
+
outcome?: string;
|
|
252
|
+
}
|
|
253
|
+
/** A part of an assistant message: its text, its reasoning, or a tool call and how it went. */
|
|
254
|
+
interface OpenCodeMessagePart {
|
|
255
|
+
type: string;
|
|
256
|
+
text?: string;
|
|
257
|
+
id?: string;
|
|
258
|
+
name?: string;
|
|
259
|
+
/** A tool call's `{ status, input, error }` (a text part's is the provider's own: ignored). */
|
|
260
|
+
state?: unknown;
|
|
261
|
+
}
|
|
220
262
|
|
|
221
263
|
/** How an OpenCode execution ended. */
|
|
222
264
|
type TurnOutcome = {
|
|
@@ -263,6 +305,24 @@ interface OpenCodeUsage {
|
|
|
263
305
|
declare function emptyUsage(): OpenCodeUsage;
|
|
264
306
|
/** `a + b`; a missing side (a milestone journaled before usage travelled) counts as nothing. */
|
|
265
307
|
declare function addUsage(a: OpenCodeUsage | undefined, b: OpenCodeUsage | undefined): OpenCodeUsage;
|
|
308
|
+
/**
|
|
309
|
+
* What a turn took from the session's assistant messages (by OpenCode message id), so a turn rebuilt
|
|
310
|
+
* after a restart takes only the rest. Journaled with every `ask` milestone: what was taken up to
|
|
311
|
+
* there is persisted (the message the ask hangs on) and its usage reported.
|
|
312
|
+
*/
|
|
313
|
+
interface TurnProgress {
|
|
314
|
+
/** Characters of text taken, per assistant message. */
|
|
315
|
+
text: Record<string, number>;
|
|
316
|
+
/** Characters of reasoning taken, per assistant message. */
|
|
317
|
+
reasoning: Record<string, number>;
|
|
318
|
+
/** Tool calls taken (OpenCode's call ids), and those whose result was taken too. */
|
|
319
|
+
called: string[];
|
|
320
|
+
settled: string[];
|
|
321
|
+
/** Assistant messages whose step's usage was counted. */
|
|
322
|
+
steps: string[];
|
|
323
|
+
}
|
|
324
|
+
/** What a turn says when it was rebuilt after a restart and the session left no answer for it. */
|
|
325
|
+
declare const LOST_ANSWER_ERROR = "The answer was lost while the agent restarted; ask again.";
|
|
266
326
|
/** The model a step ran on, as OpenCode names it (`session.step.started`). */
|
|
267
327
|
interface StepModel {
|
|
268
328
|
providerID: string;
|
|
@@ -283,6 +343,7 @@ type Milestone = {
|
|
|
283
343
|
ask: PendingAsk;
|
|
284
344
|
timeoutMs?: number;
|
|
285
345
|
usage?: OpenCodeUsage;
|
|
346
|
+
progress?: TurnProgress;
|
|
286
347
|
} | {
|
|
287
348
|
kind: 'finished';
|
|
288
349
|
outcome: TurnOutcome;
|
|
@@ -319,6 +380,14 @@ interface OpenCodeTurnArgs {
|
|
|
319
380
|
}) => Promise<StepCost>;
|
|
320
381
|
/** What the run spent before this turn object existed (an earlier process, an earlier session). */
|
|
321
382
|
carried?: OpenCodeUsage;
|
|
383
|
+
/** What the turn took before this turn object existed (the last `ask` milestone's progress). */
|
|
384
|
+
progress?: TurnProgress;
|
|
385
|
+
/**
|
|
386
|
+
* Rebuilt in a process that was not listening while the session ran (a durable `observe` re-run
|
|
387
|
+
* after a restart): when the execution ends, what the session said in between is read back from
|
|
388
|
+
* its messages.
|
|
389
|
+
*/
|
|
390
|
+
resumed?: boolean;
|
|
322
391
|
logger: Logger;
|
|
323
392
|
/**
|
|
324
393
|
* An action OpenCode was allowed to run (a person approved it, or the policy did): the approval
|
|
@@ -377,6 +446,8 @@ declare class OpenCodeTurn {
|
|
|
377
446
|
private wroteMessage;
|
|
378
447
|
private ended;
|
|
379
448
|
private stepError;
|
|
449
|
+
/** What this turn object took from the session's assistant messages (see {@link TurnProgress}). */
|
|
450
|
+
private readonly took;
|
|
380
451
|
constructor(a: OpenCodeTurnArgs);
|
|
381
452
|
/**
|
|
382
453
|
* What the session had spent before this turn prompted it (`session.get`). When the execution
|
|
@@ -388,6 +459,8 @@ declare class OpenCodeTurn {
|
|
|
388
459
|
cost?: number;
|
|
389
460
|
tokens?: OpenCodeTokens;
|
|
390
461
|
} | undefined): void;
|
|
462
|
+
/** What the turn took so far: carried from before this turn object, plus what it took. */
|
|
463
|
+
progress(): TurnProgress;
|
|
391
464
|
/** What the run spent so far: carried from before this turn object, plus what it saw. */
|
|
392
465
|
totalUsage(): OpenCodeUsage;
|
|
393
466
|
get sessionId(): string;
|
|
@@ -431,6 +504,8 @@ declare class OpenCodeTurn {
|
|
|
431
504
|
private setInput;
|
|
432
505
|
private innerCalls;
|
|
433
506
|
private onEvent;
|
|
507
|
+
/** Characters taken from an assistant message's text or reasoning. */
|
|
508
|
+
private count;
|
|
434
509
|
private settleTool;
|
|
435
510
|
private modelId;
|
|
436
511
|
/** One model call's usage and cost, into the ledger and the run's total. */
|
|
@@ -456,6 +531,23 @@ declare class OpenCodeTurn {
|
|
|
456
531
|
private addResult;
|
|
457
532
|
/** What the session spent since the baseline that no event of this turn reported. */
|
|
458
533
|
private unreported;
|
|
534
|
+
/**
|
|
535
|
+
* The session's messages since this turn's prompt, oldest first: everything after its newest user
|
|
536
|
+
* message. `undefined` when they cannot be read (no `message.list`, no prompt within reach); empty
|
|
537
|
+
* when the newest prompt is another run's (this turn's never reached the session).
|
|
538
|
+
*/
|
|
539
|
+
private messagesSincePrompt;
|
|
540
|
+
/**
|
|
541
|
+
* A turn rebuilt after a restart heard only what the session said once it re-attached: what it
|
|
542
|
+
* said in between — read back from the session's messages since the prompt, less what an earlier
|
|
543
|
+
* process already took ({@link TurnProgress}) and what this one heard — is taken now, as its
|
|
544
|
+
* events would have been: text, reasoning, tool calls and results, each step's usage. A session
|
|
545
|
+
* that left nothing for the turn fails it ({@link LOST_ANSWER_ERROR}) rather than reading as an
|
|
546
|
+
* empty answer.
|
|
547
|
+
*/
|
|
548
|
+
private recover;
|
|
549
|
+
/** A tool part of a message the turn did not hear: its call, its result, whichever it lacks. */
|
|
550
|
+
private missedTool;
|
|
459
551
|
private end;
|
|
460
552
|
}
|
|
461
553
|
/**
|
|
@@ -928,14 +1020,16 @@ declare class OpenCodeTurns implements OnApplicationShutdown {
|
|
|
928
1020
|
*
|
|
929
1021
|
* `spent` is what the run spent before (the sum of the `usage` of its earlier milestones): a turn
|
|
930
1022
|
* rebuilt here starts from it, so the answer it persists carries the whole run's usage.
|
|
1023
|
+
* `progress` is what the turn took before (its last `ask` milestone's): a turn rebuilt here reads
|
|
1024
|
+
* back from the session's messages, when the execution ends, what nobody heard after that.
|
|
931
1025
|
*/
|
|
932
|
-
observe(runId: string, input: AgentRunInput, handle: SessionHandle, spent?: OpenCodeUsage): Promise<Milestone>;
|
|
1026
|
+
observe(runId: string, input: AgentRunInput, handle: SessionHandle, spent?: OpenCodeUsage, progress?: TurnProgress): Promise<Milestone>;
|
|
933
1027
|
/**
|
|
934
1028
|
* Hand a person's answer back to OpenCode. When the server restarted while the turn waited, the
|
|
935
1029
|
* request is gone with it: a new session is opened, told what the person decided, and prompted
|
|
936
1030
|
* to go on.
|
|
937
1031
|
*/
|
|
938
|
-
reply(runId: string, input: AgentRunInput, handle: SessionHandle, ask: PendingAsk, reply: HumanReply, spent?: OpenCodeUsage): Promise<SessionHandle>;
|
|
1032
|
+
reply(runId: string, input: AgentRunInput, handle: SessionHandle, ask: PendingAsk, reply: HumanReply, spent?: OpenCodeUsage, progress?: TurnProgress): Promise<SessionHandle>;
|
|
939
1033
|
private continueAfterRestart;
|
|
940
1034
|
/** What a session spent so far (`session.get`), or nothing when OpenCode does not say. */
|
|
941
1035
|
private sessionUsage;
|
|
@@ -1000,4 +1094,4 @@ declare function openCodeControllers(options: OpenCodeEngineSettings): Type<obje
|
|
|
1000
1094
|
/** The providers every OpenCode engine needs: host, session store, settings and the turn steps. */
|
|
1001
1095
|
declare function openCodeProviders(options: OpenCodeEngineOptions): Provider[];
|
|
1002
1096
|
|
|
1003
|
-
export {
|
|
1097
|
+
export { type OpenCodeToolsOptions as A, OpenCodeToolsTokens as B, OpenCodeTurn as C, type OpenCodeTurnContext as D, type OpenCodeUsage as E, type StepCost as F, type StepModel as G, type TurnProgress as H, InMemoryOpenCodeSessionStore as I, addUsage as J, emptyUsage as K, LOST_ANSWER_ERROR as L, type Milestone as M, keyValueOpenCodeSessionStore as N, OpenCodeTurns as O, type PendingAsk as P, openCode as Q, openCodeControllers as R, type SessionHandle as S, type TurnOutcome as T, openCodeProviders as U, usageOf as V, type OpenCodeEngineSettings as a, type OpenCodeHost as b, type OpenCodeEngineOptions as c, type OpenCodeClient as d, type OpenCodeEvent as e, type OpenCodeForm as f, type OpenCodeFormValue as g, type OpenCodeFormField as h, OpenCodeMcpEndpoint as i, type OpenCodeAmendment as j, type OpenCodeCallContext as k, type OpenCodeKeyValue as l, type OpenCodeMessage as m, type OpenCodeMessagePart as n, type OpenCodeModelRef as o, type OpenCodePermissionRequest as p, type OpenCodePermissionRule as q, OpenCodeReplyMismatchError as r, type OpenCodeRunResult as s, type OpenCodeServer as t, type OpenCodeSessionCreate as u, type OpenCodeSessionRef as v, type OpenCodeSessionStore as w, type OpenCodeToolCall as x, OpenCodeToolRefusedError as y, type OpenCodeToolsClaims as z };
|