basalt-ui 1.11.0 → 1.12.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/AGENTS.md +21 -21
- package/CHANGELOG.md +15 -0
- package/README.md +36 -27
- package/agent/rules/basalt-content.md +16 -3
- package/dist/agent/adapter.d.ts +146 -0
- package/dist/agent/adapter.d.ts.map +1 -0
- package/dist/agent/adapter.js +473 -0
- package/dist/agent/adapter.test.d.ts +2 -0
- package/dist/agent/adapter.test.d.ts.map +1 -0
- package/dist/agent/ai-sdk-transport.test.d.ts +2 -0
- package/dist/agent/ai-sdk-transport.test.d.ts.map +1 -0
- package/dist/agent/coalesce.d.ts +20 -4
- package/dist/agent/coalesce.d.ts.map +1 -1
- package/dist/agent/coalesce.js +76 -8
- package/dist/agent/coalesce.test.d.ts +2 -0
- package/dist/agent/coalesce.test.d.ts.map +1 -0
- package/dist/agent/foreign.test.d.ts +2 -0
- package/dist/agent/foreign.test.d.ts.map +1 -0
- package/dist/agent/id.d.ts +30 -0
- package/dist/agent/id.d.ts.map +1 -1
- package/dist/agent/id.js +16 -0
- package/dist/agent/id.test.d.ts +2 -0
- package/dist/agent/id.test.d.ts.map +1 -0
- package/dist/agent/index.d.ts +2 -0
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +3 -0
- package/dist/agent/merge.d.ts.map +1 -1
- package/dist/agent/merge.js +19 -7
- package/dist/agent/merge.test.d.ts +2 -0
- package/dist/agent/merge.test.d.ts.map +1 -0
- package/dist/agent/part-list.d.ts +49 -34
- package/dist/agent/part-list.d.ts.map +1 -1
- package/dist/agent/part-list.js +42 -6
- package/dist/agent/part-list.test.d.ts +2 -0
- package/dist/agent/part-list.test.d.ts.map +1 -0
- package/dist/agent/parts.d.ts +46 -10
- package/dist/agent/parts.d.ts.map +1 -1
- package/dist/agent/parts.js +16 -6
- package/dist/agent/parts.test.d.ts +2 -0
- package/dist/agent/parts.test.d.ts.map +1 -0
- package/dist/agent/thread.d.ts +14 -0
- package/dist/agent/thread.d.ts.map +1 -1
- package/dist/agent/thread.js +8 -2
- package/dist/agent/thread.test.d.ts +2 -0
- package/dist/agent/thread.test.d.ts.map +1 -0
- package/dist/agent/transport.test.d.ts +2 -0
- package/dist/agent/transport.test.d.ts.map +1 -0
- package/dist/agent/use-agent-stream.test.d.ts +2 -0
- package/dist/agent/use-agent-stream.test.d.ts.map +1 -0
- package/dist/agent/use-agent-thread-runs.foreign.test.d.ts +2 -0
- package/dist/agent/use-agent-thread-runs.foreign.test.d.ts.map +1 -0
- package/dist/agent/use-agent-thread-runs.resume.test.d.ts +2 -0
- package/dist/agent/use-agent-thread-runs.resume.test.d.ts.map +1 -0
- package/dist/agent/use-agent-thread-runs.test.d.ts +2 -0
- package/dist/agent/use-agent-thread-runs.test.d.ts.map +1 -0
- package/dist/agent/use-agent-thread-runs.wedge.test.d.ts +2 -0
- package/dist/agent/use-agent-thread-runs.wedge.test.d.ts.map +1 -0
- package/dist/agent-chat/composer.d.ts +130 -8
- package/dist/agent-chat/composer.d.ts.map +1 -1
- package/dist/agent-chat/composer.js +189 -23
- package/dist/agent-chat/composer.test.d.ts +2 -0
- package/dist/agent-chat/composer.test.d.ts.map +1 -0
- package/dist/agent-chat/index.d.ts +1 -1
- package/dist/agent-chat/index.d.ts.map +1 -1
- package/dist/agent-chat/thread-detail-panel.d.ts.map +1 -1
- package/dist/agent-chat/thread-detail-panel.js +1 -1
- package/dist/agent-chat/thread-message.d.ts.map +1 -1
- package/dist/agent-chat/thread-message.js +14 -3
- package/dist/agent-chat/thread-message.test.d.ts +2 -0
- package/dist/agent-chat/thread-message.test.d.ts.map +1 -0
- package/dist/agent-chat/thread-workspace.js +1 -1
- package/dist/agent-chat/tool-chip.test.d.ts +2 -0
- package/dist/agent-chat/tool-chip.test.d.ts.map +1 -0
- package/dist/charts/primitives/ChartFrame.test.d.ts +2 -0
- package/dist/charts/primitives/ChartFrame.test.d.ts.map +1 -0
- package/dist/charts/utils/domain.test.d.ts +2 -0
- package/dist/charts/utils/domain.test.d.ts.map +1 -0
- package/dist/cli/check-theme.test.d.ts +2 -0
- package/dist/cli/check-theme.test.d.ts.map +1 -0
- package/dist/cli/help.test.d.ts +2 -0
- package/dist/cli/help.test.d.ts.map +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/init-sync.test.d.ts +2 -0
- package/dist/cli/init-sync.test.d.ts.map +1 -0
- package/dist/cli/placement-engine.test.d.ts +2 -0
- package/dist/cli/placement-engine.test.d.ts.map +1 -0
- package/dist/cli/tarball-parity.test.d.ts +2 -0
- package/dist/cli/tarball-parity.test.d.ts.map +1 -0
- package/dist/cli/template-format.test.d.ts +2 -0
- package/dist/cli/template-format.test.d.ts.map +1 -0
- package/dist/cli/template-ledger.test.d.ts +2 -0
- package/dist/cli/template-ledger.test.d.ts.map +1 -0
- package/dist/cli/tokens-css.test.d.ts +2 -0
- package/dist/cli/tokens-css.test.d.ts.map +1 -0
- package/dist/content/article-actions.test.d.ts +2 -0
- package/dist/content/article-actions.test.d.ts.map +1 -0
- package/dist/content/article-model.test.d.ts +2 -0
- package/dist/content/article-model.test.d.ts.map +1 -0
- package/dist/content/block-split.test.d.ts +2 -0
- package/dist/content/block-split.test.d.ts.map +1 -0
- package/dist/content/fence-block.d.ts +37 -10
- package/dist/content/fence-block.d.ts.map +1 -1
- package/dist/content/fence-block.js +80 -14
- package/dist/content/heading-components.d.ts.map +1 -1
- package/dist/content/heading-components.js +7 -4
- package/dist/content/heading-components.test.d.ts +2 -0
- package/dist/content/heading-components.test.d.ts.map +1 -0
- package/dist/content/index.d.ts +6 -3
- package/dist/content/index.d.ts.map +1 -1
- package/dist/content/index.js +5 -1
- package/dist/content/markdown.d.ts +101 -14
- package/dist/content/markdown.d.ts.map +1 -1
- package/dist/content/markdown.js +141 -28
- package/dist/content/markdown.test.d.ts +2 -0
- package/dist/content/markdown.test.d.ts.map +1 -0
- package/dist/content/prose.module.css.test.d.ts +2 -0
- package/dist/content/prose.module.css.test.d.ts.map +1 -0
- package/dist/content/sanitize.d.ts +170 -0
- package/dist/content/sanitize.d.ts.map +1 -0
- package/dist/content/sanitize.js +178 -0
- package/dist/content/sanitize.test.d.ts +2 -0
- package/dist/content/sanitize.test.d.ts.map +1 -0
- package/dist/content/slug.test.d.ts +2 -0
- package/dist/content/slug.test.d.ts.map +1 -0
- package/dist/dashboard/stat-card.test.d.ts +2 -0
- package/dist/dashboard/stat-card.test.d.ts.map +1 -0
- package/dist/guard/check-source.test.d.ts +2 -0
- package/dist/guard/check-source.test.d.ts.map +1 -0
- package/dist/guard/guard-hook.test.d.ts +2 -0
- package/dist/guard/guard-hook.test.d.ts.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/provider/index.test.d.ts +2 -0
- package/dist/provider/index.test.d.ts.map +1 -0
- package/dist/provider/lab-theme.test.d.ts +2 -0
- package/dist/provider/lab-theme.test.d.ts.map +1 -0
- package/dist/router-tanstack/multi-search-param-store.test.d.ts +2 -0
- package/dist/router-tanstack/multi-search-param-store.test.d.ts.map +1 -0
- package/dist/styles.floor.test.d.ts +2 -0
- package/dist/styles.floor.test.d.ts.map +1 -0
- package/dist/surfaces.d.ts +4 -4
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +12 -3
- package/dist/theme/border-coverage.test.d.ts +18 -0
- package/dist/theme/border-coverage.test.d.ts.map +1 -0
- package/dist/theme/contrast.test.d.ts +2 -0
- package/dist/theme/contrast.test.d.ts.map +1 -0
- package/dist/theme/density-option.test.d.ts +2 -0
- package/dist/theme/density-option.test.d.ts.map +1 -0
- package/dist/theme/density-relations.test.d.ts +2 -0
- package/dist/theme/density-relations.test.d.ts.map +1 -0
- package/dist/theme/derive-theme.test.d.ts +2 -0
- package/dist/theme/derive-theme.test.d.ts.map +1 -0
- package/dist/theme/fonts-option.test.d.ts +2 -0
- package/dist/theme/fonts-option.test.d.ts.map +1 -0
- package/dist/theme/radius-option.test.d.ts +2 -0
- package/dist/theme/radius-option.test.d.ts.map +1 -0
- package/dist/theme/radius.test.d.ts +2 -0
- package/dist/theme/radius.test.d.ts.map +1 -0
- package/dist/theme/shadow-surfaces.test.d.ts +26 -0
- package/dist/theme/shadow-surfaces.test.d.ts.map +1 -0
- package/dist/theme/spacing.test.d.ts +2 -0
- package/dist/theme/spacing.test.d.ts.map +1 -0
- package/dist/theme/use-basalt-spacing.test.d.ts +2 -0
- package/dist/theme/use-basalt-spacing.test.d.ts.map +1 -0
- package/dist/theme-lab/derive-controls.test.d.ts +2 -0
- package/dist/theme-lab/derive-controls.test.d.ts.map +1 -0
- package/dist/theme-lab/derive-state.test.d.ts +2 -0
- package/dist/theme-lab/derive-state.test.d.ts.map +1 -0
- package/dist/theme-lab/theme-lab.test.d.ts +2 -0
- package/dist/theme-lab/theme-lab.test.d.ts.map +1 -0
- package/dist/tokens/build-fonts-css.test.d.ts +2 -0
- package/dist/tokens/build-fonts-css.test.d.ts.map +1 -0
- package/dist/tokens/build-radius-css.test.d.ts +2 -0
- package/dist/tokens/build-radius-css.test.d.ts.map +1 -0
- package/dist/tokens/density.test.d.ts +2 -0
- package/dist/tokens/density.test.d.ts.map +1 -0
- package/dist/tokens/derive-radius.test.d.ts +2 -0
- package/dist/tokens/derive-radius.test.d.ts.map +1 -0
- package/dist/tokens/derive.test.d.ts +2 -0
- package/dist/tokens/derive.test.d.ts.map +1 -0
- package/dist/tokens/palette.test.d.ts +2 -0
- package/dist/tokens/palette.test.d.ts.map +1 -0
- package/dist/vite-color-mix.test.d.ts +2 -0
- package/dist/vite-color-mix.test.d.ts.map +1 -0
- package/dist/vite.test.d.ts +2 -0
- package/dist/vite.test.d.ts.map +1 -0
- package/llms.txt +6 -6
- package/package.json +6 -1
- package/src/agent/adapter.test.ts +1403 -0
- package/src/agent/adapter.ts +887 -0
- package/src/agent/ai-sdk-transport.test.ts +53 -26
- package/src/agent/coalesce.test.ts +202 -9
- package/src/agent/coalesce.ts +126 -15
- package/src/agent/foreign.test.ts +5 -1
- package/src/agent/id.test.ts +6 -2
- package/src/agent/id.ts +48 -0
- package/src/agent/index.ts +8 -0
- package/src/agent/merge.test.ts +87 -0
- package/src/agent/merge.ts +57 -10
- package/src/agent/part-list.test.tsx +31 -1
- package/src/agent/part-list.tsx +77 -29
- package/src/agent/parts.test.ts +121 -4
- package/src/agent/parts.ts +78 -17
- package/src/agent/thread.test.ts +75 -2
- package/src/agent/thread.ts +21 -1
- package/src/agent/use-agent-stream.test.tsx +9 -5
- package/src/agent/use-agent-thread-runs.foreign.test.tsx +5 -0
- package/src/agent/use-agent-thread-runs.resume.test.tsx +16 -11
- package/src/agent/use-agent-thread-runs.test.tsx +30 -17
- package/src/agent/use-agent-thread-runs.wedge.test.tsx +13 -7
- package/src/agent-chat/composer.test.tsx +924 -0
- package/src/agent-chat/composer.tsx +521 -52
- package/src/agent-chat/index.ts +1 -1
- package/src/agent-chat/thread-detail-panel.tsx +3 -1
- package/src/agent-chat/thread-message.test.tsx +141 -1
- package/src/agent-chat/thread-message.tsx +29 -4
- package/src/agent-chat/thread-workspace.tsx +1 -1
- package/src/cli/index.ts +0 -1
- package/src/cli/template-format.test.ts +2 -2
- package/src/content/fence-block.tsx +242 -15
- package/src/content/heading-components.test.tsx +65 -0
- package/src/content/heading-components.tsx +26 -5
- package/src/content/index.ts +19 -3
- package/src/content/markdown.test.tsx +603 -0
- package/src/content/markdown.tsx +355 -35
- package/src/content/sanitize.test.ts +659 -0
- package/src/content/sanitize.ts +510 -0
- package/src/dashboard/stat-card.test.tsx +6 -1
- package/src/index.ts +13 -1
- package/src/surfaces.ts +12 -3
- package/src/theme/contrast.test.ts +1 -4
- package/src/theme/density-relations.test.ts +4 -2
- package/src/theme/fonts-option.test.ts +7 -1
- package/src/theme/shadow-surfaces.test.ts +12 -6
- package/src/theme/use-basalt-spacing.test.tsx +2 -1
package/dist/agent/id.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../src/agent/id.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAuB,WAAW,CAAC,KAAK,SAAS;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,EAC9D,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,cAAc,CAAC,KAAK,CAAC,GAC5B,cAAc,CAAC,KAAK,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAUxC"}
|
|
1
|
+
{"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../src/agent/id.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAgBrC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAuB,WAAW,CAAC,KAAK,SAAS;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,EAC9D,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,cAAc,CAAC,KAAK,CAAC,GAC5B,cAAc,CAAC,KAAK,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAUxC"}
|
package/dist/agent/id.js
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
function mintThreadId() {
|
|
2
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
3
|
+
return crypto.randomUUID();
|
|
4
|
+
}
|
|
5
|
+
if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
|
|
6
|
+
const bytes = crypto.getRandomValues(new Uint8Array(16));
|
|
7
|
+
const hex = Array.from({ length: 16 }, (_, i) => {
|
|
8
|
+
const raw = bytes.at(i) ?? 0;
|
|
9
|
+
const byte = i === 6 ? raw & 15 | 64 : i === 8 ? raw & 63 | 128 : raw;
|
|
10
|
+
return byte.toString(16).padStart(2, "0");
|
|
11
|
+
}).join("");
|
|
12
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
13
|
+
}
|
|
14
|
+
return `id-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
15
|
+
}
|
|
1
16
|
async function* withPartIds(runId, source) {
|
|
2
17
|
let n = 0;
|
|
3
18
|
for await (const part of source) {
|
|
@@ -10,5 +25,6 @@ async function* withPartIds(runId, source) {
|
|
|
10
25
|
}
|
|
11
26
|
}
|
|
12
27
|
export {
|
|
28
|
+
mintThreadId,
|
|
13
29
|
withPartIds
|
|
14
30
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.test.d.ts","sourceRoot":"","sources":["../../src/agent/id.test.ts"],"names":[],"mappings":""}
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -55,4 +55,6 @@ export { createThreadsStore } from './thread.js';
|
|
|
55
55
|
export type { AgentThread, ThreadStatus, ThreadsStore, ThreadsStoreOptions } from './thread.js';
|
|
56
56
|
export { heuristicOutcome } from './outcome.js';
|
|
57
57
|
export type { AgentOutcome, OutcomeResolver } from './outcome.js';
|
|
58
|
+
export { createAdapterThreadsStore, threadsStoreAdapterContract } from './adapter.js';
|
|
59
|
+
export type { AdapterThreadsStoreOptions, ThreadsStoreAdapter, ThreadsStoreAdapterContractCase, } from './adapter.js';
|
|
58
60
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,YAAY,EACV,SAAS,EACT,cAAc,EACd,OAAO,EACP,SAAS,EACT,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,aAAa,EACb,UAAU,EACV,SAAS,GACV,MAAM,SAAS,CAAA;AAChB,O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AM,oBAAoB,CAAA;AAG/E,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAG5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,YAAY,EACV,cAAc,EACd,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,yBAAyB,CAAA;AAGhC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,aAAa,CAAA;AAGpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACvD,YAAY,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAGjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AAClD,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AAGvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC7C,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAG5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAG9D,OAAO,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAA;AAClF,YAAY,EACV,0BAA0B,EAC1B,mBAAmB,EACnB,+BAA+B,GAChC,MAAM,WAAW,CAAA"}
|
package/dist/agent/index.js
CHANGED
|
@@ -12,12 +12,14 @@ import { BasaltStickToBottom } from "./stick-to-bottom.js";
|
|
|
12
12
|
import { createChatHistoryStore } from "./history.js";
|
|
13
13
|
import { createThreadsStore } from "./thread.js";
|
|
14
14
|
import { heuristicOutcome } from "./outcome.js";
|
|
15
|
+
import { createAdapterThreadsStore, threadsStoreAdapterContract } from "./adapter.js";
|
|
15
16
|
export {
|
|
16
17
|
BasaltStickToBottom,
|
|
17
18
|
PartList,
|
|
18
19
|
TERMINAL_TOOL_STATES,
|
|
19
20
|
aiSdkTransport,
|
|
20
21
|
coalesceParts,
|
|
22
|
+
createAdapterThreadsStore,
|
|
21
23
|
createChatHistoryStore,
|
|
22
24
|
createThreadsStore,
|
|
23
25
|
definePartRenderers,
|
|
@@ -29,6 +31,7 @@ export {
|
|
|
29
31
|
mergePart,
|
|
30
32
|
narrowAgentPart,
|
|
31
33
|
parseAgentPart,
|
|
34
|
+
threadsStoreAdapterContract,
|
|
32
35
|
useAgentStream,
|
|
33
36
|
useAgentThreadRuns,
|
|
34
37
|
withPartIds
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/agent/merge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/agent/merge.ts"],"names":[],"mappings":"AAkCA;iGACiG;AACjG,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAoDrE,wBAAgB,SAAS,CAAC,KAAK,SAAS,QAAQ,EAAE,KAAK,EAAE,SAAS,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,GAAG,KAAK,EAAE,CAyB/F"}
|
package/dist/agent/merge.js
CHANGED
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
function isTextLikeType(type) {
|
|
2
2
|
return type === "text" || type === "reasoning";
|
|
3
3
|
}
|
|
4
|
-
function spliceText(
|
|
5
|
-
const offset = next.offset ??
|
|
6
|
-
return
|
|
4
|
+
function spliceText(existingText, next) {
|
|
5
|
+
const offset = clampOffset(next.offset ?? existingText.length, existingText.length);
|
|
6
|
+
return existingText.slice(0, offset) + next.text + existingText.slice(offset + next.text.length);
|
|
7
|
+
}
|
|
8
|
+
function clampOffset(offset, length) {
|
|
9
|
+
const clamped = Number.isFinite(offset) ? Math.min(Math.max(offset, 0), length) : length;
|
|
10
|
+
if (clamped !== offset && process.env["NODE_ENV"] !== "production") {
|
|
11
|
+
console.warn(
|
|
12
|
+
`[basalt] mergePart: text offset ${offset} out of range [0, ${length}] \u2014 clamped to ${clamped}`
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
return clamped;
|
|
7
16
|
}
|
|
8
17
|
function mergePart(parts, next) {
|
|
9
18
|
const index = parts.findIndex((part) => part.id === next.id);
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const spliceable = existing.type === next.type && isTextLikeType(next.type);
|
|
19
|
+
const existing = index === -1 ? void 0 : parts[index];
|
|
20
|
+
const spliceable = isTextLikeType(next.type) && (existing === void 0 || existing.type === next.type);
|
|
13
21
|
const merged = spliceable ? {
|
|
14
22
|
...next,
|
|
15
|
-
text: spliceText(
|
|
23
|
+
text: spliceText(
|
|
24
|
+
existing === void 0 ? "" : existing.text,
|
|
25
|
+
next
|
|
26
|
+
)
|
|
16
27
|
} : next;
|
|
28
|
+
if (existing === void 0) return [...parts, merged];
|
|
17
29
|
const out = parts.slice();
|
|
18
30
|
out[index] = merged;
|
|
19
31
|
return out;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.test.d.ts","sourceRoot":"","sources":["../../src/agent/merge.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
import type { JSX } from 'react';
|
|
2
2
|
import type { AgentPart } from './parts.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
index: number;
|
|
14
|
-
}) => JSX.Element | null;
|
|
15
|
-
export type ToolCallPartRenderer<TPart extends AgentPart = AgentPart> = (props: {
|
|
16
|
-
part: Extract<TPart, {
|
|
17
|
-
type: 'tool';
|
|
18
|
-
}>;
|
|
19
|
-
index: number;
|
|
20
|
-
}) => JSX.Element | null;
|
|
21
|
-
export type SourcePartRenderer<TPart extends AgentPart = AgentPart> = (props: {
|
|
22
|
-
part: Extract<TPart, {
|
|
23
|
-
type: 'source';
|
|
24
|
-
}>;
|
|
25
|
-
index: number;
|
|
26
|
-
}) => JSX.Element | null;
|
|
27
|
-
export type ErrorPartRenderer<TPart extends AgentPart = AgentPart> = (props: {
|
|
28
|
-
part: Extract<TPart, {
|
|
29
|
-
type: 'error';
|
|
30
|
-
}>;
|
|
3
|
+
/**
|
|
4
|
+
* The per-renderer argument. `settled` is `false` only while the message these parts belong to is
|
|
5
|
+
* still streaming — it converges this map toward the `PartRenderContext` a foreign renderer
|
|
6
|
+
* already receives (`./foreign`), rather than adding a third shape. Additive and
|
|
7
|
+
* source-compatible: an existing `({ part }) => …` renderer simply ignores it.
|
|
8
|
+
*
|
|
9
|
+
* Settlement is MONOTONE — a message that has settled never un-settles.
|
|
10
|
+
*/
|
|
11
|
+
type PartRenderArgs<TPart> = {
|
|
12
|
+
part: TPart;
|
|
31
13
|
index: number;
|
|
32
|
-
|
|
14
|
+
settled: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type TextPartRenderer<TPart extends AgentPart = AgentPart> = (props: PartRenderArgs<Extract<TPart, {
|
|
17
|
+
type: 'text';
|
|
18
|
+
}>>) => JSX.Element | null;
|
|
19
|
+
export type ReasoningPartRenderer<TPart extends AgentPart = AgentPart> = (props: PartRenderArgs<Extract<TPart, {
|
|
20
|
+
type: 'reasoning';
|
|
21
|
+
}>>) => JSX.Element | null;
|
|
22
|
+
export type ToolCallPartRenderer<TPart extends AgentPart = AgentPart> = (props: PartRenderArgs<Extract<TPart, {
|
|
23
|
+
type: 'tool';
|
|
24
|
+
}>>) => JSX.Element | null;
|
|
25
|
+
export type SourcePartRenderer<TPart extends AgentPart = AgentPart> = (props: PartRenderArgs<Extract<TPart, {
|
|
26
|
+
type: 'source';
|
|
27
|
+
}>>) => JSX.Element | null;
|
|
28
|
+
export type ErrorPartRenderer<TPart extends AgentPart = AgentPart> = (props: PartRenderArgs<Extract<TPart, {
|
|
29
|
+
type: 'error';
|
|
30
|
+
}>>) => JSX.Element | null;
|
|
33
31
|
/**
|
|
34
32
|
* Partial map of per-type renderers. Any omitted key falls back to the headless default.
|
|
35
33
|
*
|
|
36
34
|
* @example
|
|
37
35
|
* const renderers: Partial<AgentPartRenderers> = {
|
|
38
|
-
* text: ({ part }) =>
|
|
36
|
+
* text: ({ part, settled }) => (
|
|
37
|
+
* <Markdown streaming={!settled} contentTrust="untrusted" density="chat">{part.text}</Markdown>
|
|
38
|
+
* ),
|
|
39
39
|
* }
|
|
40
40
|
*/
|
|
41
41
|
export type AgentPartRenderers<TPart extends AgentPart = AgentPart> = {
|
|
@@ -50,10 +50,17 @@ export type PartListProps<TPart extends AgentPart = AgentPart> = {
|
|
|
50
50
|
readonly parts: TPart[];
|
|
51
51
|
/**
|
|
52
52
|
* Override individual part renderers. Omitted keys fall back to the headless defaults.
|
|
53
|
-
* Pass `{ text: ({ part }) => <Markdown streaming density="chat">{part.text}</Markdown> }`
|
|
54
|
-
* enable rich markdown rendering.
|
|
53
|
+
* Pass `{ text: ({ part, settled }) => <Markdown streaming={!settled} contentTrust="untrusted" density="chat">{part.text}</Markdown> }`
|
|
54
|
+
* to enable rich markdown rendering.
|
|
55
55
|
*/
|
|
56
56
|
readonly components?: Partial<AgentPartRenderers<TPart>>;
|
|
57
|
+
/**
|
|
58
|
+
* `false` while the message these parts belong to is still streaming — forwarded to every
|
|
59
|
+
* renderer so a text renderer can drop out of streaming mode (and a fenced mermaid/diagram can
|
|
60
|
+
* upgrade) once the turn finishes. Defaults to `true`: a caller that knows nothing about a run
|
|
61
|
+
* is rendering a finished list, and un-settled must be opted into by the thing that does know.
|
|
62
|
+
*/
|
|
63
|
+
readonly settled?: boolean;
|
|
57
64
|
};
|
|
58
65
|
/**
|
|
59
66
|
* Renders a list of AgentPart values via an exhaustive switch over part.type.
|
|
@@ -69,7 +76,15 @@ export type PartListProps<TPart extends AgentPart = AgentPart> = {
|
|
|
69
76
|
* // With basalt's own Markdown for the text renderer:
|
|
70
77
|
* import { PartList } from 'basalt-ui/agent'
|
|
71
78
|
* import { Markdown } from 'basalt-ui/content'
|
|
72
|
-
* <PartList
|
|
79
|
+
* <PartList
|
|
80
|
+
* parts={parts}
|
|
81
|
+
* components={{
|
|
82
|
+
* text: ({ part, settled }) => (
|
|
83
|
+
* <Markdown streaming={!settled} contentTrust="untrusted" density="chat">{part.text}</Markdown>
|
|
84
|
+
* ),
|
|
85
|
+
* }}
|
|
86
|
+
* />
|
|
73
87
|
*/
|
|
74
|
-
export declare function PartList<TPart extends AgentPart = AgentPart>({ parts, components, }: PartListProps<TPart>): JSX.Element;
|
|
88
|
+
export declare function PartList<TPart extends AgentPart = AgentPart>({ parts, components, settled, }: PartListProps<TPart>): JSX.Element;
|
|
89
|
+
export {};
|
|
75
90
|
//# sourceMappingURL=part-list.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"part-list.d.ts","sourceRoot":"","sources":["../../src/agent/part-list.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"part-list.d.ts","sourceRoot":"","sources":["../../src/agent/part-list.tsx"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAGhC,OAAO,KAAK,EACV,SAAS,EAMV,MAAM,SAAS,CAAA;AAIhB;;;;;;;GAOG;AACH,KAAK,cAAc,CAAC,KAAK,IAAI;IAC3B,IAAI,EAAE,KAAK,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,gBAAgB,CAA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,CAAC,KAAK,CAAC,CAAA;IAChD,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAA;IAC1C,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAA;IAC1C,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAA;CACzC,CAAA;AAqJD,MAAM,MAAM,aAAa,CAAC,KAAK,SAAS,SAAS,GAAG,SAAS,IAAI;IAC/D,iDAAiD;IACjD,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,CAAA;IACvB;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAA;IACxD;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,SAAS,SAAS,GAAG,SAAS,EAAE,EAC5D,KAAK,EACL,UAAU,EACV,OAAc,GACf,EAAE,aAAa,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,OAAO,CAoFpC"}
|
package/dist/agent/part-list.js
CHANGED
|
@@ -107,7 +107,8 @@ const DEFAULT_RENDERERS = {
|
|
|
107
107
|
};
|
|
108
108
|
function PartList({
|
|
109
109
|
parts,
|
|
110
|
-
components
|
|
110
|
+
components,
|
|
111
|
+
settled = true
|
|
111
112
|
}) {
|
|
112
113
|
const renderers = useMemo(
|
|
113
114
|
() => ({ ...DEFAULT_RENDERERS, ...components }),
|
|
@@ -119,23 +120,58 @@ function PartList({
|
|
|
119
120
|
return null;
|
|
120
121
|
case "text": {
|
|
121
122
|
const Render = renderers.text;
|
|
122
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
123
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
124
|
+
Render,
|
|
125
|
+
{
|
|
126
|
+
part,
|
|
127
|
+
index,
|
|
128
|
+
settled
|
|
129
|
+
}
|
|
130
|
+
) }, part.id);
|
|
123
131
|
}
|
|
124
132
|
case "reasoning": {
|
|
125
133
|
const Render = renderers.reasoning;
|
|
126
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
134
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
135
|
+
Render,
|
|
136
|
+
{
|
|
137
|
+
part,
|
|
138
|
+
index,
|
|
139
|
+
settled
|
|
140
|
+
}
|
|
141
|
+
) }, part.id);
|
|
127
142
|
}
|
|
128
143
|
case "tool": {
|
|
129
144
|
const Render = renderers.tool;
|
|
130
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
145
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
146
|
+
Render,
|
|
147
|
+
{
|
|
148
|
+
part,
|
|
149
|
+
index,
|
|
150
|
+
settled
|
|
151
|
+
}
|
|
152
|
+
) }, part.id);
|
|
131
153
|
}
|
|
132
154
|
case "source": {
|
|
133
155
|
const Render = renderers.source;
|
|
134
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
156
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
157
|
+
Render,
|
|
158
|
+
{
|
|
159
|
+
part,
|
|
160
|
+
index,
|
|
161
|
+
settled
|
|
162
|
+
}
|
|
163
|
+
) }, part.id);
|
|
135
164
|
}
|
|
136
165
|
case "error": {
|
|
137
166
|
const Render = renderers.error;
|
|
138
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
167
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
168
|
+
Render,
|
|
169
|
+
{
|
|
170
|
+
part,
|
|
171
|
+
index,
|
|
172
|
+
settled
|
|
173
|
+
}
|
|
174
|
+
) }, part.id);
|
|
139
175
|
}
|
|
140
176
|
default:
|
|
141
177
|
return assertNever(part);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"part-list.test.d.ts","sourceRoot":"","sources":["../../src/agent/part-list.test.tsx"],"names":[],"mappings":""}
|
package/dist/agent/parts.d.ts
CHANGED
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Exhaustiveness is enforced at every switch via assertNever (imported from '../register.js').
|
|
5
5
|
* Adding a new variant without a matching case is a tsc error — see the fixture in
|
|
6
|
-
* apps/playground/src/demo/agent-part.type-guard.ts.
|
|
6
|
+
* apps/playground/src/demo/agent-part.type-guard.ts. One caveat for code that folds WIRE data on
|
|
7
|
+
* the render path (`coalesceParts`): keep the compile-time guarantee — bind the value at `never` —
|
|
8
|
+
* but do NOT let the runtime throw, or one malformed chunk kills the whole transcript. See
|
|
9
|
+
* `mergeToolPart`'s default branch for that shape.
|
|
7
10
|
*
|
|
8
11
|
* Eden #231 doctrine: the server-side Elysia route MUST declare `: AsyncGenerator<AgentPart>`
|
|
9
12
|
* explicitly and carry NO t.Object/t.Union response schema. Validate at yield-time. See
|
|
@@ -68,33 +71,66 @@ type ToolApproval = {
|
|
|
68
71
|
};
|
|
69
72
|
type ToolCallBase = PartBase & {
|
|
70
73
|
readonly type: 'tool';
|
|
71
|
-
/** Required on all seven states (was optional — see parts.ts history). */
|
|
72
|
-
readonly toolCallId: string;
|
|
73
74
|
readonly toolName: string;
|
|
74
75
|
/** Wall-clock time from first sighting of this toolCallId to its terminal state. */
|
|
75
76
|
readonly durationMs?: number;
|
|
76
77
|
readonly providerExecuted?: boolean;
|
|
77
78
|
};
|
|
78
|
-
|
|
79
|
+
/**
|
|
80
|
+
* The three IN-FLIGHT states (`input-streaming`, `input-available`, `approval-requested`) carry an
|
|
81
|
+
* authoritative `toolCallId` — the merge key, and for them it is structural. An in-flight part
|
|
82
|
+
* exists only to be superseded by the settled part for the same call; with no merge key it can
|
|
83
|
+
* never be closed, so it would render as a forever-pending chip standing beside the real result.
|
|
84
|
+
* Nothing is lost by rejecting an unidentified one either: the `toolName` and `input` it carries
|
|
85
|
+
* are re-supplied on the settled part. `parseToolCallPart` therefore rejects these when the id is
|
|
86
|
+
* missing or empty.
|
|
87
|
+
*/
|
|
88
|
+
type Identified = ToolCallBase & {
|
|
89
|
+
readonly toolCallId: string;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* The four SETTLED states (`approval-responded` plus the three terminal ones) may legitimately
|
|
93
|
+
* arrive without a `toolCallId`, for two different reasons.
|
|
94
|
+
*
|
|
95
|
+
* `approval-responded` is where the WIRE omits it: the SDK's `tool-approval-response` chunk
|
|
96
|
+
* carries none, and it is resolved by reverse lookup on `approval.id` (coalesce.ts keeps the
|
|
97
|
+
* approvalId -> toolCallId side index that does it).
|
|
98
|
+
*
|
|
99
|
+
* The three terminal states admit the absence for a different reason — tolerance, not wire shape.
|
|
100
|
+
* They are self-contained: each carries the OUTCOME of the call, so a missing id costs only the
|
|
101
|
+
* fold (`coalesceParts` keeps an unresolvable part as its own block and never discards it).
|
|
102
|
+
* Rejecting one instead would delete the only record of how the call ended — silent data loss in a
|
|
103
|
+
* transcript, strictly worse than an unfolded block.
|
|
104
|
+
*
|
|
105
|
+
* The absence is modelled here rather than smuggled through an empty-string sentinel: the union
|
|
106
|
+
* previously declared an always-meaningful `string` that the `approval-responded` wire shape
|
|
107
|
+
* cannot supply, which forced a `''` sentinel into the type and an `as unknown as` cast into every
|
|
108
|
+
* test that built one. A `''` toolCallId is not a value any state accepts; `parseToolCallPart`
|
|
109
|
+
* normalizes one to absent at the wire boundary, so it never reaches the type or a consumer.
|
|
110
|
+
*/
|
|
111
|
+
type MaybeIdentified = ToolCallBase & {
|
|
112
|
+
readonly toolCallId?: string;
|
|
113
|
+
};
|
|
114
|
+
export type ToolCallPart = (Identified & {
|
|
79
115
|
readonly state: 'input-streaming';
|
|
80
116
|
readonly input?: unknown;
|
|
81
|
-
}) | (
|
|
117
|
+
}) | (Identified & {
|
|
82
118
|
readonly state: 'input-available';
|
|
83
119
|
readonly input: unknown;
|
|
84
|
-
}) | (
|
|
120
|
+
}) | (Identified & {
|
|
85
121
|
readonly state: 'approval-requested';
|
|
86
122
|
readonly input: unknown;
|
|
87
123
|
readonly approval: ToolApproval & {
|
|
88
124
|
readonly approved?: never;
|
|
89
125
|
readonly reason?: never;
|
|
90
126
|
};
|
|
91
|
-
}) | (
|
|
127
|
+
}) | (MaybeIdentified & {
|
|
92
128
|
readonly state: 'approval-responded';
|
|
93
129
|
readonly input: unknown;
|
|
94
130
|
readonly approval: ToolApproval & {
|
|
95
131
|
readonly approved: boolean;
|
|
96
132
|
};
|
|
97
|
-
}) | (
|
|
133
|
+
}) | (MaybeIdentified & {
|
|
98
134
|
readonly state: 'output-available';
|
|
99
135
|
readonly input: unknown;
|
|
100
136
|
readonly output: unknown;
|
|
@@ -102,7 +138,7 @@ export type ToolCallPart = (ToolCallBase & {
|
|
|
102
138
|
readonly approval?: ToolApproval & {
|
|
103
139
|
readonly approved?: true;
|
|
104
140
|
};
|
|
105
|
-
}) | (
|
|
141
|
+
}) | (MaybeIdentified & {
|
|
106
142
|
readonly state: 'output-error';
|
|
107
143
|
readonly input?: unknown;
|
|
108
144
|
/** The SDK's field name — there is no field named `error` anywhere in the union. */
|
|
@@ -112,7 +148,7 @@ export type ToolCallPart = (ToolCallBase & {
|
|
|
112
148
|
readonly approval?: ToolApproval & {
|
|
113
149
|
readonly approved?: true;
|
|
114
150
|
};
|
|
115
|
-
}) | (
|
|
151
|
+
}) | (MaybeIdentified & {
|
|
116
152
|
readonly state: 'output-denied';
|
|
117
153
|
readonly input: unknown;
|
|
118
154
|
readonly approval: ToolApproval & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../../src/agent/parts.ts"],"names":[],"mappings":"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AAM,CAAA;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,mEAAmE;AACnE,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvF;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,GAAG,YAAY,GAAG,UAAU,GAAG,SAAS,CAAA;AAIpG;;;;;;GAMG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,KAAK,CAAA;AAC7F,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;AAI/C;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAgD7D;AAsJD,yDAAyD;AACzD,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,SAAS,CAE5D"}
|
package/dist/agent/parts.js
CHANGED
|
@@ -51,36 +51,42 @@ function parseAgentPart(raw) {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
function parseToolCallPart(id, obj) {
|
|
54
|
-
if (typeof obj["toolCallId"] !== "string") return null;
|
|
55
54
|
if (typeof obj["toolName"] !== "string") return null;
|
|
56
55
|
if (typeof obj["state"] !== "string") return null;
|
|
57
|
-
const
|
|
56
|
+
const rawToolCallId = obj["toolCallId"];
|
|
57
|
+
if (rawToolCallId !== void 0 && typeof rawToolCallId !== "string") return null;
|
|
58
|
+
const toolCallId = typeof rawToolCallId === "string" && rawToolCallId.length > 0 ? rawToolCallId : void 0;
|
|
59
|
+
const toolName = obj["toolName"];
|
|
58
60
|
const common = {
|
|
59
61
|
id,
|
|
60
62
|
type: "tool",
|
|
61
|
-
toolCallId,
|
|
62
63
|
toolName,
|
|
63
64
|
...typeof obj["durationMs"] === "number" ? { durationMs: obj["durationMs"] } : {},
|
|
64
65
|
...typeof obj["providerExecuted"] === "boolean" ? { providerExecuted: obj["providerExecuted"] } : {}
|
|
65
66
|
};
|
|
67
|
+
const identified = toolCallId !== void 0 ? { ...common, toolCallId } : null;
|
|
68
|
+
const identity = toolCallId !== void 0 ? { toolCallId } : {};
|
|
66
69
|
switch (obj["state"]) {
|
|
67
70
|
case "input-streaming":
|
|
71
|
+
if (identified === null) return null;
|
|
68
72
|
return {
|
|
69
|
-
...
|
|
73
|
+
...identified,
|
|
70
74
|
state: "input-streaming",
|
|
71
75
|
..."input" in obj ? { input: obj["input"] } : {}
|
|
72
76
|
};
|
|
73
77
|
case "input-available":
|
|
78
|
+
if (identified === null) return null;
|
|
74
79
|
if (!("input" in obj)) return null;
|
|
75
|
-
return { ...
|
|
80
|
+
return { ...identified, state: "input-available", input: obj["input"] };
|
|
76
81
|
case "approval-requested": {
|
|
82
|
+
if (identified === null) return null;
|
|
77
83
|
if (!("input" in obj)) return null;
|
|
78
84
|
const approval = parseApproval(obj["approval"]);
|
|
79
85
|
if (approval === null || approval.approved !== void 0 || approval.reason !== void 0) {
|
|
80
86
|
return null;
|
|
81
87
|
}
|
|
82
88
|
return {
|
|
83
|
-
...
|
|
89
|
+
...identified,
|
|
84
90
|
state: "approval-requested",
|
|
85
91
|
input: obj["input"],
|
|
86
92
|
approval
|
|
@@ -92,6 +98,7 @@ function parseToolCallPart(id, obj) {
|
|
|
92
98
|
if (approval === null || typeof approval.approved !== "boolean") return null;
|
|
93
99
|
return {
|
|
94
100
|
...common,
|
|
101
|
+
...identity,
|
|
95
102
|
state: "approval-responded",
|
|
96
103
|
input: obj["input"],
|
|
97
104
|
approval
|
|
@@ -103,6 +110,7 @@ function parseToolCallPart(id, obj) {
|
|
|
103
110
|
if (approval === null || approval.approved !== false) return null;
|
|
104
111
|
return {
|
|
105
112
|
...common,
|
|
113
|
+
...identity,
|
|
106
114
|
state: "output-denied",
|
|
107
115
|
input: obj["input"],
|
|
108
116
|
approval
|
|
@@ -117,6 +125,7 @@ function parseToolCallPart(id, obj) {
|
|
|
117
125
|
}
|
|
118
126
|
return {
|
|
119
127
|
...common,
|
|
128
|
+
...identity,
|
|
120
129
|
state: "output-available",
|
|
121
130
|
input: obj["input"],
|
|
122
131
|
output: obj["output"],
|
|
@@ -132,6 +141,7 @@ function parseToolCallPart(id, obj) {
|
|
|
132
141
|
}
|
|
133
142
|
return {
|
|
134
143
|
...common,
|
|
144
|
+
...identity,
|
|
135
145
|
state: "output-error",
|
|
136
146
|
errorText: obj["errorText"],
|
|
137
147
|
..."input" in obj ? { input: obj["input"] } : {},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parts.test.d.ts","sourceRoot":"","sources":["../../src/agent/parts.test.ts"],"names":[],"mappings":""}
|
package/dist/agent/thread.d.ts
CHANGED
|
@@ -103,6 +103,20 @@ export type ThreadsStore<TPart = AgentPart> = {
|
|
|
103
103
|
readonly remove: (id: string) => void;
|
|
104
104
|
/** Remove all threads and clear the active selection. */
|
|
105
105
|
readonly clear: () => void;
|
|
106
|
+
/**
|
|
107
|
+
* Whether `threads` reflects the backing store yet. Always `true` for the localStorage store
|
|
108
|
+
* (createPersistedState resolves synchronously); meaningful only for an async, server-backed
|
|
109
|
+
* store built with `createAdapterThreadsStore` (./adapter), where it stays `false` until the
|
|
110
|
+
* first `listThreads` SUCCEEDS. Pair it with `error` — `!hydrated && error !== undefined` is a
|
|
111
|
+
* failed load, `!hydrated && error === undefined` is still loading.
|
|
112
|
+
*/
|
|
113
|
+
readonly hydrated: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* The most recent persistence failure, or `undefined`. Always `undefined` for the localStorage
|
|
116
|
+
* store, which has no failure the caller can act on. An async store surfaces the rejected
|
|
117
|
+
* load/write here after rolling its optimistic edit back.
|
|
118
|
+
*/
|
|
119
|
+
readonly error: unknown;
|
|
106
120
|
};
|
|
107
121
|
/**
|
|
108
122
|
* Creates a stable persisted multi-thread hook for the given key + version.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread.d.ts","sourceRoot":"","sources":["../../src/agent/thread.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"thread.d.ts","sourceRoot":"","sources":["../../src/agent/thread.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAIxC;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,OAAO,GAAG,aAAa,CAAA;AAInG;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,WAAW,CAAC,KAAK,GAAG,SAAS,IAAI;IAC3C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,CAAA;IACvC,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAAA;IACrC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAA;IAC7B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,IAAI,CAA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,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAA;IACxE,6BAA6B;IAC7B,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IACvC,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC,yDAAyD;IACzD,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAA;IAC1B;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CACxB,CAAA;AAID;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,GAAG,SAAS,EAClD,IAAI,EAAE,mBAAmB,GACxB,MAAM,YAAY,CAAC,KAAK,CAAC,CA0J3B"}
|
package/dist/agent/thread.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useCallback, useRef } from "react";
|
|
2
2
|
import { createPersistedState } from "../state.js";
|
|
3
|
+
import { mintThreadId } from "./id.js";
|
|
3
4
|
function createThreadsStore(opts) {
|
|
4
5
|
const maxThreads = opts.maxThreads ?? 50;
|
|
5
6
|
const maxMessages = opts.maxMessagesPerThread ?? 100;
|
|
@@ -27,7 +28,7 @@ function createThreadsStore(opts) {
|
|
|
27
28
|
);
|
|
28
29
|
const create = useCallback(
|
|
29
30
|
(createOpts) => {
|
|
30
|
-
const id =
|
|
31
|
+
const id = mintThreadId();
|
|
31
32
|
const now = Date.now();
|
|
32
33
|
const thread = {
|
|
33
34
|
id,
|
|
@@ -122,7 +123,12 @@ function createThreadsStore(opts) {
|
|
|
122
123
|
setResumeToken,
|
|
123
124
|
markRead,
|
|
124
125
|
remove,
|
|
125
|
-
clear
|
|
126
|
+
clear,
|
|
127
|
+
// localStorage resolves synchronously and swallows its own quota errors, so there is never
|
|
128
|
+
// a pending load to await nor a failure a caller could act on. See ./adapter for the async
|
|
129
|
+
// store where these two carry real information.
|
|
130
|
+
hydrated: true,
|
|
131
|
+
error: void 0
|
|
126
132
|
};
|
|
127
133
|
};
|
|
128
134
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thread.test.d.ts","sourceRoot":"","sources":["../../src/agent/thread.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.test.d.ts","sourceRoot":"","sources":["../../src/agent/transport.test.ts"],"names":[],"mappings":""}
|