@ggui-ai/mcp-server 0.23.0 → 0.25.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/build-mcp.d.ts.map +1 -1
- package/dist/build-mcp.js +140 -1
- package/dist/control-service.d.ts.map +1 -1
- package/dist/control-service.js +0 -3
- package/dist/ggui-session-channel/subscribe.d.ts +11 -36
- package/dist/ggui-session-channel/subscribe.d.ts.map +1 -1
- package/dist/ggui-session-channel/subscribe.js +41 -0
- package/dist/ggui-session-channel.d.ts +31 -3
- package/dist/ggui-session-channel.d.ts.map +1 -1
- package/dist/ggui-session-channel.js +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/llm-backed-negotiator.d.ts +19 -2
- package/dist/llm-backed-negotiator.d.ts.map +1 -1
- package/dist/llm-backed-negotiator.js +31 -38
- package/dist/mcp-apps-outbound.d.ts +1 -1
- package/dist/mcp-apps-outbound.d.ts.map +1 -1
- package/dist/mcp-apps-outbound.js +56 -13
- package/dist/mcp-endpoint-routes.d.ts +1 -0
- package/dist/mcp-endpoint-routes.d.ts.map +1 -1
- package/dist/mcp-endpoint-routes.js +34 -3
- package/dist/runtime-bundle-hash.d.ts +7 -0
- package/dist/runtime-bundle-hash.d.ts.map +1 -1
- package/dist/runtime-bundle-hash.js +8 -2
- package/dist/runtime-bundle-route.d.ts.map +1 -1
- package/dist/runtime-bundle-route.js +15 -0
- package/dist/server.d.ts +35 -52
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +46 -65
- package/package.json +13 -13
- package/dist/render-read-gate.d.ts +0 -50
- package/dist/render-read-gate.d.ts.map +0 -1
- package/dist/render-read-gate.js +0 -36
package/dist/build-mcp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-mcp.d.ts","sourceRoot":"","sources":["../src/build-mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;G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,CAAC,EAAE,CAAC;IAC5D;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;IAElE;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAE/B;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC,CAAC,MAAM,EAAE,SAAS,KAAK,IAAI,CAAC,CAAC;IAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CACvC;AAwOD,wBAAgB,cAAc,CAC5B,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,aAAa,CAAC,aAAa,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,EAChE,UAAU,EAAE,MAAM,cAAc,EAChC,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,qBAA0B,GAC/B,SAAS,CAmRX"}
|
package/dist/build-mcp.js
CHANGED
|
@@ -99,6 +99,123 @@ function classifyFailurePayload(payload) {
|
|
|
99
99
|
...(typeof code === 'string' ? { code } : {}),
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Per-session fields on the `tool_invoked` line of the session-keyed tools:
|
|
104
|
+
* the three runtime tools (ggui#1377 for pull; ggui#1395 for consume and
|
|
105
|
+
* submit) and the mutation and render tools (ggui#1474 — amend, update,
|
|
106
|
+
* render), so an instrument joins a reaction to its tap by session.
|
|
107
|
+
*
|
|
108
|
+
* In a composition that wires no logger into these handlers, this line is
|
|
109
|
+
* their whole trace. ggui#1376 had to be read per app and minute; these
|
|
110
|
+
* fields make it per session, from the wire shapes the handlers already
|
|
111
|
+
* return — ids, counts and flags, never gesture content. The return type is
|
|
112
|
+
* the closed key set that posture promises: a new key is a type change here,
|
|
113
|
+
* never a spread.
|
|
114
|
+
*
|
|
115
|
+
* What a `sessionId` on a SUCCESS line proves, per tool — never raw caller
|
|
116
|
+
* input in any of them:
|
|
117
|
+
* - pull and consume: a session the caller's app owns. Both throw on an
|
|
118
|
+
* unknown or cross-app session before they return (the visibility gate),
|
|
119
|
+
* so every success line of theirs qualifies.
|
|
120
|
+
* - submit: a pipe this server holds. Only a `kind: 'dispatch'` that
|
|
121
|
+
* committed (`ok: true`) carries it — the append fails on an absent pipe
|
|
122
|
+
* and the handler answers `{ok: false, code}` (logged as `ok: false` +
|
|
123
|
+
* `code`, no session). The append checks existence, not app ownership,
|
|
124
|
+
* so the claim stops there. An audit kind (`openLink`,
|
|
125
|
+
* `requestDisplayMode`, an extension kind) touches no pipe and carries no
|
|
126
|
+
* session at all: its `sessionId` was never read by anything.
|
|
127
|
+
* - amend and update: a session the caller's app owns, read from the
|
|
128
|
+
* OUTPUT. Both run the shared mutation core, which app-scope-gates the
|
|
129
|
+
* session (`renderStore.get` + an `appId` match) and throws
|
|
130
|
+
* `GguiSessionNotFoundError` on a missing or cross-app one before any
|
|
131
|
+
* return — so the output's `sessionId` is the gated one, including when
|
|
132
|
+
* an in-process caller threads it through the context rather than the
|
|
133
|
+
* input.
|
|
134
|
+
* - render: the session id this call MINTED for the caller's app, read
|
|
135
|
+
* from the OUTPUT (never caller input — render's input names no
|
|
136
|
+
* session). A `rendered` result carries it, and so does a `failed` one
|
|
137
|
+
* (on the in-result failure line); a `refused` result mints none. It
|
|
138
|
+
* proves the id is this call's, NOT that a row backs it: the handler
|
|
139
|
+
* swallows a render-store commit rejection (the placeholder, probe,
|
|
140
|
+
* cache-hit and error-record commits, and the cold-generation success
|
|
141
|
+
* commit, which then answers `failed`), so on those paths the id names
|
|
142
|
+
* no row, or only a provisional placeholder — the claim stops there,
|
|
143
|
+
* and a consumer that needs the row reads it from the store.
|
|
144
|
+
*
|
|
145
|
+
* Consume adds `eventCount`, `status`, `timeoutS` (the requested timeout; 0
|
|
146
|
+
* when omitted, the handler's own default) and `aborted: true` when the
|
|
147
|
+
* request's signal is aborted by the time the line is written — a superset
|
|
148
|
+
* of "cancelled mid-poll", read at log time, never a false negative. A
|
|
149
|
+
* committed dispatch adds `consumerPresent`, the doorbell's gate.
|
|
150
|
+
*/
|
|
151
|
+
const SESSION_TOOLS = new Set([
|
|
152
|
+
'ggui_runtime_pull',
|
|
153
|
+
'ggui_consume',
|
|
154
|
+
'ggui_runtime_submit_action',
|
|
155
|
+
'ggui_amend',
|
|
156
|
+
'ggui_update',
|
|
157
|
+
'ggui_render',
|
|
158
|
+
]);
|
|
159
|
+
/** ggui#1474 — session tools whose logged session is the OUTPUT's (the gated or committed one), not the input's. */
|
|
160
|
+
const OUTPUT_SESSION_TOOLS = new Set(['ggui_amend', 'ggui_update', 'ggui_render']);
|
|
161
|
+
function sessionFields(tool, input, output, ctx) {
|
|
162
|
+
if (!SESSION_TOOLS.has(tool))
|
|
163
|
+
return {};
|
|
164
|
+
const sessionId = OUTPUT_SESSION_TOOLS.has(tool) ? output['sessionId'] : input['sessionId'];
|
|
165
|
+
if (typeof sessionId !== 'string' || sessionId === '')
|
|
166
|
+
return {};
|
|
167
|
+
if (tool === 'ggui_runtime_submit_action') {
|
|
168
|
+
if (input['kind'] !== 'dispatch')
|
|
169
|
+
return {};
|
|
170
|
+
if (output['ok'] !== true) {
|
|
171
|
+
return typeof output['code'] === 'string' ? { ok: false, code: output['code'] } : { ok: false };
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
sessionId,
|
|
175
|
+
...(typeof output['consumerPresent'] === 'boolean'
|
|
176
|
+
? { consumerPresent: output['consumerPresent'] }
|
|
177
|
+
: {}),
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
if (tool === 'ggui_consume') {
|
|
181
|
+
const events = output['events'];
|
|
182
|
+
return {
|
|
183
|
+
sessionId,
|
|
184
|
+
...(Array.isArray(events) ? { eventCount: events.length } : {}),
|
|
185
|
+
...(typeof output['status'] === 'string' ? { status: output['status'] } : {}),
|
|
186
|
+
timeoutS: typeof input['timeout'] === 'number' ? input['timeout'] : 0,
|
|
187
|
+
...(ctx.signal?.aborted === true ? { aborted: true } : {}),
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
return { sessionId };
|
|
191
|
+
}
|
|
192
|
+
/** Bound on `claimedSessionId`: a real id is a UUID; anything longer is not one. */
|
|
193
|
+
const CLAIMED_SESSION_ID_MAX_CHARS = 128;
|
|
194
|
+
/**
|
|
195
|
+
* The caller's CLAIMED session on an `outcome: 'error'` line of the session
|
|
196
|
+
* tools (ggui#1395; amend and update since ggui#1474). Render's input schema
|
|
197
|
+
* declares no `sessionId` and the MCP SDK strips undeclared keys before the
|
|
198
|
+
* handler runs, so a render line never carries a claim. A refused consume — unknown or cross-app
|
|
199
|
+
* session, the visibility gate — is the one failure of the tap → consume
|
|
200
|
+
* chain that is otherwise invisible per session. It is raw caller input,
|
|
201
|
+
* the first on this line: named as a claim so it never reads as an owned
|
|
202
|
+
* session, and cut to {@link CLAIMED_SESSION_ID_MAX_CHARS} with a flag so a
|
|
203
|
+
* caller cannot put arbitrary text in a log under a field that promises an
|
|
204
|
+
* id.
|
|
205
|
+
*/
|
|
206
|
+
function claimedSessionField(tool, input) {
|
|
207
|
+
if (!SESSION_TOOLS.has(tool))
|
|
208
|
+
return {};
|
|
209
|
+
const sessionId = input['sessionId'];
|
|
210
|
+
if (typeof sessionId !== 'string')
|
|
211
|
+
return {};
|
|
212
|
+
if (sessionId.length <= CLAIMED_SESSION_ID_MAX_CHARS)
|
|
213
|
+
return { claimedSessionId: sessionId };
|
|
214
|
+
return {
|
|
215
|
+
claimedSessionId: sessionId.slice(0, CLAIMED_SESSION_ID_MAX_CHARS),
|
|
216
|
+
claimedSessionIdTruncated: true,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
102
219
|
export function buildMcpServer(info, handlers, getContext, logger, opts = {}) {
|
|
103
220
|
const server = new McpServer({
|
|
104
221
|
name: info.name,
|
|
@@ -121,7 +238,7 @@ export function buildMcpServer(info, handlers, getContext, logger, opts = {}) {
|
|
|
121
238
|
// Thread the same per-request context accessor + logger the tool
|
|
122
239
|
// path uses (`getContext`, param 3 of `buildMcpServer`) so the
|
|
123
240
|
// per-session resource handler's render-read gate sees the
|
|
124
|
-
// caller (
|
|
241
|
+
// caller (`renderReadAllowed`, @ggui-ai/mcp-server-handlers/renders).
|
|
125
242
|
...(opts.selfContained !== undefined
|
|
126
243
|
? { selfContained: { ...opts.selfContained, getContext, logger } }
|
|
127
244
|
: {}),
|
|
@@ -198,6 +315,10 @@ export function buildMcpServer(info, handlers, getContext, logger, opts = {}) {
|
|
|
198
315
|
tool: handler.name,
|
|
199
316
|
appId: ctx.appId,
|
|
200
317
|
...classifyFailurePayload(data.data),
|
|
318
|
+
// A HandlerFailure sits past the handler's own gates (consume's
|
|
319
|
+
// malformed-row refusal, ggui#839), so its session is owned and
|
|
320
|
+
// the per-session fields apply (ggui#1395).
|
|
321
|
+
...sessionFields(handler.name, input, validated, ctx),
|
|
201
322
|
elapsedMs: Date.now() - start,
|
|
202
323
|
});
|
|
203
324
|
return {
|
|
@@ -219,6 +340,7 @@ export function buildMcpServer(info, handlers, getContext, logger, opts = {}) {
|
|
|
219
340
|
tool: handler.name,
|
|
220
341
|
appId: ctx.appId,
|
|
221
342
|
outcome: 'success',
|
|
343
|
+
...sessionFields(handler.name, input, validated, ctx),
|
|
222
344
|
elapsedMs: Date.now() - start,
|
|
223
345
|
});
|
|
224
346
|
// When the handler's output carries a `nextStep`, lead the
|
|
@@ -247,9 +369,25 @@ export function buildMcpServer(info, handlers, getContext, logger, opts = {}) {
|
|
|
247
369
|
const gestureHint = nextStepHint !== undefined && nextStepHint.includes('ggui_consume')
|
|
248
370
|
? nextStepHint
|
|
249
371
|
: undefined;
|
|
372
|
+
// The consume → amend hint (ggui#1399 step 2) gets the same
|
|
373
|
+
// plain-text lead, in its own words: the agent that drained a
|
|
374
|
+
// gesture repaints THIS card rather than rendering a new one
|
|
375
|
+
// (the replacement-instead-of-amend pattern ggui#1376 read on
|
|
376
|
+
// prod). Gentle and bounded like the poll wording above.
|
|
377
|
+
const amendHint = nextStepHint !== undefined && nextStepHint.includes('ggui_amend(')
|
|
378
|
+
? nextStepHint
|
|
379
|
+
: undefined;
|
|
250
380
|
return {
|
|
251
381
|
structuredContent: validated,
|
|
252
382
|
content: [
|
|
383
|
+
...(amendHint !== undefined
|
|
384
|
+
? [
|
|
385
|
+
{
|
|
386
|
+
type: 'text',
|
|
387
|
+
text: `You drained a gesture. If it changed what the user is looking at, repaint the SAME card in place with ${amendHint} — do not render a new one — then re-call ggui_consume for the next gesture.`,
|
|
388
|
+
},
|
|
389
|
+
]
|
|
390
|
+
: []),
|
|
253
391
|
...(gestureHint !== undefined
|
|
254
392
|
? [
|
|
255
393
|
{
|
|
@@ -278,6 +416,7 @@ export function buildMcpServer(info, handlers, getContext, logger, opts = {}) {
|
|
|
278
416
|
appId: ctx.appId,
|
|
279
417
|
outcome: 'error',
|
|
280
418
|
errorClass: errorClassName(err),
|
|
419
|
+
...claimedSessionField(handler.name, input),
|
|
281
420
|
elapsedMs: Date.now() - start,
|
|
282
421
|
});
|
|
283
422
|
throw err;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control-service.d.ts","sourceRoot":"","sources":["../src/control-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC9B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAK,KAAK,WAAW,EAAmB,MAAM,KAAK,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,KAAK,UAAU,GAAG,aAAa,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAE1D,gDAAgD;AAChD,MAAM,MAAM,WAAW,GAAG,O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AAQ,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IAC7C;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAChD;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,uBAAuB,GAAG,cAAc,CAwBjF;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAe,SAAQ,UAAU;IAChD,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC5C"}
|
package/dist/control-service.js
CHANGED
|
@@ -105,15 +105,12 @@ export function filterHandlersByAudience(set, allowed) {
|
|
|
105
105
|
export const SINGLE_CALL_OPS = new Set([
|
|
106
106
|
"ggui_ops_get_credit_balance",
|
|
107
107
|
"ggui_ops_get_my_blueprint_source",
|
|
108
|
-
"ggui_ops_get_org_balance",
|
|
109
108
|
"ggui_ops_get_render_source",
|
|
110
109
|
"ggui_ops_list_apps",
|
|
111
110
|
"ggui_ops_list_blueprints",
|
|
112
|
-
"ggui_ops_list_connector_keys",
|
|
113
111
|
"ggui_ops_list_credit_transactions",
|
|
114
112
|
"ggui_ops_list_my_apps",
|
|
115
113
|
"ggui_ops_list_my_blueprints",
|
|
116
|
-
"ggui_ops_list_orgs",
|
|
117
114
|
"ggui_ops_list_provider_keys",
|
|
118
115
|
"ggui_ops_list_themes",
|
|
119
116
|
"ggui_ops_list_recent_renders",
|
|
@@ -44,8 +44,9 @@ import type { SubscriberLifecycle } from "./subscriber-lifecycle.js";
|
|
|
44
44
|
* G14 (2026-05-23): bootstrap envelopes are no longer single-use. A
|
|
45
45
|
* signature-valid + unexpired token authenticates EVERY subscribe
|
|
46
46
|
* within the TTL window; transient WS drops reconnect without a fresh
|
|
47
|
-
* handshake. Past expiry, the
|
|
48
|
-
*
|
|
47
|
+
* handshake. Past expiry, the view refreshes through
|
|
48
|
+
* `ggui_runtime_refresh_ws_token`, which re-mints only for a caller
|
|
49
|
+
* admitted to the session (ggui#1496 part B).
|
|
49
50
|
*/
|
|
50
51
|
export type GguiSessionChannelBootstrapVerifyResult = {
|
|
51
52
|
readonly ok: true;
|
|
@@ -55,30 +56,15 @@ export type GguiSessionChannelBootstrapVerifyResult = {
|
|
|
55
56
|
readonly ok: false;
|
|
56
57
|
readonly reason: "expired" | "invalid";
|
|
57
58
|
};
|
|
58
|
-
/**
|
|
59
|
-
* Result of {@link GguiSessionChannelBootstrap.refresh}.
|
|
60
|
-
*
|
|
61
|
-
* - `ok: true`: caller swaps the old envelope for `token` and resumes.
|
|
62
|
-
* - `ok: false`: caller MUST re-handshake (refresh window closed,
|
|
63
|
-
* tampered envelope, etc.).
|
|
64
|
-
*/
|
|
65
|
-
export type GguiSessionChannelBootstrapRefreshResult = {
|
|
66
|
-
readonly ok: true;
|
|
67
|
-
readonly token: string;
|
|
68
|
-
readonly expiresAt: string;
|
|
69
|
-
} | {
|
|
70
|
-
readonly ok: false;
|
|
71
|
-
readonly reason: "window_closed" | "invalid";
|
|
72
|
-
};
|
|
73
59
|
export interface GguiSessionChannelBootstrap {
|
|
74
60
|
/**
|
|
75
61
|
* Verify a `SubscribePayload.wsToken` token.
|
|
76
62
|
*
|
|
77
63
|
* Returns the bound identity on success, or a discriminated failure.
|
|
78
|
-
* The channel server maps `'expired'` to `BOOTSTRAP_EXPIRED`
|
|
79
|
-
*
|
|
80
|
-
* `BOOTSTRAP_INVALID` for tamper
|
|
81
|
-
*
|
|
64
|
+
* The channel server maps `'expired'` to `BOOTSTRAP_EXPIRED` (the view
|
|
65
|
+
* then refreshes through `ggui_runtime_refresh_ws_token`, an authorized
|
|
66
|
+
* re-mint), and `'invalid'` to `BOOTSTRAP_INVALID` for tamper, format or
|
|
67
|
+
* kind failures.
|
|
82
68
|
*/
|
|
83
69
|
verify(token: string): GguiSessionChannelBootstrapVerifyResult;
|
|
84
70
|
/**
|
|
@@ -87,21 +73,6 @@ export interface GguiSessionChannelBootstrap {
|
|
|
87
73
|
* `verify()` on a bootstrap subscribe.
|
|
88
74
|
*/
|
|
89
75
|
issueSessionToken(sessionId: string, appId: string): string;
|
|
90
|
-
/**
|
|
91
|
-
* Refresh a (possibly-expired-but-signature-valid) bootstrap envelope
|
|
92
|
-
* into a new envelope with a fresh TTL. Used by the
|
|
93
|
-
* `ggui_runtime_refresh_ws_token` MCP tool — iframes that see their
|
|
94
|
-
* bootstrap drift out of the TTL window swap in the refreshed
|
|
95
|
-
* envelope without going back through `ggui_render`.
|
|
96
|
-
*
|
|
97
|
-
* Stateless: verifies HMAC against the same secret used at mint,
|
|
98
|
-
* checks the refresh window against the ORIGINAL `iat`, and mints
|
|
99
|
-
* a fresh bootstrap envelope bound to the SAME `(sessionId, appId)`.
|
|
100
|
-
* Past the refresh window the result is `{ok:false, reason:
|
|
101
|
-
* 'window_closed'}`; tampered envelopes are `{ok:false, reason:
|
|
102
|
-
* 'invalid'}`.
|
|
103
|
-
*/
|
|
104
|
-
refresh(token: string): GguiSessionChannelBootstrapRefreshResult;
|
|
105
76
|
}
|
|
106
77
|
/**
|
|
107
78
|
* Cookie-based authentication for the live-channel upgrade. Used
|
|
@@ -140,6 +111,10 @@ export interface SubscribeDeps {
|
|
|
140
111
|
readonly cookieAuth?: GguiSessionChannelCookieAuth;
|
|
141
112
|
/** Identity → appId mapping — see `GguiSessionChannelOptions.appIdFromIdentity`. */
|
|
142
113
|
readonly appIdFromIdentity?: (result: AuthResult) => string;
|
|
114
|
+
/** Per-app authorization for a declared appId — see `GguiSessionChannelOptions.authorizeApp`. */
|
|
115
|
+
readonly authorizeApp?: (appId: string, identity: AuthResult) => Promise<void>;
|
|
116
|
+
/** Sources authorized on every subscribe — see `GguiSessionChannelOptions.perAppOnlySources`. */
|
|
117
|
+
readonly perAppOnlySources?: readonly AuthResult["source"][];
|
|
143
118
|
/** Version-handshake policy — see `GguiSessionChannelOptions.versionPolicy`. */
|
|
144
119
|
readonly versionPolicy?: "advisory" | "reject";
|
|
145
120
|
readonly sendError: Outbound["sendError"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../../src/ggui-session-channel/subscribe.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,YAAY,EACb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAMpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAGV,cAAc,EAEf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH
|
|
1
|
+
{"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../../src/ggui-session-channel/subscribe.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,YAAY,EACb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAMpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAGV,cAAc,EAEf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EA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AC;CAChC,GAAG,CACA;IACE,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC;CACxB,GACD;IAAE,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAA;CAAE,CAChC,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,0BAA0B,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACtE,iEAAiE;IACjE,eAAe,CACb,EAAE,EAAE,SAAS,EACb,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,gBAAgB,GAAG;QAAE,IAAI,EAAE,WAAW,CAAA;KAAE,EACjD,WAAW,CAAC,EAAE;QAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GACnE,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB;;;;;;;;;;;OAWG;IACH,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC,CAAC;CAC1F;AAkBD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,aAAa,GAAG,iBAAiB,CA6jB9E"}
|
|
@@ -230,6 +230,47 @@ export function createSubscribeHandlers(deps) {
|
|
|
230
230
|
appId: bound.appId,
|
|
231
231
|
});
|
|
232
232
|
}
|
|
233
|
+
// A DECLARED app on the bearer path is a claim, not a binding
|
|
234
|
+
// (ggui#1480, SPEC §12.2). The wsToken and console-cookie paths
|
|
235
|
+
// above already refuse a declared appId their credential does not
|
|
236
|
+
// bind; the bearer path proves only an identity. When the declared
|
|
237
|
+
// app is not that identity's own, it MUST pass the deployment's
|
|
238
|
+
// per-app authorization — the same check the `/mcp` endpoint runs
|
|
239
|
+
// on a URL-addressed app — before it decides the app-scope gate or
|
|
240
|
+
// names a provisioned row's app below. Refused before any store
|
|
241
|
+
// read, with one fixed answer whatever the reason, so the refusal
|
|
242
|
+
// says nothing about whether the app or the session exists. A
|
|
243
|
+
// deployment that wires no authorization keeps today's posture,
|
|
244
|
+
// as the `/mcp` endpoint does for per-app routing without one.
|
|
245
|
+
//
|
|
246
|
+
// A credential whose source the deployment lists as per-app-only
|
|
247
|
+
// (ggui#1482) passes the same authorization on EVERY subscribe, its
|
|
248
|
+
// identity-default app included — omitting `appId`, or declaring
|
|
249
|
+
// the identity's own, must not skip the checks that authorization
|
|
250
|
+
// runs. The channel refuses to construct with such a list and no
|
|
251
|
+
// authorization, so this arm can never fail open.
|
|
252
|
+
if (tokenBoundAppId === undefined && cookieBound === undefined && deps.authorizeApp) {
|
|
253
|
+
const identityAppId = (deps.appIdFromIdentity ?? defaultAppIdFromIdentity)(effectiveIdentity);
|
|
254
|
+
const appToAuthorize = payload.appId ?? identityAppId;
|
|
255
|
+
const perAppOnly = deps.perAppOnlySources?.includes(effectiveIdentity.source) === true;
|
|
256
|
+
if (perAppOnly || appToAuthorize !== identityAppId) {
|
|
257
|
+
try {
|
|
258
|
+
await deps.authorizeApp(appToAuthorize, effectiveIdentity);
|
|
259
|
+
}
|
|
260
|
+
catch (err) {
|
|
261
|
+
deps.logger.warn("render_channel_app_refused", {
|
|
262
|
+
sessionId: payload.sessionId,
|
|
263
|
+
appId: appToAuthorize,
|
|
264
|
+
declared: payload.appId !== undefined,
|
|
265
|
+
identityAppId,
|
|
266
|
+
source: effectiveIdentity.source,
|
|
267
|
+
reason: err instanceof Error ? err.message : String(err),
|
|
268
|
+
});
|
|
269
|
+
deps.sendError(ws, "APP_MISMATCH", "This credential may not act on the app this subscribe resolves", message.requestId);
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
233
274
|
// Identity-default appId resolution (SPEC §12.2): `payload.appId`
|
|
234
275
|
// is optional on the wire. Absent ⇒ resolve it from the
|
|
235
276
|
// connection's authenticated identity BEFORE any store work —
|
|
@@ -112,7 +112,7 @@ export declare const DEFAULT_PRE_SUBSCRIBE_IDLE_MS = 30000;
|
|
|
112
112
|
*/
|
|
113
113
|
export declare const DEFAULT_MAX_PRE_SUBSCRIBE_CONNECTIONS = 1024;
|
|
114
114
|
export type { GguiSessionChannelLocalToolsOptions } from "./ggui-session-channel/channel-subscriptions.js";
|
|
115
|
-
export type { GguiSessionChannelBootstrap,
|
|
115
|
+
export type { GguiSessionChannelBootstrap, GguiSessionChannelBootstrapVerifyResult, GguiSessionChannelCookieAuth, } from "./ggui-session-channel/subscribe.js";
|
|
116
116
|
export type { SubscriberSink } from "./ggui-session-channel/internal-types.js";
|
|
117
117
|
/**
|
|
118
118
|
* Thrown by {@link GguiSessionChannelServer.attachExternalSubscriber}
|
|
@@ -160,12 +160,40 @@ export interface GguiSessionChannelOptions {
|
|
|
160
160
|
readonly auth: AuthAdapter;
|
|
161
161
|
/**
|
|
162
162
|
* Maps resolved identity → the appId for subscribes that omit
|
|
163
|
-
* `payload.appId` (SPEC §12.2 identity-default resolution)
|
|
164
|
-
*
|
|
163
|
+
* `payload.appId` (SPEC §12.2 identity-default resolution), and on
|
|
164
|
+
* the bearer path decides whether a DECLARED appId is the identity's
|
|
165
|
+
* own or must pass {@link authorizeApp}. Defaults to
|
|
166
|
+
* `defaultAppIdFromIdentity` — same mapping the `/mcp` endpoint
|
|
165
167
|
* uses. Token-bound subscribes (wsToken / console cookie) never
|
|
166
168
|
* consult this seam: their credential already binds the appId.
|
|
167
169
|
*/
|
|
168
170
|
readonly appIdFromIdentity?: (result: AuthResult) => string;
|
|
171
|
+
/**
|
|
172
|
+
* Per-app authorization on the bearer path (SPEC §12.2). The channel
|
|
173
|
+
* awaits this with the subscribe's app and the identity before any
|
|
174
|
+
* store work — when the subscribe DECLARES an app other than the one
|
|
175
|
+
* `appIdFromIdentity` resolves (ggui#1480), and on EVERY subscribe
|
|
176
|
+
* from a {@link perAppOnlySources} credential, its identity-default
|
|
177
|
+
* app included (ggui#1482). A throw refuses with `APP_MISMATCH`.
|
|
178
|
+
* Wire the same check the `/mcp` endpoint runs on a URL-addressed
|
|
179
|
+
* app (`createGguiServer` threads `perAppRouting.authorize`). Absent
|
|
180
|
+
* → a declared appId is trusted, as the `/mcp` endpoint trusts a URL
|
|
181
|
+
* appId under per-app routing without an authorize callback.
|
|
182
|
+
* Credential-bound subscribes (wsToken / console cookie) never
|
|
183
|
+
* consult it: their credential already binds the app.
|
|
184
|
+
*/
|
|
185
|
+
readonly authorizeApp?: (appId: string, identity: AuthResult) => Promise<void>;
|
|
186
|
+
/**
|
|
187
|
+
* Credential sources that are valid only for their own app (ggui#1482).
|
|
188
|
+
* A bearer subscribe whose identity came from a listed source is sent
|
|
189
|
+
* to {@link authorizeApp} on EVERY subscribe — the identity-default
|
|
190
|
+
* app included, whether `payload.appId` is omitted or names it — so
|
|
191
|
+
* the checks that authorization runs cannot be skipped. Listing a
|
|
192
|
+
* source without an `authorizeApp` throws at construction: the list
|
|
193
|
+
* says these credentials must be authorized, so the channel never
|
|
194
|
+
* serves with nothing to authorize them.
|
|
195
|
+
*/
|
|
196
|
+
readonly perAppOnlySources?: readonly AuthResult["source"][];
|
|
169
197
|
/** Structured logger. */
|
|
170
198
|
readonly logger: Logger;
|
|
171
199
|
/** URL path to mount on. Defaults to `/ws`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ggui-session-channel.d.ts","sourceRoot":"","sources":["../src/ggui-session-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,oBAAoB,EACpB,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACd,MAAM,0BAA0B,CAAC;AAKlC,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,wBAAwB,EAAE,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into `createGguiServer` — see `server.ts` for the wire-up.
|
|
130
130
|
*/
|
|
131
131
|
export function createGguiSessionChannelServer(opts) {
|
|
132
|
+
if ((opts.perAppOnlySources?.length ?? 0) > 0 && opts.authorizeApp === undefined) {
|
|
133
|
+
throw new Error("createGguiSessionChannelServer: perAppOnlySources lists credential sources that must be authorized on every subscribe, but no authorizeApp is wired");
|
|
134
|
+
}
|
|
132
135
|
const path = opts.path ?? DEFAULT_RENDER_CHANNEL_PATH;
|
|
133
136
|
// Outbound stream buffer — owns seq assignment + bounded replay
|
|
134
137
|
// storage. Default is in-memory; operators swap via `opts.streamBuffer`.
|
|
@@ -225,6 +228,8 @@ export function createGguiSessionChannelServer(opts) {
|
|
|
225
228
|
bootstrap: opts.bootstrap,
|
|
226
229
|
cookieAuth: opts.cookieAuth,
|
|
227
230
|
appIdFromIdentity: opts.appIdFromIdentity,
|
|
231
|
+
...(opts.authorizeApp ? { authorizeApp: opts.authorizeApp } : {}),
|
|
232
|
+
...(opts.perAppOnlySources ? { perAppOnlySources: opts.perAppOnlySources } : {}),
|
|
228
233
|
versionPolicy: opts.versionPolicy,
|
|
229
234
|
sendError,
|
|
230
235
|
register,
|
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ export type { GenerationDeps } from '@ggui-ai/mcp-server-handlers';
|
|
|
31
31
|
export { buildNoCredentialsGguiSession } from '@ggui-ai/mcp-server-handlers';
|
|
32
32
|
export { buildOpsBundleHandlers, createGguiServer, defaultHandlers } from './server.js';
|
|
33
33
|
export type { CreateGguiServerOptions, ErrorMapperResult, GguiServer, OpsBundleDeps, } from './server.js';
|
|
34
|
+
export { AnthropicStructuredCallError, buildLlmCaller } from './llm-backed-negotiator.js';
|
|
35
|
+
export type { AnthropicStructuredCallFailureKind, BuildLlmCallerOptions, } from './llm-backed-negotiator.js';
|
|
34
36
|
export { buildControlService, CONTROL_PATH, filterHandlersByAudience, SINGLE_CALL_OPS, } from './control-service.js';
|
|
35
37
|
export type { AudienceTag, BuildControlServiceArgs } from './control-service.js';
|
|
36
38
|
export { computeRuntimeBundleHash, insertRuntimeBundleHash, resolveHashedRuntimeBundleUrl, resolveRuntimeBundleHash, } from './runtime-bundle-hash.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAKlF,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAKnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACxF,YAAY,EACV,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,aAAa,GACd,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAKlF,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAKnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACxF,YAAY,EACV,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,aA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AAY,EACV,WAAW,EACX,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AAQnC,YAAY,EACV,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAKlC,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,11 @@
|
|
|
31
31
|
// dependency.
|
|
32
32
|
export { buildNoCredentialsGguiSession } from '@ggui-ai/mcp-server-handlers';
|
|
33
33
|
export { buildOpsBundleHandlers, createGguiServer, defaultHandlers } from './server.js';
|
|
34
|
+
// The handshake negotiator's LLM caller (the rerank judge + the contract
|
|
35
|
+
// synthesizer). Exported so a deployment that builds its own negotiator
|
|
36
|
+
// reuses this one Anthropic structured-call implementation — and can bound
|
|
37
|
+
// it with an abort signal — instead of carrying a copy.
|
|
38
|
+
export { AnthropicStructuredCallError, buildLlmCaller } from './llm-backed-negotiator.js';
|
|
34
39
|
// Control plane (`/control`) — the composition that projects every
|
|
35
40
|
// `protocol`- and `ops`-tagged handler onto one anonymous-capable
|
|
36
41
|
// route with per-tool auth + confirmation gates. `createGguiServer`
|
|
@@ -46,7 +46,9 @@ import type { Blueprint } from "@ggui-ai/protocol";
|
|
|
46
46
|
* (anthropic / openai / google / openrouter / bedrock). `call` runs
|
|
47
47
|
* one `complete()` round-trip on the underlying adapter.
|
|
48
48
|
*
|
|
49
|
-
* `callStructured`
|
|
49
|
+
* `callStructured` (and `callStructuredMetered`, the same call with the
|
|
50
|
+
* response's token usage beside the tool input — ggui#1418) is wired for
|
|
51
|
+
* Anthropic only. Anthropic's
|
|
50
52
|
* `/v1/messages` natively supports forced tool use via `tools[] +
|
|
51
53
|
* tool_choice: {type:'tool', name}` — on the models that accept it; the
|
|
52
54
|
* always-thinking models refuse a forced tool (see
|
|
@@ -64,7 +66,22 @@ import type { Blueprint } from "@ggui-ai/protocol";
|
|
|
64
66
|
* - `@ggui-ai/negotiator/synthesize-contract` (cold-path contract
|
|
65
67
|
* synthesizer)
|
|
66
68
|
*/
|
|
67
|
-
export
|
|
69
|
+
export interface BuildLlmCallerOptions {
|
|
70
|
+
/**
|
|
71
|
+
* Aborts every request this caller makes — both `call` (through the
|
|
72
|
+
* provider adapter) and `callStructured` (the direct `/v1/messages`
|
|
73
|
+
* request). A caller that bounds the call's wall-clock time passes a
|
|
74
|
+
* timed signal here so the bound cancels the request itself rather than
|
|
75
|
+
* racing it. Absent ⇒ the requests run unbounded, as before.
|
|
76
|
+
*
|
|
77
|
+
* The signal is bound for this caller's lifetime and shared by every
|
|
78
|
+
* request it makes: once it fires, every later request on this caller
|
|
79
|
+
* rejects at once. A caller that bounds each call builds one caller per
|
|
80
|
+
* bound, never caches one with a timed signal.
|
|
81
|
+
*/
|
|
82
|
+
readonly signal?: AbortSignal;
|
|
83
|
+
}
|
|
84
|
+
export declare function buildLlmCaller(selection: LlmSelection, providerKey: ProviderKeyRef, options?: BuildLlmCallerOptions): LLMCaller;
|
|
68
85
|
/**
|
|
69
86
|
* Thinking budget added to the caller's ANSWER budget when the model
|
|
70
87
|
* refuses a forced tool. Those are the always-thinking models: their
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm-backed-negotiator.d.ts","sourceRoot":"","sources":["../src/llm-backed-negotiator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EAEjB,YAAY,EACZ,cAAc,EACd,uBAAuB,EACvB,wBAAwB,EACxB,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,mBAAmB,EAC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