@jini-ai/chat 0.5.3 → 0.5.5

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 (138) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/core/ag-ui/entry.d.ts +33 -0
  3. package/dist/core/ag-ui/entry.js +80 -0
  4. package/dist/core/agentic/chat-capabilities.d.ts +2 -4
  5. package/dist/core/agentic/index.d.ts +4 -17
  6. package/dist/core/agentic/index.js +4 -17
  7. package/dist/core/assistant-client/a2ui-action-poster.d.ts +46 -0
  8. package/dist/core/assistant-client/a2ui-action-poster.js +113 -0
  9. package/dist/core/assistant-client/ag-ui-transport.d.ts +68 -0
  10. package/dist/core/assistant-client/ag-ui-transport.js +147 -0
  11. package/dist/core/assistant-client/attachment-liveness.d.ts +37 -0
  12. package/dist/core/assistant-client/attachment-liveness.js +93 -0
  13. package/dist/core/assistant-client/durable-run-subscription.d.ts +39 -0
  14. package/dist/core/assistant-client/durable-run-subscription.js +96 -0
  15. package/dist/core/assistant-client/entry.d.ts +13 -0
  16. package/dist/core/assistant-client/entry.js +7 -0
  17. package/dist/core/assistant-client/messages.d.ts +73 -0
  18. package/dist/core/assistant-client/messages.js +68 -0
  19. package/dist/core/assistant-client/transport.d.ts +164 -0
  20. package/dist/core/assistant-client/transport.js +734 -0
  21. package/dist/core/browser/page-actions.d.ts +121 -0
  22. package/dist/core/browser/page-actions.js +113 -0
  23. package/dist/core/composer-history.d.ts +54 -0
  24. package/dist/core/composer-history.js +57 -0
  25. package/dist/core/durable-projection.d.ts +28 -0
  26. package/dist/core/durable-projection.js +71 -0
  27. package/dist/core/durable-runs/continuation.d.ts +18 -0
  28. package/dist/core/durable-runs/continuation.js +61 -0
  29. package/dist/core/durable-runs/ledger-contracts.d.ts +53 -0
  30. package/dist/core/durable-runs/ledger-contracts.js +2 -0
  31. package/dist/core/durable-runs/policies.d.ts +6 -0
  32. package/dist/core/durable-runs/policies.js +6 -0
  33. package/dist/core/durable-runs/ports.d.ts +123 -0
  34. package/dist/core/durable-runs/ports.js +2 -0
  35. package/dist/core/durable-runs/run-contracts.d.ts +17 -0
  36. package/dist/core/durable-runs/run-contracts.js +2 -0
  37. package/dist/core/durable-runs/run-lock.d.ts +4 -0
  38. package/dist/core/durable-runs/run-lock.js +4 -0
  39. package/dist/core/index.d.ts +9 -19
  40. package/dist/core/index.js +8 -19
  41. package/dist/core/messages.d.ts +2 -0
  42. package/dist/core/question-form/format.d.ts +0 -9
  43. package/dist/core/question-form/format.js +16 -2
  44. package/dist/core/question-form/normalize.js +1 -0
  45. package/dist/core/question-form/secret-answers.d.ts +38 -0
  46. package/dist/core/question-form/secret-answers.js +45 -0
  47. package/dist/core/question-form/types.d.ts +2 -0
  48. package/dist/core/question-form.d.ts +1 -0
  49. package/dist/core/question-form.js +1 -0
  50. package/dist/core/run-events/entry.d.ts +208 -16
  51. package/dist/core/run-events/entry.js +273 -39
  52. package/dist/core/transcript.d.ts +3 -2
  53. package/dist/core/transcript.js +19 -3
  54. package/dist/core/transport.d.ts +4 -0
  55. package/dist/core/user-text-redaction.d.ts +56 -0
  56. package/dist/core/user-text-redaction.js +89 -0
  57. package/dist/embed-widget/browser/page-actions.d.ts +1 -120
  58. package/dist/embed-widget/browser/page-actions.js +2 -112
  59. package/dist/embed-widget/react/embed.d.ts +1 -1
  60. package/dist/embed-widget/react/embed.js +1 -1
  61. package/dist/react/artifact-types.d.ts +9 -15
  62. package/dist/react/components/Composer.js +6 -0
  63. package/dist/react/components/MessageRow.js +24 -11
  64. package/dist/react/components/QuestionForm.d.ts +2 -1
  65. package/dist/react/components/QuestionForm.js +18 -12
  66. package/dist/react/components/QuestionsPanel.d.ts +3 -2
  67. package/dist/react/components/QuestionsPanel.js +2 -2
  68. package/dist/react/features/chat-pane/agent-tools.d.ts +1 -1
  69. package/dist/react/features/chat-pane/agent-tools.js +0 -1
  70. package/dist/react/features/chat-pane/components/AgentRuntimePicker.js +5 -2
  71. package/dist/react/features/chat-pane/components/ChatPane.d.ts +1 -1
  72. package/dist/react/features/chat-pane/components/ChatPane.js +9 -4
  73. package/dist/react/features/chat-pane/create-typed-answer-poster.d.ts +2 -1
  74. package/dist/react/features/chat-pane/create-typed-answer-poster.js +33 -1
  75. package/dist/react/features/chat-pane/hooks/useAgentRuntimePicker.hooks.js +3 -2
  76. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.d.ts +7 -1
  77. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.js +38 -23
  78. package/dist/react/features/chat-pane/model-options.d.ts +10 -0
  79. package/dist/react/features/chat-pane/model-options.js +51 -0
  80. package/dist/react/features/chat-pane/rules.d.ts +3 -2
  81. package/dist/react/features/chat-pane/rules.js +12 -4
  82. package/dist/react/features/chat-pane/types.d.ts +30 -1
  83. package/dist/react/hooks/assistant-chats-contracts.d.ts +164 -0
  84. package/dist/react/hooks/assistant-chats-contracts.js +2 -0
  85. package/dist/react/hooks/assistant-chats.d.ts +7 -0
  86. package/dist/react/hooks/assistant-chats.js +960 -0
  87. package/dist/react/hooks/attachment-preview-cache.d.ts +1 -1
  88. package/dist/react/hooks/attachment-preview-cache.js +1 -1
  89. package/dist/react/hooks/composer-draft-cache.d.ts +2 -2
  90. package/dist/react/hooks/composer-draft-cache.js +2 -2
  91. package/dist/react/hooks/composer-history-storage.d.ts +8 -0
  92. package/dist/react/hooks/composer-history-storage.js +40 -0
  93. package/dist/react/hooks/fab-position.d.ts +90 -0
  94. package/dist/react/hooks/fab-position.js +271 -0
  95. package/dist/react/hooks/useComposer.d.ts +10 -1
  96. package/dist/react/hooks/useComposer.js +14 -2
  97. package/dist/react/hooks/useComposerHistory.hooks.d.ts +15 -0
  98. package/dist/react/hooks/useComposerHistory.hooks.js +90 -0
  99. package/dist/react/hooks/useComposerHistoryKeys.hooks.d.ts +9 -0
  100. package/dist/react/hooks/useComposerHistoryKeys.hooks.js +90 -0
  101. package/dist/react/hooks/useConversation.d.ts +4 -1
  102. package/dist/react/hooks/useConversation.js +20 -14
  103. package/dist/react/hooks/useRunStream.js +12 -2
  104. package/dist/react/hooks/useUserTextGuard.d.ts +11 -0
  105. package/dist/react/hooks/useUserTextGuard.js +19 -0
  106. package/dist/react/index.d.ts +14 -21
  107. package/dist/react/index.js +8 -0
  108. package/dist/server/durable-runs/accept.d.ts +25 -0
  109. package/dist/server/durable-runs/accept.js +21 -0
  110. package/dist/server/durable-runs/entry.d.ts +5 -0
  111. package/dist/server/durable-runs/entry.js +4 -0
  112. package/dist/server/durable-runs/recover.d.ts +5 -0
  113. package/dist/server/durable-runs/recover.js +147 -0
  114. package/dist/server/run-finalizer/ports.d.ts +2 -16
  115. package/dist/store/legacy/sqlite/messages.d.ts +24 -18
  116. package/dist/store/legacy/sqlite/messages.js +12 -2
  117. package/dist/store/pglite/index.d.ts +2 -1
  118. package/dist/store/postgres/index.d.ts +2 -1
  119. package/dist/store/runtime/chat-expiry-sweep.d.ts +40 -0
  120. package/dist/store/runtime/chat-expiry-sweep.js +70 -0
  121. package/dist/store/runtime/chat-history-store.d.ts +20 -0
  122. package/dist/store/runtime/chat-history-store.js +50 -0
  123. package/dist/store/runtime/durable-run-store.d.ts +21 -0
  124. package/dist/store/runtime/durable-run-store.js +342 -0
  125. package/dist/store/runtime/entry.d.ts +7 -0
  126. package/dist/store/runtime/entry.js +6 -0
  127. package/dist/store/runtime/kernel.d.ts +29 -0
  128. package/dist/store/runtime/kernel.js +2 -0
  129. package/dist/store/runtime/run-guarded-chat-store.d.ts +10 -0
  130. package/dist/store/runtime/run-guarded-chat-store.js +42 -0
  131. package/dist/store/runtime/run-ledger.d.ts +15 -0
  132. package/dist/store/runtime/run-ledger.js +206 -0
  133. package/dist/store/sql/boundary.d.ts +6 -0
  134. package/dist/store/sql/boundary.js +7 -1
  135. package/dist/store/sql/store.d.ts +3 -2
  136. package/dist/store/sql/store.js +9 -2
  137. package/dist/store/sqlite/index.d.ts +3 -2
  138. package/package.json +75 -10
