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 +2 -2
- package/README.md +7 -4
- package/client/goal-pills.ts +252 -0
- package/client/goal.tsx +203 -0
- package/index.client.tsx +4 -0
- package/index.server.ts +11 -1
- package/package.json +4 -4
- package/server/build-info.ts +1 -1
- package/server/goal-command.ts +32 -0
- package/server/goal.ts +58 -0
- package/server/presentation.ts +4 -1
- package/server/provider.ts +75 -20
- package/server/session.ts +229 -79
- package/server/vendor/zcode/packages/ui/src/v4/conversationGoalSummaryModel.ts +88 -0
- package/server/vendor/zcode/provenance.json +7 -1
- package/shared/goal.ts +89 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { GoalState } from "../../../shared/src/zcode-protocol-v4/snapshot.js";
|
|
2
|
+
|
|
3
|
+
const INTERNAL_GOAL_VERIFICATION_FALLBACK_NEXT_ACTION =
|
|
4
|
+
"Continue verifying and completing the goal.";
|
|
5
|
+
|
|
6
|
+
export interface ConversationGoalIterationSummary {
|
|
7
|
+
iteration: number;
|
|
8
|
+
title: string | null;
|
|
9
|
+
items: GoalState["iterations"][number]["items"];
|
|
10
|
+
completedCount: number;
|
|
11
|
+
totalCount: number;
|
|
12
|
+
completed: boolean;
|
|
13
|
+
verificationOutcome: GoalState["verifications"][number]["outcome"] | null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function visibleNextAction(value: string | undefined): string | null {
|
|
17
|
+
const nextAction = value?.trim();
|
|
18
|
+
if (!nextAction || nextAction === INTERNAL_GOAL_VERIFICATION_FALLBACK_NEXT_ACTION) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return nextAction;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function requiredIterationCount(goal: GoalState): number {
|
|
25
|
+
const maxTodoIteration = (goal.iterations ?? []).reduce(
|
|
26
|
+
(maximum, entry) => Math.max(maximum, entry.iteration),
|
|
27
|
+
0,
|
|
28
|
+
);
|
|
29
|
+
const maxVerificationIteration = goal.verifications.reduce(
|
|
30
|
+
(maximum, entry) => Math.max(maximum, entry.iteration),
|
|
31
|
+
0,
|
|
32
|
+
);
|
|
33
|
+
const latestVerification = goal.verifications.findLast(
|
|
34
|
+
(entry) => entry.iteration === goal.iteration,
|
|
35
|
+
);
|
|
36
|
+
const continuationIsOpen =
|
|
37
|
+
goal.status === "active" ||
|
|
38
|
+
goal.status === "notSatisfied" ||
|
|
39
|
+
(goal.status === "paused" && latestVerification?.outcome === "notSatisfied");
|
|
40
|
+
const statusIteration = continuationIsOpen
|
|
41
|
+
? goal.iteration + 1
|
|
42
|
+
: Math.max(1, goal.iteration);
|
|
43
|
+
return Math.max(1, statusIteration, maxTodoIteration, maxVerificationIteration);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** 从 V4 权威 goal 投影构造右上角逐轮摘要;不从 renderer timeline 反推轮次。 */
|
|
47
|
+
export function buildConversationGoalIterationSummaries(
|
|
48
|
+
goal: GoalState,
|
|
49
|
+
): ConversationGoalIterationSummary[] {
|
|
50
|
+
const todoByIteration = new Map(
|
|
51
|
+
(goal.iterations ?? []).map((entry) => [entry.iteration, entry.items] as const),
|
|
52
|
+
);
|
|
53
|
+
const verificationByIteration = new Map(
|
|
54
|
+
goal.verifications.map((entry) => [entry.iteration, entry] as const),
|
|
55
|
+
);
|
|
56
|
+
const rows: ConversationGoalIterationSummary[] = [];
|
|
57
|
+
|
|
58
|
+
for (let iteration = 1; iteration <= requiredIterationCount(goal); iteration += 1) {
|
|
59
|
+
const items = todoByIteration.get(iteration) ?? [];
|
|
60
|
+
const completedCount = items.filter((item) => item.status === "completed").length;
|
|
61
|
+
const previousVerification = verificationByIteration.get(iteration - 1);
|
|
62
|
+
rows.push({
|
|
63
|
+
iteration,
|
|
64
|
+
title:
|
|
65
|
+
iteration === 1
|
|
66
|
+
? (goal.summaryTitle?.trim() || goal.objective.trim() || null)
|
|
67
|
+
: visibleNextAction(previousVerification?.nextAction),
|
|
68
|
+
items,
|
|
69
|
+
completedCount,
|
|
70
|
+
totalCount: items.length,
|
|
71
|
+
completed: items.length > 0 && completedCount >= items.length,
|
|
72
|
+
verificationOutcome: verificationByIteration.get(iteration)?.outcome ?? null,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return rows.sort((left, right) => {
|
|
77
|
+
if (left.completed !== right.completed) return left.completed ? -1 : 1;
|
|
78
|
+
return left.iteration - right.iteration;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function getConversationGoalElapsedSeconds(goal: GoalState, now: number): number {
|
|
83
|
+
const baseSeconds = Math.max(0, Math.floor(goal.timeUsedSeconds ?? 0));
|
|
84
|
+
const isRunning =
|
|
85
|
+
goal.status === "active" || goal.status === "verifying" || goal.status === "notSatisfied";
|
|
86
|
+
if (!isRunning || goal.activeRunStartedAtMs == null) return baseSeconds;
|
|
87
|
+
return baseSeconds + Math.max(0, Math.floor((now - goal.activeRunStartedAtMs) / 1000));
|
|
88
|
+
}
|
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
"packages/shared/src/zcode-protocol-v4/command.ts",
|
|
11
11
|
"packages/shared/src/zcode-protocol-v4/transport.ts",
|
|
12
12
|
"packages/shared/src/zcode-protocol-v4/wire.ts",
|
|
13
|
-
"packages/shared/src/zcode-protocol-v4/wire-assembler.ts"
|
|
13
|
+
"packages/shared/src/zcode-protocol-v4/wire-assembler.ts",
|
|
14
|
+
"packages/ui/src/v4/conversationGoalSummaryModel.ts"
|
|
14
15
|
],
|
|
15
16
|
"modifications": [
|
|
16
17
|
"Resolve the private @zcode/model-option-map workspace import to its vendored relative path.",
|
|
17
18
|
"Resolve packages/shared's #src/* subpath imports to their vendored relative paths.",
|
|
19
|
+
"Resolve type-only imports from @zcode/shared/zcode-protocol-v4 to the vendored module that declares the type.",
|
|
18
20
|
"Select Visual Studio Code notice 9480271317925265e806a9a196aaa33410a962fa9d4d1e248a4a5187bc8c9df9 from THIRD-PARTY-NOTICES.md and add a scope explanation; sourceSha256 hashes the complete upstream file. LICENSE and NOTICE.md are unchanged."
|
|
19
21
|
],
|
|
20
22
|
"files": {
|
|
@@ -517,6 +519,10 @@
|
|
|
517
519
|
"packages/shared/src/zcodeEndpoint.ts": {
|
|
518
520
|
"sourceSha256": "5e191377bdfd8c84cf8588251359fa2e1f64f7600ee220bb1cf2ddde563e9eac",
|
|
519
521
|
"vendoredSha256": "5e191377bdfd8c84cf8588251359fa2e1f64f7600ee220bb1cf2ddde563e9eac"
|
|
522
|
+
},
|
|
523
|
+
"packages/ui/src/v4/conversationGoalSummaryModel.ts": {
|
|
524
|
+
"sourceSha256": "fdaa5f72e7f30cbec61493c8063a8408c5f08de7a35b053ad4374b5717bce7b8",
|
|
525
|
+
"vendoredSha256": "3ede801dca1122a78738461cbe263b92074c7720b44e6b09c4ea4e0e461924e9"
|
|
520
526
|
}
|
|
521
527
|
}
|
|
522
528
|
}
|
package/shared/goal.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { defineRpc } from "@getpaseo/plugin";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
// ZCode's goal as its Desktop status panel shows it (ADR 27): one row per
|
|
5
|
+
// iteration and the time spent. The daemon reads it from the V4 state of the
|
|
6
|
+
// agent's Server; nothing here is stored.
|
|
7
|
+
const goalIterationSchema = z
|
|
8
|
+
.object({
|
|
9
|
+
iteration: z.number().int().positive(),
|
|
10
|
+
/** Null when ZCode has no title for the iteration. */
|
|
11
|
+
title: z.string().nullable(),
|
|
12
|
+
completedCount: z.number().int().nonnegative(),
|
|
13
|
+
totalCount: z.number().int().nonnegative(),
|
|
14
|
+
completed: z.boolean(),
|
|
15
|
+
})
|
|
16
|
+
.strict();
|
|
17
|
+
|
|
18
|
+
export const goalViewSchema = z
|
|
19
|
+
.object({
|
|
20
|
+
/** Paseo's agent, from the PASEO_AGENT_ID of the session's launch. */
|
|
21
|
+
agentId: z.string(),
|
|
22
|
+
status: z.enum([
|
|
23
|
+
"active",
|
|
24
|
+
"paused",
|
|
25
|
+
"verifying",
|
|
26
|
+
"verified",
|
|
27
|
+
"notSatisfied",
|
|
28
|
+
"failed",
|
|
29
|
+
]),
|
|
30
|
+
/** Seconds spent on the goal when the daemon answered. */
|
|
31
|
+
elapsedSeconds: z.number().int().nonnegative(),
|
|
32
|
+
/** Whether the time keeps counting. The client's clock adds to it. */
|
|
33
|
+
running: z.boolean(),
|
|
34
|
+
iterations: z.array(goalIterationSchema),
|
|
35
|
+
})
|
|
36
|
+
.strict();
|
|
37
|
+
export type GoalView = z.output<typeof goalViewSchema>;
|
|
38
|
+
|
|
39
|
+
// The goals of the agents that have a ZCode session open on this host.
|
|
40
|
+
export const zcodeGoals = defineRpc({
|
|
41
|
+
name: "zcode.goals",
|
|
42
|
+
input: z.object({}).strict(),
|
|
43
|
+
output: z.object({ goals: z.array(goalViewSchema) }).strict(),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
/** A goal that can change without the agent's state changing in Paseo. */
|
|
47
|
+
export function goalInProgress(goal: GoalView): boolean {
|
|
48
|
+
return (
|
|
49
|
+
goal.status === "active" ||
|
|
50
|
+
goal.status === "verifying" ||
|
|
51
|
+
goal.status === "notSatisfied"
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function goalStatusLabel(status: GoalView["status"]): string {
|
|
56
|
+
switch (status) {
|
|
57
|
+
case "active":
|
|
58
|
+
return "In progress";
|
|
59
|
+
case "verifying":
|
|
60
|
+
return "Verifying";
|
|
61
|
+
case "notSatisfied":
|
|
62
|
+
return "Incomplete, continuing";
|
|
63
|
+
case "paused":
|
|
64
|
+
return "Paused";
|
|
65
|
+
case "verified":
|
|
66
|
+
return "Complete";
|
|
67
|
+
case "failed":
|
|
68
|
+
return "Verification failed";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* `1h 3m 22s`, as ZCode Desktop's status panel writes it: units that are zero
|
|
74
|
+
* are left out. Without seconds, `1h 3m`, and `<1m` below a minute.
|
|
75
|
+
*/
|
|
76
|
+
export function formatGoalElapsed(
|
|
77
|
+
totalSeconds: number,
|
|
78
|
+
options: { seconds: boolean },
|
|
79
|
+
): string {
|
|
80
|
+
const whole = Math.max(0, Math.floor(totalSeconds));
|
|
81
|
+
const hours = Math.floor(whole / 3600),
|
|
82
|
+
minutes = Math.floor((whole % 3600) / 60),
|
|
83
|
+
seconds = whole % 60;
|
|
84
|
+
const parts: string[] = [];
|
|
85
|
+
if (hours) parts.push(`${hours}h`);
|
|
86
|
+
if (minutes) parts.push(`${minutes}m`);
|
|
87
|
+
if (options.seconds && (seconds || !parts.length)) parts.push(`${seconds}s`);
|
|
88
|
+
return parts.join(" ") || "<1m";
|
|
89
|
+
}
|