@jini-ai/chat 0.6.22 → 0.7.0

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 (52) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +8 -0
  3. package/dist/core/accepted-input.d.ts +1 -1
  4. package/dist/core/accepted-input.js +5 -4
  5. package/dist/core/assistant-client/ag-ui-transport.js +9 -3
  6. package/dist/core/assistant-client/transport.js +15 -8
  7. package/dist/core/durable-projection.js +8 -1
  8. package/dist/core/durable-runs/ports.d.ts +4 -1
  9. package/dist/core/question-answer.js +2 -1
  10. package/dist/core/turn-usage.d.ts +1 -1
  11. package/dist/core/turn-usage.js +4 -5
  12. package/dist/embed-widget/browser/frontend-session-bridge.d.ts +18 -0
  13. package/dist/embed-widget/browser/frontend-session-bridge.js +27 -0
  14. package/dist/react/components/AttachmentTray.d.ts +4 -1
  15. package/dist/react/components/AttachmentTray.js +20 -5
  16. package/dist/react/components/Composer.d.ts +3 -1
  17. package/dist/react/components/Composer.js +16 -14
  18. package/dist/react/components/ComposerDiscovery.d.ts +2 -0
  19. package/dist/react/components/ComposerDiscovery.js +4 -3
  20. package/dist/react/components/ConversationList.d.ts +4 -2
  21. package/dist/react/components/ConversationList.js +16 -7
  22. package/dist/react/components/CopyMessageButton.d.ts +3 -1
  23. package/dist/react/components/CopyMessageButton.js +3 -2
  24. package/dist/react/components/FolderChips.d.ts +3 -1
  25. package/dist/react/components/FolderChips.js +8 -5
  26. package/dist/react/components/MessageList.js +1 -1
  27. package/dist/react/components/MessageRow.js +13 -6
  28. package/dist/react/components/ToolCard.js +7 -7
  29. package/dist/react/components/ToolCard.rules.d.ts +5 -0
  30. package/dist/react/components/ToolCard.rules.js +9 -2
  31. package/dist/react/components/mcp-ui-surface-state.js +11 -0
  32. package/dist/react/features/chat-pane/components/AgentRuntimePicker.d.ts +1 -1
  33. package/dist/react/features/chat-pane/components/AgentRuntimePicker.js +39 -28
  34. package/dist/react/features/chat-pane/components/ChatPane.js +20 -8
  35. package/dist/react/features/chat-pane/components/RuntimeDropUp.d.ts +2 -1
  36. package/dist/react/features/chat-pane/components/RuntimeDropUp.js +11 -6
  37. package/dist/react/features/chat-pane/create-frontend-request-caller.d.ts +23 -0
  38. package/dist/react/features/chat-pane/create-frontend-request-caller.js +56 -0
  39. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.d.ts +2 -0
  40. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.js +16 -0
  41. package/dist/react/features/chat-pane/rules.d.ts +22 -1
  42. package/dist/react/features/chat-pane/rules.js +36 -10
  43. package/dist/react/features/chat-pane/styles.d.ts +1 -1
  44. package/dist/react/features/chat-pane/styles.js +32 -39
  45. package/dist/react/features/chat-pane/surface-recovery-stream.d.ts +11 -3
  46. package/dist/react/features/chat-pane/surface-recovery-stream.js +28 -18
  47. package/dist/react/features/chat-pane/types.d.ts +13 -0
  48. package/dist/react/index.d.ts +5 -2
  49. package/dist/react/index.js +2 -1
  50. package/dist/react/styles/chat-settings.css +149 -0
  51. package/dist/server/durable-runs/recover.js +43 -6
  52. package/package.json +21 -18
@@ -1,3 +1,4 @@
1
+ import type { SurfaceEmission } from '@jini-ai/core';
1
2
  import type { UserTextRedactionOptions } from '../../../core/user-text-redaction.js';
2
3
  import type { NativeToolPolicyInput } from '@jini-ai/agent-runtime/native-tool-policy';
3
4
  import type { CSSProperties, ReactNode, RefObject } from 'react';
@@ -11,6 +12,8 @@ export interface ChatPaneAgentOption {
11
12
  label: string;
12
13
  identityKind?: 'concrete' | 'alias' | 'routing-mode';
13
14
  resolvedId?: string;
15
+ /** Model-specific levels; absent inherits the runtime vocabulary, empty narrows it to Default. */
16
+ reasoning?: readonly ChatPaneAgentOption[];
14
17
  }
