@noodleseed/assistant 1.1.1 → 1.3.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 +218 -19
- package/dist/{appearance-KDbtkt2G.d.cts → appearance-BLO7kFYB.d.cts} +39 -0
- package/dist/{appearance-KDbtkt2G.d.ts → appearance-BLO7kFYB.d.ts} +39 -0
- package/dist/chunk-N6TFOYOX.js +642 -0
- package/dist/chunk-N6TFOYOX.js.map +1 -0
- package/dist/chunk-QMDSNLTA.js +4459 -0
- package/dist/chunk-QMDSNLTA.js.map +1 -0
- package/dist/client-Bm990MFE.d.cts +166 -0
- package/dist/client-Dd7_LZLY.d.ts +166 -0
- package/dist/client.cjs +668 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +2 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.js +9 -0
- package/dist/client.js.map +1 -0
- package/dist/index.cjs +4765 -382
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -12
- package/dist/index.d.ts +14 -12
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +4777 -388
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +3 -2
- package/dist/react.d.ts +3 -2
- package/dist/react.js +11 -4
- package/dist/react.js.map +1 -1
- package/dist/server.cjs +2 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +7 -1
- package/dist/server.d.ts +7 -1
- package/dist/server.js +2 -1
- package/dist/server.js.map +1 -1
- package/package.json +14 -1
- package/dist/chunk-IM7SAHNE.js +0 -706
- package/dist/chunk-IM7SAHNE.js.map +0 -1
package/dist/react.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { A as AssistantThemeMode } from './appearance-
|
|
3
|
-
import {
|
|
2
|
+
import { A as AssistantThemeMode } from './appearance-BLO7kFYB.cjs';
|
|
3
|
+
import { NoodleAssistantElement } from './index.cjs';
|
|
4
|
+
import { A as AssistantErrorDetail } from './client-Bm990MFE.cjs';
|
|
4
5
|
|
|
5
6
|
interface NoodleAssistantProps {
|
|
6
7
|
readonly sessionEndpoint: string;
|
package/dist/react.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { A as AssistantThemeMode } from './appearance-
|
|
3
|
-
import {
|
|
2
|
+
import { A as AssistantThemeMode } from './appearance-BLO7kFYB.js';
|
|
3
|
+
import { NoodleAssistantElement } from './index.js';
|
|
4
|
+
import { A as AssistantErrorDetail } from './client-Dd7_LZLY.js';
|
|
4
5
|
|
|
5
6
|
interface NoodleAssistantProps {
|
|
6
7
|
readonly sessionEndpoint: string;
|
package/dist/react.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
registerNoodleAssistant
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QMDSNLTA.js";
|
|
4
|
+
import "./chunk-N6TFOYOX.js";
|
|
4
5
|
|
|
5
6
|
// src/react.ts
|
|
6
7
|
import {
|
|
@@ -13,18 +14,24 @@ import {
|
|
|
13
14
|
var NoodleAssistant = forwardRef(
|
|
14
15
|
function NoodleAssistant2(props, forwardedRef) {
|
|
15
16
|
const ref = useRef(null);
|
|
17
|
+
const readyNotified = useRef(false);
|
|
16
18
|
useImperativeHandle(forwardedRef, () => ref.current, []);
|
|
17
19
|
useEffect(() => {
|
|
18
|
-
registerNoodleAssistant();
|
|
19
20
|
const element = ref.current;
|
|
20
21
|
if (!element) return;
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
const ready = () => {
|
|
23
|
+
if (readyNotified.current) return;
|
|
24
|
+
readyNotified.current = true;
|
|
25
|
+
props.onReady?.();
|
|
26
|
+
};
|
|
23
27
|
const error = (event) => props.onError?.(event.detail);
|
|
24
28
|
const expired = () => props.onSessionExpired?.();
|
|
25
29
|
element.addEventListener("assistant-ready", ready);
|
|
26
30
|
element.addEventListener("assistant-error", error);
|
|
27
31
|
element.addEventListener("assistant-session-expired", expired);
|
|
32
|
+
registerNoodleAssistant();
|
|
33
|
+
element.sessionEndpoint = props.sessionEndpoint;
|
|
34
|
+
if (element.shadowRoot) ready();
|
|
28
35
|
return () => {
|
|
29
36
|
element.removeEventListener("assistant-ready", ready);
|
|
30
37
|
element.removeEventListener("assistant-error", error);
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react.ts"],"sourcesContent":["import {\n createElement,\n forwardRef,\n type ReactElement,\n useEffect,\n useImperativeHandle,\n useRef,\n} from 'react';\nimport type { AssistantThemeMode } from './appearance.js';\nimport { type NoodleAssistantElement, registerNoodleAssistant } from './element.js';\nimport type { AssistantErrorDetail } from './transport.js';\n\nexport interface NoodleAssistantProps {\n readonly sessionEndpoint: string;\n readonly theme?: AssistantThemeMode;\n readonly open?: boolean;\n readonly className?: string;\n readonly onReady?: () => void;\n readonly onError?: (error: AssistantErrorDetail) => void;\n readonly onSessionExpired?: () => void;\n}\n\nexport const NoodleAssistant = forwardRef<NoodleAssistantElement, NoodleAssistantProps>(\n function NoodleAssistant(props, forwardedRef): ReactElement {\n const ref = useRef<NoodleAssistantElement>(null);\n useImperativeHandle(forwardedRef, () => ref.current as NoodleAssistantElement, []);\n useEffect(() => {\n
|
|
1
|
+
{"version":3,"sources":["../src/react.ts"],"sourcesContent":["import {\n createElement,\n forwardRef,\n type ReactElement,\n useEffect,\n useImperativeHandle,\n useRef,\n} from 'react';\nimport type { AssistantThemeMode } from './appearance.js';\nimport { type NoodleAssistantElement, registerNoodleAssistant } from './element.js';\nimport type { AssistantErrorDetail } from './transport.js';\n\nexport interface NoodleAssistantProps {\n readonly sessionEndpoint: string;\n readonly theme?: AssistantThemeMode;\n readonly open?: boolean;\n readonly className?: string;\n readonly onReady?: () => void;\n readonly onError?: (error: AssistantErrorDetail) => void;\n readonly onSessionExpired?: () => void;\n}\n\nexport const NoodleAssistant = forwardRef<NoodleAssistantElement, NoodleAssistantProps>(\n function NoodleAssistant(props, forwardedRef): ReactElement {\n const ref = useRef<NoodleAssistantElement>(null);\n const readyNotified = useRef(false);\n useImperativeHandle(forwardedRef, () => ref.current as NoodleAssistantElement, []);\n useEffect(() => {\n const element = ref.current;\n if (!element) return;\n const ready = () => {\n if (readyNotified.current) return;\n readyNotified.current = true;\n props.onReady?.();\n };\n const error = (event: Event) =>\n props.onError?.((event as CustomEvent<AssistantErrorDetail>).detail);\n const expired = () => props.onSessionExpired?.();\n element.addEventListener('assistant-ready', ready);\n element.addEventListener('assistant-error', error);\n element.addEventListener('assistant-session-expired', expired);\n registerNoodleAssistant();\n element.sessionEndpoint = props.sessionEndpoint;\n // The canonical entry may have registered and upgraded the element before this effect ran.\n // Readiness is sticky once the shadow root exists, so late React listeners still fire once.\n if (element.shadowRoot) ready();\n return () => {\n element.removeEventListener('assistant-ready', ready);\n element.removeEventListener('assistant-error', error);\n element.removeEventListener('assistant-session-expired', expired);\n };\n }, [props.onError, props.onReady, props.onSessionExpired, props.sessionEndpoint]);\n return createElement('noodle-assistant', {\n ref,\n class: props.className,\n 'session-endpoint': props.sessionEndpoint,\n ...(props.theme ? { theme: props.theme } : {}),\n ...(props.open ? { open: '' } : {}),\n });\n },\n);\n"],"mappings":";;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAeA,IAAM,kBAAkB;AAAA,EAC7B,SAASA,iBAAgB,OAAO,cAA4B;AAC1D,UAAM,MAAM,OAA+B,IAAI;AAC/C,UAAM,gBAAgB,OAAO,KAAK;AAClC,wBAAoB,cAAc,MAAM,IAAI,SAAmC,CAAC,CAAC;AACjF,cAAU,MAAM;AACd,YAAM,UAAU,IAAI;AACpB,UAAI,CAAC,QAAS;AACd,YAAM,QAAQ,MAAM;AAClB,YAAI,cAAc,QAAS;AAC3B,sBAAc,UAAU;AACxB,cAAM,UAAU;AAAA,MAClB;AACA,YAAM,QAAQ,CAAC,UACb,MAAM,UAAW,MAA4C,MAAM;AACrE,YAAM,UAAU,MAAM,MAAM,mBAAmB;AAC/C,cAAQ,iBAAiB,mBAAmB,KAAK;AACjD,cAAQ,iBAAiB,mBAAmB,KAAK;AACjD,cAAQ,iBAAiB,6BAA6B,OAAO;AAC7D,8BAAwB;AACxB,cAAQ,kBAAkB,MAAM;AAGhC,UAAI,QAAQ,WAAY,OAAM;AAC9B,aAAO,MAAM;AACX,gBAAQ,oBAAoB,mBAAmB,KAAK;AACpD,gBAAQ,oBAAoB,mBAAmB,KAAK;AACpD,gBAAQ,oBAAoB,6BAA6B,OAAO;AAAA,MAClE;AAAA,IACF,GAAG,CAAC,MAAM,SAAS,MAAM,SAAS,MAAM,kBAAkB,MAAM,eAAe,CAAC;AAChF,WAAO,cAAc,oBAAoB;AAAA,MACvC;AAAA,MACA,OAAO,MAAM;AAAA,MACb,oBAAoB,MAAM;AAAA,MAC1B,GAAI,MAAM,QAAQ,EAAE,OAAO,MAAM,MAAM,IAAI,CAAC;AAAA,MAC5C,GAAI,MAAM,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;AAAA,IACnC,CAAC;AAAA,EACH;AACF;","names":["NoodleAssistant"]}
|
package/dist/server.cjs
CHANGED
|
@@ -40,7 +40,8 @@ async function createAssistantSession(input, dependencies = {}) {
|
|
|
40
40
|
origin: input.origin,
|
|
41
41
|
user: input.user,
|
|
42
42
|
...input.claims ? { claims: input.claims } : {},
|
|
43
|
-
...input.context ? { context: input.context } : {}
|
|
43
|
+
...input.context ? { context: input.context } : {},
|
|
44
|
+
...input.preferences ? { preferences: input.preferences } : {}
|
|
44
45
|
})
|
|
45
46
|
});
|
|
46
47
|
if (!response.ok) throw new Error(`Assistant session exchange failed (${response.status})`);
|
package/dist/server.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server.ts"],"sourcesContent":["import type { AssistantConfiguration } from './appearance.js';\n\nexport interface CreateAssistantSessionInput {\n readonly serviceUrl: string;\n readonly clientId: string;\n readonly clientSecret: string;\n /** Browser origin to bind into the short-lived assistant session. */\n readonly origin: string;\n readonly user: {\n readonly id: string;\n readonly email?: string;\n readonly name?: string;\n readonly tenant?: string;\n readonly roles?: readonly string[];\n };\n readonly context?: Readonly<Record<string, string | number | boolean | null>>;\n /**\n * Verified session claims from your authenticated backend. Only claims the server declares in\n * `embeddedAssistant({ sessionClaims })` reach tools (`\\${user.claims.<key>}`) and, when marked\n * `exposeToModel`, the assistant's identity context. Flat scalars only.\n */\n readonly claims?: Readonly<Record<string, string | number | boolean | null>>;\n}\n\nexport interface AssistantSession {\n readonly token: string;\n readonly expiresAt: string;\n readonly endpoints: {\n readonly turns: string;\n readonly toolConfirmations: string;\n };\n readonly configuration?: AssistantConfiguration;\n}\n\nexport async function createAssistantSession(\n input: CreateAssistantSessionInput,\n dependencies: { readonly fetch?: typeof fetch } = {},\n): Promise<AssistantSession> {\n const request = dependencies.fetch ?? fetch;\n const serviceUrl = input.serviceUrl.replace(/\\/$/, '');\n const credentials = Buffer.from(`${input.clientId}:${input.clientSecret}`, 'utf8').toString(\n 'base64',\n );\n const response = await request(`${serviceUrl}/v1/assistant/sessions`, {\n method: 'POST',\n headers: {\n Authorization: `Basic ${credentials}`,\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n origin: input.origin,\n user: input.user,\n ...(input.claims ? { claims: input.claims } : {}),\n ...(input.context ? { context: input.context } : {}),\n }),\n });\n if (!response.ok) throw new Error(`Assistant session exchange failed (${response.status})`);\n return (await response.json()) as AssistantSession;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../src/server.ts"],"sourcesContent":["import type { AssistantConfiguration } from './appearance.js';\n\nexport interface CreateAssistantSessionInput {\n readonly serviceUrl: string;\n readonly clientId: string;\n readonly clientSecret: string;\n /** Browser origin to bind into the short-lived assistant session. */\n readonly origin: string;\n readonly user: {\n readonly id: string;\n readonly email?: string;\n readonly name?: string;\n readonly tenant?: string;\n readonly roles?: readonly string[];\n };\n readonly context?: Readonly<Record<string, string | number | boolean | null>>;\n /** Backend-verified user preferences; these outrank untrusted browser presentation hints. */\n readonly preferences?: {\n readonly locale?: string;\n readonly timeZone?: string;\n };\n /**\n * Verified session claims from your authenticated backend. Only claims the server declares in\n * `embeddedAssistant({ sessionClaims })` reach tools (`\\${user.claims.<key>}`) and, when marked\n * `exposeToModel`, the assistant's identity context. Flat scalars only.\n */\n readonly claims?: Readonly<Record<string, string | number | boolean | null>>;\n}\n\nexport interface AssistantSession {\n readonly token: string;\n readonly expiresAt: string;\n readonly endpoints: {\n readonly turns: string;\n readonly toolConfirmations: string;\n readonly interactions?: string;\n };\n readonly configuration?: AssistantConfiguration;\n}\n\nexport async function createAssistantSession(\n input: CreateAssistantSessionInput,\n dependencies: { readonly fetch?: typeof fetch } = {},\n): Promise<AssistantSession> {\n const request = dependencies.fetch ?? fetch;\n const serviceUrl = input.serviceUrl.replace(/\\/$/, '');\n const credentials = Buffer.from(`${input.clientId}:${input.clientSecret}`, 'utf8').toString(\n 'base64',\n );\n const response = await request(`${serviceUrl}/v1/assistant/sessions`, {\n method: 'POST',\n headers: {\n Authorization: `Basic ${credentials}`,\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n origin: input.origin,\n user: input.user,\n ...(input.claims ? { claims: input.claims } : {}),\n ...(input.context ? { context: input.context } : {}),\n ...(input.preferences ? { preferences: input.preferences } : {}),\n }),\n });\n if (!response.ok) throw new Error(`Assistant session exchange failed (${response.status})`);\n return (await response.json()) as AssistantSession;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwCA,eAAsB,uBACpB,OACA,eAAkD,CAAC,GACxB;AAC3B,QAAM,UAAU,aAAa,SAAS;AACtC,QAAM,aAAa,MAAM,WAAW,QAAQ,OAAO,EAAE;AACrD,QAAM,cAAc,OAAO,KAAK,GAAG,MAAM,QAAQ,IAAI,MAAM,YAAY,IAAI,MAAM,EAAE;AAAA,IACjF;AAAA,EACF;AACA,QAAM,WAAW,MAAM,QAAQ,GAAG,UAAU,0BAA0B;AAAA,IACpE,QAAQ;AAAA,IACR,SAAS;AAAA,MACP,eAAe,SAAS,WAAW;AAAA,MACnC,QAAQ;AAAA,MACR,gBAAgB;AAAA,IAClB;AAAA,IACA,MAAM,KAAK,UAAU;AAAA,MACnB,QAAQ,MAAM;AAAA,MACd,MAAM,MAAM;AAAA,MACZ,GAAI,MAAM,SAAS,EAAE,QAAQ,MAAM,OAAO,IAAI,CAAC;AAAA,MAC/C,GAAI,MAAM,UAAU,EAAE,SAAS,MAAM,QAAQ,IAAI,CAAC;AAAA,MAClD,GAAI,MAAM,cAAc,EAAE,aAAa,MAAM,YAAY,IAAI,CAAC;AAAA,IAChE,CAAC;AAAA,EACH,CAAC;AACD,MAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,sCAAsC,SAAS,MAAM,GAAG;AAC1F,SAAQ,MAAM,SAAS,KAAK;AAC9B;","names":[]}
|
package/dist/server.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as AssistantConfiguration } from './appearance-
|
|
1
|
+
import { a as AssistantConfiguration } from './appearance-BLO7kFYB.cjs';
|
|
2
2
|
|
|
3
3
|
interface CreateAssistantSessionInput {
|
|
4
4
|
readonly serviceUrl: string;
|
|
@@ -14,6 +14,11 @@ interface CreateAssistantSessionInput {
|
|
|
14
14
|
readonly roles?: readonly string[];
|
|
15
15
|
};
|
|
16
16
|
readonly context?: Readonly<Record<string, string | number | boolean | null>>;
|
|
17
|
+
/** Backend-verified user preferences; these outrank untrusted browser presentation hints. */
|
|
18
|
+
readonly preferences?: {
|
|
19
|
+
readonly locale?: string;
|
|
20
|
+
readonly timeZone?: string;
|
|
21
|
+
};
|
|
17
22
|
/**
|
|
18
23
|
* Verified session claims from your authenticated backend. Only claims the server declares in
|
|
19
24
|
* `embeddedAssistant({ sessionClaims })` reach tools (`\${user.claims.<key>}`) and, when marked
|
|
@@ -27,6 +32,7 @@ interface AssistantSession {
|
|
|
27
32
|
readonly endpoints: {
|
|
28
33
|
readonly turns: string;
|
|
29
34
|
readonly toolConfirmations: string;
|
|
35
|
+
readonly interactions?: string;
|
|
30
36
|
};
|
|
31
37
|
readonly configuration?: AssistantConfiguration;
|
|
32
38
|
}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as AssistantConfiguration } from './appearance-
|
|
1
|
+
import { a as AssistantConfiguration } from './appearance-BLO7kFYB.js';
|
|
2
2
|
|
|
3
3
|
interface CreateAssistantSessionInput {
|
|
4
4
|
readonly serviceUrl: string;
|
|
@@ -14,6 +14,11 @@ interface CreateAssistantSessionInput {
|
|
|
14
14
|
readonly roles?: readonly string[];
|
|
15
15
|
};
|
|
16
16
|
readonly context?: Readonly<Record<string, string | number | boolean | null>>;
|
|
17
|
+
/** Backend-verified user preferences; these outrank untrusted browser presentation hints. */
|
|
18
|
+
readonly preferences?: {
|
|
19
|
+
readonly locale?: string;
|
|
20
|
+
readonly timeZone?: string;
|
|
21
|
+
};
|
|
17
22
|
/**
|
|
18
23
|
* Verified session claims from your authenticated backend. Only claims the server declares in
|
|
19
24
|
* `embeddedAssistant({ sessionClaims })` reach tools (`\${user.claims.<key>}`) and, when marked
|
|
@@ -27,6 +32,7 @@ interface AssistantSession {
|
|
|
27
32
|
readonly endpoints: {
|
|
28
33
|
readonly turns: string;
|
|
29
34
|
readonly toolConfirmations: string;
|
|
35
|
+
readonly interactions?: string;
|
|
30
36
|
};
|
|
31
37
|
readonly configuration?: AssistantConfiguration;
|
|
32
38
|
}
|
package/dist/server.js
CHANGED
|
@@ -16,7 +16,8 @@ async function createAssistantSession(input, dependencies = {}) {
|
|
|
16
16
|
origin: input.origin,
|
|
17
17
|
user: input.user,
|
|
18
18
|
...input.claims ? { claims: input.claims } : {},
|
|
19
|
-
...input.context ? { context: input.context } : {}
|
|
19
|
+
...input.context ? { context: input.context } : {},
|
|
20
|
+
...input.preferences ? { preferences: input.preferences } : {}
|
|
20
21
|
})
|
|
21
22
|
});
|
|
22
23
|
if (!response.ok) throw new Error(`Assistant session exchange failed (${response.status})`);
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server.ts"],"sourcesContent":["import type { AssistantConfiguration } from './appearance.js';\n\nexport interface CreateAssistantSessionInput {\n readonly serviceUrl: string;\n readonly clientId: string;\n readonly clientSecret: string;\n /** Browser origin to bind into the short-lived assistant session. */\n readonly origin: string;\n readonly user: {\n readonly id: string;\n readonly email?: string;\n readonly name?: string;\n readonly tenant?: string;\n readonly roles?: readonly string[];\n };\n readonly context?: Readonly<Record<string, string | number | boolean | null>>;\n /**\n * Verified session claims from your authenticated backend. Only claims the server declares in\n * `embeddedAssistant({ sessionClaims })` reach tools (`\\${user.claims.<key>}`) and, when marked\n * `exposeToModel`, the assistant's identity context. Flat scalars only.\n */\n readonly claims?: Readonly<Record<string, string | number | boolean | null>>;\n}\n\nexport interface AssistantSession {\n readonly token: string;\n readonly expiresAt: string;\n readonly endpoints: {\n readonly turns: string;\n readonly toolConfirmations: string;\n };\n readonly configuration?: AssistantConfiguration;\n}\n\nexport async function createAssistantSession(\n input: CreateAssistantSessionInput,\n dependencies: { readonly fetch?: typeof fetch } = {},\n): Promise<AssistantSession> {\n const request = dependencies.fetch ?? fetch;\n const serviceUrl = input.serviceUrl.replace(/\\/$/, '');\n const credentials = Buffer.from(`${input.clientId}:${input.clientSecret}`, 'utf8').toString(\n 'base64',\n );\n const response = await request(`${serviceUrl}/v1/assistant/sessions`, {\n method: 'POST',\n headers: {\n Authorization: `Basic ${credentials}`,\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n origin: input.origin,\n user: input.user,\n ...(input.claims ? { claims: input.claims } : {}),\n ...(input.context ? { context: input.context } : {}),\n }),\n });\n if (!response.ok) throw new Error(`Assistant session exchange failed (${response.status})`);\n return (await response.json()) as AssistantSession;\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../src/server.ts"],"sourcesContent":["import type { AssistantConfiguration } from './appearance.js';\n\nexport interface CreateAssistantSessionInput {\n readonly serviceUrl: string;\n readonly clientId: string;\n readonly clientSecret: string;\n /** Browser origin to bind into the short-lived assistant session. */\n readonly origin: string;\n readonly user: {\n readonly id: string;\n readonly email?: string;\n readonly name?: string;\n readonly tenant?: string;\n readonly roles?: readonly string[];\n };\n readonly context?: Readonly<Record<string, string | number | boolean | null>>;\n /** Backend-verified user preferences; these outrank untrusted browser presentation hints. */\n readonly preferences?: {\n readonly locale?: string;\n readonly timeZone?: string;\n };\n /**\n * Verified session claims from your authenticated backend. Only claims the server declares in\n * `embeddedAssistant({ sessionClaims })` reach tools (`\\${user.claims.<key>}`) and, when marked\n * `exposeToModel`, the assistant's identity context. Flat scalars only.\n */\n readonly claims?: Readonly<Record<string, string | number | boolean | null>>;\n}\n\nexport interface AssistantSession {\n readonly token: string;\n readonly expiresAt: string;\n readonly endpoints: {\n readonly turns: string;\n readonly toolConfirmations: string;\n readonly interactions?: string;\n };\n readonly configuration?: AssistantConfiguration;\n}\n\nexport async function createAssistantSession(\n input: CreateAssistantSessionInput,\n dependencies: { readonly fetch?: typeof fetch } = {},\n): Promise<AssistantSession> {\n const request = dependencies.fetch ?? fetch;\n const serviceUrl = input.serviceUrl.replace(/\\/$/, '');\n const credentials = Buffer.from(`${input.clientId}:${input.clientSecret}`, 'utf8').toString(\n 'base64',\n );\n const response = await request(`${serviceUrl}/v1/assistant/sessions`, {\n method: 'POST',\n headers: {\n Authorization: `Basic ${credentials}`,\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n origin: input.origin,\n user: input.user,\n ...(input.claims ? { claims: input.claims } : {}),\n ...(input.context ? { context: input.context } : {}),\n ...(input.preferences ? { preferences: input.preferences } : {}),\n }),\n });\n if (!response.ok) throw new Error(`Assistant session exchange failed (${response.status})`);\n return (await response.json()) as AssistantSession;\n}\n"],"mappings":";AAwCA,eAAsB,uBACpB,OACA,eAAkD,CAAC,GACxB;AAC3B,QAAM,UAAU,aAAa,SAAS;AACtC,QAAM,aAAa,MAAM,WAAW,QAAQ,OAAO,EAAE;AACrD,QAAM,cAAc,OAAO,KAAK,GAAG,MAAM,QAAQ,IAAI,MAAM,YAAY,IAAI,MAAM,EAAE;AAAA,IACjF;AAAA,EACF;AACA,QAAM,WAAW,MAAM,QAAQ,GAAG,UAAU,0BAA0B;AAAA,IACpE,QAAQ;AAAA,IACR,SAAS;AAAA,MACP,eAAe,SAAS,WAAW;AAAA,MACnC,QAAQ;AAAA,MACR,gBAAgB;AAAA,IAClB;AAAA,IACA,MAAM,KAAK,UAAU;AAAA,MACnB,QAAQ,MAAM;AAAA,MACd,MAAM,MAAM;AAAA,MACZ,GAAI,MAAM,SAAS,EAAE,QAAQ,MAAM,OAAO,IAAI,CAAC;AAAA,MAC/C,GAAI,MAAM,UAAU,EAAE,SAAS,MAAM,QAAQ,IAAI,CAAC;AAAA,MAClD,GAAI,MAAM,cAAc,EAAE,aAAa,MAAM,YAAY,IAAI,CAAC;AAAA,IAChE,CAAC;AAAA,EACH,CAAC;AACD,MAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,sCAAsC,SAAS,MAAM,GAAG;AAC1F,SAAQ,MAAM,SAAS,KAAK;AAC9B;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noodleseed/assistant",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Embed the Noodle Seed customer-branded assistant in your web app: Web Component, React wrapper, and backend session helper. Authoring and deploying the server is @noodleseed/one.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -21,6 +21,12 @@
|
|
|
21
21
|
"require": "./dist/index.cjs",
|
|
22
22
|
"default": "./dist/index.js"
|
|
23
23
|
},
|
|
24
|
+
"./client": {
|
|
25
|
+
"types": "./dist/client.d.ts",
|
|
26
|
+
"import": "./dist/client.js",
|
|
27
|
+
"require": "./dist/client.cjs",
|
|
28
|
+
"default": "./dist/client.js"
|
|
29
|
+
},
|
|
24
30
|
"./react": {
|
|
25
31
|
"types": "./dist/react.d.ts",
|
|
26
32
|
"import": "./dist/react.js",
|
|
@@ -68,9 +74,16 @@
|
|
|
68
74
|
"react": [
|
|
69
75
|
"./dist/react.d.ts"
|
|
70
76
|
],
|
|
77
|
+
"client": [
|
|
78
|
+
"./dist/client.d.ts"
|
|
79
|
+
],
|
|
71
80
|
"server": [
|
|
72
81
|
"./dist/server.d.ts"
|
|
73
82
|
]
|
|
74
83
|
}
|
|
84
|
+
},
|
|
85
|
+
"dependencies": {
|
|
86
|
+
"dompurify": "^3.4.11",
|
|
87
|
+
"marked": "^16.4.2"
|
|
75
88
|
}
|
|
76
89
|
}
|