tabby-ai-tools 0.4.1 → 0.5.0

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.
@@ -0,0 +1,47 @@
1
+ /** Provider identity is lost when registering models under the isolated tabby ID. */
2
+ export function providerCompat(profile) {
3
+ if (profile.provider === 'kimi-coding')
4
+ return {
5
+ supportsDeveloperRole: false, maxTokensField: 'max_tokens', supportsStore: false,
6
+ supportsStrictMode: false, requiresReasoningContentOnAssistantMessages: true,
7
+ };
8
+ return undefined;
9
+ }
10
+ /** Keep the existing Tabby connection settings meaningful at Pi's request boundary. */
11
+ export function providerPayload(profile, payload) {
12
+ if (!payload || typeof payload !== 'object')
13
+ return payload;
14
+ const body = payload;
15
+ const effort = profile.reasoningEffort;
16
+ if (profile.provider === 'openai' || profile.provider === 'custom' && profile.apiFormat === 'responses') {
17
+ if (effort)
18
+ body.reasoning = { ...body.reasoning, effort };
19
+ }
20
+ else if (profile.provider === 'claude') {
21
+ delete body.thinking;
22
+ if (profile.thinking === 'enabled')
23
+ body.thinking = { type: 'adaptive' };
24
+ if (profile.thinking === 'disabled')
25
+ body.thinking = { type: 'disabled' };
26
+ if (effort)
27
+ body.output_config = { ...body.output_config, effort };
28
+ }
29
+ else {
30
+ delete body.thinking;
31
+ delete body.enable_thinking;
32
+ delete body.reasoning_effort;
33
+ const alwaysThinks = profile.provider === 'kimi' && /^kimi-(k3(?:\.1-pro)?|k2\.7-code)(?:-highspeed)?$/i.test(profile.model);
34
+ if ((alwaysThinks || profile.provider === 'kimi-coding' && /^k3\.1-pro(?:-highspeed)?$/i.test(profile.model)) && profile.thinking === 'disabled') {
35
+ throw new Error('此 Kimi 模型仅支持思考模式,请选择服务商默认或开启');
36
+ }
37
+ if (profile.provider !== 'custom' && profile.thinking !== 'default' && !alwaysThinks) {
38
+ if (profile.provider === 'bailian-coding')
39
+ body.enable_thinking = profile.thinking === 'enabled';
40
+ else
41
+ body.thinking = { type: profile.thinking };
42
+ }
43
+ if (effort && (profile.provider === 'custom' || profile.thinking !== 'disabled'))
44
+ body.reasoning_effort = effort;
45
+ }
46
+ return body;
47
+ }
@@ -0,0 +1,215 @@
1
+ import { createInterface } from 'node:readline';
2
+ import { mkdir, chmod } from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { InMemoryCredentialStore, createAssistantMessageEventStream } from '@earendil-works/pi-ai';
5
+ import { createAgentSession, DefaultResourceLoader, ModelRuntime, SessionManager, SettingsManager } from '@earendil-works/pi-coding-agent';
6
+ import { providerCompat, providerPayload } from './provider.mjs';
7
+ process.umask(0o077);
8
+ // stdout is a private bounded protocol. No user/project extensions or native tools are loaded.
9
+ const send = (value) => process.stdout.write(JSON.stringify(value) + '\n');
10
+ const pending = new Map();
11
+ let session;
12
+ let cancelled = false;
13
+ let initialized = false;
14
+ const lines = createInterface({ input: process.stdin, crlfDelay: Infinity });
15
+ lines.on('close', () => { cancelled = true; void session?.abort(); for (const resolve of pending.values())
16
+ resolve({ error: true, result: 'Host disconnected' }); pending.clear(); });
17
+ lines.on('line', line => {
18
+ if (Buffer.byteLength(line) > 12 * 1024 * 1024) {
19
+ process.exitCode = 1;
20
+ lines.close();
21
+ return;
22
+ }
23
+ let message;
24
+ try {
25
+ message = JSON.parse(line);
26
+ }
27
+ catch {
28
+ process.exitCode = 1;
29
+ lines.close();
30
+ return;
31
+ }
32
+ if (message.type === 'cancel') {
33
+ cancelled = true;
34
+ void session?.abort();
35
+ for (const resolve of pending.values())
36
+ resolve({ error: true, result: 'Cancelled' });
37
+ pending.clear();
38
+ }
39
+ else if (message.type === 'tool_result') {
40
+ pending.get(message.id)?.(message);
41
+ pending.delete(message.id);
42
+ }
43
+ else if (message.type === 'start') {
44
+ pending.get('start')?.(message);
45
+ pending.delete('start');
46
+ }
47
+ else if (message.type === 'accepted') {
48
+ pending.get('accepted')?.(message);
49
+ pending.delete('accepted');
50
+ }
51
+ else if (message.type === 'init' && !initialized) {
52
+ initialized = true;
53
+ void run(message).catch(error => { send({ type: 'fatal', message: String(error.message || error) }); finish(); });
54
+ }
55
+ });
56
+ function finish() { session?.dispose(); lines.close(); process.stdin.destroy(); }
57
+ async function run(input) {
58
+ const [major, minor] = process.versions.node.split('.').map(Number);
59
+ if (major < 22 || major === 22 && minor < 19)
60
+ throw new Error('Pi requires external Node >=22.19.0');
61
+ const { profile, directory } = input;
62
+ await mkdir(directory, { recursive: true, mode: 0o700 });
63
+ await chmod(directory, 0o700);
64
+ const runtime = await ModelRuntime.create({ credentials: new InMemoryCredentialStore(), modelsPath: null,
65
+ modelsStorePath: path.join(directory, 'models-cache.json'), refreshOnCreate: false, allowModelNetwork: false });
66
+ const api = profile.provider === 'claude' ? 'anthropic-messages' : profile.provider === 'openai' || profile.provider === 'custom' && profile.apiFormat === 'responses' ? 'openai-responses' : 'openai-completions';
67
+ // Anthropic's SDK appends /v1 itself; Tabby API presets include it already.
68
+ const baseUrl = profile.provider === 'claude' ? profile.baseUrl.replace(/\/v1\/?$/, '') : profile.baseUrl;
69
+ runtime.registerProvider('tabby', { baseUrl, api, apiKey: 'tabby-runtime-key', authHeader: !!input.key,
70
+ models: [{ id: profile.model, name: profile.model, api, input: ['text'], reasoning: profile.thinking === 'enabled' || profile.thinking !== 'disabled' && !!profile.reasoningEffort,
71
+ compat: providerCompat(profile),
72
+ thinkingLevelMap: { minimal: 'minimal', low: 'low', medium: 'medium', high: 'high', xhigh: 'xhigh', max: 'max' },
73
+ contextWindow: profile.contextWindow || 128000, maxTokens: profile.maxOutputTokens,
74
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 } }] });
75
+ await runtime.setRuntimeApiKey('tabby', input.key || 'tabby-no-key');
76
+ const model = runtime.getModel('tabby', profile.model);
77
+ if (!model)
78
+ throw new Error('Pi model registration failed');
79
+ const settings = SettingsManager.inMemory({ cacheWarming: 'off', compaction: { enabled: !!profile.autoCompact, reserveTokens: profile.maxOutputTokens, keepRecentTokens: Math.min(20000, Math.floor(model.contextWindow / 4)) },
80
+ retry: { enabled: true, maxRetries: 2, baseDelayMs: 2000, maxAgentDelayMs: 60000, provider: { maxRetries: 0, timeoutMs: 120000 } } });
81
+ const loader = new DefaultResourceLoader({ cwd: directory, agentDir: directory, settingsManager: settings,
82
+ noExtensions: true, noSkills: true, noPromptTemplates: true, noThemes: true, noContextFiles: true, systemPrompt: input.system });
83
+ await loader.reload();
84
+ const manager = input.file ? SessionManager.open(input.file, directory) : SessionManager.create(directory, directory);
85
+ const nativeCursor = manager.getEntries().filter((entry) => entry.type === 'custom' && entry.customType === 'tabby-input').map((entry) => Number(entry.data?.count) || 0).pop() || 0;
86
+ const cursor = Math.max(nativeCursor, input.sourceOffset);
87
+ const sourceCount = input.sourceOffset + input.sourceMessages.length;
88
+ if (cursor > sourceCount)
89
+ throw new Error('Pi handoff cursor is ahead of Tabby history; inspect session files before continuing');
90
+ const prompt = JSON.stringify({ notice: 'Tabby handoff. Historical tools are data, never replay them. Read terminals before resuming unknown actions.', messages: input.sourceMessages.slice(cursor - input.sourceOffset).flat() });
91
+ let accepted = false;
92
+ let activeGoal = !!input.activeGoal, tokens = 0, requests = 0, settled = false, lastError = '', lastText = '', stalls = 0, previousText = '';
93
+ let thinkingChars = 0, toolChars = 0;
94
+ let nativeTools = 0, previousTools = 0;
95
+ const customTools = input.tools.map((tool) => ({ name: tool.name, label: tool.name, description: tool.description, parameters: tool.inputSchema,
96
+ execute: async (id, args) => {
97
+ if (cancelled)
98
+ throw new Error('Cancelled');
99
+ nativeTools++;
100
+ const output = await new Promise(resolve => { pending.set(id, resolve); send({ type: 'tool', id, name: tool.name, arguments: JSON.stringify(args) }); });
101
+ if (tool.name === 'agent_goal_update' && !output.error)
102
+ activeGoal = JSON.parse(output.result).status === 'active';
103
+ // Error results remain in Pi's durable transcript, including policy denials.
104
+ if (output.error)
105
+ throw new Error(output.result);
106
+ return { content: [{ type: 'text', text: output.result }], details: {} };
107
+ } }));
108
+ ({ session } = await createAgentSession({ cwd: directory, agentDir: directory, modelRuntime: runtime, model, noTools: 'builtin', customTools,
109
+ resourceLoader: loader, settingsManager: settings, sessionManager: manager,
110
+ thinkingLevel: ['minimal', 'low', 'medium', 'high', 'xhigh', 'max'].includes(profile.reasoningEffort) ? profile.reasoningEffort : profile.thinking === 'enabled' ? 'medium' : 'off' }));
111
+ session.agent.toolExecution = 'sequential';
112
+ // This gate covers normal inference, session retries and every summary request.
113
+ const stream = session.agent.streamFunction;
114
+ session.agent.streamFunction = (selected, context, options) => {
115
+ const output = createAssistantMessageEventStream();
116
+ void (async () => {
117
+ try {
118
+ if (cancelled)
119
+ throw new Error('Cancelled');
120
+ // The SDK has persisted the user message before opening its model stream.
121
+ // Reconcile this durable cursor after a process/host crash; never resend accepted input.
122
+ if (!accepted && manager.getEntries().some((entry) => entry.type === 'message' && entry.message.role === 'user' &&
123
+ (typeof entry.message.content === 'string' ? entry.message.content : entry.message.content.filter((part) => part.type === 'text').map((part) => part.text).join('')) === prompt)) {
124
+ accepted = true;
125
+ manager.appendCustomEntry('tabby-input', { count: sourceCount });
126
+ await new Promise(resolve => { pending.set('accepted', resolve); send({ type: 'accepted' }); });
127
+ if (cancelled)
128
+ throw new Error('Cancelled');
129
+ }
130
+ if (input.budget && tokens >= input.budget)
131
+ throw new Error('Goal token budget exhausted');
132
+ if (++requests > 100)
133
+ throw new Error('Pi request safety limit reached (100, including retries and summaries)');
134
+ const source = await stream(selected, context, { ...options, maxRetries: 0, maxTokens: profile.maxOutputTokens,
135
+ identity: { userAgent: { custom: 'tabby-ai-tools (Pi SDK)' }, attribution: null },
136
+ onPayload: payload => providerPayload(profile, payload),
137
+ ...(!input.key ? { headers: { ...options?.headers, Authorization: null } } : {}) });
138
+ for await (const event of source) {
139
+ if (event.type === 'done' || event.type === 'error') {
140
+ const message = event.type === 'done' ? event.message : event.error;
141
+ tokens += Math.max(0, message.usage?.totalTokens || 0);
142
+ send({ type: 'usage', tokens, inputTokens: (message.usage?.input || 0) + (message.usage?.cacheRead || 0) + (message.usage?.cacheWrite || 0) });
143
+ }
144
+ output.push(event);
145
+ }
146
+ output.end(await source.result());
147
+ }
148
+ catch (error) {
149
+ const message = { role: 'assistant', content: [], api: selected.api, provider: selected.provider, model: selected.id,
150
+ usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } },
151
+ stopReason: cancelled ? 'aborted' : 'error', errorMessage: String(error.message || error), timestamp: Date.now() };
152
+ output.push({ type: 'error', reason: message.stopReason, error: message });
153
+ }
154
+ })();
155
+ return output;
156
+ };
157
+ session.subscribe(event => {
158
+ if (event.type === 'message_update' && event.assistantMessageEvent.type === 'text_delta')
159
+ send({ type: 'text', delta: event.assistantMessageEvent.delta });
160
+ if (event.type === 'message_update' && ['thinking_delta', 'toolcall_delta'].includes(event.assistantMessageEvent.type)) {
161
+ const delta = event.assistantMessageEvent;
162
+ if (delta.type === 'thinking_delta')
163
+ thinkingChars += delta.delta.length;
164
+ else
165
+ toolChars += delta.delta.length;
166
+ send({ type: 'progress', progress: { phase: delta.type === 'thinking_delta' ? 'thinking' : 'tools', receivedChars: delta.type === 'thinking_delta' ? thinkingChars : toolChars } });
167
+ }
168
+ if (event.type === 'message_end' && event.message.role === 'assistant') {
169
+ const message = event.message;
170
+ lastError = message.stopReason === 'length' ? 'Pi response reached the output token limit; the reply is incomplete.'
171
+ : message.stopReason === 'error' ? message.errorMessage || 'Pi inference failed' : '';
172
+ lastText = message.content.filter(part => part.type === 'text').map(part => part.text).join('');
173
+ }
174
+ if (['auto_retry_start', 'auto_retry_end', 'compaction_start', 'compaction_end', 'summarization_retry_scheduled', 'agent_settled'].includes(event.type))
175
+ send({ type: 'lifecycle', event });
176
+ if (event.type === 'agent_settled')
177
+ settled = true;
178
+ });
179
+ await new Promise(resolve => { pending.set('start', resolve); send({ type: 'ready', file: manager.getSessionFile() }); });
180
+ if (cancelled)
181
+ throw new Error('Cancelled');
182
+ if (input.compact) {
183
+ try {
184
+ await session.compact('Preserve all user constraints, goal, active skills, pending workflow checkpoints, observed results, and unknown actions. Never infer completion from a sent command.');
185
+ lastText = 'Context compacted; original Pi session entries retained.';
186
+ }
187
+ catch (error) {
188
+ if (!/^(Already compacted|Nothing to compact \(session too small\))$/.test(error.message))
189
+ throw error;
190
+ lastText = 'History is already compact or too short to compact.';
191
+ }
192
+ }
193
+ else {
194
+ let nextPrompt = prompt;
195
+ do {
196
+ settled = false;
197
+ await session.prompt(nextPrompt);
198
+ await session.waitForIdle();
199
+ if (!settled && !cancelled)
200
+ throw new Error('Pi did not settle');
201
+ if (lastError)
202
+ throw new Error(lastError);
203
+ if (cancelled)
204
+ break;
205
+ stalls = nativeTools === previousTools && lastText === previousText ? stalls + 1 : 0;
206
+ previousTools = nativeTools;
207
+ previousText = lastText;
208
+ if (stalls >= 2 && activeGoal)
209
+ throw new Error('Goal stalled: repeated response without new evidence');
210
+ nextPrompt = 'The goal is active. Continue from observed results, never replay completed operations. Verify the original requirements and update agent_goal_update with evidence. Pause only on user request.';
211
+ } while (activeGoal);
212
+ }
213
+ send({ type: 'done', text: lastText, tokens, file: manager.getSessionFile(), cancelled });
214
+ finish();
215
+ }
Binary file
@@ -1,6 +1,6 @@
1
1
  <svg xmlns="http://www.w3.org/2000/svg" width="1800" height="1440" viewBox="0 0 1800 1440" role="img" aria-labelledby="title desc">
