@cadenya/widgets 1.2.0 → 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/api.md +8 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +4 -1
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/resources/session.d.ts +23 -0
- package/dist/resources/session.d.ts.map +1 -0
- package/dist/resources/session.js +22 -0
- package/dist/resources/session.js.map +1 -0
- package/dist/types.d.ts +68 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +4 -1
- package/src/index.ts +1 -0
- package/src/resources/session.ts +30 -0
- package/src/types.ts +75 -8
package/api.md
CHANGED
|
@@ -64,3 +64,11 @@ Send the next message
|
|
|
64
64
|
```ts
|
|
65
65
|
client.conversations.continue(id: string, params: ConversationContinueParams, options?: RequestOptions): APIPromise<WidgetConversation>
|
|
66
66
|
```
|
|
67
|
+
|
|
68
|
+
## session
|
|
69
|
+
|
|
70
|
+
Renew a widget session token
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
client.session.renewWidget(params: SessionRenewWidgetParams, options?: RequestOptions): APIPromise<WidgetSessionCredentials>
|
|
74
|
+
```
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Logger, LogLevel } from './core/http.js';
|
|
2
2
|
import { Config } from './resources/config.js';
|
|
3
3
|
import { Conversations } from './resources/conversations.js';
|
|
4
|
+
import { Session } from './resources/session.js';
|
|
4
5
|
export interface ClientOptions {
|
|
5
6
|
/** API key. Defaults to the CADENYAWIDGETS_API_KEY environment variable. */
|
|
6
7
|
apiKey?: string;
|
|
@@ -27,6 +28,7 @@ export interface ClientOptions {
|
|
|
27
28
|
export declare class CadenyaWidgets {
|
|
28
29
|
readonly config: Config;
|
|
29
30
|
readonly conversations: Conversations;
|
|
31
|
+
readonly session: Session;
|
|
30
32
|
private readonly _client;
|
|
31
33
|
constructor(options?: ClientOptions);
|
|
32
34
|
}
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,MAAM,WAAW,aAAa;IAC5B,4EAA4E;IAC5E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mFAAmF;IACnF,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,mCAAmC;IACnC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,qBAAa,cAAc;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAa;gBAEzB,OAAO,GAAE,aAAkB;CAwBxC"}
|
package/dist/client.js
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
import { HttpClient } from './core/http.js';
|
|
3
3
|
import { Config } from './resources/config.js';
|
|
4
4
|
import { Conversations } from './resources/conversations.js';
|
|
5
|
+
import { Session } from './resources/session.js';
|
|
5
6
|
export class CadenyaWidgets {
|
|
6
7
|
config;
|
|
7
8
|
conversations;
|
|
9
|
+
session;
|
|
8
10
|
_client;
|
|
9
11
|
constructor(options = {}) {
|
|
10
12
|
// Presence is not validity: empty strings from options or environment
|
|
@@ -18,7 +20,7 @@ export class CadenyaWidgets {
|
|
|
18
20
|
authHeader: () => ({ Authorization: `Bearer ${apiKey}` }),
|
|
19
21
|
maxRetries: options.maxRetries ?? 0,
|
|
20
22
|
timeout: options.timeout,
|
|
21
|
-
defaultHeaders: { ...nodeUserAgent('cadenyawidgets-typescript/1.
|
|
23
|
+
defaultHeaders: { ...nodeUserAgent('cadenyawidgets-typescript/1.3.0 (api 1.0)'), ...options.defaultHeaders },
|
|
22
24
|
fetch: options.fetch,
|
|
23
25
|
logger: options.logger,
|
|
24
26
|
logLevel: options.logLevel,
|
|
@@ -26,6 +28,7 @@ export class CadenyaWidgets {
|
|
|
26
28
|
});
|
|
27
29
|
this.config = new Config(this._client);
|
|
28
30
|
this.conversations = new Conversations(this._client);
|
|
31
|
+
this.session = new Session(this._client);
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
// Browser-authored User-Agent headers require CORS permission. Only Node-compatible
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mapp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AAC","sourcesContent":["// Generated by redwood. Do not edit by hand.\n\nimport { HttpClient } from './core/http.js';\nimport type { Logger, LogLevel } from './core/http.js';\nimport { Config } from './resources/config.js';\nimport { Conversations } from './resources/conversations.js';\nimport { Session } from './resources/session.js';\n\nexport interface ClientOptions {\n /** API key. Defaults to the CADENYAWIDGETS_API_KEY environment variable. */\n apiKey?: string;\n /** Override the API base URL. Defaults to . */\n baseURL?: string;\n /** Max automatic retries for retryable failures. Defaults to 0. */\n maxRetries?: number;\n /**\n * Deadline for ordinary (non-streaming) requests in milliseconds; override\n * per request with `options.timeout`. Streams bound only response-header\n * acquisition — body lifetime stays under the caller's AbortSignal.\n * Defaults to 60000; a non-finite or <= 0 value disables the deadline.\n */\n timeout?: number;\n /** Additional request headers. Browsers supply their own User-Agent by default. */\n defaultHeaders?: Record<string, string>;\n /** Custom fetch implementation. */\n fetch?: typeof fetch;\n /** Destination for SDK logs. Defaults to `console`. */\n logger?: Logger;\n /** 'debug' | 'warn' (default) | 'off'. Never logs headers or bodies. */\n logLevel?: LogLevel;\n}\n\nexport class CadenyaWidgets {\n readonly config: Config;\n readonly conversations: Conversations;\n readonly session: Session;\n\n private readonly _client: HttpClient;\n\n constructor(options: ClientOptions = {}) {\n // Presence is not validity: empty strings from options or environment\n // are configuration mistakes, not credentials.\n const apiKey = resolveOption('apiKey', options.apiKey, readEnv('CADENYAWIDGETS_API_KEY'));\n if (!apiKey) {\n throw new Error(\n \"Missing API key. Pass it with `new CadenyaWidgets({ apiKey })` or set the CADENYAWIDGETS_API_KEY environment variable.\",\n );\n }\n this._client = new HttpClient({\n baseURL: resolveOption('baseURL', options.baseURL, readEnv('CADENYAWIDGETS_BASE_URL')) ?? '',\n authHeader: () => ({ Authorization: `Bearer ${apiKey}` }),\n maxRetries: options.maxRetries ?? 0,\n timeout: options.timeout,\n defaultHeaders: { ...nodeUserAgent('cadenyawidgets-typescript/1.3.0 (api 1.0)'), ...options.defaultHeaders },\n fetch: options.fetch,\n logger: options.logger,\n logLevel: options.logLevel,\n defaults: { },\n });\n this.config = new Config(this._client);\n this.conversations = new Conversations(this._client);\n this.session = new Session(this._client);\n }\n}\n\n// Browser-authored User-Agent headers require CORS permission. Only Node-compatible\n// runtimes receive the SDK default; browsers and workers use their native header.\nfunction nodeUserAgent(value: string): Record<string, string> {\n const nodeVersion = (globalThis as { process?: { versions?: { node?: string } } })\n .process?.versions?.node;\n return nodeVersion ? { 'User-Agent': value } : {};\n}\n\nfunction readEnv(name: string): string | undefined {\n const env = (globalThis as { process?: { env?: Record<string, string | undefined> } })\n .process?.env;\n return env?.[name];\n}\n\n// Presence is not validity: an explicitly provided option must be usable —\n// a blank value is a configuration mistake and never silently falls back to\n// the environment or a default. Only an OMITTED option reads the env.\nfunction resolveOption(\n label: string,\n explicit: string | undefined,\n env: string | undefined,\n): string | undefined {\n if (explicit !== undefined) {\n const value = explicit.trim();\n if (!value) {\n throw new Error(\n `${label} must not be blank when provided explicitly; omit it to use the environment instead.`,\n );\n }\n return value;\n }\n return env?.trim() || undefined;\n}\n"]}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,cAAc,IAAI,OAAO,EAAE,MAAM,aAAa,CAAC;AACxE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACtI,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,cAAc,IAAI,OAAO,EAAE,MAAM,aAAa,CAAC;AACxE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACtI,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAE7C,OAAO,EAAE,cAAc,EAAE,cAAc,IAAI,OAAO,EAAE,MAAM,aAAa,CAAC;AAExE,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEtI,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC","sourcesContent":["// Generated by redwood. Do not edit by hand.\n\nexport { CadenyaWidgets, CadenyaWidgets as default } from './client.js';\nexport type { ClientOptions } from './client.js';\nexport { APIError, APIConnectionError, APIUserAbortError, APIRequestError, APIResponseError, APITimeoutError } from './core/error.js';\nexport type { RequestOptions } from './core/http.js';\nexport { APIPromise } from './core/http.js';\nexport { Page } from './core/pagination.js';\nexport { Stream } from './core/sse.js';\nexport type { ServerSentEvent } from './core/sse.js';\nexport * from './types.js';\nexport * from './resources/config.js';\nexport * from './resources/conversations.js';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAE7C,OAAO,EAAE,cAAc,EAAE,cAAc,IAAI,OAAO,EAAE,MAAM,aAAa,CAAC;AAExE,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEtI,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC","sourcesContent":["// Generated by redwood. Do not edit by hand.\n\nexport { CadenyaWidgets, CadenyaWidgets as default } from './client.js';\nexport type { ClientOptions } from './client.js';\nexport { APIError, APIConnectionError, APIUserAbortError, APIRequestError, APIResponseError, APITimeoutError } from './core/error.js';\nexport type { RequestOptions } from './core/http.js';\nexport { APIPromise } from './core/http.js';\nexport { Page } from './core/pagination.js';\nexport { Stream } from './core/sse.js';\nexport type { ServerSentEvent } from './core/sse.js';\nexport * from './types.js';\nexport * from './resources/config.js';\nexport * from './resources/conversations.js';\nexport * from './resources/session.js';\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { HttpClient, RequestOptions, APIPromise } from '../core/http.js';
|
|
2
|
+
import type { WidgetSessionCredentials } from '../types.js';
|
|
3
|
+
export interface SessionRenewWidgetParams {
|
|
4
|
+
/**
|
|
5
|
+
* Required workspace containing the authenticated session. Must match the
|
|
6
|
+
* session resolved from the bearer token; never authorizes access by itself.
|
|
7
|
+
*/
|
|
8
|
+
workspaceId: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class Session {
|
|
11
|
+
private readonly _client;
|
|
12
|
+
constructor(_client: HttpClient);
|
|
13
|
+
/**
|
|
14
|
+
* Renew a widget session token
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const widgetSessionCredentials = await client.session.renewWidget({ workspaceId: 'workspace_123' });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
renewWidget(params: SessionRenewWidgetParams, options?: RequestOptions): APIPromise<WidgetSessionCredentials>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/resources/session.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAe,MAAM,iBAAiB,CAAC;AACtF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,OAAO;IACN,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,UAAU;IAEhD;;;;;;;OAOG;IACH,WAAW,CAAC,MAAM,EAAE,wBAAwB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,wBAAwB,CAAC;CAK9G"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Generated by redwood. Do not edit by hand.
|
|
2
|
+
import { pathSegment } from '../core/http.js';
|
|
3
|
+
export class Session {
|
|
4
|
+
_client;
|
|
5
|
+
constructor(_client) {
|
|
6
|
+
this._client = _client;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Renew a widget session token
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const widgetSessionCredentials = await client.session.renewWidget({ workspaceId: 'workspace_123' });
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
renewWidget(params, options) {
|
|
17
|
+
return this._client.requestAPI(() => {
|
|
18
|
+
return { method: 'POST', path: `/v1/workspaces/${pathSegment('workspaceId', params.workspaceId)}/session:renew` };
|
|
19
|
+
}, options);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/resources/session.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAE7C,OAAO,EAA0C,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAWtF,MAAM,OAAO,OAAO;IACW;IAA7B,YAA6B,OAAmB;QAAnB,YAAO,GAAP,OAAO,CAAY;IAAG,CAAC;IAEpD;;;;;;;OAOG;IACH,WAAW,CAAC,MAAgC,EAAE,OAAwB;QACpE,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAA2B,GAAG,EAAE;YAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,WAAW,CAAC,aAAa,EAAE,MAAM,CAAC,WAAW,CAAC,gBAAgB,EAAE,CAAC;QACpH,CAAC,EAAE,OAAO,CAAC,CAAC;IACd,CAAC;CACF","sourcesContent":["// Generated by redwood. Do not edit by hand.\n\nimport { HttpClient, RequestOptions, APIPromise, pathSegment } from '../core/http.js';\nimport type { WidgetSessionCredentials } from '../types.js';\n\nexport interface SessionRenewWidgetParams {\n /**\n * Required workspace containing the authenticated session. Must match the\n * session resolved from the bearer token; never authorizes access by itself.\n */\n workspaceId: string;\n}\n\nexport class Session {\n constructor(private readonly _client: HttpClient) {}\n\n /**\n * Renew a widget session token\n * \n * @example\n * ```ts\n * const widgetSessionCredentials = await client.session.renewWidget({ workspaceId: 'workspace_123' });\n * ```\n */\n renewWidget(params: SessionRenewWidgetParams, options?: RequestOptions): APIPromise<WidgetSessionCredentials> {\n return this._client.requestAPI<WidgetSessionCredentials>(() => {\n return { method: 'POST', path: `/v1/workspaces/${pathSegment('workspaceId', params.workspaceId)}/session:renew` };\n }, options);\n }\n}\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -90,6 +90,21 @@ export interface Page {
|
|
|
90
90
|
*/
|
|
91
91
|
total?: number;
|
|
92
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* RenewWidgetSessionRequest has no session ID or credential in its body.
|
|
95
|
+
* The verified bearer token identifies the existing session. The server
|
|
96
|
+
* rechecks current session and authorization policy before issuing a token.
|
|
97
|
+
* Token validation allows 60 seconds of clock skew: now must be strictly
|
|
98
|
+
* before exp + 60 seconds. Hard session expiry has no tolerance. A token
|
|
99
|
+
* beyond this window cannot renew even while the session remains active.
|
|
100
|
+
*/
|
|
101
|
+
export interface RenewWidgetSessionRequest {
|
|
102
|
+
/**
|
|
103
|
+
* Required workspace containing the authenticated session. Must match the
|
|
104
|
+
* session resolved from the bearer token; never authorizes access by itself.
|
|
105
|
+
*/
|
|
106
|
+
workspaceId?: string;
|
|
107
|
+
}
|
|
93
108
|
/**
|
|
94
109
|
* Set tool call content request. Lets the embedding page supply the result
|
|
95
110
|
* of a bare tool call (one whose tool set has no execution adapter) — the
|
|
@@ -111,6 +126,7 @@ export interface SetToolCallContentRequest {
|
|
|
111
126
|
*/
|
|
112
127
|
content: string;
|
|
113
128
|
}
|
|
129
|
+
export type StatusDetails = WidgetSessionErrorInfo | GoogleProtobufAny;
|
|
114
130
|
/**
|
|
115
131
|
* The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
|
|
116
132
|
*/
|
|
@@ -126,7 +142,7 @@ export interface Status {
|
|
|
126
142
|
/**
|
|
127
143
|
* A list of messages that carry the error details. There is a common set of message types for APIs to use.
|
|
128
144
|
*/
|
|
129
|
-
details?: Array<
|
|
145
|
+
details?: Array<StatusDetails>;
|
|
130
146
|
}
|
|
131
147
|
/**
|
|
132
148
|
* Submit conversation feedback request — the visitor's rating of a
|
|
@@ -175,13 +191,10 @@ export interface WidgetConfig {
|
|
|
175
191
|
}
|
|
176
192
|
export type WidgetConversationState = 'STATE_UNSPECIFIED' | 'STATE_RESPONDING' | 'STATE_OPEN' | 'STATE_CLOSED';
|
|
177
193
|
/**
|
|
178
|
-
* WidgetConversation is one conversation between
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* itself. A conversation id from outside that scope is indistinguishable from
|
|
183
|
-
* one that does not exist. Tenant is a management-side grouping only — it is
|
|
184
|
-
* never a read scope on this surface.
|
|
194
|
+
* WidgetConversation is one conversation between a visitor and a widget's
|
|
195
|
+
* agent. The presenting session must have a tenant and subject. Sessions for
|
|
196
|
+
* that same identity share history on the same widget and agent, subject to
|
|
197
|
+
* the current session's permissions. Other conversation IDs return not found.
|
|
185
198
|
*/
|
|
186
199
|
export interface WidgetConversation {
|
|
187
200
|
id: string;
|
|
@@ -246,6 +259,37 @@ export interface WidgetObjectiveStateChangedEvent {
|
|
|
246
259
|
fromState: WidgetObjectiveStateChangedEventFromState;
|
|
247
260
|
toState: WidgetObjectiveStateChangedEventToState;
|
|
248
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* WidgetSessionCredentials is the browser-safe projection of creation
|
|
264
|
+
* credentials. Renewal returns the same fields, including exact token expiry
|
|
265
|
+
* and immutable session expiry, without importing the management API module.
|
|
266
|
+
* Responses containing credentials use Cache-Control: no-store.
|
|
267
|
+
*/
|
|
268
|
+
export interface WidgetSessionCredentials {
|
|
269
|
+
/**
|
|
270
|
+
* Canonical wsess_ identifier. Ordinary renewal cannot change the session.
|
|
271
|
+
*/
|
|
272
|
+
sessionId: string;
|
|
273
|
+
/**
|
|
274
|
+
* Authoritative hostname, without a scheme or path. Use HTTPS with this
|
|
275
|
+
* host; never construct it or accept a host change during renewal.
|
|
276
|
+
*/
|
|
277
|
+
host: string;
|
|
278
|
+
/**
|
|
279
|
+
* Short-lived bearer credential for the widget host only.
|
|
280
|
+
*/
|
|
281
|
+
token: string;
|
|
282
|
+
/**
|
|
283
|
+
* Exact token expiry, at most 15 minutes after issuance and never later
|
|
284
|
+
* than session_expires_at. Equals JWT exp without the 60-second validation
|
|
285
|
+
* tolerance added. Renew proactively before this timestamp.
|
|
286
|
+
*/
|
|
287
|
+
tokenExpiresAt: string;
|
|
288
|
+
/**
|
|
289
|
+
* Immutable hard session expiry. Issuance never extends this deadline.
|
|
290
|
+
*/
|
|
291
|
+
sessionExpiresAt: string;
|
|
292
|
+
}
|
|
249
293
|
/**
|
|
250
294
|
* WidgetTimedOutEvent: the conversation timed out after inactivity. Terminal.
|
|
251
295
|
*/
|
|
@@ -550,4 +594,20 @@ export interface WidgetEvent_StateChanged {
|
|
|
550
594
|
conversationId: string;
|
|
551
595
|
createdAt: string;
|
|
552
596
|
}
|
|
597
|
+
/**
|
|
598
|
+
* TOKEN_EXPIRED identifies access-token expiry beyond the 60-second clock-skew tolerance. That token cannot renew; use already-installed newer credentials or require explicit app reauthentication. SESSION_* reasons are terminal. Never infer renewability from HTTP status alone.
|
|
599
|
+
*/
|
|
600
|
+
export type WidgetSessionErrorReason = 'TOKEN_EXPIRED' | 'SESSION_REVOKED' | 'SESSION_EXPIRED' | 'SESSION_EXHAUSTED';
|
|
601
|
+
/**
|
|
602
|
+
* google.rpc.ErrorInfo detail for widget lifecycle failures. Match both domain and reason; ignore unknown reasons rather than renewing automatically.
|
|
603
|
+
*/
|
|
604
|
+
export interface WidgetSessionErrorInfo {
|
|
605
|
+
'@type': 'type.googleapis.com/google.rpc.ErrorInfo';
|
|
606
|
+
domain: 'api.cadenya.com';
|
|
607
|
+
reason: WidgetSessionErrorReason;
|
|
608
|
+
/**
|
|
609
|
+
* Optional non-sensitive context. Never contains tokens or secrets.
|
|
610
|
+
*/
|
|
611
|
+
metadata?: Record<string, string>;
|
|
612
|
+
}
|
|
553
613
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,M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AAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,6CAA6C","sourcesContent":["// Generated by redwood. Do not edit by hand.\n\n/**\n * Approve tool call request. Responds to a toolApprovalRequested event.\n */\nexport interface ApproveToolCallRequest {\n /**\n * Conversation ID.\n */\n id?: string;\n /**\n * The tool call awaiting a decision, from the toolApprovalRequested event.\n */\n toolCallId?: string;\n}\n\n/**\n * Continue conversation request.\n */\nexport interface ContinueConversationRequest {\n /**\n * Conversation ID.\n */\n id?: string;\n /**\n * The visitor's next message.\n */\n message: string;\n}\n\n/**\n * Create conversation request. The session, tenant, subject, secrets, labels,\n * and pinned parameters all come from the presenting token's session — the\n * browser asserts nothing.\n */\nexport interface CreateConversationRequest {\n /**\n * The visitor's opening message.\n */\n message: string;\n}\n\n/**\n * Deny tool call request. Responds to a toolApprovalRequested event.\n */\nexport interface DenyToolCallRequest {\n /**\n * Conversation ID.\n */\n id?: string;\n /**\n * The tool call awaiting a decision, from the toolApprovalRequested event.\n */\n toolCallId?: string;\n}\n\n/**\n * Contains an arbitrary serialized message along with a @type that describes the type of the serialized message.\n */\nexport interface GoogleProtobufAny {\n /**\n * The type of the serialized message.\n */\n '@type'?: string;\n}\n\n/**\n * Represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive struct value, or a list of values.\n */\nexport type GoogleProtobufValue = unknown;\n\n/**\n * List conversation events response. Ordered oldest first.\n */\nexport interface ListConversationEventsResponse {\n items?: Array<WidgetEvent>;\n pagination?: Page;\n}\n\n/**\n * List conversations response. Ordered by last activity, newest first.\n */\nexport interface ListConversationsResponse {\n items?: Array<WidgetConversation>;\n pagination?: Page;\n}\n\n/**\n * Page carries pagination data for list responses. A deliberate local\n * duplicate of the api module's Page — this package imports nothing from\n * cadenya.api.v1 (see the workspace README).\n */\nexport interface Page {\n /**\n * Cursor for the next page. Empty when there are no further results.\n */\n nextCursor?: string;\n /**\n * Total number of items matching the request.\n */\n total?: number;\n}\n\n/**\n * Set tool call content request. Lets the embedding page supply the result\n * of a bare tool call (one whose tool set has no execution adapter) — the\n * widget-session flavor of the reverse-harness pattern, where client-side\n * logic executes the tool and reports the result back. The result then\n * reaches the conversation as a toolResult event.\n */\nexport interface SetToolCallContentRequest {\n /**\n * Conversation ID.\n */\n id?: string;\n /**\n * The bare tool call to supply content for.\n */\n toolCallId?: string;\n /**\n * The tool call's result content.\n */\n content: string;\n}\n\n/**\n * The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).\n */\nexport interface Status {\n /**\n * The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].\n */\n code?: number;\n /**\n * A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.\n */\n message?: string;\n /**\n * A list of messages that carry the error details. There is a common set of message types for APIs to use.\n */\n details?: Array<GoogleProtobufAny>;\n}\n\n/**\n * Submit conversation feedback request — the visitor's rating of a\n * conversation, mirroring internal objective feedback in slimmed form. Flows\n * into the same feedback machinery that scores agent variations.\n */\nexport interface SubmitConversationFeedbackRequest {\n /**\n * Conversation ID.\n */\n id?: string;\n /**\n * A score between -1.0 and 1.0. -1.0 is the worst, 0.0 neutral, 1.0 the\n * best — a thumbs-down/up UI maps to -1.0/1.0.\n */\n score: number;\n /**\n * Optional comment explaining the feedback.\n */\n comment?: string;\n}\n\n/**\n * WidgetAssistantMessageEvent is a message from the agent. Content may\n * arrive incrementally: later events for the same turn replace earlier\n * partial content.\n */\nexport interface WidgetAssistantMessageEvent {\n content: string;\n}\n\n/**\n * WidgetCancelledEvent: the conversation was cancelled. Terminal.\n */\nexport interface WidgetCancelledEvent {\n}\n\n/**\n * WidgetConfig is the widget's presentation configuration, served to the\n * browser before any session exists. Contains nothing sensitive: the widget\n * is identified by the hostname, and the edge has already enforced the\n * origin allowlist by the time this is served.\n */\nexport interface WidgetConfig {\n /**\n * Display name shown in the widget header.\n */\n displayName: string;\n}\n\nexport type WidgetConversationState = 'STATE_UNSPECIFIED' | 'STATE_RESPONDING' | 'STATE_OPEN' | 'STATE_CLOSED';\n\n/**\n * WidgetConversation is one conversation between the session's visitor and\n * the widget's agent. Conversations are scoped by the presenting token to the\n * VISITOR: a session with a subject sees that subject's conversations on this\n * widget; a session without one sees only the conversations it created\n * itself. A conversation id from outside that scope is indistinguishable from\n * one that does not exist. Tenant is a management-side grouping only — it is\n * never a read scope on this surface.\n */\nexport interface WidgetConversation {\n id: string;\n state: WidgetConversationState;\n /**\n * Server-derived display title (e.g. from the opening message).\n */\n title?: string;\n createdAt: string;\n /**\n * When the conversation last saw a message or event.\n */\n lastActiveAt?: string;\n}\n\n/**\n * WidgetErrorEvent reports a visitor-safe conversation error. The message is\n * sanitized; internal error detail never reaches the widget.\n */\nexport interface WidgetErrorEvent {\n message: string;\n}\n\n/**\n * WidgetEvent is the visitor-facing event vocabulary. It MIRRORS the internal\n * conversation event variants — same granularity, same discriminator names —\n * with slimmed messages holding exactly what a widget UI needs. Internal\n * events map to these through an explicit, exhaustive server-side projection;\n * internal-only types (context compaction, memory reads, sub-agent\n * bookkeeping) have no widget variant and are dropped. Nothing here carries\n * tool configuration, server identities, operator details, or internal error\n * strings. Tool arguments cross this boundary only when an enabled tool set\n * overlay explicitly opts the matching tool in.\n */\nexport type WidgetEvent =\n | WidgetEvent_UserMessage\n | WidgetEvent_AssistantMessage\n | WidgetEvent_ToolApprovalRequested\n | WidgetEvent_ToolApproved\n | WidgetEvent_ToolDenied\n | WidgetEvent_ToolCalled\n | WidgetEvent_ToolResult\n | WidgetEvent_ToolError\n | WidgetEvent_Error\n | WidgetEvent_Cancelled\n | WidgetEvent_TimedOut\n | WidgetEvent_Finalized\n | WidgetEvent_Heartbeat\n | WidgetEvent_StateChanged;\n\n/**\n * WidgetFinalizedEvent: the conversation's agent produced its structured\n * output and the objective reached its terminal state. Only agents with an\n * output definition finalize — such an agent ends the conversation after one\n * turn, so a widget bound to one should treat this as the answer, not a\n * message to keep chatting past.\n */\nexport interface WidgetFinalizedEvent {\n /**\n * The structured output the agent produced, matching the shape of the\n * agent's output definition schema.\n */\n output?: Record<string, unknown>;\n}\n\n/**\n * WidgetHeartbeatEvent mirrors objective heartbeat liveness. It is live-only,\n * absent from history, and never a reconnect checkpoint or state transition.\n */\nexport interface WidgetHeartbeatEvent {\n}\n\nexport type WidgetObjectiveStateChangedEventFromState = 'WIDGET_OBJECTIVE_STATE_UNSPECIFIED' | 'WIDGET_OBJECTIVE_STATE_PENDING' | 'WIDGET_OBJECTIVE_STATE_RUNNING' | 'WIDGET_OBJECTIVE_STATE_WAITING' | 'WIDGET_OBJECTIVE_STATE_FAILED' | 'WIDGET_OBJECTIVE_STATE_CANCELLED' | 'WIDGET_OBJECTIVE_STATE_FINALIZED' | 'WIDGET_OBJECTIVE_STATE_TIMED_OUT';\n\nexport type WidgetObjectiveStateChangedEventToState = 'WIDGET_OBJECTIVE_STATE_UNSPECIFIED' | 'WIDGET_OBJECTIVE_STATE_PENDING' | 'WIDGET_OBJECTIVE_STATE_RUNNING' | 'WIDGET_OBJECTIVE_STATE_WAITING' | 'WIDGET_OBJECTIVE_STATE_FAILED' | 'WIDGET_OBJECTIVE_STATE_CANCELLED' | 'WIDGET_OBJECTIVE_STATE_FINALIZED' | 'WIDGET_OBJECTIVE_STATE_TIMED_OUT';\n\n/**\n * WidgetObjectiveStateChangedEvent mirrors a durable objective transition.\n * Internal status messages are intentionally omitted. Pending/running maps\n * to a responding conversation, waiting to open, and terminal states to closed.\n */\nexport interface WidgetObjectiveStateChangedEvent {\n fromState: WidgetObjectiveStateChangedEventFromState;\n toState: WidgetObjectiveStateChangedEventToState;\n}\n\n/**\n * WidgetTimedOutEvent: the conversation timed out after inactivity. Terminal.\n */\nexport interface WidgetTimedOutEvent {\n}\n\n/**\n * WidgetToolApprovalRequestedEvent asks the visitor to approve or deny a\n * tool call before it runs. The tool reference lets the embedding UI render\n * a custom approval experience per tool; the visitor responds via the\n * approve/deny endpoints.\n */\nexport interface WidgetToolApprovalRequestedEvent {\n /**\n * The tool call awaiting a decision; pass it to the approve/deny endpoint.\n */\n toolCallId: string;\n tool: WidgetToolReference;\n}\n\n/**\n * WidgetToolApprovedEvent records that the pending tool call was approved.\n */\nexport interface WidgetToolApprovedEvent {\n toolCallId: string;\n}\n\n/**\n * WidgetToolCalledEvent reports that the agent invoked a tool.\n */\nexport interface WidgetToolCalledEvent {\n toolCallId: string;\n tool: WidgetToolReference;\n /**\n * The final arguments sent to the tool, after parameter actions were\n * applied. Present only when an enabled matching tool set overlay opts the\n * tool into exposing arguments in widget sessions. Arguments are omitted\n * by default because they may contain sensitive customer data.\n */\n arguments?: Record<string, unknown>;\n}\n\n/**\n * WidgetToolDeniedEvent records that the pending tool call was denied.\n */\nexport interface WidgetToolDeniedEvent {\n toolCallId: string;\n}\n\n/**\n * WidgetToolErrorEvent reports that a tool call failed. Internal error\n * detail never reaches the widget.\n */\nexport interface WidgetToolErrorEvent {\n toolCallId: string;\n tool: WidgetToolReference;\n}\n\n/**\n * WidgetToolReference identifies the tool involved in a tool event — enough\n * for the embedding UI to label the activity and to register custom\n * renderers keyed by the tool's id or the customer's own external id.\n * Deliberately omitted: tool configuration, adapter details, and any server\n * identity.\n */\nexport interface WidgetToolReference {\n /**\n * Cadenya's canonical tool id.\n */\n id: string;\n /**\n * The tool's external id in the customer's namespace, when set.\n */\n externalId?: string;\n /**\n * The tool's name as the workspace configured it (e.g. \"FetchOrderDetails\").\n */\n name: string;\n}\n\n/**\n * WidgetToolResultEvent reports that a tool call finished. Result content is\n * omitted by default and included only for tools the workspace has opted in\n * to sharing content with widget sessions.\n */\nexport interface WidgetToolResultEvent {\n toolCallId: string;\n tool: WidgetToolReference;\n /**\n * The tool's result, present only for tools opted in to sharing content\n * with widget sessions (a per-tool setting; default off). Arbitrary JSON\n * the embedding UI may render — chart data, cards, structured results.\n */\n content?: GoogleProtobufValue;\n}\n\n/**\n * WidgetUserMessageEvent is a message from the visitor.\n */\nexport interface WidgetUserMessageEvent {\n content: string;\n}\n\nexport interface WidgetEvent_UserMessage {\n type: 'userMessage';\n userMessage: WidgetUserMessageEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_AssistantMessage {\n type: 'assistantMessage';\n assistantMessage: WidgetAssistantMessageEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_ToolApprovalRequested {\n type: 'toolApprovalRequested';\n toolApprovalRequested: WidgetToolApprovalRequestedEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_ToolApproved {\n type: 'toolApproved';\n toolApproved: WidgetToolApprovedEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_ToolDenied {\n type: 'toolDenied';\n toolDenied: WidgetToolDeniedEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_ToolCalled {\n type: 'toolCalled';\n toolCalled: WidgetToolCalledEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_ToolResult {\n type: 'toolResult';\n toolResult: WidgetToolResultEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_ToolError {\n type: 'toolError';\n toolError: WidgetToolErrorEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_Error {\n type: 'error';\n error: WidgetErrorEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_Cancelled {\n type: 'cancelled';\n cancelled: WidgetCancelledEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_TimedOut {\n type: 'timedOut';\n timedOut: WidgetTimedOutEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_Finalized {\n type: 'finalized';\n finalized: WidgetFinalizedEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_Heartbeat {\n type: 'heartbeat';\n heartbeat: WidgetHeartbeatEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_StateChanged {\n type: 'stateChanged';\n stateChanged: WidgetObjectiveStateChangedEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,6CAA6C","sourcesContent":["// Generated by redwood. Do not edit by hand.\n\n/**\n * Approve tool call request. Responds to a toolApprovalRequested event.\n */\nexport interface ApproveToolCallRequest {\n /**\n * Conversation ID.\n */\n id?: string;\n /**\n * The tool call awaiting a decision, from the toolApprovalRequested event.\n */\n toolCallId?: string;\n}\n\n/**\n * Continue conversation request.\n */\nexport interface ContinueConversationRequest {\n /**\n * Conversation ID.\n */\n id?: string;\n /**\n * The visitor's next message.\n */\n message: string;\n}\n\n/**\n * Create conversation request. The session, tenant, subject, secrets, labels,\n * and pinned parameters all come from the presenting token's session — the\n * browser asserts nothing.\n */\nexport interface CreateConversationRequest {\n /**\n * The visitor's opening message.\n */\n message: string;\n}\n\n/**\n * Deny tool call request. Responds to a toolApprovalRequested event.\n */\nexport interface DenyToolCallRequest {\n /**\n * Conversation ID.\n */\n id?: string;\n /**\n * The tool call awaiting a decision, from the toolApprovalRequested event.\n */\n toolCallId?: string;\n}\n\n/**\n * Contains an arbitrary serialized message along with a @type that describes the type of the serialized message.\n */\nexport interface GoogleProtobufAny {\n /**\n * The type of the serialized message.\n */\n '@type'?: string;\n}\n\n/**\n * Represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive struct value, or a list of values.\n */\nexport type GoogleProtobufValue = unknown;\n\n/**\n * List conversation events response. Ordered oldest first.\n */\nexport interface ListConversationEventsResponse {\n items?: Array<WidgetEvent>;\n pagination?: Page;\n}\n\n/**\n * List conversations response. Ordered by last activity, newest first.\n */\nexport interface ListConversationsResponse {\n items?: Array<WidgetConversation>;\n pagination?: Page;\n}\n\n/**\n * Page carries pagination data for list responses. A deliberate local\n * duplicate of the api module's Page — this package imports nothing from\n * cadenya.api.v1 (see the workspace README).\n */\nexport interface Page {\n /**\n * Cursor for the next page. Empty when there are no further results.\n */\n nextCursor?: string;\n /**\n * Total number of items matching the request.\n */\n total?: number;\n}\n\n/**\n * RenewWidgetSessionRequest has no session ID or credential in its body.\n * The verified bearer token identifies the existing session. The server\n * rechecks current session and authorization policy before issuing a token.\n * Token validation allows 60 seconds of clock skew: now must be strictly\n * before exp + 60 seconds. Hard session expiry has no tolerance. A token\n * beyond this window cannot renew even while the session remains active.\n */\nexport interface RenewWidgetSessionRequest {\n /**\n * Required workspace containing the authenticated session. Must match the\n * session resolved from the bearer token; never authorizes access by itself.\n */\n workspaceId?: string;\n}\n\n/**\n * Set tool call content request. Lets the embedding page supply the result\n * of a bare tool call (one whose tool set has no execution adapter) — the\n * widget-session flavor of the reverse-harness pattern, where client-side\n * logic executes the tool and reports the result back. The result then\n * reaches the conversation as a toolResult event.\n */\nexport interface SetToolCallContentRequest {\n /**\n * Conversation ID.\n */\n id?: string;\n /**\n * The bare tool call to supply content for.\n */\n toolCallId?: string;\n /**\n * The tool call's result content.\n */\n content: string;\n}\n\nexport type StatusDetails =\n | WidgetSessionErrorInfo\n | GoogleProtobufAny;\n\n/**\n * The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).\n */\nexport interface Status {\n /**\n * The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].\n */\n code?: number;\n /**\n * A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.\n */\n message?: string;\n /**\n * A list of messages that carry the error details. There is a common set of message types for APIs to use.\n */\n details?: Array<StatusDetails>;\n}\n\n/**\n * Submit conversation feedback request — the visitor's rating of a\n * conversation, mirroring internal objective feedback in slimmed form. Flows\n * into the same feedback machinery that scores agent variations.\n */\nexport interface SubmitConversationFeedbackRequest {\n /**\n * Conversation ID.\n */\n id?: string;\n /**\n * A score between -1.0 and 1.0. -1.0 is the worst, 0.0 neutral, 1.0 the\n * best — a thumbs-down/up UI maps to -1.0/1.0.\n */\n score: number;\n /**\n * Optional comment explaining the feedback.\n */\n comment?: string;\n}\n\n/**\n * WidgetAssistantMessageEvent is a message from the agent. Content may\n * arrive incrementally: later events for the same turn replace earlier\n * partial content.\n */\nexport interface WidgetAssistantMessageEvent {\n content: string;\n}\n\n/**\n * WidgetCancelledEvent: the conversation was cancelled. Terminal.\n */\nexport interface WidgetCancelledEvent {\n}\n\n/**\n * WidgetConfig is the widget's presentation configuration, served to the\n * browser before any session exists. Contains nothing sensitive: the widget\n * is identified by the hostname, and the edge has already enforced the\n * origin allowlist by the time this is served.\n */\nexport interface WidgetConfig {\n /**\n * Display name shown in the widget header.\n */\n displayName: string;\n}\n\nexport type WidgetConversationState = 'STATE_UNSPECIFIED' | 'STATE_RESPONDING' | 'STATE_OPEN' | 'STATE_CLOSED';\n\n/**\n * WidgetConversation is one conversation between a visitor and a widget's\n * agent. The presenting session must have a tenant and subject. Sessions for\n * that same identity share history on the same widget and agent, subject to\n * the current session's permissions. Other conversation IDs return not found.\n */\nexport interface WidgetConversation {\n id: string;\n state: WidgetConversationState;\n /**\n * Server-derived display title (e.g. from the opening message).\n */\n title?: string;\n createdAt: string;\n /**\n * When the conversation last saw a message or event.\n */\n lastActiveAt?: string;\n}\n\n/**\n * WidgetErrorEvent reports a visitor-safe conversation error. The message is\n * sanitized; internal error detail never reaches the widget.\n */\nexport interface WidgetErrorEvent {\n message: string;\n}\n\n/**\n * WidgetEvent is the visitor-facing event vocabulary. It MIRRORS the internal\n * conversation event variants — same granularity, same discriminator names —\n * with slimmed messages holding exactly what a widget UI needs. Internal\n * events map to these through an explicit, exhaustive server-side projection;\n * internal-only types (context compaction, memory reads, sub-agent\n * bookkeeping) have no widget variant and are dropped. Nothing here carries\n * tool configuration, server identities, operator details, or internal error\n * strings. Tool arguments cross this boundary only when an enabled tool set\n * overlay explicitly opts the matching tool in.\n */\nexport type WidgetEvent =\n | WidgetEvent_UserMessage\n | WidgetEvent_AssistantMessage\n | WidgetEvent_ToolApprovalRequested\n | WidgetEvent_ToolApproved\n | WidgetEvent_ToolDenied\n | WidgetEvent_ToolCalled\n | WidgetEvent_ToolResult\n | WidgetEvent_ToolError\n | WidgetEvent_Error\n | WidgetEvent_Cancelled\n | WidgetEvent_TimedOut\n | WidgetEvent_Finalized\n | WidgetEvent_Heartbeat\n | WidgetEvent_StateChanged;\n\n/**\n * WidgetFinalizedEvent: the conversation's agent produced its structured\n * output and the objective reached its terminal state. Only agents with an\n * output definition finalize — such an agent ends the conversation after one\n * turn, so a widget bound to one should treat this as the answer, not a\n * message to keep chatting past.\n */\nexport interface WidgetFinalizedEvent {\n /**\n * The structured output the agent produced, matching the shape of the\n * agent's output definition schema.\n */\n output?: Record<string, unknown>;\n}\n\n/**\n * WidgetHeartbeatEvent mirrors objective heartbeat liveness. It is live-only,\n * absent from history, and never a reconnect checkpoint or state transition.\n */\nexport interface WidgetHeartbeatEvent {\n}\n\nexport type WidgetObjectiveStateChangedEventFromState = 'WIDGET_OBJECTIVE_STATE_UNSPECIFIED' | 'WIDGET_OBJECTIVE_STATE_PENDING' | 'WIDGET_OBJECTIVE_STATE_RUNNING' | 'WIDGET_OBJECTIVE_STATE_WAITING' | 'WIDGET_OBJECTIVE_STATE_FAILED' | 'WIDGET_OBJECTIVE_STATE_CANCELLED' | 'WIDGET_OBJECTIVE_STATE_FINALIZED' | 'WIDGET_OBJECTIVE_STATE_TIMED_OUT';\n\nexport type WidgetObjectiveStateChangedEventToState = 'WIDGET_OBJECTIVE_STATE_UNSPECIFIED' | 'WIDGET_OBJECTIVE_STATE_PENDING' | 'WIDGET_OBJECTIVE_STATE_RUNNING' | 'WIDGET_OBJECTIVE_STATE_WAITING' | 'WIDGET_OBJECTIVE_STATE_FAILED' | 'WIDGET_OBJECTIVE_STATE_CANCELLED' | 'WIDGET_OBJECTIVE_STATE_FINALIZED' | 'WIDGET_OBJECTIVE_STATE_TIMED_OUT';\n\n/**\n * WidgetObjectiveStateChangedEvent mirrors a durable objective transition.\n * Internal status messages are intentionally omitted. Pending/running maps\n * to a responding conversation, waiting to open, and terminal states to closed.\n */\nexport interface WidgetObjectiveStateChangedEvent {\n fromState: WidgetObjectiveStateChangedEventFromState;\n toState: WidgetObjectiveStateChangedEventToState;\n}\n\n/**\n * WidgetSessionCredentials is the browser-safe projection of creation\n * credentials. Renewal returns the same fields, including exact token expiry\n * and immutable session expiry, without importing the management API module.\n * Responses containing credentials use Cache-Control: no-store.\n */\nexport interface WidgetSessionCredentials {\n /**\n * Canonical wsess_ identifier. Ordinary renewal cannot change the session.\n */\n sessionId: string;\n /**\n * Authoritative hostname, without a scheme or path. Use HTTPS with this\n * host; never construct it or accept a host change during renewal.\n */\n host: string;\n /**\n * Short-lived bearer credential for the widget host only.\n */\n token: string;\n /**\n * Exact token expiry, at most 15 minutes after issuance and never later\n * than session_expires_at. Equals JWT exp without the 60-second validation\n * tolerance added. Renew proactively before this timestamp.\n */\n tokenExpiresAt: string;\n /**\n * Immutable hard session expiry. Issuance never extends this deadline.\n */\n sessionExpiresAt: string;\n}\n\n/**\n * WidgetTimedOutEvent: the conversation timed out after inactivity. Terminal.\n */\nexport interface WidgetTimedOutEvent {\n}\n\n/**\n * WidgetToolApprovalRequestedEvent asks the visitor to approve or deny a\n * tool call before it runs. The tool reference lets the embedding UI render\n * a custom approval experience per tool; the visitor responds via the\n * approve/deny endpoints.\n */\nexport interface WidgetToolApprovalRequestedEvent {\n /**\n * The tool call awaiting a decision; pass it to the approve/deny endpoint.\n */\n toolCallId: string;\n tool: WidgetToolReference;\n}\n\n/**\n * WidgetToolApprovedEvent records that the pending tool call was approved.\n */\nexport interface WidgetToolApprovedEvent {\n toolCallId: string;\n}\n\n/**\n * WidgetToolCalledEvent reports that the agent invoked a tool.\n */\nexport interface WidgetToolCalledEvent {\n toolCallId: string;\n tool: WidgetToolReference;\n /**\n * The final arguments sent to the tool, after parameter actions were\n * applied. Present only when an enabled matching tool set overlay opts the\n * tool into exposing arguments in widget sessions. Arguments are omitted\n * by default because they may contain sensitive customer data.\n */\n arguments?: Record<string, unknown>;\n}\n\n/**\n * WidgetToolDeniedEvent records that the pending tool call was denied.\n */\nexport interface WidgetToolDeniedEvent {\n toolCallId: string;\n}\n\n/**\n * WidgetToolErrorEvent reports that a tool call failed. Internal error\n * detail never reaches the widget.\n */\nexport interface WidgetToolErrorEvent {\n toolCallId: string;\n tool: WidgetToolReference;\n}\n\n/**\n * WidgetToolReference identifies the tool involved in a tool event — enough\n * for the embedding UI to label the activity and to register custom\n * renderers keyed by the tool's id or the customer's own external id.\n * Deliberately omitted: tool configuration, adapter details, and any server\n * identity.\n */\nexport interface WidgetToolReference {\n /**\n * Cadenya's canonical tool id.\n */\n id: string;\n /**\n * The tool's external id in the customer's namespace, when set.\n */\n externalId?: string;\n /**\n * The tool's name as the workspace configured it (e.g. \"FetchOrderDetails\").\n */\n name: string;\n}\n\n/**\n * WidgetToolResultEvent reports that a tool call finished. Result content is\n * omitted by default and included only for tools the workspace has opted in\n * to sharing content with widget sessions.\n */\nexport interface WidgetToolResultEvent {\n toolCallId: string;\n tool: WidgetToolReference;\n /**\n * The tool's result, present only for tools opted in to sharing content\n * with widget sessions (a per-tool setting; default off). Arbitrary JSON\n * the embedding UI may render — chart data, cards, structured results.\n */\n content?: GoogleProtobufValue;\n}\n\n/**\n * WidgetUserMessageEvent is a message from the visitor.\n */\nexport interface WidgetUserMessageEvent {\n content: string;\n}\n\nexport interface WidgetEvent_UserMessage {\n type: 'userMessage';\n userMessage: WidgetUserMessageEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_AssistantMessage {\n type: 'assistantMessage';\n assistantMessage: WidgetAssistantMessageEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_ToolApprovalRequested {\n type: 'toolApprovalRequested';\n toolApprovalRequested: WidgetToolApprovalRequestedEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_ToolApproved {\n type: 'toolApproved';\n toolApproved: WidgetToolApprovedEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_ToolDenied {\n type: 'toolDenied';\n toolDenied: WidgetToolDeniedEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_ToolCalled {\n type: 'toolCalled';\n toolCalled: WidgetToolCalledEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_ToolResult {\n type: 'toolResult';\n toolResult: WidgetToolResultEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_ToolError {\n type: 'toolError';\n toolError: WidgetToolErrorEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_Error {\n type: 'error';\n error: WidgetErrorEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_Cancelled {\n type: 'cancelled';\n cancelled: WidgetCancelledEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_TimedOut {\n type: 'timedOut';\n timedOut: WidgetTimedOutEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_Finalized {\n type: 'finalized';\n finalized: WidgetFinalizedEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_Heartbeat {\n type: 'heartbeat';\n heartbeat: WidgetHeartbeatEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\nexport interface WidgetEvent_StateChanged {\n type: 'stateChanged';\n stateChanged: WidgetObjectiveStateChangedEvent;\n /**\n * Unique event id (prefixed ULID). Only durable objevt_ IDs are emitted\n * as SSE `id:` fields and accepted as Last-Event-ID reconnect cursors.\n * Transient heartbeats carry hb_ IDs in this payload only.\n */\n id: string;\n /**\n * The conversation this event belongs to.\n */\n conversationId: string;\n createdAt: string;\n}\n\n/**\n * TOKEN_EXPIRED identifies access-token expiry beyond the 60-second clock-skew tolerance. That token cannot renew; use already-installed newer credentials or require explicit app reauthentication. SESSION_* reasons are terminal. Never infer renewability from HTTP status alone.\n */\nexport type WidgetSessionErrorReason = 'TOKEN_EXPIRED' | 'SESSION_REVOKED' | 'SESSION_EXPIRED' | 'SESSION_EXHAUSTED';\n\n/**\n * google.rpc.ErrorInfo detail for widget lifecycle failures. Match both domain and reason; ignore unknown reasons rather than renewing automatically.\n */\nexport interface WidgetSessionErrorInfo {\n '@type': 'type.googleapis.com/google.rpc.ErrorInfo';\n domain: 'api.cadenya.com';\n reason: WidgetSessionErrorReason;\n /**\n * Optional non-sensitive context. Never contains tokens or secrets.\n */\n metadata?: Record<string, string>;\n}\n\n"]}
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { HttpClient } from './core/http.js';
|
|
|
4
4
|
import type { Logger, LogLevel } from './core/http.js';
|
|
5
5
|
import { Config } from './resources/config.js';
|
|
6
6
|
import { Conversations } from './resources/conversations.js';
|
|
7
|
+
import { Session } from './resources/session.js';
|
|
7
8
|
|
|
8
9
|
export interface ClientOptions {
|
|
9
10
|
/** API key. Defaults to the CADENYAWIDGETS_API_KEY environment variable. */
|
|
@@ -32,6 +33,7 @@ export interface ClientOptions {
|
|
|
32
33
|
export class CadenyaWidgets {
|
|
33
34
|
readonly config: Config;
|
|
34
35
|
readonly conversations: Conversations;
|
|
36
|
+
readonly session: Session;
|
|
35
37
|
|
|
36
38
|
private readonly _client: HttpClient;
|
|
37
39
|
|
|
@@ -49,7 +51,7 @@ export class CadenyaWidgets {
|
|
|
49
51
|
authHeader: () => ({ Authorization: `Bearer ${apiKey}` }),
|
|
50
52
|
maxRetries: options.maxRetries ?? 0,
|
|
51
53
|
timeout: options.timeout,
|
|
52
|
-
defaultHeaders: { ...nodeUserAgent('cadenyawidgets-typescript/1.
|
|
54
|
+
defaultHeaders: { ...nodeUserAgent('cadenyawidgets-typescript/1.3.0 (api 1.0)'), ...options.defaultHeaders },
|
|
53
55
|
fetch: options.fetch,
|
|
54
56
|
logger: options.logger,
|
|
55
57
|
logLevel: options.logLevel,
|
|
@@ -57,6 +59,7 @@ export class CadenyaWidgets {
|
|
|
57
59
|
});
|
|
58
60
|
this.config = new Config(this._client);
|
|
59
61
|
this.conversations = new Conversations(this._client);
|
|
62
|
+
this.session = new Session(this._client);
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Generated by redwood. Do not edit by hand.
|
|
2
|
+
|
|
3
|
+
import { HttpClient, RequestOptions, APIPromise, pathSegment } from '../core/http.js';
|
|
4
|
+
import type { WidgetSessionCredentials } from '../types.js';
|
|
5
|
+
|
|
6
|
+
export interface SessionRenewWidgetParams {
|
|
7
|
+
/**
|
|
8
|
+
* Required workspace containing the authenticated session. Must match the
|
|
9
|
+
* session resolved from the bearer token; never authorizes access by itself.
|
|
10
|
+
*/
|
|
11
|
+
workspaceId: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class Session {
|
|
15
|
+
constructor(private readonly _client: HttpClient) {}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Renew a widget session token
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const widgetSessionCredentials = await client.session.renewWidget({ workspaceId: 'workspace_123' });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
renewWidget(params: SessionRenewWidgetParams, options?: RequestOptions): APIPromise<WidgetSessionCredentials> {
|
|
26
|
+
return this._client.requestAPI<WidgetSessionCredentials>(() => {
|
|
27
|
+
return { method: 'POST', path: `/v1/workspaces/${pathSegment('workspaceId', params.workspaceId)}/session:renew` };
|
|
28
|
+
}, options);
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -101,6 +101,22 @@ export interface Page {
|
|
|
101
101
|
total?: number;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* RenewWidgetSessionRequest has no session ID or credential in its body.
|
|
106
|
+
* The verified bearer token identifies the existing session. The server
|
|
107
|
+
* rechecks current session and authorization policy before issuing a token.
|
|
108
|
+
* Token validation allows 60 seconds of clock skew: now must be strictly
|
|
109
|
+
* before exp + 60 seconds. Hard session expiry has no tolerance. A token
|
|
110
|
+
* beyond this window cannot renew even while the session remains active.
|
|
111
|
+
*/
|
|
112
|
+
export interface RenewWidgetSessionRequest {
|
|
113
|
+
/**
|
|
114
|
+
* Required workspace containing the authenticated session. Must match the
|
|
115
|
+
* session resolved from the bearer token; never authorizes access by itself.
|
|
116
|
+
*/
|
|
117
|
+
workspaceId?: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
104
120
|
/**
|
|
105
121
|
* Set tool call content request. Lets the embedding page supply the result
|
|
106
122
|
* of a bare tool call (one whose tool set has no execution adapter) — the
|
|
@@ -123,6 +139,10 @@ export interface SetToolCallContentRequest {
|
|
|
123
139
|
content: string;
|
|
124
140
|
}
|
|
125
141
|
|
|
142
|
+
export type StatusDetails =
|
|
143
|
+
| WidgetSessionErrorInfo
|
|
144
|
+
| GoogleProtobufAny;
|
|
145
|
+
|
|
126
146
|
/**
|
|
127
147
|
* The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
|
|
128
148
|
*/
|
|
@@ -138,7 +158,7 @@ export interface Status {
|
|
|
138
158
|
/**
|
|
139
159
|
* A list of messages that carry the error details. There is a common set of message types for APIs to use.
|
|
140
160
|
*/
|
|
141
|
-
details?: Array<
|
|
161
|
+
details?: Array<StatusDetails>;
|
|
142
162
|
}
|
|
143
163
|
|
|
144
164
|
/**
|
|
@@ -193,13 +213,10 @@ export interface WidgetConfig {
|
|
|
193
213
|
export type WidgetConversationState = 'STATE_UNSPECIFIED' | 'STATE_RESPONDING' | 'STATE_OPEN' | 'STATE_CLOSED';
|
|
194
214
|
|
|
195
215
|
/**
|
|
196
|
-
* WidgetConversation is one conversation between
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
* itself. A conversation id from outside that scope is indistinguishable from
|
|
201
|
-
* one that does not exist. Tenant is a management-side grouping only — it is
|
|
202
|
-
* never a read scope on this surface.
|
|
216
|
+
* WidgetConversation is one conversation between a visitor and a widget's
|
|
217
|
+
* agent. The presenting session must have a tenant and subject. Sessions for
|
|
218
|
+
* that same identity share history on the same widget and agent, subject to
|
|
219
|
+
* the current session's permissions. Other conversation IDs return not found.
|
|
203
220
|
*/
|
|
204
221
|
export interface WidgetConversation {
|
|
205
222
|
id: string;
|
|
@@ -286,6 +303,38 @@ export interface WidgetObjectiveStateChangedEvent {
|
|
|
286
303
|
toState: WidgetObjectiveStateChangedEventToState;
|
|
287
304
|
}
|
|
288
305
|
|
|
306
|
+
/**
|
|
307
|
+
* WidgetSessionCredentials is the browser-safe projection of creation
|
|
308
|
+
* credentials. Renewal returns the same fields, including exact token expiry
|
|
309
|
+
* and immutable session expiry, without importing the management API module.
|
|
310
|
+
* Responses containing credentials use Cache-Control: no-store.
|
|
311
|
+
*/
|
|
312
|
+
export interface WidgetSessionCredentials {
|
|
313
|
+
/**
|
|
314
|
+
* Canonical wsess_ identifier. Ordinary renewal cannot change the session.
|
|
315
|
+
*/
|
|
316
|
+
sessionId: string;
|
|
317
|
+
/**
|
|
318
|
+
* Authoritative hostname, without a scheme or path. Use HTTPS with this
|
|
319
|
+
* host; never construct it or accept a host change during renewal.
|
|
320
|
+
*/
|
|
321
|
+
host: string;
|
|
322
|
+
/**
|
|
323
|
+
* Short-lived bearer credential for the widget host only.
|
|
324
|
+
*/
|
|
325
|
+
token: string;
|
|
326
|
+
/**
|
|
327
|
+
* Exact token expiry, at most 15 minutes after issuance and never later
|
|
328
|
+
* than session_expires_at. Equals JWT exp without the 60-second validation
|
|
329
|
+
* tolerance added. Renew proactively before this timestamp.
|
|
330
|
+
*/
|
|
331
|
+
tokenExpiresAt: string;
|
|
332
|
+
/**
|
|
333
|
+
* Immutable hard session expiry. Issuance never extends this deadline.
|
|
334
|
+
*/
|
|
335
|
+
sessionExpiresAt: string;
|
|
336
|
+
}
|
|
337
|
+
|
|
289
338
|
/**
|
|
290
339
|
* WidgetTimedOutEvent: the conversation timed out after inactivity. Terminal.
|
|
291
340
|
*/
|
|
@@ -613,3 +662,21 @@ export interface WidgetEvent_StateChanged {
|
|
|
613
662
|
createdAt: string;
|
|
614
663
|
}
|
|
615
664
|
|
|
665
|
+
/**
|
|
666
|
+
* TOKEN_EXPIRED identifies access-token expiry beyond the 60-second clock-skew tolerance. That token cannot renew; use already-installed newer credentials or require explicit app reauthentication. SESSION_* reasons are terminal. Never infer renewability from HTTP status alone.
|
|
667
|
+
*/
|
|
668
|
+
export type WidgetSessionErrorReason = 'TOKEN_EXPIRED' | 'SESSION_REVOKED' | 'SESSION_EXPIRED' | 'SESSION_EXHAUSTED';
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* google.rpc.ErrorInfo detail for widget lifecycle failures. Match both domain and reason; ignore unknown reasons rather than renewing automatically.
|
|
672
|
+
*/
|
|
673
|
+
export interface WidgetSessionErrorInfo {
|
|
674
|
+
'@type': 'type.googleapis.com/google.rpc.ErrorInfo';
|
|
675
|
+
domain: 'api.cadenya.com';
|
|
676
|
+
reason: WidgetSessionErrorReason;
|
|
677
|
+
/**
|
|
678
|
+
* Optional non-sensitive context. Never contains tokens or secrets.
|
|
679
|
+
*/
|
|
680
|
+
metadata?: Record<string, string>;
|
|
681
|
+
}
|
|
682
|
+
|