@agentstep/agent-sdk 0.4.28 → 0.4.30

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 (177) hide show
  1. package/dist/auth/middleware.js +7 -7
  2. package/dist/backends/claude/args.js +5 -5
  3. package/dist/backends/claude/index.js +7 -7
  4. package/dist/backends/claude/tool-bridge.js +3 -1
  5. package/dist/backends/codex/auth.js +5 -5
  6. package/dist/backends/codex/index.js +6 -6
  7. package/dist/backends/factory/auth.js +5 -5
  8. package/dist/backends/factory/index.js +6 -6
  9. package/dist/backends/gemini/auth.js +5 -5
  10. package/dist/backends/gemini/index.js +6 -6
  11. package/dist/backends/opencode/auth.js +5 -5
  12. package/dist/backends/opencode/index.js +6 -6
  13. package/dist/backends/pi/auth.js +5 -5
  14. package/dist/backends/pi/index.js +6 -6
  15. package/dist/backends/registry.js +18 -18
  16. package/dist/{chunk-TY3HD5I5.js → chunk-2DRBKIGQ.js} +1 -1
  17. package/dist/{chunk-ATGDKD4W.js → chunk-2JKOYBUO.js} +1 -1
  18. package/dist/{chunk-4IFVESQO.js → chunk-3KLJGU75.js} +17 -14
  19. package/dist/{chunk-ZP5VMV5O.js → chunk-46XURNM7.js} +4 -4
  20. package/dist/{chunk-P525BPB2.js → chunk-4B7PQTTS.js} +6 -6
  21. package/dist/{chunk-5GZEX4HV.js → chunk-4C7XJI2V.js} +1 -1
  22. package/dist/chunk-4FDEJHH7.js +128 -0
  23. package/dist/{chunk-R5OZHLAD.js → chunk-4PVPM2WC.js} +1 -1
  24. package/dist/{chunk-O45IQUWS.js → chunk-5NBZZZKH.js} +2 -2
  25. package/dist/{chunk-S3SKODVV.js → chunk-5QTDZQ2H.js} +4 -4
  26. package/dist/{chunk-JNHADPQ3.js → chunk-65XR7JU6.js} +11 -5
  27. package/dist/{chunk-X2CAT5MN.js → chunk-67D4I5AE.js} +1 -1
  28. package/dist/{chunk-EHCGLMPC.js → chunk-6EQZSMIZ.js} +1 -1
  29. package/dist/{chunk-HQACDTN4.js → chunk-6VENJOPG.js} +5 -5
  30. package/dist/{chunk-VHZML3D5.js → chunk-7DSZOBSQ.js} +2 -2
  31. package/dist/{chunk-VIGJQU6V.js → chunk-7GNSB22P.js} +3 -3
  32. package/dist/{chunk-4TF2EKVQ.js → chunk-7UJ2PIXJ.js} +2 -2
  33. package/dist/{chunk-NUINUAXO.js → chunk-7V277COF.js} +2 -2
  34. package/dist/{chunk-4RNCKCDV.js → chunk-AP2N4R6D.js} +1 -1
  35. package/dist/{chunk-WJUWZKRP.js → chunk-AXISFTHX.js} +2 -2
  36. package/dist/{chunk-JDELTTHV.js → chunk-BBYQMNGK.js} +1 -1
  37. package/dist/{chunk-FEHDZT7I.js → chunk-BJK4SGWG.js} +2 -2
  38. package/dist/{chunk-4WMYJM36.js → chunk-BKBC43KV.js} +1 -1
  39. package/dist/{chunk-CGPTH3JC.js → chunk-BQOFXJSK.js} +3 -3
  40. package/dist/{chunk-PF6W4L5F.js → chunk-BSVZAXLI.js} +11 -8
  41. package/dist/{chunk-UO2N4Q3V.js → chunk-CL3DUJRJ.js} +7 -4
  42. package/dist/{chunk-UZJI64HR.js → chunk-DL2BACWC.js} +12 -9
  43. package/dist/{chunk-B7L5XD24.js → chunk-DNV6JZLZ.js} +1 -1
  44. package/dist/{chunk-AU2DTTBR.js → chunk-EFCCO74P.js} +8 -5
  45. package/dist/{chunk-EF5QCTEQ.js → chunk-EFDAVLKN.js} +1 -1
  46. package/dist/{chunk-WFIMX3HG.js → chunk-EIR2TG5I.js} +1 -1
  47. package/dist/{chunk-F3M4HKEJ.js → chunk-EN3ICYTL.js} +9 -9
  48. package/dist/{chunk-Y2KDIPCT.js → chunk-F3BVYYRX.js} +5 -5
  49. package/dist/{chunk-ZMMDLKR3.js → chunk-FGQFNIRI.js} +3 -3
  50. package/dist/{chunk-DNGLD7VN.js → chunk-FIJTBRZ5.js} +1 -1
  51. package/dist/{chunk-AMWWPUSK.js → chunk-H3O7QBOQ.js} +1 -1
  52. package/dist/{chunk-AYNYP3G3.js → chunk-H62LRJJP.js} +19 -18
  53. package/dist/{chunk-FRDJNX6Z.js → chunk-H7Z4BWRI.js} +2 -2
  54. package/dist/{chunk-I44FSUBC.js → chunk-HA5FIXGQ.js} +1 -1
  55. package/dist/{chunk-NWW4246M.js → chunk-HEDK5J34.js} +1 -1
  56. package/dist/{chunk-M4CTE7EH.js → chunk-HF6HORZZ.js} +2 -2
  57. package/dist/{chunk-34BN2SJC.js → chunk-HFBC2TOG.js} +2 -2
  58. package/dist/{chunk-DO4WVWW7.js → chunk-IFXD4DH5.js} +1 -1
  59. package/dist/{chunk-ATTHVKNE.js → chunk-JN3G4Y4L.js} +4 -4
  60. package/dist/{chunk-ZQGJKPPY.js → chunk-JSKZXF5J.js} +31 -6
  61. package/dist/{chunk-Y2J7CAME.js → chunk-JYUJQHPR.js} +3 -3
  62. package/dist/{chunk-HLNTWWAZ.js → chunk-KA33M67F.js} +2 -2
  63. package/dist/{chunk-T45NOW43.js → chunk-L43UD7PK.js} +1 -1
  64. package/dist/{chunk-3QIIJADA.js → chunk-LOAFGJWC.js} +2 -2
  65. package/dist/{chunk-DWAA3F5Y.js → chunk-LR4TA74O.js} +15 -15
  66. package/dist/{chunk-MJ5J57UJ.js → chunk-M36DF445.js} +1 -1
  67. package/dist/{chunk-MHQXDTJB.js → chunk-NC4FHDIP.js} +1 -1
  68. package/dist/{chunk-NIOWKTIF.js → chunk-NT2AI5IE.js} +1 -1
  69. package/dist/{chunk-5D5P37FY.js → chunk-NZATVUV2.js} +1 -1
  70. package/dist/{chunk-ES5VD2ML.js → chunk-PFWTQ43U.js} +1 -1
  71. package/dist/{chunk-SVYLMMBI.js → chunk-QV5WI73T.js} +19 -6
  72. package/dist/{chunk-I5ZA45YL.js → chunk-QWGJS6V6.js} +4 -4
  73. package/dist/{chunk-YCXELHKG.js → chunk-REGPK5NG.js} +1 -1
  74. package/dist/{chunk-NUO56TF7.js → chunk-S5HVHCAK.js} +2 -2
  75. package/dist/{chunk-SXE7H3VK.js → chunk-SLAOS6JN.js} +1 -1
  76. package/dist/{chunk-NXRJ7Z4G.js → chunk-SW75SNDB.js} +1 -1
  77. package/dist/{chunk-JK5TPJHH.js → chunk-SXTHM67U.js} +1 -1
  78. package/dist/{chunk-NWFYV2VI.js → chunk-TRGHIMCR.js} +4 -4
  79. package/dist/{chunk-BMPB7XJH.js → chunk-TRQX5AIZ.js} +4 -4
  80. package/dist/{chunk-JEI7I3EH.js → chunk-TXUUUO5R.js} +2 -2
  81. package/dist/{chunk-P6NCA7G5.js → chunk-TZZMVXFM.js} +4 -4
  82. package/dist/{chunk-ND7BRD6B.js → chunk-UF3NB27E.js} +8 -8
  83. package/dist/{chunk-36VCC3BY.js → chunk-ULJVEN67.js} +3 -3
  84. package/dist/{chunk-UXMCHRGA.js → chunk-ULQOJ3WO.js} +2 -2
  85. package/dist/{chunk-B2JLKTBJ.js → chunk-VC25NYHW.js} +1 -1
  86. package/dist/{chunk-CCE6MVB3.js → chunk-VMILIALE.js} +18 -15
  87. package/dist/chunk-VUADJZRV.js +212 -0
  88. package/dist/{chunk-ADK2TYO4.js → chunk-WHV4YUQB.js} +1 -1
  89. package/dist/{chunk-AWHHLOWE.js → chunk-WP5EWNGJ.js} +4 -4
  90. package/dist/{chunk-HDSLSNN5.js → chunk-X2EEOO6Q.js} +5 -5
  91. package/dist/{chunk-AQXCXWAZ.js → chunk-XQEMI2MI.js} +1 -1
  92. package/dist/{chunk-OWP537VU.js → chunk-XTTHH5MF.js} +1 -1
  93. package/dist/{chunk-2BDD6OHG.js → chunk-XUNTHJIE.js} +7 -0
  94. package/dist/{chunk-BZ6HFTHU.js → chunk-YGTC5UP5.js} +1 -1
  95. package/dist/{chunk-YGAHGTVZ.js → chunk-YIOKUA23.js} +2 -2
  96. package/dist/{chunk-YY3NF45U.js → chunk-YTC6ST5T.js} +5 -5
  97. package/dist/config/index.js +4 -4
  98. package/dist/containers/client.js +5 -5
  99. package/dist/containers/exec.js +5 -5
  100. package/dist/containers/lifecycle.js +30 -30
  101. package/dist/containers/setup.js +7 -7
  102. package/dist/db/agents.js +5 -5
  103. package/dist/db/api_keys.js +4 -4
  104. package/dist/db/audit.js +3 -3
  105. package/dist/db/batch.js +9 -9
  106. package/dist/db/client.js +2 -2
  107. package/dist/db/credentials.js +3 -3
  108. package/dist/db/drizzle.js +3 -3
  109. package/dist/db/environments.js +5 -5
  110. package/dist/db/events.js +4 -4
  111. package/dist/db/files.js +4 -4
  112. package/dist/db/memory.js +4 -4
  113. package/dist/db/migrations.js +1 -1
  114. package/dist/db/proxy.js +4 -4
  115. package/dist/db/session-resources.js +4 -4
  116. package/dist/db/sessions.js +6 -6
  117. package/dist/db/sync.js +4 -4
  118. package/dist/db/tenants.js +3 -3
  119. package/dist/db/traces.js +4 -4
  120. package/dist/db/upstream_keys.js +3 -3
  121. package/dist/db/vaults.js +5 -5
  122. package/dist/handlers/agents.js +45 -45
  123. package/dist/handlers/api_keys.js +46 -46
  124. package/dist/handlers/audit.js +46 -46
  125. package/dist/handlers/batch.js +46 -46
  126. package/dist/handlers/credentials.js +46 -46
  127. package/dist/handlers/environments.js +46 -46
  128. package/dist/handlers/events.js +49 -49
  129. package/dist/handlers/files.js +46 -46
  130. package/dist/handlers/index.js +81 -81
  131. package/dist/handlers/license.js +45 -45
  132. package/dist/handlers/memory.js +46 -46
  133. package/dist/handlers/metrics.js +45 -45
  134. package/dist/handlers/models.js +46 -46
  135. package/dist/handlers/providers.js +45 -45
  136. package/dist/handlers/resources.js +45 -45
  137. package/dist/handlers/sessions.js +48 -48
  138. package/dist/handlers/settings.js +45 -45
  139. package/dist/handlers/skills-write.js +45 -45
  140. package/dist/handlers/skills.js +46 -46
  141. package/dist/handlers/stream.js +45 -45
  142. package/dist/handlers/tenants.js +46 -46
  143. package/dist/handlers/threads.js +45 -45
  144. package/dist/handlers/traces.js +46 -46
  145. package/dist/handlers/upstream_keys.js +48 -48
  146. package/dist/handlers/vaults.js +45 -45
  147. package/dist/handlers/whoami.js +45 -45
  148. package/dist/http.js +44 -44
  149. package/dist/index.js +48 -48
  150. package/dist/init.js +41 -41
  151. package/dist/lib/model-registry.js +5 -5
  152. package/dist/lib/skills-cache.js +5 -5
  153. package/dist/observability/otlp.js +11 -11
  154. package/dist/observability/redactor.js +7 -7
  155. package/dist/providers/fly.js +4 -4
  156. package/dist/providers/modal.js +4 -4
  157. package/dist/providers/registry.js +1 -1
  158. package/dist/providers/resolve-secrets.js +6 -6
  159. package/dist/providers/sprites.js +6 -6
  160. package/dist/providers/upstream-keys.js +10 -10
  161. package/dist/providers/vercel.js +4 -4
  162. package/dist/proxy/forward.js +5 -5
  163. package/dist/queue/index.js +5 -5
  164. package/dist/sessions/bus.js +9 -9
  165. package/dist/sessions/driver.js +34 -34
  166. package/dist/sessions/grader.js +4 -4
  167. package/dist/sessions/secrets.js +7 -7
  168. package/dist/sessions/sweeper.js +31 -31
  169. package/dist/sessions/threads.js +34 -34
  170. package/dist/shutdown.js +32 -32
  171. package/dist/sync/anthropic.js +9 -9
  172. package/dist/sync/container-file-sync.js +5 -5
  173. package/dist/sync/file-sync.js +16 -16
  174. package/package.json +1 -1
  175. package/dist/chunk-ALVC7G6R.js +0 -187
  176. package/dist/chunk-JLZO6TQL.js +0 -131
  177. /package/dist/{chunk-QUJNG4RA.js → chunk-C6JEPQ7T.js} +0 -0
