@moxt-ai/mobius 0.0.42 → 0.0.43

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.
Files changed (45) hide show
  1. package/dist/acp/session-config/session-config-protocol.d.ts +1 -0
  2. package/dist/acp/session-config/session-config-protocol.d.ts.map +1 -1
  3. package/dist/acp/session-config/session-config-protocol.js +77 -22
  4. package/dist/acp/session-config/session-config-protocol.js.map +1 -1
  5. package/dist/acp/session-manager.d.ts.map +1 -1
  6. package/dist/acp/session-manager.js +37 -4
  7. package/dist/acp/session-manager.js.map +1 -1
  8. package/dist/agent-catalog/agent-permission-profile.d.ts +16 -0
  9. package/dist/agent-catalog/agent-permission-profile.d.ts.map +1 -0
  10. package/dist/agent-catalog/agent-permission-profile.js +194 -0
  11. package/dist/agent-catalog/agent-permission-profile.js.map +1 -0
  12. package/dist/agent-catalog/agents/cursor-cli-agent.d.ts +1 -1
  13. package/dist/agent-catalog/agents/cursor-cli-agent.d.ts.map +1 -1
  14. package/dist/agent-catalog/agents/cursor-cli-agent.js +2 -4
  15. package/dist/agent-catalog/agents/cursor-cli-agent.js.map +1 -1
  16. package/dist/agent-catalog/agents/deepseek-harness-agent.d.ts.map +1 -1
  17. package/dist/agent-catalog/agents/deepseek-harness-agent.js +1 -2
  18. package/dist/agent-catalog/agents/deepseek-harness-agent.js.map +1 -1
  19. package/dist/agent-catalog/agents/opencode-agent.d.ts +1 -1
  20. package/dist/agent-catalog/agents/opencode-agent.d.ts.map +1 -1
  21. package/dist/agent-catalog/agents/opencode-agent.js +8 -1
  22. package/dist/agent-catalog/agents/opencode-agent.js.map +1 -1
  23. package/dist/agent-catalog/discover-local-agents.d.ts +0 -1
  24. package/dist/agent-catalog/discover-local-agents.d.ts.map +1 -1
  25. package/dist/agent-catalog/discover-local-agents.js +0 -1
  26. package/dist/agent-catalog/discover-local-agents.js.map +1 -1
  27. package/dist/agent-catalog/local-agent.d.ts +4 -1
  28. package/dist/agent-catalog/local-agent.d.ts.map +1 -1
  29. package/dist/agent-catalog/local-agent.js +12 -2
  30. package/dist/agent-catalog/local-agent.js.map +1 -1
  31. package/dist/bots/local-bot-grant-store.d.ts +3 -2
  32. package/dist/bots/local-bot-grant-store.d.ts.map +1 -1
  33. package/dist/bots/local-bot-grant-store.js +52 -7
  34. package/dist/bots/local-bot-grant-store.js.map +1 -1
  35. package/dist/cli.js +6653 -6171
  36. package/dist/cli.js.map +4 -4
  37. package/dist/index.js +541 -57
  38. package/dist/index.js.map +4 -4
  39. package/dist/run-daemon.d.ts.map +1 -1
  40. package/dist/run-daemon.js +45 -3
  41. package/dist/run-daemon.js.map +1 -1
  42. package/dist/runtime.d.ts.map +1 -1
  43. package/dist/runtime.js +5864 -5382
  44. package/dist/runtime.js.map +4 -4
  45. package/package.json +1 -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 record3 of pendingRecords.get(ctx) ?? []) {
16632
- const seen = ctx.seen.get(record3);
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);
@@ -20750,13 +20790,14 @@ var BotExecutionBindingApprovalRequest = class {
20750
20790
  bindingRevision;
20751
20791
  botId;
20752
20792
  completionPolicy;
20793
+ executionConfiguration;
20753
20794
  kind = BOT_BINDING_APPROVAL_REQUEST_KIND;
20754
20795
  requestId;
20755
20796
  requiredCapabilities;
20756
20797
  runtimeId;
20757
20798
  sessionConfigurations;
20758
20799
  workspaceRef;
20759
- constructor(requestId, botId, behaviorRevisionId, bindingId, bindingRevision, runtimeId, agentRef, workspaceRef, agentConfigRevision, behaviorInstructions, behaviorDigest, requiredCapabilities, allowedDeliveryTargets, completionPolicy, sessionConfigurations = []) {
20800
+ constructor(requestId, botId, behaviorRevisionId, bindingId, bindingRevision, runtimeId, agentRef, workspaceRef, agentConfigRevision, behaviorInstructions, behaviorDigest, requiredCapabilities, allowedDeliveryTargets, completionPolicy, executionConfiguration, sessionConfigurations = []) {
20760
20801
  this.requestId = requestId;
20761
20802
  this.botId = botId;
20762
20803
  this.behaviorRevisionId = behaviorRevisionId;
@@ -20776,6 +20817,7 @@ var BotExecutionBindingApprovalRequest = class {
20776
20817
  )
20777
20818
  );
20778
20819
  this.completionPolicy = completionPolicy;
20820
+ this.executionConfiguration = decodeAgentExecutionConfiguration(executionConfiguration);
20779
20821
  }
20780
20822
  toJSON() {
20781
20823
  const { sessionConfigurations, ...request } = this;
@@ -20843,6 +20885,7 @@ var BotSessionPromptCommand = class {
20843
20885
  executionCapabilitySecret;
20844
20886
  executionDeadlineAt;
20845
20887
  executionId;
20888
+ executionConfiguration;
20846
20889
  images;
20847
20890
  kind = BOT_SESSION_PROMPT_KIND;
20848
20891
  localGrantId;
@@ -20853,7 +20896,7 @@ var BotSessionPromptCommand = class {
20853
20896
  sessionId;
20854
20897
  targetCommandId;
20855
20898
  turnId;
20856
- constructor(sessionId, commandId, agentId, bindingId, directoryId2, additionalDirectoryIds, images, resources, prompt, executionId, executionCapabilityId, executionCapabilitySecret, executionDeadlineAt, botId, conversationId, turnId, behaviorRevisionId, bindingRevision, localGrantId, behaviorInstructions, behaviorDigest, allowedDeliveryTargets, replyRoute, sessionConfigurations = [], disposition = SessionPromptDisposition.Reject, targetCommandId = "") {
20899
+ constructor(sessionId, commandId, agentId, bindingId, directoryId2, additionalDirectoryIds, images, resources, prompt, executionId, executionCapabilityId, executionCapabilitySecret, executionDeadlineAt, botId, conversationId, turnId, behaviorRevisionId, bindingRevision, localGrantId, behaviorInstructions, behaviorDigest, allowedDeliveryTargets, replyRoute, executionConfiguration, sessionConfigurations = [], disposition = SessionPromptDisposition.Reject, targetCommandId = "") {
20857
20900
  this.sessionId = sessionId;
20858
20901
  this.commandId = commandId;
20859
20902
  this.agentId = agentId;
@@ -20882,6 +20925,7 @@ var BotSessionPromptCommand = class {
20882
20925
  )
20883
20926
  );
20884
20927
  this.replyRoute = replyRoute;
20928
+ this.executionConfiguration = decodeAgentExecutionConfiguration(executionConfiguration);
20885
20929
  this.sessionConfigurations = Object.freeze([...sessionConfigurations]);
20886
20930
  this.targetCommandId = targetCommandId;
20887
20931
  }
@@ -21067,6 +21111,7 @@ function decodeBotExecutionBindingApprovalRequest(encoded) {
21067
21111
  "bindingRevision",
21068
21112
  "botId",
21069
21113
  "completionPolicy",
21114
+ "executionConfiguration",
21070
21115
  "kind",
21071
21116
  "requestId",
21072
21117
  "requiredCapabilities",
@@ -21093,6 +21138,7 @@ function decodeBotExecutionBindingApprovalRequest(encoded) {
21093
21138
  readIdentifiers(value, "requiredCapabilities", 32),
21094
21139
  readTargets(value, "allowedDeliveryTargets"),
21095
21140
  readCompletionPolicy(value["completionPolicy"]),
21141
+ decodeAgentExecutionConfiguration(value["executionConfiguration"]),
21096
21142
  readSessionConfigurations(value)
21097
21143
  );
21098
21144
  }
@@ -21175,6 +21221,7 @@ function decodeBotSessionPromptCommand(encoded) {
21175
21221
  "executionCapabilitySecret",
21176
21222
  "executionDeadlineAt",
21177
21223
  "executionId",
21224
+ "executionConfiguration",
21178
21225
  "images",
21179
21226
  "kind",
21180
21227
  "localGrantId",
@@ -21228,6 +21275,7 @@ function decodeBotSessionPromptCommand(encoded) {
21228
21275
  readDigest(value, "behaviorDigest"),
21229
21276
  readTargets(value, "allowedDeliveryTargets"),
21230
21277
  readReplyRoute(value["replyRoute"]),
21278
+ decodeAgentExecutionConfiguration(value["executionConfiguration"]),
21231
21279
  readSessionConfigurations(value),
21232
21280
  disposition,
21233
21281
  targetCommandId
@@ -22112,6 +22160,199 @@ async function runBoundedProcess(options) {
22112
22160
  }
22113
22161
  }
22114
22162
 
22163
+ // src/agent-catalog/agent-permission-profile.ts
22164
+ var AGENT_DEFAULT_PERMISSION_MODE = AGENT_DEFAULT_EXECUTION_SETTING;
22165
+ var READ_ONLY_PERMISSION_MODE = "read-only";
22166
+ var WORKSPACE_WRITE_PERMISSION_MODE = "workspace-write";
22167
+ var DANGER_FULL_ACCESS_PERMISSION_MODE = "danger-full-access";
22168
+ var PERMISSION_MODE_CONFIG_ID = AGENT_PERMISSION_MODE_CONFIG_ID;
22169
+ var PERMISSION_MODE_MARKER = "MOBIUS_AGENT_PERMISSION_MODE";
22170
+ var AgentPermissionConfigurationError = class extends Error {
22171
+ code = "invalid_agent_permission_configuration";
22172
+ constructor(message, options = {}) {
22173
+ super(message, options);
22174
+ this.name = "AgentPermissionConfigurationError";
22175
+ }
22176
+ };
22177
+ var AgentPermissionProfile = class {
22178
+ option = (environment) => ({
22179
+ booleanValue: false,
22180
+ category: "_mobius_permission",
22181
+ currentValue: this.currentMode(environment),
22182
+ description: this.description,
22183
+ id: PERMISSION_MODE_CONFIG_ID,
22184
+ name: "Permissions",
22185
+ type: "select",
22186
+ values: this.values
22187
+ });
22188
+ };
22189
+ var AgentManagedPermissionProfile = class extends AgentPermissionProfile {
22190
+ description = "This Agent manages its own local permissions.";
22191
+ values = Object.freeze([
22192
+ {
22193
+ description: "Managed by the Agent",
22194
+ groupId: "",
22195
+ groupName: "",
22196
+ name: "Agent default",
22197
+ value: AGENT_DEFAULT_PERMISSION_MODE
22198
+ }
22199
+ ]);
22200
+ currentMode = () => AGENT_DEFAULT_PERMISSION_MODE;
22201
+ apply = (environment, permissionMode) => {
22202
+ if (permissionMode !== AGENT_DEFAULT_PERMISSION_MODE) {
22203
+ throw new AgentPermissionConfigurationError("The selected Agent does not support this permission mode");
22204
+ }
22205
+ return Object.freeze({ ...environment });
22206
+ };
22207
+ };
22208
+ var PiPermissionProfile = class extends AgentPermissionProfile {
22209
+ description = "Pi has no built-in sandbox and runs with the local Runtime user's authority.";
22210
+ values = Object.freeze([
22211
+ {
22212
+ description: "Pi default; unrestricted local execution with the Runtime user's authority",
22213
+ groupId: "",
22214
+ groupName: "",
22215
+ name: "Full access (Pi default)",
22216
+ value: DANGER_FULL_ACCESS_PERMISSION_MODE
22217
+ }
22218
+ ]);
22219
+ currentMode = () => DANGER_FULL_ACCESS_PERMISSION_MODE;
22220
+ apply = (environment, permissionMode) => {
22221
+ if (permissionMode !== DANGER_FULL_ACCESS_PERMISSION_MODE) {
22222
+ throw new AgentPermissionConfigurationError("Pi only supports its default full-access permission mode");
22223
+ }
22224
+ return Object.freeze({ ...environment });
22225
+ };
22226
+ };
22227
+ var adjustablePermissionValues = Object.freeze([
22228
+ {
22229
+ description: "Keep the Agent's existing permission policy",
22230
+ groupId: "",
22231
+ groupName: "",
22232
+ name: "Agent default",
22233
+ value: AGENT_DEFAULT_PERMISSION_MODE
22234
+ },
22235
+ {
22236
+ description: "Allow inspection without local writes or commands that can change state",
22237
+ groupId: "",
22238
+ groupName: "",
22239
+ name: "Read only",
22240
+ value: READ_ONLY_PERMISSION_MODE
22241
+ },
22242
+ {
22243
+ description: "Allow changes inside the selected workspace while protecting external paths",
22244
+ groupId: "",
22245
+ groupName: "",
22246
+ name: "Workspace write",
22247
+ value: WORKSPACE_WRITE_PERMISSION_MODE
22248
+ },
22249
+ {
22250
+ description: "Allow unrestricted local execution with the Runtime user's authority",
22251
+ groupId: "",
22252
+ groupName: "",
22253
+ name: "Full access",
22254
+ value: DANGER_FULL_ACCESS_PERMISSION_MODE
22255
+ }
22256
+ ]);
22257
+ function validateAdjustableMode(permissionMode) {
22258
+ if (!adjustablePermissionValues.some((value) => value.value === permissionMode)) {
22259
+ throw new AgentPermissionConfigurationError("The selected permission mode is unavailable");
22260
+ }
22261
+ return permissionMode;
22262
+ }
22263
+ var DeepSeekHarnessPermissionProfile = class extends AgentPermissionProfile {
22264
+ description = "Controls the local side effects allowed for this Agent session.";
22265
+ values = adjustablePermissionValues;
22266
+ currentMode = (environment) => validateAdjustableMode(environment["DSH_PERMISSION_MODE"] ?? WORKSPACE_WRITE_PERMISSION_MODE);
22267
+ apply = (environment, permissionMode) => {
22268
+ if (permissionMode === AGENT_DEFAULT_PERMISSION_MODE) {
22269
+ return Object.freeze({ ...environment });
22270
+ }
22271
+ return Object.freeze({
22272
+ ...environment,
22273
+ DSH_PERMISSION_MODE: validateAdjustableMode(permissionMode),
22274
+ [PERMISSION_MODE_MARKER]: permissionMode
22275
+ });
22276
+ };
22277
+ };
22278
+ function record2(value) {
22279
+ if (value === void 0) {
22280
+ return {};
22281
+ }
22282
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
22283
+ throw new AgentPermissionConfigurationError("The OpenCode inline configuration is invalid");
22284
+ }
22285
+ return Object.fromEntries(Object.entries(value));
22286
+ }
22287
+ function openCodeConfiguration(environment) {
22288
+ const encoded = environment["OPENCODE_CONFIG_CONTENT"];
22289
+ if (encoded === void 0 || encoded.length === 0) {
22290
+ return {};
22291
+ }
22292
+ try {
22293
+ return record2(JSON.parse(encoded));
22294
+ } catch (cause) {
22295
+ if (cause instanceof AgentPermissionConfigurationError) {
22296
+ throw cause;
22297
+ }
22298
+ throw new AgentPermissionConfigurationError("The OpenCode inline configuration is invalid", { cause });
22299
+ }
22300
+ }
22301
+ function openCodePermission(permissionMode) {
22302
+ if (permissionMode === READ_ONLY_PERMISSION_MODE) {
22303
+ return {
22304
+ "*": "deny",
22305
+ glob: "allow",
22306
+ grep: "allow",
22307
+ lsp: "allow",
22308
+ read: "allow",
22309
+ skill: "allow"
22310
+ };
22311
+ }
22312
+ if (permissionMode === WORKSPACE_WRITE_PERMISSION_MODE) {
22313
+ return {
22314
+ "*": "allow",
22315
+ external_directory: "ask"
22316
+ };
22317
+ }
22318
+ return "allow";
22319
+ }
22320
+ var OpenCodePermissionProfile = class extends AgentPermissionProfile {
22321
+ description = "Controls the local side effects allowed for this Agent session.";
22322
+ values = adjustablePermissionValues;
22323
+ currentMode = (environment) => validateAdjustableMode(environment[PERMISSION_MODE_MARKER] ?? AGENT_DEFAULT_PERMISSION_MODE);
22324
+ apply = (environment, permissionMode) => {
22325
+ const validated = validateAdjustableMode(permissionMode);
22326
+ if (validated === AGENT_DEFAULT_PERMISSION_MODE) {
22327
+ return Object.freeze({ ...environment });
22328
+ }
22329
+ return Object.freeze({
22330
+ ...environment,
22331
+ OPENCODE_CONFIG_CONTENT: JSON.stringify({
22332
+ ...openCodeConfiguration(environment),
22333
+ permission: openCodePermission(validated)
22334
+ }),
22335
+ [PERMISSION_MODE_MARKER]: validated
22336
+ });
22337
+ };
22338
+ };
22339
+ var agentManagedPermissionProfile = new AgentManagedPermissionProfile();
22340
+ var deepSeekHarnessPermissionProfile = new DeepSeekHarnessPermissionProfile();
22341
+ var openCodePermissionProfile = new OpenCodePermissionProfile();
22342
+ var piPermissionProfile = new PiPermissionProfile();
22343
+ function permissionProfileForAgent(agentId) {
22344
+ if (agentId === "deepseek-harness") {
22345
+ return deepSeekHarnessPermissionProfile;
22346
+ }
22347
+ if (agentId === "opencode") {
22348
+ return openCodePermissionProfile;
22349
+ }
22350
+ if (agentId === "pi") {
22351
+ return piPermissionProfile;
22352
+ }
22353
+ return agentManagedPermissionProfile;
22354
+ }
22355
+
22115
22356
  // src/agent-catalog/local-agent.ts
22116
22357
  function readTrustedIdentity(path2) {
22117
22358
  const resolvedPath = realpathSync(path2);
@@ -22125,7 +22366,7 @@ function readTrustedIdentity(path2) {
22125
22366
  metadata.ctimeMs
22126
22367
  );
22127
22368
  }
22128
- var LocalAgentDefinition = class {
22369
+ var LocalAgentDefinition = class _LocalAgentDefinition {
22129
22370
  adapterIdentity;
22130
22371
  adapterPath;
22131
22372
  adapterVersion;
@@ -22137,8 +22378,9 @@ var LocalAgentDefinition = class {
22137
22378
  environment;
22138
22379
  id;
22139
22380
  label;
22381
+ permissionProfile;
22140
22382
  promptTimeoutMilliseconds;
22141
- constructor(id, label, command, arguments_, environment = {}, adapterVersion = "", agentVersion = "", adapterIdentity = readTrustedIdentity(command), agentIdentity = adapterIdentity, promptTimeoutMilliseconds = 30 * 60 * 1e3, capabilities = unsupportedSessionCapabilities()) {
22383
+ constructor(id, label, command, arguments_, environment = {}, adapterVersion = "", agentVersion = "", adapterIdentity = readTrustedIdentity(command), agentIdentity = adapterIdentity, promptTimeoutMilliseconds = 30 * 60 * 1e3, capabilities = unsupportedSessionCapabilities(), permissionProfile = permissionProfileForAgent(id)) {
22142
22384
  if (!Number.isSafeInteger(promptTimeoutMilliseconds) || promptTimeoutMilliseconds < 1) {
22143
22385
  throw new Error("The local Agent prompt deadline is invalid");
22144
22386
  }
@@ -22150,11 +22392,31 @@ var LocalAgentDefinition = class {
22150
22392
  this.capabilities = Object.freeze({ ...capabilities });
22151
22393
  this.id = id;
22152
22394
  this.label = label;
22395
+ this.permissionProfile = permissionProfile;
22153
22396
  this.promptTimeoutMilliseconds = promptTimeoutMilliseconds;
22154
22397
  this.command = adapterIdentity.realPath;
22155
22398
  this.arguments = Object.freeze([...arguments_]);
22156
- this.environment = Object.freeze({ ...environment });
22399
+ this.environment = permissionProfile.apply(environment, permissionProfile.currentMode(environment));
22157
22400
  }
22401
+ withPermissionMode = (permissionMode) => {
22402
+ if (permissionMode === AGENT_DEFAULT_PERMISSION_MODE && this.permissionProfile.currentMode(this.environment) === AGENT_DEFAULT_PERMISSION_MODE) {
22403
+ return this;
22404
+ }
22405
+ return new _LocalAgentDefinition(
22406
+ this.id,
22407
+ this.label,
22408
+ this.command,
22409
+ this.arguments,
22410
+ this.permissionProfile.apply(this.environment, permissionMode),
22411
+ this.adapterVersion,
22412
+ this.agentVersion,
22413
+ this.adapterIdentity,
22414
+ this.agentIdentity,
22415
+ this.promptTimeoutMilliseconds,
22416
+ this.capabilities,
22417
+ this.permissionProfile
22418
+ );
22419
+ };
22158
22420
  };
22159
22421
  var InstallableAgentDefinition = class {
22160
22422
  id;
@@ -30464,8 +30726,70 @@ function normalizeConfigOptions(value, modes) {
30464
30726
  }
30465
30727
  return normalized.slice(0, 100);
30466
30728
  }
30729
+ function insertRequiredOption(current, required2, afterCategory = "") {
30730
+ if (current.some((option2) => option2.id === required2.id || option2.category === required2.category)) {
30731
+ return current;
30732
+ }
30733
+ if (current.length < MAXIMUM_CONFIG_OPTIONS) {
30734
+ if (afterCategory.length === 0) {
30735
+ return [required2, ...current];
30736
+ }
30737
+ const index3 = current.findIndex((option2) => option2.category === afterCategory);
30738
+ if (index3 < 0) {
30739
+ return [...current, required2];
30740
+ }
30741
+ return [...current.slice(0, index3 + 1), required2, ...current.slice(index3 + 1)];
30742
+ }
30743
+ if (afterCategory.length === 0) {
30744
+ return [required2, ...current.slice(0, MAXIMUM_CONFIG_OPTIONS - 1)];
30745
+ }
30746
+ const index2 = current.findIndex((option2) => option2.category === afterCategory);
30747
+ if (index2 < 0) {
30748
+ return [...current.slice(0, MAXIMUM_CONFIG_OPTIONS - 1), required2];
30749
+ }
30750
+ if (index2 < MAXIMUM_CONFIG_OPTIONS - 1) {
30751
+ return [...current.slice(0, index2 + 1), required2, ...current.slice(index2 + 1, MAXIMUM_CONFIG_OPTIONS - 1)];
30752
+ }
30753
+ const anchor2 = current[index2];
30754
+ if (anchor2 === void 0) {
30755
+ throw new SessionConfigProtocolError("The required Agent execution setting is unavailable");
30756
+ }
30757
+ return [...current.slice(0, MAXIMUM_CONFIG_OPTIONS - 2), anchor2, required2];
30758
+ }
30759
+ function validRequiredSelect(option2) {
30760
+ return option2.type === "select" && option2.currentValue.length > 0 && option2.values.some((value) => value.value === option2.currentValue);
30761
+ }
30762
+ function ensureModelOption(current) {
30763
+ const existing = current.find((option2) => option2.id === "model" || option2.category === "model");
30764
+ if (existing !== void 0 && validRequiredSelect(existing)) {
30765
+ return current;
30766
+ }
30767
+ const unavailable = {
30768
+ booleanValue: false,
30769
+ category: "model",
30770
+ currentValue: AGENT_DEFAULT_REASONING_EFFORT,
30771
+ description: "This Agent does not expose an adjustable model.",
30772
+ id: "model",
30773
+ name: "Model",
30774
+ type: "select",
30775
+ values: [
30776
+ {
30777
+ description: "Selected by the Agent",
30778
+ groupId: "",
30779
+ groupName: "",
30780
+ name: "Agent default",
30781
+ value: AGENT_DEFAULT_REASONING_EFFORT
30782
+ }
30783
+ ]
30784
+ };
30785
+ return insertRequiredOption(
30786
+ current.filter((option2) => option2.id !== "model" && option2.category !== "model"),
30787
+ unavailable
30788
+ );
30789
+ }
30467
30790
  function ensureReasoningEffortOption(current) {
30468
- if (current.some((option2) => option2.category === "thought_level")) {
30791
+ const existing = current.find((option2) => option2.id === "reasoning_effort" || option2.category === "thought_level");
30792
+ if (existing !== void 0 && validRequiredSelect(existing)) {
30469
30793
  return current;
30470
30794
  }
30471
30795
  const unavailable = {
@@ -30486,28 +30810,27 @@ function ensureReasoningEffortOption(current) {
30486
30810
  }
30487
30811
  ]
30488
30812
  };
30489
- const modelIndex = current.findIndex((option2) => option2.category === "model");
30490
- if (current.length < MAXIMUM_CONFIG_OPTIONS) {
30491
- if (modelIndex < 0) {
30492
- return [...current, unavailable];
30493
- }
30494
- return [...current.slice(0, modelIndex + 1), unavailable, ...current.slice(modelIndex + 1)];
30495
- }
30496
- if (modelIndex < 0) {
30497
- return [...current.slice(0, MAXIMUM_CONFIG_OPTIONS - 1), unavailable];
30498
- }
30499
- if (modelIndex < MAXIMUM_CONFIG_OPTIONS - 1) {
30500
- return [
30501
- ...current.slice(0, modelIndex + 1),
30502
- unavailable,
30503
- ...current.slice(modelIndex + 1, MAXIMUM_CONFIG_OPTIONS - 1)
30504
- ];
30505
- }
30506
- const model = current[modelIndex];
30507
- if (model === void 0) {
30508
- return [...current.slice(0, MAXIMUM_CONFIG_OPTIONS - 1), unavailable];
30813
+ return insertRequiredOption(
30814
+ current.filter((option2) => option2.id !== "reasoning_effort" && option2.category !== "thought_level"),
30815
+ unavailable,
30816
+ "model"
30817
+ );
30818
+ }
30819
+ function ensureRequiredExecutionOptions(current, permission) {
30820
+ const normalized = ensureReasoningEffortOption(ensureModelOption(current));
30821
+ const model = normalized.find(
30822
+ (option2) => (option2.id === "model" || option2.category === "model") && validRequiredSelect(option2)
30823
+ );
30824
+ const reasoningEffort = normalized.find(
30825
+ (option2) => (option2.id === "reasoning_effort" || option2.category === "thought_level") && validRequiredSelect(option2)
30826
+ );
30827
+ if (model === void 0 || reasoningEffort === void 0) {
30828
+ throw new SessionConfigProtocolError("The required Agent execution settings are unavailable");
30509
30829
  }
30510
- return [...current.slice(0, MAXIMUM_CONFIG_OPTIONS - 2), model, unavailable];
30830
+ const optional2 = normalized.filter(
30831
+ (option2) => option2.id !== permission.id && option2.category !== permission.category && option2.id !== "model" && option2.category !== "model" && option2.id !== "reasoning_effort" && option2.category !== "thought_level"
30832
+ );
30833
+ return [permission, model, reasoningEffort, ...optional2].slice(0, MAXIMUM_CONFIG_OPTIONS);
30511
30834
  }
30512
30835
  function normalizeStandardLifecycle(response) {
30513
30836
  const lifecycle = isRecord5(response) ? response : {};
@@ -31582,6 +31905,7 @@ var AcpProcessSession = class _AcpProcessSession {
31582
31905
  #preSessionUpdates = [];
31583
31906
  #processExit;
31584
31907
  #metrics;
31908
+ #permissionProfile;
31585
31909
  #sessionConfigProtocol;
31586
31910
  #store;
31587
31911
  #verifiedAgentVersion;
@@ -31623,6 +31947,7 @@ var AcpProcessSession = class _AcpProcessSession {
31623
31947
  this.#getObserver = getObserver;
31624
31948
  this.#mobiusSessionId = mobiusSessionId;
31625
31949
  this.#metrics = metrics;
31950
+ this.#permissionProfile = agent.permissionProfile;
31626
31951
  this.#sessionConfigProtocol = sessionConfigProtocolForAgent(agent.id);
31627
31952
  this.#store = store;
31628
31953
  this.#verifiedAgentVersion = agent.agentVersion;
@@ -32055,7 +32380,10 @@ var AcpProcessSession = class _AcpProcessSession {
32055
32380
  this.selectNativeSession(created.sessionId);
32056
32381
  lifecycleResponse = created;
32057
32382
  }
32058
- this.#configOptions = this.#sessionConfigProtocol.normalizeLifecycle(lifecycleResponse);
32383
+ this.#configOptions = ensureRequiredExecutionOptions(
32384
+ this.#sessionConfigProtocol.normalizeLifecycle(lifecycleResponse),
32385
+ this.#permissionProfile.option(this.#environment)
32386
+ );
32059
32387
  await this.#updateTail;
32060
32388
  signal.throwIfAborted();
32061
32389
  if (this.#prompted) {
@@ -32158,7 +32486,10 @@ var AcpProcessSession = class _AcpProcessSession {
32158
32486
  );
32159
32487
  await this.#updateTail;
32160
32488
  if (this.#configRevision === configRevision) {
32161
- this.#configOptions = configured;
32489
+ this.#configOptions = ensureRequiredExecutionOptions(
32490
+ configured,
32491
+ this.#permissionProfile.option(this.#environment)
32492
+ );
32162
32493
  }
32163
32494
  } catch (error62) {
32164
32495
  if (error62 instanceof SessionConfigProtocolError) {
@@ -32631,9 +32962,9 @@ var AcpProcessSession = class _AcpProcessSession {
32631
32962
  return;
32632
32963
  }
32633
32964
  if (update.sessionUpdate === "config_option_update") {
32634
- this.#configOptions = this.#sessionConfigProtocol.normalizeUpdate(
32635
- this.#configOptions,
32636
- update.configOptions
32965
+ this.#configOptions = ensureRequiredExecutionOptions(
32966
+ this.#sessionConfigProtocol.normalizeUpdate(this.#configOptions, update.configOptions),
32967
+ this.#permissionProfile.option(this.#environment)
32637
32968
  );
32638
32969
  this.#configRevision += 1;
32639
32970
  await this.emitConfigUpdate();
@@ -33171,6 +33502,9 @@ var AcpSessionManager = class {
33171
33502
  );
33172
33503
  try {
33173
33504
  for (const desired of desiredConfigOptions) {
33505
+ if (desired.id === PERMISSION_MODE_CONFIG_ID) {
33506
+ continue;
33507
+ }
33174
33508
  const current = runtime.prepared().configOptions.find((option2) => option2.id === desired.id);
33175
33509
  if (current === void 0 || current.type !== desired.type) {
33176
33510
  continue;
@@ -33363,6 +33697,30 @@ var AcpSessionManager = class {
33363
33697
  this.#beginSessionUse(options.sessionId);
33364
33698
  try {
33365
33699
  const runtime = await this.ensureSession(options);
33700
+ if (options.configId === PERMISSION_MODE_CONFIG_ID) {
33701
+ const permission = runtime.prepared().configOptions.find((candidate) => candidate.id === PERMISSION_MODE_CONFIG_ID);
33702
+ if (permission === void 0 || permission.type !== "select" || options.valueType !== "select" || permission.values.length < 2 || !permission.values.some((value) => value.value === options.value)) {
33703
+ throw new AcpExecutionError(
33704
+ "The requested Agent permission mode is unavailable",
33705
+ {},
33706
+ "invalid_session_configuration"
33707
+ );
33708
+ }
33709
+ if (permission.currentValue === options.value) {
33710
+ return runtime.prepared().configOptions;
33711
+ }
33712
+ try {
33713
+ return (await this.prepareExecutionSession({
33714
+ ...options,
33715
+ agent: options.agent.withPermissionMode(options.value)
33716
+ })).configOptions;
33717
+ } catch (error62) {
33718
+ if (error62 instanceof AgentPermissionConfigurationError) {
33719
+ throw new AcpExecutionError(error62.message, { cause: error62 }, error62.code);
33720
+ }
33721
+ throw error62;
33722
+ }
33723
+ }
33366
33724
  return await runtime.configure(options);
33367
33725
  } finally {
33368
33726
  this.#endSessionUse(options.sessionId);
@@ -33856,7 +34214,7 @@ var AuditStore = class {
33856
34214
  this.database.exec("ALTER TABLE audit_events ADD COLUMN details_json TEXT NOT NULL DEFAULT '{}'");
33857
34215
  }
33858
34216
  }
33859
- record(record3) {
34217
+ record(record4) {
33860
34218
  this.database.prepare(
33861
34219
  `
33862
34220
  INSERT INTO audit_events (
@@ -33869,10 +34227,10 @@ var AuditStore = class {
33869
34227
  `
33870
34228
  ).run(
33871
34229
  (/* @__PURE__ */ new Date()).toISOString(),
33872
- record3.event,
33873
- record3.commandId,
33874
- record3.sessionId,
33875
- JSON.stringify(record3.details ?? {})
34230
+ record4.event,
34231
+ record4.commandId,
34232
+ record4.sessionId,
34233
+ JSON.stringify(record4.details ?? {})
33876
34234
  );
33877
34235
  }
33878
34236
  close() {
@@ -33914,12 +34272,13 @@ var LocalBotGrant = class {
33914
34272
  bindingRevision;
33915
34273
  botId;
33916
34274
  expiresAt;
34275
+ executionConfiguration;
33917
34276
  localGrantId;
33918
34277
  revocationEpoch;
33919
34278
  workspaceIdentityDigest;
33920
34279
  workspacePath;
33921
34280
  workspaceRef;
33922
- constructor(localGrantId, botId, behaviorRevisionId, behaviorDigest, bindingId, bindingRevision, agent, agentIdentityDigest, workspaceRef, workspacePath, workspaceIdentityDigest, allowedDeliveryTargetIds, expiresAt, revocationEpoch) {
34281
+ constructor(localGrantId, botId, behaviorRevisionId, behaviorDigest, bindingId, bindingRevision, agent, agentIdentityDigest, workspaceRef, workspacePath, workspaceIdentityDigest, allowedDeliveryTargetIds, executionConfiguration, expiresAt, revocationEpoch) {
33923
34282
  this.localGrantId = localGrantId;
33924
34283
  this.botId = botId;
33925
34284
  this.behaviorRevisionId = behaviorRevisionId;
@@ -33932,6 +34291,7 @@ var LocalBotGrant = class {
33932
34291
  this.workspacePath = workspacePath;
33933
34292
  this.workspaceIdentityDigest = workspaceIdentityDigest;
33934
34293
  this.allowedDeliveryTargetIds = Object.freeze([...allowedDeliveryTargetIds]);
34294
+ this.executionConfiguration = executionConfiguration;
33935
34295
  this.expiresAt = expiresAt;
33936
34296
  this.revocationEpoch = revocationEpoch;
33937
34297
  }
@@ -33950,6 +34310,16 @@ function agentDigest(agent) {
33950
34310
  })
33951
34311
  );
33952
34312
  }
34313
+ function configurePermission(agent, permissionMode) {
34314
+ try {
34315
+ return agent.withPermissionMode(permissionMode);
34316
+ } catch (cause) {
34317
+ if (cause instanceof AgentPermissionConfigurationError) {
34318
+ throw new LocalBotAuthorizationError("binding_incompatible", cause.message, { cause });
34319
+ }
34320
+ throw cause;
34321
+ }
34322
+ }
33953
34323
  function workspaceDigest(path2) {
33954
34324
  return digest(path2);
33955
34325
  }
@@ -33971,6 +34341,9 @@ function exactSessionConfigurations(left, right) {
33971
34341
  return approved !== void 0 && approved.booleanValue === selection.booleanValue && approved.value === selection.value && approved.valueType === selection.valueType;
33972
34342
  });
33973
34343
  }
34344
+ function exactExecutionConfiguration(left, right) {
34345
+ return left.permissionMode === right.permissionMode && exactSessionConfigurations([left.model, left.reasoningEffort], [right.model, right.reasoningEffort]);
34346
+ }
33974
34347
  function rowString(row, key) {
33975
34348
  const value = Reflect.get(row, key);
33976
34349
  if (typeof value !== "string") {
@@ -34016,6 +34389,15 @@ function parseSessionConfigurations(encoded) {
34016
34389
  throw new LocalBotAuthorizationError("local_grant_invalid", "The local Bot grant is invalid", { cause });
34017
34390
  }
34018
34391
  }
34392
+ function parseExecutionConfiguration(encoded) {
34393
+ let value;
34394
+ try {
34395
+ value = JSON.parse(encoded);
34396
+ return decodeAgentExecutionConfiguration(value);
34397
+ } catch (cause) {
34398
+ throw new LocalBotAuthorizationError("local_grant_invalid", "The local Bot grant is invalid", { cause });
34399
+ }
34400
+ }
34019
34401
  var LocalBotGrantStore = class {
34020
34402
  #database;
34021
34403
  constructor(path2) {
@@ -34053,6 +34435,10 @@ var LocalBotGrantStore = class {
34053
34435
  local_grant_id TEXT PRIMARY KEY,
34054
34436
  session_configurations_json TEXT NOT NULL
34055
34437
  ) STRICT;
34438
+ CREATE TABLE IF NOT EXISTS local_bot_grant_execution_configurations (
34439
+ local_grant_id TEXT PRIMARY KEY,
34440
+ execution_configuration_json TEXT NOT NULL
34441
+ ) STRICT;
34056
34442
  `);
34057
34443
  }
34058
34444
  approve = async (request, catalog, directories, bindingAuthorityId, now, signal) => {
@@ -34111,6 +34497,11 @@ var LocalBotGrantStore = class {
34111
34497
  local_grant_id, session_configurations_json
34112
34498
  ) VALUES (?, ?)`
34113
34499
  ).run(localGrantId, JSON.stringify(request.sessionConfigurations));
34500
+ this.#database.prepare(
34501
+ `INSERT INTO local_bot_grant_execution_configurations (
34502
+ local_grant_id, execution_configuration_json
34503
+ ) VALUES (?, ?)`
34504
+ ).run(localGrantId, JSON.stringify(request.executionConfiguration));
34114
34505
  this.#database.prepare(
34115
34506
  `INSERT INTO local_bot_binding_resolutions (
34116
34507
  request_id, binding_id, local_grant_id, resolved_at, result
@@ -34137,15 +34528,20 @@ var LocalBotGrantStore = class {
34137
34528
  signal.throwIfAborted();
34138
34529
  const row = this.#database.prepare(
34139
34530
  `SELECT grants.*, COALESCE(configurations.session_configurations_json, '[]')
34140
- AS session_configurations_json
34531
+ AS session_configurations_json,
34532
+ COALESCE(execution.execution_configuration_json, ?)
34533
+ AS execution_configuration_json
34141
34534
  FROM local_bot_grants AS grants
34142
34535
  LEFT JOIN local_bot_grant_configurations AS configurations
34143
34536
  ON configurations.local_grant_id = grants.local_grant_id
34537
+ LEFT JOIN local_bot_grant_execution_configurations AS execution
34538
+ ON execution.local_grant_id = grants.local_grant_id
34144
34539
  WHERE grants.local_grant_id = ? AND grants.bot_id = ?
34145
34540
  AND behavior_revision_id = ? AND behavior_digest = ?
34146
34541
  AND binding_id = ? AND binding_revision = ?
34147
34542
  AND agent_ref = ?`
34148
34543
  ).get(
34544
+ JSON.stringify(DEFAULT_AGENT_EXECUTION_CONFIGURATION),
34149
34545
  command.localGrantId,
34150
34546
  command.botId,
34151
34547
  command.behaviorRevisionId,
@@ -34175,7 +34571,16 @@ var LocalBotGrantStore = class {
34175
34571
  "The Bot Agent configuration differs from its binding"
34176
34572
  );
34177
34573
  }
34178
- const agent = catalog.find(command.agentId);
34574
+ const approvedExecutionConfiguration = parseExecutionConfiguration(
34575
+ rowString(row, "execution_configuration_json")
34576
+ );
34577
+ if (!exactExecutionConfiguration(approvedExecutionConfiguration, command.executionConfiguration)) {
34578
+ throw new LocalBotAuthorizationError(
34579
+ "binding_not_approved",
34580
+ "The Bot execution configuration differs from its binding"
34581
+ );
34582
+ }
34583
+ const agent = configurePermission(catalog.find(command.agentId), command.executionConfiguration.permissionMode);
34179
34584
  const [adapterUnchanged, agentUnchanged] = await Promise.all([
34180
34585
  revalidateExecutable(agent.adapterIdentity),
34181
34586
  revalidateExecutable(agent.agentIdentity)
@@ -34224,6 +34629,7 @@ var LocalBotGrantStore = class {
34224
34629
  workspacePath,
34225
34630
  currentWorkspaceDigest,
34226
34631
  approvedTargets,
34632
+ approvedExecutionConfiguration,
34227
34633
  expiresAt,
34228
34634
  revocationEpoch
34229
34635
  );
@@ -34240,7 +34646,10 @@ var LocalBotGrantStore = class {
34240
34646
  this.#database.close();
34241
34647
  };
34242
34648
  resolveProposal = async (request, catalog, directories, bindingAuthorityId, signal) => {
34243
- const agent = catalog.find(request.agentRef);
34649
+ const agent = configurePermission(
34650
+ catalog.find(request.agentRef),
34651
+ request.executionConfiguration.permissionMode
34652
+ );
34244
34653
  if (request.requiredCapabilities.includes("embedded-context") && !agent.capabilities.embeddedContextPrompt) {
34245
34654
  throw new LocalBotAuthorizationError(
34246
34655
  "binding_incompatible",
@@ -35456,7 +35865,7 @@ var CopilotCliAgentSpecification = class extends DirectAcpAgentDefinition {
35456
35865
  };
35457
35866
 
35458
35867
  // src/agent-catalog/agents/cursor-cli-agent.ts
35459
- var CURSOR_CLI_TESTED_VERSION = "2026.09.02-c22c1a3";
35868
+ var CURSOR_CLI_TESTED_VERSION = "2026.09.15-d2fe57e";
35460
35869
  var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
35461
35870
  adapterVersion = CURSOR_CLI_TESTED_VERSION;
35462
35871
  authenticationCommand = () => "cursor-agent login";
@@ -35472,7 +35881,7 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
35472
35881
  }
35473
35882
  verifyAcp = async (connection, initialized, defaultWorkspace, signal) => {
35474
35883
  const capabilities = initialized.agentCapabilities ?? {};
35475
- if (capabilities.loadSession !== true || capabilities.sessionCapabilities?.list == null || !(initialized.authMethods ?? []).some((method) => method.id === "cursor_login")) {
35884
+ if (capabilities.loadSession !== true || capabilities.sessionCapabilities?.list == null) {
35476
35885
  throw new AgentProbeError("acp_incompatible", "Cursor CLI reported an unsupported ACP capability set");
35477
35886
  }
35478
35887
  await verifySessionCreation(connection, capabilities, defaultWorkspace, signal, this.label);
@@ -35555,11 +35964,10 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
35555
35964
  context.signal.throwIfAborted();
35556
35965
  }
35557
35966
  if (selectedHome === void 0 || selectedHome.length === 0) {
35558
- return Object.freeze({ DSH_PERMISSION_MODE: "workspace-write" });
35967
+ return Object.freeze({});
35559
35968
  }
35560
35969
  return Object.freeze({
35561
- DSH_HOME: await validateAgentHome(selectedHome),
35562
- DSH_PERMISSION_MODE: "workspace-write"
35970
+ DSH_HOME: await validateAgentHome(selectedHome)
35563
35971
  });
35564
35972
  };
35565
35973
  resolveManagedAgent = async (stateDirectory, _platform, signal) => {
@@ -36066,7 +36474,14 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
36066
36474
  ]
36067
36475
  );
36068
36476
  }
36069
- createLaunchEnvironment = async (_agent, _context) => Object.freeze({ OPENCODE_DISABLE_AUTOUPDATE: "1" });
36477
+ createLaunchEnvironment = async (_agent, context) => {
36478
+ const environment = { OPENCODE_DISABLE_AUTOUPDATE: "1" };
36479
+ const inlineConfiguration = context.environment["OPENCODE_CONFIG_CONTENT"];
36480
+ if (typeof inlineConfiguration === "string" && inlineConfiguration.length > 0) {
36481
+ environment["OPENCODE_CONFIG_CONTENT"] = inlineConfiguration;
36482
+ }
36483
+ return Object.freeze(environment);
36484
+ };
36070
36485
  resolveManagedAgent = async (stateDirectory, platform, signal) => await validateManagedAgentArchive(
36071
36486
  join10(stateDirectory, "agents", this.id, OPENCODE_MANAGED_VERSION),
36072
36487
  openCodeManagedArchive(platform, process.arch),
@@ -37750,7 +38165,7 @@ function invalidResponse(message) {
37750
38165
  function isRecord12(value) {
37751
38166
  return typeof value === "object" && value !== null && !Array.isArray(value);
37752
38167
  }
37753
- function record2(value, name) {
38168
+ function record3(value, name) {
37754
38169
  if (!isRecord12(value)) {
37755
38170
  throw invalidResponse(`The service returned an invalid ${name}`);
37756
38171
  }
@@ -37885,11 +38300,11 @@ function uploadingArtifact(value) {
37885
38300
  );
37886
38301
  }
37887
38302
  function decodeMobiusArtifactUpload(value) {
37888
- const artifact = record2(value, "artifact upload authorization");
38303
+ const artifact = record3(value, "artifact upload authorization");
37889
38304
  return new MobiusArtifactUpload(uploadingArtifact(artifact), stringField(artifact, "uploadToken", 256));
37890
38305
  }
37891
38306
  function decodeMobiusArtifact(value) {
37892
- const artifact = record2(value, "artifact");
38307
+ const artifact = record3(value, "artifact");
37893
38308
  const state = stringField(artifact, "state", 32);
37894
38309
  if (state === "uploading") {
37895
38310
  return uploadingArtifact(artifact);
@@ -40129,9 +40544,9 @@ function botIpcSocketPath() {
40129
40544
  var DaemonAcpObserver = class {
40130
40545
  #config;
40131
40546
  #record;
40132
- constructor(config2, record3) {
40547
+ constructor(config2, record4) {
40133
40548
  this.#config = config2;
40134
- this.#record = record3;
40549
+ this.#record = record4;
40135
40550
  }
40136
40551
  importLocalArtifact = async (sessionId, artifact, signal) => {
40137
40552
  try {
@@ -41041,9 +41456,55 @@ function botExecutionAgent(agent, contextHandle, socketPath) {
41041
41456
  agent.adapterIdentity,
41042
41457
  agent.agentIdentity,
41043
41458
  agent.promptTimeoutMilliseconds,
41044
- agent.capabilities
41459
+ agent.capabilities,
41460
+ agent.permissionProfile
41045
41461
  );
41046
41462
  }
41463
+ function assertPreparedPermission(configOptions, permissionMode) {
41464
+ const permission = configOptions.find((option2) => option2.id === "permission_mode");
41465
+ if (permission === void 0 || permission.type !== "select" || permissionMode !== AGENT_DEFAULT_EXECUTION_SETTING && permission.currentValue !== permissionMode) {
41466
+ throw new AcpExecutionError(
41467
+ "The required Agent permission mode is unavailable",
41468
+ {},
41469
+ "invalid_session_configuration"
41470
+ );
41471
+ }
41472
+ }
41473
+ async function applyRequiredExecutionSelection(sessions, configOptions, selection, category, agent, cwd, additionalDirectories, sessionId, signal) {
41474
+ const option2 = configOptions.find((candidate) => candidate.id === selection.configId);
41475
+ if (option2 === void 0 || option2.type !== "select" || option2.category !== category || selection.valueType !== "select" || selection.booleanValue) {
41476
+ throw new AcpExecutionError(
41477
+ `The required Agent setting ${selection.configId} is unavailable`,
41478
+ {},
41479
+ "invalid_session_configuration"
41480
+ );
41481
+ }
41482
+ if (selection.value === AGENT_DEFAULT_EXECUTION_SETTING) {
41483
+ return configOptions;
41484
+ }
41485
+ if (!option2.values.some((value) => value.value === selection.value)) {
41486
+ throw new AcpExecutionError(
41487
+ `The required Agent setting ${selection.configId} is unavailable`,
41488
+ {},
41489
+ "invalid_session_configuration"
41490
+ );
41491
+ }
41492
+ if (option2.currentValue === selection.value) {
41493
+ return configOptions;
41494
+ }
41495
+ return await sessions.configureSession({
41496
+ additionalDirectories,
41497
+ agent,
41498
+ booleanValue: false,
41499
+ configId: selection.configId,
41500
+ cwd,
41501
+ requestId: `cfg_${randomUUID6()}`,
41502
+ sessionId,
41503
+ signal,
41504
+ value: selection.value,
41505
+ valueType: "select"
41506
+ });
41507
+ }
41047
41508
  async function executeBotPrompt(outbox, publisher, command, config2, directories, audit, sessions, grants, contexts, applicator, ipc, attemptId, activateAttempt, timer, signal) {
41048
41509
  const activities = new CoalescingDaemonActivityPublisher(timer, (activity) => {
41049
41510
  publisher.recordAttempt(command.sessionId, encodeDaemonActivity(command, activity), attemptId);
@@ -41144,13 +41605,36 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
41144
41605
  const lease = contexts.activate(command);
41145
41606
  try {
41146
41607
  const agent = botExecutionAgent(grant.agent, lease.context.contextHandle, ipc.socketPath);
41147
- await sessions.prepareExecutionSession({
41608
+ const prepared = await sessions.prepareExecutionSession({
41148
41609
  additionalDirectories: resolved.additionalDirectories,
41149
41610
  agent,
41150
41611
  cwd: resolved.cwd,
41151
41612
  sessionId: command.sessionId,
41152
41613
  signal: executionSignal
41153
41614
  });
41615
+ assertPreparedPermission(prepared.configOptions, grant.executionConfiguration.permissionMode);
41616
+ let configOptions = await applyRequiredExecutionSelection(
41617
+ sessions,
41618
+ prepared.configOptions,
41619
+ grant.executionConfiguration.model,
41620
+ "model",
41621
+ agent,
41622
+ resolved.cwd,
41623
+ resolved.additionalDirectories,
41624
+ command.sessionId,
41625
+ executionSignal
41626
+ );
41627
+ configOptions = await applyRequiredExecutionSelection(
41628
+ sessions,
41629
+ configOptions,
41630
+ grant.executionConfiguration.reasoningEffort,
41631
+ "thought_level",
41632
+ agent,
41633
+ resolved.cwd,
41634
+ resolved.additionalDirectories,
41635
+ command.sessionId,
41636
+ executionSignal
41637
+ );
41154
41638
  for (const selection of command.sessionConfigurations) {
41155
41639
  await sessions.configureSession({
41156
41640
  additionalDirectories: resolved.additionalDirectories,
@@ -42398,7 +42882,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
42398
42882
  import { mkdir as mkdir5, realpath as realpath9, stat as stat8 } from "node:fs/promises";
42399
42883
  import { dirname as dirname8, join as join18, resolve as resolve5 } from "node:path";
42400
42884
  var IDENTIFIER_PATTERN9 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
42401
- var RUNTIME_CREDENTIAL_PATTERN = /^(?:[a-zA-Z0-9_-]{43}|prj_[a-zA-Z0-9_-]{24}_[a-zA-Z0-9_-]{43}|prj_(?:wn|en|sa|we|ee|ap|oc|af|me)_01_[a-zA-Z0-9_-]{24}_[a-zA-Z0-9_-]{43})$/;
42885
+ var RUNTIME_CREDENTIAL_PATTERN = /^[a-zA-Z0-9_-]{32,256}$/;
42402
42886
  var MobiusRuntimeConfigurationError = class extends Error {
42403
42887
  code = "runtime_configuration_invalid";
42404
42888
  constructor(message, options = {}) {