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.
Files changed (59) hide show
  1. package/NOTICE.md +2 -2
  2. package/README.md +18 -13
  3. package/client/account.tsx +13 -22
  4. package/client/goal-pills.ts +252 -0
  5. package/client/goal.tsx +203 -0
  6. package/index.client.tsx +4 -0
  7. package/index.server.ts +12 -4
  8. package/package.json +4 -4
  9. package/paseo-plugin.json +1 -1
  10. package/server/build-info.ts +1 -1
  11. package/server/diagnostics.ts +4 -1
  12. package/server/discovery/manifest.ts +2 -2
  13. package/server/errors.ts +1 -0
  14. package/server/goal-command.ts +32 -0
  15. package/server/goal.ts +58 -0
  16. package/server/host/bridge.ts +3 -0
  17. package/server/mapping.ts +23 -6
  18. package/server/presentation.ts +4 -1
  19. package/server/provider-status.ts +3 -3
  20. package/server/provider.ts +91 -21
  21. package/server/runtime/pins.ts +3 -3
  22. package/server/session.ts +278 -92
  23. package/server/turn-failure.ts +6 -1
  24. package/server/usage.ts +1 -3
  25. package/server/vendor/zcode/NOTICE.md +1 -1
  26. package/server/vendor/zcode/packages/rpc/src/channelClient.ts +18 -3
  27. package/server/vendor/zcode/packages/rpc/src/channelServer.ts +32 -12
  28. package/server/vendor/zcode/packages/rpc/src/channels.shared.ts +8 -1
  29. package/server/vendor/zcode/packages/rpc/src/serialization.ts +9 -3
  30. package/server/vendor/zcode/packages/shared/src/browser-use/command-metadata.ts +2 -0
  31. package/server/vendor/zcode/packages/shared/src/browser-use/commands.ts +2 -0
  32. package/server/vendor/zcode/packages/shared/src/browser-use/result.ts +4 -0
  33. package/server/vendor/zcode/packages/shared/src/gen-ui/contract.ts +246 -0
  34. package/server/vendor/zcode/packages/shared/src/gen-ui/tweakProtocol.ts +143 -0
  35. package/server/vendor/zcode/packages/shared/src/{localTtft.ts → local-ttft/contract.ts} +56 -1
  36. package/server/vendor/zcode/packages/shared/src/mcp-apps/contract.ts +8 -0
  37. package/server/vendor/zcode/packages/shared/src/official-mcp-auth.ts +8 -0
  38. package/server/vendor/zcode/packages/shared/src/protocol.ts +2 -0
  39. package/server/vendor/zcode/packages/shared/src/request-security-edition/verification-policy.ts +9 -1
  40. package/server/vendor/zcode/packages/shared/src/runtimeEnv.ts +10 -0
  41. package/server/vendor/zcode/packages/shared/src/server-remote.ts +2 -0
  42. package/server/vendor/zcode/packages/shared/src/source-server/compatibility.ts +11 -0
  43. package/server/vendor/zcode/packages/shared/src/source-server/contracts.ts +21 -1
  44. package/server/vendor/zcode/packages/shared/src/source-server/errorCodes.ts +27 -9
  45. package/server/vendor/zcode/packages/shared/src/subagent-profile.ts +5 -0
  46. package/server/vendor/zcode/packages/shared/src/validationAppSettings.ts +1 -0
  47. package/server/vendor/zcode/packages/shared/src/zcode-protocol/index.ts +164 -11
  48. package/server/vendor/zcode/packages/shared/src/zcode-protocol-legacy-types.ts +1 -0
  49. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/apply.ts +4 -2
  50. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/command.ts +11 -7
  51. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/delta.ts +2 -0
  52. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/input-intent.ts +2 -0
  53. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/rows.ts +19 -1
  54. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/snapshot.ts +11 -0
  55. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/transport.ts +20 -1
  56. package/server/vendor/zcode/packages/shared/src/zcode-protocol-v4/workflow-row-meta.ts +8 -0
  57. package/server/vendor/zcode/packages/ui/src/v4/conversationGoalSummaryModel.ts +88 -0
  58. package/server/vendor/zcode/provenance.json +78 -64
  59. package/shared/goal.ts +89 -0
