@guuey/chat 0.8.0 → 0.9.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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/native/components.d.ts.map +1 -1
- package/dist/native/components.js +4 -2
- package/dist/oauth.d.ts +87 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/oauth.js +121 -0
- package/dist/plan.d.ts.map +1 -1
- package/dist/plan.js +2 -0
- package/dist/react/components.d.ts.map +1 -1
- package/dist/react/components.js +6 -2
- package/dist/react/guuey-chat.d.ts +14 -0
- package/dist/react/guuey-chat.d.ts.map +1 -1
- package/dist/react/guuey-chat.js +21 -3
- package/dist/react/oauth-return.d.ts +61 -0
- package/dist/react/oauth-return.d.ts.map +1 -0
- package/dist/react/oauth-return.js +103 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +1 -0
- package/dist/strings.d.ts +10 -0
- package/dist/strings.d.ts.map +1 -1
- package/dist/strings.js +4 -0
- package/dist/types.d.ts +11 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/corpus/README.md +7 -1
- package/src/corpus/__snapshots__/corpus.test.ts.snap +84 -0
- package/src/corpus/fixtures.ts +77 -0
- package/src/index.ts +11 -0
- package/src/native/components.tsx +14 -4
- package/src/oauth.ts +157 -0
- package/src/plan.ts +2 -0
- package/src/react/components.tsx +16 -4
- package/src/react/guuey-chat.tsx +49 -1
- package/src/react/oauth-return.ts +129 -0
- package/src/react.tsx +9 -0
- package/src/strings.ts +14 -0
- package/src/types.ts +8 -0
- package/styles.css +26 -0
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export { calmPolicy, debugPolicy, type TranscriptPolicy, } from "./policy.js";
|
|
|
15
15
|
export { defaultChatStrings, humanizeToolName, type ChatStrings, } from "./strings.js";
|
|
16
16
|
export { transcriptInputsFromHistory } from "./history-inputs.js";
|
|
17
17
|
export { buildHitlAnswer, grantModeDisplay, hitlPromptsFromFold, type HitlAnswerRecord, type HitlPromptAction, } from "./hitl.js";
|
|
18
|
+
export { OAUTH_LINK_PARAMS, OAUTH_RETURN_PARAMS, OAUTH_SCHEME, oauthAuthorizeAsk, oauthAuthorizeHref, parseOAuthReturn, stripOAuthReturn, type OAuthAuthorizeAsk, type OAuthReturn, } from "./oauth.js";
|
|
18
19
|
export { DEFAULT_CHAT_THEME, GUUEY_CHAT_THEME, GuueyChatPalette, GuueyChatTheme, resolveTheme, } from "./theme.js";
|
|
19
20
|
export type { ChatDebugEvent, CitationsItem, CodeItem, CompactionItem, DataResultItem, DisplayItem, ErrorItem, HistoryBoundaryItem, ItemKey, HitlPromptInput, HitlPromptItem, MediaItem, NoticeItem, ProfilePromptInput, ProfilePromptItem, PromptItem, PromptItemInput, ReasoningItem, StatusLineItem, TextItem, ToolGroupItem, ToolItem, TranscriptInputs, TranscriptMessage, TranscriptOverrides, TranscriptPlan, UnknownItem, UserMessageItem, ViewMountItem, ViewRefItem, } from "./types.js";
|
|
20
21
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACL,aAAa,EACb,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,UAAU,EACV,WAAW,EACX,KAAK,gBAAgB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,WAAW,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,cAAc,EACd,aAAa,EACb,QAAQ,EACR,cAAc,EACd,cAAc,EACd,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,OAAO,EACP,eAAe,EACf,cAAc,EACd,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,aAAa,EACb,cAAc,EACd,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,WAAW,EACX,eAAe,EACf,aAAa,EACb,WAAW,GACZ,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACL,aAAa,EACb,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,UAAU,EACV,WAAW,EACX,KAAK,gBAAgB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,WAAW,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,cAAc,EACd,aAAa,EACb,QAAQ,EACR,cAAc,EACd,cAAc,EACd,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,OAAO,EACP,eAAe,EACf,cAAc,EACd,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,aAAa,EACb,cAAc,EACd,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,WAAW,EACX,eAAe,EACf,aAAa,EACb,WAAW,GACZ,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -15,4 +15,5 @@ export { calmPolicy, debugPolicy, } from "./policy.js";
|
|
|
15
15
|
export { defaultChatStrings, humanizeToolName, } from "./strings.js";
|
|
16
16
|
export { transcriptInputsFromHistory } from "./history-inputs.js";
|
|
17
17
|
export { buildHitlAnswer, grantModeDisplay, hitlPromptsFromFold, } from "./hitl.js";
|
|
18
|
+
export { OAUTH_LINK_PARAMS, OAUTH_RETURN_PARAMS, OAUTH_SCHEME, oauthAuthorizeAsk, oauthAuthorizeHref, parseOAuthReturn, stripOAuthReturn, } from "./oauth.js";
|
|
18
19
|
export { DEFAULT_CHAT_THEME, GUUEY_CHAT_THEME, GuueyChatPalette, GuueyChatTheme, resolveTheme, } from "./theme.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/native/components.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EACV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,2BAA2B,GAC/B,SAAS,CAuEX"}
|
|
@@ -191,14 +191,16 @@ export function NativePrompt({ item, ctx }) {
|
|
|
191
191
|
if (item.state === "resolved" || item.state === "declined") {
|
|
192
192
|
return (_jsx(MutedText, { ctx: ctx, children: item.state === "resolved"
|
|
193
193
|
? item.chosenModeLabel !== null
|
|
194
|
-
?
|
|
194
|
+
? item.oauth !== null
|
|
195
|
+
? s.promptOAuthSent(item.chosenModeLabel)
|
|
196
|
+
: s.promptAnsweredWith(item.chosenModeLabel)
|
|
195
197
|
: s.promptAccept
|
|
196
198
|
: s.promptDeclinedRecord }));
|
|
197
199
|
}
|
|
198
200
|
// `cancelled` = guuey's re-askable dismissal: a record row that reopens
|
|
199
201
|
// to the actions on toggle (silverprotocol#16 ruling).
|
|
200
202
|
const answerable = item.state === "pending" || (item.state === "cancelled" && item.expanded);
|
|
201
|
-
return (_jsxs(View, { accessibilityLiveRegion: "polite", accessible: true, style: { backgroundColor: tokens.palette.surface, borderRadius: tokens.radius, padding: tokens.pad, gap: 8 }, children: [item.state === "cancelled" && (_jsx(Pressable, { accessibilityRole: "button", accessibilityState: { expanded: item.expanded }, onPress: () => ctx.onToggle(item.key), children: _jsx(Text, { style: { color: tokens.palette.inkMuted, fontSize: tokens.fontSize }, children: s.promptDismissed }) })), answerable && (_jsxs(_Fragment, { children: [item.message !== null && (_jsx(Text, { style: { color: tokens.palette.ink, fontSize: tokens.fontSize, fontFamily: tokens.fontFamily }, children: item.message })), _jsxs(View, { style: { flexDirection: "row", flexWrap: "wrap", gap: 12 }, children: [item.grantModes.length === 0 ? (_jsx(Pressable, { accessibilityRole: "button", onPress: () => ctx.onPromptAction?.(item, "accept"), children: _jsx(Text, { style: { color: tokens.palette.accent, fontWeight: "700", fontSize: tokens.fontSize }, children: s.promptAccept }) })) : (item.grantModes.map((mode) => (_jsx(Pressable, { accessibilityRole: "button", accessibilityHint: mode.description, onPress: () => ctx.onPromptAction?.(item, { grantModeId: mode.id }), children: _jsx(Text, { style: { color: tokens.palette.accent, fontWeight: "700", fontSize: tokens.fontSize }, children: mode.label ?? mode.id }) }, mode.id)))), _jsx(Pressable, { accessibilityRole: "button", onPress: () => ctx.onPromptAction?.(item, "decline"), children: _jsx(Text, { style: { color: tokens.palette.inkMuted, fontSize: tokens.fontSize }, children: s.promptDecline }) })] })] }))] }));
|
|
203
|
+
return (_jsxs(View, { accessibilityLiveRegion: "polite", accessible: true, style: { backgroundColor: tokens.palette.surface, borderRadius: tokens.radius, padding: tokens.pad, gap: 8 }, children: [item.state === "cancelled" && (_jsx(Pressable, { accessibilityRole: "button", accessibilityState: { expanded: item.expanded }, onPress: () => ctx.onToggle(item.key), children: _jsx(Text, { style: { color: tokens.palette.inkMuted, fontSize: tokens.fontSize }, children: s.promptDismissed }) })), answerable && (_jsxs(_Fragment, { children: [item.message !== null && (_jsx(Text, { style: { color: tokens.palette.ink, fontSize: tokens.fontSize, fontFamily: tokens.fontFamily }, children: item.message })), _jsxs(View, { style: { flexDirection: "row", flexWrap: "wrap", gap: 12 }, children: [item.grantModes.length === 0 ? (_jsx(Pressable, { accessibilityRole: "button", onPress: () => ctx.onPromptAction?.(item, "accept"), children: _jsx(Text, { style: { color: tokens.palette.accent, fontWeight: "700", fontSize: tokens.fontSize }, children: s.promptAccept }) })) : (item.grantModes.map((mode) => (_jsx(Pressable, { accessibilityRole: "button", accessibilityHint: mode.description, onPress: () => ctx.onPromptAction?.(item, { grantModeId: mode.id }), children: _jsx(Text, { style: { color: tokens.palette.accent, fontWeight: "700", fontSize: tokens.fontSize }, children: mode.label ?? mode.id }) }, mode.id)))), item.oauth !== null ? (_jsx(Pressable, { accessibilityRole: "button", onPress: () => ctx.onPromptAction?.(item, "dismiss"), children: _jsx(Text, { style: { color: tokens.palette.inkMuted, fontSize: tokens.fontSize }, children: s.promptNotNow }) })) : (_jsx(Pressable, { accessibilityRole: "button", onPress: () => ctx.onPromptAction?.(item, "decline"), children: _jsx(Text, { style: { color: tokens.palette.inkMuted, fontSize: tokens.fontSize }, children: s.promptDecline }) }))] })] }))] }));
|
|
202
204
|
}
|
|
203
205
|
if (item.state !== "pending") {
|
|
204
206
|
return (_jsxs(MutedText, { ctx: ctx, children: [item.promptKind, ": ", item.state] }));
|
package/dist/oauth.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The "authorize this server" arm of R10 (guuey#178 Slice 4) — the pure
|
|
3
|
+
* helpers every surface (web kit, widget, studio, portal native) uses for a
|
|
4
|
+
* `hitl.ask kind:"auth"` whose `authConfig.scheme` is `oauth2`.
|
|
5
|
+
*
|
|
6
|
+
* The producer is the guuey runtime's MCP OAuth broker: the pod appends a
|
|
7
|
+
* paused turn (`turn.done outcome:"paused"`) whose ask declares
|
|
8
|
+
* `authConfig:{ scheme:"oauth2", authorizationUrl }` + `grantModes:
|
|
9
|
+
* [always, once?]`. Unlike the profile-consent ask there is **no answer
|
|
10
|
+
* door**: the answer IS the redirect. Picking a mode opens
|
|
11
|
+
* `authorizationUrl` with two query params appended by THIS client —
|
|
12
|
+
*
|
|
13
|
+
* - `mode=<grantModeId>` — the pre-chosen grant (recorded by the broker's
|
|
14
|
+
* callback; the mode is fixed BEFORE the identity-provider hop), and
|
|
15
|
+
* - `returnTo=<the surface's own location>` — where the broker 302s back
|
|
16
|
+
* to when the dance ends (`?connected=<serverName>` on success,
|
|
17
|
+
* `?error=<reason>` on failure). The broker allowlists it; the client
|
|
18
|
+
* just says where it lives.
|
|
19
|
+
*
|
|
20
|
+
* On return the surface strips the two params, shows a one-line notice, and
|
|
21
|
+
* does nothing else: the NEXT turn's pre-turn preflight on the pod resolves
|
|
22
|
+
* `connected` (or asks again). No client-side state survives the redirect
|
|
23
|
+
* on purpose. "Not now" is a plain dismissal (`cancelled` — still pending,
|
|
24
|
+
* re-askable); nothing is written anywhere and the ask re-emits next turn.
|
|
25
|
+
*
|
|
26
|
+
* Everything here is string-level (no `URL`/`URLSearchParams`) so it runs
|
|
27
|
+
* identically on React Native, whose URL polyfill is partial.
|
|
28
|
+
*/
|
|
29
|
+
import type { AgPausedAsk } from "@silverprotocol/core";
|
|
30
|
+
/** The `authConfig.scheme` this arm recognises (the spec's OAuth 2 vocabulary). */
|
|
31
|
+
export declare const OAUTH_SCHEME = "oauth2";
|
|
32
|
+
/** The query params THIS client appends to the authorize link. */
|
|
33
|
+
export declare const OAUTH_LINK_PARAMS: {
|
|
34
|
+
readonly mode: "mode";
|
|
35
|
+
readonly returnTo: "returnTo";
|
|
36
|
+
};
|
|
37
|
+
/** The query params the broker's callback appends to `returnTo`. */
|
|
38
|
+
export declare const OAUTH_RETURN_PARAMS: {
|
|
39
|
+
readonly connected: "connected";
|
|
40
|
+
readonly error: "error";
|
|
41
|
+
};
|
|
42
|
+
/** What an auth ask declares once narrowed to the OAuth arm. */
|
|
43
|
+
export interface OAuthAuthorizeAsk {
|
|
44
|
+
authorizationUrl: string;
|
|
45
|
+
scopes: readonly string[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Narrow an ask to the OAuth arm: `kind:"auth"` + `authConfig.scheme ===
|
|
49
|
+
* "oauth2"` + an `authorizationUrl` to open. Anything else (a plain
|
|
50
|
+
* approval, an auth ask with another scheme, a URL-less declaration) is
|
|
51
|
+
* `null` and renders as an ordinary hitl card.
|
|
52
|
+
*/
|
|
53
|
+
export declare function oauthAuthorizeAsk(ask: AgPausedAsk): OAuthAuthorizeAsk | null;
|
|
54
|
+
/**
|
|
55
|
+
* The link to open for a mode pick: `authorizationUrl` + `&mode=<grantModeId>`
|
|
56
|
+
* + `&returnTo=<returnTo>` (each value URI-encoded; `?` vs `&` chosen from
|
|
57
|
+
* the URL as declared). `grantModeId` is required iff the ask declares
|
|
58
|
+
* modes (`null` = a plain accept on a mode-less auth ask — no `mode` param).
|
|
59
|
+
* Throws on a mode the ask did not declare — the inputs came from the
|
|
60
|
+
* declaration itself, so a mismatch is a construction bug, never a user
|
|
61
|
+
* state.
|
|
62
|
+
*/
|
|
63
|
+
export declare function oauthAuthorizeHref(ask: AgPausedAsk, grantModeId: string | null, returnTo: string): string;
|
|
64
|
+
/** The broker's answer, lifted off the return location. */
|
|
65
|
+
export type OAuthReturn = {
|
|
66
|
+
kind: "connected";
|
|
67
|
+
serverName: string;
|
|
68
|
+
} | {
|
|
69
|
+
kind: "error";
|
|
70
|
+
reason: string;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Read the broker's return params off a location (a full URL, a deep link
|
|
74
|
+
* like `guuey://oauth/done?connected=linear`, or a bare `?connected=…`
|
|
75
|
+
* query). `null` when neither param is present. `connected` wins when both
|
|
76
|
+
* appear (the broker never sends both).
|
|
77
|
+
*/
|
|
78
|
+
export declare function parseOAuthReturn(urlOrQuery: string): OAuthReturn | null;
|
|
79
|
+
/**
|
|
80
|
+
* The same location with the broker's return params removed (every other
|
|
81
|
+
* param, and the hash, preserved). Idempotent; a URL without them is
|
|
82
|
+
* returned unchanged. This is what a surface writes back into its address
|
|
83
|
+
* bar (`history.replaceState`) so a reload never re-shows the notice — and
|
|
84
|
+
* what it passes as `returnTo` for the next dance.
|
|
85
|
+
*/
|
|
86
|
+
export declare function stripOAuthReturn(url: string): string;
|
|
87
|
+
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../src/oauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,mFAAmF;AACnF,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,kEAAkE;AAClE,eAAO,MAAM,iBAAiB;;;CAAkD,CAAC;AAEjF,oEAAoE;AACpE,eAAO,MAAM,mBAAmB;;;CAAsD,CAAC;AAEvF,gEAAgE;AAChE,MAAM,WAAW,iBAAiB;IAChC,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,WAAW,GAAG,iBAAiB,GAAG,IAAI,CAK5E;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAczG;AAED,2DAA2D;AAC3D,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACzC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AA4BtC;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAUvE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAiBpD"}
|
package/dist/oauth.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/** The `authConfig.scheme` this arm recognises (the spec's OAuth 2 vocabulary). */
|
|
2
|
+
export const OAUTH_SCHEME = "oauth2";
|
|
3
|
+
/** The query params THIS client appends to the authorize link. */
|
|
4
|
+
export const OAUTH_LINK_PARAMS = { mode: "mode", returnTo: "returnTo" };
|
|
5
|
+
/** The query params the broker's callback appends to `returnTo`. */
|
|
6
|
+
export const OAUTH_RETURN_PARAMS = { connected: "connected", error: "error" };
|
|
7
|
+
/**
|
|
8
|
+
* Narrow an ask to the OAuth arm: `kind:"auth"` + `authConfig.scheme ===
|
|
9
|
+
* "oauth2"` + an `authorizationUrl` to open. Anything else (a plain
|
|
10
|
+
* approval, an auth ask with another scheme, a URL-less declaration) is
|
|
11
|
+
* `null` and renders as an ordinary hitl card.
|
|
12
|
+
*/
|
|
13
|
+
export function oauthAuthorizeAsk(ask) {
|
|
14
|
+
if (ask.kind !== "auth" || ask.authConfig === undefined)
|
|
15
|
+
return null;
|
|
16
|
+
const { scheme, authorizationUrl, scopes } = ask.authConfig;
|
|
17
|
+
if (scheme !== OAUTH_SCHEME || authorizationUrl === undefined || authorizationUrl === "")
|
|
18
|
+
return null;
|
|
19
|
+
return { authorizationUrl, scopes: scopes ?? [] };
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The link to open for a mode pick: `authorizationUrl` + `&mode=<grantModeId>`
|
|
23
|
+
* + `&returnTo=<returnTo>` (each value URI-encoded; `?` vs `&` chosen from
|
|
24
|
+
* the URL as declared). `grantModeId` is required iff the ask declares
|
|
25
|
+
* modes (`null` = a plain accept on a mode-less auth ask — no `mode` param).
|
|
26
|
+
* Throws on a mode the ask did not declare — the inputs came from the
|
|
27
|
+
* declaration itself, so a mismatch is a construction bug, never a user
|
|
28
|
+
* state.
|
|
29
|
+
*/
|
|
30
|
+
export function oauthAuthorizeHref(ask, grantModeId, returnTo) {
|
|
31
|
+
const oauth = oauthAuthorizeAsk(ask);
|
|
32
|
+
if (oauth === null)
|
|
33
|
+
throw new Error("oauthAuthorizeHref: the ask is not an oauth2 auth ask");
|
|
34
|
+
const declared = ask.grantModes ?? [];
|
|
35
|
+
if (grantModeId === null && declared.length > 0) {
|
|
36
|
+
throw new Error(`oauthAuthorizeHref: ${ask.askId} declares grant modes — a mode is required`);
|
|
37
|
+
}
|
|
38
|
+
if (grantModeId !== null && !declared.some((m) => m.id === grantModeId)) {
|
|
39
|
+
throw new Error(`oauthAuthorizeHref: grant mode "${grantModeId}" is not declared on ${ask.askId}`);
|
|
40
|
+
}
|
|
41
|
+
if (returnTo === "")
|
|
42
|
+
throw new Error("oauthAuthorizeHref: returnTo is required");
|
|
43
|
+
const sep = oauth.authorizationUrl.includes("?") ? "&" : "?";
|
|
44
|
+
const mode = grantModeId === null ? "" : `${OAUTH_LINK_PARAMS.mode}=${encodeURIComponent(grantModeId)}&`;
|
|
45
|
+
return `${oauth.authorizationUrl}${sep}${mode}${OAUTH_LINK_PARAMS.returnTo}=${encodeURIComponent(returnTo)}`;
|
|
46
|
+
}
|
|
47
|
+
/** `decodeURIComponent` that yields the raw text for a malformed escape (a foreign param is not ours to fail on). */
|
|
48
|
+
function safeDecode(s) {
|
|
49
|
+
try {
|
|
50
|
+
return decodeURIComponent(s.replace(/\+/g, " "));
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return s;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/** Split a URL (or bare query) into its query pairs — RN-safe, no `URLSearchParams`. */
|
|
57
|
+
function queryPairs(urlOrQuery) {
|
|
58
|
+
const q = urlOrQuery.indexOf("?");
|
|
59
|
+
let query = q === -1 ? (urlOrQuery.startsWith("&") || !urlOrQuery.includes("=") ? "" : urlOrQuery) : urlOrQuery.slice(q + 1);
|
|
60
|
+
const hash = query.indexOf("#");
|
|
61
|
+
if (hash !== -1)
|
|
62
|
+
query = query.slice(0, hash);
|
|
63
|
+
const pairs = [];
|
|
64
|
+
for (const part of query.split("&")) {
|
|
65
|
+
if (part === "")
|
|
66
|
+
continue;
|
|
67
|
+
const eq = part.indexOf("=");
|
|
68
|
+
const k = eq === -1 ? part : part.slice(0, eq);
|
|
69
|
+
const v = eq === -1 ? "" : part.slice(eq + 1);
|
|
70
|
+
pairs.push([safeDecode(k), safeDecode(v)]);
|
|
71
|
+
}
|
|
72
|
+
return pairs;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Read the broker's return params off a location (a full URL, a deep link
|
|
76
|
+
* like `guuey://oauth/done?connected=linear`, or a bare `?connected=…`
|
|
77
|
+
* query). `null` when neither param is present. `connected` wins when both
|
|
78
|
+
* appear (the broker never sends both).
|
|
79
|
+
*/
|
|
80
|
+
export function parseOAuthReturn(urlOrQuery) {
|
|
81
|
+
let connected;
|
|
82
|
+
let error;
|
|
83
|
+
for (const [k, v] of queryPairs(urlOrQuery)) {
|
|
84
|
+
if (k === OAUTH_RETURN_PARAMS.connected && v !== "")
|
|
85
|
+
connected ??= v;
|
|
86
|
+
else if (k === OAUTH_RETURN_PARAMS.error && v !== "")
|
|
87
|
+
error ??= v;
|
|
88
|
+
}
|
|
89
|
+
if (connected !== undefined)
|
|
90
|
+
return { kind: "connected", serverName: connected };
|
|
91
|
+
if (error !== undefined)
|
|
92
|
+
return { kind: "error", reason: error };
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The same location with the broker's return params removed (every other
|
|
97
|
+
* param, and the hash, preserved). Idempotent; a URL without them is
|
|
98
|
+
* returned unchanged. This is what a surface writes back into its address
|
|
99
|
+
* bar (`history.replaceState`) so a reload never re-shows the notice — and
|
|
100
|
+
* what it passes as `returnTo` for the next dance.
|
|
101
|
+
*/
|
|
102
|
+
export function stripOAuthReturn(url) {
|
|
103
|
+
const q = url.indexOf("?");
|
|
104
|
+
if (q === -1)
|
|
105
|
+
return url;
|
|
106
|
+
const hashAt = url.indexOf("#", q);
|
|
107
|
+
const base = url.slice(0, q);
|
|
108
|
+
const hash = hashAt === -1 ? "" : url.slice(hashAt);
|
|
109
|
+
const query = hashAt === -1 ? url.slice(q + 1) : url.slice(q + 1, hashAt);
|
|
110
|
+
const kept = query
|
|
111
|
+
.split("&")
|
|
112
|
+
.filter((part) => {
|
|
113
|
+
if (part === "")
|
|
114
|
+
return false;
|
|
115
|
+
const eq = part.indexOf("=");
|
|
116
|
+
const key = safeDecode(eq === -1 ? part : part.slice(0, eq));
|
|
117
|
+
return key !== OAUTH_RETURN_PARAMS.connected && key !== OAUTH_RETURN_PARAMS.error;
|
|
118
|
+
})
|
|
119
|
+
.join("&");
|
|
120
|
+
return kept === "" ? `${base}${hash}` : `${base}?${kept}${hash}`;
|
|
121
|
+
}
|
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;
|
|
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,EASV,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EAIf,MAAM,YAAY,CAAC;AA0mBpB,uCAAuC;AACvC,wBAAgB,cAAc,CAC5B,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,gBAAgB,EACxB,SAAS,GAAE,mBAAwB,GAClC,cAAc,CA6QhB;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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { snapshotViewMount, toolResultLocator, toolResultViewMount, uiResourceChannel, } from "@guuey/mcp-apps-host";
|
|
2
2
|
import { grantModeDisplay } from "./hitl.js";
|
|
3
|
+
import { oauthAuthorizeAsk } from "./oauth.js";
|
|
3
4
|
/** R5's giant threshold: above this byte count the state is `giant`. */
|
|
4
5
|
const GIANT_RESULT_BYTES = 16_384;
|
|
5
6
|
/** Approximate byte size of a JSON value — deterministic, allocation-bounded. */
|
|
@@ -734,6 +735,7 @@ export function planTranscript(inputs, policy, overrides = {}) {
|
|
|
734
735
|
message: prompt.ask.message ?? null,
|
|
735
736
|
askKind: prompt.ask.kind,
|
|
736
737
|
grantModes: prompt.ask.grantModes ?? [],
|
|
738
|
+
oauth: oauthAuthorizeAsk(prompt.ask),
|
|
737
739
|
state: prompt.state,
|
|
738
740
|
chosenModeId: prompt.grantModeId ?? null,
|
|
739
741
|
chosenModeLabel: chosen !== undefined ? grantModeDisplay(chosen) : null,
|
|
@@ -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,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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BzC,CAAC;AAEF,uEAAuE;AACvE,wBAAgB,UAAU,CACxB,IAAI,EAAE,WAAW,EACjB,UAAU,EAAE,oBAAoB,EAChC,GAAG,EAAE,qBAAqB,GACzB,SAAS,CAuEX"}
|
package/dist/react/components.js
CHANGED
|
@@ -182,14 +182,18 @@ export function DefaultPrompt({ item, ctx }) {
|
|
|
182
182
|
// the durable deny. `cancelled` is guuey's re-askable dismissal: it
|
|
183
183
|
// collapses to a record but stays answerable when expanded.
|
|
184
184
|
if (item.state === "resolved" || item.state === "declined") {
|
|
185
|
+
// The OAuth arm's resolved record: the pick SENT the user to the
|
|
186
|
+
// provider (no answer door) — the grant lands on the next turn.
|
|
185
187
|
return (_jsx("p", { className: `guuey-chat-prompt-record guuey-chat-prompt-${item.state}`, children: item.state === "resolved"
|
|
186
188
|
? item.chosenModeLabel !== null
|
|
187
|
-
?
|
|
189
|
+
? item.oauth !== null
|
|
190
|
+
? s.promptOAuthSent(item.chosenModeLabel)
|
|
191
|
+
: s.promptAnsweredWith(item.chosenModeLabel)
|
|
188
192
|
: s.promptAccept
|
|
189
193
|
: s.promptDeclinedRecord }));
|
|
190
194
|
}
|
|
191
195
|
const answerable = item.state === "pending" || (item.state === "cancelled" && item.expanded);
|
|
192
|
-
return (_jsxs("div", { className: "guuey-chat-prompt", role: "group", children: [item.state === "cancelled" && (_jsx("button", { type: "button", className: "guuey-chat-prompt-record guuey-chat-prompt-cancelled", "aria-expanded": item.expanded, onClick: () => ctx.onToggle(item.key), children: s.promptDismissed })), answerable && (_jsxs(_Fragment, { children: [item.message !== null && _jsx("p", { className: "guuey-chat-prompt-ask", children: item.message }), _jsxs("div", { className: "guuey-chat-prompt-actions", children: [item.grantModes.length === 0 ? (_jsx("button", { ref: firstAction, type: "button", className: "guuey-chat-prompt-accept", onClick: () => ctx.onPromptAction?.(item, "accept"), children: s.promptAccept })) : (item.grantModes.map((mode, i) => (_jsx("button", { ref: i === 0 ? firstAction : undefined, type: "button", className: "guuey-chat-prompt-accept", title: mode.description, onClick: () => ctx.onPromptAction?.(item, { grantModeId: mode.id }), children: mode.label ?? mode.id }, mode.id)))), _jsx("button", { type: "button", onClick: () => ctx.onPromptAction?.(item, "decline"), children: s.promptDecline })] })] }))] }));
|
|
196
|
+
return (_jsxs("div", { className: "guuey-chat-prompt", role: "group", children: [item.state === "cancelled" && (_jsx("button", { type: "button", className: "guuey-chat-prompt-record guuey-chat-prompt-cancelled", "aria-expanded": item.expanded, onClick: () => ctx.onToggle(item.key), children: s.promptDismissed })), answerable && (_jsxs(_Fragment, { children: [item.message !== null && _jsx("p", { className: "guuey-chat-prompt-ask", children: item.message }), _jsxs("div", { className: "guuey-chat-prompt-actions", children: [item.grantModes.length === 0 ? (_jsx("button", { ref: firstAction, type: "button", className: "guuey-chat-prompt-accept", onClick: () => ctx.onPromptAction?.(item, "accept"), children: s.promptAccept })) : (item.grantModes.map((mode, i) => (_jsx("button", { ref: i === 0 ? firstAction : undefined, type: "button", className: "guuey-chat-prompt-accept", title: mode.description, onClick: () => ctx.onPromptAction?.(item, { grantModeId: mode.id }), children: mode.label ?? mode.id }, mode.id)))), item.oauth !== null ? (_jsx("button", { type: "button", onClick: () => ctx.onPromptAction?.(item, "dismiss"), children: s.promptNotNow })) : (_jsx("button", { type: "button", onClick: () => ctx.onPromptAction?.(item, "decline"), children: s.promptDecline }))] })] }))] }));
|
|
193
197
|
}
|
|
194
198
|
if (item.state !== "pending") {
|
|
195
199
|
return (_jsxs("p", { className: `guuey-chat-prompt-record guuey-chat-prompt-${item.state}`, children: [item.promptKind, ": ", item.state] }));
|
|
@@ -163,6 +163,20 @@ export interface GuueyChatProps {
|
|
|
163
163
|
* transport). Fired after the transcript record moves.
|
|
164
164
|
*/
|
|
165
165
|
onHitlAnswer?: (answer: AgHitlAnswer, ask: AgPausedAsk) => void;
|
|
166
|
+
/**
|
|
167
|
+
* The OAuth "authorize this server" arm (guuey#178): where the broker
|
|
168
|
+
* sends the user back after the provider dance. Defaults to this page's
|
|
169
|
+
* own location (stale return params stripped). Pass a value when the
|
|
170
|
+
* chat lives at a URL that is not where the user should land.
|
|
171
|
+
*/
|
|
172
|
+
oauthReturnTo?: string;
|
|
173
|
+
/**
|
|
174
|
+
* How the authorize link is opened. Defaults to `openOAuthAuthorize`
|
|
175
|
+
* (in-place navigation; a new tab when framed). The composite ALSO shows
|
|
176
|
+
* the return notice itself (`useOAuthReturn`) — a host that overrides
|
|
177
|
+
* `open` and lands elsewhere renders its own.
|
|
178
|
+
*/
|
|
179
|
+
onOAuthAuthorize?: (href: string, ask: AgPausedAsk) => void;
|
|
166
180
|
/** R11 action slot (sign-in / retry affordances). */
|
|
167
181
|
onErrorAction?: (item: ErrorItem) => void;
|
|
168
182
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guuey-chat.d.ts","sourceRoot":"","sources":["../../src/react/guuey-chat.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,OAAO,EAQL,KAAK,aAAa,EAEnB,MAAM,OAAO,CAAC;AACf,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAA2B,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAmB,MAAM,aAAa,CAAC;AAC1F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAc,KAAK,mBAAmB,EAAE,MAAM,iBAAi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,UAAU,EAChB,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,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,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAQD,eAAO,MAAM,SAAS,4GA6SpB,CAAC"}
|
package/dist/react/guuey-chat.js
CHANGED
|
@@ -53,13 +53,14 @@ import { defaultChatStrings } from "../strings.js";
|
|
|
53
53
|
import { DEFAULT_CHAT_THEME } from "../theme.js";
|
|
54
54
|
import { Transcript } from "./transcript.js";
|
|
55
55
|
import { useTranscript, useTranscriptInputs } from "./use-transcript.js";
|
|
56
|
+
import { oauthPromptAction, useOAuthReturn } from "./oauth-return.js";
|
|
56
57
|
const PROMPT_STATE = {
|
|
57
58
|
accept: "answered",
|
|
58
59
|
decline: "declined",
|
|
59
60
|
dismiss: "dismissed",
|
|
60
61
|
};
|
|
61
62
|
export const GuueyChat = forwardRef(function GuueyChat(props, ref) {
|
|
62
|
-
const { endpointUrl, appId, apiBaseUrl, getAccessToken, getGuestSecret, adapters: adaptersProp, preset = "calm", policy: policyOverrides, components, strings: stringOverrides, theme = DEFAULT_CHAT_THEME, mode = "light", window: windowing, reader, onDebugEvent, viewProps, onPromptAction, onHitlAnswer, onErrorAction, onReady, onThread, className, style, } = props;
|
|
63
|
+
const { endpointUrl, appId, apiBaseUrl, getAccessToken, getGuestSecret, adapters: adaptersProp, preset = "calm", policy: policyOverrides, components, strings: stringOverrides, theme = DEFAULT_CHAT_THEME, mode = "light", window: windowing, reader, onDebugEvent, viewProps, onPromptAction, onHitlAnswer, oauthReturnTo, onOAuthAuthorize, onErrorAction, onReady, onThread, className, style, } = props;
|
|
63
64
|
const adapters = useMemo(() => adaptersProp ??
|
|
64
65
|
createWebAdapters({
|
|
65
66
|
...(apiBaseUrl !== undefined ? { apiBaseUrl } : {}),
|
|
@@ -199,8 +200,23 @@ export const GuueyChat = forwardRef(function GuueyChat(props, ref) {
|
|
|
199
200
|
// Same contract as submit: the hook owns failure surfacing.
|
|
200
201
|
});
|
|
201
202
|
}, [invoke]);
|
|
203
|
+
// guuey#178: the broker's return notice (`?connected=` / `?error=`), read
|
|
204
|
+
// + stripped off the address bar once on mount.
|
|
205
|
+
const oauthReturn = useOAuthReturn();
|
|
202
206
|
const handlePromptAction = useCallback((item, action) => {
|
|
203
207
|
if (item.promptKind === "hitl") {
|
|
208
|
+
// The OAuth arm: the answer is the redirect (no pod door, no
|
|
209
|
+
// `onHitlAnswer`); the ledger records the pick and the link opens.
|
|
210
|
+
if (oauthPromptAction({
|
|
211
|
+
item,
|
|
212
|
+
action,
|
|
213
|
+
answerHitlPrompt,
|
|
214
|
+
...(oauthReturnTo !== undefined ? { returnTo: oauthReturnTo } : {}),
|
|
215
|
+
...(onOAuthAuthorize !== undefined ? { open: onOAuthAuthorize } : {}),
|
|
216
|
+
})) {
|
|
217
|
+
onPromptAction?.(item, action);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
204
220
|
const answer = answerHitlPrompt(item.ask, typeof action === "object" ? action : action === "accept" ? "accept" : action);
|
|
205
221
|
onHitlAnswer?.(answer, item.ask);
|
|
206
222
|
onPromptAction?.(item, action);
|
|
@@ -211,9 +227,11 @@ export const GuueyChat = forwardRef(function GuueyChat(props, ref) {
|
|
|
211
227
|
if (typeof action !== "object")
|
|
212
228
|
resolvePrompt(item.promptId, PROMPT_STATE[action]);
|
|
213
229
|
onPromptAction?.(item, action);
|
|
214
|
-
}, [resolvePrompt, answerHitlPrompt, onHitlAnswer, onPromptAction]);
|
|
230
|
+
}, [resolvePrompt, answerHitlPrompt, onHitlAnswer, onPromptAction, oauthReturnTo, onOAuthAuthorize]);
|
|
215
231
|
const strings = policy.strings;
|
|
216
|
-
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, ...(viewProps !== undefined ? { viewProps } : {}) }), _jsxs("
|
|
232
|
+
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, ...(viewProps !== undefined ? { viewProps } : {}) }), oauthReturn.notice !== null && (_jsxs("p", { role: "status", className: `guuey-chat-oauth-notice guuey-chat-oauth-${oauthReturn.notice.kind}`, children: [oauthReturn.notice.kind === "connected"
|
|
233
|
+
? strings.oauthConnected(oauthReturn.notice.serverName)
|
|
234
|
+
: 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) => {
|
|
217
235
|
e.preventDefault();
|
|
218
236
|
submit();
|
|
219
237
|
}, children: [_jsx("textarea", { ref: inputRef, className: "guuey-chat-composer-input", rows: 1, value: input, onChange: (e) => setInput(e.target.value), onKeyDown: (e) => {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { AgHitlAnswer, AgPausedAsk } from "@silverprotocol/core";
|
|
2
|
+
import type { HitlPromptAction } from "../hitl.js";
|
|
3
|
+
import { type OAuthReturn } from "../oauth.js";
|
|
4
|
+
import type { HitlPromptItem } from "../types.js";
|
|
5
|
+
/** The surface's own location as the next `returnTo` (stale return params stripped). */
|
|
6
|
+
export declare function oauthReturnToHere(): string;
|
|
7
|
+
/** The slice of `window` the opener touches (injectable — jsdom's `location.assign` cannot be spied). */
|
|
8
|
+
export interface OAuthWindow {
|
|
9
|
+
self: object;
|
|
10
|
+
top: object | null;
|
|
11
|
+
open: (url: string, target: string, features: string) => unknown;
|
|
12
|
+
location: {
|
|
13
|
+
assign: (url: string) => void;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Open the authorize link. In place when top-level (the dance ends back on
|
|
18
|
+
* this page); a new tab when framed (the IdP will not render in a frame —
|
|
19
|
+
* `returnTo` then lands the SAME page top-level in that tab, where
|
|
20
|
+
* {@link useOAuthReturn} shows the notice; the embedded chat picks the
|
|
21
|
+
* connection up on its next turn).
|
|
22
|
+
*/
|
|
23
|
+
export declare function openOAuthAuthorize(href: string, win?: OAuthWindow): void;
|
|
24
|
+
export interface UseOAuthReturnResult {
|
|
25
|
+
/** The broker's answer found on the address bar at mount, until dismissed. */
|
|
26
|
+
notice: OAuthReturn | null;
|
|
27
|
+
dismiss: () => void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Read `?connected=<serverName>` / `?error=<reason>` off the current
|
|
31
|
+
* location ONCE (on mount), strip them from the address bar via
|
|
32
|
+
* `history.replaceState`, and expose the result as a dismissible notice.
|
|
33
|
+
* SSR-safe: nothing runs until the effect.
|
|
34
|
+
*/
|
|
35
|
+
export declare function useOAuthReturn(): UseOAuthReturnResult;
|
|
36
|
+
export interface OAuthPromptActionArgs {
|
|
37
|
+
item: HitlPromptItem;
|
|
38
|
+
action: HitlPromptAction;
|
|
39
|
+
/** The kit's ledger (`useTranscriptInputs().answerHitlPrompt`) — records the pick locally; nothing is delivered. */
|
|
40
|
+
answerHitlPrompt: (ask: AgPausedAsk, action: HitlPromptAction) => AgHitlAnswer;
|
|
41
|
+
/** Where the broker should send the user back; defaults to {@link oauthReturnToHere}. */
|
|
42
|
+
returnTo?: string;
|
|
43
|
+
/** How to open the link; defaults to {@link openOAuthAuthorize}. */
|
|
44
|
+
open?: (href: string, ask: AgPausedAsk) => void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The OAuth arm of a prompt action, shared by every web surface. Returns
|
|
48
|
+
* `false` (nothing done) when the item is not an OAuth ask, so a host's
|
|
49
|
+
* #207 hitl branch (build the answer, POST it to the pod door) runs as
|
|
50
|
+
* before. For an OAuth ask:
|
|
51
|
+
*
|
|
52
|
+
* - a mode pick (or a plain accept on a mode-less ask) records the pick in
|
|
53
|
+
* the ledger — the card shows "Connecting — <mode>" — and OPENS
|
|
54
|
+
* `authorizationUrl&mode=<id>&returnTo=<here>`; NOTHING is posted to the
|
|
55
|
+
* pod (there is no answer door — the answer is the redirect);
|
|
56
|
+
* - "Not now" / decline / dismiss all record `cancelled` (still pending,
|
|
57
|
+
* re-askable): nothing is written anywhere and the pod asks again next
|
|
58
|
+
* turn.
|
|
59
|
+
*/
|
|
60
|
+
export declare function oauthPromptAction(args: OAuthPromptActionArgs): boolean;
|
|
61
|
+
//# sourceMappingURL=oauth-return.d.ts.map
|
|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EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,KAAK,IAAI,CAAC;CACjD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAatE"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The web half of the OAuth "authorize this server" arm (guuey#178 Slice 4)
|
|
3
|
+
* — the DOM-touching pieces the pure `../oauth.js` helpers deliberately
|
|
4
|
+
* leave out. Every web surface (the `<GuueyChat>` composite, the widget, the
|
|
5
|
+
* studio agent page) shares these three so the redirect + return behave the
|
|
6
|
+
* same everywhere:
|
|
7
|
+
*
|
|
8
|
+
* - {@link oauthReturnToHere} — the surface's own location, with a stale
|
|
9
|
+
* `?connected=`/`?error=` from a PREVIOUS dance stripped, ready to be
|
|
10
|
+
* the next `returnTo`.
|
|
11
|
+
* - {@link openOAuthAuthorize} — how the link is opened: a top-level page
|
|
12
|
+
* navigates in place (the broker 302s straight back to `returnTo`); a
|
|
13
|
+
* FRAMED page (the widget inside a customer origin) opens a new tab,
|
|
14
|
+
* because identity providers refuse to render inside a third-party
|
|
15
|
+
* frame (`X-Frame-Options` / `frame-ancestors`).
|
|
16
|
+
* - {@link useOAuthReturn} — on mount, read the broker's return params off
|
|
17
|
+
* the address bar, REPLACE the URL without them (a reload never re-shows
|
|
18
|
+
* the notice), and hand the surface a one-shot notice to render.
|
|
19
|
+
*/
|
|
20
|
+
import { useCallback, useEffect, useState } from "react";
|
|
21
|
+
import { oauthAuthorizeHref, parseOAuthReturn, stripOAuthReturn } from "../oauth.js";
|
|
22
|
+
/** The surface's own location as the next `returnTo` (stale return params stripped). */
|
|
23
|
+
export function oauthReturnToHere() {
|
|
24
|
+
return stripOAuthReturn(window.location.href);
|
|
25
|
+
}
|
|
26
|
+
/** Whether this document is rendered inside another origin's frame. */
|
|
27
|
+
function isFramed(win) {
|
|
28
|
+
try {
|
|
29
|
+
return win.top !== win.self;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// A cross-origin `window.top` read throws in some browsers — that IS framed.
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Open the authorize link. In place when top-level (the dance ends back on
|
|
38
|
+
* this page); a new tab when framed (the IdP will not render in a frame —
|
|
39
|
+
* `returnTo` then lands the SAME page top-level in that tab, where
|
|
40
|
+
* {@link useOAuthReturn} shows the notice; the embedded chat picks the
|
|
41
|
+
* connection up on its next turn).
|
|
42
|
+
*/
|
|
43
|
+
export function openOAuthAuthorize(href, win = window) {
|
|
44
|
+
if (isFramed(win)) {
|
|
45
|
+
win.open(href, "_blank", "noopener,noreferrer");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
win.location.assign(href);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Read `?connected=<serverName>` / `?error=<reason>` off the current
|
|
52
|
+
* location ONCE (on mount), strip them from the address bar via
|
|
53
|
+
* `history.replaceState`, and expose the result as a dismissible notice.
|
|
54
|
+
* SSR-safe: nothing runs until the effect.
|
|
55
|
+
*/
|
|
56
|
+
export function useOAuthReturn() {
|
|
57
|
+
const [notice, setNotice] = useState(null);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (typeof window === "undefined")
|
|
60
|
+
return;
|
|
61
|
+
const href = window.location.href;
|
|
62
|
+
const found = parseOAuthReturn(href);
|
|
63
|
+
if (found === null)
|
|
64
|
+
return;
|
|
65
|
+
const clean = stripOAuthReturn(href);
|
|
66
|
+
if (clean !== href)
|
|
67
|
+
window.history.replaceState(window.history.state, "", clean);
|
|
68
|
+
setNotice(found);
|
|
69
|
+
}, []);
|
|
70
|
+
const dismiss = useCallback(() => setNotice(null), []);
|
|
71
|
+
return { notice, dismiss };
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The OAuth arm of a prompt action, shared by every web surface. Returns
|
|
75
|
+
* `false` (nothing done) when the item is not an OAuth ask, so a host's
|
|
76
|
+
* #207 hitl branch (build the answer, POST it to the pod door) runs as
|
|
77
|
+
* before. For an OAuth ask:
|
|
78
|
+
*
|
|
79
|
+
* - a mode pick (or a plain accept on a mode-less ask) records the pick in
|
|
80
|
+
* the ledger — the card shows "Connecting — <mode>" — and OPENS
|
|
81
|
+
* `authorizationUrl&mode=<id>&returnTo=<here>`; NOTHING is posted to the
|
|
82
|
+
* pod (there is no answer door — the answer is the redirect);
|
|
83
|
+
* - "Not now" / decline / dismiss all record `cancelled` (still pending,
|
|
84
|
+
* re-askable): nothing is written anywhere and the pod asks again next
|
|
85
|
+
* turn.
|
|
86
|
+
*/
|
|
87
|
+
export function oauthPromptAction(args) {
|
|
88
|
+
const { item, action, answerHitlPrompt } = args;
|
|
89
|
+
if (item.oauth === null)
|
|
90
|
+
return false;
|
|
91
|
+
if (typeof action === "object" || action === "accept") {
|
|
92
|
+
const grantModeId = typeof action === "object" ? action.grantModeId : null;
|
|
93
|
+
answerHitlPrompt(item.ask, action);
|
|
94
|
+
const href = oauthAuthorizeHref(item.ask, grantModeId, args.returnTo ?? oauthReturnToHere());
|
|
95
|
+
if (args.open !== undefined)
|
|
96
|
+
args.open(href, item.ask);
|
|
97
|
+
else
|
|
98
|
+
openOAuthAuthorize(href);
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
answerHitlPrompt(item.ask, "dismiss");
|
|
102
|
+
return true;
|
|
103
|
+
}
|