@getpaseo/server 0.17.0 → 0.17.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.
Files changed (34) hide show
  1. package/dist/server/builtin-plugins/antigravity-provider/server/usage.ts +22 -12
  2. package/dist/server/builtin-plugins/package.json +1 -1
  3. package/dist/server/server/agent/agent-manager.d.ts +10 -1
  4. package/dist/server/server/agent/agent-manager.js +22 -5
  5. package/dist/server/server/agent/agent-messages/delivery.d.ts +43 -5
  6. package/dist/server/server/agent/agent-messages/delivery.js +386 -213
  7. package/dist/server/server/agent/agent-messages/envelope.d.ts +8 -0
  8. package/dist/server/server/agent/agent-messages/envelope.js +8 -1
  9. package/dist/server/server/agent/agent-prompt.d.ts +9 -2
  10. package/dist/server/server/agent/agent-prompt.js +21 -10
  11. package/dist/server/server/agent/host-operations/index.js +1 -1
  12. package/dist/server/server/agent/providers/codex-app-server-agent.js +5 -1
  13. package/dist/server/server/agent/tools/paseo-tools.js +6 -5
  14. package/dist/server/server/bootstrap.js +43 -26
  15. package/dist/server/server/session/checkout/checkout-session.d.ts +3 -1
  16. package/dist/server/server/session/checkout/checkout-session.js +2 -2
  17. package/dist/server/server/session.d.ts +3 -2
  18. package/dist/server/server/session.js +29 -22
  19. package/dist/server/server/websocket-server.d.ts +1 -0
  20. package/dist/server/server/websocket-server.js +14 -0
  21. package/dist/server/server/workspace-archive-operations.d.ts +4 -0
  22. package/dist/server/server/workspace-archive-operations.js +24 -0
  23. package/dist/server/server/workspace-directory.d.ts +1 -3
  24. package/dist/server/server/workspace-directory.js +1 -12
  25. package/dist/server/skills/paseo/SKILL.md +1 -1
  26. package/dist/server/web-ui/_expo/static/js/web/{index-9e9b3c5827a186678679c43439d3998a.js → index-12cbb5f1badfbe448300b289565efbeb.js} +42 -42
  27. package/dist/server/web-ui/_expo/static/js/web/index-12cbb5f1badfbe448300b289565efbeb.js.br +0 -0
  28. package/dist/server/web-ui/_expo/static/js/web/index-12cbb5f1badfbe448300b289565efbeb.js.gz +0 -0
  29. package/dist/server/web-ui/index.html +1 -1
  30. package/dist/server/web-ui/index.html.br +0 -0
  31. package/dist/server/web-ui/index.html.gz +0 -0
  32. package/package.json +6 -6
  33. package/dist/server/web-ui/_expo/static/js/web/index-9e9b3c5827a186678679c43439d3998a.js.br +0 -0
  34. package/dist/server/web-ui/_expo/static/js/web/index-9e9b3c5827a186678679c43439d3998a.js.gz +0 -0
@@ -48,6 +48,11 @@ function accountKey(env: ProviderLaunch["env"]): string {
48
48
  );
49
49
  }
50
50
 
51
+ function formatWindowLabel(name: string, window: string): string {
52
+ if (window.trim().toLowerCase() === "5h") return "5h";
53
+ return name.trim().replace(/(?:\s+Limit)?\s+Remaining$/i, "");
54
+ }
55
+
51
56
  function shortWindow(window: string): string {
52
57
  const trimmed = window.trim();
53
58
  const normalized = trimmed.toLowerCase();
@@ -67,18 +72,16 @@ function windowDurationSeconds(window: string): number | undefined {
67
72
  }
68
73
  }
69
74
 
