@getpaseo/server 0.16.0 → 0.16.2
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/server/builtin-plugins/package.json +1 -1
- package/dist/server/builtin-plugins/worktree-include/server/copy.ts +162 -16
- package/dist/server/server/agent/agent-manager.js +9 -16
- package/dist/server/server/agent/providers/claude/agent.d.ts +1 -0
- package/dist/server/server/agent/providers/claude/agent.js +41 -7
- package/dist/server/server/agent/providers/claude/bypass-approval.d.ts +5 -0
- package/dist/server/server/agent/providers/claude/bypass-approval.js +37 -0
- package/dist/server/server/agent/providers/claude/model-discovery.d.ts +2 -0
- package/dist/server/server/agent/providers/claude/model-discovery.js +55 -11
- package/dist/server/server/agent/providers/codex-app-server-agent.js +3 -0
- package/dist/server/server/agent/providers/model-label.d.ts +5 -0
- package/dist/server/server/agent/providers/model-label.js +21 -0
- package/dist/server/server/agent/providers/omp/agent.d.ts +2 -2
- package/dist/server/server/agent/providers/omp/agent.js +23 -26
- package/dist/server/server/agent/providers/omp/map-omp-model.js +2 -1
- package/dist/server/server/agent/providers/omp/rpc-types.d.ts +4 -0
- package/dist/server/server/agent/providers/omp/rpc-types.js +8 -0
- package/dist/server/server/agent/providers/opencode-agent.js +15 -10
- package/dist/server/server/agent/providers/pi/agent.d.ts +1 -2
- package/dist/server/server/agent/providers/pi/agent.js +4 -28
- package/dist/server/server/agent/timeline-projection.d.ts +6 -0
- package/dist/server/server/agent/timeline-projection.js +12 -8
- package/dist/server/server/agent/tools/paseo-tools.js +8 -2
- package/dist/server/server/bootstrap.js +2 -2
- package/dist/server/server/file-observer/index.d.ts +1 -0
- package/dist/server/server/file-observer/index.js +14 -1
- package/dist/server/server/file-observer/internal/observation.js +4 -0
- package/dist/server/server/hub/relationship-controller.js +26 -15
- package/dist/server/server/hub/relationship-remote.d.ts +1 -1
- package/dist/server/server/hub/relationship-remote.js +2 -2
- package/dist/server/server/resolve-worktree-creation-intent.d.ts +1 -1
- package/dist/server/server/session/workspace-recovery/workspace-recovery-service.js +30 -4
- package/dist/server/server/test-fixtures/reconciliation-registries.d.ts +1 -0
- package/dist/server/server/websocket-server.d.ts +5 -0
- package/dist/server/server/websocket-server.js +10 -2
- package/dist/server/server/workspace-archive-service.js +10 -2
- package/dist/server/server/workspace-git-service.d.ts +1 -0
- package/dist/server/server/workspace-git-service.js +31 -5
- package/dist/server/server/workspace-registry.d.ts +2 -0
- package/dist/server/server/workspace-registry.js +2 -0
- package/dist/server/terminal/terminal-worker-process.js +16 -14
- package/dist/server/terminal/terminal-worker-socket-path.d.ts +15 -1
- package/dist/server/terminal/terminal-worker-socket-path.js +57 -9
- package/dist/server/terminal-worker/terminal-worker.mjs +51 -23
- package/dist/server/utils/checkout-git.js +9 -1
- package/dist/server/utils/worktree.d.ts +14 -1
- package/dist/server/utils/worktree.js +58 -7
- package/dist/server/web-ui/_expo/static/js/web/{index-c6834d1a59b83addc7491f02fc3b6494.js → index-3d51f4c450eeff5bd838a646e9c611f2.js} +24 -24
- package/dist/server/web-ui/_expo/static/js/web/index-3d51f4c450eeff5bd838a646e9c611f2.js.br +0 -0
- package/dist/server/web-ui/_expo/static/js/web/index-3d51f4c450eeff5bd838a646e9c611f2.js.gz +0 -0
- package/dist/server/web-ui/index.html +1 -1
- package/dist/server/web-ui/index.html.br +0 -0
- package/dist/server/web-ui/index.html.gz +0 -0
- package/package.json +7 -7
- package/dist/server/web-ui/_expo/static/js/web/index-c6834d1a59b83addc7491f02fc3b6494.js.br +0 -0
- package/dist/server/web-ui/_expo/static/js/web/index-c6834d1a59b83addc7491f02fc3b6494.js.gz +0 -0
|
@@ -75,31 +75,6 @@ function createOmpNoTurnScheduler() {
|
|
|
75
75
|
},
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
function normalizeOmpModelLabel(label) {
|
|
79
|
-
const normalizedLabel = label.trim().replace(/[_\s]+/g, " ");
|
|
80
|
-
const vendorSeparatorIndex = normalizedLabel.indexOf(": ");
|
|
81
|
-
if (vendorSeparatorIndex === -1) {
|
|
82
|
-
return normalizedLabel;
|
|
83
|
-
}
|
|
84
|
-
return normalizedLabel.slice(vendorSeparatorIndex + 2).trim();
|
|
85
|
-
}
|
|
86
|
-
export function transformOmpModels(models) {
|
|
87
|
-
return models.map((model) => {
|
|
88
|
-
if (!model.label.includes("/")) {
|
|
89
|
-
return model;
|
|
90
|
-
}
|
|
91
|
-
const segments = model.label.split("/").filter((segment) => segment.length > 0);
|
|
92
|
-
const rawLabel = segments.at(-1);
|
|
93
|
-
if (!rawLabel) {
|
|
94
|
-
return model;
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
...model,
|
|
98
|
-
label: normalizeOmpModelLabel(rawLabel),
|
|
99
|
-
description: model.description ?? model.label,
|
|
100
|
-
};
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
78
|
function isOmpThinkingLevel(value) {
|
|
104
79
|
return (value === "off" ||
|
|
105
80
|
value === "minimal" ||
|
|
@@ -1313,7 +1288,29 @@ export class OmpAgentSession {
|
|
|
1313
1288
|
item: { type: "assistant_message", text },
|
|
1314
1289
|
});
|
|
1315
1290
|
}
|
|
1291
|
+
// OMP changes the level on its own, e.g. `/switch @role` or a model switch that carries a level.
|
|
1292
|
+
handleThinkingLevelChanged(event) {
|
|
1293
|
+
if (event.type !== "thinking_level_changed") {
|
|
1294
|
+
return false;
|
|
1295
|
+
}
|
|
1296
|
+
const thinkingLevel = normalizeOmpThinkingOption(event.configured ?? event.thinkingLevel);
|
|
1297
|
+
if (!thinkingLevel || thinkingLevel === this.lastKnownThinkingOptionId) {
|
|
1298
|
+
return true;
|
|
1299
|
+
}
|
|
1300
|
+
this.lastKnownThinkingOptionId = thinkingLevel;
|
|
1301
|
+
this.config.thinkingOptionId = thinkingLevel;
|
|
1302
|
+
this.state = { ...this.state, thinkingLevel };
|
|
1303
|
+
this.emit({
|
|
1304
|
+
type: "thinking_option_changed",
|
|
1305
|
+
provider: this.provider,
|
|
1306
|
+
thinkingOptionId: thinkingLevel,
|
|
1307
|
+
});
|
|
1308
|
+
return true;
|
|
1309
|
+
}
|
|
1316
1310
|
handleExtraRuntimeEvent(event) {
|
|
1311
|
+
if (this.handleThinkingLevelChanged(event)) {
|
|
1312
|
+
return true;
|
|
1313
|
+
}
|
|
1317
1314
|
if (event.type === "model_changed") {
|
|
1318
1315
|
void this.refreshState()
|
|
1319
1316
|
.then(() => this.emit({
|
|
@@ -2051,7 +2048,7 @@ export class OmpAgentClient {
|
|
|
2051
2048
|
if (!runtimeSession)
|
|
2052
2049
|
throw new Error("OMP catalog runtime did not start");
|
|
2053
2050
|
const catalogSession = runtimeSession;
|
|
2054
|
-
const models =
|
|
2051
|
+
const models = (await runProviderRefreshActivity(context, "get_available_models", () => catalogSession.getAvailableModels(null))).map((model) => mapOmpModel(model, this.provider));
|
|
2055
2052
|
return { models, modes: [...OMP_MODES] };
|
|
2056
2053
|
}
|
|
2057
2054
|
finally {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { modelDisplayLabel } from "../model-label.js";
|
|
1
2
|
export const DEFAULT_OMP_THINKING_LEVEL = "medium";
|
|
2
3
|
export const OMP_THINKING_OPTIONS = [
|
|
3
4
|
{ id: "auto", label: "Auto", description: "OMP picks the effort each turn" },
|
|
@@ -25,7 +26,7 @@ export function mapOmpModel(model, provider) {
|
|
|
25
26
|
return {
|
|
26
27
|
provider,
|
|
27
28
|
id: `${model.provider}/${model.id}`,
|
|
28
|
-
label:
|
|
29
|
+
label: modelDisplayLabel(model),
|
|
29
30
|
description: `${model.provider}/${model.id}`,
|
|
30
31
|
metadata: {
|
|
31
32
|
provider: model.provider,
|
|
@@ -2139,6 +2139,10 @@ export declare const OmpRuntimeEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
2139
2139
|
}, z.core.$loose>;
|
|
2140
2140
|
}, z.core.$loose>, z.ZodObject<{
|
|
2141
2141
|
type: z.ZodLiteral<"model_changed">;
|
|
2142
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
2143
|
+
type: z.ZodLiteral<"thinking_level_changed">;
|
|
2144
|
+
thinkingLevel: z.ZodOptional<z.ZodString>;
|
|
2145
|
+
configured: z.ZodOptional<z.ZodString>;
|
|
2142
2146
|
}, z.core.$loose>], "type">;
|
|
2143
2147
|
export declare const OmpRpcCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
2144
2148
|
type: z.ZodLiteral<"prompt">;
|
|
@@ -508,6 +508,14 @@ export const OmpRuntimeEventSchema = z.discriminatedUnion("type", [
|
|
|
508
508
|
OmpRpcHostToolCancelRequestSchema,
|
|
509
509
|
OmpRpcHostToolUpdateSchema,
|
|
510
510
|
z.object({ type: z.literal("model_changed") }).passthrough(),
|
|
511
|
+
z
|
|
512
|
+
.object({
|
|
513
|
+
type: z.literal("thinking_level_changed"),
|
|
514
|
+
thinkingLevel: z.string().optional(),
|
|
515
|
+
// The user's selector ("auto") when it differs from the level OMP runs.
|
|
516
|
+
configured: z.string().optional(),
|
|
517
|
+
})
|
|
518
|
+
.passthrough(),
|
|
511
519
|
]);
|
|
512
520
|
const OmpCommandBase = { id: z.string().optional() };
|
|
513
521
|
export const OmpRpcCommandSchema = z.discriminatedUnion("type", [
|
|
@@ -3787,19 +3787,24 @@ class OpenCodeAgentSession {
|
|
|
3787
3787
|
answers,
|
|
3788
3788
|
});
|
|
3789
3789
|
}
|
|
3790
|
-
this.pendingPermissions.delete(requestId);
|
|
3791
|
-
this.pendingPermissionDirectories.delete(requestId);
|
|
3792
|
-
return;
|
|
3793
3790
|
}
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3791
|
+
else {
|
|
3792
|
+
const reply = resolveOpenCodePermissionReply(response);
|
|
3793
|
+
await this.client.permission.reply({
|
|
3794
|
+
requestID: requestId,
|
|
3795
|
+
directory,
|
|
3796
|
+
reply,
|
|
3797
|
+
message: response.behavior === "deny" ? response.message : undefined,
|
|
3798
|
+
});
|
|
3799
|
+
}
|
|
3801
3800
|
this.pendingPermissions.delete(requestId);
|
|
3802
3801
|
this.pendingPermissionDirectories.delete(requestId);
|
|
3802
|
+
this.notifySubscribers({
|
|
3803
|
+
type: "permission_resolved",
|
|
3804
|
+
provider: "opencode",
|
|
3805
|
+
requestId,
|
|
3806
|
+
resolution: response,
|
|
3807
|
+
});
|
|
3803
3808
|
}
|
|
3804
3809
|
describePersistence() {
|
|
3805
3810
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Logger } from "pino";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { type AgentCapabilityFlags, type AgentClient, type AgentDraftControls, type AgentLaunchContext, type AgentMode, type
|
|
3
|
+
import { type AgentCapabilityFlags, type AgentClient, type AgentDraftControls, type AgentLaunchContext, type AgentMode, type AgentPermissionRequest, type AgentPermissionResponse, type AgentProviderNotice, type AgentPersistenceHandle, type AgentPromptInput, type AgentProvider, type AgentResumeSessionOptions, type AgentRunOptions, type AgentRunResult, type AgentRuntimeInfo, type AgentSession, type AgentSessionConfig, type AgentSlashCommand, type AgentStreamEvent, type FetchCatalogOptions, type SteerActiveTurnOptions, type SteerResult, type ImportableProviderSession, type ImportProviderSessionContext, type ImportProviderSessionInput, type ListImportableSessionsOptions, type ProviderCatalog, type ProviderRefreshContext } from "../../agent-sdk-types.js";
|
|
4
4
|
import { type ProviderRuntimeSettings } from "../../provider-launch-config.js";
|
|
5
5
|
import type { PiRuntime, PiRuntimeSession } from "./runtime.js";
|
|
6
6
|
import type { PiSessionState } from "./rpc-types.js";
|
|
@@ -32,7 +32,6 @@ interface PiRpcAgentSessionOptions {
|
|
|
32
32
|
logger: Logger;
|
|
33
33
|
usagePollScheduler?: PiUsagePollScheduler;
|
|
34
34
|
}
|
|
35
|
-
export declare function transformPiModels(models: AgentModelDefinition[]): AgentModelDefinition[];
|
|
36
35
|
export declare class PiRpcAgentSession implements AgentSession {
|
|
37
36
|
readonly provider: AgentProvider;
|
|
38
37
|
readonly capabilities: AgentCapabilityFlags;
|
|
@@ -19,6 +19,7 @@ import { createPiExtensionHost, piExtensionRuntimeBridge, } from "./extensions/i
|
|
|
19
19
|
import { resolveResumeProcessCwd } from "../resume-process-cwd.js";
|
|
20
20
|
import { revertPiConversation } from "./rewind.js";
|
|
21
21
|
import { copyPiSessionFileWithCwd, listPiImportableSessions, readPiImportSessionConfig, } from "./session-descriptor.js";
|
|
22
|
+
import { modelDisplayLabel } from "../model-label.js";
|
|
22
23
|
import { PiUsagePoller } from "./usage-poller.js";
|
|
23
24
|
import { mapToolDetail, parseToolArgs, parseToolResult, splitPiToolResultImages, } from "./tool-call-mapper.js";
|
|
24
25
|
const PI_PROVIDER = "pi";
|
|
@@ -108,31 +109,6 @@ function isPiDefinitiveSteerRejection(error) {
|
|
|
108
109
|
function isPiMissingClearQueueRpc(error) {
|
|
109
110
|
return toDiagnosticErrorMessage(error) === "Unknown command: clear_queue";
|
|
110
111
|
}
|
|
111
|
-
function normalizePiModelLabel(label) {
|
|
112
|
-
const normalizedLabel = label.trim().replace(/[_\s]+/g, " ");
|
|
113
|
-
const vendorSeparatorIndex = normalizedLabel.indexOf(": ");
|
|
114
|
-
if (vendorSeparatorIndex === -1) {
|
|
115
|
-
return normalizedLabel;
|
|
116
|
-
}
|
|
117
|
-
return normalizedLabel.slice(vendorSeparatorIndex + 2).trim();
|
|
118
|
-
}
|
|
119
|
-
export function transformPiModels(models) {
|
|
120
|
-
return models.map((model) => {
|
|
121
|
-
if (!model.label.includes("/")) {
|
|
122
|
-
return model;
|
|
123
|
-
}
|
|
124
|
-
const segments = model.label.split("/").filter((segment) => segment.length > 0);
|
|
125
|
-
const rawLabel = segments.at(-1);
|
|
126
|
-
if (!rawLabel) {
|
|
127
|
-
return model;
|
|
128
|
-
}
|
|
129
|
-
return {
|
|
130
|
-
...model,
|
|
131
|
-
label: normalizePiModelLabel(rawLabel),
|
|
132
|
-
description: model.description ?? model.label,
|
|
133
|
-
};
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
112
|
function isPiThinkingLevel(value) {
|
|
137
113
|
return (value === "off" ||
|
|
138
114
|
value === "minimal" ||
|
|
@@ -836,7 +812,7 @@ function mapPiModel(model, provider) {
|
|
|
836
812
|
return {
|
|
837
813
|
provider,
|
|
838
814
|
id: `${model.provider}/${model.id}`,
|
|
839
|
-
label:
|
|
815
|
+
label: modelDisplayLabel(model),
|
|
840
816
|
description: `${model.provider}/${model.id}`,
|
|
841
817
|
metadata: {
|
|
842
818
|
provider: model.provider,
|
|
@@ -2294,13 +2270,13 @@ export class PiRpcAgentClient {
|
|
|
2294
2270
|
const piModels = await runProviderRefreshActivity(context, "get_available_models", () => catalogSession.getAvailableModels(null));
|
|
2295
2271
|
// A fresh Pi session starts on the model Pi resolves from its own settings.
|
|
2296
2272
|
const { model: configuredModel } = await runProviderRefreshActivity(context, "get_state", () => catalogSession.getState());
|
|
2297
|
-
const models =
|
|
2273
|
+
const models = piModels.map((model) => {
|
|
2298
2274
|
const mapped = mapPiModel(model, PI_PROVIDER);
|
|
2299
2275
|
const isConfigured = model.provider === configuredModel?.provider && model.id === configuredModel?.id;
|
|
2300
2276
|
if (isConfigured)
|
|
2301
2277
|
mapped.isDefault = true;
|
|
2302
2278
|
return mapped;
|
|
2303
|
-
})
|
|
2279
|
+
});
|
|
2304
2280
|
return { models, modes: [] };
|
|
2305
2281
|
}
|
|
2306
2282
|
finally {
|
|
@@ -38,6 +38,12 @@ export declare function mergeToolCallItems(existing: Extract<AgentTimelineItem,
|
|
|
38
38
|
}>): Extract<AgentTimelineItem, {
|
|
39
39
|
type: "tool_call";
|
|
40
40
|
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Whether `next`, the row right after `previous`, is another chunk of the same assistant
|
|
43
|
+
* message. A turn id or message id change starts a new message, which matters where rows
|
|
44
|
+
* replayed from provider history carry no turn id.
|
|
45
|
+
*/
|
|
46
|
+
export declare function continuesAssistantMessage(previous: Pick<AgentTimelineRow, "item" | "turnId">, next: Pick<AgentTimelineRow, "item" | "turnId">): boolean;
|
|
41
47
|
/** A retained item. `seq` is its latest source event, not its display anchor. */
|
|
42
48
|
export type ProjectedTimelineRow = AgentTimelineRow & TimelineProjectionEntry;
|
|
43
49
|
interface ProjectedTimelinePageOptions {
|
|
@@ -165,26 +165,30 @@ function mergeReasoningChunks(entries) {
|
|
|
165
165
|
}
|
|
166
166
|
return output;
|
|
167
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Whether `next`, the row right after `previous`, is another chunk of the same assistant
|
|
170
|
+
* message. A turn id or message id change starts a new message, which matters where rows
|
|
171
|
+
* replayed from provider history carry no turn id.
|
|
172
|
+
*/
|
|
173
|
+
export function continuesAssistantMessage(previous, next) {
|
|
174
|
+
return (previous.item.type === "assistant_message" &&
|
|
175
|
+
next.item.type === "assistant_message" &&
|
|
176
|
+
previous.turnId === next.turnId &&
|
|
177
|
+
(next.item.messageId === undefined || next.item.messageId === previous.item.messageId));
|
|
178
|
+
}
|
|
168
179
|
function mergeAssistantChunks(entries) {
|
|
169
180
|
const output = [];
|
|
170
181
|
for (const entry of entries) {
|
|
171
182
|
const previous = output[output.length - 1];
|
|
172
183
|
const shouldMerge = previous &&
|
|
173
|
-
previous.item.type === "assistant_message" &&
|
|
174
|
-
entry.item.type === "assistant_message" &&
|
|
175
184
|
previous.seqEnd + 1 === entry.seqStart &&
|
|
176
|
-
previous
|
|
185
|
+
continuesAssistantMessage(previous, entry);
|
|
177
186
|
if (!shouldMerge || !previous) {
|
|
178
187
|
output.push(entry);
|
|
179
188
|
continue;
|
|
180
189
|
}
|
|
181
190
|
const previousAssistant = previous.item;
|
|
182
191
|
const entryAssistant = entry.item;
|
|
183
|
-
if (entryAssistant.messageId !== undefined &&
|
|
184
|
-
previousAssistant.messageId !== entryAssistant.messageId) {
|
|
185
|
-
output.push(entry);
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
192
|
const collapsedKinds = new Set([
|
|
189
193
|
...previous.collapsed,
|
|
190
194
|
...entry.collapsed,
|
|
@@ -1535,6 +1535,12 @@ function createToolCatalog(options, scope) {
|
|
|
1535
1535
|
};
|
|
1536
1536
|
return response;
|
|
1537
1537
|
});
|
|
1538
|
+
// Match the WebSocket snapshot: idle agents can still own background work.
|
|
1539
|
+
async function projectLiveAgent(agent) {
|
|
1540
|
+
const snapshot = await serializeSnapshotWithMetadata(agentStorage, agent, childLogger);
|
|
1541
|
+
const backgroundWork = agentManager.getAgentBackgroundWorkSummary(agent.id);
|
|
1542
|
+
return backgroundWork ? { ...snapshot, backgroundWork } : snapshot;
|
|
1543
|
+
}
|
|
1538
1544
|
registerTool("get_agent_status", {
|
|
1539
1545
|
title: "Get agent status",
|
|
1540
1546
|
description: "Return the latest snapshot for an agent, including lifecycle state, capabilities, and pending permissions.",
|
|
@@ -1548,7 +1554,7 @@ function createToolCatalog(options, scope) {
|
|
|
1548
1554
|
}, async ({ agentId }) => {
|
|
1549
1555
|
const snapshot = agentManager.getAgent(agentId);
|
|
1550
1556
|
if (snapshot) {
|
|
1551
|
-
const structuredSnapshot = await
|
|
1557
|
+
const structuredSnapshot = await projectLiveAgent(snapshot);
|
|
1552
1558
|
return {
|
|
1553
1559
|
content: [],
|
|
1554
1560
|
structuredContent: ensureValidJson({
|
|
@@ -1599,7 +1605,7 @@ function createToolCatalog(options, scope) {
|
|
|
1599
1605
|
manager: agentManager,
|
|
1600
1606
|
storage: agentStorage,
|
|
1601
1607
|
workspaces: options.workspaceRegistry,
|
|
1602
|
-
projectLive:
|
|
1608
|
+
projectLive: projectLiveAgent,
|
|
1603
1609
|
projectStored: (record) => buildStoredAgentPayload(record, new Set(providerSnapshotManager.listRegisteredProviderIds()), (provider, own) => agentManager.effectiveOptionsFor(provider, own)),
|
|
1604
1610
|
isProviderVisible: () => true,
|
|
1605
1611
|
isStoredProviderAvailable: (record) => isStoredAgentProviderAvailable(record, new Set(providerSnapshotManager.listRegisteredProviderIds())),
|
|
@@ -96,7 +96,7 @@ export async function fanOutReconciledWorkspaceUpdates(input) {
|
|
|
96
96
|
}
|
|
97
97
|
}));
|
|
98
98
|
}
|
|
99
|
-
import { VoiceAssistantWebSocketServer } from "./websocket-server.js";
|
|
99
|
+
import { VoiceAssistantWebSocketServer, isDaemonOriginAllowed } from "./websocket-server.js";
|
|
100
100
|
import { WorkspaceSetupRuntime } from "./workspace-setup-runtime.js";
|
|
101
101
|
import { createWorkspaceLabelService } from "./workspace-labels/index.js";
|
|
102
102
|
import { createGitHubService } from "../services/github-service.js";
|
|
@@ -515,7 +515,7 @@ export async function createPaseoDaemon(config, rootLogger, dependencies = {}) {
|
|
|
515
515
|
});
|
|
516
516
|
app.use((req, res, next) => {
|
|
517
517
|
const origin = req.headers.origin;
|
|
518
|
-
if (origin && (
|
|
518
|
+
if (origin && isDaemonOriginAllowed(origin, req.headers.host ?? null, allowedOrigins)) {
|
|
519
519
|
res.setHeader("Access-Control-Allow-Origin", origin);
|
|
520
520
|
res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
|
|
521
521
|
res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
|
|
@@ -36,7 +36,20 @@ class FileObserverService {
|
|
|
36
36
|
createBackend: this.createBackend,
|
|
37
37
|
onClosed: () => state.observations.delete(observation),
|
|
38
38
|
});
|
|
39
|
-
|
|
39
|
+
const { signal } = options;
|
|
40
|
+
signal?.throwIfAborted();
|
|
41
|
+
const abort = () => void observation.close();
|
|
42
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
43
|
+
try {
|
|
44
|
+
await observation.start();
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
signal?.removeEventListener("abort", abort);
|
|
48
|
+
}
|
|
49
|
+
if (signal?.aborted) {
|
|
50
|
+
await observation.close();
|
|
51
|
+
throw signal.reason;
|
|
52
|
+
}
|
|
40
53
|
if (this.closePromise) {
|
|
41
54
|
await observation.close();
|
|
42
55
|
throw new Error("File observer is closed");
|
|
@@ -21,6 +21,10 @@ class Observation {
|
|
|
21
21
|
if (!rootStats.isDirectory()) {
|
|
22
22
|
throw new Error(`File observation requires a directory: ${this.root}`);
|
|
23
23
|
}
|
|
24
|
+
// An aborted subscription can close the observation while the root is being read; the backend
|
|
25
|
+
// must not start after its close has already finished.
|
|
26
|
+
if (!this.isActive())
|
|
27
|
+
return;
|
|
24
28
|
try {
|
|
25
29
|
await this.backend.start();
|
|
26
30
|
}
|
|
@@ -148,7 +148,7 @@ export class HubRelationshipController {
|
|
|
148
148
|
}
|
|
149
149
|
async start() {
|
|
150
150
|
if (this.record?.state === "active")
|
|
151
|
-
this.openSocket(
|
|
151
|
+
this.openSocket(false);
|
|
152
152
|
if (this.record?.state === "pending") {
|
|
153
153
|
const enrollmentGeneration = this.beginEnrollmentAttempt();
|
|
154
154
|
try {
|
|
@@ -322,7 +322,7 @@ export class HubRelationshipController {
|
|
|
322
322
|
this.record = active;
|
|
323
323
|
this.retry = null;
|
|
324
324
|
this.retryAttempt = 0;
|
|
325
|
-
this.openSocket(
|
|
325
|
+
this.openSocket(false);
|
|
326
326
|
}
|
|
327
327
|
catch (error) {
|
|
328
328
|
if (enrollmentGeneration !== this.enrollmentGeneration)
|
|
@@ -338,14 +338,17 @@ export class HubRelationshipController {
|
|
|
338
338
|
this.inFlightEnrollments.delete(settled);
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
|
-
openSocket(
|
|
341
|
+
openSocket(reconnecting) {
|
|
342
|
+
const record = this.record;
|
|
343
|
+
if (record?.state !== "active")
|
|
344
|
+
return;
|
|
342
345
|
const generation = ++this.generation;
|
|
343
346
|
this.state = reconnecting ? "reconnecting" : "connecting";
|
|
344
347
|
const events = {
|
|
345
|
-
connected: (socket, sessionProtocol) => this.socketConnected(generation,
|
|
348
|
+
connected: (socket, sessionProtocol) => this.socketConnected(generation, socket, sessionProtocol),
|
|
346
349
|
rejected: (statusCode) => this.socketRejected(generation, statusCode),
|
|
347
|
-
closed: (code) => this.socketClosed(generation,
|
|
348
|
-
failed: (error) => this.socketFailed(generation,
|
|
350
|
+
closed: (code, reason) => this.socketClosed(generation, code, reason),
|
|
351
|
+
failed: (error) => this.socketFailed(generation, error),
|
|
349
352
|
};
|
|
350
353
|
this.socket = this.options.remote.openSocket({
|
|
351
354
|
daemonId: record.relationship.daemonId,
|
|
@@ -353,12 +356,12 @@ export class HubRelationshipController {
|
|
|
353
356
|
credential: record.credential.secret,
|
|
354
357
|
}, events);
|
|
355
358
|
}
|
|
356
|
-
socketConnected(generation,
|
|
357
|
-
|
|
359
|
+
socketConnected(generation, socket, sessionProtocol) {
|
|
360
|
+
const record = this.record;
|
|
361
|
+
if (generation !== this.generation || record?.state !== "active") {
|
|
358
362
|
socket.close();
|
|
359
363
|
return;
|
|
360
364
|
}
|
|
361
|
-
this.retryAttempt = 0;
|
|
362
365
|
this.state = "connected";
|
|
363
366
|
this.connectedAt = this.clock.now().toISOString();
|
|
364
367
|
this.lastError = null;
|
|
@@ -387,26 +390,34 @@ export class HubRelationshipController {
|
|
|
387
390
|
return;
|
|
388
391
|
this.revoke(`Hub rejected socket authentication (${statusCode})`);
|
|
389
392
|
}
|
|
390
|
-
socketClosed(generation,
|
|
393
|
+
socketClosed(generation, code, reason) {
|
|
391
394
|
if (generation !== this.generation)
|
|
392
395
|
return;
|
|
396
|
+
if (code === 4403 && reason === "daemon session permissions do not match enrollment") {
|
|
397
|
+
this.lastError =
|
|
398
|
+
"Hub and daemon permissions differ. Run `paseo hub permissions grant <permission>` or `paseo hub permissions revoke <permission>` on this daemon to reapply your intended permissions.";
|
|
399
|
+
this.scheduleSocket(true);
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
393
402
|
if (code === 4403) {
|
|
394
403
|
this.revoke("Hub revoked this relationship");
|
|
395
404
|
return;
|
|
396
405
|
}
|
|
397
406
|
if (this.record?.state === "active")
|
|
398
|
-
this.scheduleSocket(
|
|
407
|
+
this.scheduleSocket();
|
|
399
408
|
}
|
|
400
|
-
socketFailed(generation,
|
|
409
|
+
socketFailed(generation, error) {
|
|
401
410
|
if (generation !== this.generation)
|
|
402
411
|
return;
|
|
403
412
|
this.lastError = error.message;
|
|
404
413
|
if (this.record?.state === "active")
|
|
405
|
-
this.scheduleSocket(
|
|
414
|
+
this.scheduleSocket();
|
|
406
415
|
}
|
|
407
|
-
scheduleSocket(
|
|
416
|
+
scheduleSocket(permissionMismatch = false) {
|
|
417
|
+
if (this.state === "connected" && !permissionMismatch)
|
|
418
|
+
this.retryAttempt = 0;
|
|
408
419
|
this.state = "reconnecting";
|
|
409
|
-
this.schedule(() => this.openSocket(
|
|
420
|
+
this.schedule(() => this.openSocket(true));
|
|
410
421
|
}
|
|
411
422
|
scheduleEnrollment(record, enrollmentGeneration) {
|
|
412
423
|
if (enrollmentGeneration !== this.enrollmentGeneration)
|
|
@@ -34,7 +34,7 @@ export interface HubSocketCredentials {
|
|
|
34
34
|
export interface HubSocketEvents {
|
|
35
35
|
connected(socket: WebSocketLike, sessionProtocol: "legacy" | "session-v1"): void;
|
|
36
36
|
rejected(statusCode: 401 | 403): void;
|
|
37
|
-
closed(code: number): void;
|
|
37
|
+
closed(code: number, reason?: string): void;
|
|
38
38
|
failed(error: Error): void;
|
|
39
39
|
}
|
|
40
40
|
export interface HubSocketConnection {
|
|
@@ -160,12 +160,12 @@ export class DirectHubRelationshipRemote {
|
|
|
160
160
|
}
|
|
161
161
|
events.closed(1006);
|
|
162
162
|
});
|
|
163
|
-
socket.once("close", (code) => {
|
|
163
|
+
socket.once("close", (code, reason) => {
|
|
164
164
|
stopHeartbeat();
|
|
165
165
|
if (settled)
|
|
166
166
|
return;
|
|
167
167
|
settled = true;
|
|
168
|
-
events.closed(code);
|
|
168
|
+
events.closed(code, reason.toString());
|
|
169
169
|
});
|
|
170
170
|
socket.once("error", fail);
|
|
171
171
|
return socket;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ForgeService } from "../services/forge-service.js";
|
|
2
2
|
import type { WorktreeSource } from "../utils/worktree.js";
|
|
3
3
|
export type WorktreeCreationIntent = Exclude<WorktreeSource, {
|
|
4
|
-
kind: "restore" | "restore-from-base";
|
|
4
|
+
kind: "restore" | "restore-from-base" | "restore-commit";
|
|
5
5
|
}>;
|
|
6
6
|
export interface ResolveWorktreeCreationIntentInput {
|
|
7
7
|
worktreeSlug?: string;
|
|
@@ -74,13 +74,29 @@ export function createWorkspaceRecoveryService(deps) {
|
|
|
74
74
|
return { workspaceId, action: resolved.kind };
|
|
75
75
|
}
|
|
76
76
|
async function recreateArchivedWorktree(workspace, sourceRepoRoot) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
let source;
|
|
78
|
+
const checkout = parseWorkspaceHead(workspace);
|
|
79
|
+
if (checkout.kind === "branch") {
|
|
80
|
+
source = {
|
|
81
|
+
kind: "restore",
|
|
82
|
+
branchName: checkout.branch,
|
|
83
|
+
baseRef: workspace.baseBranch,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
else if (checkout.kind === "commit") {
|
|
87
|
+
source = {
|
|
88
|
+
kind: "restore-commit",
|
|
89
|
+
commit: checkout.commit,
|
|
90
|
+
baseRef: await resolveRecoveryBase(sourceRepoRoot, workspace.baseBranch),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
source = {
|
|
80
95
|
kind: "restore-from-base",
|
|
81
96
|
branchName: `restored/${randomUUID().slice(0, 8)}`,
|
|
82
97
|
baseRef: await resolveRecoveryBase(sourceRepoRoot, workspace.baseBranch),
|
|
83
98
|
};
|
|
99
|
+
}
|
|
84
100
|
try {
|
|
85
101
|
await runGitCommand(["worktree", "prune"], { cwd: sourceRepoRoot, timeout: 30000 });
|
|
86
102
|
}
|
|
@@ -166,12 +182,22 @@ async function resolveRecoveryBase(repoRoot, recordedBase) {
|
|
|
166
182
|
}
|
|
167
183
|
return defaultBranch;
|
|
168
184
|
}
|
|
185
|
+
function parseWorkspaceHead(workspace) {
|
|
186
|
+
if (workspace.head) {
|
|
187
|
+
const prefix = "refs/heads/";
|
|
188
|
+
return workspace.head.startsWith(prefix)
|
|
189
|
+
? { kind: "branch", branch: workspace.head.slice(prefix.length) }
|
|
190
|
+
: { kind: "commit", commit: workspace.head };
|
|
191
|
+
}
|
|
192
|
+
return workspace.branch ? { kind: "branch", branch: workspace.branch } : { kind: "missing" };
|
|
193
|
+
}
|
|
169
194
|
function createRecoveryPlan(input) {
|
|
195
|
+
const checkout = parseWorkspaceHead(input.workspace);
|
|
170
196
|
const state = {
|
|
171
197
|
kind: "recoverable",
|
|
172
198
|
workspaceId: input.workspace.workspaceId,
|
|
173
199
|
workspaceName: resolveWorkspaceDisplayName(input.workspace),
|
|
174
|
-
branch:
|
|
200
|
+
branch: checkout.kind === "branch" ? checkout.branch : null,
|
|
175
201
|
};
|
|
176
202
|
if (input.action === "restore") {
|
|
177
203
|
return {
|
|
@@ -33,6 +33,7 @@ export declare function createTestRegistries(): {
|
|
|
33
33
|
metadata: Record<string, import("@getpaseo/protocol/agent-types").JsonValue>;
|
|
34
34
|
background: boolean;
|
|
35
35
|
parentWorkspaceId?: string | undefined;
|
|
36
|
+
head?: string | undefined;
|
|
36
37
|
labels?: string[] | undefined;
|
|
37
38
|
untrustedSource?: {
|
|
38
39
|
kind: "change_request";
|
|
@@ -227,6 +227,11 @@ export declare class VoiceAssistantWebSocketServer {
|
|
|
227
227
|
private broadcastAgentAttention;
|
|
228
228
|
private broadcastTerminalAttention;
|
|
229
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* Whether a page at `origin` may talk to the daemon reached at `requestHost`. The WebSocket
|
|
232
|
+
* upgrade and the HTTP CORS check both use it, so a page that can connect can also fetch.
|
|
233
|
+
*/
|
|
234
|
+
export declare function isDaemonOriginAllowed(origin: string, requestHost: string | null, allowedOrigins: Set<string>): boolean;
|
|
230
235
|
export declare function isWebSocketSameOrigin(origin: string | undefined, requestHost: string | null): boolean;
|
|
231
236
|
export {};
|
|
232
237
|
//# sourceMappingURL=websocket-server.d.ts.map
|
|
@@ -562,8 +562,7 @@ export class VoiceAssistantWebSocketServer {
|
|
|
562
562
|
callback(false, 403, "Host not allowed");
|
|
563
563
|
return;
|
|
564
564
|
}
|
|
565
|
-
|
|
566
|
-
if (!origin || allowedOrigins.has("*") || allowedOrigins.has(origin) || sameOrigin) {
|
|
565
|
+
if (!origin || isDaemonOriginAllowed(origin, requestHost, allowedOrigins)) {
|
|
567
566
|
callback(true);
|
|
568
567
|
}
|
|
569
568
|
else {
|
|
@@ -2426,6 +2425,15 @@ function isLoopbackAlias(hostname) {
|
|
|
2426
2425
|
}
|
|
2427
2426
|
return /^127(?:\.\d{1,3}){3}$/.test(normalized);
|
|
2428
2427
|
}
|
|
2428
|
+
/**
|
|
2429
|
+
* Whether a page at `origin` may talk to the daemon reached at `requestHost`. The WebSocket
|
|
2430
|
+
* upgrade and the HTTP CORS check both use it, so a page that can connect can also fetch.
|
|
2431
|
+
*/
|
|
2432
|
+
export function isDaemonOriginAllowed(origin, requestHost, allowedOrigins) {
|
|
2433
|
+
return (allowedOrigins.has("*") ||
|
|
2434
|
+
allowedOrigins.has(origin) ||
|
|
2435
|
+
isWebSocketSameOrigin(origin, requestHost));
|
|
2436
|
+
}
|
|
2429
2437
|
export function isWebSocketSameOrigin(origin, requestHost) {
|
|
2430
2438
|
if (!origin || !requestHost) {
|
|
2431
2439
|
return false;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
|
-
import { deletePaseoWorktree, isPaseoOwnedWorktreeCwd, runWorktreeTeardownCommands, WorktreeTeardownError, } from "../utils/worktree.js";
|
|
2
|
+
import { deletePaseoWorktree, readWorktreeHeadReference, isPaseoOwnedWorktreeCwd, runWorktreeTeardownCommands, WorktreeTeardownError, } from "../utils/worktree.js";
|
|
3
3
|
import { createRealpathAwarePathMatcher } from "../utils/path.js";
|
|
4
4
|
import { runWithGitCommandPriority } from "../utils/run-git-command.js";
|
|
5
5
|
import { WorkspaceAutomationBlockedError } from "./workspace-automation-gate.js";
|
|
@@ -418,7 +418,15 @@ export async function archivePersistedWorkspaceRecord(input) {
|
|
|
418
418
|
return existingWorkspace;
|
|
419
419
|
}
|
|
420
420
|
const archivedAt = input.archivedAt ?? new Date().toISOString();
|
|
421
|
-
|
|
421
|
+
let head = null;
|
|
422
|
+
if (existingWorkspace.kind === "worktree") {
|
|
423
|
+
const cwd = existingWorkspace.worktreeRoot ?? existingWorkspace.cwd;
|
|
424
|
+
head = await readWorktreeHeadReference(cwd);
|
|
425
|
+
}
|
|
426
|
+
await input.workspaceRegistry.archive(input.workspaceId, archivedAt, {
|
|
427
|
+
...input.context,
|
|
428
|
+
...(head ? { head } : {}),
|
|
429
|
+
});
|
|
422
430
|
return existingWorkspace;
|
|
423
431
|
}
|
|
424
432
|
export async function unarchiveWorkspaceAgents(input) {
|
|
@@ -323,6 +323,7 @@ export declare class WorkspaceGitServiceImpl implements WorkspaceGitService {
|
|
|
323
323
|
* rule.
|
|
324
324
|
*/
|
|
325
325
|
private advanceWatchRecoveryLadder;
|
|
326
|
+
private noteWatchSetupFailure;
|
|
326
327
|
private scheduleWorkingTreeWatchRecovery;
|
|
327
328
|
private recoverWorkingTreeWatch;
|
|
328
329
|
private promoteWorkingTreeWatchTarget;
|