@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/cli.js CHANGED
@@ -11,7 +11,7 @@ import { mkdir as mkdir5 } from "node:fs/promises";
11
11
  // package.json
12
12
  var package_default = {
13
13
  name: "@moxt-ai/mobius",
14
- version: "0.0.39",
14
+ version: "0.0.40",
15
15
  description: "Mobius CLI for pairing and running local AI agent services.",
16
16
  type: "module",
17
17
  bin: {
@@ -841,10 +841,11 @@ var IntegrationProbeFailed = class extends UnavailableInstalledAgent {
841
841
  };
842
842
  var IncompatibleAdapter = class extends UnavailableInstalledAgent {
843
843
  code = "acp_incompatible";
844
- message = "ACP adapter is incompatible";
844
+ message;
845
845
  status = "incompatible_adapter";
846
- constructor(specification, agent) {
846
+ constructor(specification, agent, message) {
847
847
  super(specification, agent);
848
+ this.message = message;
848
849
  }
849
850
  };
850
851
  var AuthenticationRequiredAgent = class extends UnavailableInstalledAgent {
@@ -1645,6 +1646,9 @@ var GeminiCliAgentSpecification = class extends DirectAcpAgentDefinition {
1645
1646
  // src/agent-catalog/agents/grok-build-agent.ts
1646
1647
  import { realpath as realpath4 } from "node:fs/promises";
1647
1648
  import { isAbsolute as isAbsolute4, join as join7, relative as relative2, sep as sep2 } from "node:path";
1649
+ import {
1650
+ RequestError
1651
+ } from "@agentclientprotocol/sdk";
1648
1652
 
1649
1653
  // src/agent-installation/grok-managed-package.ts
1650
1654
  var GROK_BUILD_MANAGED_VERSION = "1.0.21";
@@ -1757,11 +1761,23 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
1757
1761
  };
1758
1762
  verifyAcp = async (connection, initialized, defaultWorkspace, signal) => {
1759
1763
  const capabilities = initialized.agentCapabilities ?? {};
1760
- const session = capabilities.sessionCapabilities;
1761
- 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")) {
1762
- throw new AgentProbeError("acp_incompatible", "Grok Build reported an unsupported ACP capability set");
1764
+ if (capabilities.loadSession !== true) {
1765
+ throw new AgentProbeError("acp_incompatible", "Grok Build did not report ACP session loading");
1766
+ }
1767
+ const authMethods = initialized.authMethods ?? [];
1768
+ if (authMethods.length === 0) {
1769
+ throw new AgentProbeError("acp_incompatible", "Grok Build did not report an ACP authentication method");
1770
+ }
1771
+ try {
1772
+ await verifySessionCreation(connection, capabilities, defaultWorkspace, signal, this.label);
1773
+ } catch (cause) {
1774
+ const detail = cause instanceof RequestError ? `ACP error ${cause.code}: ${cause.message}` : cause instanceof Error ? `${cause.name}: ${cause.message}` : "unknown error";
1775
+ throw new AgentProbeError(
1776
+ "acp_incompatible",
1777
+ `Grok Build could not create an ACP session (${detail}; auth methods: ${authMethods.map(({ id }) => id).join(", ")})`,
1778
+ { cause }
1779
+ );
1763
1780
  }
1764
- await verifySessionCreation(connection, capabilities, defaultWorkspace, signal, this.label);
1765
1781
  };
1766
1782
  };
1767
1783
 
@@ -2304,7 +2320,7 @@ import {
2304
2320
  methods as methods4,
2305
2321
  ndJsonStream,
2306
2322
  PROTOCOL_VERSION,
2307
- RequestError
2323
+ RequestError as RequestError2
2308
2324
  } from "@agentclientprotocol/sdk";
2309
2325
 
2310
2326
  // src/acp/create-client.ts
@@ -2482,7 +2498,7 @@ async function probeAcpReadiness(specification, agent, environment, defaultWorks
2482
2498
  if (error62 instanceof AgentProbeError) {
2483
2499
  throw error62;
2484
2500
  }
2485
- if (error62 instanceof RequestError && error62.code === -32e3 && specification.authenticationCommand().length > 0) {
2501
+ if (error62 instanceof RequestError2 && error62.code === -32e3 && specification.authenticationCommand().length > 0) {
2486
2502
  throw new AgentProbeError("authentication_required", "Agent authentication is required", { cause: error62 });
2487
2503
  }
2488
2504
  throw new AgentProbeError("acp_incompatible", "ACP adapter initialization failed", { cause: error62 });
@@ -2719,7 +2735,7 @@ function integrationProbeFailure(specification, agent, error62) {
2719
2735
  if (error62.code === "authentication_required") {
2720
2736
  return new AuthenticationRequiredAgent(specification, agent);
2721
2737
  }
2722
- return error62.code === "acp_incompatible" ? new IncompatibleAdapter(specification, agent) : new IntegrationProbeFailed(specification, agent, error62.code, error62.message);
2738
+ return error62.code === "acp_incompatible" ? new IncompatibleAdapter(specification, agent, error62.message) : new IntegrationProbeFailed(specification, agent, error62.code, error62.message);
2723
2739
  }
2724
2740
  if (error62 instanceof ProcessExecutionError) {
2725
2741
  const code = error62.code === "process_timeout" ? "adapter_probe_timeout" : "adapter_probe_failed";
@@ -23824,6 +23840,7 @@ var BotSessionPromptCommand = class {
23824
23840
  commandId;
23825
23841
  conversationId;
23826
23842
  directoryId;
23843
+ disposition;
23827
23844
  executionCapabilityId;
23828
23845
  executionCapabilitySecret;
23829
23846
  executionDeadlineAt;
@@ -23836,13 +23853,15 @@ var BotSessionPromptCommand = class {
23836
23853
  resources;
23837
23854
  sessionConfigurations;
23838
23855
  sessionId;
23856
+ targetCommandId;
23839
23857
  turnId;
23840
- 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 = []) {
23858
+ 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 = "") {
23841
23859
  this.sessionId = sessionId;
23842
23860
  this.commandId = commandId;
23843
23861
  this.agentId = agentId;
23844
23862
  this.bindingId = bindingId;
23845
23863
  this.directoryId = directoryId2;
23864
+ this.disposition = disposition;
23846
23865
  this.additionalDirectoryIds = Object.freeze([...additionalDirectoryIds]);
23847
23866
  this.images = Object.freeze([...images]);
23848
23867
  this.resources = Object.freeze([...resources]);
@@ -23866,12 +23885,14 @@ var BotSessionPromptCommand = class {
23866
23885
  );
23867
23886
  this.replyRoute = replyRoute;
23868
23887
  this.sessionConfigurations = Object.freeze([...sessionConfigurations]);
23888
+ this.targetCommandId = targetCommandId;
23869
23889
  }
23870
23890
  toJSON() {
23871
- const { sessionConfigurations, ...command } = this;
23891
+ const { disposition, sessionConfigurations, targetCommandId, ...command } = this;
23872
23892
  return {
23873
23893
  ...command,
23874
- ...sessionConfigurations.length === 0 ? {} : { sessionConfigurations }
23894
+ ...sessionConfigurations.length === 0 ? {} : { sessionConfigurations },
23895
+ ...disposition === SessionPromptDisposition.Reject ? {} : { disposition, targetCommandId }
23875
23896
  };
23876
23897
  }
23877
23898
  };
@@ -24165,11 +24186,26 @@ function decodeBotSessionPromptCommand(encoded) {
24165
24186
  "sessionId",
24166
24187
  "turnId"
24167
24188
  ],
24168
- ["sessionConfigurations"]
24189
+ ["disposition", "sessionConfigurations", "targetCommandId"]
24169
24190
  );
24170
24191
  if (value["kind"] !== BOT_SESSION_PROMPT_KIND) {
24171
24192
  throw new ProtocolMessageError("Invalid Bot Session prompt kind");
24172
24193
  }
24194
+ const rawDisposition = value["disposition"];
24195
+ let disposition;
24196
+ if (rawDisposition === void 0 || rawDisposition === SessionPromptDisposition.Reject) {
24197
+ disposition = SessionPromptDisposition.Reject;
24198
+ } else if (rawDisposition === SessionPromptDisposition.Queue) {
24199
+ disposition = SessionPromptDisposition.Queue;
24200
+ } else if (rawDisposition === SessionPromptDisposition.Steer) {
24201
+ disposition = SessionPromptDisposition.Steer;
24202
+ } else {
24203
+ throw new ProtocolMessageError("Invalid Bot Session prompt disposition");
24204
+ }
24205
+ const targetCommandId = value["targetCommandId"] === void 0 ? "" : readText2(value, "targetCommandId", 128, false);
24206
+ if (disposition === SessionPromptDisposition.Reject && targetCommandId.length > 0 || disposition !== SessionPromptDisposition.Reject && !IDENTIFIER_PATTERN3.test(targetCommandId)) {
24207
+ throw new ProtocolMessageError("Bot Session prompt disposition has an invalid target command");
24208
+ }
24173
24209
  return new BotSessionPromptCommand(
24174
24210
  readIdentifier2(value, "sessionId"),
24175
24211
  readIdentifier2(value, "commandId"),
@@ -24194,7 +24230,9 @@ function decodeBotSessionPromptCommand(encoded) {
24194
24230
  readDigest(value, "behaviorDigest"),
24195
24231
  readTargets(value, "allowedDeliveryTargets"),
24196
24232
  readReplyRoute(value["replyRoute"]),
24197
- readSessionConfigurations(value)
24233
+ readSessionConfigurations(value),
24234
+ disposition,
24235
+ targetCommandId
24198
24236
  );
24199
24237
  }
24200
24238
 
@@ -25653,7 +25691,7 @@ import {
25653
25691
  methods as methods6,
25654
25692
  ndJsonStream as ndJsonStream2,
25655
25693
  PROTOCOL_VERSION as PROTOCOL_VERSION2,
25656
- RequestError as RequestError2
25694
+ RequestError as RequestError3
25657
25695
  } from "@agentclientprotocol/sdk";
25658
25696
 
25659
25697
  // src/authorization/local-raster.ts
@@ -35886,7 +35924,7 @@ var AcpProcessSession = class _AcpProcessSession {
35886
35924
  ]);
35887
35925
  } catch (error62) {
35888
35926
  signal.throwIfAborted();
35889
- if (error62 instanceof RequestError2 && error62.code === -32e3) {
35927
+ if (error62 instanceof RequestError3 && error62.code === -32e3) {
35890
35928
  throw new AcpExecutionError(
35891
35929
  "Agent authentication is required",
35892
35930
  { cause: error62 },
@@ -37112,14 +37150,14 @@ var FixedInstallationExecutor = class {
37112
37150
  if (initialDiscovery instanceof MissingAgent) {
37113
37151
  throw new InstallationManagerError(
37114
37152
  "agent_not_installed",
37115
- `Install ${specification.label} on this machine, then try installing the integration again.`
37153
+ `Install ${specification.label} on this machine, then check local Agents again.`
37116
37154
  );
37117
37155
  }
37118
37156
  const verifiedAgent = await findVerifiedAgentExecutable(specification, discoveryOptions);
37119
37157
  if (verifiedAgent === null) {
37120
37158
  throw new InstallationManagerError(
37121
37159
  "agent_not_installed",
37122
- `Install ${specification.label} on this machine, then try installing the integration again.`
37160
+ `Install ${specification.label} on this machine, then check local Agents again.`
37123
37161
  );
37124
37162
  }
37125
37163
  const agent = verifiedAgent.executable;
@@ -40756,32 +40794,9 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
40756
40794
  }
40757
40795
  const attachments = await resolvePromptArtifacts(config2, command, signal);
40758
40796
  const applied = await applicator.apply(command, grant, attachments.resources, signal);
40759
- const lease = contexts.activate(command);
40760
- try {
40761
- const deadlineSignal = AbortSignal.timeout(remaining);
40762
- const executionSignal = AbortSignal.any([signal, deadlineSignal]);
40763
- const agent = botExecutionAgent(grant.agent, lease.context.contextHandle, ipc.socketPath);
40764
- await sessions.prepareExecutionSession({
40765
- additionalDirectories: resolved.additionalDirectories,
40766
- agent,
40767
- cwd: resolved.cwd,
40768
- sessionId: command.sessionId,
40769
- signal: executionSignal
40770
- });
40771
- for (const selection of command.sessionConfigurations) {
40772
- await sessions.configureSession({
40773
- additionalDirectories: resolved.additionalDirectories,
40774
- agent,
40775
- booleanValue: selection.booleanValue,
40776
- configId: selection.configId,
40777
- cwd: resolved.cwd,
40778
- requestId: `cfg_${randomUUID6()}`,
40779
- sessionId: command.sessionId,
40780
- signal: executionSignal,
40781
- value: selection.value,
40782
- valueType: selection.valueType
40783
- });
40784
- }
40797
+ const deadlineSignal = AbortSignal.timeout(remaining);
40798
+ const executionSignal = AbortSignal.any([signal, deadlineSignal]);
40799
+ const startExecution = () => {
40785
40800
  audit.record({
40786
40801
  commandId: command.commandId,
40787
40802
  details: {
@@ -40806,56 +40821,106 @@ async function executeBotPrompt(outbox, publisher, command, config2, directories
40806
40821
  attemptId
40807
40822
  );
40808
40823
  activateAttempt();
40809
- const result = await sessions.runPrompt({
40824
+ };
40825
+ let stopReason = "steered";
40826
+ if (command.disposition === SessionPromptDisposition.Steer) {
40827
+ startExecution();
40828
+ await sessions.steerPrompt({
40810
40829
  additionalDirectories: resolved.additionalDirectories,
40811
- agent,
40830
+ agent: grant.agent,
40812
40831
  commandId: command.commandId,
40813
40832
  cwd: resolved.cwd,
40814
40833
  images: attachments.images,
40815
- onActivity: activities.record,
40816
- onText: (text3, messageId) => {
40817
- publisher.recordAttempt(
40818
- command.sessionId,
40819
- encodeAgentMessageDeltaEvent({
40820
- commandId: command.commandId,
40821
- kind: AGENT_MESSAGE_DELTA_KIND,
40822
- messageId,
40823
- sessionId: command.sessionId,
40824
- text: text3
40825
- }),
40826
- attemptId
40827
- );
40828
- return Promise.resolve();
40829
- },
40830
40834
  prompt: command.prompt,
40831
40835
  resources: applied.resources,
40832
40836
  sessionId: command.sessionId,
40833
- signal: executionSignal
40837
+ signal: executionSignal,
40838
+ targetCommandId: command.targetCommandId
40834
40839
  });
40835
- activities.flush();
40836
- publisher.recordAttempt(
40837
- command.sessionId,
40838
- encodeSessionCompletedEvent({
40840
+ } else {
40841
+ if (command.disposition === SessionPromptDisposition.Queue && !outbox.isTerminalExecution(command.targetCommandId, command.sessionId)) {
40842
+ throw new AcpExecutionError(
40843
+ "The queued Bot prompt target is unavailable",
40844
+ {},
40845
+ "prompt_queue_target_unavailable"
40846
+ );
40847
+ }
40848
+ const lease = contexts.activate(command);
40849
+ try {
40850
+ const agent = botExecutionAgent(grant.agent, lease.context.contextHandle, ipc.socketPath);
40851
+ await sessions.prepareExecutionSession({
40852
+ additionalDirectories: resolved.additionalDirectories,
40853
+ agent,
40854
+ cwd: resolved.cwd,
40855
+ sessionId: command.sessionId,
40856
+ signal: executionSignal
40857
+ });
40858
+ for (const selection of command.sessionConfigurations) {
40859
+ await sessions.configureSession({
40860
+ additionalDirectories: resolved.additionalDirectories,
40861
+ agent,
40862
+ booleanValue: selection.booleanValue,
40863
+ configId: selection.configId,
40864
+ cwd: resolved.cwd,
40865
+ requestId: `cfg_${randomUUID6()}`,
40866
+ sessionId: command.sessionId,
40867
+ signal: executionSignal,
40868
+ value: selection.value,
40869
+ valueType: selection.valueType
40870
+ });
40871
+ }
40872
+ startExecution();
40873
+ const result = await sessions.runPrompt({
40874
+ additionalDirectories: resolved.additionalDirectories,
40875
+ agent,
40839
40876
  commandId: command.commandId,
40840
- kind: SESSION_COMPLETED_KIND,
40877
+ cwd: resolved.cwd,
40878
+ disposition: command.disposition,
40879
+ images: attachments.images,
40880
+ onActivity: activities.record,
40881
+ onText: (text3, messageId) => {
40882
+ publisher.recordAttempt(
40883
+ command.sessionId,
40884
+ encodeAgentMessageDeltaEvent({
40885
+ commandId: command.commandId,
40886
+ kind: AGENT_MESSAGE_DELTA_KIND,
40887
+ messageId,
40888
+ sessionId: command.sessionId,
40889
+ text: text3
40890
+ }),
40891
+ attemptId
40892
+ );
40893
+ return Promise.resolve();
40894
+ },
40895
+ prompt: command.prompt,
40896
+ resources: applied.resources,
40841
40897
  sessionId: command.sessionId,
40842
- stopReason: result.stopReason
40843
- }),
40844
- attemptId
40845
- );
40846
- outbox.transitionExecution(
40847
- command.commandId,
40848
- result.stopReason === "cancelled" ? "cancelled" : "succeeded"
40849
- );
40850
- audit.record({
40851
- commandId: command.commandId,
40852
- details: { botId: command.botId, executionId: command.executionId },
40853
- event: result.stopReason === "cancelled" ? "bot_session_cancelled" : "bot_session_completed",
40854
- sessionId: command.sessionId
40855
- });
40856
- } finally {
40857
- lease.release();
40898
+ signal: executionSignal,
40899
+ targetCommandId: command.targetCommandId
40900
+ });
40901
+ stopReason = result.stopReason;
40902
+ } finally {
40903
+ lease.release();
40904
+ }
40858
40905
  }
40906
+ activities.flush();
40907
+ publisher.recordAttempt(
40908
+ command.sessionId,
40909
+ encodeSessionCompletedEvent({
40910
+ commandId: command.commandId,
40911
+ kind: SESSION_COMPLETED_KIND,
40912
+ sessionId: command.sessionId,
40913
+ stopReason
40914
+ }),
40915
+ attemptId
40916
+ );
40917
+ outbox.transitionExecution(command.commandId, stopReason === "cancelled" ? "cancelled" : "succeeded");
40918
+ audit.record({
40919
+ commandId: command.commandId,
40920
+ details: { botId: command.botId, executionId: command.executionId },
40921
+ event: stopReason === "cancelled" ? "bot_session_cancelled" : "bot_session_completed",
40922
+ sessionId: command.sessionId
40923
+ });
40859
40924
  } catch (error62) {
40860
40925
  activities.flush();
40861
40926
  const failure2 = Date.parse(command.executionDeadlineAt) <= Date.now() ? new LocalBotAuthorizationError("turn_expired", "The Bot execution deadline has expired", {
@@ -41106,7 +41171,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
41106
41171
  await processDeliveredPrompt(
41107
41172
  delivery,
41108
41173
  command,
41109
- true,
41174
+ command.disposition !== SessionPromptDisposition.Steer,
41110
41175
  (attemptId, activateAttempt, executionSignal) => executeBotPrompt(
41111
41176
  outbox,
41112
41177
  publisher,
@@ -41759,7 +41824,11 @@ async function runRelayConnection(config2, directories, audit, sessions, install
41759
41824
  applicator,
41760
41825
  ipc,
41761
41826
  receipt2.attemptId,
41762
- () => activeAttemptIds.set(command2.sessionId, receipt2.attemptId),
41827
+ () => {
41828
+ if (command2.disposition !== SessionPromptDisposition.Steer) {
41829
+ activeAttemptIds.set(command2.sessionId, receipt2.attemptId);
41830
+ }
41831
+ },
41763
41832
  timer,
41764
41833
  turn2.signal
41765
41834
  ).catch((error62) => {