@moxt-ai/mobius 0.0.34 → 0.0.36
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/acp/session-manager.d.ts +10 -2
- package/dist/acp/session-manager.d.ts.map +1 -1
- package/dist/acp/session-manager.js +71 -18
- package/dist/acp/session-manager.js.map +1 -1
- package/dist/agent-catalog/discover-local-agents.d.ts +0 -1
- package/dist/agent-catalog/discover-local-agents.d.ts.map +1 -1
- package/dist/agent-catalog/discover-local-agents.js +0 -1
- package/dist/agent-catalog/discover-local-agents.js.map +1 -1
- package/dist/agent-catalog/publish-agent-catalog.d.ts.map +1 -1
- package/dist/agent-catalog/publish-agent-catalog.js +1 -0
- package/dist/agent-catalog/publish-agent-catalog.js.map +1 -1
- package/dist/bots/local-bot-grant-store.d.ts.map +1 -1
- package/dist/bots/local-bot-grant-store.js +43 -3
- package/dist/bots/local-bot-grant-store.js.map +1 -1
- package/dist/cli.js +394 -109
- package/dist/cli.js.map +4 -4
- package/dist/index.js +393 -108
- package/dist/index.js.map +4 -4
- package/dist/infra/operation-metrics.d.ts +18 -0
- package/dist/infra/operation-metrics.d.ts.map +1 -0
- package/dist/infra/operation-metrics.js +31 -0
- package/dist/infra/operation-metrics.js.map +1 -0
- package/dist/native-sessions/service.d.ts.map +1 -1
- package/dist/native-sessions/service.js +14 -0
- package/dist/native-sessions/service.js.map +1 -1
- package/dist/pairing/pair-local-machine.d.ts.map +1 -1
- package/dist/pairing/pair-local-machine.js +1 -0
- package/dist/pairing/pair-local-machine.js.map +1 -1
- package/dist/run-daemon.d.ts.map +1 -1
- package/dist/run-daemon.js +55 -4
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +393 -108
- package/dist/runtime.js.map +4 -4
- package/package.json +1 -1
package/dist/runtime.js
CHANGED
|
@@ -22562,7 +22562,7 @@ var configValueSchema = external_exports.strictObject({
|
|
|
22562
22562
|
name: external_exports.string().min(1).max(255),
|
|
22563
22563
|
value: external_exports.string().min(1).max(500)
|
|
22564
22564
|
}).readonly();
|
|
22565
|
-
var
|
|
22565
|
+
var sessionConfigOptionSchema = external_exports.strictObject({
|
|
22566
22566
|
booleanValue: external_exports.boolean(),
|
|
22567
22567
|
category: external_exports.string().max(128),
|
|
22568
22568
|
currentValue: external_exports.string().max(500),
|
|
@@ -22572,6 +22572,26 @@ var configOptionSchema = external_exports.strictObject({
|
|
|
22572
22572
|
type: external_exports.enum(["boolean", "select"]),
|
|
22573
22573
|
values: external_exports.array(configValueSchema).max(500).readonly()
|
|
22574
22574
|
}).readonly();
|
|
22575
|
+
var sessionConfigOptionsSchema = external_exports.array(sessionConfigOptionSchema).max(100).readonly();
|
|
22576
|
+
var sessionConfigurationSelectionSchema = external_exports.strictObject({
|
|
22577
|
+
booleanValue: external_exports.boolean(),
|
|
22578
|
+
configId: IDENTIFIER,
|
|
22579
|
+
value: external_exports.string().max(500),
|
|
22580
|
+
valueType: external_exports.enum(["boolean", "select"])
|
|
22581
|
+
}).readonly();
|
|
22582
|
+
var sessionConfigurationSelectionsSchema = external_exports.array(sessionConfigurationSelectionSchema).max(100).superRefine((selections, context) => {
|
|
22583
|
+
const identifiers = /* @__PURE__ */ new Set();
|
|
22584
|
+
for (const [index, selection] of selections.entries()) {
|
|
22585
|
+
if (identifiers.has(selection.configId)) {
|
|
22586
|
+
context.addIssue({
|
|
22587
|
+
code: "custom",
|
|
22588
|
+
message: "Session configuration identifiers must be unique",
|
|
22589
|
+
path: [index, "configId"]
|
|
22590
|
+
});
|
|
22591
|
+
}
|
|
22592
|
+
identifiers.add(selection.configId);
|
|
22593
|
+
}
|
|
22594
|
+
}).readonly();
|
|
22575
22595
|
var sessionCapabilitiesSchema = external_exports.strictObject({
|
|
22576
22596
|
additionalDirectories: external_exports.boolean(),
|
|
22577
22597
|
audioPrompt: external_exports.boolean(),
|
|
@@ -22681,8 +22701,15 @@ var sessionIdentityFields = {
|
|
|
22681
22701
|
};
|
|
22682
22702
|
var sessionPrepareCommandSchema = external_exports.strictObject({
|
|
22683
22703
|
...sessionIdentityFields,
|
|
22704
|
+
configuration: external_exports.strictObject({
|
|
22705
|
+
booleanValue: external_exports.boolean(),
|
|
22706
|
+
configId: external_exports.string().min(1).max(128),
|
|
22707
|
+
value: external_exports.string().max(500),
|
|
22708
|
+
valueType: external_exports.enum(["boolean", "select"])
|
|
22709
|
+
}).readonly().optional(),
|
|
22684
22710
|
kind: external_exports.literal(SESSION_PREPARE_KIND),
|
|
22685
|
-
requestId: IDENTIFIER
|
|
22711
|
+
requestId: IDENTIFIER,
|
|
22712
|
+
transient: external_exports.boolean().optional()
|
|
22686
22713
|
}).readonly();
|
|
22687
22714
|
var sessionReadyEventSchema = external_exports.strictObject({
|
|
22688
22715
|
additionalDirectories: external_exports.array(workspaceEntrySchema).max(16).readonly(),
|
|
@@ -22691,12 +22718,18 @@ var sessionReadyEventSchema = external_exports.strictObject({
|
|
|
22691
22718
|
agentVersion: external_exports.string().max(128),
|
|
22692
22719
|
capabilities: sessionCapabilitiesSchema,
|
|
22693
22720
|
commands: external_exports.array(sessionCommandSchema).max(500).readonly(),
|
|
22694
|
-
configOptions:
|
|
22721
|
+
configOptions: sessionConfigOptionsSchema,
|
|
22695
22722
|
directoryId: DIRECTORY_IDENTIFIER,
|
|
22696
22723
|
directoryLabel: external_exports.string().min(1).max(2048),
|
|
22697
22724
|
kind: external_exports.literal(SESSION_READY_KIND),
|
|
22698
22725
|
requestId: IDENTIFIER,
|
|
22699
22726
|
restored: external_exports.boolean(),
|
|
22727
|
+
runtimeTimings: external_exports.array(
|
|
22728
|
+
external_exports.strictObject({
|
|
22729
|
+
durationMilliseconds: external_exports.number().finite().nonnegative().max(12e4),
|
|
22730
|
+
name: external_exports.string().regex(/^[a-z][a-z0-9-]{0,63}$/)
|
|
22731
|
+
}).readonly()
|
|
22732
|
+
).max(16).readonly().optional(),
|
|
22700
22733
|
sessionId: IDENTIFIER
|
|
22701
22734
|
}).readonly();
|
|
22702
22735
|
var sessionConfigureCommandSchema = external_exports.strictObject({
|
|
@@ -22709,7 +22742,7 @@ var sessionConfigureCommandSchema = external_exports.strictObject({
|
|
|
22709
22742
|
valueType: external_exports.enum(["boolean", "select"])
|
|
22710
22743
|
}).readonly();
|
|
22711
22744
|
var sessionConfigUpdatedEventSchema = external_exports.strictObject({
|
|
22712
|
-
configOptions:
|
|
22745
|
+
configOptions: sessionConfigOptionsSchema,
|
|
22713
22746
|
kind: external_exports.literal(SESSION_CONFIG_UPDATED_KIND),
|
|
22714
22747
|
requestId: IDENTIFIER,
|
|
22715
22748
|
sessionId: IDENTIFIER
|
|
@@ -22885,6 +22918,7 @@ var decodeAgentDisplayContentValue = (value) => decodeValue(value, displayConten
|
|
|
22885
22918
|
var decodeRecordedAgentContentValue = (value) => decodeValue(value, recordedDisplayContentSchema);
|
|
22886
22919
|
var decodePromptImagesValue = (value) => decodeValue(value, external_exports.array(promptImageSchema).max(8).readonly());
|
|
22887
22920
|
var decodePromptResourcesValue = (value) => decodeValue(value, external_exports.array(promptResourceSchema).max(16).readonly());
|
|
22921
|
+
var decodeSessionConfigurationSelections = (value) => decodeValue(value, sessionConfigurationSelectionsSchema);
|
|
22888
22922
|
var encode3 = (message, schema) => JSON.stringify(decodeValue(message, schema));
|
|
22889
22923
|
var decodeWorkspaceListCommand = (encoded) => decode3(encoded, workspaceListCommandSchema);
|
|
22890
22924
|
var encodeWorkspaceEntriesEvent = (message) => encode3(message, workspaceEntriesEventSchema);
|
|
@@ -23421,8 +23455,9 @@ var BotExecutionBindingApprovalRequest = class {
|
|
|
23421
23455
|
requestId;
|
|
23422
23456
|
requiredCapabilities;
|
|
23423
23457
|
runtimeId;
|
|
23458
|
+
sessionConfigurations;
|
|
23424
23459
|
workspaceRef;
|
|
23425
|
-
constructor(requestId, botId, behaviorRevisionId, bindingId, bindingRevision, runtimeId, agentRef, workspaceRef, agentConfigRevision, behaviorInstructions, behaviorDigest, requiredCapabilities, allowedDeliveryTargets, completionPolicy) {
|
|
23460
|
+
constructor(requestId, botId, behaviorRevisionId, bindingId, bindingRevision, runtimeId, agentRef, workspaceRef, agentConfigRevision, behaviorInstructions, behaviorDigest, requiredCapabilities, allowedDeliveryTargets, completionPolicy, sessionConfigurations = []) {
|
|
23426
23461
|
this.requestId = requestId;
|
|
23427
23462
|
this.botId = botId;
|
|
23428
23463
|
this.behaviorRevisionId = behaviorRevisionId;
|
|
@@ -23435,6 +23470,7 @@ var BotExecutionBindingApprovalRequest = class {
|
|
|
23435
23470
|
this.behaviorInstructions = behaviorInstructions;
|
|
23436
23471
|
this.behaviorDigest = behaviorDigest;
|
|
23437
23472
|
this.requiredCapabilities = Object.freeze([...requiredCapabilities]);
|
|
23473
|
+
this.sessionConfigurations = Object.freeze([...sessionConfigurations]);
|
|
23438
23474
|
this.allowedDeliveryTargets = Object.freeze(
|
|
23439
23475
|
allowedDeliveryTargets.map(
|
|
23440
23476
|
(target) => new BotDeliveryTargetReference(target.alias, target.deliveryTargetId)
|
|
@@ -23442,6 +23478,13 @@ var BotExecutionBindingApprovalRequest = class {
|
|
|
23442
23478
|
);
|
|
23443
23479
|
this.completionPolicy = completionPolicy;
|
|
23444
23480
|
}
|
|
23481
|
+
toJSON() {
|
|
23482
|
+
const { sessionConfigurations, ...request } = this;
|
|
23483
|
+
return {
|
|
23484
|
+
...request,
|
|
23485
|
+
...sessionConfigurations.length === 0 ? {} : { sessionConfigurations }
|
|
23486
|
+
};
|
|
23487
|
+
}
|
|
23445
23488
|
};
|
|
23446
23489
|
var BotExecutionBindingApprovedEvent = class {
|
|
23447
23490
|
agentIdentityDigest;
|
|
@@ -23506,9 +23549,10 @@ var BotSessionPromptCommand = class {
|
|
|
23506
23549
|
prompt;
|
|
23507
23550
|
replyRoute;
|
|
23508
23551
|
resources;
|
|
23552
|
+
sessionConfigurations;
|
|
23509
23553
|
sessionId;
|
|
23510
23554
|
turnId;
|
|
23511
|
-
constructor(sessionId, commandId, agentId, bindingId, directoryId2, additionalDirectoryIds, images, resources, prompt, executionId, executionCapabilityId, executionCapabilitySecret, executionDeadlineAt, botId, conversationId, turnId, behaviorRevisionId, bindingRevision, localGrantId, behaviorInstructions, behaviorDigest, allowedDeliveryTargets, replyRoute) {
|
|
23555
|
+
constructor(sessionId, commandId, agentId, bindingId, directoryId2, additionalDirectoryIds, images, resources, prompt, executionId, executionCapabilityId, executionCapabilitySecret, executionDeadlineAt, botId, conversationId, turnId, behaviorRevisionId, bindingRevision, localGrantId, behaviorInstructions, behaviorDigest, allowedDeliveryTargets, replyRoute, sessionConfigurations = []) {
|
|
23512
23556
|
this.sessionId = sessionId;
|
|
23513
23557
|
this.commandId = commandId;
|
|
23514
23558
|
this.agentId = agentId;
|
|
@@ -23536,6 +23580,14 @@ var BotSessionPromptCommand = class {
|
|
|
23536
23580
|
)
|
|
23537
23581
|
);
|
|
23538
23582
|
this.replyRoute = replyRoute;
|
|
23583
|
+
this.sessionConfigurations = Object.freeze([...sessionConfigurations]);
|
|
23584
|
+
}
|
|
23585
|
+
toJSON() {
|
|
23586
|
+
const { sessionConfigurations, ...command } = this;
|
|
23587
|
+
return {
|
|
23588
|
+
...command,
|
|
23589
|
+
...sessionConfigurations.length === 0 ? {} : { sessionConfigurations }
|
|
23590
|
+
};
|
|
23539
23591
|
}
|
|
23540
23592
|
};
|
|
23541
23593
|
function isRecord5(value) {
|
|
@@ -23559,6 +23611,12 @@ function assertExactKeys2(value, expected) {
|
|
|
23559
23611
|
throw new ProtocolMessageError("Message fields do not match the Bot protocol");
|
|
23560
23612
|
}
|
|
23561
23613
|
}
|
|
23614
|
+
function assertKeysWithOptional(value, expected, optional2) {
|
|
23615
|
+
const keys = Object.keys(value);
|
|
23616
|
+
if (keys.length < expected.length || keys.length > expected.length + optional2.length || expected.some((key) => !Object.hasOwn(value, key)) || keys.some((key) => !expected.includes(key) && !optional2.includes(key))) {
|
|
23617
|
+
throw new ProtocolMessageError("Message fields do not match the Bot protocol");
|
|
23618
|
+
}
|
|
23619
|
+
}
|
|
23562
23620
|
function readText2(value, key, maximumLength, allowEmpty) {
|
|
23563
23621
|
const field = value[key];
|
|
23564
23622
|
if (typeof field !== "string" || field.length > maximumLength || !allowEmpty && field.length === 0) {
|
|
@@ -23648,6 +23706,12 @@ function readTargets(value, key) {
|
|
|
23648
23706
|
}
|
|
23649
23707
|
return Object.freeze(targets);
|
|
23650
23708
|
}
|
|
23709
|
+
function readSessionConfigurations(value) {
|
|
23710
|
+
if (!Object.hasOwn(value, "sessionConfigurations")) {
|
|
23711
|
+
return [];
|
|
23712
|
+
}
|
|
23713
|
+
return decodeSessionConfigurationSelections(value["sessionConfigurations"]);
|
|
23714
|
+
}
|
|
23651
23715
|
function readCompletionPolicy(value) {
|
|
23652
23716
|
if (!isRecord5(value)) {
|
|
23653
23717
|
throw new ProtocolMessageError("Invalid Bot completion policy");
|
|
@@ -23686,23 +23750,27 @@ function readReplyRoute(value) {
|
|
|
23686
23750
|
}
|
|
23687
23751
|
function decodeBotExecutionBindingApprovalRequest(encoded) {
|
|
23688
23752
|
const value = parseJson3(encoded);
|
|
23689
|
-
|
|
23690
|
-
|
|
23691
|
-
|
|
23692
|
-
|
|
23693
|
-
|
|
23694
|
-
|
|
23695
|
-
|
|
23696
|
-
|
|
23697
|
-
|
|
23698
|
-
|
|
23699
|
-
|
|
23700
|
-
|
|
23701
|
-
|
|
23702
|
-
|
|
23703
|
-
|
|
23704
|
-
|
|
23705
|
-
|
|
23753
|
+
assertKeysWithOptional(
|
|
23754
|
+
value,
|
|
23755
|
+
[
|
|
23756
|
+
"agentConfigRevision",
|
|
23757
|
+
"agentRef",
|
|
23758
|
+
"allowedDeliveryTargets",
|
|
23759
|
+
"behaviorDigest",
|
|
23760
|
+
"behaviorInstructions",
|
|
23761
|
+
"behaviorRevisionId",
|
|
23762
|
+
"bindingId",
|
|
23763
|
+
"bindingRevision",
|
|
23764
|
+
"botId",
|
|
23765
|
+
"completionPolicy",
|
|
23766
|
+
"kind",
|
|
23767
|
+
"requestId",
|
|
23768
|
+
"requiredCapabilities",
|
|
23769
|
+
"runtimeId",
|
|
23770
|
+
"workspaceRef"
|
|
23771
|
+
],
|
|
23772
|
+
["sessionConfigurations"]
|
|
23773
|
+
);
|
|
23706
23774
|
if (value["kind"] !== BOT_BINDING_APPROVAL_REQUEST_KIND) {
|
|
23707
23775
|
throw new ProtocolMessageError("Invalid Bot binding approval request kind");
|
|
23708
23776
|
}
|
|
@@ -23720,7 +23788,8 @@ function decodeBotExecutionBindingApprovalRequest(encoded) {
|
|
|
23720
23788
|
readDigest(value, "behaviorDigest"),
|
|
23721
23789
|
readIdentifiers(value, "requiredCapabilities", 32),
|
|
23722
23790
|
readTargets(value, "allowedDeliveryTargets"),
|
|
23723
|
-
readCompletionPolicy(value["completionPolicy"])
|
|
23791
|
+
readCompletionPolicy(value["completionPolicy"]),
|
|
23792
|
+
readSessionConfigurations(value)
|
|
23724
23793
|
);
|
|
23725
23794
|
}
|
|
23726
23795
|
function decodeBotExecutionBindingApprovedEvent(encoded) {
|
|
@@ -23783,32 +23852,36 @@ function encodeBotExecutionBindingUnavailableEvent(event) {
|
|
|
23783
23852
|
}
|
|
23784
23853
|
function decodeBotSessionPromptCommand(encoded) {
|
|
23785
23854
|
const value = parseJson3(encoded);
|
|
23786
|
-
|
|
23787
|
-
|
|
23788
|
-
|
|
23789
|
-
|
|
23790
|
-
|
|
23791
|
-
|
|
23792
|
-
|
|
23793
|
-
|
|
23794
|
-
|
|
23795
|
-
|
|
23796
|
-
|
|
23797
|
-
|
|
23798
|
-
|
|
23799
|
-
|
|
23800
|
-
|
|
23801
|
-
|
|
23802
|
-
|
|
23803
|
-
|
|
23804
|
-
|
|
23805
|
-
|
|
23806
|
-
|
|
23807
|
-
|
|
23808
|
-
|
|
23809
|
-
|
|
23810
|
-
|
|
23811
|
-
|
|
23855
|
+
assertKeysWithOptional(
|
|
23856
|
+
value,
|
|
23857
|
+
[
|
|
23858
|
+
"additionalDirectoryIds",
|
|
23859
|
+
"agentId",
|
|
23860
|
+
"allowedDeliveryTargets",
|
|
23861
|
+
"behaviorDigest",
|
|
23862
|
+
"behaviorInstructions",
|
|
23863
|
+
"behaviorRevisionId",
|
|
23864
|
+
"bindingId",
|
|
23865
|
+
"bindingRevision",
|
|
23866
|
+
"botId",
|
|
23867
|
+
"commandId",
|
|
23868
|
+
"conversationId",
|
|
23869
|
+
"directoryId",
|
|
23870
|
+
"executionCapabilityId",
|
|
23871
|
+
"executionCapabilitySecret",
|
|
23872
|
+
"executionDeadlineAt",
|
|
23873
|
+
"executionId",
|
|
23874
|
+
"images",
|
|
23875
|
+
"kind",
|
|
23876
|
+
"localGrantId",
|
|
23877
|
+
"prompt",
|
|
23878
|
+
"replyRoute",
|
|
23879
|
+
"resources",
|
|
23880
|
+
"sessionId",
|
|
23881
|
+
"turnId"
|
|
23882
|
+
],
|
|
23883
|
+
["sessionConfigurations"]
|
|
23884
|
+
);
|
|
23812
23885
|
if (value["kind"] !== BOT_SESSION_PROMPT_KIND) {
|
|
23813
23886
|
throw new ProtocolMessageError("Invalid Bot Session prompt kind");
|
|
23814
23887
|
}
|
|
@@ -23835,7 +23908,8 @@ function decodeBotSessionPromptCommand(encoded) {
|
|
|
23835
23908
|
readText2(value, "behaviorInstructions", MAX_INSTRUCTIONS_LENGTH, true),
|
|
23836
23909
|
readDigest(value, "behaviorDigest"),
|
|
23837
23910
|
readTargets(value, "allowedDeliveryTargets"),
|
|
23838
|
-
readReplyRoute(value["replyRoute"])
|
|
23911
|
+
readReplyRoute(value["replyRoute"]),
|
|
23912
|
+
readSessionConfigurations(value)
|
|
23839
23913
|
);
|
|
23840
23914
|
}
|
|
23841
23915
|
|
|
@@ -23958,6 +24032,7 @@ var nativeSessionTurnForkCommandSchema = external_exports.strictObject({
|
|
|
23958
24032
|
title: external_exports.string().max(500)
|
|
23959
24033
|
}).readonly();
|
|
23960
24034
|
var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
24035
|
+
external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
|
|
23961
24036
|
external_exports.strictObject({
|
|
23962
24037
|
...identity,
|
|
23963
24038
|
action: external_exports.literal("list"),
|
|
@@ -24008,7 +24083,7 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
|
24008
24083
|
action: external_exports.literal("preview"),
|
|
24009
24084
|
entryId: identifier,
|
|
24010
24085
|
targetSessionId: identifier,
|
|
24011
|
-
reason: external_exports.
|
|
24086
|
+
reason: external_exports.enum(["continuation_unavailable", "requested"]),
|
|
24012
24087
|
history: sessionHistorySchema,
|
|
24013
24088
|
title: external_exports.string().max(500)
|
|
24014
24089
|
}).readonly(),
|
|
@@ -24309,6 +24384,38 @@ async function readAuthorizedRaster(uri, roots, signal) {
|
|
|
24309
24384
|
return new LocalRasterImage(basename(target) || "Image", mimeType, bytes);
|
|
24310
24385
|
}
|
|
24311
24386
|
|
|
24387
|
+
// src/infra/operation-metrics.ts
|
|
24388
|
+
var AccumulatingOperationMetrics = class {
|
|
24389
|
+
#durations = /* @__PURE__ */ new Map();
|
|
24390
|
+
measure = async (name, operation) => {
|
|
24391
|
+
const startedAt = performance.now();
|
|
24392
|
+
try {
|
|
24393
|
+
return await operation();
|
|
24394
|
+
} finally {
|
|
24395
|
+
this.record(name, performance.now() - startedAt);
|
|
24396
|
+
}
|
|
24397
|
+
};
|
|
24398
|
+
measureSync = (name, operation) => {
|
|
24399
|
+
const startedAt = performance.now();
|
|
24400
|
+
try {
|
|
24401
|
+
return operation();
|
|
24402
|
+
} finally {
|
|
24403
|
+
this.record(name, performance.now() - startedAt);
|
|
24404
|
+
}
|
|
24405
|
+
};
|
|
24406
|
+
snapshot = () => Object.freeze(
|
|
24407
|
+
[...this.#durations].map(([name, durationMilliseconds]) => Object.freeze({ durationMilliseconds, name }))
|
|
24408
|
+
);
|
|
24409
|
+
record = (name, durationMilliseconds) => {
|
|
24410
|
+
this.#durations.set(name, (this.#durations.get(name) ?? 0) + Math.max(0, durationMilliseconds));
|
|
24411
|
+
};
|
|
24412
|
+
};
|
|
24413
|
+
var unmeasuredOperationMetrics = Object.freeze({
|
|
24414
|
+
measure: async (_name, operation) => await operation(),
|
|
24415
|
+
measureSync: (_name, operation) => operation(),
|
|
24416
|
+
snapshot: () => Object.freeze([])
|
|
24417
|
+
});
|
|
24418
|
+
|
|
24312
24419
|
// src/native-sessions/history-images.ts
|
|
24313
24420
|
var IMAGE_MARKER = /\[@image\]\(([^)\r\n]*)(?:\)|$)/g;
|
|
24314
24421
|
async function embedLocalHistoryImages(history, roots, signal) {
|
|
@@ -26049,6 +26156,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
26049
26156
|
#pendingPermissions = /* @__PURE__ */ new Map();
|
|
26050
26157
|
#preSessionUpdates = [];
|
|
26051
26158
|
#processExit;
|
|
26159
|
+
#metrics;
|
|
26052
26160
|
#sessionConfigProtocol;
|
|
26053
26161
|
#store;
|
|
26054
26162
|
#verifiedAgentVersion;
|
|
@@ -26082,13 +26190,14 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
26082
26190
|
#sessionUpdatedAt = "";
|
|
26083
26191
|
#turn = new IdleAcpTurn();
|
|
26084
26192
|
#updateTail = Promise.resolve();
|
|
26085
|
-
constructor(agent, cwd, additionalDirectories, mobiusSessionId, getObserver, store) {
|
|
26193
|
+
constructor(agent, cwd, additionalDirectories, mobiusSessionId, getObserver, store, metrics) {
|
|
26086
26194
|
this.#additionalDirectories = [...additionalDirectories];
|
|
26087
26195
|
this.#agentId = agent.id;
|
|
26088
26196
|
this.#cwd = cwd;
|
|
26089
26197
|
this.#environment = agent.environment;
|
|
26090
26198
|
this.#getObserver = getObserver;
|
|
26091
26199
|
this.#mobiusSessionId = mobiusSessionId;
|
|
26200
|
+
this.#metrics = metrics;
|
|
26092
26201
|
this.#sessionConfigProtocol = sessionConfigProtocolForAgent(agent.id);
|
|
26093
26202
|
this.#store = store;
|
|
26094
26203
|
this.#verifiedAgentVersion = agent.agentVersion;
|
|
@@ -26117,13 +26226,16 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
26117
26226
|
const stream = ndJsonStream2(createWritableAcpStream(stdin), readableWebStream(stdout));
|
|
26118
26227
|
this.#connection = createAcpClient(this).connect(stream);
|
|
26119
26228
|
}
|
|
26120
|
-
static async #start(options, getObserver, store, initialize) {
|
|
26229
|
+
static async #start(options, getObserver, store, initialize, metrics) {
|
|
26121
26230
|
for (let attempt = 1; attempt <= 2; attempt += 1) {
|
|
26122
26231
|
options.signal.throwIfAborted();
|
|
26123
|
-
const [adapterUnchanged, agentUnchanged] = await
|
|
26124
|
-
|
|
26125
|
-
|
|
26126
|
-
|
|
26232
|
+
const [adapterUnchanged, agentUnchanged] = await metrics.measure(
|
|
26233
|
+
"executable-validation",
|
|
26234
|
+
async () => await Promise.all([
|
|
26235
|
+
revalidateExecutable(options.agent.adapterIdentity),
|
|
26236
|
+
revalidateExecutable(options.agent.agentIdentity)
|
|
26237
|
+
])
|
|
26238
|
+
);
|
|
26127
26239
|
options.signal.throwIfAborted();
|
|
26128
26240
|
if (!adapterUnchanged || !agentUnchanged) {
|
|
26129
26241
|
throw new AcpExecutionError(
|
|
@@ -26132,13 +26244,17 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
26132
26244
|
"agent_runtime_changed"
|
|
26133
26245
|
);
|
|
26134
26246
|
}
|
|
26135
|
-
const runtime =
|
|
26136
|
-
|
|
26137
|
-
|
|
26138
|
-
|
|
26139
|
-
|
|
26140
|
-
|
|
26141
|
-
|
|
26247
|
+
const runtime = metrics.measureSync(
|
|
26248
|
+
"process-spawn",
|
|
26249
|
+
() => new _AcpProcessSession(
|
|
26250
|
+
options.agent,
|
|
26251
|
+
options.cwd,
|
|
26252
|
+
options.additionalDirectories,
|
|
26253
|
+
options.sessionId,
|
|
26254
|
+
getObserver,
|
|
26255
|
+
store,
|
|
26256
|
+
metrics
|
|
26257
|
+
)
|
|
26142
26258
|
);
|
|
26143
26259
|
try {
|
|
26144
26260
|
await initialize(runtime);
|
|
@@ -26160,17 +26276,19 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
26160
26276
|
}
|
|
26161
26277
|
throw new AcpExecutionError("ACP agent initialization failed");
|
|
26162
26278
|
}
|
|
26163
|
-
static start = async (options, getObserver, store) => await _AcpProcessSession.#start(
|
|
26279
|
+
static start = async (options, getObserver, store, metrics = unmeasuredOperationMetrics) => await _AcpProcessSession.#start(
|
|
26164
26280
|
options,
|
|
26165
26281
|
getObserver,
|
|
26166
26282
|
store,
|
|
26167
|
-
async (runtime) => await runtime.initialize(options.signal, options.origin)
|
|
26283
|
+
async (runtime) => await runtime.initialize(options.signal, options.origin),
|
|
26284
|
+
metrics
|
|
26168
26285
|
);
|
|
26169
26286
|
static startNativeSessionBrowser = async (options, getObserver, store) => await _AcpProcessSession.#start(
|
|
26170
26287
|
options,
|
|
26171
26288
|
getObserver,
|
|
26172
26289
|
store,
|
|
26173
|
-
async (runtime) => await runtime.#initializeAgent(options.signal)
|
|
26290
|
+
async (runtime) => await runtime.#initializeAgent(options.signal),
|
|
26291
|
+
unmeasuredOperationMetrics
|
|
26174
26292
|
);
|
|
26175
26293
|
static startSessionForkAtTurn = async (options, sourceNativeSessionId, forkPoint, getObserver, store) => await _AcpProcessSession.#start(
|
|
26176
26294
|
options,
|
|
@@ -26180,7 +26298,8 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
26180
26298
|
options.signal,
|
|
26181
26299
|
{ kind: "fork", nativeSessionId: sourceNativeSessionId },
|
|
26182
26300
|
forkPoint
|
|
26183
|
-
)
|
|
26301
|
+
),
|
|
26302
|
+
unmeasuredOperationMetrics
|
|
26184
26303
|
);
|
|
26185
26304
|
belongsTo = (agentId, cwd, additionalDirectories) => this.#agentId === agentId && this.#cwd === cwd && arraysEqual(this.#additionalDirectories, additionalDirectories);
|
|
26186
26305
|
usesEnvironment = (environment) => recordsEqual(this.#environment, environment);
|
|
@@ -26299,6 +26418,9 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
26299
26418
|
);
|
|
26300
26419
|
};
|
|
26301
26420
|
async #initializeAgent(signal) {
|
|
26421
|
+
await this.#metrics.measure("agent-initialize", async () => await this.#initializeAgentOperation(signal));
|
|
26422
|
+
}
|
|
26423
|
+
async #initializeAgentOperation(signal) {
|
|
26302
26424
|
const initialized = await this.race(
|
|
26303
26425
|
this.#connection.agent.request(
|
|
26304
26426
|
methods6.agent.initialize,
|
|
@@ -26469,18 +26591,21 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
26469
26591
|
}
|
|
26470
26592
|
this.#store.remove(this.#mobiusSessionId);
|
|
26471
26593
|
}
|
|
26472
|
-
const created = await this.
|
|
26473
|
-
|
|
26474
|
-
|
|
26475
|
-
|
|
26476
|
-
|
|
26477
|
-
|
|
26478
|
-
|
|
26479
|
-
|
|
26480
|
-
|
|
26481
|
-
|
|
26482
|
-
|
|
26483
|
-
|
|
26594
|
+
const created = await this.#metrics.measure(
|
|
26595
|
+
"session-new",
|
|
26596
|
+
async () => await this.race(
|
|
26597
|
+
this.#connection.agent.request(
|
|
26598
|
+
methods6.agent.session.new,
|
|
26599
|
+
{
|
|
26600
|
+
additionalDirectories: [...this.#additionalDirectories],
|
|
26601
|
+
cwd: this.#cwd,
|
|
26602
|
+
mcpServers: []
|
|
26603
|
+
},
|
|
26604
|
+
{ cancellationSignal: signal }
|
|
26605
|
+
),
|
|
26606
|
+
"ACP agent exited while starting a session",
|
|
26607
|
+
signal
|
|
26608
|
+
)
|
|
26484
26609
|
);
|
|
26485
26610
|
this.selectNativeSession(created.sessionId);
|
|
26486
26611
|
lifecycleResponse = created;
|
|
@@ -27283,10 +27408,10 @@ var AcpSessionManager = class {
|
|
|
27283
27408
|
this.#nativeBrowserPreparing.set(options.sessionId, operation);
|
|
27284
27409
|
return await operation;
|
|
27285
27410
|
}
|
|
27286
|
-
async #startPreparation(options) {
|
|
27411
|
+
async #startPreparation(options, metrics = unmeasuredOperationMetrics) {
|
|
27287
27412
|
const operation = (async () => {
|
|
27288
27413
|
try {
|
|
27289
|
-
const runtime = await AcpProcessSession.start(options, () => this.#observer, this.#store);
|
|
27414
|
+
const runtime = await AcpProcessSession.start(options, () => this.#observer, this.#store, metrics);
|
|
27290
27415
|
this.#sessions.set(options.sessionId, runtime);
|
|
27291
27416
|
return runtime;
|
|
27292
27417
|
} finally {
|
|
@@ -27315,13 +27440,13 @@ var AcpSessionManager = class {
|
|
|
27315
27440
|
this.#preparing.set(options.sessionId, operation);
|
|
27316
27441
|
return await operation;
|
|
27317
27442
|
}
|
|
27318
|
-
async #replacePreparation(existing, options) {
|
|
27443
|
+
async #replacePreparation(existing, options, metrics) {
|
|
27319
27444
|
const operation = (async () => {
|
|
27320
27445
|
try {
|
|
27321
27446
|
this.#sessions.delete(options.sessionId);
|
|
27322
27447
|
await existing.close();
|
|
27323
27448
|
this.#store.remove(options.sessionId);
|
|
27324
|
-
const runtime = await AcpProcessSession.start(options, () => this.#observer, this.#store);
|
|
27449
|
+
const runtime = await AcpProcessSession.start(options, () => this.#observer, this.#store, metrics);
|
|
27325
27450
|
this.#sessions.set(options.sessionId, runtime);
|
|
27326
27451
|
return runtime;
|
|
27327
27452
|
} finally {
|
|
@@ -27383,7 +27508,7 @@ var AcpSessionManager = class {
|
|
|
27383
27508
|
this.#preparing.set(options.sessionId, operation);
|
|
27384
27509
|
return await operation;
|
|
27385
27510
|
}
|
|
27386
|
-
prepareSession = async (options) => {
|
|
27511
|
+
prepareSession = async (options, metrics = unmeasuredOperationMetrics) => {
|
|
27387
27512
|
const stored = this.#store.read(options.sessionId);
|
|
27388
27513
|
if (stored instanceof DeletedAcpStoredSession) {
|
|
27389
27514
|
throw new AcpExecutionError(
|
|
@@ -27401,7 +27526,7 @@ var AcpSessionManager = class {
|
|
|
27401
27526
|
if (runtime2.belongsTo(options.agent.id, options.cwd, options.additionalDirectories)) {
|
|
27402
27527
|
return runtime2.prepared();
|
|
27403
27528
|
}
|
|
27404
|
-
return await this.prepareSession(options);
|
|
27529
|
+
return await this.prepareSession(options, metrics);
|
|
27405
27530
|
}
|
|
27406
27531
|
const existing = this.#sessions.get(options.sessionId);
|
|
27407
27532
|
if (existing !== void 0) {
|
|
@@ -27415,12 +27540,35 @@ var AcpSessionManager = class {
|
|
|
27415
27540
|
"session_identity_mismatch"
|
|
27416
27541
|
);
|
|
27417
27542
|
}
|
|
27418
|
-
const runtime2 = await this.#replacePreparation(existing, options);
|
|
27543
|
+
const runtime2 = await this.#replacePreparation(existing, options, metrics);
|
|
27419
27544
|
return runtime2.prepared();
|
|
27420
27545
|
}
|
|
27421
|
-
const runtime = await this.#startPreparation(options);
|
|
27546
|
+
const runtime = await this.#startPreparation(options, metrics);
|
|
27422
27547
|
return runtime.prepared();
|
|
27423
27548
|
};
|
|
27549
|
+
/**
|
|
27550
|
+
* Opens a short-lived ACP session only to read the Agent's authoritative
|
|
27551
|
+
* configuration options. The runtime and any persisted native-session
|
|
27552
|
+
* record are released before this method resolves.
|
|
27553
|
+
*/
|
|
27554
|
+
inspectSession = async (options) => {
|
|
27555
|
+
if (this.#preparing.has(options.sessionId) || this.#sessions.has(options.sessionId)) {
|
|
27556
|
+
throw new AcpExecutionError("The configuration inspection session is already in use", {}, "session_busy");
|
|
27557
|
+
}
|
|
27558
|
+
const runtime = await this.#startPreparation(options);
|
|
27559
|
+
try {
|
|
27560
|
+
return runtime.prepared();
|
|
27561
|
+
} finally {
|
|
27562
|
+
if (this.#sessions.get(options.sessionId) === runtime) {
|
|
27563
|
+
this.#sessions.delete(options.sessionId);
|
|
27564
|
+
}
|
|
27565
|
+
try {
|
|
27566
|
+
await runtime.close();
|
|
27567
|
+
} finally {
|
|
27568
|
+
this.#store.remove(options.sessionId);
|
|
27569
|
+
}
|
|
27570
|
+
}
|
|
27571
|
+
};
|
|
27424
27572
|
prepareExecutionSession = async (options) => {
|
|
27425
27573
|
const pending = this.#preparing.get(options.sessionId);
|
|
27426
27574
|
if (pending !== void 0) {
|
|
@@ -27681,6 +27829,33 @@ var AcpSessionManager = class {
|
|
|
27681
27829
|
return started;
|
|
27682
27830
|
}
|
|
27683
27831
|
listNativeSessions = async (options, cursor) => await (await this.#ensureNativeSessionBrowser(options)).listNativeSessions(cursor, options.signal);
|
|
27832
|
+
previewNativeSession = async (options, nativeSessionId) => {
|
|
27833
|
+
const key = `${options.agent.id}:${nativeSessionId}`;
|
|
27834
|
+
const linked = this.#store.findNative(options.agent.id, nativeSessionId);
|
|
27835
|
+
if (this.#nativeOperations.has(key) || linked.some((entry) => this.#activeSessionIds.has(entry.sessionId) || this.#preparing.has(entry.sessionId))) {
|
|
27836
|
+
throw new AcpExecutionError(
|
|
27837
|
+
"Wait for the native session's running operation to finish",
|
|
27838
|
+
{},
|
|
27839
|
+
"session_busy"
|
|
27840
|
+
);
|
|
27841
|
+
}
|
|
27842
|
+
this.#nativeOperations.add(key);
|
|
27843
|
+
try {
|
|
27844
|
+
const runtime = await AcpProcessSession.startNativeSessionBrowser(
|
|
27845
|
+
options,
|
|
27846
|
+
() => this.#nativeBrowserObserver,
|
|
27847
|
+
new MemoryAcpSessionStore()
|
|
27848
|
+
);
|
|
27849
|
+
try {
|
|
27850
|
+
runtime.selectNativeSession(nativeSessionId);
|
|
27851
|
+
return await runtime.loadHistory(options.signal);
|
|
27852
|
+
} finally {
|
|
27853
|
+
await runtime.closeProcess();
|
|
27854
|
+
}
|
|
27855
|
+
} finally {
|
|
27856
|
+
this.#nativeOperations.delete(key);
|
|
27857
|
+
}
|
|
27858
|
+
};
|
|
27684
27859
|
openNativeSession = async (options, origin) => {
|
|
27685
27860
|
const key = `${options.agent.id}:${origin.nativeSessionId}`;
|
|
27686
27861
|
if (this.#nativeOperations.has(key)) {
|
|
@@ -27907,6 +28082,7 @@ async function publishAgentCatalog(config2, signal) {
|
|
|
27907
28082
|
agents: catalog.agents.map((agent) => ({
|
|
27908
28083
|
agentPath: agent.agentIdentity.requestedPath,
|
|
27909
28084
|
agentVersion: agent.agentVersion,
|
|
28085
|
+
botSessionConfiguration: true,
|
|
27910
28086
|
capabilities: agent.capabilities,
|
|
27911
28087
|
id: agent.id,
|
|
27912
28088
|
label: agent.label
|
|
@@ -29045,6 +29221,16 @@ function exactTargets(left, right) {
|
|
|
29045
29221
|
const actual = [...right].sort();
|
|
29046
29222
|
return expected.every((target, index) => target === actual[index]);
|
|
29047
29223
|
}
|
|
29224
|
+
function exactSessionConfigurations(left, right) {
|
|
29225
|
+
if (left.length !== right.length) {
|
|
29226
|
+
return false;
|
|
29227
|
+
}
|
|
29228
|
+
const expected = new Map(left.map((selection) => [selection.configId, selection]));
|
|
29229
|
+
return right.every((selection) => {
|
|
29230
|
+
const approved = expected.get(selection.configId);
|
|
29231
|
+
return approved !== void 0 && approved.booleanValue === selection.booleanValue && approved.value === selection.value && approved.valueType === selection.valueType;
|
|
29232
|
+
});
|
|
29233
|
+
}
|
|
29048
29234
|
function rowString(row, key) {
|
|
29049
29235
|
const value = Reflect.get(row, key);
|
|
29050
29236
|
if (typeof value !== "string") {
|
|
@@ -29071,6 +29257,15 @@ function parseTargets(encoded) {
|
|
|
29071
29257
|
}
|
|
29072
29258
|
return value.filter((target) => typeof target === "string");
|
|
29073
29259
|
}
|
|
29260
|
+
function parseSessionConfigurations(encoded) {
|
|
29261
|
+
let value;
|
|
29262
|
+
try {
|
|
29263
|
+
value = JSON.parse(encoded);
|
|
29264
|
+
return decodeSessionConfigurationSelections(value);
|
|
29265
|
+
} catch (cause) {
|
|
29266
|
+
throw new LocalBotAuthorizationError("local_grant_invalid", "The local Bot grant is invalid", { cause });
|
|
29267
|
+
}
|
|
29268
|
+
}
|
|
29074
29269
|
var LocalBotGrantStore = class {
|
|
29075
29270
|
#database;
|
|
29076
29271
|
static containsBot = (path2, botId) => {
|
|
@@ -29115,6 +29310,10 @@ var LocalBotGrantStore = class {
|
|
|
29115
29310
|
error_code TEXT,
|
|
29116
29311
|
error_message TEXT
|
|
29117
29312
|
) STRICT;
|
|
29313
|
+
CREATE TABLE IF NOT EXISTS local_bot_grant_configurations (
|
|
29314
|
+
local_grant_id TEXT PRIMARY KEY,
|
|
29315
|
+
session_configurations_json TEXT NOT NULL
|
|
29316
|
+
) STRICT;
|
|
29118
29317
|
`);
|
|
29119
29318
|
}
|
|
29120
29319
|
/** Only the local CLI may invoke this explicit approval transition. */
|
|
@@ -29240,6 +29439,11 @@ var LocalBotGrantStore = class {
|
|
|
29240
29439
|
now,
|
|
29241
29440
|
expiresAt
|
|
29242
29441
|
);
|
|
29442
|
+
this.#database.prepare(
|
|
29443
|
+
`INSERT INTO local_bot_grant_configurations (
|
|
29444
|
+
local_grant_id, session_configurations_json
|
|
29445
|
+
) VALUES (?, ?)`
|
|
29446
|
+
).run(localGrantId, JSON.stringify(request.sessionConfigurations));
|
|
29243
29447
|
this.#database.prepare(
|
|
29244
29448
|
`INSERT INTO local_bot_binding_resolutions (
|
|
29245
29449
|
request_id, binding_id, local_grant_id, resolved_at, result
|
|
@@ -29265,8 +29469,12 @@ var LocalBotGrantStore = class {
|
|
|
29265
29469
|
resolveExecution = async (command, catalog, directories, bindingAuthorityId, now, signal) => {
|
|
29266
29470
|
signal.throwIfAborted();
|
|
29267
29471
|
const row = this.#database.prepare(
|
|
29268
|
-
`SELECT
|
|
29269
|
-
|
|
29472
|
+
`SELECT grants.*, COALESCE(configurations.session_configurations_json, '[]')
|
|
29473
|
+
AS session_configurations_json
|
|
29474
|
+
FROM local_bot_grants AS grants
|
|
29475
|
+
LEFT JOIN local_bot_grant_configurations AS configurations
|
|
29476
|
+
ON configurations.local_grant_id = grants.local_grant_id
|
|
29477
|
+
WHERE grants.local_grant_id = ? AND grants.bot_id = ?
|
|
29270
29478
|
AND behavior_revision_id = ? AND behavior_digest = ?
|
|
29271
29479
|
AND binding_id = ? AND binding_revision = ?
|
|
29272
29480
|
AND agent_ref = ?
|
|
@@ -29295,6 +29503,13 @@ var LocalBotGrantStore = class {
|
|
|
29295
29503
|
"The Bot execution target policy changed after local approval"
|
|
29296
29504
|
);
|
|
29297
29505
|
}
|
|
29506
|
+
const approvedConfigurations = parseSessionConfigurations(rowString(row, "session_configurations_json"));
|
|
29507
|
+
if (!exactSessionConfigurations(approvedConfigurations, command.sessionConfigurations)) {
|
|
29508
|
+
throw new LocalBotAuthorizationError(
|
|
29509
|
+
"binding_not_approved",
|
|
29510
|
+
"The Bot Agent configuration changed after local approval"
|
|
29511
|
+
);
|
|
29512
|
+
}
|
|
29298
29513
|
const agent = catalog.find(command.agentId);
|
|
29299
29514
|
const [adapterUnchanged, agentUnchanged] = await Promise.all([
|
|
29300
29515
|
revalidateExecutable(agent.adapterIdentity),
|
|
@@ -29889,6 +30104,23 @@ var NativeSessionService = class {
|
|
|
29889
30104
|
);
|
|
29890
30105
|
}
|
|
29891
30106
|
const target = await this.resolveTarget(command, options, selected);
|
|
30107
|
+
if (command.action === "preview") {
|
|
30108
|
+
const history = await this.#sessions.previewNativeSession(
|
|
30109
|
+
{ ...options, cwd: target.cwd, additionalDirectories: target.additionalDirectories },
|
|
30110
|
+
target.info.sessionId
|
|
30111
|
+
);
|
|
30112
|
+
signal.throwIfAborted();
|
|
30113
|
+
this.record(command, "native_session_previewed");
|
|
30114
|
+
return {
|
|
30115
|
+
...envelope2,
|
|
30116
|
+
action: "preview",
|
|
30117
|
+
entryId: command.entryId,
|
|
30118
|
+
targetSessionId: command.sessionId,
|
|
30119
|
+
reason: "requested",
|
|
30120
|
+
title: target.info.title ?? "Untitled session",
|
|
30121
|
+
history
|
|
30122
|
+
};
|
|
30123
|
+
}
|
|
29892
30124
|
if (command.action === "delete") {
|
|
29893
30125
|
if (!prepared.capabilities.deleteSession) {
|
|
29894
30126
|
throw new AcpExecutionError(
|
|
@@ -31888,35 +32120,73 @@ async function executeSessionPrepare(publisher, socket, command, config2, direct
|
|
|
31888
32120
|
signal
|
|
31889
32121
|
);
|
|
31890
32122
|
const agent = config2.catalog.find(command.agentId);
|
|
31891
|
-
const
|
|
32123
|
+
const metrics = new AccumulatingOperationMetrics();
|
|
32124
|
+
const preparation = {
|
|
31892
32125
|
additionalDirectories: resolved.additionalDirectories,
|
|
31893
32126
|
agent,
|
|
31894
32127
|
cwd: resolved.cwd,
|
|
31895
32128
|
sessionId: command.sessionId,
|
|
31896
32129
|
signal
|
|
31897
|
-
}
|
|
32130
|
+
};
|
|
32131
|
+
const prepared = command.transient === true ? await sessions.inspectSession(preparation) : await sessions.prepareSession(preparation, metrics);
|
|
32132
|
+
const configuration = command.configuration;
|
|
32133
|
+
const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
|
|
32134
|
+
"configuration",
|
|
32135
|
+
async () => await sessions.configureSession({
|
|
32136
|
+
...preparation,
|
|
32137
|
+
booleanValue: configuration.booleanValue,
|
|
32138
|
+
configId: configuration.configId,
|
|
32139
|
+
requestId: command.requestId,
|
|
32140
|
+
value: configuration.value,
|
|
32141
|
+
valueType: configuration.valueType
|
|
32142
|
+
})
|
|
32143
|
+
);
|
|
31898
32144
|
const listing = await directories.list(config2.bindingId, command.directoryId, signal);
|
|
31899
32145
|
audit.record({
|
|
31900
32146
|
commandId: command.requestId,
|
|
31901
32147
|
event: "session_prepared",
|
|
31902
32148
|
sessionId: command.sessionId
|
|
31903
32149
|
});
|
|
31904
|
-
|
|
31905
|
-
|
|
31906
|
-
|
|
31907
|
-
|
|
31908
|
-
agentId: command.agentId,
|
|
31909
|
-
agentName: prepared.agentName,
|
|
31910
|
-
agentVersion: prepared.agentVersion,
|
|
31911
|
-
capabilities: prepared.capabilities,
|
|
31912
|
-
commands: prepared.commands,
|
|
31913
|
-
configOptions: prepared.configOptions,
|
|
31914
|
-
directoryId: command.directoryId,
|
|
31915
|
-
directoryLabel: listing.directoryLabel,
|
|
31916
|
-
kind: "session.ready",
|
|
31917
|
-
requestId: command.requestId,
|
|
31918
|
-
restored: prepared.restored,
|
|
32150
|
+
if (command.configuration !== void 0) {
|
|
32151
|
+
audit.record({
|
|
32152
|
+
commandId: command.requestId,
|
|
32153
|
+
event: "session_configured",
|
|
31919
32154
|
sessionId: command.sessionId
|
|
32155
|
+
});
|
|
32156
|
+
publisher.recordRuntime(
|
|
32157
|
+
command.sessionId,
|
|
32158
|
+
encodeSessionConfigUpdatedEvent({
|
|
32159
|
+
configOptions,
|
|
32160
|
+
kind: "session.config.updated",
|
|
32161
|
+
requestId: command.requestId,
|
|
32162
|
+
sessionId: command.sessionId
|
|
32163
|
+
})
|
|
32164
|
+
);
|
|
32165
|
+
}
|
|
32166
|
+
const readyEvent = {
|
|
32167
|
+
additionalDirectories: resolved.additionalDirectoryEntries,
|
|
32168
|
+
agentId: command.agentId,
|
|
32169
|
+
agentName: prepared.agentName,
|
|
32170
|
+
agentVersion: prepared.agentVersion,
|
|
32171
|
+
capabilities: prepared.capabilities,
|
|
32172
|
+
commands: prepared.commands,
|
|
32173
|
+
configOptions,
|
|
32174
|
+
directoryId: command.directoryId,
|
|
32175
|
+
directoryLabel: listing.directoryLabel,
|
|
32176
|
+
kind: "session.ready",
|
|
32177
|
+
requestId: command.requestId,
|
|
32178
|
+
restored: prepared.restored,
|
|
32179
|
+
sessionId: command.sessionId,
|
|
32180
|
+
runtimeTimings: metrics.snapshot()
|
|
32181
|
+
};
|
|
32182
|
+
metrics.measureSync("readiness-commit", () => {
|
|
32183
|
+
publisher.recordRuntime(command.sessionId, encodeSessionReadyEvent(readyEvent));
|
|
32184
|
+
});
|
|
32185
|
+
send(
|
|
32186
|
+
socket,
|
|
32187
|
+
encodeSessionReadyEvent({
|
|
32188
|
+
...readyEvent,
|
|
32189
|
+
runtimeTimings: metrics.snapshot()
|
|
31920
32190
|
})
|
|
31921
32191
|
);
|
|
31922
32192
|
} catch (error62) {
|
|
@@ -32173,6 +32443,20 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
|
|
|
32173
32443
|
sessionId: command.sessionId,
|
|
32174
32444
|
signal: executionSignal
|
|
32175
32445
|
});
|
|
32446
|
+
for (const selection of command.sessionConfigurations) {
|
|
32447
|
+
await sessions.configureSession({
|
|
32448
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
32449
|
+
agent,
|
|
32450
|
+
booleanValue: selection.booleanValue,
|
|
32451
|
+
configId: selection.configId,
|
|
32452
|
+
cwd: resolved.cwd,
|
|
32453
|
+
requestId: `cfg_${randomUUID4()}`,
|
|
32454
|
+
sessionId: command.sessionId,
|
|
32455
|
+
signal: executionSignal,
|
|
32456
|
+
value: selection.value,
|
|
32457
|
+
valueType: selection.valueType
|
|
32458
|
+
});
|
|
32459
|
+
}
|
|
32176
32460
|
audit.record({
|
|
32177
32461
|
commandId: command.commandId,
|
|
32178
32462
|
details: {
|
|
@@ -33393,6 +33677,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
|
|
|
33393
33677
|
const agents = localAgents.map((agent) => ({
|
|
33394
33678
|
agentPath: agent.agentIdentity.requestedPath,
|
|
33395
33679
|
agentVersion: agent.agentVersion,
|
|
33680
|
+
botSessionConfiguration: true,
|
|
33396
33681
|
capabilities: agent.capabilities,
|
|
33397
33682
|
id: agent.id,
|
|
33398
33683
|
label: agent.label
|