@noodleseed/assistant 1.8.0 → 1.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/README.md +33 -7
- package/dist/{appearance-DowzFJjh.d.cts → appearance-Cc-eqSbp.d.cts} +1 -1
- package/dist/{appearance-DowzFJjh.d.ts → appearance-Cc-eqSbp.d.ts} +1 -1
- package/dist/{chunk-JMBUJSFP.js → chunk-4B3XXGRP.js} +74 -13
- package/dist/chunk-4B3XXGRP.js.map +1 -0
- package/dist/{client-ERQCAH_0.d.ts → client-B803xZVn.d.ts} +2 -2
- package/dist/{client-BxoNZkWp.d.cts → client-CsmtpD1z.d.cts} +2 -2
- package/dist/client.d.cts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/index.cjs +68 -12
- 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 +1 -1
- package/dist/react/client.d.cts +2 -2
- package/dist/react/client.d.ts +2 -2
- package/dist/react.cjs +124 -19
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +22 -4
- package/dist/react.d.ts +22 -4
- package/dist/react.js +58 -9
- package/dist/react.js.map +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-JMBUJSFP.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as AssistantConfiguration } from './appearance-Cc-eqSbp.js';
|
|
2
2
|
import { ChatStatus, UIMessage } from 'ai';
|
|
3
3
|
|
|
4
4
|
type AssistantJsonValue = string | number | boolean | null | readonly AssistantJsonValue[] | {
|
|
@@ -226,4 +226,4 @@ declare class AssistantClientError extends Error {
|
|
|
226
226
|
}
|
|
227
227
|
declare function createAssistantClient<TPageContext extends AssistantPageContext = AssistantContext>(options: CreateAssistantClientOptions<TPageContext>): AssistantClient<TPageContext>;
|
|
228
228
|
|
|
229
|
-
export { type AssistantPageContext as A, type AssistantInteractionStatus as B, type CreateAssistantClientOptions as C, type AssistantJsonValue as D, type AssistantSessionResponse as E, type AssistantToolCompletedDetail as F, type AssistantToolCompletedEvent as G, type AssistantToolProposedDetail as H, type AssistantToolProposedEvent as I, type AssistantToolResultData as J, type AssistantUIDataTypes as K, type AssistantUIMessage as L, type AssistantUnrecognizedEvent as M, type AssistantViewData as N, createAssistantClient as O, type AssistantContext as a, type AssistantChatState as b, type AssistantClient as c, type
|
|
229
|
+
export { type AssistantPageContext as A, type AssistantInteractionStatus as B, type CreateAssistantClientOptions as C, type AssistantJsonValue as D, type AssistantSessionResponse as E, type AssistantToolCompletedDetail as F, type AssistantToolCompletedEvent as G, type AssistantToolProposedDetail as H, type AssistantToolProposedEvent as I, type AssistantToolResultData as J, type AssistantUIDataTypes as K, type AssistantUIMessage as L, type AssistantUnrecognizedEvent as M, type AssistantViewData as N, createAssistantClient as O, type AssistantContext as a, type AssistantChatState as b, type AssistantClient as c, type AssistantViewAvailableDetail as d, type AssistantModelContextUpdate as e, type AssistantClientEvent as f, type AssistantErrorDetail as g, type AssistantInteractionResponse as h, type AssistantEvent as i, type AssistantViewAvailableEvent as j, type AssistantChatError as k, type AssistantClientContext as l, AssistantClientError as m, type AssistantClientLifecycleEvent as n, type AssistantConfirmationData as o, type AssistantContentDetail as p, type AssistantContentEvent as q, type AssistantContextValue as r, type AssistantDoneEvent as s, type AssistantErrorEvent as t, type AssistantErrorEventDetail as u, type AssistantInputRequestData as v, type AssistantInputRequestedDetail as w, type AssistantInputRequestedEvent as x, type AssistantInteractionResolvedDetail as y, type AssistantInteractionResolvedEvent as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as AssistantConfiguration } from './appearance-Cc-eqSbp.cjs';
|
|
2
2
|
import { ChatStatus, UIMessage } from 'ai';
|
|
3
3
|
|
|
4
4
|
type AssistantJsonValue = string | number | boolean | null | readonly AssistantJsonValue[] | {
|
|
@@ -226,4 +226,4 @@ declare class AssistantClientError extends Error {
|
|
|
226
226
|
}
|
|
227
227
|
declare function createAssistantClient<TPageContext extends AssistantPageContext = AssistantContext>(options: CreateAssistantClientOptions<TPageContext>): AssistantClient<TPageContext>;
|
|
228
228
|
|
|
229
|
-
export { type AssistantPageContext as A, type AssistantInteractionStatus as B, type CreateAssistantClientOptions as C, type AssistantJsonValue as D, type AssistantSessionResponse as E, type AssistantToolCompletedDetail as F, type AssistantToolCompletedEvent as G, type AssistantToolProposedDetail as H, type AssistantToolProposedEvent as I, type AssistantToolResultData as J, type AssistantUIDataTypes as K, type AssistantUIMessage as L, type AssistantUnrecognizedEvent as M, type AssistantViewData as N, createAssistantClient as O, type AssistantContext as a, type AssistantChatState as b, type AssistantClient as c, type
|
|
229
|
+
export { type AssistantPageContext as A, type AssistantInteractionStatus as B, type CreateAssistantClientOptions as C, type AssistantJsonValue as D, type AssistantSessionResponse as E, type AssistantToolCompletedDetail as F, type AssistantToolCompletedEvent as G, type AssistantToolProposedDetail as H, type AssistantToolProposedEvent as I, type AssistantToolResultData as J, type AssistantUIDataTypes as K, type AssistantUIMessage as L, type AssistantUnrecognizedEvent as M, type AssistantViewData as N, createAssistantClient as O, type AssistantContext as a, type AssistantChatState as b, type AssistantClient as c, type AssistantViewAvailableDetail as d, type AssistantModelContextUpdate as e, type AssistantClientEvent as f, type AssistantErrorDetail as g, type AssistantInteractionResponse as h, type AssistantEvent as i, type AssistantViewAvailableEvent as j, type AssistantChatError as k, type AssistantClientContext as l, AssistantClientError as m, type AssistantClientLifecycleEvent as n, type AssistantConfirmationData as o, type AssistantContentDetail as p, type AssistantContentEvent as q, type AssistantContextValue as r, type AssistantDoneEvent as s, type AssistantErrorEvent as t, type AssistantErrorEventDetail as u, type AssistantInputRequestData as v, type AssistantInputRequestedDetail as w, type AssistantInputRequestedEvent as x, type AssistantInteractionResolvedDetail as y, type AssistantInteractionResolvedEvent as z };
|
package/dist/client.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import './appearance-
|
|
2
|
-
export { k as AssistantChatError, b as AssistantChatState, c as AssistantClient, l as AssistantClientContext, m as AssistantClientError,
|
|
1
|
+
import './appearance-Cc-eqSbp.cjs';
|
|
2
|
+
export { k as AssistantChatError, b as AssistantChatState, c as AssistantClient, l as AssistantClientContext, m as AssistantClientError, f as AssistantClientEvent, n as AssistantClientLifecycleEvent, o as AssistantConfirmationData, p as AssistantContentDetail, q as AssistantContentEvent, a as AssistantContext, r as AssistantContextValue, s as AssistantDoneEvent, t as AssistantErrorEvent, u as AssistantErrorEventDetail, v as AssistantInputRequestData, w as AssistantInputRequestedDetail, x as AssistantInputRequestedEvent, y as AssistantInteractionResolvedDetail, z as AssistantInteractionResolvedEvent, h as AssistantInteractionResponse, B as AssistantInteractionStatus, D as AssistantJsonValue, e as AssistantModelContextUpdate, A as AssistantPageContext, E as AssistantSessionResponse, F as AssistantToolCompletedDetail, G as AssistantToolCompletedEvent, H as AssistantToolProposedDetail, I as AssistantToolProposedEvent, J as AssistantToolResultData, K as AssistantUIDataTypes, L as AssistantUIMessage, M as AssistantUnrecognizedEvent, d as AssistantViewAvailableDetail, j as AssistantViewAvailableEvent, N as AssistantViewData, C as CreateAssistantClientOptions, O as createAssistantClient } from './client-CsmtpD1z.cjs';
|
|
3
3
|
import 'ai';
|
package/dist/client.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import './appearance-
|
|
2
|
-
export { k as AssistantChatError, b as AssistantChatState, c as AssistantClient, l as AssistantClientContext, m as AssistantClientError,
|
|
1
|
+
import './appearance-Cc-eqSbp.js';
|
|
2
|
+
export { k as AssistantChatError, b as AssistantChatState, c as AssistantClient, l as AssistantClientContext, m as AssistantClientError, f as AssistantClientEvent, n as AssistantClientLifecycleEvent, o as AssistantConfirmationData, p as AssistantContentDetail, q as AssistantContentEvent, a as AssistantContext, r as AssistantContextValue, s as AssistantDoneEvent, t as AssistantErrorEvent, u as AssistantErrorEventDetail, v as AssistantInputRequestData, w as AssistantInputRequestedDetail, x as AssistantInputRequestedEvent, y as AssistantInteractionResolvedDetail, z as AssistantInteractionResolvedEvent, h as AssistantInteractionResponse, B as AssistantInteractionStatus, D as AssistantJsonValue, e as AssistantModelContextUpdate, A as AssistantPageContext, E as AssistantSessionResponse, F as AssistantToolCompletedDetail, G as AssistantToolCompletedEvent, H as AssistantToolProposedDetail, I as AssistantToolProposedEvent, J as AssistantToolResultData, K as AssistantUIDataTypes, L as AssistantUIMessage, M as AssistantUnrecognizedEvent, d as AssistantViewAvailableDetail, j as AssistantViewAvailableEvent, N as AssistantViewData, C as CreateAssistantClientOptions, O as createAssistantClient } from './client-B803xZVn.js';
|
|
3
3
|
import 'ai';
|
package/dist/index.cjs
CHANGED
|
@@ -22121,6 +22121,8 @@ function createAssistantAppHostContext(theme) {
|
|
|
22121
22121
|
};
|
|
22122
22122
|
}
|
|
22123
22123
|
var APP_RENDER_TIMEOUT_MS = 1e4;
|
|
22124
|
+
var APP_TEARDOWN_TIMEOUT_MS = 1e3;
|
|
22125
|
+
var mountedApps = /* @__PURE__ */ new WeakMap();
|
|
22124
22126
|
function resolveSandboxUrl(value) {
|
|
22125
22127
|
if (!value) return void 0;
|
|
22126
22128
|
try {
|
|
@@ -22149,7 +22151,11 @@ function mountAssistantApp(detail, actions, options = {}) {
|
|
|
22149
22151
|
if (sandboxUrl) frame.src = sandboxUrl;
|
|
22150
22152
|
else frame.srcdoc = PROXY_DOCUMENT;
|
|
22151
22153
|
card.append(frame);
|
|
22154
|
+
let mountedBridge;
|
|
22155
|
+
let mountedTransport;
|
|
22156
|
+
let destroyed = false;
|
|
22152
22157
|
let initialized = false;
|
|
22158
|
+
let destroyPromise;
|
|
22153
22159
|
const renderTimer = setTimeout(() => {
|
|
22154
22160
|
if (initialized || !frame.isConnected) return;
|
|
22155
22161
|
const note = document.createElement("div");
|
|
@@ -22161,6 +22167,7 @@ function mountAssistantApp(detail, actions, options = {}) {
|
|
|
22161
22167
|
frame.addEventListener(
|
|
22162
22168
|
"load",
|
|
22163
22169
|
() => {
|
|
22170
|
+
if (destroyed) return;
|
|
22164
22171
|
const target = frame.contentWindow;
|
|
22165
22172
|
if (!target) return;
|
|
22166
22173
|
const bridge = new DX(
|
|
@@ -22177,19 +22184,24 @@ function mountAssistantApp(detail, actions, options = {}) {
|
|
|
22177
22184
|
hostContext: createAssistantAppHostContext(actions.theme)
|
|
22178
22185
|
}
|
|
22179
22186
|
);
|
|
22187
|
+
mountedBridge = bridge;
|
|
22180
22188
|
bridge.onsandboxready = () => {
|
|
22189
|
+
if (destroyed) return;
|
|
22190
|
+
const current = options.getDetail?.() ?? detail;
|
|
22181
22191
|
void bridge.sendSandboxResourceReady({
|
|
22182
|
-
html:
|
|
22192
|
+
html: current.html,
|
|
22183
22193
|
sandbox: "allow-scripts allow-forms",
|
|
22184
|
-
...
|
|
22194
|
+
...current.resourceMeta ?? {}
|
|
22185
22195
|
});
|
|
22186
22196
|
};
|
|
22187
22197
|
bridge.onsizechange = ({ height }) => {
|
|
22198
|
+
if (destroyed) return;
|
|
22188
22199
|
if (typeof height === "number" && Number.isFinite(height)) {
|
|
22189
22200
|
frame.style.height = `${Math.min(1200, Math.max(120, Math.ceil(height)))}px`;
|
|
22190
22201
|
}
|
|
22191
22202
|
};
|
|
22192
22203
|
bridge.onmessage = async ({ content }) => {
|
|
22204
|
+
if (destroyed) return {};
|
|
22193
22205
|
const text3 = content.flatMap(
|
|
22194
22206
|
(part) => part.type === "text" && typeof part.text === "string" ? [part.text] : []
|
|
22195
22207
|
).join("\n").trim();
|
|
@@ -22197,13 +22209,16 @@ function mountAssistantApp(detail, actions, options = {}) {
|
|
|
22197
22209
|
return {};
|
|
22198
22210
|
};
|
|
22199
22211
|
bridge.onupdatemodelcontext = async (update) => {
|
|
22212
|
+
if (destroyed) return {};
|
|
22200
22213
|
actions.updateModelContext(update);
|
|
22201
22214
|
return {};
|
|
22202
22215
|
};
|
|
22203
22216
|
bridge.onopenlink = async ({ url: url2 }) => {
|
|
22217
|
+
if (destroyed) return { isError: true };
|
|
22218
|
+
const current = options.getDetail?.() ?? detail;
|
|
22204
22219
|
const allowed = isAllowedAppLink(
|
|
22205
22220
|
url2,
|
|
22206
|
-
|
|
22221
|
+
current.allowedOpenDomains ?? [],
|
|
22207
22222
|
globalThis.location?.href ?? "https://invalid.example"
|
|
22208
22223
|
);
|
|
22209
22224
|
if (!allowed) return { isError: true };
|
|
@@ -22212,28 +22227,69 @@ function mountAssistantApp(detail, actions, options = {}) {
|
|
|
22212
22227
|
};
|
|
22213
22228
|
bridge.onrequestdisplaymode = async ({ mode }) => {
|
|
22214
22229
|
const accepted = mode === "fullscreen" ? "fullscreen" : "inline";
|
|
22230
|
+
if (destroyed) return { mode: accepted };
|
|
22215
22231
|
card.toggleAttribute("data-fullscreen", accepted === "fullscreen");
|
|
22216
22232
|
return { mode: accepted };
|
|
22217
22233
|
};
|
|
22218
|
-
bridge.oncalltool = async (params) =>
|
|
22219
|
-
|
|
22220
|
-
|
|
22234
|
+
bridge.oncalltool = async (params) => {
|
|
22235
|
+
if (destroyed) {
|
|
22236
|
+
return {
|
|
22237
|
+
content: [{ type: "text", text: "App view is closing." }],
|
|
22238
|
+
isError: true
|
|
22239
|
+
};
|
|
22240
|
+
}
|
|
22241
|
+
return await actions.client.requestApp("tools/call", params);
|
|
22242
|
+
};
|
|
22243
|
+
bridge.onlistresources = async (params) => {
|
|
22244
|
+
if (destroyed) {
|
|
22245
|
+
return { resources: [] };
|
|
22246
|
+
}
|
|
22247
|
+
return await actions.client.requestApp("resources/list", params ?? {});
|
|
22248
|
+
};
|
|
22249
|
+
bridge.onreadresource = async (params) => {
|
|
22250
|
+
if (destroyed) {
|
|
22251
|
+
return { contents: [] };
|
|
22252
|
+
}
|
|
22253
|
+
return await actions.client.requestApp("resources/read", params);
|
|
22254
|
+
};
|
|
22221
22255
|
bridge.oninitialized = () => {
|
|
22256
|
+
if (destroyed) return;
|
|
22222
22257
|
initialized = true;
|
|
22223
22258
|
clearTimeout(renderTimer);
|
|
22224
|
-
|
|
22259
|
+
const current = options.getDetail?.() ?? detail;
|
|
22260
|
+
void bridge.sendToolInput({ arguments: current.arguments ?? {} });
|
|
22225
22261
|
void bridge.sendToolResult({
|
|
22226
|
-
content: [{ type: "text", text: JSON.stringify(
|
|
22227
|
-
...typeof
|
|
22262
|
+
content: [{ type: "text", text: JSON.stringify(current.result) }],
|
|
22263
|
+
...typeof current.result === "object" && current.result !== null && !Array.isArray(current.result) ? { structuredContent: current.result } : {}
|
|
22228
22264
|
});
|
|
22229
22265
|
};
|
|
22230
|
-
|
|
22231
|
-
|
|
22232
|
-
|
|
22266
|
+
const transport = new E(target, target);
|
|
22267
|
+
mountedTransport = transport;
|
|
22268
|
+
void bridge.connect(transport).catch(() => {
|
|
22269
|
+
void destroy();
|
|
22233
22270
|
});
|
|
22234
22271
|
},
|
|
22235
22272
|
{ once: true }
|
|
22236
22273
|
);
|
|
22274
|
+
const destroy = () => {
|
|
22275
|
+
if (destroyPromise) return destroyPromise;
|
|
22276
|
+
destroyed = true;
|
|
22277
|
+
clearTimeout(renderTimer);
|
|
22278
|
+
destroyPromise = (async () => {
|
|
22279
|
+
try {
|
|
22280
|
+
if (initialized) {
|
|
22281
|
+
await mountedBridge?.teardownResource({}, { timeout: APP_TEARDOWN_TIMEOUT_MS });
|
|
22282
|
+
}
|
|
22283
|
+
} catch {
|
|
22284
|
+
}
|
|
22285
|
+
await mountedTransport?.close().catch(() => {
|
|
22286
|
+
});
|
|
22287
|
+
card.remove();
|
|
22288
|
+
mountedApps.delete(card);
|
|
22289
|
+
})();
|
|
22290
|
+
return destroyPromise;
|
|
22291
|
+
};
|
|
22292
|
+
mountedApps.set(card, { destroy });
|
|
22237
22293
|
return card;
|
|
22238
22294
|
}
|
|
22239
22295
|
|