@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.
Files changed (69) hide show
  1. package/dist/auth-storage-Dk3CUY3q.js +1814 -0
  2. package/dist/bin.js +23 -0
  3. package/dist/cli-entry-DcDpQ30L.js +13 -0
  4. package/dist/client-C91-b2CL.js +1 -0
  5. package/dist/client-y2WkNuZj.js +7977 -0
  6. package/dist/dist-BFP19NOO.js +432 -0
  7. package/dist/dist-Bh1bQHZA.js +38890 -0
  8. package/dist/dist-Cq73_r65.js +3 -0
  9. package/dist/esm-CMGh_WhC.js +9446 -0
  10. package/dist/execute-BeGXhU1O.js +1757 -0
  11. package/dist/fake-claude-connectors-DSP9UC8d.js +1 -0
  12. package/dist/fake-claude-connectors-sDLeP10T.js +107 -0
  13. package/dist/fake-claude-sdk-CvqW_1iQ.js +571 -0
  14. package/dist/fake-claude-thread-script-2iHHwUZM.js +48 -0
  15. package/dist/last-exit-write-ksHeHGrC.js +9 -0
  16. package/dist/latest-version-di9hD7cY.js +106 -0
  17. package/dist/lib-DIX7q_HJ.js +1460 -0
  18. package/dist/machines-behind-BjGgmSs_.js +257 -0
  19. package/dist/main-D-Tg9b5Y.js +1610 -0
  20. package/dist/manager-B_WHbb1U.js +589 -0
  21. package/dist/names-cTrEXB6w.js +35 -0
  22. package/dist/node-BpwblPFP.js +56269 -0
  23. package/dist/pdfjs-nTcHjDPT.js +69856 -0
  24. package/dist/photon_rs-DBr7W_rK.js +4252 -0
  25. package/dist/promise.try-CAAOYvMP.js +1426 -0
  26. package/dist/readability-DsDNO63a.js +1670 -0
  27. package/dist/real-deps-f96UmLBz.js +89 -0
  28. package/dist/rolldown-runtime-1p2KPIdQ.js +44 -0
  29. package/dist/runtime-i-oEtgAl.js +2721 -0
  30. package/dist/sdk-missing-CHbVbY1G.js +10 -0
  31. package/dist/sdk-port-BGw9ORUR.js +215 -0
  32. package/dist/serve-Cmy0rUWr.js +2932 -0
  33. package/dist/serve-Dmzn5V0l.js +1 -0
  34. package/dist/service-command-C74K0saj.js +34 -0
  35. package/dist/service-command-DqcstJ8e.js +1 -0
  36. package/dist/shell-CQa4e7rx.js +643 -0
  37. package/dist/skills/builtin/tau/SKILL.md +51 -0
  38. package/dist/src-DO9LUlhi.js +44088 -0
  39. package/dist/streamableHttp-BBaRYV9h.js +1 -0
  40. package/dist/streamableHttp-DPAoMlJd.js +1931 -0
  41. package/dist/tool-DBZK2lci.js +14335 -0
  42. package/dist/tool-server-BjP37EJg.js +40 -0
  43. package/dist/turndown.cjs-Bo1xLg2S.js +15620 -0
  44. package/dist/turndown.cjs-jpUF50AR.js +3 -0
  45. package/dist/types-C4M3CRp2.js +7592 -0
  46. package/dist/undici-8cI97lnP.js +27110 -0
  47. package/dist/wait-for-lock-B1Qx8GWg.js +1 -0
  48. package/dist/wait-for-lock-CrSl2mi1.js +25 -0
  49. package/dist/watchdog.js +47 -0
  50. package/dist/web/dist/assets/addon-fit-DIOBYJe3.js +1 -0
  51. package/dist/web/dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  52. package/dist/web/dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  53. package/dist/web/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  54. package/dist/web/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  55. package/dist/web/dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  56. package/dist/web/dist/assets/index-BktLKZHR.js +108 -0
  57. package/dist/web/dist/assets/index-D_Aa3Oou.css +2 -0
  58. package/dist/web/dist/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  59. package/dist/web/dist/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  60. package/dist/web/dist/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  61. package/dist/web/dist/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  62. package/dist/web/dist/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  63. package/dist/web/dist/assets/wght-DMLdVLkb.css +1 -0
  64. package/dist/web/dist/assets/xterm-BrP-ENHg.css +1 -0
  65. package/dist/web/dist/assets/xterm-CerOhKYV.js +16 -0
  66. package/dist/web/dist/favicon.svg +14 -0
  67. package/dist/web/dist/index.html +25 -0
  68. package/package.json +53 -4
  69. package/README.md +0 -3
