lark-remote 0.1.6 → 0.1.7
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/CHANGELOG.md +23 -1
- package/README.en.md +9 -1
- package/README.md +14 -2
- package/dist/bridge/approval-coordinator.d.ts +57 -34
- package/dist/bridge/approval-coordinator.js +191 -40
- package/dist/bridge/inbound-media.d.ts +62 -0
- package/dist/bridge/inbound-media.js +282 -0
- package/dist/bridge/index.d.ts +78 -7
- package/dist/bridge/index.js +202 -79
- package/dist/bridge/queue-manager.d.ts +2 -1
- package/dist/bridge/queue-manager.js +1 -0
- package/dist/card/approval-render.js +152 -36
- package/dist/card/bash-card-session.d.ts +2 -24
- package/dist/card/bash-card-session.js +6 -73
- package/dist/card/bash-renderer.js +2 -3
- package/dist/card/card-budget.js +29 -75
- package/dist/card/card-session.d.ts +48 -0
- package/dist/card/card-session.js +86 -0
- package/dist/card/card-shared.d.ts +1 -12
- package/dist/card/card-shared.js +1 -26
- package/dist/card/run-card-session.d.ts +2 -55
- package/dist/card/run-card-session.js +6 -104
- package/dist/card/run-renderer.js +99 -232
- package/dist/card/run-state.d.ts +13 -0
- package/dist/card/run-state.js +25 -16
- package/dist/card/text-truncate.d.ts +13 -12
- package/dist/card/text-truncate.js +13 -63
- package/dist/common/fs.d.ts +8 -0
- package/dist/common/fs.js +17 -0
- package/dist/common/guards.d.ts +0 -20
- package/dist/common/guards.js +0 -43
- package/dist/common/sleep.d.ts +2 -0
- package/dist/common/sleep.js +5 -0
- package/dist/common/truncate.d.ts +39 -0
- package/dist/common/truncate.js +92 -0
- package/dist/config/codex-config.d.ts +1 -1
- package/dist/config/codex-config.js +1 -1
- package/dist/config/index.d.ts +88 -23
- package/dist/config/index.js +105 -34
- package/dist/connector/index.d.ts +69 -2
- package/dist/connector/index.js +107 -1
- package/dist/index.js +123 -105
- package/dist/instance-lock.js +4 -12
- package/dist/order/alias-resolve.d.ts +13 -0
- package/dist/order/alias-resolve.js +22 -0
- package/dist/order/alias-store.d.ts +38 -0
- package/dist/order/alias-store.js +106 -0
- package/dist/persistence/atomic-write.d.ts +8 -2
- package/dist/persistence/atomic-write.js +23 -7
- package/dist/restart.js +2 -1
- package/dist/router/card-helpers.d.ts +63 -0
- package/dist/router/card-helpers.js +146 -0
- package/dist/router/config/claude.js +25 -1
- package/dist/router/config/codex.js +29 -50
- package/dist/router/config/common/model-patch.d.ts +22 -0
- package/dist/router/config/common/model-patch.js +26 -0
- package/dist/router/config/common/render.js +5 -4
- package/dist/router/config/index.d.ts +12 -0
- package/dist/router/config/index.js +25 -1
- package/dist/router/config/kimi.d.ts +4 -1
- package/dist/router/config/kimi.js +27 -0
- package/dist/router/config/opencode.js +18 -5
- package/dist/router/config/pi.js +4 -5
- package/dist/router/config/types.d.ts +11 -2
- package/dist/router/index.d.ts +56 -21
- package/dist/router/index.js +373 -548
- package/dist/router/utils.d.ts +2 -0
- package/dist/router/utils.js +4 -0
- package/dist/runner/agent-choices-common.d.ts +16 -0
- package/dist/runner/agent-choices-common.js +31 -0
- package/dist/runner/claude/runner.d.ts +47 -10
- package/dist/runner/claude/runner.js +117 -46
- package/dist/runner/claude/session.d.ts +166 -0
- package/dist/runner/claude/session.js +749 -0
- package/dist/runner/codex/app-server/protocol-types.d.ts +31 -39
- package/dist/runner/codex/app-server/protocol-types.js +1 -12
- package/dist/runner/codex/app-server/runner.d.ts +42 -59
- package/dist/runner/codex/app-server/runner.js +160 -337
- package/dist/runner/codex/app-server/translator.d.ts +1 -21
- package/dist/runner/codex/app-server/translator.js +0 -18
- package/dist/runner/codex/index.d.ts +0 -2
- package/dist/runner/codex/index.js +0 -2
- package/dist/runner/common/acp/protocol-helpers.d.ts +14 -0
- package/dist/runner/common/acp/protocol-helpers.js +21 -0
- package/dist/runner/common/acp/protocol-types.d.ts +238 -0
- package/dist/runner/common/acp/protocol-types.js +75 -0
- package/dist/runner/common/connection-based-runner.d.ts +111 -0
- package/dist/runner/common/connection-based-runner.js +261 -0
- package/dist/runner/{codex/app-server → common/jsonrpc}/client.d.ts +14 -7
- package/dist/runner/{codex/app-server → common/jsonrpc}/client.js +27 -18
- package/dist/runner/common/jsonrpc/connection-manager.d.ts +125 -0
- package/dist/runner/{codex/app-server → common/jsonrpc}/connection-manager.js +63 -28
- package/dist/runner/{codex/app-server → common/jsonrpc}/transport.d.ts +5 -4
- package/dist/runner/{codex/app-server → common/jsonrpc}/transport.js +18 -19
- package/dist/runner/common/jsonrpc/types.d.ts +32 -0
- package/dist/runner/common/jsonrpc/types.js +9 -0
- package/dist/runner/common/process-stopper.d.ts +2 -1
- package/dist/runner/common/process-stopper.js +1 -0
- package/dist/runner/common/runner-utils.d.ts +6 -13
- package/dist/runner/common/runner-utils.js +6 -47
- package/dist/runner/common/spawning-runner.d.ts +24 -70
- package/dist/runner/common/spawning-runner.js +98 -152
- package/dist/runner/index.d.ts +4 -4
- package/dist/runner/index.js +4 -4
- package/dist/runner/kimi/acp/runner.d.ts +106 -0
- package/dist/runner/kimi/acp/runner.js +448 -0
- package/dist/runner/kimi/acp/translator.d.ts +124 -0
- package/dist/runner/kimi/acp/translator.js +336 -0
- package/dist/runner/kimi/index.d.ts +1 -1
- package/dist/runner/kimi/index.js +1 -1
- package/dist/runner/opencode/acp/index.d.ts +1 -0
- package/dist/runner/opencode/acp/index.js +2 -0
- package/dist/runner/opencode/acp/runner.d.ts +121 -0
- package/dist/runner/opencode/acp/runner.js +429 -0
- package/dist/runner/opencode/acp/translator.d.ts +119 -0
- package/dist/runner/opencode/acp/translator.js +345 -0
- package/dist/runner/opencode/index.d.ts +1 -1
- package/dist/runner/opencode/index.js +1 -1
- package/dist/runner/pi/index.d.ts +1 -1
- package/dist/runner/pi/index.js +1 -1
- package/dist/runner/pi/rpc/client.d.ts +52 -0
- package/dist/runner/pi/rpc/client.js +114 -0
- package/dist/runner/pi/rpc/index.d.ts +4 -0
- package/dist/runner/pi/rpc/index.js +4 -0
- package/dist/runner/pi/rpc/protocol-types.d.ts +127 -0
- package/dist/runner/pi/rpc/protocol-types.js +21 -0
- package/dist/runner/pi/rpc/runner.d.ts +80 -0
- package/dist/runner/pi/rpc/runner.js +199 -0
- package/dist/runner/pi/rpc/translator.d.ts +55 -0
- package/dist/runner/pi/rpc/translator.js +258 -0
- package/dist/runner/registry.d.ts +7 -8
- package/dist/runner/registry.js +3 -4
- package/dist/runner/resolve-agent-choices.js +18 -59
- package/dist/runner/sync-agent-choices.js +16 -67
- package/dist/runner/types.d.ts +43 -13
- package/dist/session/claude/session-index.js +2 -3
- package/dist/session/claude/session-reader.js +3 -6
- package/dist/session/claude/sessions.js +6 -13
- package/dist/session/codex/rollout-reader.d.ts +2 -2
- package/dist/session/codex/rollout-reader.js +14 -17
- package/dist/session/codex/sessions.d.ts +1 -1
- package/dist/session/codex/sessions.js +2 -2
- package/dist/session/common/content-blocks.d.ts +7 -0
- package/dist/session/common/content-blocks.js +13 -9
- package/dist/session/common/jsonl.d.ts +8 -25
- package/dist/session/common/jsonl.js +126 -261
- package/dist/session/common/pagination.d.ts +28 -0
- package/dist/session/common/pagination.js +33 -0
- package/dist/session/kimi/sessions.d.ts +34 -1
- package/dist/session/kimi/sessions.js +208 -98
- package/dist/session/opencode/sessions.d.ts +17 -3
- package/dist/session/opencode/sessions.js +29 -29
- package/dist/session/pi/sessions.d.ts +5 -1
- package/dist/session/pi/sessions.js +12 -16
- package/dist/session/session-store.d.ts +11 -1
- package/dist/session/session-store.js +75 -178
- package/dist/update/index.d.ts +2 -2
- package/dist/update/index.js +2 -2
- package/dist/update/install.d.ts +20 -2
- package/dist/update/install.js +51 -7
- package/package.json +1 -1
- package/dist/runner/codex/app-server/connection-manager.d.ts +0 -56
- package/dist/runner/codex/argv.d.ts +0 -33
- package/dist/runner/codex/argv.js +0 -40
- package/dist/runner/codex/factory.d.ts +0 -29
- package/dist/runner/codex/factory.js +0 -39
- package/dist/runner/codex/jsonl.d.ts +0 -37
- package/dist/runner/codex/jsonl.js +0 -221
- package/dist/runner/codex/runner.d.ts +0 -66
- package/dist/runner/codex/runner.js +0 -129
- package/dist/runner/common/exec-translator.d.ts +0 -73
- package/dist/runner/common/exec-translator.js +0 -105
- package/dist/runner/kimi/jsonl.d.ts +0 -28
- package/dist/runner/kimi/jsonl.js +0 -143
- package/dist/runner/kimi/runner.d.ts +0 -49
- package/dist/runner/kimi/runner.js +0 -105
- package/dist/runner/opencode/argv.d.ts +0 -32
- package/dist/runner/opencode/argv.js +0 -35
- package/dist/runner/opencode/jsonl.d.ts +0 -68
- package/dist/runner/opencode/jsonl.js +0 -295
- package/dist/runner/opencode/runner.d.ts +0 -61
- package/dist/runner/opencode/runner.js +0 -93
- package/dist/runner/pi/jsonl.d.ts +0 -128
- package/dist/runner/pi/jsonl.js +0 -249
- package/dist/runner/pi/runner.d.ts +0 -36
- package/dist/runner/pi/runner.js +0 -76
- package/dist/session/common/catch-up.d.ts +0 -12
- package/dist/session/common/catch-up.js +0 -31
package/dist/runner/pi/jsonl.js
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Accumulates pi's incremental message_update events and emits normalized
|
|
3
|
-
* AgentEvents. Content mapping: text→TextContent, thinking→ThinkingContent,
|
|
4
|
-
* toolCall→ToolUseContent (input:arguments), toolResult→ToolResultContent.
|
|
5
|
-
*
|
|
6
|
-
* Implements RunnerTranslator so the base SpawningRunner can drive it
|
|
7
|
-
* uniformly. pi has no agent-reported terminal error (no equivalent of codex
|
|
8
|
-
* `turn.failed`), so isTerminal/finish/getTerminalError/hasAgentTerminalError
|
|
9
|
-
* are no-ops — pi relies entirely on the base class's signal/code-based
|
|
10
|
-
* result event classification.
|
|
11
|
-
*/
|
|
12
|
-
export class PiEventAccumulator {
|
|
13
|
-
content = [];
|
|
14
|
-
currentContentIndex = -1;
|
|
15
|
-
sessionId = '';
|
|
16
|
-
/**
|
|
17
|
-
* Accumulated (summed) token usage across all assistant messages in this run.
|
|
18
|
-
* pi emits per-message (non-cumulative) usage on each assistant `message_end`;
|
|
19
|
-
* summing yields the run's total consumption, aligned with ccusage (which sums
|
|
20
|
-
* per-message entries).
|
|
21
|
-
* `totalTokens` is NOT summed: it tracks the last message's total as the
|
|
22
|
-
* context-length water level (summing would overcount - design.md §usage:
|
|
23
|
-
* "N turn 累加得 N×context 虚假巨值").
|
|
24
|
-
*/
|
|
25
|
-
accInput = 0;
|
|
26
|
-
accOutput = 0;
|
|
27
|
-
accCacheRead = 0;
|
|
28
|
-
accCacheCreation = 0;
|
|
29
|
-
lastTotalTokens;
|
|
30
|
-
/** stopReason of the most recent assistant message_end. "error" indicates a
|
|
31
|
-
* provider/LLM failure (pi retries internally; a later message_end may
|
|
32
|
-
* overwrite this with "stop" on eventual success). */
|
|
33
|
-
lastAssistantStopReason;
|
|
34
|
-
/** errorMessage paired with the last assistant message_end whose
|
|
35
|
-
* stopReason==="error". Surfaces the provider's failure text (e.g.
|
|
36
|
-
* "Connection error.") to the user via the result event. */
|
|
37
|
-
lastAssistantErrorMessage;
|
|
38
|
-
translate(raw) {
|
|
39
|
-
return this.normalize(raw);
|
|
40
|
-
}
|
|
41
|
-
isTerminal() {
|
|
42
|
-
// pi has no terminal event — agent_end is non-terminal (the process
|
|
43
|
-
// continues until exit). The base class's result event is the terminal.
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
finish(_reason) {
|
|
47
|
-
// No-op: pi has no stream-ended-early terminal error to record.
|
|
48
|
-
// The base class's signal/code-based result event handles all cases.
|
|
49
|
-
}
|
|
50
|
-
getTerminalError() {
|
|
51
|
-
// Surface provider/LLM failures reported via stopReason="error" on the
|
|
52
|
-
// final assistant message_end. pi has no other agent-reported terminal
|
|
53
|
-
// error; this lets SpawningRunner produce an error result event instead
|
|
54
|
-
// of a silent "success" with empty content.
|
|
55
|
-
// Empty-string errorMessage is treated as missing (defensive against
|
|
56
|
-
// providers that return stopReason="error" with no message) — fall back
|
|
57
|
-
// to a non-empty sentinel so the run card never shows an empty error.
|
|
58
|
-
if (this.lastAssistantStopReason === 'error') {
|
|
59
|
-
const msg = this.lastAssistantErrorMessage;
|
|
60
|
-
return msg && msg.trim() ? msg : 'pi reported an error';
|
|
61
|
-
}
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
hasAgentTerminalError() {
|
|
65
|
-
// True when the most recent assistant message_end reported stopReason
|
|
66
|
-
// "error" (provider/LLM failure). pi retries internally; if a later
|
|
67
|
-
// message_end succeeds, lastAssistantStopReason is overwritten to "stop"
|
|
68
|
-
// and this returns false — so transient retries that eventually succeed
|
|
69
|
-
// are NOT misclassified as errors.
|
|
70
|
-
return this.lastAssistantStopReason === 'error';
|
|
71
|
-
}
|
|
72
|
-
getSessionId() {
|
|
73
|
-
return this.sessionId;
|
|
74
|
-
}
|
|
75
|
-
getLastUsage() {
|
|
76
|
-
if (this.accInput === 0 &&
|
|
77
|
-
this.accOutput === 0 &&
|
|
78
|
-
this.accCacheRead === 0 &&
|
|
79
|
-
this.accCacheCreation === 0 &&
|
|
80
|
-
this.lastTotalTokens === undefined) {
|
|
81
|
-
return undefined;
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
input_tokens: this.accInput,
|
|
85
|
-
output_tokens: this.accOutput,
|
|
86
|
-
cache_read_tokens: this.accCacheRead,
|
|
87
|
-
cache_creation_tokens: this.accCacheCreation,
|
|
88
|
-
...(this.lastTotalTokens != null ? { total_tokens: this.lastTotalTokens } : {}),
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
/** Accumulate a per-message usage record into the run's cumulative totals. */
|
|
92
|
-
addUsage(u) {
|
|
93
|
-
this.accInput += u.input ?? 0;
|
|
94
|
-
this.accOutput += u.output ?? 0;
|
|
95
|
-
this.accCacheRead += u.cacheRead ?? 0;
|
|
96
|
-
this.accCacheCreation += u.cacheWrite ?? 0;
|
|
97
|
-
if (u.totalTokens != null) {
|
|
98
|
-
this.lastTotalTokens = u.totalTokens;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
normalize(raw) {
|
|
102
|
-
switch (raw.type) {
|
|
103
|
-
case 'session': {
|
|
104
|
-
const s = raw;
|
|
105
|
-
this.sessionId = s.id;
|
|
106
|
-
return {
|
|
107
|
-
type: 'system',
|
|
108
|
-
subtype: 'init',
|
|
109
|
-
session_id: s.id,
|
|
110
|
-
cwd: s.cwd,
|
|
111
|
-
model: s.model ?? '',
|
|
112
|
-
timestamp: new Date().toISOString(),
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
case 'message_start': {
|
|
116
|
-
const m = raw.message;
|
|
117
|
-
if (m.role === 'assistant') {
|
|
118
|
-
// Initialize accumulator for new assistant message
|
|
119
|
-
this.content = [];
|
|
120
|
-
this.currentContentIndex = -1;
|
|
121
|
-
}
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
case 'message_update': {
|
|
125
|
-
const evt = raw.assistantMessageEvent;
|
|
126
|
-
this.applyUpdate(evt);
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
case 'message_end': {
|
|
130
|
-
const m = raw.message;
|
|
131
|
-
if (m.role === 'assistant') {
|
|
132
|
-
// Record provider/LLM failure signal: pi emits stopReason="error"
|
|
133
|
-
// with an errorMessage on transient provider outages. A subsequent
|
|
134
|
-
// successful message_end (stopReason="stop" after internal retry)
|
|
135
|
-
// overwrites these, so only the final state decides terminal error.
|
|
136
|
-
this.lastAssistantStopReason = m.stopReason;
|
|
137
|
-
if (m.stopReason === 'error') {
|
|
138
|
-
this.lastAssistantErrorMessage = m.errorMessage;
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
this.lastAssistantErrorMessage = undefined;
|
|
142
|
-
}
|
|
143
|
-
// Emit accumulated AssistantEvent
|
|
144
|
-
const event = {
|
|
145
|
-
type: 'assistant',
|
|
146
|
-
message: { content: this.content },
|
|
147
|
-
timestamp: new Date().toISOString(),
|
|
148
|
-
};
|
|
149
|
-
this.content = [];
|
|
150
|
-
this.currentContentIndex = -1;
|
|
151
|
-
// Accumulate per-message usage (ccusage-aligned: input is non-cached).
|
|
152
|
-
if (m.usage) {
|
|
153
|
-
this.addUsage(m.usage);
|
|
154
|
-
}
|
|
155
|
-
return event;
|
|
156
|
-
}
|
|
157
|
-
if (m.role === 'toolResult') {
|
|
158
|
-
// Emit UserEvent with tool_result content
|
|
159
|
-
const toolResultContent = this.normalizeToolResult(m);
|
|
160
|
-
const event = {
|
|
161
|
-
type: 'user',
|
|
162
|
-
message: { content: [toolResultContent] },
|
|
163
|
-
timestamp: new Date().toISOString(),
|
|
164
|
-
};
|
|
165
|
-
return event;
|
|
166
|
-
}
|
|
167
|
-
return null;
|
|
168
|
-
}
|
|
169
|
-
case 'turn_end': {
|
|
170
|
-
// pi 0.80+ `message_end` always carries usage; `turn_end` is a no-op.
|
|
171
|
-
return null;
|
|
172
|
-
}
|
|
173
|
-
case 'agent_end': {
|
|
174
|
-
// P2#6: do NOT emit result here — base class emits after exit-code check.
|
|
175
|
-
return null;
|
|
176
|
-
}
|
|
177
|
-
default:
|
|
178
|
-
// Ignore unknown event types (agent_start, turn_start, tool_execution_*, etc.)
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
applyUpdate(evt) {
|
|
183
|
-
switch (evt.type) {
|
|
184
|
-
case 'text_start':
|
|
185
|
-
this.content.push({ type: 'text', text: '' });
|
|
186
|
-
this.currentContentIndex++;
|
|
187
|
-
break;
|
|
188
|
-
case 'text_delta':
|
|
189
|
-
if (this.currentContentIndex >= 0 &&
|
|
190
|
-
this.content[this.currentContentIndex]?.type === 'text') {
|
|
191
|
-
this.content[this.currentContentIndex].text += evt.delta ?? '';
|
|
192
|
-
}
|
|
193
|
-
break;
|
|
194
|
-
case 'text_end':
|
|
195
|
-
if (this.currentContentIndex >= 0 &&
|
|
196
|
-
this.content[this.currentContentIndex]?.type === 'text' &&
|
|
197
|
-
evt.content) {
|
|
198
|
-
this.content[this.currentContentIndex].text = evt.content;
|
|
199
|
-
}
|
|
200
|
-
break;
|
|
201
|
-
case 'thinking_start':
|
|
202
|
-
this.content.push({ type: 'thinking', thinking: '' });
|
|
203
|
-
this.currentContentIndex++;
|
|
204
|
-
break;
|
|
205
|
-
case 'thinking_delta':
|
|
206
|
-
if (this.currentContentIndex >= 0 &&
|
|
207
|
-
this.content[this.currentContentIndex]?.type === 'thinking') {
|
|
208
|
-
this.content[this.currentContentIndex].thinking +=
|
|
209
|
-
evt.delta ?? '';
|
|
210
|
-
}
|
|
211
|
-
break;
|
|
212
|
-
case 'thinking_end':
|
|
213
|
-
if (this.currentContentIndex >= 0 &&
|
|
214
|
-
this.content[this.currentContentIndex]?.type === 'thinking' &&
|
|
215
|
-
evt.content) {
|
|
216
|
-
this.content[this.currentContentIndex].thinking = evt.content;
|
|
217
|
-
}
|
|
218
|
-
break;
|
|
219
|
-
case 'toolcall_start':
|
|
220
|
-
this.content.push({ type: 'tool_use', id: '', name: '', input: {} });
|
|
221
|
-
this.currentContentIndex++;
|
|
222
|
-
break;
|
|
223
|
-
case 'toolcall_end':
|
|
224
|
-
if (this.currentContentIndex >= 0 &&
|
|
225
|
-
this.content[this.currentContentIndex]?.type === 'tool_use' &&
|
|
226
|
-
evt.toolCall) {
|
|
227
|
-
this.content[this.currentContentIndex] = {
|
|
228
|
-
type: 'tool_use',
|
|
229
|
-
id: evt.toolCall.id,
|
|
230
|
-
name: evt.toolCall.name,
|
|
231
|
-
input: evt.toolCall.arguments,
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
break;
|
|
235
|
-
default:
|
|
236
|
-
// toolcall_delta: pi provides complete arguments at toolcall_end, ignore delta
|
|
237
|
-
break;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
normalizeToolResult(msg) {
|
|
241
|
-
return {
|
|
242
|
-
type: 'tool_result',
|
|
243
|
-
tool_use_id: msg.toolCallId ?? '',
|
|
244
|
-
content: msg.content ?? '',
|
|
245
|
-
is_error: msg.isError ?? false,
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
//# sourceMappingURL=jsonl.js.map
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { AgentRunner, AgentSessionReader, SpawnOptions, AgentStatusInfo } from '../types.js';
|
|
2
|
-
import { SpawningRunner, type RunnerTranslator } from '../common/spawning-runner.js';
|
|
3
|
-
interface PiRunnerConfig {
|
|
4
|
-
provider?: string;
|
|
5
|
-
model?: string;
|
|
6
|
-
thinking?: string;
|
|
7
|
-
tools?: string[];
|
|
8
|
-
stopGraceMs?: number;
|
|
9
|
-
pidDir?: string;
|
|
10
|
-
workspace: string;
|
|
11
|
-
spawnHeartbeatMs?: number;
|
|
12
|
-
sessionReader?: AgentSessionReader;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* PiRunner: spawn-per-message runner using `pi --mode json -p <prompt> ...`.
|
|
16
|
-
*
|
|
17
|
-
* Inherits the spawn + completion + cleanup orchestration from SpawningRunner.
|
|
18
|
-
* This subclass overrides only the createTranslator()
|
|
19
|
-
* hook to return a PiEventAccumulator (which implements RunnerTranslator).
|
|
20
|
-
* Pi uses the default JSONL stream reader (createJSONLStream) and the default
|
|
21
|
-
* stdio ['ignore','pipe','pipe'] — no stdin writing, no env sync.
|
|
22
|
-
*/
|
|
23
|
-
export declare class PiRunner extends SpawningRunner implements AgentRunner {
|
|
24
|
-
readonly kind: "pi";
|
|
25
|
-
readonly sessionReader: AgentSessionReader;
|
|
26
|
-
private provider;
|
|
27
|
-
private defaultModel;
|
|
28
|
-
private thinking;
|
|
29
|
-
private tools;
|
|
30
|
-
constructor(opts: PiRunnerConfig);
|
|
31
|
-
get pid(): number | undefined;
|
|
32
|
-
getStatusInfo(): AgentStatusInfo;
|
|
33
|
-
protected buildArgv(opts: SpawnOptions): string[];
|
|
34
|
-
protected createTranslator(_opts: SpawnOptions): RunnerTranslator;
|
|
35
|
-
}
|
|
36
|
-
export {};
|
package/dist/runner/pi/runner.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { SpawningRunner } from '../common/spawning-runner.js';
|
|
2
|
-
import { PiEventAccumulator } from './jsonl.js';
|
|
3
|
-
/**
|
|
4
|
-
* PiRunner: spawn-per-message runner using `pi --mode json -p <prompt> ...`.
|
|
5
|
-
*
|
|
6
|
-
* Inherits the spawn + completion + cleanup orchestration from SpawningRunner.
|
|
7
|
-
* This subclass overrides only the createTranslator()
|
|
8
|
-
* hook to return a PiEventAccumulator (which implements RunnerTranslator).
|
|
9
|
-
* Pi uses the default JSONL stream reader (createJSONLStream) and the default
|
|
10
|
-
* stdio ['ignore','pipe','pipe'] — no stdin writing, no env sync.
|
|
11
|
-
*/
|
|
12
|
-
export class PiRunner extends SpawningRunner {
|
|
13
|
-
kind = 'pi';
|
|
14
|
-
sessionReader;
|
|
15
|
-
provider;
|
|
16
|
-
defaultModel;
|
|
17
|
-
thinking;
|
|
18
|
-
tools;
|
|
19
|
-
constructor(opts) {
|
|
20
|
-
super({
|
|
21
|
-
pidDir: opts.pidDir,
|
|
22
|
-
workspace: opts.workspace,
|
|
23
|
-
stopGraceMs: opts.stopGraceMs,
|
|
24
|
-
spawnHeartbeatMs: opts.spawnHeartbeatMs,
|
|
25
|
-
pidFilePrefix: 'pi',
|
|
26
|
-
logTag: 'pi-runner',
|
|
27
|
-
});
|
|
28
|
-
this.binary = 'pi';
|
|
29
|
-
this.provider = opts.provider ?? 'Volcano';
|
|
30
|
-
this.defaultModel = opts.model ?? 'glm-5.2';
|
|
31
|
-
this.thinking = opts.thinking ?? 'medium';
|
|
32
|
-
this.tools = opts.tools ?? ['read', 'bash', 'edit', 'write', 'grep', 'find', 'ls'];
|
|
33
|
-
this.sessionReader = opts.sessionReader ?? {
|
|
34
|
-
listSessions: () => ({ sessions: [], total: 0 }),
|
|
35
|
-
getNewestSession: () => null,
|
|
36
|
-
readSessionContent: () => ({ events: [] }),
|
|
37
|
-
isSessionActive: () => false,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
get pid() {
|
|
41
|
-
return this.currentProcess?.pid;
|
|
42
|
-
}
|
|
43
|
-
getStatusInfo() {
|
|
44
|
-
return {
|
|
45
|
-
kind: 'pi',
|
|
46
|
-
model: this.defaultModel,
|
|
47
|
-
provider: this.provider,
|
|
48
|
-
reasoning: this.thinking,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
buildArgv(opts) {
|
|
52
|
-
const args = [
|
|
53
|
-
'--mode',
|
|
54
|
-
'json',
|
|
55
|
-
'-p',
|
|
56
|
-
this.currentMessage,
|
|
57
|
-
'--provider',
|
|
58
|
-
this.provider,
|
|
59
|
-
'--model',
|
|
60
|
-
opts.model ?? this.defaultModel,
|
|
61
|
-
'--tools',
|
|
62
|
-
this.tools.join(','),
|
|
63
|
-
];
|
|
64
|
-
if (opts.sessionId)
|
|
65
|
-
args.push('--session-id', opts.sessionId);
|
|
66
|
-
if (this.thinking && this.thinking !== 'off')
|
|
67
|
-
args.push('--thinking', this.thinking);
|
|
68
|
-
return args;
|
|
69
|
-
}
|
|
70
|
-
// --- Hooks ---
|
|
71
|
-
createTranslator(_opts) {
|
|
72
|
-
// Fresh accumulator per run (stateful: content buffer, sessionId, lastUsage).
|
|
73
|
-
return new PiEventAccumulator();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=runner.js.map
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Find the index of the last line in a JSONL line array whose parsed object
|
|
3
|
-
* satisfies the given predicate.
|
|
4
|
-
*
|
|
5
|
-
* Invalid JSON, empty, and whitespace-only lines are silently skipped.
|
|
6
|
-
*
|
|
7
|
-
* @param lines Array of raw JSONL line strings.
|
|
8
|
-
* @param isUserMessage Predicate that receives the parsed object and returns
|
|
9
|
-
* true for lines considered "user" messages.
|
|
10
|
-
* @returns The array index of the last matching line, or -1 if none match.
|
|
11
|
-
*/
|
|
12
|
-
export declare function findLastUserIndex(lines: string[], isUserMessage: (obj: Record<string, unknown>) => boolean): number;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Find the index of the last line in a JSONL line array whose parsed object
|
|
3
|
-
* satisfies the given predicate.
|
|
4
|
-
*
|
|
5
|
-
* Invalid JSON, empty, and whitespace-only lines are silently skipped.
|
|
6
|
-
*
|
|
7
|
-
* @param lines Array of raw JSONL line strings.
|
|
8
|
-
* @param isUserMessage Predicate that receives the parsed object and returns
|
|
9
|
-
* true for lines considered "user" messages.
|
|
10
|
-
* @returns The array index of the last matching line, or -1 if none match.
|
|
11
|
-
*/
|
|
12
|
-
export function findLastUserIndex(lines, isUserMessage) {
|
|
13
|
-
let lastIdx = -1;
|
|
14
|
-
for (let i = 0; i < lines.length; i++) {
|
|
15
|
-
const line = lines[i];
|
|
16
|
-
if (!line.trim())
|
|
17
|
-
continue;
|
|
18
|
-
let obj;
|
|
19
|
-
try {
|
|
20
|
-
obj = JSON.parse(line);
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
if (isUserMessage(obj)) {
|
|
26
|
-
lastIdx = i;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return lastIdx;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=catch-up.js.map
|