@moxt-ai/mobius 0.0.34 → 0.0.35
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 +7 -0
- package/dist/acp/session-manager.d.ts.map +1 -1
- package/dist/acp/session-manager.js +47 -0
- package/dist/acp/session-manager.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 +243 -57
- package/dist/cli.js.map +3 -3
- package/dist/index.js +242 -56
- package/dist/index.js.map +3 -3
- 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 +19 -2
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +242 -56
- package/dist/runtime.js.map +3 -3
- 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(),
|
|
@@ -22682,7 +22702,8 @@ var sessionIdentityFields = {
|
|
|
22682
22702
|
var sessionPrepareCommandSchema = external_exports.strictObject({
|
|
22683
22703
|
...sessionIdentityFields,
|
|
22684
22704
|
kind: external_exports.literal(SESSION_PREPARE_KIND),
|
|
22685
|
-
requestId: IDENTIFIER
|
|
22705
|
+
requestId: IDENTIFIER,
|
|
22706
|
+
transient: external_exports.boolean().optional()
|
|
22686
22707
|
}).readonly();
|
|
22687
22708
|
var sessionReadyEventSchema = external_exports.strictObject({
|
|
22688
22709
|
additionalDirectories: external_exports.array(workspaceEntrySchema).max(16).readonly(),
|
|
@@ -22691,7 +22712,7 @@ var sessionReadyEventSchema = external_exports.strictObject({
|
|
|
22691
22712
|
agentVersion: external_exports.string().max(128),
|
|
22692
22713
|
capabilities: sessionCapabilitiesSchema,
|
|
22693
22714
|
commands: external_exports.array(sessionCommandSchema).max(500).readonly(),
|
|
22694
|
-
configOptions:
|
|
22715
|
+
configOptions: sessionConfigOptionsSchema,
|
|
22695
22716
|
directoryId: DIRECTORY_IDENTIFIER,
|
|
22696
22717
|
directoryLabel: external_exports.string().min(1).max(2048),
|
|
22697
22718
|
kind: external_exports.literal(SESSION_READY_KIND),
|
|
@@ -22709,7 +22730,7 @@ var sessionConfigureCommandSchema = external_exports.strictObject({
|
|
|
22709
22730
|
valueType: external_exports.enum(["boolean", "select"])
|
|
22710
22731
|
}).readonly();
|
|
22711
22732
|
var sessionConfigUpdatedEventSchema = external_exports.strictObject({
|
|
22712
|
-
configOptions:
|
|
22733
|
+
configOptions: sessionConfigOptionsSchema,
|
|
22713
22734
|
kind: external_exports.literal(SESSION_CONFIG_UPDATED_KIND),
|
|
22714
22735
|
requestId: IDENTIFIER,
|
|
22715
22736
|
sessionId: IDENTIFIER
|
|
@@ -22885,6 +22906,7 @@ var decodeAgentDisplayContentValue = (value) => decodeValue(value, displayConten
|
|
|
22885
22906
|
var decodeRecordedAgentContentValue = (value) => decodeValue(value, recordedDisplayContentSchema);
|
|
22886
22907
|
var decodePromptImagesValue = (value) => decodeValue(value, external_exports.array(promptImageSchema).max(8).readonly());
|
|
22887
22908
|
var decodePromptResourcesValue = (value) => decodeValue(value, external_exports.array(promptResourceSchema).max(16).readonly());
|
|
22909
|
+
var decodeSessionConfigurationSelections = (value) => decodeValue(value, sessionConfigurationSelectionsSchema);
|
|
22888
22910
|
var encode3 = (message, schema) => JSON.stringify(decodeValue(message, schema));
|
|
22889
22911
|
var decodeWorkspaceListCommand = (encoded) => decode3(encoded, workspaceListCommandSchema);
|
|
22890
22912
|
var encodeWorkspaceEntriesEvent = (message) => encode3(message, workspaceEntriesEventSchema);
|
|
@@ -23421,8 +23443,9 @@ var BotExecutionBindingApprovalRequest = class {
|
|
|
23421
23443
|
requestId;
|
|
23422
23444
|
requiredCapabilities;
|
|
23423
23445
|
runtimeId;
|
|
23446
|
+
sessionConfigurations;
|
|
23424
23447
|
workspaceRef;
|
|
23425
|
-
constructor(requestId, botId, behaviorRevisionId, bindingId, bindingRevision, runtimeId, agentRef, workspaceRef, agentConfigRevision, behaviorInstructions, behaviorDigest, requiredCapabilities, allowedDeliveryTargets, completionPolicy) {
|
|
23448
|
+
constructor(requestId, botId, behaviorRevisionId, bindingId, bindingRevision, runtimeId, agentRef, workspaceRef, agentConfigRevision, behaviorInstructions, behaviorDigest, requiredCapabilities, allowedDeliveryTargets, completionPolicy, sessionConfigurations = []) {
|
|
23426
23449
|
this.requestId = requestId;
|
|
23427
23450
|
this.botId = botId;
|
|
23428
23451
|
this.behaviorRevisionId = behaviorRevisionId;
|
|
@@ -23435,6 +23458,7 @@ var BotExecutionBindingApprovalRequest = class {
|
|
|
23435
23458
|
this.behaviorInstructions = behaviorInstructions;
|
|
23436
23459
|
this.behaviorDigest = behaviorDigest;
|
|
23437
23460
|
this.requiredCapabilities = Object.freeze([...requiredCapabilities]);
|
|
23461
|
+
this.sessionConfigurations = Object.freeze([...sessionConfigurations]);
|
|
23438
23462
|
this.allowedDeliveryTargets = Object.freeze(
|
|
23439
23463
|
allowedDeliveryTargets.map(
|
|
23440
23464
|
(target) => new BotDeliveryTargetReference(target.alias, target.deliveryTargetId)
|
|
@@ -23442,6 +23466,13 @@ var BotExecutionBindingApprovalRequest = class {
|
|
|
23442
23466
|
);
|
|
23443
23467
|
this.completionPolicy = completionPolicy;
|
|
23444
23468
|
}
|
|
23469
|
+
toJSON() {
|
|
23470
|
+
const { sessionConfigurations, ...request } = this;
|
|
23471
|
+
return {
|
|
23472
|
+
...request,
|
|
23473
|
+
...sessionConfigurations.length === 0 ? {} : { sessionConfigurations }
|
|
23474
|
+
};
|
|
23475
|
+
}
|
|
23445
23476
|
};
|
|
23446
23477
|
var BotExecutionBindingApprovedEvent = class {
|
|
23447
23478
|
agentIdentityDigest;
|
|
@@ -23506,9 +23537,10 @@ var BotSessionPromptCommand = class {
|
|
|
23506
23537
|
prompt;
|
|
23507
23538
|
replyRoute;
|
|
23508
23539
|
resources;
|
|
23540
|
+
sessionConfigurations;
|
|
23509
23541
|
sessionId;
|
|
23510
23542
|
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) {
|
|
23543
|
+
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
23544
|
this.sessionId = sessionId;
|
|
23513
23545
|
this.commandId = commandId;
|
|
23514
23546
|
this.agentId = agentId;
|
|
@@ -23536,6 +23568,14 @@ var BotSessionPromptCommand = class {
|
|
|
23536
23568
|
)
|
|
23537
23569
|
);
|
|
23538
23570
|
this.replyRoute = replyRoute;
|
|
23571
|
+
this.sessionConfigurations = Object.freeze([...sessionConfigurations]);
|
|
23572
|
+
}
|
|
23573
|
+
toJSON() {
|
|
23574
|
+
const { sessionConfigurations, ...command } = this;
|
|
23575
|
+
return {
|
|
23576
|
+
...command,
|
|
23577
|
+
...sessionConfigurations.length === 0 ? {} : { sessionConfigurations }
|
|
23578
|
+
};
|
|
23539
23579
|
}
|
|
23540
23580
|
};
|
|
23541
23581
|
function isRecord5(value) {
|
|
@@ -23559,6 +23599,12 @@ function assertExactKeys2(value, expected) {
|
|
|
23559
23599
|
throw new ProtocolMessageError("Message fields do not match the Bot protocol");
|
|
23560
23600
|
}
|
|
23561
23601
|
}
|
|
23602
|
+
function assertKeysWithOptional(value, expected, optional2) {
|
|
23603
|
+
const keys = Object.keys(value);
|
|
23604
|
+
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))) {
|
|
23605
|
+
throw new ProtocolMessageError("Message fields do not match the Bot protocol");
|
|
23606
|
+
}
|
|
23607
|
+
}
|
|
23562
23608
|
function readText2(value, key, maximumLength, allowEmpty) {
|
|
23563
23609
|
const field = value[key];
|
|
23564
23610
|
if (typeof field !== "string" || field.length > maximumLength || !allowEmpty && field.length === 0) {
|
|
@@ -23648,6 +23694,12 @@ function readTargets(value, key) {
|
|
|
23648
23694
|
}
|
|
23649
23695
|
return Object.freeze(targets);
|
|
23650
23696
|
}
|
|
23697
|
+
function readSessionConfigurations(value) {
|
|
23698
|
+
if (!Object.hasOwn(value, "sessionConfigurations")) {
|
|
23699
|
+
return [];
|
|
23700
|
+
}
|
|
23701
|
+
return decodeSessionConfigurationSelections(value["sessionConfigurations"]);
|
|
23702
|
+
}
|
|
23651
23703
|
function readCompletionPolicy(value) {
|
|
23652
23704
|
if (!isRecord5(value)) {
|
|
23653
23705
|
throw new ProtocolMessageError("Invalid Bot completion policy");
|
|
@@ -23686,23 +23738,27 @@ function readReplyRoute(value) {
|
|
|
23686
23738
|
}
|
|
23687
23739
|
function decodeBotExecutionBindingApprovalRequest(encoded) {
|
|
23688
23740
|
const value = parseJson3(encoded);
|
|
23689
|
-
|
|
23690
|
-
|
|
23691
|
-
|
|
23692
|
-
|
|
23693
|
-
|
|
23694
|
-
|
|
23695
|
-
|
|
23696
|
-
|
|
23697
|
-
|
|
23698
|
-
|
|
23699
|
-
|
|
23700
|
-
|
|
23701
|
-
|
|
23702
|
-
|
|
23703
|
-
|
|
23704
|
-
|
|
23705
|
-
|
|
23741
|
+
assertKeysWithOptional(
|
|
23742
|
+
value,
|
|
23743
|
+
[
|
|
23744
|
+
"agentConfigRevision",
|
|
23745
|
+
"agentRef",
|
|
23746
|
+
"allowedDeliveryTargets",
|
|
23747
|
+
"behaviorDigest",
|
|
23748
|
+
"behaviorInstructions",
|
|
23749
|
+
"behaviorRevisionId",
|
|
23750
|
+
"bindingId",
|
|
23751
|
+
"bindingRevision",
|
|
23752
|
+
"botId",
|
|
23753
|
+
"completionPolicy",
|
|
23754
|
+
"kind",
|
|
23755
|
+
"requestId",
|
|
23756
|
+
"requiredCapabilities",
|
|
23757
|
+
"runtimeId",
|
|
23758
|
+
"workspaceRef"
|
|
23759
|
+
],
|
|
23760
|
+
["sessionConfigurations"]
|
|
23761
|
+
);
|
|
23706
23762
|
if (value["kind"] !== BOT_BINDING_APPROVAL_REQUEST_KIND) {
|
|
23707
23763
|
throw new ProtocolMessageError("Invalid Bot binding approval request kind");
|
|
23708
23764
|
}
|
|
@@ -23720,7 +23776,8 @@ function decodeBotExecutionBindingApprovalRequest(encoded) {
|
|
|
23720
23776
|
readDigest(value, "behaviorDigest"),
|
|
23721
23777
|
readIdentifiers(value, "requiredCapabilities", 32),
|
|
23722
23778
|
readTargets(value, "allowedDeliveryTargets"),
|
|
23723
|
-
readCompletionPolicy(value["completionPolicy"])
|
|
23779
|
+
readCompletionPolicy(value["completionPolicy"]),
|
|
23780
|
+
readSessionConfigurations(value)
|
|
23724
23781
|
);
|
|
23725
23782
|
}
|
|
23726
23783
|
function decodeBotExecutionBindingApprovedEvent(encoded) {
|
|
@@ -23783,32 +23840,36 @@ function encodeBotExecutionBindingUnavailableEvent(event) {
|
|
|
23783
23840
|
}
|
|
23784
23841
|
function decodeBotSessionPromptCommand(encoded) {
|
|
23785
23842
|
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
|
-
|
|
23843
|
+
assertKeysWithOptional(
|
|
23844
|
+
value,
|
|
23845
|
+
[
|
|
23846
|
+
"additionalDirectoryIds",
|
|
23847
|
+
"agentId",
|
|
23848
|
+
"allowedDeliveryTargets",
|
|
23849
|
+
"behaviorDigest",
|
|
23850
|
+
"behaviorInstructions",
|
|
23851
|
+
"behaviorRevisionId",
|
|
23852
|
+
"bindingId",
|
|
23853
|
+
"bindingRevision",
|
|
23854
|
+
"botId",
|
|
23855
|
+
"commandId",
|
|
23856
|
+
"conversationId",
|
|
23857
|
+
"directoryId",
|
|
23858
|
+
"executionCapabilityId",
|
|
23859
|
+
"executionCapabilitySecret",
|
|
23860
|
+
"executionDeadlineAt",
|
|
23861
|
+
"executionId",
|
|
23862
|
+
"images",
|
|
23863
|
+
"kind",
|
|
23864
|
+
"localGrantId",
|
|
23865
|
+
"prompt",
|
|
23866
|
+
"replyRoute",
|
|
23867
|
+
"resources",
|
|
23868
|
+
"sessionId",
|
|
23869
|
+
"turnId"
|
|
23870
|
+
],
|
|
23871
|
+
["sessionConfigurations"]
|
|
23872
|
+
);
|
|
23812
23873
|
if (value["kind"] !== BOT_SESSION_PROMPT_KIND) {
|
|
23813
23874
|
throw new ProtocolMessageError("Invalid Bot Session prompt kind");
|
|
23814
23875
|
}
|
|
@@ -23835,7 +23896,8 @@ function decodeBotSessionPromptCommand(encoded) {
|
|
|
23835
23896
|
readText2(value, "behaviorInstructions", MAX_INSTRUCTIONS_LENGTH, true),
|
|
23836
23897
|
readDigest(value, "behaviorDigest"),
|
|
23837
23898
|
readTargets(value, "allowedDeliveryTargets"),
|
|
23838
|
-
readReplyRoute(value["replyRoute"])
|
|
23899
|
+
readReplyRoute(value["replyRoute"]),
|
|
23900
|
+
readSessionConfigurations(value)
|
|
23839
23901
|
);
|
|
23840
23902
|
}
|
|
23841
23903
|
|
|
@@ -23958,6 +24020,7 @@ var nativeSessionTurnForkCommandSchema = external_exports.strictObject({
|
|
|
23958
24020
|
title: external_exports.string().max(500)
|
|
23959
24021
|
}).readonly();
|
|
23960
24022
|
var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
24023
|
+
external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
|
|
23961
24024
|
external_exports.strictObject({
|
|
23962
24025
|
...identity,
|
|
23963
24026
|
action: external_exports.literal("list"),
|
|
@@ -24008,7 +24071,7 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
|
24008
24071
|
action: external_exports.literal("preview"),
|
|
24009
24072
|
entryId: identifier,
|
|
24010
24073
|
targetSessionId: identifier,
|
|
24011
|
-
reason: external_exports.
|
|
24074
|
+
reason: external_exports.enum(["continuation_unavailable", "requested"]),
|
|
24012
24075
|
history: sessionHistorySchema,
|
|
24013
24076
|
title: external_exports.string().max(500)
|
|
24014
24077
|
}).readonly(),
|
|
@@ -27421,6 +27484,29 @@ var AcpSessionManager = class {
|
|
|
27421
27484
|
const runtime = await this.#startPreparation(options);
|
|
27422
27485
|
return runtime.prepared();
|
|
27423
27486
|
};
|
|
27487
|
+
/**
|
|
27488
|
+
* Opens a short-lived ACP session only to read the Agent's authoritative
|
|
27489
|
+
* configuration options. The runtime and any persisted native-session
|
|
27490
|
+
* record are released before this method resolves.
|
|
27491
|
+
*/
|
|
27492
|
+
inspectSession = async (options) => {
|
|
27493
|
+
if (this.#preparing.has(options.sessionId) || this.#sessions.has(options.sessionId)) {
|
|
27494
|
+
throw new AcpExecutionError("The configuration inspection session is already in use", {}, "session_busy");
|
|
27495
|
+
}
|
|
27496
|
+
const runtime = await this.#startPreparation(options);
|
|
27497
|
+
try {
|
|
27498
|
+
return runtime.prepared();
|
|
27499
|
+
} finally {
|
|
27500
|
+
if (this.#sessions.get(options.sessionId) === runtime) {
|
|
27501
|
+
this.#sessions.delete(options.sessionId);
|
|
27502
|
+
}
|
|
27503
|
+
try {
|
|
27504
|
+
await runtime.close();
|
|
27505
|
+
} finally {
|
|
27506
|
+
this.#store.remove(options.sessionId);
|
|
27507
|
+
}
|
|
27508
|
+
}
|
|
27509
|
+
};
|
|
27424
27510
|
prepareExecutionSession = async (options) => {
|
|
27425
27511
|
const pending = this.#preparing.get(options.sessionId);
|
|
27426
27512
|
if (pending !== void 0) {
|
|
@@ -27681,6 +27767,33 @@ var AcpSessionManager = class {
|
|
|
27681
27767
|
return started;
|
|
27682
27768
|
}
|
|
27683
27769
|
listNativeSessions = async (options, cursor) => await (await this.#ensureNativeSessionBrowser(options)).listNativeSessions(cursor, options.signal);
|
|
27770
|
+
previewNativeSession = async (options, nativeSessionId) => {
|
|
27771
|
+
const key = `${options.agent.id}:${nativeSessionId}`;
|
|
27772
|
+
const linked = this.#store.findNative(options.agent.id, nativeSessionId);
|
|
27773
|
+
if (this.#nativeOperations.has(key) || linked.some((entry) => this.#activeSessionIds.has(entry.sessionId) || this.#preparing.has(entry.sessionId))) {
|
|
27774
|
+
throw new AcpExecutionError(
|
|
27775
|
+
"Wait for the native session's running operation to finish",
|
|
27776
|
+
{},
|
|
27777
|
+
"session_busy"
|
|
27778
|
+
);
|
|
27779
|
+
}
|
|
27780
|
+
this.#nativeOperations.add(key);
|
|
27781
|
+
try {
|
|
27782
|
+
const runtime = await AcpProcessSession.startNativeSessionBrowser(
|
|
27783
|
+
options,
|
|
27784
|
+
() => this.#nativeBrowserObserver,
|
|
27785
|
+
new MemoryAcpSessionStore()
|
|
27786
|
+
);
|
|
27787
|
+
try {
|
|
27788
|
+
runtime.selectNativeSession(nativeSessionId);
|
|
27789
|
+
return await runtime.loadHistory(options.signal);
|
|
27790
|
+
} finally {
|
|
27791
|
+
await runtime.closeProcess();
|
|
27792
|
+
}
|
|
27793
|
+
} finally {
|
|
27794
|
+
this.#nativeOperations.delete(key);
|
|
27795
|
+
}
|
|
27796
|
+
};
|
|
27684
27797
|
openNativeSession = async (options, origin) => {
|
|
27685
27798
|
const key = `${options.agent.id}:${origin.nativeSessionId}`;
|
|
27686
27799
|
if (this.#nativeOperations.has(key)) {
|
|
@@ -27907,6 +28020,7 @@ async function publishAgentCatalog(config2, signal) {
|
|
|
27907
28020
|
agents: catalog.agents.map((agent) => ({
|
|
27908
28021
|
agentPath: agent.agentIdentity.requestedPath,
|
|
27909
28022
|
agentVersion: agent.agentVersion,
|
|
28023
|
+
botSessionConfiguration: true,
|
|
27910
28024
|
capabilities: agent.capabilities,
|
|
27911
28025
|
id: agent.id,
|
|
27912
28026
|
label: agent.label
|
|
@@ -29045,6 +29159,16 @@ function exactTargets(left, right) {
|
|
|
29045
29159
|
const actual = [...right].sort();
|
|
29046
29160
|
return expected.every((target, index) => target === actual[index]);
|
|
29047
29161
|
}
|
|
29162
|
+
function exactSessionConfigurations(left, right) {
|
|
29163
|
+
if (left.length !== right.length) {
|
|
29164
|
+
return false;
|
|
29165
|
+
}
|
|
29166
|
+
const expected = new Map(left.map((selection) => [selection.configId, selection]));
|
|
29167
|
+
return right.every((selection) => {
|
|
29168
|
+
const approved = expected.get(selection.configId);
|
|
29169
|
+
return approved !== void 0 && approved.booleanValue === selection.booleanValue && approved.value === selection.value && approved.valueType === selection.valueType;
|
|
29170
|
+
});
|
|
29171
|
+
}
|
|
29048
29172
|
function rowString(row, key) {
|
|
29049
29173
|
const value = Reflect.get(row, key);
|
|
29050
29174
|
if (typeof value !== "string") {
|
|
@@ -29071,6 +29195,15 @@ function parseTargets(encoded) {
|
|
|
29071
29195
|
}
|
|
29072
29196
|
return value.filter((target) => typeof target === "string");
|
|
29073
29197
|
}
|
|
29198
|
+
function parseSessionConfigurations(encoded) {
|
|
29199
|
+
let value;
|
|
29200
|
+
try {
|
|
29201
|
+
value = JSON.parse(encoded);
|
|
29202
|
+
return decodeSessionConfigurationSelections(value);
|
|
29203
|
+
} catch (cause) {
|
|
29204
|
+
throw new LocalBotAuthorizationError("local_grant_invalid", "The local Bot grant is invalid", { cause });
|
|
29205
|
+
}
|
|
29206
|
+
}
|
|
29074
29207
|
var LocalBotGrantStore = class {
|
|
29075
29208
|
#database;
|
|
29076
29209
|
static containsBot = (path2, botId) => {
|
|
@@ -29115,6 +29248,10 @@ var LocalBotGrantStore = class {
|
|
|
29115
29248
|
error_code TEXT,
|
|
29116
29249
|
error_message TEXT
|
|
29117
29250
|
) STRICT;
|
|
29251
|
+
CREATE TABLE IF NOT EXISTS local_bot_grant_configurations (
|
|
29252
|
+
local_grant_id TEXT PRIMARY KEY,
|
|
29253
|
+
session_configurations_json TEXT NOT NULL
|
|
29254
|
+
) STRICT;
|
|
29118
29255
|
`);
|
|
29119
29256
|
}
|
|
29120
29257
|
/** Only the local CLI may invoke this explicit approval transition. */
|
|
@@ -29240,6 +29377,11 @@ var LocalBotGrantStore = class {
|
|
|
29240
29377
|
now,
|
|
29241
29378
|
expiresAt
|
|
29242
29379
|
);
|
|
29380
|
+
this.#database.prepare(
|
|
29381
|
+
`INSERT INTO local_bot_grant_configurations (
|
|
29382
|
+
local_grant_id, session_configurations_json
|
|
29383
|
+
) VALUES (?, ?)`
|
|
29384
|
+
).run(localGrantId, JSON.stringify(request.sessionConfigurations));
|
|
29243
29385
|
this.#database.prepare(
|
|
29244
29386
|
`INSERT INTO local_bot_binding_resolutions (
|
|
29245
29387
|
request_id, binding_id, local_grant_id, resolved_at, result
|
|
@@ -29265,8 +29407,12 @@ var LocalBotGrantStore = class {
|
|
|
29265
29407
|
resolveExecution = async (command, catalog, directories, bindingAuthorityId, now, signal) => {
|
|
29266
29408
|
signal.throwIfAborted();
|
|
29267
29409
|
const row = this.#database.prepare(
|
|
29268
|
-
`SELECT
|
|
29269
|
-
|
|
29410
|
+
`SELECT grants.*, COALESCE(configurations.session_configurations_json, '[]')
|
|
29411
|
+
AS session_configurations_json
|
|
29412
|
+
FROM local_bot_grants AS grants
|
|
29413
|
+
LEFT JOIN local_bot_grant_configurations AS configurations
|
|
29414
|
+
ON configurations.local_grant_id = grants.local_grant_id
|
|
29415
|
+
WHERE grants.local_grant_id = ? AND grants.bot_id = ?
|
|
29270
29416
|
AND behavior_revision_id = ? AND behavior_digest = ?
|
|
29271
29417
|
AND binding_id = ? AND binding_revision = ?
|
|
29272
29418
|
AND agent_ref = ?
|
|
@@ -29295,6 +29441,13 @@ var LocalBotGrantStore = class {
|
|
|
29295
29441
|
"The Bot execution target policy changed after local approval"
|
|
29296
29442
|
);
|
|
29297
29443
|
}
|
|
29444
|
+
const approvedConfigurations = parseSessionConfigurations(rowString(row, "session_configurations_json"));
|
|
29445
|
+
if (!exactSessionConfigurations(approvedConfigurations, command.sessionConfigurations)) {
|
|
29446
|
+
throw new LocalBotAuthorizationError(
|
|
29447
|
+
"binding_not_approved",
|
|
29448
|
+
"The Bot Agent configuration changed after local approval"
|
|
29449
|
+
);
|
|
29450
|
+
}
|
|
29298
29451
|
const agent = catalog.find(command.agentId);
|
|
29299
29452
|
const [adapterUnchanged, agentUnchanged] = await Promise.all([
|
|
29300
29453
|
revalidateExecutable(agent.adapterIdentity),
|
|
@@ -29889,6 +30042,23 @@ var NativeSessionService = class {
|
|
|
29889
30042
|
);
|
|
29890
30043
|
}
|
|
29891
30044
|
const target = await this.resolveTarget(command, options, selected);
|
|
30045
|
+
if (command.action === "preview") {
|
|
30046
|
+
const history = await this.#sessions.previewNativeSession(
|
|
30047
|
+
{ ...options, cwd: target.cwd, additionalDirectories: target.additionalDirectories },
|
|
30048
|
+
target.info.sessionId
|
|
30049
|
+
);
|
|
30050
|
+
signal.throwIfAborted();
|
|
30051
|
+
this.record(command, "native_session_previewed");
|
|
30052
|
+
return {
|
|
30053
|
+
...envelope2,
|
|
30054
|
+
action: "preview",
|
|
30055
|
+
entryId: command.entryId,
|
|
30056
|
+
targetSessionId: command.sessionId,
|
|
30057
|
+
reason: "requested",
|
|
30058
|
+
title: target.info.title ?? "Untitled session",
|
|
30059
|
+
history
|
|
30060
|
+
};
|
|
30061
|
+
}
|
|
29892
30062
|
if (command.action === "delete") {
|
|
29893
30063
|
if (!prepared.capabilities.deleteSession) {
|
|
29894
30064
|
throw new AcpExecutionError(
|
|
@@ -31888,13 +32058,14 @@ async function executeSessionPrepare(publisher, socket, command, config2, direct
|
|
|
31888
32058
|
signal
|
|
31889
32059
|
);
|
|
31890
32060
|
const agent = config2.catalog.find(command.agentId);
|
|
31891
|
-
const
|
|
32061
|
+
const preparation = {
|
|
31892
32062
|
additionalDirectories: resolved.additionalDirectories,
|
|
31893
32063
|
agent,
|
|
31894
32064
|
cwd: resolved.cwd,
|
|
31895
32065
|
sessionId: command.sessionId,
|
|
31896
32066
|
signal
|
|
31897
|
-
}
|
|
32067
|
+
};
|
|
32068
|
+
const prepared = command.transient === true ? await sessions.inspectSession(preparation) : await sessions.prepareSession(preparation);
|
|
31898
32069
|
const listing = await directories.list(config2.bindingId, command.directoryId, signal);
|
|
31899
32070
|
audit.record({
|
|
31900
32071
|
commandId: command.requestId,
|
|
@@ -32173,6 +32344,20 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
|
|
|
32173
32344
|
sessionId: command.sessionId,
|
|
32174
32345
|
signal: executionSignal
|
|
32175
32346
|
});
|
|
32347
|
+
for (const selection of command.sessionConfigurations) {
|
|
32348
|
+
await sessions.configureSession({
|
|
32349
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
32350
|
+
agent,
|
|
32351
|
+
booleanValue: selection.booleanValue,
|
|
32352
|
+
configId: selection.configId,
|
|
32353
|
+
cwd: resolved.cwd,
|
|
32354
|
+
requestId: `cfg_${randomUUID4()}`,
|
|
32355
|
+
sessionId: command.sessionId,
|
|
32356
|
+
signal: executionSignal,
|
|
32357
|
+
value: selection.value,
|
|
32358
|
+
valueType: selection.valueType
|
|
32359
|
+
});
|
|
32360
|
+
}
|
|
32176
32361
|
audit.record({
|
|
32177
32362
|
commandId: command.commandId,
|
|
32178
32363
|
details: {
|
|
@@ -33393,6 +33578,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
|
|
|
33393
33578
|
const agents = localAgents.map((agent) => ({
|
|
33394
33579
|
agentPath: agent.agentIdentity.requestedPath,
|
|
33395
33580
|
agentVersion: agent.agentVersion,
|
|
33581
|
+
botSessionConfiguration: true,
|
|
33396
33582
|
capabilities: agent.capabilities,
|
|
33397
33583
|
id: agent.id,
|
|
33398
33584
|
label: agent.label
|