@desplega.ai/agent-swarm 1.157.0 → 1.158.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/dist/{acp-adapter-qhqrk4q0.js → acp-adapter-xaq4n6pc.js} +1 -1
- package/dist/{actions-9rrg0zxm.js → actions-p9hz5yat.js} +15 -15
- package/dist/{app-enysy1zd.js → app-g26wdcz6.js} +4 -4
- package/dist/{artifact-td4q4dch.js → artifact-3v5t9jtg.js} +1 -1
- package/dist/{assistant-zegamy48.js → assistant-wydfqkb3.js} +16 -16
- package/dist/{boot-reembed-r6shx5qx.js → boot-reembed-g5ckg9yb.js} +6 -6
- package/dist/{boot-reembed-zfxb937k.js → boot-reembed-se8zmdcp.js} +5 -5
- package/dist/{boot-scrub-logs-k5y0se6r.js → boot-scrub-logs-wfxqan61.js} +3 -3
- package/dist/{seed-pricing-vqxa06qf.js → boot-seeds-s3q01xj3.js} +10 -10
- package/dist/{claude-adapter-5yc7hxwv.js → claude-adapter-tv2x4f36.js} +7 -7
- package/dist/{claude-managed-adapter-ea2aga6w.js → claude-managed-adapter-41b2s7fd.js} +2 -2
- package/dist/{claude-sdk-session-j4ywn3xf.js → claude-sdk-session-t442qz6f.js} +8 -8
- package/dist/{cli-e781c6f9.js → cli-0xjkj1j7.js} +1 -0
- package/dist/{cli-58rgvkt4.js → cli-1hkrch3k.js} +2 -2
- package/dist/{cli-yscm6cv8.js → cli-20cj37vt.js} +1866 -9
- package/dist/{cli-h0wdadsx.js → cli-4198qc9v.js} +7 -3
- package/dist/{cli-awwphhcs.js → cli-47m6dkd3.js} +362 -126
- package/dist/{cli-wb2zvbfg.js → cli-53sz8gkz.js} +1 -1
- package/dist/{cli-005pze6s.js → cli-5d10vd2m.js} +1 -1
- package/dist/{cli-v53rbqp3.js → cli-65hjmev5.js} +57 -17
- package/dist/{cli-scwq51gn.js → cli-68w09sjw.js} +7 -1
- package/dist/{cli-s98skd5r.js → cli-7gtvvpbh.js} +4 -4
- package/dist/{cli-y3nxwx0t.js → cli-7s3syk22.js} +18 -11
- package/dist/{cli-74h6f2bp.js → cli-8qmme6vd.js} +2 -2
- package/dist/{cli-wsed24mk.js → cli-987hg0aa.js} +2 -2
- package/dist/{cli-9n76jszt.js → cli-9httdpyq.js} +1 -1
- package/dist/{cli-f3va018d.js → cli-aky8tctm.js} +26 -93
- package/dist/{cli-sgyqyyxe.js → cli-c07r9a2m.js} +2 -1
- package/dist/{cli-c41wjx0r.js → cli-fgqxwrpv.js} +291 -12
- package/dist/{cli-01vfmq8c.js → cli-ftfvggzx.js} +607 -164
- package/dist/{cli-ytxs7mn1.js → cli-g8djp6qe.js} +17 -0
- package/dist/{cli-avkd6mqv.js → cli-h967nb6r.js} +551 -0
- package/dist/{cli-r9ee9c4w.js → cli-j55n64b6.js} +23 -22
- package/dist/{cli-9p33cz9h.js → cli-j57qkrpq.js} +86 -28
- package/dist/{cli-tjmghmm5.js → cli-q67y4wzm.js} +6 -3
- package/dist/{cli-n6zq3kbd.js → cli-rj19hc34.js} +1 -1
- package/dist/{cli-jytrw2na.js → cli-rjehvrts.js} +4 -4
- package/dist/{cli-tpv97m71.js → cli-rqz8qbw7.js} +245 -75
- package/dist/{cli-p37sg0a9.js → cli-s8eet254.js} +1 -1
- package/dist/cli-t1ze64h3.js +811 -0
- package/dist/{cli-6jjzxv3b.js → cli-ws6rqycm.js} +3 -2
- package/dist/{cli-xf5b7y1f.js → cli-wscdvcqz.js} +13 -5
- package/dist/{cli-5j7bm4tb.js → cli-x24pshtq.js} +5 -5
- package/dist/{cli-nbp6m6gp.js → cli-xberxa1r.js} +51 -26
- package/dist/{cli-vx9p3qdt.js → cli-xhaeg2nc.js} +1 -1
- package/dist/cli.js +29 -15
- package/dist/{codex-adapter-gns3s6c3.js → codex-adapter-cnm8wk11.js} +5 -5
- package/dist/{codex-session-runner-gqnxys5w.js → codex-session-runner-gfg547zj.js} +5 -5
- package/dist/{commands-hxy2y2sp.js → commands-e3bn0p75.js} +3 -3
- package/dist/{db-w8ghhsgf.js → db-03v9kzr2.js} +17 -3
- package/dist/{dispatcher-cp1rknjz.js → dispatcher-nrmg8yht.js} +14 -14
- package/dist/{dsh-adapter-1dwg97zv.js → dsh-adapter-k03nfqa6.js} +2 -2
- package/dist/{handlers-egfhr351.js → handlers-aqcedbyb.js} +17 -17
- package/dist/{hook-x4kftwzt.js → hook-7vkskkre.js} +19 -11
- package/dist/{hook-fbxjqfjz.js → hook-ybvmrmhq.js} +4 -4
- package/dist/{http-c7jfx990.js → http-2eqa8t24.js} +432 -195
- package/dist/{index-4k9hct21.js → index-1yks3qcr.js} +14 -14
- package/dist/{index-jtvpgb8f.js → index-a3vn96n8.js} +30 -27
- package/dist/{index-dc2ek6bw.js → index-c6zsv1bd.js} +5 -5
- package/dist/{index-yy07ef2s.js → index-chgdkq36.js} +14 -14
- package/dist/{index-r6bty6tb.js → index-x71bvq0p.js} +15 -15
- package/dist/{keepalive-f7ekefyc.js → keepalive-vtkf5n99.js} +5 -5
- package/dist/{lead-h053syts.js → lead-h3sp357x.js} +26 -26
- package/dist/{maintenance-a3w6zs54.js → maintenance-jzeqtk3q.js} +6 -6
- package/dist/{oauth-refresh-sweep-vra1dhkd.js → oauth-refresh-sweep-qp3dzmdp.js} +4 -4
- package/dist/{onboard-mfgzeqxs.js → onboard-tmsp0qbz.js} +278 -81
- package/dist/{opencode-adapter-z64xjzec.js → opencode-adapter-x6x2da1z.js} +3 -3
- package/dist/{otel-impl-2ez6xk57.js → otel-impl-9mz73q65.js} +416 -301
- package/dist/{pi-mono-adapter-2b7mw16r.js → pi-mono-adapter-m6dvv0dz.js} +2 -2
- package/dist/{pricing-refresh-6sw65tck.js → pricing-refresh-v1cbr9te.js} +5 -5
- package/dist/{rbac-roles-nm6924sy.js → rbac-roles-c9wqz83x.js} +4 -4
- package/dist/{render-v2-f026j6c4.js → render-v2-gryrh9h8.js} +4 -4
- package/dist/{setup-w606fr1q.js → setup-q9720bt6.js} +2 -2
- package/dist/{virtual-modules-8qheft18.js → virtual-modules-3htpgn8x.js} +1 -1
- package/dist/{work-objects-ezmggdne.js → work-objects-b76x7deb.js} +17 -17
- package/dist/{worker-1mbyv29k.js → worker-6vrxbv41.js} +26 -26
- package/openapi.json +1626 -629
- package/package.json +2 -1
- package/src/apps/catalog.generated.json +229 -0
- package/src/apps/page-validator.ts +71 -16
- package/src/apps/row-store.ts +66 -11
- package/src/apps/sync.ts +59 -17
- package/src/artifact-sdk/browser-sdk.ts +436 -2
- package/src/be/approval-sweeps.ts +109 -0
- package/src/be/boot-seeds.ts +40 -0
- package/src/be/chunking.ts +1 -1
- package/src/be/db/agents.ts +20 -0
- package/src/be/db/approvals.ts +78 -0
- package/src/be/db/tasks/read.ts +197 -39
- package/src/be/db/tasks/write.ts +41 -9
- package/src/be/db-client.ts +107 -48
- package/src/be/db.ts +219 -76
- package/src/be/events.ts +33 -1
- package/src/be/memory/graph-expansion.ts +10 -3
- package/src/be/memory/providers/sqlite-store.ts +55 -13
- package/src/be/memory/raters/retrieval.ts +5 -2
- package/src/be/memory/reranker.ts +26 -2
- package/src/be/memory/types.ts +2 -0
- package/src/be/migrations/166_approval_request_auto_cancellation.sql +9 -0
- package/src/be/migrations/171_memory_retrieval_relevance.sql +8 -0
- package/src/be/migrations/175_workflow_runs_list_index.sql +11 -0
- package/src/be/migrations/177_events_event_agent_created_index.sql +11 -0
- package/src/be/models-catalog.ts +2 -0
- package/src/be/modelsdev-cache.json +1857 -0
- package/src/be/modelsdev-cache.ts +14 -1
- package/src/be/pricing-normalize.ts +2 -0
- package/src/be/scripts/typecheck.ts +1 -0
- package/src/be/seed-pricing.ts +3 -1
- package/src/be/seed-skills/bundled-files.generated.json +1 -1
- package/src/be/steering.ts +53 -3
- package/src/be/swarm-config-guard.ts +3 -0
- package/src/be/task-citations.ts +29 -0
- package/src/cli.tsx +14 -1
- package/src/commands/onboard/compose-generator.ts +8 -3
- package/src/commands/onboard/container-engine.ts +220 -0
- package/src/commands/onboard/manifest.ts +1 -0
- package/src/commands/onboard/steps/health-check.tsx +4 -1
- package/src/commands/onboard/steps/prereq-check.tsx +50 -54
- package/src/commands/onboard/steps/start.tsx +31 -16
- package/src/commands/onboard/types.ts +7 -2
- package/src/commands/onboard.tsx +39 -4
- package/src/commands/profile-sync.ts +79 -26
- package/src/commands/runner.ts +8 -1
- package/src/extensions/catalog.generated.json +17 -0
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/heartbeat/heartbeat.ts +263 -103
- package/src/hooks/hook.ts +21 -12
- package/src/http/agents.ts +35 -0
- package/src/http/approval-requests.ts +136 -64
- package/src/http/apps.ts +14 -3
- package/src/http/config.ts +15 -1
- package/src/http/events.ts +62 -2
- package/src/http/index.ts +6 -4
- package/src/http/memory.ts +21 -7
- package/src/http/schedules.ts +1 -1
- package/src/http/session-data.ts +9 -4
- package/src/http/sessions.ts +25 -18
- package/src/http/stats.ts +19 -7
- package/src/http/status.ts +11 -1
- package/src/http/tasks.ts +40 -8
- package/src/http/webhooks.ts +67 -46
- package/src/http/workflows.ts +15 -20
- package/src/linear/outbound.ts +37 -15
- package/src/otel-impl.ts +151 -1
- package/src/otel.ts +14 -3
- package/src/prompts/memories.ts +19 -2
- package/src/providers/claude-managed-models.ts +8 -0
- package/src/providers/modelsdev-reasoning.json +551 -0
- package/src/rbac/legacy-policy.ts +16 -0
- package/src/rbac/permissions.ts +4 -0
- package/src/scheduler/schedule-task.ts +3 -0
- package/src/scripts-runtime/sdk-allowlist.ts +1 -0
- package/src/scripts-runtime/swarm-sdk.ts +9 -0
- package/src/scripts-runtime/types/stdlib.d.ts +1 -0
- package/src/scripts-runtime/types/swarm-extension.d.ts +1 -0
- package/src/scripts-runtime/types/swarm-sdk.d.ts +1 -0
- package/src/server.ts +12 -7
- package/src/slack/app.ts +35 -4
- package/src/slack/connection-state.ts +17 -0
- package/src/tasks/context-key.ts +1 -0
- package/src/tasks/worker-follow-up.ts +6 -2
- package/src/tests/agent-task-activity.test.ts +74 -0
- package/src/tests/agents-list-model-display.test.ts +6 -1
- package/src/tests/approval-auto-cancellation-migration.test.ts +104 -0
- package/src/tests/approval-requests.test.ts +395 -0
- package/src/tests/approval-sweeps-config.test.ts +47 -0
- package/src/tests/approval-sweeps.test.ts +508 -0
- package/src/tests/apps-kibo-blocks.test.ts +77 -0
- package/src/tests/apps-spike.test.ts +56 -1
- package/src/tests/apps-sync-engine.test.ts +20 -9
- package/src/tests/boot-seeds.test.ts +170 -0
- package/src/tests/cancel-approval-request-tool.test.ts +115 -0
- package/src/tests/claude-managed-adapter.test.ts +6 -0
- package/src/tests/config-key-filter.test.ts +80 -0
- package/src/tests/context-window.test.ts +1 -0
- package/src/tests/db-client-busy-retry.test.ts +96 -0
- package/src/tests/db-client.test.ts +60 -1
- package/src/tests/db-task-read-contract.test.ts +10 -0
- package/src/tests/db-task-write-contract.test.ts +9 -0
- package/src/tests/docs-index-footprint.test.js +3 -3
- package/src/tests/events-http.test.ts +103 -0
- package/src/tests/extensions-catalog.test.ts +22 -17
- package/src/tests/extensions-pre-task.test.ts +107 -0
- package/src/tests/fixtures/kibo-blocks-definition.json.txt +105 -0
- package/src/tests/follow-up-config-inheritance.test.ts +260 -0
- package/src/tests/heartbeat-orphan-resume.test.ts +84 -0
- package/src/tests/heartbeat-reboot-live.test.ts +95 -0
- package/src/tests/heartbeat-stall-cas.test.ts +80 -0
- package/src/tests/heartbeat.test.ts +99 -3
- package/src/tests/hook-mcp-config.test.ts +29 -0
- package/src/tests/http-api-integration.test.ts +16 -2
- package/src/tests/kv-storage.test.ts +62 -0
- package/src/tests/linear-outbound-sync.test.ts +120 -5
- package/src/tests/list-endpoint-slimming.test.ts +91 -0
- package/src/tests/memory-graph-organic-route.test.ts +155 -0
- package/src/tests/memory-http-recall-gating.test.ts +14 -4
- package/src/tests/memory-hybrid.test.ts +161 -1
- package/src/tests/memory-prompt-recall-crowdout.test.ts +297 -0
- package/src/tests/memory.test.ts +22 -0
- package/src/tests/onboard-container-engine.test.ts +240 -0
- package/src/tests/otel-event-loop-and-logs.test.ts +99 -0
- package/src/tests/pricing-routes.test.ts +14 -0
- package/src/tests/profile-sync-warning.test.ts +8 -4
- package/src/tests/promote-draft-task-route.test.ts +19 -0
- package/src/tests/provider-registration.test.ts +296 -42
- package/src/tests/rbac-engine.test.ts +30 -0
- package/src/tests/reasoning-effort.test.ts +8 -0
- package/src/tests/script-connections.test.ts +7 -0
- package/src/tests/sdk-allowlist.test.ts +39 -0
- package/src/tests/session-costs-model-key-normalize.test.ts +1 -0
- package/src/tests/sessions-detail-batch.test.ts +250 -0
- package/src/tests/sessions.test.ts +118 -0
- package/src/tests/slack-config.test.ts +22 -0
- package/src/tests/sonnet-5-5-registry.test.ts +44 -0
- package/src/tests/status.test.ts +36 -1
- package/src/tests/swarm-diff.test.ts +316 -10
- package/src/tests/task-completion-idempotency.test.ts +2 -1
- package/src/tests/tasks-requested-by-filter.test.ts +3 -1
- package/src/tests/tool-annotations.test.ts +1 -1
- package/src/tests/ui-list-slim-projections.test.ts +158 -0
- package/src/tests/webhooks-task-blocked.test.ts +127 -0
- package/src/tests/workflow-approval-recovery.test.ts +203 -0
- package/src/tests/workflow-hitl-routing.test.ts +22 -1
- package/src/tests/workflow-hitl-slack-card.test.ts +52 -0
- package/src/tests/workflow-http-v2.test.ts +99 -8
- package/src/tests/workflow-retry-validation.test.ts +56 -0
- package/src/tests/workflow-tla-races.test.ts +389 -0
- package/src/tests/workflow-validation-port-routing.test.ts +113 -1
- package/src/tools/cancel-approval-request.ts +57 -0
- package/src/tools/memory-search.ts +1 -0
- package/src/tools/request-human-input.ts +4 -2
- package/src/tools/send-task.ts +4 -0
- package/src/tools/templates.ts +19 -0
- package/src/tools/tool-config.ts +2 -1
- package/src/tools/workflows/list-workflow-runs.ts +1 -0
- package/src/types.ts +38 -0
- package/src/utils/context-window.ts +1 -0
- package/src/workflows/approval-cancel.ts +152 -0
- package/src/workflows/approval-notifications.ts +84 -0
- package/src/workflows/checkpoint.ts +10 -5
- package/src/workflows/definition.ts +21 -0
- package/src/workflows/engine.ts +152 -21
- package/src/workflows/executors/human-in-the-loop.ts +1 -1
- package/src/workflows/recovery.ts +100 -45
- package/src/workflows/resume.ts +49 -18
- package/src/workflows/retry-poller.ts +71 -21
- package/templates/extensions/README.md +1 -0
- package/templates/extensions/github-sender-allowlist/README.md +18 -0
- package/templates/extensions/github-sender-allowlist/hooks.ts +55 -0
- package/templates/extensions/github-sender-allowlist/manifest.json +8 -0
- package/templates/skills/apps/content.md +20 -1
- package/templates/skills/code-quality/content.md +26 -1
- package/templates/skills/pages/content.md +16 -4
- package/templates/skills/pages/files/examples/multiplayer-board.html +3 -12
- package/dist/cli-2daksqps.js +0 -378
- package/dist/rbac-roles-3gxmnb20.js +0 -37
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
normalizeAssetKey,
|
|
18
18
|
parseAssetKey,
|
|
19
19
|
parseModelTier
|
|
20
|
-
} from "./cli-
|
|
20
|
+
} from "./cli-4198qc9v.js";
|
|
21
21
|
import {
|
|
22
22
|
IdentityFieldBudgetError,
|
|
23
23
|
checkIdentityFieldBudget,
|
|
@@ -77,7 +77,7 @@ import {
|
|
|
77
77
|
import {
|
|
78
78
|
init_package,
|
|
79
79
|
package_default
|
|
80
|
-
} from "./cli-
|
|
80
|
+
} from "./cli-c07r9a2m.js";
|
|
81
81
|
import {
|
|
82
82
|
init_secret_scrubber,
|
|
83
83
|
registerVolatileSecret,
|
|
@@ -1364,6 +1364,21 @@ function isInTransaction() {
|
|
|
1364
1364
|
const store = txContext.getStore();
|
|
1365
1365
|
return store !== undefined && !store.closed;
|
|
1366
1366
|
}
|
|
1367
|
+
function warnIfSlowStatement(sql, durationMs) {
|
|
1368
|
+
if (durationMs < SLOW_STATEMENT_WARN_MS)
|
|
1369
|
+
return;
|
|
1370
|
+
const flat = sql.replace(/\s+/g, " ").trim();
|
|
1371
|
+
const shown = flat.length > SLOW_STATEMENT_SQL_MAX_CHARS ? `${flat.slice(0, SLOW_STATEMENT_SQL_MAX_CHARS)}…` : flat;
|
|
1372
|
+
console.warn(`[db-client] slow sync statement blocked the event loop for ${Math.round(durationMs)}ms: ${scrubSecrets(shown)}`);
|
|
1373
|
+
}
|
|
1374
|
+
function timedStatement(sql, run) {
|
|
1375
|
+
const startedAt = performance.now();
|
|
1376
|
+
try {
|
|
1377
|
+
return run();
|
|
1378
|
+
} finally {
|
|
1379
|
+
warnIfSlowStatement(sql, performance.now() - startedAt);
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1367
1382
|
function sleep(ms) {
|
|
1368
1383
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1369
1384
|
}
|
|
@@ -1388,20 +1403,20 @@ class BunSqliteClient {
|
|
|
1388
1403
|
this.busyRetry = busyRetry;
|
|
1389
1404
|
}
|
|
1390
1405
|
query(sql, params = []) {
|
|
1391
|
-
return this.execute((db) => db.query(sql).all(...params));
|
|
1406
|
+
return this.execute(sql, (db) => db.query(sql).all(...params));
|
|
1392
1407
|
}
|
|
1393
1408
|
get(sql, params = []) {
|
|
1394
|
-
return this.execute((db) => db.query(sql).get(...params));
|
|
1409
|
+
return this.execute(sql, (db) => db.query(sql).get(...params));
|
|
1395
1410
|
}
|
|
1396
1411
|
run(sql, params = []) {
|
|
1397
|
-
return this.execute((db) => {
|
|
1412
|
+
return this.execute(sql, (db) => {
|
|
1398
1413
|
const result = db.query(sql).run(...params);
|
|
1399
1414
|
return { changes: result.changes };
|
|
1400
1415
|
});
|
|
1401
1416
|
}
|
|
1402
1417
|
async runTimed(sql, params = []) {
|
|
1403
1418
|
let executionMs = 0;
|
|
1404
|
-
const result = await this.execute((db) => {
|
|
1419
|
+
const result = await this.execute(sql, (db) => {
|
|
1405
1420
|
const run = db.query(sql).run(...params);
|
|
1406
1421
|
return { changes: run.changes };
|
|
1407
1422
|
}, (ms) => {
|
|
@@ -1428,7 +1443,7 @@ class BunSqliteClient {
|
|
|
1428
1443
|
await sleep(jittered(backoff));
|
|
1429
1444
|
}
|
|
1430
1445
|
}
|
|
1431
|
-
async runTransactionAttempt(fn, readOnly,
|
|
1446
|
+
async runTransactionAttempt(fn, readOnly, finalAttempt = false) {
|
|
1432
1447
|
const release = await this.lock.acquire();
|
|
1433
1448
|
const ctx = { closed: false, afterCommit: [] };
|
|
1434
1449
|
let began = false;
|
|
@@ -1439,11 +1454,7 @@ class BunSqliteClient {
|
|
|
1439
1454
|
db.run("BEGIN");
|
|
1440
1455
|
} else {
|
|
1441
1456
|
try {
|
|
1442
|
-
|
|
1443
|
-
db.run("BEGIN IMMEDIATE");
|
|
1444
|
-
} else {
|
|
1445
|
-
this.shortSpin(db, () => db.run("BEGIN IMMEDIATE"));
|
|
1446
|
-
}
|
|
1457
|
+
this.shortSpin(db, () => db.run("BEGIN IMMEDIATE"), finalAttempt);
|
|
1447
1458
|
} catch (err) {
|
|
1448
1459
|
if (isSqliteBusy(err))
|
|
1449
1460
|
return { ok: false, busyBegin: err };
|
|
@@ -1511,15 +1522,20 @@ class BunSqliteClient {
|
|
|
1511
1522
|
throw err;
|
|
1512
1523
|
}
|
|
1513
1524
|
}
|
|
1514
|
-
async execute(op, recordExecutionMs) {
|
|
1515
|
-
const timed = (attempt) => {
|
|
1516
|
-
if (!recordExecutionMs)
|
|
1517
|
-
return attempt();
|
|
1525
|
+
async execute(sql, op, recordExecutionMs) {
|
|
1526
|
+
const timed = (attempt, retryable = false) => {
|
|
1518
1527
|
const startedAt = performance.now();
|
|
1528
|
+
let willRetry = false;
|
|
1519
1529
|
try {
|
|
1520
1530
|
return attempt();
|
|
1531
|
+
} catch (err) {
|
|
1532
|
+
willRetry = retryable && isSqliteBusy(err);
|
|
1533
|
+
throw err;
|
|
1521
1534
|
} finally {
|
|
1522
|
-
|
|
1535
|
+
const ms = performance.now() - startedAt;
|
|
1536
|
+
recordExecutionMs?.(ms);
|
|
1537
|
+
if (!willRetry)
|
|
1538
|
+
warnIfSlowStatement(sql, ms);
|
|
1523
1539
|
}
|
|
1524
1540
|
};
|
|
1525
1541
|
const ctx = txContext.getStore();
|
|
@@ -1533,7 +1549,7 @@ class BunSqliteClient {
|
|
|
1533
1549
|
const release = await this.lock.acquire();
|
|
1534
1550
|
let backoff = 0;
|
|
1535
1551
|
try {
|
|
1536
|
-
return timed(() =>
|
|
1552
|
+
return timed(() => this.shortSpin(this.getDatabase(), () => op(this.getDatabase()), !canRetryAfter), canRetryAfter);
|
|
1537
1553
|
} catch (err) {
|
|
1538
1554
|
if (!isSqliteBusy(err) || !canRetryAfter || next === undefined)
|
|
1539
1555
|
throw err;
|
|
@@ -1545,12 +1561,13 @@ class BunSqliteClient {
|
|
|
1545
1561
|
await sleep(jittered(backoff));
|
|
1546
1562
|
}
|
|
1547
1563
|
}
|
|
1548
|
-
shortSpin(db, attempt) {
|
|
1564
|
+
shortSpin(db, attempt, finalAttempt = false) {
|
|
1549
1565
|
if (this.restoreBusyTimeoutMs === null) {
|
|
1550
1566
|
const row = db.query("PRAGMA busy_timeout").get();
|
|
1551
1567
|
this.restoreBusyTimeoutMs = row?.timeout ?? 5000;
|
|
1552
1568
|
}
|
|
1553
|
-
|
|
1569
|
+
const spinMs = finalAttempt ? this.busyRetry.finalAttemptSpinMs ?? DEFAULT_FINAL_ATTEMPT_SPIN_MS : this.busyRetry.attemptSpinMs;
|
|
1570
|
+
db.exec(`PRAGMA busy_timeout = ${spinMs}`);
|
|
1554
1571
|
try {
|
|
1555
1572
|
return attempt();
|
|
1556
1573
|
} finally {
|
|
@@ -1581,10 +1598,10 @@ class BunSqliteClient {
|
|
|
1581
1598
|
return this.getDatabase();
|
|
1582
1599
|
};
|
|
1583
1600
|
return {
|
|
1584
|
-
query: async (sql, params = []) => guard().query(sql).all(...params),
|
|
1585
|
-
get: async (sql, params = []) => guard().query(sql).get(...params),
|
|
1601
|
+
query: async (sql, params = []) => timedStatement(sql, () => guard().query(sql).all(...params)),
|
|
1602
|
+
get: async (sql, params = []) => timedStatement(sql, () => guard().query(sql).get(...params)),
|
|
1586
1603
|
run: async (sql, params = []) => {
|
|
1587
|
-
const result = guard().query(sql).run(...params);
|
|
1604
|
+
const result = timedStatement(sql, () => guard().query(sql).run(...params));
|
|
1588
1605
|
return { changes: result.changes };
|
|
1589
1606
|
}
|
|
1590
1607
|
};
|
|
@@ -1593,13 +1610,15 @@ class BunSqliteClient {
|
|
|
1593
1610
|
function createBunSqliteClient(getDatabase, busyRetry) {
|
|
1594
1611
|
return new BunSqliteClient(getDatabase, busyRetry);
|
|
1595
1612
|
}
|
|
1596
|
-
var LOCK_WATCHDOG_MS = 30000, txContext, DEFAULT_BUSY_RETRY;
|
|
1613
|
+
var LOCK_WATCHDOG_MS = 30000, txContext, DEFAULT_FINAL_ATTEMPT_SPIN_MS = 250, DEFAULT_BUSY_RETRY, SLOW_STATEMENT_WARN_MS = 100, SLOW_STATEMENT_SQL_MAX_CHARS = 200;
|
|
1597
1614
|
var init_db_client = __esm(() => {
|
|
1615
|
+
init_secret_scrubber();
|
|
1598
1616
|
txContext = new AsyncLocalStorage2;
|
|
1599
1617
|
DEFAULT_BUSY_RETRY = {
|
|
1600
|
-
maxWaitMs:
|
|
1601
|
-
backoffMs: [25, 50, 100, 250, 500
|
|
1602
|
-
attemptSpinMs: 100
|
|
1618
|
+
maxWaitMs: 11000,
|
|
1619
|
+
backoffMs: [25, 50, 100, 250, ...Array(21).fill(500)],
|
|
1620
|
+
attemptSpinMs: 100,
|
|
1621
|
+
finalAttemptSpinMs: DEFAULT_FINAL_ATTEMPT_SPIN_MS
|
|
1603
1622
|
};
|
|
1604
1623
|
});
|
|
1605
1624
|
|
|
@@ -1942,6 +1961,24 @@ Continue your work based on the human's input.`,
|
|
|
1942
1961
|
],
|
|
1943
1962
|
category: "task_lifecycle"
|
|
1944
1963
|
});
|
|
1964
|
+
registerTemplate({
|
|
1965
|
+
eventType: "hitl.timeout",
|
|
1966
|
+
header: "",
|
|
1967
|
+
defaultBody: `Your approval request ({{request_id}}) timed out with no answer.
|
|
1968
|
+
|
|
1969
|
+
Title: {{title}}
|
|
1970
|
+
Deadline: {{expires_at}}
|
|
1971
|
+
Reason: {{reason}}
|
|
1972
|
+
|
|
1973
|
+
No human responded before the deadline. Decide how to continue without this input.`,
|
|
1974
|
+
variables: [
|
|
1975
|
+
{ name: "request_id", description: "The approval request ID" },
|
|
1976
|
+
{ name: "title", description: "Title of the approval request" },
|
|
1977
|
+
{ name: "expires_at", description: "The deadline that passed, ISO 8601" },
|
|
1978
|
+
{ name: "reason", description: "The resolutionReason stored on the request" }
|
|
1979
|
+
],
|
|
1980
|
+
category: "task_lifecycle"
|
|
1981
|
+
});
|
|
1945
1982
|
registerTemplate({
|
|
1946
1983
|
eventType: "task.worker.failed",
|
|
1947
1984
|
header: "",
|
|
@@ -2624,6 +2661,14 @@ function isAgentEligibleForTask(agent, task) {
|
|
|
2624
2661
|
return false;
|
|
2625
2662
|
return hasRequiredCapabilities();
|
|
2626
2663
|
}
|
|
2664
|
+
async function getAgentDailyTaskCounts(agentId, days) {
|
|
2665
|
+
const since = new Date(Date.now() - days * 86400000).toISOString().slice(0, 10);
|
|
2666
|
+
return getDbClient().query(`SELECT substr(createdAt, 1, 10) AS date, COUNT(*) AS count
|
|
2667
|
+
FROM agent_tasks
|
|
2668
|
+
WHERE agentId = ? AND createdAt >= ?
|
|
2669
|
+
GROUP BY date
|
|
2670
|
+
ORDER BY date`, [agentId, since]);
|
|
2671
|
+
}
|
|
2627
2672
|
var dependencies, EXTENSION_AGENT_ROLE = "extension", NOT_EXTENSION_AGENT_SQL, ReservedAgentRoleError, ExtensionAgentAssignmentError, MAX_EMPTY_POLLS = 2;
|
|
2628
2673
|
var init_agents = __esm(() => {
|
|
2629
2674
|
init_types();
|
|
@@ -2644,6 +2689,43 @@ var init_agents = __esm(() => {
|
|
|
2644
2689
|
};
|
|
2645
2690
|
});
|
|
2646
2691
|
|
|
2692
|
+
// src/be/db/approvals.ts
|
|
2693
|
+
function approvalRequestListClause(filters) {
|
|
2694
|
+
const conditions = [];
|
|
2695
|
+
const params = [];
|
|
2696
|
+
if (filters?.status) {
|
|
2697
|
+
conditions.push("status = ?");
|
|
2698
|
+
params.push(filters.status);
|
|
2699
|
+
}
|
|
2700
|
+
if (filters?.workflowRunId) {
|
|
2701
|
+
conditions.push("workflowRunId = ?");
|
|
2702
|
+
params.push(filters.workflowRunId);
|
|
2703
|
+
}
|
|
2704
|
+
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
2705
|
+
params.push(filters?.limit ?? 100);
|
|
2706
|
+
return { sql: `${where} ORDER BY createdAt DESC LIMIT ?`, params };
|
|
2707
|
+
}
|
|
2708
|
+
async function listApprovalRequestSummaries(filters) {
|
|
2709
|
+
const { sql, params } = approvalRequestListClause(filters);
|
|
2710
|
+
const rows = await getDbClient().query(`SELECT id, title, workflowRunId, workflowRunStepId, sourceTaskId, status, resolvedBy,
|
|
2711
|
+
resolvedAt, timeoutSeconds, expiresAt, created_by, createdAt, updatedAt,
|
|
2712
|
+
json_array_length(questions) AS questionCount
|
|
2713
|
+
FROM approval_requests ${sql}`, params);
|
|
2714
|
+
return rows.map(({ created_by, questionCount, ...row }) => ({
|
|
2715
|
+
...row,
|
|
2716
|
+
questionCount: questionCount ?? 0,
|
|
2717
|
+
resolvedAt: normalizeDate(row.resolvedAt),
|
|
2718
|
+
expiresAt: normalizeDate(row.expiresAt),
|
|
2719
|
+
createdBy: created_by ?? undefined,
|
|
2720
|
+
createdAt: normalizeDateRequired(row.createdAt),
|
|
2721
|
+
updatedAt: normalizeDateRequired(row.updatedAt)
|
|
2722
|
+
}));
|
|
2723
|
+
}
|
|
2724
|
+
var init_approvals = __esm(() => {
|
|
2725
|
+
init_date_utils();
|
|
2726
|
+
init_runtime();
|
|
2727
|
+
});
|
|
2728
|
+
|
|
2647
2729
|
// src/be/db/context-versions.ts
|
|
2648
2730
|
function computeContentHash(content) {
|
|
2649
2731
|
const hasher = new Bun.CryptoHasher("sha256");
|
|
@@ -2719,6 +2801,10 @@ var init_provider_metadata = () => {};
|
|
|
2719
2801
|
function configureTaskReadDependencies(value) {
|
|
2720
2802
|
dependencies2 = value;
|
|
2721
2803
|
}
|
|
2804
|
+
function taskPreview(task) {
|
|
2805
|
+
const text = task instanceof Uint8Array ? taskPreviewDecoder.decode(task) : task;
|
|
2806
|
+
return dependencies2.previewText(text, TASK_PREVIEW_LENGTH);
|
|
2807
|
+
}
|
|
2722
2808
|
function rowToAgentTask(row) {
|
|
2723
2809
|
let followUpConfig;
|
|
2724
2810
|
if (row.followUpConfig) {
|
|
@@ -2830,35 +2916,49 @@ function rowToAgentTask(row) {
|
|
|
2830
2916
|
};
|
|
2831
2917
|
}
|
|
2832
2918
|
function rowToAgentTaskSummary(row) {
|
|
2833
|
-
const t = rowToAgentTask(row);
|
|
2834
2919
|
return {
|
|
2835
|
-
id:
|
|
2836
|
-
key:
|
|
2837
|
-
agentId:
|
|
2838
|
-
creatorAgentId:
|
|
2839
|
-
task:
|
|
2840
|
-
title:
|
|
2841
|
-
status:
|
|
2842
|
-
source:
|
|
2843
|
-
taskType:
|
|
2844
|
-
tags:
|
|
2845
|
-
priority:
|
|
2846
|
-
dependsOn:
|
|
2847
|
-
offeredTo:
|
|
2848
|
-
acceptedAt:
|
|
2849
|
-
parentTaskId:
|
|
2850
|
-
scheduleId:
|
|
2851
|
-
model:
|
|
2852
|
-
modelTier:
|
|
2853
|
-
effort:
|
|
2854
|
-
provider:
|
|
2855
|
-
requestedByUserId:
|
|
2856
|
-
progress:
|
|
2857
|
-
createdAt:
|
|
2858
|
-
lastUpdatedAt:
|
|
2859
|
-
finishedAt:
|
|
2860
|
-
peakContextPercent:
|
|
2861
|
-
totalCostUsd:
|
|
2920
|
+
id: row.id,
|
|
2921
|
+
key: row.key,
|
|
2922
|
+
agentId: row.agentId,
|
|
2923
|
+
creatorAgentId: row.creatorAgentId ?? undefined,
|
|
2924
|
+
task: taskPreview(row.task),
|
|
2925
|
+
title: row.title ?? undefined,
|
|
2926
|
+
status: row.status,
|
|
2927
|
+
source: row.source,
|
|
2928
|
+
taskType: row.taskType ?? undefined,
|
|
2929
|
+
tags: row.tags ? JSON.parse(row.tags) : [],
|
|
2930
|
+
priority: row.priority ?? 50,
|
|
2931
|
+
dependsOn: row.dependsOn ? JSON.parse(row.dependsOn) : [],
|
|
2932
|
+
offeredTo: row.offeredTo ?? undefined,
|
|
2933
|
+
acceptedAt: row.acceptedAt ?? undefined,
|
|
2934
|
+
parentTaskId: row.parentTaskId ?? undefined,
|
|
2935
|
+
scheduleId: row.scheduleId ?? undefined,
|
|
2936
|
+
model: row.model ?? undefined,
|
|
2937
|
+
modelTier: parseModelTier(row.modelTier) ?? undefined,
|
|
2938
|
+
effort: ReasoningEffortSchema.safeParse(row.effort).success ? row.effort : undefined,
|
|
2939
|
+
provider: row.provider ?? undefined,
|
|
2940
|
+
requestedByUserId: row.requestedByUserId ?? undefined,
|
|
2941
|
+
progress: row.progress ?? undefined,
|
|
2942
|
+
createdAt: row.createdAt,
|
|
2943
|
+
lastUpdatedAt: row.lastUpdatedAt,
|
|
2944
|
+
finishedAt: row.finishedAt ?? undefined,
|
|
2945
|
+
peakContextPercent: row.peakContextPercent ?? undefined,
|
|
2946
|
+
totalCostUsd: row.totalCostUsd ?? undefined
|
|
2947
|
+
};
|
|
2948
|
+
}
|
|
2949
|
+
function rowToAgentTaskTimelineItem(row) {
|
|
2950
|
+
return {
|
|
2951
|
+
id: row.id,
|
|
2952
|
+
agentId: row.agentId,
|
|
2953
|
+
parentTaskId: row.parentTaskId ?? undefined,
|
|
2954
|
+
task: taskPreview(row.task),
|
|
2955
|
+
title: row.title ?? undefined,
|
|
2956
|
+
status: row.status,
|
|
2957
|
+
createdAt: row.createdAt,
|
|
2958
|
+
lastUpdatedAt: row.lastUpdatedAt,
|
|
2959
|
+
finishedAt: row.finishedAt ?? undefined,
|
|
2960
|
+
peakContextTokens: row.peakContextTokens ?? undefined,
|
|
2961
|
+
totalCostUsd: row.totalCostUsd ?? undefined
|
|
2862
2962
|
};
|
|
2863
2963
|
}
|
|
2864
2964
|
async function getTaskById(id) {
|
|
@@ -2877,6 +2977,18 @@ async function hasNonTerminalResumeChild(parentId) {
|
|
|
2877
2977
|
LIMIT 1`, [parentId]);
|
|
2878
2978
|
return row !== undefined && row !== null;
|
|
2879
2979
|
}
|
|
2980
|
+
async function getSupersededTasksWithoutResume(finishedBefore, finishedAfter) {
|
|
2981
|
+
const rows = await getDbClient().query(`SELECT * FROM agent_tasks t
|
|
2982
|
+
WHERE t.status = 'superseded'
|
|
2983
|
+
AND t.workflowRunStepId IS NULL
|
|
2984
|
+
AND t.finishedAt < ?
|
|
2985
|
+
AND t.finishedAt > ?
|
|
2986
|
+
AND NOT EXISTS (
|
|
2987
|
+
SELECT 1 FROM agent_tasks c WHERE c.parentTaskId = t.id AND c.taskType = 'resume'
|
|
2988
|
+
)
|
|
2989
|
+
ORDER BY t.finishedAt ASC`, [finishedBefore, finishedAfter]);
|
|
2990
|
+
return rows.map(rowToAgentTask);
|
|
2991
|
+
}
|
|
2880
2992
|
async function hasNonTerminalRerouteDecisionChild(parentId) {
|
|
2881
2993
|
const row = await getDbClient().get(`SELECT 1 FROM agent_tasks
|
|
2882
2994
|
WHERE parentTaskId = ?
|
|
@@ -2987,12 +3099,20 @@ async function getAllTasks(filters, opts) {
|
|
|
2987
3099
|
const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
2988
3100
|
const limit = filters?.limit ?? 25;
|
|
2989
3101
|
const offset = filters?.offset ?? 0;
|
|
2990
|
-
const
|
|
2991
|
-
const
|
|
3102
|
+
const orderColumns = filters?.orderBy === "createdAt" ? ["createdAt DESC", "rowid DESC"] : ["lastUpdatedAt DESC", "priority DESC"];
|
|
3103
|
+
const fields = opts?.fields === "timeline" ? "timeline" : opts?.slim ? "slim" : "full";
|
|
3104
|
+
const query = `WITH page AS (
|
|
3105
|
+
SELECT rowid AS rid FROM agent_tasks ${whereClause}
|
|
3106
|
+
ORDER BY ${orderColumns.join(", ")} LIMIT ${limit} OFFSET ${offset}
|
|
3107
|
+
)
|
|
3108
|
+
SELECT ${LIST_COLUMNS[fields]},
|
|
2992
3109
|
(SELECT SUM(totalCostUsd) FROM session_costs WHERE session_costs.taskId = agent_tasks.id) AS totalCostUsd
|
|
2993
|
-
FROM agent_tasks
|
|
2994
|
-
ORDER BY ${
|
|
2995
|
-
|
|
3110
|
+
FROM page JOIN agent_tasks ON agent_tasks.rowid = page.rid
|
|
3111
|
+
ORDER BY ${[...new Set([...orderColumns, "rowid DESC"])].map((column) => `agent_tasks.${column}`).join(", ")}`;
|
|
3112
|
+
if (fields === "timeline") {
|
|
3113
|
+
const rows2 = await getDbClient().query(query, params);
|
|
3114
|
+
return rows2.map(rowToAgentTaskTimelineItem);
|
|
3115
|
+
}
|
|
2996
3116
|
const filterReady = async (items) => {
|
|
2997
3117
|
const readyFlags = await Promise.all(items.map(async (task) => {
|
|
2998
3118
|
if (!task.dependsOn || task.dependsOn.length === 0)
|
|
@@ -3001,12 +3121,14 @@ async function getAllTasks(filters, opts) {
|
|
|
3001
3121
|
}));
|
|
3002
3122
|
return items.filter((_, i) => readyFlags[i]);
|
|
3003
3123
|
};
|
|
3004
|
-
if (
|
|
3005
|
-
|
|
3124
|
+
if (fields === "slim") {
|
|
3125
|
+
const rows2 = await getDbClient().query(query, params);
|
|
3126
|
+
let tasks2 = rows2.map(rowToAgentTaskSummary);
|
|
3006
3127
|
if (filters?.readyOnly)
|
|
3007
3128
|
tasks2 = await filterReady(tasks2);
|
|
3008
3129
|
return tasks2;
|
|
3009
3130
|
}
|
|
3131
|
+
const rows = await getDbClient().query(query, params);
|
|
3010
3132
|
let tasks = rows.map(rowToAgentTask);
|
|
3011
3133
|
if (filters?.readyOnly)
|
|
3012
3134
|
tasks = await filterReady(tasks);
|
|
@@ -3360,13 +3482,30 @@ async function findRecentCancelledTaskInThread(channelId, threadTs, windowMinute
|
|
|
3360
3482
|
LIMIT 1`, [channelId, threadTs, since]);
|
|
3361
3483
|
return row ? rowToAgentTask(row) : null;
|
|
3362
3484
|
}
|
|
3363
|
-
var dependencies2, TASK_PREVIEW_LENGTH = 300, findTaskByGitHub, LINEAR_TRACKER_CONTEXT_KEY_PREFIX = "task:trackers:linear:";
|
|
3485
|
+
var dependencies2, TASK_PREVIEW_LENGTH = 300, TASK_PREVIEW_BYTES, TASK_PREVIEW_SQL, taskPreviewDecoder, LIST_COLUMNS, findTaskByGitHub, LINEAR_TRACKER_CONTEXT_KEY_PREFIX = "task:trackers:linear:";
|
|
3364
3486
|
var init_read = __esm(() => {
|
|
3365
3487
|
init_key();
|
|
3366
3488
|
init_types();
|
|
3367
3489
|
init_provider_metadata();
|
|
3368
3490
|
init_agents();
|
|
3369
3491
|
init_runtime();
|
|
3492
|
+
TASK_PREVIEW_BYTES = 4 * (TASK_PREVIEW_LENGTH + 1);
|
|
3493
|
+
TASK_PREVIEW_SQL = `substr(CAST(agent_tasks.task AS BLOB), 1, ${TASK_PREVIEW_BYTES}) AS task`;
|
|
3494
|
+
taskPreviewDecoder = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
3495
|
+
LIST_COLUMNS = {
|
|
3496
|
+
full: "agent_tasks.*",
|
|
3497
|
+
slim: `agent_tasks.id, agent_tasks."key", agent_tasks.agentId, agent_tasks.creatorAgentId,
|
|
3498
|
+
${TASK_PREVIEW_SQL}, agent_tasks.title, agent_tasks.status, agent_tasks.source,
|
|
3499
|
+
agent_tasks.taskType, agent_tasks.tags, agent_tasks.priority, agent_tasks.dependsOn,
|
|
3500
|
+
agent_tasks.offeredTo, agent_tasks.acceptedAt, agent_tasks.parentTaskId,
|
|
3501
|
+
agent_tasks.scheduleId, agent_tasks.model, agent_tasks.modelTier, agent_tasks.effort,
|
|
3502
|
+
agent_tasks.provider, agent_tasks.requestedByUserId, agent_tasks.progress,
|
|
3503
|
+
agent_tasks.createdAt, agent_tasks.lastUpdatedAt, agent_tasks.finishedAt,
|
|
3504
|
+
agent_tasks.peakContextPercent`,
|
|
3505
|
+
timeline: `agent_tasks.id, agent_tasks.agentId, agent_tasks.parentTaskId, ${TASK_PREVIEW_SQL},
|
|
3506
|
+
agent_tasks.title, agent_tasks.status, agent_tasks.createdAt, agent_tasks.lastUpdatedAt,
|
|
3507
|
+
agent_tasks.finishedAt, agent_tasks.peakContextTokens`
|
|
3508
|
+
};
|
|
3370
3509
|
findTaskByGitHub = findTaskByVcs;
|
|
3371
3510
|
});
|
|
3372
3511
|
|
|
@@ -3631,7 +3770,7 @@ async function completeTask(id, output, options) {
|
|
|
3631
3770
|
}
|
|
3632
3771
|
return row ? rowToAgentTask(row) : null;
|
|
3633
3772
|
}
|
|
3634
|
-
async function failTask(id, reason) {
|
|
3773
|
+
async function failTask(id, reason, opts = {}) {
|
|
3635
3774
|
const oldTask = await getTaskById(id);
|
|
3636
3775
|
if (!oldTask)
|
|
3637
3776
|
return null;
|
|
@@ -3641,7 +3780,14 @@ async function failTask(id, reason) {
|
|
|
3641
3780
|
const finishedAt = new Date().toISOString();
|
|
3642
3781
|
const scrubbedReason = scrubSecrets(reason);
|
|
3643
3782
|
const row = await getDbClient().get(`UPDATE agent_tasks SET status = 'failed', failureReason = ?, finishedAt = ?, lastUpdatedAt = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
|
|
3644
|
-
WHERE id = ? AND status NOT IN ('completed', 'failed', 'cancelled', 'superseded')
|
|
3783
|
+
WHERE id = ? AND status NOT IN ('completed', 'failed', 'cancelled', 'superseded')
|
|
3784
|
+
AND (? IS NULL OR lastUpdatedAt = ?) RETURNING *`, [
|
|
3785
|
+
scrubbedReason,
|
|
3786
|
+
finishedAt,
|
|
3787
|
+
id,
|
|
3788
|
+
opts.expectedLastUpdatedAt ?? null,
|
|
3789
|
+
opts.expectedLastUpdatedAt ?? null
|
|
3790
|
+
]);
|
|
3645
3791
|
if (row && oldTask) {
|
|
3646
3792
|
dependencies3.emitTaskLifecycleTelemetryAfterCommit("failed", {
|
|
3647
3793
|
taskId: id,
|
|
@@ -3676,10 +3822,12 @@ async function failTask(id, reason) {
|
|
|
3676
3822
|
} catch (error) {
|
|
3677
3823
|
console.error("[failTask] pending steering promotion error:", scrubSecrets(error instanceof Error ? error.message : String(error)));
|
|
3678
3824
|
}
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3825
|
+
if (opts.cascadeDependents !== false) {
|
|
3826
|
+
try {
|
|
3827
|
+
await dependencies3.cascadeFailDependents(id, "failed");
|
|
3828
|
+
} catch (err) {
|
|
3829
|
+
console.error("[failTask] cascade-fail dependents error:", err);
|
|
3830
|
+
}
|
|
3683
3831
|
}
|
|
3684
3832
|
}
|
|
3685
3833
|
return row ? rowToAgentTask(row) : null;
|
|
@@ -3769,7 +3917,8 @@ async function supersedeTask(id, args) {
|
|
|
3769
3917
|
finishedAt = ?,
|
|
3770
3918
|
lastUpdatedAt = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
|
|
3771
3919
|
WHERE id = ? AND status NOT IN ('completed', 'failed', 'cancelled', 'superseded')
|
|
3772
|
-
|
|
3920
|
+
AND (? IS NULL OR lastUpdatedAt = ?)
|
|
3921
|
+
RETURNING *`, [finishedAt, id, args.expectedLastUpdatedAt ?? null, args.expectedLastUpdatedAt ?? null]);
|
|
3773
3922
|
if (row && oldTask) {
|
|
3774
3923
|
dependencies3.emitTaskLifecycleTelemetryAfterCommit("superseded", {
|
|
3775
3924
|
taskId: id,
|
|
@@ -3994,14 +4143,36 @@ async function providerForTask(task) {
|
|
|
3994
4143
|
const agent = task.agentId ? await getAgentById(task.agentId) : null;
|
|
3995
4144
|
return agent?.harnessProvider ?? agent?.provider ?? task.provider ?? "claude";
|
|
3996
4145
|
}
|
|
3997
|
-
|
|
3998
|
-
const agent = task.agentId ? await getAgentById(task.agentId) : null;
|
|
4146
|
+
function steeringFieldsFor(task, agent) {
|
|
3999
4147
|
const provider = agent?.harnessProvider ?? agent?.provider ?? task.provider;
|
|
4000
4148
|
return {
|
|
4001
4149
|
isLeadTask: agent?.isLead ?? false,
|
|
4002
4150
|
supportedSteerModes: provider ? PROVIDER_STEER_CAPABILITIES[provider] : []
|
|
4003
4151
|
};
|
|
4004
4152
|
}
|
|
4153
|
+
async function getTaskSteeringFields(task) {
|
|
4154
|
+
const agent = task.agentId ? await getAgentById(task.agentId) : null;
|
|
4155
|
+
return steeringFieldsFor(task, agent);
|
|
4156
|
+
}
|
|
4157
|
+
async function getTaskSteeringFieldsForTasks(tasks) {
|
|
4158
|
+
const agentIds = [...new Set(tasks.flatMap((task) => task.agentId ? [task.agentId] : []))];
|
|
4159
|
+
const agents = new Map;
|
|
4160
|
+
for (let i = 0;i < agentIds.length; i += AGENT_ID_CHUNK) {
|
|
4161
|
+
const ids = agentIds.slice(i, i + AGENT_ID_CHUNK);
|
|
4162
|
+
const rows = await getDbClient().query(`SELECT id, isLead, provider, harness_provider FROM agents WHERE id IN (${ids.map(() => "?").join(",")})`, ids);
|
|
4163
|
+
for (const row of rows) {
|
|
4164
|
+
agents.set(row.id, {
|
|
4165
|
+
isLead: row.isLead === 1,
|
|
4166
|
+
provider: row.provider ?? undefined,
|
|
4167
|
+
harnessProvider: row.harness_provider ?? null
|
|
4168
|
+
});
|
|
4169
|
+
}
|
|
4170
|
+
}
|
|
4171
|
+
return new Map(tasks.map((task) => [
|
|
4172
|
+
task.id,
|
|
4173
|
+
steeringFieldsFor(task, task.agentId ? agents.get(task.agentId) ?? null : null)
|
|
4174
|
+
]));
|
|
4175
|
+
}
|
|
4005
4176
|
async function promoteSteeringToTask(task, message) {
|
|
4006
4177
|
return await createTaskExtended(message.body, {
|
|
4007
4178
|
agentId: task.agentId,
|
|
@@ -4114,7 +4285,7 @@ async function requestSteering(args) {
|
|
|
4114
4285
|
degradedFrom
|
|
4115
4286
|
};
|
|
4116
4287
|
}
|
|
4117
|
-
var SteeringRequestError;
|
|
4288
|
+
var SteeringRequestError, AGENT_ID_CHUNK = 500;
|
|
4118
4289
|
var init_steering = __esm(() => {
|
|
4119
4290
|
init_types();
|
|
4120
4291
|
init_secret_scrubber();
|
|
@@ -4263,6 +4434,7 @@ var init_tool_config = __esm(() => {
|
|
|
4263
4434
|
"preview-prompt-template",
|
|
4264
4435
|
"create_metric",
|
|
4265
4436
|
"request-human-input",
|
|
4437
|
+
"cancel-approval-request",
|
|
4266
4438
|
"skill-create",
|
|
4267
4439
|
"skill-update",
|
|
4268
4440
|
"skill-delete",
|
|
@@ -4550,6 +4722,7 @@ var init_swarm_config_guard = __esm(() => {
|
|
|
4550
4722
|
"BUDGET_ADMISSION_DISABLED",
|
|
4551
4723
|
"MCP_OAUTH_ALLOW_PRIVATE_HOSTS",
|
|
4552
4724
|
"OTEL_TRACE_POLL",
|
|
4725
|
+
"OTEL_EXPORT_API_LOGS",
|
|
4553
4726
|
"ANONYMIZED_TELEMETRY",
|
|
4554
4727
|
"SWARM_HIDE_CLOUD_PROMO",
|
|
4555
4728
|
"DB_QUERY_BOUNDED_ENABLED",
|
|
@@ -4594,6 +4767,7 @@ var init_swarm_config_guard = __esm(() => {
|
|
|
4594
4767
|
...boundedIntegerValidatorsFor(DB_RETENTION_TUNING_BOUNDS),
|
|
4595
4768
|
...boundedIntegerValidators(["SESSION_LOG_RETENTION_DAYS", "AGENT_LOG_RETENTION_DAYS", "EVENTS_RETENTION_DAYS"], 1, MAX_DB_RETENTION_DAYS),
|
|
4596
4769
|
...integerValidators(["HEARTBEAT_MAX_AUTO_ASSIGN"], 0),
|
|
4770
|
+
...integerValidators(["APPROVAL_REQUEST_AUTO_CANCELLATION_DAYS"], 0),
|
|
4597
4771
|
...boundedIntegerValidators(["CONTEXT_PREAMBLE_MAX_TOKENS"], 100, 20000),
|
|
4598
4772
|
MEMORY_MIN_SIMILARITY: (value) => validateFloatRange("MEMORY_MIN_SIMILARITY", value, 0, 1, "between 0 and 1 inclusive"),
|
|
4599
4773
|
MEMORY_ACCESS_BOOST_MAX: (value) => validateFloatRange("MEMORY_ACCESS_BOOST_MAX", value, 1, Number.POSITIVE_INFINITY, "a number >= 1")
|
|
@@ -4619,6 +4793,7 @@ __export(exports_db, {
|
|
|
4619
4793
|
backfillSupersedeTaskResumeTaskId: () => backfillSupersedeTaskResumeTaskId,
|
|
4620
4794
|
bindSlackMessageTimestamp: () => bindSlackMessageTimestamp,
|
|
4621
4795
|
buildRoutingAffinityFromAgent: () => buildRoutingAffinityFromAgent,
|
|
4796
|
+
cancelApprovalRequestById: () => cancelApprovalRequestById,
|
|
4622
4797
|
cancelPendingApprovalRequestsForRun: () => cancelPendingApprovalRequestsForRun,
|
|
4623
4798
|
cancelPendingSteeringForTask: () => cancelPendingSteeringForTask,
|
|
4624
4799
|
cancelTask: () => cancelTask,
|
|
@@ -4729,6 +4904,7 @@ __export(exports_db, {
|
|
|
4729
4904
|
getActiveTaskCount: () => getActiveTaskCount,
|
|
4730
4905
|
getAgentById: () => getAgentById,
|
|
4731
4906
|
getAgentCurrentTask: () => getAgentCurrentTask,
|
|
4907
|
+
getAgentDailyTaskCounts: () => getAgentDailyTaskCounts,
|
|
4732
4908
|
getAgentHarnessProviders: () => getAgentHarnessProviders,
|
|
4733
4909
|
getAgentMailInboxMapping: () => getAgentMailInboxMapping,
|
|
4734
4910
|
getAgentMailInboxMappingsByAgent: () => getAgentMailInboxMappingsByAgent,
|
|
@@ -4771,6 +4947,7 @@ __export(exports_db, {
|
|
|
4771
4947
|
getContextSummaryByTaskId: () => getContextSummaryByTaskId,
|
|
4772
4948
|
getContextVersion: () => getContextVersion,
|
|
4773
4949
|
getContextVersionHistory: () => getContextVersionHistory,
|
|
4950
|
+
getCurrentStepForNode: () => getCurrentStepForNode,
|
|
4774
4951
|
getDailySpendForAgent: () => getDailySpendForAgent,
|
|
4775
4952
|
getDailySpendForUser: () => getDailySpendForUser,
|
|
4776
4953
|
getDailySpendGlobal: () => getDailySpendGlobal,
|
|
@@ -4876,6 +5053,7 @@ __export(exports_db, {
|
|
|
4876
5053
|
getSlackTreeMessage: () => getSlackTreeMessage,
|
|
4877
5054
|
getSlackTreeMessageByThread: () => getSlackTreeMessageByThread,
|
|
4878
5055
|
getSlackTreeMessages: () => getSlackTreeMessages,
|
|
5056
|
+
getStaleApprovalRequests: () => getStaleApprovalRequests,
|
|
4879
5057
|
getStalePinnedResumes: () => getStalePinnedResumes,
|
|
4880
5058
|
getStaleUnassignedAffinityTasks: () => getStaleUnassignedAffinityTasks,
|
|
4881
5059
|
getStalledInProgressTasks: () => getStalledInProgressTasks,
|
|
@@ -4886,6 +5064,7 @@ __export(exports_db, {
|
|
|
4886
5064
|
getStuckApprovalRuns: () => getStuckApprovalRuns,
|
|
4887
5065
|
getStuckWaitRuns: () => getStuckWaitRuns,
|
|
4888
5066
|
getStuckWorkflowRuns: () => getStuckWorkflowRuns,
|
|
5067
|
+
getSupersededTasksWithoutResume: () => getSupersededTasksWithoutResume,
|
|
4889
5068
|
getSwarmConfigById: () => getSwarmConfigById,
|
|
4890
5069
|
getSwarmConfigLookupById: () => getSwarmConfigLookupById,
|
|
4891
5070
|
getSwarmConfigs: () => getSwarmConfigs,
|
|
@@ -4942,9 +5121,11 @@ __export(exports_db, {
|
|
|
4942
5121
|
isPoolAffinityEnforcementEnabled: () => isPoolAffinityEnforcementEnabled,
|
|
4943
5122
|
isSettledSlackMessage: () => isSettledSlackMessage,
|
|
4944
5123
|
isSqliteVecAvailable: () => isSqliteVecAvailable,
|
|
5124
|
+
kvPrefixUpperBound: () => kvPrefixUpperBound,
|
|
4945
5125
|
listAgentsWithCredStatusByProvider: () => listAgentsWithCredStatusByProvider,
|
|
4946
5126
|
listAllMetrics: () => listAllMetrics,
|
|
4947
5127
|
listAllPages: () => listAllPages,
|
|
5128
|
+
listApprovalRequestSummaries: () => listApprovalRequestSummaries,
|
|
4948
5129
|
listApprovalRequests: () => listApprovalRequests,
|
|
4949
5130
|
listAssetSummaries: () => listAssetSummaries,
|
|
4950
5131
|
listCancelledApprovalRequestsForRun: () => listCancelledApprovalRequestsForRun,
|
|
@@ -5079,9 +5260,11 @@ __export(exports_db, {
|
|
|
5079
5260
|
upsertSwarmConfig: () => upsertSwarmConfig,
|
|
5080
5261
|
withFavoriteFlags: () => withFavoriteFlags
|
|
5081
5262
|
});
|
|
5263
|
+
function literalPrefixPattern(prefix) {
|
|
5264
|
+
return `${prefix.replace(/[\\%_]/g, "\\$&")}%`;
|
|
5265
|
+
}
|
|
5082
5266
|
function assetKeyPrefixPattern(input) {
|
|
5083
|
-
|
|
5084
|
-
return `${canonical.replace(/[\\%_]/g, "\\$&")}%`;
|
|
5267
|
+
return literalPrefixPattern(normalizeAssetKey(input));
|
|
5085
5268
|
}
|
|
5086
5269
|
function emitTaskLifecycleTelemetryAfterCommit(event, props, verify) {
|
|
5087
5270
|
getDbClient().afterCommit(() => {
|
|
@@ -6327,7 +6510,7 @@ async function createTaskExtended(task, options) {
|
|
|
6327
6510
|
if (parent.contextKey && !options.contextKey) {
|
|
6328
6511
|
options.contextKey = parent.contextKey;
|
|
6329
6512
|
}
|
|
6330
|
-
if (parent.followUpConfig && !options.followUpConfig) {
|
|
6513
|
+
if (parent.followUpConfig && !options.followUpConfig && options.inheritParentFollowUpConfig === true) {
|
|
6331
6514
|
options.followUpConfig = parent.followUpConfig;
|
|
6332
6515
|
}
|
|
6333
6516
|
if (parent.routingAffinityInvalid && options.inheritParentRoutingAffinity !== false) {
|
|
@@ -9248,7 +9431,8 @@ async function listWorkflowRuns(workflowId, options = {}) {
|
|
|
9248
9431
|
pagination = " LIMIT -1 OFFSET ?";
|
|
9249
9432
|
params.push(options.offset);
|
|
9250
9433
|
}
|
|
9251
|
-
const
|
|
9434
|
+
const columns = options.includeContext ? "*" : WORKFLOW_RUN_SUMMARY_COLUMNS;
|
|
9435
|
+
const rows = await getDbClient().query(`SELECT ${columns} FROM workflow_runs
|
|
9252
9436
|
WHERE ${conditions.join(" AND ")}
|
|
9253
9437
|
ORDER BY startedAt DESC, id DESC${pagination}`, params);
|
|
9254
9438
|
return rows.map(rowToWorkflowRun);
|
|
@@ -9404,11 +9588,13 @@ async function getLastRunStart(workflowId) {
|
|
|
9404
9588
|
}
|
|
9405
9589
|
async function getRetryableSteps() {
|
|
9406
9590
|
const now = new Date().toISOString();
|
|
9407
|
-
const rows = await getDbClient().query(`SELECT
|
|
9408
|
-
|
|
9409
|
-
|
|
9410
|
-
AND nextRetryAt
|
|
9411
|
-
|
|
9591
|
+
const rows = await getDbClient().query(`SELECT s.* FROM workflow_run_steps s
|
|
9592
|
+
JOIN workflow_runs r ON r.id = s.runId
|
|
9593
|
+
WHERE s.status = 'failed'
|
|
9594
|
+
AND s.nextRetryAt IS NOT NULL
|
|
9595
|
+
AND s.nextRetryAt <= ?
|
|
9596
|
+
AND r.status IN ('running', 'waiting', 'failed')
|
|
9597
|
+
ORDER BY s.nextRetryAt ASC`, [now]);
|
|
9412
9598
|
return rows.map(rowToWorkflowRunStep);
|
|
9413
9599
|
}
|
|
9414
9600
|
async function getCompletedStepNodeIds(runId) {
|
|
@@ -9435,6 +9621,21 @@ async function getLatestStepForNode(runId, nodeId) {
|
|
|
9435
9621
|
const row = await getDbClient().get("SELECT * FROM workflow_run_steps WHERE runId = ? AND nodeId = ? ORDER BY startedAt DESC LIMIT 1", [runId, nodeId]);
|
|
9436
9622
|
return row ? rowToWorkflowRunStep(row) : null;
|
|
9437
9623
|
}
|
|
9624
|
+
async function getCurrentStepForNode(runId, nodeId, predecessorIds) {
|
|
9625
|
+
const row = await getDbClient().get("SELECT * FROM workflow_run_steps WHERE runId = ? AND nodeId = ? ORDER BY rowid DESC LIMIT 1", [runId, nodeId]);
|
|
9626
|
+
if (!row || !["running", "waiting", "completed"].includes(row.status))
|
|
9627
|
+
return null;
|
|
9628
|
+
if (predecessorIds.length > 0) {
|
|
9629
|
+
const newer = await getDbClient().get(`SELECT 1 AS found FROM workflow_run_steps
|
|
9630
|
+
WHERE runId = ? AND status = 'completed'
|
|
9631
|
+
AND nodeId IN (${predecessorIds.map(() => "?").join(", ")})
|
|
9632
|
+
AND rowid > (SELECT rowid FROM workflow_run_steps WHERE id = ?)
|
|
9633
|
+
LIMIT 1`, [runId, ...predecessorIds, row.id]);
|
|
9634
|
+
if (newer)
|
|
9635
|
+
return null;
|
|
9636
|
+
}
|
|
9637
|
+
return rowToWorkflowRunStep(row);
|
|
9638
|
+
}
|
|
9438
9639
|
function rowToWorkflowVersion(row) {
|
|
9439
9640
|
return {
|
|
9440
9641
|
id: row.id,
|
|
@@ -10114,19 +10315,29 @@ async function resolveApprovalRequest(id, data, options) {
|
|
|
10114
10315
|
)
|
|
10115
10316
|
)` : "";
|
|
10116
10317
|
const row = await getDbClient().get(`UPDATE approval_requests
|
|
10117
|
-
SET status = ?, responses = ?, resolvedBy = ?,
|
|
10318
|
+
SET status = ?, responses = ?, resolvedBy = ?, resolutionReason = ?, resolvedAt = ?,
|
|
10319
|
+
updatedAt = ?
|
|
10118
10320
|
WHERE id = ? AND status = 'pending'
|
|
10119
10321
|
${actionableWorkflowClause}
|
|
10120
10322
|
RETURNING *`, [
|
|
10121
10323
|
data.status,
|
|
10122
10324
|
data.responses ? JSON.stringify(data.responses) : null,
|
|
10123
10325
|
data.resolvedBy ?? null,
|
|
10326
|
+
data.resolutionReason ?? null,
|
|
10124
10327
|
now,
|
|
10125
10328
|
now,
|
|
10126
10329
|
id
|
|
10127
10330
|
]);
|
|
10128
10331
|
return row ? rowToApprovalRequest(row) : null;
|
|
10129
10332
|
}
|
|
10333
|
+
async function cancelApprovalRequestById(id, data) {
|
|
10334
|
+
const now = new Date().toISOString();
|
|
10335
|
+
const row = await getDbClient().get(`UPDATE approval_requests
|
|
10336
|
+
SET status = 'cancelled', resolutionReason = ?, resolvedBy = ?, resolvedAt = ?, updatedAt = ?
|
|
10337
|
+
WHERE id = ? AND status = 'pending'
|
|
10338
|
+
RETURNING *`, [data.reason, data.resolvedBy, now, now, id]);
|
|
10339
|
+
return row ? rowToApprovalRequest(row) : null;
|
|
10340
|
+
}
|
|
10130
10341
|
async function cancelPendingApprovalRequestsForRun(workflowRunId, reason) {
|
|
10131
10342
|
const now = new Date().toISOString();
|
|
10132
10343
|
const rows = await getDbClient().query(`UPDATE approval_requests
|
|
@@ -10194,20 +10405,8 @@ async function updateApprovalRequestNotifications(id, notificationChannels) {
|
|
|
10194
10405
|
await getDbClient().run("UPDATE approval_requests SET notificationChannels = ?, updatedAt = ? WHERE id = ?", [JSON.stringify(notificationChannels), now, id]);
|
|
10195
10406
|
}
|
|
10196
10407
|
async function listApprovalRequests(filters) {
|
|
10197
|
-
const
|
|
10198
|
-
const
|
|
10199
|
-
if (filters?.status) {
|
|
10200
|
-
conditions.push("status = ?");
|
|
10201
|
-
params.push(filters.status);
|
|
10202
|
-
}
|
|
10203
|
-
if (filters?.workflowRunId) {
|
|
10204
|
-
conditions.push("workflowRunId = ?");
|
|
10205
|
-
params.push(filters.workflowRunId);
|
|
10206
|
-
}
|
|
10207
|
-
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
10208
|
-
const limit = filters?.limit ?? 100;
|
|
10209
|
-
params.push(limit);
|
|
10210
|
-
const rows = await getDbClient().query(`SELECT * FROM approval_requests ${where} ORDER BY createdAt DESC LIMIT ?`, params);
|
|
10408
|
+
const { sql, params } = approvalRequestListClause(filters);
|
|
10409
|
+
const rows = await getDbClient().query(`SELECT * FROM approval_requests ${sql}`, params);
|
|
10211
10410
|
return rows.map(rowToApprovalRequest);
|
|
10212
10411
|
}
|
|
10213
10412
|
async function getStuckApprovalRuns() {
|
|
@@ -10231,11 +10430,20 @@ async function getApprovalRequestByStepId(stepId) {
|
|
|
10231
10430
|
const row = await getDbClient().get("SELECT * FROM approval_requests WHERE workflowRunStepId = ?", [stepId]);
|
|
10232
10431
|
return row ? rowToApprovalRequest(row) : null;
|
|
10233
10432
|
}
|
|
10234
|
-
async function getExpiredPendingApprovals() {
|
|
10433
|
+
async function getExpiredPendingApprovals(opts) {
|
|
10235
10434
|
const rows = await getDbClient().query(`SELECT * FROM approval_requests
|
|
10236
10435
|
WHERE status = 'pending'
|
|
10237
10436
|
AND expiresAt IS NOT NULL
|
|
10238
|
-
AND expiresAt <
|
|
10437
|
+
AND expiresAt < ?
|
|
10438
|
+
ORDER BY expiresAt ASC`, [opts?.now ?? new Date().toISOString()]);
|
|
10439
|
+
return rows.map(rowToApprovalRequest);
|
|
10440
|
+
}
|
|
10441
|
+
async function getStaleApprovalRequests(opts) {
|
|
10442
|
+
const rows = await getDbClient().query(`SELECT * FROM approval_requests
|
|
10443
|
+
WHERE status = 'pending'
|
|
10444
|
+
AND expiresAt IS NULL
|
|
10445
|
+
AND createdAt < ?
|
|
10446
|
+
ORDER BY createdAt ASC`, [opts.cutoff]);
|
|
10239
10447
|
return rows.map(rowToApprovalRequest);
|
|
10240
10448
|
}
|
|
10241
10449
|
function rowToWaitState(row) {
|
|
@@ -11691,9 +11899,9 @@ async function getRootTaskChain(rootTaskId) {
|
|
|
11691
11899
|
SELECT t.id FROM agent_tasks t
|
|
11692
11900
|
JOIN chain c ON t.parentTaskId = c.id
|
|
11693
11901
|
)
|
|
11694
|
-
SELECT t.* FROM
|
|
11695
|
-
JOIN
|
|
11696
|
-
ORDER BY t.createdAt`, [rootTaskId]);
|
|
11902
|
+
SELECT t.* FROM chain
|
|
11903
|
+
CROSS JOIN agent_tasks t ON t.id = chain.id
|
|
11904
|
+
ORDER BY t.createdAt, t.rowid`, [rootTaskId]);
|
|
11697
11905
|
return rows.map(rowToAgentTask);
|
|
11698
11906
|
}
|
|
11699
11907
|
async function listRecentSessions(opts) {
|
|
@@ -11717,6 +11925,10 @@ async function listRecentSessions(opts) {
|
|
|
11717
11925
|
conditions.push("r.requestedByUserId = ?");
|
|
11718
11926
|
params.push(requestedByUserId);
|
|
11719
11927
|
}
|
|
11928
|
+
if (opts?.contextKeyPrefix) {
|
|
11929
|
+
conditions.push(`r.contextKey LIKE ? ESCAPE '\\'`);
|
|
11930
|
+
params.push(literalPrefixPattern(opts.contextKeyPrefix));
|
|
11931
|
+
}
|
|
11720
11932
|
params.push(limit, offset);
|
|
11721
11933
|
const rootRows = await getDbClient().query(`WITH RECURSIVE chain(root_id, id, lastUpdatedAt, status) AS (
|
|
11722
11934
|
SELECT r.id, r.id, r.lastUpdatedAt, r.status
|
|
@@ -11749,7 +11961,7 @@ async function listRecentSessions(opts) {
|
|
|
11749
11961
|
FROM agent_tasks r
|
|
11750
11962
|
JOIN agg a ON a.root_id = r.id
|
|
11751
11963
|
LEFT JOIN latest_status ls ON ls.root_id = r.id
|
|
11752
|
-
ORDER BY a.lastActivityAt DESC
|
|
11964
|
+
ORDER BY a.lastActivityAt DESC, r.createdAt DESC, r.id DESC
|
|
11753
11965
|
LIMIT ? OFFSET ?`, params);
|
|
11754
11966
|
if (opts?.slim) {
|
|
11755
11967
|
return rootRows.map((row) => {
|
|
@@ -11791,6 +12003,10 @@ async function countSessions(opts) {
|
|
|
11791
12003
|
conditions.push("requestedByUserId = ?");
|
|
11792
12004
|
params.push(requestedByUserId);
|
|
11793
12005
|
}
|
|
12006
|
+
if (opts?.contextKeyPrefix) {
|
|
12007
|
+
conditions.push(`contextKey LIKE ? ESCAPE '\\'`);
|
|
12008
|
+
params.push(literalPrefixPattern(opts.contextKeyPrefix));
|
|
12009
|
+
}
|
|
11794
12010
|
const row = await getDbClient().get(`SELECT COUNT(*) AS count FROM agent_tasks WHERE ${conditions.join(" AND ")}`, params);
|
|
11795
12011
|
return row?.count ?? 0;
|
|
11796
12012
|
}
|
|
@@ -12163,40 +12379,58 @@ async function incrKv(namespace, key, by) {
|
|
|
12163
12379
|
return decodeKvRow(row);
|
|
12164
12380
|
});
|
|
12165
12381
|
}
|
|
12382
|
+
function kvPrefixUpperBound(prefix) {
|
|
12383
|
+
const codePoints = Array.from(prefix);
|
|
12384
|
+
while (codePoints.length > 0) {
|
|
12385
|
+
const last = codePoints.pop().codePointAt(0);
|
|
12386
|
+
if (last < 1114111) {
|
|
12387
|
+
const next = last + 1 === 55296 ? 57344 : last + 1;
|
|
12388
|
+
return codePoints.join("") + String.fromCodePoint(next);
|
|
12389
|
+
}
|
|
12390
|
+
}
|
|
12391
|
+
return null;
|
|
12392
|
+
}
|
|
12393
|
+
function kvPrefixCondition(prefix) {
|
|
12394
|
+
if (prefix === undefined || prefix.length === 0)
|
|
12395
|
+
return { sql: "", params: [] };
|
|
12396
|
+
const upper = kvPrefixUpperBound(prefix);
|
|
12397
|
+
return upper === null ? { sql: "AND key >= ?", params: [prefix] } : { sql: "AND key >= ? AND key < ?", params: [prefix, upper] };
|
|
12398
|
+
}
|
|
12399
|
+
function kvJsonFieldConditions(filters) {
|
|
12400
|
+
const parts = [];
|
|
12401
|
+
const params = [];
|
|
12402
|
+
for (const filter of filters ?? []) {
|
|
12403
|
+
if (/["\\]/.test(filter.field)) {
|
|
12404
|
+
throw new Error(`unsupported JSON field name: ${filter.field}`);
|
|
12405
|
+
}
|
|
12406
|
+
if (typeof filter.value === "number" && !Number.isSafeInteger(filter.value))
|
|
12407
|
+
continue;
|
|
12408
|
+
parts.push("AND (CASE WHEN value_type = 'json' AND json_valid(value) THEN json_extract(value, ?) END) = ?");
|
|
12409
|
+
params.push(`$."${filter.field}"`, filter.value);
|
|
12410
|
+
}
|
|
12411
|
+
return { sql: parts.join(" "), params };
|
|
12412
|
+
}
|
|
12166
12413
|
async function listKv(namespace, opts) {
|
|
12167
12414
|
const now = Date.now();
|
|
12168
|
-
|
|
12169
|
-
|
|
12170
|
-
const rows2 = await getDbClient().query(`SELECT namespace, key, value, value_type, expires_at, created_at, updated_at
|
|
12171
|
-
FROM kv_entries
|
|
12172
|
-
WHERE namespace = ?
|
|
12173
|
-
AND (expires_at IS NULL OR expires_at > ?)
|
|
12174
|
-
AND key LIKE ? ESCAPE '\\'
|
|
12175
|
-
ORDER BY key
|
|
12176
|
-
LIMIT ? OFFSET ?`, [namespace, now, `${escaped}%`, opts.limit, opts.offset]);
|
|
12177
|
-
return rows2.map(decodeKvRow);
|
|
12178
|
-
}
|
|
12415
|
+
const prefix = kvPrefixCondition(opts.prefix);
|
|
12416
|
+
const json = kvJsonFieldConditions(opts.jsonFieldEquals);
|
|
12179
12417
|
const rows = await getDbClient().query(`SELECT namespace, key, value, value_type, expires_at, created_at, updated_at
|
|
12180
12418
|
FROM kv_entries
|
|
12181
12419
|
WHERE namespace = ?
|
|
12182
12420
|
AND (expires_at IS NULL OR expires_at > ?)
|
|
12421
|
+
${prefix.sql}
|
|
12422
|
+
${json.sql}
|
|
12183
12423
|
ORDER BY key
|
|
12184
|
-
LIMIT ? OFFSET ?`, [namespace, now, opts.limit, opts.offset]);
|
|
12424
|
+
LIMIT ? OFFSET ?`, [namespace, now, ...prefix.params, ...json.params, opts.limit, opts.offset]);
|
|
12185
12425
|
return rows.map(decodeKvRow);
|
|
12186
12426
|
}
|
|
12187
12427
|
async function countKv(namespace, opts) {
|
|
12188
12428
|
const now = Date.now();
|
|
12189
|
-
|
|
12190
|
-
const escaped = opts.prefix.replace(/[\\%_]/g, "\\$&");
|
|
12191
|
-
const row2 = await getDbClient().get(`SELECT COUNT(*) AS n FROM kv_entries
|
|
12192
|
-
WHERE namespace = ?
|
|
12193
|
-
AND (expires_at IS NULL OR expires_at > ?)
|
|
12194
|
-
AND key LIKE ? ESCAPE '\\'`, [namespace, now, `${escaped}%`]);
|
|
12195
|
-
return row2?.n ?? 0;
|
|
12196
|
-
}
|
|
12429
|
+
const prefix = kvPrefixCondition(opts.prefix);
|
|
12197
12430
|
const row = await getDbClient().get(`SELECT COUNT(*) AS n FROM kv_entries
|
|
12198
12431
|
WHERE namespace = ?
|
|
12199
|
-
AND (expires_at IS NULL OR expires_at > ?)
|
|
12432
|
+
AND (expires_at IS NULL OR expires_at > ?)
|
|
12433
|
+
${prefix.sql}`, [namespace, now, ...prefix.params]);
|
|
12200
12434
|
return row?.n ?? 0;
|
|
12201
12435
|
}
|
|
12202
12436
|
function parseJsonColumn(value) {
|
|
@@ -12515,7 +12749,7 @@ END`, ELIGIBILITY_SCAN_BATCH_SIZE, ELIGIBILITY_SCAN_CAP, UNATTRIBUTED_USER_ID =
|
|
|
12515
12749
|
AND run.created_by IS NULL
|
|
12516
12750
|
)
|
|
12517
12751
|
)
|
|
12518
|
-
)`, SCHEDULE_TEMPLATE_PREVIEW_LENGTH = 280, RESERVED_CONFIG_PLACEHOLDER = "[reserved key stored in swarm_config; delete this row]", SKILL_FILE_LIMITS, BINARY_SKILL_FILE_PLACEHOLDER = "[binary file - not synced]", SKILL_SLIM_COLUMNS = "id, name, description, type, scope, ownerAgentId, sourceUrl, sourceRepo, sourcePath, sourceBranch, sourceHash, isComplex, allowedTools, model, effort, context, agent, disableModelInvocation, userInvocable, version, isEnabled, systemDefault, createdAt, lastUpdatedAt, lastFetchedAt, '' as content", WEEK_SECONDS, KvTypeCollisionError;
|
|
12752
|
+
)`, SCHEDULE_TEMPLATE_PREVIEW_LENGTH = 280, RESERVED_CONFIG_PLACEHOLDER = "[reserved key stored in swarm_config; delete this row]", WORKFLOW_RUN_SUMMARY_COLUMNS = "id, workflowId, status, triggerType, triggerData, error, created_by, startedAt, lastUpdatedAt, finishedAt", SKILL_FILE_LIMITS, BINARY_SKILL_FILE_PLACEHOLDER = "[binary file - not synced]", SKILL_SLIM_COLUMNS = "id, name, description, type, scope, ownerAgentId, sourceUrl, sourceRepo, sourcePath, sourceBranch, sourceHash, isComplex, allowedTools, model, effort, context, agent, disableModelInvocation, userInvocable, version, isEnabled, systemDefault, createdAt, lastUpdatedAt, lastFetchedAt, '' as content", WEEK_SECONDS, KvTypeCollisionError;
|
|
12519
12753
|
var init_db = __esm(() => {
|
|
12520
12754
|
init_package();
|
|
12521
12755
|
init_key();
|
|
@@ -12536,6 +12770,7 @@ var init_db = __esm(() => {
|
|
|
12536
12770
|
init_crypto();
|
|
12537
12771
|
init_date_utils();
|
|
12538
12772
|
init_agents();
|
|
12773
|
+
init_approvals();
|
|
12539
12774
|
init_context_versions();
|
|
12540
12775
|
init_runtime();
|
|
12541
12776
|
init_read();
|
|
@@ -12544,6 +12779,7 @@ var init_db = __esm(() => {
|
|
|
12544
12779
|
init_swarm_config_guard();
|
|
12545
12780
|
init_task_lifecycle_events();
|
|
12546
12781
|
init_agents();
|
|
12782
|
+
init_approvals();
|
|
12547
12783
|
init_context_versions();
|
|
12548
12784
|
init_runtime();
|
|
12549
12785
|
init_read();
|
|
@@ -12599,4 +12835,4 @@ var init_db = __esm(() => {
|
|
|
12599
12835
|
};
|
|
12600
12836
|
});
|
|
12601
12837
|
|
|
12602
|
-
export { slackContextKey, agentmailContextKey, githubContextKey, gitlabContextKey, linearContextKey, buildJiraContextKey, scheduleContextKey, workflowContextKey, agentContextKey, pageContextKey, init_context_key, checkSlackRoutingCoherence, init_slack_routing, _resolveIntegrationType, _resolveIntegrationProvider, initTelemetry, telemetry, emitIntegrationConnected, init_telemetry, HeartbeatExpiryError, init_heartbeat_expiry, beginRequestAuthScope, setRequestAuth, getRequestAuth, getCurrentRequestAuth, runWithoutRequestAuth, init_request_auth_context, auditAssetKeys, init_asset_key_audit, encryptSecret, decryptSecret, getEncryptionKey, init_crypto, normalizeDate, normalizeDateRequired, init_date_utils, CredentialBindingSchema, placeholderForConfigKey, CredentialBroker, DEFAULT_CREDENTIAL_BINDINGS, init_credential_broker, isInTransaction, init_db_client, getPromptTemplateDefaultDrift, init_default_drift, init_templates2 as init_templates, isSqliteVecAvailable, resolveSqliteVecExtensionPath, __resetSqliteVecExtensionPathCacheForTests, initDb, getDb, closeDb, getDbClient, updateAgentCredentialState, updateAgentCredentialMissing, createAgent, getAgentById, EXTENSION_AGENT_ROLE, NOT_EXTENSION_AGENT_SQL, isExtensionAgent, extensionAgentAssignmentError, ReservedAgentRoleError, reservedRoleViolation, ExtensionAgentAssignmentError, getAllAgents, getLeadAgent, updateAgentStatus, updateAgentMaxTasks, updateAgentProvider, setAgentHarnessProvider, updateAgentCredStatus, listAgentsWithCredStatusByProvider, getAgentHarnessProviders, updateAgentActivity, MAX_EMPTY_POLLS, incrementEmptyPollCount, resetEmptyPollCount, shouldBlockPolling, deleteAgent, getActiveTaskCount, hasCapacity, getRemainingCapacity, updateAgentStatusFromCapacity, isPoolAffinityEnforcementEnabled, buildRoutingAffinityFromAgent, isAgentEligibleForTask, computeContentHash, createContextVersion, getLatestContextVersion, getContextVersion, getContextVersionHistory, getTaskById, getChildTasks, hasNonTerminalResumeChild, hasNonTerminalRerouteDecisionChild, getTasksByAgentId, getAgentCurrentTask, getTasksByStatus, findTaskByVcs, findTaskByGitHub, getAllTasks, getTasksCount, getTaskStats, getCompletedSlackTasks, getPendingSlackRelayTasks, markSlackRelayAttempted, markSlackRelayDelivered, markFinalizedSlackRelaysDelivered, getRecentlyFinishedWorkerTasks, markTasksNotified, resetTasksNotified, getInProgressSlackTasks, getSlackTasksMissingTree, getInProgressTasksByContextKey, findExistingLinearTrackerContextWork, getLatestTaskByContextKey, getLatestScriptRunStepTaskByContextKey, getAgentWorkingOnThread, getLatestActiveTaskInThread, getLatestLeadTaskInThread, getMostRecentTaskInThread, findCompletedTaskInThread, findRecentCancelledTaskInThread, onTaskStarted, init_task_lifecycle_events, createTask, getPendingTaskForAgent, assignUnassignedTaskPending, startTask, updateTaskClaudeSessionId, updateTaskTitle, completeTask, failTask, overwriteTerminalTaskResultText, cancelTask, supersedeTask, backfillSupersedeTaskResumeTaskId, pauseTask, resumeTask, getPausedTasksForAgent, getOrphanedInProgressTasksForAgent, resetOrphanedInProgressTasksForAgent, getRecentlyCancelledTasksForAgent, deleteTask, updateTaskProgress, SteeringRequestError, isSteeringEnabled2 as isSteeringEnabled, getTaskSteeringFields, promotePendingSteeringForTask, markSteeringUndeliverable, requestSteering, init_steering, SLACK_REACTION_DEFAULTS, SLACK_REACTION_CONFIG_KEYS, reactionName, init_reaction_shortcode, parseTaskToolManifest, selectTaskTools, init_task_tool_manifest, isInternalConfigKey, internalConfigKeyError, isReservedConfigKey, reservedKeyError, MAX_DB_RETENTION_DAYS, DB_RETENTION_TUNING_BOUNDS, validateConfigValue, init_swarm_config_guard, getSlackRenderV2ActivatedAt, ensureSlackRenderV2Activation, getSlackDelegationActivatedAt, ensureSlackDelegationActivation, isPendingSlackMessage, isSettledSlackMessage, recordSlackMessage, reserveSlackMessage, bindSlackMessageTimestamp, updateSlackMessageRecord, markSlackTreeRendered, deleteSlackMessageRecord, getSlackTreeMessage, getSlackTreeMessageByThread, getSlackOutcomeMessage, getResolvableDeferralOutcomes, markSlackDeferralResolved, noteSlackOutcomeDeliveryFailure, abandonSlackOutcomeDelivery, getSlackTreeMessages, getSlackMessageByChannelTs, getSlackTasksInThread, markTaskSlackReplySent, setSlackMessageTracking, updateTaskVcs, insertTaskAttachment, recordTaskPullRequestAttachments, getAssetKeyMappingByProvider, upsertAssetKeyMapping, getAssetKeyMapping, listAssetSummaries, moveAssetKey, deleteTaskAttachment, replaceTaskAttachment, getTaskAttachments, createSteeringMessage, getSteeringMessagesForTask, getSteeringMessageById, getPendingSteeringForTask, getPendingSteeringForAgent, markSteeringDelivered, markSteeringHandled, markSteeringPromoted, cancelPendingSteeringForTask, hasPendingSteering, getAgentWithTasks, getAllAgentsWithTasks, createLogEntry, getLogsByAgentId, getLogsByTaskId, getLogsByTaskIdAndEventType, getLogsByTaskIdChronological, getLogsByEventType, getAllLogs, findRecentSimilarTasks, createTaskExtended, claimTask, releaseTask, acceptTask, rejectTask, moveTaskToBacklog, moveTaskFromBacklog, promoteDraftTask, refreshDraftTaskLease, promoteAbandonedDraftTasks, releaseStaleReviewingTasks, releaseStaleOfferedTasksForOfflineAgents, getOfferedTasksForAgent, claimOfferedTask, getUnassignedTasksCount, getUnassignedTaskIds, getUnassignedTaskIdsForAgent, checkDependencies, getDependentTasks, cascadeFailDependents, updateAgentProfile, updateAgentName, createChannel, getMessageById, getChannelById, getChannelByName, getAllChannels, deleteChannel, postMessage, getChannelMessages, updateReadState, getLastReadAt, getUnreadMessages, getMentionsForAgent, getInboxSummary, claimMentions, releaseMentionProcessing, releaseStaleMentionProcessing, createService, getServiceById, getServiceByAgentAndName, getServicesByAgentId, getAllServices, updateServiceStatus, deleteService, upsertService, deleteServicesByAgentId, createSessionLogs, getSessionLogsByTaskId, getSessionLogsBySession, createSessionCost, getSessionCostsByTaskId, getSessionCostsByAgentId, getAllSessionCosts, getSessionCostsFiltered, UNATTRIBUTED_USER_ID, getSessionCostSummary, getUsageDataVersion, getAttributionByPerson, getDashboardCostSummary, createInboxMessage, getInboxMessageById, getUnreadInboxMessages, claimInboxMessages, markInboxMessageRead, markInboxMessageResponded, markInboxMessageDelegated, releaseStaleProcessingInbox, getConcurrentContext, getScheduledTasks, getScheduledTaskById, getScheduledTaskByName, createScheduledTask, updateScheduledTask, deleteScheduledTask, getDueScheduledTasks, autoEncryptLegacyPlaintextSecrets, maskSecrets, getSwarmConfigs, getInjectableGlobalConfigs, getSwarmConfigById, getSwarmConfigLookupById, upsertSwarmConfig, emitBuiltInIntegrationConnectedOnce, deleteSwarmConfig, deleteSwarmConfigByKey, getResolvedConfig, getSwarmRepos, getSwarmRepoById, getSwarmRepoByName, getSwarmRepoByUrl, createSwarmRepo, updateSwarmRepo, deleteSwarmRepo, getAgentMailInboxMapping, getAgentMailInboxMappingsByAgent, getAllAgentMailInboxMappings, createAgentMailInboxMapping, deleteAgentMailInboxMapping, findTaskByAgentMailThread, insertActiveSession, deleteActiveSession, deleteActiveSessionById, getActiveSessions, heartbeatActiveSession, cleanupStaleSessions, cleanupAgentSessions, updateActiveSessionProviderSessionId, getActiveSessionForTask, reassociateSessionLogs, getStalledInProgressTasks, getStalePinnedResumes, failPendingResumeIfUnclaimed, getIdleWorkersWithCapacity, getUnassignedPoolTasks, getStaleUnassignedAffinityTasks, getRecentFailedTasks, getRecentCompletedCount, getRecentFailedCount, createWorkflow, getWorkflow, listWorkflows, updateWorkflow, deleteWorkflow, getWorkflowsByScheduleId, createWorkflowRun, getWorkflowRun, updateWorkflowRun, listWorkflowRuns, countWorkflowRuns, listWorkflowRunsPage, createWorkflowRunStep, getWorkflowRunStep, updateWorkflowRunStep, getWorkflowRunStepsByRunId, getStuckWorkflowRuns, getLastSuccessfulRun, getLastRunStart, getRetryableSteps, getCompletedStepNodeIds, getTaskByWorkflowRunStepId, detachTaskFromWorkflowRunStep, getStepByIdempotencyKey, getStepCountForNode, getLatestStepForNode, createWorkflowVersion, getWorkflowVersions, getWorkflowVersion, createAppVersion, getAppVersions, getAppVersion, createPage, getPage, getPageBySlug, getLatestPageBySlug, listPagesByAgent, listAllPages, countAllPages, countPagesByAgent, updatePage, deletePage, incrementPageViewCount, createPageVersion, getPageVersions, getPageVersion, createMetric, getMetric, getMetricBySlug, listMetricsByAgent, listAllMetrics, countAllMetrics, countMetricsByAgent, updateMetric, deleteMetric, createMetricVersion, getMetricVersions, getMetricVersion, getPromptTemplates, getPromptTemplateById, upsertPromptTemplate, deletePromptTemplate, resetPromptTemplateToDefault, getPromptTemplateHistory, resolvePromptTemplate, checkoutPromptTemplate, getAllChannelActivityCursors, getChannelActivityCursor, upsertChannelActivityCursor, createApprovalRequest, getApprovalRequestById, resolveApprovalRequest, cancelPendingApprovalRequestsForRun, listCancelledApprovalRequestsForRun, listCancelledApprovalRequestsForStep, claimApprovalCancellationNotification, completeApprovalCancellationNotificationClaim, releaseApprovalCancellationNotificationClaim, updateApprovalRequestNotifications, listApprovalRequests, getStuckApprovalRuns, getApprovalRequestByStepId, getExpiredPendingApprovals, createWaitState, getWaitStateById, getWaitStateByStepId, getDueWaitStates, getPendingEventWaitNames, getPendingWaitsByEvent, resolveWaitState, getStuckWaitRuns, SKILL_FILE_LIMITS, normalizeSkillFilePath, createSkill, updateSkill, listSkillFileManifest, getSkillFiles, getSkillFile, upsertSkillFile, upsertSkillFiles, deleteSkillFile, deleteSkill, getSkillById, getSkillByName, listSkills, searchSkills, installSkill, getSystemDefaultSkills, installSystemDefaultSkillsForAgent, uninstallSkill, getAgentSkills, toggleAgentSkill, createMcpServer, emitMcpServerConnectedTelemetry, updateMcpServer, deleteMcpServer, getMcpServerById, getMcpServerByName, listMcpServers, installMcpServer, uninstallMcpServer, getAgentMcpServers, createContextSnapshot, getContextSnapshotsByTaskId, getContextSnapshotsBySessionId, getContextSummaryByTaskId, getAvailableKeyIndices, recordKeyUsage, setApiKeyPlan, markKeyRateLimited, recordKeyRateLimitWindows, setApiKeyName, clearKeyRateLimit, getKeyStatuses, getKeyCostSummary, getUserById, getAllUsers, createUser, updateUser, deleteUser, listInboxState, upsertInboxState, listFavorites, listUserFavorites, getFavoriteItemIdSet, setFavorite, setUserFavorite, withFavoriteFlags, listTaskTemplates, getRootTaskChain, listRecentSessions, countSessions, getBudget, getBudgets, upsertBudget, deleteBudget, getAllPricingRows, getPricingRows, getActivePricingRow, insertPricingRow, deletePricingRow, getDailySpendForAgent, getDailySpendGlobal, getDailySpendForUser, recordBudgetRefusalNotification, getBudgetRefusalNotification, getRecentBudgetRefusalNotifications, hasBudgetRefusalNotificationToday, setBudgetRefusalFollowUpTaskId, getLiveAgentCounts, getReadyAgentCounts, getInstanceActivity, getSwarmMetrics, hasFirstCompletedTask, getKv, sweepExpiredKv, sweepExpiredKvPrefix, upsertKv, claimKv, deleteKv, KvTypeCollisionError, incrKv, listKv, countKv, createScriptRun, recordInlineScriptRun, getScriptRun, getScriptRunByIdempotencyKey, listScriptRuns, countScriptRuns, countActiveScriptRuns, updateScriptRun, updateScriptRunIfNotTerminal, updateScriptRunIfRunning, getRunningScriptRuns, getScriptRunJournalStep, upsertScriptRunJournalStep, listScriptRunJournalSteps, countScriptRunJournalSteps, countScriptRunJournalAgentTaskSteps, exports_db, init_db };
|
|
12838
|
+
export { slackContextKey, agentmailContextKey, githubContextKey, gitlabContextKey, linearContextKey, buildJiraContextKey, scheduleContextKey, workflowContextKey, agentContextKey, pageContextKey, init_context_key, checkSlackRoutingCoherence, init_slack_routing, _resolveIntegrationType, _resolveIntegrationProvider, initTelemetry, telemetry, emitIntegrationConnected, init_telemetry, HeartbeatExpiryError, init_heartbeat_expiry, beginRequestAuthScope, setRequestAuth, getRequestAuth, getCurrentRequestAuth, runWithoutRequestAuth, init_request_auth_context, auditAssetKeys, init_asset_key_audit, encryptSecret, decryptSecret, getEncryptionKey, init_crypto, normalizeDate, normalizeDateRequired, init_date_utils, CredentialBindingSchema, placeholderForConfigKey, CredentialBroker, DEFAULT_CREDENTIAL_BINDINGS, init_credential_broker, isInTransaction, init_db_client, getPromptTemplateDefaultDrift, init_default_drift, init_templates2 as init_templates, isSqliteVecAvailable, resolveSqliteVecExtensionPath, __resetSqliteVecExtensionPathCacheForTests, initDb, getDb, closeDb, getDbClient, updateAgentCredentialState, updateAgentCredentialMissing, createAgent, getAgentById, EXTENSION_AGENT_ROLE, NOT_EXTENSION_AGENT_SQL, isExtensionAgent, extensionAgentAssignmentError, ReservedAgentRoleError, reservedRoleViolation, ExtensionAgentAssignmentError, getAllAgents, getLeadAgent, updateAgentStatus, updateAgentMaxTasks, updateAgentProvider, setAgentHarnessProvider, updateAgentCredStatus, listAgentsWithCredStatusByProvider, getAgentHarnessProviders, updateAgentActivity, MAX_EMPTY_POLLS, incrementEmptyPollCount, resetEmptyPollCount, shouldBlockPolling, deleteAgent, getActiveTaskCount, hasCapacity, getRemainingCapacity, updateAgentStatusFromCapacity, isPoolAffinityEnforcementEnabled, buildRoutingAffinityFromAgent, isAgentEligibleForTask, getAgentDailyTaskCounts, listApprovalRequestSummaries, computeContentHash, createContextVersion, getLatestContextVersion, getContextVersion, getContextVersionHistory, getTaskById, getChildTasks, hasNonTerminalResumeChild, getSupersededTasksWithoutResume, hasNonTerminalRerouteDecisionChild, getTasksByAgentId, getAgentCurrentTask, getTasksByStatus, findTaskByVcs, findTaskByGitHub, getAllTasks, getTasksCount, getTaskStats, getCompletedSlackTasks, getPendingSlackRelayTasks, markSlackRelayAttempted, markSlackRelayDelivered, markFinalizedSlackRelaysDelivered, getRecentlyFinishedWorkerTasks, markTasksNotified, resetTasksNotified, getInProgressSlackTasks, getSlackTasksMissingTree, getInProgressTasksByContextKey, findExistingLinearTrackerContextWork, getLatestTaskByContextKey, getLatestScriptRunStepTaskByContextKey, getAgentWorkingOnThread, getLatestActiveTaskInThread, getLatestLeadTaskInThread, getMostRecentTaskInThread, findCompletedTaskInThread, findRecentCancelledTaskInThread, onTaskStarted, init_task_lifecycle_events, createTask, getPendingTaskForAgent, assignUnassignedTaskPending, startTask, updateTaskClaudeSessionId, updateTaskTitle, completeTask, failTask, overwriteTerminalTaskResultText, cancelTask, supersedeTask, backfillSupersedeTaskResumeTaskId, pauseTask, resumeTask, getPausedTasksForAgent, getOrphanedInProgressTasksForAgent, resetOrphanedInProgressTasksForAgent, getRecentlyCancelledTasksForAgent, deleteTask, updateTaskProgress, SteeringRequestError, isSteeringEnabled2 as isSteeringEnabled, getTaskSteeringFields, getTaskSteeringFieldsForTasks, promotePendingSteeringForTask, markSteeringUndeliverable, requestSteering, init_steering, SLACK_REACTION_DEFAULTS, SLACK_REACTION_CONFIG_KEYS, reactionName, init_reaction_shortcode, parseTaskToolManifest, selectTaskTools, init_task_tool_manifest, isInternalConfigKey, internalConfigKeyError, isReservedConfigKey, reservedKeyError, MAX_DB_RETENTION_DAYS, DB_RETENTION_TUNING_BOUNDS, validateConfigValue, init_swarm_config_guard, getSlackRenderV2ActivatedAt, ensureSlackRenderV2Activation, getSlackDelegationActivatedAt, ensureSlackDelegationActivation, isPendingSlackMessage, isSettledSlackMessage, recordSlackMessage, reserveSlackMessage, bindSlackMessageTimestamp, updateSlackMessageRecord, markSlackTreeRendered, deleteSlackMessageRecord, getSlackTreeMessage, getSlackTreeMessageByThread, getSlackOutcomeMessage, getResolvableDeferralOutcomes, markSlackDeferralResolved, noteSlackOutcomeDeliveryFailure, abandonSlackOutcomeDelivery, getSlackTreeMessages, getSlackMessageByChannelTs, getSlackTasksInThread, markTaskSlackReplySent, setSlackMessageTracking, updateTaskVcs, insertTaskAttachment, recordTaskPullRequestAttachments, getAssetKeyMappingByProvider, upsertAssetKeyMapping, getAssetKeyMapping, listAssetSummaries, moveAssetKey, deleteTaskAttachment, replaceTaskAttachment, getTaskAttachments, createSteeringMessage, getSteeringMessagesForTask, getSteeringMessageById, getPendingSteeringForTask, getPendingSteeringForAgent, markSteeringDelivered, markSteeringHandled, markSteeringPromoted, cancelPendingSteeringForTask, hasPendingSteering, getAgentWithTasks, getAllAgentsWithTasks, createLogEntry, getLogsByAgentId, getLogsByTaskId, getLogsByTaskIdAndEventType, getLogsByTaskIdChronological, getLogsByEventType, getAllLogs, findRecentSimilarTasks, createTaskExtended, claimTask, releaseTask, acceptTask, rejectTask, moveTaskToBacklog, moveTaskFromBacklog, promoteDraftTask, refreshDraftTaskLease, promoteAbandonedDraftTasks, releaseStaleReviewingTasks, releaseStaleOfferedTasksForOfflineAgents, getOfferedTasksForAgent, claimOfferedTask, getUnassignedTasksCount, getUnassignedTaskIds, getUnassignedTaskIdsForAgent, checkDependencies, getDependentTasks, cascadeFailDependents, updateAgentProfile, updateAgentName, createChannel, getMessageById, getChannelById, getChannelByName, getAllChannels, deleteChannel, postMessage, getChannelMessages, updateReadState, getLastReadAt, getUnreadMessages, getMentionsForAgent, getInboxSummary, claimMentions, releaseMentionProcessing, releaseStaleMentionProcessing, createService, getServiceById, getServiceByAgentAndName, getServicesByAgentId, getAllServices, updateServiceStatus, deleteService, upsertService, deleteServicesByAgentId, createSessionLogs, getSessionLogsByTaskId, getSessionLogsBySession, createSessionCost, getSessionCostsByTaskId, getSessionCostsByAgentId, getAllSessionCosts, getSessionCostsFiltered, UNATTRIBUTED_USER_ID, getSessionCostSummary, getUsageDataVersion, getAttributionByPerson, getDashboardCostSummary, createInboxMessage, getInboxMessageById, getUnreadInboxMessages, claimInboxMessages, markInboxMessageRead, markInboxMessageResponded, markInboxMessageDelegated, releaseStaleProcessingInbox, getConcurrentContext, getScheduledTasks, getScheduledTaskById, getScheduledTaskByName, createScheduledTask, updateScheduledTask, deleteScheduledTask, getDueScheduledTasks, autoEncryptLegacyPlaintextSecrets, maskSecrets, getSwarmConfigs, getInjectableGlobalConfigs, getSwarmConfigById, getSwarmConfigLookupById, upsertSwarmConfig, emitBuiltInIntegrationConnectedOnce, deleteSwarmConfig, deleteSwarmConfigByKey, getResolvedConfig, getSwarmRepos, getSwarmRepoById, getSwarmRepoByName, getSwarmRepoByUrl, createSwarmRepo, updateSwarmRepo, deleteSwarmRepo, getAgentMailInboxMapping, getAgentMailInboxMappingsByAgent, getAllAgentMailInboxMappings, createAgentMailInboxMapping, deleteAgentMailInboxMapping, findTaskByAgentMailThread, insertActiveSession, deleteActiveSession, deleteActiveSessionById, getActiveSessions, heartbeatActiveSession, cleanupStaleSessions, cleanupAgentSessions, updateActiveSessionProviderSessionId, getActiveSessionForTask, reassociateSessionLogs, getStalledInProgressTasks, getStalePinnedResumes, failPendingResumeIfUnclaimed, getIdleWorkersWithCapacity, getUnassignedPoolTasks, getStaleUnassignedAffinityTasks, getRecentFailedTasks, getRecentCompletedCount, getRecentFailedCount, createWorkflow, getWorkflow, listWorkflows, updateWorkflow, deleteWorkflow, getWorkflowsByScheduleId, createWorkflowRun, getWorkflowRun, updateWorkflowRun, listWorkflowRuns, countWorkflowRuns, listWorkflowRunsPage, createWorkflowRunStep, getWorkflowRunStep, updateWorkflowRunStep, getWorkflowRunStepsByRunId, getStuckWorkflowRuns, getLastSuccessfulRun, getLastRunStart, getRetryableSteps, getCompletedStepNodeIds, getTaskByWorkflowRunStepId, detachTaskFromWorkflowRunStep, getStepByIdempotencyKey, getStepCountForNode, getLatestStepForNode, getCurrentStepForNode, createWorkflowVersion, getWorkflowVersions, getWorkflowVersion, createAppVersion, getAppVersions, getAppVersion, createPage, getPage, getPageBySlug, getLatestPageBySlug, listPagesByAgent, listAllPages, countAllPages, countPagesByAgent, updatePage, deletePage, incrementPageViewCount, createPageVersion, getPageVersions, getPageVersion, createMetric, getMetric, getMetricBySlug, listMetricsByAgent, listAllMetrics, countAllMetrics, countMetricsByAgent, updateMetric, deleteMetric, createMetricVersion, getMetricVersions, getMetricVersion, getPromptTemplates, getPromptTemplateById, upsertPromptTemplate, deletePromptTemplate, resetPromptTemplateToDefault, getPromptTemplateHistory, resolvePromptTemplate, checkoutPromptTemplate, getAllChannelActivityCursors, getChannelActivityCursor, upsertChannelActivityCursor, createApprovalRequest, getApprovalRequestById, resolveApprovalRequest, cancelApprovalRequestById, cancelPendingApprovalRequestsForRun, listCancelledApprovalRequestsForRun, listCancelledApprovalRequestsForStep, claimApprovalCancellationNotification, completeApprovalCancellationNotificationClaim, releaseApprovalCancellationNotificationClaim, updateApprovalRequestNotifications, listApprovalRequests, getStuckApprovalRuns, getApprovalRequestByStepId, getExpiredPendingApprovals, getStaleApprovalRequests, createWaitState, getWaitStateById, getWaitStateByStepId, getDueWaitStates, getPendingEventWaitNames, getPendingWaitsByEvent, resolveWaitState, getStuckWaitRuns, SKILL_FILE_LIMITS, normalizeSkillFilePath, createSkill, updateSkill, listSkillFileManifest, getSkillFiles, getSkillFile, upsertSkillFile, upsertSkillFiles, deleteSkillFile, deleteSkill, getSkillById, getSkillByName, listSkills, searchSkills, installSkill, getSystemDefaultSkills, installSystemDefaultSkillsForAgent, uninstallSkill, getAgentSkills, toggleAgentSkill, createMcpServer, emitMcpServerConnectedTelemetry, updateMcpServer, deleteMcpServer, getMcpServerById, getMcpServerByName, listMcpServers, installMcpServer, uninstallMcpServer, getAgentMcpServers, createContextSnapshot, getContextSnapshotsByTaskId, getContextSnapshotsBySessionId, getContextSummaryByTaskId, getAvailableKeyIndices, recordKeyUsage, setApiKeyPlan, markKeyRateLimited, recordKeyRateLimitWindows, setApiKeyName, clearKeyRateLimit, getKeyStatuses, getKeyCostSummary, getUserById, getAllUsers, createUser, updateUser, deleteUser, listInboxState, upsertInboxState, listFavorites, listUserFavorites, getFavoriteItemIdSet, setFavorite, setUserFavorite, withFavoriteFlags, listTaskTemplates, getRootTaskChain, listRecentSessions, countSessions, getBudget, getBudgets, upsertBudget, deleteBudget, getAllPricingRows, getPricingRows, getActivePricingRow, insertPricingRow, deletePricingRow, getDailySpendForAgent, getDailySpendGlobal, getDailySpendForUser, recordBudgetRefusalNotification, getBudgetRefusalNotification, getRecentBudgetRefusalNotifications, hasBudgetRefusalNotificationToday, setBudgetRefusalFollowUpTaskId, getLiveAgentCounts, getReadyAgentCounts, getInstanceActivity, getSwarmMetrics, hasFirstCompletedTask, getKv, sweepExpiredKv, sweepExpiredKvPrefix, upsertKv, claimKv, deleteKv, KvTypeCollisionError, incrKv, kvPrefixUpperBound, listKv, countKv, createScriptRun, recordInlineScriptRun, getScriptRun, getScriptRunByIdempotencyKey, listScriptRuns, countScriptRuns, countActiveScriptRuns, updateScriptRun, updateScriptRunIfNotTerminal, updateScriptRunIfRunning, getRunningScriptRuns, getScriptRunJournalStep, upsertScriptRunJournalStep, listScriptRunJournalSteps, countScriptRunJournalSteps, countScriptRunJournalAgentTaskSteps, exports_db, init_db };
|