tabby-ai-tools 0.4.1 → 0.5.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 +8 -2
- package/README.zh-CN.md +8 -2
- package/VALIDATION.md +50 -0
- package/dist/index.js +1 -1
- package/dist/pi/THIRD_PARTY_NOTICES.txt +3357 -0
- package/dist/pi/electron-host.cjs +142 -0
- package/dist/pi/provider.mjs +44 -0
- package/dist/pi/sidecar.mjs +304555 -0
- package/docs/assets/overview.png +0 -0
- package/docs/assets/overview.svg +29 -29
- package/docs/development.md +29 -3
- package/docs/guide.md +17 -6
- package/docs/pi.md +47 -0
- package/docs/releases/0.5.0.md +19 -0
- package/docs/releases/0.5.1.md +13 -0
- package/docs/releases/pi-runtime.md +11 -0
- package/docs/releases/unreleased.md +1 -1
- package/docs/task-workflows.md +19 -1
- package/package.json +11 -4
- package/skills/tabby/SKILL.md +12 -2
- package/skills/tabby/references/operations.md +10 -0
- package/docs/provider-roadmap.md +0 -162
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// runtime/pi/electron-host.cts
|
|
21
|
+
var electron_host_exports = {};
|
|
22
|
+
__export(electron_host_exports, {
|
|
23
|
+
fork: () => fork,
|
|
24
|
+
inspect: () => inspect
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(electron_host_exports);
|
|
27
|
+
var import_node_events = require("node:events");
|
|
28
|
+
var import_node_stream = require("node:stream");
|
|
29
|
+
var import_node_path = require("node:path");
|
|
30
|
+
var { app, utilityProcess, webContents } = require("electron");
|
|
31
|
+
function inspect() {
|
|
32
|
+
if (!app.isReady() || typeof utilityProcess?.fork !== "function") throw new Error("Tabby does not support the Pi utility process");
|
|
33
|
+
return { node: process.versions.node, electron: process.versions.electron };
|
|
34
|
+
}
|
|
35
|
+
function fork(ownerId) {
|
|
36
|
+
inspect();
|
|
37
|
+
const owner = webContents.fromId(ownerId);
|
|
38
|
+
if (!owner || owner.isDestroyed()) throw new Error("Pi owner window is unavailable");
|
|
39
|
+
const child = utilityProcess.fork((0, import_node_path.join)(__dirname, "sidecar.mjs"), [], {
|
|
40
|
+
stdio: "pipe",
|
|
41
|
+
serviceName: "Tabby AI Tools \u2014 Pi",
|
|
42
|
+
env: { ...process.env, NODE_OPTIONS: "", NODE_PATH: "", ELECTRON_RUN_AS_NODE: "" }
|
|
43
|
+
});
|
|
44
|
+
const bridge = new import_node_events.EventEmitter();
|
|
45
|
+
let closed = false, buffer = "", diagnostics = 0, stopping;
|
|
46
|
+
bridge.stdout = new import_node_stream.PassThrough();
|
|
47
|
+
bridge.stderr = new import_node_stream.PassThrough();
|
|
48
|
+
bridge.on("error", () => void 0);
|
|
49
|
+
bridge.stdin = new import_node_stream.Writable({ write(chunk, _encoding, callback) {
|
|
50
|
+
try {
|
|
51
|
+
if (closed) throw new Error("Pi utility process has exited");
|
|
52
|
+
buffer += chunk.toString();
|
|
53
|
+
if (Buffer.byteLength(buffer) > 12 * 1024 * 1024) throw new Error("Pi protocol exceeded limit");
|
|
54
|
+
let newline;
|
|
55
|
+
while ((newline = buffer.indexOf("\n")) >= 0) {
|
|
56
|
+
const line = buffer.slice(0, newline);
|
|
57
|
+
buffer = buffer.slice(newline + 1);
|
|
58
|
+
child.postMessage(line);
|
|
59
|
+
}
|
|
60
|
+
callback();
|
|
61
|
+
} catch (error) {
|
|
62
|
+
callback(error);
|
|
63
|
+
}
|
|
64
|
+
} });
|
|
65
|
+
bridge.terminate = () => stopping ||= new Promise((resolve, reject) => {
|
|
66
|
+
if (closed) {
|
|
67
|
+
resolve();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const force = setTimeout(() => {
|
|
71
|
+
if (!closed && child.pid) {
|
|
72
|
+
try {
|
|
73
|
+
process.kill(child.pid, "SIGKILL");
|
|
74
|
+
} catch {
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}, 1500);
|
|
78
|
+
const timeout = setTimeout(() => {
|
|
79
|
+
cleanup();
|
|
80
|
+
reject(new Error("Pi utility process did not exit"));
|
|
81
|
+
}, 5e3);
|
|
82
|
+
const cleanup = () => {
|
|
83
|
+
clearTimeout(force);
|
|
84
|
+
clearTimeout(timeout);
|
|
85
|
+
bridge.off("close", complete);
|
|
86
|
+
};
|
|
87
|
+
const complete = () => {
|
|
88
|
+
cleanup();
|
|
89
|
+
resolve();
|
|
90
|
+
};
|
|
91
|
+
bridge.once("close", complete);
|
|
92
|
+
child.kill();
|
|
93
|
+
});
|
|
94
|
+
const ownerGone = () => {
|
|
95
|
+
void bridge.terminate().catch(() => void 0);
|
|
96
|
+
};
|
|
97
|
+
owner.once("destroyed", ownerGone);
|
|
98
|
+
owner.once("render-process-gone", ownerGone);
|
|
99
|
+
child.on("message", (message) => {
|
|
100
|
+
if (typeof message !== "string" || Buffer.byteLength(message) > 12 * 1024 * 1024) {
|
|
101
|
+
bridge.emit("error", new Error("Pi protocol exceeded limit"));
|
|
102
|
+
ownerGone();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
bridge.stdout.write(message + "\n");
|
|
106
|
+
try {
|
|
107
|
+
const type = JSON.parse(message).type;
|
|
108
|
+
if (type === "done" || type === "fatal") child.postMessage('{"type":"shutdown"}');
|
|
109
|
+
} catch {
|
|
110
|
+
bridge.emit("error", new Error("Invalid Pi protocol"));
|
|
111
|
+
ownerGone();
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
const diagnostic = (chunk, stderr) => {
|
|
115
|
+
diagnostics += chunk.length;
|
|
116
|
+
if (diagnostics > 1024 * 1024) {
|
|
117
|
+
bridge.emit("error", new Error("Pi diagnostics exceeded limit"));
|
|
118
|
+
ownerGone();
|
|
119
|
+
} else if (stderr) bridge.stderr.write(chunk);
|
|
120
|
+
};
|
|
121
|
+
child.stdout?.on("data", (chunk) => diagnostic(chunk, false));
|
|
122
|
+
child.stderr?.on("data", (chunk) => diagnostic(chunk, true));
|
|
123
|
+
child.once("error", () => {
|
|
124
|
+
bridge.emit("error", new Error("Pi utility process failed"));
|
|
125
|
+
ownerGone();
|
|
126
|
+
});
|
|
127
|
+
child.once("exit", (code) => {
|
|
128
|
+
closed = true;
|
|
129
|
+
owner.off("destroyed", ownerGone);
|
|
130
|
+
owner.off("render-process-gone", ownerGone);
|
|
131
|
+
bridge.stdin.destroy();
|
|
132
|
+
bridge.stdout.end();
|
|
133
|
+
bridge.stderr.end();
|
|
134
|
+
bridge.emit("close", code, null);
|
|
135
|
+
});
|
|
136
|
+
return bridge;
|
|
137
|
+
}
|
|
138
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
139
|
+
0 && (module.exports = {
|
|
140
|
+
fork,
|
|
141
|
+
inspect
|
|
142
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createRequire as __tabbyCreateRequire } from "node:module"; const require = __tabbyCreateRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// runtime/pi/provider.mts
|
|
4
|
+
function providerCompat(profile) {
|
|
5
|
+
if (profile.provider === "kimi-coding") return {
|
|
6
|
+
supportsDeveloperRole: false,
|
|
7
|
+
maxTokensField: "max_tokens",
|
|
8
|
+
supportsStore: false,
|
|
9
|
+
supportsStrictMode: false,
|
|
10
|
+
requiresReasoningContentOnAssistantMessages: true
|
|
11
|
+
};
|
|
12
|
+
return void 0;
|
|
13
|
+
}
|
|
14
|
+
function providerPayload(profile, payload) {
|
|
15
|
+
if (!payload || typeof payload !== "object") return payload;
|
|
16
|
+
const body = payload;
|
|
17
|
+
const effort = profile.reasoningEffort;
|
|
18
|
+
if (profile.provider === "openai" || profile.provider === "custom" && profile.apiFormat === "responses") {
|
|
19
|
+
if (effort) body.reasoning = { ...body.reasoning, effort };
|
|
20
|
+
} else if (profile.provider === "claude") {
|
|
21
|
+
delete body.thinking;
|
|
22
|
+
if (profile.thinking === "enabled") body.thinking = { type: "adaptive" };
|
|
23
|
+
if (profile.thinking === "disabled") body.thinking = { type: "disabled" };
|
|
24
|
+
if (effort) body.output_config = { ...body.output_config, effort };
|
|
25
|
+
} else {
|
|
26
|
+
delete body.thinking;
|
|
27
|
+
delete body.enable_thinking;
|
|
28
|
+
delete body.reasoning_effort;
|
|
29
|
+
const alwaysThinks = profile.provider === "kimi" && /^kimi-(k3(?:\.1-pro)?|k2\.7-code)(?:-highspeed)?$/i.test(profile.model);
|
|
30
|
+
if ((alwaysThinks || profile.provider === "kimi-coding" && /^k3\.1-pro(?:-highspeed)?$/i.test(profile.model)) && profile.thinking === "disabled") {
|
|
31
|
+
throw new Error("\u6B64 Kimi \u6A21\u578B\u4EC5\u652F\u6301\u601D\u8003\u6A21\u5F0F\uFF0C\u8BF7\u9009\u62E9\u670D\u52A1\u5546\u9ED8\u8BA4\u6216\u5F00\u542F");
|
|
32
|
+
}
|
|
33
|
+
if (profile.provider !== "custom" && profile.thinking !== "default" && !alwaysThinks) {
|
|
34
|
+
if (profile.provider === "bailian-coding") body.enable_thinking = profile.thinking === "enabled";
|
|
35
|
+
else body.thinking = { type: profile.thinking };
|
|
36
|
+
}
|
|
37
|
+
if (effort && (profile.provider === "custom" || profile.thinking !== "disabled")) body.reasoning_effort = effort;
|
|
38
|
+
}
|
|
39
|
+
return body;
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
providerCompat,
|
|
43
|
+
providerPayload
|
|
44
|
+
};
|