@moxt-ai/mobius 0.0.42 → 0.0.44
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-config/session-config-protocol.d.ts +1 -0
- package/dist/acp/session-config/session-config-protocol.d.ts.map +1 -1
- package/dist/acp/session-config/session-config-protocol.js +77 -22
- package/dist/acp/session-config/session-config-protocol.js.map +1 -1
- package/dist/acp/session-manager.d.ts.map +1 -1
- package/dist/acp/session-manager.js +37 -4
- package/dist/acp/session-manager.js.map +1 -1
- package/dist/agent-catalog/agent-permission-profile.d.ts +16 -0
- package/dist/agent-catalog/agent-permission-profile.d.ts.map +1 -0
- package/dist/agent-catalog/agent-permission-profile.js +194 -0
- package/dist/agent-catalog/agent-permission-profile.js.map +1 -0
- package/dist/agent-catalog/agents/cursor-cli-agent.d.ts +1 -1
- package/dist/agent-catalog/agents/cursor-cli-agent.d.ts.map +1 -1
- package/dist/agent-catalog/agents/cursor-cli-agent.js +2 -4
- package/dist/agent-catalog/agents/cursor-cli-agent.js.map +1 -1
- package/dist/agent-catalog/agents/deepseek-harness-agent.d.ts.map +1 -1
- package/dist/agent-catalog/agents/deepseek-harness-agent.js +1 -2
- package/dist/agent-catalog/agents/deepseek-harness-agent.js.map +1 -1
- package/dist/agent-catalog/agents/opencode-agent.d.ts +1 -1
- package/dist/agent-catalog/agents/opencode-agent.d.ts.map +1 -1
- package/dist/agent-catalog/agents/opencode-agent.js +8 -1
- package/dist/agent-catalog/agents/opencode-agent.js.map +1 -1
- package/dist/agent-catalog/discover-local-agents.d.ts +0 -1
- package/dist/agent-catalog/discover-local-agents.d.ts.map +1 -1
- package/dist/agent-catalog/discover-local-agents.js +0 -1
- package/dist/agent-catalog/discover-local-agents.js.map +1 -1
- package/dist/agent-catalog/local-agent.d.ts +4 -1
- package/dist/agent-catalog/local-agent.d.ts.map +1 -1
- package/dist/agent-catalog/local-agent.js +12 -2
- package/dist/agent-catalog/local-agent.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 +6691 -6959
- package/dist/cli.js.map +4 -4
- package/dist/index.js +551 -817
- package/dist/index.js.map +4 -4
- package/dist/run-daemon.d.ts.map +1 -1
- package/dist/run-daemon.js +58 -82
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +6234 -6502
- package/dist/runtime.js.map +4 -4
- package/package.json +1 -1
- package/dist/bots/local-bot-grant-store.d.ts +0 -35
- package/dist/bots/local-bot-grant-store.d.ts.map +0 -1
- package/dist/bots/local-bot-grant-store.js +0 -353
- package/dist/bots/local-bot-grant-store.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -16628,8 +16628,8 @@ function rewriteKeyNames(ctx) {
|
|
|
16628
16628
|
bySchema.set(entry.schema, entry);
|
|
16629
16629
|
}
|
|
16630
16630
|
const rewrites = /* @__PURE__ */ new Map();
|
|
16631
|
-
for (const
|
|
16632
|
-
const seen = ctx.seen.get(
|
|
16631
|
+
for (const record4 of pendingRecords.get(ctx) ?? []) {
|
|
16632
|
+
const seen = ctx.seen.get(record4);
|
|
16633
16633
|
const names = (seen?.def ?? seen?.schema)?.propertyNames;
|
|
16634
16634
|
if (!names || names === true || rewrites.has(names))
|
|
16635
16635
|
continue;
|
|
@@ -19863,6 +19863,45 @@ var sessionConfigurationSelectionSchema = external_exports.strictObject({
|
|
|
19863
19863
|
value: external_exports.string().max(500),
|
|
19864
19864
|
valueType: external_exports.enum(["boolean", "select"])
|
|
19865
19865
|
}).readonly();
|
|
19866
|
+
var AGENT_DEFAULT_EXECUTION_SETTING = "agent_default";
|
|
19867
|
+
var AGENT_PERMISSION_MODE_CONFIG_ID = "permission_mode";
|
|
19868
|
+
var AGENT_PERMISSION_MODES = Object.freeze([
|
|
19869
|
+
AGENT_DEFAULT_EXECUTION_SETTING,
|
|
19870
|
+
"read-only",
|
|
19871
|
+
"workspace-write",
|
|
19872
|
+
"danger-full-access"
|
|
19873
|
+
]);
|
|
19874
|
+
var agentExecutionConfigurationSchema = external_exports.strictObject({
|
|
19875
|
+
model: sessionConfigurationSelectionSchema,
|
|
19876
|
+
permissionMode: external_exports.string().refine((value) => AGENT_PERMISSION_MODES.includes(value)),
|
|
19877
|
+
reasoningEffort: sessionConfigurationSelectionSchema
|
|
19878
|
+
}).superRefine((configuration, context) => {
|
|
19879
|
+
if (configuration.model.valueType !== "select" || configuration.model.booleanValue || configuration.model.value.length === 0 || configuration.reasoningEffort.valueType !== "select" || configuration.reasoningEffort.booleanValue || configuration.reasoningEffort.value.length === 0) {
|
|
19880
|
+
context.addIssue({
|
|
19881
|
+
code: "custom",
|
|
19882
|
+
message: "Model and reasoning effort must be explicit select configurations"
|
|
19883
|
+
});
|
|
19884
|
+
}
|
|
19885
|
+
if (configuration.model.configId === configuration.reasoningEffort.configId || configuration.model.configId === AGENT_PERMISSION_MODE_CONFIG_ID || configuration.reasoningEffort.configId === AGENT_PERMISSION_MODE_CONFIG_ID) {
|
|
19886
|
+
context.addIssue({
|
|
19887
|
+
code: "custom",
|
|
19888
|
+
message: "Required execution setting identifiers must differ"
|
|
19889
|
+
});
|
|
19890
|
+
}
|
|
19891
|
+
}).readonly();
|
|
19892
|
+
function agentDefaultSelection(configId) {
|
|
19893
|
+
return Object.freeze({
|
|
19894
|
+
booleanValue: false,
|
|
19895
|
+
configId,
|
|
19896
|
+
value: AGENT_DEFAULT_EXECUTION_SETTING,
|
|
19897
|
+
valueType: "select"
|
|
19898
|
+
});
|
|
19899
|
+
}
|
|
19900
|
+
var DEFAULT_AGENT_EXECUTION_CONFIGURATION = Object.freeze({
|
|
19901
|
+
model: agentDefaultSelection("model"),
|
|
19902
|
+
permissionMode: AGENT_DEFAULT_EXECUTION_SETTING,
|
|
19903
|
+
reasoningEffort: agentDefaultSelection("reasoning_effort")
|
|
19904
|
+
});
|
|
19866
19905
|
var sessionConfigurationSelectionsSchema = external_exports.array(sessionConfigurationSelectionSchema).max(100).superRefine((selections, context) => {
|
|
19867
19906
|
const identifiers = /* @__PURE__ */ new Set();
|
|
19868
19907
|
for (const [index2, selection] of selections.entries()) {
|
|
@@ -20215,6 +20254,7 @@ var decodeRecordedAgentContentValue = (value) => decodeValue(value, recordedDisp
|
|
|
20215
20254
|
var decodePromptImagesValue = (value) => decodeValue(value, external_exports.array(promptImageSchema).max(8).readonly());
|
|
20216
20255
|
var decodePromptResourcesValue = (value) => decodeValue(value, external_exports.array(promptResourceSchema).max(16).readonly());
|
|
20217
20256
|
var decodeSessionConfigurationSelections = (value) => decodeValue(value, sessionConfigurationSelectionsSchema);
|
|
20257
|
+
var decodeAgentExecutionConfiguration = (value) => decodeValue(value, agentExecutionConfigurationSchema);
|
|
20218
20258
|
var encode3 = (message, schema) => JSON.stringify(decodeValue(message, schema));
|
|
20219
20259
|
var decodeAgentSettingsDiscoverCommand = (encoded) => decode3(encoded, agentSettingsDiscoverCommandSchema);
|
|
20220
20260
|
var encodeAgentSettingsDiscoveredEvent = (message) => encode3(message, agentSettingsDiscoveredEventSchema);
|
|
@@ -20692,9 +20732,6 @@ function encodeSessionFailedEvent(message) {
|
|
|
20692
20732
|
}
|
|
20693
20733
|
|
|
20694
20734
|
// ../protocol/src/bot.ts
|
|
20695
|
-
var BOT_BINDING_APPROVAL_REQUEST_KIND = "bot.binding.approval.request";
|
|
20696
|
-
var BOT_BINDING_APPROVED_KIND = "bot.binding.approved";
|
|
20697
|
-
var BOT_BINDING_UNAVAILABLE_KIND = "bot.binding.unavailable";
|
|
20698
20735
|
var BOT_SESSION_PROMPT_KIND = "bot.session.prompt";
|
|
20699
20736
|
var IDENTIFIER_PATTERN3 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
20700
20737
|
var DIRECTORY_IDENTIFIER_PATTERN3 = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/;
|
|
@@ -20709,21 +20746,6 @@ var BotDeliveryTargetReference = class {
|
|
|
20709
20746
|
this.deliveryTargetId = deliveryTargetId;
|
|
20710
20747
|
}
|
|
20711
20748
|
};
|
|
20712
|
-
var BotCompletionDeliveryPolicy = class {
|
|
20713
|
-
};
|
|
20714
|
-
var NoBotCompletionDeliveryPolicy = class extends BotCompletionDeliveryPolicy {
|
|
20715
|
-
kind = "none";
|
|
20716
|
-
};
|
|
20717
|
-
var RequiredBotCompletionDeliveryPolicy = class extends BotCompletionDeliveryPolicy {
|
|
20718
|
-
deliveryTargetId;
|
|
20719
|
-
kind = "required";
|
|
20720
|
-
messageTemplate;
|
|
20721
|
-
constructor(deliveryTargetId, messageTemplate) {
|
|
20722
|
-
super();
|
|
20723
|
-
this.deliveryTargetId = deliveryTargetId;
|
|
20724
|
-
this.messageTemplate = messageTemplate;
|
|
20725
|
-
}
|
|
20726
|
-
};
|
|
20727
20749
|
var BotReplyRoute = class {
|
|
20728
20750
|
};
|
|
20729
20751
|
var OwnerBotReplyRoute = class extends BotReplyRoute {
|
|
@@ -20739,92 +20761,6 @@ var BotConnectionReplyRoute = class extends BotReplyRoute {
|
|
|
20739
20761
|
this.deliveryTargetId = deliveryTargetId;
|
|
20740
20762
|
}
|
|
20741
20763
|
};
|
|
20742
|
-
var BotExecutionBindingApprovalRequest = class {
|
|
20743
|
-
agentConfigRevision;
|
|
20744
|
-
agentRef;
|
|
20745
|
-
allowedDeliveryTargets;
|
|
20746
|
-
behaviorDigest;
|
|
20747
|
-
behaviorInstructions;
|
|
20748
|
-
behaviorRevisionId;
|
|
20749
|
-
bindingId;
|
|
20750
|
-
bindingRevision;
|
|
20751
|
-
botId;
|
|
20752
|
-
completionPolicy;
|
|
20753
|
-
kind = BOT_BINDING_APPROVAL_REQUEST_KIND;
|
|
20754
|
-
requestId;
|
|
20755
|
-
requiredCapabilities;
|
|
20756
|
-
runtimeId;
|
|
20757
|
-
sessionConfigurations;
|
|
20758
|
-
workspaceRef;
|
|
20759
|
-
constructor(requestId, botId, behaviorRevisionId, bindingId, bindingRevision, runtimeId, agentRef, workspaceRef, agentConfigRevision, behaviorInstructions, behaviorDigest, requiredCapabilities, allowedDeliveryTargets, completionPolicy, sessionConfigurations = []) {
|
|
20760
|
-
this.requestId = requestId;
|
|
20761
|
-
this.botId = botId;
|
|
20762
|
-
this.behaviorRevisionId = behaviorRevisionId;
|
|
20763
|
-
this.bindingId = bindingId;
|
|
20764
|
-
this.bindingRevision = bindingRevision;
|
|
20765
|
-
this.runtimeId = runtimeId;
|
|
20766
|
-
this.agentRef = agentRef;
|
|
20767
|
-
this.workspaceRef = workspaceRef;
|
|
20768
|
-
this.agentConfigRevision = agentConfigRevision;
|
|
20769
|
-
this.behaviorInstructions = behaviorInstructions;
|
|
20770
|
-
this.behaviorDigest = behaviorDigest;
|
|
20771
|
-
this.requiredCapabilities = Object.freeze([...requiredCapabilities]);
|
|
20772
|
-
this.sessionConfigurations = Object.freeze([...sessionConfigurations]);
|
|
20773
|
-
this.allowedDeliveryTargets = Object.freeze(
|
|
20774
|
-
allowedDeliveryTargets.map(
|
|
20775
|
-
(target) => new BotDeliveryTargetReference(target.alias, target.deliveryTargetId)
|
|
20776
|
-
)
|
|
20777
|
-
);
|
|
20778
|
-
this.completionPolicy = completionPolicy;
|
|
20779
|
-
}
|
|
20780
|
-
toJSON() {
|
|
20781
|
-
const { sessionConfigurations, ...request } = this;
|
|
20782
|
-
return {
|
|
20783
|
-
...request,
|
|
20784
|
-
...sessionConfigurations.length === 0 ? {} : { sessionConfigurations }
|
|
20785
|
-
};
|
|
20786
|
-
}
|
|
20787
|
-
};
|
|
20788
|
-
var BotExecutionBindingApprovedEvent = class {
|
|
20789
|
-
agentIdentityDigest;
|
|
20790
|
-
behaviorRevisionId;
|
|
20791
|
-
bindingId;
|
|
20792
|
-
bindingRevision;
|
|
20793
|
-
botId;
|
|
20794
|
-
kind = BOT_BINDING_APPROVED_KIND;
|
|
20795
|
-
localGrantId;
|
|
20796
|
-
requestId;
|
|
20797
|
-
workspaceIdentityDigest;
|
|
20798
|
-
constructor(requestId, botId, behaviorRevisionId, bindingId, bindingRevision, localGrantId, agentIdentityDigest, workspaceIdentityDigest) {
|
|
20799
|
-
this.requestId = requestId;
|
|
20800
|
-
this.botId = botId;
|
|
20801
|
-
this.behaviorRevisionId = behaviorRevisionId;
|
|
20802
|
-
this.bindingId = bindingId;
|
|
20803
|
-
this.bindingRevision = bindingRevision;
|
|
20804
|
-
this.localGrantId = localGrantId;
|
|
20805
|
-
this.agentIdentityDigest = agentIdentityDigest;
|
|
20806
|
-
this.workspaceIdentityDigest = workspaceIdentityDigest;
|
|
20807
|
-
}
|
|
20808
|
-
};
|
|
20809
|
-
var BotExecutionBindingUnavailableEvent = class {
|
|
20810
|
-
behaviorRevisionId;
|
|
20811
|
-
bindingId;
|
|
20812
|
-
bindingRevision;
|
|
20813
|
-
botId;
|
|
20814
|
-
code;
|
|
20815
|
-
kind = BOT_BINDING_UNAVAILABLE_KIND;
|
|
20816
|
-
message;
|
|
20817
|
-
requestId;
|
|
20818
|
-
constructor(requestId, botId, behaviorRevisionId, bindingId, bindingRevision, code, message) {
|
|
20819
|
-
this.requestId = requestId;
|
|
20820
|
-
this.botId = botId;
|
|
20821
|
-
this.behaviorRevisionId = behaviorRevisionId;
|
|
20822
|
-
this.bindingId = bindingId;
|
|
20823
|
-
this.bindingRevision = bindingRevision;
|
|
20824
|
-
this.code = code;
|
|
20825
|
-
this.message = message;
|
|
20826
|
-
}
|
|
20827
|
-
};
|
|
20828
20764
|
var BotSessionPromptCommand = class {
|
|
20829
20765
|
additionalDirectoryIds;
|
|
20830
20766
|
agentId;
|
|
@@ -20843,9 +20779,9 @@ var BotSessionPromptCommand = class {
|
|
|
20843
20779
|
executionCapabilitySecret;
|
|
20844
20780
|
executionDeadlineAt;
|
|
20845
20781
|
executionId;
|
|
20782
|
+
executionConfiguration;
|
|
20846
20783
|
images;
|
|
20847
20784
|
kind = BOT_SESSION_PROMPT_KIND;
|
|
20848
|
-
localGrantId;
|
|
20849
20785
|
prompt;
|
|
20850
20786
|
replyRoute;
|
|
20851
20787
|
resources;
|
|
@@ -20853,7 +20789,7 @@ var BotSessionPromptCommand = class {
|
|
|
20853
20789
|
sessionId;
|
|
20854
20790
|
targetCommandId;
|
|
20855
20791
|
turnId;
|
|
20856
|
-
constructor(sessionId, commandId, agentId, bindingId, directoryId2, additionalDirectoryIds, images, resources, prompt, executionId, executionCapabilityId, executionCapabilitySecret, executionDeadlineAt, botId, conversationId, turnId, behaviorRevisionId, bindingRevision,
|
|
20792
|
+
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 = "") {
|
|
20857
20793
|
this.sessionId = sessionId;
|
|
20858
20794
|
this.commandId = commandId;
|
|
20859
20795
|
this.agentId = agentId;
|
|
@@ -20873,7 +20809,6 @@ var BotSessionPromptCommand = class {
|
|
|
20873
20809
|
this.turnId = turnId;
|
|
20874
20810
|
this.behaviorRevisionId = behaviorRevisionId;
|
|
20875
20811
|
this.bindingRevision = bindingRevision;
|
|
20876
|
-
this.localGrantId = localGrantId;
|
|
20877
20812
|
this.behaviorInstructions = behaviorInstructions;
|
|
20878
20813
|
this.behaviorDigest = behaviorDigest;
|
|
20879
20814
|
this.allowedDeliveryTargets = Object.freeze(
|
|
@@ -20882,6 +20817,7 @@ var BotSessionPromptCommand = class {
|
|
|
20882
20817
|
)
|
|
20883
20818
|
);
|
|
20884
20819
|
this.replyRoute = replyRoute;
|
|
20820
|
+
this.executionConfiguration = decodeAgentExecutionConfiguration(executionConfiguration);
|
|
20885
20821
|
this.sessionConfigurations = Object.freeze([...sessionConfigurations]);
|
|
20886
20822
|
this.targetCommandId = targetCommandId;
|
|
20887
20823
|
}
|
|
@@ -21016,24 +20952,6 @@ function readSessionConfigurations(value) {
|
|
|
21016
20952
|
}
|
|
21017
20953
|
return decodeSessionConfigurationSelections(value["sessionConfigurations"]);
|
|
21018
20954
|
}
|
|
21019
|
-
function readCompletionPolicy(value) {
|
|
21020
|
-
if (!isRecord2(value)) {
|
|
21021
|
-
throw new ProtocolMessageError("Invalid Bot completion policy");
|
|
21022
|
-
}
|
|
21023
|
-
const kind = readText2(value, "kind", 32, false);
|
|
21024
|
-
if (kind === "none") {
|
|
21025
|
-
assertExactKeys2(value, ["kind"]);
|
|
21026
|
-
return new NoBotCompletionDeliveryPolicy();
|
|
21027
|
-
}
|
|
21028
|
-
if (kind === "required") {
|
|
21029
|
-
assertExactKeys2(value, ["deliveryTargetId", "kind", "messageTemplate"]);
|
|
21030
|
-
return new RequiredBotCompletionDeliveryPolicy(
|
|
21031
|
-
readIdentifier2(value, "deliveryTargetId"),
|
|
21032
|
-
readText2(value, "messageTemplate", 1e4, false)
|
|
21033
|
-
);
|
|
21034
|
-
}
|
|
21035
|
-
throw new ProtocolMessageError("Invalid Bot completion policy");
|
|
21036
|
-
}
|
|
21037
20955
|
function readReplyRoute(value) {
|
|
21038
20956
|
if (!isRecord2(value)) {
|
|
21039
20957
|
throw new ProtocolMessageError("Invalid Bot reply route");
|
|
@@ -21052,108 +20970,6 @@ function readReplyRoute(value) {
|
|
|
21052
20970
|
}
|
|
21053
20971
|
throw new ProtocolMessageError("Invalid Bot reply route");
|
|
21054
20972
|
}
|
|
21055
|
-
function decodeBotExecutionBindingApprovalRequest(encoded) {
|
|
21056
|
-
const value = parseJson3(encoded);
|
|
21057
|
-
assertKeysWithOptional(
|
|
21058
|
-
value,
|
|
21059
|
-
[
|
|
21060
|
-
"agentConfigRevision",
|
|
21061
|
-
"agentRef",
|
|
21062
|
-
"allowedDeliveryTargets",
|
|
21063
|
-
"behaviorDigest",
|
|
21064
|
-
"behaviorInstructions",
|
|
21065
|
-
"behaviorRevisionId",
|
|
21066
|
-
"bindingId",
|
|
21067
|
-
"bindingRevision",
|
|
21068
|
-
"botId",
|
|
21069
|
-
"completionPolicy",
|
|
21070
|
-
"kind",
|
|
21071
|
-
"requestId",
|
|
21072
|
-
"requiredCapabilities",
|
|
21073
|
-
"runtimeId",
|
|
21074
|
-
"workspaceRef"
|
|
21075
|
-
],
|
|
21076
|
-
["sessionConfigurations"]
|
|
21077
|
-
);
|
|
21078
|
-
if (value["kind"] !== BOT_BINDING_APPROVAL_REQUEST_KIND) {
|
|
21079
|
-
throw new ProtocolMessageError("Invalid Bot binding approval request kind");
|
|
21080
|
-
}
|
|
21081
|
-
return new BotExecutionBindingApprovalRequest(
|
|
21082
|
-
readIdentifier2(value, "requestId"),
|
|
21083
|
-
readIdentifier2(value, "botId"),
|
|
21084
|
-
readIdentifier2(value, "behaviorRevisionId"),
|
|
21085
|
-
readIdentifier2(value, "bindingId"),
|
|
21086
|
-
readInteger(value, "bindingRevision"),
|
|
21087
|
-
readIdentifier2(value, "runtimeId"),
|
|
21088
|
-
readIdentifier2(value, "agentRef"),
|
|
21089
|
-
readDirectoryIdentifier2(value, "workspaceRef"),
|
|
21090
|
-
readInteger(value, "agentConfigRevision"),
|
|
21091
|
-
readText2(value, "behaviorInstructions", MAX_INSTRUCTIONS_LENGTH, true),
|
|
21092
|
-
readDigest(value, "behaviorDigest"),
|
|
21093
|
-
readIdentifiers(value, "requiredCapabilities", 32),
|
|
21094
|
-
readTargets(value, "allowedDeliveryTargets"),
|
|
21095
|
-
readCompletionPolicy(value["completionPolicy"]),
|
|
21096
|
-
readSessionConfigurations(value)
|
|
21097
|
-
);
|
|
21098
|
-
}
|
|
21099
|
-
function decodeBotExecutionBindingApprovedEvent(encoded) {
|
|
21100
|
-
const value = parseJson3(encoded);
|
|
21101
|
-
assertExactKeys2(value, [
|
|
21102
|
-
"agentIdentityDigest",
|
|
21103
|
-
"behaviorRevisionId",
|
|
21104
|
-
"bindingId",
|
|
21105
|
-
"bindingRevision",
|
|
21106
|
-
"botId",
|
|
21107
|
-
"kind",
|
|
21108
|
-
"localGrantId",
|
|
21109
|
-
"requestId",
|
|
21110
|
-
"workspaceIdentityDigest"
|
|
21111
|
-
]);
|
|
21112
|
-
if (value["kind"] !== BOT_BINDING_APPROVED_KIND) {
|
|
21113
|
-
throw new ProtocolMessageError("Invalid Bot binding approval event kind");
|
|
21114
|
-
}
|
|
21115
|
-
return new BotExecutionBindingApprovedEvent(
|
|
21116
|
-
readIdentifier2(value, "requestId"),
|
|
21117
|
-
readIdentifier2(value, "botId"),
|
|
21118
|
-
readIdentifier2(value, "behaviorRevisionId"),
|
|
21119
|
-
readIdentifier2(value, "bindingId"),
|
|
21120
|
-
readInteger(value, "bindingRevision"),
|
|
21121
|
-
readIdentifier2(value, "localGrantId"),
|
|
21122
|
-
readDigest(value, "agentIdentityDigest"),
|
|
21123
|
-
readDigest(value, "workspaceIdentityDigest")
|
|
21124
|
-
);
|
|
21125
|
-
}
|
|
21126
|
-
function encodeBotExecutionBindingApprovedEvent(event) {
|
|
21127
|
-
return JSON.stringify(decodeBotExecutionBindingApprovedEvent(JSON.stringify(event)));
|
|
21128
|
-
}
|
|
21129
|
-
function decodeBotExecutionBindingUnavailableEvent(encoded) {
|
|
21130
|
-
const value = parseJson3(encoded);
|
|
21131
|
-
assertExactKeys2(value, [
|
|
21132
|
-
"behaviorRevisionId",
|
|
21133
|
-
"bindingId",
|
|
21134
|
-
"bindingRevision",
|
|
21135
|
-
"botId",
|
|
21136
|
-
"code",
|
|
21137
|
-
"kind",
|
|
21138
|
-
"message",
|
|
21139
|
-
"requestId"
|
|
21140
|
-
]);
|
|
21141
|
-
if (value["kind"] !== BOT_BINDING_UNAVAILABLE_KIND) {
|
|
21142
|
-
throw new ProtocolMessageError("Invalid Bot binding unavailable event kind");
|
|
21143
|
-
}
|
|
21144
|
-
return new BotExecutionBindingUnavailableEvent(
|
|
21145
|
-
readIdentifier2(value, "requestId"),
|
|
21146
|
-
readIdentifier2(value, "botId"),
|
|
21147
|
-
readIdentifier2(value, "behaviorRevisionId"),
|
|
21148
|
-
readIdentifier2(value, "bindingId"),
|
|
21149
|
-
readInteger(value, "bindingRevision"),
|
|
21150
|
-
readIdentifier2(value, "code"),
|
|
21151
|
-
readText2(value, "message", 500, false)
|
|
21152
|
-
);
|
|
21153
|
-
}
|
|
21154
|
-
function encodeBotExecutionBindingUnavailableEvent(event) {
|
|
21155
|
-
return JSON.stringify(decodeBotExecutionBindingUnavailableEvent(JSON.stringify(event)));
|
|
21156
|
-
}
|
|
21157
20973
|
function decodeBotSessionPromptCommand(encoded) {
|
|
21158
20974
|
const value = parseJson3(encoded);
|
|
21159
20975
|
assertKeysWithOptional(
|
|
@@ -21175,9 +20991,9 @@ function decodeBotSessionPromptCommand(encoded) {
|
|
|
21175
20991
|
"executionCapabilitySecret",
|
|
21176
20992
|
"executionDeadlineAt",
|
|
21177
20993
|
"executionId",
|
|
20994
|
+
"executionConfiguration",
|
|
21178
20995
|
"images",
|
|
21179
20996
|
"kind",
|
|
21180
|
-
"localGrantId",
|
|
21181
20997
|
"prompt",
|
|
21182
20998
|
"replyRoute",
|
|
21183
20999
|
"resources",
|
|
@@ -21223,11 +21039,11 @@ function decodeBotSessionPromptCommand(encoded) {
|
|
|
21223
21039
|
readIdentifier2(value, "turnId"),
|
|
21224
21040
|
readIdentifier2(value, "behaviorRevisionId"),
|
|
21225
21041
|
readInteger(value, "bindingRevision"),
|
|
21226
|
-
readIdentifier2(value, "localGrantId"),
|
|
21227
21042
|
readText2(value, "behaviorInstructions", MAX_INSTRUCTIONS_LENGTH, true),
|
|
21228
21043
|
readDigest(value, "behaviorDigest"),
|
|
21229
21044
|
readTargets(value, "allowedDeliveryTargets"),
|
|
21230
21045
|
readReplyRoute(value["replyRoute"]),
|
|
21046
|
+
decodeAgentExecutionConfiguration(value["executionConfiguration"]),
|
|
21231
21047
|
readSessionConfigurations(value),
|
|
21232
21048
|
disposition,
|
|
21233
21049
|
targetCommandId
|
|
@@ -22112,6 +21928,199 @@ async function runBoundedProcess(options) {
|
|
|
22112
21928
|
}
|
|
22113
21929
|
}
|
|
22114
21930
|
|
|
21931
|
+
// src/agent-catalog/agent-permission-profile.ts
|
|
21932
|
+
var AGENT_DEFAULT_PERMISSION_MODE = AGENT_DEFAULT_EXECUTION_SETTING;
|
|
21933
|
+
var READ_ONLY_PERMISSION_MODE = "read-only";
|
|
21934
|
+
var WORKSPACE_WRITE_PERMISSION_MODE = "workspace-write";
|
|
21935
|
+
var DANGER_FULL_ACCESS_PERMISSION_MODE = "danger-full-access";
|
|
21936
|
+
var PERMISSION_MODE_CONFIG_ID = AGENT_PERMISSION_MODE_CONFIG_ID;
|
|
21937
|
+
var PERMISSION_MODE_MARKER = "MOBIUS_AGENT_PERMISSION_MODE";
|
|
21938
|
+
var AgentPermissionConfigurationError = class extends Error {
|
|
21939
|
+
code = "invalid_agent_permission_configuration";
|
|
21940
|
+
constructor(message, options = {}) {
|
|
21941
|
+
super(message, options);
|
|
21942
|
+
this.name = "AgentPermissionConfigurationError";
|
|
21943
|
+
}
|
|
21944
|
+
};
|
|
21945
|
+
var AgentPermissionProfile = class {
|
|
21946
|
+
option = (environment) => ({
|
|
21947
|
+
booleanValue: false,
|
|
21948
|
+
category: "_mobius_permission",
|
|
21949
|
+
currentValue: this.currentMode(environment),
|
|
21950
|
+
description: this.description,
|
|
21951
|
+
id: PERMISSION_MODE_CONFIG_ID,
|
|
21952
|
+
name: "Permissions",
|
|
21953
|
+
type: "select",
|
|
21954
|
+
values: this.values
|
|
21955
|
+
});
|
|
21956
|
+
};
|
|
21957
|
+
var AgentManagedPermissionProfile = class extends AgentPermissionProfile {
|
|
21958
|
+
description = "This Agent manages its own local permissions.";
|
|
21959
|
+
values = Object.freeze([
|
|
21960
|
+
{
|
|
21961
|
+
description: "Managed by the Agent",
|
|
21962
|
+
groupId: "",
|
|
21963
|
+
groupName: "",
|
|
21964
|
+
name: "Agent default",
|
|
21965
|
+
value: AGENT_DEFAULT_PERMISSION_MODE
|
|
21966
|
+
}
|
|
21967
|
+
]);
|
|
21968
|
+
currentMode = () => AGENT_DEFAULT_PERMISSION_MODE;
|
|
21969
|
+
apply = (environment, permissionMode) => {
|
|
21970
|
+
if (permissionMode !== AGENT_DEFAULT_PERMISSION_MODE) {
|
|
21971
|
+
throw new AgentPermissionConfigurationError("The selected Agent does not support this permission mode");
|
|
21972
|
+
}
|
|
21973
|
+
return Object.freeze({ ...environment });
|
|
21974
|
+
};
|
|
21975
|
+
};
|
|
21976
|
+
var PiPermissionProfile = class extends AgentPermissionProfile {
|
|
21977
|
+
description = "Pi has no built-in sandbox and runs with the local Runtime user's authority.";
|
|
21978
|
+
values = Object.freeze([
|
|
21979
|
+
{
|
|
21980
|
+
description: "Pi default; unrestricted local execution with the Runtime user's authority",
|
|
21981
|
+
groupId: "",
|
|
21982
|
+
groupName: "",
|
|
21983
|
+
name: "Full access (Pi default)",
|
|
21984
|
+
value: DANGER_FULL_ACCESS_PERMISSION_MODE
|
|
21985
|
+
}
|
|
21986
|
+
]);
|
|
21987
|
+
currentMode = () => DANGER_FULL_ACCESS_PERMISSION_MODE;
|
|
21988
|
+
apply = (environment, permissionMode) => {
|
|
21989
|
+
if (permissionMode !== DANGER_FULL_ACCESS_PERMISSION_MODE) {
|
|
21990
|
+
throw new AgentPermissionConfigurationError("Pi only supports its default full-access permission mode");
|
|
21991
|
+
}
|
|
21992
|
+
return Object.freeze({ ...environment });
|
|
21993
|
+
};
|
|
21994
|
+
};
|
|
21995
|
+
var adjustablePermissionValues = Object.freeze([
|
|
21996
|
+
{
|
|
21997
|
+
description: "Keep the Agent's existing permission policy",
|
|
21998
|
+
groupId: "",
|
|
21999
|
+
groupName: "",
|
|
22000
|
+
name: "Agent default",
|
|
22001
|
+
value: AGENT_DEFAULT_PERMISSION_MODE
|
|
22002
|
+
},
|
|
22003
|
+
{
|
|
22004
|
+
description: "Allow inspection without local writes or commands that can change state",
|
|
22005
|
+
groupId: "",
|
|
22006
|
+
groupName: "",
|
|
22007
|
+
name: "Read only",
|
|
22008
|
+
value: READ_ONLY_PERMISSION_MODE
|
|
22009
|
+
},
|
|
22010
|
+
{
|
|
22011
|
+
description: "Allow changes inside the selected workspace while protecting external paths",
|
|
22012
|
+
groupId: "",
|
|
22013
|
+
groupName: "",
|
|
22014
|
+
name: "Workspace write",
|
|
22015
|
+
value: WORKSPACE_WRITE_PERMISSION_MODE
|
|
22016
|
+
},
|
|
22017
|
+
{
|
|
22018
|
+
description: "Allow unrestricted local execution with the Runtime user's authority",
|
|
22019
|
+
groupId: "",
|
|
22020
|
+
groupName: "",
|
|
22021
|
+
name: "Full access",
|
|
22022
|
+
value: DANGER_FULL_ACCESS_PERMISSION_MODE
|
|
22023
|
+
}
|
|
22024
|
+
]);
|
|
22025
|
+
function validateAdjustableMode(permissionMode) {
|
|
22026
|
+
if (!adjustablePermissionValues.some((value) => value.value === permissionMode)) {
|
|
22027
|
+
throw new AgentPermissionConfigurationError("The selected permission mode is unavailable");
|
|
22028
|
+
}
|
|
22029
|
+
return permissionMode;
|
|
22030
|
+
}
|
|
22031
|
+
var DeepSeekHarnessPermissionProfile = class extends AgentPermissionProfile {
|
|
22032
|
+
description = "Controls the local side effects allowed for this Agent session.";
|
|
22033
|
+
values = adjustablePermissionValues;
|
|
22034
|
+
currentMode = (environment) => validateAdjustableMode(environment["DSH_PERMISSION_MODE"] ?? WORKSPACE_WRITE_PERMISSION_MODE);
|
|
22035
|
+
apply = (environment, permissionMode) => {
|
|
22036
|
+
if (permissionMode === AGENT_DEFAULT_PERMISSION_MODE) {
|
|
22037
|
+
return Object.freeze({ ...environment });
|
|
22038
|
+
}
|
|
22039
|
+
return Object.freeze({
|
|
22040
|
+
...environment,
|
|
22041
|
+
DSH_PERMISSION_MODE: validateAdjustableMode(permissionMode),
|
|
22042
|
+
[PERMISSION_MODE_MARKER]: permissionMode
|
|
22043
|
+
});
|
|
22044
|
+
};
|
|
22045
|
+
};
|
|
22046
|
+
function record2(value) {
|
|
22047
|
+
if (value === void 0) {
|
|
22048
|
+
return {};
|
|
22049
|
+
}
|
|
22050
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
22051
|
+
throw new AgentPermissionConfigurationError("The OpenCode inline configuration is invalid");
|
|
22052
|
+
}
|
|
22053
|
+
return Object.fromEntries(Object.entries(value));
|
|
22054
|
+
}
|
|
22055
|
+
function openCodeConfiguration(environment) {
|
|
22056
|
+
const encoded = environment["OPENCODE_CONFIG_CONTENT"];
|
|
22057
|
+
if (encoded === void 0 || encoded.length === 0) {
|
|
22058
|
+
return {};
|
|
22059
|
+
}
|
|
22060
|
+
try {
|
|
22061
|
+
return record2(JSON.parse(encoded));
|
|
22062
|
+
} catch (cause) {
|
|
22063
|
+
if (cause instanceof AgentPermissionConfigurationError) {
|
|
22064
|
+
throw cause;
|
|
22065
|
+
}
|
|
22066
|
+
throw new AgentPermissionConfigurationError("The OpenCode inline configuration is invalid", { cause });
|
|
22067
|
+
}
|
|
22068
|
+
}
|
|
22069
|
+
function openCodePermission(permissionMode) {
|
|
22070
|
+
if (permissionMode === READ_ONLY_PERMISSION_MODE) {
|
|
22071
|
+
return {
|
|
22072
|
+
"*": "deny",
|
|
22073
|
+
glob: "allow",
|
|
22074
|
+
grep: "allow",
|
|
22075
|
+
lsp: "allow",
|
|
22076
|
+
read: "allow",
|
|
22077
|
+
skill: "allow"
|
|
22078
|
+
};
|
|
22079
|
+
}
|
|
22080
|
+
if (permissionMode === WORKSPACE_WRITE_PERMISSION_MODE) {
|
|
22081
|
+
return {
|
|
22082
|
+
"*": "allow",
|
|
22083
|
+
external_directory: "ask"
|
|
22084
|
+
};
|
|
22085
|
+
}
|
|
22086
|
+
return "allow";
|
|
22087
|
+
}
|
|
22088
|
+
var OpenCodePermissionProfile = class extends AgentPermissionProfile {
|
|
22089
|
+
description = "Controls the local side effects allowed for this Agent session.";
|
|
22090
|
+
values = adjustablePermissionValues;
|
|
22091
|
+
currentMode = (environment) => validateAdjustableMode(environment[PERMISSION_MODE_MARKER] ?? AGENT_DEFAULT_PERMISSION_MODE);
|
|
22092
|
+
apply = (environment, permissionMode) => {
|
|
22093
|
+
const validated = validateAdjustableMode(permissionMode);
|
|
22094
|
+
if (validated === AGENT_DEFAULT_PERMISSION_MODE) {
|
|
22095
|
+
return Object.freeze({ ...environment });
|
|
22096
|
+
}
|
|
22097
|
+
return Object.freeze({
|
|
22098
|
+
...environment,
|
|
22099
|
+
OPENCODE_CONFIG_CONTENT: JSON.stringify({
|
|
22100
|
+
...openCodeConfiguration(environment),
|
|
22101
|
+
permission: openCodePermission(validated)
|
|
22102
|
+
}),
|
|
22103
|
+
[PERMISSION_MODE_MARKER]: validated
|
|
22104
|
+
});
|
|
22105
|
+
};
|
|
22106
|
+
};
|
|
22107
|
+
var agentManagedPermissionProfile = new AgentManagedPermissionProfile();
|
|
22108
|
+
var deepSeekHarnessPermissionProfile = new DeepSeekHarnessPermissionProfile();
|
|
22109
|
+
var openCodePermissionProfile = new OpenCodePermissionProfile();
|
|
22110
|
+
var piPermissionProfile = new PiPermissionProfile();
|
|
22111
|
+
function permissionProfileForAgent(agentId) {
|
|
22112
|
+
if (agentId === "deepseek-harness") {
|
|
22113
|
+
return deepSeekHarnessPermissionProfile;
|
|
22114
|
+
}
|
|
22115
|
+
if (agentId === "opencode") {
|
|
22116
|
+
return openCodePermissionProfile;
|
|
22117
|
+
}
|
|
22118
|
+
if (agentId === "pi") {
|
|
22119
|
+
return piPermissionProfile;
|
|
22120
|
+
}
|
|
22121
|
+
return agentManagedPermissionProfile;
|
|
22122
|
+
}
|
|
22123
|
+
|
|
22115
22124
|
// src/agent-catalog/local-agent.ts
|
|
22116
22125
|
function readTrustedIdentity(path2) {
|
|
22117
22126
|
const resolvedPath = realpathSync(path2);
|
|
@@ -22125,7 +22134,7 @@ function readTrustedIdentity(path2) {
|
|
|
22125
22134
|
metadata.ctimeMs
|
|
22126
22135
|
);
|
|
22127
22136
|
}
|
|
22128
|
-
var LocalAgentDefinition = class {
|
|
22137
|
+
var LocalAgentDefinition = class _LocalAgentDefinition {
|
|
22129
22138
|
adapterIdentity;
|
|
22130
22139
|
adapterPath;
|
|
22131
22140
|
adapterVersion;
|
|
@@ -22137,8 +22146,9 @@ var LocalAgentDefinition = class {
|
|
|
22137
22146
|
environment;
|
|
22138
22147
|
id;
|
|
22139
22148
|
label;
|
|
22149
|
+
permissionProfile;
|
|
22140
22150
|
promptTimeoutMilliseconds;
|
|
22141
|
-
constructor(id, label, command, arguments_, environment = {}, adapterVersion = "", agentVersion = "", adapterIdentity = readTrustedIdentity(command), agentIdentity = adapterIdentity, promptTimeoutMilliseconds = 30 * 60 * 1e3, capabilities = unsupportedSessionCapabilities()) {
|
|
22151
|
+
constructor(id, label, command, arguments_, environment = {}, adapterVersion = "", agentVersion = "", adapterIdentity = readTrustedIdentity(command), agentIdentity = adapterIdentity, promptTimeoutMilliseconds = 30 * 60 * 1e3, capabilities = unsupportedSessionCapabilities(), permissionProfile = permissionProfileForAgent(id)) {
|
|
22142
22152
|
if (!Number.isSafeInteger(promptTimeoutMilliseconds) || promptTimeoutMilliseconds < 1) {
|
|
22143
22153
|
throw new Error("The local Agent prompt deadline is invalid");
|
|
22144
22154
|
}
|
|
@@ -22150,11 +22160,31 @@ var LocalAgentDefinition = class {
|
|
|
22150
22160
|
this.capabilities = Object.freeze({ ...capabilities });
|
|
22151
22161
|
this.id = id;
|
|
22152
22162
|
this.label = label;
|
|
22163
|
+
this.permissionProfile = permissionProfile;
|
|
22153
22164
|
this.promptTimeoutMilliseconds = promptTimeoutMilliseconds;
|
|
22154
22165
|
this.command = adapterIdentity.realPath;
|
|
22155
22166
|
this.arguments = Object.freeze([...arguments_]);
|
|
22156
|
-
this.environment =
|
|
22167
|
+
this.environment = permissionProfile.apply(environment, permissionProfile.currentMode(environment));
|
|
22157
22168
|
}
|
|
22169
|
+
withPermissionMode = (permissionMode) => {
|
|
22170
|
+
if (permissionMode === AGENT_DEFAULT_PERMISSION_MODE && this.permissionProfile.currentMode(this.environment) === AGENT_DEFAULT_PERMISSION_MODE) {
|
|
22171
|
+
return this;
|
|
22172
|
+
}
|
|
22173
|
+
return new _LocalAgentDefinition(
|
|
22174
|
+
this.id,
|
|
22175
|
+
this.label,
|
|
22176
|
+
this.command,
|
|
22177
|
+
this.arguments,
|
|
22178
|
+
this.permissionProfile.apply(this.environment, permissionMode),
|
|
22179
|
+
this.adapterVersion,
|
|
22180
|
+
this.agentVersion,
|
|
22181
|
+
this.adapterIdentity,
|
|
22182
|
+
this.agentIdentity,
|
|
22183
|
+
this.promptTimeoutMilliseconds,
|
|
22184
|
+
this.capabilities,
|
|
22185
|
+
this.permissionProfile
|
|
22186
|
+
);
|
|
22187
|
+
};
|
|
22158
22188
|
};
|
|
22159
22189
|
var InstallableAgentDefinition = class {
|
|
22160
22190
|
id;
|
|
@@ -30464,8 +30494,70 @@ function normalizeConfigOptions(value, modes) {
|
|
|
30464
30494
|
}
|
|
30465
30495
|
return normalized.slice(0, 100);
|
|
30466
30496
|
}
|
|
30497
|
+
function insertRequiredOption(current, required2, afterCategory = "") {
|
|
30498
|
+
if (current.some((option2) => option2.id === required2.id || option2.category === required2.category)) {
|
|
30499
|
+
return current;
|
|
30500
|
+
}
|
|
30501
|
+
if (current.length < MAXIMUM_CONFIG_OPTIONS) {
|
|
30502
|
+
if (afterCategory.length === 0) {
|
|
30503
|
+
return [required2, ...current];
|
|
30504
|
+
}
|
|
30505
|
+
const index3 = current.findIndex((option2) => option2.category === afterCategory);
|
|
30506
|
+
if (index3 < 0) {
|
|
30507
|
+
return [...current, required2];
|
|
30508
|
+
}
|
|
30509
|
+
return [...current.slice(0, index3 + 1), required2, ...current.slice(index3 + 1)];
|
|
30510
|
+
}
|
|
30511
|
+
if (afterCategory.length === 0) {
|
|
30512
|
+
return [required2, ...current.slice(0, MAXIMUM_CONFIG_OPTIONS - 1)];
|
|
30513
|
+
}
|
|
30514
|
+
const index2 = current.findIndex((option2) => option2.category === afterCategory);
|
|
30515
|
+
if (index2 < 0) {
|
|
30516
|
+
return [...current.slice(0, MAXIMUM_CONFIG_OPTIONS - 1), required2];
|
|
30517
|
+
}
|
|
30518
|
+
if (index2 < MAXIMUM_CONFIG_OPTIONS - 1) {
|
|
30519
|
+
return [...current.slice(0, index2 + 1), required2, ...current.slice(index2 + 1, MAXIMUM_CONFIG_OPTIONS - 1)];
|
|
30520
|
+
}
|
|
30521
|
+
const anchor2 = current[index2];
|
|
30522
|
+
if (anchor2 === void 0) {
|
|
30523
|
+
throw new SessionConfigProtocolError("The required Agent execution setting is unavailable");
|
|
30524
|
+
}
|
|
30525
|
+
return [...current.slice(0, MAXIMUM_CONFIG_OPTIONS - 2), anchor2, required2];
|
|
30526
|
+
}
|
|
30527
|
+
function validRequiredSelect(option2) {
|
|
30528
|
+
return option2.type === "select" && option2.currentValue.length > 0 && option2.values.some((value) => value.value === option2.currentValue);
|
|
30529
|
+
}
|
|
30530
|
+
function ensureModelOption(current) {
|
|
30531
|
+
const existing = current.find((option2) => option2.id === "model" || option2.category === "model");
|
|
30532
|
+
if (existing !== void 0 && validRequiredSelect(existing)) {
|
|
30533
|
+
return current;
|
|
30534
|
+
}
|
|
30535
|
+
const unavailable = {
|
|
30536
|
+
booleanValue: false,
|
|
30537
|
+
category: "model",
|
|
30538
|
+
currentValue: AGENT_DEFAULT_REASONING_EFFORT,
|
|
30539
|
+
description: "This Agent does not expose an adjustable model.",
|
|
30540
|
+
id: "model",
|
|
30541
|
+
name: "Model",
|
|
30542
|
+
type: "select",
|
|
30543
|
+
values: [
|
|
30544
|
+
{
|
|
30545
|
+
description: "Selected by the Agent",
|
|
30546
|
+
groupId: "",
|
|
30547
|
+
groupName: "",
|
|
30548
|
+
name: "Agent default",
|
|
30549
|
+
value: AGENT_DEFAULT_REASONING_EFFORT
|
|
30550
|
+
}
|
|
30551
|
+
]
|
|
30552
|
+
};
|
|
30553
|
+
return insertRequiredOption(
|
|
30554
|
+
current.filter((option2) => option2.id !== "model" && option2.category !== "model"),
|
|
30555
|
+
unavailable
|
|
30556
|
+
);
|
|
30557
|
+
}
|
|
30467
30558
|
function ensureReasoningEffortOption(current) {
|
|
30468
|
-
|
|
30559
|
+
const existing = current.find((option2) => option2.id === "reasoning_effort" || option2.category === "thought_level");
|
|
30560
|
+
if (existing !== void 0 && validRequiredSelect(existing)) {
|
|
30469
30561
|
return current;
|
|
30470
30562
|
}
|
|
30471
30563
|
const unavailable = {
|
|
@@ -30486,28 +30578,27 @@ function ensureReasoningEffortOption(current) {
|
|
|
30486
30578
|
}
|
|
30487
30579
|
]
|
|
30488
30580
|
};
|
|
30489
|
-
|
|
30490
|
-
|
|
30491
|
-
|
|
30492
|
-
|
|
30493
|
-
|
|
30494
|
-
|
|
30495
|
-
|
|
30496
|
-
|
|
30497
|
-
|
|
30498
|
-
|
|
30499
|
-
|
|
30500
|
-
|
|
30501
|
-
|
|
30502
|
-
|
|
30503
|
-
|
|
30504
|
-
|
|
30505
|
-
}
|
|
30506
|
-
const model = current[modelIndex];
|
|
30507
|
-
if (model === void 0) {
|
|
30508
|
-
return [...current.slice(0, MAXIMUM_CONFIG_OPTIONS - 1), unavailable];
|
|
30581
|
+
return insertRequiredOption(
|
|
30582
|
+
current.filter((option2) => option2.id !== "reasoning_effort" && option2.category !== "thought_level"),
|
|
30583
|
+
unavailable,
|
|
30584
|
+
"model"
|
|
30585
|
+
);
|
|
30586
|
+
}
|
|
30587
|
+
function ensureRequiredExecutionOptions(current, permission) {
|
|
30588
|
+
const normalized = ensureReasoningEffortOption(ensureModelOption(current));
|
|
30589
|
+
const model = normalized.find(
|
|
30590
|
+
(option2) => (option2.id === "model" || option2.category === "model") && validRequiredSelect(option2)
|
|
30591
|
+
);
|
|
30592
|
+
const reasoningEffort = normalized.find(
|
|
30593
|
+
(option2) => (option2.id === "reasoning_effort" || option2.category === "thought_level") && validRequiredSelect(option2)
|
|
30594
|
+
);
|
|
30595
|
+
if (model === void 0 || reasoningEffort === void 0) {
|
|
30596
|
+
throw new SessionConfigProtocolError("The required Agent execution settings are unavailable");
|
|
30509
30597
|
}
|
|
30510
|
-
|
|
30598
|
+
const optional2 = normalized.filter(
|
|
30599
|
+
(option2) => option2.id !== permission.id && option2.category !== permission.category && option2.id !== "model" && option2.category !== "model" && option2.id !== "reasoning_effort" && option2.category !== "thought_level"
|
|
30600
|
+
);
|
|
30601
|
+
return [permission, model, reasoningEffort, ...optional2].slice(0, MAXIMUM_CONFIG_OPTIONS);
|
|
30511
30602
|
}
|
|
30512
30603
|
function normalizeStandardLifecycle(response) {
|
|
30513
30604
|
const lifecycle = isRecord5(response) ? response : {};
|
|
@@ -31582,6 +31673,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
31582
31673
|
#preSessionUpdates = [];
|
|
31583
31674
|
#processExit;
|
|
31584
31675
|
#metrics;
|
|
31676
|
+
#permissionProfile;
|
|
31585
31677
|
#sessionConfigProtocol;
|
|
31586
31678
|
#store;
|
|
31587
31679
|
#verifiedAgentVersion;
|
|
@@ -31623,6 +31715,7 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
31623
31715
|
this.#getObserver = getObserver;
|
|
31624
31716
|
this.#mobiusSessionId = mobiusSessionId;
|
|
31625
31717
|
this.#metrics = metrics;
|
|
31718
|
+
this.#permissionProfile = agent.permissionProfile;
|
|
31626
31719
|
this.#sessionConfigProtocol = sessionConfigProtocolForAgent(agent.id);
|
|
31627
31720
|
this.#store = store;
|
|
31628
31721
|
this.#verifiedAgentVersion = agent.agentVersion;
|
|
@@ -32055,7 +32148,10 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
32055
32148
|
this.selectNativeSession(created.sessionId);
|
|
32056
32149
|
lifecycleResponse = created;
|
|
32057
32150
|
}
|
|
32058
|
-
this.#configOptions =
|
|
32151
|
+
this.#configOptions = ensureRequiredExecutionOptions(
|
|
32152
|
+
this.#sessionConfigProtocol.normalizeLifecycle(lifecycleResponse),
|
|
32153
|
+
this.#permissionProfile.option(this.#environment)
|
|
32154
|
+
);
|
|
32059
32155
|
await this.#updateTail;
|
|
32060
32156
|
signal.throwIfAborted();
|
|
32061
32157
|
if (this.#prompted) {
|
|
@@ -32158,7 +32254,10 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
32158
32254
|
);
|
|
32159
32255
|
await this.#updateTail;
|
|
32160
32256
|
if (this.#configRevision === configRevision) {
|
|
32161
|
-
this.#configOptions =
|
|
32257
|
+
this.#configOptions = ensureRequiredExecutionOptions(
|
|
32258
|
+
configured,
|
|
32259
|
+
this.#permissionProfile.option(this.#environment)
|
|
32260
|
+
);
|
|
32162
32261
|
}
|
|
32163
32262
|
} catch (error62) {
|
|
32164
32263
|
if (error62 instanceof SessionConfigProtocolError) {
|
|
@@ -32631,9 +32730,9 @@ var AcpProcessSession = class _AcpProcessSession {
|
|
|
32631
32730
|
return;
|
|
32632
32731
|
}
|
|
32633
32732
|
if (update.sessionUpdate === "config_option_update") {
|
|
32634
|
-
this.#configOptions =
|
|
32635
|
-
this.#configOptions,
|
|
32636
|
-
|
|
32733
|
+
this.#configOptions = ensureRequiredExecutionOptions(
|
|
32734
|
+
this.#sessionConfigProtocol.normalizeUpdate(this.#configOptions, update.configOptions),
|
|
32735
|
+
this.#permissionProfile.option(this.#environment)
|
|
32637
32736
|
);
|
|
32638
32737
|
this.#configRevision += 1;
|
|
32639
32738
|
await this.emitConfigUpdate();
|
|
@@ -33171,6 +33270,9 @@ var AcpSessionManager = class {
|
|
|
33171
33270
|
);
|
|
33172
33271
|
try {
|
|
33173
33272
|
for (const desired of desiredConfigOptions) {
|
|
33273
|
+
if (desired.id === PERMISSION_MODE_CONFIG_ID) {
|
|
33274
|
+
continue;
|
|
33275
|
+
}
|
|
33174
33276
|
const current = runtime.prepared().configOptions.find((option2) => option2.id === desired.id);
|
|
33175
33277
|
if (current === void 0 || current.type !== desired.type) {
|
|
33176
33278
|
continue;
|
|
@@ -33363,6 +33465,30 @@ var AcpSessionManager = class {
|
|
|
33363
33465
|
this.#beginSessionUse(options.sessionId);
|
|
33364
33466
|
try {
|
|
33365
33467
|
const runtime = await this.ensureSession(options);
|
|
33468
|
+
if (options.configId === PERMISSION_MODE_CONFIG_ID) {
|
|
33469
|
+
const permission = runtime.prepared().configOptions.find((candidate) => candidate.id === PERMISSION_MODE_CONFIG_ID);
|
|
33470
|
+
if (permission === void 0 || permission.type !== "select" || options.valueType !== "select" || permission.values.length < 2 || !permission.values.some((value) => value.value === options.value)) {
|
|
33471
|
+
throw new AcpExecutionError(
|
|
33472
|
+
"The requested Agent permission mode is unavailable",
|
|
33473
|
+
{},
|
|
33474
|
+
"invalid_session_configuration"
|
|
33475
|
+
);
|
|
33476
|
+
}
|
|
33477
|
+
if (permission.currentValue === options.value) {
|
|
33478
|
+
return runtime.prepared().configOptions;
|
|
33479
|
+
}
|
|
33480
|
+
try {
|
|
33481
|
+
return (await this.prepareExecutionSession({
|
|
33482
|
+
...options,
|
|
33483
|
+
agent: options.agent.withPermissionMode(options.value)
|
|
33484
|
+
})).configOptions;
|
|
33485
|
+
} catch (error62) {
|
|
33486
|
+
if (error62 instanceof AgentPermissionConfigurationError) {
|
|
33487
|
+
throw new AcpExecutionError(error62.message, { cause: error62 }, error62.code);
|
|
33488
|
+
}
|
|
33489
|
+
throw error62;
|
|
33490
|
+
}
|
|
33491
|
+
}
|
|
33366
33492
|
return await runtime.configure(options);
|
|
33367
33493
|
} finally {
|
|
33368
33494
|
this.#endSessionUse(options.sessionId);
|
|
@@ -33856,7 +33982,7 @@ var AuditStore = class {
|
|
|
33856
33982
|
this.database.exec("ALTER TABLE audit_events ADD COLUMN details_json TEXT NOT NULL DEFAULT '{}'");
|
|
33857
33983
|
}
|
|
33858
33984
|
}
|
|
33859
|
-
record(
|
|
33985
|
+
record(record4) {
|
|
33860
33986
|
this.database.prepare(
|
|
33861
33987
|
`
|
|
33862
33988
|
INSERT INTO audit_events (
|
|
@@ -33869,10 +33995,10 @@ var AuditStore = class {
|
|
|
33869
33995
|
`
|
|
33870
33996
|
).run(
|
|
33871
33997
|
(/* @__PURE__ */ new Date()).toISOString(),
|
|
33872
|
-
|
|
33873
|
-
|
|
33874
|
-
|
|
33875
|
-
JSON.stringify(
|
|
33998
|
+
record4.event,
|
|
33999
|
+
record4.commandId,
|
|
34000
|
+
record4.sessionId,
|
|
34001
|
+
JSON.stringify(record4.details ?? {})
|
|
33876
34002
|
);
|
|
33877
34003
|
}
|
|
33878
34004
|
close() {
|
|
@@ -33892,10 +34018,7 @@ var LocalAuthorizationError = class extends Error {
|
|
|
33892
34018
|
// src/bots/bot-execution-context.ts
|
|
33893
34019
|
import { randomBytes } from "node:crypto";
|
|
33894
34020
|
|
|
33895
|
-
// src/bots/local-bot-
|
|
33896
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
33897
|
-
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
33898
|
-
var LOCAL_BOT_GRANT_LIFETIME_MILLISECONDS = 90 * 24 * 60 * 60 * 1e3;
|
|
34021
|
+
// src/bots/local-bot-execution-authorizer.ts
|
|
33899
34022
|
var LocalBotAuthorizationError = class extends Error {
|
|
33900
34023
|
code;
|
|
33901
34024
|
constructor(code, message, options = {}) {
|
|
@@ -33904,278 +34027,40 @@ var LocalBotAuthorizationError = class extends Error {
|
|
|
33904
34027
|
this.name = "LocalBotAuthorizationError";
|
|
33905
34028
|
}
|
|
33906
34029
|
};
|
|
33907
|
-
var
|
|
34030
|
+
var AuthorizedLocalBotExecution = class {
|
|
33908
34031
|
agent;
|
|
33909
|
-
agentIdentityDigest;
|
|
33910
|
-
allowedDeliveryTargetIds;
|
|
33911
34032
|
behaviorDigest;
|
|
33912
34033
|
behaviorRevisionId;
|
|
33913
34034
|
bindingId;
|
|
33914
34035
|
bindingRevision;
|
|
33915
34036
|
botId;
|
|
33916
|
-
|
|
33917
|
-
localGrantId;
|
|
33918
|
-
revocationEpoch;
|
|
33919
|
-
workspaceIdentityDigest;
|
|
34037
|
+
executionConfiguration;
|
|
33920
34038
|
workspacePath;
|
|
33921
34039
|
workspaceRef;
|
|
33922
|
-
constructor(
|
|
33923
|
-
this.localGrantId = localGrantId;
|
|
33924
|
-
this.botId = botId;
|
|
33925
|
-
this.behaviorRevisionId = behaviorRevisionId;
|
|
33926
|
-
this.behaviorDigest = behaviorDigest;
|
|
33927
|
-
this.bindingId = bindingId;
|
|
33928
|
-
this.bindingRevision = bindingRevision;
|
|
34040
|
+
constructor(command, agent, workspacePath) {
|
|
33929
34041
|
this.agent = agent;
|
|
33930
|
-
this.
|
|
33931
|
-
this.
|
|
34042
|
+
this.behaviorDigest = command.behaviorDigest;
|
|
34043
|
+
this.behaviorRevisionId = command.behaviorRevisionId;
|
|
34044
|
+
this.bindingId = command.bindingId;
|
|
34045
|
+
this.bindingRevision = command.bindingRevision;
|
|
34046
|
+
this.botId = command.botId;
|
|
34047
|
+
this.executionConfiguration = command.executionConfiguration;
|
|
33932
34048
|
this.workspacePath = workspacePath;
|
|
33933
|
-
this.
|
|
33934
|
-
this.allowedDeliveryTargetIds = Object.freeze([...allowedDeliveryTargetIds]);
|
|
33935
|
-
this.expiresAt = expiresAt;
|
|
33936
|
-
this.revocationEpoch = revocationEpoch;
|
|
34049
|
+
this.workspaceRef = command.directoryId;
|
|
33937
34050
|
}
|
|
33938
34051
|
};
|
|
33939
|
-
|
|
33940
|
-
|
|
33941
|
-
}
|
|
33942
|
-
function agentDigest(agent) {
|
|
33943
|
-
return digest(
|
|
33944
|
-
JSON.stringify({
|
|
33945
|
-
adapter: agent.adapterIdentity,
|
|
33946
|
-
agent: agent.agentIdentity,
|
|
33947
|
-
agentVersion: agent.agentVersion,
|
|
33948
|
-
arguments: agent.arguments,
|
|
33949
|
-
id: agent.id
|
|
33950
|
-
})
|
|
33951
|
-
);
|
|
33952
|
-
}
|
|
33953
|
-
function workspaceDigest(path2) {
|
|
33954
|
-
return digest(path2);
|
|
33955
|
-
}
|
|
33956
|
-
function exactTargets(left, right) {
|
|
33957
|
-
if (left.length !== right.length) {
|
|
33958
|
-
return false;
|
|
33959
|
-
}
|
|
33960
|
-
const expected = [...left].sort();
|
|
33961
|
-
const actual = [...right].sort();
|
|
33962
|
-
return expected.every((target, index2) => target === actual[index2]);
|
|
33963
|
-
}
|
|
33964
|
-
function exactSessionConfigurations(left, right) {
|
|
33965
|
-
if (left.length !== right.length) {
|
|
33966
|
-
return false;
|
|
33967
|
-
}
|
|
33968
|
-
const expected = new Map(left.map((selection) => [selection.configId, selection]));
|
|
33969
|
-
return right.every((selection) => {
|
|
33970
|
-
const approved = expected.get(selection.configId);
|
|
33971
|
-
return approved !== void 0 && approved.booleanValue === selection.booleanValue && approved.value === selection.value && approved.valueType === selection.valueType;
|
|
33972
|
-
});
|
|
33973
|
-
}
|
|
33974
|
-
function rowString(row, key) {
|
|
33975
|
-
const value = Reflect.get(row, key);
|
|
33976
|
-
if (typeof value !== "string") {
|
|
33977
|
-
throw new LocalBotAuthorizationError("local_grant_invalid", "The local Bot grant is invalid");
|
|
33978
|
-
}
|
|
33979
|
-
return value;
|
|
33980
|
-
}
|
|
33981
|
-
function rowInteger(row, key) {
|
|
33982
|
-
const value = Reflect.get(row, key);
|
|
33983
|
-
if (typeof value !== "number" || !Number.isSafeInteger(value)) {
|
|
33984
|
-
throw new LocalBotAuthorizationError("local_grant_invalid", "The local Bot grant is invalid");
|
|
33985
|
-
}
|
|
33986
|
-
return value;
|
|
33987
|
-
}
|
|
33988
|
-
function rowHasInteger(row, key) {
|
|
33989
|
-
const value = Reflect.get(row, key);
|
|
33990
|
-
if (value === null) {
|
|
33991
|
-
return false;
|
|
33992
|
-
}
|
|
33993
|
-
if (typeof value !== "number" || !Number.isSafeInteger(value)) {
|
|
33994
|
-
throw new LocalBotAuthorizationError("local_grant_invalid", "The local Bot grant is invalid");
|
|
33995
|
-
}
|
|
33996
|
-
return true;
|
|
33997
|
-
}
|
|
33998
|
-
function parseTargets(encoded) {
|
|
33999
|
-
let value;
|
|
34000
|
-
try {
|
|
34001
|
-
value = JSON.parse(encoded);
|
|
34002
|
-
} catch (cause) {
|
|
34003
|
-
throw new LocalBotAuthorizationError("local_grant_invalid", "The local Bot grant is invalid", { cause });
|
|
34004
|
-
}
|
|
34005
|
-
if (!Array.isArray(value) || value.some((target) => typeof target !== "string")) {
|
|
34006
|
-
throw new LocalBotAuthorizationError("local_grant_invalid", "The local Bot grant is invalid");
|
|
34007
|
-
}
|
|
34008
|
-
return value.filter((target) => typeof target === "string");
|
|
34009
|
-
}
|
|
34010
|
-
function parseSessionConfigurations(encoded) {
|
|
34011
|
-
let value;
|
|
34012
|
-
try {
|
|
34013
|
-
value = JSON.parse(encoded);
|
|
34014
|
-
return decodeSessionConfigurationSelections(value);
|
|
34015
|
-
} catch (cause) {
|
|
34016
|
-
throw new LocalBotAuthorizationError("local_grant_invalid", "The local Bot grant is invalid", { cause });
|
|
34017
|
-
}
|
|
34018
|
-
}
|
|
34019
|
-
var LocalBotGrantStore = class {
|
|
34020
|
-
#database;
|
|
34021
|
-
constructor(path2) {
|
|
34022
|
-
this.#database = new DatabaseSync3(path2);
|
|
34023
|
-
this.#database.exec(`
|
|
34024
|
-
CREATE TABLE IF NOT EXISTS local_bot_grants (
|
|
34025
|
-
local_grant_id TEXT PRIMARY KEY,
|
|
34026
|
-
bot_id TEXT NOT NULL,
|
|
34027
|
-
behavior_revision_id TEXT NOT NULL,
|
|
34028
|
-
behavior_digest TEXT NOT NULL,
|
|
34029
|
-
binding_id TEXT NOT NULL UNIQUE,
|
|
34030
|
-
binding_revision INTEGER NOT NULL,
|
|
34031
|
-
agent_ref TEXT NOT NULL,
|
|
34032
|
-
agent_identity_digest TEXT NOT NULL,
|
|
34033
|
-
workspace_ref TEXT NOT NULL,
|
|
34034
|
-
workspace_path TEXT NOT NULL,
|
|
34035
|
-
workspace_identity_digest TEXT NOT NULL,
|
|
34036
|
-
allowed_delivery_target_ids_json TEXT NOT NULL,
|
|
34037
|
-
unattended_policy_json TEXT NOT NULL,
|
|
34038
|
-
created_at INTEGER NOT NULL,
|
|
34039
|
-
expires_at INTEGER NOT NULL,
|
|
34040
|
-
revocation_epoch INTEGER NOT NULL DEFAULT 0,
|
|
34041
|
-
revoked_at INTEGER
|
|
34042
|
-
) STRICT;
|
|
34043
|
-
CREATE TABLE IF NOT EXISTS local_bot_binding_resolutions (
|
|
34044
|
-
request_id TEXT PRIMARY KEY,
|
|
34045
|
-
binding_id TEXT NOT NULL,
|
|
34046
|
-
local_grant_id TEXT NOT NULL,
|
|
34047
|
-
resolved_at INTEGER NOT NULL,
|
|
34048
|
-
result TEXT NOT NULL CHECK (result IN ('approved', 'unavailable')),
|
|
34049
|
-
error_code TEXT,
|
|
34050
|
-
error_message TEXT
|
|
34051
|
-
) STRICT;
|
|
34052
|
-
CREATE TABLE IF NOT EXISTS local_bot_grant_configurations (
|
|
34053
|
-
local_grant_id TEXT PRIMARY KEY,
|
|
34054
|
-
session_configurations_json TEXT NOT NULL
|
|
34055
|
-
) STRICT;
|
|
34056
|
-
`);
|
|
34057
|
-
}
|
|
34058
|
-
approve = async (request, catalog, directories, bindingAuthorityId, now, signal) => {
|
|
34052
|
+
var LocalBotExecutionAuthorizer = class {
|
|
34053
|
+
authorize = async (command, catalog, directories, bindingAuthorityId, signal) => {
|
|
34059
34054
|
signal.throwIfAborted();
|
|
34060
|
-
|
|
34061
|
-
`SELECT grants.* FROM local_bot_binding_resolutions AS resolutions
|
|
34062
|
-
INNER JOIN local_bot_grants AS grants
|
|
34063
|
-
ON grants.local_grant_id = resolutions.local_grant_id
|
|
34064
|
-
WHERE resolutions.request_id = ? AND resolutions.binding_id = ?
|
|
34065
|
-
AND resolutions.result = 'approved'`
|
|
34066
|
-
).get(request.requestId, request.bindingId);
|
|
34067
|
-
if (existing !== void 0) {
|
|
34068
|
-
return new BotExecutionBindingApprovedEvent(
|
|
34069
|
-
request.requestId,
|
|
34070
|
-
request.botId,
|
|
34071
|
-
request.behaviorRevisionId,
|
|
34072
|
-
request.bindingId,
|
|
34073
|
-
request.bindingRevision,
|
|
34074
|
-
rowString(existing, "local_grant_id"),
|
|
34075
|
-
rowString(existing, "agent_identity_digest"),
|
|
34076
|
-
rowString(existing, "workspace_identity_digest")
|
|
34077
|
-
);
|
|
34078
|
-
}
|
|
34079
|
-
const resolved = await this.resolveProposal(request, catalog, directories, bindingAuthorityId, signal);
|
|
34080
|
-
const localGrantId = `lbg_${randomUUID()}`;
|
|
34081
|
-
const expiresAt = now + LOCAL_BOT_GRANT_LIFETIME_MILLISECONDS;
|
|
34082
|
-
this.#database.exec("BEGIN IMMEDIATE");
|
|
34055
|
+
let agent;
|
|
34083
34056
|
try {
|
|
34084
|
-
|
|
34085
|
-
`INSERT INTO local_bot_grants (
|
|
34086
|
-
local_grant_id, bot_id, behavior_revision_id, behavior_digest,
|
|
34087
|
-
binding_id, binding_revision, agent_ref,
|
|
34088
|
-
agent_identity_digest, workspace_ref, workspace_path,
|
|
34089
|
-
workspace_identity_digest, allowed_delivery_target_ids_json,
|
|
34090
|
-
unattended_policy_json, created_at, expires_at
|
|
34091
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
34092
|
-
).run(
|
|
34093
|
-
localGrantId,
|
|
34094
|
-
request.botId,
|
|
34095
|
-
request.behaviorRevisionId,
|
|
34096
|
-
request.behaviorDigest,
|
|
34097
|
-
request.bindingId,
|
|
34098
|
-
request.bindingRevision,
|
|
34099
|
-
request.agentRef,
|
|
34100
|
-
resolved.agentIdentityDigest,
|
|
34101
|
-
request.workspaceRef,
|
|
34102
|
-
resolved.workspacePath,
|
|
34103
|
-
resolved.workspaceIdentityDigest,
|
|
34104
|
-
JSON.stringify(request.allowedDeliveryTargets.map((target) => target.deliveryTargetId)),
|
|
34105
|
-
JSON.stringify({ localSideEffects: "owner-approval-required" }),
|
|
34106
|
-
now,
|
|
34107
|
-
expiresAt
|
|
34108
|
-
);
|
|
34109
|
-
this.#database.prepare(
|
|
34110
|
-
`INSERT INTO local_bot_grant_configurations (
|
|
34111
|
-
local_grant_id, session_configurations_json
|
|
34112
|
-
) VALUES (?, ?)`
|
|
34113
|
-
).run(localGrantId, JSON.stringify(request.sessionConfigurations));
|
|
34114
|
-
this.#database.prepare(
|
|
34115
|
-
`INSERT INTO local_bot_binding_resolutions (
|
|
34116
|
-
request_id, binding_id, local_grant_id, resolved_at, result
|
|
34117
|
-
) VALUES (?, ?, ?, ?, 'approved')`
|
|
34118
|
-
).run(request.requestId, request.bindingId, localGrantId, now);
|
|
34119
|
-
this.#database.exec("COMMIT");
|
|
34057
|
+
agent = catalog.find(command.agentId).withPermissionMode(command.executionConfiguration.permissionMode);
|
|
34120
34058
|
} catch (cause) {
|
|
34121
|
-
|
|
34059
|
+
if (cause instanceof AgentPermissionConfigurationError) {
|
|
34060
|
+
throw new LocalBotAuthorizationError("binding_incompatible", cause.message, { cause });
|
|
34061
|
+
}
|
|
34122
34062
|
throw cause;
|
|
34123
34063
|
}
|
|
34124
|
-
signal.throwIfAborted();
|
|
34125
|
-
return new BotExecutionBindingApprovedEvent(
|
|
34126
|
-
request.requestId,
|
|
34127
|
-
request.botId,
|
|
34128
|
-
request.behaviorRevisionId,
|
|
34129
|
-
request.bindingId,
|
|
34130
|
-
request.bindingRevision,
|
|
34131
|
-
localGrantId,
|
|
34132
|
-
resolved.agentIdentityDigest,
|
|
34133
|
-
resolved.workspaceIdentityDigest
|
|
34134
|
-
);
|
|
34135
|
-
};
|
|
34136
|
-
resolveExecution = async (command, catalog, directories, bindingAuthorityId, now, signal) => {
|
|
34137
|
-
signal.throwIfAborted();
|
|
34138
|
-
const row = this.#database.prepare(
|
|
34139
|
-
`SELECT grants.*, COALESCE(configurations.session_configurations_json, '[]')
|
|
34140
|
-
AS session_configurations_json
|
|
34141
|
-
FROM local_bot_grants AS grants
|
|
34142
|
-
LEFT JOIN local_bot_grant_configurations AS configurations
|
|
34143
|
-
ON configurations.local_grant_id = grants.local_grant_id
|
|
34144
|
-
WHERE grants.local_grant_id = ? AND grants.bot_id = ?
|
|
34145
|
-
AND behavior_revision_id = ? AND behavior_digest = ?
|
|
34146
|
-
AND binding_id = ? AND binding_revision = ?
|
|
34147
|
-
AND agent_ref = ?`
|
|
34148
|
-
).get(
|
|
34149
|
-
command.localGrantId,
|
|
34150
|
-
command.botId,
|
|
34151
|
-
command.behaviorRevisionId,
|
|
34152
|
-
command.behaviorDigest,
|
|
34153
|
-
command.bindingId,
|
|
34154
|
-
command.bindingRevision,
|
|
34155
|
-
command.agentId
|
|
34156
|
-
);
|
|
34157
|
-
if (row === void 0) {
|
|
34158
|
-
throw new LocalBotAuthorizationError(
|
|
34159
|
-
"binding_not_approved",
|
|
34160
|
-
"The Bot execution binding is not locally approved"
|
|
34161
|
-
);
|
|
34162
|
-
}
|
|
34163
|
-
const approvedTargets = parseTargets(rowString(row, "allowed_delivery_target_ids_json"));
|
|
34164
|
-
const requestedTargets = command.allowedDeliveryTargets.map((target) => target.deliveryTargetId);
|
|
34165
|
-
if (!exactTargets(approvedTargets, requestedTargets)) {
|
|
34166
|
-
throw new LocalBotAuthorizationError(
|
|
34167
|
-
"binding_not_approved",
|
|
34168
|
-
"The Bot execution target policy differs from its binding"
|
|
34169
|
-
);
|
|
34170
|
-
}
|
|
34171
|
-
const approvedConfigurations = parseSessionConfigurations(rowString(row, "session_configurations_json"));
|
|
34172
|
-
if (!exactSessionConfigurations(approvedConfigurations, command.sessionConfigurations)) {
|
|
34173
|
-
throw new LocalBotAuthorizationError(
|
|
34174
|
-
"binding_not_approved",
|
|
34175
|
-
"The Bot Agent configuration differs from its binding"
|
|
34176
|
-
);
|
|
34177
|
-
}
|
|
34178
|
-
const agent = catalog.find(command.agentId);
|
|
34179
34064
|
const [adapterUnchanged, agentUnchanged] = await Promise.all([
|
|
34180
34065
|
revalidateExecutable(agent.adapterIdentity),
|
|
34181
34066
|
revalidateExecutable(agent.agentIdentity)
|
|
@@ -34187,146 +34072,15 @@ var LocalBotGrantStore = class {
|
|
|
34187
34072
|
"The local Agent executable changed while the Runtime is active; restart the Runtime"
|
|
34188
34073
|
);
|
|
34189
34074
|
}
|
|
34190
|
-
const workspaceRef = rowString(row, "workspace_ref");
|
|
34191
|
-
const workspacePath = await directories.resolve(bindingAuthorityId, workspaceRef, signal);
|
|
34192
|
-
const currentAgentDigest = agentDigest(agent);
|
|
34193
|
-
const currentWorkspaceDigest = workspaceDigest(workspacePath);
|
|
34194
|
-
signal.throwIfAborted();
|
|
34195
|
-
let expiresAt = rowInteger(row, "expires_at");
|
|
34196
|
-
let revocationEpoch = rowInteger(row, "revocation_epoch");
|
|
34197
|
-
if (currentAgentDigest !== rowString(row, "agent_identity_digest") || currentWorkspaceDigest !== rowString(row, "workspace_identity_digest") || workspacePath !== rowString(row, "workspace_path") || expiresAt <= now || rowHasInteger(row, "revoked_at")) {
|
|
34198
|
-
const refreshed = this.refreshTarget(
|
|
34199
|
-
rowString(row, "local_grant_id"),
|
|
34200
|
-
currentAgentDigest,
|
|
34201
|
-
currentWorkspaceDigest,
|
|
34202
|
-
workspacePath,
|
|
34203
|
-
now
|
|
34204
|
-
);
|
|
34205
|
-
expiresAt = refreshed.expiresAt;
|
|
34206
|
-
revocationEpoch = refreshed.revocationEpoch;
|
|
34207
|
-
}
|
|
34208
34075
|
if (command.behaviorInstructions.length > 0 && !agent.capabilities.embeddedContextPrompt) {
|
|
34209
34076
|
throw new LocalBotAuthorizationError(
|
|
34210
34077
|
"binding_incompatible",
|
|
34211
|
-
"The local Agent cannot apply the
|
|
34212
|
-
);
|
|
34213
|
-
}
|
|
34214
|
-
return new LocalBotGrant(
|
|
34215
|
-
rowString(row, "local_grant_id"),
|
|
34216
|
-
command.botId,
|
|
34217
|
-
command.behaviorRevisionId,
|
|
34218
|
-
command.behaviorDigest,
|
|
34219
|
-
command.bindingId,
|
|
34220
|
-
command.bindingRevision,
|
|
34221
|
-
agent,
|
|
34222
|
-
currentAgentDigest,
|
|
34223
|
-
workspaceRef,
|
|
34224
|
-
workspacePath,
|
|
34225
|
-
currentWorkspaceDigest,
|
|
34226
|
-
approvedTargets,
|
|
34227
|
-
expiresAt,
|
|
34228
|
-
revocationEpoch
|
|
34229
|
-
);
|
|
34230
|
-
};
|
|
34231
|
-
recordUnavailable = (request, code, message, now) => {
|
|
34232
|
-
this.#database.prepare(
|
|
34233
|
-
`INSERT OR IGNORE INTO local_bot_binding_resolutions (
|
|
34234
|
-
request_id, binding_id, local_grant_id, resolved_at,
|
|
34235
|
-
result, error_code, error_message
|
|
34236
|
-
) VALUES (?, ?, '', ?, 'unavailable', ?, ?)`
|
|
34237
|
-
).run(request.requestId, request.bindingId, now, code, message);
|
|
34238
|
-
};
|
|
34239
|
-
close = () => {
|
|
34240
|
-
this.#database.close();
|
|
34241
|
-
};
|
|
34242
|
-
resolveProposal = async (request, catalog, directories, bindingAuthorityId, signal) => {
|
|
34243
|
-
const agent = catalog.find(request.agentRef);
|
|
34244
|
-
if (request.requiredCapabilities.includes("embedded-context") && !agent.capabilities.embeddedContextPrompt) {
|
|
34245
|
-
throw new LocalBotAuthorizationError(
|
|
34246
|
-
"binding_incompatible",
|
|
34247
|
-
"The local Agent cannot apply embedded Bot context"
|
|
34078
|
+
"The local Agent cannot apply the Bot behavior"
|
|
34248
34079
|
);
|
|
34249
34080
|
}
|
|
34250
|
-
|
|
34251
|
-
throw new LocalBotAuthorizationError(
|
|
34252
|
-
"binding_incompatible",
|
|
34253
|
-
"The Bot requires an unsupported local Agent capability"
|
|
34254
|
-
);
|
|
34255
|
-
}
|
|
34256
|
-
const [adapterUnchanged, agentUnchanged] = await Promise.all([
|
|
34257
|
-
revalidateExecutable(agent.adapterIdentity),
|
|
34258
|
-
revalidateExecutable(agent.agentIdentity)
|
|
34259
|
-
]);
|
|
34081
|
+
const workspacePath = await directories.resolve(bindingAuthorityId, command.directoryId, signal);
|
|
34260
34082
|
signal.throwIfAborted();
|
|
34261
|
-
|
|
34262
|
-
throw new LocalBotAuthorizationError(
|
|
34263
|
-
"binding_incompatible",
|
|
34264
|
-
"The local Agent executable changed before approval"
|
|
34265
|
-
);
|
|
34266
|
-
}
|
|
34267
|
-
const workspacePath = await directories.resolve(bindingAuthorityId, request.workspaceRef, signal);
|
|
34268
|
-
return {
|
|
34269
|
-
agent,
|
|
34270
|
-
agentIdentityDigest: agentDigest(agent),
|
|
34271
|
-
workspaceIdentityDigest: workspaceDigest(workspacePath),
|
|
34272
|
-
workspacePath
|
|
34273
|
-
};
|
|
34274
|
-
};
|
|
34275
|
-
refreshTarget = (localGrantId, agentIdentityDigest, workspaceIdentityDigest, workspacePath, now) => {
|
|
34276
|
-
const expiresAt = now + LOCAL_BOT_GRANT_LIFETIME_MILLISECONDS;
|
|
34277
|
-
this.#database.exec("BEGIN IMMEDIATE");
|
|
34278
|
-
try {
|
|
34279
|
-
const current = this.#database.prepare("SELECT * FROM local_bot_grants WHERE local_grant_id = ?").get(localGrantId);
|
|
34280
|
-
if (current === void 0) {
|
|
34281
|
-
throw new LocalBotAuthorizationError("local_grant_invalid", "The local Bot grant is missing");
|
|
34282
|
-
}
|
|
34283
|
-
const currentExpiresAt = rowInteger(current, "expires_at");
|
|
34284
|
-
const currentRevocationEpoch = rowInteger(current, "revocation_epoch");
|
|
34285
|
-
if (agentIdentityDigest === rowString(current, "agent_identity_digest") && workspaceIdentityDigest === rowString(current, "workspace_identity_digest") && workspacePath === rowString(current, "workspace_path") && currentExpiresAt > now && !rowHasInteger(current, "revoked_at")) {
|
|
34286
|
-
this.#database.exec("COMMIT");
|
|
34287
|
-
return { expiresAt: currentExpiresAt, revocationEpoch: currentRevocationEpoch };
|
|
34288
|
-
}
|
|
34289
|
-
const result = this.#database.prepare(
|
|
34290
|
-
`UPDATE local_bot_grants
|
|
34291
|
-
SET agent_identity_digest = ?, workspace_identity_digest = ?, workspace_path = ?,
|
|
34292
|
-
expires_at = ?, revoked_at = NULL, revocation_epoch = revocation_epoch + 1
|
|
34293
|
-
WHERE local_grant_id = ? AND revocation_epoch = ?`
|
|
34294
|
-
).run(
|
|
34295
|
-
agentIdentityDigest,
|
|
34296
|
-
workspaceIdentityDigest,
|
|
34297
|
-
workspacePath,
|
|
34298
|
-
expiresAt,
|
|
34299
|
-
localGrantId,
|
|
34300
|
-
currentRevocationEpoch
|
|
34301
|
-
);
|
|
34302
|
-
if (result.changes !== 1) {
|
|
34303
|
-
throw new LocalBotAuthorizationError(
|
|
34304
|
-
"local_grant_invalid",
|
|
34305
|
-
"The local Bot grant target could not be refreshed"
|
|
34306
|
-
);
|
|
34307
|
-
}
|
|
34308
|
-
this.#database.prepare(
|
|
34309
|
-
`INSERT INTO audit_events (recorded_at, event, command_id, session_id, details_json)
|
|
34310
|
-
VALUES (?, 'bot_binding_target_refreshed', ?, '', ?)`
|
|
34311
|
-
).run(
|
|
34312
|
-
new Date(now).toISOString(),
|
|
34313
|
-
rowString(current, "binding_id"),
|
|
34314
|
-
JSON.stringify({
|
|
34315
|
-
agentIdentityChanged: agentIdentityDigest !== rowString(current, "agent_identity_digest"),
|
|
34316
|
-
bindingId: rowString(current, "binding_id"),
|
|
34317
|
-
botId: rowString(current, "bot_id"),
|
|
34318
|
-
expired: currentExpiresAt <= now,
|
|
34319
|
-
revived: rowHasInteger(current, "revoked_at"),
|
|
34320
|
-
workspaceIdentityChanged: workspaceIdentityDigest !== rowString(current, "workspace_identity_digest"),
|
|
34321
|
-
workspacePathChanged: workspacePath !== rowString(current, "workspace_path")
|
|
34322
|
-
})
|
|
34323
|
-
);
|
|
34324
|
-
this.#database.exec("COMMIT");
|
|
34325
|
-
return { expiresAt, revocationEpoch: currentRevocationEpoch + 1 };
|
|
34326
|
-
} catch (cause) {
|
|
34327
|
-
this.#database.exec("ROLLBACK");
|
|
34328
|
-
throw cause;
|
|
34329
|
-
}
|
|
34083
|
+
return new AuthorizedLocalBotExecution(command, agent, workspacePath);
|
|
34330
34084
|
};
|
|
34331
34085
|
};
|
|
34332
34086
|
|
|
@@ -34426,7 +34180,7 @@ var BotExecutionContextRegistry = class {
|
|
|
34426
34180
|
};
|
|
34427
34181
|
|
|
34428
34182
|
// src/bots/bot-message-command.ts
|
|
34429
|
-
import { randomUUID
|
|
34183
|
+
import { randomUUID } from "node:crypto";
|
|
34430
34184
|
import { createConnection } from "node:net";
|
|
34431
34185
|
var BOT_IPC_RESPONSE_LIMIT = 64 * 1024;
|
|
34432
34186
|
var BOT_IPC_TIMEOUT_MILLISECONDS = 2e4;
|
|
@@ -34575,7 +34329,7 @@ async function executeBotMessageCommand(arguments_, environment, signal) {
|
|
|
34575
34329
|
socketPath,
|
|
34576
34330
|
JSON.stringify({
|
|
34577
34331
|
contextHandle,
|
|
34578
|
-
idempotencyKey: `cli_${
|
|
34332
|
+
idempotencyKey: `cli_${randomUUID()}`,
|
|
34579
34333
|
target,
|
|
34580
34334
|
text: text3
|
|
34581
34335
|
}),
|
|
@@ -34823,7 +34577,7 @@ var BotOutboundIpcServer = class {
|
|
|
34823
34577
|
};
|
|
34824
34578
|
|
|
34825
34579
|
// src/pairing/pair-local-machine.ts
|
|
34826
|
-
import { randomUUID as
|
|
34580
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
34827
34581
|
import { mkdir as mkdir4, open as open4, realpath as realpath7, rename as rename3, stat as stat6, writeFile as writeFile2 } from "node:fs/promises";
|
|
34828
34582
|
import { hostname as hostname3 } from "node:os";
|
|
34829
34583
|
import { basename as basename3, join as join15, resolve as resolve3 } from "node:path";
|
|
@@ -35456,7 +35210,7 @@ var CopilotCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
35456
35210
|
};
|
|
35457
35211
|
|
|
35458
35212
|
// src/agent-catalog/agents/cursor-cli-agent.ts
|
|
35459
|
-
var CURSOR_CLI_TESTED_VERSION = "2026.09.
|
|
35213
|
+
var CURSOR_CLI_TESTED_VERSION = "2026.09.15-d2fe57e";
|
|
35460
35214
|
var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
35461
35215
|
adapterVersion = CURSOR_CLI_TESTED_VERSION;
|
|
35462
35216
|
authenticationCommand = () => "cursor-agent login";
|
|
@@ -35472,7 +35226,7 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
35472
35226
|
}
|
|
35473
35227
|
verifyAcp = async (connection, initialized, defaultWorkspace, signal) => {
|
|
35474
35228
|
const capabilities = initialized.agentCapabilities ?? {};
|
|
35475
|
-
if (capabilities.loadSession !== true || capabilities.sessionCapabilities?.list == null
|
|
35229
|
+
if (capabilities.loadSession !== true || capabilities.sessionCapabilities?.list == null) {
|
|
35476
35230
|
throw new AgentProbeError("acp_incompatible", "Cursor CLI reported an unsupported ACP capability set");
|
|
35477
35231
|
}
|
|
35478
35232
|
await verifySessionCreation(connection, capabilities, defaultWorkspace, signal, this.label);
|
|
@@ -35555,11 +35309,10 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
35555
35309
|
context.signal.throwIfAborted();
|
|
35556
35310
|
}
|
|
35557
35311
|
if (selectedHome === void 0 || selectedHome.length === 0) {
|
|
35558
|
-
return Object.freeze({
|
|
35312
|
+
return Object.freeze({});
|
|
35559
35313
|
}
|
|
35560
35314
|
return Object.freeze({
|
|
35561
|
-
DSH_HOME: await validateAgentHome(selectedHome)
|
|
35562
|
-
DSH_PERMISSION_MODE: "workspace-write"
|
|
35315
|
+
DSH_HOME: await validateAgentHome(selectedHome)
|
|
35563
35316
|
});
|
|
35564
35317
|
};
|
|
35565
35318
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
@@ -35784,7 +35537,7 @@ var HermesAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
35784
35537
|
import { join as join10 } from "node:path";
|
|
35785
35538
|
|
|
35786
35539
|
// src/agent-installation/managed-agent-archive.ts
|
|
35787
|
-
import { createHash
|
|
35540
|
+
import { createHash } from "node:crypto";
|
|
35788
35541
|
import { createReadStream } from "node:fs";
|
|
35789
35542
|
import { chmod as chmod2, copyFile, mkdir as mkdir3, mkdtemp as mkdtemp2, open as open3, realpath as realpath6, rename as rename2, rm as rm2, stat as stat5, writeFile } from "node:fs/promises";
|
|
35790
35543
|
import { delimiter as delimiter2, dirname as dirname5, isAbsolute as isAbsolute7, join as join9, relative as relative4, sep as sep4 } from "node:path";
|
|
@@ -35897,7 +35650,7 @@ function isContainedPath3(root, candidate) {
|
|
|
35897
35650
|
}
|
|
35898
35651
|
async function hashFile(path2, signal) {
|
|
35899
35652
|
signal.throwIfAborted();
|
|
35900
|
-
const
|
|
35653
|
+
const digest = createHash("sha256");
|
|
35901
35654
|
const stream = createReadStream(path2, { signal });
|
|
35902
35655
|
try {
|
|
35903
35656
|
for await (const chunk of stream) {
|
|
@@ -35908,9 +35661,9 @@ async function hashFile(path2, signal) {
|
|
|
35908
35661
|
"The managed Agent archive produced invalid bytes"
|
|
35909
35662
|
);
|
|
35910
35663
|
}
|
|
35911
|
-
|
|
35664
|
+
digest.update(chunk);
|
|
35912
35665
|
}
|
|
35913
|
-
return
|
|
35666
|
+
return digest.digest("hex");
|
|
35914
35667
|
} catch (error62) {
|
|
35915
35668
|
if (signal.aborted) {
|
|
35916
35669
|
signal.throwIfAborted();
|
|
@@ -36066,7 +35819,14 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
36066
35819
|
]
|
|
36067
35820
|
);
|
|
36068
35821
|
}
|
|
36069
|
-
createLaunchEnvironment = async (_agent,
|
|
35822
|
+
createLaunchEnvironment = async (_agent, context) => {
|
|
35823
|
+
const environment = { OPENCODE_DISABLE_AUTOUPDATE: "1" };
|
|
35824
|
+
const inlineConfiguration = context.environment["OPENCODE_CONFIG_CONTENT"];
|
|
35825
|
+
if (typeof inlineConfiguration === "string" && inlineConfiguration.length > 0) {
|
|
35826
|
+
environment["OPENCODE_CONFIG_CONTENT"] = inlineConfiguration;
|
|
35827
|
+
}
|
|
35828
|
+
return Object.freeze(environment);
|
|
35829
|
+
};
|
|
36070
35830
|
resolveManagedAgent = async (stateDirectory, platform, signal) => await validateManagedAgentArchive(
|
|
36071
35831
|
join10(stateDirectory, "agents", this.id, OPENCODE_MANAGED_VERSION),
|
|
36072
35832
|
openCodeManagedArchive(platform, process.arch),
|
|
@@ -37023,7 +36783,7 @@ async function persistConnection(channelId, relayOrigin, runtimeCredential2, def
|
|
|
37023
36783
|
const connectionsDirectory = join15(readStateDirectory(environment), "connections");
|
|
37024
36784
|
await mkdir4(connectionsDirectory, { mode: 448, recursive: true });
|
|
37025
36785
|
const connectionPath = join15(connectionsDirectory, `${channelId}.json`);
|
|
37026
|
-
const temporaryPath = join15(connectionsDirectory, `.${channelId}.${
|
|
36786
|
+
const temporaryPath = join15(connectionsDirectory, `.${channelId}.${randomUUID2()}.tmp`);
|
|
37027
36787
|
await writeFile2(
|
|
37028
36788
|
temporaryPath,
|
|
37029
36789
|
`${JSON.stringify(
|
|
@@ -37173,7 +36933,7 @@ async function resumeLocalMachine(arguments_, signal = new AbortController().sig
|
|
|
37173
36933
|
}
|
|
37174
36934
|
|
|
37175
36935
|
// src/run-daemon.ts
|
|
37176
|
-
import { randomUUID as
|
|
36936
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
37177
36937
|
import { basename as basename6, join as join17 } from "node:path";
|
|
37178
36938
|
import { styleText } from "node:util";
|
|
37179
36939
|
import { fetch as fetch7, WebSocket as WebSocket2 } from "undici";
|
|
@@ -37718,7 +37478,7 @@ var FixedInstallationExecutor = class {
|
|
|
37718
37478
|
};
|
|
37719
37479
|
|
|
37720
37480
|
// src/artifacts/runtime-artifact-uploader.ts
|
|
37721
|
-
import { createHash as
|
|
37481
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
37722
37482
|
|
|
37723
37483
|
// ../mobius-sdk/src/errors.ts
|
|
37724
37484
|
var MobiusError = class extends Error {
|
|
@@ -37750,7 +37510,7 @@ function invalidResponse(message) {
|
|
|
37750
37510
|
function isRecord12(value) {
|
|
37751
37511
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
37752
37512
|
}
|
|
37753
|
-
function
|
|
37513
|
+
function record3(value, name) {
|
|
37754
37514
|
if (!isRecord12(value)) {
|
|
37755
37515
|
throw invalidResponse(`The service returned an invalid ${name}`);
|
|
37756
37516
|
}
|
|
@@ -37885,11 +37645,11 @@ function uploadingArtifact(value) {
|
|
|
37885
37645
|
);
|
|
37886
37646
|
}
|
|
37887
37647
|
function decodeMobiusArtifactUpload(value) {
|
|
37888
|
-
const artifact =
|
|
37648
|
+
const artifact = record3(value, "artifact upload authorization");
|
|
37889
37649
|
return new MobiusArtifactUpload(uploadingArtifact(artifact), stringField(artifact, "uploadToken", 256));
|
|
37890
37650
|
}
|
|
37891
37651
|
function decodeMobiusArtifact(value) {
|
|
37892
|
-
const artifact =
|
|
37652
|
+
const artifact = record3(value, "artifact");
|
|
37893
37653
|
const state = stringField(artifact, "state", 32);
|
|
37894
37654
|
if (state === "uploading") {
|
|
37895
37655
|
return uploadingArtifact(artifact);
|
|
@@ -38045,7 +37805,7 @@ async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
|
|
|
38045
37805
|
artifact.name,
|
|
38046
37806
|
artifact.mimeType,
|
|
38047
37807
|
artifact.bytes.byteLength,
|
|
38048
|
-
|
|
37808
|
+
createHash2("sha256").update(artifact.bytes).digest("hex")
|
|
38049
37809
|
);
|
|
38050
37810
|
} catch (cause) {
|
|
38051
37811
|
translateSdkError(cause);
|
|
@@ -38272,18 +38032,18 @@ var AppliedBotContext = class {
|
|
|
38272
38032
|
}
|
|
38273
38033
|
};
|
|
38274
38034
|
var EmbeddedBotContextApplicator = class {
|
|
38275
|
-
apply = async (command,
|
|
38035
|
+
apply = async (command, execution, resources, signal) => {
|
|
38276
38036
|
signal.throwIfAborted();
|
|
38277
|
-
if (
|
|
38037
|
+
if (execution.botId !== command.botId || execution.behaviorRevisionId !== command.behaviorRevisionId || execution.behaviorDigest !== command.behaviorDigest) {
|
|
38278
38038
|
throw new LocalBotAuthorizationError(
|
|
38279
|
-
"
|
|
38280
|
-
"The Bot behavior does not match
|
|
38039
|
+
"binding_incompatible",
|
|
38040
|
+
"The Bot behavior does not match the execution target"
|
|
38281
38041
|
);
|
|
38282
38042
|
}
|
|
38283
38043
|
if (command.behaviorInstructions.length === 0) {
|
|
38284
38044
|
return new AppliedBotContext(resources);
|
|
38285
38045
|
}
|
|
38286
|
-
if (!
|
|
38046
|
+
if (!execution.agent.capabilities.embeddedContextPrompt) {
|
|
38287
38047
|
throw new LocalBotAuthorizationError(
|
|
38288
38048
|
"binding_incompatible",
|
|
38289
38049
|
"The local Agent cannot enforce the Bot behavior context"
|
|
@@ -38301,7 +38061,7 @@ var EmbeddedBotContextApplicator = class {
|
|
|
38301
38061
|
};
|
|
38302
38062
|
|
|
38303
38063
|
// src/native-sessions/service.ts
|
|
38304
|
-
import { randomUUID as
|
|
38064
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
38305
38065
|
import { basename as basename5 } from "node:path";
|
|
38306
38066
|
|
|
38307
38067
|
// src/native-sessions/codex-history.ts
|
|
@@ -38596,7 +38356,7 @@ var NativeSessionService = class {
|
|
|
38596
38356
|
if (authorized === null) {
|
|
38597
38357
|
return null;
|
|
38598
38358
|
}
|
|
38599
|
-
const entryId =
|
|
38359
|
+
const entryId = randomUUID3();
|
|
38600
38360
|
if (this.#entries.size >= 5e3) {
|
|
38601
38361
|
this.#entries.clear();
|
|
38602
38362
|
}
|
|
@@ -38650,7 +38410,7 @@ var NativeSessionService = class {
|
|
|
38650
38410
|
"invalid_native_session_response"
|
|
38651
38411
|
);
|
|
38652
38412
|
}
|
|
38653
|
-
nextCursor =
|
|
38413
|
+
nextCursor = randomUUID3();
|
|
38654
38414
|
if (this.#cursors.size >= 500) {
|
|
38655
38415
|
this.#cursors.clear();
|
|
38656
38416
|
}
|
|
@@ -38968,7 +38728,7 @@ var NativeSessionService = class {
|
|
|
38968
38728
|
};
|
|
38969
38729
|
|
|
38970
38730
|
// src/prompt-artifact-resolver.ts
|
|
38971
|
-
import { createHash as
|
|
38731
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
38972
38732
|
import { fetch as fetch6 } from "undici";
|
|
38973
38733
|
var ARTIFACT_SCHEME = "mobius-artifact:";
|
|
38974
38734
|
var ARTIFACT_DOWNLOAD_TIMEOUT_MILLISECONDS = 2e4;
|
|
@@ -39107,7 +38867,7 @@ async function download(config2, command, reference, signal) {
|
|
|
39107
38867
|
);
|
|
39108
38868
|
}
|
|
39109
38869
|
const bytes = await responseBytes(response, reference.byteLength, requestSignal);
|
|
39110
|
-
if (
|
|
38870
|
+
if (createHash3("sha256").update(bytes).digest("hex") !== reference.sha256) {
|
|
39111
38871
|
throw new PromptArtifactError(
|
|
39112
38872
|
"artifact_integrity_failed",
|
|
39113
38873
|
"The prompt artifact failed integrity validation"
|
|
@@ -39416,7 +39176,7 @@ var RelayConnectionDiagnostics = class {
|
|
|
39416
39176
|
};
|
|
39417
39177
|
|
|
39418
39178
|
// src/relay-connection/liveness.ts
|
|
39419
|
-
import { randomUUID as
|
|
39179
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
39420
39180
|
var HEARTBEAT_ACK_TIMEOUT_MILLISECONDS = 1e4;
|
|
39421
39181
|
var HEARTBEAT_INTERVAL_MILLISECONDS = 2e4;
|
|
39422
39182
|
var RelayLivenessState = class {
|
|
@@ -39505,7 +39265,7 @@ var RelayConnectionLiveness = class {
|
|
|
39505
39265
|
}
|
|
39506
39266
|
throw new Error("Heartbeat was scheduled in an invalid state");
|
|
39507
39267
|
}
|
|
39508
|
-
const heartbeatId =
|
|
39268
|
+
const heartbeatId = randomUUID4();
|
|
39509
39269
|
this.#state = new AwaitingHeartbeatAckState(
|
|
39510
39270
|
heartbeatId,
|
|
39511
39271
|
this.#timer.schedule(this.#handleTimeout, HEARTBEAT_ACK_TIMEOUT_MILLISECONDS)
|
|
@@ -39522,7 +39282,7 @@ var RelayConnectionLiveness = class {
|
|
|
39522
39282
|
// src/relay-connection/session-event-outbox.ts
|
|
39523
39283
|
import { mkdirSync as mkdirSync3 } from "node:fs";
|
|
39524
39284
|
import { dirname as dirname7 } from "node:path";
|
|
39525
|
-
import { DatabaseSync as
|
|
39285
|
+
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
39526
39286
|
var DEFAULT_OUTBOX_LIMITS = {
|
|
39527
39287
|
criticalEventBytes: 136 * 1024 * 1024,
|
|
39528
39288
|
runtimeDeliveryBytes: 64 * 1024 * 1024,
|
|
@@ -39574,7 +39334,7 @@ function rowNumber(row, field) {
|
|
|
39574
39334
|
}
|
|
39575
39335
|
return value;
|
|
39576
39336
|
}
|
|
39577
|
-
function
|
|
39337
|
+
function rowString(row, field) {
|
|
39578
39338
|
const value = typeof row === "object" && row !== null ? Reflect.get(row, field) : void 0;
|
|
39579
39339
|
if (typeof value !== "string" || value.length === 0) {
|
|
39580
39340
|
throw new Error(`SQLite returned an invalid ${field} value`);
|
|
@@ -39588,7 +39348,7 @@ var SessionEventOutbox = class {
|
|
|
39588
39348
|
validateLimits(limits);
|
|
39589
39349
|
this.#limits = limits;
|
|
39590
39350
|
mkdirSync3(dirname7(path2), { recursive: true });
|
|
39591
|
-
this.#database = new
|
|
39351
|
+
this.#database = new DatabaseSync3(path2);
|
|
39592
39352
|
this.#database.exec(`
|
|
39593
39353
|
CREATE TABLE IF NOT EXISTS relay_session_event_outbox (
|
|
39594
39354
|
ordinal INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
@@ -39823,8 +39583,8 @@ var SessionEventOutbox = class {
|
|
|
39823
39583
|
WHERE delivery_id = ?`
|
|
39824
39584
|
).get(delivery.deliveryId);
|
|
39825
39585
|
if (existing !== void 0) {
|
|
39826
|
-
const sessionId =
|
|
39827
|
-
const payload =
|
|
39586
|
+
const sessionId = rowString(existing, "session_id");
|
|
39587
|
+
const payload = rowString(existing, "payload_json");
|
|
39828
39588
|
const state = runtimeDeliveryState(existing);
|
|
39829
39589
|
if (sessionId !== delivery.sessionId || payload !== delivery.payload) {
|
|
39830
39590
|
throw new Error("The Runtime delivery identity conflicts with its durable receipt");
|
|
@@ -39912,9 +39672,9 @@ var SessionEventOutbox = class {
|
|
|
39912
39672
|
ORDER BY received_at, delivery_id`
|
|
39913
39673
|
).all().map(
|
|
39914
39674
|
(row) => new StoredRuntimeDelivery(
|
|
39915
|
-
|
|
39916
|
-
|
|
39917
|
-
|
|
39675
|
+
rowString(row, "delivery_id"),
|
|
39676
|
+
rowString(row, "session_id"),
|
|
39677
|
+
rowString(row, "payload_json"),
|
|
39918
39678
|
runtimeDeliveryState(row),
|
|
39919
39679
|
true
|
|
39920
39680
|
)
|
|
@@ -40096,7 +39856,7 @@ function validateLimits(limits) {
|
|
|
40096
39856
|
}
|
|
40097
39857
|
}
|
|
40098
39858
|
function runtimeDeliveryState(row) {
|
|
40099
|
-
const state =
|
|
39859
|
+
const state = rowString(row, "state");
|
|
40100
39860
|
if (state !== "received" && state !== "relay_committed" && state !== "processed") {
|
|
40101
39861
|
throw new Error("SQLite returned an invalid Runtime delivery state");
|
|
40102
39862
|
}
|
|
@@ -40122,16 +39882,16 @@ var ACTIVE_TURN_RECONCILIATION_TIMEOUT_MILLISECONDS = 2e4;
|
|
|
40122
39882
|
var ACTIVE_TURN_RECONCILIATION_CLOSE_CODE = 4009;
|
|
40123
39883
|
function botIpcSocketPath() {
|
|
40124
39884
|
if (process.platform === "win32") {
|
|
40125
|
-
return `\\\\.\\pipe\\mobius-bot-${
|
|
39885
|
+
return `\\\\.\\pipe\\mobius-bot-${randomUUID5()}`;
|
|
40126
39886
|
}
|
|
40127
|
-
return join17("/tmp", `mobius-bot-${
|
|
39887
|
+
return join17("/tmp", `mobius-bot-${randomUUID5()}.sock`);
|
|
40128
39888
|
}
|
|
40129
39889
|
var DaemonAcpObserver = class {
|
|
40130
39890
|
#config;
|
|
40131
39891
|
#record;
|
|
40132
|
-
constructor(config2,
|
|
39892
|
+
constructor(config2, record4) {
|
|
40133
39893
|
this.#config = config2;
|
|
40134
|
-
this.#record =
|
|
39894
|
+
this.#record = record4;
|
|
40135
39895
|
}
|
|
40136
39896
|
importLocalArtifact = async (sessionId, artifact, signal) => {
|
|
40137
39897
|
try {
|
|
@@ -41041,10 +40801,56 @@ function botExecutionAgent(agent, contextHandle, socketPath) {
|
|
|
41041
40801
|
agent.adapterIdentity,
|
|
41042
40802
|
agent.agentIdentity,
|
|
41043
40803
|
agent.promptTimeoutMilliseconds,
|
|
41044
|
-
agent.capabilities
|
|
40804
|
+
agent.capabilities,
|
|
40805
|
+
agent.permissionProfile
|
|
41045
40806
|
);
|
|
41046
40807
|
}
|
|
41047
|
-
|
|
40808
|
+
function assertPreparedPermission(configOptions, permissionMode) {
|
|
40809
|
+
const permission = configOptions.find((option2) => option2.id === "permission_mode");
|
|
40810
|
+
if (permission === void 0 || permission.type !== "select" || permissionMode !== AGENT_DEFAULT_EXECUTION_SETTING && permission.currentValue !== permissionMode) {
|
|
40811
|
+
throw new AcpExecutionError(
|
|
40812
|
+
"The required Agent permission mode is unavailable",
|
|
40813
|
+
{},
|
|
40814
|
+
"invalid_session_configuration"
|
|
40815
|
+
);
|
|
40816
|
+
}
|
|
40817
|
+
}
|
|
40818
|
+
async function applyRequiredExecutionSelection(sessions, configOptions, selection, category, agent, cwd, additionalDirectories, sessionId, signal) {
|
|
40819
|
+
const option2 = configOptions.find((candidate) => candidate.id === selection.configId);
|
|
40820
|
+
if (option2 === void 0 || option2.type !== "select" || option2.category !== category || selection.valueType !== "select" || selection.booleanValue) {
|
|
40821
|
+
throw new AcpExecutionError(
|
|
40822
|
+
`The required Agent setting ${selection.configId} is unavailable`,
|
|
40823
|
+
{},
|
|
40824
|
+
"invalid_session_configuration"
|
|
40825
|
+
);
|
|
40826
|
+
}
|
|
40827
|
+
if (selection.value === AGENT_DEFAULT_EXECUTION_SETTING) {
|
|
40828
|
+
return configOptions;
|
|
40829
|
+
}
|
|
40830
|
+
if (!option2.values.some((value) => value.value === selection.value)) {
|
|
40831
|
+
throw new AcpExecutionError(
|
|
40832
|
+
`The required Agent setting ${selection.configId} is unavailable`,
|
|
40833
|
+
{},
|
|
40834
|
+
"invalid_session_configuration"
|
|
40835
|
+
);
|
|
40836
|
+
}
|
|
40837
|
+
if (option2.currentValue === selection.value) {
|
|
40838
|
+
return configOptions;
|
|
40839
|
+
}
|
|
40840
|
+
return await sessions.configureSession({
|
|
40841
|
+
additionalDirectories,
|
|
40842
|
+
agent,
|
|
40843
|
+
booleanValue: false,
|
|
40844
|
+
configId: selection.configId,
|
|
40845
|
+
cwd,
|
|
40846
|
+
requestId: `cfg_${randomUUID5()}`,
|
|
40847
|
+
sessionId,
|
|
40848
|
+
signal,
|
|
40849
|
+
value: selection.value,
|
|
40850
|
+
valueType: "select"
|
|
40851
|
+
});
|
|
40852
|
+
}
|
|
40853
|
+
async function executeBotPrompt(outbox, publisher, command, config2, directories, audit, sessions, authorizer, contexts, applicator, ipc, attemptId, activateAttempt, timer, signal) {
|
|
41048
40854
|
const activities = new CoalescingDaemonActivityPublisher(timer, (activity) => {
|
|
41049
40855
|
publisher.recordAttempt(command.sessionId, encodeDaemonActivity(command, activity), attemptId);
|
|
41050
40856
|
});
|
|
@@ -41054,21 +40860,7 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
|
|
|
41054
40860
|
if (!Number.isSafeInteger(deadline) || remaining <= 0) {
|
|
41055
40861
|
throw new LocalBotAuthorizationError("turn_expired", "The Bot execution deadline has expired");
|
|
41056
40862
|
}
|
|
41057
|
-
const
|
|
41058
|
-
command,
|
|
41059
|
-
config2.catalog,
|
|
41060
|
-
directories,
|
|
41061
|
-
config2.bindingId,
|
|
41062
|
-
Date.now(),
|
|
41063
|
-
signal
|
|
41064
|
-
);
|
|
41065
|
-
const requestedExecutionTargetOverridden = command.directoryId !== grant.workspaceRef || command.additionalDirectoryIds.length > 0;
|
|
41066
|
-
if (requestedExecutionTargetOverridden && !(command.replyRoute instanceof OwnerBotReplyRoute)) {
|
|
41067
|
-
throw new LocalBotAuthorizationError(
|
|
41068
|
-
"binding_not_approved",
|
|
41069
|
-
"Only a paired owner conversation can override the approved Bot workspace"
|
|
41070
|
-
);
|
|
41071
|
-
}
|
|
40863
|
+
const execution = await authorizer.authorize(command, config2.catalog, directories, config2.bindingId, signal);
|
|
41072
40864
|
const resolved = await resolveSessionDirectories(
|
|
41073
40865
|
directories,
|
|
41074
40866
|
config2.bindingId,
|
|
@@ -41076,20 +40868,8 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
|
|
|
41076
40868
|
command.additionalDirectoryIds,
|
|
41077
40869
|
signal
|
|
41078
40870
|
);
|
|
41079
|
-
const executionTargetOverridden = resolved.cwd !== grant.workspacePath || resolved.additionalDirectories.length > 0;
|
|
41080
|
-
if (executionTargetOverridden && !sessions.hasPreparedSession(
|
|
41081
|
-
command.sessionId,
|
|
41082
|
-
grant.agent.id,
|
|
41083
|
-
resolved.cwd,
|
|
41084
|
-
resolved.additionalDirectories
|
|
41085
|
-
)) {
|
|
41086
|
-
throw new LocalBotAuthorizationError(
|
|
41087
|
-
"local_approval_required",
|
|
41088
|
-
"Open this Bot conversation in the paired local Web app before using the selected workspace"
|
|
41089
|
-
);
|
|
41090
|
-
}
|
|
41091
40871
|
const attachments = await resolvePromptArtifacts(config2, command, signal);
|
|
41092
|
-
const applied = await applicator.apply(command,
|
|
40872
|
+
const applied = await applicator.apply(command, execution, attachments.resources, signal);
|
|
41093
40873
|
const deadlineSignal = AbortSignal.timeout(remaining);
|
|
41094
40874
|
const executionSignal = AbortSignal.any([signal, deadlineSignal]);
|
|
41095
40875
|
const startExecution = () => {
|
|
@@ -41099,8 +40879,7 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
|
|
|
41099
40879
|
behaviorRevisionId: command.behaviorRevisionId,
|
|
41100
40880
|
bindingId: command.bindingId,
|
|
41101
40881
|
botId: command.botId,
|
|
41102
|
-
executionId: command.executionId
|
|
41103
|
-
localGrantId: command.localGrantId
|
|
40882
|
+
executionId: command.executionId
|
|
41104
40883
|
},
|
|
41105
40884
|
event: "bot_session_authorized",
|
|
41106
40885
|
sessionId: command.sessionId
|
|
@@ -41123,7 +40902,7 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
|
|
|
41123
40902
|
startExecution();
|
|
41124
40903
|
await sessions.steerPrompt({
|
|
41125
40904
|
additionalDirectories: resolved.additionalDirectories,
|
|
41126
|
-
agent:
|
|
40905
|
+
agent: execution.agent,
|
|
41127
40906
|
commandId: command.commandId,
|
|
41128
40907
|
cwd: resolved.cwd,
|
|
41129
40908
|
images: attachments.images,
|
|
@@ -41143,14 +40922,37 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
|
|
|
41143
40922
|
}
|
|
41144
40923
|
const lease = contexts.activate(command);
|
|
41145
40924
|
try {
|
|
41146
|
-
const agent = botExecutionAgent(
|
|
41147
|
-
await sessions.prepareExecutionSession({
|
|
40925
|
+
const agent = botExecutionAgent(execution.agent, lease.context.contextHandle, ipc.socketPath);
|
|
40926
|
+
const prepared = await sessions.prepareExecutionSession({
|
|
41148
40927
|
additionalDirectories: resolved.additionalDirectories,
|
|
41149
40928
|
agent,
|
|
41150
40929
|
cwd: resolved.cwd,
|
|
41151
40930
|
sessionId: command.sessionId,
|
|
41152
40931
|
signal: executionSignal
|
|
41153
40932
|
});
|
|
40933
|
+
assertPreparedPermission(prepared.configOptions, execution.executionConfiguration.permissionMode);
|
|
40934
|
+
let configOptions = await applyRequiredExecutionSelection(
|
|
40935
|
+
sessions,
|
|
40936
|
+
prepared.configOptions,
|
|
40937
|
+
execution.executionConfiguration.model,
|
|
40938
|
+
"model",
|
|
40939
|
+
agent,
|
|
40940
|
+
resolved.cwd,
|
|
40941
|
+
resolved.additionalDirectories,
|
|
40942
|
+
command.sessionId,
|
|
40943
|
+
executionSignal
|
|
40944
|
+
);
|
|
40945
|
+
configOptions = await applyRequiredExecutionSelection(
|
|
40946
|
+
sessions,
|
|
40947
|
+
configOptions,
|
|
40948
|
+
execution.executionConfiguration.reasoningEffort,
|
|
40949
|
+
"thought_level",
|
|
40950
|
+
agent,
|
|
40951
|
+
resolved.cwd,
|
|
40952
|
+
resolved.additionalDirectories,
|
|
40953
|
+
command.sessionId,
|
|
40954
|
+
executionSignal
|
|
40955
|
+
);
|
|
41154
40956
|
for (const selection of command.sessionConfigurations) {
|
|
41155
40957
|
await sessions.configureSession({
|
|
41156
40958
|
additionalDirectories: resolved.additionalDirectories,
|
|
@@ -41158,7 +40960,7 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
|
|
|
41158
40960
|
booleanValue: selection.booleanValue,
|
|
41159
40961
|
configId: selection.configId,
|
|
41160
40962
|
cwd: resolved.cwd,
|
|
41161
|
-
requestId: `cfg_${
|
|
40963
|
+
requestId: `cfg_${randomUUID5()}`,
|
|
41162
40964
|
sessionId: command.sessionId,
|
|
41163
40965
|
signal: executionSignal,
|
|
41164
40966
|
value: selection.value,
|
|
@@ -41290,13 +41092,13 @@ async function installDetectedAgentIntegrations(config2, installations, signal)
|
|
|
41290
41092
|
{
|
|
41291
41093
|
agentId: agent.id,
|
|
41292
41094
|
kind: AGENT_INSTALL_REQUEST_KIND,
|
|
41293
|
-
requestId: `automatic-integration-${
|
|
41095
|
+
requestId: `automatic-integration-${randomUUID5()}`
|
|
41294
41096
|
},
|
|
41295
41097
|
signal
|
|
41296
41098
|
);
|
|
41297
41099
|
}
|
|
41298
41100
|
}
|
|
41299
|
-
async function runRelayConnection(config2, directories, audit, sessions, installations, installationObserver, nativeSessions, outbox, publisher,
|
|
41101
|
+
async function runRelayConnection(config2, directories, audit, sessions, installations, installationObserver, nativeSessions, outbox, publisher, authorizer, contexts, applicator, ipc, activeTurns, activeAttemptIds, connectionEpoch, diagnostics, onConnected, signal, timer) {
|
|
41300
41102
|
const relayUrl = new URL(config2.relayUrl);
|
|
41301
41103
|
relayUrl.searchParams.set("deliveryReceipts", "1");
|
|
41302
41104
|
relayUrl.searchParams.set("liveness", "1");
|
|
@@ -41476,7 +41278,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41476
41278
|
directories,
|
|
41477
41279
|
audit,
|
|
41478
41280
|
sessions,
|
|
41479
|
-
|
|
41281
|
+
authorizer,
|
|
41480
41282
|
contexts,
|
|
41481
41283
|
applicator,
|
|
41482
41284
|
ipc,
|
|
@@ -41656,70 +41458,6 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
41656
41458
|
}
|
|
41657
41459
|
return;
|
|
41658
41460
|
}
|
|
41659
|
-
if (kind === BOT_BINDING_APPROVED_KIND) {
|
|
41660
|
-
decodeBotExecutionBindingApprovedEvent(encoded);
|
|
41661
|
-
return;
|
|
41662
|
-
}
|
|
41663
|
-
if (kind === BOT_BINDING_UNAVAILABLE_KIND) {
|
|
41664
|
-
decodeBotExecutionBindingUnavailableEvent(encoded);
|
|
41665
|
-
return;
|
|
41666
|
-
}
|
|
41667
|
-
if (kind === BOT_BINDING_APPROVAL_REQUEST_KIND) {
|
|
41668
|
-
const request = decodeBotExecutionBindingApprovalRequest(encoded);
|
|
41669
|
-
void grants.approve(
|
|
41670
|
-
request,
|
|
41671
|
-
config2.catalog,
|
|
41672
|
-
directories,
|
|
41673
|
-
config2.bindingId,
|
|
41674
|
-
Date.now(),
|
|
41675
|
-
connectionController.signal
|
|
41676
|
-
).then((approved) => {
|
|
41677
|
-
audit.record({
|
|
41678
|
-
commandId: request.requestId,
|
|
41679
|
-
details: {
|
|
41680
|
-
behaviorRevisionId: request.behaviorRevisionId,
|
|
41681
|
-
bindingId: request.bindingId,
|
|
41682
|
-
botId: request.botId,
|
|
41683
|
-
localGrantId: approved.localGrantId
|
|
41684
|
-
},
|
|
41685
|
-
event: "bot_binding_approved",
|
|
41686
|
-
sessionId: `bot-binding:${request.bindingId}`
|
|
41687
|
-
});
|
|
41688
|
-
if (socket.readyState === WebSocket2.OPEN) {
|
|
41689
|
-
send(socket, encodeBotExecutionBindingApprovedEvent(approved));
|
|
41690
|
-
}
|
|
41691
|
-
}).catch((error62) => {
|
|
41692
|
-
if (connectionController.signal.aborted) {
|
|
41693
|
-
return;
|
|
41694
|
-
}
|
|
41695
|
-
const code = error62 instanceof LocalBotAuthorizationError ? error62.code : "binding_incompatible";
|
|
41696
|
-
const message = error62 instanceof LocalBotAuthorizationError ? error62.message : "The local execution target is incompatible";
|
|
41697
|
-
grants.recordUnavailable(request, code, message, Date.now());
|
|
41698
|
-
audit.record({
|
|
41699
|
-
commandId: request.requestId,
|
|
41700
|
-
details: { bindingId: request.bindingId, botId: request.botId, code },
|
|
41701
|
-
event: "bot_binding_unavailable",
|
|
41702
|
-
sessionId: `bot-binding:${request.bindingId}`
|
|
41703
|
-
});
|
|
41704
|
-
if (socket.readyState === WebSocket2.OPEN) {
|
|
41705
|
-
send(
|
|
41706
|
-
socket,
|
|
41707
|
-
encodeBotExecutionBindingUnavailableEvent(
|
|
41708
|
-
new BotExecutionBindingUnavailableEvent(
|
|
41709
|
-
request.requestId,
|
|
41710
|
-
request.botId,
|
|
41711
|
-
request.behaviorRevisionId,
|
|
41712
|
-
request.bindingId,
|
|
41713
|
-
request.bindingRevision,
|
|
41714
|
-
code,
|
|
41715
|
-
message
|
|
41716
|
-
)
|
|
41717
|
-
)
|
|
41718
|
-
);
|
|
41719
|
-
}
|
|
41720
|
-
});
|
|
41721
|
-
return;
|
|
41722
|
-
}
|
|
41723
41461
|
if (kind === NATIVE_SESSION_CANCEL_KIND) {
|
|
41724
41462
|
const command2 = decodeNativeSessionCancel(encoded);
|
|
41725
41463
|
const pending = nativeRequests.get(command2.requestId);
|
|
@@ -42115,7 +41853,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
42115
41853
|
directories,
|
|
42116
41854
|
audit,
|
|
42117
41855
|
sessions,
|
|
42118
|
-
|
|
41856
|
+
authorizer,
|
|
42119
41857
|
contexts,
|
|
42120
41858
|
applicator,
|
|
42121
41859
|
ipc,
|
|
@@ -42241,7 +41979,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
|
|
|
42241
41979
|
const sessionStore = new SqliteAcpSessionStore(config2.auditDatabasePath);
|
|
42242
41980
|
const outbox = new SessionEventOutbox(config2.auditDatabasePath);
|
|
42243
41981
|
const publisher = new DaemonSessionEventPublisher(outbox, timer);
|
|
42244
|
-
const
|
|
41982
|
+
const authorizer = new LocalBotExecutionAuthorizer();
|
|
42245
41983
|
const contexts = new BotExecutionContextRegistry();
|
|
42246
41984
|
const applicator = new EmbeddedBotContextApplicator();
|
|
42247
41985
|
const ipc = new BotOutboundIpcServer(botIpcSocketPath(), config2.relayUrl, contexts);
|
|
@@ -42332,7 +42070,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
|
|
|
42332
42070
|
nativeSessions,
|
|
42333
42071
|
outbox,
|
|
42334
42072
|
publisher,
|
|
42335
|
-
|
|
42073
|
+
authorizer,
|
|
42336
42074
|
contexts,
|
|
42337
42075
|
applicator,
|
|
42338
42076
|
ipc,
|
|
@@ -42377,13 +42115,9 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
|
|
|
42377
42115
|
sessionStore.close();
|
|
42378
42116
|
} finally {
|
|
42379
42117
|
try {
|
|
42380
|
-
|
|
42118
|
+
publisher.close();
|
|
42381
42119
|
} finally {
|
|
42382
|
-
|
|
42383
|
-
publisher.close();
|
|
42384
|
-
} finally {
|
|
42385
|
-
outbox.close();
|
|
42386
|
-
}
|
|
42120
|
+
outbox.close();
|
|
42387
42121
|
}
|
|
42388
42122
|
}
|
|
42389
42123
|
}
|
|
@@ -42398,7 +42132,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
|
|
|
42398
42132
|
import { mkdir as mkdir5, realpath as realpath9, stat as stat8 } from "node:fs/promises";
|
|
42399
42133
|
import { dirname as dirname8, join as join18, resolve as resolve5 } from "node:path";
|
|
42400
42134
|
var IDENTIFIER_PATTERN9 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
42401
|
-
var RUNTIME_CREDENTIAL_PATTERN = /^
|
|
42135
|
+
var RUNTIME_CREDENTIAL_PATTERN = /^[a-zA-Z0-9_-]{32,256}$/;
|
|
42402
42136
|
var MobiusRuntimeConfigurationError = class extends Error {
|
|
42403
42137
|
code = "runtime_configuration_invalid";
|
|
42404
42138
|
constructor(message, options = {}) {
|