@hasna/assistants 0.6.20 → 0.6.21
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 +234 -98
- package/dist/index.js.map +7 -7
- 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**
|
|
@@ -42304,7 +42363,7 @@ async function createLLMClient(config) {
|
|
|
42304
42363
|
|
|
42305
42364
|
// packages/core/src/heartbeat/manager.ts
|
|
42306
42365
|
import { dirname as dirname5 } from "path";
|
|
42307
|
-
import { mkdirSync as
|
|
42366
|
+
import { mkdirSync as mkdirSync4 } from "fs";
|
|
42308
42367
|
import { readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
|
|
42309
42368
|
|
|
42310
42369
|
class HeartbeatManager {
|
|
@@ -42326,7 +42385,7 @@ class HeartbeatManager {
|
|
|
42326
42385
|
uptimeSeconds: 0
|
|
42327
42386
|
};
|
|
42328
42387
|
const dir = dirname5(config.persistPath);
|
|
42329
|
-
|
|
42388
|
+
mkdirSync4(dir, { recursive: true });
|
|
42330
42389
|
}
|
|
42331
42390
|
start(sessionId) {
|
|
42332
42391
|
if (this.intervalId)
|
|
@@ -42400,14 +42459,14 @@ class HeartbeatManager {
|
|
|
42400
42459
|
}
|
|
42401
42460
|
// packages/core/src/heartbeat/persistence.ts
|
|
42402
42461
|
import { dirname as dirname6 } from "path";
|
|
42403
|
-
import { mkdirSync as
|
|
42462
|
+
import { mkdirSync as mkdirSync5 } from "fs";
|
|
42404
42463
|
import { readFile as readFile5, writeFile as writeFile4, unlink as unlink3 } from "fs/promises";
|
|
42405
42464
|
|
|
42406
42465
|
class StatePersistence {
|
|
42407
42466
|
path;
|
|
42408
42467
|
constructor(path2) {
|
|
42409
42468
|
this.path = path2;
|
|
42410
|
-
|
|
42469
|
+
mkdirSync5(dirname6(path2), { recursive: true });
|
|
42411
42470
|
}
|
|
42412
42471
|
async save(state) {
|
|
42413
42472
|
try {
|
|
@@ -42627,14 +42686,14 @@ class EnergyManager {
|
|
|
42627
42686
|
}
|
|
42628
42687
|
// packages/core/src/energy/storage.ts
|
|
42629
42688
|
import { dirname as dirname7 } from "path";
|
|
42630
|
-
import { mkdirSync as
|
|
42689
|
+
import { mkdirSync as mkdirSync6 } from "fs";
|
|
42631
42690
|
import { readFile as readFile6, writeFile as writeFile5 } from "fs/promises";
|
|
42632
42691
|
|
|
42633
42692
|
class EnergyStorage {
|
|
42634
42693
|
path;
|
|
42635
42694
|
constructor(path2) {
|
|
42636
42695
|
this.path = path2;
|
|
42637
|
-
|
|
42696
|
+
mkdirSync6(dirname7(path2), { recursive: true });
|
|
42638
42697
|
}
|
|
42639
42698
|
async save(state) {
|
|
42640
42699
|
try {
|
|
@@ -42701,7 +42760,7 @@ function validateToolCalls(toolCalls, tools) {
|
|
|
42701
42760
|
}
|
|
42702
42761
|
|
|
42703
42762
|
// packages/core/src/voice/utils.ts
|
|
42704
|
-
import { existsSync as
|
|
42763
|
+
import { existsSync as existsSync9, readFileSync as readFileSync4 } from "fs";
|
|
42705
42764
|
import { homedir as homedir9 } from "os";
|
|
42706
42765
|
import { join as join13 } from "path";
|
|
42707
42766
|
import { spawnSync } from "child_process";
|
|
@@ -42709,10 +42768,10 @@ function loadApiKeyFromSecrets2(key) {
|
|
|
42709
42768
|
const envHome = process.env.HOME || process.env.USERPROFILE;
|
|
42710
42769
|
const homeDir = envHome && envHome.trim().length > 0 ? envHome : homedir9();
|
|
42711
42770
|
const secretsPath = join13(homeDir, ".secrets");
|
|
42712
|
-
if (!
|
|
42771
|
+
if (!existsSync9(secretsPath))
|
|
42713
42772
|
return;
|
|
42714
42773
|
try {
|
|
42715
|
-
const content =
|
|
42774
|
+
const content = readFileSync4(secretsPath, "utf-8");
|
|
42716
42775
|
const match = content.match(new RegExp(`export\\s+${key}\\s*=\\s*['"]?([^'"\\n]+)['"]?`));
|
|
42717
42776
|
return match?.[1];
|
|
42718
42777
|
} catch {
|
|
@@ -42783,7 +42842,7 @@ class SystemSTT {
|
|
|
42783
42842
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
42784
42843
|
import { tmpdir as tmpdir2 } from "os";
|
|
42785
42844
|
import { join as join14 } from "path";
|
|
42786
|
-
import { readFileSync as
|
|
42845
|
+
import { readFileSync as readFileSync5, unlinkSync as unlinkSync2 } from "fs";
|
|
42787
42846
|
class ElevenLabsTTS {
|
|
42788
42847
|
apiKey;
|
|
42789
42848
|
voiceId;
|
|
@@ -42899,7 +42958,7 @@ class SystemTTS {
|
|
|
42899
42958
|
if (result.status !== 0) {
|
|
42900
42959
|
throw new Error(`System TTS failed: ${result.stderr || "unknown error"}`);
|
|
42901
42960
|
}
|
|
42902
|
-
const audio =
|
|
42961
|
+
const audio = readFileSync5(output);
|
|
42903
42962
|
unlinkSync2(output);
|
|
42904
42963
|
return {
|
|
42905
42964
|
audio: audio.buffer.slice(audio.byteOffset, audio.byteOffset + audio.byteLength),
|
|
@@ -42921,7 +42980,7 @@ class SystemTTS {
|
|
|
42921
42980
|
if (result.status !== 0) {
|
|
42922
42981
|
throw new Error(`System TTS failed: ${result.stderr || "unknown error"}`);
|
|
42923
42982
|
}
|
|
42924
|
-
const audio =
|
|
42983
|
+
const audio = readFileSync5(output);
|
|
42925
42984
|
unlinkSync2(output);
|
|
42926
42985
|
return {
|
|
42927
42986
|
audio: audio.buffer.slice(audio.byteOffset, audio.byteOffset + audio.byteLength),
|
|
@@ -42936,14 +42995,14 @@ class SystemTTS {
|
|
|
42936
42995
|
import { spawn } from "child_process";
|
|
42937
42996
|
import { tmpdir as tmpdir3 } from "os";
|
|
42938
42997
|
import { join as join15 } from "path";
|
|
42939
|
-
import { unlink as unlink4, writeFileSync as
|
|
42998
|
+
import { unlink as unlink4, writeFileSync as writeFileSync5 } from "fs";
|
|
42940
42999
|
class AudioPlayer {
|
|
42941
43000
|
currentProcess = null;
|
|
42942
43001
|
playing = false;
|
|
42943
43002
|
async play(audio, options = {}) {
|
|
42944
43003
|
const format = options.format ?? "mp3";
|
|
42945
43004
|
const tempFile = join15(tmpdir3(), `assistants-audio-${Date.now()}.${format}`);
|
|
42946
|
-
|
|
43005
|
+
writeFileSync5(tempFile, Buffer.from(audio));
|
|
42947
43006
|
const player = this.resolvePlayer(format);
|
|
42948
43007
|
if (!player) {
|
|
42949
43008
|
throw new Error("No supported audio player found. Install afplay, ffplay, mpg123, or aplay.");
|
|
@@ -43011,7 +43070,7 @@ class AudioPlayer {
|
|
|
43011
43070
|
import { spawn as spawn2 } from "child_process";
|
|
43012
43071
|
import { tmpdir as tmpdir4 } from "os";
|
|
43013
43072
|
import { join as join16 } from "path";
|
|
43014
|
-
import { readFileSync as
|
|
43073
|
+
import { readFileSync as readFileSync6, unlink as unlink5 } from "fs";
|
|
43015
43074
|
class AudioRecorder {
|
|
43016
43075
|
currentProcess = null;
|
|
43017
43076
|
async record(options = {}) {
|
|
@@ -43041,7 +43100,7 @@ class AudioRecorder {
|
|
|
43041
43100
|
reject(error);
|
|
43042
43101
|
});
|
|
43043
43102
|
});
|
|
43044
|
-
const data =
|
|
43103
|
+
const data = readFileSync6(output);
|
|
43045
43104
|
unlink5(output, () => {});
|
|
43046
43105
|
return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
43047
43106
|
}
|
|
@@ -43213,13 +43272,13 @@ class VoiceManager {
|
|
|
43213
43272
|
}
|
|
43214
43273
|
// packages/core/src/identity/assistant-manager.ts
|
|
43215
43274
|
init_src();
|
|
43216
|
-
import { existsSync as
|
|
43275
|
+
import { existsSync as existsSync11 } from "fs";
|
|
43217
43276
|
import { mkdir as mkdir5, readFile as readFile8, writeFile as writeFile7, rm as rm2 } from "fs/promises";
|
|
43218
43277
|
import { join as join18 } from "path";
|
|
43219
43278
|
|
|
43220
43279
|
// packages/core/src/identity/identity-manager.ts
|
|
43221
43280
|
init_src();
|
|
43222
|
-
import { existsSync as
|
|
43281
|
+
import { existsSync as existsSync10 } from "fs";
|
|
43223
43282
|
import { mkdir as mkdir4, readFile as readFile7, writeFile as writeFile6, rm } from "fs/promises";
|
|
43224
43283
|
import { join as join17 } from "path";
|
|
43225
43284
|
var DEFAULT_PROFILE = {
|
|
@@ -43369,7 +43428,7 @@ class IdentityManager {
|
|
|
43369
43428
|
`);
|
|
43370
43429
|
}
|
|
43371
43430
|
async readIndex() {
|
|
43372
|
-
if (!
|
|
43431
|
+
if (!existsSync10(this.indexPath)) {
|
|
43373
43432
|
return { identities: [] };
|
|
43374
43433
|
}
|
|
43375
43434
|
try {
|
|
@@ -43394,7 +43453,7 @@ class IdentityManager {
|
|
|
43394
43453
|
}
|
|
43395
43454
|
async readIdentity(id) {
|
|
43396
43455
|
const path2 = this.identityPath(id);
|
|
43397
|
-
if (!
|
|
43456
|
+
if (!existsSync10(path2))
|
|
43398
43457
|
return null;
|
|
43399
43458
|
try {
|
|
43400
43459
|
const raw = await readFile7(path2, "utf-8");
|
|
@@ -43408,7 +43467,7 @@ class IdentityManager {
|
|
|
43408
43467
|
await writeFile6(this.identityPath(identity.id), JSON.stringify(identity, null, 2));
|
|
43409
43468
|
}
|
|
43410
43469
|
async readActive() {
|
|
43411
|
-
if (!
|
|
43470
|
+
if (!existsSync10(this.activePath))
|
|
43412
43471
|
return null;
|
|
43413
43472
|
try {
|
|
43414
43473
|
const raw = await readFile7(this.activePath, "utf-8");
|
|
@@ -43423,7 +43482,7 @@ class IdentityManager {
|
|
|
43423
43482
|
await writeFile6(this.activePath, JSON.stringify({ id }, null, 2));
|
|
43424
43483
|
}
|
|
43425
43484
|
async loadAssistant() {
|
|
43426
|
-
if (!
|
|
43485
|
+
if (!existsSync10(this.assistantConfigPath()))
|
|
43427
43486
|
return null;
|
|
43428
43487
|
try {
|
|
43429
43488
|
const raw = await readFile7(this.assistantConfigPath(), "utf-8");
|
|
@@ -43541,7 +43600,7 @@ class AssistantManager {
|
|
|
43541
43600
|
return new IdentityManager(assistantId, this.basePath);
|
|
43542
43601
|
}
|
|
43543
43602
|
async readIndex() {
|
|
43544
|
-
if (!
|
|
43603
|
+
if (!existsSync11(this.indexPath)) {
|
|
43545
43604
|
return { assistants: [] };
|
|
43546
43605
|
}
|
|
43547
43606
|
try {
|
|
@@ -43566,7 +43625,7 @@ class AssistantManager {
|
|
|
43566
43625
|
}
|
|
43567
43626
|
async readAssistant(id) {
|
|
43568
43627
|
const configPath = this.assistantConfigPath(id);
|
|
43569
|
-
if (!
|
|
43628
|
+
if (!existsSync11(configPath))
|
|
43570
43629
|
return null;
|
|
43571
43630
|
try {
|
|
43572
43631
|
const raw = await readFile8(configPath, "utf-8");
|
|
@@ -43581,7 +43640,7 @@ class AssistantManager {
|
|
|
43581
43640
|
await writeFile7(this.assistantConfigPath(assistant.id), JSON.stringify(assistant, null, 2));
|
|
43582
43641
|
}
|
|
43583
43642
|
async readActive() {
|
|
43584
|
-
if (!
|
|
43643
|
+
if (!existsSync11(this.activePath))
|
|
43585
43644
|
return null;
|
|
43586
43645
|
try {
|
|
43587
43646
|
const raw = await readFile8(this.activePath, "utf-8");
|
|
@@ -44675,7 +44734,7 @@ function parseErrorCode(message) {
|
|
|
44675
44734
|
// packages/core/src/memory/sessions.ts
|
|
44676
44735
|
init_src();
|
|
44677
44736
|
// packages/core/src/migration/migrate-to-assistants.ts
|
|
44678
|
-
import { existsSync as
|
|
44737
|
+
import { existsSync as existsSync12 } from "fs";
|
|
44679
44738
|
import { mkdir as mkdir6, readFile as readFile9, writeFile as writeFile8, rename, cp } from "fs/promises";
|
|
44680
44739
|
import { join as join20 } from "path";
|
|
44681
44740
|
import { homedir as homedir10 } from "os";
|
|
@@ -44684,14 +44743,14 @@ async function ensureDir(path2) {
|
|
|
44684
44743
|
await mkdir6(path2, { recursive: true });
|
|
44685
44744
|
}
|
|
44686
44745
|
async function copyIfExists(source, destination) {
|
|
44687
|
-
if (!
|
|
44746
|
+
if (!existsSync12(source))
|
|
44688
44747
|
return false;
|
|
44689
44748
|
await ensureDir(join20(destination, ".."));
|
|
44690
44749
|
await cp(source, destination, { recursive: true });
|
|
44691
44750
|
return true;
|
|
44692
44751
|
}
|
|
44693
44752
|
async function readJson(path2) {
|
|
44694
|
-
if (!
|
|
44753
|
+
if (!existsSync12(path2))
|
|
44695
44754
|
return null;
|
|
44696
44755
|
try {
|
|
44697
44756
|
const raw = await readFile9(path2, "utf-8");
|
|
@@ -44709,13 +44768,13 @@ async function migrateFromOldpal() {
|
|
|
44709
44768
|
const home = homedir10();
|
|
44710
44769
|
const oldPath = join20(home, ".oldpal");
|
|
44711
44770
|
const newPath = join20(home, ".assistants");
|
|
44712
|
-
if (!
|
|
44771
|
+
if (!existsSync12(oldPath)) {
|
|
44713
44772
|
result.success = true;
|
|
44714
44773
|
return result;
|
|
44715
44774
|
}
|
|
44716
|
-
if (
|
|
44775
|
+
if (existsSync12(newPath)) {
|
|
44717
44776
|
const marker = join20(newPath, "migration", MIGRATION_MARKER);
|
|
44718
|
-
if (
|
|
44777
|
+
if (existsSync12(marker)) {
|
|
44719
44778
|
result.success = true;
|
|
44720
44779
|
return result;
|
|
44721
44780
|
}
|
|
@@ -44783,7 +44842,7 @@ init_anthropic();
|
|
|
44783
44842
|
init_src();
|
|
44784
44843
|
|
|
44785
44844
|
// packages/core/src/logger.ts
|
|
44786
|
-
import { existsSync as
|
|
44845
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync7, appendFileSync, readdirSync as readdirSync3, readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "fs";
|
|
44787
44846
|
import { join as join21 } from "path";
|
|
44788
44847
|
class Logger {
|
|
44789
44848
|
logDir;
|
|
@@ -44797,8 +44856,8 @@ class Logger {
|
|
|
44797
44856
|
this.logFile = join21(this.logDir, `${date}.log`);
|
|
44798
44857
|
}
|
|
44799
44858
|
ensureDir(dir) {
|
|
44800
|
-
if (!
|
|
44801
|
-
|
|
44859
|
+
if (!existsSync13(dir)) {
|
|
44860
|
+
mkdirSync7(dir, { recursive: true });
|
|
44802
44861
|
}
|
|
44803
44862
|
}
|
|
44804
44863
|
write(level, message, data) {
|
|
@@ -44843,13 +44902,13 @@ class SessionStorage {
|
|
|
44843
44902
|
this.sessionFile = join21(this.sessionsDir, `${sessionId}.json`);
|
|
44844
44903
|
}
|
|
44845
44904
|
ensureDir(dir) {
|
|
44846
|
-
if (!
|
|
44847
|
-
|
|
44905
|
+
if (!existsSync13(dir)) {
|
|
44906
|
+
mkdirSync7(dir, { recursive: true });
|
|
44848
44907
|
}
|
|
44849
44908
|
}
|
|
44850
44909
|
save(data) {
|
|
44851
44910
|
try {
|
|
44852
|
-
|
|
44911
|
+
writeFileSync6(this.sessionFile, JSON.stringify(data, null, 2));
|
|
44853
44912
|
} catch {}
|
|
44854
44913
|
}
|
|
44855
44914
|
getSessionId() {
|
|
@@ -44857,9 +44916,9 @@ class SessionStorage {
|
|
|
44857
44916
|
}
|
|
44858
44917
|
load() {
|
|
44859
44918
|
try {
|
|
44860
|
-
if (!
|
|
44919
|
+
if (!existsSync13(this.sessionFile))
|
|
44861
44920
|
return null;
|
|
44862
|
-
return JSON.parse(
|
|
44921
|
+
return JSON.parse(readFileSync7(this.sessionFile, "utf-8"));
|
|
44863
44922
|
} catch {
|
|
44864
44923
|
return null;
|
|
44865
44924
|
}
|
|
@@ -44867,9 +44926,9 @@ class SessionStorage {
|
|
|
44867
44926
|
static getActiveAssistantId() {
|
|
44868
44927
|
try {
|
|
44869
44928
|
const activePath = join21(getConfigDir(), "active.json");
|
|
44870
|
-
if (!
|
|
44929
|
+
if (!existsSync13(activePath))
|
|
44871
44930
|
return null;
|
|
44872
|
-
const raw =
|
|
44931
|
+
const raw = readFileSync7(activePath, "utf-8");
|
|
44873
44932
|
const data = JSON.parse(raw);
|
|
44874
44933
|
return data.id || null;
|
|
44875
44934
|
} catch {
|
|
@@ -44881,7 +44940,7 @@ class SessionStorage {
|
|
|
44881
44940
|
const resolvedId = assistantId ?? SessionStorage.getActiveAssistantId();
|
|
44882
44941
|
if (resolvedId) {
|
|
44883
44942
|
const assistantDir = join21(root, "assistants", resolvedId, "sessions");
|
|
44884
|
-
if (
|
|
44943
|
+
if (existsSync13(assistantDir)) {
|
|
44885
44944
|
return assistantDir;
|
|
44886
44945
|
}
|
|
44887
44946
|
}
|
|
@@ -44889,7 +44948,7 @@ class SessionStorage {
|
|
|
44889
44948
|
}
|
|
44890
44949
|
static listSessions(assistantId) {
|
|
44891
44950
|
const sessionsDir = SessionStorage.resolveSessionsDir(assistantId);
|
|
44892
|
-
if (!
|
|
44951
|
+
if (!existsSync13(sessionsDir))
|
|
44893
44952
|
return [];
|
|
44894
44953
|
const sessions = [];
|
|
44895
44954
|
const files = readdirSync3(sessionsDir);
|
|
@@ -44899,7 +44958,7 @@ class SessionStorage {
|
|
|
44899
44958
|
try {
|
|
44900
44959
|
const filePath = join21(sessionsDir, file);
|
|
44901
44960
|
const stat = Bun.file(filePath);
|
|
44902
|
-
const content = JSON.parse(
|
|
44961
|
+
const content = JSON.parse(readFileSync7(filePath, "utf-8"));
|
|
44903
44962
|
sessions.push({
|
|
44904
44963
|
id: file.replace(".json", ""),
|
|
44905
44964
|
cwd: content.cwd,
|
|
@@ -44919,9 +44978,9 @@ class SessionStorage {
|
|
|
44919
44978
|
const sessionsDir = SessionStorage.resolveSessionsDir(assistantId);
|
|
44920
44979
|
const sessionFile = join21(sessionsDir, `${sessionId}.json`);
|
|
44921
44980
|
try {
|
|
44922
|
-
if (!
|
|
44981
|
+
if (!existsSync13(sessionFile))
|
|
44923
44982
|
return null;
|
|
44924
|
-
return JSON.parse(
|
|
44983
|
+
return JSON.parse(readFileSync7(sessionFile, "utf-8"));
|
|
44925
44984
|
} catch {
|
|
44926
44985
|
return null;
|
|
44927
44986
|
}
|
|
@@ -44942,8 +45001,8 @@ function initAssistantsDir() {
|
|
|
44942
45001
|
join21(baseDir, "migration")
|
|
44943
45002
|
];
|
|
44944
45003
|
for (const dir of dirs) {
|
|
44945
|
-
if (!
|
|
44946
|
-
|
|
45004
|
+
if (!existsSync13(dir)) {
|
|
45005
|
+
mkdirSync7(dir, { recursive: true });
|
|
44947
45006
|
}
|
|
44948
45007
|
}
|
|
44949
45008
|
}
|
|
@@ -46654,6 +46713,8 @@ function MessageBubble({ message, queuedMessageIds }) {
|
|
|
46654
46713
|
const chunkMatch = message.id.match(/::chunk-(\d+)$/);
|
|
46655
46714
|
const chunkIndex = chunkMatch ? Number(chunkMatch[1]) : -1;
|
|
46656
46715
|
const isContinuation = chunkIndex > 0;
|
|
46716
|
+
const content = message.content ?? "";
|
|
46717
|
+
const leadingBullet = !isContinuation && !startsWithListOrTable(content);
|
|
46657
46718
|
if (isSystem) {
|
|
46658
46719
|
return null;
|
|
46659
46720
|
}
|
|
@@ -46682,7 +46743,7 @@ function MessageBubble({ message, queuedMessageIds }) {
|
|
|
46682
46743
|
}
|
|
46683
46744
|
const toolCalls = message.toolCalls || [];
|
|
46684
46745
|
const toolResults = message.toolResults || [];
|
|
46685
|
-
const hasContent =
|
|
46746
|
+
const hasContent = content && content.trim();
|
|
46686
46747
|
return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
|
|
46687
46748
|
marginY: isContinuation ? 0 : 1,
|
|
46688
46749
|
flexDirection: "column",
|
|
@@ -46692,7 +46753,7 @@ function MessageBubble({ message, queuedMessageIds }) {
|
|
|
46692
46753
|
/* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Text, {
|
|
46693
46754
|
dimColor: true,
|
|
46694
46755
|
children: [
|
|
46695
|
-
isContinuation ? " " : "\u25CF ",
|
|
46756
|
+
isContinuation || !leadingBullet ? " " : "\u25CF ",
|
|
46696
46757
|
" "
|
|
46697
46758
|
]
|
|
46698
46759
|
}, undefined, true, undefined, this),
|
|
@@ -46715,6 +46776,23 @@ function MessageBubble({ message, queuedMessageIds }) {
|
|
|
46715
46776
|
]
|
|
46716
46777
|
}, undefined, true, undefined, this);
|
|
46717
46778
|
}
|
|
46779
|
+
function startsWithListOrTable(content) {
|
|
46780
|
+
const lines = content.split(`
|
|
46781
|
+
`);
|
|
46782
|
+
for (const line of lines) {
|
|
46783
|
+
const trimmed = line.trimStart();
|
|
46784
|
+
if (!trimmed)
|
|
46785
|
+
continue;
|
|
46786
|
+
if (/^[-*\u2022]\s+/.test(trimmed))
|
|
46787
|
+
return true;
|
|
46788
|
+
if (/^\d+\.\s+/.test(trimmed))
|
|
46789
|
+
return true;
|
|
46790
|
+
if (trimmed.startsWith("|"))
|
|
46791
|
+
return true;
|
|
46792
|
+
return false;
|
|
46793
|
+
}
|
|
46794
|
+
return false;
|
|
46795
|
+
}
|
|
46718
46796
|
function ToolCallPanel({
|
|
46719
46797
|
toolCalls,
|
|
46720
46798
|
toolResults
|
|
@@ -46735,7 +46813,7 @@ function ToolCallPanel({
|
|
|
46735
46813
|
borderStyle: "round",
|
|
46736
46814
|
borderColor,
|
|
46737
46815
|
paddingX: 1,
|
|
46738
|
-
width:
|
|
46816
|
+
width: "100%",
|
|
46739
46817
|
children: [
|
|
46740
46818
|
/* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
|
|
46741
46819
|
justifyContent: "space-between",
|
|
@@ -46868,7 +46946,7 @@ function getToolDisplayName(toolCall) {
|
|
|
46868
46946
|
return "image";
|
|
46869
46947
|
case "schedule":
|
|
46870
46948
|
return "schedule";
|
|
46871
|
-
case "
|
|
46949
|
+
case "submit_feedback":
|
|
46872
46950
|
return "feedback";
|
|
46873
46951
|
case "notion":
|
|
46874
46952
|
case "gmail":
|
|
@@ -46902,7 +46980,7 @@ function formatToolCall(toolCall) {
|
|
|
46902
46980
|
return `Searching: ${truncate(String(input.pattern || ""), 60)}`;
|
|
46903
46981
|
case "schedule":
|
|
46904
46982
|
return formatScheduleCall(input);
|
|
46905
|
-
case "
|
|
46983
|
+
case "submit_feedback":
|
|
46906
46984
|
return formatFeedbackCall(input);
|
|
46907
46985
|
case "notion":
|
|
46908
46986
|
return `Notion: ${truncate(String(input.command || input.action || ""), 60)}`;
|
|
@@ -46998,7 +47076,7 @@ function formatToolResultNicely(toolName, content, isError) {
|
|
|
46998
47076
|
switch (toolName) {
|
|
46999
47077
|
case "schedule":
|
|
47000
47078
|
return formatScheduleResult(content);
|
|
47001
|
-
case "
|
|
47079
|
+
case "submit_feedback":
|
|
47002
47080
|
return formatFeedbackResult(content);
|
|
47003
47081
|
case "read":
|
|
47004
47082
|
return formatReadResult(content);
|
|
@@ -47151,6 +47229,7 @@ function Status({
|
|
|
47151
47229
|
const sessionInfo = sessionIndex && sessionCount && sessionCount > 1 ? `${sessionIndex}/${sessionCount}` : "";
|
|
47152
47230
|
const bgIndicator = backgroundProcessingCount > 0 ? ` +${backgroundProcessingCount}` : "";
|
|
47153
47231
|
const voiceIcon = voiceState?.enabled ? voiceState.isListening ? "\uD83C\uDFA4" : voiceState.isSpeaking ? "\uD83D\uDD0A" : "\uD83C\uDF99" : "";
|
|
47232
|
+
const sessionLabel = sessionId ? `id ${sessionId}` : "";
|
|
47154
47233
|
return /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Box_default, {
|
|
47155
47234
|
marginTop: 1,
|
|
47156
47235
|
justifyContent: "space-between",
|
|
@@ -47193,6 +47272,13 @@ function Status({
|
|
|
47193
47272
|
" \xB7 ",
|
|
47194
47273
|
formatDuration2(elapsed)
|
|
47195
47274
|
]
|
|
47275
|
+
}, undefined, true, undefined, this),
|
|
47276
|
+
sessionLabel && /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
|
|
47277
|
+
dimColor: true,
|
|
47278
|
+
children: [
|
|
47279
|
+
contextInfo || isProcessing && processingStartTime || sessionInfo ? " \xB7 " : "",
|
|
47280
|
+
sessionLabel
|
|
47281
|
+
]
|
|
47196
47282
|
}, undefined, true, undefined, this)
|
|
47197
47283
|
]
|
|
47198
47284
|
}, undefined, true, undefined, this)
|
|
@@ -47531,6 +47617,14 @@ function parseErrorMessage(error) {
|
|
|
47531
47617
|
}
|
|
47532
47618
|
return { code, message, suggestion };
|
|
47533
47619
|
}
|
|
47620
|
+
function formatElapsedDuration(ms) {
|
|
47621
|
+
const totalSeconds = Math.max(0, Math.floor(ms / 1000));
|
|
47622
|
+
if (totalSeconds < 60)
|
|
47623
|
+
return `${totalSeconds}s`;
|
|
47624
|
+
const mins = Math.floor(totalSeconds / 60);
|
|
47625
|
+
const secs = totalSeconds % 60;
|
|
47626
|
+
return `${mins}m ${secs}s`;
|
|
47627
|
+
}
|
|
47534
47628
|
var MESSAGE_CHUNK_LINES = 12;
|
|
47535
47629
|
var MESSAGE_WRAP_CHARS = 120;
|
|
47536
47630
|
function wrapTextLines(text, wrapChars) {
|
|
@@ -47648,6 +47742,7 @@ function App2({ cwd: cwd2, version }) {
|
|
|
47648
47742
|
const [isProcessing, setIsProcessing] = import_react29.useState(false);
|
|
47649
47743
|
const [error, setError] = import_react29.useState(null);
|
|
47650
47744
|
const [messageQueue, setMessageQueue] = import_react29.useState([]);
|
|
47745
|
+
const [inlinePending, setInlinePending] = import_react29.useState([]);
|
|
47651
47746
|
const [activityLog, setActivityLog] = import_react29.useState([]);
|
|
47652
47747
|
const [tokenUsage, setTokenUsage] = import_react29.useState();
|
|
47653
47748
|
const [energyState, setEnergyState] = import_react29.useState();
|
|
@@ -47719,6 +47814,12 @@ function App2({ cwd: cwd2, version }) {
|
|
|
47719
47814
|
content = content ? `${content}
|
|
47720
47815
|
|
|
47721
47816
|
[error]` : "[error]";
|
|
47817
|
+
}
|
|
47818
|
+
if (processingStartTime) {
|
|
47819
|
+
const workedFor = formatElapsedDuration(Date.now() - processingStartTime);
|
|
47820
|
+
content = content ? `${content}
|
|
47821
|
+
|
|
47822
|
+
\u273B Worked for ${workedFor}` : `\u273B Worked for ${workedFor}`;
|
|
47722
47823
|
}
|
|
47723
47824
|
setMessages((prev) => [
|
|
47724
47825
|
...prev,
|
|
@@ -47732,7 +47833,7 @@ function App2({ cwd: cwd2, version }) {
|
|
|
47732
47833
|
}
|
|
47733
47834
|
]);
|
|
47734
47835
|
return true;
|
|
47735
|
-
}, [buildFullResponse]);
|
|
47836
|
+
}, [buildFullResponse, processingStartTime]);
|
|
47736
47837
|
const resetTurnState = import_react29.useCallback(() => {
|
|
47737
47838
|
setCurrentResponse("");
|
|
47738
47839
|
responseRef.current = "";
|
|
@@ -47801,6 +47902,21 @@ function App2({ cwd: cwd2, version }) {
|
|
|
47801
47902
|
setAutoScroll(true);
|
|
47802
47903
|
}, []);
|
|
47803
47904
|
const handleChunk = import_react29.useCallback((chunk) => {
|
|
47905
|
+
if (!isProcessingRef.current && (chunk.type === "text" || chunk.type === "tool_use" || chunk.type === "tool_result")) {
|
|
47906
|
+
const active = registryRef.current.getActiveSession();
|
|
47907
|
+
if (active) {
|
|
47908
|
+
registryRef.current.setProcessing(active.id, true);
|
|
47909
|
+
setIsProcessing(true);
|
|
47910
|
+
isProcessingRef.current = true;
|
|
47911
|
+
setProcessingStartTime(Date.now());
|
|
47912
|
+
setInlinePending((prev) => {
|
|
47913
|
+
const idx = prev.findIndex((msg) => msg.sessionId === active.id);
|
|
47914
|
+
if (idx === -1)
|
|
47915
|
+
return prev;
|
|
47916
|
+
return [...prev.slice(0, idx), ...prev.slice(idx + 1)];
|
|
47917
|
+
});
|
|
47918
|
+
}
|
|
47919
|
+
}
|
|
47804
47920
|
if (chunk.type === "text" && chunk.content) {
|
|
47805
47921
|
responseRef.current += chunk.content;
|
|
47806
47922
|
setCurrentResponse(responseRef.current);
|
|
@@ -47984,6 +48100,7 @@ function App2({ cwd: cwd2, version }) {
|
|
|
47984
48100
|
await activeSession2.client.send(nextMessage.content);
|
|
47985
48101
|
}, [activeSessionId]);
|
|
47986
48102
|
const activeQueue = activeSessionId ? messageQueue.filter((msg) => msg.sessionId === activeSessionId) : [];
|
|
48103
|
+
const activeInline = activeSessionId ? inlinePending.filter((msg) => msg.sessionId === activeSessionId) : [];
|
|
47987
48104
|
const queuedMessageIds = import_react29.useMemo(() => new Set(activeQueue.filter((msg) => msg.mode === "queued").map((msg) => msg.id)), [activeQueue]);
|
|
47988
48105
|
const wrapChars = columns ? Math.max(40, columns - 4) : MESSAGE_WRAP_CHARS;
|
|
47989
48106
|
const renderWidth = columns ? Math.max(20, columns - 2) : undefined;
|
|
@@ -48154,7 +48271,7 @@ function App2({ cwd: cwd2, version }) {
|
|
|
48154
48271
|
setShowSessionSelector(true);
|
|
48155
48272
|
return;
|
|
48156
48273
|
}
|
|
48157
|
-
if (mode === "queue"
|
|
48274
|
+
if (mode === "queue") {
|
|
48158
48275
|
if (!activeSessionId)
|
|
48159
48276
|
return;
|
|
48160
48277
|
const queuedId = generateId();
|
|
@@ -48165,7 +48282,7 @@ function App2({ cwd: cwd2, version }) {
|
|
|
48165
48282
|
sessionId: activeSessionId,
|
|
48166
48283
|
content: trimmedInput,
|
|
48167
48284
|
queuedAt: now(),
|
|
48168
|
-
mode:
|
|
48285
|
+
mode: "queued"
|
|
48169
48286
|
}
|
|
48170
48287
|
]);
|
|
48171
48288
|
setMessages((prev) => [
|
|
@@ -48179,6 +48296,32 @@ function App2({ cwd: cwd2, version }) {
|
|
|
48179
48296
|
]);
|
|
48180
48297
|
return;
|
|
48181
48298
|
}
|
|
48299
|
+
if (mode === "inline") {
|
|
48300
|
+
if (!activeSessionId)
|
|
48301
|
+
return;
|
|
48302
|
+
const inlineId = generateId();
|
|
48303
|
+
setInlinePending((prev) => [
|
|
48304
|
+
...prev,
|
|
48305
|
+
{
|
|
48306
|
+
id: inlineId,
|
|
48307
|
+
sessionId: activeSessionId,
|
|
48308
|
+
content: trimmedInput,
|
|
48309
|
+
queuedAt: now(),
|
|
48310
|
+
mode: "inline"
|
|
48311
|
+
}
|
|
48312
|
+
]);
|
|
48313
|
+
setMessages((prev) => [
|
|
48314
|
+
...prev,
|
|
48315
|
+
{
|
|
48316
|
+
id: inlineId,
|
|
48317
|
+
role: "user",
|
|
48318
|
+
content: trimmedInput,
|
|
48319
|
+
timestamp: now()
|
|
48320
|
+
}
|
|
48321
|
+
]);
|
|
48322
|
+
await activeSession.client.send(trimmedInput);
|
|
48323
|
+
return;
|
|
48324
|
+
}
|
|
48182
48325
|
if (mode === "interrupt" && isProcessing) {
|
|
48183
48326
|
activeSession.client.stop();
|
|
48184
48327
|
const finalized = finalizeResponse("interrupted");
|
|
@@ -48263,7 +48406,7 @@ function App2({ cwd: cwd2, version }) {
|
|
|
48263
48406
|
return text.slice(0, maxLen - 3) + "...";
|
|
48264
48407
|
};
|
|
48265
48408
|
const queuedCount = activeQueue.filter((msg) => msg.mode === "queued").length;
|
|
48266
|
-
const inlineCount =
|
|
48409
|
+
const inlineCount = activeInline.length;
|
|
48267
48410
|
const showWelcome = messages.length === 0 && !isProcessing;
|
|
48268
48411
|
return /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
48269
48412
|
flexDirection: "column",
|
|
@@ -48307,20 +48450,20 @@ function App2({ cwd: cwd2, version }) {
|
|
|
48307
48450
|
scrollOffsetLines: scrollOffset,
|
|
48308
48451
|
maxVisibleLines
|
|
48309
48452
|
}, activeSessionId || "default", false, undefined, this),
|
|
48310
|
-
activeQueue.length > 0 && /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
48453
|
+
(activeQueue.length > 0 || inlineCount > 0) && /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
48311
48454
|
marginY: 1,
|
|
48312
48455
|
flexDirection: "column",
|
|
48313
48456
|
children: [
|
|
48314
48457
|
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
48315
48458
|
dimColor: true,
|
|
48316
48459
|
children: [
|
|
48317
|
-
activeQueue.length,
|
|
48460
|
+
activeQueue.length + inlineCount,
|
|
48318
48461
|
" pending message",
|
|
48319
|
-
activeQueue.length > 1 ? "s" : "",
|
|
48462
|
+
activeQueue.length + inlineCount > 1 ? "s" : "",
|
|
48320
48463
|
inlineCount > 0 || queuedCount > 0 ? ` \xB7 ${inlineCount} in-stream \xB7 ${queuedCount} queued` : ""
|
|
48321
48464
|
]
|
|
48322
48465
|
}, undefined, true, undefined, this),
|
|
48323
|
-
activeQueue.slice(0, MAX_QUEUED_PREVIEW).map((queued) => /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
48466
|
+
[...activeInline, ...activeQueue].slice(0, MAX_QUEUED_PREVIEW).map((queued) => /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
48324
48467
|
marginLeft: 2,
|
|
48325
48468
|
children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
48326
48469
|
dimColor: true,
|
|
@@ -48331,11 +48474,11 @@ function App2({ cwd: cwd2, version }) {
|
|
|
48331
48474
|
]
|
|
48332
48475
|
}, undefined, true, undefined, this)
|
|
48333
48476
|
}, queued.id, false, undefined, this)),
|
|
48334
|
-
activeQueue.length > MAX_QUEUED_PREVIEW && /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
48477
|
+
activeQueue.length + inlineCount > MAX_QUEUED_PREVIEW && /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
48335
48478
|
dimColor: true,
|
|
48336
48479
|
children: [
|
|
48337
48480
|
" ... and ",
|
|
48338
|
-
activeQueue.length - MAX_QUEUED_PREVIEW,
|
|
48481
|
+
activeQueue.length + inlineCount - MAX_QUEUED_PREVIEW,
|
|
48339
48482
|
" more"
|
|
48340
48483
|
]
|
|
48341
48484
|
}, undefined, true, undefined, this)
|
|
@@ -48375,13 +48518,13 @@ function App2({ cwd: cwd2, version }) {
|
|
|
48375
48518
|
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Input, {
|
|
48376
48519
|
onSubmit: handleSubmit,
|
|
48377
48520
|
isProcessing,
|
|
48378
|
-
queueLength: activeQueue.length,
|
|
48521
|
+
queueLength: activeQueue.length + inlineCount,
|
|
48379
48522
|
skills
|
|
48380
48523
|
}, undefined, false, undefined, this),
|
|
48381
48524
|
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Status, {
|
|
48382
48525
|
isProcessing,
|
|
48383
48526
|
cwd: activeSession?.cwd || cwd2,
|
|
48384
|
-
queueLength: activeQueue.length,
|
|
48527
|
+
queueLength: activeQueue.length + inlineCount,
|
|
48385
48528
|
tokenUsage,
|
|
48386
48529
|
energyState,
|
|
48387
48530
|
voiceState,
|
|
@@ -48571,7 +48714,7 @@ function formatStreamEvent(chunk) {
|
|
|
48571
48714
|
|
|
48572
48715
|
// packages/terminal/src/index.tsx
|
|
48573
48716
|
var jsx_dev_runtime10 = __toESM(require_jsx_dev_runtime(), 1);
|
|
48574
|
-
var VERSION3 = "0.6.
|
|
48717
|
+
var VERSION3 = "0.6.21";
|
|
48575
48718
|
process.env.ASSISTANTS_VERSION ??= VERSION3;
|
|
48576
48719
|
function parseArgs(argv) {
|
|
48577
48720
|
const args = argv.slice(2);
|
|
@@ -48698,14 +48841,7 @@ Interactive Mode:
|
|
|
48698
48841
|
`);
|
|
48699
48842
|
process.exit(0);
|
|
48700
48843
|
}
|
|
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
|
-
}
|
|
48844
|
+
migrateFromOldpal().catch(() => {});
|
|
48709
48845
|
if (options.print !== null) {
|
|
48710
48846
|
if (!options.print.trim()) {
|
|
48711
48847
|
console.error("Error: Prompt is required with -p/--print flag");
|
|
@@ -48735,4 +48871,4 @@ if (options.print !== null) {
|
|
|
48735
48871
|
});
|
|
48736
48872
|
}
|
|
48737
48873
|
|
|
48738
|
-
//# debugId=
|
|
48874
|
+
//# debugId=9F87F41E551C4D1964756E2164756E21
|