@yinaoxiong/paseo-client 0.0.0-stage → 0.11.2-personal.1
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/README.md +43 -2
- package/build-info.json +21 -0
- package/dist/compat/normalize-provider-models.d.ts +11 -0
- package/dist/compat/normalize-provider-models.js +51 -0
- package/dist/connection/index.d.ts +49 -0
- package/dist/connection/index.js +111 -0
- package/dist/connection/legacy-workspaces.d.ts +19 -0
- package/dist/connection/legacy-workspaces.js +160 -0
- package/dist/connection/legacy.d.ts +31 -0
- package/dist/connection/legacy.js +245 -0
- package/dist/connection/owned.d.ts +36 -0
- package/dist/connection/owned.js +210 -0
- package/dist/creation/index.d.ts +40 -0
- package/dist/creation/index.js +197 -0
- package/dist/daemon-client-relay-e2ee-transport.d.ts +9 -0
- package/dist/daemon-client-relay-e2ee-transport.js +165 -0
- package/dist/daemon-client-runtime-metrics.d.ts +39 -0
- package/dist/daemon-client-runtime-metrics.js +173 -0
- package/dist/daemon-client-transport-types.d.ts +36 -0
- package/dist/daemon-client-transport-types.js +2 -0
- package/dist/daemon-client-transport-utils.d.ts +13 -0
- package/dist/daemon-client-transport-utils.js +123 -0
- package/dist/daemon-client-transport.d.ts +5 -0
- package/dist/daemon-client-transport.js +4 -0
- package/dist/daemon-client-websocket-transport.d.ts +12 -0
- package/dist/daemon-client-websocket-transport.js +140 -0
- package/dist/daemon-client.d.ts +1310 -0
- package/dist/daemon-client.js +4927 -0
- package/dist/index.d.ts +410 -0
- package/dist/index.js +538 -0
- package/dist/legacy-usage-icons.d.ts +2 -0
- package/dist/legacy-usage-icons.js +16 -0
- package/dist/provider-snapshots/index.d.ts +21 -0
- package/dist/provider-snapshots/index.js +56 -0
- package/dist/terminal-stream-router.d.ts +25 -0
- package/dist/terminal-stream-router.js +62 -0
- package/dist/terminals/index.d.ts +69 -0
- package/dist/terminals/index.js +103 -0
- package/dist/timeline-subscription/index.d.ts +25 -0
- package/dist/timeline-subscription/index.js +56 -0
- package/package.json +46 -4
package/README.md
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @getpaseo/client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TypeScript SDK for building integrations on top of a Paseo daemon.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @getpaseo/client
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { createPaseoClient } from "@getpaseo/client";
|
|
11
|
+
|
|
12
|
+
const client = createPaseoClient({ url: "ws://127.0.0.1:6767/ws" });
|
|
13
|
+
await client.connect();
|
|
14
|
+
|
|
15
|
+
const agent = await client.agents.create({
|
|
16
|
+
config: { provider: "codex/gpt-5.5" },
|
|
17
|
+
cwd: "/Users/me/dev/storefront",
|
|
18
|
+
prompt: "Review the current diff and name the riskiest change.",
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const result = await agent.waitForFinish();
|
|
22
|
+
console.log(result.lastMessage);
|
|
23
|
+
|
|
24
|
+
await client.close();
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The public API is the package root. Imports under `@getpaseo/client/internal/*` are unsupported implementation details used by Paseo's own packages.
|
|
28
|
+
|
|
29
|
+
Read the [SDK documentation](https://paseo.sh/docs/sdk) for agents, workspaces, terminals, provider discovery, events, recipes, and the API reference. Runnable TypeScript patterns also live in [`examples/`](./examples/README.md).
|
|
30
|
+
|
|
31
|
+
## Runtime
|
|
32
|
+
|
|
33
|
+
The client needs a WebSocket implementation. Modern browsers and Node.js 22 provide one globally.
|
|
34
|
+
|
|
35
|
+
Use a WebSocket URL ending in `/ws`, such as `ws://127.0.0.1:6767/ws`. Pass `password` when the daemon requires authentication.
|
|
36
|
+
|
|
37
|
+
The client advertises its supported protocol capabilities by default. Optional `capabilities`
|
|
38
|
+
overrides extend or override that declaration; browser hosting must be supplied by the caller.
|
|
39
|
+
Connecting alone does not subscribe to agent timelines or catalog events. See the
|
|
40
|
+
[event guide](https://paseo.sh/docs/sdk/events) for subscription lifetimes and timeline replacements.
|
|
41
|
+
|
|
42
|
+
## Stability
|
|
43
|
+
|
|
44
|
+
The high-level API exported from `@getpaseo/client` is the supported SDK surface. The SDK and daemon remain protocol-compatible across versions, but newly added capabilities can require a newer daemon.
|
package/build-info.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"upstreamVersion": "0.11.2",
|
|
4
|
+
"revision": 1,
|
|
5
|
+
"version": "0.11.2-personal.1",
|
|
6
|
+
"appVersion": "0.11.2",
|
|
7
|
+
"androidVersionCode": 11002001,
|
|
8
|
+
"iosBuildNumber": "11002999",
|
|
9
|
+
"sourceSha": "f6d461e8aed966e668ec4dd7c5e574877fde0937",
|
|
10
|
+
"lockSha256": "2c24d71c5c42c035bf12fda1d893f203fd2e659e8477953995cb55f870d3b861",
|
|
11
|
+
"nodeVersion": "v24.21.0",
|
|
12
|
+
"npmVersion": "11.19.0",
|
|
13
|
+
"platform": "linux",
|
|
14
|
+
"arch": "x64",
|
|
15
|
+
"signature": "unsigned",
|
|
16
|
+
"githubRunId": "37967635075",
|
|
17
|
+
"githubRunAttempt": "1",
|
|
18
|
+
"marker": "v0112-all-1884",
|
|
19
|
+
"packageName": "@yinaoxiong/paseo-client",
|
|
20
|
+
"desktopVersion": "0.11.2+personal.1"
|
|
21
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { GetProvidersSnapshotResponseMessage, ListProviderModelsResponseMessage, SessionOutboundMessage } from "@getpaseo/protocol/messages";
|
|
2
|
+
type ListProviderModelsPayload = ListProviderModelsResponseMessage["payload"];
|
|
3
|
+
type GetProvidersSnapshotPayload = GetProvidersSnapshotResponseMessage["payload"];
|
|
4
|
+
type ProvidersSnapshotUpdatePayload = Extract<SessionOutboundMessage, {
|
|
5
|
+
type: "providers_snapshot_update";
|
|
6
|
+
}>["payload"];
|
|
7
|
+
export declare function normalizeListProviderModelsPayload(payload: ListProviderModelsPayload): ListProviderModelsPayload;
|
|
8
|
+
export declare function normalizeProvidersSnapshotPayload<T extends GetProvidersSnapshotPayload | ProvidersSnapshotUpdatePayload>(payload: T, expand?: boolean): T;
|
|
9
|
+
export declare function normalizeProviderSnapshotUpdateMessage(msg: SessionOutboundMessage, expand?: boolean): SessionOutboundMessage;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=normalize-provider-models.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { normalizeAgentModelDefinition } from "@getpaseo/protocol/agent-types";
|
|
2
|
+
import { expandProviderSnapshot } from "@getpaseo/protocol/provider-snapshot-codec";
|
|
3
|
+
// COMPAT(model-normalize): daemon normalizes at source (provider-registry) — shim covers older daemons; drop when floor >= v0.1.104
|
|
4
|
+
function normalizeAgentModels(models) {
|
|
5
|
+
if (!models) {
|
|
6
|
+
return models;
|
|
7
|
+
}
|
|
8
|
+
let changed = false;
|
|
9
|
+
const normalized = models.map((model) => {
|
|
10
|
+
const next = normalizeAgentModelDefinition(model);
|
|
11
|
+
changed || (changed = next !== model);
|
|
12
|
+
return next;
|
|
13
|
+
});
|
|
14
|
+
return changed ? normalized : models;
|
|
15
|
+
}
|
|
16
|
+
function normalizeProviderSnapshotEntry(entry) {
|
|
17
|
+
const models = normalizeAgentModels(entry.models);
|
|
18
|
+
return models === entry.models ? entry : { ...entry, models };
|
|
19
|
+
}
|
|
20
|
+
function normalizeProviderSnapshotEntries(entries) {
|
|
21
|
+
let changed = false;
|
|
22
|
+
const normalized = entries.map((entry) => {
|
|
23
|
+
const next = normalizeProviderSnapshotEntry(entry);
|
|
24
|
+
changed || (changed = next !== entry);
|
|
25
|
+
return next;
|
|
26
|
+
});
|
|
27
|
+
return changed ? normalized : entries;
|
|
28
|
+
}
|
|
29
|
+
export function normalizeListProviderModelsPayload(payload) {
|
|
30
|
+
const models = normalizeAgentModels(payload.models);
|
|
31
|
+
return models === payload.models ? payload : { ...payload, models };
|
|
32
|
+
}
|
|
33
|
+
export function normalizeProvidersSnapshotPayload(payload, expand = true) {
|
|
34
|
+
if (payload.compactSnapshot && !expand)
|
|
35
|
+
return payload;
|
|
36
|
+
const decoded = payload.compactSnapshot
|
|
37
|
+
? expandProviderSnapshot(payload.compactSnapshot)
|
|
38
|
+
: normalizeProviderSnapshotEntries(payload.entries);
|
|
39
|
+
const freshness = payload.fetchedAt;
|
|
40
|
+
const entries = freshness && expand
|
|
41
|
+
? decoded.map((entry) => freshness[entry.provider] ? { ...entry, fetchedAt: freshness[entry.provider] } : entry)
|
|
42
|
+
: decoded;
|
|
43
|
+
return entries === payload.entries ? payload : { ...payload, entries };
|
|
44
|
+
}
|
|
45
|
+
export function normalizeProviderSnapshotUpdateMessage(msg, expand = true) {
|
|
46
|
+
if (msg.type !== "providers_snapshot_update") {
|
|
47
|
+
return msg;
|
|
48
|
+
}
|
|
49
|
+
return { ...msg, payload: normalizeProvidersSnapshotPayload(msg.payload, expand) };
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=normalize-provider-models.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export { OwnedSubscriptions, type OwnedSubscription, type SubscriptionObserver } from "./owned.js";
|
|
2
|
+
import { OwnedSubscriptions, type OwnedSubscription, type OwnedSubscriptionsHost } from "./owned.js";
|
|
3
|
+
import { type ObservationRequest } from "./legacy.js";
|
|
4
|
+
import { type SessionInboundMessage, type SessionOutboundMessage, type ServerInfoStatusPayload } from "@getpaseo/protocol/messages";
|
|
5
|
+
import { type ClientCapability } from "@getpaseo/protocol/client-capabilities";
|
|
6
|
+
export declare class ConnectionSubscriptions extends OwnedSubscriptions {
|
|
7
|
+
private readonly connection;
|
|
8
|
+
private legacy;
|
|
9
|
+
constructor(connection: OwnedSubscriptionsHost & {
|
|
10
|
+
send(message: ObservationRequest): Promise<void>;
|
|
11
|
+
});
|
|
12
|
+
restore(info?: ServerInfoStatusPayload, capabilities?: Partial<Record<ClientCapability, unknown>>): void;
|
|
13
|
+
disconnected(): void;
|
|
14
|
+
observeRequest<T>(query: ObservationRequest, request: (query: ObservationRequest, accept: (snapshot: T) => void) => Promise<T>, signal?: AbortSignal, failed?: () => void): OwnedSubscription<T>;
|
|
15
|
+
owns(message: SessionOutboundMessage): boolean;
|
|
16
|
+
receive(message: SessionOutboundMessage): void;
|
|
17
|
+
normalize(message: SessionOutboundMessage): SessionOutboundMessage;
|
|
18
|
+
prepareRequest(message: SessionInboundMessage): {
|
|
19
|
+
message: SessionInboundMessage;
|
|
20
|
+
receive(message: SessionOutboundMessage): SessionOutboundMessage;
|
|
21
|
+
finish(): Promise<void>;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export declare const DEFAULT_CLIENT_CAPABILITIES: {
|
|
25
|
+
hello_rejection: true;
|
|
26
|
+
owned_subscriptions: true;
|
|
27
|
+
all_providers: true;
|
|
28
|
+
selective_agent_timeline: true;
|
|
29
|
+
reasoning_merge_enum: true;
|
|
30
|
+
custom_mode_icons: true;
|
|
31
|
+
terminal_reflowable_snapshot: true;
|
|
32
|
+
provider_subagents: true;
|
|
33
|
+
projected_subagent_timeline: true;
|
|
34
|
+
project_updates: true;
|
|
35
|
+
compact_provider_snapshots: true;
|
|
36
|
+
provider_snapshot_references: true;
|
|
37
|
+
timeline_replacement_invalidation: true;
|
|
38
|
+
timeline_notifications: true;
|
|
39
|
+
plugin_timeline_items: true;
|
|
40
|
+
workspace_setup_blocked: true;
|
|
41
|
+
explicit_event_subscriptions: true;
|
|
42
|
+
};
|
|
43
|
+
/** Calling releases demand; ready waits for membership, or local attachment on broadcast hosts. */
|
|
44
|
+
export type TimelineSubscription = (() => void) & {
|
|
45
|
+
readonly ready: Promise<void>;
|
|
46
|
+
readonly subscriptionId: string | null;
|
|
47
|
+
release(): Promise<void>;
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export { OwnedSubscriptions } from "./owned.js";
|
|
2
|
+
import { OwnedSubscriptions, } from "./owned.js";
|
|
3
|
+
import { LegacySubscriptions } from "./legacy.js";
|
|
4
|
+
import { CLIENT_CAPS } from "@getpaseo/protocol/client-capabilities";
|
|
5
|
+
export class ConnectionSubscriptions extends OwnedSubscriptions {
|
|
6
|
+
constructor(connection) {
|
|
7
|
+
super({
|
|
8
|
+
...connection,
|
|
9
|
+
release: async (id) => {
|
|
10
|
+
if (!this.legacy)
|
|
11
|
+
return connection.release(id);
|
|
12
|
+
const message = this.legacy.release(id);
|
|
13
|
+
if (message)
|
|
14
|
+
await connection.send(message);
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
this.connection = connection;
|
|
18
|
+
this.legacy = null;
|
|
19
|
+
}
|
|
20
|
+
restore(info, capabilities) {
|
|
21
|
+
if (info) {
|
|
22
|
+
const clientCapabilities = capabilities ?? DEFAULT_CLIENT_CAPABILITIES;
|
|
23
|
+
const owned = info.features?.ownedSubscriptions === true &&
|
|
24
|
+
clientCapabilities[CLIENT_CAPS.ownedSubscriptions] === true;
|
|
25
|
+
this.legacy = null;
|
|
26
|
+
if (!owned) {
|
|
27
|
+
this.legacy = new LegacySubscriptions(info, this.connection.send, capabilities?.[CLIENT_CAPS.browserHost]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
super.restore();
|
|
31
|
+
}
|
|
32
|
+
disconnected() {
|
|
33
|
+
super.disconnected();
|
|
34
|
+
this.legacy = null;
|
|
35
|
+
}
|
|
36
|
+
observeRequest(query, request, signal, failed) {
|
|
37
|
+
return super.observe(async (accept) => {
|
|
38
|
+
const legacy = this.legacy;
|
|
39
|
+
if (!legacy)
|
|
40
|
+
return request(query, accept);
|
|
41
|
+
const interest = legacy.start(query);
|
|
42
|
+
const snapshot = (payload) => ({
|
|
43
|
+
...payload,
|
|
44
|
+
subscriptionId: interest.id,
|
|
45
|
+
});
|
|
46
|
+
try {
|
|
47
|
+
const message = legacy.request(interest);
|
|
48
|
+
if (!message) {
|
|
49
|
+
// Broadcast-era hosts have no acknowledgement. Readiness means the
|
|
50
|
+
// local listener is attached; no server membership is being claimed.
|
|
51
|
+
const value = snapshot({
|
|
52
|
+
requestId: interest.id,
|
|
53
|
+
...(query.type === "agent.timeline.set_subscription.request"
|
|
54
|
+
? { agentIds: query.agentIds }
|
|
55
|
+
: {}),
|
|
56
|
+
});
|
|
57
|
+
accept(value);
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
return snapshot(await request(message, (payload) => accept(snapshot(payload))));
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
const release = legacy.release(interest.id);
|
|
64
|
+
if (release && this.legacy === legacy)
|
|
65
|
+
await this.connection.send(release).catch(this.connection.failed);
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}, signal, failed);
|
|
69
|
+
}
|
|
70
|
+
owns(message) {
|
|
71
|
+
return this.legacy ? this.legacy.owns(message) : super.owns(message);
|
|
72
|
+
}
|
|
73
|
+
receive(message) {
|
|
74
|
+
if (this.legacy)
|
|
75
|
+
this.legacy.receive(message, (update) => super.receive(update));
|
|
76
|
+
else
|
|
77
|
+
super.receive(message);
|
|
78
|
+
}
|
|
79
|
+
normalize(message) {
|
|
80
|
+
return this.legacy?.normalize(message) ?? message;
|
|
81
|
+
}
|
|
82
|
+
prepareRequest(message) {
|
|
83
|
+
return (this.legacy?.prepareRequest(message) ?? {
|
|
84
|
+
message,
|
|
85
|
+
receive: (value) => value,
|
|
86
|
+
finish: async () => { },
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// Protocol support belongs to the installed client. Only browser hosting needs
|
|
91
|
+
// a resource supplied by the caller. Keep this exhaustive as the protocol evolves.
|
|
92
|
+
export const DEFAULT_CLIENT_CAPABILITIES = {
|
|
93
|
+
[CLIENT_CAPS.helloRejection]: true,
|
|
94
|
+
[CLIENT_CAPS.ownedSubscriptions]: true,
|
|
95
|
+
[CLIENT_CAPS.allProviders]: true,
|
|
96
|
+
[CLIENT_CAPS.selectiveAgentTimeline]: true,
|
|
97
|
+
[CLIENT_CAPS.reasoningMergeEnum]: true,
|
|
98
|
+
[CLIENT_CAPS.customModeIcons]: true,
|
|
99
|
+
[CLIENT_CAPS.terminalReflowableSnapshot]: true,
|
|
100
|
+
[CLIENT_CAPS.providerSubagents]: true,
|
|
101
|
+
[CLIENT_CAPS.projectedSubagentTimeline]: true,
|
|
102
|
+
[CLIENT_CAPS.projectUpdates]: true,
|
|
103
|
+
[CLIENT_CAPS.compactProviderSnapshots]: true,
|
|
104
|
+
[CLIENT_CAPS.providerSnapshotReferences]: true,
|
|
105
|
+
[CLIENT_CAPS.timelineReplacementInvalidation]: true,
|
|
106
|
+
[CLIENT_CAPS.timelineNotifications]: true,
|
|
107
|
+
[CLIENT_CAPS.pluginTimelineItems]: true,
|
|
108
|
+
[CLIENT_CAPS.workspaceSetupBlocked]: true,
|
|
109
|
+
[CLIENT_CAPS.explicitEventSubscriptions]: true,
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SessionOutboundMessage } from "@getpaseo/protocol/messages";
|
|
2
|
+
type AgentEntry = Extract<SessionOutboundMessage, {
|
|
3
|
+
type: "fetch_agents_response";
|
|
4
|
+
}>["payload"]["entries"][number];
|
|
5
|
+
type Workspace = Extract<SessionOutboundMessage, {
|
|
6
|
+
type: "fetch_workspaces_response";
|
|
7
|
+
}>["payload"]["entries"][number];
|
|
8
|
+
type WorkspaceUpdate = Extract<SessionOutboundMessage, {
|
|
9
|
+
type: "workspace_update";
|
|
10
|
+
}>;
|
|
11
|
+
export declare class LegacyWorkspaces {
|
|
12
|
+
private readonly agents;
|
|
13
|
+
normalize(message: SessionOutboundMessage): SessionOutboundMessage;
|
|
14
|
+
read(entries: AgentEntry[], reset: boolean): Workspace[];
|
|
15
|
+
update(message: SessionOutboundMessage): WorkspaceUpdate[];
|
|
16
|
+
private workspaces;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=legacy-workspaces.d.ts.map
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { AgentSnapshotPayloadSchema } from "@getpaseo/protocol/messages";
|
|
2
|
+
import { deriveAgentStateBucket, getWorkspaceStateBucketPriority, } from "@getpaseo/protocol/agent-state-bucket";
|
|
3
|
+
// Preserve the pre-registry app's identity format. This is an opaque ID, never
|
|
4
|
+
// a filesystem path: converting C:\ to C: changes a drive root into a relative path.
|
|
5
|
+
function legacyWorkspaceId(value) {
|
|
6
|
+
return value.trim().replace(/\\/g, "/").replace(/\/+$/, "") || "/";
|
|
7
|
+
}
|
|
8
|
+
// COMPAT(legacyWorkspaceDaemon): restored in v0.8.0; remove after 2027-03-11 once daemon floor >= v0.1.97.
|
|
9
|
+
// The pre-registry app grouped agents by checkout path. Keep that representation
|
|
10
|
+
// at the client edge, including live updates, so app workflows need no version branch.
|
|
11
|
+
export class LegacyWorkspaces {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.agents = new Map();
|
|
14
|
+
}
|
|
15
|
+
normalize(message) {
|
|
16
|
+
const stamp = (agent) => ({
|
|
17
|
+
...agent,
|
|
18
|
+
workspaceId: agent.workspaceId ?? legacyWorkspaceId(agent.cwd),
|
|
19
|
+
});
|
|
20
|
+
if (message.type === "fetch_agents_response")
|
|
21
|
+
return {
|
|
22
|
+
...message,
|
|
23
|
+
payload: {
|
|
24
|
+
...message.payload,
|
|
25
|
+
entries: message.payload.entries.map((entry) => ({
|
|
26
|
+
...entry,
|
|
27
|
+
agent: stamp(entry.agent),
|
|
28
|
+
})),
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
if (message.type === "agent_update" && message.payload.kind === "upsert")
|
|
32
|
+
return { ...message, payload: { ...message.payload, agent: stamp(message.payload.agent) } };
|
|
33
|
+
if ((message.type === "fetch_agent_response" ||
|
|
34
|
+
message.type === "fetch_agent_timeline_response" ||
|
|
35
|
+
message.type === "cancel_agent_response") &&
|
|
36
|
+
message.payload.agent) {
|
|
37
|
+
return {
|
|
38
|
+
...message,
|
|
39
|
+
payload: { ...message.payload, agent: stamp(message.payload.agent) },
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (message.type === "status" &&
|
|
43
|
+
(message.payload.status === "agent_created" || message.payload.status === "agent_resumed")) {
|
|
44
|
+
return {
|
|
45
|
+
...message,
|
|
46
|
+
payload: {
|
|
47
|
+
...message.payload,
|
|
48
|
+
agent: stamp(AgentSnapshotPayloadSchema.parse(message.payload.agent)),
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return message;
|
|
53
|
+
}
|
|
54
|
+
read(entries, reset) {
|
|
55
|
+
if (reset)
|
|
56
|
+
this.agents.clear();
|
|
57
|
+
for (const entry of entries)
|
|
58
|
+
this.agents.set(entry.agent.id, entry);
|
|
59
|
+
const pageIds = new Set(entries.map(workspaceId));
|
|
60
|
+
return [...this.workspaces().values()].filter((workspace) => pageIds.has(workspace.id));
|
|
61
|
+
}
|
|
62
|
+
update(message) {
|
|
63
|
+
if (message.type !== "agent_update")
|
|
64
|
+
return [];
|
|
65
|
+
const before = this.workspaces();
|
|
66
|
+
const update = message.payload;
|
|
67
|
+
if (update.kind === "remove")
|
|
68
|
+
this.agents.delete(update.agentId);
|
|
69
|
+
else {
|
|
70
|
+
const project = update.project ?? this.agents.get(update.agent.id)?.project;
|
|
71
|
+
if (update.agent.archivedAt)
|
|
72
|
+
this.agents.delete(update.agent.id);
|
|
73
|
+
else if (project)
|
|
74
|
+
this.agents.set(update.agent.id, { agent: update.agent, project });
|
|
75
|
+
}
|
|
76
|
+
const after = this.workspaces();
|
|
77
|
+
const changes = [];
|
|
78
|
+
for (const [id, workspace] of after) {
|
|
79
|
+
if (JSON.stringify(before.get(id)) !== JSON.stringify(workspace))
|
|
80
|
+
changes.push({ type: "workspace_update", payload: { kind: "upsert", workspace } });
|
|
81
|
+
}
|
|
82
|
+
for (const id of before.keys())
|
|
83
|
+
if (!after.has(id))
|
|
84
|
+
changes.push({ type: "workspace_update", payload: { kind: "remove", id } });
|
|
85
|
+
return changes;
|
|
86
|
+
}
|
|
87
|
+
workspaces() {
|
|
88
|
+
const workspaces = new Map();
|
|
89
|
+
for (const entry of this.agents.values()) {
|
|
90
|
+
const { agent, project } = entry;
|
|
91
|
+
const { checkout } = project;
|
|
92
|
+
const id = workspaceId(entry);
|
|
93
|
+
const status = deriveAgentStateBucket({
|
|
94
|
+
status: agent.status,
|
|
95
|
+
pendingPermissionCount: agent.pendingPermissions.length,
|
|
96
|
+
requiresAttention: agent.requiresAttention,
|
|
97
|
+
attentionReason: agent.attentionReason,
|
|
98
|
+
});
|
|
99
|
+
const existing = workspaces.get(id);
|
|
100
|
+
if (existing &&
|
|
101
|
+
getWorkspaceStateBucketPriority(existing.status) <= getWorkspaceStateBucketPriority(status))
|
|
102
|
+
continue;
|
|
103
|
+
workspaces.set(id, {
|
|
104
|
+
id,
|
|
105
|
+
projectId: project.projectKey,
|
|
106
|
+
projectDisplayName: project.projectName,
|
|
107
|
+
projectCustomName: null,
|
|
108
|
+
projectRootPath: checkout.mainRepoRoot ?? checkout.worktreeRoot ?? checkout.cwd,
|
|
109
|
+
workspaceDirectory: checkout.cwd,
|
|
110
|
+
projectKind: checkout.isGit ? "git" : "non_git",
|
|
111
|
+
workspaceKind: workspaceKind(checkout),
|
|
112
|
+
name: workspaceName(entry, id),
|
|
113
|
+
title: null,
|
|
114
|
+
status,
|
|
115
|
+
statusEnteredAt: agent.attentionTimestamp ?? agent.updatedAt,
|
|
116
|
+
activityAt: agent.updatedAt,
|
|
117
|
+
archivingAt: null,
|
|
118
|
+
diffStat: null,
|
|
119
|
+
scripts: [],
|
|
120
|
+
gitRuntime: gitRuntime(checkout),
|
|
121
|
+
githubRuntime: null,
|
|
122
|
+
project,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return workspaces;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function workspaceId(entry) {
|
|
129
|
+
return entry.agent.workspaceId ?? legacyWorkspaceId(entry.project.checkout.cwd);
|
|
130
|
+
}
|
|
131
|
+
function workspaceKind(checkout) {
|
|
132
|
+
if (!checkout.isGit)
|
|
133
|
+
return "directory";
|
|
134
|
+
if (checkout.isPaseoOwnedWorktree)
|
|
135
|
+
return "worktree";
|
|
136
|
+
return "checkout";
|
|
137
|
+
}
|
|
138
|
+
function workspaceName(entry, id) {
|
|
139
|
+
const name = entry.project.workspaceName?.trim();
|
|
140
|
+
if (name)
|
|
141
|
+
return name;
|
|
142
|
+
const branch = entry.project.checkout.currentBranch?.trim();
|
|
143
|
+
if (branch && branch !== "HEAD")
|
|
144
|
+
return branch;
|
|
145
|
+
return id.slice(id.lastIndexOf("/") + 1);
|
|
146
|
+
}
|
|
147
|
+
function gitRuntime(checkout) {
|
|
148
|
+
if (!checkout.isGit)
|
|
149
|
+
return null;
|
|
150
|
+
return {
|
|
151
|
+
currentBranch: checkout.currentBranch,
|
|
152
|
+
remoteUrl: checkout.remoteUrl,
|
|
153
|
+
isPaseoOwnedWorktree: checkout.isPaseoOwnedWorktree,
|
|
154
|
+
isDirty: null,
|
|
155
|
+
aheadBehind: null,
|
|
156
|
+
aheadOfOrigin: null,
|
|
157
|
+
behindOfOrigin: null,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=legacy-workspaces.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ServerInfoStatusPayload, SessionInboundMessage, SessionOutboundMessage } from "@getpaseo/protocol/messages";
|
|
2
|
+
export type ObservationRequest = {
|
|
3
|
+
type: SessionInboundMessage["type"];
|
|
4
|
+
} & Record<string, unknown>;
|
|
5
|
+
interface Interest {
|
|
6
|
+
id: string;
|
|
7
|
+
query: ObservationRequest;
|
|
8
|
+
}
|
|
9
|
+
export declare class LegacySubscriptions {
|
|
10
|
+
private readonly info;
|
|
11
|
+
private readonly send;
|
|
12
|
+
private readonly browserHost;
|
|
13
|
+
private readonly interests;
|
|
14
|
+
private readonly workspaces;
|
|
15
|
+
constructor(info: ServerInfoStatusPayload, send: (message: ObservationRequest) => Promise<void>, browserHost: unknown);
|
|
16
|
+
normalize(message: SessionOutboundMessage): SessionOutboundMessage;
|
|
17
|
+
prepareRequest(message: SessionInboundMessage): {
|
|
18
|
+
message: SessionInboundMessage;
|
|
19
|
+
receive(message: SessionOutboundMessage): SessionOutboundMessage;
|
|
20
|
+
finish(): Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
start(query: ObservationRequest): Interest;
|
|
23
|
+
request({ id, query }: Interest): ObservationRequest | null;
|
|
24
|
+
private members;
|
|
25
|
+
release(id: string): ObservationRequest | null;
|
|
26
|
+
owns(message: SessionOutboundMessage): boolean;
|
|
27
|
+
receive(message: SessionOutboundMessage, deliver: (message: SessionOutboundMessage) => void): void;
|
|
28
|
+
private matches;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=legacy.d.ts.map
|