@@ -1,39 +1,39 @@
1
1
  import {
2
2
  resolveAnthropicKey
3
- } from "../chunk-ATTHVKNE.js";
4
- import "../chunk-BZ6HFTHU.js";
3
+ } from "../chunk-JN3G4Y4L.js";
4
+ import "../chunk-YGTC5UP5.js";
5
5
  import {
6
6
  resolveRemoteSessionId
7
- } from "../chunk-YGAHGTVZ.js";
7
+ } from "../chunk-YIOKUA23.js";
8
8
  import {
9
9
  createFile
10
- } from "../chunk-NXRJ7Z4G.js";
10
+ } from "../chunk-SW75SNDB.js";
11
11
  import {
12
12
  isProxied
13
- } from "../chunk-NIOWKTIF.js";
13
+ } from "../chunk-NT2AI5IE.js";
14
14
  import {
15
15
  onAfterCommit
16
- } from "../chunk-BMPB7XJH.js";
17
- import "../chunk-VIGJQU6V.js";
16
+ } from "../chunk-TRQX5AIZ.js";
17
+ import "../chunk-7GNSB22P.js";
18
18
  import {
19
19
  getSession
20
- } from "../chunk-I5ZA45YL.js";
21
- import "../chunk-R5OZHLAD.js";
20
+ } from "../chunk-QWGJS6V6.js";
21
+ import "../chunk-4PVPM2WC.js";
22
22
  import "../chunk-AIBH32FN.js";
