@desplega.ai/agent-swarm 1.119.1 → 1.119.3

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 (78) hide show
  1. package/README.md +3 -0
  2. package/dist/{actions-d6rvh4xw.js → actions-kd321p1j.js} +7 -7
  3. package/dist/{app-2t2t6qtm.js → app-p1gqacgd.js} +3 -3
  4. package/dist/{assistant-kb23g109.js → assistant-6w0zb089.js} +10 -10
  5. package/dist/{boot-reembed-t2ct62pw.js → boot-reembed-7gy85nnp.js} +3 -3
  6. package/dist/{boot-reembed-gjatq261.js → boot-reembed-zktmj8zt.js} +4 -4
  7. package/dist/{boot-scrub-logs-vwvpxk23.js → boot-scrub-logs-d8n8pcgr.js} +2 -2
  8. package/dist/{cli-wmep6bjt.js → cli-3sew4a9j.js} +1 -1
  9. package/dist/{cli-gq1ss3yf.js → cli-527y7yzc.js} +3 -3
  10. package/dist/{cli-bwkxh7pa.js → cli-6expbmb3.js} +1 -1
  11. package/dist/{cli-2teefgw6.js → cli-7yfmb4ne.js} +1 -1
  12. package/dist/{cli-p750jfs0.js → cli-8y1kmyn7.js} +2 -2
  13. package/dist/cli-95kferzh.js +439 -0
  14. package/dist/{cli-2dsbab02.js → cli-9aqtt1dn.js} +7 -7
  15. package/dist/{cli-q8bgrc7c.js → cli-9y4z25ke.js} +1 -1
  16. package/dist/{cli-6j7ftsbs.js → cli-cx30v78p.js} +1 -1
  17. package/dist/{cli-wh91zby6.js → cli-dh9eb7tt.js} +6 -6
  18. package/dist/{cli-gpyx6t1w.js → cli-e5hdn9nx.js} +1 -1
  19. package/dist/{cli-34194d2q.js → cli-eb3s7zwh.js} +37 -35
  20. package/dist/{cli-wt7b0vr9.js → cli-emgzr4ja.js} +5 -5
  21. package/dist/{cli-9b5m9d9v.js → cli-g5a31r9y.js} +22 -3
  22. package/dist/{cli-1q7q8zws.js → cli-get7n46a.js} +1 -1
  23. package/dist/{cli-3hqj0r0f.js → cli-gzng1fst.js} +2 -2
  24. package/dist/{cli-e7306swv.js → cli-hcpm1e90.js} +6 -6
  25. package/dist/{cli-yk38sbmz.js → cli-j2vpt4hd.js} +11 -11
  26. package/dist/{cli-zyjvbdgq.js → cli-j5da6jb2.js} +12 -12
  27. package/dist/{cli-xjb2jg7b.js → cli-j6n9at34.js} +2 -2
  28. package/dist/{cli-gq46dx9q.js → cli-p4yn675m.js} +1 -1
  29. package/dist/{cli-226nz7j1.js → cli-td2x0s9b.js} +1 -1
  30. package/dist/{cli-5fb5rv64.js → cli-xgefj1nz.js} +2 -2
  31. package/dist/{cli-6637ryhr.js → cli-y82m27mq.js} +1 -1
  32. package/dist/{cli-03hw3tdq.js → cli-yzxg93ma.js} +4 -4
  33. package/dist/{cli-gat4kjhe.js → cli-z612d1nc.js} +1 -1
  34. package/dist/cli.js +13 -13
  35. package/dist/{codex-adapter-de3w0nch.js → codex-adapter-efskwfc4.js} +4 -4
  36. package/dist/{codex-session-runner-bnw8cysk.js → codex-session-runner-n7ad0jdv.js} +4 -4
  37. package/dist/{commands-sar3k5f6.js → commands-14gkjns3.js} +2 -2
  38. package/dist/{db-93qmw47d.js → db-c9wx8pbf.js} +2 -2
  39. package/dist/{handlers-4q6rrpg6.js → handlers-m9jxp50r.js} +10 -10
  40. package/dist/{hook-r6j7pb72.js → hook-mm8mj3cp.js} +3 -3
  41. package/dist/{http-yr4md33c.js → http-hhmh7m51.js} +101 -495
  42. package/dist/{index-snekxj7z.js → index-9h6qre5v.js} +6 -6
  43. package/dist/{index-afc5zk9k.js → index-basky7qw.js} +10 -10
  44. package/dist/{index-4zpkrw7q.js → index-ep25fyer.js} +9 -9
  45. package/dist/{index-wk5gsfqy.js → index-vmcp507g.js} +8 -8
  46. package/dist/{keepalive-wp8xyhnb.js → keepalive-70mwsyhb.js} +4 -4
  47. package/dist/{lead-5x0j5wxz.js → lead-pshn5w58.js} +25 -25
  48. package/dist/{maintenance-yx9pwy8a.js → maintenance-rbjav7ey.js} +4 -4
  49. package/dist/{oauth-refresh-sweep-yb4scdc0.js → oauth-refresh-sweep-dfbd7yw0.js} +3 -3
  50. package/dist/{onboard-f27pqdmq.js → onboard-g8911158.js} +2 -2
  51. package/dist/{otel-impl-z3cdybex.js → otel-impl-qw4pakj6.js} +1 -1
  52. package/dist/{pi-mono-adapter-05sck1ds.js → pi-mono-adapter-erghwha0.js} +7 -7
  53. package/dist/{pricing-refresh-0d0877ex.js → pricing-refresh-7ra0g3az.js} +4 -4
  54. package/dist/{rbac-roles-fya9jda4.js → rbac-roles-ksnmkjzf.js} +2 -2
  55. package/dist/{rbac-roles-s1kpmgrb.js → rbac-roles-s0esm5k6.js} +3 -3
  56. package/dist/registry-wejfsj31.js +13 -0
  57. package/dist/{seed-pricing-n6weaf7s.js → seed-pricing-jd8zj8k7.js} +3 -3
  58. package/dist/{setup-64291zb4.js → setup-z2s4vqf3.js} +2 -2
  59. package/dist/{worker-2v01h42e.js → worker-xse3rpzd.js} +25 -25
  60. package/openapi.json +53 -1
  61. package/package.json +1 -1
  62. package/src/be/seed/agent-fs-provision.ts +41 -1
  63. package/src/fs/registry.ts +13 -1
  64. package/src/http/core.ts +8 -0
  65. package/src/http/fs.ts +41 -1
  66. package/src/tests/agent-fs-provision-seeder.test.ts +40 -0
  67. package/src/tests/preload.ts +21 -0
  68. package/src/tests/prompt-template-resolver.test.ts +6 -0
  69. package/src/tests/prompt-template-session.test.ts +6 -0
  70. package/src/tests/template-registry-helpers.ts +29 -0
  71. package/dist/{azure-openai-responses-gm1ejtmn.js → azure-openai-responses-f57n5qy7.js} +4 -4
  72. package/dist/{claude-managed-setup-cm05wtek.js → claude-managed-setup-eac00cqn.js} +1 -1
  73. package/dist/{cli-6b4wwmm8.js → cli-0qy7bk86.js} +3 -3
  74. package/dist/{google-vertex-8bs2pzgn.js → google-vertex-9hhq68sw.js} +3 -3
  75. package/dist/{mistral-conversations-7gqnz2wt.js → mistral-conversations-tn4sj5qv.js} +3 -3
  76. package/dist/{openai-codex-responses-3nkvje79.js → openai-codex-responses-bex0bpn6.js} +2 -2
  77. package/dist/{openai-completions-0asftkwg.js → openai-completions-gygw5cxt.js} +8 -8
  78. package/dist/{openai-responses-pmatek45.js → openai-responses-8c0dgmty.js} +7 -7