package/server/session.ts CHANGED
@@ -15,6 +15,7 @@ import type {
15
15
  ConversationRow,
16
16
  TurnHeaderRow,
17
17
  } from "./vendor/zcode/packages/shared/src/zcode-protocol-v4/rows.js";
18
+ import type { GoalState } from "./vendor/zcode/packages/shared/src/zcode-protocol-v4/snapshot.js";
18
19
  import { Conversation, conversationCommand } from "./conversation.js";
19
20
  import {
20
21
  rowTimeline,
@@ -24,6 +25,7 @@ import {
24
25
  } from "./presentation.js";
25
26
  import { readModelSelection, resolveModelSelection } from "./models.js";
26
27
  import { uploadAttachments } from "./attachments.js";
28
+ import { parseGoalCommand, type GoalCommand } from "./goal-command.js";
27
29
  import {
28
30
  catalogModels,
29
31
  decodeModel,
@@ -99,6 +101,8 @@ export class ZCodeSession {
99
101
  private modelCatalog: readonly ModelOption[],
100
102
  private readonly timeline: () => TimelinePreferences,
101
103
  private readonly onClose: () => void,
104
+ /** False when Paseo's MCP servers replace the project's configuration. */
105
+ private readonly projectMcpServers: boolean,
102
106
  ) {
103
107
  assertSnapshotWorkspace(snapshot, workspace);
104
108
  this.id = snapshot.session.sessionId;
@@ -114,6 +118,7 @@ export class ZCodeSession {
114
118
  modelCatalog: readonly ModelOption[];
115
119
  timeline: () => TimelinePreferences;
116
120
  onClose: () => void;
121
+ projectMcpServers: boolean;
117
122
  }): Promise<ZCodeSession> {
118
123
  const session = new ZCodeSession(
119
124
  options.bridge,
@@ -123,6 +128,7 @@ export class ZCodeSession {
123
128
  options.modelCatalog,
124
129
  options.timeline,
125
130
  options.onClose,
131
+ options.projectMcpServers,
126
132
  );
127
133
  session.unlistenFailure = options.bridge.onFailure((error) =>
128
134
  session.runtimeFailed(error),
@@ -214,9 +220,16 @@ export class ZCodeSession {
214
220
  private observe(): void {
215
221
  if (!this.initialized || this.failed || this.closed) return;
216
222
  for (const row of this.state.rows.window) {
217
- if (row.kind === "userInput" && row.sourceCommandId) {
223
+ // ZCode has taken up an input once a row carries its command ID: its
224
+ // user input row, or the header of the turn it started. Compaction adds
225
+ // no user input row (ADR 28). Later turns can carry the same ID, as each
226
+ // turn toward a goal does; they are not that input again.
227
+ if (
228
+ (row.kind === "userInput" || row.kind === "turnHeader") &&
229
+ row.sourceCommandId
230
+ ) {
218
231
  const input = this.admissions.get(row.sourceCommandId);
219
- if (input) {
232
+ if (input && (row.kind === "userInput" || !input.consumed)) {
220
233
  input.consumed = true;
221
234
  input.productTurnId = this.productTurn(row);
222
235
  if (this.active?.inputs.has(row.sourceCommandId)) {
@@ -316,19 +329,18 @@ export class ZCodeSession {
316
329
  this.state.pendingInteractions.some(
317
330
  (i) => i.kind === "workspaceHookReview",
318
331
  )
319
- ) {
320
- const item: ProviderTimelineItem = {
321
- id: "zcode:hook-trust",
322
- type: "notification",
323
- level: "warning",
324
- message:
325
- "ZCode workspace hooks require trust review. Review them with the official zcode hooks trust command.",
326
- };
327
- if (!this.presented.has(item.id)) {
328
- this.presented.set(item.id, { item });
329
- this.runEvent({ type: "timeline", item });
330
- }
331
- }
332
+ )
333
+ this.warnOnce(
334
+ "zcode:hook-trust",
335
+ "ZCode workspace hooks require trust review. Review them with the official zcode hooks trust command.",
336
+ );
337
+ // ZCode 3.17 counts the project's declarations even when Paseo's servers
338
+ // replace them, so the warning only applies to the project's configuration.
339
+ if (this.projectMcpServers && this.state.workspaceMcpAdmission)
340
+ this.warnOnce(
341
+ "zcode:mcp-trust",
342
+ "ZCode has not started this project's MCP servers because they are not trusted. Trust them in ZCode Desktop under Settings → MCP Servers, then start a new session.",
343
+ );
332
344
  this.changed();
333
345
  const run = this.active;
334
346
  if (
@@ -371,6 +383,17 @@ export class ZCodeSession {
371
383
  );
372
384
  }
373
385
  }
386
+ private warnOnce(id: string, message: string): void {
387
+ if (this.presented.has(id)) return;
388
+ const item: ProviderTimelineItem = {
389
+ id,
390
+ type: "notification",
391
+ level: "warning",
392
+ message,
393
+ };
394
+ this.presented.set(id, { item });
395
+ this.runEvent({ type: "timeline", item });
396
+ }
374
397
  private maybeComplete(): void {
375
398
  const run = this.active;
376
399
  if (
@@ -466,6 +489,28 @@ export class ZCodeSession {
466
489
  hasActiveTurn(): boolean {
467
490
  return !!this.active;
468
491
  }
492
+ /**
493
+ * Whether closing loses no native work (Paseo's idle runtime cleanup).
494
+ * Background Bash, subagents and workflow runs outlive the foreground turn,
495
+ * and an active goal continues on its own. Only `running` work counts, as in
496
+ * ZCode's own `hasBackgroundWork`: a finished one stays `resultPending` even
497
+ * after the turn that delivered its result.
498
+ */
499
+ canStopRuntime(): boolean {
500
+ this.assertOpen();
501
+ const state = this.state;
502
+ return (
503
+ !this.active &&
504
+ !this.pendingAdmissions &&
505
+ this.conversation.idle &&
506
+ !state.pendingInteractions.length &&
507
+ !state.pendingCommands.length &&
508
+ !state.backgroundWorks.some((w) => w.status === "running") &&
509
+ !state.subagents?.running.length &&
510
+ state.goal?.status !== "active" &&
511
+ state.goal?.status !== "verifying"
512
+ );
513
+ }
469
514
  subscribe(listener: (event: NativeSessionEvent) => void): () => void {
470
515
  this.listeners.add(listener);
471
516
  listener({ type: "usage_updated", usage: usage(this.state) });
@@ -602,14 +647,210 @@ export class ZCodeSession {
602
647
  "SESSION_BUSY",
603
648
  "ZCode cannot accept this input in its current execution state",
604
649
  );
650
+ return this.admit(
651
+ previous,
652
+ {
653
+ clientMessageId: options?.clientMessageId,
654
+ releasesInteractions: options?.clearPendingPermissions === true,
655
+ },
656
+ async ({ commandId, assertSending, sending }) => {
657
+ const native = await mapPrompt(prompt, this.workspace);
658
+ if (!native.content.trim() && !native.attachments.length)
659
+ throw new AdapterError(
660
+ "UNSUPPORTED_CONTENT",
661
+ "ZCode requires nonempty input",
662
+ );
663
+ if (previous && native.content.trimStart().startsWith("/"))
664
+ throw new AdapterError(
665
+ "SESSION_BUSY",
666
+ "ZCode commands require an idle session",
667
+ );
668
+ // Text input does not interpret /goal; the model would read it as is.
669
+ if (parseGoalCommand(native.content))
670
+ throw new AdapterError(
671
+ "INVALID_CONFIGURATION",
672
+ "The /goal command requires a single text input without attachments",
673
+ );
674
+ await options?.beforeSend?.();
675
+ assertSending();
676
+ if (!previous && !this.state.queue.autoDrain)
677
+ await this.control("setAutoDrain", { autoDrain: true });
678
+ const attachments = await uploadAttachments(
679
+ this.bridge,
680
+ this.workspace,
681
+ this.id,
682
+ native.attachments,
683
+ assertSending,
684
+ );
685
+ assertSending();
686
+ const config = this.state.config;
687
+ if (!config.modelSelection?.options?.reasoningLevel)
688
+ throw new AdapterError(
689
+ "INVALID_CONFIGURATION",
690
+ "Select a ZCode model and reasoning level before sending",
691
+ );
692
+ sending();
693
+ const ack = await conversationCommand(
694
+ this.bridge,
695
+ this.workspace,
696
+ this.id,
697
+ "sendText",
698
+ {
699
+ text: native.content,
700
+ attachments,
701
+ modelSelection: config.modelSelection,
702
+ mode: config.mode,
703
+ planEnabled: config.planEnabled === true,
704
+ toolDisallowlist: [...UNSUPPORTED_TOOLS],
705
+ requestedDelivery: previous
706
+ ? attachments.length
707
+ ? "queue"
708
+ : "guide"
709
+ : "startNow",
710
+ },
711
+ { commandId },
712
+ );
713
+ if (["failed", "rejected", "stale", "noop"].includes(ack.status))
714
+ throw new AdapterError(
715
+ "NATIVE_INPUT_REJECTED",
716
+ "ZCode rejected the input",
717
+ );
718
+ if (
719
+ ack.status !== "accepted" ||
720
+ ack.result?.type !== "inputAccepted" ||
721
+ ack.result.inputId !== commandId
722
+ )
723
+ throw new AdapterError(
724
+ "NATIVE_PROTOCOL_ERROR",
725
+ "ZCode input acknowledgement is inconsistent",
726
+ );
727
+ },
728
+ );
729
+ }
730
+ /**
731
+ * `/goal <objective>` and `/goal resume`. ZCode records the goal and starts
732
+ * the turn that works toward it; that turn and its verification belong to
733
+ * this run. ZCode starts later iterations itself, as turns of their own.
734
+ */
735
+ async startGoal(
736
+ command: Extract<GoalCommand, { kind: "set" | "resume" }>,
737
+ options: { clientMessageId: string; beforeSend?: () => Promise<void> },
738
+ ): Promise<{ turnId: string }> {
739
+ this.assertIdle();
740
+ // The Server rejects the two together, in any order.
741
+ if (this.state.config.planEnabled)
742
+ throw new AdapterError(
743
+ "INVALID_CONFIGURATION",
744
+ "ZCode cannot work toward a goal in Plan mode. Turn Plan mode off first.",
745
+ );
746
+ if (
747
+ command.kind === "resume" &&
748
+ !this.state.availability.resumeGoal.allowed
749
+ )
750
+ throw new AdapterError(
751
+ "INVALID_CONFIGURATION",
752
+ "ZCode has no paused goal to resume",
753
+ );
754
+ return this.admit(
755
+ undefined,
756
+ {
757
+ clientMessageId: options.clientMessageId,
758
+ // Resuming adds no user input row; the turn it starts is the evidence.
759
+ consumed: command.kind === "resume",
760
+ },
761
+ async ({ commandId, assertSending, sending }) => {
762
+ await options.beforeSend?.();
763
+ assertSending();
764
+ if (!this.state.queue.autoDrain)
765
+ await this.control("setAutoDrain", { autoDrain: true });
766
+ assertSending();
767
+ const config = this.state.config;
768
+ if (!config.modelSelection?.options?.reasoningLevel)
769
+ throw new AdapterError(
770
+ "INVALID_CONFIGURATION",
771
+ "Select a ZCode model and reasoning level before sending",
772
+ );
773
+ sending();
774
+ // sendGoalCommand takes no toolDisallowlist; see ADR 27.
775
+ const ack =
776
+ command.kind === "resume"
777
+ ? await this.cas("resumeGoal", {})
778
+ : await conversationCommand(
779
+ this.bridge,
780
+ this.workspace,
781
+ this.id,
782
+ "sendGoalCommand",
783
+ {
784
+ text: command.objective,
785
+ displayText: command.displayText,
786
+ modelSelection: config.modelSelection,
787
+ mode: config.mode,
788
+ planEnabled: false,
789
+ },
790
+ { commandId },
791
+ );
792
+ if (ack.status !== "accepted")
793
+ throw new AdapterError(
794
+ "NATIVE_INPUT_REJECTED",
795
+ "ZCode rejected the goal command",
796
+ );
797
+ },
798
+ );
799
+ }
800
+ /**
801
+ * `/goal pause`, for a goal that stays active without a turn. Stopping a
802
+ * turn pauses its goal in ZCode itself.
803
+ */
804
+ async pauseGoal(): Promise<void> {
805
+ this.assertIdle();
806
+ // Typed during a turn, the command arrives after Paseo stopped that turn,
807
+ // which paused the goal already.
808
+ if (this.state.goal?.status === "paused") return;
809
+ if (!this.state.availability.pauseGoal.allowed)
810
+ throw new AdapterError(
811
+ "INVALID_CONFIGURATION",
812
+ "ZCode has no active goal to pause",
813
+ );
814
+ const ack = await this.cas("pauseGoal", {});
815
+ if (ack.status !== "accepted")
816
+ throw new AdapterError(
817
+ "NATIVE_INPUT_REJECTED",
818
+ "ZCode rejected the goal command",
819
+ );
820
+ await this.conversation.waitFor(
821
+ () => !this.state.availability.pauseGoal.allowed,
822
+ );
823
+ }
824
+ /** The goal of the conversation, for the Goal pill (ADR 27). */
825
+ goal(): GoalState | null {
826
+ return this.conversation.state?.goal ?? null;
827
+ }
828
+ /**
829
+ * Admits one input into a run. `send` prepares and issues the command; it
830
+ * calls `sending` before the command leaves and throws
831
+ * NATIVE_INPUT_REJECTED when ZCode refuses it.
832
+ */
833
+ private async admit(
834
+ previous: Run | undefined,
835
+ options: {
836
+ clientMessageId?: string;
837
+ releasesInteractions?: boolean;
838
+ consumed?: boolean;
839
+ },
840
+ send: (context: {
841
+ commandId: string;
842
+ assertSending: () => void;
843
+ sending: () => void;
844
+ }) => Promise<void>,
845
+ ): Promise<{ turnId: string }> {
605
846
  const run = previous ?? this.newRun();
606
847
  this.active = run;
607
848
  run.inFlight++;
608
849
  const commandId = randomUUID(),
609
850
  input: Admission = {
610
- clientMessageId: options?.clientMessageId,
851
+ clientMessageId: options.clientMessageId,
611
852
  accepted: false,
612
- consumed: false,
853
+ consumed: options.consumed === true,
613
854
  };
614
855
  run.inputs.set(commandId, input);
615
856
  this.admissions.set(commandId, input);
@@ -623,74 +864,17 @@ export class ZCodeSession {
623
864
  );
624
865
  };
625
866
  try {
626
- const native = await mapPrompt(prompt, this.workspace);
627
- if (!native.content.trim() && !native.attachments.length)
628
- throw new AdapterError(
629
- "UNSUPPORTED_CONTENT",
630
- "ZCode requires nonempty input",
631
- );
632
- if (previous && native.content.trimStart().startsWith("/"))
633
- throw new AdapterError(
634
- "SESSION_BUSY",
635
- "ZCode commands require an idle session",
636
- );
637
- await options?.beforeSend?.();
638
- assertSending();
639
- if (!previous && !this.state.queue.autoDrain)
640
- await this.control("setAutoDrain", { autoDrain: true });
641
- const attachments = await uploadAttachments(
642
- this.bridge,
643
- this.workspace,
644
- this.id,
645
- native.attachments,
867
+ await send({
868
+ commandId,
646
869
  assertSending,
647
- );
648
- assertSending();
649
- const config = this.state.config;
650
- if (!config.modelSelection?.options?.reasoningLevel)
651
- throw new AdapterError(
652
- "INVALID_CONFIGURATION",
653
- "Select a ZCode model and reasoning level before sending",
654
- );
655
- sent = true;
656
- const ack = await conversationCommand(
657
- this.bridge,
658
- this.workspace,
659
- this.id,
660
- "sendText",
661
- {
662
- text: native.content,
663
- attachments,
664
- modelSelection: config.modelSelection,
665
- mode: config.mode,
666
- planEnabled: config.planEnabled === true,
667
- toolDisallowlist: [...UNSUPPORTED_TOOLS],
668
- requestedDelivery: previous
669
- ? attachments.length
670
- ? "queue"
671
- : "guide"
672
- : "startNow",
870
+ sending: () => {
871
+ sent = true;
673
872
  },
674
- { commandId },
675
- );
676
- if (["failed", "rejected", "stale", "noop"].includes(ack.status))
677
- throw new AdapterError(
678
- "NATIVE_INPUT_REJECTED",
679
- "ZCode rejected the input",
680
- );
681
- if (
682
- ack.status !== "accepted" ||
683
- ack.result?.type !== "inputAccepted" ||
684
- ack.result.inputId !== commandId
685
- )
686
- throw new AdapterError(
687
- "NATIVE_PROTOCOL_ERROR",
688
- "ZCode input acknowledgement is inconsistent",
689
- );
873
+ });
690
874
  this.assertOpen();
691
875
  input.accepted = true;
692
- input.releasesInteractions = options?.clearPendingPermissions === true;
693
- if (options?.clientMessageId)
876
+ input.releasesInteractions = options.releasesInteractions === true;
877
+ if (options.clientMessageId)
694
878
  this.emit({
695
879
  type: "prompt_accepted",
696
880
  clientMessageId: options.clientMessageId,
@@ -718,6 +902,15 @@ export class ZCodeSession {
718
902
  }
719
903
  }
720
904
  private async control(type: string, payload: unknown): Promise<void> {
905
+ const ack = await this.cas(type, payload);
906
+ if (ack.status !== "accepted" && ack.status !== "noop")
907
+ throw new AdapterError(
908
+ "NATIVE_PROTOCOL_ERROR",
909
+ `ZCode ${type} was rejected`,
910
+ );
911
+ }
912
+ /** Sends a command that carries the revision it was decided on. */
913
+ private async cas(type: string, payload: unknown) {
721
914
  this.assertOpen();
722
915
  // A stale CAS proves no mutation occurred. No input is retried here.
723
916
  let revision = this.state.revision;
@@ -730,12 +923,7 @@ export class ZCodeSession {
730
923
  payload,
731
924
  { revision },
732
925
  );
733
- if (ack.status === "accepted" || ack.status === "noop") return;
734
- if (ack.status !== "stale")
735
- throw new AdapterError(
736
- "NATIVE_PROTOCOL_ERROR",
737
- `ZCode ${type} was rejected`,
738
- );
926
+ if (ack.status !== "stale") return ack;
739
927
  revision = ack.revisionAtDecision;
740
928
  }
741
929
  throw new AdapterError(
@@ -795,13 +983,11 @@ export class ZCodeSession {
795
983
  const target = this.state.control.activeWorks.find(
796
984
  (w) => w.foregroundExecutionId,
797
985
  )?.foregroundExecutionId;
798
- if (this.state.control.canStop && !target)
799
- throw new AdapterError(
800
- "NATIVE_PROTOCOL_ERROR",
801
- "ZCode did not identify its stoppable foreground execution",
802
- );
986
+ // The ID keeps a late stop from ending a later execution. The works of a
987
+ // manual compaction name none; like ZCode Desktop, stop without one then.
803
988
  if (target)
804
989
  await this.control("stop", { expectedForegroundExecutionId: target });
990
+ else if (this.state.control.canStop) await this.control("stop", {});
805
991
  await this.conversation.waitFor(
806
992
  () =>
807
993
  !this.state.control.canStop &&
@@ -29,6 +29,7 @@ const reasonCodes: Partial<Record<ModelFailureReason, TurnFailureCode>> = {
29
29
  tls_error: "MODEL_NETWORK_ERROR",
30
30
  server_error: "MODEL_PROVIDER_ERROR",
31
31
  provider_overloaded: "MODEL_PROVIDER_ERROR",
32
+ content_filter: "MODEL_CONTENT_FILTERED",
32
33
  };
33
34
 
34
35
  const messages: Record<
@@ -38,7 +39,7 @@ const messages: Record<
38
39
  NATIVE_TURN_FAILED: ["ZCode turn failed"],
39
40
  MODEL_RATE_LIMITED: [
40
41
  "The model provider's usage or rate limit was reached",
41
- "Wait for it to reset or switch models. For a ZCode Coding Plan, Paseo 0.11 and later show the reset times on the Usage screen.",
42
+ "Wait for it to reset or switch models. For a ZCode Coding Plan, Paseo shows the reset times on the Usage screen.",
42
43
  ],
43
44
  MODEL_AUTH_FAILED: [
44
45
  "The model provider is not signed in or rejected the credentials",
@@ -56,6 +57,10 @@ const messages: Record<
56
57
  "The model provider returned a server error or is overloaded",
57
58
  "Try again later.",
58
59
  ],
60
+ MODEL_CONTENT_FILTERED: [
61
+ "The model provider's content filter blocked the reply",
62
+ "Rephrase the request or switch models.",
63
+ ],
59
64
  MODEL_REQUEST_FAILED: ["The model provider rejected the request"],
60
65
  };
61
66
 
package/server/usage.ts CHANGED
@@ -1,6 +1,4 @@
1
1
  import { createHash } from "node:crypto";
2
- // Types only, from the module every supported Paseo resolves; Paseo 0.9–0.10
3
- // reject `@getpaseo/plugin/server/usage` even as a type import.
4
2
  import type {
5
3
  UsageReport,
6
4
  UsageSourceRegistration,
@@ -234,7 +232,7 @@ export interface UsageSourceOptions {
234
232
  }
235
233
 
236
234
  /**
237
- * Coding Plan quota for Paseo's Usage screen (Paseo 0.11+), read through
235
+ * Coding Plan quota for Paseo's Usage screen, read through
238
236
  * ZCode's official usage-stats service on the account Server (ADR 18).
239
237
  */
240
238
  export function createUsageSource(
@@ -49,7 +49,7 @@ AI 生成的代码、命令、解释、文件和建议可能存在错误、遗
49
49
  | 手机远程控制 | 启用远程控制并完成配对后,桌面与手机网页经外部 relay 交换会话内容、输入、任务状态、权限请求与附件预览等协议消息;relay 负责鉴权、配对、心跳与消息透传,不运行任务。配对与连接会发送设备、窗口与会话标识。relay 地址随发行配置确定,可由 `ZCODE_WEB_REMOTE_CONTROL_RELAY_WS_URL` 覆盖。 |
50
50
  | Bots 第三方聊天接入 | 配置 Bot 后,所选第三方聊天平台(如 Telegram、飞书/Lark)的消息可驱动任务;Bot 按回复模式把助手回复、工具调用、文件变更摘要及权限请求发送到该平台,平台方可获得这些内容。Bot 凭据保存在本地凭据服务,配置文件只保存引用。 |
51
51
  | 营销触达与奖励中心 | 登录后可从业务服务获取营销 Banner/弹窗配置及资源包并展示;点击、关闭等操作会上报确认/取消事件,领取类操作会调用套餐领取接口。奖励中心以内嵌网页打开,桥接接口向该页面提供主题、语言和登录状态。 |
52
- | 安装、插件获取、远端部署与更新 | 安装、发现、认证、部署和更新会访问仓库、包服务、插件市场、CDN 或更新服务器;统一 CLI 安装脚本会从配置的分发源读取版本清单并下载发行包。桌面自动更新受发行形态和运行条件控制,启用后可在启动及周期检查时请求更新清单,携带平台、渠道、设备等信息;平台取值可区分架构,版本信息还会影响更新选择。开源构建默认不启用自动更新(构建期可选能力);启用时,开发构建与打包版都接受 `ZCODE_UPDATE_FEED_URL` 环境变量及 `--zcode-update-feed-url` 启动参数覆盖更新源,用于诊断与应急。下载的代码可能随后被安装或执行,远端部署还可能将本地已有或下载的组件上传/复制到目标环境。下载检查、实际安装及运行组件的控制条件不同,不能统一描述成每步都先弹出确认。 |
52
+ | 安装、插件获取、远端部署与更新 | 安装、发现、认证、部署和更新会访问仓库、包服务、插件市场、CDN 或更新服务器;统一 CLI 安装脚本会从配置的分发源读取版本清单并下载发行包。桌面自动更新受发行形态和运行条件控制,启用后可在启动及周期检查时请求更新清单,携带平台、渠道、设备等信息;平台取值可区分架构,版本信息还会影响更新选择。开源构建默认不启用自动更新(构建期可选能力);启用时,仅未打包开发态接受 `ZCODE_UPDATE_FEED_URL` 环境变量及 `--zcode-update-feed-url` 启动参数覆盖更新源,用于诊断;打包应用忽略这两个入口,继续使用既有服务端 manifest 入口。下载的代码可能随后被安装或执行,远端部署还可能将本地已有或下载的组件上传/复制到目标环境。下载检查、实际安装及运行组件的控制条件不同,不能统一描述成每步都先弹出确认。 |
53
53
  | 工具、Hook、工作流与自动任务的交付或发布 | Shell、终端、Git、Node REPL、浏览器、插件、MCP 或工作流可以读取任务涉及的数据、向相应目标服务上传文件或生成物,并改变外部服务状态;生命周期 Hook 和已配置的定时/后台任务也可触发程序。权限规则、模式、插件配置及系统账号决定执行范围,不能保证每份外发内容都由用户逐项选择或每次外发都有独立确认。发布、发送、购买或部署完成后,本地取消或撤销不一定能恢复外部状态;权限边界见第二节。 |
54
54
  | 开发测试、调试与请求录制 | 显式运行相关开发工具时,可向配置的真实模型或工具服务发送测试提示、样例资料及认证头;配置为真实上游的录制代理可转发请求,不能因名称含测试/录制就认为完全离线。请求轨迹和调试文件还可能在本地保存模型内容;这些工具的触发入口与普通产品运行不同。 |
55
55
  | 构建、签名与维护者发布 | 显式运行安装、构建或发布脚本时,可下载依赖、原生二进制和运行时,将构建材料复制到发布共享目录、推送 Git,或交给签名工具、Apple 公证服务处理。外部签名工具及另行配置的 CI、存储和分发服务具有自己的网络行为;本仓未展开的流程不能仅凭脚本名称推定已核验。相关调用具有不同的启动入口、环境和凭据要求。CLI SEA 共享目录发布与上传会先校验第三方声明材料,校验失败会阻断该发布流程。当前 native-search 准备步骤按目标平台校验并解包仓库内置归档,本步骤不下载这些归档;Node 等其他组件有各自的下载链路。 |
@@ -99,6 +99,7 @@ export class ChannelClient implements IChannelClient, IDisposable {
99
99
  "taskId",
100
100
  "traceId",
101
101
  "retryable",
102
+ "profileId",
102
103
  ] as const;
103
104
  for (const key of passthroughKeys) {
104
105
  const value = response.data[key];
@@ -170,7 +171,18 @@ export class ChannelClient implements IChannelClient, IDisposable {
170
171
  });
171
172
 
172
173
  this.handlers.set(id, (response) => {
173
- emitter.fire((response as { data: any }).data);
174
+ if (response.type === ResponseType.EventFire) {
175
+ emitter.fire(response.data);
176
+ } else if (response.type === ResponseType.EventError) {
177
+ // 订阅失败必须结束其监听器,不能把错误对象写入终端等正常事件流,也不能继续保留旧请求。
178
+ this.handlers.delete(id);
179
+ this.activeRequests.delete(emitter);
180
+ emitter.dispose();
181
+ const error = new Error(response.data.message);
182
+ error.name = response.data.name;
183
+ if (response.data.stack) error.stack = response.data.stack.join("\n");
184
+ console.error(`RPC event subscription failed: ${channelName}.${name}`, error);
185
+ }
174
186
  });
175
187
 
176
188
  return emitter.event;
@@ -208,9 +220,11 @@ export class ChannelClient implements IChannelClient, IDisposable {
208
220
  }
209
221
 
210
222
  private onBuffer(message: VSBuffer): void {
223
+ // 修复原因:同一 protocol 上还有反向 ChannelServer(host ↔ 远端 WebSocket 两端都是),对方发来的
224
+ // 请求也会到这里。原来先解码消息体再判断类型,每条请求都被完整解码两次,大请求(例如数据同步的
225
+ // 归档)白白多花一倍 CPU。修法:先读消息头,只解码属于本端的响应体。
211
226
  const reader = new BufferReader(message);
212
227
  const header = deserialize(reader);
213
- const body = deserialize(reader);
214
228
  const type = header[0] as ResponseType;
215
229
 
216
230
  switch (type) {
@@ -220,11 +234,12 @@ export class ChannelClient implements IChannelClient, IDisposable {
220
234
  case ResponseType.PromiseSuccess:
221
235
  case ResponseType.PromiseError:
222
236
  case ResponseType.EventFire:
237
+ case ResponseType.EventError:
223
238
  case ResponseType.PromiseErrorObj:
224
239
  this.onResponse({
225
240
  type,
226
241
  id: header[1],
227
- data: body,
242
+ data: deserialize(reader),
228
243
  } as IRawResponse);
229
244
  return;
230
245
  }