@hasna/assistants 0.6.20 → 0.6.22
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 +261 -99
- package/dist/index.js.map +8 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -27290,16 +27290,16 @@ var exports_anthropic = {};
|
|
|
27290
27290
|
__export(exports_anthropic, {
|
|
27291
27291
|
AnthropicClient: () => AnthropicClient
|
|
27292
27292
|
});
|
|
27293
|
-
import { readFileSync as
|
|
27293
|
+
import { readFileSync as readFileSync3, existsSync as existsSync8 } from "fs";
|
|
27294
27294
|
import { homedir as homedir8 } from "os";
|
|
27295
27295
|
import { join as join12 } from "path";
|
|
27296
27296
|
function loadApiKeyFromSecrets() {
|
|
27297
27297
|
const envHome = process.env.HOME || process.env.USERPROFILE;
|
|
27298
27298
|
const homeDir = envHome && envHome.trim().length > 0 ? envHome : homedir8();
|
|
27299
27299
|
const secretsPath = join12(homeDir, ".secrets");
|
|
27300
|
-
if (
|
|
27300
|
+
if (existsSync8(secretsPath)) {
|
|
27301
27301
|
try {
|
|
27302
|
-
const content =
|
|
27302
|
+
const content = readFileSync3(secretsPath, "utf-8");
|
|
27303
27303
|
const match = content.match(/export\s+ANTHROPIC_API_KEY\s*=\s*["']?([^"'\n]+)["']?/);
|
|
27304
27304
|
if (match) {
|
|
27305
27305
|
return match[1];
|
|
@@ -36636,22 +36636,64 @@ function isErrorResult(result) {
|
|
|
36636
36636
|
init_errors();
|
|
36637
36637
|
import { homedir as homedir2 } from "os";
|
|
36638
36638
|
import { join as join3, delimiter } from "path";
|
|
36639
|
-
import { readdirSync, statSync } from "fs";
|
|
36639
|
+
import { readdirSync, statSync, existsSync as existsSync2, mkdirSync, writeFileSync, readFileSync as readFileSync2 } from "fs";
|
|
36640
36640
|
function resolveTimeout(resolve) {
|
|
36641
36641
|
resolve({ exitCode: 1 });
|
|
36642
36642
|
}
|
|
36643
|
+
var CACHE_VERSION = 1;
|
|
36644
|
+
var CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
|
36643
36645
|
|
|
36644
36646
|
class ConnectorBridge {
|
|
36645
36647
|
connectors = new Map;
|
|
36646
36648
|
static cache = new Map;
|
|
36649
|
+
static diskCacheLoaded = false;
|
|
36647
36650
|
cwd;
|
|
36648
36651
|
constructor(cwd2) {
|
|
36649
36652
|
this.cwd = cwd2;
|
|
36653
|
+
if (!ConnectorBridge.diskCacheLoaded) {
|
|
36654
|
+
ConnectorBridge.loadDiskCache();
|
|
36655
|
+
}
|
|
36650
36656
|
}
|
|
36651
36657
|
getHomeDir() {
|
|
36652
36658
|
const envHome = process.env.HOME || process.env.USERPROFILE;
|
|
36653
36659
|
return envHome && envHome.trim().length > 0 ? envHome : homedir2();
|
|
36654
36660
|
}
|
|
36661
|
+
static getCachePath() {
|
|
36662
|
+
const envHome = process.env.HOME || process.env.USERPROFILE;
|
|
36663
|
+
const home = envHome && envHome.trim().length > 0 ? envHome : homedir2();
|
|
36664
|
+
return join3(home, ".assistants", "cache", "connectors.json");
|
|
36665
|
+
}
|
|
36666
|
+
static loadDiskCache() {
|
|
36667
|
+
ConnectorBridge.diskCacheLoaded = true;
|
|
36668
|
+
try {
|
|
36669
|
+
const cachePath = ConnectorBridge.getCachePath();
|
|
36670
|
+
if (!existsSync2(cachePath))
|
|
36671
|
+
return;
|
|
36672
|
+
const data = JSON.parse(readFileSync2(cachePath, "utf-8"));
|
|
36673
|
+
if (data.version !== CACHE_VERSION)
|
|
36674
|
+
return;
|
|
36675
|
+
if (Date.now() - data.timestamp > CACHE_TTL_MS)
|
|
36676
|
+
return;
|
|
36677
|
+
for (const [name, connector] of Object.entries(data.connectors)) {
|
|
36678
|
+
ConnectorBridge.cache.set(name, connector);
|
|
36679
|
+
}
|
|
36680
|
+
} catch {}
|
|
36681
|
+
}
|
|
36682
|
+
static saveDiskCache() {
|
|
36683
|
+
try {
|
|
36684
|
+
const cachePath = ConnectorBridge.getCachePath();
|
|
36685
|
+
const cacheDir = join3(cachePath, "..");
|
|
36686
|
+
if (!existsSync2(cacheDir)) {
|
|
36687
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
36688
|
+
}
|
|
36689
|
+
const data = {
|
|
36690
|
+
version: CACHE_VERSION,
|
|
36691
|
+
timestamp: Date.now(),
|
|
36692
|
+
connectors: Object.fromEntries(ConnectorBridge.cache)
|
|
36693
|
+
};
|
|
36694
|
+
writeFileSync(cachePath, JSON.stringify(data));
|
|
36695
|
+
} catch {}
|
|
36696
|
+
}
|
|
36655
36697
|
autoDiscoverConnectorNames() {
|
|
36656
36698
|
const connectorNames = new Set;
|
|
36657
36699
|
const pathDirs = (process.env.PATH || "").split(delimiter);
|
|
@@ -36691,6 +36733,19 @@ class ConnectorBridge {
|
|
|
36691
36733
|
return Array.from(connectorNames);
|
|
36692
36734
|
}
|
|
36693
36735
|
fastDiscover(connectorNames) {
|
|
36736
|
+
if (ConnectorBridge.cache.size > 0) {
|
|
36737
|
+
const connectors2 = [];
|
|
36738
|
+
const allowList2 = connectorNames && connectorNames.length > 0 ? new Set(connectorNames) : null;
|
|
36739
|
+
for (const [name, connector] of ConnectorBridge.cache) {
|
|
36740
|
+
if (connector && (!allowList2 || allowList2.has(name))) {
|
|
36741
|
+
this.connectors.set(connector.name, connector);
|
|
36742
|
+
connectors2.push(connector);
|
|
36743
|
+
}
|
|
36744
|
+
}
|
|
36745
|
+
if (connectors2.length > 0) {
|
|
36746
|
+
return connectors2;
|
|
36747
|
+
}
|
|
36748
|
+
}
|
|
36694
36749
|
const discoveredNames = this.autoDiscoverConnectorNames();
|
|
36695
36750
|
const allowList = connectorNames && connectorNames.length > 0 ? new Set(connectorNames) : null;
|
|
36696
36751
|
const names = allowList ? discoveredNames.filter((name) => allowList.has(name)) : discoveredNames;
|
|
@@ -36713,6 +36768,9 @@ class ConnectorBridge {
|
|
|
36713
36768
|
this.connectors.set(connector.name, connector);
|
|
36714
36769
|
connectors.push(connector);
|
|
36715
36770
|
}
|
|
36771
|
+
if (connectors.length > 0) {
|
|
36772
|
+
ConnectorBridge.saveDiskCache();
|
|
36773
|
+
}
|
|
36716
36774
|
return connectors;
|
|
36717
36775
|
}
|
|
36718
36776
|
async discover(connectorNames) {
|
|
@@ -36732,6 +36790,7 @@ class ConnectorBridge {
|
|
|
36732
36790
|
tasks.push(this.populateCache(name));
|
|
36733
36791
|
}
|
|
36734
36792
|
await Promise.all(tasks);
|
|
36793
|
+
ConnectorBridge.saveDiskCache();
|
|
36735
36794
|
}
|
|
36736
36795
|
const discovered = [];
|
|
36737
36796
|
for (const name of names) {
|
|
@@ -36910,7 +36969,7 @@ class ConnectorBridge {
|
|
|
36910
36969
|
cwd: cwd2,
|
|
36911
36970
|
stdin: "ignore",
|
|
36912
36971
|
stdout: "ignore",
|
|
36913
|
-
stderr: "
|
|
36972
|
+
stderr: "ignore"
|
|
36914
36973
|
});
|
|
36915
36974
|
proc.unref?.();
|
|
36916
36975
|
} catch {}
|
|
@@ -37320,7 +37379,7 @@ ${stderr || stdout}`.trim(), {
|
|
|
37320
37379
|
|
|
37321
37380
|
// packages/core/src/tools/filesystem.ts
|
|
37322
37381
|
import { join as join4, resolve as resolve3, dirname as dirname2, sep } from "path";
|
|
37323
|
-
import { existsSync as
|
|
37382
|
+
import { existsSync as existsSync3 } from "fs";
|
|
37324
37383
|
init_errors();
|
|
37325
37384
|
var {Glob } = globalThis.Bun;
|
|
37326
37385
|
|
|
@@ -37411,7 +37470,7 @@ var currentSessionId = "default";
|
|
|
37411
37470
|
function getScriptsFolder(cwd2, sessionId) {
|
|
37412
37471
|
const resolvedSessionId = sessionId || currentSessionId;
|
|
37413
37472
|
const legacyDir = join4(cwd2, ".oldpal");
|
|
37414
|
-
if (
|
|
37473
|
+
if (existsSync3(legacyDir)) {
|
|
37415
37474
|
return join4(legacyDir, "scripts", resolvedSessionId);
|
|
37416
37475
|
}
|
|
37417
37476
|
return join4(getProjectConfigDir(cwd2), "scripts", resolvedSessionId);
|
|
@@ -38336,7 +38395,7 @@ function isPrivateIPv4(octets) {
|
|
|
38336
38395
|
// packages/core/src/tools/feedback.ts
|
|
38337
38396
|
init_src();
|
|
38338
38397
|
import { join as join5 } from "path";
|
|
38339
|
-
import { existsSync as
|
|
38398
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
38340
38399
|
function normalizeTags(value) {
|
|
38341
38400
|
if (Array.isArray(value)) {
|
|
38342
38401
|
const tags = value.map((t) => String(t).trim()).filter(Boolean);
|
|
@@ -38351,16 +38410,16 @@ function normalizeTags(value) {
|
|
|
38351
38410
|
function resolveFeedbackDir(cwd2) {
|
|
38352
38411
|
const baseCwd = cwd2 && cwd2.trim().length > 0 ? cwd2 : process.cwd();
|
|
38353
38412
|
const legacyDir = join5(baseCwd, ".oldpal");
|
|
38354
|
-
if (
|
|
38413
|
+
if (existsSync4(legacyDir)) {
|
|
38355
38414
|
return join5(legacyDir, "feedback");
|
|
38356
38415
|
}
|
|
38357
38416
|
return join5(getConfigDir(), "feedback");
|
|
38358
38417
|
}
|
|
38359
38418
|
function saveFeedbackEntry(entry, cwd2) {
|
|
38360
38419
|
const feedbackDir = resolveFeedbackDir(cwd2);
|
|
38361
|
-
|
|
38420
|
+
mkdirSync2(feedbackDir, { recursive: true });
|
|
38362
38421
|
const path2 = join5(feedbackDir, `${entry.id}.json`);
|
|
38363
|
-
|
|
38422
|
+
writeFileSync2(path2, JSON.stringify(entry, null, 2));
|
|
38364
38423
|
return { path: path2 };
|
|
38365
38424
|
}
|
|
38366
38425
|
function buildEntry(input, overrides) {
|
|
@@ -38921,7 +38980,7 @@ class SchedulerTool {
|
|
|
38921
38980
|
|
|
38922
38981
|
// packages/core/src/tools/image.ts
|
|
38923
38982
|
init_src();
|
|
38924
|
-
import { existsSync as
|
|
38983
|
+
import { existsSync as existsSync5, writeFileSync as writeFileSync3, unlinkSync } from "fs";
|
|
38925
38984
|
import { tmpdir } from "os";
|
|
38926
38985
|
import { join as join7 } from "path";
|
|
38927
38986
|
import { homedir as homedir4 } from "os";
|
|
@@ -39002,13 +39061,13 @@ class ImageDisplayTool {
|
|
|
39002
39061
|
const buffer = await response.arrayBuffer();
|
|
39003
39062
|
const ext = contentType.split("/")[1]?.split(";")[0] || "png";
|
|
39004
39063
|
tempFile = join7(tmpdir(), `assistants-image-${generateId()}.${ext}`);
|
|
39005
|
-
|
|
39064
|
+
writeFileSync3(tempFile, Buffer.from(buffer));
|
|
39006
39065
|
localPath = tempFile;
|
|
39007
39066
|
} catch (error) {
|
|
39008
39067
|
return `Error: Failed to fetch image: ${error instanceof Error ? error.message : String(error)}`;
|
|
39009
39068
|
}
|
|
39010
39069
|
}
|
|
39011
|
-
if (!
|
|
39070
|
+
if (!existsSync5(localPath)) {
|
|
39012
39071
|
return `Error: Image file not found: ${localPath}`;
|
|
39013
39072
|
}
|
|
39014
39073
|
try {
|
|
@@ -39033,7 +39092,7 @@ class ImageDisplayTool {
|
|
|
39033
39092
|
} catch (error) {
|
|
39034
39093
|
return `Error: ${error instanceof Error ? error.message : String(error)}`;
|
|
39035
39094
|
} finally {
|
|
39036
|
-
if (tempFile &&
|
|
39095
|
+
if (tempFile && existsSync5(tempFile)) {
|
|
39037
39096
|
try {
|
|
39038
39097
|
unlinkSync(tempFile);
|
|
39039
39098
|
} catch {}
|
|
@@ -39537,7 +39596,7 @@ Respond with JSON only: {"allow": boolean, "reason": string}`;
|
|
|
39537
39596
|
}
|
|
39538
39597
|
}
|
|
39539
39598
|
// packages/core/src/commands/loader.ts
|
|
39540
|
-
import { existsSync as
|
|
39599
|
+
import { existsSync as existsSync6, readdirSync as readdirSync2, statSync as statSync2 } from "fs";
|
|
39541
39600
|
import { join as join9, basename as basename2, extname } from "path";
|
|
39542
39601
|
import { homedir as homedir6 } from "os";
|
|
39543
39602
|
|
|
@@ -39561,7 +39620,7 @@ class CommandLoader {
|
|
|
39561
39620
|
await this.loadFromDirectory(legacyProjectDir, "project");
|
|
39562
39621
|
}
|
|
39563
39622
|
async loadFromDirectory(dir, source, prefix = "") {
|
|
39564
|
-
if (!
|
|
39623
|
+
if (!existsSync6(dir))
|
|
39565
39624
|
return;
|
|
39566
39625
|
const entries = readdirSync2(dir);
|
|
39567
39626
|
for (const entry of entries) {
|
|
@@ -39792,7 +39851,7 @@ ${stderr}`;
|
|
|
39792
39851
|
// packages/core/src/commands/builtin.ts
|
|
39793
39852
|
import { join as join11 } from "path";
|
|
39794
39853
|
import { homedir as homedir7, platform as platform2, release, arch } from "os";
|
|
39795
|
-
import { existsSync as
|
|
39854
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync3, writeFileSync as writeFileSync4 } from "fs";
|
|
39796
39855
|
init_src();
|
|
39797
39856
|
|
|
39798
39857
|
// packages/core/src/projects/store.ts
|
|
@@ -41560,7 +41619,7 @@ Format the summary as a brief bullet-point list. This summary will replace the c
|
|
|
41560
41619
|
message += `**Config File Locations:**
|
|
41561
41620
|
`;
|
|
41562
41621
|
for (const path2 of configPaths) {
|
|
41563
|
-
const exists =
|
|
41622
|
+
const exists = existsSync7(path2);
|
|
41564
41623
|
message += ` ${exists ? "\u2713" : "\u25CB"} ${path2}
|
|
41565
41624
|
`;
|
|
41566
41625
|
}
|
|
@@ -41588,7 +41647,7 @@ Format the summary as a brief bullet-point list. This summary will replace the c
|
|
|
41588
41647
|
content: "",
|
|
41589
41648
|
handler: async (args, context) => {
|
|
41590
41649
|
const commandsDir = join11(context.cwd, ".assistants", "commands");
|
|
41591
|
-
|
|
41650
|
+
mkdirSync3(commandsDir, { recursive: true });
|
|
41592
41651
|
const exampleCommand = `---
|
|
41593
41652
|
name: reflect
|
|
41594
41653
|
description: Reflect on the conversation and suggest next steps
|
|
@@ -41604,8 +41663,8 @@ Please summarize the last interaction and suggest 2-3 next steps.
|
|
|
41604
41663
|
- Ask a follow-up question if needed
|
|
41605
41664
|
`;
|
|
41606
41665
|
const examplePath = join11(commandsDir, "reflect.md");
|
|
41607
|
-
if (!
|
|
41608
|
-
|
|
41666
|
+
if (!existsSync7(examplePath)) {
|
|
41667
|
+
writeFileSync4(examplePath, exampleCommand);
|
|
41609
41668
|
}
|
|
41610
41669
|
let message = `
|
|
41611
41670
|
**Initialized assistants**
|
|
@@ -41841,8 +41900,19 @@ Keep it concise but comprehensive.`
|
|
|
41841
41900
|
handler: async (args, context) => {
|
|
41842
41901
|
const id = args.trim();
|
|
41843
41902
|
if (!id) {
|
|
41844
|
-
|
|
41903
|
+
const schedules = await listSchedules(context.cwd);
|
|
41904
|
+
if (schedules.length === 0) {
|
|
41905
|
+
context.emit("text", `No schedules found.
|
|
41906
|
+
`);
|
|
41907
|
+
} else {
|
|
41908
|
+
const lines = schedules.sort((a, b) => (a.nextRunAt || 0) - (b.nextRunAt || 0)).map((schedule) => `- ${schedule.id} [${schedule.status}] ${schedule.command}`);
|
|
41909
|
+
context.emit("text", `Usage: /pause <id>
|
|
41910
|
+
|
|
41911
|
+
Available schedules:
|
|
41912
|
+
${lines.join(`
|
|
41913
|
+
`)}
|
|
41845
41914
|
`);
|
|
41915
|
+
}
|
|
41846
41916
|
context.emit("done");
|
|
41847
41917
|
return { handled: true };
|
|
41848
41918
|
}
|
|
@@ -41868,8 +41938,19 @@ Keep it concise but comprehensive.`
|
|
|
41868
41938
|
handler: async (args, context) => {
|
|
41869
41939
|
const id = args.trim();
|
|
41870
41940
|
if (!id) {
|
|
41871
|
-
|
|
41941
|
+
const schedules = await listSchedules(context.cwd);
|
|
41942
|
+
if (schedules.length === 0) {
|
|
41943
|
+
context.emit("text", `No schedules found.
|
|
41872
41944
|
`);
|
|
41945
|
+
} else {
|
|
41946
|
+
const lines = schedules.sort((a, b) => (a.nextRunAt || 0) - (b.nextRunAt || 0)).map((schedule) => `- ${schedule.id} [${schedule.status}] ${schedule.command}`);
|
|
41947
|
+
context.emit("text", `Usage: /resume <id>
|
|
41948
|
+
|
|
41949
|
+
Available schedules:
|
|
41950
|
+
${lines.join(`
|
|
41951
|
+
`)}
|
|
41952
|
+
`);
|
|
41953
|
+
}
|
|
41873
41954
|
context.emit("done");
|
|
41874
41955
|
return { handled: true };
|
|
41875
41956
|
}
|
|
@@ -42304,7 +42385,7 @@ async function createLLMClient(config) {
|
|
|
42304
42385
|
|
|
42305
42386
|
// packages/core/src/heartbeat/manager.ts
|
|
42306
42387
|
import { dirname as dirname5 } from "path";
|
|
42307
|
-
import { mkdirSync as
|
|
42388
|
+
import { mkdirSync as mkdirSync4 } from "fs";
|
|
42308
42389
|
import { readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
|
|
42309
42390
|
|
|
42310
42391
|
class HeartbeatManager {
|
|
@@ -42326,7 +42407,7 @@ class HeartbeatManager {
|
|
|
42326
42407
|
uptimeSeconds: 0
|
|
42327
42408
|
};
|
|
42328
42409
|
const dir = dirname5(config.persistPath);
|
|
42329
|
-
|
|
42410
|
+
mkdirSync4(dir, { recursive: true });
|
|
42330
42411
|
}
|
|
42331
42412
|
start(sessionId) {
|
|
42332
42413
|
if (this.intervalId)
|
|
@@ -42400,14 +42481,14 @@ class HeartbeatManager {
|
|
|
42400
42481
|
}
|
|
42401
42482
|
// packages/core/src/heartbeat/persistence.ts
|
|
42402
42483
|
import { dirname as dirname6 } from "path";
|
|
42403
|
-
import { mkdirSync as
|
|
42484
|
+
import { mkdirSync as mkdirSync5 } from "fs";
|
|
42404
42485
|
import { readFile as readFile5, writeFile as writeFile4, unlink as unlink3 } from "fs/promises";
|
|
42405
42486
|
|
|
42406
42487
|
class StatePersistence {
|
|
42407
42488
|
path;
|
|
42408
42489
|
constructor(path2) {
|
|
42409
42490
|
this.path = path2;
|
|
42410
|
-
|
|
42491
|
+
mkdirSync5(dirname6(path2), { recursive: true });
|
|
42411
42492
|
}
|
|
42412
42493
|
async save(state) {
|
|
42413
42494
|
try {
|
|
@@ -42627,14 +42708,14 @@ class EnergyManager {
|
|
|
42627
42708
|
}
|
|
42628
42709
|
// packages/core/src/energy/storage.ts
|
|
42629
42710
|
import { dirname as dirname7 } from "path";
|
|
42630
|
-
import { mkdirSync as
|
|
42711
|
+
import { mkdirSync as mkdirSync6 } from "fs";
|
|
42631
42712
|
import { readFile as readFile6, writeFile as writeFile5 } from "fs/promises";
|
|
42632
42713
|
|
|
42633
42714
|
class EnergyStorage {
|
|
42634
42715
|
path;
|
|
42635
42716
|
constructor(path2) {
|
|
42636
42717
|
this.path = path2;
|
|
42637
|
-
|
|
42718
|
+
mkdirSync6(dirname7(path2), { recursive: true });
|
|
42638
42719
|
}
|
|
42639
42720
|
async save(state) {
|
|
42640
42721
|
try {
|
|
@@ -42701,7 +42782,7 @@ function validateToolCalls(toolCalls, tools) {
|
|
|
42701
42782
|
}
|
|
42702
42783
|
|
|
42703
42784
|
// packages/core/src/voice/utils.ts
|
|
42704
|
-
import { existsSync as
|
|
42785
|
+
import { existsSync as existsSync9, readFileSync as readFileSync4 } from "fs";
|
|
42705
42786
|
import { homedir as homedir9 } from "os";
|
|
42706
42787
|
import { join as join13 } from "path";
|
|
42707
42788
|
import { spawnSync } from "child_process";
|
|
@@ -42709,10 +42790,10 @@ function loadApiKeyFromSecrets2(key) {
|
|
|
42709
42790
|
const envHome = process.env.HOME || process.env.USERPROFILE;
|
|
42710
42791
|
const homeDir = envHome && envHome.trim().length > 0 ? envHome : homedir9();
|
|
42711
42792
|
const secretsPath = join13(homeDir, ".secrets");
|
|
42712
|
-
if (!
|
|
42793
|
+
if (!existsSync9(secretsPath))
|
|
42713
42794
|
return;
|
|
42714
42795
|
try {
|
|
42715
|
-
const content =
|
|
42796
|
+
const content = readFileSync4(secretsPath, "utf-8");
|
|
42716
42797
|
const match = content.match(new RegExp(`export\\s+${key}\\s*=\\s*['"]?([^'"\\n]+)['"]?`));
|
|
42717
42798
|
return match?.[1];
|
|
42718
42799
|
} catch {
|
|
@@ -42783,7 +42864,7 @@ class SystemSTT {
|
|
|
42783
42864
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
42784
42865
|
import { tmpdir as tmpdir2 } from "os";
|
|
42785
42866
|
import { join as join14 } from "path";
|
|
42786
|
-
import { readFileSync as
|
|
42867
|
+
import { readFileSync as readFileSync5, unlinkSync as unlinkSync2 } from "fs";
|
|
42787
42868
|
class ElevenLabsTTS {
|
|
42788
42869
|
apiKey;
|
|
42789
42870
|
voiceId;
|
|
@@ -42899,7 +42980,7 @@ class SystemTTS {
|
|
|
42899
42980
|
if (result.status !== 0) {
|
|
42900
42981
|
throw new Error(`System TTS failed: ${result.stderr || "unknown error"}`);
|
|
42901
42982
|
}
|
|
42902
|
-
const audio =
|
|
42983
|
+
const audio = readFileSync5(output);
|
|
42903
42984
|
unlinkSync2(output);
|
|
42904
42985
|
return {
|
|
42905
42986
|
audio: audio.buffer.slice(audio.byteOffset, audio.byteOffset + audio.byteLength),
|
|
@@ -42921,7 +43002,7 @@ class SystemTTS {
|
|
|
42921
43002
|
if (result.status !== 0) {
|
|
42922
43003
|
throw new Error(`System TTS failed: ${result.stderr || "unknown error"}`);
|
|
42923
43004
|
}
|
|
42924
|
-
const audio =
|
|
43005
|
+
const audio = readFileSync5(output);
|
|
42925
43006
|
unlinkSync2(output);
|
|
42926
43007
|
return {
|
|
42927
43008
|
audio: audio.buffer.slice(audio.byteOffset, audio.byteOffset + audio.byteLength),
|
|
@@ -42936,14 +43017,14 @@ class SystemTTS {
|
|
|
42936
43017
|
import { spawn } from "child_process";
|
|
42937
43018
|
import { tmpdir as tmpdir3 } from "os";
|
|
42938
43019
|
import { join as join15 } from "path";
|
|
42939
|
-
import { unlink as unlink4, writeFileSync as
|
|
43020
|
+
import { unlink as unlink4, writeFileSync as writeFileSync5 } from "fs";
|
|
42940
43021
|
class AudioPlayer {
|
|
42941
43022
|
currentProcess = null;
|
|
42942
43023
|
playing = false;
|
|
42943
43024
|
async play(audio, options = {}) {
|
|
42944
43025
|
const format = options.format ?? "mp3";
|
|
42945
43026
|
const tempFile = join15(tmpdir3(), `assistants-audio-${Date.now()}.${format}`);
|
|
42946
|
-
|
|
43027
|
+
writeFileSync5(tempFile, Buffer.from(audio));
|
|
42947
43028
|
const player = this.resolvePlayer(format);
|
|
42948
43029
|
if (!player) {
|
|
42949
43030
|
throw new Error("No supported audio player found. Install afplay, ffplay, mpg123, or aplay.");
|
|
@@ -43011,7 +43092,7 @@ class AudioPlayer {
|
|
|
43011
43092
|
import { spawn as spawn2 } from "child_process";
|
|
43012
43093
|
import { tmpdir as tmpdir4 } from "os";
|
|
43013
43094
|
import { join as join16 } from "path";
|
|
43014
|
-
import { readFileSync as
|
|
43095
|
+
import { readFileSync as readFileSync6, unlink as unlink5 } from "fs";
|
|
43015
43096
|
class AudioRecorder {
|
|
43016
43097
|
currentProcess = null;
|
|
43017
43098
|
async record(options = {}) {
|
|
@@ -43041,7 +43122,7 @@ class AudioRecorder {
|
|
|
43041
43122
|
reject(error);
|
|
43042
43123
|
});
|
|
43043
43124
|
});
|
|
43044
|
-
const data =
|
|
43125
|
+
const data = readFileSync6(output);
|
|
43045
43126
|
unlink5(output, () => {});
|
|
43046
43127
|
return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
43047
43128
|
}
|
|
@@ -43213,13 +43294,13 @@ class VoiceManager {
|
|
|
43213
43294
|
}
|
|
43214
43295
|
// packages/core/src/identity/assistant-manager.ts
|
|
43215
43296
|
init_src();
|
|
43216
|
-
import { existsSync as
|
|
43297
|
+
import { existsSync as existsSync11 } from "fs";
|
|
43217
43298
|
import { mkdir as mkdir5, readFile as readFile8, writeFile as writeFile7, rm as rm2 } from "fs/promises";
|
|
43218
43299
|
import { join as join18 } from "path";
|
|
43219
43300
|
|
|
43220
43301
|
// packages/core/src/identity/identity-manager.ts
|
|
43221
43302
|
init_src();
|
|
43222
|
-
import { existsSync as
|
|
43303
|
+
import { existsSync as existsSync10 } from "fs";
|
|
43223
43304
|
import { mkdir as mkdir4, readFile as readFile7, writeFile as writeFile6, rm } from "fs/promises";
|
|
43224
43305
|
import { join as join17 } from "path";
|
|
43225
43306
|
var DEFAULT_PROFILE = {
|
|
@@ -43369,7 +43450,7 @@ class IdentityManager {
|
|
|
43369
43450
|
`);
|
|
43370
43451
|
}
|
|
43371
43452
|
async readIndex() {
|
|
43372
|
-
if (!
|
|
43453
|
+
if (!existsSync10(this.indexPath)) {
|
|
43373
43454
|
return { identities: [] };
|
|
43374
43455
|
}
|
|
43375
43456
|
try {
|
|
@@ -43394,7 +43475,7 @@ class IdentityManager {
|
|
|
43394
43475
|
}
|
|
43395
43476
|
async readIdentity(id) {
|
|
43396
43477
|
const path2 = this.identityPath(id);
|
|
43397
|
-
if (!
|
|
43478
|
+
if (!existsSync10(path2))
|
|
43398
43479
|
return null;
|
|
43399
43480
|
try {
|
|
43400
43481
|
const raw = await readFile7(path2, "utf-8");
|
|
@@ -43408,7 +43489,7 @@ class IdentityManager {
|
|
|
43408
43489
|
await writeFile6(this.identityPath(identity.id), JSON.stringify(identity, null, 2));
|
|
43409
43490
|
}
|
|
43410
43491
|
async readActive() {
|
|
43411
|
-
if (!
|
|
43492
|
+
if (!existsSync10(this.activePath))
|
|
43412
43493
|
return null;
|
|
43413
43494
|
try {
|
|
43414
43495
|
const raw = await readFile7(this.activePath, "utf-8");
|
|
@@ -43423,7 +43504,7 @@ class IdentityManager {
|
|
|
43423
43504
|
await writeFile6(this.activePath, JSON.stringify({ id }, null, 2));
|
|
43424
43505
|
}
|
|
43425
43506
|
async loadAssistant() {
|
|
43426
|
-
if (!
|
|
43507
|
+
if (!existsSync10(this.assistantConfigPath()))
|
|
43427
43508
|
return null;
|
|
43428
43509
|
try {
|
|
43429
43510
|
const raw = await readFile7(this.assistantConfigPath(), "utf-8");
|
|
@@ -43541,7 +43622,7 @@ class AssistantManager {
|
|
|
43541
43622
|
return new IdentityManager(assistantId, this.basePath);
|
|
43542
43623
|
}
|
|
43543
43624
|
async readIndex() {
|
|
43544
|
-
if (!
|
|
43625
|
+
if (!existsSync11(this.indexPath)) {
|
|
43545
43626
|
return { assistants: [] };
|
|
43546
43627
|
}
|
|
43547
43628
|
try {
|
|
@@ -43566,7 +43647,7 @@ class AssistantManager {
|
|
|
43566
43647
|
}
|
|
43567
43648
|
async readAssistant(id) {
|
|
43568
43649
|
const configPath = this.assistantConfigPath(id);
|
|
43569
|
-
if (!
|
|
43650
|
+
if (!existsSync11(configPath))
|
|
43570
43651
|
return null;
|
|
43571
43652
|
try {
|
|
43572
43653
|
const raw = await readFile8(configPath, "utf-8");
|
|
@@ -43581,7 +43662,7 @@ class AssistantManager {
|
|
|
43581
43662
|
await writeFile7(this.assistantConfigPath(assistant.id), JSON.stringify(assistant, null, 2));
|
|
43582
43663
|
}
|
|
43583
43664
|
async readActive() {
|
|
43584
|
-
if (!
|
|
43665
|
+
if (!existsSync11(this.activePath))
|
|
43585
43666
|
return null;
|
|
43586
43667
|
try {
|
|
43587
43668
|
const raw = await readFile8(this.activePath, "utf-8");
|
|
@@ -44675,7 +44756,7 @@ function parseErrorCode(message) {
|
|
|
44675
44756
|
// packages/core/src/memory/sessions.ts
|
|
44676
44757
|
init_src();
|
|
44677
44758
|
// packages/core/src/migration/migrate-to-assistants.ts
|
|
44678
|
-
import { existsSync as
|
|
44759
|
+
import { existsSync as existsSync12 } from "fs";
|
|
44679
44760
|
import { mkdir as mkdir6, readFile as readFile9, writeFile as writeFile8, rename, cp } from "fs/promises";
|
|
44680
44761
|
import { join as join20 } from "path";
|
|
44681
44762
|
import { homedir as homedir10 } from "os";
|
|
@@ -44684,14 +44765,14 @@ async function ensureDir(path2) {
|
|
|
44684
44765
|
await mkdir6(path2, { recursive: true });
|
|
44685
44766
|
}
|
|
44686
44767
|
async function copyIfExists(source, destination) {
|
|
44687
|
-
if (!
|
|
44768
|
+
if (!existsSync12(source))
|
|
44688
44769
|
return false;
|
|
44689
44770
|
await ensureDir(join20(destination, ".."));
|
|
44690
44771
|
await cp(source, destination, { recursive: true });
|
|
44691
44772
|
return true;
|
|
44692
44773
|
}
|
|
44693
44774
|
async function readJson(path2) {
|
|
44694
|
-
if (!
|
|
44775
|
+
if (!existsSync12(path2))
|
|
44695
44776
|
return null;
|
|
44696
44777
|
try {
|
|
44697
44778
|
const raw = await readFile9(path2, "utf-8");
|
|
@@ -44709,13 +44790,13 @@ async function migrateFromOldpal() {
|
|
|
44709
44790
|
const home = homedir10();
|
|
44710
44791
|
const oldPath = join20(home, ".oldpal");
|
|
44711
44792
|
const newPath = join20(home, ".assistants");
|
|
44712
|
-
if (!
|
|
44793
|
+
if (!existsSync12(oldPath)) {
|
|
44713
44794
|
result.success = true;
|
|
44714
44795
|
return result;
|
|
44715
44796
|
}
|
|
44716
|
-
if (
|
|
44797
|
+
if (existsSync12(newPath)) {
|
|
44717
44798
|
const marker = join20(newPath, "migration", MIGRATION_MARKER);
|
|
44718
|
-
if (
|
|
44799
|
+
if (existsSync12(marker)) {
|
|
44719
44800
|
result.success = true;
|
|
44720
44801
|
return result;
|
|
44721
44802
|
}
|
|
@@ -44783,7 +44864,7 @@ init_anthropic();
|
|
|
44783
44864
|
init_src();
|
|
44784
44865
|
|
|
44785
44866
|
// packages/core/src/logger.ts
|
|
44786
|
-
import { existsSync as
|
|
44867
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync7, appendFileSync, readdirSync as readdirSync3, readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "fs";
|
|
44787
44868
|
import { join as join21 } from "path";
|
|
44788
44869
|
class Logger {
|
|
44789
44870
|
logDir;
|
|
@@ -44797,8 +44878,8 @@ class Logger {
|
|
|
44797
44878
|
this.logFile = join21(this.logDir, `${date}.log`);
|
|
44798
44879
|
}
|
|
44799
44880
|
ensureDir(dir) {
|
|
44800
|
-
if (!
|
|
44801
|
-
|
|
44881
|
+
if (!existsSync13(dir)) {
|
|
44882
|
+
mkdirSync7(dir, { recursive: true });
|
|
44802
44883
|
}
|
|
44803
44884
|
}
|
|
44804
44885
|
write(level, message, data) {
|
|
@@ -44843,13 +44924,13 @@ class SessionStorage {
|
|
|
44843
44924
|
this.sessionFile = join21(this.sessionsDir, `${sessionId}.json`);
|
|
44844
44925
|
}
|
|
44845
44926
|
ensureDir(dir) {
|
|
44846
|
-
if (!
|
|
44847
|
-
|
|
44927
|
+
if (!existsSync13(dir)) {
|
|
44928
|
+
mkdirSync7(dir, { recursive: true });
|
|
44848
44929
|
}
|
|
44849
44930
|
}
|
|
44850
44931
|
save(data) {
|
|
44851
44932
|
try {
|
|
44852
|
-
|
|
44933
|
+
writeFileSync6(this.sessionFile, JSON.stringify(data, null, 2));
|
|
44853
44934
|
} catch {}
|
|
44854
44935
|
}
|
|
44855
44936
|
getSessionId() {
|
|
@@ -44857,9 +44938,9 @@ class SessionStorage {
|
|
|
44857
44938
|
}
|
|
44858
44939
|
load() {
|
|
44859
44940
|
try {
|
|
44860
|
-
if (!
|
|
44941
|
+
if (!existsSync13(this.sessionFile))
|
|
44861
44942
|
return null;
|
|
44862
|
-
return JSON.parse(
|
|
44943
|
+
return JSON.parse(readFileSync7(this.sessionFile, "utf-8"));
|
|
44863
44944
|
} catch {
|
|
44864
44945
|
return null;
|
|
44865
44946
|
}
|
|
@@ -44867,9 +44948,9 @@ class SessionStorage {
|
|
|
44867
44948
|
static getActiveAssistantId() {
|
|
44868
44949
|
try {
|
|
44869
44950
|
const activePath = join21(getConfigDir(), "active.json");
|
|
44870
|
-
if (!
|
|
44951
|
+
if (!existsSync13(activePath))
|
|
44871
44952
|
return null;
|
|
44872
|
-
const raw =
|
|
44953
|
+
const raw = readFileSync7(activePath, "utf-8");
|
|
44873
44954
|
const data = JSON.parse(raw);
|
|
44874
44955
|
return data.id || null;
|
|
44875
44956
|
} catch {
|
|
@@ -44881,7 +44962,7 @@ class SessionStorage {
|
|
|
44881
44962
|
const resolvedId = assistantId ?? SessionStorage.getActiveAssistantId();
|
|
44882
44963
|
if (resolvedId) {
|
|
44883
44964
|
const assistantDir = join21(root, "assistants", resolvedId, "sessions");
|
|
44884
|
-
if (
|
|
44965
|
+
if (existsSync13(assistantDir)) {
|
|
44885
44966
|
return assistantDir;
|
|
44886
44967
|
}
|
|
44887
44968
|
}
|
|
@@ -44889,7 +44970,7 @@ class SessionStorage {
|
|
|
44889
44970
|
}
|
|
44890
44971
|
static listSessions(assistantId) {
|
|
44891
44972
|
const sessionsDir = SessionStorage.resolveSessionsDir(assistantId);
|
|
44892
|
-
if (!
|
|
44973
|
+
if (!existsSync13(sessionsDir))
|
|
44893
44974
|
return [];
|
|
44894
44975
|
const sessions = [];
|
|
44895
44976
|
const files = readdirSync3(sessionsDir);
|
|
@@ -44899,7 +44980,7 @@ class SessionStorage {
|
|
|
44899
44980
|
try {
|
|
44900
44981
|
const filePath = join21(sessionsDir, file);
|
|
44901
44982
|
const stat = Bun.file(filePath);
|
|
44902
|
-
const content = JSON.parse(
|
|
44983
|
+
const content = JSON.parse(readFileSync7(filePath, "utf-8"));
|
|
44903
44984
|
sessions.push({
|
|
44904
44985
|
id: file.replace(".json", ""),
|
|
44905
44986
|
cwd: content.cwd,
|
|
@@ -44919,9 +45000,9 @@ class SessionStorage {
|
|
|
44919
45000
|
const sessionsDir = SessionStorage.resolveSessionsDir(assistantId);
|
|
44920
45001
|
const sessionFile = join21(sessionsDir, `${sessionId}.json`);
|
|
44921
45002
|
try {
|
|
44922
|
-
if (!
|
|
45003
|
+
if (!existsSync13(sessionFile))
|
|
44923
45004
|
return null;
|
|
44924
|
-
return JSON.parse(
|
|
45005
|
+
return JSON.parse(readFileSync7(sessionFile, "utf-8"));
|
|
44925
45006
|
} catch {
|
|
44926
45007
|
return null;
|
|
44927
45008
|
}
|
|
@@ -44942,8 +45023,8 @@ function initAssistantsDir() {
|
|
|
44942
45023
|
join21(baseDir, "migration")
|
|
44943
45024
|
];
|
|
44944
45025
|
for (const dir of dirs) {
|
|
44945
|
-
if (!
|
|
44946
|
-
|
|
45026
|
+
if (!existsSync13(dir)) {
|
|
45027
|
+
mkdirSync7(dir, { recursive: true });
|
|
44947
45028
|
}
|
|
44948
45029
|
}
|
|
44949
45030
|
}
|
|
@@ -46654,6 +46735,8 @@ function MessageBubble({ message, queuedMessageIds }) {
|
|
|
46654
46735
|
const chunkMatch = message.id.match(/::chunk-(\d+)$/);
|
|
46655
46736
|
const chunkIndex = chunkMatch ? Number(chunkMatch[1]) : -1;
|
|
46656
46737
|
const isContinuation = chunkIndex > 0;
|
|
46738
|
+
const content = message.content ?? "";
|
|
46739
|
+
const leadingBullet = !isContinuation && !startsWithListOrTable(content);
|
|
46657
46740
|
if (isSystem) {
|
|
46658
46741
|
return null;
|
|
46659
46742
|
}
|
|
@@ -46682,7 +46765,7 @@ function MessageBubble({ message, queuedMessageIds }) {
|
|
|
46682
46765
|
}
|
|
46683
46766
|
const toolCalls = message.toolCalls || [];
|
|
46684
46767
|
const toolResults = message.toolResults || [];
|
|
46685
|
-
const hasContent =
|
|
46768
|
+
const hasContent = content && content.trim();
|
|
46686
46769
|
return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
|
|
46687
46770
|
marginY: isContinuation ? 0 : 1,
|
|
46688
46771
|
flexDirection: "column",
|
|
@@ -46692,7 +46775,7 @@ function MessageBubble({ message, queuedMessageIds }) {
|
|
|
46692
46775
|
/* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
|
|
46693
46776
|
dimColor: true,
|
|
46694
46777
|
children: [
|
|
46695
|
-
isContinuation ? " " : "\u25CF ",
|
|
46778
|
+
isContinuation || !leadingBullet ? " " : "\u25CF ",
|
|
46696
46779
|
" "
|
|
46697
46780
|
]
|
|
46698
46781
|
}, undefined, true, undefined, this),
|
|
@@ -46715,6 +46798,23 @@ function MessageBubble({ message, queuedMessageIds }) {
|
|
|
46715
46798
|
]
|
|
46716
46799
|
}, undefined, true, undefined, this);
|
|
46717
46800
|
}
|
|
46801
|
+
function startsWithListOrTable(content) {
|
|
46802
|
+
const lines = content.split(`
|
|
46803
|
+
`);
|
|
46804
|
+
for (const line of lines) {
|
|
46805
|
+
const trimmed = line.trimStart();
|
|
46806
|
+
if (!trimmed)
|
|
46807
|
+
continue;
|
|
46808
|
+
if (/^[-*\u2022]\s+/.test(trimmed))
|
|
46809
|
+
return true;
|
|
46810
|
+
if (/^\d+\.\s+/.test(trimmed))
|
|
46811
|
+
return true;
|
|
46812
|
+
if (trimmed.startsWith("|"))
|
|
46813
|
+
return true;
|
|
46814
|
+
return false;
|
|
46815
|
+
}
|
|
46816
|
+
return false;
|
|
46817
|
+
}
|
|
46718
46818
|
function ToolCallPanel({
|
|
46719
46819
|
toolCalls,
|
|
46720
46820
|
toolResults
|
|
@@ -46735,7 +46835,7 @@ function ToolCallPanel({
|
|
|
46735
46835
|
borderStyle: "round",
|
|
46736
46836
|
borderColor,
|
|
46737
46837
|
paddingX: 1,
|
|
46738
|
-
width:
|
|
46838
|
+
width: "100%",
|
|
46739
46839
|
children: [
|
|
46740
46840
|
/* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
|
|
46741
46841
|
justifyContent: "space-between",
|
|
@@ -46868,7 +46968,7 @@ function getToolDisplayName(toolCall) {
|
|
|
46868
46968
|
return "image";
|
|
46869
46969
|
case "schedule":
|
|
46870
46970
|
return "schedule";
|
|
46871
|
-
case "
|
|
46971
|
+
case "submit_feedback":
|
|
46872
46972
|
return "feedback";
|
|
46873
46973
|
case "notion":
|
|
46874
46974
|
case "gmail":
|
|
@@ -46902,7 +47002,7 @@ function formatToolCall(toolCall) {
|
|
|
46902
47002
|
return `Searching: ${truncate(String(input.pattern || ""), 60)}`;
|
|
46903
47003
|
case "schedule":
|
|
46904
47004
|
return formatScheduleCall(input);
|
|
46905
|
-
case "
|
|
47005
|
+
case "submit_feedback":
|
|
46906
47006
|
return formatFeedbackCall(input);
|
|
46907
47007
|
case "notion":
|
|
46908
47008
|
return `Notion: ${truncate(String(input.command || input.action || ""), 60)}`;
|
|
@@ -46998,7 +47098,7 @@ function formatToolResultNicely(toolName, content, isError) {
|
|
|
46998
47098
|
switch (toolName) {
|
|
46999
47099
|
case "schedule":
|
|
47000
47100
|
return formatScheduleResult(content);
|
|
47001
|
-
case "
|
|
47101
|
+
case "submit_feedback":
|
|
47002
47102
|
return formatFeedbackResult(content);
|
|
47003
47103
|
case "read":
|
|
47004
47104
|
return formatReadResult(content);
|
|
@@ -47151,6 +47251,7 @@ function Status({
|
|
|
47151
47251
|
const sessionInfo = sessionIndex && sessionCount && sessionCount > 1 ? `${sessionIndex}/${sessionCount}` : "";
|
|
47152
47252
|
const bgIndicator = backgroundProcessingCount > 0 ? ` +${backgroundProcessingCount}` : "";
|
|
47153
47253
|
const voiceIcon = voiceState?.enabled ? voiceState.isListening ? "\uD83C\uDFA4" : voiceState.isSpeaking ? "\uD83D\uDD0A" : "\uD83C\uDF99" : "";
|
|
47254
|
+
const sessionLabel = sessionId ? `id ${sessionId}` : "";
|
|
47154
47255
|
return /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Box_default, {
|
|
47155
47256
|
marginTop: 1,
|
|
47156
47257
|
justifyContent: "space-between",
|
|
@@ -47193,6 +47294,13 @@ function Status({
|
|
|
47193
47294
|
" \xB7 ",
|
|
47194
47295
|
formatDuration2(elapsed)
|
|
47195
47296
|
]
|
|
47297
|
+
}, undefined, true, undefined, this),
|
|
47298
|
+
sessionLabel && /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
|
|
47299
|
+
dimColor: true,
|
|
47300
|
+
children: [
|
|
47301
|
+
contextInfo || isProcessing && processingStartTime || sessionInfo ? " \xB7 " : "",
|
|
47302
|
+
sessionLabel
|
|
47303
|
+
]
|
|
47196
47304
|
}, undefined, true, undefined, this)
|
|
47197
47305
|
]
|
|
47198
47306
|
}, undefined, true, undefined, this)
|
|
@@ -47531,6 +47639,14 @@ function parseErrorMessage(error) {
|
|
|
47531
47639
|
}
|
|
47532
47640
|
return { code, message, suggestion };
|
|
47533
47641
|
}
|
|
47642
|
+
function formatElapsedDuration(ms) {
|
|
47643
|
+
const totalSeconds = Math.max(0, Math.floor(ms / 1000));
|
|
47644
|
+
if (totalSeconds < 60)
|
|
47645
|
+
return `${totalSeconds}s`;
|
|
47646
|
+
const mins = Math.floor(totalSeconds / 60);
|
|
47647
|
+
const secs = totalSeconds % 60;
|
|
47648
|
+
return `${mins}m ${secs}s`;
|
|
47649
|
+
}
|
|
47534
47650
|
var MESSAGE_CHUNK_LINES = 12;
|
|
47535
47651
|
var MESSAGE_WRAP_CHARS = 120;
|
|
47536
47652
|
function wrapTextLines(text, wrapChars) {
|
|
@@ -47648,6 +47764,7 @@ function App2({ cwd: cwd2, version }) {
|
|
|
47648
47764
|
const [isProcessing, setIsProcessing] = import_react29.useState(false);
|
|
47649
47765
|
const [error, setError] = import_react29.useState(null);
|
|
47650
47766
|
const [messageQueue, setMessageQueue] = import_react29.useState([]);
|
|
47767
|
+
const [inlinePending, setInlinePending] = import_react29.useState([]);
|
|
47651
47768
|
const [activityLog, setActivityLog] = import_react29.useState([]);
|
|
47652
47769
|
const [tokenUsage, setTokenUsage] = import_react29.useState();
|
|
47653
47770
|
const [energyState, setEnergyState] = import_react29.useState();
|
|
@@ -47665,9 +47782,13 @@ function App2({ cwd: cwd2, version }) {
|
|
|
47665
47782
|
const prevDisplayLineCountRef = import_react29.useRef(0);
|
|
47666
47783
|
const skipNextDoneRef = import_react29.useRef(false);
|
|
47667
47784
|
const isProcessingRef = import_react29.useRef(isProcessing);
|
|
47785
|
+
const processingStartTimeRef = import_react29.useRef(processingStartTime);
|
|
47668
47786
|
import_react29.useEffect(() => {
|
|
47669
47787
|
isProcessingRef.current = isProcessing;
|
|
47670
47788
|
}, [isProcessing]);
|
|
47789
|
+
import_react29.useEffect(() => {
|
|
47790
|
+
processingStartTimeRef.current = processingStartTime;
|
|
47791
|
+
}, [processingStartTime]);
|
|
47671
47792
|
import_react29.useEffect(() => {
|
|
47672
47793
|
if (isProcessing && !processingStartTime) {
|
|
47673
47794
|
setProcessingStartTime(Date.now());
|
|
@@ -47719,6 +47840,12 @@ function App2({ cwd: cwd2, version }) {
|
|
|
47719
47840
|
content = content ? `${content}
|
|
47720
47841
|
|
|
47721
47842
|
[error]` : "[error]";
|
|
47843
|
+
}
|
|
47844
|
+
if (processingStartTimeRef.current) {
|
|
47845
|
+
const workedFor = formatElapsedDuration(Date.now() - processingStartTimeRef.current);
|
|
47846
|
+
content = content ? `${content}
|
|
47847
|
+
|
|
47848
|
+
\u273B Worked for ${workedFor}` : `\u273B Worked for ${workedFor}`;
|
|
47722
47849
|
}
|
|
47723
47850
|
setMessages((prev) => [
|
|
47724
47851
|
...prev,
|
|
@@ -47801,6 +47928,21 @@ function App2({ cwd: cwd2, version }) {
|
|
|
47801
47928
|
setAutoScroll(true);
|
|
47802
47929
|
}, []);
|
|
47803
47930
|
const handleChunk = import_react29.useCallback((chunk) => {
|
|
47931
|
+
if (!isProcessingRef.current && (chunk.type === "text" || chunk.type === "tool_use" || chunk.type === "tool_result")) {
|
|
47932
|
+
const active = registryRef.current.getActiveSession();
|
|
47933
|
+
if (active) {
|
|
47934
|
+
registryRef.current.setProcessing(active.id, true);
|
|
47935
|
+
setIsProcessing(true);
|
|
47936
|
+
isProcessingRef.current = true;
|
|
47937
|
+
setProcessingStartTime(Date.now());
|
|
47938
|
+
setInlinePending((prev) => {
|
|
47939
|
+
const idx = prev.findIndex((msg) => msg.sessionId === active.id);
|
|
47940
|
+
if (idx === -1)
|
|
47941
|
+
return prev;
|
|
47942
|
+
return [...prev.slice(0, idx), ...prev.slice(idx + 1)];
|
|
47943
|
+
});
|
|
47944
|
+
}
|
|
47945
|
+
}
|
|
47804
47946
|
if (chunk.type === "text" && chunk.content) {
|
|
47805
47947
|
responseRef.current += chunk.content;
|
|
47806
47948
|
setCurrentResponse(responseRef.current);
|
|
@@ -47984,6 +48126,7 @@ function App2({ cwd: cwd2, version }) {
|
|
|
47984
48126
|
await activeSession2.client.send(nextMessage.content);
|
|
47985
48127
|
}, [activeSessionId]);
|
|
47986
48128
|
const activeQueue = activeSessionId ? messageQueue.filter((msg) => msg.sessionId === activeSessionId) : [];
|
|
48129
|
+
const activeInline = activeSessionId ? inlinePending.filter((msg) => msg.sessionId === activeSessionId) : [];
|
|
47987
48130
|
const queuedMessageIds = import_react29.useMemo(() => new Set(activeQueue.filter((msg) => msg.mode === "queued").map((msg) => msg.id)), [activeQueue]);
|
|
47988
48131
|
const wrapChars = columns ? Math.max(40, columns - 4) : MESSAGE_WRAP_CHARS;
|
|
47989
48132
|
const renderWidth = columns ? Math.max(20, columns - 2) : undefined;
|
|
@@ -48154,7 +48297,7 @@ function App2({ cwd: cwd2, version }) {
|
|
|
48154
48297
|
setShowSessionSelector(true);
|
|
48155
48298
|
return;
|
|
48156
48299
|
}
|
|
48157
|
-
if (mode === "queue"
|
|
48300
|
+
if (mode === "queue") {
|
|
48158
48301
|
if (!activeSessionId)
|
|
48159
48302
|
return;
|
|
48160
48303
|
const queuedId = generateId();
|
|
@@ -48165,7 +48308,7 @@ function App2({ cwd: cwd2, version }) {
|
|
|
48165
48308
|
sessionId: activeSessionId,
|
|
48166
48309
|
content: trimmedInput,
|
|
48167
48310
|
queuedAt: now(),
|
|
48168
|
-
mode:
|
|
48311
|
+
mode: "queued"
|
|
48169
48312
|
}
|
|
48170
48313
|
]);
|
|
48171
48314
|
setMessages((prev) => [
|
|
@@ -48179,6 +48322,32 @@ function App2({ cwd: cwd2, version }) {
|
|
|
48179
48322
|
]);
|
|
48180
48323
|
return;
|
|
48181
48324
|
}
|
|
48325
|
+
if (mode === "inline") {
|
|
48326
|
+
if (!activeSessionId)
|
|
48327
|
+
return;
|
|
48328
|
+
const inlineId = generateId();
|
|
48329
|
+
setInlinePending((prev) => [
|
|
48330
|
+
...prev,
|
|
48331
|
+
{
|
|
48332
|
+
id: inlineId,
|
|
48333
|
+
sessionId: activeSessionId,
|
|
48334
|
+
content: trimmedInput,
|
|
48335
|
+
queuedAt: now(),
|
|
48336
|
+
mode: "inline"
|
|
48337
|
+
}
|
|
48338
|
+
]);
|
|
48339
|
+
setMessages((prev) => [
|
|
48340
|
+
...prev,
|
|
48341
|
+
{
|
|
48342
|
+
id: inlineId,
|
|
48343
|
+
role: "user",
|
|
48344
|
+
content: trimmedInput,
|
|
48345
|
+
timestamp: now()
|
|
48346
|
+
}
|
|
48347
|
+
]);
|
|
48348
|
+
await activeSession.client.send(trimmedInput);
|
|
48349
|
+
return;
|
|
48350
|
+
}
|
|
48182
48351
|
if (mode === "interrupt" && isProcessing) {
|
|
48183
48352
|
activeSession.client.stop();
|
|
48184
48353
|
const finalized = finalizeResponse("interrupted");
|
|
@@ -48263,7 +48432,7 @@ function App2({ cwd: cwd2, version }) {
|
|
|
48263
48432
|
return text.slice(0, maxLen - 3) + "...";
|
|
48264
48433
|
};
|
|
48265
48434
|
const queuedCount = activeQueue.filter((msg) => msg.mode === "queued").length;
|
|
48266
|
-
const inlineCount =
|
|
48435
|
+
const inlineCount = activeInline.length;
|
|
48267
48436
|
const showWelcome = messages.length === 0 && !isProcessing;
|
|
48268
48437
|
return /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
48269
48438
|
flexDirection: "column",
|
|
@@ -48307,20 +48476,20 @@ function App2({ cwd: cwd2, version }) {
|
|
|
48307
48476
|
scrollOffsetLines: scrollOffset,
|
|
48308
48477
|
maxVisibleLines
|
|
48309
48478
|
}, activeSessionId || "default", false, undefined, this),
|
|
48310
|
-
activeQueue.length > 0 && /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
48479
|
+
(activeQueue.length > 0 || inlineCount > 0) && /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
48311
48480
|
marginY: 1,
|
|
48312
48481
|
flexDirection: "column",
|
|
48313
48482
|
children: [
|
|
48314
48483
|
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
48315
48484
|
dimColor: true,
|
|
48316
48485
|
children: [
|
|
48317
|
-
activeQueue.length,
|
|
48486
|
+
activeQueue.length + inlineCount,
|
|
48318
48487
|
" pending message",
|
|
48319
|
-
activeQueue.length > 1 ? "s" : "",
|
|
48488
|
+
activeQueue.length + inlineCount > 1 ? "s" : "",
|
|
48320
48489
|
inlineCount > 0 || queuedCount > 0 ? ` \xB7 ${inlineCount} in-stream \xB7 ${queuedCount} queued` : ""
|
|
48321
48490
|
]
|
|
48322
48491
|
}, undefined, true, undefined, this),
|
|
48323
|
-
activeQueue.slice(0, MAX_QUEUED_PREVIEW).map((queued) => /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
48492
|
+
[...activeInline, ...activeQueue].slice(0, MAX_QUEUED_PREVIEW).map((queued) => /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
48324
48493
|
marginLeft: 2,
|
|
48325
48494
|
children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
48326
48495
|
dimColor: true,
|
|
@@ -48331,11 +48500,11 @@ function App2({ cwd: cwd2, version }) {
|
|
|
48331
48500
|
]
|
|
48332
48501
|
}, undefined, true, undefined, this)
|
|
48333
48502
|
}, queued.id, false, undefined, this)),
|
|
48334
|
-
activeQueue.length > MAX_QUEUED_PREVIEW && /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
48503
|
+
activeQueue.length + inlineCount > MAX_QUEUED_PREVIEW && /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
48335
48504
|
dimColor: true,
|
|
48336
48505
|
children: [
|
|
48337
48506
|
" ... and ",
|
|
48338
|
-
activeQueue.length - MAX_QUEUED_PREVIEW,
|
|
48507
|
+
activeQueue.length + inlineCount - MAX_QUEUED_PREVIEW,
|
|
48339
48508
|
" more"
|
|
48340
48509
|
]
|
|
48341
48510
|
}, undefined, true, undefined, this)
|
|
@@ -48375,13 +48544,13 @@ function App2({ cwd: cwd2, version }) {
|
|
|
48375
48544
|
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Input, {
|
|
48376
48545
|
onSubmit: handleSubmit,
|
|
48377
48546
|
isProcessing,
|
|
48378
|
-
queueLength: activeQueue.length,
|
|
48547
|
+
queueLength: activeQueue.length + inlineCount,
|
|
48379
48548
|
skills
|
|
48380
48549
|
}, undefined, false, undefined, this),
|
|
48381
48550
|
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Status, {
|
|
48382
48551
|
isProcessing,
|
|
48383
48552
|
cwd: activeSession?.cwd || cwd2,
|
|
48384
|
-
queueLength: activeQueue.length,
|
|
48553
|
+
queueLength: activeQueue.length + inlineCount,
|
|
48385
48554
|
tokenUsage,
|
|
48386
48555
|
energyState,
|
|
48387
48556
|
voiceState,
|
|
@@ -48571,7 +48740,7 @@ function formatStreamEvent(chunk) {
|
|
|
48571
48740
|
|
|
48572
48741
|
// packages/terminal/src/index.tsx
|
|
48573
48742
|
var jsx_dev_runtime10 = __toESM(require_jsx_dev_runtime(), 1);
|
|
48574
|
-
var VERSION3 = "0.6.
|
|
48743
|
+
var VERSION3 = "0.6.22";
|
|
48575
48744
|
process.env.ASSISTANTS_VERSION ??= VERSION3;
|
|
48576
48745
|
function parseArgs(argv) {
|
|
48577
48746
|
const args = argv.slice(2);
|
|
@@ -48698,14 +48867,7 @@ Interactive Mode:
|
|
|
48698
48867
|
`);
|
|
48699
48868
|
process.exit(0);
|
|
48700
48869
|
}
|
|
48701
|
-
|
|
48702
|
-
const result = await migrateFromOldpal();
|
|
48703
|
-
if (!result.success && result.errors.length > 0) {
|
|
48704
|
-
console.error(`Migration warning: ${result.errors.join("; ")}`);
|
|
48705
|
-
}
|
|
48706
|
-
} catch (error) {
|
|
48707
|
-
console.error(`Migration warning: ${error instanceof Error ? error.message : String(error)}`);
|
|
48708
|
-
}
|
|
48870
|
+
migrateFromOldpal().catch(() => {});
|
|
48709
48871
|
if (options.print !== null) {
|
|
48710
48872
|
if (!options.print.trim()) {
|
|
48711
48873
|
console.error("Error: Prompt is required with -p/--print flag");
|
|
@@ -48735,4 +48897,4 @@ if (options.print !== null) {
|
|
|
48735
48897
|
});
|
|
48736
48898
|
}
|
|
48737
48899
|
|
|
48738
|
-
//# debugId=
|
|
48900
|
+
//# debugId=F27739426C3D43A464756E2164756E21
|