2
- <title id="title">Tabby AI Tools v0.4.1 interface illustration — Claude Code local login, continuous goals, reasoning picker and custom OpenAI-compatible connections</title>
3
- <desc id="desc">Interface illustration, not a running screenshot. The assistant sidebar coordinates example staging database and application terminals. Connection and model controls share one compact row. Scheduled tasks, provider connections, startup opening enabled by default and twelve interface languages and the Claude Code local-login connection are shown below. Active goals continue automatically by default. A Kimi Coding Plan reasoning picker and China/international presets for Kimi and Alibaba Coding Plan are illustrated. Custom OpenAI-compatible settings show an example Base URL, model, protocol and authentication. This is a version 0.4.1 interface example.</desc>
2
+ <title id="title">Tabby AI Tools v0.5.0 interface illustration — verified workflow recording, conversational aliases, local login and API connections</title>
3
+ <desc id="desc">Interface illustration, not a running screenshot. The assistant sidebar coordinates example staging database and application terminals. Connection and model controls share one compact row. Scheduled tasks, provider connections, startup opening enabled by default and twelve interface languages and the Claude Code local-login connection are shown below. Active goals continue automatically by default. Terminal output is read on demand without automatic forwarding; a completed explicit recording and a saved workflow alias are shown. Archive status distinguishes successful checkpoints from successful persistence. Pi runtime settings show an external Node executable, host-only tools and opt-in automatic context compaction. The provider list includes Kimi and Alibaba Cloud Coding Plan connections. Custom OpenAI-compatible settings show an example Base URL, model, protocol and authentication. Version 0.5.0 example with optional Pi SDK runtime, external Node 22.19+, manual context compaction and structured retry waiting.</desc>
4
4
  <defs>
