@askexenow/exe-os 0.9.294 → 0.9.296
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/deploy/compose/cloudflared/config.yml.example +14 -9
- package/deploy/compose/docker-compose.yml +86 -8
- package/deploy/compose/sso-edge/default.conf.template +87 -0
- package/deploy/compose/sso-edge/entrypoint.sh +23 -0
- package/deploy/compose/sso-edge/sso-redirect.conf +63 -0
- package/deploy/stack-manifests/v0.9.json +2 -2
- package/dist/active-agent-AFX2FODG.js +28 -0
- package/dist/active-agent-E2IJA7YX.js +27 -0
- package/dist/agentic-ontology-A2YUZK5O.js +25 -0
- package/dist/assets/com.askexe.exed.plist +4 -1
- package/dist/backfill-metadata-OC7EOD5U.js +600 -0
- package/dist/behaviors-H5ZOVHDH.js +46 -0
- package/dist/bin/agentic-ontology-backfill.js +5 -5
- package/dist/bin/agentic-reflection-backfill.js +6 -6
- package/dist/bin/agentic-semantic-label.js +5 -5
- package/dist/bin/backfill-conversations.js +6 -6
- package/dist/bin/backfill-responses.js +6 -6
- package/dist/bin/backfill-vectors.js +8 -8
- package/dist/bin/bulk-sync-postgres.js +7 -7
- package/dist/bin/cc-doctor.js +4 -4
- package/dist/bin/cleanup-stale-review-tasks.js +11 -11
- package/dist/bin/cli.js +16 -16
- package/dist/bin/deferred-daemon-restart.js +1 -1
- package/dist/bin/exe-agent-config.js +2 -2
- package/dist/bin/exe-agent.js +4 -4
- package/dist/bin/exe-assign.js +8 -8
- package/dist/bin/exe-boot.js +21 -18
- package/dist/bin/exe-call.js +4 -4
- package/dist/bin/exe-cloud.js +7 -7
- package/dist/bin/exe-dispatch.js +11 -11
- package/dist/bin/exe-doctor.js +3 -2
- package/dist/bin/exe-export-behaviors.js +7 -7
- package/dist/bin/exe-forget.js +6 -6
- package/dist/bin/exe-gateway.js +7 -7
- package/dist/bin/exe-healthcheck.js +6 -4
- package/dist/bin/exe-heartbeat.js +11 -11
- package/dist/bin/exe-kill.js +14 -14
- package/dist/bin/exe-launch-agent.js +18 -18
- package/dist/bin/exe-new-employee.js +6 -6
- package/dist/bin/exe-pending-messages.js +12 -12
- package/dist/bin/exe-pending-notifications.js +11 -11
- package/dist/bin/exe-pending-reviews.js +11 -11
- package/dist/bin/exe-rename.js +4 -4
- package/dist/bin/exe-review.js +13 -13
- package/dist/bin/exe-search.js +5 -5
- package/dist/bin/exe-session-cleanup.js +16 -16
- package/dist/bin/exe-settings.js +39 -9
- package/dist/bin/exe-start-codex.js +11 -11
- package/dist/bin/exe-start-opencode.js +8 -8
- package/dist/bin/exe-status.js +12 -12
- package/dist/bin/exe-team.js +3 -3
- package/dist/bin/git-sweep.js +12 -12
- package/dist/bin/graph-backfill.js +4 -4
- package/dist/bin/graph-export.js +5 -5
- package/dist/bin/import-history.js +7 -7
- package/dist/bin/install-launchd.js +13 -6
- package/dist/bin/install.js +26 -14
- package/dist/bin/intercom-check.js +4 -4
- package/dist/bin/mcp-sessions.js +2 -2
- package/dist/bin/orchestration-metrics.js +4 -4
- package/dist/bin/postgres-agentic-reflection-backfill.js +2 -2
- package/dist/bin/postgres-agentic-semantic-backfill.js +1 -1
- package/dist/bin/scan-tasks.js +11 -11
- package/dist/bin/setup.js +1 -1
- package/dist/bin/shard-migrate.js +4 -4
- package/dist/bin/stack-update.js +2 -2
- package/dist/bin/vps-health-gate.js +1 -1
- package/dist/capability-cards-4USI7CUW.js +89 -0
- package/dist/capacity-monitor-WLCBTEYR.js +51 -0
- package/dist/catchup-brief-ZR3NX6LZ.js +175 -0
- package/dist/chunk-22TVSRQQ.js +226 -0
- package/dist/chunk-2E43UXRH.js +395 -0
- package/dist/chunk-2PIGT6UJ.js +460 -0
- package/dist/chunk-3XTMW2MZ.js +535 -0
- package/dist/chunk-465PQFTH.js +262 -0
- package/dist/chunk-5CCXU2AW.js +129 -0
- package/dist/chunk-5D6MPWR7.js +1094 -0
- package/dist/chunk-5Q4MR6SL.js +123 -0
- package/dist/chunk-6327RBWR.js +345 -0
- package/dist/chunk-6MZZREZY.js +199 -0
- package/dist/chunk-7DI2Q4O5.js +1186 -0
- package/dist/chunk-7PW5VNIY.js +122 -0
- package/dist/chunk-7T7Y56HW.js +43 -0
- package/dist/chunk-7UHCWCLT.js +128 -0
- package/dist/chunk-A2ZUMF6L.js +1350 -0
- package/dist/chunk-AKV44JEH.js +185 -0
- package/dist/chunk-ANHWGX5N.js +735 -0
- package/dist/chunk-BQ3P4TKD.js +97 -0
- package/dist/chunk-BUZMT3KZ.js +604 -0
- package/dist/chunk-C2SBESBO.js +210 -0
- package/dist/chunk-CLSXZUZW.js +51 -0
- package/dist/chunk-CONHLVAR.js +1079 -0
- package/dist/chunk-D3WTZPFX.js +456 -0
- package/dist/chunk-DE6SOIYL.js +197 -0
- package/dist/chunk-EIVNMA3Q.js +284 -0
- package/dist/chunk-EJIF4FNT.js +12 -0
- package/dist/chunk-FDFOW564.js +171 -0
- package/dist/chunk-GZUBJ5EC.js +127 -0
- package/dist/chunk-HGZITN22.js +105 -0
- package/dist/chunk-HSRKDU6X.js +362 -0
- package/dist/chunk-IIEN2PHV.js +85 -0
- package/dist/chunk-JQ56VLMM.js +567 -0
- package/dist/chunk-JVHHXRFY.js +280 -0
- package/dist/chunk-JXCXGZ3S.js +55 -0
- package/dist/chunk-K5ZO532Q.js +4388 -0
- package/dist/chunk-K6CAAMXF.js +97 -0
- package/dist/chunk-KA26YTNU.js +81 -0
- package/dist/chunk-KMUW5C3R.js +381 -0
- package/dist/chunk-KOO3J5PV.js +20 -0
- package/dist/chunk-LSV7OFIH.js +290 -0
- package/dist/chunk-LSVFDVNY.js +1158 -0
- package/dist/chunk-LXDQTW32.js +230 -0
- package/dist/chunk-MEP7OUVZ.js +181 -0
- package/dist/chunk-MN2B2LKS.js +240 -0
- package/dist/chunk-N2EAYPYQ.js +1352 -0
- package/dist/chunk-N7I2A667.js +70 -0
- package/dist/chunk-NLZHVIOP.js +630 -0
- package/dist/chunk-NUH5TRZL.js +227 -0
- package/dist/chunk-OAHEIH3G.js +167 -0
- package/dist/chunk-OBHRQGCK.js +58 -0
- package/dist/chunk-ODFA7B2V.js +54 -0
- package/dist/chunk-OSNUP45F.js +731 -0
- package/dist/chunk-OTPRHBTO.js +33 -0
- package/dist/chunk-P6MUA4QU.js +157 -0
- package/dist/chunk-PGIOFKSK.js +2093 -0
- package/dist/chunk-PSE7VHWK.js +50 -0
- package/dist/chunk-QIFUVZFW.js +331 -0
- package/dist/chunk-RDPXKTVK.js +221 -0
- package/dist/chunk-RKYTYJGB.js +76 -0
- package/dist/chunk-RXLR6EFM.js +348 -0
- package/dist/chunk-SDB67PQJ.js +159 -0
- package/dist/chunk-SF2T7MP3.js +402 -0
- package/dist/chunk-SLU3FRFQ.js +2133 -0
- package/dist/chunk-SNDZJ5IV.js +214 -0
- package/dist/chunk-STEEAABW.js +448 -0
- package/dist/chunk-TUTWNHIQ.js +244 -0
- package/dist/chunk-UDP35QBR.js +30 -0
- package/dist/chunk-UKFHNJBI.js +85 -0
- package/dist/chunk-VC2DTK2X.js +382 -0
- package/dist/chunk-VRRAE5JX.js +836 -0
- package/dist/chunk-VVJTBQPR.js +38 -0
- package/dist/chunk-W3EQ362K.js +581 -0
- package/dist/chunk-WHIXIFHC.js +2242 -0
- package/dist/chunk-WRNGJJNR.js +377 -0
- package/dist/chunk-WUKHLCBE.js +3313 -0
- package/dist/chunk-WVPLHGDG.js +150 -0
- package/dist/chunk-XJZBSTL5.js +204 -0
- package/dist/chunk-Y3PMNUM5.js +304 -0
- package/dist/chunk-YHVS4QOV.js +14597 -0
- package/dist/chunk-YJ2OYAOC.js +668 -0
- package/dist/chunk-YYAD2GXX.js +128 -0
- package/dist/chunk-ZQML7EWE.js +333 -0
- package/dist/co-activation-XJLH46OX.js +74 -0
- package/dist/co-occurrence-GNN2X526.js +95 -0
- package/dist/code-context-index-OCPRLFG5.js +30 -0
- package/dist/core-memory-J4W2IYOF.js +110 -0
- package/dist/crdt-sync-QCBTSHIH.js +33 -0
- package/dist/crm-webhook-EM442VUW.js +10 -0
- package/dist/cto-delegation-gate-MLJMVHBK.js +280 -0
- package/dist/daemon-orchestration-2VNLZVTW.js +139 -0
- package/dist/db-backup-VUGFTPJ4.js +43 -0
- package/dist/doc-graph-extractor-PNRSFPSS.js +133 -0
- package/dist/dreaming-SK5VEQRF.js +34 -0
- package/dist/entity-boost-TQWWJUC2.js +375 -0
- package/dist/exe-drift-N34UPO7S.js +70 -0
- package/dist/exe-export-KACBKGVV.js +77 -0
- package/dist/exe-import-GXGDWACG.js +80 -0
- package/dist/exe-key-XPDOZBWW.js +673 -0
- package/dist/exe-snapshot-32GQKGQ5.js +338 -0
- package/dist/fast-db-init-F3TDD5VV.js +7 -0
- package/dist/gateway/index.js +8 -8
- package/dist/git-staleness-J45WNYRF.js +112 -0
- package/dist/git-task-sweep-BTGVQPFB.js +42 -0
- package/dist/global-procedures-6JCQWU4D.js +22 -0
- package/dist/graph-auto-extract-3ZQNXTPC.js +183 -0
- package/dist/hooks/bug-report-worker.js +13 -13
- package/dist/hooks/codex-stop-task-finalizer.js +13 -13
- package/dist/hooks/commit-complete.js +13 -13
- package/dist/hooks/error-recall.js +6 -6
- package/dist/hooks/exe-heartbeat-hook.js +3 -3
- package/dist/hooks/ingest-worker.js +3 -3
- package/dist/hooks/ingest.js +6 -6
- package/dist/hooks/instructions-loaded.js +4 -4
- package/dist/hooks/manifest.json +20 -20
- package/dist/hooks/notification.js +4 -4
- package/dist/hooks/post-compact.js +12 -12
- package/dist/hooks/post-tool-combined.js +6 -6
- package/dist/hooks/pre-compact.js +16 -16
- package/dist/hooks/pre-tool-use.js +16 -16
- package/dist/hooks/prompt-submit.js +24 -24
- package/dist/hooks/session-end.js +21 -21
- package/dist/hooks/session-start.js +12 -12
- package/dist/hooks/stop.js +19 -19
- package/dist/hooks/subagent-stop.js +12 -12
- package/dist/hooks/summary-worker.js +19 -19
- package/dist/index.js +19 -19
- package/dist/installer-5VPFY7SB.js +298 -0
- package/dist/installer-OENFPMA2.js +344 -0
- package/dist/installer-OIX4QOG5.js +40 -0
- package/dist/lib/cloud-sync.js +7 -7
- package/dist/lib/consolidation.js +6 -5
- package/dist/lib/database.js +2 -2
- package/dist/lib/db-daemon-client.js +2 -2
- package/dist/lib/db.js +2 -2
- package/dist/lib/embed-worker.js +1 -0
- package/dist/lib/embedder.js +7 -3
- package/dist/lib/employee-templates.js +4 -4
- package/dist/lib/employees.js +2 -2
- package/dist/lib/exe-daemon-client.js +2 -2
- package/dist/lib/exe-daemon.js +160 -79
- package/dist/lib/hybrid-search.js +5 -5
- package/dist/lib/identity.js +2 -2
- package/dist/lib/messaging.js +11 -11
- package/dist/lib/reminders.js +3 -3
- package/dist/lib/schedules.js +5 -5
- package/dist/lib/session-registry.js +4 -4
- package/dist/lib/skill-learning.js +6 -6
- package/dist/lib/store.js +4 -4
- package/dist/lib/task-router.js +3 -3
- package/dist/lib/tasks.js +12 -12
- package/dist/lib/tmux-routing.js +12 -10
- package/dist/lib/tmux-transport.js +1 -1
- package/dist/lib/token-spend.js +3 -3
- package/dist/lib/transport.js +2 -2
- package/dist/mcp/register-tools.js +62 -61
- package/dist/mcp/server.js +63 -62
- package/dist/mcp/tools/complete-reminder.js +4 -4
- package/dist/mcp/tools/create-reminder.js +4 -4
- package/dist/mcp/tools/create-task.js +14 -14
- package/dist/mcp/tools/deactivate-behavior.js +7 -7
- package/dist/mcp/tools/list-reminders.js +4 -4
- package/dist/mcp/tools/list-tasks.js +14 -14
- package/dist/mcp/tools/send-message.js +13 -13
- package/dist/mcp/tools/update-task.js +13 -13
- package/dist/mcp-http-config-PQTOLCTP.js +29 -0
- package/dist/memory-cards-4RVDZIY2.js +180 -0
- package/dist/memory-graph-extractor-L6YC7G4M.js +22 -0
- package/dist/memory-poisoning-defense-4YVJYH4G.js +224 -0
- package/dist/memory-queue-client-MVAUOZNJ.js +16 -0
- package/dist/memory-reflection-SHHDQNOH.js +244 -0
- package/dist/message-queue-client-DCKZT6X2.js +92 -0
- package/dist/notifications-JFR3G42W.js +47 -0
- package/dist/orchestration-events-MGCGPTDN.js +27 -0
- package/dist/orchestrator-DAFL2YZB.js +35 -0
- package/dist/pipeline-router-WWSZVPCH.js +15 -0
- package/dist/plan-limits-C7XCSDZC.js +28 -0
- package/dist/project-boot-N3NTBVLE.js +299 -0
- package/dist/projection-worker-MTPAPCWX.js +1084 -0
- package/dist/prospective-memory-BTIVUJSB.js +232 -0
- package/dist/reranker-UA6WVESJ.js +19 -0
- package/dist/retrieval-health-7XNZJEBF.js +12 -0
- package/dist/review-polling-4ALGMXC3.js +126 -0
- package/dist/runtime/index.js +13 -13
- package/dist/self-query-router-MROFQLQB.js +192 -0
- package/dist/session-events-CK44XOU4.js +38 -0
- package/dist/session-kill-telemetry-MT6ITDOG.js +31 -0
- package/dist/session-scope-3XDBWV65.js +88 -0
- package/dist/setup-wizard-X6DOD7MC.js +12 -0
- package/dist/skill-refinement-G2CCY3GM.js +159 -0
- package/dist/stack-update-JF7F56AS.js +84 -0
- package/dist/steward-gate-YF2CYXE7.js +15 -0
- package/dist/task-enforcement-YN6HK7NE.js +506 -0
- package/dist/task-scope-CVK6ISCZ.js +37 -0
- package/dist/tasks-crud-NTNET4JE.js +79 -0
- package/dist/tasks-notify-4LJVFPCV.js +40 -0
- package/dist/tasks-review-3V4WOIRG.js +49 -0
- package/dist/telemetry-upload-5PNUKGTM.js +741 -0
- package/dist/token-budget-E46G7ZAQ.js +86 -0
- package/dist/tool-capability-index-JDSMKJER.js +10 -0
- package/dist/tool-telemetry-J3NLS3LJ.js +17 -0
- package/dist/tui/App.js +18 -18
- package/dist/tui-data-6DOMUUCM.js +260 -0
- package/dist/wiki-acl-5UK37LKF.js +111 -0
- package/dist/worker-gate-FM7AEC7G.js +21 -0
- package/dist/workflow-engine-2EDUHUIY.js +28 -0
- package/dist/worktree-7YKKJIYR.js +28 -0
- package/dist/worktree-sweep-C3ELFGDN.js +21 -0
- package/package.json +1 -1
- package/release-notes.json +88 -88
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getClient
|
|
3
|
+
} from "./chunk-WUKHLCBE.js";
|
|
4
|
+
import "./chunk-2I23RPSI.js";
|
|
5
|
+
import "./chunk-2E43UXRH.js";
|
|
6
|
+
import "./chunk-PNQDP3OA.js";
|
|
7
|
+
import "./chunk-7HLWBYH7.js";
|
|
8
|
+
import "./chunk-FXU7JOXK.js";
|
|
9
|
+
import "./chunk-R36FAN53.js";
|
|
10
|
+
import "./chunk-LYH5HE24.js";
|
|
11
|
+
import "./chunk-MLKGABMK.js";
|
|
12
|
+
|
|
13
|
+
// src/lib/prospective-memory.ts
|
|
14
|
+
import crypto from "crypto";
|
|
15
|
+
var PROSPECTIVE_RECURRENCES = [
|
|
16
|
+
"daily",
|
|
17
|
+
"weekly",
|
|
18
|
+
"monthly",
|
|
19
|
+
"once"
|
|
20
|
+
];
|
|
21
|
+
var PROSPECTIVE_STATUSES = [
|
|
22
|
+
"pending",
|
|
23
|
+
"completed",
|
|
24
|
+
"deferred"
|
|
25
|
+
];
|
|
26
|
+
function normalizeRecurrence(value) {
|
|
27
|
+
return PROSPECTIVE_RECURRENCES.includes(value) ? value : "once";
|
|
28
|
+
}
|
|
29
|
+
function clampPriority(value) {
|
|
30
|
+
const n = Number(value);
|
|
31
|
+
if (!Number.isFinite(n)) return 5;
|
|
32
|
+
return Math.min(10, Math.max(1, Math.round(n)));
|
|
33
|
+
}
|
|
34
|
+
function rowToProspective(row) {
|
|
35
|
+
return {
|
|
36
|
+
id: String(row.id),
|
|
37
|
+
agentId: String(row.agent_id),
|
|
38
|
+
content: String(row.content ?? ""),
|
|
39
|
+
dueDate: row.due_date != null ? String(row.due_date) : null,
|
|
40
|
+
recurrence: normalizeRecurrence(row.recurrence),
|
|
41
|
+
priority: clampPriority(row.priority),
|
|
42
|
+
status: PROSPECTIVE_STATUSES.includes(String(row.status)) ? String(row.status) : "pending",
|
|
43
|
+
lastSurfaced: row.last_surfaced != null ? String(row.last_surfaced) : null,
|
|
44
|
+
projectName: row.project_name != null ? String(row.project_name) : null,
|
|
45
|
+
sessionScope: row.session_scope != null ? String(row.session_scope) : null,
|
|
46
|
+
createdAt: String(row.created_at),
|
|
47
|
+
updatedAt: String(row.updated_at)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function nextDueDate(current, recurrence) {
|
|
51
|
+
if (recurrence === "once") return null;
|
|
52
|
+
const base = current ? new Date(current) : /* @__PURE__ */ new Date();
|
|
53
|
+
if (Number.isNaN(base.getTime())) return null;
|
|
54
|
+
const next = new Date(base.getTime());
|
|
55
|
+
switch (recurrence) {
|
|
56
|
+
case "daily":
|
|
57
|
+
next.setUTCDate(next.getUTCDate() + 1);
|
|
58
|
+
break;
|
|
59
|
+
case "weekly":
|
|
60
|
+
next.setUTCDate(next.getUTCDate() + 7);
|
|
61
|
+
break;
|
|
62
|
+
case "monthly":
|
|
63
|
+
next.setUTCMonth(next.getUTCMonth() + 1);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
return next.toISOString();
|
|
67
|
+
}
|
|
68
|
+
async function createProspectiveMemory(input) {
|
|
69
|
+
const id = crypto.randomUUID();
|
|
70
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
71
|
+
const record = {
|
|
72
|
+
id,
|
|
73
|
+
agentId: input.agentId.toLowerCase(),
|
|
74
|
+
content: input.content,
|
|
75
|
+
dueDate: input.dueDate ?? null,
|
|
76
|
+
recurrence: normalizeRecurrence(input.recurrence ?? "once"),
|
|
77
|
+
priority: clampPriority(input.priority ?? 5),
|
|
78
|
+
status: "pending",
|
|
79
|
+
lastSurfaced: null,
|
|
80
|
+
projectName: input.projectName ?? null,
|
|
81
|
+
sessionScope: input.sessionScope ?? null,
|
|
82
|
+
createdAt: now,
|
|
83
|
+
updatedAt: now
|
|
84
|
+
};
|
|
85
|
+
const client = getClient();
|
|
86
|
+
await client.execute({
|
|
87
|
+
sql: `INSERT INTO prospective_memories
|
|
88
|
+
(id, agent_id, content, due_date, recurrence, priority, status,
|
|
89
|
+
last_surfaced, project_name, session_scope, created_at, updated_at)
|
|
90
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
91
|
+
args: [
|
|
92
|
+
record.id,
|
|
93
|
+
record.agentId,
|
|
94
|
+
record.content,
|
|
95
|
+
record.dueDate,
|
|
96
|
+
record.recurrence,
|
|
97
|
+
record.priority,
|
|
98
|
+
record.status,
|
|
99
|
+
record.lastSurfaced,
|
|
100
|
+
record.projectName,
|
|
101
|
+
record.sessionScope,
|
|
102
|
+
record.createdAt,
|
|
103
|
+
record.updatedAt
|
|
104
|
+
]
|
|
105
|
+
});
|
|
106
|
+
return record;
|
|
107
|
+
}
|
|
108
|
+
async function getPendingProspective(agentId, options = {}) {
|
|
109
|
+
const client = getClient();
|
|
110
|
+
const cutoff = options.dueBefore ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
111
|
+
const limit = options.limit ?? 10;
|
|
112
|
+
const args = [agentId.toLowerCase(), cutoff];
|
|
113
|
+
let projectClause = "";
|
|
114
|
+
if (options.projectName) {
|
|
115
|
+
projectClause = " AND (project_name IS NULL OR project_name = ?)";
|
|
116
|
+
args.push(options.projectName);
|
|
117
|
+
}
|
|
118
|
+
args.push(limit);
|
|
119
|
+
const result = await client.execute({
|
|
120
|
+
sql: `SELECT id, agent_id, content, due_date, recurrence, priority, status,
|
|
121
|
+
last_surfaced, project_name, session_scope, created_at, updated_at
|
|
122
|
+
FROM prospective_memories
|
|
123
|
+
WHERE agent_id = ?
|
|
124
|
+
AND status = 'pending'
|
|
125
|
+
AND (due_date IS NULL OR due_date <= ?)${projectClause}
|
|
126
|
+
ORDER BY (due_date IS NULL) ASC, due_date ASC, priority ASC, created_at ASC
|
|
127
|
+
LIMIT ?`,
|
|
128
|
+
args
|
|
129
|
+
});
|
|
130
|
+
return result.rows.map((r) => rowToProspective(r));
|
|
131
|
+
}
|
|
132
|
+
async function markSurfaced(ids) {
|
|
133
|
+
if (ids.length === 0) return;
|
|
134
|
+
const client = getClient();
|
|
135
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
136
|
+
const placeholders = ids.map(() => "?").join(",");
|
|
137
|
+
await client.execute({
|
|
138
|
+
sql: `UPDATE prospective_memories SET last_surfaced = ?, updated_at = ?
|
|
139
|
+
WHERE id IN (${placeholders})`,
|
|
140
|
+
args: [now, now, ...ids]
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
async function getOverdueProspective(agentId, asOf) {
|
|
144
|
+
const client = getClient();
|
|
145
|
+
const cutoff = asOf ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
146
|
+
const result = await client.execute({
|
|
147
|
+
sql: `SELECT id, agent_id, content, due_date, recurrence, priority, status,
|
|
148
|
+
last_surfaced, project_name, session_scope, created_at, updated_at
|
|
149
|
+
FROM prospective_memories
|
|
150
|
+
WHERE agent_id = ?
|
|
151
|
+
AND status = 'pending'
|
|
152
|
+
AND due_date IS NOT NULL
|
|
153
|
+
AND due_date < ?
|
|
154
|
+
ORDER BY due_date ASC, priority ASC`,
|
|
155
|
+
args: [agentId.toLowerCase(), cutoff]
|
|
156
|
+
});
|
|
157
|
+
return result.rows.map((r) => rowToProspective(r));
|
|
158
|
+
}
|
|
159
|
+
async function completeProspective(id) {
|
|
160
|
+
const client = getClient();
|
|
161
|
+
const existing = await client.execute({
|
|
162
|
+
sql: `SELECT id, agent_id, content, due_date, recurrence, priority, status,
|
|
163
|
+
last_surfaced, project_name, session_scope, created_at, updated_at
|
|
164
|
+
FROM prospective_memories WHERE id = ?`,
|
|
165
|
+
args: [id]
|
|
166
|
+
});
|
|
167
|
+
if (existing.rows.length === 0) return null;
|
|
168
|
+
const record = rowToProspective(existing.rows[0]);
|
|
169
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
170
|
+
if (record.recurrence === "once") {
|
|
171
|
+
await client.execute({
|
|
172
|
+
sql: `UPDATE prospective_memories SET status = 'completed', updated_at = ? WHERE id = ?`,
|
|
173
|
+
args: [now, id]
|
|
174
|
+
});
|
|
175
|
+
return { ...record, status: "completed", updatedAt: now };
|
|
176
|
+
}
|
|
177
|
+
const advanced = nextDueDate(record.dueDate, record.recurrence);
|
|
178
|
+
await client.execute({
|
|
179
|
+
sql: `UPDATE prospective_memories SET due_date = ?, updated_at = ? WHERE id = ?`,
|
|
180
|
+
args: [advanced, now, id]
|
|
181
|
+
});
|
|
182
|
+
return { ...record, dueDate: advanced, updatedAt: now };
|
|
183
|
+
}
|
|
184
|
+
async function deferProspective(id, newDueDate) {
|
|
185
|
+
const client = getClient();
|
|
186
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
187
|
+
const existing = await client.execute({
|
|
188
|
+
sql: `SELECT id, agent_id, content, due_date, recurrence, priority, status,
|
|
189
|
+
last_surfaced, project_name, session_scope, created_at, updated_at
|
|
190
|
+
FROM prospective_memories WHERE id = ?`,
|
|
191
|
+
args: [id]
|
|
192
|
+
});
|
|
193
|
+
if (existing.rows.length === 0) return null;
|
|
194
|
+
await client.execute({
|
|
195
|
+
sql: `UPDATE prospective_memories SET due_date = ?, status = 'deferred', updated_at = ? WHERE id = ?`,
|
|
196
|
+
args: [newDueDate, now, id]
|
|
197
|
+
});
|
|
198
|
+
const record = rowToProspective(existing.rows[0]);
|
|
199
|
+
return { ...record, dueDate: newDueDate, status: "deferred", updatedAt: now };
|
|
200
|
+
}
|
|
201
|
+
async function listProspective(agentId, options = {}) {
|
|
202
|
+
const client = getClient();
|
|
203
|
+
const args = [agentId.toLowerCase()];
|
|
204
|
+
let statusClause = "";
|
|
205
|
+
if (options.status) {
|
|
206
|
+
statusClause = " AND status = ?";
|
|
207
|
+
args.push(options.status);
|
|
208
|
+
}
|
|
209
|
+
args.push(options.limit ?? 50);
|
|
210
|
+
const result = await client.execute({
|
|
211
|
+
sql: `SELECT id, agent_id, content, due_date, recurrence, priority, status,
|
|
212
|
+
last_surfaced, project_name, session_scope, created_at, updated_at
|
|
213
|
+
FROM prospective_memories
|
|
214
|
+
WHERE agent_id = ?${statusClause}
|
|
215
|
+
ORDER BY (due_date IS NULL) ASC, due_date ASC, priority ASC
|
|
216
|
+
LIMIT ?`,
|
|
217
|
+
args
|
|
218
|
+
});
|
|
219
|
+
return result.rows.map((r) => rowToProspective(r));
|
|
220
|
+
}
|
|
221
|
+
export {
|
|
222
|
+
PROSPECTIVE_RECURRENCES,
|
|
223
|
+
PROSPECTIVE_STATUSES,
|
|
224
|
+
completeProspective,
|
|
225
|
+
createProspectiveMemory,
|
|
226
|
+
deferProspective,
|
|
227
|
+
getOverdueProspective,
|
|
228
|
+
getPendingProspective,
|
|
229
|
+
listProspective,
|
|
230
|
+
markSurfaced,
|
|
231
|
+
nextDueDate
|
|
232
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
disposeReranker,
|
|
3
|
+
getRerankerModelPath,
|
|
4
|
+
isRerankerAvailable,
|
|
5
|
+
rerank,
|
|
6
|
+
rerankWithContext,
|
|
7
|
+
rerankWithScores
|
|
8
|
+
} from "./chunk-OBHRQGCK.js";
|
|
9
|
+
import "./chunk-R36FAN53.js";
|
|
10
|
+
import "./chunk-LYH5HE24.js";
|
|
11
|
+
import "./chunk-MLKGABMK.js";
|
|
12
|
+
export {
|
|
13
|
+
disposeReranker,
|
|
14
|
+
getRerankerModelPath,
|
|
15
|
+
isRerankerAvailable,
|
|
16
|
+
rerank,
|
|
17
|
+
rerankWithContext,
|
|
18
|
+
rerankWithScores
|
|
19
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isExeSession,
|
|
3
|
+
strictSessionScopeFilter
|
|
4
|
+
} from "./chunk-K5ZO532Q.js";
|
|
5
|
+
import "./chunk-JVHHXRFY.js";
|
|
6
|
+
import "./chunk-4JERP7NT.js";
|
|
7
|
+
import "./chunk-4FVVJ7ME.js";
|
|
8
|
+
import "./chunk-Y3PMNUM5.js";
|
|
9
|
+
import "./chunk-KOO3J5PV.js";
|
|
10
|
+
import "./chunk-22TVSRQQ.js";
|
|
11
|
+
import "./chunk-SSTLTIF3.js";
|
|
12
|
+
import "./chunk-NLZHVIOP.js";
|
|
13
|
+
import "./chunk-QRTJNSKU.js";
|
|
14
|
+
import "./chunk-NGP6LSV2.js";
|
|
15
|
+
import "./chunk-5CCXU2AW.js";
|
|
16
|
+
import "./chunk-CVYC6DUW.js";
|
|
17
|
+
import "./chunk-OPU3NYOO.js";
|
|
18
|
+
import "./chunk-GJV3WDWM.js";
|
|
19
|
+
import "./chunk-MP2AFCGL.js";
|
|
20
|
+
import "./chunk-N7I2A667.js";
|
|
21
|
+
import "./chunk-HYZV25LY.js";
|
|
22
|
+
import {
|
|
23
|
+
DEFAULT_COORDINATOR_TEMPLATE_NAME,
|
|
24
|
+
getCoordinatorName
|
|
25
|
+
} from "./chunk-WUKHLCBE.js";
|
|
26
|
+
import "./chunk-2I23RPSI.js";
|
|
27
|
+
import "./chunk-2E43UXRH.js";
|
|
28
|
+
import "./chunk-PNQDP3OA.js";
|
|
29
|
+
import "./chunk-7HLWBYH7.js";
|
|
30
|
+
import "./chunk-FXU7JOXK.js";
|
|
31
|
+
import "./chunk-YTKVJJSU.js";
|
|
32
|
+
import "./chunk-R36FAN53.js";
|
|
33
|
+
import "./chunk-LYH5HE24.js";
|
|
34
|
+
import "./chunk-MLKGABMK.js";
|
|
35
|
+
|
|
36
|
+
// src/lib/review-polling.ts
|
|
37
|
+
import { execSync } from "child_process";
|
|
38
|
+
async function pollPendingReviews(deps, _state) {
|
|
39
|
+
let sessions;
|
|
40
|
+
try {
|
|
41
|
+
sessions = deps.listTmuxSessions().filter((s) => isExeSession(s));
|
|
42
|
+
} catch (err) {
|
|
43
|
+
process.stderr.write(
|
|
44
|
+
`[review-polling] tmux session listing failed: ${err instanceof Error ? err.message : String(err)}
|
|
45
|
+
`
|
|
46
|
+
);
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
if (sessions.length === 0) return [];
|
|
50
|
+
const sent = [];
|
|
51
|
+
for (const exeSession of sessions) {
|
|
52
|
+
try {
|
|
53
|
+
const orphans = await deps.findOrphanedDoneTasks(exeSession);
|
|
54
|
+
for (const orphan of orphans) {
|
|
55
|
+
try {
|
|
56
|
+
await deps.createReviewForOrphan(orphan);
|
|
57
|
+
} catch {
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
} catch {
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return sent;
|
|
64
|
+
}
|
|
65
|
+
function createRealDeps(getClient) {
|
|
66
|
+
return {
|
|
67
|
+
listTmuxSessions: () => {
|
|
68
|
+
try {
|
|
69
|
+
return execSync("tmux list-sessions -F '#{session_name}' 2>/dev/null", {
|
|
70
|
+
encoding: "utf8",
|
|
71
|
+
timeout: 3e3
|
|
72
|
+
}).trim().split("\n").filter(Boolean);
|
|
73
|
+
} catch {
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
countPendingReviews: async (sessionScope) => {
|
|
78
|
+
const client = getClient();
|
|
79
|
+
const rpScope = strictSessionScopeFilter(sessionScope);
|
|
80
|
+
const result = await client.execute({
|
|
81
|
+
sql: `SELECT COUNT(*) as count FROM tasks
|
|
82
|
+
WHERE status = 'needs_review'${rpScope.sql}`,
|
|
83
|
+
args: [...rpScope.args]
|
|
84
|
+
});
|
|
85
|
+
return Number(result.rows[0]?.count ?? 0);
|
|
86
|
+
},
|
|
87
|
+
sendIntercom: (session) => {
|
|
88
|
+
import("./lib/tmux-routing.js").then(({ sendIntercom: centralSend }) => centralSend(session)).catch(() => {
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
findOrphanedDoneTasks: async (sessionScope) => {
|
|
92
|
+
const client = getClient();
|
|
93
|
+
const coordinatorName = getCoordinatorName();
|
|
94
|
+
const odScope = strictSessionScopeFilter(sessionScope, "t");
|
|
95
|
+
const result = await client.execute({
|
|
96
|
+
sql: `SELECT t.id, t.title, t.assigned_to, t.assigned_by,
|
|
97
|
+
t.project_name, t.task_file, t.result, t.status
|
|
98
|
+
FROM tasks t
|
|
99
|
+
WHERE t.status = 'needs_review'
|
|
100
|
+
AND t.assigned_to != ?
|
|
101
|
+
AND t.assigned_to != ?${odScope.sql}
|
|
102
|
+
AND (t.result IS NULL OR t.result NOT LIKE '%## Review notes%')`,
|
|
103
|
+
args: [coordinatorName, DEFAULT_COORDINATOR_TEMPLATE_NAME, ...odScope.args]
|
|
104
|
+
});
|
|
105
|
+
return result.rows;
|
|
106
|
+
},
|
|
107
|
+
createReviewForOrphan: async (task) => {
|
|
108
|
+
const { createReviewForCompletedTask } = await import("./tasks-review-3V4WOIRG.js");
|
|
109
|
+
const cwd = process.cwd();
|
|
110
|
+
await createReviewForCompletedTask(
|
|
111
|
+
task,
|
|
112
|
+
task.result ?? void 0,
|
|
113
|
+
cwd,
|
|
114
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
115
|
+
);
|
|
116
|
+
process.stderr.write(`[exed] Created missing review for: ${task.title} (${task.assigned_to})
|
|
117
|
+
`);
|
|
118
|
+
}
|
|
119
|
+
// findUrgentUnread and findUnstartedTasks removed (2026-05-25 consolidation).
|
|
120
|
+
// All employee nudging handled by task-enforcement → sendIntercom.
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
export {
|
|
124
|
+
createRealDeps,
|
|
125
|
+
pollPendingReviews
|
|
126
|
+
};
|
package/dist/runtime/index.js
CHANGED
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
SessionManager,
|
|
4
4
|
checkGitSafety,
|
|
5
5
|
targetsMainBranch
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-OSNUP45F.js";
|
|
7
7
|
import {
|
|
8
8
|
MultiAgentOrchestrator
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-EIVNMA3Q.js";
|
|
10
10
|
import {
|
|
11
11
|
createQuietRenderer,
|
|
12
12
|
createTerminalRenderer,
|
|
@@ -56,19 +56,19 @@ import {
|
|
|
56
56
|
composeHooks,
|
|
57
57
|
createDefaultHooks
|
|
58
58
|
} from "../chunk-O377P7GM.js";
|
|
59
|
-
import "../chunk-
|
|
60
|
-
import "../chunk-
|
|
61
|
-
import "../chunk-
|
|
59
|
+
import "../chunk-WVPLHGDG.js";
|
|
60
|
+
import "../chunk-K5ZO532Q.js";
|
|
61
|
+
import "../chunk-JVHHXRFY.js";
|
|
62
62
|
import "../chunk-4JERP7NT.js";
|
|
63
63
|
import "../chunk-4FVVJ7ME.js";
|
|
64
|
-
import "../chunk-
|
|
65
|
-
import "../chunk-
|
|
66
|
-
import "../chunk-
|
|
64
|
+
import "../chunk-Y3PMNUM5.js";
|
|
65
|
+
import "../chunk-KOO3J5PV.js";
|
|
66
|
+
import "../chunk-22TVSRQQ.js";
|
|
67
67
|
import "../chunk-SSTLTIF3.js";
|
|
68
|
-
import "../chunk-
|
|
68
|
+
import "../chunk-NLZHVIOP.js";
|
|
69
69
|
import "../chunk-QRTJNSKU.js";
|
|
70
70
|
import "../chunk-NGP6LSV2.js";
|
|
71
|
-
import "../chunk-
|
|
71
|
+
import "../chunk-5CCXU2AW.js";
|
|
72
72
|
import "../chunk-CVYC6DUW.js";
|
|
73
73
|
import "../chunk-OPU3NYOO.js";
|
|
74
74
|
import "../chunk-GJV3WDWM.js";
|
|
@@ -76,11 +76,11 @@ import {
|
|
|
76
76
|
StateBus,
|
|
77
77
|
orgBus
|
|
78
78
|
} from "../chunk-MP2AFCGL.js";
|
|
79
|
-
import "../chunk-
|
|
79
|
+
import "../chunk-N7I2A667.js";
|
|
80
80
|
import "../chunk-HYZV25LY.js";
|
|
81
|
-
import "../chunk-
|
|
81
|
+
import "../chunk-WUKHLCBE.js";
|
|
82
82
|
import "../chunk-2I23RPSI.js";
|
|
83
|
-
import "../chunk-
|
|
83
|
+
import "../chunk-2E43UXRH.js";
|
|
84
84
|
import "../chunk-PNQDP3OA.js";
|
|
85
85
|
import "../chunk-7HLWBYH7.js";
|
|
86
86
|
import "../chunk-FXU7JOXK.js";
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveAnthropicAuth
|
|
3
|
+
} from "./chunk-EJIF4FNT.js";
|
|
4
|
+
import "./chunk-MLKGABMK.js";
|
|
5
|
+
|
|
6
|
+
// src/lib/self-query-router.ts
|
|
7
|
+
var EXTRACT_TOOL = {
|
|
8
|
+
name: "extract_search_filters",
|
|
9
|
+
description: "Extract metadata filters from a memory search query to improve retrieval precision.",
|
|
10
|
+
input_schema: {
|
|
11
|
+
type: "object",
|
|
12
|
+
properties: {
|
|
13
|
+
semantic_query: {
|
|
14
|
+
type: "string",
|
|
15
|
+
description: "The core semantic meaning of the query, stripped of metadata references. This is used for embedding search."
|
|
16
|
+
},
|
|
17
|
+
project_filter: {
|
|
18
|
+
type: ["string", "null"],
|
|
19
|
+
description: "Project name if the query references a specific project (e.g., 'exe-os', 'exe-create'). Null if no project specified."
|
|
20
|
+
},
|
|
21
|
+
role_filter: {
|
|
22
|
+
type: ["string", "null"],
|
|
23
|
+
description: "Agent role if the query targets a specific role (e.g., 'CTO', 'CMO'). Null if no role specified."
|
|
24
|
+
},
|
|
25
|
+
time_filter: {
|
|
26
|
+
type: ["string", "null"],
|
|
27
|
+
description: "ISO 8601 timestamp lower bound if the query references a time period (e.g., 'last week', 'yesterday'). Null if no time reference."
|
|
28
|
+
},
|
|
29
|
+
is_broad_query: {
|
|
30
|
+
type: "boolean",
|
|
31
|
+
description: "True if the query is exploratory/broad (e.g., 'what has the CTO been working on', 'summarize recent activity'). False if targeted (e.g., 'how did we fix the auth bug')."
|
|
32
|
+
},
|
|
33
|
+
inferred_terms: {
|
|
34
|
+
type: "array",
|
|
35
|
+
items: { type: "string" },
|
|
36
|
+
description: "Entities or concepts NOT explicitly in the query but likely relevant for retrieval. Infer related terms from context clues. E.g., 'nephew of Ivory Lee Brown' \u2192 ['NFL', 'Oklahoma', 'football']. 'the auth bug we fixed' \u2192 ['JWT', 'token', 'login']. Return empty array if no useful inference. Max 5 terms."
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
required: ["semantic_query", "project_filter", "role_filter", "time_filter", "is_broad_query", "inferred_terms"]
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var CACHE_MAX_SIZE = Number(process.env.EXE_QUERY_CACHE_SIZE) || 200;
|
|
43
|
+
var CACHE_TTL_MS = Number(process.env.EXE_QUERY_CACHE_TTL_MS) || 5 * 60 * 1e3;
|
|
44
|
+
var queryCache = /* @__PURE__ */ new Map();
|
|
45
|
+
function normalizeCacheKey(query) {
|
|
46
|
+
return query.toLowerCase().trim().replace(/\s+/g, " ");
|
|
47
|
+
}
|
|
48
|
+
function evictCache() {
|
|
49
|
+
const now = Date.now();
|
|
50
|
+
for (const [key, entry] of queryCache) {
|
|
51
|
+
if (now - entry.timestamp > CACHE_TTL_MS) {
|
|
52
|
+
queryCache.delete(key);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
while (queryCache.size > CACHE_MAX_SIZE) {
|
|
56
|
+
const firstKey = queryCache.keys().next().value;
|
|
57
|
+
if (firstKey !== void 0) queryCache.delete(firstKey);
|
|
58
|
+
else break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function getQueryCacheStats() {
|
|
62
|
+
return {
|
|
63
|
+
size: queryCache.size,
|
|
64
|
+
maxSize: CACHE_MAX_SIZE,
|
|
65
|
+
ttlMs: CACHE_TTL_MS,
|
|
66
|
+
hitRate: _cacheTotal > 0 ? `${(_cacheHits / _cacheTotal * 100).toFixed(1)}%` : "n/a"
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function _resetQueryCache() {
|
|
70
|
+
queryCache.clear();
|
|
71
|
+
_cacheHits = 0;
|
|
72
|
+
_cacheTotal = 0;
|
|
73
|
+
}
|
|
74
|
+
var _cacheHits = 0;
|
|
75
|
+
var _cacheTotal = 0;
|
|
76
|
+
var _warnedNoAnthropicKey = false;
|
|
77
|
+
function cacheResult(cacheKey, result) {
|
|
78
|
+
evictCache();
|
|
79
|
+
queryCache.set(cacheKey, { result, timestamp: Date.now() });
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
function inferTimeFilter(queryLower) {
|
|
83
|
+
const now = Date.now();
|
|
84
|
+
const day = 24 * 60 * 60 * 1e3;
|
|
85
|
+
if (/\byesterday\b/.test(queryLower)) return new Date(now - day).toISOString();
|
|
86
|
+
if (/\blast\s+24\s*h(?:ours?)?\b/.test(queryLower)) return new Date(now - day).toISOString();
|
|
87
|
+
if (/\blast\s+7\s+days?\b|\blast\s+week\b|\bthis\s+week\b/.test(queryLower)) return new Date(now - 7 * day).toISOString();
|
|
88
|
+
if (/\blast\s+30\s+days?\b|\blast\s+month\b|\bthis\s+month\b/.test(queryLower)) return new Date(now - 30 * day).toISOString();
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
function inferProjectFilter(query) {
|
|
92
|
+
const explicit = query.match(/\b(?:project|repo)\s*[:=]\s*([a-z0-9._-]+)/i);
|
|
93
|
+
if (explicit?.[1]) return explicit[1];
|
|
94
|
+
const named = query.match(/\b(exe-[a-z0-9._-]+)\b/i);
|
|
95
|
+
if (named?.[1]) return named[1];
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
function inferTerms(queryLower) {
|
|
99
|
+
const terms = /* @__PURE__ */ new Set();
|
|
100
|
+
const mappings = [
|
|
101
|
+
[/\b(orchestration|delegate|delegation|dispatch|agent|tmux|session)\b/, ["dispatch", "tmux", "intercom", "session", "task lifecycle"]],
|
|
102
|
+
[/\b(memory|recall|search|retrieval|fts|vector|embedding|wiki)\b/, ["hybrid search", "FTS5", "graph", "vector", "wiki"]],
|
|
103
|
+
[/\b(crash|blocked|block|daemon|self[- ]heal|event loop|rss|oom)\b/, ["event loop", "daemon", "self-heal", "RSS", "watchdog"]],
|
|
104
|
+
[/\b(deploy|stack|docker|registry|image|ghcr|compose)\b/, ["stack-update", "docker", "registry", "GHCR", "compose"]],
|
|
105
|
+
[/\b(task|review|close|claim|lease|heartbeat)\b/, ["task status", "claim", "lease", "review", "heartbeat"]],
|
|
106
|
+
[/\b(security|secret|token|key|auth|permission)\b/, ["redaction", "token", "credential", "auth", "permission"]]
|
|
107
|
+
];
|
|
108
|
+
for (const [pattern, values] of mappings) {
|
|
109
|
+
if (pattern.test(queryLower)) values.forEach((v) => terms.add(v));
|
|
110
|
+
}
|
|
111
|
+
return [...terms].slice(0, 5);
|
|
112
|
+
}
|
|
113
|
+
function fallbackRouteQuery(query) {
|
|
114
|
+
const lower = query.toLowerCase();
|
|
115
|
+
const broad = /\b(all|everything|overview|summari[sz]e|recap|history|what do we know|recent activity|audit|map out|deep dive)\b/.test(lower);
|
|
116
|
+
return {
|
|
117
|
+
semanticQuery: query,
|
|
118
|
+
projectFilter: inferProjectFilter(query),
|
|
119
|
+
roleFilter: /\bcto\b/.test(lower) ? "CTO" : /\bcmo\b/.test(lower) ? "CMO" : /\bcoo\b|chief of staff\b/.test(lower) ? "COO" : null,
|
|
120
|
+
timeFilter: inferTimeFilter(lower),
|
|
121
|
+
isBroadQuery: broad,
|
|
122
|
+
inferredTerms: inferTerms(lower)
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
async function routeQuery(query, model = "claude-haiku-4-5-20251001", _agentId) {
|
|
126
|
+
if (query.length < 10) {
|
|
127
|
+
return {
|
|
128
|
+
semanticQuery: query,
|
|
129
|
+
projectFilter: null,
|
|
130
|
+
roleFilter: null,
|
|
131
|
+
timeFilter: null,
|
|
132
|
+
isBroadQuery: false,
|
|
133
|
+
inferredTerms: []
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
const cacheKey = normalizeCacheKey(query);
|
|
137
|
+
_cacheTotal++;
|
|
138
|
+
const cached = queryCache.get(cacheKey);
|
|
139
|
+
if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {
|
|
140
|
+
_cacheHits++;
|
|
141
|
+
queryCache.delete(cacheKey);
|
|
142
|
+
queryCache.set(cacheKey, cached);
|
|
143
|
+
return cached.result;
|
|
144
|
+
}
|
|
145
|
+
const auth = resolveAnthropicAuth();
|
|
146
|
+
if (!auth) {
|
|
147
|
+
if (!_warnedNoAnthropicKey && !process.env.VITEST) {
|
|
148
|
+
process.stderr.write("[self-query-router] No Anthropic credentials (ANTHROPIC_API_KEY / ANTHROPIC_AUTH_TOKEN); using rule-based query routing fallback\n");
|
|
149
|
+
_warnedNoAnthropicKey = true;
|
|
150
|
+
}
|
|
151
|
+
return cacheResult(cacheKey, fallbackRouteQuery(query));
|
|
152
|
+
}
|
|
153
|
+
try {
|
|
154
|
+
const Anthropic = (await import("@anthropic-ai/sdk")).default;
|
|
155
|
+
const client = new Anthropic(auth);
|
|
156
|
+
const now = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
157
|
+
const response = await client.messages.create({
|
|
158
|
+
model,
|
|
159
|
+
max_tokens: 256,
|
|
160
|
+
system: `You are a search query router and context enricher. Extract metadata filters from the user's memory search query. Also infer related entities/concepts that aren't explicitly stated but would help retrieval (like Apple CLaRa's Query Reasoner). Today is ${now}. Convert relative time references (yesterday, last week) to ISO timestamps.`,
|
|
161
|
+
messages: [{ role: "user", content: query }],
|
|
162
|
+
tools: [EXTRACT_TOOL],
|
|
163
|
+
tool_choice: { type: "tool", name: "extract_search_filters" }
|
|
164
|
+
});
|
|
165
|
+
const toolBlock = response.content.find((b) => b.type === "tool_use");
|
|
166
|
+
if (toolBlock && toolBlock.type === "tool_use") {
|
|
167
|
+
const input = toolBlock.input;
|
|
168
|
+
const rawTerms = input.inferred_terms;
|
|
169
|
+
const inferredTerms = Array.isArray(rawTerms) ? rawTerms.filter((t) => typeof t === "string" && t.length > 0).slice(0, 5) : [];
|
|
170
|
+
const result = {
|
|
171
|
+
semanticQuery: input.semantic_query || query,
|
|
172
|
+
projectFilter: input.project_filter || null,
|
|
173
|
+
roleFilter: input.role_filter || null,
|
|
174
|
+
timeFilter: input.time_filter || null,
|
|
175
|
+
isBroadQuery: Boolean(input.is_broad_query),
|
|
176
|
+
inferredTerms
|
|
177
|
+
};
|
|
178
|
+
return cacheResult(cacheKey, result);
|
|
179
|
+
}
|
|
180
|
+
} catch (err) {
|
|
181
|
+
process.stderr.write(
|
|
182
|
+
`[self-query-router] LLM extraction failed, using rule-based fallback: ${err instanceof Error ? err.message : String(err)}
|
|
183
|
+
`
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
return cacheResult(cacheKey, fallbackRouteQuery(query));
|
|
187
|
+
}
|
|
188
|
+
export {
|
|
189
|
+
_resetQueryCache,
|
|
190
|
+
getQueryCacheStats,
|
|
191
|
+
routeQuery
|
|
192
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ensureSessionEventsTable,
|
|
3
|
+
listRecentSessionEvents,
|
|
4
|
+
recordSessionEvent
|
|
5
|
+
} from "./chunk-YYAD2GXX.js";
|
|
6
|
+
import "./chunk-K5ZO532Q.js";
|
|
7
|
+
import "./chunk-JVHHXRFY.js";
|
|
8
|
+
import "./chunk-4JERP7NT.js";
|
|
9
|
+
import "./chunk-4FVVJ7ME.js";
|
|
10
|
+
import "./chunk-Y3PMNUM5.js";
|
|
11
|
+
import "./chunk-KOO3J5PV.js";
|
|
12
|
+
import "./chunk-22TVSRQQ.js";
|
|
13
|
+
import "./chunk-SSTLTIF3.js";
|
|
14
|
+
import "./chunk-NLZHVIOP.js";
|
|
15
|
+
import "./chunk-QRTJNSKU.js";
|
|
16
|
+
import "./chunk-NGP6LSV2.js";
|
|
17
|
+
import "./chunk-5CCXU2AW.js";
|
|
18
|
+
import "./chunk-CVYC6DUW.js";
|
|
19
|
+
import "./chunk-OPU3NYOO.js";
|
|
20
|
+
import "./chunk-GJV3WDWM.js";
|
|
21
|
+
import "./chunk-MP2AFCGL.js";
|
|
22
|
+
import "./chunk-N7I2A667.js";
|
|
23
|
+
import "./chunk-HYZV25LY.js";
|
|
24
|
+
import "./chunk-WUKHLCBE.js";
|
|
25
|
+
import "./chunk-2I23RPSI.js";
|
|
26
|
+
import "./chunk-2E43UXRH.js";
|
|
27
|
+
import "./chunk-PNQDP3OA.js";
|
|
28
|
+
import "./chunk-7HLWBYH7.js";
|
|
29
|
+
import "./chunk-FXU7JOXK.js";
|
|
30
|
+
import "./chunk-YTKVJJSU.js";
|
|
31
|
+
import "./chunk-R36FAN53.js";
|
|
32
|
+
import "./chunk-LYH5HE24.js";
|
|
33
|
+
import "./chunk-MLKGABMK.js";
|
|
34
|
+
export {
|
|
35
|
+
ensureSessionEventsTable,
|
|
36
|
+
listRecentSessionEvents,
|
|
37
|
+
recordSessionEvent
|
|
38
|
+
};
|