@@ -1,3 +1,7 @@
1
+ import {
2
+ BROWSER_SDK_JS,
3
+ SWARM_UI_JS
4
+ } from "./cli-ppwm8c6e.js";
1
5
  import {
2
6
  AssetKeyAuthorizationError,
3
7
  BODY_TOO_LARGE,
@@ -126,12 +130,11 @@ import {
126
130
  withRemoteContext,
127
131
  withSpanContext,
128
132
  writeSkillsToFilesystem
129
- } from "./cli-34194d2q.js";
133
+ } from "./cli-eb3s7zwh.js";
130
134
  import"./cli-1z7048dy.js";
131
135
  import {
132
- BROWSER_SDK_JS,
133
- SWARM_UI_JS
134
- } from "./cli-ppwm8c6e.js";
136
+ Anthropic
137
+ } from "./cli-gz9sbyk3.js";
135
138
  import {
136
139
  REFERENCES_SOURCE_MAX_LENGTH,
137
140
  sanitizeReferencesSource
@@ -141,19 +144,23 @@ import {
141
144
  getValidCodexOAuth,
142
145
  loadAllCodexOAuthSlots
143
146
  } from "./cli-tk9vyqzh.js";
144
- import {
145
- Anthropic
146
- } from "./cli-gz9sbyk3.js";
147
147
  import {
148
148
  reasoningCapability
149
149
  } from "./cli-e61fs2hp.js";
150
- import"./cli-p750jfs0.js";
150
+ import {
151
+ calculateNextRun,
152
+ dispatchScheduleTarget,
153
+ ensure,
154
+ initialize,
155
+ require_dist
156
+ } from "./cli-yzxg93ma.js";
157
+ import"./cli-8y1kmyn7.js";
151
158
  import {
152
159
  normalizeModelKey
153
- } from "./cli-gpyx6t1w.js";
160
+ } from "./cli-e5hdn9nx.js";
154
161
  import {
155
162
  getUserGrant
156
- } from "./cli-2teefgw6.js";
163
+ } from "./cli-7yfmb4ne.js";
157
164
  import {
158
165
  can,
159
166
  clearAuditSink,
@@ -165,27 +172,20 @@ import {
165
172
  ensureAgentFsCredentialsForAgent,
166
173
  extractArgsJsonSchema,
167
174
  extractScriptSignature,
175
+ inviteEmailToSharedOrg,
168
176
  scriptSdkTypesWithGeneratedApis,
169
177
  scriptStdlibTypesWithGeneratedApis,
170
178
  typecheckScript
171
- } from "./cli-9b5m9d9v.js";
179
+ } from "./cli-g5a31r9y.js";
172
180
  import {
173
181
  checkHeartbeatChecklist,
174
182
  runHeartbeatSweep,
175
183
  stopHeartbeat
176
- } from "./cli-gq1ss3yf.js";
184
+ } from "./cli-527y7yzc.js";
177
185
  import {
178
186
  createResumeFollowUp,
179
187
  createWorkerTaskFollowUp
180
- } from "./cli-gat4kjhe.js";
181
- import"./cli-fad8m16k.js";
182
- import {
183
- calculateNextRun,
184
- dispatchScheduleTarget,
185
- ensure,
186
- initialize,
187
- require_dist
188
- } from "./cli-03hw3tdq.js";
188
+ } from "./cli-z612d1nc.js";
189
189
  import {
190
190
  RawLlmConfigSchema,
191
191
  TriggerSchemaError,
@@ -207,10 +207,22 @@ import {
207
207
  validateDefinition,
208
208
  validateJsonSchema,
209
209
  verifyHmacSignature
210
- } from "./cli-zyjvbdgq.js";
210
+ } from "./cli-j5da6jb2.js";
211
211
  import {
212
212
  getApiKey
213
213
  } from "./cli-f14fvzag.js";
