@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/cli.js
CHANGED
|
@@ -2340,11 +2340,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2340
2340
|
};
|
|
2341
2341
|
this._checkNumberOfArguments();
|
|
2342
2342
|
const processedArgs = [];
|
|
2343
|
-
this.registeredArguments.forEach((declaredArg,
|
|
2343
|
+
this.registeredArguments.forEach((declaredArg, index) => {
|
|
2344
2344
|
let value = declaredArg.defaultValue;
|
|
2345
2345
|
if (declaredArg.variadic) {
|
|
2346
|
-
if (
|
|
2347
|
-
value = this.args.slice(
|
|
2346
|
+
if (index < this.args.length) {
|
|
2347
|
+
value = this.args.slice(index);
|
|
2348
2348
|
if (declaredArg.parseArg) {
|
|
2349
2349
|
value = value.reduce((processed, v) => {
|
|
2350
2350
|
return myParseArg(declaredArg, v, processed);
|
|
@@ -2353,13 +2353,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2353
2353
|
} else if (value === void 0) {
|
|
2354
2354
|
value = [];
|
|
2355
2355
|
}
|
|
2356
|
-
} else if (
|
|
2357
|
-
value = this.args[
|
|
2356
|
+
} else if (index < this.args.length) {
|
|
2357
|
+
value = this.args[index];
|
|
2358
2358
|
if (declaredArg.parseArg) {
|
|
2359
2359
|
value = myParseArg(declaredArg, value, declaredArg.defaultValue);
|
|
2360
2360
|
}
|
|
2361
2361
|
}
|
|
2362
|
-
processedArgs[
|
|
2362
|
+
processedArgs[index] = value;
|
|
2363
2363
|
});
|
|
2364
2364
|
this.processedArgs = processedArgs;
|
|
2365
2365
|
}
|
|
@@ -2653,10 +2653,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2653
2653
|
}
|
|
2654
2654
|
}
|
|
2655
2655
|
if (/^--[^=]+=/.test(arg)) {
|
|
2656
|
-
const
|
|
2657
|
-
const option = this._findOption(arg.slice(0,
|
|
2656
|
+
const index = arg.indexOf("=");
|
|
2657
|
+
const option = this._findOption(arg.slice(0, index));
|
|
2658
2658
|
if (option && (option.required || option.optional)) {
|
|
2659
|
-
this.emit(`option:${option.name()}`, arg.slice(
|
|
2659
|
+
this.emit(`option:${option.name()}`, arg.slice(index + 1));
|
|
2660
2660
|
continue;
|
|
2661
2661
|
}
|
|
2662
2662
|
}
|
|
@@ -3381,7 +3381,7 @@ var program = new Command();
|
|
|
3381
3381
|
// package.json
|
|
3382
3382
|
var package_default = {
|
|
3383
3383
|
name: "@moxt-ai/mobius",
|
|
3384
|
-
version: "0.0.
|
|
3384
|
+
version: "0.0.174",
|
|
3385
3385
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
3386
3386
|
type: "module",
|
|
3387
3387
|
bin: {
|
|
@@ -8320,11 +8320,11 @@ var $ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => {
|
|
|
8320
8320
|
return payload;
|
|
8321
8321
|
};
|
|
8322
8322
|
});
|
|
8323
|
-
function handleArrayResult(result, final,
|
|
8323
|
+
function handleArrayResult(result, final, index) {
|
|
8324
8324
|
if (result.issues.length) {
|
|
8325
|
-
final.issues.push(...prefixIssues(
|
|
8325
|
+
final.issues.push(...prefixIssues(index, result.issues));
|
|
8326
8326
|
}
|
|
8327
|
-
final.value[
|
|
8327
|
+
final.value[index] = result.value;
|
|
8328
8328
|
}
|
|
8329
8329
|
var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
8330
8330
|
$ZodType.init(inst, def);
|
|
@@ -8935,14 +8935,14 @@ function mergeValues(a, b) {
|
|
|
8935
8935
|
return { valid: false, mergeErrorPath: [] };
|
|
8936
8936
|
}
|
|
8937
8937
|
const newArray = [];
|
|
8938
|
-
for (let
|
|
8939
|
-
const itemA = a[
|
|
8940
|
-
const itemB = b[
|
|
8938
|
+
for (let index = 0; index < a.length; index++) {
|
|
8939
|
+
const itemA = a[index];
|
|
8940
|
+
const itemB = b[index];
|
|
8941
8941
|
const sharedValue = mergeValues(itemA, itemB);
|
|
8942
8942
|
if (!sharedValue.valid) {
|
|
8943
8943
|
return {
|
|
8944
8944
|
valid: false,
|
|
8945
|
-
mergeErrorPath: [
|
|
8945
|
+
mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
|
|
8946
8946
|
};
|
|
8947
8947
|
}
|
|
8948
8948
|
newArray.push(sharedValue.data);
|
|
@@ -9093,11 +9093,11 @@ function getTupleOptStart(items, key) {
|
|
|
9093
9093
|
}
|
|
9094
9094
|
return 0;
|
|
9095
9095
|
}
|
|
9096
|
-
function handleTupleResult(result, final,
|
|
9096
|
+
function handleTupleResult(result, final, index) {
|
|
9097
9097
|
if (result.issues.length) {
|
|
9098
|
-
final.issues.push(...prefixIssues(
|
|
9098
|
+
final.issues.push(...prefixIssues(index, result.issues));
|
|
9099
9099
|
}
|
|
9100
|
-
final.value[
|
|
9100
|
+
final.value[index] = result.value;
|
|
9101
9101
|
}
|
|
9102
9102
|
function handleTupleResults(itemResults, final, items, input2, optoutStart) {
|
|
9103
9103
|
for (let i = 0; i < items.length; i++) {
|
|
@@ -23778,7 +23778,7 @@ function detectVersion(schema, defaultTarget) {
|
|
|
23778
23778
|
return defaultTarget ?? "draft-2020-12";
|
|
23779
23779
|
}
|
|
23780
23780
|
function applyMinItems(items, minItems) {
|
|
23781
|
-
return items.map((item,
|
|
23781
|
+
return items.map((item, index) => index < minItems ? item : item.optional());
|
|
23782
23782
|
}
|
|
23783
23783
|
function decodeJSONPointerSegment(segment) {
|
|
23784
23784
|
return segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
@@ -27852,9 +27852,9 @@ function comparePrerelease(left, right) {
|
|
|
27852
27852
|
if (left.length === 0 || right.length === 0) {
|
|
27853
27853
|
return left.length === right.length ? 0 : left.length === 0 ? 1 : -1;
|
|
27854
27854
|
}
|
|
27855
|
-
for (let
|
|
27856
|
-
const leftPart = left[
|
|
27857
|
-
const rightPart = right[
|
|
27855
|
+
for (let index = 0; index < Math.max(left.length, right.length); index += 1) {
|
|
27856
|
+
const leftPart = left[index];
|
|
27857
|
+
const rightPart = right[index];
|
|
27858
27858
|
if (leftPart === void 0 || rightPart === void 0) {
|
|
27859
27859
|
return leftPart === rightPart ? 0 : leftPart === void 0 ? -1 : 1;
|
|
27860
27860
|
}
|
|
@@ -27879,8 +27879,8 @@ function compareAgentVersions(left, right) {
|
|
|
27879
27879
|
if (parsedLeft === null || parsedRight === null) {
|
|
27880
27880
|
return null;
|
|
27881
27881
|
}
|
|
27882
|
-
for (let
|
|
27883
|
-
const difference = (parsedLeft.core[
|
|
27882
|
+
for (let index = 0; index < Math.max(parsedLeft.core.length, parsedRight.core.length); index += 1) {
|
|
27883
|
+
const difference = (parsedLeft.core[index] ?? 0) - (parsedRight.core[index] ?? 0);
|
|
27884
27884
|
if (difference !== 0) {
|
|
27885
27885
|
return Math.sign(difference);
|
|
27886
27886
|
}
|
|
@@ -28416,9 +28416,6 @@ var AGENT_INSTALL_CANCELLED_KIND = "agent.integration.install.cancelled";
|
|
|
28416
28416
|
var AGENT_SETTINGS_DISCOVER_KIND = "agent.settings.discover";
|
|
28417
28417
|
var AGENT_SETTINGS_DISCOVERED_KIND = "agent.settings.discovered";
|
|
28418
28418
|
var AGENT_SETTINGS_DISCOVERY_FAILED_KIND = "agent.settings.discovery.failed";
|
|
28419
|
-
var AGENT_CATALOG_REFRESH_KIND = "agent.catalog.refresh";
|
|
28420
|
-
var AGENT_CATALOG_REFRESHED_KIND = "agent.catalog.refreshed";
|
|
28421
|
-
var AGENT_CATALOG_REFRESH_FAILED_KIND = "agent.catalog.refresh.failed";
|
|
28422
28419
|
var FILE_READ_KIND = "file.read";
|
|
28423
28420
|
var FILE_BEGIN_KIND = "file.begin";
|
|
28424
28421
|
var FILE_CHUNK_KIND = "file.chunk";
|
|
@@ -28580,20 +28577,6 @@ var agentSettingsDiscoveryFailedEventSchema = external_exports.object({
|
|
|
28580
28577
|
message: external_exports.string().min(1).max(500),
|
|
28581
28578
|
requestId: identifierStringSchema
|
|
28582
28579
|
}).readonly();
|
|
28583
|
-
var agentCatalogRefreshCommandSchema = external_exports.object({
|
|
28584
|
-
kind: external_exports.literal(AGENT_CATALOG_REFRESH_KIND),
|
|
28585
|
-
requestId: identifierStringSchema
|
|
28586
|
-
}).readonly();
|
|
28587
|
-
var agentCatalogRefreshedEventSchema = external_exports.object({
|
|
28588
|
-
kind: external_exports.literal(AGENT_CATALOG_REFRESHED_KIND),
|
|
28589
|
-
requestId: identifierStringSchema
|
|
28590
|
-
}).readonly();
|
|
28591
|
-
var agentCatalogRefreshFailedEventSchema = external_exports.object({
|
|
28592
|
-
code: identifierStringSchema,
|
|
28593
|
-
kind: external_exports.literal(AGENT_CATALOG_REFRESH_FAILED_KIND),
|
|
28594
|
-
message: external_exports.string().min(1).max(500),
|
|
28595
|
-
requestId: identifierStringSchema
|
|
28596
|
-
}).readonly();
|
|
28597
28580
|
var sessionConfigurationSelectionSchema = external_exports.object({
|
|
28598
28581
|
booleanValue: external_exports.boolean(),
|
|
28599
28582
|
configId: identifierStringSchema,
|
|
@@ -28641,12 +28624,12 @@ var DEFAULT_AGENT_EXECUTION_CONFIGURATION = Object.freeze({
|
|
|
28641
28624
|
});
|
|
28642
28625
|
var sessionConfigurationSelectionsSchema = external_exports.array(sessionConfigurationSelectionSchema).max(100).superRefine((selections, context) => {
|
|
28643
28626
|
const identifiers = /* @__PURE__ */ new Set();
|
|
28644
|
-
for (const [
|
|
28627
|
+
for (const [index, selection] of selections.entries()) {
|
|
28645
28628
|
if (identifiers.has(selection.configId)) {
|
|
28646
28629
|
context.addIssue({
|
|
28647
28630
|
code: "custom",
|
|
28648
28631
|
message: "Session configuration identifiers must be unique",
|
|
28649
|
-
path: [
|
|
28632
|
+
path: [index, "configId"]
|
|
28650
28633
|
});
|
|
28651
28634
|
}
|
|
28652
28635
|
identifiers.add(selection.configId);
|
|
@@ -28998,12 +28981,6 @@ var decodeAgentSettingsDiscoveredEvent = (encoded) => decode3(encoded, agentSett
|
|
|
28998
28981
|
var encodeAgentSettingsDiscoveredEvent = (message) => encode3(message, agentSettingsDiscoveredEventSchema);
|
|
28999
28982
|
var decodeAgentSettingsDiscoveryFailedEvent = (encoded) => decode3(encoded, agentSettingsDiscoveryFailedEventSchema);
|
|
29000
28983
|
var encodeAgentSettingsDiscoveryFailedEvent = (message) => encode3(message, agentSettingsDiscoveryFailedEventSchema);
|
|
29001
|
-
var decodeAgentCatalogRefreshCommand = (encoded) => decode3(encoded, agentCatalogRefreshCommandSchema);
|
|
29002
|
-
var encodeAgentCatalogRefreshCommand = (message) => encode3(message, agentCatalogRefreshCommandSchema);
|
|
29003
|
-
var decodeAgentCatalogRefreshedEvent = (encoded) => decode3(encoded, agentCatalogRefreshedEventSchema);
|
|
29004
|
-
var encodeAgentCatalogRefreshedEvent = (message) => encode3(message, agentCatalogRefreshedEventSchema);
|
|
29005
|
-
var decodeAgentCatalogRefreshFailedEvent = (encoded) => decode3(encoded, agentCatalogRefreshFailedEventSchema);
|
|
29006
|
-
var encodeAgentCatalogRefreshFailedEvent = (message) => encode3(message, agentCatalogRefreshFailedEventSchema);
|
|
29007
28984
|
var decodeFileReadCommand = (encoded) => decode3(encoded, fileReadCommandSchema);
|
|
29008
28985
|
var encodeFileReadCommand = (message) => encode3(message, fileReadCommandSchema);
|
|
29009
28986
|
var decodeFileBeginEvent = (encoded) => decode3(encoded, fileBeginEventSchema);
|
|
@@ -29072,6 +29049,8 @@ var SESSION_CANCEL_KIND = "session.cancel";
|
|
|
29072
29049
|
var RUNTIME_LIVENESS_READY_KIND = "runtime.liveness.ready";
|
|
29073
29050
|
var RUNTIME_HEARTBEAT_KIND = "runtime.heartbeat";
|
|
29074
29051
|
var RUNTIME_HEARTBEAT_ACK_KIND = "runtime.heartbeat.ack";
|
|
29052
|
+
var RUNTIME_PING_KIND = "runtime.ping";
|
|
29053
|
+
var RUNTIME_PONG_KIND = "runtime.pong";
|
|
29075
29054
|
var SESSION_STARTED_KIND = "session.started";
|
|
29076
29055
|
var SESSION_QUEUED_KIND = "session.queued";
|
|
29077
29056
|
var AGENT_MESSAGE_DELTA_KIND = "agent.message.delta";
|
|
@@ -29384,6 +29363,16 @@ function decodeRuntimeHeartbeatAckEvent(encoded) {
|
|
|
29384
29363
|
kind: RUNTIME_HEARTBEAT_ACK_KIND
|
|
29385
29364
|
};
|
|
29386
29365
|
}
|
|
29366
|
+
function decodeRuntimePingCommand(encoded) {
|
|
29367
|
+
const value = parseJson2(encoded);
|
|
29368
|
+
assertKind(value, RUNTIME_PING_KIND);
|
|
29369
|
+
return { kind: RUNTIME_PING_KIND, requestId: readIdentifier(value, "requestId") };
|
|
29370
|
+
}
|
|
29371
|
+
function decodeRuntimePongEvent(encoded) {
|
|
29372
|
+
const value = parseJson2(encoded);
|
|
29373
|
+
assertKind(value, RUNTIME_PONG_KIND);
|
|
29374
|
+
return { kind: RUNTIME_PONG_KIND, requestId: readIdentifier(value, "requestId") };
|
|
29375
|
+
}
|
|
29387
29376
|
function decodeSessionStartedEvent(encoded) {
|
|
29388
29377
|
const value = parseJson2(encoded);
|
|
29389
29378
|
assertKind(value, SESSION_STARTED_KIND);
|
|
@@ -29481,6 +29470,12 @@ function encodeRuntimeHeartbeatEvent(message) {
|
|
|
29481
29470
|
function encodeRuntimeHeartbeatAckEvent(message) {
|
|
29482
29471
|
return JSON.stringify(decodeRuntimeHeartbeatAckEvent(JSON.stringify(message)));
|
|
29483
29472
|
}
|
|
29473
|
+
function encodeRuntimePingCommand(message) {
|
|
29474
|
+
return JSON.stringify(decodeRuntimePingCommand(JSON.stringify(message)));
|
|
29475
|
+
}
|
|
29476
|
+
function encodeRuntimePongEvent(message) {
|
|
29477
|
+
return JSON.stringify(decodeRuntimePongEvent(JSON.stringify(message)));
|
|
29478
|
+
}
|
|
29484
29479
|
function decodeAgentActivityNarrationEvent(encoded) {
|
|
29485
29480
|
const value = parseJson2(encoded);
|
|
29486
29481
|
assertKind(value, AGENT_ACTIVITY_NARRATION_KIND);
|
|
@@ -29594,10 +29589,6 @@ function withinHistoryContentLimits(history) {
|
|
|
29594
29589
|
) <= SESSION_HISTORY_IMAGE_CHARACTER_LIMIT;
|
|
29595
29590
|
}
|
|
29596
29591
|
var sessionHistorySchema = external_exports.discriminatedUnion("status", [availableSessionHistorySchema, unavailableSessionHistorySchema]).refine(withinHistoryContentLimits);
|
|
29597
|
-
var nativeMessagePageSchema = external_exports.discriminatedUnion("status", [
|
|
29598
|
-
availableSessionHistoryObjectSchema.extend({ nextCursor: external_exports.string().max(512).nullable() }).readonly(),
|
|
29599
|
-
unavailableSessionHistoryObjectSchema.extend({ nextCursor: external_exports.null() }).readonly()
|
|
29600
|
-
]).refine(withinHistoryContentLimits);
|
|
29601
29592
|
|
|
29602
29593
|
// ../protocol/src/native-sessions.ts
|
|
29603
29594
|
var NATIVE_SESSION_REQUEST_KIND = "native.session.request";
|
|
@@ -29663,10 +29654,7 @@ var identity = {
|
|
|
29663
29654
|
directoryId
|
|
29664
29655
|
};
|
|
29665
29656
|
var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
29666
|
-
external_exports.object({ ...identity, action: external_exports.literal("create") }).readonly(),
|
|
29667
29657
|
external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
|
|
29668
|
-
external_exports.object({ ...identity, action: external_exports.literal("preview"), entryId: identifierStringSchema }).readonly(),
|
|
29669
|
-
external_exports.object({ ...identity, action: external_exports.literal("history"), entryId: identifierStringSchema }).readonly(),
|
|
29670
29658
|
external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
29671
29659
|
external_exports.object({
|
|
29672
29660
|
...identity,
|
|
@@ -29692,10 +29680,7 @@ var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
|
29692
29680
|
}).readonly()
|
|
29693
29681
|
]);
|
|
29694
29682
|
var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
29695
|
-
external_exports.object({ ...identity, action: external_exports.literal("create") }).readonly(),
|
|
29696
29683
|
external_exports.object({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifierStringSchema }).readonly(),
|
|
29697
|
-
external_exports.object({ ...identity, action: external_exports.literal("preview"), entryId: identifierStringSchema }).readonly(),
|
|
29698
|
-
external_exports.object({ ...identity, action: external_exports.literal("history"), entryId: identifierStringSchema }).readonly(),
|
|
29699
29684
|
external_exports.object({ ...identity, action: external_exports.literal("find"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
29700
29685
|
external_exports.object({
|
|
29701
29686
|
...identity,
|
|
@@ -29735,7 +29720,6 @@ var resultEnvelope = {
|
|
|
29735
29720
|
kind: external_exports.literal(NATIVE_SESSION_RESULT_KIND)
|
|
29736
29721
|
};
|
|
29737
29722
|
var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
29738
|
-
external_exports.object({ ...resultEnvelope, action: external_exports.literal("create"), nativeSessionId: identifierStringSchema }).readonly(),
|
|
29739
29723
|
external_exports.object({
|
|
29740
29724
|
...resultEnvelope,
|
|
29741
29725
|
action: external_exports.literal("active-turn"),
|
|
@@ -29768,22 +29752,6 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
|
29768
29752
|
ready: sessionReadyEventSchema,
|
|
29769
29753
|
title: external_exports.string().max(500)
|
|
29770
29754
|
}).readonly(),
|
|
29771
|
-
external_exports.object({
|
|
29772
|
-
...resultEnvelope,
|
|
29773
|
-
action: external_exports.literal("preview"),
|
|
29774
|
-
entryId: identifierStringSchema,
|
|
29775
|
-
targetSessionId: identifierStringSchema,
|
|
29776
|
-
reason: external_exports.enum(["continuation_unavailable", "requested"]),
|
|
29777
|
-
history: sessionHistorySchema,
|
|
29778
|
-
title: external_exports.string().max(500)
|
|
29779
|
-
}).readonly(),
|
|
29780
|
-
external_exports.object({
|
|
29781
|
-
...resultEnvelope,
|
|
29782
|
-
action: external_exports.literal("history"),
|
|
29783
|
-
entryId: identifierStringSchema,
|
|
29784
|
-
history: sessionHistorySchema,
|
|
29785
|
-
title: external_exports.string().max(500)
|
|
29786
|
-
}).readonly(),
|
|
29787
29755
|
external_exports.object({
|
|
29788
29756
|
...resultEnvelope,
|
|
29789
29757
|
action: external_exports.literal("delete"),
|
|
@@ -30190,12 +30158,12 @@ var sessionExportV2Schema = external_exports.object({
|
|
|
30190
30158
|
}).readonly().superRefine((session, context) => {
|
|
30191
30159
|
let previousPosition = 0n;
|
|
30192
30160
|
const eventIds = /* @__PURE__ */ new Set();
|
|
30193
|
-
for (const [
|
|
30161
|
+
for (const [index, event] of session.events.entries()) {
|
|
30194
30162
|
if (event.sessionId !== session.sessionId) {
|
|
30195
30163
|
context.addIssue({
|
|
30196
30164
|
code: "custom",
|
|
30197
30165
|
message: "Exported event belongs to a different Session",
|
|
30198
|
-
path: ["events",
|
|
30166
|
+
path: ["events", index, "sessionId"]
|
|
30199
30167
|
});
|
|
30200
30168
|
}
|
|
30201
30169
|
const position = BigInt(event.position);
|
|
@@ -30203,14 +30171,14 @@ var sessionExportV2Schema = external_exports.object({
|
|
|
30203
30171
|
context.addIssue({
|
|
30204
30172
|
code: "custom",
|
|
30205
30173
|
message: "Exported events are not in increasing position order",
|
|
30206
|
-
path: ["events",
|
|
30174
|
+
path: ["events", index, "position"]
|
|
30207
30175
|
});
|
|
30208
30176
|
}
|
|
30209
30177
|
if (eventIds.has(event.eventId)) {
|
|
30210
30178
|
context.addIssue({
|
|
30211
30179
|
code: "custom",
|
|
30212
30180
|
message: "Exported event identities are not unique",
|
|
30213
|
-
path: ["events",
|
|
30181
|
+
path: ["events", index, "eventId"]
|
|
30214
30182
|
});
|
|
30215
30183
|
}
|
|
30216
30184
|
previousPosition = position;
|
|
@@ -30354,28 +30322,9 @@ function decodeRecordedSessionEvent(encoded) {
|
|
|
30354
30322
|
var encodeRecordedSessionEvent = (event) => JSON.stringify(decodeRecordedSessionEvent(JSON.stringify(event)));
|
|
30355
30323
|
|
|
30356
30324
|
// ../protocol/src/session-live-history.ts
|
|
30357
|
-
var SESSION_LIVE_HISTORY_PAGE_LOAD_KIND = "session.live-history.page.load";
|
|
30358
|
-
var SESSION_LIVE_HISTORY_PAGE_LOADED_KIND = "session.live-history.page.loaded";
|
|
30359
30325
|
var SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND = "session.live-history.v2.page.load";
|
|
30360
30326
|
var SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND = "session.live-history.v2.page.loaded";
|
|
30361
30327
|
var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
|
|
30362
|
-
var sessionLiveHistoryPageLoadSchema = external_exports.object({
|
|
30363
|
-
additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
|
|
30364
|
-
agentId: identifierStringSchema,
|
|
30365
|
-
bindingId: identifierStringSchema,
|
|
30366
|
-
cursor: external_exports.string().min(1).max(512).nullable(),
|
|
30367
|
-
directoryId: directoryIdentifier,
|
|
30368
|
-
kind: external_exports.literal(SESSION_LIVE_HISTORY_PAGE_LOAD_KIND),
|
|
30369
|
-
limit: external_exports.number().int().min(1).max(100),
|
|
30370
|
-
requestId: identifierStringSchema,
|
|
30371
|
-
sessionId: identifierStringSchema
|
|
30372
|
-
}).readonly();
|
|
30373
|
-
var sessionLiveHistoryPageLoadedSchema = external_exports.object({
|
|
30374
|
-
kind: external_exports.literal(SESSION_LIVE_HISTORY_PAGE_LOADED_KIND),
|
|
30375
|
-
page: nativeMessagePageSchema,
|
|
30376
|
-
requestId: identifierStringSchema,
|
|
30377
|
-
sessionId: identifierStringSchema
|
|
30378
|
-
}).readonly();
|
|
30379
30328
|
var sessionLiveHistoryV2PageLoadSchema = external_exports.object({
|
|
30380
30329
|
additionalDirectoryIds: external_exports.array(directoryIdentifier).max(16).readonly(),
|
|
30381
30330
|
agentId: identifierStringSchema,
|
|
@@ -30401,10 +30350,6 @@ function decode7(schema, encoded) {
|
|
|
30401
30350
|
throw new ProtocolMessageError("Invalid live Session history message", { cause });
|
|
30402
30351
|
}
|
|
30403
30352
|
}
|
|
30404
|
-
var decodeSessionLiveHistoryPageLoad = (encoded) => decode7(sessionLiveHistoryPageLoadSchema, encoded);
|
|
30405
|
-
var decodeSessionLiveHistoryPageLoaded = (encoded) => decode7(sessionLiveHistoryPageLoadedSchema, encoded);
|
|
30406
|
-
var encodeSessionLiveHistoryPageLoad = (value) => JSON.stringify(sessionLiveHistoryPageLoadSchema.parse(value));
|
|
30407
|
-
var encodeSessionLiveHistoryPageLoaded = (value) => JSON.stringify(sessionLiveHistoryPageLoadedSchema.parse(value));
|
|
30408
30353
|
var decodeSessionLiveHistoryV2PageLoad = (encoded) => decode7(sessionLiveHistoryV2PageLoadSchema, encoded);
|
|
30409
30354
|
var decodeSessionLiveHistoryV2PageLoaded = (encoded) => decode7(sessionLiveHistoryV2PageLoadedSchema, encoded);
|
|
30410
30355
|
var encodeSessionLiveHistoryV2PageLoad = (value) => JSON.stringify(sessionLiveHistoryV2PageLoadSchema.parse(value));
|
|
@@ -30421,11 +30366,6 @@ function defineMessageSignature(kind, encoder, decoder) {
|
|
|
30421
30366
|
};
|
|
30422
30367
|
}
|
|
30423
30368
|
var serviceToDaemonSignatures = {
|
|
30424
|
-
[AGENT_CATALOG_REFRESH_KIND]: defineMessageSignature(
|
|
30425
|
-
AGENT_CATALOG_REFRESH_KIND,
|
|
30426
|
-
encodeAgentCatalogRefreshCommand,
|
|
30427
|
-
decodeAgentCatalogRefreshCommand
|
|
30428
|
-
),
|
|
30429
30369
|
[AGENT_INSTALL_CANCEL_KIND]: defineMessageSignature(
|
|
30430
30370
|
AGENT_INSTALL_CANCEL_KIND,
|
|
30431
30371
|
encodeAgentInstallCancelCommand,
|
|
@@ -30468,6 +30408,7 @@ var serviceToDaemonSignatures = {
|
|
|
30468
30408
|
encodeRuntimeLivenessReadyEvent,
|
|
30469
30409
|
decodeRuntimeLivenessReadyEvent
|
|
30470
30410
|
),
|
|
30411
|
+
[RUNTIME_PING_KIND]: defineMessageSignature(RUNTIME_PING_KIND, encodeRuntimePingCommand, decodeRuntimePingCommand),
|
|
30471
30412
|
[SESSION_CANCEL_KIND]: defineMessageSignature(
|
|
30472
30413
|
SESSION_CANCEL_KIND,
|
|
30473
30414
|
encodeSessionCancelCommand,
|
|
@@ -30483,11 +30424,6 @@ var serviceToDaemonSignatures = {
|
|
|
30483
30424
|
encodeSessionElicitationRespondCommand,
|
|
30484
30425
|
decodeSessionElicitationRespondCommand
|
|
30485
30426
|
),
|
|
30486
|
-
[SESSION_LIVE_HISTORY_PAGE_LOAD_KIND]: defineMessageSignature(
|
|
30487
|
-
SESSION_LIVE_HISTORY_PAGE_LOAD_KIND,
|
|
30488
|
-
encodeSessionLiveHistoryPageLoad,
|
|
30489
|
-
decodeSessionLiveHistoryPageLoad
|
|
30490
|
-
),
|
|
30491
30427
|
[SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND]: defineMessageSignature(
|
|
30492
30428
|
SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND,
|
|
30493
30429
|
encodeSessionLiveHistoryV2PageLoad,
|
|
@@ -30529,16 +30465,6 @@ function decodeServiceToDaemonMessage(encoded) {
|
|
|
30529
30465
|
return signature.decoder(encoded);
|
|
30530
30466
|
}
|
|
30531
30467
|
var daemonToServiceSignatures = {
|
|
30532
|
-
[AGENT_CATALOG_REFRESHED_KIND]: defineMessageSignature(
|
|
30533
|
-
AGENT_CATALOG_REFRESHED_KIND,
|
|
30534
|
-
encodeAgentCatalogRefreshedEvent,
|
|
30535
|
-
decodeAgentCatalogRefreshedEvent
|
|
30536
|
-
),
|
|
30537
|
-
[AGENT_CATALOG_REFRESH_FAILED_KIND]: defineMessageSignature(
|
|
30538
|
-
AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
30539
|
-
encodeAgentCatalogRefreshFailedEvent,
|
|
30540
|
-
decodeAgentCatalogRefreshFailedEvent
|
|
30541
|
-
),
|
|
30542
30468
|
[AGENT_INSTALL_CANCELLED_KIND]: defineMessageSignature(
|
|
30543
30469
|
AGENT_INSTALL_CANCELLED_KIND,
|
|
30544
30470
|
encodeAgentInstallCancelledEvent,
|
|
@@ -30608,6 +30534,7 @@ var daemonToServiceSignatures = {
|
|
|
30608
30534
|
encodeRuntimeHeartbeatEvent,
|
|
30609
30535
|
decodeRuntimeHeartbeatEvent
|
|
30610
30536
|
),
|
|
30537
|
+
[RUNTIME_PONG_KIND]: defineMessageSignature(RUNTIME_PONG_KIND, encodeRuntimePongEvent, decodeRuntimePongEvent),
|
|
30611
30538
|
[SESSION_EVENT_KIND]: defineMessageSignature(
|
|
30612
30539
|
SESSION_EVENT_KIND,
|
|
30613
30540
|
encodeSessionEventEnvelope,
|
|
@@ -30623,11 +30550,6 @@ var daemonToServiceSignatures = {
|
|
|
30623
30550
|
encodeSessionOperationFailedEvent,
|
|
30624
30551
|
decodeSessionOperationFailedEvent
|
|
30625
30552
|
),
|
|
30626
|
-
[SESSION_LIVE_HISTORY_PAGE_LOADED_KIND]: defineMessageSignature(
|
|
30627
|
-
SESSION_LIVE_HISTORY_PAGE_LOADED_KIND,
|
|
30628
|
-
encodeSessionLiveHistoryPageLoaded,
|
|
30629
|
-
decodeSessionLiveHistoryPageLoaded
|
|
30630
|
-
),
|
|
30631
30553
|
[SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND]: defineMessageSignature(
|
|
30632
30554
|
SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND,
|
|
30633
30555
|
encodeSessionLiveHistoryV2PageLoaded,
|
|
@@ -31052,16 +30974,16 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
31052
30974
|
};
|
|
31053
30975
|
#readConnectionForChannel = async (channelId, signal) => {
|
|
31054
30976
|
const normalizedChannelId = validateIdentifier(channelId, "invalid_channel_id");
|
|
31055
|
-
const
|
|
30977
|
+
const index = decodeChannelIndex(
|
|
31056
30978
|
await readJsonFile(this.channelIndexPath(normalizedChannelId), signal, "connection_not_found")
|
|
31057
30979
|
);
|
|
31058
|
-
if (
|
|
30980
|
+
if (index.applicationId !== this.applicationId || index.installationId !== this.installationId || index.channelId !== normalizedChannelId) {
|
|
31059
30981
|
throw new RuntimeInstallationStoreError(
|
|
31060
30982
|
"connection_owner_mismatch",
|
|
31061
30983
|
"The saved Runtime connection belongs to another installation"
|
|
31062
30984
|
);
|
|
31063
30985
|
}
|
|
31064
|
-
return await this.readConnection(
|
|
30986
|
+
return await this.readConnection(index.connectionId, signal);
|
|
31065
30987
|
};
|
|
31066
30988
|
saveConnection = async (input2, signal) => {
|
|
31067
30989
|
const stored = new VerifiedRuntimeConnection(
|
|
@@ -31256,16 +31178,16 @@ function hasExactKeys2(value, expectedKeys) {
|
|
|
31256
31178
|
}
|
|
31257
31179
|
function readSingleOption(arguments_, option) {
|
|
31258
31180
|
const values = [];
|
|
31259
|
-
for (let
|
|
31260
|
-
if (arguments_[
|
|
31181
|
+
for (let index = 0; index < arguments_.length; index += 1) {
|
|
31182
|
+
if (arguments_[index] !== option) {
|
|
31261
31183
|
continue;
|
|
31262
31184
|
}
|
|
31263
|
-
const value = arguments_[
|
|
31185
|
+
const value = arguments_[index + 1];
|
|
31264
31186
|
if (value === void 0 || value.startsWith("--")) {
|
|
31265
31187
|
throw new PairingClientError("invalid_arguments", `${option} requires a value`);
|
|
31266
31188
|
}
|
|
31267
31189
|
values.push(value);
|
|
31268
|
-
|
|
31190
|
+
index += 1;
|
|
31269
31191
|
}
|
|
31270
31192
|
if (values.length !== 1) {
|
|
31271
31193
|
throw new PairingClientError("invalid_arguments", `${option} must be provided exactly once`);
|
|
@@ -31273,8 +31195,8 @@ function readSingleOption(arguments_, option) {
|
|
|
31273
31195
|
return values[0] ?? "";
|
|
31274
31196
|
}
|
|
31275
31197
|
function assertKnownArguments(arguments_) {
|
|
31276
|
-
for (let
|
|
31277
|
-
const option = arguments_[
|
|
31198
|
+
for (let index = 0; index < arguments_.length; index += 2) {
|
|
31199
|
+
const option = arguments_[index];
|
|
31278
31200
|
if (option !== "--url" && option !== "--code" && option !== "--pairing" && option !== "--workspace") {
|
|
31279
31201
|
throw new PairingClientError("invalid_arguments", `Unknown pairing option: ${option ?? "missing option"}`);
|
|
31280
31202
|
}
|
|
@@ -31674,7 +31596,7 @@ function startsWith(bytes, signature, offset = 0) {
|
|
|
31674
31596
|
if (bytes.byteLength < offset + signature.byteLength) {
|
|
31675
31597
|
return false;
|
|
31676
31598
|
}
|
|
31677
|
-
return signature.every((value,
|
|
31599
|
+
return signature.every((value, index) => bytes[offset + index] === value);
|
|
31678
31600
|
}
|
|
31679
31601
|
function sniffRasterMime(bytes) {
|
|
31680
31602
|
if (startsWith(bytes, PNG_SIGNATURE)) {
|
|
@@ -31802,7 +31724,7 @@ function startsWith2(bytes, signature, offset = 0) {
|
|
|
31802
31724
|
if (bytes.byteLength < offset + signature.byteLength) {
|
|
31803
31725
|
return false;
|
|
31804
31726
|
}
|
|
31805
|
-
return signature.every((value,
|
|
31727
|
+
return signature.every((value, index) => bytes[offset + index] === value);
|
|
31806
31728
|
}
|
|
31807
31729
|
function sniffVideoMime(bytes) {
|
|
31808
31730
|
if (startsWith2(bytes, MP4_FILE_TYPE, 4)) {
|
|
@@ -31931,10 +31853,10 @@ async function replaceImageMarkers(text2, replace) {
|
|
|
31931
31853
|
let cursor = 0;
|
|
31932
31854
|
let rewritten = "";
|
|
31933
31855
|
for (const match of matches) {
|
|
31934
|
-
const
|
|
31935
|
-
rewritten += text2.slice(cursor,
|
|
31856
|
+
const index = match.index ?? 0;
|
|
31857
|
+
rewritten += text2.slice(cursor, index);
|
|
31936
31858
|
rewritten += await replace(match[1] ?? "");
|
|
31937
|
-
cursor =
|
|
31859
|
+
cursor = index + match[0].length;
|
|
31938
31860
|
}
|
|
31939
31861
|
return `${rewritten}${text2.slice(cursor)}`;
|
|
31940
31862
|
}
|
|
@@ -35059,7 +34981,7 @@ function haveSameKeys(left, right) {
|
|
|
35059
34981
|
const leftKeys = Object.keys(left);
|
|
35060
34982
|
const rightKeys = Object.keys(right);
|
|
35061
34983
|
if (leftKeys.length !== rightKeys.length) return false;
|
|
35062
|
-
for (const [
|
|
34984
|
+
for (const [index, key] of leftKeys.entries()) if (key !== rightKeys[index]) return false;
|
|
35063
34985
|
return true;
|
|
35064
34986
|
}
|
|
35065
34987
|
function mapUpdateSet(table, values) {
|
|
@@ -36565,60 +36487,6 @@ function sqliteTableWithCasing(casing) {
|
|
|
36565
36487
|
}
|
|
36566
36488
|
var sqliteTable = sqliteTableWithCasing(void 0);
|
|
36567
36489
|
|
|
36568
|
-
// ../../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
|
|
36569
|
-
var IndexBuilderOn = class {
|
|
36570
|
-
static [entityKind] = "SQLiteIndexBuilderOn";
|
|
36571
|
-
constructor(name2, unique) {
|
|
36572
|
-
this.name = name2;
|
|
36573
|
-
this.unique = unique;
|
|
36574
|
-
}
|
|
36575
|
-
on(...columns) {
|
|
36576
|
-
return new IndexBuilder(this.name, columns, this.unique);
|
|
36577
|
-
}
|
|
36578
|
-
};
|
|
36579
|
-
var IndexBuilder = class {
|
|
36580
|
-
static [entityKind] = "SQLiteIndexBuilder";
|
|
36581
|
-
/** @internal */
|
|
36582
|
-
config;
|
|
36583
|
-
constructor(name2, columns, unique) {
|
|
36584
|
-
this.config = {
|
|
36585
|
-
name: name2,
|
|
36586
|
-
columns,
|
|
36587
|
-
unique,
|
|
36588
|
-
where: void 0
|
|
36589
|
-
};
|
|
36590
|
-
}
|
|
36591
|
-
/**
|
|
36592
|
-
* Condition for partial index.
|
|
36593
|
-
*/
|
|
36594
|
-
where(condition) {
|
|
36595
|
-
this.config.where = condition;
|
|
36596
|
-
return this;
|
|
36597
|
-
}
|
|
36598
|
-
/** @internal */
|
|
36599
|
-
build(table) {
|
|
36600
|
-
return new Index(this.config, table);
|
|
36601
|
-
}
|
|
36602
|
-
};
|
|
36603
|
-
var Index = class {
|
|
36604
|
-
static [entityKind] = "SQLiteIndex";
|
|
36605
|
-
config;
|
|
36606
|
-
isNameExplicit;
|
|
36607
|
-
constructor(config2, table) {
|
|
36608
|
-
this.config = {
|
|
36609
|
-
...config2,
|
|
36610
|
-
table
|
|
36611
|
-
};
|
|
36612
|
-
this.isNameExplicit = !!config2.name;
|
|
36613
|
-
}
|
|
36614
|
-
};
|
|
36615
|
-
function index(name2) {
|
|
36616
|
-
return new IndexBuilderOn(name2, false);
|
|
36617
|
-
}
|
|
36618
|
-
function uniqueIndex(name2) {
|
|
36619
|
-
return new IndexBuilderOn(name2, true);
|
|
36620
|
-
}
|
|
36621
|
-
|
|
36622
36490
|
// ../../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
|
|
36623
36491
|
function extractUsedTable(table) {
|
|
36624
36492
|
if (is(table, SQLiteTable)) return [`${table[Table.Symbol.BaseName]}`];
|
|
@@ -37443,8 +37311,8 @@ var SQLiteDialect = class {
|
|
|
37443
37311
|
buildJoins(joins) {
|
|
37444
37312
|
if (!joins || joins.length === 0) return;
|
|
37445
37313
|
const joinsArray = [];
|
|
37446
|
-
if (joins) for (const [
|
|
37447
|
-
if (
|
|
37314
|
+
if (joins) for (const [index, joinMeta] of joins.entries()) {
|
|
37315
|
+
if (index === 0) joinsArray.push(sql` `);
|
|
37448
37316
|
const table = joinMeta.table;
|
|
37449
37317
|
const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
|
|
37450
37318
|
if (is(table, SQLiteTable)) {
|
|
@@ -37454,7 +37322,7 @@ var SQLiteDialect = class {
|
|
|
37454
37322
|
const alias = tableName === origTableName ? void 0 : joinMeta.alias;
|
|
37455
37323
|
joinsArray.push(sql`${sql.raw(joinMeta.joinType)} join ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`);
|
|
37456
37324
|
} else joinsArray.push(sql`${sql.raw(joinMeta.joinType)} join ${table}${onSql}`);
|
|
37457
|
-
if (
|
|
37325
|
+
if (index < joins.length - 1) joinsArray.push(sql` `);
|
|
37458
37326
|
}
|
|
37459
37327
|
return sql.join(joinsArray);
|
|
37460
37328
|
}
|
|
@@ -37463,9 +37331,9 @@ var SQLiteDialect = class {
|
|
|
37463
37331
|
}
|
|
37464
37332
|
buildOrderBy(orderBy) {
|
|
37465
37333
|
const orderByList = [];
|
|
37466
|
-
if (orderBy) for (const [
|
|
37334
|
+
if (orderBy) for (const [index, orderByValue] of orderBy.entries()) {
|
|
37467
37335
|
orderByList.push(orderByValue);
|
|
37468
|
-
if (
|
|
37336
|
+
if (index < orderBy.length - 1) orderByList.push(sql`, `);
|
|
37469
37337
|
}
|
|
37470
37338
|
return orderByList.length > 0 ? sql` order by ${sql.join(orderByList)}` : void 0;
|
|
37471
37339
|
}
|
|
@@ -37493,9 +37361,9 @@ var SQLiteDialect = class {
|
|
|
37493
37361
|
const whereSql = where ? sql` where ${where}` : void 0;
|
|
37494
37362
|
const havingSql = having ? sql` having ${having}` : void 0;
|
|
37495
37363
|
const groupByList = [];
|
|
37496
|
-
if (groupBy) for (const [
|
|
37364
|
+
if (groupBy) for (const [index, groupByValue] of groupBy.entries()) {
|
|
37497
37365
|
groupByList.push(groupByValue);
|
|
37498
|
-
if (
|
|
37366
|
+
if (index < groupBy.length - 1) groupByList.push(sql`, `);
|
|
37499
37367
|
}
|
|
37500
37368
|
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}`;
|
|
37501
37369
|
if (setOperators.length > 0) return this.buildSetOperations(finalQuery, setOperators);
|
|
@@ -38787,6 +38655,10 @@ var acpSessionStoreMigrations = [
|
|
|
38787
38655
|
{
|
|
38788
38656
|
"name": "0002_equal_black_queen.sql",
|
|
38789
38657
|
"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`);"
|
|
38658
|
+
},
|
|
38659
|
+
{
|
|
38660
|
+
"name": "0003_silky_ravenous.sql",
|
|
38661
|
+
"sql": "DROP TABLE `session_event_v2`;"
|
|
38790
38662
|
}
|
|
38791
38663
|
];
|
|
38792
38664
|
|
|
@@ -38808,21 +38680,6 @@ var deletedAcpSession = sqliteTable("deleted_acp_session", {
|
|
|
38808
38680
|
sessionId: text("session_id").primaryKey()
|
|
38809
38681
|
});
|
|
38810
38682
|
|
|
38811
|
-
// src/schema/acp-session-store/session-event-v2.ts
|
|
38812
|
-
var sessionEventV2 = sqliteTable(
|
|
38813
|
-
"session_event_v2",
|
|
38814
|
-
{
|
|
38815
|
-
eventId: text("event_id").primaryKey(),
|
|
38816
|
-
eventJson: text("event_json").notNull(),
|
|
38817
|
-
position: integer2("position").notNull(),
|
|
38818
|
-
sessionId: text("session_id").notNull()
|
|
38819
|
-
},
|
|
38820
|
-
(table) => [
|
|
38821
|
-
uniqueIndex("session_event_v2_session_position_unique").on(table.sessionId, table.position),
|
|
38822
|
-
index("session_event_v2_session_position_index").on(table.sessionId, table.position)
|
|
38823
|
-
]
|
|
38824
|
-
);
|
|
38825
|
-
|
|
38826
38683
|
// src/acp/session-store.ts
|
|
38827
38684
|
var AcpStoredSession = class {
|
|
38828
38685
|
additionalDirectories;
|
|
@@ -38939,15 +38796,15 @@ var SqliteAcpSessionStore = class {
|
|
|
38939
38796
|
this.#sqliteDatabase.close();
|
|
38940
38797
|
throw new Error("The ACP Session database was created by a newer Mobius version");
|
|
38941
38798
|
}
|
|
38942
|
-
for (let
|
|
38943
|
-
const migration = acpSessionStoreMigrations[
|
|
38799
|
+
for (let index = version2; index < acpSessionStoreMigrations.length; index += 1) {
|
|
38800
|
+
const migration = acpSessionStoreMigrations[index];
|
|
38944
38801
|
if (migration === void 0) {
|
|
38945
38802
|
throw new Error("The ACP Session migration is unavailable");
|
|
38946
38803
|
}
|
|
38947
38804
|
this.#sqliteDatabase.exec("BEGIN IMMEDIATE");
|
|
38948
38805
|
try {
|
|
38949
38806
|
this.#sqliteDatabase.exec(migration.sql);
|
|
38950
|
-
this.#sqliteDatabase.exec(`PRAGMA user_version = ${
|
|
38807
|
+
this.#sqliteDatabase.exec(`PRAGMA user_version = ${index + 1}`);
|
|
38951
38808
|
this.#sqliteDatabase.exec("COMMIT");
|
|
38952
38809
|
} catch (error62) {
|
|
38953
38810
|
this.#sqliteDatabase.exec("ROLLBACK");
|
|
@@ -39023,7 +38880,7 @@ var RetryableAcpInitializationError = class extends AcpExecutionError {
|
|
|
39023
38880
|
}
|
|
39024
38881
|
};
|
|
39025
38882
|
function arraysEqual(left, right) {
|
|
39026
|
-
return left.length === right.length && left.every((value,
|
|
38883
|
+
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
39027
38884
|
}
|
|
39028
38885
|
function recordsEqual(left, right) {
|
|
39029
38886
|
const leftEntries = Object.entries(left);
|
|
@@ -40759,9 +40616,6 @@ var LocalExternalContentStore = class {
|
|
|
40759
40616
|
};
|
|
40760
40617
|
|
|
40761
40618
|
// src/native-sessions/chat-agent.ts
|
|
40762
|
-
function supportsNativeChat(agentId) {
|
|
40763
|
-
return agentId === "codex" || agentId === "claude" || agentId === "opencode" || agentId === "pi";
|
|
40764
|
-
}
|
|
40765
40619
|
function isNativeChatSessionId(agentId, sessionId) {
|
|
40766
40620
|
if (!nativeSessionIdSchema.safeParse(sessionId).success) {
|
|
40767
40621
|
return false;
|
|
@@ -40820,9 +40674,9 @@ var AcpProcessCapacityLock = class {
|
|
|
40820
40674
|
return await waiter.completion.promise;
|
|
40821
40675
|
} finally {
|
|
40822
40676
|
signal.removeEventListener("abort", waiter.cancel);
|
|
40823
|
-
const
|
|
40824
|
-
if (
|
|
40825
|
-
this.#waiters.splice(
|
|
40677
|
+
const index = this.#waiters.indexOf(waiter);
|
|
40678
|
+
if (index >= 0) {
|
|
40679
|
+
this.#waiters.splice(index, 1);
|
|
40826
40680
|
}
|
|
40827
40681
|
}
|
|
40828
40682
|
};
|
|
@@ -42876,8 +42730,8 @@ var ACTIVE_TURN_TEXT_CHUNK_LIMIT = Math.floor(SESSION_HISTORY_CHARACTER_LIMIT /
|
|
|
42876
42730
|
function boundedRecoveryMessages(messages) {
|
|
42877
42731
|
const selected = [];
|
|
42878
42732
|
let remainingCharacters = SESSION_HISTORY_CHARACTER_LIMIT;
|
|
42879
|
-
for (let
|
|
42880
|
-
const message = messages[
|
|
42733
|
+
for (let index = messages.length - 1; index >= 0 && selected.length < SESSION_HISTORY_MESSAGE_LIMIT; index -= 1) {
|
|
42734
|
+
const message = messages[index];
|
|
42881
42735
|
if (message === void 0) {
|
|
42882
42736
|
break;
|
|
42883
42737
|
}
|
|
@@ -43018,7 +42872,7 @@ var ActiveDaemonTurn = class {
|
|
|
43018
42872
|
];
|
|
43019
42873
|
} else {
|
|
43020
42874
|
this.#timeline = this.#timeline.map(
|
|
43021
|
-
(entry,
|
|
42875
|
+
(entry, index) => index === target && entry.kind === "message" ? { ...entry, content: new Map([...entry.content, [event.contentId, event.content]]) } : entry
|
|
43022
42876
|
);
|
|
43023
42877
|
}
|
|
43024
42878
|
} else if (event.kind === SESSION_PERMISSION_REQUESTED_KIND || event.kind === SESSION_ELICITATION_REQUESTED_KIND) {
|
|
@@ -44019,7 +43873,6 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
44019
43873
|
child2.removeListener("exit", onExit);
|
|
44020
43874
|
}
|
|
44021
43875
|
}
|
|
44022
|
-
var readCodexHistory = async (agent, cwd, nativeSessionId, signal) => await readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal, { detail: "messages" });
|
|
44023
43876
|
var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTurn) => await readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal, {
|
|
44024
43877
|
detail: "rich",
|
|
44025
43878
|
...nativeTurn === void 0 ? {} : { nativeTurn }
|
|
@@ -44028,84 +43881,6 @@ var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTur
|
|
|
44028
43881
|
// src/native-sessions/service.ts
|
|
44029
43882
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
44030
43883
|
import { basename as basename5 } from "node:path";
|
|
44031
|
-
|
|
44032
|
-
// src/native-sessions/acp-history.ts
|
|
44033
|
-
async function readAcpHistory(sessions, directories, bindingId, options, nativeSessionId) {
|
|
44034
|
-
let cursor = null;
|
|
44035
|
-
let inspected = 0;
|
|
44036
|
-
for (let pageNumber = 0; pageNumber < 500 && inspected < 500; pageNumber += 1) {
|
|
44037
|
-
const page = await sessions.listNativeSessions(options, cursor);
|
|
44038
|
-
inspected += page.sessions.length;
|
|
44039
|
-
const found = page.sessions.find((entry) => entry.sessionId === nativeSessionId);
|
|
44040
|
-
if (found !== void 0) {
|
|
44041
|
-
const primary = await directories.identify(bindingId, found.cwd, options.signal);
|
|
44042
|
-
const additional = await Promise.all(
|
|
44043
|
-
found.additionalDirectories.map(
|
|
44044
|
-
async (directory) => await directories.identify(bindingId, directory, options.signal)
|
|
44045
|
-
)
|
|
44046
|
-
);
|
|
44047
|
-
if (primary.path !== options.cwd || additional.length !== options.additionalDirectories.length || additional.some((directory, index2) => directory.path !== options.additionalDirectories[index2])) {
|
|
44048
|
-
throw new AcpExecutionError(
|
|
44049
|
-
"The native Session belongs to another workspace.",
|
|
44050
|
-
{},
|
|
44051
|
-
"session_identity_mismatch"
|
|
44052
|
-
);
|
|
44053
|
-
}
|
|
44054
|
-
return await sessions.previewNativeSession(options, nativeSessionId);
|
|
44055
|
-
}
|
|
44056
|
-
if (page.nextCursor === null || page.nextCursor === cursor) {
|
|
44057
|
-
break;
|
|
44058
|
-
}
|
|
44059
|
-
cursor = page.nextCursor ?? null;
|
|
44060
|
-
}
|
|
44061
|
-
throw new AcpExecutionError("The native Session was not found.", {}, "native_session_not_found");
|
|
44062
|
-
}
|
|
44063
|
-
|
|
44064
|
-
// src/native-sessions/acp-adapter.ts
|
|
44065
|
-
var acpSessionAdapter = {
|
|
44066
|
-
history: async ({ sessions, directories, bindingId, options, nativeSessionId }) => await readAcpHistory(sessions, directories, bindingId, options, nativeSessionId),
|
|
44067
|
-
preview: async ({ sessions, options, nativeSessionId }) => await sessions.previewNativeSession(options, nativeSessionId)
|
|
44068
|
-
};
|
|
44069
|
-
|
|
44070
|
-
// src/native-sessions/codex-adapter.ts
|
|
44071
|
-
async function verifiedHistory(context, full) {
|
|
44072
|
-
const { options, nativeSessionId, directories, bindingId } = context;
|
|
44073
|
-
const snapshot = full ? await readCodexFullHistory(options.agent, options.cwd, nativeSessionId, options.signal) : await readCodexHistory(options.agent, options.cwd, nativeSessionId, options.signal);
|
|
44074
|
-
const resolved = await directories.identify(bindingId, snapshot.cwd, options.signal);
|
|
44075
|
-
if (snapshot.nativeSessionId !== nativeSessionId || resolved.path !== options.cwd) {
|
|
44076
|
-
throw new AcpExecutionError(
|
|
44077
|
-
"Codex returned history for a different session or workspace.",
|
|
44078
|
-
{},
|
|
44079
|
-
"invalid_native_session_response"
|
|
44080
|
-
);
|
|
44081
|
-
}
|
|
44082
|
-
return snapshot.history;
|
|
44083
|
-
}
|
|
44084
|
-
var codexSessionAdapter = {
|
|
44085
|
-
history: async (context) => await verifiedHistory(context, true),
|
|
44086
|
-
// Codex enforces an exclusive writer per thread. Its read-only app-server
|
|
44087
|
-
// history path keeps externally owned conversations previewable.
|
|
44088
|
-
preview: async (context) => await verifiedHistory(context, false)
|
|
44089
|
-
};
|
|
44090
|
-
|
|
44091
|
-
// src/native-sessions/agent-adapter.ts
|
|
44092
|
-
var genericSessionAdapter = {
|
|
44093
|
-
history: async () => {
|
|
44094
|
-
throw new AcpExecutionError("Native history is unavailable for this Agent", {}, "native_session_unsupported");
|
|
44095
|
-
},
|
|
44096
|
-
preview: async ({ sessions, options, nativeSessionId }) => await sessions.previewNativeSession(options, nativeSessionId)
|
|
44097
|
-
};
|
|
44098
|
-
function nativeSessionAdapter(agentId) {
|
|
44099
|
-
if (agentId === "codex") {
|
|
44100
|
-
return codexSessionAdapter;
|
|
44101
|
-
}
|
|
44102
|
-
if (agentId === "claude" || agentId === "opencode" || agentId === "pi") {
|
|
44103
|
-
return acpSessionAdapter;
|
|
44104
|
-
}
|
|
44105
|
-
return genericSessionAdapter;
|
|
44106
|
-
}
|
|
44107
|
-
|
|
44108
|
-
// src/native-sessions/service.ts
|
|
44109
43884
|
var NativeSessionService = class {
|
|
44110
43885
|
#entries = /* @__PURE__ */ new Map();
|
|
44111
43886
|
#cursors = /* @__PURE__ */ new Map();
|
|
@@ -44149,25 +43924,6 @@ var NativeSessionService = class {
|
|
|
44149
43924
|
...await this.#activeTurn(command, options)
|
|
44150
43925
|
};
|
|
44151
43926
|
}
|
|
44152
|
-
if (command.action === "create") {
|
|
44153
|
-
if (!supportsNativeChat(options.agent.id)) {
|
|
44154
|
-
throw new AcpExecutionError(
|
|
44155
|
-
"Native session creation is unavailable for this Agent",
|
|
44156
|
-
{},
|
|
44157
|
-
"native_session_unsupported"
|
|
44158
|
-
);
|
|
44159
|
-
}
|
|
44160
|
-
const nativeSessionId = await this.#sessions.createNativeSession(options);
|
|
44161
|
-
signal.throwIfAborted();
|
|
44162
|
-
this.record(command, "native_session_created");
|
|
44163
|
-
return {
|
|
44164
|
-
action: "create",
|
|
44165
|
-
kind: "native.session.result",
|
|
44166
|
-
nativeSessionId: decodeIdentifier(nativeSessionId),
|
|
44167
|
-
requestId: command.requestId,
|
|
44168
|
-
sessionId: command.sessionId
|
|
44169
|
-
};
|
|
44170
|
-
}
|
|
44171
43927
|
if (command.action === "fork-recorded") {
|
|
44172
43928
|
const source = this.#sessions.findSessions([command.sessionId])[0];
|
|
44173
43929
|
if (source === void 0 || !source.prompted) {
|
|
@@ -44177,7 +43933,7 @@ var NativeSessionService = class {
|
|
|
44177
43933
|
"native_session_not_found"
|
|
44178
43934
|
);
|
|
44179
43935
|
}
|
|
44180
|
-
if (source.agentId !== command.agentId || source.cwd !== cwd || source.additionalDirectories.length !== additionalDirectories.length || source.additionalDirectories.some((path3,
|
|
43936
|
+
if (source.agentId !== command.agentId || source.cwd !== cwd || source.additionalDirectories.length !== additionalDirectories.length || source.additionalDirectories.some((path3, index) => path3 !== additionalDirectories[index])) {
|
|
44181
43937
|
throw new AcpExecutionError(
|
|
44182
43938
|
"The source conversation execution target does not match the fork request",
|
|
44183
43939
|
{},
|
|
@@ -44198,8 +43954,8 @@ var NativeSessionService = class {
|
|
|
44198
43954
|
signal.throwIfAborted();
|
|
44199
43955
|
const directory = await this.#directories.list(this.#config.bindingId, command.directoryId, signal);
|
|
44200
43956
|
const ready2 = {
|
|
44201
|
-
additionalDirectories: additionalDirectories.map((path3,
|
|
44202
|
-
directoryId: command.additionalDirectoryIds[
|
|
43957
|
+
additionalDirectories: additionalDirectories.map((path3, index) => ({
|
|
43958
|
+
directoryId: command.additionalDirectoryIds[index] ?? command.directoryId,
|
|
44203
43959
|
name: basename5(path3) || path3
|
|
44204
43960
|
})),
|
|
44205
43961
|
agentId: command.agentId,
|
|
@@ -44360,44 +44116,6 @@ var NativeSessionService = class {
|
|
|
44360
44116
|
);
|
|
44361
44117
|
}
|
|
44362
44118
|
const target = await this.resolveTarget(command, options, selected);
|
|
44363
|
-
if (command.action === "history") {
|
|
44364
|
-
const history = await nativeSessionAdapter(options.agent.id).history({
|
|
44365
|
-
sessions: this.#sessions,
|
|
44366
|
-
directories: this.#directories,
|
|
44367
|
-
bindingId: command.bindingId,
|
|
44368
|
-
options: { ...options, cwd: target.cwd, additionalDirectories: target.additionalDirectories },
|
|
44369
|
-
nativeSessionId: target.info.sessionId
|
|
44370
|
-
});
|
|
44371
|
-
signal.throwIfAborted();
|
|
44372
|
-
this.record(command, "native_session_history_read");
|
|
44373
|
-
return {
|
|
44374
|
-
...envelope2,
|
|
44375
|
-
action: "history",
|
|
44376
|
-
entryId: command.entryId,
|
|
44377
|
-
history,
|
|
44378
|
-
title: target.info.title ?? "Untitled session"
|
|
44379
|
-
};
|
|
44380
|
-
}
|
|
44381
|
-
if (command.action === "preview") {
|
|
44382
|
-
const history = await nativeSessionAdapter(options.agent.id).preview({
|
|
44383
|
-
sessions: this.#sessions,
|
|
44384
|
-
directories: this.#directories,
|
|
44385
|
-
bindingId: command.bindingId,
|
|
44386
|
-
options: { ...options, cwd: target.cwd, additionalDirectories: target.additionalDirectories },
|
|
44387
|
-
nativeSessionId: target.info.sessionId
|
|
44388
|
-
});
|
|
44389
|
-
signal.throwIfAborted();
|
|
44390
|
-
this.record(command, "native_session_previewed");
|
|
44391
|
-
return {
|
|
44392
|
-
...envelope2,
|
|
44393
|
-
action: "preview",
|
|
44394
|
-
entryId: command.entryId,
|
|
44395
|
-
targetSessionId: command.sessionId,
|
|
44396
|
-
reason: "requested",
|
|
44397
|
-
title: target.info.title ?? "Untitled session",
|
|
44398
|
-
history
|
|
44399
|
-
};
|
|
44400
|
-
}
|
|
44401
44119
|
if (command.action === "delete") {
|
|
44402
44120
|
if (!prepared.capabilities.deleteSession) {
|
|
44403
44121
|
throw new AcpExecutionError(
|
|
@@ -44532,7 +44250,7 @@ var NativeSessionService = class {
|
|
|
44532
44250
|
resolveTarget = async (command, options, selected) => {
|
|
44533
44251
|
let cursor = null;
|
|
44534
44252
|
const visited = /* @__PURE__ */ new Set();
|
|
44535
|
-
for (let
|
|
44253
|
+
for (let index = 0; index < 100; index += 1) {
|
|
44536
44254
|
const page = await this.#sessions.listNativeSessions(options, cursor);
|
|
44537
44255
|
const info = page.sessions.find((entry) => entry.sessionId === selected.nativeSessionId);
|
|
44538
44256
|
if (info !== void 0) {
|
|
@@ -44540,7 +44258,7 @@ var NativeSessionService = class {
|
|
|
44540
44258
|
if (target === null) {
|
|
44541
44259
|
throw new LocalAuthorizationError("The selected native session is not authorized");
|
|
44542
44260
|
}
|
|
44543
|
-
if (target.cwd !== selected.cwd || target.additionalDirectories.length !== selected.additionalDirectories.length || target.additionalDirectories.some((path3,
|
|
44261
|
+
if (target.cwd !== selected.cwd || target.additionalDirectories.length !== selected.additionalDirectories.length || target.additionalDirectories.some((path3, index2) => path3 !== selected.additionalDirectories[index2])) {
|
|
44544
44262
|
throw new AcpExecutionError(
|
|
44545
44263
|
"This session's directory changed. Refresh the list before continuing.",
|
|
44546
44264
|
{},
|
|
@@ -44801,135 +44519,13 @@ var RelayConnectionDiagnostics = class {
|
|
|
44801
44519
|
};
|
|
44802
44520
|
|
|
44803
44521
|
// src/relay-connection/run-relay-connection.ts
|
|
44804
|
-
import { WebSocket as
|
|
44522
|
+
import { WebSocket as WebSocket7 } from "undici";
|
|
44805
44523
|
|
|
44806
44524
|
// src/daemon-command-handler.ts
|
|
44807
|
-
import { WebSocket as
|
|
44808
|
-
|
|
44809
|
-
// src/agent-catalog/handle-agent-catalog-refresh.ts
|
|
44810
|
-
import { WebSocket as WebSocket3 } from "undici";
|
|
44811
|
-
async function retainStillInstalledAgents(previous, refreshed, signal) {
|
|
44812
|
-
const refreshedIdentifiers = new Set(refreshed.map((agent) => agent.id));
|
|
44813
|
-
const retained = [];
|
|
44814
|
-
for (const agent of previous) {
|
|
44815
|
-
if (refreshedIdentifiers.has(agent.id)) {
|
|
44816
|
-
continue;
|
|
44817
|
-
}
|
|
44818
|
-
signal.throwIfAborted();
|
|
44819
|
-
if (await revalidateExecutable(agent.agentIdentity)) {
|
|
44820
|
-
retained.push(agent);
|
|
44821
|
-
}
|
|
44822
|
-
}
|
|
44823
|
-
return Object.freeze([...refreshed, ...retained]);
|
|
44824
|
-
}
|
|
44825
|
-
async function refreshAgentCatalog(config2, resolveEnvironment, signal) {
|
|
44826
|
-
signal.throwIfAborted();
|
|
44827
|
-
const shellEnvironment = await resolveEnvironment(signal);
|
|
44828
|
-
const environment = new DaemonLocalContext(config2.localContext.stateDirectory, shellEnvironment).environment;
|
|
44829
|
-
signal.throwIfAborted();
|
|
44830
|
-
const inventory = await discoverLocalAgentInventory({
|
|
44831
|
-
defaultWorkspace: config2.defaultWorkspace,
|
|
44832
|
-
environment,
|
|
44833
|
-
signal
|
|
44834
|
-
});
|
|
44835
|
-
const previousCatalog = config2.catalog.read();
|
|
44836
|
-
const refreshedAgents = inventory.readyAgents().map((agent) => withDaemonEnvironment(agent, environment));
|
|
44837
|
-
const agents = await retainStillInstalledAgents(previousCatalog.agents, refreshedAgents, signal);
|
|
44838
|
-
const verifiedIdentifiers = new Set(agents.map((agent) => agent.id));
|
|
44839
|
-
config2.catalog.transition(
|
|
44840
|
-
agents,
|
|
44841
|
-
inventory.installable.filter((agent) => !verifiedIdentifiers.has(agent.id))
|
|
44842
|
-
);
|
|
44843
|
-
try {
|
|
44844
|
-
await publishAgentCatalog(config2, signal);
|
|
44845
|
-
} catch (error62) {
|
|
44846
|
-
config2.catalog.transition(previousCatalog.agents, previousCatalog.installableAgents);
|
|
44847
|
-
throw error62;
|
|
44848
|
-
}
|
|
44849
|
-
}
|
|
44850
|
-
function createAgentCatalogRefreshHandler(dependencies) {
|
|
44851
|
-
const { config: config2, audit, diagnostics, socket, signal, timer, resolveEnvironment } = dependencies;
|
|
44852
|
-
const agentCatalogRefreshes = /* @__PURE__ */ new Map();
|
|
44853
|
-
const handle = (command) => {
|
|
44854
|
-
if (agentCatalogRefreshes.has(command.requestId) || agentCatalogRefreshes.size > 0) {
|
|
44855
|
-
if (socket.readyState === WebSocket3.OPEN) {
|
|
44856
|
-
send(socket, {
|
|
44857
|
-
code: "agent_catalog_refresh_busy",
|
|
44858
|
-
kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
44859
|
-
message: "Another local Agent catalog refresh is already running",
|
|
44860
|
-
requestId: command.requestId
|
|
44861
|
-
});
|
|
44862
|
-
}
|
|
44863
|
-
return;
|
|
44864
|
-
}
|
|
44865
|
-
const controller = new AbortController();
|
|
44866
|
-
const operationSignal = AbortSignal.any([signal, controller.signal]);
|
|
44867
|
-
const timeout = timer.schedule(
|
|
44868
|
-
() => controller.abort(
|
|
44869
|
-
new AcpExecutionError(
|
|
44870
|
-
"The local Agent catalog refresh timed out",
|
|
44871
|
-
{},
|
|
44872
|
-
"agent_catalog_refresh_timeout"
|
|
44873
|
-
)
|
|
44874
|
-
),
|
|
44875
|
-
9e4
|
|
44876
|
-
);
|
|
44877
|
-
const completion = (async () => {
|
|
44878
|
-
try {
|
|
44879
|
-
await refreshAgentCatalog(config2, resolveEnvironment, operationSignal);
|
|
44880
|
-
audit.record({
|
|
44881
|
-
commandId: command.requestId,
|
|
44882
|
-
event: "agent_catalog_refreshed",
|
|
44883
|
-
sessionId: "agent-catalog"
|
|
44884
|
-
});
|
|
44885
|
-
if (socket.readyState === WebSocket3.OPEN) {
|
|
44886
|
-
send(socket, {
|
|
44887
|
-
kind: AGENT_CATALOG_REFRESHED_KIND,
|
|
44888
|
-
requestId: command.requestId
|
|
44889
|
-
});
|
|
44890
|
-
}
|
|
44891
|
-
} catch (error62) {
|
|
44892
|
-
const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError(
|
|
44893
|
-
"The local Agent catalog refresh was cancelled",
|
|
44894
|
-
{},
|
|
44895
|
-
"agent_catalog_refresh_cancelled"
|
|
44896
|
-
) : error62;
|
|
44897
|
-
audit.record({
|
|
44898
|
-
commandId: command.requestId,
|
|
44899
|
-
details: { code: operationErrorCode(failure2) },
|
|
44900
|
-
event: "agent_catalog_refresh_failed",
|
|
44901
|
-
sessionId: "agent-catalog"
|
|
44902
|
-
});
|
|
44903
|
-
diagnostics.daemonDiagnostic(
|
|
44904
|
-
"agent_catalog_refresh_failed",
|
|
44905
|
-
command.requestId,
|
|
44906
|
-
{ code: operationErrorCode(failure2) },
|
|
44907
|
-
failure2
|
|
44908
|
-
);
|
|
44909
|
-
if (socket.readyState === WebSocket3.OPEN) {
|
|
44910
|
-
send(socket, {
|
|
44911
|
-
code: operationErrorCode(failure2),
|
|
44912
|
-
kind: AGENT_CATALOG_REFRESH_FAILED_KIND,
|
|
44913
|
-
message: operationErrorMessage(failure2),
|
|
44914
|
-
requestId: command.requestId
|
|
44915
|
-
});
|
|
44916
|
-
}
|
|
44917
|
-
} finally {
|
|
44918
|
-
timeout.cancel();
|
|
44919
|
-
agentCatalogRefreshes.delete(command.requestId);
|
|
44920
|
-
}
|
|
44921
|
-
})();
|
|
44922
|
-
agentCatalogRefreshes.set(command.requestId, { completion, controller });
|
|
44923
|
-
return;
|
|
44924
|
-
};
|
|
44925
|
-
const settle2 = async () => {
|
|
44926
|
-
await Promise.all([...agentCatalogRefreshes.values()].map((request) => request.completion));
|
|
44927
|
-
};
|
|
44928
|
-
return { handle, settle: settle2 };
|
|
44929
|
-
}
|
|
44525
|
+
import { WebSocket as WebSocket5 } from "undici";
|
|
44930
44526
|
|
|
44931
44527
|
// src/agent-catalog/handle-agent-settings-discovery.ts
|
|
44932
|
-
import { WebSocket as
|
|
44528
|
+
import { WebSocket as WebSocket3 } from "undici";
|
|
44933
44529
|
|
|
44934
44530
|
// src/agent-catalog/discover-agent-settings.ts
|
|
44935
44531
|
import { createHash as createHash6 } from "node:crypto";
|
|
@@ -45417,7 +45013,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
45417
45013
|
(request) => request.agentId === command.agentId && !request.controller.signal.aborted
|
|
45418
45014
|
);
|
|
45419
45015
|
if ([...agentSettingsDiscoveries.values()].some((request) => request.requestIds.has(command.requestId))) {
|
|
45420
|
-
if (socket.readyState ===
|
|
45016
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
45421
45017
|
send(socket, {
|
|
45422
45018
|
code: "agent_settings_discovery_busy",
|
|
45423
45019
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -45432,7 +45028,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
45432
45028
|
return;
|
|
45433
45029
|
}
|
|
45434
45030
|
if (existing !== void 0) {
|
|
45435
|
-
if (socket.readyState ===
|
|
45031
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
45436
45032
|
send(socket, {
|
|
45437
45033
|
code: "agent_settings_discovery_busy",
|
|
45438
45034
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -45443,7 +45039,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
45443
45039
|
return;
|
|
45444
45040
|
}
|
|
45445
45041
|
if (agentSettingsDiscoveries.size >= 4) {
|
|
45446
|
-
if (socket.readyState ===
|
|
45042
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
45447
45043
|
send(socket, {
|
|
45448
45044
|
code: "agent_settings_discovery_busy",
|
|
45449
45045
|
kind: AGENT_SETTINGS_DISCOVERY_FAILED_KIND,
|
|
@@ -45489,7 +45085,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
45489
45085
|
event: "agent_settings_discovered",
|
|
45490
45086
|
sessionId: `agent-settings:${command.agentId}`
|
|
45491
45087
|
});
|
|
45492
|
-
if (socket.readyState ===
|
|
45088
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
45493
45089
|
send(socket, { ...result.event, requestId });
|
|
45494
45090
|
}
|
|
45495
45091
|
}
|
|
@@ -45515,7 +45111,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
45515
45111
|
`
|
|
45516
45112
|
);
|
|
45517
45113
|
}
|
|
45518
|
-
if (socket.readyState ===
|
|
45114
|
+
if (socket.readyState === WebSocket3.OPEN) {
|
|
45519
45115
|
for (const requestId of requestIds) {
|
|
45520
45116
|
send(socket, {
|
|
45521
45117
|
code: operationErrorCode(failure2),
|
|
@@ -45661,300 +45257,7 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
|
|
|
45661
45257
|
return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
|
|
45662
45258
|
}
|
|
45663
45259
|
|
|
45664
|
-
// src/native-sessions/live-history-page.ts
|
|
45665
|
-
function encodeLiveHistoryCursor(cursor) {
|
|
45666
|
-
return Buffer.from(JSON.stringify(cursor), "utf8").toString("base64url");
|
|
45667
|
-
}
|
|
45668
|
-
function decodeLiveHistoryCursor(cursor, sessionId) {
|
|
45669
|
-
try {
|
|
45670
|
-
if (!/^[A-Za-z0-9_-]{1,512}$/u.test(cursor)) {
|
|
45671
|
-
throw new Error("Invalid cursor alphabet");
|
|
45672
|
-
}
|
|
45673
|
-
const value = JSON.parse(Buffer.from(cursor, "base64url").toString("utf8"));
|
|
45674
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
45675
|
-
throw new Error("Invalid cursor shape");
|
|
45676
|
-
}
|
|
45677
|
-
const record2 = Object.fromEntries(Object.entries(value));
|
|
45678
|
-
const keys = Object.keys(record2).sort().join(",");
|
|
45679
|
-
const legacyNative = keys === "endIndex,sessionId";
|
|
45680
|
-
const kind = legacyNative ? "native" : record2["kind"];
|
|
45681
|
-
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) {
|
|
45682
|
-
throw new Error("Invalid cursor target");
|
|
45683
|
-
}
|
|
45684
|
-
if (kind === "active") {
|
|
45685
|
-
if (keys !== "endIndex,epoch,kind,sessionId" || typeof record2["epoch"] !== "string") {
|
|
45686
|
-
throw new Error("Invalid active cursor target");
|
|
45687
|
-
}
|
|
45688
|
-
return { endIndex: record2["endIndex"], epoch: record2["epoch"], kind, sessionId };
|
|
45689
|
-
}
|
|
45690
|
-
if (keys !== "endIndex,kind,sessionId" && !legacyNative) {
|
|
45691
|
-
throw new Error("Invalid native cursor target");
|
|
45692
|
-
}
|
|
45693
|
-
return { endIndex: record2["endIndex"], kind, sessionId };
|
|
45694
|
-
} catch (cause) {
|
|
45695
|
-
throw new AcpExecutionError("The native Session history cursor is invalid", { cause }, "invalid_cursor");
|
|
45696
|
-
}
|
|
45697
|
-
}
|
|
45698
|
-
function activeHistoryCursor(sessionId, epoch, endIndex) {
|
|
45699
|
-
return encodeLiveHistoryCursor({ endIndex, epoch, kind: "active", sessionId });
|
|
45700
|
-
}
|
|
45701
|
-
function nativeHistoryCursor(sessionId, endIndex) {
|
|
45702
|
-
return encodeLiveHistoryCursor({ endIndex, kind: "native", sessionId });
|
|
45703
|
-
}
|
|
45704
|
-
function liveHistoryCoveredTurnRanges(history) {
|
|
45705
|
-
const ranges = [];
|
|
45706
|
-
let historyIndex = history.messages.length;
|
|
45707
|
-
for (const commandId of history.coveredCommandIds) {
|
|
45708
|
-
let assistantStartIndex = historyIndex;
|
|
45709
|
-
while (assistantStartIndex > 0 && history.messages[assistantStartIndex - 1]?.role === "assistant") {
|
|
45710
|
-
assistantStartIndex -= 1;
|
|
45711
|
-
}
|
|
45712
|
-
const userIndex = assistantStartIndex - 1;
|
|
45713
|
-
if (assistantStartIndex === historyIndex || history.messages[userIndex]?.role !== "user") {
|
|
45714
|
-
break;
|
|
45715
|
-
}
|
|
45716
|
-
ranges.push({ assistantEndIndex: historyIndex, assistantStartIndex, commandId, userIndex });
|
|
45717
|
-
historyIndex = userIndex;
|
|
45718
|
-
}
|
|
45719
|
-
return ranges;
|
|
45720
|
-
}
|
|
45721
|
-
function historyMessageCharacters(message) {
|
|
45722
|
-
return message.text.length + (message.role === "assistant" ? JSON.stringify(message.activities).length + JSON.stringify(message.content).length : 0);
|
|
45723
|
-
}
|
|
45724
|
-
function isNativeHistoryImageMimeType(mimeType) {
|
|
45725
|
-
return mimeType === "image/png" || mimeType === "image/jpeg" || mimeType === "image/gif" || mimeType === "image/webp";
|
|
45726
|
-
}
|
|
45727
|
-
function selectMessagesBefore(messages, endIndex, messageLimit, characterLimit) {
|
|
45728
|
-
const selected = [];
|
|
45729
|
-
let remainingCharacters = characterLimit;
|
|
45730
|
-
let startIndex = endIndex;
|
|
45731
|
-
for (let index2 = endIndex - 1; index2 >= 0 && selected.length < messageLimit; index2 -= 1) {
|
|
45732
|
-
const message = messages[index2];
|
|
45733
|
-
if (message === void 0) {
|
|
45734
|
-
break;
|
|
45735
|
-
}
|
|
45736
|
-
const characters = historyMessageCharacters(message);
|
|
45737
|
-
if (characters > remainingCharacters) {
|
|
45738
|
-
break;
|
|
45739
|
-
}
|
|
45740
|
-
selected.unshift(message);
|
|
45741
|
-
remainingCharacters -= characters;
|
|
45742
|
-
startIndex = index2;
|
|
45743
|
-
}
|
|
45744
|
-
if (selected.length === 0 && endIndex > 0) {
|
|
45745
|
-
throw new AcpExecutionError(
|
|
45746
|
-
"A native Session history item exceeds the page budget",
|
|
45747
|
-
{},
|
|
45748
|
-
"history_item_too_large"
|
|
45749
|
-
);
|
|
45750
|
-
}
|
|
45751
|
-
return { characters: characterLimit - remainingCharacters, messages: selected, startIndex };
|
|
45752
|
-
}
|
|
45753
|
-
function nativeActiveMessage(message) {
|
|
45754
|
-
if (message.role === "assistant") {
|
|
45755
|
-
return {
|
|
45756
|
-
activities: message.activities,
|
|
45757
|
-
content: message.content,
|
|
45758
|
-
role: "assistant",
|
|
45759
|
-
text: message.text
|
|
45760
|
-
};
|
|
45761
|
-
}
|
|
45762
|
-
const images = (message.images ?? []).flatMap((image) => {
|
|
45763
|
-
if (image.data.length < 4 || image.data.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/u.test(image.data) || !isNativeHistoryImageMimeType(image.mimeType)) {
|
|
45764
|
-
return [];
|
|
45765
|
-
}
|
|
45766
|
-
return [{ data: image.data, mimeType: image.mimeType, name: image.name }];
|
|
45767
|
-
});
|
|
45768
|
-
return { ...images.length === 0 ? {} : { images }, role: "user", text: message.text };
|
|
45769
|
-
}
|
|
45770
|
-
function nativeHistoryCoversCompletedRecovery(history, recovery) {
|
|
45771
|
-
const root = recovery.messages.find((message) => message.role === "user" && message.id === recovery.commandId);
|
|
45772
|
-
if (root === void 0) {
|
|
45773
|
-
return false;
|
|
45774
|
-
}
|
|
45775
|
-
const rootIndex = history.messages.findLastIndex(
|
|
45776
|
-
(message) => message.role === "user" && message.text === root.text
|
|
45777
|
-
);
|
|
45778
|
-
if (rootIndex < 0) {
|
|
45779
|
-
return false;
|
|
45780
|
-
}
|
|
45781
|
-
const nativeAssistant = history.messages.slice(rootIndex + 1).filter((message) => message.role === "assistant");
|
|
45782
|
-
if (nativeAssistant.length === 0) {
|
|
45783
|
-
return false;
|
|
45784
|
-
}
|
|
45785
|
-
const recoveryAssistant = recovery.messages.filter((message) => message.role === "assistant");
|
|
45786
|
-
const recoveryText = recoveryAssistant.map((message) => message.text).join("");
|
|
45787
|
-
const nativeText = nativeAssistant.map((message) => message.text).join("");
|
|
45788
|
-
if (recoveryText.length > 0 && !nativeText.includes(recoveryText)) {
|
|
45789
|
-
return false;
|
|
45790
|
-
}
|
|
45791
|
-
const nativeContent = new Set(
|
|
45792
|
-
nativeAssistant.flatMap((message) => message.content).map((content) => JSON.stringify(content))
|
|
45793
|
-
);
|
|
45794
|
-
return recoveryAssistant.flatMap((message) => message.content).every((content) => nativeContent.has(JSON.stringify(content)));
|
|
45795
|
-
}
|
|
45796
|
-
function historyBeforeActiveTurn(history, activeTurn) {
|
|
45797
|
-
if (history.status === "unavailable") {
|
|
45798
|
-
return history;
|
|
45799
|
-
}
|
|
45800
|
-
const activeRoot = activeTurn.messages.find(
|
|
45801
|
-
(message) => message.role === "user" && message.id === activeTurn.commandId
|
|
45802
|
-
);
|
|
45803
|
-
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;
|
|
45804
|
-
const activeUserIndex = matchingActiveUserIndex >= 0 ? matchingActiveUserIndex : liveHistoryCoveredTurnRanges(history).find((range) => range.commandId === activeTurn.commandId)?.userIndex ?? -1;
|
|
45805
|
-
if (activeUserIndex < 0) {
|
|
45806
|
-
return history;
|
|
45807
|
-
}
|
|
45808
|
-
return {
|
|
45809
|
-
...history,
|
|
45810
|
-
coveredCommandIds: history.coveredCommandIds.filter((id) => id !== activeTurn.commandId),
|
|
45811
|
-
coveredMessageIds: history.coveredMessageIds.filter(
|
|
45812
|
-
(id) => id !== `${activeTurn.commandId}:user` && id !== `${activeTurn.commandId}:agent`
|
|
45813
|
-
),
|
|
45814
|
-
messages: history.messages.slice(0, activeUserIndex)
|
|
45815
|
-
};
|
|
45816
|
-
}
|
|
45817
|
-
function paginateAvailableNativeHistory(history, sessionId, endIndex, limit, characterLimit) {
|
|
45818
|
-
if (endIndex > history.messages.length) {
|
|
45819
|
-
throw new AcpExecutionError("The native Session history cursor is invalid", {}, "invalid_cursor");
|
|
45820
|
-
}
|
|
45821
|
-
const selected = selectMessagesBefore(history.messages, endIndex, limit, characterLimit);
|
|
45822
|
-
const coveredMessageIds = new Set(history.coveredMessageIds);
|
|
45823
|
-
const ranges = liveHistoryCoveredTurnRanges(history);
|
|
45824
|
-
return {
|
|
45825
|
-
coveredCommandIds: ranges.filter((range) => range.userIndex >= selected.startIndex && range.assistantEndIndex <= endIndex).map((range) => range.commandId),
|
|
45826
|
-
coveredMessageIds: ranges.flatMap((range) => [
|
|
45827
|
-
...range.userIndex >= selected.startIndex && range.userIndex < endIndex && coveredMessageIds.has(`${range.commandId}:user`) ? [`${range.commandId}:user`] : [],
|
|
45828
|
-
...range.assistantStartIndex >= selected.startIndex && range.assistantEndIndex <= endIndex && coveredMessageIds.has(`${range.commandId}:agent`) ? [`${range.commandId}:agent`] : []
|
|
45829
|
-
]),
|
|
45830
|
-
messages: selected.messages,
|
|
45831
|
-
nextCursor: selected.startIndex > 0 ? nativeHistoryCursor(sessionId, selected.startIndex) : null,
|
|
45832
|
-
status: "available",
|
|
45833
|
-
truncated: history.truncated
|
|
45834
|
-
};
|
|
45835
|
-
}
|
|
45836
|
-
function paginateNativeHistory(history, sessionId, cursor, limit) {
|
|
45837
|
-
if (cursor?.kind === "active") {
|
|
45838
|
-
throw new AcpExecutionError("The native Session history cursor is invalid", {}, "invalid_cursor");
|
|
45839
|
-
}
|
|
45840
|
-
if (history.status === "unavailable") {
|
|
45841
|
-
if (cursor !== null) {
|
|
45842
|
-
throw new AcpExecutionError("Unavailable native Session history has no cursor", {}, "invalid_cursor");
|
|
45843
|
-
}
|
|
45844
|
-
return { cause: history.cause, nextCursor: null, status: "unavailable" };
|
|
45845
|
-
}
|
|
45846
|
-
return paginateAvailableNativeHistory(
|
|
45847
|
-
history,
|
|
45848
|
-
sessionId,
|
|
45849
|
-
cursor?.endIndex ?? history.messages.length,
|
|
45850
|
-
limit,
|
|
45851
|
-
SESSION_HISTORY_CHARACTER_LIMIT
|
|
45852
|
-
);
|
|
45853
|
-
}
|
|
45854
|
-
function paginateActiveTurn(history, activeTurn, sessionId, endIndex, limit) {
|
|
45855
|
-
if (endIndex > activeTurn.messages.length) {
|
|
45856
|
-
throw new AcpExecutionError("The native Session history cursor is invalid", {}, "invalid_cursor");
|
|
45857
|
-
}
|
|
45858
|
-
const activeMessages = activeTurn.messages.map(nativeActiveMessage);
|
|
45859
|
-
const active = selectMessagesBefore(activeMessages, endIndex, limit, SESSION_HISTORY_CHARACTER_LIMIT);
|
|
45860
|
-
const historicalLimit = limit - active.messages.length;
|
|
45861
|
-
const historicalCharacterLimit = SESSION_HISTORY_CHARACTER_LIMIT - active.characters;
|
|
45862
|
-
const pendingHistoricalCursor = history.status === "available" && history.messages.length > 0 ? nativeHistoryCursor(sessionId, history.messages.length) : null;
|
|
45863
|
-
const latestHistoricalMessage = history.status === "available" ? history.messages.at(-1) : void 0;
|
|
45864
|
-
const historicalPageFits = latestHistoricalMessage === void 0 || historyMessageCharacters(latestHistoricalMessage) <= historicalCharacterLimit;
|
|
45865
|
-
const historical = active.startIndex === 0 && history.status === "available" && historicalLimit > 0 && historicalPageFits ? paginateAvailableNativeHistory(
|
|
45866
|
-
history,
|
|
45867
|
-
sessionId,
|
|
45868
|
-
history.messages.length,
|
|
45869
|
-
historicalLimit,
|
|
45870
|
-
historicalCharacterLimit
|
|
45871
|
-
) : null;
|
|
45872
|
-
return {
|
|
45873
|
-
streamPosition: { commandId: activeTurn.commandId, epoch: activeTurn.epoch, sequence: activeTurn.sequence },
|
|
45874
|
-
coveredCommandIds: historical?.coveredCommandIds ?? [],
|
|
45875
|
-
coveredMessageIds: [
|
|
45876
|
-
...historical?.coveredMessageIds ?? [],
|
|
45877
|
-
...active.startIndex === 0 ? [`${activeTurn.commandId}:user`, `${activeTurn.commandId}:agent`] : []
|
|
45878
|
-
],
|
|
45879
|
-
messages: [...historical?.messages ?? [], ...active.messages],
|
|
45880
|
-
nextCursor: active.startIndex > 0 ? activeHistoryCursor(sessionId, activeTurn.epoch, active.startIndex) : historical === null ? pendingHistoricalCursor : historical.nextCursor,
|
|
45881
|
-
status: "available",
|
|
45882
|
-
truncated: activeTurn.truncated || (historical?.truncated ?? false)
|
|
45883
|
-
};
|
|
45884
|
-
}
|
|
45885
|
-
function paginateLiveSessionHistory(history, activeTurn, sessionId, encodedCursor, limit) {
|
|
45886
|
-
const cursor = encodedCursor === null ? null : decodeLiveHistoryCursor(encodedCursor, sessionId);
|
|
45887
|
-
if (activeTurn === null || activeTurn.state === "completed" && history.status === "available" && nativeHistoryCoversCompletedRecovery(history, activeTurn)) {
|
|
45888
|
-
return paginateNativeHistory(history, sessionId, cursor, limit);
|
|
45889
|
-
}
|
|
45890
|
-
const historical = historyBeforeActiveTurn(history, activeTurn);
|
|
45891
|
-
if (cursor?.kind === "native") {
|
|
45892
|
-
return paginateNativeHistory(historical, sessionId, cursor, limit);
|
|
45893
|
-
}
|
|
45894
|
-
if (cursor !== null && cursor.epoch !== activeTurn.epoch) {
|
|
45895
|
-
throw new AcpExecutionError("The active Turn history cursor is stale", {}, "stale_cursor");
|
|
45896
|
-
}
|
|
45897
|
-
return paginateActiveTurn(historical, activeTurn, sessionId, cursor?.endIndex ?? activeTurn.messages.length, limit);
|
|
45898
|
-
}
|
|
45899
|
-
|
|
45900
45260
|
// src/daemon-history-commands.ts
|
|
45901
|
-
async function executeSessionLiveHistoryPageLoad(socket, command, config2, directories, audit, sessions, activeTurn, signal) {
|
|
45902
|
-
try {
|
|
45903
|
-
const resolved = await resolveSessionDirectories(
|
|
45904
|
-
directories,
|
|
45905
|
-
config2.bindingId,
|
|
45906
|
-
command.directoryId,
|
|
45907
|
-
command.additionalDirectoryIds,
|
|
45908
|
-
signal
|
|
45909
|
-
);
|
|
45910
|
-
const history = await sessions.loadSessionHistory({
|
|
45911
|
-
additionalDirectories: resolved.additionalDirectories,
|
|
45912
|
-
agent: config2.catalog.find(command.agentId),
|
|
45913
|
-
cwd: resolved.cwd,
|
|
45914
|
-
sessionId: command.sessionId,
|
|
45915
|
-
signal
|
|
45916
|
-
});
|
|
45917
|
-
signal.throwIfAborted();
|
|
45918
|
-
const page = paginateLiveSessionHistory(
|
|
45919
|
-
history,
|
|
45920
|
-
activeTurn(command.sessionId),
|
|
45921
|
-
command.sessionId,
|
|
45922
|
-
command.cursor,
|
|
45923
|
-
command.limit
|
|
45924
|
-
);
|
|
45925
|
-
audit.record({
|
|
45926
|
-
commandId: command.requestId,
|
|
45927
|
-
event: "session_history_loaded",
|
|
45928
|
-
sessionId: command.sessionId
|
|
45929
|
-
});
|
|
45930
|
-
send(socket, {
|
|
45931
|
-
kind: "session.live-history.page.loaded",
|
|
45932
|
-
page,
|
|
45933
|
-
requestId: command.requestId,
|
|
45934
|
-
sessionId: command.sessionId
|
|
45935
|
-
});
|
|
45936
|
-
} catch (error62) {
|
|
45937
|
-
if (signal.aborted) {
|
|
45938
|
-
return;
|
|
45939
|
-
}
|
|
45940
|
-
audit.record({
|
|
45941
|
-
commandId: command.requestId,
|
|
45942
|
-
details: { code: operationErrorCode(error62) },
|
|
45943
|
-
event: "session_history_unavailable",
|
|
45944
|
-
sessionId: command.sessionId
|
|
45945
|
-
});
|
|
45946
|
-
send(socket, {
|
|
45947
|
-
kind: "session.live-history.page.loaded",
|
|
45948
|
-
page: {
|
|
45949
|
-
status: "unavailable",
|
|
45950
|
-
cause: { code: operationErrorCode(error62), message: operationErrorMessage(error62) },
|
|
45951
|
-
nextCursor: null
|
|
45952
|
-
},
|
|
45953
|
-
requestId: command.requestId,
|
|
45954
|
-
sessionId: command.sessionId
|
|
45955
|
-
});
|
|
45956
|
-
}
|
|
45957
|
-
}
|
|
45958
45261
|
async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, eventLogV2, signal) {
|
|
45959
45262
|
try {
|
|
45960
45263
|
const resolved = await resolveSessionDirectories(
|
|
@@ -45975,7 +45278,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
45975
45278
|
const replay = await sessions.loadSessionEventsV2(loadOptions, command.eventLimit, command.cursor);
|
|
45976
45279
|
signal.throwIfAborted();
|
|
45977
45280
|
const events = replay.events.map(
|
|
45978
|
-
(event,
|
|
45281
|
+
(event, index) => eventLogV2.event(command.sessionId, replay.startPosition + index, event, "1970-01-01T00:00:00.000Z")
|
|
45979
45282
|
);
|
|
45980
45283
|
const tailCursor = events.at(-1)?.eventId ?? "";
|
|
45981
45284
|
audit.record({
|
|
@@ -46725,7 +46028,7 @@ async function executeSessionConfigure(publisher, socket, command, config2, dire
|
|
|
46725
46028
|
}
|
|
46726
46029
|
|
|
46727
46030
|
// src/native-sessions/handle-native-requests.ts
|
|
46728
|
-
import { WebSocket as
|
|
46031
|
+
import { WebSocket as WebSocket4 } from "undici";
|
|
46729
46032
|
function createNativeSessionRequestHandler(dependencies) {
|
|
46730
46033
|
const { audit, diagnostics, nativeSessions, publisher, signal, socket, timer } = dependencies;
|
|
46731
46034
|
const pending = /* @__PURE__ */ new Map();
|
|
@@ -46790,7 +46093,7 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
46790
46093
|
}
|
|
46791
46094
|
]);
|
|
46792
46095
|
}
|
|
46793
|
-
if (socket.readyState ===
|
|
46096
|
+
if (socket.readyState === WebSocket4.OPEN) {
|
|
46794
46097
|
send(socket, result);
|
|
46795
46098
|
}
|
|
46796
46099
|
} catch (error62) {
|
|
@@ -46849,8 +46152,7 @@ function createDaemonCommandHandler({
|
|
|
46849
46152
|
socket,
|
|
46850
46153
|
signal,
|
|
46851
46154
|
runtimeSignal,
|
|
46852
|
-
timer
|
|
46853
|
-
resolveAgentCatalogEnvironment
|
|
46155
|
+
timer
|
|
46854
46156
|
}) {
|
|
46855
46157
|
const handleSettingsDiscovery = createAgentSettingsDiscoveryHandler({
|
|
46856
46158
|
config: config2,
|
|
@@ -46862,20 +46164,10 @@ function createDaemonCommandHandler({
|
|
|
46862
46164
|
signal,
|
|
46863
46165
|
timer
|
|
46864
46166
|
});
|
|
46865
|
-
const handleCatalogRefresh = createAgentCatalogRefreshHandler({
|
|
46866
|
-
config: config2,
|
|
46867
|
-
audit,
|
|
46868
|
-
diagnostics,
|
|
46869
|
-
socket,
|
|
46870
|
-
signal,
|
|
46871
|
-
timer,
|
|
46872
|
-
resolveEnvironment: resolveAgentCatalogEnvironment
|
|
46873
|
-
});
|
|
46874
46167
|
const queueChanged = (sessionId) => {
|
|
46875
46168
|
publisher.publish(sessionId, { kind: "session.queue.changed", sessionId });
|
|
46876
46169
|
eventLogV2.queueChanged(sessionId);
|
|
46877
46170
|
};
|
|
46878
|
-
const activeTurnRecovery = (sessionId) => activeTurns.recovery((command) => command.sessionId === sessionId);
|
|
46879
46171
|
const nativeRequestHandler = createNativeSessionRequestHandler({
|
|
46880
46172
|
audit,
|
|
46881
46173
|
diagnostics,
|
|
@@ -46888,18 +46180,8 @@ function createDaemonCommandHandler({
|
|
|
46888
46180
|
return {
|
|
46889
46181
|
handle: (message) => {
|
|
46890
46182
|
const kind = message.kind;
|
|
46891
|
-
if (kind ===
|
|
46892
|
-
|
|
46893
|
-
void executeSessionLiveHistoryPageLoad(
|
|
46894
|
-
socket,
|
|
46895
|
-
command2,
|
|
46896
|
-
config2,
|
|
46897
|
-
directories,
|
|
46898
|
-
audit,
|
|
46899
|
-
sessions,
|
|
46900
|
-
activeTurnRecovery,
|
|
46901
|
-
signal
|
|
46902
|
-
);
|
|
46183
|
+
if (kind === RUNTIME_PING_KIND) {
|
|
46184
|
+
send(socket, { kind: RUNTIME_PONG_KIND, requestId: message.requestId });
|
|
46903
46185
|
return;
|
|
46904
46186
|
}
|
|
46905
46187
|
if (kind === SESSION_LIVE_HISTORY_V2_PAGE_LOAD_KIND) {
|
|
@@ -46924,10 +46206,6 @@ function createDaemonCommandHandler({
|
|
|
46924
46206
|
handleSettingsDiscovery.handle(message);
|
|
46925
46207
|
return;
|
|
46926
46208
|
}
|
|
46927
|
-
if (kind === AGENT_CATALOG_REFRESH_KIND) {
|
|
46928
|
-
handleCatalogRefresh.handle(message);
|
|
46929
|
-
return;
|
|
46930
|
-
}
|
|
46931
46209
|
if (kind === NATIVE_SESSION_REQUEST_KIND) {
|
|
46932
46210
|
nativeRequestHandler.handle(message);
|
|
46933
46211
|
return;
|
|
@@ -46941,7 +46219,7 @@ function createDaemonCommandHandler({
|
|
|
46941
46219
|
sessions.findSessions([command2.sessionId])[0]?.cwd ?? null,
|
|
46942
46220
|
externalContent
|
|
46943
46221
|
).catch((error62) => {
|
|
46944
|
-
if (socket.readyState !==
|
|
46222
|
+
if (socket.readyState !== WebSocket5.OPEN || signal.aborted) {
|
|
46945
46223
|
return;
|
|
46946
46224
|
}
|
|
46947
46225
|
send(socket, {
|
|
@@ -47147,17 +46425,13 @@ function createDaemonCommandHandler({
|
|
|
47147
46425
|
});
|
|
47148
46426
|
},
|
|
47149
46427
|
settle: async () => {
|
|
47150
|
-
await Promise.all([
|
|
47151
|
-
nativeRequestHandler.settle(),
|
|
47152
|
-
handleSettingsDiscovery.settle(),
|
|
47153
|
-
handleCatalogRefresh.settle()
|
|
47154
|
-
]);
|
|
46428
|
+
await Promise.all([nativeRequestHandler.settle(), handleSettingsDiscovery.settle()]);
|
|
47155
46429
|
}
|
|
47156
46430
|
};
|
|
47157
46431
|
}
|
|
47158
46432
|
|
|
47159
46433
|
// src/relay-connection/connect.ts
|
|
47160
|
-
import { WebSocket as
|
|
46434
|
+
import { WebSocket as WebSocket6 } from "undici";
|
|
47161
46435
|
|
|
47162
46436
|
// src/relay-connection/runtime-revocation.ts
|
|
47163
46437
|
var runtimeRevocationCloseCode = 1008;
|
|
@@ -47195,7 +46469,7 @@ function connectRelay(url2, signal) {
|
|
|
47195
46469
|
const endpoint = new URL(url2);
|
|
47196
46470
|
const headers = runtimeAuthorization(endpoint);
|
|
47197
46471
|
endpoint.searchParams.delete("token");
|
|
47198
|
-
const socket = new
|
|
46472
|
+
const socket = new WebSocket6(endpoint, {
|
|
47199
46473
|
dispatcher: environmentProxyDispatcher,
|
|
47200
46474
|
headers
|
|
47201
46475
|
});
|
|
@@ -47413,8 +46687,7 @@ async function runRelayConnection({
|
|
|
47413
46687
|
diagnostics,
|
|
47414
46688
|
onConnected,
|
|
47415
46689
|
signal,
|
|
47416
|
-
timer
|
|
47417
|
-
resolveAgentCatalogEnvironment
|
|
46690
|
+
timer
|
|
47418
46691
|
}) {
|
|
47419
46692
|
const relayUrl = new URL(config2.relayUrl);
|
|
47420
46693
|
relayUrl.searchParams.set("liveness", "1");
|
|
@@ -47437,8 +46710,7 @@ async function runRelayConnection({
|
|
|
47437
46710
|
socket,
|
|
47438
46711
|
signal: connectionController.signal,
|
|
47439
46712
|
runtimeSignal: signal,
|
|
47440
|
-
timer
|
|
47441
|
-
resolveAgentCatalogEnvironment
|
|
46713
|
+
timer
|
|
47442
46714
|
});
|
|
47443
46715
|
installationObserver.connect(socket);
|
|
47444
46716
|
onConnected();
|
|
@@ -47484,14 +46756,14 @@ async function runRelayConnection({
|
|
|
47484
46756
|
};
|
|
47485
46757
|
const connectionLiveness = new RelayConnectionLiveness(timer, {
|
|
47486
46758
|
send: (message) => {
|
|
47487
|
-
if (socket.readyState !==
|
|
46759
|
+
if (socket.readyState !== WebSocket7.OPEN) {
|
|
47488
46760
|
return false;
|
|
47489
46761
|
}
|
|
47490
46762
|
try {
|
|
47491
46763
|
send(socket, message);
|
|
47492
46764
|
return true;
|
|
47493
46765
|
} catch (error62) {
|
|
47494
|
-
if (socket.readyState !==
|
|
46766
|
+
if (socket.readyState !== WebSocket7.OPEN) {
|
|
47495
46767
|
return false;
|
|
47496
46768
|
}
|
|
47497
46769
|
throw error62;
|
|
@@ -47580,7 +46852,7 @@ async function runRelayConnection({
|
|
|
47580
46852
|
}
|
|
47581
46853
|
|
|
47582
46854
|
// src/relay-connection/session-event-publisher.ts
|
|
47583
|
-
import { WebSocket as
|
|
46855
|
+
import { WebSocket as WebSocket8 } from "undici";
|
|
47584
46856
|
var MAX_BUFFERED_BYTES = 32 * 1024 * 1024;
|
|
47585
46857
|
var DaemonSessionEventPublisher = class {
|
|
47586
46858
|
#socket = null;
|
|
@@ -47597,7 +46869,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
47597
46869
|
};
|
|
47598
46870
|
publish = (sessionId, event) => {
|
|
47599
46871
|
const socket = this.#socket;
|
|
47600
|
-
if (socket === null || socket.readyState !==
|
|
46872
|
+
if (socket === null || socket.readyState !== WebSocket8.OPEN) {
|
|
47601
46873
|
return;
|
|
47602
46874
|
}
|
|
47603
46875
|
const encoded = encodeDaemonToServiceMessage({
|
|
@@ -47621,7 +46893,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
47621
46893
|
};
|
|
47622
46894
|
publishStatus = (event) => {
|
|
47623
46895
|
const socket = this.#socket;
|
|
47624
|
-
if (socket === null || socket.readyState !==
|
|
46896
|
+
if (socket === null || socket.readyState !== WebSocket8.OPEN) {
|
|
47625
46897
|
return;
|
|
47626
46898
|
}
|
|
47627
46899
|
const encoded = encodeDaemonToServiceMessage(event);
|
|
@@ -47636,7 +46908,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
47636
46908
|
};
|
|
47637
46909
|
publishV2 = (event) => {
|
|
47638
46910
|
const socket = this.#socket;
|
|
47639
|
-
if (socket === null || socket.readyState !==
|
|
46911
|
+
if (socket === null || socket.readyState !== WebSocket8.OPEN) {
|
|
47640
46912
|
return;
|
|
47641
46913
|
}
|
|
47642
46914
|
const encoded = encodeDaemonToServiceMessage({ event, kind: SESSION_EVENT_V2_KIND });
|
|
@@ -47685,7 +46957,7 @@ function promptContent(command) {
|
|
|
47685
46957
|
}
|
|
47686
46958
|
return content;
|
|
47687
46959
|
}
|
|
47688
|
-
function
|
|
46960
|
+
function sessionEventV2(daemonGenerationId, sessionId, position, event, recordedAt) {
|
|
47689
46961
|
const sessionPrefix = createHash7("sha256").update(sessionId).digest("hex").slice(0, 16);
|
|
47690
46962
|
return {
|
|
47691
46963
|
eventId: `event-${daemonGenerationId}-${sessionPrefix}-${position.toString().padStart(16, "0")}`,
|
|
@@ -47721,7 +46993,7 @@ var DaemonSessionEventLogV2 = class {
|
|
|
47721
46993
|
record = (sessionId, event, position) => {
|
|
47722
46994
|
this.#publisher.publishV2(this.event(sessionId, position, event, (/* @__PURE__ */ new Date()).toISOString()));
|
|
47723
46995
|
};
|
|
47724
|
-
event = (sessionId, position, event, recordedAt) =>
|
|
46996
|
+
event = (sessionId, position, event, recordedAt) => sessionEventV2(this.daemonGenerationId, sessionId, position, event, recordedAt);
|
|
47725
46997
|
queueChanged = (_sessionId) => void 0;
|
|
47726
46998
|
completed = (sessionId, commandId, _stopReason) => {
|
|
47727
46999
|
const request = this.#queued.get(commandId);
|
|
@@ -47858,7 +47130,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
47858
47130
|
options2.signal
|
|
47859
47131
|
);
|
|
47860
47132
|
return cwd === options2.cwd && additionalDirectories.length === options2.additionalDirectories.length && additionalDirectories.every(
|
|
47861
|
-
(directory,
|
|
47133
|
+
(directory, index) => directory === options2.additionalDirectories[index]
|
|
47862
47134
|
);
|
|
47863
47135
|
});
|
|
47864
47136
|
}
|
|
@@ -47875,10 +47147,6 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
47875
47147
|
let connectionAnnounced = false;
|
|
47876
47148
|
let catalogPublished = false;
|
|
47877
47149
|
let readinessAnnounced = false;
|
|
47878
|
-
const resolveAgentCatalogEnvironment = options.resolveAgentCatalogEnvironment ?? (async (catalogSignal) => {
|
|
47879
|
-
catalogSignal.throwIfAborted();
|
|
47880
|
-
return config2.localContext.environment;
|
|
47881
|
-
});
|
|
47882
47150
|
const startAutomaticIntegrationProvisioning = () => {
|
|
47883
47151
|
if (!connectionAnnounced || !catalogPublished || automaticIntegrationProvisioningStarted) {
|
|
47884
47152
|
return;
|
|
@@ -47956,8 +47224,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
47956
47224
|
announceConnection();
|
|
47957
47225
|
},
|
|
47958
47226
|
signal,
|
|
47959
|
-
timer
|
|
47960
|
-
resolveAgentCatalogEnvironment
|
|
47227
|
+
timer
|
|
47961
47228
|
});
|
|
47962
47229
|
} catch (error62) {
|
|
47963
47230
|
if (signal.aborted) {
|
|
@@ -48051,8 +47318,7 @@ var MobiusRuntimeEngine = class {
|
|
|
48051
47318
|
const audit = new AuditStore();
|
|
48052
47319
|
try {
|
|
48053
47320
|
await runDaemon(this.#config, audit, signal, void 0, {
|
|
48054
|
-
...this.#options.onConnectionStatus === void 0 ? {} : { onConnectionStatus: this.#options.onConnectionStatus }
|
|
48055
|
-
...this.#options.resolveAgentCatalogEnvironment === void 0 ? {} : { resolveAgentCatalogEnvironment: this.#options.resolveAgentCatalogEnvironment }
|
|
47321
|
+
...this.#options.onConnectionStatus === void 0 ? {} : { onConnectionStatus: this.#options.onConnectionStatus }
|
|
48056
47322
|
});
|
|
48057
47323
|
} finally {
|
|
48058
47324
|
audit.close();
|
|
@@ -48329,12 +47595,12 @@ var RuntimeSupervisor = class {
|
|
|
48329
47595
|
}
|
|
48330
47596
|
};
|
|
48331
47597
|
function pairingIdentifier(arguments_) {
|
|
48332
|
-
const indexes = arguments_.flatMap((argument,
|
|
47598
|
+
const indexes = arguments_.flatMap((argument, index2) => argument === "--pairing" ? [index2] : []);
|
|
48333
47599
|
if (indexes.length !== 1) {
|
|
48334
47600
|
return null;
|
|
48335
47601
|
}
|
|
48336
|
-
const
|
|
48337
|
-
return
|
|
47602
|
+
const index = indexes[0];
|
|
47603
|
+
return index === void 0 ? null : arguments_[index + 1] ?? null;
|
|
48338
47604
|
}
|
|
48339
47605
|
async function waitForReady(active, signal) {
|
|
48340
47606
|
if (active.status === "online") {
|
|
@@ -48629,9 +47895,9 @@ function formatPairTable(pairs) {
|
|
|
48629
47895
|
const headers = ["connection_id", "app_id", "runtime_id", "workspace", "status"];
|
|
48630
47896
|
const rows = pairs.map((pair) => [pair.connectionId, pair.appId, pair.runtimeId, pair.workspace, pair.status]);
|
|
48631
47897
|
const widths = headers.map(
|
|
48632
|
-
(header,
|
|
47898
|
+
(header, index) => Math.max(header.length, ...rows.map((row) => row[index]?.length ?? 0))
|
|
48633
47899
|
);
|
|
48634
|
-
const line = (row) => `| ${row.map((value,
|
|
47900
|
+
const line = (row) => `| ${row.map((value, index) => value.padEnd(widths[index] ?? value.length)).join(" | ")} |`;
|
|
48635
47901
|
const divider = `|-${widths.map((width) => "-".repeat(width)).join("-|-")}-|`;
|
|
48636
47902
|
return `${line(headers)}
|
|
48637
47903
|
${divider}
|