@av-pi-studio/protocol 0.0.92 → 0.0.94

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
@@ -778,6 +778,251 @@ export const extensionPacksSetResponseSchema = z
778
778
  })
779
779
  .passthrough();
780
780
  // ===========================================================================
781
+ // Provider auth (sprint-055, features/provider-auth-rpc.md) — remote-driven Pi login flows.
782
+ // Five request/response pairs get real schemas + union membership (durable, multi-client RPC
783
+ // surface). The per-session progress push, `provider_auth_flow_event`, is deliberately NOT a
784
+ // union member — like `checkout_status_update`/`file_changed`, it rides
785
+ // `sessionMessageBaseSchema`'s passthrough fallback. Do not "fix" that by adding a schema for it.
786
+ //
787
+ // Every response requires `ok`; a domain failure is `{ ok: false, error: "<reason>" }` in the
788
+ // payload, never a chosen `rpc_error` code (`ws/router.ts` only emits `unknown_message_type` /
789
+ // `handler_error`, both reserved for transport-level failures).
790
+ // ===========================================================================
791
+ export const providerAuthTypeSchema = z.enum(["api_key", "oauth"]);
792
+ /** One provider's auth capability + current state (`configured: "unknown"` = a bounded
793
+ * `checkAuth()` timed out — see sprint-054's `checkAuthBounded` precedent). */
794
+ export const providerAuthInfoSchema = z
795
+ .object({
796
+ id: z.string(),
797
+ name: z.string(),
798
+ authTypes: z.array(providerAuthTypeSchema),
799
+ oauthLoginLabel: z.string().optional(),
800
+ oauthIsSubscription: z.boolean().optional(),
801
+ configured: z.union([z.boolean(), z.literal("unknown")]),
802
+ configuredType: providerAuthTypeSchema.optional(),
803
+ configuredSource: z.string().optional(),
804
+ })
805
+ .passthrough();
806
+ export const providerAuthListRequestSchema = z
807
+ .object({
808
+ type: z.literal("provider_auth_list_request"),
809
+ requestId: z.string(),
810
+ })
811
+ .passthrough();
812
+ export const providerAuthListResponseSchema = z
813
+ .object({
814
+ type: z.literal("provider_auth_list_response"),
815
+ requestId: z.string(),
816
+ payload: z
817
+ .object({
818
+ ok: z.boolean(),
819
+ providers: z.array(providerAuthInfoSchema).default([]),
820
+ error: z.string().optional(),
821
+ })
822
+ .passthrough(),
823
+ })
824
+ .passthrough();
825
+ export const providerAuthLoginRequestSchema = z
826
+ .object({
827
+ type: z.literal("provider_auth_login_request"),
828
+ requestId: z.string(),
829
+ provider: z.string(),
830
+ authType: providerAuthTypeSchema,
831
+ })
832
+ .passthrough();
833
+ export const providerAuthLoginResponseSchema = z
834
+ .object({
835
+ type: z.literal("provider_auth_login_response"),
836
+ requestId: z.string(),
837
+ payload: z
838
+ .object({
839
+ ok: z.boolean(),
840
+ flowId: z.string().optional(),
841
+ error: z.string().optional(),
842
+ })
843
+ .passthrough(),
844
+ })
845
+ .passthrough();
846
+ export const providerAuthRespondRequestSchema = z
847
+ .object({
848
+ type: z.literal("provider_auth_respond_request"),
849
+ requestId: z.string(),
850
+ flowId: z.string(),
851
+ promptId: z.string(),
852
+ value: z.string(),
853
+ })
854
+ .passthrough();
855
+ export const providerAuthRespondResponseSchema = z
856
+ .object({
857
+ type: z.literal("provider_auth_respond_response"),
858
+ requestId: z.string(),
859
+ payload: z
860
+ .object({
861
+ ok: z.boolean(),
862
+ error: z.string().optional(),
863
+ })
864
+ .passthrough(),
865
+ })
866
+ .passthrough();
867
+ export const providerAuthCancelRequestSchema = z
868
+ .object({
869
+ type: z.literal("provider_auth_cancel_request"),
870
+ requestId: z.string(),
871
+ flowId: z.string(),
872
+ })
873
+ .passthrough();
874
+ /** Idempotent — `ok: true` even when the named flow was already gone. */
875
+ export const providerAuthCancelResponseSchema = z
876
+ .object({
877
+ type: z.literal("provider_auth_cancel_response"),
878
+ requestId: z.string(),
879
+ payload: z.object({ ok: z.boolean() }).passthrough(),
880
+ })
881
+ .passthrough();
882
+ export const providerAuthLogoutRequestSchema = z
883
+ .object({
884
+ type: z.literal("provider_auth_logout_request"),
885
+ requestId: z.string(),
886
+ provider: z.string(),
887
+ })
888
+ .passthrough();
889
+ /** `stillConfigured` flags an ambient credential (e.g. an env var) surviving the logout. */
890
+ export const providerAuthLogoutResponseSchema = z
891
+ .object({
892
+ type: z.literal("provider_auth_logout_response"),
893
+ requestId: z.string(),
894
+ payload: z
895
+ .object({
896
+ ok: z.boolean(),
897
+ stillConfigured: z.boolean().optional(),
898
+ error: z.string().optional(),
899
+ })
900
+ .passthrough(),
901
+ })
902
+ .passthrough();
903
+ // ===========================================================================
904
+ // Extension UI (features/extension-ui-rpc.md) — additive, new in sprint-066
905
+ // ===========================================================================
906
+ /**
907
+ * A pending extension-UI dialog awaiting a client answer (list/reconnect-catch-up shape). Method
908
+ * semantics (which fields `payload` carries, how to render it) are entirely Pi's business — the
909
+ * daemon never interprets `payload`, only correlates and forwards it.
910
+ */
911
+ export const agentUiPendingRequestSchema = z
912
+ .object({
913
+ requestId: z.string(),
914
+ agentId: z.string(),
915
+ method: z.string(),
916
+ expectsResponse: z.boolean(),
917
+ payload: z.record(z.unknown()),
918
+ surfaceKey: z.string().optional(),
919
+ timeoutMs: z.number().optional(),
920
+ createdAt: wireTimestampSchema,
921
+ })
922
+ .passthrough();
923
+ /**
924
+ * A retained, last-value-wins extension-UI surface (status line, widget, title). Deleted (not
925
+ * listed) once its owning method sends a clearing update — see `agent_ui_request.removed`.
926
+ */
927
+ export const agentUiSurfaceSchema = z
928
+ .object({
929
+ agentId: z.string(),
930
+ method: z.string(),
931
+ surfaceKey: z.string(),
932
+ payload: z.record(z.unknown()),
933
+ updatedAt: wireTimestampSchema,
934
+ })
935
+ .passthrough();
936
+ /**
937
+ * Agent-scoped broadcast to every client — one per provider UI event, exactly like
938
+ * `agentPermissionRequestSchema`, not the `sessionMessageBaseSchema` passthrough family (this is a
939
+ * per-agent broadcast, not a per-session subscription push). `requestId` is daemon-minted, never the
940
+ * provider's own id. `removed: true` marks a surface-clearing update (no `payload` fields to render).
941
+ */
942
+ export const agentUiRequestSchema = z
943
+ .object({
944
+ type: z.literal("agent_ui_request"),
945
+ requestId: z.string(),
946
+ agentId: z.string(),
947
+ method: z.string(),
948
+ expectsResponse: z.boolean(),
949
+ payload: z.record(z.unknown()),
950
+ surfaceKey: z.string().optional(),
951
+ removed: z.boolean().optional(),
952
+ timeoutMs: z.number().optional(),
953
+ createdAt: wireTimestampSchema,
954
+ })
955
+ .passthrough();
956
+ /**
957
+ * Broadcast that lets every client dismiss a dialog once it is no longer answerable. `reason` is
958
+ * deliberately an open string (`answered` | `cancelled` | `timeout` | `aborted` documented, not
959
+ * enumerated) so the daemon can extend its taxonomy without narrowing the wire for older clients.
960
+ */
961
+ export const agentUiResolvedSchema = z
962
+ .object({
963
+ type: z.literal("agent_ui_resolved"),
964
+ requestId: z.string(),
965
+ agentId: z.string(),
966
+ reason: z.string(),
967
+ })
968
+ .passthrough();
969
+ /**
970
+ * The answer body forwarded to the provider. Deliberately permissive (every field optional,
971
+ * `.passthrough()`): method → response-shape validation is Pi's business, and a strict union keyed
972
+ * on `method` would reject a shape a future Pi UI method introduces, blocking that extension forever
973
+ * on a response the daemon refused to forward.
974
+ */
975
+ export const agentUiResponseSchema = z
976
+ .object({
977
+ value: z.string().optional(),
978
+ confirmed: z.boolean().optional(),
979
+ cancelled: z.boolean().optional(),
980
+ })
981
+ .passthrough();
982
+ export const agentUiRespondRequestSchema = z
983
+ .object({
984
+ type: z.literal("agent_ui_respond_request"),
985
+ requestId: z.string(),
986
+ uiRequestId: z.string(),
987
+ response: agentUiResponseSchema,
988
+ })
989
+ .passthrough();
990
+ /** `error` is an open string (`not_found` | `unsupported` documented, not enumerated). */
991
+ export const agentUiRespondResponseSchema = z
992
+ .object({
993
+ type: z.literal("agent_ui_respond_response"),
994
+ requestId: z.string(),
995
+ payload: z
996
+ .object({
997
+ ok: z.boolean(),
998
+ error: z.string().optional(),
999
+ })
1000
+ .passthrough(),
1001
+ })
1002
+ .passthrough();
1003
+ /** Reconnect catch-up: list current pending dialogs + retained surfaces, all agents or one. */
1004
+ export const agentUiListRequestSchema = z
1005
+ .object({
1006
+ type: z.literal("agent_ui_list_request"),
1007
+ requestId: z.string(),
1008
+ agentId: z.string().optional(),
1009
+ })
1010
+ .passthrough();
1011
+ export const agentUiListResponseSchema = z
1012
+ .object({
1013
+ type: z.literal("agent_ui_list_response"),
1014
+ requestId: z.string(),
1015
+ payload: z
1016
+ .object({
1017
+ ok: z.boolean(),
1018
+ pending: z.array(agentUiPendingRequestSchema),
1019
+ surfaces: z.array(agentUiSurfaceSchema),
1020
+ error: z.string().optional(),
1021
+ })
1022
+ .passthrough(),
1023
+ })
1024
+ .passthrough();
1025
+ // ===========================================================================
781
1026
  // RPC error
