@runtypelabs/persona 4.19.0 → 4.21.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.
- package/dist/animations/glyph-cycle.d.cts +1 -1
- package/dist/animations/glyph-cycle.d.ts +1 -1
- package/dist/animations/{types-CG-bLFmk.d.cts → types-B_JdVK9o.d.cts} +2 -0
- package/dist/animations/{types-CG-bLFmk.d.ts → types-B_JdVK9o.d.ts} +2 -0
- package/dist/animations/wipe.d.cts +1 -1
- package/dist/animations/wipe.d.ts +1 -1
- package/dist/animations-extra.d.cts +2 -0
- package/dist/animations-extra.d.ts +2 -0
- package/dist/approval-ui.d.cts +99 -5
- package/dist/approval-ui.d.ts +99 -5
- package/dist/artifacts-ui.d.cts +99 -5
- package/dist/artifacts-ui.d.ts +99 -5
- package/dist/codegen.cjs +1 -1
- package/dist/codegen.js +1 -1
- package/dist/context-mentions.d.cts +99 -5
- package/dist/context-mentions.d.ts +99 -5
- package/dist/event-stream-view.d.cts +99 -5
- package/dist/event-stream-view.d.ts +99 -5
- package/dist/forms-ui.d.cts +123 -9
- package/dist/forms-ui.d.ts +123 -9
- package/dist/history-view.d.cts +2 -0
- package/dist/history-view.d.ts +2 -0
- package/dist/index.cjs +51 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +128 -10
- package/dist/index.d.ts +128 -10
- package/dist/index.global.js +34 -34
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +51 -51
- package/dist/index.js.map +1 -1
- package/dist/launcher.global.js.map +1 -1
- package/dist/session-reconnect.d.cts +99 -5
- package/dist/session-reconnect.d.ts +99 -5
- package/dist/smart-dom-reader.d.cts +99 -5
- package/dist/smart-dom-reader.d.ts +99 -5
- package/dist/theme-editor-preview.cjs +53 -53
- package/dist/theme-editor-preview.d.cts +99 -5
- package/dist/theme-editor-preview.d.ts +99 -5
- package/dist/theme-editor-preview.js +31 -31
- package/dist/theme-editor.d.cts +99 -5
- package/dist/theme-editor.d.ts +99 -5
- package/dist/theme-reference.cjs +1 -1
- package/dist/theme-reference.d.cts +46 -5
- package/dist/theme-reference.d.ts +46 -5
- package/dist/theme-reference.js +1 -1
- package/dist/webmcp-runtime.d.cts +16 -0
- package/dist/webmcp-runtime.d.ts +16 -0
- package/dist/widget.css +1 -1
- package/package.json +1 -1
- package/src/client-visitor-history.test.ts +342 -3
- package/src/client.test.ts +141 -3
- package/src/client.ts +157 -39
- package/src/components/composer-actions.ts +27 -1
- package/src/components/composer-model-picker.ts +4 -14
- package/src/components/composer-overflow-menu.ts +14 -0
- package/src/components/composer-parts.ts +20 -0
- package/src/generated/runtype-openapi-contract.ts +2 -0
- package/src/index-core.ts +2 -0
- package/src/session.ts +139 -103
- package/src/session.webmcp.test.ts +48 -1
- package/src/styles/widget-styles.test.ts +83 -1
- package/src/styles/widget.css +50 -14
- package/src/theme-reference.ts +1 -1
- package/src/types/theme.ts +47 -5
- package/src/types.ts +63 -0
- package/src/ui.composer-action-visibility.test.ts +202 -0
- package/src/ui.composer-models.test.ts +37 -0
- package/src/ui.composer-modes.test.ts +82 -0
- package/src/ui.composer-overflow.test.ts +78 -0
- package/src/ui.history-lifecycle.test.ts +2 -2
- package/src/ui.ts +77 -6
- package/src/utils/__snapshots__/tokens-parity.test.ts.snap +1633 -686
- package/src/utils/composer-modes.test.ts +33 -0
- package/src/utils/composer-modes.ts +19 -2
- package/src/utils/tokens-parity.test.ts +20 -0
- package/src/utils/tokens.test.ts +76 -0
- package/src/utils/tokens.ts +4 -4
package/src/ui.ts
CHANGED
|
@@ -8370,6 +8370,22 @@ export const createAgentExperience = (
|
|
|
8370
8370
|
const stored = persistentMetadata[key];
|
|
8371
8371
|
return typeof stored === 'string' ? stored : null;
|
|
8372
8372
|
};
|
|
8373
|
+
const readStoredResumableHandle = (): {
|
|
8374
|
+
executionId: string;
|
|
8375
|
+
after: string;
|
|
8376
|
+
} | null => {
|
|
8377
|
+
const stored = persistentMetadata.durableResume;
|
|
8378
|
+
if (!stored || typeof stored !== 'object') return null;
|
|
8379
|
+
const candidate = stored as Record<string, unknown>;
|
|
8380
|
+
return typeof candidate.executionId === 'string' &&
|
|
8381
|
+
candidate.executionId.length > 0 &&
|
|
8382
|
+
typeof candidate.after === 'string' &&
|
|
8383
|
+
candidate.after.length > 0
|
|
8384
|
+
? { executionId: candidate.executionId, after: candidate.after }
|
|
8385
|
+
: null;
|
|
8386
|
+
};
|
|
8387
|
+
const personaOwnsClientTokenRecovery =
|
|
8388
|
+
Boolean(config.clientToken) && typeof config.reconnectStream !== "function";
|
|
8373
8389
|
if (config.clientToken) {
|
|
8374
8390
|
config = {
|
|
8375
8391
|
...config,
|
|
@@ -8394,11 +8410,11 @@ export const createAgentExperience = (
|
|
|
8394
8410
|
};
|
|
8395
8411
|
}
|
|
8396
8412
|
|
|
8397
|
-
//
|
|
8398
|
-
// persistence-disabled).
|
|
8399
|
-
//
|
|
8413
|
+
// Exact-browser visitor credential store, keyed on (clientToken, keyPrefix,
|
|
8414
|
+
// persistence-disabled). Durable reconnect and optional visitor history use
|
|
8415
|
+
// the same credential but negotiate independent server capabilities.
|
|
8400
8416
|
const historyStoreToken = (): string | null =>
|
|
8401
|
-
config.
|
|
8417
|
+
config.clientToken ?? null;
|
|
8402
8418
|
const buildVisitorStore = (token: string) =>
|
|
8403
8419
|
createVisitorStore(token, currentKeyPrefix(), config.persistState === false);
|
|
8404
8420
|
const initialStoreToken = historyStoreToken();
|
|
@@ -8446,6 +8462,16 @@ export const createAgentExperience = (
|
|
|
8446
8462
|
pendingDisplayProjections: pending,
|
|
8447
8463
|
}));
|
|
8448
8464
|
},
|
|
8465
|
+
getStoredResumableHandle: readStoredResumableHandle,
|
|
8466
|
+
setStoredResumableHandle: (handle) => {
|
|
8467
|
+
if (!handle) {
|
|
8468
|
+
dropMetadataKey('durableResume');
|
|
8469
|
+
return;
|
|
8470
|
+
}
|
|
8471
|
+
updateSessionMetadata((prev) => ({ ...prev, durableResume: handle }));
|
|
8472
|
+
},
|
|
8473
|
+
shouldResumeDurableConversation: () =>
|
|
8474
|
+
personaOwnsClientTokenRecovery && readStoredResumableHandle() !== null,
|
|
8449
8475
|
...(hostOwnsConversationId
|
|
8450
8476
|
? {}
|
|
8451
8477
|
: {
|
|
@@ -8463,6 +8489,46 @@ export const createAgentExperience = (
|
|
|
8463
8489
|
},
|
|
8464
8490
|
}),
|
|
8465
8491
|
};
|
|
8492
|
+
|
|
8493
|
+
// Runtype client-token widgets already possess the session, conversation,
|
|
8494
|
+
// and exact-browser visitor credential needed by the public reconnect route.
|
|
8495
|
+
// Install Persona's existing reconnect hooks by default so this mode follows
|
|
8496
|
+
// the same path as host-configured durable dashboard chats.
|
|
8497
|
+
if (personaOwnsClientTokenRecovery) {
|
|
8498
|
+
const hostExecutionState = config.onExecutionState;
|
|
8499
|
+
const recoveryWindow = mount.ownerDocument.defaultView;
|
|
8500
|
+
let pageExitInProgress = false;
|
|
8501
|
+
const markPageExit = () => {
|
|
8502
|
+
pageExitInProgress = true;
|
|
8503
|
+
};
|
|
8504
|
+
const markPageActive = () => {
|
|
8505
|
+
pageExitInProgress = false;
|
|
8506
|
+
};
|
|
8507
|
+
recoveryWindow?.addEventListener("beforeunload", markPageExit);
|
|
8508
|
+
recoveryWindow?.addEventListener("pagehide", markPageExit);
|
|
8509
|
+
recoveryWindow?.addEventListener("pageshow", markPageActive);
|
|
8510
|
+
destroyCallbacks.push(() => {
|
|
8511
|
+
recoveryWindow?.removeEventListener("beforeunload", markPageExit);
|
|
8512
|
+
recoveryWindow?.removeEventListener("pagehide", markPageExit);
|
|
8513
|
+
recoveryWindow?.removeEventListener("pageshow", markPageActive);
|
|
8514
|
+
});
|
|
8515
|
+
config = {
|
|
8516
|
+
...config,
|
|
8517
|
+
reconnectStream:
|
|
8518
|
+
config.reconnectStream ??
|
|
8519
|
+
((ctx) => session.getClient().reconnectClientTokenStream(ctx)),
|
|
8520
|
+
onExecutionState: (handle) => {
|
|
8521
|
+
if (handle || !pageExitInProgress) {
|
|
8522
|
+
historyInternals.setStoredResumableHandle?.(
|
|
8523
|
+
handle
|
|
8524
|
+
? { executionId: handle.executionId, after: handle.lastEventId }
|
|
8525
|
+
: null
|
|
8526
|
+
);
|
|
8527
|
+
}
|
|
8528
|
+
hostExecutionState?.(handle);
|
|
8529
|
+
},
|
|
8530
|
+
};
|
|
8531
|
+
}
|
|
8466
8532
|
const syncVisitorStore = () => {
|
|
8467
8533
|
const token = historyStoreToken();
|
|
8468
8534
|
if (
|
|
@@ -11297,8 +11363,13 @@ export const createAgentExperience = (
|
|
|
11297
11363
|
// the restored conversation. Fires AFTER hydration so the trailing partial
|
|
11298
11364
|
// assistant bubble exists for the replay to append to.
|
|
11299
11365
|
const maybeBootResume = () => {
|
|
11300
|
-
|
|
11301
|
-
|
|
11366
|
+
const resume =
|
|
11367
|
+
config.resume ??
|
|
11368
|
+
(personaOwnsClientTokenRecovery
|
|
11369
|
+
? historyInternals.getStoredResumableHandle?.()
|
|
11370
|
+
: null);
|
|
11371
|
+
if (resume && typeof config.reconnectStream === "function") {
|
|
11372
|
+
session.resumeFromHandle(resume);
|
|
11302
11373
|
}
|
|
11303
11374
|
};
|
|
11304
11375
|
|