@wippy-fe/types-global-proxy 0.0.63 → 0.0.65

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 (2) hide show
  1. package/index.d.ts +282 -118
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -58,7 +58,7 @@ interface HostComponentPanelDef extends HostPanelBase {
58
58
  tagName: string;
59
59
  }
60
60
  /**
61
- * Built-in panel ids shipped by gen-2-chat. The `@HOST/` prefix marks
61
+ * Built-in panel ids shipped by the Wippy Web Host. The `@HOST/` prefix marks
62
62
  * them as framework-owned so consumers can later plug in their own
63
63
  * `kind: 'builtin'` ids without colliding (and so the declaration
64
64
  * shows ownership at a glance).
@@ -348,100 +348,110 @@ type ApiRoutesOverride = {
348
348
  };
349
349
  };
350
350
 
351
- var chat = {
352
- emptyState: {
353
- title: "No chat session selected",
354
- description: "Please select a session from the dropdown above or start a new conversation.",
355
- goToHome: "Go to Home Page",
356
- loadingAgents: "Loading agents...",
357
- selectAgent: "Select Agent",
358
- startChat: "Start Chat",
359
- startChatError: "Failed to start chat",
360
- noAgents: "No agents available. Please contact your administrator.",
361
- dropFiles: "Drop files here to upload"
362
- },
363
- contextMenu: {
364
- copyConversation: "Copy conversation",
365
- copySelection: "Copy selection",
366
- copySessionLink: "Copy session link",
367
- copySessionJson: "Copy session JSON (debug)",
368
- copied: "Copied",
369
- copiedDetail: "Copied to clipboard",
370
- copyFailed: "Copy failed",
371
- copyFailedDetail: "Could not copy to clipboard",
372
- nothingToCopy: "Nothing to copy yet"
373
- }
374
- };
375
- var customPage = {
376
- loading: {
377
- title: "Loading page content..."
378
- },
379
- error: {
380
- title: "Failed to load page content"
381
- }
382
- };
383
- var home = {
384
- loading: "Application is Loading",
385
- error: {
386
- title: "Error Loading Application"
387
- },
388
- noHomePage: {
389
- title: "No Home Page Detected",
390
- message: "Probably backend configuration is malformed"
391
- }
392
- };
393
- var app = {
394
- title: "Wippy App",
395
- appName: "Wippy",
396
- icon: "wippy:logo"
397
- };
398
- var login = {
399
- error: {
400
- title: "Session Token Expired",
401
- description: "Your session has expired or is no longer valid. Please close this window and log in again to continue."
402
- }
403
- };
404
- var logout = {
405
- title: "Logout",
406
- description: "Logging out..."
407
- };
408
- var keeper = {
409
- controls: {
410
- newChat: "New Chat",
411
- searchAgents: "Search agents...",
412
- undo: "Undo",
413
- redo: "Redo",
414
- download: "Registry To File System",
415
- upload: "File System To Registry",
416
- codeAssistant: "Wippy Code Assistant",
417
- syncControls: "Sync Controls",
418
- confirmUpload: {
419
- title: "Confirm Upload",
420
- message: "Do you wish to upload file system changes to registry? This will overwrite current state",
421
- cancel: "Cancel",
422
- upload: "Upload",
423
- cancelled: {
424
- title: "Upload cancelled",
425
- message: "The upload operation was cancelled"
426
- }
427
- }
428
- },
429
- version: {
430
- label: "Version:",
431
- tooltip: "Version {{version}}"
432
- }
433
- };
434
- var textRS = {
435
- chat: chat,
436
- customPage: customPage,
437
- home: home,
438
- app: app,
439
- login: login,
440
- logout: logout,
441
- keeper: keeper
351
+ declare const defaultLNG: "en";
352
+ declare const defaultNS: "text";
353
+ declare const resources: {
354
+ readonly en: {
355
+ readonly text: {
356
+ chat: {
357
+ emptyState: {
358
+ title: string;
359
+ description: string;
360
+ goToHome: string;
361
+ loadingAgents: string;
362
+ selectAgent: string;
363
+ startChat: string;
364
+ startChatError: string;
365
+ noAgents: string;
366
+ dropFiles: string;
367
+ };
368
+ contextMenu: {
369
+ copyConversation: string;
370
+ copySelection: string;
371
+ copySessionLink: string;
372
+ copySessionJson: string;
373
+ copied: string;
374
+ copiedDetail: string;
375
+ copyFailed: string;
376
+ copyFailedDetail: string;
377
+ nothingToCopy: string;
378
+ };
379
+ };
380
+ customPage: {
381
+ loading: {
382
+ title: string;
383
+ };
384
+ error: {
385
+ title: string;
386
+ };
387
+ };
388
+ home: {
389
+ loading: string;
390
+ error: {
391
+ title: string;
392
+ };
393
+ noHomePage: {
394
+ title: string;
395
+ message: string;
396
+ };
397
+ };
398
+ app: {
399
+ title: string;
400
+ appName: string;
401
+ icon: string;
402
+ };
403
+ login: {
404
+ error: {
405
+ title: string;
406
+ description: string;
407
+ };
408
+ };
409
+ logout: {
410
+ title: string;
411
+ description: string;
412
+ };
413
+ keeper: {
414
+ controls: {
415
+ newChat: string;
416
+ searchAgents: string;
417
+ undo: string;
418
+ redo: string;
419
+ download: string;
420
+ upload: string;
421
+ codeAssistant: string;
422
+ syncControls: string;
423
+ confirmUpload: {
424
+ title: string;
425
+ message: string;
426
+ cancel: string;
427
+ upload: string;
428
+ cancelled: {
429
+ title: string;
430
+ message: string;
431
+ };
432
+ };
433
+ };
434
+ version: {
435
+ label: string;
436
+ tooltip: string;
437
+ };
438
+ };
439
+ };
440
+ readonly feature: {
441
+ session: {
442
+ type: string;
443
+ };
444
+ history: string;
445
+ env: {
446
+ APP_API_URL: string;
447
+ APP_AUTH_API_URL: string;
448
+ APP_WEBSOCKET_URL: string;
449
+ };
450
+ };
451
+ readonly css: {};
452
+ };
442
453
  };
443
-
444
- type I18NTextTypes = typeof textRS;
454
+ type I18NTextTypes = (typeof resources)[typeof defaultLNG][typeof defaultNS];
445
455
 
446
456
  interface IconDef {
447
457
  body: string;
@@ -759,6 +769,128 @@ interface SanitizeOptions {
759
769
  extraTags?: Record<string, string[]>;
760
770
  }
761
771
 
772
+ /** An error for one question. A form-level error that names an unknown question also has `field`. */
773
+ interface ArtifactFormFieldError {
774
+ code: string;
775
+ message: string;
776
+ field?: string;
777
+ }
778
+ declare const ARTIFACT_STATE_ERROR_BRAND: unique symbol;
779
+ /**
780
+ * Rejection type of `artifactState()` calls. Prefer `isArtifactStateError()`:
781
+ * each proxy bundle carries its own copy of this class, so `instanceof` fails
782
+ * for an error thrown by another bundle.
783
+ */
784
+ declare class ArtifactStateError extends Error {
785
+ readonly status?: number;
786
+ readonly code?: string;
787
+ readonly errors?: Record<string, ArtifactFormFieldError[]>;
788
+ readonly formErrors?: ArtifactFormFieldError[];
789
+ readonly [ARTIFACT_STATE_ERROR_BRAND] = true;
790
+ constructor(message: string, options?: {
791
+ status?: number;
792
+ code?: string;
793
+ errors?: Record<string, ArtifactFormFieldError[]>;
794
+ formErrors?: ArtifactFormFieldError[];
795
+ cause?: unknown;
796
+ });
797
+ }
798
+
799
+ interface ArtifactFormFieldOption {
800
+ value: string;
801
+ label: string;
802
+ description?: string;
803
+ }
804
+ interface ArtifactFormField {
805
+ id: string;
806
+ type: 'choice';
807
+ label: string;
808
+ description?: string;
809
+ required: boolean;
810
+ options: ArtifactFormFieldOption[];
811
+ multiple: boolean;
812
+ allow_other: boolean;
813
+ }
814
+ interface ArtifactFormDefinition {
815
+ title: string;
816
+ description?: string;
817
+ submit_label?: string;
818
+ /** The text of the user's chat message once the form is answered. The form never shows it. */
819
+ answered_message?: string;
820
+ fields: ArtifactFormField[];
821
+ }
822
+ /**
823
+ * One answer to a choice: a listed option, a listed option with the user's
824
+ * note, or text the user wrote instead of an option. A stored answer with a
825
+ * note always has `note`, and a submitted one may leave it out.
826
+ */
827
+ type ArtifactFormChoiceAnswer = string | {
828
+ value: string;
829
+ note?: string;
830
+ } | {
831
+ other: string;
832
+ };
833
+ /** The answer to one field. A `multiple` field takes a list of choices. */
834
+ type ArtifactFormAnswerValue = ArtifactFormChoiceAnswer | ArtifactFormChoiceAnswer[];
835
+ type ArtifactFormAnswers = Record<string, ArtifactFormAnswerValue>;
836
+ /**
837
+ * Where an accepted answer is on its way to the agent.
838
+ *
839
+ * - `pending`: the session has not taken the answer yet.
840
+ * - `running`: the session took it and the agent is working on it.
841
+ * - `complete`: the agent replied after the answer.
842
+ * - `interrupted`: the turn was stopped, or failed, before a reply.
843
+ */
844
+ type ArtifactFormDelivery = 'pending' | 'running' | 'complete' | 'interrupted';
845
+ /** GET `artifacts.state` response body. */
846
+ interface ArtifactFormState {
847
+ form_version: number;
848
+ artifact_id: string;
849
+ session_id: string;
850
+ status: 'active' | 'idle';
851
+ /** Only for an `active` form: another user message came after the form was created. */
852
+ stale: boolean;
853
+ late: boolean;
854
+ content_version: number;
855
+ definition: ArtifactFormDefinition;
856
+ data: ArtifactFormAnswers | null;
857
+ submitted_at: string | null;
858
+ answer_message_id: string | null;
859
+ /** `null` until the form is answered. */
860
+ delivery: ArtifactFormDelivery | null;
861
+ }
862
+ /** POST `artifacts.state` request body. */
863
+ interface ArtifactFormSubmitEnvelope {
864
+ /** The `form_version` of the state the answers belong to. */
865
+ form_version: number;
866
+ request_id: string;
867
+ /**
868
+ * The `content_version` the form was loaded at. The server answers 409
869
+ * `version_conflict` when it has changed since. Without it the server skips
870
+ * that check.
871
+ */
872
+ expected_content_version?: number;
873
+ answers: ArtifactFormAnswers;
874
+ }
875
+ /** POST `artifacts.state` success (200) response body. */
876
+ interface ArtifactFormSubmitResult {
877
+ success: true;
878
+ artifact_id: string;
879
+ request_id: string;
880
+ answer_message_id: string;
881
+ content_version: number;
882
+ status: 'idle';
883
+ late: boolean;
884
+ /** `pending` for a new answer. An exact replay reports the current delivery. */
885
+ delivery: ArtifactFormDelivery;
886
+ /** `true` when this was an exact replay of an earlier request (same `request_id` and answers). */
887
+ replayed: boolean;
888
+ }
889
+ interface ArtifactStateClient {
890
+ get: () => Promise<ArtifactFormState>;
891
+ submit: (envelope: ArtifactFormSubmitEnvelope) => Promise<ArtifactFormSubmitResult>;
892
+ }
893
+
762
894
  interface AttentionInspectionApi {
763
895
  subscribe: (options: AttentionSubscriptionOptions, listener: (notification: AttentionNotification) => void) => AttentionSubscription;
764
896
  getCursor: (scope?: AttentionInspectionScope) => Promise<AttentionInspectionResult>;
@@ -965,7 +1097,8 @@ interface Artifact {
965
1097
  type: ArtifactType;
966
1098
  /** The content of the artifact, which can be HTML, Markdown, or JSON with wippy specific package.json info */
967
1099
  content_type: 'text/html' | 'text/markdown' | 'application/json';
968
- content_version?: string;
1100
+ /** Revision number. Set it through {@link normalizeArtifactFields}, so a legacy numeric string becomes a number. */
1101
+ content_version?: number;
969
1102
  status: ArtifactStatus;
970
1103
  }
971
1104
 
@@ -1064,6 +1197,8 @@ declare enum WsMessageType {
1064
1197
  CONTENT = "content",
1065
1198
  /** Contains content of the message to append to current one */
1066
1199
  CHUNK = "chunk",
1200
+ /** Reasoning text that a thinking model streams before its reply. The chat does not show it. */
1201
+ THINKING = "thinking",
1067
1202
  /** User message with contents */
1068
1203
  USER = "received",
1069
1204
  /** Response started, can create a message placeholder */
@@ -1165,11 +1300,22 @@ interface WsMessageDataChunk extends WsMessageDataBase {
1165
1300
  type: WsMessageType.CHUNK;
1166
1301
  content: string;
1167
1302
  }
1303
+ /** Reasoning text that a thinking model streams before its reply. */
1304
+ interface WsMessageDataThinking extends WsMessageDataBase {
1305
+ type: WsMessageType.THINKING;
1306
+ content?: string;
1307
+ }
1168
1308
  interface WsMessageDataContent extends WsMessageDataBase {
1169
1309
  type: WsMessageType.CONTENT;
1170
1310
  content: string;
1171
1311
  message_id: MessageUUID;
1172
1312
  file_uuids?: string[];
1313
+ /**
1314
+ * The message's own timestamp (RFC3339), matching `messages.date` in the
1315
+ * REST history — i.e. when the reply was produced, not when its turn
1316
+ * started. Optional: older backends, and any other event type, omit it.
1317
+ */
1318
+ date?: string;
1173
1319
  }
1174
1320
  interface WsMessageDataUser extends WsMessageDataBase {
1175
1321
  type: WsMessageType.USER;
@@ -1246,7 +1392,7 @@ interface WsMessageDataError extends WsMessageDataBase {
1246
1392
  }
1247
1393
  interface WsMessage_SessionMessage extends WsMessageBase {
1248
1394
  topic: WsTopicTypes['SessionMessage'];
1249
- data: (WsMessageDataUser | WsMessageDataContent | WsMessageDataChunk | WsMessageDataDelegation | WsMessageDataToolCall | WsMessageDataError | WsMessageDataInvalidate | WsMessageDataStarted | WsMessageDataToolSuccess | WsMessageDataArtifact | WsMessageDataToolError | WsMessageDataUpdate) & {
1395
+ data: (WsMessageDataUser | WsMessageDataContent | WsMessageDataChunk | WsMessageDataThinking | WsMessageDataDelegation | WsMessageDataToolCall | WsMessageDataError | WsMessageDataInvalidate | WsMessageDataStarted | WsMessageDataToolSuccess | WsMessageDataArtifact | WsMessageDataToolError | WsMessageDataUpdate) & {
1250
1396
  request_id?: string;
1251
1397
  };
1252
1398
  }
@@ -1488,7 +1634,7 @@ interface LayoutApi {
1488
1634
  on: (channel: string, handler: (env: BroadcastEnvelope) => void) => () => void;
1489
1635
  }
1490
1636
 
1491
- type KnownTopics = '@history' | '@visibility' | '@message' | '@state-error' | '@layout-change' | '@layout-breakpoint' | '@theme' | '@config';
1637
+ type KnownTopics = '@history' | '@visibility' | '@message' | '@state-error' | '@layout-change' | '@layout-breakpoint' | '@theme' | '@config' | '@reconnect';
1492
1638
  type Events = {
1493
1639
  /** Effective child config changed; the injected config is refreshed before this fires. */
1494
1640
  '@config': () => void;
@@ -1510,6 +1656,12 @@ type Events = {
1510
1656
  }) => void;
1511
1657
  /** Accepted theme mode changed in the resolved application config. */
1512
1658
  '@theme': (mode: 'auto' | 'light' | 'dark') => void;
1659
+ /**
1660
+ * The host's WebSocket reconnected after a genuine drop.
1661
+ * No payload — anything that depends on live session/artifact state
1662
+ * should refetch it. See iframe-proxy.md next to `@visibility`.
1663
+ */
1664
+ '@reconnect': () => void;
1513
1665
  } & {
1514
1666
  [K in string as K extends KnownTopics ? never : K]: (data: WsMessage) => void;
1515
1667
  };
@@ -1710,6 +1862,14 @@ interface ProxyApiInstance {
1710
1862
  get: () => Promise<FormState>;
1711
1863
  submit: (data: FormData | Record<string, unknown>) => Promise<FormResult>;
1712
1864
  };
1865
+ /**
1866
+ * Typed client for the session-forms artifact state route
1867
+ * (`artifacts.state` = `/api/v1/artifact/{artifactId}/state`). Resolves
1868
+ * route overrides fresh on every call and throws a real `ArtifactStateError`
1869
+ * (HTTP status + code + field errors) instead of fabricating data on
1870
+ * failure — see `iframe-proxy.md#artifact-state-forms`.
1871
+ */
1872
+ artifactState: (artifactId: string) => ArtifactStateClient;
1713
1873
  /**
1714
1874
  * Subscribe to events. Returns an unsubscribe function that MUST be called
1715
1875
  * on component unmount to prevent subscription leaks.
@@ -1749,6 +1909,29 @@ interface ProxyApiInstance {
1749
1909
  */
1750
1910
  sanitize: (html: string, opts?: SanitizeOptions) => string;
1751
1911
  }
1912
+ /** The `window.$W` global of a srcdoc iframe page. Each accessor resolves one member of the realm's `ProxyApiInstance`. */
1913
+ interface ProxyGlobalApi {
1914
+ config: () => Promise<ChildAppConfig>;
1915
+ instance: () => Promise<ProxyApiInstance>;
1916
+ api: () => Promise<ProxyApiInstance['api']>;
1917
+ attention: () => Promise<ProxyApiInstance['attention']>;
1918
+ /** @deprecated Use `$W.api` instead */
1919
+ form: () => Promise<ProxyApiInstance['api']>;
1920
+ host: () => Promise<ProxyApiInstance['host']>;
1921
+ /** @deprecated Use `$W.host` instead */
1922
+ iframe: () => Promise<ProxyApiInstance['host']>;
1923
+ on: () => Promise<ProxyApiInstance['on']>;
1924
+ logger: () => Promise<ProxyApiInstance['logger']>;
1925
+ state: () => Promise<ProxyApiInstance['state']>;
1926
+ ws: () => Promise<ProxyApiInstance['ws']>;
1927
+ loadWebComponent: () => Promise<ProxyApiInstance['loadWebComponent']>;
1928
+ loadByTagName: () => Promise<ProxyApiInstance['loadByTagName']>;
1929
+ sanitize: () => Promise<ProxyApiInstance['sanitize']>;
1930
+ html: () => Promise<ProxyApiInstance['html']>;
1931
+ artifactState: () => Promise<ProxyApiInstance['artifactState']>;
1932
+ /** Same check as isArtifactStateError from @wippy-fe/proxy. */
1933
+ isArtifactStateError: (value: unknown) => value is ArtifactStateError;
1934
+ }
1752
1935
 
1753
1936
  declare global {
1754
1937
  interface Window {
@@ -1798,25 +1981,7 @@ declare global {
1798
1981
  * @deprecated
1799
1982
  */
1800
1983
  initWippyApi: () => Promise<ProxyApiInstance>;
1801
- $W: {
1802
- config: () => Promise<ChildAppConfig>;
1803
- instance: () => Promise<ProxyApiInstance>;
1804
- api: () => Promise<ProxyApiInstance['api']>;
1805
- attention: () => Promise<ProxyApiInstance['attention']>;
1806
- /** @deprecated Use `$W.api` instead */
1807
- form: () => Promise<ProxyApiInstance['api']>;
1808
- host: () => Promise<ProxyApiInstance['host']>;
1809
- /** @deprecated Use `$W.host` instead */
1810
- iframe: () => Promise<ProxyApiInstance['host']>;
1811
- on: () => Promise<ProxyApiInstance['on']>;
1812
- logger: () => Promise<ProxyApiInstance['logger']>;
1813
- state: () => Promise<ProxyApiInstance['state']>;
1814
- ws: () => Promise<ProxyApiInstance['ws']>;
1815
- loadWebComponent: () => Promise<ProxyApiInstance['loadWebComponent']>;
1816
- loadByTagName: () => Promise<ProxyApiInstance['loadByTagName']>;
1817
- sanitize: () => Promise<ProxyApiInstance['sanitize']>;
1818
- html: () => Promise<ProxyApiInstance['html']>;
1819
- };
1984
+ $W: ProxyGlobalApi;
1820
1985
  tailwind?: {
1821
1986
  config: Partial<typeof _default>;
1822
1987
  };
@@ -1826,8 +1991,7 @@ declare global {
1826
1991
 
1827
1992
  // Augment axios's request config so consumers can opt out of the proxy
1828
1993
  // api's default auth handling on a per-request basis. The proxy's createApi
1829
- // reads `skipDefaultAuth` in both the request and response interceptors;
1830
- // see `gen-2-chat:src/proxy/shared/api.ts` for the runtime semantics.
1994
+ // reads `skipDefaultAuth` in both the request and response interceptors.
1831
1995
  declare module 'axios' {
1832
1996
  interface AxiosRequestConfig {
1833
1997
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wippy-fe/types-global-proxy",
3
- "version": "0.0.63",
3
+ "version": "0.0.65",
4
4
  "description": "Global type declarations for Wippy iframe proxy (window.getWippyApi, $W, etc.)",
5
5
  "license": "UNLICENSED",
6
6
  "types": "index.d.ts",