@desplega.ai/agent-swarm 1.82.0 → 1.83.0

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.
@@ -17,3 +17,61 @@ export function getAppUrl(): string {
17
17
  const raw = process.env.APP_URL?.trim();
18
18
  return (raw || DEFAULT_APP_URL).replace(/\/+$/, "");
19
19
  }
20
+
21
+ /**
22
+ * Default agent-fs live host used when `AGENT_FS_LIVE_URL` is unset. Points at
23
+ * the public production live server so any link rendered in Slack/UI is
24
+ * always reachable. Self-hosted operators should set `AGENT_FS_LIVE_URL`.
25
+ */
26
+ export const DEFAULT_AGENT_FS_LIVE_URL = "https://live.agent-fs.dev";
27
+
28
+ /**
29
+ * Resolve the effective agent-fs live URL from `AGENT_FS_LIVE_URL` (with
30
+ * trailing slashes stripped), falling back to {@link DEFAULT_AGENT_FS_LIVE_URL}.
31
+ */
32
+ export function getAgentFsLiveUrl(): string {
33
+ const raw = process.env.AGENT_FS_LIVE_URL?.trim();
34
+ return (raw || DEFAULT_AGENT_FS_LIVE_URL).replace(/\/+$/, "");
35
+ }
36
+
37
+ /**
38
+ * Optional fallback agent-fs `org_id` for attachments that store only `path`.
39
+ * Strictly opt-in — when neither env var is set, the renderer keeps the
40
+ * `agent-fs:<path>` raw-string fallback. Row-level IDs always win over the
41
+ * env-var defaults so per-attachment overrides remain authoritative.
42
+ */
43
+ export function getAgentFsDefaultOrgId(): string | undefined {
44
+ const raw = process.env.AGENT_FS_DEFAULT_ORG_ID?.trim();
45
+ return raw || undefined;
46
+ }
47
+
48
+ /**
49
+ * Optional fallback agent-fs `drive_id`. See {@link getAgentFsDefaultOrgId}.
50
+ */
51
+ export function getAgentFsDefaultDriveId(): string | undefined {
52
+ const raw = process.env.AGENT_FS_DEFAULT_DRIVE_ID?.trim();
53
+ return raw || undefined;
54
+ }
55
+
56
+ /**
57
+ * Resolve a public agent-fs live URL for an attachment when we have enough
58
+ * info — `path` plus (`orgId` and `driveId`, falling back to env-var
59
+ * defaults). Returns `null` when the path is missing or no org/drive pair is
60
+ * available; callers fall back to the raw `agent-fs:<path>` display.
61
+ *
62
+ * Shape: ${liveHost}/file/~/<orgId>/<driveId>/<normalized-path>
63
+ */
64
+ export function buildAgentFsLiveUrl(opts: {
65
+ path?: string | null;
66
+ orgId?: string | null;
67
+ driveId?: string | null;
68
+ }): string | null {
69
+ const path = opts.path?.trim();
70
+ if (!path) return null;
71
+ const orgId = opts.orgId?.trim() || getAgentFsDefaultOrgId();
72
+ const driveId = opts.driveId?.trim() || getAgentFsDefaultDriveId();
73
+ if (!orgId || !driveId) return null;
74
+ const host = getAgentFsLiveUrl();
75
+ const normalizedPath = path.replace(/^\/+/, "");
76
+ return `${host}/file/~/${orgId}/${driveId}/${normalizedPath}`;
77
+ }