@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/cli.js
CHANGED
|
@@ -11,7 +11,7 @@ import { mkdir as mkdir5 } from "node:fs/promises";
|
|
|
11
11
|
// package.json
|
|
12
12
|
var package_default = {
|
|
13
13
|
name: "@moxt-ai/mobius",
|
|
14
|
-
version: "0.0.
|
|
14
|
+
version: "0.0.36",
|
|
15
15
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
16
16
|
type: "module",
|
|
17
17
|
bin: {
|
|
@@ -22812,7 +22812,7 @@ var configValueSchema = external_exports.strictObject({
|
|
|
22812
22812
|
name: external_exports.string().min(1).max(255),
|
|
22813
22813
|
value: external_exports.string().min(1).max(500)
|
|
22814
22814
|
}).readonly();
|
|
22815
|
-
var
|
|
22815
|
+
var sessionConfigOptionSchema = external_exports.strictObject({
|
|
22816
22816
|
booleanValue: external_exports.boolean(),
|
|
22817
22817
|
category: external_exports.string().max(128),
|
|
22818
22818
|
currentValue: external_exports.string().max(500),
|
|
@@ -22822,6 +22822,26 @@ var configOptionSchema = external_exports.strictObject({
|
|
|
22822
22822
|
type: external_exports.enum(["boolean", "select"]),
|
|
22823
22823
|
values: external_exports.array(configValueSchema).max(500).readonly()
|
|
22824
22824
|
}).readonly();
|
|
22825
|
+
var sessionConfigOptionsSchema = external_exports.array(sessionConfigOptionSchema).max(100).readonly();
|
|
22826
|
+
var sessionConfigurationSelectionSchema = external_exports.strictObject({
|
|
22827
|
+
booleanValue: external_exports.boolean(),
|
|
22828
|
+
configId: IDENTIFIER,
|
|
22829
|
+
value: external_exports.string().max(500),
|
|
22830
|
+
valueType: external_exports.enum(["boolean", "select"])
|
|
22831
|
+
}).readonly();
|
|
22832
|
+
var sessionConfigurationSelectionsSchema = external_exports.array(sessionConfigurationSelectionSchema).max(100).superRefine((selections, context) => {
|
|
22833
|
+
const identifiers = /* @__PURE__ */ new Set();
|
|
22834
|
+
for (const [index, selection] of selections.entries()) {
|
|
22835
|
+
if (identifiers.has(selection.configId)) {
|
|
22836
|
+
context.addIssue({
|
|
22837
|
+
code: "custom",
|
|
22838
|
+
message: "Session configuration identifiers must be unique",
|
|
22839
|
+
path: [index, "configId"]
|
|
22840
|
+
});
|
|
22841
|
+
}
|
|
22842
|
+
identifiers.add(selection.configId);
|
|
22843
|
+
}
|
|
22844
|
+
}).readonly();
|
|
22825
22845
|
var sessionCapabilitiesSchema = external_exports.strictObject({
|
|
22826
22846
|
additionalDirectories: external_exports.boolean(),
|
|
22827
22847
|
audioPrompt: external_exports.boolean(),
|
|
@@ -22931,8 +22951,15 @@ var sessionIdentityFields = {
|
|
|
22931
22951
|
};
|
|
22932
22952
|
var sessionPrepareCommandSchema = external_exports.strictObject({
|
|
22933
22953
|
...sessionIdentityFields,
|
|
22954
|
+
configuration: external_exports.strictObject({
|
|
22955
|
+
booleanValue: external_exports.boolean(),
|
|
22956
|
+
configId: external_exports.string().min(1).max(128),
|
|
22957
|
+
value: external_exports.string().max(500),
|
|
22958
|
+
valueType: external_exports.enum(["boolean", "select"])
|
|
22959
|
+
}).readonly().optional(),
|
|
22934
22960
|
kind: external_exports.literal(SESSION_PREPARE_KIND),
|
|
22935
|
-
requestId: IDENTIFIER
|
|
22961
|
+
requestId: IDENTIFIER,
|
|
22962
|
+
transient: external_exports.boolean().optional()
|
|
22936
22963
|
}).readonly();
|
|
22937
22964
|
var sessionReadyEventSchema = external_exports.strictObject({
|
|
22938
22965
|
additionalDirectories: external_exports.array(workspaceEntrySchema).max(16).readonly(),
|
|
@@ -22941,12 +22968,18 @@ var sessionReadyEventSchema = external_exports.strictObject({
|
|
|
22941
22968
|
agentVersion: external_exports.string().max(128),
|
|
22942
22969
|
capabilities: sessionCapabilitiesSchema,
|
|
22943
22970
|
commands: external_exports.array(sessionCommandSchema).max(500).readonly(),
|
|
22944
|
-
configOptions:
|
|
22971
|
+
configOptions: sessionConfigOptionsSchema,
|
|
22945
22972
|
directoryId: DIRECTORY_IDENTIFIER,
|
|
22946
22973
|
directoryLabel: external_exports.string().min(1).max(2048),
|
|
22947
22974
|
kind: external_exports.literal(SESSION_READY_KIND),
|
|
22948
22975
|
requestId: IDENTIFIER,
|
|
22949
22976
|
restored: external_exports.boolean(),
|
|
22977
|
+
runtimeTimings: external_exports.array(
|
|
22978
|
+
external_exports.strictObject({
|
|
22979
|
+
durationMilliseconds: external_exports.number().finite().nonnegative().max(12e4),
|
|
22980
|
+
name: external_exports.string().regex(/^[a-z][a-z0-9-]{0,63}$/)
|
|
22981
|
+
}).readonly()
|
|
22982
|
+
).max(16).readonly().optional(),
|
|
22950
22983
|
sessionId: IDENTIFIER
|
|
22951
22984
|
}).readonly();
|
|
22952
22985
|
var sessionConfigureCommandSchema = external_exports.strictObject({
|
|
@@ -22959,7 +22992,7 @@ var sessionConfigureCommandSchema = external_exports.strictObject({
|
|
|
22959
22992
|
valueType: external_exports.enum(["boolean", "select"])
|
|
22960
22993
|
}).readonly();
|
|
22961
22994
|
var sessionConfigUpdatedEventSchema = external_exports.strictObject({
|
|
22962
|
-
configOptions:
|
|
22995
|
+
configOptions: sessionConfigOptionsSchema,
|
|
22963
22996
|
kind: external_exports.literal(SESSION_CONFIG_UPDATED_KIND),
|
|
22964
22997
|
requestId: IDENTIFIER,
|
|
22965
22998
|
sessionId: IDENTIFIER
|
|
@@ -23135,6 +23168,7 @@ var decodeAgentDisplayContentValue = (value) => decodeValue(value, displayConten
|
|
|
23135
23168
|
var decodeRecordedAgentContentValue = (value) => decodeValue(value, recordedDisplayContentSchema);
|
|
23136
23169
|
var decodePromptImagesValue = (value) => decodeValue(value, external_exports.array(promptImageSchema).max(8).readonly());
|
|
23137
23170
|
var decodePromptResourcesValue = (value) => decodeValue(value, external_exports.array(promptResourceSchema).max(16).readonly());
|
|
23171
|
+
var decodeSessionConfigurationSelections = (value) => decodeValue(value, sessionConfigurationSelectionsSchema);
|
|
23138
23172
|
var encode3 = (message, schema) => JSON.stringify(decodeValue(message, schema));
|
|
23139
23173
|
var decodeWorkspaceListCommand = (encoded) => decode3(encoded, workspaceListCommandSchema);
|
|
23140
23174
|
var encodeWorkspaceEntriesEvent = (message) => encode3(message, workspaceEntriesEventSchema);
|
|
@@ -23671,8 +23705,9 @@ var BotExecutionBindingApprovalRequest = class {
|
|
|
23671
23705
|
requestId;
|
|
23672
23706
|
requiredCapabilities;
|
|
23673
23707
|
runtimeId;
|
|
23708
|
+
sessionConfigurations;
|
|
23674
23709
|
workspaceRef;
|
|
23675
|
-
constructor(requestId, botId, behaviorRevisionId, bindingId, bindingRevision, runtimeId, agentRef, workspaceRef, agentConfigRevision, behaviorInstructions, behaviorDigest, requiredCapabilities, allowedDeliveryTargets, completionPolicy) {
|
|
23710
|
+
constructor(requestId, botId, behaviorRevisionId, bindingId, bindingRevision, runtimeId, agentRef, workspaceRef, agentConfigRevision, behaviorInstructions, behaviorDigest, requiredCapabilities, allowedDeliveryTargets, completionPolicy, sessionConfigurations = []) {
|
|
23676
23711
|
this.requestId = requestId;
|
|
23677
23712
|
this.botId = botId;
|
|
23678
23713
|
this.behaviorRevisionId = behaviorRevisionId;
|
|
@@ -23685,6 +23720,7 @@ var BotExecutionBindingApprovalRequest = class {
|
|
|
23685
23720
|
this.behaviorInstructions = behaviorInstructions;
|
|
23686
23721
|
this.behaviorDigest = behaviorDigest;
|
|
23687
23722
|
this.requiredCapabilities = Object.freeze([...requiredCapabilities]);
|
|
23723
|
+
this.sessionConfigurations = Object.freeze([...sessionConfigurations]);
|
|
23688
23724
|
this.allowedDeliveryTargets = Object.freeze(
|
|
23689
23725
|
allowedDeliveryTargets.map(
|
|
23690
23726
|
(target) => new BotDeliveryTargetReference(target.alias, target.deliveryTargetId)
|
|
@@ -23692,6 +23728,13 @@ var BotExecutionBindingApprovalRequest = class {
|
|
|
23692
23728
|
);
|
|
23693
23729
|
this.completionPolicy = completionPolicy;
|
|
23694
23730
|
}
|
|
23731
|
+
toJSON() {
|
|
23732
|
+
const { sessionConfigurations, ...request } = this;
|
|
23733
|
+
return {
|
|
23734
|
+
...request,
|
|
23735
|
+
...sessionConfigurations.length === 0 ? {} : { sessionConfigurations }
|
|
23736
|
+
};
|
|
23737
|
+
}
|
|
23695
23738
|
};
|
|
23696
23739
|
var BotExecutionBindingApprovedEvent = class {
|
|
23697
23740
|
agentIdentityDigest;
|
|
@@ -23756,9 +23799,10 @@ var BotSessionPromptCommand = class {
|
|
|
23756
23799
|
prompt;
|
|
23757
23800
|
replyRoute;
|
|
23758
23801
|
resources;
|
|
23802
|
+
sessionConfigurations;
|
|
23759
23803
|
sessionId;
|
|
23760
23804
|
turnId;
|
|
23761
|
-
constructor(sessionId, commandId, agentId, bindingId, directoryId2, additionalDirectoryIds, images, resources, prompt, executionId, executionCapabilityId, executionCapabilitySecret, executionDeadlineAt, botId, conversationId, turnId, behaviorRevisionId, bindingRevision, localGrantId, behaviorInstructions, behaviorDigest, allowedDeliveryTargets, replyRoute) {
|
|
23805
|
+
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 = []) {
|
|
23762
23806
|
this.sessionId = sessionId;
|
|
23763
23807
|
this.commandId = commandId;
|
|
23764
23808
|
this.agentId = agentId;
|
|
@@ -23786,6 +23830,14 @@ var BotSessionPromptCommand = class {
|
|
|
23786
23830
|
)
|
|
23787
23831
|
);
|
|
23788
23832
|
this.replyRoute = replyRoute;
|
|
23833
|
+
this.sessionConfigurations = Object.freeze([...sessionConfigurations]);
|
|
23834
|
+
}
|
|
23835
|
+
toJSON() {
|
|
23836
|
+
const { sessionConfigurations, ...command } = this;
|
|
23837
|
+
return {
|
|
23838
|
+
...command,
|
|
23839
|
+
...sessionConfigurations.length === 0 ? {} : { sessionConfigurations }
|
|
23840
|
+
};
|
|
23789
23841
|
}
|
|
23790
23842
|
};
|
|
23791
23843
|
function isRecord5(value) {
|
|
@@ -23809,6 +23861,12 @@ function assertExactKeys2(value, expected) {
|
|
|
23809
23861
|
throw new ProtocolMessageError("Message fields do not match the Bot protocol");
|
|
23810
23862
|
}
|
|
23811
23863
|
}
|
|
23864
|
+
function assertKeysWithOptional(value, expected, optional2) {
|
|
23865
|
+
const keys = Object.keys(value);
|
|
23866
|
+
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))) {
|
|
23867
|
+
throw new ProtocolMessageError("Message fields do not match the Bot protocol");
|
|
23868
|
+
}
|
|
23869
|
+
}
|
|
23812
23870
|
function readText2(value, key, maximumLength, allowEmpty) {
|
|
23813
23871
|
const field = value[key];
|
|
23814
23872
|
if (typeof field !== "string" || field.length > maximumLength || !allowEmpty && field.length === 0) {
|
|
@@ -23898,6 +23956,12 @@ function readTargets(value, key) {
|
|
|
23898
23956
|
}
|
|
23899
23957
|
return Object.freeze(targets);
|
|
23900
23958
|
}
|
|
23959
|
+
function readSessionConfigurations(value) {
|
|
23960
|
+
if (!Object.hasOwn(value, "sessionConfigurations")) {
|
|
23961
|
+
return [];
|
|
23962
|
+
}
|
|
23963
|
+
return decodeSessionConfigurationSelections(value["sessionConfigurations"]);
|
|
23964
|
+
}
|
|
23901
23965
|
function readCompletionPolicy(value) {
|
|
23902
23966
|
if (!isRecord5(value)) {
|
|
23903
23967
|
throw new ProtocolMessageError("Invalid Bot completion policy");
|
|
@@ -23936,23 +24000,27 @@ function readReplyRoute(value) {
|
|
|
23936
24000
|
}
|
|
23937
24001
|
function decodeBotExecutionBindingApprovalRequest(encoded) {
|
|
23938
24002
|
const value = parseJson3(encoded);
|
|
23939
|
-
|
|
23940
|
-
|
|
23941
|
-
|
|
23942
|
-
|
|
23943
|
-
|
|
23944
|
-
|
|
23945
|
-
|
|
23946
|
-
|
|
23947
|
-
|
|
23948
|
-
|
|
23949
|
-
|
|
23950
|
-
|
|
23951
|
-
|
|
23952
|
-
|
|
23953
|
-
|
|
23954
|
-
|
|
23955
|
-
|
|
24003
|
+
assertKeysWithOptional(
|
|
24004
|
+
value,
|
|
24005
|
+
[
|
|
24006
|
+
"agentConfigRevision",
|
|
24007
|
+
"agentRef",
|
|
24008
|
+
"allowedDeliveryTargets",
|
|
24009
|
+
"behaviorDigest",
|
|
24010
|
+
"behaviorInstructions",
|
|
24011
|
+
"behaviorRevisionId",
|
|
24012
|
+
"bindingId",
|
|
24013
|
+
"bindingRevision",
|
|
24014
|
+
"botId",
|
|
24015
|
+
"completionPolicy",
|
|
24016
|
+
"kind",
|
|
24017
|
+
"requestId",
|
|
24018
|
+
"requiredCapabilities",
|
|
24019
|
+
"runtimeId",
|
|
24020
|
+
"workspaceRef"
|
|
24021
|
+
],
|
|
24022
|
+
["sessionConfigurations"]
|
|
24023
|
+
);
|
|
23956
24024
|
if (value["kind"] !== BOT_BINDING_APPROVAL_REQUEST_KIND) {
|
|
23957
24025
|
throw new ProtocolMessageError("Invalid Bot binding approval request kind");
|
|
23958
24026
|
}
|
|
@@ -23970,7 +24038,8 @@ function decodeBotExecutionBindingApprovalRequest(encoded) {
|
|
|
23970
24038
|
readDigest(value, "behaviorDigest"),
|
|
23971
24039
|
readIdentifiers(value, "requiredCapabilities", 32),
|
|
23972
24040
|
readTargets(value, "allowedDeliveryTargets"),
|
|
23973
|
-
readCompletionPolicy(value["completionPolicy"])
|
|
24041
|
+
readCompletionPolicy(value["completionPolicy"]),
|
|
24042
|
+
readSessionConfigurations(value)
|
|
23974
24043
|
);
|
|
23975
24044
|
}
|
|
23976
24045
|
function decodeBotExecutionBindingApprovedEvent(encoded) {
|
|
@@ -24033,32 +24102,36 @@ function encodeBotExecutionBindingUnavailableEvent(event) {
|
|
|
24033
24102
|
}
|
|
24034
24103
|
function decodeBotSessionPromptCommand(encoded) {
|
|
24035
24104
|
const value = parseJson3(encoded);
|
|
24036
|
-
|
|
24037
|
-
|
|
24038
|
-
|
|
24039
|
-
|
|
24040
|
-
|
|
24041
|
-
|
|
24042
|
-
|
|
24043
|
-
|
|
24044
|
-
|
|
24045
|
-
|
|
24046
|
-
|
|
24047
|
-
|
|
24048
|
-
|
|
24049
|
-
|
|
24050
|
-
|
|
24051
|
-
|
|
24052
|
-
|
|
24053
|
-
|
|
24054
|
-
|
|
24055
|
-
|
|
24056
|
-
|
|
24057
|
-
|
|
24058
|
-
|
|
24059
|
-
|
|
24060
|
-
|
|
24061
|
-
|
|
24105
|
+
assertKeysWithOptional(
|
|
24106
|
+
value,
|
|
24107
|
+
[
|
|
24108
|
+
"additionalDirectoryIds",
|
|
24109
|
+
"agentId",
|
|
24110
|
+
"allowedDeliveryTargets",
|
|
24111
|
+
"behaviorDigest",
|
|
24112
|
+
"behaviorInstructions",
|
|
24113
|
+
"behaviorRevisionId",
|
|
24114
|
+
"bindingId",
|
|
24115
|
+
"bindingRevision",
|
|
24116
|
+
"botId",
|
|
24117
|
+
"commandId",
|
|
24118
|
+
"conversationId",
|
|
24119
|
+
"directoryId",
|
|
24120
|
+
"executionCapabilityId",
|
|
24121
|
+
"executionCapabilitySecret",
|
|
24122
|
+
"executionDeadlineAt",
|
|
24123
|
+
"executionId",
|
|
24124
|
+
"images",
|
|
24125
|
+
"kind",
|
|
24126
|
+
"localGrantId",
|
|
24127
|
+
"prompt",
|
|
24128
|
+
"replyRoute",
|
|
24129
|
+
"resources",
|
|
24130
|
+
"sessionId",
|
|
24131
|
+
"turnId"
|
|
24132
|
+
],
|
|
24133
|
+
["sessionConfigurations"]
|
|
24134
|
+
);
|
|
24062
24135
|
if (value["kind"] !== BOT_SESSION_PROMPT_KIND) {
|
|
24063
24136
|
throw new ProtocolMessageError("Invalid Bot Session prompt kind");
|
|
24064
24137
|
}
|
|
@@ -24085,7 +24158,8 @@ function decodeBotSessionPromptCommand(encoded) {
|
|
|
24085
24158
|
readText2(value, "behaviorInstructions", MAX_INSTRUCTIONS_LENGTH, true),
|
|
24086
24159
|
readDigest(value, "behaviorDigest"),
|
|
24087
24160
|
readTargets(value, "allowedDeliveryTargets"),
|
|
24088
|
-
readReplyRoute(value["replyRoute"])
|
|
24161
|
+
readReplyRoute(value["replyRoute"]),
|
|
24162
|
+
readSessionConfigurations(value)
|
|
24089
24163
|
);
|
|
24090
24164
|
}
|
|
24091
24165
|
|
|
@@ -24208,6 +24282,7 @@ var nativeSessionTurnForkCommandSchema = external_exports.strictObject({
|
|
|
24208
24282
|
title: external_exports.string().max(500)
|
|
24209
24283
|
}).readonly();
|
|
24210
24284
|
var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
24285
|
+
external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
|
|
24211
24286
|
external_exports.strictObject({
|
|
24212
24287
|
...identity,
|
|
24213
24288
|
action: external_exports.literal("list"),
|
|
@@ -24258,7 +24333,7 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
|
24258
24333
|
action: external_exports.literal("preview"),
|
|
24259
24334
|
entryId: identifier,
|
|
24260
24335
|
targetSessionId: identifier,
|
|
24261
|
-
reason: external_exports.
|
|
24336
|
+
reason: external_exports.enum(["continuation_unavailable", "requested"]),
|
|
24262
24337
|
history: sessionHistorySchema,
|
|
24263
24338
|
title: external_exports.string().max(500)
|
|
24264
24339
|
}).readonly(),
|
|
@@ -24567,6 +24642,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
|
|
|
24567
24642
|
const agents = localAgents.map((agent) => ({
|
|
24568
24643
|
agentPath: agent.agentIdentity.requestedPath,
|
|
24569
24644
|
agentVersion: agent.agentVersion,
|
|
24645
|
+
botSessionConfiguration: true,
|
|
24570
24646
|
capabilities: agent.capabilities,
|
|
24571
24647
|
id: agent.id,
|
|
24572
24648
|
label: agent.label
|
|
@@ -24830,6 +24906,16 @@ function exactTargets(left, right) {
|
|
|
24830
24906
|
const actual = [...right].sort();
|
|
24831
24907
|
return expected.every((target, index) => target === actual[index]);
|
|
24832
24908
|
}
|
|
24909
|
+
function exactSessionConfigurations(left, right) {
|
|
24910
|
+
if (left.length !== right.length) {
|
|
24911
|
+
return false;
|
|
24912
|
+
}
|
|
24913
|
+
const expected = new Map(left.map((selection) => [selection.configId, selection]));
|
|
24914
|
+
return right.every((selection) => {
|
|
24915
|
+
const approved = expected.get(selection.configId);
|
|
24916
|
+
return approved !== void 0 && approved.booleanValue === selection.booleanValue && approved.value === selection.value && approved.valueType === selection.valueType;
|
|
24917
|
+
});
|
|
24918
|
+
}
|
|
24833
24919
|
function rowString(row, key) {
|
|
24834
24920
|
const value = Reflect.get(row, key);
|
|
24835
24921
|
if (typeof value !== "string") {
|
|
@@ -24856,6 +24942,15 @@ function parseTargets(encoded) {
|
|
|
24856
24942
|
}
|
|
24857
24943
|
return value.filter((target) => typeof target === "string");
|
|
24858
24944
|
}
|
|
24945
|
+
function parseSessionConfigurations(encoded) {
|
|
24946
|
+
let value;
|
|
24947
|
+
try {
|
|
24948
|
+
value = JSON.parse(encoded);
|
|
24949
|
+
return decodeSessionConfigurationSelections(value);
|
|
24950
|
+
} catch (cause) {
|
|
24951
|
+
throw new LocalBotAuthorizationError("local_grant_invalid", "The local Bot grant is invalid", { cause });
|
|
24952
|
+
}
|
|
24953
|
+
}
|
|
24859
24954
|
var LocalBotGrantStore = class {
|
|
24860
24955
|
#database;
|
|
24861
24956
|
static containsBot = (path2, botId) => {
|
|
@@ -24900,6 +24995,10 @@ var LocalBotGrantStore = class {
|
|
|
24900
24995
|
error_code TEXT,
|
|
24901
24996
|
error_message TEXT
|
|
24902
24997
|
) STRICT;
|
|
24998
|
+
CREATE TABLE IF NOT EXISTS local_bot_grant_configurations (
|
|
24999
|
+
local_grant_id TEXT PRIMARY KEY,
|
|
25000
|
+
session_configurations_json TEXT NOT NULL
|
|
25001
|
+
) STRICT;
|
|
24903
25002
|
`);
|
|
24904
25003
|
}
|
|
24905
25004
|
/** Only the local CLI may invoke this explicit approval transition. */
|
|
@@ -25025,6 +25124,11 @@ var LocalBotGrantStore = class {
|
|
|
25025
25124
|
now,
|
|
25026
25125
|
expiresAt
|
|
25027
25126
|
);
|
|
25127
|
+
this.#database.prepare(
|
|
25128
|
+
`INSERT INTO local_bot_grant_configurations (
|
|
25129
|
+
local_grant_id, session_configurations_json
|
|
25130
|
+
) VALUES (?, ?)`
|
|
25131
|
+
).run(localGrantId, JSON.stringify(request.sessionConfigurations));
|
|
25028
25132
|
this.#database.prepare(
|
|
25029
25133
|
`INSERT INTO local_bot_binding_resolutions (
|
|
25030
25134
|
request_id, binding_id, local_grant_id, resolved_at, result
|
|
@@ -25050,8 +25154,12 @@ var LocalBotGrantStore = class {
|
|
|
25050
25154
|
resolveExecution = async (command, catalog, directories, bindingAuthorityId, now, signal) => {
|
|
25051
25155
|
signal.throwIfAborted();
|
|
25052
25156
|
const row = this.#database.prepare(
|
|
25053
|
-
`SELECT
|
|
25054
|
-
|
|
25157
|
+
`SELECT grants.*, COALESCE(configurations.session_configurations_json, '[]')
|
|
25158
|
+
AS session_configurations_json
|
|
25159
|
+
FROM local_bot_grants AS grants
|
|
25160
|
+
LEFT JOIN local_bot_grant_configurations AS configurations
|
|
25161
|
+
ON configurations.local_grant_id = grants.local_grant_id
|
|
25162
|
+
WHERE grants.local_grant_id = ? AND grants.bot_id = ?
|
|
25055
25163
|
AND behavior_revision_id = ? AND behavior_digest = ?
|
|
25056
25164
|
AND binding_id = ? AND binding_revision = ?
|
|
25057
25165
|
AND agent_ref = ?
|
|
@@ -25080,6 +25188,13 @@ var LocalBotGrantStore = class {
|
|
|
25080
25188
|
"The Bot execution target policy changed after local approval"
|
|
25081
25189
|
);
|
|
25082
25190
|
}
|
|
25191
|
+
const approvedConfigurations = parseSessionConfigurations(rowString(row, "session_configurations_json"));
|
|
25192
|
+
if (!exactSessionConfigurations(approvedConfigurations, command.sessionConfigurations)) {
|
|
25193
|
+
throw new LocalBotAuthorizationError(
|
|
25194
|
+
"binding_not_approved",
|
|
25195
|
+
"The Bot Agent configuration changed after local approval"
|
|
25196
|
+
);
|
|
25197
|
+
}
|
|
25083
25198
|
const agent = catalog.find(command.agentId);
|
|
25084
25199
|
const [adapterUnchanged, agentUnchanged] = await Promise.all([
|
|
25085
25200
|
revalidateExecutable(agent.adapterIdentity),
|
|
@@ -25649,6 +25764,38 @@ async function readAuthorizedRaster(uri, roots, signal) {
|
|
|
25649
25764
|
return new LocalRasterImage(basename3(target) || "Image", mimeType, bytes);
|
|
25650
25765
|
}
|
|
25651
25766
|
|
|
25767
|
+
// src/infra/operation-metrics.ts
|
|
25768
|
+
var AccumulatingOperationMetrics = class {
|
|
25769
|
+
#durations = /* @__PURE__ */ new Map();
|
|
25770
|
+
measure = async (name, operation) => {
|
|
25771
|
+
const startedAt = performance.now();
|
|
25772
|
+
try {
|
|
25773
|
+
return await operation();
|
|
25774
|
+
} finally {
|
|
25775
|
+
this.record(name, performance.now() - startedAt);
|
|
25776
|
+
}
|
|
25777
|
+
};
|
|
25778
|
+
measureSync = (name, operation) => {
|
|
25779
|
+
const startedAt = performance.now();
|
|
25780
|
+
try {
|
|
25781
|
+
return operation();
|
|
25782
|
+
} finally {
|
|
25783
|
+
this.record(name, performance.now() - startedAt);
|
|
25784
|
+
}
|
|
25785
|
+
};
|
|
25786
|
+
snapshot = () => Object.freeze(
|
|
25787
|
+
[...this.#durations].map(([name, durationMilliseconds]) => Object.freeze({ durationMilliseconds, name }))
|
|
25788
|
+
);
|
|
25789
|
+
record = (name, durationMilliseconds) => {
|
|
25790
|
+
this.#durations.set(name, (this.#durations.get(name) ?? 0) + Math.max(0, durationMilliseconds));
|
|
25791
|
+
};
|
|
25792
|
+
};
|
|
25793
|
+
var unmeasuredOperationMetrics = Object.freeze({
|
|
25794
|
+
measure: async (_name, operation) => await operation(),
|
|
25795
|
+
measureSync: (_name, operation) => operation(),
|
|
25796
|
+
snapshot: () => Object.freeze([])
|
|
25797
|
+
});
|
|
25798
|
+
|
|
25652
25799
|
// src/native-sessions/history-images.ts
|
|
25653
25800
|
var IMAGE_MARKER = /\[@image\]\(([^)\r\n]*)(?:\)|$)/g;
|
|
25654
25801
|
async function embedLocalHistoryImages(history, roots, signal) {
|
|
@@ -27389,6 +27536,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
27389
27536
|
#pendingPermissions = /* @__PURE__ */ new Map();
|
|
27390
27537
|
#preSessionUpdates = [];
|
|
27391
27538
|
#processExit;
|
|
27539
|
+
#metrics;
|
|
27392
27540
|
#sessionConfigProtocol;
|
|
27393
27541
|
#store;
|
|
27394
27542
|
#verifiedAgentVersion;
|
|
@@ -27422,13 +27570,14 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
27422
27570
|
#sessionUpdatedAt = "";
|
|
27423
27571
|
#turn = new IdleAcpTurn();
|
|
27424
27572
|
#updateTail = Promise.resolve();
|
|
27425
|
-
constructor(agent, cwd, additionalDirectories, mobiusSessionId, getObserver, store) {
|
|
27573
|
+
constructor(agent, cwd, additionalDirectories, mobiusSessionId, getObserver, store, metrics) {
|
|
27426
27574
|
this.#additionalDirectories = [...additionalDirectories];
|
|
27427
27575
|
this.#agentId = agent.id;
|
|
27428
27576
|
this.#cwd = cwd;
|
|
27429
27577
|
this.#environment = agent.environment;
|
|
27430
27578
|
this.#getObserver = getObserver;
|
|
27431
27579
|
this.#mobiusSessionId = mobiusSessionId;
|
|
27580
|
+
this.#metrics = metrics;
|
|
27432
27581
|
this.#sessionConfigProtocol = sessionConfigProtocolForAgent(agent.id);
|
|
27433
27582
|
this.#store = store;
|
|
27434
27583
|
this.#verifiedAgentVersion = agent.agentVersion;
|
|
@@ -27457,13 +27606,16 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
27457
27606
|
const stream = ndJsonStream2(createWritableAcpStream(stdin), readableWebStream(stdout));
|
|
27458
27607
|
this.#connection = createAcpClient(this).connect(stream);
|
|
27459
27608
|
}
|
|
27460
|
-
static async #start(options, getObserver, store, initialize) {
|
|
27609
|
+
static async #start(options, getObserver, store, initialize, metrics) {
|
|
27461
27610
|
for (let attempt = 1; attempt <= 2; attempt += 1) {
|
|
27462
27611
|
options.signal.throwIfAborted();
|
|
27463
|
-
const [adapterUnchanged, agentUnchanged] = await
|
|
27464
|
-
|
|
27465
|
-
|
|
27466
|
-
|
|
27612
|
+
const [adapterUnchanged, agentUnchanged] = await metrics.measure(
|
|
27613
|
+
"executable-validation",
|
|
27614
|
+
async () => await Promise.all([
|
|
27615
|
+
revalidateExecutable(options.agent.adapterIdentity),
|
|
27616
|
+
revalidateExecutable(options.agent.agentIdentity)
|
|
27617
|
+
])
|
|
27618
|
+
);
|
|
27467
27619
|
options.signal.throwIfAborted();
|
|
27468
27620
|
if (!adapterUnchanged || !agentUnchanged) {
|
|
27469
27621
|
throw new AcpExecutionError(
|
|
@@ -27472,13 +27624,17 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
27472
27624
|
"agent_runtime_changed"
|
|
27473
27625
|
);
|
|
27474
27626
|
}
|
|
27475
|
-
const runtime =
|
|
27476
|
-
|
|
27477
|
-
|
|
27478
|
-
|
|
27479
|
-
|
|
27480
|
-
|
|
27481
|
-
|
|
27627
|
+
const runtime = metrics.measureSync(
|
|
27628
|
+
"process-spawn",
|
|
27629
|
+
() => new _AcpProcessSession(
|
|
27630
|
+
options.agent,
|
|
27631
|
+
options.cwd,
|
|
27632
|
+
options.additionalDirectories,
|
|
27633
|
+
options.sessionId,
|
|
27634
|
+
getObserver,
|
|
27635
|
+
store,
|
|
27636
|
+
metrics
|
|
27637
|
+
)
|
|
27482
27638
|
);
|
|
27483
27639
|
try {
|
|
27484
27640
|
await initialize(runtime);
|
|
@@ -27500,17 +27656,19 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
27500
27656
|
}
|
|
27501
27657
|
throw new AcpExecutionError("ACP agent initialization failed");
|
|
27502
27658
|
}
|
|
27503
|
-
static start = async (options, getObserver, store) => await _AcpProcessSession.#start(
|
|
27659
|
+
static start = async (options, getObserver, store, metrics = unmeasuredOperationMetrics) => await _AcpProcessSession.#start(
|
|
27504
27660
|
options,
|
|
27505
27661
|
getObserver,
|
|
27506
27662
|
store,
|
|
27507
|
-
async (runtime) => await runtime.initialize(options.signal, options.origin)
|
|
27663
|
+
async (runtime) => await runtime.initialize(options.signal, options.origin),
|
|
27664
|
+
metrics
|
|
27508
27665
|
);
|
|
27509
27666
|
static startNativeSessionBrowser = async (options, getObserver, store) => await _AcpProcessSession.#start(
|
|
27510
27667
|
options,
|
|
27511
27668
|
getObserver,
|
|
27512
27669
|
store,
|
|
27513
|
-
async (runtime) => await runtime.#initializeAgent(options.signal)
|
|
27670
|
+
async (runtime) => await runtime.#initializeAgent(options.signal),
|
|
27671
|
+
unmeasuredOperationMetrics
|
|
27514
27672
|
);
|
|
27515
27673
|
static startSessionForkAtTurn = async (options, sourceNativeSessionId, forkPoint, getObserver, store) => await _AcpProcessSession.#start(
|
|
27516
27674
|
options,
|
|
@@ -27520,7 +27678,8 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
27520
27678
|
options.signal,
|
|
27521
27679
|
{ kind: "fork", nativeSessionId: sourceNativeSessionId },
|
|
27522
27680
|
forkPoint
|
|
27523
|
-
)
|
|
27681
|
+
),
|
|
27682
|
+
unmeasuredOperationMetrics
|
|
27524
27683
|
);
|
|
27525
27684
|
belongsTo = (agentId, cwd, additionalDirectories) => this.#agentId === agentId && this.#cwd === cwd && arraysEqual(this.#additionalDirectories, additionalDirectories);
|
|
27526
27685
|
usesEnvironment = (environment) => recordsEqual(this.#environment, environment);
|
|
@@ -27639,6 +27798,9 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
27639
27798
|
);
|
|
27640
27799
|
};
|
|
27641
27800
|
async #initializeAgent(signal) {
|
|
27801
|
+
await this.#metrics.measure("agent-initialize", async () => await this.#initializeAgentOperation(signal));
|
|
27802
|
+
}
|
|
27803
|
+
async #initializeAgentOperation(signal) {
|
|
27642
27804
|
const initialized = await this.race(
|
|
27643
27805
|
this.#connection.agent.request(
|
|
27644
27806
|
methods6.agent.initialize,
|
|
@@ -27809,18 +27971,21 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
27809
27971
|
}
|
|
27810
27972
|
this.#store.remove(this.#mobiusSessionId);
|
|
27811
27973
|
}
|
|
27812
|
-
const created = await this.
|
|
27813
|
-
|
|
27814
|
-
|
|
27815
|
-
|
|
27816
|
-
|
|
27817
|
-
|
|
27818
|
-
|
|
27819
|
-
|
|
27820
|
-
|
|
27821
|
-
|
|
27822
|
-
|
|
27823
|
-
|
|
27974
|
+
const created = await this.#metrics.measure(
|
|
27975
|
+
"session-new",
|
|
27976
|
+
async () => await this.race(
|
|
27977
|
+
this.#connection.agent.request(
|
|
27978
|
+
methods6.agent.session.new,
|
|
27979
|
+
{
|
|
27980
|
+
additionalDirectories: [...this.#additionalDirectories],
|
|
27981
|
+
cwd: this.#cwd,
|
|
27982
|
+
mcpServers: []
|
|
27983
|
+
},
|
|
27984
|
+
{ cancellationSignal: signal }
|
|
27985
|
+
),
|
|
27986
|
+
"ACP agent exited while starting a session",
|
|
27987
|
+
signal
|
|
27988
|
+
)
|
|
27824
27989
|
);
|
|
27825
27990
|
this.selectNativeSession(created.sessionId);
|
|
27826
27991
|
lifecycleResponse = created;
|
|
@@ -28623,10 +28788,10 @@ var AcpSessionManager = class {
|
|
|
28623
28788
|
this.#nativeBrowserPreparing.set(options.sessionId, operation);
|
|
28624
28789
|
return await operation;
|
|
28625
28790
|
}
|
|
28626
|
-
async #startPreparation(options) {
|
|
28791
|
+
async #startPreparation(options, metrics = unmeasuredOperationMetrics) {
|
|
28627
28792
|
const operation = (async () => {
|
|
28628
28793
|
try {
|
|
28629
|
-
const runtime = await AcpProcessSession.start(options, () => this.#observer, this.#store);
|
|
28794
|
+
const runtime = await AcpProcessSession.start(options, () => this.#observer, this.#store, metrics);
|
|
28630
28795
|
this.#sessions.set(options.sessionId, runtime);
|
|
28631
28796
|
return runtime;
|
|
28632
28797
|
} finally {
|
|
@@ -28655,13 +28820,13 @@ var AcpSessionManager = class {
|
|
|
28655
28820
|
this.#preparing.set(options.sessionId, operation);
|
|
28656
28821
|
return await operation;
|
|
28657
28822
|
}
|
|
28658
|
-
async #replacePreparation(existing, options) {
|
|
28823
|
+
async #replacePreparation(existing, options, metrics) {
|
|
28659
28824
|
const operation = (async () => {
|
|
28660
28825
|
try {
|
|
28661
28826
|
this.#sessions.delete(options.sessionId);
|
|
28662
28827
|
await existing.close();
|
|
28663
28828
|
this.#store.remove(options.sessionId);
|
|
28664
|
-
const runtime = await AcpProcessSession.start(options, () => this.#observer, this.#store);
|
|
28829
|
+
const runtime = await AcpProcessSession.start(options, () => this.#observer, this.#store, metrics);
|
|
28665
28830
|
this.#sessions.set(options.sessionId, runtime);
|
|
28666
28831
|
return runtime;
|
|
28667
28832
|
} finally {
|
|
@@ -28723,7 +28888,7 @@ var AcpSessionManager = class {
|
|
|
28723
28888
|
this.#preparing.set(options.sessionId, operation);
|
|
28724
28889
|
return await operation;
|
|
28725
28890
|
}
|
|
28726
|
-
prepareSession = async (options) => {
|
|
28891
|
+
prepareSession = async (options, metrics = unmeasuredOperationMetrics) => {
|
|
28727
28892
|
const stored = this.#store.read(options.sessionId);
|
|
28728
28893
|
if (stored instanceof DeletedAcpStoredSession) {
|
|
28729
28894
|
throw new AcpExecutionError(
|
|
@@ -28741,7 +28906,7 @@ var AcpSessionManager = class {
|
|
|
28741
28906
|
if (runtime2.belongsTo(options.agent.id, options.cwd, options.additionalDirectories)) {
|
|
28742
28907
|
return runtime2.prepared();
|
|
28743
28908
|
}
|
|
28744
|
-
return await this.prepareSession(options);
|
|
28909
|
+
return await this.prepareSession(options, metrics);
|
|
28745
28910
|
}
|
|
28746
28911
|
const existing = this.#sessions.get(options.sessionId);
|
|
28747
28912
|
if (existing !== void 0) {
|
|
@@ -28755,12 +28920,35 @@ var AcpSessionManager = class {
|
|
|
28755
28920
|
"session_identity_mismatch"
|
|
28756
28921
|
);
|
|
28757
28922
|
}
|
|
28758
|
-
const runtime2 = await this.#replacePreparation(existing, options);
|
|
28923
|
+
const runtime2 = await this.#replacePreparation(existing, options, metrics);
|
|
28759
28924
|
return runtime2.prepared();
|
|
28760
28925
|
}
|
|
28761
|
-
const runtime = await this.#startPreparation(options);
|
|
28926
|
+
const runtime = await this.#startPreparation(options, metrics);
|
|
28762
28927
|
return runtime.prepared();
|
|
28763
28928
|
};
|
|
28929
|
+
/**
|
|
28930
|
+
* Opens a short-lived ACP session only to read the Agent's authoritative
|
|
28931
|
+
* configuration options. The runtime and any persisted native-session
|
|
28932
|
+
* record are released before this method resolves.
|
|
28933
|
+
*/
|
|
28934
|
+
inspectSession = async (options) => {
|
|
28935
|
+
if (this.#preparing.has(options.sessionId) || this.#sessions.has(options.sessionId)) {
|
|
28936
|
+
throw new AcpExecutionError("The configuration inspection session is already in use", {}, "session_busy");
|
|
28937
|
+
}
|
|
28938
|
+
const runtime = await this.#startPreparation(options);
|
|
28939
|
+
try {
|
|
28940
|
+
return runtime.prepared();
|
|
28941
|
+
} finally {
|
|
28942
|
+
if (this.#sessions.get(options.sessionId) === runtime) {
|
|
28943
|
+
this.#sessions.delete(options.sessionId);
|
|
28944
|
+
}
|
|
28945
|
+
try {
|
|
28946
|
+
await runtime.close();
|
|
28947
|
+
} finally {
|
|
28948
|
+
this.#store.remove(options.sessionId);
|
|
28949
|
+
}
|
|
28950
|
+
}
|
|
28951
|
+
};
|
|
28764
28952
|
prepareExecutionSession = async (options) => {
|
|
28765
28953
|
const pending = this.#preparing.get(options.sessionId);
|
|
28766
28954
|
if (pending !== void 0) {
|
|
@@ -29021,6 +29209,33 @@ var AcpSessionManager = class {
|
|
|
29021
29209
|
return started;
|
|
29022
29210
|
}
|
|
29023
29211
|
listNativeSessions = async (options, cursor) => await (await this.#ensureNativeSessionBrowser(options)).listNativeSessions(cursor, options.signal);
|
|
29212
|
+
previewNativeSession = async (options, nativeSessionId) => {
|
|
29213
|
+
const key = `${options.agent.id}:${nativeSessionId}`;
|
|
29214
|
+
const linked = this.#store.findNative(options.agent.id, nativeSessionId);
|
|
29215
|
+
if (this.#nativeOperations.has(key) || linked.some((entry) => this.#activeSessionIds.has(entry.sessionId) || this.#preparing.has(entry.sessionId))) {
|
|
29216
|
+
throw new AcpExecutionError(
|
|
29217
|
+
"Wait for the native session's running operation to finish",
|
|
29218
|
+
{},
|
|
29219
|
+
"session_busy"
|
|
29220
|
+
);
|
|
29221
|
+
}
|
|
29222
|
+
this.#nativeOperations.add(key);
|
|
29223
|
+
try {
|
|
29224
|
+
const runtime = await AcpProcessSession.startNativeSessionBrowser(
|
|
29225
|
+
options,
|
|
29226
|
+
() => this.#nativeBrowserObserver,
|
|
29227
|
+
new MemoryAcpSessionStore()
|
|
29228
|
+
);
|
|
29229
|
+
try {
|
|
29230
|
+
runtime.selectNativeSession(nativeSessionId);
|
|
29231
|
+
return await runtime.loadHistory(options.signal);
|
|
29232
|
+
} finally {
|
|
29233
|
+
await runtime.closeProcess();
|
|
29234
|
+
}
|
|
29235
|
+
} finally {
|
|
29236
|
+
this.#nativeOperations.delete(key);
|
|
29237
|
+
}
|
|
29238
|
+
};
|
|
29024
29239
|
openNativeSession = async (options, origin) => {
|
|
29025
29240
|
const key = `${options.agent.id}:${origin.nativeSessionId}`;
|
|
29026
29241
|
if (this.#nativeOperations.has(key)) {
|
|
@@ -29247,6 +29462,7 @@ async function publishAgentCatalog(config2, signal) {
|
|
|
29247
29462
|
agents: catalog.agents.map((agent) => ({
|
|
29248
29463
|
agentPath: agent.agentIdentity.requestedPath,
|
|
29249
29464
|
agentVersion: agent.agentVersion,
|
|
29465
|
+
botSessionConfiguration: true,
|
|
29250
29466
|
capabilities: agent.capabilities,
|
|
29251
29467
|
id: agent.id,
|
|
29252
29468
|
label: agent.label
|
|
@@ -30632,6 +30848,23 @@ var NativeSessionService = class {
|
|
|
30632
30848
|
);
|
|
30633
30849
|
}
|
|
30634
30850
|
const target = await this.resolveTarget(command, options, selected);
|
|
30851
|
+
if (command.action === "preview") {
|
|
30852
|
+
const history = await this.#sessions.previewNativeSession(
|
|
30853
|
+
{ ...options, cwd: target.cwd, additionalDirectories: target.additionalDirectories },
|
|
30854
|
+
target.info.sessionId
|
|
30855
|
+
);
|
|
30856
|
+
signal.throwIfAborted();
|
|
30857
|
+
this.record(command, "native_session_previewed");
|
|
30858
|
+
return {
|
|
30859
|
+
...envelope2,
|
|
30860
|
+
action: "preview",
|
|
30861
|
+
entryId: command.entryId,
|
|
30862
|
+
targetSessionId: command.sessionId,
|
|
30863
|
+
reason: "requested",
|
|
30864
|
+
title: target.info.title ?? "Untitled session",
|
|
30865
|
+
history
|
|
30866
|
+
};
|
|
30867
|
+
}
|
|
30635
30868
|
if (command.action === "delete") {
|
|
30636
30869
|
if (!prepared.capabilities.deleteSession) {
|
|
30637
30870
|
throw new AcpExecutionError(
|
|
@@ -32631,35 +32864,73 @@ async function executeSessionPrepare(publisher, socket, command, config2, direct
|
|
|
32631
32864
|
signal
|
|
32632
32865
|
);
|
|
32633
32866
|
const agent = config2.catalog.find(command.agentId);
|
|
32634
|
-
const
|
|
32867
|
+
const metrics = new AccumulatingOperationMetrics();
|
|
32868
|
+
const preparation = {
|
|
32635
32869
|
additionalDirectories: resolved.additionalDirectories,
|
|
32636
32870
|
agent,
|
|
32637
32871
|
cwd: resolved.cwd,
|
|
32638
32872
|
sessionId: command.sessionId,
|
|
32639
32873
|
signal
|
|
32640
|
-
}
|
|
32874
|
+
};
|
|
32875
|
+
const prepared = command.transient === true ? await sessions.inspectSession(preparation) : await sessions.prepareSession(preparation, metrics);
|
|
32876
|
+
const configuration = command.configuration;
|
|
32877
|
+
const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
|
|
32878
|
+
"configuration",
|
|
32879
|
+
async () => await sessions.configureSession({
|
|
32880
|
+
...preparation,
|
|
32881
|
+
booleanValue: configuration.booleanValue,
|
|
32882
|
+
configId: configuration.configId,
|
|
32883
|
+
requestId: command.requestId,
|
|
32884
|
+
value: configuration.value,
|
|
32885
|
+
valueType: configuration.valueType
|
|
32886
|
+
})
|
|
32887
|
+
);
|
|
32641
32888
|
const listing = await directories.list(config2.bindingId, command.directoryId, signal);
|
|
32642
32889
|
audit.record({
|
|
32643
32890
|
commandId: command.requestId,
|
|
32644
32891
|
event: "session_prepared",
|
|
32645
32892
|
sessionId: command.sessionId
|
|
32646
32893
|
});
|
|
32647
|
-
|
|
32648
|
-
|
|
32649
|
-
|
|
32650
|
-
|
|
32651
|
-
agentId: command.agentId,
|
|
32652
|
-
agentName: prepared.agentName,
|
|
32653
|
-
agentVersion: prepared.agentVersion,
|
|
32654
|
-
capabilities: prepared.capabilities,
|
|
32655
|
-
commands: prepared.commands,
|
|
32656
|
-
configOptions: prepared.configOptions,
|
|
32657
|
-
directoryId: command.directoryId,
|
|
32658
|
-
directoryLabel: listing.directoryLabel,
|
|
32659
|
-
kind: "session.ready",
|
|
32660
|
-
requestId: command.requestId,
|
|
32661
|
-
restored: prepared.restored,
|
|
32894
|
+
if (command.configuration !== void 0) {
|
|
32895
|
+
audit.record({
|
|
32896
|
+
commandId: command.requestId,
|
|
32897
|
+
event: "session_configured",
|
|
32662
32898
|
sessionId: command.sessionId
|
|
32899
|
+
});
|
|
32900
|
+
publisher.recordRuntime(
|
|
32901
|
+
command.sessionId,
|
|
32902
|
+
encodeSessionConfigUpdatedEvent({
|
|
32903
|
+
configOptions,
|
|
32904
|
+
kind: "session.config.updated",
|
|
32905
|
+
requestId: command.requestId,
|
|
32906
|
+
sessionId: command.sessionId
|
|
32907
|
+
})
|
|
32908
|
+
);
|
|
32909
|
+
}
|
|
32910
|
+
const readyEvent = {
|
|
32911
|
+
additionalDirectories: resolved.additionalDirectoryEntries,
|
|
32912
|
+
agentId: command.agentId,
|
|
32913
|
+
agentName: prepared.agentName,
|
|
32914
|
+
agentVersion: prepared.agentVersion,
|
|
32915
|
+
capabilities: prepared.capabilities,
|
|
32916
|
+
commands: prepared.commands,
|
|
32917
|
+
configOptions,
|
|
32918
|
+
directoryId: command.directoryId,
|
|
32919
|
+
directoryLabel: listing.directoryLabel,
|
|
32920
|
+
kind: "session.ready",
|
|
32921
|
+
requestId: command.requestId,
|
|
32922
|
+
restored: prepared.restored,
|
|
32923
|
+
sessionId: command.sessionId,
|
|
32924
|
+
runtimeTimings: metrics.snapshot()
|
|
32925
|
+
};
|
|
32926
|
+
metrics.measureSync("readiness-commit", () => {
|
|
32927
|
+
publisher.recordRuntime(command.sessionId, encodeSessionReadyEvent(readyEvent));
|
|
32928
|
+
});
|
|
32929
|
+
send(
|
|
32930
|
+
socket,
|
|
32931
|
+
encodeSessionReadyEvent({
|
|
32932
|
+
...readyEvent,
|
|
32933
|
+
runtimeTimings: metrics.snapshot()
|
|
32663
32934
|
})
|
|
32664
32935
|
);
|
|
32665
32936
|
} catch (error62) {
|
|
@@ -32916,6 +33187,20 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
|
|
|
32916
33187
|
sessionId: command.sessionId,
|
|
32917
33188
|
signal: executionSignal
|
|
32918
33189
|
});
|
|
33190
|
+
for (const selection of command.sessionConfigurations) {
|
|
33191
|
+
await sessions.configureSession({
|
|
33192
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
33193
|
+
agent,
|
|
33194
|
+
booleanValue: selection.booleanValue,
|
|
33195
|
+
configId: selection.configId,
|
|
33196
|
+
cwd: resolved.cwd,
|
|
33197
|
+
requestId: `cfg_${randomUUID6()}`,
|
|
33198
|
+
sessionId: command.sessionId,
|
|
33199
|
+
signal: executionSignal,
|
|
33200
|
+
value: selection.value,
|
|
33201
|
+
valueType: selection.valueType
|
|
33202
|
+
});
|
|
33203
|
+
}
|
|
32919
33204
|
audit.record({
|
|
32920
33205
|
commandId: command.commandId,
|
|
32921
33206
|
details: {
|