5
5
  <linearGradient id="background" x2="1" y2="1"><stop stop-color="#0c1622"/><stop offset="1" stop-color="#151729"/></linearGradient>
6
6
  <linearGradient id="outline"><stop stop-color="#375d5d"/><stop offset="1" stop-color="#3b3d5c"/></linearGradient>
@@ -15,9 +15,9 @@ text{font-family:"DejaVu Sans",sans-serif;fill:#e8eff9}
15
15
  <text x="56" y="65" font-size="23" font-weight="700" style="fill:#8ae6c2" class="mono">&gt;_</text>
16
16
  <text x="106" y="66" font-size="21" font-weight="700" style="fill:#a7b8cb">TABBY AI TOOLS</text>
17
17
  <rect x="1534" y="44" width="218" height="28" rx="6" fill="#22313f"/>
18
- <text x="1544" y="64" font-size="16" font-weight="600" style="fill:#8ae6c2">v0.4.1 / 12 languages</text>
18
+ <text x="1544" y="64" font-size="16" font-weight="600" style="fill:#8ae6c2">v0.5.0 / Pi optional</text>
19
19
  <text x="48" y="134" font-size="54" font-weight="700" style="fill:#f1f6ff">Your terminals. Working together.</text>
20
- <text x="50" y="176" font-size="23" font-weight="400" style="fill:#a7b8cb">Codex + Claude Code local login + APIs / Terminal tools / Scheduled AI tasks</text>
20
+ <text x="50" y="176" font-size="23" font-weight="400" style="fill:#a7b8cb">Codex + Claude Code + APIs + optional Pi SDK / Terminal tools / Scheduled AI tasks</text>
21
21
  <rect x="48" y="210" width="1704" height="632" rx="14" fill="#0d1520" stroke="url(#outline)"/>
22
22
  <rect x="49" y="211" width="1702" height="42" rx="13" fill="#1c2635"/>
23
23
  <rect x="49" y="235" width="1702" height="18" rx="0" fill="#1c2635"/>
@@ -28,7 +28,7 @@ text{font-family:"DejaVu Sans",sans-serif;fill:#e8eff9}
28
28
  <text x="1647" y="239" font-size="15" font-weight="400" style="fill:#a7b8cb">+ Settings</text>
29
29
  <rect x="49" y="253" width="499" height="588" rx="0" fill="#172130"/>
30
30
  <path d="M548 253L548 842" stroke="#3b4b60"/>
31
- <text x="72" y="285" font-size="23" font-weight="700" style="fill:#eef4ff">Claude Code</text>
31
+ <text x="72" y="285" font-size="23" font-weight="700" style="fill:#eef4ff">Pi example</text>
32
32
  <text x="248" y="284" font-size="16" font-weight="400" style="fill:#8ca0b8">workspace</text>
33
33
  <rect x="368" y="263" width="62" height="28" rx="6" fill="#1a4a3a"/>
34
34
  <text x="378" y="283" font-size="14" font-weight="600" style="fill:#8ae6c2">Linked</text>
@@ -36,26 +36,26 @@ text{font-family:"DejaVu Sans",sans-serif;fill:#e8eff9}
36
36
  <text x="448" y="283" font-size="14" font-weight="600" style="fill:#a7b8cb">Details</text>
37
37
  <text x="519" y="285" font-size="22" font-weight="400" style="fill:#8ca0b8">×</text>
38
38
  <rect x="72" y="302" width="196" height="33" rx="5" fill="#243247" stroke="#3a4c65"/>
39
- <text x="82" y="325" font-size="15" style="fill:#e8eff9">Claude Code (local)</text>
39
+ <text x="82" y="325" font-size="15" style="fill:#e8eff9">Pi SDK (example)</text>
40
40
  <text x="246" y="325" font-size="20" style="fill:#a7b8cb">⌄</text>
41
41
  <rect x="276" y="302" width="248" height="33" rx="5" fill="#202d40"/>
42
- <text x="284" y="325" font-size="14" style="fill:#e8eff9">sonnet</text>
42
+ <text x="284" y="325" font-size="14" style="fill:#e8eff9">default</text>
43
43
  <text x="390" y="325" font-size="14" style="fill:#a7b8cb">reasoning: high</text>
44
44
  <g transform="translate(0 -40)">
45
45
  <rect x="72" y="384" width="88" height="28" rx="6" fill="#344132"/>
46
- <text x="82" y="404" font-size="15" font-weight="600" style="fill:#d4e9a1">Running</text>
46
+ <text x="82" y="404" font-size="15" font-weight="600" style="fill:#d4e9a1">Done</text>
47
47
  <text x="174" y="405" font-size="15" font-weight="400" style="fill:#a7b8cb">Context —</text>
48
- <text x="290" y="405" font-size="15" font-weight="400" style="fill:#8ae6c2">Control 2</text>
49
- <text x="387" y="405" font-size="15" font-weight="600" style="fill:#8ae6c2">Release</text>
50
- <text x="461" y="405" font-size="14" font-weight="400" style="fill:#a7b8cb">Fwd on</text>
48
+ <text x="290" y="405" font-size="15" font-weight="400" style="fill:#8ae6c2">Control —</text>
49
+
50
+ <text x="461" y="405" font-size="14" font-weight="400" style="fill:#a7b8cb">Fwd off</text>
51
51
  <rect x="72" y="419" width="452" height="80" rx="8" fill="#21324b" stroke="#3b4f70"/>
52
52
  <text x="86" y="442" font-size="14" font-weight="600" style="fill:#b9d3f7">You</text>
53
- <text x="86" y="467" font-size="17" font-weight="400" style="fill:#e8eff9">Check staging-db first, then staging-app.</text>
54
- <text x="86" y="489" font-size="17" font-weight="400" style="fill:#e8eff9">Verify connectivity and the health check.</text>
53
+ <text x="86" y="467" font-size="17" font-weight="400" style="fill:#e8eff9">/remember Check staging services.</text>
54
+ <text x="86" y="489" font-size="17" font-weight="400" style="fill:#e8eff9">Verify database and application health.</text>
55
55
  <rect x="72" y="509" width="452" height="80" rx="8" fill="#1b2839" stroke="#344458"/>
56
56
  <text x="86" y="533" font-size="14" font-weight="600" style="fill:#8ae6c2">Assistant</text>
57
- <text x="86" y="557" font-size="17" font-weight="400" style="fill:#e8eff9">Database step verified. Application next.</text>
58
- <text x="86" y="578" font-size="17" font-weight="400" style="fill:#e8eff9">Goal active: continuing automatically.</text>
57
+ <text x="86" y="557" font-size="17" font-weight="400" style="fill:#e8eff9">Checks passed; recording archived.</text>
58
+ <text x="86" y="578" font-size="17" font-weight="400" style="fill:#e8eff9">Workflow alias saved: /pm1.</text>
59
59
  <text x="75" y="606" font-size="15" font-weight="600" style="fill:#a7b8cb">Workflows</text>
60
60
  <text x="205" y="606" font-size="15" font-weight="600" style="fill:#8ae6c2">Scheduled tasks</text>
61
61
  <rect x="72" y="619" width="452" height="92" rx="7" fill="#1a2938" stroke="#35534f"/>
@@ -64,8 +64,8 @@ text{font-family:"DejaVu Sans",sans-serif;fill:#e8eff9}
64
64
  <text x="85" y="692" font-size="15" font-weight="400" style="fill:#8ae6c2">Run now Pause Run history</text>
65
65
  </g>
66
66
  <rect x="72" y="683" width="452" height="93" rx="7" fill="#101a27" stroke="#42546d"/>
67
- <text x="85" y="707" font-size="16" font-weight="400" style="fill:#8ca0b8">/task1 — run the saved workflow</text>
68
- <text x="85" y="728" font-size="12" font-weight="400" style="fill:#8ca0b8">Ctrl / Cmd + Enter to send</text>
67
+ <text x="85" y="707" font-size="16" font-weight="400" style="fill:#8ca0b8">Workflow alias saved: /pm1</text>
68
+ <text x="85" y="728" font-size="12" font-weight="400" style="fill:#8ca0b8">/pm1 will verify the live targets again.</text>
69
69
  <text x="73" y="812" font-size="14" font-weight="400" style="fill:#a7b8cb">Tools</text>
70
70
  <rect x="115" y="792" width="159" height="28" rx="6" fill="#253348"/>
71
71
  <text x="125" y="812" font-size="14" font-weight="600" style="fill:#a7b8cb">Terminal tools</text>
@@ -107,7 +107,7 @@ text{font-family:"DejaVu Sans",sans-serif;fill:#e8eff9}
107
107
  <text x="1178" y="654" font-size="18" font-weight="400" style="fill:#8ca0b8" class="mono">}</text>
108
108
  <text x="1178" y="685" font-size="18" font-weight="400" style="fill:#c7b6f6" class="mono">deploy@staging-app:~$</text>
109
109
  <path d="M549 806H1751" stroke="#2b3a4d"/>
110
- <text x="574" y="830" font-size="16" font-weight="400" style="fill:#a7b8cb">2 SSH terminals · Input can be reclaimed from the sidebar at any time</text>
110
+ <text x="574" y="830" font-size="16" font-weight="400" style="fill:#a7b8cb">2 SSH terminals · Output read on demand · Automatic forwarding off</text>
111
111
  <rect x="48" y="878" width="1050" height="254" rx="12" fill="#172130" stroke="#35475c"/>
112
112
  <text x="72" y="915" font-size="24" font-weight="650" style="fill:#edf5ff">Settings / AI Tools</text>
113
113
  <text x="72" y="952" font-size="18" font-weight="400" style="fill:#a7b8cb">Default connection</text>
@@ -127,20 +127,20 @@ text{font-family:"DejaVu Sans",sans-serif;fill:#e8eff9}
127
127
  <text x="72" y="1086" font-size="16" font-weight="500" style="fill:#8ae6c2">Codex · Claude Code · OpenAI · DeepSeek · GLM · Kimi API / Plan · Alibaba Plan · Claude API</text>
128
128
  <text x="72" y="1115" font-size="14" style="fill:#a7b8cb">Goals continue automatically · Default tool-round limit: 0 (unlimited)</text>
129
129
  <rect x="1122" y="878" width="630" height="254" rx="12" fill="#172130" stroke="#35475c"/>
130
- <text x="1146" y="915" font-size="22" font-weight="650" style="fill:#edf5ff">Kimi Coding Plan / Step 2: reasoning</text>
131
- <text x="1146" y="946" font-size="16" style="fill:#a7b8cb">Region: China mainland / International / Custom</text>
130
+ <text x="1146" y="915" font-size="22" font-weight="650" style="fill:#edf5ff">Pi SDK / Example runtime settings</text>
131
+ <text x="1146" y="946" font-size="16" style="fill:#a7b8cb">Runtime: isolated Node 22.19+ process</text>
132
132
  <rect x="1146" y="960" width="580" height="31" rx="5" fill="#233246"/>
133
- <text x="1160" y="981" font-size="16">kimi-for-coding · reasoning: max</text>
134
- <text x="1160" y="1015" font-size="16">low</text>
135
- <text x="1315" y="1015" font-size="16">high</text>
133
+ <text x="1160" y="981" font-size="16">Node executable: /path/to/node</text>
134
+ <text x="1160" y="1015" font-size="16">API Agent</text>
135
+ <text x="1315" y="1015" font-size="16">Pi SDK</text>
136
136
  <rect x="1475" y="997" width="251" height="28" rx="5" fill="#286a54"/>
137
- <text x="1490" y="1016" font-size="16" style="fill:#e8fff5">max ✓</text>
138
- <text x="1146" y="1052" font-size="15" style="fill:#a7b8cb">Custom effort (optional)</text>
137
+ <text x="1490" y="1016" font-size="16" style="fill:#e8fff5">Pi SDK selected</text>
138
+ <text x="1146" y="1052" font-size="15" style="fill:#a7b8cb">Automatic compaction (optional)</text>
139
139
  <rect x="1146" y="1063" width="461" height="28" rx="5" fill="#233246"/>
140
- <text x="1160" y="1083" font-size="14" style="fill:#a7b8cb">Provider default</text>
140
+ <text x="1160" y="1083" font-size="14" style="fill:#a7b8cb">Off by default; /compact manually</text>
141
141
  <rect x="1619" y="1063" width="107" height="28" rx="5" fill="#253348"/>
142
- <text x="1648" y="1083" font-size="14">Apply</text>
143
- <text x="1146" y="1116" font-size="15" style="fill:#8ae6c2">Alibaba Coding Plan also offers regional presets</text>
142
+ <text x="1648" y="1083" font-size="14">Saved</text>
143
+ <text x="1146" y="1116" font-size="15" style="fill:#8ae6c2">Host tools only · Existing approval and workflow policies</text>
144
144
  <rect x="48" y="1152" width="1704" height="204" rx="12" fill="#172130" stroke="#35475c"/>
145
145
  <text x="72" y="1189" font-size="22" font-weight="650" style="fill:#edf5ff">Custom (OpenAI compatible) / Example connection settings</text>
146
146
  <text x="72" y="1223" font-size="16" style="fill:#a7b8cb">API protocol</text>
@@ -155,7 +155,7 @@ text{font-family:"DejaVu Sans",sans-serif;fill:#e8eff9}
155
155
  <text x="890" y="1271" font-size="16" style="fill:#a7b8cb">Model ID</text>
156
156
  <rect x="1080" y="1249" width="646" height="33" rx="5" fill="#233246"/>
157
157
  <text x="1096" y="1272" font-size="16">your-model-id / Discover or enter manually</text>
158
- <text x="72" y="1326" font-size="16" style="fill:#8ae6c2">Streaming + function tools required · localhost HTTP supported · Connection test available</text>
158
+ <text x="72" y="1326" font-size="16" style="fill:#8ae6c2">/compact retains original history · Summaries use quota · Structured retry countdown · Stop cancels backoff</text>
159
159
  <text x="49" y="1393" font-size="16" font-weight="400" style="fill:#8ca0b8">INTERFACE ILLUSTRATION · Example connections and task output; not a running screenshot.</text>
160
160
  <text x="49" y="1418" font-size="14" font-weight="400" style="fill:#8ca0b8">Appearance varies with your Tabby theme, window size and configured connections.</text>
161
161
  </svg>
@@ -2,7 +2,7 @@
2
2
 
3
3
  [← 返回 README](../README.md) · [使用指南](guide.md)
4
4
 
5
- 后续设置页的信息组织、Provider 定义和每周接入排期见 [Provider 配置改版与路线图](provider-roadmap.md)。该文档是待实施计划,功能与发布状态按每周验收记录更新。
5
+ 后续供应商设置页改版尚未实现;规划和研究资料仅保留在本地,不随插件分发。功能与发布状态以实际代码和发布说明为准。
6
6
 
7
7
  v0.4.1 已优先加入 `provider: custom`:可选 `apiFormat: chat-completions | responses`,缺省为 Chat Completions。`apiPath` / `usesResponsesApi` 统一推理路径与工具结果格式;模型发现仍用 `/models`。`keySource: none` 仅限自定义连接,密钥服务返回空值且请求省略认证头。自定义协议加入历史指纹,既有供应商指纹不变;切换协议通过已有通用上下文导入路径处理。设置中变更协议、端点或密钥会取消并清除旧连接测试和模型列表,旧异步结果不能覆盖新状态。自定义接口不推断厂商 Thinking 参数,不硬编码模型能力。
8
8
 
@@ -17,7 +17,7 @@ npm test
17
17
  npm run build
18
18
  ```
19
19
 
20
- CI 使用 Node.js 20,在 Ubuntu、macOS 和 Windows 上运行类型检查、测试和构建。开发时可用 `TABBY_PLUGINS=/path/to/tabby-ai-tools tabby --debug` 加载插件。
20
+ CI 使用 Node.js 22.19.0,在 Ubuntu、macOS 和 Windows 上运行类型检查、测试和构建。开发时可用 `TABBY_PLUGINS=/path/to/tabby-ai-tools tabby --debug` 加载插件。
21
21
 
22
22
  ### 安装后的重启提示
23
23
 
@@ -94,7 +94,7 @@ npm run skill:check # 检查内嵌知识与 skill 文件是否一致
94
94
 
95
95
  任务流程仅由 `/remember TASK` 开始录制,结束后设置别名,`/task1` 执行。`src/sudo-workflow.ts` 构造终端内非交互预检与保活,`src/tab-tools.ts` 管理其任务生命周期;使用假 sudo 测试预检失败和跨命令保活,不能替代真实桌面/SSH 策略验证。
96
96
 
97
- 流程身份和验收采用结构化 `TaskStep.server/dependsOn/verification/verificationCommands`。`read_tab` 仅提取连接字段白名单和会话路径;`workflow_checkpoint` 由面板路由到 `TaskMemory`,使用同终端新观察和串行发送门禁。通用规则在 bundled skill,具体流程和约束由发送时隐藏提示注入。旧库字段可选保持兼容;新录制须有完整身份及逐步验收。不将单纯读取或发送回执作为成功证明,语义验收仍由模型判断。
97
+ 流程身份和验收采用结构化 `TaskStep.server/dependsOn/verification/verificationCommands`。`read_tab` 仅提取连接字段白名单和会话路径;`workflow_checkpoint` 由面板路由到 `TaskMemory`,使用同终端新观察和串行发送门禁。通用规则在 bundled skill,具体流程和约束由发送时隐藏提示注入。旧库字段可选保持兼容;新录制须有完整身份及逐步验收。不将单纯读取或发送回执作为成功证明,语义验收仍由模型判断。`workflow_status` 与 `workflow_set_alias` 同样由面板路由:前者区分录制、别名执行、归档中、拒绝归档和写盘失败,后者仅操作本会话/目录最近完成的显式录制,禁止只读模式修改。checkpoint 返回录制模式和归档资格;写盘失败保留已验收记录供别名工具重试,不重放终端命令。发送后续目标前等待完成中的归档,避免清理录制进度。最近录制及失败重试缓冲仅在当前进程保留,重启后已落盘流程仍通过设置管理。
98
98
 
99
99
  终端接管由 `send_input` 自动处理,不再生成 `local/terminalTakeover` 请求。检测未知(SSH、无枚举接口、枚举异常)时不因检测能力缺失暂停,不盲发 Ctrl+C;已检测的无关进程需要 `foregroundTaskNeeded=false`,发送 Ctrl+C 并验证停止。保留任务所需进程、会话/所有权检查、取消与只读限制。
100
100
 
@@ -111,3 +111,21 @@ API / Claude Code 的 active Goal 在普通文本响应结束后由 `ApiAgent`
111
111
  `model-reasoning.ts` 为缺少服务端能力元数据的已知模型提供保守等级,模型浮窗对 API / Claude Code 统一提供第二步、默认值与手动输入。离线 HTTP / CLI 测试覆盖选中后保存、下一次推理请求中的供应商原生参数、默认值清除及保存失败回滚。不以真实模型调用作为常规验证。
112
112
 
113
113
  Kimi/百炼 Coding Plan 的实现与验证边界见 [配置说明](coding-plans.md)。本地夹具还验证区域端点预设、保留自定义代理和密钥草稿、切换区域取消旧模型发现、两套 Kimi Key 配置、持久缓存标识、仅思考模型参数和百炼 `enable_thinking`。没有运行收费模型或证明真实套餐准入;区域的可用模型与额度须以各平台控制台为准。
114
+
115
+ ## 终端回显与重试回归
116
+
117
+ 面板不订阅 `terminalOutput.updates$`,移除了 700ms / 2,000 字符批次经 `turn/steer` 注入的路径。终端服务仍使用有界缓冲供 `read_tab` 和用户发送/继续时的一次摘要读取;重试等待只用每秒刷新的本地 UI 时钟展示已等待时长与可用的倒计时,不创建模型请求或新的后台重试循环;恢复、断线、换会话、取消和销毁面板时清理 UI 时钟。
118
+
119
+ `turn-retry.ts` 识别字符串错误类别与结构化 `httpStatusCode: 429`。本地 Codex app-server 生成的 `ErrorNotification` 仅包含 `error / willRetry / threadId / turnId`;`TurnError` 的 `message / additionalDetails` 可以包含重试时长,但没有独立截止时间字段。只解析明确的 `retry in/after N seconds/ms/minutes` 文本;缺失时显示未知。后台日志中未发给客户端的信息不会被推测或轮询数据库补齐。
120
+
121
+ `test/turn-retry.test.js` 使用真实终端缓冲和模拟后台事件,覆盖一万段高频回显、等待期合并、重试时间缺失与显式时长、重复错误合并、旧回合事件、停止失败/成功、断线与恢复、UI 时钟自动刷新与清理。`test/task-memory-panel.test.js` 覆盖第二步已发送后限流、中断、恢复读取验收并继续,不重复发送 stash 或解压。全部为本地夹具;未访问用户 Windows 现场日志、未恢复原任务,也没有真实模型压力测试或 Tabby 桌面端到端验证。
122
+
123
+ ## Optional Pi sidecar and context projections
124
+
125
+ Use Node 22.19+ (`.nvmrc` and both CI workflows pin 22.19.0). Angular 15/webpack retain TypeScript 4.9; `typescript-pi` aliases the pinned 5.9.3 compiler for `runtime/pi/tsconfig.json` in NodeNext mode. `npm run typecheck` checks both boundaries, `npm test` first builds the sidecar, and `npm run build` emits `dist/index.js` plus `dist/pi/sidecar.mjs`. Pi is a runtime npm dependency, loaded only in the external Node process. Do not import its ESM SDK into the Angular bundle or assume the host Electron Node meets its engine requirement.
126
+
127
+ `PiBackend` reuses the host's API thread/UI/tool-policy port, while `PiAdapter` delegates the complete native loop to the SDK. The pipe acknowledges persisted session setup and accepted input before inference. Host action intents/results are stored before/after execution; repeated IDs use the saved result or return unknown-state evidence. Process exit aborts pending host tool waits. No process auto-restart or whole-prompt retry is allowed. `agent/lifecycle` carries structured retry, compaction and settled events; the panel clock only displays the supplied delay.
128
+
129
+ `api-context.ts` owns immutable API request projections. Summaries record source hashes/ranges and retain whole batches from a user-turn boundary; private reasoning is not passed to the summarizer. Pi session JSONL is the authority for Pi model context, with the Tabby store used for UI, goals, journals and portable migrations. The existing structured workflow state and checkpoint enforcement stay in the host.
130
+
131
+ `test/pi-agent.test.js` uses actual local HTTP streaming fixtures, without credentials or real model calls. Validate persistence, retry-after-tool, cancellation, budget/quota, repeated compaction and raw entry retention. The isolated Linux desktop fixture additionally loaded the plugin in official Tabby 1.0.238 (Electron 43.7.0 / Node 24.21.0), rendered runtime settings and exercised the sidebar → Node 22.19 Pi → host list_tabs → verified Goal flow. It used Xvfb and no real model. Windows/macOS, SSH/PTY mutations and real-provider execution still require their actual environments. See [runtime details](pi.md) and the [unreleased change note](releases/pi-runtime.md).
package/docs/guide.md CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  - 本机安装 [Tabby](https://github.com/Eugeny/tabby),并能访问所选 AI 服务。操作内网服务器时,本机还需能通过 Tabby 连接目标服务器。
14
14
  - **ChatGPT 订阅/Codex 登录模式**:本机安装 Codex CLI,在本地终端执行 `codex login`,使用具备 Codex 权限的 ChatGPT 账号登录,再执行 `codex login status` 确认认证状态,无需在插件中填写 API Key。插件默认连接选 **Codex(本机登录)**;可用模型、用量和工作区权限以账号实际权益为准。见 [OpenAI 官方认证说明](https://learn.chatgpt.com/docs/auth)。CLI 需支持 `thread/goal/*`;已测试版本见[验证记录](../VALIDATION.md)。
15
- - **Claude 订阅/Claude Code 本机模式(开发版)**:本机安装官方 Claude Code,运行 `claude auth login`,用 `claude auth status` 核对账号与认证方式。在侧栏或默认连接中选择 **Claude Code(本机登录)**;无需在插件里配置订阅凭据。API Key/云平台可能使用独立计费。完整方案、权限、恢复机制与验证限制见 [Claude Code 接入](claude-code.md)。
15
+ - **Claude 订阅/Claude Code 本机模式**:本机安装官方 Claude Code,运行 `claude auth login`,用 `claude auth status` 核对账号与认证方式。在侧栏或默认连接中选择 **Claude Code(本机登录)**;无需在插件里配置订阅凭据。API Key/云平台可能使用独立计费。完整方案、权限、恢复机制与验证限制见 [Claude Code 接入](claude-code.md)。
16
16
  - **API 模式**:准备 OpenAI、DeepSeek、GLM、Kimi、百炼 Coding Plan 或 Claude 对应的 Key,无需安装 Codex CLI。订阅登录与 API 连接是两种独立配置方式。
17
17
 
18
18
  ### 安装插件
@@ -162,7 +162,7 @@ API 工具循环检测始终启用,无需等到轮数上限。近期同一段
162
162
 
163
163
  ## 重复任务与操作习惯
164
164
 
165
- 用 `/remember 任务描述` 明确开始录制,插件执行任务并记录已核对的终端步骤;完成后提示是否设置别名,例如 `task1`。之后直接发送 `/task1` 执行流程。普通任务不再自动归档,也不再按相似描述自动匹配;输入框中的“不检索记忆”复选框已移除。点击 **任务流程** 或输入 `/workflows` 查看当前目录的流程,设置中可以给已有流程添加别名。
165
+ 用 `/remember 任务描述` 明确开始录制,插件执行任务并记录已核对的终端步骤;完成后提示是否设置别名,例如 `task1`。之后直接发送 `/task1` 执行流程。普通任务不再自动归档,也不再按相似描述自动匹配;输入框中的“不检索记忆”复选框已移除。点击 **任务流程** 或输入 `/workflows` 查看当前目录的流程,设置中可以给已有流程添加别名。也可以直接告诉助手“设置别名为 pm1”:助手先用 `workflow_status` 核对本会话最近录制的目标与归档状态,再用 `workflow_set_alias` 保存并回读 `/pm1`。checkpoint 成功仅表示步骤验收;录制不完整或含敏感内容时会说明无法归档的原因。普通任务不能事后保存为流程,不能为了补存而重跑已完成操作。
166
166
 
167
167
  含 sudo 的流程会提前提示在每个实际执行终端运行 `sudo -v` 或 `sudo ls`,完成认证后继续。其他终端的认证不保证共享。执行时用 `sudo -n -v` 预检,每 30 秒非交互刷新;认证失效时停止该命令并要求重新认证。详情和清理边界见[任务流程说明](task-workflows.md)。各步骤还保存服务器 IP、持久连接/服务器 ID、操作路径、前置依赖和验收证据。跨服务器也逐步执行:读取对应终端的新结果,并通过步骤确认工具验收后,才放行下一步;目标或路径不符时停止。操作偏好继续在设置页管理,`/remember` 专用于开始任务录制。
168
168
 
@@ -212,7 +212,7 @@ AI Tools 默认在启动 Tabby 时自动展开侧栏,使用默认连接,无
212
212
 
213
213
  | 入口 | 用途 |
214
214
  | --- | --- |
215
- | 工具栏机器人图标 | 打开/收起侧栏,从当前终端绑定自动转发;侧栏边缘可拖动调宽。 |
215
+ | 工具栏机器人图标 | 打开/收起侧栏,从当前终端绑定上下文摘要;侧栏边缘可拖动调宽。 |
216
216
  | 侧栏连接选择、连接图标 | 切换 Codex/API 连接、应用连接参数或重新连接。 |
217
217
  | 模型摘要、Thinking 控件、`/model` | 选择模型、推理强度和支持的思考模式。支持 `/model 模型ID`。 |
218
218
  | `/new` 或 `new` | 开始新会话,保留旧会话。 |
@@ -226,7 +226,7 @@ AI Tools 默认在启动 Tabby 时自动展开侧栏,使用默认连接,无
226
226
  | 侧栏提问选项与审批卡片 | 回答问题、补充自由文本、处理授权。 |
227
227
  | **停止**、**释放**、**临时释放** | 中断 AI 回合、取回全部或单个终端输入权;不会自动撤销已执行命令,已提交命令可能仍运行。 |
228
228
  | **继续当前目标** | 在目标仍未完成时继续推进。 |
229
- | **详情 → 自动转发** | 查看绑定源或停止新增输出自动转发;独立的按需读屏工具仍可使用。 |
229
+ | **详情 → 终端上下文** | 查看或解除摘要源绑定;运行中不自动转发输出,AI 用 `read_tab` 按需读取。 |
230
230
  | 消息复制、**回到最新消息** | 复制文本,恢复滚动跟随。 |
231
231
  | **Settings → AI Tools** | 配置连接、模型、权限、预算、启动、语言、流程偏好和定时任务。 |
232
232
  | 在对话中请求操作 Tabby | AI 可发现连接配置、标签、分屏、设置、快捷键与插件命令;SFTP、隧道等依赖已安装提供者的实际入口,原生弹窗可能需要人工操作。 |
@@ -238,7 +238,7 @@ AI Tools 默认在启动 Tabby 时自动展开侧栏,使用默认连接,无
238
238
 
239
239
  - 发送被拒绝或回合执行失败时,对话区和输入框上方会显示具体原因。用量/频率超限提示等待恢复,并在已收到额度信息时显示重置时间;上下文和预算超限给出相应处理提示。同步发送失败会恢复输入内容;自动重试期间保留执行状态,收到正常回答后清除输入框上方的错误提示。
240
240
 
241
- - **详情**(也可输入 `/status` 打开)完整显示路径、会话 ID、任务状态、查询时 Codex 上报的模型与运行状态、上下文 token 和会话累计、额度、普通用量是否可用、目标、权限、控制终端列表及自动转发说明,并保留 **刷新** 查询。各项独立读取,部分读取失败时仍显示其他信息。详情高度受限且可滚动,窄侧栏内完整信息自动换行;详情与 `/resume` 历史列表互斥。历史、输出等异常通知仍直接显示。还支持 `/new` 和 `/help`。
241
+ - **详情**(也可输入 `/status` 打开)完整显示路径、会话 ID、任务状态、查询时 Codex 上报的模型与运行状态、上下文 token 和会话累计、额度、普通用量是否可用、目标、权限、控制终端列表及终端上下文说明,并保留 **刷新** 查询。各项独立读取,部分读取失败时仍显示其他信息。详情高度受限且可滚动,窄侧栏内完整信息自动换行;详情与 `/resume` 历史列表互斥。历史、输出等异常通知仍直接显示。还支持 `/new` 和 `/help`。
242
242
 
243
243
  - 上下文摘要收到 Codex 的 token 用量通知后显示百分比;未上报时显示“上下文 —”。**详情** 显示最近一次模型请求的用量、上下文窗口大小和会话累计 token;切换会话时会清空旧会话数字,等待新通知。
244
244
 
@@ -258,7 +258,8 @@ AI Tools 默认在启动 Tabby 时自动展开侧栏,使用默认连接,无
258
258
 
259
259
  ## 终端输出与远程环境
260
260
 
261
- - 从终端点击工具栏图标会绑定该终端作为自动转发源;按游标只把新片段送给 Codex。同目录有多个终端时,恢复后的 AI 面板不会猜测自动转发源,需要从目标终端再次点击工具栏图标。AI 面板可随时在 **详情 → 自动转发** 中点击 **停止自动转发**;之后也可从终端重新绑定。独立的 `tabby_tabs` 工具会监控当前窗口的所有终端标签,以便 Codex 按需读取任意标签;停止自动转发不关闭工具读取能力。
261
+ - 从终端点击工具栏图标会绑定该终端作为上下文摘要源;仅在用户发送新回合或继续目标时附带最多 6,000 字符的新增输出。执行期间的回显保留在有界终端缓冲区,不会通过 `turn/steer` 自动追加或启动模型请求;AI 必须用 `read_tab` 主动读取结果。摘要不是流程验收证据。同目录有多个终端时,恢复后的 AI 面板不会猜测摘要源,需要从目标终端再次点击工具栏图标。可在 **详情 → 终端上下文** 中点击 **解除绑定**,独立的 `tabby_tabs` 按需读取不受影响。
262
+ - 收到后台 `willRetry` 错误事件后,侧栏保持回合执行中并显示限流/重试等待和实时已等待时长,暂时禁用追加发送。后台错误文本明确提供等待时长时显示下次重试时间及倒计时;倒计时结束但尚无返回时明确显示等待后台结果,否则显示“后台未提供下次重试时间”;账号额度重置时间不等同于下次重试时间。点击 **停止** 请求取消后台回合,收到中断结果后再继续。429 可能是请求频率或用量限制,不能仅据此认定长期额度耗尽;避免反复停止并立即新建任务。CLI 只写入本地日志、没有发送事件的信息无法在面板中展示。恢复流程先核对终端结果、产物、目录和 Git 状态,再验收待确认步骤,不重放已发送的 stash、restore、apply。
262
263
 
263
264
  - 新任务启动时最多附带 6,000 字,运行中每批最多 2,000 字、每回合最多 16,000 字,超出部分留给后续回合。缓存只保留已绑定终端最近 32,768 字;缓存溢出时会明确标记截断。`new` 会丢弃旧会话的未发送终端输出。
264
265
 
@@ -312,3 +313,11 @@ NVM 优先 current,其余按 Node 版本降序。IDE 同时支持 `.vscode-ins
312
313
 
313
314
  本地安装后请在 **已安装插件** 中查看;**可用插件** 列表来自 npm 搜索,未发布到 npm 的本地包不会出现在该列表。
314
315
 
316
+
317
+ ## Pi 与上下文压缩(v0.5.0)
318
+
319
+ 在 API 连接的“Agent 运行时”中选择 Pi SDK,填写外部 Node 22.19+ 的可执行文件路径,然后从侧栏重新连接。供应商、模型、Base URL 和密钥来源沿用连接设置;Pi 不提供订阅认证。仅开放 Tabby 宿主工具,审批、只读、终端所有权、sudo 与流程 checkpoint 继续生效。
320
+
321
+ 空闲时输入 `/compact` 手动压缩。内置 API 保留原始历史,按完整工具批次投影请求;Pi 保留自己的 JSONL 原始条目和压缩边界。自动压缩默认关闭,摘要本身消耗额度并计入 Goal 预算。Pi 的重试倒计时使用 SDK 结构化事件,取消会结束独立进程,不重放整段任务。中断后先读取真实终端再继续,未知动作不会自动重放。
322
+
323
+ Pi 的使用、存储、预算和验证限制见 [Pi runtime](pi.md)。开发与 CI 使用 Node 22.19+;升级系统 Node 不会改变 Electron 内置 Node。当前已验证本地 HTTP 夹具,并在独立配置的 Linux Tabby 1.0.238(Electron 43.7.0 / Node 24.21.0)中跑通侧栏、Pi 子进程、宿主 list_tabs 与 Goal 完成;真实模型、SSH/PTY 修改操作和 macOS/Windows 桌面仍待实测。此功能从 v0.5.0 开始提供。
package/docs/pi.md ADDED
@@ -0,0 +1,41 @@
1
+ # Pi runtime
2
+
3
+ Version 0.5.0 offers **Pi SDK** as an optional runtime for API connections. It uses pinned `@earendil-works/pi-coding-agent` / `pi-ai` 1.4.0 in a separate ESM Node process. Codex and Claude Code remain independent CLI connections.
4
+
5
+ ## Setup
6
+
7
+ 1. Install an external **Node 22.19.0 or newer**. Updating your shell's Node does not update Electron's embedded Node.
8
+ 2. Install or update `tabby-ai-tools` to version 0.5.0 or newer in **Settings → Plugins**, then restart Tabby. For source installations, use Node 22.19+ to run `npm ci`, `npm run build` and `npm run install:tabby -- "<Plugins Directory>"`; the installer also installs runtime dependencies.
9
+ 3. In **Settings → AI Tools**, select an API connection, choose **Agent runtime → Pi SDK**, and enter its external Node executable if `node` is absent from Tabby's PATH. Use a real Node executable, not Tabby's executable or a shell command with flags.
10
+ 4. Keep the existing provider, Base URL, model ID and key source. OpenAI uses Responses, Claude API uses Anthropic Messages, and the other presets use Chat Completions; custom connections keep their selected protocol. Kimi Coding explicitly uses `system` messages and `max_tokens`, including international and proxy endpoints, rather than relying on SDK URL detection. API billing applies; choosing Pi does not provide a ChatGPT or Claude subscription login.
11
+ 5. Connect from the sidebar. The sidebar’s **Details** panel reports external Node and host Node/Electron versions. The explicit connection test uses the real Pi process and a harmless nonce tool; it consumes model quota when requested.
12
+
13
+ Only the Tabby tools advertised by the host are available. Pi's built-in shell, filesystem tools, extensions, project context files, external skills, MCP discovery, prompt templates and cache warming are disabled. The existing Tabby skill and task context are supplied by the host. Terminal tools run serially, with the same read-only rules, approvals, terminal ownership, sudo handling and workflow checkpoints as other connections. A command being sent is not evidence that it completed.
14
+
15
+ ## Context and history
16
+
17
+ `/compact` manually summarizes an idle API or Pi conversation. It consumes model quota. For the built-in API runtime, the original messages remain intact; an independently checked summary projection cuts only at a user-turn boundary so a complete tool batch stays together. Source ranges, a source hash, retained index and summary token usage are saved. Codex and Claude Code continue managing their own native context.
18
+
19
+ For Pi, the SDK's JSONL session is the sole native model context. Compaction appends a summary with its retained entry boundary; old entries remain readable. Tabby keeps a UI transcript, goal, action journal and portable handoff rather than replacing Pi's history. Changing runtime, model, provider or protocol creates a portable handoff into a separate session. Original native histories stay on disk. Manual compaction does not acknowledge host-only input: queued corrections and interruption recovery notices remain pending until a subsequent normal prompt imports them into Pi.
20
+
21
+ Automatic compaction is **off by default**. Enable it per connection after trying manual compaction. The API runtime uses a conservative character estimate at 75% of the configured context window (not an exact tokenizer). Pi uses its own threshold/overflow handling. Summaries preserve constraints and pending checkpoints in their instructions; the host's structured workflow checks remain authoritative regardless of summary text.
22
+
23
+ ## Retries, cancellation and budgets
24
+
25
+ Pi owns its session retries, with two retries and a maximum advertised wait of 60 seconds. Provider SDK retries are disabled, preventing nested retry multiplication. The sidebar consumes structured retry delays; no client timer resends the prompt. Replies truncated by the output token limit are reported as incomplete failures, retaining partial text and reported usage; truncation does not silently restart the Goal or report success. Completion waits for `agent_settled` and process completion. A low-level `agent_end` alone is insufficient.
26
+
27
+ All Pi model requests, retry attempts and summary requests share a **100-request safety cap per invocation**. Summary usage is counted, even when compaction needs more than one request. Reported tokens count toward the current goal budget; after exhaustion, another model request or host tool cannot proceed. An already-started response may exceed the remaining budget; these are reported usage limits, not a provider billing guarantee. Retry and request limits reset for a new invocation; goal token usage persists.
28
+
29
+ The sidecar continues active goals itself using the same native session. Tabby does not wrap Pi with the API persistent-goal loop. Existing host tool limits and repeated-tool detection still apply. Stop remains available during model streaming, tool approval, compaction and backoff and terminates the owned process tree. Appended sidebar input is queued for the next host invocation after the current Pi run settles; use Stop first when a correction must interrupt current work.
30
+
31
+ ## Recovery and storage
32
+
33
+ Sessions live under the Tabby configuration directory in `tabby-agent-sessions/pi/<session-id>/`. Host UI indexes and action journals remain in the existing session store. Use the sidebar history list to resume; reported cumulative usage and the last known model input are restored with the UI history. Do not edit a Pi JSONL file or its host index while a session is active. Missing or unreadable native history stops execution rather than silently creating an empty model context.
34
+
35
+ Each Pi tool call has a stable native action ID. Before execution, Tabby durably records the intent; afterward it records the result. A duplicate returns the recorded result. An intent without a known result never executes again automatically. The private stdin/stdout bridge has no HTTP transport retries and never automatically restarts a failed process. Accepted user-input cursors are recorded in Pi history and acknowledged by the host before inference. Following a crash or lost response, the next prompt instructs the agent to read the terminal and verify actual state before continuing. This does not make arbitrary shell operations transactional or safe to replay under a new action ID.
36
+
37
+ ## Validation boundary
38
+
39
+ Local HTTP fixtures exercise the actual SDK, provider streaming, host tools, retries, cancellation, quota errors, goal continuation, persistent restart, repeated compaction and summary budgets without calling a real model. The three-platform CI matrix uses Node 22.19.0. Running those checks locally on Linux does not establish macOS/Windows or desktop Tabby results. A downloaded official Linux Tabby 1.0.238 was also exercised under Xvfb with an isolated configuration: Electron 43.7.0 / host Node 24.21.0 loaded the plugin, the sidecar used Node 22.19.0, and the sidebar completed a local-provider task through the actual `list_tabs` host bridge and goal update. Runtime settings rendered in the actual app. This covers a local desktop fixture, not SSH/PTY mutation, real-provider/subscription access, macOS or Windows end-to-end behavior. Pi remains optional pending those checks.
40
+
41
+ Upstream API reference: [Pi SDK](https://github.com/earendil-works/pi/blob/f9daca3480732d0042b1df3a6e27221f597a620d/packages/coding-agent/docs/sdk.md).