@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,429 @@
|
|
|
1
|
+
// node_modules/oauth4webapi/build/index.js
|
|
2
|
+
var USER_AGENT;
|
|
3
|
+
if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) {
|
|
4
|
+
const NAME = "oauth4webapi";
|
|
5
|
+
const VERSION = "v3.8.5";
|
|
6
|
+
USER_AGENT = `${NAME}/${VERSION}`;
|
|
7
|
+
}
|
|
8
|
+
var ERR_INVALID_ARG_VALUE = "ERR_INVALID_ARG_VALUE";
|
|
9
|
+
var ERR_INVALID_ARG_TYPE = "ERR_INVALID_ARG_TYPE";
|
|
10
|
+
function CodedTypeError(message, code, cause) {
|
|
11
|
+
const err = new TypeError(message, { cause });
|
|
12
|
+
Object.assign(err, { code });
|
|
13
|
+
return err;
|
|
14
|
+
}
|
|
15
|
+
var allowInsecureRequests = Symbol();
|
|
16
|
+
var clockSkew = Symbol();
|
|
17
|
+
var clockTolerance = Symbol();
|
|
18
|
+
var customFetch = Symbol();
|
|
19
|
+
var modifyAssertion = Symbol();
|
|
20
|
+
var jweDecrypt = Symbol();
|
|
21
|
+
var jwksCache = Symbol();
|
|
22
|
+
var encoder = new TextEncoder;
|
|
23
|
+
var decoder = new TextDecoder;
|
|
24
|
+
function buf(input) {
|
|
25
|
+
if (typeof input === "string") {
|
|
26
|
+
return encoder.encode(input);
|
|
27
|
+
}
|
|
28
|
+
return decoder.decode(input);
|
|
29
|
+
}
|
|
30
|
+
var encodeBase64Url;
|
|
31
|
+
if (Uint8Array.prototype.toBase64) {
|
|
32
|
+
encodeBase64Url = (input) => {
|
|
33
|
+
if (input instanceof ArrayBuffer) {
|
|
34
|
+
input = new Uint8Array(input);
|
|
35
|
+
}
|
|
36
|
+
return input.toBase64({ alphabet: "base64url", omitPadding: true });
|
|
37
|
+
};
|
|
38
|
+
} else {
|
|
39
|
+
const CHUNK_SIZE = 32768;
|
|
40
|
+
encodeBase64Url = (input) => {
|
|
41
|
+
if (input instanceof ArrayBuffer) {
|
|
42
|
+
input = new Uint8Array(input);
|
|
43
|
+
}
|
|
44
|
+
const arr = [];
|
|
45
|
+
for (let i = 0;i < input.byteLength; i += CHUNK_SIZE) {
|
|
46
|
+
arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));
|
|
47
|
+
}
|
|
48
|
+
return btoa(arr.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
var decodeBase64Url;
|
|
52
|
+
if (Uint8Array.fromBase64) {
|
|
53
|
+
decodeBase64Url = (input) => {
|
|
54
|
+
try {
|
|
55
|
+
return Uint8Array.fromBase64(input, { alphabet: "base64url" });
|
|
56
|
+
} catch (cause) {
|
|
57
|
+
throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
} else {
|
|
61
|
+
decodeBase64Url = (input) => {
|
|
62
|
+
try {
|
|
63
|
+
const binary = atob(input.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, ""));
|
|
64
|
+
const bytes = new Uint8Array(binary.length);
|
|
65
|
+
for (let i = 0;i < binary.length; i++) {
|
|
66
|
+
bytes[i] = binary.charCodeAt(i);
|
|
67
|
+
}
|
|
68
|
+
return bytes;
|
|
69
|
+
} catch (cause) {
|
|
70
|
+
throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function b64u(input) {
|
|
75
|
+
if (typeof input === "string") {
|
|
76
|
+
return decodeBase64Url(input);
|
|
77
|
+
}
|
|
78
|
+
return encodeBase64Url(input);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
class UnsupportedOperationError extends Error {
|
|
82
|
+
code;
|
|
83
|
+
constructor(message, options) {
|
|
84
|
+
super(message, options);
|
|
85
|
+
this.name = this.constructor.name;
|
|
86
|
+
this.code = UNSUPPORTED_OPERATION;
|
|
87
|
+
Error.captureStackTrace?.(this, this.constructor);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
class OperationProcessingError extends Error {
|
|
92
|
+
code;
|
|
93
|
+
constructor(message, options) {
|
|
94
|
+
super(message, options);
|
|
95
|
+
this.name = this.constructor.name;
|
|
96
|
+
if (options?.code) {
|
|
97
|
+
this.code = options?.code;
|
|
98
|
+
}
|
|
99
|
+
Error.captureStackTrace?.(this, this.constructor);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function OPE(message, code, cause) {
|
|
103
|
+
return new OperationProcessingError(message, { code, cause });
|
|
104
|
+
}
|
|
105
|
+
async function calculateJwkThumbprint(jwk) {
|
|
106
|
+
let components;
|
|
107
|
+
switch (jwk.kty) {
|
|
108
|
+
case "EC":
|
|
109
|
+
components = {
|
|
110
|
+
crv: jwk.crv,
|
|
111
|
+
kty: jwk.kty,
|
|
112
|
+
x: jwk.x,
|
|
113
|
+
y: jwk.y
|
|
114
|
+
};
|
|
115
|
+
break;
|
|
116
|
+
case "OKP":
|
|
117
|
+
components = {
|
|
118
|
+
crv: jwk.crv,
|
|
119
|
+
kty: jwk.kty,
|
|
120
|
+
x: jwk.x
|
|
121
|
+
};
|
|
122
|
+
break;
|
|
123
|
+
case "AKP":
|
|
124
|
+
components = {
|
|
125
|
+
alg: jwk.alg,
|
|
126
|
+
kty: jwk.kty,
|
|
127
|
+
pub: jwk.pub
|
|
128
|
+
};
|
|
129
|
+
break;
|
|
130
|
+
case "RSA":
|
|
131
|
+
components = {
|
|
132
|
+
e: jwk.e,
|
|
133
|
+
kty: jwk.kty,
|
|
134
|
+
n: jwk.n
|
|
135
|
+
};
|
|
136
|
+
break;
|
|
137
|
+
default:
|
|
138
|
+
throw new UnsupportedOperationError("unsupported JWK key type", { cause: jwk });
|
|
139
|
+
}
|
|
140
|
+
return b64u(await crypto.subtle.digest("SHA-256", buf(JSON.stringify(components))));
|
|
141
|
+
}
|
|
142
|
+
function assertCryptoKey(key, it) {
|
|
143
|
+
if (!(key instanceof CryptoKey)) {
|
|
144
|
+
throw CodedTypeError(`${it} must be a CryptoKey`, ERR_INVALID_ARG_TYPE);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function assertPrivateKey(key, it) {
|
|
148
|
+
assertCryptoKey(key, it);
|
|
149
|
+
if (key.type !== "private") {
|
|
150
|
+
throw CodedTypeError(`${it} must be a private CryptoKey`, ERR_INVALID_ARG_VALUE);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function assertPublicKey(key, it) {
|
|
154
|
+
assertCryptoKey(key, it);
|
|
155
|
+
if (key.type !== "public") {
|
|
156
|
+
throw CodedTypeError(`${it} must be a public CryptoKey`, ERR_INVALID_ARG_VALUE);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function assertString(input, it, code, cause) {
|
|
160
|
+
try {
|
|
161
|
+
if (typeof input !== "string") {
|
|
162
|
+
throw CodedTypeError(`${it} must be a string`, ERR_INVALID_ARG_TYPE, cause);
|
|
163
|
+
}
|
|
164
|
+
if (input.length === 0) {
|
|
165
|
+
throw CodedTypeError(`${it} must not be empty`, ERR_INVALID_ARG_VALUE, cause);
|
|
166
|
+
}
|
|
167
|
+
} catch (err) {
|
|
168
|
+
if (code) {
|
|
169
|
+
throw OPE(err.message, code, cause);
|
|
170
|
+
}
|
|
171
|
+
throw err;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function randomBytes() {
|
|
175
|
+
return b64u(crypto.getRandomValues(new Uint8Array(32)));
|
|
176
|
+
}
|
|
177
|
+
function generateRandomCodeVerifier() {
|
|
178
|
+
return randomBytes();
|
|
179
|
+
}
|
|
180
|
+
function generateRandomState() {
|
|
181
|
+
return randomBytes();
|
|
182
|
+
}
|
|
183
|
+
async function calculatePKCECodeChallenge(codeVerifier) {
|
|
184
|
+
assertString(codeVerifier, "codeVerifier");
|
|
185
|
+
return b64u(await crypto.subtle.digest("SHA-256", buf(codeVerifier)));
|
|
186
|
+
}
|
|
187
|
+
function psAlg(key) {
|
|
188
|
+
switch (key.algorithm.hash.name) {
|
|
189
|
+
case "SHA-256":
|
|
190
|
+
return "PS256";
|
|
191
|
+
case "SHA-384":
|
|
192
|
+
return "PS384";
|
|
193
|
+
case "SHA-512":
|
|
194
|
+
return "PS512";
|
|
195
|
+
default:
|
|
196
|
+
throw new UnsupportedOperationError("unsupported RsaHashedKeyAlgorithm hash name", {
|
|
197
|
+
cause: key
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function rsAlg(key) {
|
|
202
|
+
switch (key.algorithm.hash.name) {
|
|
203
|
+
case "SHA-256":
|
|
204
|
+
return "RS256";
|
|
205
|
+
case "SHA-384":
|
|
206
|
+
return "RS384";
|
|
207
|
+
case "SHA-512":
|
|
208
|
+
return "RS512";
|
|
209
|
+
default:
|
|
210
|
+
throw new UnsupportedOperationError("unsupported RsaHashedKeyAlgorithm hash name", {
|
|
211
|
+
cause: key
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function esAlg(key) {
|
|
216
|
+
switch (key.algorithm.namedCurve) {
|
|
217
|
+
case "P-256":
|
|
218
|
+
return "ES256";
|
|
219
|
+
case "P-384":
|
|
220
|
+
return "ES384";
|
|
221
|
+
case "P-521":
|
|
222
|
+
return "ES512";
|
|
223
|
+
default:
|
|
224
|
+
throw new UnsupportedOperationError("unsupported EcKeyAlgorithm namedCurve", { cause: key });
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function keyToJws(key) {
|
|
228
|
+
switch (key.algorithm.name) {
|
|
229
|
+
case "RSA-PSS":
|
|
230
|
+
return psAlg(key);
|
|
231
|
+
case "RSASSA-PKCS1-v1_5":
|
|
232
|
+
return rsAlg(key);
|
|
233
|
+
case "ECDSA":
|
|
234
|
+
return esAlg(key);
|
|
235
|
+
case "Ed25519":
|
|
236
|
+
case "ML-DSA-44":
|
|
237
|
+
case "ML-DSA-65":
|
|
238
|
+
case "ML-DSA-87":
|
|
239
|
+
return key.algorithm.name;
|
|
240
|
+
case "EdDSA":
|
|
241
|
+
return "Ed25519";
|
|
242
|
+
default:
|
|
243
|
+
throw new UnsupportedOperationError("unsupported CryptoKey algorithm name", { cause: key });
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
function getClockSkew(client) {
|
|
247
|
+
const skew = client?.[clockSkew];
|
|
248
|
+
return typeof skew === "number" && Number.isFinite(skew) ? skew : 0;
|
|
249
|
+
}
|
|
250
|
+
function epochTime() {
|
|
251
|
+
return Math.floor(Date.now() / 1000);
|
|
252
|
+
}
|
|
253
|
+
async function signJwt(header, payload, key) {
|
|
254
|
+
if (!key.usages.includes("sign")) {
|
|
255
|
+
throw CodedTypeError('CryptoKey instances used for signing assertions must include "sign" in their "usages"', ERR_INVALID_ARG_VALUE);
|
|
256
|
+
}
|
|
257
|
+
const input = `${b64u(buf(JSON.stringify(header)))}.${b64u(buf(JSON.stringify(payload)))}`;
|
|
258
|
+
const signature = b64u(await crypto.subtle.sign(keyToSubtle(key), key, buf(input)));
|
|
259
|
+
return `${input}.${signature}`;
|
|
260
|
+
}
|
|
261
|
+
var jwkCache;
|
|
262
|
+
async function getSetPublicJwkCache(key, alg) {
|
|
263
|
+
const { kty, e, n, x, y, crv, pub } = await crypto.subtle.exportKey("jwk", key);
|
|
264
|
+
const jwk = { kty, e, n, x, y, crv, pub };
|
|
265
|
+
if (kty === "AKP")
|
|
266
|
+
jwk.alg = alg;
|
|
267
|
+
jwkCache.set(key, jwk);
|
|
268
|
+
return jwk;
|
|
269
|
+
}
|
|
270
|
+
async function publicJwk(key, alg) {
|
|
271
|
+
jwkCache ||= new WeakMap;
|
|
272
|
+
return jwkCache.get(key) || getSetPublicJwkCache(key, alg);
|
|
273
|
+
}
|
|
274
|
+
var URLParse = URL.parse ? (url, base) => URL.parse(url, base) : (url, base) => {
|
|
275
|
+
try {
|
|
276
|
+
return new URL(url, base);
|
|
277
|
+
} catch {
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
class DPoPHandler {
|
|
282
|
+
#header;
|
|
283
|
+
#privateKey;
|
|
284
|
+
#publicKey;
|
|
285
|
+
#clockSkew;
|
|
286
|
+
#modifyAssertion;
|
|
287
|
+
#map;
|
|
288
|
+
#jkt;
|
|
289
|
+
constructor(client, keyPair, options) {
|
|
290
|
+
assertPrivateKey(keyPair?.privateKey, '"DPoP.privateKey"');
|
|
291
|
+
assertPublicKey(keyPair?.publicKey, '"DPoP.publicKey"');
|
|
292
|
+
if (!keyPair.publicKey.extractable) {
|
|
293
|
+
throw CodedTypeError('"DPoP.publicKey.extractable" must be true', ERR_INVALID_ARG_VALUE);
|
|
294
|
+
}
|
|
295
|
+
this.#modifyAssertion = options?.[modifyAssertion];
|
|
296
|
+
this.#clockSkew = getClockSkew(client);
|
|
297
|
+
this.#privateKey = keyPair.privateKey;
|
|
298
|
+
this.#publicKey = keyPair.publicKey;
|
|
299
|
+
branded.add(this);
|
|
300
|
+
}
|
|
301
|
+
#get(key) {
|
|
302
|
+
this.#map ||= new Map;
|
|
303
|
+
let item = this.#map.get(key);
|
|
304
|
+
if (item) {
|
|
305
|
+
this.#map.delete(key);
|
|
306
|
+
this.#map.set(key, item);
|
|
307
|
+
}
|
|
308
|
+
return item;
|
|
309
|
+
}
|
|
310
|
+
#set(key, val) {
|
|
311
|
+
this.#map ||= new Map;
|
|
312
|
+
this.#map.delete(key);
|
|
313
|
+
if (this.#map.size === 100) {
|
|
314
|
+
this.#map.delete(this.#map.keys().next().value);
|
|
315
|
+
}
|
|
316
|
+
this.#map.set(key, val);
|
|
317
|
+
}
|
|
318
|
+
async calculateThumbprint() {
|
|
319
|
+
if (!this.#jkt) {
|
|
320
|
+
const jwk = await crypto.subtle.exportKey("jwk", this.#publicKey);
|
|
321
|
+
this.#jkt ||= await calculateJwkThumbprint(jwk);
|
|
322
|
+
}
|
|
323
|
+
return this.#jkt;
|
|
324
|
+
}
|
|
325
|
+
async addProof(url, headers, htm, accessToken) {
|
|
326
|
+
const alg = keyToJws(this.#privateKey);
|
|
327
|
+
this.#header ||= {
|
|
328
|
+
alg,
|
|
329
|
+
typ: "dpop+jwt",
|
|
330
|
+
jwk: await publicJwk(this.#publicKey, alg)
|
|
331
|
+
};
|
|
332
|
+
const nonce = this.#get(url.origin);
|
|
333
|
+
const now = epochTime() + this.#clockSkew;
|
|
334
|
+
const payload = {
|
|
335
|
+
iat: now,
|
|
336
|
+
jti: randomBytes(),
|
|
337
|
+
htm,
|
|
338
|
+
nonce,
|
|
339
|
+
htu: `${url.origin}${url.pathname}`,
|
|
340
|
+
ath: accessToken ? b64u(await crypto.subtle.digest("SHA-256", buf(accessToken))) : undefined
|
|
341
|
+
};
|
|
342
|
+
this.#modifyAssertion?.(this.#header, payload);
|
|
343
|
+
headers.set("dpop", await signJwt(this.#header, payload, this.#privateKey));
|
|
344
|
+
}
|
|
345
|
+
cacheNonce(response, url) {
|
|
346
|
+
try {
|
|
347
|
+
const nonce = response.headers.get("dpop-nonce");
|
|
348
|
+
if (nonce) {
|
|
349
|
+
this.#set(url.origin, nonce);
|
|
350
|
+
}
|
|
351
|
+
} catch {}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
var tokenMatch = "[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+";
|
|
355
|
+
var token68Match = "[a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2}";
|
|
356
|
+
var quotedMatch = '"((?:[^"\\\\]|\\\\[\\s\\S])*)"';
|
|
357
|
+
var quotedParamMatcher = "(" + tokenMatch + ")\\s*=\\s*" + quotedMatch;
|
|
358
|
+
var paramMatcher = "(" + tokenMatch + ")\\s*=\\s*(" + tokenMatch + ")";
|
|
359
|
+
var schemeRE = new RegExp("^[,\\s]*(" + tokenMatch + ")");
|
|
360
|
+
var quotedParamRE = new RegExp("^[,\\s]*" + quotedParamMatcher + "[,\\s]*(.*)");
|
|
361
|
+
var unquotedParamRE = new RegExp("^[,\\s]*" + paramMatcher + "[,\\s]*(.*)");
|
|
362
|
+
var token68ParamRE = new RegExp("^(" + token68Match + ")(?:$|[,\\s])(.*)");
|
|
363
|
+
var skipSubjectCheck = Symbol();
|
|
364
|
+
var idTokenClaims = new WeakMap;
|
|
365
|
+
var jwtRefs = new WeakMap;
|
|
366
|
+
var branded = new WeakSet;
|
|
367
|
+
var nopkce = Symbol();
|
|
368
|
+
var expectNoNonce = Symbol();
|
|
369
|
+
var skipAuthTimeCheck = Symbol();
|
|
370
|
+
var UNSUPPORTED_OPERATION = "OAUTH_UNSUPPORTED_OPERATION";
|
|
371
|
+
function checkRsaKeyAlgorithm(key) {
|
|
372
|
+
const { algorithm } = key;
|
|
373
|
+
if (typeof algorithm.modulusLength !== "number" || algorithm.modulusLength < 2048) {
|
|
374
|
+
throw new UnsupportedOperationError(`unsupported ${algorithm.name} modulusLength`, {
|
|
375
|
+
cause: key
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
function ecdsaHashName(key) {
|
|
380
|
+
const { algorithm } = key;
|
|
381
|
+
switch (algorithm.namedCurve) {
|
|
382
|
+
case "P-256":
|
|
383
|
+
return "SHA-256";
|
|
384
|
+
case "P-384":
|
|
385
|
+
return "SHA-384";
|
|
386
|
+
case "P-521":
|
|
387
|
+
return "SHA-512";
|
|
388
|
+
default:
|
|
389
|
+
throw new UnsupportedOperationError("unsupported ECDSA namedCurve", { cause: key });
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
function keyToSubtle(key) {
|
|
393
|
+
switch (key.algorithm.name) {
|
|
394
|
+
case "ECDSA":
|
|
395
|
+
return {
|
|
396
|
+
name: key.algorithm.name,
|
|
397
|
+
hash: ecdsaHashName(key)
|
|
398
|
+
};
|
|
399
|
+
case "RSA-PSS": {
|
|
400
|
+
checkRsaKeyAlgorithm(key);
|
|
401
|
+
switch (key.algorithm.hash.name) {
|
|
402
|
+
case "SHA-256":
|
|
403
|
+
case "SHA-384":
|
|
404
|
+
case "SHA-512":
|
|
405
|
+
return {
|
|
406
|
+
name: key.algorithm.name,
|
|
407
|
+
saltLength: parseInt(key.algorithm.hash.name.slice(-3), 10) >> 3
|
|
408
|
+
};
|
|
409
|
+
default:
|
|
410
|
+
throw new UnsupportedOperationError("unsupported RSA-PSS hash name", { cause: key });
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
case "RSASSA-PKCS1-v1_5":
|
|
414
|
+
checkRsaKeyAlgorithm(key);
|
|
415
|
+
return key.algorithm.name;
|
|
416
|
+
case "ML-DSA-44":
|
|
417
|
+
case "ML-DSA-65":
|
|
418
|
+
case "ML-DSA-87":
|
|
419
|
+
case "Ed25519":
|
|
420
|
+
return key.algorithm.name;
|
|
421
|
+
}
|
|
422
|
+
throw new UnsupportedOperationError("unsupported CryptoKey algorithm name", { cause: key });
|
|
423
|
+
}
|
|
424
|
+
var skipStateCheck = Symbol();
|
|
425
|
+
var expectNoState = Symbol();
|
|
426
|
+
var _nodiscoverycheck = Symbol();
|
|
427
|
+
var _expectedIssuer = Symbol();
|
|
428
|
+
|
|
429
|
+
export { generateRandomCodeVerifier, generateRandomState, calculatePKCECodeChallenge };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getScriptApiTypes,
|
|
3
|
+
getScriptMcpTypes,
|
|
3
4
|
require_typescript
|
|
4
|
-
} from "./cli-
|
|
5
|
+
} from "./cli-r9f6ngrf.js";
|
|
5
6
|
import {
|
|
6
7
|
deleteSwarmConfigByKey,
|
|
7
8
|
getAgentById,
|
|
@@ -10,7 +11,7 @@ import {
|
|
|
10
11
|
getSwarmConfigs,
|
|
11
12
|
init_db,
|
|
12
13
|
upsertSwarmConfig
|
|
13
|
-
} from "./cli-
|
|
14
|
+
} from "./cli-15y7qhzp.js";
|
|
14
15
|
import {
|
|
15
16
|
init_secret_scrubber,
|
|
16
17
|
scrubSecrets
|
|
@@ -361,6 +362,17 @@ var SCRIPT_SDK_TYPES = `
|
|
|
361
362
|
export type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue };
|
|
362
363
|
export type ScriptScope = "agent" | "global";
|
|
363
364
|
export type ScriptFsMode = "none" | "workspace-rw";
|
|
365
|
+
export type ScriptApiRawOptions = { raw: true };
|
|
366
|
+
export type ScriptApiDefaultOptions = { raw?: false };
|
|
367
|
+
|
|
368
|
+
export interface ScriptApiRawResult {
|
|
369
|
+
ok: boolean;
|
|
370
|
+
status: number;
|
|
371
|
+
statusText: string;
|
|
372
|
+
headers: Record<string, string>;
|
|
373
|
+
url: string;
|
|
374
|
+
response: Response;
|
|
375
|
+
}
|
|
364
376
|
|
|
365
377
|
export interface Redacted<T> {
|
|
366
378
|
readonly __redactedBrand?: T;
|
|
@@ -408,7 +420,7 @@ export interface SwarmSdk {
|
|
|
408
420
|
swarm_get(args?: { includeFull?: boolean }): Promise<unknown>;
|
|
409
421
|
agent_info(args?: Record<string, unknown>): Promise<unknown>;
|
|
410
422
|
metrics_get(args?: Record<string, unknown>): Promise<unknown>;
|
|
411
|
-
user_resolve(args?: { kind?: string; externalId?: string; email?: string; userId?: string }): Promise<unknown>;
|
|
423
|
+
user_resolve(args?: { kind?: string; externalId?: string; email?: string; userId?: string; name?: string }): Promise<unknown>;
|
|
412
424
|
db_query(args: { sql: string; params?: unknown[] }): Promise<unknown>;
|
|
413
425
|
// --- config ---
|
|
414
426
|
config_get(args?: { agentId?: string; repoId?: string; key?: string; includeSecrets?: boolean }): Promise<unknown>;
|
|
@@ -541,6 +553,7 @@ export interface SwarmSdk {
|
|
|
541
553
|
|
|
542
554
|
// --- pages & metrics ---
|
|
543
555
|
page_create(args: Record<string, unknown>): Promise<unknown>;
|
|
556
|
+
page_delete(args: { pageId?: string; slug?: string }): Promise<unknown>;
|
|
544
557
|
metric_create(args: Record<string, unknown>): Promise<unknown>;
|
|
545
558
|
|
|
546
559
|
// --- human input ---
|
|
@@ -607,6 +620,7 @@ export interface ScriptContext {
|
|
|
607
620
|
step?: ScriptWorkflowSteps;
|
|
608
621
|
swarm: SwarmSdk & { config: SwarmConfig };
|
|
609
622
|
api: ScriptApiRegistry;
|
|
623
|
+
mcp: ScriptMcpRegistry;
|
|
610
624
|
stdlib: ScriptStdlib;
|
|
611
625
|
logger: ScriptLogger;
|
|
612
626
|
}
|
|
@@ -614,12 +628,13 @@ export interface ScriptContext {
|
|
|
614
628
|
// biome-ignore lint/suspicious/noExplicitAny: scripts may narrow their args type at the entrypoint.
|
|
615
629
|
export type ScriptMain = (args: any, ctx: ScriptContext) => unknown | Promise<unknown>;
|
|
616
630
|
`;
|
|
617
|
-
function scriptSdkTypesWithGeneratedApis(apiTypes = getScriptApiTypes()) {
|
|
631
|
+
function scriptSdkTypesWithGeneratedApis(apiTypes = getScriptApiTypes(), mcpTypes = getScriptMcpTypes()) {
|
|
618
632
|
return `${SCRIPT_SDK_TYPES}
|
|
619
633
|
${apiTypes}
|
|
634
|
+
${mcpTypes}
|
|
620
635
|
`;
|
|
621
636
|
}
|
|
622
|
-
var
|
|
637
|
+
var STDLIB_MODULE_TYPES = `
|
|
623
638
|
declare module "stdlib" {
|
|
624
639
|
export interface Redacted<T> {
|
|
625
640
|
readonly __redactedBrand?: T;
|
|
@@ -637,11 +652,20 @@ declare module "stdlib" {
|
|
|
637
652
|
export function glob(pattern: string): Promise<string[]>;
|
|
638
653
|
export function table(rows: Array<Record<string, unknown>>): string;
|
|
639
654
|
}
|
|
640
|
-
|
|
655
|
+
`;
|
|
656
|
+
function stdlibTypesFor(sdkModuleBody) {
|
|
657
|
+
return `${STDLIB_MODULE_TYPES}
|
|
641
658
|
declare module "swarm-sdk" {
|
|
642
|
-
${
|
|
659
|
+
${sdkModuleBody.replace(/^/gm, " ")}
|
|
643
660
|
}
|
|
644
661
|
`;
|
|
662
|
+
}
|
|
663
|
+
var SCRIPT_STDLIB_TYPES = stdlibTypesFor(SCRIPT_SDK_TYPES);
|
|
664
|
+
function scriptStdlibTypesWithGeneratedApis(apiTypes = getScriptApiTypes(), mcpTypes = getScriptMcpTypes()) {
|
|
665
|
+
return stdlibTypesFor(`${SCRIPT_SDK_TYPES}
|
|
666
|
+
${apiTypes}
|
|
667
|
+
${mcpTypes}`);
|
|
668
|
+
}
|
|
645
669
|
var SCRIPT_RUNTIME_GLOBALS = `
|
|
646
670
|
// === Console ===
|
|
647
671
|
|
|
@@ -1080,7 +1104,7 @@ function typecheckScript(source, context = {}) {
|
|
|
1080
1104
|
target: import_typescript.default.ScriptTarget.ES2022,
|
|
1081
1105
|
types: []
|
|
1082
1106
|
};
|
|
1083
|
-
const sdkTypes = scriptSdkTypesWithGeneratedApis(getScriptApiTypes(context));
|
|
1107
|
+
const sdkTypes = scriptSdkTypesWithGeneratedApis(getScriptApiTypes(context), getScriptMcpTypes(context));
|
|
1084
1108
|
const files = new Map([
|
|
1085
1109
|
[USER_FILE, source],
|
|
1086
1110
|
[SDK_FILE, sdkTypes],
|
|
@@ -1179,4 +1203,4 @@ function extractScriptSignature(source) {
|
|
|
1179
1203
|
return FALLBACK_SIGNATURE;
|
|
1180
1204
|
}
|
|
1181
1205
|
|
|
1182
|
-
export { agentFsProvisionSeeder, ensureAgentFsCredentialsForAgent, extractArgsJsonSchema, scriptSdkTypesWithGeneratedApis,
|
|
1206
|
+
export { agentFsProvisionSeeder, ensureAgentFsCredentialsForAgent, extractArgsJsonSchema, scriptSdkTypesWithGeneratedApis, scriptStdlibTypesWithGeneratedApis, typecheckScript, extractScriptSignature };
|