214
+ import {
215
+ acquireOAuthRefreshLock,
216
+ buildAuthorizationUrl,
217
+ deleteOAuthTokens,
218
+ ensureTokenOrThrow,
219
+ exchangeCode,
220
+ forceRefreshTokenOrThrow,
221
+ getOAuthApp,
222
+ getOAuthTokens,
223
+ releaseOAuthRefreshLock,
224
+ upsertOAuthApp
225
+ } from "./cli-p4yn675m.js";
214
226
  import {
215
227
  CredentialBindingSchema,
216
228
  applyMcpOAuthRefresh,
@@ -259,11 +271,11 @@ import {
259
271
  upsertMcpOAuthToken,
260
272
  upsertScriptByName,
261
273
  upsertScriptConnection
262
- } from "./cli-3hqj0r0f.js";
274
+ } from "./cli-gzng1fst.js";
263
275
  import"./cli-jkhwmmgg.js";
264
276
  import {
265
277
  searchScripts
266
- } from "./cli-5fb5rv64.js";
278
+ } from "./cli-xgefj1nz.js";
267
279
  import {
268
280
  CANDIDATE_SET_MULTIPLIER,
269
281
  getEmbeddingProvider,
@@ -271,27 +283,21 @@ import {
271
283
  init_constants,
272
284
  init_reranker,
273
285
  rerank
274
- } from "./cli-bwkxh7pa.js";
286
+ } from "./cli-6expbmb3.js";
275
287
  import"./cli-q25ejbyn.js";
276
- import {
277
- acquireOAuthRefreshLock,
278
- buildAuthorizationUrl,
279
- deleteOAuthTokens,
280
- ensureTokenOrThrow,
281
- exchangeCode,
282
- forceRefreshTokenOrThrow,
283
- getOAuthApp,
284
- getOAuthTokens,
285
- releaseOAuthRefreshLock,
286
- upsertOAuthApp
287
- } from "./cli-gq46dx9q.js";
288
288
  import"./cli-0pygq9r1.js";
289
- import"./cli-q8bgrc7c.js";
289
+ import"./cli-fad8m16k.js";
290
+ import {
291
+ FilesError,
292
+ getFileStorageProvider,
293
+ normalizeFilesError
294
+ } from "./cli-95kferzh.js";
295
+ import"./cli-9y4z25ke.js";
290
296
  import {
291
297
  getSlackApp,
292
298
  startSlackApp,
293
299
  stopSlackApp
294
- } from "./cli-wt7b0vr9.js";
300
+ } from "./cli-emgzr4ja.js";
295
301
  import"./cli-rkndnn90.js";
296
302
  import"./cli-b0p7rfnd.js";
297
303
  import {
@@ -311,12 +317,12 @@ import {
311
317
  resolveUserByToken,
312
318
  revokeToken,
313
319
  unlinkIdentity
314
- } from "./cli-wmep6bjt.js";
315
- import"./cli-ma04faw5.js";
316
- import"./cli-wspgs9bt.js";
320
+ } from "./cli-3sew4a9j.js";
317
321
  import {
318
322
  createTaskWithSiblingAwareness
319
- } from "./cli-226nz7j1.js";
323
+ } from "./cli-td2x0s9b.js";
324
+ import"./cli-ma04faw5.js";
325
+ import"./cli-wspgs9bt.js";
320
326
  import {
321
327
  getAppUrl,
322
328
  getConfiguredAppUrls,
@@ -635,7 +641,7 @@ import {
635
641
  upsertSwarmConfig,
636
642
  validateConfigValue,
637
643
  withFavoriteFlags
638
- } from "./cli-6637ryhr.js";
644
+ } from "./cli-y82m27mq.js";
639
645
  import"./cli-z2zcxes1.js";
