paseo-plugin-zcode-provider 0.5.0 → 0.5.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/NOTICE.md CHANGED
@@ -16,11 +16,11 @@ ZCode は統合 CLI を配布していないため、このリポジトリは `z
16
16
 
17
17
  Node.js は利用者のマシンが nodejs.org の公式成果物を直接取得します。このリポジトリは Node.js を再配布しません。
18
18
 
19
- `server/vendor/zcode` は [zai-org/ZCode](https://github.com/zai-org/ZCode/tree/a9fe401eede6e6e5e01be9048679c206fe6f02d9) の RPC、V4 契約、wire 組み立てと純粋な差分適用、および必要なスキーマ依存を含みます。第一者コードは [上流 LICENSE](server/vendor/zcode/LICENSE) の Apache-2.0、RPC と wire codec の VS Code 由来部分は [MIT の通知](server/vendor/zcode/THIRD-PARTY-NOTICES.md) の条件を保持します。[上流 NOTICE](server/vendor/zcode/NOTICE.md) は全文を保持しており、上流製品全体の説明です。そこに記載された全機能・依存がプラグインへ同梱されることを意味しません。
19
+ `server/vendor/zcode` は [zai-org/ZCode](https://github.com/zai-org/ZCode/tree/a9fe401eede6e6e5e01be9048679c206fe6f02d9) の RPC、V4 契約、wire 組み立てと純粋な差分適用、Desktop の Goal 欄の行と経過時間を求める純粋関数(`packages/ui/src/v4/conversationGoalSummaryModel.ts`、ADR 27)、および必要なスキーマ依存を含みます。第一者コードは [上流 LICENSE](server/vendor/zcode/LICENSE) の Apache-2.0、RPC と wire codec の VS Code 由来部分は [MIT の通知](server/vendor/zcode/THIRD-PARTY-NOTICES.md) の条件を保持します。[上流 NOTICE](server/vendor/zcode/NOTICE.md) は全文を保持しており、上流製品全体の説明です。そこに記載された全機能・依存がプラグインへ同梱されることを意味しません。
20
20
 
21
21
  ファイルごとの出典・SHA-256、private workspace import の変更、第三者通知の抽出範囲を [provenance.json](server/vendor/zcode/provenance.json) に記録しています。取得・照合は `scripts/sync-zcode-source.mjs` で行います。`npm run build` はこれらのライセンス・通知を `dist/licenses/zcode` にも配置します。
22
22
 
23
- 開発 SDK は `@getpaseo/plugin@0.15.3` です。ビルドは `@getpaseo/plugin/server/provider` と `zod` を外部モジュールとして維持し、Paseo に解決させます。
23
+ 開発 SDK は `@getpaseo/plugin@0.15.4` です。ビルドは `@getpaseo/plugin/server/provider` と `zod` を外部モジュールとして維持し、Paseo に解決させます。
24
24
 
25
25
  `icon.svg` は [Paseo main c424f829 の glm-acp-agent.svg](https://github.com/getpaseo/paseo/blob/c424f82922fcd36aa9cc9e473644bca04417b420/packages/app/src/assets/acp-provider-icons/glm-acp-agent.svg) のコピーです。この SVG は [ACP Registry の glm-acp-agent/icon.svg](https://github.com/agentclientprotocol/registry/blob/f3826ddd6e35951ea9b7fd0cf43c35a30c3c64cd/glm-acp-agent/icon.svg) とバイト単位で一致します。ACP Registry は Apache-2.0 で配布されており、その [LICENSE](vendor/acp-registry/LICENSE) を保持しています。アイコンは変更していません。商標への権利や公式の承認を示すものではありません。
26
26
 
package/README.md CHANGED
@@ -10,7 +10,7 @@ This is an unofficial plugin. It is not endorsed or maintained by ZCode or Z.ai.
10
10
 
11
11
  | Setting | Requirement |
12
12
  | -------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
13
- | Paseo | 0.15.0 or later; development SDK 0.15.3 |
13
+ | Paseo | 0.15.0 or later; development SDK 0.15.4 |
14
14
  | Plugin Node.js | 22.12.0 or later (the Paseo daemon's runtime) |
15
15
  | Managed setup | darwin-arm64, linux-x64, linux-arm64, win-x64, win-arm64 |
16
16
  | ZCode | Managed: 3.17.2 (release `3.17.2-paseo.1`) with Node.js 24.21.0. Overrides: stable Server 3.14.0+ / Agent 0.16.9+ with Node.js 24.14.0+ |
@@ -63,7 +63,7 @@ ZCode adds a line when a turn runs on a different model than the previous turn,
63
63
 
64
64
  ### Coding Plan usage
65
65
 
66
- Paseo's **Usage** screen and sidebar usage summary show a **ZCode** card for the signed-in account's Individual Coding Plan (Z.ai or BigModel). It lists the 5-hour, weekly, monthly tool-call and ZCode MCP quotas with their reset times, as ZCode Desktop does. The plugin asks ZCode's official usage service for this plan only, on the same ZCode Server as the Account tab. The service never uses an API key from the environment. Team Plan and Start Plan are not shown. Nothing is requested while **Check usage** is off for the host. Paseo 0.15.3 does not yet show usage in a ZCode agent's popover.
66
+ Paseo's **Usage** screen and sidebar usage summary show a **ZCode** card for the signed-in account's Individual Coding Plan (Z.ai or BigModel). It lists the 5-hour, weekly, monthly tool-call and ZCode MCP quotas with their reset times, as ZCode Desktop does. The plugin asks ZCode's official usage service for this plan only, on the same ZCode Server as the Account tab. The service never uses an API key from the environment. Team Plan and Start Plan are not shown. Nothing is requested while **Check usage** is off for the host. Paseo 0.15.4 does not yet show usage in a ZCode agent's popover.
67
67
 
68
68
  ### Using your own runtime
69
69
 
@@ -88,13 +88,16 @@ The source baseline is `a9fe401eede6e6e5e01be9048679c206fe6f02d9` (ZCode 3.17.2,
88
88
  - Paseo sends every message typed in the app during a run as a steer that asks to clear pending permissions. The plugin queues it first, then declines pending permissions, questions and Plan approvals with their deny action until ZCode reads the message, including requests opened in the meantime. Requests that appear after it is read are left to the user. Declining a Plan approval in Plan mode ends ZCode's turn; the message then starts the next native turn in the same Paseo run (ADR 22).
89
89
  - A failed turn reports a code classified from the attribution of ZCode's error: `MODEL_RATE_LIMITED`, `MODEL_AUTH_FAILED`, `MODEL_CONTEXT_EXCEEDED`, `MODEL_NETWORK_ERROR`, `MODEL_PROVIDER_ERROR`, `MODEL_CONTENT_FILTERED` or `MODEL_REQUEST_FAILED` when the model provider or network failed, and `NATIVE_TURN_FAILED` otherwise. The message is the plugin's own text with the HTTP status and the provider's error code when known. The provider's own message, which can include a quota reset time, is not shown; Coding Plan reset times appear on Paseo's Usage screen (ADR 23).
90
90
  - Acceptance is reported once, after the native acknowledgement. Unknown delivery results are never automatically resent. Stop identifies the current native execution, disables automatic queue execution and removes pending input. A new explicit run enables the queue again.
91
- - As in ZCode Desktop, successful hooks are not shown. A finished hook invocation appears once, as a notification, only when a hook was blocked, failed, timed out or was cancelled; context compaction also appears once, when it ends. Paseo appends every notification it receives, so progress is not reported. Model changes appear only when turned on (see [Timeline](#timeline)).
91
+ - `/compact [instructions]` compacts the conversation in a turn of its own; the instructions go to the summary request. ZCode adds no user message for that turn, so the plugin ties it to the command by the ID on the turn itself. Stop cancels a compaction in progress, although ZCode names no execution for it then (ADR 28).
92
+ - As in ZCode Desktop, successful hooks are not shown. A finished hook invocation appears once, as a notification, only when a hook was blocked, failed, timed out or was cancelled; context compaction and a goal verification also appear once, when they end. Paseo appends every notification it receives, so progress is not reported. Model changes appear only when turned on (see [Timeline](#timeline)).
92
93
  - Native permission IDs, option values, questions and Plan approval retain their meanings. Question auto-resolution is disabled for each owned Server. Workspace hook trust is reviewed through the official CLI; it is not represented as “allow once.”
93
94
  - From ZCode 3.17, a project's own MCP servers start only after they are trusted in ZCode Desktop (Settings → MCP Servers); ZCode has no CLI command for it. A session that uses the project's MCP configuration shows a warning while any of them awaits trust. MCP servers that Paseo passes to a session replace ZCode's MCP configuration, as before, and are marked as the user's, so the project's trust review does not block them.
94
95
  - Each session owns its Server process and environment. Metadata requests use temporary Servers. Closing stdin gives ZCode time to clean up before process termination.
96
+ - `/goal <objective>` sets a ZCode goal, as in ZCode Desktop: ZCode works toward it in turns it starts itself, verifies the result after each one and continues until the verifier passes it. `/goal replace <objective>` (or a new `/goal <objective>`) replaces the goal, stopping the turn pauses it, `/goal resume` continues it, and `/goal pause` pauses a goal that is active without a turn. Goal commands need an idle agent and Plan mode off; ZCode does not run a goal in Plan mode. ZCode's Server has no command for `/goal clear` or `/goal show`, so the plugin refuses them with an explanation, and `/goal` with an attachment (ADR 27).
97
+ - An agent with a goal shows a **Goal** pill above the composer, next to Paseo's Tasks, with the time spent and an icon for the state. Its popover lists one row per iteration with the count of that iteration's tasks, as ZCode Desktop's status panel does. The pill follows the goal within about 10 seconds while it is in progress. It appears only while the agent's session is open: after Paseo released an idle agent or the daemon restarted, it returns with the next message.
95
98
  - With **Release idle agents** (Host settings → Agents, on by default), Paseo closes an agent's session after an hour of inactivity and reopens it on the next message. The plugin keeps the session while ZCode still has a foreground turn, queued input, a pending question or approval, a running background command, subagent or workflow, or a goal that is active or being verified (ADR 25). A finished background command's result that ZCode has not yet delivered is not distinguishable and does not keep it. **Resume agents after restart** reopens agents interrupted by a host restart and sends the resume prompt. Both reopen the saved conversation with Paseo's saved mode and Plan settings ([ADR 14](docs/adr/0014-paseoの保存設定を再適用する復元を保証範囲とする.md)).
96
99
 
97
- The plugin uses ZCode's own skills, MCP configuration and tools. Browser Use and Computer Use cannot run in the plugin's ZCode, even when ZCode Desktop has them enabled: the Computer Use helper accepts only the signed Desktop app, and only Desktop provides browsers. ZCode's Visualize (interactive views in the conversation) renders only in Desktop. The plugin therefore hides all three from the model (ADR 19, ADR 21); Desktop is not affected. Generic rewind, independent Paseo child agents, hook-review UI and Goal/Workflow controls are outside this migration. `prompt.output_schema`, custom system prompts and `persist:false` are unsupported. A system prompt makes session creation fail with `INVALID_CONFIGURATION` and a message explaining why, including one appended by Paseo's Orchestration → System prompt setting or by another plugin that adds one to new agents. MCP `alwaysLoad` is unsupported; stdio MCP commands must be absolute paths. Provider options are unsupported: `agents.providers.zcode.options` in Paseo's `config.json` makes sessions fail with `INVALID_CONFIGURATION`, and the `command` and `env` overrides there are not applied. Paseo does not show context usage reported before the first turn, and the plugin adds no substitute display; Coding Plan quota appears in Paseo's Usage screen (see [Coding Plan usage](#coding-plan-usage)).
100
+ The plugin uses ZCode's own skills, MCP configuration and tools. Browser Use and Computer Use cannot run in the plugin's ZCode, even when ZCode Desktop has them enabled: the Computer Use helper accepts only the signed Desktop app, and only Desktop provides browsers. ZCode's Visualize (interactive views in the conversation) renders only in Desktop. The plugin therefore hides all three from the model (ADR 19, ADR 21); Desktop is not affected. Generic rewind, independent Paseo child agents, hook-review UI, Workflow controls and buttons for the goal (use the `/goal` commands) are outside this migration. `prompt.output_schema`, custom system prompts and `persist:false` are unsupported. A system prompt makes session creation fail with `INVALID_CONFIGURATION` and a message explaining why, including one appended by Paseo's Orchestration → System prompt setting or by another plugin that adds one to new agents. MCP `alwaysLoad` is unsupported; stdio MCP commands must be absolute paths. Provider options are unsupported: `agents.providers.zcode.options` in Paseo's `config.json` makes sessions fail with `INVALID_CONFIGURATION`, and the `command` and `env` overrides there are not applied. Paseo does not show context usage reported before the first turn, and the plugin adds no substitute display; Coding Plan quota appears in Paseo's Usage screen (see [Coding Plan usage](#coding-plan-usage)).
98
101
 
99
102
  ## Persistence
100
103
 
@@ -0,0 +1,252 @@
1
+ import type { ComponentType } from "react";
2
+ import type {
3
+ PluginButtonContentProps,
4
+ PluginButtonRegistration,
5
+ PluginClientContext,
6
+ } from "@getpaseo/plugin/client";
7
+ import {
8
+ formatGoalElapsed,
9
+ goalInProgress,
10
+ goalStatusLabel,
11
+ zcodeGoals,
12
+ type GoalView,
13
+ } from "../shared/goal";
14
+
15
+ /** The provider ID the agents of this plugin carry. */
16
+ const PROVIDER = "zcode";
17
+ /** The least time between two reads of the goals. */
18
+ const READ_SPACING_MS = 1_000;
19
+ /**
20
+ * A goal in progress changes without its agent changing in Paseo, as when
21
+ * ZCode titles it, and Paseo 0.15 gives the daemon no way to tell a client.
22
+ */
23
+ const IN_PROGRESS_READ_MS = 10_000;
24
+
25
+ export type GoalPillHost = Pick<
26
+ PluginClientContext,
27
+ "addComposerPill" | "rpc" | "paseo"
28
+ >;
29
+
30
+ type Timer = ReturnType<typeof setTimeout>;
31
+ // React Native's clearTimeout takes no undefined.
32
+ function cancel(timer: Timer | undefined): void {
33
+ if (timer !== undefined) clearTimeout(timer);
34
+ }
35
+
36
+ interface Pill {
37
+ workspaceId: string;
38
+ registration: PluginButtonRegistration;
39
+ goal: GoalView;
40
+ /** This client's clock when the daemon answered. */
41
+ readAt: number;
42
+ shown: { title: string; icon: string; label: string };
43
+ }
44
+
45
+ /** The seconds spent on the goal now, by this client's clock. */
46
+ export function goalElapsedSeconds(
47
+ goal: GoalView,
48
+ readAt: number,
49
+ now: number,
50
+ ): number {
51
+ return (
52
+ goal.elapsedSeconds +
53
+ (goal.running ? Math.max(0, Math.floor((now - readAt) / 1000)) : 0)
54
+ );
55
+ }
56
+
57
+ function goalIcon(status: GoalView["status"]): string {
58
+ switch (status) {
59
+ case "active":
60
+ case "notSatisfied":
61
+ return "Goal";
62
+ case "verifying":
63
+ return "ScanSearch";
64
+ case "paused":
65
+ return "CirclePause";
66
+ case "verified":
67
+ return "CircleCheckBig";
68
+ case "failed":
69
+ return "CircleAlert";
70
+ }
71
+ }
72
+
73
+ function present(goal: GoalView, readAt: number, now: number): Pill["shown"] {
74
+ return {
75
+ title: `Goal: ${goalStatusLabel(goal.status)}`,
76
+ icon: goalIcon(goal.status),
77
+ label: `Goal ${formatGoalElapsed(goalElapsedSeconds(goal, readAt, now), {
78
+ seconds: false,
79
+ })}`,
80
+ };
81
+ }
82
+
83
+ /**
84
+ * Shows a pill above the composer of every ZCode agent that has a goal, next
85
+ * to Paseo's Tasks (ADR 27). Returns the cleanup.
86
+ */
87
+ export function followGoals(
88
+ client: GoalPillHost,
89
+ Content: ComponentType<PluginButtonContentProps>,
90
+ ): () => void {
91
+ /** The ZCode agents this client knows, with their workspaces. */
92
+ const agents = new Map<string, string>();
93
+ const pills = new Map<string, Pill>();
94
+ const lifetime = new AbortController();
95
+ let stopped = false,
96
+ reading = false,
97
+ again = false,
98
+ lastRead = Number.NEGATIVE_INFINITY;
99
+ let readTimer: Timer | undefined, labelTimer: Timer | undefined;
100
+
101
+ const hide = (agentId: string) => {
102
+ pills.get(agentId)?.registration.remove();
103
+ pills.delete(agentId);
104
+ };
105
+
106
+ const show = (goal: GoalView, workspaceId: string, readAt: number) => {
107
+ const shown = present(goal, readAt, readAt);
108
+ let pill = pills.get(goal.agentId);
109
+ if (pill && pill.workspaceId !== workspaceId) {
110
+ hide(goal.agentId);
111
+ pill = undefined;
112
+ }
113
+ if (!pill) {
114
+ pills.set(goal.agentId, {
115
+ workspaceId,
116
+ goal,
117
+ readAt,
118
+ shown,
119
+ registration: client.addComposerPill({
120
+ id: "goal",
121
+ workspaceId,
122
+ agentId: goal.agentId,
123
+ button: { ...shown, behavior: { kind: "popover", Content } },
124
+ }),
125
+ });
126
+ return;
127
+ }
128
+ pill.goal = goal;
129
+ pill.readAt = readAt;
130
+ relabel(pill, shown);
131
+ };
132
+
133
+ // An update of the behavior would close an open popover.
134
+ const relabel = (pill: Pill, next: Pill["shown"]) => {
135
+ const patch = Object.fromEntries(
136
+ Object.entries(next).filter(
137
+ ([key, value]) => pill.shown[key as keyof Pill["shown"]] !== value,
138
+ ),
139
+ );
140
+ pill.shown = next;
141
+ if (Object.keys(patch).length) pill.registration.update(patch);
142
+ };
143
+
144
+ /** The label counts minutes; the next change is at the next full minute. */
145
+ const scheduleLabels = () => {
146
+ cancel(labelTimer);
147
+ labelTimer = undefined;
148
+ const now = Date.now();
149
+ let next = Number.POSITIVE_INFINITY;
150
+ for (const pill of pills.values()) {
151
+ if (!pill.goal.running) continue;
152
+ relabel(pill, present(pill.goal, pill.readAt, now));
153
+ const elapsed = goalElapsedSeconds(pill.goal, pill.readAt, now);
154
+ next = Math.min(next, 60 - (elapsed % 60));
155
+ }
156
+ if (Number.isFinite(next))
157
+ labelTimer = setTimeout(scheduleLabels, next * 1000);
158
+ };
159
+
160
+ const apply = (goals: readonly GoalView[]) => {
161
+ const readAt = Date.now();
162
+ const current = new Set<string>();
163
+ for (const goal of goals) {
164
+ const workspaceId = agents.get(goal.agentId);
165
+ if (workspaceId === undefined) continue;
166
+ current.add(goal.agentId);
167
+ show(goal, workspaceId, readAt);
168
+ }
169
+ for (const agentId of [...pills.keys()])
170
+ if (!current.has(agentId)) hide(agentId);
171
+ scheduleLabels();
172
+ };
173
+
174
+ const read = async () => {
175
+ reading = true;
176
+ lastRead = Date.now();
177
+ try {
178
+ const { goals } = await client.rpc(zcodeGoals, {});
179
+ if (!stopped) apply(goals);
180
+ } catch (error) {
181
+ // The pills keep what they show; the next read replaces it.
182
+ if (!stopped) console.error("Reading ZCode goals failed", error);
183
+ } finally {
184
+ reading = false;
185
+ if (!stopped) {
186
+ if (again) refresh();
187
+ else if ([...pills.values()].some((p) => goalInProgress(p.goal)))
188
+ readTimer = setTimeout(refresh, IN_PROGRESS_READ_MS);
189
+ }
190
+ }
191
+ };
192
+
193
+ /** Reads the goals now, or as soon as the spacing allows. */
194
+ function refresh() {
195
+ if (stopped) return;
196
+ if (reading) {
197
+ again = true;
198
+ return;
199
+ }
200
+ again = false;
201
+ cancel(readTimer);
202
+ readTimer = undefined;
203
+ const wait = lastRead + READ_SPACING_MS - Date.now();
204
+ if (wait > 0) readTimer = setTimeout(refresh, wait);
205
+ else void read();
206
+ }
207
+
208
+ const track = (agent: {
209
+ id: string;
210
+ provider: string;
211
+ workspaceId?: string | null;
212
+ }): boolean => {
213
+ if (agent.provider !== PROVIDER) return false;
214
+ if (agent.workspaceId) agents.set(agent.id, agent.workspaceId);
215
+ else agents.delete(agent.id);
216
+ return true;
217
+ };
218
+
219
+ void client.paseo.agents
220
+ .list({ subscribe: {}, signal: lifetime.signal })
221
+ .then(({ subscription }) => {
222
+ subscription.subscribe({
223
+ // Also delivered after a reconnect: it replaces what is known.
224
+ snapshot: ({ entries }) => {
225
+ agents.clear();
226
+ for (const { agent } of entries) track(agent);
227
+ refresh();
228
+ },
229
+ update: (message) => {
230
+ if (message.type !== "agent_update") return;
231
+ const update = message.payload;
232
+ if (update.kind === "remove") {
233
+ agents.delete(update.agentId);
234
+ hide(update.agentId);
235
+ } else if (track(update.agent)) refresh();
236
+ },
237
+ });
238
+ return undefined;
239
+ })
240
+ .catch((error: unknown) => {
241
+ if (!stopped) console.error("Observing Paseo agents failed", error);
242
+ });
243
+
244
+ return () => {
245
+ stopped = true;
246
+ lifetime.abort();
247
+ cancel(readTimer);
248
+ cancel(labelTimer);
249
+ for (const pill of pills.values()) pill.registration.remove();
250
+ pills.clear();
251
+ };
252
+ }
@@ -0,0 +1,203 @@
1
+ import { useEffect, useState } from "react";
2
+ import { Text, View } from "react-native";
3
+ import { type PluginButtonContentProps, useRpc } from "@getpaseo/plugin/client";
4
+ import { Icon } from "@getpaseo/plugin/client/ui";
5
+ import {
6
+ formatGoalElapsed,
7
+ goalInProgress,
8
+ goalStatusLabel,
9
+ zcodeGoals,
10
+ type GoalView,
11
+ } from "../shared/goal";
12
+ import { goalElapsedSeconds } from "./goal-pills";
13
+
14
+ type Theme = PluginButtonContentProps["theme"];
15
+
16
+ /** How often the open popover reads a goal that is in progress. */
17
+ const READ_MS = 3_000;
18
+
19
+ function statusColor(status: GoalView["status"], theme: Theme): string {
20
+ switch (status) {
21
+ case "verified":
22
+ return theme.colors.statusSuccess;
23
+ case "failed":
24
+ return theme.colors.statusDanger;
25
+ case "paused":
26
+ return theme.colors.statusWarning;
27
+ default:
28
+ return theme.colors.foreground;
29
+ }
30
+ }
31
+
32
+ function hint(goal: GoalView): string | undefined {
33
+ if (goal.status === "paused") return "Send /goal resume to continue.";
34
+ if (goalInProgress(goal)) return "Stopping the turn pauses the goal.";
35
+ return undefined;
36
+ }
37
+
38
+ // One row per iteration, as in ZCode Desktop's status panel: a finished
39
+ // iteration carries its number, and the count is of its task list.
40
+ function Iteration({
41
+ row,
42
+ theme,
43
+ }: {
44
+ row: GoalView["iterations"][number];
45
+ theme: Theme;
46
+ }) {
47
+ return (
48
+ <View style={{ flexDirection: "row", alignItems: "flex-start", gap: 8 }}>
49
+ <View
50
+ style={{
51
+ width: 18,
52
+ height: 20,
53
+ alignItems: "center",
54
+ justifyContent: "center",
55
+ }}
56
+ >
57
+ {row.completed ? (
58
+ <View
59
+ style={{
60
+ width: 16,
61
+ height: 16,
62
+ borderRadius: 8,
63
+ borderWidth: 1,
64
+ borderColor: theme.colors.statusSuccess,
65
+ alignItems: "center",
66
+ justifyContent: "center",
67
+ }}
68
+ >
69
+ <Text
70
+ style={{
71
+ color: theme.colors.statusSuccess,
72
+ fontSize: 10,
73
+ lineHeight: 12,
74
+ }}
75
+ >
76
+ {row.iteration}
77
+ </Text>
78
+ </View>
79
+ ) : (
80
+ <Icon name="Goal" size={16} color={theme.colors.foregroundMuted} />
81
+ )}
82
+ </View>
83
+ <Text
84
+ numberOfLines={3}
85
+ style={{
86
+ flex: 1,
87
+ minWidth: 0,
88
+ color: theme.colors.foreground,
89
+ fontSize: 14,
90
+ lineHeight: 20,
91
+ }}
92
+ >
93
+ {row.title ?? `Iteration ${row.iteration}`}
94
+ </Text>
95
+ {row.totalCount > 0 ? (
96
+ <Text
97
+ style={{
98
+ color: theme.colors.foregroundMuted,
99
+ fontSize: 13,
100
+ lineHeight: 20,
101
+ fontVariant: ["tabular-nums"],
102
+ }}
103
+ >
104
+ {row.completedCount}/{row.totalCount}
105
+ </Text>
106
+ ) : null}
107
+ </View>
108
+ );
109
+ }
110
+
111
+ /** The body of the Goal pill's popover (ADR 27). */
112
+ export function GoalPopover(props: PluginButtonContentProps) {
113
+ const { theme, layout } = props;
114
+ const agentId = props.context === "agent" ? props.agentId : undefined;
115
+ const fetchGoals = useRpc(zcodeGoals);
116
+ const [read, setRead] = useState<
117
+ { goal: GoalView | null; readAt: number } | "failed" | undefined
118
+ >();
119
+ const [now, setNow] = useState(() => Date.now());
120
+
121
+ useEffect(() => {
122
+ let open = true;
123
+ let timer: ReturnType<typeof setTimeout> | undefined;
124
+ const load = async () => {
125
+ try {
126
+ const { goals } = await fetchGoals({});
127
+ if (!open) return;
128
+ const goal = goals.find((g) => g.agentId === agentId) ?? null;
129
+ setRead({ goal, readAt: Date.now() });
130
+ if (goal && goalInProgress(goal)) timer = setTimeout(load, READ_MS);
131
+ } catch {
132
+ if (open) setRead("failed");
133
+ }
134
+ };
135
+ void load();
136
+ return () => {
137
+ open = false;
138
+ if (timer !== undefined) clearTimeout(timer);
139
+ };
140
+ }, [fetchGoals, agentId]);
141
+
142
+ const goal = typeof read === "object" ? read.goal : null;
143
+ const running = goal?.running === true;
144
+ useEffect(() => {
145
+ if (!running) return;
146
+ setNow(Date.now());
147
+ const timer = setInterval(() => setNow(Date.now()), 1000);
148
+ return () => clearInterval(timer);
149
+ }, [running]);
150
+
151
+ const muted = {
152
+ color: theme.colors.foregroundMuted,
153
+ fontSize: 13,
154
+ lineHeight: 20,
155
+ };
156
+ const frame = {
157
+ gap: 12,
158
+ ...(layout.compact ? {} : { width: 320 }),
159
+ };
160
+ if (typeof read !== "object" || !goal)
161
+ return (
162
+ <View style={frame}>
163
+ <Text style={muted}>
164
+ {read === undefined
165
+ ? "Loading…"
166
+ : read === "failed"
167
+ ? "The goal could not be read."
168
+ : "This agent has no goal."}
169
+ </Text>
170
+ </View>
171
+ );
172
+
173
+ const note = hint(goal);
174
+ return (
175
+ <View style={frame}>
176
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
177
+ <Text
178
+ style={{
179
+ flex: 1,
180
+ color: statusColor(goal.status, theme),
181
+ fontSize: 14,
182
+ lineHeight: 20,
183
+ fontWeight: "600",
184
+ }}
185
+ >
186
+ {goalStatusLabel(goal.status)}
187
+ </Text>
188
+ <Text style={{ ...muted, fontVariant: ["tabular-nums"] }}>
189
+ {formatGoalElapsed(
190
+ goalElapsedSeconds(goal, read.readAt, Math.max(now, read.readAt)),
191
+ { seconds: true },
192
+ )}
193
+ </Text>
194
+ </View>
195
+ <View style={{ gap: 8 }}>
196
+ {goal.iterations.map((row) => (
197
+ <Iteration key={row.iteration} row={row} theme={theme} />
198
+ ))}
199
+ </View>
200
+ {note ? <Text style={muted}>{note}</Text> : null}
201
+ </View>
202
+ );
203
+ }
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(undefined, undefined, undefined, timeline.current),
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paseo-plugin-zcode-provider",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
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.15.3",
64
- "@getpaseo/plugin": "0.15.3",
65
- "@getpaseo/protocol": "0.15.3",
63
+ "@getpaseo/client": "0.15.4",
64
+ "@getpaseo/plugin": "0.15.4",
65
+ "@getpaseo/protocol": "0.15.4",
66
66
  "@types/node": "22.18.3",
67
67
  "@types/react": "~19.2.0",
68
68
  "@types/semver": "7.8.0",
@@ -1,2 +1,2 @@
1
1
  // Generated from package.json by npm prepare / prebuild.
2
- export const PROVIDER_VERSION = "0.5.0";
2
+ export const PROVIDER_VERSION = "0.5.2";
@@ -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
+ }