15
18
  /**
16
19
  * Browser-safe runtime inventory consumed by the chat pane. This is
@@ -47,6 +50,10 @@ export interface ChatPaneAgent {
47
50
  reason: string;
48
51
  };
49
52
  reasoningOptions?: readonly ChatPaneAgentOption[];
53
+ /** Effort lives in model IDs for these runtimes, so no independent control is offered. */
54
+ reasoningInModelId?: {
55
+ levels: readonly ChatPaneAgentOption[];
56
+ };
50
57
  supportsCustomModel?: boolean;
51
58
  supportsConcreteModelSelection?: boolean;
52
59
  diagnostic?: string;
@@ -202,6 +209,8 @@ export type DeliverMidRunMessage = (input: {
202
209
  attachments?: readonly ChatAttachment[];
203
210
  }) => Promise<MidRunMessageDelivery>;
204
211
  export interface ChatPaneProps extends UserTextRedactionOptions {
212
+ /** Automation base for the package-owned composer and runtime picker; false opts out. */
213
+ agentHandle?: string | false | undefined;
205
214
  transport: ChatTransport;
206
215
  /** Host-localized text shown verbatim while the active run is awaiting acceptance.
207
216
  * Omit to use the translated `Sending…` label; ignored once sending ends. */
@@ -226,6 +235,8 @@ export interface ChatPaneProps extends UserTextRedactionOptions {
226
235
  onActivityChange?: (activity: ChatPaneActivity) => void;
227
236
  /** Fires with the full message list whenever it changes — the read side of an otherwise write-only pane, for a host that needs to inspect or test what the conversation actually contains. */
228
237
  onMessagesChange?: (messages: ChatMessage[]) => void;
238
+ /** Host-only request surfaces enter the current transcript through its existing sandbox renderer. */
239
+ subscribeToSurfaces?: (listener: (emission: SurfaceEmission) => void) => () => void;
229
240
  onRescanAgents?: () => void;
230
241
  scanningAgents?: boolean;
231
242
  daemonOnline?: boolean;
@@ -414,6 +425,8 @@ export interface ByokRuntimeSummary {
414
425
  }[];
415
426
  }
416
427
  export interface AgentRuntimePickerProps {
428
+ /** Stable automation base; generated by default, false opts out at every leaf. */
429
+ agentHandle?: string | false | undefined;
417
430
  agents: readonly ChatPaneAgent[];
418
431
  nativeToolPolicy?: NativeToolPolicyInput;
419
432
  value: ChatPaneAgentSelection;
@@ -154,8 +154,8 @@ export type { JiniChatProviderProps, JiniChatSlots } from './components/JiniChat
154
154
  * `createDomPageDriver`/`currentAgentPage` moved to `@jini-ai/agentic/dom` in the 2026-07-26
155
155
  * extraction — re-exported here so existing `@jini-ai/chat-react` importers keep working.
156
156
  */
157
- export { createFrontendSessionBridge } from './agent-bridge/frontend-session-bridge.js';
158
- export type { FrontendSessionBridge, FrontendSessionBridgeArgs, FrontendSessionBridgeOptions, } from './agent-bridge/frontend-session-bridge.js';
157
+ export { createFrontendSessionBridge, createFrontendNavigationGuard } from './agent-bridge/frontend-session-bridge.js';
158
+ export type { FrontendSessionBridge, FrontendNavigationGuard, FrontendSessionBridgeArgs, FrontendSessionBridgeOptions, } from './agent-bridge/frontend-session-bridge.js';
159
159
  export { createDomPageDriver, currentAgentPage, type DomPageDriverOptions } from '@jini-ai/agentic/dom';
160
160
  export { createBrowserComposerHistoryStorage } from './hooks/composer-history-storage.js';
161
161
  export type { ComposerHistoryStoragePort } from '../core/composer-history.js';
@@ -175,4 +175,7 @@ export type { AgentPluginUsage, AgentPluginUsage as Usage } from '../core/agent-
175
175
  export { acceptedInputEvent, acceptedInputUserEvent, projectAcceptedInputEvents } from '../core/accepted-input.js';
176
176
  export type { AcceptedChatInput } from '../core/accepted-input.js';
177
177
  export { isAwaitingAnswer } from '../core/run-activity.js';
178
+ export { createFrontendRequestCaller } from './features/chat-pane/create-frontend-request-caller.js';
179
+ export type { FrontendRequestCallerRequired, FrontendRequestInput } from './features/chat-pane/create-frontend-request-caller.js';
180
+ export type { SurfaceRecoveryInfo } from '../core/surface-recovery.js';
178
181
  //# sourceMappingURL=index.d.ts.map
@@ -133,7 +133,7 @@ export { JiniChatProvider, useJiniChatSlots, useOnFeedback } from './components/
133
133
  * `createDomPageDriver`/`currentAgentPage` moved to `@jini-ai/agentic/dom` in the 2026-07-26
134
134
  * extraction — re-exported here so existing `@jini-ai/chat-react` importers keep working.
135
135
  */
136
- export { createFrontendSessionBridge } from './agent-bridge/frontend-session-bridge.js';
136
+ export { createFrontendSessionBridge, createFrontendNavigationGuard } from './agent-bridge/frontend-session-bridge.js';
137
137
  export { createDomPageDriver, currentAgentPage } from '@jini-ai/agentic/dom';
138
138
  export { createBrowserComposerHistoryStorage } from './hooks/composer-history-storage.js';
139
139
  // ChatPane consumers share the same redaction and draft/preview state owners.
@@ -147,4 +147,5 @@ export { isTerminalRunStatus } from '../core/messages.js';
147
147
  export { AGENT_PLUGIN_STATE_CHANGED, readAgentPluginChatState, writeAgentPluginChatState } from '../core/agent-plugin-chat-state.js';
148
148
  export { acceptedInputEvent, acceptedInputUserEvent, projectAcceptedInputEvents } from '../core/accepted-input.js';
149
149
  export { isAwaitingAnswer } from '../core/run-activity.js';
150
+ export { createFrontendRequestCaller } from './features/chat-pane/create-frontend-request-caller.js';
150
151
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,149 @@
1
+ /** Optional presentation for ChatSettingsDialog and ChatSettingsSegmented.
2
+ * Import @jini-ai/chat/react/styles/chat-settings.css; hosts may bind the
3
+ * --jini-chat-settings-* tokens to their theme. All tokens have standalone defaults.
4
+ */
5
+ /* Chat settings (Jini `ChatSettingsDialog`, restyled 2026-10-17 after owner called it "awful"):
6
+ fixed header + tabs, only the panel body scrolls. Each option is one row: switch, then label with
7
+ a one-line muted description (owner 2026-10-17: ⓘ tooltips floated too far from their icon, so
8
+ no tooltips here). Full CLI access is the card header; the capabilities it switches all at once
9
+ sit in the card body beneath it. */
10
+ .jini-chat-settings-dialog {
11
+ box-sizing: border-box;
12
+ width: 36rem;
13
+ max-width: calc(100vw - 2rem);
14
+ /* Top-anchored, not centred: switching tabs changes the height, and a centred dialog would
15
+ move its header and tabs under the pointer each time. */
16
+ max-height: min(42rem, calc(100dvh - clamp(1rem, 10vh, 5rem) - 1rem));
17
+ margin: clamp(1rem, 10vh, 5rem) auto auto;
18
+ padding: 0;
19
+ overflow: hidden;
20
+ border: var(--jini-border-width, 1px) solid var(--jini-chat-settings-border, #d9dce2);
21
+ border-radius: var(--radius-lg, 12px);
22
+ background: var(--jini-chat-settings-bg, #fff);
23
+ color: var(--jini-chat-settings-fg, #1a1916);
24
+ font: inherit;
25
+ box-shadow: var(--jini-overlay-shadow, 0 12px 36px #0003);
26
+ background-image: var(--jini-panel-texture, none);
27
+ }
28
+ .jini-chat-settings-dialog[open] { display: flex; flex-direction: column; }
29
+ .jini-chat-settings-dialog::backdrop { background: var(--jini-chat-settings-overlay-bg, #0006);
30
+ backdrop-filter: var(--jini-chat-settings-backdrop-filter, none);
31
+ }
32
+ .jini-chat-settings-header {
33
+ flex: none; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
34
+ padding: 0.875rem 0.875rem 0 1.5rem;
35
+ }
36
+ .jini-chat-settings-header .jini-dialog-title { margin: 0; font-size: 1.125rem; font-weight: 700; line-height: 1.3; }
37
+ .jini-chat-settings-dialog .jini-chat-settings-close {
38
+ display: inline-flex; align-items: center; justify-content: center; flex: none;
39
+ width: 2.25rem; height: 2.25rem; min-width: 0; min-height: 0; padding: 0;
40
+ border: 0; border-radius: var(--radius, 8px); background: transparent; color: var(--jini-chat-settings-muted, #676767);
41
+ font-size: 1.5rem; line-height: 1; cursor: pointer;
42
+ }
43
+ .jini-chat-settings-dialog .jini-chat-settings-close:hover { background: var(--jini-chat-settings-subtle, #f4f5f7); color: var(--jini-chat-settings-fg, #1a1916); }
44
+ .jini-chat-settings-dialog .jini-chat-settings-close:focus-visible { outline: 2px solid var(--jini-chat-settings-accent, #3b66c4); outline-offset: 2px; }
45
+ .jini-chat-settings-dialog > .tab-bar { display: flex; border-bottom: 1px solid var(--jini-chat-settings-border, #d9dce2); flex: none; flex-wrap: nowrap; margin: 0.25rem 0 0; padding: 0 1.5rem; gap: 0.5rem; }
46
+ .jini-chat-settings-dialog > .tab-bar .tab-bar-item {
47
+ display: inline-flex; align-items: center; flex-shrink: 0; background: none;
48
+ border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 0.65rem 0.25rem;
49
+ margin-bottom: -1px; font: inherit; font-size: var(--text-sm, 0.875rem); font-weight: 600;
50
+ color: var(--jini-chat-settings-muted, #676767); cursor: pointer; transition: color 140ms, border-color 140ms;
51
+ }
52
+ .jini-chat-settings-dialog > .tab-bar .tab-bar-item:hover { color: var(--jini-chat-settings-fg, #1a1916); }
53
+ .jini-chat-settings-dialog > .tab-bar .tab-bar-item[aria-selected="true"] {
54
+ color: var(--jini-chat-settings-selected-text, var(--jini-chat-settings-accent, #3b66c4));
55
+ border-bottom-color: var(--jini-chat-settings-selected-ring, var(--jini-chat-settings-accent, #3b66c4));
56
+ }
57
+ .jini-chat-settings-dialog .tab-bar-item:focus-visible { outline: 2px solid var(--jini-chat-settings-accent, #3b66c4); outline-offset: -2px; border-radius: 4px 4px 0 0; }
58
+ .jini-chat-settings-body {
59
+ flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
60
+ padding: 1.25rem 1.5rem 1.5rem; overflow-wrap: anywhere;
61
+ }
62
+ .jini-chat-settings-group { display: flex; flex-direction: column; min-width: 0; margin: 0; padding: 0; border: 0; }
63
+ .jini-chat-settings-group + .jini-chat-settings-group { margin-top: 1.25rem; }
64
+ .jini-chat-settings-legend { padding: 0; margin-bottom: 0.5rem; font-size: var(--text-sm, 0.875rem); font-weight: 600; color: var(--jini-chat-settings-fg, #1a1916); }
65
+ /* Tool calls: the shared segmented-control look, built on real radios for keyboard and AT. */
66
+ .jini-chat-settings-segmented {
67
+ display: inline-flex; flex-wrap: wrap; align-self: flex-start; max-width: 100%; gap: 0.25rem; padding: 0.2rem;
68
+ border: 1px solid var(--jini-chat-settings-border, #d9dce2); border-radius: 8px; background: var(--jini-chat-settings-subtle, #f4f5f7);
69
+ }
70
+ .jini-chat-settings-legend > .info-tip { margin-left: 0.3rem; }
71
+ .jini-chat-settings-segment {
72
+ position: relative; display: inline-flex; align-items: center; padding: 0.4rem 0.95rem;
73
+ border-radius: 6px; font-size: var(--text-sm, 0.875rem); color: var(--jini-chat-settings-muted, #676767); cursor: pointer;
74
+ }
75
+ .jini-chat-settings-segment input {
76
+ position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer;
77
+ }
78
+ .jini-chat-settings-segment:hover { color: var(--jini-chat-settings-fg, #1a1916); }
79
+ /* The same pill also supports a host tablist:
80
+ tab buttons, so the global filled `button` look comes off and `[aria-selected]` stands in for a
81
+ checked radio below. */
82
+ button.jini-chat-settings-segment {
83
+ border: 0; background: transparent; font-family: inherit; font-weight: inherit; letter-spacing: normal;
84
+ line-height: inherit; transition: none;
85
+ }
86
+ button.jini-chat-settings-segment:hover { opacity: 1; }
87
+ .jini-chat-settings-segment:has(input:checked), .jini-chat-settings-segment[aria-selected="true"] { background: var(--jini-chat-settings-selected-bg, #fff); color: var(--jini-chat-settings-fg, #1a1916); font-weight: 600; box-shadow: var(--jini-chat-settings-selected-shadow, 0 1px 3px #0002); }
88
+ .jini-chat-settings-segment:has(input:focus-visible), .jini-chat-settings-segment[role="tab"]:focus-visible { outline: 2px solid var(--jini-chat-settings-accent, #3b66c4); outline-offset: 1px; }
89
+ .jini-chat-settings-segment:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }
90
+ /* Switch, then label with its one-line description; the switch centres on the label line. */
91
+ .jini-chat-settings-row { display: flex; align-items: flex-start; gap: 0.75rem; padding-block: 0.5rem; }
92
+ .jini-chat-settings-row > input[role="switch"] { margin-top: 0.0625rem; }
93
+ .jini-chat-settings-text { display: flex; flex-direction: column; gap: 0.125rem; min-width: 0; }
94
+ /* A switch's ⓘ follows its label's text, like the legend's (owner, 2026-10-21), outside the label so a tap never toggles. */
95
+ .jini-chat-settings-label-row { display: flex; align-items: center; gap: 0.3rem; }
96
+ .jini-chat-settings-label-row > .info-tip { flex: none; }
97
+ .jini-chat-settings-label { font-size: 0.9375rem; line-height: 1.4; cursor: pointer; }
98
+ .jini-chat-settings-description { margin: 0; font-size: 0.8125rem; line-height: 1.35; color: var(--jini-text-muted, var(--jini-chat-settings-muted, #676767)); }
99
+ .jini-chat-settings-description--group { margin: -0.25rem 0 0.625rem; }
100
+ .jini-chat-settings-row:has(input:disabled) .jini-chat-settings-label { color: var(--jini-chat-settings-muted, #676767); cursor: not-allowed; }
101
+ /* Same track-and-knob geometry as the shared permission controls. */
102
+ .jini-chat-settings-dialog input[type="checkbox"][role="switch"] {
103
+ appearance: none; -webkit-appearance: none; position: relative; flex: none;
104
+ width: 38px; height: 22px; margin: 0; border-radius: 999px; cursor: pointer;
105
+ border: 1px solid var(--jini-border-strong, var(--jini-chat-settings-border, #d9dce2));
106
+ background: var(--jini-border-strong, var(--jini-chat-settings-border, #d9dce2)); transition: background-color 120ms ease;
107
+ }
108
+ .jini-chat-settings-dialog input[type="checkbox"][role="switch"]::after {
109
+ content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
110
+ background: var(--jini-control-thumb-bg, #fff); box-shadow: var(--jini-control-thumb-shadow, 0 1px 2px #0003); transition: transform 120ms ease;
111
+ }
112
+ .jini-chat-settings-dialog input[type="checkbox"][role="switch"]:checked { background: var(--jini-chat-settings-accent, #3b66c4); border-color: var(--jini-chat-settings-accent, #3b66c4); }
113
+ .jini-chat-settings-dialog input[type="checkbox"][role="switch"]:checked::after { transform: translateX(16px); }
114
+ .jini-chat-settings-dialog input[type="checkbox"][role="switch"]:focus-visible { outline: 2px solid var(--jini-chat-settings-accent, #3b66c4); outline-offset: 2px; }
115
+ .jini-chat-settings-dialog input[type="checkbox"][role="switch"]:disabled { opacity: 0.5; cursor: not-allowed; }
116
+ @media (prefers-reduced-motion: reduce) {
117
+ .jini-chat-settings-dialog input[role="switch"], .jini-chat-settings-dialog input[role="switch"]::after { transition: none; }
118
+ }
119
+ .jini-chat-settings-note { margin: 0 0 1rem; font-size: var(--text-sm, 0.875rem); color: var(--jini-chat-settings-muted, #676767); line-height: 1.5; }
120
+ .jini-chat-settings-error { margin: 1rem 0 0; font-size: var(--text-sm, 0.875rem); color: var(--jini-chat-settings-danger, #b42318); }
121
+ .jini-chat-settings-row--master {
122
+ padding: 0.625rem 1rem; border: 1px solid var(--jini-chat-settings-border, #d9dce2); border-radius: var(--radius-lg, 12px) var(--radius-lg, 12px) 0 0;
123
+ background: var(--jini-chat-settings-subtle, #f4f5f7);
124
+ }
125
+ .jini-chat-settings-row--master .jini-chat-settings-label { font-weight: 600; }
126
+ .jini-chat-settings-capabilities {
127
+ padding: 0.375rem 1rem 0.5rem 1.75rem; border: 1px solid var(--jini-chat-settings-border, #d9dce2); border-top: 0;
128
+ border-radius: 0 0 var(--radius-lg, 12px) var(--radius-lg, 12px);
129
+ }
130
+ /* Help has its own touch target, outside every setting's button or label. The 44px target is an
131
+ invisible hit area (17.6px icon + 2 × 13px), not a wider icon: sizing the icon itself to 44px
132
+ added ~80px to the Tool calls pill and wrapped it onto two rows in a 390px dialog. The ≤640px
133
+ phone floor in styles.css (44px min on every [role="button"] in `.jini-dialog`) did the same,
134
+ so it is undone here and the hit area takes over at that width too. */
135
+ @media (pointer: coarse), (max-width: 640px) {
136
+ .jini-chat-settings-legend .info-tip-icon,
137
+ .jini-chat-settings-label-row > .info-tip .info-tip-icon { position: relative; }
138
+ .jini-chat-settings-legend .info-tip-icon::before,
139
+ .jini-chat-settings-label-row > .info-tip .info-tip-icon::before { content: ""; position: absolute; inset: -13px; }
140
+ .jini-dialog .jini-chat-settings-legend .info-tip-icon[role="button"],
141
+ .jini-dialog .jini-chat-settings-label-row > .info-tip .info-tip-icon[role="button"] { min-width: 0; min-height: 0; }
142
+ }
143
+ @media (max-width: 640px) {
144
+ .jini-chat-settings-dialog input[type="checkbox"][role="switch"] { width: 38px; height: 22px; }
145
+ .jini-chat-settings-body { padding-inline: 1rem; }
146
+ .jini-chat-settings-dialog > .tab-bar { padding-inline: 1rem; }
147
+ .jini-chat-settings-header { padding-left: 1rem; }
148
+ }
149
+
@@ -1,5 +1,5 @@
1
1
  import { recoveredRunEvents } from "../../core/index.js";
2
- import { classifyAgentServiceFailure } from "@jini-ai/agent-runtime";
2
+ import { classifyAgentServiceFailure, startupFailureMessage } from "@jini-ai/agent-runtime";
3
3
  import { continuationRequest } from "../../core/durable-runs/continuation.js";
4
4
  import { isAwaitingAnswer } from "../../core/run-activity.js";
5
5
  import { RECOVERY_LIMIT, RUN_STALENESS_MS, SAVED_WORK_NOTICE, AWAITING_ANSWER_NOTICE, EXHAUSTED_NOTICE } from "../../core/durable-runs/policies.js";
@@ -73,6 +73,11 @@ function attemptFailure({ diagnostics }, _optional = {}) {
73
73
  }
74
74
  /** Keep the notice bounded and scoped to the same executor diagnostics as failure classification. */
75
75
  function lastDiagnosticLine({ diagnostics }, _optional = {}) {
76
+ // Startup evidence is already bounded, but redact again for older saved events. Keep the
77
+ // complete stage/cause block; a last-line/300-character tail erased its useful context.
78
+ const startup = diagnostics.lastIndexOf('Startup stage:');
79
+ if (startup >= 0)
80
+ return startupFailureMessage({ stage: 'saved startup failure', error: diagnostics.slice(startup) }, {});
76
81
  return diagnostics.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).at(-1)?.slice(0, 300);
77
82
  }
78
83
  function attemptFailureDetail({ run }, _optional = {}) {
@@ -130,6 +135,23 @@ function continuesNow({ run, trigger, now }, _optional = {}) {
130
135
  /** Recovery coordinator behind explicit host ports. One CAS owns both the attempt and its conversation slot.
131
136
  * Each recovery decision logs one `logger.info` line (default console) of run metadata. */
132
137
  export function createDurableRecovery(ports, { logger = console } = {}) {
138
+ /** Replay starts from attemptBase. Carry this attempt's saved launch notice into it too, so
139
+ * reconnect/reload cannot replace that evidence with the daemon's shorter replay prefix.
140
+ * O(e) in saved events; no additional store read, write, or polling. */
141
+ function attach(run) {
142
+ const events = run.message.events ?? [];
143
+ const noticeIndex = lastIndexWhere({ events, match: event => event.kind === 'status' && event.code === 'run_launch_unconfirmed' });
144
+ const marker = lastIndexWhere({ events, match: event => event.kind === 'status' && event.code === 'run_recovering' });
145
+ if (noticeIndex <= marker) {
146
+ ports.attach(run, {});
147
+ return;
148
+ }
149
+ const notice = events[noticeIndex];
150
+ const base = [...run.attemptBase];
151
+ if (!base.includes(notice))
152
+ base.push(notice);
153
+ ports.attach({ ...run, attemptBase: base }, {});
154
+ }
133
155
  async function finalize(run, notice, { canceled = false, detail } = {}) {
134
156
  await ports.cancelAttempt(run, {}).catch(() => undefined);
135
157
  // Persist the notice as an event: hook errors are live-only and would leave a reloaded
@@ -145,15 +167,30 @@ export function createDurableRecovery(ports, { logger = console } = {}) {
145
167
  return false;
146
168
  return ports.verifyChildDead(run.child, {}).catch(() => false);
147
169
  }
170
+ /** Persist rejection evidence but leave liveness and retry decisions to the existing probe. */
148
171
  async function launchNext({ run, next, native }, _optional = {}) {
172
+ let stage = 'recovery launch';
149
173
  try {
150
174
  await ports.launch({ run: next, request: continuationRequest({ run: { ...run, message: next.message, transcript: next.transcript }, native }, {}) }, {});
175
+ stage = 'recovery clock';
151
176
  await ports.store.recoveryClock({ runId: next.runId, now: ports.now(), active: false }, {});
152
177
  }
153
- catch {
178
+ catch (error) {
154
179
  // A rejected/lost start response is uncertain: the daemon may already be executing. The
155
180
  // same idempotent attempt is probed by the attached watcher before another CAS is possible.
181
+ const diagnostic = { kind: 'status', code: 'run_launch_unconfirmed',
182
+ label: 'The assistant start response was not confirmed. Checking whether this attempt is running.',
183
+ detail: startupFailureMessage({ stage, error }, {
184
+ notice: 'The assistant start response was not confirmed. Wait while this attempt is checked.',
185
+ }) };
186
+ const events = [...(next.message.events ?? []), diagnostic];
187
+ // Preserve the saved answer and all prior events in the existing projection write. The
188
+ // checkpoint's generation fence rejects a concurrent stop or successor attempt.
189
+ await ports.checkpoint?.({ conversationId: next.conversationId, messageId: next.messageId,
190
+ runId: next.runId, content: next.message.content, events }, {}).catch(() => false);
191
+ return { ...next, message: { ...next.message, events } };
156
192
  }
193
+ return next;
157
194
  }
158
195
  async function continueDead(run) {
159
196
  await ports.cancelAttempt(run, {}).catch(() => undefined);
@@ -172,8 +209,8 @@ export function createDurableRecovery(ports, { logger = console } = {}) {
172
209
  return "superseded";
173
210
  if (next.cancelReason)
174
211
  return finalize(next, STOPPED_NOTICE, { canceled: true });
175
- await launchNext({ run, next, native });
176
- ports.attach(next, {});
212
+ const launched = await launchNext({ run, next, native });
213
+ attach(launched);
177
214
  return "continued";
178
215
  }
179
216
  async function probeAttempt({ run, trigger, liveRunId }, _optional = {}) {
@@ -185,7 +222,7 @@ export function createDurableRecovery(ports, { logger = console } = {}) {
185
222
  }
186
223
  async function reattach(run) {
187
224
  await ports.store.recoveryClock({ runId: run.runId, now: ports.now(), active: false }, {});
188
- ports.attach(run, {});
225
+ attach(run);
189
226
  return "reattached";
190
227
  }
191
228
  async function finalizeFailure({ run, failure, diagnostics }, _optional = {}) {
@@ -259,7 +296,7 @@ export function createDurableRecovery(ports, { logger = console } = {}) {
259
296
  // Give that idempotent launch time to appear before a 404 can advance its generation.
260
297
  if (continuesNow({ run, trigger, now: ports.now() }))
261
298
  return continueDead(run);
262
- ports.attach(run, {});
299
+ attach(run);
263
300
  return "waiting";
264
301
  }
265
302
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/chat",
3
- "version": "0.6.22",
3
+ "version": "0.7.0",
4
4
  "description": "Jini's chat/artifact frontend, consolidated into one package with two subpaths: framework-free chat vocabulary and pure parsers in `/core`, headless hooks + presentational components + slots in `/react`. Import only the layer you need.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -38,7 +38,8 @@
38
38
  "./vanilla": "browser",
39
39
  "./browser/lazy-loader": "browser",
40
40
  "./vanilla/style.css": "browser",
41
- "./browser/frontend-session-bridge": "browser"
41
+ "./browser/frontend-session-bridge": "browser",
42
+ "./react/styles/chat-settings.css": "browser"
42
43
  },
43
44
  "neutralEntries": [
44
45
  "src/store/contracts"
@@ -192,7 +193,8 @@
192
193
  "types": "./dist/embed-widget/browser/frontend-session-bridge.d.ts",
193
194
  "import": "./dist/embed-widget/browser/frontend-session-bridge.js",
194
195
  "default": "./dist/embed-widget/browser/frontend-session-bridge.js"
195
- }
196
+ },
197
+ "./react/styles/chat-settings.css": "./dist/react/styles/chat-settings.css"
196
198
  },
197
199
  "files": [
198
200
  "dist",
@@ -214,10 +216,10 @@
214
216
  },
215
217
  "dependencies": {
216
218
  "kysely": "^0.29.6",
217
- "@jini-ai/core": "^0.6.22",
218
- "@jini-ai/agentic": "^0.6.19",
219
- "@jini-ai/diagnostics": "^0.6.22",
220
- "@jini-ai/db": "^0.6.19"
219
+ "@jini-ai/diagnostics": "^0.7.0",
220
+ "@jini-ai/db": "^0.7.0",
221
+ "@jini-ai/agentic": "^0.7.0",
222
+ "@jini-ai/core": "^0.7.0"
221
223
  },
222
224
  "peerDependencies": {
223
225
  "react": "^18.3.0 || ^19.0.0",
@@ -232,9 +234,9 @@
232
234
  "@radix-ui/react-radio-group": "^1.4.7",
233
235
  "@radix-ui/react-select": "^2.3.7",
234
236
  "@radix-ui/react-slot": "^1.3.3",
235
- "@jini-ai/agent-runtime": "^0.6.10",
236
- "@jini-ai/protocol": "^0.6.10",
237
- "@jini-ai/ui": "^0.6.10"
237
+ "@jini-ai/agent-runtime": "^0.7.0",
238
+ "@jini-ai/protocol": "^0.7.0",
239
+ "@jini-ai/ui": "^0.7.0"
238
240
  },
239
241
  "devDependencies": {
240
242
  "@mcp-ui/client": "7.1.1",
@@ -261,13 +263,14 @@
261
263
  "pg": "8.23.0",
262
264
  "@ag-ui/core": "0.0.58",
263
265
  "fast-check": "4.3.0",
264
- "@jini-ai/agent-runtime": "0.6.22",
265
- "@jini-ai/agentic": "^0.6.19",
266
- "@jini-ai/protocol": "^0.6.19",
267
- "@jini-ai/core": "^0.6.22",
268
- "@jini-ai/diagnostics": "^0.6.22",
269
- "@jini-ai/ui": "^0.6.22",
270
- "@jini-ai/db": "0.6.19"
266
+ "@jini-ai/ui-kit": "^0.7.0",
267
+ "@jini-ai/db": "0.7.0",
268
+ "@jini-ai/agentic": "^0.7.0",
269
+ "@jini-ai/agent-runtime": "0.7.0",
270
+ "@jini-ai/core": "^0.7.0",
271
+ "@jini-ai/diagnostics": "^0.7.0",
272
+ "@jini-ai/protocol": "^0.7.0",
273
+ "@jini-ai/ui": "^0.7.0"
271
274
  },
272
275
  "typesVersions": {
273
276
  "*": {
@@ -384,7 +387,7 @@
384
387
  }
385
388
  },
386
389
  "scripts": {
387
- "build": "tsc -p tsconfig.json && mkdir -p dist/react/styles && cp src/react/styles/reference.css dist/react/styles/ && mkdir -p dist/embed-widget/vanilla && node --input-type=module -e \"import {writeFileSync,readFileSync} from 'node:fs'; import {CHAT_BUBBLE_STYLE} from './dist/embed-widget/browser/lazy-loader.js'; writeFileSync('dist/embed-widget/vanilla/style.css',CHAT_BUBBLE_STYLE+'\\n'+readFileSync('src/embed-widget/vanilla/style.css','utf8'));\"",
390
+ "build": "tsc -p tsconfig.json && mkdir -p dist/react/styles && cp src/react/styles/*.css dist/react/styles/ && mkdir -p dist/embed-widget/vanilla && node --input-type=module -e \"import {writeFileSync,readFileSync} from 'node:fs'; import {CHAT_BUBBLE_STYLE} from './dist/embed-widget/browser/lazy-loader.js'; writeFileSync('dist/embed-widget/vanilla/style.css',CHAT_BUBBLE_STYLE+'\\n'+readFileSync('src/embed-widget/vanilla/style.css','utf8'));\"",
388
391
  "typecheck": "tsc -p tsconfig.json --noEmit",
389
392
  "test": "vitest run",
390
393
  "test:coverage": "vitest run --coverage",