@askexenow/exe-os 0.9.263 → 0.9.265
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/stack-manifests/v0.9.json +1 -1
- package/dist/backfill-metadata-WM46YQZL.js +597 -0
- package/dist/bin/agentic-ontology-backfill.js +1 -1
- package/dist/bin/agentic-reflection-backfill.js +1 -1
- package/dist/bin/agentic-semantic-label.js +1 -1
- package/dist/bin/backfill-conversations.js +1 -1
- package/dist/bin/backfill-responses.js +1 -1
- package/dist/bin/backfill-vectors.js +2 -2
- package/dist/bin/bulk-sync-postgres.js +1 -1
- package/dist/bin/cleanup-stale-review-tasks.js +2 -2
- package/dist/bin/cli.js +5 -5
- package/dist/bin/exe-assign.js +1 -1
- package/dist/bin/exe-boot.js +3 -3
- package/dist/bin/exe-dispatch.js +2 -2
- package/dist/bin/exe-doctor.js +1 -1
- package/dist/bin/exe-export-behaviors.js +2 -2
- package/dist/bin/exe-forget.js +3 -3
- package/dist/bin/exe-gateway.js +5 -5
- package/dist/bin/exe-heartbeat.js +3 -3
- package/dist/bin/exe-kill.js +3 -3
- package/dist/bin/exe-launch-agent.js +3 -3
- package/dist/bin/exe-pending-messages.js +3 -3
- package/dist/bin/exe-pending-notifications.js +2 -2
- package/dist/bin/exe-pending-reviews.js +6 -4
- package/dist/bin/exe-review.js +3 -3
- package/dist/bin/exe-search.js +2 -2
- package/dist/bin/exe-session-cleanup.js +5 -5
- package/dist/bin/exe-start-codex.js +1 -1
- package/dist/bin/exe-start-opencode.js +1 -1
- package/dist/bin/exe-status.js +3 -3
- package/dist/bin/exe-support.js +1 -1
- package/dist/bin/exe-team.js +1 -1
- package/dist/bin/git-sweep.js +2 -2
- package/dist/bin/graph-backfill.js +1 -1
- package/dist/bin/graph-export.js +2 -2
- package/dist/bin/import-history.js +2 -2
- package/dist/bin/intercom-check.js +5 -4
- package/dist/bin/mcp-sessions.js +2 -2
- package/dist/bin/orchestration-metrics.js +1 -1
- package/dist/bin/scan-tasks.js +2 -2
- package/dist/bin/shard-migrate.js +1 -1
- package/dist/capacity-monitor-FZORNXTA.js +49 -0
- package/dist/catchup-brief-PRKHIRWW.js +151 -0
- package/dist/chunk-2GU3NYMB.js +813 -0
- package/dist/chunk-2VT7Z2E2.js +197 -0
- package/dist/chunk-3L6XLN4V.js +1090 -0
- package/dist/chunk-3T4PNG5O.js +447 -0
- package/dist/chunk-3W324KN7.js +13696 -0
- package/dist/{chunk-BJYXHSFN.js → chunk-3X555IGG.js} +1 -1
- package/dist/chunk-4IATAIAF.js +89 -0
- package/dist/chunk-5M4F2FVD.js +204 -0
- package/dist/chunk-5TANMPI4.js +377 -0
- package/dist/chunk-67E5WIMW.js +333 -0
- package/dist/chunk-6NRJIARA.js +346 -0
- package/dist/chunk-6O22GTSE.js +1148 -0
- package/dist/chunk-7O5CMDP6.js +1345 -0
- package/dist/chunk-7P2JKEO3.js +382 -0
- package/dist/chunk-A4UY44T7.js +486 -0
- package/dist/chunk-AZHPQGSI.js +159 -0
- package/dist/chunk-BQAC3GCO.js +127 -0
- package/dist/chunk-CIWJRYIC.js +244 -0
- package/dist/chunk-CZO2DGGF.js +214 -0
- package/dist/chunk-D55SXO3N.js +3951 -0
- package/dist/chunk-EPDSRI6O.js +284 -0
- package/dist/chunk-EU34R2A3.js +1073 -0
- package/dist/chunk-G4KEDLSM.js +488 -0
- package/dist/{chunk-235ZCOYB.js → chunk-IBGC6JFX.js} +2 -2
- package/dist/chunk-IODP4JNE.js +551 -0
- package/dist/chunk-IZ6LCET7.js +58 -0
- package/dist/chunk-LPG3U5UW.js +731 -0
- package/dist/chunk-NH6TPXZV.js +13696 -0
- package/dist/chunk-O5TZI7OZ.js +50 -0
- package/dist/chunk-Q3N4KHLM.js +330 -0
- package/dist/chunk-QHQTMWYH.js +54 -0
- package/dist/chunk-QNYOPM2L.js +1921 -0
- package/dist/chunk-SPOA7EOD.js +81 -0
- package/dist/chunk-TK23WXKB.js +128 -0
- package/dist/chunk-TOVXER6J.js +76 -0
- package/dist/chunk-UIPAZYP7.js +171 -0
- package/dist/chunk-WXW4GF6M.js +495 -0
- package/dist/{chunk-KQNVIDBP.js → chunk-XLYBSXWS.js} +4 -3
- package/dist/core-memory-QXMQ5I7S.js +110 -0
- package/dist/crm-webhook-CH5W633Y.js +10 -0
- package/dist/cto-delegation-gate-XY3NMGTE.js +206 -0
- package/dist/daemon-orchestration-LS62JMTI.js +135 -0
- package/dist/dreaming-ZBKE2GFX.js +32 -0
- package/dist/exe-export-JNSQRIWI.js +73 -0
- package/dist/exe-import-AVGWQZLU.js +76 -0
- package/dist/exe-key-WR6QEHYO.js +579 -0
- package/dist/exe-snapshot-U6K3J6BD.js +164 -0
- package/dist/fast-db-init-ZHRRYI7M.js +7 -0
- package/dist/gateway/index.js +6 -6
- package/dist/git-task-sweep-64KSWRUI.js +40 -0
- package/dist/hooks/bug-report-worker.js +4 -4
- package/dist/hooks/codex-stop-task-finalizer.js +4 -4
- package/dist/hooks/commit-complete.js +4 -4
- package/dist/hooks/error-recall.js +2 -2
- package/dist/hooks/ingest.js +2 -2
- package/dist/hooks/instructions-loaded.js +1 -1
- package/dist/hooks/manifest.json +18 -18
- package/dist/hooks/notification.js +1 -1
- package/dist/hooks/post-compact.js +2 -2
- package/dist/hooks/post-tool-combined.js +2 -2
- package/dist/hooks/pre-compact.js +3 -3
- package/dist/hooks/pre-tool-use.js +6 -6
- package/dist/hooks/prompt-submit.js +16 -11
- package/dist/hooks/session-end.js +5 -5
- package/dist/hooks/session-start.js +6 -6
- package/dist/hooks/stop.js +5 -5
- package/dist/hooks/subagent-stop.js +2 -2
- package/dist/hooks/summary-worker.js +5 -5
- package/dist/index.js +9 -9
- package/dist/lib/consolidation.js +2 -2
- package/dist/lib/exe-daemon.js +17 -17
- package/dist/lib/hybrid-search.js +2 -2
- package/dist/lib/messaging.js +2 -2
- package/dist/lib/schedules.js +2 -2
- package/dist/lib/store.js +1 -1
- package/dist/lib/tasks.js +3 -3
- package/dist/lib/tmux-routing.js +1 -1
- package/dist/mcp/register-tools.js +25 -25
- package/dist/mcp/server.js +26 -26
- package/dist/mcp/tools/create-task.js +4 -4
- package/dist/mcp/tools/list-tasks.js +4 -4
- package/dist/mcp/tools/send-message.js +3 -3
- package/dist/mcp/tools/update-task.js +4 -4
- package/dist/notifications-45QSHDFA.js +45 -0
- package/dist/orchestrator-7XBMFK7D.js +33 -0
- package/dist/pipeline-router-MQKRNCTR.js +13 -0
- package/dist/reranker-CJW3UYE2.js +19 -0
- package/dist/review-polling-RL75XLAY.js +124 -0
- package/dist/runtime/index.js +3 -3
- package/dist/session-events-ZULAN4XL.js +36 -0
- package/dist/session-scope-V2RSOTDU.js +86 -0
- package/dist/skill-refinement-BSX6Q6IN.js +157 -0
- package/dist/{support-outbox-SZVLHHZG.js → support-outbox-SO73Q5H2.js} +202 -7
- package/dist/task-enforcement-JRTAOYZT.js +333 -0
- package/dist/task-scope-GNCB2GAM.js +35 -0
- package/dist/tasks-crud-MZIOYF3R.js +77 -0
- package/dist/tasks-notify-7KNZ4ULO.js +38 -0
- package/dist/tasks-review-U5VEV4Y7.js +47 -0
- package/dist/telemetry-upload-BIB5TJA4.js +739 -0
- package/dist/tui/App.js +7 -7
- package/dist/tui-data-ZSB5DDEY.js +258 -0
- package/dist/worker-gate-TXLX33PX.js +21 -0
- package/dist/workflow-engine-3PIT3Y56.js +28 -0
- package/package.json +1 -1
- package/release-notes.json +27 -24
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// src/bin/fast-db-init.ts
|
|
2
|
+
async function fastDbInit() {
|
|
3
|
+
const { isInitialized, getClient, setExternalClient } = await import("./lib/database.js");
|
|
4
|
+
if (isInitialized()) {
|
|
5
|
+
return getClient();
|
|
6
|
+
}
|
|
7
|
+
const forceDirect = process.env.EXE_DB_DIRECT === "1" || process.env.EXE_DB_READONLY === "1" || process.env.EXE_SKIP_DAEMON === "1";
|
|
8
|
+
if (!forceDirect) {
|
|
9
|
+
try {
|
|
10
|
+
const { connectEmbedDaemon, sendDaemonRequest, isClientConnected, disconnectClient } = await import("./lib/exe-daemon-client.js");
|
|
11
|
+
const { deserializeResultSet } = await import("./daemon-protocol-XW2OLNBS.js");
|
|
12
|
+
await Promise.race([
|
|
13
|
+
connectEmbedDaemon(),
|
|
14
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error("Daemon socket timeout (2s)")), 2e3))
|
|
15
|
+
]);
|
|
16
|
+
if (isClientConnected()) {
|
|
17
|
+
const daemonClient = {
|
|
18
|
+
async execute(stmt) {
|
|
19
|
+
const sql = typeof stmt === "string" ? stmt : stmt.sql;
|
|
20
|
+
const args = typeof stmt === "string" ? [] : Array.isArray(stmt.args) ? stmt.args : [];
|
|
21
|
+
const resp = await sendDaemonRequest({ type: "db-execute", sql, args });
|
|
22
|
+
if (resp.error) throw new Error(String(resp.error));
|
|
23
|
+
if (resp.db) return deserializeResultSet(resp.db);
|
|
24
|
+
throw new Error("Unexpected daemon response");
|
|
25
|
+
},
|
|
26
|
+
async batch(stmts, mode) {
|
|
27
|
+
const statements = stmts.map((s) => {
|
|
28
|
+
const sql = typeof s === "string" ? s : s.sql;
|
|
29
|
+
const args = typeof s === "string" ? [] : Array.isArray(s.args) ? s.args : [];
|
|
30
|
+
return { sql, args };
|
|
31
|
+
});
|
|
32
|
+
const resp = await sendDaemonRequest({ type: "db-batch", statements, mode: mode ?? "deferred" });
|
|
33
|
+
if (resp.error) throw new Error(String(resp.error));
|
|
34
|
+
const batchResults = resp["db-batch"];
|
|
35
|
+
if (batchResults) return batchResults.map(deserializeResultSet);
|
|
36
|
+
throw new Error("Unexpected daemon batch response");
|
|
37
|
+
},
|
|
38
|
+
async transaction(_mode) {
|
|
39
|
+
throw new Error("Transactions not supported via daemon socket");
|
|
40
|
+
},
|
|
41
|
+
async executeMultiple(_sql) {
|
|
42
|
+
throw new Error("executeMultiple not supported via daemon socket");
|
|
43
|
+
},
|
|
44
|
+
async migrate(_stmts) {
|
|
45
|
+
throw new Error("migrate not supported via daemon socket");
|
|
46
|
+
},
|
|
47
|
+
sync() {
|
|
48
|
+
return Promise.resolve(void 0);
|
|
49
|
+
},
|
|
50
|
+
close() {
|
|
51
|
+
},
|
|
52
|
+
get closed() {
|
|
53
|
+
return false;
|
|
54
|
+
},
|
|
55
|
+
get protocol() {
|
|
56
|
+
return "file";
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
try {
|
|
60
|
+
await daemonClient.execute("SELECT 1");
|
|
61
|
+
} catch {
|
|
62
|
+
try {
|
|
63
|
+
disconnectClient();
|
|
64
|
+
} catch {
|
|
65
|
+
}
|
|
66
|
+
throw new Error("Daemon socket validation failed");
|
|
67
|
+
}
|
|
68
|
+
setExternalClient(daemonClient);
|
|
69
|
+
return daemonClient;
|
|
70
|
+
}
|
|
71
|
+
} catch {
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const { initStore } = await import("./lib/store.js");
|
|
75
|
+
await initStore({ lightweight: true });
|
|
76
|
+
return getClient();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
fastDbInit
|
|
81
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getCurrentSessionScope,
|
|
3
|
+
strictSessionScopeFilter
|
|
4
|
+
} from "./chunk-D55SXO3N.js";
|
|
5
|
+
import {
|
|
6
|
+
getProjectName
|
|
7
|
+
} from "./chunk-OPU3NYOO.js";
|
|
8
|
+
|
|
9
|
+
// src/lib/session-events.ts
|
|
10
|
+
import { randomUUID } from "crypto";
|
|
11
|
+
async function ensureSessionEventsTable(client) {
|
|
12
|
+
await client.execute(`
|
|
13
|
+
CREATE TABLE IF NOT EXISTS session_events (
|
|
14
|
+
id TEXT PRIMARY KEY,
|
|
15
|
+
agent_id TEXT NOT NULL,
|
|
16
|
+
agent_role TEXT NOT NULL,
|
|
17
|
+
session_id TEXT NOT NULL,
|
|
18
|
+
session_scope TEXT,
|
|
19
|
+
project_name TEXT NOT NULL,
|
|
20
|
+
event_index INTEGER NOT NULL,
|
|
21
|
+
event_type TEXT NOT NULL,
|
|
22
|
+
tool_name TEXT,
|
|
23
|
+
tool_use_id TEXT,
|
|
24
|
+
content TEXT NOT NULL,
|
|
25
|
+
payload_json TEXT,
|
|
26
|
+
has_error INTEGER NOT NULL DEFAULT 0,
|
|
27
|
+
created_at TEXT NOT NULL
|
|
28
|
+
)
|
|
29
|
+
`);
|
|
30
|
+
await client.execute(`
|
|
31
|
+
CREATE INDEX IF NOT EXISTS idx_session_events_agent_time
|
|
32
|
+
ON session_events(agent_id, created_at DESC)
|
|
33
|
+
`);
|
|
34
|
+
await client.execute(`
|
|
35
|
+
CREATE INDEX IF NOT EXISTS idx_session_events_session_index
|
|
36
|
+
ON session_events(session_id, event_index)
|
|
37
|
+
`);
|
|
38
|
+
await client.execute(`
|
|
39
|
+
CREATE INDEX IF NOT EXISTS idx_session_events_scope_agent_time
|
|
40
|
+
ON session_events(session_scope, agent_id, created_at DESC)
|
|
41
|
+
`);
|
|
42
|
+
}
|
|
43
|
+
async function recordSessionEvent(client, input) {
|
|
44
|
+
if (!input.content || input.content.trim().length === 0) return;
|
|
45
|
+
await ensureSessionEventsTable(client);
|
|
46
|
+
const maxResult = await client.execute({
|
|
47
|
+
sql: "SELECT COALESCE(MAX(event_index), 0) AS max_index FROM session_events WHERE session_id = ?",
|
|
48
|
+
args: [input.sessionId]
|
|
49
|
+
});
|
|
50
|
+
const currentMax = Number(maxResult.rows[0]?.max_index ?? 0);
|
|
51
|
+
const eventIndex = Number.isFinite(currentMax) ? currentMax + 1 : 1;
|
|
52
|
+
await client.execute({
|
|
53
|
+
sql: `INSERT INTO session_events (
|
|
54
|
+
id, agent_id, agent_role, session_id, session_scope, project_name,
|
|
55
|
+
event_index, event_type, tool_name, tool_use_id, content,
|
|
56
|
+
payload_json, has_error, created_at
|
|
57
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
58
|
+
args: [
|
|
59
|
+
randomUUID(),
|
|
60
|
+
input.agentId,
|
|
61
|
+
input.agentRole,
|
|
62
|
+
input.sessionId,
|
|
63
|
+
input.sessionScope ?? getCurrentSessionScope(),
|
|
64
|
+
input.projectName ?? getProjectName(input.cwd),
|
|
65
|
+
eventIndex,
|
|
66
|
+
input.eventType,
|
|
67
|
+
input.toolName ?? null,
|
|
68
|
+
input.toolUseId ?? null,
|
|
69
|
+
input.content,
|
|
70
|
+
input.payloadJson ?? null,
|
|
71
|
+
input.hasError ? 1 : 0,
|
|
72
|
+
input.timestamp ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async function listRecentSessionEvents(client, options) {
|
|
77
|
+
await ensureSessionEventsTable(client);
|
|
78
|
+
const conditions = ["agent_id = ?"];
|
|
79
|
+
const args = [options.agentId];
|
|
80
|
+
if (options.sessionId) {
|
|
81
|
+
conditions.push("session_id = ?");
|
|
82
|
+
args.push(options.sessionId);
|
|
83
|
+
}
|
|
84
|
+
if (options.eventType) {
|
|
85
|
+
conditions.push("event_type = ?");
|
|
86
|
+
args.push(options.eventType);
|
|
87
|
+
}
|
|
88
|
+
if (options.projectName && options.projectName !== "all") {
|
|
89
|
+
conditions.push("project_name = ?");
|
|
90
|
+
args.push(options.projectName);
|
|
91
|
+
}
|
|
92
|
+
const scope = strictSessionScopeFilter(options.sessionScope);
|
|
93
|
+
const where = `WHERE ${conditions.join(" AND ")}${scope.sql}`;
|
|
94
|
+
args.push(...scope.args);
|
|
95
|
+
args.push(Math.min(Math.max(options.limit ?? 20, 1), 100));
|
|
96
|
+
const result = await client.execute({
|
|
97
|
+
sql: `SELECT id, agent_id, agent_role, session_id, session_scope,
|
|
98
|
+
project_name, event_index, event_type, tool_name, tool_use_id,
|
|
99
|
+
content, payload_json, has_error, created_at
|
|
100
|
+
FROM session_events
|
|
101
|
+
${where}
|
|
102
|
+
ORDER BY created_at DESC, event_index DESC
|
|
103
|
+
LIMIT ?`,
|
|
104
|
+
args
|
|
105
|
+
});
|
|
106
|
+
return result.rows.map((row) => ({
|
|
107
|
+
id: String(row.id),
|
|
108
|
+
agentId: String(row.agent_id),
|
|
109
|
+
agentRole: String(row.agent_role),
|
|
110
|
+
sessionId: String(row.session_id),
|
|
111
|
+
sessionScope: row.session_scope == null ? null : String(row.session_scope),
|
|
112
|
+
projectName: String(row.project_name),
|
|
113
|
+
eventIndex: Number(row.event_index),
|
|
114
|
+
eventType: String(row.event_type),
|
|
115
|
+
toolName: row.tool_name == null ? null : String(row.tool_name),
|
|
116
|
+
toolUseId: row.tool_use_id == null ? null : String(row.tool_use_id),
|
|
117
|
+
content: String(row.content),
|
|
118
|
+
payloadJson: row.payload_json == null ? null : String(row.payload_json),
|
|
119
|
+
hasError: Number(row.has_error) === 1,
|
|
120
|
+
createdAt: String(row.created_at)
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export {
|
|
125
|
+
ensureSessionEventsTable,
|
|
126
|
+
recordSessionEvent,
|
|
127
|
+
listRecentSessionEvents
|
|
128
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fastDbInit
|
|
3
|
+
} from "./chunk-SPOA7EOD.js";
|
|
4
|
+
import {
|
|
5
|
+
sessionScopeFilter
|
|
6
|
+
} from "./chunk-D55SXO3N.js";
|
|
7
|
+
import {
|
|
8
|
+
formatStatusAll,
|
|
9
|
+
formatStatusDeep,
|
|
10
|
+
getEmployeeStatuses,
|
|
11
|
+
inTmux
|
|
12
|
+
} from "./chunk-CX6GL3ZJ.js";
|
|
13
|
+
import {
|
|
14
|
+
getClient,
|
|
15
|
+
isCoordinatorRole,
|
|
16
|
+
loadEmployees
|
|
17
|
+
} from "./chunk-QQZMP6QL.js";
|
|
18
|
+
import {
|
|
19
|
+
isMainModule
|
|
20
|
+
} from "./chunk-6Y4B3QF6.js";
|
|
21
|
+
|
|
22
|
+
// src/bin/exe-status.ts
|
|
23
|
+
async function status(targetEmployee) {
|
|
24
|
+
if (!inTmux()) {
|
|
25
|
+
return "Not in a tmux session. Start tmux first: tmux new-session -s work";
|
|
26
|
+
}
|
|
27
|
+
const employees = await loadEmployees();
|
|
28
|
+
const names = employees.filter((e) => !isCoordinatorRole(e.role)).map((e) => e.name);
|
|
29
|
+
const roles = new Map(employees.map((e) => [e.name, e.role ?? ""]));
|
|
30
|
+
await fastDbInit();
|
|
31
|
+
const client = getClient();
|
|
32
|
+
const taskMap = /* @__PURE__ */ new Map();
|
|
33
|
+
try {
|
|
34
|
+
const esScope = sessionScopeFilter();
|
|
35
|
+
const result = await client.execute({
|
|
36
|
+
sql: `SELECT assigned_to, title, priority FROM tasks
|
|
37
|
+
WHERE status = 'in_progress'${esScope.sql}
|
|
38
|
+
ORDER BY priority ASC, created_at ASC`,
|
|
39
|
+
args: [...esScope.args]
|
|
40
|
+
});
|
|
41
|
+
for (const row of result.rows) {
|
|
42
|
+
const assignee = String(row.assigned_to);
|
|
43
|
+
if (!taskMap.has(assignee)) {
|
|
44
|
+
taskMap.set(assignee, {
|
|
45
|
+
title: String(row.title),
|
|
46
|
+
priority: String(row.priority)
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} catch {
|
|
51
|
+
}
|
|
52
|
+
if (targetEmployee) {
|
|
53
|
+
if (!names.includes(targetEmployee)) {
|
|
54
|
+
return `Employee "${targetEmployee}" not found. Available: ${names.join(", ")}`;
|
|
55
|
+
}
|
|
56
|
+
const statuses2 = getEmployeeStatuses([targetEmployee]);
|
|
57
|
+
const s = statuses2[0];
|
|
58
|
+
return formatStatusDeep(s, taskMap.get(targetEmployee), roles.get(targetEmployee) ?? "");
|
|
59
|
+
}
|
|
60
|
+
const statuses = getEmployeeStatuses(names);
|
|
61
|
+
return formatStatusAll(statuses, taskMap, roles);
|
|
62
|
+
}
|
|
63
|
+
if (isMainModule(import.meta.url)) {
|
|
64
|
+
const target = process.argv[2];
|
|
65
|
+
status(target).then((output) => {
|
|
66
|
+
process.stdout.write(output + "\n");
|
|
67
|
+
}).catch((err) => {
|
|
68
|
+
process.stderr.write(`Error: ${err instanceof Error ? err.message : String(err)}
|
|
69
|
+
`);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export {
|
|
75
|
+
status
|
|
76
|
+
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import {
|
|
2
|
+
writeMemoryViaDaemon
|
|
3
|
+
} from "./chunk-Q3GLQDZI.js";
|
|
4
|
+
|
|
5
|
+
// src/lib/auto-checkpoint.ts
|
|
6
|
+
var FILE_RE = /(?:^|\s)([\w./-]+\.(?:ts|tsx|js|jsx|json|md|yml|yaml|sql|go|py|css|scss|html|sh))(?:\b|$)/g;
|
|
7
|
+
var DECISION_RE = /\b(decision:|decided:|we decided|founder directive|captured in .*architecture|source of truth)\b/i;
|
|
8
|
+
function asString(value, fallback = "") {
|
|
9
|
+
if (value == null) return fallback;
|
|
10
|
+
return String(value);
|
|
11
|
+
}
|
|
12
|
+
function compactLine(text, max = 220) {
|
|
13
|
+
return text.replace(/\s+/g, " ").trim().slice(0, max);
|
|
14
|
+
}
|
|
15
|
+
function topEntries(counts, limit) {
|
|
16
|
+
return [...counts.entries()].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).slice(0, limit).map(([name, count]) => `${name}(${count})`);
|
|
17
|
+
}
|
|
18
|
+
function buildAutoCheckpoint(input) {
|
|
19
|
+
const maxSamples = input.maxSamples ?? 8;
|
|
20
|
+
const projectCounts = /* @__PURE__ */ new Map();
|
|
21
|
+
const toolCounts = /* @__PURE__ */ new Map();
|
|
22
|
+
const files = /* @__PURE__ */ new Set();
|
|
23
|
+
const errors = [];
|
|
24
|
+
const samples = [];
|
|
25
|
+
const decisionTexts = [];
|
|
26
|
+
for (const row of input.memories) {
|
|
27
|
+
const tool = asString(row.tool_name, "unknown");
|
|
28
|
+
const project = asString(row.project_name, input.projectName || "unknown");
|
|
29
|
+
const raw = asString(row.raw_text);
|
|
30
|
+
const hasError = row.has_error === 1 || row.has_error === true;
|
|
31
|
+
toolCounts.set(tool, (toolCounts.get(tool) ?? 0) + 1);
|
|
32
|
+
projectCounts.set(project, (projectCounts.get(project) ?? 0) + 1);
|
|
33
|
+
if (hasError && errors.length < 5) errors.push(compactLine(raw, 180));
|
|
34
|
+
if (samples.length < maxSamples && raw.length > 30) {
|
|
35
|
+
samples.push(`[${tool}] ${compactLine(raw)}`);
|
|
36
|
+
}
|
|
37
|
+
if (DECISION_RE.test(raw) && decisionTexts.length < 5) {
|
|
38
|
+
decisionTexts.push(`AUTO DECISION CANDIDATE [${input.agentId}]: ${compactLine(raw, 500)}`);
|
|
39
|
+
}
|
|
40
|
+
for (const match of raw.matchAll(FILE_RE)) {
|
|
41
|
+
if (match[1]) files.add(match[1]);
|
|
42
|
+
if (files.size >= 20) break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const taskLines = (input.tasks ?? []).slice(0, 10).map((task) => {
|
|
46
|
+
const status = asString(task.status, "unknown");
|
|
47
|
+
const priority = asString(task.priority, "?").toUpperCase();
|
|
48
|
+
const title = asString(task.title, "untitled");
|
|
49
|
+
const taskFile = asString(task.task_file);
|
|
50
|
+
return `- [${status}/${priority}] ${title}${taskFile ? ` (${taskFile})` : ""}`;
|
|
51
|
+
});
|
|
52
|
+
const parts = [
|
|
53
|
+
`CONTEXT CHECKPOINT [auto:${input.reason}]`,
|
|
54
|
+
`Agent: ${input.agentId} (${input.agentRole})`,
|
|
55
|
+
`Session: ${input.sessionId}`,
|
|
56
|
+
`Project: ${input.projectName}`,
|
|
57
|
+
`Time: ${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
58
|
+
"",
|
|
59
|
+
"## Recent Activity",
|
|
60
|
+
`- Memories scanned: ${input.memories.length}`,
|
|
61
|
+
`- Projects: ${topEntries(projectCounts, 5).join(", ") || input.projectName}`,
|
|
62
|
+
`- Tools: ${topEntries(toolCounts, 8).join(", ") || "none"}`
|
|
63
|
+
];
|
|
64
|
+
if (taskLines.length > 0) {
|
|
65
|
+
parts.push("", "## Open / Active Tasks", ...taskLines);
|
|
66
|
+
}
|
|
67
|
+
if (files.size > 0) {
|
|
68
|
+
parts.push("", "## Files Mentioned", ...[...files].slice(0, 20).map((f) => `- ${f}`));
|
|
69
|
+
}
|
|
70
|
+
if (samples.length > 0) {
|
|
71
|
+
parts.push("", "## Important Recent Traces", ...samples.map((s) => `- ${s}`));
|
|
72
|
+
}
|
|
73
|
+
if (errors.length > 0) {
|
|
74
|
+
parts.push("", "## Errors / Risks", ...errors.map((e) => `- ${e}`));
|
|
75
|
+
}
|
|
76
|
+
if (decisionTexts.length > 0) {
|
|
77
|
+
parts.push("", "## Decision Candidates", ...decisionTexts.map((d) => `- ${d.replace(/^AUTO DECISION CANDIDATE \\[[^\\]]+\\]: /, "")}`));
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
checkpointText: parts.join("\n"),
|
|
81
|
+
decisionTexts
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// src/lib/checkpoint-orchestrator.ts
|
|
86
|
+
function toolNameForReason(reason) {
|
|
87
|
+
switch (reason) {
|
|
88
|
+
case "periodic":
|
|
89
|
+
return "auto-summary";
|
|
90
|
+
case "session-end":
|
|
91
|
+
return "SessionEnd";
|
|
92
|
+
case "pre-compact":
|
|
93
|
+
return "pre-compact-hook";
|
|
94
|
+
case "capacity-signal":
|
|
95
|
+
return "auto-checkpoint";
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function importanceForReason(reason, override) {
|
|
99
|
+
if (override !== void 0) return override;
|
|
100
|
+
switch (reason) {
|
|
101
|
+
case "periodic":
|
|
102
|
+
return 7;
|
|
103
|
+
case "session-end":
|
|
104
|
+
case "pre-compact":
|
|
105
|
+
case "capacity-signal":
|
|
106
|
+
return 8;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function buildContinuityCheckpoint(input) {
|
|
110
|
+
const { checkpointText, decisionTexts } = buildAutoCheckpoint({
|
|
111
|
+
agentId: input.agentId,
|
|
112
|
+
agentRole: input.agentRole,
|
|
113
|
+
sessionId: input.sessionId,
|
|
114
|
+
projectName: input.projectName,
|
|
115
|
+
reason: input.reason,
|
|
116
|
+
memories: input.memories ?? [],
|
|
117
|
+
tasks: input.tasks ?? [],
|
|
118
|
+
maxSamples: input.maxSamples
|
|
119
|
+
});
|
|
120
|
+
const extra = input.extraSections?.filter((section) => section.trim().length > 0) ?? [];
|
|
121
|
+
return {
|
|
122
|
+
checkpointText: extra.length > 0 ? `${checkpointText}
|
|
123
|
+
|
|
124
|
+
${extra.join("\n\n")}` : checkpointText,
|
|
125
|
+
decisionTexts
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
async function writeContinuityCheckpoint(input) {
|
|
129
|
+
const result = buildContinuityCheckpoint(input);
|
|
130
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
131
|
+
await writeMemoryViaDaemon({
|
|
132
|
+
raw_text: result.checkpointText,
|
|
133
|
+
agent_id: input.agentId,
|
|
134
|
+
agent_role: input.agentRole,
|
|
135
|
+
session_id: input.sessionId,
|
|
136
|
+
tool_name: toolNameForReason(input.reason),
|
|
137
|
+
project_name: input.projectName,
|
|
138
|
+
timestamp: now,
|
|
139
|
+
importance: importanceForReason(input.reason, input.importance),
|
|
140
|
+
task_id: input.taskId,
|
|
141
|
+
memory_type: "checkpoint"
|
|
142
|
+
});
|
|
143
|
+
const decisionLimit = input.reason === "periodic" ? 3 : 5;
|
|
144
|
+
for (const decisionText of result.decisionTexts.slice(0, decisionLimit)) {
|
|
145
|
+
await writeMemoryViaDaemon({
|
|
146
|
+
raw_text: decisionText,
|
|
147
|
+
agent_id: input.agentId,
|
|
148
|
+
agent_role: input.agentRole,
|
|
149
|
+
session_id: input.sessionId,
|
|
150
|
+
tool_name: "auto-decision",
|
|
151
|
+
project_name: input.projectName,
|
|
152
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
153
|
+
importance: 8,
|
|
154
|
+
memory_type: "decision"
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
async function checkpointActiveTask(input) {
|
|
160
|
+
const { writeCheckpoint } = await import("./lib/tasks.js");
|
|
161
|
+
await writeCheckpoint({
|
|
162
|
+
taskId: input.taskId,
|
|
163
|
+
step: input.step ?? "pre-compaction-checkpoint",
|
|
164
|
+
contextSummary: `Auto-checkpoint before context compaction. Task: ${input.taskTitle}. Session: ${input.sessionId}. Project: ${input.projectName}.`
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export {
|
|
169
|
+
writeContinuityCheckpoint,
|
|
170
|
+
checkpointActiveTask
|
|
171
|
+
};
|