@getpaseo/protocol 0.2.5 → 0.3.0-beta.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/dist/messages.js CHANGED
@@ -55,8 +55,15 @@ const MutableBrowserToolsConfigSchema = z
55
55
  enabled: z.boolean().default(false),
56
56
  })
57
57
  .passthrough();
58
+ const MutableRelayConfigSchema = z
59
+ .object({
60
+ enabled: z.boolean(),
61
+ })
62
+ .passthrough();
58
63
  export const MutableDaemonConfigSchema = z
59
64
  .object({
65
+ // COMPAT(relayConfig): added in v0.2.6, remove after 2027-01-31 when old daemons are unsupported.
66
+ relay: MutableRelayConfigSchema.optional(),
60
67
  mcp: z
61
68
  .object({
62
69
  injectIntoAgents: z.boolean(),
@@ -73,6 +80,7 @@ export const MutableDaemonConfigSchema = z
73
80
  .passthrough();
74
81
  export const MutableDaemonConfigPatchSchema = z
75
82
  .object({
83
+ relay: MutableRelayConfigSchema.partial().optional(),
76
84
  mcp: MutableDaemonConfigSchema.shape.mcp.partial().optional(),
77
85
  browserTools: MutableBrowserToolsConfigSchema.partial().optional(),
78
86
  providers: z
@@ -160,6 +168,25 @@ export const ProviderSnapshotEntrySchema = z.object({
160
168
  description: z.string().optional(),
161
169
  defaultModeId: z.string().nullable().optional(),
162
170
  });
171
+ export const CompactProviderSnapshotModelSchema = AgentModelDefinitionSchema.omit({
172
+ provider: true,
173
+ thinkingOptions: true,
174
+ }).extend({
175
+ thinkingSet: z.number().int().nonnegative().optional(),
176
+ });
177
+ export const ProviderSnapshotThinkingSetSchema = z.object({
178
+ options: z.array(AgentSelectOptionSchema),
179
+ defaultOptionId: z.string().optional(),
180
+ });
181
+ export const CompactProviderSnapshotEntrySchema = ProviderSnapshotEntrySchema.omit({
182
+ models: true,
183
+ }).extend({
184
+ models: z.array(CompactProviderSnapshotModelSchema).optional(),
185
+ });
186
+ export const CompactProviderSnapshotSchema = z.object({
187
+ entries: z.array(CompactProviderSnapshotEntrySchema),
188
+ thinkingSets: z.array(ProviderSnapshotThinkingSetSchema),
189
+ });
163
190
  const AgentCapabilityFlagsSchema = z
164
191
  .object({
165
192
  supportsStreaming: z.boolean(),
@@ -464,15 +491,18 @@ export const AgentStreamEventPayloadSchema = z.discriminatedUnion("type", [
464
491
  z.object({
465
492
  type: z.literal("turn_started"),
466
493
  provider: AgentProviderSchema,
494
+ turnId: z.string().optional(),
467
495
  }),
468
496
  z.object({
469
497
  type: z.literal("turn_completed"),
470
498
  provider: AgentProviderSchema,
499
+ turnId: z.string().optional(),
471
500
  usage: AgentUsageSchema.optional(),
472
501
  }),
473
502
  z.object({
474
503
  type: z.literal("turn_failed"),
475
504
  provider: AgentProviderSchema,
505
+ turnId: z.string().optional(),
476
506
  error: z.string(),
477
507
  code: z.string().optional(),
478
508
  diagnostic: z.string().optional(),
@@ -480,6 +510,7 @@ export const AgentStreamEventPayloadSchema = z.discriminatedUnion("type", [
480
510
  z.object({
481
511
  type: z.literal("turn_canceled"),
482
512
  provider: AgentProviderSchema,
513
+ turnId: z.string().optional(),
483
514
  reason: z.string(),
484
515
  }),
485
516
  z.object({
@@ -534,6 +565,10 @@ const AgentRuntimeInfoSchema = z.object({
534
565
  modeId: z.string().nullable().optional(),
535
566
  extra: z.record(z.string(), z.unknown()).optional(),
536
567
  });
568
+ const AgentActiveTurnPayloadSchema = z.object({
569
+ turnId: z.string(),
570
+ startedAt: z.string().nullable(),
571
+ });
537
572
  export const AgentSnapshotPayloadSchema = z.object({
538
573
  id: z.string(),
539
574
  provider: AgentProviderSchema,
@@ -547,6 +582,7 @@ export const AgentSnapshotPayloadSchema = z.object({
547
582
  updatedAt: z.string(),
548
583
  lastUserMessageAt: z.string().nullable(),
549
584
  status: AgentStatusSchema,
585
+ activeTurn: AgentActiveTurnPayloadSchema.nullable().optional(),
550
586
  capabilities: AgentCapabilityFlagsSchema,
551
587
  currentModeId: z.string().nullable(),
552
588
  availableModes: z.array(AgentModeSchema),
@@ -640,6 +676,12 @@ export const UpdateAgentRequestMessageSchema = z.object({
640
676
  labels: z.record(z.string(), z.string()).optional(),
641
677
  requestId: z.string(),
642
678
  });
679
+ // The daemon accepts only image bytes chosen or acquired by the client. It must
680
+ // never fetch a user-provided URL on the host's network.
681
+ export const ProjectIconSourceSchema = z.discriminatedUnion("type", [
682
+ z.object({ type: z.literal("automatic") }),
683
+ z.object({ type: z.literal("upload"), data: z.string() }),
684
+ ]);
643
685
  export const ProjectRenameRequestSchema = z.object({
644
686
  type: z.literal("project.rename.request"),
645
687
  projectId: z.string(),
@@ -647,6 +689,12 @@ export const ProjectRenameRequestSchema = z.object({
647
689
  customName: z.string().nullable(),
648
690
  requestId: z.string(),
649
691
  });
692
+ export const ProjectIconSetRequestSchema = z.object({
693
+ type: z.literal("project.icon.set.request"),
694
+ projectId: z.string(),
695
+ source: ProjectIconSourceSchema,
696
+ requestId: z.string(),
697
+ });
650
698
  export const ProjectRemoveRequestSchema = z.object({
651
699
  type: z.literal("project.remove.request"),
652
700
  projectId: z.string(),
@@ -1060,6 +1108,8 @@ export const ListAvailableProvidersRequestMessageSchema = z.object({
1060
1108
  export const GetProvidersSnapshotRequestMessageSchema = z.object({
1061
1109
  type: z.literal("get_providers_snapshot_request"),
1062
1110
  cwd: z.string().optional(),
1111
+ // COMPAT(compactProviderSnapshots): old daemons ignore this field and return a full snapshot.
1112
+ ifNoneMatch: z.string().optional(),
1063
1113
  requestId: z.string(),
1064
1114
  });
1065
1115
  export const RefreshProvidersSnapshotRequestMessageSchema = z.object({
@@ -1131,6 +1181,13 @@ export const FetchAgentTimelineRequestMessageSchema = z.object({
1131
1181
  limit: z.number().int().nonnegative().optional(),
1132
1182
  // Default should be projected for app timeline loading.
1133
1183
  projection: z.enum(["projected", "canonical"]).optional(),
1184
+ // Allow the client to merge this bounded page outside its contiguous loaded range.
1185
+ mergeWindow: z.boolean().optional(),
1186
+ });
1187
+ export const AgentTimelineListPromptsRequestMessageSchema = z.object({
1188
+ type: z.literal("agent.timeline.list_prompts.request"),
1189
+ agentId: z.string(),
1190
+ requestId: z.string(),
1134
1191
  });
1135
1192
  export const ProviderSubagentListRequestMessageSchema = z.object({
1136
1193
  type: z.literal("agent.provider_subagents.list.request"),
@@ -1247,6 +1304,15 @@ export const ProjectRenameResponseSchema = z.object({
1247
1304
  type: z.literal("project.rename.response"),
1248
1305
  payload: ProjectRenameResponsePayloadSchema,
1249
1306
  });
1307
+ export const ProjectIconSetResponseSchema = z.object({
1308
+ type: z.literal("project.icon.set.response"),
1309
+ payload: z.object({
1310
+ requestId: z.string(),
1311
+ projectId: z.string(),
1312
+ accepted: z.boolean(),
1313
+ error: z.string().nullable(),
1314
+ }),
1315
+ });
1250
1316
  export const ProjectRemoveResponsePayloadSchema = z.object({
1251
1317
  requestId: z.string(),
1252
1318
  projectId: z.string(),
@@ -1857,6 +1923,11 @@ export const ProjectIconRequestSchema = z.object({
1857
1923
  cwd: z.string(),
1858
1924
  requestId: z.string(),
1859
1925
  });
1926
+ export const ProjectIconGetRequestSchema = z.object({
1927
+ type: z.literal("project.icon.get.request"),
1928
+ projectId: z.string(),
1929
+ requestId: z.string(),
1930
+ });
1860
1931
  export const FileDownloadTokenRequestSchema = z.object({
1861
1932
  type: z.literal("file_download_token_request"),
1862
1933
  cwd: z.string(),
@@ -2005,7 +2076,12 @@ export const UnsubscribeTerminalRequestSchema = z.object({
2005
2076
  });
2006
2077
  const TerminalClientMessageSchema = z.discriminatedUnion("type", [
2007
2078
  z.object({ type: z.literal("input"), data: z.string() }),
2008
- z.object({ type: z.literal("resize"), rows: z.number(), cols: z.number() }),
2079
+ z.object({
2080
+ type: z.literal("resize"),
2081
+ rows: z.number(),
2082
+ cols: z.number(),
2083
+ intent: z.enum(["claim", "update"]).optional(),
2084
+ }),
2009
2085
  z.object({
2010
2086
  type: z.literal("mouse"),
2011
2087
  row: z.number(),
@@ -2045,6 +2121,7 @@ export const HubExecutionAgentCreateRequestSchema = z.object({
2045
2121
  thinkingOptionId: z.string().optional(),
2046
2122
  featureValues: z.record(z.string(), z.unknown()).optional(),
2047
2123
  env: z.record(z.string(), z.string()).optional(),
2124
+ mcpServers: z.record(z.string(), McpServerConfigSchema).optional(),
2048
2125
  worktree: CreateAgentWorktreeTargetSchema.optional(),
2049
2126
  });
2050
2127
  export const HubExecutionControlActionSchema = z.enum(["interrupt", "archive"]);
@@ -2072,6 +2149,7 @@ export const SessionInboundMessageSchema = z.discriminatedUnion("type", [
2072
2149
  CloseItemsRequestMessageSchema,
2073
2150
  UpdateAgentRequestMessageSchema,
2074
2151
  ProjectRenameRequestSchema,
2152
+ ProjectIconSetRequestSchema,
2075
2153
  ProjectRemoveRequestSchema,
2076
2154
  WorkspaceTitleSetRequestSchema,
2077
2155
  WorkspacePinSetRequestSchema,
@@ -2111,6 +2189,7 @@ export const SessionInboundMessageSchema = z.discriminatedUnion("type", [
2111
2189
  RestartServerRequestMessageSchema,
2112
2190
  DaemonUpdateRequestMessageSchema,
2113
2191
  FetchAgentTimelineRequestMessageSchema,
2192
+ AgentTimelineListPromptsRequestMessageSchema,
2114
2193
  ProviderSubagentListRequestMessageSchema,
2115
2194
  ProviderSubagentTimelineRequestMessageSchema,
2116
2195
  SetAgentTimelineSubscriptionRequestMessageSchema,
@@ -2170,6 +2249,7 @@ export const SessionInboundMessageSchema = z.discriminatedUnion("type", [
2170
2249
  FileUnsubscribeRequestSchema,
2171
2250
  FileWriteRequestSchema,
2172
2251
  ProjectIconRequestSchema,
2252
+ ProjectIconGetRequestSchema,
2173
2253
  FileDownloadTokenRequestSchema,
2174
2254
  FileUploadRequestSchema,
2175
2255
  ClearAgentAttentionMessageSchema,
@@ -2370,10 +2450,18 @@ export const ServerInfoStatusPayloadSchema = z
2370
2450
  forgeSearch: z.boolean().optional(),
2371
2451
  // COMPAT(daemonStatusRpc): added in v0.1.76, remove gate after 2026-11-18.
2372
2452
  daemonStatusRpc: z.boolean().optional(),
2453
+ // COMPAT(relayConfig): added in v0.2.6, remove gate after 2027-01-31.
2454
+ relayConfig: z.boolean().optional(),
2373
2455
  // COMPAT(terminalRestoreModes): added in v0.1.81, remove gate after 2026-11-23.
2374
2456
  "terminal-restore-modes": z.boolean().optional(),
2457
+ // COMPAT(terminalInputModeReplay): added in v0.2.6, remove gate after 2027-02-02.
2458
+ "terminal-input-mode-replay": z.boolean().optional(),
2459
+ // COMPAT(terminalSizeOwnership): added in v0.2.6, remove gate after 2027-02-02.
2460
+ "terminal-size-ownership": z.boolean().optional(),
2375
2461
  // COMPAT(rewind): added in v0.1.X, drop the gate when floor >= v0.1.X.
2376
2462
  rewind: z.boolean().optional(),
2463
+ // COMPAT(agentTimelinePromptIndex): added in v0.2.X, drop the gate when floor >= v0.2.X.
2464
+ agentTimelinePromptIndex: z.boolean().optional(),
2377
2465
  // COMPAT(checkoutRefresh): added in v0.1.86, remove gate after 2026-11-29.
2378
2466
  checkoutRefresh: z.boolean().optional(),
2379
2467
  // COMPAT(workspaceMultiplicity): added in v0.1.97, drop the gate when floor >= v0.1.97
@@ -2430,10 +2518,16 @@ export const ServerInfoStatusPayloadSchema = z
2430
2518
  forgeProviders: z.boolean().optional(),
2431
2519
  // COMPAT(selectiveAgentTimeline): added in v0.1.106, remove after 2027-01-12.
2432
2520
  selectiveAgentTimeline: z.boolean().optional(),
2521
+ // COMPAT(canonicalSubmittedPrompts): added in v0.2.6, remove gate after 2027-01-30.
2522
+ canonicalSubmittedPrompts: z.boolean().optional(),
2523
+ // COMPAT(agentTurnIdentity): accept peers that observed pre-release v0.2.6 through 2027-01-31.
2524
+ agentTurnIdentity: z.boolean().optional(),
2433
2525
  // COMPAT(stableProjectIdentity): added in v0.1.109, remove gate after 2027-01-15.
2434
2526
  stableProjectIdentity: z.boolean().optional(),
2435
2527
  // COMPAT(workspaceScriptManagement): added in v0.1.105, remove gate after 2027-01-10.
2436
2528
  workspaceScriptManagement: z.boolean().optional(),
2529
+ // COMPAT(projectCustomIcon): added in v0.2.0, remove after 2027-01-20.
2530
+ projectCustomIcon: z.boolean().optional(),
2437
2531
  })
2438
2532
  .optional(),
2439
2533
  })
@@ -2672,8 +2766,14 @@ export const WorkspaceDescriptorPayloadSchema = z
2672
2766
  // value (customName) and projectCustomName mirrors the raw override so the
2673
2767
  // settings UI can prefill its input and offer a "reset" action.
2674
2768
  projectCustomName: z.string().nullable().optional(),
2769
+ // Identifies the project's stored custom icon; null means automatic.
2770
+ // COMPAT(projectCustomIcon): added in v0.2.0, remove after 2027-01-20.
2771
+ projectCustomIconRevision: z.string().nullable().optional(),
2675
2772
  projectRootPath: z.string(),
2676
2773
  workspaceDirectory: z.string().optional(),
2774
+ // COMPAT(worktreeSlug): added in v0.2.6, remove optional after 2027-01-31.
2775
+ // Present only for Paseo-owned worktrees; this is the basename of their root directory.
2776
+ worktreeSlug: z.string().optional(),
2677
2777
  projectKind: z.enum(["git", "non_git", "directory"]),
2678
2778
  // COMPAT(workspaces): keep legacy directory workspace kind parseable.
2679
2779
  workspaceKind: z.enum(["directory", "local_checkout", "checkout", "worktree"]),
@@ -2800,6 +2900,8 @@ export const WorkspaceProjectDescriptorPayloadSchema = z.object({
2800
2900
  projectKey: z.string().optional(),
2801
2901
  projectDisplayName: z.string(),
2802
2902
  projectCustomName: z.string().nullable().optional(),
2903
+ // COMPAT(projectCustomIcon): added in v0.2.0, remove after 2027-01-20.
2904
+ projectCustomIconRevision: z.string().nullable().optional(),
2803
2905
  projectRootPath: z.string(),
2804
2906
  projectKind: z.enum(["git", "non_git", "directory"]),
2805
2907
  });
@@ -3070,10 +3172,25 @@ export const FetchAgentTimelineResponseMessageSchema = z.object({
3070
3172
  endCursor: AgentTimelineCursorSchema.nullable(),
3071
3173
  hasOlder: z.boolean(),
3072
3174
  hasNewer: z.boolean(),
3175
+ mergeWindow: z.boolean().optional(),
3073
3176
  entries: z.array(AgentTimelineEntryPayloadSchema),
3074
3177
  error: z.string().nullable(),
3075
3178
  }),
3076
3179
  });
3180
+ export const AgentTimelineListPromptsResponseMessageSchema = z.object({
3181
+ type: z.literal("agent.timeline.list_prompts.response"),
3182
+ payload: z.object({
3183
+ requestId: z.string(),
3184
+ agentId: z.string(),
3185
+ epoch: z.string(),
3186
+ prompts: z.array(z.object({
3187
+ seq: z.number().int().nonnegative(),
3188
+ timestamp: z.string(),
3189
+ preview: z.string(),
3190
+ })),
3191
+ error: z.string().nullable(),
3192
+ }),
3193
+ });
3077
3194
  export const ProviderSubagentDescriptorPayloadSchema = z.object({
3078
3195
  id: z.string(),
3079
3196
  parentAgentId: z.string(),
@@ -3085,6 +3202,9 @@ export const ProviderSubagentDescriptorPayloadSchema = z.object({
3085
3202
  updatedAt: z.string(),
3086
3203
  toolCallId: z.string().nullable(),
3087
3204
  cwd: z.string().nullable().optional(),
3205
+ // Compact provider-owned context for the shared track. Providers choose what belongs here and
3206
+ // format it for display; clients must not parse provider-specific facts out of this string.
3207
+ subtitle: z.string().nullable().optional(),
3088
3208
  });
3089
3209
  export const ProviderSubagentListResponseMessageSchema = z.object({
3090
3210
  type: z.literal("agent.provider_subagents.list.response"),
@@ -3440,6 +3560,13 @@ const CheckoutStatusCommonSchema = z.object({
3440
3560
  cwd: z.string(),
3441
3561
  error: CheckoutErrorSchema.nullable(),
3442
3562
  requestId: z.string(),
3563
+ // The full ref currentBranch tracks, as git resolves `<branch>@{upstream}`:
3564
+ // "refs/remotes/origin/main", "refs/remotes/upstream/main" on a fork, or a
3565
+ // "refs/heads/..." ref for a branch tracking a local branch. Null when there is no
3566
+ // upstream. Clients use it verbatim — the remote is not necessarily origin and the
3567
+ // upstream branch name is not necessarily currentBranch, so composing one is wrong.
3568
+ // aheadOfOrigin/behindOfOrigin are measured against exactly this ref.
3569
+ upstreamRef: z.string().nullable().optional(),
3443
3570
  });
3444
3571
  const CheckoutStatusNotGitSchema = CheckoutStatusCommonSchema.extend({
3445
3572
  isGit: z.literal(false),
@@ -4008,6 +4135,8 @@ export const BranchSuggestionsResponseSchema = z.object({
4008
4135
  committerDate: z.number(),
4009
4136
  hasLocal: z.boolean().optional(),
4010
4137
  hasRemote: z.boolean().optional(),
4138
+ localAhead: z.number().int().nonnegative().optional(),
4139
+ localBehind: z.number().int().nonnegative().optional(),
4011
4140
  }))
4012
4141
  .optional(),
4013
4142
  error: z.string().nullable(),
@@ -4150,6 +4279,15 @@ export const ProjectIconResponseSchema = z.object({
4150
4279
  requestId: z.string(),
4151
4280
  }),
4152
4281
  });
4282
+ export const ProjectIconGetResponseSchema = z.object({
4283
+ type: z.literal("project.icon.get.response"),
4284
+ payload: z.object({
4285
+ projectId: z.string(),
4286
+ icon: ProjectIconSchema.nullable(),
4287
+ error: z.string().nullable(),
4288
+ requestId: z.string(),
4289
+ }),
4290
+ });
4153
4291
  export const FileDownloadTokenResponseSchema = z.object({
4154
4292
  type: z.literal("file_download_token_response"),
4155
4293
  payload: z.object({
@@ -4220,6 +4358,9 @@ export const GetProvidersSnapshotResponseMessageSchema = z.object({
4220
4358
  type: z.literal("get_providers_snapshot_response"),
4221
4359
  payload: z.object({
4222
4360
  entries: z.array(ProviderSnapshotEntrySchema),
4361
+ compactSnapshot: CompactProviderSnapshotSchema.optional(),
4362
+ snapshotHash: z.string().optional(),
4363
+ notModified: z.boolean().optional(),
4223
4364
  generatedAt: z.string(),
4224
4365
  requestId: z.string(),
4225
4366
  }),
@@ -4230,6 +4371,8 @@ export const ProvidersSnapshotUpdateMessageSchema = z.object({
4230
4371
  payload: z.object({
4231
4372
  cwd: z.string().optional(),
4232
4373
  entries: z.array(ProviderSnapshotEntrySchema),
4374
+ compactSnapshot: CompactProviderSnapshotSchema.optional(),
4375
+ snapshotHash: z.string().optional(),
4233
4376
  generatedAt: z.string(),
4234
4377
  }),
4235
4378
  });
@@ -4569,6 +4712,7 @@ export const SessionOutboundMessageSchema = z.discriminatedUnion("type", [
4569
4712
  ArchiveWorkspaceResponseMessageSchema,
4570
4713
  FetchAgentResponseMessageSchema,
4571
4714
  FetchAgentTimelineResponseMessageSchema,
4715
+ AgentTimelineListPromptsResponseMessageSchema,
4572
4716
  ProviderSubagentListResponseMessageSchema,
4573
4717
  ProviderSubagentTimelineResponseMessageSchema,
4574
4718
  ProviderSubagentUpdateMessageSchema,
@@ -4599,6 +4743,7 @@ export const SessionOutboundMessageSchema = z.discriminatedUnion("type", [
4599
4743
  AgentRewindResponseMessageSchema,
4600
4744
  UpdateAgentResponseMessageSchema,
4601
4745
  ProjectRenameResponseSchema,
4746
+ ProjectIconSetResponseSchema,
4602
4747
  ProjectRemoveResponseSchema,
4603
4748
  WorkspaceTitleSetResponseSchema,
4604
4749
  WorkspacePinSetResponseSchema,
@@ -4649,6 +4794,7 @@ export const SessionOutboundMessageSchema = z.discriminatedUnion("type", [
4649
4794
  FileWriteResponseSchema,
4650
4795
  FileUpdateSchema,
4651
4796
  ProjectIconResponseSchema,
4797
+ ProjectIconGetResponseSchema,
4652
4798
  FileDownloadTokenResponseSchema,
4653
4799
  FileUploadResponseSchema,
4654
4800
  ListProviderModelsResponseMessageSchema,
@@ -4720,6 +4866,7 @@ export const WSHelloMessageSchema = z.object({
4720
4866
  [CLIENT_CAPS.terminalReflowableSnapshot]: z.boolean().optional(),
4721
4867
  [CLIENT_CAPS.providerSubagents]: z.boolean().optional(),
4722
4868
  [CLIENT_CAPS.projectUpdates]: z.boolean().optional(),
4869
+ [CLIENT_CAPS.compactProviderSnapshots]: z.boolean().optional(),
4723
4870
  [CLIENT_CAPS.browserHost]: BrowserAutomationHostCapabilitySchema.optional(),
4724
4871
  })
4725
4872
  .passthrough()
@@ -0,0 +1,18 @@
1
+ import type { AgentModelDefinition, AgentSelectOption, ProviderSnapshotEntry } from "./agent-types.js";
2
+ export interface CompactProviderSnapshotModel extends Omit<AgentModelDefinition, "provider" | "thinkingOptions"> {
3
+ thinkingSet?: number;
4
+ }
5
+ export interface CompactProviderSnapshotEntry extends Omit<ProviderSnapshotEntry, "models"> {
6
+ models?: CompactProviderSnapshotModel[];
7
+ }
8
+ export interface ProviderSnapshotThinkingSet {
9
+ options: AgentSelectOption[];
10
+ defaultOptionId?: string;
11
+ }
12
+ export interface CompactProviderSnapshot {
13
+ entries: CompactProviderSnapshotEntry[];
14
+ thinkingSets: ProviderSnapshotThinkingSet[];
15
+ }
16
+ export declare function compactProviderSnapshot(entries: ProviderSnapshotEntry[]): CompactProviderSnapshot;
17
+ export declare function expandProviderSnapshot(snapshot: CompactProviderSnapshot): ProviderSnapshotEntry[];
18
+ //# sourceMappingURL=provider-snapshot-codec.d.ts.map
@@ -0,0 +1,71 @@
1
+ function thinkingSetKey(set) {
2
+ return JSON.stringify(set);
3
+ }
4
+ function compactModel({ provider: _provider, thinkingOptions, defaultThinkingOptionId, ...modelFields }, thinkingSets, thinkingSetIndexes) {
5
+ const compact = modelFields;
6
+ if (thinkingOptions === undefined) {
7
+ if (defaultThinkingOptionId !== undefined) {
8
+ compact.defaultThinkingOptionId = defaultThinkingOptionId;
9
+ }
10
+ return compact;
11
+ }
12
+ const thinkingSet = {
13
+ options: thinkingOptions,
14
+ ...(defaultThinkingOptionId !== undefined ? { defaultOptionId: defaultThinkingOptionId } : {}),
15
+ };
16
+ const key = thinkingSetKey(thinkingSet);
17
+ const existingIndex = thinkingSetIndexes.get(key);
18
+ if (existingIndex !== undefined) {
19
+ compact.thinkingSet = existingIndex;
20
+ return compact;
21
+ }
22
+ const index = thinkingSets.length;
23
+ thinkingSets.push(thinkingSet);
24
+ thinkingSetIndexes.set(key, index);
25
+ compact.thinkingSet = index;
26
+ return compact;
27
+ }
28
+ export function compactProviderSnapshot(entries) {
29
+ const thinkingSets = [];
30
+ const thinkingSetIndexes = new Map();
31
+ const compactEntries = entries.map((entry) => {
32
+ if (entry.models === undefined) {
33
+ return entry;
34
+ }
35
+ return {
36
+ ...entry,
37
+ models: entry.models.map((model) => compactModel(model, thinkingSets, thinkingSetIndexes)),
38
+ };
39
+ });
40
+ return { entries: compactEntries, thinkingSets };
41
+ }
42
+ function expandModel(provider, model, thinkingSets) {
43
+ const { thinkingSet: thinkingSetIndex, ...modelFields } = model;
44
+ if (thinkingSetIndex === undefined) {
45
+ return { provider, ...modelFields };
46
+ }
47
+ const thinkingSet = thinkingSets[thinkingSetIndex];
48
+ if (!thinkingSet) {
49
+ throw new RangeError(`Provider snapshot references missing thinking set ${thinkingSetIndex}`);
50
+ }
51
+ return {
52
+ provider,
53
+ ...modelFields,
54
+ thinkingOptions: thinkingSet.options,
55
+ ...(thinkingSet.defaultOptionId !== undefined
56
+ ? { defaultThinkingOptionId: thinkingSet.defaultOptionId }
57
+ : {}),
58
+ };
59
+ }
60
+ export function expandProviderSnapshot(snapshot) {
61
+ return snapshot.entries.map((entry) => {
62
+ const { models, ...entryFields } = entry;
63
+ if (models === undefined)
64
+ return entryFields;
65
+ return {
66
+ ...entryFields,
67
+ models: models.map((model) => expandModel(entryFields.provider, model, snapshot.thinkingSets)),
68
+ };
69
+ });
70
+ }
71
+ //# sourceMappingURL=provider-snapshot-codec.js.map
@@ -5,6 +5,8 @@ export interface TerminalInputModeFeedResult {
5
5
  export interface TerminalInputModeState {
6
6
  kittyKeyboardFlags: number;
7
7
  win32InputMode: boolean;
8
+ applicationCursorKeys?: boolean;
9
+ bracketedPaste?: boolean;
8
10
  }
9
11
  export declare const DEFAULT_TERMINAL_INPUT_MODE_STATE: TerminalInputModeState;
10
12
  export declare function terminalInputModeSupportsModifiedEnter(state: TerminalInputModeState): boolean;
@@ -12,6 +14,8 @@ export declare function terminalInputModeStatesEqual(left: TerminalInputModeStat
12
14
  export declare class TerminalInputModeTracker {
13
15
  private kittyKeyboardFlags;
14
16
  private win32InputMode;
17
+ private applicationCursorKeys;
18
+ private bracketedPaste;
15
19
  private readonly kittyKeyboardStack;
16
20
  private pending;
17
21
  feed(data: string): TerminalInputModeFeedResult;
@@ -1,9 +1,13 @@
1
1
  export const DEFAULT_TERMINAL_INPUT_MODE_STATE = {
2
2
  kittyKeyboardFlags: 0,
3
3
  win32InputMode: false,
4
+ applicationCursorKeys: false,
5
+ bracketedPaste: false,
4
6
  };
5
7
  const ESC = String.fromCharCode(0x1b);
8
+ const APPLICATION_CURSOR_KEYS_MODE = 1;
6
9
  const WIN32_INPUT_MODE = 9001;
10
+ const BRACKETED_PASTE_MODE = 2004;
7
11
  const CSI_INPUT_MODE_SEQUENCE = new RegExp(`${ESC}\\[(?:([<>=?]?)([0-9;]*)u|\\?([0-9;]*)([hl]))`, "g");
8
12
  const INCOMPLETE_CSI_INPUT_MODE_SEQUENCE = new RegExp(`${ESC}\\[[<>=?]?[0-9;]*$`);
9
13
  function parseFirstParam(params) {
@@ -34,12 +38,16 @@ export function terminalInputModeSupportsModifiedEnter(state) {
34
38
  }
35
39
  export function terminalInputModeStatesEqual(left, right) {
36
40
  return (left.kittyKeyboardFlags === right.kittyKeyboardFlags &&
37
- left.win32InputMode === right.win32InputMode);
41
+ left.win32InputMode === right.win32InputMode &&
42
+ Boolean(left.applicationCursorKeys) === Boolean(right.applicationCursorKeys) &&
43
+ Boolean(left.bracketedPaste) === Boolean(right.bracketedPaste));
38
44
  }
39
45
  export class TerminalInputModeTracker {
40
46
  constructor() {
41
47
  this.kittyKeyboardFlags = 0;
42
48
  this.win32InputMode = false;
49
+ this.applicationCursorKeys = false;
50
+ this.bracketedPaste = false;
43
51
  this.kittyKeyboardStack = [];
44
52
  this.pending = "";
45
53
  }
@@ -80,6 +88,8 @@ export class TerminalInputModeTracker {
80
88
  reset() {
81
89
  this.kittyKeyboardFlags = 0;
82
90
  this.win32InputMode = false;
91
+ this.applicationCursorKeys = false;
92
+ this.bracketedPaste = false;
83
93
  this.kittyKeyboardStack.length = 0;
84
94
  this.pending = "";
85
95
  }
@@ -87,6 +97,8 @@ export class TerminalInputModeTracker {
87
97
  return {
88
98
  kittyKeyboardFlags: this.kittyKeyboardFlags,
89
99
  win32InputMode: this.win32InputMode,
100
+ applicationCursorKeys: this.applicationCursorKeys,
101
+ bracketedPaste: this.bracketedPaste,
90
102
  };
91
103
  }
92
104
  getKittyKeyboardFlags() {
@@ -103,6 +115,12 @@ export class TerminalInputModeTracker {
103
115
  if (this.win32InputMode) {
104
116
  parts.push("\x1b[?9001h");
105
117
  }
118
+ if (this.applicationCursorKeys) {
119
+ parts.push("\x1b[?1h");
120
+ }
121
+ if (this.bracketedPaste) {
122
+ parts.push("\x1b[?2004h");
123
+ }
106
124
  return parts.join("");
107
125
  }
108
126
  applyKittyKeyboardSequence(prefix, params) {
@@ -140,12 +158,23 @@ export class TerminalInputModeTracker {
140
158
  }
141
159
  applyPrivateModeSequence(params, final) {
142
160
  const modes = parsePrivateModeParams(params);
143
- if (!modes.has(WIN32_INPUT_MODE)) {
144
- return false;
161
+ let changed = false;
162
+ if (modes.has(WIN32_INPUT_MODE)) {
163
+ const previous = this.win32InputMode;
164
+ this.win32InputMode = final === "h";
165
+ changed = this.win32InputMode !== previous || changed;
166
+ }
167
+ if (modes.has(APPLICATION_CURSOR_KEYS_MODE)) {
168
+ const previous = this.applicationCursorKeys;
169
+ this.applicationCursorKeys = final === "h";
170
+ changed = this.applicationCursorKeys !== previous || changed;
171
+ }
172
+ if (modes.has(BRACKETED_PASTE_MODE)) {
173
+ const previous = this.bracketedPaste;
174
+ this.bracketedPaste = final === "h";
175
+ changed = this.bracketedPaste !== previous || changed;
145
176
  }
146
- const previous = this.win32InputMode;
147
- this.win32InputMode = final === "h";
148
- return this.win32InputMode !== previous;
177
+ return changed;
149
178
  }
150
179
  }
151
180
  //# sourceMappingURL=terminal-input-mode.js.map
@@ -99,6 +99,9 @@ function csiWithModifier(finalByte, input) {
99
99
  const mod = modifierParam(input);
100
100
  return mod === 1 ? `\x1b[${finalByte}` : `\x1b[1;${mod}${finalByte}`;
101
101
  }
102
+ function ss3WithModifier(finalByte, input) {
103
+ return modifierParam(input) === 1 ? `\x1bO${finalByte}` : csiWithModifier(finalByte, input);
104
+ }
102
105
  function csiTilde(base, input) {
103
106
  const mod = modifierParam(input);
104
107
  return mod === 1 ? `\x1b[${base}~` : `\x1b[${base};${mod}~`;
@@ -133,16 +136,22 @@ function encodeFunctionKey(key, input) {
133
136
  return null;
134
137
  }
135
138
  }
136
- function encodeNavigationKey(key, input) {
139
+ function encodeArrowKey(finalByte, input, options) {
140
+ if (options.inputMode?.applicationCursorKeys) {
141
+ return ss3WithModifier(finalByte, input);
142
+ }
143
+ return csiWithModifier(finalByte, input);
144
+ }
145
+ function encodeNavigationKey(key, input, options) {
137
146
  switch (key) {
138
147
  case "ArrowUp":
139
- return csiWithModifier("A", input);
148
+ return encodeArrowKey("A", input, options);
140
149
  case "ArrowDown":
141
- return csiWithModifier("B", input);
150
+ return encodeArrowKey("B", input, options);
142
151
  case "ArrowRight":
143
- return csiWithModifier("C", input);
152
+ return encodeArrowKey("C", input, options);
144
153
  case "ArrowLeft":
145
- return csiWithModifier("D", input);
154
+ return encodeArrowKey("D", input, options);
146
155
  case "Home":
147
156
  return csiWithModifier("H", input);
148
157
  case "End":
@@ -190,7 +199,7 @@ export function encodeTerminalKeyInput(input, options = {}) {
190
199
  default:
191
200
  break;
192
201
  }
193
- const nav = encodeNavigationKey(key, input);
202
+ const nav = encodeNavigationKey(key, input, options);
194
203
  if (nav !== null)
195
204
  return nav;
196
205
  const fn = encodeFunctionKey(key, input);