paseo-plugin-zcode-provider 0.5.0 → 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 +1 -1
- package/README.md +5 -2
- 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 +1 -1
- 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
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
|
+
}
|