23
23
  import "../chunk-YPXI7Q2M.js";
24
- import "../chunk-O45IQUWS.js";
25
- import "../chunk-JEI7I3EH.js";
26
- import "../chunk-JDELTTHV.js";
24
+ import "../chunk-5NBZZZKH.js";
25
+ import "../chunk-TXUUUO5R.js";
26
+ import "../chunk-BBYQMNGK.js";
27
27
  import "../chunk-F4WUVOLE.js";
28
- import "../chunk-EF5QCTEQ.js";
29
- import "../chunk-SXE7H3VK.js";
28
+ import "../chunk-EFDAVLKN.js";
29
+ import "../chunk-SLAOS6JN.js";
30
30
  import "../chunk-LHHBOQUR.js";
31
31
  import "../chunk-HFDLUBWN.js";
32
32
  import {
33
33
  getDb,
34
34
  init_client
35
- } from "../chunk-5GZEX4HV.js";
36
- import "../chunk-2BDD6OHG.js";
35
+ } from "../chunk-4C7XJI2V.js";
36
+ import "../chunk-XUNTHJIE.js";
37
37
  import "../chunk-2ESYSVXG.js";
38
38
 
39
39
  // src/sync/file-sync.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "license": "Apache-2.0",
3
3
  "name": "@agentstep/agent-sdk",
