@aria-cli/tools 1.0.12 → 1.0.14

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 (233) hide show
  1. package/dist/index.js +378 -70
  2. package/dist/network-runtime/index.js +8 -12
  3. package/dist-cjs/index.js +400 -435
  4. package/dist-cjs/network-runtime/index.js +8 -172
  5. package/package.json +8 -6
  6. package/dist/.tsbuildinfo +0 -1
  7. package/dist/ask-user-interaction.js +0 -22
  8. package/dist/cache/web-cache.js +0 -66
  9. package/dist/definitions/arion.js +0 -104
  10. package/dist/definitions/browser/browser.js +0 -418
  11. package/dist/definitions/browser/index.js +0 -4
  12. package/dist/definitions/browser/pw-downloads.js +0 -114
  13. package/dist/definitions/browser/pw-interactions.js +0 -199
  14. package/dist/definitions/browser/pw-responses.js +0 -76
  15. package/dist/definitions/browser/pw-session.js +0 -310
  16. package/dist/definitions/browser/pw-shared.js +0 -66
  17. package/dist/definitions/browser/pw-snapshot.js +0 -301
  18. package/dist/definitions/browser/pw-state.js +0 -62
  19. package/dist/definitions/browser/types.js +0 -4
  20. package/dist/definitions/code-intelligence.js +0 -470
  21. package/dist/definitions/core.js +0 -109
  22. package/dist/definitions/delegation.js +0 -512
  23. package/dist/definitions/deploy.js +0 -65
  24. package/dist/definitions/filesystem.js +0 -196
  25. package/dist/definitions/frg.js +0 -63
  26. package/dist/definitions/index.js +0 -20
  27. package/dist/definitions/memory.js +0 -123
  28. package/dist/definitions/messaging.js +0 -625
  29. package/dist/definitions/meta.js +0 -349
  30. package/dist/definitions/network.js +0 -159
  31. package/dist/definitions/outlook.js +0 -277
  32. package/dist/definitions/patch/apply-patch.js +0 -184
  33. package/dist/definitions/patch/fuzzy-match.js +0 -166
  34. package/dist/definitions/patch/index.js +0 -1
  35. package/dist/definitions/patch/patch-parser.js +0 -207
  36. package/dist/definitions/patch/sandbox-paths.js +0 -105
  37. package/dist/definitions/process/index.js +0 -4
  38. package/dist/definitions/process/process-registry.js +0 -213
  39. package/dist/definitions/process/process.js +0 -386
  40. package/dist/definitions/process/pty-keys.js +0 -254
  41. package/dist/definitions/process/session-slug.js +0 -142
  42. package/dist/definitions/quip.js +0 -195
  43. package/dist/definitions/search.js +0 -60
  44. package/dist/definitions/session-history.js +0 -69
  45. package/dist/definitions/shell.js +0 -181
  46. package/dist/definitions/slack.js +0 -180
  47. package/dist/definitions/web.js +0 -109
  48. package/dist/executors/apply-patch.js +0 -901
  49. package/dist/executors/arion.js +0 -119
  50. package/dist/executors/code-intelligence.js +0 -882
  51. package/dist/executors/deploy.js +0 -848
  52. package/dist/executors/filesystem.js +0 -1122
  53. package/dist/executors/frg-freshness.js +0 -576
  54. package/dist/executors/frg.js +0 -298
  55. package/dist/executors/index.js +0 -46
  56. package/dist/executors/learning-meta.js +0 -1146
  57. package/dist/executors/lsp-client.js +0 -296
  58. package/dist/executors/memory.js +0 -750
  59. package/dist/executors/meta.js +0 -220
  60. package/dist/executors/process-registry.js +0 -465
  61. package/dist/executors/pty-session-store.js +0 -30
  62. package/dist/executors/pty.js +0 -271
  63. package/dist/executors/restart.js +0 -119
  64. package/dist/executors/search-freshness.js +0 -195
  65. package/dist/executors/search-types.js +0 -52
  66. package/dist/executors/search.js +0 -66
  67. package/dist/executors/self-diagnose.js +0 -398
  68. package/dist/executors/session-history.js +0 -283
  69. package/dist/executors/shell-safety.js +0 -473
  70. package/dist/executors/shell.js +0 -954
  71. package/dist/executors/utils.js +0 -33
  72. package/dist/executors/web.js +0 -542
  73. package/dist/extraction/content-extraction.js +0 -235
  74. package/dist/extraction/index.js +0 -4
  75. package/dist/headless-control-contract.js +0 -967
  76. package/dist/local-control-http-auth.js +0 -2
  77. package/dist/mcp/client.js +0 -181
  78. package/dist/mcp/connection.js +0 -480
  79. package/dist/mcp/index.js +0 -10
  80. package/dist/mcp/jsonrpc.js +0 -144
  81. package/dist/mcp/types.js +0 -7
  82. package/dist/network-control-adapter.js +0 -72
  83. package/dist/network-runtime/address-types.js +0 -165
  84. package/dist/network-runtime/db-owner-fencing.js +0 -69
  85. package/dist/network-runtime/delivery-receipts.js +0 -267
  86. package/dist/network-runtime/direct-endpoint-authority.js +0 -25
  87. package/dist/network-runtime/local-control-contract.js +0 -627
  88. package/dist/network-runtime/node-store-contract.js +0 -34
  89. package/dist/network-runtime/pair-route-contract.js +0 -77
  90. package/dist/network-runtime/peer-capabilities.js +0 -28
  91. package/dist/network-runtime/peer-principal-ref.js +0 -12
  92. package/dist/network-runtime/peer-state-machine.js +0 -121
  93. package/dist/network-runtime/protocol-schemas.js +0 -205
  94. package/dist/network-runtime/runtime-bootstrap-contract.js +0 -60
  95. package/dist/outlook/desktop-session.js +0 -279
  96. package/dist/policy.js +0 -149
  97. package/dist/providers/brave.js +0 -62
  98. package/dist/providers/duckduckgo.js +0 -176
  99. package/dist/providers/exa.js +0 -63
  100. package/dist/providers/firecrawl.js +0 -55
  101. package/dist/providers/index.js +0 -7
  102. package/dist/providers/jina.js +0 -49
  103. package/dist/providers/router.js +0 -96
  104. package/dist/providers/search-provider.js +0 -32
  105. package/dist/providers/tavily.js +0 -54
  106. package/dist/quip/desktop-session.js +0 -317
  107. package/dist/registry/index.js +0 -1
  108. package/dist/registry/registry.js +0 -756
  109. package/dist/runtime-socket-local-control-client.js +0 -330
  110. package/dist/security/dns-normalization.js +0 -19
  111. package/dist/security/dns-pinning.js +0 -123
  112. package/dist/security/external-content.js +0 -91
  113. package/dist/security/ssrf.js +0 -181
  114. package/dist/slack/desktop-session.js +0 -324
  115. package/dist/tool-factory.js +0 -47
  116. package/dist/types.js +0 -7
  117. package/dist/utils/retry.js +0 -132
  118. package/dist/utils/safe-parse-json.js +0 -160
  119. package/dist/utils/url.js +0 -19
  120. package/dist-cjs/.tsbuildinfo +0 -1
  121. package/dist-cjs/ask-user-interaction.js +0 -27
  122. package/dist-cjs/cache/web-cache.js +0 -70
  123. package/dist-cjs/definitions/arion.js +0 -107
  124. package/dist-cjs/definitions/browser/browser.js +0 -421
  125. package/dist-cjs/definitions/browser/index.js +0 -8
  126. package/dist-cjs/definitions/browser/pw-downloads.js +0 -117
  127. package/dist-cjs/definitions/browser/pw-interactions.js +0 -213
  128. package/dist-cjs/definitions/browser/pw-responses.js +0 -84
  129. package/dist-cjs/definitions/browser/pw-session.js +0 -326
  130. package/dist-cjs/definitions/browser/pw-shared.js +0 -72
  131. package/dist-cjs/definitions/browser/pw-snapshot.js +0 -307
  132. package/dist-cjs/definitions/browser/pw-state.js +0 -70
  133. package/dist-cjs/definitions/browser/types.js +0 -5
  134. package/dist-cjs/definitions/code-intelligence.js +0 -473
  135. package/dist-cjs/definitions/core.js +0 -133
  136. package/dist-cjs/definitions/delegation.js +0 -515
  137. package/dist-cjs/definitions/deploy.js +0 -68
  138. package/dist-cjs/definitions/filesystem.js +0 -199
  139. package/dist-cjs/definitions/frg.js +0 -66
  140. package/dist-cjs/definitions/index.js +0 -43
  141. package/dist-cjs/definitions/memory.js +0 -126
  142. package/dist-cjs/definitions/messaging.js +0 -631
  143. package/dist-cjs/definitions/meta.js +0 -352
  144. package/dist-cjs/definitions/network.js +0 -162
  145. package/dist-cjs/definitions/outlook.js +0 -280
  146. package/dist-cjs/definitions/patch/apply-patch.js +0 -191
  147. package/dist-cjs/definitions/patch/fuzzy-match.js +0 -172
  148. package/dist-cjs/definitions/patch/index.js +0 -5
  149. package/dist-cjs/definitions/patch/patch-parser.js +0 -215
  150. package/dist-cjs/definitions/patch/sandbox-paths.js +0 -113
  151. package/dist-cjs/definitions/process/index.js +0 -8
  152. package/dist-cjs/definitions/process/process-registry.js +0 -231
  153. package/dist-cjs/definitions/process/process.js +0 -389
  154. package/dist-cjs/definitions/process/pty-keys.js +0 -259
  155. package/dist-cjs/definitions/process/session-slug.js +0 -145
  156. package/dist-cjs/definitions/quip.js +0 -198
  157. package/dist-cjs/definitions/search.js +0 -63
  158. package/dist-cjs/definitions/session-history.js +0 -72
  159. package/dist-cjs/definitions/shell.js +0 -184
  160. package/dist-cjs/definitions/slack.js +0 -183
  161. package/dist-cjs/definitions/web.js +0 -112
  162. package/dist-cjs/executors/apply-patch.js +0 -938
  163. package/dist-cjs/executors/arion.js +0 -125
  164. package/dist-cjs/executors/code-intelligence.js +0 -925
  165. package/dist-cjs/executors/deploy.js +0 -869
  166. package/dist-cjs/executors/filesystem.js +0 -1167
  167. package/dist-cjs/executors/frg-freshness.js +0 -627
  168. package/dist-cjs/executors/frg.js +0 -334
  169. package/dist-cjs/executors/index.js +0 -143
  170. package/dist-cjs/executors/learning-meta.js +0 -1165
  171. package/dist-cjs/executors/lsp-client.js +0 -310
  172. package/dist-cjs/executors/memory.js +0 -796
  173. package/dist-cjs/executors/meta.js +0 -226
  174. package/dist-cjs/executors/process-registry.js +0 -469
  175. package/dist-cjs/executors/pty-session-store.js +0 -34
  176. package/dist-cjs/executors/pty.js +0 -312
  177. package/dist-cjs/executors/restart.js +0 -155
  178. package/dist-cjs/executors/search-freshness.js +0 -234
  179. package/dist-cjs/executors/search-types.js +0 -56
  180. package/dist-cjs/executors/search.js +0 -102
  181. package/dist-cjs/executors/self-diagnose.js +0 -434
  182. package/dist-cjs/executors/session-history.js +0 -320
  183. package/dist-cjs/executors/shell-safety.js +0 -478
  184. package/dist-cjs/executors/shell.js +0 -1001
  185. package/dist-cjs/executors/utils.js +0 -73
  186. package/dist-cjs/executors/web.js +0 -547
  187. package/dist-cjs/extraction/content-extraction.js +0 -243
  188. package/dist-cjs/extraction/index.js +0 -8
  189. package/dist-cjs/headless-control-contract.js +0 -972
  190. package/dist-cjs/local-control-http-auth.js +0 -5
  191. package/dist-cjs/mcp/client.js +0 -185
  192. package/dist-cjs/mcp/connection.js +0 -484
  193. package/dist-cjs/mcp/index.js +0 -30
  194. package/dist-cjs/mcp/jsonrpc.js +0 -148
  195. package/dist-cjs/mcp/types.js +0 -8
  196. package/dist-cjs/network-control-adapter.js +0 -77
  197. package/dist-cjs/network-runtime/address-types.js +0 -168
  198. package/dist-cjs/network-runtime/db-owner-fencing.js +0 -76
  199. package/dist-cjs/network-runtime/delivery-receipts.js +0 -276
  200. package/dist-cjs/network-runtime/direct-endpoint-authority.js +0 -29
  201. package/dist-cjs/network-runtime/local-control-contract.js +0 -633
  202. package/dist-cjs/network-runtime/node-store-contract.js +0 -38
  203. package/dist-cjs/network-runtime/pair-route-contract.js +0 -80
  204. package/dist-cjs/network-runtime/peer-capabilities.js +0 -37
  205. package/dist-cjs/network-runtime/peer-principal-ref.js +0 -15
  206. package/dist-cjs/network-runtime/peer-state-machine.js +0 -129
  207. package/dist-cjs/network-runtime/protocol-schemas.js +0 -212
  208. package/dist-cjs/network-runtime/runtime-bootstrap-contract.js +0 -63
  209. package/dist-cjs/outlook/desktop-session.js +0 -318
  210. package/dist-cjs/policy.js +0 -155
  211. package/dist-cjs/providers/brave.js +0 -66
  212. package/dist-cjs/providers/duckduckgo.js +0 -180
  213. package/dist-cjs/providers/exa.js +0 -67
  214. package/dist-cjs/providers/firecrawl.js +0 -59
  215. package/dist-cjs/providers/index.js +0 -17
  216. package/dist-cjs/providers/jina.js +0 -53
  217. package/dist-cjs/providers/router.js +0 -100
  218. package/dist-cjs/providers/search-provider.js +0 -36
  219. package/dist-cjs/providers/tavily.js +0 -58
  220. package/dist-cjs/quip/desktop-session.js +0 -353
  221. package/dist-cjs/registry/index.js +0 -6
  222. package/dist-cjs/registry/registry.js +0 -761
  223. package/dist-cjs/runtime-socket-local-control-client.js +0 -367
  224. package/dist-cjs/security/dns-normalization.js +0 -22
  225. package/dist-cjs/security/dns-pinning.js +0 -160
  226. package/dist-cjs/security/external-content.js +0 -95
  227. package/dist-cjs/security/ssrf.js +0 -221
  228. package/dist-cjs/slack/desktop-session.js +0 -366
  229. package/dist-cjs/tool-factory.js +0 -50
  230. package/dist-cjs/types.js +0 -8
  231. package/dist-cjs/utils/retry.js +0 -169
  232. package/dist-cjs/utils/safe-parse-json.js +0 -164
  233. package/dist-cjs/utils/url.js +0 -23
