@guuey/chat 0.11.0 → 0.12.1
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/plan.d.ts.map +1 -1
- package/dist/plan.js +72 -26
- package/dist/react/components.d.ts +1 -1
- package/dist/react/components.d.ts.map +1 -1
- package/dist/react/guuey-chat.d.ts +18 -1
- package/dist/react/guuey-chat.d.ts.map +1 -1
- package/dist/react/guuey-chat.js +92 -2
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/plan.ts +71 -28
- package/src/react/components.tsx +1 -0
- package/src/react/guuey-chat.tsx +115 -3
- package/src/types.ts +8 -1
package/dist/plan.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AAkCA,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD,OAAO,KAAK,EAUV,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EAIf,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AAkCA,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD,OAAO,KAAK,EAUV,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EAIf,MAAM,YAAY,CAAC;AA2pBpB,uCAAuC;AACvC,wBAAgB,cAAc,CAC5B,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,gBAAgB,EACxB,SAAS,GAAE,mBAAwB,GAClC,cAAc,CA2ThB;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,GAAG,cAAc,CAAC,GACxD;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAAE,GAAG,SAAS,CAiB5D"}
|
package/dist/plan.js
CHANGED
|
@@ -57,18 +57,45 @@ function foldAssistantSources(result, inFlight, aborted) {
|
|
|
57
57
|
// behaviour, kept so identity-less folds plan exactly as before.
|
|
58
58
|
const openTurns = new Set(result.turns.filter((t) => t.outcome === undefined).map((t) => t.turnId));
|
|
59
59
|
const hasTurnIdentity = result.messages.some((m) => m.role === "assistant" && m.turnId !== undefined);
|
|
60
|
+
// ONE source per conversational TURN, not per assistant message segment
|
|
61
|
+
// (guuey#306 — the mis-slotting bug): a pod fold emits SEVERAL assistant
|
|
62
|
+
// messages per turn (thought/text/tool interleave — a generative-card
|
|
63
|
+
// turn is ~6-8 segments), and the conversation loop pairs users to
|
|
64
|
+
// sources BY SLOT — per-segment sources stretched the index space, so
|
|
65
|
+
// from turn 2 on every user bubble rendered clustered inside turn 1's
|
|
66
|
+
// segment run. Grouping: a `user` row closes the current group (the
|
|
67
|
+
// fold's messages are the whole conversation, users included), and a
|
|
68
|
+
// turnId CHANGE between assistant segments splits too (identity beats
|
|
69
|
+
// adjacency — two turns without an intervening user row still separate).
|
|
60
70
|
const sources = [];
|
|
61
71
|
const notices = [];
|
|
72
|
+
let current = null;
|
|
73
|
+
let currentTurnId;
|
|
62
74
|
for (const m of result.messages) {
|
|
63
|
-
if (m.role === "
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
75
|
+
if (m.role === "user") {
|
|
76
|
+
current = null;
|
|
77
|
+
currentTurnId = undefined;
|
|
78
|
+
}
|
|
79
|
+
else if (m.role === "assistant") {
|
|
80
|
+
const startsNewTurn = current === null ||
|
|
81
|
+
(m.turnId !== undefined && currentTurnId !== undefined && m.turnId !== currentTurnId);
|
|
82
|
+
if (startsNewTurn) {
|
|
83
|
+
current = { blocks: [], live: false, stopped: false };
|
|
84
|
+
sources.push(current);
|
|
85
|
+
currentTurnId = undefined;
|
|
86
|
+
}
|
|
87
|
+
if (m.turnId !== undefined)
|
|
88
|
+
currentTurnId = m.turnId;
|
|
89
|
+
current.blocks.push(...m.content);
|
|
90
|
+
if (inFlight && hasTurnIdentity && m.turnId !== undefined && openTurns.has(m.turnId)) {
|
|
91
|
+
current.live = true;
|
|
92
|
+
}
|
|
69
93
|
}
|
|
70
94
|
else if (m.role === "tool" && sources.length > 0) {
|
|
71
|
-
|
|
95
|
+
// Tool results belong to the turn in progress — or, when they trail a
|
|
96
|
+
// user boundary before the next assistant segment, to the PRECEDING
|
|
97
|
+
// turn (the pre-#306 last-source semantics, kept).
|
|
98
|
+
(current ?? sources[sources.length - 1]).blocks.push(...m.content);
|
|
72
99
|
}
|
|
73
100
|
else if (m.role === "notice") {
|
|
74
101
|
// R16 (spec draft.2): a session annotation — a PEER row, never folded
|
|
@@ -88,10 +115,33 @@ function foldAssistantSources(result, inFlight, aborted) {
|
|
|
88
115
|
}
|
|
89
116
|
return { sources, notices };
|
|
90
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Flat assistant rows grouped by conversational ORDER (guuey#306): a user
|
|
120
|
+
* row closes the current slot, consecutive assistant rows merge into one —
|
|
121
|
+
* the assembler's interleave IS the turn structure, and the old
|
|
122
|
+
* filter/zip threw it away (double/empty assistant rows drifted every
|
|
123
|
+
* later user bubble by one). Shared by the flat path and the fold-vs-flat
|
|
124
|
+
* seam, so both count the same slots.
|
|
125
|
+
*/
|
|
126
|
+
function flatSettledGroups(messages) {
|
|
127
|
+
const groups = [];
|
|
128
|
+
let current = null;
|
|
129
|
+
for (const m of messages) {
|
|
130
|
+
if (m.role === "user") {
|
|
131
|
+
current = null;
|
|
132
|
+
}
|
|
133
|
+
else if (m.role === "assistant") {
|
|
134
|
+
if (current === null) {
|
|
135
|
+
current = { blocks: [], live: false, stopped: false };
|
|
136
|
+
groups.push(current);
|
|
137
|
+
}
|
|
138
|
+
current.blocks.push({ type: "text", text: m.text });
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return groups;
|
|
142
|
+
}
|
|
91
143
|
function flatAssistantSources(inputs, inFlight) {
|
|
92
|
-
const settled = inputs.messages
|
|
93
|
-
.filter((m) => m.role === "assistant")
|
|
94
|
-
.map((m) => ({ blocks: [{ type: "text", text: m.text }], live: false, stopped: false }));
|
|
144
|
+
const settled = flatSettledGroups(inputs.messages);
|
|
95
145
|
// The in-flight (or abort-kept) partial is its own trailing slot — settled
|
|
96
146
|
// turns live in `messages`; `assistantText` is ignored once `ready` again
|
|
97
147
|
// UNLESS the turn ended by abort (R1 aborted-partial keeps it).
|
|
@@ -602,27 +652,23 @@ export function planTranscript(inputs, policy, overrides = {}) {
|
|
|
602
652
|
// keep rendering as flat text slots in front. When the fold spans the
|
|
603
653
|
// whole conversation (a pure-live session — the corpus's world), the kept
|
|
604
654
|
// prefix is empty and the plan is byte-identical to the old wholesale
|
|
605
|
-
// replace. Alignment
|
|
606
|
-
//
|
|
607
|
-
//
|
|
608
|
-
//
|
|
609
|
-
//
|
|
610
|
-
// cards by the actionScope dedupe below.
|
|
655
|
+
// replace. Alignment counts TURNS on
|
|
656
|
+
// both sides (guuey#306): fold sources group per turn (user boundary +
|
|
657
|
+
// turnId change), flat entries group by conversational order — the old
|
|
658
|
+
// per-message COUNT approximation (and its one-off seam drift on
|
|
659
|
+
// card-only turns) is gone.
|
|
611
660
|
let assistants;
|
|
612
661
|
if (inputs.result) {
|
|
613
662
|
const fold = foldAssistantSources(inputs.result, inFlight, inputs.aborted === true);
|
|
614
663
|
const foldSources = fold.sources;
|
|
615
664
|
const settledFoldCount = foldSources.filter((s) => !s.live).length;
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
})),
|
|
624
|
-
...foldSources,
|
|
625
|
-
];
|
|
665
|
+
// Both sides of the seam now count TURNS (guuey#306): fold sources are
|
|
666
|
+
// per-turn groups, and the flat prefix uses the SAME order-derived
|
|
667
|
+
// grouping — the old per-message counts were the documented
|
|
668
|
+
// approximation this replaces.
|
|
669
|
+
const flatGroups = flatSettledGroups(inputs.messages);
|
|
670
|
+
const keep = Math.max(0, flatGroups.length - settledFoldCount);
|
|
671
|
+
assistants = [...flatGroups.slice(0, keep), ...foldSources];
|
|
626
672
|
if (policy.notice.show) {
|
|
627
673
|
// Fold-borne notices anchor to the fold source they followed, which
|
|
628
674
|
// sits at global slot `keep + afterSourceIndex` after the seam.
|
|
@@ -69,7 +69,7 @@ export interface TranscriptItemContext {
|
|
|
69
69
|
viewProps?: ViewSlotProps | ((item: ViewMountItem, mount: ResolvedViewMount) => ViewSlotProps);
|
|
70
70
|
}
|
|
71
71
|
/** The per-view slice of `GuueyViewProps` a transcript may configure. */
|
|
72
|
-
export type ViewSlotProps = Pick<GuueyViewProps, "hostCapabilities" | "hostInfo" | "hostContext" | "onCallTool" | "onReadResource" | "onSizeChanged" | "negotiationTimeoutMs" | "dangerouslyAddSandboxFlags" | "allow" | "sandboxPageUrl" | "autoResize" | "cspOrigins">;
|
|
72
|
+
export type ViewSlotProps = Pick<GuueyViewProps, "hostCapabilities" | "hostInfo" | "hostContext" | "onCallTool" | "onUpdateModelContext" | "onReadResource" | "onSizeChanged" | "negotiationTimeoutMs" | "dangerouslyAddSandboxFlags" | "allow" | "sandboxPageUrl" | "autoResize" | "cspOrigins">;
|
|
73
73
|
interface ItemProps<T> {
|
|
74
74
|
item: T;
|
|
75
75
|
ctx: TranscriptItemContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/react/components.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,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AAC,CAAC;CAClD;AAED,eAAO,MAAM,2BAA2B,EAAE,oBAmBzC,CAAC;AAEF,uEAAuE;AACvE,wBAAgB,UAAU,CACxB,IAAI,EAAE,WAAW,EACjB,UAAU,EAAE,oBAAoB,EAChC,GAAG,EAAE,qBAAqB,GACzB,SAAS,CAuEX"}
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/react/components.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC/F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EACV,aAAa,EACb,QAAQ,EACR,cAAc,EACd,cAAc,EACd,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,OAAO,EACP,SAAS,EACT,UAAU,EACV,UAAU,EACV,aAAa,EACb,cAAc,EACd,aAAa,EACb,QAAQ,EACR,WAAW,EACX,eAAe,EACf,QAAQ,EACR,aAAa,EACb,WAAW,EACZ,MAAM,aAAa,CAAC;AAGrB,yDAAyD;AACzD,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,WAAW,CAAC;IACrB,wEAAwE;IACxE,QAAQ,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IACjC,4BAA4B;IAC5B,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;IAC1C;;;;OAIG;IACH,cAAc,CAAC,EAAE,CACf,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,KAC/D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AAC;IAC7C,MAAM,EAAE,aAAa,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;IAC7C,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;IAC3C,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC,CAAC;IACvD,UAAU,EAAE,aAAa,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC;IACrD,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/C,MAAM,EAAE,aAAa,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC;CAClD;AAED,eAAO,MAAM,2BAA2B,EAAE,oBAmBzC,CAAC;AAEF,uEAAuE;AACvE,wBAAgB,UAAU,CACxB,IAAI,EAAE,WAAW,EACjB,UAAU,EAAE,oBAAoB,EAChC,GAAG,EAAE,qBAAqB,GACzB,SAAS,CAuEX"}
|
|
@@ -54,7 +54,14 @@ import { type GuueyChatTheme } from "../theme.js";
|
|
|
54
54
|
import type { ChatDebugEvent, ErrorItem, PlanViewSummary, PromptItem, ViewRefItem } from "../types.js";
|
|
55
55
|
import type { ThemeMode } from "./theme-css.js";
|
|
56
56
|
import { type TranscriptWindowing } from "./transcript.js";
|
|
57
|
-
import type { TranscriptComponents, TranscriptItemContext } from "./components.js";
|
|
57
|
+
import type { TranscriptComponents, TranscriptItemContext, ViewSlotProps } from "./components.js";
|
|
58
|
+
/**
|
|
59
|
+
* The kit-tier theme announce (guuey#302): default `hostContext.theme`
|
|
60
|
+
* from the transcript mode onto every view slot. A caller-declared
|
|
61
|
+
* `hostContext` key wins field-by-field; `theme` is only filled in.
|
|
62
|
+
* Exported for tests; not part of the package surface.
|
|
63
|
+
*/
|
|
64
|
+
export declare function viewPropsWithThemeAnnounce(viewProps: TranscriptItemContext["viewProps"], mode: ThemeMode, defaults?: Pick<ViewSlotProps, "onCallTool" | "onUpdateModelContext">): TranscriptItemContext["viewProps"];
|
|
58
65
|
/**
|
|
59
66
|
* The imperative seam (guuey#210): programmatic send/prefill/focus for
|
|
60
67
|
* hosts that stay on the batteries-included path (suggested-prompt chips
|
|
@@ -92,6 +99,16 @@ export interface GuueyChatHandle {
|
|
|
92
99
|
* {@link GuueyChatProps.onThread}.
|
|
93
100
|
*/
|
|
94
101
|
readonly threadId: string | null;
|
|
102
|
+
/**
|
|
103
|
+
* The slot props the kit's OWN inline mounts run with — theme announce,
|
|
104
|
+
* default action relay, model-context sink (guuey#335). A host mounting
|
|
105
|
+
* a roster view on its own canvas (`<GuueyView {...handle.viewSlotProps()}`>)
|
|
106
|
+
* gets the identical wiring, so a rendered card's Confirm works there
|
|
107
|
+
* too. Live values (read on demand); when the host passed a FUNCTION-form
|
|
108
|
+
* `viewProps`, this returns the kit defaults (per-item resolution belongs
|
|
109
|
+
* to the transcript).
|
|
110
|
+
*/
|
|
111
|
+
viewSlotProps(): ViewSlotProps;
|
|
95
112
|
}
|
|
96
113
|
export interface GuueyChatProps {
|
|
97
114
|
/** Pod base URL (with or without `/agent/invoke`). `null` disables chat. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guuey-chat.d.ts","sourceRoot":"","sources":["../../src/react/guuey-chat.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,OAAO,EASL,KAAK,aAAa,EAEnB,MAAM,OAAO,CAAC;AACf,OAAO,
|
|
1
|
+
{"version":3,"file":"guuey-chat.d.ts","sourceRoot":"","sources":["../../src/react/guuey-chat.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,OAAO,EASL,KAAK,aAAa,EAEnB,MAAM,OAAO,CAAC;AACf,OAAO,EAIL,KAAK,mBAAmB,EACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,WA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AAE,KAC/D,IAAI,CAAC;IACV;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,WAAW,KAAK,IAAI,CAAC;IAChE;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,KAAK,IAAI,CAAC;IAC5D,qDAAqD;IACrD,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IAC1C;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IAC5C;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC;;;;;;;;;OASG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IACxC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAQD,eAAO,MAAM,SAAS,4GA0bpB,CAAC"}
|
package/dist/react/guuey-chat.js
CHANGED
|
@@ -46,8 +46,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
46
46
|
* native GuueyChat, so there is no native surface to put a handle on yet.
|
|
47
47
|
*/
|
|
48
48
|
import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useMemo, useRef, useState, } from "react";
|
|
49
|
-
import { createUiResourceReader, createWebAdapters, } from "@guuey/agent-client";
|
|
49
|
+
import { createUiActionRelay, createUiResourceReader, createWebAdapters, } from "@guuey/agent-client";
|
|
50
50
|
import { useAgentInvoke } from "@guuey/agent-client/react";
|
|
51
|
+
import { unavailableToolCallResult } from "@guuey/mcp-apps-host";
|
|
51
52
|
import { calmPolicy, debugPolicy } from "../policy.js";
|
|
52
53
|
import { useStructuralIdentity } from "./structural-identity.js";
|
|
53
54
|
import { defaultChatStrings } from "../strings.js";
|
|
@@ -55,6 +56,29 @@ import { DEFAULT_CHAT_THEME } from "../theme.js";
|
|
|
55
56
|
import { Transcript } from "./transcript.js";
|
|
56
57
|
import { useTranscript, useTranscriptInputs } from "./use-transcript.js";
|
|
57
58
|
import { oauthPromptAction, useOAuthReturn } from "./oauth-return.js";
|
|
59
|
+
/**
|
|
60
|
+
* The kit-tier theme announce (guuey#302): default `hostContext.theme`
|
|
61
|
+
* from the transcript mode onto every view slot. A caller-declared
|
|
62
|
+
* `hostContext` key wins field-by-field; `theme` is only filled in.
|
|
63
|
+
* Exported for tests; not part of the package surface.
|
|
64
|
+
*/
|
|
65
|
+
export function viewPropsWithThemeAnnounce(viewProps, mode, defaults = {}) {
|
|
66
|
+
const themed = (base) => ({
|
|
67
|
+
// Kit-default host wires (guuey#335): the ACTION RELAY (Confirm inside
|
|
68
|
+
// a rendered card is a tools/call — without a relay the initialize-only
|
|
69
|
+
// host -32601s and the interaction visibly fails) and the
|
|
70
|
+
// model-context sink (a COMPLEMENT channel — producers mirror the
|
|
71
|
+
// snapshot server-side, so a recording sink is honest). A caller-
|
|
72
|
+
// declared slot prop always wins.
|
|
73
|
+
...defaults,
|
|
74
|
+
...base,
|
|
75
|
+
hostContext: { theme: mode, ...base?.hostContext },
|
|
76
|
+
});
|
|
77
|
+
if (typeof viewProps === "function") {
|
|
78
|
+
return (item, mount) => themed(viewProps(item, mount));
|
|
79
|
+
}
|
|
80
|
+
return themed(viewProps);
|
|
81
|
+
}
|
|
58
82
|
const PROMPT_STATE = {
|
|
59
83
|
accept: "answered",
|
|
60
84
|
decline: "declined",
|
|
@@ -174,6 +198,69 @@ export const GuueyChat = forwardRef(function GuueyChat(props, ref) {
|
|
|
174
198
|
});
|
|
175
199
|
onViewsChangeRef.current(overlaid);
|
|
176
200
|
}, [plan.views, resolvedMounts]);
|
|
201
|
+
// The theme announce, completed at the kit tier (guuey#302): every
|
|
202
|
+
// inline mount carries `hostContext.theme` from the transcript's `mode`
|
|
203
|
+
// — render bundles read it at ui/initialize (ggui precedence: slice
|
|
204
|
+
// wins, host falls back — their #551/#573). A caller's explicit
|
|
205
|
+
// `viewProps.hostContext` keys win; `theme` is only defaulted. Hosts
|
|
206
|
+
// mounting views DIRECTLY (a canvas over the roster) announce on their
|
|
207
|
+
// own <GuueyView hostContext> — this covers the kit's own mounts.
|
|
208
|
+
// The DEFAULT ACTION RELAY (guuey#335 — the founder-hit Confirm bug):
|
|
209
|
+
// pod-then-persisted, built over the SAME identity as the reader, thread
|
|
210
|
+
// read through the ref at CALL time. Without it, a kit-mounted render's
|
|
211
|
+
// tools/call hits an initialize-only host and the card's interaction
|
|
212
|
+
// visibly fails — the #221 batteries-included treatment, applied to the
|
|
213
|
+
// ACTION half. No thread yet ⇒ the in-band unavailable result (a card
|
|
214
|
+
// cannot exist before its thread, but a race answers honestly).
|
|
215
|
+
const defaultOnCallTool = useMemo(() => {
|
|
216
|
+
if (apiBaseUrl === undefined)
|
|
217
|
+
return undefined;
|
|
218
|
+
return async (request) => {
|
|
219
|
+
const threadId = threadIdRef.current;
|
|
220
|
+
if (threadId === null)
|
|
221
|
+
return unavailableToolCallResult();
|
|
222
|
+
const getToken = getAccessTokenRef.current;
|
|
223
|
+
const getGuest = getGuestSecretRef.current;
|
|
224
|
+
const relay = createUiActionRelay({
|
|
225
|
+
apiBaseUrl,
|
|
226
|
+
threadId,
|
|
227
|
+
endpointUrl,
|
|
228
|
+
...(getToken !== undefined ? { getAccessToken: getToken } : {}),
|
|
229
|
+
guestSecret: getGuest !== undefined ? getGuest() : null,
|
|
230
|
+
});
|
|
231
|
+
return relay(request);
|
|
232
|
+
};
|
|
233
|
+
}, [apiBaseUrl, endpointUrl]);
|
|
234
|
+
// Model-context sink (guuey#335): the snapshot is a complement (producers
|
|
235
|
+
// mirror it server-side), so recording to the debug surface is the honest
|
|
236
|
+
// kit default — and answering the method keeps strict producers green.
|
|
237
|
+
const onDebugEventRef = useRef(onDebugEvent);
|
|
238
|
+
onDebugEventRef.current = onDebugEvent;
|
|
239
|
+
const defaultOnUpdateModelContext = useCallback((params) => {
|
|
240
|
+
onDebugEventRef.current?.({
|
|
241
|
+
type: "model-context-update",
|
|
242
|
+
byteSize: JSON.stringify(params)?.length ?? 0,
|
|
243
|
+
});
|
|
244
|
+
}, []);
|
|
245
|
+
const effectiveViewProps = useMemo(() => viewPropsWithThemeAnnounce(viewProps, mode, {
|
|
246
|
+
...(defaultOnCallTool !== undefined ? { onCallTool: defaultOnCallTool } : {}),
|
|
247
|
+
onUpdateModelContext: defaultOnUpdateModelContext,
|
|
248
|
+
}), [viewProps, mode, defaultOnCallTool, defaultOnUpdateModelContext]);
|
|
249
|
+
// The canvas-host door (guuey#335): a host mounting views DIRECTLY from
|
|
250
|
+
// the roster (the chat-rail shell) needs the SAME slot wiring the kit's
|
|
251
|
+
// inline mounts get — theme announce, action relay, context sink. Read
|
|
252
|
+
// through a ref so the lifetime-stable handle always hands out current
|
|
253
|
+
// wiring; a caller-passed FUNCTION-form viewProps resolves per transcript
|
|
254
|
+
// item only, so the handle returns the kit defaults in that case.
|
|
255
|
+
const staticSlotPropsRef = useRef({});
|
|
256
|
+
staticSlotPropsRef.current =
|
|
257
|
+
typeof effectiveViewProps === "function"
|
|
258
|
+
? {
|
|
259
|
+
...(defaultOnCallTool !== undefined ? { onCallTool: defaultOnCallTool } : {}),
|
|
260
|
+
onUpdateModelContext: defaultOnUpdateModelContext,
|
|
261
|
+
hostContext: { theme: mode },
|
|
262
|
+
}
|
|
263
|
+
: (effectiveViewProps ?? {});
|
|
177
264
|
// ── Composer ─────────────────────────────────────────────────────────
|
|
178
265
|
const [input, setInput] = useState("");
|
|
179
266
|
const inputRef = useRef(null);
|
|
@@ -221,6 +308,9 @@ export const GuueyChat = forwardRef(function GuueyChat(props, ref) {
|
|
|
221
308
|
get threadId() {
|
|
222
309
|
return threadIdRef.current;
|
|
223
310
|
},
|
|
311
|
+
// Same live-read discipline as `threadId`: the ref always holds the
|
|
312
|
+
// CURRENT kit wiring (guuey#335 — the canvas-host door).
|
|
313
|
+
viewSlotProps: () => staticSlotPropsRef.current,
|
|
224
314
|
}), []);
|
|
225
315
|
useImperativeHandle(ref, () => handle, [handle]);
|
|
226
316
|
// `onThread` fires on the first hydrated id and on each DISTINCT change —
|
|
@@ -290,7 +380,7 @@ export const GuueyChat = forwardRef(function GuueyChat(props, ref) {
|
|
|
290
380
|
onPromptAction?.(item, action);
|
|
291
381
|
}, [resolvePrompt, answerHitlPrompt, onHitlAnswer, onPromptAction, oauthReturnTo, onOAuthAuthorize]);
|
|
292
382
|
const strings = policy.strings;
|
|
293
|
-
return (_jsxs("div", { className: `guuey-chat-surface${className !== undefined ? ` ${className}` : ""}`, style: style, children: [_jsx(Transcript, { plan: plan, strings: strings, theme: theme, mode: mode, ...(windowing !== undefined ? { window: windowing } : {}), ...(components !== undefined ? { components } : {}), onToggle: toggle, onRetry: handleRetry, onPromptAction: handlePromptAction, ...(onErrorAction !== undefined ? { onErrorAction } : {}), resolvedMounts: resolvedMounts, onViewPhase: onViewPhase, onViewDiagnosis: onViewDiagnosis, ...(onViewRef !== undefined ? { onViewRef } : {}),
|
|
383
|
+
return (_jsxs("div", { className: `guuey-chat-surface${className !== undefined ? ` ${className}` : ""}`, style: style, children: [_jsx(Transcript, { plan: plan, strings: strings, theme: theme, mode: mode, ...(windowing !== undefined ? { window: windowing } : {}), ...(components !== undefined ? { components } : {}), onToggle: toggle, onRetry: handleRetry, onPromptAction: handlePromptAction, ...(onErrorAction !== undefined ? { onErrorAction } : {}), resolvedMounts: resolvedMounts, onViewPhase: onViewPhase, onViewDiagnosis: onViewDiagnosis, ...(onViewRef !== undefined ? { onViewRef } : {}), viewProps: effectiveViewProps }), oauthReturn.notice !== null && (_jsxs("p", { role: "status", className: `guuey-chat-oauth-notice guuey-chat-oauth-${oauthReturn.notice.kind}`, children: [oauthReturn.notice.kind === "connected"
|
|
294
384
|
? strings.oauthConnected(oauthReturn.notice.serverName)
|
|
295
385
|
: strings.oauthFailed(oauthReturn.notice.reason), _jsx("button", { type: "button", className: "guuey-chat-oauth-dismiss", onClick: oauthReturn.dismiss, children: strings.promptDismissed })] })), _jsxs("form", { className: "guuey-chat-composer", onSubmit: (e) => {
|
|
296
386
|
e.preventDefault();
|
package/dist/types.d.ts
CHANGED
|
@@ -452,6 +452,16 @@ export type ChatDebugEvent = {
|
|
|
452
452
|
} | {
|
|
453
453
|
type: "turn-recovered";
|
|
454
454
|
marker: string;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* A view pushed a `ui/update-model-context` snapshot and the kit's
|
|
458
|
+
* default sink recorded it (guuey#335). The snapshot itself is a
|
|
459
|
+
* COMPLEMENT — producers mirror it server-side — so the debug surface
|
|
460
|
+
* carries the fact and the size, not the payload.
|
|
461
|
+
*/
|
|
462
|
+
| {
|
|
463
|
+
type: "model-context-update";
|
|
464
|
+
byteSize: number;
|
|
455
465
|
};
|
|
456
466
|
/**
|
|
457
467
|
* One renderable view the plan saw, BEFORE any chips/promotion pass —
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,WAAW,EACX,cAAc,EACd,QAAQ,EACR,SAAS,EACV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;;;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EAAE,eAAe,CAAC;IAAC,GAAG,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC3E;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AAC5C;;;;;GAKG;GACD;IAAE,IAAI,EAAE,sBAAsB,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,OAAO,CAAC;IACb,yEAAyE;IACzE,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,aAAa,GAAG,SAAS,CAAC;IACjC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACjC,4DAA4D;IAC5D,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,0EAA0E;IAC1E,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;;;;OAKG;IACH,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAC7B,6DAA6D;IAC7D,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,kEAAkE;IAClE,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB;;;;OAIG;IACH,KAAK,EAAE,eAAe,EAAE,CAAC;CAC1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guuey/chat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "The default end-user transcript UI for guuey agents — the headless view-model (planTranscript), calm/debug presets, the GuueyChatTheme token schema, the ChatStrings i18n seam, and (at ./react) the component kit that renders it: per-category components, <Transcript>, the live + history input assemblers, and stick-to-bottom/windowed/accessible transcript behavior; at ./native, the React Native renderer over the same view-model.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"@silverprotocol/core": "0.5.0",
|
|
40
40
|
"@silverprotocol/richtext": "0.5.0",
|
|
41
41
|
"zod": "^4.3.6",
|
|
42
|
-
"@guuey/agent-client": "0.
|
|
43
|
-
"@guuey/mcp-apps-host": "0.
|
|
42
|
+
"@guuey/agent-client": "0.12.1",
|
|
43
|
+
"@guuey/mcp-apps-host": "0.12.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"react": ">=18",
|
package/src/plan.ts
CHANGED
|
@@ -149,17 +149,43 @@ function foldAssistantSources(
|
|
|
149
149
|
const hasTurnIdentity = result.messages.some(
|
|
150
150
|
(m) => m.role === "assistant" && m.turnId !== undefined,
|
|
151
151
|
);
|
|
152
|
+
// ONE source per conversational TURN, not per assistant message segment
|
|
153
|
+
// (guuey#306 — the mis-slotting bug): a pod fold emits SEVERAL assistant
|
|
154
|
+
// messages per turn (thought/text/tool interleave — a generative-card
|
|
155
|
+
// turn is ~6-8 segments), and the conversation loop pairs users to
|
|
156
|
+
// sources BY SLOT — per-segment sources stretched the index space, so
|
|
157
|
+
// from turn 2 on every user bubble rendered clustered inside turn 1's
|
|
158
|
+
// segment run. Grouping: a `user` row closes the current group (the
|
|
159
|
+
// fold's messages are the whole conversation, users included), and a
|
|
160
|
+
// turnId CHANGE between assistant segments splits too (identity beats
|
|
161
|
+
// adjacency — two turns without an intervening user row still separate).
|
|
152
162
|
const sources: AssistantSource[] = [];
|
|
153
163
|
const notices: FoldNotice[] = [];
|
|
164
|
+
let current: AssistantSource | null = null;
|
|
165
|
+
let currentTurnId: string | undefined;
|
|
154
166
|
for (const m of result.messages) {
|
|
155
|
-
if (m.role === "
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
167
|
+
if (m.role === "user") {
|
|
168
|
+
current = null;
|
|
169
|
+
currentTurnId = undefined;
|
|
170
|
+
} else if (m.role === "assistant") {
|
|
171
|
+
const startsNewTurn =
|
|
172
|
+
current === null ||
|
|
173
|
+
(m.turnId !== undefined && currentTurnId !== undefined && m.turnId !== currentTurnId);
|
|
174
|
+
if (startsNewTurn) {
|
|
175
|
+
current = { blocks: [], live: false, stopped: false };
|
|
176
|
+
sources.push(current);
|
|
177
|
+
currentTurnId = undefined;
|
|
178
|
+
}
|
|
179
|
+
if (m.turnId !== undefined) currentTurnId = m.turnId;
|
|
180
|
+
current!.blocks.push(...m.content);
|
|
181
|
+
if (inFlight && hasTurnIdentity && m.turnId !== undefined && openTurns.has(m.turnId)) {
|
|
182
|
+
current!.live = true;
|
|
183
|
+
}
|
|
161
184
|
} else if (m.role === "tool" && sources.length > 0) {
|
|
162
|
-
|
|
185
|
+
// Tool results belong to the turn in progress — or, when they trail a
|
|
186
|
+
// user boundary before the next assistant segment, to the PRECEDING
|
|
187
|
+
// turn (the pre-#306 last-source semantics, kept).
|
|
188
|
+
(current ?? sources[sources.length - 1]!).blocks.push(...m.content);
|
|
163
189
|
} else if (m.role === "notice") {
|
|
164
190
|
// R16 (spec draft.2): a session annotation — a PEER row, never folded
|
|
165
191
|
// into assistant content; it anchors after the source it followed.
|
|
@@ -178,10 +204,33 @@ function foldAssistantSources(
|
|
|
178
204
|
return { sources, notices };
|
|
179
205
|
}
|
|
180
206
|
|
|
207
|
+
/**
|
|
208
|
+
* Flat assistant rows grouped by conversational ORDER (guuey#306): a user
|
|
209
|
+
* row closes the current slot, consecutive assistant rows merge into one —
|
|
210
|
+
* the assembler's interleave IS the turn structure, and the old
|
|
211
|
+
* filter/zip threw it away (double/empty assistant rows drifted every
|
|
212
|
+
* later user bubble by one). Shared by the flat path and the fold-vs-flat
|
|
213
|
+
* seam, so both count the same slots.
|
|
214
|
+
*/
|
|
215
|
+
function flatSettledGroups(messages: TranscriptInputs["messages"]): AssistantSource[] {
|
|
216
|
+
const groups: AssistantSource[] = [];
|
|
217
|
+
let current: AssistantSource | null = null;
|
|
218
|
+
for (const m of messages) {
|
|
219
|
+
if (m.role === "user") {
|
|
220
|
+
current = null;
|
|
221
|
+
} else if (m.role === "assistant") {
|
|
222
|
+
if (current === null) {
|
|
223
|
+
current = { blocks: [], live: false, stopped: false };
|
|
224
|
+
groups.push(current);
|
|
225
|
+
}
|
|
226
|
+
current.blocks.push({ type: "text", text: m.text });
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return groups;
|
|
230
|
+
}
|
|
231
|
+
|
|
181
232
|
function flatAssistantSources(inputs: TranscriptInputs, inFlight: boolean): AssistantSource[] {
|
|
182
|
-
const settled: AssistantSource[] = inputs.messages
|
|
183
|
-
.filter((m) => m.role === "assistant")
|
|
184
|
-
.map((m) => ({ blocks: [{ type: "text", text: m.text }], live: false, stopped: false }));
|
|
233
|
+
const settled: AssistantSource[] = flatSettledGroups(inputs.messages);
|
|
185
234
|
// The in-flight (or abort-kept) partial is its own trailing slot — settled
|
|
186
235
|
// turns live in `messages`; `assistantText` is ignored once `ready` again
|
|
187
236
|
// UNLESS the turn ended by abort (R1 aborted-partial keeps it).
|
|
@@ -727,29 +776,23 @@ export function planTranscript(
|
|
|
727
776
|
// keep rendering as flat text slots in front. When the fold spans the
|
|
728
777
|
// whole conversation (a pure-live session — the corpus's world), the kept
|
|
729
778
|
// prefix is empty and the plan is byte-identical to the old wholesale
|
|
730
|
-
// replace. Alignment
|
|
731
|
-
//
|
|
732
|
-
//
|
|
733
|
-
//
|
|
734
|
-
//
|
|
735
|
-
// cards by the actionScope dedupe below.
|
|
779
|
+
// replace. Alignment counts TURNS on
|
|
780
|
+
// both sides (guuey#306): fold sources group per turn (user boundary +
|
|
781
|
+
// turnId change), flat entries group by conversational order — the old
|
|
782
|
+
// per-message COUNT approximation (and its one-off seam drift on
|
|
783
|
+
// card-only turns) is gone.
|
|
736
784
|
let assistants: AssistantSource[];
|
|
737
785
|
if (inputs.result) {
|
|
738
786
|
const fold = foldAssistantSources(inputs.result, inFlight, inputs.aborted === true);
|
|
739
787
|
const foldSources = fold.sources;
|
|
740
788
|
const settledFoldCount = foldSources.filter((s) => !s.live).length;
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
stopped: false,
|
|
749
|
-
}),
|
|
750
|
-
),
|
|
751
|
-
...foldSources,
|
|
752
|
-
];
|
|
789
|
+
// Both sides of the seam now count TURNS (guuey#306): fold sources are
|
|
790
|
+
// per-turn groups, and the flat prefix uses the SAME order-derived
|
|
791
|
+
// grouping — the old per-message counts were the documented
|
|
792
|
+
// approximation this replaces.
|
|
793
|
+
const flatGroups = flatSettledGroups(inputs.messages);
|
|
794
|
+
const keep = Math.max(0, flatGroups.length - settledFoldCount);
|
|
795
|
+
assistants = [...flatGroups.slice(0, keep), ...foldSources];
|
|
753
796
|
if (policy.notice.show) {
|
|
754
797
|
// Fold-borne notices anchor to the fold source they followed, which
|
|
755
798
|
// sits at global slot `keep + afterSourceIndex` after the seam.
|
package/src/react/components.tsx
CHANGED
package/src/react/guuey-chat.tsx
CHANGED
|
@@ -57,13 +57,15 @@ import {
|
|
|
57
57
|
type ReactNode,
|
|
58
58
|
} from "react";
|
|
59
59
|
import {
|
|
60
|
+
createUiActionRelay,
|
|
60
61
|
createUiResourceReader,
|
|
61
62
|
createWebAdapters,
|
|
62
63
|
type AgentInvokeAdapters,
|
|
63
64
|
} from "@guuey/agent-client";
|
|
64
65
|
import type { AgHitlAnswer, AgPausedAsk } from "@silverprotocol/core";
|
|
65
66
|
import { useAgentInvoke } from "@guuey/agent-client/react";
|
|
66
|
-
import
|
|
67
|
+
import { unavailableToolCallResult } from "@guuey/mcp-apps-host";
|
|
68
|
+
import type { McpToolCallResult, UiActionRequest, UiResourceReader } from "@guuey/mcp-apps-host";
|
|
67
69
|
import { calmPolicy, debugPolicy, type TranscriptPolicy } from "../policy.js";
|
|
68
70
|
import { useStructuralIdentity } from "./structural-identity.js";
|
|
69
71
|
import { defaultChatStrings, type ChatStrings } from "../strings.js";
|
|
@@ -78,10 +80,38 @@ import type {
|
|
|
78
80
|
} from "../types.js";
|
|
79
81
|
import type { ThemeMode } from "./theme-css.js";
|
|
80
82
|
import { Transcript, type TranscriptWindowing } from "./transcript.js";
|
|
81
|
-
import type { TranscriptComponents, TranscriptItemContext } from "./components.js";
|
|
83
|
+
import type { TranscriptComponents, TranscriptItemContext, ViewSlotProps } from "./components.js";
|
|
82
84
|
import { useTranscript, useTranscriptInputs } from "./use-transcript.js";
|
|
83
85
|
import { oauthPromptAction, useOAuthReturn } from "./oauth-return.js";
|
|
84
86
|
|
|
87
|
+
/**
|
|
88
|
+
* The kit-tier theme announce (guuey#302): default `hostContext.theme`
|
|
89
|
+
* from the transcript mode onto every view slot. A caller-declared
|
|
90
|
+
* `hostContext` key wins field-by-field; `theme` is only filled in.
|
|
91
|
+
* Exported for tests; not part of the package surface.
|
|
92
|
+
*/
|
|
93
|
+
export function viewPropsWithThemeAnnounce(
|
|
94
|
+
viewProps: TranscriptItemContext["viewProps"],
|
|
95
|
+
mode: ThemeMode,
|
|
96
|
+
defaults: Pick<ViewSlotProps, "onCallTool" | "onUpdateModelContext"> = {},
|
|
97
|
+
): TranscriptItemContext["viewProps"] {
|
|
98
|
+
const themed = (base: ViewSlotProps | undefined): ViewSlotProps => ({
|
|
99
|
+
// Kit-default host wires (guuey#335): the ACTION RELAY (Confirm inside
|
|
100
|
+
// a rendered card is a tools/call — without a relay the initialize-only
|
|
101
|
+
// host -32601s and the interaction visibly fails) and the
|
|
102
|
+
// model-context sink (a COMPLEMENT channel — producers mirror the
|
|
103
|
+
// snapshot server-side, so a recording sink is honest). A caller-
|
|
104
|
+
// declared slot prop always wins.
|
|
105
|
+
...defaults,
|
|
106
|
+
...base,
|
|
107
|
+
hostContext: { theme: mode, ...base?.hostContext },
|
|
108
|
+
});
|
|
109
|
+
if (typeof viewProps === "function") {
|
|
110
|
+
return (item, mount) => themed(viewProps(item, mount));
|
|
111
|
+
}
|
|
112
|
+
return themed(viewProps);
|
|
113
|
+
}
|
|
114
|
+
|
|
85
115
|
/**
|
|
86
116
|
* The imperative seam (guuey#210): programmatic send/prefill/focus for
|
|
87
117
|
* hosts that stay on the batteries-included path (suggested-prompt chips
|
|
@@ -116,6 +146,16 @@ export interface GuueyChatHandle {
|
|
|
116
146
|
* {@link GuueyChatProps.onThread}.
|
|
117
147
|
*/
|
|
118
148
|
readonly threadId: string | null;
|
|
149
|
+
/**
|
|
150
|
+
* The slot props the kit's OWN inline mounts run with — theme announce,
|
|
151
|
+
* default action relay, model-context sink (guuey#335). A host mounting
|
|
152
|
+
* a roster view on its own canvas (`<GuueyView {...handle.viewSlotProps()}`>)
|
|
153
|
+
* gets the identical wiring, so a rendered card's Confirm works there
|
|
154
|
+
* too. Live values (read on demand); when the host passed a FUNCTION-form
|
|
155
|
+
* `viewProps`, this returns the kit defaults (per-item resolution belongs
|
|
156
|
+
* to the transcript).
|
|
157
|
+
*/
|
|
158
|
+
viewSlotProps(): ViewSlotProps;
|
|
119
159
|
}
|
|
120
160
|
|
|
121
161
|
export interface GuueyChatProps {
|
|
@@ -396,6 +436,75 @@ export const GuueyChat = forwardRef<GuueyChatHandle, GuueyChatProps>(function Gu
|
|
|
396
436
|
onViewsChangeRef.current(overlaid);
|
|
397
437
|
}, [plan.views, resolvedMounts]);
|
|
398
438
|
|
|
439
|
+
// The theme announce, completed at the kit tier (guuey#302): every
|
|
440
|
+
// inline mount carries `hostContext.theme` from the transcript's `mode`
|
|
441
|
+
// — render bundles read it at ui/initialize (ggui precedence: slice
|
|
442
|
+
// wins, host falls back — their #551/#573). A caller's explicit
|
|
443
|
+
// `viewProps.hostContext` keys win; `theme` is only defaulted. Hosts
|
|
444
|
+
// mounting views DIRECTLY (a canvas over the roster) announce on their
|
|
445
|
+
// own <GuueyView hostContext> — this covers the kit's own mounts.
|
|
446
|
+
// The DEFAULT ACTION RELAY (guuey#335 — the founder-hit Confirm bug):
|
|
447
|
+
// pod-then-persisted, built over the SAME identity as the reader, thread
|
|
448
|
+
// read through the ref at CALL time. Without it, a kit-mounted render's
|
|
449
|
+
// tools/call hits an initialize-only host and the card's interaction
|
|
450
|
+
// visibly fails — the #221 batteries-included treatment, applied to the
|
|
451
|
+
// ACTION half. No thread yet ⇒ the in-band unavailable result (a card
|
|
452
|
+
// cannot exist before its thread, but a race answers honestly).
|
|
453
|
+
const defaultOnCallTool = useMemo<((request: UiActionRequest) => Promise<McpToolCallResult>) | undefined>(() => {
|
|
454
|
+
if (apiBaseUrl === undefined) return undefined;
|
|
455
|
+
return async (request) => {
|
|
456
|
+
const threadId = threadIdRef.current;
|
|
457
|
+
if (threadId === null) return unavailableToolCallResult();
|
|
458
|
+
const getToken = getAccessTokenRef.current;
|
|
459
|
+
const getGuest = getGuestSecretRef.current;
|
|
460
|
+
const relay = createUiActionRelay({
|
|
461
|
+
apiBaseUrl,
|
|
462
|
+
threadId,
|
|
463
|
+
endpointUrl,
|
|
464
|
+
...(getToken !== undefined ? { getAccessToken: getToken } : {}),
|
|
465
|
+
guestSecret: getGuest !== undefined ? getGuest() : null,
|
|
466
|
+
});
|
|
467
|
+
return relay(request);
|
|
468
|
+
};
|
|
469
|
+
}, [apiBaseUrl, endpointUrl]);
|
|
470
|
+
|
|
471
|
+
// Model-context sink (guuey#335): the snapshot is a complement (producers
|
|
472
|
+
// mirror it server-side), so recording to the debug surface is the honest
|
|
473
|
+
// kit default — and answering the method keeps strict producers green.
|
|
474
|
+
const onDebugEventRef = useRef(onDebugEvent);
|
|
475
|
+
onDebugEventRef.current = onDebugEvent;
|
|
476
|
+
const defaultOnUpdateModelContext = useCallback((params: { [key: string]: unknown }) => {
|
|
477
|
+
onDebugEventRef.current?.({
|
|
478
|
+
type: "model-context-update",
|
|
479
|
+
byteSize: JSON.stringify(params)?.length ?? 0,
|
|
480
|
+
});
|
|
481
|
+
}, []);
|
|
482
|
+
|
|
483
|
+
const effectiveViewProps = useMemo<TranscriptItemContext["viewProps"]>(
|
|
484
|
+
() =>
|
|
485
|
+
viewPropsWithThemeAnnounce(viewProps, mode, {
|
|
486
|
+
...(defaultOnCallTool !== undefined ? { onCallTool: defaultOnCallTool } : {}),
|
|
487
|
+
onUpdateModelContext: defaultOnUpdateModelContext,
|
|
488
|
+
}),
|
|
489
|
+
[viewProps, mode, defaultOnCallTool, defaultOnUpdateModelContext],
|
|
490
|
+
);
|
|
491
|
+
|
|
492
|
+
// The canvas-host door (guuey#335): a host mounting views DIRECTLY from
|
|
493
|
+
// the roster (the chat-rail shell) needs the SAME slot wiring the kit's
|
|
494
|
+
// inline mounts get — theme announce, action relay, context sink. Read
|
|
495
|
+
// through a ref so the lifetime-stable handle always hands out current
|
|
496
|
+
// wiring; a caller-passed FUNCTION-form viewProps resolves per transcript
|
|
497
|
+
// item only, so the handle returns the kit defaults in that case.
|
|
498
|
+
const staticSlotPropsRef = useRef<ViewSlotProps>({});
|
|
499
|
+
staticSlotPropsRef.current =
|
|
500
|
+
typeof effectiveViewProps === "function"
|
|
501
|
+
? {
|
|
502
|
+
...(defaultOnCallTool !== undefined ? { onCallTool: defaultOnCallTool } : {}),
|
|
503
|
+
onUpdateModelContext: defaultOnUpdateModelContext,
|
|
504
|
+
hostContext: { theme: mode },
|
|
505
|
+
}
|
|
506
|
+
: (effectiveViewProps ?? {});
|
|
507
|
+
|
|
399
508
|
// ── Composer ─────────────────────────────────────────────────────────
|
|
400
509
|
const [input, setInput] = useState("");
|
|
401
510
|
const inputRef = useRef<HTMLTextAreaElement | null>(null);
|
|
@@ -445,6 +554,9 @@ export const GuueyChat = forwardRef<GuueyChatHandle, GuueyChatProps>(function Gu
|
|
|
445
554
|
get threadId(): string | null {
|
|
446
555
|
return threadIdRef.current;
|
|
447
556
|
},
|
|
557
|
+
// Same live-read discipline as `threadId`: the ref always holds the
|
|
558
|
+
// CURRENT kit wiring (guuey#335 — the canvas-host door).
|
|
559
|
+
viewSlotProps: (): ViewSlotProps => staticSlotPropsRef.current,
|
|
448
560
|
}),
|
|
449
561
|
[],
|
|
450
562
|
);
|
|
@@ -552,7 +664,7 @@ export const GuueyChat = forwardRef<GuueyChatHandle, GuueyChatProps>(function Gu
|
|
|
552
664
|
onViewPhase={onViewPhase}
|
|
553
665
|
onViewDiagnosis={onViewDiagnosis}
|
|
554
666
|
{...(onViewRef !== undefined ? { onViewRef } : {})}
|
|
555
|
-
|
|
667
|
+
viewProps={effectiveViewProps}
|
|
556
668
|
/>
|
|
557
669
|
{oauthReturn.notice !== null && (
|
|
558
670
|
<p
|
package/src/types.ts
CHANGED
|
@@ -503,7 +503,14 @@ export type ChatDebugEvent =
|
|
|
503
503
|
diagnosis?: ViewCspDiagnosis;
|
|
504
504
|
}
|
|
505
505
|
| { type: "unknown-block"; key: ItemKey; typeName: string; byteSize: number }
|
|
506
|
-
| { type: "turn-recovered"; marker: string }
|
|
506
|
+
| { type: "turn-recovered"; marker: string }
|
|
507
|
+
/**
|
|
508
|
+
* A view pushed a `ui/update-model-context` snapshot and the kit's
|
|
509
|
+
* default sink recorded it (guuey#335). The snapshot itself is a
|
|
510
|
+
* COMPLEMENT — producers mirror it server-side — so the debug surface
|
|
511
|
+
* carries the fact and the size, not the payload.
|
|
512
|
+
*/
|
|
513
|
+
| { type: "model-context-update"; byteSize: number };
|
|
507
514
|
|
|
508
515
|
/**
|
|
509
516
|
* One renderable view the plan saw, BEFORE any chips/promotion pass —
|