paseo-plugin-zcode-provider 0.4.4 → 0.5.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/NOTICE.md +2 -2
- package/README.md +18 -13
- package/client/account.tsx +13 -22
- package/client/goal-pills.ts +252 -0
- package/client/goal.tsx +203 -0
- package/index.client.tsx +4 -0
- package/index.server.ts +12 -4
- package/package.json +4 -4
- package/paseo-plugin.json +1 -1
- package/server/build-info.ts +1 -1
- package/server/diagnostics.ts +4 -1
- package/server/discovery/manifest.ts +2 -2
- package/server/errors.ts +1 -0
- package/server/goal-command.ts +32 -0
- package/server/goal.ts +58 -0
- package/server/host/bridge.ts +3 -0
- package/server/mapping.ts +23 -6
- package/server/presentation.ts +4 -1
- package/server/provider-status.ts +3 -3
- package/server/provider.ts +91 -21
- package/server/runtime/pins.ts +3 -3
- package/server/session.ts +278 -92
- package/server/turn-failure.ts +6 -1
- package/server/usage.ts +1 -3
- package/server/vendor/zcode/NOTICE.md +1 -1
- package/server/vendor/zcode/packages/rpc/src/channelClient.ts +18 -3
- package/server/vendor/zcode/packages/rpc/src/channelServer.ts +32 -12
- package/server/vendor/zcode/packages/rpc/src/channels.shared.ts +8 -1
- package/server/vendor/zcode/packages/rpc/src/serialization.ts +9 -3
- package/server/vendor/zcode/packages/shared/src/browser-use/command-metadata.ts +2 -0
- package/server/vendor/zcode/packages/shared/src/browser-use/commands.ts +2 -0
- package/server/vendor/zcode/packages/shared/src/browser-use/result.ts +4 -0
- package/server/vendor/zcode/packages/shared/src/gen-ui/contract.ts +246 -0
- package/server/vendor/zcode/packages/shared/src/gen-ui/tweakProtocol.ts +143 -0
- package/server/vendor/zcode/packages/shared/src/{localTtft.ts → local-ttft/contract.ts} +56 -1
- package/server/vendor/zcode/packages/shared/src/mcp-apps/contract.ts +8 -0
- package/server/vendor/zcode/packages/shared/src/official-mcp-auth.ts +8 -0
- package/server/vendor/zcode/packages/shared/src/protocol.ts +2 -0
- package/server/vendor/zcode/packages/shared/src/request-security-edition/verification-policy.ts +9 -1
- package/server/vendor/zcode/packages/shared/src/runtimeEnv.ts +10 -0
- package/server/vendor/zcode/packages/shared/src/server-remote.ts +2 -0
- package/server/vendor/zcode/packages/shared/src/source-server/compatibility.ts +11 -0
- package/server/vendor/zcode/packages/shared/src/source-server/contracts.ts +21 -1
- package/server/vendor/zcode/packages/shared/src/source-server/errorCodes.ts +27 -9
- package/server/vendor/zcode/packages/shared/src/subagent-profile.ts +5 -0
- package/server/vendor/zcode/packages/shared/src/validationAppSettings.ts +1 -0
- package/server/vendor/zcode/packages/shared/src/zcode-protocol/index.ts +164 -11
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-legacy-types.ts +1 -0
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/apply.ts +4 -2
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/command.ts +11 -7
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/delta.ts +2 -0
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/input-intent.ts +2 -0
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/rows.ts +19 -1
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/snapshot.ts +11 -0
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/transport.ts +20 -1
- package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/workflow-row-meta.ts +8 -0
- package/server/vendor/zcode/packages/ui/src/v4/conversationGoalSummaryModel.ts +88 -0
- package/server/vendor/zcode/provenance.json +78 -64
- package/shared/goal.ts +89 -0
package/index.client.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { PluginClientContext } from "@getpaseo/plugin/client";
|
|
2
2
|
import { DiagnosticsScreen } from "./client/diagnostics";
|
|
3
|
+
import { GoalPopover } from "./client/goal";
|
|
4
|
+
import { followGoals } from "./client/goal-pills";
|
|
3
5
|
import { SettingsScreen } from "./client/settings";
|
|
4
6
|
|
|
5
7
|
export default function contribute(client: PluginClientContext): () => void {
|
|
@@ -15,8 +17,10 @@ export default function contribute(client: PluginClientContext): () => void {
|
|
|
15
17
|
icon: "Activity",
|
|
16
18
|
Component: DiagnosticsScreen,
|
|
17
19
|
});
|
|
20
|
+
const stopGoals = followGoals(client, GoalPopover);
|
|
18
21
|
return () => {
|
|
19
22
|
removeSettings();
|
|
20
23
|
removeDiagnostics();
|
|
24
|
+
stopGoals();
|
|
21
25
|
};
|
|
22
26
|
}
|
package/index.server.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { homedir } from "node:os";
|
|
2
2
|
import type { PluginServerContext } from "@getpaseo/plugin/server";
|
|
3
3
|
import { AccountService } from "./server/account.js";
|
|
4
|
+
import { GoalDirectory } from "./server/goal.js";
|
|
4
5
|
import { createHost, createZCodeProvider } from "./server/provider.js";
|
|
5
6
|
import { ManagedRuntimeInstaller } from "./server/runtime/managed.js";
|
|
6
7
|
import { createRuntimeSetupHandlers } from "./server/runtime-setup.js";
|
|
@@ -9,6 +10,7 @@ import { followTimelineSettings } from "./server/timeline-settings.js";
|
|
|
9
10
|
import { createUsageSource } from "./server/usage.js";
|
|
10
11
|
import { zcodeAccountChange, zcodeAccountView } from "./shared/account.js";
|
|
11
12
|
import { zcodeDiagnostics } from "./shared/diagnostics.js";
|
|
13
|
+
import { zcodeGoals } from "./shared/goal.js";
|
|
12
14
|
import {
|
|
13
15
|
zcodeRuntimeInstall,
|
|
14
16
|
zcodeRuntimeRemove,
|
|
@@ -20,9 +22,17 @@ export default function contribute(server: PluginServerContext): () => void {
|
|
|
20
22
|
const timeline = followTimelineSettings(
|
|
21
23
|
server.registerSettings(zcodeTimelineSettings),
|
|
22
24
|
);
|
|
25
|
+
const goals = new GoalDirectory();
|
|
23
26
|
server.registerProvider(
|
|
24
|
-
createZCodeProvider(
|
|
27
|
+
createZCodeProvider(
|
|
28
|
+
undefined,
|
|
29
|
+
undefined,
|
|
30
|
+
undefined,
|
|
31
|
+
timeline.current,
|
|
32
|
+
goals,
|
|
33
|
+
),
|
|
25
34
|
);
|
|
35
|
+
server.handle(zcodeGoals, () => ({ goals: goals.views() }));
|
|
26
36
|
server.handle(zcodeDiagnostics, createDiagnosticsHandler());
|
|
27
37
|
const setup = createRuntimeSetupHandlers(new ManagedRuntimeInstaller());
|
|
28
38
|
server.handle(zcodeRuntimeStatus, setup.status);
|
|
@@ -34,10 +44,8 @@ export default function contribute(server: PluginServerContext): () => void {
|
|
|
34
44
|
);
|
|
35
45
|
server.handle(zcodeAccountView, () => account.view());
|
|
36
46
|
server.handle(zcodeAccountChange, (input) => account.change(input));
|
|
37
|
-
// Usage sources arrived in Paseo 0.11; older daemons do not offer them.
|
|
38
47
|
const usage = createUsageSource(account);
|
|
39
|
-
|
|
40
|
-
server.registerUsageSource(usage.source);
|
|
48
|
+
server.registerUsageSource(usage.source);
|
|
41
49
|
return () => {
|
|
42
50
|
usage.dispose();
|
|
43
51
|
timeline.dispose();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paseo-plugin-zcode-provider",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Unofficial Paseo provider plugin for ZCode, using the official stdio Services Server of the integrated ZCode CLI.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"paseo",
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"semver": "7.8.5"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@getpaseo/client": "0.
|
|
64
|
-
"@getpaseo/plugin": "0.
|
|
65
|
-
"@getpaseo/protocol": "0.
|
|
63
|
+
"@getpaseo/client": "0.15.3",
|
|
64
|
+
"@getpaseo/plugin": "0.15.3",
|
|
65
|
+
"@getpaseo/protocol": "0.15.3",
|
|
66
66
|
"@types/node": "22.18.3",
|
|
67
67
|
"@types/react": "~19.2.0",
|
|
68
68
|
"@types/semver": "7.8.0",
|
package/paseo-plugin.json
CHANGED
package/server/build-info.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated from package.json by npm prepare / prebuild.
|
|
2
|
-
export const PROVIDER_VERSION = "0.
|
|
2
|
+
export const PROVIDER_VERSION = "0.5.1";
|
package/server/diagnostics.ts
CHANGED
|
@@ -17,8 +17,11 @@ const stages = [
|
|
|
17
17
|
"session",
|
|
18
18
|
"turn",
|
|
19
19
|
] as const;
|
|
20
|
-
// ZCode's ModelFailureReason (apps/zcode-cli/packages/contracts/src/model/index.ts at
|
|
20
|
+
// ZCode's ModelFailureReason (apps/zcode-cli/packages/contracts/src/model/index.ts at
|
|
21
|
+
// a9fe401), plus content_filter, which 3.17 sets outside that list for a reply
|
|
22
|
+
// the provider's content filter blocked (core/src/runtime/helpers/model-errors.ts).
|
|
21
23
|
export const modelFailureReasons = [
|
|
24
|
+
"content_filter",
|
|
22
25
|
"rate_limited",
|
|
23
26
|
"provider_overloaded",
|
|
24
27
|
"server_error",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { gte, parse } from "semver";
|
|
2
2
|
import type { RuntimeIdentity } from "./types.js";
|
|
3
3
|
|
|
4
|
-
export const ZCODE_SOURCE_COMMIT = "
|
|
4
|
+
export const ZCODE_SOURCE_COMMIT = "a9fe401eede6e6e5e01be9048679c206fe6f02d9";
|
|
5
5
|
export const MINIMUM_ZCODE_VERSION = { app: "3.14.0", cli: "0.16.9" } as const;
|
|
6
6
|
export const MINIMUM_NODE_VERSION = "24.14.0";
|
|
7
7
|
|
|
@@ -33,4 +33,4 @@ export function assessCompatibility(identity: RuntimeIdentity): {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// Last reviewed public changelog release; source versions are not releases.
|
|
36
|
-
export const LAST_REVIEWED_ZCODE_RELEASE = "3.
|
|
36
|
+
export const LAST_REVIEWED_ZCODE_RELEASE = "3.17.2";
|
package/server/errors.ts
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// `/goal` and its alias `/target`. The Server's text input does not interpret
|
|
2
|
+
// them: ZCode Desktop reads the command itself and sends a V4 goal command
|
|
3
|
+
// (packages/ui/src/v4/slashCommands.ts at a9fe401). The first word decides, as
|
|
4
|
+
// there and in ZCode's terminal UI, so an objective cannot begin with one of
|
|
5
|
+
// the action words.
|
|
6
|
+
export type GoalCommand =
|
|
7
|
+
/** `/goal <objective>` and `/goal replace <objective>`: both replace a goal. */
|
|
8
|
+
| { kind: "set"; objective: string; displayText: string }
|
|
9
|
+
| { kind: "resume" }
|
|
10
|
+
/** A button in Desktop; here the command, as in the terminal UI. */
|
|
11
|
+
| { kind: "pause" }
|
|
12
|
+
/** `clear` and `show` have no V4 command. */
|
|
13
|
+
| { kind: "unsupported"; action: string }
|
|
14
|
+
| { kind: "empty" };
|
|
15
|
+
|
|
16
|
+
export function parseGoalCommand(text: string): GoalCommand | undefined {
|
|
17
|
+
const displayText = text.trim();
|
|
18
|
+
const match = /^\/([^\s]+)(?:\s+([\s\S]*))?$/.exec(displayText);
|
|
19
|
+
const name = match?.[1]?.toLowerCase();
|
|
20
|
+
if (name !== "goal" && name !== "target") return undefined;
|
|
21
|
+
const args = match?.[2]?.trim() ?? "";
|
|
22
|
+
if (!args) return { kind: "empty" };
|
|
23
|
+
const action = args.split(/\s+/, 1)[0]!.toLowerCase();
|
|
24
|
+
if (action === "resume" || action === "pause") return { kind: action };
|
|
25
|
+
if (action === "clear" || action === "show")
|
|
26
|
+
return { kind: "unsupported", action };
|
|
27
|
+
const objective =
|
|
28
|
+
action === "replace" ? args.replace(/^replace\s*/i, "").trim() : args;
|
|
29
|
+
return objective
|
|
30
|
+
? { kind: "set", objective, displayText }
|
|
31
|
+
: { kind: "empty" };
|
|
32
|
+
}
|
package/server/goal.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { GoalState } from "./vendor/zcode/packages/shared/src/zcode-protocol-v4/snapshot.js";
|
|
2
|
+
import {
|
|
3
|
+
buildConversationGoalIterationSummaries,
|
|
4
|
+
getConversationGoalElapsedSeconds,
|
|
5
|
+
} from "./vendor/zcode/packages/ui/src/v4/conversationGoalSummaryModel.js";
|
|
6
|
+
import type { GoalView } from "../shared/goal.js";
|
|
7
|
+
|
|
8
|
+
/** The goal as ZCode Desktop's status panel lays it out. */
|
|
9
|
+
export function goalView(
|
|
10
|
+
agentId: string,
|
|
11
|
+
goal: GoalState,
|
|
12
|
+
now: number,
|
|
13
|
+
): GoalView {
|
|
14
|
+
const inProgress =
|
|
15
|
+
goal.status === "active" ||
|
|
16
|
+
goal.status === "verifying" ||
|
|
17
|
+
goal.status === "notSatisfied";
|
|
18
|
+
return {
|
|
19
|
+
agentId,
|
|
20
|
+
status: goal.status,
|
|
21
|
+
// The daemon's clock and ZCode's are the same host's; a client's is not.
|
|
22
|
+
elapsedSeconds: getConversationGoalElapsedSeconds(goal, now),
|
|
23
|
+
running: inProgress && goal.activeRunStartedAtMs != null,
|
|
24
|
+
iterations: buildConversationGoalIterationSummaries(goal).map((row) => ({
|
|
25
|
+
iteration: row.iteration,
|
|
26
|
+
title: row.title,
|
|
27
|
+
completedCount: row.completedCount,
|
|
28
|
+
totalCount: row.totalCount,
|
|
29
|
+
completed: row.completed,
|
|
30
|
+
})),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The open sessions by Paseo agent. A provider session ID is Paseo's own and
|
|
36
|
+
* changes on every open, so clients name the agent instead (ADR 27).
|
|
37
|
+
*/
|
|
38
|
+
export class GoalDirectory {
|
|
39
|
+
private readonly sessions = new Map<string, () => GoalState | null>();
|
|
40
|
+
|
|
41
|
+
/** Returns the function that removes the session again. */
|
|
42
|
+
register(agentId: string, read: () => GoalState | null): () => void {
|
|
43
|
+
this.sessions.set(agentId, read);
|
|
44
|
+
return () => {
|
|
45
|
+
// Paseo can open an agent's next session before closing the previous one.
|
|
46
|
+
if (this.sessions.get(agentId) === read) this.sessions.delete(agentId);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
views(now = Date.now()): GoalView[] {
|
|
51
|
+
const views: GoalView[] = [];
|
|
52
|
+
for (const [agentId, read] of this.sessions) {
|
|
53
|
+
const goal = read();
|
|
54
|
+
if (goal) views.push(goalView(agentId, goal, now));
|
|
55
|
+
}
|
|
56
|
+
return views;
|
|
57
|
+
}
|
|
58
|
+
}
|
package/server/host/bridge.ts
CHANGED
|
@@ -144,6 +144,9 @@ export class ZCodeHostBridge implements HostBridge {
|
|
|
144
144
|
env: {
|
|
145
145
|
...runtimeEnvironment(environment),
|
|
146
146
|
...UNSUPPORTED_CAPABILITY_ENVIRONMENT,
|
|
147
|
+
// The Agent inherits this and reports it in model request headers, or
|
|
148
|
+
// its CLI version without it. Desktop and the remote Core set it too.
|
|
149
|
+
ZCODE_APP_VERSION: runtime.identity.appVersion,
|
|
147
150
|
ZCODE_SERVICE_AUTHORITY_MODE: "standalone-server",
|
|
148
151
|
ZCODE_AGENT_SERVER_COMMAND: runtime.paths.executable,
|
|
149
152
|
ZCODE_AGENT_SERVER_ARGS_JSON: JSON.stringify([
|
package/server/mapping.ts
CHANGED
|
@@ -38,13 +38,22 @@ export const ZCODE_MODES: ProviderMode[] = [
|
|
|
38
38
|
// ZCode 3.15.1 added guarded ("Autonomous mode"); older Servers reject it.
|
|
39
39
|
const GUARDED_MINIMUM_APP_VERSION = "3.15.1";
|
|
40
40
|
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
// ZCode 3.17.1 added the MCP server `scope`; older Servers reject it.
|
|
42
|
+
const MCP_SCOPE_MINIMUM_APP_VERSION = "3.17.1";
|
|
43
|
+
|
|
44
|
+
function atLeast(appVersion: string | undefined, minimum: string): boolean {
|
|
45
|
+
return (
|
|
44
46
|
appVersion !== undefined &&
|
|
45
47
|
valid(appVersion) !== null &&
|
|
46
|
-
gte(appVersion,
|
|
47
|
-
|
|
48
|
+
gte(appVersion, minimum)
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// The modes the runtime with this Server version supports.
|
|
53
|
+
export function zcodeModes(appVersion: string | undefined): ProviderMode[] {
|
|
54
|
+
return atLeast(appVersion, GUARDED_MINIMUM_APP_VERSION)
|
|
55
|
+
? ZCODE_MODES
|
|
56
|
+
: ZCODE_MODES.filter((m) => m.id !== "guarded");
|
|
48
57
|
}
|
|
49
58
|
|
|
50
59
|
export function requireConfigurableMode(
|
|
@@ -151,7 +160,14 @@ export function catalogModels(
|
|
|
151
160
|
|
|
152
161
|
export function mapMcpServers(
|
|
153
162
|
servers: Record<string, ProviderMcpServerConfig> | undefined,
|
|
163
|
+
appVersion: string | undefined,
|
|
154
164
|
): Array<Record<string, unknown>> {
|
|
165
|
+
// Paseo's servers are not project declarations. Without a scope, ZCode
|
|
166
|
+
// treats them as such when the project declares the same name or its
|
|
167
|
+
// configuration is unreadable, and blocks them until the project is trusted.
|
|
168
|
+
const scope = atLeast(appVersion, MCP_SCOPE_MINIMUM_APP_VERSION)
|
|
169
|
+
? { scope: "user" }
|
|
170
|
+
: {};
|
|
155
171
|
return Object.entries(servers ?? {}).map(([name, server]) => {
|
|
156
172
|
if (name.trim() === "") {
|
|
157
173
|
throw new AdapterError(
|
|
@@ -174,6 +190,7 @@ export function mapMcpServers(
|
|
|
174
190
|
}
|
|
175
191
|
return {
|
|
176
192
|
name,
|
|
193
|
+
...scope,
|
|
177
194
|
command: server.command,
|
|
178
195
|
args: server.args ?? [],
|
|
179
196
|
env: Object.entries(server.env ?? {}).map(([key, value]) => ({
|
|
@@ -189,7 +206,7 @@ export function mapMcpServers(
|
|
|
189
206
|
}),
|
|
190
207
|
);
|
|
191
208
|
if (server.type === "http" || server.type === "sse") {
|
|
192
|
-
return { type: server.type, name, url: server.url, headers };
|
|
209
|
+
return { type: server.type, name, ...scope, url: server.url, headers };
|
|
193
210
|
}
|
|
194
211
|
throw new AdapterError(
|
|
195
212
|
"INVALID_CONFIGURATION",
|
package/server/presentation.ts
CHANGED
|
@@ -165,7 +165,10 @@ export function rowTimeline(
|
|
|
165
165
|
case "timelineMarker":
|
|
166
166
|
// Paseo appends every notification it receives, so a changing row is
|
|
167
167
|
// reported once, in its final state.
|
|
168
|
-
if (
|
|
168
|
+
if (
|
|
169
|
+
(row.marker.type === "compact" && row.marker.status === "running") ||
|
|
170
|
+
(row.marker.type === "goalVerify" && row.marker.outcome === "running")
|
|
171
|
+
)
|
|
169
172
|
return;
|
|
170
173
|
return {
|
|
171
174
|
id,
|
|
@@ -62,9 +62,9 @@ async function check(
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* Availability for Paseo's provider snapshot and diagnostics
|
|
66
|
-
*
|
|
67
|
-
*
|
|
65
|
+
* Availability for Paseo's provider snapshot and diagnostics. It inspects the
|
|
66
|
+
* runtime without starting a Server, so sign-in problems still surface when a
|
|
67
|
+
* session opens.
|
|
68
68
|
*/
|
|
69
69
|
export function createRuntimeStatus(options: RuntimeStatusOptions = {}) {
|
|
70
70
|
const environment = options.environment ?? process.env;
|
package/server/provider.ts
CHANGED
|
@@ -51,6 +51,8 @@ import {
|
|
|
51
51
|
} from "./session.js";
|
|
52
52
|
import { SessionSnapshotSchema, SessionListSchema } from "./host/schemas.js";
|
|
53
53
|
import { TimelineSnapshots } from "./timeline.js";
|
|
54
|
+
import { GoalDirectory } from "./goal.js";
|
|
55
|
+
import { parseGoalCommand } from "./goal-command.js";
|
|
54
56
|
import type { NativeSessionEvent } from "./session-types.js";
|
|
55
57
|
import {
|
|
56
58
|
defaultTimelinePreferences,
|
|
@@ -62,6 +64,7 @@ export const CAPABILITIES = [
|
|
|
62
64
|
"prompt.command",
|
|
63
65
|
"prompt.image",
|
|
64
66
|
"prompt.steer",
|
|
67
|
+
"session.can_stop_runtime",
|
|
65
68
|
"session.configure",
|
|
66
69
|
"session.list",
|
|
67
70
|
"session.persistence",
|
|
@@ -115,6 +118,8 @@ interface SessionEntry {
|
|
|
115
118
|
messages: Map<string, boolean>;
|
|
116
119
|
inputGeneration: number;
|
|
117
120
|
queue: Promise<void>;
|
|
121
|
+
/** Removes the session from the goal directory. */
|
|
122
|
+
forgetGoal: () => void;
|
|
118
123
|
}
|
|
119
124
|
|
|
120
125
|
export function createZCodeProvider(
|
|
@@ -122,6 +127,7 @@ export function createZCodeProvider(
|
|
|
122
127
|
persistenceStore = new SessionPersistenceStore(),
|
|
123
128
|
status: ProviderRegistration["status"] = createRuntimeStatus(),
|
|
124
129
|
timeline: () => TimelinePreferences = () => defaultTimelinePreferences,
|
|
130
|
+
goals = new GoalDirectory(),
|
|
125
131
|
): ProviderRegistration {
|
|
126
132
|
return {
|
|
127
133
|
id: "zcode",
|
|
@@ -140,6 +146,7 @@ export function createZCodeProvider(
|
|
|
140
146
|
bridgeFactory,
|
|
141
147
|
persistenceStore,
|
|
142
148
|
timeline,
|
|
149
|
+
goals,
|
|
143
150
|
);
|
|
144
151
|
},
|
|
145
152
|
};
|
|
@@ -161,6 +168,7 @@ export class ZCodeConnection implements ProviderConnection {
|
|
|
161
168
|
private readonly bridgeFactory: BridgeFactory,
|
|
162
169
|
private readonly persistenceStore: SessionPersistenceStore,
|
|
163
170
|
private readonly timeline: () => TimelinePreferences,
|
|
171
|
+
private readonly goals = new GoalDirectory(),
|
|
164
172
|
) {}
|
|
165
173
|
|
|
166
174
|
onEvent(listener: (event: ProviderEvent) => void): () => void {
|
|
@@ -417,6 +425,25 @@ export class ZCodeConnection implements ProviderConnection {
|
|
|
417
425
|
? prompt.arguments.trim()
|
|
418
426
|
: (text?.match(/^\/plan(?:\s+([\s\S]*))?$/)?.[1]?.trim() ??
|
|
419
427
|
(text === "/plan" ? "" : undefined));
|
|
428
|
+
// The command ran without a turn.
|
|
429
|
+
const completed = () => {
|
|
430
|
+
entry.messages.set(input.prompt.clientMessageId, true);
|
|
431
|
+
this.emit({
|
|
432
|
+
type: "session.prompt_result",
|
|
433
|
+
sessionId: input.sessionId,
|
|
434
|
+
clientMessageId: input.prompt.clientMessageId,
|
|
435
|
+
result: { type: "completed" },
|
|
436
|
+
});
|
|
437
|
+
};
|
|
438
|
+
const beforeSend = async () => {
|
|
439
|
+
if (!entry.submitted) {
|
|
440
|
+
await this.persistenceStore.save(
|
|
441
|
+
entry.persistence,
|
|
442
|
+
entry.native.id,
|
|
443
|
+
);
|
|
444
|
+
entry.submitted = true;
|
|
445
|
+
}
|
|
446
|
+
};
|
|
420
447
|
if (planTask !== undefined) {
|
|
421
448
|
if (prompt.type === "message" && prompt.content.length !== 1)
|
|
422
449
|
throw new AdapterError(
|
|
@@ -425,34 +452,51 @@ export class ZCodeConnection implements ProviderConnection {
|
|
|
425
452
|
);
|
|
426
453
|
await entry.native.configureMode(undefined, true);
|
|
427
454
|
if (!planTask) {
|
|
428
|
-
|
|
429
|
-
this.emit({
|
|
430
|
-
type: "session.prompt_result",
|
|
431
|
-
sessionId: input.sessionId,
|
|
432
|
-
clientMessageId: input.prompt.clientMessageId,
|
|
433
|
-
result: { type: "completed" },
|
|
434
|
-
});
|
|
455
|
+
completed();
|
|
435
456
|
return;
|
|
436
457
|
}
|
|
437
458
|
}
|
|
459
|
+
const command =
|
|
460
|
+
prompt.type === "command"
|
|
461
|
+
? `/${prompt.name}${prompt.arguments ? ` ${prompt.arguments}` : ""}`
|
|
462
|
+
: undefined;
|
|
463
|
+
// Like /plan, /goal is not text to the Server: ZCode Desktop sends the
|
|
464
|
+
// V4 goal commands for it (ADR 27).
|
|
465
|
+
const goalText =
|
|
466
|
+
command ??
|
|
467
|
+
(prompt.type === "message" && prompt.content.length === 1
|
|
468
|
+
? text
|
|
469
|
+
: undefined);
|
|
470
|
+
const goal =
|
|
471
|
+
planTask === undefined && goalText !== undefined
|
|
472
|
+
? parseGoalCommand(goalText)
|
|
473
|
+
: undefined;
|
|
474
|
+
if (goal?.kind === "empty" || goal?.kind === "unsupported")
|
|
475
|
+
throw new AdapterError(
|
|
476
|
+
"INVALID_CONFIGURATION",
|
|
477
|
+
goal.kind === "empty"
|
|
478
|
+
? "Usage: /goal <objective>, /goal pause or /goal resume"
|
|
479
|
+
: `ZCode's Server has no /goal ${goal.action}. Use /goal <objective> to replace the goal, or /goal pause.`,
|
|
480
|
+
);
|
|
481
|
+
if (goal?.kind === "pause") {
|
|
482
|
+
await entry.native.pauseGoal();
|
|
483
|
+
completed();
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
if (goal) {
|
|
487
|
+
await entry.native.startGoal(goal, {
|
|
488
|
+
clientMessageId: input.prompt.clientMessageId,
|
|
489
|
+
beforeSend,
|
|
490
|
+
});
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
438
493
|
await entry.native.startTurn(
|
|
439
|
-
planTask ??
|
|
440
|
-
(prompt.type === "command"
|
|
441
|
-
? `/${prompt.name}${prompt.arguments ? ` ${prompt.arguments}` : ""}`
|
|
442
|
-
: prompt.content),
|
|
494
|
+
planTask ?? (prompt.type === "command" ? command! : prompt.content),
|
|
443
495
|
{
|
|
444
496
|
clientMessageId: input.prompt.clientMessageId,
|
|
445
497
|
delivery: input.prompt.delivery,
|
|
446
498
|
clearPendingPermissions: input.prompt.clearPendingPermissions,
|
|
447
|
-
beforeSend
|
|
448
|
-
if (!entry.submitted) {
|
|
449
|
-
await this.persistenceStore.save(
|
|
450
|
-
entry.persistence,
|
|
451
|
-
entry.native.id,
|
|
452
|
-
);
|
|
453
|
-
entry.submitted = true;
|
|
454
|
-
}
|
|
455
|
-
},
|
|
499
|
+
beforeSend,
|
|
456
500
|
},
|
|
457
501
|
);
|
|
458
502
|
return;
|
|
@@ -478,6 +522,15 @@ export class ZCodeConnection implements ProviderConnection {
|
|
|
478
522
|
case "session.interrupt":
|
|
479
523
|
await entry.native.interrupt();
|
|
480
524
|
break;
|
|
525
|
+
// Paseo asks before releasing an idle runtime; the answer is the reply.
|
|
526
|
+
case "session.can_stop_runtime":
|
|
527
|
+
this.emit({
|
|
528
|
+
type: "session.can_stop_runtime",
|
|
529
|
+
requestId: input.requestId,
|
|
530
|
+
sessionId: input.sessionId,
|
|
531
|
+
canStop: entry.native.canStopRuntime(),
|
|
532
|
+
});
|
|
533
|
+
return;
|
|
481
534
|
case "session.permission":
|
|
482
535
|
await entry.native.respondToPermission(
|
|
483
536
|
input.permissionId,
|
|
@@ -521,6 +574,7 @@ export class ZCodeConnection implements ProviderConnection {
|
|
|
521
574
|
const nativeId = await this.persistenceStore.resolve(persistence);
|
|
522
575
|
const host = await this.host(config.env, cwd);
|
|
523
576
|
let native: ZCodeSession | undefined;
|
|
577
|
+
let forgetGoal = () => {};
|
|
524
578
|
try {
|
|
525
579
|
const { selection } = await initializeWorkspace(host, cwd);
|
|
526
580
|
const requested = nativeId
|
|
@@ -553,7 +607,10 @@ export class ZCodeConnection implements ProviderConnection {
|
|
|
553
607
|
}
|
|
554
608
|
: {}),
|
|
555
609
|
}),
|
|
556
|
-
mcpServers: mapMcpServers(
|
|
610
|
+
mcpServers: mapMcpServers(
|
|
611
|
+
config.mcpServers,
|
|
612
|
+
host.diagnostic.appVersion,
|
|
613
|
+
),
|
|
557
614
|
},
|
|
558
615
|
SessionSnapshotSchema,
|
|
559
616
|
60000,
|
|
@@ -568,6 +625,8 @@ export class ZCodeConnection implements ProviderConnection {
|
|
|
568
625
|
modelCatalog: selection.models,
|
|
569
626
|
timeline: this.timeline,
|
|
570
627
|
onClose() {},
|
|
628
|
+
// A non-empty list replaces ZCode's MCP configuration files.
|
|
629
|
+
projectMcpServers: Object.keys(config.mcpServers ?? {}).length === 0,
|
|
571
630
|
});
|
|
572
631
|
if (
|
|
573
632
|
initialModel &&
|
|
@@ -606,8 +665,17 @@ export class ZCodeConnection implements ProviderConnection {
|
|
|
606
665
|
messages: new Map(),
|
|
607
666
|
inputGeneration: 0,
|
|
608
667
|
queue: Promise.resolve(),
|
|
668
|
+
forgetGoal() {},
|
|
609
669
|
};
|
|
610
670
|
this.sessions.set(input.sessionId, entry);
|
|
671
|
+
// Paseo sets PASEO_AGENT_ID in the launch environment of every session.
|
|
672
|
+
const agentId = config.env.PASEO_AGENT_ID;
|
|
673
|
+
if (agentId) {
|
|
674
|
+
const session = native;
|
|
675
|
+
forgetGoal = entry.forgetGoal = this.goals.register(agentId, () =>
|
|
676
|
+
session.goal(),
|
|
677
|
+
);
|
|
678
|
+
}
|
|
611
679
|
this.emit({
|
|
612
680
|
type: "session.opened",
|
|
613
681
|
requestId: input.requestId,
|
|
@@ -651,6 +719,7 @@ export class ZCodeConnection implements ProviderConnection {
|
|
|
651
719
|
});
|
|
652
720
|
} catch (error) {
|
|
653
721
|
this.sessions.delete(input.sessionId);
|
|
722
|
+
forgetGoal();
|
|
654
723
|
try {
|
|
655
724
|
await native?.close();
|
|
656
725
|
} finally {
|
|
@@ -787,6 +856,7 @@ export class ZCodeConnection implements ProviderConnection {
|
|
|
787
856
|
private async closeSession(id: string): Promise<void> {
|
|
788
857
|
const entry = this.requireSession(id);
|
|
789
858
|
this.sessions.delete(id);
|
|
859
|
+
entry.forgetGoal();
|
|
790
860
|
try {
|
|
791
861
|
await entry.native.close();
|
|
792
862
|
} finally {
|
package/server/runtime/pins.ts
CHANGED
|
@@ -55,12 +55,12 @@ export const MANAGED_NODE_ARCHIVES: Readonly<
|
|
|
55
55
|
// Published by .github/workflows/zcode-runtime-release.yml from the pinned
|
|
56
56
|
// source with patches/zcode applied (ADR 19). The same archive serves every
|
|
57
57
|
// managed platform.
|
|
58
|
-
export const MANAGED_ZCODE_VERSION = "3.
|
|
58
|
+
export const MANAGED_ZCODE_VERSION = "3.17.2";
|
|
59
59
|
const MANAGED_ZCODE_RELEASE = `${MANAGED_ZCODE_VERSION}-paseo.1`;
|
|
60
60
|
export const MANAGED_ZCODE_ARCHIVE: PinnedArchive = {
|
|
61
61
|
url: `https://github.com/supermomonga/paseo-plugin-zcode-provider/releases/download/zcode-runtime-v${MANAGED_ZCODE_RELEASE}/zcode-runtime-${MANAGED_ZCODE_RELEASE}.tar.gz`,
|
|
62
|
-
sha256: "
|
|
63
|
-
size:
|
|
62
|
+
sha256: "24e3a9b03260d7b800958ccba4cfdc8233eee67936170636da79d440245bd15d",
|
|
63
|
+
size: 83_086_942,
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
export function managedPlatform(
|