@askexenow/exe-os 0.8.61 → 0.8.63
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 +2 -3
- package/dist/bin/backfill-responses.js +3 -4
- package/dist/bin/backfill-vectors.js +0 -1
- package/dist/bin/cleanup-stale-review-tasks.js +0 -1
- package/dist/bin/cli.js +1654 -397
- package/dist/bin/exe-assign.js +0 -1
- package/dist/bin/exe-boot.js +61 -84
- package/dist/bin/exe-cloud.js +28 -60
- package/dist/bin/exe-dispatch.js +0 -1
- package/dist/bin/exe-doctor.js +0 -1
- package/dist/bin/exe-export-behaviors.js +1 -2
- package/dist/bin/exe-forget.js +0 -1
- package/dist/bin/exe-gateway.js +16 -17
- package/dist/bin/exe-heartbeat.js +1 -2
- package/dist/bin/exe-kill.js +2 -3
- package/dist/bin/exe-launch-agent.js +1 -2
- package/dist/bin/exe-link.js +49 -78
- package/dist/bin/exe-pending-messages.js +1 -2
- package/dist/bin/exe-pending-notifications.js +0 -1
- package/dist/bin/exe-pending-reviews.js +1 -2
- package/dist/bin/exe-review.js +0 -1
- package/dist/bin/exe-search.js +2 -3
- package/dist/bin/exe-session-cleanup.js +4 -5
- package/dist/bin/exe-status.js +0 -1
- package/dist/bin/exe-team.js +0 -1
- package/dist/bin/git-sweep.js +0 -1
- package/dist/bin/graph-backfill.js +5 -6
- package/dist/bin/graph-export.js +0 -1
- package/dist/bin/scan-tasks.js +0 -1
- package/dist/bin/setup.js +1460 -115
- package/dist/bin/shard-migrate.js +0 -1
- package/dist/bin/wiki-sync.js +0 -1
- package/dist/gateway/index.js +16 -17
- package/dist/hooks/bug-report-worker.js +11 -12
- package/dist/hooks/commit-complete.js +0 -1
- package/dist/hooks/error-recall.js +2 -3
- package/dist/hooks/ingest-worker.js +14 -15
- package/dist/hooks/instructions-loaded.js +0 -1
- package/dist/hooks/notification.js +0 -1
- package/dist/hooks/post-compact.js +0 -1
- package/dist/hooks/pre-compact.js +2 -3
- package/dist/hooks/pre-tool-use.js +0 -1
- package/dist/hooks/prompt-ingest-worker.js +2 -3
- package/dist/hooks/prompt-submit.js +6 -7
- package/dist/hooks/response-ingest-worker.js +2 -3
- package/dist/hooks/session-end.js +3 -4
- package/dist/hooks/session-start.js +2 -3
- package/dist/hooks/stop.js +2 -3
- package/dist/hooks/subagent-stop.js +0 -1
- package/dist/hooks/summary-worker.js +51 -74
- package/dist/index.js +7 -8
- package/dist/lib/cloud-sync.js +21 -12
- package/dist/lib/consolidation.js +0 -1
- package/dist/lib/exe-daemon.js +33 -65
- package/dist/lib/hybrid-search.js +2 -3
- package/dist/lib/keychain.js +19 -58
- package/dist/lib/schedules.js +2 -3
- package/dist/lib/store.js +0 -1
- package/dist/mcp/server.js +29 -30
- package/dist/runtime/index.js +2 -3
- package/dist/tui/App.js +24 -56
- package/package.json +1 -1
package/dist/lib/schedules.js
CHANGED
|
@@ -1531,7 +1531,7 @@ ${p.content}`).join("\n\n");
|
|
|
1531
1531
|
|
|
1532
1532
|
// src/lib/schedules.ts
|
|
1533
1533
|
init_database();
|
|
1534
|
-
import
|
|
1534
|
+
import crypto from "crypto";
|
|
1535
1535
|
import { execSync } from "child_process";
|
|
1536
1536
|
|
|
1537
1537
|
// src/lib/store.ts
|
|
@@ -1542,7 +1542,6 @@ import { readFile, writeFile, unlink, mkdir, chmod } from "fs/promises";
|
|
|
1542
1542
|
import { existsSync } from "fs";
|
|
1543
1543
|
import path from "path";
|
|
1544
1544
|
import os from "os";
|
|
1545
|
-
import crypto from "crypto";
|
|
1546
1545
|
var SERVICE = "exe-mem";
|
|
1547
1546
|
var ACCOUNT = "master-key";
|
|
1548
1547
|
function getKeyDir() {
|
|
@@ -1779,7 +1778,7 @@ function parseHumanCron(input) {
|
|
|
1779
1778
|
async function createSchedule(input) {
|
|
1780
1779
|
await ensureDb();
|
|
1781
1780
|
const client = getClient();
|
|
1782
|
-
const id =
|
|
1781
|
+
const id = crypto.randomUUID().slice(0, 8);
|
|
1783
1782
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1784
1783
|
const prompt = input.prompt ?? input.description;
|
|
1785
1784
|
await client.execute({
|
package/dist/lib/store.js
CHANGED
|
@@ -1545,7 +1545,6 @@ import { readFile, writeFile, unlink, mkdir, chmod } from "fs/promises";
|
|
|
1545
1545
|
import { existsSync } from "fs";
|
|
1546
1546
|
import path from "path";
|
|
1547
1547
|
import os from "os";
|
|
1548
|
-
import crypto from "crypto";
|
|
1549
1548
|
var SERVICE = "exe-mem";
|
|
1550
1549
|
var ACCOUNT = "master-key";
|
|
1551
1550
|
function getKeyDir() {
|
package/dist/mcp/server.js
CHANGED
|
@@ -1625,7 +1625,6 @@ import { readFile as readFile2, writeFile as writeFile2, unlink, mkdir as mkdir2
|
|
|
1625
1625
|
import { existsSync as existsSync3 } from "fs";
|
|
1626
1626
|
import path3 from "path";
|
|
1627
1627
|
import os2 from "os";
|
|
1628
|
-
import crypto from "crypto";
|
|
1629
1628
|
function getKeyDir() {
|
|
1630
1629
|
return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path3.join(os2.homedir(), ".exe-os");
|
|
1631
1630
|
}
|
|
@@ -2783,7 +2782,7 @@ __export(file_grep_exports, {
|
|
|
2783
2782
|
import { execSync as execSync2 } from "child_process";
|
|
2784
2783
|
import { readFileSync as readFileSync3, readdirSync as readdirSync2, statSync as statSync2, existsSync as existsSync5 } from "fs";
|
|
2785
2784
|
import path6 from "path";
|
|
2786
|
-
import
|
|
2785
|
+
import crypto from "crypto";
|
|
2787
2786
|
function hasRipgrep() {
|
|
2788
2787
|
if (_hasRg === null) {
|
|
2789
2788
|
try {
|
|
@@ -2816,7 +2815,7 @@ async function grepProjectFiles(query, projectRoot, options) {
|
|
|
2816
2815
|
const chunkCtx = getChunkContext(hit.filePath, hit.lineNumber);
|
|
2817
2816
|
const prefix = chunkCtx ? `[file: ${hit.filePath}:${hit.lineNumber} in ${chunkCtx}]` : `[file: ${hit.filePath}:${hit.lineNumber}]`;
|
|
2818
2817
|
return {
|
|
2819
|
-
id:
|
|
2818
|
+
id: crypto.createHash("sha256").update(`${hit.filePath}:${hit.lineNumber}`).digest("hex").slice(0, 36),
|
|
2820
2819
|
agent_id: "project",
|
|
2821
2820
|
agent_role: "file",
|
|
2822
2821
|
session_id: "file-grep",
|
|
@@ -3935,7 +3934,7 @@ var init_plan_limits = __esm({
|
|
|
3935
3934
|
});
|
|
3936
3935
|
|
|
3937
3936
|
// src/lib/notifications.ts
|
|
3938
|
-
import
|
|
3937
|
+
import crypto4 from "crypto";
|
|
3939
3938
|
import path14 from "path";
|
|
3940
3939
|
import os3 from "os";
|
|
3941
3940
|
import {
|
|
@@ -3948,7 +3947,7 @@ import {
|
|
|
3948
3947
|
async function writeNotification(notification) {
|
|
3949
3948
|
try {
|
|
3950
3949
|
const client = getClient();
|
|
3951
|
-
const id =
|
|
3950
|
+
const id = crypto4.randomUUID();
|
|
3952
3951
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3953
3952
|
await client.execute({
|
|
3954
3953
|
sql: `INSERT INTO notifications (id, agent_id, agent_role, event, project, summary, task_file, read, created_at)
|
|
@@ -4250,7 +4249,7 @@ var init_intercom_queue = __esm({
|
|
|
4250
4249
|
});
|
|
4251
4250
|
|
|
4252
4251
|
// src/lib/session-kill-telemetry.ts
|
|
4253
|
-
import
|
|
4252
|
+
import crypto5 from "crypto";
|
|
4254
4253
|
async function recordSessionKill(input) {
|
|
4255
4254
|
try {
|
|
4256
4255
|
const client = getClient();
|
|
@@ -4260,7 +4259,7 @@ async function recordSessionKill(input) {
|
|
|
4260
4259
|
ticks_idle, estimated_tokens_saved)
|
|
4261
4260
|
VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
|
4262
4261
|
args: [
|
|
4263
|
-
|
|
4262
|
+
crypto5.randomUUID(),
|
|
4264
4263
|
input.sessionName,
|
|
4265
4264
|
input.agentId,
|
|
4266
4265
|
(/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -5244,7 +5243,7 @@ var init_task_scope = __esm({
|
|
|
5244
5243
|
});
|
|
5245
5244
|
|
|
5246
5245
|
// src/lib/tasks-crud.ts
|
|
5247
|
-
import
|
|
5246
|
+
import crypto6 from "crypto";
|
|
5248
5247
|
import path18 from "path";
|
|
5249
5248
|
import { execSync as execSync8 } from "child_process";
|
|
5250
5249
|
import { mkdir as mkdir4, writeFile as writeFile4, appendFile } from "fs/promises";
|
|
@@ -5335,7 +5334,7 @@ async function resolveTask(client, identifier, scopeSession) {
|
|
|
5335
5334
|
}
|
|
5336
5335
|
async function createTaskCore(input) {
|
|
5337
5336
|
const client = getClient();
|
|
5338
|
-
const id =
|
|
5337
|
+
const id = crypto6.randomUUID();
|
|
5339
5338
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
5340
5339
|
const slug = slugify(input.title);
|
|
5341
5340
|
const taskFile = input.taskFile ?? `exe/${input.assignedTo}/${slug}.md`;
|
|
@@ -6079,10 +6078,10 @@ var init_tasks_notify = __esm({
|
|
|
6079
6078
|
});
|
|
6080
6079
|
|
|
6081
6080
|
// src/lib/behaviors.ts
|
|
6082
|
-
import
|
|
6081
|
+
import crypto7 from "crypto";
|
|
6083
6082
|
async function storeBehavior(opts) {
|
|
6084
6083
|
const client = getClient();
|
|
6085
|
-
const id =
|
|
6084
|
+
const id = crypto7.randomUUID();
|
|
6086
6085
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
6087
6086
|
await client.execute({
|
|
6088
6087
|
sql: `INSERT INTO behaviors (id, agent_id, project_name, domain, priority, content, active, created_at, updated_at)
|
|
@@ -6139,7 +6138,7 @@ __export(skill_learning_exports, {
|
|
|
6139
6138
|
storeTrajectory: () => storeTrajectory,
|
|
6140
6139
|
sweepTrajectories: () => sweepTrajectories
|
|
6141
6140
|
});
|
|
6142
|
-
import
|
|
6141
|
+
import crypto8 from "crypto";
|
|
6143
6142
|
async function extractTrajectory(taskId, agentId) {
|
|
6144
6143
|
const client = getClient();
|
|
6145
6144
|
const result = await client.execute({
|
|
@@ -6168,11 +6167,11 @@ async function extractTrajectory(taskId, agentId) {
|
|
|
6168
6167
|
return signature;
|
|
6169
6168
|
}
|
|
6170
6169
|
function hashSignature(signature) {
|
|
6171
|
-
return
|
|
6170
|
+
return crypto8.createHash("sha256").update(signature.join("|")).digest("hex").slice(0, 16);
|
|
6172
6171
|
}
|
|
6173
6172
|
async function storeTrajectory(opts) {
|
|
6174
6173
|
const client = getClient();
|
|
6175
|
-
const id =
|
|
6174
|
+
const id = crypto8.randomUUID();
|
|
6176
6175
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
6177
6176
|
const signatureHash = hashSignature(opts.signature);
|
|
6178
6177
|
await client.execute({
|
|
@@ -6598,10 +6597,10 @@ var init_tasks = __esm({
|
|
|
6598
6597
|
});
|
|
6599
6598
|
|
|
6600
6599
|
// src/lib/messaging.ts
|
|
6601
|
-
import
|
|
6600
|
+
import crypto9 from "crypto";
|
|
6602
6601
|
function generateUlid() {
|
|
6603
6602
|
const timestamp = Date.now().toString(36).padStart(10, "0");
|
|
6604
|
-
const random =
|
|
6603
|
+
const random = crypto9.randomBytes(10).toString("hex").slice(0, 16);
|
|
6605
6604
|
return (timestamp + random).toUpperCase();
|
|
6606
6605
|
}
|
|
6607
6606
|
function rowToMessage(row) {
|
|
@@ -7892,7 +7891,7 @@ init_store();
|
|
|
7892
7891
|
init_active_agent();
|
|
7893
7892
|
init_plan_limits();
|
|
7894
7893
|
import { z as z4 } from "zod";
|
|
7895
|
-
import
|
|
7894
|
+
import crypto2 from "crypto";
|
|
7896
7895
|
import { writeFileSync as writeFileSync3 } from "fs";
|
|
7897
7896
|
import path12 from "path";
|
|
7898
7897
|
function registerStoreMemory(server2) {
|
|
@@ -7943,7 +7942,7 @@ function registerStoreMemory(server2) {
|
|
|
7943
7942
|
vector = null;
|
|
7944
7943
|
needsBackfill = true;
|
|
7945
7944
|
}
|
|
7946
|
-
const memoryId =
|
|
7945
|
+
const memoryId = crypto2.randomUUID();
|
|
7947
7946
|
await writeMemory({
|
|
7948
7947
|
id: memoryId,
|
|
7949
7948
|
agent_id: agentId,
|
|
@@ -7985,7 +7984,7 @@ init_store();
|
|
|
7985
7984
|
init_plan_limits();
|
|
7986
7985
|
init_active_agent();
|
|
7987
7986
|
import { z as z5 } from "zod";
|
|
7988
|
-
import
|
|
7987
|
+
import crypto3 from "crypto";
|
|
7989
7988
|
import { writeFileSync as writeFileSync4 } from "fs";
|
|
7990
7989
|
import path13 from "path";
|
|
7991
7990
|
function registerCommitMemory(server2) {
|
|
@@ -8034,7 +8033,7 @@ function registerCommitMemory(server2) {
|
|
|
8034
8033
|
vector = null;
|
|
8035
8034
|
needsBackfill = true;
|
|
8036
8035
|
}
|
|
8037
|
-
const memoryId =
|
|
8036
|
+
const memoryId = crypto3.randomUUID();
|
|
8038
8037
|
await assertMemoryLimit();
|
|
8039
8038
|
await writeMemory({
|
|
8040
8039
|
id: memoryId,
|
|
@@ -9007,10 +9006,10 @@ import { z as z16 } from "zod";
|
|
|
9007
9006
|
|
|
9008
9007
|
// src/lib/reminders.ts
|
|
9009
9008
|
init_database();
|
|
9010
|
-
import
|
|
9009
|
+
import crypto10 from "crypto";
|
|
9011
9010
|
async function createReminder(text, dueDate) {
|
|
9012
9011
|
const client = getClient();
|
|
9013
|
-
const id =
|
|
9012
|
+
const id = crypto10.randomUUID();
|
|
9014
9013
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
9015
9014
|
await client.execute({
|
|
9016
9015
|
sql: `INSERT INTO reminders (id, text, created_at, due_date) VALUES (?, ?, ?, ?)`,
|
|
@@ -9496,7 +9495,7 @@ import { z as z23 } from "zod";
|
|
|
9496
9495
|
init_database();
|
|
9497
9496
|
init_embedder();
|
|
9498
9497
|
init_store();
|
|
9499
|
-
import
|
|
9498
|
+
import crypto11 from "crypto";
|
|
9500
9499
|
var WIKI_AGENT_ID = "wiki";
|
|
9501
9500
|
var WIKI_AGENT_ROLE = "Knowledge";
|
|
9502
9501
|
var WIKI_TOOL_NAME = "ingest_document";
|
|
@@ -9550,7 +9549,7 @@ async function resolveWorkspace(slug_or_id, name) {
|
|
|
9550
9549
|
if (existing.rows.length > 0) {
|
|
9551
9550
|
return rowToWorkspace(existing.rows[0]);
|
|
9552
9551
|
}
|
|
9553
|
-
const id =
|
|
9552
|
+
const id = crypto11.randomUUID();
|
|
9554
9553
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
9555
9554
|
const resolvedName = name ?? slug_or_id;
|
|
9556
9555
|
await client.execute({
|
|
@@ -9641,13 +9640,13 @@ async function ingestDocument(input) {
|
|
|
9641
9640
|
}));
|
|
9642
9641
|
const vectors = await embedTexts(enrichedChunks.map((c) => c.text));
|
|
9643
9642
|
const client = getClient();
|
|
9644
|
-
const documentId =
|
|
9643
|
+
const documentId = crypto11.randomUUID();
|
|
9645
9644
|
const uploadedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
9646
9645
|
const mime = input.mime ?? null;
|
|
9647
9646
|
const sourceType = input.source_type ?? DEFAULT_SOURCE_TYPE;
|
|
9648
9647
|
const userId = input.user_id ?? null;
|
|
9649
9648
|
const documentMetadata = input.document_metadata != null ? JSON.stringify(input.document_metadata) : null;
|
|
9650
|
-
const chunkIds = input.chunks.map(() =>
|
|
9649
|
+
const chunkIds = input.chunks.map(() => crypto11.randomUUID());
|
|
9651
9650
|
const versions = reserveVersions(input.chunks.length);
|
|
9652
9651
|
const documentStmt = {
|
|
9653
9652
|
sql: `INSERT INTO documents
|
|
@@ -10317,7 +10316,7 @@ function isScheduledTrigger(trigger) {
|
|
|
10317
10316
|
// src/lib/schedules.ts
|
|
10318
10317
|
init_database();
|
|
10319
10318
|
init_store();
|
|
10320
|
-
import
|
|
10319
|
+
import crypto12 from "crypto";
|
|
10321
10320
|
import { execSync as execSync9 } from "child_process";
|
|
10322
10321
|
async function ensureDb() {
|
|
10323
10322
|
if (!isInitialized()) {
|
|
@@ -10386,7 +10385,7 @@ function parseHumanCron(input) {
|
|
|
10386
10385
|
async function createSchedule(input) {
|
|
10387
10386
|
await ensureDb();
|
|
10388
10387
|
const client = getClient();
|
|
10389
|
-
const id =
|
|
10388
|
+
const id = crypto12.randomUUID().slice(0, 8);
|
|
10390
10389
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
10391
10390
|
const prompt = input.prompt ?? input.description;
|
|
10392
10391
|
await client.execute({
|
|
@@ -11044,7 +11043,7 @@ init_database();
|
|
|
11044
11043
|
import { z as z32 } from "zod";
|
|
11045
11044
|
|
|
11046
11045
|
// src/lib/graph-rag.ts
|
|
11047
|
-
import
|
|
11046
|
+
import crypto13 from "crypto";
|
|
11048
11047
|
|
|
11049
11048
|
// src/lib/code-chunker.ts
|
|
11050
11049
|
import ts from "typescript";
|
|
@@ -11055,7 +11054,7 @@ function normalizeEntityName(name) {
|
|
|
11055
11054
|
}
|
|
11056
11055
|
function entityId(name, type) {
|
|
11057
11056
|
const normalized = normalizeEntityName(name);
|
|
11058
|
-
return
|
|
11057
|
+
return crypto13.createHash("sha256").update(`${normalized}::${type.toLowerCase()}`).digest("hex").slice(0, 16);
|
|
11059
11058
|
}
|
|
11060
11059
|
async function registerAlias(client, alias, canonicalEntityId) {
|
|
11061
11060
|
const normalized = normalizeEntityName(alias);
|
package/dist/runtime/index.js
CHANGED
|
@@ -4160,7 +4160,6 @@ import { readFile as readFile4, writeFile as writeFile5, unlink, mkdir as mkdir4
|
|
|
4160
4160
|
import { existsSync as existsSync11 } from "fs";
|
|
4161
4161
|
import path15 from "path";
|
|
4162
4162
|
import os7 from "os";
|
|
4163
|
-
import crypto6 from "crypto";
|
|
4164
4163
|
function getKeyDir() {
|
|
4165
4164
|
return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path15.join(os7.homedir(), ".exe-os");
|
|
4166
4165
|
}
|
|
@@ -5320,7 +5319,7 @@ __export(error_detector_exports, {
|
|
|
5320
5319
|
errorFingerprint: () => errorFingerprint,
|
|
5321
5320
|
isExeOsError: () => isExeOsError
|
|
5322
5321
|
});
|
|
5323
|
-
import
|
|
5322
|
+
import crypto6 from "crypto";
|
|
5324
5323
|
function isRealStderr(stderr) {
|
|
5325
5324
|
const lines = stderr.trim().split("\n");
|
|
5326
5325
|
const meaningful = lines.filter(
|
|
@@ -5391,7 +5390,7 @@ function classifyError(errorText) {
|
|
|
5391
5390
|
}
|
|
5392
5391
|
function errorFingerprint(toolName, errorText) {
|
|
5393
5392
|
const normalized = errorText.replace(/\d{4}-\d{2}-\d{2}T[\d:.]+Z/g, "TIMESTAMP").replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, "UUID").replace(/\/Users\/[^\s]+/g, "PATH").replace(/:\d+:\d+/g, ":LINE:COL").slice(0, 200);
|
|
5394
|
-
return
|
|
5393
|
+
return crypto6.createHash("sha256").update(`${toolName}:${normalized}`).digest("hex").slice(0, 16);
|
|
5395
5394
|
}
|
|
5396
5395
|
var ERROR_PATTERNS, FILE_CONTENT_TOOLS, STDERR_IGNORE_PATTERNS, USER_ERROR_PATTERNS, SYSTEM_BUG_PATTERNS;
|
|
5397
5396
|
var init_error_detector = __esm({
|
package/dist/tui/App.js
CHANGED
|
@@ -7594,7 +7594,6 @@ import { readFile as readFile4, writeFile as writeFile5, unlink, mkdir as mkdir4
|
|
|
7594
7594
|
import { existsSync as existsSync12 } from "fs";
|
|
7595
7595
|
import path22 from "path";
|
|
7596
7596
|
import os7 from "os";
|
|
7597
|
-
import crypto6 from "crypto";
|
|
7598
7597
|
function getKeyDir() {
|
|
7599
7598
|
return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path22.join(os7.homedir(), ".exe-os");
|
|
7600
7599
|
}
|
|
@@ -7659,65 +7658,34 @@ async function deleteMasterKey() {
|
|
|
7659
7658
|
await unlink(keyPath);
|
|
7660
7659
|
}
|
|
7661
7660
|
}
|
|
7662
|
-
function
|
|
7663
|
-
if (key.length !== 32) {
|
|
7664
|
-
throw new Error(`Key must be 32 bytes, got ${key.length}`);
|
|
7665
|
-
}
|
|
7666
|
-
const hash = crypto6.createHash("sha256").update(key).digest();
|
|
7667
|
-
const checksumByte = hash[0];
|
|
7668
|
-
let bits = "";
|
|
7669
|
-
for (const byte of key) {
|
|
7670
|
-
bits += byte.toString(2).padStart(8, "0");
|
|
7671
|
-
}
|
|
7672
|
-
bits += checksumByte.toString(2).padStart(8, "0");
|
|
7673
|
-
const words = [];
|
|
7674
|
-
let wordlist;
|
|
7661
|
+
async function loadBip39() {
|
|
7675
7662
|
try {
|
|
7676
|
-
|
|
7677
|
-
wordlist = bip39.wordlists?.english ?? bip39.default?.wordlists?.english;
|
|
7678
|
-
if (!wordlist) throw new Error("no wordlist");
|
|
7663
|
+
return await import("bip39");
|
|
7679
7664
|
} catch {
|
|
7680
|
-
throw new Error(
|
|
7665
|
+
throw new Error(
|
|
7666
|
+
"bip39 package not found. Run: npm install -g bip39\nOr reinstall exe-os: npm install -g @askexenow/exe-os"
|
|
7667
|
+
);
|
|
7681
7668
|
}
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7669
|
+
}
|
|
7670
|
+
async function exportMnemonic(key) {
|
|
7671
|
+
if (key.length !== 32) {
|
|
7672
|
+
throw new Error(`Key must be 32 bytes, got ${key.length}`);
|
|
7685
7673
|
}
|
|
7686
|
-
|
|
7674
|
+
const { entropyToMnemonic } = await loadBip39();
|
|
7675
|
+
return entropyToMnemonic(key.toString("hex"));
|
|
7687
7676
|
}
|
|
7688
|
-
function importMnemonic(mnemonic) {
|
|
7689
|
-
const
|
|
7677
|
+
async function importMnemonic(mnemonic) {
|
|
7678
|
+
const trimmed = mnemonic.trim();
|
|
7679
|
+
const words = trimmed.split(/\s+/);
|
|
7690
7680
|
if (words.length !== 24) {
|
|
7691
7681
|
throw new Error(`Expected 24 words, got ${words.length}`);
|
|
7692
7682
|
}
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
wordlist = bip39.wordlists?.english ?? bip39.default?.wordlists?.english;
|
|
7697
|
-
if (!wordlist) throw new Error("no wordlist");
|
|
7698
|
-
} catch {
|
|
7699
|
-
throw new Error("bip39 package required. Install with: npm install bip39");
|
|
7700
|
-
}
|
|
7701
|
-
let bits = "";
|
|
7702
|
-
for (const word of words) {
|
|
7703
|
-
const index = wordlist.indexOf(word.toLowerCase());
|
|
7704
|
-
if (index === -1) {
|
|
7705
|
-
throw new Error(`Invalid BIP39 word: "${word}"`);
|
|
7706
|
-
}
|
|
7707
|
-
bits += index.toString(2).padStart(11, "0");
|
|
7683
|
+
const { validateMnemonic, mnemonicToEntropy } = await loadBip39();
|
|
7684
|
+
if (!validateMnemonic(trimmed)) {
|
|
7685
|
+
throw new Error("Invalid mnemonic \u2014 check for typos or missing words");
|
|
7708
7686
|
}
|
|
7709
|
-
const
|
|
7710
|
-
|
|
7711
|
-
const key = Buffer.alloc(32);
|
|
7712
|
-
for (let i = 0; i < 32; i++) {
|
|
7713
|
-
key[i] = parseInt(entropyBits.slice(i * 8, (i + 1) * 8), 2);
|
|
7714
|
-
}
|
|
7715
|
-
const hash = crypto6.createHash("sha256").update(key).digest();
|
|
7716
|
-
const expectedChecksum = hash[0].toString(2).padStart(8, "0");
|
|
7717
|
-
if (checksumBits !== expectedChecksum) {
|
|
7718
|
-
throw new Error("Invalid mnemonic checksum");
|
|
7719
|
-
}
|
|
7720
|
-
return key;
|
|
7687
|
+
const entropy = mnemonicToEntropy(trimmed);
|
|
7688
|
+
return Buffer.from(entropy, "hex");
|
|
7721
7689
|
}
|
|
7722
7690
|
var SERVICE, ACCOUNT;
|
|
7723
7691
|
var init_keychain = __esm({
|
|
@@ -7735,16 +7703,16 @@ __export(ws_auth_exports, {
|
|
|
7735
7703
|
deriveWsAuthToken: () => deriveWsAuthToken,
|
|
7736
7704
|
hashAuthToken: () => hashAuthToken
|
|
7737
7705
|
});
|
|
7738
|
-
import
|
|
7706
|
+
import crypto6 from "crypto";
|
|
7739
7707
|
function deriveWsAuthToken(masterKey) {
|
|
7740
|
-
return Buffer.from(
|
|
7708
|
+
return Buffer.from(crypto6.hkdfSync("sha256", masterKey, "", WS_AUTH_HKDF_INFO, 32));
|
|
7741
7709
|
}
|
|
7742
7710
|
function deriveOrgId(masterKey) {
|
|
7743
|
-
const raw = Buffer.from(
|
|
7744
|
-
return
|
|
7711
|
+
const raw = Buffer.from(crypto6.hkdfSync("sha256", masterKey, "", ORG_ID_HKDF_INFO, 32));
|
|
7712
|
+
return crypto6.createHash("sha256").update(raw).digest("hex").slice(0, 32);
|
|
7745
7713
|
}
|
|
7746
7714
|
function hashAuthToken(token) {
|
|
7747
|
-
return
|
|
7715
|
+
return crypto6.createHash("sha256").update(token).digest("hex");
|
|
7748
7716
|
}
|
|
7749
7717
|
var WS_AUTH_HKDF_INFO, ORG_ID_HKDF_INFO;
|
|
7750
7718
|
var init_ws_auth = __esm({
|
package/package.json
CHANGED