@askexenow/exe-os 0.9.38 → 0.9.39
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/dist/bin/backfill-conversations.js +34 -7
- package/dist/bin/backfill-responses.js +34 -7
- package/dist/bin/backfill-vectors.js +34 -7
- package/dist/bin/cleanup-stale-review-tasks.js +35 -8
- package/dist/bin/cli.js +72 -42
- package/dist/bin/exe-agent.js +11 -3
- package/dist/bin/exe-assign.js +34 -7
- package/dist/bin/exe-boot.js +48 -18
- package/dist/bin/exe-call.js +132 -340
- package/dist/bin/exe-dispatch.js +34 -7
- package/dist/bin/exe-doctor.js +37 -10
- package/dist/bin/exe-export-behaviors.js +36 -9
- package/dist/bin/exe-forget.js +34 -7
- package/dist/bin/exe-gateway.js +40 -12
- package/dist/bin/exe-heartbeat.js +35 -8
- package/dist/bin/exe-kill.js +34 -7
- package/dist/bin/exe-launch-agent.js +285 -1079
- package/dist/bin/exe-new-employee.js +29 -10
- package/dist/bin/exe-pending-messages.js +34 -7
- package/dist/bin/exe-pending-notifications.js +34 -7
- package/dist/bin/exe-pending-reviews.js +34 -7
- package/dist/bin/exe-rename.js +41 -13
- package/dist/bin/exe-review.js +34 -7
- package/dist/bin/exe-search.js +36 -9
- package/dist/bin/exe-session-cleanup.js +36 -9
- package/dist/bin/exe-start-codex.js +36 -9
- package/dist/bin/exe-start-opencode.js +36 -9
- package/dist/bin/exe-status.js +35 -8
- package/dist/bin/exe-team.js +34 -7
- package/dist/bin/git-sweep.js +34 -7
- package/dist/bin/graph-backfill.js +34 -7
- package/dist/bin/graph-export.js +34 -7
- package/dist/bin/install.js +2 -1
- package/dist/bin/intercom-check.js +36 -9
- package/dist/bin/scan-tasks.js +34 -7
- package/dist/bin/setup.js +18 -17
- package/dist/bin/shard-migrate.js +34 -7
- package/dist/gateway/index.js +38 -10
- package/dist/hooks/bug-report-worker.js +38 -10
- package/dist/hooks/codex-stop-task-finalizer.js +36 -9
- package/dist/hooks/commit-complete.js +34 -7
- package/dist/hooks/error-recall.js +36 -9
- package/dist/hooks/ingest.js +36 -8
- package/dist/hooks/instructions-loaded.js +42 -10
- package/dist/hooks/notification.js +34 -7
- package/dist/hooks/post-compact.js +34 -7
- package/dist/hooks/post-tool-combined.js +37 -10
- package/dist/hooks/pre-compact.js +35 -8
- package/dist/hooks/pre-tool-use.js +36 -8
- package/dist/hooks/prompt-submit.js +41 -13
- package/dist/hooks/session-end.js +35 -8
- package/dist/hooks/session-start.js +47 -14
- package/dist/hooks/stop.js +35 -8
- package/dist/hooks/subagent-stop.js +34 -7
- package/dist/hooks/summary-worker.js +43 -16
- package/dist/index.js +36 -8
- package/dist/lib/consolidation.js +2 -1
- package/dist/lib/employee-templates.js +2 -1
- package/dist/lib/employees.js +2 -1
- package/dist/lib/exe-daemon.js +136 -36
- package/dist/lib/hybrid-search.js +36 -9
- package/dist/lib/identity.js +8 -3
- package/dist/lib/schedules.js +34 -7
- package/dist/lib/store.js +34 -7
- package/dist/mcp/server.js +133 -33
- package/dist/mcp/tools/create-task.js +10 -4
- package/dist/runtime/index.js +34 -7
- package/dist/tui/App.js +40 -11
- package/package.json +1 -1
|
@@ -3416,7 +3416,7 @@ __export(shard_manager_exports, {
|
|
|
3416
3416
|
shardExists: () => shardExists
|
|
3417
3417
|
});
|
|
3418
3418
|
import path7 from "path";
|
|
3419
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync } from "fs";
|
|
3419
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as statSync2 } from "fs";
|
|
3420
3420
|
import { createClient as createClient2 } from "@libsql/client";
|
|
3421
3421
|
function initShardManager(encryptionKey) {
|
|
3422
3422
|
_encryptionKey = encryptionKey;
|
|
@@ -3438,7 +3438,7 @@ function getShardClient(projectName) {
|
|
|
3438
3438
|
if (!_encryptionKey) {
|
|
3439
3439
|
throw new Error("Shard manager not initialized. Call initShardManager() first.");
|
|
3440
3440
|
}
|
|
3441
|
-
const safeName = projectName
|
|
3441
|
+
const safeName = safeShardName(projectName);
|
|
3442
3442
|
if (!safeName || safeName === "unknown") {
|
|
3443
3443
|
throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
|
|
3444
3444
|
}
|
|
@@ -3460,9 +3460,12 @@ function getShardClient(projectName) {
|
|
|
3460
3460
|
return client;
|
|
3461
3461
|
}
|
|
3462
3462
|
function shardExists(projectName) {
|
|
3463
|
-
const safeName = projectName
|
|
3463
|
+
const safeName = safeShardName(projectName);
|
|
3464
3464
|
return existsSync7(path7.join(SHARDS_DIR, `${safeName}.db`));
|
|
3465
3465
|
}
|
|
3466
|
+
function safeShardName(projectName) {
|
|
3467
|
+
return projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
3468
|
+
}
|
|
3466
3469
|
function listShards() {
|
|
3467
3470
|
if (!existsSync7(SHARDS_DIR)) return [];
|
|
3468
3471
|
return readdirSync(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
|
|
@@ -3556,7 +3559,8 @@ async function ensureShardSchema(client) {
|
|
|
3556
3559
|
"ALTER TABLE memories ADD COLUMN token_cost REAL",
|
|
3557
3560
|
"ALTER TABLE memories ADD COLUMN audience TEXT",
|
|
3558
3561
|
"ALTER TABLE memories ADD COLUMN language_type TEXT",
|
|
3559
|
-
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT"
|
|
3562
|
+
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT",
|
|
3563
|
+
"ALTER TABLE memories ADD COLUMN deleted_at TEXT"
|
|
3560
3564
|
]) {
|
|
3561
3565
|
try {
|
|
3562
3566
|
await client.execute(col);
|
|
@@ -3652,9 +3656,32 @@ async function ensureShardSchema(client) {
|
|
|
3652
3656
|
}
|
|
3653
3657
|
}
|
|
3654
3658
|
async function getReadyShardClient(projectName) {
|
|
3655
|
-
const
|
|
3656
|
-
|
|
3657
|
-
|
|
3659
|
+
const safeName = safeShardName(projectName);
|
|
3660
|
+
let client = getShardClient(projectName);
|
|
3661
|
+
try {
|
|
3662
|
+
await ensureShardSchema(client);
|
|
3663
|
+
return client;
|
|
3664
|
+
} catch (err) {
|
|
3665
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
3666
|
+
if (!/SQLITE_NOTADB|file is not a database/i.test(message)) throw err;
|
|
3667
|
+
client.close();
|
|
3668
|
+
_shards.delete(safeName);
|
|
3669
|
+
_shardLastAccess.delete(safeName);
|
|
3670
|
+
const dbPath = path7.join(SHARDS_DIR, `${safeName}.db`);
|
|
3671
|
+
if (existsSync7(dbPath)) {
|
|
3672
|
+
const stat = statSync2(dbPath);
|
|
3673
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
3674
|
+
const archivedPath = path7.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
3675
|
+
renameSync3(dbPath, archivedPath);
|
|
3676
|
+
process.stderr.write(
|
|
3677
|
+
`[shard-manager] Archived unreadable shard ${safeName}: ${archivedPath} (${stat.size} bytes, mtime ${stat.mtime.toISOString()})
|
|
3678
|
+
`
|
|
3679
|
+
);
|
|
3680
|
+
}
|
|
3681
|
+
client = getShardClient(projectName);
|
|
3682
|
+
await ensureShardSchema(client);
|
|
3683
|
+
return client;
|
|
3684
|
+
}
|
|
3658
3685
|
}
|
|
3659
3686
|
function evictLRU() {
|
|
3660
3687
|
let oldest = null;
|
|
@@ -4929,7 +4956,7 @@ __export(file_grep_exports, {
|
|
|
4929
4956
|
grepProjectFiles: () => grepProjectFiles
|
|
4930
4957
|
});
|
|
4931
4958
|
import { execSync as execSync4 } from "child_process";
|
|
4932
|
-
import { readFileSync as readFileSync5, readdirSync as readdirSync2, statSync as
|
|
4959
|
+
import { readFileSync as readFileSync5, readdirSync as readdirSync2, statSync as statSync3, existsSync as existsSync9 } from "fs";
|
|
4933
4960
|
import path10 from "path";
|
|
4934
4961
|
import crypto3 from "crypto";
|
|
4935
4962
|
function hasRipgrep() {
|
|
@@ -5046,7 +5073,7 @@ function grepWithNodeFs(pattern, projectRoot, patterns) {
|
|
|
5046
5073
|
for (const filePath of files.slice(0, MAX_FILES)) {
|
|
5047
5074
|
const absPath = path10.join(projectRoot, filePath);
|
|
5048
5075
|
try {
|
|
5049
|
-
const stat =
|
|
5076
|
+
const stat = statSync3(absPath);
|
|
5050
5077
|
if (stat.size > MAX_FILE_SIZE) continue;
|
|
5051
5078
|
const content = readFileSync5(absPath, "utf8");
|
|
5052
5079
|
const lines = content.split("\n");
|
|
@@ -6545,7 +6572,7 @@ var init_content_extractor = __esm({
|
|
|
6545
6572
|
});
|
|
6546
6573
|
|
|
6547
6574
|
// src/lib/memory-queue.ts
|
|
6548
|
-
import { appendFileSync, readFileSync as readFileSync6, renameSync as
|
|
6575
|
+
import { appendFileSync, readFileSync as readFileSync6, renameSync as renameSync4, unlinkSync as unlinkSync3, existsSync as existsSync10, statSync as statSync4 } from "fs";
|
|
6549
6576
|
import path11 from "path";
|
|
6550
6577
|
function enqueueMemory(entry) {
|
|
6551
6578
|
appendFileSync(QUEUE_PATH, JSON.stringify(entry) + "\n");
|
|
@@ -6933,7 +6933,7 @@ __export(shard_manager_exports, {
|
|
|
6933
6933
|
shardExists: () => shardExists
|
|
6934
6934
|
});
|
|
6935
6935
|
import path20 from "path";
|
|
6936
|
-
import { existsSync as existsSync16, mkdirSync as mkdirSync8, readdirSync as readdirSync5 } from "fs";
|
|
6936
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync8, readdirSync as readdirSync5, renameSync as renameSync4, statSync as statSync2 } from "fs";
|
|
6937
6937
|
import { createClient as createClient2 } from "@libsql/client";
|
|
6938
6938
|
function initShardManager(encryptionKey) {
|
|
6939
6939
|
_encryptionKey = encryptionKey;
|
|
@@ -6955,7 +6955,7 @@ function getShardClient(projectName) {
|
|
|
6955
6955
|
if (!_encryptionKey) {
|
|
6956
6956
|
throw new Error("Shard manager not initialized. Call initShardManager() first.");
|
|
6957
6957
|
}
|
|
6958
|
-
const safeName = projectName
|
|
6958
|
+
const safeName = safeShardName(projectName);
|
|
6959
6959
|
if (!safeName || safeName === "unknown") {
|
|
6960
6960
|
throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
|
|
6961
6961
|
}
|
|
@@ -6977,9 +6977,12 @@ function getShardClient(projectName) {
|
|
|
6977
6977
|
return client;
|
|
6978
6978
|
}
|
|
6979
6979
|
function shardExists(projectName) {
|
|
6980
|
-
const safeName = projectName
|
|
6980
|
+
const safeName = safeShardName(projectName);
|
|
6981
6981
|
return existsSync16(path20.join(SHARDS_DIR, `${safeName}.db`));
|
|
6982
6982
|
}
|
|
6983
|
+
function safeShardName(projectName) {
|
|
6984
|
+
return projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
6985
|
+
}
|
|
6983
6986
|
function listShards() {
|
|
6984
6987
|
if (!existsSync16(SHARDS_DIR)) return [];
|
|
6985
6988
|
return readdirSync5(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
|
|
@@ -7073,7 +7076,8 @@ async function ensureShardSchema(client) {
|
|
|
7073
7076
|
"ALTER TABLE memories ADD COLUMN token_cost REAL",
|
|
7074
7077
|
"ALTER TABLE memories ADD COLUMN audience TEXT",
|
|
7075
7078
|
"ALTER TABLE memories ADD COLUMN language_type TEXT",
|
|
7076
|
-
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT"
|
|
7079
|
+
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT",
|
|
7080
|
+
"ALTER TABLE memories ADD COLUMN deleted_at TEXT"
|
|
7077
7081
|
]) {
|
|
7078
7082
|
try {
|
|
7079
7083
|
await client.execute(col);
|
|
@@ -7169,9 +7173,32 @@ async function ensureShardSchema(client) {
|
|
|
7169
7173
|
}
|
|
7170
7174
|
}
|
|
7171
7175
|
async function getReadyShardClient(projectName) {
|
|
7172
|
-
const
|
|
7173
|
-
|
|
7174
|
-
|
|
7176
|
+
const safeName = safeShardName(projectName);
|
|
7177
|
+
let client = getShardClient(projectName);
|
|
7178
|
+
try {
|
|
7179
|
+
await ensureShardSchema(client);
|
|
7180
|
+
return client;
|
|
7181
|
+
} catch (err) {
|
|
7182
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
7183
|
+
if (!/SQLITE_NOTADB|file is not a database/i.test(message)) throw err;
|
|
7184
|
+
client.close();
|
|
7185
|
+
_shards.delete(safeName);
|
|
7186
|
+
_shardLastAccess.delete(safeName);
|
|
7187
|
+
const dbPath = path20.join(SHARDS_DIR, `${safeName}.db`);
|
|
7188
|
+
if (existsSync16(dbPath)) {
|
|
7189
|
+
const stat = statSync2(dbPath);
|
|
7190
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
7191
|
+
const archivedPath = path20.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
7192
|
+
renameSync4(dbPath, archivedPath);
|
|
7193
|
+
process.stderr.write(
|
|
7194
|
+
`[shard-manager] Archived unreadable shard ${safeName}: ${archivedPath} (${stat.size} bytes, mtime ${stat.mtime.toISOString()})
|
|
7195
|
+
`
|
|
7196
|
+
);
|
|
7197
|
+
}
|
|
7198
|
+
client = getShardClient(projectName);
|
|
7199
|
+
await ensureShardSchema(client);
|
|
7200
|
+
return client;
|
|
7201
|
+
}
|
|
7175
7202
|
}
|
|
7176
7203
|
function evictLRU() {
|
|
7177
7204
|
let oldest = null;
|
|
@@ -8176,7 +8203,7 @@ var init_fast_db_init = __esm({
|
|
|
8176
8203
|
});
|
|
8177
8204
|
|
|
8178
8205
|
// src/lib/memory-queue.ts
|
|
8179
|
-
import { appendFileSync as appendFileSync2, readFileSync as readFileSync14, renameSync as
|
|
8206
|
+
import { appendFileSync as appendFileSync2, readFileSync as readFileSync14, renameSync as renameSync5, unlinkSync as unlinkSync8, existsSync as existsSync17, statSync as statSync3 } from "fs";
|
|
8180
8207
|
import path21 from "path";
|
|
8181
8208
|
function enqueueMemory(entry) {
|
|
8182
8209
|
appendFileSync2(QUEUE_PATH2, JSON.stringify(entry) + "\n");
|
|
@@ -552,7 +552,8 @@ function isMultiInstance(agentName, employees) {
|
|
|
552
552
|
return MULTI_INSTANCE_ROLES.has(emp.role.toLowerCase());
|
|
553
553
|
}
|
|
554
554
|
function addEmployee(employees, employee) {
|
|
555
|
-
const
|
|
555
|
+
const { systemPrompt: _legacyPrompt, ...rest } = employee;
|
|
556
|
+
const normalized = { ...rest, name: employee.name.toLowerCase() };
|
|
556
557
|
if (employees.some((e) => e.name.toLowerCase() === normalized.name)) {
|
|
557
558
|
throw new Error(`Employee '${normalized.name}' already exists`);
|
|
558
559
|
}
|
|
@@ -4142,7 +4143,7 @@ __export(shard_manager_exports, {
|
|
|
4142
4143
|
shardExists: () => shardExists
|
|
4143
4144
|
});
|
|
4144
4145
|
import path15 from "path";
|
|
4145
|
-
import { existsSync as existsSync13, mkdirSync as mkdirSync6, readdirSync as readdirSync3 } from "fs";
|
|
4146
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync6, readdirSync as readdirSync3, renameSync as renameSync4, statSync as statSync3 } from "fs";
|
|
4146
4147
|
import { createClient as createClient2 } from "@libsql/client";
|
|
4147
4148
|
function initShardManager(encryptionKey) {
|
|
4148
4149
|
_encryptionKey = encryptionKey;
|
|
@@ -4164,7 +4165,7 @@ function getShardClient(projectName) {
|
|
|
4164
4165
|
if (!_encryptionKey) {
|
|
4165
4166
|
throw new Error("Shard manager not initialized. Call initShardManager() first.");
|
|
4166
4167
|
}
|
|
4167
|
-
const safeName = projectName
|
|
4168
|
+
const safeName = safeShardName(projectName);
|
|
4168
4169
|
if (!safeName || safeName === "unknown") {
|
|
4169
4170
|
throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
|
|
4170
4171
|
}
|
|
@@ -4186,9 +4187,12 @@ function getShardClient(projectName) {
|
|
|
4186
4187
|
return client;
|
|
4187
4188
|
}
|
|
4188
4189
|
function shardExists(projectName) {
|
|
4189
|
-
const safeName = projectName
|
|
4190
|
+
const safeName = safeShardName(projectName);
|
|
4190
4191
|
return existsSync13(path15.join(SHARDS_DIR, `${safeName}.db`));
|
|
4191
4192
|
}
|
|
4193
|
+
function safeShardName(projectName) {
|
|
4194
|
+
return projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
4195
|
+
}
|
|
4192
4196
|
function listShards() {
|
|
4193
4197
|
if (!existsSync13(SHARDS_DIR)) return [];
|
|
4194
4198
|
return readdirSync3(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
|
|
@@ -4282,7 +4286,8 @@ async function ensureShardSchema(client) {
|
|
|
4282
4286
|
"ALTER TABLE memories ADD COLUMN token_cost REAL",
|
|
4283
4287
|
"ALTER TABLE memories ADD COLUMN audience TEXT",
|
|
4284
4288
|
"ALTER TABLE memories ADD COLUMN language_type TEXT",
|
|
4285
|
-
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT"
|
|
4289
|
+
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT",
|
|
4290
|
+
"ALTER TABLE memories ADD COLUMN deleted_at TEXT"
|
|
4286
4291
|
]) {
|
|
4287
4292
|
try {
|
|
4288
4293
|
await client.execute(col);
|
|
@@ -4378,9 +4383,32 @@ async function ensureShardSchema(client) {
|
|
|
4378
4383
|
}
|
|
4379
4384
|
}
|
|
4380
4385
|
async function getReadyShardClient(projectName) {
|
|
4381
|
-
const
|
|
4382
|
-
|
|
4383
|
-
|
|
4386
|
+
const safeName = safeShardName(projectName);
|
|
4387
|
+
let client = getShardClient(projectName);
|
|
4388
|
+
try {
|
|
4389
|
+
await ensureShardSchema(client);
|
|
4390
|
+
return client;
|
|
4391
|
+
} catch (err) {
|
|
4392
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
4393
|
+
if (!/SQLITE_NOTADB|file is not a database/i.test(message)) throw err;
|
|
4394
|
+
client.close();
|
|
4395
|
+
_shards.delete(safeName);
|
|
4396
|
+
_shardLastAccess.delete(safeName);
|
|
4397
|
+
const dbPath = path15.join(SHARDS_DIR, `${safeName}.db`);
|
|
4398
|
+
if (existsSync13(dbPath)) {
|
|
4399
|
+
const stat = statSync3(dbPath);
|
|
4400
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
4401
|
+
const archivedPath = path15.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
4402
|
+
renameSync4(dbPath, archivedPath);
|
|
4403
|
+
process.stderr.write(
|
|
4404
|
+
`[shard-manager] Archived unreadable shard ${safeName}: ${archivedPath} (${stat.size} bytes, mtime ${stat.mtime.toISOString()})
|
|
4405
|
+
`
|
|
4406
|
+
);
|
|
4407
|
+
}
|
|
4408
|
+
client = getShardClient(projectName);
|
|
4409
|
+
await ensureShardSchema(client);
|
|
4410
|
+
return client;
|
|
4411
|
+
}
|
|
4384
4412
|
}
|
|
4385
4413
|
function evictLRU() {
|
|
4386
4414
|
let oldest = null;
|
|
@@ -603,7 +603,8 @@ function isMultiInstance(agentName, employees) {
|
|
|
603
603
|
return MULTI_INSTANCE_ROLES.has(emp.role.toLowerCase());
|
|
604
604
|
}
|
|
605
605
|
function addEmployee(employees, employee) {
|
|
606
|
-
const
|
|
606
|
+
const { systemPrompt: _legacyPrompt, ...rest } = employee;
|
|
607
|
+
const normalized = { ...rest, name: employee.name.toLowerCase() };
|
|
607
608
|
if (employees.some((e) => e.name.toLowerCase() === normalized.name)) {
|
|
608
609
|
throw new Error(`Employee '${normalized.name}' already exists`);
|
|
609
610
|
}
|
|
@@ -3583,7 +3584,7 @@ __export(shard_manager_exports, {
|
|
|
3583
3584
|
shardExists: () => shardExists
|
|
3584
3585
|
});
|
|
3585
3586
|
import path8 from "path";
|
|
3586
|
-
import { existsSync as existsSync8, mkdirSync as mkdirSync2, readdirSync } from "fs";
|
|
3587
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as statSync2 } from "fs";
|
|
3587
3588
|
import { createClient as createClient2 } from "@libsql/client";
|
|
3588
3589
|
function initShardManager(encryptionKey) {
|
|
3589
3590
|
_encryptionKey = encryptionKey;
|
|
@@ -3605,7 +3606,7 @@ function getShardClient(projectName) {
|
|
|
3605
3606
|
if (!_encryptionKey) {
|
|
3606
3607
|
throw new Error("Shard manager not initialized. Call initShardManager() first.");
|
|
3607
3608
|
}
|
|
3608
|
-
const safeName = projectName
|
|
3609
|
+
const safeName = safeShardName(projectName);
|
|
3609
3610
|
if (!safeName || safeName === "unknown") {
|
|
3610
3611
|
throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
|
|
3611
3612
|
}
|
|
@@ -3627,9 +3628,12 @@ function getShardClient(projectName) {
|
|
|
3627
3628
|
return client;
|
|
3628
3629
|
}
|
|
3629
3630
|
function shardExists(projectName) {
|
|
3630
|
-
const safeName = projectName
|
|
3631
|
+
const safeName = safeShardName(projectName);
|
|
3631
3632
|
return existsSync8(path8.join(SHARDS_DIR, `${safeName}.db`));
|
|
3632
3633
|
}
|
|
3634
|
+
function safeShardName(projectName) {
|
|
3635
|
+
return projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
3636
|
+
}
|
|
3633
3637
|
function listShards() {
|
|
3634
3638
|
if (!existsSync8(SHARDS_DIR)) return [];
|
|
3635
3639
|
return readdirSync(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
|
|
@@ -3723,7 +3727,8 @@ async function ensureShardSchema(client) {
|
|
|
3723
3727
|
"ALTER TABLE memories ADD COLUMN token_cost REAL",
|
|
3724
3728
|
"ALTER TABLE memories ADD COLUMN audience TEXT",
|
|
3725
3729
|
"ALTER TABLE memories ADD COLUMN language_type TEXT",
|
|
3726
|
-
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT"
|
|
3730
|
+
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT",
|
|
3731
|
+
"ALTER TABLE memories ADD COLUMN deleted_at TEXT"
|
|
3727
3732
|
]) {
|
|
3728
3733
|
try {
|
|
3729
3734
|
await client.execute(col);
|
|
@@ -3819,9 +3824,32 @@ async function ensureShardSchema(client) {
|
|
|
3819
3824
|
}
|
|
3820
3825
|
}
|
|
3821
3826
|
async function getReadyShardClient(projectName) {
|
|
3822
|
-
const
|
|
3823
|
-
|
|
3824
|
-
|
|
3827
|
+
const safeName = safeShardName(projectName);
|
|
3828
|
+
let client = getShardClient(projectName);
|
|
3829
|
+
try {
|
|
3830
|
+
await ensureShardSchema(client);
|
|
3831
|
+
return client;
|
|
3832
|
+
} catch (err) {
|
|
3833
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
3834
|
+
if (!/SQLITE_NOTADB|file is not a database/i.test(message)) throw err;
|
|
3835
|
+
client.close();
|
|
3836
|
+
_shards.delete(safeName);
|
|
3837
|
+
_shardLastAccess.delete(safeName);
|
|
3838
|
+
const dbPath = path8.join(SHARDS_DIR, `${safeName}.db`);
|
|
3839
|
+
if (existsSync8(dbPath)) {
|
|
3840
|
+
const stat = statSync2(dbPath);
|
|
3841
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
3842
|
+
const archivedPath = path8.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
3843
|
+
renameSync3(dbPath, archivedPath);
|
|
3844
|
+
process.stderr.write(
|
|
3845
|
+
`[shard-manager] Archived unreadable shard ${safeName}: ${archivedPath} (${stat.size} bytes, mtime ${stat.mtime.toISOString()})
|
|
3846
|
+
`
|
|
3847
|
+
);
|
|
3848
|
+
}
|
|
3849
|
+
client = getShardClient(projectName);
|
|
3850
|
+
await ensureShardSchema(client);
|
|
3851
|
+
return client;
|
|
3852
|
+
}
|
|
3825
3853
|
}
|
|
3826
3854
|
function evictLRU() {
|
|
3827
3855
|
let oldest = null;
|
|
@@ -5096,7 +5124,7 @@ __export(file_grep_exports, {
|
|
|
5096
5124
|
grepProjectFiles: () => grepProjectFiles
|
|
5097
5125
|
});
|
|
5098
5126
|
import { execSync as execSync4 } from "child_process";
|
|
5099
|
-
import { readFileSync as readFileSync6, readdirSync as readdirSync2, statSync as
|
|
5127
|
+
import { readFileSync as readFileSync6, readdirSync as readdirSync2, statSync as statSync3, existsSync as existsSync10 } from "fs";
|
|
5100
5128
|
import path11 from "path";
|
|
5101
5129
|
import crypto2 from "crypto";
|
|
5102
5130
|
function hasRipgrep() {
|
|
@@ -5213,7 +5241,7 @@ function grepWithNodeFs(pattern, projectRoot, patterns) {
|
|
|
5213
5241
|
for (const filePath of files.slice(0, MAX_FILES)) {
|
|
5214
5242
|
const absPath = path11.join(projectRoot, filePath);
|
|
5215
5243
|
try {
|
|
5216
|
-
const stat =
|
|
5244
|
+
const stat = statSync3(absPath);
|
|
5217
5245
|
if (stat.size > MAX_FILE_SIZE) continue;
|
|
5218
5246
|
const content = readFileSync6(absPath, "utf8");
|
|
5219
5247
|
const lines = content.split("\n");
|
|
@@ -6237,7 +6265,7 @@ __export(intercom_queue_exports, {
|
|
|
6237
6265
|
queueIntercom: () => queueIntercom,
|
|
6238
6266
|
readQueue: () => readQueue
|
|
6239
6267
|
});
|
|
6240
|
-
import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, renameSync as
|
|
6268
|
+
import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, renameSync as renameSync4, existsSync as existsSync13, mkdirSync as mkdirSync6 } from "fs";
|
|
6241
6269
|
import path15 from "path";
|
|
6242
6270
|
import os8 from "os";
|
|
6243
6271
|
function ensureDir() {
|
|
@@ -6256,7 +6284,7 @@ function writeQueue(queue) {
|
|
|
6256
6284
|
ensureDir();
|
|
6257
6285
|
const tmp = `${QUEUE_PATH}.tmp`;
|
|
6258
6286
|
writeFileSync7(tmp, JSON.stringify(queue, null, 2));
|
|
6259
|
-
|
|
6287
|
+
renameSync4(tmp, QUEUE_PATH);
|
|
6260
6288
|
}
|
|
6261
6289
|
function queueIntercom(targetSession, reason) {
|
|
6262
6290
|
const queue = readQueue();
|
|
@@ -9687,7 +9715,7 @@ var init_messaging = __esm({
|
|
|
9687
9715
|
});
|
|
9688
9716
|
|
|
9689
9717
|
// src/lib/memory-queue.ts
|
|
9690
|
-
import { appendFileSync as appendFileSync2, readFileSync as readFileSync16, renameSync as
|
|
9718
|
+
import { appendFileSync as appendFileSync2, readFileSync as readFileSync16, renameSync as renameSync5, unlinkSync as unlinkSync9, existsSync as existsSync20, statSync as statSync4 } from "fs";
|
|
9691
9719
|
import path24 from "path";
|
|
9692
9720
|
function enqueueMemory(entry) {
|
|
9693
9721
|
appendFileSync2(QUEUE_PATH2, JSON.stringify(entry) + "\n");
|
|
@@ -7142,7 +7142,7 @@ __export(shard_manager_exports, {
|
|
|
7142
7142
|
shardExists: () => shardExists
|
|
7143
7143
|
});
|
|
7144
7144
|
import path21 from "path";
|
|
7145
|
-
import { existsSync as existsSync17, mkdirSync as mkdirSync9, readdirSync as readdirSync5 } from "fs";
|
|
7145
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync9, readdirSync as readdirSync5, renameSync as renameSync4, statSync as statSync2 } from "fs";
|
|
7146
7146
|
import { createClient as createClient2 } from "@libsql/client";
|
|
7147
7147
|
function initShardManager(encryptionKey) {
|
|
7148
7148
|
_encryptionKey = encryptionKey;
|
|
@@ -7164,7 +7164,7 @@ function getShardClient(projectName) {
|
|
|
7164
7164
|
if (!_encryptionKey) {
|
|
7165
7165
|
throw new Error("Shard manager not initialized. Call initShardManager() first.");
|
|
7166
7166
|
}
|
|
7167
|
-
const safeName = projectName
|
|
7167
|
+
const safeName = safeShardName(projectName);
|
|
7168
7168
|
if (!safeName || safeName === "unknown") {
|
|
7169
7169
|
throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
|
|
7170
7170
|
}
|
|
@@ -7186,9 +7186,12 @@ function getShardClient(projectName) {
|
|
|
7186
7186
|
return client;
|
|
7187
7187
|
}
|
|
7188
7188
|
function shardExists(projectName) {
|
|
7189
|
-
const safeName = projectName
|
|
7189
|
+
const safeName = safeShardName(projectName);
|
|
7190
7190
|
return existsSync17(path21.join(SHARDS_DIR, `${safeName}.db`));
|
|
7191
7191
|
}
|
|
7192
|
+
function safeShardName(projectName) {
|
|
7193
|
+
return projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
7194
|
+
}
|
|
7192
7195
|
function listShards() {
|
|
7193
7196
|
if (!existsSync17(SHARDS_DIR)) return [];
|
|
7194
7197
|
return readdirSync5(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
|
|
@@ -7282,7 +7285,8 @@ async function ensureShardSchema(client) {
|
|
|
7282
7285
|
"ALTER TABLE memories ADD COLUMN token_cost REAL",
|
|
7283
7286
|
"ALTER TABLE memories ADD COLUMN audience TEXT",
|
|
7284
7287
|
"ALTER TABLE memories ADD COLUMN language_type TEXT",
|
|
7285
|
-
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT"
|
|
7288
|
+
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT",
|
|
7289
|
+
"ALTER TABLE memories ADD COLUMN deleted_at TEXT"
|
|
7286
7290
|
]) {
|
|
7287
7291
|
try {
|
|
7288
7292
|
await client.execute(col);
|
|
@@ -7378,9 +7382,32 @@ async function ensureShardSchema(client) {
|
|
|
7378
7382
|
}
|
|
7379
7383
|
}
|
|
7380
7384
|
async function getReadyShardClient(projectName) {
|
|
7381
|
-
const
|
|
7382
|
-
|
|
7383
|
-
|
|
7385
|
+
const safeName = safeShardName(projectName);
|
|
7386
|
+
let client = getShardClient(projectName);
|
|
7387
|
+
try {
|
|
7388
|
+
await ensureShardSchema(client);
|
|
7389
|
+
return client;
|
|
7390
|
+
} catch (err) {
|
|
7391
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
7392
|
+
if (!/SQLITE_NOTADB|file is not a database/i.test(message)) throw err;
|
|
7393
|
+
client.close();
|
|
7394
|
+
_shards.delete(safeName);
|
|
7395
|
+
_shardLastAccess.delete(safeName);
|
|
7396
|
+
const dbPath = path21.join(SHARDS_DIR, `${safeName}.db`);
|
|
7397
|
+
if (existsSync17(dbPath)) {
|
|
7398
|
+
const stat = statSync2(dbPath);
|
|
7399
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
7400
|
+
const archivedPath = path21.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
7401
|
+
renameSync4(dbPath, archivedPath);
|
|
7402
|
+
process.stderr.write(
|
|
7403
|
+
`[shard-manager] Archived unreadable shard ${safeName}: ${archivedPath} (${stat.size} bytes, mtime ${stat.mtime.toISOString()})
|
|
7404
|
+
`
|
|
7405
|
+
);
|
|
7406
|
+
}
|
|
7407
|
+
client = getShardClient(projectName);
|
|
7408
|
+
await ensureShardSchema(client);
|
|
7409
|
+
return client;
|
|
7410
|
+
}
|
|
7384
7411
|
}
|
|
7385
7412
|
function evictLRU() {
|
|
7386
7413
|
let oldest = null;
|
|
@@ -8385,7 +8412,7 @@ var init_fast_db_init = __esm({
|
|
|
8385
8412
|
});
|
|
8386
8413
|
|
|
8387
8414
|
// src/lib/memory-queue.ts
|
|
8388
|
-
import { appendFileSync as appendFileSync2, readFileSync as readFileSync15, renameSync as
|
|
8415
|
+
import { appendFileSync as appendFileSync2, readFileSync as readFileSync15, renameSync as renameSync5, unlinkSync as unlinkSync9, existsSync as existsSync18, statSync as statSync3 } from "fs";
|
|
8389
8416
|
import path22 from "path";
|
|
8390
8417
|
function enqueueMemory(entry) {
|
|
8391
8418
|
appendFileSync2(QUEUE_PATH2, JSON.stringify(entry) + "\n");
|
|
@@ -594,7 +594,8 @@ function isMultiInstance(agentName, employees) {
|
|
|
594
594
|
return MULTI_INSTANCE_ROLES.has(emp.role.toLowerCase());
|
|
595
595
|
}
|
|
596
596
|
function addEmployee(employees, employee) {
|
|
597
|
-
const
|
|
597
|
+
const { systemPrompt: _legacyPrompt, ...rest } = employee;
|
|
598
|
+
const normalized = { ...rest, name: employee.name.toLowerCase() };
|
|
598
599
|
if (employees.some((e) => e.name.toLowerCase() === normalized.name)) {
|
|
599
600
|
throw new Error(`Employee '${normalized.name}' already exists`);
|
|
600
601
|
}
|
|
@@ -3649,7 +3650,7 @@ __export(shard_manager_exports, {
|
|
|
3649
3650
|
shardExists: () => shardExists
|
|
3650
3651
|
});
|
|
3651
3652
|
import path8 from "path";
|
|
3652
|
-
import { existsSync as existsSync8, mkdirSync as mkdirSync2, readdirSync } from "fs";
|
|
3653
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as statSync2 } from "fs";
|
|
3653
3654
|
import { createClient as createClient2 } from "@libsql/client";
|
|
3654
3655
|
function initShardManager(encryptionKey) {
|
|
3655
3656
|
_encryptionKey = encryptionKey;
|
|
@@ -3671,7 +3672,7 @@ function getShardClient(projectName) {
|
|
|
3671
3672
|
if (!_encryptionKey) {
|
|
3672
3673
|
throw new Error("Shard manager not initialized. Call initShardManager() first.");
|
|
3673
3674
|
}
|
|
3674
|
-
const safeName = projectName
|
|
3675
|
+
const safeName = safeShardName(projectName);
|
|
3675
3676
|
if (!safeName || safeName === "unknown") {
|
|
3676
3677
|
throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
|
|
3677
3678
|
}
|
|
@@ -3693,9 +3694,12 @@ function getShardClient(projectName) {
|
|
|
3693
3694
|
return client;
|
|
3694
3695
|
}
|
|
3695
3696
|
function shardExists(projectName) {
|
|
3696
|
-
const safeName = projectName
|
|
3697
|
+
const safeName = safeShardName(projectName);
|
|
3697
3698
|
return existsSync8(path8.join(SHARDS_DIR, `${safeName}.db`));
|
|
3698
3699
|
}
|
|
3700
|
+
function safeShardName(projectName) {
|
|
3701
|
+
return projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
3702
|
+
}
|
|
3699
3703
|
function listShards() {
|
|
3700
3704
|
if (!existsSync8(SHARDS_DIR)) return [];
|
|
3701
3705
|
return readdirSync(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
|
|
@@ -3789,7 +3793,8 @@ async function ensureShardSchema(client) {
|
|
|
3789
3793
|
"ALTER TABLE memories ADD COLUMN token_cost REAL",
|
|
3790
3794
|
"ALTER TABLE memories ADD COLUMN audience TEXT",
|
|
3791
3795
|
"ALTER TABLE memories ADD COLUMN language_type TEXT",
|
|
3792
|
-
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT"
|
|
3796
|
+
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT",
|
|
3797
|
+
"ALTER TABLE memories ADD COLUMN deleted_at TEXT"
|
|
3793
3798
|
]) {
|
|
3794
3799
|
try {
|
|
3795
3800
|
await client.execute(col);
|
|
@@ -3885,9 +3890,32 @@ async function ensureShardSchema(client) {
|
|
|
3885
3890
|
}
|
|
3886
3891
|
}
|
|
3887
3892
|
async function getReadyShardClient(projectName) {
|
|
3888
|
-
const
|
|
3889
|
-
|
|
3890
|
-
|
|
3893
|
+
const safeName = safeShardName(projectName);
|
|
3894
|
+
let client = getShardClient(projectName);
|
|
3895
|
+
try {
|
|
3896
|
+
await ensureShardSchema(client);
|
|
3897
|
+
return client;
|
|
3898
|
+
} catch (err) {
|
|
3899
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
3900
|
+
if (!/SQLITE_NOTADB|file is not a database/i.test(message)) throw err;
|
|
3901
|
+
client.close();
|
|
3902
|
+
_shards.delete(safeName);
|
|
3903
|
+
_shardLastAccess.delete(safeName);
|
|
3904
|
+
const dbPath = path8.join(SHARDS_DIR, `${safeName}.db`);
|
|
3905
|
+
if (existsSync8(dbPath)) {
|
|
3906
|
+
const stat = statSync2(dbPath);
|
|
3907
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
3908
|
+
const archivedPath = path8.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
3909
|
+
renameSync3(dbPath, archivedPath);
|
|
3910
|
+
process.stderr.write(
|
|
3911
|
+
`[shard-manager] Archived unreadable shard ${safeName}: ${archivedPath} (${stat.size} bytes, mtime ${stat.mtime.toISOString()})
|
|
3912
|
+
`
|
|
3913
|
+
);
|
|
3914
|
+
}
|
|
3915
|
+
client = getShardClient(projectName);
|
|
3916
|
+
await ensureShardSchema(client);
|
|
3917
|
+
return client;
|
|
3918
|
+
}
|
|
3891
3919
|
}
|
|
3892
3920
|
function evictLRU() {
|
|
3893
3921
|
let oldest = null;
|
|
@@ -5162,7 +5190,7 @@ __export(file_grep_exports, {
|
|
|
5162
5190
|
grepProjectFiles: () => grepProjectFiles
|
|
5163
5191
|
});
|
|
5164
5192
|
import { execSync as execSync4 } from "child_process";
|
|
5165
|
-
import { readFileSync as readFileSync6, readdirSync as readdirSync2, statSync as
|
|
5193
|
+
import { readFileSync as readFileSync6, readdirSync as readdirSync2, statSync as statSync3, existsSync as existsSync10 } from "fs";
|
|
5166
5194
|
import path11 from "path";
|
|
5167
5195
|
import crypto2 from "crypto";
|
|
5168
5196
|
function hasRipgrep() {
|
|
@@ -5279,7 +5307,7 @@ function grepWithNodeFs(pattern, projectRoot, patterns) {
|
|
|
5279
5307
|
for (const filePath of files.slice(0, MAX_FILES)) {
|
|
5280
5308
|
const absPath = path11.join(projectRoot, filePath);
|
|
5281
5309
|
try {
|
|
5282
|
-
const stat =
|
|
5310
|
+
const stat = statSync3(absPath);
|
|
5283
5311
|
if (stat.size > MAX_FILE_SIZE) continue;
|
|
5284
5312
|
const content = readFileSync6(absPath, "utf8");
|
|
5285
5313
|
const lines = content.split("\n");
|
|
@@ -7006,7 +7034,7 @@ var init_provider_table = __esm({
|
|
|
7006
7034
|
});
|
|
7007
7035
|
|
|
7008
7036
|
// src/lib/intercom-queue.ts
|
|
7009
|
-
import { readFileSync as readFileSync8, writeFileSync as writeFileSync5, renameSync as
|
|
7037
|
+
import { readFileSync as readFileSync8, writeFileSync as writeFileSync5, renameSync as renameSync4, existsSync as existsSync11, mkdirSync as mkdirSync4 } from "fs";
|
|
7010
7038
|
import path14 from "path";
|
|
7011
7039
|
import os7 from "os";
|
|
7012
7040
|
var QUEUE_PATH, TTL_MS, INTERCOM_LOG;
|
|
@@ -7483,6 +7511,9 @@ function ensureDir() {
|
|
|
7483
7511
|
function identityPath(agentId) {
|
|
7484
7512
|
return path19.join(IDENTITY_DIR2, `${agentId}.md`);
|
|
7485
7513
|
}
|
|
7514
|
+
function sanitizeIdentityBody(body) {
|
|
7515
|
+
return body.replace(/<!--[\s\S]*?-->/g, "").trim();
|
|
7516
|
+
}
|
|
7486
7517
|
function parseFrontmatter(raw) {
|
|
7487
7518
|
const match = raw.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
|
|
7488
7519
|
if (!match) {
|
|
@@ -7495,11 +7526,11 @@ function parseFrontmatter(raw) {
|
|
|
7495
7526
|
created_by: "system",
|
|
7496
7527
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
7497
7528
|
},
|
|
7498
|
-
body: raw
|
|
7529
|
+
body: sanitizeIdentityBody(raw)
|
|
7499
7530
|
};
|
|
7500
7531
|
}
|
|
7501
7532
|
const yamlStr = match[1];
|
|
7502
|
-
const body = match[2]
|
|
7533
|
+
const body = sanitizeIdentityBody(match[2]);
|
|
7503
7534
|
const fm = {};
|
|
7504
7535
|
for (const line of yamlStr.split("\n")) {
|
|
7505
7536
|
const kv = line.match(/^(\w+):\s*(.+)$/);
|
|
@@ -7564,7 +7595,9 @@ function listIdentities() {
|
|
|
7564
7595
|
const summary = lines[0]?.trim().slice(0, 120) ?? identity.frontmatter.title;
|
|
7565
7596
|
results.push({
|
|
7566
7597
|
agentId,
|
|
7567
|
-
title
|
|
7598
|
+
// User-facing/team-facing title only. `frontmatter.role` is internal
|
|
7599
|
+
// routing metadata and must not leak as an external title.
|
|
7600
|
+
title: identity.frontmatter.title,
|
|
7568
7601
|
summary
|
|
7569
7602
|
});
|
|
7570
7603
|
}
|