@moxt-ai/mobius 0.0.44 → 0.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-catalog/publish-agent-catalog.d.ts.map +1 -1
- package/dist/agent-catalog/publish-agent-catalog.js +1 -0
- package/dist/agent-catalog/publish-agent-catalog.js.map +1 -1
- package/dist/artifacts/runtime-artifact-uploader.d.ts.map +1 -1
- package/dist/artifacts/runtime-artifact-uploader.js +10 -17
- package/dist/artifacts/runtime-artifact-uploader.js.map +1 -1
- package/dist/cli.js +162 -34
- package/dist/cli.js.map +3 -3
- package/dist/index.js +159 -31
- package/dist/index.js.map +3 -3
- package/dist/pairing/pair-local-machine.d.ts.map +1 -1
- package/dist/pairing/pair-local-machine.js +1 -0
- package/dist/pairing/pair-local-machine.js.map +1 -1
- package/dist/run-daemon.d.ts.map +1 -1
- package/dist/run-daemon.js +122 -4
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +161 -33
- package/dist/runtime.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20514,6 +20514,7 @@ function decodeMessageKind(encoded) {
|
|
|
20514
20514
|
}
|
|
20515
20515
|
function decodeSessionPromptCommand(encoded) {
|
|
20516
20516
|
const value = parseJson2(encoded);
|
|
20517
|
+
const hasSessionConfigurations = Object.hasOwn(value, "sessionConfigurations");
|
|
20517
20518
|
assertExactKeys(value, [
|
|
20518
20519
|
"additionalDirectoryIds",
|
|
20519
20520
|
"agentId",
|
|
@@ -20525,6 +20526,7 @@ function decodeSessionPromptCommand(encoded) {
|
|
|
20525
20526
|
"kind",
|
|
20526
20527
|
"prompt",
|
|
20527
20528
|
"resources",
|
|
20529
|
+
...hasSessionConfigurations ? ["sessionConfigurations"] : [],
|
|
20528
20530
|
"sessionId",
|
|
20529
20531
|
"targetCommandId"
|
|
20530
20532
|
]);
|
|
@@ -20545,6 +20547,10 @@ function decodeSessionPromptCommand(encoded) {
|
|
|
20545
20547
|
if (disposition === SessionPromptDisposition.Reject && targetCommandId.length > 0 || disposition !== SessionPromptDisposition.Reject && !IDENTIFIER_PATTERN2.test(targetCommandId)) {
|
|
20546
20548
|
throw new ProtocolMessageError("Prompt disposition has an invalid target command");
|
|
20547
20549
|
}
|
|
20550
|
+
const sessionConfigurations = hasSessionConfigurations ? decodeSessionConfigurationSelections(value["sessionConfigurations"]) : [];
|
|
20551
|
+
if (new Set(sessionConfigurations.map((selection) => selection.configId)).size !== sessionConfigurations.length) {
|
|
20552
|
+
throw new ProtocolMessageError("Session configuration identifiers must be unique");
|
|
20553
|
+
}
|
|
20548
20554
|
return {
|
|
20549
20555
|
additionalDirectoryIds: readDirectoryIdentifiers(value, "additionalDirectoryIds", 16),
|
|
20550
20556
|
agentId: readIdentifier(value, "agentId"),
|
|
@@ -20556,6 +20562,7 @@ function decodeSessionPromptCommand(encoded) {
|
|
|
20556
20562
|
kind: SESSION_PROMPT_KIND,
|
|
20557
20563
|
prompt,
|
|
20558
20564
|
resources,
|
|
20565
|
+
...hasSessionConfigurations ? { sessionConfigurations } : {},
|
|
20559
20566
|
sessionId: readIdentifier(value, "sessionId"),
|
|
20560
20567
|
targetCommandId
|
|
20561
20568
|
};
|
|
@@ -36752,7 +36759,8 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
|
|
|
36752
36759
|
botSessionConfiguration: true,
|
|
36753
36760
|
capabilities: agent.capabilities,
|
|
36754
36761
|
id: agent.id,
|
|
36755
|
-
label: agent.label
|
|
36762
|
+
label: agent.label,
|
|
36763
|
+
sessionTurnConfiguration: true
|
|
36756
36764
|
}));
|
|
36757
36765
|
const endpoint = options.pairingId.length > 0 ? mobiusApiUrl(options.relayOrigin, `/v1/runtime-pairings/${encodeURIComponent(options.pairingId)}/redeem`) : mobiusApiUrl(options.relayOrigin, "/pairings/claim");
|
|
36758
36766
|
let response;
|
|
@@ -36994,7 +37002,8 @@ async function publishAgentCatalog(config2, signal) {
|
|
|
36994
37002
|
botSessionConfiguration: true,
|
|
36995
37003
|
capabilities: agent.capabilities,
|
|
36996
37004
|
id: agent.id,
|
|
36997
|
-
label: agent.label
|
|
37005
|
+
label: agent.label,
|
|
37006
|
+
sessionTurnConfiguration: true
|
|
36998
37007
|
})),
|
|
36999
37008
|
installableAgents: catalog.installableAgents
|
|
37000
37009
|
}),
|
|
@@ -37720,13 +37729,6 @@ var UploadedRuntimeArtifact = class {
|
|
|
37720
37729
|
this.sha256 = sha256;
|
|
37721
37730
|
}
|
|
37722
37731
|
};
|
|
37723
|
-
function daemonToken2(config2) {
|
|
37724
|
-
const token = config2.relayUrl.searchParams.get("token");
|
|
37725
|
-
if (token === null || token.length < 32) {
|
|
37726
|
-
throw new RuntimeArtifactUploadError("artifact_endpoint_invalid", "The Relay daemon token is missing");
|
|
37727
|
-
}
|
|
37728
|
-
return token;
|
|
37729
|
-
}
|
|
37730
37732
|
function channelOrigin(config2) {
|
|
37731
37733
|
const url2 = new URL(config2.relayUrl);
|
|
37732
37734
|
url2.protocol = url2.protocol === "wss:" ? "https:" : "http:";
|
|
@@ -37771,24 +37773,23 @@ async function readAuthorization(response) {
|
|
|
37771
37773
|
translateSdkError(cause);
|
|
37772
37774
|
}
|
|
37773
37775
|
}
|
|
37774
|
-
function sessionArtifactUrl(origin, sessionId, resourcePath
|
|
37775
|
-
|
|
37776
|
-
url2.searchParams.set("token", token);
|
|
37777
|
-
return url2;
|
|
37776
|
+
function sessionArtifactUrl(origin, sessionId, resourcePath) {
|
|
37777
|
+
return new URL(`${origin.pathname}/sessions/${encodeURIComponent(sessionId)}/${resourcePath}`, origin);
|
|
37778
37778
|
}
|
|
37779
|
-
async function postLease(url2, request, signal) {
|
|
37779
|
+
async function postLease(url2, headers, request, signal) {
|
|
37780
37780
|
return await fetch5(url2, {
|
|
37781
37781
|
dispatcher: environmentProxyDispatcher,
|
|
37782
|
-
headers: { "content-type": "application/json" },
|
|
37782
|
+
headers: { ...headers, "content-type": "application/json" },
|
|
37783
37783
|
method: "POST",
|
|
37784
37784
|
body: JSON.stringify(request),
|
|
37785
37785
|
signal
|
|
37786
37786
|
});
|
|
37787
37787
|
}
|
|
37788
|
-
async function putContent(url2, authorization, bytes, signal) {
|
|
37788
|
+
async function putContent(url2, headers, authorization, bytes, signal) {
|
|
37789
37789
|
return await fetch5(url2, {
|
|
37790
37790
|
dispatcher: environmentProxyDispatcher,
|
|
37791
37791
|
headers: {
|
|
37792
|
+
...headers,
|
|
37792
37793
|
"content-type": authorization.mediaType,
|
|
37793
37794
|
"x-mobius-upload-token": authorization.uploadToken
|
|
37794
37795
|
},
|
|
@@ -37813,11 +37814,12 @@ async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
|
|
|
37813
37814
|
const timeoutSignal = AbortSignal.timeout(UPLOAD_TIMEOUT_MILLISECONDS);
|
|
37814
37815
|
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
37815
37816
|
const origin = channelOrigin(config2);
|
|
37816
|
-
const
|
|
37817
|
+
const headers = runtimeAuthorization(config2.relayUrl);
|
|
37817
37818
|
let created;
|
|
37818
37819
|
try {
|
|
37819
37820
|
created = await postLease(
|
|
37820
|
-
sessionArtifactUrl(origin, sessionId, "artifacts/uploads"
|
|
37821
|
+
sessionArtifactUrl(origin, sessionId, "artifacts/uploads"),
|
|
37822
|
+
headers,
|
|
37821
37823
|
request,
|
|
37822
37824
|
requestSignal
|
|
37823
37825
|
);
|
|
@@ -37837,12 +37839,8 @@ async function uploadRuntimeArtifact(config2, sessionId, artifact, signal) {
|
|
|
37837
37839
|
let uploaded;
|
|
37838
37840
|
try {
|
|
37839
37841
|
uploaded = await putContent(
|
|
37840
|
-
sessionArtifactUrl(
|
|
37841
|
-
|
|
37842
|
-
sessionId,
|
|
37843
|
-
`artifacts/${encodeURIComponent(authorization.artifactId)}/content`,
|
|
37844
|
-
token
|
|
37845
|
-
),
|
|
37842
|
+
sessionArtifactUrl(origin, sessionId, `artifacts/${encodeURIComponent(authorization.artifactId)}/content`),
|
|
37843
|
+
headers,
|
|
37846
37844
|
authorization,
|
|
37847
37845
|
artifact.bytes,
|
|
37848
37846
|
requestSignal
|
|
@@ -40676,6 +40674,36 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
40676
40674
|
signal
|
|
40677
40675
|
);
|
|
40678
40676
|
const agent = config2.catalog.find(command.agentId);
|
|
40677
|
+
if (command.disposition === SessionPromptDisposition.Queue && !outbox.isTerminalExecution(command.targetCommandId, command.sessionId)) {
|
|
40678
|
+
throw new AcpExecutionError(
|
|
40679
|
+
"The queued prompt target is unavailable",
|
|
40680
|
+
{},
|
|
40681
|
+
"prompt_queue_target_unavailable"
|
|
40682
|
+
);
|
|
40683
|
+
}
|
|
40684
|
+
if (command.sessionConfigurations !== void 0) {
|
|
40685
|
+
const prepared = await sessions.prepareExecutionSession({
|
|
40686
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
40687
|
+
agent,
|
|
40688
|
+
cwd: resolved.cwd,
|
|
40689
|
+
sessionId: command.sessionId,
|
|
40690
|
+
signal
|
|
40691
|
+
});
|
|
40692
|
+
if (command.disposition === SessionPromptDisposition.Steer) {
|
|
40693
|
+
assertCompleteSessionConfiguration(prepared.configOptions, command.sessionConfigurations);
|
|
40694
|
+
} else {
|
|
40695
|
+
await applyCompleteSessionConfiguration(
|
|
40696
|
+
sessions,
|
|
40697
|
+
prepared.configOptions,
|
|
40698
|
+
command.sessionConfigurations,
|
|
40699
|
+
agent,
|
|
40700
|
+
resolved.cwd,
|
|
40701
|
+
resolved.additionalDirectories,
|
|
40702
|
+
command.sessionId,
|
|
40703
|
+
signal
|
|
40704
|
+
);
|
|
40705
|
+
}
|
|
40706
|
+
}
|
|
40679
40707
|
audit.record({
|
|
40680
40708
|
commandId: command.commandId,
|
|
40681
40709
|
event: "session_authorized",
|
|
@@ -40710,13 +40738,6 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
40710
40738
|
});
|
|
40711
40739
|
stopReason = "steered";
|
|
40712
40740
|
} else {
|
|
40713
|
-
if (command.disposition === SessionPromptDisposition.Queue && !outbox.isTerminalExecution(command.targetCommandId, command.sessionId)) {
|
|
40714
|
-
throw new AcpExecutionError(
|
|
40715
|
-
"The queued prompt target is unavailable",
|
|
40716
|
-
{},
|
|
40717
|
-
"prompt_queue_target_unavailable"
|
|
40718
|
-
);
|
|
40719
|
-
}
|
|
40720
40741
|
const result = await sessions.runPrompt({
|
|
40721
40742
|
additionalDirectories: resolved.additionalDirectories,
|
|
40722
40743
|
agent,
|
|
@@ -40783,6 +40804,113 @@ async function executePrompt(outbox, publisher, command, config2, directories, a
|
|
|
40783
40804
|
console.error("Mobius daemon command failed", error62);
|
|
40784
40805
|
}
|
|
40785
40806
|
}
|
|
40807
|
+
function invalidSessionConfiguration(message) {
|
|
40808
|
+
return new AcpExecutionError(message, {}, "invalid_session_configuration");
|
|
40809
|
+
}
|
|
40810
|
+
function validateSessionConfigurationSelection(option2, selection) {
|
|
40811
|
+
if (option2.type !== selection.valueType) {
|
|
40812
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} changed type`);
|
|
40813
|
+
}
|
|
40814
|
+
if (option2.type === "boolean") {
|
|
40815
|
+
if (selection.value.length > 0) {
|
|
40816
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} has an invalid value`);
|
|
40817
|
+
}
|
|
40818
|
+
return;
|
|
40819
|
+
}
|
|
40820
|
+
if (selection.booleanValue) {
|
|
40821
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} has an invalid value`);
|
|
40822
|
+
}
|
|
40823
|
+
if (!option2.values.some((value) => value.value === selection.value)) {
|
|
40824
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} has an unavailable value`);
|
|
40825
|
+
}
|
|
40826
|
+
}
|
|
40827
|
+
function assertSessionConfigurationSchema(options, selections) {
|
|
40828
|
+
if (options.length !== selections.length) {
|
|
40829
|
+
throw invalidSessionConfiguration("The Turn configuration does not match the Agent settings schema");
|
|
40830
|
+
}
|
|
40831
|
+
const selectionsById = new Map(selections.map((selection) => [selection.configId, selection]));
|
|
40832
|
+
if (selectionsById.size !== selections.length) {
|
|
40833
|
+
throw invalidSessionConfiguration("The Turn configuration contains duplicate Agent settings");
|
|
40834
|
+
}
|
|
40835
|
+
for (const option2 of options) {
|
|
40836
|
+
const selection = selectionsById.get(option2.id);
|
|
40837
|
+
if (selection === void 0 || selection.valueType !== option2.type || option2.type === "boolean" && selection.value.length > 0 || option2.type === "select" && selection.booleanValue) {
|
|
40838
|
+
throw invalidSessionConfiguration(`The Turn configuration does not match Agent setting ${option2.id}`);
|
|
40839
|
+
}
|
|
40840
|
+
}
|
|
40841
|
+
}
|
|
40842
|
+
function sessionConfigurationMatches(option2, selection) {
|
|
40843
|
+
validateSessionConfigurationSelection(option2, selection);
|
|
40844
|
+
return option2.type === "boolean" ? option2.booleanValue === selection.booleanValue : option2.currentValue === selection.value;
|
|
40845
|
+
}
|
|
40846
|
+
function sessionConfigurationPriority(selection, options) {
|
|
40847
|
+
if (selection.configId === "permission_mode") {
|
|
40848
|
+
return 0;
|
|
40849
|
+
}
|
|
40850
|
+
const option2 = options.find((candidate) => candidate.id === selection.configId);
|
|
40851
|
+
if (selection.configId === "model" || option2?.category === "model") {
|
|
40852
|
+
return 1;
|
|
40853
|
+
}
|
|
40854
|
+
if (selection.configId === "reasoning_effort" || option2?.category === "thought_level") {
|
|
40855
|
+
return 2;
|
|
40856
|
+
}
|
|
40857
|
+
if (option2?.category === "model_config") {
|
|
40858
|
+
return 3;
|
|
40859
|
+
}
|
|
40860
|
+
return 4;
|
|
40861
|
+
}
|
|
40862
|
+
function assertCompleteSessionConfiguration(options, selections) {
|
|
40863
|
+
assertSessionConfigurationSchema(options, selections);
|
|
40864
|
+
const selectionsById = new Map(selections.map((selection) => [selection.configId, selection]));
|
|
40865
|
+
for (const option2 of options) {
|
|
40866
|
+
const selection = selectionsById.get(option2.id);
|
|
40867
|
+
if (selection === void 0 || !sessionConfigurationMatches(option2, selection)) {
|
|
40868
|
+
throw invalidSessionConfiguration(`The Turn configuration does not match Agent setting ${option2.id}`);
|
|
40869
|
+
}
|
|
40870
|
+
}
|
|
40871
|
+
}
|
|
40872
|
+
async function applySessionConfigurationSelection(sessions, options, selection, agent, cwd, additionalDirectories, sessionId, signal) {
|
|
40873
|
+
const option2 = options.find((candidate) => candidate.id === selection.configId);
|
|
40874
|
+
if (option2 === void 0) {
|
|
40875
|
+
throw invalidSessionConfiguration(`The Agent setting ${selection.configId} is unavailable`);
|
|
40876
|
+
}
|
|
40877
|
+
if (sessionConfigurationMatches(option2, selection)) {
|
|
40878
|
+
return options;
|
|
40879
|
+
}
|
|
40880
|
+
return await sessions.configureSession({
|
|
40881
|
+
additionalDirectories,
|
|
40882
|
+
agent,
|
|
40883
|
+
booleanValue: selection.booleanValue,
|
|
40884
|
+
configId: selection.configId,
|
|
40885
|
+
cwd,
|
|
40886
|
+
requestId: `cfg_${randomUUID5()}`,
|
|
40887
|
+
sessionId,
|
|
40888
|
+
signal,
|
|
40889
|
+
value: selection.value,
|
|
40890
|
+
valueType: selection.valueType
|
|
40891
|
+
});
|
|
40892
|
+
}
|
|
40893
|
+
async function applyCompleteSessionConfiguration(sessions, initialOptions, selections, agent, cwd, additionalDirectories, sessionId, signal) {
|
|
40894
|
+
assertSessionConfigurationSchema(initialOptions, selections);
|
|
40895
|
+
let options = initialOptions;
|
|
40896
|
+
const orderedSelections = selections.toSorted((left, right) => {
|
|
40897
|
+
const priority = sessionConfigurationPriority(left, initialOptions) - sessionConfigurationPriority(right, initialOptions);
|
|
40898
|
+
return priority === 0 ? left.configId.localeCompare(right.configId) : priority;
|
|
40899
|
+
});
|
|
40900
|
+
for (const selection of orderedSelections) {
|
|
40901
|
+
options = await applySessionConfigurationSelection(
|
|
40902
|
+
sessions,
|
|
40903
|
+
options,
|
|
40904
|
+
selection,
|
|
40905
|
+
agent,
|
|
40906
|
+
cwd,
|
|
40907
|
+
additionalDirectories,
|
|
40908
|
+
sessionId,
|
|
40909
|
+
signal
|
|
40910
|
+
);
|
|
40911
|
+
}
|
|
40912
|
+
assertCompleteSessionConfiguration(options, selections);
|
|
40913
|
+
}
|
|
40786
40914
|
function botExecutionAgent(agent, contextHandle, socketPath) {
|
|
40787
40915
|
return new LocalAgentDefinition(
|
|
40788
40916
|
agent.id,
|