@desplega.ai/agent-swarm 1.113.0 → 1.115.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.
- package/README.md +2 -2
- package/dist/{actions-q4n7cz6e.js → actions-17ya5wde.js} +8 -9
- package/dist/{app-es4nzc71.js → app-4f718yk0.js} +6 -6
- package/dist/{assistant-0x8ey0vs.js → assistant-ah7csnjz.js} +19 -18
- package/dist/{boot-reembed-69agkhv6.js → boot-reembed-4jpxhb25.js} +6 -6
- package/dist/{boot-reembed-p0ny05t8.js → boot-reembed-qata34xa.js} +5 -5
- package/dist/{boot-scrub-logs-yybrkmvr.js → boot-scrub-logs-tv48nn3z.js} +4 -4
- package/dist/{claude-adapter-mma9a1yr.js → claude-adapter-3csn5bks.js} +3 -3
- package/dist/{claude-managed-adapter-pv2nbqy4.js → claude-managed-adapter-kysmkz89.js} +2 -2
- package/dist/cli-0pygq9r1.js +429 -0
- package/dist/{cli-hsetkkd3.js → cli-12vb0xg6.js} +33 -9
- package/dist/{cli-ncfgsqbd.js → cli-15y7qhzp.js} +262 -33
- package/dist/{cli-7ga43spr.js → cli-1yjrbg1f.js} +1 -1
- package/dist/{cli-36ymmpmp.js → cli-3samkyap.js} +2 -2
- package/dist/cli-52fg7s7x.js +269 -0
- package/dist/{cli-hjhvekf4.js → cli-65ekje01.js} +11 -8
- package/dist/{cli-h3k622d0.js → cli-6aq8xhvm.js} +90 -3
- package/dist/{cli-f3qa069v.js → cli-7xje5amz.js} +1 -1
- package/dist/cli-86fdnerz.js +405 -0
- package/dist/{cli-9cy6nc5m.js → cli-8fjwym53.js} +1 -1
- package/dist/{cli-c3frqf65.js → cli-b23axgz4.js} +3 -3
- package/dist/{cli-a0t7vapf.js → cli-bc89my0z.js} +1 -1
- package/dist/{cli-bnzbn8j8.js → cli-beea4a3y.js} +73 -24
- package/dist/{cli-q21d49ac.js → cli-bw80ck94.js} +1 -1
- package/dist/{cli-pwc5e83c.js → cli-cchksf5q.js} +12 -7
- package/dist/{cli-30bbaveh.js → cli-cmw9rzy5.js} +2 -2
- package/dist/{cli-y6mrptcn.js → cli-cnwssmsr.js} +1 -1
- package/dist/{cli-r5g6ngtn.js → cli-dcca6j8m.js} +46 -5
- package/dist/{cli-tkmm5nf9.js → cli-e61fs2hp.js} +59 -2
- package/dist/{cli-6wscj9z0.js → cli-e7306swv.js} +14 -14
- package/dist/{cli-dcfyyh3t.js → cli-ftyf58xj.js} +2 -2
- package/dist/{cli-4xyj9jtq.js → cli-hrhye2rm.js} +1062 -478
- package/dist/cli-jkhwmmgg.js +136 -0
- package/dist/{cli-y4ycrnjc.js → cli-k3y4z3h5.js} +1 -1
- package/dist/{cli-6xd0bvf8.js → cli-ma04faw5.js} +1 -1
- package/dist/{cli-2fc97xm5.js → cli-mnbgv3w7.js} +4 -4
- package/dist/{cli-trmapn9k.js → cli-pet3aev6.js} +95 -10
- package/dist/{cli-z46pnksz.js → cli-q1rx7g0d.js} +175 -28
- package/dist/{cli-qwgtacd6.js → cli-r9f6ngrf.js} +1244 -336
- package/dist/{cli-gtkqc144.js → cli-shvaxw27.js} +13 -7
- package/dist/{cli-ywez6yps.js → cli-sq7f72d6.js} +1 -1
- package/dist/cli-t0vqevnm.js +393 -0
- package/dist/{cli-tbw13sx8.js → cli-tece6zgm.js} +1 -1
- package/dist/{cli-bgvskydy.js → cli-tffvrh6j.js} +1 -1
- package/dist/cli-wh91zby6.js +187222 -0
- package/dist/{cli-anrj584m.js → cli-xz9aq0rf.js} +1 -1
- package/dist/{cli-mq580e06.js → cli-zsrdty74.js} +18 -18
- package/dist/cli.js +32 -15
- package/dist/{codex-adapter-5cmy858w.js → codex-adapter-de3w0nch.js} +10 -10
- package/dist/{codex-session-runner-46q8mrba.js → codex-session-runner-bnw8cysk.js} +10 -10
- package/dist/{commands-z5dbwta3.js → commands-hch4e2k1.js} +4 -4
- package/dist/{db-bbgahh4z.js → db-p3h2j06x.js} +14 -4
- package/dist/{handlers-6b44317z.js → handlers-9er4zx9q.js} +17 -31
- package/dist/{hook-sbp5fmps.js → hook-4axs756z.js} +7 -7
- package/dist/{http-2xz43gz3.js → http-809fvtz2.js} +1934 -886
- package/dist/{index-wz1ea15p.js → index-2dgfj9av.js} +3 -3
- package/dist/{index-nhat35em.js → index-47em3d2n.js} +14 -11
- package/dist/{index-5ghxn8s6.js → index-9fqaktjr.js} +12 -9
- package/dist/{index-0gzmqj4k.js → index-9ht8gr56.js} +13 -10
- package/dist/{index-vfedgdw6.js → index-rm85cfdx.js} +368 -40
- package/dist/{index-ykvs43z4.js → index-t2snazez.js} +4 -4
- package/dist/{keepalive-62gfj91d.js → keepalive-3cps6e3e.js} +7 -6
- package/dist/{lead-ag0akn0v.js → lead-fkk95wgq.js} +36 -32
- package/dist/{maintenance-xxrrzk5x.js → maintenance-fweqh0yj.js} +6 -6
- package/dist/{mistral-conversations-26yrnbf1.js → mistral-conversations-7gqnz2wt.js} +7 -7
- package/dist/oauth-refresh-sweep-sycqtbph.js +114 -0
- package/dist/{onboard-64zyfcbs.js → onboard-cy0rkgvx.js} +2 -2
- package/dist/{opencode-adapter-mqsxr170.js → opencode-adapter-p6bxnbm4.js} +2 -2
- package/dist/{otel-zjd9zaxs.js → otel-g299k41b.js} +2 -2
- package/dist/{otel-impl-b86qseaa.js → otel-impl-wbns8hf7.js} +1 -1
- package/dist/{pi-mono-adapter-kxjxpfgy.js → pi-mono-adapter-05sck1ds.js} +17 -109
- package/dist/{pricing-refresh-cgtkffpa.js → pricing-refresh-0hvazmkf.js} +6 -6
- package/dist/rbac-roles-kfesjy9y.js +28 -0
- package/dist/rbac-roles-mwcwhbxc.js +283 -0
- package/dist/{seed-pricing-1r1y1xkq.js → seed-pricing-h2kdq4cq.js} +5 -5
- package/dist/{setup-mkcgkjf7.js → setup-8506q97w.js} +2 -2
- package/dist/{worker-351sze63.js → worker-4r5c6zyb.js} +36 -32
- package/openapi.json +1327 -20
- package/package.json +3 -3
- package/src/agentmail/handlers.ts +16 -6
- package/src/agentmail/templates.ts +25 -5
- package/src/be/audit-user.ts +28 -4
- package/src/be/db-queries/oauth.ts +42 -0
- package/src/be/db.ts +314 -28
- package/src/be/identity.ts +79 -0
- package/src/be/mcp-proxy.ts +132 -0
- package/src/be/migrations/109_rbac_roles.sql +79 -0
- package/src/be/migrations/111_oauth_credential_bindings.sql +6 -0
- package/src/be/migrations/112_script_connections_graphql.sql +96 -0
- package/src/be/migrations/113_task_routing_affinity.sql +9 -0
- package/src/be/migrations/114_backfill_gpt_5_6_pricing.sql +15 -0
- package/src/be/modelsdev-cache.json +135 -0
- package/src/be/oauth-credential-bindings.ts +35 -0
- package/src/be/oauth-refresh-sweep.ts +159 -0
- package/src/be/rbac-audit.ts +52 -13
- package/src/be/rbac-roles.ts +424 -0
- package/src/be/script-connections.ts +459 -40
- package/src/be/script-credential-broker.ts +29 -3
- package/src/be/scripts/typecheck.ts +51 -7
- package/src/be/seed-scripts/catalog/catalog-report.inline.ts +325 -24
- package/src/be/seed-scripts/catalog/catalog-report.ts +325 -24
- package/src/be/users.ts +24 -0
- package/src/cli.tsx +17 -0
- package/src/github/handlers.ts +10 -9
- package/src/github/templates.ts +45 -9
- package/src/gitlab/handlers.ts +20 -8
- package/src/gitlab/templates.ts +18 -6
- package/src/heartbeat/heartbeat.ts +143 -21
- package/src/http/all-routes.ts +3 -0
- package/src/http/approval-requests.ts +12 -0
- package/src/http/config.ts +44 -10
- package/src/http/core.ts +30 -3
- package/src/http/favorites.ts +1 -5
- package/src/http/index.ts +25 -1
- package/src/http/mcp-oauth.ts +2 -0
- package/src/http/mcp-servers.ts +44 -3
- package/src/http/oauth-generic.ts +105 -0
- package/src/http/poll.ts +20 -3
- package/src/http/script-connection-proxy.ts +116 -0
- package/src/http/script-connections.ts +1657 -0
- package/src/http/scripts.ts +27 -7
- package/src/http/skills.ts +11 -0
- package/src/http/tasks.ts +27 -13
- package/src/http/x.ts +6 -2
- package/src/integrations/kapso/inbound.ts +23 -6
- package/src/jira/sync.ts +111 -17
- package/src/jira/templates.ts +10 -2
- package/src/mcp-client/http-client.ts +194 -0
- package/src/oauth/app-validation.ts +16 -0
- package/src/oauth/ensure-token.ts +69 -14
- package/src/oauth/mcp-wrapper.ts +15 -0
- package/src/oauth/wrapper.ts +48 -20
- package/src/prompts/session-templates.ts +3 -3
- package/src/providers/codex-models.ts +100 -30
- package/src/providers/modelsdev-reasoning.json +51 -0
- package/src/providers/pi-mono-mcp-client.ts +2 -133
- package/src/providers/reasoning-effort.ts +11 -5
- package/src/rbac/admission.ts +68 -0
- package/src/rbac/index.ts +2 -0
- package/src/rbac/legacy-policy.ts +12 -0
- package/src/rbac/permissions.ts +48 -0
- package/src/scheduler/scheduler.ts +9 -1
- package/src/scripts-runtime/api-client.ts +151 -19
- package/src/scripts-runtime/api-types.ts +38 -6
- package/src/scripts-runtime/credential-broker/default-bindings.ts +1 -0
- package/src/scripts-runtime/credential-broker/types.ts +8 -0
- package/src/scripts-runtime/ctx.ts +11 -1
- package/src/scripts-runtime/eval-harness.ts +5 -1
- package/src/scripts-runtime/executors/types.ts +2 -1
- package/src/scripts-runtime/loader.ts +3 -1
- package/src/scripts-runtime/mcp-client.ts +87 -0
- package/src/scripts-runtime/sdk-allowlist.ts +1 -0
- package/src/scripts-runtime/types/stdlib.d.ts +6 -0
- package/src/scripts-runtime/types/swarm-sdk.d.ts +19 -0
- package/src/server-user.ts +114 -59
- package/src/server.ts +12 -0
- package/src/slack/assistant.ts +14 -6
- package/src/slack/enrich.ts +17 -0
- package/src/slack/handlers.ts +8 -22
- package/src/slack/responses.ts +91 -1
- package/src/slack/thread-buffer.ts +6 -3
- package/src/slack/watcher.ts +9 -6
- package/src/tasks/worker-follow-up.ts +100 -3
- package/src/tests/agentmail-handlers.test.ts +32 -3
- package/src/tests/approval-requests.test.ts +61 -0
- package/src/tests/audit-user.test.ts +47 -1
- package/src/tests/codex-adapter.test.ts +46 -23
- package/src/tests/credential-broker.test.ts +5 -2
- package/src/tests/delete-page-tool.test.ts +197 -0
- package/src/tests/github-handlers.test.ts +28 -2
- package/src/tests/gitlab-handlers.test.ts +125 -0
- package/src/tests/heartbeat.test.ts +48 -3
- package/src/tests/identity.test.ts +117 -0
- package/src/tests/jira-sync.test.ts +99 -1
- package/src/tests/kapso-inbound.test.ts +7 -0
- package/src/tests/mcp-tools-user.test.ts +60 -6
- package/src/tests/model-control.test.ts +8 -2
- package/src/tests/oauth-credential-bindings.test.ts +490 -0
- package/src/tests/oauth-refresh-sweep.test.ts +160 -0
- package/src/tests/pool-affinity.test.ts +401 -0
- package/src/tests/prompt-template-remaining.test.ts +2 -2
- package/src/tests/rbac-admission-e2e.test.ts +386 -0
- package/src/tests/rbac-admission.test.ts +492 -0
- package/src/tests/rbac-e2e-helpers.ts +3 -0
- package/src/tests/rbac-engine.test.ts +50 -0
- package/src/tests/rbac-mcp-admission-e2e.test.ts +362 -0
- package/src/tests/rbac-roles.test.ts +328 -0
- package/src/tests/reasoning-effort.test.ts +15 -2
- package/src/tests/schedule-target-type.test.ts +50 -0
- package/src/tests/scheduled-tasks.test.ts +40 -0
- package/src/tests/script-apis-mcp.test.ts +37 -13
- package/src/tests/script-connections-http.test.ts +1158 -0
- package/src/tests/script-connections-mcp.test.ts +894 -0
- package/src/tests/script-connections.test.ts +754 -6
- package/src/tests/scripts-external-api.test.ts +49 -1
- package/src/tests/scripts-runtime-secret-egress.test.ts +1 -0
- package/src/tests/scripts-runtime.test.ts +291 -0
- package/src/tests/seed-scripts.test.ts +36 -0
- package/src/tests/slack-identity-resolution.test.ts +37 -3
- package/src/tests/slack-inline-output.test.ts +65 -0
- package/src/tests/slack-thread-buffer.test.ts +28 -0
- package/src/tests/tool-annotations.test.ts +1 -0
- package/src/tests/user-token-rest-auth.test.ts +140 -1
- package/src/tests/workflow-swarm-script.test.ts +44 -0
- package/src/tests/workflow-triggers-v2.test.ts +300 -1
- package/src/tools/credential-bindings/tool.ts +277 -18
- package/src/tools/delete-page.ts +145 -0
- package/src/tools/mcp-servers/mcp-server-delete.ts +7 -4
- package/src/tools/request-human-input.ts +2 -0
- package/src/tools/resolve-user.ts +77 -27
- package/src/tools/script-apis.ts +62 -3
- package/src/tools/script-connections/tool.ts +275 -31
- package/src/tools/send-task.ts +15 -1
- package/src/tools/task-action.ts +34 -2
- package/src/tools/templates.ts +53 -1
- package/src/tools/tool-config.ts +2 -1
- package/src/tools/utils.ts +2 -0
- package/src/tools/workflows/create-workflow.ts +8 -1
- package/src/tools/workflows/update-workflow.ts +11 -2
- package/src/types.ts +90 -11
- package/src/utils/scoped-resource.ts +25 -0
- package/src/workflows/executors/human-in-the-loop.ts +1 -0
- package/src/workflows/executors/swarm-script.ts +7 -1
- package/src/workflows/triggers.ts +146 -18
- package/templates/skills/swarm-scripts/content.md +33 -8
- package/dist/cli-bgef578c.js +0 -771
- package/dist/cli-c9mtm09b.js +0 -43
- package/dist/cli-ceewqajw.js +0 -1698
- package/dist/{anthropic-messages-8nc6r2dw.js → anthropic-messages-kq3pjhbp.js} +6 -6
- package/dist/{azure-openai-responses-6yfzw3qw.js → azure-openai-responses-gm1ejtmn.js} +7 -7
- package/dist/{cli-vbraamxr.js → cli-6b4wwmm8.js} +9 -9
- package/dist/{cli-2r7s8jhp.js → cli-sznberje.js} +3 -3
- package/dist/{google-generative-ai-vfq6ymz9.js → google-generative-ai-hyrra2jm.js} +3 -3
- package/dist/{google-vertex-mj5y5rfj.js → google-vertex-8bs2pzgn.js} +3 -3
- package/dist/{openai-codex-responses-8h6kvfv8.js → openai-codex-responses-3nkvje79.js} +4 -4
- package/dist/{openai-completions-x6kjnqjd.js → openai-completions-0asftkwg.js} +11 -11
- package/dist/{openai-responses-7jwyz3ds.js → openai-responses-pmatek45.js} +10 -10
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// src/mcp-client/http-client.ts
|
|
2
|
+
function jsonRpcErrorMessage(error) {
|
|
3
|
+
if (typeof error === "string")
|
|
4
|
+
return error;
|
|
5
|
+
return error.message ?? JSON.stringify(error);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
class McpHttpClient {
|
|
9
|
+
baseUrl;
|
|
10
|
+
apiKey;
|
|
11
|
+
agentId;
|
|
12
|
+
taskId;
|
|
13
|
+
options;
|
|
14
|
+
sessionId = null;
|
|
15
|
+
nextId = 1;
|
|
16
|
+
customHeaders = {};
|
|
17
|
+
useRawUrl = false;
|
|
18
|
+
constructor(baseUrl, apiKey, agentId, taskId, options = {}) {
|
|
19
|
+
this.baseUrl = baseUrl;
|
|
20
|
+
this.apiKey = apiKey;
|
|
21
|
+
this.agentId = agentId;
|
|
22
|
+
this.taskId = taskId;
|
|
23
|
+
this.options = options;
|
|
24
|
+
}
|
|
25
|
+
async send(body) {
|
|
26
|
+
const headers = {
|
|
27
|
+
"Content-Type": "application/json",
|
|
28
|
+
Accept: "application/json, text/event-stream"
|
|
29
|
+
};
|
|
30
|
+
if (this.apiKey || !this.options.omitEmptyAuthHeaders) {
|
|
31
|
+
headers.Authorization = `Bearer ${this.apiKey}`;
|
|
32
|
+
}
|
|
33
|
+
if (this.agentId || !this.options.omitEmptyAuthHeaders) {
|
|
34
|
+
headers["X-Agent-ID"] = this.agentId;
|
|
35
|
+
}
|
|
36
|
+
Object.assign(headers, this.customHeaders);
|
|
37
|
+
if (this.taskId) {
|
|
38
|
+
headers["X-Source-Task-Id"] = this.taskId;
|
|
39
|
+
}
|
|
40
|
+
if (this.sessionId) {
|
|
41
|
+
headers["mcp-session-id"] = this.sessionId;
|
|
42
|
+
}
|
|
43
|
+
const controller = this.options.timeoutMs ? new AbortController : null;
|
|
44
|
+
const timeout = controller ? setTimeout(() => controller.abort(), this.options.timeoutMs) : null;
|
|
45
|
+
const url = this.useRawUrl ? this.baseUrl : `${this.baseUrl}/mcp`;
|
|
46
|
+
try {
|
|
47
|
+
const res = await fetch(url, {
|
|
48
|
+
method: "POST",
|
|
49
|
+
headers,
|
|
50
|
+
body: JSON.stringify(body),
|
|
51
|
+
signal: controller?.signal
|
|
52
|
+
});
|
|
53
|
+
if (!res.ok) {
|
|
54
|
+
throw new Error(`MCP request failed: ${res.status} ${res.statusText}`);
|
|
55
|
+
}
|
|
56
|
+
const sid = res.headers.get("mcp-session-id");
|
|
57
|
+
if (sid)
|
|
58
|
+
this.sessionId = sid;
|
|
59
|
+
const contentType = res.headers.get("content-type") || "";
|
|
60
|
+
if (contentType.includes("text/event-stream")) {
|
|
61
|
+
const text2 = await res.text();
|
|
62
|
+
const dataLines = text2.split(`
|
|
63
|
+
`).filter((line) => line.startsWith("data: ")).map((line) => line.slice(6));
|
|
64
|
+
const lastData = dataLines[dataLines.length - 1];
|
|
65
|
+
return { data: lastData ? JSON.parse(lastData) : null, headers: res.headers };
|
|
66
|
+
}
|
|
67
|
+
const text = await res.text();
|
|
68
|
+
const data = text.trim() ? JSON.parse(text) : null;
|
|
69
|
+
return { data, headers: res.headers };
|
|
70
|
+
} catch (err) {
|
|
71
|
+
if (err instanceof DOMException && err.name === "AbortError") {
|
|
72
|
+
throw new Error(`MCP request timed out after ${this.options.timeoutMs}ms`);
|
|
73
|
+
}
|
|
74
|
+
throw err;
|
|
75
|
+
} finally {
|
|
76
|
+
if (timeout)
|
|
77
|
+
clearTimeout(timeout);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async initialize() {
|
|
81
|
+
const { data } = await this.send({
|
|
82
|
+
jsonrpc: "2.0",
|
|
83
|
+
id: this.nextId++,
|
|
84
|
+
method: "initialize",
|
|
85
|
+
params: {
|
|
86
|
+
protocolVersion: this.options.protocolVersion ?? "2025-03-26",
|
|
87
|
+
capabilities: {},
|
|
88
|
+
clientInfo: this.options.clientInfo ?? {
|
|
89
|
+
name: "agent-swarm-pi-mono",
|
|
90
|
+
version: "1.0.0"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
if (!data || typeof data !== "object" || !("result" in data)) {
|
|
95
|
+
throw new Error(`MCP initialize failed: ${JSON.stringify(data)}`);
|
|
96
|
+
}
|
|
97
|
+
await this.send({
|
|
98
|
+
jsonrpc: "2.0",
|
|
99
|
+
method: "notifications/initialized"
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
async listTools() {
|
|
103
|
+
const { data } = await this.send({
|
|
104
|
+
jsonrpc: "2.0",
|
|
105
|
+
id: this.nextId++,
|
|
106
|
+
method: "tools/list",
|
|
107
|
+
params: {}
|
|
108
|
+
});
|
|
109
|
+
const result = data;
|
|
110
|
+
if (result?.error) {
|
|
111
|
+
throw new Error(`MCP tools/list failed: ${jsonRpcErrorMessage(result.error)}`);
|
|
112
|
+
}
|
|
113
|
+
return result?.result?.tools ?? [];
|
|
114
|
+
}
|
|
115
|
+
async callToolRaw(name, args) {
|
|
116
|
+
const { data } = await this.send({
|
|
117
|
+
jsonrpc: "2.0",
|
|
118
|
+
id: this.nextId++,
|
|
119
|
+
method: "tools/call",
|
|
120
|
+
params: { name, arguments: args }
|
|
121
|
+
});
|
|
122
|
+
const response = data;
|
|
123
|
+
if (response?.error)
|
|
124
|
+
return { ok: false, error: response.error };
|
|
125
|
+
return {
|
|
126
|
+
ok: true,
|
|
127
|
+
result: response?.result ?? { content: [{ type: "text", text: "No result" }] }
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
async callTool(name, args) {
|
|
131
|
+
const envelope = await this.callToolRaw(name, args);
|
|
132
|
+
return envelope.ok ? envelope.result : { content: [{ type: "text", text: "No result" }] };
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export { McpHttpClient };
|
|
@@ -294,4 +294,4 @@ function buildTreeBlocks(roots) {
|
|
|
294
294
|
return blocks;
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
export { getTaskLink, markdownToSlack, formatAttachmentsBlockForSlack, formatDuration, buildCompletedBlocks, buildCompletedBlockBatches, buildFailedBlocks, buildProgressBlocks, buildCancelledBlocks, buildBufferFlushBlocks, buildTreeBlocks };
|
|
297
|
+
export { getTaskLink, markdownToSlack, splitSlackSectionText, formatAttachmentsBlockForSlack, formatDuration, buildCompletedBlocks, buildCompletedBlockBatches, buildFailedBlocks, buildProgressBlocks, buildCancelledBlocks, buildBufferFlushBlocks, buildTreeBlocks };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fetchInstalledMcpServers
|
|
3
|
+
} from "./cli-tng3131n.js";
|
|
1
4
|
import {
|
|
2
5
|
SessionErrorTracker,
|
|
3
6
|
buildOtelTraceparentEnv,
|
|
@@ -5,9 +8,6 @@ import {
|
|
|
5
8
|
parseStderrForErrors,
|
|
6
9
|
trackErrorFromJson
|
|
7
10
|
} from "./cli-psrqtw2m.js";
|
|
8
|
-
import {
|
|
9
|
-
fetchInstalledMcpServers
|
|
10
|
-
} from "./cli-tng3131n.js";
|
|
11
11
|
import {
|
|
12
12
|
CTX_MODE_NUDGE_EVERY
|
|
13
13
|
} from "./cli-zm7njwzd.js";
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
} from "./cli-tghre7g6.js";
|
|
20
20
|
import {
|
|
21
21
|
applyReasoningEffort
|
|
22
|
-
} from "./cli-
|
|
22
|
+
} from "./cli-e61fs2hp.js";
|
|
23
23
|
import {
|
|
24
24
|
init_credentials,
|
|
25
25
|
validateClaudeCredentials
|
|
@@ -14,8 +14,10 @@ import {
|
|
|
14
14
|
buildTreeBlocks,
|
|
15
15
|
formatAttachmentsBlockForSlack,
|
|
16
16
|
formatDuration,
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
getTaskLink,
|
|
18
|
+
markdownToSlack,
|
|
19
|
+
splitSlackSectionText
|
|
20
|
+
} from "./cli-ma04faw5.js";
|
|
19
21
|
import {
|
|
20
22
|
getAgentById,
|
|
21
23
|
getChildTasks,
|
|
@@ -25,7 +27,7 @@ import {
|
|
|
25
27
|
getTaskById,
|
|
26
28
|
init_db,
|
|
27
29
|
setSlackMessageTracking
|
|
28
|
-
} from "./cli-
|
|
30
|
+
} from "./cli-15y7qhzp.js";
|
|
29
31
|
import {
|
|
30
32
|
require_receiver,
|
|
31
33
|
require_sender,
|
|
@@ -54212,9 +54214,89 @@ function classifySlackUpdateError(error) {
|
|
|
54212
54214
|
return "failed";
|
|
54213
54215
|
}
|
|
54214
54216
|
var isDev = process.env.ENV === "development";
|
|
54217
|
+
var MIN_INLINE_OUTPUT_LENGTH = 20;
|
|
54218
|
+
var MAX_INLINE_OUTPUT_MESSAGE_LENGTH = 4000;
|
|
54219
|
+
var INLINE_OUTPUT_FALLBACKS = new Set([
|
|
54220
|
+
"done",
|
|
54221
|
+
"completed",
|
|
54222
|
+
"complete",
|
|
54223
|
+
"task completed",
|
|
54224
|
+
"process completed successfully",
|
|
54225
|
+
"process completed successfully (no output captured)"
|
|
54226
|
+
]);
|
|
54215
54227
|
function getAgentDisplayName(agent) {
|
|
54216
54228
|
return isDev ? `(dev) ${agent.name}` : agent.name;
|
|
54217
54229
|
}
|
|
54230
|
+
function shouldPostInlineCompletionOutput(task, attachments) {
|
|
54231
|
+
if (task.status !== "completed")
|
|
54232
|
+
return false;
|
|
54233
|
+
if (!task.slackChannelId || !task.slackThreadTs)
|
|
54234
|
+
return false;
|
|
54235
|
+
if (task.slackReplySent)
|
|
54236
|
+
return false;
|
|
54237
|
+
const output = task.output?.trim();
|
|
54238
|
+
if (!output || output.length < MIN_INLINE_OUTPUT_LENGTH)
|
|
54239
|
+
return false;
|
|
54240
|
+
if (INLINE_OUTPUT_FALLBACKS.has(output.toLowerCase()))
|
|
54241
|
+
return false;
|
|
54242
|
+
return !attachments.some((attachment) => attachment.isPrimary);
|
|
54243
|
+
}
|
|
54244
|
+
function formatInlineCompletionOutputText(opts) {
|
|
54245
|
+
const header = `✅ *${opts.agentName}* completed with output (${getTaskLink(opts.taskId)}):
|
|
54246
|
+
|
|
54247
|
+
`;
|
|
54248
|
+
const tail = `
|
|
54249
|
+
|
|
54250
|
+
…(full output in task ${getTaskLink(opts.taskId)})`;
|
|
54251
|
+
const slackOutput = markdownToSlack(opts.output.trim());
|
|
54252
|
+
const maxBodyLength = MAX_INLINE_OUTPUT_MESSAGE_LENGTH - header.length;
|
|
54253
|
+
if (slackOutput.length <= maxBodyLength) {
|
|
54254
|
+
return header + slackOutput;
|
|
54255
|
+
}
|
|
54256
|
+
const maxTruncatedBodyLength = Math.max(0, maxBodyLength - tail.length);
|
|
54257
|
+
let cut = slackOutput.lastIndexOf(`
|
|
54258
|
+
`, maxTruncatedBodyLength);
|
|
54259
|
+
if (cut < maxTruncatedBodyLength / 2) {
|
|
54260
|
+
cut = slackOutput.lastIndexOf(" ", maxTruncatedBodyLength);
|
|
54261
|
+
}
|
|
54262
|
+
if (cut < maxTruncatedBodyLength / 2) {
|
|
54263
|
+
cut = maxTruncatedBodyLength;
|
|
54264
|
+
}
|
|
54265
|
+
return header + slackOutput.slice(0, cut).trimEnd() + tail;
|
|
54266
|
+
}
|
|
54267
|
+
async function sendInlineTaskOutput(task) {
|
|
54268
|
+
const app = getSlackApp();
|
|
54269
|
+
if (!app || !task.slackChannelId || !task.slackThreadTs || !task.agentId || !task.output) {
|
|
54270
|
+
return false;
|
|
54271
|
+
}
|
|
54272
|
+
const agent = getAgentById(task.agentId);
|
|
54273
|
+
if (!agent) {
|
|
54274
|
+
console.error(`[Slack] Agent not found for task ${task.id}`);
|
|
54275
|
+
return false;
|
|
54276
|
+
}
|
|
54277
|
+
const text = formatInlineCompletionOutputText({
|
|
54278
|
+
agentName: agent.name,
|
|
54279
|
+
taskId: task.id,
|
|
54280
|
+
output: task.output
|
|
54281
|
+
});
|
|
54282
|
+
try {
|
|
54283
|
+
await sendWithPersona(app.client, {
|
|
54284
|
+
channel: task.slackChannelId,
|
|
54285
|
+
thread_ts: task.slackThreadTs,
|
|
54286
|
+
text,
|
|
54287
|
+
username: getAgentDisplayName(agent),
|
|
54288
|
+
icon_emoji: getAgentEmoji(agent),
|
|
54289
|
+
blocks: splitSlackSectionText(text).map((chunk) => ({
|
|
54290
|
+
type: "section",
|
|
54291
|
+
text: { type: "mrkdwn", text: chunk }
|
|
54292
|
+
}))
|
|
54293
|
+
});
|
|
54294
|
+
return true;
|
|
54295
|
+
} catch (error) {
|
|
54296
|
+
console.error(`[Slack] Failed to send inline output for task ${task.id}:`, error);
|
|
54297
|
+
return false;
|
|
54298
|
+
}
|
|
54299
|
+
}
|
|
54218
54300
|
async function sendTaskResponse(task) {
|
|
54219
54301
|
const app = getSlackApp();
|
|
54220
54302
|
if (!app || !task.slackChannelId || !task.slackThreadTs) {
|
|
@@ -54904,7 +54986,8 @@ function startTaskWatcher(intervalMs = 3000) {
|
|
|
54904
54986
|
if (lastSent && now2 - lastSent < MIN_SEND_INTERVAL)
|
|
54905
54987
|
continue;
|
|
54906
54988
|
if (taskToTree.has(task.id)) {
|
|
54907
|
-
|
|
54989
|
+
const attachments = task.status === "completed" ? getTaskAttachments(task.id) : [];
|
|
54990
|
+
if (!shouldPostInlineCompletionOutput(task, attachments)) {
|
|
54908
54991
|
notifiedCompletions.set(task.id, now2);
|
|
54909
54992
|
continue;
|
|
54910
54993
|
}
|
|
@@ -54912,8 +54995,10 @@ function startTaskWatcher(intervalMs = 3000) {
|
|
|
54912
54995
|
notifiedCompletions.set(task.id, now2);
|
|
54913
54996
|
lastSendTime.set(completionKey, now2);
|
|
54914
54997
|
try {
|
|
54915
|
-
await
|
|
54916
|
-
|
|
54998
|
+
const sent = await sendInlineTaskOutput(task);
|
|
54999
|
+
if (!sent)
|
|
55000
|
+
throw new Error("sendInlineTaskOutput returned false");
|
|
55001
|
+
console.log(`[Slack] Sent inline output for tree-tracked completion ${task.id.slice(0, 8)}`);
|
|
54917
55002
|
} catch (error) {
|
|
54918
55003
|
notifiedCompletions.delete(task.id);
|
|
54919
55004
|
lastSendTime.delete(completionKey);
|
|
@@ -54988,13 +55073,13 @@ async function initSlackApp() {
|
|
|
54988
55073
|
socketMode: true,
|
|
54989
55074
|
logLevel: import_bolt.LogLevel.DEBUG
|
|
54990
55075
|
});
|
|
54991
|
-
const { registerMessageHandler } = await import("./handlers-
|
|
54992
|
-
const { registerCommandHandler } = await import("./commands-
|
|
54993
|
-
const { registerActionHandlers } = await import("./actions-
|
|
55076
|
+
const { registerMessageHandler } = await import("./handlers-9er4zx9q.js");
|
|
55077
|
+
const { registerCommandHandler } = await import("./commands-hch4e2k1.js");
|
|
55078
|
+
const { registerActionHandlers } = await import("./actions-17ya5wde.js");
|
|
54994
55079
|
registerMessageHandler(app);
|
|
54995
55080
|
registerCommandHandler(app);
|
|
54996
55081
|
registerActionHandlers(app);
|
|
54997
|
-
const { createAssistant } = await import("./assistant-
|
|
55082
|
+
const { createAssistant } = await import("./assistant-ah7csnjz.js");
|
|
54998
55083
|
app.assistant(createAssistant());
|
|
54999
55084
|
return app;
|
|
55000
55085
|
}
|
|
@@ -6,14 +6,23 @@ import {
|
|
|
6
6
|
DEFAULT_CREDENTIAL_BINDINGS,
|
|
7
7
|
SwarmConfigCredentialBindingStore,
|
|
8
8
|
getScript,
|
|
9
|
+
getScriptApiConnectionDescriptors,
|
|
10
|
+
getScriptMcpConnectionDescriptors,
|
|
9
11
|
getScriptVersion,
|
|
10
12
|
listRelationalCredentialBindings,
|
|
11
13
|
validateScriptImports
|
|
12
|
-
} from "./cli-
|
|
14
|
+
} from "./cli-r9f6ngrf.js";
|
|
15
|
+
import {
|
|
16
|
+
ensureTokenOrThrow,
|
|
17
|
+
getOAuthApp,
|
|
18
|
+
getOAuthTokens,
|
|
19
|
+
isTokenExpiringSoon,
|
|
20
|
+
oauthAppRowToProviderConfig
|
|
21
|
+
} from "./cli-t0vqevnm.js";
|
|
13
22
|
import {
|
|
14
23
|
withSiblingAwareness,
|
|
15
24
|
workflowContextKey
|
|
16
|
-
} from "./cli-
|
|
25
|
+
} from "./cli-k3y4z3h5.js";
|
|
17
26
|
import {
|
|
18
27
|
getAppUrl
|
|
19
28
|
} from "./cli-dh55d5fg.js";
|
|
@@ -62,13 +71,13 @@ import {
|
|
|
62
71
|
telemetry,
|
|
63
72
|
updateWorkflowRun,
|
|
64
73
|
updateWorkflowRunStep
|
|
65
|
-
} from "./cli-
|
|
74
|
+
} from "./cli-15y7qhzp.js";
|
|
66
75
|
import {
|
|
67
76
|
init_zod
|
|
68
|
-
} from "./cli-
|
|
77
|
+
} from "./cli-bw80ck94.js";
|
|
69
78
|
import {
|
|
70
79
|
exports_external
|
|
71
|
-
} from "./cli-
|
|
80
|
+
} from "./cli-xz9aq0rf.js";
|
|
72
81
|
import {
|
|
73
82
|
init_secret_scrubber,
|
|
74
83
|
isSensitiveKey,
|
|
@@ -2083,6 +2092,51 @@ function resolveHmacSecret(raw) {
|
|
|
2083
2092
|
}
|
|
2084
2093
|
return raw;
|
|
2085
2094
|
}
|
|
2095
|
+
function verifyWebhookRequest(trigger, rawBody, headers) {
|
|
2096
|
+
if (!trigger.hmacSecret) {
|
|
2097
|
+
if (trigger.verification) {
|
|
2098
|
+
throw new WebhookError("Webhook trigger has `verification` configured but no `hmacSecret`; refusing to accept unverified requests", 500);
|
|
2099
|
+
}
|
|
2100
|
+
return;
|
|
2101
|
+
}
|
|
2102
|
+
const secret = resolveHmacSecret(trigger.hmacSecret);
|
|
2103
|
+
const verification = trigger.verification;
|
|
2104
|
+
if (!verification) {
|
|
2105
|
+
const hmacHeader = trigger.hmacHeader || DEFAULT_HMAC_HEADER;
|
|
2106
|
+
const signature2 = resolveSignature(headers, hmacHeader);
|
|
2107
|
+
if (!signature2) {
|
|
2108
|
+
throw new WebhookError("Missing signature", 401);
|
|
2109
|
+
}
|
|
2110
|
+
if (!verifyHmacSignature(secret, rawBody, signature2)) {
|
|
2111
|
+
throw new WebhookError("Invalid signature", 401);
|
|
2112
|
+
}
|
|
2113
|
+
return;
|
|
2114
|
+
}
|
|
2115
|
+
const header = verification.header || DEFAULT_HMAC_HEADER;
|
|
2116
|
+
const signature = getHeader(headers, header);
|
|
2117
|
+
if (!signature) {
|
|
2118
|
+
throw new WebhookError("Missing signature", 401);
|
|
2119
|
+
}
|
|
2120
|
+
let isValid = false;
|
|
2121
|
+
switch (verification.format) {
|
|
2122
|
+
case "hmac-sha256":
|
|
2123
|
+
isValid = verifyHmacSignature(secret, rawBody, signature);
|
|
2124
|
+
break;
|
|
2125
|
+
case "timestamped-hmac-sha256":
|
|
2126
|
+
isValid = verifyTimestampedHmacSignature(secret, rawBody, signature, {
|
|
2127
|
+
timestampKey: verification.timestampKey,
|
|
2128
|
+
signatureKey: verification.signatureKey,
|
|
2129
|
+
toleranceSeconds: verification.toleranceSeconds
|
|
2130
|
+
});
|
|
2131
|
+
break;
|
|
2132
|
+
case "token-equality":
|
|
2133
|
+
isValid = verifyTokenEquality(secret, signature);
|
|
2134
|
+
break;
|
|
2135
|
+
}
|
|
2136
|
+
if (!isValid) {
|
|
2137
|
+
throw new WebhookError("Invalid signature", 401);
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2086
2140
|
async function handleWebhookTrigger(workflowId, payload, headers, registry) {
|
|
2087
2141
|
const workflow = getWorkflow(workflowId);
|
|
2088
2142
|
if (!workflow) {
|
|
@@ -2092,17 +2146,8 @@ async function handleWebhookTrigger(workflowId, payload, headers, registry) {
|
|
|
2092
2146
|
throw new WebhookError("Workflow is disabled", 400);
|
|
2093
2147
|
}
|
|
2094
2148
|
const webhookTrigger = workflow.triggers.find((t) => t.type === "webhook");
|
|
2095
|
-
if (webhookTrigger && webhookTrigger.type === "webhook" && webhookTrigger.hmacSecret) {
|
|
2096
|
-
|
|
2097
|
-
const signature = resolveSignature(headers, hmacHeader);
|
|
2098
|
-
if (!signature) {
|
|
2099
|
-
throw new WebhookError("Missing signature", 401);
|
|
2100
|
-
}
|
|
2101
|
-
const secret = resolveHmacSecret(webhookTrigger.hmacSecret);
|
|
2102
|
-
const isValid = verifyHmacSignature(secret, typeof payload === "string" ? payload : JSON.stringify(payload), signature);
|
|
2103
|
-
if (!isValid) {
|
|
2104
|
-
throw new WebhookError("Invalid signature", 401);
|
|
2105
|
-
}
|
|
2149
|
+
if (webhookTrigger && webhookTrigger.type === "webhook" && (webhookTrigger.hmacSecret || webhookTrigger.verification)) {
|
|
2150
|
+
verifyWebhookRequest(webhookTrigger, typeof payload === "string" ? payload : JSON.stringify(payload), headers);
|
|
2106
2151
|
}
|
|
2107
2152
|
const triggerData = parseTriggerPayload(payload);
|
|
2108
2153
|
const runId = await startWorkflowExecution(workflow, triggerData, registry, {
|
|
@@ -2149,6 +2194,57 @@ function verifyHmacSignature(secret, body, providedSignature) {
|
|
|
2149
2194
|
return false;
|
|
2150
2195
|
}
|
|
2151
2196
|
}
|
|
2197
|
+
function verifyTimestampedHmacSignature(secret, body, headerValue, opts = {}, nowMs = Date.now()) {
|
|
2198
|
+
const timestampKey = opts.timestampKey ?? "t";
|
|
2199
|
+
const signatureKey = opts.signatureKey ?? "v1";
|
|
2200
|
+
const toleranceSeconds = opts.toleranceSeconds ?? 300;
|
|
2201
|
+
const parsed = parseSignatureHeader(headerValue);
|
|
2202
|
+
const timestampValue = parsed.get(timestampKey)?.[0];
|
|
2203
|
+
const signatures = parsed.get(signatureKey) ?? [];
|
|
2204
|
+
if (!timestampValue || signatures.length === 0 || !/^\d+$/.test(timestampValue)) {
|
|
2205
|
+
return false;
|
|
2206
|
+
}
|
|
2207
|
+
const timestampSeconds = Number(timestampValue);
|
|
2208
|
+
if (!Number.isSafeInteger(timestampSeconds)) {
|
|
2209
|
+
return false;
|
|
2210
|
+
}
|
|
2211
|
+
const ageSeconds = Math.abs(nowMs / 1000 - timestampSeconds);
|
|
2212
|
+
if (ageSeconds > toleranceSeconds) {
|
|
2213
|
+
return false;
|
|
2214
|
+
}
|
|
2215
|
+
const hmac = crypto2.createHmac("sha256", secret);
|
|
2216
|
+
hmac.update(`${timestampValue}.${body}`);
|
|
2217
|
+
const expectedHex = hmac.digest("hex");
|
|
2218
|
+
const expected = Buffer.from(expectedHex, "hex");
|
|
2219
|
+
return signatures.some((signature) => timingSafeEqualHex(signature, expected));
|
|
2220
|
+
}
|
|
2221
|
+
function verifyTokenEquality(secret, providedToken) {
|
|
2222
|
+
const secretDigest = crypto2.createHash("sha256").update(secret).digest();
|
|
2223
|
+
const providedDigest = crypto2.createHash("sha256").update(providedToken).digest();
|
|
2224
|
+
return crypto2.timingSafeEqual(providedDigest, secretDigest);
|
|
2225
|
+
}
|
|
2226
|
+
function parseSignatureHeader(headerValue) {
|
|
2227
|
+
const parsed = new Map;
|
|
2228
|
+
for (const part of headerValue.split(",")) {
|
|
2229
|
+
const trimmed = part.trim();
|
|
2230
|
+
const separatorIndex = trimmed.indexOf("=");
|
|
2231
|
+
if (separatorIndex <= 0)
|
|
2232
|
+
continue;
|
|
2233
|
+
const key = trimmed.slice(0, separatorIndex).trim();
|
|
2234
|
+
const value = trimmed.slice(separatorIndex + 1).trim();
|
|
2235
|
+
const values = parsed.get(key) ?? [];
|
|
2236
|
+
values.push(value);
|
|
2237
|
+
parsed.set(key, values);
|
|
2238
|
+
}
|
|
2239
|
+
return parsed;
|
|
2240
|
+
}
|
|
2241
|
+
function timingSafeEqualHex(providedHex, expected) {
|
|
2242
|
+
try {
|
|
2243
|
+
return crypto2.timingSafeEqual(Buffer.from(providedHex, "hex"), expected);
|
|
2244
|
+
} catch {
|
|
2245
|
+
return false;
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2152
2248
|
|
|
2153
2249
|
class WebhookError extends Error {
|
|
2154
2250
|
statusCode;
|
|
@@ -2487,7 +2583,8 @@ class HumanInTheLoopExecutor extends BaseExecutor {
|
|
|
2487
2583
|
workflowRunId: meta.runId,
|
|
2488
2584
|
workflowRunStepId: meta.stepId,
|
|
2489
2585
|
timeoutSeconds: config.timeout?.seconds,
|
|
2490
|
-
notificationChannels: config.notifications
|
|
2586
|
+
notificationChannels: config.notifications,
|
|
2587
|
+
createdBy: meta.requestedByUserId
|
|
2491
2588
|
});
|
|
2492
2589
|
if (config.notifications?.length) {
|
|
2493
2590
|
this.dispatchNotifications(requestId, config, db).catch((err) => {
|
|
@@ -2515,7 +2612,7 @@ class HumanInTheLoopExecutor extends BaseExecutor {
|
|
|
2515
2612
|
}
|
|
2516
2613
|
if (notification.channel === "slack") {
|
|
2517
2614
|
try {
|
|
2518
|
-
const { getSlackApp } = await import("./app-
|
|
2615
|
+
const { getSlackApp } = await import("./app-4f718yk0.js");
|
|
2519
2616
|
const slackApp = getSlackApp();
|
|
2520
2617
|
if (!slackApp) {
|
|
2521
2618
|
console.warn("[HITL] Slack not initialized — cannot send notification");
|
|
@@ -2629,7 +2726,7 @@ class NotifyExecutor extends BaseExecutor {
|
|
|
2629
2726
|
}
|
|
2630
2727
|
}
|
|
2631
2728
|
case "slack": {
|
|
2632
|
-
const { getSlackApp } = await import("./app-
|
|
2729
|
+
const { getSlackApp } = await import("./app-4f718yk0.js");
|
|
2633
2730
|
const app = getSlackApp();
|
|
2634
2731
|
if (!app) {
|
|
2635
2732
|
return {
|
|
@@ -2752,14 +2849,14 @@ var RawLlmOutputSchema = exports_external.object({
|
|
|
2752
2849
|
async function executeRawLlm(config) {
|
|
2753
2850
|
const modelName = config.model ?? "google/gemini-3-flash-preview";
|
|
2754
2851
|
try {
|
|
2755
|
-
const { createOpenAI } = await import("./index-
|
|
2852
|
+
const { createOpenAI } = await import("./index-2dgfj9av.js");
|
|
2756
2853
|
const openrouter = createOpenAI({
|
|
2757
2854
|
baseURL: "https://openrouter.ai/api/v1",
|
|
2758
2855
|
apiKey: process.env.OPENROUTER_API_KEY
|
|
2759
2856
|
});
|
|
2760
2857
|
const model = openrouter(modelName);
|
|
2761
2858
|
if (config.schema) {
|
|
2762
|
-
const { generateObject, jsonSchema } = await import("./index-
|
|
2859
|
+
const { generateObject, jsonSchema } = await import("./index-t2snazez.js");
|
|
2763
2860
|
const { object } = await generateObject({
|
|
2764
2861
|
model,
|
|
2765
2862
|
schema: jsonSchema(config.schema),
|
|
@@ -2773,7 +2870,7 @@ async function executeRawLlm(config) {
|
|
|
2773
2870
|
output: { result: object, model: modelName }
|
|
2774
2871
|
};
|
|
2775
2872
|
}
|
|
2776
|
-
const { generateText } = await import("./index-
|
|
2873
|
+
const { generateText } = await import("./index-t2snazez.js");
|
|
2777
2874
|
const { text } = await generateText({
|
|
2778
2875
|
model,
|
|
2779
2876
|
prompt: config.prompt
|
|
@@ -2926,6 +3023,33 @@ init_zod();
|
|
|
2926
3023
|
// src/be/script-credential-broker.ts
|
|
2927
3024
|
init_secret_scrubber();
|
|
2928
3025
|
init_db();
|
|
3026
|
+
|
|
3027
|
+
// src/be/oauth-credential-bindings.ts
|
|
3028
|
+
var OAUTH_BINDING_REFRESH_BUFFER_MS = 5 * 60 * 1000;
|
|
3029
|
+
function getOAuthProviderConfig(provider) {
|
|
3030
|
+
const app = getOAuthApp(provider);
|
|
3031
|
+
return app ? oauthAppRowToProviderConfig(app) : null;
|
|
3032
|
+
}
|
|
3033
|
+
function getOAuthBindingTokenStatus(provider) {
|
|
3034
|
+
if (!getOAuthApp(provider))
|
|
3035
|
+
return "missing";
|
|
3036
|
+
if (!getOAuthTokens(provider))
|
|
3037
|
+
return "missing";
|
|
3038
|
+
return isTokenExpiringSoon(provider, OAUTH_BINDING_REFRESH_BUFFER_MS) ? "expiring" : "ok";
|
|
3039
|
+
}
|
|
3040
|
+
async function resolveOAuthBindingToken(provider) {
|
|
3041
|
+
if (!getOAuthApp(provider))
|
|
3042
|
+
return;
|
|
3043
|
+
const initialTokens = getOAuthTokens(provider);
|
|
3044
|
+
if (!initialTokens)
|
|
3045
|
+
return;
|
|
3046
|
+
if (isTokenExpiringSoon(provider, OAUTH_BINDING_REFRESH_BUFFER_MS)) {
|
|
3047
|
+
await ensureTokenOrThrow(provider, OAUTH_BINDING_REFRESH_BUFFER_MS);
|
|
3048
|
+
}
|
|
3049
|
+
return getOAuthTokens(provider)?.accessToken;
|
|
3050
|
+
}
|
|
3051
|
+
|
|
3052
|
+
// src/be/script-credential-broker.ts
|
|
2929
3053
|
class RelationalCredentialBindingStore extends SwarmConfigCredentialBindingStore {
|
|
2930
3054
|
listActiveBindings(context) {
|
|
2931
3055
|
const relational = listRelationalCredentialBindings(context);
|
|
@@ -2934,9 +3058,29 @@ class RelationalCredentialBindingStore extends SwarmConfigCredentialBindingStore
|
|
|
2934
3058
|
return super.listActiveBindings(context);
|
|
2935
3059
|
}
|
|
2936
3060
|
}
|
|
2937
|
-
function buildScriptCredentialBindings(input) {
|
|
3061
|
+
async function buildScriptCredentialBindings(input) {
|
|
2938
3062
|
const resolvedConfigs = getResolvedConfig(input.agentId, input.repoId);
|
|
2939
3063
|
const configMap = new Map(resolvedConfigs.map((config) => [config.key, config.value]));
|
|
3064
|
+
const relationalBindings = listRelationalCredentialBindings(input);
|
|
3065
|
+
for (const binding of relationalBindings) {
|
|
3066
|
+
if (binding.authKind !== "oauth")
|
|
3067
|
+
continue;
|
|
3068
|
+
configMap.set(binding.configKey, "");
|
|
3069
|
+
if (!binding.oauthProvider)
|
|
3070
|
+
continue;
|
|
3071
|
+
let accessToken;
|
|
3072
|
+
try {
|
|
3073
|
+
accessToken = await resolveOAuthBindingToken(binding.oauthProvider);
|
|
3074
|
+
} catch (err) {
|
|
3075
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
3076
|
+
console.warn(`[script-credential-broker] skipping OAuth binding ${binding.configKey}: token refresh for provider ${binding.oauthProvider} failed: ${scrubSecrets(message)}`);
|
|
3077
|
+
continue;
|
|
3078
|
+
}
|
|
3079
|
+
if (!accessToken)
|
|
3080
|
+
continue;
|
|
3081
|
+
configMap.set(binding.configKey, accessToken);
|
|
3082
|
+
registerVolatileSecret(accessToken, binding.configKey);
|
|
3083
|
+
}
|
|
2940
3084
|
const broker = new CredentialBroker(new RelationalCredentialBindingStore((filters) => getSwarmConfigs(filters)), (configKey) => configMap.get(configKey) ?? process.env[configKey], DEFAULT_CREDENTIAL_BINDINGS);
|
|
2941
3085
|
const bindings = broker.resolveBindings({ agentId: input.agentId, repoId: input.repoId });
|
|
2942
3086
|
for (const binding of bindings) {
|
|
@@ -3211,7 +3355,8 @@ function buildConfigPayload(input) {
|
|
|
3211
3355
|
},
|
|
3212
3356
|
user: input.userConfig ?? {},
|
|
3213
3357
|
egressSecrets: input.egressSecrets ?? buildEgressSecrets(),
|
|
3214
|
-
apiConnections: input.apiConnections ?? []
|
|
3358
|
+
apiConnections: input.apiConnections ?? [],
|
|
3359
|
+
mcpConnections: input.mcpConnections ?? []
|
|
3215
3360
|
};
|
|
3216
3361
|
}
|
|
3217
3362
|
async function runScript(input) {
|
|
@@ -3307,7 +3452,9 @@ class SwarmScriptExecutor extends BaseExecutor {
|
|
|
3307
3452
|
args: config.args,
|
|
3308
3453
|
fsMode: "none",
|
|
3309
3454
|
agentId: agentId ?? "workflow",
|
|
3310
|
-
egressSecrets: buildScriptCredentialBindings({ agentId: agentId ?? undefined }),
|
|
3455
|
+
egressSecrets: await buildScriptCredentialBindings({ agentId: agentId ?? undefined }),
|
|
3456
|
+
apiConnections: getScriptApiConnectionDescriptors({ agentId: agentId ?? undefined }),
|
|
3457
|
+
mcpConnections: getScriptMcpConnectionDescriptors({ agentId: agentId ?? undefined }),
|
|
3311
3458
|
timeoutMs: config.timeoutMs
|
|
3312
3459
|
});
|
|
3313
3460
|
const workflowOutput = {
|
|
@@ -3462,8 +3609,8 @@ class ValidateExecutor extends BaseExecutor {
|
|
|
3462
3609
|
const interpolatedPrompt = this.deps.interpolate(prompt, context);
|
|
3463
3610
|
const outputStr = typeof targetOutput === "string" ? targetOutput : JSON.stringify(targetOutput);
|
|
3464
3611
|
try {
|
|
3465
|
-
const { createOpenAI } = await import("./index-
|
|
3466
|
-
const { generateObject, jsonSchema } = await import("./index-
|
|
3612
|
+
const { createOpenAI } = await import("./index-2dgfj9av.js");
|
|
3613
|
+
const { generateObject, jsonSchema } = await import("./index-t2snazez.js");
|
|
3467
3614
|
const openrouter = createOpenAI({
|
|
3468
3615
|
baseURL: "https://openrouter.ai/api/v1",
|
|
3469
3616
|
apiKey: process.env.OPENROUTER_API_KEY
|
|
@@ -3665,4 +3812,4 @@ function initWorkflows() {
|
|
|
3665
3812
|
initWaitBusSubscriptions(_registry);
|
|
3666
3813
|
}
|
|
3667
3814
|
|
|
3668
|
-
export { buildScriptCredentialBindings, runScript, generateEdges, findEntryNodes, getSuccessors, validateDefinition, applyDefinitionPatch, validateJsonSchema, TriggerSchemaError, startWorkflowExecution, setupWorkflowResumeListener, retryFailedRun, cancelWorkflowRun, resumeWaitState, initWaitBusSubscriptions, subscribeWaitToBus, recoverIncompleteRuns, startRetryPoller, stopRetryPoller, validateTemplateVariables, instantiateTemplate, handleWebhookTrigger, handleScheduleTrigger, verifyHmacSignature, WebhookError, snapshotWorkflow, startWaitPoller, stopWaitPoller, RawLlmConfigSchema, executeRawLlm, getExecutorRegistry, initWorkflows };
|
|
3815
|
+
export { getOAuthProviderConfig, getOAuthBindingTokenStatus, buildScriptCredentialBindings, runScript, generateEdges, findEntryNodes, getSuccessors, validateDefinition, applyDefinitionPatch, validateJsonSchema, TriggerSchemaError, startWorkflowExecution, setupWorkflowResumeListener, retryFailedRun, cancelWorkflowRun, resumeWaitState, initWaitBusSubscriptions, subscribeWaitToBus, recoverIncompleteRuns, startRetryPoller, stopRetryPoller, validateTemplateVariables, instantiateTemplate, handleWebhookTrigger, handleScheduleTrigger, verifyHmacSignature, WebhookError, snapshotWorkflow, startWaitPoller, stopWaitPoller, RawLlmConfigSchema, executeRawLlm, getExecutorRegistry, initWorkflows };
|