@@ -1,10 +1,14 @@
1
+ import type { UserTextRedactionOptions } from '../../../core/user-text-redaction.js';
1
2
  import type { CSSProperties, ReactNode, RefObject } from 'react';
2
3
  import type { ChatAttachment, ChatMessage } from '@jini-ai/chat';
3
4
  import type { ComposerSlots } from '../../slots.js';
5
+ import type { ComposerHistoryStoragePort } from '../../../core/composer-history.js';
4
6
  import type { ChatTransport, RunContext } from '@jini-ai/chat';
5
7
  export interface ChatPaneAgentOption {
6
8
  id: string;
7
9
  label: string;
10
+ identityKind?: 'concrete' | 'alias' | 'routing-mode';
11
+ resolvedId?: string;
8
12
  }
9
13
  /**
10
14
  * Browser-safe runtime inventory consumed by the chat pane. This is
@@ -18,8 +22,29 @@ export interface ChatPaneAgent {
18
22
  version?: string | null;
19
23
  authStatus?: 'ok' | 'missing' | 'unknown';
20
24
  models?: readonly ChatPaneAgentOption[];
25
+ modelCatalog?: {
26
+ source: 'cli' | 'rpc' | 'provider-api' | 'cli-cache' | 'config-file' | 'offline-fallback';
27
+ freshness: 'fresh' | 'stale' | 'offline-fallback';
28
+ fetchedAt: string;
29
+ expiresAt: string;
30
+ coverage: 'account' | 'provider' | 'configured' | 'observed';
31
+ launchFingerprint: string;
32
+ };
33
+ defaultModelResolution?: {
34
+ status: 'resolved';
35
+ id: string;
36
+ selectionId?: string;
37
+ source: string;
38
+ resolvedAt: string;
39
+ launchFingerprint: string;
40
+ } | {
41
+ status: 'unresolved';
42
+ selectionId?: string;
43
+ reason: string;
44
+ };
21
45
  reasoningOptions?: readonly ChatPaneAgentOption[];
22
46
  supportsCustomModel?: boolean;
47
+ supportsConcreteModelSelection?: boolean;
23
48
  diagnostic?: string;
24
49
  /**
25
50
  * Whether this runtime can receive external MCP servers (host/Jini tools) at all — mirrors
@@ -142,7 +167,7 @@ export type DeliverTypedAnswer = ((input: {
142
167
  }) => Promise<TypedAnswerDelivery>) & {
143
168
  readonly toolName: string;
144
169
  };
145
- export interface ChatPaneProps {
170
+ export interface ChatPaneProps extends UserTextRedactionOptions {
146
171
  transport: ChatTransport;
147
172
  agents?: readonly ChatPaneAgent[];
148
173
  /** Optional host effects for package-owned inventory, rescan, and health polling. */
