@moxt-ai/mobius 0.0.39 → 0.0.40

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/runtime.js CHANGED
@@ -774,10 +774,11 @@ var IntegrationProbeFailed = class extends UnavailableInstalledAgent {
774
774
  };
775
775
  var IncompatibleAdapter = class extends UnavailableInstalledAgent {
776
776
  code = "acp_incompatible";
777
- message = "ACP adapter is incompatible";
777
+ message;
778
778
  status = "incompatible_adapter";
779
- constructor(specification, agent) {
779
+ constructor(specification, agent, message) {
780
780
  super(specification, agent);
781
+ this.message = message;
781
782
  }
782
783
  };
783
784
  var AuthenticationRequiredAgent = class extends UnavailableInstalledAgent {
@@ -1513,6 +1514,9 @@ var GeminiCliAgentSpecification = class extends DirectAcpAgentDefinition {
1513
1514
  // src/agent-catalog/agents/grok-build-agent.ts
1514
1515
  import { realpath as realpath4 } from "node:fs/promises";
1515
1516
  import { isAbsolute as isAbsolute4, join as join7, relative as relative2, sep as sep2 } from "node:path";
1517
+ import {
1518
+ RequestError
1519
+ } from "@agentclientprotocol/sdk";
1516
1520
 
1517
1521
  // src/agent-installation/grok-managed-package.ts
1518
1522
  var GROK_BUILD_MANAGED_VERSION = "1.0.21";
@@ -1625,11 +1629,23 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
1625
1629
  };
1626
1630
  verifyAcp = async (connection, initialized, defaultWorkspace, signal) => {
1627
1631
  const capabilities = initialized.agentCapabilities ?? {};
1628
- const session = capabilities.sessionCapabilities;
1629
- if (capabilities.loadSession !== true || session?.close == null || session.list == null || session.resume == null || !(initialized.authMethods ?? []).some((method) => method.id === "xai.api_key" || method.id === "grok.com")) {
1630
- throw new AgentProbeError("acp_incompatible", "Grok Build reported an unsupported ACP capability set");
1632
+ if (capabilities.loadSession !== true) {
1633
+ throw new AgentProbeError("acp_incompatible", "Grok Build did not report ACP session loading");
1634
+ }
1635
+ const authMethods = initialized.authMethods ?? [];
1636
+ if (authMethods.length === 0) {
1637
+ throw new AgentProbeError("acp_incompatible", "Grok Build did not report an ACP authentication method");
1638
+ }
1639
+ try {
1640
+ await verifySessionCreation(connection, capabilities, defaultWorkspace, signal, this.label);
1641
+ } catch (cause) {
1642
+ const detail = cause instanceof RequestError ? `ACP error ${cause.code}: ${cause.message}` : cause instanceof Error ? `${cause.name}: ${cause.message}` : "unknown error";
1643
+ throw new AgentProbeError(
1644
+ "acp_incompatible",
1645
+ `Grok Build could not create an ACP session (${detail}; auth methods: ${authMethods.map(({ id }) => id).join(", ")})`,
1646
+ { cause }
1647
+ );
1631
1648
  }
1632
- await verifySessionCreation(connection, capabilities, defaultWorkspace, signal, this.label);
1633
1649
  };
1634
1650
  };
1635
1651
 
@@ -2172,7 +2188,7 @@ import {
2172
2188
  methods as methods4,
2173
2189
  ndJsonStream,
2174
2190
  PROTOCOL_VERSION,
2175
- RequestError
2191
+ RequestError as RequestError2
2176
2192
  } from "@agentclientprotocol/sdk";
2177
2193
 
2178
2194
  // src/acp/create-client.ts
@@ -2350,7 +2366,7 @@ async function probeAcpReadiness(specification, agent, environment, defaultWorks
2350
2366
  if (error62 instanceof AgentProbeError) {
2351
2367
  throw error62;
2352
2368
  }
2353
- if (error62 instanceof RequestError && error62.code === -32e3 && specification.authenticationCommand().length > 0) {
2369
+ if (error62 instanceof RequestError2 && error62.code === -32e3 && specification.authenticationCommand().length > 0) {
2354
2370
  throw new AgentProbeError("authentication_required", "Agent authentication is required", { cause: error62 });
2355
2371
  }
2356
2372
  throw new AgentProbeError("acp_incompatible", "ACP adapter initialization failed", { cause: error62 });
@@ -2587,7 +2603,7 @@ function integrationProbeFailure(specification, agent, error62) {
2587
2603
  if (error62.code === "authentication_required") {
2588
2604
  return new AuthenticationRequiredAgent(specification, agent);
2589
2605
  }
2590
- return error62.code === "acp_incompatible" ? new IncompatibleAdapter(specification, agent) : new IntegrationProbeFailed(specification, agent, error62.code, error62.message);
2606
+ return error62.code === "acp_incompatible" ? new IncompatibleAdapter(specification, agent, error62.message) : new IntegrationProbeFailed(specification, agent, error62.code, error62.message);
2591
2607
  }
2592
2608
  if (error62 instanceof ProcessExecutionError) {
2593
2609
  const code = error62.code === "process_timeout" ? "adapter_probe_timeout" : "adapter_probe_failed";
@@ -23571,6 +23587,7 @@ var BotSessionPromptCommand = class {
23571
23587
  commandId;
23572
23588
  conversationId;
23573
23589
  directoryId;
23590
+ disposition;
23574
23591
  executionCapabilityId;
23575
23592
  executionCapabilitySecret;
23576
23593
  executionDeadlineAt;
@@ -23583,13 +23600,15 @@ var BotSessionPromptCommand = class {
23583
23600
  resources;
23584
23601
  sessionConfigurations;
23585
23602
  sessionId;
23603
+ targetCommandId;
23586
23604
  turnId;
23587
- 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 = []) {
23605
+ 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 = "") {
23588
23606
  this.sessionId = sessionId;
23589
23607
  this.commandId = commandId;
23590
23608
  this.agentId = agentId;
23591
23609
  this.bindingId = bindingId;
23592
23610
  this.directoryId = directoryId2;
23611
+ this.disposition = disposition;
23593
23612
  this.additionalDirectoryIds = Object.freeze([...additionalDirectoryIds]);
23594
23613
  this.images = Object.freeze([...images]);
23595
23614
  this.resources = Object.freeze([...resources]);
@@ -23613,12 +23632,14 @@ var BotSessionPromptCommand = class {
23613
23632
  );
23614
23633
  this.replyRoute = replyRoute;
23615
23634
  this.sessionConfigurations = Object.freeze([...sessionConfigurations]);
23635
+ this.targetCommandId = targetCommandId;
23616
23636
  }
23617
23637
  toJSON() {
23618
- const { sessionConfigurations, ...command } = this;
23638
+ const { disposition, sessionConfigurations, targetCommandId, ...command } = this;
23619
23639
  return {
23620
23640
  ...command,
23621
- ...sessionConfigurations.length === 0 ? {} : { sessionConfigurations }
23641
+ ...sessionConfigurations.length === 0 ? {} : { sessionConfigurations },
23642
+ ...disposition === SessionPromptDisposition.Reject ? {} : { disposition, targetCommandId }
23622
23643
  };
23623
23644
  }
23624
23645
  };
@@ -23912,11 +23933,26 @@ function decodeBotSessionPromptCommand(encoded) {
23912
23933
  "sessionId",
23913
23934
  "turnId"
23914
23935
  ],
23915
- ["sessionConfigurations"]
23936
+ ["disposition", "sessionConfigurations", "targetCommandId"]
23916
23937
  );
23917
23938
  if (value["kind"] !== BOT_SESSION_PROMPT_KIND) {
23918
23939
  throw new ProtocolMessageError("Invalid Bot Session prompt kind");
23919
23940
  }
23941
+ const rawDisposition = value["disposition"];
23942
+ let disposition;
23943
+ if (rawDisposition === void 0 || rawDisposition === SessionPromptDisposition.Reject) {
23944
+ disposition = SessionPromptDisposition.Reject;
23945
+ } else if (rawDisposition === SessionPromptDisposition.Queue) {
23946
+ disposition = SessionPromptDisposition.Queue;
23947
+ } else if (rawDisposition === SessionPromptDisposition.Steer) {
23948
+ disposition = SessionPromptDisposition.Steer;
23949
+ } else {
23950
+ throw new ProtocolMessageError("Invalid Bot Session prompt disposition");
23951
+ }
23952
+ const targetCommandId = value["targetCommandId"] === void 0 ? "" : readText2(value, "targetCommandId", 128, false);
23953
+ if (disposition === SessionPromptDisposition.Reject && targetCommandId.length > 0 || disposition !== SessionPromptDisposition.Reject && !IDENTIFIER_PATTERN3.test(targetCommandId)) {
23954
+ throw new ProtocolMessageError("Bot Session prompt disposition has an invalid target command");
23955
+ }
23920
23956
  return new BotSessionPromptCommand(
23921
23957
  readIdentifier2(value, "sessionId"),
23922
23958
  readIdentifier2(value, "commandId"),
@@ -23941,7 +23977,9 @@ function decodeBotSessionPromptCommand(encoded) {
23941
23977
  readDigest(value, "behaviorDigest"),
23942
23978
  readTargets(value, "allowedDeliveryTargets"),
23943
23979
  readReplyRoute(value["replyRoute"]),
23944
- readSessionConfigurations(value)
23980
+ readSessionConfigurations(value),
23981
+ disposition,
23982
+ targetCommandId
23945
23983
  );
23946
23984
  }
23947
23985
 
@@ -24269,7 +24307,7 @@ import {
24269
24307
  methods as methods6,
24270
24308
  ndJsonStream as ndJsonStream2,
24271
24309
  PROTOCOL_VERSION as PROTOCOL_VERSION2,
24272
- RequestError as RequestError2
24310
+ RequestError as RequestError3
24273
24311
  } from "@agentclientprotocol/sdk";
24274
24312
 
24275
24313
  // src/authorization/local-raster.ts
@@ -34502,7 +34540,7 @@ var AcpProcessSession = class _AcpProcessSession {
34502
34540
  ]);
34503
34541
  } catch (error62) {
34504
34542
  signal.throwIfAborted();
34505
- if (error62 instanceof RequestError2 && error62.code === -32e3) {
34543
+ if (error62 instanceof RequestError3 && error62.code === -32e3) {
34506
34544
  throw new AcpExecutionError(
34507
34545
  "Agent authentication is required",
34508
34546
  { cause: error62 },
@@ -35728,14 +35766,14 @@ var FixedInstallationExecutor = class {
35728
35766
  if (initialDiscovery instanceof MissingAgent) {
35729
35767
  throw new InstallationManagerError(
35730
35768
  "agent_not_installed",
35731
- `Install ${specification.label} on this machine, then try installing the integration again.`
35769
+ `Install ${specification.label} on this machine, then check local Agents again.`
35732
35770
  );
35733
35771
  }
35734
35772
  const verifiedAgent = await findVerifiedAgentExecutable(specification, discoveryOptions);
35735
35773
  if (verifiedAgent === null) {
35736
35774
  throw new InstallationManagerError(
35737
35775
  "agent_not_installed",
35738
- `Install ${specification.label} on this machine, then try installing the integration again.`
35776
+ `Install ${specification.label} on this machine, then check local Agents again.`
35739
35777
  );
35740
35778
  }
35741
35779
  const agent = verifiedAgent.executable;
@@ -40008,32 +40046,9 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
40008
40046
  }
40009
40047
  const attachments = await resolvePromptArtifacts(config2, command, signal);
40010
40048
  const applied = await applicator.apply(command, grant, attachments.resources, signal);
40011
- const lease = contexts.activate(command);
40012
- try {
40013
- const deadlineSignal = AbortSignal.timeout(remaining);
40014
- const executionSignal = AbortSignal.any([signal, deadlineSignal]);
40015
- const agent = botExecutionAgent(grant.agent, lease.context.contextHandle, ipc.socketPath);
40016
- await sessions.prepareExecutionSession({
40017
- additionalDirectories: resolved.additionalDirectories,
40018
- agent,
40019
- cwd: resolved.cwd,
40020
- sessionId: command.sessionId,
40021
- signal: executionSignal
40022
- });
40023
- for (const selection of command.sessionConfigurations) {
40024
- await sessions.configureSession({
40025
- additionalDirectories: resolved.additionalDirectories,
40026
- agent,
40027
- booleanValue: selection.booleanValue,
40028
- configId: selection.configId,
40029
- cwd: resolved.cwd,
40030
- requestId: `cfg_${randomUUID4()}`,
40031
- sessionId: command.sessionId,
40032
- signal: executionSignal,
40033
- value: selection.value,
40034
- valueType: selection.valueType
40035
- });
40036
- }
40049
+ const deadlineSignal = AbortSignal.timeout(remaining);
40050
+ const executionSignal = AbortSignal.any([signal, deadlineSignal]);
40051
+ const startExecution = () => {
40037
40052
  audit.record({
40038
40053
  commandId: command.commandId,
40039
40054
  details: {
@@ -40058,56 +40073,106 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
40058
40073
  attemptId
40059
40074
  );
40060
40075
  activateAttempt();
40061
- const result = await sessions.runPrompt({
40076
+ };
40077
+ let stopReason = "steered";
40078
+ if (command.disposition === SessionPromptDisposition.Steer) {
40079
+ startExecution();
40080
+ await sessions.steerPrompt({
40062
40081
  additionalDirectories: resolved.additionalDirectories,
40063
- agent,
40082
+ agent: grant.agent,
40064
40083
  commandId: command.commandId,
40065
40084
  cwd: resolved.cwd,
40066
40085
  images: attachments.images,
40067
- onActivity: activities.record,
40068
- onText: (text3, messageId) => {
40069
- publisher.recordAttempt(
40070
- command.sessionId,
40071
- encodeAgentMessageDeltaEvent({
40072
- commandId: command.commandId,
40073
- kind: AGENT_MESSAGE_DELTA_KIND,
40074
- messageId,
40075
- sessionId: command.sessionId,
40076
- text: text3
40077
- }),
40078
- attemptId
40079
- );
40080
- return Promise.resolve();
40081
- },
40082
40086
  prompt: command.prompt,
40083
40087
  resources: applied.resources,
40084
40088
  sessionId: command.sessionId,
40085
- signal: executionSignal
40089
+ signal: executionSignal,
40090
+ targetCommandId: command.targetCommandId
40086
40091
  });
40087
- activities.flush();
40088
- publisher.recordAttempt(
40089
- command.sessionId,
40090
- encodeSessionCompletedEvent({
40092
+ } else {
40093
+ if (command.disposition === SessionPromptDisposition.Queue && !outbox.isTerminalExecution(command.targetCommandId, command.sessionId)) {
40094
+ throw new AcpExecutionError(
40095
+ "The queued Bot prompt target is unavailable",
40096
+ {},
40097
+ "prompt_queue_target_unavailable"
40098
+ );
40099
+ }
40100
+ const lease = contexts.activate(command);
40101
+ try {
40102
+ const agent = botExecutionAgent(grant.agent, lease.context.contextHandle, ipc.socketPath);
40103
+ await sessions.prepareExecutionSession({
40104
+ additionalDirectories: resolved.additionalDirectories,
40105
+ agent,
40106
+ cwd: resolved.cwd,
40107
+ sessionId: command.sessionId,
40108
+ signal: executionSignal
40109
+ });
40110
+ for (const selection of command.sessionConfigurations) {
40111
+ await sessions.configureSession({
40112
+ additionalDirectories: resolved.additionalDirectories,
40113
+ agent,
40114
+ booleanValue: selection.booleanValue,
40115
+ configId: selection.configId,
40116
+ cwd: resolved.cwd,
40117
+ requestId: `cfg_${randomUUID4()}`,
40118
+ sessionId: command.sessionId,
40119
+ signal: executionSignal,
40120
+ value: selection.value,
40121
+ valueType: selection.valueType
40122
+ });
40123
+ }
40124
+ startExecution();
40125
+ const result = await sessions.runPrompt({
40126
+ additionalDirectories: resolved.additionalDirectories,
40127
+ agent,
40091
40128
  commandId: command.commandId,
40092
- kind: SESSION_COMPLETED_KIND,
40129
+ cwd: resolved.cwd,
40130
+ disposition: command.disposition,
40131
+ images: attachments.images,
40132
+ onActivity: activities.record,
40133
+ onText: (text3, messageId) => {
40134
+ publisher.recordAttempt(
40135
+ command.sessionId,
40136
+ encodeAgentMessageDeltaEvent({
40137
+ commandId: command.commandId,
40138
+ kind: AGENT_MESSAGE_DELTA_KIND,
40139
+ messageId,
40140
+ sessionId: command.sessionId,
40141
+ text: text3
40142
+ }),
40143
+ attemptId
40144
+ );
40145
+ return Promise.resolve();
40146
+ },
40147
+ prompt: command.prompt,
40148
+ resources: applied.resources,
40093
40149
  sessionId: command.sessionId,
40094
- stopReason: result.stopReason
40095
- }),
40096
- attemptId
40097
- );
40098
- outbox.transitionExecution(
40099
- command.commandId,
40100
- result.stopReason === "cancelled" ? "cancelled" : "succeeded"
40101
- );
40102
- audit.record({
40103
- commandId: command.commandId,
40104
- details: { botId: command.botId, executionId: command.executionId },
40105
- event: result.stopReason === "cancelled" ? "bot_session_cancelled" : "bot_session_completed",
40106
- sessionId: command.sessionId
40107
- });
40108
- } finally {
40109
- lease.release();
40150
+ signal: executionSignal,
40151
+ targetCommandId: command.targetCommandId
40152
+ });
40153
+ stopReason = result.stopReason;
40154
+ } finally {
40155
+ lease.release();
40156
+ }
40110
40157
  }
40158
+ activities.flush();
40159
+ publisher.recordAttempt(
40160
+ command.sessionId,
40161
+ encodeSessionCompletedEvent({
40162
+ commandId: command.commandId,
40163
+ kind: SESSION_COMPLETED_KIND,
40164
+ sessionId: command.sessionId,
40165
+ stopReason
40166
+ }),
40167
+ attemptId
40168
+ );
40169
+ outbox.transitionExecution(command.commandId, stopReason === "cancelled" ? "cancelled" : "succeeded");
40170
+ audit.record({
40171
+ commandId: command.commandId,
40172
+ details: { botId: command.botId, executionId: command.executionId },
40173
+ event: stopReason === "cancelled" ? "bot_session_cancelled" : "bot_session_completed",
40174
+ sessionId: command.sessionId
40175
+ });
40111
40176
  } catch (error62) {
40112
40177
  activities.flush();
40113
40178
  const failure2 = Date.parse(command.executionDeadlineAt) <= Date.now() ? new LocalBotAuthorizationError("turn_expired", "The Bot execution deadline has expired", {
@@ -40358,7 +40423,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
40358
40423
  await processDeliveredPrompt(
40359
40424
  delivery,
40360
40425
  command,
40361
- true,
40426
+ command.disposition !== SessionPromptDisposition.Steer,
40362
40427
  (attemptId, activateAttempt, executionSignal) => executeBotPrompt(
40363
40428
  outbox,
40364
40429
  publisher,
@@ -41011,7 +41076,11 @@ async function runRelayConnection(config2, directories, audit, sessions, install
41011
41076
  applicator,
41012
41077
  ipc,
41013
41078
  receipt2.attemptId,
41014
- () => activeAttemptIds.set(command2.sessionId, receipt2.attemptId),
41079
+ () => {
41080
+ if (command2.disposition !== SessionPromptDisposition.Steer) {
41081
+ activeAttemptIds.set(command2.sessionId, receipt2.attemptId);
41082
+ }
41083
+ },
41015
41084
  timer,
41016
41085
  turn2.signal
41017
41086
  ).catch((error62) => {