@moxt-ai/mobius 0.0.172 → 0.0.174
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/agent-catalog/agent-specification.js +1 -1
- package/dist/cli.js +129 -863
- package/dist/cli.js.map +4 -4
- package/dist/daemon-command-handler.d.ts +1 -2
- package/dist/daemon-command-handler.d.ts.map +1 -1
- package/dist/daemon-command-handler.js +6 -26
- package/dist/daemon-command-handler.js.map +1 -1
- package/dist/daemon-history-commands.d.ts +1 -3
- package/dist/daemon-history-commands.d.ts.map +1 -1
- package/dist/daemon-history-commands.js +1 -48
- package/dist/daemon-history-commands.js.map +1 -1
- package/dist/daemon-turn-registry.d.ts +13 -13
- package/dist/generated/acp-session-store-migrations.d.ts +3 -0
- package/dist/generated/acp-session-store-migrations.d.ts.map +1 -1
- package/dist/generated/acp-session-store-migrations.js +5 -1
- package/dist/generated/acp-session-store-migrations.js.map +1 -1
- package/dist/index.js +114 -848
- package/dist/index.js.map +4 -4
- package/dist/native-sessions/service.d.ts.map +1 -1
- package/dist/native-sessions/service.js +0 -55
- package/dist/native-sessions/service.js.map +1 -1
- package/dist/relay-connection/run-relay-connection.d.ts +1 -2
- package/dist/relay-connection/run-relay-connection.d.ts.map +1 -1
- package/dist/relay-connection/run-relay-connection.js +1 -2
- package/dist/relay-connection/run-relay-connection.js.map +1 -1
- package/dist/run-daemon.d.ts +0 -1
- package/dist/run-daemon.d.ts.map +1 -1
- package/dist/run-daemon.js +0 -6
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.d.ts +0 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +108 -842
- package/dist/runtime.js.map +4 -4
- package/dist/schema/acp-session-store/index.d.ts +0 -1
- package/dist/schema/acp-session-store/index.d.ts.map +1 -1
- package/dist/schema/acp-session-store/index.js +0 -1
- package/dist/schema/acp-session-store/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/agent-catalog/handle-agent-catalog-refresh.d.ts +0 -21
- package/dist/agent-catalog/handle-agent-catalog-refresh.d.ts.map +0 -1
- package/dist/agent-catalog/handle-agent-catalog-refresh.js +0 -119
- package/dist/agent-catalog/handle-agent-catalog-refresh.js.map +0 -1
- package/dist/native-sessions/acp-adapter.d.ts +0 -3
- package/dist/native-sessions/acp-adapter.d.ts.map +0 -1
- package/dist/native-sessions/acp-adapter.js +0 -6
- package/dist/native-sessions/acp-adapter.js.map +0 -1
- package/dist/native-sessions/acp-history.d.ts +0 -6
- package/dist/native-sessions/acp-history.d.ts.map +0 -1
- package/dist/native-sessions/acp-history.js +0 -27
- package/dist/native-sessions/acp-history.js.map +0 -1
- package/dist/native-sessions/agent-adapter.d.ts +0 -16
- package/dist/native-sessions/agent-adapter.d.ts.map +0 -1
- package/dist/native-sessions/agent-adapter.js +0 -19
- package/dist/native-sessions/agent-adapter.js.map +0 -1
- package/dist/native-sessions/codex-adapter.d.ts +0 -3
- package/dist/native-sessions/codex-adapter.d.ts.map +0 -1
- package/dist/native-sessions/codex-adapter.js +0 -20
- package/dist/native-sessions/codex-adapter.js.map +0 -1
- package/dist/native-sessions/live-history-page.d.ts +0 -4
- package/dist/native-sessions/live-history-page.d.ts.map +0 -1
- package/dist/native-sessions/live-history-page.js +0 -258
- package/dist/native-sessions/live-history-page.js.map +0 -1
- package/dist/schema/acp-session-store/session-event-v2.d.ts +0 -72
- package/dist/schema/acp-session-store/session-event-v2.d.ts.map +0 -1
- package/dist/schema/acp-session-store/session-event-v2.js +0 -11
- package/dist/schema/acp-session-store/session-event-v2.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -3380,11 +3380,11 @@ var $ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => {
|
|
|
3380
3380
|
return payload;
|
|
3381
3381
|
};
|
|
3382
3382
|
});
|
|
3383
|
-
function handleArrayResult(result, final,
|
|
3383
|
+
function handleArrayResult(result, final, index) {
|
|
3384
3384
|
if (result.issues.length) {
|
|
3385
|
-
final.issues.push(...prefixIssues(
|
|
3385
|
+
final.issues.push(...prefixIssues(index, result.issues));
|
|
3386
3386
|
}
|
|
3387
|
-
final.value[
|
|
3387
|
+
final.value[index] = result.value;
|
|
3388
3388
|
}
|
|
3389
3389
|
var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
3390
3390
|
$ZodType.init(inst, def);
|
|
@@ -3995,14 +3995,14 @@ function mergeValues(a, b) {
|
|
|
3995
3995
|
return { valid: false, mergeErrorPath: [] };
|
|
3996
3996
|
}
|
|
3997
3997
|
const newArray = [];
|
|
3998
|
-
for (let
|
|
3999
|
-
const itemA = a[
|
|
4000
|
-
const itemB = b[
|
|
3998
|
+
for (let index = 0; index < a.length; index++) {
|
|
3999
|
+
const itemA = a[index];
|
|
4000
|
+
const itemB = b[index];
|
|
4001
4001
|
const sharedValue = mergeValues(itemA, itemB);
|
|
4002
4002
|
if (!sharedValue.valid) {
|
|
4003
4003
|
return {
|
|
4004
4004
|
valid: false,
|
|
4005
|
-
mergeErrorPath: [
|
|
4005
|
+
mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
|
|
4006
4006
|
};
|
|
4007
4007
|
}
|
|
4008
4008
|
newArray.push(sharedValue.data);
|
|
@@ -4153,11 +4153,11 @@ function getTupleOptStart(items, key) {
|
|
|
4153
4153
|
}
|
|
4154
4154
|
return 0;
|
|
4155
4155
|
}
|
|
4156
|
-
function handleTupleResult(result, final,
|
|
4156
|
+
function handleTupleResult(result, final, index) {
|
|
4157
4157
|
if (result.issues.length) {
|
|
4158
|
-
final.issues.push(...prefixIssues(
|
|
4158
|
+
final.issues.push(...prefixIssues(index, result.issues));
|
|
4159
4159
|
}
|
|
4160
|
-
final.value[
|
|
4160
|
+
final.value[index] = result.value;
|
|
4161
4161
|
}
|
|
4162
4162
|
function handleTupleResults(itemResults, final, items, input2, optoutStart) {
|
|
4163
4163
|
for (let i = 0; i < items.length; i++) {
|
|
@@ -18838,7 +18838,7 @@ function detectVersion(schema, defaultTarget) {
|
|
|
18838
18838
|
return defaultTarget ?? "draft-2020-12";
|
|
18839
18839
|
}
|
|
18840
18840
|
function applyMinItems(items, minItems) {
|
|
18841
|
-
return items.map((item,
|
|
18841
|
+
return items.map((item, index) => index < minItems ? item : item.optional());
|
|
18842
18842
|
}
|
|
18843
18843
|
function decodeJSONPointerSegment(segment) {
|
|
18844
18844
|
return segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
@@ -19815,9 +19815,6 @@ var AGENT_INSTALL_CANCELLED_KIND = "agent.integration.install.cancelled";
|
|
|
19815
19815
|
var AGENT_SETTINGS_DISCOVER_KIND = "agent.settings.discover";
|
|
19816
19816
|
var AGENT_SETTINGS_DISCOVERED_KIND = "agent.settings.discovered";
|
|
19817
19817
|
var AGENT_SETTINGS_DISCOVERY_FAILED_KIND = "agent.settings.discovery.failed";
|
|
19818
|
-
var AGENT_CATALOG_REFRESH_KIND = "agent.catalog.refresh";
|
|
19819
|
-
var AGENT_CATALOG_REFRESHED_KIND = "agent.catalog.refreshed";
|
|
19820
|
-
var AGENT_CATALOG_REFRESH_FAILED_KIND = "agent.catalog.refresh.failed";
|
|
19821
19818
|
var FILE_READ_KIND = "file.read";
|
|
19822
19819
|
var FILE_BEGIN_KIND = "file.begin";
|
|
19823
19820
|
var FILE_CHUNK_KIND = "file.chunk";
|
|
@@ -19979,20 +19976,6 @@ var agentSettingsDiscoveryFailedEventSchema = external_exports.object({
|
|
|
19979
19976
|
message: external_exports.string().min(1).max(500),
|
|
19980
19977
|
requestId: identifierStringSchema
|
|
19981
19978
|
}).readonly();
|
|
19982
|
-
var agentCatalogRefreshCommandSchema = external_exports.object({
|
|
19983
|
-
kind: external_exports.literal(AGENT_CATALOG_REFRESH_KIND),
|
|
19984
|
-
requestId: identifierStringSchema
|
|
19985
|
-
}).readonly();
|
|
19986
|
-
var agentCatalogRefreshedEventSchema = external_exports.object({
|
|
19987
|
-
kind: external_exports.literal(AGENT_CATALOG_REFRESHED_KIND),
|
|
19988
|
-
requestId: identifierStringSchema
|
|
19989
|
-
}).readonly();
|
|
19990
|
-
var agentCatalogRefreshFailedEventSchema = external_exports.object({
|
|
19991
|
-
code: identifierStringSchema,
|
|
19992
|
-
kind: external_exports.literal(AGENT_CATALOG_REFRESH_FAILED_KIND),
|
|
19993
|
-
message: external_exports.string().min(1).max(500),
|
|
19994
|
-
requestId: identifierStringSchema
|
|
19995
|
-
}).readonly();
|
|
19996
19979
|
var sessionConfigurationSelectionSchema = external_exports.object({
|
|
19997
19980
|
booleanValue: external_exports.boolean(),
|
|
19998
19981
|
configId: identifierStringSchema,
|
|
@@ -20040,12 +20023,12 @@ var DEFAULT_AGENT_EXECUTION_CONFIGURATION = Object.freeze({
|
|
|
20040
20023
|
});
|
|
20041
20024
|
var sessionConfigurationSelectionsSchema = external_exports.array(sessionConfigurationSelectionSchema).max(100).superRefine((selections, context) => {
|
|
20042
20025
|
const identifiers = /* @__PURE__ */ new Set();
|
|
20043
|
-
for (const [
|
|
20026
|
+
for (const [index, selection] of selections.entries()) {
|
|
20044
20027
|
if (identifiers.has(selection.configId)) {
|
|
20045
20028
|
context.addIssue({
|
|
20046
20029
|
code: "custom",
|
|
20047
20030
|
message: "Session configuration identifiers must be unique",
|
|
20048
|
-
path: [
|
|
20031
|
+
path: [index, "configId"]
|
|
20049
20032
|
});
|
|
20050
20033
|
}
|
|
20051
20034
|
identifiers.add(selection.configId);
|
|
@@ -20397,12 +20380,6 @@ var decodeAgentSettingsDiscoveredEvent = (encoded) => decode3(encoded, agentSett
|
|
|
20397
20380
|
var encodeAgentSettingsDiscoveredEvent = (message) => encode3(message, agentSettingsDiscoveredEventSchema);
|
|
20398
20381
|
var decodeAgentSettingsDiscoveryFailedEvent = (encoded) => decode3(encoded, agentSettingsDiscoveryFailedEventSchema);
|
|
20399
20382
|
var encodeAgentSettingsDiscoveryFailedEvent = (message) => encode3(message, agentSettingsDiscoveryFailedEventSchema);
|
|
20400
|
-
var decodeAgentCatalogRefreshCommand = (encoded) => decode3(encoded, agentCatalogRefreshCommandSchema);
|
|
20401
|
-
var encodeAgentCatalogRefreshCommand = (message) => encode3(message, agentCatalogRefreshCommandSchema);
|
|
20402
|
-
var decodeAgentCatalogRefreshedEvent = (encoded) => decode3(encoded, agentCatalogRefreshedEventSchema);
|
|
20403
|
-
var encodeAgentCatalogRefreshedEvent = (message) => encode3(message, agentCatalogRefreshedEventSchema);
|
|
20404
|
-
var decodeAgentCatalogRefreshFailedEvent = (encoded) => decode3(encoded, agentCatalogRefreshFailedEventSchema);
|
|
20405
|
-
var encodeAgentCatalogRefreshFailedEvent = (message) => encode3(message, agentCatalogRefreshFailedEventSchema);
|
|
20406
20383
|
var decodeFileReadCommand = (encoded) => decode3(encoded, fileReadCommandSchema);
|
|
20407
20384
|
var encodeFileReadCommand = (message) => encode3(message, fileReadCommandSchema);
|
|
20408
20385
|
var decodeFileBeginEvent = (encoded) => decode3(encoded, fileBeginEventSchema);
|
|
@@ -20471,6 +20448,8 @@ var SESSION_CANCEL_KIND = "session.cancel";
|
|
|
20471
20448
|
var RUNTIME_LIVENESS_READY_KIND = "runtime.liveness.ready";
|
|
20472
20449
|
var RUNTIME_HEARTBEAT_KIND = "runtime.heartbeat";
|
|
20473
20450
|
var RUNTIME_HEARTBEAT_ACK_KIND = "runtime.heartbeat.ack";
|
|
20451
|
+
var RUNTIME_PING_KIND = "runtime.ping";
|
|
20452
|
+
var RUNTIME_PONG_KIND = "runtime.pong";
|
|
20474
20453
|
var SESSION_STARTED_KIND = "session.started";
|
|
20475
20454
|
var SESSION_QUEUED_KIND = "session.queued";
|
|
20476
20455
|
var AGENT_MESSAGE_DELTA_KIND = "agent.message.delta";
|
|
@@ -20783,6 +20762,16 @@ function decodeRuntimeHeartbeatAckEvent(encoded) {
|
|
|
20783
20762
|
kind: RUNTIME_HEARTBEAT_ACK_KIND
|
|
20784
20763
|
};
|
|
20785
20764
|
}
|
|
20765
|
+
function decodeRuntimePingCommand(encoded) {
|
|
20766
|
+
const value = parseJson2(encoded);
|
|
20767
|
+
assertKind(value, RUNTIME_PING_KIND);
|
|
20768
|
+
return { kind: RUNTIME_PING_KIND, requestId: readIdentifier(value, "requestId") };
|
|
20769
|
+
}
|
|
20770
|
+
function decodeRuntimePongEvent(encoded) {
|
|
20771
|
+
const value = parseJson2(encoded);
|
|
20772
|
+
assertKind(value, RUNTIME_PONG_KIND);
|
|
20773
|
+
return { kind: RUNTIME_PONG_KIND, requestId: readIdentifier(value, "requestId") };
|
|
20774
|
+
}
|
|
20786
20775
|
function decodeSessionStartedEvent(encoded) {
|
|
20787
20776
|
const value = parseJson2(encoded);
|
|
20788
20777
|
assertKind(value, SESSION_STARTED_KIND);
|
|
@@ -20880,6 +20869,12 @@ function encodeRuntimeHeartbeatEvent(message) {
|
|
|
20880
20869
|
function encodeRuntimeHeartbeatAckEvent(message) {
|
|
20881
20870
|
return JSON.stringify(decodeRuntimeHeartbeatAckEvent(JSON.stringify(message)));
|
|
20882
20871
|
}
|
|
20872
|
+
function encodeRuntimePingCommand(message) {
|
|
20873
|
+
return JSON.stringify(decodeRuntimePingCommand(JSON.stringify(message)));
|
|
20874
|
+
}
|
|
20875
|
+
function encodeRuntimePongEvent(message) {
|
|
20876
|
+
return JSON.stringify(decodeRuntimePongEvent(JSON.stringify(message)));
|
|
20877
|
+
}
|
|
20883
20878
|
function decodeAgentActivityNarrationEvent(encoded) {
|
|
20884
20879
|
const value = parseJson2(encoded);
|
|
20885
20880
|
assertKind(value, AGENT_ACTIVITY_NARRATION_KIND);
|
|
@@ -20993,10 +20988,6 @@ function withinHistoryContentLimits(history) {
|
|
|
20993
20988
|
) <= SESSION_HISTORY_IMAGE_CHARACTER_LIMIT;
|
|
20994
20989
|
}
|
|
20995
20990
|
var sessionHistorySchema = external_exports.discriminatedUnion("status", [availableSessionHistorySchema, unavailableSessionHistorySchema]).refine(withinHistoryContentLimits);
|
|
20996
|
-
var nativeMessagePageSchema = external_exports.discriminatedUnion("status", [
|
|
20997
|
-
availableSessionHistoryObjectSchema.extend({ nextCursor: external_exports.string().max(512).nullable() }).readonly(),
|
|
20998
|
-
unavailableSessionHistoryObjectSchema.extend({ nextCursor: external_exports.null() }).readonly()
|
|
20999
|
-
]).refine(withinHistoryContentLimits);
|
|
21000
20991
|
|
|
21001
20992
|
// ../protocol/src/native-sessions.ts
|
|
21002
20993
|
var NATIVE_SESSION_REQUEST_KIND = "native.session.request";
|
|
@@ -21062,10 +21053,7 @@ var identity = {
|
|
|
21062
21053
|
directoryId
|
|
21063
21054
|
};
|
|
21064
21055
|
var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
21065
|
-
external_exports.object({ ...identity, action: external_exports.literal("create") }).readonly(),
|
|
21066
21056
|
external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
|
|
21067
|
-
external_exports.object({ ...identity, action: external_exports.literal("preview"), entryId: identifierStringSchema }).readonly(),
|
|
21068
|
-
external_exports.object({ ...identity, action: external_exports.literal("history"), entryId: identifierStringSchema }).readonly(),
|
|
21069
21057
|
external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
21070
21058
|
external_exports.object({
|
|
21071
21059
|
...identity,
|
|
@@ -21091,10 +21079,7 @@ var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
|
21091
21079
|
}).readonly()
|
|
21092
21080
|
]);
|
|
21093
21081
|
var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
21094
|
-
external_exports.object({ ...identity, action: external_exports.literal("create") }).readonly(),
|
|
21095
21082
|
external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
|
|
21096
|
-
external_exports.object({ ...identity, action: external_exports.literal("preview"), entryId: identifierStringSchema }).readonly(),
|
|
21097
|
-
external_exports.object({ ...identity, action: external_exports.literal("history"), entryId: identifierStringSchema }).readonly(),
|
|
21098
21083
|
external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
21099
21084
|
external_exports.object({
|
|
21100
21085
|
...identity,
|
|
@@ -21134,7 +21119,6 @@ var resultEnvelope = {
|
|
|
21134
21119
|
kind: external_exports.literal(NATIVE_SESSION_RESULT_KIND)
|
|
21135
21120
|
};
|
|
21136
21121
|
var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
21137
|
-
external_exports.object({ ...resultEnvelope, action: external_exports.literal("create"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
21138
21122
|
external_exports.object({
|
|
21139
21123
|
...resultEnvelope,
|
|
21140
21124
|
action: external_exports.literal("active-turn"),
|
|
@@ -21167,22 +21151,6 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
|
21167
21151
|
ready: sessionReadyEventSchema,
|
|
21168
21152
|
title: external_exports.string().max(500)
|
|
21169
21153
|
}).readonly(),
|
|
21170
|
-
external_exports.object({
|
|
21171
|
-
...resultEnvelope,
|
|
21172
|
-
action: external_exports.literal("preview"),
|
|
21173
|
-
entryId: identifierStringSchema,
|
|
21174
|
-
targetSessionId: identifierStringSchema,
|
|
21175
|
-
reason: external_exports.enum(["continuation_unavailable", "requested"]),
|
|
21176
|
-
history: sessionHistorySchema,
|
|
21177
|
-
title: external_exports.string().max(500)
|
|
21178
|
-
}).readonly(),
|
|
21179
|
-
external_exports.object({
|
|
21180
|
-
...resultEnvelope,
|
|
21181
|
-
action: external_exports.literal("history"),
|
|
21182
|
-
entryId: identifierStringSchema,
|
|
21183
|
-
history: sessionHistorySchema,
|
|
21184
|
-
title: external_exports.string().max(500)
|
|
21185
|
-
}).readonly(),
|
|
21186
21154
|
external_exports.object({
|
|
21187
21155
|
...resultEnvelope,
|
|
21188
21156
|
action: external_exports.literal("delete"),
|
|
@@ -21589,12 +21557,12 @@ var sessionExportV2Schema = external_exports.object({
|
|
|
21589
21557
|
}).readonly().superRefine((session, context) => {
|
|
21590
21558
|
let previousPosition = 0n;
|
|
21591
21559
|
const eventIds = /* @__PURE__ */ new Set();
|
|
21592
|
-
for (const [
|
|
21560
|
+
for (const [index, event] of session.events.entries()) {
|
|
21593
21561
|
if (event.sessionId !== session.sessionId) {
|
|
21594
21562
|
context.addIssue({
|
|
21595
21563
|
code: "custom",
|
|
21596
21564
|
message: "Exported event belongs to a different Session",
|
|
21597
|
-
path: ["events",
|
|
21565
|
+
path: ["events", index, "sessionId"]
|
|
21598
21566
|
});
|
|
21599
21567
|
}
|
|
21600
21568
|
const position = BigInt(event.position);
|
|
@@ -21602,14 +21570,14 @@ var sessionExportV2Schema = external_exports.object({
|
|
|
21602
21570
|
context.addIssue({
|
|
21603
21571
|
code: "custom",
|
|
21604
21572
|
message: "Exported events are not in increasing position order",
|
|
21605
|
-
path: ["events",
|
|
21573
|
+
path: ["events", index, "position"]
|
|
21606
21574
|
});
|
|
21607
21575
|
}
|
|
21608
21576
|
if (eventIds.has(event.eventId)) {
|
|
21609
21577
|
context.addIssue({
|
|
21610
21578
|
code: "custom",
|
|
21611
21579
|
message: "Exported event identities are not unique",
|
|
21612
|
-
path: ["events",
|
|
21580
|
+
path: ["events", index, "eventId"]
|
|
21613
21581
|
});
|
|
21614
21582
|
}
|
|
21615
21583
|
previousPosition = position;
|
|
@@ -21753,28 +21721,9 @@ function decodeRecordedSessionEvent(encoded) {
|
|
|
21753
21721
|
var encodeRecordedSessionEvent = (event) => JSON.stringify(decodeRecordedSessionEvent(JSON.stringify(event)));
|
|
21754
21722
|
|
|
21755
21723
|
// ../protocol/src/session-live-history.ts
|
|
21756
|
-
var SESSION_LIVE_HISTORY_PAGE_LOAD_KIND = "session.live-history.page.load";
|
|
21757
|
-
var SESSION_LIVE_HISTORY_PAGE_LOADED_KIND = "session.live-history.page.loaded";
|
|
21758
21724
|
var SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND = "session.live-history.v2.page.load";
|
|
21759
21725
|
var SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND = "session.live-history.v2.page.loaded";
|
|
21760
21726
|
var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
|
|
21761
|
-
var sessionLiveHistoryPageLoadSchema = external_exports.object({
|
|
21762
|
-
additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
|
|
21763
|
-
agentId: identifierStringSchema,
|
|
21764
|
-
bindingId: identifierStringSchema,
|
|
21765
|
-
cursor: external_exports.string().min(1).max(512).nullable(),
|
|
21766
|
-
directoryId: directoryIdentifier,
|
|
21767
|
-
kind: external_exports.literal(SESSION_LIVE_HISTORY_PAGE_LOAD_KIND),
|
|
21768
|
-
limit: external_exports.number().int().min(1).max(100),
|
|
21769
|
-
requestId: identifierStringSchema,
|
|
21770
|
-
sessionId: identifierStringSchema
|
|
21771
|
-
}).readonly();
|
|
21772
|
-
var sessionLiveHistoryPageLoadedSchema = external_exports.object({
|
|
21773
|
-
kind: external_exports.literal(SESSION_LIVE_HISTORY_PAGE_LOADED_KIND),
|
|
21774
|
-
page: nativeMessagePageSchema,
|
|
21775
|
-
requestId: identifierStringSchema,
|
|
21776
|
-
sessionId: identifierStringSchema
|
|
21777
|
-
}).readonly();
|
|
21778
21727
|
var sessionLiveHistoryV2PageLoadSchema = external_exports.object({
|
|
21779
21728
|
additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
|
|
21780
21729
|
agentId: identifierStringSchema,
|
|
@@ -21800,10 +21749,6 @@ function decode7(schema, encoded) {
|
|
|
21800
21749
|
throw new ProtocolMessageError("Invalid live Session history message", { cause });
|
|
21801
21750
|
}
|
|
21802
21751
|
}
|
|
21803
|
-
var decodeSessionLiveHistoryPageLoad = (encoded) => decode7(sessionLiveHistoryPageLoadSchema, encoded);
|
|
21804
|
-
var decodeSessionLiveHistoryPageLoaded = (encoded) => decode7(sessionLiveHistoryPageLoadedSchema, encoded);
|
|
21805
|
-
var encodeSessionLiveHistoryPageLoad = (value) => JSON.stringify(sessionLiveHistoryPageLoadSchema.parse(value));
|
|
21806
|
-
var encodeSessionLiveHistoryPageLoaded = (value) => JSON.stringify(sessionLiveHistoryPageLoadedSchema.parse(value));
|
|
21807
21752
|
var decodeSessionLiveHistoryV2PageLoad = (encoded) => decode7(sessionLiveHistoryV2PageLoadSchema, encoded);
|
|
21808
21753
|
var decodeSessionLiveHistoryV2PageLoaded = (encoded) => decode7(sessionLiveHistoryV2PageLoadedSchema, encoded);
|
|
21809
21754
|
var encodeSessionLiveHistoryV2PageLoad = (value) => JSON.stringify(sessionLiveHistoryV2PageLoadSchema.parse(value));
|
|
@@ -21820,11 +21765,6 @@ function defineMessageSignature(kind, encoder, decoder) {
|
|
|
21820
21765
|
};
|
|
21821
21766
|
}
|
|
21822
21767
|
var serviceToDaemonSignatures = {
|
|
21823
|
-
[AGENT_CATALOG_REFRESH_KIND]: defineMessageSignature(
|
|
21824
|
-
AGENT_CATALOG_REFRESH_KIND,
|
|
21825
|
-
encodeAgentCatalogRefreshCommand,
|
|
21826
|
-
decodeAgentCatalogRefreshCommand
|
|
21827
|
-
),
|
|
21828
21768
|
[AGENT_INSTALL_CANCEL_KIND]: defineMessageSignature(
|
|
21829
21769
|
AGENT_INSTALL_CANCEL_KIND,
|
|
21830
21770
|
encodeAgentInstallCancelCommand,
|
|
@@ -21867,6 +21807,7 @@ var serviceToDaemonSignatures = {
|
|
|
21867
21807
|
encodeRuntimeLivenessReadyEvent,
|
|
21868
21808
|
decodeRuntimeLivenessReadyEvent
|
|
21869
21809
|
),
|
|
21810
|
+
[RUNTIME_PING_KIND]: defineMessageSignature(RUNTIME_PING_KIND, encodeRuntimePingCommand, decodeRuntimePingCommand),
|
|
21870
21811
|
[SESSION_CANCEL_KIND]: defineMessageSignature(
|
|
21871
21812
|
SESSION_CANCEL_KIND,
|
|
21872
21813
|
encodeSessionCancelCommand,
|
|
@@ -21882,11 +21823,6 @@ var serviceToDaemonSignatures = {
|
|
|
21882
21823
|
encodeSessionElicitationRespondCommand,
|
|
21883
21824
|
decodeSessionElicitationRespondCommand
|
|
21884
21825
|
),
|
|
21885
|
-
[SESSION_LIVE_HISTORY_PAGE_LOAD_KIND]: defineMessageSignature(
|
|
21886
|
-
SESSION_LIVE_HISTORY_PAGE_LOAD_KIND,
|
|
21887
|
-
encodeSessionLiveHistoryPageLoad,
|
|
21888
|
-
decodeSessionLiveHistoryPageLoad
|
|
21889
|
-
),
|
|
21890
21826
|
[SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND]: defineMessageSignature(
|
|
21891
21827
|
SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND,
|
|
21892
21828
|
encodeSessionLiveHistoryV2PageLoad,
|
|
@@ -21928,16 +21864,6 @@ function decodeServiceToDaemonMessage(encoded) {
|
|
|
21928
21864
|
return signature.decoder(encoded);
|
|
21929
21865
|
}
|
|
21930
21866
|
var daemonToServiceSignatures = {
|
|
21931
|
-
[AGENT_CATALOG_REFRESHED_KIND]: defineMessageSignature(
|
|
21932
|
-
AGENT_CATALOG_REFRESHED_KIND,
|
|
21933
|
-
encodeAgentCatalogRefreshedEvent,
|
|
21934
|
-
decodeAgentCatalogRefreshedEvent
|
|
21935
|
-
),
|
|
21936
|
-
[AGENT_CATALOG_REFRESH_FAILED_KIND]: defineMessageSignature(
|
|
21937
|
-
AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
21938
|
-
encodeAgentCatalogRefreshFailedEvent,
|
|
21939
|
-
decodeAgentCatalogRefreshFailedEvent
|
|
21940
|
-
),
|
|
21941
21867
|
[AGENT_INSTALL_CANCELLED_KIND]: defineMessageSignature(
|
|
21942
21868
|
AGENT_INSTALL_CANCELLED_KIND,
|
|
21943
21869
|
encodeAgentInstallCancelledEvent,
|
|
@@ -22007,6 +21933,7 @@ var daemonToServiceSignatures = {
|
|
|
22007
21933
|
encodeRuntimeHeartbeatEvent,
|
|
22008
21934
|
decodeRuntimeHeartbeatEvent
|
|
22009
21935
|
),
|
|
21936
|
+
[RUNTIME_PONG_KIND]: defineMessageSignature(RUNTIME_PONG_KIND, encodeRuntimePongEvent, decodeRuntimePongEvent),
|
|
22010
21937
|
[SESSION_EVENT_KIND]: defineMessageSignature(
|
|
22011
21938
|
SESSION_EVENT_KIND,
|
|
22012
21939
|
encodeSessionEventEnvelope,
|
|
@@ -22022,11 +21949,6 @@ var daemonToServiceSignatures = {
|
|
|
22022
21949
|
encodeSessionOperationFailedEvent,
|
|
22023
21950
|
decodeSessionOperationFailedEvent
|
|
22024
21951
|
),
|
|
22025
|
-
[SESSION_LIVE_HISTORY_PAGE_LOADED_KIND]: defineMessageSignature(
|
|
22026
|
-
SESSION_LIVE_HISTORY_PAGE_LOADED_KIND,
|
|
22027
|
-
encodeSessionLiveHistoryPageLoaded,
|
|
22028
|
-
decodeSessionLiveHistoryPageLoaded
|
|
22029
|
-
),
|
|
22030
21952
|
[SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND]: defineMessageSignature(
|
|
22031
21953
|
SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND,
|
|
22032
21954
|
encodeSessionLiveHistoryV2PageLoaded,
|
|
@@ -23021,7 +22943,7 @@ function startsWith(bytes, signature, offset = 0) {
|
|
|
23021
22943
|
if (bytes.byteLength < offset + signature.byteLength) {
|
|
23022
22944
|
return false;
|
|
23023
22945
|
}
|
|
23024
|
-
return signature.every((value,
|
|
22946
|
+
return signature.every((value, index) => bytes[offset + index] === value);
|
|
23025
22947
|
}
|
|
23026
22948
|
function sniffRasterMime(bytes) {
|
|
23027
22949
|
if (startsWith(bytes, PNG_SIGNATURE)) {
|
|
@@ -23149,7 +23071,7 @@ function startsWith2(bytes, signature, offset = 0) {
|
|
|
23149
23071
|
if (bytes.byteLength < offset + signature.byteLength) {
|
|
23150
23072
|
return false;
|
|
23151
23073
|
}
|
|
23152
|
-
return signature.every((value,
|
|
23074
|
+
return signature.every((value, index) => bytes[offset + index] === value);
|
|
23153
23075
|
}
|
|
23154
23076
|
function sniffVideoMime(bytes) {
|
|
23155
23077
|
if (startsWith2(bytes, MP4_FILE_TYPE, 4)) {
|
|
@@ -23278,10 +23200,10 @@ async function replaceImageMarkers(text2, replace) {
|
|
|
23278
23200
|
let cursor = 0;
|
|
23279
23201
|
let rewritten = "";
|
|
23280
23202
|
for (const match of matches) {
|
|
23281
|
-
const
|
|
23282
|
-
rewritten += text2.slice(cursor,
|
|
23203
|
+
const index = match.index ?? 0;
|
|
23204
|
+
rewritten += text2.slice(cursor, index);
|
|
23283
23205
|
rewritten += await replace(match[1] ?? "");
|
|
23284
|
-
cursor =
|
|
23206
|
+
cursor = index + match[0].length;
|
|
23285
23207
|
}
|
|
23286
23208
|
return `${rewritten}${text2.slice(cursor)}`;
|
|
23287
23209
|
}
|
|
@@ -26490,7 +26412,7 @@ function haveSameKeys(left, right) {
|
|
|
26490
26412
|
const leftKeys = Object.keys(left);
|
|
26491
26413
|
const rightKeys = Object.keys(right);
|
|
26492
26414
|
if (leftKeys.length !== rightKeys.length) return false;
|
|
26493
|
-
for (const [
|
|
26415
|
+
for (const [index, key] of leftKeys.entries()) if (key !== rightKeys[index]) return false;
|
|
26494
26416
|
return true;
|
|
26495
26417
|
}
|
|
26496
26418
|
function mapUpdateSet(table, values) {
|
|
@@ -27996,60 +27918,6 @@ function sqliteTableWithCasing(casing) {
|
|
|
27996
27918
|
}
|
|
27997
27919
|
var sqliteTable = sqliteTableWithCasing(void 0);
|
|
27998
27920
|
|
|
27999
|
-
// ../../node_modules/.pnpm/drizzle-orm@1.0.0-rc.4_@cloudflare+workers-types@5.20260918.1_@types+better-sqlite3@7.6_f872c171b7e1945bb1fa42180063dab2/node_modules/drizzle-orm/sqlite-core/indexes.js
|
|
28000
|
-
var IndexBuilderOn = class {
|
|
28001
|
-
static [entityKind] = "SQLiteIndexBuilderOn";
|
|
28002
|
-
constructor(name2, unique) {
|
|
28003
|
-
this.name = name2;
|
|
28004
|
-
this.unique = unique;
|
|
28005
|
-
}
|
|
28006
|
-
on(...columns) {
|
|
28007
|
-
return new IndexBuilder(this.name, columns, this.unique);
|
|
28008
|
-
}
|
|
28009
|
-
};
|
|
28010
|
-
var IndexBuilder = class {
|
|
28011
|
-
static [entityKind] = "SQLiteIndexBuilder";
|
|
28012
|
-
/** @internal */
|
|
28013
|
-
config;
|
|
28014
|
-
constructor(name2, columns, unique) {
|
|
28015
|
-
this.config = {
|
|
28016
|
-
name: name2,
|
|
28017
|
-
columns,
|
|
28018
|
-
unique,
|
|
28019
|
-
where: void 0
|
|
28020
|
-
};
|
|
28021
|
-
}
|
|
28022
|
-
/**
|
|
28023
|
-
* Condition for partial index.
|
|
28024
|
-
*/
|
|
28025
|
-
where(condition) {
|
|
28026
|
-
this.config.where = condition;
|
|
28027
|
-
return this;
|
|
28028
|
-
}
|
|
28029
|
-
/** @internal */
|
|
28030
|
-
build(table) {
|
|
28031
|
-
return new Index(this.config, table);
|
|
28032
|
-
}
|
|
28033
|
-
};
|
|
28034
|
-
var Index = class {
|
|
28035
|
-
static [entityKind] = "SQLiteIndex";
|
|
28036
|
-
config;
|
|
28037
|
-
isNameExplicit;
|
|
28038
|
-
constructor(config2, table) {
|
|
28039
|
-
this.config = {
|
|
28040
|
-
...config2,
|
|
28041
|
-
table
|
|
28042
|
-
};
|
|
28043
|
-
this.isNameExplicit = !!config2.name;
|
|
28044
|
-
}
|
|
28045
|
-
};
|
|
28046
|
-
function index(name2) {
|
|
28047
|
-
return new IndexBuilderOn(name2, false);
|
|
28048
|
-
}
|
|
28049
|
-
function uniqueIndex(name2) {
|
|
28050
|
-
return new IndexBuilderOn(name2, true);
|
|
28051
|
-
}
|
|
28052
|
-
|
|
28053
27921
|
// ../../node_modules/.pnpm/drizzle-orm@1.0.0-rc.4_@cloudflare+workers-types@5.20260918.1_@types+better-sqlite3@7.6_f872c171b7e1945bb1fa42180063dab2/node_modules/drizzle-orm/sqlite-core/utils.js
|
|
28054
27922
|
function extractUsedTable(table) {
|
|
28055
27923
|
if (is(table, SQLiteTable)) return [`${table[Table.Symbol.BaseName]}`];
|
|
@@ -28874,8 +28742,8 @@ var SQLiteDialect = class {
|
|
|
28874
28742
|
buildJoins(joins) {
|
|
28875
28743
|
if (!joins || joins.length === 0) return;
|
|
28876
28744
|
const joinsArray = [];
|
|
28877
|
-
if (joins) for (const [
|
|
28878
|
-
if (
|
|
28745
|
+
if (joins) for (const [index, joinMeta] of joins.entries()) {
|
|
28746
|
+
if (index === 0) joinsArray.push(sql` `);
|
|
28879
28747
|
const table = joinMeta.table;
|
|
28880
28748
|
const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
|
|
28881
28749
|
if (is(table, SQLiteTable)) {
|
|
@@ -28885,7 +28753,7 @@ var SQLiteDialect = class {
|
|
|
28885
28753
|
const alias = tableName === origTableName ? void 0 : joinMeta.alias;
|
|
28886
28754
|
joinsArray.push(sql`${sql.raw(joinMeta.joinType)} join ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`);
|
|
28887
28755
|
} else joinsArray.push(sql`${sql.raw(joinMeta.joinType)} join ${table}${onSql}`);
|
|
28888
|
-
if (
|
|
28756
|
+
if (index < joins.length - 1) joinsArray.push(sql` `);
|
|
28889
28757
|
}
|
|
28890
28758
|
return sql.join(joinsArray);
|
|
28891
28759
|
}
|
|
@@ -28894,9 +28762,9 @@ var SQLiteDialect = class {
|
|
|
28894
28762
|
}
|
|
28895
28763
|
buildOrderBy(orderBy) {
|
|
28896
28764
|
const orderByList = [];
|
|
28897
|
-
if (orderBy) for (const [
|
|
28765
|
+
if (orderBy) for (const [index, orderByValue] of orderBy.entries()) {
|
|
28898
28766
|
orderByList.push(orderByValue);
|
|
28899
|
-
if (
|
|
28767
|
+
if (index < orderBy.length - 1) orderByList.push(sql`, `);
|
|
28900
28768
|
}
|
|
28901
28769
|
return orderByList.length > 0 ? sql` order by ${sql.join(orderByList)}` : void 0;
|
|
28902
28770
|
}
|
|
@@ -28924,9 +28792,9 @@ var SQLiteDialect = class {
|
|
|
28924
28792
|
const whereSql = where ? sql` where ${where}` : void 0;
|
|
28925
28793
|
const havingSql = having ? sql` having ${having}` : void 0;
|
|
28926
28794
|
const groupByList = [];
|
|
28927
|
-
if (groupBy) for (const [
|
|
28795
|
+
if (groupBy) for (const [index, groupByValue] of groupBy.entries()) {
|
|
28928
28796
|
groupByList.push(groupByValue);
|
|
28929
|
-
if (
|
|
28797
|
+
if (index < groupBy.length - 1) groupByList.push(sql`, `);
|
|
28930
28798
|
}
|
|
28931
28799
|
const finalQuery = sql`${withSql}select${distinctSql} ${selection} from ${tableSql}${joinsSql}${whereSql}${groupByList.length > 0 ? sql` group by ${sql.join(groupByList)}` : void 0}${havingSql}${this.buildOrderBy(orderBy)}${this.buildLimit(limit)}${offset ? sql` offset ${offset}` : void 0}`;
|
|
28932
28800
|
if (setOperators.length > 0) return this.buildSetOperations(finalQuery, setOperators);
|
|
@@ -30218,6 +30086,10 @@ var acpSessionStoreMigrations = [
|
|
|
30218
30086
|
{
|
|
30219
30087
|
"name": "0002_equal_black_queen.sql",
|
|
30220
30088
|
"sql": "CREATE TABLE `session_event_v2` (\n `event_id` text PRIMARY KEY NOT NULL,\n `event_json` text NOT NULL,\n `position` integer NOT NULL,\n `session_id` text NOT NULL\n);\n--> statement-breakpoint\nCREATE UNIQUE INDEX `session_event_v2_session_position_unique` ON `session_event_v2` (`session_id`,`position`);--> statement-breakpoint\nCREATE INDEX `session_event_v2_session_position_index` ON `session_event_v2` (`session_id`,`position`);"
|
|
30089
|
+
},
|
|
30090
|
+
{
|
|
30091
|
+
"name": "0003_silky_ravenous.sql",
|
|
30092
|
+
"sql": "DROP TABLE `session_event_v2`;"
|
|
30221
30093
|
}
|
|
30222
30094
|
];
|
|
30223
30095
|
|
|
@@ -30239,21 +30111,6 @@ var deletedAcpSession = sqliteTable("deleted_acp_session", {
|
|
|
30239
30111
|
sessionId: text("session_id").primaryKey()
|
|
30240
30112
|
});
|
|
30241
30113
|
|
|
30242
|
-
// src/schema/acp-session-store/session-event-v2.ts
|
|
30243
|
-
var sessionEventV2 = sqliteTable(
|
|
30244
|
-
"session_event_v2",
|
|
30245
|
-
{
|
|
30246
|
-
eventId: text("event_id").primaryKey(),
|
|
30247
|
-
eventJson: text("event_json").notNull(),
|
|
30248
|
-
position: integer2("position").notNull(),
|
|
30249
|
-
sessionId: text("session_id").notNull()
|
|
30250
|
-
},
|
|
30251
|
-
(table) => [
|
|
30252
|
-
uniqueIndex("session_event_v2_session_position_unique").on(table.sessionId, table.position),
|
|
30253
|
-
index("session_event_v2_session_position_index").on(table.sessionId, table.position)
|
|
30254
|
-
]
|
|
30255
|
-
);
|
|
30256
|
-
|
|
30257
30114
|
// src/acp/session-store.ts
|
|
30258
30115
|
var AcpStoredSession = class {
|
|
30259
30116
|
additionalDirectories;
|
|
@@ -30370,15 +30227,15 @@ var SqliteAcpSessionStore = class {
|
|
|
30370
30227
|
this.#sqliteDatabase.close();
|
|
30371
30228
|
throw new Error("The ACP Session database was created by a newer Mobius version");
|
|
30372
30229
|
}
|
|
30373
|
-
for (let
|
|
30374
|
-
const migration = acpSessionStoreMigrations[
|
|
30230
|
+
for (let index = version2; index < acpSessionStoreMigrations.length; index += 1) {
|
|
30231
|
+
const migration = acpSessionStoreMigrations[index];
|
|
30375
30232
|
if (migration === void 0) {
|
|
30376
30233
|
throw new Error("The ACP Session migration is unavailable");
|
|
30377
30234
|
}
|
|
30378
30235
|
this.#sqliteDatabase.exec("BEGIN IMMEDIATE");
|
|
30379
30236
|
try {
|
|
30380
30237
|
this.#sqliteDatabase.exec(migration.sql);
|
|
30381
|
-
this.#sqliteDatabase.exec(`PRAGMA user_version = ${
|
|
30238
|
+
this.#sqliteDatabase.exec(`PRAGMA user_version = ${index + 1}`);
|
|
30382
30239
|
this.#sqliteDatabase.exec("COMMIT");
|
|
30383
30240
|
} catch (error62) {
|
|
30384
30241
|
this.#sqliteDatabase.exec("ROLLBACK");
|
|
@@ -30454,7 +30311,7 @@ var RetryableAcpInitializationError = class extends AcpExecutionError {
|
|
|
30454
30311
|
}
|
|
30455
30312
|
};
|
|
30456
30313
|
function arraysEqual(left, right) {
|
|
30457
|
-
return left.length === right.length && left.every((value,
|
|
30314
|
+
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
30458
30315
|
}
|
|
30459
30316
|
function recordsEqual(left, right) {
|
|
30460
30317
|
const leftEntries = Object.entries(left);
|
|
@@ -32190,9 +32047,6 @@ var LocalExternalContentStore = class {
|
|
|
32190
32047
|
};
|
|
32191
32048
|
|
|
32192
32049
|
// src/native-sessions/chat-agent.ts
|
|
32193
|
-
function supportsNativeChat(agentId) {
|
|
32194
|
-
return agentId === "codex" || agentId === "claude" || agentId === "opencode" || agentId === "pi";
|
|
32195
|
-
}
|
|
32196
32050
|
function isNativeChatSessionId(agentId, sessionId) {
|
|
32197
32051
|
if (!nativeSessionIdSchema.safeParse(sessionId).success) {
|
|
32198
32052
|
return false;
|
|
@@ -32251,9 +32105,9 @@ var AcpProcessCapacityLock = class {
|
|
|
32251
32105
|
return await waiter.completion.promise;
|
|
32252
32106
|
} finally {
|
|
32253
32107
|
signal.removeEventListener("abort", waiter.cancel);
|
|
32254
|
-
const
|
|
32255
|
-
if (
|
|
32256
|
-
this.#waiters.splice(
|
|
32108
|
+
const index = this.#waiters.indexOf(waiter);
|
|
32109
|
+
if (index >= 0) {
|
|
32110
|
+
this.#waiters.splice(index, 1);
|
|
32257
32111
|
}
|
|
32258
32112
|
}
|
|
32259
32113
|
};
|
|
@@ -36890,9 +36744,9 @@ function comparePrerelease(left, right) {
|
|
|
36890
36744
|
if (left.length === 0 || right.length === 0) {
|
|
36891
36745
|
return left.length === right.length ? 0 : left.length === 0 ? 1 : -1;
|
|
36892
36746
|
}
|
|
36893
|
-
for (let
|
|
36894
|
-
const leftPart = left[
|
|
36895
|
-
const rightPart = right[
|
|
36747
|
+
for (let index = 0; index < Math.max(left.length, right.length); index += 1) {
|
|
36748
|
+
const leftPart = left[index];
|
|
36749
|
+
const rightPart = right[index];
|
|
36896
36750
|
if (leftPart === void 0 || rightPart === void 0) {
|
|
36897
36751
|
return leftPart === rightPart ? 0 : leftPart === void 0 ? -1 : 1;
|
|
36898
36752
|
}
|
|
@@ -36917,8 +36771,8 @@ function compareAgentVersions(left, right) {
|
|
|
36917
36771
|
if (parsedLeft === null || parsedRight === null) {
|
|
36918
36772
|
return null;
|
|
36919
36773
|
}
|
|
36920
|
-
for (let
|
|
36921
|
-
const difference = (parsedLeft.core[
|
|
36774
|
+
for (let index = 0; index < Math.max(parsedLeft.core.length, parsedRight.core.length); index += 1) {
|
|
36775
|
+
const difference = (parsedLeft.core[index] ?? 0) - (parsedRight.core[index] ?? 0);
|
|
36922
36776
|
if (difference !== 0) {
|
|
36923
36777
|
return Math.sign(difference);
|
|
36924
36778
|
}
|
|
@@ -37661,16 +37515,16 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
37661
37515
|
};
|
|
37662
37516
|
#readConnectionForChannel = async (channelId, signal) => {
|
|
37663
37517
|
const normalizedChannelId = validateIdentifier(channelId, "invalid_channel_id");
|
|
37664
|
-
const
|
|
37518
|
+
const index = decodeChannelIndex(
|
|
37665
37519
|
await readJsonFile(this.channelIndexPath(normalizedChannelId), signal, "connection_not_found")
|
|
37666
37520
|
);
|
|
37667
|
-
if (
|
|
37521
|
+
if (index.applicationId !== this.applicationId || index.installationId !== this.installationId || index.channelId !== normalizedChannelId) {
|
|
37668
37522
|
throw new RuntimeInstallationStoreError(
|
|
37669
37523
|
"connection_owner_mismatch",
|
|
37670
37524
|
"The saved Runtime connection belongs to another installation"
|
|
37671
37525
|
);
|
|
37672
37526
|
}
|
|
37673
|
-
return await this.readConnection(
|
|
37527
|
+
return await this.readConnection(index.connectionId, signal);
|
|
37674
37528
|
};
|
|
37675
37529
|
saveConnection = async (input2, signal) => {
|
|
37676
37530
|
const stored = new VerifiedRuntimeConnection(
|
|
@@ -37865,16 +37719,16 @@ function hasExactKeys2(value, expectedKeys) {
|
|
|
37865
37719
|
}
|
|
37866
37720
|
function readSingleOption(arguments_, option) {
|
|
37867
37721
|
const values = [];
|
|
37868
|
-
for (let
|
|
37869
|
-
if (arguments_[
|
|
37722
|
+
for (let index = 0; index < arguments_.length; index += 1) {
|
|
37723
|
+
if (arguments_[index] !== option) {
|
|
37870
37724
|
continue;
|
|
37871
37725
|
}
|
|
37872
|
-
const value = arguments_[
|
|
37726
|
+
const value = arguments_[index + 1];
|
|
37873
37727
|
if (value === void 0 || value.startsWith("--")) {
|
|
37874
37728
|
throw new PairingClientError("invalid_arguments", `${option} requires a value`);
|
|
37875
37729
|
}
|
|
37876
37730
|
values.push(value);
|
|
37877
|
-
|
|
37731
|
+
index += 1;
|
|
37878
37732
|
}
|
|
37879
37733
|
if (values.length !== 1) {
|
|
37880
37734
|
throw new PairingClientError("invalid_arguments", `${option} must be provided exactly once`);
|
|
@@ -37882,8 +37736,8 @@ function readSingleOption(arguments_, option) {
|
|
|
37882
37736
|
return values[0] ?? "";
|
|
37883
37737
|
}
|
|
37884
37738
|
function assertKnownArguments(arguments_) {
|
|
37885
|
-
for (let
|
|
37886
|
-
const option = arguments_[
|
|
37739
|
+
for (let index = 0; index < arguments_.length; index += 2) {
|
|
37740
|
+
const option = arguments_[index];
|
|
37887
37741
|
if (option !== "--url" && option !== "--code" && option !== "--pairing" && option !== "--workspace") {
|
|
37888
37742
|
throw new PairingClientError("invalid_arguments", `Unknown pairing option: ${option ?? "missing option"}`);
|
|
37889
37743
|
}
|
|
@@ -39395,8 +39249,8 @@ var ACTIVE_TURN_TEXT_CHUNK_LIMIT = Math.floor(SESSION_HISTORY_CHARACTER_LIMIT /
|
|
|
39395
39249
|
function boundedRecoveryMessages(messages) {
|
|
39396
39250
|
const selected = [];
|
|
39397
39251
|
let remainingCharacters = SESSION_HISTORY_CHARACTER_LIMIT;
|
|
39398
|
-
for (let
|
|
39399
|
-
const message = messages[
|
|
39252
|
+
for (let index = messages.length - 1; index >= 0 && selected.length < SESSION_HISTORY_MESSAGE_LIMIT; index -= 1) {
|
|
39253
|
+
const message = messages[index];
|
|
39400
39254
|
if (message === void 0) {
|
|
39401
39255
|
break;
|
|
39402
39256
|
}
|
|
@@ -39537,7 +39391,7 @@ var ActiveDaemonTurn = class {
|
|
|
39537
39391
|
];
|
|
39538
39392
|
} else {
|
|
39539
39393
|
this.#timeline = this.#timeline.map(
|
|
39540
|
-
(entry,
|
|
39394
|
+
(entry, index) => index === target && entry.kind === "message" ? { ...entry, content: new Map([...entry.content, [event.contentId, event.content]]) } : entry
|
|
39541
39395
|
);
|
|
39542
39396
|
}
|
|
39543
39397
|
} else if (event.kind === SESSION_PERMISSION_REQUESTED_KIND || event.kind === SESSION_ELICITATION_REQUESTED_KIND) {
|
|
@@ -40538,7 +40392,6 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
40538
40392
|
child2.removeListener("exit", onExit);
|
|
40539
40393
|
}
|
|
40540
40394
|
}
|
|
40541
|
-
var readCodexHistory = async (agent, cwd, nativeSessionId, signal) => await readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal, { detail: "messages" });
|
|
40542
40395
|
var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTurn) => await readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal, {
|
|
40543
40396
|
detail: "rich",
|
|
40544
40397
|
...nativeTurn === void 0 ? {} : { nativeTurn }
|
|
@@ -40547,84 +40400,6 @@ var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTur
|
|
|
40547
40400
|
// src/native-sessions/service.ts
|
|
40548
40401
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
40549
40402
|
import { basename as basename5 } from "node:path";
|
|
40550
|
-
|
|
40551
|
-
// src/native-sessions/acp-history.ts
|
|
40552
|
-
async function readAcpHistory(sessions, directories, bindingId, options, nativeSessionId) {
|
|
40553
|
-
let cursor = null;
|
|
40554
|
-
let inspected = 0;
|
|
40555
|
-
for (let pageNumber = 0; pageNumber < 500 && inspected < 500; pageNumber += 1) {
|
|
40556
|
-
const page = await sessions.listNativeSessions(options, cursor);
|
|
40557
|
-
inspected += page.sessions.length;
|
|
40558
|
-
const found = page.sessions.find((entry) => entry.sessionId === nativeSessionId);
|
|
40559
|
-
if (found !== void 0) {
|
|
40560
|
-
const primary = await directories.identify(bindingId, found.cwd, options.signal);
|
|
40561
|
-
const additional = await Promise.all(
|
|
40562
|
-
found.additionalDirectories.map(
|
|
40563
|
-
async (directory) => await directories.identify(bindingId, directory, options.signal)
|
|
40564
|
-
)
|
|
40565
|
-
);
|
|
40566
|
-
if (primary.path !== options.cwd || additional.length !== options.additionalDirectories.length || additional.some((directory, index2) => directory.path !== options.additionalDirectories[index2])) {
|
|
40567
|
-
throw new AcpExecutionError(
|
|
40568
|
-
"The native Session belongs to another workspace.",
|
|
40569
|
-
{},
|
|
40570
|
-
"session_identity_mismatch"
|
|
40571
|
-
);
|
|
40572
|
-
}
|
|
40573
|
-
return await sessions.previewNativeSession(options, nativeSessionId);
|
|
40574
|
-
}
|
|
40575
|
-
if (page.nextCursor === null || page.nextCursor === cursor) {
|
|
40576
|
-
break;
|
|
40577
|
-
}
|
|
40578
|
-
cursor = page.nextCursor ?? null;
|
|
40579
|
-
}
|
|
40580
|
-
throw new AcpExecutionError("The native Session was not found.", {}, "native_session_not_found");
|
|
40581
|
-
}
|
|
40582
|
-
|
|
40583
|
-
// src/native-sessions/acp-adapter.ts
|
|
40584
|
-
var acpSessionAdapter = {
|
|
40585
|
-
history: async ({ sessions, directories, bindingId, options, nativeSessionId }) => await readAcpHistory(sessions, directories, bindingId, options, nativeSessionId),
|
|
40586
|
-
preview: async ({ sessions, options, nativeSessionId }) => await sessions.previewNativeSession(options, nativeSessionId)
|
|
40587
|
-
};
|
|
40588
|
-
|
|
40589
|
-
// src/native-sessions/codex-adapter.ts
|
|
40590
|
-
async function verifiedHistory(context, full) {
|
|
40591
|
-
const { options, nativeSessionId, directories, bindingId } = context;
|
|
40592
|
-
const snapshot = full ? await readCodexFullHistory(options.agent, options.cwd, nativeSessionId, options.signal) : await readCodexHistory(options.agent, options.cwd, nativeSessionId, options.signal);
|
|
40593
|
-
const resolved = await directories.identify(bindingId, snapshot.cwd, options.signal);
|
|
40594
|
-
if (snapshot.nativeSessionId !== nativeSessionId || resolved.path !== options.cwd) {
|
|
40595
|
-
throw new AcpExecutionError(
|
|
40596
|
-
"Codex returned history for a different session or workspace.",
|
|
40597
|
-
{},
|
|
40598
|
-
"invalid_native_session_response"
|
|
40599
|
-
);
|
|
40600
|
-
}
|
|
40601
|
-
return snapshot.history;
|
|
40602
|
-
}
|
|
40603
|
-
var codexSessionAdapter = {
|
|
40604
|
-
history: async (context) => await verifiedHistory(context, true),
|
|
40605
|
-
// Codex enforces an exclusive writer per thread. Its read-only app-server
|
|
40606
|
-
// history path keeps externally owned conversations previewable.
|
|
40607
|
-
preview: async (context) => await verifiedHistory(context, false)
|
|
40608
|
-
};
|
|
40609
|
-
|
|
40610
|
-
// src/native-sessions/agent-adapter.ts
|
|
40611
|
-
var genericSessionAdapter = {
|
|
40612
|
-
history: async () => {
|
|
40613
|
-
throw new AcpExecutionError("Native history is unavailable for this Agent", {}, "native_session_unsupported");
|
|
40614
|
-
},
|
|
40615
|
-
preview: async ({ sessions, options, nativeSessionId }) => await sessions.previewNativeSession(options, nativeSessionId)
|
|
40616
|
-
};
|
|
40617
|
-
function nativeSessionAdapter(agentId) {
|
|
40618
|
-
if (agentId === "codex") {
|
|
40619
|
-
return codexSessionAdapter;
|
|
40620
|
-
}
|
|
40621
|
-
if (agentId === "claude" || agentId === "opencode" || agentId === "pi") {
|
|
40622
|
-
return acpSessionAdapter;
|
|
40623
|
-
}
|
|
40624
|
-
return genericSessionAdapter;
|
|
40625
|
-
}
|
|
40626
|
-
|
|
40627
|
-
// src/native-sessions/service.ts
|
|
40628
40403
|
var NativeSessionService = class {
|
|
40629
40404
|
#entries = /* @__PURE__ */ new Map();
|
|
40630
40405
|
#cursors = /* @__PURE__ */ new Map();
|
|
@@ -40668,25 +40443,6 @@ var NativeSessionService = class {
|
|
|
40668
40443
|
...await this.#activeTurn(command, options)
|
|
40669
40444
|
};
|
|
40670
40445
|
}
|
|
40671
|
-
if (command.action === "create") {
|
|
40672
|
-
if (!supportsNativeChat(options.agent.id)) {
|
|
40673
|
-
throw new AcpExecutionError(
|
|
40674
|
-
"Native session creation is unavailable for this Agent",
|
|
40675
|
-
{},
|
|
40676
|
-
"native_session_unsupported"
|
|
40677
|
-
);
|
|
40678
|
-
}
|
|
40679
|
-
const nativeSessionId = await this.#sessions.createNativeSession(options);
|
|
40680
|
-
signal.throwIfAborted();
|
|
40681
|
-
this.record(command, "native_session_created");
|
|
40682
|
-
return {
|
|
40683
|
-
action: "create",
|
|
40684
|
-
kind: "native.session.result",
|
|
40685
|
-
nativeSessionId: decodeIdentifier(nativeSessionId),
|
|
40686
|
-
requestId: command.requestId,
|
|
40687
|
-
sessionId: command.sessionId
|
|
40688
|
-
};
|
|
40689
|
-
}
|
|
40690
40446
|
if (command.action === "fork-recorded") {
|
|
40691
40447
|
const source = this.#sessions.findSessions([command.sessionId])[0];
|
|
40692
40448
|
if (source === void 0 || !source.prompted) {
|
|
@@ -40696,7 +40452,7 @@ var NativeSessionService = class {
|
|
|
40696
40452
|
"native_session_not_found"
|
|
40697
40453
|
);
|
|
40698
40454
|
}
|
|
40699
|
-
if (source.agentId !== command.agentId || source.cwd !== cwd || source.additionalDirectories.length !== additionalDirectories.length || source.additionalDirectories.some((path2,
|
|
40455
|
+
if (source.agentId !== command.agentId || source.cwd !== cwd || source.additionalDirectories.length !== additionalDirectories.length || source.additionalDirectories.some((path2, index) => path2 !== additionalDirectories[index])) {
|
|
40700
40456
|
throw new AcpExecutionError(
|
|
40701
40457
|
"The source conversation execution target does not match the fork request",
|
|
40702
40458
|
{},
|
|
@@ -40717,8 +40473,8 @@ var NativeSessionService = class {
|
|
|
40717
40473
|
signal.throwIfAborted();
|
|
40718
40474
|
const directory = await this.#directories.list(this.#config.bindingId, command.directoryId, signal);
|
|
40719
40475
|
const ready2 = {
|
|
40720
|
-
additionalDirectories: additionalDirectories.map((path2,
|
|
40721
|
-
directoryId: command.additionalDirectoryIds[
|
|
40476
|
+
additionalDirectories: additionalDirectories.map((path2, index) => ({
|
|
40477
|
+
directoryId: command.additionalDirectoryIds[index] ?? command.directoryId,
|
|
40722
40478
|
name: basename5(path2) || path2
|
|
40723
40479
|
})),
|
|
40724
40480
|
agentId: command.agentId,
|
|
@@ -40879,44 +40635,6 @@ var NativeSessionService = class {
|
|
|
40879
40635
|
);
|
|
40880
40636
|
}
|
|
40881
40637
|
const target = await this.resolveTarget(command, options, selected);
|
|
40882
|
-
if (command.action === "history") {
|
|
40883
|
-
const history = await nativeSessionAdapter(options.agent.id).history({
|
|
40884
|
-
sessions: this.#sessions,
|
|
40885
|
-
directories: this.#directories,
|
|
40886
|
-
bindingId: command.bindingId,
|
|
40887
|
-
options: { ...options, cwd: target.cwd, additionalDirectories: target.additionalDirectories },
|
|
40888
|
-
nativeSessionId: target.info.sessionId
|
|
40889
|
-
});
|
|
40890
|
-
signal.throwIfAborted();
|
|
40891
|
-
this.record(command, "native_session_history_read");
|
|
40892
|
-
return {
|
|
40893
|
-
...envelope2,
|
|
40894
|
-
action: "history",
|
|
40895
|
-
entryId: command.entryId,
|
|
40896
|
-
history,
|
|
40897
|
-
title: target.info.title ?? "Untitled session"
|
|
40898
|
-
};
|
|
40899
|
-
}
|
|
40900
|
-
if (command.action === "preview") {
|
|
40901
|
-
const history = await nativeSessionAdapter(options.agent.id).preview({
|
|
40902
|
-
sessions: this.#sessions,
|
|
40903
|
-
directories: this.#directories,
|
|
40904
|
-
bindingId: command.bindingId,
|
|
40905
|
-
options: { ...options, cwd: target.cwd, additionalDirectories: target.additionalDirectories },
|
|
40906
|
-
nativeSessionId: target.info.sessionId
|
|
40907
|
-
});
|
|
40908
|
-
signal.throwIfAborted();
|
|
40909
|
-
this.record(command, "native_session_previewed");
|
|
40910
|
-
return {
|
|
40911
|
-
...envelope2,
|
|
40912
|
-
action: "preview",
|
|
40913
|
-
entryId: command.entryId,
|
|
40914
|
-
targetSessionId: command.sessionId,
|
|
40915
|
-
reason: "requested",
|
|
40916
|
-
title: target.info.title ?? "Untitled session",
|
|
40917
|
-
history
|
|
40918
|
-
};
|
|
40919
|
-
}
|
|
40920
40638
|
if (command.action === "delete") {
|
|
40921
40639
|
if (!prepared.capabilities.deleteSession) {
|
|
40922
40640
|
throw new AcpExecutionError(
|
|
@@ -41051,7 +40769,7 @@ var NativeSessionService = class {
|
|
|
41051
40769
|
resolveTarget = async (command, options, selected) => {
|
|
41052
40770
|
let cursor = null;
|
|
41053
40771
|
const visited = /* @__PURE__ */ new Set();
|
|
41054
|
-
for (let
|
|
40772
|
+
for (let index = 0; index < 100; index += 1) {
|
|
41055
40773
|
const page = await this.#sessions.listNativeSessions(options, cursor);
|
|
41056
40774
|
const info = page.sessions.find((entry) => entry.sessionId === selected.nativeSessionId);
|
|
41057
40775
|
if (info !== void 0) {
|
|
@@ -41059,7 +40777,7 @@ var NativeSessionService = class {
|
|
|
41059
40777
|
if (target === null) {
|
|
41060
40778
|
throw new LocalAuthorizationError("The selected native session is not authorized");
|
|
41061
40779
|
}
|
|
41062
|
-
if (target.cwd !== selected.cwd || target.additionalDirectories.length !== selected.additionalDirectories.length || target.additionalDirectories.some((path2,
|
|
40780
|
+
if (target.cwd !== selected.cwd || target.additionalDirectories.length !== selected.additionalDirectories.length || target.additionalDirectories.some((path2, index2) => path2 !== selected.additionalDirectories[index2])) {
|
|
41063
40781
|
throw new AcpExecutionError(
|
|
41064
40782
|
"This session's directory changed. Refresh the list before continuing.",
|
|
41065
40783
|
{},
|
|
@@ -41320,135 +41038,13 @@ var RelayConnectionDiagnostics = class {
|
|
|
41320
41038
|
};
|
|
41321
41039
|
|
|
41322
41040
|
// src/relay-connection/run-relay-connection.ts
|
|
41323
|
-
import { WebSocket as
|
|
41041
|
+
import { WebSocket as WebSocket7 } from "undici";
|
|
41324
41042
|
|
|
41325
41043
|
// src/daemon-command-handler.ts
|
|
41326
|
-
import { WebSocket as
|
|
41327
|
-
|
|
41328
|
-
// src/agent-catalog/handle-agent-catalog-refresh.ts
|
|
41329
|
-
import { WebSocket as WebSocket3 } from "undici";
|
|
41330
|
-
async function retainStillInstalledAgents(previous, refreshed, signal) {
|
|
41331
|
-
const refreshedIdentifiers = new Set(refreshed.map((agent) => agent.id));
|
|
41332
|
-
const retained = [];
|
|
41333
|
-
for (const agent of previous) {
|
|
41334
|
-
if (refreshedIdentifiers.has(agent.id)) {
|
|
41335
|
-
continue;
|
|
41336
|
-
}
|
|
41337
|
-
signal.throwIfAborted();
|
|
41338
|
-
if (await revalidateExecutable(agent.agentIdentity)) {
|
|
41339
|
-
retained.push(agent);
|
|
41340
|
-
}
|
|
41341
|
-
}
|
|
41342
|
-
return Object.freeze([...refreshed, ...retained]);
|
|
41343
|
-
}
|
|
41344
|
-
async function refreshAgentCatalog(config2, resolveEnvironment, signal) {
|
|
41345
|
-
signal.throwIfAborted();
|
|
41346
|
-
const shellEnvironment = await resolveEnvironment(signal);
|
|
41347
|
-
const environment = new DaemonLocalContext(config2.localContext.stateDirectory, shellEnvironment).environment;
|
|
41348
|
-
signal.throwIfAborted();
|
|
41349
|
-
const inventory = await discoverLocalAgentInventory({
|
|
41350
|
-
defaultWorkspace: config2.defaultWorkspace,
|
|
41351
|
-
environment,
|
|
41352
|
-
signal
|
|
41353
|
-
});
|
|
41354
|
-
const previousCatalog = config2.catalog.read();
|
|
41355
|
-
const refreshedAgents = inventory.readyAgents().map((agent) => withDaemonEnvironment(agent, environment));
|
|
41356
|
-
const agents = await retainStillInstalledAgents(previousCatalog.agents, refreshedAgents, signal);
|
|
41357
|
-
const verifiedIdentifiers = new Set(agents.map((agent) => agent.id));
|
|
41358
|
-
config2.catalog.transition(
|
|
41359
|
-
agents,
|
|
41360
|
-
inventory.installable.filter((agent) => !verifiedIdentifiers.has(agent.id))
|
|
41361
|
-
);
|
|
41362
|
-
try {
|
|
41363
|
-
await publishAgentCatalog(config2, signal);
|
|
41364
|
-
} catch (error62) {
|
|
41365
|
-
config2.catalog.transition(previousCatalog.agents, previousCatalog.installableAgents);
|
|
41366
|
-
throw error62;
|
|
41367
|
-
}
|
|
41368
|
-
}
|
|
41369
|
-
function createAgentCatalogRefreshHandler(dependencies) {
|
|
41370
|
-
const { config: config2, audit, diagnostics, socket, signal, timer, resolveEnvironment } = dependencies;
|
|
41371
|
-
const agentCatalogRefreshes = /* @__PURE__ */ new Map();
|
|
41372
|
-
const handle = (command) => {
|
|
41373
|
-
if (agentCatalogRefreshes.has(command.requestId) || agentCatalogRefreshes.size > 0) {
|
|
41374
|
-
if (socket.readyState === WebSocket3.OPEN) {
|
|
41375
|
-
send(socket, {
|
|
41376
|
-
code: "agent_catalog_refresh_busy",
|
|
41377
|
-
kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
41378
|
-
message: "Another local Agent catalog refresh is already running",
|
|
41379
|
-
requestId: command.requestId
|
|
41380
|
-
});
|
|
41381
|
-
}
|
|
41382
|
-
return;
|
|
41383
|
-
}
|
|
41384
|
-
const controller = new AbortController();
|
|
41385
|
-
const operationSignal = AbortSignal.any([signal, controller.signal]);
|
|
41386
|
-
const timeout = timer.schedule(
|
|
41387
|
-
() => controller.abort(
|
|
41388
|
-
new AcpExecutionError(
|
|
41389
|
-
"The local Agent catalog refresh timed out",
|
|
41390
|
-
{},
|
|
41391
|
-
"agent_catalog_refresh_timeout"
|
|
41392
|
-
)
|
|
41393
|
-
),
|
|
41394
|
-
9e4
|
|
41395
|
-
);
|
|
41396
|
-
const completion = (async () => {
|
|
41397
|
-
try {
|
|
41398
|
-
await refreshAgentCatalog(config2, resolveEnvironment, operationSignal);
|
|
41399
|
-
audit.record({
|
|
41400
|
-
commandId: command.requestId,
|
|
41401
|
-
event: "agent_catalog_refreshed",
|
|
41402
|
-
sessionId: "agent-catalog"
|
|
41403
|
-
});
|
|
41404
|
-
if (socket.readyState === WebSocket3.OPEN) {
|
|
41405
|
-
send(socket, {
|
|
41406
|
-
kind: AGENT_CATALOG_REFRESHED_KIND,
|
|
41407
|
-
requestId: command.requestId
|
|
41408
|
-
});
|
|
41409
|
-
}
|
|
41410
|
-
} catch (error62) {
|
|
41411
|
-
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
41412
|
-
"The local Agent catalog refresh was cancelled",
|
|
41413
|
-
{},
|
|
41414
|
-
"agent_catalog_refresh_cancelled"
|
|
41415
|
-
) : error62;
|
|
41416
|
-
audit.record({
|
|
41417
|
-
commandId: command.requestId,
|
|
41418
|
-
details: { code: operationErrorCode(failure2) },
|
|
41419
|
-
event: "agent_catalog_refresh_failed",
|
|
41420
|
-
sessionId: "agent-catalog"
|
|
41421
|
-
});
|
|
41422
|
-
diagnostics.daemonDiagnostic(
|
|
41423
|
-
"agent_catalog_refresh_failed",
|
|
41424
|
-
command.requestId,
|
|
41425
|
-
{ code: operationErrorCode(failure2) },
|
|
41426
|
-
failure2
|
|
41427
|
-
);
|
|
41428
|
-
if (socket.readyState === WebSocket3.OPEN) {
|
|
41429
|
-
send(socket, {
|
|
41430
|
-
code: operationErrorCode(failure2),
|
|
41431
|
-
kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
41432
|
-
message: operationErrorMessage(failure2),
|
|
41433
|
-
requestId: command.requestId
|
|
41434
|
-
});
|
|
41435
|
-
}
|
|
41436
|
-
} finally {
|
|
41437
|
-
timeout.cancel();
|
|
41438
|
-
agentCatalogRefreshes.delete(command.requestId);
|
|
41439
|
-
}
|
|
41440
|
-
})();
|
|
41441
|
-
agentCatalogRefreshes.set(command.requestId, { completion, controller });
|
|
41442
|
-
return;
|
|
41443
|
-
};
|
|
41444
|
-
const settle2 = async () => {
|
|
41445
|
-
await Promise.all([...agentCatalogRefreshes.values()].map((request) => request.completion));
|
|
41446
|
-
};
|
|
41447
|
-
return { handle, settle: settle2 };
|
|
41448
|
-
}
|
|
41044
|
+
import { WebSocket as WebSocket5 } from "undici";
|
|
41449
41045
|
|
|
41450
41046
|
// src/agent-catalog/handle-agent-settings-discovery.ts
|
|
41451
|
-
import { WebSocket as
|
|
41047
|
+
import { WebSocket as WebSocket3 } from "undici";
|
|
41452
41048
|
|
|
41453
41049
|
// src/agent-catalog/discover-agent-settings.ts
|
|
41454
41050
|
import { createHash as createHash6 } from "node:crypto";
|
|
@@ -41936,7 +41532,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
41936
41532
|
(request) => request.agentId === command.agentId && !request.controller.signal.aborted
|
|
41937
41533
|
);
|
|
41938
41534
|
if ([...agentSettingsDiscoveries.values()].some((request) => request.requestIds.has(command.requestId))) {
|
|
41939
|
-
if (socket.readyState ===
|
|
41535
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
41940
41536
|
send(socket, {
|
|
41941
41537
|
code: "agent_settings_discovery_busy",
|
|
41942
41538
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -41951,7 +41547,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
41951
41547
|
return;
|
|
41952
41548
|
}
|
|
41953
41549
|
if (existing !== void 0) {
|
|
41954
|
-
if (socket.readyState ===
|
|
41550
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
41955
41551
|
send(socket, {
|
|
41956
41552
|
code: "agent_settings_discovery_busy",
|
|
41957
41553
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -41962,7 +41558,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
41962
41558
|
return;
|
|
41963
41559
|
}
|
|
41964
41560
|
if (agentSettingsDiscoveries.size >= 4) {
|
|
41965
|
-
if (socket.readyState ===
|
|
41561
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
41966
41562
|
send(socket, {
|
|
41967
41563
|
code: "agent_settings_discovery_busy",
|
|
41968
41564
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -42008,7 +41604,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
42008
41604
|
event: "agent_settings_discovered",
|
|
42009
41605
|
sessionId: `agent-settings:${command.agentId}`
|
|
42010
41606
|
});
|
|
42011
|
-
if (socket.readyState ===
|
|
41607
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
42012
41608
|
send(socket, { ...result.event, requestId });
|
|
42013
41609
|
}
|
|
42014
41610
|
}
|
|
@@ -42034,7 +41630,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
42034
41630
|
`
|
|
42035
41631
|
);
|
|
42036
41632
|
}
|
|
42037
|
-
if (socket.readyState ===
|
|
41633
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
42038
41634
|
for (const requestId of requestIds) {
|
|
42039
41635
|
send(socket, {
|
|
42040
41636
|
code: operationErrorCode(failure2),
|
|
@@ -42180,300 +41776,7 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
|
|
|
42180
41776
|
return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
|
|
42181
41777
|
}
|
|
42182
41778
|
|
|
42183
|
-
// src/native-sessions/live-history-page.ts
|
|
42184
|
-
function encodeLiveHistoryCursor(cursor) {
|
|
42185
|
-
return Buffer.from(JSON.stringify(cursor), "utf8").toString("base64url");
|
|
42186
|
-
}
|
|
42187
|
-
function decodeLiveHistoryCursor(cursor, sessionId) {
|
|
42188
|
-
try {
|
|
42189
|
-
if (!/^[A-Za-z0-9_-]{1,512}$/u.test(cursor)) {
|
|
42190
|
-
throw new Error("Invalid cursor alphabet");
|
|
42191
|
-
}
|
|
42192
|
-
const value = JSON.parse(Buffer.from(cursor, "base64url").toString("utf8"));
|
|
42193
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
42194
|
-
throw new Error("Invalid cursor shape");
|
|
42195
|
-
}
|
|
42196
|
-
const record2 = Object.fromEntries(Object.entries(value));
|
|
42197
|
-
const keys = Object.keys(record2).sort().join(",");
|
|
42198
|
-
const legacyNative = keys === "endIndex,sessionId";
|
|
42199
|
-
const kind = legacyNative ? "native" : record2["kind"];
|
|
42200
|
-
if (keys !== "endIndex,kind,sessionId" && keys !== "endIndex,epoch,kind,sessionId" && !legacyNative || record2["sessionId"] !== sessionId || kind !== "active" && kind !== "native" || typeof record2["endIndex"] !== "number" || !Number.isSafeInteger(record2["endIndex"]) || record2["endIndex"] < 0) {
|
|
42201
|
-
throw new Error("Invalid cursor target");
|
|
42202
|
-
}
|
|
42203
|
-
if (kind === "active") {
|
|
42204
|
-
if (keys !== "endIndex,epoch,kind,sessionId" || typeof record2["epoch"] !== "string") {
|
|
42205
|
-
throw new Error("Invalid active cursor target");
|
|
42206
|
-
}
|
|
42207
|
-
return { endIndex: record2["endIndex"], epoch: record2["epoch"], kind, sessionId };
|
|
42208
|
-
}
|
|
42209
|
-
if (keys !== "endIndex,kind,sessionId" && !legacyNative) {
|
|
42210
|
-
throw new Error("Invalid native cursor target");
|
|
42211
|
-
}
|
|
42212
|
-
return { endIndex: record2["endIndex"], kind, sessionId };
|
|
42213
|
-
} catch (cause) {
|
|
42214
|
-
throw new AcpExecutionError("The native Session history cursor is invalid", { cause }, "invalid_cursor");
|
|
42215
|
-
}
|
|
42216
|
-
}
|
|
42217
|
-
function activeHistoryCursor(sessionId, epoch, endIndex) {
|
|
42218
|
-
return encodeLiveHistoryCursor({ endIndex, epoch, kind: "active", sessionId });
|
|
42219
|
-
}
|
|
42220
|
-
function nativeHistoryCursor(sessionId, endIndex) {
|
|
42221
|
-
return encodeLiveHistoryCursor({ endIndex, kind: "native", sessionId });
|
|
42222
|
-
}
|
|
42223
|
-
function liveHistoryCoveredTurnRanges(history) {
|
|
42224
|
-
const ranges = [];
|
|
42225
|
-
let historyIndex = history.messages.length;
|
|
42226
|
-
for (const commandId of history.coveredCommandIds) {
|
|
42227
|
-
let assistantStartIndex = historyIndex;
|
|
42228
|
-
while (assistantStartIndex > 0 && history.messages[assistantStartIndex - 1]?.role === "assistant") {
|
|
42229
|
-
assistantStartIndex -= 1;
|
|
42230
|
-
}
|
|
42231
|
-
const userIndex = assistantStartIndex - 1;
|
|
42232
|
-
if (assistantStartIndex === historyIndex || history.messages[userIndex]?.role !== "user") {
|
|
42233
|
-
break;
|
|
42234
|
-
}
|
|
42235
|
-
ranges.push({ assistantEndIndex: historyIndex, assistantStartIndex, commandId, userIndex });
|
|
42236
|
-
historyIndex = userIndex;
|
|
42237
|
-
}
|
|
42238
|
-
return ranges;
|
|
42239
|
-
}
|
|
42240
|
-
function historyMessageCharacters(message) {
|
|
42241
|
-
return message.text.length + (message.role === "assistant" ? JSON.stringify(message.activities).length + JSON.stringify(message.content).length : 0);
|
|
42242
|
-
}
|
|
42243
|
-
function isNativeHistoryImageMimeType(mimeType) {
|
|
42244
|
-
return mimeType === "image/png" || mimeType === "image/jpeg" || mimeType === "image/gif" || mimeType === "image/webp";
|
|
42245
|
-
}
|
|
42246
|
-
function selectMessagesBefore(messages, endIndex, messageLimit, characterLimit) {
|
|
42247
|
-
const selected = [];
|
|
42248
|
-
let remainingCharacters = characterLimit;
|
|
42249
|
-
let startIndex = endIndex;
|
|
42250
|
-
for (let index2 = endIndex - 1; index2 >= 0 && selected.length < messageLimit; index2 -= 1) {
|
|
42251
|
-
const message = messages[index2];
|
|
42252
|
-
if (message === void 0) {
|
|
42253
|
-
break;
|
|
42254
|
-
}
|
|
42255
|
-
const characters = historyMessageCharacters(message);
|
|
42256
|
-
if (characters > remainingCharacters) {
|
|
42257
|
-
break;
|
|
42258
|
-
}
|
|
42259
|
-
selected.unshift(message);
|
|
42260
|
-
remainingCharacters -= characters;
|
|
42261
|
-
startIndex = index2;
|
|
42262
|
-
}
|
|
42263
|
-
if (selected.length === 0 && endIndex > 0) {
|
|
42264
|
-
throw new AcpExecutionError(
|
|
42265
|
-
"A native Session history item exceeds the page budget",
|
|
42266
|
-
{},
|
|
42267
|
-
"history_item_too_large"
|
|
42268
|
-
);
|
|
42269
|
-
}
|
|
42270
|
-
return { characters: characterLimit - remainingCharacters, messages: selected, startIndex };
|
|
42271
|
-
}
|
|
42272
|
-
function nativeActiveMessage(message) {
|
|
42273
|
-
if (message.role === "assistant") {
|
|
42274
|
-
return {
|
|
42275
|
-
activities: message.activities,
|
|
42276
|
-
content: message.content,
|
|
42277
|
-
role: "assistant",
|
|
42278
|
-
text: message.text
|
|
42279
|
-
};
|
|
42280
|
-
}
|
|
42281
|
-
const images = (message.images ?? []).flatMap((image) => {
|
|
42282
|
-
if (image.data.length < 4 || image.data.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/u.test(image.data) || !isNativeHistoryImageMimeType(image.mimeType)) {
|
|
42283
|
-
return [];
|
|
42284
|
-
}
|
|
42285
|
-
return [{ data: image.data, mimeType: image.mimeType, name: image.name }];
|
|
42286
|
-
});
|
|
42287
|
-
return { ...images.length === 0 ? {} : { images }, role: "user", text: message.text };
|
|
42288
|
-
}
|
|
42289
|
-
function nativeHistoryCoversCompletedRecovery(history, recovery) {
|
|
42290
|
-
const root = recovery.messages.find((message) => message.role === "user" && message.id === recovery.commandId);
|
|
42291
|
-
if (root === void 0) {
|
|
42292
|
-
return false;
|
|
42293
|
-
}
|
|
42294
|
-
const rootIndex = history.messages.findLastIndex(
|
|
42295
|
-
(message) => message.role === "user" && message.text === root.text
|
|
42296
|
-
);
|
|
42297
|
-
if (rootIndex < 0) {
|
|
42298
|
-
return false;
|
|
42299
|
-
}
|
|
42300
|
-
const nativeAssistant = history.messages.slice(rootIndex + 1).filter((message) => message.role === "assistant");
|
|
42301
|
-
if (nativeAssistant.length === 0) {
|
|
42302
|
-
return false;
|
|
42303
|
-
}
|
|
42304
|
-
const recoveryAssistant = recovery.messages.filter((message) => message.role === "assistant");
|
|
42305
|
-
const recoveryText = recoveryAssistant.map((message) => message.text).join("");
|
|
42306
|
-
const nativeText = nativeAssistant.map((message) => message.text).join("");
|
|
42307
|
-
if (recoveryText.length > 0 && !nativeText.includes(recoveryText)) {
|
|
42308
|
-
return false;
|
|
42309
|
-
}
|
|
42310
|
-
const nativeContent = new Set(
|
|
42311
|
-
nativeAssistant.flatMap((message) => message.content).map((content) => JSON.stringify(content))
|
|
42312
|
-
);
|
|
42313
|
-
return recoveryAssistant.flatMap((message) => message.content).every((content) => nativeContent.has(JSON.stringify(content)));
|
|
42314
|
-
}
|
|
42315
|
-
function historyBeforeActiveTurn(history, activeTurn) {
|
|
42316
|
-
if (history.status === "unavailable") {
|
|
42317
|
-
return history;
|
|
42318
|
-
}
|
|
42319
|
-
const activeRoot = activeTurn.messages.find(
|
|
42320
|
-
(message) => message.role === "user" && message.id === activeTurn.commandId
|
|
42321
|
-
);
|
|
42322
|
-
const matchingActiveUserIndex = activeRoot === void 0 ? -1 : activeTurn.state === "completed" || history.messages.at(-1)?.role === "user" && history.messages.at(-1)?.text === activeRoot.text || history.coveredCommandIds.includes(activeTurn.commandId) ? history.messages.findLastIndex((message) => message.role === "user" && message.text === activeRoot.text) : -1;
|
|
42323
|
-
const activeUserIndex = matchingActiveUserIndex >= 0 ? matchingActiveUserIndex : liveHistoryCoveredTurnRanges(history).find((range) => range.commandId === activeTurn.commandId)?.userIndex ?? -1;
|
|
42324
|
-
if (activeUserIndex < 0) {
|
|
42325
|
-
return history;
|
|
42326
|
-
}
|
|
42327
|
-
return {
|
|
42328
|
-
...history,
|
|
42329
|
-
coveredCommandIds: history.coveredCommandIds.filter((id) => id !== activeTurn.commandId),
|
|
42330
|
-
coveredMessageIds: history.coveredMessageIds.filter(
|
|
42331
|
-
(id) => id !== `${activeTurn.commandId}:user` && id !== `${activeTurn.commandId}:agent`
|
|
42332
|
-
),
|
|
42333
|
-
messages: history.messages.slice(0, activeUserIndex)
|
|
42334
|
-
};
|
|
42335
|
-
}
|
|
42336
|
-
function paginateAvailableNativeHistory(history, sessionId, endIndex, limit, characterLimit) {
|
|
42337
|
-
if (endIndex > history.messages.length) {
|
|
42338
|
-
throw new AcpExecutionError("The native Session history cursor is invalid", {}, "invalid_cursor");
|
|
42339
|
-
}
|
|
42340
|
-
const selected = selectMessagesBefore(history.messages, endIndex, limit, characterLimit);
|
|
42341
|
-
const coveredMessageIds = new Set(history.coveredMessageIds);
|
|
42342
|
-
const ranges = liveHistoryCoveredTurnRanges(history);
|
|
42343
|
-
return {
|
|
42344
|
-
coveredCommandIds: ranges.filter((range) => range.userIndex >= selected.startIndex && range.assistantEndIndex <= endIndex).map((range) => range.commandId),
|
|
42345
|
-
coveredMessageIds: ranges.flatMap((range) => [
|
|
42346
|
-
...range.userIndex >= selected.startIndex && range.userIndex < endIndex && coveredMessageIds.has(`${range.commandId}:user`) ? [`${range.commandId}:user`] : [],
|
|
42347
|
-
...range.assistantStartIndex >= selected.startIndex && range.assistantEndIndex <= endIndex && coveredMessageIds.has(`${range.commandId}:agent`) ? [`${range.commandId}:agent`] : []
|
|
42348
|
-
]),
|
|
42349
|
-
messages: selected.messages,
|
|
42350
|
-
nextCursor: selected.startIndex > 0 ? nativeHistoryCursor(sessionId, selected.startIndex) : null,
|
|
42351
|
-
status: "available",
|
|
42352
|
-
truncated: history.truncated
|
|
42353
|
-
};
|
|
42354
|
-
}
|
|
42355
|
-
function paginateNativeHistory(history, sessionId, cursor, limit) {
|
|
42356
|
-
if (cursor?.kind === "active") {
|
|
42357
|
-
throw new AcpExecutionError("The native Session history cursor is invalid", {}, "invalid_cursor");
|
|
42358
|
-
}
|
|
42359
|
-
if (history.status === "unavailable") {
|
|
42360
|
-
if (cursor !== null) {
|
|
42361
|
-
throw new AcpExecutionError("Unavailable native Session history has no cursor", {}, "invalid_cursor");
|
|
42362
|
-
}
|
|
42363
|
-
return { cause: history.cause, nextCursor: null, status: "unavailable" };
|
|
42364
|
-
}
|
|
42365
|
-
return paginateAvailableNativeHistory(
|
|
42366
|
-
history,
|
|
42367
|
-
sessionId,
|
|
42368
|
-
cursor?.endIndex ?? history.messages.length,
|
|
42369
|
-
limit,
|
|
42370
|
-
SESSION_HISTORY_CHARACTER_LIMIT
|
|
42371
|
-
);
|
|
42372
|
-
}
|
|
42373
|
-
function paginateActiveTurn(history, activeTurn, sessionId, endIndex, limit) {
|
|
42374
|
-
if (endIndex > activeTurn.messages.length) {
|
|
42375
|
-
throw new AcpExecutionError("The native Session history cursor is invalid", {}, "invalid_cursor");
|
|
42376
|
-
}
|
|
42377
|
-
const activeMessages = activeTurn.messages.map(nativeActiveMessage);
|
|
42378
|
-
const active = selectMessagesBefore(activeMessages, endIndex, limit, SESSION_HISTORY_CHARACTER_LIMIT);
|
|
42379
|
-
const historicalLimit = limit - active.messages.length;
|
|
42380
|
-
const historicalCharacterLimit = SESSION_HISTORY_CHARACTER_LIMIT - active.characters;
|
|
42381
|
-
const pendingHistoricalCursor = history.status === "available" && history.messages.length > 0 ? nativeHistoryCursor(sessionId, history.messages.length) : null;
|
|
42382
|
-
const latestHistoricalMessage = history.status === "available" ? history.messages.at(-1) : void 0;
|
|
42383
|
-
const historicalPageFits = latestHistoricalMessage === void 0 || historyMessageCharacters(latestHistoricalMessage) <= historicalCharacterLimit;
|
|
42384
|
-
const historical = active.startIndex === 0 && history.status === "available" && historicalLimit > 0 && historicalPageFits ? paginateAvailableNativeHistory(
|
|
42385
|
-
history,
|
|
42386
|
-
sessionId,
|
|
42387
|
-
history.messages.length,
|
|
42388
|
-
historicalLimit,
|
|
42389
|
-
historicalCharacterLimit
|
|
42390
|
-
) : null;
|
|
42391
|
-
return {
|
|
42392
|
-
streamPosition: { commandId: activeTurn.commandId, epoch: activeTurn.epoch, sequence: activeTurn.sequence },
|
|
42393
|
-
coveredCommandIds: historical?.coveredCommandIds ?? [],
|
|
42394
|
-
coveredMessageIds: [
|
|
42395
|
-
...historical?.coveredMessageIds ?? [],
|
|
42396
|
-
...active.startIndex === 0 ? [`${activeTurn.commandId}:user`, `${activeTurn.commandId}:agent`] : []
|
|
42397
|
-
],
|
|
42398
|
-
messages: [...historical?.messages ?? [], ...active.messages],
|
|
42399
|
-
nextCursor: active.startIndex > 0 ? activeHistoryCursor(sessionId, activeTurn.epoch, active.startIndex) : historical === null ? pendingHistoricalCursor : historical.nextCursor,
|
|
42400
|
-
status: "available",
|
|
42401
|
-
truncated: activeTurn.truncated || (historical?.truncated ?? false)
|
|
42402
|
-
};
|
|
42403
|
-
}
|
|
42404
|
-
function paginateLiveSessionHistory(history, activeTurn, sessionId, encodedCursor, limit) {
|
|
42405
|
-
const cursor = encodedCursor === null ? null : decodeLiveHistoryCursor(encodedCursor, sessionId);
|
|
42406
|
-
if (activeTurn === null || activeTurn.state === "completed" && history.status === "available" && nativeHistoryCoversCompletedRecovery(history, activeTurn)) {
|
|
42407
|
-
return paginateNativeHistory(history, sessionId, cursor, limit);
|
|
42408
|
-
}
|
|
42409
|
-
const historical = historyBeforeActiveTurn(history, activeTurn);
|
|
42410
|
-
if (cursor?.kind === "native") {
|
|
42411
|
-
return paginateNativeHistory(historical, sessionId, cursor, limit);
|
|
42412
|
-
}
|
|
42413
|
-
if (cursor !== null && cursor.epoch !== activeTurn.epoch) {
|
|
42414
|
-
throw new AcpExecutionError("The active Turn history cursor is stale", {}, "stale_cursor");
|
|
42415
|
-
}
|
|
42416
|
-
return paginateActiveTurn(historical, activeTurn, sessionId, cursor?.endIndex ?? activeTurn.messages.length, limit);
|
|
42417
|
-
}
|
|
42418
|
-
|
|
42419
41779
|
// src/daemon-history-commands.ts
|
|
42420
|
-
async function executeSessionLiveHistoryPageLoad(socket, command, config2, directories, audit, sessions, activeTurn, signal) {
|
|
42421
|
-
try {
|
|
42422
|
-
const resolved = await resolveSessionDirectories(
|
|
42423
|
-
directories,
|
|
42424
|
-
config2.bindingId,
|
|
42425
|
-
command.directoryId,
|
|
42426
|
-
command.additionalDirectoryIds,
|
|
42427
|
-
signal
|
|
42428
|
-
);
|
|
42429
|
-
const history = await sessions.loadSessionHistory({
|
|
42430
|
-
additionalDirectories: resolved.additionalDirectories,
|
|
42431
|
-
agent: config2.catalog.find(command.agentId),
|
|
42432
|
-
cwd: resolved.cwd,
|
|
42433
|
-
sessionId: command.sessionId,
|
|
42434
|
-
signal
|
|
42435
|
-
});
|
|
42436
|
-
signal.throwIfAborted();
|
|
42437
|
-
const page = paginateLiveSessionHistory(
|
|
42438
|
-
history,
|
|
42439
|
-
activeTurn(command.sessionId),
|
|
42440
|
-
command.sessionId,
|
|
42441
|
-
command.cursor,
|
|
42442
|
-
command.limit
|
|
42443
|
-
);
|
|
42444
|
-
audit.record({
|
|
42445
|
-
commandId: command.requestId,
|
|
42446
|
-
event: "session_history_loaded",
|
|
42447
|
-
sessionId: command.sessionId
|
|
42448
|
-
});
|
|
42449
|
-
send(socket, {
|
|
42450
|
-
kind: "session.live-history.page.loaded",
|
|
42451
|
-
page,
|
|
42452
|
-
requestId: command.requestId,
|
|
42453
|
-
sessionId: command.sessionId
|
|
42454
|
-
});
|
|
42455
|
-
} catch (error62) {
|
|
42456
|
-
if (signal.aborted) {
|
|
42457
|
-
return;
|
|
42458
|
-
}
|
|
42459
|
-
audit.record({
|
|
42460
|
-
commandId: command.requestId,
|
|
42461
|
-
details: { code: operationErrorCode(error62) },
|
|
42462
|
-
event: "session_history_unavailable",
|
|
42463
|
-
sessionId: command.sessionId
|
|
42464
|
-
});
|
|
42465
|
-
send(socket, {
|
|
42466
|
-
kind: "session.live-history.page.loaded",
|
|
42467
|
-
page: {
|
|
42468
|
-
status: "unavailable",
|
|
42469
|
-
cause: { code: operationErrorCode(error62), message: operationErrorMessage(error62) },
|
|
42470
|
-
nextCursor: null
|
|
42471
|
-
},
|
|
42472
|
-
requestId: command.requestId,
|
|
42473
|
-
sessionId: command.sessionId
|
|
42474
|
-
});
|
|
42475
|
-
}
|
|
42476
|
-
}
|
|
42477
41780
|
async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, eventLogV2, signal) {
|
|
42478
41781
|
try {
|
|
42479
41782
|
const resolved = await resolveSessionDirectories(
|
|
@@ -42494,7 +41797,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
42494
41797
|
const replay = await sessions.loadSessionEventsV2(loadOptions, command.eventLimit, command.cursor);
|
|
42495
41798
|
signal.throwIfAborted();
|
|
42496
41799
|
const events = replay.events.map(
|
|
42497
|
-
(event,
|
|
41800
|
+
(event, index) => eventLogV2.event(command.sessionId, replay.startPosition + index, event, "1970-01-01T00:00:00.000Z")
|
|
42498
41801
|
);
|
|
42499
41802
|
const tailCursor = events.at(-1)?.eventId ?? "";
|
|
42500
41803
|
audit.record({
|
|
@@ -43244,7 +42547,7 @@ async function executeSessionConfigure(publisher, socket, command, config2, dire
|
|
|
43244
42547
|
}
|
|
43245
42548
|
|
|
43246
42549
|
// src/native-sessions/handle-native-requests.ts
|
|
43247
|
-
import { WebSocket as
|
|
42550
|
+
import { WebSocket as WebSocket4 } from "undici";
|
|
43248
42551
|
function createNativeSessionRequestHandler(dependencies) {
|
|
43249
42552
|
const { audit, diagnostics, nativeSessions, publisher, signal, socket, timer } = dependencies;
|
|
43250
42553
|
const pending = /* @__PURE__ */ new Map();
|
|
@@ -43309,7 +42612,7 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
43309
42612
|
}
|
|
43310
42613
|
]);
|
|
43311
42614
|
}
|
|
43312
|
-
if (socket.readyState ===
|
|
42615
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
43313
42616
|
send(socket, result);
|
|
43314
42617
|
}
|
|
43315
42618
|
} catch (error62) {
|
|
@@ -43368,8 +42671,7 @@ function createDaemonCommandHandler({
|
|
|
43368
42671
|
socket,
|
|
43369
42672
|
signal,
|
|
43370
42673
|
runtimeSignal,
|
|
43371
|
-
timer
|
|
43372
|
-
resolveAgentCatalogEnvironment
|
|
42674
|
+
timer
|
|
43373
42675
|
}) {
|
|
43374
42676
|
const handleSettingsDiscovery = createAgentSettingsDiscoveryHandler({
|
|
43375
42677
|
config: config2,
|
|
@@ -43381,20 +42683,10 @@ function createDaemonCommandHandler({
|
|
|
43381
42683
|
signal,
|
|
43382
42684
|
timer
|
|
43383
42685
|
});
|
|
43384
|
-
const handleCatalogRefresh = createAgentCatalogRefreshHandler({
|
|
43385
|
-
config: config2,
|
|
43386
|
-
audit,
|
|
43387
|
-
diagnostics,
|
|
43388
|
-
socket,
|
|
43389
|
-
signal,
|
|
43390
|
-
timer,
|
|
43391
|
-
resolveEnvironment: resolveAgentCatalogEnvironment
|
|
43392
|
-
});
|
|
43393
42686
|
const queueChanged = (sessionId) => {
|
|
43394
42687
|
publisher.publish(sessionId, { kind: "session.queue.changed", sessionId });
|
|
43395
42688
|
eventLogV2.queueChanged(sessionId);
|
|
43396
42689
|
};
|
|
43397
|
-
const activeTurnRecovery = (sessionId) => activeTurns.recovery((command) => command.sessionId === sessionId);
|
|
43398
42690
|
const nativeRequestHandler = createNativeSessionRequestHandler({
|
|
43399
42691
|
audit,
|
|
43400
42692
|
diagnostics,
|
|
@@ -43407,18 +42699,8 @@ function createDaemonCommandHandler({
|
|
|
43407
42699
|
return {
|
|
43408
42700
|
handle: (message) => {
|
|
43409
42701
|
const kind = message.kind;
|
|
43410
|
-
if (kind ===
|
|
43411
|
-
|
|
43412
|
-
void executeSessionLiveHistoryPageLoad(
|
|
43413
|
-
socket,
|
|
43414
|
-
command2,
|
|
43415
|
-
config2,
|
|
43416
|
-
directories,
|
|
43417
|
-
audit,
|
|
43418
|
-
sessions,
|
|
43419
|
-
activeTurnRecovery,
|
|
43420
|
-
signal
|
|
43421
|
-
);
|
|
42702
|
+
if (kind === RUNTIME_PING_KIND) {
|
|
42703
|
+
send(socket, { kind: RUNTIME_PONG_KIND, requestId: message.requestId });
|
|
43422
42704
|
return;
|
|
43423
42705
|
}
|
|
43424
42706
|
if (kind === SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND) {
|
|
@@ -43443,10 +42725,6 @@ function createDaemonCommandHandler({
|
|
|
43443
42725
|
handleSettingsDiscovery.handle(message);
|
|
43444
42726
|
return;
|
|
43445
42727
|
}
|
|
43446
|
-
if (kind === AGENT_CATALOG_REFRESH_KIND) {
|
|
43447
|
-
handleCatalogRefresh.handle(message);
|
|
43448
|
-
return;
|
|
43449
|
-
}
|
|
43450
42728
|
if (kind === NATIVE_SESSION_REQUEST_KIND) {
|
|
43451
42729
|
nativeRequestHandler.handle(message);
|
|
43452
42730
|
return;
|
|
@@ -43460,7 +42738,7 @@ function createDaemonCommandHandler({
|
|
|
43460
42738
|
sessions.findSessions([command2.sessionId])[0]?.cwd ?? null,
|
|
43461
42739
|
externalContent
|
|
43462
42740
|
).catch((error62) => {
|
|
43463
|
-
if (socket.readyState !==
|
|
42741
|
+
if (socket.readyState !== WebSocket5.OPEN || signal.aborted) {
|
|
43464
42742
|
return;
|
|
43465
42743
|
}
|
|
43466
42744
|
send(socket, {
|
|
@@ -43666,17 +42944,13 @@ function createDaemonCommandHandler({
|
|
|
43666
42944
|
});
|
|
43667
42945
|
},
|
|
43668
42946
|
settle: async () => {
|
|
43669
|
-
await Promise.all([
|
|
43670
|
-
nativeRequestHandler.settle(),
|
|
43671
|
-
handleSettingsDiscovery.settle(),
|
|
43672
|
-
handleCatalogRefresh.settle()
|
|
43673
|
-
]);
|
|
42947
|
+
await Promise.all([nativeRequestHandler.settle(), handleSettingsDiscovery.settle()]);
|
|
43674
42948
|
}
|
|
43675
42949
|
};
|
|
43676
42950
|
}
|
|
43677
42951
|
|
|
43678
42952
|
// src/relay-connection/connect.ts
|
|
43679
|
-
import { WebSocket as
|
|
42953
|
+
import { WebSocket as WebSocket6 } from "undici";
|
|
43680
42954
|
var CONNECTION_TIMEOUT_MILLISECONDS = 6e4;
|
|
43681
42955
|
var RelayConnectionError = class extends Error {
|
|
43682
42956
|
code;
|
|
@@ -43694,7 +42968,7 @@ function connectRelay(url2, signal) {
|
|
|
43694
42968
|
const endpoint = new URL(url2);
|
|
43695
42969
|
const headers = runtimeAuthorization(endpoint);
|
|
43696
42970
|
endpoint.searchParams.delete("token");
|
|
43697
|
-
const socket = new
|
|
42971
|
+
const socket = new WebSocket6(endpoint, {
|
|
43698
42972
|
dispatcher: environmentProxyDispatcher,
|
|
43699
42973
|
headers
|
|
43700
42974
|
});
|
|
@@ -43912,8 +43186,7 @@ async function runRelayConnection({
|
|
|
43912
43186
|
diagnostics,
|
|
43913
43187
|
onConnected,
|
|
43914
43188
|
signal,
|
|
43915
|
-
timer
|
|
43916
|
-
resolveAgentCatalogEnvironment
|
|
43189
|
+
timer
|
|
43917
43190
|
}) {
|
|
43918
43191
|
const relayUrl = new URL(config2.relayUrl);
|
|
43919
43192
|
relayUrl.searchParams.set("liveness", "1");
|
|
@@ -43936,8 +43209,7 @@ async function runRelayConnection({
|
|
|
43936
43209
|
socket,
|
|
43937
43210
|
signal: connectionController.signal,
|
|
43938
43211
|
runtimeSignal: signal,
|
|
43939
|
-
timer
|
|
43940
|
-
resolveAgentCatalogEnvironment
|
|
43212
|
+
timer
|
|
43941
43213
|
});
|
|
43942
43214
|
installationObserver.connect(socket);
|
|
43943
43215
|
onConnected();
|
|
@@ -43983,14 +43255,14 @@ async function runRelayConnection({
|
|
|
43983
43255
|
};
|
|
43984
43256
|
const connectionLiveness = new RelayConnectionLiveness(timer, {
|
|
43985
43257
|
send: (message) => {
|
|
43986
|
-
if (socket.readyState !==
|
|
43258
|
+
if (socket.readyState !== WebSocket7.OPEN) {
|
|
43987
43259
|
return false;
|
|
43988
43260
|
}
|
|
43989
43261
|
try {
|
|
43990
43262
|
send(socket, message);
|
|
43991
43263
|
return true;
|
|
43992
43264
|
} catch (error62) {
|
|
43993
|
-
if (socket.readyState !==
|
|
43265
|
+
if (socket.readyState !== WebSocket7.OPEN) {
|
|
43994
43266
|
return false;
|
|
43995
43267
|
}
|
|
43996
43268
|
throw error62;
|
|
@@ -44079,7 +43351,7 @@ async function runRelayConnection({
|
|
|
44079
43351
|
}
|
|
44080
43352
|
|
|
44081
43353
|
// src/relay-connection/session-event-publisher.ts
|
|
44082
|
-
import { WebSocket as
|
|
43354
|
+
import { WebSocket as WebSocket8 } from "undici";
|
|
44083
43355
|
var MAX_BUFFERED_BYTES = 32 * 1024 * 1024;
|
|
44084
43356
|
var DaemonSessionEventPublisher = class {
|
|
44085
43357
|
#socket = null;
|
|
@@ -44096,7 +43368,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
44096
43368
|
};
|
|
44097
43369
|
publish = (sessionId, event) => {
|
|
44098
43370
|
const socket = this.#socket;
|
|
44099
|
-
if (socket === null || socket.readyState !==
|
|
43371
|
+
if (socket === null || socket.readyState !== WebSocket8.OPEN) {
|
|
44100
43372
|
return;
|
|
44101
43373
|
}
|
|
44102
43374
|
const encoded = encodeDaemonToServiceMessage({
|
|
@@ -44120,7 +43392,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
44120
43392
|
};
|
|
44121
43393
|
publishStatus = (event) => {
|
|
44122
43394
|
const socket = this.#socket;
|
|
44123
|
-
if (socket === null || socket.readyState !==
|
|
43395
|
+
if (socket === null || socket.readyState !== WebSocket8.OPEN) {
|
|
44124
43396
|
return;
|
|
44125
43397
|
}
|
|
44126
43398
|
const encoded = encodeDaemonToServiceMessage(event);
|
|
@@ -44135,7 +43407,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
44135
43407
|
};
|
|
44136
43408
|
publishV2 = (event) => {
|
|
44137
43409
|
const socket = this.#socket;
|
|
44138
|
-
if (socket === null || socket.readyState !==
|
|
43410
|
+
if (socket === null || socket.readyState !== WebSocket8.OPEN) {
|
|
44139
43411
|
return;
|
|
44140
43412
|
}
|
|
44141
43413
|
const encoded = encodeDaemonToServiceMessage({ event, kind: SESSION_EVENT_V2_KIND });
|
|
@@ -44184,7 +43456,7 @@ function promptContent(command) {
|
|
|
44184
43456
|
}
|
|
44185
43457
|
return content;
|
|
44186
43458
|
}
|
|
44187
|
-
function
|
|
43459
|
+
function sessionEventV2(daemonGenerationId, sessionId, position, event, recordedAt) {
|
|
44188
43460
|
const sessionPrefix = createHash7("sha256").update(sessionId).digest("hex").slice(0, 16);
|
|
44189
43461
|
return {
|
|
44190
43462
|
eventId: `event-${daemonGenerationId}-${sessionPrefix}-${position.toString().padStart(16, "0")}`,
|
|
@@ -44220,7 +43492,7 @@ var DaemonSessionEventLogV2 = class {
|
|
|
44220
43492
|
record = (sessionId, event, position) => {
|
|
44221
43493
|
this.#publisher.publishV2(this.event(sessionId, position, event, (/* @__PURE__ */ new Date()).toISOString()));
|
|
44222
43494
|
};
|
|
44223
|
-
event = (sessionId, position, event, recordedAt) =>
|
|
43495
|
+
event = (sessionId, position, event, recordedAt) => sessionEventV2(this.daemonGenerationId, sessionId, position, event, recordedAt);
|
|
44224
43496
|
queueChanged = (_sessionId) => void 0;
|
|
44225
43497
|
completed = (sessionId, commandId, _stopReason) => {
|
|
44226
43498
|
const request = this.#queued.get(commandId);
|
|
@@ -44357,7 +43629,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
44357
43629
|
options2.signal
|
|
44358
43630
|
);
|
|
44359
43631
|
return cwd === options2.cwd && additionalDirectories.length === options2.additionalDirectories.length && additionalDirectories.every(
|
|
44360
|
-
(directory,
|
|
43632
|
+
(directory, index) => directory === options2.additionalDirectories[index]
|
|
44361
43633
|
);
|
|
44362
43634
|
});
|
|
44363
43635
|
}
|
|
@@ -44374,10 +43646,6 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
44374
43646
|
let connectionAnnounced = false;
|
|
44375
43647
|
let catalogPublished = false;
|
|
44376
43648
|
let readinessAnnounced = false;
|
|
44377
|
-
const resolveAgentCatalogEnvironment = options.resolveAgentCatalogEnvironment ?? (async (catalogSignal) => {
|
|
44378
|
-
catalogSignal.throwIfAborted();
|
|
44379
|
-
return config2.localContext.environment;
|
|
44380
|
-
});
|
|
44381
43649
|
const startAutomaticIntegrationProvisioning = () => {
|
|
44382
43650
|
if (!connectionAnnounced || !catalogPublished || automaticIntegrationProvisioningStarted) {
|
|
44383
43651
|
return;
|
|
@@ -44455,8 +43723,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
44455
43723
|
announceConnection();
|
|
44456
43724
|
},
|
|
44457
43725
|
signal,
|
|
44458
|
-
timer
|
|
44459
|
-
resolveAgentCatalogEnvironment
|
|
43726
|
+
timer
|
|
44460
43727
|
});
|
|
44461
43728
|
} catch (error62) {
|
|
44462
43729
|
if (signal.aborted) {
|
|
@@ -44625,8 +43892,7 @@ var MobiusRuntimeEngine = class {
|
|
|
44625
43892
|
const audit = new AuditStore();
|
|
44626
43893
|
try {
|
|
44627
43894
|
await runDaemon(this.#config, audit, signal, void 0, {
|
|
44628
|
-
...this.#options.onConnectionStatus === void 0 ? {} : { onConnectionStatus: this.#options.onConnectionStatus }
|
|
44629
|
-
...this.#options.resolveAgentCatalogEnvironment === void 0 ? {} : { resolveAgentCatalogEnvironment: this.#options.resolveAgentCatalogEnvironment }
|
|
43895
|
+
...this.#options.onConnectionStatus === void 0 ? {} : { onConnectionStatus: this.#options.onConnectionStatus }
|
|
44630
43896
|
});
|
|
44631
43897
|
} finally {
|
|
44632
43898
|
audit.close();
|