@moxt-ai/mobius 0.0.34 → 0.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp/session-manager.d.ts +10 -2
- package/dist/acp/session-manager.d.ts.map +1 -1
- package/dist/acp/session-manager.js +71 -18
- package/dist/acp/session-manager.js.map +1 -1
- package/dist/agent-catalog/discover-local-agents.d.ts +0 -1
- package/dist/agent-catalog/discover-local-agents.d.ts.map +1 -1
- package/dist/agent-catalog/discover-local-agents.js +0 -1
- package/dist/agent-catalog/discover-local-agents.js.map +1 -1
- package/dist/agent-catalog/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/bots/local-bot-grant-store.d.ts.map +1 -1
- package/dist/bots/local-bot-grant-store.js +43 -3
- package/dist/bots/local-bot-grant-store.js.map +1 -1
- package/dist/cli.js +394 -109
- package/dist/cli.js.map +4 -4
- package/dist/index.js +393 -108
- package/dist/index.js.map +4 -4
- package/dist/infra/operation-metrics.d.ts +18 -0
- package/dist/infra/operation-metrics.d.ts.map +1 -0
- package/dist/infra/operation-metrics.js +31 -0
- package/dist/infra/operation-metrics.js.map +1 -0
- package/dist/native-sessions/service.d.ts.map +1 -1
- package/dist/native-sessions/service.js +14 -0
- package/dist/native-sessions/service.js.map +1 -1
- 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 +55 -4
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +393 -108
- package/dist/runtime.js.map +4 -4
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import { type CompleteElicitationNotification, type ContentBlock, type CreateEli
|
|
|
2
2
|
import { type AgentContentEvent, type AgentPromptResponse, type NativeSessionHistory, type PromptImage, type PromptResource, type SessionCapabilities, type SessionCommand, type SessionCommandsUpdatedEvent, type SessionConfigOption, type SessionConfigUpdatedEvent, type SessionElicitationRequestedEvent, type SessionElicitationResolvedEvent, type SessionInfoUpdatedEvent, type SessionPermissionRequestedEvent, type SessionPermissionResolvedEvent, type SessionUsageUpdatedEvent } from "@moxt-ai/mobius-protocol";
|
|
3
3
|
import type { LocalRasterImage } from "../authorization/local-raster.ts";
|
|
4
4
|
import type { LocalAgentDefinition } from "../config.ts";
|
|
5
|
+
import { type OperationMetrics } from "../infra/operation-metrics.ts";
|
|
5
6
|
import { type ProcessTreeIdentity } from "../process/executable.ts";
|
|
6
7
|
import { type AcpActivity } from "./activity.ts";
|
|
7
8
|
import { type AcpClientHandler } from "./create-client.ts";
|
|
@@ -97,7 +98,7 @@ export declare function createWritableAcpStream(output: NodeJS.WritableStream):
|
|
|
97
98
|
declare class AcpProcessSession implements AcpClientHandler {
|
|
98
99
|
#private;
|
|
99
100
|
private constructor();
|
|
100
|
-
static readonly start: (options: AcpPrepareOptions, getObserver: () => AcpSessionObserver, store: AcpSessionStore) => Promise<AcpProcessSession>;
|
|
101
|
+
static readonly start: (options: AcpPrepareOptions, getObserver: () => AcpSessionObserver, store: AcpSessionStore, metrics?: OperationMetrics) => Promise<AcpProcessSession>;
|
|
101
102
|
static readonly startNativeSessionBrowser: (options: AcpPrepareOptions, getObserver: () => AcpSessionObserver, store: AcpSessionStore) => Promise<AcpProcessSession>;
|
|
102
103
|
static readonly startSessionForkAtTurn: (options: AcpPrepareOptions, sourceNativeSessionId: string, forkPoint: AcpSessionForkPoint, getObserver: () => AcpSessionObserver, store: AcpSessionStore) => Promise<AcpProcessSession>;
|
|
103
104
|
readonly belongsTo: (agentId: string, cwd: string, additionalDirectories: readonly string[]) => boolean;
|
|
@@ -142,7 +143,13 @@ export declare class AcpSessionManager {
|
|
|
142
143
|
#private;
|
|
143
144
|
constructor(observer?: AcpSessionObserver, store?: AcpSessionStore);
|
|
144
145
|
readonly setObserver: (observer: AcpSessionObserver) => void;
|
|
145
|
-
readonly prepareSession: (options: AcpPrepareOptions) => Promise<AcpPreparedSession>;
|
|
146
|
+
readonly prepareSession: (options: AcpPrepareOptions, metrics?: OperationMetrics) => Promise<AcpPreparedSession>;
|
|
147
|
+
/**
|
|
148
|
+
* Opens a short-lived ACP session only to read the Agent's authoritative
|
|
149
|
+
* configuration options. The runtime and any persisted native-session
|
|
150
|
+
* record are released before this method resolves.
|
|
151
|
+
*/
|
|
152
|
+
readonly inspectSession: (options: AcpPrepareOptions) => Promise<AcpPreparedSession>;
|
|
146
153
|
readonly prepareExecutionSession: (options: AcpPrepareOptions) => Promise<AcpPreparedSession>;
|
|
147
154
|
readonly prepareNativeSessionBrowser: (options: AcpPrepareOptions) => Promise<AcpPreparedSession>;
|
|
148
155
|
readonly configureSession: (options: AcpConfigureOptions) => Promise<readonly SessionConfigOption[]>;
|
|
@@ -155,6 +162,7 @@ export declare class AcpSessionManager {
|
|
|
155
162
|
readonly hasPreparedSession: (sessionId: string, agentId: string, cwd: string, additionalDirectories: readonly string[]) => boolean;
|
|
156
163
|
readonly ensureSession: (options: AcpPrepareOptions) => Promise<AcpProcessSession>;
|
|
157
164
|
readonly listNativeSessions: (options: AcpPrepareOptions, cursor: string | null) => Promise<NativeSessionPage>;
|
|
165
|
+
readonly previewNativeSession: (options: AcpPrepareOptions, nativeSessionId: string) => Promise<NativeSessionHistory>;
|
|
158
166
|
readonly openNativeSession: (options: AcpPrepareOptions, origin: NativeSessionOrigin) => Promise<{
|
|
159
167
|
readonly sessionId: string;
|
|
160
168
|
readonly prepared: AcpPreparedSession;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-manager.d.ts","sourceRoot":"","sources":["../../src/acp/session-manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAEH,KAAK,+BAA+B,EACpC,KAAK,YAAY,EACjB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAM9B,KAAK,wBAAwB,EAC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oB,CAAC;KAC1C,CAAC,CAmFA;IAEF,QAAQ,CAAC,iBAAiB,YACb,iBAAiB,mBACT,MAAM,aACZ,mBAAmB;;;;;;;;;;;;;;;;;;;;OA0EhC;IAEF,QAAQ,CAAC,mBAAmB,YACf,iBAAiB,mBACT,MAAM,KACxB,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAmC3B;CACL"}
|
|
@@ -2,6 +2,7 @@ import { spawn } from "node:child_process";
|
|
|
2
2
|
import { methods, ndJsonStream, PROTOCOL_VERSION, RequestError, } from "@agentclientprotocol/sdk";
|
|
3
3
|
import { AGENT_CONTENT_KIND, decodeAgentPromptResponse, SESSION_COMMANDS_UPDATED_KIND, SESSION_CONFIG_UPDATED_KIND, SESSION_ELICITATION_REQUESTED_KIND, SESSION_ELICITATION_RESOLVED_KIND, SESSION_INFO_UPDATED_KIND, SESSION_PERMISSION_REQUESTED_KIND, SESSION_PERMISSION_RESOLVED_KIND, SESSION_USAGE_UPDATED_KIND, } from "@moxt-ai/mobius-protocol";
|
|
4
4
|
import { readAuthorizedRaster, readInlineRaster } from "../authorization/local-raster.js";
|
|
5
|
+
import { unmeasuredOperationMetrics } from "../infra/operation-metrics.js";
|
|
5
6
|
import { embedLocalHistoryImages } from "../native-sessions/history-images.js";
|
|
6
7
|
import { captureProcessTree, revalidateExecutable, stopProcessTree, } from "../process/executable.js";
|
|
7
8
|
import { AcpActivityTracker, imageDisplayContent, isProgressMessage, normalizeContentBlock, } from "./activity.js";
|
|
@@ -434,6 +435,7 @@ class AcpProcessSession {
|
|
|
434
435
|
#pendingPermissions = new Map();
|
|
435
436
|
#preSessionUpdates = [];
|
|
436
437
|
#processExit;
|
|
438
|
+
#metrics;
|
|
437
439
|
#sessionConfigProtocol;
|
|
438
440
|
#store;
|
|
439
441
|
#verifiedAgentVersion;
|
|
@@ -467,13 +469,14 @@ class AcpProcessSession {
|
|
|
467
469
|
#sessionUpdatedAt = "";
|
|
468
470
|
#turn = new IdleAcpTurn();
|
|
469
471
|
#updateTail = Promise.resolve();
|
|
470
|
-
constructor(agent, cwd, additionalDirectories, mobiusSessionId, getObserver, store) {
|
|
472
|
+
constructor(agent, cwd, additionalDirectories, mobiusSessionId, getObserver, store, metrics) {
|
|
471
473
|
this.#additionalDirectories = [...additionalDirectories];
|
|
472
474
|
this.#agentId = agent.id;
|
|
473
475
|
this.#cwd = cwd;
|
|
474
476
|
this.#environment = agent.environment;
|
|
475
477
|
this.#getObserver = getObserver;
|
|
476
478
|
this.#mobiusSessionId = mobiusSessionId;
|
|
479
|
+
this.#metrics = metrics;
|
|
477
480
|
this.#sessionConfigProtocol = sessionConfigProtocolForAgent(agent.id);
|
|
478
481
|
this.#store = store;
|
|
479
482
|
this.#verifiedAgentVersion = agent.agentVersion;
|
|
@@ -502,18 +505,18 @@ class AcpProcessSession {
|
|
|
502
505
|
const stream = ndJsonStream(createWritableAcpStream(stdin), readableWebStream(stdout));
|
|
503
506
|
this.#connection = createAcpClient(this).connect(stream);
|
|
504
507
|
}
|
|
505
|
-
static async #start(options, getObserver, store, initialize) {
|
|
508
|
+
static async #start(options, getObserver, store, initialize, metrics) {
|
|
506
509
|
for (let attempt = 1; attempt <= 2; attempt += 1) {
|
|
507
510
|
options.signal.throwIfAborted();
|
|
508
|
-
const [adapterUnchanged, agentUnchanged] = await Promise.all([
|
|
511
|
+
const [adapterUnchanged, agentUnchanged] = await metrics.measure("executable-validation", async () => await Promise.all([
|
|
509
512
|
revalidateExecutable(options.agent.adapterIdentity),
|
|
510
513
|
revalidateExecutable(options.agent.agentIdentity),
|
|
511
|
-
]);
|
|
514
|
+
]));
|
|
512
515
|
options.signal.throwIfAborted();
|
|
513
516
|
if (!adapterUnchanged || !agentUnchanged) {
|
|
514
517
|
throw new AcpExecutionError("The local Agent runtime changed; restart Mobius before starting a new conversation", {}, "agent_runtime_changed");
|
|
515
518
|
}
|
|
516
|
-
const runtime = new AcpProcessSession(options.agent, options.cwd, options.additionalDirectories, options.sessionId, getObserver, store);
|
|
519
|
+
const runtime = metrics.measureSync("process-spawn", () => new AcpProcessSession(options.agent, options.cwd, options.additionalDirectories, options.sessionId, getObserver, store, metrics));
|
|
517
520
|
try {
|
|
518
521
|
await initialize(runtime);
|
|
519
522
|
return runtime;
|
|
@@ -535,9 +538,9 @@ class AcpProcessSession {
|
|
|
535
538
|
}
|
|
536
539
|
throw new AcpExecutionError("ACP agent initialization failed");
|
|
537
540
|
}
|
|
538
|
-
static start = async (options, getObserver, store) => await AcpProcessSession.#start(options, getObserver, store, async (runtime) => await runtime.initialize(options.signal, options.origin));
|
|
539
|
-
static startNativeSessionBrowser = async (options, getObserver, store) => await AcpProcessSession.#start(options, getObserver, store, async (runtime) => await runtime.#initializeAgent(options.signal));
|
|
540
|
-
static startSessionForkAtTurn = async (options, sourceNativeSessionId, forkPoint, getObserver, store) => await AcpProcessSession.#start(options, getObserver, store, async (runtime) => await runtime.initialize(options.signal, { kind: "fork", nativeSessionId: sourceNativeSessionId }, forkPoint));
|
|
541
|
+
static start = async (options, getObserver, store, metrics = unmeasuredOperationMetrics) => await AcpProcessSession.#start(options, getObserver, store, async (runtime) => await runtime.initialize(options.signal, options.origin), metrics);
|
|
542
|
+
static startNativeSessionBrowser = async (options, getObserver, store) => await AcpProcessSession.#start(options, getObserver, store, async (runtime) => await runtime.#initializeAgent(options.signal), unmeasuredOperationMetrics);
|
|
543
|
+
static startSessionForkAtTurn = async (options, sourceNativeSessionId, forkPoint, getObserver, store) => await AcpProcessSession.#start(options, getObserver, store, async (runtime) => await runtime.initialize(options.signal, { kind: "fork", nativeSessionId: sourceNativeSessionId }, forkPoint), unmeasuredOperationMetrics);
|
|
541
544
|
belongsTo = (agentId, cwd, additionalDirectories) => this.#agentId === agentId &&
|
|
542
545
|
this.#cwd === cwd &&
|
|
543
546
|
arraysEqual(this.#additionalDirectories, additionalDirectories);
|
|
@@ -634,6 +637,9 @@ class AcpProcessSession {
|
|
|
634
637
|
return imageDisplayContent(raster.mimeType, raster.name, artifactId.length > 0 ? "" : raster.base64(), artifactId);
|
|
635
638
|
};
|
|
636
639
|
async #initializeAgent(signal) {
|
|
640
|
+
await this.#metrics.measure("agent-initialize", async () => await this.#initializeAgentOperation(signal));
|
|
641
|
+
}
|
|
642
|
+
async #initializeAgentOperation(signal) {
|
|
637
643
|
const initialized = await this.race(this.#connection.agent.request(methods.agent.initialize, {
|
|
638
644
|
clientCapabilities: {
|
|
639
645
|
elicitation: { form: {}, url: {} },
|
|
@@ -745,11 +751,11 @@ class AcpProcessSession {
|
|
|
745
751
|
}
|
|
746
752
|
this.#store.remove(this.#mobiusSessionId);
|
|
747
753
|
}
|
|
748
|
-
const created = await this.race(this.#connection.agent.request(methods.agent.session.new, {
|
|
754
|
+
const created = await this.#metrics.measure("session-new", async () => await this.race(this.#connection.agent.request(methods.agent.session.new, {
|
|
749
755
|
additionalDirectories: [...this.#additionalDirectories],
|
|
750
756
|
cwd: this.#cwd,
|
|
751
757
|
mcpServers: [],
|
|
752
|
-
}, { cancellationSignal: signal }), "ACP agent exited while starting a session", signal);
|
|
758
|
+
}, { cancellationSignal: signal }), "ACP agent exited while starting a session", signal));
|
|
753
759
|
this.selectNativeSession(created.sessionId);
|
|
754
760
|
lifecycleResponse = created;
|
|
755
761
|
}
|
|
@@ -1403,10 +1409,10 @@ export class AcpSessionManager {
|
|
|
1403
1409
|
this.#nativeBrowserPreparing.set(options.sessionId, operation);
|
|
1404
1410
|
return await operation;
|
|
1405
1411
|
}
|
|
1406
|
-
async #startPreparation(options) {
|
|
1412
|
+
async #startPreparation(options, metrics = unmeasuredOperationMetrics) {
|
|
1407
1413
|
const operation = (async () => {
|
|
1408
1414
|
try {
|
|
1409
|
-
const runtime = await AcpProcessSession.start(options, () => this.#observer, this.#store);
|
|
1415
|
+
const runtime = await AcpProcessSession.start(options, () => this.#observer, this.#store, metrics);
|
|
1410
1416
|
this.#sessions.set(options.sessionId, runtime);
|
|
1411
1417
|
return runtime;
|
|
1412
1418
|
}
|
|
@@ -1431,13 +1437,13 @@ export class AcpSessionManager {
|
|
|
1431
1437
|
this.#preparing.set(options.sessionId, operation);
|
|
1432
1438
|
return await operation;
|
|
1433
1439
|
}
|
|
1434
|
-
async #replacePreparation(existing, options) {
|
|
1440
|
+
async #replacePreparation(existing, options, metrics) {
|
|
1435
1441
|
const operation = (async () => {
|
|
1436
1442
|
try {
|
|
1437
1443
|
this.#sessions.delete(options.sessionId);
|
|
1438
1444
|
await existing.close();
|
|
1439
1445
|
this.#store.remove(options.sessionId);
|
|
1440
|
-
const runtime = await AcpProcessSession.start(options, () => this.#observer, this.#store);
|
|
1446
|
+
const runtime = await AcpProcessSession.start(options, () => this.#observer, this.#store, metrics);
|
|
1441
1447
|
this.#sessions.set(options.sessionId, runtime);
|
|
1442
1448
|
return runtime;
|
|
1443
1449
|
}
|
|
@@ -1503,7 +1509,7 @@ export class AcpSessionManager {
|
|
|
1503
1509
|
this.#preparing.set(options.sessionId, operation);
|
|
1504
1510
|
return await operation;
|
|
1505
1511
|
}
|
|
1506
|
-
prepareSession = async (options) => {
|
|
1512
|
+
prepareSession = async (options, metrics = unmeasuredOperationMetrics) => {
|
|
1507
1513
|
const stored = this.#store.read(options.sessionId);
|
|
1508
1514
|
if (stored instanceof DeletedAcpStoredSession) {
|
|
1509
1515
|
throw new AcpExecutionError("The native Agent session was deleted. Start a new chat.", {}, "native_session_deleted");
|
|
@@ -1518,7 +1524,7 @@ export class AcpSessionManager {
|
|
|
1518
1524
|
if (runtime.belongsTo(options.agent.id, options.cwd, options.additionalDirectories)) {
|
|
1519
1525
|
return runtime.prepared();
|
|
1520
1526
|
}
|
|
1521
|
-
return await this.prepareSession(options);
|
|
1527
|
+
return await this.prepareSession(options, metrics);
|
|
1522
1528
|
}
|
|
1523
1529
|
const existing = this.#sessions.get(options.sessionId);
|
|
1524
1530
|
if (existing !== undefined) {
|
|
@@ -1528,12 +1534,37 @@ export class AcpSessionManager {
|
|
|
1528
1534
|
if (!existing.canRebind()) {
|
|
1529
1535
|
throw new AcpExecutionError("The agent or workspace cannot change after a conversation has started", {}, "session_identity_mismatch");
|
|
1530
1536
|
}
|
|
1531
|
-
const runtime = await this.#replacePreparation(existing, options);
|
|
1537
|
+
const runtime = await this.#replacePreparation(existing, options, metrics);
|
|
1532
1538
|
return runtime.prepared();
|
|
1533
1539
|
}
|
|
1534
|
-
const runtime = await this.#startPreparation(options);
|
|
1540
|
+
const runtime = await this.#startPreparation(options, metrics);
|
|
1535
1541
|
return runtime.prepared();
|
|
1536
1542
|
};
|
|
1543
|
+
/**
|
|
1544
|
+
* Opens a short-lived ACP session only to read the Agent's authoritative
|
|
1545
|
+
* configuration options. The runtime and any persisted native-session
|
|
1546
|
+
* record are released before this method resolves.
|
|
1547
|
+
*/
|
|
1548
|
+
inspectSession = async (options) => {
|
|
1549
|
+
if (this.#preparing.has(options.sessionId) || this.#sessions.has(options.sessionId)) {
|
|
1550
|
+
throw new AcpExecutionError("The configuration inspection session is already in use", {}, "session_busy");
|
|
1551
|
+
}
|
|
1552
|
+
const runtime = await this.#startPreparation(options);
|
|
1553
|
+
try {
|
|
1554
|
+
return runtime.prepared();
|
|
1555
|
+
}
|
|
1556
|
+
finally {
|
|
1557
|
+
if (this.#sessions.get(options.sessionId) === runtime) {
|
|
1558
|
+
this.#sessions.delete(options.sessionId);
|
|
1559
|
+
}
|
|
1560
|
+
try {
|
|
1561
|
+
await runtime.close();
|
|
1562
|
+
}
|
|
1563
|
+
finally {
|
|
1564
|
+
this.#store.remove(options.sessionId);
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1537
1568
|
prepareExecutionSession = async (options) => {
|
|
1538
1569
|
const pending = this.#preparing.get(options.sessionId);
|
|
1539
1570
|
if (pending !== undefined) {
|
|
@@ -1766,6 +1797,28 @@ export class AcpSessionManager {
|
|
|
1766
1797
|
return started;
|
|
1767
1798
|
}
|
|
1768
1799
|
listNativeSessions = async (options, cursor) => await (await this.#ensureNativeSessionBrowser(options)).listNativeSessions(cursor, options.signal);
|
|
1800
|
+
previewNativeSession = async (options, nativeSessionId) => {
|
|
1801
|
+
const key = `${options.agent.id}:${nativeSessionId}`;
|
|
1802
|
+
const linked = this.#store.findNative(options.agent.id, nativeSessionId);
|
|
1803
|
+
if (this.#nativeOperations.has(key) ||
|
|
1804
|
+
linked.some((entry) => this.#activeSessionIds.has(entry.sessionId) || this.#preparing.has(entry.sessionId))) {
|
|
1805
|
+
throw new AcpExecutionError("Wait for the native session's running operation to finish", {}, "session_busy");
|
|
1806
|
+
}
|
|
1807
|
+
this.#nativeOperations.add(key);
|
|
1808
|
+
try {
|
|
1809
|
+
const runtime = await AcpProcessSession.startNativeSessionBrowser(options, () => this.#nativeBrowserObserver, new MemoryAcpSessionStore());
|
|
1810
|
+
try {
|
|
1811
|
+
runtime.selectNativeSession(nativeSessionId);
|
|
1812
|
+
return await runtime.loadHistory(options.signal);
|
|
1813
|
+
}
|
|
1814
|
+
finally {
|
|
1815
|
+
await runtime.closeProcess();
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
finally {
|
|
1819
|
+
this.#nativeOperations.delete(key);
|
|
1820
|
+
}
|
|
1821
|
+
};
|
|
1769
1822
|
openNativeSession = async (options, origin) => {
|
|
1770
1823
|
const key = `${options.agent.id}:${origin.nativeSessionId}`;
|
|
1771
1824
|
if (this.#nativeOperations.has(key)) {
|