782
1027
  // ===========================================================================
783
1028
  export const rpcErrorSchema = z.object({
@@ -846,6 +1091,22 @@ export const sessionMessageSchema = z.discriminatedUnion("type", [
846
1091
  extensionPacksListResponseSchema,
847
1092
  extensionPacksSetRequestSchema,
848
1093
  extensionPacksSetResponseSchema,
1094
+ providerAuthListRequestSchema,
1095
+ providerAuthListResponseSchema,
1096
+ providerAuthLoginRequestSchema,
1097
+ providerAuthLoginResponseSchema,
1098
+ providerAuthRespondRequestSchema,
1099
+ providerAuthRespondResponseSchema,
1100
+ providerAuthCancelRequestSchema,
1101
+ providerAuthCancelResponseSchema,
1102
+ providerAuthLogoutRequestSchema,
1103
+ providerAuthLogoutResponseSchema,
1104
+ agentUiRequestSchema,
1105
+ agentUiResolvedSchema,
1106
+ agentUiRespondRequestSchema,
1107
+ agentUiRespondResponseSchema,
1108
+ agentUiListRequestSchema,
1109
+ agentUiListResponseSchema,
849
1110
  rpcErrorSchema,
850
1111
  ]);
851
1112
  /**
@@ -23,6 +23,7 @@ export declare const agentCapabilityFlagsSchema: z.ZodObject<{
23
23
  supportsRewindFiles: z.ZodOptional<z.ZodBoolean>;
24
24
  supportsRewindBoth: z.ZodOptional<z.ZodBoolean>;
25
25
  supportsSteering: z.ZodOptional<z.ZodBoolean>;
26
+ supportsExtensionUi: z.ZodOptional<z.ZodBoolean>;
26
27
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
27
28
  supportsStreaming: z.ZodBoolean;
28
29
  supportsSessionPersistence: z.ZodBoolean;
@@ -34,6 +35,7 @@ export declare const agentCapabilityFlagsSchema: z.ZodObject<{
34
35
  supportsRewindFiles: z.ZodOptional<z.ZodBoolean>;
35
36
  supportsRewindBoth: z.ZodOptional<z.ZodBoolean>;
36
37
  supportsSteering: z.ZodOptional<z.ZodBoolean>;
38
+ supportsExtensionUi: z.ZodOptional<z.ZodBoolean>;
37
39
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
38
40
  supportsStreaming: z.ZodBoolean;
39
41
  supportsSessionPersistence: z.ZodBoolean;
@@ -45,6 +47,7 @@ export declare const agentCapabilityFlagsSchema: z.ZodObject<{
45
47
  supportsRewindFiles: z.ZodOptional<z.ZodBoolean>;
46
48
  supportsRewindBoth: z.ZodOptional<z.ZodBoolean>;
47
49
  supportsSteering: z.ZodOptional<z.ZodBoolean>;
50
+ supportsExtensionUi: z.ZodOptional<z.ZodBoolean>;
48
51
  }, z.ZodTypeAny, "passthrough">>;
49
52
  export type AgentCapabilityFlags = z.infer<typeof agentCapabilityFlagsSchema>;
50
53
  /** UI metadata for a provider mode (plan/default/full-access/...). */
@@ -104,6 +107,7 @@ export declare const providerDefinitionSchema: z.ZodObject<{
104
107
  supportsRewindFiles: z.ZodOptional<z.ZodBoolean>;
105
108
  supportsRewindBoth: z.ZodOptional<z.ZodBoolean>;
106
109
  supportsSteering: z.ZodOptional<z.ZodBoolean>;
110
+ supportsExtensionUi: z.ZodOptional<z.ZodBoolean>;
107
111
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
108
112
  supportsStreaming: z.ZodBoolean;
109
113
  supportsSessionPersistence: z.ZodBoolean;
@@ -115,6 +119,7 @@ export declare const providerDefinitionSchema: z.ZodObject<{
115
119
  supportsRewindFiles: z.ZodOptional<z.ZodBoolean>;
116
120
  supportsRewindBoth: z.ZodOptional<z.ZodBoolean>;
117
121
  supportsSteering: z.ZodOptional<z.ZodBoolean>;
122
+ supportsExtensionUi: z.ZodOptional<z.ZodBoolean>;
118
123
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
119
124
  supportsStreaming: z.ZodBoolean;
120
125
  supportsSessionPersistence: z.ZodBoolean;
@@ -126,6 +131,7 @@ export declare const providerDefinitionSchema: z.ZodObject<{
126
131
  supportsRewindFiles: z.ZodOptional<z.ZodBoolean>;
127
132
  supportsRewindBoth: z.ZodOptional<z.ZodBoolean>;
128
133
  supportsSteering: z.ZodOptional<z.ZodBoolean>;
134
+ supportsExtensionUi: z.ZodOptional<z.ZodBoolean>;
129
135
  }, z.ZodTypeAny, "passthrough">>;
130
136
  }, "strip", z.ZodTypeAny, {
131
137
  id: string;
@@ -150,6 +156,7 @@ export declare const providerDefinitionSchema: z.ZodObject<{
150
156
  supportsRewindFiles?: boolean | undefined;
151
157
  supportsRewindBoth?: boolean | undefined;
152
158
  supportsSteering?: boolean | undefined;
159
+ supportsExtensionUi?: boolean | undefined;
153
160
  } & {
154
161
  [k: string]: unknown;
155
162
  };
@@ -176,6 +183,7 @@ export declare const providerDefinitionSchema: z.ZodObject<{
176
183
  supportsRewindFiles?: boolean | undefined;
177
184
  supportsRewindBoth?: boolean | undefined;
178
185
  supportsSteering?: boolean | undefined;
186
+ supportsExtensionUi?: boolean | undefined;
179
187
  } & {
180
188
  [k: string]: unknown;
181
189
  };
@@ -11,7 +11,8 @@ export const providerIdSchema = z.string().regex(/^[a-z][a-z0-9-]*$/, "invalid p
11
11
  /** Mode danger/intent tier driving UI color. */
12
12
  export const colorTierSchema = z.enum(["safe", "moderate", "dangerous", "planning"]);
13
13
  /** Per-provider capability flags. */
14
- export const agentCapabilityFlagsSchema = z.object({
14
+ export const agentCapabilityFlagsSchema = z
15
+ .object({
15
16
  supportsStreaming: z.boolean(),
16
17
  supportsSessionPersistence: z.boolean(),
17
18
  supportsDynamicModes: z.boolean(),
@@ -25,7 +26,12 @@ export const agentCapabilityFlagsSchema = z.object({
25
26
  // Steering capability (features/agent-sessions.md § Steering) — additive, optional. When true,
26
27
  // the provider accepts `steer`/`follow_up` messages injected into a live turn.
27
28
  supportsSteering: z.boolean().optional(),
28
- }).passthrough();
29
+ // Extension UI capability (features/extension-ui-rpc.md) — additive, optional. When true, the
30
+ // provider's `AgentSession` implements `onUiRequest`/`respondToUi` and dialogs/fire-and-forget
31
+ // extension UI methods are forwarded to clients instead of being auto-cancelled/dropped.
32
+ supportsExtensionUi: z.boolean().optional(),
33
+ })
34
+ .passthrough();
29
35
  /** UI metadata for a provider mode (plan/default/full-access/...). */
30
36
  export const providerModeSchema = z.object({
31
37
  id: z.string(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@av-pi-studio/protocol",
3
- "version": "0.0.92",
3
+ "version": "0.0.94",
4
4
  "files": [
5
5
  "dist",
6
6
  "!dist/**/*.map",