@askexenow/exe-os 0.9.65 → 0.9.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deploy/stack-manifests/v0.9.json +54 -5
- package/dist/bin/age-ontology-load.js +61 -0
- package/dist/bin/agentic-ontology-backfill.js +4708 -0
- package/dist/bin/agentic-reflection-backfill.js +4144 -0
- package/dist/bin/{exe-link.js → agentic-semantic-label.js} +1532 -2173
- package/dist/bin/backfill-conversations.js +528 -20
- package/dist/bin/backfill-responses.js +528 -20
- package/dist/bin/backfill-vectors.js +255 -20
- package/dist/bin/bulk-sync-postgres.js +4876 -0
- package/dist/bin/cleanup-stale-review-tasks.js +529 -21
- package/dist/bin/cli.js +3471 -1491
- package/dist/bin/exe-agent-config.js +4 -0
- package/dist/bin/exe-agent.js +16 -0
- package/dist/bin/exe-assign.js +528 -20
- package/dist/bin/exe-boot.js +492 -54
- package/dist/bin/exe-call.js +16 -0
- package/dist/bin/exe-cloud.js +7415 -518
- package/dist/bin/exe-dispatch.js +540 -22
- package/dist/bin/exe-doctor.js +3404 -1225
- package/dist/bin/exe-export-behaviors.js +542 -24
- package/dist/bin/exe-forget.js +529 -21
- package/dist/bin/exe-gateway.js +595 -25
- package/dist/bin/exe-heartbeat.js +541 -24
- package/dist/bin/exe-kill.js +529 -21
- package/dist/bin/exe-launch-agent.js +2334 -1067
- package/dist/bin/exe-new-employee.js +324 -166
- package/dist/bin/exe-pending-messages.js +529 -21
- package/dist/bin/exe-pending-notifications.js +529 -21
- package/dist/bin/exe-pending-reviews.js +529 -21
- package/dist/bin/exe-rename.js +529 -21
- package/dist/bin/exe-review.js +529 -21
- package/dist/bin/exe-search.js +542 -24
- package/dist/bin/exe-session-cleanup.js +540 -22
- package/dist/bin/exe-settings.js +14 -0
- package/dist/bin/exe-start-codex.js +817 -144
- package/dist/bin/exe-start-opencode.js +776 -80
- package/dist/bin/exe-status.js +529 -21
- package/dist/bin/exe-team.js +529 -21
- package/dist/bin/git-sweep.js +540 -22
- package/dist/bin/graph-backfill.js +580 -21
- package/dist/bin/graph-export.js +529 -21
- package/dist/bin/graph-layer-benchmark.js +109 -0
- package/dist/bin/install.js +420 -289
- package/dist/bin/intercom-check.js +540 -22
- package/dist/bin/postgres-agentic-reflection-backfill.js +187 -0
- package/dist/bin/postgres-agentic-semantic-backfill.js +237 -0
- package/dist/bin/scan-tasks.js +540 -22
- package/dist/bin/setup.js +790 -206
- package/dist/bin/shard-migrate.js +528 -20
- package/dist/bin/update.js +4 -0
- package/dist/gateway/index.js +593 -23
- package/dist/hooks/bug-report-worker.js +651 -64
- package/dist/hooks/codex-stop-task-finalizer.js +540 -22
- package/dist/hooks/commit-complete.js +540 -22
- package/dist/hooks/error-recall.js +542 -24
- package/dist/hooks/exe-heartbeat-hook.js +4 -0
- package/dist/hooks/ingest-worker.js +4 -0
- package/dist/hooks/ingest.js +539 -22
- package/dist/hooks/instructions-loaded.js +529 -21
- package/dist/hooks/notification.js +529 -21
- package/dist/hooks/post-compact.js +529 -21
- package/dist/hooks/post-tool-combined.js +543 -25
- package/dist/hooks/pre-compact.js +772 -127
- package/dist/hooks/pre-tool-use.js +529 -21
- package/dist/hooks/prompt-submit.js +543 -25
- package/dist/hooks/session-end.js +673 -140
- package/dist/hooks/session-start.js +662 -26
- package/dist/hooks/stop.js +540 -23
- package/dist/hooks/subagent-stop.js +529 -21
- package/dist/hooks/summary-worker.js +571 -126
- package/dist/index.js +593 -23
- package/dist/lib/agent-config.js +4 -0
- package/dist/lib/cloud-sync.js +408 -47
- package/dist/lib/config.js +25 -1
- package/dist/lib/consolidation.js +5 -1
- package/dist/lib/database.js +128 -0
- package/dist/lib/db-daemon-client.js +4 -0
- package/dist/lib/db.js +128 -0
- package/dist/lib/device-registry.js +128 -0
- package/dist/lib/embedder.js +25 -1
- package/dist/lib/employee-templates.js +16 -0
- package/dist/lib/employees.js +4 -0
- package/dist/lib/exe-daemon-client.js +4 -0
- package/dist/lib/exe-daemon.js +3158 -930
- package/dist/lib/hybrid-search.js +542 -24
- package/dist/lib/identity.js +7 -0
- package/dist/lib/keychain.js +178 -22
- package/dist/lib/license.js +4 -0
- package/dist/lib/messaging.js +7 -0
- package/dist/lib/reminders.js +7 -0
- package/dist/lib/schedules.js +255 -20
- package/dist/lib/skill-learning.js +28 -1
- package/dist/lib/status-brief.js +39 -0
- package/dist/lib/store.js +528 -20
- package/dist/lib/task-router.js +4 -0
- package/dist/lib/tasks.js +28 -1
- package/dist/lib/tmux-routing.js +28 -1
- package/dist/lib/token-spend.js +7 -0
- package/dist/mcp/server.js +2739 -813
- package/dist/mcp/tools/complete-reminder.js +7 -0
- package/dist/mcp/tools/create-reminder.js +7 -0
- package/dist/mcp/tools/create-task.js +28 -1
- package/dist/mcp/tools/deactivate-behavior.js +7 -0
- package/dist/mcp/tools/list-reminders.js +7 -0
- package/dist/mcp/tools/list-tasks.js +7 -0
- package/dist/mcp/tools/send-message.js +7 -0
- package/dist/mcp/tools/update-task.js +28 -1
- package/dist/runtime/index.js +540 -22
- package/dist/tui/App.js +618 -29
- package/package.json +9 -5
- package/src/commands/exe/cloud.md +11 -8
- package/stack.release.json +3 -3
- package/src/commands/exe/link.md +0 -17
|
@@ -149,6 +149,11 @@ function normalizeAutoUpdate(raw) {
|
|
|
149
149
|
const userAU = raw.autoUpdate ?? {};
|
|
150
150
|
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
151
151
|
}
|
|
152
|
+
function normalizeOrchestration(raw) {
|
|
153
|
+
const defaultOrg = DEFAULT_CONFIG.orchestration;
|
|
154
|
+
const userOrg = raw.orchestration ?? {};
|
|
155
|
+
raw.orchestration = { ...defaultOrg, ...userOrg };
|
|
156
|
+
}
|
|
152
157
|
async function loadConfig() {
|
|
153
158
|
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
154
159
|
await ensurePrivateDir(dir);
|
|
@@ -173,10 +178,15 @@ async function loadConfig() {
|
|
|
173
178
|
normalizeScalingRoadmap(migratedCfg);
|
|
174
179
|
normalizeSessionLifecycle(migratedCfg);
|
|
175
180
|
normalizeAutoUpdate(migratedCfg);
|
|
181
|
+
normalizeOrchestration(migratedCfg);
|
|
176
182
|
const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
|
|
177
183
|
if (config.dbPath.startsWith("~")) {
|
|
178
184
|
config.dbPath = config.dbPath.replace(/^~/, os.homedir());
|
|
179
185
|
}
|
|
186
|
+
const envDbPath = path.join(dir, "memories.db");
|
|
187
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync2(config.dbPath) && existsSync2(envDbPath)) {
|
|
188
|
+
config.dbPath = envDbPath;
|
|
189
|
+
}
|
|
180
190
|
return config;
|
|
181
191
|
} catch {
|
|
182
192
|
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
@@ -196,7 +206,16 @@ function loadConfigSync() {
|
|
|
196
206
|
normalizeScalingRoadmap(migratedCfg);
|
|
197
207
|
normalizeSessionLifecycle(migratedCfg);
|
|
198
208
|
normalizeAutoUpdate(migratedCfg);
|
|
199
|
-
|
|
209
|
+
normalizeOrchestration(migratedCfg);
|
|
210
|
+
const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
|
|
211
|
+
if (config.dbPath.startsWith("~")) {
|
|
212
|
+
config.dbPath = config.dbPath.replace(/^~/, os.homedir());
|
|
213
|
+
}
|
|
214
|
+
const envDbPath = path.join(dir, "memories.db");
|
|
215
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync2(config.dbPath) && existsSync2(envDbPath)) {
|
|
216
|
+
config.dbPath = envDbPath;
|
|
217
|
+
}
|
|
218
|
+
return config;
|
|
200
219
|
} catch {
|
|
201
220
|
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
202
221
|
}
|
|
@@ -217,6 +236,7 @@ async function loadConfigFrom(configPath) {
|
|
|
217
236
|
normalizeScalingRoadmap(migratedCfg);
|
|
218
237
|
normalizeSessionLifecycle(migratedCfg);
|
|
219
238
|
normalizeAutoUpdate(migratedCfg);
|
|
239
|
+
normalizeOrchestration(migratedCfg);
|
|
220
240
|
return { ...DEFAULT_CONFIG, ...migratedCfg };
|
|
221
241
|
} catch {
|
|
222
242
|
return { ...DEFAULT_CONFIG };
|
|
@@ -288,6 +308,10 @@ var init_config = __esm({
|
|
|
288
308
|
checkOnBoot: true,
|
|
289
309
|
autoInstall: false,
|
|
290
310
|
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
311
|
+
},
|
|
312
|
+
orchestration: {
|
|
313
|
+
phase: "phase_1_coo",
|
|
314
|
+
phaseSetBy: "default"
|
|
291
315
|
}
|
|
292
316
|
};
|
|
293
317
|
CONFIG_MIGRATIONS = [
|
|
@@ -2134,6 +2158,9 @@ function getClient() {
|
|
|
2134
2158
|
if (_daemonClient && _daemonClient._isDaemonActive()) {
|
|
2135
2159
|
return _daemonClient;
|
|
2136
2160
|
}
|
|
2161
|
+
if (!_resilientClient) {
|
|
2162
|
+
return _adapterClient;
|
|
2163
|
+
}
|
|
2137
2164
|
return _resilientClient;
|
|
2138
2165
|
}
|
|
2139
2166
|
async function initDaemonClient() {
|
|
@@ -3166,6 +3193,127 @@ async function ensureSchema() {
|
|
|
3166
3193
|
VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
|
|
3167
3194
|
END;
|
|
3168
3195
|
`);
|
|
3196
|
+
await client.executeMultiple(`
|
|
3197
|
+
CREATE TABLE IF NOT EXISTS agent_sessions (
|
|
3198
|
+
id TEXT PRIMARY KEY,
|
|
3199
|
+
agent_id TEXT NOT NULL,
|
|
3200
|
+
project_name TEXT,
|
|
3201
|
+
started_at TEXT NOT NULL,
|
|
3202
|
+
last_event_at TEXT NOT NULL,
|
|
3203
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
3204
|
+
properties TEXT DEFAULT '{}'
|
|
3205
|
+
);
|
|
3206
|
+
|
|
3207
|
+
CREATE INDEX IF NOT EXISTS idx_agent_sessions_agent_time
|
|
3208
|
+
ON agent_sessions(agent_id, started_at);
|
|
3209
|
+
|
|
3210
|
+
CREATE TABLE IF NOT EXISTS agent_goals (
|
|
3211
|
+
id TEXT PRIMARY KEY,
|
|
3212
|
+
statement TEXT NOT NULL,
|
|
3213
|
+
owner_agent_id TEXT,
|
|
3214
|
+
project_name TEXT,
|
|
3215
|
+
status TEXT NOT NULL DEFAULT 'open',
|
|
3216
|
+
priority INTEGER NOT NULL DEFAULT 5,
|
|
3217
|
+
success_criteria TEXT,
|
|
3218
|
+
parent_goal_id TEXT,
|
|
3219
|
+
due_at TEXT,
|
|
3220
|
+
achieved_at TEXT,
|
|
3221
|
+
supersedes_id TEXT,
|
|
3222
|
+
created_at TEXT NOT NULL,
|
|
3223
|
+
updated_at TEXT NOT NULL,
|
|
3224
|
+
source_memory_id TEXT
|
|
3225
|
+
);
|
|
3226
|
+
|
|
3227
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goals_project_status
|
|
3228
|
+
ON agent_goals(project_name, status, priority);
|
|
3229
|
+
|
|
3230
|
+
CREATE TABLE IF NOT EXISTS agent_events (
|
|
3231
|
+
id TEXT PRIMARY KEY,
|
|
3232
|
+
event_type TEXT NOT NULL,
|
|
3233
|
+
occurred_at TEXT NOT NULL,
|
|
3234
|
+
sequence_index INTEGER NOT NULL,
|
|
3235
|
+
actor_agent_id TEXT,
|
|
3236
|
+
agent_role TEXT,
|
|
3237
|
+
project_name TEXT,
|
|
3238
|
+
session_id TEXT,
|
|
3239
|
+
task_id TEXT,
|
|
3240
|
+
goal_id TEXT,
|
|
3241
|
+
parent_event_id TEXT,
|
|
3242
|
+
intention TEXT,
|
|
3243
|
+
outcome TEXT,
|
|
3244
|
+
evidence_memory_id TEXT,
|
|
3245
|
+
impact TEXT,
|
|
3246
|
+
payload TEXT DEFAULT '{}',
|
|
3247
|
+
created_at TEXT NOT NULL
|
|
3248
|
+
);
|
|
3249
|
+
|
|
3250
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_time
|
|
3251
|
+
ON agent_events(occurred_at, sequence_index);
|
|
3252
|
+
|
|
3253
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_session_seq
|
|
3254
|
+
ON agent_events(session_id, sequence_index);
|
|
3255
|
+
|
|
3256
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_goal_time
|
|
3257
|
+
ON agent_events(goal_id, occurred_at);
|
|
3258
|
+
|
|
3259
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_memory
|
|
3260
|
+
ON agent_events(evidence_memory_id);
|
|
3261
|
+
|
|
3262
|
+
CREATE TABLE IF NOT EXISTS agent_goal_links (
|
|
3263
|
+
id TEXT PRIMARY KEY,
|
|
3264
|
+
goal_id TEXT NOT NULL,
|
|
3265
|
+
link_type TEXT NOT NULL,
|
|
3266
|
+
target_id TEXT NOT NULL,
|
|
3267
|
+
target_type TEXT NOT NULL,
|
|
3268
|
+
created_at TEXT NOT NULL
|
|
3269
|
+
);
|
|
3270
|
+
|
|
3271
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goal_links_goal
|
|
3272
|
+
ON agent_goal_links(goal_id, target_type);
|
|
3273
|
+
|
|
3274
|
+
CREATE TABLE IF NOT EXISTS agent_semantic_labels (
|
|
3275
|
+
id TEXT PRIMARY KEY,
|
|
3276
|
+
source_memory_id TEXT NOT NULL,
|
|
3277
|
+
event_id TEXT,
|
|
3278
|
+
labeler TEXT NOT NULL,
|
|
3279
|
+
schema_version INTEGER NOT NULL DEFAULT 1,
|
|
3280
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
3281
|
+
labels TEXT NOT NULL,
|
|
3282
|
+
created_at TEXT NOT NULL,
|
|
3283
|
+
updated_at TEXT NOT NULL
|
|
3284
|
+
);
|
|
3285
|
+
|
|
3286
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_memory
|
|
3287
|
+
ON agent_semantic_labels(source_memory_id, labeler);
|
|
3288
|
+
|
|
3289
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_event
|
|
3290
|
+
ON agent_semantic_labels(event_id);
|
|
3291
|
+
|
|
3292
|
+
CREATE TABLE IF NOT EXISTS agent_reflection_checkpoints (
|
|
3293
|
+
id TEXT PRIMARY KEY,
|
|
3294
|
+
project_name TEXT,
|
|
3295
|
+
session_id TEXT,
|
|
3296
|
+
window_start_at TEXT NOT NULL,
|
|
3297
|
+
window_end_at TEXT NOT NULL,
|
|
3298
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
3299
|
+
goal_count INTEGER NOT NULL DEFAULT 0,
|
|
3300
|
+
success_count INTEGER NOT NULL DEFAULT 0,
|
|
3301
|
+
failure_count INTEGER NOT NULL DEFAULT 0,
|
|
3302
|
+
risk_count INTEGER NOT NULL DEFAULT 0,
|
|
3303
|
+
summary TEXT NOT NULL,
|
|
3304
|
+
learnings TEXT NOT NULL DEFAULT '[]',
|
|
3305
|
+
next_actions TEXT NOT NULL DEFAULT '[]',
|
|
3306
|
+
evidence_event_ids TEXT NOT NULL DEFAULT '[]',
|
|
3307
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
3308
|
+
created_at TEXT NOT NULL
|
|
3309
|
+
);
|
|
3310
|
+
|
|
3311
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_project_time
|
|
3312
|
+
ON agent_reflection_checkpoints(project_name, window_end_at);
|
|
3313
|
+
|
|
3314
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_session_time
|
|
3315
|
+
ON agent_reflection_checkpoints(session_id, window_end_at);
|
|
3316
|
+
`);
|
|
3169
3317
|
try {
|
|
3170
3318
|
await client.execute({
|
|
3171
3319
|
sql: `ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3`,
|
|
@@ -3315,7 +3463,7 @@ var init_database = __esm({
|
|
|
3315
3463
|
|
|
3316
3464
|
// src/lib/keychain.ts
|
|
3317
3465
|
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
3318
|
-
import { existsSync as existsSync7 } from "fs";
|
|
3466
|
+
import { existsSync as existsSync7, statSync as statSync2 } from "fs";
|
|
3319
3467
|
import { execSync as execSync2 } from "child_process";
|
|
3320
3468
|
import path7 from "path";
|
|
3321
3469
|
import os5 from "os";
|
|
@@ -3325,29 +3473,78 @@ function getKeyDir() {
|
|
|
3325
3473
|
function getKeyPath() {
|
|
3326
3474
|
return path7.join(getKeyDir(), "master.key");
|
|
3327
3475
|
}
|
|
3328
|
-
function
|
|
3476
|
+
function nativeKeychainAllowed() {
|
|
3477
|
+
return process.env.EXE_OS_DISABLE_NATIVE_KEYCHAIN !== "1";
|
|
3478
|
+
}
|
|
3479
|
+
function linuxSecretAvailable() {
|
|
3480
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3481
|
+
if (process.platform !== "linux") return false;
|
|
3482
|
+
if (linuxSecretAvailability !== null) return linuxSecretAvailability;
|
|
3483
|
+
try {
|
|
3484
|
+
execSync2("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
|
|
3485
|
+
} catch {
|
|
3486
|
+
linuxSecretAvailability = false;
|
|
3487
|
+
return false;
|
|
3488
|
+
}
|
|
3489
|
+
try {
|
|
3490
|
+
execSync2("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
|
|
3491
|
+
linuxSecretAvailability = true;
|
|
3492
|
+
} catch {
|
|
3493
|
+
linuxSecretAvailability = false;
|
|
3494
|
+
}
|
|
3495
|
+
return linuxSecretAvailability;
|
|
3496
|
+
}
|
|
3497
|
+
function isRootOnlyTrustedServerKeyFile(keyPath) {
|
|
3498
|
+
if (process.platform !== "linux") return false;
|
|
3499
|
+
try {
|
|
3500
|
+
const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
|
|
3501
|
+
const st = statSync2(keyPath);
|
|
3502
|
+
if (!st.isFile() || (st.mode & 63) !== 0) return false;
|
|
3503
|
+
if (uid === 0) return true;
|
|
3504
|
+
const exeOsDir = process.env.EXE_OS_DIR;
|
|
3505
|
+
return Boolean(exeOsDir && path7.resolve(keyPath).startsWith(path7.resolve(exeOsDir) + path7.sep));
|
|
3506
|
+
} catch {
|
|
3507
|
+
return false;
|
|
3508
|
+
}
|
|
3509
|
+
}
|
|
3510
|
+
function macKeychainGet(service = SERVICE) {
|
|
3511
|
+
if (!nativeKeychainAllowed()) return null;
|
|
3329
3512
|
if (process.platform !== "darwin") return null;
|
|
3330
3513
|
try {
|
|
3331
3514
|
return execSync2(
|
|
3332
|
-
`security find-generic-password -s "${
|
|
3515
|
+
`security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
|
|
3333
3516
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
3334
3517
|
).trim();
|
|
3335
3518
|
} catch {
|
|
3336
3519
|
return null;
|
|
3337
3520
|
}
|
|
3338
3521
|
}
|
|
3339
|
-
function macKeychainSet(value) {
|
|
3522
|
+
function macKeychainSet(value, service = SERVICE) {
|
|
3523
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3340
3524
|
if (process.platform !== "darwin") return false;
|
|
3341
3525
|
try {
|
|
3342
3526
|
try {
|
|
3343
3527
|
execSync2(
|
|
3344
|
-
`security delete-generic-password -s "${
|
|
3528
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
3345
3529
|
{ timeout: 5e3 }
|
|
3346
3530
|
);
|
|
3347
3531
|
} catch {
|
|
3348
3532
|
}
|
|
3349
3533
|
execSync2(
|
|
3350
|
-
`security add-generic-password -s "${
|
|
3534
|
+
`security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
|
|
3535
|
+
{ timeout: 5e3 }
|
|
3536
|
+
);
|
|
3537
|
+
return true;
|
|
3538
|
+
} catch {
|
|
3539
|
+
return false;
|
|
3540
|
+
}
|
|
3541
|
+
}
|
|
3542
|
+
function macKeychainDelete(service = SERVICE) {
|
|
3543
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3544
|
+
if (process.platform !== "darwin") return false;
|
|
3545
|
+
try {
|
|
3546
|
+
execSync2(
|
|
3547
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
3351
3548
|
{ timeout: 5e3 }
|
|
3352
3549
|
);
|
|
3353
3550
|
return true;
|
|
@@ -3355,22 +3552,35 @@ function macKeychainSet(value) {
|
|
|
3355
3552
|
return false;
|
|
3356
3553
|
}
|
|
3357
3554
|
}
|
|
3358
|
-
function linuxSecretGet() {
|
|
3359
|
-
if (
|
|
3555
|
+
function linuxSecretGet(service = SERVICE) {
|
|
3556
|
+
if (!linuxSecretAvailable()) return null;
|
|
3360
3557
|
try {
|
|
3361
3558
|
return execSync2(
|
|
3362
|
-
`secret-tool lookup service "${
|
|
3559
|
+
`secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3363
3560
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
3364
3561
|
).trim();
|
|
3365
3562
|
} catch {
|
|
3366
3563
|
return null;
|
|
3367
3564
|
}
|
|
3368
3565
|
}
|
|
3369
|
-
function linuxSecretSet(value) {
|
|
3566
|
+
function linuxSecretSet(value, service = SERVICE) {
|
|
3567
|
+
if (!linuxSecretAvailable()) return false;
|
|
3568
|
+
try {
|
|
3569
|
+
execSync2(
|
|
3570
|
+
`echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3571
|
+
{ timeout: 5e3 }
|
|
3572
|
+
);
|
|
3573
|
+
return true;
|
|
3574
|
+
} catch {
|
|
3575
|
+
return false;
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3578
|
+
function linuxSecretDelete(service = SERVICE) {
|
|
3579
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3370
3580
|
if (process.platform !== "linux") return false;
|
|
3371
3581
|
try {
|
|
3372
3582
|
execSync2(
|
|
3373
|
-
`
|
|
3583
|
+
`secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3374
3584
|
{ timeout: 5e3 }
|
|
3375
3585
|
);
|
|
3376
3586
|
return true;
|
|
@@ -3379,6 +3589,7 @@ function linuxSecretSet(value) {
|
|
|
3379
3589
|
}
|
|
3380
3590
|
}
|
|
3381
3591
|
async function tryKeytar() {
|
|
3592
|
+
if (!nativeKeychainAllowed()) return null;
|
|
3382
3593
|
try {
|
|
3383
3594
|
return await import("keytar");
|
|
3384
3595
|
} catch {
|
|
@@ -3452,7 +3663,19 @@ async function writeMachineBoundFileFallback(b64) {
|
|
|
3452
3663
|
return "plaintext";
|
|
3453
3664
|
}
|
|
3454
3665
|
async function getMasterKey() {
|
|
3455
|
-
|
|
3666
|
+
let nativeValue = macKeychainGet() ?? linuxSecretGet();
|
|
3667
|
+
if (!nativeValue) {
|
|
3668
|
+
const legacyValue = macKeychainGet(LEGACY_SERVICE) ?? linuxSecretGet(LEGACY_SERVICE);
|
|
3669
|
+
if (legacyValue) {
|
|
3670
|
+
const migrated = macKeychainSet(legacyValue) || linuxSecretSet(legacyValue);
|
|
3671
|
+
if (migrated) {
|
|
3672
|
+
macKeychainDelete(LEGACY_SERVICE);
|
|
3673
|
+
linuxSecretDelete(LEGACY_SERVICE);
|
|
3674
|
+
process.stderr.write("[keychain] Migrated keychain service from exe-mem to exe-os.\n");
|
|
3675
|
+
}
|
|
3676
|
+
nativeValue = legacyValue;
|
|
3677
|
+
}
|
|
3678
|
+
}
|
|
3456
3679
|
if (nativeValue) {
|
|
3457
3680
|
return Buffer.from(nativeValue, "base64");
|
|
3458
3681
|
}
|
|
@@ -3460,12 +3683,17 @@ async function getMasterKey() {
|
|
|
3460
3683
|
if (keytar) {
|
|
3461
3684
|
try {
|
|
3462
3685
|
const keytarValue = await keytar.getPassword(SERVICE, ACCOUNT);
|
|
3463
|
-
|
|
3464
|
-
|
|
3686
|
+
const legacyKeytarValue = keytarValue ?? await keytar.getPassword(LEGACY_SERVICE, ACCOUNT);
|
|
3687
|
+
if (legacyKeytarValue) {
|
|
3688
|
+
const migrated = macKeychainSet(legacyKeytarValue) || linuxSecretSet(legacyKeytarValue);
|
|
3465
3689
|
if (migrated) {
|
|
3466
3690
|
process.stderr.write("[keychain] Migrated key from keytar to native keychain.\n");
|
|
3691
|
+
try {
|
|
3692
|
+
await keytar.deletePassword(LEGACY_SERVICE, ACCOUNT);
|
|
3693
|
+
} catch {
|
|
3694
|
+
}
|
|
3467
3695
|
}
|
|
3468
|
-
return Buffer.from(
|
|
3696
|
+
return Buffer.from(legacyKeytarValue, "base64");
|
|
3469
3697
|
}
|
|
3470
3698
|
} catch {
|
|
3471
3699
|
}
|
|
@@ -3490,7 +3718,7 @@ async function getMasterKey() {
|
|
|
3490
3718
|
const decrypted = decryptWithMachineKey(content, machineKey);
|
|
3491
3719
|
if (!decrypted) {
|
|
3492
3720
|
process.stderr.write(
|
|
3493
|
-
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase: exe-os
|
|
3721
|
+
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase during setup: exe-os setup\n"
|
|
3494
3722
|
);
|
|
3495
3723
|
return null;
|
|
3496
3724
|
}
|
|
@@ -3499,6 +3727,9 @@ async function getMasterKey() {
|
|
|
3499
3727
|
b64Value = content;
|
|
3500
3728
|
}
|
|
3501
3729
|
const key = Buffer.from(b64Value, "base64");
|
|
3730
|
+
if (!content.startsWith(ENCRYPTED_PREFIX) && isRootOnlyTrustedServerKeyFile(keyPath)) {
|
|
3731
|
+
return key;
|
|
3732
|
+
}
|
|
3502
3733
|
const migrated = macKeychainSet(b64Value) || linuxSecretSet(b64Value);
|
|
3503
3734
|
if (migrated) {
|
|
3504
3735
|
process.stderr.write("[keychain] Migrated key from file to native keychain.\n");
|
|
@@ -3526,12 +3757,14 @@ async function getMasterKey() {
|
|
|
3526
3757
|
return null;
|
|
3527
3758
|
}
|
|
3528
3759
|
}
|
|
3529
|
-
var SERVICE, ACCOUNT, ENCRYPTED_PREFIX;
|
|
3760
|
+
var SERVICE, LEGACY_SERVICE, ACCOUNT, linuxSecretAvailability, ENCRYPTED_PREFIX;
|
|
3530
3761
|
var init_keychain = __esm({
|
|
3531
3762
|
"src/lib/keychain.ts"() {
|
|
3532
3763
|
"use strict";
|
|
3533
|
-
SERVICE = "exe-
|
|
3764
|
+
SERVICE = "exe-os";
|
|
3765
|
+
LEGACY_SERVICE = "exe-mem";
|
|
3534
3766
|
ACCOUNT = "master-key";
|
|
3767
|
+
linuxSecretAvailability = null;
|
|
3535
3768
|
ENCRYPTED_PREFIX = "enc:";
|
|
3536
3769
|
}
|
|
3537
3770
|
});
|
|
@@ -3801,7 +4034,7 @@ __export(shard_manager_exports, {
|
|
|
3801
4034
|
shardExists: () => shardExists
|
|
3802
4035
|
});
|
|
3803
4036
|
import path8 from "path";
|
|
3804
|
-
import { existsSync as existsSync8, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as
|
|
4037
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as statSync3 } from "fs";
|
|
3805
4038
|
import { createClient as createClient2 } from "@libsql/client";
|
|
3806
4039
|
function initShardManager(encryptionKey) {
|
|
3807
4040
|
_encryptionKey = encryptionKey;
|
|
@@ -3865,7 +4098,7 @@ async function auditShardHealth(options = {}) {
|
|
|
3865
4098
|
const shards = [];
|
|
3866
4099
|
for (const name of names) {
|
|
3867
4100
|
const dbPath = path8.join(SHARDS_DIR, `${name}.db`);
|
|
3868
|
-
const stat =
|
|
4101
|
+
const stat = statSync3(dbPath);
|
|
3869
4102
|
const item = {
|
|
3870
4103
|
name,
|
|
3871
4104
|
path: dbPath,
|
|
@@ -4118,7 +4351,7 @@ async function getReadyShardClient(projectName) {
|
|
|
4118
4351
|
_shardLastAccess.delete(safeName);
|
|
4119
4352
|
const dbPath = path8.join(SHARDS_DIR, `${safeName}.db`);
|
|
4120
4353
|
if (existsSync8(dbPath)) {
|
|
4121
|
-
const stat =
|
|
4354
|
+
const stat = statSync3(dbPath);
|
|
4122
4355
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
4123
4356
|
const archivedPath = path8.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
4124
4357
|
renameSync3(dbPath, archivedPath);
|
|
@@ -4238,6 +4471,12 @@ var init_platform_procedures = __esm({
|
|
|
4238
4471
|
priority: "p0",
|
|
4239
4472
|
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."
|
|
4240
4473
|
},
|
|
4474
|
+
{
|
|
4475
|
+
title: "Customer orchestration maturity \u2014 recommend, never trap",
|
|
4476
|
+
domain: "workflow",
|
|
4477
|
+
priority: "p1",
|
|
4478
|
+
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."
|
|
4479
|
+
},
|
|
4241
4480
|
{
|
|
4242
4481
|
title: "Single dispatch path \u2014 create_task only",
|
|
4243
4482
|
domain: "workflow",
|
|
@@ -4296,6 +4535,12 @@ var init_platform_procedures = __esm({
|
|
|
4296
4535
|
priority: "p0",
|
|
4297
4536
|
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."
|
|
4298
4537
|
},
|
|
4538
|
+
{
|
|
4539
|
+
title: "Commit discipline \u2014 never leave verified work floating",
|
|
4540
|
+
domain: "workflow",
|
|
4541
|
+
priority: "p1",
|
|
4542
|
+
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."
|
|
4543
|
+
},
|
|
4299
4544
|
{
|
|
4300
4545
|
title: "Desktop and TUI are the same product",
|
|
4301
4546
|
domain: "architecture",
|
|
@@ -4613,6 +4858,274 @@ var init_memory_cards = __esm({
|
|
|
4613
4858
|
}
|
|
4614
4859
|
});
|
|
4615
4860
|
|
|
4861
|
+
// src/lib/agentic-ontology.ts
|
|
4862
|
+
var agentic_ontology_exports = {};
|
|
4863
|
+
__export(agentic_ontology_exports, {
|
|
4864
|
+
clean: () => clean,
|
|
4865
|
+
extractGoalCandidates: () => extractGoalCandidates,
|
|
4866
|
+
inferIntention: () => inferIntention,
|
|
4867
|
+
inferOntologyEventType: () => inferOntologyEventType,
|
|
4868
|
+
inferOutcome: () => inferOutcome,
|
|
4869
|
+
inferSemanticLabel: () => inferSemanticLabel,
|
|
4870
|
+
insertOntologyForBatch: () => insertOntologyForBatch,
|
|
4871
|
+
insertOntologyForMemory: () => insertOntologyForMemory,
|
|
4872
|
+
ontologyPayload: () => ontologyPayload,
|
|
4873
|
+
stableId: () => stableId2
|
|
4874
|
+
});
|
|
4875
|
+
import { createHash as createHash3 } from "crypto";
|
|
4876
|
+
function stableId2(...parts) {
|
|
4877
|
+
return createHash3("sha256").update(parts.map((p) => String(p ?? "")).join("::")).digest("hex").slice(0, 32);
|
|
4878
|
+
}
|
|
4879
|
+
function clean(text, max = 240) {
|
|
4880
|
+
return text.replace(/\u0000/g, "").replace(/```[\s\S]*?```/g, " ").replace(/\s+/g, " ").trim().slice(0, max);
|
|
4881
|
+
}
|
|
4882
|
+
function inferOntologyEventType(row) {
|
|
4883
|
+
const lower = row.raw_text.toLowerCase();
|
|
4884
|
+
if (row.has_error) return "error";
|
|
4885
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published)\b/.test(lower)) return "milestone";
|
|
4886
|
+
if (/\b(blocked|failed|error|bug|regression|broken)\b/.test(lower)) return "problem";
|
|
4887
|
+
if (/\b(decided|decision|adr|we chose|approved|rejected)\b/.test(lower)) return "decision";
|
|
4888
|
+
if (/\b(goal|need to|we need|want to|trying to|objective)\b/.test(lower)) return "goal_signal";
|
|
4889
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) return "tool_action";
|
|
4890
|
+
if (row.tool_name.startsWith("memory_card")) return "memory_card";
|
|
4891
|
+
return "memory_observation";
|
|
4892
|
+
}
|
|
4893
|
+
function inferIntention(row) {
|
|
4894
|
+
if (row.intent) return clean(row.intent, 220);
|
|
4895
|
+
const text = clean(row.raw_text, 1e3);
|
|
4896
|
+
const patterns = [
|
|
4897
|
+
/(?: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,
|
|
4898
|
+
/(?:so that|in order to)\s+([^.!?\n]{8,220})/i,
|
|
4899
|
+
/(?:task|plan):\s*([^.!?\n]{8,220})/i
|
|
4900
|
+
];
|
|
4901
|
+
for (const p of patterns) {
|
|
4902
|
+
const m = text.match(p);
|
|
4903
|
+
if (m?.[1]) return clean(m[1], 220);
|
|
4904
|
+
}
|
|
4905
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) {
|
|
4906
|
+
return `${row.tool_name} during ${row.project_name}`;
|
|
4907
|
+
}
|
|
4908
|
+
return null;
|
|
4909
|
+
}
|
|
4910
|
+
function inferOutcome(row) {
|
|
4911
|
+
if (row.outcome) return clean(row.outcome, 220);
|
|
4912
|
+
if (row.has_error) return "error";
|
|
4913
|
+
const lower = row.raw_text.toLowerCase();
|
|
4914
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published|passed)\b/.test(lower)) return "success_signal";
|
|
4915
|
+
if (/\b(blocked|failed|error|regression|broken|not working|could not)\b/.test(lower)) return "failure_signal";
|
|
4916
|
+
if (/\b(warning|risk|concern|caveat)\b/.test(lower)) return "risk_signal";
|
|
4917
|
+
return null;
|
|
4918
|
+
}
|
|
4919
|
+
function extractGoalCandidates(row) {
|
|
4920
|
+
const text = clean(row.raw_text, 1600);
|
|
4921
|
+
const patterns = [
|
|
4922
|
+
/(?: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,
|
|
4923
|
+
/(?:success means|success criteria|so that)\s+([^.!?\n]{12,220})/gi
|
|
4924
|
+
];
|
|
4925
|
+
const out = [];
|
|
4926
|
+
for (const pattern of patterns) {
|
|
4927
|
+
for (const m of text.matchAll(pattern)) {
|
|
4928
|
+
const candidate = clean(m[1] ?? "", 220);
|
|
4929
|
+
if (candidate.length >= 12 && !out.some((x) => x.toLowerCase() === candidate.toLowerCase())) out.push(candidate);
|
|
4930
|
+
if (out.length >= 3) return out;
|
|
4931
|
+
}
|
|
4932
|
+
}
|
|
4933
|
+
return out;
|
|
4934
|
+
}
|
|
4935
|
+
function uniq(values, max = 6) {
|
|
4936
|
+
const out = [];
|
|
4937
|
+
for (const value of values.map((v) => clean(v, 220)).filter(Boolean)) {
|
|
4938
|
+
if (!out.some((x) => x.toLowerCase() === value.toLowerCase())) out.push(value);
|
|
4939
|
+
if (out.length >= max) break;
|
|
4940
|
+
}
|
|
4941
|
+
return out;
|
|
4942
|
+
}
|
|
4943
|
+
function extractMatches(text, patterns, max = 5) {
|
|
4944
|
+
const out = [];
|
|
4945
|
+
for (const pattern of patterns) {
|
|
4946
|
+
for (const match of text.matchAll(pattern)) {
|
|
4947
|
+
const value = match[1] ?? match[0];
|
|
4948
|
+
if (value) out.push(value);
|
|
4949
|
+
if (out.length >= max) return uniq(out, max);
|
|
4950
|
+
}
|
|
4951
|
+
}
|
|
4952
|
+
return uniq(out, max);
|
|
4953
|
+
}
|
|
4954
|
+
function inferSemanticLabel(row) {
|
|
4955
|
+
const text = clean(row.raw_text, 2400);
|
|
4956
|
+
const eventType = inferOntologyEventType(row);
|
|
4957
|
+
const intention = inferIntention(row);
|
|
4958
|
+
const outcome = inferOutcome(row);
|
|
4959
|
+
const goals = extractGoalCandidates(row);
|
|
4960
|
+
const milestones = extractMatches(text, [
|
|
4961
|
+
/\b(?:completed|finished|fixed|resolved|shipped|deployed|published|pushed|passed)\b([^.!?\n]{0,180})/gi,
|
|
4962
|
+
/(?:milestone|done):\s*([^.!?\n]{8,220})/gi
|
|
4963
|
+
]);
|
|
4964
|
+
const problems = extractMatches(text, [
|
|
4965
|
+
/\b(?:blocked by|failed because|bug|regression|broken|not working|error)\b([^.!?\n]{0,180})/gi,
|
|
4966
|
+
/(?:problem|issue|risk):\s*([^.!?\n]{8,220})/gi
|
|
4967
|
+
]);
|
|
4968
|
+
const decisions = extractMatches(text, [
|
|
4969
|
+
/(?:decided|decision|adr|we chose|approved|rejected)\s+([^.!?\n]{8,220})/gi
|
|
4970
|
+
]);
|
|
4971
|
+
const temporalAnchors = extractMatches(text, [
|
|
4972
|
+
/\b(\d{4}-\d{2}-\d{2}(?:[T ][0-9:.+-Z]+)?)\b/g,
|
|
4973
|
+
/\b(today|yesterday|tomorrow|this week|next week|last week|morning|afternoon|tonight)\b/gi
|
|
4974
|
+
], 8);
|
|
4975
|
+
const nextActions = extractMatches(text, [
|
|
4976
|
+
/(?:next|todo|follow[- ]?up|remaining|need to)\s*:?\s*([^.!?\n]{8,220})/gi
|
|
4977
|
+
]);
|
|
4978
|
+
const actors = uniq([
|
|
4979
|
+
row.agent_id,
|
|
4980
|
+
...extractMatches(text, [/\b(?:agent|employee|owner|assignee)[:= ]+([a-zA-Z][a-zA-Z0-9_-]{1,40})/gi], 5)
|
|
4981
|
+
], 6);
|
|
4982
|
+
const successSignals = milestones.length ? milestones : outcome === "success_signal" ? [clean(text, 180)] : [];
|
|
4983
|
+
const failureSignals = problems.length ? problems : outcome === "failure_signal" || row.has_error ? [clean(text, 180)] : [];
|
|
4984
|
+
const impact = successSignals.length && failureSignals.length ? "mixed" : failureSignals.length ? "negative" : successSignals.length ? "positive" : "neutral";
|
|
4985
|
+
const signalCount = goals.length + milestones.length + problems.length + decisions.length + nextActions.length;
|
|
4986
|
+
return {
|
|
4987
|
+
labeler: "deterministic",
|
|
4988
|
+
schemaVersion: 1,
|
|
4989
|
+
eventType,
|
|
4990
|
+
intention,
|
|
4991
|
+
outcome,
|
|
4992
|
+
impact,
|
|
4993
|
+
confidence: Math.min(0.95, 0.45 + signalCount * 0.08 + (intention ? 0.1 : 0) + (outcome ? 0.1 : 0)),
|
|
4994
|
+
goals,
|
|
4995
|
+
milestones,
|
|
4996
|
+
problems,
|
|
4997
|
+
decisions,
|
|
4998
|
+
actors,
|
|
4999
|
+
temporalAnchors,
|
|
5000
|
+
successSignals,
|
|
5001
|
+
failureSignals,
|
|
5002
|
+
nextActions,
|
|
5003
|
+
summary: clean(text, 280)
|
|
5004
|
+
};
|
|
5005
|
+
}
|
|
5006
|
+
function ontologyPayload(row) {
|
|
5007
|
+
const semantic = inferSemanticLabel(row);
|
|
5008
|
+
return {
|
|
5009
|
+
tool_name: row.tool_name,
|
|
5010
|
+
memory_version: row.version ?? null,
|
|
5011
|
+
domain: row.domain ?? null,
|
|
5012
|
+
trajectory: row.trajectory ? safeJson(row.trajectory) : null,
|
|
5013
|
+
semantic
|
|
5014
|
+
};
|
|
5015
|
+
}
|
|
5016
|
+
function safeJson(value) {
|
|
5017
|
+
try {
|
|
5018
|
+
return JSON.parse(value);
|
|
5019
|
+
} catch {
|
|
5020
|
+
return value.slice(0, 1e3);
|
|
5021
|
+
}
|
|
5022
|
+
}
|
|
5023
|
+
async function resolveClient(client) {
|
|
5024
|
+
if (client) return client;
|
|
5025
|
+
const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
5026
|
+
return getClient2();
|
|
5027
|
+
}
|
|
5028
|
+
async function insertOntologyForMemory(row, client) {
|
|
5029
|
+
const db = await resolveClient(client);
|
|
5030
|
+
const occurredAt = row.timestamp;
|
|
5031
|
+
const sequence = Number(row.version ?? 0) || Math.floor(new Date(occurredAt).getTime() / 1e3);
|
|
5032
|
+
const eventType = inferOntologyEventType(row);
|
|
5033
|
+
const intention = inferIntention(row);
|
|
5034
|
+
const outcome = inferOutcome(row);
|
|
5035
|
+
const eventId = stableId2("event", row.id);
|
|
5036
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
5037
|
+
await db.execute({
|
|
5038
|
+
sql: `INSERT INTO agent_sessions (id, agent_id, project_name, started_at, last_event_at, event_count, properties)
|
|
5039
|
+
VALUES (?, ?, ?, ?, ?, 1, ?)
|
|
5040
|
+
ON CONFLICT(id) DO UPDATE SET last_event_at = MAX(last_event_at, excluded.last_event_at),
|
|
5041
|
+
event_count = event_count + 1`,
|
|
5042
|
+
args: [row.session_id, row.agent_id, row.project_name, occurredAt, occurredAt, JSON.stringify({ agent_role: row.agent_role })]
|
|
5043
|
+
});
|
|
5044
|
+
await db.execute({
|
|
5045
|
+
sql: `INSERT OR IGNORE INTO agent_events
|
|
5046
|
+
(id, event_type, occurred_at, sequence_index, actor_agent_id, agent_role, project_name,
|
|
5047
|
+
session_id, task_id, goal_id, parent_event_id, intention, outcome, evidence_memory_id,
|
|
5048
|
+
impact, payload, created_at)
|
|
5049
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, ?, ?, ?, ?, ?, ?)`,
|
|
5050
|
+
args: [
|
|
5051
|
+
eventId,
|
|
5052
|
+
eventType,
|
|
5053
|
+
occurredAt,
|
|
5054
|
+
sequence,
|
|
5055
|
+
row.agent_id,
|
|
5056
|
+
row.agent_role,
|
|
5057
|
+
row.project_name,
|
|
5058
|
+
row.session_id,
|
|
5059
|
+
row.task_id ?? null,
|
|
5060
|
+
intention,
|
|
5061
|
+
outcome,
|
|
5062
|
+
row.id,
|
|
5063
|
+
row.has_error ? "negative" : outcome === "success_signal" ? "positive" : "neutral",
|
|
5064
|
+
JSON.stringify(ontologyPayload(row)),
|
|
5065
|
+
now
|
|
5066
|
+
]
|
|
5067
|
+
});
|
|
5068
|
+
const semantic = inferSemanticLabel(row);
|
|
5069
|
+
await db.execute({
|
|
5070
|
+
sql: `INSERT INTO agent_semantic_labels
|
|
5071
|
+
(id, source_memory_id, event_id, labeler, schema_version, confidence, labels, created_at, updated_at)
|
|
5072
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
5073
|
+
ON CONFLICT(id) DO UPDATE SET confidence = excluded.confidence,
|
|
5074
|
+
labels = excluded.labels, updated_at = excluded.updated_at`,
|
|
5075
|
+
args: [
|
|
5076
|
+
stableId2("semantic", row.id, semantic.labeler, semantic.schemaVersion),
|
|
5077
|
+
row.id,
|
|
5078
|
+
eventId,
|
|
5079
|
+
semantic.labeler,
|
|
5080
|
+
semantic.schemaVersion,
|
|
5081
|
+
semantic.confidence,
|
|
5082
|
+
JSON.stringify(semantic),
|
|
5083
|
+
now,
|
|
5084
|
+
now
|
|
5085
|
+
]
|
|
5086
|
+
});
|
|
5087
|
+
for (const statement of extractGoalCandidates(row)) {
|
|
5088
|
+
const goalId = stableId2("goal", row.project_name, statement.toLowerCase());
|
|
5089
|
+
await db.execute({
|
|
5090
|
+
sql: `INSERT INTO agent_goals
|
|
5091
|
+
(id, statement, owner_agent_id, project_name, status, priority, success_criteria,
|
|
5092
|
+
parent_goal_id, due_at, achieved_at, supersedes_id, created_at, updated_at, source_memory_id)
|
|
5093
|
+
VALUES (?, ?, ?, ?, 'open', 5, NULL, NULL, NULL, NULL, NULL, ?, ?, ?)
|
|
5094
|
+
ON CONFLICT(id) DO UPDATE SET updated_at = excluded.updated_at`,
|
|
5095
|
+
args: [goalId, statement, row.agent_id, row.project_name, now, now, row.id]
|
|
5096
|
+
});
|
|
5097
|
+
await db.execute({
|
|
5098
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
5099
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
5100
|
+
VALUES (?, ?, 'evidence', ?, 'memory', ?)`,
|
|
5101
|
+
args: [stableId2("goal_link", goalId, row.id, "memory"), goalId, row.id, now]
|
|
5102
|
+
});
|
|
5103
|
+
await db.execute({
|
|
5104
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
5105
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
5106
|
+
VALUES (?, ?, 'event', ?, 'event', ?)`,
|
|
5107
|
+
args: [stableId2("goal_link", goalId, eventId, "event"), goalId, eventId, now]
|
|
5108
|
+
});
|
|
5109
|
+
}
|
|
5110
|
+
}
|
|
5111
|
+
async function insertOntologyForBatch(rows, client) {
|
|
5112
|
+
const db = await resolveClient(client);
|
|
5113
|
+
let count = 0;
|
|
5114
|
+
for (const row of rows) {
|
|
5115
|
+
try {
|
|
5116
|
+
await insertOntologyForMemory(row, db);
|
|
5117
|
+
count++;
|
|
5118
|
+
} catch {
|
|
5119
|
+
}
|
|
5120
|
+
}
|
|
5121
|
+
return count;
|
|
5122
|
+
}
|
|
5123
|
+
var init_agentic_ontology = __esm({
|
|
5124
|
+
"src/lib/agentic-ontology.ts"() {
|
|
5125
|
+
"use strict";
|
|
5126
|
+
}
|
|
5127
|
+
});
|
|
5128
|
+
|
|
4616
5129
|
// src/lib/store.ts
|
|
4617
5130
|
var store_exports = {};
|
|
4618
5131
|
__export(store_exports, {
|
|
@@ -4956,6 +5469,11 @@ async function flushBatch() {
|
|
|
4956
5469
|
await insertMemoryCardsForBatch2(batch);
|
|
4957
5470
|
} catch {
|
|
4958
5471
|
}
|
|
5472
|
+
try {
|
|
5473
|
+
const { insertOntologyForBatch: insertOntologyForBatch2 } = await Promise.resolve().then(() => (init_agentic_ontology(), agentic_ontology_exports));
|
|
5474
|
+
await insertOntologyForBatch2(batch);
|
|
5475
|
+
} catch {
|
|
5476
|
+
}
|
|
4959
5477
|
schedulePostWriteMemoryHygiene(batch.map((row) => row.id));
|
|
4960
5478
|
_pendingRecords.splice(0, batch.length);
|
|
4961
5479
|
try {
|
|
@@ -5574,7 +6092,7 @@ __export(file_grep_exports, {
|
|
|
5574
6092
|
grepProjectFiles: () => grepProjectFiles
|
|
5575
6093
|
});
|
|
5576
6094
|
import { execSync as execSync4 } from "child_process";
|
|
5577
|
-
import { readFileSync as readFileSync6, readdirSync as readdirSync2, statSync as
|
|
6095
|
+
import { readFileSync as readFileSync6, readdirSync as readdirSync2, statSync as statSync4, existsSync as existsSync10 } from "fs";
|
|
5578
6096
|
import path11 from "path";
|
|
5579
6097
|
import crypto2 from "crypto";
|
|
5580
6098
|
function hasRipgrep() {
|
|
@@ -5691,7 +6209,7 @@ function grepWithNodeFs(pattern, projectRoot, patterns) {
|
|
|
5691
6209
|
for (const filePath of files.slice(0, MAX_FILES)) {
|
|
5692
6210
|
const absPath = path11.join(projectRoot, filePath);
|
|
5693
6211
|
try {
|
|
5694
|
-
const stat =
|
|
6212
|
+
const stat = statSync4(absPath);
|
|
5695
6213
|
if (stat.size > MAX_FILE_SIZE) continue;
|
|
5696
6214
|
const content = readFileSync6(absPath, "utf8");
|
|
5697
6215
|
const lines = content.split("\n");
|
|
@@ -7927,7 +8445,7 @@ __export(identity_exports, {
|
|
|
7927
8445
|
import { existsSync as existsSync16, mkdirSync as mkdirSync8, readFileSync as readFileSync12, writeFileSync as writeFileSync8 } from "fs";
|
|
7928
8446
|
import { readdirSync as readdirSync5 } from "fs";
|
|
7929
8447
|
import path20 from "path";
|
|
7930
|
-
import { createHash as
|
|
8448
|
+
import { createHash as createHash4 } from "crypto";
|
|
7931
8449
|
function ensureDir() {
|
|
7932
8450
|
if (!existsSync16(IDENTITY_DIR2)) {
|
|
7933
8451
|
mkdirSync8(IDENTITY_DIR2, { recursive: true });
|
|
@@ -7974,7 +8492,7 @@ function parseFrontmatter(raw) {
|
|
|
7974
8492
|
};
|
|
7975
8493
|
}
|
|
7976
8494
|
function contentHash(content) {
|
|
7977
|
-
return
|
|
8495
|
+
return createHash4("sha256").update(content).digest("hex").slice(0, 16);
|
|
7978
8496
|
}
|
|
7979
8497
|
function getIdentity(agentId) {
|
|
7980
8498
|
const filePath = identityPath(agentId);
|
|
@@ -8055,6 +8573,115 @@ var init_identity = __esm({
|
|
|
8055
8573
|
}
|
|
8056
8574
|
});
|
|
8057
8575
|
|
|
8576
|
+
// src/lib/orchestration-phase.ts
|
|
8577
|
+
var orchestration_phase_exports = {};
|
|
8578
|
+
__export(orchestration_phase_exports, {
|
|
8579
|
+
ORCHESTRATION_PHASES: () => ORCHESTRATION_PHASES,
|
|
8580
|
+
applyDefaultOrchestrationPhase: () => applyDefaultOrchestrationPhase,
|
|
8581
|
+
getConfigOrchestrationPhase: () => getConfigOrchestrationPhase,
|
|
8582
|
+
getOrchestrationPhaseInfo: () => getOrchestrationPhaseInfo,
|
|
8583
|
+
loadOrchestrationPhase: () => loadOrchestrationPhase,
|
|
8584
|
+
normalizeOrchestrationPhase: () => normalizeOrchestrationPhase,
|
|
8585
|
+
phaseReminderLine: () => phaseReminderLine,
|
|
8586
|
+
setOrchestrationPhase: () => setOrchestrationPhase
|
|
8587
|
+
});
|
|
8588
|
+
function normalizeOrchestrationPhase(input2) {
|
|
8589
|
+
if (typeof input2 !== "string") return "phase_1_coo";
|
|
8590
|
+
const normalized = input2.trim().toLowerCase().replace(/\s+/g, "_");
|
|
8591
|
+
if (["1", "phase1", "phase_1", "coo", "coo_mode", "chief_of_staff", "phase_1_coo"].includes(normalized)) {
|
|
8592
|
+
return "phase_1_coo";
|
|
8593
|
+
}
|
|
8594
|
+
if (["2", "phase2", "phase_2", "executives", "executive", "executive_bench", "phase_2_executives"].includes(normalized)) {
|
|
8595
|
+
return "phase_2_executives";
|
|
8596
|
+
}
|
|
8597
|
+
if (["3", "phase3", "phase_3", "parallel", "parallel_org", "parallel_execution", "phase_3_parallel_org"].includes(normalized)) {
|
|
8598
|
+
return "phase_3_parallel_org";
|
|
8599
|
+
}
|
|
8600
|
+
if (ORCHESTRATION_PHASES.includes(normalized)) return normalized;
|
|
8601
|
+
return "phase_1_coo";
|
|
8602
|
+
}
|
|
8603
|
+
function getOrchestrationPhaseInfo(phase) {
|
|
8604
|
+
return PHASE_INFO[normalizeOrchestrationPhase(phase)];
|
|
8605
|
+
}
|
|
8606
|
+
function getConfigOrchestrationPhase(config) {
|
|
8607
|
+
const orchestration = config.orchestration;
|
|
8608
|
+
return normalizeOrchestrationPhase(orchestration?.phase);
|
|
8609
|
+
}
|
|
8610
|
+
function applyDefaultOrchestrationPhase(config) {
|
|
8611
|
+
if (!config.orchestration) {
|
|
8612
|
+
config.orchestration = {
|
|
8613
|
+
phase: "phase_1_coo",
|
|
8614
|
+
phaseSetAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8615
|
+
phaseSetBy: "setup-default"
|
|
8616
|
+
};
|
|
8617
|
+
return config;
|
|
8618
|
+
}
|
|
8619
|
+
if (!config.orchestration.phase) {
|
|
8620
|
+
config.orchestration = {
|
|
8621
|
+
...config.orchestration,
|
|
8622
|
+
phase: "phase_1_coo",
|
|
8623
|
+
phaseSetAt: config.orchestration.phaseSetAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
8624
|
+
phaseSetBy: config.orchestration.phaseSetBy ?? "setup-default"
|
|
8625
|
+
};
|
|
8626
|
+
}
|
|
8627
|
+
return config;
|
|
8628
|
+
}
|
|
8629
|
+
async function loadOrchestrationPhase() {
|
|
8630
|
+
const config = await loadConfig();
|
|
8631
|
+
return getOrchestrationPhaseInfo(config.orchestration?.phase);
|
|
8632
|
+
}
|
|
8633
|
+
async function setOrchestrationPhase(phaseInput, setBy = "user") {
|
|
8634
|
+
const config = await loadConfig();
|
|
8635
|
+
const phase = normalizeOrchestrationPhase(phaseInput);
|
|
8636
|
+
config.orchestration = {
|
|
8637
|
+
...config.orchestration ?? {},
|
|
8638
|
+
phase,
|
|
8639
|
+
phaseSetAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8640
|
+
phaseSetBy: setBy
|
|
8641
|
+
};
|
|
8642
|
+
await saveConfig(config);
|
|
8643
|
+
return getOrchestrationPhaseInfo(phase);
|
|
8644
|
+
}
|
|
8645
|
+
function phaseReminderLine(phase) {
|
|
8646
|
+
const info = getOrchestrationPhaseInfo(phase);
|
|
8647
|
+
return `${info.shortLabel}: ${info.focus}. ${info.nextSuggestion}`;
|
|
8648
|
+
}
|
|
8649
|
+
var ORCHESTRATION_PHASES, PHASE_INFO;
|
|
8650
|
+
var init_orchestration_phase = __esm({
|
|
8651
|
+
"src/lib/orchestration-phase.ts"() {
|
|
8652
|
+
"use strict";
|
|
8653
|
+
init_config();
|
|
8654
|
+
ORCHESTRATION_PHASES = [
|
|
8655
|
+
"phase_1_coo",
|
|
8656
|
+
"phase_2_executives",
|
|
8657
|
+
"phase_3_parallel_org"
|
|
8658
|
+
];
|
|
8659
|
+
PHASE_INFO = {
|
|
8660
|
+
phase_1_coo: {
|
|
8661
|
+
phase: "phase_1_coo",
|
|
8662
|
+
shortLabel: "Phase 1 \u2014 COO mode",
|
|
8663
|
+
label: "Phase 1 \u2014 COO / Chief of Staff mode",
|
|
8664
|
+
focus: "building company context before delegation",
|
|
8665
|
+
nextSuggestion: "Unlock executives when technical, marketing, ops, legal, or finance work repeats."
|
|
8666
|
+
},
|
|
8667
|
+
phase_2_executives: {
|
|
8668
|
+
phase: "phase_2_executives",
|
|
8669
|
+
shortLabel: "Phase 2 \u2014 Executive bench",
|
|
8670
|
+
label: "Phase 2 \u2014 Executive bench",
|
|
8671
|
+
focus: "COO works with domain executives like CTO/CMO before specialist fan-out",
|
|
8672
|
+
nextSuggestion: "Unlock parallel execution when review gates, permissions, and workflows are ready."
|
|
8673
|
+
},
|
|
8674
|
+
phase_3_parallel_org: {
|
|
8675
|
+
phase: "phase_3_parallel_org",
|
|
8676
|
+
shortLabel: "Phase 3 \u2014 Parallel org",
|
|
8677
|
+
label: "Phase 3 \u2014 Parallel execution org",
|
|
8678
|
+
focus: "executives can delegate to specialists in parallel with review gates",
|
|
8679
|
+
nextSuggestion: "Keep review/CI/permission gates healthy; downgrade anytime if you want simpler COO-only mode."
|
|
8680
|
+
}
|
|
8681
|
+
};
|
|
8682
|
+
}
|
|
8683
|
+
});
|
|
8684
|
+
|
|
8058
8685
|
// src/adapters/claude/hooks/session-start.ts
|
|
8059
8686
|
init_config();
|
|
8060
8687
|
import path21 from "path";
|
|
@@ -8236,6 +8863,15 @@ You are **${title}**${role ? ` (${role})` : ""}. ${firstLine}
|
|
|
8236
8863
|
} catch {
|
|
8237
8864
|
}
|
|
8238
8865
|
}
|
|
8866
|
+
try {
|
|
8867
|
+
const { loadOrchestrationPhase: loadOrchestrationPhase2 } = await Promise.resolve().then(() => (init_orchestration_phase(), orchestration_phase_exports));
|
|
8868
|
+
const phase = await loadOrchestrationPhase2();
|
|
8869
|
+
additionalContext += `## Orchestration Phase
|
|
8870
|
+
${phase.label}. Focus: ${phase.focus}. This is guidance, not a blocker; the user can switch phases anytime. ${phase.nextSuggestion}
|
|
8871
|
+
|
|
8872
|
+
`;
|
|
8873
|
+
} catch {
|
|
8874
|
+
}
|
|
8239
8875
|
if (memories.length > 0) {
|
|
8240
8876
|
const brief = memories.map(
|
|
8241
8877
|
(m) => `[${m.timestamp}] ${m.tool_name}: ${m.raw_text.slice(0, 200)}`
|