@@ -1,353 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.createQuipDesktopClient = createQuipDesktopClient;
37
- const node_child_process_1 = require("node:child_process");
38
- const node_util_1 = require("node:util");
39
- const execFileAsync = (0, node_util_1.promisify)(node_child_process_1.execFile);
40
- const QUIP_API_BASE = "https://platform.quip.com/1";
41
- const DEFAULT_BOOTSTRAP_TIMEOUT_MS = 30_000;
42
- // ── HTML → Markdown conversion (regex-based, no deps) ───────────────
43
- function htmlToMarkdown(html) {
44
- let md = html;
45
- // Block elements first
46
- md = md.replace(/<h1[^>]*>([\s\S]*?)<\/h1>/gi, "\n# $1\n");
47
- md = md.replace(/<h2[^>]*>([\s\S]*?)<\/h2>/gi, "\n## $1\n");
48
- md = md.replace(/<h3[^>]*>([\s\S]*?)<\/h3>/gi, "\n### $1\n");
49
- md = md.replace(/<h4[^>]*>([\s\S]*?)<\/h4>/gi, "\n#### $1\n");
50
- md = md.replace(/<br\s*\/?>/gi, "\n");
51
- md = md.replace(/<\/p>/gi, "\n\n");
52
- md = md.replace(/<p[^>]*>/gi, "");
53
- md = md.replace(/<li[^>]*>([\s\S]*?)<\/li>/gi, "- $1\n");
54
- md = md.replace(/<\/?(ul|ol)[^>]*>/gi, "\n");
55
- md = md.replace(/<blockquote[^>]*>([\s\S]*?)<\/blockquote>/gi, (_, content) => content
56
- .split("\n")
57
- .map((line) => `> ${line}`)
58
- .join("\n"));
59
- md = md.replace(/<pre[^>]*>([\s\S]*?)<\/pre>/gi, "\n```\n$1\n```\n");
60
- md = md.replace(/<code[^>]*>([\s\S]*?)<\/code>/gi, "`$1`");
61
- // Inline formatting
62
- md = md.replace(/<(b|strong)[^>]*>([\s\S]*?)<\/\1>/gi, "**$2**");
63
- md = md.replace(/<(i|em)[^>]*>([\s\S]*?)<\/\1>/gi, "*$2*");
64
- md = md.replace(/<(s|del|strike)[^>]*>([\s\S]*?)<\/\1>/gi, "~~$2~~");
65
- md = md.replace(/<a\s+href="([^"]*)"[^>]*>([\s\S]*?)<\/a>/gi, "[$2]($1)");
66
- // Strip remaining tags
67
- md = md.replace(/<[^>]+>/g, "");
68
- // Decode common HTML entities
69
- md = md.replace(/&amp;/g, "&");
70
- md = md.replace(/&lt;/g, "<");
71
- md = md.replace(/&gt;/g, ">");
72
- md = md.replace(/&quot;/g, '"');
73
- md = md.replace(/&#39;/g, "'");
74
- md = md.replace(/&nbsp;/g, " ");
75
- // Collapse excessive blank lines
76
- md = md.replace(/\n{3,}/g, "\n\n");
77
- return md.trim();
78
- }
79
- async function extractKeychainDesktopToken() {
80
- try {
81
- // Use python3 to parse the bplist from Keychain — macOS ships python3
82
- // and plutil requires a temp file; python3 one-liner is cleaner.
83
- const { stdout } = await execFileAsync("python3", [
84
- "-c",
85
- `
86
- import subprocess, plistlib, sys
87
- from datetime import datetime, timedelta
88
- try:
89
- raw = subprocess.check_output([
90
- 'security', 'find-generic-password', '-s', 'Quip', '-a', 'MultiAccount', '-g'
91
- ], stderr=subprocess.STDOUT).decode()
92
- import re
93
- hex_match = re.search(r'password: 0x([0-9A-Fa-f]+)', raw)
94
- if not hex_match:
95
- sys.exit(1)
96
- data = bytes.fromhex(hex_match.group(1))
97
- plist = plistlib.loads(data)
98
- import json
99
- for uid, info in plist.get('accounts', {}).items():
100
- exp = info.get('session_expiration', 0)
101
- exp_date = datetime(2001, 1, 1) + timedelta(seconds=exp)
102
- if exp_date > datetime.now():
103
- json.dump({"token": info["session_id"], "userId": uid}, sys.stdout)
104
- sys.exit(0)
105
- sys.exit(1)
106
- except:
107
- sys.exit(1)
108
- `.trim(),
109
- ]);
110
- const parsed = JSON.parse(stdout.trim());
111
- if (parsed.token && parsed.userId) {
112
- return parsed;
113
- }
114
- }
115
- catch {
116
- // Keychain extraction failed — fall through
117
- }
118
- return null;
119
- }
120
- async function extractManualKeychainToken() {
121
- try {
122
- const { stdout } = await execFileAsync("security", [
123
- "find-generic-password",
124
- "-a",
125
- "aria",
126
- "-s",
127
- "quip-token",
128
- "-w",
129
- ]);
130
- const token = stdout.trim();
131
- return token || null;
132
- }
133
- catch {
134
- return null;
135
- }
136
- }
137
- async function extractPlaywrightToken(timeoutMs) {
138
- const playwright = await Promise.resolve().then(() => __importStar(require("playwright")));
139
- const browser = await playwright.chromium.launch({ headless: true });
140
- try {
141
- const context = await browser.newContext();
142
- const page = await context.newPage();
143
- const tokenPromise = new Promise((resolve, reject) => {
144
- const timer = setTimeout(() => {
145
- page.off("request", handleRequest);
146
- reject(new Error("Timed out waiting for Quip API token via Playwright."));
147
- }, timeoutMs);
148
- const handleRequest = (request) => {
149
- const url = request.url();
150
- if (!url.includes("platform.quip.com"))
151
- return;
152
- const authHeader = request.headers()["authorization"];
153
- if (!authHeader?.startsWith("Bearer "))
154
- return;
155
- clearTimeout(timer);
156
- page.off("request", handleRequest);
157
- resolve(authHeader.slice(7));
158
- };
159
- page.on("request", handleRequest);
160
- });
161
- await page.goto("https://quip.com", {
162
- waitUntil: "domcontentloaded",
163
- timeout: timeoutMs,
164
- });
165
- const token = await tokenPromise;
166
- // Get user ID from /users/current
167
- const resp = await context.request.get(`${QUIP_API_BASE}/users/current`, {
168
- headers: { Authorization: `Bearer ${token}` },
169
- });
170
- const userData = (await resp.json());
171
- const userId = typeof userData.id === "string" ? userData.id : "unknown";
172
- await page.close().catch(() => undefined);
173
- await context.close().catch(() => undefined);
174
- await browser.close().catch(() => undefined);
175
- return { token, userId };
176
- }
177
- catch (error) {
178
- await browser.close().catch(() => undefined);
179
- throw error;
180
- }
181
- }
182
- // ── Thread/document helpers ─────────────────────────────────────────
183
- function toDocumentSummary(thread) {
184
- return {
185
- threadId: typeof thread.id === "string" ? thread.id : "",
186
- title: typeof thread.title === "string" ? thread.title : "",
187
- link: typeof thread.link === "string" ? thread.link : "",
188
- updatedUsec: typeof thread.updated_usec === "number" ? thread.updated_usec : 0,
189
- createdUsec: typeof thread.created_usec === "number" ? thread.created_usec : 0,
190
- };
191
- }
192
- // ── Client factory ──────────────────────────────────────────────────
193
- async function createQuipDesktopClient(options) {
194
- const timeoutMs = options?.bootstrapTimeoutMs ?? DEFAULT_BOOTSTRAP_TIMEOUT_MS;
195
- // Priority 1: Keychain desktop token (auto from Quip desktop app)
196
- let keychainResult = await extractKeychainDesktopToken();
197
- // Priority 2: Playwright web session (SSO handles auth)
198
- if (!keychainResult) {
199
- try {
200
- keychainResult = await extractPlaywrightToken(timeoutMs);
201
- }
202
- catch {
203
- // Playwright extraction failed — fall through
204
- }
205
- }
206
- // Priority 3: Manual keychain token
207
- let token;
208
- let userId;
209
- if (keychainResult) {
210
- token = keychainResult.token;
211
- userId = keychainResult.userId;
212
- }
213
- else {
214
- const manualToken = await extractManualKeychainToken();
215
- if (!manualToken) {
216
- throw new Error("No Quip token available. Install the Quip desktop app, or add a manual token:\n" +
217
- ' security add-generic-password -a aria -s quip-token -w "<token>"\n' +
218
- "Get a token from https://quip.com/dev/token");
219
- }
220
- token = manualToken;
221
- userId = "unknown";
222
- }
223
- // Verify token and resolve userId if unknown
224
- const invokeApi = async (method, endpoint, body) => {
225
- const url = `${QUIP_API_BASE}${endpoint}`;
226
- const headers = {
227
- Authorization: `Bearer ${token}`,
228
- };
229
- const fetchOptions = { method, headers };
230
- if (body) {
231
- headers["Content-Type"] = "application/x-www-form-urlencoded";
232
- fetchOptions.body = new URLSearchParams(Object.entries(body).map(([k, v]) => [k, String(v)])).toString();
233
- }
234
- const resp = await fetch(url, fetchOptions);
235
- const text = await resp.text();
236
- let json;
237
- try {
238
- json = JSON.parse(text);
239
- }
240
- catch {
241
- throw new Error(`Quip API ${endpoint} returned non-JSON (HTTP ${resp.status}).`);
242
- }
243
- if (!resp.ok) {
244
- const errorCode = typeof json.error_code === "number" ? json.error_code : resp.status;
245
- const errorMsg = typeof json.error_description === "string" ? json.error_description : `HTTP ${resp.status}`;
246
- throw new Error(`Quip API ${endpoint} failed (${errorCode}): ${errorMsg}`);
247
- }
248
- return json;
249
- };
250
- // Resolve userId on first use if unknown
251
- if (userId === "unknown") {
252
- const user = await invokeApi("GET", "/users/current");
253
- userId = typeof user.id === "string" ? user.id : "unknown";
254
- }
255
- return {
256
- getUserId: () => userId,
257
- listRecentDocuments: async ({ limit = 20 }) => {
258
- const data = await invokeApi("GET", `/threads/recent?count=${Math.min(limit, 50)}`);
259
- const threads = Array.isArray(data)
260
- ? data
261
- : typeof data === "object" && data !== null
262
- ? Object.values(data)
263
- : [];
264
- const documents = [];
265
- for (const entry of threads) {
266
- if (!entry || typeof entry !== "object")
267
- continue;
268
- const thread = "thread" in entry
269
- ? entry.thread
270
- : entry;
271
- documents.push(toDocumentSummary(thread));
272
- }
273
- return { documents: documents.slice(0, limit) };
274
- },
275
- searchDocuments: async ({ query, limit = 20 }) => {
276
- const params = new URLSearchParams({ query, count: String(Math.min(limit, 50)) });
277
- const data = await invokeApi("GET", `/threads/search?${params}`);
278
- const threads = Array.isArray(data)
279
- ? data
280
- : typeof data === "object" && data !== null
281
- ? Object.values(data)
282
- : [];
283
- const documents = [];
284
- for (const entry of threads) {
285
- if (!entry || typeof entry !== "object")
286
- continue;
287
- const thread = "thread" in entry
288
- ? entry.thread
289
- : entry;
290
- documents.push(toDocumentSummary(thread));
291
- }
292
- return { documents: documents.slice(0, limit) };
293
- },
294
- readDocument: async ({ threadId }) => {
295
- const data = await invokeApi("GET", `/threads/${threadId}`);
296
- const thread = typeof data.thread === "object" && data.thread !== null
297
- ? data.thread
298
- : data;
299
- const rawHtml = typeof data.html === "string" ? data.html : "";
300
- return {
301
- threadId: typeof thread.id === "string" ? thread.id : threadId,
302
- title: typeof thread.title === "string" ? thread.title : "",
303
- link: typeof thread.link === "string" ? thread.link : "",
304
- markdown: htmlToMarkdown(rawHtml),
305
- updatedUsec: typeof thread.updated_usec === "number" ? thread.updated_usec : 0,
306
- createdUsec: typeof thread.created_usec === "number" ? thread.created_usec : 0,
307
- authorId: typeof thread.author_id === "string" ? thread.author_id : "",
308
- };
309
- },
310
- createDocument: async ({ title, content, format = "markdown", folderId }) => {
311
- const body = { title, content, format };
312
- if (folderId)
313
- body.member_ids = folderId;
314
- const data = await invokeApi("POST", "/threads/new-document", body);
315
- const thread = typeof data.thread === "object" && data.thread !== null
316
- ? data.thread
317
- : data;
318
- return {
319
- threadId: typeof thread.id === "string" ? thread.id : "",
320
- title: typeof thread.title === "string" ? thread.title : title,
321
- link: typeof thread.link === "string" ? thread.link : "",
322
- };
323
- },
324
- addComment: async ({ threadId, content }) => {
325
- const data = await invokeApi("POST", "/messages/new", {
326
- thread_id: threadId,
327
- content,
328
- });
329
- return {
330
- threadId,
331
- commentId: typeof data.id === "string" ? data.id : "",
332
- };
333
- },
334
- listComments: async ({ threadId }) => {
335
- const data = await invokeApi("GET", `/messages/${threadId}`);
336
- const rawMessages = Array.isArray(data) ? data : [];
337
- const comments = rawMessages
338
- .filter((m) => !!m && typeof m === "object")
339
- .map((m) => ({
340
- id: typeof m.id === "string" ? m.id : "",
341
- authorId: typeof m.author_id === "string" ? m.author_id : "",
342
- authorName: typeof m.author_name === "string" ? m.author_name : "",
343
- text: typeof m.text === "string" ? m.text : "",
344
- createdUsec: typeof m.created_usec === "number" ? m.created_usec : 0,
345
- }));
346
- return { threadId, comments };
347
- },
348
- close: async () => {
349
- // No persistent resources to clean up (unlike Slack which keeps a browser open).
350
- // Token-based client is stateless.
351
- },
352
- };
353
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateToolInput = exports.ToolRegistry = void 0;
4
- var registry_js_1 = require("./registry.js");
5
- Object.defineProperty(exports, "ToolRegistry", { enumerable: true, get: function () { return registry_js_1.ToolRegistry; } });
6
- Object.defineProperty(exports, "validateToolInput", { enumerable: true, get: function () { return registry_js_1.validateToolInput; } });