640
646
  import {
641
647
  init_zod
@@ -650,7 +656,7 @@ import {
650
656
  import {
651
657
  init_package,
652
658
  package_default
653
- } from "./cli-6j7ftsbs.js";
659
+ } from "./cli-cx30v78p.js";
654
660
  import {
655
661
  init_secret_scrubber,
656
662
  registerVolatileSecret,
@@ -664,16 +670,16 @@ import {
664
670
  } from "./cli-9aryf9tv.js";
665
671
  import {
666
672
  bedrockProviderModule
667
- } from "./cli-6b4wwmm8.js";
673
+ } from "./cli-0qy7bk86.js";
668
674
  import"./cli-cwy5hqbq.js";
669
675
  import"./cli-jvv0g8bh.js";
670
676
  import {
671
677
  setBedrockProviderModule
672
678
  } from "./cli-xw7p4wkq.js";
673
679
  import"./cli-hv2fndhm.js";
674
- import"./cli-pscrc6tw.js";
675
680
  import"./cli-zyxs93y9.js";
676
681
  import"./cli-4wgngmwv.js";
682
+ import"./cli-pscrc6tw.js";
677
683
  import"./cli-bsyka9ta.js";
678
684
  import"./cli-vapyk8sw.js";
679
685
  import"./cli-y2apkfe2.js";
@@ -3860,440 +3866,6 @@ async function handleFavorites(req, res, pathSegments, queryParams, myAgentId) {
3860
3866
  init_zod();
3861
3867
  init_db();
3862
3868
  import { createHash as createHash2 } from "node:crypto";
3863
-
3864
- // src/fs/provider.ts
3865
- class FilesError extends Error {
3866
- code;
3867
- status;
3868
- cause;
3869
- constructor(code, message, opts = {}) {
3870
- super(message);
3871
- this.name = "FilesError";
3872
- this.code = code;
3873
- this.status = opts.status;
3874
- this.cause = opts.cause;
3875
- }
3876
- }
3877
- function providerPath(scope) {
3878
- if (scope.key !== undefined && scope.key !== null && scope.key !== "") {
3879
- return normalizeStoredKey(scope.key);
3880
- }
3881
- const safeName = normalizeName(scope.name);
3882
- return `tasks/${encodeURIComponent(scope.taskId)}/${safeName}`;
3883
- }
3884
- function normalizeStoredKey(key) {
3885
- const trimmed = key.trim().replace(/^\/+/, "");
3886
- if (!trimmed || trimmed.includes("\x00")) {
3887
- throw new FilesError("Provider", "Stored file key must be a non-empty path");
3888
- }
3889
- if (trimmed.split("/").some((part) => part === "..")) {
3890
- throw new FilesError("Provider", "Stored file key must not contain parent path segments");
3891
- }
3892
- return trimmed;
3893
- }
3894
- function normalizeName(name) {
3895
- const trimmed = name.trim().replace(/^\/+/, "");
3896
- if (!trimmed || trimmed === "." || trimmed.includes("\x00")) {
3897
- throw new FilesError("Provider", "File name must be a non-empty relative path");
3898
- }
3899
- const parts = trimmed.split("/");
3900
- if (parts.some((part) => !part || part === "." || part === "..")) {
3901
- throw new FilesError("Provider", "File name must not contain empty or parent path segments");
3902
- }
3903
- return parts.map(encodeURIComponent).join("/");
3904
- }
3905
- function fileObjectFromHeaders(providerId, scope, headers2, overrides = {}) {
3906
- const sizeHeader = headers2.get("content-length");
3907
- return {
3908
- providerId,
3909
- key: providerPath(scope),
3910
- taskId: scope.taskId,
3911
- name: scope.name,
3912
- contentType: headers2.get("content-type") ?? undefined,
3913
- sizeBytes: sizeHeader ? Number(sizeHeader) : undefined,
3914
- etag: headers2.get("etag") ?? undefined,
3915
- sha256: headers2.get("x-agent-fs-content-hash") ?? undefined,
3916
- version: headers2.get("x-agent-fs-version") ?? undefined,
3917
- ...overrides
3918
- };
3919
- }
3920
- function normalizeFilesError(error) {
3921
- if (error instanceof FilesError) {
3922
- return error;
3923
- }
3924
- return new FilesError("Provider", error instanceof Error ? error.message : "File provider error", {
3925
- cause: error
3926
- });
3927
- }
3928
-
3929
- // src/fs/agent-fs-provider.ts
3930
- class AgentFsProvider {
3931
- id = "agent-fs";
3932
- capabilities = {
3933
- signedUrl: { supported: true, maxExpiresIn: 3600 },
3934
- search: true,
3935
- comments: true,
3936
- versioning: true
3937
- };
3938
- apiUrl;
3939
- apiKey;
3940
- orgId;
3941
- driveId;
3942
- fetchImpl;
3943
- constructor(options = {}) {
3944
- this.apiUrl = stripTrailingSlash(options.apiUrl ?? process.env.AGENT_FS_API_URL ?? "");
3945
- this.apiKey = options.apiKey ?? process.env.API_AGENT_FS_API_KEY ?? process.env.AGENT_FS_API_KEY ?? "";
3946
- this.orgId = options.orgId ?? process.env.AGENT_FS_DEFAULT_ORG_ID ?? process.env.AGENT_FS_SHARED_ORG_ID ?? "";
3947
- this.driveId = options.driveId ?? process.env.AGENT_FS_DEFAULT_DRIVE_ID ?? "";
3948
- this.fetchImpl = options.fetchImpl ?? globalThis.fetch;
3949
- if (!this.apiUrl || !this.apiKey || !this.orgId || !this.driveId) {
3950
- throw new FilesError("Provider", "AGENT_FS_API_URL, API_AGENT_FS_API_KEY or AGENT_FS_API_KEY, AGENT_FS_DEFAULT_ORG_ID, and AGENT_FS_DEFAULT_DRIVE_ID are required for the agent-fs provider");
3951
- }
3952
- }
3953
- async upload(scope, body, options = {}) {
3954
- const headers2 = new Headers(this.authHeaders());
3955
- if (options.contentType) {
3956
- headers2.set("content-type", options.contentType);
3957
- }
3958
- if (options.ifNoneMatch) {
3959
- headers2.set("if-none-match", options.ifNoneMatch);
3960
- }
3961
- if (options.ifMatch) {
3962
- headers2.set("if-match", options.ifMatch);
3963
- }
3964
- if (options.message) {
3965
- headers2.set("x-agent-fs-message", options.message);
3966
- }
3967
- const response = await this.fetchRaw(scope, { method: "PUT", headers: headers2, body });
3968
- const parsed = await response.json().catch(() => ({}));
3969
- return fileObjectFromHeaders(this.id, scope, response.headers, {
3970
- key: parsed.path ?? providerPath(scope),
3971
- version: parsed.version === undefined ? response.headers.get("x-agent-fs-version") ?? undefined : String(parsed.version),
3972
- sha256: parsed.contentHash ?? response.headers.get("x-agent-fs-content-hash") ?? undefined,
3973
- metadata: { deduped: parsed.deduped }
3974
- });
3975
- }
3976
- async download(scope) {
3977
- return this.fetchRaw(scope, { method: "GET", headers: this.authHeaders() });
3978
- }
3979
- async head(scope) {
3980
- const response = await this.download(scope);
3981
- await response.body?.cancel();
3982
- return fileObjectFromHeaders(this.id, scope, response.headers);
3983
- }
3984
- async exists(scope) {
3985
- try {
3986
- await this.head(scope);
3987
- return true;
3988
- } catch (error) {
3989
- if (error instanceof FilesError && error.code === "NotFound") {
3990
- return false;
3991
- }
3992
- throw error;
3993
- }
3994
- }
3995
- async delete(scope) {
3996
- await this.ops({ op: "rm", path: providerPath(scope) }, scope);
3997
- }
3998
- async copy(source, destination) {
3999
- await this.ops({ op: "cp", path: providerPath(source), dest: providerPath(destination) });
4000
- return this.head(destination);
4001
- }
4002
- async move(source, destination) {
4003
- await this.ops({ op: "mv", path: providerPath(source), dest: providerPath(destination) });
4004
- return this.head(destination);
4005
- }
4006
- async list(options) {
4007
- const prefix = `tasks/${encodeURIComponent(options.taskId)}/${options.prefix ?? ""}`;
4008
- const result = await this.ops({ op: "ls", path: prefix });
4009
- const resultRecord = asRecord(result);
4010
- const entries = Array.isArray(result) ? result : Array.isArray(resultRecord?.entries) ? resultRecord.entries : [];
4011
- return entries.slice(0, options.limit).map((entry) => {
4012
- const key = String(entry.path ?? entry.name ?? "");
4013
- const name = key.startsWith(`tasks/${encodeURIComponent(options.taskId)}/`) ? key.slice(`tasks/${encodeURIComponent(options.taskId)}/`.length) : key;
4014
- return {
4015
- providerId: this.id,
4016
- key,
4017
- taskId: options.taskId,
4018
- name: decodeURIComponent(name),
4019
- contentType: typeof entry.mimeType === "string" ? entry.mimeType : undefined,
4020
- sizeBytes: typeof entry.size === "number" ? entry.size : undefined,
4021
- version: entry.version === undefined ? undefined : String(entry.version)
4022
- };
4023
- });
4024
- }
4025
- async* listAll(options) {
4026
- for (const item of await this.list(options)) {
4027
- yield item;
4028
- }
4029
- }
4030
- async url(scope, options = {}) {
4031
- const expiresIn = Math.min(options.expiresIn ?? 3600, this.capabilities.signedUrl.maxExpiresIn);
4032
- const result = await this.ops({ op: "signed-url", path: providerPath(scope), expiresIn }, scope);
4033
- if (typeof result === "string") {
4034
- return result;
4035
- }
4036
- const resultRecord = asRecord(result);
4037
- if (typeof resultRecord?.url === "string") {
4038
- return resultRecord.url;
4039
- }
4040
- throw new FilesError("Provider", "agent-fs signed-url op did not return a URL");
4041
- }
4042
- async signedUploadUrl() {
4043
- throw new FilesError("ReadOnly", "agent-fs does not support signed upload URLs");
4044
- }
4045
- async search(query) {
4046
- const result = await this.ops({
4047
- op: "search",
4048
- query: query.query,
4049
- path: `tasks/${encodeURIComponent(query.taskId)}`,
4050
- limit: query.limit
4051
- });
4052
- return Array.isArray(result) ? result : [];
4053
- }
4054
- async addComment(input) {
4055
- return await this.ops({
4056
- op: "comment-add",
4057
- path: providerPath(input),
4058
- body: input.body,
4059
- range: input.range
4060
- });
4061
- }
4062
- async listComments(scope) {
4063
- const result = await this.ops({ op: "comment-list", path: providerPath(scope) });
4064
- return Array.isArray(result) ? result : [];
4065
- }
4066
- async listVersions(scope) {
4067
- const result = await this.ops({ op: "log", path: providerPath(scope) });
4068
- return Array.isArray(result) ? result : [];
4069
- }
4070
- async restoreVersion(scope) {
4071
- return await this.ops({
4072
- op: "revert",
4073
- path: providerPath(scope),
4074
- version: scope.version
4075
- });
4076
- }
4077
- async fetchRaw(scope, init) {
4078
- const response = await this.fetchImpl(this.rawUrl(scope), init);
4079
- if (!response.ok) {
4080
- throw await responseToFilesError(response);
4081
- }
4082
- return response;
4083
- }
4084
- async ops(body, scope) {
4085
- const response = await this.fetchImpl(`${this.apiUrl}/orgs/${encodeURIComponent(this.orgFor(scope))}/ops`, {
4086
- method: "POST",
4087
- headers: {
4088
- ...this.authHeaders(),
4089
- "content-type": "application/json"
4090
- },
4091
- body: JSON.stringify({ driveId: this.driveFor(scope), ...body })
4092
- });
4093
- if (!response.ok) {
4094
- throw await responseToFilesError(response);
4095
- }
4096
- return response.json().catch(() => null);
4097
- }
4098
- rawUrl(scope) {
4099
- return `${this.apiUrl}/orgs/${encodeURIComponent(this.orgFor(scope))}/drives/${encodeURIComponent(this.driveFor(scope))}/files/${providerPath(scope)}/raw`;
4100
- }
4101
- orgFor(scope) {
4102
- return scope?.orgId?.trim() || this.orgId;
4103
- }
4104
- driveFor(scope) {
4105
- return scope?.driveId?.trim() || this.driveId;
4106
- }
4107
- authHeaders() {
4108
- return { authorization: `Bearer ${this.apiKey}` };
4109
- }
4110
- }
4111
- function asRecord(value) {
4112
- return value && typeof value === "object" ? value : null;
4113
- }
4114
- async function responseToFilesError(response) {
4115
- const text = await response.text().catch(() => "");
4116
- const message = text || `File provider returned HTTP ${response.status}`;
4117
- if (response.status === 401 || response.status === 403) {
4118
- return new FilesError("Unauthorized", message, { status: response.status });
4119
- }
4120
- if (response.status === 404) {
4121
- return new FilesError("NotFound", message, { status: response.status });
4122
- }
4123
- if (response.status === 409 || response.status === 412) {
4124
- return new FilesError("Conflict", message, { status: response.status });
4125
- }
4126
- return new FilesError("Provider", message, { status: response.status });
4127
- }
4128
- function stripTrailingSlash(value) {
4129
- return value.replace(/\/+$/, "");
4130
- }
4131
-
4132
- // src/fs/local-fs-provider.ts
4133
- import { mkdir as mkdir2, readdir, rm as rm2, stat } from "node:fs/promises";
4134
- import { dirname, join, relative, sep } from "node:path";
4135
- var DEFAULT_ROOT_DIR = "./data/fs";
4136
-
4137
- class LocalFsProvider {
4138
- id = "local-fs";
4139
- capabilities = {
4140
- signedUrl: { supported: false }
4141
- };
4142
- rootDir;
4143
- constructor(options = {}) {
4144
- this.rootDir = options.rootDir ?? process.env.AGENT_FS_LOCAL_DIR ?? DEFAULT_ROOT_DIR;
4145
- }
4146
- async upload(scope, body, options = {}) {
4147
- const target = this.localPath(scope);
4148
- await mkdir2(dirname(target), { recursive: true });
4149
- if (options.ifNoneMatch === "*" && await this.exists(scope)) {
4150
- throw new FilesError("Conflict", "File already exists");
4151
- }
4152
- await Bun.write(target, await new Response(body).arrayBuffer());
4153
- if (options.contentType) {
4154
- await Bun.write(this.metaPath(target), JSON.stringify({ contentType: options.contentType }));
4155
- }
4156
- return this.head(scope);
4157
- }
4158
- async download(scope) {
4159
- const target = this.localPath(scope);
4160
- if (!await this.exists(scope)) {
4161
- throw new FilesError("NotFound", "File not found");
4162
- }
4163
- return new Response(Bun.file(target));
4164
- }
4165
- async head(scope) {
4166
- const target = this.localPath(scope);
4167
- try {
4168
- const info = await stat(target);
4169
- const storedContentType = await this.readStoredContentType(target);
4170
- return {
4171
- providerId: this.id,
4172
- key: providerPath(scope),
4173
- taskId: scope.taskId,
4174
- name: scope.name,
4175
- contentType: storedContentType ?? Bun.file(target).type ?? undefined,
4176
- sizeBytes: info.size,
4177
- updatedAt: info.mtime.toISOString()
4178
- };
4179
- } catch (error) {
4180
- if (error.code === "ENOENT") {
4181
- throw new FilesError("NotFound", "File not found", { cause: error });
4182
- }
4183
- throw new FilesError("Provider", "Unable to read file metadata", { cause: error });
4184
- }
4185
- }
4186
- async exists(scope) {
4187
- try {
4188
- await stat(this.localPath(scope));
4189
- return true;
4190
- } catch (error) {
4191
- if (error.code === "ENOENT") {
4192
- return false;
4193
- }
4194
- throw new FilesError("Provider", "Unable to check file existence", { cause: error });
4195
- }
4196
- }
4197
- async delete(scope) {
4198
- const target = this.localPath(scope);
4199
- await rm2(target, { force: true });
4200
- await rm2(this.metaPath(target), { force: true });
4201
- }
4202
- async copy(source, destination) {
4203
- const sourceHead = await this.head(source);
4204
- const response = await this.download(source);
4205
- await this.upload(destination, await response.arrayBuffer(), {
4206
- contentType: sourceHead.contentType
4207
- });
4208
- return this.head(destination);
4209
- }
4210
- async move(source, destination) {
4211
- const copied = await this.copy(source, destination);
4212
- await this.delete(source);
4213
- return copied;
4214
- }
4215
- async list(options) {
4216
- const taskRoot = join(this.rootDir, "tasks", encodeURIComponent(options.taskId));
4217
- const files = [];
4218
- await this.walk(taskRoot, async (path) => {
4219
- const rel = relative(taskRoot, path).split(sep).join("/");
4220
- const name = decodePath(rel);
4221
- if (options.prefix && !name.startsWith(options.prefix)) {
4222
- return;
4223
- }
4224
- files.push(await this.head({ taskId: options.taskId, name }));
4225
- });
4226
- return typeof options.limit === "number" ? files.slice(0, options.limit) : files;
4227
- }
4228
- async* listAll(options) {
4229
- for (const item of await this.list(options)) {
4230
- yield item;
4231
- }
4232
- }
4233
- async url(scope) {
4234
- return `/api/fs/tasks/${encodeURIComponent(scope.taskId)}/files/${encodeURIComponent(scope.name)}/raw`;
4235
- }
4236
- async signedUploadUrl() {
4237
- throw new FilesError("ReadOnly", "local-fs does not support signed upload URLs");
4238
- }
4239
- localPath(scope) {
4240
- return join(this.rootDir, providerPath(scope));
4241
- }
4242
- metaPath(target) {
4243
- return `${target}.meta.json`;
4244
- }
4245
- async readStoredContentType(target) {
4246
- try {
4247
- const metaFile = Bun.file(this.metaPath(target));
4248
- if (!await metaFile.exists()) {
4249
- return;
4250
- }
4251
- const meta = await metaFile.json();
4252
- return typeof meta?.contentType === "string" ? meta.contentType : undefined;
4253
- } catch {
4254
- return;
4255
- }
4256
- }
4257
- async walk(dir, visit) {
4258
- let entries;
4259
- try {
4260
- entries = await readdir(dir, { withFileTypes: true });
4261
- } catch (error) {
4262
- if (error.code === "ENOENT") {
4263
- return;
4264
- }
4265
- throw new FilesError("Provider", "Unable to list files", { cause: error });
4266
- }
4267
- for (const entry of entries) {
4268
- const path = join(dir, entry.name);
4269
- if (entry.isDirectory()) {
4270
- await this.walk(path, visit);
4271
- } else if (entry.isFile() && !entry.name.endsWith(".meta.json")) {
4272
- await visit(path);
4273
- }
4274
- }
4275
- }
4276
- }
4277
- function decodePath(path) {
4278
- return path.split("/").map((part) => decodeURIComponent(part)).join("/");
4279
- }
4280
-
4281
- // src/fs/registry.ts
4282
- var memoizedProvider = null;
4283
- function getFileStorageProvider() {
4284
- if (!memoizedProvider) {
4285
- memoizedProvider = selectProvider();
4286
- }
4287
- return memoizedProvider;
4288
- }
4289
- function selectProvider() {
4290
- if (process.env.AGENT_FS_API_URL && (process.env.API_AGENT_FS_API_KEY || process.env.AGENT_FS_API_KEY)) {
4291
- return new AgentFsProvider;
4292
- }
4293
- return new LocalFsProvider;
4294
- }
4295
-
4296
- // src/http/fs.ts
4297
3869
  init_request_auth_context();
4298
3870
  init_secret_scrubber();
4299
3871
  var MAX_UPLOAD_BYTES = 50 * 1024 * 1024;
@@ -4334,6 +3906,27 @@ var ensureAgentCredentialsRoute = route({
4334
3906
  },
4335
3907
  auth: { apiKey: true, agentId: true }
4336
3908
  });
3909
+ var inviteMemberRoute = route({
3910
+ method: "post",
3911
+ path: "/api/fs/members/invite",
3912
+ pattern: ["api", "fs", "members", "invite"],
3913
+ summary: "Invite an external member into the agent-fs shared org",
3914
+ description: "The API server performs the invite with its own bootstrap credentials (which are API-only and never served over HTTP), provisioning the shared org/drive first when needed. Intended for the cloud control plane's Connect-to-Drive flow. No keys are returned; the invitee obtains their own key via agent-fs registration.",
3915
+ tags: ["FS"],
3916
+ body: exports_external.object({
3917
+ email: exports_external.email(),
3918
+ role: exports_external.enum(["viewer", "editor", "admin"]).default("editor")
3919
+ }),
3920
+ responses: {
3921
+ 200: { description: "Invite state ({ orgId, invited })" },
3922
+ 400: { description: "Invalid body" },
3923
+ 500: { description: "Provisioning or invite failed" }
3924
+ },
3925
+ auth: { apiKey: true },
3926
+ rbac: {
3927
+ ungated: "Tenant API key is the org-owner credential; the invite runs under the API server's own bootstrap identity, no per-agent principal applies."
3928
+ }
3929
+ });
4337
3930
  var listTaskFilesRoute = route({
4338
3931
  method: "get",
4339
3932
  path: "/api/fs/tasks/{taskId}/files",
@@ -4439,6 +4032,19 @@ async function handleFs(req, res, pathSegments, queryParams, myAgentId) {
4439
4032
  }
4440
4033
  return true;
4441
4034
  }
4035
+ if (inviteMemberRoute.match(req.method, pathSegments)) {
4036
+ const parsed = await inviteMemberRoute.parse(req, res, pathSegments, queryParams);
4037
+ if (!parsed)
4038
+ return true;
4039
+ try {
4040
+ const result = await inviteEmailToSharedOrg(parsed.body.email, parsed.body.role);
4041
+ json(res, result);
4042
+ } catch (error) {
4043
+ const message = scrubSecrets(error instanceof Error ? error.message : String(error));
4044
+ jsonError(res, `Failed to invite member to agent-fs shared org: ${message}`, 500);
4045
+ }
4046
+ return true;
4047
+ }
4442
4048
  if (downloadTaskFileRoute.match(req.method, pathSegments)) {
4443
4049
  const parsed = await downloadTaskFileRoute.parse(req, res, pathSegments, queryParams);
4444
4050
  if (!parsed)
@@ -20689,14 +20295,14 @@ async function shutdown() {
20689
20295
  sessionsProcessed: getServerSessionsProcessed()
20690
20296
  });
20691
20297
  if (hasCapability("scheduling")) {
20692
- const { stopScheduler } = await import("./index-4zpkrw7q.js");
20298
+ const { stopScheduler } = await import("./index-ep25fyer.js");
20693
20299
  stopScheduler();
20694
20300
  }
20695
20301
  stopHeartbeat();
20696
20302
  stopScriptRunSupervisor();
20697
20303
  await stopSlackApp();
20698
20304
  if (process.env.OAUTH_KEEPALIVE_DISABLE !== "true") {
20699
- const { stopOAuthKeepalive } = await import("./keepalive-wp8xyhnb.js");
20305
+ const { stopOAuthKeepalive } = await import("./keepalive-70mwsyhb.js");
20700
20306
  await stopOAuthKeepalive();
20701
20307
  }
20702
20308
  stopMcpOAuthPendingGc();
@@ -20753,15 +20359,15 @@ try {
20753
20359
  throw err;
20754
20360
  }
20755
20361
  try {
20756
- const { seedPricingFromModelsDev } = await import("./seed-pricing-n6weaf7s.js");
20362
+ const { seedPricingFromModelsDev } = await import("./seed-pricing-jd8zj8k7.js");
20757
20363
  seedPricingFromModelsDev();
20758
- const { startPricingRefreshLoop } = await import("./pricing-refresh-0d0877ex.js");
20364
+ const { startPricingRefreshLoop } = await import("./pricing-refresh-7ra0g3az.js");
20759
20365
  startPricingRefreshLoop();
20760
20366
  } catch (err) {
20761
20367
  console.error("[startup] Failed to seed pricing rows:", err);
20762
20368
  }
20763
20369
  try {
20764
- const { ensureRbacSeedsSynced } = await import("./rbac-roles-s1kpmgrb.js");
20370
+ const { ensureRbacSeedsSynced } = await import("./rbac-roles-s0esm5k6.js");
20765
20371
  ensureRbacSeedsSynced();
20766
20372
  } catch (err) {
20767
20373
  console.error("[startup] Failed to sync RBAC seed rows:", err);
@@ -20769,7 +20375,7 @@ try {
20769
20375
  throw err;
20770
20376
  }
20771
20377
  try {
20772
- const { runAllSeeders } = await import("./index-snekxj7z.js");
20378
+ const { runAllSeeders } = await import("./index-9h6qre5v.js");
20773
20379
  await runAllSeeders({ scriptEmbeddingMode: "skip" });
20774
20380
  } catch (err) {
20775
20381
  console.error("[startup] Failed to seed built-in entities:", err);
@@ -20805,35 +20411,35 @@ httpServer.listen(port, async () => {
20805
20411
  initWorkflows();
20806
20412
  startScriptRunSupervisor(getMcpBaseUrl());
20807
20413
  if (hasCapability("scheduling")) {
20808
- const { startScheduler } = await import("./index-4zpkrw7q.js");
20809
- const { getExecutorRegistry: getExecutorRegistry2 } = await import("./index-wk5gsfqy.js");
20414
+ const { startScheduler } = await import("./index-ep25fyer.js");
20415
+ const { getExecutorRegistry: getExecutorRegistry2 } = await import("./index-vmcp507g.js");
20810
20416
  const intervalMs = Number(process.env.SCHEDULER_INTERVAL_MS) || 1e4;
20811
20417
  startScheduler(getExecutorRegistry2(), intervalMs, {
20812
20418
  runId: globalState.__runId
20813
20419
  });
20814
20420
  }
20815
20421
  if (process.env.HEARTBEAT_DISABLE !== "true") {
20816
- const { startHeartbeat } = await import("./index-afc5zk9k.js");
20422
+ const { startHeartbeat } = await import("./index-basky7qw.js");
20817
20423
  const heartbeatMs = Number(process.env.HEARTBEAT_INTERVAL_MS) || 90000;
20818
20424
  startHeartbeat(heartbeatMs);
20819
20425
  }
20820
20426
  if (process.env.OAUTH_KEEPALIVE_DISABLE !== "true") {
20821
- const { startOAuthKeepalive } = await import("./keepalive-wp8xyhnb.js");
20427
+ const { startOAuthKeepalive } = await import("./keepalive-70mwsyhb.js");
20822
20428
  startOAuthKeepalive();
20823
20429
  }
20824
20430
  if (process.env.OAUTH_REFRESH_SWEEP_DISABLE !== "true") {
20825
- const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-yb4scdc0.js");
20431
+ const { startOAuthRefreshSweep } = await import("./oauth-refresh-sweep-dfbd7yw0.js");
20826
20432
  startOAuthRefreshSweep();
20827
20433
  }
20828
20434
  startMcpOAuthPendingGc();
20829
20435
  startMemoryGc();
20830
- import("./boot-reembed-t2ct62pw.js").then(({ runBootReembed }) => runBootReembed()).catch((err) => {
20436
+ import("./boot-reembed-7gy85nnp.js").then(({ runBootReembed }) => runBootReembed()).catch((err) => {
20831
20437
  console.error("[boot-reembed] startup backfill failed (non-fatal):", err);
20832
20438
  });
20833
- import("./boot-reembed-gjatq261.js").then(({ runBootReembedScripts }) => runBootReembedScripts()).catch((err) => {
20439
+ import("./boot-reembed-zktmj8zt.js").then(({ runBootReembedScripts }) => runBootReembedScripts()).catch((err) => {
20834
20440
  console.error("[boot-reembed-scripts] startup backfill failed (non-fatal):", err);
20835
20441
  });
20836
- import("./boot-scrub-logs-vwvpxk23.js").then(({ runBootScrubLogs }) => runBootScrubLogs()).catch((err) => {
20442
+ import("./boot-scrub-logs-d8n8pcgr.js").then(({ runBootScrubLogs }) => runBootScrubLogs()).catch((err) => {
20837
20443
  console.error("[boot-scrub-logs] startup scrub failed (non-fatal):", err);
20838
20444
  });
20839
20445
  }).on("error", (err) => {