@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
package/dist/lib/store.js
CHANGED
|
@@ -187,6 +187,11 @@ function normalizeAutoUpdate(raw) {
|
|
|
187
187
|
const userAU = raw.autoUpdate ?? {};
|
|
188
188
|
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
189
189
|
}
|
|
190
|
+
function normalizeOrchestration(raw) {
|
|
191
|
+
const defaultOrg = DEFAULT_CONFIG.orchestration;
|
|
192
|
+
const userOrg = raw.orchestration ?? {};
|
|
193
|
+
raw.orchestration = { ...defaultOrg, ...userOrg };
|
|
194
|
+
}
|
|
190
195
|
async function loadConfig() {
|
|
191
196
|
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
192
197
|
await ensurePrivateDir(dir);
|
|
@@ -211,10 +216,15 @@ async function loadConfig() {
|
|
|
211
216
|
normalizeScalingRoadmap(migratedCfg);
|
|
212
217
|
normalizeSessionLifecycle(migratedCfg);
|
|
213
218
|
normalizeAutoUpdate(migratedCfg);
|
|
219
|
+
normalizeOrchestration(migratedCfg);
|
|
214
220
|
const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
|
|
215
221
|
if (config.dbPath.startsWith("~")) {
|
|
216
222
|
config.dbPath = config.dbPath.replace(/^~/, os.homedir());
|
|
217
223
|
}
|
|
224
|
+
const envDbPath = path.join(dir, "memories.db");
|
|
225
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync2(config.dbPath) && existsSync2(envDbPath)) {
|
|
226
|
+
config.dbPath = envDbPath;
|
|
227
|
+
}
|
|
218
228
|
return config;
|
|
219
229
|
} catch {
|
|
220
230
|
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
@@ -286,6 +296,10 @@ var init_config = __esm({
|
|
|
286
296
|
checkOnBoot: true,
|
|
287
297
|
autoInstall: false,
|
|
288
298
|
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
299
|
+
},
|
|
300
|
+
orchestration: {
|
|
301
|
+
phase: "phase_1_coo",
|
|
302
|
+
phaseSetBy: "default"
|
|
289
303
|
}
|
|
290
304
|
};
|
|
291
305
|
CONFIG_MIGRATIONS = [
|
|
@@ -1518,6 +1532,9 @@ function getClient() {
|
|
|
1518
1532
|
if (_daemonClient && _daemonClient._isDaemonActive()) {
|
|
1519
1533
|
return _daemonClient;
|
|
1520
1534
|
}
|
|
1535
|
+
if (!_resilientClient) {
|
|
1536
|
+
return _adapterClient;
|
|
1537
|
+
}
|
|
1521
1538
|
return _resilientClient;
|
|
1522
1539
|
}
|
|
1523
1540
|
async function initDaemonClient() {
|
|
@@ -2550,6 +2567,127 @@ async function ensureSchema() {
|
|
|
2550
2567
|
VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
|
|
2551
2568
|
END;
|
|
2552
2569
|
`);
|
|
2570
|
+
await client.executeMultiple(`
|
|
2571
|
+
CREATE TABLE IF NOT EXISTS agent_sessions (
|
|
2572
|
+
id TEXT PRIMARY KEY,
|
|
2573
|
+
agent_id TEXT NOT NULL,
|
|
2574
|
+
project_name TEXT,
|
|
2575
|
+
started_at TEXT NOT NULL,
|
|
2576
|
+
last_event_at TEXT NOT NULL,
|
|
2577
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
2578
|
+
properties TEXT DEFAULT '{}'
|
|
2579
|
+
);
|
|
2580
|
+
|
|
2581
|
+
CREATE INDEX IF NOT EXISTS idx_agent_sessions_agent_time
|
|
2582
|
+
ON agent_sessions(agent_id, started_at);
|
|
2583
|
+
|
|
2584
|
+
CREATE TABLE IF NOT EXISTS agent_goals (
|
|
2585
|
+
id TEXT PRIMARY KEY,
|
|
2586
|
+
statement TEXT NOT NULL,
|
|
2587
|
+
owner_agent_id TEXT,
|
|
2588
|
+
project_name TEXT,
|
|
2589
|
+
status TEXT NOT NULL DEFAULT 'open',
|
|
2590
|
+
priority INTEGER NOT NULL DEFAULT 5,
|
|
2591
|
+
success_criteria TEXT,
|
|
2592
|
+
parent_goal_id TEXT,
|
|
2593
|
+
due_at TEXT,
|
|
2594
|
+
achieved_at TEXT,
|
|
2595
|
+
supersedes_id TEXT,
|
|
2596
|
+
created_at TEXT NOT NULL,
|
|
2597
|
+
updated_at TEXT NOT NULL,
|
|
2598
|
+
source_memory_id TEXT
|
|
2599
|
+
);
|
|
2600
|
+
|
|
2601
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goals_project_status
|
|
2602
|
+
ON agent_goals(project_name, status, priority);
|
|
2603
|
+
|
|
2604
|
+
CREATE TABLE IF NOT EXISTS agent_events (
|
|
2605
|
+
id TEXT PRIMARY KEY,
|
|
2606
|
+
event_type TEXT NOT NULL,
|
|
2607
|
+
occurred_at TEXT NOT NULL,
|
|
2608
|
+
sequence_index INTEGER NOT NULL,
|
|
2609
|
+
actor_agent_id TEXT,
|
|
2610
|
+
agent_role TEXT,
|
|
2611
|
+
project_name TEXT,
|
|
2612
|
+
session_id TEXT,
|
|
2613
|
+
task_id TEXT,
|
|
2614
|
+
goal_id TEXT,
|
|
2615
|
+
parent_event_id TEXT,
|
|
2616
|
+
intention TEXT,
|
|
2617
|
+
outcome TEXT,
|
|
2618
|
+
evidence_memory_id TEXT,
|
|
2619
|
+
impact TEXT,
|
|
2620
|
+
payload TEXT DEFAULT '{}',
|
|
2621
|
+
created_at TEXT NOT NULL
|
|
2622
|
+
);
|
|
2623
|
+
|
|
2624
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_time
|
|
2625
|
+
ON agent_events(occurred_at, sequence_index);
|
|
2626
|
+
|
|
2627
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_session_seq
|
|
2628
|
+
ON agent_events(session_id, sequence_index);
|
|
2629
|
+
|
|
2630
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_goal_time
|
|
2631
|
+
ON agent_events(goal_id, occurred_at);
|
|
2632
|
+
|
|
2633
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_memory
|
|
2634
|
+
ON agent_events(evidence_memory_id);
|
|
2635
|
+
|
|
2636
|
+
CREATE TABLE IF NOT EXISTS agent_goal_links (
|
|
2637
|
+
id TEXT PRIMARY KEY,
|
|
2638
|
+
goal_id TEXT NOT NULL,
|
|
2639
|
+
link_type TEXT NOT NULL,
|
|
2640
|
+
target_id TEXT NOT NULL,
|
|
2641
|
+
target_type TEXT NOT NULL,
|
|
2642
|
+
created_at TEXT NOT NULL
|
|
2643
|
+
);
|
|
2644
|
+
|
|
2645
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goal_links_goal
|
|
2646
|
+
ON agent_goal_links(goal_id, target_type);
|
|
2647
|
+
|
|
2648
|
+
CREATE TABLE IF NOT EXISTS agent_semantic_labels (
|
|
2649
|
+
id TEXT PRIMARY KEY,
|
|
2650
|
+
source_memory_id TEXT NOT NULL,
|
|
2651
|
+
event_id TEXT,
|
|
2652
|
+
labeler TEXT NOT NULL,
|
|
2653
|
+
schema_version INTEGER NOT NULL DEFAULT 1,
|
|
2654
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
2655
|
+
labels TEXT NOT NULL,
|
|
2656
|
+
created_at TEXT NOT NULL,
|
|
2657
|
+
updated_at TEXT NOT NULL
|
|
2658
|
+
);
|
|
2659
|
+
|
|
2660
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_memory
|
|
2661
|
+
ON agent_semantic_labels(source_memory_id, labeler);
|
|
2662
|
+
|
|
2663
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_event
|
|
2664
|
+
ON agent_semantic_labels(event_id);
|
|
2665
|
+
|
|
2666
|
+
CREATE TABLE IF NOT EXISTS agent_reflection_checkpoints (
|
|
2667
|
+
id TEXT PRIMARY KEY,
|
|
2668
|
+
project_name TEXT,
|
|
2669
|
+
session_id TEXT,
|
|
2670
|
+
window_start_at TEXT NOT NULL,
|
|
2671
|
+
window_end_at TEXT NOT NULL,
|
|
2672
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
2673
|
+
goal_count INTEGER NOT NULL DEFAULT 0,
|
|
2674
|
+
success_count INTEGER NOT NULL DEFAULT 0,
|
|
2675
|
+
failure_count INTEGER NOT NULL DEFAULT 0,
|
|
2676
|
+
risk_count INTEGER NOT NULL DEFAULT 0,
|
|
2677
|
+
summary TEXT NOT NULL,
|
|
2678
|
+
learnings TEXT NOT NULL DEFAULT '[]',
|
|
2679
|
+
next_actions TEXT NOT NULL DEFAULT '[]',
|
|
2680
|
+
evidence_event_ids TEXT NOT NULL DEFAULT '[]',
|
|
2681
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
2682
|
+
created_at TEXT NOT NULL
|
|
2683
|
+
);
|
|
2684
|
+
|
|
2685
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_project_time
|
|
2686
|
+
ON agent_reflection_checkpoints(project_name, window_end_at);
|
|
2687
|
+
|
|
2688
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_session_time
|
|
2689
|
+
ON agent_reflection_checkpoints(session_id, window_end_at);
|
|
2690
|
+
`);
|
|
2553
2691
|
try {
|
|
2554
2692
|
await client.execute({
|
|
2555
2693
|
sql: `ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3`,
|
|
@@ -2713,7 +2851,7 @@ __export(shard_manager_exports, {
|
|
|
2713
2851
|
shardExists: () => shardExists
|
|
2714
2852
|
});
|
|
2715
2853
|
import path7 from "path";
|
|
2716
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as
|
|
2854
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as statSync3 } from "fs";
|
|
2717
2855
|
import { createClient as createClient2 } from "@libsql/client";
|
|
2718
2856
|
function initShardManager(encryptionKey) {
|
|
2719
2857
|
_encryptionKey = encryptionKey;
|
|
@@ -2777,7 +2915,7 @@ async function auditShardHealth(options = {}) {
|
|
|
2777
2915
|
const shards = [];
|
|
2778
2916
|
for (const name of names) {
|
|
2779
2917
|
const dbPath = path7.join(SHARDS_DIR, `${name}.db`);
|
|
2780
|
-
const stat =
|
|
2918
|
+
const stat = statSync3(dbPath);
|
|
2781
2919
|
const item = {
|
|
2782
2920
|
name,
|
|
2783
2921
|
path: dbPath,
|
|
@@ -3030,7 +3168,7 @@ async function getReadyShardClient(projectName) {
|
|
|
3030
3168
|
_shardLastAccess.delete(safeName);
|
|
3031
3169
|
const dbPath = path7.join(SHARDS_DIR, `${safeName}.db`);
|
|
3032
3170
|
if (existsSync7(dbPath)) {
|
|
3033
|
-
const stat =
|
|
3171
|
+
const stat = statSync3(dbPath);
|
|
3034
3172
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
3035
3173
|
const archivedPath = path7.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
3036
3174
|
renameSync3(dbPath, archivedPath);
|
|
@@ -3150,6 +3288,12 @@ var init_platform_procedures = __esm({
|
|
|
3150
3288
|
priority: "p0",
|
|
3151
3289
|
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."
|
|
3152
3290
|
},
|
|
3291
|
+
{
|
|
3292
|
+
title: "Customer orchestration maturity \u2014 recommend, never trap",
|
|
3293
|
+
domain: "workflow",
|
|
3294
|
+
priority: "p1",
|
|
3295
|
+
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."
|
|
3296
|
+
},
|
|
3153
3297
|
{
|
|
3154
3298
|
title: "Single dispatch path \u2014 create_task only",
|
|
3155
3299
|
domain: "workflow",
|
|
@@ -3208,6 +3352,12 @@ var init_platform_procedures = __esm({
|
|
|
3208
3352
|
priority: "p0",
|
|
3209
3353
|
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."
|
|
3210
3354
|
},
|
|
3355
|
+
{
|
|
3356
|
+
title: "Commit discipline \u2014 never leave verified work floating",
|
|
3357
|
+
domain: "workflow",
|
|
3358
|
+
priority: "p1",
|
|
3359
|
+
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."
|
|
3360
|
+
},
|
|
3211
3361
|
{
|
|
3212
3362
|
title: "Desktop and TUI are the same product",
|
|
3213
3363
|
domain: "architecture",
|
|
@@ -3525,17 +3675,286 @@ var init_memory_cards = __esm({
|
|
|
3525
3675
|
}
|
|
3526
3676
|
});
|
|
3527
3677
|
|
|
3678
|
+
// src/lib/agentic-ontology.ts
|
|
3679
|
+
var agentic_ontology_exports = {};
|
|
3680
|
+
__export(agentic_ontology_exports, {
|
|
3681
|
+
clean: () => clean,
|
|
3682
|
+
extractGoalCandidates: () => extractGoalCandidates,
|
|
3683
|
+
inferIntention: () => inferIntention,
|
|
3684
|
+
inferOntologyEventType: () => inferOntologyEventType,
|
|
3685
|
+
inferOutcome: () => inferOutcome,
|
|
3686
|
+
inferSemanticLabel: () => inferSemanticLabel,
|
|
3687
|
+
insertOntologyForBatch: () => insertOntologyForBatch,
|
|
3688
|
+
insertOntologyForMemory: () => insertOntologyForMemory,
|
|
3689
|
+
ontologyPayload: () => ontologyPayload,
|
|
3690
|
+
stableId: () => stableId2
|
|
3691
|
+
});
|
|
3692
|
+
import { createHash as createHash3 } from "crypto";
|
|
3693
|
+
function stableId2(...parts) {
|
|
3694
|
+
return createHash3("sha256").update(parts.map((p) => String(p ?? "")).join("::")).digest("hex").slice(0, 32);
|
|
3695
|
+
}
|
|
3696
|
+
function clean(text, max = 240) {
|
|
3697
|
+
return text.replace(/\u0000/g, "").replace(/```[\s\S]*?```/g, " ").replace(/\s+/g, " ").trim().slice(0, max);
|
|
3698
|
+
}
|
|
3699
|
+
function inferOntologyEventType(row) {
|
|
3700
|
+
const lower = row.raw_text.toLowerCase();
|
|
3701
|
+
if (row.has_error) return "error";
|
|
3702
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published)\b/.test(lower)) return "milestone";
|
|
3703
|
+
if (/\b(blocked|failed|error|bug|regression|broken)\b/.test(lower)) return "problem";
|
|
3704
|
+
if (/\b(decided|decision|adr|we chose|approved|rejected)\b/.test(lower)) return "decision";
|
|
3705
|
+
if (/\b(goal|need to|we need|want to|trying to|objective)\b/.test(lower)) return "goal_signal";
|
|
3706
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) return "tool_action";
|
|
3707
|
+
if (row.tool_name.startsWith("memory_card")) return "memory_card";
|
|
3708
|
+
return "memory_observation";
|
|
3709
|
+
}
|
|
3710
|
+
function inferIntention(row) {
|
|
3711
|
+
if (row.intent) return clean(row.intent, 220);
|
|
3712
|
+
const text = clean(row.raw_text, 1e3);
|
|
3713
|
+
const patterns = [
|
|
3714
|
+
/(?: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,
|
|
3715
|
+
/(?:so that|in order to)\s+([^.!?\n]{8,220})/i,
|
|
3716
|
+
/(?:task|plan):\s*([^.!?\n]{8,220})/i
|
|
3717
|
+
];
|
|
3718
|
+
for (const p of patterns) {
|
|
3719
|
+
const m = text.match(p);
|
|
3720
|
+
if (m?.[1]) return clean(m[1], 220);
|
|
3721
|
+
}
|
|
3722
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) {
|
|
3723
|
+
return `${row.tool_name} during ${row.project_name}`;
|
|
3724
|
+
}
|
|
3725
|
+
return null;
|
|
3726
|
+
}
|
|
3727
|
+
function inferOutcome(row) {
|
|
3728
|
+
if (row.outcome) return clean(row.outcome, 220);
|
|
3729
|
+
if (row.has_error) return "error";
|
|
3730
|
+
const lower = row.raw_text.toLowerCase();
|
|
3731
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published|passed)\b/.test(lower)) return "success_signal";
|
|
3732
|
+
if (/\b(blocked|failed|error|regression|broken|not working|could not)\b/.test(lower)) return "failure_signal";
|
|
3733
|
+
if (/\b(warning|risk|concern|caveat)\b/.test(lower)) return "risk_signal";
|
|
3734
|
+
return null;
|
|
3735
|
+
}
|
|
3736
|
+
function extractGoalCandidates(row) {
|
|
3737
|
+
const text = clean(row.raw_text, 1600);
|
|
3738
|
+
const patterns = [
|
|
3739
|
+
/(?: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,
|
|
3740
|
+
/(?:success means|success criteria|so that)\s+([^.!?\n]{12,220})/gi
|
|
3741
|
+
];
|
|
3742
|
+
const out = [];
|
|
3743
|
+
for (const pattern of patterns) {
|
|
3744
|
+
for (const m of text.matchAll(pattern)) {
|
|
3745
|
+
const candidate = clean(m[1] ?? "", 220);
|
|
3746
|
+
if (candidate.length >= 12 && !out.some((x) => x.toLowerCase() === candidate.toLowerCase())) out.push(candidate);
|
|
3747
|
+
if (out.length >= 3) return out;
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3750
|
+
return out;
|
|
3751
|
+
}
|
|
3752
|
+
function uniq(values, max = 6) {
|
|
3753
|
+
const out = [];
|
|
3754
|
+
for (const value of values.map((v) => clean(v, 220)).filter(Boolean)) {
|
|
3755
|
+
if (!out.some((x) => x.toLowerCase() === value.toLowerCase())) out.push(value);
|
|
3756
|
+
if (out.length >= max) break;
|
|
3757
|
+
}
|
|
3758
|
+
return out;
|
|
3759
|
+
}
|
|
3760
|
+
function extractMatches(text, patterns, max = 5) {
|
|
3761
|
+
const out = [];
|
|
3762
|
+
for (const pattern of patterns) {
|
|
3763
|
+
for (const match of text.matchAll(pattern)) {
|
|
3764
|
+
const value = match[1] ?? match[0];
|
|
3765
|
+
if (value) out.push(value);
|
|
3766
|
+
if (out.length >= max) return uniq(out, max);
|
|
3767
|
+
}
|
|
3768
|
+
}
|
|
3769
|
+
return uniq(out, max);
|
|
3770
|
+
}
|
|
3771
|
+
function inferSemanticLabel(row) {
|
|
3772
|
+
const text = clean(row.raw_text, 2400);
|
|
3773
|
+
const eventType = inferOntologyEventType(row);
|
|
3774
|
+
const intention = inferIntention(row);
|
|
3775
|
+
const outcome = inferOutcome(row);
|
|
3776
|
+
const goals = extractGoalCandidates(row);
|
|
3777
|
+
const milestones = extractMatches(text, [
|
|
3778
|
+
/\b(?:completed|finished|fixed|resolved|shipped|deployed|published|pushed|passed)\b([^.!?\n]{0,180})/gi,
|
|
3779
|
+
/(?:milestone|done):\s*([^.!?\n]{8,220})/gi
|
|
3780
|
+
]);
|
|
3781
|
+
const problems = extractMatches(text, [
|
|
3782
|
+
/\b(?:blocked by|failed because|bug|regression|broken|not working|error)\b([^.!?\n]{0,180})/gi,
|
|
3783
|
+
/(?:problem|issue|risk):\s*([^.!?\n]{8,220})/gi
|
|
3784
|
+
]);
|
|
3785
|
+
const decisions = extractMatches(text, [
|
|
3786
|
+
/(?:decided|decision|adr|we chose|approved|rejected)\s+([^.!?\n]{8,220})/gi
|
|
3787
|
+
]);
|
|
3788
|
+
const temporalAnchors = extractMatches(text, [
|
|
3789
|
+
/\b(\d{4}-\d{2}-\d{2}(?:[T ][0-9:.+-Z]+)?)\b/g,
|
|
3790
|
+
/\b(today|yesterday|tomorrow|this week|next week|last week|morning|afternoon|tonight)\b/gi
|
|
3791
|
+
], 8);
|
|
3792
|
+
const nextActions = extractMatches(text, [
|
|
3793
|
+
/(?:next|todo|follow[- ]?up|remaining|need to)\s*:?\s*([^.!?\n]{8,220})/gi
|
|
3794
|
+
]);
|
|
3795
|
+
const actors = uniq([
|
|
3796
|
+
row.agent_id,
|
|
3797
|
+
...extractMatches(text, [/\b(?:agent|employee|owner|assignee)[:= ]+([a-zA-Z][a-zA-Z0-9_-]{1,40})/gi], 5)
|
|
3798
|
+
], 6);
|
|
3799
|
+
const successSignals = milestones.length ? milestones : outcome === "success_signal" ? [clean(text, 180)] : [];
|
|
3800
|
+
const failureSignals = problems.length ? problems : outcome === "failure_signal" || row.has_error ? [clean(text, 180)] : [];
|
|
3801
|
+
const impact = successSignals.length && failureSignals.length ? "mixed" : failureSignals.length ? "negative" : successSignals.length ? "positive" : "neutral";
|
|
3802
|
+
const signalCount = goals.length + milestones.length + problems.length + decisions.length + nextActions.length;
|
|
3803
|
+
return {
|
|
3804
|
+
labeler: "deterministic",
|
|
3805
|
+
schemaVersion: 1,
|
|
3806
|
+
eventType,
|
|
3807
|
+
intention,
|
|
3808
|
+
outcome,
|
|
3809
|
+
impact,
|
|
3810
|
+
confidence: Math.min(0.95, 0.45 + signalCount * 0.08 + (intention ? 0.1 : 0) + (outcome ? 0.1 : 0)),
|
|
3811
|
+
goals,
|
|
3812
|
+
milestones,
|
|
3813
|
+
problems,
|
|
3814
|
+
decisions,
|
|
3815
|
+
actors,
|
|
3816
|
+
temporalAnchors,
|
|
3817
|
+
successSignals,
|
|
3818
|
+
failureSignals,
|
|
3819
|
+
nextActions,
|
|
3820
|
+
summary: clean(text, 280)
|
|
3821
|
+
};
|
|
3822
|
+
}
|
|
3823
|
+
function ontologyPayload(row) {
|
|
3824
|
+
const semantic = inferSemanticLabel(row);
|
|
3825
|
+
return {
|
|
3826
|
+
tool_name: row.tool_name,
|
|
3827
|
+
memory_version: row.version ?? null,
|
|
3828
|
+
domain: row.domain ?? null,
|
|
3829
|
+
trajectory: row.trajectory ? safeJson(row.trajectory) : null,
|
|
3830
|
+
semantic
|
|
3831
|
+
};
|
|
3832
|
+
}
|
|
3833
|
+
function safeJson(value) {
|
|
3834
|
+
try {
|
|
3835
|
+
return JSON.parse(value);
|
|
3836
|
+
} catch {
|
|
3837
|
+
return value.slice(0, 1e3);
|
|
3838
|
+
}
|
|
3839
|
+
}
|
|
3840
|
+
async function resolveClient(client) {
|
|
3841
|
+
if (client) return client;
|
|
3842
|
+
const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
3843
|
+
return getClient2();
|
|
3844
|
+
}
|
|
3845
|
+
async function insertOntologyForMemory(row, client) {
|
|
3846
|
+
const db = await resolveClient(client);
|
|
3847
|
+
const occurredAt = row.timestamp;
|
|
3848
|
+
const sequence = Number(row.version ?? 0) || Math.floor(new Date(occurredAt).getTime() / 1e3);
|
|
3849
|
+
const eventType = inferOntologyEventType(row);
|
|
3850
|
+
const intention = inferIntention(row);
|
|
3851
|
+
const outcome = inferOutcome(row);
|
|
3852
|
+
const eventId = stableId2("event", row.id);
|
|
3853
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3854
|
+
await db.execute({
|
|
3855
|
+
sql: `INSERT INTO agent_sessions (id, agent_id, project_name, started_at, last_event_at, event_count, properties)
|
|
3856
|
+
VALUES (?, ?, ?, ?, ?, 1, ?)
|
|
3857
|
+
ON CONFLICT(id) DO UPDATE SET last_event_at = MAX(last_event_at, excluded.last_event_at),
|
|
3858
|
+
event_count = event_count + 1`,
|
|
3859
|
+
args: [row.session_id, row.agent_id, row.project_name, occurredAt, occurredAt, JSON.stringify({ agent_role: row.agent_role })]
|
|
3860
|
+
});
|
|
3861
|
+
await db.execute({
|
|
3862
|
+
sql: `INSERT OR IGNORE INTO agent_events
|
|
3863
|
+
(id, event_type, occurred_at, sequence_index, actor_agent_id, agent_role, project_name,
|
|
3864
|
+
session_id, task_id, goal_id, parent_event_id, intention, outcome, evidence_memory_id,
|
|
3865
|
+
impact, payload, created_at)
|
|
3866
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, ?, ?, ?, ?, ?, ?)`,
|
|
3867
|
+
args: [
|
|
3868
|
+
eventId,
|
|
3869
|
+
eventType,
|
|
3870
|
+
occurredAt,
|
|
3871
|
+
sequence,
|
|
3872
|
+
row.agent_id,
|
|
3873
|
+
row.agent_role,
|
|
3874
|
+
row.project_name,
|
|
3875
|
+
row.session_id,
|
|
3876
|
+
row.task_id ?? null,
|
|
3877
|
+
intention,
|
|
3878
|
+
outcome,
|
|
3879
|
+
row.id,
|
|
3880
|
+
row.has_error ? "negative" : outcome === "success_signal" ? "positive" : "neutral",
|
|
3881
|
+
JSON.stringify(ontologyPayload(row)),
|
|
3882
|
+
now
|
|
3883
|
+
]
|
|
3884
|
+
});
|
|
3885
|
+
const semantic = inferSemanticLabel(row);
|
|
3886
|
+
await db.execute({
|
|
3887
|
+
sql: `INSERT INTO agent_semantic_labels
|
|
3888
|
+
(id, source_memory_id, event_id, labeler, schema_version, confidence, labels, created_at, updated_at)
|
|
3889
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
3890
|
+
ON CONFLICT(id) DO UPDATE SET confidence = excluded.confidence,
|
|
3891
|
+
labels = excluded.labels, updated_at = excluded.updated_at`,
|
|
3892
|
+
args: [
|
|
3893
|
+
stableId2("semantic", row.id, semantic.labeler, semantic.schemaVersion),
|
|
3894
|
+
row.id,
|
|
3895
|
+
eventId,
|
|
3896
|
+
semantic.labeler,
|
|
3897
|
+
semantic.schemaVersion,
|
|
3898
|
+
semantic.confidence,
|
|
3899
|
+
JSON.stringify(semantic),
|
|
3900
|
+
now,
|
|
3901
|
+
now
|
|
3902
|
+
]
|
|
3903
|
+
});
|
|
3904
|
+
for (const statement of extractGoalCandidates(row)) {
|
|
3905
|
+
const goalId = stableId2("goal", row.project_name, statement.toLowerCase());
|
|
3906
|
+
await db.execute({
|
|
3907
|
+
sql: `INSERT INTO agent_goals
|
|
3908
|
+
(id, statement, owner_agent_id, project_name, status, priority, success_criteria,
|
|
3909
|
+
parent_goal_id, due_at, achieved_at, supersedes_id, created_at, updated_at, source_memory_id)
|
|
3910
|
+
VALUES (?, ?, ?, ?, 'open', 5, NULL, NULL, NULL, NULL, NULL, ?, ?, ?)
|
|
3911
|
+
ON CONFLICT(id) DO UPDATE SET updated_at = excluded.updated_at`,
|
|
3912
|
+
args: [goalId, statement, row.agent_id, row.project_name, now, now, row.id]
|
|
3913
|
+
});
|
|
3914
|
+
await db.execute({
|
|
3915
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
3916
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
3917
|
+
VALUES (?, ?, 'evidence', ?, 'memory', ?)`,
|
|
3918
|
+
args: [stableId2("goal_link", goalId, row.id, "memory"), goalId, row.id, now]
|
|
3919
|
+
});
|
|
3920
|
+
await db.execute({
|
|
3921
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
3922
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
3923
|
+
VALUES (?, ?, 'event', ?, 'event', ?)`,
|
|
3924
|
+
args: [stableId2("goal_link", goalId, eventId, "event"), goalId, eventId, now]
|
|
3925
|
+
});
|
|
3926
|
+
}
|
|
3927
|
+
}
|
|
3928
|
+
async function insertOntologyForBatch(rows, client) {
|
|
3929
|
+
const db = await resolveClient(client);
|
|
3930
|
+
let count = 0;
|
|
3931
|
+
for (const row of rows) {
|
|
3932
|
+
try {
|
|
3933
|
+
await insertOntologyForMemory(row, db);
|
|
3934
|
+
count++;
|
|
3935
|
+
} catch {
|
|
3936
|
+
}
|
|
3937
|
+
}
|
|
3938
|
+
return count;
|
|
3939
|
+
}
|
|
3940
|
+
var init_agentic_ontology = __esm({
|
|
3941
|
+
"src/lib/agentic-ontology.ts"() {
|
|
3942
|
+
"use strict";
|
|
3943
|
+
}
|
|
3944
|
+
});
|
|
3945
|
+
|
|
3528
3946
|
// src/lib/store.ts
|
|
3529
3947
|
init_memory();
|
|
3530
3948
|
init_database();
|
|
3531
3949
|
|
|
3532
3950
|
// src/lib/keychain.ts
|
|
3533
3951
|
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
3534
|
-
import { existsSync as existsSync6 } from "fs";
|
|
3952
|
+
import { existsSync as existsSync6, statSync as statSync2 } from "fs";
|
|
3535
3953
|
import { execSync as execSync2 } from "child_process";
|
|
3536
3954
|
import path6 from "path";
|
|
3537
3955
|
import os5 from "os";
|
|
3538
|
-
var SERVICE = "exe-
|
|
3956
|
+
var SERVICE = "exe-os";
|
|
3957
|
+
var LEGACY_SERVICE = "exe-mem";
|
|
3539
3958
|
var ACCOUNT = "master-key";
|
|
3540
3959
|
function getKeyDir() {
|
|
3541
3960
|
return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path6.join(os5.homedir(), ".exe-os");
|
|
@@ -3543,29 +3962,79 @@ function getKeyDir() {
|
|
|
3543
3962
|
function getKeyPath() {
|
|
3544
3963
|
return path6.join(getKeyDir(), "master.key");
|
|
3545
3964
|
}
|
|
3546
|
-
function
|
|
3965
|
+
function nativeKeychainAllowed() {
|
|
3966
|
+
return process.env.EXE_OS_DISABLE_NATIVE_KEYCHAIN !== "1";
|
|
3967
|
+
}
|
|
3968
|
+
var linuxSecretAvailability = null;
|
|
3969
|
+
function linuxSecretAvailable() {
|
|
3970
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3971
|
+
if (process.platform !== "linux") return false;
|
|
3972
|
+
if (linuxSecretAvailability !== null) return linuxSecretAvailability;
|
|
3973
|
+
try {
|
|
3974
|
+
execSync2("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
|
|
3975
|
+
} catch {
|
|
3976
|
+
linuxSecretAvailability = false;
|
|
3977
|
+
return false;
|
|
3978
|
+
}
|
|
3979
|
+
try {
|
|
3980
|
+
execSync2("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
|
|
3981
|
+
linuxSecretAvailability = true;
|
|
3982
|
+
} catch {
|
|
3983
|
+
linuxSecretAvailability = false;
|
|
3984
|
+
}
|
|
3985
|
+
return linuxSecretAvailability;
|
|
3986
|
+
}
|
|
3987
|
+
function isRootOnlyTrustedServerKeyFile(keyPath) {
|
|
3988
|
+
if (process.platform !== "linux") return false;
|
|
3989
|
+
try {
|
|
3990
|
+
const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
|
|
3991
|
+
const st = statSync2(keyPath);
|
|
3992
|
+
if (!st.isFile() || (st.mode & 63) !== 0) return false;
|
|
3993
|
+
if (uid === 0) return true;
|
|
3994
|
+
const exeOsDir = process.env.EXE_OS_DIR;
|
|
3995
|
+
return Boolean(exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep));
|
|
3996
|
+
} catch {
|
|
3997
|
+
return false;
|
|
3998
|
+
}
|
|
3999
|
+
}
|
|
4000
|
+
function macKeychainGet(service = SERVICE) {
|
|
4001
|
+
if (!nativeKeychainAllowed()) return null;
|
|
3547
4002
|
if (process.platform !== "darwin") return null;
|
|
3548
4003
|
try {
|
|
3549
4004
|
return execSync2(
|
|
3550
|
-
`security find-generic-password -s "${
|
|
4005
|
+
`security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
|
|
3551
4006
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
3552
4007
|
).trim();
|
|
3553
4008
|
} catch {
|
|
3554
4009
|
return null;
|
|
3555
4010
|
}
|
|
3556
4011
|
}
|
|
3557
|
-
function macKeychainSet(value) {
|
|
4012
|
+
function macKeychainSet(value, service = SERVICE) {
|
|
4013
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3558
4014
|
if (process.platform !== "darwin") return false;
|
|
3559
4015
|
try {
|
|
3560
4016
|
try {
|
|
3561
4017
|
execSync2(
|
|
3562
|
-
`security delete-generic-password -s "${
|
|
4018
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
3563
4019
|
{ timeout: 5e3 }
|
|
3564
4020
|
);
|
|
3565
4021
|
} catch {
|
|
3566
4022
|
}
|
|
3567
4023
|
execSync2(
|
|
3568
|
-
`security add-generic-password -s "${
|
|
4024
|
+
`security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
|
|
4025
|
+
{ timeout: 5e3 }
|
|
4026
|
+
);
|
|
4027
|
+
return true;
|
|
4028
|
+
} catch {
|
|
4029
|
+
return false;
|
|
4030
|
+
}
|
|
4031
|
+
}
|
|
4032
|
+
function macKeychainDelete(service = SERVICE) {
|
|
4033
|
+
if (!nativeKeychainAllowed()) return false;
|
|
4034
|
+
if (process.platform !== "darwin") return false;
|
|
4035
|
+
try {
|
|
4036
|
+
execSync2(
|
|
4037
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
3569
4038
|
{ timeout: 5e3 }
|
|
3570
4039
|
);
|
|
3571
4040
|
return true;
|
|
@@ -3573,22 +4042,35 @@ function macKeychainSet(value) {
|
|
|
3573
4042
|
return false;
|
|
3574
4043
|
}
|
|
3575
4044
|
}
|
|
3576
|
-
function linuxSecretGet() {
|
|
3577
|
-
if (
|
|
4045
|
+
function linuxSecretGet(service = SERVICE) {
|
|
4046
|
+
if (!linuxSecretAvailable()) return null;
|
|
3578
4047
|
try {
|
|
3579
4048
|
return execSync2(
|
|
3580
|
-
`secret-tool lookup service "${
|
|
4049
|
+
`secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3581
4050
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
3582
4051
|
).trim();
|
|
3583
4052
|
} catch {
|
|
3584
4053
|
return null;
|
|
3585
4054
|
}
|
|
3586
4055
|
}
|
|
3587
|
-
function linuxSecretSet(value) {
|
|
4056
|
+
function linuxSecretSet(value, service = SERVICE) {
|
|
4057
|
+
if (!linuxSecretAvailable()) return false;
|
|
4058
|
+
try {
|
|
4059
|
+
execSync2(
|
|
4060
|
+
`echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
4061
|
+
{ timeout: 5e3 }
|
|
4062
|
+
);
|
|
4063
|
+
return true;
|
|
4064
|
+
} catch {
|
|
4065
|
+
return false;
|
|
4066
|
+
}
|
|
4067
|
+
}
|
|
4068
|
+
function linuxSecretDelete(service = SERVICE) {
|
|
4069
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3588
4070
|
if (process.platform !== "linux") return false;
|
|
3589
4071
|
try {
|
|
3590
4072
|
execSync2(
|
|
3591
|
-
`
|
|
4073
|
+
`secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3592
4074
|
{ timeout: 5e3 }
|
|
3593
4075
|
);
|
|
3594
4076
|
return true;
|
|
@@ -3597,6 +4079,7 @@ function linuxSecretSet(value) {
|
|
|
3597
4079
|
}
|
|
3598
4080
|
}
|
|
3599
4081
|
async function tryKeytar() {
|
|
4082
|
+
if (!nativeKeychainAllowed()) return null;
|
|
3600
4083
|
try {
|
|
3601
4084
|
return await import("keytar");
|
|
3602
4085
|
} catch {
|
|
@@ -3671,7 +4154,19 @@ async function writeMachineBoundFileFallback(b64) {
|
|
|
3671
4154
|
return "plaintext";
|
|
3672
4155
|
}
|
|
3673
4156
|
async function getMasterKey() {
|
|
3674
|
-
|
|
4157
|
+
let nativeValue = macKeychainGet() ?? linuxSecretGet();
|
|
4158
|
+
if (!nativeValue) {
|
|
4159
|
+
const legacyValue = macKeychainGet(LEGACY_SERVICE) ?? linuxSecretGet(LEGACY_SERVICE);
|
|
4160
|
+
if (legacyValue) {
|
|
4161
|
+
const migrated = macKeychainSet(legacyValue) || linuxSecretSet(legacyValue);
|
|
4162
|
+
if (migrated) {
|
|
4163
|
+
macKeychainDelete(LEGACY_SERVICE);
|
|
4164
|
+
linuxSecretDelete(LEGACY_SERVICE);
|
|
4165
|
+
process.stderr.write("[keychain] Migrated keychain service from exe-mem to exe-os.\n");
|
|
4166
|
+
}
|
|
4167
|
+
nativeValue = legacyValue;
|
|
4168
|
+
}
|
|
4169
|
+
}
|
|
3675
4170
|
if (nativeValue) {
|
|
3676
4171
|
return Buffer.from(nativeValue, "base64");
|
|
3677
4172
|
}
|
|
@@ -3679,12 +4174,17 @@ async function getMasterKey() {
|
|
|
3679
4174
|
if (keytar) {
|
|
3680
4175
|
try {
|
|
3681
4176
|
const keytarValue = await keytar.getPassword(SERVICE, ACCOUNT);
|
|
3682
|
-
|
|
3683
|
-
|
|
4177
|
+
const legacyKeytarValue = keytarValue ?? await keytar.getPassword(LEGACY_SERVICE, ACCOUNT);
|
|
4178
|
+
if (legacyKeytarValue) {
|
|
4179
|
+
const migrated = macKeychainSet(legacyKeytarValue) || linuxSecretSet(legacyKeytarValue);
|
|
3684
4180
|
if (migrated) {
|
|
3685
4181
|
process.stderr.write("[keychain] Migrated key from keytar to native keychain.\n");
|
|
4182
|
+
try {
|
|
4183
|
+
await keytar.deletePassword(LEGACY_SERVICE, ACCOUNT);
|
|
4184
|
+
} catch {
|
|
4185
|
+
}
|
|
3686
4186
|
}
|
|
3687
|
-
return Buffer.from(
|
|
4187
|
+
return Buffer.from(legacyKeytarValue, "base64");
|
|
3688
4188
|
}
|
|
3689
4189
|
} catch {
|
|
3690
4190
|
}
|
|
@@ -3709,7 +4209,7 @@ async function getMasterKey() {
|
|
|
3709
4209
|
const decrypted = decryptWithMachineKey(content, machineKey);
|
|
3710
4210
|
if (!decrypted) {
|
|
3711
4211
|
process.stderr.write(
|
|
3712
|
-
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase: exe-os
|
|
4212
|
+
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase during setup: exe-os setup\n"
|
|
3713
4213
|
);
|
|
3714
4214
|
return null;
|
|
3715
4215
|
}
|
|
@@ -3718,6 +4218,9 @@ async function getMasterKey() {
|
|
|
3718
4218
|
b64Value = content;
|
|
3719
4219
|
}
|
|
3720
4220
|
const key = Buffer.from(b64Value, "base64");
|
|
4221
|
+
if (!content.startsWith(ENCRYPTED_PREFIX) && isRootOnlyTrustedServerKeyFile(keyPath)) {
|
|
4222
|
+
return key;
|
|
4223
|
+
}
|
|
3721
4224
|
const migrated = macKeychainSet(b64Value) || linuxSecretSet(b64Value);
|
|
3722
4225
|
if (migrated) {
|
|
3723
4226
|
process.stderr.write("[keychain] Migrated key from file to native keychain.\n");
|
|
@@ -4320,6 +4823,11 @@ async function flushBatch() {
|
|
|
4320
4823
|
await insertMemoryCardsForBatch2(batch);
|
|
4321
4824
|
} catch {
|
|
4322
4825
|
}
|
|
4826
|
+
try {
|
|
4827
|
+
const { insertOntologyForBatch: insertOntologyForBatch2 } = await Promise.resolve().then(() => (init_agentic_ontology(), agentic_ontology_exports));
|
|
4828
|
+
await insertOntologyForBatch2(batch);
|
|
4829
|
+
} catch {
|
|
4830
|
+
}
|
|
4323
4831
|
schedulePostWriteMemoryHygiene(batch.map((row) => row.id));
|
|
4324
4832
|
_pendingRecords.splice(0, batch.length);
|
|
4325
4833
|
try {
|