pi-maestro-mobile 0.5.1 → 0.7.0
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/application/application-command-router.d.ts +1 -18
- package/dist/application/application-command-router.d.ts.map +1 -1
- package/dist/application/application-command-router.js +0 -10
- package/dist/application/application-command-router.js.map +1 -1
- package/dist/application/monitor-read-service.d.ts +3 -1
- package/dist/application/monitor-read-service.d.ts.map +1 -1
- package/dist/application/monitor-read-service.js +4 -1
- package/dist/application/monitor-read-service.js.map +1 -1
- package/dist/application/session-command-service.d.ts +2 -1
- package/dist/application/session-command-service.d.ts.map +1 -1
- package/dist/application/session-command-service.js +10 -43
- package/dist/application/session-command-service.js.map +1 -1
- package/dist/application/session-query-service.d.ts +1 -2
- package/dist/application/session-query-service.d.ts.map +1 -1
- package/dist/application/session-query-service.js +91 -119
- package/dist/application/session-query-service.js.map +1 -1
- package/dist/application/session-visibility.d.ts.map +1 -1
- package/dist/application/session-visibility.js +1 -0
- package/dist/application/session-visibility.js.map +1 -1
- package/dist/cli.js +5 -3
- package/dist/cli.js.map +1 -1
- package/dist/control/SessionDirectory.d.ts +3 -8
- package/dist/control/SessionDirectory.d.ts.map +1 -1
- package/dist/control/SessionDirectory.js +38 -75
- package/dist/control/SessionDirectory.js.map +1 -1
- package/dist/control/desktop-control-gateway.d.ts.map +1 -1
- package/dist/control/desktop-control-gateway.js +4 -2
- package/dist/control/desktop-control-gateway.js.map +1 -1
- package/dist/host-controller.d.ts +25 -17
- package/dist/host-controller.d.ts.map +1 -1
- package/dist/host-controller.js +169 -231
- package/dist/host-controller.js.map +1 -1
- package/dist/host-error.d.ts +6 -0
- package/dist/host-error.d.ts.map +1 -0
- package/dist/host-error.js +82 -0
- package/dist/host-error.js.map +1 -0
- package/dist/jsonl-pager.d.ts.map +1 -1
- package/dist/jsonl-pager.js +6 -1
- package/dist/jsonl-pager.js.map +1 -1
- package/dist/monitor-projection.d.ts +18 -2
- package/dist/monitor-projection.d.ts.map +1 -1
- package/dist/monitor-projection.js +115 -10
- package/dist/monitor-projection.js.map +1 -1
- package/dist/pi/pi-sdk-runtime.d.ts +6 -11
- package/dist/pi/pi-sdk-runtime.d.ts.map +1 -1
- package/dist/pi/pi-sdk-runtime.js +6 -50
- package/dist/pi/pi-sdk-runtime.js.map +1 -1
- package/dist/plugin/desktop-broker-host-ipc.d.ts +10 -1
- package/dist/plugin/desktop-broker-host-ipc.d.ts.map +1 -1
- package/dist/plugin/desktop-broker-host-ipc.js +66 -0
- package/dist/plugin/desktop-broker-host-ipc.js.map +1 -1
- package/dist/plugin/desktop-broker.d.ts +7 -0
- package/dist/plugin/desktop-broker.d.ts.map +1 -1
- package/dist/plugin/desktop-broker.js +100 -1
- package/dist/plugin/desktop-broker.js.map +1 -1
- package/dist/plugin/desktop-pi-session-adapter.d.ts.map +1 -1
- package/dist/plugin/desktop-pi-session-adapter.js +6 -1
- package/dist/plugin/desktop-pi-session-adapter.js.map +1 -1
- package/dist/plugin/desktop-plugin-extension.d.ts.map +1 -1
- package/dist/plugin/desktop-plugin-extension.js +353 -4
- package/dist/plugin/desktop-plugin-extension.js.map +1 -1
- package/dist/plugin/desktop-plugin-ipc.d.ts +15 -1
- package/dist/plugin/desktop-plugin-ipc.d.ts.map +1 -1
- package/dist/plugin/desktop-plugin-ipc.js +109 -5
- package/dist/plugin/desktop-plugin-ipc.js.map +1 -1
- package/dist/plugin/desktop-plugin-registry.d.ts +4 -1
- package/dist/plugin/desktop-plugin-registry.d.ts.map +1 -1
- package/dist/plugin/desktop-plugin-registry.js +21 -0
- package/dist/plugin/desktop-plugin-registry.js.map +1 -1
- package/dist/plugin/flow-plan-transport.d.ts +57 -0
- package/dist/plugin/flow-plan-transport.d.ts.map +1 -0
- package/dist/plugin/flow-plan-transport.js +144 -0
- package/dist/plugin/flow-plan-transport.js.map +1 -0
- package/dist/server/mobile-host-server.d.ts.map +1 -1
- package/dist/server/mobile-host-server.js +46 -48
- package/dist/server/mobile-host-server.js.map +1 -1
- package/dist/types.d.ts +3 -84
- package/dist/types.d.ts.map +1 -1
- package/dist/vendor/shared/desktop-broker-protocol.d.ts +30 -4
- package/dist/vendor/shared/desktop-broker-protocol.d.ts.map +1 -1
- package/dist/vendor/shared/desktop-broker-protocol.js +16 -3
- package/dist/vendor/shared/desktop-broker-protocol.js.map +1 -1
- package/dist/vendor/shared/desktop-plugin-protocol.d.ts +107 -4
- package/dist/vendor/shared/desktop-plugin-protocol.d.ts.map +1 -1
- package/dist/vendor/shared/desktop-plugin-protocol.js +119 -4
- package/dist/vendor/shared/desktop-plugin-protocol.js.map +1 -1
- package/dist/vendor/shared/protocol.d.ts +159 -8
- package/dist/vendor/shared/protocol.d.ts.map +1 -1
- package/dist/vendor/shared/protocol.js +178 -3
- package/dist/vendor/shared/protocol.js.map +1 -1
- package/dist/vendor/shared/release.d.ts +1 -1
- package/dist/vendor/shared/release.js +1 -1
- package/dist/workspace-telemetry.d.ts +1 -1
- package/dist/workspace-telemetry.d.ts.map +1 -1
- package/dist/workspace-telemetry.js +7 -0
- package/dist/workspace-telemetry.js.map +1 -1
- package/package.json +1 -1
- package/dist/mobile-agent.d.ts +0 -86
- package/dist/mobile-agent.d.ts.map +0 -1
- package/dist/mobile-agent.js +0 -2
- package/dist/mobile-agent.js.map +0 -1
- package/dist/session-runner.d.ts +0 -155
- package/dist/session-runner.d.ts.map +0 -1
- package/dist/session-runner.js +0 -809
- package/dist/session-runner.js.map +0 -1
|
@@ -3,14 +3,9 @@ import type { MonitorQueryService } from "./monitor-query-service.js";
|
|
|
3
3
|
import type { SessionCommand, CommandResult, SessionCommandService } from "./session-command-service.js";
|
|
4
4
|
import type { SessionListOptions, QueryResult, SessionQueryService } from "./session-query-service.js";
|
|
5
5
|
import type { SessionSnapshot, HostSessionList, TimelineItem, ExtensionUiResponse } from "../vendor/shared/index.js";
|
|
6
|
-
import type { SessionTargetIdentity } from "../control/SessionDirectory.js";
|
|
7
6
|
import type { UsageTotals } from "../usage-reader.js";
|
|
8
|
-
import type {
|
|
7
|
+
import type { SessionTargetIdentity } from "../control/SessionDirectory.js";
|
|
9
8
|
export interface ApplicationLifecycle {
|
|
10
|
-
openSession(request: OpenSessionRequest): Promise<{
|
|
11
|
-
id: string;
|
|
12
|
-
}>;
|
|
13
|
-
closeSession(sessionId: string, target?: SessionTargetIdentity): Promise<boolean>;
|
|
14
9
|
respondToExtensionUi(sessionId: string, requestId: string, response: ExtensionUiResponse, target?: SessionTargetIdentity): Promise<boolean>;
|
|
15
10
|
sessionOperation?(operation: SessionOperation): Promise<unknown>;
|
|
16
11
|
readMaestroState?(): Promise<unknown>;
|
|
@@ -38,14 +33,6 @@ export type SessionOperation = {
|
|
|
38
33
|
target: SessionTargetIdentity;
|
|
39
34
|
modelId: string;
|
|
40
35
|
provider?: string;
|
|
41
|
-
} | {
|
|
42
|
-
kind: "compact";
|
|
43
|
-
target: SessionTargetIdentity;
|
|
44
|
-
customInstructions?: string;
|
|
45
|
-
} | {
|
|
46
|
-
kind: "rename_session";
|
|
47
|
-
target: SessionTargetIdentity;
|
|
48
|
-
name: string;
|
|
49
36
|
};
|
|
50
37
|
export type ApplicationQuery = {
|
|
51
38
|
kind: "session_list";
|
|
@@ -77,10 +64,6 @@ export declare class ApplicationCommandRouter {
|
|
|
77
64
|
constructor(commands: SessionCommandService, sessions: SessionQueryService, monitor: MonitorQueryService, lifecycle?: ApplicationLifecycle | undefined);
|
|
78
65
|
command(command: SessionCommand): Promise<CommandResult>;
|
|
79
66
|
query(query: ApplicationQuery): Promise<ApplicationQueryResult>;
|
|
80
|
-
openSession(request: OpenSessionRequest): Promise<{
|
|
81
|
-
id: string;
|
|
82
|
-
}>;
|
|
83
|
-
closeSession(sessionId: string, target?: SessionTargetIdentity): Promise<boolean>;
|
|
84
67
|
respondToExtensionUi(sessionId: string, requestId: string, response: ExtensionUiResponse, target?: SessionTargetIdentity): Promise<boolean>;
|
|
85
68
|
sessionOperation(operation: SessionOperation): Promise<unknown>;
|
|
86
69
|
readMaestroState(): Promise<unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application-command-router.d.ts","sourceRoot":"","sources":["../../src/application/application-command-router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACzG,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACvG,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"application-command-router.d.ts","sourceRoot":"","sources":["../../src/application/application-command-router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACzG,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACvG,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAE5E,MAAM,WAAW,oBAAoB;IACnC,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,Q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O,CAAC;IAKhC,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;CAIjE"}
|
|
@@ -21,16 +21,6 @@ export class ApplicationCommandRouter {
|
|
|
21
21
|
case "monitor": return this.monitor.read();
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
openSession(request) {
|
|
25
|
-
if (!this.lifecycle)
|
|
26
|
-
return Promise.reject(new Error("session lifecycle unavailable"));
|
|
27
|
-
return this.lifecycle.openSession(request);
|
|
28
|
-
}
|
|
29
|
-
closeSession(sessionId, target) {
|
|
30
|
-
if (!this.lifecycle)
|
|
31
|
-
return Promise.reject(new Error("session lifecycle unavailable"));
|
|
32
|
-
return this.lifecycle.closeSession(sessionId, target);
|
|
33
|
-
}
|
|
34
24
|
respondToExtensionUi(sessionId, requestId, response, target) {
|
|
35
25
|
return this.lifecycle?.respondToExtensionUi(sessionId, requestId, response, target) ?? Promise.resolve(false);
|
|
36
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application-command-router.js","sourceRoot":"","sources":["../../src/application/application-command-router.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"application-command-router.js","sourceRoot":"","sources":["../../src/application/application-command-router.ts"],"names":[],"mappings":"AAqCA,MAAM,OAAO,wBAAwB;IAEhB;IACA;IACA;IACA;IAJnB,YACmB,QAA+B,EAC/B,QAA6B,EAC7B,OAA4B,EAC5B,SAAgC;QAHhC,aAAQ,GAAR,QAAQ,CAAuB;QAC/B,aAAQ,GAAR,QAAQ,CAAqB;QAC7B,YAAO,GAAP,OAAO,CAAqB;QAC5B,cAAS,GAAT,SAAS,CAAuB;IAChD,CAAC;IAEJ,OAAO,CAAC,OAAuB;QAC7B,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,KAAuB;QAC3B,QAAQ,KAAK,CA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AC;IAC3C,CAAC;IAED,YAAY;QACV,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY;YAAE,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC;QAC5F,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC;IACvC,CAAC;IAED,cAAc,CAAC,KAA8B;QAC3C,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc;YAAE,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC;QAC9F,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { MonitorState, WorkspaceTelemetryState } from "../vendor/shared/index.js";
|
|
1
|
+
import type { ExecutionProjection, MonitorState, WorkspaceTelemetryState } from "../vendor/shared/index.js";
|
|
2
2
|
import type { WorkspaceTelemetryReader } from "../workspace-telemetry.js";
|
|
3
3
|
export interface MonitorReadSnapshot {
|
|
4
4
|
state: MonitorState;
|
|
5
|
+
projections: ExecutionProjection[];
|
|
5
6
|
stableKey: string;
|
|
6
7
|
revision: number;
|
|
7
8
|
}
|
|
@@ -14,6 +15,7 @@ export declare class MonitorReadService {
|
|
|
14
15
|
private readonly source;
|
|
15
16
|
private lastStableKey;
|
|
16
17
|
private revision;
|
|
18
|
+
private readonly epoch;
|
|
17
19
|
private readChain;
|
|
18
20
|
constructor(source: MonitorTelemetrySource);
|
|
19
21
|
read(): Promise<MonitorReadSnapshot>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor-read-service.d.ts","sourceRoot":"","sources":["../../src/application/monitor-read-service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"monitor-read-service.d.ts","sourceRoot":"","sources":["../../src/application/monitor-read-service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAE5G,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAE1E,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,YAAY,CAAC;IACpB,WAAW,EAAE,mBAAmB,EAAE,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,wBAAwB,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC;AAEvH;;;GAGG;AACH,qBAAa,kBAAkB;IAQjB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAPnC,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IAGtC,OAAO,CAAC,SAAS,CAAoC;gBAExB,MAAM,EAAE,sBAAsB;IAErD,IAAI,IAAI,OAAO,CAAC,mBAAmB,CAAC;CAgC3C"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { projectExecutionProjections, projectMonitorWindows, telemetryStableKeyFromWindows } from "../monitor-projection.js";
|
|
2
3
|
/**
|
|
3
4
|
* Read-only Monitor query service. Both pull and push callers consume the same
|
|
4
5
|
* bounded projection and the same revision/stable-key state machine.
|
|
@@ -7,6 +8,7 @@ export class MonitorReadService {
|
|
|
7
8
|
source;
|
|
8
9
|
lastStableKey;
|
|
9
10
|
revision = 0;
|
|
11
|
+
epoch = randomUUID();
|
|
10
12
|
readChain = Promise.resolve();
|
|
11
13
|
constructor(source) {
|
|
12
14
|
this.source = source;
|
|
@@ -32,6 +34,7 @@ export class MonitorReadService {
|
|
|
32
34
|
}
|
|
33
35
|
resolveResult({
|
|
34
36
|
state: { ...state, revision: this.revision },
|
|
37
|
+
projections: projectExecutionProjections(telemetry, this.epoch, this.revision),
|
|
35
38
|
stableKey,
|
|
36
39
|
revision: this.revision,
|
|
37
40
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor-read-service.js","sourceRoot":"","sources":["../../src/application/monitor-read-service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"monitor-read-service.js","sourceRoot":"","sources":["../../src/application/monitor-read-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAY7H;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IAQA;IAPrB,aAAa,CAAqB;IAClC,QAAQ,GAAG,CAAC,CAAC;IACJ,KAAK,GAAG,UAAU,EAAE,CAAC;IAG9B,SAAS,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IAErD,YAA6B,MAA8B;QAA9B,WAAM,GAAN,MAAM,CAAwB;IAAG,CAAC;IAE/D,KAAK,CAAC,IAAI;QACR,IAAI,aAAoD,CAAC;QACzD,IAAI,YAAyC,CAAC;QAC9C,MAAM,MAAM,GAAG,IAAI,OAAO,CAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAClE,aAAa,GAAG,OAAO,CAAC;YACxB,YAAY,GAAG,MAAM,CAAC;QACxB,CAAC,CAAC,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;YACzC,IAAI,CAAC;gBACH,MAAM,SAAS,GAAG,OAAO,IAAI,CAAC,MAAM,KAAK,UAAU;oBACjD,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,EAAE;oBACrB,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC7B,MAAM,OAAO,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;gBACjD,MAAM,KAAK,GAAG,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,CAAC,UAAU,EAAE,CAAC;gBAC5D,MAAM,SAAS,GAAG,6BAA6B,CAAC,OAAO,CAAC,CAAC;gBACzD,IAAI,SAAS,KAAK,IAAI,CAAC,aAAa,EAAE,CAAC;oBACrC,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;oBAC/B,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC;gBACrB,CAAC;gBACD,aAAa,CAAC;oBACZ,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE;oBAC5C,WAAW,EAAE,2BAA2B,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;oBAC9E,SAAS;oBACT,QAAQ,EAAE,IAAI,CAAC,QAAQ;iBACxB,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,YAAY,CAAC,KAAK,CAAC,CAAC;YACtB,CAAC;QACH,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5D,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { JsonValue, OperationReceipt } from "../vendor/shared/index.js";
|
|
1
|
+
import type { HostError, JsonValue, OperationReceipt } from "../vendor/shared/index.js";
|
|
2
2
|
import type { SessionDirectory, SessionTargetIdentity } from "../control/SessionDirectory.js";
|
|
3
3
|
export type SessionCommandKind = "prompt" | "steer" | "follow_up" | "abort" | "set_model" | "set_thinking";
|
|
4
4
|
export interface SessionCommand {
|
|
@@ -15,6 +15,7 @@ export interface CommandResult extends OperationReceipt {
|
|
|
15
15
|
error?: {
|
|
16
16
|
code: string;
|
|
17
17
|
message?: string;
|
|
18
|
+
details?: HostError;
|
|
18
19
|
};
|
|
19
20
|
result?: JsonValue;
|
|
20
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-command-service.d.ts","sourceRoot":"","sources":["../../src/application/session-command-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAmB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"session-command-service.d.ts","sourceRoot":"","sources":["../../src/application/session-command-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAmB,MAAM,2BAA2B,CAAC;AAGzG,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAE9F,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,OAAO,GAAG,WAAW,GAAG,OAAO,GAAG,WAAW,GAAG,cAAc,CAAC;AAG3G,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,qBAAqB,CAAC;IAC9B,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,SAAS,CAAA;KAAE,CAAC;IAChE,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACzD,KAAK,CAAC,MAAM,EAAE,qBAAqB,EAAE,SAAS,EAAE,aAAa,GAAG,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAClG;AAqBD,qBAAa,qBAAqB;IAI9B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;IAJlC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0C;gBAG9C,SAAS,EAAE,gBAAgB,EAC3B,cAAc,CAAC,EAAE,qBAAqB,YAAA;IAGzD,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAmBxD,gBAAgB,IAAI,IAAI;CAGzB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeHostError } from "../host-error.js";
|
|
1
2
|
import { IdempotencyLedger } from "../control/idempotency-ledger.js";
|
|
2
3
|
function commandScope(command) {
|
|
3
4
|
return JSON.stringify([command.kind, command.target.sessionId, command.target.endpointId, command.target.normalizedCwd, command.target.processGeneration]);
|
|
@@ -24,52 +25,18 @@ export class SessionCommandService {
|
|
|
24
25
|
const target = this.directory.resolve(command.target, command.kind);
|
|
25
26
|
if (!target)
|
|
26
27
|
return result(command, this.directory.revision, "unknown", { code: "target_unavailable" });
|
|
27
|
-
if (target.kind
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
try {
|
|
32
|
-
const response = await this.desktopGateway.execute(command);
|
|
33
|
-
return { ...response, requestId: command.requestId, operation: command.kind, revision: this.directory.revision };
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return result(command, this.directory.revision, "unknown", { code: "desktop_confirmation_unavailable" });
|
|
37
|
-
}
|
|
28
|
+
if (target.kind !== "desktop")
|
|
29
|
+
return result(command, this.directory.revision, "unknown", { code: "target_unavailable" });
|
|
30
|
+
if (!this.desktopGateway) {
|
|
31
|
+
return result(command, this.directory.revision, "unknown", { code: "desktop_gateway_unavailable" });
|
|
38
32
|
}
|
|
39
|
-
const runner = target.runner;
|
|
40
|
-
if (!runner)
|
|
41
|
-
return result(command, this.directory.revision, "unknown", { code: "host_runner_unavailable" });
|
|
42
33
|
try {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
await runner.steer(command.message ?? "");
|
|
46
|
-
else
|
|
47
|
-
await runner.prompt(command.message ?? "", undefined, command.images);
|
|
48
|
-
}
|
|
49
|
-
else if (command.kind === "steer")
|
|
50
|
-
await runner.steer(command.message ?? "");
|
|
51
|
-
else if (command.kind === "follow_up")
|
|
52
|
-
await runner.followUp(command.message ?? "");
|
|
53
|
-
else if (command.kind === "set_model") {
|
|
54
|
-
if (!command.modelId || typeof runner.setModel !== "function")
|
|
55
|
-
throw new Error("model_unavailable");
|
|
56
|
-
const changed = await runner.setModel(command.modelId, command.provider);
|
|
57
|
-
if (!changed.ok)
|
|
58
|
-
return result(command, this.directory.revision, "failed", { code: changed.error ?? "model_change_failed" });
|
|
59
|
-
}
|
|
60
|
-
else if (command.kind === "set_thinking") {
|
|
61
|
-
if (!command.level || typeof runner.setThinking !== "function")
|
|
62
|
-
throw new Error("thinking_unavailable");
|
|
63
|
-
const changed = runner.setThinking(command.level);
|
|
64
|
-
if (!changed.ok)
|
|
65
|
-
return result(command, this.directory.revision, "failed", { code: changed.error ?? "thinking_change_failed" });
|
|
66
|
-
}
|
|
67
|
-
else
|
|
68
|
-
await runner.abort();
|
|
69
|
-
return result(command, this.directory.revision, "observed");
|
|
34
|
+
const response = await this.desktopGateway.execute(command);
|
|
35
|
+
return { ...response, requestId: command.requestId, operation: command.kind, revision: this.directory.revision };
|
|
70
36
|
}
|
|
71
|
-
catch {
|
|
72
|
-
|
|
37
|
+
catch (error) {
|
|
38
|
+
const details = normalizeHostError(error, "transport");
|
|
39
|
+
return result(command, this.directory.revision, "unknown", { code: details.code, message: details.message, details });
|
|
73
40
|
}
|
|
74
41
|
});
|
|
75
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-command-service.js","sourceRoot":"","sources":["../../src/application/session-command-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"session-command-service.js","sourceRoot":"","sources":["../../src/application/session-command-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AA2BrE,SAAS,YAAY,CAAC,OAAuB;IAC3C,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAC7J,CAAC;AAED,SAAS,MAAM,CACb,OAAuB,EACvB,QAAgB,EAChB,MAAuB,EACvB,KAA+D;IAE/D,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,SAAS,EAAE,OAAO,CAAC,IAAI;QACvB,MAAM;QACN,QAAQ;QACR,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5B,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,qBAAqB;IAIb;IACA;IAJF,MAAM,GAAG,IAAI,iBAAiB,EAAiB,CAAC;IAEjE,YACmB,SAA2B,EAC3B,cAAsC;QADtC,cAAS,GAAT,SAAS,CAAkB;QAC3B,mBAAc,GAAd,cAAc,CAAwB;IACtD,CAAC;IAEJ,OAAO,CAAC,OAAuB;QAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EA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E,OAAO,EAAE,CAAC,CAAC;YACxH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,gBAAgB;QACd,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -27,12 +27,11 @@ export interface QueryResult<T> {
|
|
|
27
27
|
export declare class SessionQueryService {
|
|
28
28
|
private readonly source;
|
|
29
29
|
private readonly directory;
|
|
30
|
-
private readonly presentationFor?;
|
|
31
30
|
private readonly now;
|
|
32
31
|
private readonly monitorState?;
|
|
33
32
|
private readonly targetFor?;
|
|
34
33
|
private readonly desktopHistory;
|
|
35
|
-
constructor(source: SessionListSource, directory: SessionDirectory,
|
|
34
|
+
constructor(source: SessionListSource, directory: SessionDirectory, _presentationFor?: (sessionId: string) => SessionPresentation | undefined, now?: () => number, monitorState?: (() => Promise<MonitorState>) | undefined, targetFor?: ((sessionId: string) => SessionDirectoryTarget | undefined) | undefined);
|
|
36
35
|
list(options?: SessionListOptions): Promise<HostSessionList>;
|
|
37
36
|
snapshot(target: SessionTargetIdentity): Promise<QueryResult<SessionSnapshot>>;
|
|
38
37
|
history(target: SessionTargetIdentity, count?: number): Promise<QueryResult<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-query-service.d.ts","sourceRoot":"","sources":["../../src/application/session-query-service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAiC,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAwB,eAAe,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzM,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACtH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGtD,MAAM,WAAW,iBAAiB;IAChC,YAAY,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;CAChD;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,EAAE,SAAS,GAAG,QAAQ,CAAC,CAAC;IACxD,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,QAAQ,EAAE,MAAM,CAAC;CAClB;
|
|
1
|
+
{"version":3,"file":"session-query-service.d.ts","sourceRoot":"","sources":["../../src/application/session-query-service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAiC,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAwB,eAAe,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzM,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACtH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGtD,MAAM,WAAW,iBAAiB;IAChC,YAAY,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;CAChD;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAC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,qBAAqB,GAAG,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAsC9E,OAAO,CAAC,MAAM,EAAE,qBAAqB,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;QAAE,KAAK,EAAE,YAAY,EAAE,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAW3K,KAAK,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAoB7E,OAAO,CAAC,gBAAgB;CAMzB"}
|
|
@@ -7,14 +7,23 @@ function asIso(value) {
|
|
|
7
7
|
function summaryOf(record) {
|
|
8
8
|
const cwd = typeof record.cwd === "string" ? record.cwd : "";
|
|
9
9
|
const title = String(record.firstMessage ?? record.title ?? "");
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const path = String(record.path ?? record.sessionFile ?? "");
|
|
11
|
+
const target = {
|
|
12
12
|
sessionId: String(record.id ?? ""),
|
|
13
13
|
endpointId: "history",
|
|
14
|
+
normalizedCwd: cwd,
|
|
15
|
+
processGeneration: "persisted",
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
id: target.sessionId,
|
|
19
|
+
sessionId: target.sessionId,
|
|
20
|
+
endpointId: target.endpointId,
|
|
21
|
+
target,
|
|
22
|
+
targetKey: targetIdentityKey(target),
|
|
14
23
|
runtimeStatus: "history",
|
|
15
24
|
cwd,
|
|
16
25
|
cwdName: cwd.split("/").filter(Boolean).at(-1) ?? cwd,
|
|
17
|
-
path
|
|
26
|
+
path,
|
|
18
27
|
title: title.length > 80 ? `${title.slice(0, 80)}…` : title,
|
|
19
28
|
...(typeof record.name === "string" && record.name ? { name: record.name } : {}),
|
|
20
29
|
...(typeof record.model === "string" ? { model: record.model } : {}),
|
|
@@ -54,18 +63,14 @@ function readonlyPresentation(revision) {
|
|
|
54
63
|
canFollowUp: false,
|
|
55
64
|
canAbort: false,
|
|
56
65
|
canAnswerAsk: false,
|
|
66
|
+
canPlan: false,
|
|
57
67
|
},
|
|
58
68
|
revision,
|
|
59
69
|
};
|
|
60
70
|
}
|
|
61
71
|
/** 已注册的 Desktop socket 即使尚未附着 Host reader,也属于活跃目标。 */
|
|
62
72
|
function runtimeStatusForTarget(target) {
|
|
63
|
-
|
|
64
|
-
return target.runtimeStatus ?? "idle";
|
|
65
|
-
const runState = target.runner?.state.runState;
|
|
66
|
-
if (!runState)
|
|
67
|
-
return "history";
|
|
68
|
-
return runState === "idle" || runState === "error" ? "idle" : "running";
|
|
73
|
+
return target.kind === "desktop" ? target.runtimeStatus ?? "idle" : "history";
|
|
69
74
|
}
|
|
70
75
|
function presentationForTarget(target, revision, sourcePresentation) {
|
|
71
76
|
const targetPresentation = target.presentation ?? readonlyPresentation(revision);
|
|
@@ -81,7 +86,6 @@ function presentationForTarget(target, revision, sourcePresentation) {
|
|
|
81
86
|
function summaryForTarget(target, revision, observedAt, base, sourcePresentation) {
|
|
82
87
|
const cwd = target.identity.normalizedCwd;
|
|
83
88
|
const cwdName = cwd.split("/").filter(Boolean).at(-1) ?? cwd;
|
|
84
|
-
const runnerState = target.runner?.state;
|
|
85
89
|
return {
|
|
86
90
|
...base,
|
|
87
91
|
id: target.identity.sessionId,
|
|
@@ -92,10 +96,10 @@ function summaryForTarget(target, revision, observedAt, base, sourcePresentation
|
|
|
92
96
|
runtimeStatus: runtimeStatusForTarget(target),
|
|
93
97
|
cwd,
|
|
94
98
|
cwdName,
|
|
95
|
-
path: target.sessionFile ?? base?.path ??
|
|
96
|
-
title: base?.title ||
|
|
97
|
-
messageCount: target.messageCount ??
|
|
98
|
-
updatedAt: target.lastActivityAt ??
|
|
99
|
+
path: target.sessionFile ?? base?.path ?? "",
|
|
100
|
+
title: base?.title || cwdName || target.identity.sessionId,
|
|
101
|
+
messageCount: target.messageCount ?? base?.messageCount ?? 0,
|
|
102
|
+
updatedAt: target.lastActivityAt ?? base?.updatedAt ?? observedAt,
|
|
99
103
|
presentation: presentationForTarget(target, revision, sourcePresentation),
|
|
100
104
|
...(target.activeSince ? { activeSince: target.activeSince } : {}),
|
|
101
105
|
...(target.lastActivityAt ? { lastActivityAt: target.lastActivityAt } : {}),
|
|
@@ -107,15 +111,13 @@ function summaryForTarget(target, revision, observedAt, base, sourcePresentation
|
|
|
107
111
|
export class SessionQueryService {
|
|
108
112
|
source;
|
|
109
113
|
directory;
|
|
110
|
-
presentationFor;
|
|
111
114
|
now;
|
|
112
115
|
monitorState;
|
|
113
116
|
targetFor;
|
|
114
117
|
desktopHistory = new Map();
|
|
115
|
-
constructor(source, directory,
|
|
118
|
+
constructor(source, directory, _presentationFor, now = Date.now, monitorState, targetFor) {
|
|
116
119
|
this.source = source;
|
|
117
120
|
this.directory = directory;
|
|
118
|
-
this.presentationFor = presentationFor;
|
|
119
121
|
this.now = now;
|
|
120
122
|
this.monitorState = monitorState;
|
|
121
123
|
this.targetFor = targetFor;
|
|
@@ -139,12 +141,20 @@ export class SessionQueryService {
|
|
|
139
141
|
const projectCwds = options.projectCwds?.map((cwd) => normalize(cwd.trim())).filter(Boolean);
|
|
140
142
|
const query = options.query?.trim().toLocaleLowerCase();
|
|
141
143
|
const records = await this.source.listSessions(options.cwd);
|
|
144
|
+
for (const record of records) {
|
|
145
|
+
const summary = summaryOf(record);
|
|
146
|
+
if (summary.target && summary.path)
|
|
147
|
+
this.directory.registerHistoryTarget(summary.target, summary.path);
|
|
148
|
+
}
|
|
142
149
|
const monitorWindows = this.monitorState ? (await this.monitorState()).windows : [];
|
|
143
|
-
const
|
|
150
|
+
const windowsByTargetKey = new Map();
|
|
144
151
|
for (const window of monitorWindows) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
152
|
+
if (window.target) {
|
|
153
|
+
const targetKey = targetIdentityKey(window.target);
|
|
154
|
+
const exactWindows = windowsByTargetKey.get(targetKey) ?? [];
|
|
155
|
+
exactWindows.push(window);
|
|
156
|
+
windowsByTargetKey.set(targetKey, exactWindows);
|
|
157
|
+
}
|
|
148
158
|
}
|
|
149
159
|
const observedAt = new Date(this.now()).toISOString();
|
|
150
160
|
const directoryTargets = this.directory.list();
|
|
@@ -166,13 +176,11 @@ export class SessionQueryService {
|
|
|
166
176
|
messageCount: 0,
|
|
167
177
|
updatedAt: observedAt,
|
|
168
178
|
presentation: window.presentation,
|
|
179
|
+
...(window.target ? { target: { ...window.target }, targetKey: targetIdentityKey(window.target) } : {}),
|
|
169
180
|
});
|
|
170
181
|
}
|
|
171
182
|
const projectedTargetKeys = new Set();
|
|
172
183
|
let sessions = summaries.flatMap((summary) => {
|
|
173
|
-
const windows = windowsBySessionId.get(summary.sessionId) ?? [];
|
|
174
|
-
const window = windows.length === 1 ? windows[0] : undefined;
|
|
175
|
-
const sourcePresentation = window?.presentation ?? summary.presentation ?? this.presentationFor?.(summary.sessionId);
|
|
176
184
|
const matchingTargets = directoryTargets.filter((candidate) => candidate.identity.sessionId === summary.sessionId);
|
|
177
185
|
if (matchingTargets.length > 0) {
|
|
178
186
|
return matchingTargets.flatMap((target) => {
|
|
@@ -180,31 +188,21 @@ export class SessionQueryService {
|
|
|
180
188
|
if (projectedTargetKeys.has(targetKey))
|
|
181
189
|
return [];
|
|
182
190
|
projectedTargetKeys.add(targetKey);
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
&& candidate.identity.normalizedCwd === target.identity.normalizedCwd);
|
|
187
|
-
const presentation = matchingTargets.length === 1 ? sourcePresentation
|
|
188
|
-
: attributedWindows.length === 1 && sameEndpointTargets.length === 1 ? attributedWindows[0].presentation : undefined;
|
|
191
|
+
const exactWindows = windowsByTargetKey.get(targetKey) ?? [];
|
|
192
|
+
const presentation = target.kind === "desktop" && exactWindows.length === 1
|
|
193
|
+
? exactWindows[0]?.presentation : undefined;
|
|
189
194
|
return [summaryForTarget(target, this.directory.revision, observedAt, summary, presentation)];
|
|
190
195
|
});
|
|
191
196
|
}
|
|
192
197
|
const target = this.targetFor?.(summary.sessionId);
|
|
193
198
|
if (target) {
|
|
194
199
|
projectedTargetKeys.add(targetIdentityKey(target.identity));
|
|
195
|
-
|
|
200
|
+
const exactWindows = windowsByTargetKey.get(targetIdentityKey(target.identity)) ?? [];
|
|
201
|
+
const presentation = target.kind === "desktop" && exactWindows.length === 1
|
|
202
|
+
? exactWindows[0]?.presentation : undefined;
|
|
203
|
+
return [summaryForTarget(target, this.directory.revision, observedAt, summary, presentation)];
|
|
196
204
|
}
|
|
197
|
-
|
|
198
|
-
return [window
|
|
199
|
-
? {
|
|
200
|
-
...summary,
|
|
201
|
-
endpointId: window.endpointId,
|
|
202
|
-
runtimeStatus: window.runtimeStatus,
|
|
203
|
-
...(directoryPresentation ?? window.presentation ?? summary.presentation
|
|
204
|
-
? { presentation: directoryPresentation ?? window.presentation ?? summary.presentation }
|
|
205
|
-
: {}),
|
|
206
|
-
}
|
|
207
|
-
: summary];
|
|
205
|
+
return [summary];
|
|
208
206
|
});
|
|
209
207
|
for (const target of directoryTargets) {
|
|
210
208
|
const targetKey = targetIdentityKey(target.identity);
|
|
@@ -213,7 +211,11 @@ export class SessionQueryService {
|
|
|
213
211
|
sessions.push(summaryForTarget(target, this.directory.revision, observedAt));
|
|
214
212
|
}
|
|
215
213
|
sessions = sessions.filter((session) => {
|
|
216
|
-
const presentation = session.presentation ??
|
|
214
|
+
const presentation = session.presentation ?? readonlyPresentation(this.directory.revision);
|
|
215
|
+
if (presentation.visibility === "monitor_tab"
|
|
216
|
+
&& (!session.target || !directoryTargets.some((target) => target.kind === "desktop"
|
|
217
|
+
&& targetIdentityKey(target.identity) === targetIdentityKey(session.target))))
|
|
218
|
+
return false;
|
|
217
219
|
if (!options.includeMonitor && presentation.visibility === "monitor_tab")
|
|
218
220
|
return false;
|
|
219
221
|
if (projectCwds && !projectCwds.includes(session.cwd))
|
|
@@ -267,52 +269,36 @@ export class SessionQueryService {
|
|
|
267
269
|
const entry = this.directory.resolve(target);
|
|
268
270
|
if (!entry)
|
|
269
271
|
return { ok: false, status: "unknown", error: { code: "target_unavailable" }, revision: this.directory.revision };
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
timeline = page.items;
|
|
280
|
-
hasMoreHistory = page.hasMore;
|
|
281
|
-
this.desktopHistory.set(targetIdentityKey(entry.identity), { cursor: page.cursor, totalEntries: page.totalEntries });
|
|
282
|
-
}
|
|
283
|
-
return {
|
|
284
|
-
ok: true,
|
|
285
|
-
value: {
|
|
286
|
-
session: {
|
|
287
|
-
id: entry.identity.sessionId,
|
|
288
|
-
cwd: entry.identity.normalizedCwd,
|
|
289
|
-
title: entry.identity.normalizedCwd.split("/").filter(Boolean).at(-1) ?? entry.identity.sessionId,
|
|
290
|
-
runState: runtimeStatus === "running" ? "streaming" : "idle",
|
|
291
|
-
messageCount: entry.messageCount ?? 0,
|
|
292
|
-
pendingMessageCount: 0,
|
|
293
|
-
updatedAt,
|
|
294
|
-
...(entry.sessionFile ? { sessionFile: entry.sessionFile } : {}),
|
|
295
|
-
...(entry.model ? { model: structuredClone(entry.model) } : {}),
|
|
296
|
-
...(entry.thinkingLevel ? { thinkingLevel: entry.thinkingLevel } : {}),
|
|
297
|
-
presentation: entry.presentation ?? readonlyPresentation(this.directory.revision),
|
|
298
|
-
},
|
|
299
|
-
timeline,
|
|
300
|
-
nextSeq: 0,
|
|
301
|
-
historyAvailable: Boolean(entry.sessionFile),
|
|
302
|
-
hasMoreHistory,
|
|
303
|
-
},
|
|
304
|
-
revision: this.directory.revision,
|
|
305
|
-
};
|
|
272
|
+
const runtimeStatus = runtimeStatusForTarget(entry);
|
|
273
|
+
const updatedAt = entry.lastActivityAt ?? new Date(this.now()).toISOString();
|
|
274
|
+
let timeline = [];
|
|
275
|
+
let hasMoreHistory = false;
|
|
276
|
+
if (entry.sessionFile) {
|
|
277
|
+
const page = await replayTailFromJsonl(entry.sessionFile, 80);
|
|
278
|
+
timeline = page.items;
|
|
279
|
+
hasMoreHistory = page.hasMore;
|
|
280
|
+
this.desktopHistory.set(targetIdentityKey(entry.identity), { cursor: page.cursor, totalEntries: page.totalEntries });
|
|
306
281
|
}
|
|
307
|
-
const snapshot = entry.runner.snapshot();
|
|
308
282
|
return {
|
|
309
283
|
ok: true,
|
|
310
284
|
value: {
|
|
311
|
-
...snapshot,
|
|
312
285
|
session: {
|
|
313
|
-
|
|
286
|
+
id: entry.identity.sessionId,
|
|
287
|
+
cwd: entry.identity.normalizedCwd,
|
|
288
|
+
title: entry.identity.normalizedCwd.split("/").filter(Boolean).at(-1) ?? entry.identity.sessionId,
|
|
289
|
+
runState: runtimeStatus === "running" ? "streaming" : "idle",
|
|
290
|
+
messageCount: entry.messageCount ?? 0,
|
|
291
|
+
pendingMessageCount: 0,
|
|
292
|
+
updatedAt,
|
|
293
|
+
...(entry.sessionFile ? { sessionFile: entry.sessionFile } : {}),
|
|
294
|
+
...(entry.model ? { model: structuredClone(entry.model) } : {}),
|
|
295
|
+
...(entry.thinkingLevel ? { thinkingLevel: entry.thinkingLevel } : {}),
|
|
314
296
|
presentation: entry.presentation ?? readonlyPresentation(this.directory.revision),
|
|
315
297
|
},
|
|
298
|
+
timeline,
|
|
299
|
+
nextSeq: 0,
|
|
300
|
+
historyAvailable: Boolean(entry.sessionFile),
|
|
301
|
+
hasMoreHistory,
|
|
316
302
|
},
|
|
317
303
|
revision: this.directory.revision,
|
|
318
304
|
};
|
|
@@ -321,52 +307,38 @@ export class SessionQueryService {
|
|
|
321
307
|
const entry = this.directory.resolve(target);
|
|
322
308
|
if (!entry)
|
|
323
309
|
return { ok: false, status: "unknown", error: { code: "target_unavailable" }, revision: this.directory.revision };
|
|
324
|
-
if (!entry.
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}
|
|
332
|
-
if (entry.kind === "desktop")
|
|
333
|
-
return { ok: true, value: { items: [], hasMore: false, totalEntries: 0, historyAvailable: false }, revision: this.directory.revision };
|
|
334
|
-
return { ok: false, status: "failed", error: { code: "session_readonly_or_unavailable" }, revision: this.directory.revision };
|
|
335
|
-
}
|
|
336
|
-
return { ok: true, value: await entry.runner.loadMoreHistory(count), revision: this.directory.revision };
|
|
310
|
+
if (!entry.sessionFile)
|
|
311
|
+
return { ok: true, value: { items: [], hasMore: false, totalEntries: 0, historyAvailable: false }, revision: this.directory.revision };
|
|
312
|
+
const key = targetIdentityKey(entry.identity);
|
|
313
|
+
const cursor = this.desktopHistory.get(key)?.cursor ?? (await replayTailFromJsonl(entry.sessionFile, 80)).cursor;
|
|
314
|
+
const page = await replayPageBeforeJsonl(entry.sessionFile, cursor, count ?? 100);
|
|
315
|
+
this.desktopHistory.set(key, { cursor: page.cursor, totalEntries: page.totalEntries });
|
|
316
|
+
return { ok: true, value: { items: page.items, hasMore: page.hasMore, totalEntries: page.totalEntries, historyAvailable: true }, revision: this.directory.revision };
|
|
337
317
|
}
|
|
338
318
|
async usage(target) {
|
|
339
319
|
const entry = this.directory.resolve(target);
|
|
340
320
|
if (!entry)
|
|
341
321
|
return { ok: false, status: "unknown", error: { code: "target_unavailable" }, revision: this.directory.revision };
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
revision: this.directory.revision,
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
return { ok: false, status: "failed", error: { code: "session_readonly_or_unavailable" }, revision: this.directory.revision };
|
|
361
|
-
}
|
|
362
|
-
if (!entry.runner.getUsage)
|
|
363
|
-
return { ok: false, status: "failed", error: { code: "usage_unavailable" }, revision: this.directory.revision };
|
|
364
|
-
return { ok: true, value: await entry.runner.getUsage(), revision: this.directory.revision };
|
|
322
|
+
const usage = entry.usage;
|
|
323
|
+
return {
|
|
324
|
+
ok: true,
|
|
325
|
+
value: {
|
|
326
|
+
entries: 0,
|
|
327
|
+
input: usage?.input ?? 0,
|
|
328
|
+
output: usage?.output ?? 0,
|
|
329
|
+
cacheRead: usage?.cacheRead ?? 0,
|
|
330
|
+
cacheWrite: usage?.cacheWrite ?? 0,
|
|
331
|
+
reasoning: 0,
|
|
332
|
+
totalTokens: usage?.totalTokens ?? 0,
|
|
333
|
+
cost: usage?.cost ?? 0,
|
|
334
|
+
},
|
|
335
|
+
revision: this.directory.revision,
|
|
336
|
+
};
|
|
365
337
|
}
|
|
366
338
|
withPresentation(session) {
|
|
367
339
|
return {
|
|
368
340
|
...session,
|
|
369
|
-
presentation: session.presentation ??
|
|
341
|
+
presentation: session.presentation ?? readonlyPresentation(this.directory.revision),
|
|
370
342
|
};
|
|
371
343
|
}
|
|
372
344
|
}
|