@@ -172,6 +197,10 @@ export interface ChatPaneProps {
172
197
  /** Passed straight through to the runtime picker. */
173
198
  onByokModelChange?: (model: string) => void;
174
199
  initialDraft?: string;
200
+ /** Principal-scoped recent prompt recall; defaults to the origin-local default scope. */
201
+ composerHistoryScope?: string;
202
+ /** Optional storage effects; omitted uses bounded browser storage with memory fallback. */
203
+ composerHistoryStorage?: ComposerHistoryStoragePort;
175
204
  /**
176
205
  * Confirms which previously staged attachments still exist, so a draft restored after a reload
177
206
  * never shows a chip for a file the backend has since garbage-collected — that looks intact and
@@ -0,0 +1,164 @@
1
+ import type { ChatMessage } from "../../core/messages.js";
2
+ import type { AssistantConversation } from "../../core/assistant-client/messages.js";
3
+ /**
4
+ * @file What `useAssistantChats` needs from the outside world, as an interface rather than a set of
5
+ * module imports.
6
+ *
7
+ * The hook used to import `lib/assistant-chats`'s functions directly, which meant the only way to
8
+ * test it was to stub the global `fetch` and assert on the URLs and methods that came out — the
9
+ * tests described HTTP when what they meant to describe was "which conversation did this message
10
+ * get written to". Worse, behaviour that has nothing to do with transport (the write retry and its
11
+ * backoff) could only be exercised by hand-building `Response` objects with the right status codes.
12
+ *
13
+ * Declaring the seam here follows the `useX(dependencies)` / `useWiredX()` pair this workspace
14
+ * already uses throughout `@jini-ai/ui` (see `features/html-viewer/react/hooks/usePresentMode.ts`
15
+ * for the canonical shape, and `foundry/docs/jini-port/skills/fixing-open-design-web.md` for the
16
+ * rules). `ports.ts` declares, `assistant-chats-dependencies.ts` binds, and nothing else imports the
17
+ * real provider.
18
+ *
19
+ * `AssistantConversation` is imported here `import type`, which is erased at compile time — so this
20
+ * file still has no runtime dependency on `lib/assistant-chats`, and `dependencies.ts` remains the
21
+ * single place the real implementation is reached.
22
+ *
23
+ * ## What is deliberately NOT in this port
24
+ *
25
+ * `persistableMessages` and `HttpError`. The first is a pure rule — no I/O, no host — and per the
26
+ * pattern a hook imports rules directly rather than having them injected; making it swappable would
27
+ * let a fake quietly change which messages count as settled, which is the one thing every test here
28
+ * needs to hold still. The second is the error type an implementation is expected to throw for a
29
+ * non-2xx response, and it is part of this contract even though it is not a method: {@link
30
+ * AssistantChatsPort.saveMessage}'s retry classifies failures by it.
31
+ */
32
+ export interface AssistantChatsPort {
33
+ listConversations(required: Record<string, never>, optional: Record<string, never>): Promise<AssistantConversation[]>;
34
+ /** `firstMessage` seeds the server-side title heuristic; omit it for an untitled empty chat. */
35
+ createConversation(required: {
36
+ firstMessage?: string;
37
+ }, optional: Record<string, never>): Promise<AssistantConversation>;
38
+ renameConversation(required: {
39
+ id: string;
40
+ title: string;
41
+ }, optional: Record<string, never>): Promise<void>;
42
+ deleteConversation(required: {
43
+ id: string;
44
+ }, optional: Record<string, never>): Promise<void>;
45
+ loadMessages(required: {
46
+ conversationId: string;
47
+ }, optional: Record<string, never>): Promise<ChatMessage[]>;
48
+ /**
49
+ * Writes one message.
50
+ *
51
+ * Expected to reject with an `HttpError` for a non-2xx response and with anything else for a
52
+ * transport failure — the hook retries the second kind, and the first only for 429/5xx. An
53
+ * implementation that swallows failures into a resolved promise silently disables the retry.
54
+ */
55
+ saveMessage(required: {
56
+ conversationId: string;
57
+ message: ChatMessage;
58
+ }, optional: Record<string, never>): Promise<void>;
59
+ }
60
+ export interface UseAssistantChats {
61
+ conversations: AssistantConversation[];
62
+ activeId: string | null;
63
+ /**
64
+ * `ChatPane`'s `key`. Deliberately NOT `activeId`.
65
+ *
66
+ * Remounting the pane is correct for a user-initiated switch and destructive at any other time: it
67
+ * re-seeds from `initialMessages` and discards whatever the pane currently holds. `activeId` now
68
+ * also changes when an untitled pane silently adopts a freshly created conversation mid-run (see
69
+ * `onMessagesChange`), and re-keying on that would wipe the reply being streamed. So the two are
70
+ * separate: this changes only on `select`/`create`/`remove`, `activeId` tracks where writes go.
71
+ */
72
+ paneKey: string;
73
+ /** Messages to seed the pane with. Changes identity only on a real conversation switch. */
74
+ initialMessages: ChatMessage[];
75
+ select: (required: {
76
+ id: string;
77
+ }, optional?: Record<string, never>) => void;
78
+ create: (required: Record<string, never>, optional?: Record<string, never>) => Promise<void>;
79
+ remove: (required: {
80
+ id: string;
81
+ }, optional?: Record<string, never>) => Promise<void>;
82
+ rename: (required: {
83
+ id: string;
84
+ title: string;
85
+ }, optional?: Record<string, never>) => Promise<void>;
86
+ onMessagesChange: (required: {
87
+ messages: ChatMessage[];
88
+ }, optional?: Record<string, never>) => void;
89
+ /**
90
+ * This pane's conversation id, adopting one if none is active yet. Awaited by
91
+ * `assistant-transport.ts`'s `startRun` so turn 1's run carries the identity its agent-CLI session
92
+ * id gets filed under — see the hook's own implementation doc for the amnesia defect that needs it.
93
+ * Resolves `null` (never rejects) when creation fails.
94
+ */
95
+ ensureConversationId: (required: Record<string, never>, optional?: Record<string, never>) => Promise<string | null>;
96
+ /**
97
+ * Writes one user turn durably, awaited by `assistant-transport.ts`'s `startRun` BEFORE it
98
+ * dispatches the run — see the implementation's own doc for the defect (a failed run's user
99
+ * message reaching no agent and no later prompt). Never rejects; a failed write releases the id
100
+ * so the delta-driven `flush` can still pick it up.
101
+ */
102
+ persistUserTurn: (required: {
103
+ conversationId: string;
104
+ message: ChatMessage;
105
+ }, optional?: Record<string, never>) => Promise<void>;
106
+ }
107
+ export interface AssistantChatsClientPorts {
108
+ readonly statusOf: (required: {
109
+ error: unknown;
110
+ }, optional: Record<string, never>) => number | undefined;
111
+ readonly sleep: (required: {
112
+ delayMs: number;
113
+ }, optional: Record<string, never>) => Promise<void>;
114
+ readonly reportPermanent: (required: {
115
+ conversationId: string;
116
+ messageId: string;
117
+ error: unknown;
118
+ }, optional: Record<string, never>) => void;
119
+ readonly requestRunPrefixes: readonly string[];
120
+ }
121
+ export type SaveOutcome = "saved" | "exhausted" | "permanent" | "missing";
122
+ export type AttemptResult = {
123
+ done: true;
124
+ outcome: SaveOutcome;
125
+ } | {
126
+ done: false;
127
+ };
128
+ export interface SaveFailureInput {
129
+ error: unknown;
130
+ conversationId: string;
131
+ message: ChatMessage;
132
+ attempt: number;
133
+ isDisposed: () => boolean;
134
+ }
135
+ export interface AssistantChatsClient {
136
+ giveUpOutcome(required: {
137
+ error: unknown;
138
+ }, optional?: Record<string, never>): SaveOutcome;
139
+ handleSaveFailure(required: SaveFailureInput, optional?: Record<string, never>): Promise<AttemptResult>;
140
+ attemptSave(required: Omit<SaveFailureInput, "error"> & {
141
+ port: AssistantChatsPort;
142
+ }, optional?: Record<string, never>): Promise<AttemptResult>;
143
+ summarizeFlushOutcomes(required: {
144
+ results: readonly {
145
+ message: ChatMessage;
146
+ outcome: SaveOutcome;
147
+ }[];
148
+ isConversationStillActive: boolean;
149
+ }, optional?: Record<string, never>): {
150
+ idsToRelease: string[];
151
+ shouldRefresh: boolean;
152
+ };
153
+ resolveRememberedConversation(required: {
154
+ remembered: string | null;
155
+ conversations: readonly AssistantConversation[];
156
+ listFailed: boolean;
157
+ }, optional?: Record<string, never>): "restore" | "forget" | "keep";
158
+ useAssistantChats(required: {
159
+ port: AssistantChatsPort;
160
+ }, optional?: {
161
+ lastConversation?: import("./last-conversation-store.js").LastConversationStore;
162
+ }): UseAssistantChats;
163
+ }
164
+ //# sourceMappingURL=assistant-chats-contracts.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=assistant-chats-contracts.js.map
@@ -0,0 +1,7 @@
1
+ import type { AssistantChatsClientPorts, AssistantChatsClient } from "./assistant-chats-contracts.js";
2
+ /** Bind effects once; the returned hook captures its conversation port at mount.
3
+ * Existing race guards and retry ordering remain in the original lexical lifecycle. */
4
+ export declare function createAssistantChatsClient({ ports }: {
5
+ ports: AssistantChatsClientPorts;
6
+ }, _options?: Record<string, never>): AssistantChatsClient;
7
+ //# sourceMappingURL=assistant-chats.d.ts.map