@desplega.ai/agent-swarm 1.122.1 → 1.123.1
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 -0
- package/dist/{actions-rd8p2zqb.js → actions-3ntn8s3f.js} +6 -6
- package/dist/{app-v839gywt.js → app-pej7g57x.js} +4 -4
- package/dist/{assistant-qjp128zg.js → assistant-pxa36zjn.js} +14 -11
- package/dist/{boot-reembed-e4b9xsa1.js → boot-reembed-wdwde4vr.js} +3 -3
- package/dist/{boot-reembed-3fjfyz1h.js → boot-reembed-ybq960bh.js} +4 -4
- package/dist/{boot-scrub-logs-x3vrw472.js → boot-scrub-logs-ndqxg6e3.js} +2 -2
- package/dist/{cli-4pcxkk69.js → cli-0pmkqg1d.js} +6 -1
- package/dist/{cli-ctzr9apr.js → cli-1cah98w1.js} +1 -1
- package/dist/{cli-zrc5k1rd.js → cli-1kv5sydm.js} +22 -17
- package/dist/{cli-nqxvcvnv.js → cli-256kb8p5.js} +4 -4
- package/dist/{cli-mwp9asnz.js → cli-2e5t0yjj.js} +17 -13
- package/dist/{cli-3m3ysn1f.js → cli-333x50bh.js} +1 -1
- package/dist/{cli-5arfywtm.js → cli-5ncdb7ff.js} +19 -9
- package/dist/{cli-xpveay6y.js → cli-7qvpf14x.js} +2 -2
- package/dist/{cli-jc23g2g2.js → cli-7rk0bbfr.js} +90 -4
- package/dist/{cli-9pv05nba.js → cli-7yn0n4fp.js} +11 -2
- package/dist/{cli-g279mtbs.js → cli-82eq5zf5.js} +6 -3
- package/dist/{cli-ndv6ftj4.js → cli-ca32n52j.js} +2 -2
- package/dist/{cli-2y473tja.js → cli-g4bfr1e7.js} +2 -2
- package/dist/{cli-pw04m0wb.js → cli-hgkf9zmd.js} +3523 -5659
- package/dist/{cli-v2e8jdb6.js → cli-k3yfwe8g.js} +2 -2
- package/dist/{cli-jjcd495f.js → cli-kqgkfpz7.js} +8 -3
- package/dist/{cli-h7209ted.js → cli-mb3gz7qr.js} +1 -1
- package/dist/{cli-ydcfdmcz.js → cli-mntyk3cr.js} +1 -1
- package/dist/{cli-th8jh1rm.js → cli-pjvdm39a.js} +6 -6
- package/dist/{cli-spsg6mqp.js → cli-qrnhnhma.js} +19 -9
- package/dist/{cli-2rcegy4e.js → cli-r07fhvsk.js} +48 -56
- package/dist/{cli-ea6b2m9a.js → cli-sj43m5z0.js} +7 -4
- package/dist/{cli-fdbt8m8y.js → cli-vw0acwe7.js} +37 -21
- package/dist/{cli-31163xvp.js → cli-x2hk4m81.js} +250 -24
- package/dist/{cli-h4kjb2qy.js → cli-xv09zc8e.js} +1 -1
- package/dist/{cli-xdv1vntm.js → cli-zvbxe7pf.js} +5 -3
- package/dist/cli.js +14 -12
- package/dist/{commands-jfmtpvvy.js → commands-5p0erxye.js} +7 -4
- package/dist/{db-vn5met8v.js → db-yp9e9nvs.js} +2 -2
- package/dist/{e2b-2s4psnbf.js → e2b-q345y8s4.js} +0 -4
- package/dist/{handlers-0s7dn9ma.js → handlers-3hqw1dsr.js} +14 -11
- package/dist/{hook-b2293dx1.js → hook-5981d59r.js} +1 -40
- package/dist/{http-4hmtrrpx.js → http-ek9ctgth.js} +151 -633
- package/dist/{index-cmee5q4s.js → index-1cnvzmh4.js} +7 -7
- package/dist/{index-4bcr1r09.js → index-33eb3q08.js} +11 -11
- package/dist/{index-zy9smn2h.js → index-8j9b86c9.js} +9 -9
- package/dist/{index-gxj7sbzx.js → index-chcty242.js} +10 -10
- package/dist/{keepalive-2htbn1j9.js → keepalive-rrvxy1fy.js} +5 -5
- package/dist/{lead-p9s142mj.js → lead-jvw8b413.js} +21 -21
- package/dist/{maintenance-x8jgt9fd.js → maintenance-3zjnr2wa.js} +4 -4
- package/dist/{oauth-refresh-sweep-9m7qmm1m.js → oauth-refresh-sweep-vfhvqmby.js} +4 -4
- package/dist/{onboard-jsy93b12.js → onboard-kvntqz8h.js} +6 -2
- package/dist/{otel-impl-z2w4phcp.js → otel-impl-61tsn4bx.js} +1 -1
- package/dist/{pi-mono-adapter-2syx1x4d.js → pi-mono-adapter-z6h98fva.js} +4 -38
- package/dist/{pricing-refresh-cjjd6ayt.js → pricing-refresh-jcp6ntbk.js} +4 -4
- package/dist/{rbac-roles-v3xrhv48.js → rbac-roles-r3j4z9vs.js} +4 -4
- package/dist/{rbac-roles-166rf7ba.js → rbac-roles-xcbab18x.js} +3 -3
- package/dist/{seed-pricing-f4xrjref.js → seed-pricing-bd669a7j.js} +3 -3
- package/dist/{setup-58jmv2vm.js → setup-pg03xran.js} +2 -2
- package/dist/{worker-95x5vnx4.js → worker-q5n4qwvq.js} +21 -21
- package/openapi.json +124 -1
- package/package.json +5 -3
- package/src/be/budget-admission.ts +2 -1
- package/src/be/db.ts +2 -1
- package/src/be/memory/constants.ts +29 -25
- package/src/be/memory/providers/sqlite-store.ts +3 -3
- package/src/be/memory/reranker.ts +4 -5
- package/src/be/models-catalog.ts +156 -0
- package/src/be/modelsdev-cache.ts +14 -1
- package/src/be/pricing-refresh.ts +2 -0
- package/src/be/rbac-audit.ts +2 -1
- package/src/be/scripts/typecheck.ts +9 -0
- package/src/be/swarm-config-guard.ts +117 -1
- package/src/commands/onboard/env-generator.ts +12 -0
- package/src/commands/runner.ts +34 -0
- package/src/e2b/env.ts +0 -4
- package/src/gitlab/auth.ts +3 -1
- package/src/heartbeat/heartbeat.ts +44 -19
- package/src/hooks/hook.ts +0 -67
- package/src/http/all-routes.ts +1 -0
- package/src/http/core.ts +66 -1
- package/src/http/index.ts +8 -2
- package/src/http/mcp-oauth.ts +2 -1
- package/src/http/models-catalog.ts +65 -0
- package/src/oauth/mcp-wrapper.ts +2 -1
- package/src/otel.ts +23 -10
- package/src/prompts/base-prompt.ts +8 -7
- package/src/prompts/session-templates.ts +103 -12
- package/src/providers/pi-mono-adapter.ts +12 -2
- package/src/providers/pi-mono-extension.ts +0 -64
- package/src/providers/pricing-sources.md +16 -1
- package/src/rbac/admission.ts +2 -1
- package/src/scripts-runtime/eval-harness.ts +18 -1
- package/src/scripts-runtime/types/stdlib.d.ts +9 -0
- package/src/scripts-runtime/types/swarm-sdk.d.ts +9 -0
- package/src/server-user.ts +4 -7
- package/src/slack/assistant.ts +3 -2
- package/src/slack/blocks.ts +21 -8
- package/src/slack/commands.ts +2 -1
- package/src/slack/handlers.ts +6 -3
- package/src/slack/responses.ts +27 -51
- package/src/slack/router.ts +5 -2
- package/src/slack/watcher.ts +22 -5
- package/src/tasks/worker-follow-up.ts +9 -2
- package/src/telemetry.ts +168 -4
- package/src/tests/base-prompt.test.ts +79 -0
- package/src/tests/env-flag.test.ts +93 -0
- package/src/tests/heartbeat-reroute-decision.test.ts +10 -10
- package/src/tests/heartbeat-supersede-resume.test.ts +2 -2
- package/src/tests/mcp-tools-user.test.ts +62 -16
- package/src/tests/mcp-tools.test.ts +4 -1
- package/src/tests/memory-edit.test.ts +21 -4
- package/src/tests/model-groups-live-catalog.test.ts +65 -0
- package/src/tests/models-catalog.test.ts +119 -0
- package/src/tests/oauth-access-token-tool.test.ts +71 -1
- package/src/tests/pricing-refresh.test.ts +25 -0
- package/src/tests/prompt-template-session.test.ts +135 -5
- package/src/tests/rbac-charact-skills.test.ts +81 -14
- package/src/tests/reload-config.test.ts +81 -6
- package/src/tests/script-apis-mcp.test.ts +56 -8
- package/src/tests/scripts-mcp-e2e.test.ts +108 -8
- package/src/tests/slack-blocks.test.ts +2 -1
- package/src/tests/slack-inline-output.test.ts +24 -30
- package/src/tests/slack-watcher.test.ts +42 -0
- package/src/tests/steer-task-tool.test.ts +37 -8
- package/src/tests/steering-transport.test.ts +18 -3
- package/src/tests/swarm-tool-result-gate.test.ts +364 -0
- package/src/tests/task-tools-ctx.test.ts +19 -16
- package/src/tests/task-tools-ownership.test.ts +41 -13
- package/src/tests/telemetry-init.test.ts +379 -2
- package/src/tests/tool-output-agent-id.test.ts +14 -2
- package/src/tools/accept-steer.ts +45 -53
- package/src/tools/cancel-task.ts +31 -41
- package/src/tools/context-diff.ts +19 -63
- package/src/tools/context-history.ts +22 -51
- package/src/tools/create-channel.ts +24 -39
- package/src/tools/create-metric.ts +19 -82
- package/src/tools/create-page.ts +20 -81
- package/src/tools/credential-bindings/tool.ts +125 -246
- package/src/tools/db-query.ts +13 -24
- package/src/tools/delete-channel.ts +25 -71
- package/src/tools/delete-page.ts +27 -75
- package/src/tools/get-metrics.ts +29 -22
- package/src/tools/get-swarm.ts +44 -15
- package/src/tools/get-task-details.ts +150 -32
- package/src/tools/get-tasks.ts +24 -29
- package/src/tools/inject-learning.ts +8 -38
- package/src/tools/join-swarm.ts +45 -47
- package/src/tools/kv/kv-delete.ts +13 -37
- package/src/tools/kv/kv-get.ts +38 -29
- package/src/tools/kv/kv-incr.ts +28 -56
- package/src/tools/kv/kv-list.ts +40 -31
- package/src/tools/kv/kv-set.ts +34 -76
- package/src/tools/list-channels.ts +24 -17
- package/src/tools/list-services.ts +37 -45
- package/src/tools/manage-user.ts +53 -66
- package/src/tools/mcp-servers/mcp-server-create.ts +19 -55
- package/src/tools/mcp-servers/mcp-server-delete.ts +9 -39
- package/src/tools/mcp-servers/mcp-server-get.ts +9 -35
- package/src/tools/mcp-servers/mcp-server-install.ts +13 -60
- package/src/tools/mcp-servers/mcp-server-list.ts +28 -26
- package/src/tools/mcp-servers/mcp-server-uninstall.ts +10 -36
- package/src/tools/mcp-servers/mcp-server-update.ts +13 -57
- package/src/tools/memory-delete.ts +16 -46
- package/src/tools/memory-edit.ts +48 -49
- package/src/tools/memory-get.ts +40 -36
- package/src/tools/memory-rate.ts +14 -44
- package/src/tools/memory-search.ts +46 -52
- package/src/tools/my-agent-info.ts +39 -33
- package/src/tools/oauth-access-token.ts +9 -24
- package/src/tools/poll-task.ts +50 -77
- package/src/tools/post-message.ts +24 -38
- package/src/tools/prompt-templates/delete.ts +16 -48
- package/src/tools/prompt-templates/get.ts +45 -42
- package/src/tools/prompt-templates/list.ts +29 -44
- package/src/tools/prompt-templates/preview.ts +14 -40
- package/src/tools/prompt-templates/set.ts +30 -52
- package/src/tools/read-messages.ts +45 -54
- package/src/tools/register-agentmail-inbox.ts +28 -84
- package/src/tools/register-kapso-number.ts +20 -50
- package/src/tools/register-service.ts +36 -44
- package/src/tools/repos/get-repos.ts +29 -21
- package/src/tools/repos/update-repo.ts +30 -27
- package/src/tools/request-human-input.ts +10 -33
- package/src/tools/resolve-user.ts +59 -16
- package/src/tools/schedules/create-schedule.ts +58 -173
- package/src/tools/schedules/delete-schedule.ts +16 -56
- package/src/tools/schedules/list-schedules.ts +41 -67
- package/src/tools/schedules/patch-schedule.ts +57 -153
- package/src/tools/schedules/run-schedule-now.ts +18 -59
- package/src/tools/schedules/update-schedule.ts +57 -153
- package/src/tools/script-apis.ts +46 -28
- package/src/tools/script-common.ts +129 -34
- package/src/tools/script-connections/tool.ts +59 -154
- package/src/tools/script-query-types.ts +43 -3
- package/src/tools/script-run.ts +40 -1
- package/src/tools/script-runs.ts +69 -1
- package/src/tools/script-search.ts +24 -1
- package/src/tools/script-upsert.ts +17 -2
- package/src/tools/send-task.ts +32 -81
- package/src/tools/skills/skill-create.ts +14 -39
- package/src/tools/skills/skill-delete.ts +14 -42
- package/src/tools/skills/skill-get-file.ts +10 -43
- package/src/tools/skills/skill-get.ts +9 -32
- package/src/tools/skills/skill-install-remote.ts +16 -52
- package/src/tools/skills/skill-install.ts +14 -52
- package/src/tools/skills/skill-list.ts +24 -26
- package/src/tools/skills/skill-publish.ts +18 -54
- package/src/tools/skills/skill-search.ts +21 -18
- package/src/tools/skills/skill-sync-remote.ts +12 -24
- package/src/tools/skills/skill-uninstall.ts +10 -26
- package/src/tools/skills/skill-update.ts +24 -81
- package/src/tools/slack-delete.ts +8 -32
- package/src/tools/slack-download-file.ts +17 -57
- package/src/tools/slack-list-channels.ts +16 -43
- package/src/tools/slack-post.ts +11 -40
- package/src/tools/slack-read.ts +33 -103
- package/src/tools/slack-reply.ts +16 -53
- package/src/tools/slack-start-thread.ts +14 -55
- package/src/tools/slack-update.ts +8 -35
- package/src/tools/slack-upload-file.ts +22 -122
- package/src/tools/steer-task.ts +22 -35
- package/src/tools/store-progress.ts +11 -26
- package/src/tools/swarm-config/delete-config.ts +19 -57
- package/src/tools/swarm-config/get-config.ts +36 -44
- package/src/tools/swarm-config/list-config.ts +36 -44
- package/src/tools/swarm-config/set-config.ts +35 -73
- package/src/tools/swarm-x.ts +20 -26
- package/src/tools/task-action.ts +26 -46
- package/src/tools/task-tool-ctx.ts +5 -13
- package/src/tools/tracker/tracker-link-task.ts +8 -22
- package/src/tools/tracker/tracker-map-agent.ts +8 -22
- package/src/tools/tracker/tracker-status.ts +27 -19
- package/src/tools/tracker/tracker-sync-status.ts +8 -18
- package/src/tools/tracker/tracker-unlink.ts +4 -16
- package/src/tools/unregister-service.ts +19 -59
- package/src/tools/update-profile.ts +60 -100
- package/src/tools/update-service-status.ts +42 -67
- package/src/tools/utils.ts +183 -8
- package/src/tools/whatsapp-message.ts +19 -32
- package/src/tools/workflows/cancel-workflow-run.ts +4 -16
- package/src/tools/workflows/create-workflow.ts +9 -38
- package/src/tools/workflows/delete-workflow.ts +5 -17
- package/src/tools/workflows/get-workflow-run.ts +41 -31
- package/src/tools/workflows/get-workflow.ts +10 -21
- package/src/tools/workflows/list-workflow-runs.ts +19 -17
- package/src/tools/workflows/list-workflows.ts +5 -17
- package/src/tools/workflows/patch-workflow-node.ts +11 -39
- package/src/tools/workflows/patch-workflow.ts +11 -36
- package/src/tools/workflows/retry-workflow-run.ts +4 -16
- package/src/tools/workflows/trigger-workflow.ts +22 -58
- package/src/tools/workflows/update-workflow.ts +10 -42
- package/src/utils/env-flag.ts +55 -0
- package/src/utils/scripts-only-mode.ts +12 -2
- package/src/utils/steering-enabled.ts +3 -2
- package/src/workflows/engine.ts +14 -6
- package/templates/skills/swarm-scripts/SKILL.md +1 -1
package/README.md
CHANGED
|
@@ -127,6 +127,8 @@ Check [our templates](https://templates.agent-swarm.dev) for a quick start.
|
|
|
127
127
|
- **Multi-channel inputs** — Slack, GitHub, GitLab, email, WhatsApp, Linear, Jira, and the HTTP API all create tasks. [Integrations](#integrations)
|
|
128
128
|
- **Workflow engine with Human-in-the-Loop** — DAG-based automation with approval gates, retries, and structured I/O. [Workflows →](https://docs.agent-swarm.dev/docs/concepts/workflows)
|
|
129
129
|
- **Scheduled & recurring tasks** — cron-based automation for standing work, with schedules that can target agent tasks, workflows, or catalog scripts. [Scheduling →](https://docs.agent-swarm.dev/docs/concepts/scheduling)
|
|
130
|
+
- **Mid-run task steering** — add context at the next turn boundary, request an immediate interrupt where the harness supports it, or degrade safely to a follow-up task. [Task steering →](https://docs.agent-swarm.dev/docs/guides/task-steering)
|
|
131
|
+
- **Operator configuration UI** — tune non-secret feature flags, limits, integration toggles, and runtime defaults from Settings → Configuration, with source and restart-required indicators. [Configuration →](https://docs.agent-swarm.dev/docs/ui/configuration)
|
|
130
132
|
- **Asset namespaces** — group tasks, workflows, schedules, pages, and mapped files under canonical shared or personal keys, with inheritance, subtree filtering, audited moves, and cross-entity discovery. [Asset namespaces →](https://docs.agent-swarm.dev/docs/guides/asset-namespaces)
|
|
131
133
|
- **Persistent shared files via agent-fs** — co-deploy agent-fs for shared task attachments, previews, and search; late provisioning or config reloads activate the provider without an API restart, and tenant-authenticated control planes can invite shared-org members without receiving the bootstrap key. [Co-deployment guide →](https://docs.agent-swarm.dev/docs/guides/agent-fs-co-deployment)
|
|
132
134
|
- **Durable script workflows** — launch background script runs, inspect their journals, and track them from the dashboard when a one-shot `script-run` is too small. [Guide →](https://docs.agent-swarm.dev/docs/guides/script-workflow-runs)
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveSlackUserId
|
|
3
|
-
} from "./cli-
|
|
4
|
-
import"./cli-
|
|
3
|
+
} from "./cli-g4bfr1e7.js";
|
|
4
|
+
import"./cli-xv09zc8e.js";
|
|
5
5
|
import {
|
|
6
6
|
createTaskWithSiblingAwareness
|
|
7
|
-
} from "./cli-
|
|
7
|
+
} from "./cli-1cah98w1.js";
|
|
8
8
|
import {
|
|
9
9
|
buildCancelledBlocks,
|
|
10
10
|
getTaskLink
|
|
11
|
-
} from "./cli-
|
|
11
|
+
} from "./cli-5ncdb7ff.js";
|
|
12
12
|
import"./cli-wspgs9bt.js";
|
|
13
13
|
import"./cli-dh55d5fg.js";
|
|
14
14
|
import {
|
|
@@ -19,9 +19,9 @@ import {
|
|
|
19
19
|
init_context_key,
|
|
20
20
|
init_db,
|
|
21
21
|
slackContextKey
|
|
22
|
-
} from "./cli-
|
|
22
|
+
} from "./cli-x2hk4m81.js";
|
|
23
23
|
import"./cli-z2zcxes1.js";
|
|
24
|
-
import"./cli-
|
|
24
|
+
import"./cli-zvbxe7pf.js";
|
|
25
25
|
import"./cli-4j2mrzag.js";
|
|
26
26
|
import"./cli-bw80ck94.js";
|
|
27
27
|
import"./cli-xz9aq0rf.js";
|
|
@@ -3,15 +3,15 @@ import {
|
|
|
3
3
|
initSlackApp,
|
|
4
4
|
startSlackApp,
|
|
5
5
|
stopSlackApp
|
|
6
|
-
} from "./cli-
|
|
6
|
+
} from "./cli-r07fhvsk.js";
|
|
7
7
|
import"./cli-rkndnn90.js";
|
|
8
8
|
import"./cli-b0p7rfnd.js";
|
|
9
|
-
import"./cli-
|
|
9
|
+
import"./cli-5ncdb7ff.js";
|
|
10
10
|
import"./cli-wspgs9bt.js";
|
|
11
11
|
import"./cli-dh55d5fg.js";
|
|
12
|
-
import"./cli-
|
|
12
|
+
import"./cli-x2hk4m81.js";
|
|
13
13
|
import"./cli-z2zcxes1.js";
|
|
14
|
-
import"./cli-
|
|
14
|
+
import"./cli-zvbxe7pf.js";
|
|
15
15
|
import"./cli-4j2mrzag.js";
|
|
16
16
|
import"./cli-bw80ck94.js";
|
|
17
17
|
import"./cli-xz9aq0rf.js";
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
bufferThreadMessage,
|
|
3
3
|
wasEventSeen
|
|
4
|
-
} from "./cli-
|
|
4
|
+
} from "./cli-pjvdm39a.js";
|
|
5
5
|
import {
|
|
6
6
|
hasOtherUserMention
|
|
7
|
-
} from "./cli-
|
|
7
|
+
} from "./cli-82eq5zf5.js";
|
|
8
8
|
import {
|
|
9
9
|
resolveSlackUserId,
|
|
10
10
|
rewriteSlackMentions
|
|
11
|
-
} from "./cli-
|
|
12
|
-
import"./cli-
|
|
11
|
+
} from "./cli-g4bfr1e7.js";
|
|
12
|
+
import"./cli-xv09zc8e.js";
|
|
13
13
|
import {
|
|
14
14
|
createTaskWithSiblingAwareness
|
|
15
|
-
} from "./cli-
|
|
15
|
+
} from "./cli-1cah98w1.js";
|
|
16
16
|
import {
|
|
17
17
|
require_dist
|
|
18
|
-
} from "./cli-
|
|
18
|
+
} from "./cli-r07fhvsk.js";
|
|
19
19
|
import"./cli-rkndnn90.js";
|
|
20
20
|
import"./cli-b0p7rfnd.js";
|
|
21
|
-
import"./cli-
|
|
21
|
+
import"./cli-5ncdb7ff.js";
|
|
22
22
|
import"./cli-wspgs9bt.js";
|
|
23
23
|
import"./cli-dh55d5fg.js";
|
|
24
24
|
import {
|
|
@@ -27,12 +27,14 @@ import {
|
|
|
27
27
|
getMostRecentTaskInThread,
|
|
28
28
|
init_context_key,
|
|
29
29
|
init_db,
|
|
30
|
+
init_env_flag,
|
|
30
31
|
init_resolver,
|
|
32
|
+
isEnvFlagEnabled,
|
|
31
33
|
resolveTemplate,
|
|
32
34
|
slackContextKey
|
|
33
|
-
} from "./cli-
|
|
35
|
+
} from "./cli-x2hk4m81.js";
|
|
34
36
|
import"./cli-z2zcxes1.js";
|
|
35
|
-
import"./cli-
|
|
37
|
+
import"./cli-zvbxe7pf.js";
|
|
36
38
|
import"./cli-4j2mrzag.js";
|
|
37
39
|
import"./cli-bw80ck94.js";
|
|
38
40
|
import"./cli-xz9aq0rf.js";
|
|
@@ -47,7 +49,8 @@ init_db();
|
|
|
47
49
|
init_resolver();
|
|
48
50
|
init_context_key();
|
|
49
51
|
var import_bolt = __toESM(require_dist(), 1);
|
|
50
|
-
|
|
52
|
+
init_env_flag();
|
|
53
|
+
var isAdditiveSlack = () => isEnvFlagEnabled("ADDITIVE_SLACK", false);
|
|
51
54
|
var cachedBotUserId = null;
|
|
52
55
|
function createAssistant() {
|
|
53
56
|
return new import_bolt.Assistant({
|
|
@@ -119,7 +122,7 @@ function createAssistant() {
|
|
|
119
122
|
}) : undefined;
|
|
120
123
|
const workingAgent = getAgentWorkingOnThread(channelId, threadTs);
|
|
121
124
|
if (workingAgent && workingAgent.status !== "offline") {
|
|
122
|
-
if (
|
|
125
|
+
if (isAdditiveSlack()) {
|
|
123
126
|
bufferThreadMessage(channelId, threadTs, messageText, userId, message.ts);
|
|
124
127
|
await safeSetStatus("Queuing follow-up...");
|
|
125
128
|
return;
|
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
getEmbeddingProvider,
|
|
4
4
|
getMemoryStore,
|
|
5
5
|
init_constants
|
|
6
|
-
} from "./cli-
|
|
6
|
+
} from "./cli-1kv5sydm.js";
|
|
7
7
|
import"./cli-q25ejbyn.js";
|
|
8
8
|
import {
|
|
9
9
|
getDb,
|
|
10
10
|
init_db
|
|
11
|
-
} from "./cli-
|
|
11
|
+
} from "./cli-x2hk4m81.js";
|
|
12
12
|
import"./cli-z2zcxes1.js";
|
|
13
|
-
import"./cli-
|
|
13
|
+
import"./cli-zvbxe7pf.js";
|
|
14
14
|
import"./cli-4j2mrzag.js";
|
|
15
15
|
import"./cli-bw80ck94.js";
|
|
16
16
|
import"./cli-xz9aq0rf.js";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
embedScript,
|
|
3
3
|
embeddingProvider
|
|
4
|
-
} from "./cli-
|
|
5
|
-
import"./cli-
|
|
4
|
+
} from "./cli-ca32n52j.js";
|
|
5
|
+
import"./cli-1kv5sydm.js";
|
|
6
6
|
import"./cli-q25ejbyn.js";
|
|
7
7
|
import {
|
|
8
8
|
getDb,
|
|
9
9
|
init_db
|
|
10
|
-
} from "./cli-
|
|
10
|
+
} from "./cli-x2hk4m81.js";
|
|
11
11
|
import"./cli-z2zcxes1.js";
|
|
12
|
-
import"./cli-
|
|
12
|
+
import"./cli-zvbxe7pf.js";
|
|
13
13
|
import"./cli-4j2mrzag.js";
|
|
14
14
|
import"./cli-bw80ck94.js";
|
|
15
15
|
import"./cli-xz9aq0rf.js";
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_env_flag,
|
|
3
|
+
isEnvFlagEnabled
|
|
4
|
+
} from "./cli-x2hk4m81.js";
|
|
1
5
|
import {
|
|
2
6
|
init_zod
|
|
3
7
|
} from "./cli-bw80ck94.js";
|
|
@@ -229,8 +233,9 @@ var PERMISSION_VERBS = Object.keys(PERMISSIONS);
|
|
|
229
233
|
var PermissionVerbSchema = _enum(PERMISSION_VERBS);
|
|
230
234
|
|
|
231
235
|
// src/rbac/admission.ts
|
|
236
|
+
init_env_flag();
|
|
232
237
|
function isRbacEnabled() {
|
|
233
|
-
return
|
|
238
|
+
return isEnvFlagEnabled("RBAC_ENABLED", false);
|
|
234
239
|
}
|
|
235
240
|
function decideAdmission(input) {
|
|
236
241
|
if (input.grant.grantsAll) {
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
getDb,
|
|
7
7
|
init_db,
|
|
8
8
|
isSqliteVecAvailable
|
|
9
|
-
} from "./cli-
|
|
9
|
+
} from "./cli-x2hk4m81.js";
|
|
10
10
|
import {
|
|
11
11
|
__esm,
|
|
12
12
|
__export,
|
|
@@ -21,6 +21,21 @@ function numEnv(key, fallback) {
|
|
|
21
21
|
const parsed = Number(val);
|
|
22
22
|
return Number.isNaN(parsed) ? fallback : parsed;
|
|
23
23
|
}
|
|
24
|
+
function recencyDecayHalfLifeDays(source = "task_completion") {
|
|
25
|
+
const raw = process.env.MEMORY_RECENCY_HALF_LIFE_DAYS;
|
|
26
|
+
if (raw != null && raw !== "") {
|
|
27
|
+
const parsed = Number(raw);
|
|
28
|
+
if (Number.isFinite(parsed))
|
|
29
|
+
return parsed;
|
|
30
|
+
}
|
|
31
|
+
return DEFAULT_RECENCY_DECAY_HALF_LIFE[source];
|
|
32
|
+
}
|
|
33
|
+
function minSimilarity() {
|
|
34
|
+
return numEnv("MEMORY_MIN_SIMILARITY", 0.1);
|
|
35
|
+
}
|
|
36
|
+
function accessBoostMaxMultiplier() {
|
|
37
|
+
return numEnv("MEMORY_ACCESS_BOOST_MAX", 1.5);
|
|
38
|
+
}
|
|
24
39
|
function isHybridSearchEnabled() {
|
|
25
40
|
const val = process.env.MEMORY_HYBRID_SEARCH?.trim().toLowerCase();
|
|
26
41
|
return val !== "0" && val !== "false";
|
|
@@ -29,7 +44,7 @@ function isGraphExpansionEnabled() {
|
|
|
29
44
|
const val = process.env.MEMORY_GRAPH_EXPANSION?.trim().toLowerCase();
|
|
30
45
|
return val !== "0" && val !== "false";
|
|
31
46
|
}
|
|
32
|
-
var TTL_DEFAULTS,
|
|
47
|
+
var TTL_DEFAULTS, DEFAULT_RECENCY_DECAY_HALF_LIFE, SOURCE_QUALITY_MULTIPLIER, ACCESS_BOOST_RECENCY_WINDOW_HOURS, CANDIDATE_SET_MULTIPLIER, EMBEDDING_DIMENSIONS, DEFAULT_EMBEDDING_MODEL = "openai/text-embedding-3-small", PROTECTED_SOURCES;
|
|
33
48
|
var init_constants = __esm(() => {
|
|
34
49
|
TTL_DEFAULTS = {
|
|
35
50
|
task_completion: 7,
|
|
@@ -37,28 +52,18 @@ var init_constants = __esm(() => {
|
|
|
37
52
|
file_index: 30,
|
|
38
53
|
manual: null
|
|
39
54
|
};
|
|
40
|
-
|
|
41
|
-
GLOBAL_HALF_LIFE = GLOBAL_HALF_LIFE_OVERRIDE != null && GLOBAL_HALF_LIFE_OVERRIDE !== "" ? Number(GLOBAL_HALF_LIFE_OVERRIDE) : null;
|
|
42
|
-
RECENCY_DECAY_HALF_LIFE = GLOBAL_HALF_LIFE != null && Number.isFinite(GLOBAL_HALF_LIFE) ? {
|
|
43
|
-
manual: GLOBAL_HALF_LIFE,
|
|
44
|
-
file_index: GLOBAL_HALF_LIFE,
|
|
45
|
-
task_completion: GLOBAL_HALF_LIFE,
|
|
46
|
-
session_summary: GLOBAL_HALF_LIFE
|
|
47
|
-
} : {
|
|
55
|
+
DEFAULT_RECENCY_DECAY_HALF_LIFE = {
|
|
48
56
|
manual: Number.POSITIVE_INFINITY,
|
|
49
57
|
file_index: 180,
|
|
50
58
|
task_completion: 14,
|
|
51
59
|
session_summary: 7
|
|
52
60
|
};
|
|
53
|
-
RECENCY_DECAY_HALF_LIFE_DAYS = RECENCY_DECAY_HALF_LIFE.task_completion;
|
|
54
61
|
SOURCE_QUALITY_MULTIPLIER = {
|
|
55
62
|
manual: 1.5,
|
|
56
63
|
file_index: 1,
|
|
57
64
|
task_completion: 0.7,
|
|
58
65
|
session_summary: 0.5
|
|
59
66
|
};
|
|
60
|
-
MIN_SIMILARITY = numEnv("MEMORY_MIN_SIMILARITY", 0.1);
|
|
61
|
-
ACCESS_BOOST_MAX_MULTIPLIER = numEnv("MEMORY_ACCESS_BOOST_MAX", 1.5);
|
|
62
67
|
ACCESS_BOOST_RECENCY_WINDOW_HOURS = numEnv("MEMORY_ACCESS_RECENCY_HOURS", 48);
|
|
63
68
|
CANDIDATE_SET_MULTIPLIER = numEnv("MEMORY_CANDIDATE_MULTIPLIER", 3);
|
|
64
69
|
EMBEDDING_DIMENSIONS = numEnv("EMBEDDING_DIMENSIONS", 512);
|
|
@@ -6543,7 +6548,7 @@ var init_embedding = () => {};
|
|
|
6543
6548
|
|
|
6544
6549
|
// src/be/memory/reranker.ts
|
|
6545
6550
|
function recencyDecay(createdAt, now, source) {
|
|
6546
|
-
const halfLife = source
|
|
6551
|
+
const halfLife = recencyDecayHalfLifeDays(source);
|
|
6547
6552
|
if (!Number.isFinite(halfLife))
|
|
6548
6553
|
return 1;
|
|
6549
6554
|
const ageDays = (now.getTime() - new Date(createdAt).getTime()) / MS_PER_DAY;
|
|
@@ -6556,7 +6561,7 @@ function accessBoost(accessedAt, accessCount, now) {
|
|
|
6556
6561
|
return 1;
|
|
6557
6562
|
const hoursSinceAccess = (now.getTime() - new Date(accessedAt).getTime()) / MS_PER_HOUR;
|
|
6558
6563
|
const recencyFactor = hoursSinceAccess <= ACCESS_BOOST_RECENCY_WINDOW_HOURS ? 1 : 0.5;
|
|
6559
|
-
const boost = 1 + Math.min(accessCount / 10,
|
|
6564
|
+
const boost = 1 + Math.min(accessCount / 10, accessBoostMaxMultiplier() - 1) * recencyFactor;
|
|
6560
6565
|
return boost;
|
|
6561
6566
|
}
|
|
6562
6567
|
function sourceQuality(source) {
|
|
@@ -7038,7 +7043,7 @@ class SqliteMemoryStore {
|
|
|
7038
7043
|
const candidates = [];
|
|
7039
7044
|
for (const row of rows) {
|
|
7040
7045
|
const similarity = 1 - row.distance;
|
|
7041
|
-
if (similarity <
|
|
7046
|
+
if (similarity < minSimilarity())
|
|
7042
7047
|
continue;
|
|
7043
7048
|
candidates.push({ ...rowToCandidate(row, similarity), retrievalSource: "vec" });
|
|
7044
7049
|
}
|
|
@@ -7067,7 +7072,7 @@ class SqliteMemoryStore {
|
|
|
7067
7072
|
if (emb.length !== queryEmbedding.length)
|
|
7068
7073
|
continue;
|
|
7069
7074
|
const similarity = cosineSimilarity(queryEmbedding, emb);
|
|
7070
|
-
if (similarity <
|
|
7075
|
+
if (similarity < minSimilarity())
|
|
7071
7076
|
continue;
|
|
7072
7077
|
candidates.push({ ...rowToCandidate(row, similarity), retrievalSource: "fallback" });
|
|
7073
7078
|
}
|
|
@@ -4,15 +4,15 @@ import {
|
|
|
4
4
|
handleScheduleTrigger,
|
|
5
5
|
runScript,
|
|
6
6
|
startWorkflowExecution
|
|
7
|
-
} from "./cli-
|
|
7
|
+
} from "./cli-2e5t0yjj.js";
|
|
8
8
|
import {
|
|
9
9
|
getScript,
|
|
10
10
|
getScriptApiConnectionDescriptors,
|
|
11
11
|
getScriptMcpConnectionDescriptors
|
|
12
|
-
} from "./cli-
|
|
12
|
+
} from "./cli-sj43m5z0.js";
|
|
13
13
|
import {
|
|
14
14
|
createTaskWithSiblingAwareness
|
|
15
|
-
} from "./cli-
|
|
15
|
+
} from "./cli-1cah98w1.js";
|
|
16
16
|
import {
|
|
17
17
|
getDb,
|
|
18
18
|
getDueScheduledTasks,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
scheduleContextKey,
|
|
25
25
|
telemetry,
|
|
26
26
|
updateScheduledTask
|
|
27
|
-
} from "./cli-
|
|
27
|
+
} from "./cli-x2hk4m81.js";
|
|
28
28
|
import {
|
|
29
29
|
__commonJS,
|
|
30
30
|
__require,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
ensureAuthorizationTokenOrThrow,
|
|
9
9
|
oauthAppRowToProviderConfig
|
|
10
|
-
} from "./cli-
|
|
10
|
+
} from "./cli-333x50bh.js";
|
|
11
11
|
import {
|
|
12
12
|
getScript,
|
|
13
13
|
getScriptApiConnectionDescriptors,
|
|
@@ -15,15 +15,15 @@ import {
|
|
|
15
15
|
getScriptVersion,
|
|
16
16
|
listRelationalCredentialBindings,
|
|
17
17
|
validateScriptImports
|
|
18
|
-
} from "./cli-
|
|
18
|
+
} from "./cli-sj43m5z0.js";
|
|
19
19
|
import {
|
|
20
20
|
getAuthorizationById,
|
|
21
21
|
getOAuthApp,
|
|
22
22
|
getOAuthAppById
|
|
23
|
-
} from "./cli-
|
|
23
|
+
} from "./cli-mb3gz7qr.js";
|
|
24
24
|
import {
|
|
25
25
|
withSiblingAwareness
|
|
26
|
-
} from "./cli-
|
|
26
|
+
} from "./cli-1cah98w1.js";
|
|
27
27
|
import {
|
|
28
28
|
getAppUrl
|
|
29
29
|
} from "./cli-dh55d5fg.js";
|
|
@@ -77,7 +77,7 @@ import {
|
|
|
77
77
|
updateWorkflowRun,
|
|
78
78
|
updateWorkflowRunStep,
|
|
79
79
|
workflowContextKey
|
|
80
|
-
} from "./cli-
|
|
80
|
+
} from "./cli-x2hk4m81.js";
|
|
81
81
|
import {
|
|
82
82
|
init_secret_scrubber,
|
|
83
83
|
isSensitiveKey,
|
|
@@ -650,8 +650,12 @@ async function runStepValidation(registry, stepNode, stepOutput, context, meta)
|
|
|
650
650
|
|
|
651
651
|
// src/workflows/engine.ts
|
|
652
652
|
var DEFAULT_TIMEOUT_MS = 30000;
|
|
653
|
-
|
|
654
|
-
|
|
653
|
+
function maxIterations() {
|
|
654
|
+
return Number(process.env.WORKFLOW_MAX_ITERATIONS) || 100;
|
|
655
|
+
}
|
|
656
|
+
function maxStepsPerRun() {
|
|
657
|
+
return Number(process.env.WORKFLOW_MAX_STEPS_PER_RUN) || 500;
|
|
658
|
+
}
|
|
655
659
|
|
|
656
660
|
class TriggerSchemaError extends Error {
|
|
657
661
|
validationErrors;
|
|
@@ -736,10 +740,10 @@ async function walkGraph(def, runId, ctx, startNodes, registry, workflowId, secr
|
|
|
736
740
|
}
|
|
737
741
|
}
|
|
738
742
|
const allSteps = getWorkflowRunStepsByRunId(runId);
|
|
739
|
-
if (allSteps.length >=
|
|
743
|
+
if (allSteps.length >= maxStepsPerRun()) {
|
|
740
744
|
updateWorkflowRun(runId, {
|
|
741
745
|
status: "failed",
|
|
742
|
-
error: `Circuit breaker: run exceeded ${
|
|
746
|
+
error: `Circuit breaker: run exceeded ${maxStepsPerRun()} total steps (WORKFLOW_MAX_STEPS_PER_RUN)`,
|
|
743
747
|
finishedAt: new Date().toISOString()
|
|
744
748
|
});
|
|
745
749
|
return;
|
|
@@ -764,10 +768,10 @@ async function walkGraph(def, runId, ctx, startNodes, registry, workflowId, secr
|
|
|
764
768
|
const executedInThisWalk = new Set;
|
|
765
769
|
while (pendingNodes.length > 0) {
|
|
766
770
|
nodeExecutionCount += pendingNodes.length;
|
|
767
|
-
if (nodeExecutionCount >
|
|
771
|
+
if (nodeExecutionCount > maxIterations()) {
|
|
768
772
|
updateWorkflowRun(runId, {
|
|
769
773
|
status: "failed",
|
|
770
|
-
error: `Max node executions (${
|
|
774
|
+
error: `Max node executions (${maxIterations()}) exceeded — possible infinite loop`,
|
|
771
775
|
finishedAt: new Date().toISOString()
|
|
772
776
|
});
|
|
773
777
|
return;
|
|
@@ -2623,7 +2627,7 @@ class HumanInTheLoopExecutor extends BaseExecutor {
|
|
|
2623
2627
|
}
|
|
2624
2628
|
if (notification.channel === "slack") {
|
|
2625
2629
|
try {
|
|
2626
|
-
const { getSlackApp } = await import("./app-
|
|
2630
|
+
const { getSlackApp } = await import("./app-pej7g57x.js");
|
|
2627
2631
|
const slackApp = getSlackApp();
|
|
2628
2632
|
if (!slackApp) {
|
|
2629
2633
|
console.warn("[HITL] Slack not initialized — cannot send notification");
|
|
@@ -2737,7 +2741,7 @@ class NotifyExecutor extends BaseExecutor {
|
|
|
2737
2741
|
}
|
|
2738
2742
|
}
|
|
2739
2743
|
case "slack": {
|
|
2740
|
-
const { getSlackApp } = await import("./app-
|
|
2744
|
+
const { getSlackApp } = await import("./app-pej7g57x.js");
|
|
2741
2745
|
const app = getSlackApp();
|
|
2742
2746
|
if (!app) {
|
|
2743
2747
|
return {
|
|
@@ -185,13 +185,23 @@ var MAX_VISIBLE_CHILDREN = 8;
|
|
|
185
185
|
var MAX_OUTPUT_LENGTH = 120;
|
|
186
186
|
function truncateOutput(text) {
|
|
187
187
|
const sentenceEnd = text.search(/\.\s/);
|
|
188
|
-
const
|
|
189
|
-
if (
|
|
190
|
-
return
|
|
191
|
-
|
|
192
|
-
|
|
188
|
+
const sentenceCut = sentenceEnd !== -1 ? sentenceEnd + 1 : text.length;
|
|
189
|
+
if (sentenceCut === text.length && text.length <= MAX_OUTPUT_LENGTH) {
|
|
190
|
+
return { text, truncated: false };
|
|
191
|
+
}
|
|
192
|
+
let cut = Math.min(sentenceCut, MAX_OUTPUT_LENGTH);
|
|
193
|
+
if (cut === MAX_OUTPUT_LENGTH) {
|
|
194
|
+
const boundary = text.lastIndexOf(" ", MAX_OUTPUT_LENGTH);
|
|
195
|
+
cut = boundary >= MAX_OUTPUT_LENGTH / 2 ? boundary : MAX_OUTPUT_LENGTH;
|
|
196
|
+
}
|
|
193
197
|
const omitted = text.length - cut;
|
|
194
|
-
return
|
|
198
|
+
return {
|
|
199
|
+
text: `${text.slice(0, cut).trimEnd()}… (${omitted} more chars; open task for full output)`,
|
|
200
|
+
truncated: true
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function isTreeOutputTruncated(text) {
|
|
204
|
+
return truncateOutput(text).truncated;
|
|
195
205
|
}
|
|
196
206
|
function renderNodeLine(node) {
|
|
197
207
|
const icon = STATUS_ICON[node.status] ?? "•";
|
|
@@ -212,7 +222,7 @@ function renderChildDetail(node, indent) {
|
|
|
212
222
|
lines.push(`${indent}${node.progress}`);
|
|
213
223
|
}
|
|
214
224
|
if (node.status === "completed" && !node.slackReplySent && node.output) {
|
|
215
|
-
lines.push(`${indent}${truncateOutput(markdownToSlack(node.output))}`);
|
|
225
|
+
lines.push(`${indent}${truncateOutput(markdownToSlack(node.output)).text}`);
|
|
216
226
|
}
|
|
217
227
|
return lines;
|
|
218
228
|
}
|
|
@@ -227,7 +237,7 @@ function renderTree(root) {
|
|
|
227
237
|
lines.push(` Error: ${root.failureReason}`);
|
|
228
238
|
}
|
|
229
239
|
if (root.status === "completed" && !root.slackReplySent && root.output) {
|
|
230
|
-
lines.push(` ${truncateOutput(markdownToSlack(root.output))}`);
|
|
240
|
+
lines.push(` ${truncateOutput(markdownToSlack(root.output)).text}`);
|
|
231
241
|
}
|
|
232
242
|
return lines.join(`
|
|
233
243
|
`);
|
|
@@ -296,4 +306,4 @@ function buildTreeBlocks(roots) {
|
|
|
296
306
|
return blocks;
|
|
297
307
|
}
|
|
298
308
|
|
|
299
|
-
export { getTaskLink, markdownToSlack, splitSlackSectionText, formatAttachmentsBlockForSlack, formatDuration, buildCompletedBlocks, buildCompletedBlockBatches, buildFailedBlocks, buildProgressBlocks, buildCancelledBlocks, buildBufferFlushBlocks, buildTreeBlocks };
|
|
309
|
+
export { getTaskLink, markdownToSlack, splitSlackSectionText, formatAttachmentsBlockForSlack, formatDuration, buildCompletedBlocks, buildCompletedBlockBatches, buildFailedBlocks, buildProgressBlocks, buildCancelledBlocks, buildBufferFlushBlocks, isTreeOutputTruncated, buildTreeBlocks };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getDb,
|
|
3
3
|
init_db
|
|
4
|
-
} from "./cli-
|
|
4
|
+
} from "./cli-x2hk4m81.js";
|
|
5
5
|
|
|
6
6
|
// src/be/seed-pricing.ts
|
|
7
7
|
init_db();
|
|
@@ -195,4 +195,4 @@ function seedPricingFromModelsDev(opts) {
|
|
|
195
195
|
return { inserted, modelsdevFound: !!cache };
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
export { normalizeModelKey, buildModelsDevSeedRows, seedPricingFromModelsDev };
|
|
198
|
+
export { loadModelsDevCache, normalizeModelKey, buildModelsDevSeedRows, seedPricingFromModelsDev };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
-
buildModelsDevSeedRows
|
|
3
|
-
|
|
2
|
+
buildModelsDevSeedRows,
|
|
3
|
+
loadModelsDevCache
|
|
4
|
+
} from "./cli-7qvpf14x.js";
|
|
4
5
|
import {
|
|
5
6
|
createLogEntry,
|
|
6
7
|
getActivePricingRow,
|
|
7
8
|
getDb,
|
|
8
9
|
init_db,
|
|
9
10
|
insertPricingRow
|
|
10
|
-
} from "./cli-
|
|
11
|
+
} from "./cli-x2hk4m81.js";
|
|
11
12
|
import {
|
|
12
13
|
init_secret_scrubber,
|
|
13
14
|
scrubSecrets
|
|
@@ -16,6 +17,90 @@ import {
|
|
|
16
17
|
// src/be/pricing-refresh.ts
|
|
17
18
|
init_secret_scrubber();
|
|
18
19
|
init_db();
|
|
20
|
+
|
|
21
|
+
// src/be/models-catalog.ts
|
|
22
|
+
var CATALOG_PROVIDER_IDS = [
|
|
23
|
+
"openrouter",
|
|
24
|
+
"anthropic",
|
|
25
|
+
"openai",
|
|
26
|
+
"amazon-bedrock"
|
|
27
|
+
];
|
|
28
|
+
var PINNED_MODELSDEV_ENTRIES = [
|
|
29
|
+
"anthropic/claude-mythos-5",
|
|
30
|
+
"anthropic/claude-sonnet-5",
|
|
31
|
+
"amazon-bedrock/anthropic.claude-sonnet-5"
|
|
32
|
+
];
|
|
33
|
+
function slimModel(modelKey, model) {
|
|
34
|
+
const reasoningOptions = Array.isArray(model.reasoning_options) ? model.reasoning_options.filter((o) => typeof o.type === "string").map((o) => ({
|
|
35
|
+
type: o.type,
|
|
36
|
+
...Array.isArray(o.values) ? { values: o.values } : {}
|
|
37
|
+
})) : [];
|
|
38
|
+
return {
|
|
39
|
+
id: model.id ?? modelKey,
|
|
40
|
+
...model.name !== undefined ? { name: model.name } : {},
|
|
41
|
+
...model.cost !== undefined ? { cost: { input: model.cost.input, output: model.cost.output } } : {},
|
|
42
|
+
...model.limit?.context !== undefined ? { limit: { context: model.limit.context } } : {},
|
|
43
|
+
...model.reasoning !== undefined ? { reasoning: model.reasoning } : {},
|
|
44
|
+
...reasoningOptions.length > 0 ? { reasoning_options: reasoningOptions } : {}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function buildModelsCatalog(cache) {
|
|
48
|
+
const catalog = {};
|
|
49
|
+
for (const providerId of CATALOG_PROVIDER_IDS) {
|
|
50
|
+
const provider = cache[providerId];
|
|
51
|
+
if (!provider?.models)
|
|
52
|
+
continue;
|
|
53
|
+
const models = {};
|
|
54
|
+
for (const [modelKey, model] of Object.entries(provider.models)) {
|
|
55
|
+
models[modelKey] = slimModel(modelKey, model);
|
|
56
|
+
}
|
|
57
|
+
catalog[providerId] = {
|
|
58
|
+
id: provider.id ?? providerId,
|
|
59
|
+
...provider.name !== undefined ? { name: provider.name } : {},
|
|
60
|
+
models
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return catalog;
|
|
64
|
+
}
|
|
65
|
+
var liveCatalog = null;
|
|
66
|
+
var liveUpdatedAt = null;
|
|
67
|
+
var snapshotCatalog;
|
|
68
|
+
function bundledSnapshotCatalog() {
|
|
69
|
+
if (snapshotCatalog === undefined) {
|
|
70
|
+
const raw = loadModelsDevCache();
|
|
71
|
+
snapshotCatalog = raw ? buildModelsCatalog(raw) : null;
|
|
72
|
+
}
|
|
73
|
+
return snapshotCatalog ?? {};
|
|
74
|
+
}
|
|
75
|
+
function mergePinnedEntries(catalog) {
|
|
76
|
+
const snapshot = bundledSnapshotCatalog();
|
|
77
|
+
for (const entryPath of PINNED_MODELSDEV_ENTRIES) {
|
|
78
|
+
const slashIndex = entryPath.indexOf("/");
|
|
79
|
+
const providerId = entryPath.slice(0, slashIndex);
|
|
80
|
+
const modelId = entryPath.slice(slashIndex + 1);
|
|
81
|
+
if (catalog[providerId]?.models[modelId])
|
|
82
|
+
continue;
|
|
83
|
+
const pinned = snapshot[providerId]?.models[modelId];
|
|
84
|
+
if (!pinned)
|
|
85
|
+
continue;
|
|
86
|
+
catalog[providerId] ??= { id: providerId, models: {} };
|
|
87
|
+
catalog[providerId].models[modelId] = pinned;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function updateLiveModelsCatalog(cache, now = Date.now()) {
|
|
91
|
+
const catalog = buildModelsCatalog(cache);
|
|
92
|
+
mergePinnedEntries(catalog);
|
|
93
|
+
liveCatalog = catalog;
|
|
94
|
+
liveUpdatedAt = now;
|
|
95
|
+
}
|
|
96
|
+
function getModelsCatalog() {
|
|
97
|
+
if (liveCatalog) {
|
|
98
|
+
return { source: "live", updatedAt: liveUpdatedAt, providers: liveCatalog };
|
|
99
|
+
}
|
|
100
|
+
return { source: "snapshot", updatedAt: null, providers: bundledSnapshotCatalog() };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// src/be/pricing-refresh.ts
|
|
19
104
|
var MODELSDEV_API_URL = "https://models.dev/api.json";
|
|
20
105
|
var PRICING_REFRESH_INTERVAL_MS = 12 * 60 * 60 * 1000;
|
|
21
106
|
var lastETag = null;
|
|
@@ -116,6 +201,7 @@ async function refreshPricingFromModelsDev(opts = {}) {
|
|
|
116
201
|
}
|
|
117
202
|
const cache = await response.json();
|
|
118
203
|
const etag = response.headers.get("etag");
|
|
204
|
+
updateLiveModelsCatalog(cache, now);
|
|
119
205
|
const rows = buildModelsDevSeedRows(cache);
|
|
120
206
|
const { inserted, unchanged } = insertChangedPricingRows(rows, now);
|
|
121
207
|
const pruned = prunePricingHistory(2);
|
|
@@ -151,4 +237,4 @@ function startPricingRefreshLoop() {
|
|
|
151
237
|
interval.unref?.();
|
|
152
238
|
}
|
|
153
239
|
|
|
154
|
-
export { PRICING_REFRESH_INTERVAL_MS, refreshPricingFromModelsDev, startPricingRefreshLoop };
|
|
240
|
+
export { getModelsCatalog, PRICING_REFRESH_INTERVAL_MS, refreshPricingFromModelsDev, startPricingRefreshLoop };
|