@letta-ai/letta-code 0.30.15 → 0.30.17
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/channels-slack.js +232 -34
- package/dist/channels-slack.js.map +7 -5
- package/dist/mcp-client.js +2 -2
- package/dist/mcp-client.js.map +1 -1
- package/dist/types/agent/message.d.ts +2 -0
- package/dist/types/agent/message.d.ts.map +1 -1
- package/dist/types/channels/slack/ingress-policy.d.ts +2 -1
- package/dist/types/channels/slack/ingress-policy.d.ts.map +1 -1
- package/dist/types/channels/slack/model-picker-blocks.d.ts +10 -0
- package/dist/types/channels/slack/model-picker-blocks.d.ts.map +1 -0
- package/dist/types/channels/slack/utils.d.ts +0 -1
- package/dist/types/channels/slack/utils.d.ts.map +1 -1
- package/dist/types/channels-slack.d.ts +1 -0
- package/dist/types/channels-slack.d.ts.map +1 -1
- package/dist/types/mods/mod-engine.d.ts.map +1 -1
- package/dist/types/mods/turn-start-input.d.ts +5 -0
- package/dist/types/mods/turn-start-input.d.ts.map +1 -0
- package/dist/types/tools/impl/monitor.d.ts.map +1 -1
- package/dist/types/tools/impl/worktree-git.d.ts.map +1 -1
- package/dist/types/types/runtime-scope.d.ts +2 -0
- package/dist/types/types/runtime-scope.d.ts.map +1 -1
- package/dist/types/websocket/listener/protocol-outbound.d.ts +1 -2
- package/dist/types/websocket/listener/protocol-outbound.d.ts.map +1 -1
- package/dist/types/websocket/listener/runtime.d.ts.map +1 -1
- package/dist/types/websocket/listener/scope.d.ts +1 -0
- package/dist/types/websocket/listener/scope.d.ts.map +1 -1
- package/dist/types/websocket/listener/turn-lifecycle.d.ts +3 -0
- package/dist/types/websocket/listener/turn-lifecycle.d.ts.map +1 -1
- package/dist/types/websocket/listener/types.d.ts +4 -0
- package/dist/types/websocket/listener/types.d.ts.map +1 -1
- package/letta.js +307 -213
- package/package.json +1 -1
- package/scripts/isolated-unit-tests.json +22 -0
- package/scripts/source-file-size-baseline.json +2 -2
package/letta.js
CHANGED
|
@@ -5488,7 +5488,7 @@ var package_default;
|
|
|
5488
5488
|
var init_package = __esm(() => {
|
|
5489
5489
|
package_default = {
|
|
5490
5490
|
name: "@letta-ai/letta-code",
|
|
5491
|
-
version: "0.30.
|
|
5491
|
+
version: "0.30.17",
|
|
5492
5492
|
description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
|
|
5493
5493
|
type: "module",
|
|
5494
5494
|
packageManager: "bun@1.3.0",
|
|
@@ -152619,7 +152619,8 @@ function resolveRuntimeScope(runtime, params) {
|
|
|
152619
152619
|
const resolvedConversationId = resolveScopedConversationId(runtime, params);
|
|
152620
152620
|
return {
|
|
152621
152621
|
agent_id: resolvedAgentId,
|
|
152622
|
-
conversation_id: resolvedConversationId
|
|
152622
|
+
conversation_id: resolvedConversationId,
|
|
152623
|
+
...params?.super_run_id ? { super_run_id: params.super_run_id } : {}
|
|
152623
152624
|
};
|
|
152624
152625
|
}
|
|
152625
152626
|
|
|
@@ -152754,6 +152755,7 @@ class TurnLifecycle {
|
|
|
152754
152755
|
#createId;
|
|
152755
152756
|
#state = IDLE_STATE;
|
|
152756
152757
|
#lastStopReason = null;
|
|
152758
|
+
#superRunOwner = null;
|
|
152757
152759
|
constructor(createId = () => crypto.randomUUID()) {
|
|
152758
152760
|
this.#createId = createId;
|
|
152759
152761
|
}
|
|
@@ -152775,6 +152777,9 @@ class TurnLifecycle {
|
|
|
152775
152777
|
get activeRunId() {
|
|
152776
152778
|
return this.#state.kind === "active" ? this.#state.runId : null;
|
|
152777
152779
|
}
|
|
152780
|
+
get superRunId() {
|
|
152781
|
+
return this.#superRunOwner?.superRunId ?? null;
|
|
152782
|
+
}
|
|
152778
152783
|
get executingToolCallIds() {
|
|
152779
152784
|
return this.#state.kind === "active" || this.#state.kind === "cancelling" ? this.#state.executingToolCallIds : [];
|
|
152780
152785
|
}
|
|
@@ -152824,6 +152829,10 @@ class TurnLifecycle {
|
|
|
152824
152829
|
id: this.#createId(),
|
|
152825
152830
|
signal: abortController.signal
|
|
152826
152831
|
});
|
|
152832
|
+
this.#superRunOwner = {
|
|
152833
|
+
leaseId: lease.id,
|
|
152834
|
+
superRunId: options3.superRunId ?? null
|
|
152835
|
+
};
|
|
152827
152836
|
this.#state = {
|
|
152828
152837
|
kind: "active",
|
|
152829
152838
|
origin: options3.origin,
|
|
@@ -152850,6 +152859,13 @@ class TurnLifecycle {
|
|
|
152850
152859
|
this.#state = { ...this.#state, loopStatus: status };
|
|
152851
152860
|
return true;
|
|
152852
152861
|
}
|
|
152862
|
+
releaseSuperRunId(lease) {
|
|
152863
|
+
if (this.#superRunOwner?.leaseId !== lease.id) {
|
|
152864
|
+
return false;
|
|
152865
|
+
}
|
|
152866
|
+
this.#superRunOwner = null;
|
|
152867
|
+
return true;
|
|
152868
|
+
}
|
|
152853
152869
|
setRunId(lease, runId) {
|
|
152854
152870
|
if (this.#state.kind !== "active" || !this.isCurrent(lease)) {
|
|
152855
152871
|
return false;
|
|
@@ -152881,6 +152897,7 @@ class TurnLifecycle {
|
|
|
152881
152897
|
if (this.#state.kind !== "idle") {
|
|
152882
152898
|
return false;
|
|
152883
152899
|
}
|
|
152900
|
+
this.#superRunOwner = null;
|
|
152884
152901
|
this.#state = {
|
|
152885
152902
|
kind: "command",
|
|
152886
152903
|
loopStatus: "EXECUTING_COMMAND"
|
|
@@ -152971,6 +152988,7 @@ class TurnLifecycle {
|
|
|
152971
152988
|
}
|
|
152972
152989
|
reset(stopReason = "cancelled") {
|
|
152973
152990
|
const state = this.#state;
|
|
152991
|
+
this.#superRunOwner = null;
|
|
152974
152992
|
if (state.kind === "active" || state.kind === "cancelling") {
|
|
152975
152993
|
if (!state.abortController.signal.aborted) {
|
|
152976
152994
|
state.abortController.abort();
|
|
@@ -153141,6 +153159,9 @@ function createConversationRuntime(listener, agentId, conversationId) {
|
|
|
153141
153159
|
key: runtimeKey,
|
|
153142
153160
|
agentId: normalizedAgentId,
|
|
153143
153161
|
conversationId: normalizedConversationId,
|
|
153162
|
+
get superRunId() {
|
|
153163
|
+
return turnLifecycle.superRunId;
|
|
153164
|
+
},
|
|
153144
153165
|
skillSources: listener.skillSourcesByConversation.get(runtimeKey)?.slice(),
|
|
153145
153166
|
activeConnectionId: null,
|
|
153146
153167
|
turnLifecycle,
|
|
@@ -157592,7 +157613,8 @@ function getScopeForRuntime(runtime, scope) {
|
|
|
157592
157613
|
if (runtime && "listener" in runtime) {
|
|
157593
157614
|
return {
|
|
157594
157615
|
agent_id: scope?.agent_id ?? runtime.agentId,
|
|
157595
|
-
conversation_id: scope?.conversation_id ?? runtime.conversationId
|
|
157616
|
+
conversation_id: scope?.conversation_id ?? runtime.conversationId,
|
|
157617
|
+
super_run_id: scope?.super_run_id ?? runtime.superRunId ?? undefined
|
|
157596
157618
|
};
|
|
157597
157619
|
}
|
|
157598
157620
|
return scope ?? {};
|
|
@@ -157757,7 +157779,7 @@ function emitProtocolV2Message(socket, runtime, message, scope, routing) {
|
|
|
157757
157779
|
typeLabel: message.type,
|
|
157758
157780
|
frameClass,
|
|
157759
157781
|
...frameClass === "status" ? {
|
|
157760
|
-
coalesceKey: `${message.type}:${runtimeScope.agent_id ?? ""}:${runtimeScope.conversation_id ?? ""}`
|
|
157782
|
+
coalesceKey: `${message.type}:${runtimeScope.agent_id ?? ""}:${runtimeScope.conversation_id ?? ""}:${runtimeScope.super_run_id ?? ""}`
|
|
157761
157783
|
} : {},
|
|
157762
157784
|
build: () => {
|
|
157763
157785
|
const eventSeq = nextListenerConnectionEventSeq(connection, listener);
|
|
@@ -158483,11 +158505,13 @@ async function gitRefExists(cwd, ref6) {
|
|
|
158483
158505
|
return result.exitCode === 0;
|
|
158484
158506
|
}
|
|
158485
158507
|
async function resolveRepoRoot(cwd) {
|
|
158486
|
-
|
|
158508
|
+
const repoRoot = await gitStdout(["rev-parse", "--show-toplevel"], cwd);
|
|
158509
|
+
return path16.resolve(repoRoot);
|
|
158487
158510
|
}
|
|
158488
158511
|
async function resolvePrimaryWorktreeRoot(repoRoot) {
|
|
158489
158512
|
const commonDir = await gitStdout(["rev-parse", "--path-format=absolute", "--git-common-dir"], repoRoot);
|
|
158490
|
-
|
|
158513
|
+
const primaryRoot = path16.basename(commonDir) === ".git" ? path16.dirname(commonDir) : repoRoot;
|
|
158514
|
+
return path16.resolve(primaryRoot);
|
|
158491
158515
|
}
|
|
158492
158516
|
async function resolveDefaultBaseRef(repoRoot) {
|
|
158493
158517
|
const remoteHead = await runGit2(["symbolic-ref", "--quiet", "--short", "refs/remotes/origin/HEAD"], repoRoot, { allowFailure: true });
|
|
@@ -162985,7 +163009,7 @@ var init_monitor_event_stream = __esm(() => {
|
|
|
162985
163009
|
});
|
|
162986
163010
|
|
|
162987
163011
|
// src/tools/impl/monitor.ts
|
|
162988
|
-
import { appendFileSync as appendFileSync4 } from "node:fs";
|
|
163012
|
+
import { appendFileSync as appendFileSync4, readFileSync as readFileSync9, writeFileSync as writeFileSync8 } from "node:fs";
|
|
162989
163013
|
import { WebSocket as WebSocket4 } from "ws";
|
|
162990
163014
|
function buildMonitorResult(taskId, timeoutMs, persistent) {
|
|
162991
163015
|
const lifetime = persistent ? "persistent — runs until TaskStop or session end" : `timeout ${timeoutMs}ms`;
|
|
@@ -163033,11 +163057,10 @@ class MonitorOutputWriter {
|
|
|
163033
163057
|
const marker = Buffer.from(`
|
|
163034
163058
|
[output truncated at ${MONITOR_OUTPUT_FILE_BYTES} bytes]
|
|
163035
163059
|
`, "utf8");
|
|
163036
|
-
const
|
|
163037
|
-
const
|
|
163038
|
-
|
|
163039
|
-
|
|
163040
|
-
this.bytesWritten = MONITOR_OUTPUT_FILE_BYTES;
|
|
163060
|
+
const content = validUtf8Prefix(Buffer.concat([readFileSync9(this.path), chunk]), MONITOR_OUTPUT_FILE_BYTES - marker.length);
|
|
163061
|
+
const truncatedOutput = Buffer.concat([content, marker]);
|
|
163062
|
+
writeFileSync8(this.path, truncatedOutput);
|
|
163063
|
+
this.bytesWritten = truncatedOutput.length;
|
|
163041
163064
|
this.truncated = true;
|
|
163042
163065
|
}
|
|
163043
163066
|
}
|
|
@@ -163666,12 +163689,12 @@ __export(exports_image_resize_magick, {
|
|
|
163666
163689
|
resizeImageIfNeeded: () => resizeImageIfNeeded
|
|
163667
163690
|
});
|
|
163668
163691
|
import { execSync } from "node:child_process";
|
|
163669
|
-
import { readFileSync as
|
|
163692
|
+
import { readFileSync as readFileSync10, unlinkSync as unlinkSync4, writeFileSync as writeFileSync9 } from "node:fs";
|
|
163670
163693
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
163671
163694
|
import { join as join21 } from "node:path";
|
|
163672
163695
|
async function getImageDimensions(buffer) {
|
|
163673
163696
|
const tempInput = join21(tmpdir4(), `image-${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`);
|
|
163674
|
-
|
|
163697
|
+
writeFileSync9(tempInput, buffer);
|
|
163675
163698
|
try {
|
|
163676
163699
|
const output = execSync(`magick identify -format "%w %h %m" "${tempInput}"`, {
|
|
163677
163700
|
encoding: "utf-8"
|
|
@@ -163702,7 +163725,7 @@ async function compressToFitByteLimit(buffer, currentWidth, currentHeight) {
|
|
|
163702
163725
|
return null;
|
|
163703
163726
|
}
|
|
163704
163727
|
const tempInput = join21(tmpdir4(), `compress-input-${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`);
|
|
163705
|
-
|
|
163728
|
+
writeFileSync9(tempInput, buffer);
|
|
163706
163729
|
try {
|
|
163707
163730
|
const qualities = [85, 70, 55, 40];
|
|
163708
163731
|
for (const quality of qualities) {
|
|
@@ -163711,7 +163734,7 @@ async function compressToFitByteLimit(buffer, currentWidth, currentHeight) {
|
|
|
163711
163734
|
execSync(`magick "${tempInput}" -quality ${quality} "${tempOutput}"`, {
|
|
163712
163735
|
stdio: "ignore"
|
|
163713
163736
|
});
|
|
163714
|
-
const compressed =
|
|
163737
|
+
const compressed = readFileSync10(tempOutput);
|
|
163715
163738
|
if (compressed.length <= MAX_IMAGE_BYTES) {
|
|
163716
163739
|
return buildVerifiedResizeResult(compressed, "image/jpeg", true, "compressed image output");
|
|
163717
163740
|
}
|
|
@@ -163730,7 +163753,7 @@ async function compressToFitByteLimit(buffer, currentWidth, currentHeight) {
|
|
|
163730
163753
|
execSync(`magick "${tempInput}" -resize ${scaledWidth}x${scaledHeight} -quality 70 "${tempOutput}"`, {
|
|
163731
163754
|
stdio: "ignore"
|
|
163732
163755
|
});
|
|
163733
|
-
const reduced =
|
|
163756
|
+
const reduced = readFileSync10(tempOutput);
|
|
163734
163757
|
if (reduced.length <= MAX_IMAGE_BYTES) {
|
|
163735
163758
|
return buildVerifiedResizeResult(reduced, "image/jpeg", true, "dimension-reduced image output");
|
|
163736
163759
|
}
|
|
@@ -163757,7 +163780,7 @@ async function resizeImageIfNeeded(buffer, inputMediaType) {
|
|
|
163757
163780
|
return buildVerifiedResizeResult(buffer, inputMediaType, false, "passthrough image output");
|
|
163758
163781
|
}
|
|
163759
163782
|
const tempInput = join21(tmpdir4(), `resize-input-${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`);
|
|
163760
|
-
|
|
163783
|
+
writeFileSync9(tempInput, buffer);
|
|
163761
163784
|
try {
|
|
163762
163785
|
if (needsResize) {
|
|
163763
163786
|
const tempOutput2 = join21(tmpdir4(), `resize-output-${Date.now()}-${Math.random().toString(36).slice(2)}`);
|
|
@@ -163767,14 +163790,14 @@ async function resizeImageIfNeeded(buffer, inputMediaType) {
|
|
|
163767
163790
|
execSync(`magick "${tempInput}" -resize ${MAX_IMAGE_WIDTH}x${MAX_IMAGE_HEIGHT}> -quality 85 "${tempOutput2}.jpg"`, {
|
|
163768
163791
|
stdio: "ignore"
|
|
163769
163792
|
});
|
|
163770
|
-
outputBuffer2 =
|
|
163793
|
+
outputBuffer2 = readFileSync10(`${tempOutput2}.jpg`);
|
|
163771
163794
|
outputMediaType = "image/jpeg";
|
|
163772
163795
|
unlinkSync4(`${tempOutput2}.jpg`);
|
|
163773
163796
|
} else {
|
|
163774
163797
|
execSync(`magick "${tempInput}" -resize ${MAX_IMAGE_WIDTH}x${MAX_IMAGE_HEIGHT}> "${tempOutput2}.png"`, {
|
|
163775
163798
|
stdio: "ignore"
|
|
163776
163799
|
});
|
|
163777
|
-
outputBuffer2 =
|
|
163800
|
+
outputBuffer2 = readFileSync10(`${tempOutput2}.png`);
|
|
163778
163801
|
outputMediaType = "image/png";
|
|
163779
163802
|
unlinkSync4(`${tempOutput2}.png`);
|
|
163780
163803
|
}
|
|
@@ -163789,7 +163812,7 @@ async function resizeImageIfNeeded(buffer, inputMediaType) {
|
|
|
163789
163812
|
execSync(`magick "${tempInput}" "${tempOutput}"`, {
|
|
163790
163813
|
stdio: "ignore"
|
|
163791
163814
|
});
|
|
163792
|
-
const outputBuffer =
|
|
163815
|
+
const outputBuffer = readFileSync10(tempOutput);
|
|
163793
163816
|
unlinkSync4(tempOutput);
|
|
163794
163817
|
const compressed = await compressToFitByteLimit(outputBuffer, width, height);
|
|
163795
163818
|
if (compressed) {
|
|
@@ -179795,7 +179818,7 @@ __export(exports_loader, {
|
|
|
179795
179818
|
getUserSettingsPaths: () => getUserSettingsPaths
|
|
179796
179819
|
});
|
|
179797
179820
|
import { createHash as createHash3 } from "node:crypto";
|
|
179798
|
-
import { readFileSync as
|
|
179821
|
+
import { readFileSync as readFileSync11, statSync as statSync5, watch as watch2 } from "node:fs";
|
|
179799
179822
|
import { homedir as homedir17 } from "node:os";
|
|
179800
179823
|
import { dirname as dirname17, join as join26, resolve as resolve23 } from "node:path";
|
|
179801
179824
|
function getUserSettingsPaths(options3 = {}) {
|
|
@@ -179825,7 +179848,7 @@ function getFileSignature(path30) {
|
|
|
179825
179848
|
exists: true,
|
|
179826
179849
|
mtimeMs: stat10.mtimeMs,
|
|
179827
179850
|
size: stat10.size,
|
|
179828
|
-
hash: createHash3("sha256").update(
|
|
179851
|
+
hash: createHash3("sha256").update(readFileSync11(path30)).digest("hex")
|
|
179829
179852
|
};
|
|
179830
179853
|
} catch {
|
|
179831
179854
|
return { exists: false };
|
|
@@ -181452,6 +181475,9 @@ async function sendMessageStreamWithBackend(backend, conversationId, messages, o
|
|
|
181452
181475
|
if (opts.actingUserId) {
|
|
181453
181476
|
extraHeaders["X-Letta-Acting-User-Id"] = opts.actingUserId;
|
|
181454
181477
|
}
|
|
181478
|
+
if (opts.superRunId) {
|
|
181479
|
+
extraHeaders["X-Letta-Super-Run-Id"] = opts.superRunId;
|
|
181480
|
+
}
|
|
181455
181481
|
const messageSummary = normalizedMessages.map((item) => {
|
|
181456
181482
|
if (item.type === "approval") {
|
|
181457
181483
|
return `approval:${item.approvals?.length ?? 0}`;
|
|
@@ -184056,7 +184082,7 @@ var init_memory_git_config_lock = __esm(() => {
|
|
|
184056
184082
|
});
|
|
184057
184083
|
|
|
184058
184084
|
// src/agent/memory-git-hooks.ts
|
|
184059
|
-
import { chmodSync as chmodSync4, existsSync as existsSync21, mkdirSync as mkdirSync14, writeFileSync as
|
|
184085
|
+
import { chmodSync as chmodSync4, existsSync as existsSync21, mkdirSync as mkdirSync14, writeFileSync as writeFileSync10 } from "node:fs";
|
|
184060
184086
|
import { join as join29 } from "node:path";
|
|
184061
184087
|
function installPreCommitHook(dir) {
|
|
184062
184088
|
const hooksDir = join29(dir, ".git", "hooks");
|
|
@@ -184064,7 +184090,7 @@ function installPreCommitHook(dir) {
|
|
|
184064
184090
|
if (!existsSync21(hooksDir)) {
|
|
184065
184091
|
mkdirSync14(hooksDir, { recursive: true });
|
|
184066
184092
|
}
|
|
184067
|
-
|
|
184093
|
+
writeFileSync10(hookPath, PRE_COMMIT_HOOK_SCRIPT, "utf-8");
|
|
184068
184094
|
chmodSync4(hookPath, 493);
|
|
184069
184095
|
debugLog("memfs-git", "Installed pre-commit hook");
|
|
184070
184096
|
}
|
|
@@ -184074,7 +184100,7 @@ function installPostCommitHook(dir) {
|
|
|
184074
184100
|
if (!existsSync21(hooksDir)) {
|
|
184075
184101
|
mkdirSync14(hooksDir, { recursive: true });
|
|
184076
184102
|
}
|
|
184077
|
-
|
|
184103
|
+
writeFileSync10(hookPath, POST_COMMIT_HOOK_SCRIPT, "utf-8");
|
|
184078
184104
|
chmodSync4(hookPath, 493);
|
|
184079
184105
|
debugLog("memfs-git", "Installed post-commit memory-repository hook");
|
|
184080
184106
|
}
|
|
@@ -184295,10 +184321,10 @@ import { execFile as execFileCb2 } from "node:child_process";
|
|
|
184295
184321
|
import {
|
|
184296
184322
|
existsSync as existsSync22,
|
|
184297
184323
|
mkdirSync as mkdirSync15,
|
|
184298
|
-
readFileSync as
|
|
184324
|
+
readFileSync as readFileSync12,
|
|
184299
184325
|
renameSync as renameSync3,
|
|
184300
184326
|
rmSync as rmSync4,
|
|
184301
|
-
writeFileSync as
|
|
184327
|
+
writeFileSync as writeFileSync11
|
|
184302
184328
|
} from "node:fs";
|
|
184303
184329
|
import { homedir as homedir20, platform as platform3 } from "node:os";
|
|
184304
184330
|
import { dirname as dirname19, isAbsolute as isAbsolute20, join as join30 } from "node:path";
|
|
@@ -184651,7 +184677,7 @@ async function configureLocalCredentialHelper(dir, token) {
|
|
|
184651
184677
|
echo username=letta
|
|
184652
184678
|
echo password=${token}
|
|
184653
184679
|
`;
|
|
184654
|
-
|
|
184680
|
+
writeFileSync11(helperScriptPath, batchScript, "utf-8");
|
|
184655
184681
|
helper = formatGitCredentialHelperPath(helperScriptPath);
|
|
184656
184682
|
debugLog("memfs-git", `Wrote Windows credential helper script`);
|
|
184657
184683
|
} else {
|
|
@@ -184832,7 +184858,7 @@ function readMemoryRepositoryPushLog(agentId, tailLines = 20) {
|
|
|
184832
184858
|
return "";
|
|
184833
184859
|
}
|
|
184834
184860
|
try {
|
|
184835
|
-
const content =
|
|
184861
|
+
const content = readFileSync12(logPath, "utf-8");
|
|
184836
184862
|
const lines = content.split(`
|
|
184837
184863
|
`);
|
|
184838
184864
|
return lines.slice(-tailLines).join(`
|
|
@@ -185002,7 +185028,7 @@ function describeMarkdownEncodingIssue(memoryDir, relativePath) {
|
|
|
185002
185028
|
if (!existsSync22(filePath)) {
|
|
185003
185029
|
return null;
|
|
185004
185030
|
}
|
|
185005
|
-
const bytes =
|
|
185031
|
+
const bytes = readFileSync12(filePath);
|
|
185006
185032
|
const utf16Bom = getUtf16Bom(bytes);
|
|
185007
185033
|
if (utf16Bom) {
|
|
185008
185034
|
return `${relativePath} has ${utf16Bom} BOM`;
|
|
@@ -185080,7 +185106,7 @@ async function initializeLocalMemoryRepo(params) {
|
|
|
185080
185106
|
}
|
|
185081
185107
|
const fullPath = join30(params.memoryDir, relativePath);
|
|
185082
185108
|
mkdirSync15(dirname19(fullPath), { recursive: true });
|
|
185083
|
-
|
|
185109
|
+
writeFileSync11(fullPath, file3.content, "utf8");
|
|
185084
185110
|
pathspecs.push(relativePath);
|
|
185085
185111
|
}
|
|
185086
185112
|
if (pathspecs.length > 0) {
|
|
@@ -186179,11 +186205,11 @@ import {
|
|
|
186179
186205
|
mkdirSync as mkdirSync16,
|
|
186180
186206
|
openSync,
|
|
186181
186207
|
readdirSync as readdirSync9,
|
|
186182
|
-
readFileSync as
|
|
186208
|
+
readFileSync as readFileSync13,
|
|
186183
186209
|
readSync,
|
|
186184
186210
|
rmSync as rmSync5,
|
|
186185
186211
|
statSync as statSync7,
|
|
186186
|
-
writeFileSync as
|
|
186212
|
+
writeFileSync as writeFileSync12
|
|
186187
186213
|
} from "node:fs";
|
|
186188
186214
|
import { join as join31 } from "node:path";
|
|
186189
186215
|
function isStringArray3(value) {
|
|
@@ -186363,12 +186389,12 @@ function jsonl(items3) {
|
|
|
186363
186389
|
function readJsonFile2(path30) {
|
|
186364
186390
|
if (!existsSync23(path30))
|
|
186365
186391
|
return;
|
|
186366
|
-
return JSON.parse(
|
|
186392
|
+
return JSON.parse(readFileSync13(path30, "utf8"));
|
|
186367
186393
|
}
|
|
186368
186394
|
function readJsonlFile(path30) {
|
|
186369
186395
|
if (!existsSync23(path30))
|
|
186370
186396
|
return [];
|
|
186371
|
-
return
|
|
186397
|
+
return readFileSync13(path30, "utf8").split(`
|
|
186372
186398
|
`).filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
|
|
186373
186399
|
}
|
|
186374
186400
|
function readJsonlFileSuffix(path30, maxBytes) {
|
|
@@ -186546,7 +186572,7 @@ function validateLocalTranscriptManifest(conversationDir, storageDir) {
|
|
|
186546
186572
|
return manifest;
|
|
186547
186573
|
}
|
|
186548
186574
|
function writeLocalTranscriptManifest(conversationDir, manifest = createLocalTranscriptManifest()) {
|
|
186549
|
-
|
|
186575
|
+
writeFileSync12(transcriptManifestPath(conversationDir), `${JSON.stringify(manifest, null, 2)}
|
|
186550
186576
|
`);
|
|
186551
186577
|
}
|
|
186552
186578
|
function numericSuffix(value, prefix) {
|
|
@@ -187969,7 +187995,7 @@ class LocalStore {
|
|
|
187969
187995
|
return;
|
|
187970
187996
|
const agentsDir = join31(this.storageDir, "agents");
|
|
187971
187997
|
mkdirSync16(agentsDir, { recursive: true });
|
|
187972
|
-
|
|
187998
|
+
writeFileSync12(join31(agentsDir, `${encodePathSegment(agentId)}.json`), `${JSON.stringify(agent2, null, 2)}
|
|
187973
187999
|
`);
|
|
187974
188000
|
this.recordAgentRecordMtime(agentId);
|
|
187975
188001
|
}
|
|
@@ -188032,7 +188058,7 @@ class LocalStore {
|
|
|
188032
188058
|
return;
|
|
188033
188059
|
const conversationDir = join31(this.storageDir, "conversations", encodePathSegment(key));
|
|
188034
188060
|
mkdirSync16(conversationDir, { recursive: true });
|
|
188035
|
-
|
|
188061
|
+
writeFileSync12(join31(conversationDir, "conversation.json"), `${JSON.stringify(conversation, null, 2)}
|
|
188036
188062
|
`);
|
|
188037
188063
|
this.recordConversationRecordMtime(key, conversationDir);
|
|
188038
188064
|
const messagesPath = transcriptMessagesPath(conversationDir);
|
|
@@ -188103,7 +188129,7 @@ class LocalStore {
|
|
|
188103
188129
|
if (messages.length === 0)
|
|
188104
188130
|
return;
|
|
188105
188131
|
const entries = localTranscriptSessionEntries(conversation, messages);
|
|
188106
|
-
|
|
188132
|
+
writeFileSync12(messagesPath, jsonl(entries));
|
|
188107
188133
|
this.resetPersistedSessionStateFromEntries(key, entries);
|
|
188108
188134
|
}
|
|
188109
188135
|
appendConversationSessionMessageEntry(key, conversation, messagesPath, message) {
|
|
@@ -188155,7 +188181,7 @@ class LocalStore {
|
|
|
188155
188181
|
ensureConversationTranscriptHeader(conversation, messagesPath) {
|
|
188156
188182
|
if (existsSync23(messagesPath) && statSync7(messagesPath).size > 0)
|
|
188157
188183
|
return;
|
|
188158
|
-
|
|
188184
|
+
writeFileSync12(messagesPath, `${JSON.stringify(createLocalTranscriptSessionHeader(conversation))}
|
|
188159
188185
|
`);
|
|
188160
188186
|
}
|
|
188161
188187
|
resetPersistedSessionState(key, messageFormat, transcript) {
|
|
@@ -188214,7 +188240,7 @@ class LocalStore {
|
|
|
188214
188240
|
return;
|
|
188215
188241
|
const conversationDir = join31(this.storageDir, "conversations", encodePathSegment(key));
|
|
188216
188242
|
mkdirSync16(conversationDir, { recursive: true });
|
|
188217
|
-
|
|
188243
|
+
writeFileSync12(join31(conversationDir, "system-prompt.json"), `${JSON.stringify(prompt, null, 2)}
|
|
188218
188244
|
`);
|
|
188219
188245
|
}
|
|
188220
188246
|
ensureConversation(conversationId, agentId) {
|
|
@@ -195026,7 +195052,7 @@ __export(exports_personality, {
|
|
|
195026
195052
|
applyPersonalityToMemory: () => applyPersonalityToMemory
|
|
195027
195053
|
});
|
|
195028
195054
|
import { execFile as execFileCb3 } from "node:child_process";
|
|
195029
|
-
import { existsSync as existsSync25, mkdirSync as mkdirSync17, readFileSync as
|
|
195055
|
+
import { existsSync as existsSync25, mkdirSync as mkdirSync17, readFileSync as readFileSync14, writeFileSync as writeFileSync13 } from "node:fs";
|
|
195030
195056
|
import { dirname as dirname21, join as join32 } from "node:path";
|
|
195031
195057
|
import { promisify as promisify6 } from "node:util";
|
|
195032
195058
|
function ensureTrailingNewline2(content) {
|
|
@@ -195160,7 +195186,7 @@ async function getMemoryCommitAuthor(agentId) {
|
|
|
195160
195186
|
function applyPersonalityFiles(filesToUpdate) {
|
|
195161
195187
|
const changedPaths = [];
|
|
195162
195188
|
for (const file3 of filesToUpdate) {
|
|
195163
|
-
const existingContent = existsSync25(file3.absolutePath) ?
|
|
195189
|
+
const existingContent = existsSync25(file3.absolutePath) ? readFileSync14(file3.absolutePath, "utf-8") : null;
|
|
195164
195190
|
const nextContent = existingContent ? replaceBodyPreservingFrontmatter(existingContent, file3.content, {
|
|
195165
195191
|
description: file3.description
|
|
195166
195192
|
}) : buildDefaultMemoryFile(file3.templatePromptAssetName, file3.content, file3.description);
|
|
@@ -195168,7 +195194,7 @@ function applyPersonalityFiles(filesToUpdate) {
|
|
|
195168
195194
|
continue;
|
|
195169
195195
|
}
|
|
195170
195196
|
mkdirSync17(dirname21(file3.absolutePath), { recursive: true });
|
|
195171
|
-
|
|
195197
|
+
writeFileSync13(file3.absolutePath, nextContent, "utf-8");
|
|
195172
195198
|
changedPaths.push(file3.relativePath);
|
|
195173
195199
|
}
|
|
195174
195200
|
return changedPaths;
|
|
@@ -232339,7 +232365,7 @@ var init_paste_registry = __esm(() => {
|
|
|
232339
232365
|
|
|
232340
232366
|
// src/cli/helpers/clipboard.ts
|
|
232341
232367
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
232342
|
-
import { existsSync as existsSync27, readFileSync as
|
|
232368
|
+
import { existsSync as existsSync27, readFileSync as readFileSync16, statSync as statSync8, unlinkSync as unlinkSync5 } from "node:fs";
|
|
232343
232369
|
import { tmpdir as tmpdir6 } from "node:os";
|
|
232344
232370
|
import { basename as basename9, extname as extname4, isAbsolute as isAbsolute21, join as join33, resolve as resolve28 } from "node:path";
|
|
232345
232371
|
function countLines(text2) {
|
|
@@ -232398,14 +232424,14 @@ function translatePasteForImages(paste) {
|
|
|
232398
232424
|
try {
|
|
232399
232425
|
const stat10 = statSync8(filePath);
|
|
232400
232426
|
if (stat10.isFile())
|
|
232401
|
-
buf =
|
|
232427
|
+
buf = readFileSync16(filePath);
|
|
232402
232428
|
} catch {}
|
|
232403
232429
|
let clipboardMediaType = null;
|
|
232404
232430
|
if (!buf && process.platform === "darwin" && /TemporaryItems\/.*screencaptureui/i.test(filePath)) {
|
|
232405
232431
|
const clipResult = getClipboardImageToTempFile();
|
|
232406
232432
|
if (clipResult) {
|
|
232407
232433
|
try {
|
|
232408
|
-
buf =
|
|
232434
|
+
buf = readFileSync16(clipResult.tempPath);
|
|
232409
232435
|
clipboardMediaType = UTI_TO_MEDIA_TYPE[clipResult.uti] || null;
|
|
232410
232436
|
try {
|
|
232411
232437
|
unlinkSync5(clipResult.tempPath);
|
|
@@ -232474,7 +232500,7 @@ async function tryImportClipboardImageMac() {
|
|
|
232474
232500
|
return null;
|
|
232475
232501
|
const { tempPath, uti } = clipboardResult;
|
|
232476
232502
|
try {
|
|
232477
|
-
const buffer =
|
|
232503
|
+
const buffer = readFileSync16(tempPath);
|
|
232478
232504
|
try {
|
|
232479
232505
|
unlinkSync5(tempPath);
|
|
232480
232506
|
} catch {}
|
|
@@ -234421,7 +234447,7 @@ var init_local = __esm(() => {
|
|
|
234421
234447
|
});
|
|
234422
234448
|
|
|
234423
234449
|
// src/cli/helpers/local-agent-listing.ts
|
|
234424
|
-
import { existsSync as existsSync29, readdirSync as readdirSync11, readFileSync as
|
|
234450
|
+
import { existsSync as existsSync29, readdirSync as readdirSync11, readFileSync as readFileSync17, statSync as statSync10 } from "node:fs";
|
|
234425
234451
|
import { join as join35 } from "node:path";
|
|
234426
234452
|
function listLocalAgentsFromDisk() {
|
|
234427
234453
|
const storageDir = getLocalBackendStorageDir();
|
|
@@ -234433,7 +234459,7 @@ function listLocalAgentsFromDisk() {
|
|
|
234433
234459
|
for (const file3 of files) {
|
|
234434
234460
|
try {
|
|
234435
234461
|
const filePath = join35(agentsDir, file3);
|
|
234436
|
-
const raw2 =
|
|
234462
|
+
const raw2 = readFileSync17(filePath, "utf8");
|
|
234437
234463
|
const record5 = JSON.parse(raw2);
|
|
234438
234464
|
if (isHiddenLocalAgentRecord(record5))
|
|
234439
234465
|
continue;
|
|
@@ -236291,7 +236317,7 @@ function shouldAcceptSlackInboundBotMessage(params) {
|
|
|
236291
236317
|
}
|
|
236292
236318
|
|
|
236293
236319
|
// src/channels/config.ts
|
|
236294
|
-
import { existsSync as existsSync30, readFileSync as
|
|
236320
|
+
import { existsSync as existsSync30, readFileSync as readFileSync18 } from "node:fs";
|
|
236295
236321
|
import { homedir as homedir24 } from "node:os";
|
|
236296
236322
|
import { join as join36 } from "node:path";
|
|
236297
236323
|
function parseWhatsAppWaitingBehavior(value) {
|
|
@@ -236395,7 +236421,7 @@ function readChannelConfig(channelId) {
|
|
|
236395
236421
|
if (!existsSync30(configPath))
|
|
236396
236422
|
return null;
|
|
236397
236423
|
try {
|
|
236398
|
-
const text2 =
|
|
236424
|
+
const text2 = readFileSync18(configPath, "utf-8");
|
|
236399
236425
|
const parsed = parseSimpleYaml(text2);
|
|
236400
236426
|
const codec3 = getChannelConfigCodec(channelId);
|
|
236401
236427
|
if (!codec3)
|
|
@@ -236676,7 +236702,7 @@ __export(exports_accounts, {
|
|
|
236676
236702
|
__testOverrideLoadChannelAccounts: () => __testOverrideLoadChannelAccounts,
|
|
236677
236703
|
LEGACY_CHANNEL_ACCOUNT_ID: () => LEGACY_CHANNEL_ACCOUNT_ID
|
|
236678
236704
|
});
|
|
236679
|
-
import { existsSync as existsSync31, mkdirSync as mkdirSync19, readFileSync as
|
|
236705
|
+
import { existsSync as existsSync31, mkdirSync as mkdirSync19, readFileSync as readFileSync19, writeFileSync as writeFileSync14 } from "node:fs";
|
|
236680
236706
|
function isSecretPlaceholder(value) {
|
|
236681
236707
|
return value === SECRET_PRESENT_PLACEHOLDER;
|
|
236682
236708
|
}
|
|
@@ -237031,7 +237057,7 @@ function loadChannelAccounts(channelId) {
|
|
|
237031
237057
|
const path30 = getChannelAccountsPath(channelId);
|
|
237032
237058
|
if (existsSync31(path30)) {
|
|
237033
237059
|
try {
|
|
237034
|
-
const text2 =
|
|
237060
|
+
const text2 = readFileSync19(path30, "utf-8");
|
|
237035
237061
|
const parsed = JSON.parse(text2);
|
|
237036
237062
|
stores.set(channelId, {
|
|
237037
237063
|
accounts: (parsed.accounts ?? []).map((account) => {
|
|
@@ -237084,7 +237110,7 @@ function saveChannelAccounts(channelId) {
|
|
|
237084
237110
|
}
|
|
237085
237111
|
const dir = getChannelDir(channelId);
|
|
237086
237112
|
mkdirSync19(dir, { recursive: true });
|
|
237087
|
-
|
|
237113
|
+
writeFileSync14(getChannelAccountsPath(channelId), `${JSON.stringify({ accounts: writeAccounts }, null, 2)}
|
|
237088
237114
|
`, "utf-8");
|
|
237089
237115
|
}
|
|
237090
237116
|
async function flushPendingChannelSecretWrites() {
|
|
@@ -237241,7 +237267,7 @@ __export(exports_pairing, {
|
|
|
237241
237267
|
__testOverrideLoadPairingStore: () => __testOverrideLoadPairingStore
|
|
237242
237268
|
});
|
|
237243
237269
|
import { randomInt } from "node:crypto";
|
|
237244
|
-
import { existsSync as existsSync32, mkdirSync as mkdirSync20, readFileSync as
|
|
237270
|
+
import { existsSync as existsSync32, mkdirSync as mkdirSync20, readFileSync as readFileSync20, writeFileSync as writeFileSync15 } from "node:fs";
|
|
237245
237271
|
function normalizeAccountId(accountId) {
|
|
237246
237272
|
return accountId ?? LEGACY_CHANNEL_ACCOUNT_ID;
|
|
237247
237273
|
}
|
|
@@ -237269,7 +237295,7 @@ function loadPairingStore(channelId) {
|
|
|
237269
237295
|
if (!existsSync32(path30))
|
|
237270
237296
|
return;
|
|
237271
237297
|
try {
|
|
237272
|
-
const text2 =
|
|
237298
|
+
const text2 = readFileSync20(path30, "utf-8");
|
|
237273
237299
|
const parsed = JSON.parse(text2);
|
|
237274
237300
|
stores2.set(channelId, {
|
|
237275
237301
|
pending: parsed.pending ?? [],
|
|
@@ -237288,7 +237314,7 @@ function savePairingStore(channelId) {
|
|
|
237288
237314
|
}
|
|
237289
237315
|
const dir = getChannelDir(channelId);
|
|
237290
237316
|
mkdirSync20(dir, { recursive: true });
|
|
237291
|
-
|
|
237317
|
+
writeFileSync15(getChannelPairingPath(channelId), `${JSON.stringify(store2, null, 2)}
|
|
237292
237318
|
`, "utf-8");
|
|
237293
237319
|
}
|
|
237294
237320
|
function generateCode(length = 6) {
|
|
@@ -238664,7 +238690,7 @@ __export(exports_transcription, {
|
|
|
238664
238690
|
isTranscriptionConfigured: () => isTranscriptionConfigured
|
|
238665
238691
|
});
|
|
238666
238692
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
238667
|
-
import { mkdtempSync as mkdtempSync2, readFileSync as
|
|
238693
|
+
import { mkdtempSync as mkdtempSync2, readFileSync as readFileSync21, rmSync as rmSync7 } from "node:fs";
|
|
238668
238694
|
import { tmpdir as tmpdir7 } from "node:os";
|
|
238669
238695
|
import { basename as basename12, extname as extname5, join as join39 } from "node:path";
|
|
238670
238696
|
function audioMimeTypeForPath(localPath) {
|
|
@@ -238731,7 +238757,7 @@ async function transcribeAudioFile(localPath) {
|
|
|
238731
238757
|
try {
|
|
238732
238758
|
const prepared = prepareOpenAiTranscriptionFile(localPath);
|
|
238733
238759
|
try {
|
|
238734
|
-
const buffer =
|
|
238760
|
+
const buffer = readFileSync21(prepared.localPath);
|
|
238735
238761
|
const filename = basename12(prepared.localPath);
|
|
238736
238762
|
const formData = new FormData;
|
|
238737
238763
|
const blob = new Blob([buffer], {
|
|
@@ -241115,11 +241141,6 @@ function getSlackActionRecord(action3, body3) {
|
|
|
241115
241141
|
const actions = asRecord2(body3)?.actions;
|
|
241116
241142
|
return Array.isArray(actions) ? asRecord2(actions[0]) : null;
|
|
241117
241143
|
}
|
|
241118
|
-
function resolveSlackSelectedModel(action3, body3) {
|
|
241119
|
-
const actionRecord = getSlackActionRecord(action3, body3);
|
|
241120
|
-
const selectedOption = asRecord2(actionRecord?.selected_option);
|
|
241121
|
-
return firstNonEmptyString(selectedOption?.value, actionRecord?.value) ?? null;
|
|
241122
|
-
}
|
|
241123
241144
|
function resolveSlackActionChannelId(body3) {
|
|
241124
241145
|
const bodyRecord = asRecord2(body3);
|
|
241125
241146
|
const channel = asRecord2(bodyRecord?.channel);
|
|
@@ -241707,6 +241728,11 @@ var init_command_runtime_executor = __esm(() => {
|
|
|
241707
241728
|
});
|
|
241708
241729
|
|
|
241709
241730
|
// src/channels/slack/model-picker-blocks.ts
|
|
241731
|
+
function resolveSlackSelectedModel(action3, body3) {
|
|
241732
|
+
const actionRecord = getSlackActionRecord(action3, body3);
|
|
241733
|
+
const selectedOption = asRecord2(actionRecord?.selected_option);
|
|
241734
|
+
return firstNonEmptyString(selectedOption?.value, actionRecord?.value) ?? null;
|
|
241735
|
+
}
|
|
241710
241736
|
function escapeSlackMrkdwn(text2) {
|
|
241711
241737
|
return text2.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
241712
241738
|
}
|
|
@@ -241824,6 +241850,7 @@ Handle: ${escapeSlackMrkdwn(params.current.modelHandle)}` : "";
|
|
|
241824
241850
|
var SLACK_MODEL_PICKER_OPTION_LIMIT = 100, SLACK_MODEL_OPTION_TEXT_LIMIT = 75, SLACK_MODEL_OPTION_VALUE_LIMIT = 75, SLACK_MODEL_SELECT_ACTION_ID = "letta_channel_model_select";
|
|
241825
241851
|
var init_model_picker_blocks = __esm(() => {
|
|
241826
241852
|
init_command_runtime_executor();
|
|
241853
|
+
init_utils6();
|
|
241827
241854
|
});
|
|
241828
241855
|
|
|
241829
241856
|
// src/channels/slack/agent-thread-tracker.ts
|
|
@@ -244515,6 +244542,9 @@ function resolveSlackMessageIngressPolicy(params) {
|
|
|
244515
244542
|
}
|
|
244516
244543
|
const rawText = isNonEmptyString5(message.text) ? message.text : "";
|
|
244517
244544
|
const wasMentioned = hasSlackMention2(rawText, params.botUserId);
|
|
244545
|
+
if (chatType === "channel" && wasMentioned && params.appMentionEventWillHandleMentions === true) {
|
|
244546
|
+
return { shouldRoute: false, reason: "handled_by_app_mention" };
|
|
244547
|
+
}
|
|
244518
244548
|
const isAgentThread = params.isAgentThread === true;
|
|
244519
244549
|
const effectiveMention = isBotAuthoredMessage(message) ? wasMentioned : wasMentioned || isAgentThread;
|
|
244520
244550
|
return {
|
|
@@ -244731,7 +244761,8 @@ function createSlackIngressController(params) {
|
|
|
244731
244761
|
}
|
|
244732
244762
|
const basePolicy = resolveSlackMessageIngressPolicy({
|
|
244733
244763
|
message: rawMessage,
|
|
244734
|
-
botUserId: params.getBotUserId()
|
|
244764
|
+
botUserId: params.getBotUserId(),
|
|
244765
|
+
appMentionEventWillHandleMentions: true
|
|
244735
244766
|
});
|
|
244736
244767
|
if (!basePolicy.shouldRoute)
|
|
244737
244768
|
return;
|
|
@@ -244755,7 +244786,8 @@ function createSlackIngressController(params) {
|
|
|
244755
244786
|
const policy = resolveSlackMessageIngressPolicy({
|
|
244756
244787
|
message: rawMessage,
|
|
244757
244788
|
botUserId: params.getBotUserId(),
|
|
244758
|
-
isAgentThread
|
|
244789
|
+
isAgentThread,
|
|
244790
|
+
appMentionEventWillHandleMentions: true
|
|
244759
244791
|
});
|
|
244760
244792
|
if (!policy.shouldRoute)
|
|
244761
244793
|
return;
|
|
@@ -245835,7 +245867,7 @@ function createSlackMessageActionAdapter(options3 = {}) {
|
|
|
245835
245867
|
}
|
|
245836
245868
|
|
|
245837
245869
|
// src/channels/targets.ts
|
|
245838
|
-
import { existsSync as existsSync34, mkdirSync as mkdirSync21, readFileSync as
|
|
245870
|
+
import { existsSync as existsSync34, mkdirSync as mkdirSync21, readFileSync as readFileSync22, writeFileSync as writeFileSync16 } from "node:fs";
|
|
245839
245871
|
function getStore3(channelId) {
|
|
245840
245872
|
let store2 = stores3.get(channelId);
|
|
245841
245873
|
if (!store2) {
|
|
@@ -245854,7 +245886,7 @@ function loadTargetStore(channelId) {
|
|
|
245854
245886
|
return;
|
|
245855
245887
|
}
|
|
245856
245888
|
try {
|
|
245857
|
-
const text2 =
|
|
245889
|
+
const text2 = readFileSync22(path30, "utf-8");
|
|
245858
245890
|
const parsed = JSON.parse(text2);
|
|
245859
245891
|
stores3.set(channelId, {
|
|
245860
245892
|
targets: parsed.targets ?? []
|
|
@@ -245868,7 +245900,7 @@ function saveTargetStore(channelId) {
|
|
|
245868
245900
|
}
|
|
245869
245901
|
const dir = getChannelDir(channelId);
|
|
245870
245902
|
mkdirSync21(dir, { recursive: true });
|
|
245871
|
-
|
|
245903
|
+
writeFileSync16(getChannelTargetsPath(channelId), `${JSON.stringify(getStore3(channelId), null, 2)}
|
|
245872
245904
|
`, "utf-8");
|
|
245873
245905
|
}
|
|
245874
245906
|
function listChannelTargets(channelId, accountId) {
|
|
@@ -248559,16 +248591,16 @@ import {
|
|
|
248559
248591
|
closeSync as closeSync2,
|
|
248560
248592
|
mkdirSync as mkdirSync23,
|
|
248561
248593
|
openSync as openSync2,
|
|
248562
|
-
readFileSync as
|
|
248594
|
+
readFileSync as readFileSync23,
|
|
248563
248595
|
renameSync as renameSync5,
|
|
248564
248596
|
unlinkSync as unlinkSync6,
|
|
248565
|
-
writeFileSync as
|
|
248597
|
+
writeFileSync as writeFileSync17
|
|
248566
248598
|
} from "node:fs";
|
|
248567
248599
|
import { dirname as dirname23, isAbsolute as isAbsolute23 } from "node:path";
|
|
248568
248600
|
function parseStoreFile(filePath) {
|
|
248569
248601
|
let rawText;
|
|
248570
248602
|
try {
|
|
248571
|
-
rawText =
|
|
248603
|
+
rawText = readFileSync23(filePath, "utf8");
|
|
248572
248604
|
} catch {
|
|
248573
248605
|
return new Map;
|
|
248574
248606
|
}
|
|
@@ -248655,7 +248687,7 @@ function createLidStore(filePath) {
|
|
|
248655
248687
|
let fd = null;
|
|
248656
248688
|
try {
|
|
248657
248689
|
fd = openSync2(tmpPath, "wx", 384);
|
|
248658
|
-
|
|
248690
|
+
writeFileSync17(fd, data, "utf8");
|
|
248659
248691
|
closeSync2(fd);
|
|
248660
248692
|
fd = null;
|
|
248661
248693
|
renameSync5(tmpPath, filePath);
|
|
@@ -248982,7 +249014,7 @@ var init_state = __esm(() => {
|
|
|
248982
249014
|
});
|
|
248983
249015
|
|
|
248984
249016
|
// src/channels/whatsapp/session.ts
|
|
248985
|
-
import { mkdirSync as mkdirSync24, readFileSync as
|
|
249017
|
+
import { mkdirSync as mkdirSync24, readFileSync as readFileSync24, rmSync as rmSync8, writeFileSync as writeFileSync18 } from "node:fs";
|
|
248986
249018
|
import { homedir as homedir25 } from "node:os";
|
|
248987
249019
|
import { join as join44 } from "node:path";
|
|
248988
249020
|
function shouldDropLine(line) {
|
|
@@ -249056,7 +249088,7 @@ function defaultIsProcessAlive(pid) {
|
|
|
249056
249088
|
}
|
|
249057
249089
|
function readLeaseOwner(lockDir) {
|
|
249058
249090
|
try {
|
|
249059
|
-
const owner = JSON.parse(
|
|
249091
|
+
const owner = JSON.parse(readFileSync24(join44(lockDir, "owner.json"), "utf8"));
|
|
249060
249092
|
return {
|
|
249061
249093
|
pid: typeof owner.pid === "number" ? owner.pid : undefined,
|
|
249062
249094
|
command: typeof owner.command === "string" ? owner.command : undefined
|
|
@@ -249076,7 +249108,7 @@ function acquireWhatsAppSessionLease(accountId, options3 = {}) {
|
|
|
249076
249108
|
for (let attempt = 0;attempt < 2; attempt += 1) {
|
|
249077
249109
|
try {
|
|
249078
249110
|
mkdirSync24(lockDir);
|
|
249079
|
-
|
|
249111
|
+
writeFileSync18(join44(lockDir, "owner.json"), `${JSON.stringify({
|
|
249080
249112
|
accountId,
|
|
249081
249113
|
pid,
|
|
249082
249114
|
command: process.argv.join(" "),
|
|
@@ -250681,7 +250713,7 @@ import {
|
|
|
250681
250713
|
copyFileSync as copyFileSync2,
|
|
250682
250714
|
mkdirSync as mkdirSync25,
|
|
250683
250715
|
readdirSync as readdirSync12,
|
|
250684
|
-
readFileSync as
|
|
250716
|
+
readFileSync as readFileSync25,
|
|
250685
250717
|
realpathSync as realpathSync6,
|
|
250686
250718
|
statSync as statSync12
|
|
250687
250719
|
} from "node:fs";
|
|
@@ -250971,7 +251003,7 @@ function copySignalAttachment(params) {
|
|
|
250971
251003
|
localPath
|
|
250972
251004
|
};
|
|
250973
251005
|
if (kind === "image" && sizeBytes <= MAX_SIGNAL_INLINE_IMAGE_BYTES) {
|
|
250974
|
-
attachment.imageDataBase64 =
|
|
251006
|
+
attachment.imageDataBase64 = readFileSync25(localPath).toString("base64");
|
|
250975
251007
|
}
|
|
250976
251008
|
return attachment;
|
|
250977
251009
|
}
|
|
@@ -252467,7 +252499,7 @@ __export(exports_plugin_registry, {
|
|
|
252467
252499
|
getChannelDisplayName: () => getChannelDisplayName,
|
|
252468
252500
|
__testClearUserChannelPluginCache: () => __testClearUserChannelPluginCache
|
|
252469
252501
|
});
|
|
252470
|
-
import { existsSync as existsSync36, readdirSync as readdirSync13, readFileSync as
|
|
252502
|
+
import { existsSync as existsSync36, readdirSync as readdirSync13, readFileSync as readFileSync26 } from "node:fs";
|
|
252471
252503
|
import { resolve as resolve30, sep as sep6 } from "node:path";
|
|
252472
252504
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
252473
252505
|
function isValidChannelId(value) {
|
|
@@ -252482,7 +252514,7 @@ function readChannelManifest(channelDir) {
|
|
|
252482
252514
|
return null;
|
|
252483
252515
|
}
|
|
252484
252516
|
try {
|
|
252485
|
-
const parsed = JSON.parse(
|
|
252517
|
+
const parsed = JSON.parse(readFileSync26(manifestPath, "utf-8"));
|
|
252486
252518
|
if (!isRecord(parsed)) {
|
|
252487
252519
|
return null;
|
|
252488
252520
|
}
|
|
@@ -252743,7 +252775,7 @@ __export(exports_routing, {
|
|
|
252743
252775
|
__testOverrideSaveRoutes: () => __testOverrideSaveRoutes,
|
|
252744
252776
|
__testOverrideLoadRoutes: () => __testOverrideLoadRoutes
|
|
252745
252777
|
});
|
|
252746
|
-
import { existsSync as existsSync37, mkdirSync as mkdirSync26, readFileSync as
|
|
252778
|
+
import { existsSync as existsSync37, mkdirSync as mkdirSync26, readFileSync as readFileSync27, writeFileSync as writeFileSync19 } from "node:fs";
|
|
252747
252779
|
function normalizeAccountId3(accountId) {
|
|
252748
252780
|
return accountId ?? LEGACY_CHANNEL_ACCOUNT_ID;
|
|
252749
252781
|
}
|
|
@@ -252797,7 +252829,7 @@ function loadRoutes(channelId) {
|
|
|
252797
252829
|
if (!existsSync37(path30))
|
|
252798
252830
|
return;
|
|
252799
252831
|
try {
|
|
252800
|
-
const text2 =
|
|
252832
|
+
const text2 = readFileSync27(path30, "utf-8");
|
|
252801
252833
|
const parsed = JSON.parse(text2);
|
|
252802
252834
|
const routes = parsed.routes ?? [];
|
|
252803
252835
|
for (const route of routes) {
|
|
@@ -252834,7 +252866,7 @@ function saveRoutes(channelId) {
|
|
|
252834
252866
|
mkdirSync26(dir, { recursive: true });
|
|
252835
252867
|
const routes = getRoutesForChannel(channelId);
|
|
252836
252868
|
const data = { routes };
|
|
252837
|
-
|
|
252869
|
+
writeFileSync19(getChannelRoutingPath(channelId), `${JSON.stringify(data, null, 2)}
|
|
252838
252870
|
`, "utf-8");
|
|
252839
252871
|
}
|
|
252840
252872
|
function getRoute(channel, chatId, accountId, threadId) {
|
|
@@ -253257,7 +253289,7 @@ var init_registry_commands = __esm(() => {
|
|
|
253257
253289
|
});
|
|
253258
253290
|
|
|
253259
253291
|
// src/channels/pending-control-requests.ts
|
|
253260
|
-
import { existsSync as existsSync38, mkdirSync as mkdirSync27, readFileSync as
|
|
253292
|
+
import { existsSync as existsSync38, mkdirSync as mkdirSync27, readFileSync as readFileSync28, writeFileSync as writeFileSync20 } from "node:fs";
|
|
253261
253293
|
import { dirname as dirname24 } from "node:path";
|
|
253262
253294
|
function cloneEvent(event2) {
|
|
253263
253295
|
return structuredClone(event2);
|
|
@@ -253290,7 +253322,7 @@ function ensureStoreLoaded() {
|
|
|
253290
253322
|
return;
|
|
253291
253323
|
}
|
|
253292
253324
|
try {
|
|
253293
|
-
const text2 =
|
|
253325
|
+
const text2 = readFileSync28(storePath, "utf-8");
|
|
253294
253326
|
const parsed = JSON.parse(text2);
|
|
253295
253327
|
store2 = {
|
|
253296
253328
|
requests: Array.isArray(parsed.requests) ? parsed.requests.filter(isChannelControlRequestEvent).map(cloneEvent) : []
|
|
@@ -253308,7 +253340,7 @@ function saveStore() {
|
|
|
253308
253340
|
}
|
|
253309
253341
|
const storePath = getPendingChannelControlRequestsPath();
|
|
253310
253342
|
mkdirSync27(dirname24(storePath), { recursive: true });
|
|
253311
|
-
|
|
253343
|
+
writeFileSync20(storePath, `${JSON.stringify(snapshot, null, 2)}
|
|
253312
253344
|
`, "utf-8");
|
|
253313
253345
|
}
|
|
253314
253346
|
function listPendingControlRequests() {
|
|
@@ -265434,8 +265466,8 @@ var require_CronFileParser = __commonJS((exports) => {
|
|
|
265434
265466
|
return CronFileParser.#parseContent(data);
|
|
265435
265467
|
}
|
|
265436
265468
|
static parseFileSync(filePath) {
|
|
265437
|
-
const { readFileSync:
|
|
265438
|
-
const data =
|
|
265469
|
+
const { readFileSync: readFileSync29 } = __require("fs");
|
|
265470
|
+
const data = readFileSync29(filePath, "utf8");
|
|
265439
265471
|
return CronFileParser.#parseContent(data);
|
|
265440
265472
|
}
|
|
265441
265473
|
static #parseContent(data) {
|
|
@@ -265777,11 +265809,11 @@ import { randomBytes } from "node:crypto";
|
|
|
265777
265809
|
import {
|
|
265778
265810
|
existsSync as existsSync39,
|
|
265779
265811
|
mkdirSync as mkdirSync28,
|
|
265780
|
-
readFileSync as
|
|
265812
|
+
readFileSync as readFileSync29,
|
|
265781
265813
|
renameSync as renameSync6,
|
|
265782
265814
|
rmSync as rmSync9,
|
|
265783
265815
|
statSync as statSync13,
|
|
265784
|
-
writeFileSync as
|
|
265816
|
+
writeFileSync as writeFileSync21
|
|
265785
265817
|
} from "node:fs";
|
|
265786
265818
|
import { join as join47 } from "node:path";
|
|
265787
265819
|
function getLettaDir() {
|
|
@@ -265826,7 +265858,7 @@ function readCronFile() {
|
|
|
265826
265858
|
if (!existsSync39(path31))
|
|
265827
265859
|
return emptyFile();
|
|
265828
265860
|
try {
|
|
265829
|
-
const raw2 =
|
|
265861
|
+
const raw2 = readFileSync29(path31, "utf-8");
|
|
265830
265862
|
const data = JSON.parse(raw2);
|
|
265831
265863
|
if (data.version !== 1)
|
|
265832
265864
|
return emptyFile();
|
|
@@ -265842,12 +265874,12 @@ function writeCronFile(data) {
|
|
|
265842
265874
|
mkdirSync28(dir, { recursive: true });
|
|
265843
265875
|
}
|
|
265844
265876
|
const tmp = `${path31}.tmp`;
|
|
265845
|
-
|
|
265877
|
+
writeFileSync21(tmp, JSON.stringify(data, null, 2), { flush: true });
|
|
265846
265878
|
renameSync6(tmp, path31);
|
|
265847
265879
|
}
|
|
265848
265880
|
function readLinuxProcessIdentity(pid) {
|
|
265849
265881
|
try {
|
|
265850
|
-
const stat10 =
|
|
265882
|
+
const stat10 = readFileSync29(`/proc/${pid}/stat`, "utf8");
|
|
265851
265883
|
const endCommand = stat10.lastIndexOf(")");
|
|
265852
265884
|
if (endCommand === -1) {
|
|
265853
265885
|
return null;
|
|
@@ -265859,7 +265891,7 @@ function readLinuxProcessIdentity(pid) {
|
|
|
265859
265891
|
}
|
|
265860
265892
|
let bootId = null;
|
|
265861
265893
|
try {
|
|
265862
|
-
bootId =
|
|
265894
|
+
bootId = readFileSync29("/proc/sys/kernel/random/boot_id", "utf8").trim() || null;
|
|
265863
265895
|
} catch {}
|
|
265864
265896
|
return { startTicks, bootId };
|
|
265865
265897
|
} catch {
|
|
@@ -265900,14 +265932,14 @@ function isProcessAlive(pid, owner) {
|
|
|
265900
265932
|
}
|
|
265901
265933
|
function readLockOwner(lockDir) {
|
|
265902
265934
|
try {
|
|
265903
|
-
const raw2 =
|
|
265935
|
+
const raw2 = readFileSync29(join47(lockDir, LOCK_TOKEN_FILE), "utf-8");
|
|
265904
265936
|
return JSON.parse(raw2);
|
|
265905
265937
|
} catch {
|
|
265906
265938
|
return null;
|
|
265907
265939
|
}
|
|
265908
265940
|
}
|
|
265909
265941
|
function writeLockOwner(lockDir, owner) {
|
|
265910
|
-
|
|
265942
|
+
writeFileSync21(join47(lockDir, LOCK_TOKEN_FILE), JSON.stringify(owner));
|
|
265911
265943
|
}
|
|
265912
265944
|
function isLockStale(lockDir) {
|
|
265913
265945
|
const owner = readLockOwner(lockDir);
|
|
@@ -266197,9 +266229,9 @@ import {
|
|
|
266197
266229
|
chmodSync as chmodSync6,
|
|
266198
266230
|
existsSync as existsSync40,
|
|
266199
266231
|
mkdirSync as mkdirSync29,
|
|
266200
|
-
readFileSync as
|
|
266232
|
+
readFileSync as readFileSync30,
|
|
266201
266233
|
statSync as statSync14,
|
|
266202
|
-
writeFileSync as
|
|
266234
|
+
writeFileSync as writeFileSync22
|
|
266203
266235
|
} from "node:fs";
|
|
266204
266236
|
import path31 from "node:path";
|
|
266205
266237
|
function assertSafeCronRunLogJobId(jobId) {
|
|
@@ -266245,11 +266277,11 @@ function pruneIfNeeded(filePath, opts) {
|
|
|
266245
266277
|
if (size <= opts.maxBytes) {
|
|
266246
266278
|
return;
|
|
266247
266279
|
}
|
|
266248
|
-
const raw2 =
|
|
266280
|
+
const raw2 = readFileSync30(filePath, "utf-8");
|
|
266249
266281
|
const lines = raw2.split(`
|
|
266250
266282
|
`).map((line) => line.trim()).filter(Boolean);
|
|
266251
266283
|
const kept = lines.slice(Math.max(0, lines.length - opts.keepLines));
|
|
266252
|
-
|
|
266284
|
+
writeFileSync22(filePath, `${kept.join(`
|
|
266253
266285
|
`)}
|
|
266254
266286
|
`, { mode: 384 });
|
|
266255
266287
|
setSecureFileMode(filePath);
|
|
@@ -266325,7 +266357,7 @@ function readCronRunLogEntries(filePath, opts) {
|
|
|
266325
266357
|
const limit3 = Math.max(1, Math.min(5000, Math.floor(opts?.limit ?? 200)));
|
|
266326
266358
|
let raw2 = "";
|
|
266327
266359
|
try {
|
|
266328
|
-
raw2 =
|
|
266360
|
+
raw2 = readFileSync30(path31.resolve(filePath), "utf-8");
|
|
266329
266361
|
} catch {
|
|
266330
266362
|
return [];
|
|
266331
266363
|
}
|
|
@@ -266753,7 +266785,7 @@ function shouldProcessInboundMessageDirectly(runtime, parsed) {
|
|
|
266753
266785
|
});
|
|
266754
266786
|
return getListenerBlockedReason(runtime.turnLifecycle.snapshot(), activeScope ? getPendingControlRequestCount(runtime.listener, activeScope) : 0) === null;
|
|
266755
266787
|
}
|
|
266756
|
-
function consumeQueuedTurn(runtime) {
|
|
266788
|
+
function consumeQueuedTurn(runtime, options3) {
|
|
266757
266789
|
const queuedItems = runtime.queueRuntime.peek();
|
|
266758
266790
|
const firstQueuedItem = queuedItems[0];
|
|
266759
266791
|
if (!firstQueuedItem || !isCoalescable(firstQueuedItem.kind)) {
|
|
@@ -266803,6 +266835,18 @@ function consumeQueuedTurn(runtime) {
|
|
|
266803
266835
|
if (!hasMessage && !hasTaskNotification && !hasCronPrompt && !hasModContinue || queueLen === 0) {
|
|
266804
266836
|
return null;
|
|
266805
266837
|
}
|
|
266838
|
+
if (options3?.matchActiveSuperRun) {
|
|
266839
|
+
const activeSuperRunId = runtime.superRunId;
|
|
266840
|
+
const crossesSuperRun = queuedItems.slice(0, queueLen).some((item) => {
|
|
266841
|
+
if (item.kind !== "message")
|
|
266842
|
+
return false;
|
|
266843
|
+
const queuedSuperRunId = runtime.queuedMessagesByItemId.get(item.id)?.superRunId ?? null;
|
|
266844
|
+
return queuedSuperRunId !== activeSuperRunId;
|
|
266845
|
+
});
|
|
266846
|
+
if (crossesSuperRun) {
|
|
266847
|
+
return null;
|
|
266848
|
+
}
|
|
266849
|
+
}
|
|
266806
266850
|
const dequeuedBatch = runtime.queueRuntime.consumeItems(queueLen);
|
|
266807
266851
|
if (!dequeuedBatch) {
|
|
266808
266852
|
return null;
|
|
@@ -276842,11 +276886,11 @@ function resolvePendingApprovalResolver(runtime, response, connectionId) {
|
|
|
276842
276886
|
setCommandLoopStatus(runtime, "WAITING_ON_INPUT");
|
|
276843
276887
|
}
|
|
276844
276888
|
pending.resolve(response);
|
|
276845
|
-
emitLoopStatusIfOpen(runtime
|
|
276889
|
+
emitLoopStatusIfOpen(runtime, {
|
|
276846
276890
|
agent_id: runtime.agentId,
|
|
276847
276891
|
conversation_id: runtime.conversationId
|
|
276848
276892
|
});
|
|
276849
|
-
emitDeviceStatusIfOpen(runtime
|
|
276893
|
+
emitDeviceStatusIfOpen(runtime, {
|
|
276850
276894
|
agent_id: runtime.agentId,
|
|
276851
276895
|
conversation_id: runtime.conversationId
|
|
276852
276896
|
});
|
|
@@ -276861,11 +276905,11 @@ function rejectPendingApprovalResolvers(runtime, reason) {
|
|
|
276861
276905
|
if (!runtime.isProcessing && !runtime.cancelRequested) {
|
|
276862
276906
|
setCommandLoopStatus(runtime, "WAITING_ON_INPUT");
|
|
276863
276907
|
}
|
|
276864
|
-
emitLoopStatusIfOpen(runtime
|
|
276908
|
+
emitLoopStatusIfOpen(runtime, {
|
|
276865
276909
|
agent_id: runtime.agentId,
|
|
276866
276910
|
conversation_id: runtime.conversationId
|
|
276867
276911
|
});
|
|
276868
|
-
emitDeviceStatusIfOpen(runtime
|
|
276912
|
+
emitDeviceStatusIfOpen(runtime, {
|
|
276869
276913
|
agent_id: runtime.agentId,
|
|
276870
276914
|
conversation_id: runtime.conversationId
|
|
276871
276915
|
});
|
|
@@ -276970,11 +277014,11 @@ function requestApprovalOverWS(runtime, socket, turnLease, requestId, controlReq
|
|
|
276970
277014
|
runtime.turnLifecycle.recordStopReason(turnLease, "requires_approval");
|
|
276971
277015
|
setTurnLoopStatus(runtime, turnLease, "WAITING_ON_APPROVAL");
|
|
276972
277016
|
emitProtocolV2Message(socket, runtime, controlRequest, scope, TO_SUBSCRIBERS);
|
|
276973
|
-
emitLoopStatusIfOpen(runtime
|
|
277017
|
+
emitLoopStatusIfOpen(runtime, {
|
|
276974
277018
|
agent_id: runtime.agentId,
|
|
276975
277019
|
conversation_id: runtime.conversationId
|
|
276976
277020
|
});
|
|
276977
|
-
emitDeviceStatusIfOpen(runtime
|
|
277021
|
+
emitDeviceStatusIfOpen(runtime, {
|
|
276978
277022
|
agent_id: runtime.agentId,
|
|
276979
277023
|
conversation_id: runtime.conversationId
|
|
276980
277024
|
});
|
|
@@ -278532,7 +278576,7 @@ __export(exports_memory_scanner, {
|
|
|
278532
278576
|
readFileContent: () => readFileContent,
|
|
278533
278577
|
getFileNodes: () => getFileNodes
|
|
278534
278578
|
});
|
|
278535
|
-
import { readdirSync as readdirSync16, readFileSync as
|
|
278579
|
+
import { readdirSync as readdirSync16, readFileSync as readFileSync31, statSync as statSync16 } from "node:fs";
|
|
278536
278580
|
import { join as join62, relative as relative9 } from "node:path";
|
|
278537
278581
|
function scanMemoryFilesystem(memoryRoot) {
|
|
278538
278582
|
const nodes = [];
|
|
@@ -278597,7 +278641,7 @@ function getFileNodes(nodes) {
|
|
|
278597
278641
|
}
|
|
278598
278642
|
function readFileContent(fullPath) {
|
|
278599
278643
|
try {
|
|
278600
|
-
return
|
|
278644
|
+
return readFileSync31(fullPath, "utf-8");
|
|
278601
278645
|
} catch {
|
|
278602
278646
|
return "(unable to read file)";
|
|
278603
278647
|
}
|
|
@@ -279339,7 +279383,7 @@ __export(exports_remote_model_catalog, {
|
|
|
279339
279383
|
__testResetRemoteModelCatalog: () => __testResetRemoteModelCatalog
|
|
279340
279384
|
});
|
|
279341
279385
|
import { createHash as createHash8 } from "node:crypto";
|
|
279342
|
-
import { existsSync as existsSync44, mkdirSync as mkdirSync31, readFileSync as
|
|
279386
|
+
import { existsSync as existsSync44, mkdirSync as mkdirSync31, readFileSync as readFileSync32, writeFileSync as writeFileSync23 } from "node:fs";
|
|
279343
279387
|
import { homedir as homedir37 } from "node:os";
|
|
279344
279388
|
import { dirname as dirname27, join as join63 } from "node:path";
|
|
279345
279389
|
function cloneCatalogModels(entries) {
|
|
@@ -279431,7 +279475,7 @@ function persistCatalogCache(entries, source2) {
|
|
|
279431
279475
|
try {
|
|
279432
279476
|
const path33 = catalogCachePath();
|
|
279433
279477
|
mkdirSync31(dirname27(path33), { recursive: true });
|
|
279434
|
-
|
|
279478
|
+
writeFileSync23(path33, JSON.stringify({
|
|
279435
279479
|
schemaVersion: CACHE_SCHEMA_VERSION,
|
|
279436
279480
|
source: source2,
|
|
279437
279481
|
bundledCatalogFingerprint,
|
|
@@ -279450,7 +279494,7 @@ function loadPersistedModelCatalog(source2) {
|
|
|
279450
279494
|
if (!existsSync44(path33)) {
|
|
279451
279495
|
return false;
|
|
279452
279496
|
}
|
|
279453
|
-
const parsed = JSON.parse(
|
|
279497
|
+
const parsed = JSON.parse(readFileSync32(path33, "utf-8"));
|
|
279454
279498
|
if (parsed.schemaVersion !== CACHE_SCHEMA_VERSION || parsed.source !== normalizeCatalogSource(source2) || parsed.bundledCatalogFingerprint !== bundledCatalogFingerprint || !Array.isArray(parsed.models)) {
|
|
279455
279499
|
return false;
|
|
279456
279500
|
}
|
|
@@ -279872,7 +279916,7 @@ var LETTA_MODS_DIR_ENV = "LETTA_MODS_DIR", LEGACY_LETTA_EXTENSIONS_DIR_ENV = "LE
|
|
|
279872
279916
|
var init_paths2 = () => {};
|
|
279873
279917
|
|
|
279874
279918
|
// src/mods/mod-diagnostics-file.ts
|
|
279875
|
-
import { mkdirSync as mkdirSync32, writeFileSync as
|
|
279919
|
+
import { mkdirSync as mkdirSync32, writeFileSync as writeFileSync24 } from "node:fs";
|
|
279876
279920
|
import { homedir as homedir39 } from "node:os";
|
|
279877
279921
|
import path34 from "node:path";
|
|
279878
279922
|
function getDefaultModDiagnosticsRoot(homeDirectory = homedir39()) {
|
|
@@ -279891,7 +279935,7 @@ function writeModDiagnosticsLatestFile(diagnostics2, options3 = {}) {
|
|
|
279891
279935
|
const file3 = createModDiagnosticsFile(diagnostics2, options3.generatedAt);
|
|
279892
279936
|
const filePath = getModDiagnosticsLatestFilePath(options3.rootDirectory);
|
|
279893
279937
|
mkdirSync32(path34.dirname(filePath), { recursive: true });
|
|
279894
|
-
|
|
279938
|
+
writeFileSync24(filePath, `${JSON.stringify(file3, null, 2)}
|
|
279895
279939
|
`, "utf-8");
|
|
279896
279940
|
return file3;
|
|
279897
279941
|
}
|
|
@@ -448636,7 +448680,7 @@ var init_file_extensions = __esm(() => {
|
|
|
448636
448680
|
});
|
|
448637
448681
|
|
|
448638
448682
|
// src/mods/package-manifest.ts
|
|
448639
|
-
import { readFileSync as
|
|
448683
|
+
import { readFileSync as readFileSync33 } from "node:fs";
|
|
448640
448684
|
import path35 from "node:path";
|
|
448641
448685
|
function isRecord9(value) {
|
|
448642
448686
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -448846,7 +448890,7 @@ function parseLettaPackageManifest(packageJson) {
|
|
|
448846
448890
|
}
|
|
448847
448891
|
function readLettaPackageManifest(packageJsonPath) {
|
|
448848
448892
|
try {
|
|
448849
|
-
const packageJson = JSON.parse(
|
|
448893
|
+
const packageJson = JSON.parse(readFileSync33(packageJsonPath, "utf8"));
|
|
448850
448894
|
return parseLettaPackageManifest(packageJson);
|
|
448851
448895
|
} catch (error54) {
|
|
448852
448896
|
return {
|
|
@@ -448878,9 +448922,9 @@ var init_package_manifest = __esm(() => {
|
|
|
448878
448922
|
import {
|
|
448879
448923
|
existsSync as existsSync46,
|
|
448880
448924
|
mkdirSync as mkdirSync33,
|
|
448881
|
-
readFileSync as
|
|
448925
|
+
readFileSync as readFileSync34,
|
|
448882
448926
|
rmSync as rmSync10,
|
|
448883
|
-
writeFileSync as
|
|
448927
|
+
writeFileSync as writeFileSync25
|
|
448884
448928
|
} from "node:fs";
|
|
448885
448929
|
import path36 from "node:path";
|
|
448886
448930
|
function isRecord10(value) {
|
|
@@ -448934,7 +448978,7 @@ function parseJsonFile(filePath) {
|
|
|
448934
448978
|
try {
|
|
448935
448979
|
return {
|
|
448936
448980
|
ok: true,
|
|
448937
|
-
value: JSON.parse(
|
|
448981
|
+
value: JSON.parse(readFileSync34(filePath, "utf8"))
|
|
448938
448982
|
};
|
|
448939
448983
|
} catch (error54) {
|
|
448940
448984
|
return {
|
|
@@ -449375,12 +449419,12 @@ function findPackageIndex(modsRoot, packagesValue, specifier) {
|
|
|
449375
449419
|
}
|
|
449376
449420
|
function writePackageRegistry(registryPath, registry2) {
|
|
449377
449421
|
mkdirSync33(path36.dirname(registryPath), { recursive: true });
|
|
449378
|
-
|
|
449422
|
+
writeFileSync25(registryPath, `${JSON.stringify(registry2, null, 2)}
|
|
449379
449423
|
`);
|
|
449380
449424
|
}
|
|
449381
449425
|
function validateManagedModPackageRegistryForMutation(modsRoot) {
|
|
449382
449426
|
const registryPath = getRegistryPath(modsRoot);
|
|
449383
|
-
const contents = existsSync46(registryPath) ?
|
|
449427
|
+
const contents = existsSync46(registryPath) ? readFileSync34(registryPath, "utf8") : null;
|
|
449384
449428
|
const registry2 = readMutablePackageRegistry(modsRoot, {
|
|
449385
449429
|
createIfMissing: true
|
|
449386
449430
|
});
|
|
@@ -449633,6 +449677,41 @@ function getTurnStartCancel(event2) {
|
|
|
449633
449677
|
}
|
|
449634
449678
|
var MAX_TURN_START_CANCEL_REASON_LENGTH = 2000;
|
|
449635
449679
|
|
|
449680
|
+
// src/mods/turn-start-input.ts
|
|
449681
|
+
function isTurnStartInput(value) {
|
|
449682
|
+
return Array.isArray(value) && value.every((item) => typeof item === "object" && item !== null);
|
|
449683
|
+
}
|
|
449684
|
+
function cloneTurnStartInput(input) {
|
|
449685
|
+
return input.map((item) => structuredClone(item));
|
|
449686
|
+
}
|
|
449687
|
+
function isApprovalInput(item) {
|
|
449688
|
+
return item.type === "approval";
|
|
449689
|
+
}
|
|
449690
|
+
function preserveApprovalFirstOrdering(wasApprovalContinuation, transformedInput) {
|
|
449691
|
+
if (!wasApprovalContinuation)
|
|
449692
|
+
return transformedInput;
|
|
449693
|
+
let sawNonApproval = false;
|
|
449694
|
+
let needsReorder = false;
|
|
449695
|
+
for (const item of transformedInput) {
|
|
449696
|
+
if (isApprovalInput(item)) {
|
|
449697
|
+
if (sawNonApproval) {
|
|
449698
|
+
needsReorder = true;
|
|
449699
|
+
break;
|
|
449700
|
+
}
|
|
449701
|
+
} else {
|
|
449702
|
+
sawNonApproval = true;
|
|
449703
|
+
}
|
|
449704
|
+
}
|
|
449705
|
+
if (!needsReorder)
|
|
449706
|
+
return transformedInput;
|
|
449707
|
+
const approvals = [];
|
|
449708
|
+
const remaining = [];
|
|
449709
|
+
for (const item of transformedInput) {
|
|
449710
|
+
(isApprovalInput(item) ? approvals : remaining).push(item);
|
|
449711
|
+
}
|
|
449712
|
+
return [...approvals, ...remaining];
|
|
449713
|
+
}
|
|
449714
|
+
|
|
449636
449715
|
// src/mods/ui-helpers.ts
|
|
449637
449716
|
function createNoopModPanelHandle() {
|
|
449638
449717
|
return { close() {}, update() {} };
|
|
@@ -449644,10 +449723,10 @@ import {
|
|
|
449644
449723
|
existsSync as existsSync48,
|
|
449645
449724
|
mkdirSync as mkdirSync35,
|
|
449646
449725
|
readdirSync as readdirSync18,
|
|
449647
|
-
readFileSync as
|
|
449726
|
+
readFileSync as readFileSync35,
|
|
449648
449727
|
statSync as statSync17,
|
|
449649
449728
|
unlinkSync as unlinkSync9,
|
|
449650
|
-
writeFileSync as
|
|
449729
|
+
writeFileSync as writeFileSync26
|
|
449651
449730
|
} from "node:fs";
|
|
449652
449731
|
import { createRequire as createRequire5 } from "node:module";
|
|
449653
449732
|
import path39 from "node:path";
|
|
@@ -449820,7 +449899,7 @@ function prepareModForImport(modPath, source2) {
|
|
|
449820
449899
|
}
|
|
449821
449900
|
function createImportableModPath(modPath, cacheDirectory, source2) {
|
|
449822
449901
|
const importCacheDirectory = getManagedPackageImportCacheDirectory(modPath, source2) ?? cacheDirectory;
|
|
449823
|
-
const sourceText =
|
|
449902
|
+
const sourceText = readFileSync35(modPath, "utf8");
|
|
449824
449903
|
const hash4 = createHash9("sha256").update(sourceText).digest("hex").slice(0, 16);
|
|
449825
449904
|
const fileExtension = path39.extname(modPath);
|
|
449826
449905
|
const importableSource = prepareModForImport(modPath, sourceText);
|
|
@@ -449832,7 +449911,7 @@ function createImportableModPath(modPath, cacheDirectory, source2) {
|
|
|
449832
449911
|
const baseName = path39.basename(modPath, fileExtension).replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
449833
449912
|
const importPath = path39.join(importCacheDirectory, `.letta-mod-${baseName}-${hash4}.mjs`);
|
|
449834
449913
|
if (!existsSync48(importPath)) {
|
|
449835
|
-
|
|
449914
|
+
writeFileSync26(importPath, importableSource, "utf8");
|
|
449836
449915
|
}
|
|
449837
449916
|
try {
|
|
449838
449917
|
for (const entry of readdirSync18(importCacheDirectory)) {
|
|
@@ -449901,12 +449980,6 @@ function isTurnStartResultWithCancel(name, result) {
|
|
|
449901
449980
|
const cancel = result.cancel;
|
|
449902
449981
|
return typeof cancel === "object" && cancel !== null && normalizeTurnStartCancelReason(cancel.reason) !== null;
|
|
449903
449982
|
}
|
|
449904
|
-
function isTurnStartInput(value) {
|
|
449905
|
-
return Array.isArray(value) && value.every((item) => typeof item === "object" && item !== null);
|
|
449906
|
-
}
|
|
449907
|
-
function cloneTurnStartInput(input) {
|
|
449908
|
-
return input.map((item) => structuredClone(item));
|
|
449909
|
-
}
|
|
449910
449983
|
function isToolStartResultWithArgs(name, result) {
|
|
449911
449984
|
return name === "tool_start" && typeof result === "object" && result !== null && isToolStartArgs2(result.args);
|
|
449912
449985
|
}
|
|
@@ -450481,7 +450554,7 @@ async function loadLocalMods(options3) {
|
|
|
450481
450554
|
}
|
|
450482
450555
|
try {
|
|
450483
450556
|
const mtimeMs = statSync17(modPath).mtimeMs;
|
|
450484
|
-
const sourceText =
|
|
450557
|
+
const sourceText = readFileSync35(modPath, "utf8");
|
|
450485
450558
|
recordDeprecatedContextApiSourceDiagnostics(sourceText, (diagnostic) => {
|
|
450486
450559
|
recordModDiagnostic(registry2, {
|
|
450487
450560
|
...diagnostic,
|
|
@@ -450529,6 +450602,7 @@ async function emitLocalModEvent(registry2, name, event2, context3, backend3, on
|
|
|
450529
450602
|
const diagnostics2 = [];
|
|
450530
450603
|
const results = [];
|
|
450531
450604
|
let turnStartCancel;
|
|
450605
|
+
const turnStartHadApproval = name === "turn_start" && event2.input.some((item) => item.type === "approval");
|
|
450532
450606
|
for (const registration of registrations) {
|
|
450533
450607
|
const signal = registration.owner ? registry2.ownerAbortControllers[registration.owner.id]?.signal : undefined;
|
|
450534
450608
|
if (signal?.aborted)
|
|
@@ -450603,6 +450677,7 @@ async function emitLocalModEvent(registry2, name, event2, context3, backend3, on
|
|
|
450603
450677
|
}
|
|
450604
450678
|
if (name === "turn_start") {
|
|
450605
450679
|
const turnStartEventWithCancel = event2;
|
|
450680
|
+
turnStartEventWithCancel.input = preserveApprovalFirstOrdering(turnStartHadApproval, turnStartEventWithCancel.input);
|
|
450606
450681
|
if (turnStartCancel) {
|
|
450607
450682
|
turnStartEventWithCancel.cancel = { ...turnStartCancel };
|
|
450608
450683
|
} else {
|
|
@@ -454459,7 +454534,7 @@ import {
|
|
|
454459
454534
|
mkdirSync as mkdirSync37,
|
|
454460
454535
|
readdirSync as readdirSync19,
|
|
454461
454536
|
unlinkSync as unlinkSync10,
|
|
454462
|
-
writeFileSync as
|
|
454537
|
+
writeFileSync as writeFileSync27
|
|
454463
454538
|
} from "node:fs";
|
|
454464
454539
|
import { homedir as homedir40 } from "node:os";
|
|
454465
454540
|
import { join as join65 } from "node:path";
|
|
@@ -454571,7 +454646,7 @@ class ChunkLog {
|
|
|
454571
454646
|
try {
|
|
454572
454647
|
const content = this.buffer.map((entry) => JSON.stringify(entry)).join(`
|
|
454573
454648
|
`);
|
|
454574
|
-
|
|
454649
|
+
writeFileSync27(this.logPath, `${content}
|
|
454575
454650
|
`, "utf8");
|
|
454576
454651
|
} catch (e2) {
|
|
454577
454652
|
debugWarn("chunkLog", `Failed to write ${this.logPath}: ${e2 instanceof Error ? e2.message : String(e2)}`);
|
|
@@ -455937,7 +456012,8 @@ async function resolveRecoveredApprovalResponse(runtime, socket, response, proce
|
|
|
455937
456012
|
const workingDirectory = getConversationWorkingDirectory(runtime.listener, recovered.agentId, recovered.conversationId);
|
|
455938
456013
|
const scope = {
|
|
455939
456014
|
agent_id: recovered.agentId,
|
|
455940
|
-
conversation_id: recovered.conversationId
|
|
456015
|
+
conversation_id: recovered.conversationId,
|
|
456016
|
+
...opts?.superRunId ? { super_run_id: opts.superRunId } : {}
|
|
455941
456017
|
};
|
|
455942
456018
|
const respondedEntry = recovered.approvalsByRequestId.get(requestId);
|
|
455943
456019
|
let autoDecisionsToAppend = [];
|
|
@@ -455990,7 +456066,8 @@ async function resolveRecoveredApprovalResponse(runtime, socket, response, proce
|
|
|
455990
456066
|
const recoveryLease = pendingRequestIdsAfterResponse.length === 0 ? runtime.turnLifecycle.begin({
|
|
455991
456067
|
origin: "approval_recovery",
|
|
455992
456068
|
workingDirectory,
|
|
455993
|
-
initialStatus: "EXECUTING_CLIENT_SIDE_TOOL"
|
|
456069
|
+
initialStatus: "EXECUTING_CLIENT_SIDE_TOOL",
|
|
456070
|
+
superRunId: opts?.superRunId
|
|
455994
456071
|
}) : null;
|
|
455995
456072
|
let continuationFinalized = false;
|
|
455996
456073
|
try {
|
|
@@ -456144,7 +456221,9 @@ async function resolveRecoveredApprovalResponse(runtime, socket, response, proce
|
|
|
456144
456221
|
}
|
|
456145
456222
|
]);
|
|
456146
456223
|
let continuationBatchId = `batch-recovered-${crypto.randomUUID()}`;
|
|
456147
|
-
const consumedQueuedTurn = consumeQueuedTurn(runtime
|
|
456224
|
+
const consumedQueuedTurn = consumeQueuedTurn(runtime, {
|
|
456225
|
+
matchActiveSuperRun: true
|
|
456226
|
+
});
|
|
456148
456227
|
if (consumedQueuedTurn) {
|
|
456149
456228
|
const { dequeuedBatch, queuedTurn } = consumedQueuedTurn;
|
|
456150
456229
|
continuationBatchId = dequeuedBatch.batchId;
|
|
@@ -456158,6 +456237,7 @@ async function resolveRecoveredApprovalResponse(runtime, socket, response, proce
|
|
|
456158
456237
|
type: "message",
|
|
456159
456238
|
agentId: recovered.agentId,
|
|
456160
456239
|
conversationId: recovered.conversationId,
|
|
456240
|
+
...opts?.superRunId ? { superRunId: opts.superRunId } : {},
|
|
456161
456241
|
messages: continuationInput.messages
|
|
456162
456242
|
}, socket, runtime, opts?.onStatusChange, opts?.connectionId, continuationBatchId, recoveryLease);
|
|
456163
456243
|
if (runtime.turnLifecycle.isCurrent(recoveryLease)) {
|
|
@@ -456183,17 +456263,21 @@ async function resolveRecoveredApprovalResponse(runtime, socket, response, proce
|
|
|
456183
456263
|
recovered.responsesByRequestId.clear();
|
|
456184
456264
|
}
|
|
456185
456265
|
const stopReason = recoveryLease.signal.aborted ? "cancelled" : "error";
|
|
456186
|
-
|
|
456187
|
-
|
|
456188
|
-
|
|
456189
|
-
|
|
456190
|
-
|
|
456191
|
-
|
|
456192
|
-
|
|
456193
|
-
error:
|
|
456194
|
-
|
|
456195
|
-
|
|
456196
|
-
|
|
456266
|
+
try {
|
|
456267
|
+
finishListenerTurn(runtime, recoveryLease, {
|
|
456268
|
+
stopReason,
|
|
456269
|
+
socket,
|
|
456270
|
+
agentId: recovered.agentId,
|
|
456271
|
+
conversationId: recovered.conversationId,
|
|
456272
|
+
turnId: `batch-recovered-${requestId}`,
|
|
456273
|
+
error: stopReason === "error" ? getTranscriptLoopErrorMessage({
|
|
456274
|
+
error: error54,
|
|
456275
|
+
message: error54 instanceof Error ? error54.message : String(error54)
|
|
456276
|
+
}) : undefined
|
|
456277
|
+
});
|
|
456278
|
+
} finally {
|
|
456279
|
+
runtime.turnLifecycle.releaseSuperRunId(recoveryLease);
|
|
456280
|
+
}
|
|
456197
456281
|
throw error54;
|
|
456198
456282
|
}
|
|
456199
456283
|
}
|
|
@@ -456540,7 +456624,9 @@ async function resolveStaleApprovals(runtime, socket, turnLease, deps = {}) {
|
|
|
456540
456624
|
otid: crypto.randomUUID()
|
|
456541
456625
|
}
|
|
456542
456626
|
]);
|
|
456543
|
-
const consumedQueuedTurn = consumeQueuedTurn(runtime
|
|
456627
|
+
const consumedQueuedTurn = consumeQueuedTurn(runtime, {
|
|
456628
|
+
matchActiveSuperRun: true
|
|
456629
|
+
});
|
|
456544
456630
|
if (consumedQueuedTurn) {
|
|
456545
456631
|
const { dequeuedBatch, queuedTurn } = consumedQueuedTurn;
|
|
456546
456632
|
continuationInput = appendQueuedTurnToInput(continuationInput, queuedTurn);
|
|
@@ -459313,7 +459399,9 @@ async function handleApprovalStop(params) {
|
|
|
459313
459399
|
}
|
|
459314
459400
|
]);
|
|
459315
459401
|
let continuationBatchId = dequeuedBatchId;
|
|
459316
|
-
const consumedQueuedTurn = consumeQueuedTurn(runtime
|
|
459402
|
+
const consumedQueuedTurn = consumeQueuedTurn(runtime, {
|
|
459403
|
+
matchActiveSuperRun: true
|
|
459404
|
+
});
|
|
459317
459405
|
if (consumedQueuedTurn) {
|
|
459318
459406
|
const { dequeuedBatch, queuedTurn } = consumedQueuedTurn;
|
|
459319
459407
|
continuationBatchId = dequeuedBatch.batchId;
|
|
@@ -460928,7 +461016,8 @@ async function handleIncomingMessageInner(msg, socket, runtime, onStatusChange,
|
|
|
460928
461016
|
let lastNeedsUserInputToolCallIds = [];
|
|
460929
461017
|
const turnLease = existingTurnLease ?? runtime.turnLifecycle.begin({
|
|
460930
461018
|
origin: "message",
|
|
460931
|
-
workingDirectory: turnWorkingDirectory
|
|
461019
|
+
workingDirectory: turnWorkingDirectory,
|
|
461020
|
+
superRunId: msg.superRunId
|
|
460932
461021
|
});
|
|
460933
461022
|
if (connectionId) {
|
|
460934
461023
|
runtime.activeConnectionId = connectionId;
|
|
@@ -461047,6 +461136,7 @@ async function handleIncomingMessageInner(msg, socket, runtime, onStatusChange,
|
|
|
461047
461136
|
} : {},
|
|
461048
461137
|
...providerFallback.overrideModel ? { overrideModel: providerFallback.overrideModel } : {},
|
|
461049
461138
|
...msg.actingUserId ? { actingUserId: msg.actingUserId } : {},
|
|
461139
|
+
...msg.superRunId ? { superRunId: msg.superRunId } : {},
|
|
461050
461140
|
...pendingNormalizationInterruptedToolCallIds.length > 0 ? {
|
|
461051
461141
|
approvalNormalization: {
|
|
461052
461142
|
interruptedToolCallIds: pendingNormalizationInterruptedToolCallIds
|
|
@@ -461572,6 +461662,7 @@ async function handleIncomingMessageInner(msg, socket, runtime, onStatusChange,
|
|
|
461572
461662
|
}
|
|
461573
461663
|
} finally {
|
|
461574
461664
|
releaseListenerTurnContext({ runtime, agentId, conversationId });
|
|
461665
|
+
runtime.turnLifecycle.releaseSuperRunId(turnLease);
|
|
461575
461666
|
}
|
|
461576
461667
|
evictConversationRuntimeIfIdle(runtime);
|
|
461577
461668
|
}
|
|
@@ -461698,7 +461789,8 @@ async function handleApprovalResponseInput(listener, params, deps = {
|
|
|
461698
461789
|
}
|
|
461699
461790
|
if (await deps.resolveRecoveredApprovalResponse(targetRuntime, params.socket, params.response, handleIncomingMessage, {
|
|
461700
461791
|
onStatusChange: params.opts.onStatusChange,
|
|
461701
|
-
connectionId: params.opts.connectionId
|
|
461792
|
+
connectionId: params.opts.connectionId,
|
|
461793
|
+
...params.runtime.super_run_id ? { superRunId: params.runtime.super_run_id } : {}
|
|
461702
461794
|
})) {
|
|
461703
461795
|
deps.scheduleQueuePump(targetRuntime, params.socket, params.opts, params.processQueuedTurn);
|
|
461704
461796
|
return true;
|
|
@@ -466221,6 +466313,8 @@ function createListenerMessageHandler(params) {
|
|
|
466221
466313
|
connectionId,
|
|
466222
466314
|
agentId: parsed.runtime.agent_id,
|
|
466223
466315
|
conversationId: parsed.runtime.conversation_id,
|
|
466316
|
+
superRunId: parsed.runtime.super_run_id,
|
|
466317
|
+
noCoalesce: parsed.runtime.super_run_id !== undefined,
|
|
466224
466318
|
clientToolAllowlist: inputPayload.client_tool_allowlist,
|
|
466225
466319
|
clientToolset: inputPayload.client_toolset,
|
|
466226
466320
|
externalToolScopeIds: inputPayload.external_tool_scope_ids,
|
|
@@ -470929,14 +471023,14 @@ import {
|
|
|
470929
471023
|
existsSync as existsSync52,
|
|
470930
471024
|
mkdirSync as mkdirSync38,
|
|
470931
471025
|
readdirSync as readdirSync20,
|
|
470932
|
-
readFileSync as
|
|
470933
|
-
writeFileSync as
|
|
471026
|
+
readFileSync as readFileSync36,
|
|
471027
|
+
writeFileSync as writeFileSync28
|
|
470934
471028
|
} from "node:fs";
|
|
470935
471029
|
import { join as join68 } from "node:path";
|
|
470936
471030
|
function readJsonl(path44) {
|
|
470937
471031
|
if (!existsSync52(path44))
|
|
470938
471032
|
return [];
|
|
470939
|
-
return
|
|
471033
|
+
return readFileSync36(path44, "utf8").split(`
|
|
470940
471034
|
`).filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
|
|
470941
471035
|
}
|
|
470942
471036
|
function isLegacyUiMessage(value) {
|
|
@@ -470946,7 +471040,7 @@ function isPiLocalMessage(value) {
|
|
|
470946
471040
|
return isRecord(value) && typeof value.id === "string" && (value.role === "user" || value.role === "assistant" || value.role === "toolResult") && Object.hasOwn(value, "content");
|
|
470947
471041
|
}
|
|
470948
471042
|
function writeJsonl(path44, items3) {
|
|
470949
|
-
|
|
471043
|
+
writeFileSync28(path44, `${items3.map((item) => JSON.stringify(item)).join(`
|
|
470950
471044
|
`)}
|
|
470951
471045
|
`);
|
|
470952
471046
|
}
|
|
@@ -471231,7 +471325,7 @@ function migrateLocalBackendTranscripts(input) {
|
|
|
471231
471325
|
const hasManifest = existsSync52(manifestPath);
|
|
471232
471326
|
const existingManifest = hasManifest ? (() => {
|
|
471233
471327
|
try {
|
|
471234
|
-
return JSON.parse(
|
|
471328
|
+
return JSON.parse(readFileSync36(manifestPath, "utf8"));
|
|
471235
471329
|
} catch {
|
|
471236
471330
|
return;
|
|
471237
471331
|
}
|
|
@@ -471247,7 +471341,7 @@ function migrateLocalBackendTranscripts(input) {
|
|
|
471247
471341
|
result.skipped.push({ conversationDir, reason: "empty" });
|
|
471248
471342
|
if (!input.dryRun) {
|
|
471249
471343
|
mkdirSync38(conversationDir, { recursive: true });
|
|
471250
|
-
|
|
471344
|
+
writeFileSync28(manifestPath, `${JSON.stringify(manifest({}), null, 2)}
|
|
471251
471345
|
`);
|
|
471252
471346
|
}
|
|
471253
471347
|
continue;
|
|
@@ -471274,7 +471368,7 @@ function migrateLocalBackendTranscripts(input) {
|
|
|
471274
471368
|
let conversation;
|
|
471275
471369
|
if (existsSync52(conversationPath)) {
|
|
471276
471370
|
try {
|
|
471277
|
-
conversation = JSON.parse(
|
|
471371
|
+
conversation = JSON.parse(readFileSync36(conversationPath, "utf8"));
|
|
471278
471372
|
} catch {
|
|
471279
471373
|
conversation = undefined;
|
|
471280
471374
|
}
|
|
@@ -471300,12 +471394,12 @@ function migrateLocalBackendTranscripts(input) {
|
|
|
471300
471394
|
}
|
|
471301
471395
|
}
|
|
471302
471396
|
conversation.in_context_message_ids = remapped;
|
|
471303
|
-
|
|
471397
|
+
writeFileSync28(conversationPath, `${JSON.stringify(conversation, null, 2)}
|
|
471304
471398
|
`);
|
|
471305
471399
|
}
|
|
471306
471400
|
} catch {}
|
|
471307
471401
|
}
|
|
471308
|
-
|
|
471402
|
+
writeFileSync28(manifestPath, `${JSON.stringify(manifest({
|
|
471309
471403
|
backupPath,
|
|
471310
471404
|
migratedFrom: repairVersioned ? hasLegacyUiRows ? "versioned-pi-transcript-with-legacy-ui-message-rows" : "versioned-pi-ai-message-jsonl" : undefined
|
|
471311
471405
|
}), null, 2)}
|
|
@@ -471736,13 +471830,13 @@ var init_memory7 = __esm(() => {
|
|
|
471736
471830
|
});
|
|
471737
471831
|
|
|
471738
471832
|
// src/backend/local/transcript-search.ts
|
|
471739
|
-
import { existsSync as existsSync54, readdirSync as readdirSync21, readFileSync as
|
|
471833
|
+
import { existsSync as existsSync54, readdirSync as readdirSync21, readFileSync as readFileSync37, statSync as statSync19 } from "node:fs";
|
|
471740
471834
|
import { join as join70 } from "node:path";
|
|
471741
471835
|
function readJsonFile3(path44) {
|
|
471742
471836
|
if (!existsSync54(path44))
|
|
471743
471837
|
return;
|
|
471744
471838
|
try {
|
|
471745
|
-
return JSON.parse(
|
|
471839
|
+
return JSON.parse(readFileSync37(path44, "utf8"));
|
|
471746
471840
|
} catch {
|
|
471747
471841
|
return;
|
|
471748
471842
|
}
|
|
@@ -471751,7 +471845,7 @@ function readJsonlFile2(path44) {
|
|
|
471751
471845
|
if (!existsSync54(path44))
|
|
471752
471846
|
return [];
|
|
471753
471847
|
try {
|
|
471754
|
-
return
|
|
471848
|
+
return readFileSync37(path44, "utf8").split(`
|
|
471755
471849
|
`).filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
|
|
471756
471850
|
} catch {
|
|
471757
471851
|
return [];
|
|
@@ -472456,10 +472550,10 @@ import {
|
|
|
472456
472550
|
mkdirSync as mkdirSync40,
|
|
472457
472551
|
mkdtempSync as mkdtempSync3,
|
|
472458
472552
|
readdirSync as readdirSync22,
|
|
472459
|
-
readFileSync as
|
|
472553
|
+
readFileSync as readFileSync38,
|
|
472460
472554
|
renameSync as renameSync7,
|
|
472461
472555
|
rmSync as rmSync12,
|
|
472462
|
-
writeFileSync as
|
|
472556
|
+
writeFileSync as writeFileSync29
|
|
472463
472557
|
} from "node:fs";
|
|
472464
472558
|
import { tmpdir as tmpdir9 } from "node:os";
|
|
472465
472559
|
import path44 from "node:path";
|
|
@@ -472475,7 +472569,7 @@ function isPathInsideOrEqual2(childPath, parentPath) {
|
|
|
472475
472569
|
function readPackageJson(packageJsonPath) {
|
|
472476
472570
|
let parsed;
|
|
472477
472571
|
try {
|
|
472478
|
-
parsed = JSON.parse(
|
|
472572
|
+
parsed = JSON.parse(readFileSync38(packageJsonPath, "utf8"));
|
|
472479
472573
|
} catch (error54) {
|
|
472480
472574
|
throw new Error(`Could not read package.json: ${error54 instanceof Error ? error54.message : String(error54)}`);
|
|
472481
472575
|
}
|
|
@@ -472683,7 +472777,7 @@ function restoreRegistry(registryPath, previousContents) {
|
|
|
472683
472777
|
return;
|
|
472684
472778
|
}
|
|
472685
472779
|
mkdirSync40(path44.dirname(registryPath), { recursive: true });
|
|
472686
|
-
|
|
472780
|
+
writeFileSync29(registryPath, previousContents);
|
|
472687
472781
|
}
|
|
472688
472782
|
function removeIfExists(targetPath) {
|
|
472689
472783
|
if (!targetPath)
|
|
@@ -472804,7 +472898,7 @@ function getNpmInstallArgs(installSpec) {
|
|
|
472804
472898
|
];
|
|
472805
472899
|
}
|
|
472806
472900
|
function writeNpmInstallManifest(tempRoot) {
|
|
472807
|
-
|
|
472901
|
+
writeFileSync29(path44.join(tempRoot, "package.json"), `${JSON.stringify({
|
|
472808
472902
|
private: true,
|
|
472809
472903
|
name: "letta-managed-mod-install"
|
|
472810
472904
|
}, null, 2)}
|
|
@@ -473078,7 +473172,7 @@ function getPackageVersionForGitPackage(params) {
|
|
|
473078
473172
|
}
|
|
473079
473173
|
function writeCompatibilityPackageManifest(params) {
|
|
473080
473174
|
const packageJsonPath = path44.join(params.packageDirectory, "package.json");
|
|
473081
|
-
|
|
473175
|
+
writeFileSync29(packageJsonPath, `${JSON.stringify({
|
|
473082
473176
|
...params.packageJson ?? {},
|
|
473083
473177
|
name: params.packageName,
|
|
473084
473178
|
version: params.version,
|
|
@@ -473316,7 +473410,7 @@ import {
|
|
|
473316
473410
|
lstatSync as lstatSync4,
|
|
473317
473411
|
mkdirSync as mkdirSync41,
|
|
473318
473412
|
rmSync as rmSync13,
|
|
473319
|
-
writeFileSync as
|
|
473413
|
+
writeFileSync as writeFileSync30
|
|
473320
473414
|
} from "node:fs";
|
|
473321
473415
|
import path45 from "node:path";
|
|
473322
473416
|
function assertValidPackageName(packageName) {
|
|
@@ -473419,10 +473513,10 @@ function scaffoldLocalModPackage(options3) {
|
|
|
473419
473513
|
try {
|
|
473420
473514
|
mkdirSync41(targetModsDirectory, { recursive: true });
|
|
473421
473515
|
copyFileSync5(sourceFile, targetModPath);
|
|
473422
|
-
|
|
473516
|
+
writeFileSync30(packageJsonPath, `${JSON.stringify(createPackageJson(packageName, manifestEntry), null, 2)}
|
|
473423
473517
|
`);
|
|
473424
|
-
|
|
473425
|
-
|
|
473518
|
+
writeFileSync30(readmePath, createReadme(packageName));
|
|
473519
|
+
writeFileSync30(modGuidePath, createModGuide(packageName, manifestEntry));
|
|
473426
473520
|
} catch (error54) {
|
|
473427
473521
|
rmSync13(outputDirectory, { force: true, recursive: true });
|
|
473428
473522
|
throw error54;
|
|
@@ -476157,10 +476251,10 @@ import {
|
|
|
476157
476251
|
cpSync as cpSync2,
|
|
476158
476252
|
existsSync as existsSync58,
|
|
476159
476253
|
mkdtempSync as mkdtempSync4,
|
|
476160
|
-
readFileSync as
|
|
476254
|
+
readFileSync as readFileSync39,
|
|
476161
476255
|
rmSync as rmSync14,
|
|
476162
476256
|
statSync as statSync20,
|
|
476163
|
-
writeFileSync as
|
|
476257
|
+
writeFileSync as writeFileSync31
|
|
476164
476258
|
} from "node:fs";
|
|
476165
476259
|
import { mkdir as mkdir15, readdir as readdir14 } from "node:fs/promises";
|
|
476166
476260
|
import { tmpdir as tmpdir10 } from "node:os";
|
|
@@ -476522,7 +476616,7 @@ async function downloadDirectSkillFileSource(location, options3 = {}) {
|
|
|
476522
476616
|
try {
|
|
476523
476617
|
const sourceDir = join73(tmpDir, "skill");
|
|
476524
476618
|
await mkdir15(sourceDir, { recursive: true });
|
|
476525
|
-
|
|
476619
|
+
writeFileSync31(join73(sourceDir, "SKILL.md"), skillText, "utf8");
|
|
476526
476620
|
return { tmpDir, sourceDir };
|
|
476527
476621
|
} catch (error54) {
|
|
476528
476622
|
rmSync14(tmpDir, { recursive: true, force: true });
|
|
@@ -476574,7 +476668,7 @@ async function downloadClawHubSkillSource(location) {
|
|
|
476574
476668
|
if (!response.ok) {
|
|
476575
476669
|
throw new Error(`ClawHub download failed for ${location.slug}@${version2}: ${response.status}`);
|
|
476576
476670
|
}
|
|
476577
|
-
|
|
476671
|
+
writeFileSync31(zipPath, Buffer.from(await response.arrayBuffer()));
|
|
476578
476672
|
const { stdout } = await execFile16("unzip", ["-Z1", zipPath], {
|
|
476579
476673
|
timeout: 30000
|
|
476580
476674
|
});
|
|
@@ -476604,7 +476698,7 @@ function sanitizeSkillName(name) {
|
|
|
476604
476698
|
return trimmed;
|
|
476605
476699
|
}
|
|
476606
476700
|
function getSkillName(sourceDir) {
|
|
476607
|
-
const skillMd =
|
|
476701
|
+
const skillMd = readFileSync39(join73(sourceDir, "SKILL.md"), "utf8");
|
|
476608
476702
|
const { frontmatter } = parseFrontmatter(skillMd);
|
|
476609
476703
|
const frontmatterName = frontmatter.name;
|
|
476610
476704
|
const name = typeof frontmatterName === "string" && frontmatterName.trim() ? frontmatterName : basename28(sourceDir);
|
|
@@ -476654,7 +476748,7 @@ async function listSkillDirectories(params) {
|
|
|
476654
476748
|
let name = entry.name;
|
|
476655
476749
|
let description;
|
|
476656
476750
|
try {
|
|
476657
|
-
const skillMd =
|
|
476751
|
+
const skillMd = readFileSync39(skillMdPath, "utf8");
|
|
476658
476752
|
const { frontmatter } = parseFrontmatter(skillMd);
|
|
476659
476753
|
if (typeof frontmatter.name === "string" && frontmatter.name.trim()) {
|
|
476660
476754
|
name = frontmatter.name.trim();
|
|
@@ -480696,7 +480790,7 @@ var init_message_channel_gateway_tool = __esm(() => {
|
|
|
480696
480790
|
});
|
|
480697
480791
|
|
|
480698
480792
|
// src/channels/custom/scaffolding.ts
|
|
480699
|
-
import { existsSync as existsSync59, mkdirSync as mkdirSync42, rmSync as rmSync15, writeFileSync as
|
|
480793
|
+
import { existsSync as existsSync59, mkdirSync as mkdirSync42, rmSync as rmSync15, writeFileSync as writeFileSync32 } from "node:fs";
|
|
480700
480794
|
function removeUserPlugin(channelId) {
|
|
480701
480795
|
if (FIRST_PARTY_SET.has(channelId)) {
|
|
480702
480796
|
return;
|
|
@@ -482647,7 +482741,7 @@ var exports_bootstrap_tools = {};
|
|
|
482647
482741
|
__export(exports_bootstrap_tools, {
|
|
482648
482742
|
bootstrapBaseToolsIfNeeded: () => bootstrapBaseToolsIfNeeded
|
|
482649
482743
|
});
|
|
482650
|
-
import { existsSync as existsSync60, mkdirSync as mkdirSync43, writeFileSync as
|
|
482744
|
+
import { existsSync as existsSync60, mkdirSync as mkdirSync43, writeFileSync as writeFileSync33 } from "node:fs";
|
|
482651
482745
|
import { homedir as homedir42 } from "node:os";
|
|
482652
482746
|
import { join as join77 } from "node:path";
|
|
482653
482747
|
async function bootstrapBaseToolsIfNeeded() {
|
|
@@ -482658,7 +482752,7 @@ async function bootstrapBaseToolsIfNeeded() {
|
|
|
482658
482752
|
const success2 = await addBaseToolsToServer();
|
|
482659
482753
|
if (success2) {
|
|
482660
482754
|
mkdirSync43(join77(homedir42(), ".letta"), { recursive: true });
|
|
482661
|
-
|
|
482755
|
+
writeFileSync33(MARKER_PATH, new Date().toISOString(), "utf-8");
|
|
482662
482756
|
}
|
|
482663
482757
|
} catch (err) {
|
|
482664
482758
|
debugWarn("bootstrap", `Failed to bootstrap base tools: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -494451,7 +494545,7 @@ var init_mcp_client = __esm(() => {
|
|
|
494451
494545
|
init_streamableHttp();
|
|
494452
494546
|
DEFAULT_CLIENT_INFO = {
|
|
494453
494547
|
name: "letta-code",
|
|
494454
|
-
version: "0.30.
|
|
494548
|
+
version: "0.30.17"
|
|
494455
494549
|
};
|
|
494456
494550
|
});
|
|
494457
494551
|
|
|
@@ -494873,7 +494967,7 @@ var init_mcp_runtime = __esm(async () => {
|
|
|
494873
494967
|
});
|
|
494874
494968
|
|
|
494875
494969
|
// src/skills/builtin/creating-skills/scripts/validate-skill.ts
|
|
494876
|
-
import { existsSync as existsSync61, readFileSync as
|
|
494970
|
+
import { existsSync as existsSync61, readFileSync as readFileSync40 } from "node:fs";
|
|
494877
494971
|
import { basename as basename30, join as join79, resolve as resolve34 } from "node:path";
|
|
494878
494972
|
import { fileURLToPath as fileURLToPath11 } from "node:url";
|
|
494879
494973
|
function parseQuotedScalar(value) {
|
|
@@ -494975,7 +495069,7 @@ function validateSkill(skillPath) {
|
|
|
494975
495069
|
if (!existsSync61(skillMdPath)) {
|
|
494976
495070
|
return { valid: false, message: "SKILL.md not found" };
|
|
494977
495071
|
}
|
|
494978
|
-
const content =
|
|
495072
|
+
const content = readFileSync40(skillMdPath, "utf-8");
|
|
494979
495073
|
if (!content.startsWith("---")) {
|
|
494980
495074
|
return { valid: false, message: "No YAML frontmatter found" };
|
|
494981
495075
|
}
|
|
@@ -501397,8 +501491,8 @@ import {
|
|
|
501397
501491
|
copyFileSync as copyFileSync6,
|
|
501398
501492
|
existsSync as existsSync64,
|
|
501399
501493
|
mkdirSync as mkdirSync45,
|
|
501400
|
-
readFileSync as
|
|
501401
|
-
writeFileSync as
|
|
501494
|
+
readFileSync as readFileSync42,
|
|
501495
|
+
writeFileSync as writeFileSync35
|
|
501402
501496
|
} from "node:fs";
|
|
501403
501497
|
import { homedir as homedir47, platform as platform10 } from "node:os";
|
|
501404
501498
|
import { dirname as dirname35, join as join83 } from "node:path";
|
|
@@ -501467,7 +501561,7 @@ function keybindingExists(keybindingsPath) {
|
|
|
501467
501561
|
if (!existsSync64(keybindingsPath))
|
|
501468
501562
|
return false;
|
|
501469
501563
|
try {
|
|
501470
|
-
const content =
|
|
501564
|
+
const content = readFileSync42(keybindingsPath, { encoding: "utf-8" });
|
|
501471
501565
|
const keybindings = parseKeybindings(content);
|
|
501472
501566
|
if (!keybindings)
|
|
501473
501567
|
return false;
|
|
@@ -501500,7 +501594,7 @@ function installKeybinding(keybindingsPath) {
|
|
|
501500
501594
|
let backupPath = null;
|
|
501501
501595
|
if (existsSync64(keybindingsPath)) {
|
|
501502
501596
|
backupPath = createBackup(keybindingsPath);
|
|
501503
|
-
const content =
|
|
501597
|
+
const content = readFileSync42(keybindingsPath, { encoding: "utf-8" });
|
|
501504
501598
|
const parsed = parseKeybindings(content);
|
|
501505
501599
|
if (parsed === null) {
|
|
501506
501600
|
return {
|
|
@@ -501513,7 +501607,7 @@ function installKeybinding(keybindingsPath) {
|
|
|
501513
501607
|
keybindings.push(SHIFT_ENTER_KEYBINDING);
|
|
501514
501608
|
const newContent = `${JSON.stringify(keybindings, null, 2)}
|
|
501515
501609
|
`;
|
|
501516
|
-
|
|
501610
|
+
writeFileSync35(keybindingsPath, newContent, { encoding: "utf-8" });
|
|
501517
501611
|
return {
|
|
501518
501612
|
success: true,
|
|
501519
501613
|
backupPath: backupPath ?? undefined
|
|
@@ -501531,7 +501625,7 @@ function removeKeybinding(keybindingsPath) {
|
|
|
501531
501625
|
if (!existsSync64(keybindingsPath)) {
|
|
501532
501626
|
return { success: true };
|
|
501533
501627
|
}
|
|
501534
|
-
const content =
|
|
501628
|
+
const content = readFileSync42(keybindingsPath, { encoding: "utf-8" });
|
|
501535
501629
|
const keybindings = parseKeybindings(content);
|
|
501536
501630
|
if (!keybindings) {
|
|
501537
501631
|
return {
|
|
@@ -501542,7 +501636,7 @@ function removeKeybinding(keybindingsPath) {
|
|
|
501542
501636
|
const filtered = keybindings.filter((kb) => !(kb.key?.toLowerCase() === "shift+enter" && kb.command === "workbench.action.terminal.sendSequence" && kb.when?.includes("terminalFocus")));
|
|
501543
501637
|
const newContent = `${JSON.stringify(filtered, null, 2)}
|
|
501544
501638
|
`;
|
|
501545
|
-
|
|
501639
|
+
writeFileSync35(keybindingsPath, newContent, { encoding: "utf-8" });
|
|
501546
501640
|
return { success: true };
|
|
501547
501641
|
} catch (error54) {
|
|
501548
501642
|
const message = error54 instanceof Error ? error54.message : String(error54);
|
|
@@ -501708,7 +501802,7 @@ function wezTermDeleteFixExists(configPath) {
|
|
|
501708
501802
|
if (!existsSync64(configPath))
|
|
501709
501803
|
return false;
|
|
501710
501804
|
try {
|
|
501711
|
-
const content =
|
|
501805
|
+
const content = readFileSync42(configPath, { encoding: "utf-8" });
|
|
501712
501806
|
return content.includes("Letta Code: Fix Delete key") || content.includes("key = 'Delete'") && content.includes("SendString") && content.includes("\\x1b[3~");
|
|
501713
501807
|
} catch {
|
|
501714
501808
|
return false;
|
|
@@ -501725,14 +501819,14 @@ function installWezTermDeleteFix() {
|
|
|
501725
501819
|
if (existsSync64(configPath)) {
|
|
501726
501820
|
backupPath = `${configPath}.letta-backup`;
|
|
501727
501821
|
copyFileSync6(configPath, backupPath);
|
|
501728
|
-
content =
|
|
501822
|
+
content = readFileSync42(configPath, { encoding: "utf-8" });
|
|
501729
501823
|
}
|
|
501730
501824
|
content = injectWezTermDeleteFix(content);
|
|
501731
501825
|
const parentDir = dirname35(configPath);
|
|
501732
501826
|
if (!existsSync64(parentDir)) {
|
|
501733
501827
|
mkdirSync45(parentDir, { recursive: true });
|
|
501734
501828
|
}
|
|
501735
|
-
|
|
501829
|
+
writeFileSync35(configPath, content, { encoding: "utf-8" });
|
|
501736
501830
|
return {
|
|
501737
501831
|
success: true,
|
|
501738
501832
|
backupPath: backupPath ?? undefined
|
|
@@ -513236,9 +513330,9 @@ import {
|
|
|
513236
513330
|
existsSync as existsSync65,
|
|
513237
513331
|
mkdirSync as mkdirSync46,
|
|
513238
513332
|
mkdtempSync as mkdtempSync5,
|
|
513239
|
-
readFileSync as
|
|
513333
|
+
readFileSync as readFileSync43,
|
|
513240
513334
|
rmSync as rmSync16,
|
|
513241
|
-
writeFileSync as
|
|
513335
|
+
writeFileSync as writeFileSync36
|
|
513242
513336
|
} from "node:fs";
|
|
513243
513337
|
import { tmpdir as tmpdir11 } from "node:os";
|
|
513244
513338
|
import { dirname as dirname36, join as join85 } from "node:path";
|
|
@@ -513481,12 +513575,12 @@ function writeWorkflow(repoDir, workflowPath, content) {
|
|
|
513481
513575
|
const next = `${content.trimEnd()}
|
|
513482
513576
|
`;
|
|
513483
513577
|
if (existsSync65(absolutePath)) {
|
|
513484
|
-
const previous =
|
|
513578
|
+
const previous = readFileSync43(absolutePath, "utf8");
|
|
513485
513579
|
if (previous === next) {
|
|
513486
513580
|
return false;
|
|
513487
513581
|
}
|
|
513488
513582
|
}
|
|
513489
|
-
|
|
513583
|
+
writeFileSync36(absolutePath, next, "utf8");
|
|
513490
513584
|
return true;
|
|
513491
513585
|
}
|
|
513492
513586
|
function getDefaultBaseBranch(repoDir) {
|
|
@@ -517370,7 +517464,7 @@ __export(exports_generate_memory_viewer, {
|
|
|
517370
517464
|
generateAndOpenMemoryViewer: () => generateAndOpenMemoryViewer
|
|
517371
517465
|
});
|
|
517372
517466
|
import { execFile as execFileCb7 } from "node:child_process";
|
|
517373
|
-
import { chmodSync as chmodSync7, existsSync as existsSync66, mkdirSync as mkdirSync47, writeFileSync as
|
|
517467
|
+
import { chmodSync as chmodSync7, existsSync as existsSync66, mkdirSync as mkdirSync47, writeFileSync as writeFileSync37 } from "node:fs";
|
|
517374
517468
|
import { homedir as homedir50 } from "node:os";
|
|
517375
517469
|
import { join as join86 } from "node:path";
|
|
517376
517470
|
import { promisify as promisify17 } from "node:util";
|
|
@@ -517698,7 +517792,7 @@ async function generateAndOpenMemoryViewer(agentId, options3) {
|
|
|
517698
517792
|
chmodSync7(VIEWERS_DIR, 448);
|
|
517699
517793
|
} catch {}
|
|
517700
517794
|
const filePath = join86(VIEWERS_DIR, `memory-${encodeURIComponent(agentId)}.html`);
|
|
517701
|
-
|
|
517795
|
+
writeFileSync37(filePath, html5);
|
|
517702
517796
|
chmodSync7(filePath, 384);
|
|
517703
517797
|
const skipOpen = Boolean(process.env.TMUX) || Boolean(process.env.SSH_CONNECTION) || Boolean(process.env.SSH_TTY);
|
|
517704
517798
|
if (!skipOpen) {
|
|
@@ -541249,7 +541343,7 @@ __export(exports_generate_diff_viewer, {
|
|
|
541249
541343
|
generateAndOpenDiffViewer: () => generateAndOpenDiffViewer
|
|
541250
541344
|
});
|
|
541251
541345
|
import { execFile as execFileCb8 } from "node:child_process";
|
|
541252
|
-
import { chmodSync as chmodSync8, existsSync as existsSync68, mkdirSync as mkdirSync48, writeFileSync as
|
|
541346
|
+
import { chmodSync as chmodSync8, existsSync as existsSync68, mkdirSync as mkdirSync48, writeFileSync as writeFileSync38 } from "node:fs";
|
|
541253
541347
|
import { homedir as homedir52 } from "node:os";
|
|
541254
541348
|
import { isAbsolute as isAbsolute29, join as join89, resolve as resolve38 } from "node:path";
|
|
541255
541349
|
import { promisify as promisify18 } from "node:util";
|
|
@@ -541477,7 +541571,7 @@ async function generateAndOpenDiffViewer(targetPath) {
|
|
|
541477
541571
|
chmodSync8(VIEWERS_DIR2, 448);
|
|
541478
541572
|
} catch {}
|
|
541479
541573
|
const filePath = join89(VIEWERS_DIR2, `diff-${encodeURIComponent(worktreePath)}.html`);
|
|
541480
|
-
|
|
541574
|
+
writeFileSync38(filePath, html5);
|
|
541481
541575
|
chmodSync8(filePath, 384);
|
|
541482
541576
|
const skipOpen = shouldSkipOpen();
|
|
541483
541577
|
if (!skipOpen) {
|
|
@@ -543535,7 +543629,7 @@ __export(exports_shell_aliases, {
|
|
|
543535
543629
|
expandAliases: () => expandAliases,
|
|
543536
543630
|
clearAliasCache: () => clearAliasCache
|
|
543537
543631
|
});
|
|
543538
|
-
import { existsSync as existsSync69, readFileSync as
|
|
543632
|
+
import { existsSync as existsSync69, readFileSync as readFileSync44 } from "node:fs";
|
|
543539
543633
|
import { homedir as homedir53 } from "node:os";
|
|
543540
543634
|
import { join as join90 } from "node:path";
|
|
543541
543635
|
function parseAliasesFromFile(filePath) {
|
|
@@ -543544,7 +543638,7 @@ function parseAliasesFromFile(filePath) {
|
|
|
543544
543638
|
return aliases;
|
|
543545
543639
|
}
|
|
543546
543640
|
try {
|
|
543547
|
-
const content =
|
|
543641
|
+
const content = readFileSync44(filePath, "utf-8");
|
|
543548
543642
|
const lines = content.split(`
|
|
543549
543643
|
`);
|
|
543550
543644
|
let inFunction = false;
|
|
@@ -551914,7 +552008,7 @@ var init_conversation_switch_alert = __esm(() => {
|
|
|
551914
552008
|
|
|
551915
552009
|
// src/cli/app/use-submit-handler.ts
|
|
551916
552010
|
import { randomUUID as randomUUID40 } from "node:crypto";
|
|
551917
|
-
import { existsSync as existsSync70, readFileSync as
|
|
552011
|
+
import { existsSync as existsSync70, readFileSync as readFileSync45, renameSync as renameSync8, writeFileSync as writeFileSync39 } from "node:fs";
|
|
551918
552012
|
import { tmpdir as tmpdir12 } from "node:os";
|
|
551919
552013
|
import { join as join91 } from "node:path";
|
|
551920
552014
|
async function findCustomCommandByName(commandName) {
|
|
@@ -552616,7 +552710,7 @@ ${SYSTEM_REMINDER_CLOSE}`),
|
|
|
552616
552710
|
];
|
|
552617
552711
|
const personaPath = personaCandidates.find((candidate) => existsSync70(candidate));
|
|
552618
552712
|
if (personaPath) {
|
|
552619
|
-
const personaContent =
|
|
552713
|
+
const personaContent = readFileSync45(personaPath, "utf-8");
|
|
552620
552714
|
setCurrentPersonalityId(detectPersonalityFromPersonaFile(personaContent));
|
|
552621
552715
|
} else {
|
|
552622
552716
|
setCurrentPersonalityId(null);
|
|
@@ -553384,7 +553478,7 @@ Tip: Use /clear instead to clear the current message buffer.`;
|
|
|
553384
553478
|
fileContent.skills = skills;
|
|
553385
553479
|
}
|
|
553386
553480
|
const fileName = exportParams.conversation_id ? `${exportParams.conversation_id}.af` : `${agentId}.af`;
|
|
553387
|
-
|
|
553481
|
+
writeFileSync39(fileName, JSON.stringify(fileContent, null, 2));
|
|
553388
553482
|
let summary = `AgentFile exported to ${fileName}`;
|
|
553389
553483
|
if (skills.length > 0) {
|
|
553390
553484
|
summary += `
|
|
@@ -561735,4 +561829,4 @@ function registerBunOAuthFlows() {
|
|
|
561735
561829
|
registerBunOAuthFlows();
|
|
561736
561830
|
await init_src5().then(() => exports_src2);
|
|
561737
561831
|
|
|
561738
|
-
//# debugId=
|
|
561832
|
+
//# debugId=72DF88226DD9B50564756E2164756E21
|