@askexenow/exe-os 0.9.65 → 0.9.67
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 +54 -5
- package/dist/bin/age-ontology-load.js +61 -0
- package/dist/bin/agentic-ontology-backfill.js +4708 -0
- package/dist/bin/agentic-reflection-backfill.js +4144 -0
- package/dist/bin/{exe-link.js → agentic-semantic-label.js} +1532 -2173
- package/dist/bin/backfill-conversations.js +528 -20
- package/dist/bin/backfill-responses.js +528 -20
- package/dist/bin/backfill-vectors.js +255 -20
- package/dist/bin/bulk-sync-postgres.js +4876 -0
- package/dist/bin/cleanup-stale-review-tasks.js +529 -21
- package/dist/bin/cli.js +3471 -1491
- package/dist/bin/exe-agent-config.js +4 -0
- package/dist/bin/exe-agent.js +16 -0
- package/dist/bin/exe-assign.js +528 -20
- package/dist/bin/exe-boot.js +492 -54
- package/dist/bin/exe-call.js +16 -0
- package/dist/bin/exe-cloud.js +7415 -518
- package/dist/bin/exe-dispatch.js +540 -22
- package/dist/bin/exe-doctor.js +3404 -1225
- package/dist/bin/exe-export-behaviors.js +542 -24
- package/dist/bin/exe-forget.js +529 -21
- package/dist/bin/exe-gateway.js +595 -25
- package/dist/bin/exe-heartbeat.js +541 -24
- package/dist/bin/exe-kill.js +529 -21
- package/dist/bin/exe-launch-agent.js +2334 -1067
- package/dist/bin/exe-new-employee.js +324 -166
- package/dist/bin/exe-pending-messages.js +529 -21
- package/dist/bin/exe-pending-notifications.js +529 -21
- package/dist/bin/exe-pending-reviews.js +529 -21
- package/dist/bin/exe-rename.js +529 -21
- package/dist/bin/exe-review.js +529 -21
- package/dist/bin/exe-search.js +542 -24
- package/dist/bin/exe-session-cleanup.js +540 -22
- package/dist/bin/exe-settings.js +14 -0
- package/dist/bin/exe-start-codex.js +817 -144
- package/dist/bin/exe-start-opencode.js +776 -80
- package/dist/bin/exe-status.js +529 -21
- package/dist/bin/exe-team.js +529 -21
- package/dist/bin/git-sweep.js +540 -22
- package/dist/bin/graph-backfill.js +580 -21
- package/dist/bin/graph-export.js +529 -21
- package/dist/bin/graph-layer-benchmark.js +109 -0
- package/dist/bin/install.js +420 -289
- package/dist/bin/intercom-check.js +540 -22
- package/dist/bin/postgres-agentic-reflection-backfill.js +187 -0
- package/dist/bin/postgres-agentic-semantic-backfill.js +237 -0
- package/dist/bin/scan-tasks.js +540 -22
- package/dist/bin/setup.js +790 -206
- package/dist/bin/shard-migrate.js +528 -20
- package/dist/bin/update.js +4 -0
- package/dist/gateway/index.js +593 -23
- package/dist/hooks/bug-report-worker.js +651 -64
- package/dist/hooks/codex-stop-task-finalizer.js +540 -22
- package/dist/hooks/commit-complete.js +540 -22
- package/dist/hooks/error-recall.js +542 -24
- package/dist/hooks/exe-heartbeat-hook.js +4 -0
- package/dist/hooks/ingest-worker.js +4 -0
- package/dist/hooks/ingest.js +539 -22
- package/dist/hooks/instructions-loaded.js +529 -21
- package/dist/hooks/notification.js +529 -21
- package/dist/hooks/post-compact.js +529 -21
- package/dist/hooks/post-tool-combined.js +543 -25
- package/dist/hooks/pre-compact.js +772 -127
- package/dist/hooks/pre-tool-use.js +529 -21
- package/dist/hooks/prompt-submit.js +543 -25
- package/dist/hooks/session-end.js +673 -140
- package/dist/hooks/session-start.js +662 -26
- package/dist/hooks/stop.js +540 -23
- package/dist/hooks/subagent-stop.js +529 -21
- package/dist/hooks/summary-worker.js +571 -126
- package/dist/index.js +593 -23
- package/dist/lib/agent-config.js +4 -0
- package/dist/lib/cloud-sync.js +408 -47
- package/dist/lib/config.js +25 -1
- package/dist/lib/consolidation.js +5 -1
- package/dist/lib/database.js +128 -0
- package/dist/lib/db-daemon-client.js +4 -0
- package/dist/lib/db.js +128 -0
- package/dist/lib/device-registry.js +128 -0
- package/dist/lib/embedder.js +25 -1
- package/dist/lib/employee-templates.js +16 -0
- package/dist/lib/employees.js +4 -0
- package/dist/lib/exe-daemon-client.js +4 -0
- package/dist/lib/exe-daemon.js +3158 -930
- package/dist/lib/hybrid-search.js +542 -24
- package/dist/lib/identity.js +7 -0
- package/dist/lib/keychain.js +178 -22
- package/dist/lib/license.js +4 -0
- package/dist/lib/messaging.js +7 -0
- package/dist/lib/reminders.js +7 -0
- package/dist/lib/schedules.js +255 -20
- package/dist/lib/skill-learning.js +28 -1
- package/dist/lib/status-brief.js +39 -0
- package/dist/lib/store.js +528 -20
- package/dist/lib/task-router.js +4 -0
- package/dist/lib/tasks.js +28 -1
- package/dist/lib/tmux-routing.js +28 -1
- package/dist/lib/token-spend.js +7 -0
- package/dist/mcp/server.js +2739 -813
- package/dist/mcp/tools/complete-reminder.js +7 -0
- package/dist/mcp/tools/create-reminder.js +7 -0
- package/dist/mcp/tools/create-task.js +28 -1
- package/dist/mcp/tools/deactivate-behavior.js +7 -0
- package/dist/mcp/tools/list-reminders.js +7 -0
- package/dist/mcp/tools/list-tasks.js +7 -0
- package/dist/mcp/tools/send-message.js +7 -0
- package/dist/mcp/tools/update-task.js +28 -1
- package/dist/runtime/index.js +540 -22
- package/dist/tui/App.js +618 -29
- package/package.json +9 -5
- package/src/commands/exe/cloud.md +11 -8
- package/stack.release.json +3 -3
- package/src/commands/exe/link.md +0 -17
|
@@ -149,6 +149,11 @@ function normalizeAutoUpdate(raw) {
|
|
|
149
149
|
const userAU = raw.autoUpdate ?? {};
|
|
150
150
|
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
151
151
|
}
|
|
152
|
+
function normalizeOrchestration(raw) {
|
|
153
|
+
const defaultOrg = DEFAULT_CONFIG.orchestration;
|
|
154
|
+
const userOrg = raw.orchestration ?? {};
|
|
155
|
+
raw.orchestration = { ...defaultOrg, ...userOrg };
|
|
156
|
+
}
|
|
152
157
|
async function loadConfig() {
|
|
153
158
|
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
154
159
|
await ensurePrivateDir(dir);
|
|
@@ -173,10 +178,15 @@ async function loadConfig() {
|
|
|
173
178
|
normalizeScalingRoadmap(migratedCfg);
|
|
174
179
|
normalizeSessionLifecycle(migratedCfg);
|
|
175
180
|
normalizeAutoUpdate(migratedCfg);
|
|
181
|
+
normalizeOrchestration(migratedCfg);
|
|
176
182
|
const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
|
|
177
183
|
if (config.dbPath.startsWith("~")) {
|
|
178
184
|
config.dbPath = config.dbPath.replace(/^~/, os.homedir());
|
|
179
185
|
}
|
|
186
|
+
const envDbPath = path.join(dir, "memories.db");
|
|
187
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync2(config.dbPath) && existsSync2(envDbPath)) {
|
|
188
|
+
config.dbPath = envDbPath;
|
|
189
|
+
}
|
|
180
190
|
return config;
|
|
181
191
|
} catch {
|
|
182
192
|
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
@@ -196,7 +206,16 @@ function loadConfigSync() {
|
|
|
196
206
|
normalizeScalingRoadmap(migratedCfg);
|
|
197
207
|
normalizeSessionLifecycle(migratedCfg);
|
|
198
208
|
normalizeAutoUpdate(migratedCfg);
|
|
199
|
-
|
|
209
|
+
normalizeOrchestration(migratedCfg);
|
|
210
|
+
const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
|
|
211
|
+
if (config.dbPath.startsWith("~")) {
|
|
212
|
+
config.dbPath = config.dbPath.replace(/^~/, os.homedir());
|
|
213
|
+
}
|
|
214
|
+
const envDbPath = path.join(dir, "memories.db");
|
|
215
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync2(config.dbPath) && existsSync2(envDbPath)) {
|
|
216
|
+
config.dbPath = envDbPath;
|
|
217
|
+
}
|
|
218
|
+
return config;
|
|
200
219
|
} catch {
|
|
201
220
|
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
202
221
|
}
|
|
@@ -217,6 +236,7 @@ async function loadConfigFrom(configPath) {
|
|
|
217
236
|
normalizeScalingRoadmap(migratedCfg);
|
|
218
237
|
normalizeSessionLifecycle(migratedCfg);
|
|
219
238
|
normalizeAutoUpdate(migratedCfg);
|
|
239
|
+
normalizeOrchestration(migratedCfg);
|
|
220
240
|
return { ...DEFAULT_CONFIG, ...migratedCfg };
|
|
221
241
|
} catch {
|
|
222
242
|
return { ...DEFAULT_CONFIG };
|
|
@@ -288,6 +308,10 @@ var init_config = __esm({
|
|
|
288
308
|
checkOnBoot: true,
|
|
289
309
|
autoInstall: false,
|
|
290
310
|
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
311
|
+
},
|
|
312
|
+
orchestration: {
|
|
313
|
+
phase: "phase_1_coo",
|
|
314
|
+
phaseSetBy: "default"
|
|
291
315
|
}
|
|
292
316
|
};
|
|
293
317
|
CONFIG_MIGRATIONS = [
|
|
@@ -2312,6 +2336,9 @@ function getClient() {
|
|
|
2312
2336
|
if (_daemonClient && _daemonClient._isDaemonActive()) {
|
|
2313
2337
|
return _daemonClient;
|
|
2314
2338
|
}
|
|
2339
|
+
if (!_resilientClient) {
|
|
2340
|
+
return _adapterClient;
|
|
2341
|
+
}
|
|
2315
2342
|
return _resilientClient;
|
|
2316
2343
|
}
|
|
2317
2344
|
async function initDaemonClient() {
|
|
@@ -3344,6 +3371,127 @@ async function ensureSchema() {
|
|
|
3344
3371
|
VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
|
|
3345
3372
|
END;
|
|
3346
3373
|
`);
|
|
3374
|
+
await client.executeMultiple(`
|
|
3375
|
+
CREATE TABLE IF NOT EXISTS agent_sessions (
|
|
3376
|
+
id TEXT PRIMARY KEY,
|
|
3377
|
+
agent_id TEXT NOT NULL,
|
|
3378
|
+
project_name TEXT,
|
|
3379
|
+
started_at TEXT NOT NULL,
|
|
3380
|
+
last_event_at TEXT NOT NULL,
|
|
3381
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
3382
|
+
properties TEXT DEFAULT '{}'
|
|
3383
|
+
);
|
|
3384
|
+
|
|
3385
|
+
CREATE INDEX IF NOT EXISTS idx_agent_sessions_agent_time
|
|
3386
|
+
ON agent_sessions(agent_id, started_at);
|
|
3387
|
+
|
|
3388
|
+
CREATE TABLE IF NOT EXISTS agent_goals (
|
|
3389
|
+
id TEXT PRIMARY KEY,
|
|
3390
|
+
statement TEXT NOT NULL,
|
|
3391
|
+
owner_agent_id TEXT,
|
|
3392
|
+
project_name TEXT,
|
|
3393
|
+
status TEXT NOT NULL DEFAULT 'open',
|
|
3394
|
+
priority INTEGER NOT NULL DEFAULT 5,
|
|
3395
|
+
success_criteria TEXT,
|
|
3396
|
+
parent_goal_id TEXT,
|
|
3397
|
+
due_at TEXT,
|
|
3398
|
+
achieved_at TEXT,
|
|
3399
|
+
supersedes_id TEXT,
|
|
3400
|
+
created_at TEXT NOT NULL,
|
|
3401
|
+
updated_at TEXT NOT NULL,
|
|
3402
|
+
source_memory_id TEXT
|
|
3403
|
+
);
|
|
3404
|
+
|
|
3405
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goals_project_status
|
|
3406
|
+
ON agent_goals(project_name, status, priority);
|
|
3407
|
+
|
|
3408
|
+
CREATE TABLE IF NOT EXISTS agent_events (
|
|
3409
|
+
id TEXT PRIMARY KEY,
|
|
3410
|
+
event_type TEXT NOT NULL,
|
|
3411
|
+
occurred_at TEXT NOT NULL,
|
|
3412
|
+
sequence_index INTEGER NOT NULL,
|
|
3413
|
+
actor_agent_id TEXT,
|
|
3414
|
+
agent_role TEXT,
|
|
3415
|
+
project_name TEXT,
|
|
3416
|
+
session_id TEXT,
|
|
3417
|
+
task_id TEXT,
|
|
3418
|
+
goal_id TEXT,
|
|
3419
|
+
parent_event_id TEXT,
|
|
3420
|
+
intention TEXT,
|
|
3421
|
+
outcome TEXT,
|
|
3422
|
+
evidence_memory_id TEXT,
|
|
3423
|
+
impact TEXT,
|
|
3424
|
+
payload TEXT DEFAULT '{}',
|
|
3425
|
+
created_at TEXT NOT NULL
|
|
3426
|
+
);
|
|
3427
|
+
|
|
3428
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_time
|
|
3429
|
+
ON agent_events(occurred_at, sequence_index);
|
|
3430
|
+
|
|
3431
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_session_seq
|
|
3432
|
+
ON agent_events(session_id, sequence_index);
|
|
3433
|
+
|
|
3434
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_goal_time
|
|
3435
|
+
ON agent_events(goal_id, occurred_at);
|
|
3436
|
+
|
|
3437
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_memory
|
|
3438
|
+
ON agent_events(evidence_memory_id);
|
|
3439
|
+
|
|
3440
|
+
CREATE TABLE IF NOT EXISTS agent_goal_links (
|
|
3441
|
+
id TEXT PRIMARY KEY,
|
|
3442
|
+
goal_id TEXT NOT NULL,
|
|
3443
|
+
link_type TEXT NOT NULL,
|
|
3444
|
+
target_id TEXT NOT NULL,
|
|
3445
|
+
target_type TEXT NOT NULL,
|
|
3446
|
+
created_at TEXT NOT NULL
|
|
3447
|
+
);
|
|
3448
|
+
|
|
3449
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goal_links_goal
|
|
3450
|
+
ON agent_goal_links(goal_id, target_type);
|
|
3451
|
+
|
|
3452
|
+
CREATE TABLE IF NOT EXISTS agent_semantic_labels (
|
|
3453
|
+
id TEXT PRIMARY KEY,
|
|
3454
|
+
source_memory_id TEXT NOT NULL,
|
|
3455
|
+
event_id TEXT,
|
|
3456
|
+
labeler TEXT NOT NULL,
|
|
3457
|
+
schema_version INTEGER NOT NULL DEFAULT 1,
|
|
3458
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
3459
|
+
labels TEXT NOT NULL,
|
|
3460
|
+
created_at TEXT NOT NULL,
|
|
3461
|
+
updated_at TEXT NOT NULL
|
|
3462
|
+
);
|
|
3463
|
+
|
|
3464
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_memory
|
|
3465
|
+
ON agent_semantic_labels(source_memory_id, labeler);
|
|
3466
|
+
|
|
3467
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_event
|
|
3468
|
+
ON agent_semantic_labels(event_id);
|
|
3469
|
+
|
|
3470
|
+
CREATE TABLE IF NOT EXISTS agent_reflection_checkpoints (
|
|
3471
|
+
id TEXT PRIMARY KEY,
|
|
3472
|
+
project_name TEXT,
|
|
3473
|
+
session_id TEXT,
|
|
3474
|
+
window_start_at TEXT NOT NULL,
|
|
3475
|
+
window_end_at TEXT NOT NULL,
|
|
3476
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
3477
|
+
goal_count INTEGER NOT NULL DEFAULT 0,
|
|
3478
|
+
success_count INTEGER NOT NULL DEFAULT 0,
|
|
3479
|
+
failure_count INTEGER NOT NULL DEFAULT 0,
|
|
3480
|
+
risk_count INTEGER NOT NULL DEFAULT 0,
|
|
3481
|
+
summary TEXT NOT NULL,
|
|
3482
|
+
learnings TEXT NOT NULL DEFAULT '[]',
|
|
3483
|
+
next_actions TEXT NOT NULL DEFAULT '[]',
|
|
3484
|
+
evidence_event_ids TEXT NOT NULL DEFAULT '[]',
|
|
3485
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
3486
|
+
created_at TEXT NOT NULL
|
|
3487
|
+
);
|
|
3488
|
+
|
|
3489
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_project_time
|
|
3490
|
+
ON agent_reflection_checkpoints(project_name, window_end_at);
|
|
3491
|
+
|
|
3492
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_session_time
|
|
3493
|
+
ON agent_reflection_checkpoints(session_id, window_end_at);
|
|
3494
|
+
`);
|
|
3347
3495
|
try {
|
|
3348
3496
|
await client.execute({
|
|
3349
3497
|
sql: `ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3`,
|
|
@@ -6725,39 +6873,88 @@ var init_task_scope = __esm({
|
|
|
6725
6873
|
|
|
6726
6874
|
// src/lib/keychain.ts
|
|
6727
6875
|
import { readFile as readFile4, writeFile as writeFile5, unlink, mkdir as mkdir4, chmod as chmod2 } from "fs/promises";
|
|
6728
|
-
import { existsSync as
|
|
6876
|
+
import { existsSync as existsSync17, statSync as statSync3 } from "fs";
|
|
6729
6877
|
import { execSync as execSync8 } from "child_process";
|
|
6730
|
-
import
|
|
6878
|
+
import path21 from "path";
|
|
6731
6879
|
import os12 from "os";
|
|
6732
6880
|
function getKeyDir() {
|
|
6733
|
-
return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ??
|
|
6881
|
+
return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path21.join(os12.homedir(), ".exe-os");
|
|
6734
6882
|
}
|
|
6735
6883
|
function getKeyPath() {
|
|
6736
|
-
return
|
|
6884
|
+
return path21.join(getKeyDir(), "master.key");
|
|
6885
|
+
}
|
|
6886
|
+
function nativeKeychainAllowed() {
|
|
6887
|
+
return process.env.EXE_OS_DISABLE_NATIVE_KEYCHAIN !== "1";
|
|
6737
6888
|
}
|
|
6738
|
-
function
|
|
6889
|
+
function linuxSecretAvailable() {
|
|
6890
|
+
if (!nativeKeychainAllowed()) return false;
|
|
6891
|
+
if (process.platform !== "linux") return false;
|
|
6892
|
+
if (linuxSecretAvailability !== null) return linuxSecretAvailability;
|
|
6893
|
+
try {
|
|
6894
|
+
execSync8("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
|
|
6895
|
+
} catch {
|
|
6896
|
+
linuxSecretAvailability = false;
|
|
6897
|
+
return false;
|
|
6898
|
+
}
|
|
6899
|
+
try {
|
|
6900
|
+
execSync8("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
|
|
6901
|
+
linuxSecretAvailability = true;
|
|
6902
|
+
} catch {
|
|
6903
|
+
linuxSecretAvailability = false;
|
|
6904
|
+
}
|
|
6905
|
+
return linuxSecretAvailability;
|
|
6906
|
+
}
|
|
6907
|
+
function isRootOnlyTrustedServerKeyFile(keyPath) {
|
|
6908
|
+
if (process.platform !== "linux") return false;
|
|
6909
|
+
try {
|
|
6910
|
+
const uid = typeof os12.userInfo().uid === "number" ? os12.userInfo().uid : -1;
|
|
6911
|
+
const st = statSync3(keyPath);
|
|
6912
|
+
if (!st.isFile() || (st.mode & 63) !== 0) return false;
|
|
6913
|
+
if (uid === 0) return true;
|
|
6914
|
+
const exeOsDir = process.env.EXE_OS_DIR;
|
|
6915
|
+
return Boolean(exeOsDir && path21.resolve(keyPath).startsWith(path21.resolve(exeOsDir) + path21.sep));
|
|
6916
|
+
} catch {
|
|
6917
|
+
return false;
|
|
6918
|
+
}
|
|
6919
|
+
}
|
|
6920
|
+
function macKeychainGet(service = SERVICE) {
|
|
6921
|
+
if (!nativeKeychainAllowed()) return null;
|
|
6739
6922
|
if (process.platform !== "darwin") return null;
|
|
6740
6923
|
try {
|
|
6741
6924
|
return execSync8(
|
|
6742
|
-
`security find-generic-password -s "${
|
|
6925
|
+
`security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
|
|
6743
6926
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
6744
6927
|
).trim();
|
|
6745
6928
|
} catch {
|
|
6746
6929
|
return null;
|
|
6747
6930
|
}
|
|
6748
6931
|
}
|
|
6749
|
-
function macKeychainSet(value) {
|
|
6932
|
+
function macKeychainSet(value, service = SERVICE) {
|
|
6933
|
+
if (!nativeKeychainAllowed()) return false;
|
|
6750
6934
|
if (process.platform !== "darwin") return false;
|
|
6751
6935
|
try {
|
|
6752
6936
|
try {
|
|
6753
6937
|
execSync8(
|
|
6754
|
-
`security delete-generic-password -s "${
|
|
6938
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
6755
6939
|
{ timeout: 5e3 }
|
|
6756
6940
|
);
|
|
6757
6941
|
} catch {
|
|
6758
6942
|
}
|
|
6759
6943
|
execSync8(
|
|
6760
|
-
`security add-generic-password -s "${
|
|
6944
|
+
`security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
|
|
6945
|
+
{ timeout: 5e3 }
|
|
6946
|
+
);
|
|
6947
|
+
return true;
|
|
6948
|
+
} catch {
|
|
6949
|
+
return false;
|
|
6950
|
+
}
|
|
6951
|
+
}
|
|
6952
|
+
function macKeychainDelete(service = SERVICE) {
|
|
6953
|
+
if (!nativeKeychainAllowed()) return false;
|
|
6954
|
+
if (process.platform !== "darwin") return false;
|
|
6955
|
+
try {
|
|
6956
|
+
execSync8(
|
|
6957
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
6761
6958
|
{ timeout: 5e3 }
|
|
6762
6959
|
);
|
|
6763
6960
|
return true;
|
|
@@ -6765,22 +6962,35 @@ function macKeychainSet(value) {
|
|
|
6765
6962
|
return false;
|
|
6766
6963
|
}
|
|
6767
6964
|
}
|
|
6768
|
-
function linuxSecretGet() {
|
|
6769
|
-
if (
|
|
6965
|
+
function linuxSecretGet(service = SERVICE) {
|
|
6966
|
+
if (!linuxSecretAvailable()) return null;
|
|
6770
6967
|
try {
|
|
6771
6968
|
return execSync8(
|
|
6772
|
-
`secret-tool lookup service "${
|
|
6969
|
+
`secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
6773
6970
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
6774
6971
|
).trim();
|
|
6775
6972
|
} catch {
|
|
6776
6973
|
return null;
|
|
6777
6974
|
}
|
|
6778
6975
|
}
|
|
6779
|
-
function linuxSecretSet(value) {
|
|
6976
|
+
function linuxSecretSet(value, service = SERVICE) {
|
|
6977
|
+
if (!linuxSecretAvailable()) return false;
|
|
6978
|
+
try {
|
|
6979
|
+
execSync8(
|
|
6980
|
+
`echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
6981
|
+
{ timeout: 5e3 }
|
|
6982
|
+
);
|
|
6983
|
+
return true;
|
|
6984
|
+
} catch {
|
|
6985
|
+
return false;
|
|
6986
|
+
}
|
|
6987
|
+
}
|
|
6988
|
+
function linuxSecretDelete(service = SERVICE) {
|
|
6989
|
+
if (!nativeKeychainAllowed()) return false;
|
|
6780
6990
|
if (process.platform !== "linux") return false;
|
|
6781
6991
|
try {
|
|
6782
6992
|
execSync8(
|
|
6783
|
-
`
|
|
6993
|
+
`secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
6784
6994
|
{ timeout: 5e3 }
|
|
6785
6995
|
);
|
|
6786
6996
|
return true;
|
|
@@ -6789,6 +6999,7 @@ function linuxSecretSet(value) {
|
|
|
6789
6999
|
}
|
|
6790
7000
|
}
|
|
6791
7001
|
async function tryKeytar() {
|
|
7002
|
+
if (!nativeKeychainAllowed()) return null;
|
|
6792
7003
|
try {
|
|
6793
7004
|
return await import("keytar");
|
|
6794
7005
|
} catch {
|
|
@@ -6862,7 +7073,19 @@ async function writeMachineBoundFileFallback(b64) {
|
|
|
6862
7073
|
return "plaintext";
|
|
6863
7074
|
}
|
|
6864
7075
|
async function getMasterKey() {
|
|
6865
|
-
|
|
7076
|
+
let nativeValue = macKeychainGet() ?? linuxSecretGet();
|
|
7077
|
+
if (!nativeValue) {
|
|
7078
|
+
const legacyValue = macKeychainGet(LEGACY_SERVICE) ?? linuxSecretGet(LEGACY_SERVICE);
|
|
7079
|
+
if (legacyValue) {
|
|
7080
|
+
const migrated = macKeychainSet(legacyValue) || linuxSecretSet(legacyValue);
|
|
7081
|
+
if (migrated) {
|
|
7082
|
+
macKeychainDelete(LEGACY_SERVICE);
|
|
7083
|
+
linuxSecretDelete(LEGACY_SERVICE);
|
|
7084
|
+
process.stderr.write("[keychain] Migrated keychain service from exe-mem to exe-os.\n");
|
|
7085
|
+
}
|
|
7086
|
+
nativeValue = legacyValue;
|
|
7087
|
+
}
|
|
7088
|
+
}
|
|
6866
7089
|
if (nativeValue) {
|
|
6867
7090
|
return Buffer.from(nativeValue, "base64");
|
|
6868
7091
|
}
|
|
@@ -6870,18 +7093,23 @@ async function getMasterKey() {
|
|
|
6870
7093
|
if (keytar) {
|
|
6871
7094
|
try {
|
|
6872
7095
|
const keytarValue = await keytar.getPassword(SERVICE, ACCOUNT);
|
|
6873
|
-
|
|
6874
|
-
|
|
7096
|
+
const legacyKeytarValue = keytarValue ?? await keytar.getPassword(LEGACY_SERVICE, ACCOUNT);
|
|
7097
|
+
if (legacyKeytarValue) {
|
|
7098
|
+
const migrated = macKeychainSet(legacyKeytarValue) || linuxSecretSet(legacyKeytarValue);
|
|
6875
7099
|
if (migrated) {
|
|
6876
7100
|
process.stderr.write("[keychain] Migrated key from keytar to native keychain.\n");
|
|
7101
|
+
try {
|
|
7102
|
+
await keytar.deletePassword(LEGACY_SERVICE, ACCOUNT);
|
|
7103
|
+
} catch {
|
|
7104
|
+
}
|
|
6877
7105
|
}
|
|
6878
|
-
return Buffer.from(
|
|
7106
|
+
return Buffer.from(legacyKeytarValue, "base64");
|
|
6879
7107
|
}
|
|
6880
7108
|
} catch {
|
|
6881
7109
|
}
|
|
6882
7110
|
}
|
|
6883
7111
|
const keyPath = getKeyPath();
|
|
6884
|
-
if (!
|
|
7112
|
+
if (!existsSync17(keyPath)) {
|
|
6885
7113
|
process.stderr.write(
|
|
6886
7114
|
`[keychain] Key not found at ${keyPath} (HOME=${os12.homedir()}, EXE_OS_DIR=${process.env.EXE_OS_DIR ?? "unset"})
|
|
6887
7115
|
`
|
|
@@ -6900,7 +7128,7 @@ async function getMasterKey() {
|
|
|
6900
7128
|
const decrypted = decryptWithMachineKey(content, machineKey);
|
|
6901
7129
|
if (!decrypted) {
|
|
6902
7130
|
process.stderr.write(
|
|
6903
|
-
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase: exe-os
|
|
7131
|
+
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase during setup: exe-os setup\n"
|
|
6904
7132
|
);
|
|
6905
7133
|
return null;
|
|
6906
7134
|
}
|
|
@@ -6909,6 +7137,9 @@ async function getMasterKey() {
|
|
|
6909
7137
|
b64Value = content;
|
|
6910
7138
|
}
|
|
6911
7139
|
const key = Buffer.from(b64Value, "base64");
|
|
7140
|
+
if (!content.startsWith(ENCRYPTED_PREFIX) && isRootOnlyTrustedServerKeyFile(keyPath)) {
|
|
7141
|
+
return key;
|
|
7142
|
+
}
|
|
6912
7143
|
const migrated = macKeychainSet(b64Value) || linuxSecretSet(b64Value);
|
|
6913
7144
|
if (migrated) {
|
|
6914
7145
|
process.stderr.write("[keychain] Migrated key from file to native keychain.\n");
|
|
@@ -6936,12 +7167,14 @@ async function getMasterKey() {
|
|
|
6936
7167
|
return null;
|
|
6937
7168
|
}
|
|
6938
7169
|
}
|
|
6939
|
-
var SERVICE, ACCOUNT, ENCRYPTED_PREFIX;
|
|
7170
|
+
var SERVICE, LEGACY_SERVICE, ACCOUNT, linuxSecretAvailability, ENCRYPTED_PREFIX;
|
|
6940
7171
|
var init_keychain = __esm({
|
|
6941
7172
|
"src/lib/keychain.ts"() {
|
|
6942
7173
|
"use strict";
|
|
6943
|
-
SERVICE = "exe-
|
|
7174
|
+
SERVICE = "exe-os";
|
|
7175
|
+
LEGACY_SERVICE = "exe-mem";
|
|
6944
7176
|
ACCOUNT = "master-key";
|
|
7177
|
+
linuxSecretAvailability = null;
|
|
6945
7178
|
ENCRYPTED_PREFIX = "enc:";
|
|
6946
7179
|
}
|
|
6947
7180
|
});
|
|
@@ -7155,12 +7388,12 @@ __export(shard_manager_exports, {
|
|
|
7155
7388
|
listShards: () => listShards,
|
|
7156
7389
|
shardExists: () => shardExists
|
|
7157
7390
|
});
|
|
7158
|
-
import
|
|
7159
|
-
import { existsSync as
|
|
7391
|
+
import path22 from "path";
|
|
7392
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync9, readdirSync as readdirSync5, renameSync as renameSync5, statSync as statSync4 } from "fs";
|
|
7160
7393
|
import { createClient as createClient2 } from "@libsql/client";
|
|
7161
7394
|
function initShardManager(encryptionKey) {
|
|
7162
7395
|
_encryptionKey = encryptionKey;
|
|
7163
|
-
if (!
|
|
7396
|
+
if (!existsSync18(SHARDS_DIR)) {
|
|
7164
7397
|
mkdirSync9(SHARDS_DIR, { recursive: true });
|
|
7165
7398
|
}
|
|
7166
7399
|
_shardingEnabled = true;
|
|
@@ -7190,7 +7423,7 @@ function getShardClient(projectName) {
|
|
|
7190
7423
|
while (_shards.size >= MAX_OPEN_SHARDS) {
|
|
7191
7424
|
evictLRU();
|
|
7192
7425
|
}
|
|
7193
|
-
const dbPath =
|
|
7426
|
+
const dbPath = path22.join(SHARDS_DIR, `${safeName}.db`);
|
|
7194
7427
|
const client = createClient2({
|
|
7195
7428
|
url: `file:${dbPath}`,
|
|
7196
7429
|
encryptionKey: _encryptionKey
|
|
@@ -7201,13 +7434,13 @@ function getShardClient(projectName) {
|
|
|
7201
7434
|
}
|
|
7202
7435
|
function shardExists(projectName) {
|
|
7203
7436
|
const safeName = safeShardName(projectName);
|
|
7204
|
-
return
|
|
7437
|
+
return existsSync18(path22.join(SHARDS_DIR, `${safeName}.db`));
|
|
7205
7438
|
}
|
|
7206
7439
|
function safeShardName(projectName) {
|
|
7207
7440
|
return projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
7208
7441
|
}
|
|
7209
7442
|
function listShards() {
|
|
7210
|
-
if (!
|
|
7443
|
+
if (!existsSync18(SHARDS_DIR)) return [];
|
|
7211
7444
|
return readdirSync5(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
|
|
7212
7445
|
}
|
|
7213
7446
|
async function auditShardHealth(options = {}) {
|
|
@@ -7219,8 +7452,8 @@ async function auditShardHealth(options = {}) {
|
|
|
7219
7452
|
const names = listShards();
|
|
7220
7453
|
const shards = [];
|
|
7221
7454
|
for (const name of names) {
|
|
7222
|
-
const dbPath =
|
|
7223
|
-
const stat =
|
|
7455
|
+
const dbPath = path22.join(SHARDS_DIR, `${name}.db`);
|
|
7456
|
+
const stat = statSync4(dbPath);
|
|
7224
7457
|
const item = {
|
|
7225
7458
|
name,
|
|
7226
7459
|
path: dbPath,
|
|
@@ -7254,8 +7487,8 @@ async function auditShardHealth(options = {}) {
|
|
|
7254
7487
|
_shards.delete(name);
|
|
7255
7488
|
_shardLastAccess.delete(name);
|
|
7256
7489
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
7257
|
-
const archivedPath =
|
|
7258
|
-
|
|
7490
|
+
const archivedPath = path22.join(SHARDS_DIR, `${name}.db.broken-${stamp}`);
|
|
7491
|
+
renameSync5(dbPath, archivedPath);
|
|
7259
7492
|
item.archivedPath = archivedPath;
|
|
7260
7493
|
}
|
|
7261
7494
|
} finally {
|
|
@@ -7471,12 +7704,12 @@ async function getReadyShardClient(projectName) {
|
|
|
7471
7704
|
client.close();
|
|
7472
7705
|
_shards.delete(safeName);
|
|
7473
7706
|
_shardLastAccess.delete(safeName);
|
|
7474
|
-
const dbPath =
|
|
7475
|
-
if (
|
|
7476
|
-
const stat =
|
|
7707
|
+
const dbPath = path22.join(SHARDS_DIR, `${safeName}.db`);
|
|
7708
|
+
if (existsSync18(dbPath)) {
|
|
7709
|
+
const stat = statSync4(dbPath);
|
|
7477
7710
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
7478
|
-
const archivedPath =
|
|
7479
|
-
|
|
7711
|
+
const archivedPath = path22.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
7712
|
+
renameSync5(dbPath, archivedPath);
|
|
7480
7713
|
process.stderr.write(
|
|
7481
7714
|
`[shard-manager] Archived unreadable shard ${safeName}: ${archivedPath} (${stat.size} bytes, mtime ${stat.mtime.toISOString()})
|
|
7482
7715
|
`
|
|
@@ -7543,7 +7776,7 @@ var init_shard_manager = __esm({
|
|
|
7543
7776
|
"src/lib/shard-manager.ts"() {
|
|
7544
7777
|
"use strict";
|
|
7545
7778
|
init_config();
|
|
7546
|
-
SHARDS_DIR =
|
|
7779
|
+
SHARDS_DIR = path22.join(EXE_AI_DIR, "shards");
|
|
7547
7780
|
SHARD_IDLE_MS = 5 * 60 * 1e3;
|
|
7548
7781
|
MAX_OPEN_SHARDS = 10;
|
|
7549
7782
|
EVICTION_INTERVAL_MS = 60 * 1e3;
|
|
@@ -7593,6 +7826,12 @@ var init_platform_procedures = __esm({
|
|
|
7593
7826
|
priority: "p0",
|
|
7594
7827
|
content: "Founder -> coordinator (the executive agent, internally routed as 'COO') -> CTO/CMO. CTO -> engineers. CMO -> content production. Never skip levels: the coordinator does not bypass managers for specialist work. Specialists report to their manager. If you need cross-team info, use ask_team_memory \u2014 don't read other agents' task folders. Each level owns dispatch downward and review upward."
|
|
7595
7828
|
},
|
|
7829
|
+
{
|
|
7830
|
+
title: "Customer orchestration maturity \u2014 recommend, never trap",
|
|
7831
|
+
domain: "workflow",
|
|
7832
|
+
priority: "p1",
|
|
7833
|
+
content: "New customers start best in Phase 1: founder \u2194 coordinator/Chief of Staff, building company context. Suggest Phase 2 executives when domain work repeats; suggest Phase 3 parallel execution only when review/permission gates are ready. This is guidance, not a blocker: users may jump phases anytime. Never overwrite their phase, role titles, identities, or custom org design."
|
|
7834
|
+
},
|
|
7596
7835
|
{
|
|
7597
7836
|
title: "Single dispatch path \u2014 create_task only",
|
|
7598
7837
|
domain: "workflow",
|
|
@@ -7651,6 +7890,12 @@ var init_platform_procedures = __esm({
|
|
|
7651
7890
|
priority: "p0",
|
|
7652
7891
|
content: "exe-build-adv is MANDATORY for ALL work touching 3+ files. Run /exe-build-adv --auto BEFORE implementation. Pipeline: Spec \u2192 AC \u2192 Tests \u2192 Evaluate \u2192 Fix. No multi-file feature ships without pipeline artifacts. No exceptions \u2014 managers reject work without them."
|
|
7653
7892
|
},
|
|
7893
|
+
{
|
|
7894
|
+
title: "Commit discipline \u2014 never leave verified work floating",
|
|
7895
|
+
domain: "workflow",
|
|
7896
|
+
priority: "p1",
|
|
7897
|
+
content: "After any code-change batch passes typecheck/tests/build, run git status, summarize changed files, and commit with a clear message before ending the session. If work must remain uncommitted for review/dogfood, explicitly say so, list the files, and state the blocker. Never imply work is complete while verified changes are still floating locally."
|
|
7898
|
+
},
|
|
7654
7899
|
{
|
|
7655
7900
|
title: "Desktop and TUI are the same product",
|
|
7656
7901
|
domain: "architecture",
|
|
@@ -7968,6 +8213,274 @@ var init_memory_cards = __esm({
|
|
|
7968
8213
|
}
|
|
7969
8214
|
});
|
|
7970
8215
|
|
|
8216
|
+
// src/lib/agentic-ontology.ts
|
|
8217
|
+
var agentic_ontology_exports = {};
|
|
8218
|
+
__export(agentic_ontology_exports, {
|
|
8219
|
+
clean: () => clean,
|
|
8220
|
+
extractGoalCandidates: () => extractGoalCandidates,
|
|
8221
|
+
inferIntention: () => inferIntention,
|
|
8222
|
+
inferOntologyEventType: () => inferOntologyEventType,
|
|
8223
|
+
inferOutcome: () => inferOutcome,
|
|
8224
|
+
inferSemanticLabel: () => inferSemanticLabel,
|
|
8225
|
+
insertOntologyForBatch: () => insertOntologyForBatch,
|
|
8226
|
+
insertOntologyForMemory: () => insertOntologyForMemory,
|
|
8227
|
+
ontologyPayload: () => ontologyPayload,
|
|
8228
|
+
stableId: () => stableId2
|
|
8229
|
+
});
|
|
8230
|
+
import { createHash as createHash3 } from "crypto";
|
|
8231
|
+
function stableId2(...parts) {
|
|
8232
|
+
return createHash3("sha256").update(parts.map((p) => String(p ?? "")).join("::")).digest("hex").slice(0, 32);
|
|
8233
|
+
}
|
|
8234
|
+
function clean(text, max = 240) {
|
|
8235
|
+
return text.replace(/\u0000/g, "").replace(/```[\s\S]*?```/g, " ").replace(/\s+/g, " ").trim().slice(0, max);
|
|
8236
|
+
}
|
|
8237
|
+
function inferOntologyEventType(row) {
|
|
8238
|
+
const lower = row.raw_text.toLowerCase();
|
|
8239
|
+
if (row.has_error) return "error";
|
|
8240
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published)\b/.test(lower)) return "milestone";
|
|
8241
|
+
if (/\b(blocked|failed|error|bug|regression|broken)\b/.test(lower)) return "problem";
|
|
8242
|
+
if (/\b(decided|decision|adr|we chose|approved|rejected)\b/.test(lower)) return "decision";
|
|
8243
|
+
if (/\b(goal|need to|we need|want to|trying to|objective)\b/.test(lower)) return "goal_signal";
|
|
8244
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) return "tool_action";
|
|
8245
|
+
if (row.tool_name.startsWith("memory_card")) return "memory_card";
|
|
8246
|
+
return "memory_observation";
|
|
8247
|
+
}
|
|
8248
|
+
function inferIntention(row) {
|
|
8249
|
+
if (row.intent) return clean(row.intent, 220);
|
|
8250
|
+
const text = clean(row.raw_text, 1e3);
|
|
8251
|
+
const patterns = [
|
|
8252
|
+
/(?:we need to|need to|let'?s|i want to|we should|goal is to|objective is to|trying to)\s+([^.!?\n]{8,220})/i,
|
|
8253
|
+
/(?:so that|in order to)\s+([^.!?\n]{8,220})/i,
|
|
8254
|
+
/(?:task|plan):\s*([^.!?\n]{8,220})/i
|
|
8255
|
+
];
|
|
8256
|
+
for (const p of patterns) {
|
|
8257
|
+
const m = text.match(p);
|
|
8258
|
+
if (m?.[1]) return clean(m[1], 220);
|
|
8259
|
+
}
|
|
8260
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) {
|
|
8261
|
+
return `${row.tool_name} during ${row.project_name}`;
|
|
8262
|
+
}
|
|
8263
|
+
return null;
|
|
8264
|
+
}
|
|
8265
|
+
function inferOutcome(row) {
|
|
8266
|
+
if (row.outcome) return clean(row.outcome, 220);
|
|
8267
|
+
if (row.has_error) return "error";
|
|
8268
|
+
const lower = row.raw_text.toLowerCase();
|
|
8269
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published|passed)\b/.test(lower)) return "success_signal";
|
|
8270
|
+
if (/\b(blocked|failed|error|regression|broken|not working|could not)\b/.test(lower)) return "failure_signal";
|
|
8271
|
+
if (/\b(warning|risk|concern|caveat)\b/.test(lower)) return "risk_signal";
|
|
8272
|
+
return null;
|
|
8273
|
+
}
|
|
8274
|
+
function extractGoalCandidates(row) {
|
|
8275
|
+
const text = clean(row.raw_text, 1600);
|
|
8276
|
+
const patterns = [
|
|
8277
|
+
/(?:we need to|need to|i want to|we should|goal is to|objective is to|trying to|let'?s)\s+([^.!?\n]{12,220})/gi,
|
|
8278
|
+
/(?:success means|success criteria|so that)\s+([^.!?\n]{12,220})/gi
|
|
8279
|
+
];
|
|
8280
|
+
const out = [];
|
|
8281
|
+
for (const pattern of patterns) {
|
|
8282
|
+
for (const m of text.matchAll(pattern)) {
|
|
8283
|
+
const candidate = clean(m[1] ?? "", 220);
|
|
8284
|
+
if (candidate.length >= 12 && !out.some((x) => x.toLowerCase() === candidate.toLowerCase())) out.push(candidate);
|
|
8285
|
+
if (out.length >= 3) return out;
|
|
8286
|
+
}
|
|
8287
|
+
}
|
|
8288
|
+
return out;
|
|
8289
|
+
}
|
|
8290
|
+
function uniq(values, max = 6) {
|
|
8291
|
+
const out = [];
|
|
8292
|
+
for (const value of values.map((v) => clean(v, 220)).filter(Boolean)) {
|
|
8293
|
+
if (!out.some((x) => x.toLowerCase() === value.toLowerCase())) out.push(value);
|
|
8294
|
+
if (out.length >= max) break;
|
|
8295
|
+
}
|
|
8296
|
+
return out;
|
|
8297
|
+
}
|
|
8298
|
+
function extractMatches(text, patterns, max = 5) {
|
|
8299
|
+
const out = [];
|
|
8300
|
+
for (const pattern of patterns) {
|
|
8301
|
+
for (const match of text.matchAll(pattern)) {
|
|
8302
|
+
const value = match[1] ?? match[0];
|
|
8303
|
+
if (value) out.push(value);
|
|
8304
|
+
if (out.length >= max) return uniq(out, max);
|
|
8305
|
+
}
|
|
8306
|
+
}
|
|
8307
|
+
return uniq(out, max);
|
|
8308
|
+
}
|
|
8309
|
+
function inferSemanticLabel(row) {
|
|
8310
|
+
const text = clean(row.raw_text, 2400);
|
|
8311
|
+
const eventType = inferOntologyEventType(row);
|
|
8312
|
+
const intention = inferIntention(row);
|
|
8313
|
+
const outcome = inferOutcome(row);
|
|
8314
|
+
const goals = extractGoalCandidates(row);
|
|
8315
|
+
const milestones = extractMatches(text, [
|
|
8316
|
+
/\b(?:completed|finished|fixed|resolved|shipped|deployed|published|pushed|passed)\b([^.!?\n]{0,180})/gi,
|
|
8317
|
+
/(?:milestone|done):\s*([^.!?\n]{8,220})/gi
|
|
8318
|
+
]);
|
|
8319
|
+
const problems = extractMatches(text, [
|
|
8320
|
+
/\b(?:blocked by|failed because|bug|regression|broken|not working|error)\b([^.!?\n]{0,180})/gi,
|
|
8321
|
+
/(?:problem|issue|risk):\s*([^.!?\n]{8,220})/gi
|
|
8322
|
+
]);
|
|
8323
|
+
const decisions = extractMatches(text, [
|
|
8324
|
+
/(?:decided|decision|adr|we chose|approved|rejected)\s+([^.!?\n]{8,220})/gi
|
|
8325
|
+
]);
|
|
8326
|
+
const temporalAnchors = extractMatches(text, [
|
|
8327
|
+
/\b(\d{4}-\d{2}-\d{2}(?:[T ][0-9:.+-Z]+)?)\b/g,
|
|
8328
|
+
/\b(today|yesterday|tomorrow|this week|next week|last week|morning|afternoon|tonight)\b/gi
|
|
8329
|
+
], 8);
|
|
8330
|
+
const nextActions = extractMatches(text, [
|
|
8331
|
+
/(?:next|todo|follow[- ]?up|remaining|need to)\s*:?\s*([^.!?\n]{8,220})/gi
|
|
8332
|
+
]);
|
|
8333
|
+
const actors = uniq([
|
|
8334
|
+
row.agent_id,
|
|
8335
|
+
...extractMatches(text, [/\b(?:agent|employee|owner|assignee)[:= ]+([a-zA-Z][a-zA-Z0-9_-]{1,40})/gi], 5)
|
|
8336
|
+
], 6);
|
|
8337
|
+
const successSignals = milestones.length ? milestones : outcome === "success_signal" ? [clean(text, 180)] : [];
|
|
8338
|
+
const failureSignals = problems.length ? problems : outcome === "failure_signal" || row.has_error ? [clean(text, 180)] : [];
|
|
8339
|
+
const impact = successSignals.length && failureSignals.length ? "mixed" : failureSignals.length ? "negative" : successSignals.length ? "positive" : "neutral";
|
|
8340
|
+
const signalCount = goals.length + milestones.length + problems.length + decisions.length + nextActions.length;
|
|
8341
|
+
return {
|
|
8342
|
+
labeler: "deterministic",
|
|
8343
|
+
schemaVersion: 1,
|
|
8344
|
+
eventType,
|
|
8345
|
+
intention,
|
|
8346
|
+
outcome,
|
|
8347
|
+
impact,
|
|
8348
|
+
confidence: Math.min(0.95, 0.45 + signalCount * 0.08 + (intention ? 0.1 : 0) + (outcome ? 0.1 : 0)),
|
|
8349
|
+
goals,
|
|
8350
|
+
milestones,
|
|
8351
|
+
problems,
|
|
8352
|
+
decisions,
|
|
8353
|
+
actors,
|
|
8354
|
+
temporalAnchors,
|
|
8355
|
+
successSignals,
|
|
8356
|
+
failureSignals,
|
|
8357
|
+
nextActions,
|
|
8358
|
+
summary: clean(text, 280)
|
|
8359
|
+
};
|
|
8360
|
+
}
|
|
8361
|
+
function ontologyPayload(row) {
|
|
8362
|
+
const semantic = inferSemanticLabel(row);
|
|
8363
|
+
return {
|
|
8364
|
+
tool_name: row.tool_name,
|
|
8365
|
+
memory_version: row.version ?? null,
|
|
8366
|
+
domain: row.domain ?? null,
|
|
8367
|
+
trajectory: row.trajectory ? safeJson(row.trajectory) : null,
|
|
8368
|
+
semantic
|
|
8369
|
+
};
|
|
8370
|
+
}
|
|
8371
|
+
function safeJson(value) {
|
|
8372
|
+
try {
|
|
8373
|
+
return JSON.parse(value);
|
|
8374
|
+
} catch {
|
|
8375
|
+
return value.slice(0, 1e3);
|
|
8376
|
+
}
|
|
8377
|
+
}
|
|
8378
|
+
async function resolveClient(client) {
|
|
8379
|
+
if (client) return client;
|
|
8380
|
+
const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
8381
|
+
return getClient2();
|
|
8382
|
+
}
|
|
8383
|
+
async function insertOntologyForMemory(row, client) {
|
|
8384
|
+
const db = await resolveClient(client);
|
|
8385
|
+
const occurredAt = row.timestamp;
|
|
8386
|
+
const sequence = Number(row.version ?? 0) || Math.floor(new Date(occurredAt).getTime() / 1e3);
|
|
8387
|
+
const eventType = inferOntologyEventType(row);
|
|
8388
|
+
const intention = inferIntention(row);
|
|
8389
|
+
const outcome = inferOutcome(row);
|
|
8390
|
+
const eventId = stableId2("event", row.id);
|
|
8391
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
8392
|
+
await db.execute({
|
|
8393
|
+
sql: `INSERT INTO agent_sessions (id, agent_id, project_name, started_at, last_event_at, event_count, properties)
|
|
8394
|
+
VALUES (?, ?, ?, ?, ?, 1, ?)
|
|
8395
|
+
ON CONFLICT(id) DO UPDATE SET last_event_at = MAX(last_event_at, excluded.last_event_at),
|
|
8396
|
+
event_count = event_count + 1`,
|
|
8397
|
+
args: [row.session_id, row.agent_id, row.project_name, occurredAt, occurredAt, JSON.stringify({ agent_role: row.agent_role })]
|
|
8398
|
+
});
|
|
8399
|
+
await db.execute({
|
|
8400
|
+
sql: `INSERT OR IGNORE INTO agent_events
|
|
8401
|
+
(id, event_type, occurred_at, sequence_index, actor_agent_id, agent_role, project_name,
|
|
8402
|
+
session_id, task_id, goal_id, parent_event_id, intention, outcome, evidence_memory_id,
|
|
8403
|
+
impact, payload, created_at)
|
|
8404
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, ?, ?, ?, ?, ?, ?)`,
|
|
8405
|
+
args: [
|
|
8406
|
+
eventId,
|
|
8407
|
+
eventType,
|
|
8408
|
+
occurredAt,
|
|
8409
|
+
sequence,
|
|
8410
|
+
row.agent_id,
|
|
8411
|
+
row.agent_role,
|
|
8412
|
+
row.project_name,
|
|
8413
|
+
row.session_id,
|
|
8414
|
+
row.task_id ?? null,
|
|
8415
|
+
intention,
|
|
8416
|
+
outcome,
|
|
8417
|
+
row.id,
|
|
8418
|
+
row.has_error ? "negative" : outcome === "success_signal" ? "positive" : "neutral",
|
|
8419
|
+
JSON.stringify(ontologyPayload(row)),
|
|
8420
|
+
now
|
|
8421
|
+
]
|
|
8422
|
+
});
|
|
8423
|
+
const semantic = inferSemanticLabel(row);
|
|
8424
|
+
await db.execute({
|
|
8425
|
+
sql: `INSERT INTO agent_semantic_labels
|
|
8426
|
+
(id, source_memory_id, event_id, labeler, schema_version, confidence, labels, created_at, updated_at)
|
|
8427
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
8428
|
+
ON CONFLICT(id) DO UPDATE SET confidence = excluded.confidence,
|
|
8429
|
+
labels = excluded.labels, updated_at = excluded.updated_at`,
|
|
8430
|
+
args: [
|
|
8431
|
+
stableId2("semantic", row.id, semantic.labeler, semantic.schemaVersion),
|
|
8432
|
+
row.id,
|
|
8433
|
+
eventId,
|
|
8434
|
+
semantic.labeler,
|
|
8435
|
+
semantic.schemaVersion,
|
|
8436
|
+
semantic.confidence,
|
|
8437
|
+
JSON.stringify(semantic),
|
|
8438
|
+
now,
|
|
8439
|
+
now
|
|
8440
|
+
]
|
|
8441
|
+
});
|
|
8442
|
+
for (const statement of extractGoalCandidates(row)) {
|
|
8443
|
+
const goalId = stableId2("goal", row.project_name, statement.toLowerCase());
|
|
8444
|
+
await db.execute({
|
|
8445
|
+
sql: `INSERT INTO agent_goals
|
|
8446
|
+
(id, statement, owner_agent_id, project_name, status, priority, success_criteria,
|
|
8447
|
+
parent_goal_id, due_at, achieved_at, supersedes_id, created_at, updated_at, source_memory_id)
|
|
8448
|
+
VALUES (?, ?, ?, ?, 'open', 5, NULL, NULL, NULL, NULL, NULL, ?, ?, ?)
|
|
8449
|
+
ON CONFLICT(id) DO UPDATE SET updated_at = excluded.updated_at`,
|
|
8450
|
+
args: [goalId, statement, row.agent_id, row.project_name, now, now, row.id]
|
|
8451
|
+
});
|
|
8452
|
+
await db.execute({
|
|
8453
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
8454
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
8455
|
+
VALUES (?, ?, 'evidence', ?, 'memory', ?)`,
|
|
8456
|
+
args: [stableId2("goal_link", goalId, row.id, "memory"), goalId, row.id, now]
|
|
8457
|
+
});
|
|
8458
|
+
await db.execute({
|
|
8459
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
8460
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
8461
|
+
VALUES (?, ?, 'event', ?, 'event', ?)`,
|
|
8462
|
+
args: [stableId2("goal_link", goalId, eventId, "event"), goalId, eventId, now]
|
|
8463
|
+
});
|
|
8464
|
+
}
|
|
8465
|
+
}
|
|
8466
|
+
async function insertOntologyForBatch(rows, client) {
|
|
8467
|
+
const db = await resolveClient(client);
|
|
8468
|
+
let count = 0;
|
|
8469
|
+
for (const row of rows) {
|
|
8470
|
+
try {
|
|
8471
|
+
await insertOntologyForMemory(row, db);
|
|
8472
|
+
count++;
|
|
8473
|
+
} catch {
|
|
8474
|
+
}
|
|
8475
|
+
}
|
|
8476
|
+
return count;
|
|
8477
|
+
}
|
|
8478
|
+
var init_agentic_ontology = __esm({
|
|
8479
|
+
"src/lib/agentic-ontology.ts"() {
|
|
8480
|
+
"use strict";
|
|
8481
|
+
}
|
|
8482
|
+
});
|
|
8483
|
+
|
|
7971
8484
|
// src/lib/store.ts
|
|
7972
8485
|
var store_exports = {};
|
|
7973
8486
|
__export(store_exports, {
|
|
@@ -8311,6 +8824,11 @@ async function flushBatch() {
|
|
|
8311
8824
|
await insertMemoryCardsForBatch2(batch);
|
|
8312
8825
|
} catch {
|
|
8313
8826
|
}
|
|
8827
|
+
try {
|
|
8828
|
+
const { insertOntologyForBatch: insertOntologyForBatch2 } = await Promise.resolve().then(() => (init_agentic_ontology(), agentic_ontology_exports));
|
|
8829
|
+
await insertOntologyForBatch2(batch);
|
|
8830
|
+
} catch {
|
|
8831
|
+
}
|
|
8314
8832
|
schedulePostWriteMemoryHygiene(batch.map((row) => row.id));
|
|
8315
8833
|
_pendingRecords.splice(0, batch.length);
|
|
8316
8834
|
try {
|
|
@@ -8658,78 +9176,6 @@ var init_fast_db_init = __esm({
|
|
|
8658
9176
|
}
|
|
8659
9177
|
});
|
|
8660
9178
|
|
|
8661
|
-
// src/lib/memory-queue.ts
|
|
8662
|
-
import { appendFileSync as appendFileSync2, readFileSync as readFileSync14, renameSync as renameSync5, unlinkSync as unlinkSync8, existsSync as existsSync18, statSync as statSync3 } from "fs";
|
|
8663
|
-
import path22 from "path";
|
|
8664
|
-
function enqueueMemory(entry) {
|
|
8665
|
-
appendFileSync2(QUEUE_PATH2, JSON.stringify(entry) + "\n");
|
|
8666
|
-
}
|
|
8667
|
-
var QUEUE_PATH2, PROCESSING_PATH, TTL_MS2;
|
|
8668
|
-
var init_memory_queue = __esm({
|
|
8669
|
-
"src/lib/memory-queue.ts"() {
|
|
8670
|
-
"use strict";
|
|
8671
|
-
init_config();
|
|
8672
|
-
QUEUE_PATH2 = path22.join(EXE_AI_DIR, "memory-queue.jsonl");
|
|
8673
|
-
PROCESSING_PATH = QUEUE_PATH2 + ".processing";
|
|
8674
|
-
TTL_MS2 = 24 * 60 * 60 * 1e3;
|
|
8675
|
-
}
|
|
8676
|
-
});
|
|
8677
|
-
|
|
8678
|
-
// src/lib/memory-queue-client.ts
|
|
8679
|
-
var memory_queue_client_exports = {};
|
|
8680
|
-
__export(memory_queue_client_exports, {
|
|
8681
|
-
batchWriteMemoryViaDaemon: () => batchWriteMemoryViaDaemon,
|
|
8682
|
-
writeMemoryViaDaemon: () => writeMemoryViaDaemon
|
|
8683
|
-
});
|
|
8684
|
-
async function writeMemoryViaDaemon(entry) {
|
|
8685
|
-
if (process.env.EXE_IS_DAEMON === "1") {
|
|
8686
|
-
enqueueMemory(entry);
|
|
8687
|
-
return false;
|
|
8688
|
-
}
|
|
8689
|
-
if (!isClientConnected()) {
|
|
8690
|
-
enqueueMemory(entry);
|
|
8691
|
-
return false;
|
|
8692
|
-
}
|
|
8693
|
-
try {
|
|
8694
|
-
const response = await sendDaemonRequest({
|
|
8695
|
-
type: "write-memory",
|
|
8696
|
-
entry
|
|
8697
|
-
});
|
|
8698
|
-
if (response.ok) return true;
|
|
8699
|
-
enqueueMemory(entry);
|
|
8700
|
-
return false;
|
|
8701
|
-
} catch {
|
|
8702
|
-
enqueueMemory(entry);
|
|
8703
|
-
return false;
|
|
8704
|
-
}
|
|
8705
|
-
}
|
|
8706
|
-
async function batchWriteMemoryViaDaemon(entries) {
|
|
8707
|
-
if (entries.length === 0) return 0;
|
|
8708
|
-
if (process.env.EXE_IS_DAEMON === "1" || !isClientConnected()) {
|
|
8709
|
-
for (const entry of entries) enqueueMemory(entry);
|
|
8710
|
-
return 0;
|
|
8711
|
-
}
|
|
8712
|
-
try {
|
|
8713
|
-
const response = await sendDaemonRequest({
|
|
8714
|
-
type: "batch-write-memory",
|
|
8715
|
-
entries
|
|
8716
|
-
});
|
|
8717
|
-
if (response.ok) return response.count ?? entries.length;
|
|
8718
|
-
for (const entry of entries) enqueueMemory(entry);
|
|
8719
|
-
return 0;
|
|
8720
|
-
} catch {
|
|
8721
|
-
for (const entry of entries) enqueueMemory(entry);
|
|
8722
|
-
return 0;
|
|
8723
|
-
}
|
|
8724
|
-
}
|
|
8725
|
-
var init_memory_queue_client = __esm({
|
|
8726
|
-
"src/lib/memory-queue-client.ts"() {
|
|
8727
|
-
"use strict";
|
|
8728
|
-
init_exe_daemon_client();
|
|
8729
|
-
init_memory_queue();
|
|
8730
|
-
}
|
|
8731
|
-
});
|
|
8732
|
-
|
|
8733
9179
|
// src/lib/active-agent.ts
|
|
8734
9180
|
init_config();
|
|
8735
9181
|
init_session_key();
|
|
@@ -8840,6 +9286,209 @@ function getActiveAgent() {
|
|
|
8840
9286
|
|
|
8841
9287
|
// src/adapters/claude/hooks/pre-compact.ts
|
|
8842
9288
|
init_task_scope();
|
|
9289
|
+
|
|
9290
|
+
// src/lib/auto-checkpoint.ts
|
|
9291
|
+
var FILE_RE = /(?:^|\s)([\w./-]+\.(?:ts|tsx|js|jsx|json|md|yml|yaml|sql|go|py|css|scss|html|sh))(?:\b|$)/g;
|
|
9292
|
+
var DECISION_RE = /\b(decision:|decided:|we decided|founder directive|captured in .*architecture|source of truth)\b/i;
|
|
9293
|
+
function asString(value, fallback = "") {
|
|
9294
|
+
if (value == null) return fallback;
|
|
9295
|
+
return String(value);
|
|
9296
|
+
}
|
|
9297
|
+
function compactLine(text, max = 220) {
|
|
9298
|
+
return text.replace(/\s+/g, " ").trim().slice(0, max);
|
|
9299
|
+
}
|
|
9300
|
+
function topEntries(counts, limit) {
|
|
9301
|
+
return [...counts.entries()].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).slice(0, limit).map(([name, count]) => `${name}(${count})`);
|
|
9302
|
+
}
|
|
9303
|
+
function buildAutoCheckpoint(input2) {
|
|
9304
|
+
const maxSamples = input2.maxSamples ?? 8;
|
|
9305
|
+
const projectCounts = /* @__PURE__ */ new Map();
|
|
9306
|
+
const toolCounts = /* @__PURE__ */ new Map();
|
|
9307
|
+
const files = /* @__PURE__ */ new Set();
|
|
9308
|
+
const errors = [];
|
|
9309
|
+
const samples = [];
|
|
9310
|
+
const decisionTexts = [];
|
|
9311
|
+
for (const row of input2.memories) {
|
|
9312
|
+
const tool = asString(row.tool_name, "unknown");
|
|
9313
|
+
const project = asString(row.project_name, input2.projectName || "unknown");
|
|
9314
|
+
const raw = asString(row.raw_text);
|
|
9315
|
+
const hasError = row.has_error === 1 || row.has_error === true;
|
|
9316
|
+
toolCounts.set(tool, (toolCounts.get(tool) ?? 0) + 1);
|
|
9317
|
+
projectCounts.set(project, (projectCounts.get(project) ?? 0) + 1);
|
|
9318
|
+
if (hasError && errors.length < 5) errors.push(compactLine(raw, 180));
|
|
9319
|
+
if (samples.length < maxSamples && raw.length > 30) {
|
|
9320
|
+
samples.push(`[${tool}] ${compactLine(raw)}`);
|
|
9321
|
+
}
|
|
9322
|
+
if (DECISION_RE.test(raw) && decisionTexts.length < 5) {
|
|
9323
|
+
decisionTexts.push(`AUTO DECISION CANDIDATE [${input2.agentId}]: ${compactLine(raw, 500)}`);
|
|
9324
|
+
}
|
|
9325
|
+
for (const match of raw.matchAll(FILE_RE)) {
|
|
9326
|
+
if (match[1]) files.add(match[1]);
|
|
9327
|
+
if (files.size >= 20) break;
|
|
9328
|
+
}
|
|
9329
|
+
}
|
|
9330
|
+
const taskLines = (input2.tasks ?? []).slice(0, 10).map((task) => {
|
|
9331
|
+
const status = asString(task.status, "unknown");
|
|
9332
|
+
const priority = asString(task.priority, "?").toUpperCase();
|
|
9333
|
+
const title = asString(task.title, "untitled");
|
|
9334
|
+
const taskFile = asString(task.task_file);
|
|
9335
|
+
return `- [${status}/${priority}] ${title}${taskFile ? ` (${taskFile})` : ""}`;
|
|
9336
|
+
});
|
|
9337
|
+
const parts = [
|
|
9338
|
+
`CONTEXT CHECKPOINT [auto:${input2.reason}]`,
|
|
9339
|
+
`Agent: ${input2.agentId} (${input2.agentRole})`,
|
|
9340
|
+
`Session: ${input2.sessionId}`,
|
|
9341
|
+
`Project: ${input2.projectName}`,
|
|
9342
|
+
`Time: ${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
9343
|
+
"",
|
|
9344
|
+
"## Recent Activity",
|
|
9345
|
+
`- Memories scanned: ${input2.memories.length}`,
|
|
9346
|
+
`- Projects: ${topEntries(projectCounts, 5).join(", ") || input2.projectName}`,
|
|
9347
|
+
`- Tools: ${topEntries(toolCounts, 8).join(", ") || "none"}`
|
|
9348
|
+
];
|
|
9349
|
+
if (taskLines.length > 0) {
|
|
9350
|
+
parts.push("", "## Open / Active Tasks", ...taskLines);
|
|
9351
|
+
}
|
|
9352
|
+
if (files.size > 0) {
|
|
9353
|
+
parts.push("", "## Files Mentioned", ...[...files].slice(0, 20).map((f) => `- ${f}`));
|
|
9354
|
+
}
|
|
9355
|
+
if (samples.length > 0) {
|
|
9356
|
+
parts.push("", "## Important Recent Traces", ...samples.map((s) => `- ${s}`));
|
|
9357
|
+
}
|
|
9358
|
+
if (errors.length > 0) {
|
|
9359
|
+
parts.push("", "## Errors / Risks", ...errors.map((e) => `- ${e}`));
|
|
9360
|
+
}
|
|
9361
|
+
if (decisionTexts.length > 0) {
|
|
9362
|
+
parts.push("", "## Decision Candidates", ...decisionTexts.map((d) => `- ${d.replace(/^AUTO DECISION CANDIDATE \\[[^\\]]+\\]: /, "")}`));
|
|
9363
|
+
}
|
|
9364
|
+
return {
|
|
9365
|
+
checkpointText: parts.join("\n"),
|
|
9366
|
+
decisionTexts
|
|
9367
|
+
};
|
|
9368
|
+
}
|
|
9369
|
+
|
|
9370
|
+
// src/lib/memory-queue-client.ts
|
|
9371
|
+
init_exe_daemon_client();
|
|
9372
|
+
|
|
9373
|
+
// src/lib/memory-queue.ts
|
|
9374
|
+
init_config();
|
|
9375
|
+
import { appendFileSync as appendFileSync2, readFileSync as readFileSync14, renameSync as renameSync4, unlinkSync as unlinkSync8, existsSync as existsSync16, statSync as statSync2 } from "fs";
|
|
9376
|
+
import path20 from "path";
|
|
9377
|
+
var QUEUE_PATH2 = path20.join(EXE_AI_DIR, "memory-queue.jsonl");
|
|
9378
|
+
var PROCESSING_PATH = QUEUE_PATH2 + ".processing";
|
|
9379
|
+
var TTL_MS2 = 24 * 60 * 60 * 1e3;
|
|
9380
|
+
function enqueueMemory(entry) {
|
|
9381
|
+
appendFileSync2(QUEUE_PATH2, JSON.stringify(entry) + "\n");
|
|
9382
|
+
}
|
|
9383
|
+
|
|
9384
|
+
// src/lib/memory-queue-client.ts
|
|
9385
|
+
async function writeMemoryViaDaemon(entry) {
|
|
9386
|
+
if (process.env.EXE_IS_DAEMON === "1") {
|
|
9387
|
+
enqueueMemory(entry);
|
|
9388
|
+
return false;
|
|
9389
|
+
}
|
|
9390
|
+
if (!isClientConnected()) {
|
|
9391
|
+
enqueueMemory(entry);
|
|
9392
|
+
return false;
|
|
9393
|
+
}
|
|
9394
|
+
try {
|
|
9395
|
+
const response = await sendDaemonRequest({
|
|
9396
|
+
type: "write-memory",
|
|
9397
|
+
entry
|
|
9398
|
+
});
|
|
9399
|
+
if (response.ok) return true;
|
|
9400
|
+
enqueueMemory(entry);
|
|
9401
|
+
return false;
|
|
9402
|
+
} catch {
|
|
9403
|
+
enqueueMemory(entry);
|
|
9404
|
+
return false;
|
|
9405
|
+
}
|
|
9406
|
+
}
|
|
9407
|
+
|
|
9408
|
+
// src/lib/checkpoint-orchestrator.ts
|
|
9409
|
+
function toolNameForReason(reason) {
|
|
9410
|
+
switch (reason) {
|
|
9411
|
+
case "periodic":
|
|
9412
|
+
return "auto-summary";
|
|
9413
|
+
case "session-end":
|
|
9414
|
+
return "SessionEnd";
|
|
9415
|
+
case "pre-compact":
|
|
9416
|
+
return "pre-compact-hook";
|
|
9417
|
+
case "capacity-signal":
|
|
9418
|
+
return "auto-checkpoint";
|
|
9419
|
+
}
|
|
9420
|
+
}
|
|
9421
|
+
function importanceForReason(reason, override) {
|
|
9422
|
+
if (override !== void 0) return override;
|
|
9423
|
+
switch (reason) {
|
|
9424
|
+
case "periodic":
|
|
9425
|
+
return 7;
|
|
9426
|
+
case "session-end":
|
|
9427
|
+
case "pre-compact":
|
|
9428
|
+
case "capacity-signal":
|
|
9429
|
+
return 8;
|
|
9430
|
+
}
|
|
9431
|
+
}
|
|
9432
|
+
function buildContinuityCheckpoint(input2) {
|
|
9433
|
+
const { checkpointText, decisionTexts } = buildAutoCheckpoint({
|
|
9434
|
+
agentId: input2.agentId,
|
|
9435
|
+
agentRole: input2.agentRole,
|
|
9436
|
+
sessionId: input2.sessionId,
|
|
9437
|
+
projectName: input2.projectName,
|
|
9438
|
+
reason: input2.reason,
|
|
9439
|
+
memories: input2.memories ?? [],
|
|
9440
|
+
tasks: input2.tasks ?? [],
|
|
9441
|
+
maxSamples: input2.maxSamples
|
|
9442
|
+
});
|
|
9443
|
+
const extra = input2.extraSections?.filter((section) => section.trim().length > 0) ?? [];
|
|
9444
|
+
return {
|
|
9445
|
+
checkpointText: extra.length > 0 ? `${checkpointText}
|
|
9446
|
+
|
|
9447
|
+
${extra.join("\n\n")}` : checkpointText,
|
|
9448
|
+
decisionTexts
|
|
9449
|
+
};
|
|
9450
|
+
}
|
|
9451
|
+
async function writeContinuityCheckpoint(input2) {
|
|
9452
|
+
const result = buildContinuityCheckpoint(input2);
|
|
9453
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
9454
|
+
await writeMemoryViaDaemon({
|
|
9455
|
+
raw_text: result.checkpointText,
|
|
9456
|
+
agent_id: input2.agentId,
|
|
9457
|
+
agent_role: input2.agentRole,
|
|
9458
|
+
session_id: input2.sessionId,
|
|
9459
|
+
tool_name: toolNameForReason(input2.reason),
|
|
9460
|
+
project_name: input2.projectName,
|
|
9461
|
+
timestamp: now,
|
|
9462
|
+
importance: importanceForReason(input2.reason, input2.importance),
|
|
9463
|
+
task_id: input2.taskId,
|
|
9464
|
+
memory_type: "checkpoint"
|
|
9465
|
+
});
|
|
9466
|
+
const decisionLimit = input2.reason === "periodic" ? 3 : 5;
|
|
9467
|
+
for (const decisionText of result.decisionTexts.slice(0, decisionLimit)) {
|
|
9468
|
+
await writeMemoryViaDaemon({
|
|
9469
|
+
raw_text: decisionText,
|
|
9470
|
+
agent_id: input2.agentId,
|
|
9471
|
+
agent_role: input2.agentRole,
|
|
9472
|
+
session_id: input2.sessionId,
|
|
9473
|
+
tool_name: "auto-decision",
|
|
9474
|
+
project_name: input2.projectName,
|
|
9475
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9476
|
+
importance: 8,
|
|
9477
|
+
memory_type: "decision"
|
|
9478
|
+
});
|
|
9479
|
+
}
|
|
9480
|
+
return result;
|
|
9481
|
+
}
|
|
9482
|
+
async function checkpointActiveTask(input2) {
|
|
9483
|
+
const { writeCheckpoint: writeCheckpoint2 } = await Promise.resolve().then(() => (init_tasks(), tasks_exports));
|
|
9484
|
+
await writeCheckpoint2({
|
|
9485
|
+
taskId: input2.taskId,
|
|
9486
|
+
step: input2.step ?? "pre-compaction-checkpoint",
|
|
9487
|
+
contextSummary: `Auto-checkpoint before context compaction. Task: ${input2.taskTitle}. Session: ${input2.sessionId}. Project: ${input2.projectName}.`
|
|
9488
|
+
});
|
|
9489
|
+
}
|
|
9490
|
+
|
|
9491
|
+
// src/adapters/claude/hooks/pre-compact.ts
|
|
8843
9492
|
if (!process.env.AGENT_ID) {
|
|
8844
9493
|
process.env.AGENT_ID = "default";
|
|
8845
9494
|
process.env.AGENT_ROLE = "employee";
|
|
@@ -8882,11 +9531,11 @@ ${taskLines}`);
|
|
|
8882
9531
|
const taskId = String(task.id);
|
|
8883
9532
|
const taskTitle = String(task.title);
|
|
8884
9533
|
try {
|
|
8885
|
-
|
|
8886
|
-
await writeCheckpoint2({
|
|
9534
|
+
await checkpointActiveTask({
|
|
8887
9535
|
taskId,
|
|
8888
|
-
|
|
8889
|
-
|
|
9536
|
+
taskTitle,
|
|
9537
|
+
sessionId: payload.session_id,
|
|
9538
|
+
projectName
|
|
8890
9539
|
});
|
|
8891
9540
|
} catch {
|
|
8892
9541
|
}
|
|
@@ -8909,18 +9558,14 @@ ${taskLines}`);
|
|
|
8909
9558
|
if (lastCheckpoint?.files_touched?.length) {
|
|
8910
9559
|
recoveryLines.push(`Files: ${lastCheckpoint.files_touched.join(", ")}`);
|
|
8911
9560
|
}
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
|
|
8915
|
-
|
|
8916
|
-
|
|
8917
|
-
|
|
8918
|
-
|
|
8919
|
-
|
|
8920
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8921
|
-
importance: 8,
|
|
8922
|
-
task_id: taskId,
|
|
8923
|
-
memory_type: "checkpoint"
|
|
9561
|
+
await writeContinuityCheckpoint({
|
|
9562
|
+
agentId: agent.agentId,
|
|
9563
|
+
agentRole: agent.agentRole,
|
|
9564
|
+
sessionId: payload.session_id,
|
|
9565
|
+
projectName,
|
|
9566
|
+
reason: "pre-compact",
|
|
9567
|
+
taskId,
|
|
9568
|
+
extraSections: [recoveryLines.join("\n")]
|
|
8924
9569
|
});
|
|
8925
9570
|
} catch {
|
|
8926
9571
|
}
|