@noodleseed/assistant 1.24.0 → 1.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/README.md +4 -9
- package/dist/{app-view-element-DSPtyEul.d.cts → app-view-element-9ojWWYov.d.cts} +3 -2
- package/dist/{app-view-element-DDtXu08a.d.ts → app-view-element-BM4lral-.d.ts} +3 -2
- package/dist/app-view.cjs +213 -41
- package/dist/app-view.cjs.map +1 -1
- package/dist/app-view.d.cts +3 -3
- package/dist/app-view.d.ts +3 -3
- package/dist/app-view.js +2 -2
- package/dist/{appearance-0nS2LFjb.d.cts → appearance-B6vSg8Ub.d.cts} +4 -0
- package/dist/{appearance-0nS2LFjb.d.ts → appearance-B6vSg8Ub.d.ts} +4 -0
- package/dist/{chunk-IBDP6PXQ.js → chunk-7BQHW37I.js} +71 -3
- package/dist/chunk-7BQHW37I.js.map +1 -0
- package/dist/{chunk-5NBHHNI3.js → chunk-LNBUYHL7.js} +2 -2
- package/dist/chunk-LNBUYHL7.js.map +1 -0
- package/dist/{chunk-XKTUXFGX.js → chunk-P32MAR4K.js} +214 -42
- package/dist/chunk-P32MAR4K.js.map +1 -0
- package/dist/{chunk-6PVDV7SO.js → chunk-SGMECNNU.js} +55 -21
- package/dist/chunk-SGMECNNU.js.map +1 -0
- package/dist/{client-By4gqB1k.d.cts → client-BkogON2A.d.ts} +11 -1
- package/dist/{client-Cf38TgwN.d.ts → client-C07ppTU_.d.cts} +11 -1
- package/dist/client.cjs +70 -2
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +1 -1
- package/dist/embed.global.js +149 -114
- package/dist/index.cjs +357 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/react/client.cjs +70 -2
- package/dist/react/client.cjs.map +1 -1
- package/dist/react/client.d.cts +2 -2
- package/dist/react/client.d.ts +2 -2
- package/dist/react/client.js +1 -1
- package/dist/react.cjs +357 -83
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +4 -4
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +3 -1
- package/dist/server.d.ts +3 -1
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-5NBHHNI3.js.map +0 -1
- package/dist/chunk-6PVDV7SO.js.map +0 -1
- package/dist/chunk-IBDP6PXQ.js.map +0 -1
- package/dist/chunk-XKTUXFGX.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -15197,7 +15197,7 @@ __export(src_exports, {
|
|
|
15197
15197
|
});
|
|
15198
15198
|
module.exports = __toCommonJS(src_exports);
|
|
15199
15199
|
|
|
15200
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
15200
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_supports-color@7.2.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
15201
15201
|
init_v4();
|
|
15202
15202
|
var RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
|
|
15203
15203
|
var JSONRPC_VERSION = "2.0";
|
|
@@ -20594,7 +20594,7 @@ var pipelineType = ZodPipeline.create;
|
|
|
20594
20594
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/mini/parse.js
|
|
20595
20595
|
init_core2();
|
|
20596
20596
|
|
|
20597
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
|
|
20597
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_supports-color@7.2.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
|
|
20598
20598
|
function isZ4Schema(s2) {
|
|
20599
20599
|
const schema = s2;
|
|
20600
20600
|
return !!schema._zod;
|
|
@@ -20657,7 +20657,7 @@ function getLiteralValue(schema) {
|
|
|
20657
20657
|
return void 0;
|
|
20658
20658
|
}
|
|
20659
20659
|
|
|
20660
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
|
|
20660
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_supports-color@7.2.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
|
|
20661
20661
|
function isTerminal(status) {
|
|
20662
20662
|
return status === "completed" || status === "failed" || status === "cancelled";
|
|
20663
20663
|
}
|
|
@@ -20665,7 +20665,7 @@ function isTerminal(status) {
|
|
|
20665
20665
|
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@4.4.3/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
|
|
20666
20666
|
var ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
20667
20667
|
|
|
20668
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
|
|
20668
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_supports-color@7.2.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
|
|
20669
20669
|
function getMethodLiteral(schema) {
|
|
20670
20670
|
const shape = getObjectShape(schema);
|
|
20671
20671
|
const methodSchema = shape?.method;
|
|
@@ -20686,7 +20686,7 @@ function parseWithCompat(schema, data) {
|
|
|
20686
20686
|
return result.data;
|
|
20687
20687
|
}
|
|
20688
20688
|
|
|
20689
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
|
|
20689
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_supports-color@7.2.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
|
|
20690
20690
|
var DEFAULT_REQUEST_TIMEOUT_MSEC = 6e4;
|
|
20691
20691
|
var Protocol = class {
|
|
20692
20692
|
constructor(_options) {
|
|
@@ -21798,6 +21798,15 @@ var E = class {
|
|
|
21798
21798
|
sessionId;
|
|
21799
21799
|
setProtocolVersion;
|
|
21800
21800
|
};
|
|
21801
|
+
function AZ(X2) {
|
|
21802
|
+
if (!X2) return "";
|
|
21803
|
+
let Y = [];
|
|
21804
|
+
if (X2.camera) Y.push("camera");
|
|
21805
|
+
if (X2.microphone) Y.push("microphone");
|
|
21806
|
+
if (X2.geolocation) Y.push("geolocation");
|
|
21807
|
+
if (X2.clipboardWrite) Y.push("clipboard-write");
|
|
21808
|
+
return Y.join("; ");
|
|
21809
|
+
}
|
|
21801
21810
|
var KX = [j];
|
|
21802
21811
|
var DX = class extends _ {
|
|
21803
21812
|
_client;
|
|
@@ -22068,34 +22077,131 @@ function GX(X2, Y) {
|
|
|
22068
22077
|
return JSON.stringify(X2) === JSON.stringify(Y);
|
|
22069
22078
|
}
|
|
22070
22079
|
|
|
22080
|
+
// src/app-sandbox-policy.ts
|
|
22081
|
+
var MAX_DOMAINS_PER_DIRECTIVE = 32;
|
|
22082
|
+
function isRecord(value) {
|
|
22083
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22084
|
+
}
|
|
22085
|
+
function isLoopback(hostname3) {
|
|
22086
|
+
return hostname3 === "localhost" || hostname3 === "127.0.0.1" || hostname3 === "[::1]";
|
|
22087
|
+
}
|
|
22088
|
+
function normalizeDomain(value, connect) {
|
|
22089
|
+
if (value.length > 512 || /[;\r\n'"\s]/u.test(value)) return void 0;
|
|
22090
|
+
try {
|
|
22091
|
+
const parsed = new URL(value);
|
|
22092
|
+
const secure = parsed.protocol === "https:" || connect && parsed.protocol === "wss:";
|
|
22093
|
+
const local = isLoopback(parsed.hostname) && (parsed.protocol === "http:" || connect && parsed.protocol === "ws:");
|
|
22094
|
+
if (!secure && !local) return void 0;
|
|
22095
|
+
if (parsed.username || parsed.password || parsed.pathname !== "/" || parsed.search || parsed.hash) {
|
|
22096
|
+
return void 0;
|
|
22097
|
+
}
|
|
22098
|
+
return parsed.origin;
|
|
22099
|
+
} catch {
|
|
22100
|
+
return void 0;
|
|
22101
|
+
}
|
|
22102
|
+
}
|
|
22103
|
+
function normalizeDomains(values, connect) {
|
|
22104
|
+
const normalized = [
|
|
22105
|
+
...new Set(
|
|
22106
|
+
values.slice(0, MAX_DOMAINS_PER_DIRECTIVE).map((value) => typeof value === "string" ? normalizeDomain(value, connect) : void 0).filter((value) => value !== void 0)
|
|
22107
|
+
)
|
|
22108
|
+
];
|
|
22109
|
+
return normalized;
|
|
22110
|
+
}
|
|
22111
|
+
function resolveAssistantAppSandboxPolicy(resourceMeta) {
|
|
22112
|
+
if (!isRecord(resourceMeta)) return {};
|
|
22113
|
+
const rawCsp = resourceMeta.csp;
|
|
22114
|
+
const csp = isRecord(rawCsp) ? {
|
|
22115
|
+
...Array.isArray(rawCsp.connectDomains) ? { connectDomains: normalizeDomains(rawCsp.connectDomains, true) } : {},
|
|
22116
|
+
...Array.isArray(rawCsp.resourceDomains) ? { resourceDomains: normalizeDomains(rawCsp.resourceDomains, false) } : {},
|
|
22117
|
+
...Array.isArray(rawCsp.frameDomains) ? { frameDomains: normalizeDomains(rawCsp.frameDomains, false) } : {},
|
|
22118
|
+
...Array.isArray(rawCsp.baseUriDomains) ? { baseUriDomains: normalizeDomains(rawCsp.baseUriDomains, false) } : {}
|
|
22119
|
+
} : void 0;
|
|
22120
|
+
const rawPermissions = resourceMeta.permissions;
|
|
22121
|
+
const permissions = isRecord(rawPermissions) ? {
|
|
22122
|
+
...isRecord(rawPermissions.camera) ? { camera: {} } : {},
|
|
22123
|
+
...isRecord(rawPermissions.microphone) ? { microphone: {} } : {},
|
|
22124
|
+
...isRecord(rawPermissions.geolocation) ? { geolocation: {} } : {},
|
|
22125
|
+
...isRecord(rawPermissions.clipboardWrite) ? { clipboardWrite: {} } : {}
|
|
22126
|
+
} : void 0;
|
|
22127
|
+
const allowAttribute = AZ(permissions);
|
|
22128
|
+
return {
|
|
22129
|
+
...csp === void 0 ? {} : { csp },
|
|
22130
|
+
...permissions === void 0 ? {} : { permissions },
|
|
22131
|
+
...allowAttribute ? { allowAttribute } : {}
|
|
22132
|
+
};
|
|
22133
|
+
}
|
|
22134
|
+
function assistantAppSandboxUrl(sandboxUrl, policy) {
|
|
22135
|
+
const parsed = new URL(sandboxUrl);
|
|
22136
|
+
if (policy.csp) parsed.searchParams.set("csp", JSON.stringify(policy.csp));
|
|
22137
|
+
const parentOrigin = globalThis.location?.origin;
|
|
22138
|
+
if (parentOrigin && parentOrigin !== "null") {
|
|
22139
|
+
parsed.hash = new URLSearchParams({ parentOrigin }).toString();
|
|
22140
|
+
}
|
|
22141
|
+
return parsed.href;
|
|
22142
|
+
}
|
|
22143
|
+
|
|
22071
22144
|
// src/app-host.ts
|
|
22072
|
-
var PROXY_DOCUMENT = `<!doctype html><meta charset="utf-8"><style>html,body,iframe{border:0;margin:0;width:100%;height:100%;overflow:hidden}body{background:transparent}</style><script>
|
|
22073
|
-
let inner;
|
|
22145
|
+
var PROXY_DOCUMENT = `<!doctype html><meta charset="utf-8"><style>html,body,iframe{border:0;margin:0;width:100%;height:100%;overflow:hidden}body{background:transparent}</style><body><script>
|
|
22146
|
+
let inner,loaded=false;
|
|
22147
|
+
if(self===top)throw new Error('The assistant sandbox relay must be embedded');
|
|
22148
|
+
const standardSandbox='allow-scripts allow-same-origin allow-forms';
|
|
22149
|
+
const rawParentOrigin=new URLSearchParams(location.hash.slice(1)).get('parentOrigin');
|
|
22150
|
+
let expectedParentOrigin;
|
|
22151
|
+
try{const parsed=new URL(rawParentOrigin||'');if(parsed.origin===rawParentOrigin&&/^https?:$/.test(parsed.protocol))expectedParentOrigin=parsed.origin}catch{}
|
|
22152
|
+
const parentTarget=expectedParentOrigin||'*';
|
|
22153
|
+
const ownOrigin=self.origin;
|
|
22074
22154
|
const ready={jsonrpc:'2.0',method:'ui/notifications/sandbox-proxy-ready',params:{}};
|
|
22075
22155
|
// Re-announce until the host acknowledges with the resource: when this document is hosted
|
|
22076
22156
|
// cross-origin, the first announcement can arrive before the host's load handler is listening.
|
|
22077
|
-
const announce=setInterval(()=>parent.postMessage(ready,
|
|
22157
|
+
const announce=setInterval(()=>parent.postMessage(ready,parentTarget),120);
|
|
22078
22158
|
setTimeout(()=>clearInterval(announce),15000);
|
|
22079
22159
|
addEventListener('message',(event)=>{
|
|
22080
22160
|
if(event.source===parent){
|
|
22161
|
+
if(expectedParentOrigin&&event.origin!==expectedParentOrigin)return;
|
|
22081
22162
|
const message=event.data;
|
|
22082
22163
|
if(message?.method==='ui/notifications/sandbox-resource-ready'){
|
|
22083
22164
|
clearInterval(announce);
|
|
22084
|
-
if(
|
|
22165
|
+
if(loaded)return;
|
|
22166
|
+
loaded=true;
|
|
22167
|
+
const requestedSandbox=message.params?.sandbox;
|
|
22085
22168
|
inner=document.createElement('iframe');
|
|
22086
|
-
inner.setAttribute('sandbox',
|
|
22169
|
+
inner.setAttribute('sandbox',requestedSandbox===standardSandbox?standardSandbox:'allow-scripts');
|
|
22087
22170
|
inner.setAttribute('referrerpolicy','no-referrer');
|
|
22088
|
-
|
|
22089
|
-
|
|
22171
|
+
const permissions=message.params?.permissions;
|
|
22172
|
+
const allow=[];
|
|
22173
|
+
if(permissions?.camera)allow.push('camera');
|
|
22174
|
+
if(permissions?.microphone)allow.push('microphone');
|
|
22175
|
+
if(permissions?.geolocation)allow.push('geolocation');
|
|
22176
|
+
if(permissions?.clipboardWrite)allow.push('clipboard-write');
|
|
22177
|
+
if(allow.length)inner.setAttribute('allow',allow.join('; '));
|
|
22178
|
+
document.body.append(inner);
|
|
22179
|
+
let html=String(message.params?.html||'');
|
|
22180
|
+
const csp=message.params?.csp;
|
|
22181
|
+
if(csp&&typeof csp==='object'){
|
|
22182
|
+
const list=(value,fallback)=>Array.isArray(value)&&value.length?value.join(' '):fallback;
|
|
22183
|
+
const resources=Array.isArray(csp.resourceDomains)?csp.resourceDomains:[];
|
|
22184
|
+
const suffix=resources.length?' '+resources.join(' '):'';
|
|
22185
|
+
const policy=["default-src 'none'","script-src 'unsafe-inline'"+suffix,"style-src 'unsafe-inline'"+suffix,'img-src data: blob:'+suffix,'font-src data: blob:'+suffix,'media-src data: blob:'+suffix,'worker-src blob:'+suffix,'connect-src '+list(csp.connectDomains,"'none'"),'frame-src '+list(csp.frameDomains,"'none'"),"object-src 'none'","form-action 'none'",'base-uri '+list(csp.baseUriDomains,"'none'")].join('; ');
|
|
22186
|
+
const meta='<meta http-equiv="Content-Security-Policy" content="'+policy.replace(/&/g,'&').replace(/"/g,'"')+'">';
|
|
22187
|
+
const doctype=html.match(/^\\s*<!doctype[^>]*>/i);
|
|
22188
|
+
html=doctype?html.slice(0,doctype[0].length)+meta+html.slice(doctype[0].length):meta+html;
|
|
22189
|
+
}
|
|
22190
|
+
try{
|
|
22191
|
+
const doc=inner.contentDocument||inner.contentWindow?.document;
|
|
22192
|
+
if(!doc)throw new Error('document unavailable');
|
|
22193
|
+
doc.open();doc.write(html);doc.close();
|
|
22194
|
+
}catch{inner.srcdoc=html}
|
|
22090
22195
|
return;
|
|
22091
22196
|
}
|
|
22092
22197
|
inner?.contentWindow?.postMessage(message,'*');
|
|
22093
22198
|
} else if(inner && event.source===inner.contentWindow) {
|
|
22094
|
-
|
|
22199
|
+
if(event.origin!==ownOrigin)return;
|
|
22200
|
+
parent.postMessage(event.data,parentTarget);
|
|
22095
22201
|
}
|
|
22096
22202
|
});
|
|
22097
|
-
parent.postMessage(ready,
|
|
22098
|
-
</script>`;
|
|
22203
|
+
parent.postMessage(ready,parentTarget);
|
|
22204
|
+
</script></body>`;
|
|
22099
22205
|
function isAllowedAppLink(value, allowedDomains, baseUrl) {
|
|
22100
22206
|
try {
|
|
22101
22207
|
const parsed = new URL(value, baseUrl);
|
|
@@ -22122,16 +22228,42 @@ function createAssistantAppHostContext(theme, allowFullscreen = false, displayMo
|
|
|
22122
22228
|
}
|
|
22123
22229
|
var APP_RENDER_TIMEOUT_MS = 1e4;
|
|
22124
22230
|
var APP_TEARDOWN_TIMEOUT_MS = 1e3;
|
|
22231
|
+
var STANDARD_SANDBOX = "allow-scripts allow-same-origin allow-forms";
|
|
22125
22232
|
var mountedApps = /* @__PURE__ */ new WeakMap();
|
|
22126
22233
|
function resolveSandboxUrl(value) {
|
|
22127
22234
|
if (!value) return void 0;
|
|
22128
22235
|
try {
|
|
22129
22236
|
const parsed = new URL(value);
|
|
22130
|
-
|
|
22237
|
+
const loopback = parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1" || parsed.hostname === "[::1]";
|
|
22238
|
+
const permittedProtocol = parsed.protocol === "https:" || parsed.protocol === "http:" && loopback;
|
|
22239
|
+
const embedderOrigin = globalThis.location?.origin;
|
|
22240
|
+
if (!permittedProtocol || embedderOrigin && embedderOrigin !== "null" && parsed.origin === embedderOrigin) {
|
|
22241
|
+
return void 0;
|
|
22242
|
+
}
|
|
22243
|
+
return parsed.href;
|
|
22131
22244
|
} catch {
|
|
22132
22245
|
return void 0;
|
|
22133
22246
|
}
|
|
22134
22247
|
}
|
|
22248
|
+
function copyAppJson(value, depth = 0) {
|
|
22249
|
+
if (depth > 64) throw new Error("App payload nesting exceeds the host limit");
|
|
22250
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return value;
|
|
22251
|
+
if (typeof value === "number") {
|
|
22252
|
+
if (!Number.isFinite(value)) throw new Error("App payload numbers must be finite");
|
|
22253
|
+
return value;
|
|
22254
|
+
}
|
|
22255
|
+
if (Array.isArray(value)) return value.map((entry) => copyAppJson(entry, depth + 1));
|
|
22256
|
+
const copied = {};
|
|
22257
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
22258
|
+
Object.defineProperty(copied, key, {
|
|
22259
|
+
value: copyAppJson(entry, depth + 1),
|
|
22260
|
+
enumerable: true,
|
|
22261
|
+
configurable: true,
|
|
22262
|
+
writable: true
|
|
22263
|
+
});
|
|
22264
|
+
}
|
|
22265
|
+
return copied;
|
|
22266
|
+
}
|
|
22135
22267
|
function mountAssistantApp(detail, actions, options = {}) {
|
|
22136
22268
|
if (!detail.html) return void 0;
|
|
22137
22269
|
const card = document.createElement("section");
|
|
@@ -22152,16 +22284,25 @@ function mountAssistantApp(detail, actions, options = {}) {
|
|
|
22152
22284
|
const frame = document.createElement("iframe");
|
|
22153
22285
|
frame.className = "noodle-app-frame";
|
|
22154
22286
|
frame.title = detail.title ?? detail.tool;
|
|
22155
|
-
|
|
22287
|
+
const policy = resolveAssistantAppSandboxPolicy(detail.resourceMeta);
|
|
22156
22288
|
frame.setAttribute("referrerpolicy", "no-referrer");
|
|
22157
22289
|
const sandboxUrl = resolveSandboxUrl(options.sandboxUrl);
|
|
22158
|
-
|
|
22159
|
-
|
|
22290
|
+
const appliedPolicy = sandboxUrl ? policy : { csp: policy.csp ?? {} };
|
|
22291
|
+
if (sandboxUrl) {
|
|
22292
|
+
frame.setAttribute("sandbox", STANDARD_SANDBOX);
|
|
22293
|
+
if (policy.allowAttribute) frame.setAttribute("allow", policy.allowAttribute);
|
|
22294
|
+
frame.src = assistantAppSandboxUrl(sandboxUrl, policy);
|
|
22295
|
+
} else {
|
|
22296
|
+
frame.setAttribute("sandbox", "allow-scripts");
|
|
22297
|
+
frame.srcdoc = PROXY_DOCUMENT;
|
|
22298
|
+
}
|
|
22160
22299
|
card.append(frame);
|
|
22161
22300
|
let mountedBridge;
|
|
22162
22301
|
let mountedTransport;
|
|
22163
22302
|
let destroyed = false;
|
|
22164
22303
|
let initialized = false;
|
|
22304
|
+
let renderFailed = false;
|
|
22305
|
+
let renderStage = "sandbox_load";
|
|
22165
22306
|
let currentTheme = actions.theme;
|
|
22166
22307
|
let displayMode = "inline";
|
|
22167
22308
|
let hostContext = createAssistantAppHostContext(
|
|
@@ -22170,6 +22311,15 @@ function mountAssistantApp(detail, actions, options = {}) {
|
|
|
22170
22311
|
displayMode
|
|
22171
22312
|
);
|
|
22172
22313
|
let destroyPromise;
|
|
22314
|
+
let transportClosePromise;
|
|
22315
|
+
let renderTimer;
|
|
22316
|
+
const closeTransport = () => {
|
|
22317
|
+
if (transportClosePromise) return transportClosePromise;
|
|
22318
|
+
const closing = mountedTransport?.close().catch(() => {
|
|
22319
|
+
}) ?? Promise.resolve();
|
|
22320
|
+
transportClosePromise = closing;
|
|
22321
|
+
return closing;
|
|
22322
|
+
};
|
|
22173
22323
|
const applyDisplayMode = (requestedMode) => {
|
|
22174
22324
|
displayMode = requestedMode === "fullscreen" && options.allowFullscreen === true ? "fullscreen" : "inline";
|
|
22175
22325
|
card.toggleAttribute("data-fullscreen", displayMode === "fullscreen");
|
|
@@ -22187,18 +22337,26 @@ function mountAssistantApp(detail, actions, options = {}) {
|
|
|
22187
22337
|
applyDisplayMode("inline");
|
|
22188
22338
|
frame.focus();
|
|
22189
22339
|
});
|
|
22190
|
-
const
|
|
22191
|
-
if (initialized || !frame.isConnected)
|
|
22340
|
+
const showRenderFailure = (code) => {
|
|
22341
|
+
if (code === "view_render_timeout" && initialized || destroyed || renderFailed || !frame.isConnected)
|
|
22342
|
+
return;
|
|
22343
|
+
renderFailed = true;
|
|
22344
|
+
clearTimeout(renderTimer);
|
|
22192
22345
|
const note = document.createElement("div");
|
|
22193
22346
|
note.className = "noodle-app-fallback";
|
|
22194
22347
|
note.textContent = "This app view could not be displayed.";
|
|
22195
22348
|
frame.replaceWith(note);
|
|
22196
|
-
options.onRenderFailure?.({ code
|
|
22349
|
+
options.onRenderFailure?.({ code, retryable: false, stage: renderStage });
|
|
22350
|
+
void closeTransport();
|
|
22351
|
+
};
|
|
22352
|
+
renderTimer = setTimeout(() => {
|
|
22353
|
+
showRenderFailure("view_render_timeout");
|
|
22197
22354
|
}, APP_RENDER_TIMEOUT_MS);
|
|
22198
22355
|
frame.addEventListener(
|
|
22199
22356
|
"load",
|
|
22200
22357
|
() => {
|
|
22201
|
-
if (destroyed) return;
|
|
22358
|
+
if (destroyed || renderFailed) return;
|
|
22359
|
+
renderStage = "sandbox_proxy";
|
|
22202
22360
|
const target = frame.contentWindow;
|
|
22203
22361
|
if (!target) return;
|
|
22204
22362
|
const bridge = new DX(
|
|
@@ -22209,7 +22367,11 @@ function mountAssistantApp(detail, actions, options = {}) {
|
|
|
22209
22367
|
serverTools: {},
|
|
22210
22368
|
serverResources: {},
|
|
22211
22369
|
updateModelContext: { text: {}, structuredContent: {} },
|
|
22212
|
-
message: { text: {} }
|
|
22370
|
+
message: { text: {} },
|
|
22371
|
+
sandbox: {
|
|
22372
|
+
...appliedPolicy.csp === void 0 ? {} : { csp: appliedPolicy.csp },
|
|
22373
|
+
...appliedPolicy.permissions === void 0 ? {} : { permissions: appliedPolicy.permissions }
|
|
22374
|
+
}
|
|
22213
22375
|
},
|
|
22214
22376
|
{
|
|
22215
22377
|
hostContext
|
|
@@ -22217,13 +22379,15 @@ function mountAssistantApp(detail, actions, options = {}) {
|
|
|
22217
22379
|
);
|
|
22218
22380
|
mountedBridge = bridge;
|
|
22219
22381
|
bridge.onsandboxready = () => {
|
|
22220
|
-
if (destroyed) return;
|
|
22382
|
+
if (destroyed || renderFailed) return;
|
|
22383
|
+
renderStage = "app_initialize";
|
|
22221
22384
|
const current = options.getDetail?.() ?? detail;
|
|
22222
22385
|
void bridge.sendSandboxResourceReady({
|
|
22223
22386
|
html: current.html,
|
|
22224
|
-
sandbox: "allow-scripts",
|
|
22225
|
-
...
|
|
22226
|
-
|
|
22387
|
+
sandbox: sandboxUrl ? STANDARD_SANDBOX : "allow-scripts",
|
|
22388
|
+
...appliedPolicy.csp === void 0 ? {} : { csp: appliedPolicy.csp },
|
|
22389
|
+
...appliedPolicy.permissions === void 0 ? {} : { permissions: appliedPolicy.permissions }
|
|
22390
|
+
}).catch(() => showRenderFailure("view_bridge_error"));
|
|
22227
22391
|
};
|
|
22228
22392
|
bridge.onsizechange = ({ height }) => {
|
|
22229
22393
|
if (destroyed) return;
|
|
@@ -22287,21 +22451,30 @@ function mountAssistantApp(detail, actions, options = {}) {
|
|
|
22287
22451
|
return await actions.client.requestApp("resources/read", params);
|
|
22288
22452
|
};
|
|
22289
22453
|
bridge.oninitialized = () => {
|
|
22290
|
-
if (destroyed) return;
|
|
22291
|
-
|
|
22292
|
-
|
|
22293
|
-
|
|
22294
|
-
|
|
22295
|
-
|
|
22296
|
-
|
|
22297
|
-
|
|
22298
|
-
|
|
22299
|
-
|
|
22454
|
+
if (destroyed || renderFailed) return;
|
|
22455
|
+
try {
|
|
22456
|
+
const current = options.getDetail?.() ?? detail;
|
|
22457
|
+
const copiedArguments = copyAppJson(current.arguments ?? {});
|
|
22458
|
+
const copiedResult = copyAppJson(current.result);
|
|
22459
|
+
const argumentsRecord = typeof copiedArguments === "object" && copiedArguments !== null && !Array.isArray(copiedArguments) ? copiedArguments : {};
|
|
22460
|
+
initialized = true;
|
|
22461
|
+
clearTimeout(renderTimer);
|
|
22462
|
+
bridge.setHostContext(hostContext);
|
|
22463
|
+
void Promise.all([
|
|
22464
|
+
bridge.sendToolInput({ arguments: argumentsRecord }),
|
|
22465
|
+
bridge.sendToolResult({
|
|
22466
|
+
content: [{ type: "text", text: JSON.stringify(copiedResult) }],
|
|
22467
|
+
...typeof copiedResult === "object" && copiedResult !== null && !Array.isArray(copiedResult) ? { structuredContent: copiedResult } : {}
|
|
22468
|
+
})
|
|
22469
|
+
]).catch(() => showRenderFailure("view_bridge_error"));
|
|
22470
|
+
} catch {
|
|
22471
|
+
showRenderFailure("view_bridge_error");
|
|
22472
|
+
}
|
|
22300
22473
|
};
|
|
22301
22474
|
const transport = new E(target, target);
|
|
22302
22475
|
mountedTransport = transport;
|
|
22303
22476
|
void bridge.connect(transport).catch(() => {
|
|
22304
|
-
|
|
22477
|
+
showRenderFailure("view_bridge_error");
|
|
22305
22478
|
});
|
|
22306
22479
|
},
|
|
22307
22480
|
{ once: true }
|
|
@@ -22327,8 +22500,7 @@ function mountAssistantApp(detail, actions, options = {}) {
|
|
|
22327
22500
|
}
|
|
22328
22501
|
} catch {
|
|
22329
22502
|
}
|
|
22330
|
-
await
|
|
22331
|
-
});
|
|
22503
|
+
await closeTransport();
|
|
22332
22504
|
card.remove();
|
|
22333
22505
|
mountedApps.delete(card);
|
|
22334
22506
|
})();
|
|
@@ -22455,7 +22627,12 @@ var DEFAULT_APPEARANCE = {
|
|
|
22455
22627
|
sessionIdle: "Assistant session idle",
|
|
22456
22628
|
sessionLoading: "Assistant session loading",
|
|
22457
22629
|
sessionReady: "Assistant session ready",
|
|
22458
|
-
sessionError: "Assistant session unavailable"
|
|
22630
|
+
sessionError: "Assistant session unavailable",
|
|
22631
|
+
signInHeading: "Sign in to continue",
|
|
22632
|
+
signInBody: "",
|
|
22633
|
+
signInAction: "Sign in",
|
|
22634
|
+
// Empty means no sign-up button: authoring the label is the opt-in (ADR 0201, 2026-08-22).
|
|
22635
|
+
signUpAction: ""
|
|
22459
22636
|
},
|
|
22460
22637
|
presentation: {
|
|
22461
22638
|
panel: {
|
|
@@ -27095,6 +27272,9 @@ var AssistantChatStateStore = class {
|
|
|
27095
27272
|
})
|
|
27096
27273
|
);
|
|
27097
27274
|
return;
|
|
27275
|
+
case "auth_requested":
|
|
27276
|
+
this.#writeStandaloneData(() => this.#writeData("sign-in", event.data.id, event.data));
|
|
27277
|
+
return;
|
|
27098
27278
|
case "tool_completed":
|
|
27099
27279
|
this.#writeData("tool-result", event.data.id, event.data);
|
|
27100
27280
|
return;
|
|
@@ -27319,14 +27499,14 @@ function toChatError(error51) {
|
|
|
27319
27499
|
}
|
|
27320
27500
|
function readErrorDetail(error51) {
|
|
27321
27501
|
const detail = Reflect.get(error51, "detail");
|
|
27322
|
-
if (!
|
|
27502
|
+
if (!isRecord2(detail) || typeof detail.code !== "string") return void 0;
|
|
27323
27503
|
return {
|
|
27324
27504
|
code: detail.code,
|
|
27325
27505
|
...typeof detail.status === "number" ? { status: detail.status } : {},
|
|
27326
27506
|
retryable: detail.retryable === true
|
|
27327
27507
|
};
|
|
27328
27508
|
}
|
|
27329
|
-
function
|
|
27509
|
+
function isRecord2(value) {
|
|
27330
27510
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27331
27511
|
}
|
|
27332
27512
|
|
|
@@ -27353,13 +27533,14 @@ var AssistantClientError = class extends Error {
|
|
|
27353
27533
|
}
|
|
27354
27534
|
};
|
|
27355
27535
|
function parseSession(value) {
|
|
27356
|
-
if (!
|
|
27536
|
+
if (!isRecord3(value) || !isRecord3(value.endpoints)) {
|
|
27357
27537
|
throw clientError("session_failed", "Assistant session response is invalid", true);
|
|
27358
27538
|
}
|
|
27359
27539
|
const interactions = value.endpoints.interactions;
|
|
27360
27540
|
const apps = value.endpoints.apps;
|
|
27361
27541
|
const sandbox = value.endpoints.sandbox;
|
|
27362
|
-
|
|
27542
|
+
const transcript = value.endpoints.transcript;
|
|
27543
|
+
if (typeof value.token !== "string" || typeof value.expiresAt !== "string" || typeof value.endpoints.turns !== "string" || typeof value.endpoints.toolConfirmations !== "string" || interactions !== void 0 && typeof interactions !== "string" || apps !== void 0 && typeof apps !== "string" || sandbox !== void 0 && typeof sandbox !== "string" || transcript !== void 0 && typeof transcript !== "string") {
|
|
27363
27544
|
throw clientError("session_failed", "Assistant session response is invalid", true);
|
|
27364
27545
|
}
|
|
27365
27546
|
return {
|
|
@@ -27370,13 +27551,14 @@ function parseSession(value) {
|
|
|
27370
27551
|
toolConfirmations: value.endpoints.toolConfirmations,
|
|
27371
27552
|
...typeof interactions === "string" ? { interactions } : {},
|
|
27372
27553
|
...typeof apps === "string" ? { apps } : {},
|
|
27373
|
-
...typeof sandbox === "string" ? { sandbox } : {}
|
|
27554
|
+
...typeof sandbox === "string" ? { sandbox } : {},
|
|
27555
|
+
...typeof transcript === "string" ? { transcript } : {}
|
|
27374
27556
|
},
|
|
27375
|
-
...
|
|
27376
|
-
...
|
|
27557
|
+
...isRecord3(value.configuration) ? { configuration: value.configuration } : {},
|
|
27558
|
+
...isRecord3(value.resume) && typeof value.resume.tool === "string" ? { resume: { tool: value.resume.tool } } : {}
|
|
27377
27559
|
};
|
|
27378
27560
|
}
|
|
27379
|
-
function
|
|
27561
|
+
function isRecord3(value) {
|
|
27380
27562
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27381
27563
|
}
|
|
27382
27564
|
async function readStableErrorCode(response) {
|
|
@@ -27386,7 +27568,7 @@ async function readStableErrorCode(response) {
|
|
|
27386
27568
|
} catch {
|
|
27387
27569
|
return void 0;
|
|
27388
27570
|
}
|
|
27389
|
-
if (!
|
|
27571
|
+
if (!isRecord3(value) || typeof value.code !== "string") return void 0;
|
|
27390
27572
|
return /^[A-Za-z0-9_.-]{1,64}$/.test(value.code) ? value.code : void 0;
|
|
27391
27573
|
}
|
|
27392
27574
|
function clientError(code, message, retryable, status, options, serviceCode) {
|
|
@@ -27417,12 +27599,12 @@ function toAssistantClientEvent(event) {
|
|
|
27417
27599
|
}
|
|
27418
27600
|
break;
|
|
27419
27601
|
case "tool_proposed":
|
|
27420
|
-
if (hasString(value, "id") && hasString(value, "tool") && hasOptionalString(value.title) && hasOptionalString(value.description) && hasOptionalJson(value.arguments) && (value.reviewSchema === void 0 ||
|
|
27602
|
+
if (hasString(value, "id") && hasString(value, "tool") && hasOptionalString(value.title) && hasOptionalString(value.description) && hasOptionalJson(value.arguments) && (value.reviewSchema === void 0 || isRecord4(value.reviewSchema)) && hasOptionalString(value.expiresAt) && (value.requiresConfirmation === void 0 || value.requiresConfirmation === true) && hasOptionalTurnId(value)) {
|
|
27421
27603
|
return event;
|
|
27422
27604
|
}
|
|
27423
27605
|
break;
|
|
27424
27606
|
case "input_requested":
|
|
27425
|
-
if (hasString(value, "id") && hasString(value, "message") &&
|
|
27607
|
+
if (hasString(value, "id") && hasString(value, "message") && isRecord4(value.requestedSchema) && hasString(value, "expiresAt") && hasOptionalTurnId(value)) {
|
|
27426
27608
|
return event;
|
|
27427
27609
|
}
|
|
27428
27610
|
break;
|
|
@@ -27466,7 +27648,7 @@ function toAssistantClientEvent(event) {
|
|
|
27466
27648
|
return { event: "unrecognized", data: { name: event.event, payload: value } };
|
|
27467
27649
|
}
|
|
27468
27650
|
function isViewAvailableDetail(value) {
|
|
27469
|
-
return hasString(value, "id") && hasString(value, "tool") && typeof value.resourceUri === "string" && value.resourceUri.startsWith("ui://") && hasOptionalString(value.title) && (value.replayed === void 0 || value.replayed === true) && isJsonValue(value.result, 0) && hasOptionalJson(value.arguments) && hasOptionalString(value.html) && (value.resourceMeta === void 0 ||
|
|
27651
|
+
return hasString(value, "id") && hasString(value, "tool") && typeof value.resourceUri === "string" && value.resourceUri.startsWith("ui://") && hasOptionalString(value.title) && (value.replayed === void 0 || value.replayed === true) && isJsonValue(value.result, 0) && hasOptionalJson(value.arguments) && hasOptionalString(value.html) && (value.resourceMeta === void 0 || isRecord4(value.resourceMeta)) && (value.allowedOpenDomains === void 0 || Array.isArray(value.allowedOpenDomains) && value.allowedOpenDomains.every(isHttpsUrl)) && hasOptionalTurnId(value);
|
|
27470
27652
|
}
|
|
27471
27653
|
function isHttpsUrl(value) {
|
|
27472
27654
|
if (typeof value !== "string") return false;
|
|
@@ -27499,11 +27681,11 @@ function isJsonValue(value, depth) {
|
|
|
27499
27681
|
if (Array.isArray(value)) {
|
|
27500
27682
|
return value.length <= 256 && value.every((entry) => isJsonValue(entry, depth + 1));
|
|
27501
27683
|
}
|
|
27502
|
-
if (!
|
|
27684
|
+
if (!isRecord4(value)) return false;
|
|
27503
27685
|
const entries2 = Object.entries(value);
|
|
27504
27686
|
return entries2.length <= 256 && entries2.every(([, entry]) => isJsonValue(entry, depth + 1));
|
|
27505
27687
|
}
|
|
27506
|
-
function
|
|
27688
|
+
function isRecord4(value) {
|
|
27507
27689
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27508
27690
|
}
|
|
27509
27691
|
|
|
@@ -27525,6 +27707,43 @@ function sessionSourceKey(options) {
|
|
|
27525
27707
|
return `${options.embedId ?? ""}|${options.serviceUrl ?? ""}|${options.sessionEndpoint ?? ""}`;
|
|
27526
27708
|
}
|
|
27527
27709
|
|
|
27710
|
+
// src/transcript-replay.ts
|
|
27711
|
+
function parseTranscriptEntries(value) {
|
|
27712
|
+
if (typeof value !== "object" || value === null) return [];
|
|
27713
|
+
const entries2 = value.entries;
|
|
27714
|
+
if (!Array.isArray(entries2)) return [];
|
|
27715
|
+
const parsed = [];
|
|
27716
|
+
for (const entry of entries2) {
|
|
27717
|
+
const { role, text: text3 } = entry ?? {};
|
|
27718
|
+
if (role !== "user" && role !== "assistant" || typeof text3 !== "string") return [];
|
|
27719
|
+
parsed.push({ role, text: text3 });
|
|
27720
|
+
}
|
|
27721
|
+
return parsed;
|
|
27722
|
+
}
|
|
27723
|
+
function transcriptReplayEvents(entries2) {
|
|
27724
|
+
const events = [];
|
|
27725
|
+
let open = false;
|
|
27726
|
+
let awaitingAssistant = false;
|
|
27727
|
+
for (const entry of entries2) {
|
|
27728
|
+
if (entry.role === "user") {
|
|
27729
|
+
if (open) events.push({ event: "message_completed", data: {} });
|
|
27730
|
+
events.push({ event: "message_started", data: { message: entry.text } });
|
|
27731
|
+
open = true;
|
|
27732
|
+
awaitingAssistant = true;
|
|
27733
|
+
continue;
|
|
27734
|
+
}
|
|
27735
|
+
if (!open || !awaitingAssistant) {
|
|
27736
|
+
if (open) events.push({ event: "message_completed", data: {} });
|
|
27737
|
+
events.push({ event: "resume_started", data: { tool: "" } });
|
|
27738
|
+
open = true;
|
|
27739
|
+
}
|
|
27740
|
+
events.push({ event: "content", data: { delta: entry.text } });
|
|
27741
|
+
awaitingAssistant = false;
|
|
27742
|
+
}
|
|
27743
|
+
if (open) events.push({ event: "message_completed", data: {} });
|
|
27744
|
+
return events;
|
|
27745
|
+
}
|
|
27746
|
+
|
|
27528
27747
|
// src/transport.ts
|
|
27529
27748
|
var AssistantTransportError = class extends Error {
|
|
27530
27749
|
code = "invalid_response";
|
|
@@ -27633,15 +27852,15 @@ function parseFrame(frame) {
|
|
|
27633
27852
|
if (event === "done" && !isValidDonePayload(parsed)) {
|
|
27634
27853
|
throw invalidStream("assistant event stream contained an invalid done event");
|
|
27635
27854
|
}
|
|
27636
|
-
return { event, data:
|
|
27855
|
+
return { event, data: isRecord5(parsed) ? parsed : { value: parsed } };
|
|
27637
27856
|
}
|
|
27638
27857
|
function normalizeLineEndings(input) {
|
|
27639
27858
|
return input.replaceAll("\r\n", "\n").replaceAll("\r", "\n");
|
|
27640
27859
|
}
|
|
27641
27860
|
function isValidDonePayload(value) {
|
|
27642
|
-
return
|
|
27861
|
+
return isRecord5(value) && (value.turnId === void 0 || typeof value.turnId === "string" && value.turnId.length > 0);
|
|
27643
27862
|
}
|
|
27644
|
-
function
|
|
27863
|
+
function isRecord5(value) {
|
|
27645
27864
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27646
27865
|
}
|
|
27647
27866
|
function invalidStream(message, cause) {
|
|
@@ -27695,6 +27914,12 @@ var DefaultAssistantClient = class {
|
|
|
27695
27914
|
await this.#singleFlight(async (signal) => {
|
|
27696
27915
|
if (this.#session) return;
|
|
27697
27916
|
const session = await this.#createSession(signal);
|
|
27917
|
+
if (this.#source.kind !== "public" && session.endpoints.transcript) {
|
|
27918
|
+
try {
|
|
27919
|
+
await this.#replayTranscript(session, signal);
|
|
27920
|
+
} catch {
|
|
27921
|
+
}
|
|
27922
|
+
}
|
|
27698
27923
|
if (session.resume) {
|
|
27699
27924
|
try {
|
|
27700
27925
|
await this.#runChatOperation(signal, () => this.#resumeTurn(session, signal));
|
|
@@ -27703,6 +27928,26 @@ var DefaultAssistantClient = class {
|
|
|
27703
27928
|
}
|
|
27704
27929
|
});
|
|
27705
27930
|
}
|
|
27931
|
+
/** Fetch and re-emit the bounded visible transcript through the standard event path. */
|
|
27932
|
+
async #replayTranscript(session, signal) {
|
|
27933
|
+
const endpoint = session.endpoints.transcript;
|
|
27934
|
+
if (!endpoint) return;
|
|
27935
|
+
const response = await this.#request(
|
|
27936
|
+
endpoint,
|
|
27937
|
+
{
|
|
27938
|
+
method: "POST",
|
|
27939
|
+
headers: authorizedHeaders(session.token, "application/json"),
|
|
27940
|
+
body: "{}",
|
|
27941
|
+
signal
|
|
27942
|
+
},
|
|
27943
|
+
"turn_failed"
|
|
27944
|
+
);
|
|
27945
|
+
if (!response.ok) return;
|
|
27946
|
+
for (const event of transcriptReplayEvents(parseTranscriptEntries(await response.json()))) {
|
|
27947
|
+
this.#emit(event);
|
|
27948
|
+
if (event.event === "message_completed") await this.#chat.flush();
|
|
27949
|
+
}
|
|
27950
|
+
}
|
|
27706
27951
|
/** POST the one-shot resume trigger; a 409 means nothing was pending, which renders as silence. */
|
|
27707
27952
|
async #resumeTurn(session, signal) {
|
|
27708
27953
|
const response = await this.#request(
|
|
@@ -28134,10 +28379,10 @@ function authorizedHeaders(token, accept) {
|
|
|
28134
28379
|
};
|
|
28135
28380
|
}
|
|
28136
28381
|
function parseAppInteraction(value) {
|
|
28137
|
-
if (!
|
|
28382
|
+
if (!isRecord3(value) || !isRecord3(value.interaction)) return void 0;
|
|
28138
28383
|
const event = value.interaction.event;
|
|
28139
28384
|
const data = value.interaction.data;
|
|
28140
|
-
if (event !== "tool_proposed" && event !== "input_requested" || !
|
|
28385
|
+
if (event !== "tool_proposed" && event !== "input_requested" || !isRecord3(data)) {
|
|
28141
28386
|
return void 0;
|
|
28142
28387
|
}
|
|
28143
28388
|
const parsed = toAssistantClientEvent({ event, data });
|
|
@@ -31269,22 +31514,46 @@ function renderMarkdown(text3) {
|
|
|
31269
31514
|
// src/sign-in-card.ts
|
|
31270
31515
|
function createSignInCard(options) {
|
|
31271
31516
|
const card = document.createElement("div");
|
|
31272
|
-
card.className = "
|
|
31517
|
+
card.className = "tool-proposal sign-in";
|
|
31273
31518
|
card.dataset.tool = options.tool;
|
|
31274
31519
|
card.setAttribute("role", "status");
|
|
31275
|
-
const
|
|
31276
|
-
|
|
31520
|
+
const badge = document.createElement("span");
|
|
31521
|
+
badge.className = "sign-in-badge";
|
|
31522
|
+
badge.setAttribute("aria-hidden", "true");
|
|
31523
|
+
card.append(badge);
|
|
31524
|
+
const heading = document.createElement("h3");
|
|
31277
31525
|
heading.textContent = options.labels.heading;
|
|
31278
31526
|
card.append(heading);
|
|
31279
|
-
|
|
31280
|
-
|
|
31281
|
-
|
|
31282
|
-
|
|
31283
|
-
|
|
31284
|
-
|
|
31285
|
-
|
|
31286
|
-
|
|
31287
|
-
|
|
31527
|
+
if (options.labels.body) {
|
|
31528
|
+
const body = document.createElement("p");
|
|
31529
|
+
body.className = "proposal-description";
|
|
31530
|
+
body.textContent = options.labels.body;
|
|
31531
|
+
card.append(body);
|
|
31532
|
+
}
|
|
31533
|
+
const actions = document.createElement("div");
|
|
31534
|
+
actions.className = "proposal-actions";
|
|
31535
|
+
const buttons = [];
|
|
31536
|
+
const act = (intent) => {
|
|
31537
|
+
for (const button2 of buttons) button2.disabled = true;
|
|
31538
|
+
options.onAction(intent);
|
|
31539
|
+
};
|
|
31540
|
+
const signIn = document.createElement("button");
|
|
31541
|
+
signIn.type = "button";
|
|
31542
|
+
signIn.className = "sign-in-action";
|
|
31543
|
+
signIn.textContent = options.labels.action;
|
|
31544
|
+
signIn.addEventListener("click", () => act("sign-in"));
|
|
31545
|
+
buttons.push(signIn);
|
|
31546
|
+
actions.append(signIn);
|
|
31547
|
+
if (options.labels.signUpAction) {
|
|
31548
|
+
const signUp = document.createElement("button");
|
|
31549
|
+
signUp.type = "button";
|
|
31550
|
+
signUp.className = "sign-up-action";
|
|
31551
|
+
signUp.textContent = options.labels.signUpAction;
|
|
31552
|
+
signUp.addEventListener("click", () => act("sign-up"));
|
|
31553
|
+
buttons.push(signUp);
|
|
31554
|
+
actions.append(signUp);
|
|
31555
|
+
}
|
|
31556
|
+
card.append(actions);
|
|
31288
31557
|
return card;
|
|
31289
31558
|
}
|
|
31290
31559
|
|
|
@@ -31312,7 +31581,7 @@ var AssistantElementEventController = class {
|
|
|
31312
31581
|
if (event.event === "unrecognized") return;
|
|
31313
31582
|
const { event: name21, data } = event;
|
|
31314
31583
|
if (name21 === "session_started") {
|
|
31315
|
-
if (
|
|
31584
|
+
if (isRecord6(data.configuration)) {
|
|
31316
31585
|
this.#host.applyConfiguration(data.configuration);
|
|
31317
31586
|
}
|
|
31318
31587
|
this.#host.element.dispatchEvent(
|
|
@@ -31380,10 +31649,10 @@ var AssistantElementEventController = class {
|
|
|
31380
31649
|
this.#appendToolProposal(
|
|
31381
31650
|
String(data.id ?? ""),
|
|
31382
31651
|
String(data.tool ?? "action"),
|
|
31383
|
-
|
|
31652
|
+
isRecord6(data.arguments) ? data.arguments : void 0,
|
|
31384
31653
|
typeof data.title === "string" ? data.title : void 0,
|
|
31385
31654
|
"description" in data && typeof data.description === "string" ? data.description : void 0,
|
|
31386
|
-
"reviewSchema" in data &&
|
|
31655
|
+
"reviewSchema" in data && isRecord6(data.reviewSchema) ? data.reviewSchema : void 0
|
|
31387
31656
|
);
|
|
31388
31657
|
return;
|
|
31389
31658
|
}
|
|
@@ -31396,7 +31665,7 @@ var AssistantElementEventController = class {
|
|
|
31396
31665
|
);
|
|
31397
31666
|
return;
|
|
31398
31667
|
}
|
|
31399
|
-
if (name21 === "input_requested" &&
|
|
31668
|
+
if (name21 === "input_requested" && isRecord6(data.requestedSchema)) {
|
|
31400
31669
|
this.#appendInputRequest(
|
|
31401
31670
|
String(data.id ?? ""),
|
|
31402
31671
|
String(data.message ?? "More information is required"),
|
|
@@ -31490,17 +31759,20 @@ var AssistantElementEventController = class {
|
|
|
31490
31759
|
const messages = this.#host.messages();
|
|
31491
31760
|
if (!messages) return;
|
|
31492
31761
|
this.#proposalCards.get(id)?.remove();
|
|
31762
|
+
const labels = this.#host.labels();
|
|
31493
31763
|
const card = createSignInCard({
|
|
31494
31764
|
tool,
|
|
31495
31765
|
signInTicket,
|
|
31496
31766
|
expiresAt,
|
|
31497
31767
|
labels: {
|
|
31498
|
-
heading:
|
|
31499
|
-
|
|
31768
|
+
heading: labels.signInHeading,
|
|
31769
|
+
body: labels.signInBody,
|
|
31770
|
+
action: labels.signInAction,
|
|
31771
|
+
signUpAction: labels.signUpAction
|
|
31500
31772
|
},
|
|
31501
|
-
|
|
31773
|
+
onAction: (intent) => this.#host.element.dispatchEvent(
|
|
31502
31774
|
new CustomEvent("assistant-sign-in-requested", {
|
|
31503
|
-
detail: { id, tool, signInTicket, expiresAt },
|
|
31775
|
+
detail: { id, tool, signInTicket, expiresAt, intent },
|
|
31504
31776
|
bubbles: true,
|
|
31505
31777
|
composed: true
|
|
31506
31778
|
})
|
|
@@ -31564,7 +31836,7 @@ var AssistantElementEventController = class {
|
|
|
31564
31836
|
this.#host.revealLatest();
|
|
31565
31837
|
}
|
|
31566
31838
|
};
|
|
31567
|
-
function
|
|
31839
|
+
function isRecord6(value) {
|
|
31568
31840
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31569
31841
|
}
|
|
31570
31842
|
|
|
@@ -31896,8 +32168,10 @@ var ASSISTANT_ELEMENT_STYLES = `<style>
|
|
|
31896
32168
|
.proposal-details .proposal-arguments { margin-top: 4px; }
|
|
31897
32169
|
.proposal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: end; }
|
|
31898
32170
|
.tool-proposal button { min-height: 44px; padding: 9px 16px; border: 1px solid var(--ns-assistant-secondary-button-border, transparent); border-radius: var(--ns-assistant-button-radius, var(--ns-assistant-default-button-radius)); color: var(--ns-assistant-secondary-button-text, var(--ns-assistant-text, var(--ns-assistant-default-text))); background: var(--ns-assistant-secondary-button, var(--ns-assistant-elevated, var(--ns-assistant-default-elevated))); cursor: pointer; font-weight: 600; }
|
|
31899
|
-
.tool-proposal .proposal-accept { color: var(--ns-assistant-primary-button-text, var(--ns-assistant-accent-text, var(--ns-assistant-default-accent-text))); background: var(--ns-assistant-primary-button, var(--ns-assistant-accent, var(--ns-assistant-default-accent))); border-color: var(--ns-assistant-primary-button-border, transparent); }
|
|
32171
|
+
.tool-proposal .proposal-accept, .tool-proposal .sign-in-action { color: var(--ns-assistant-primary-button-text, var(--ns-assistant-accent-text, var(--ns-assistant-default-accent-text))); background: var(--ns-assistant-primary-button, var(--ns-assistant-accent, var(--ns-assistant-default-accent))); border-color: var(--ns-assistant-primary-button-border, transparent); }
|
|
31900
32172
|
.tool-proposal button:disabled { opacity: .55; cursor: not-allowed; }
|
|
32173
|
+
.sign-in .sign-in-badge { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 999px; color: var(--ns-assistant-accent, var(--ns-assistant-default-accent)); background: color-mix(in srgb, var(--ns-assistant-accent, var(--ns-assistant-default-accent)) 12%, transparent); }
|
|
32174
|
+
.sign-in .sign-in-badge::before { content: ''; width: 19px; height: 19px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 12a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9Zm0 2.2c-4.3 0-7.8 2.6-7.8 5.8v1h15.6v-1c0-3.2-3.5-5.8-7.8-5.8Z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 12a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9Zm0 2.2c-4.3 0-7.8 2.6-7.8 5.8v1h15.6v-1c0-3.2-3.5-5.8-7.8-5.8Z'/%3E%3C/svg%3E") center / contain no-repeat; }
|
|
31901
32175
|
.tool-proposal button { min-height: 45px; }
|
|
31902
32176
|
.tool-result { display: grid; gap: 10px; margin: 8px 0 16px; padding: 16px; border: 1px solid var(--ns-assistant-divider, var(--ns-assistant-default-divider)); border-radius: var(--ns-assistant-card-radius, 14px); background: var(--ns-assistant-assistant-message, var(--ns-assistant-elevated, var(--ns-assistant-default-elevated))); }
|
|
31903
32177
|
.tool-result > strong { color: var(--ns-assistant-success, var(--ns-assistant-default-success)); }
|