@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
|
@@ -214,6 +214,11 @@ function normalizeAutoUpdate(raw) {
|
|
|
214
214
|
const userAU = raw.autoUpdate ?? {};
|
|
215
215
|
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
216
216
|
}
|
|
217
|
+
function normalizeOrchestration(raw) {
|
|
218
|
+
const defaultOrg = DEFAULT_CONFIG.orchestration;
|
|
219
|
+
const userOrg = raw.orchestration ?? {};
|
|
220
|
+
raw.orchestration = { ...defaultOrg, ...userOrg };
|
|
221
|
+
}
|
|
217
222
|
async function loadConfig() {
|
|
218
223
|
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
219
224
|
await ensurePrivateDir(dir);
|
|
@@ -238,10 +243,15 @@ async function loadConfig() {
|
|
|
238
243
|
normalizeScalingRoadmap(migratedCfg);
|
|
239
244
|
normalizeSessionLifecycle(migratedCfg);
|
|
240
245
|
normalizeAutoUpdate(migratedCfg);
|
|
246
|
+
normalizeOrchestration(migratedCfg);
|
|
241
247
|
const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
|
|
242
248
|
if (config.dbPath.startsWith("~")) {
|
|
243
249
|
config.dbPath = config.dbPath.replace(/^~/, os.homedir());
|
|
244
250
|
}
|
|
251
|
+
const envDbPath = path.join(dir, "memories.db");
|
|
252
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync2(config.dbPath) && existsSync2(envDbPath)) {
|
|
253
|
+
config.dbPath = envDbPath;
|
|
254
|
+
}
|
|
245
255
|
return config;
|
|
246
256
|
} catch {
|
|
247
257
|
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
@@ -261,7 +271,16 @@ function loadConfigSync() {
|
|
|
261
271
|
normalizeScalingRoadmap(migratedCfg);
|
|
262
272
|
normalizeSessionLifecycle(migratedCfg);
|
|
263
273
|
normalizeAutoUpdate(migratedCfg);
|
|
264
|
-
|
|
274
|
+
normalizeOrchestration(migratedCfg);
|
|
275
|
+
const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
|
|
276
|
+
if (config.dbPath.startsWith("~")) {
|
|
277
|
+
config.dbPath = config.dbPath.replace(/^~/, os.homedir());
|
|
278
|
+
}
|
|
279
|
+
const envDbPath = path.join(dir, "memories.db");
|
|
280
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync2(config.dbPath) && existsSync2(envDbPath)) {
|
|
281
|
+
config.dbPath = envDbPath;
|
|
282
|
+
}
|
|
283
|
+
return config;
|
|
265
284
|
} catch {
|
|
266
285
|
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
267
286
|
}
|
|
@@ -282,6 +301,7 @@ async function loadConfigFrom(configPath) {
|
|
|
282
301
|
normalizeScalingRoadmap(migratedCfg);
|
|
283
302
|
normalizeSessionLifecycle(migratedCfg);
|
|
284
303
|
normalizeAutoUpdate(migratedCfg);
|
|
304
|
+
normalizeOrchestration(migratedCfg);
|
|
285
305
|
return { ...DEFAULT_CONFIG, ...migratedCfg };
|
|
286
306
|
} catch {
|
|
287
307
|
return { ...DEFAULT_CONFIG };
|
|
@@ -353,6 +373,10 @@ var init_config = __esm({
|
|
|
353
373
|
checkOnBoot: true,
|
|
354
374
|
autoInstall: false,
|
|
355
375
|
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
376
|
+
},
|
|
377
|
+
orchestration: {
|
|
378
|
+
phase: "phase_1_coo",
|
|
379
|
+
phaseSetBy: "default"
|
|
356
380
|
}
|
|
357
381
|
};
|
|
358
382
|
CONFIG_MIGRATIONS = [
|
|
@@ -1596,6 +1620,9 @@ function getClient() {
|
|
|
1596
1620
|
if (_daemonClient && _daemonClient._isDaemonActive()) {
|
|
1597
1621
|
return _daemonClient;
|
|
1598
1622
|
}
|
|
1623
|
+
if (!_resilientClient) {
|
|
1624
|
+
return _adapterClient;
|
|
1625
|
+
}
|
|
1599
1626
|
return _resilientClient;
|
|
1600
1627
|
}
|
|
1601
1628
|
async function initDaemonClient() {
|
|
@@ -2628,6 +2655,127 @@ async function ensureSchema() {
|
|
|
2628
2655
|
VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
|
|
2629
2656
|
END;
|
|
2630
2657
|
`);
|
|
2658
|
+
await client.executeMultiple(`
|
|
2659
|
+
CREATE TABLE IF NOT EXISTS agent_sessions (
|
|
2660
|
+
id TEXT PRIMARY KEY,
|
|
2661
|
+
agent_id TEXT NOT NULL,
|
|
2662
|
+
project_name TEXT,
|
|
2663
|
+
started_at TEXT NOT NULL,
|
|
2664
|
+
last_event_at TEXT NOT NULL,
|
|
2665
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
2666
|
+
properties TEXT DEFAULT '{}'
|
|
2667
|
+
);
|
|
2668
|
+
|
|
2669
|
+
CREATE INDEX IF NOT EXISTS idx_agent_sessions_agent_time
|
|
2670
|
+
ON agent_sessions(agent_id, started_at);
|
|
2671
|
+
|
|
2672
|
+
CREATE TABLE IF NOT EXISTS agent_goals (
|
|
2673
|
+
id TEXT PRIMARY KEY,
|
|
2674
|
+
statement TEXT NOT NULL,
|
|
2675
|
+
owner_agent_id TEXT,
|
|
2676
|
+
project_name TEXT,
|
|
2677
|
+
status TEXT NOT NULL DEFAULT 'open',
|
|
2678
|
+
priority INTEGER NOT NULL DEFAULT 5,
|
|
2679
|
+
success_criteria TEXT,
|
|
2680
|
+
parent_goal_id TEXT,
|
|
2681
|
+
due_at TEXT,
|
|
2682
|
+
achieved_at TEXT,
|
|
2683
|
+
supersedes_id TEXT,
|
|
2684
|
+
created_at TEXT NOT NULL,
|
|
2685
|
+
updated_at TEXT NOT NULL,
|
|
2686
|
+
source_memory_id TEXT
|
|
2687
|
+
);
|
|
2688
|
+
|
|
2689
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goals_project_status
|
|
2690
|
+
ON agent_goals(project_name, status, priority);
|
|
2691
|
+
|
|
2692
|
+
CREATE TABLE IF NOT EXISTS agent_events (
|
|
2693
|
+
id TEXT PRIMARY KEY,
|
|
2694
|
+
event_type TEXT NOT NULL,
|
|
2695
|
+
occurred_at TEXT NOT NULL,
|
|
2696
|
+
sequence_index INTEGER NOT NULL,
|
|
2697
|
+
actor_agent_id TEXT,
|
|
2698
|
+
agent_role TEXT,
|
|
2699
|
+
project_name TEXT,
|
|
2700
|
+
session_id TEXT,
|
|
2701
|
+
task_id TEXT,
|
|
2702
|
+
goal_id TEXT,
|
|
2703
|
+
parent_event_id TEXT,
|
|
2704
|
+
intention TEXT,
|
|
2705
|
+
outcome TEXT,
|
|
2706
|
+
evidence_memory_id TEXT,
|
|
2707
|
+
impact TEXT,
|
|
2708
|
+
payload TEXT DEFAULT '{}',
|
|
2709
|
+
created_at TEXT NOT NULL
|
|
2710
|
+
);
|
|
2711
|
+
|
|
2712
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_time
|
|
2713
|
+
ON agent_events(occurred_at, sequence_index);
|
|
2714
|
+
|
|
2715
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_session_seq
|
|
2716
|
+
ON agent_events(session_id, sequence_index);
|
|
2717
|
+
|
|
2718
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_goal_time
|
|
2719
|
+
ON agent_events(goal_id, occurred_at);
|
|
2720
|
+
|
|
2721
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_memory
|
|
2722
|
+
ON agent_events(evidence_memory_id);
|
|
2723
|
+
|
|
2724
|
+
CREATE TABLE IF NOT EXISTS agent_goal_links (
|
|
2725
|
+
id TEXT PRIMARY KEY,
|
|
2726
|
+
goal_id TEXT NOT NULL,
|
|
2727
|
+
link_type TEXT NOT NULL,
|
|
2728
|
+
target_id TEXT NOT NULL,
|
|
2729
|
+
target_type TEXT NOT NULL,
|
|
2730
|
+
created_at TEXT NOT NULL
|
|
2731
|
+
);
|
|
2732
|
+
|
|
2733
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goal_links_goal
|
|
2734
|
+
ON agent_goal_links(goal_id, target_type);
|
|
2735
|
+
|
|
2736
|
+
CREATE TABLE IF NOT EXISTS agent_semantic_labels (
|
|
2737
|
+
id TEXT PRIMARY KEY,
|
|
2738
|
+
source_memory_id TEXT NOT NULL,
|
|
2739
|
+
event_id TEXT,
|
|
2740
|
+
labeler TEXT NOT NULL,
|
|
2741
|
+
schema_version INTEGER NOT NULL DEFAULT 1,
|
|
2742
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
2743
|
+
labels TEXT NOT NULL,
|
|
2744
|
+
created_at TEXT NOT NULL,
|
|
2745
|
+
updated_at TEXT NOT NULL
|
|
2746
|
+
);
|
|
2747
|
+
|
|
2748
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_memory
|
|
2749
|
+
ON agent_semantic_labels(source_memory_id, labeler);
|
|
2750
|
+
|
|
2751
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_event
|
|
2752
|
+
ON agent_semantic_labels(event_id);
|
|
2753
|
+
|
|
2754
|
+
CREATE TABLE IF NOT EXISTS agent_reflection_checkpoints (
|
|
2755
|
+
id TEXT PRIMARY KEY,
|
|
2756
|
+
project_name TEXT,
|
|
2757
|
+
session_id TEXT,
|
|
2758
|
+
window_start_at TEXT NOT NULL,
|
|
2759
|
+
window_end_at TEXT NOT NULL,
|
|
2760
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
2761
|
+
goal_count INTEGER NOT NULL DEFAULT 0,
|
|
2762
|
+
success_count INTEGER NOT NULL DEFAULT 0,
|
|
2763
|
+
failure_count INTEGER NOT NULL DEFAULT 0,
|
|
2764
|
+
risk_count INTEGER NOT NULL DEFAULT 0,
|
|
2765
|
+
summary TEXT NOT NULL,
|
|
2766
|
+
learnings TEXT NOT NULL DEFAULT '[]',
|
|
2767
|
+
next_actions TEXT NOT NULL DEFAULT '[]',
|
|
2768
|
+
evidence_event_ids TEXT NOT NULL DEFAULT '[]',
|
|
2769
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
2770
|
+
created_at TEXT NOT NULL
|
|
2771
|
+
);
|
|
2772
|
+
|
|
2773
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_project_time
|
|
2774
|
+
ON agent_reflection_checkpoints(project_name, window_end_at);
|
|
2775
|
+
|
|
2776
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_session_time
|
|
2777
|
+
ON agent_reflection_checkpoints(session_id, window_end_at);
|
|
2778
|
+
`);
|
|
2631
2779
|
try {
|
|
2632
2780
|
await client.execute({
|
|
2633
2781
|
sql: `ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3`,
|
|
@@ -2791,7 +2939,7 @@ __export(shard_manager_exports, {
|
|
|
2791
2939
|
shardExists: () => shardExists
|
|
2792
2940
|
});
|
|
2793
2941
|
import path7 from "path";
|
|
2794
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as
|
|
2942
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as statSync3 } from "fs";
|
|
2795
2943
|
import { createClient as createClient2 } from "@libsql/client";
|
|
2796
2944
|
function initShardManager(encryptionKey) {
|
|
2797
2945
|
_encryptionKey = encryptionKey;
|
|
@@ -2855,7 +3003,7 @@ async function auditShardHealth(options = {}) {
|
|
|
2855
3003
|
const shards = [];
|
|
2856
3004
|
for (const name of names) {
|
|
2857
3005
|
const dbPath = path7.join(SHARDS_DIR, `${name}.db`);
|
|
2858
|
-
const stat =
|
|
3006
|
+
const stat = statSync3(dbPath);
|
|
2859
3007
|
const item = {
|
|
2860
3008
|
name,
|
|
2861
3009
|
path: dbPath,
|
|
@@ -3108,7 +3256,7 @@ async function getReadyShardClient(projectName) {
|
|
|
3108
3256
|
_shardLastAccess.delete(safeName);
|
|
3109
3257
|
const dbPath = path7.join(SHARDS_DIR, `${safeName}.db`);
|
|
3110
3258
|
if (existsSync7(dbPath)) {
|
|
3111
|
-
const stat =
|
|
3259
|
+
const stat = statSync3(dbPath);
|
|
3112
3260
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
3113
3261
|
const archivedPath = path7.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
3114
3262
|
renameSync3(dbPath, archivedPath);
|
|
@@ -3228,6 +3376,12 @@ var init_platform_procedures = __esm({
|
|
|
3228
3376
|
priority: "p0",
|
|
3229
3377
|
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."
|
|
3230
3378
|
},
|
|
3379
|
+
{
|
|
3380
|
+
title: "Customer orchestration maturity \u2014 recommend, never trap",
|
|
3381
|
+
domain: "workflow",
|
|
3382
|
+
priority: "p1",
|
|
3383
|
+
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."
|
|
3384
|
+
},
|
|
3231
3385
|
{
|
|
3232
3386
|
title: "Single dispatch path \u2014 create_task only",
|
|
3233
3387
|
domain: "workflow",
|
|
@@ -3286,6 +3440,12 @@ var init_platform_procedures = __esm({
|
|
|
3286
3440
|
priority: "p0",
|
|
3287
3441
|
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."
|
|
3288
3442
|
},
|
|
3443
|
+
{
|
|
3444
|
+
title: "Commit discipline \u2014 never leave verified work floating",
|
|
3445
|
+
domain: "workflow",
|
|
3446
|
+
priority: "p1",
|
|
3447
|
+
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."
|
|
3448
|
+
},
|
|
3289
3449
|
{
|
|
3290
3450
|
title: "Desktop and TUI are the same product",
|
|
3291
3451
|
domain: "architecture",
|
|
@@ -3603,6 +3763,274 @@ var init_memory_cards = __esm({
|
|
|
3603
3763
|
}
|
|
3604
3764
|
});
|
|
3605
3765
|
|
|
3766
|
+
// src/lib/agentic-ontology.ts
|
|
3767
|
+
var agentic_ontology_exports = {};
|
|
3768
|
+
__export(agentic_ontology_exports, {
|
|
3769
|
+
clean: () => clean,
|
|
3770
|
+
extractGoalCandidates: () => extractGoalCandidates,
|
|
3771
|
+
inferIntention: () => inferIntention,
|
|
3772
|
+
inferOntologyEventType: () => inferOntologyEventType,
|
|
3773
|
+
inferOutcome: () => inferOutcome,
|
|
3774
|
+
inferSemanticLabel: () => inferSemanticLabel,
|
|
3775
|
+
insertOntologyForBatch: () => insertOntologyForBatch,
|
|
3776
|
+
insertOntologyForMemory: () => insertOntologyForMemory,
|
|
3777
|
+
ontologyPayload: () => ontologyPayload,
|
|
3778
|
+
stableId: () => stableId2
|
|
3779
|
+
});
|
|
3780
|
+
import { createHash as createHash3 } from "crypto";
|
|
3781
|
+
function stableId2(...parts) {
|
|
3782
|
+
return createHash3("sha256").update(parts.map((p) => String(p ?? "")).join("::")).digest("hex").slice(0, 32);
|
|
3783
|
+
}
|
|
3784
|
+
function clean(text, max = 240) {
|
|
3785
|
+
return text.replace(/\u0000/g, "").replace(/```[\s\S]*?```/g, " ").replace(/\s+/g, " ").trim().slice(0, max);
|
|
3786
|
+
}
|
|
3787
|
+
function inferOntologyEventType(row) {
|
|
3788
|
+
const lower = row.raw_text.toLowerCase();
|
|
3789
|
+
if (row.has_error) return "error";
|
|
3790
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published)\b/.test(lower)) return "milestone";
|
|
3791
|
+
if (/\b(blocked|failed|error|bug|regression|broken)\b/.test(lower)) return "problem";
|
|
3792
|
+
if (/\b(decided|decision|adr|we chose|approved|rejected)\b/.test(lower)) return "decision";
|
|
3793
|
+
if (/\b(goal|need to|we need|want to|trying to|objective)\b/.test(lower)) return "goal_signal";
|
|
3794
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) return "tool_action";
|
|
3795
|
+
if (row.tool_name.startsWith("memory_card")) return "memory_card";
|
|
3796
|
+
return "memory_observation";
|
|
3797
|
+
}
|
|
3798
|
+
function inferIntention(row) {
|
|
3799
|
+
if (row.intent) return clean(row.intent, 220);
|
|
3800
|
+
const text = clean(row.raw_text, 1e3);
|
|
3801
|
+
const patterns = [
|
|
3802
|
+
/(?: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,
|
|
3803
|
+
/(?:so that|in order to)\s+([^.!?\n]{8,220})/i,
|
|
3804
|
+
/(?:task|plan):\s*([^.!?\n]{8,220})/i
|
|
3805
|
+
];
|
|
3806
|
+
for (const p of patterns) {
|
|
3807
|
+
const m = text.match(p);
|
|
3808
|
+
if (m?.[1]) return clean(m[1], 220);
|
|
3809
|
+
}
|
|
3810
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) {
|
|
3811
|
+
return `${row.tool_name} during ${row.project_name}`;
|
|
3812
|
+
}
|
|
3813
|
+
return null;
|
|
3814
|
+
}
|
|
3815
|
+
function inferOutcome(row) {
|
|
3816
|
+
if (row.outcome) return clean(row.outcome, 220);
|
|
3817
|
+
if (row.has_error) return "error";
|
|
3818
|
+
const lower = row.raw_text.toLowerCase();
|
|
3819
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published|passed)\b/.test(lower)) return "success_signal";
|
|
3820
|
+
if (/\b(blocked|failed|error|regression|broken|not working|could not)\b/.test(lower)) return "failure_signal";
|
|
3821
|
+
if (/\b(warning|risk|concern|caveat)\b/.test(lower)) return "risk_signal";
|
|
3822
|
+
return null;
|
|
3823
|
+
}
|
|
3824
|
+
function extractGoalCandidates(row) {
|
|
3825
|
+
const text = clean(row.raw_text, 1600);
|
|
3826
|
+
const patterns = [
|
|
3827
|
+
/(?: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,
|
|
3828
|
+
/(?:success means|success criteria|so that)\s+([^.!?\n]{12,220})/gi
|
|
3829
|
+
];
|
|
3830
|
+
const out = [];
|
|
3831
|
+
for (const pattern of patterns) {
|
|
3832
|
+
for (const m of text.matchAll(pattern)) {
|
|
3833
|
+
const candidate = clean(m[1] ?? "", 220);
|
|
3834
|
+
if (candidate.length >= 12 && !out.some((x) => x.toLowerCase() === candidate.toLowerCase())) out.push(candidate);
|
|
3835
|
+
if (out.length >= 3) return out;
|
|
3836
|
+
}
|
|
3837
|
+
}
|
|
3838
|
+
return out;
|
|
3839
|
+
}
|
|
3840
|
+
function uniq(values, max = 6) {
|
|
3841
|
+
const out = [];
|
|
3842
|
+
for (const value of values.map((v) => clean(v, 220)).filter(Boolean)) {
|
|
3843
|
+
if (!out.some((x) => x.toLowerCase() === value.toLowerCase())) out.push(value);
|
|
3844
|
+
if (out.length >= max) break;
|
|
3845
|
+
}
|
|
3846
|
+
return out;
|
|
3847
|
+
}
|
|
3848
|
+
function extractMatches(text, patterns, max = 5) {
|
|
3849
|
+
const out = [];
|
|
3850
|
+
for (const pattern of patterns) {
|
|
3851
|
+
for (const match of text.matchAll(pattern)) {
|
|
3852
|
+
const value = match[1] ?? match[0];
|
|
3853
|
+
if (value) out.push(value);
|
|
3854
|
+
if (out.length >= max) return uniq(out, max);
|
|
3855
|
+
}
|
|
3856
|
+
}
|
|
3857
|
+
return uniq(out, max);
|
|
3858
|
+
}
|
|
3859
|
+
function inferSemanticLabel(row) {
|
|
3860
|
+
const text = clean(row.raw_text, 2400);
|
|
3861
|
+
const eventType = inferOntologyEventType(row);
|
|
3862
|
+
const intention = inferIntention(row);
|
|
3863
|
+
const outcome = inferOutcome(row);
|
|
3864
|
+
const goals = extractGoalCandidates(row);
|
|
3865
|
+
const milestones = extractMatches(text, [
|
|
3866
|
+
/\b(?:completed|finished|fixed|resolved|shipped|deployed|published|pushed|passed)\b([^.!?\n]{0,180})/gi,
|
|
3867
|
+
/(?:milestone|done):\s*([^.!?\n]{8,220})/gi
|
|
3868
|
+
]);
|
|
3869
|
+
const problems = extractMatches(text, [
|
|
3870
|
+
/\b(?:blocked by|failed because|bug|regression|broken|not working|error)\b([^.!?\n]{0,180})/gi,
|
|
3871
|
+
/(?:problem|issue|risk):\s*([^.!?\n]{8,220})/gi
|
|
3872
|
+
]);
|
|
3873
|
+
const decisions = extractMatches(text, [
|
|
3874
|
+
/(?:decided|decision|adr|we chose|approved|rejected)\s+([^.!?\n]{8,220})/gi
|
|
3875
|
+
]);
|
|
3876
|
+
const temporalAnchors = extractMatches(text, [
|
|
3877
|
+
/\b(\d{4}-\d{2}-\d{2}(?:[T ][0-9:.+-Z]+)?)\b/g,
|
|
3878
|
+
/\b(today|yesterday|tomorrow|this week|next week|last week|morning|afternoon|tonight)\b/gi
|
|
3879
|
+
], 8);
|
|
3880
|
+
const nextActions = extractMatches(text, [
|
|
3881
|
+
/(?:next|todo|follow[- ]?up|remaining|need to)\s*:?\s*([^.!?\n]{8,220})/gi
|
|
3882
|
+
]);
|
|
3883
|
+
const actors = uniq([
|
|
3884
|
+
row.agent_id,
|
|
3885
|
+
...extractMatches(text, [/\b(?:agent|employee|owner|assignee)[:= ]+([a-zA-Z][a-zA-Z0-9_-]{1,40})/gi], 5)
|
|
3886
|
+
], 6);
|
|
3887
|
+
const successSignals = milestones.length ? milestones : outcome === "success_signal" ? [clean(text, 180)] : [];
|
|
3888
|
+
const failureSignals = problems.length ? problems : outcome === "failure_signal" || row.has_error ? [clean(text, 180)] : [];
|
|
3889
|
+
const impact = successSignals.length && failureSignals.length ? "mixed" : failureSignals.length ? "negative" : successSignals.length ? "positive" : "neutral";
|
|
3890
|
+
const signalCount = goals.length + milestones.length + problems.length + decisions.length + nextActions.length;
|
|
3891
|
+
return {
|
|
3892
|
+
labeler: "deterministic",
|
|
3893
|
+
schemaVersion: 1,
|
|
3894
|
+
eventType,
|
|
3895
|
+
intention,
|
|
3896
|
+
outcome,
|
|
3897
|
+
impact,
|
|
3898
|
+
confidence: Math.min(0.95, 0.45 + signalCount * 0.08 + (intention ? 0.1 : 0) + (outcome ? 0.1 : 0)),
|
|
3899
|
+
goals,
|
|
3900
|
+
milestones,
|
|
3901
|
+
problems,
|
|
3902
|
+
decisions,
|
|
3903
|
+
actors,
|
|
3904
|
+
temporalAnchors,
|
|
3905
|
+
successSignals,
|
|
3906
|
+
failureSignals,
|
|
3907
|
+
nextActions,
|
|
3908
|
+
summary: clean(text, 280)
|
|
3909
|
+
};
|
|
3910
|
+
}
|
|
3911
|
+
function ontologyPayload(row) {
|
|
3912
|
+
const semantic = inferSemanticLabel(row);
|
|
3913
|
+
return {
|
|
3914
|
+
tool_name: row.tool_name,
|
|
3915
|
+
memory_version: row.version ?? null,
|
|
3916
|
+
domain: row.domain ?? null,
|
|
3917
|
+
trajectory: row.trajectory ? safeJson(row.trajectory) : null,
|
|
3918
|
+
semantic
|
|
3919
|
+
};
|
|
3920
|
+
}
|
|
3921
|
+
function safeJson(value) {
|
|
3922
|
+
try {
|
|
3923
|
+
return JSON.parse(value);
|
|
3924
|
+
} catch {
|
|
3925
|
+
return value.slice(0, 1e3);
|
|
3926
|
+
}
|
|
3927
|
+
}
|
|
3928
|
+
async function resolveClient(client) {
|
|
3929
|
+
if (client) return client;
|
|
3930
|
+
const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
3931
|
+
return getClient2();
|
|
3932
|
+
}
|
|
3933
|
+
async function insertOntologyForMemory(row, client) {
|
|
3934
|
+
const db = await resolveClient(client);
|
|
3935
|
+
const occurredAt = row.timestamp;
|
|
3936
|
+
const sequence = Number(row.version ?? 0) || Math.floor(new Date(occurredAt).getTime() / 1e3);
|
|
3937
|
+
const eventType = inferOntologyEventType(row);
|
|
3938
|
+
const intention = inferIntention(row);
|
|
3939
|
+
const outcome = inferOutcome(row);
|
|
3940
|
+
const eventId = stableId2("event", row.id);
|
|
3941
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3942
|
+
await db.execute({
|
|
3943
|
+
sql: `INSERT INTO agent_sessions (id, agent_id, project_name, started_at, last_event_at, event_count, properties)
|
|
3944
|
+
VALUES (?, ?, ?, ?, ?, 1, ?)
|
|
3945
|
+
ON CONFLICT(id) DO UPDATE SET last_event_at = MAX(last_event_at, excluded.last_event_at),
|
|
3946
|
+
event_count = event_count + 1`,
|
|
3947
|
+
args: [row.session_id, row.agent_id, row.project_name, occurredAt, occurredAt, JSON.stringify({ agent_role: row.agent_role })]
|
|
3948
|
+
});
|
|
3949
|
+
await db.execute({
|
|
3950
|
+
sql: `INSERT OR IGNORE INTO agent_events
|
|
3951
|
+
(id, event_type, occurred_at, sequence_index, actor_agent_id, agent_role, project_name,
|
|
3952
|
+
session_id, task_id, goal_id, parent_event_id, intention, outcome, evidence_memory_id,
|
|
3953
|
+
impact, payload, created_at)
|
|
3954
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, ?, ?, ?, ?, ?, ?)`,
|
|
3955
|
+
args: [
|
|
3956
|
+
eventId,
|
|
3957
|
+
eventType,
|
|
3958
|
+
occurredAt,
|
|
3959
|
+
sequence,
|
|
3960
|
+
row.agent_id,
|
|
3961
|
+
row.agent_role,
|
|
3962
|
+
row.project_name,
|
|
3963
|
+
row.session_id,
|
|
3964
|
+
row.task_id ?? null,
|
|
3965
|
+
intention,
|
|
3966
|
+
outcome,
|
|
3967
|
+
row.id,
|
|
3968
|
+
row.has_error ? "negative" : outcome === "success_signal" ? "positive" : "neutral",
|
|
3969
|
+
JSON.stringify(ontologyPayload(row)),
|
|
3970
|
+
now
|
|
3971
|
+
]
|
|
3972
|
+
});
|
|
3973
|
+
const semantic = inferSemanticLabel(row);
|
|
3974
|
+
await db.execute({
|
|
3975
|
+
sql: `INSERT INTO agent_semantic_labels
|
|
3976
|
+
(id, source_memory_id, event_id, labeler, schema_version, confidence, labels, created_at, updated_at)
|
|
3977
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
3978
|
+
ON CONFLICT(id) DO UPDATE SET confidence = excluded.confidence,
|
|
3979
|
+
labels = excluded.labels, updated_at = excluded.updated_at`,
|
|
3980
|
+
args: [
|
|
3981
|
+
stableId2("semantic", row.id, semantic.labeler, semantic.schemaVersion),
|
|
3982
|
+
row.id,
|
|
3983
|
+
eventId,
|
|
3984
|
+
semantic.labeler,
|
|
3985
|
+
semantic.schemaVersion,
|
|
3986
|
+
semantic.confidence,
|
|
3987
|
+
JSON.stringify(semantic),
|
|
3988
|
+
now,
|
|
3989
|
+
now
|
|
3990
|
+
]
|
|
3991
|
+
});
|
|
3992
|
+
for (const statement of extractGoalCandidates(row)) {
|
|
3993
|
+
const goalId = stableId2("goal", row.project_name, statement.toLowerCase());
|
|
3994
|
+
await db.execute({
|
|
3995
|
+
sql: `INSERT INTO agent_goals
|
|
3996
|
+
(id, statement, owner_agent_id, project_name, status, priority, success_criteria,
|
|
3997
|
+
parent_goal_id, due_at, achieved_at, supersedes_id, created_at, updated_at, source_memory_id)
|
|
3998
|
+
VALUES (?, ?, ?, ?, 'open', 5, NULL, NULL, NULL, NULL, NULL, ?, ?, ?)
|
|
3999
|
+
ON CONFLICT(id) DO UPDATE SET updated_at = excluded.updated_at`,
|
|
4000
|
+
args: [goalId, statement, row.agent_id, row.project_name, now, now, row.id]
|
|
4001
|
+
});
|
|
4002
|
+
await db.execute({
|
|
4003
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
4004
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
4005
|
+
VALUES (?, ?, 'evidence', ?, 'memory', ?)`,
|
|
4006
|
+
args: [stableId2("goal_link", goalId, row.id, "memory"), goalId, row.id, now]
|
|
4007
|
+
});
|
|
4008
|
+
await db.execute({
|
|
4009
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
4010
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
4011
|
+
VALUES (?, ?, 'event', ?, 'event', ?)`,
|
|
4012
|
+
args: [stableId2("goal_link", goalId, eventId, "event"), goalId, eventId, now]
|
|
4013
|
+
});
|
|
4014
|
+
}
|
|
4015
|
+
}
|
|
4016
|
+
async function insertOntologyForBatch(rows, client) {
|
|
4017
|
+
const db = await resolveClient(client);
|
|
4018
|
+
let count = 0;
|
|
4019
|
+
for (const row of rows) {
|
|
4020
|
+
try {
|
|
4021
|
+
await insertOntologyForMemory(row, db);
|
|
4022
|
+
count++;
|
|
4023
|
+
} catch {
|
|
4024
|
+
}
|
|
4025
|
+
}
|
|
4026
|
+
return count;
|
|
4027
|
+
}
|
|
4028
|
+
var init_agentic_ontology = __esm({
|
|
4029
|
+
"src/lib/agentic-ontology.ts"() {
|
|
4030
|
+
"use strict";
|
|
4031
|
+
}
|
|
4032
|
+
});
|
|
4033
|
+
|
|
3606
4034
|
// src/lib/runtime-table.ts
|
|
3607
4035
|
var RUNTIME_TABLE;
|
|
3608
4036
|
var init_runtime_table = __esm({
|
|
@@ -3930,11 +4358,61 @@ var init_preferences = __esm({
|
|
|
3930
4358
|
}
|
|
3931
4359
|
});
|
|
3932
4360
|
|
|
4361
|
+
// src/adapters/mcp-http-config.ts
|
|
4362
|
+
import { chmodSync as chmodSync2, existsSync as existsSync11, mkdirSync as mkdirSync6, readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "fs";
|
|
4363
|
+
import { randomBytes } from "crypto";
|
|
4364
|
+
import path12 from "path";
|
|
4365
|
+
import os9 from "os";
|
|
4366
|
+
function mcpHttpPort() {
|
|
4367
|
+
return process.env.EXE_MCP_PORT || DEFAULT_MCP_HTTP_PORT;
|
|
4368
|
+
}
|
|
4369
|
+
function mcpHttpUrl() {
|
|
4370
|
+
return `http://127.0.0.1:${mcpHttpPort()}/mcp`;
|
|
4371
|
+
}
|
|
4372
|
+
function readOrCreateDaemonToken(homeDir = os9.homedir()) {
|
|
4373
|
+
const exeDir = path12.join(homeDir, ".exe-os");
|
|
4374
|
+
const tokenPath = path12.join(exeDir, "exed.token");
|
|
4375
|
+
if (existsSync11(tokenPath)) {
|
|
4376
|
+
try {
|
|
4377
|
+
const token2 = readFileSync7(tokenPath, "utf-8").trim();
|
|
4378
|
+
if (/^[a-f0-9]{64}$/i.test(token2)) return token2;
|
|
4379
|
+
} catch {
|
|
4380
|
+
}
|
|
4381
|
+
}
|
|
4382
|
+
const token = randomBytes(32).toString("hex");
|
|
4383
|
+
mkdirSync6(exeDir, { recursive: true });
|
|
4384
|
+
writeFileSync6(tokenPath, `${token}
|
|
4385
|
+
`, "utf-8");
|
|
4386
|
+
try {
|
|
4387
|
+
chmodSync2(tokenPath, 384);
|
|
4388
|
+
} catch {
|
|
4389
|
+
}
|
|
4390
|
+
return token;
|
|
4391
|
+
}
|
|
4392
|
+
function buildMcpHttpHeaders(homeDir = os9.homedir(), opts = {}) {
|
|
4393
|
+
const agentId = opts.useShellPlaceholders ? "${AGENT_ID:-exe}" : opts.agentId ?? DEFAULT_MCP_HTTP_AGENT_ID;
|
|
4394
|
+
const agentRole = opts.useShellPlaceholders ? "${AGENT_ROLE:-COO}" : opts.agentRole ?? DEFAULT_MCP_HTTP_AGENT_ROLE;
|
|
4395
|
+
return {
|
|
4396
|
+
Authorization: `Bearer ${readOrCreateDaemonToken(homeDir)}`,
|
|
4397
|
+
"X-Agent-Id": agentId,
|
|
4398
|
+
"X-Agent-Role": agentRole
|
|
4399
|
+
};
|
|
4400
|
+
}
|
|
4401
|
+
var DEFAULT_MCP_HTTP_PORT, DEFAULT_MCP_HTTP_AGENT_ID, DEFAULT_MCP_HTTP_AGENT_ROLE;
|
|
4402
|
+
var init_mcp_http_config = __esm({
|
|
4403
|
+
"src/adapters/mcp-http-config.ts"() {
|
|
4404
|
+
"use strict";
|
|
4405
|
+
DEFAULT_MCP_HTTP_PORT = "48739";
|
|
4406
|
+
DEFAULT_MCP_HTTP_AGENT_ID = "exe";
|
|
4407
|
+
DEFAULT_MCP_HTTP_AGENT_ROLE = "COO";
|
|
4408
|
+
}
|
|
4409
|
+
});
|
|
4410
|
+
|
|
3933
4411
|
// src/adapters/runtime-hook-manifest.ts
|
|
3934
4412
|
function textHasLegacySplitPostToolHook(text) {
|
|
3935
4413
|
return [EXE_HOOK_FILES.ingest, EXE_HOOK_FILES.errorRecall, EXE_HOOK_FILES.ingestWorker].some((file) => text.includes(file));
|
|
3936
4414
|
}
|
|
3937
|
-
var EXE_HOOK_FILES;
|
|
4415
|
+
var EXE_HOOK_FILES, EXE_HOOKS, EXE_HOOK_MANIFEST;
|
|
3938
4416
|
var init_runtime_hook_manifest = __esm({
|
|
3939
4417
|
"src/adapters/runtime-hook-manifest.ts"() {
|
|
3940
4418
|
"use strict";
|
|
@@ -3944,33 +4422,157 @@ var init_runtime_hook_manifest = __esm({
|
|
|
3944
4422
|
errorRecall: "error-recall.js",
|
|
3945
4423
|
ingestWorker: "ingest-worker.js"
|
|
3946
4424
|
};
|
|
4425
|
+
EXE_HOOKS = {
|
|
4426
|
+
postToolCombined: "dist/hooks/post-tool-combined.js",
|
|
4427
|
+
sessionStart: "dist/hooks/session-start.js",
|
|
4428
|
+
promptSubmit: "dist/hooks/prompt-submit.js",
|
|
4429
|
+
heartbeat: "dist/hooks/exe-heartbeat-hook.js",
|
|
4430
|
+
stop: "dist/hooks/stop.js",
|
|
4431
|
+
preToolUse: "dist/hooks/pre-tool-use.js",
|
|
4432
|
+
subagentStop: "dist/hooks/subagent-stop.js",
|
|
4433
|
+
preCompact: "dist/hooks/pre-compact.js",
|
|
4434
|
+
postCompact: "dist/hooks/post-compact.js",
|
|
4435
|
+
sessionEnd: "dist/hooks/session-end.js",
|
|
4436
|
+
notification: "dist/hooks/notification.js",
|
|
4437
|
+
instructionsLoaded: "dist/hooks/instructions-loaded.js"
|
|
4438
|
+
};
|
|
4439
|
+
EXE_HOOK_MANIFEST = [
|
|
4440
|
+
{
|
|
4441
|
+
key: "postToolCombined",
|
|
4442
|
+
event: "PostToolUse",
|
|
4443
|
+
commandMarker: EXE_HOOKS.postToolCombined,
|
|
4444
|
+
owner: "exe-os",
|
|
4445
|
+
purpose: "Single PostToolUse entrypoint for ingestion, error recall, summaries, and bug detection.",
|
|
4446
|
+
runtimes: ["claude", "codex", "opencode"],
|
|
4447
|
+
checkpointRole: "none"
|
|
4448
|
+
},
|
|
4449
|
+
{
|
|
4450
|
+
key: "sessionStart",
|
|
4451
|
+
event: "SessionStart",
|
|
4452
|
+
commandMarker: EXE_HOOKS.sessionStart,
|
|
4453
|
+
owner: "exe-os",
|
|
4454
|
+
purpose: "Loads agent identity, procedures, and boot context.",
|
|
4455
|
+
runtimes: ["claude", "codex", "opencode"],
|
|
4456
|
+
checkpointRole: "none"
|
|
4457
|
+
},
|
|
4458
|
+
{
|
|
4459
|
+
key: "promptSubmit",
|
|
4460
|
+
event: "UserPromptSubmit",
|
|
4461
|
+
commandMarker: EXE_HOOKS.promptSubmit,
|
|
4462
|
+
owner: "exe-os",
|
|
4463
|
+
purpose: "Injects current tasks, pending reviews, and local context before each prompt.",
|
|
4464
|
+
runtimes: ["claude", "codex", "opencode"],
|
|
4465
|
+
checkpointRole: "none"
|
|
4466
|
+
},
|
|
4467
|
+
{
|
|
4468
|
+
key: "heartbeat",
|
|
4469
|
+
event: "UserPromptSubmit",
|
|
4470
|
+
commandMarker: EXE_HOOKS.heartbeat,
|
|
4471
|
+
owner: "exe-os",
|
|
4472
|
+
purpose: "Lightweight heartbeat/status sidecar for Claude Code sessions.",
|
|
4473
|
+
runtimes: ["claude"],
|
|
4474
|
+
checkpointRole: "none"
|
|
4475
|
+
},
|
|
4476
|
+
{
|
|
4477
|
+
key: "stop",
|
|
4478
|
+
event: "Stop",
|
|
4479
|
+
commandMarker: EXE_HOOKS.stop,
|
|
4480
|
+
owner: "exe-os",
|
|
4481
|
+
purpose: "Finalizes task state, capacity signals, and emergency checkpointing.",
|
|
4482
|
+
runtimes: ["claude", "codex", "opencode"],
|
|
4483
|
+
checkpointRole: "capacity_checkpoint"
|
|
4484
|
+
},
|
|
4485
|
+
{
|
|
4486
|
+
key: "preToolUse",
|
|
4487
|
+
event: "PreToolUse",
|
|
4488
|
+
commandMarker: EXE_HOOKS.preToolUse,
|
|
4489
|
+
owner: "exe-os",
|
|
4490
|
+
purpose: "Preflight guardrails before shell/tool execution.",
|
|
4491
|
+
runtimes: ["claude", "codex", "opencode"],
|
|
4492
|
+
checkpointRole: "none"
|
|
4493
|
+
},
|
|
4494
|
+
{
|
|
4495
|
+
key: "subagentStop",
|
|
4496
|
+
event: "SubagentStop",
|
|
4497
|
+
commandMarker: EXE_HOOKS.subagentStop,
|
|
4498
|
+
owner: "exe-os",
|
|
4499
|
+
purpose: "Captures subagent completion context.",
|
|
4500
|
+
runtimes: ["claude"],
|
|
4501
|
+
checkpointRole: "none"
|
|
4502
|
+
},
|
|
4503
|
+
{
|
|
4504
|
+
key: "preCompact",
|
|
4505
|
+
event: "PreCompact",
|
|
4506
|
+
commandMarker: EXE_HOOKS.preCompact,
|
|
4507
|
+
owner: "exe-os",
|
|
4508
|
+
purpose: "Writes active-task snapshot and compaction recovery context.",
|
|
4509
|
+
runtimes: ["claude"],
|
|
4510
|
+
checkpointRole: "recovery_context"
|
|
4511
|
+
},
|
|
4512
|
+
{
|
|
4513
|
+
key: "postCompact",
|
|
4514
|
+
event: "PostCompact",
|
|
4515
|
+
commandMarker: EXE_HOOKS.postCompact,
|
|
4516
|
+
owner: "exe-os",
|
|
4517
|
+
purpose: "Rehydrates recovery context after compaction.",
|
|
4518
|
+
runtimes: ["claude"],
|
|
4519
|
+
checkpointRole: "recovery_context"
|
|
4520
|
+
},
|
|
4521
|
+
{
|
|
4522
|
+
key: "sessionEnd",
|
|
4523
|
+
event: "SessionEnd",
|
|
4524
|
+
commandMarker: EXE_HOOKS.sessionEnd,
|
|
4525
|
+
owner: "exe-os",
|
|
4526
|
+
purpose: "Stores session-end checkpoint and triages orphaned in-progress tasks.",
|
|
4527
|
+
runtimes: ["claude"],
|
|
4528
|
+
checkpointRole: "session_summary"
|
|
4529
|
+
},
|
|
4530
|
+
{
|
|
4531
|
+
key: "notification",
|
|
4532
|
+
event: "Notification",
|
|
4533
|
+
commandMarker: EXE_HOOKS.notification,
|
|
4534
|
+
owner: "exe-os",
|
|
4535
|
+
purpose: "Captures runtime notifications and nudges.",
|
|
4536
|
+
runtimes: ["claude"],
|
|
4537
|
+
checkpointRole: "none"
|
|
4538
|
+
},
|
|
4539
|
+
{
|
|
4540
|
+
key: "instructionsLoaded",
|
|
4541
|
+
event: "InstructionsLoaded",
|
|
4542
|
+
commandMarker: EXE_HOOKS.instructionsLoaded,
|
|
4543
|
+
owner: "exe-os",
|
|
4544
|
+
purpose: "Applies runtime instruction post-processing.",
|
|
4545
|
+
runtimes: ["claude"],
|
|
4546
|
+
checkpointRole: "none"
|
|
4547
|
+
}
|
|
4548
|
+
];
|
|
3947
4549
|
}
|
|
3948
4550
|
});
|
|
3949
4551
|
|
|
3950
4552
|
// src/adapters/claude/installer.ts
|
|
3951
|
-
import { readFile as readFile4, writeFile as writeFile4, mkdir as mkdir4, readdir } from "fs/promises";
|
|
3952
|
-
import { existsSync as
|
|
3953
|
-
import { createHash as
|
|
3954
|
-
import
|
|
3955
|
-
import
|
|
4553
|
+
import { readFile as readFile4, writeFile as writeFile4, mkdir as mkdir4, readdir, rm } from "fs/promises";
|
|
4554
|
+
import { existsSync as existsSync12, readFileSync as readFileSync8, writeFileSync as writeFileSync7, copyFileSync, mkdirSync as mkdirSync7 } from "fs";
|
|
4555
|
+
import { createHash as createHash4 } from "crypto";
|
|
4556
|
+
import path13 from "path";
|
|
4557
|
+
import os10 from "os";
|
|
3956
4558
|
import { execSync as execSync5 } from "child_process";
|
|
3957
4559
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
3958
4560
|
function resolvePackageRoot() {
|
|
3959
4561
|
const thisFile = fileURLToPath2(import.meta.url);
|
|
3960
|
-
let dir =
|
|
3961
|
-
const root =
|
|
4562
|
+
let dir = path13.dirname(thisFile);
|
|
4563
|
+
const root = path13.parse(dir).root;
|
|
3962
4564
|
while (dir !== root) {
|
|
3963
|
-
const pkgPath =
|
|
3964
|
-
if (
|
|
4565
|
+
const pkgPath = path13.join(dir, "package.json");
|
|
4566
|
+
if (existsSync12(pkgPath)) {
|
|
3965
4567
|
try {
|
|
3966
|
-
const pkg = JSON.parse(
|
|
4568
|
+
const pkg = JSON.parse(readFileSync8(pkgPath, "utf-8"));
|
|
3967
4569
|
if (pkg.name === "@askexenow/exe-os" || pkg.name === "exe-os") return dir;
|
|
3968
4570
|
} catch {
|
|
3969
4571
|
}
|
|
3970
4572
|
}
|
|
3971
|
-
dir =
|
|
4573
|
+
dir = path13.dirname(dir);
|
|
3972
4574
|
}
|
|
3973
|
-
return
|
|
4575
|
+
return path13.resolve(path13.dirname(thisFile), "..", "..", "..");
|
|
3974
4576
|
}
|
|
3975
4577
|
var EXE_SECTION_START, EXE_SECTION_END, ORCHESTRATION_RULES;
|
|
3976
4578
|
var init_installer = __esm({
|
|
@@ -3979,6 +4581,7 @@ var init_installer = __esm({
|
|
|
3979
4581
|
init_agent_symlinks();
|
|
3980
4582
|
init_mcp_prefix();
|
|
3981
4583
|
init_preferences();
|
|
4584
|
+
init_mcp_http_config();
|
|
3982
4585
|
init_runtime_hook_manifest();
|
|
3983
4586
|
EXE_SECTION_START = "<!-- exe-os:orchestration-start -->";
|
|
3984
4587
|
EXE_SECTION_END = "<!-- exe-os:orchestration-end -->";
|
|
@@ -4189,15 +4792,16 @@ __export(installer_exports, {
|
|
|
4189
4792
|
verifyOpenCodeHooks: () => verifyOpenCodeHooks
|
|
4190
4793
|
});
|
|
4191
4794
|
import { readFile as readFile5, writeFile as writeFile5, mkdir as mkdir5 } from "fs/promises";
|
|
4192
|
-
import { existsSync as
|
|
4193
|
-
import
|
|
4194
|
-
import
|
|
4195
|
-
async function registerOpenCodeMcp(packageRoot, homeDir =
|
|
4196
|
-
|
|
4197
|
-
const
|
|
4795
|
+
import { existsSync as existsSync13, readFileSync as readFileSync9 } from "fs";
|
|
4796
|
+
import path14 from "path";
|
|
4797
|
+
import os11 from "os";
|
|
4798
|
+
async function registerOpenCodeMcp(packageRoot, homeDir = os11.homedir()) {
|
|
4799
|
+
void packageRoot;
|
|
4800
|
+
const configDir = path14.join(homeDir, ".config", "opencode");
|
|
4801
|
+
const configPath = path14.join(configDir, "opencode.json");
|
|
4198
4802
|
await mkdir5(configDir, { recursive: true });
|
|
4199
4803
|
let config = {};
|
|
4200
|
-
if (
|
|
4804
|
+
if (existsSync13(configPath)) {
|
|
4201
4805
|
try {
|
|
4202
4806
|
config = JSON.parse(await readFile5(configPath, "utf-8"));
|
|
4203
4807
|
} catch {
|
|
@@ -4208,8 +4812,9 @@ async function registerOpenCodeMcp(packageRoot, homeDir = os10.homedir()) {
|
|
|
4208
4812
|
config.mcp = {};
|
|
4209
4813
|
}
|
|
4210
4814
|
const newEntry = {
|
|
4211
|
-
type: "
|
|
4212
|
-
|
|
4815
|
+
type: "remote",
|
|
4816
|
+
url: mcpHttpUrl(),
|
|
4817
|
+
headers: buildMcpHttpHeaders(homeDir),
|
|
4213
4818
|
enabled: true
|
|
4214
4819
|
};
|
|
4215
4820
|
const current = config.mcp["exe-os"];
|
|
@@ -4223,15 +4828,15 @@ async function registerOpenCodeMcp(packageRoot, homeDir = os10.homedir()) {
|
|
|
4223
4828
|
await writeFile5(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
4224
4829
|
return true;
|
|
4225
4830
|
}
|
|
4226
|
-
async function installOpenCodePlugin(packageRoot, homeDir =
|
|
4227
|
-
const pluginDir =
|
|
4228
|
-
const pluginPath =
|
|
4831
|
+
async function installOpenCodePlugin(packageRoot, homeDir = os11.homedir()) {
|
|
4832
|
+
const pluginDir = path14.join(homeDir, ".config", "opencode", "plugins");
|
|
4833
|
+
const pluginPath = path14.join(pluginDir, "exe-os.mjs");
|
|
4229
4834
|
await mkdir5(pluginDir, { recursive: true });
|
|
4230
4835
|
const pluginContent = PLUGIN_TEMPLATE.replace(
|
|
4231
4836
|
/__PACKAGE_ROOT__/g,
|
|
4232
4837
|
packageRoot.replace(/\\/g, "\\\\")
|
|
4233
4838
|
);
|
|
4234
|
-
if (
|
|
4839
|
+
if (existsSync13(pluginPath)) {
|
|
4235
4840
|
const existing = await readFile5(pluginPath, "utf-8");
|
|
4236
4841
|
if (existing === pluginContent) {
|
|
4237
4842
|
return false;
|
|
@@ -4240,19 +4845,19 @@ async function installOpenCodePlugin(packageRoot, homeDir = os10.homedir()) {
|
|
|
4240
4845
|
await writeFile5(pluginPath, pluginContent);
|
|
4241
4846
|
return true;
|
|
4242
4847
|
}
|
|
4243
|
-
function verifyOpenCodeHooks(homeDir =
|
|
4244
|
-
const configPath =
|
|
4245
|
-
const pluginPath =
|
|
4246
|
-
if (!
|
|
4848
|
+
function verifyOpenCodeHooks(homeDir = os11.homedir()) {
|
|
4849
|
+
const configPath = path14.join(homeDir, ".config", "opencode", "opencode.json");
|
|
4850
|
+
const pluginPath = path14.join(homeDir, ".config", "opencode", "plugins", "exe-os.mjs");
|
|
4851
|
+
if (!existsSync13(configPath)) return false;
|
|
4247
4852
|
try {
|
|
4248
|
-
const config = JSON.parse(
|
|
4853
|
+
const config = JSON.parse(readFileSync9(configPath, "utf-8"));
|
|
4249
4854
|
if (!config.mcp?.["exe-os"]?.enabled) return false;
|
|
4250
4855
|
} catch {
|
|
4251
4856
|
return false;
|
|
4252
4857
|
}
|
|
4253
|
-
if (!
|
|
4858
|
+
if (!existsSync13(pluginPath)) return false;
|
|
4254
4859
|
try {
|
|
4255
|
-
const plugin =
|
|
4860
|
+
const plugin = readFileSync9(pluginPath, "utf-8");
|
|
4256
4861
|
if (!plugin.includes(EXE_HOOK_FILES.postToolCombined)) return false;
|
|
4257
4862
|
if (textHasLegacySplitPostToolHook(plugin)) return false;
|
|
4258
4863
|
} catch {
|
|
@@ -4279,17 +4884,18 @@ var init_installer2 = __esm({
|
|
|
4279
4884
|
init_installer();
|
|
4280
4885
|
init_plugin_template();
|
|
4281
4886
|
init_runtime_hook_manifest();
|
|
4887
|
+
init_mcp_http_config();
|
|
4282
4888
|
}
|
|
4283
4889
|
});
|
|
4284
4890
|
|
|
4285
4891
|
// src/bin/exe-start-opencode.ts
|
|
4286
|
-
import
|
|
4287
|
-
import
|
|
4892
|
+
import os12 from "os";
|
|
4893
|
+
import path15 from "path";
|
|
4288
4894
|
import {
|
|
4289
|
-
existsSync as
|
|
4290
|
-
readFileSync as
|
|
4291
|
-
writeFileSync as
|
|
4292
|
-
mkdirSync as
|
|
4895
|
+
existsSync as existsSync14,
|
|
4896
|
+
readFileSync as readFileSync10,
|
|
4897
|
+
writeFileSync as writeFileSync8,
|
|
4898
|
+
mkdirSync as mkdirSync8,
|
|
4293
4899
|
readdirSync as readdirSync4
|
|
4294
4900
|
} from "fs";
|
|
4295
4901
|
import { spawnSync } from "child_process";
|
|
@@ -4300,11 +4906,12 @@ init_database();
|
|
|
4300
4906
|
|
|
4301
4907
|
// src/lib/keychain.ts
|
|
4302
4908
|
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
4303
|
-
import { existsSync as existsSync6 } from "fs";
|
|
4909
|
+
import { existsSync as existsSync6, statSync as statSync2 } from "fs";
|
|
4304
4910
|
import { execSync as execSync2 } from "child_process";
|
|
4305
4911
|
import path6 from "path";
|
|
4306
4912
|
import os5 from "os";
|
|
4307
|
-
var SERVICE = "exe-
|
|
4913
|
+
var SERVICE = "exe-os";
|
|
4914
|
+
var LEGACY_SERVICE = "exe-mem";
|
|
4308
4915
|
var ACCOUNT = "master-key";
|
|
4309
4916
|
function getKeyDir() {
|
|
4310
4917
|
return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path6.join(os5.homedir(), ".exe-os");
|
|
@@ -4312,29 +4919,79 @@ function getKeyDir() {
|
|
|
4312
4919
|
function getKeyPath() {
|
|
4313
4920
|
return path6.join(getKeyDir(), "master.key");
|
|
4314
4921
|
}
|
|
4315
|
-
function
|
|
4922
|
+
function nativeKeychainAllowed() {
|
|
4923
|
+
return process.env.EXE_OS_DISABLE_NATIVE_KEYCHAIN !== "1";
|
|
4924
|
+
}
|
|
4925
|
+
var linuxSecretAvailability = null;
|
|
4926
|
+
function linuxSecretAvailable() {
|
|
4927
|
+
if (!nativeKeychainAllowed()) return false;
|
|
4928
|
+
if (process.platform !== "linux") return false;
|
|
4929
|
+
if (linuxSecretAvailability !== null) return linuxSecretAvailability;
|
|
4930
|
+
try {
|
|
4931
|
+
execSync2("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
|
|
4932
|
+
} catch {
|
|
4933
|
+
linuxSecretAvailability = false;
|
|
4934
|
+
return false;
|
|
4935
|
+
}
|
|
4936
|
+
try {
|
|
4937
|
+
execSync2("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
|
|
4938
|
+
linuxSecretAvailability = true;
|
|
4939
|
+
} catch {
|
|
4940
|
+
linuxSecretAvailability = false;
|
|
4941
|
+
}
|
|
4942
|
+
return linuxSecretAvailability;
|
|
4943
|
+
}
|
|
4944
|
+
function isRootOnlyTrustedServerKeyFile(keyPath) {
|
|
4945
|
+
if (process.platform !== "linux") return false;
|
|
4946
|
+
try {
|
|
4947
|
+
const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
|
|
4948
|
+
const st = statSync2(keyPath);
|
|
4949
|
+
if (!st.isFile() || (st.mode & 63) !== 0) return false;
|
|
4950
|
+
if (uid === 0) return true;
|
|
4951
|
+
const exeOsDir = process.env.EXE_OS_DIR;
|
|
4952
|
+
return Boolean(exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep));
|
|
4953
|
+
} catch {
|
|
4954
|
+
return false;
|
|
4955
|
+
}
|
|
4956
|
+
}
|
|
4957
|
+
function macKeychainGet(service = SERVICE) {
|
|
4958
|
+
if (!nativeKeychainAllowed()) return null;
|
|
4316
4959
|
if (process.platform !== "darwin") return null;
|
|
4317
4960
|
try {
|
|
4318
4961
|
return execSync2(
|
|
4319
|
-
`security find-generic-password -s "${
|
|
4962
|
+
`security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
|
|
4320
4963
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
4321
4964
|
).trim();
|
|
4322
4965
|
} catch {
|
|
4323
4966
|
return null;
|
|
4324
4967
|
}
|
|
4325
4968
|
}
|
|
4326
|
-
function macKeychainSet(value) {
|
|
4969
|
+
function macKeychainSet(value, service = SERVICE) {
|
|
4970
|
+
if (!nativeKeychainAllowed()) return false;
|
|
4327
4971
|
if (process.platform !== "darwin") return false;
|
|
4328
4972
|
try {
|
|
4329
4973
|
try {
|
|
4330
4974
|
execSync2(
|
|
4331
|
-
`security delete-generic-password -s "${
|
|
4975
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
4332
4976
|
{ timeout: 5e3 }
|
|
4333
4977
|
);
|
|
4334
4978
|
} catch {
|
|
4335
4979
|
}
|
|
4336
4980
|
execSync2(
|
|
4337
|
-
`security add-generic-password -s "${
|
|
4981
|
+
`security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
|
|
4982
|
+
{ timeout: 5e3 }
|
|
4983
|
+
);
|
|
4984
|
+
return true;
|
|
4985
|
+
} catch {
|
|
4986
|
+
return false;
|
|
4987
|
+
}
|
|
4988
|
+
}
|
|
4989
|
+
function macKeychainDelete(service = SERVICE) {
|
|
4990
|
+
if (!nativeKeychainAllowed()) return false;
|
|
4991
|
+
if (process.platform !== "darwin") return false;
|
|
4992
|
+
try {
|
|
4993
|
+
execSync2(
|
|
4994
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
4338
4995
|
{ timeout: 5e3 }
|
|
4339
4996
|
);
|
|
4340
4997
|
return true;
|
|
@@ -4342,22 +4999,35 @@ function macKeychainSet(value) {
|
|
|
4342
4999
|
return false;
|
|
4343
5000
|
}
|
|
4344
5001
|
}
|
|
4345
|
-
function linuxSecretGet() {
|
|
4346
|
-
if (
|
|
5002
|
+
function linuxSecretGet(service = SERVICE) {
|
|
5003
|
+
if (!linuxSecretAvailable()) return null;
|
|
4347
5004
|
try {
|
|
4348
5005
|
return execSync2(
|
|
4349
|
-
`secret-tool lookup service "${
|
|
5006
|
+
`secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
4350
5007
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
4351
5008
|
).trim();
|
|
4352
5009
|
} catch {
|
|
4353
5010
|
return null;
|
|
4354
5011
|
}
|
|
4355
5012
|
}
|
|
4356
|
-
function linuxSecretSet(value) {
|
|
5013
|
+
function linuxSecretSet(value, service = SERVICE) {
|
|
5014
|
+
if (!linuxSecretAvailable()) return false;
|
|
5015
|
+
try {
|
|
5016
|
+
execSync2(
|
|
5017
|
+
`echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
5018
|
+
{ timeout: 5e3 }
|
|
5019
|
+
);
|
|
5020
|
+
return true;
|
|
5021
|
+
} catch {
|
|
5022
|
+
return false;
|
|
5023
|
+
}
|
|
5024
|
+
}
|
|
5025
|
+
function linuxSecretDelete(service = SERVICE) {
|
|
5026
|
+
if (!nativeKeychainAllowed()) return false;
|
|
4357
5027
|
if (process.platform !== "linux") return false;
|
|
4358
5028
|
try {
|
|
4359
5029
|
execSync2(
|
|
4360
|
-
`
|
|
5030
|
+
`secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
4361
5031
|
{ timeout: 5e3 }
|
|
4362
5032
|
);
|
|
4363
5033
|
return true;
|
|
@@ -4366,6 +5036,7 @@ function linuxSecretSet(value) {
|
|
|
4366
5036
|
}
|
|
4367
5037
|
}
|
|
4368
5038
|
async function tryKeytar() {
|
|
5039
|
+
if (!nativeKeychainAllowed()) return null;
|
|
4369
5040
|
try {
|
|
4370
5041
|
return await import("keytar");
|
|
4371
5042
|
} catch {
|
|
@@ -4391,8 +5062,8 @@ function deriveMachineKey() {
|
|
|
4391
5062
|
}
|
|
4392
5063
|
function readMachineId() {
|
|
4393
5064
|
try {
|
|
4394
|
-
const { readFileSync:
|
|
4395
|
-
return
|
|
5065
|
+
const { readFileSync: readFileSync11 } = __require("fs");
|
|
5066
|
+
return readFileSync11("/etc/machine-id", "utf-8").trim();
|
|
4396
5067
|
} catch {
|
|
4397
5068
|
return "";
|
|
4398
5069
|
}
|
|
@@ -4440,7 +5111,19 @@ async function writeMachineBoundFileFallback(b64) {
|
|
|
4440
5111
|
return "plaintext";
|
|
4441
5112
|
}
|
|
4442
5113
|
async function getMasterKey() {
|
|
4443
|
-
|
|
5114
|
+
let nativeValue = macKeychainGet() ?? linuxSecretGet();
|
|
5115
|
+
if (!nativeValue) {
|
|
5116
|
+
const legacyValue = macKeychainGet(LEGACY_SERVICE) ?? linuxSecretGet(LEGACY_SERVICE);
|
|
5117
|
+
if (legacyValue) {
|
|
5118
|
+
const migrated = macKeychainSet(legacyValue) || linuxSecretSet(legacyValue);
|
|
5119
|
+
if (migrated) {
|
|
5120
|
+
macKeychainDelete(LEGACY_SERVICE);
|
|
5121
|
+
linuxSecretDelete(LEGACY_SERVICE);
|
|
5122
|
+
process.stderr.write("[keychain] Migrated keychain service from exe-mem to exe-os.\n");
|
|
5123
|
+
}
|
|
5124
|
+
nativeValue = legacyValue;
|
|
5125
|
+
}
|
|
5126
|
+
}
|
|
4444
5127
|
if (nativeValue) {
|
|
4445
5128
|
return Buffer.from(nativeValue, "base64");
|
|
4446
5129
|
}
|
|
@@ -4448,12 +5131,17 @@ async function getMasterKey() {
|
|
|
4448
5131
|
if (keytar) {
|
|
4449
5132
|
try {
|
|
4450
5133
|
const keytarValue = await keytar.getPassword(SERVICE, ACCOUNT);
|
|
4451
|
-
|
|
4452
|
-
|
|
5134
|
+
const legacyKeytarValue = keytarValue ?? await keytar.getPassword(LEGACY_SERVICE, ACCOUNT);
|
|
5135
|
+
if (legacyKeytarValue) {
|
|
5136
|
+
const migrated = macKeychainSet(legacyKeytarValue) || linuxSecretSet(legacyKeytarValue);
|
|
4453
5137
|
if (migrated) {
|
|
4454
5138
|
process.stderr.write("[keychain] Migrated key from keytar to native keychain.\n");
|
|
5139
|
+
try {
|
|
5140
|
+
await keytar.deletePassword(LEGACY_SERVICE, ACCOUNT);
|
|
5141
|
+
} catch {
|
|
5142
|
+
}
|
|
4455
5143
|
}
|
|
4456
|
-
return Buffer.from(
|
|
5144
|
+
return Buffer.from(legacyKeytarValue, "base64");
|
|
4457
5145
|
}
|
|
4458
5146
|
} catch {
|
|
4459
5147
|
}
|
|
@@ -4478,7 +5166,7 @@ async function getMasterKey() {
|
|
|
4478
5166
|
const decrypted = decryptWithMachineKey(content, machineKey);
|
|
4479
5167
|
if (!decrypted) {
|
|
4480
5168
|
process.stderr.write(
|
|
4481
|
-
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase: exe-os
|
|
5169
|
+
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase during setup: exe-os setup\n"
|
|
4482
5170
|
);
|
|
4483
5171
|
return null;
|
|
4484
5172
|
}
|
|
@@ -4487,6 +5175,9 @@ async function getMasterKey() {
|
|
|
4487
5175
|
b64Value = content;
|
|
4488
5176
|
}
|
|
4489
5177
|
const key = Buffer.from(b64Value, "base64");
|
|
5178
|
+
if (!content.startsWith(ENCRYPTED_PREFIX) && isRootOnlyTrustedServerKeyFile(keyPath)) {
|
|
5179
|
+
return key;
|
|
5180
|
+
}
|
|
4490
5181
|
const migrated = macKeychainSet(b64Value) || linuxSecretSet(b64Value);
|
|
4491
5182
|
if (migrated) {
|
|
4492
5183
|
process.stderr.write("[keychain] Migrated key from file to native keychain.\n");
|
|
@@ -4853,6 +5544,11 @@ async function flushBatch() {
|
|
|
4853
5544
|
await insertMemoryCardsForBatch2(batch);
|
|
4854
5545
|
} catch {
|
|
4855
5546
|
}
|
|
5547
|
+
try {
|
|
5548
|
+
const { insertOntologyForBatch: insertOntologyForBatch2 } = await Promise.resolve().then(() => (init_agentic_ontology(), agentic_ontology_exports));
|
|
5549
|
+
await insertOntologyForBatch2(batch);
|
|
5550
|
+
} catch {
|
|
5551
|
+
}
|
|
4856
5552
|
schedulePostWriteMemoryHygiene(batch.map((row) => row.id));
|
|
4857
5553
|
_pendingRecords.splice(0, batch.length);
|
|
4858
5554
|
try {
|
|
@@ -4921,7 +5617,7 @@ import {
|
|
|
4921
5617
|
existsSync as existsSync8,
|
|
4922
5618
|
mkdirSync as mkdirSync3,
|
|
4923
5619
|
readdirSync as readdirSync2,
|
|
4924
|
-
statSync as
|
|
5620
|
+
statSync as statSync4,
|
|
4925
5621
|
unlinkSync as unlinkSync3,
|
|
4926
5622
|
writeFileSync as writeFileSync3
|
|
4927
5623
|
} from "fs";
|
|
@@ -4993,7 +5689,7 @@ function sweepStaleBehaviorExports(now = Date.now()) {
|
|
|
4993
5689
|
for (const entry of entries) {
|
|
4994
5690
|
const filePath = path8.join(BEHAVIORS_EXPORT_DIR, entry);
|
|
4995
5691
|
try {
|
|
4996
|
-
const stat =
|
|
5692
|
+
const stat = statSync4(filePath);
|
|
4997
5693
|
if (now - stat.mtimeMs > STALE_EXPORT_AGE_MS) {
|
|
4998
5694
|
unlinkSync3(filePath);
|
|
4999
5695
|
}
|
|
@@ -5056,7 +5752,7 @@ When done with a task: call update_task with status "done".
|
|
|
5056
5752
|
Always call store_memory to persist important findings.
|
|
5057
5753
|
`;
|
|
5058
5754
|
function resolveAgent(argv) {
|
|
5059
|
-
const invokedAs =
|
|
5755
|
+
const invokedAs = path15.basename(argv[1] ?? "");
|
|
5060
5756
|
if (invokedAs && invokedAs !== "exe-start-opencode" && !invokedAs.endsWith(".js")) {
|
|
5061
5757
|
const agent2 = invokedAs.replace(/-opencode$/, "").toLowerCase();
|
|
5062
5758
|
return { agent: agent2, passthrough: argv.slice(2) };
|
|
@@ -5073,24 +5769,24 @@ function resolveAgent(argv) {
|
|
|
5073
5769
|
return { agent, passthrough };
|
|
5074
5770
|
}
|
|
5075
5771
|
function loadIdentity(agent) {
|
|
5076
|
-
const dir =
|
|
5077
|
-
const exact =
|
|
5078
|
-
if (
|
|
5079
|
-
const content =
|
|
5772
|
+
const dir = path15.join(os12.homedir(), ".exe-os", "identity");
|
|
5773
|
+
const exact = path15.join(dir, `${agent}.md`);
|
|
5774
|
+
if (existsSync14(exact)) {
|
|
5775
|
+
const content = readFileSync10(exact, "utf-8").trim();
|
|
5080
5776
|
if (content) return content;
|
|
5081
5777
|
}
|
|
5082
5778
|
try {
|
|
5083
5779
|
const files = readdirSync4(dir);
|
|
5084
5780
|
const match = files.find((f) => f.toLowerCase() === `${agent.toLowerCase()}.md`);
|
|
5085
5781
|
if (match) {
|
|
5086
|
-
const content =
|
|
5782
|
+
const content = readFileSync10(path15.join(dir, match), "utf-8").trim();
|
|
5087
5783
|
if (content) return content;
|
|
5088
5784
|
}
|
|
5089
5785
|
} catch {
|
|
5090
5786
|
}
|
|
5091
5787
|
try {
|
|
5092
|
-
const rosterPath =
|
|
5093
|
-
const roster = JSON.parse(
|
|
5788
|
+
const rosterPath = path15.join(os12.homedir(), ".exe-os", "exe-employees.json");
|
|
5789
|
+
const roster = JSON.parse(readFileSync10(rosterPath, "utf8"));
|
|
5094
5790
|
const emp = roster.find((e) => e.name.toLowerCase() === agent.toLowerCase());
|
|
5095
5791
|
if (emp?.systemPrompt && emp.systemPrompt.trim().length > 20) {
|
|
5096
5792
|
return emp.systemPrompt;
|
|
@@ -5100,18 +5796,18 @@ function loadIdentity(agent) {
|
|
|
5100
5796
|
return null;
|
|
5101
5797
|
}
|
|
5102
5798
|
function writeAgentFile(agent, identity, behaviorsPath) {
|
|
5103
|
-
const agentDir =
|
|
5104
|
-
|
|
5799
|
+
const agentDir = path15.join(os12.homedir(), ".config", "opencode", "agents");
|
|
5800
|
+
mkdirSync8(agentDir, { recursive: true });
|
|
5105
5801
|
let content = identity;
|
|
5106
|
-
if (behaviorsPath &&
|
|
5107
|
-
const behaviors =
|
|
5802
|
+
if (behaviorsPath && existsSync14(behaviorsPath)) {
|
|
5803
|
+
const behaviors = readFileSync10(behaviorsPath, "utf-8").trim();
|
|
5108
5804
|
if (behaviors) {
|
|
5109
5805
|
content += "\n\n" + behaviors;
|
|
5110
5806
|
}
|
|
5111
5807
|
}
|
|
5112
5808
|
content += "\n" + BOOT_INSTRUCTIONS;
|
|
5113
|
-
const outPath =
|
|
5114
|
-
|
|
5809
|
+
const outPath = path15.join(agentDir, `${agent}.md`);
|
|
5810
|
+
writeFileSync8(outPath, content, "utf-8");
|
|
5115
5811
|
return outPath;
|
|
5116
5812
|
}
|
|
5117
5813
|
async function main() {
|
|
@@ -5172,8 +5868,8 @@ async function main() {
|
|
|
5172
5868
|
process.env.EXE_RUNTIME = "opencode";
|
|
5173
5869
|
const empRole = (() => {
|
|
5174
5870
|
try {
|
|
5175
|
-
const emps =
|
|
5176
|
-
|
|
5871
|
+
const emps = readFileSync10(
|
|
5872
|
+
path15.join(os12.homedir(), ".exe-os", "exe-employees.json"),
|
|
5177
5873
|
"utf-8"
|
|
5178
5874
|
);
|
|
5179
5875
|
const found = JSON.parse(emps).find(
|