@@ -0,0 +1,10 @@
1
+ //#region ../core/src/claude-cli/sdk-missing.ts
2
+ var ClaudeSdkMissingError = class extends Error {
3
+ constructor() {
4
+ super("The Claude Agent SDK is not installed.");
5
+ this.name = "ClaudeSdkMissingError";
6
+ }
7
+ };
8
+ const isSdkMissing = (error) => error instanceof ClaudeSdkMissingError;
9
+ //#endregion
10
+ export { isSdkMissing as n, ClaudeSdkMissingError as t };
@@ -0,0 +1,215 @@
1
+ import { t as ClaudeSdkMissingError } from "./sdk-missing-CHbVbY1G.js";
2
+ import { n as buildToolServer } from "./tool-server-BjP37EJg.js";
3
+ import { createRequire } from "node:module";
4
+ import { dirname, join } from "node:path";
5
+ import { tmpdir } from "node:os";
6
+ import { pathToFileURL } from "node:url";
7
+ import { readFile } from "node:fs/promises";
8
+ import { execFile } from "node:child_process";
9
+ //#region ../core/src/claude-cli/auth-status.ts
10
+ const AUTH_STATUS_TIMEOUT_MS = 5e3;
11
+ const stringOrNull = (value) => typeof value === "string" ? value : null;
12
+ /** Keeps only the four fields tau may read: never the email, ids or tokens. */
13
+ function parseAuthStatus(stdout) {
14
+ const raw = JSON.parse(stdout);
15
+ if (typeof raw !== "object" || raw === null) throw new Error("claude auth status printed no object");
16
+ const fields = raw;
17
+ return {
18
+ loggedIn: fields.loggedIn === true,
19
+ authMethod: stringOrNull(fields.authMethod),
20
+ subscriptionType: stringOrNull(fields.subscriptionType),
21
+ orgName: stringOrNull(fields.orgName)
22
+ };
23
+ }
24
+ const claudeBinary = (env) => env.TAU_CLAUDE_PATH ?? "claude";
25
+ /** A logged-out CLI exits 1 but still prints the JSON, so a non-zero exit with output is an answer. */
26
+ function runAuthStatus(env) {
27
+ return new Promise((resolve, reject) => {
28
+ execFile(claudeBinary(env), [
29
+ "auth",
30
+ "status",
31
+ "--json"
32
+ ], {
33
+ timeout: AUTH_STATUS_TIMEOUT_MS,
34
+ env: { ...env }
35
+ }, (error, stdout) => {
36
+ if (stdout.trim() !== "") {
37
+ try {
38
+ resolve(parseAuthStatus(stdout));
39
+ } catch (parseError) {
40
+ reject(parseError);
41
+ }
42
+ return;
43
+ }
44
+ reject(error ?? /* @__PURE__ */ new Error("claude auth status printed nothing"));
45
+ });
46
+ });
47
+ }
48
+ //#endregion
49
+ //#region ../core/src/claude-cli/sdk-port.ts
50
+ const SDK_PACKAGE = "@anthropic-ai/claude-agent-sdk";
51
+ const API_KEY_VARIABLES = ["ANTHROPIC_API_KEY", "ANTHROPIC_AUTH_TOKEN"];
52
+ const toContextSummary = (usage) => {
53
+ const loadedMcpToolCounts = {};
54
+ for (const tool of usage.mcpTools) if (tool.isLoaded !== false) loadedMcpToolCounts[tool.serverName] = (loadedMcpToolCounts[tool.serverName] ?? 0) + 1;
55
+ return {
56
+ memoryFileCount: usage.memoryFiles.length,
57
+ loadedMcpToolCounts
58
+ };
59
+ };
60
+ const withoutApiKeys = (env) => Object.fromEntries(Object.entries(env).filter(([name]) => !API_KEY_VARIABLES.includes(name)));
61
+ const toServerStatus = (server) => ({
62
+ name: server.name,
63
+ status: server.status,
64
+ source: server.source ?? server.scope ?? null,
65
+ error: server.error ?? null,
66
+ tools: (server.tools ?? []).map((tool) => ({
67
+ name: tool.name,
68
+ readOnly: tool.annotations?.readOnly === true
69
+ }))
70
+ });
71
+ const toSdkCanUseTool = (canUseTool) => (toolName, input, options) => canUseTool({
72
+ toolName,
73
+ input,
74
+ toolUseId: options.toolUseID,
75
+ signal: options.signal,
76
+ mcpServer: options.mcpServer ?? null
77
+ });
78
+ const mcpToggleOf = (query) => ({ toggleMcpServer: (name, enabled) => query.toggleMcpServer(name, enabled) });
79
+ const mcpControlOf = (query) => ({ mcpServerStatus: async () => (await query.mcpServerStatus()).map(toServerStatus) });
80
+ function sdkOptions(sdk, options) {
81
+ const toolServer = options.toolHost ? buildToolServer(sdk.createSdkMcpServer, options.toolHost) : void 0;
82
+ const { prompt: _prompt, toolHost: _host, canUseTool, env, ...rest } = options;
83
+ return {
84
+ ...rest,
85
+ ...canUseTool && { canUseTool: toSdkCanUseTool(canUseTool) },
86
+ env: withoutApiKeys(env),
87
+ ...toolServer && { mcpServers: { ["tau"]: toolServer.config } }
88
+ };
89
+ }
90
+ function wrapQuery(query, exposeToggle) {
91
+ return {
92
+ [Symbol.asyncIterator]: () => query[Symbol.asyncIterator](),
93
+ interrupt: async () => void await query.interrupt(),
94
+ setModel: (model) => query.setModel(model),
95
+ applyFlagSettings: (settings) => query.applyFlagSettings({ ...settings }),
96
+ isAutoCompactEnabled: async () => (await query.getContextUsage()).isAutoCompactEnabled,
97
+ ...mcpControlOf(query),
98
+ ...exposeToggle && mcpToggleOf(query),
99
+ close: () => query.close()
100
+ };
101
+ }
102
+ const probeOptions = (options) => ({
103
+ cwd: tmpdir(),
104
+ settingSources: options.settingSources ?? [],
105
+ tools: [],
106
+ strictMcpConfig: false,
107
+ settings: { disableClaudeAiConnectors: false },
108
+ permissionMode: "dontAsk",
109
+ env: withoutApiKeys(process.env)
110
+ });
111
+ function startProbe(sdk, options, exposeToggle) {
112
+ let release = () => void 0;
113
+ const neverSendsAPrompt = (async function* () {
114
+ await new Promise((resolve) => release = resolve);
115
+ })();
116
+ const query = sdk.query({
117
+ prompt: neverSendsAPrompt,
118
+ options: probeOptions(options)
119
+ });
120
+ return {
121
+ ...mcpControlOf(query),
122
+ ...exposeToggle && mcpToggleOf(query),
123
+ contextSummary: async () => toContextSummary(await query.getContextUsage()),
124
+ close() {
125
+ release();
126
+ query.close();
127
+ }
128
+ };
129
+ }
130
+ const idleOptions = () => ({
131
+ cwd: tmpdir(),
132
+ settingSources: [],
133
+ tools: [],
134
+ strictMcpConfig: true,
135
+ settings: { disableClaudeAiConnectors: true },
136
+ env: withoutApiKeys(process.env)
137
+ });
138
+ async function withIdleQuery(sdk, use) {
139
+ let release = () => void 0;
140
+ const neverSendsAPrompt = (async function* () {
141
+ await new Promise((resolve) => release = resolve);
142
+ })();
143
+ const query = sdk.query({
144
+ prompt: neverSendsAPrompt,
145
+ options: idleOptions()
146
+ });
147
+ try {
148
+ return await use(query);
149
+ } finally {
150
+ release();
151
+ query.close();
152
+ }
153
+ }
154
+ async function readBundledCliVersion(entry) {
155
+ const manifest = JSON.parse(await readFile(join(dirname(entry), "package.json"), "utf8"));
156
+ if (!manifest.claudeCodeVersion) throw new Error("The Agent SDK package has no claudeCodeVersion.");
157
+ return manifest.claudeCodeVersion;
158
+ }
159
+ const toModelOption = (model) => ({
160
+ value: model.value,
161
+ resolvedModel: model.resolvedModel ?? null,
162
+ displayName: model.displayName,
163
+ description: model.description,
164
+ supportedEffortLevels: model.supportedEffortLevels ?? [],
165
+ supportsThinkingOff: model.supportsThinkingOff ?? false
166
+ });
167
+ const toAccountInfo = (info) => ({
168
+ organization: info.organization ?? null,
169
+ subscriptionType: info.subscriptionType ?? null
170
+ });
171
+ function portOf(sdk, entry, exposeToggle) {
172
+ return {
173
+ authStatus: () => runAuthStatus(process.env),
174
+ accountInfo: () => withIdleQuery(sdk, async (query) => toAccountInfo(await query.accountInfo())),
175
+ supportedModels: () => withIdleQuery(sdk, async (query) => (await query.supportedModels()).map(toModelOption)),
176
+ bundledCliVersion: () => readBundledCliVersion(entry),
177
+ startProbe: (options = {}) => startProbe(sdk, options, exposeToggle),
178
+ startQuery(options) {
179
+ return wrapQuery(sdk.query({
180
+ prompt: options.prompt,
181
+ options: sdkOptions(sdk, options)
182
+ }), exposeToggle);
183
+ },
184
+ deleteSession: (sessionId) => sdk.deleteSession(sessionId)
185
+ };
186
+ }
187
+ const resolveInSdkHome = (sdkHome) => {
188
+ try {
189
+ return createRequire(join(sdkHome, "package.json")).resolve(SDK_PACKAGE);
190
+ } catch {
191
+ return null;
192
+ }
193
+ };
194
+ const resolveInDevelopment = () => {
195
+ try {
196
+ return createRequire(import.meta.url).resolve(SDK_PACKAGE);
197
+ } catch {
198
+ return null;
199
+ }
200
+ };
201
+ async function importSdk(sdkHome) {
202
+ const entry = sdkHome && resolveInSdkHome(sdkHome) || resolveInDevelopment();
203
+ if (!entry) throw new ClaudeSdkMissingError();
204
+ return {
205
+ sdk: await import(pathToFileURL(entry).href),
206
+ entry
207
+ };
208
+ }
209
+ /** The only place the Agent SDK is loaded. Nothing imports it while the kill switch is on. */
210
+ async function loadClaudeSdkPort(sdkHome, options = {}) {
211
+ const { sdk, entry } = await importSdk(sdkHome);
212
+ return portOf(sdk, entry, options.exposeToggleForPins ?? false);
213
+ }
214
+ //#endregion
215
+ export { loadClaudeSdkPort };