@moxt-ai/mobius 0.0.43 → 0.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-catalog/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/artifacts/runtime-artifact-uploader.d.ts.map +1 -1
- package/dist/artifacts/runtime-artifact-uploader.js +10 -17
- package/dist/artifacts/runtime-artifact-uploader.js.map +1 -1
- package/dist/bots/bot-context-applicator.d.ts +3 -3
- package/dist/bots/bot-context-applicator.d.ts.map +1 -1
- package/dist/bots/bot-context-applicator.js +7 -7
- package/dist/bots/bot-context-applicator.js.map +1 -1
- package/dist/bots/bot-execution-context.js +1 -1
- package/dist/bots/bot-execution-context.js.map +1 -1
- package/dist/bots/bot-outbound-ipc.js +1 -1
- package/dist/bots/bot-outbound-ipc.js.map +1 -1
- package/dist/bots/local-bot-execution-authorizer.d.ts +23 -0
- package/dist/bots/local-bot-execution-authorizer.d.ts.map +1 -0
- package/dist/bots/local-bot-execution-authorizer.js +62 -0
- package/dist/bots/local-bot-execution-authorizer.js.map +1 -0
- package/dist/cli.js +229 -851
- package/dist/cli.js.map +4 -4
- package/dist/index.js +233 -855
- package/dist/index.js.map +4 -4
- 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 +139 -87
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +230 -852
- package/dist/runtime.js.map +4 -4
- package/package.json +1 -1
- package/dist/bots/local-bot-grant-store.d.ts +0 -36
- package/dist/bots/local-bot-grant-store.d.ts.map +0 -1
- package/dist/bots/local-bot-grant-store.js +0 -398
- package/dist/bots/local-bot-grant-store.js.map +0 -1
package/dist/runtime.js
CHANGED
|
@@ -21071,6 +21071,7 @@ function decodeMessageKind(encoded) {
|
|
|
21071
21071
|
}
|
|
21072
21072
|
function decodeSessionPromptCommand(encoded) {
|
|
21073
21073
|
const value = parseJson2(encoded);
|
|
21074
|
+
const hasSessionConfigurations = Object.hasOwn(value, "sessionConfigurations");
|
|
21074
21075
|
assertExactKeys(value, [
|
|
21075
21076
|
"additionalDirectoryIds",
|
|
21076
21077
|
"agentId",
|
|
@@ -21082,6 +21083,7 @@ function decodeSessionPromptCommand(encoded) {
|
|
|
21082
21083
|
"kind",
|
|
21083
21084
|
"prompt",
|
|
21084
21085
|
"resources",
|
|
21086
|
+
...hasSessionConfigurations ? ["sessionConfigurations"] : [],
|
|
21085
21087
|
"sessionId",
|
|
21086
21088
|
"targetCommandId"
|
|
21087
21089
|
]);
|
|
@@ -21102,6 +21104,10 @@ function decodeSessionPromptCommand(encoded) {
|
|
|
21102
21104
|
if (disposition === SessionPromptDisposition.Reject && targetCommandId.length > 0 || disposition !== SessionPromptDisposition.Reject && !IDENTIFIER_PATTERN2.test(targetCommandId)) {
|
|
21103
21105
|
throw new ProtocolMessageError("Prompt disposition has an invalid target command");
|
|
21104
21106
|
}
|
|
21107
|
+
const sessionConfigurations = hasSessionConfigurations ? decodeSessionConfigurationSelections(value["sessionConfigurations"]) : [];
|
|
21108
|
+
if (new Set(sessionConfigurations.map((selection) => selection.configId)).size !== sessionConfigurations.length) {
|
|
21109
|
+
throw new ProtocolMessageError("Session configuration identifiers must be unique");
|
|
21110
|
+
}
|
|
21105
21111
|
return {
|
|
21106
21112
|
additionalDirectoryIds: readDirectoryIdentifiers(value, "additionalDirectoryIds", 16),
|
|
21107
21113
|
agentId: readIdentifier(value, "agentId"),
|
|
@@ -21113,6 +21119,7 @@ function decodeSessionPromptCommand(encoded) {
|
|
|
21113
21119
|
kind: SESSION_PROMPT_KIND,
|
|
21114
21120
|
prompt,
|
|
21115
21121
|
resources,
|
|
21122
|
+
...hasSessionConfigurations ? { sessionConfigurations } : {},
|
|
21116
21123
|
sessionId: readIdentifier(value, "sessionId"),
|
|
21117
21124
|
targetCommandId
|
|
21118
21125
|
};
|
|
@@ -21289,9 +21296,6 @@ function encodeSessionFailedEvent(message) {
|
|
|
21289
21296
|
}
|
|
21290
21297
|
|
|
21291
21298
|
// ../protocol/src/bot.ts
|
|
21292
|
-
var BOT_BINDING_APPROVAL_REQUEST_KIND = "bot.binding.approval.request";
|
|
21293
|
-
var BOT_BINDING_APPROVED_KIND = "bot.binding.approved";
|
|
21294
|
-
var BOT_BINDING_UNAVAILABLE_KIND = "bot.binding.unavailable";
|
|
21295
21299
|
var BOT_SESSION_PROMPT_KIND = "bot.session.prompt";
|
|
21296
21300
|
var IDENTIFIER_PATTERN3 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
21297
21301
|
var DIRECTORY_IDENTIFIER_PATTERN3 = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/;
|
|
@@ -21306,21 +21310,6 @@ var BotDeliveryTargetReference = class {
|
|
|
21306
21310
|
this.deliveryTargetId = deliveryTargetId;
|
|
21307
21311
|
}
|
|
21308
21312
|
};
|
|
21309
|
-
var BotCompletionDeliveryPolicy = class {
|
|
21310
|
-
};
|
|
21311
|
-
var NoBotCompletionDeliveryPolicy = class extends BotCompletionDeliveryPolicy {
|
|
21312
|
-
kind = "none";
|
|
21313
|
-
};
|
|
21314
|
-
var RequiredBotCompletionDeliveryPolicy = class extends BotCompletionDeliveryPolicy {
|
|
21315
|
-
deliveryTargetId;
|
|
21316
|
-
kind = "required";
|
|
21317
|
-
messageTemplate;
|
|
21318
|
-
constructor(deliveryTargetId, messageTemplate) {
|
|
21319
|
-
super();
|
|
21320
|
-
this.deliveryTargetId = deliveryTargetId;
|
|
21321
|
-
this.messageTemplate = messageTemplate;
|
|
21322
|
-
}
|
|
21323
|
-
};
|
|
21324
21313
|
var BotReplyRoute = class {
|
|
21325
21314
|
};
|
|
21326
21315
|
var OwnerBotReplyRoute = class extends BotReplyRoute {
|
|
@@ -21336,94 +21325,6 @@ var BotConnectionReplyRoute = class extends BotReplyRoute {
|
|
|
21336
21325
|
this.deliveryTargetId = deliveryTargetId;
|
|
21337
21326
|
}
|
|
21338
21327
|
};
|
|
21339
|
-
var BotExecutionBindingApprovalRequest = class {
|
|
21340
|
-
agentConfigRevision;
|
|
21341
|
-
agentRef;
|
|
21342
|
-
allowedDeliveryTargets;
|
|
21343
|
-
behaviorDigest;
|
|
21344
|
-
behaviorInstructions;
|
|
21345
|
-
behaviorRevisionId;
|
|
21346
|
-
bindingId;
|
|
21347
|
-
bindingRevision;
|
|
21348
|
-
botId;
|
|
21349
|
-
completionPolicy;
|
|
21350
|
-
executionConfiguration;
|
|
21351
|
-
kind = BOT_BINDING_APPROVAL_REQUEST_KIND;
|
|
21352
|
-
requestId;
|
|
21353
|
-
requiredCapabilities;
|
|
21354
|
-
runtimeId;
|
|
21355
|
-
sessionConfigurations;
|
|
21356
|
-
workspaceRef;
|
|
21357
|
-
constructor(requestId, botId, behaviorRevisionId, bindingId, bindingRevision, runtimeId, agentRef, workspaceRef, agentConfigRevision, behaviorInstructions, behaviorDigest, requiredCapabilities, allowedDeliveryTargets, completionPolicy, executionConfiguration, sessionConfigurations = []) {
|
|
21358
|
-
this.requestId = requestId;
|
|
21359
|
-
this.botId = botId;
|
|
21360
|
-
this.behaviorRevisionId = behaviorRevisionId;
|
|
21361
|
-
this.bindingId = bindingId;
|
|
21362
|
-
this.bindingRevision = bindingRevision;
|
|
21363
|
-
this.runtimeId = runtimeId;
|
|
21364
|
-
this.agentRef = agentRef;
|
|
21365
|
-
this.workspaceRef = workspaceRef;
|
|
21366
|
-
this.agentConfigRevision = agentConfigRevision;
|
|
21367
|
-
this.behaviorInstructions = behaviorInstructions;
|
|
21368
|
-
this.behaviorDigest = behaviorDigest;
|
|
21369
|
-
this.requiredCapabilities = Object.freeze([...requiredCapabilities]);
|
|
21370
|
-
this.sessionConfigurations = Object.freeze([...sessionConfigurations]);
|
|
21371
|
-
this.allowedDeliveryTargets = Object.freeze(
|
|
21372
|
-
allowedDeliveryTargets.map(
|
|
21373
|
-
(target) => new BotDeliveryTargetReference(target.alias, target.deliveryTargetId)
|
|
21374
|
-
)
|
|
21375
|
-
);
|
|
21376
|
-
this.completionPolicy = completionPolicy;
|
|
21377
|
-
this.executionConfiguration = decodeAgentExecutionConfiguration(executionConfiguration);
|
|
21378
|
-
}
|
|
21379
|
-
toJSON() {
|
|
21380
|
-
const { sessionConfigurations, ...request } = this;
|
|
21381
|
-
return {
|
|
21382
|
-
...request,
|
|
21383
|
-
...sessionConfigurations.length === 0 ? {} : { sessionConfigurations }
|
|
21384
|
-
};
|
|
21385
|
-
}
|
|
21386
|
-
};
|
|
21387
|
-
var BotExecutionBindingApprovedEvent = class {
|
|
21388
|
-
agentIdentityDigest;
|
|
21389
|
-
behaviorRevisionId;
|
|
21390
|
-
bindingId;
|
|
21391
|
-
bindingRevision;
|
|
21392
|
-
botId;
|
|
21393
|
-
kind = BOT_BINDING_APPROVED_KIND;
|
|
21394
|
-
localGrantId;
|
|
21395
|
-
requestId;
|
|
21396
|
-
workspaceIdentityDigest;
|
|
21397
|
-
constructor(requestId, botId, behaviorRevisionId, bindingId, bindingRevision, localGrantId, agentIdentityDigest, workspaceIdentityDigest) {
|
|
21398
|
-
this.requestId = requestId;
|
|
21399
|
-
this.botId = botId;
|
|
21400
|
-
this.behaviorRevisionId = behaviorRevisionId;
|
|
21401
|
-
this.bindingId = bindingId;
|
|
21402
|
-
this.bindingRevision = bindingRevision;
|
|
21403
|
-
this.localGrantId = localGrantId;
|
|
21404
|
-
this.agentIdentityDigest = agentIdentityDigest;
|
|
21405
|
-
this.workspaceIdentityDigest = workspaceIdentityDigest;
|
|
21406
|
-
}
|
|
21407
|
-
};
|
|
21408
|
-
var BotExecutionBindingUnavailableEvent = class {
|
|
21409
|
-
behaviorRevisionId;
|
|
21410
|
-
bindingId;
|
|
21411
|
-
bindingRevision;
|
|
21412
|
-
botId;
|
|
21413
|
-
code;
|
|
21414
|
-
kind = BOT_BINDING_UNAVAILABLE_KIND;
|
|
21415
|
-
message;
|
|
21416
|
-
requestId;
|
|
21417
|
-
constructor(requestId, botId, behaviorRevisionId, bindingId, bindingRevision, code, message) {
|
|
21418
|
-
this.requestId = requestId;
|
|
21419
|
-
this.botId = botId;
|
|
21420
|
-
this.behaviorRevisionId = behaviorRevisionId;
|
|
21421
|
-
this.bindingId = bindingId;
|
|
21422
|
-
this.bindingRevision = bindingRevision;
|
|
21423
|
-
this.code = code;
|
|
21424
|
-
this.message = message;
|
|
21425
|
-
}
|
|
21426
|
-
};
|
|
21427
21328
|
var BotSessionPromptCommand = class {
|
|
21428
21329
|
additionalDirectoryIds;
|
|
21429
21330
|
agentId;
|
|
@@ -21445,7 +21346,6 @@ var BotSessionPromptCommand = class {
|
|
|
21445
21346
|
executionConfiguration;
|
|
21446
21347
|
images;
|
|
21447
21348
|
kind = BOT_SESSION_PROMPT_KIND;
|
|
21448
|
-
localGrantId;
|
|
21449
21349
|
prompt;
|
|
21450
21350
|
replyRoute;
|
|
21451
21351
|
resources;
|
|
@@ -21453,7 +21353,7 @@ var BotSessionPromptCommand = class {
|
|
|
21453
21353
|
sessionId;
|
|
21454
21354
|
targetCommandId;
|
|
21455
21355
|
turnId;
|
|
21456
|
-
constructor(sessionId, commandId, agentId, bindingId, directoryId2, additionalDirectoryIds, images, resources, prompt, executionId, executionCapabilityId, executionCapabilitySecret, executionDeadlineAt, botId, conversationId, turnId, behaviorRevisionId, bindingRevision,
|
|
21356
|
+
constructor(sessionId, commandId, agentId, bindingId, directoryId2, additionalDirectoryIds, images, resources, prompt, executionId, executionCapabilityId, executionCapabilitySecret, executionDeadlineAt, botId, conversationId, turnId, behaviorRevisionId, bindingRevision, behaviorInstructions, behaviorDigest, allowedDeliveryTargets, replyRoute, executionConfiguration, sessionConfigurations = [], disposition = SessionPromptDisposition.Reject, targetCommandId = "") {
|
|
21457
21357
|
this.sessionId = sessionId;
|
|
21458
21358
|
this.commandId = commandId;
|
|
21459
21359
|
this.agentId = agentId;
|
|
@@ -21473,7 +21373,6 @@ var BotSessionPromptCommand = class {
|
|
|
21473
21373
|
this.turnId = turnId;
|
|
21474
21374
|
this.behaviorRevisionId = behaviorRevisionId;
|
|
21475
21375
|
this.bindingRevision = bindingRevision;
|
|
21476
|
-
this.localGrantId = localGrantId;
|
|
21477
21376
|
this.behaviorInstructions = behaviorInstructions;
|
|
21478
21377
|
this.behaviorDigest = behaviorDigest;
|
|
21479
21378
|
this.allowedDeliveryTargets = Object.freeze(
|
|
@@ -21617,24 +21516,6 @@ function readSessionConfigurations(value) {
|
|
|
21617
21516
|
}
|
|
21618
21517
|
return decodeSessionConfigurationSelections(value["sessionConfigurations"]);
|
|
21619
21518
|
}
|
|
21620
|
-
function readCompletionPolicy(value) {
|
|
21621
|
-
if (!isRecord3(value)) {
|
|
21622
|
-
throw new ProtocolMessageError("Invalid Bot completion policy");
|
|
21623
|
-
}
|
|
21624
|
-
const kind = readText2(value, "kind", 32, false);
|
|
21625
|
-
if (kind === "none") {
|
|
21626
|
-
assertExactKeys2(value, ["kind"]);
|
|
21627
|
-
return new NoBotCompletionDeliveryPolicy();
|
|
21628
|
-
}
|
|
21629
|
-
if (kind === "required") {
|
|
21630
|
-
assertExactKeys2(value, ["deliveryTargetId", "kind", "messageTemplate"]);
|
|
21631
|
-
return new RequiredBotCompletionDeliveryPolicy(
|
|
21632
|
-
readIdentifier2(value, "deliveryTargetId"),
|
|
21633
|
-
readText2(value, "messageTemplate", 1e4, false)
|
|
21634
|
-
);
|
|
21635
|
-
}
|
|
21636
|
-
throw new ProtocolMessageError("Invalid Bot completion policy");
|
|
21637
|
-
}
|
|
21638
21519
|
function readReplyRoute(value) {
|
|
21639
21520
|
if (!isRecord3(value)) {
|
|
21640
21521
|
throw new ProtocolMessageError("Invalid Bot reply route");
|
|
@@ -21653,110 +21534,6 @@ function readReplyRoute(value) {
|
|
|
21653
21534
|
}
|
|
21654
21535
|
throw new ProtocolMessageError("Invalid Bot reply route");
|
|
21655
21536
|
}
|
|
21656
|
-
function decodeBotExecutionBindingApprovalRequest(encoded) {
|
|
21657
|
-
const value = parseJson3(encoded);
|
|
21658
|
-
assertKeysWithOptional(
|
|
21659
|
-
value,
|
|
21660
|
-
[
|
|
21661
|
-
"agentConfigRevision",
|
|
21662
|
-
"agentRef",
|
|
21663
|
-
"allowedDeliveryTargets",
|
|
21664
|
-
"behaviorDigest",
|
|
21665
|
-
"behaviorInstructions",
|
|
21666
|
-
"behaviorRevisionId",
|
|
21667
|
-
"bindingId",
|
|
21668
|
-
"bindingRevision",
|
|
21669
|
-
"botId",
|
|
21670
|
-
"completionPolicy",
|
|
21671
|
-
"executionConfiguration",
|
|
21672
|
-
"kind",
|
|
21673
|
-
"requestId",
|
|
21674
|
-
"requiredCapabilities",
|
|
21675
|
-
"runtimeId",
|
|
21676
|
-
"workspaceRef"
|
|
21677
|
-
],
|
|
21678
|
-
["sessionConfigurations"]
|
|
21679
|
-
);
|
|
21680
|
-
if (value["kind"] !== BOT_BINDING_APPROVAL_REQUEST_KIND) {
|
|
21681
|
-
throw new ProtocolMessageError("Invalid Bot binding approval request kind");
|
|
21682
|
-
}
|
|
21683
|
-
return new BotExecutionBindingApprovalRequest(
|
|
21684
|
-
readIdentifier2(value, "requestId"),
|
|
21685
|
-
readIdentifier2(value, "botId"),
|
|
21686
|
-
readIdentifier2(value, "behaviorRevisionId"),
|
|
21687
|
-
readIdentifier2(value, "bindingId"),
|
|
21688
|
-
readInteger(value, "bindingRevision"),
|
|
21689
|
-
readIdentifier2(value, "runtimeId"),
|
|
21690
|
-
readIdentifier2(value, "agentRef"),
|
|
21691
|
-
readDirectoryIdentifier2(value, "workspaceRef"),
|
|
21692
|
-
readInteger(value, "agentConfigRevision"),
|
|
21693
|
-
readText2(value, "behaviorInstructions", MAX_INSTRUCTIONS_LENGTH, true),
|
|
21694
|
-
readDigest(value, "behaviorDigest"),
|
|
21695
|
-
readIdentifiers(value, "requiredCapabilities", 32),
|
|
21696
|
-
readTargets(value, "allowedDeliveryTargets"),
|
|
21697
|
-
readCompletionPolicy(value["completionPolicy"]),
|
|
21698
|
-
decodeAgentExecutionConfiguration(value["executionConfiguration"]),
|
|
21699
|
-
readSessionConfigurations(value)
|
|
21700
|
-
);
|
|
21701
|
-
}
|
|
21702
|
-
function decodeBotExecutionBindingApprovedEvent(encoded) {
|
|
21703
|
-
const value = parseJson3(encoded);
|
|
21704
|
-
assertExactKeys2(value, [
|
|
21705
|
-
"agentIdentityDigest",
|
|
21706
|
-
"behaviorRevisionId",
|
|
21707
|
-
"bindingId",
|
|
21708
|
-
"bindingRevision",
|
|
21709
|
-
"botId",
|
|
21710
|
-
"kind",
|
|
21711
|
-
"localGrantId",
|
|
21712
|
-
"requestId",
|
|
21713
|
-
"workspaceIdentityDigest"
|
|
21714
|
-
]);
|
|
21715
|
-
if (value["kind"] !== BOT_BINDING_APPROVED_KIND) {
|
|
21716
|
-
throw new ProtocolMessageError("Invalid Bot binding approval event kind");
|
|
21717
|
-
}
|
|
21718
|
-
return new BotExecutionBindingApprovedEvent(
|
|
21719
|
-
readIdentifier2(value, "requestId"),
|
|
21720
|
-
readIdentifier2(value, "botId"),
|
|
21721
|
-
readIdentifier2(value, "behaviorRevisionId"),
|
|
21722
|
-
readIdentifier2(value, "bindingId"),
|
|
21723
|
-
readInteger(value, "bindingRevision"),
|
|
21724
|
-
readIdentifier2(value, "localGrantId"),
|
|
21725
|
-
readDigest(value, "agentIdentityDigest"),
|
|
21726
|
-
readDigest(value, "workspaceIdentityDigest")
|
|
21727
|
-
);
|
|
21728
|
-
}
|
|
21729
|
-
function encodeBotExecutionBindingApprovedEvent(event) {
|
|
21730
|
-
return JSON.stringify(decodeBotExecutionBindingApprovedEvent(JSON.stringify(event)));
|
|
21731
|
-
}
|
|
21732
|
-
function decodeBotExecutionBindingUnavailableEvent(encoded) {
|
|
21733
|
-
const value = parseJson3(encoded);
|
|
21734
|
-
assertExactKeys2(value, [
|
|
21735
|
-
"behaviorRevisionId",
|
|
21736
|
-
"bindingId",
|
|
21737
|
-
"bindingRevision",
|
|
21738
|
-
"botId",
|
|
21739
|
-
"code",
|
|
21740
|
-
"kind",
|
|
21741
|
-
"message",
|
|
21742
|
-
"requestId"
|
|
21743
|
-
]);
|
|
21744
|
-
if (value["kind"] !== BOT_BINDING_UNAVAILABLE_KIND) {
|
|
21745
|
-
throw new ProtocolMessageError("Invalid Bot binding unavailable event kind");
|
|
21746
|
-
}
|
|
21747
|
-
return new BotExecutionBindingUnavailableEvent(
|
|
21748
|
-
readIdentifier2(value, "requestId"),
|
|
21749
|
-
readIdentifier2(value, "botId"),
|
|
21750
|
-
readIdentifier2(value, "behaviorRevisionId"),
|
|
21751
|
-
readIdentifier2(value, "bindingId"),
|
|
21752
|
-
readInteger(value, "bindingRevision"),
|
|
21753
|
-
readIdentifier2(value, "code"),
|
|
21754
|
-
readText2(value, "message", 500, false)
|
|
21755
|
-
);
|
|
21756
|
-
}
|
|
21757
|
-
function encodeBotExecutionBindingUnavailableEvent(event) {
|
|
21758
|
-
return JSON.stringify(decodeBotExecutionBindingUnavailableEvent(JSON.stringify(event)));
|
|
21759
|
-
}
|
|
21760
21537
|
function decodeBotSessionPromptCommand(encoded) {
|
|
21761
21538
|
const value = parseJson3(encoded);
|
|
21762
21539
|
assertKeysWithOptional(
|
|
@@ -21781,7 +21558,6 @@ function decodeBotSessionPromptCommand(encoded) {
|
|
|
21781
21558
|
"executionConfiguration",
|
|
21782
21559
|
"images",
|
|
21783
21560
|
"kind",
|
|
21784
|
-
"localGrantId",
|
|
21785
21561
|
"prompt",
|
|
21786
21562
|
"replyRoute",
|
|
21787
21563
|
"resources",
|
|
@@ -21827,7 +21603,6 @@ function decodeBotSessionPromptCommand(encoded) {
|
|
|
21827
21603
|
readIdentifier2(value, "turnId"),
|
|
21828
21604
|
readIdentifier2(value, "behaviorRevisionId"),
|
|
21829
21605
|
readInteger(value, "bindingRevision"),
|
|
21830
|
-
readIdentifier2(value, "localGrantId"),
|
|
21831
21606
|
readText2(value, "behaviorInstructions", MAX_INSTRUCTIONS_LENGTH, true),
|
|
21832
21607
|
readDigest(value, "behaviorDigest"),
|
|
21833
21608
|
readTargets(value, "allowedDeliveryTargets"),
|
|
@@ -23545,7 +23320,7 @@ function isContainedPath3(root, candidate) {
|
|
|
23545
23320
|
}
|
|
23546
23321
|
async function hashFile(path2, signal) {
|
|
23547
23322
|
signal.throwIfAborted();
|
|
23548
|
-
const
|
|
23323
|
+
const digest = createHash("sha256");
|
|
23549
23324
|
const stream = createReadStream(path2, { signal });
|
|
23550
23325
|
try {
|
|
23551
23326
|
for await (const chunk of stream) {
|
|
@@ -23556,9 +23331,9 @@ async function hashFile(path2, signal) {
|
|
|
23556
23331
|
"The managed Agent archive produced invalid bytes"
|
|
23557
23332
|
);
|
|
23558
23333
|
}
|
|
23559
|
-
|
|
23334
|
+
digest.update(chunk);
|
|
23560
23335
|
}
|
|
23561
|
-
return
|
|
23336
|
+
return digest.digest("hex");
|
|
23562
23337
|
} catch (error62) {
|
|
23563
23338
|
if (signal.aborted) {
|
|
23564
23339
|
signal.throwIfAborted();
|
|
@@ -24571,7 +24346,7 @@ function createDaemonConfig(connection, agents = [], installableAgents = []) {
|
|
|
24571
24346
|
}
|
|
24572
24347
|
|
|
24573
24348
|
// src/run-daemon.ts
|
|
24574
|
-
import { randomUUID as
|
|
24349
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
24575
24350
|
import { basename as basename5, join as join16 } from "node:path";
|
|
24576
24351
|
import { styleText } from "node:util";
|
|
24577
24352
|
import { fetch as fetch6, WebSocket as WebSocket2 } from "undici";
|
|
@@ -36258,7 +36033,8 @@ async function publishAgentCatalog(config2, signal) {
|
|
|
36258
36033
|
botSessionConfiguration: true,
|
|
36259
36034
|
capabilities: agent.capabilities,
|
|
36260
36035
|
id: agent.id,
|
|
36261
|
-
label: agent.label
|
|
36036
|
+
label: agent.label,
|
|
36037
|
+
sessionTurnConfiguration: true
|
|
36262
36038
|
})),
|
|
36263
36039
|
installableAgents: catalog.installableAgents
|
|
36264
36040
|
}),
|
|
@@ -36984,13 +36760,6 @@ var UploadedRuntimeArtifact = class {
|
|
|
36984
36760
|
this.sha256 = sha256;
|
|
36985
36761
|
}
|
|
36986
36762
|
};
|
|
36987
|
-
function daemonToken(config2) {
|
|
36988
|
-
const token = config2.relayUrl.searchParams.get("token");
|
|
36989
|
-
if (token === null || token.length < 32) {
|
|
36990
|
-
throw new RuntimeArtifactUploadError("artifact_endpoint_invalid", "The Relay daemon token is missing");
|
|
36991
|
-
}
|
|
36992
|
-
return token;
|
|
36993
|
-
}
|
|
36994
36763
|
function channelOrigin(config2) {
|
|
36995
36764
|
const url2 = new URL(config2.relayUrl);
|
|
36996
36765
|
url2.protocol = url2.protocol === "wss:" ? "https:" : "http:";
|
|
@@ -37035,24 +36804,23 @@ async function readAuthorization(response) {
|
|
|
37035
36804
|
translateSdkError(cause);
|
|
37036
36805
|
}
|
|
37037
36806
|
}
|
|
37038
|
-
function sessionArtifactUrl(origin, sessionId, resourcePath
|
|
37039
|
-
|
|
37040
|
-
url2.searchParams.set("token", token);
|
|
37041
|
-
return url2;
|
|
36807
|
+
function sessionArtifactUrl(origin, sessionId, resourcePath) {
|
|
36808
|
+
return new URL(`${origin.pathname}/sessions/${encodeURIComponent(sessionId)}/${resourcePath}`, origin);
|
|
37042
36809
|
}
|
|
37043
|
-
async function postLease(url2, request, signal) {
|
|
36810
|
+
async function postLease(url2, headers, request, signal) {
|
|
37044
36811
|
return await fetch3(url2, {
|
|
37045
36812
|
dispatcher: environmentProxyDispatcher,
|
|
37046
|
-
headers: { "content-type": "application/json" },
|
|
36813
|
+
headers: { ...headers, "content-type": "application/json" },
|
|
37047
36814
|
method: "POST",
|
|
37048
36815
|
body: JSON.stringify(request),
|
|
37049
36816
|
signal
|
|
37050
36817
|
});
|
|
37051
36818
|
}
|
|
37052
|
-
async function putContent(url2, authorization, bytes, signal) {
|
|
36819
|
+
async function putContent(url2, headers, authorization, bytes, signal) {
|
|
37053
36820
|
return await fetch3(url2, {
|
|
37054
36821
|
dispatcher: environmentProxyDispatcher,
|
|
37055
36822
|
headers: {
|
|
36823
|
+
...headers,
|
|
37056
36824
|
"content-type": authorization.mediaType,
|
|
37057
36825
|
"x-mobius-upload-token": authorization.uploadToken
|
|
37058
36826
|
},
|
|
@@ -37077,11 +36845,12 @@ async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
|
|
|
37077
36845
|
const timeoutSignal = AbortSignal.timeout(UPLOAD_TIMEOUT_MILLISECONDS);
|
|
37078
36846
|
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
37079
36847
|
const origin = channelOrigin(config2);
|
|
37080
|
-
const
|
|
36848
|
+
const headers = runtimeAuthorization(config2.relayUrl);
|
|
37081
36849
|
let created;
|
|
37082
36850
|
try {
|
|
37083
36851
|
created = await postLease(
|
|
37084
|
-
sessionArtifactUrl(origin, sessionId, "artifacts/uploads"
|
|
36852
|
+
sessionArtifactUrl(origin, sessionId, "artifacts/uploads"),
|
|
36853
|
+
headers,
|
|
37085
36854
|
request,
|
|
37086
36855
|
requestSignal
|
|
37087
36856
|
);
|
|
@@ -37101,12 +36870,8 @@ async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
|
|
|
37101
36870
|
let uploaded;
|
|
37102
36871
|
try {
|
|
37103
36872
|
uploaded = await putContent(
|
|
37104
|
-
sessionArtifactUrl(
|
|
37105
|
-
|
|
37106
|
-
sessionId,
|
|
37107
|
-
`artifacts/${encodeURIComponent(authorization.artifactId)}/content`,
|
|
37108
|
-
token
|
|
37109
|
-
),
|
|
36873
|
+
sessionArtifactUrl(origin, sessionId, `artifacts/${encodeURIComponent(authorization.artifactId)}/content`),
|
|
36874
|
+
headers,
|
|
37110
36875
|
authorization,
|
|
37111
36876
|
artifact.bytes,
|
|
37112
36877
|
requestSignal
|
|
@@ -37297,10 +37062,7 @@ var WorkspaceDirectoryService = class {
|
|
|
37297
37062
|
};
|
|
37298
37063
|
};
|
|
37299
37064
|
|
|
37300
|
-
// src/bots/local-bot-
|
|
37301
|
-
import { createHash as createHash3, randomUUID } from "node:crypto";
|
|
37302
|
-
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
37303
|
-
var LOCAL_BOT_GRANT_LIFETIME_MILLISECONDS = 90 * 24 * 60 * 60 * 1e3;
|
|
37065
|
+
// src/bots/local-bot-execution-authorizer.ts
|
|
37304
37066
|
var LocalBotAuthorizationError = class extends Error {
|
|
37305
37067
|
code;
|
|
37306
37068
|
constructor(code, message, options = {}) {
|
|
@@ -37309,325 +37071,40 @@ var LocalBotAuthorizationError = class extends Error {
|
|
|
37309
37071
|
this.name = "LocalBotAuthorizationError";
|
|
37310
37072
|
}
|
|
37311
37073
|
};
|
|
37312
|
-
var
|
|
37074
|
+
var AuthorizedLocalBotExecution = class {
|
|
37313
37075
|
agent;
|
|
37314
|
-
agentIdentityDigest;
|
|
37315
|
-
allowedDeliveryTargetIds;
|
|
37316
37076
|
behaviorDigest;
|
|
37317
37077
|
behaviorRevisionId;
|
|
37318
37078
|
bindingId;
|
|
37319
37079
|
bindingRevision;
|
|
37320
37080
|
botId;
|
|
37321
|
-
expiresAt;
|
|
37322
37081
|
executionConfiguration;
|
|
37323
|
-
localGrantId;
|
|
37324
|
-
revocationEpoch;
|
|
37325
|
-
workspaceIdentityDigest;
|
|
37326
37082
|
workspacePath;
|
|
37327
37083
|
workspaceRef;
|
|
37328
|
-
constructor(
|
|
37329
|
-
this.localGrantId = localGrantId;
|
|
37330
|
-
this.botId = botId;
|
|
37331
|
-
this.behaviorRevisionId = behaviorRevisionId;
|
|
37332
|
-
this.behaviorDigest = behaviorDigest;
|
|
37333
|
-
this.bindingId = bindingId;
|
|
37334
|
-
this.bindingRevision = bindingRevision;
|
|
37084
|
+
constructor(command, agent, workspacePath) {
|
|
37335
37085
|
this.agent = agent;
|
|
37336
|
-
this.
|
|
37337
|
-
this.
|
|
37086
|
+
this.behaviorDigest = command.behaviorDigest;
|
|
37087
|
+
this.behaviorRevisionId = command.behaviorRevisionId;
|
|
37088
|
+
this.bindingId = command.bindingId;
|
|
37089
|
+
this.bindingRevision = command.bindingRevision;
|
|
37090
|
+
this.botId = command.botId;
|
|
37091
|
+
this.executionConfiguration = command.executionConfiguration;
|
|
37338
37092
|
this.workspacePath = workspacePath;
|
|
37339
|
-
this.
|
|
37340
|
-
this.allowedDeliveryTargetIds = Object.freeze([...allowedDeliveryTargetIds]);
|
|
37341
|
-
this.executionConfiguration = executionConfiguration;
|
|
37342
|
-
this.expiresAt = expiresAt;
|
|
37343
|
-
this.revocationEpoch = revocationEpoch;
|
|
37093
|
+
this.workspaceRef = command.directoryId;
|
|
37344
37094
|
}
|
|
37345
37095
|
};
|
|
37346
|
-
|
|
37347
|
-
|
|
37348
|
-
}
|
|
37349
|
-
function agentDigest(agent) {
|
|
37350
|
-
return digest(
|
|
37351
|
-
JSON.stringify({
|
|
37352
|
-
adapter: agent.adapterIdentity,
|
|
37353
|
-
agent: agent.agentIdentity,
|
|
37354
|
-
agentVersion: agent.agentVersion,
|
|
37355
|
-
arguments: agent.arguments,
|
|
37356
|
-
id: agent.id
|
|
37357
|
-
})
|
|
37358
|
-
);
|
|
37359
|
-
}
|
|
37360
|
-
function configurePermission(agent, permissionMode) {
|
|
37361
|
-
try {
|
|
37362
|
-
return agent.withPermissionMode(permissionMode);
|
|
37363
|
-
} catch (cause) {
|
|
37364
|
-
if (cause instanceof AgentPermissionConfigurationError) {
|
|
37365
|
-
throw new LocalBotAuthorizationError("binding_incompatible", cause.message, { cause });
|
|
37366
|
-
}
|
|
37367
|
-
throw cause;
|
|
37368
|
-
}
|
|
37369
|
-
}
|
|
37370
|
-
function workspaceDigest(path2) {
|
|
37371
|
-
return digest(path2);
|
|
37372
|
-
}
|
|
37373
|
-
function exactTargets(left, right) {
|
|
37374
|
-
if (left.length !== right.length) {
|
|
37375
|
-
return false;
|
|
37376
|
-
}
|
|
37377
|
-
const expected = [...left].sort();
|
|
37378
|
-
const actual = [...right].sort();
|
|
37379
|
-
return expected.every((target, index2) => target === actual[index2]);
|
|
37380
|
-
}
|
|
37381
|
-
function exactSessionConfigurations(left, right) {
|
|
37382
|
-
if (left.length !== right.length) {
|
|
37383
|
-
return false;
|
|
37384
|
-
}
|
|
37385
|
-
const expected = new Map(left.map((selection) => [selection.configId, selection]));
|
|
37386
|
-
return right.every((selection) => {
|
|
37387
|
-
const approved = expected.get(selection.configId);
|
|
37388
|
-
return approved !== void 0 && approved.booleanValue === selection.booleanValue && approved.value === selection.value && approved.valueType === selection.valueType;
|
|
37389
|
-
});
|
|
37390
|
-
}
|
|
37391
|
-
function exactExecutionConfiguration(left, right) {
|
|
37392
|
-
return left.permissionMode === right.permissionMode && exactSessionConfigurations([left.model, left.reasoningEffort], [right.model, right.reasoningEffort]);
|
|
37393
|
-
}
|
|
37394
|
-
function rowString(row, key) {
|
|
37395
|
-
const value = Reflect.get(row, key);
|
|
37396
|
-
if (typeof value !== "string") {
|
|
37397
|
-
throw new LocalBotAuthorizationError("local_grant_invalid", "The local Bot grant is invalid");
|
|
37398
|
-
}
|
|
37399
|
-
return value;
|
|
37400
|
-
}
|
|
37401
|
-
function rowInteger(row, key) {
|
|
37402
|
-
const value = Reflect.get(row, key);
|
|
37403
|
-
if (typeof value !== "number" || !Number.isSafeInteger(value)) {
|
|
37404
|
-
throw new LocalBotAuthorizationError("local_grant_invalid", "The local Bot grant is invalid");
|
|
37405
|
-
}
|
|
37406
|
-
return value;
|
|
37407
|
-
}
|
|
37408
|
-
function rowHasInteger(row, key) {
|
|
37409
|
-
const value = Reflect.get(row, key);
|
|
37410
|
-
if (value === null) {
|
|
37411
|
-
return false;
|
|
37412
|
-
}
|
|
37413
|
-
if (typeof value !== "number" || !Number.isSafeInteger(value)) {
|
|
37414
|
-
throw new LocalBotAuthorizationError("local_grant_invalid", "The local Bot grant is invalid");
|
|
37415
|
-
}
|
|
37416
|
-
return true;
|
|
37417
|
-
}
|
|
37418
|
-
function parseTargets(encoded) {
|
|
37419
|
-
let value;
|
|
37420
|
-
try {
|
|
37421
|
-
value = JSON.parse(encoded);
|
|
37422
|
-
} catch (cause) {
|
|
37423
|
-
throw new LocalBotAuthorizationError("local_grant_invalid", "The local Bot grant is invalid", { cause });
|
|
37424
|
-
}
|
|
37425
|
-
if (!Array.isArray(value) || value.some((target) => typeof target !== "string")) {
|
|
37426
|
-
throw new LocalBotAuthorizationError("local_grant_invalid", "The local Bot grant is invalid");
|
|
37427
|
-
}
|
|
37428
|
-
return value.filter((target) => typeof target === "string");
|
|
37429
|
-
}
|
|
37430
|
-
function parseSessionConfigurations(encoded) {
|
|
37431
|
-
let value;
|
|
37432
|
-
try {
|
|
37433
|
-
value = JSON.parse(encoded);
|
|
37434
|
-
return decodeSessionConfigurationSelections(value);
|
|
37435
|
-
} catch (cause) {
|
|
37436
|
-
throw new LocalBotAuthorizationError("local_grant_invalid", "The local Bot grant is invalid", { cause });
|
|
37437
|
-
}
|
|
37438
|
-
}
|
|
37439
|
-
function parseExecutionConfiguration(encoded) {
|
|
37440
|
-
let value;
|
|
37441
|
-
try {
|
|
37442
|
-
value = JSON.parse(encoded);
|
|
37443
|
-
return decodeAgentExecutionConfiguration(value);
|
|
37444
|
-
} catch (cause) {
|
|
37445
|
-
throw new LocalBotAuthorizationError("local_grant_invalid", "The local Bot grant is invalid", { cause });
|
|
37446
|
-
}
|
|
37447
|
-
}
|
|
37448
|
-
var LocalBotGrantStore = class {
|
|
37449
|
-
#database;
|
|
37450
|
-
constructor(path2) {
|
|
37451
|
-
this.#database = new DatabaseSync3(path2);
|
|
37452
|
-
this.#database.exec(`
|
|
37453
|
-
CREATE TABLE IF NOT EXISTS local_bot_grants (
|
|
37454
|
-
local_grant_id TEXT PRIMARY KEY,
|
|
37455
|
-
bot_id TEXT NOT NULL,
|
|
37456
|
-
behavior_revision_id TEXT NOT NULL,
|
|
37457
|
-
behavior_digest TEXT NOT NULL,
|
|
37458
|
-
binding_id TEXT NOT NULL UNIQUE,
|
|
37459
|
-
binding_revision INTEGER NOT NULL,
|
|
37460
|
-
agent_ref TEXT NOT NULL,
|
|
37461
|
-
agent_identity_digest TEXT NOT NULL,
|
|
37462
|
-
workspace_ref TEXT NOT NULL,
|
|
37463
|
-
workspace_path TEXT NOT NULL,
|
|
37464
|
-
workspace_identity_digest TEXT NOT NULL,
|
|
37465
|
-
allowed_delivery_target_ids_json TEXT NOT NULL,
|
|
37466
|
-
unattended_policy_json TEXT NOT NULL,
|
|
37467
|
-
created_at INTEGER NOT NULL,
|
|
37468
|
-
expires_at INTEGER NOT NULL,
|
|
37469
|
-
revocation_epoch INTEGER NOT NULL DEFAULT 0,
|
|
37470
|
-
revoked_at INTEGER
|
|
37471
|
-
) STRICT;
|
|
37472
|
-
CREATE TABLE IF NOT EXISTS local_bot_binding_resolutions (
|
|
37473
|
-
request_id TEXT PRIMARY KEY,
|
|
37474
|
-
binding_id TEXT NOT NULL,
|
|
37475
|
-
local_grant_id TEXT NOT NULL,
|
|
37476
|
-
resolved_at INTEGER NOT NULL,
|
|
37477
|
-
result TEXT NOT NULL CHECK (result IN ('approved', 'unavailable')),
|
|
37478
|
-
error_code TEXT,
|
|
37479
|
-
error_message TEXT
|
|
37480
|
-
) STRICT;
|
|
37481
|
-
CREATE TABLE IF NOT EXISTS local_bot_grant_configurations (
|
|
37482
|
-
local_grant_id TEXT PRIMARY KEY,
|
|
37483
|
-
session_configurations_json TEXT NOT NULL
|
|
37484
|
-
) STRICT;
|
|
37485
|
-
CREATE TABLE IF NOT EXISTS local_bot_grant_execution_configurations (
|
|
37486
|
-
local_grant_id TEXT PRIMARY KEY,
|
|
37487
|
-
execution_configuration_json TEXT NOT NULL
|
|
37488
|
-
) STRICT;
|
|
37489
|
-
`);
|
|
37490
|
-
}
|
|
37491
|
-
approve = async (request, catalog, directories, bindingAuthorityId, now, signal) => {
|
|
37096
|
+
var LocalBotExecutionAuthorizer = class {
|
|
37097
|
+
authorize = async (command, catalog, directories, bindingAuthorityId, signal) => {
|
|
37492
37098
|
signal.throwIfAborted();
|
|
37493
|
-
|
|
37494
|
-
`SELECT grants.* FROM local_bot_binding_resolutions AS resolutions
|
|
37495
|
-
INNER JOIN local_bot_grants AS grants
|
|
37496
|
-
ON grants.local_grant_id = resolutions.local_grant_id
|
|
37497
|
-
WHERE resolutions.request_id = ? AND resolutions.binding_id = ?
|
|
37498
|
-
AND resolutions.result = 'approved'`
|
|
37499
|
-
).get(request.requestId, request.bindingId);
|
|
37500
|
-
if (existing !== void 0) {
|
|
37501
|
-
return new BotExecutionBindingApprovedEvent(
|
|
37502
|
-
request.requestId,
|
|
37503
|
-
request.botId,
|
|
37504
|
-
request.behaviorRevisionId,
|
|
37505
|
-
request.bindingId,
|
|
37506
|
-
request.bindingRevision,
|
|
37507
|
-
rowString(existing, "local_grant_id"),
|
|
37508
|
-
rowString(existing, "agent_identity_digest"),
|
|
37509
|
-
rowString(existing, "workspace_identity_digest")
|
|
37510
|
-
);
|
|
37511
|
-
}
|
|
37512
|
-
const resolved = await this.resolveProposal(request, catalog, directories, bindingAuthorityId, signal);
|
|
37513
|
-
const localGrantId = `lbg_${randomUUID()}`;
|
|
37514
|
-
const expiresAt = now + LOCAL_BOT_GRANT_LIFETIME_MILLISECONDS;
|
|
37515
|
-
this.#database.exec("BEGIN IMMEDIATE");
|
|
37099
|
+
let agent;
|
|
37516
37100
|
try {
|
|
37517
|
-
|
|
37518
|
-
`INSERT INTO local_bot_grants (
|
|
37519
|
-
local_grant_id, bot_id, behavior_revision_id, behavior_digest,
|
|
37520
|
-
binding_id, binding_revision, agent_ref,
|
|
37521
|
-
agent_identity_digest, workspace_ref, workspace_path,
|
|
37522
|
-
workspace_identity_digest, allowed_delivery_target_ids_json,
|
|
37523
|
-
unattended_policy_json, created_at, expires_at
|
|
37524
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
37525
|
-
).run(
|
|
37526
|
-
localGrantId,
|
|
37527
|
-
request.botId,
|
|
37528
|
-
request.behaviorRevisionId,
|
|
37529
|
-
request.behaviorDigest,
|
|
37530
|
-
request.bindingId,
|
|
37531
|
-
request.bindingRevision,
|
|
37532
|
-
request.agentRef,
|
|
37533
|
-
resolved.agentIdentityDigest,
|
|
37534
|
-
request.workspaceRef,
|
|
37535
|
-
resolved.workspacePath,
|
|
37536
|
-
resolved.workspaceIdentityDigest,
|
|
37537
|
-
JSON.stringify(request.allowedDeliveryTargets.map((target) => target.deliveryTargetId)),
|
|
37538
|
-
JSON.stringify({ localSideEffects: "owner-approval-required" }),
|
|
37539
|
-
now,
|
|
37540
|
-
expiresAt
|
|
37541
|
-
);
|
|
37542
|
-
this.#database.prepare(
|
|
37543
|
-
`INSERT INTO local_bot_grant_configurations (
|
|
37544
|
-
local_grant_id, session_configurations_json
|
|
37545
|
-
) VALUES (?, ?)`
|
|
37546
|
-
).run(localGrantId, JSON.stringify(request.sessionConfigurations));
|
|
37547
|
-
this.#database.prepare(
|
|
37548
|
-
`INSERT INTO local_bot_grant_execution_configurations (
|
|
37549
|
-
local_grant_id, execution_configuration_json
|
|
37550
|
-
) VALUES (?, ?)`
|
|
37551
|
-
).run(localGrantId, JSON.stringify(request.executionConfiguration));
|
|
37552
|
-
this.#database.prepare(
|
|
37553
|
-
`INSERT INTO local_bot_binding_resolutions (
|
|
37554
|
-
request_id, binding_id, local_grant_id, resolved_at, result
|
|
37555
|
-
) VALUES (?, ?, ?, ?, 'approved')`
|
|
37556
|
-
).run(request.requestId, request.bindingId, localGrantId, now);
|
|
37557
|
-
this.#database.exec("COMMIT");
|
|
37101
|
+
agent = catalog.find(command.agentId).withPermissionMode(command.executionConfiguration.permissionMode);
|
|
37558
37102
|
} catch (cause) {
|
|
37559
|
-
|
|
37103
|
+
if (cause instanceof AgentPermissionConfigurationError) {
|
|
37104
|
+
throw new LocalBotAuthorizationError("binding_incompatible", cause.message, { cause });
|
|
37105
|
+
}
|
|
37560
37106
|
throw cause;
|
|
37561
37107
|
}
|
|
37562
|
-
signal.throwIfAborted();
|
|
37563
|
-
return new BotExecutionBindingApprovedEvent(
|
|
37564
|
-
request.requestId,
|
|
37565
|
-
request.botId,
|
|
37566
|
-
request.behaviorRevisionId,
|
|
37567
|
-
request.bindingId,
|
|
37568
|
-
request.bindingRevision,
|
|
37569
|
-
localGrantId,
|
|
37570
|
-
resolved.agentIdentityDigest,
|
|
37571
|
-
resolved.workspaceIdentityDigest
|
|
37572
|
-
);
|
|
37573
|
-
};
|
|
37574
|
-
resolveExecution = async (command, catalog, directories, bindingAuthorityId, now, signal) => {
|
|
37575
|
-
signal.throwIfAborted();
|
|
37576
|
-
const row = this.#database.prepare(
|
|
37577
|
-
`SELECT grants.*, COALESCE(configurations.session_configurations_json, '[]')
|
|
37578
|
-
AS session_configurations_json,
|
|
37579
|
-
COALESCE(execution.execution_configuration_json, ?)
|
|
37580
|
-
AS execution_configuration_json
|
|
37581
|
-
FROM local_bot_grants AS grants
|
|
37582
|
-
LEFT JOIN local_bot_grant_configurations AS configurations
|
|
37583
|
-
ON configurations.local_grant_id = grants.local_grant_id
|
|
37584
|
-
LEFT JOIN local_bot_grant_execution_configurations AS execution
|
|
37585
|
-
ON execution.local_grant_id = grants.local_grant_id
|
|
37586
|
-
WHERE grants.local_grant_id = ? AND grants.bot_id = ?
|
|
37587
|
-
AND behavior_revision_id = ? AND behavior_digest = ?
|
|
37588
|
-
AND binding_id = ? AND binding_revision = ?
|
|
37589
|
-
AND agent_ref = ?`
|
|
37590
|
-
).get(
|
|
37591
|
-
JSON.stringify(DEFAULT_AGENT_EXECUTION_CONFIGURATION),
|
|
37592
|
-
command.localGrantId,
|
|
37593
|
-
command.botId,
|
|
37594
|
-
command.behaviorRevisionId,
|
|
37595
|
-
command.behaviorDigest,
|
|
37596
|
-
command.bindingId,
|
|
37597
|
-
command.bindingRevision,
|
|
37598
|
-
command.agentId
|
|
37599
|
-
);
|
|
37600
|
-
if (row === void 0) {
|
|
37601
|
-
throw new LocalBotAuthorizationError(
|
|
37602
|
-
"binding_not_approved",
|
|
37603
|
-
"The Bot execution binding is not locally approved"
|
|
37604
|
-
);
|
|
37605
|
-
}
|
|
37606
|
-
const approvedTargets = parseTargets(rowString(row, "allowed_delivery_target_ids_json"));
|
|
37607
|
-
const requestedTargets = command.allowedDeliveryTargets.map((target) => target.deliveryTargetId);
|
|
37608
|
-
if (!exactTargets(approvedTargets, requestedTargets)) {
|
|
37609
|
-
throw new LocalBotAuthorizationError(
|
|
37610
|
-
"binding_not_approved",
|
|
37611
|
-
"The Bot execution target policy differs from its binding"
|
|
37612
|
-
);
|
|
37613
|
-
}
|
|
37614
|
-
const approvedConfigurations = parseSessionConfigurations(rowString(row, "session_configurations_json"));
|
|
37615
|
-
if (!exactSessionConfigurations(approvedConfigurations, command.sessionConfigurations)) {
|
|
37616
|
-
throw new LocalBotAuthorizationError(
|
|
37617
|
-
"binding_not_approved",
|
|
37618
|
-
"The Bot Agent configuration differs from its binding"
|
|
37619
|
-
);
|
|
37620
|
-
}
|
|
37621
|
-
const approvedExecutionConfiguration = parseExecutionConfiguration(
|
|
37622
|
-
rowString(row, "execution_configuration_json")
|
|
37623
|
-
);
|
|
37624
|
-
if (!exactExecutionConfiguration(approvedExecutionConfiguration, command.executionConfiguration)) {
|
|
37625
|
-
throw new LocalBotAuthorizationError(
|
|
37626
|
-
"binding_not_approved",
|
|
37627
|
-
"The Bot execution configuration differs from its binding"
|
|
37628
|
-
);
|
|
37629
|
-
}
|
|
37630
|
-
const agent = configurePermission(catalog.find(command.agentId), command.executionConfiguration.permissionMode);
|
|
37631
37108
|
const [adapterUnchanged, agentUnchanged] = await Promise.all([
|
|
37632
37109
|
revalidateExecutable(agent.adapterIdentity),
|
|
37633
37110
|
revalidateExecutable(agent.agentIdentity)
|
|
@@ -37639,150 +37116,15 @@ var LocalBotGrantStore = class {
|
|
|
37639
37116
|
"The local Agent executable changed while the Runtime is active; restart the Runtime"
|
|
37640
37117
|
);
|
|
37641
37118
|
}
|
|
37642
|
-
const workspaceRef = rowString(row, "workspace_ref");
|
|
37643
|
-
const workspacePath = await directories.resolve(bindingAuthorityId, workspaceRef, signal);
|
|
37644
|
-
const currentAgentDigest = agentDigest(agent);
|
|
37645
|
-
const currentWorkspaceDigest = workspaceDigest(workspacePath);
|
|
37646
|
-
signal.throwIfAborted();
|
|
37647
|
-
let expiresAt = rowInteger(row, "expires_at");
|
|
37648
|
-
let revocationEpoch = rowInteger(row, "revocation_epoch");
|
|
37649
|
-
if (currentAgentDigest !== rowString(row, "agent_identity_digest") || currentWorkspaceDigest !== rowString(row, "workspace_identity_digest") || workspacePath !== rowString(row, "workspace_path") || expiresAt <= now || rowHasInteger(row, "revoked_at")) {
|
|
37650
|
-
const refreshed = this.refreshTarget(
|
|
37651
|
-
rowString(row, "local_grant_id"),
|
|
37652
|
-
currentAgentDigest,
|
|
37653
|
-
currentWorkspaceDigest,
|
|
37654
|
-
workspacePath,
|
|
37655
|
-
now
|
|
37656
|
-
);
|
|
37657
|
-
expiresAt = refreshed.expiresAt;
|
|
37658
|
-
revocationEpoch = refreshed.revocationEpoch;
|
|
37659
|
-
}
|
|
37660
37119
|
if (command.behaviorInstructions.length > 0 && !agent.capabilities.embeddedContextPrompt) {
|
|
37661
37120
|
throw new LocalBotAuthorizationError(
|
|
37662
37121
|
"binding_incompatible",
|
|
37663
|
-
"The local Agent cannot apply the
|
|
37122
|
+
"The local Agent cannot apply the Bot behavior"
|
|
37664
37123
|
);
|
|
37665
37124
|
}
|
|
37666
|
-
|
|
37667
|
-
rowString(row, "local_grant_id"),
|
|
37668
|
-
command.botId,
|
|
37669
|
-
command.behaviorRevisionId,
|
|
37670
|
-
command.behaviorDigest,
|
|
37671
|
-
command.bindingId,
|
|
37672
|
-
command.bindingRevision,
|
|
37673
|
-
agent,
|
|
37674
|
-
currentAgentDigest,
|
|
37675
|
-
workspaceRef,
|
|
37676
|
-
workspacePath,
|
|
37677
|
-
currentWorkspaceDigest,
|
|
37678
|
-
approvedTargets,
|
|
37679
|
-
approvedExecutionConfiguration,
|
|
37680
|
-
expiresAt,
|
|
37681
|
-
revocationEpoch
|
|
37682
|
-
);
|
|
37683
|
-
};
|
|
37684
|
-
recordUnavailable = (request, code, message, now) => {
|
|
37685
|
-
this.#database.prepare(
|
|
37686
|
-
`INSERT OR IGNORE INTO local_bot_binding_resolutions (
|
|
37687
|
-
request_id, binding_id, local_grant_id, resolved_at,
|
|
37688
|
-
result, error_code, error_message
|
|
37689
|
-
) VALUES (?, ?, '', ?, 'unavailable', ?, ?)`
|
|
37690
|
-
).run(request.requestId, request.bindingId, now, code, message);
|
|
37691
|
-
};
|
|
37692
|
-
close = () => {
|
|
37693
|
-
this.#database.close();
|
|
37694
|
-
};
|
|
37695
|
-
resolveProposal = async (request, catalog, directories, bindingAuthorityId, signal) => {
|
|
37696
|
-
const agent = configurePermission(
|
|
37697
|
-
catalog.find(request.agentRef),
|
|
37698
|
-
request.executionConfiguration.permissionMode
|
|
37699
|
-
);
|
|
37700
|
-
if (request.requiredCapabilities.includes("embedded-context") && !agent.capabilities.embeddedContextPrompt) {
|
|
37701
|
-
throw new LocalBotAuthorizationError(
|
|
37702
|
-
"binding_incompatible",
|
|
37703
|
-
"The local Agent cannot apply embedded Bot context"
|
|
37704
|
-
);
|
|
37705
|
-
}
|
|
37706
|
-
if (request.requiredCapabilities.some((capability) => capability !== "embedded-context")) {
|
|
37707
|
-
throw new LocalBotAuthorizationError(
|
|
37708
|
-
"binding_incompatible",
|
|
37709
|
-
"The Bot requires an unsupported local Agent capability"
|
|
37710
|
-
);
|
|
37711
|
-
}
|
|
37712
|
-
const [adapterUnchanged, agentUnchanged] = await Promise.all([
|
|
37713
|
-
revalidateExecutable(agent.adapterIdentity),
|
|
37714
|
-
revalidateExecutable(agent.agentIdentity)
|
|
37715
|
-
]);
|
|
37125
|
+
const workspacePath = await directories.resolve(bindingAuthorityId, command.directoryId, signal);
|
|
37716
37126
|
signal.throwIfAborted();
|
|
37717
|
-
|
|
37718
|
-
throw new LocalBotAuthorizationError(
|
|
37719
|
-
"binding_incompatible",
|
|
37720
|
-
"The local Agent executable changed before approval"
|
|
37721
|
-
);
|
|
37722
|
-
}
|
|
37723
|
-
const workspacePath = await directories.resolve(bindingAuthorityId, request.workspaceRef, signal);
|
|
37724
|
-
return {
|
|
37725
|
-
agent,
|
|
37726
|
-
agentIdentityDigest: agentDigest(agent),
|
|
37727
|
-
workspaceIdentityDigest: workspaceDigest(workspacePath),
|
|
37728
|
-
workspacePath
|
|
37729
|
-
};
|
|
37730
|
-
};
|
|
37731
|
-
refreshTarget = (localGrantId, agentIdentityDigest, workspaceIdentityDigest, workspacePath, now) => {
|
|
37732
|
-
const expiresAt = now + LOCAL_BOT_GRANT_LIFETIME_MILLISECONDS;
|
|
37733
|
-
this.#database.exec("BEGIN IMMEDIATE");
|
|
37734
|
-
try {
|
|
37735
|
-
const current = this.#database.prepare("SELECT * FROM local_bot_grants WHERE local_grant_id = ?").get(localGrantId);
|
|
37736
|
-
if (current === void 0) {
|
|
37737
|
-
throw new LocalBotAuthorizationError("local_grant_invalid", "The local Bot grant is missing");
|
|
37738
|
-
}
|
|
37739
|
-
const currentExpiresAt = rowInteger(current, "expires_at");
|
|
37740
|
-
const currentRevocationEpoch = rowInteger(current, "revocation_epoch");
|
|
37741
|
-
if (agentIdentityDigest === rowString(current, "agent_identity_digest") && workspaceIdentityDigest === rowString(current, "workspace_identity_digest") && workspacePath === rowString(current, "workspace_path") && currentExpiresAt > now && !rowHasInteger(current, "revoked_at")) {
|
|
37742
|
-
this.#database.exec("COMMIT");
|
|
37743
|
-
return { expiresAt: currentExpiresAt, revocationEpoch: currentRevocationEpoch };
|
|
37744
|
-
}
|
|
37745
|
-
const result = this.#database.prepare(
|
|
37746
|
-
`UPDATE local_bot_grants
|
|
37747
|
-
SET agent_identity_digest = ?, workspace_identity_digest = ?, workspace_path = ?,
|
|
37748
|
-
expires_at = ?, revoked_at = NULL, revocation_epoch = revocation_epoch + 1
|
|
37749
|
-
WHERE local_grant_id = ? AND revocation_epoch = ?`
|
|
37750
|
-
).run(
|
|
37751
|
-
agentIdentityDigest,
|
|
37752
|
-
workspaceIdentityDigest,
|
|
37753
|
-
workspacePath,
|
|
37754
|
-
expiresAt,
|
|
37755
|
-
localGrantId,
|
|
37756
|
-
currentRevocationEpoch
|
|
37757
|
-
);
|
|
37758
|
-
if (result.changes !== 1) {
|
|
37759
|
-
throw new LocalBotAuthorizationError(
|
|
37760
|
-
"local_grant_invalid",
|
|
37761
|
-
"The local Bot grant target could not be refreshed"
|
|
37762
|
-
);
|
|
37763
|
-
}
|
|
37764
|
-
this.#database.prepare(
|
|
37765
|
-
`INSERT INTO audit_events (recorded_at, event, command_id, session_id, details_json)
|
|
37766
|
-
VALUES (?, 'bot_binding_target_refreshed', ?, '', ?)`
|
|
37767
|
-
).run(
|
|
37768
|
-
new Date(now).toISOString(),
|
|
37769
|
-
rowString(current, "binding_id"),
|
|
37770
|
-
JSON.stringify({
|
|
37771
|
-
agentIdentityChanged: agentIdentityDigest !== rowString(current, "agent_identity_digest"),
|
|
37772
|
-
bindingId: rowString(current, "binding_id"),
|
|
37773
|
-
botId: rowString(current, "bot_id"),
|
|
37774
|
-
expired: currentExpiresAt <= now,
|
|
37775
|
-
revived: rowHasInteger(current, "revoked_at"),
|
|
37776
|
-
workspaceIdentityChanged: workspaceIdentityDigest !== rowString(current, "workspace_identity_digest"),
|
|
37777
|
-
workspacePathChanged: workspacePath !== rowString(current, "workspace_path")
|
|
37778
|
-
})
|
|
37779
|
-
);
|
|
37780
|
-
this.#database.exec("COMMIT");
|
|
37781
|
-
return { expiresAt, revocationEpoch: currentRevocationEpoch + 1 };
|
|
37782
|
-
} catch (cause) {
|
|
37783
|
-
this.#database.exec("ROLLBACK");
|
|
37784
|
-
throw cause;
|
|
37785
|
-
}
|
|
37127
|
+
return new AuthorizedLocalBotExecution(command, agent, workspacePath);
|
|
37786
37128
|
};
|
|
37787
37129
|
};
|
|
37788
37130
|
|
|
@@ -37794,18 +37136,18 @@ var AppliedBotContext = class {
|
|
|
37794
37136
|
}
|
|
37795
37137
|
};
|
|
37796
37138
|
var EmbeddedBotContextApplicator = class {
|
|
37797
|
-
apply = async (command,
|
|
37139
|
+
apply = async (command, execution, resources, signal) => {
|
|
37798
37140
|
signal.throwIfAborted();
|
|
37799
|
-
if (
|
|
37141
|
+
if (execution.botId !== command.botId || execution.behaviorRevisionId !== command.behaviorRevisionId || execution.behaviorDigest !== command.behaviorDigest) {
|
|
37800
37142
|
throw new LocalBotAuthorizationError(
|
|
37801
|
-
"
|
|
37802
|
-
"The Bot behavior does not match
|
|
37143
|
+
"binding_incompatible",
|
|
37144
|
+
"The Bot behavior does not match the execution target"
|
|
37803
37145
|
);
|
|
37804
37146
|
}
|
|
37805
37147
|
if (command.behaviorInstructions.length === 0) {
|
|
37806
37148
|
return new AppliedBotContext(resources);
|
|
37807
37149
|
}
|
|
37808
|
-
if (!
|
|
37150
|
+
if (!execution.agent.capabilities.embeddedContextPrompt) {
|
|
37809
37151
|
throw new LocalBotAuthorizationError(
|
|
37810
37152
|
"binding_incompatible",
|
|
37811
37153
|
"The local Agent cannot enforce the Bot behavior context"
|
|
@@ -37983,7 +37325,7 @@ function relayEndpoint(relayUrl, context, target) {
|
|
|
37983
37325
|
endpoint.pathname = `${MOBIUS_API_PREFIX}/v1/bot-executions/${execution}/delivery-targets/${encodeURIComponent(deliveryTargetId)}/messages`;
|
|
37984
37326
|
return endpoint;
|
|
37985
37327
|
}
|
|
37986
|
-
function
|
|
37328
|
+
function daemonToken(relayUrl) {
|
|
37987
37329
|
const token = relayUrl.searchParams.get("token") ?? "";
|
|
37988
37330
|
if (!/^[a-zA-Z0-9_-]{32,256}$/.test(token)) {
|
|
37989
37331
|
throw new LocalBotAuthorizationError("bot_service_unavailable", "The Runtime credential is unavailable");
|
|
@@ -38138,7 +37480,7 @@ var BotOutboundIpcServer = class {
|
|
|
38138
37480
|
response = await fetch4(relayEndpoint(this.#relayUrl, context, request.target), {
|
|
38139
37481
|
body: JSON.stringify({ idempotencyKey: request.idempotencyKey, text: request.text }),
|
|
38140
37482
|
headers: {
|
|
38141
|
-
authorization: `Bearer ${
|
|
37483
|
+
authorization: `Bearer ${daemonToken(this.#relayUrl)}`,
|
|
38142
37484
|
"content-type": "application/json",
|
|
38143
37485
|
"x-mobius-bot-execution-capability": context.command.executionCapabilitySecret
|
|
38144
37486
|
},
|
|
@@ -38158,7 +37500,7 @@ var BotOutboundIpcServer = class {
|
|
|
38158
37500
|
};
|
|
38159
37501
|
|
|
38160
37502
|
// src/native-sessions/service.ts
|
|
38161
|
-
import { randomUUID
|
|
37503
|
+
import { randomUUID } from "node:crypto";
|
|
38162
37504
|
import { basename as basename4 } from "node:path";
|
|
38163
37505
|
|
|
38164
37506
|
// src/native-sessions/codex-history.ts
|
|
@@ -38453,7 +37795,7 @@ var NativeSessionService = class {
|
|
|
38453
37795
|
if (authorized === null) {
|
|
38454
37796
|
return null;
|
|
38455
37797
|
}
|
|
38456
|
-
const entryId =
|
|
37798
|
+
const entryId = randomUUID();
|
|
38457
37799
|
if (this.#entries.size >= 5e3) {
|
|
38458
37800
|
this.#entries.clear();
|
|
38459
37801
|
}
|
|
@@ -38507,7 +37849,7 @@ var NativeSessionService = class {
|
|
|
38507
37849
|
"invalid_native_session_response"
|
|
38508
37850
|
);
|
|
38509
37851
|
}
|
|
38510
|
-
nextCursor =
|
|
37852
|
+
nextCursor = randomUUID();
|
|
38511
37853
|
if (this.#cursors.size >= 500) {
|
|
38512
37854
|
this.#cursors.clear();
|
|
38513
37855
|
}
|
|
@@ -38825,7 +38167,7 @@ var NativeSessionService = class {
|
|
|
38825
38167
|
};
|
|
38826
38168
|
|
|
38827
38169
|
// src/prompt-artifact-resolver.ts
|
|
38828
|
-
import { createHash as
|
|
38170
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
38829
38171
|
import { fetch as fetch5 } from "undici";
|
|
38830
38172
|
var ARTIFACT_SCHEME = "mobius-artifact:";
|
|
38831
38173
|
var ARTIFACT_DOWNLOAD_TIMEOUT_MILLISECONDS = 2e4;
|
|
@@ -38964,7 +38306,7 @@ async function download(config2, command, reference, signal) {
|
|
|
38964
38306
|
);
|
|
38965
38307
|
}
|
|
38966
38308
|
const bytes = await responseBytes(response, reference.byteLength, requestSignal);
|
|
38967
|
-
if (
|
|
38309
|
+
if (createHash3("sha256").update(bytes).digest("hex") !== reference.sha256) {
|
|
38968
38310
|
throw new PromptArtifactError(
|
|
38969
38311
|
"artifact_integrity_failed",
|
|
38970
38312
|
"The prompt artifact failed integrity validation"
|
|
@@ -39273,7 +38615,7 @@ var RelayConnectionDiagnostics = class {
|
|
|
39273
38615
|
};
|
|
39274
38616
|
|
|
39275
38617
|
// src/relay-connection/liveness.ts
|
|
39276
|
-
import { randomUUID as
|
|
38618
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
39277
38619
|
var HEARTBEAT_ACK_TIMEOUT_MILLISECONDS = 1e4;
|
|
39278
38620
|
var HEARTBEAT_INTERVAL_MILLISECONDS = 2e4;
|
|
39279
38621
|
var RelayLivenessState = class {
|
|
@@ -39362,7 +38704,7 @@ var RelayConnectionLiveness = class {
|
|
|
39362
38704
|
}
|
|
39363
38705
|
throw new Error("Heartbeat was scheduled in an invalid state");
|
|
39364
38706
|
}
|
|
39365
|
-
const heartbeatId =
|
|
38707
|
+
const heartbeatId = randomUUID2();
|
|
39366
38708
|
this.#state = new AwaitingHeartbeatAckState(
|
|
39367
38709
|
heartbeatId,
|
|
39368
38710
|
this.#timer.schedule(this.#handleTimeout, HEARTBEAT_ACK_TIMEOUT_MILLISECONDS)
|
|
@@ -39379,7 +38721,7 @@ var RelayConnectionLiveness = class {
|
|
|
39379
38721
|
// src/relay-connection/session-event-outbox.ts
|
|
39380
38722
|
import { mkdirSync as mkdirSync3 } from "node:fs";
|
|
39381
38723
|
import { dirname as dirname7 } from "node:path";
|
|
39382
|
-
import { DatabaseSync as
|
|
38724
|
+
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
39383
38725
|
var DEFAULT_OUTBOX_LIMITS = {
|
|
39384
38726
|
criticalEventBytes: 136 * 1024 * 1024,
|
|
39385
38727
|
runtimeDeliveryBytes: 64 * 1024 * 1024,
|
|
@@ -39431,7 +38773,7 @@ function rowNumber(row, field) {
|
|
|
39431
38773
|
}
|
|
39432
38774
|
return value;
|
|
39433
38775
|
}
|
|
39434
|
-
function
|
|
38776
|
+
function rowString(row, field) {
|
|
39435
38777
|
const value = typeof row === "object" && row !== null ? Reflect.get(row, field) : void 0;
|
|
39436
38778
|
if (typeof value !== "string" || value.length === 0) {
|
|
39437
38779
|
throw new Error(`SQLite returned an invalid ${field} value`);
|
|
@@ -39445,7 +38787,7 @@ var SessionEventOutbox = class {
|
|
|
39445
38787
|
validateLimits(limits);
|
|
39446
38788
|
this.#limits = limits;
|
|
39447
38789
|
mkdirSync3(dirname7(path2), { recursive: true });
|
|
39448
|
-
this.#database = new
|
|
38790
|
+
this.#database = new DatabaseSync3(path2);
|
|
39449
38791
|
this.#database.exec(`
|
|
39450
38792
|
CREATE TABLE IF NOT EXISTS relay_session_event_outbox (
|
|
39451
38793
|
ordinal INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
@@ -39680,8 +39022,8 @@ var SessionEventOutbox = class {
|
|
|
39680
39022
|
WHERE delivery_id = ?`
|
|
39681
39023
|
).get(delivery.deliveryId);
|
|
39682
39024
|
if (existing !== void 0) {
|
|
39683
|
-
const sessionId =
|
|
39684
|
-
const payload =
|
|
39025
|
+
const sessionId = rowString(existing, "session_id");
|
|
39026
|
+
const payload = rowString(existing, "payload_json");
|
|
39685
39027
|
const state = runtimeDeliveryState(existing);
|
|
39686
39028
|
if (sessionId !== delivery.sessionId || payload !== delivery.payload) {
|
|
39687
39029
|
throw new Error("The Runtime delivery identity conflicts with its durable receipt");
|
|
@@ -39769,9 +39111,9 @@ var SessionEventOutbox = class {
|
|
|
39769
39111
|
ORDER BY received_at, delivery_id`
|
|
39770
39112
|
).all().map(
|
|
39771
39113
|
(row) => new StoredRuntimeDelivery(
|
|
39772
|
-
|
|
39773
|
-
|
|
39774
|
-
|
|
39114
|
+
rowString(row, "delivery_id"),
|
|
39115
|
+
rowString(row, "session_id"),
|
|
39116
|
+
rowString(row, "payload_json"),
|
|
39775
39117
|
runtimeDeliveryState(row),
|
|
39776
39118
|
true
|
|
39777
39119
|
)
|
|
@@ -39953,7 +39295,7 @@ function validateLimits(limits) {
|
|
|
39953
39295
|
}
|
|
39954
39296
|
}
|
|
39955
39297
|
function runtimeDeliveryState(row) {
|
|
39956
|
-
const state =
|
|
39298
|
+
const state = rowString(row, "state");
|
|
39957
39299
|
if (state !== "received" && state !== "relay_committed" && state !== "processed") {
|
|
39958
39300
|
throw new Error("SQLite returned an invalid Runtime delivery state");
|
|
39959
39301
|
}
|
|
@@ -39979,9 +39321,9 @@ var ACTIVE_TURN_RECONCILIATION_TIMEOUT_MILLISECONDS = 2e4;
|
|
|
39979
39321
|
var ACTIVE_TURN_RECONCILIATION_CLOSE_CODE = 4009;
|
|
39980
39322
|
function botIpcSocketPath() {
|
|
39981
39323
|
if (process.platform === "win32") {
|
|
39982
|
-
return `\\\\.\\pipe\\mobius-bot-${
|
|
39324
|
+
return `\\\\.\\pipe\\mobius-bot-${randomUUID3()}`;
|
|
39983
39325
|
}
|
|
39984
|
-
return join16("/tmp", `mobius-bot-${
|
|
39326
|
+
return join16("/tmp", `mobius-bot-${randomUUID3()}.sock`);
|
|
39985
39327
|
}
|
|
39986
39328
|
var DaemonAcpObserver = class {
|
|
39987
39329
|
#config;
|
|
@@ -40773,6 +40115,36 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
40773
40115
|
signal
|
|
40774
40116
|
);
|
|
40775
40117
|
const agent = config2.catalog.find(command.agentId);
|
|
40118
|
+
if (command.disposition === SessionPromptDisposition.Queue && !outbox.isTerminalExecution(command.targetCommandId, command.sessionId)) {
|
|
40119
|
+
throw new AcpExecutionError(
|
|
40120
|
+
"The queued prompt target is unavailable",
|
|
40121
|
+
{},
|
|
40122
|
+
"prompt_queue_target_unavailable"
|
|
40123
|
+
);
|
|
40124
|
+
}
|
|
40125
|
+
if (command.sessionConfigurations !== void 0) {
|
|
40126
|
+
const prepared = await sessions.prepareExecutionSession({
|
|
40127
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
40128
|
+
agent,
|
|
40129
|
+
cwd: resolved.cwd,
|
|
40130
|
+
sessionId: command.sessionId,
|
|
40131
|
+
signal
|
|
40132
|
+
});
|
|
40133
|
+
if (command.disposition === SessionPromptDisposition.Steer) {
|
|
40134
|
+
assertCompleteSessionConfiguration(prepared.configOptions, command.sessionConfigurations);
|
|
40135
|
+
} else {
|
|
40136
|
+
await applyCompleteSessionConfiguration(
|
|
40137
|
+
sessions,
|
|
40138
|
+
prepared.configOptions,
|
|
40139
|
+
command.sessionConfigurations,
|
|
40140
|
+
agent,
|
|
40141
|
+
resolved.cwd,
|
|
40142
|
+
resolved.additionalDirectories,
|
|
40143
|
+
command.sessionId,
|
|
40144
|
+
signal
|
|
40145
|
+
);
|
|
40146
|
+
}
|
|
40147
|
+
}
|
|
40776
40148
|
audit.record({
|
|
40777
40149
|
commandId: command.commandId,
|
|
40778
40150
|
event: "session_authorized",
|
|
@@ -40807,13 +40179,6 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
40807
40179
|
});
|
|
40808
40180
|
stopReason = "steered";
|
|
40809
40181
|
} else {
|
|
40810
|
-
if (command.disposition === SessionPromptDisposition.Queue && !outbox.isTerminalExecution(command.targetCommandId, command.sessionId)) {
|
|
40811
|
-
throw new AcpExecutionError(
|
|
40812
|
-
"The queued prompt target is unavailable",
|
|
40813
|
-
{},
|
|
40814
|
-
"prompt_queue_target_unavailable"
|
|
40815
|
-
);
|
|
40816
|
-
}
|
|
40817
40182
|
const result = await sessions.runPrompt({
|
|
40818
40183
|
additionalDirectories: resolved.additionalDirectories,
|
|
40819
40184
|
agent,
|
|
@@ -40880,6 +40245,113 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
40880
40245
|
console.error("Mobius daemon command failed", error62);
|
|
40881
40246
|
}
|
|
40882
40247
|
}
|
|
40248
|
+
function invalidSessionConfiguration(message) {
|
|
40249
|
+
return new AcpExecutionError(message, {}, "invalid_session_configuration");
|
|
40250
|
+
}
|
|
40251
|
+
function validateSessionConfigurationSelection(option, selection) {
|
|
40252
|
+
if (option.type !== selection.valueType) {
|
|
40253
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} changed type`);
|
|
40254
|
+
}
|
|
40255
|
+
if (option.type === "boolean") {
|
|
40256
|
+
if (selection.value.length > 0) {
|
|
40257
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} has an invalid value`);
|
|
40258
|
+
}
|
|
40259
|
+
return;
|
|
40260
|
+
}
|
|
40261
|
+
if (selection.booleanValue) {
|
|
40262
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} has an invalid value`);
|
|
40263
|
+
}
|
|
40264
|
+
if (!option.values.some((value) => value.value === selection.value)) {
|
|
40265
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} has an unavailable value`);
|
|
40266
|
+
}
|
|
40267
|
+
}
|
|
40268
|
+
function assertSessionConfigurationSchema(options, selections) {
|
|
40269
|
+
if (options.length !== selections.length) {
|
|
40270
|
+
throw invalidSessionConfiguration("The Turn configuration does not match the Agent settings schema");
|
|
40271
|
+
}
|
|
40272
|
+
const selectionsById = new Map(selections.map((selection) => [selection.configId, selection]));
|
|
40273
|
+
if (selectionsById.size !== selections.length) {
|
|
40274
|
+
throw invalidSessionConfiguration("The Turn configuration contains duplicate Agent settings");
|
|
40275
|
+
}
|
|
40276
|
+
for (const option of options) {
|
|
40277
|
+
const selection = selectionsById.get(option.id);
|
|
40278
|
+
if (selection === void 0 || selection.valueType !== option.type || option.type === "boolean" && selection.value.length > 0 || option.type === "select" && selection.booleanValue) {
|
|
40279
|
+
throw invalidSessionConfiguration(`The Turn configuration does not match Agent setting ${option.id}`);
|
|
40280
|
+
}
|
|
40281
|
+
}
|
|
40282
|
+
}
|
|
40283
|
+
function sessionConfigurationMatches(option, selection) {
|
|
40284
|
+
validateSessionConfigurationSelection(option, selection);
|
|
40285
|
+
return option.type === "boolean" ? option.booleanValue === selection.booleanValue : option.currentValue === selection.value;
|
|
40286
|
+
}
|
|
40287
|
+
function sessionConfigurationPriority(selection, options) {
|
|
40288
|
+
if (selection.configId === "permission_mode") {
|
|
40289
|
+
return 0;
|
|
40290
|
+
}
|
|
40291
|
+
const option = options.find((candidate) => candidate.id === selection.configId);
|
|
40292
|
+
if (selection.configId === "model" || option?.category === "model") {
|
|
40293
|
+
return 1;
|
|
40294
|
+
}
|
|
40295
|
+
if (selection.configId === "reasoning_effort" || option?.category === "thought_level") {
|
|
40296
|
+
return 2;
|
|
40297
|
+
}
|
|
40298
|
+
if (option?.category === "model_config") {
|
|
40299
|
+
return 3;
|
|
40300
|
+
}
|
|
40301
|
+
return 4;
|
|
40302
|
+
}
|
|
40303
|
+
function assertCompleteSessionConfiguration(options, selections) {
|
|
40304
|
+
assertSessionConfigurationSchema(options, selections);
|
|
40305
|
+
const selectionsById = new Map(selections.map((selection) => [selection.configId, selection]));
|
|
40306
|
+
for (const option of options) {
|
|
40307
|
+
const selection = selectionsById.get(option.id);
|
|
40308
|
+
if (selection === void 0 || !sessionConfigurationMatches(option, selection)) {
|
|
40309
|
+
throw invalidSessionConfiguration(`The Turn configuration does not match Agent setting ${option.id}`);
|
|
40310
|
+
}
|
|
40311
|
+
}
|
|
40312
|
+
}
|
|
40313
|
+
async function applySessionConfigurationSelection(sessions, options, selection, agent, cwd, additionalDirectories, sessionId, signal) {
|
|
40314
|
+
const option = options.find((candidate) => candidate.id === selection.configId);
|
|
40315
|
+
if (option === void 0) {
|
|
40316
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} is unavailable`);
|
|
40317
|
+
}
|
|
40318
|
+
if (sessionConfigurationMatches(option, selection)) {
|
|
40319
|
+
return options;
|
|
40320
|
+
}
|
|
40321
|
+
return await sessions.configureSession({
|
|
40322
|
+
additionalDirectories,
|
|
40323
|
+
agent,
|
|
40324
|
+
booleanValue: selection.booleanValue,
|
|
40325
|
+
configId: selection.configId,
|
|
40326
|
+
cwd,
|
|
40327
|
+
requestId: `cfg_${randomUUID3()}`,
|
|
40328
|
+
sessionId,
|
|
40329
|
+
signal,
|
|
40330
|
+
value: selection.value,
|
|
40331
|
+
valueType: selection.valueType
|
|
40332
|
+
});
|
|
40333
|
+
}
|
|
40334
|
+
async function applyCompleteSessionConfiguration(sessions, initialOptions, selections, agent, cwd, additionalDirectories, sessionId, signal) {
|
|
40335
|
+
assertSessionConfigurationSchema(initialOptions, selections);
|
|
40336
|
+
let options = initialOptions;
|
|
40337
|
+
const orderedSelections = selections.toSorted((left, right) => {
|
|
40338
|
+
const priority = sessionConfigurationPriority(left, initialOptions) - sessionConfigurationPriority(right, initialOptions);
|
|
40339
|
+
return priority === 0 ? left.configId.localeCompare(right.configId) : priority;
|
|
40340
|
+
});
|
|
40341
|
+
for (const selection of orderedSelections) {
|
|
40342
|
+
options = await applySessionConfigurationSelection(
|
|
40343
|
+
sessions,
|
|
40344
|
+
options,
|
|
40345
|
+
selection,
|
|
40346
|
+
agent,
|
|
40347
|
+
cwd,
|
|
40348
|
+
additionalDirectories,
|
|
40349
|
+
sessionId,
|
|
40350
|
+
signal
|
|
40351
|
+
);
|
|
40352
|
+
}
|
|
40353
|
+
assertCompleteSessionConfiguration(options, selections);
|
|
40354
|
+
}
|
|
40883
40355
|
function botExecutionAgent(agent, contextHandle, socketPath) {
|
|
40884
40356
|
return new LocalAgentDefinition(
|
|
40885
40357
|
agent.id,
|
|
@@ -40940,14 +40412,14 @@ async function applyRequiredExecutionSelection(sessions, configOptions, selectio
|
|
|
40940
40412
|
booleanValue: false,
|
|
40941
40413
|
configId: selection.configId,
|
|
40942
40414
|
cwd,
|
|
40943
|
-
requestId: `cfg_${
|
|
40415
|
+
requestId: `cfg_${randomUUID3()}`,
|
|
40944
40416
|
sessionId,
|
|
40945
40417
|
signal,
|
|
40946
40418
|
value: selection.value,
|
|
40947
40419
|
valueType: "select"
|
|
40948
40420
|
});
|
|
40949
40421
|
}
|
|
40950
|
-
async function executeBotPrompt(outbox, publisher, command, config2, directories, audit, sessions,
|
|
40422
|
+
async function executeBotPrompt(outbox, publisher, command, config2, directories, audit, sessions, authorizer, contexts, applicator, ipc, attemptId, activateAttempt, timer, signal) {
|
|
40951
40423
|
const activities = new CoalescingDaemonActivityPublisher(timer, (activity) => {
|
|
40952
40424
|
publisher.recordAttempt(command.sessionId, encodeDaemonActivity(command, activity), attemptId);
|
|
40953
40425
|
});
|
|
@@ -40957,21 +40429,7 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
|
|
|
40957
40429
|
if (!Number.isSafeInteger(deadline) || remaining <= 0) {
|
|
40958
40430
|
throw new LocalBotAuthorizationError("turn_expired", "The Bot execution deadline has expired");
|
|
40959
40431
|
}
|
|
40960
|
-
const
|
|
40961
|
-
command,
|
|
40962
|
-
config2.catalog,
|
|
40963
|
-
directories,
|
|
40964
|
-
config2.bindingId,
|
|
40965
|
-
Date.now(),
|
|
40966
|
-
signal
|
|
40967
|
-
);
|
|
40968
|
-
const requestedExecutionTargetOverridden = command.directoryId !== grant.workspaceRef || command.additionalDirectoryIds.length > 0;
|
|
40969
|
-
if (requestedExecutionTargetOverridden && !(command.replyRoute instanceof OwnerBotReplyRoute)) {
|
|
40970
|
-
throw new LocalBotAuthorizationError(
|
|
40971
|
-
"binding_not_approved",
|
|
40972
|
-
"Only a paired owner conversation can override the approved Bot workspace"
|
|
40973
|
-
);
|
|
40974
|
-
}
|
|
40432
|
+
const execution = await authorizer.authorize(command, config2.catalog, directories, config2.bindingId, signal);
|
|
40975
40433
|
const resolved = await resolveSessionDirectories(
|
|
40976
40434
|
directories,
|
|
40977
40435
|
config2.bindingId,
|
|
@@ -40979,20 +40437,8 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
|
|
|
40979
40437
|
command.additionalDirectoryIds,
|
|
40980
40438
|
signal
|
|
40981
40439
|
);
|
|
40982
|
-
const executionTargetOverridden = resolved.cwd !== grant.workspacePath || resolved.additionalDirectories.length > 0;
|
|
40983
|
-
if (executionTargetOverridden && !sessions.hasPreparedSession(
|
|
40984
|
-
command.sessionId,
|
|
40985
|
-
grant.agent.id,
|
|
40986
|
-
resolved.cwd,
|
|
40987
|
-
resolved.additionalDirectories
|
|
40988
|
-
)) {
|
|
40989
|
-
throw new LocalBotAuthorizationError(
|
|
40990
|
-
"local_approval_required",
|
|
40991
|
-
"Open this Bot conversation in the paired local Web app before using the selected workspace"
|
|
40992
|
-
);
|
|
40993
|
-
}
|
|
40994
40440
|
const attachments = await resolvePromptArtifacts(config2, command, signal);
|
|
40995
|
-
const applied = await applicator.apply(command,
|
|
40441
|
+
const applied = await applicator.apply(command, execution, attachments.resources, signal);
|
|
40996
40442
|
const deadlineSignal = AbortSignal.timeout(remaining);
|
|
40997
40443
|
const executionSignal = AbortSignal.any([signal, deadlineSignal]);
|
|
40998
40444
|
const startExecution = () => {
|
|
@@ -41002,8 +40448,7 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
|
|
|
41002
40448
|
behaviorRevisionId: command.behaviorRevisionId,
|
|
41003
40449
|
bindingId: command.bindingId,
|
|
41004
40450
|
botId: command.botId,
|
|
41005
|
-
executionId: command.executionId
|
|
41006
|
-
localGrantId: command.localGrantId
|
|
40451
|
+
executionId: command.executionId
|
|
41007
40452
|
},
|
|
41008
40453
|
event: "bot_session_authorized",
|
|
41009
40454
|
sessionId: command.sessionId
|
|
@@ -41026,7 +40471,7 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
|
|
|
41026
40471
|
startExecution();
|
|
41027
40472
|
await sessions.steerPrompt({
|
|
41028
40473
|
additionalDirectories: resolved.additionalDirectories,
|
|
41029
|
-
agent:
|
|
40474
|
+
agent: execution.agent,
|
|
41030
40475
|
commandId: command.commandId,
|
|
41031
40476
|
cwd: resolved.cwd,
|
|
41032
40477
|
images: attachments.images,
|
|
@@ -41046,7 +40491,7 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
|
|
|
41046
40491
|
}
|
|
41047
40492
|
const lease = contexts.activate(command);
|
|
41048
40493
|
try {
|
|
41049
|
-
const agent = botExecutionAgent(
|
|
40494
|
+
const agent = botExecutionAgent(execution.agent, lease.context.contextHandle, ipc.socketPath);
|
|
41050
40495
|
const prepared = await sessions.prepareExecutionSession({
|
|
41051
40496
|
additionalDirectories: resolved.additionalDirectories,
|
|
41052
40497
|
agent,
|
|
@@ -41054,11 +40499,11 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
|
|
|
41054
40499
|
sessionId: command.sessionId,
|
|
41055
40500
|
signal: executionSignal
|
|
41056
40501
|
});
|
|
41057
|
-
assertPreparedPermission(prepared.configOptions,
|
|
40502
|
+
assertPreparedPermission(prepared.configOptions, execution.executionConfiguration.permissionMode);
|
|
41058
40503
|
let configOptions = await applyRequiredExecutionSelection(
|
|
41059
40504
|
sessions,
|
|
41060
40505
|
prepared.configOptions,
|
|
41061
|
-
|
|
40506
|
+
execution.executionConfiguration.model,
|
|
41062
40507
|
"model",
|
|
41063
40508
|
agent,
|
|
41064
40509
|
resolved.cwd,
|
|
@@ -41069,7 +40514,7 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
|
|
|
41069
40514
|
configOptions = await applyRequiredExecutionSelection(
|
|
41070
40515
|
sessions,
|
|
41071
40516
|
configOptions,
|
|
41072
|
-
|
|
40517
|
+
execution.executionConfiguration.reasoningEffort,
|
|
41073
40518
|
"thought_level",
|
|
41074
40519
|
agent,
|
|
41075
40520
|
resolved.cwd,
|
|
@@ -41084,7 +40529,7 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
|
|
|
41084
40529
|
booleanValue: selection.booleanValue,
|
|
41085
40530
|
configId: selection.configId,
|
|
41086
40531
|
cwd: resolved.cwd,
|
|
41087
|
-
requestId: `cfg_${
|
|
40532
|
+
requestId: `cfg_${randomUUID3()}`,
|
|
41088
40533
|
sessionId: command.sessionId,
|
|
41089
40534
|
signal: executionSignal,
|
|
41090
40535
|
value: selection.value,
|
|
@@ -41216,13 +40661,13 @@ async function installDetectedAgentIntegrations(config2, installations, signal)
|
|
|
41216
40661
|
{
|
|
41217
40662
|
agentId: agent.id,
|
|
41218
40663
|
kind: AGENT_INSTALL_REQUEST_KIND,
|
|
41219
|
-
requestId: `automatic-integration-${
|
|
40664
|
+
requestId: `automatic-integration-${randomUUID3()}`
|
|
41220
40665
|
},
|
|
41221
40666
|
signal
|
|
41222
40667
|
);
|
|
41223
40668
|
}
|
|
41224
40669
|
}
|
|
41225
|
-
async function runRelayConnection(config2, directories, audit, sessions, installations, installationObserver, nativeSessions, outbox, publisher,
|
|
40670
|
+
async function runRelayConnection(config2, directories, audit, sessions, installations, installationObserver, nativeSessions, outbox, publisher, authorizer, contexts, applicator, ipc, activeTurns, activeAttemptIds, connectionEpoch, diagnostics, onConnected, signal, timer) {
|
|
41226
40671
|
const relayUrl = new URL(config2.relayUrl);
|
|
41227
40672
|
relayUrl.searchParams.set("deliveryReceipts", "1");
|
|
41228
40673
|
relayUrl.searchParams.set("liveness", "1");
|
|
@@ -41402,7 +40847,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41402
40847
|
directories,
|
|
41403
40848
|
audit,
|
|
41404
40849
|
sessions,
|
|
41405
|
-
|
|
40850
|
+
authorizer,
|
|
41406
40851
|
contexts,
|
|
41407
40852
|
applicator,
|
|
41408
40853
|
ipc,
|
|
@@ -41582,70 +41027,6 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41582
41027
|
}
|
|
41583
41028
|
return;
|
|
41584
41029
|
}
|
|
41585
|
-
if (kind === BOT_BINDING_APPROVED_KIND) {
|
|
41586
|
-
decodeBotExecutionBindingApprovedEvent(encoded);
|
|
41587
|
-
return;
|
|
41588
|
-
}
|
|
41589
|
-
if (kind === BOT_BINDING_UNAVAILABLE_KIND) {
|
|
41590
|
-
decodeBotExecutionBindingUnavailableEvent(encoded);
|
|
41591
|
-
return;
|
|
41592
|
-
}
|
|
41593
|
-
if (kind === BOT_BINDING_APPROVAL_REQUEST_KIND) {
|
|
41594
|
-
const request = decodeBotExecutionBindingApprovalRequest(encoded);
|
|
41595
|
-
void grants.approve(
|
|
41596
|
-
request,
|
|
41597
|
-
config2.catalog,
|
|
41598
|
-
directories,
|
|
41599
|
-
config2.bindingId,
|
|
41600
|
-
Date.now(),
|
|
41601
|
-
connectionController.signal
|
|
41602
|
-
).then((approved) => {
|
|
41603
|
-
audit.record({
|
|
41604
|
-
commandId: request.requestId,
|
|
41605
|
-
details: {
|
|
41606
|
-
behaviorRevisionId: request.behaviorRevisionId,
|
|
41607
|
-
bindingId: request.bindingId,
|
|
41608
|
-
botId: request.botId,
|
|
41609
|
-
localGrantId: approved.localGrantId
|
|
41610
|
-
},
|
|
41611
|
-
event: "bot_binding_approved",
|
|
41612
|
-
sessionId: `bot-binding:${request.bindingId}`
|
|
41613
|
-
});
|
|
41614
|
-
if (socket.readyState === WebSocket2.OPEN) {
|
|
41615
|
-
send(socket, encodeBotExecutionBindingApprovedEvent(approved));
|
|
41616
|
-
}
|
|
41617
|
-
}).catch((error62) => {
|
|
41618
|
-
if (connectionController.signal.aborted) {
|
|
41619
|
-
return;
|
|
41620
|
-
}
|
|
41621
|
-
const code = error62 instanceof LocalBotAuthorizationError ? error62.code : "binding_incompatible";
|
|
41622
|
-
const message = error62 instanceof LocalBotAuthorizationError ? error62.message : "The local execution target is incompatible";
|
|
41623
|
-
grants.recordUnavailable(request, code, message, Date.now());
|
|
41624
|
-
audit.record({
|
|
41625
|
-
commandId: request.requestId,
|
|
41626
|
-
details: { bindingId: request.bindingId, botId: request.botId, code },
|
|
41627
|
-
event: "bot_binding_unavailable",
|
|
41628
|
-
sessionId: `bot-binding:${request.bindingId}`
|
|
41629
|
-
});
|
|
41630
|
-
if (socket.readyState === WebSocket2.OPEN) {
|
|
41631
|
-
send(
|
|
41632
|
-
socket,
|
|
41633
|
-
encodeBotExecutionBindingUnavailableEvent(
|
|
41634
|
-
new BotExecutionBindingUnavailableEvent(
|
|
41635
|
-
request.requestId,
|
|
41636
|
-
request.botId,
|
|
41637
|
-
request.behaviorRevisionId,
|
|
41638
|
-
request.bindingId,
|
|
41639
|
-
request.bindingRevision,
|
|
41640
|
-
code,
|
|
41641
|
-
message
|
|
41642
|
-
)
|
|
41643
|
-
)
|
|
41644
|
-
);
|
|
41645
|
-
}
|
|
41646
|
-
});
|
|
41647
|
-
return;
|
|
41648
|
-
}
|
|
41649
41030
|
if (kind === NATIVE_SESSION_CANCEL_KIND) {
|
|
41650
41031
|
const command2 = decodeNativeSessionCancel(encoded);
|
|
41651
41032
|
const pending = nativeRequests.get(command2.requestId);
|
|
@@ -42041,7 +41422,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
42041
41422
|
directories,
|
|
42042
41423
|
audit,
|
|
42043
41424
|
sessions,
|
|
42044
|
-
|
|
41425
|
+
authorizer,
|
|
42045
41426
|
contexts,
|
|
42046
41427
|
applicator,
|
|
42047
41428
|
ipc,
|
|
@@ -42167,7 +41548,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
|
|
|
42167
41548
|
const sessionStore = new SqliteAcpSessionStore(config2.auditDatabasePath);
|
|
42168
41549
|
const outbox = new SessionEventOutbox(config2.auditDatabasePath);
|
|
42169
41550
|
const publisher = new DaemonSessionEventPublisher(outbox, timer);
|
|
42170
|
-
const
|
|
41551
|
+
const authorizer = new LocalBotExecutionAuthorizer();
|
|
42171
41552
|
const contexts = new BotExecutionContextRegistry();
|
|
42172
41553
|
const applicator = new EmbeddedBotContextApplicator();
|
|
42173
41554
|
const ipc = new BotOutboundIpcServer(botIpcSocketPath(), config2.relayUrl, contexts);
|
|
@@ -42258,7 +41639,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
|
|
|
42258
41639
|
nativeSessions,
|
|
42259
41640
|
outbox,
|
|
42260
41641
|
publisher,
|
|
42261
|
-
|
|
41642
|
+
authorizer,
|
|
42262
41643
|
contexts,
|
|
42263
41644
|
applicator,
|
|
42264
41645
|
ipc,
|
|
@@ -42303,13 +41684,9 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
|
|
|
42303
41684
|
sessionStore.close();
|
|
42304
41685
|
} finally {
|
|
42305
41686
|
try {
|
|
42306
|
-
|
|
41687
|
+
publisher.close();
|
|
42307
41688
|
} finally {
|
|
42308
|
-
|
|
42309
|
-
publisher.close();
|
|
42310
|
-
} finally {
|
|
42311
|
-
outbox.close();
|
|
42312
|
-
}
|
|
41689
|
+
outbox.close();
|
|
42313
41690
|
}
|
|
42314
41691
|
}
|
|
42315
41692
|
}
|
|
@@ -42321,7 +41698,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
|
|
|
42321
41698
|
}
|
|
42322
41699
|
|
|
42323
41700
|
// src/pairing/pair-local-machine.ts
|
|
42324
|
-
import { randomUUID as
|
|
41701
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
42325
41702
|
import { mkdir as mkdir4, open as open4, realpath as realpath8, rename as rename3, stat as stat7, writeFile as writeFile2 } from "node:fs/promises";
|
|
42326
41703
|
import { hostname as hostname3 } from "node:os";
|
|
42327
41704
|
import { basename as basename6, join as join17, resolve as resolve4 } from "node:path";
|
|
@@ -42453,7 +41830,8 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
|
|
|
42453
41830
|
botSessionConfiguration: true,
|
|
42454
41831
|
capabilities: agent.capabilities,
|
|
42455
41832
|
id: agent.id,
|
|
42456
|
-
label: agent.label
|
|
41833
|
+
label: agent.label,
|
|
41834
|
+
sessionTurnConfiguration: true
|
|
42457
41835
|
}));
|
|
42458
41836
|
const endpoint = options.pairingId.length > 0 ? mobiusApiUrl(options.relayOrigin, `/v1/runtime-pairings/${encodeURIComponent(options.pairingId)}/redeem`) : mobiusApiUrl(options.relayOrigin, "/pairings/claim");
|
|
42459
41837
|
let response;
|
|
@@ -42484,7 +41862,7 @@ async function persistConnection(channelId, relayOrigin, runtimeCredential2, def
|
|
|
42484
41862
|
const connectionsDirectory = join17(readStateDirectory(environment), "connections");
|
|
42485
41863
|
await mkdir4(connectionsDirectory, { mode: 448, recursive: true });
|
|
42486
41864
|
const connectionPath = join17(connectionsDirectory, `${channelId}.json`);
|
|
42487
|
-
const temporaryPath = join17(connectionsDirectory, `.${channelId}.${
|
|
41865
|
+
const temporaryPath = join17(connectionsDirectory, `.${channelId}.${randomUUID4()}.tmp`);
|
|
42488
41866
|
await writeFile2(
|
|
42489
41867
|
temporaryPath,
|
|
42490
41868
|
`${JSON.stringify(
|