4
- "version": "0.4.28",
4
+ "version": "0.4.30",
5
5
  "description": "Core engine for AgentStep Gateway \u2014 backends, sandbox providers, session orchestration, and vault encryption.",
6
6
  "keywords": [
7
7
  "anthropic",
@@ -1,187 +0,0 @@
1
- // src/backends/claude/tool-bridge.ts
2
- var TOOL_BRIDGE_DIR = "/tmp/tool-bridge";
3
- var TOOL_BRIDGE_SCRIPT_PATH = `${TOOL_BRIDGE_DIR}/bridge.mjs`;
4
- var TOOL_BRIDGE_TOOLS_PATH = `${TOOL_BRIDGE_DIR}/tools.json`;
5
- var TOOL_BRIDGE_REQUEST_PATH = `${TOOL_BRIDGE_DIR}/request.json`;
6
- var TOOL_BRIDGE_RESPONSE_PATH = `${TOOL_BRIDGE_DIR}/response.json`;
7
- var TOOL_BRIDGE_PENDING_PATH = `${TOOL_BRIDGE_DIR}/pending`;
8
- function generateBridgeScript() {
9
- return `#!/usr/bin/env node
10
- // Auto-generated MCP stdio server for custom tool bridge.
11
- // Reads tool definitions from ${TOOL_BRIDGE_TOOLS_PATH}
12
- import { readFileSync, writeFileSync, unlinkSync, existsSync, watch, watchFile, unwatchFile } from 'node:fs';
13
- import { createInterface } from 'node:readline';
14
-
15
- const TOOLS_PATH = ${JSON.stringify(TOOL_BRIDGE_TOOLS_PATH)};
16
- const REQUEST_PATH = ${JSON.stringify(TOOL_BRIDGE_REQUEST_PATH)};
17
- const RESPONSE_PATH = ${JSON.stringify(TOOL_BRIDGE_RESPONSE_PATH)};
18
- const PENDING_PATH = ${JSON.stringify(TOOL_BRIDGE_PENDING_PATH)};
19
-
20
- let tools = [];
21
- try { tools = JSON.parse(readFileSync(TOOLS_PATH, 'utf8')); } catch {}
22
-
23
- function sendResponse(id, result) {
24
- const msg = JSON.stringify({ jsonrpc: '2.0', id, result });
25
- const buf = Buffer.from(msg, 'utf8');
26
- process.stdout.write('Content-Length: ' + buf.length + '\\r\\n\\r\\n');
27
- process.stdout.write(buf);
28
- }
29
-
30
- function sendError(id, code, message) {
31
- const msg = JSON.stringify({ jsonrpc: '2.0', id, error: { code, message } });
32
- const buf = Buffer.from(msg, 'utf8');
33
- process.stdout.write('Content-Length: ' + buf.length + '\\r\\n\\r\\n');
34
- process.stdout.write(buf);
35
- }
36
-
37
- function handleRequest(req) {
38
- if (req.method === 'initialize') {
39
- sendResponse(req.id, {
40
- protocolVersion: '2024-11-05',
41
- capabilities: { tools: { listChanged: false } },
42
- serverInfo: { name: 'tool-bridge', version: '1.0.0' },
43
- });
44
- return;
45
- }
46
- if (req.method === 'notifications/initialized') return;
47
- if (req.method === 'tools/list') {
48
- sendResponse(req.id, {
49
- tools: tools.map(t => ({
50
- name: t.name,
51
- description: t.description || '',
52
- inputSchema: t.input_schema || { type: 'object', properties: {} },
53
- })),
54
- });
55
- return;
56
- }
57
- if (req.method === 'tools/call') {
58
- const toolName = req.params?.name;
59
- const toolInput = req.params?.arguments || {};
60
-
61
- // Replay case: if response.json already exists (from a --resume re-entry),
62
- // return it immediately without creating a pending sentinel.
63
- if (existsSync(RESPONSE_PATH)) {
64
- try {
65
- const resp = JSON.parse(readFileSync(RESPONSE_PATH, 'utf8'));
66
- sendResponse(req.id, {
67
- content: [{ type: 'text', text: JSON.stringify(resp.content ?? resp) }],
68
- isError: false,
69
- });
70
- try { unlinkSync(RESPONSE_PATH); } catch {}
71
- return;
72
- } catch (e) {
73
- console.error('[tool-bridge] replay failed:', e);
74
- process.exit(1);
75
- }
76
- }
77
-
78
- // Write the request and create pending sentinel
79
- writeFileSync(REQUEST_PATH, JSON.stringify({
80
- tool_use_id: req.id,
81
- name: toolName,
82
- input: toolInput,
83
- }));
84
- writeFileSync(PENDING_PATH, '');
85
-
86
- // Watch for response.json \u2014 prefer fs.watch (inotify/kqueue) over
87
- // fs.watchFile (stat polling). Fall back to watchFile if watch fails.
88
- let resolved = false;
89
- const onResponse = () => {
90
- if (resolved) return;
91
- if (!existsSync(RESPONSE_PATH)) return;
92
- resolved = true;
93
- // Clean up whichever watcher is active
94
- if (watcher) { try { watcher.close(); } catch {} }
95
- try { unwatchFile(RESPONSE_PATH, pollFallback); } catch {}
96
- try {
97
- const resp = JSON.parse(readFileSync(RESPONSE_PATH, 'utf8'));
98
- try { unlinkSync(RESPONSE_PATH); } catch {}
99
- try { unlinkSync(PENDING_PATH); } catch {}
100
- sendResponse(req.id, {
101
- content: [{ type: 'text', text: JSON.stringify(resp.content ?? resp) }],
102
- isError: false,
103
- });
104
- } catch (e) {
105
- sendError(req.id, -32603, 'Failed to read response: ' + e.message);
106
- }
107
- };
108
- const pollFallback = () => onResponse();
109
- let watcher = null;
110
- // Check immediately in case it was written between our existsSync check
111
- onResponse();
112
- if (resolved) return;
113
- try {
114
- watcher = watch(RESPONSE_PATH, () => onResponse());
115
- watcher.on('error', () => {
116
- // fs.watch failed mid-watch \u2014 fall back to polling
117
- try { watcher.close(); } catch {}
118
- watcher = null;
119
- watchFile(RESPONSE_PATH, { interval: 200 }, pollFallback);
120
- });
121
- } catch {
122
- // fs.watch not available \u2014 fall back to stat polling
123
- watchFile(RESPONSE_PATH, { interval: 200 }, pollFallback);
124
- }
125
- return;
126
- }
127
- // Unknown method
128
- if (req.id != null) {
129
- sendError(req.id, -32601, 'Method not found: ' + req.method);
130
- }
131
- }
132
-
133
- // Read MCP stdio protocol: Content-Length headers + JSON body
134
- let buffer = '';
135
- process.stdin.setEncoding('utf8');
136
- process.stdin.on('data', (chunk) => {
137
- buffer += chunk;
138
- while (true) {
139
- const headerEnd = buffer.indexOf('\\r\\n\\r\\n');
140
- if (headerEnd === -1) break;
141
- const header = buffer.slice(0, headerEnd);
142
- const match = header.match(/Content-Length:\\s*(\\d+)/i);
143
- if (!match) { buffer = buffer.slice(headerEnd + 4); continue; }
144
- const len = parseInt(match[1], 10);
145
- const bodyStart = headerEnd + 4;
146
- if (buffer.length < bodyStart + len) break;
147
- const body = buffer.slice(bodyStart, bodyStart + len);
148
- buffer = buffer.slice(bodyStart + len);
149
- try {
150
- handleRequest(JSON.parse(body));
151
- } catch {}
152
- }
153
- });
154
- process.stdin.on('end', () => process.exit(0));
155
- `;
156
- }
157
- function buildBridgeMcpConfig(existingServers) {
158
- return {
159
- ...existingServers,
160
- "tool-bridge": {
161
- type: "stdio",
162
- command: "node",
163
- args: [TOOL_BRIDGE_SCRIPT_PATH]
164
- }
165
- };
166
- }
167
- function toolsToJson(tools) {
168
- return JSON.stringify(
169
- tools.map((t) => ({
170
- name: t.name,
171
- description: t.description,
172
- input_schema: t.input_schema
173
- }))
174
- );
175
- }
176
-
177
- export {
178
- TOOL_BRIDGE_DIR,
179
- TOOL_BRIDGE_SCRIPT_PATH,
180
- TOOL_BRIDGE_TOOLS_PATH,
181
- TOOL_BRIDGE_REQUEST_PATH,
182
- TOOL_BRIDGE_RESPONSE_PATH,
183
- TOOL_BRIDGE_PENDING_PATH,
184
- generateBridgeScript,
185
- buildBridgeMcpConfig,
186
- toolsToJson
187
- };
@@ -1,131 +0,0 @@
1
- import {
2
- loadVaultForCaller
3
- } from "./chunk-JNHADPQ3.js";
4
- import {
5
- jsonOk,
6
- routeWrap
7
- } from "./chunk-3QIIJADA.js";
8
- import {
9
- createCredential,
10
- deleteCredential,
11
- getCredential,
12
- listCredentials,
13
- updateCredential
14
- } from "./chunk-ZQGJKPPY.js";
15
- import {
16
- badRequest,
17
- conflict,
18
- notFound
19
- } from "./chunk-EZYKRG4W.js";
20
-
21
- // src/handlers/credentials.ts
22
- import { z } from "zod";
23
- var CreateCredentialSchema = z.object({
24
- display_name: z.string().min(1).max(200),
25
- auth: z.object({
26
- type: z.enum(["static_bearer"]),
27
- mcp_server_url: z.string().url().optional(),
28
- token: z.string().min(1)
29
- }),
30
- metadata: z.record(z.string()).optional()
31
- });
32
- var UpdateCredentialSchema = z.object({
33
- display_name: z.string().min(1).max(200).optional(),
34
- auth: z.object({
35
- type: z.enum(["static_bearer"]).optional(),
36
- token: z.string().min(1).optional(),
37
- mcp_server_url: z.string().url().nullish()
38
- }).optional()
39
- });
40
- function handleCreateCredential(request, vaultId) {
41
- return routeWrap(request, async ({ auth }) => {
42
- loadVaultForCaller(auth, vaultId);
43
- const body = await request.json();
44
- const parsed = CreateCredentialSchema.safeParse(body);
45
- if (!parsed.success) throw badRequest(parsed.error.message);
46
- try {
47
- const cred = createCredential({
48
- vault_id: vaultId,
49
- display_name: parsed.data.display_name,
50
- auth_type: parsed.data.auth.type,
51
- token: parsed.data.auth.token,
52
- mcp_server_url: parsed.data.auth.mcp_server_url ?? null
53
- });
54
- return jsonOk(cred, 201);
55
- } catch (err) {
56
- const msg = err instanceof Error ? err.message : String(err);
57
- if (msg.includes("UNIQUE constraint failed") || msg.includes("SQLITE_CONSTRAINT")) {
58
- throw conflict(
59
- `Credential "${parsed.data.display_name}" already exists in this vault`
60
- );
61
- }
62
- throw err;
63
- }
64
- });
65
- }
66
- function handleListCredentials(request, vaultId) {
67
- return routeWrap(request, async ({ auth }) => {
68
- loadVaultForCaller(auth, vaultId);
69
- const data = listCredentials(vaultId);
70
- return jsonOk({ data });
71
- });
72
- }
73
- function handleGetCredential(request, vaultId, credentialId) {
74
- return routeWrap(request, async ({ auth }) => {
75
- loadVaultForCaller(auth, vaultId);
76
- const cred = getCredential(credentialId);
77
- if (!cred || cred.vault_id !== vaultId) {
78
- throw notFound(`credential not found: ${credentialId}`);
79
- }
80
- return jsonOk(cred);
81
- });
82
- }
83
- function handleUpdateCredential(request, vaultId, credentialId) {
84
- return routeWrap(request, async ({ auth }) => {
85
- loadVaultForCaller(auth, vaultId);
86
- const existing = getCredential(credentialId);
87
- if (!existing || existing.vault_id !== vaultId) {
88
- throw notFound(`credential not found: ${credentialId}`);
89
- }
90
- const body = await request.json();
91
- const parsed = UpdateCredentialSchema.safeParse(body);
92
- if (!parsed.success) throw badRequest(parsed.error.message);
93
- try {
94
- const updated = updateCredential(credentialId, {
95
- display_name: parsed.data.display_name,
96
- auth_type: parsed.data.auth?.type,
97
- token: parsed.data.auth?.token,
98
- mcp_server_url: parsed.data.auth?.mcp_server_url
99
- });
100
- if (!updated) throw notFound(`credential not found: ${credentialId}`);
101
- return jsonOk(updated);
102
- } catch (err) {
103
- if (err instanceof Error && (err.message.includes("UNIQUE constraint failed") || err.message.includes("SQLITE_CONSTRAINT"))) {
104
- throw conflict(
105
- `Credential "${parsed.data.display_name}" already exists in this vault`
106
- );
107
- }
108
- throw err;
109
- }
110
- });
111
- }
112
- function handleDeleteCredential(request, vaultId, credentialId) {
113
- return routeWrap(request, async ({ auth }) => {
114
- loadVaultForCaller(auth, vaultId);
115
- const existing = getCredential(credentialId);
116
- if (!existing || existing.vault_id !== vaultId) {
117
- throw notFound(`credential not found: ${credentialId}`);
118
- }
119
- const deleted = deleteCredential(credentialId);
120
- if (!deleted) throw notFound(`credential not found: ${credentialId}`);
121
- return jsonOk({ id: credentialId, type: "vault_credential_deleted" });
122
- });
123
- }
124
-
125
- export {
126
- handleCreateCredential,
127
- handleListCredentials,
128
- handleGetCredential,
129
- handleUpdateCredential,
130
- handleDeleteCredential
131
- };
File without changes