@hasna/assistants 1.1.52 → 1.1.53
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/index.js +158 -202
- package/dist/index.js.map +7 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -616,8 +616,6 @@ async function ensureConfigDir(sessionId, baseDir) {
|
|
|
616
616
|
const dirs = [
|
|
617
617
|
mkdir2(configDir, { recursive: true }),
|
|
618
618
|
mkdir2(join(configDir, "logs"), { recursive: true }),
|
|
619
|
-
mkdir2(join(configDir, "assistants"), { recursive: true }),
|
|
620
|
-
mkdir2(join(configDir, "migration"), { recursive: true }),
|
|
621
619
|
mkdir2(join(configDir, "temp"), { recursive: true }),
|
|
622
620
|
mkdir2(join(configDir, "messages"), { recursive: true }),
|
|
623
621
|
mkdir2(join(configDir, "backups"), { recursive: true })
|
|
@@ -21587,14 +21585,9 @@ function initAssistantsDir(basePath) {
|
|
|
21587
21585
|
const dirs = [
|
|
21588
21586
|
baseDir,
|
|
21589
21587
|
join11(baseDir, "logs"),
|
|
21590
|
-
join11(baseDir, "assistants"),
|
|
21591
|
-
join11(baseDir, "shared", "skills"),
|
|
21592
|
-
join11(baseDir, "commands"),
|
|
21593
21588
|
join11(baseDir, "temp"),
|
|
21594
|
-
join11(baseDir, "
|
|
21595
|
-
join11(baseDir, "
|
|
21596
|
-
join11(baseDir, "energy"),
|
|
21597
|
-
join11(baseDir, "migration")
|
|
21589
|
+
join11(baseDir, "messages"),
|
|
21590
|
+
join11(baseDir, "backups")
|
|
21598
21591
|
];
|
|
21599
21592
|
for (const dir of dirs) {
|
|
21600
21593
|
if (!existsSync8(dir)) {
|
|
@@ -22104,6 +22097,7 @@ function rowToSession(row) {
|
|
|
22104
22097
|
suggestions: [],
|
|
22105
22098
|
verificationResult: {
|
|
22106
22099
|
goalsMet: result === "pass",
|
|
22100
|
+
goalsAnalysis: [],
|
|
22107
22101
|
reason: "",
|
|
22108
22102
|
suggestions: []
|
|
22109
22103
|
},
|
|
@@ -89090,7 +89084,7 @@ Not a git repository or git not available.
|
|
|
89090
89084
|
context.setProjectContext(projectContext);
|
|
89091
89085
|
}
|
|
89092
89086
|
}
|
|
89093
|
-
var VERSION2 = "1.1.
|
|
89087
|
+
var VERSION2 = "1.1.53";
|
|
89094
89088
|
var init_builtin = __esm(async () => {
|
|
89095
89089
|
init_src2();
|
|
89096
89090
|
init_context3();
|
|
@@ -94234,65 +94228,38 @@ var init_recovery = __esm(async () => {
|
|
|
94234
94228
|
});
|
|
94235
94229
|
|
|
94236
94230
|
// packages/core/src/heartbeat/finder.ts
|
|
94237
|
-
import { existsSync as existsSync20, readdirSync as readdirSync7, readFileSync as readFileSync10 } from "fs";
|
|
94238
|
-
import { join as join26 } from "path";
|
|
94239
94231
|
function findRecoverableSessions(staleThresholdMs = 120000, maxAgeMs = 24 * 60 * 60 * 1000, baseDir) {
|
|
94240
|
-
const configDir = baseDir ?? getConfigDir();
|
|
94241
|
-
const heartbeatsDir = join26(configDir, "heartbeats");
|
|
94242
|
-
const stateDir = join26(configDir, "state");
|
|
94243
|
-
const sessionsDir = join26(configDir, "sessions");
|
|
94244
94232
|
const recoverableSessions = [];
|
|
94245
|
-
|
|
94233
|
+
let db;
|
|
94234
|
+
try {
|
|
94235
|
+
db = getDatabase();
|
|
94236
|
+
} catch {
|
|
94246
94237
|
return recoverableSessions;
|
|
94247
94238
|
}
|
|
94248
94239
|
const now2 = Date.now();
|
|
94249
|
-
const
|
|
94250
|
-
|
|
94251
|
-
|
|
94252
|
-
const heartbeatPath = join26(heartbeatsDir, file);
|
|
94253
|
-
const statePath = join26(stateDir, `${sessionId}.json`);
|
|
94254
|
-
const sessionPath = join26(sessionsDir, `${sessionId}.json`);
|
|
94240
|
+
const cutoffIso = new Date(now2 - maxAgeMs).toISOString();
|
|
94241
|
+
const rows = db.query("SELECT session_id, heartbeat, context, timestamp FROM heartbeat_state WHERE timestamp > ?").all(cutoffIso);
|
|
94242
|
+
for (const row of rows) {
|
|
94255
94243
|
try {
|
|
94256
|
-
const
|
|
94257
|
-
const
|
|
94244
|
+
const heartbeat = JSON.parse(row.heartbeat);
|
|
94245
|
+
const context = JSON.parse(row.context);
|
|
94258
94246
|
const heartbeatAge = now2 - new Date(heartbeat.timestamp).getTime();
|
|
94259
94247
|
if (heartbeatAge < staleThresholdMs) {
|
|
94260
94248
|
continue;
|
|
94261
94249
|
}
|
|
94262
|
-
|
|
94263
|
-
|
|
94264
|
-
|
|
94265
|
-
|
|
94266
|
-
|
|
94267
|
-
|
|
94268
|
-
const stateAge = now2 - new Date(state.timestamp).getTime();
|
|
94269
|
-
if (stateAge > maxAgeMs) {
|
|
94270
|
-
continue;
|
|
94271
|
-
}
|
|
94272
|
-
}
|
|
94250
|
+
const state = {
|
|
94251
|
+
sessionId: row.session_id,
|
|
94252
|
+
heartbeat,
|
|
94253
|
+
context,
|
|
94254
|
+
timestamp: row.timestamp
|
|
94255
|
+
};
|
|
94273
94256
|
let messageCount = 0;
|
|
94274
|
-
|
|
94275
|
-
if (existsSync20(sessionPath)) {
|
|
94276
|
-
try {
|
|
94277
|
-
const sessionContent = readFileSync10(sessionPath, "utf-8");
|
|
94278
|
-
const sessionData = JSON.parse(sessionContent);
|
|
94279
|
-
messageCount = sessionData.messages?.length || 0;
|
|
94280
|
-
cwd = sessionData.cwd || cwd;
|
|
94281
|
-
} catch {}
|
|
94282
|
-
}
|
|
94283
|
-
if (!state && messageCount === 0) {
|
|
94284
|
-
continue;
|
|
94285
|
-
}
|
|
94257
|
+
const cwd = context.cwd || process.cwd();
|
|
94286
94258
|
recoverableSessions.push({
|
|
94287
|
-
sessionId,
|
|
94259
|
+
sessionId: row.session_id,
|
|
94288
94260
|
heartbeat,
|
|
94289
|
-
state
|
|
94290
|
-
|
|
94291
|
-
heartbeat,
|
|
94292
|
-
context: { cwd },
|
|
94293
|
-
timestamp: heartbeat.timestamp
|
|
94294
|
-
},
|
|
94295
|
-
sessionPath,
|
|
94261
|
+
state,
|
|
94262
|
+
sessionPath: "",
|
|
94296
94263
|
cwd,
|
|
94297
94264
|
lastActivity: new Date(heartbeat.lastActivity || heartbeat.timestamp),
|
|
94298
94265
|
messageCount
|
|
@@ -94305,23 +94272,13 @@ function findRecoverableSessions(staleThresholdMs = 120000, maxAgeMs = 24 * 60 *
|
|
|
94305
94272
|
return recoverableSessions;
|
|
94306
94273
|
}
|
|
94307
94274
|
function clearRecoveryState(sessionId, baseDir) {
|
|
94308
|
-
const configDir = baseDir ?? getConfigDir();
|
|
94309
|
-
const heartbeatPath = join26(configDir, "heartbeats", `${sessionId}.json`);
|
|
94310
|
-
const statePath = join26(configDir, "state", `${sessionId}.json`);
|
|
94311
|
-
const { unlinkSync: unlinkSync3 } = __require("fs");
|
|
94312
94275
|
try {
|
|
94313
|
-
|
|
94314
|
-
|
|
94315
|
-
}
|
|
94316
|
-
} catch {}
|
|
94317
|
-
try {
|
|
94318
|
-
if (existsSync20(statePath)) {
|
|
94319
|
-
unlinkSync3(statePath);
|
|
94320
|
-
}
|
|
94276
|
+
const db = getDatabase();
|
|
94277
|
+
db.prepare("DELETE FROM heartbeat_state WHERE session_id = ?").run(sessionId);
|
|
94321
94278
|
} catch {}
|
|
94322
94279
|
}
|
|
94323
94280
|
var init_finder = __esm(async () => {
|
|
94324
|
-
await
|
|
94281
|
+
await init_database();
|
|
94325
94282
|
});
|
|
94326
94283
|
|
|
94327
94284
|
// packages/core/src/heartbeat/conventions.ts
|
|
@@ -94444,12 +94401,12 @@ var init_watchdog = __esm(async () => {
|
|
|
94444
94401
|
});
|
|
94445
94402
|
|
|
94446
94403
|
// packages/core/src/heartbeat/install-skills.ts
|
|
94447
|
-
import { join as
|
|
94404
|
+
import { join as join26 } from "path";
|
|
94448
94405
|
import { homedir as homedir16 } from "os";
|
|
94449
94406
|
async function writeSkillIfNeeded(dir, skillName, content) {
|
|
94450
94407
|
const { mkdir: mkdir7, writeFile: writeFile5, readFile: readFile6 } = await import("fs/promises");
|
|
94451
|
-
const skillDir =
|
|
94452
|
-
const skillFile =
|
|
94408
|
+
const skillDir = join26(dir, `skill-${skillName}`);
|
|
94409
|
+
const skillFile = join26(skillDir, "SKILL.md");
|
|
94453
94410
|
await mkdir7(skillDir, { recursive: true });
|
|
94454
94411
|
try {
|
|
94455
94412
|
const existing = await readFile6(skillFile, "utf-8");
|
|
@@ -94468,8 +94425,8 @@ async function writeSkillIfNeeded(dir, skillName, content) {
|
|
|
94468
94425
|
}
|
|
94469
94426
|
}
|
|
94470
94427
|
async function installHeartbeatSkills() {
|
|
94471
|
-
const baseDir = process.env.ASSISTANTS_DIR ||
|
|
94472
|
-
const sharedSkillsDir =
|
|
94428
|
+
const baseDir = process.env.ASSISTANTS_DIR || join26(homedir16(), ".assistants");
|
|
94429
|
+
const sharedSkillsDir = join26(baseDir, "shared", "skills");
|
|
94473
94430
|
const installed = [];
|
|
94474
94431
|
const results = await Promise.all([
|
|
94475
94432
|
writeSkillIfNeeded(sharedSkillsDir, "main-loop", MAIN_LOOP_SKILL),
|
|
@@ -94830,8 +94787,8 @@ var init_llm_response = __esm(() => {
|
|
|
94830
94787
|
// packages/core/src/voice/tts.ts
|
|
94831
94788
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
94832
94789
|
import { tmpdir as tmpdir2 } from "os";
|
|
94833
|
-
import { join as
|
|
94834
|
-
import { readFileSync as
|
|
94790
|
+
import { join as join27 } from "path";
|
|
94791
|
+
import { readFileSync as readFileSync10, unlinkSync as unlinkSync3 } from "fs";
|
|
94835
94792
|
|
|
94836
94793
|
class ElevenLabsTTS {
|
|
94837
94794
|
apiKey;
|
|
@@ -94935,7 +94892,7 @@ class SystemTTS {
|
|
|
94935
94892
|
if (!say) {
|
|
94936
94893
|
throw new Error('System TTS not available: missing "say" command.');
|
|
94937
94894
|
}
|
|
94938
|
-
const output =
|
|
94895
|
+
const output = join27(tmpdir2(), `assistants-tts-${Date.now()}-${Math.random().toString(36).slice(2, 8)}.aiff`);
|
|
94939
94896
|
const args = [];
|
|
94940
94897
|
if (this.voiceId) {
|
|
94941
94898
|
args.push("-v", this.voiceId);
|
|
@@ -94948,7 +94905,7 @@ class SystemTTS {
|
|
|
94948
94905
|
if (result.status !== 0) {
|
|
94949
94906
|
throw new Error(`System TTS failed: ${result.stderr || "unknown error"}`);
|
|
94950
94907
|
}
|
|
94951
|
-
const audio =
|
|
94908
|
+
const audio = readFileSync10(output);
|
|
94952
94909
|
unlinkSync3(output);
|
|
94953
94910
|
return {
|
|
94954
94911
|
audio: audio.buffer.slice(audio.byteOffset, audio.byteOffset + audio.byteLength),
|
|
@@ -94957,7 +94914,7 @@ class SystemTTS {
|
|
|
94957
94914
|
}
|
|
94958
94915
|
const espeak = findExecutable("espeak") || findExecutable("espeak-ng");
|
|
94959
94916
|
if (espeak) {
|
|
94960
|
-
const output =
|
|
94917
|
+
const output = join27(tmpdir2(), `assistants-tts-${Date.now()}-${Math.random().toString(36).slice(2, 8)}.wav`);
|
|
94961
94918
|
const args = ["-w", output];
|
|
94962
94919
|
if (this.voiceId) {
|
|
94963
94920
|
args.push("-v", this.voiceId);
|
|
@@ -94970,7 +94927,7 @@ class SystemTTS {
|
|
|
94970
94927
|
if (result.status !== 0) {
|
|
94971
94928
|
throw new Error(`System TTS failed: ${result.stderr || "unknown error"}`);
|
|
94972
94929
|
}
|
|
94973
|
-
const audio =
|
|
94930
|
+
const audio = readFileSync10(output);
|
|
94974
94931
|
unlinkSync3(output);
|
|
94975
94932
|
return {
|
|
94976
94933
|
audio: audio.buffer.slice(audio.byteOffset, audio.byteOffset + audio.byteLength),
|
|
@@ -94987,7 +94944,7 @@ var init_tts = __esm(() => {
|
|
|
94987
94944
|
// packages/core/src/voice/player.ts
|
|
94988
94945
|
import { spawn as spawn2 } from "child_process";
|
|
94989
94946
|
import { tmpdir as tmpdir3 } from "os";
|
|
94990
|
-
import { join as
|
|
94947
|
+
import { join as join28 } from "path";
|
|
94991
94948
|
import { unlink as unlink2, writeFileSync as writeFileSync10, appendFileSync as appendFileSync3 } from "fs";
|
|
94992
94949
|
|
|
94993
94950
|
class AudioPlayer {
|
|
@@ -94995,7 +94952,7 @@ class AudioPlayer {
|
|
|
94995
94952
|
playing = false;
|
|
94996
94953
|
async play(audio, options = {}) {
|
|
94997
94954
|
const format = options.format ?? "mp3";
|
|
94998
|
-
const tempFile =
|
|
94955
|
+
const tempFile = join28(tmpdir3(), `assistants-audio-${Date.now()}-${Math.random().toString(36).slice(2, 8)}.${format}`);
|
|
94999
94956
|
writeFileSync10(tempFile, Buffer.from(audio));
|
|
95000
94957
|
const player = this.resolvePlayer(format);
|
|
95001
94958
|
if (!player) {
|
|
@@ -95023,7 +94980,7 @@ class AudioPlayer {
|
|
|
95023
94980
|
}
|
|
95024
94981
|
async playStream(chunks, options = {}) {
|
|
95025
94982
|
const format = options.format ?? "mp3";
|
|
95026
|
-
const tempFile =
|
|
94983
|
+
const tempFile = join28(tmpdir3(), `assistants-stream-${Date.now()}-${Math.random().toString(36).slice(2, 8)}.${format}`);
|
|
95027
94984
|
writeFileSync10(tempFile, Buffer.alloc(0));
|
|
95028
94985
|
for await (const chunk of chunks) {
|
|
95029
94986
|
appendFileSync3(tempFile, Buffer.from(chunk));
|
|
@@ -95092,8 +95049,8 @@ var init_player = __esm(() => {
|
|
|
95092
95049
|
// packages/core/src/voice/recorder.ts
|
|
95093
95050
|
import { spawn as spawn3 } from "child_process";
|
|
95094
95051
|
import { tmpdir as tmpdir4 } from "os";
|
|
95095
|
-
import { join as
|
|
95096
|
-
import { readFileSync as
|
|
95052
|
+
import { join as join29 } from "path";
|
|
95053
|
+
import { readFileSync as readFileSync11, existsSync as existsSync20, unlink as unlink3 } from "fs";
|
|
95097
95054
|
|
|
95098
95055
|
class AudioRecorder {
|
|
95099
95056
|
currentProcess = null;
|
|
@@ -95106,7 +95063,7 @@ class AudioRecorder {
|
|
|
95106
95063
|
const duration = options.durationSeconds ?? 5;
|
|
95107
95064
|
const sampleRate = options.sampleRate ?? 16000;
|
|
95108
95065
|
const channels = options.channels ?? 1;
|
|
95109
|
-
const output =
|
|
95066
|
+
const output = join29(tmpdir4(), `assistants-record-${Date.now()}.wav`);
|
|
95110
95067
|
this.currentOutputPath = output;
|
|
95111
95068
|
this.stoppedIntentionally = false;
|
|
95112
95069
|
const recorder = this.resolveRecorder(sampleRate, channels, duration, output);
|
|
@@ -95128,11 +95085,11 @@ class AudioRecorder {
|
|
|
95128
95085
|
reject(error3);
|
|
95129
95086
|
});
|
|
95130
95087
|
});
|
|
95131
|
-
if (!
|
|
95088
|
+
if (!existsSync20(output)) {
|
|
95132
95089
|
this.currentOutputPath = null;
|
|
95133
95090
|
return new ArrayBuffer(0);
|
|
95134
95091
|
}
|
|
95135
|
-
const data =
|
|
95092
|
+
const data = readFileSync11(output);
|
|
95136
95093
|
unlink3(output, () => {});
|
|
95137
95094
|
this.currentOutputPath = null;
|
|
95138
95095
|
return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
@@ -95144,7 +95101,7 @@ class AudioRecorder {
|
|
|
95144
95101
|
const sampleRate = options.sampleRate ?? 16000;
|
|
95145
95102
|
const channels = options.channels ?? 1;
|
|
95146
95103
|
const maxDuration = options.durationSeconds ?? 30;
|
|
95147
|
-
const output =
|
|
95104
|
+
const output = join29(tmpdir4(), `assistants-record-${Date.now()}.wav`);
|
|
95148
95105
|
this.currentOutputPath = output;
|
|
95149
95106
|
this.stoppedIntentionally = false;
|
|
95150
95107
|
const recorder = this.resolveVadRecorder(sampleRate, channels, maxDuration, output);
|
|
@@ -95166,11 +95123,11 @@ class AudioRecorder {
|
|
|
95166
95123
|
reject(error3);
|
|
95167
95124
|
});
|
|
95168
95125
|
});
|
|
95169
|
-
if (!
|
|
95126
|
+
if (!existsSync20(output)) {
|
|
95170
95127
|
this.currentOutputPath = null;
|
|
95171
95128
|
return new ArrayBuffer(0);
|
|
95172
95129
|
}
|
|
95173
|
-
const data =
|
|
95130
|
+
const data = readFileSync11(output);
|
|
95174
95131
|
unlink3(output, () => {});
|
|
95175
95132
|
this.currentOutputPath = null;
|
|
95176
95133
|
return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
@@ -95554,9 +95511,9 @@ var init_manager4 = __esm(() => {
|
|
|
95554
95511
|
init_recorder();
|
|
95555
95512
|
});
|
|
95556
95513
|
// packages/core/src/identity/identity-manager.ts
|
|
95557
|
-
import { existsSync as
|
|
95514
|
+
import { existsSync as existsSync21 } from "fs";
|
|
95558
95515
|
import { mkdir as mkdir7, readFile as readFile6, writeFile as writeFile5, rm as rm2 } from "fs/promises";
|
|
95559
|
-
import { join as
|
|
95516
|
+
import { join as join30 } from "path";
|
|
95560
95517
|
function isValidId3(id) {
|
|
95561
95518
|
return typeof id === "string" && id.length > 0 && SAFE_ID_PATTERN4.test(id);
|
|
95562
95519
|
}
|
|
@@ -95577,20 +95534,20 @@ class IdentityManager {
|
|
|
95577
95534
|
this.basePath = basePath;
|
|
95578
95535
|
}
|
|
95579
95536
|
get identitiesRoot() {
|
|
95580
|
-
return
|
|
95537
|
+
return join30(this.basePath, "assistants", this.assistantId, "identities");
|
|
95581
95538
|
}
|
|
95582
95539
|
get indexPath() {
|
|
95583
|
-
return
|
|
95540
|
+
return join30(this.identitiesRoot, "index.json");
|
|
95584
95541
|
}
|
|
95585
95542
|
get activePath() {
|
|
95586
|
-
return
|
|
95543
|
+
return join30(this.identitiesRoot, "active.json");
|
|
95587
95544
|
}
|
|
95588
95545
|
identityPath(id) {
|
|
95589
95546
|
validateId(id, "identityId");
|
|
95590
|
-
return
|
|
95547
|
+
return join30(this.identitiesRoot, `${id}.json`);
|
|
95591
95548
|
}
|
|
95592
95549
|
assistantConfigPath() {
|
|
95593
|
-
return
|
|
95550
|
+
return join30(this.basePath, "assistants", this.assistantId, "config.json");
|
|
95594
95551
|
}
|
|
95595
95552
|
async initialize() {
|
|
95596
95553
|
await mkdir7(this.identitiesRoot, { recursive: true });
|
|
@@ -95716,7 +95673,7 @@ class IdentityManager {
|
|
|
95716
95673
|
`);
|
|
95717
95674
|
}
|
|
95718
95675
|
async readIndex() {
|
|
95719
|
-
if (!
|
|
95676
|
+
if (!existsSync21(this.indexPath)) {
|
|
95720
95677
|
return { identities: [] };
|
|
95721
95678
|
}
|
|
95722
95679
|
try {
|
|
@@ -95742,7 +95699,7 @@ class IdentityManager {
|
|
|
95742
95699
|
}
|
|
95743
95700
|
async readIdentity(id) {
|
|
95744
95701
|
const path3 = this.identityPath(id);
|
|
95745
|
-
if (!
|
|
95702
|
+
if (!existsSync21(path3))
|
|
95746
95703
|
return null;
|
|
95747
95704
|
try {
|
|
95748
95705
|
const raw = await readFile6(path3, "utf-8");
|
|
@@ -95756,7 +95713,7 @@ class IdentityManager {
|
|
|
95756
95713
|
await writeFile5(this.identityPath(identity.id), JSON.stringify(identity, null, 2));
|
|
95757
95714
|
}
|
|
95758
95715
|
async readActive() {
|
|
95759
|
-
if (!
|
|
95716
|
+
if (!existsSync21(this.activePath))
|
|
95760
95717
|
return null;
|
|
95761
95718
|
try {
|
|
95762
95719
|
const raw = await readFile6(this.activePath, "utf-8");
|
|
@@ -95775,7 +95732,7 @@ class IdentityManager {
|
|
|
95775
95732
|
await writeFile5(this.activePath, JSON.stringify({ id }, null, 2));
|
|
95776
95733
|
}
|
|
95777
95734
|
async loadAssistant() {
|
|
95778
|
-
if (!
|
|
95735
|
+
if (!existsSync21(this.assistantConfigPath()))
|
|
95779
95736
|
return null;
|
|
95780
95737
|
try {
|
|
95781
95738
|
const raw = await readFile6(this.assistantConfigPath(), "utf-8");
|
|
@@ -123477,7 +123434,7 @@ var require_signin = __commonJS((exports) => {
|
|
|
123477
123434
|
import { createHash as createHash4, createPrivateKey, createPublicKey, sign } from "crypto";
|
|
123478
123435
|
import { promises as fs2 } from "fs";
|
|
123479
123436
|
import { homedir as homedir17 } from "os";
|
|
123480
|
-
import { dirname as dirname13, join as
|
|
123437
|
+
import { dirname as dirname13, join as join31 } from "path";
|
|
123481
123438
|
var import_property_provider18, import_protocol_http11, import_shared_ini_file_loader6, LoginCredentialsFetcher;
|
|
123482
123439
|
var init_LoginCredentialsFetcher = __esm(() => {
|
|
123483
123440
|
import_property_provider18 = __toESM(require_dist_cjs17(), 1);
|
|
@@ -123637,10 +123594,10 @@ var init_LoginCredentialsFetcher = __esm(() => {
|
|
|
123637
123594
|
await fs2.writeFile(tokenFilePath, JSON.stringify(token, null, 2), "utf8");
|
|
123638
123595
|
}
|
|
123639
123596
|
getTokenFilePath() {
|
|
123640
|
-
const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ??
|
|
123597
|
+
const directory = process.env.AWS_LOGIN_CACHE_DIRECTORY ?? join31(homedir17(), ".aws", "login", "cache");
|
|
123641
123598
|
const loginSessionBytes = Buffer.from(this.loginSession, "utf8");
|
|
123642
123599
|
const loginSessionSha256 = createHash4("sha256").update(loginSessionBytes).digest("hex");
|
|
123643
|
-
return
|
|
123600
|
+
return join31(directory, `${loginSessionSha256}.json`);
|
|
123644
123601
|
}
|
|
123645
123602
|
derToRawSignature(derSignature) {
|
|
123646
123603
|
let offset = 2;
|
|
@@ -123946,7 +123903,7 @@ var fromWebToken = (init) => async (awsIdentityProperties) => {
|
|
|
123946
123903
|
};
|
|
123947
123904
|
|
|
123948
123905
|
// node_modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.972.5/node_modules/@aws-sdk/credential-provider-web-identity/dist-es/fromTokenFile.js
|
|
123949
|
-
import { readFileSync as
|
|
123906
|
+
import { readFileSync as readFileSync12 } from "fs";
|
|
123950
123907
|
var import_client17, import_property_provider21, import_shared_ini_file_loader10, ENV_TOKEN_FILE = "AWS_WEB_IDENTITY_TOKEN_FILE", ENV_ROLE_ARN = "AWS_ROLE_ARN", ENV_ROLE_SESSION_NAME = "AWS_ROLE_SESSION_NAME", fromTokenFile = (init = {}) => async (awsIdentityProperties) => {
|
|
123951
123908
|
init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromTokenFile");
|
|
123952
123909
|
const webIdentityTokenFile = init?.webIdentityTokenFile ?? process.env[ENV_TOKEN_FILE];
|
|
@@ -123959,7 +123916,7 @@ var import_client17, import_property_provider21, import_shared_ini_file_loader10
|
|
|
123959
123916
|
}
|
|
123960
123917
|
const credentials = await fromWebToken({
|
|
123961
123918
|
...init,
|
|
123962
|
-
webIdentityToken: import_shared_ini_file_loader10.externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ??
|
|
123919
|
+
webIdentityToken: import_shared_ini_file_loader10.externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ?? readFileSync12(webIdentityTokenFile, { encoding: "ascii" }),
|
|
123963
123920
|
roleArn,
|
|
123964
123921
|
roleSessionName
|
|
123965
123922
|
})(awsIdentityProperties);
|
|
@@ -128295,7 +128252,7 @@ var init_s3_client = __esm(() => {
|
|
|
128295
128252
|
});
|
|
128296
128253
|
|
|
128297
128254
|
// packages/core/src/inbox/storage/local-cache.ts
|
|
128298
|
-
import { join as
|
|
128255
|
+
import { join as join32, basename as basename6 } from "path";
|
|
128299
128256
|
import { mkdir as mkdir8, readFile as readFile8, writeFile as writeFile7, rm as rm3, readdir, stat as stat4 } from "fs/promises";
|
|
128300
128257
|
import { createHash as createHash5 } from "crypto";
|
|
128301
128258
|
function isValidAssistantId(id) {
|
|
@@ -128336,15 +128293,15 @@ class LocalInboxCache {
|
|
|
128336
128293
|
validateAssistantId(options.assistantId);
|
|
128337
128294
|
this.assistantId = options.assistantId;
|
|
128338
128295
|
this.basePath = options.basePath;
|
|
128339
|
-
this.cacheDir =
|
|
128296
|
+
this.cacheDir = join32(this.basePath, this.assistantId);
|
|
128340
128297
|
this.injectedDb = options.db;
|
|
128341
128298
|
}
|
|
128342
128299
|
db() {
|
|
128343
128300
|
return getDb12(this.injectedDb);
|
|
128344
128301
|
}
|
|
128345
128302
|
async ensureDirectories() {
|
|
128346
|
-
await mkdir8(
|
|
128347
|
-
await mkdir8(
|
|
128303
|
+
await mkdir8(join32(this.cacheDir, "emails"), { recursive: true });
|
|
128304
|
+
await mkdir8(join32(this.cacheDir, "attachments"), { recursive: true });
|
|
128348
128305
|
}
|
|
128349
128306
|
async loadIndex() {
|
|
128350
128307
|
const rows = this.db().query("SELECT * FROM inbox_cache WHERE assistant_id = ? ORDER BY date DESC").all(this.assistantId);
|
|
@@ -128372,7 +128329,7 @@ class LocalInboxCache {
|
|
|
128372
128329
|
throw new Error(`Failed to create safe filename for email ID: "${email.id}"`);
|
|
128373
128330
|
}
|
|
128374
128331
|
await this.ensureDirectories();
|
|
128375
|
-
const emailPath =
|
|
128332
|
+
const emailPath = join32(this.cacheDir, "emails", `${filename}.json`);
|
|
128376
128333
|
await writeFile7(emailPath, JSON.stringify(email, null, 2));
|
|
128377
128334
|
const existing = this.db().query("SELECT * FROM inbox_cache WHERE id = ? AND assistant_id = ?").get(email.id, this.assistantId);
|
|
128378
128335
|
if (existing) {
|
|
@@ -128391,7 +128348,7 @@ class LocalInboxCache {
|
|
|
128391
128348
|
if (!isValidMappedFilename(filename))
|
|
128392
128349
|
return null;
|
|
128393
128350
|
try {
|
|
128394
|
-
const emailPath =
|
|
128351
|
+
const emailPath = join32(this.cacheDir, "emails", `${filename}.json`);
|
|
128395
128352
|
const content = await readFile8(emailPath, "utf-8");
|
|
128396
128353
|
return JSON.parse(content);
|
|
128397
128354
|
} catch {
|
|
@@ -128443,9 +128400,9 @@ class LocalInboxCache {
|
|
|
128443
128400
|
if (!safeFilename) {
|
|
128444
128401
|
throw new Error("Invalid attachment filename");
|
|
128445
128402
|
}
|
|
128446
|
-
const attachmentDir =
|
|
128403
|
+
const attachmentDir = join32(this.cacheDir, "attachments", emailFilename);
|
|
128447
128404
|
await mkdir8(attachmentDir, { recursive: true });
|
|
128448
|
-
const attachmentPath =
|
|
128405
|
+
const attachmentPath = join32(attachmentDir, safeFilename);
|
|
128449
128406
|
await writeFile7(attachmentPath, content);
|
|
128450
128407
|
return attachmentPath;
|
|
128451
128408
|
}
|
|
@@ -128459,7 +128416,7 @@ class LocalInboxCache {
|
|
|
128459
128416
|
return null;
|
|
128460
128417
|
}
|
|
128461
128418
|
try {
|
|
128462
|
-
const attachmentPath =
|
|
128419
|
+
const attachmentPath = join32(this.cacheDir, "attachments", emailFilename, safeFilename);
|
|
128463
128420
|
await stat4(attachmentPath);
|
|
128464
128421
|
return attachmentPath;
|
|
128465
128422
|
} catch {
|
|
@@ -128482,10 +128439,10 @@ class LocalInboxCache {
|
|
|
128482
128439
|
const filename = row.filename || emailIdToFilename(row.id);
|
|
128483
128440
|
if (isValidMappedFilename(filename)) {
|
|
128484
128441
|
try {
|
|
128485
|
-
await rm3(
|
|
128442
|
+
await rm3(join32(this.cacheDir, "emails", `${filename}.json`));
|
|
128486
128443
|
} catch {}
|
|
128487
128444
|
try {
|
|
128488
|
-
await rm3(
|
|
128445
|
+
await rm3(join32(this.cacheDir, "attachments", filename), { recursive: true });
|
|
128489
128446
|
} catch {}
|
|
128490
128447
|
}
|
|
128491
128448
|
}
|
|
@@ -128497,20 +128454,20 @@ class LocalInboxCache {
|
|
|
128497
128454
|
async getCacheSize() {
|
|
128498
128455
|
let totalSize = 0;
|
|
128499
128456
|
try {
|
|
128500
|
-
const emailsDir =
|
|
128457
|
+
const emailsDir = join32(this.cacheDir, "emails");
|
|
128501
128458
|
const files = await readdir(emailsDir);
|
|
128502
128459
|
for (const file of files) {
|
|
128503
|
-
const fileStat = await stat4(
|
|
128460
|
+
const fileStat = await stat4(join32(emailsDir, file));
|
|
128504
128461
|
totalSize += fileStat.size;
|
|
128505
128462
|
}
|
|
128506
128463
|
} catch {}
|
|
128507
128464
|
try {
|
|
128508
|
-
const attachmentsDir =
|
|
128465
|
+
const attachmentsDir = join32(this.cacheDir, "attachments");
|
|
128509
128466
|
const dirs = await readdir(attachmentsDir);
|
|
128510
128467
|
for (const dir of dirs) {
|
|
128511
|
-
const files = await readdir(
|
|
128468
|
+
const files = await readdir(join32(attachmentsDir, dir));
|
|
128512
128469
|
for (const file of files) {
|
|
128513
|
-
const fileStat = await stat4(
|
|
128470
|
+
const fileStat = await stat4(join32(attachmentsDir, dir, file));
|
|
128514
128471
|
totalSize += fileStat.size;
|
|
128515
128472
|
}
|
|
128516
128473
|
}
|
|
@@ -146747,8 +146704,8 @@ function many(p4) {
|
|
|
146747
146704
|
function many1(p4) {
|
|
146748
146705
|
return ab2(p4, many(p4), (head, tail) => [head, ...tail]);
|
|
146749
146706
|
}
|
|
146750
|
-
function ab2(pa, pb,
|
|
146751
|
-
return (data, i4) => mapOuter(pa(data, i4), (ma) => mapInner(pb(data, ma.position), (vb, j4) =>
|
|
146707
|
+
function ab2(pa, pb, join33) {
|
|
146708
|
+
return (data, i4) => mapOuter(pa(data, i4), (ma) => mapInner(pb(data, ma.position), (vb, j4) => join33(ma.value, vb, data, i4, j4)));
|
|
146752
146709
|
}
|
|
146753
146710
|
function left(pa, pb) {
|
|
146754
146711
|
return ab2(pa, pb, (va) => va);
|
|
@@ -146756,8 +146713,8 @@ function left(pa, pb) {
|
|
|
146756
146713
|
function right(pa, pb) {
|
|
146757
146714
|
return ab2(pa, pb, (va, vb) => vb);
|
|
146758
146715
|
}
|
|
146759
|
-
function abc(pa, pb, pc,
|
|
146760
|
-
return (data, i4) => mapOuter(pa(data, i4), (ma) => mapOuter(pb(data, ma.position), (mb) => mapInner(pc(data, mb.position), (vc, j4) =>
|
|
146716
|
+
function abc(pa, pb, pc, join33) {
|
|
146717
|
+
return (data, i4) => mapOuter(pa(data, i4), (ma) => mapOuter(pb(data, ma.position), (mb) => mapInner(pc(data, mb.position), (vc, j4) => join33(ma.value, mb.value, vc, data, i4, j4))));
|
|
146761
146718
|
}
|
|
146762
146719
|
function middle(pa, pb, pc) {
|
|
146763
146720
|
return abc(pa, pb, pc, (ra, rb) => rb);
|
|
@@ -170344,7 +170301,7 @@ var init_providers = __esm(() => {
|
|
|
170344
170301
|
});
|
|
170345
170302
|
|
|
170346
170303
|
// packages/core/src/inbox/inbox-manager.ts
|
|
170347
|
-
import { join as
|
|
170304
|
+
import { join as join33 } from "path";
|
|
170348
170305
|
|
|
170349
170306
|
class InboxManager {
|
|
170350
170307
|
assistantId;
|
|
@@ -170518,7 +170475,7 @@ class InboxManager {
|
|
|
170518
170475
|
}
|
|
170519
170476
|
}
|
|
170520
170477
|
function createInboxManager(assistantId, assistantName, config, configDir) {
|
|
170521
|
-
const basePath =
|
|
170478
|
+
const basePath = join33(configDir, "messages");
|
|
170522
170479
|
return new InboxManager({
|
|
170523
170480
|
assistantId,
|
|
170524
170481
|
assistantName,
|
|
@@ -174542,8 +174499,8 @@ var init_local_storage = __esm(async () => {
|
|
|
174542
174499
|
});
|
|
174543
174500
|
|
|
174544
174501
|
// packages/core/src/messages/watcher.ts
|
|
174545
|
-
import { watch, existsSync as
|
|
174546
|
-
import { join as
|
|
174502
|
+
import { watch, existsSync as existsSync22, readdirSync as readdirSync7 } from "fs";
|
|
174503
|
+
import { join as join34 } from "path";
|
|
174547
174504
|
|
|
174548
174505
|
class InboxWatcher {
|
|
174549
174506
|
assistantId;
|
|
@@ -174555,14 +174512,14 @@ class InboxWatcher {
|
|
|
174555
174512
|
constructor(assistantId, basePath) {
|
|
174556
174513
|
this.assistantId = assistantId;
|
|
174557
174514
|
const base = basePath || getMessagesBasePath();
|
|
174558
|
-
this.inboxPath =
|
|
174515
|
+
this.inboxPath = join34(base, assistantId, "messages");
|
|
174559
174516
|
}
|
|
174560
174517
|
start() {
|
|
174561
174518
|
if (this.running)
|
|
174562
174519
|
return;
|
|
174563
174520
|
this.running = true;
|
|
174564
174521
|
this.snapshotExisting();
|
|
174565
|
-
if (!
|
|
174522
|
+
if (!existsSync22(this.inboxPath)) {
|
|
174566
174523
|
this.pollForDirectory();
|
|
174567
174524
|
return;
|
|
174568
174525
|
}
|
|
@@ -174587,8 +174544,8 @@ class InboxWatcher {
|
|
|
174587
174544
|
}
|
|
174588
174545
|
snapshotExisting() {
|
|
174589
174546
|
try {
|
|
174590
|
-
if (
|
|
174591
|
-
const files =
|
|
174547
|
+
if (existsSync22(this.inboxPath)) {
|
|
174548
|
+
const files = readdirSync7(this.inboxPath);
|
|
174592
174549
|
for (const file of files) {
|
|
174593
174550
|
if (file.endsWith(".json")) {
|
|
174594
174551
|
this.knownFiles.add(file);
|
|
@@ -174630,7 +174587,7 @@ class InboxWatcher {
|
|
|
174630
174587
|
clearInterval(interval);
|
|
174631
174588
|
return;
|
|
174632
174589
|
}
|
|
174633
|
-
if (
|
|
174590
|
+
if (existsSync22(this.inboxPath)) {
|
|
174634
174591
|
clearInterval(interval);
|
|
174635
174592
|
this.snapshotExisting();
|
|
174636
174593
|
this.startWatching();
|
|
@@ -175532,8 +175489,8 @@ var init_local_storage2 = __esm(async () => {
|
|
|
175532
175489
|
});
|
|
175533
175490
|
|
|
175534
175491
|
// packages/core/src/webhooks/watcher.ts
|
|
175535
|
-
import { watch as watch2, existsSync as
|
|
175536
|
-
import { join as
|
|
175492
|
+
import { watch as watch2, existsSync as existsSync23, readdirSync as readdirSync8 } from "fs";
|
|
175493
|
+
import { join as join35 } from "path";
|
|
175537
175494
|
|
|
175538
175495
|
class WebhookEventWatcher {
|
|
175539
175496
|
basePath;
|
|
@@ -175545,13 +175502,13 @@ class WebhookEventWatcher {
|
|
|
175545
175502
|
directoryWatcher = null;
|
|
175546
175503
|
constructor(basePath) {
|
|
175547
175504
|
this.basePath = basePath || getWebhooksBasePath();
|
|
175548
|
-
this.eventsPath =
|
|
175505
|
+
this.eventsPath = join35(this.basePath, "events");
|
|
175549
175506
|
}
|
|
175550
175507
|
start() {
|
|
175551
175508
|
if (this.running)
|
|
175552
175509
|
return;
|
|
175553
175510
|
this.running = true;
|
|
175554
|
-
if (!
|
|
175511
|
+
if (!existsSync23(this.eventsPath)) {
|
|
175555
175512
|
this.pollForDirectory();
|
|
175556
175513
|
return;
|
|
175557
175514
|
}
|
|
@@ -175584,8 +175541,8 @@ class WebhookEventWatcher {
|
|
|
175584
175541
|
this.directoryWatcher = watch2(this.eventsPath, (eventType, filename) => {
|
|
175585
175542
|
if (!filename || eventType !== "rename")
|
|
175586
175543
|
return;
|
|
175587
|
-
const dirPath =
|
|
175588
|
-
if (
|
|
175544
|
+
const dirPath = join35(this.eventsPath, filename);
|
|
175545
|
+
if (existsSync23(dirPath) && !this.watchers.has(filename)) {
|
|
175589
175546
|
this.watchWebhookDir(filename);
|
|
175590
175547
|
}
|
|
175591
175548
|
});
|
|
@@ -175601,7 +175558,7 @@ class WebhookEventWatcher {
|
|
|
175601
175558
|
});
|
|
175602
175559
|
} catch {}
|
|
175603
175560
|
try {
|
|
175604
|
-
const dirs =
|
|
175561
|
+
const dirs = readdirSync8(this.eventsPath);
|
|
175605
175562
|
for (const dir of dirs) {
|
|
175606
175563
|
this.watchWebhookDir(dir);
|
|
175607
175564
|
}
|
|
@@ -175610,12 +175567,12 @@ class WebhookEventWatcher {
|
|
|
175610
175567
|
watchWebhookDir(webhookId) {
|
|
175611
175568
|
if (this.watchers.has(webhookId))
|
|
175612
175569
|
return;
|
|
175613
|
-
const dirPath =
|
|
175614
|
-
if (!
|
|
175570
|
+
const dirPath = join35(this.eventsPath, webhookId);
|
|
175571
|
+
if (!existsSync23(dirPath))
|
|
175615
175572
|
return;
|
|
175616
175573
|
const known = new Set;
|
|
175617
175574
|
try {
|
|
175618
|
-
const files =
|
|
175575
|
+
const files = readdirSync8(dirPath);
|
|
175619
175576
|
for (const file of files) {
|
|
175620
175577
|
if (file.endsWith(".json") && file !== "index.json") {
|
|
175621
175578
|
known.add(file);
|
|
@@ -175655,7 +175612,7 @@ class WebhookEventWatcher {
|
|
|
175655
175612
|
clearInterval(interval);
|
|
175656
175613
|
return;
|
|
175657
175614
|
}
|
|
175658
|
-
if (
|
|
175615
|
+
if (existsSync23(this.eventsPath)) {
|
|
175659
175616
|
clearInterval(interval);
|
|
175660
175617
|
this.startWatchingAll();
|
|
175661
175618
|
}
|
|
@@ -176977,15 +176934,15 @@ import { spawn as spawn4 } from "child_process";
|
|
|
176977
176934
|
import { createInterface } from "readline";
|
|
176978
176935
|
import * as fs4 from "fs";
|
|
176979
176936
|
import { stat as statPromise, open as open2 } from "fs/promises";
|
|
176980
|
-
import { join as
|
|
176937
|
+
import { join as join36 } from "path";
|
|
176981
176938
|
import { homedir as homedir18 } from "os";
|
|
176982
176939
|
import { dirname as dirname14, join as join210 } from "path";
|
|
176983
176940
|
import { cwd } from "process";
|
|
176984
176941
|
import { realpathSync as realpathSync2 } from "fs";
|
|
176985
176942
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
176986
176943
|
import { randomUUID as randomUUID22 } from "crypto";
|
|
176987
|
-
import { appendFileSync as appendFileSync22, existsSync as
|
|
176988
|
-
import { join as
|
|
176944
|
+
import { appendFileSync as appendFileSync22, existsSync as existsSync25, mkdirSync as mkdirSync22 } from "fs";
|
|
176945
|
+
import { join as join37 } from "path";
|
|
176989
176946
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
176990
176947
|
import { join as join42 } from "path";
|
|
176991
176948
|
import { fileURLToPath } from "url";
|
|
@@ -177262,7 +177219,7 @@ function shouldShowDebugMessage(message, filter) {
|
|
|
177262
177219
|
return shouldShowDebugCategories(categories, filter);
|
|
177263
177220
|
}
|
|
177264
177221
|
function getClaudeConfigHomeDir() {
|
|
177265
|
-
return process.env.CLAUDE_CONFIG_DIR ??
|
|
177222
|
+
return process.env.CLAUDE_CONFIG_DIR ?? join36(homedir18(), ".claude");
|
|
177266
177223
|
}
|
|
177267
177224
|
function isEnvTruthy(envVar) {
|
|
177268
177225
|
if (!envVar)
|
|
@@ -177539,9 +177496,9 @@ function getOrCreateDebugFile() {
|
|
|
177539
177496
|
if (!process.env.DEBUG_CLAUDE_AGENT_SDK) {
|
|
177540
177497
|
return null;
|
|
177541
177498
|
}
|
|
177542
|
-
const debugDir =
|
|
177543
|
-
debugFilePath =
|
|
177544
|
-
if (!
|
|
177499
|
+
const debugDir = join37(getClaudeConfigHomeDir(), "debug");
|
|
177500
|
+
debugFilePath = join37(debugDir, `sdk-${randomUUID22()}.txt`);
|
|
177501
|
+
if (!existsSync25(debugDir)) {
|
|
177545
177502
|
mkdirSync22(debugDir, { recursive: true });
|
|
177546
177503
|
}
|
|
177547
177504
|
process.stderr.write(`SDK debug logs: ${debugFilePath}
|
|
@@ -206205,7 +206162,7 @@ function createSelfAwarenessToolExecutors(context) {
|
|
|
206205
206162
|
workspace_map: async (input) => {
|
|
206206
206163
|
const { readdir: readdir2, stat: stat5, access } = await import("fs/promises");
|
|
206207
206164
|
const { execSync } = await import("child_process");
|
|
206208
|
-
const { join:
|
|
206165
|
+
const { join: join38, basename: basename7 } = await import("path");
|
|
206209
206166
|
const depth = input.depth ?? 3;
|
|
206210
206167
|
const includeGitStatus = input.include_git_status !== false;
|
|
206211
206168
|
const includeRecentFiles = input.include_recent_files !== false;
|
|
@@ -206251,7 +206208,7 @@ function createSelfAwarenessToolExecutors(context) {
|
|
|
206251
206208
|
break;
|
|
206252
206209
|
}
|
|
206253
206210
|
if (entry.isDirectory()) {
|
|
206254
|
-
const children2 = await buildTree(
|
|
206211
|
+
const children2 = await buildTree(join38(dir, entry.name), currentDepth + 1);
|
|
206255
206212
|
nodes.push({
|
|
206256
206213
|
name: entry.name,
|
|
206257
206214
|
type: "directory",
|
|
@@ -206277,7 +206234,7 @@ function createSelfAwarenessToolExecutors(context) {
|
|
|
206277
206234
|
};
|
|
206278
206235
|
if (includeGitStatus) {
|
|
206279
206236
|
try {
|
|
206280
|
-
await access(
|
|
206237
|
+
await access(join38(cwd2, ".git"));
|
|
206281
206238
|
gitStatus.isRepo = true;
|
|
206282
206239
|
try {
|
|
206283
206240
|
const branch = execSync("git branch --show-current", { cwd: cwd2, encoding: "utf-8" }).trim();
|
|
@@ -206308,7 +206265,7 @@ function createSelfAwarenessToolExecutors(context) {
|
|
|
206308
206265
|
for (const entry of entries) {
|
|
206309
206266
|
if (shouldIgnore(entry.name))
|
|
206310
206267
|
continue;
|
|
206311
|
-
const fullPath =
|
|
206268
|
+
const fullPath = join38(dir, entry.name);
|
|
206312
206269
|
const relPath = relativePath ? `${relativePath}/${entry.name}` : entry.name;
|
|
206313
206270
|
if (entry.isFile()) {
|
|
206314
206271
|
try {
|
|
@@ -206342,12 +206299,12 @@ function createSelfAwarenessToolExecutors(context) {
|
|
|
206342
206299
|
let projectName = basename7(cwd2);
|
|
206343
206300
|
for (const indicator of projectIndicators) {
|
|
206344
206301
|
try {
|
|
206345
|
-
await access(
|
|
206302
|
+
await access(join38(cwd2, indicator.file));
|
|
206346
206303
|
projectType = indicator.type;
|
|
206347
206304
|
if (indicator.file === "package.json") {
|
|
206348
206305
|
try {
|
|
206349
206306
|
const { readFile: readFile9 } = await import("fs/promises");
|
|
206350
|
-
const pkg = JSON.parse(await readFile9(
|
|
206307
|
+
const pkg = JSON.parse(await readFile9(join38(cwd2, indicator.file), "utf-8"));
|
|
206351
206308
|
projectName = pkg.name || projectName;
|
|
206352
206309
|
} catch {}
|
|
206353
206310
|
}
|
|
@@ -211129,7 +211086,6 @@ var init_capabilities2 = __esm(async () => {
|
|
|
211129
211086
|
});
|
|
211130
211087
|
|
|
211131
211088
|
// packages/core/src/agent/loop.ts
|
|
211132
|
-
import { join as join39 } from "path";
|
|
211133
211089
|
function parseErrorCode(message) {
|
|
211134
211090
|
const index = message.indexOf(":");
|
|
211135
211091
|
if (index === -1)
|
|
@@ -213845,8 +213801,8 @@ Current state: ${voiceState.enabled ? "enabled" : "disabled"}, STT: ${voiceState
|
|
|
213845
213801
|
return null;
|
|
213846
213802
|
const intervalMs = Math.max(1000, config2.heartbeat?.intervalMs ?? 15000);
|
|
213847
213803
|
const staleThresholdMs = Math.max(intervalMs * 2, config2.heartbeat?.staleThresholdMs ?? 120000);
|
|
213848
|
-
const persistPath = config2.heartbeat?.persistPath ??
|
|
213849
|
-
const historyPath = config2.heartbeat?.historyPath ??
|
|
213804
|
+
const persistPath = config2.heartbeat?.persistPath ?? `<db>:heartbeat_state:${this.sessionId}`;
|
|
213805
|
+
const historyPath = config2.heartbeat?.historyPath ?? `<db>:heartbeat_history:${this.sessionId}`;
|
|
213850
213806
|
return {
|
|
213851
213807
|
intervalMs,
|
|
213852
213808
|
staleThresholdMs,
|
|
@@ -214227,9 +214183,9 @@ class StatsTracker {
|
|
|
214227
214183
|
}
|
|
214228
214184
|
|
|
214229
214185
|
// packages/core/src/tools/connector-index.ts
|
|
214230
|
-
import { join as
|
|
214186
|
+
import { join as join38, dirname as dirname15 } from "path";
|
|
214231
214187
|
import { homedir as homedir19 } from "os";
|
|
214232
|
-
import { existsSync as
|
|
214188
|
+
import { existsSync as existsSync26, mkdirSync as mkdirSync15, writeFileSync as writeFileSync11, readFileSync as readFileSync14 } from "fs";
|
|
214233
214189
|
var TAG_KEYWORDS, INDEX_VERSION = 1, INDEX_TTL_MS, ConnectorIndex;
|
|
214234
214190
|
var init_connector_index = __esm(() => {
|
|
214235
214191
|
TAG_KEYWORDS = {
|
|
@@ -214266,15 +214222,15 @@ var init_connector_index = __esm(() => {
|
|
|
214266
214222
|
return envHome && envHome.trim().length > 0 ? envHome : homedir19();
|
|
214267
214223
|
}
|
|
214268
214224
|
getCachePath() {
|
|
214269
|
-
return
|
|
214225
|
+
return join38(this.getHomeDir(), ".assistants", "cache", "connector-index.json");
|
|
214270
214226
|
}
|
|
214271
214227
|
loadDiskCache() {
|
|
214272
214228
|
ConnectorIndex.indexLoaded = true;
|
|
214273
214229
|
try {
|
|
214274
214230
|
const cachePath = this.getCachePath();
|
|
214275
|
-
if (!
|
|
214231
|
+
if (!existsSync26(cachePath))
|
|
214276
214232
|
return;
|
|
214277
|
-
const data = JSON.parse(
|
|
214233
|
+
const data = JSON.parse(readFileSync14(cachePath, "utf-8"));
|
|
214278
214234
|
if (data.version !== INDEX_VERSION)
|
|
214279
214235
|
return;
|
|
214280
214236
|
if (Date.now() - data.timestamp > INDEX_TTL_MS)
|
|
@@ -214289,7 +214245,7 @@ var init_connector_index = __esm(() => {
|
|
|
214289
214245
|
try {
|
|
214290
214246
|
const cachePath = this.getCachePath();
|
|
214291
214247
|
const cacheDir = dirname15(cachePath);
|
|
214292
|
-
if (!
|
|
214248
|
+
if (!existsSync26(cacheDir)) {
|
|
214293
214249
|
mkdirSync15(cacheDir, { recursive: true });
|
|
214294
214250
|
}
|
|
214295
214251
|
const data = {
|
|
@@ -214869,16 +214825,16 @@ var init_interviews = __esm(async () => {
|
|
|
214869
214825
|
});
|
|
214870
214826
|
|
|
214871
214827
|
// packages/core/src/memory/sessions.ts
|
|
214872
|
-
import { join as
|
|
214873
|
-
import { existsSync as
|
|
214828
|
+
import { join as join40, dirname as dirname16 } from "path";
|
|
214829
|
+
import { existsSync as existsSync28, mkdirSync as mkdirSync16 } from "fs";
|
|
214874
214830
|
|
|
214875
214831
|
class SessionManager {
|
|
214876
214832
|
db;
|
|
214877
214833
|
constructor(dbPath, assistantId) {
|
|
214878
214834
|
const baseDir = getConfigDir();
|
|
214879
|
-
const path4 = dbPath || (assistantId ?
|
|
214835
|
+
const path4 = dbPath || (assistantId ? join40(baseDir, "assistants", assistantId, "memory.db") : join40(baseDir, "memory.db"));
|
|
214880
214836
|
const dir = dirname16(path4);
|
|
214881
|
-
if (!
|
|
214837
|
+
if (!existsSync28(dir)) {
|
|
214882
214838
|
mkdirSync16(dir, { recursive: true });
|
|
214883
214839
|
}
|
|
214884
214840
|
const runtime = getRuntime();
|
|
@@ -214992,9 +214948,9 @@ var init_sessions4 = __esm(async () => {
|
|
|
214992
214948
|
]);
|
|
214993
214949
|
});
|
|
214994
214950
|
// packages/core/src/migration/validators.ts
|
|
214995
|
-
import { existsSync as
|
|
214951
|
+
import { existsSync as existsSync29 } from "fs";
|
|
214996
214952
|
function assertNoExistingTarget(targetPath) {
|
|
214997
|
-
if (
|
|
214953
|
+
if (existsSync29(targetPath)) {
|
|
214998
214954
|
throw new Error(`Target already exists at ${targetPath}`);
|
|
214999
214955
|
}
|
|
215000
214956
|
}
|
|
@@ -233747,7 +233703,7 @@ var require_filesystem = __commonJS((exports, module) => {
|
|
|
233747
233703
|
var LDD_PATH = "/usr/bin/ldd";
|
|
233748
233704
|
var SELF_PATH = "/proc/self/exe";
|
|
233749
233705
|
var MAX_LENGTH = 2048;
|
|
233750
|
-
var
|
|
233706
|
+
var readFileSync16 = (path4) => {
|
|
233751
233707
|
const fd = fs7.openSync(path4, "r");
|
|
233752
233708
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
233753
233709
|
const bytesRead = fs7.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
@@ -233770,7 +233726,7 @@ var require_filesystem = __commonJS((exports, module) => {
|
|
|
233770
233726
|
module.exports = {
|
|
233771
233727
|
LDD_PATH,
|
|
233772
233728
|
SELF_PATH,
|
|
233773
|
-
readFileSync:
|
|
233729
|
+
readFileSync: readFileSync16,
|
|
233774
233730
|
readFile: readFile9
|
|
233775
233731
|
};
|
|
233776
233732
|
});
|
|
@@ -233813,7 +233769,7 @@ var require_elf = __commonJS((exports, module) => {
|
|
|
233813
233769
|
var require_detect_libc = __commonJS((exports, module) => {
|
|
233814
233770
|
var childProcess = __require("child_process");
|
|
233815
233771
|
var { isLinux: isLinux2, getReport } = require_process();
|
|
233816
|
-
var { LDD_PATH, SELF_PATH, readFile: readFile9, readFileSync:
|
|
233772
|
+
var { LDD_PATH, SELF_PATH, readFile: readFile9, readFileSync: readFileSync16 } = require_filesystem();
|
|
233817
233773
|
var { interpreterPath } = require_elf();
|
|
233818
233774
|
var cachedFamilyInterpreter;
|
|
233819
233775
|
var cachedFamilyFilesystem;
|
|
@@ -233904,7 +233860,7 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
233904
233860
|
}
|
|
233905
233861
|
cachedFamilyFilesystem = null;
|
|
233906
233862
|
try {
|
|
233907
|
-
const lddContent =
|
|
233863
|
+
const lddContent = readFileSync16(LDD_PATH);
|
|
233908
233864
|
cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
|
|
233909
233865
|
} catch (e6) {}
|
|
233910
233866
|
return cachedFamilyFilesystem;
|
|
@@ -233927,7 +233883,7 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
233927
233883
|
}
|
|
233928
233884
|
cachedFamilyInterpreter = null;
|
|
233929
233885
|
try {
|
|
233930
|
-
const selfContent =
|
|
233886
|
+
const selfContent = readFileSync16(SELF_PATH);
|
|
233931
233887
|
const path4 = interpreterPath(selfContent);
|
|
233932
233888
|
cachedFamilyInterpreter = familyFromInterpreterPath(path4);
|
|
233933
233889
|
} catch (e6) {}
|
|
@@ -233989,7 +233945,7 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
233989
233945
|
}
|
|
233990
233946
|
cachedVersionFilesystem = null;
|
|
233991
233947
|
try {
|
|
233992
|
-
const lddContent =
|
|
233948
|
+
const lddContent = readFileSync16(LDD_PATH);
|
|
233993
233949
|
const versionMatch = lddContent.match(RE_GLIBC_VERSION);
|
|
233994
233950
|
if (versionMatch) {
|
|
233995
233951
|
cachedVersionFilesystem = versionMatch[1];
|
|
@@ -255286,7 +255242,7 @@ await __promiseAll([
|
|
|
255286
255242
|
]);
|
|
255287
255243
|
var import_react84 = __toESM(require_react(), 1);
|
|
255288
255244
|
import { spawn as spawn6 } from "child_process";
|
|
255289
|
-
import { join as
|
|
255245
|
+
import { join as join43 } from "path";
|
|
255290
255246
|
import { homedir as homedir20 } from "os";
|
|
255291
255247
|
|
|
255292
255248
|
// packages/terminal/src/components/Input.tsx
|
|
@@ -285985,7 +285941,7 @@ await init_src3();
|
|
|
285985
285941
|
// packages/terminal/src/lib/budgets.ts
|
|
285986
285942
|
init_src2();
|
|
285987
285943
|
await init_src3();
|
|
285988
|
-
import { join as
|
|
285944
|
+
import { join as join41 } from "path";
|
|
285989
285945
|
import { mkdir as mkdir9, readFile as readFile9, writeFile as writeFile8 } from "fs/promises";
|
|
285990
285946
|
var PROFILES_FILE = "budgets.json";
|
|
285991
285947
|
var SESSION_MAP_FILE = "budget-sessions.json";
|
|
@@ -286009,7 +285965,7 @@ async function writeJsonFile(path6, data) {
|
|
|
286009
285965
|
}
|
|
286010
285966
|
async function loadBudgetProfiles(baseDir, seedConfig) {
|
|
286011
285967
|
await ensureDir(baseDir);
|
|
286012
|
-
const path6 =
|
|
285968
|
+
const path6 = join41(baseDir, PROFILES_FILE);
|
|
286013
285969
|
const data = await readJsonFile(path6);
|
|
286014
285970
|
const profiles = Array.isArray(data?.profiles) ? data.profiles : [];
|
|
286015
285971
|
if (profiles.length === 0) {
|
|
@@ -286029,7 +285985,7 @@ async function loadBudgetProfiles(baseDir, seedConfig) {
|
|
|
286029
285985
|
}
|
|
286030
285986
|
async function saveBudgetProfiles(baseDir, profiles) {
|
|
286031
285987
|
await ensureDir(baseDir);
|
|
286032
|
-
const path6 =
|
|
285988
|
+
const path6 = join41(baseDir, PROFILES_FILE);
|
|
286033
285989
|
await writeJsonFile(path6, { profiles });
|
|
286034
285990
|
}
|
|
286035
285991
|
async function createBudgetProfile(baseDir, name2, config2, description) {
|
|
@@ -286067,13 +286023,13 @@ async function deleteBudgetProfile(baseDir, id) {
|
|
|
286067
286023
|
}
|
|
286068
286024
|
async function loadSessionBudgetMap(baseDir) {
|
|
286069
286025
|
await ensureDir(baseDir);
|
|
286070
|
-
const path6 =
|
|
286026
|
+
const path6 = join41(baseDir, SESSION_MAP_FILE);
|
|
286071
286027
|
const data = await readJsonFile(path6);
|
|
286072
286028
|
return data || {};
|
|
286073
286029
|
}
|
|
286074
286030
|
async function saveSessionBudgetMap(baseDir, map2) {
|
|
286075
286031
|
await ensureDir(baseDir);
|
|
286076
|
-
const path6 =
|
|
286032
|
+
const path6 = join41(baseDir, SESSION_MAP_FILE);
|
|
286077
286033
|
await writeJsonFile(path6, map2);
|
|
286078
286034
|
}
|
|
286079
286035
|
|
|
@@ -287692,13 +287648,13 @@ function App2({ cwd: cwd3, version: version5 }) {
|
|
|
287692
287648
|
});
|
|
287693
287649
|
}, [recoverableSessions, createSessionFromRecovery, workspaceBaseDir]);
|
|
287694
287650
|
const handleOnboardingComplete = import_react84.useCallback(async (result) => {
|
|
287695
|
-
const { existsSync:
|
|
287696
|
-
const secretsPath =
|
|
287651
|
+
const { existsSync: existsSync27, mkdirSync: mkdirSync17, readFileSync: readFileSync16, writeFileSync: writeFileSync12, appendFileSync: appendFileSync5 } = await import("fs");
|
|
287652
|
+
const secretsPath = join43(homedir20(), ".secrets");
|
|
287697
287653
|
const providerInfo = getProviderInfo(result.provider);
|
|
287698
287654
|
const envName = providerInfo?.apiKeyEnv || "ANTHROPIC_API_KEY";
|
|
287699
287655
|
const keyExport = `export ${envName}="${result.apiKey}"`;
|
|
287700
|
-
if (
|
|
287701
|
-
const content =
|
|
287656
|
+
if (existsSync27(secretsPath)) {
|
|
287657
|
+
const content = readFileSync16(secretsPath, "utf-8");
|
|
287702
287658
|
if (content.includes(envName)) {
|
|
287703
287659
|
const updated = content.replace(new RegExp(`^export ${envName}=.*$`, "m"), keyExport);
|
|
287704
287660
|
writeFileSync12(secretsPath, updated, "utf-8");
|
|
@@ -287714,7 +287670,7 @@ function App2({ cwd: cwd3, version: version5 }) {
|
|
|
287714
287670
|
for (const [name2, key] of Object.entries(result.connectorKeys)) {
|
|
287715
287671
|
const envName2 = `${name2.toUpperCase()}_API_KEY`;
|
|
287716
287672
|
const connKeyExport = `export ${envName2}="${key}"`;
|
|
287717
|
-
const content =
|
|
287673
|
+
const content = readFileSync16(secretsPath, "utf-8");
|
|
287718
287674
|
if (content.includes(envName2)) {
|
|
287719
287675
|
const updated = content.replace(new RegExp(`^export ${envName2}=.*$`, "m"), connKeyExport);
|
|
287720
287676
|
writeFileSync12(secretsPath, updated, "utf-8");
|
|
@@ -287724,14 +287680,14 @@ function App2({ cwd: cwd3, version: version5 }) {
|
|
|
287724
287680
|
}
|
|
287725
287681
|
}
|
|
287726
287682
|
const configDir = workspaceBaseDir || getConfigDir();
|
|
287727
|
-
if (!
|
|
287683
|
+
if (!existsSync27(configDir)) {
|
|
287728
287684
|
mkdirSync17(configDir, { recursive: true });
|
|
287729
287685
|
}
|
|
287730
|
-
const configPath =
|
|
287686
|
+
const configPath = join43(configDir, "config.json");
|
|
287731
287687
|
let existingConfig = {};
|
|
287732
|
-
if (
|
|
287688
|
+
if (existsSync27(configPath)) {
|
|
287733
287689
|
try {
|
|
287734
|
-
existingConfig = JSON.parse(
|
|
287690
|
+
existingConfig = JSON.parse(readFileSync16(configPath, "utf-8"));
|
|
287735
287691
|
} catch {}
|
|
287736
287692
|
}
|
|
287737
287693
|
const newConfig = {
|
|
@@ -287773,14 +287729,14 @@ function App2({ cwd: cwd3, version: version5 }) {
|
|
|
287773
287729
|
return;
|
|
287774
287730
|
}
|
|
287775
287731
|
try {
|
|
287776
|
-
const configPath =
|
|
287777
|
-
const { existsSync:
|
|
287732
|
+
const configPath = join43(workspaceBaseDir || getConfigDir(), "config.json");
|
|
287733
|
+
const { existsSync: existsSync27, readFileSync: readFileSync16 } = await import("fs");
|
|
287778
287734
|
let needsOnboarding = false;
|
|
287779
|
-
if (!
|
|
287735
|
+
if (!existsSync27(configPath)) {
|
|
287780
287736
|
needsOnboarding = true;
|
|
287781
287737
|
} else {
|
|
287782
287738
|
try {
|
|
287783
|
-
const raw =
|
|
287739
|
+
const raw = readFileSync16(configPath, "utf-8");
|
|
287784
287740
|
const parsed = JSON.parse(raw);
|
|
287785
287741
|
if (!parsed.onboardingCompleted) {
|
|
287786
287742
|
needsOnboarding = true;
|
|
@@ -290893,7 +290849,7 @@ Interactive Mode:
|
|
|
290893
290849
|
// packages/terminal/src/index.tsx
|
|
290894
290850
|
var jsx_dev_runtime52 = __toESM(require_jsx_dev_runtime(), 1);
|
|
290895
290851
|
setRuntime(bunRuntime);
|
|
290896
|
-
var VERSION4 = "1.1.
|
|
290852
|
+
var VERSION4 = "1.1.53";
|
|
290897
290853
|
var SYNC_START = "\x1B[?2026h";
|
|
290898
290854
|
var SYNC_END = "\x1B[?2026l";
|
|
290899
290855
|
function enableSynchronizedOutput() {
|
|
@@ -291012,4 +290968,4 @@ export {
|
|
|
291012
290968
|
main
|
|
291013
290969
|
};
|
|
291014
290970
|
|
|
291015
|
-
//# debugId=
|
|
290971
|
+
//# debugId=2C44C31995AA98B064756E2164756E21
|