lody 0.46.3-next.1 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +215 -178
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -22780,7 +22780,7 @@ Event: ${getEventDescription(event)}`);
|
|
|
22780
22780
|
const mergedOptions = {
|
|
22781
22781
|
...options,
|
|
22782
22782
|
dsn: options.dsn ?? "https://080f9de535ff335a1a0440d0e385f796@o4510491299086336.ingest.us.sentry.io/4510559045681152",
|
|
22783
|
-
environment: options.environment ?? "
|
|
22783
|
+
environment: options.environment ?? "production",
|
|
22784
22784
|
sendClientReports: options.sendClientReports ?? true,
|
|
22785
22785
|
transport: options.transport ?? makeNodeTransport,
|
|
22786
22786
|
stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),
|
|
@@ -36820,7 +36820,7 @@ Mongoose Error Code: ${error2.code}` : ""}`
|
|
|
36820
36820
|
return client;
|
|
36821
36821
|
}
|
|
36822
36822
|
const name = "lody";
|
|
36823
|
-
const version$4 = "0.
|
|
36823
|
+
const version$4 = "0.47.0";
|
|
36824
36824
|
const description = "Lody Agent CLI tool for managing remote command execution";
|
|
36825
36825
|
const type = "module";
|
|
36826
36826
|
const main$3 = "dist/index.js";
|
|
@@ -37068,15 +37068,15 @@ Mongoose Error Code: ${error2.code}` : ""}`
|
|
|
37068
37068
|
return "dev";
|
|
37069
37069
|
}
|
|
37070
37070
|
};
|
|
37071
|
-
const getRuntimeEnv = () => normalizeRuntimeEnv("
|
|
37071
|
+
const getRuntimeEnv = () => normalizeRuntimeEnv("production");
|
|
37072
37072
|
const isDevEnv = () => getRuntimeEnv() === "dev";
|
|
37073
37073
|
const runtimeEnv = getRuntimeEnv();
|
|
37074
|
-
const environment$1 = "
|
|
37074
|
+
const environment$1 = "production";
|
|
37075
37075
|
const dsn = "https://080f9de535ff335a1a0440d0e385f796@o4510491299086336.ingest.us.sentry.io/4510559045681152";
|
|
37076
37076
|
const postHogHost = process.env.LODY_POSTHOG_HOST ?? "https://us.i.posthog.com";
|
|
37077
37077
|
const postHogKey = process.env.LODY_POSTHOG_KEY ?? "phc_LFS5i5WIwg4irAhrG5oJR04iYPhReVZ3DdFZOKqCkjG";
|
|
37078
|
-
const tracesSampleRate = Number(process.env.SENTRY_TRACES_SAMPLE_RATE) ||
|
|
37079
|
-
const profilesSampleRate = Number(process.env.SENTRY_PROFILES_SAMPLE_RATE) || 0.
|
|
37078
|
+
const tracesSampleRate = Number(process.env.SENTRY_TRACES_SAMPLE_RATE) || 0.2;
|
|
37079
|
+
const profilesSampleRate = Number(process.env.SENTRY_PROFILES_SAMPLE_RATE) || 0.1;
|
|
37080
37080
|
const sentryEnabled = runtimeEnv !== "dev" && true;
|
|
37081
37081
|
const postHogEnabled = runtimeEnv !== "dev" && process.env.LODY_POSTHOG_DISABLED !== "1";
|
|
37082
37082
|
const release = `${name}@${version$4}`;
|
|
@@ -64608,16 +64608,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
64608
64608
|
}
|
|
64609
64609
|
return _v4(options, buf, offset2);
|
|
64610
64610
|
}
|
|
64611
|
-
let LODY_AUTH_URL = "https://
|
|
64611
|
+
let LODY_AUTH_URL = "https://nautical-curlew-181.convex.cloud";
|
|
64612
64612
|
let LODY_AUTH_SITE_URL = "";
|
|
64613
|
-
let LODY_SERVER_URL = "https://lody
|
|
64614
|
-
let SITE_URL = "https://
|
|
64613
|
+
let LODY_SERVER_URL = "https://api.lody.ai";
|
|
64614
|
+
let SITE_URL = "https://lody.ai";
|
|
64615
64615
|
let SITE_APP_BASE_PATH = "";
|
|
64616
64616
|
const loadEnv = () => {
|
|
64617
|
-
LODY_AUTH_URL = "https://
|
|
64617
|
+
LODY_AUTH_URL = "https://nautical-curlew-181.convex.cloud";
|
|
64618
64618
|
LODY_AUTH_SITE_URL = "";
|
|
64619
|
-
LODY_SERVER_URL = "https://lody
|
|
64620
|
-
SITE_URL = "https://
|
|
64619
|
+
LODY_SERVER_URL = "https://api.lody.ai";
|
|
64620
|
+
SITE_URL = "https://lody.ai";
|
|
64621
64621
|
SITE_APP_BASE_PATH = process.env["SITE_APP_BASE_PATH"] ?? "";
|
|
64622
64622
|
};
|
|
64623
64623
|
const MACHINE_ID_FILE_NAME = "machine-id";
|
|
@@ -91164,7 +91164,8 @@ ${val.stack}`;
|
|
|
91164
91164
|
const requestUrl = this.subresourceEndpoint("/bootstrap");
|
|
91165
91165
|
const response = await this.http.fetchAuthorized(requestUrl, {
|
|
91166
91166
|
method: "GET",
|
|
91167
|
-
headers: this.mergeHeaders(input2.headers)
|
|
91167
|
+
headers: this.mergeHeaders(input2.headers),
|
|
91168
|
+
signal: input2.signal
|
|
91168
91169
|
}, this.timeoutConfig.connectTimeoutMs, "connect");
|
|
91169
91170
|
if (!response.ok) return {
|
|
91170
91171
|
ok: false,
|
|
@@ -92710,8 +92711,10 @@ stream:${scope2.streamId}`;
|
|
|
92710
92711
|
}
|
|
92711
92712
|
};
|
|
92712
92713
|
}
|
|
92713
|
-
async bootstrap() {
|
|
92714
|
-
const result = await this.client.bootstrap(
|
|
92714
|
+
async bootstrap(signal) {
|
|
92715
|
+
const result = await this.client.bootstrap({
|
|
92716
|
+
signal
|
|
92717
|
+
});
|
|
92715
92718
|
if (!result.ok) throw this.toTransportFailure(result.result);
|
|
92716
92719
|
return {
|
|
92717
92720
|
nextOffset: result.result.nextOffset,
|
|
@@ -94090,7 +94093,7 @@ stream:${scope2.streamId}`;
|
|
|
94090
94093
|
async startJoin(state2) {
|
|
94091
94094
|
try {
|
|
94092
94095
|
state2.requestController ??= new AbortController();
|
|
94093
|
-
const joined = await this.performInitialJoinSync(state2.liveMode);
|
|
94096
|
+
const joined = await this.performInitialJoinSync(state2.liveMode, state2.requestController?.signal);
|
|
94094
94097
|
state2.cursor = joined.cursor;
|
|
94095
94098
|
state2.streamCursor = joined.streamCursor;
|
|
94096
94099
|
state2.liveMode = joined.liveMode;
|
|
@@ -94133,8 +94136,8 @@ stream:${scope2.streamId}`;
|
|
|
94133
94136
|
}
|
|
94134
94137
|
return cursor;
|
|
94135
94138
|
}
|
|
94136
|
-
async performInitialJoinSync(preferredLiveMode) {
|
|
94137
|
-
const initial = await this.finalizeDirectLocalAppendIfNeeded(await this.resolveInitialRemoteState());
|
|
94139
|
+
async performInitialJoinSync(preferredLiveMode, signal) {
|
|
94140
|
+
const initial = await this.finalizeDirectLocalAppendIfNeeded(await this.resolveInitialRemoteState(signal));
|
|
94138
94141
|
let cursor = initial.cursor;
|
|
94139
94142
|
let localExportRefVersion = cursor.serverLowerBoundVersion;
|
|
94140
94143
|
let streamCursor = initial.streamCursor;
|
|
@@ -94143,7 +94146,7 @@ stream:${scope2.streamId}`;
|
|
|
94143
94146
|
localExportRefVersion = exportedLocal.nextRefVersion;
|
|
94144
94147
|
if (exportedLocal.batch != null) {
|
|
94145
94148
|
cursor = await this.appendLocalBatch(cursor, exportedLocal.batch);
|
|
94146
|
-
const caughtUp = await this.catchup(cursor);
|
|
94149
|
+
const caughtUp = await this.catchup(cursor, void 0, void 0, void 0, signal);
|
|
94147
94150
|
cursor = caughtUp.cursor;
|
|
94148
94151
|
streamCursor = caughtUp.streamCursor;
|
|
94149
94152
|
}
|
|
@@ -94162,31 +94165,37 @@ stream:${scope2.streamId}`;
|
|
|
94162
94165
|
serverLowerBoundVersion: this.adapter.emptyVersion()
|
|
94163
94166
|
});
|
|
94164
94167
|
}
|
|
94165
|
-
async resolveInitialRemoteState() {
|
|
94168
|
+
async resolveInitialRemoteState(signal) {
|
|
94166
94169
|
const loaded = await this.remoteCursorStore.load(this.streamUrl);
|
|
94167
94170
|
const cursor = loaded ?? this.createInitialCursor();
|
|
94168
94171
|
try {
|
|
94169
|
-
if (loaded == null) return await this.bootstrapState(cursor
|
|
94172
|
+
if (loaded == null) return await this.bootstrapState(cursor, {
|
|
94173
|
+
signal
|
|
94174
|
+
});
|
|
94170
94175
|
const caughtUp = await this.catchupOrGone(cursor, {
|
|
94171
|
-
goneStrategy: "return-gone"
|
|
94176
|
+
goneStrategy: "return-gone",
|
|
94177
|
+
signal
|
|
94172
94178
|
});
|
|
94173
|
-
if ("kind" in caughtUp) return await this.recoverFromGoneWithLocalBootstrap(cursor);
|
|
94179
|
+
if ("kind" in caughtUp) return await this.recoverFromGoneWithLocalBootstrap(cursor, signal);
|
|
94174
94180
|
return caughtUp;
|
|
94175
94181
|
} catch (error2) {
|
|
94176
94182
|
if (!isStreamNotFoundError(error2) || !this.createStreamIfMissing) throw error2;
|
|
94177
94183
|
await this.ensureStreamExists();
|
|
94178
|
-
return await this.bootstrapState(this.createInitialCursor()
|
|
94184
|
+
return await this.bootstrapState(this.createInitialCursor(), {
|
|
94185
|
+
signal
|
|
94186
|
+
});
|
|
94179
94187
|
}
|
|
94180
94188
|
}
|
|
94181
94189
|
async bootstrapState(cursor, options = {}) {
|
|
94182
94190
|
const cursorManager = options.cursorManager ?? this.cursorManager;
|
|
94183
|
-
const result = await this.client.bootstrap();
|
|
94191
|
+
const result = await this.client.bootstrap(options.signal);
|
|
94184
94192
|
let saved = await cursorManager.applyBootstrapPayload(cursor, result.snapshot, result.updates, result.nextOffset);
|
|
94185
94193
|
let bootstrapCursor = result.streamCursor;
|
|
94186
94194
|
if (!result.upToDate) {
|
|
94187
94195
|
const caughtUp = await this.catchupOrGone(saved, {
|
|
94188
94196
|
streamCursor: bootstrapCursor,
|
|
94189
|
-
cursorManager
|
|
94197
|
+
cursorManager,
|
|
94198
|
+
signal: options.signal
|
|
94190
94199
|
});
|
|
94191
94200
|
if ("kind" in caughtUp) throw new Error("bootstrap catch-up unexpectedly returned gone");
|
|
94192
94201
|
saved = caughtUp.cursor;
|
|
@@ -94197,11 +94206,12 @@ stream:${scope2.streamId}`;
|
|
|
94197
94206
|
streamCursor: bootstrapCursor
|
|
94198
94207
|
};
|
|
94199
94208
|
}
|
|
94200
|
-
async catchup(cursor, live, streamCursor, onRemoteVersionApplied) {
|
|
94209
|
+
async catchup(cursor, live, streamCursor, onRemoteVersionApplied, signal) {
|
|
94201
94210
|
const result = await this.catchupOrGone(cursor, {
|
|
94202
94211
|
live,
|
|
94203
94212
|
streamCursor,
|
|
94204
|
-
onRemoteVersionApplied
|
|
94213
|
+
onRemoteVersionApplied,
|
|
94214
|
+
signal
|
|
94205
94215
|
});
|
|
94206
94216
|
if ("kind" in result) throw new Error("catchup unexpectedly returned gone");
|
|
94207
94217
|
return result;
|
|
@@ -94213,7 +94223,7 @@ stream:${scope2.streamId}`;
|
|
|
94213
94223
|
const cursorManager = options.cursorManager ?? this.cursorManager;
|
|
94214
94224
|
while (true) {
|
|
94215
94225
|
const requestOffset = current2.nextOffset;
|
|
94216
|
-
const response = await this.client.readFromOffset(requestOffset, currentStreamCursor, options.live);
|
|
94226
|
+
const response = await this.client.readFromOffset(requestOffset, currentStreamCursor, options.live, options.signal);
|
|
94217
94227
|
if (response.kind === "gone") {
|
|
94218
94228
|
if (goneStrategy === "return-gone") return StreamsCrdt2.GONE_CATCHUP;
|
|
94219
94229
|
return await this.bootstrapState({
|
|
@@ -94221,7 +94231,8 @@ stream:${scope2.streamId}`;
|
|
|
94221
94231
|
nextOffset: "-1",
|
|
94222
94232
|
serverLowerBoundVersion: this.adapter.emptyVersion()
|
|
94223
94233
|
}, {
|
|
94224
|
-
cursorManager
|
|
94234
|
+
cursorManager,
|
|
94235
|
+
signal: options.signal
|
|
94225
94236
|
});
|
|
94226
94237
|
}
|
|
94227
94238
|
const result = response.value;
|
|
@@ -94388,9 +94399,10 @@ stream:${scope2.streamId}`;
|
|
|
94388
94399
|
if (isolated == null) return null;
|
|
94389
94400
|
return this.createCursorManager(isolated, async (cursor) => cursor);
|
|
94390
94401
|
}
|
|
94391
|
-
async inferRemoteAndAppendLocal(bootstrapCursor, cursorManager) {
|
|
94402
|
+
async inferRemoteAndAppendLocal(bootstrapCursor, cursorManager, signal) {
|
|
94392
94403
|
const inferredRemote = await this.bootstrapState(bootstrapCursor, {
|
|
94393
|
-
cursorManager
|
|
94404
|
+
cursorManager,
|
|
94405
|
+
signal
|
|
94394
94406
|
});
|
|
94395
94407
|
let pendingAppend;
|
|
94396
94408
|
if (this.frozenLocalAppend != null) {
|
|
@@ -94400,23 +94412,26 @@ stream:${scope2.streamId}`;
|
|
|
94400
94412
|
const localBatch = this.exportUpdates(inferredRemote.cursor.serverLowerBoundVersion);
|
|
94401
94413
|
if (localBatch.batch != null) pendingAppend = await this.appendLocalBatchRemote(inferredRemote.cursor, localBatch.batch);
|
|
94402
94414
|
}
|
|
94403
|
-
const result = await this.bootstrapState(bootstrapCursor
|
|
94415
|
+
const result = await this.bootstrapState(bootstrapCursor, {
|
|
94416
|
+
signal
|
|
94417
|
+
});
|
|
94404
94418
|
if (pendingAppend != null) this.commitProducerAck(pendingAppend.producerAck);
|
|
94405
94419
|
return result;
|
|
94406
94420
|
}
|
|
94407
|
-
async recoverFromGoneWithLocalBootstrap(cursor) {
|
|
94421
|
+
async recoverFromGoneWithLocalBootstrap(cursor, signal) {
|
|
94408
94422
|
const isolatedCursorManager = await this.createIsolatedCursorManager();
|
|
94409
94423
|
const bootstrapCursor = {
|
|
94410
94424
|
...cursor,
|
|
94411
94425
|
nextOffset: "-1",
|
|
94412
94426
|
serverLowerBoundVersion: this.adapter.emptyVersion()
|
|
94413
94427
|
};
|
|
94414
|
-
if (isolatedCursorManager != null) return await this.inferRemoteAndAppendLocal(bootstrapCursor, isolatedCursorManager);
|
|
94428
|
+
if (isolatedCursorManager != null) return await this.inferRemoteAndAppendLocal(bootstrapCursor, isolatedCursorManager, signal);
|
|
94415
94429
|
const preservedLocalSnapshot = this.adapter.exportSnapshot();
|
|
94416
94430
|
let restoredLocalSnapshot = false;
|
|
94417
94431
|
try {
|
|
94418
94432
|
const inferredRemote = await this.bootstrapState(bootstrapCursor, {
|
|
94419
|
-
cursorManager: this.volatileCursorManager
|
|
94433
|
+
cursorManager: this.volatileCursorManager,
|
|
94434
|
+
signal
|
|
94420
94435
|
});
|
|
94421
94436
|
await this.adapter.applySnapshot(preservedLocalSnapshot);
|
|
94422
94437
|
restoredLocalSnapshot = true;
|
|
@@ -94428,7 +94443,9 @@ stream:${scope2.streamId}`;
|
|
|
94428
94443
|
const localBatch = this.exportUpdates(inferredRemote.cursor.serverLowerBoundVersion);
|
|
94429
94444
|
if (localBatch.batch != null) pendingAppend = await this.appendLocalBatchRemote(inferredRemote.cursor, localBatch.batch);
|
|
94430
94445
|
}
|
|
94431
|
-
const result = await this.bootstrapState(bootstrapCursor
|
|
94446
|
+
const result = await this.bootstrapState(bootstrapCursor, {
|
|
94447
|
+
signal
|
|
94448
|
+
});
|
|
94432
94449
|
if (pendingAppend != null) this.commitProducerAck(pendingAppend.producerAck);
|
|
94433
94450
|
return result;
|
|
94434
94451
|
} catch (error2) {
|
|
@@ -94465,6 +94482,8 @@ stream:${scope2.streamId}`;
|
|
|
94465
94482
|
...state2.cursor,
|
|
94466
94483
|
nextOffset: "-1",
|
|
94467
94484
|
serverLowerBoundVersion: this.adapter.emptyVersion()
|
|
94485
|
+
}, {
|
|
94486
|
+
signal: capturedController?.signal
|
|
94468
94487
|
});
|
|
94469
94488
|
state2.cursor = bootstrapped2.cursor;
|
|
94470
94489
|
state2.streamCursor = bootstrapped2.streamCursor;
|
|
@@ -114189,7 +114208,7 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
|
|
|
114189
114208
|
const agent = proxyUrl ? new distExports.HttpsProxyAgent(proxyUrl) : void 0;
|
|
114190
114209
|
const logger2 = getLogger("loro:websocket");
|
|
114191
114210
|
logger2.debug(`Creating WebSocket url=${sanitizeUrlForLogging(urlString)} proxy=${proxyUrl ? redactProxyUrl(proxyUrl) : "none"} agentValid=${!!agent}`);
|
|
114192
|
-
if (
|
|
114211
|
+
if (globalThis.Bun && proxyUrl) {
|
|
114193
114212
|
logger2.debug("Bun does not support WebSocket proxy yet: https://github.com/oven-sh/bun/issues/14522");
|
|
114194
114213
|
}
|
|
114195
114214
|
super(urlString, protocols, {
|
|
@@ -115700,12 +115719,12 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
|
|
|
115700
115719
|
}));
|
|
115701
115720
|
return result.nextOffset;
|
|
115702
115721
|
},
|
|
115703
|
-
longPollJson: async (streamId, state2,
|
|
115722
|
+
longPollJson: async (streamId, state2, readOptions) => {
|
|
115704
115723
|
const result = unwrapStreamResult("long-poll stream", streamId, await getStreamClient(streamId).readOnce({
|
|
115705
115724
|
offset: state2.nextOffset ?? "now",
|
|
115706
115725
|
cursor: state2.cursor,
|
|
115707
115726
|
live: "long-poll",
|
|
115708
|
-
signal:
|
|
115727
|
+
signal: readOptions?.signal
|
|
115709
115728
|
}));
|
|
115710
115729
|
return {
|
|
115711
115730
|
messages: result.payload === null ? [] : parseJsonBatchPayload(result.payload, streamId, "long-poll read"),
|
|
@@ -115714,13 +115733,13 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
|
|
|
115714
115733
|
upToDate: result.upToDate
|
|
115715
115734
|
};
|
|
115716
115735
|
},
|
|
115717
|
-
readJsonLive: async (streamId, state2, onBatch,
|
|
115736
|
+
readJsonLive: async (streamId, state2, onBatch, liveOptions) => {
|
|
115718
115737
|
const pendingMessages = [];
|
|
115719
115738
|
const streamClient = getStreamClient(streamId);
|
|
115720
115739
|
for await (const event of streamClient.live({
|
|
115721
115740
|
offset: state2.nextOffset ?? "now",
|
|
115722
115741
|
mode: "auto",
|
|
115723
|
-
signal:
|
|
115742
|
+
signal: liveOptions?.signal
|
|
115724
115743
|
})) {
|
|
115725
115744
|
switch (event.type) {
|
|
115726
115745
|
case "data":
|
|
@@ -117316,7 +117335,7 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
|
|
|
117316
117335
|
throw err2;
|
|
117317
117336
|
}
|
|
117318
117337
|
logger2.debug(`[${sessionId}] ${operationName} failed after ${attempt + 1} attempt(s) with transport error: ${formatErrorMessage(err2)}`);
|
|
117319
|
-
reportError(`agent-client:${operationName}`, err2 instanceof Error ? err2 : new Error(String(err2)));
|
|
117338
|
+
void reportError(`agent-client:${operationName}`, err2 instanceof Error ? err2 : new Error(String(err2)));
|
|
117320
117339
|
return void 0;
|
|
117321
117340
|
}
|
|
117322
117341
|
}
|
|
@@ -118918,6 +118937,7 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
|
|
|
118918
118937
|
case "idle":
|
|
118919
118938
|
return "idle";
|
|
118920
118939
|
}
|
|
118940
|
+
return "unknown";
|
|
118921
118941
|
};
|
|
118922
118942
|
class SessionHeartbeat {
|
|
118923
118943
|
constructor(sessionId, workspaceDocument, logger2, options = {}) {
|
|
@@ -120736,11 +120756,7 @@ path=/${options.repoFullName}.git
|
|
|
120736
120756
|
});
|
|
120737
120757
|
}
|
|
120738
120758
|
async function fetchAcpCapabilities(cliType, agentType, logger2, env2) {
|
|
120739
|
-
const
|
|
120740
|
-
const workdir = path__default.join(os__default.tmpdir(), "lody-acp-capabilities", `${cliType}-${safeAgentType}`);
|
|
120741
|
-
fs__default.mkdirSync(workdir, {
|
|
120742
|
-
recursive: true
|
|
120743
|
-
});
|
|
120759
|
+
const workdir = process.cwd();
|
|
120744
120760
|
let capturedCommands;
|
|
120745
120761
|
let commandsResolve;
|
|
120746
120762
|
const commandsPromise = new Promise((resolve2) => {
|
|
@@ -121892,91 +121908,94 @@ $mem | ConvertTo-Json -Compress
|
|
|
121892
121908
|
const runtime = this.createTurnRuntime(sessionId, turnId, userTurnId, session);
|
|
121893
121909
|
this.registerTurnRuntime(runtime);
|
|
121894
121910
|
const self2 = this;
|
|
121895
|
-
const program2 = scoped(acquireRelease(succeed(runtime), (
|
|
121911
|
+
const program2 = scoped(acquireRelease(succeed(runtime), (turnRuntime, exit2) => gen(function* () {
|
|
121896
121912
|
const wasInterrupted = isFailure(exit2) && isInterrupted(exit2.cause);
|
|
121897
|
-
const wasCancelled =
|
|
121913
|
+
const wasCancelled = turnRuntime.cancelRequested || self2.isTurnCancelled(sessionId, turnRuntime.turnId) || wasInterrupted;
|
|
121898
121914
|
if (wasCancelled) {
|
|
121899
121915
|
yield* self2.finalizeCancelledTurnEffect({
|
|
121900
121916
|
sessionId,
|
|
121901
121917
|
sessionDoc,
|
|
121902
|
-
turnId:
|
|
121918
|
+
turnId: turnRuntime.turnId,
|
|
121903
121919
|
userTurnId,
|
|
121904
|
-
session:
|
|
121905
|
-
pendingSession:
|
|
121906
|
-
terminateSession:
|
|
121907
|
-
reportTurnError: self2.shouldReportCancelledTurnError(
|
|
121920
|
+
session: turnRuntime.session,
|
|
121921
|
+
pendingSession: turnRuntime.pendingSession,
|
|
121922
|
+
terminateSession: turnRuntime.terminateSessionOnCancel,
|
|
121923
|
+
reportTurnError: self2.shouldReportCancelledTurnError(turnRuntime)
|
|
121908
121924
|
});
|
|
121909
121925
|
}
|
|
121910
|
-
self2.releaseTurnRuntime(sessionId,
|
|
121911
|
-
})).pipe(flatMap$1((
|
|
121912
|
-
yield* self2.tryPromise(() => self2.deps.createAssistantEntryForTurn(sessionId, sessionDoc,
|
|
121926
|
+
self2.releaseTurnRuntime(sessionId, turnRuntime.turnId);
|
|
121927
|
+
})).pipe(flatMap$1((turnRuntime) => gen(function* () {
|
|
121928
|
+
yield* self2.tryPromise(() => self2.deps.createAssistantEntryForTurn(sessionId, sessionDoc, turnRuntime.turnId, turnRuntime.session?.agentClient?.currentModel, userTurnId));
|
|
121913
121929
|
yield* self2.acquireSessionHeartbeat(sessionId);
|
|
121914
121930
|
if (userTurnId) {
|
|
121915
121931
|
yield* self2.tryPromise(() => self2.setDispatchProcessing(sessionId, sessionDoc, userTurnId));
|
|
121916
121932
|
}
|
|
121917
121933
|
const bindSession = (nextSession) => {
|
|
121918
|
-
|
|
121919
|
-
|
|
121934
|
+
runtime.session = nextSession;
|
|
121935
|
+
runtime.pendingSession = void 0;
|
|
121920
121936
|
};
|
|
121921
121937
|
const trackPendingSession = (pendingSession, pendingOptions) => gen(function* () {
|
|
121922
121938
|
const pending2 = yield* try_({
|
|
121923
121939
|
try: () => typeof pendingSession === "function" ? pendingSession() : pendingSession,
|
|
121924
121940
|
catch: (error2) => error2
|
|
121925
121941
|
});
|
|
121926
|
-
|
|
121942
|
+
runtime.pendingSession = pending2;
|
|
121927
121943
|
if (pendingOptions?.terminateOnCancel) {
|
|
121928
|
-
|
|
121944
|
+
runtime.terminateSessionOnCancel = true;
|
|
121929
121945
|
}
|
|
121930
121946
|
return yield* self2.tryPromise(() => pending2);
|
|
121931
121947
|
});
|
|
121932
121948
|
const abortIfCancelled = (cancelOptions) => gen(function* () {
|
|
121933
121949
|
if (cancelOptions?.terminateSession) {
|
|
121934
|
-
|
|
121950
|
+
runtime.terminateSessionOnCancel = true;
|
|
121935
121951
|
}
|
|
121936
121952
|
const userTurnWasCancelled = yield* self2.tryPromise(() => self2.isUserTurnCancelled(sessionDoc, userTurnId));
|
|
121937
|
-
if (!
|
|
121938
|
-
return;
|
|
121953
|
+
if (!runtime.cancelRequested && !self2.isTurnCancelled(sessionId, runtime.turnId) && !userTurnWasCancelled) {
|
|
121954
|
+
return void 0;
|
|
121939
121955
|
}
|
|
121940
121956
|
yield* self2.finalizeCancelledTurnEffect({
|
|
121941
121957
|
sessionId,
|
|
121942
121958
|
sessionDoc,
|
|
121943
|
-
turnId:
|
|
121959
|
+
turnId: runtime.turnId,
|
|
121944
121960
|
userTurnId,
|
|
121945
|
-
session:
|
|
121946
|
-
pendingSession:
|
|
121947
|
-
terminateSession: cancelOptions?.terminateSession ??
|
|
121948
|
-
reportTurnError: self2.shouldReportCancelledTurnError(
|
|
121961
|
+
session: runtime.session,
|
|
121962
|
+
pendingSession: runtime.pendingSession,
|
|
121963
|
+
terminateSession: cancelOptions?.terminateSession ?? runtime.terminateSessionOnCancel,
|
|
121964
|
+
reportTurnError: self2.shouldReportCancelledTurnError(runtime)
|
|
121949
121965
|
});
|
|
121950
|
-
|
|
121966
|
+
yield* fail(new SessionTurnCancelled({
|
|
121951
121967
|
sessionId,
|
|
121952
|
-
turnId:
|
|
121968
|
+
turnId: runtime.turnId
|
|
121953
121969
|
}));
|
|
121970
|
+
return void 0;
|
|
121954
121971
|
});
|
|
121955
|
-
const patchAssistantEntry = () => self2.tryPromise(() => self2.deps.createAssistantEntryForTurn(sessionId, sessionDoc,
|
|
121972
|
+
const patchAssistantEntry = () => self2.tryPromise(() => self2.deps.createAssistantEntryForTurn(sessionId, sessionDoc, runtime.turnId, runtime.session?.agentClient?.currentModel, userTurnId));
|
|
121956
121973
|
const prompt2 = (promptBlocks) => gen(function* () {
|
|
121957
|
-
const activeSession =
|
|
121974
|
+
const activeSession = runtime.session;
|
|
121958
121975
|
const agentClient = activeSession?.agentClient;
|
|
121959
121976
|
const acpSessionId = activeSession?.acpSessionId;
|
|
121960
121977
|
if (!agentClient || !acpSessionId) {
|
|
121961
|
-
|
|
121978
|
+
yield* fail(new Error("Agent session was not ready"));
|
|
121979
|
+
return void 0;
|
|
121962
121980
|
}
|
|
121963
|
-
|
|
121964
|
-
|
|
121981
|
+
runtime.terminateSessionOnCancel = false;
|
|
121982
|
+
runtime.promptStarted = true;
|
|
121965
121983
|
yield* acquireUseRelease(sync(() => {
|
|
121966
|
-
|
|
121984
|
+
runtime.promptInFlight = true;
|
|
121967
121985
|
return activeSession;
|
|
121968
121986
|
}), () => self2.tryPromise((signal) => agentClient.prompt(acpSessionId, promptBlocks, {
|
|
121969
121987
|
signal
|
|
121970
121988
|
})).pipe(catchAll((error2) => sync(() => {
|
|
121971
|
-
|
|
121989
|
+
runtime.promptFailed = true;
|
|
121972
121990
|
}).pipe(flatMap$1(() => fail(error2))))), () => sync(() => {
|
|
121973
|
-
|
|
121991
|
+
runtime.promptInFlight = false;
|
|
121974
121992
|
}));
|
|
121975
|
-
self2.deps.clearActiveTurnId(sessionId,
|
|
121993
|
+
self2.deps.clearActiveTurnId(sessionId, runtime.turnId);
|
|
121994
|
+
return void 0;
|
|
121976
121995
|
});
|
|
121977
121996
|
yield* body({
|
|
121978
|
-
turnId:
|
|
121979
|
-
runtime
|
|
121997
|
+
turnId: runtime.turnId,
|
|
121998
|
+
runtime,
|
|
121980
121999
|
bindSession,
|
|
121981
122000
|
trackPendingSession,
|
|
121982
122001
|
abortIfCancelled,
|
|
@@ -122649,7 +122668,8 @@ $mem | ConvertTo-Json -Compress
|
|
|
122649
122668
|
}, ({ turnId, runtime, bindSession, trackPendingSession, abortIfCancelled, patchAssistantEntry, prompt: prompt2 }) => gen(function* () {
|
|
122650
122669
|
yield* abortIfCancelled();
|
|
122651
122670
|
if (project?.kind === "local" && !workdir) {
|
|
122652
|
-
|
|
122671
|
+
yield* fail(new Error(`Local project not found in workspace: ${project.localProjectId}`));
|
|
122672
|
+
return void 0;
|
|
122653
122673
|
}
|
|
122654
122674
|
if (shouldPrepareWorktree) {
|
|
122655
122675
|
yield* self2.tryPromise(() => sessionDoc.setStatus(SessionStatusFactory.initializing("git-clone")));
|
|
@@ -122734,6 +122754,7 @@ $mem | ConvertTo-Json -Compress
|
|
|
122734
122754
|
yield* abortIfCancelled();
|
|
122735
122755
|
self2.clearTurnCancellation(sessionId, turnId);
|
|
122736
122756
|
yield* self2.tryPromise(() => self2.deps.processMessageQueue(sessionId));
|
|
122757
|
+
return void 0;
|
|
122737
122758
|
}));
|
|
122738
122759
|
}
|
|
122739
122760
|
async cancelSession(message) {
|
|
@@ -123365,6 +123386,7 @@ $mem | ConvertTo-Json -Compress
|
|
|
123365
123386
|
case "cli_token_invalid":
|
|
123366
123387
|
return "CLI token is invalid or has been revoked.";
|
|
123367
123388
|
}
|
|
123389
|
+
return "Machine access was denied.";
|
|
123368
123390
|
}
|
|
123369
123391
|
async markDispatchAccessDenied(sessionId, sessionDoc, userTurnId, reason) {
|
|
123370
123392
|
const message = this.getAccessDeniedMessage(reason);
|
|
@@ -124302,7 +124324,7 @@ $mem | ConvertTo-Json -Compress
|
|
|
124302
124324
|
getActiveTurnId: (sessionId) => this.store.getActiveTurnId(sessionId),
|
|
124303
124325
|
clearActiveTurnId: (sessionId, turnId) => this.clearActiveTurnIdIfMatches(sessionId, turnId),
|
|
124304
124326
|
buildAcpPromptBlocks: async (args2) => await this.buildAcpPromptBlocks(args2),
|
|
124305
|
-
applyAcpModeAndModel: async (session,
|
|
124327
|
+
applyAcpModeAndModel: async (session, acpConfig) => await this.applyAcpModeAndModel(session, acpConfig),
|
|
124306
124328
|
createAssistantEntryForTurn: async (sessionId, sessionDoc, turnId, modelInfo, userTurnId) => await this.createAssistantEntryForTurn(sessionId, sessionDoc, turnId, modelInfo, userTurnId),
|
|
124307
124329
|
turnFinalization: {
|
|
124308
124330
|
finalizeACPState: async (sessionId) => await this.finalizeACPState(sessionId),
|
|
@@ -124607,7 +124629,7 @@ $mem | ConvertTo-Json -Compress
|
|
|
124607
124629
|
trackPendingContextWindowPersist(sessionId, promise) {
|
|
124608
124630
|
const state2 = this.store.get(sessionId);
|
|
124609
124631
|
state2.pendingContextWindowHandlers.add(promise);
|
|
124610
|
-
promise.finally(() => {
|
|
124632
|
+
void promise.finally(() => {
|
|
124611
124633
|
state2.pendingContextWindowHandlers.delete(promise);
|
|
124612
124634
|
});
|
|
124613
124635
|
}
|
|
@@ -125075,7 +125097,7 @@ $mem | ConvertTo-Json -Compress
|
|
|
125075
125097
|
}
|
|
125076
125098
|
}
|
|
125077
125099
|
setupSessionEventHandlers() {
|
|
125078
|
-
this.sessionManager.on("output",
|
|
125100
|
+
this.sessionManager.on("output", (output) => {
|
|
125079
125101
|
this.logger.debug(`Output from session [${output.sessionId}]: <${output.data.length} bytes>`);
|
|
125080
125102
|
});
|
|
125081
125103
|
this.sessionManager.on("onACPUpdateMessage", (sessionId, update2) => {
|
|
@@ -125085,53 +125107,59 @@ $mem | ConvertTo-Json -Compress
|
|
|
125085
125107
|
const promise = this.handleUsageUpdate(sessionId, acpSessionId, usage);
|
|
125086
125108
|
const usageState = this.store.get(sessionId);
|
|
125087
125109
|
usageState.pendingUsageHandlers.add(promise);
|
|
125088
|
-
promise.finally(() => {
|
|
125110
|
+
void promise.finally(() => {
|
|
125089
125111
|
usageState.pendingUsageHandlers.delete(promise);
|
|
125090
125112
|
});
|
|
125091
125113
|
});
|
|
125092
125114
|
this.sessionManager.on("onContextWindowUsageUpdate", (sessionId, usage) => {
|
|
125093
125115
|
this.enqueueContextWindowUsageUpdate(sessionId, usage);
|
|
125094
125116
|
});
|
|
125095
|
-
this.sessionManager.on("onRateLimitUpdate",
|
|
125096
|
-
|
|
125117
|
+
this.sessionManager.on("onRateLimitUpdate", (machineId, cliType, limits) => {
|
|
125118
|
+
void this.workspaceDocument.updateRateLimits(machineId, cliType, limits);
|
|
125097
125119
|
});
|
|
125098
|
-
this.sessionManager.on("error",
|
|
125099
|
-
|
|
125100
|
-
|
|
125101
|
-
|
|
125102
|
-
|
|
125103
|
-
|
|
125104
|
-
|
|
125105
|
-
|
|
125106
|
-
|
|
125120
|
+
this.sessionManager.on("error", (event) => {
|
|
125121
|
+
void (async () => {
|
|
125122
|
+
this.logger.error(`[${event.sessionId}] Session error event received:`, event);
|
|
125123
|
+
const sessionId = event.sessionId;
|
|
125124
|
+
this.stopMachineSessionHeartbeat(sessionId);
|
|
125125
|
+
await this.finalizeACPState(sessionId);
|
|
125126
|
+
await this.flushSessionUsage(sessionId);
|
|
125127
|
+
const sessionDoc = await this.workspaceDocument.getOrCreateSessionDoc(sessionId);
|
|
125128
|
+
await sessionDoc.setStatus(SessionStatusFactory.idle());
|
|
125129
|
+
this.logger.debug(`[${sessionId}] Status set to idle (via error event)`);
|
|
125130
|
+
})();
|
|
125107
125131
|
});
|
|
125108
|
-
this.sessionManager.on("exit",
|
|
125109
|
-
|
|
125110
|
-
|
|
125111
|
-
|
|
125112
|
-
this.
|
|
125113
|
-
|
|
125114
|
-
|
|
125115
|
-
|
|
125116
|
-
await this.finalizeACPState(sessionId);
|
|
125117
|
-
await this.flushSessionUsage(sessionId);
|
|
125118
|
-
const session = await this.workspaceDocument.getOrCreateSessionDoc(sessionId);
|
|
125119
|
-
await session.setStatus(SessionStatusFactory.idle());
|
|
125120
|
-
this.logger.debug(`[${sessionId}] Status set to idle (via exit event)`);
|
|
125121
|
-
});
|
|
125122
|
-
this.sessionManager.on("terminated", async (event) => {
|
|
125123
|
-
const sessionId = event.sessionId;
|
|
125124
|
-
if (!this.store.has(sessionId)) {
|
|
125125
|
-
this.logger.debug(`[${sessionId}] Ignoring terminated event for GC-cleaned session`);
|
|
125126
|
-
return;
|
|
125127
|
-
}
|
|
125128
|
-
try {
|
|
125132
|
+
this.sessionManager.on("exit", (exit2) => {
|
|
125133
|
+
void (async () => {
|
|
125134
|
+
const sessionId = exit2.sessionId;
|
|
125135
|
+
this.logger.debug(`[${sessionId}] Session exit event received (exitCode=${exit2.exitCode})`);
|
|
125136
|
+
if (!this.store.has(sessionId)) {
|
|
125137
|
+
this.logger.debug(`[${sessionId}] Ignoring exit event for GC-cleaned session`);
|
|
125138
|
+
return;
|
|
125139
|
+
}
|
|
125129
125140
|
this.stopMachineSessionHeartbeat(sessionId);
|
|
125130
125141
|
await this.finalizeACPState(sessionId);
|
|
125131
125142
|
await this.flushSessionUsage(sessionId);
|
|
125132
|
-
|
|
125133
|
-
|
|
125134
|
-
|
|
125143
|
+
const session = await this.workspaceDocument.getOrCreateSessionDoc(sessionId);
|
|
125144
|
+
await session.setStatus(SessionStatusFactory.idle());
|
|
125145
|
+
this.logger.debug(`[${sessionId}] Status set to idle (via exit event)`);
|
|
125146
|
+
})();
|
|
125147
|
+
});
|
|
125148
|
+
this.sessionManager.on("terminated", (event) => {
|
|
125149
|
+
void (async () => {
|
|
125150
|
+
const sessionId = event.sessionId;
|
|
125151
|
+
if (!this.store.has(sessionId)) {
|
|
125152
|
+
this.logger.debug(`[${sessionId}] Ignoring terminated event for GC-cleaned session`);
|
|
125153
|
+
return;
|
|
125154
|
+
}
|
|
125155
|
+
try {
|
|
125156
|
+
this.stopMachineSessionHeartbeat(sessionId);
|
|
125157
|
+
await this.finalizeACPState(sessionId);
|
|
125158
|
+
await this.flushSessionUsage(sessionId);
|
|
125159
|
+
} catch (error2) {
|
|
125160
|
+
this.logger.error(`[${sessionId}] Failed to handle termination event: ${formatErrorMessage(error2)}`);
|
|
125161
|
+
}
|
|
125162
|
+
})();
|
|
125135
125163
|
});
|
|
125136
125164
|
}
|
|
125137
125165
|
setupArchiveWatcher() {
|
|
@@ -125403,7 +125431,7 @@ $mem | ConvertTo-Json -Compress
|
|
|
125403
125431
|
const batchWindowMs = state2.acpFlushCountInTurn === 0 ? MessageHandler.ACP_INITIAL_UPDATE_BATCH_WINDOW_MS : MessageHandler.ACP_SUBSEQUENT_UPDATE_BATCH_WINDOW_MS;
|
|
125404
125432
|
const timer2 = setTimeout(() => {
|
|
125405
125433
|
state2.acpFlushTimer = null;
|
|
125406
|
-
this.startACPUpdateFlush(sessionId);
|
|
125434
|
+
void this.startACPUpdateFlush(sessionId);
|
|
125407
125435
|
}, batchWindowMs);
|
|
125408
125436
|
timer2.unref?.();
|
|
125409
125437
|
state2.acpFlushTimer = timer2;
|
|
@@ -125416,7 +125444,7 @@ $mem | ConvertTo-Json -Compress
|
|
|
125416
125444
|
if (state2.acpUpdateBuffer.length === 0) {
|
|
125417
125445
|
return;
|
|
125418
125446
|
}
|
|
125419
|
-
this.startACPUpdateFlush(sessionId);
|
|
125447
|
+
void this.startACPUpdateFlush(sessionId);
|
|
125420
125448
|
}
|
|
125421
125449
|
const inFlight = state2.acpFlushInFlight;
|
|
125422
125450
|
if (!inFlight) {
|
|
@@ -125572,11 +125600,11 @@ $mem | ConvertTo-Json -Compress
|
|
|
125572
125600
|
try {
|
|
125573
125601
|
await handleACPUpdateMessage(sessionDoc, queue2, {
|
|
125574
125602
|
logger: this.logger,
|
|
125575
|
-
getCurrentSessionTurnId: (
|
|
125576
|
-
const tid = this.store.getTurnId(
|
|
125603
|
+
getCurrentSessionTurnId: (currentSessionId) => {
|
|
125604
|
+
const tid = this.store.getTurnId(currentSessionId);
|
|
125577
125605
|
if (!tid) {
|
|
125578
|
-
captureException(new Error(`No turn id found for session ${
|
|
125579
|
-
throw new Error(`No turn id found for session ${
|
|
125606
|
+
void captureException(new Error(`No turn id found for session ${currentSessionId}`));
|
|
125607
|
+
throw new Error(`No turn id found for session ${currentSessionId}`);
|
|
125580
125608
|
}
|
|
125581
125609
|
return tid;
|
|
125582
125610
|
}
|
|
@@ -125954,7 +125982,7 @@ $mem | ConvertTo-Json -Compress
|
|
|
125954
125982
|
});
|
|
125955
125983
|
attachedTo = "new_entry";
|
|
125956
125984
|
} else {
|
|
125957
|
-
const
|
|
125985
|
+
const failureMessage = latestAttachTarget.kind === "unavailable" ? `Session is ${latestAttachTarget.statusType} and the original assistant turn is no longer available for image upload` : "The original assistant turn is no longer available for image upload";
|
|
125958
125986
|
this.captureSessionImageUploadEvent(analyticsUserId, "session/image_upload_failed", {
|
|
125959
125987
|
entrypoint: dispatchContext.source === "local" ? "cli_command" : "session_runtime",
|
|
125960
125988
|
session_id: sessionId,
|
|
@@ -125964,13 +125992,13 @@ $mem | ConvertTo-Json -Compress
|
|
|
125964
125992
|
local_project_id: localProjectId,
|
|
125965
125993
|
repo_full_name: repoFullName,
|
|
125966
125994
|
failure_reason: "active_turn_unavailable",
|
|
125967
|
-
error_message:
|
|
125995
|
+
error_message: failureMessage
|
|
125968
125996
|
});
|
|
125969
125997
|
respond({
|
|
125970
125998
|
success: false,
|
|
125971
125999
|
workspaceId: this.workspaceId,
|
|
125972
126000
|
error: "active_turn_unavailable",
|
|
125973
|
-
message:
|
|
126001
|
+
message: failureMessage
|
|
125974
126002
|
});
|
|
125975
126003
|
return;
|
|
125976
126004
|
}
|
|
@@ -125987,7 +126015,7 @@ $mem | ConvertTo-Json -Compress
|
|
|
125987
126015
|
});
|
|
125988
126016
|
if (!replaced) {
|
|
125989
126017
|
const latestAttachTarget = await this.resolveSessionImageUploadAttachTarget(sessionId, sessionDoc);
|
|
125990
|
-
const
|
|
126018
|
+
const failureMessage = latestAttachTarget.kind === "active_turn" ? "Session started a new assistant turn during image upload; retry after the turn completes" : latestAttachTarget.kind === "unavailable" ? `Session is ${latestAttachTarget.statusType} and no idle assistant entry can be created` : "Reserved assistant image entry is no longer available";
|
|
125991
126019
|
this.captureSessionImageUploadEvent(analyticsUserId, "session/image_upload_failed", {
|
|
125992
126020
|
entrypoint: dispatchContext.source === "local" ? "cli_command" : "session_runtime",
|
|
125993
126021
|
session_id: sessionId,
|
|
@@ -125997,13 +126025,13 @@ $mem | ConvertTo-Json -Compress
|
|
|
125997
126025
|
local_project_id: localProjectId,
|
|
125998
126026
|
repo_full_name: repoFullName,
|
|
125999
126027
|
failure_reason: "active_turn_unavailable",
|
|
126000
|
-
error_message:
|
|
126028
|
+
error_message: failureMessage
|
|
126001
126029
|
});
|
|
126002
126030
|
respond({
|
|
126003
126031
|
success: false,
|
|
126004
126032
|
workspaceId: this.workspaceId,
|
|
126005
126033
|
error: "active_turn_unavailable",
|
|
126006
|
-
message:
|
|
126034
|
+
message: failureMessage
|
|
126007
126035
|
});
|
|
126008
126036
|
return;
|
|
126009
126037
|
}
|
|
@@ -126241,20 +126269,22 @@ $mem | ConvertTo-Json -Compress
|
|
|
126241
126269
|
});
|
|
126242
126270
|
}
|
|
126243
126271
|
checkForOutcome();
|
|
126244
|
-
timeoutId = setTimeout(
|
|
126245
|
-
|
|
126246
|
-
|
|
126247
|
-
|
|
126248
|
-
|
|
126249
|
-
|
|
126272
|
+
timeoutId = setTimeout(() => {
|
|
126273
|
+
void (async () => {
|
|
126274
|
+
if (resolved) return;
|
|
126275
|
+
this.logger.warn(`Permission request timed out for session ${sessionId}`);
|
|
126276
|
+
this.logger.debug(`[${sessionId}] Permission request ${requestId} timed out after ${PERMISSION_REQUEST_TIMEOUT_MS}ms`);
|
|
126277
|
+
try {
|
|
126278
|
+
await updatePermissionOutcomeInHistory(doc, requestId, {
|
|
126279
|
+
outcome: "cancelled"
|
|
126280
|
+
}, this.logger);
|
|
126281
|
+
} catch (error2) {
|
|
126282
|
+
this.logger.error(`[${sessionId}] Failed to update permission timeout in history: ${formatErrorMessage(error2)}`);
|
|
126283
|
+
}
|
|
126284
|
+
void resolveWithOutcome({
|
|
126250
126285
|
outcome: "cancelled"
|
|
126251
|
-
}
|
|
126252
|
-
}
|
|
126253
|
-
this.logger.error(`[${sessionId}] Failed to update permission timeout in history: ${formatErrorMessage(error2)}`);
|
|
126254
|
-
}
|
|
126255
|
-
void resolveWithOutcome({
|
|
126256
|
-
outcome: "cancelled"
|
|
126257
|
-
});
|
|
126286
|
+
});
|
|
126287
|
+
})();
|
|
126258
126288
|
}, PERMISSION_REQUEST_TIMEOUT_MS);
|
|
126259
126289
|
});
|
|
126260
126290
|
}
|
|
@@ -127389,7 +127419,7 @@ $mem | ConvertTo-Json -Compress
|
|
|
127389
127419
|
}
|
|
127390
127420
|
const BROKER_STATE_FILE_PATH = path__default.join(os__default.homedir(), ".lody", "broker.json");
|
|
127391
127421
|
const createGitCredentialBrokerHandler = (options) => {
|
|
127392
|
-
|
|
127422
|
+
const handleRequest = async (req, res) => {
|
|
127393
127423
|
try {
|
|
127394
127424
|
if (req.method === "GET" && req.url === "/health") {
|
|
127395
127425
|
res.writeHead(200, {
|
|
@@ -127482,6 +127512,9 @@ $mem | ConvertTo-Json -Compress
|
|
|
127482
127512
|
}));
|
|
127483
127513
|
}
|
|
127484
127514
|
};
|
|
127515
|
+
return (req, res) => {
|
|
127516
|
+
void handleRequest(req, res);
|
|
127517
|
+
};
|
|
127485
127518
|
};
|
|
127486
127519
|
const DEFAULT_HEALTH_CHECK_INTERVAL_MS = 3e4;
|
|
127487
127520
|
const HEALTH_CHECK_TIMEOUT_MS = 5e3;
|
|
@@ -127587,15 +127620,17 @@ $mem | ConvertTo-Json -Compress
|
|
|
127587
127620
|
if (this.healthCheckTimer) {
|
|
127588
127621
|
return;
|
|
127589
127622
|
}
|
|
127590
|
-
this.healthCheckTimer = setInterval(
|
|
127591
|
-
|
|
127592
|
-
|
|
127593
|
-
|
|
127594
|
-
|
|
127595
|
-
|
|
127596
|
-
|
|
127597
|
-
|
|
127598
|
-
|
|
127623
|
+
this.healthCheckTimer = setInterval(() => {
|
|
127624
|
+
void (async () => {
|
|
127625
|
+
if (this.isRecovering) {
|
|
127626
|
+
return;
|
|
127627
|
+
}
|
|
127628
|
+
const isHealthy = await this.checkHealth();
|
|
127629
|
+
if (!isHealthy && this.env) {
|
|
127630
|
+
this.logger.debug("Git credential broker health check failed, attempting recovery...");
|
|
127631
|
+
await this.recover();
|
|
127632
|
+
}
|
|
127633
|
+
})();
|
|
127599
127634
|
}, DEFAULT_HEALTH_CHECK_INTERVAL_MS);
|
|
127600
127635
|
this.healthCheckTimer.unref();
|
|
127601
127636
|
}
|
|
@@ -134784,11 +134819,11 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
|
|
|
134784
134819
|
responses
|
|
134785
134820
|
});
|
|
134786
134821
|
} catch (error2) {
|
|
134787
|
-
const
|
|
134788
|
-
config2.logger.debug(`Local session control dispatch failed: ${
|
|
134822
|
+
const errorMessage = formatErrorMessage(error2);
|
|
134823
|
+
config2.logger.debug(`Local session control dispatch failed: ${errorMessage}`);
|
|
134789
134824
|
jsonResponse(res, 500, {
|
|
134790
134825
|
ok: false,
|
|
134791
|
-
error:
|
|
134826
|
+
error: errorMessage
|
|
134792
134827
|
});
|
|
134793
134828
|
}
|
|
134794
134829
|
}
|
|
@@ -134985,21 +135020,23 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
|
|
|
134985
135020
|
}
|
|
134986
135021
|
chunks.push(chunk);
|
|
134987
135022
|
});
|
|
134988
|
-
req.on("end",
|
|
134989
|
-
|
|
134990
|
-
|
|
134991
|
-
|
|
134992
|
-
|
|
134993
|
-
|
|
134994
|
-
|
|
134995
|
-
|
|
134996
|
-
|
|
134997
|
-
|
|
134998
|
-
|
|
134999
|
-
|
|
135000
|
-
|
|
135001
|
-
|
|
135002
|
-
|
|
135023
|
+
req.on("end", () => {
|
|
135024
|
+
void (async () => {
|
|
135025
|
+
if (res.headersSent || res.writableEnded || res.destroyed) {
|
|
135026
|
+
return;
|
|
135027
|
+
}
|
|
135028
|
+
const raw = Buffer.concat(chunks).toString("utf8");
|
|
135029
|
+
config2.logger.debug(`[local-control:${requestId}] request body received: bytes=${Buffer.byteLength(raw, "utf8")} path=${requestPath}`);
|
|
135030
|
+
if (requestPath === SESSION_CONTROL_PATH$1) {
|
|
135031
|
+
await handleSessionControlRequest(config2, raw, res, requestId);
|
|
135032
|
+
return;
|
|
135033
|
+
}
|
|
135034
|
+
if (requestPath === IMAGE_UPLOAD_PATH) {
|
|
135035
|
+
await handleImageUploadRequest(config2, raw, res, requestId);
|
|
135036
|
+
return;
|
|
135037
|
+
}
|
|
135038
|
+
await handleProjectControlRequest(config2, raw, res, requestId);
|
|
135039
|
+
})();
|
|
135003
135040
|
});
|
|
135004
135041
|
req.on("error", (error2) => {
|
|
135005
135042
|
config2.logger.debug(`[local-control:${requestId}] request stream error: ${error2.message}`);
|
|
@@ -136005,7 +136042,7 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
|
|
|
136005
136042
|
this.retryTimers.clear();
|
|
136006
136043
|
this.unsubscribeWorkspaces?.();
|
|
136007
136044
|
this.unsubscribeWorkspaces = null;
|
|
136008
|
-
this.convex?.close();
|
|
136045
|
+
void this.convex?.close();
|
|
136009
136046
|
this.convex = null;
|
|
136010
136047
|
const runtimes = Array.from(this.runtimes.values());
|
|
136011
136048
|
this.runtimes.clear();
|
|
@@ -169715,7 +169752,7 @@ ${result.stderr}`;
|
|
|
169715
169752
|
if (error2 instanceof Error && error2.name === "CommanderError") {
|
|
169716
169753
|
process.exit(1);
|
|
169717
169754
|
} else {
|
|
169718
|
-
reportError("cli", error2, {
|
|
169755
|
+
void reportError("cli", error2, {
|
|
169719
169756
|
logger: cliLogger,
|
|
169720
169757
|
fatal: true
|
|
169721
169758
|
}).finally(() => process.exit(1));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lody",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"description": "Lody Agent CLI tool for managing remote command execution",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
"winston-transport": "^4.7.1",
|
|
73
73
|
"ws": "^8.18.3",
|
|
74
74
|
"zod": "^4.1.5",
|
|
75
|
-
"@lody/cli-supervisor": "0.0.1",
|
|
76
75
|
"@lody/convex": "0.0.1",
|
|
77
76
|
"@lody/loro-streams-rpc": "0.0.1",
|
|
77
|
+
"@lody/cli-supervisor": "0.0.1",
|
|
78
78
|
"@lody/shared": "0.0.1",
|
|
79
79
|
"loro-code": "0.0.1"
|
|
80
80
|
},
|