70
- function shortGroupName(name: string): string {
75
+ function formatGroupLabel(name: string): string {
71
76
  return name
72
77
  .trim()
73
- .replace(/\s+models$/i, "")
78
+ .replace(/(?:^|\s+)models$/i, "")
74
79
  .trim();
75
80
  }
76
81
 
77
- function formatShortLabel(groupName: string, window: string, includeGroup: boolean): string {
82
+ function formatShortLabel(groupLabel: string, window: string): string {
78
83
  const period = shortWindow(window);
79
- if (!includeGroup) return period;
80
- const scope = shortGroupName(groupName);
81
- return scope ? `${scope} ${period}` : period;
84
+ return groupLabel ? `${groupLabel} ${period}` : period;
82
85
  }
83
86
 
84
87
  export class Usage {
@@ -129,15 +132,22 @@ export class Usage {
129
132
  if (!data.command) throw new Error("agy did not return usage data");
130
133
  const groups = data.command.data.groups;
131
134
  const includeGroup = groups.length > 1;
132
- const windows = groups.flatMap((group) =>
133
- group.buckets.flatMap((bucket) => {
135
+ const windows = groups.flatMap((group) => {
136
+ const groupLabel = formatGroupLabel(group.name);
137
+ return group.buckets.flatMap((bucket) => {
134
138
  if (!bucket.disabled && bucket.remaining_fraction == null) return [];
135
139
  const used = bucket.disabled ? null : (1 - bucket.remaining_fraction!) * 100;
136
140
  return [
137
141
  windowFromUsedPct({
138
142
  id: bucket.id,
139
- label: `${group.name} · ${bucket.name}${bucket.disabled ? " · Disabled" : ""}`,
140
- shortLabel: formatShortLabel(group.name, bucket.window, includeGroup),
143
+ label: [
144
+ groupLabel,
145
+ formatWindowLabel(bucket.name, bucket.window),
146
+ bucket.disabled ? "Disabled" : null,
147
+ ]
148
+ .filter(Boolean)
149
+ .join(" · "),
150
+ shortLabel: formatShortLabel(includeGroup ? groupLabel : "", bucket.window),
141
151
  summary: !bucket.disabled && bucket.window === "weekly",
142
152
  utilizationPct: used,
143
153
  durationSeconds: windowDurationSeconds(bucket.window),
@@ -145,8 +155,8 @@ export class Usage {
145
155
  tone: used === null ? "default" : toneFromUsedPct(used),
146
156
  }),
147
157
  ];
148
- }),
149
- );
158
+ });
159
+ });
150
160
  if (windows.length === 0)
151
161
  return unavailable({ kind: "no_quota", detail: "No usage quota reported by agy" });
152
162
  return { status: "available", windows };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpaseo/builtin-plugins",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -23,8 +23,9 @@ import { type AgentBackgroundWorkItem, type DaemonBackgroundWorkInput, type Daem
23
23
  export declare class AgentManagerShuttingDownError extends Error {
24
24
  constructor();
25
25
  }
26
+ type RunCancellationCause = "reload" | "replace" | "rewind" | "stop";
26
27
  export declare class AgentRunCancellationError extends Error {
27
- constructor(agentId: string, action: "reload" | "replace" | "rewind" | "stop");
28
+ constructor(agentId: string, action: RunCancellationCause);
28
29
  }
29
30
  export type AgentRunCancellationResult = {
30
31
  status: "not_running";
@@ -303,6 +304,7 @@ export declare class AgentManager {
303
304
  private readonly replacementMutationTails;
304
305
  private readonly runs;
305
306
  private readonly subscribers;
307
+ private readonly stopListeners;
306
308
  private readonly idFactory;
307
309
  private readonly registry?;
308
310
  private readonly durableTimelineStore?;
@@ -370,6 +372,11 @@ export declare class AgentManager {
370
372
  private nextStoredUpdatedAt;
371
373
  hasPendingPermissions(agentId: string): boolean;
372
374
  hasInFlightRun(agentId: string): boolean;
375
+ /**
376
+ * Notify before a running turn is stopped with no prompt replacing it: Stop and `cancel_agent`,
377
+ * not a replacing prompt, a reload, or a rewind. Listeners run before the agent settles.
378
+ */
379
+ onStop(listener: (agentId: string) => void): () => void;
373
380
  subscribe(callback: AgentSubscriber, options?: SubscribeOptions): () => void;
374
381
  subscriptionCount(): number;
375
382
  listAgents(options?: {
@@ -572,7 +579,9 @@ export declare class AgentManager {
572
579
  private recordAcceptedSteer;
573
580
  waitForAgentRunStart(agentId: string, options?: WaitForAgentStartOptions): Promise<void>;
574
581
  respondToPermission(agentId: string, requestId: string, response: AgentPermissionResponse): Promise<AgentPermissionResult | void>;
582
+ /** Stop the running turn. Nothing replaces it, so `onStop` listeners hear about it first. */
575
583
  cancelAgentRun(agentId: string): Promise<AgentRunCancellationResult>;
584
+ private cancelRun;
576
585
  private cancelAgentRunNow;
577
586
  private cancelAgentRunBefore;
578
587
  private interruptSession;
@@ -343,6 +343,7 @@ export class AgentManager {
343
343
  this.replacementMutationTails = new Map();
344
344
  this.runs = new AgentRunState();
345
345
  this.subscribers = new Set();
346
+ this.stopListeners = new Set();
346
347
  this.previousStatuses = new Map();
347
348
  this.backgroundTasks = new Set();
348
349
  this.agentRegistrationTasks = new Set();
@@ -552,6 +553,14 @@ export class AgentManager {
552
553
  Boolean(agent.activeForegroundTurnId) ||
553
554
  this.runs.hasRun(agentId));
554
555
  }
556
+ /**
557
+ * Notify before a running turn is stopped with no prompt replacing it: Stop and `cancel_agent`,
558
+ * not a replacing prompt, a reload, or a rewind. Listeners run before the agent settles.
559
+ */
560
+ onStop(listener) {
561
+ this.stopListeners.add(listener);
562
+ return () => this.stopListeners.delete(listener);
563
+ }
555
564
  subscribe(callback, options) {
556
565
  const targetAgentId = options?.agentId == null ? null : validateAgentId(options.agentId, "subscribe");
557
566
  const record = {
@@ -2585,7 +2594,7 @@ export class AgentManager {
2585
2594
  this.touchUpdatedAt(agent);
2586
2595
  this.emitState(agent);
2587
2596
  try {
2588
- const result = await this.cancelAgentRunNow(agent.id);
2597
+ const result = await this.cancelAgentRunNow(agent.id, "replace");
2589
2598
  if (result.status === "refused") {
2590
2599
  throw new AgentRunCancellationError(agent.id, "replace");
2591
2600
  }
@@ -2742,10 +2751,14 @@ export class AgentManager {
2742
2751
  agent.bufferedPermissionResolutions.delete(requestId);
2743
2752
  }
2744
2753
  }
2745
- async cancelAgentRun(agentId) {
2754
+ /** Stop the running turn. Nothing replaces it, so `onStop` listeners hear about it first. */
2755
+ cancelAgentRun(agentId) {
2756
+ return this.cancelRun(agentId, "stop");
2757
+ }
2758
+ async cancelRun(agentId, cause) {
2746
2759
  const cancellation = this.runForegroundMutation(agentId, () => {
2747
2760
  this.requireSessionAgent(agentId).pendingReplacement = false;
2748
- return this.cancelAgentRunNow(agentId);
2761
+ return this.cancelAgentRunNow(agentId, cause);
2749
2762
  });
2750
2763
  this.pendingCancellations.set(agentId, cancellation);
2751
2764
  try {
@@ -2757,13 +2770,17 @@ export class AgentManager {
2757
2770
  }
2758
2771
  }
2759
2772
  }
2760
- async cancelAgentRunNow(agentId) {
2773
+ async cancelAgentRunNow(agentId, cause) {
2761
2774
  const agent = this.requireSessionAgent(agentId);
2762
2775
  const run = this.runs.getRun(agentId) ??
2763
2776
  (agent.lifecycle === "running" ? this.runs.trackAutonomousRun(agentId, null) : null);
2764
2777
  if (!run) {
2765
2778
  return { status: "not_running" };
2766
2779
  }
2780
+ if (cause === "stop") {
2781
+ for (const listener of this.stopListeners)
2782
+ listener(agentId);
2783
+ }
2767
2784
  const interruptAcknowledged = await this.interruptSession(agent.session, agentId);
2768
2785
  const settlement = await this.waitWithTimeout({
2769
2786
  operation: run.settledPromise,
@@ -2810,7 +2827,7 @@ export class AgentManager {
2810
2827
  return { status: "settled" };
2811
2828
  }
2812
2829
  async cancelAgentRunBefore(agentId, action) {
2813
- const result = await this.cancelAgentRun(agentId);
2830
+ const result = await this.cancelRun(agentId, action);
2814
2831
  if (result.status === "refused") {
2815
2832
  throw new AgentRunCancellationError(agentId, action);
2816
2833
  }
@@ -1,4 +1,4 @@
1
- import { type PromptDispatchDisposition } from "../agent-prompt.js";
1
+ import { type PromptDispatchDisposition, type PromptDispatchResult } from "../agent-prompt.js";
2
2
  import type { AgentPromptInput } from "../agent-sdk-types.js";
3
3
  import { type AgentPromptSource } from "./envelope.js";
4
4
  interface Message {
@@ -24,36 +24,74 @@ interface DispatchRequest {
24
24
  prompt: AgentPromptInput;
25
25
  activeTurnBehavior: "steer" | "interrupt";
26
26
  idleOnly: boolean;
27
- /** Claim this exact prompt at provider admission. A withdrawn message invalidates the batch. */
27
+ /**
28
+ * Claim this exact prompt at provider admission. A withdrawn message or a Stop that reached
29
+ * the recipient first invalidates it.
30
+ */
28
31
  admit(): boolean;
29
32
  sessionMode?: string;
30
33
  clearPendingPermissions: boolean;
31
34
  unarchive: boolean;
32
35
  }
36
+ /** A prompt that does not wait its turn: a person's, or the daemon's own. */
37
+ interface DirectPrompt {
38
+ recipientId: string;
39
+ prompt: AgentPromptInput;
40
+ source?: AgentPromptSource;
41
+ messageId?: string;
42
+ sessionMode?: string;
43
+ unarchive?: boolean;
44
+ }
45
+ /** The provider prompt a direct prompt became. Unchanged when nothing was queued. */
46
+ interface JoinedPrompt {
47
+ prompt: AgentPromptInput;
48
+ messageId?: string;
49
+ sessionMode?: string;
50
+ unarchive: boolean;
51
+ }
33
52
  interface Dependencies {
34
53
  /** Includes admitted starts and provider turns, including compaction. */
35
54
  isRunning?: (recipientId: string) => boolean;
36
55
  hasPendingPermission?: (recipientId: string) => boolean;
37
56
  /** Notify when recipient state changes; admission still checks whether it is idle. */
38
57
  subscribe?: (listener: (recipientId: string) => void) => () => void;
58
+ /** Notify before a recipient's turn is stopped with no prompt replacing it. */
59
+ onStop?: (listener: (recipientId: string) => void) => () => void;
39
60
  tryRunOutOfBand?(request: DispatchRequest, onAccepted: () => void): Promise<boolean>;
61
+ /** Hand a batch to the recipient. Resolves once the provider admitted it. */
40
62
  dispatch(request: DispatchRequest): Promise<PromptDispatchDisposition>;
63
+ /** Bound the wait for the provider to admit a direct prompt. Unbounded when absent. */
64
+ awaitStart?(recipientId: string, started: Promise<void>): Promise<void>;
41
65
  onError(error: unknown, request: DispatchRequest): void;
42
66
  /** Return a cancellation function. Production uses the daemon's event loop. */
43
67
  schedule?: (delayMs: number, callback: () => void) => () => void;
44
68
  }
45
69
  export interface AgentMessageDelivery {
70
+ /** Admit a message that waits its turn. An interrupt releases at once, with everything queued. */
46
71
  enqueue(message: Message): Receipt;
72
+ /**
73
+ * Send a prompt that does not wait its turn. The messages admitted before it go ahead of it
74
+ * in the same provider prompt, so none starts a turn of its own afterwards. Its place is
75
+ * decided by this call, whenever the recipient gets to it. A command travels alone.
76
+ */
77
+ sendDirect<Result extends PromptDispatchResult>(direct: DirectPrompt, send: (joined: JoinedPrompt) => Promise<Result>): Promise<Result>;
47
78
  /** Remove matching messages that the queue still owns before dispatcher handoff. */
48
79
  withdrawPending(recipientId: string, matches: (source: AgentPromptSource) => boolean): number;
49
- /** Queued messages and provider dispatches still owned by this recipient. */
80
+ /** Messages and dispatches that will proceed without a new prompt. Held messages do not count. */
50
81
  hasPending(recipientId: string): boolean;
51
82
  /** Stop admission, flush pending messages, and await provider dispatch acknowledgments. */
52
83
  close(): Promise<void>;
53
- /** Completion waits include admitted messages, but return at permission checkpoints. */
84
+ /** Completion waits include admitted messages, but return at permission checkpoints and holds. */
54
85
  waitForDispatch(recipientId: string, signal: AbortSignal): Promise<void>;
55
86
  }
56
- /** Recipient-owned agent delivery. Human prompts never enter this module. */
87
+ /**
88
+ * Owns the order in which prompts reach a recipient. Delivery order equals admission order:
89
+ * only a prefix of the queue is ever dispatched, except a command a provider runs out of band.
90
+ *
91
+ * Every prompt for a recipient takes its place when it is admitted, and one operation at a
92
+ * time acts on the queue. A message stays in the queue until the provider admits the prompt
93
+ * that carries it, so agent messages, a person's prompts, and Stop all decide over the same list.
94
+ */
57
95
  export declare function createAgentMessageDelivery(dependencies: Dependencies): AgentMessageDelivery;
58
96
  export {};
59
97
  //# sourceMappingURL=delivery.d.ts.map