@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, DEFAULT_RUNTIME;
|
|
3608
4036
|
var init_runtime_table = __esm({
|
|
@@ -3941,6 +4369,56 @@ var init_preferences = __esm({
|
|
|
3941
4369
|
}
|
|
3942
4370
|
});
|
|
3943
4371
|
|
|
4372
|
+
// src/adapters/mcp-http-config.ts
|
|
4373
|
+
import { chmodSync as chmodSync2, existsSync as existsSync11, mkdirSync as mkdirSync6, readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "fs";
|
|
4374
|
+
import { randomBytes } from "crypto";
|
|
4375
|
+
import path12 from "path";
|
|
4376
|
+
import os9 from "os";
|
|
4377
|
+
function mcpHttpPort() {
|
|
4378
|
+
return process.env.EXE_MCP_PORT || DEFAULT_MCP_HTTP_PORT;
|
|
4379
|
+
}
|
|
4380
|
+
function mcpHttpUrl() {
|
|
4381
|
+
return `http://127.0.0.1:${mcpHttpPort()}/mcp`;
|
|
4382
|
+
}
|
|
4383
|
+
function readOrCreateDaemonToken(homeDir = os9.homedir()) {
|
|
4384
|
+
const exeDir = path12.join(homeDir, ".exe-os");
|
|
4385
|
+
const tokenPath = path12.join(exeDir, "exed.token");
|
|
4386
|
+
if (existsSync11(tokenPath)) {
|
|
4387
|
+
try {
|
|
4388
|
+
const token2 = readFileSync7(tokenPath, "utf-8").trim();
|
|
4389
|
+
if (/^[a-f0-9]{64}$/i.test(token2)) return token2;
|
|
4390
|
+
} catch {
|
|
4391
|
+
}
|
|
4392
|
+
}
|
|
4393
|
+
const token = randomBytes(32).toString("hex");
|
|
4394
|
+
mkdirSync6(exeDir, { recursive: true });
|
|
4395
|
+
writeFileSync6(tokenPath, `${token}
|
|
4396
|
+
`, "utf-8");
|
|
4397
|
+
try {
|
|
4398
|
+
chmodSync2(tokenPath, 384);
|
|
4399
|
+
} catch {
|
|
4400
|
+
}
|
|
4401
|
+
return token;
|
|
4402
|
+
}
|
|
4403
|
+
function buildMcpHttpHeaders(homeDir = os9.homedir(), opts = {}) {
|
|
4404
|
+
const agentId = opts.useShellPlaceholders ? "${AGENT_ID:-exe}" : opts.agentId ?? DEFAULT_MCP_HTTP_AGENT_ID;
|
|
4405
|
+
const agentRole = opts.useShellPlaceholders ? "${AGENT_ROLE:-COO}" : opts.agentRole ?? DEFAULT_MCP_HTTP_AGENT_ROLE;
|
|
4406
|
+
return {
|
|
4407
|
+
Authorization: `Bearer ${readOrCreateDaemonToken(homeDir)}`,
|
|
4408
|
+
"X-Agent-Id": agentId,
|
|
4409
|
+
"X-Agent-Role": agentRole
|
|
4410
|
+
};
|
|
4411
|
+
}
|
|
4412
|
+
var DEFAULT_MCP_HTTP_PORT, DEFAULT_MCP_HTTP_AGENT_ID, DEFAULT_MCP_HTTP_AGENT_ROLE;
|
|
4413
|
+
var init_mcp_http_config = __esm({
|
|
4414
|
+
"src/adapters/mcp-http-config.ts"() {
|
|
4415
|
+
"use strict";
|
|
4416
|
+
DEFAULT_MCP_HTTP_PORT = "48739";
|
|
4417
|
+
DEFAULT_MCP_HTTP_AGENT_ID = "exe";
|
|
4418
|
+
DEFAULT_MCP_HTTP_AGENT_ROLE = "COO";
|
|
4419
|
+
}
|
|
4420
|
+
});
|
|
4421
|
+
|
|
3944
4422
|
// src/adapters/runtime-hook-manifest.ts
|
|
3945
4423
|
function commandHasAnyMarker(command, markers) {
|
|
3946
4424
|
return markers.some((marker) => command.includes(marker));
|
|
@@ -3948,7 +4426,7 @@ function commandHasAnyMarker(command, markers) {
|
|
|
3948
4426
|
function isLegacySplitPostToolCommand(command) {
|
|
3949
4427
|
return commandHasAnyMarker(command, LEGACY_SPLIT_POST_TOOL_HOOK_MARKERS);
|
|
3950
4428
|
}
|
|
3951
|
-
var EXE_HOOKS, LEGACY_SPLIT_POST_TOOL_HOOK_MARKERS;
|
|
4429
|
+
var EXE_HOOKS, EXE_HOOK_MANIFEST, LEGACY_SPLIT_POST_TOOL_HOOK_MARKERS;
|
|
3952
4430
|
var init_runtime_hook_manifest = __esm({
|
|
3953
4431
|
"src/adapters/runtime-hook-manifest.ts"() {
|
|
3954
4432
|
"use strict";
|
|
@@ -3966,6 +4444,116 @@ var init_runtime_hook_manifest = __esm({
|
|
|
3966
4444
|
notification: "dist/hooks/notification.js",
|
|
3967
4445
|
instructionsLoaded: "dist/hooks/instructions-loaded.js"
|
|
3968
4446
|
};
|
|
4447
|
+
EXE_HOOK_MANIFEST = [
|
|
4448
|
+
{
|
|
4449
|
+
key: "postToolCombined",
|
|
4450
|
+
event: "PostToolUse",
|
|
4451
|
+
commandMarker: EXE_HOOKS.postToolCombined,
|
|
4452
|
+
owner: "exe-os",
|
|
4453
|
+
purpose: "Single PostToolUse entrypoint for ingestion, error recall, summaries, and bug detection.",
|
|
4454
|
+
runtimes: ["claude", "codex", "opencode"],
|
|
4455
|
+
checkpointRole: "none"
|
|
4456
|
+
},
|
|
4457
|
+
{
|
|
4458
|
+
key: "sessionStart",
|
|
4459
|
+
event: "SessionStart",
|
|
4460
|
+
commandMarker: EXE_HOOKS.sessionStart,
|
|
4461
|
+
owner: "exe-os",
|
|
4462
|
+
purpose: "Loads agent identity, procedures, and boot context.",
|
|
4463
|
+
runtimes: ["claude", "codex", "opencode"],
|
|
4464
|
+
checkpointRole: "none"
|
|
4465
|
+
},
|
|
4466
|
+
{
|
|
4467
|
+
key: "promptSubmit",
|
|
4468
|
+
event: "UserPromptSubmit",
|
|
4469
|
+
commandMarker: EXE_HOOKS.promptSubmit,
|
|
4470
|
+
owner: "exe-os",
|
|
4471
|
+
purpose: "Injects current tasks, pending reviews, and local context before each prompt.",
|
|
4472
|
+
runtimes: ["claude", "codex", "opencode"],
|
|
4473
|
+
checkpointRole: "none"
|
|
4474
|
+
},
|
|
4475
|
+
{
|
|
4476
|
+
key: "heartbeat",
|
|
4477
|
+
event: "UserPromptSubmit",
|
|
4478
|
+
commandMarker: EXE_HOOKS.heartbeat,
|
|
4479
|
+
owner: "exe-os",
|
|
4480
|
+
purpose: "Lightweight heartbeat/status sidecar for Claude Code sessions.",
|
|
4481
|
+
runtimes: ["claude"],
|
|
4482
|
+
checkpointRole: "none"
|
|
4483
|
+
},
|
|
4484
|
+
{
|
|
4485
|
+
key: "stop",
|
|
4486
|
+
event: "Stop",
|
|
4487
|
+
commandMarker: EXE_HOOKS.stop,
|
|
4488
|
+
owner: "exe-os",
|
|
4489
|
+
purpose: "Finalizes task state, capacity signals, and emergency checkpointing.",
|
|
4490
|
+
runtimes: ["claude", "codex", "opencode"],
|
|
4491
|
+
checkpointRole: "capacity_checkpoint"
|
|
4492
|
+
},
|
|
4493
|
+
{
|
|
4494
|
+
key: "preToolUse",
|
|
4495
|
+
event: "PreToolUse",
|
|
4496
|
+
commandMarker: EXE_HOOKS.preToolUse,
|
|
4497
|
+
owner: "exe-os",
|
|
4498
|
+
purpose: "Preflight guardrails before shell/tool execution.",
|
|
4499
|
+
runtimes: ["claude", "codex", "opencode"],
|
|
4500
|
+
checkpointRole: "none"
|
|
4501
|
+
},
|
|
4502
|
+
{
|
|
4503
|
+
key: "subagentStop",
|
|
4504
|
+
event: "SubagentStop",
|
|
4505
|
+
commandMarker: EXE_HOOKS.subagentStop,
|
|
4506
|
+
owner: "exe-os",
|
|
4507
|
+
purpose: "Captures subagent completion context.",
|
|
4508
|
+
runtimes: ["claude"],
|
|
4509
|
+
checkpointRole: "none"
|
|
4510
|
+
},
|
|
4511
|
+
{
|
|
4512
|
+
key: "preCompact",
|
|
4513
|
+
event: "PreCompact",
|
|
4514
|
+
commandMarker: EXE_HOOKS.preCompact,
|
|
4515
|
+
owner: "exe-os",
|
|
4516
|
+
purpose: "Writes active-task snapshot and compaction recovery context.",
|
|
4517
|
+
runtimes: ["claude"],
|
|
4518
|
+
checkpointRole: "recovery_context"
|
|
4519
|
+
},
|
|
4520
|
+
{
|
|
4521
|
+
key: "postCompact",
|
|
4522
|
+
event: "PostCompact",
|
|
4523
|
+
commandMarker: EXE_HOOKS.postCompact,
|
|
4524
|
+
owner: "exe-os",
|
|
4525
|
+
purpose: "Rehydrates recovery context after compaction.",
|
|
4526
|
+
runtimes: ["claude"],
|
|
4527
|
+
checkpointRole: "recovery_context"
|
|
4528
|
+
},
|
|
4529
|
+
{
|
|
4530
|
+
key: "sessionEnd",
|
|
4531
|
+
event: "SessionEnd",
|
|
4532
|
+
commandMarker: EXE_HOOKS.sessionEnd,
|
|
4533
|
+
owner: "exe-os",
|
|
4534
|
+
purpose: "Stores session-end checkpoint and triages orphaned in-progress tasks.",
|
|
4535
|
+
runtimes: ["claude"],
|
|
4536
|
+
checkpointRole: "session_summary"
|
|
4537
|
+
},
|
|
4538
|
+
{
|
|
4539
|
+
key: "notification",
|
|
4540
|
+
event: "Notification",
|
|
4541
|
+
commandMarker: EXE_HOOKS.notification,
|
|
4542
|
+
owner: "exe-os",
|
|
4543
|
+
purpose: "Captures runtime notifications and nudges.",
|
|
4544
|
+
runtimes: ["claude"],
|
|
4545
|
+
checkpointRole: "none"
|
|
4546
|
+
},
|
|
4547
|
+
{
|
|
4548
|
+
key: "instructionsLoaded",
|
|
4549
|
+
event: "InstructionsLoaded",
|
|
4550
|
+
commandMarker: EXE_HOOKS.instructionsLoaded,
|
|
4551
|
+
owner: "exe-os",
|
|
4552
|
+
purpose: "Applies runtime instruction post-processing.",
|
|
4553
|
+
runtimes: ["claude"],
|
|
4554
|
+
checkpointRole: "none"
|
|
4555
|
+
}
|
|
4556
|
+
];
|
|
3969
4557
|
LEGACY_SPLIT_POST_TOOL_HOOK_MARKERS = [
|
|
3970
4558
|
"dist/hooks/ingest.js",
|
|
3971
4559
|
"dist/hooks/error-recall.js",
|
|
@@ -3975,29 +4563,29 @@ var init_runtime_hook_manifest = __esm({
|
|
|
3975
4563
|
});
|
|
3976
4564
|
|
|
3977
4565
|
// src/adapters/claude/installer.ts
|
|
3978
|
-
import { readFile as readFile4, writeFile as writeFile4, mkdir as mkdir4, readdir } from "fs/promises";
|
|
3979
|
-
import { existsSync as
|
|
3980
|
-
import { createHash as
|
|
3981
|
-
import
|
|
3982
|
-
import
|
|
4566
|
+
import { readFile as readFile4, writeFile as writeFile4, mkdir as mkdir4, readdir, rm } from "fs/promises";
|
|
4567
|
+
import { existsSync as existsSync12, readFileSync as readFileSync8, writeFileSync as writeFileSync7, copyFileSync, mkdirSync as mkdirSync7 } from "fs";
|
|
4568
|
+
import { createHash as createHash4 } from "crypto";
|
|
4569
|
+
import path13 from "path";
|
|
4570
|
+
import os10 from "os";
|
|
3983
4571
|
import { execSync as execSync5 } from "child_process";
|
|
3984
4572
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
3985
4573
|
function resolvePackageRoot() {
|
|
3986
4574
|
const thisFile = fileURLToPath2(import.meta.url);
|
|
3987
|
-
let dir =
|
|
3988
|
-
const root =
|
|
4575
|
+
let dir = path13.dirname(thisFile);
|
|
4576
|
+
const root = path13.parse(dir).root;
|
|
3989
4577
|
while (dir !== root) {
|
|
3990
|
-
const pkgPath =
|
|
3991
|
-
if (
|
|
4578
|
+
const pkgPath = path13.join(dir, "package.json");
|
|
4579
|
+
if (existsSync12(pkgPath)) {
|
|
3992
4580
|
try {
|
|
3993
|
-
const pkg = JSON.parse(
|
|
4581
|
+
const pkg = JSON.parse(readFileSync8(pkgPath, "utf-8"));
|
|
3994
4582
|
if (pkg.name === "@askexenow/exe-os" || pkg.name === "exe-os") return dir;
|
|
3995
4583
|
} catch {
|
|
3996
4584
|
}
|
|
3997
4585
|
}
|
|
3998
|
-
dir =
|
|
4586
|
+
dir = path13.dirname(dir);
|
|
3999
4587
|
}
|
|
4000
|
-
return
|
|
4588
|
+
return path13.resolve(path13.dirname(thisFile), "..", "..", "..");
|
|
4001
4589
|
}
|
|
4002
4590
|
var EXE_SECTION_START, EXE_SECTION_END, ORCHESTRATION_RULES;
|
|
4003
4591
|
var init_installer = __esm({
|
|
@@ -4006,6 +4594,7 @@ var init_installer = __esm({
|
|
|
4006
4594
|
init_agent_symlinks();
|
|
4007
4595
|
init_mcp_prefix();
|
|
4008
4596
|
init_preferences();
|
|
4597
|
+
init_mcp_http_config();
|
|
4009
4598
|
init_runtime_hook_manifest();
|
|
4010
4599
|
EXE_SECTION_START = "<!-- exe-os:orchestration-start -->";
|
|
4011
4600
|
EXE_SECTION_END = "<!-- exe-os:orchestration-end -->";
|
|
@@ -4034,19 +4623,19 @@ __export(installer_exports, {
|
|
|
4034
4623
|
verifyCodexHooks: () => verifyCodexHooks
|
|
4035
4624
|
});
|
|
4036
4625
|
import { readFile as readFile5, writeFile as writeFile5, mkdir as mkdir5 } from "fs/promises";
|
|
4037
|
-
import { existsSync as
|
|
4038
|
-
import
|
|
4039
|
-
import
|
|
4040
|
-
async function mergeCodexHooks(packageRoot, homeDir =
|
|
4041
|
-
const codexDir =
|
|
4042
|
-
const hooksPath =
|
|
4043
|
-
const logsDir =
|
|
4044
|
-
const hookLogPath =
|
|
4626
|
+
import { existsSync as existsSync13, readFileSync as readFileSync9 } from "fs";
|
|
4627
|
+
import path14 from "path";
|
|
4628
|
+
import os11 from "os";
|
|
4629
|
+
async function mergeCodexHooks(packageRoot, homeDir = os11.homedir()) {
|
|
4630
|
+
const codexDir = path14.join(homeDir, ".codex");
|
|
4631
|
+
const hooksPath = path14.join(codexDir, "hooks.json");
|
|
4632
|
+
const logsDir = path14.join(homeDir, ".exe-os", "logs");
|
|
4633
|
+
const hookLogPath = path14.join(logsDir, "hooks.log");
|
|
4045
4634
|
const logSuffix = ` 2>> "${hookLogPath}"`;
|
|
4046
4635
|
await mkdir5(codexDir, { recursive: true });
|
|
4047
4636
|
await mkdir5(logsDir, { recursive: true });
|
|
4048
4637
|
let hooksJson = {};
|
|
4049
|
-
if (
|
|
4638
|
+
if (existsSync13(hooksPath)) {
|
|
4050
4639
|
try {
|
|
4051
4640
|
hooksJson = JSON.parse(await readFile5(hooksPath, "utf-8"));
|
|
4052
4641
|
} catch {
|
|
@@ -4057,19 +4646,6 @@ async function mergeCodexHooks(packageRoot, homeDir = os10.homedir()) {
|
|
|
4057
4646
|
hooksJson.hooks = {};
|
|
4058
4647
|
}
|
|
4059
4648
|
const hooksToRegister = [
|
|
4060
|
-
{
|
|
4061
|
-
event: "SessionStart",
|
|
4062
|
-
group: {
|
|
4063
|
-
hooks: [
|
|
4064
|
-
{
|
|
4065
|
-
type: "command",
|
|
4066
|
-
command: `node "${path13.join(packageRoot, "dist", "hooks", "session-start.js")}"${logSuffix}`,
|
|
4067
|
-
timeout: 30
|
|
4068
|
-
}
|
|
4069
|
-
]
|
|
4070
|
-
},
|
|
4071
|
-
marker: EXE_HOOKS.sessionStart
|
|
4072
|
-
},
|
|
4073
4649
|
{
|
|
4074
4650
|
event: "PostToolUse",
|
|
4075
4651
|
group: {
|
|
@@ -4079,7 +4655,7 @@ async function mergeCodexHooks(packageRoot, homeDir = os10.homedir()) {
|
|
|
4079
4655
|
// Combined hook: runs ingest + error-recall in one Node process.
|
|
4080
4656
|
// Eliminates a cold-start cycle per tool call (~3-6s savings on Codex).
|
|
4081
4657
|
type: "command",
|
|
4082
|
-
command: `node "${
|
|
4658
|
+
command: `node "${path14.join(packageRoot, "dist", "hooks", "post-tool-combined.js")}"${logSuffix}`
|
|
4083
4659
|
}
|
|
4084
4660
|
]
|
|
4085
4661
|
},
|
|
@@ -4093,7 +4669,7 @@ async function mergeCodexHooks(packageRoot, homeDir = os10.homedir()) {
|
|
|
4093
4669
|
// Single hook: prompt-submit handles memory retrieval + entity boost.
|
|
4094
4670
|
// exe-heartbeat-hook is CC-specific (intercom) — omitted on Codex.
|
|
4095
4671
|
type: "command",
|
|
4096
|
-
command: `node "${
|
|
4672
|
+
command: `node "${path14.join(packageRoot, "dist", "hooks", "prompt-submit.js")}"${logSuffix}`
|
|
4097
4673
|
}
|
|
4098
4674
|
]
|
|
4099
4675
|
},
|
|
@@ -4105,7 +4681,7 @@ async function mergeCodexHooks(packageRoot, homeDir = os10.homedir()) {
|
|
|
4105
4681
|
hooks: [
|
|
4106
4682
|
{
|
|
4107
4683
|
type: "command",
|
|
4108
|
-
command: `node "${
|
|
4684
|
+
command: `node "${path14.join(packageRoot, "dist", "hooks", "stop.js")}"${logSuffix}`
|
|
4109
4685
|
}
|
|
4110
4686
|
]
|
|
4111
4687
|
},
|
|
@@ -4118,7 +4694,7 @@ async function mergeCodexHooks(packageRoot, homeDir = os10.homedir()) {
|
|
|
4118
4694
|
hooks: [
|
|
4119
4695
|
{
|
|
4120
4696
|
type: "command",
|
|
4121
|
-
command: `node "${
|
|
4697
|
+
command: `node "${path14.join(packageRoot, "dist", "hooks", "pre-tool-use.js")}"${logSuffix}`
|
|
4122
4698
|
}
|
|
4123
4699
|
]
|
|
4124
4700
|
},
|
|
@@ -4127,6 +4703,16 @@ async function mergeCodexHooks(packageRoot, homeDir = os10.homedir()) {
|
|
|
4127
4703
|
];
|
|
4128
4704
|
let added = 0;
|
|
4129
4705
|
let skipped = 0;
|
|
4706
|
+
const sessionStartGroups = hooksJson.hooks["SessionStart"];
|
|
4707
|
+
if (Array.isArray(sessionStartGroups)) {
|
|
4708
|
+
hooksJson.hooks["SessionStart"] = sessionStartGroups.map((g) => ({
|
|
4709
|
+
...g,
|
|
4710
|
+
hooks: g.hooks.filter((h) => !h.command.includes(EXE_HOOKS.sessionStart))
|
|
4711
|
+
})).filter((g) => g.hooks.length > 0);
|
|
4712
|
+
if (hooksJson.hooks["SessionStart"].length === 0) {
|
|
4713
|
+
delete hooksJson.hooks["SessionStart"];
|
|
4714
|
+
}
|
|
4715
|
+
}
|
|
4130
4716
|
const postToolGroups = hooksJson.hooks["PostToolUse"];
|
|
4131
4717
|
if (Array.isArray(postToolGroups)) {
|
|
4132
4718
|
hooksJson.hooks["PostToolUse"] = postToolGroups.map((g) => ({
|
|
@@ -4156,15 +4742,13 @@ async function mergeCodexHooks(packageRoot, homeDir = os10.homedir()) {
|
|
|
4156
4742
|
await writeFile5(hooksPath, JSON.stringify(hooksJson, null, 2) + "\n");
|
|
4157
4743
|
return { added, skipped };
|
|
4158
4744
|
}
|
|
4159
|
-
function verifyCodexHooks(homeDir =
|
|
4160
|
-
const hooksPath =
|
|
4161
|
-
if (!
|
|
4745
|
+
function verifyCodexHooks(homeDir = os11.homedir()) {
|
|
4746
|
+
const hooksPath = path14.join(homeDir, ".codex", "hooks.json");
|
|
4747
|
+
if (!existsSync13(hooksPath)) return false;
|
|
4162
4748
|
try {
|
|
4163
|
-
const hooksJson = JSON.parse(
|
|
4164
|
-
__require("fs").readFileSync(hooksPath, "utf-8")
|
|
4165
|
-
);
|
|
4749
|
+
const hooksJson = JSON.parse(readFileSync9(hooksPath, "utf-8"));
|
|
4166
4750
|
if (!hooksJson.hooks) return false;
|
|
4167
|
-
const required = ["
|
|
4751
|
+
const required = ["PostToolUse", "UserPromptSubmit", "Stop", "PreToolUse"];
|
|
4168
4752
|
for (const event of required) {
|
|
4169
4753
|
const groups = hooksJson.hooks[event];
|
|
4170
4754
|
if (!groups || !groups.some(
|
|
@@ -4182,19 +4766,23 @@ function verifyCodexHooks(homeDir = os10.homedir()) {
|
|
|
4182
4766
|
)) {
|
|
4183
4767
|
return false;
|
|
4184
4768
|
}
|
|
4769
|
+
const sessionStartCommands = (hooksJson.hooks.SessionStart ?? []).flatMap((g) => g.hooks.map((h) => h.command));
|
|
4770
|
+
if (sessionStartCommands.some((cmd) => cmd.includes(EXE_HOOKS.sessionStart))) {
|
|
4771
|
+
return false;
|
|
4772
|
+
}
|
|
4185
4773
|
return true;
|
|
4186
4774
|
} catch {
|
|
4187
4775
|
return false;
|
|
4188
4776
|
}
|
|
4189
4777
|
}
|
|
4190
|
-
async function installCodexStatusLine(homeDir =
|
|
4778
|
+
async function installCodexStatusLine(homeDir = os11.homedir()) {
|
|
4191
4779
|
const prefs = loadPreferences(homeDir);
|
|
4192
4780
|
if (prefs.codexStatusLine === false) return "opted-out";
|
|
4193
|
-
const codexDir =
|
|
4194
|
-
const configPath =
|
|
4781
|
+
const codexDir = path14.join(homeDir, ".codex");
|
|
4782
|
+
const configPath = path14.join(codexDir, "config.toml");
|
|
4195
4783
|
await mkdir5(codexDir, { recursive: true });
|
|
4196
4784
|
let content = "";
|
|
4197
|
-
if (
|
|
4785
|
+
if (existsSync13(configPath)) {
|
|
4198
4786
|
content = await readFile5(configPath, "utf-8");
|
|
4199
4787
|
if (/\[tui\][\s\S]*?status_line\s*=/.test(content)) {
|
|
4200
4788
|
return "already-configured";
|
|
@@ -4211,53 +4799,47 @@ status_line = [${DEFAULT_CODEX_STATUS_LINE.map((s) => `"${s}"`).join(", ")}]`;
|
|
|
4211
4799
|
await writeFile5(configPath, content);
|
|
4212
4800
|
return "installed";
|
|
4213
4801
|
}
|
|
4214
|
-
function
|
|
4802
|
+
function tomlString(value) {
|
|
4803
|
+
return JSON.stringify(value);
|
|
4804
|
+
}
|
|
4805
|
+
function codexHttpHeadersToml(homeDir) {
|
|
4806
|
+
const headers = buildMcpHttpHeaders(homeDir);
|
|
4807
|
+
return `{ ${Object.entries(headers).map(([key, value]) => `${tomlString(key)} = ${tomlString(value)}`).join(", ")} }`;
|
|
4808
|
+
}
|
|
4809
|
+
function desiredCodexMcpSection(homeDir) {
|
|
4215
4810
|
return [
|
|
4216
4811
|
"[mcp_servers.exe-os]",
|
|
4217
|
-
`
|
|
4218
|
-
`
|
|
4812
|
+
`url = ${tomlString(mcpHttpUrl())}`,
|
|
4813
|
+
`http_headers = ${codexHttpHeadersToml(homeDir)}`,
|
|
4219
4814
|
`startup_timeout_sec = ${CODEX_EXE_MCP_STARTUP_TIMEOUT_SEC}`,
|
|
4220
4815
|
`tool_timeout_sec = ${CODEX_EXE_MCP_TOOL_TIMEOUT_SEC}`,
|
|
4221
4816
|
""
|
|
4222
4817
|
].join("\n");
|
|
4223
4818
|
}
|
|
4224
|
-
function reconcileCodexMcpSection(sectionContent,
|
|
4819
|
+
function reconcileCodexMcpSection(sectionContent, homeDir) {
|
|
4225
4820
|
const desiredLines = {
|
|
4226
|
-
|
|
4227
|
-
|
|
4821
|
+
url: `url = ${tomlString(mcpHttpUrl())}`,
|
|
4822
|
+
headers: `http_headers = ${codexHttpHeadersToml(homeDir)}`,
|
|
4228
4823
|
startup: `startup_timeout_sec = ${CODEX_EXE_MCP_STARTUP_TIMEOUT_SEC}`,
|
|
4229
4824
|
tool: `tool_timeout_sec = ${CODEX_EXE_MCP_TOOL_TIMEOUT_SEC}`
|
|
4230
4825
|
};
|
|
4231
4826
|
let next = sectionContent;
|
|
4232
|
-
|
|
4233
|
-
const
|
|
4234
|
-
|
|
4235
|
-
const updated = next.replace(regex, desired);
|
|
4236
|
-
if (updated !== next) {
|
|
4237
|
-
next = updated;
|
|
4238
|
-
changed = true;
|
|
4239
|
-
}
|
|
4240
|
-
return;
|
|
4241
|
-
}
|
|
4242
|
-
next = next.endsWith("\n") ? `${next}${desired}
|
|
4827
|
+
next = next.split("\n").filter((line) => !/^(command|args|env|type|url|http_headers|startup_timeout_sec|tool_timeout_sec)\s*=/.test(line.trim())).join("\n").replace(/\n{3,}/g, "\n\n");
|
|
4828
|
+
for (const line of [desiredLines.url, desiredLines.headers, desiredLines.startup, desiredLines.tool]) {
|
|
4829
|
+
next = next.endsWith("\n") ? `${next}${line}
|
|
4243
4830
|
` : `${next}
|
|
4244
|
-
${
|
|
4831
|
+
${line}
|
|
4245
4832
|
`;
|
|
4246
|
-
|
|
4247
|
-
};
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
}
|
|
4254
|
-
async function registerCodexMcpServer(packageRoot, homeDir = os10.homedir()) {
|
|
4255
|
-
const codexDir = path13.join(homeDir, ".codex");
|
|
4256
|
-
const configPath = path13.join(codexDir, "config.toml");
|
|
4257
|
-
const serverJsPath = path13.join(packageRoot, "dist", "mcp", "server.js");
|
|
4833
|
+
}
|
|
4834
|
+
return { content: next, changed: next !== sectionContent };
|
|
4835
|
+
}
|
|
4836
|
+
async function registerCodexMcpServer(packageRoot, homeDir = os11.homedir()) {
|
|
4837
|
+
const codexDir = path14.join(homeDir, ".codex");
|
|
4838
|
+
const configPath = path14.join(codexDir, "config.toml");
|
|
4839
|
+
void packageRoot;
|
|
4258
4840
|
await mkdir5(codexDir, { recursive: true });
|
|
4259
4841
|
let content = "";
|
|
4260
|
-
if (
|
|
4842
|
+
if (existsSync13(configPath)) {
|
|
4261
4843
|
content = await readFile5(configPath, "utf-8");
|
|
4262
4844
|
}
|
|
4263
4845
|
const sectionHeader = "[mcp_servers.exe-os]";
|
|
@@ -4267,7 +4849,7 @@ async function registerCodexMcpServer(packageRoot, homeDir = os10.homedir()) {
|
|
|
4267
4849
|
const nextSectionMatch = afterHeader.match(/\n\[(?!mcp_servers\.exe-os)/);
|
|
4268
4850
|
const sectionEnd = nextSectionMatch ? headerIndex + sectionHeader.length + nextSectionMatch.index : content.length;
|
|
4269
4851
|
const sectionContent = content.slice(headerIndex, sectionEnd);
|
|
4270
|
-
const reconciled = reconcileCodexMcpSection(sectionContent,
|
|
4852
|
+
const reconciled = reconcileCodexMcpSection(sectionContent, homeDir);
|
|
4271
4853
|
if (!reconciled.changed) {
|
|
4272
4854
|
return "already-registered";
|
|
4273
4855
|
}
|
|
@@ -4275,17 +4857,17 @@ async function registerCodexMcpServer(packageRoot, homeDir = os10.homedir()) {
|
|
|
4275
4857
|
await writeFile5(configPath, content);
|
|
4276
4858
|
return "updated";
|
|
4277
4859
|
}
|
|
4278
|
-
const newSection = desiredCodexMcpSection(
|
|
4860
|
+
const newSection = desiredCodexMcpSection(homeDir);
|
|
4279
4861
|
const separator = content.length > 0 && !content.endsWith("\n") ? "\n\n" : content.length > 0 ? "\n" : "";
|
|
4280
4862
|
content = content + separator + newSection;
|
|
4281
4863
|
await writeFile5(configPath, content);
|
|
4282
4864
|
return "registered";
|
|
4283
4865
|
}
|
|
4284
|
-
async function ensureCodexHooksFeature(homeDir =
|
|
4285
|
-
const configPath =
|
|
4286
|
-
await mkdir5(
|
|
4866
|
+
async function ensureCodexHooksFeature(homeDir = os11.homedir()) {
|
|
4867
|
+
const configPath = path14.join(homeDir, ".codex", "config.toml");
|
|
4868
|
+
await mkdir5(path14.join(homeDir, ".codex"), { recursive: true });
|
|
4287
4869
|
let content = "";
|
|
4288
|
-
if (
|
|
4870
|
+
if (existsSync13(configPath)) {
|
|
4289
4871
|
content = await readFile5(configPath, "utf-8");
|
|
4290
4872
|
}
|
|
4291
4873
|
if (/\[features\][\s\S]*?codex_hooks\s*=\s*true/.test(content)) {
|
|
@@ -4340,6 +4922,7 @@ var init_installer2 = __esm({
|
|
|
4340
4922
|
init_installer();
|
|
4341
4923
|
init_preferences();
|
|
4342
4924
|
init_runtime_hook_manifest();
|
|
4925
|
+
init_mcp_http_config();
|
|
4343
4926
|
DEFAULT_CODEX_STATUS_LINE = [
|
|
4344
4927
|
"model-with-reasoning",
|
|
4345
4928
|
"current-dir",
|
|
@@ -4366,20 +4949,20 @@ __export(agent_config_exports, {
|
|
|
4366
4949
|
saveAgentConfig: () => saveAgentConfig,
|
|
4367
4950
|
setAgentRuntime: () => setAgentRuntime
|
|
4368
4951
|
});
|
|
4369
|
-
import { readFileSync as
|
|
4370
|
-
import
|
|
4952
|
+
import { readFileSync as readFileSync10, writeFileSync as writeFileSync8, existsSync as existsSync14 } from "fs";
|
|
4953
|
+
import path15 from "path";
|
|
4371
4954
|
function loadAgentConfig() {
|
|
4372
|
-
if (!
|
|
4955
|
+
if (!existsSync14(AGENT_CONFIG_PATH)) return {};
|
|
4373
4956
|
try {
|
|
4374
|
-
return JSON.parse(
|
|
4957
|
+
return JSON.parse(readFileSync10(AGENT_CONFIG_PATH, "utf-8"));
|
|
4375
4958
|
} catch {
|
|
4376
4959
|
return {};
|
|
4377
4960
|
}
|
|
4378
4961
|
}
|
|
4379
4962
|
function saveAgentConfig(config) {
|
|
4380
|
-
const dir =
|
|
4963
|
+
const dir = path15.dirname(AGENT_CONFIG_PATH);
|
|
4381
4964
|
ensurePrivateDirSync(dir);
|
|
4382
|
-
|
|
4965
|
+
writeFileSync8(AGENT_CONFIG_PATH, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
4383
4966
|
enforcePrivateFileSync(AGENT_CONFIG_PATH);
|
|
4384
4967
|
}
|
|
4385
4968
|
function getAgentRuntime(agentId) {
|
|
@@ -4423,7 +5006,7 @@ var init_agent_config = __esm({
|
|
|
4423
5006
|
init_config();
|
|
4424
5007
|
init_runtime_table();
|
|
4425
5008
|
init_secure_files();
|
|
4426
|
-
AGENT_CONFIG_PATH =
|
|
5009
|
+
AGENT_CONFIG_PATH = path15.join(EXE_AI_DIR, "agent-config.json");
|
|
4427
5010
|
KNOWN_RUNTIMES = {
|
|
4428
5011
|
claude: ["claude-opus-4.6", "claude-opus-4", "claude-sonnet-4.6", "claude-sonnet-4", "claude-haiku-4.5"],
|
|
4429
5012
|
codex: ["gpt-5.4", "gpt-5.5", "gpt-5.3-codex-spark", "o3", "o4-mini"],
|
|
@@ -4443,13 +5026,13 @@ var init_agent_config = __esm({
|
|
|
4443
5026
|
});
|
|
4444
5027
|
|
|
4445
5028
|
// src/bin/exe-start-codex.ts
|
|
4446
|
-
import
|
|
4447
|
-
import
|
|
5029
|
+
import os12 from "os";
|
|
5030
|
+
import path16 from "path";
|
|
4448
5031
|
import {
|
|
4449
|
-
existsSync as
|
|
4450
|
-
readFileSync as
|
|
4451
|
-
writeFileSync as
|
|
4452
|
-
mkdirSync as
|
|
5032
|
+
existsSync as existsSync15,
|
|
5033
|
+
readFileSync as readFileSync11,
|
|
5034
|
+
writeFileSync as writeFileSync9,
|
|
5035
|
+
mkdirSync as mkdirSync8,
|
|
4453
5036
|
readdirSync as readdirSync4
|
|
4454
5037
|
} from "fs";
|
|
4455
5038
|
import { spawnSync } from "child_process";
|
|
@@ -4460,11 +5043,12 @@ init_database();
|
|
|
4460
5043
|
|
|
4461
5044
|
// src/lib/keychain.ts
|
|
4462
5045
|
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
4463
|
-
import { existsSync as existsSync6 } from "fs";
|
|
5046
|
+
import { existsSync as existsSync6, statSync as statSync2 } from "fs";
|
|
4464
5047
|
import { execSync as execSync2 } from "child_process";
|
|
4465
5048
|
import path6 from "path";
|
|
4466
5049
|
import os5 from "os";
|
|
4467
|
-
var SERVICE = "exe-
|
|
5050
|
+
var SERVICE = "exe-os";
|
|
5051
|
+
var LEGACY_SERVICE = "exe-mem";
|
|
4468
5052
|
var ACCOUNT = "master-key";
|
|
4469
5053
|
function getKeyDir() {
|
|
4470
5054
|
return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path6.join(os5.homedir(), ".exe-os");
|
|
@@ -4472,29 +5056,79 @@ function getKeyDir() {
|
|
|
4472
5056
|
function getKeyPath() {
|
|
4473
5057
|
return path6.join(getKeyDir(), "master.key");
|
|
4474
5058
|
}
|
|
4475
|
-
function
|
|
5059
|
+
function nativeKeychainAllowed() {
|
|
5060
|
+
return process.env.EXE_OS_DISABLE_NATIVE_KEYCHAIN !== "1";
|
|
5061
|
+
}
|
|
5062
|
+
var linuxSecretAvailability = null;
|
|
5063
|
+
function linuxSecretAvailable() {
|
|
5064
|
+
if (!nativeKeychainAllowed()) return false;
|
|
5065
|
+
if (process.platform !== "linux") return false;
|
|
5066
|
+
if (linuxSecretAvailability !== null) return linuxSecretAvailability;
|
|
5067
|
+
try {
|
|
5068
|
+
execSync2("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
|
|
5069
|
+
} catch {
|
|
5070
|
+
linuxSecretAvailability = false;
|
|
5071
|
+
return false;
|
|
5072
|
+
}
|
|
5073
|
+
try {
|
|
5074
|
+
execSync2("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
|
|
5075
|
+
linuxSecretAvailability = true;
|
|
5076
|
+
} catch {
|
|
5077
|
+
linuxSecretAvailability = false;
|
|
5078
|
+
}
|
|
5079
|
+
return linuxSecretAvailability;
|
|
5080
|
+
}
|
|
5081
|
+
function isRootOnlyTrustedServerKeyFile(keyPath) {
|
|
5082
|
+
if (process.platform !== "linux") return false;
|
|
5083
|
+
try {
|
|
5084
|
+
const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
|
|
5085
|
+
const st = statSync2(keyPath);
|
|
5086
|
+
if (!st.isFile() || (st.mode & 63) !== 0) return false;
|
|
5087
|
+
if (uid === 0) return true;
|
|
5088
|
+
const exeOsDir = process.env.EXE_OS_DIR;
|
|
5089
|
+
return Boolean(exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep));
|
|
5090
|
+
} catch {
|
|
5091
|
+
return false;
|
|
5092
|
+
}
|
|
5093
|
+
}
|
|
5094
|
+
function macKeychainGet(service = SERVICE) {
|
|
5095
|
+
if (!nativeKeychainAllowed()) return null;
|
|
4476
5096
|
if (process.platform !== "darwin") return null;
|
|
4477
5097
|
try {
|
|
4478
5098
|
return execSync2(
|
|
4479
|
-
`security find-generic-password -s "${
|
|
5099
|
+
`security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
|
|
4480
5100
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
4481
5101
|
).trim();
|
|
4482
5102
|
} catch {
|
|
4483
5103
|
return null;
|
|
4484
5104
|
}
|
|
4485
5105
|
}
|
|
4486
|
-
function macKeychainSet(value) {
|
|
5106
|
+
function macKeychainSet(value, service = SERVICE) {
|
|
5107
|
+
if (!nativeKeychainAllowed()) return false;
|
|
4487
5108
|
if (process.platform !== "darwin") return false;
|
|
4488
5109
|
try {
|
|
4489
5110
|
try {
|
|
4490
5111
|
execSync2(
|
|
4491
|
-
`security delete-generic-password -s "${
|
|
5112
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
4492
5113
|
{ timeout: 5e3 }
|
|
4493
5114
|
);
|
|
4494
5115
|
} catch {
|
|
4495
5116
|
}
|
|
4496
5117
|
execSync2(
|
|
4497
|
-
`security add-generic-password -s "${
|
|
5118
|
+
`security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
|
|
5119
|
+
{ timeout: 5e3 }
|
|
5120
|
+
);
|
|
5121
|
+
return true;
|
|
5122
|
+
} catch {
|
|
5123
|
+
return false;
|
|
5124
|
+
}
|
|
5125
|
+
}
|
|
5126
|
+
function macKeychainDelete(service = SERVICE) {
|
|
5127
|
+
if (!nativeKeychainAllowed()) return false;
|
|
5128
|
+
if (process.platform !== "darwin") return false;
|
|
5129
|
+
try {
|
|
5130
|
+
execSync2(
|
|
5131
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
4498
5132
|
{ timeout: 5e3 }
|
|
4499
5133
|
);
|
|
4500
5134
|
return true;
|
|
@@ -4502,22 +5136,35 @@ function macKeychainSet(value) {
|
|
|
4502
5136
|
return false;
|
|
4503
5137
|
}
|
|
4504
5138
|
}
|
|
4505
|
-
function linuxSecretGet() {
|
|
4506
|
-
if (
|
|
5139
|
+
function linuxSecretGet(service = SERVICE) {
|
|
5140
|
+
if (!linuxSecretAvailable()) return null;
|
|
4507
5141
|
try {
|
|
4508
5142
|
return execSync2(
|
|
4509
|
-
`secret-tool lookup service "${
|
|
5143
|
+
`secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
4510
5144
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
4511
5145
|
).trim();
|
|
4512
5146
|
} catch {
|
|
4513
5147
|
return null;
|
|
4514
5148
|
}
|
|
4515
5149
|
}
|
|
4516
|
-
function linuxSecretSet(value) {
|
|
5150
|
+
function linuxSecretSet(value, service = SERVICE) {
|
|
5151
|
+
if (!linuxSecretAvailable()) return false;
|
|
5152
|
+
try {
|
|
5153
|
+
execSync2(
|
|
5154
|
+
`echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
5155
|
+
{ timeout: 5e3 }
|
|
5156
|
+
);
|
|
5157
|
+
return true;
|
|
5158
|
+
} catch {
|
|
5159
|
+
return false;
|
|
5160
|
+
}
|
|
5161
|
+
}
|
|
5162
|
+
function linuxSecretDelete(service = SERVICE) {
|
|
5163
|
+
if (!nativeKeychainAllowed()) return false;
|
|
4517
5164
|
if (process.platform !== "linux") return false;
|
|
4518
5165
|
try {
|
|
4519
5166
|
execSync2(
|
|
4520
|
-
`
|
|
5167
|
+
`secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
4521
5168
|
{ timeout: 5e3 }
|
|
4522
5169
|
);
|
|
4523
5170
|
return true;
|
|
@@ -4526,6 +5173,7 @@ function linuxSecretSet(value) {
|
|
|
4526
5173
|
}
|
|
4527
5174
|
}
|
|
4528
5175
|
async function tryKeytar() {
|
|
5176
|
+
if (!nativeKeychainAllowed()) return null;
|
|
4529
5177
|
try {
|
|
4530
5178
|
return await import("keytar");
|
|
4531
5179
|
} catch {
|
|
@@ -4551,8 +5199,8 @@ function deriveMachineKey() {
|
|
|
4551
5199
|
}
|
|
4552
5200
|
function readMachineId() {
|
|
4553
5201
|
try {
|
|
4554
|
-
const { readFileSync:
|
|
4555
|
-
return
|
|
5202
|
+
const { readFileSync: readFileSync12 } = __require("fs");
|
|
5203
|
+
return readFileSync12("/etc/machine-id", "utf-8").trim();
|
|
4556
5204
|
} catch {
|
|
4557
5205
|
return "";
|
|
4558
5206
|
}
|
|
@@ -4600,7 +5248,19 @@ async function writeMachineBoundFileFallback(b64) {
|
|
|
4600
5248
|
return "plaintext";
|
|
4601
5249
|
}
|
|
4602
5250
|
async function getMasterKey() {
|
|
4603
|
-
|
|
5251
|
+
let nativeValue = macKeychainGet() ?? linuxSecretGet();
|
|
5252
|
+
if (!nativeValue) {
|
|
5253
|
+
const legacyValue = macKeychainGet(LEGACY_SERVICE) ?? linuxSecretGet(LEGACY_SERVICE);
|
|
5254
|
+
if (legacyValue) {
|
|
5255
|
+
const migrated = macKeychainSet(legacyValue) || linuxSecretSet(legacyValue);
|
|
5256
|
+
if (migrated) {
|
|
5257
|
+
macKeychainDelete(LEGACY_SERVICE);
|
|
5258
|
+
linuxSecretDelete(LEGACY_SERVICE);
|
|
5259
|
+
process.stderr.write("[keychain] Migrated keychain service from exe-mem to exe-os.\n");
|
|
5260
|
+
}
|
|
5261
|
+
nativeValue = legacyValue;
|
|
5262
|
+
}
|
|
5263
|
+
}
|
|
4604
5264
|
if (nativeValue) {
|
|
4605
5265
|
return Buffer.from(nativeValue, "base64");
|
|
4606
5266
|
}
|
|
@@ -4608,12 +5268,17 @@ async function getMasterKey() {
|
|
|
4608
5268
|
if (keytar) {
|
|
4609
5269
|
try {
|
|
4610
5270
|
const keytarValue = await keytar.getPassword(SERVICE, ACCOUNT);
|
|
4611
|
-
|
|
4612
|
-
|
|
5271
|
+
const legacyKeytarValue = keytarValue ?? await keytar.getPassword(LEGACY_SERVICE, ACCOUNT);
|
|
5272
|
+
if (legacyKeytarValue) {
|
|
5273
|
+
const migrated = macKeychainSet(legacyKeytarValue) || linuxSecretSet(legacyKeytarValue);
|
|
4613
5274
|
if (migrated) {
|
|
4614
5275
|
process.stderr.write("[keychain] Migrated key from keytar to native keychain.\n");
|
|
5276
|
+
try {
|
|
5277
|
+
await keytar.deletePassword(LEGACY_SERVICE, ACCOUNT);
|
|
5278
|
+
} catch {
|
|
5279
|
+
}
|
|
4615
5280
|
}
|
|
4616
|
-
return Buffer.from(
|
|
5281
|
+
return Buffer.from(legacyKeytarValue, "base64");
|
|
4617
5282
|
}
|
|
4618
5283
|
} catch {
|
|
4619
5284
|
}
|
|
@@ -4638,7 +5303,7 @@ async function getMasterKey() {
|
|
|
4638
5303
|
const decrypted = decryptWithMachineKey(content, machineKey);
|
|
4639
5304
|
if (!decrypted) {
|
|
4640
5305
|
process.stderr.write(
|
|
4641
|
-
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase: exe-os
|
|
5306
|
+
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase during setup: exe-os setup\n"
|
|
4642
5307
|
);
|
|
4643
5308
|
return null;
|
|
4644
5309
|
}
|
|
@@ -4647,6 +5312,9 @@ async function getMasterKey() {
|
|
|
4647
5312
|
b64Value = content;
|
|
4648
5313
|
}
|
|
4649
5314
|
const key = Buffer.from(b64Value, "base64");
|
|
5315
|
+
if (!content.startsWith(ENCRYPTED_PREFIX) && isRootOnlyTrustedServerKeyFile(keyPath)) {
|
|
5316
|
+
return key;
|
|
5317
|
+
}
|
|
4650
5318
|
const migrated = macKeychainSet(b64Value) || linuxSecretSet(b64Value);
|
|
4651
5319
|
if (migrated) {
|
|
4652
5320
|
process.stderr.write("[keychain] Migrated key from file to native keychain.\n");
|
|
@@ -5013,6 +5681,11 @@ async function flushBatch() {
|
|
|
5013
5681
|
await insertMemoryCardsForBatch2(batch);
|
|
5014
5682
|
} catch {
|
|
5015
5683
|
}
|
|
5684
|
+
try {
|
|
5685
|
+
const { insertOntologyForBatch: insertOntologyForBatch2 } = await Promise.resolve().then(() => (init_agentic_ontology(), agentic_ontology_exports));
|
|
5686
|
+
await insertOntologyForBatch2(batch);
|
|
5687
|
+
} catch {
|
|
5688
|
+
}
|
|
5016
5689
|
schedulePostWriteMemoryHygiene(batch.map((row) => row.id));
|
|
5017
5690
|
_pendingRecords.splice(0, batch.length);
|
|
5018
5691
|
try {
|
|
@@ -5081,7 +5754,7 @@ import {
|
|
|
5081
5754
|
existsSync as existsSync8,
|
|
5082
5755
|
mkdirSync as mkdirSync3,
|
|
5083
5756
|
readdirSync as readdirSync2,
|
|
5084
|
-
statSync as
|
|
5757
|
+
statSync as statSync4,
|
|
5085
5758
|
unlinkSync as unlinkSync3,
|
|
5086
5759
|
writeFileSync as writeFileSync3
|
|
5087
5760
|
} from "fs";
|
|
@@ -5153,7 +5826,7 @@ function sweepStaleBehaviorExports(now = Date.now()) {
|
|
|
5153
5826
|
for (const entry of entries) {
|
|
5154
5827
|
const filePath = path8.join(BEHAVIORS_EXPORT_DIR, entry);
|
|
5155
5828
|
try {
|
|
5156
|
-
const stat =
|
|
5829
|
+
const stat = statSync4(filePath);
|
|
5157
5830
|
if (now - stat.mtimeMs > STALE_EXPORT_AGE_MS) {
|
|
5158
5831
|
unlinkSync3(filePath);
|
|
5159
5832
|
}
|
|
@@ -5231,7 +5904,7 @@ When done with a task: call update_task with status "done" and a result summary.
|
|
|
5231
5904
|
Always call store_memory to persist important decisions.
|
|
5232
5905
|
`;
|
|
5233
5906
|
function resolveAgent(argv) {
|
|
5234
|
-
const invokedAs =
|
|
5907
|
+
const invokedAs = path16.basename(argv[1] ?? "");
|
|
5235
5908
|
if (invokedAs && invokedAs !== "exe-start-codex" && !invokedAs.endsWith(".js")) {
|
|
5236
5909
|
const agent2 = invokedAs.replace(/-codex$/, "").toLowerCase();
|
|
5237
5910
|
return { agent: agent2, passthrough: argv.slice(2) };
|
|
@@ -5257,24 +5930,24 @@ function resolveAgent(argv) {
|
|
|
5257
5930
|
return { agent, passthrough, sessionName };
|
|
5258
5931
|
}
|
|
5259
5932
|
function loadIdentity(agent) {
|
|
5260
|
-
const dir =
|
|
5261
|
-
const exact =
|
|
5262
|
-
if (
|
|
5263
|
-
const content =
|
|
5933
|
+
const dir = path16.join(os12.homedir(), ".exe-os", "identity");
|
|
5934
|
+
const exact = path16.join(dir, `${agent}.md`);
|
|
5935
|
+
if (existsSync15(exact)) {
|
|
5936
|
+
const content = readFileSync11(exact, "utf-8").trim();
|
|
5264
5937
|
if (content) return content;
|
|
5265
5938
|
}
|
|
5266
5939
|
try {
|
|
5267
5940
|
const files = readdirSync4(dir);
|
|
5268
5941
|
const match = files.find((f) => f.toLowerCase() === `${agent.toLowerCase()}.md`);
|
|
5269
5942
|
if (match) {
|
|
5270
|
-
const content =
|
|
5943
|
+
const content = readFileSync11(path16.join(dir, match), "utf-8").trim();
|
|
5271
5944
|
if (content) return content;
|
|
5272
5945
|
}
|
|
5273
5946
|
} catch {
|
|
5274
5947
|
}
|
|
5275
5948
|
try {
|
|
5276
|
-
const rosterPath =
|
|
5277
|
-
const roster = JSON.parse(
|
|
5949
|
+
const rosterPath = path16.join(os12.homedir(), ".exe-os", "exe-employees.json");
|
|
5950
|
+
const roster = JSON.parse(readFileSync11(rosterPath, "utf8"));
|
|
5278
5951
|
const emp = roster.find((e) => e.name.toLowerCase() === agent.toLowerCase());
|
|
5279
5952
|
if (emp?.systemPrompt && emp.systemPrompt.trim().length > 20) {
|
|
5280
5953
|
return emp.systemPrompt;
|
|
@@ -5284,22 +5957,22 @@ function loadIdentity(agent) {
|
|
|
5284
5957
|
return null;
|
|
5285
5958
|
}
|
|
5286
5959
|
function writePromptFile(agent, identity, behaviorsPath, globalProcedures) {
|
|
5287
|
-
const promptDir =
|
|
5288
|
-
|
|
5960
|
+
const promptDir = path16.join(os12.homedir(), ".exe-os", "codex-prompt");
|
|
5961
|
+
mkdirSync8(promptDir, { recursive: true });
|
|
5289
5962
|
let prompt = "";
|
|
5290
5963
|
if (globalProcedures) {
|
|
5291
5964
|
prompt += globalProcedures + "\n\n";
|
|
5292
5965
|
}
|
|
5293
5966
|
prompt += identity;
|
|
5294
|
-
if (behaviorsPath &&
|
|
5295
|
-
const behaviors =
|
|
5967
|
+
if (behaviorsPath && existsSync15(behaviorsPath)) {
|
|
5968
|
+
const behaviors = readFileSync11(behaviorsPath, "utf-8").trim();
|
|
5296
5969
|
if (behaviors) {
|
|
5297
5970
|
prompt += "\n\n" + behaviors;
|
|
5298
5971
|
}
|
|
5299
5972
|
}
|
|
5300
5973
|
prompt += "\n" + BOOT_INSTRUCTIONS;
|
|
5301
|
-
const outPath =
|
|
5302
|
-
|
|
5974
|
+
const outPath = path16.join(promptDir, `${agent}.md`);
|
|
5975
|
+
writeFileSync9(outPath, prompt, "utf-8");
|
|
5303
5976
|
return outPath;
|
|
5304
5977
|
}
|
|
5305
5978
|
async function main() {
|
|
@@ -5390,8 +6063,8 @@ async function main() {
|
|
|
5390
6063
|
process.env.EXE_RUNTIME = "codex";
|
|
5391
6064
|
const empRole = (() => {
|
|
5392
6065
|
try {
|
|
5393
|
-
const emps =
|
|
5394
|
-
|
|
6066
|
+
const emps = readFileSync11(
|
|
6067
|
+
path16.join(os12.homedir(), ".exe-os", "exe-employees.json"),
|
|
5395
6068
|
"utf-8"
|
|
5396
6069
|
);
|
|
5397
6070
|
const found = JSON.parse(emps).find(
|
|
@@ -5428,14 +6101,14 @@ async function main() {
|
|
|
5428
6101
|
if (WORKTREE_ROLES.has(empRole)) {
|
|
5429
6102
|
try {
|
|
5430
6103
|
const { execSync: es } = await import("child_process");
|
|
5431
|
-
const worktreeDir =
|
|
6104
|
+
const worktreeDir = path16.join(process.cwd(), ".worktrees", worktreeName);
|
|
5432
6105
|
const branchName = `${worktreeName}/codex-${Date.now()}`;
|
|
5433
|
-
if (
|
|
6106
|
+
if (existsSync15(worktreeDir)) {
|
|
5434
6107
|
worktreePath = worktreeDir;
|
|
5435
6108
|
process.stderr.write(`[exe-start-codex] Reusing worktree at ${worktreeDir}
|
|
5436
6109
|
`);
|
|
5437
6110
|
} else {
|
|
5438
|
-
|
|
6111
|
+
mkdirSync8(path16.dirname(worktreeDir), { recursive: true });
|
|
5439
6112
|
es(`git worktree add "${worktreeDir}" -b "${branchName}" HEAD`, {
|
|
5440
6113
|
encoding: "utf-8",
|
|
5441
6114
|
timeout: 3e4
|