@pablopunk/tau 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth-storage-Dk3CUY3q.js +1814 -0
- package/dist/bin.js +23 -0
- package/dist/cli-entry-DcDpQ30L.js +13 -0
- package/dist/client-C91-b2CL.js +1 -0
- package/dist/client-y2WkNuZj.js +7977 -0
- package/dist/dist-BFP19NOO.js +432 -0
- package/dist/dist-Bh1bQHZA.js +38890 -0
- package/dist/dist-Cq73_r65.js +3 -0
- package/dist/esm-CMGh_WhC.js +9446 -0
- package/dist/execute-BeGXhU1O.js +1757 -0
- package/dist/fake-claude-connectors-DSP9UC8d.js +1 -0
- package/dist/fake-claude-connectors-sDLeP10T.js +107 -0
- package/dist/fake-claude-sdk-CvqW_1iQ.js +571 -0
- package/dist/fake-claude-thread-script-2iHHwUZM.js +48 -0
- package/dist/last-exit-write-ksHeHGrC.js +9 -0
- package/dist/latest-version-di9hD7cY.js +106 -0
- package/dist/lib-DIX7q_HJ.js +1460 -0
- package/dist/machines-behind-BjGgmSs_.js +257 -0
- package/dist/main-D-Tg9b5Y.js +1610 -0
- package/dist/manager-B_WHbb1U.js +589 -0
- package/dist/names-cTrEXB6w.js +35 -0
- package/dist/node-BpwblPFP.js +56269 -0
- package/dist/pdfjs-nTcHjDPT.js +69856 -0
- package/dist/photon_rs-DBr7W_rK.js +4252 -0
- package/dist/promise.try-CAAOYvMP.js +1426 -0
- package/dist/readability-DsDNO63a.js +1670 -0
- package/dist/real-deps-f96UmLBz.js +89 -0
- package/dist/rolldown-runtime-1p2KPIdQ.js +44 -0
- package/dist/runtime-i-oEtgAl.js +2721 -0
- package/dist/sdk-missing-CHbVbY1G.js +10 -0
- package/dist/sdk-port-BGw9ORUR.js +215 -0
- package/dist/serve-Cmy0rUWr.js +2932 -0
- package/dist/serve-Dmzn5V0l.js +1 -0
- package/dist/service-command-C74K0saj.js +34 -0
- package/dist/service-command-DqcstJ8e.js +1 -0
- package/dist/shell-CQa4e7rx.js +643 -0
- package/dist/skills/builtin/tau/SKILL.md +51 -0
- package/dist/src-DO9LUlhi.js +44088 -0
- package/dist/streamableHttp-BBaRYV9h.js +1 -0
- package/dist/streamableHttp-DPAoMlJd.js +1931 -0
- package/dist/tool-DBZK2lci.js +14335 -0
- package/dist/tool-server-BjP37EJg.js +40 -0
- package/dist/turndown.cjs-Bo1xLg2S.js +15620 -0
- package/dist/turndown.cjs-jpUF50AR.js +3 -0
- package/dist/types-C4M3CRp2.js +7592 -0
- package/dist/undici-8cI97lnP.js +27110 -0
- package/dist/wait-for-lock-B1Qx8GWg.js +1 -0
- package/dist/wait-for-lock-CrSl2mi1.js +25 -0
- package/dist/watchdog.js +47 -0
- package/dist/web/dist/assets/addon-fit-DIOBYJe3.js +1 -0
- package/dist/web/dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/dist/web/dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/dist/web/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/dist/web/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/dist/web/dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/dist/web/dist/assets/index-BktLKZHR.js +108 -0
- package/dist/web/dist/assets/index-D_Aa3Oou.css +2 -0
- package/dist/web/dist/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/web/dist/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/web/dist/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/web/dist/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/web/dist/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/web/dist/assets/wght-DMLdVLkb.css +1 -0
- package/dist/web/dist/assets/xterm-BrP-ENHg.css +1 -0
- package/dist/web/dist/assets/xterm-CerOhKYV.js +16 -0
- package/dist/web/dist/favicon.svg +14 -0
- package/dist/web/dist/index.html +25 -0
- package/package.json +53 -4
- package/README.md +0 -3
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//#region ../core/src/claude-cli/testing/fake-claude-thread-script.ts
|
|
2
|
+
const FAKE_CLAUDE_REPLY = "Fake Claude reply.";
|
|
3
|
+
const FAKE_CLAUDE_TOOL_REPLY = "Fake Claude ran the tool.";
|
|
4
|
+
const TOOL_COMMAND = /^(bash|read) (.+)/s;
|
|
5
|
+
const toolArguments = (tool, rest) => tool === "bash" ? { command: rest } : { path: rest };
|
|
6
|
+
function toolSteps(tool, rest) {
|
|
7
|
+
return [{
|
|
8
|
+
kind: "tools",
|
|
9
|
+
calls: [{
|
|
10
|
+
name: tool,
|
|
11
|
+
arguments: toolArguments(tool, rest)
|
|
12
|
+
}]
|
|
13
|
+
}, {
|
|
14
|
+
kind: "text",
|
|
15
|
+
text: FAKE_CLAUDE_TOOL_REPLY
|
|
16
|
+
}];
|
|
17
|
+
}
|
|
18
|
+
const CONNECTOR_COMMAND = /^connector (\S+) (\S+)/;
|
|
19
|
+
const fakeConnectorResult = (tool) => `Fake connector result for ${tool}.`;
|
|
20
|
+
function connectorSteps(server, tool) {
|
|
21
|
+
return [{
|
|
22
|
+
kind: "tools",
|
|
23
|
+
calls: [{
|
|
24
|
+
name: tool,
|
|
25
|
+
arguments: {},
|
|
26
|
+
connector: {
|
|
27
|
+
server: `claude.ai ${server}`,
|
|
28
|
+
result: fakeConnectorResult(tool)
|
|
29
|
+
}
|
|
30
|
+
}]
|
|
31
|
+
}, {
|
|
32
|
+
kind: "text",
|
|
33
|
+
text: FAKE_CLAUDE_TOOL_REPLY
|
|
34
|
+
}];
|
|
35
|
+
}
|
|
36
|
+
/** The script behind `TAU_FAKE_CLAUDE_CLI=1`: "bash <command>" and "read <path>" call that Pi tool, anything else gets a reply. */
|
|
37
|
+
const fakeThreadScript = (_turn, firstUserText, hasTools) => {
|
|
38
|
+
const connector = hasTools ? CONNECTOR_COMMAND.exec(firstUserText.trim()) : null;
|
|
39
|
+
if (connector?.[1] && connector[2]) return connectorSteps(connector[1], connector[2]);
|
|
40
|
+
const match = hasTools ? TOOL_COMMAND.exec(firstUserText.trim()) : null;
|
|
41
|
+
if (match?.[1] && match[2]) return toolSteps(match[1], match[2]);
|
|
42
|
+
return [{
|
|
43
|
+
kind: "text",
|
|
44
|
+
text: FAKE_CLAUDE_REPLY
|
|
45
|
+
}];
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { fakeThreadScript };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { appendFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
//#region ../core/src/watchdog/last-exit-write.ts
|
|
3
|
+
/** Synchronous on purpose: the watchdog writes this just before it kills the process. */
|
|
4
|
+
function writeLastExitSync(file, logFile, exit) {
|
|
5
|
+
writeFileSync(file, `${JSON.stringify(exit)}\n`, { mode: 384 });
|
|
6
|
+
if (logFile && exit.reason === "watchdog") appendFileSync(logFile, `tau: watchdog killed the server (${exit.detail ?? exit.reason})\n`);
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { writeLastExitSync as t };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { l as isPlainVersion } from "./src-DO9LUlhi.js";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { randomBytes } from "node:crypto";
|
|
5
|
+
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
//#region src/private-files.ts
|
|
8
|
+
const PRIVATE_DIRECTORY_MODE = 448;
|
|
9
|
+
const PRIVATE_FILE_MODE = 384;
|
|
10
|
+
async function ensurePrivateDirectory(path) {
|
|
11
|
+
await mkdir(path, {
|
|
12
|
+
recursive: true,
|
|
13
|
+
mode: PRIVATE_DIRECTORY_MODE
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
/** Temp file, then rename, so readers never see a half-written file. */
|
|
17
|
+
async function writePrivateFile(path, content) {
|
|
18
|
+
await ensurePrivateDirectory(dirname(path));
|
|
19
|
+
const temporary = `${path}.${process.pid}.tmp`;
|
|
20
|
+
await writeFile(temporary, content, { mode: PRIVATE_FILE_MODE });
|
|
21
|
+
await rename(temporary, path);
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/token.ts
|
|
25
|
+
const TOKEN_BYTES = 32;
|
|
26
|
+
const MIN_TOKEN_LENGTH = 32;
|
|
27
|
+
const tokenPath = (home) => join(home, "token");
|
|
28
|
+
async function readExistingToken(home) {
|
|
29
|
+
try {
|
|
30
|
+
const token = (await readFile(tokenPath(home), "utf8")).trim();
|
|
31
|
+
return token.length >= MIN_TOKEN_LENGTH ? token : void 0;
|
|
32
|
+
} catch {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** The token outlives restarts so open browser tabs keep their cookie. */
|
|
37
|
+
async function readOrCreateToken(home) {
|
|
38
|
+
const existing = await readExistingToken(home);
|
|
39
|
+
if (existing) return existing;
|
|
40
|
+
const token = randomBytes(TOKEN_BYTES).toString("base64url");
|
|
41
|
+
await writePrivateFile(tokenPath(home), `${token}\n`);
|
|
42
|
+
return token;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/version.ts
|
|
46
|
+
/** From the `package.json` next to `src/` and next to `dist/`. */
|
|
47
|
+
function cliVersion() {
|
|
48
|
+
return JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/update/command-runner.ts
|
|
52
|
+
/** Spawns with an args array and no shell. A missing binary is a result with `code: null`. */
|
|
53
|
+
const spawnCommand = (command, args, options) => new Promise((resolve) => {
|
|
54
|
+
const child = spawn(command, [...args], {
|
|
55
|
+
env: options.env ?? process.env,
|
|
56
|
+
stdio: options.stdio === "inherit" ? "inherit" : [
|
|
57
|
+
"inherit",
|
|
58
|
+
options.stdio === "tee" ? "inherit" : "pipe",
|
|
59
|
+
"pipe"
|
|
60
|
+
],
|
|
61
|
+
timeout: options.timeoutMs
|
|
62
|
+
});
|
|
63
|
+
let stdout = "";
|
|
64
|
+
let stderr = "";
|
|
65
|
+
child.stdout?.on("data", (chunk) => {
|
|
66
|
+
stdout += chunk.toString();
|
|
67
|
+
});
|
|
68
|
+
child.stderr?.on("data", (chunk) => {
|
|
69
|
+
stderr += chunk.toString();
|
|
70
|
+
if (options.stdio === "tee") process.stderr.write(chunk);
|
|
71
|
+
});
|
|
72
|
+
child.on("error", (error) => resolve({
|
|
73
|
+
code: null,
|
|
74
|
+
stdout,
|
|
75
|
+
stderr: stderr + error.message
|
|
76
|
+
}));
|
|
77
|
+
child.on("close", (code) => resolve({
|
|
78
|
+
code,
|
|
79
|
+
stdout,
|
|
80
|
+
stderr
|
|
81
|
+
}));
|
|
82
|
+
});
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/update/latest-version.ts
|
|
85
|
+
const PACKAGE_NAME = "@pablopunk/tau";
|
|
86
|
+
const VIEW_TIMEOUT_MS = 15e3;
|
|
87
|
+
const npmOf = (execPath) => join(dirname(execPath), "npm");
|
|
88
|
+
/** The registry's `latest` as plain `x.y.z`; anything else is an error. */
|
|
89
|
+
async function fetchLatestVersion(run, execPath) {
|
|
90
|
+
const args = [
|
|
91
|
+
"view",
|
|
92
|
+
`${PACKAGE_NAME}@latest`,
|
|
93
|
+
"version",
|
|
94
|
+
"--prefer-online"
|
|
95
|
+
];
|
|
96
|
+
const result = await run(npmOf(execPath), args, {
|
|
97
|
+
stdio: "capture",
|
|
98
|
+
timeoutMs: VIEW_TIMEOUT_MS
|
|
99
|
+
});
|
|
100
|
+
if (result.code !== 0) throw new Error(`Could not read the latest version from the npm registry (${result.stderr.trim().split("\n")[0] || `exit ${result.code}`}).`);
|
|
101
|
+
const version = result.stdout.trim();
|
|
102
|
+
if (!isPlainVersion(version)) throw new Error(`The registry returned an unexpected version: ${version}`);
|
|
103
|
+
return version;
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
export { cliVersion as a, writePrivateFile as c, spawnCommand as i, fetchLatestVersion as n, readOrCreateToken as o, npmOf as r, ensurePrivateDirectory as s, PACKAGE_NAME as t };
|