feat: Passwordless cross-device authentication

- Arkitektur: docs/auth/passwordless-architecture.md
- Backend: iom/quixzoom-auth-service/ (FastAPI + Redis)
- Webb: quixzoom-market-pages/se/login/ (QR-kod + polling)
- App: iom/quixzoom-app/src/features/auth/ (push + deep links)

Flöde: QR-kod → app-godkännande → webb-inloggad
This commit is contained in:
Bernt
2026-07-07 07:11:50 +00:00
parent 4aa984ad74
commit 6989a98d75
61843 changed files with 5491611 additions and 872231 deletions
+51
View File
@@ -0,0 +1,51 @@
import { APIResource } from "../../../core/resource.mjs";
import * as SessionsAPI from "./sessions.mjs";
import { SessionCreateParams, Sessions } from "./sessions.mjs";
import * as ThreadsAPI from "./threads.mjs";
import { ChatKitAttachment, ChatKitResponseOutputText, ChatKitThread, ChatKitThreadAssistantMessageItem, ChatKitThreadItemList, ChatKitThreadItemListDataPage, ChatKitThreadUserMessageItem, ChatKitThreadsPage, ChatKitWidgetItem, ChatSession, ChatSessionAutomaticThreadTitling, ChatSessionChatKitConfiguration, ChatSessionChatKitConfigurationParam, ChatSessionExpiresAfterParam, ChatSessionFileUpload, ChatSessionHistory, ChatSessionRateLimits, ChatSessionRateLimitsParam, ChatSessionStatus, ChatSessionWorkflowParam, ThreadDeleteResponse, ThreadListItemsParams, ThreadListParams, Threads } from "./threads.mjs";
export declare class ChatKit extends APIResource {
sessions: SessionsAPI.Sessions;
threads: ThreadsAPI.Threads;
}
/**
* Workflow metadata and state returned for the session.
*/
export interface ChatKitWorkflow {
/**
* Identifier of the workflow backing the session.
*/
id: string;
/**
* State variable key-value pairs applied when invoking the workflow. Defaults to
* null when no overrides were provided.
*/
state_variables: {
[key: string]: string | boolean | number;
} | null;
/**
* Tracing settings applied to the workflow.
*/
tracing: ChatKitWorkflow.Tracing;
/**
* Specific workflow version used for the session. Defaults to null when using the
* latest deployment.
*/
version: string | null;
}
export declare namespace ChatKitWorkflow {
/**
* Tracing settings applied to the workflow.
*/
interface Tracing {
/**
* Indicates whether tracing is enabled.
*/
enabled: boolean;
}
}
export declare namespace ChatKit {
export { type ChatKitWorkflow as ChatKitWorkflow };
export { Sessions as Sessions, type SessionCreateParams as SessionCreateParams };
export { Threads as Threads, type ChatSession as ChatSession, type ChatSessionAutomaticThreadTitling as ChatSessionAutomaticThreadTitling, type ChatSessionChatKitConfiguration as ChatSessionChatKitConfiguration, type ChatSessionChatKitConfigurationParam as ChatSessionChatKitConfigurationParam, type ChatSessionExpiresAfterParam as ChatSessionExpiresAfterParam, type ChatSessionFileUpload as ChatSessionFileUpload, type ChatSessionHistory as ChatSessionHistory, type ChatSessionRateLimits as ChatSessionRateLimits, type ChatSessionRateLimitsParam as ChatSessionRateLimitsParam, type ChatSessionStatus as ChatSessionStatus, type ChatSessionWorkflowParam as ChatSessionWorkflowParam, type ChatKitAttachment as ChatKitAttachment, type ChatKitResponseOutputText as ChatKitResponseOutputText, type ChatKitThread as ChatKitThread, type ChatKitThreadAssistantMessageItem as ChatKitThreadAssistantMessageItem, type ChatKitThreadItemList as ChatKitThreadItemList, type ChatKitThreadUserMessageItem as ChatKitThreadUserMessageItem, type ChatKitWidgetItem as ChatKitWidgetItem, type ThreadDeleteResponse as ThreadDeleteResponse, type ChatKitThreadsPage as ChatKitThreadsPage, type ChatKitThreadItemListDataPage as ChatKitThreadItemListDataPage, type ThreadListParams as ThreadListParams, type ThreadListItemsParams as ThreadListItemsParams, };
}
//# sourceMappingURL=chatkit.d.mts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"chatkit.d.mts","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/chatkit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,mCAA+B;AACrD,OAAO,KAAK,WAAW,uBAAmB;AAC1C,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,uBAAmB;AAC3D,OAAO,KAAK,UAAU,sBAAkB;AACxC,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,aAAa,EACb,iCAAiC,EACjC,qBAAqB,EACrB,6BAA6B,EAC7B,4BAA4B,EAC5B,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,iCAAiC,EACjC,+BAA+B,EAC/B,oCAAoC,EACpC,4BAA4B,EAC5B,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,0BAA0B,EAC1B,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,OAAO,EACR,sBAAkB;AAEnB,qBAAa,OAAQ,SAAQ,WAAW;IACtC,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAA0C;IACxE,OAAO,EAAE,UAAU,CAAC,OAAO,CAAwC;CACpE;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;OAGG;IACH,eAAe,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAErE;;OAEG;IACH,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC;IAEjC;;;OAGG;IACH,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,yBAAiB,eAAe,CAAC;IAC/B;;OAEG;IACH,UAAiB,OAAO;QACtB;;WAEG;QACH,OAAO,EAAE,OAAO,CAAC;KAClB;CACF;AAKD,MAAM,CAAC,OAAO,WAAW,OAAO,CAAC;IAC/B,OAAO,EAAE,KAAK,eAAe,IAAI,eAAe,EAAE,CAAC;IAEnD,OAAO,EAAE,QAAQ,IAAI,QAAQ,EAAE,KAAK,mBAAmB,IAAI,mBAAmB,EAAE,CAAC;IAEjF,OAAO,EACL,OAAO,IAAI,OAAO,EAClB,KAAK,WAAW,IAAI,WAAW,EAC/B,KAAK,iCAAiC,IAAI,iCAAiC,EAC3E,KAAK,+BAA+B,IAAI,+BAA+B,EACvE,KAAK,oCAAoC,IAAI,oCAAoC,EACjF,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,yBAAyB,IAAI,yBAAyB,EAC3D,KAAK,aAAa,IAAI,aAAa,EACnC,KAAK,iCAAiC,IAAI,iCAAiC,EAC3E,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,qBAAqB,IAAI,qBAAqB,GACpD,CAAC;CACH"}
+51
View File
@@ -0,0 +1,51 @@
import { APIResource } from "../../../core/resource.js";
import * as SessionsAPI from "./sessions.js";
import { SessionCreateParams, Sessions } from "./sessions.js";
import * as ThreadsAPI from "./threads.js";
import { ChatKitAttachment, ChatKitResponseOutputText, ChatKitThread, ChatKitThreadAssistantMessageItem, ChatKitThreadItemList, ChatKitThreadItemListDataPage, ChatKitThreadUserMessageItem, ChatKitThreadsPage, ChatKitWidgetItem, ChatSession, ChatSessionAutomaticThreadTitling, ChatSessionChatKitConfiguration, ChatSessionChatKitConfigurationParam, ChatSessionExpiresAfterParam, ChatSessionFileUpload, ChatSessionHistory, ChatSessionRateLimits, ChatSessionRateLimitsParam, ChatSessionStatus, ChatSessionWorkflowParam, ThreadDeleteResponse, ThreadListItemsParams, ThreadListParams, Threads } from "./threads.js";
export declare class ChatKit extends APIResource {
sessions: SessionsAPI.Sessions;
threads: ThreadsAPI.Threads;
}
/**
* Workflow metadata and state returned for the session.
*/
export interface ChatKitWorkflow {
/**
* Identifier of the workflow backing the session.
*/
id: string;
/**
* State variable key-value pairs applied when invoking the workflow. Defaults to
* null when no overrides were provided.
*/
state_variables: {
[key: string]: string | boolean | number;
} | null;
/**
* Tracing settings applied to the workflow.
*/
tracing: ChatKitWorkflow.Tracing;
/**
* Specific workflow version used for the session. Defaults to null when using the
* latest deployment.
*/
version: string | null;
}
export declare namespace ChatKitWorkflow {
/**
* Tracing settings applied to the workflow.
*/
interface Tracing {
/**
* Indicates whether tracing is enabled.
*/
enabled: boolean;
}
}
export declare namespace ChatKit {
export { type ChatKitWorkflow as ChatKitWorkflow };
export { Sessions as Sessions, type SessionCreateParams as SessionCreateParams };
export { Threads as Threads, type ChatSession as ChatSession, type ChatSessionAutomaticThreadTitling as ChatSessionAutomaticThreadTitling, type ChatSessionChatKitConfiguration as ChatSessionChatKitConfiguration, type ChatSessionChatKitConfigurationParam as ChatSessionChatKitConfigurationParam, type ChatSessionExpiresAfterParam as ChatSessionExpiresAfterParam, type ChatSessionFileUpload as ChatSessionFileUpload, type ChatSessionHistory as ChatSessionHistory, type ChatSessionRateLimits as ChatSessionRateLimits, type ChatSessionRateLimitsParam as ChatSessionRateLimitsParam, type ChatSessionStatus as ChatSessionStatus, type ChatSessionWorkflowParam as ChatSessionWorkflowParam, type ChatKitAttachment as ChatKitAttachment, type ChatKitResponseOutputText as ChatKitResponseOutputText, type ChatKitThread as ChatKitThread, type ChatKitThreadAssistantMessageItem as ChatKitThreadAssistantMessageItem, type ChatKitThreadItemList as ChatKitThreadItemList, type ChatKitThreadUserMessageItem as ChatKitThreadUserMessageItem, type ChatKitWidgetItem as ChatKitWidgetItem, type ThreadDeleteResponse as ThreadDeleteResponse, type ChatKitThreadsPage as ChatKitThreadsPage, type ChatKitThreadItemListDataPage as ChatKitThreadItemListDataPage, type ThreadListParams as ThreadListParams, type ThreadListItemsParams as ThreadListItemsParams, };
}
//# sourceMappingURL=chatkit.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"chatkit.d.ts","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/chatkit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,kCAA+B;AACrD,OAAO,KAAK,WAAW,sBAAmB;AAC1C,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,sBAAmB;AAC3D,OAAO,KAAK,UAAU,qBAAkB;AACxC,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,aAAa,EACb,iCAAiC,EACjC,qBAAqB,EACrB,6BAA6B,EAC7B,4BAA4B,EAC5B,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,iCAAiC,EACjC,+BAA+B,EAC/B,oCAAoC,EACpC,4BAA4B,EAC5B,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,0BAA0B,EAC1B,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,OAAO,EACR,qBAAkB;AAEnB,qBAAa,OAAQ,SAAQ,WAAW;IACtC,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAA0C;IACxE,OAAO,EAAE,UAAU,CAAC,OAAO,CAAwC;CACpE;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;OAGG;IACH,eAAe,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAErE;;OAEG;IACH,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC;IAEjC;;;OAGG;IACH,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,yBAAiB,eAAe,CAAC;IAC/B;;OAEG;IACH,UAAiB,OAAO;QACtB;;WAEG;QACH,OAAO,EAAE,OAAO,CAAC;KAClB;CACF;AAKD,MAAM,CAAC,OAAO,WAAW,OAAO,CAAC;IAC/B,OAAO,EAAE,KAAK,eAAe,IAAI,eAAe,EAAE,CAAC;IAEnD,OAAO,EAAE,QAAQ,IAAI,QAAQ,EAAE,KAAK,mBAAmB,IAAI,mBAAmB,EAAE,CAAC;IAEjF,OAAO,EACL,OAAO,IAAI,OAAO,EAClB,KAAK,WAAW,IAAI,WAAW,EAC/B,KAAK,iCAAiC,IAAI,iCAAiC,EAC3E,KAAK,+BAA+B,IAAI,+BAA+B,EACvE,KAAK,oCAAoC,IAAI,oCAAoC,EACjF,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,yBAAyB,IAAI,yBAAyB,EAC3D,KAAK,aAAa,IAAI,aAAa,EACnC,KAAK,iCAAiC,IAAI,iCAAiC,EAC3E,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,qBAAqB,IAAI,qBAAqB,GACpD,CAAC;CACH"}
+21
View File
@@ -0,0 +1,21 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChatKit = void 0;
const tslib_1 = require("../../../internal/tslib.js");
const resource_1 = require("../../../core/resource.js");
const SessionsAPI = tslib_1.__importStar(require("./sessions.js"));
const sessions_1 = require("./sessions.js");
const ThreadsAPI = tslib_1.__importStar(require("./threads.js"));
const threads_1 = require("./threads.js");
class ChatKit extends resource_1.APIResource {
constructor() {
super(...arguments);
this.sessions = new SessionsAPI.Sessions(this._client);
this.threads = new ThreadsAPI.Threads(this._client);
}
}
exports.ChatKit = ChatKit;
ChatKit.Sessions = sessions_1.Sessions;
ChatKit.Threads = threads_1.Threads;
//# sourceMappingURL=chatkit.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"chatkit.js","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/chatkit.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;AAEtF,wDAAqD;AACrD,mEAA0C;AAC1C,4CAA2D;AAC3D,iEAAwC;AACxC,0CAyBmB;AAEnB,MAAa,OAAQ,SAAQ,sBAAW;IAAxC;;QACE,aAAQ,GAAyB,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxE,YAAO,GAAuB,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;CAAA;AAHD,0BAGC;AAyCD,OAAO,CAAC,QAAQ,GAAG,mBAAQ,CAAC;AAC5B,OAAO,CAAC,OAAO,GAAG,iBAAO,CAAC"}
+16
View File
@@ -0,0 +1,16 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import * as SessionsAPI from "./sessions.mjs";
import { Sessions } from "./sessions.mjs";
import * as ThreadsAPI from "./threads.mjs";
import { Threads, } from "./threads.mjs";
export class ChatKit extends APIResource {
constructor() {
super(...arguments);
this.sessions = new SessionsAPI.Sessions(this._client);
this.threads = new ThreadsAPI.Threads(this._client);
}
}
ChatKit.Sessions = Sessions;
ChatKit.Threads = Threads;
//# sourceMappingURL=chatkit.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"chatkit.mjs","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/chatkit.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,mCAA+B;AACrD,OAAO,KAAK,WAAW,uBAAmB;AAC1C,OAAO,EAAuB,QAAQ,EAAE,uBAAmB;AAC3D,OAAO,KAAK,UAAU,sBAAkB;AACxC,OAAO,EAwBL,OAAO,GACR,sBAAkB;AAEnB,MAAM,OAAO,OAAQ,SAAQ,WAAW;IAAxC;;QACE,aAAQ,GAAyB,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxE,YAAO,GAAuB,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;CAAA;AAyCD,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC5B,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC"}
+4
View File
@@ -0,0 +1,4 @@
export { ChatKit, type ChatKitWorkflow } from "./chatkit.mjs";
export { Sessions, type SessionCreateParams } from "./sessions.mjs";
export { Threads, type ChatSession, type ChatSessionAutomaticThreadTitling, type ChatSessionChatKitConfiguration, type ChatSessionChatKitConfigurationParam, type ChatSessionExpiresAfterParam, type ChatSessionFileUpload, type ChatSessionHistory, type ChatSessionRateLimits, type ChatSessionRateLimitsParam, type ChatSessionStatus, type ChatSessionWorkflowParam, type ChatKitAttachment, type ChatKitResponseOutputText, type ChatKitThread, type ChatKitThreadAssistantMessageItem, type ChatKitThreadItemList, type ChatKitThreadUserMessageItem, type ChatKitWidgetItem, type ThreadDeleteResponse, type ThreadListParams, type ThreadListItemsParams, type ChatKitThreadsPage, type ChatKitThreadItemListDataPage, } from "./threads.mjs";
//# sourceMappingURL=index.d.mts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,KAAK,eAAe,EAAE,sBAAkB;AAC1D,OAAO,EAAE,QAAQ,EAAE,KAAK,mBAAmB,EAAE,uBAAmB;AAChE,OAAO,EACL,OAAO,EACP,KAAK,WAAW,EAChB,KAAK,iCAAiC,EACtC,KAAK,+BAA+B,EACpC,KAAK,oCAAoC,EACzC,KAAK,4BAA4B,EACjC,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAClB,KAAK,iCAAiC,EACtC,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,6BAA6B,GACnC,sBAAkB"}
+4
View File
@@ -0,0 +1,4 @@
export { ChatKit, type ChatKitWorkflow } from "./chatkit.js";
export { Sessions, type SessionCreateParams } from "./sessions.js";
export { Threads, type ChatSession, type ChatSessionAutomaticThreadTitling, type ChatSessionChatKitConfiguration, type ChatSessionChatKitConfigurationParam, type ChatSessionExpiresAfterParam, type ChatSessionFileUpload, type ChatSessionHistory, type ChatSessionRateLimits, type ChatSessionRateLimitsParam, type ChatSessionStatus, type ChatSessionWorkflowParam, type ChatKitAttachment, type ChatKitResponseOutputText, type ChatKitThread, type ChatKitThreadAssistantMessageItem, type ChatKitThreadItemList, type ChatKitThreadUserMessageItem, type ChatKitWidgetItem, type ThreadDeleteResponse, type ThreadListParams, type ThreadListItemsParams, type ChatKitThreadsPage, type ChatKitThreadItemListDataPage, } from "./threads.js";
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,KAAK,eAAe,EAAE,qBAAkB;AAC1D,OAAO,EAAE,QAAQ,EAAE,KAAK,mBAAmB,EAAE,sBAAmB;AAChE,OAAO,EACL,OAAO,EACP,KAAK,WAAW,EAChB,KAAK,iCAAiC,EACtC,KAAK,+BAA+B,EACpC,KAAK,oCAAoC,EACzC,KAAK,4BAA4B,EACjC,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAClB,KAAK,iCAAiC,EACtC,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,6BAA6B,GACnC,qBAAkB"}
+11
View File
@@ -0,0 +1,11 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Threads = exports.Sessions = exports.ChatKit = void 0;
var chatkit_1 = require("./chatkit.js");
Object.defineProperty(exports, "ChatKit", { enumerable: true, get: function () { return chatkit_1.ChatKit; } });
var sessions_1 = require("./sessions.js");
Object.defineProperty(exports, "Sessions", { enumerable: true, get: function () { return sessions_1.Sessions; } });
var threads_1 = require("./threads.js");
Object.defineProperty(exports, "Threads", { enumerable: true, get: function () { return threads_1.Threads; } });
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,wCAA0D;AAAjD,kGAAA,OAAO,OAAA;AAChB,0CAAgE;AAAvD,oGAAA,QAAQ,OAAA;AACjB,wCAyBmB;AAxBjB,kGAAA,OAAO,OAAA"}
+5
View File
@@ -0,0 +1,5 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
export { ChatKit } from "./chatkit.mjs";
export { Sessions } from "./sessions.mjs";
export { Threads, } from "./threads.mjs";
//# sourceMappingURL=index.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,OAAO,EAAwB,sBAAkB;AAC1D,OAAO,EAAE,QAAQ,EAA4B,uBAAmB;AAChE,OAAO,EACL,OAAO,GAwBR,sBAAkB"}
+59
View File
@@ -0,0 +1,59 @@
import { APIResource } from "../../../core/resource.mjs";
import * as ThreadsAPI from "./threads.mjs";
import { APIPromise } from "../../../core/api-promise.mjs";
import { RequestOptions } from "../../../internal/request-options.mjs";
export declare class Sessions extends APIResource {
/**
* Create a ChatKit session.
*
* @example
* ```ts
* const chatSession =
* await client.beta.chatkit.sessions.create({
* user: 'x',
* workflow: { id: 'id' },
* });
* ```
*/
create(body: SessionCreateParams, options?: RequestOptions): APIPromise<ThreadsAPI.ChatSession>;
/**
* Cancel an active ChatKit session and return its most recent metadata.
*
* Cancelling prevents new requests from using the issued client secret.
*
* @example
* ```ts
* const chatSession =
* await client.beta.chatkit.sessions.cancel('cksess_123');
* ```
*/
cancel(sessionID: string, options?: RequestOptions): APIPromise<ThreadsAPI.ChatSession>;
}
export interface SessionCreateParams {
/**
* A free-form string that identifies your end user; ensures this Session can
* access other objects that have the same `user` scope.
*/
user: string;
/**
* Workflow that powers the session.
*/
workflow: ThreadsAPI.ChatSessionWorkflowParam;
/**
* Optional overrides for ChatKit runtime configuration features
*/
chatkit_configuration?: ThreadsAPI.ChatSessionChatKitConfigurationParam;
/**
* Optional override for session expiration timing in seconds from creation.
* Defaults to 10 minutes.
*/
expires_after?: ThreadsAPI.ChatSessionExpiresAfterParam;
/**
* Optional override for per-minute request limits. When omitted, defaults to 10.
*/
rate_limits?: ThreadsAPI.ChatSessionRateLimitsParam;
}
export declare namespace Sessions {
export { type SessionCreateParams as SessionCreateParams };
}
//# sourceMappingURL=sessions.d.mts.map
@@ -0,0 +1 @@
{"version":3,"file":"sessions.d.mts","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/sessions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,mCAA+B;AACrD,OAAO,KAAK,UAAU,sBAAkB;AACxC,OAAO,EAAE,UAAU,EAAE,sCAAkC;AAEvD,OAAO,EAAE,cAAc,EAAE,8CAA0C;AAGnE,qBAAa,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC;IAS/F;;;;;;;;;;OAUG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC;CAOxF;AAED,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,QAAQ,EAAE,UAAU,CAAC,wBAAwB,CAAC;IAE9C;;OAEG;IACH,qBAAqB,CAAC,EAAE,UAAU,CAAC,oCAAoC,CAAC;IAExE;;;OAGG;IACH,aAAa,CAAC,EAAE,UAAU,CAAC,4BAA4B,CAAC;IAExD;;OAEG;IACH,WAAW,CAAC,EAAE,UAAU,CAAC,0BAA0B,CAAC;CACrD;AAED,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC;IAChC,OAAO,EAAE,KAAK,mBAAmB,IAAI,mBAAmB,EAAE,CAAC;CAC5D"}
+59
View File
@@ -0,0 +1,59 @@
import { APIResource } from "../../../core/resource.js";
import * as ThreadsAPI from "./threads.js";
import { APIPromise } from "../../../core/api-promise.js";
import { RequestOptions } from "../../../internal/request-options.js";
export declare class Sessions extends APIResource {
/**
* Create a ChatKit session.
*
* @example
* ```ts
* const chatSession =
* await client.beta.chatkit.sessions.create({
* user: 'x',
* workflow: { id: 'id' },
* });
* ```
*/
create(body: SessionCreateParams, options?: RequestOptions): APIPromise<ThreadsAPI.ChatSession>;
/**
* Cancel an active ChatKit session and return its most recent metadata.
*
* Cancelling prevents new requests from using the issued client secret.
*
* @example
* ```ts
* const chatSession =
* await client.beta.chatkit.sessions.cancel('cksess_123');
* ```
*/
cancel(sessionID: string, options?: RequestOptions): APIPromise<ThreadsAPI.ChatSession>;
}
export interface SessionCreateParams {
/**
* A free-form string that identifies your end user; ensures this Session can
* access other objects that have the same `user` scope.
*/
user: string;
/**
* Workflow that powers the session.
*/
workflow: ThreadsAPI.ChatSessionWorkflowParam;
/**
* Optional overrides for ChatKit runtime configuration features
*/
chatkit_configuration?: ThreadsAPI.ChatSessionChatKitConfigurationParam;
/**
* Optional override for session expiration timing in seconds from creation.
* Defaults to 10 minutes.
*/
expires_after?: ThreadsAPI.ChatSessionExpiresAfterParam;
/**
* Optional override for per-minute request limits. When omitted, defaults to 10.
*/
rate_limits?: ThreadsAPI.ChatSessionRateLimitsParam;
}
export declare namespace Sessions {
export { type SessionCreateParams as SessionCreateParams };
}
//# sourceMappingURL=sessions.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/sessions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,kCAA+B;AACrD,OAAO,KAAK,UAAU,qBAAkB;AACxC,OAAO,EAAE,UAAU,EAAE,qCAAkC;AAEvD,OAAO,EAAE,cAAc,EAAE,6CAA0C;AAGnE,qBAAa,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC;IAS/F;;;;;;;;;;OAUG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC;CAOxF;AAED,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,QAAQ,EAAE,UAAU,CAAC,wBAAwB,CAAC;IAE9C;;OAEG;IACH,qBAAqB,CAAC,EAAE,UAAU,CAAC,oCAAoC,CAAC;IAExE;;;OAGG;IACH,aAAa,CAAC,EAAE,UAAU,CAAC,4BAA4B,CAAC;IAExD;;OAEG;IACH,WAAW,CAAC,EAAE,UAAU,CAAC,0BAA0B,CAAC;CACrD;AAED,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC;IAChC,OAAO,EAAE,KAAK,mBAAmB,IAAI,mBAAmB,EAAE,CAAC;CAC5D"}
+49
View File
@@ -0,0 +1,49 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Sessions = void 0;
const resource_1 = require("../../../core/resource.js");
const headers_1 = require("../../../internal/headers.js");
const path_1 = require("../../../internal/utils/path.js");
class Sessions extends resource_1.APIResource {
/**
* Create a ChatKit session.
*
* @example
* ```ts
* const chatSession =
* await client.beta.chatkit.sessions.create({
* user: 'x',
* workflow: { id: 'id' },
* });
* ```
*/
create(body, options) {
return this._client.post('/chatkit/sessions', {
body,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Cancel an active ChatKit session and return its most recent metadata.
*
* Cancelling prevents new requests from using the issued client secret.
*
* @example
* ```ts
* const chatSession =
* await client.beta.chatkit.sessions.cancel('cksess_123');
* ```
*/
cancel(sessionID, options) {
return this._client.post((0, path_1.path) `/chatkit/sessions/${sessionID}/cancel`, {
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
}
exports.Sessions = Sessions;
//# sourceMappingURL=sessions.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/sessions.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,wDAAqD;AAGrD,0DAAyD;AAEzD,0DAAoD;AAEpD,MAAa,QAAS,SAAQ,sBAAW;IACvC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,IAAyB,EAAE,OAAwB;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE;YAC5C,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,SAAiB,EAAE,OAAwB;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,WAAI,EAAA,qBAAqB,SAAS,SAAS,EAAE;YACpE,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;CACF;AAxCD,4BAwCC"}
+45
View File
@@ -0,0 +1,45 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import { buildHeaders } from "../../../internal/headers.mjs";
import { path } from "../../../internal/utils/path.mjs";
export class Sessions extends APIResource {
/**
* Create a ChatKit session.
*
* @example
* ```ts
* const chatSession =
* await client.beta.chatkit.sessions.create({
* user: 'x',
* workflow: { id: 'id' },
* });
* ```
*/
create(body, options) {
return this._client.post('/chatkit/sessions', {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Cancel an active ChatKit session and return its most recent metadata.
*
* Cancelling prevents new requests from using the issued client secret.
*
* @example
* ```ts
* const chatSession =
* await client.beta.chatkit.sessions.cancel('cksess_123');
* ```
*/
cancel(sessionID, options) {
return this._client.post(path `/chatkit/sessions/${sessionID}/cancel`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
}
//# sourceMappingURL=sessions.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"sessions.mjs","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/sessions.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,mCAA+B;AAGrD,OAAO,EAAE,YAAY,EAAE,sCAAkC;AAEzD,OAAO,EAAE,IAAI,EAAE,yCAAqC;AAEpD,MAAM,OAAO,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,IAAyB,EAAE,OAAwB;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE;YAC5C,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,SAAiB,EAAE,OAAwB;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAA,qBAAqB,SAAS,SAAS,EAAE;YACpE,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;CACF"}
+811
View File
@@ -0,0 +1,811 @@
import { APIResource } from "../../../core/resource.mjs";
import * as ChatKitAPI from "./chatkit.mjs";
import { APIPromise } from "../../../core/api-promise.mjs";
import { ConversationCursorPage, type ConversationCursorPageParams, PagePromise } from "../../../core/pagination.mjs";
import { RequestOptions } from "../../../internal/request-options.mjs";
export declare class Threads extends APIResource {
/**
* Retrieve a ChatKit thread by its identifier.
*
* @example
* ```ts
* const chatkitThread =
* await client.beta.chatkit.threads.retrieve('cthr_123');
* ```
*/
retrieve(threadID: string, options?: RequestOptions): APIPromise<ChatKitThread>;
/**
* List ChatKit threads with optional pagination and user filters.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const chatkitThread of client.beta.chatkit.threads.list()) {
* // ...
* }
* ```
*/
list(query?: ThreadListParams | null | undefined, options?: RequestOptions): PagePromise<ChatKitThreadsPage, ChatKitThread>;
/**
* Delete a ChatKit thread along with its items and stored attachments.
*
* @example
* ```ts
* const thread = await client.beta.chatkit.threads.delete(
* 'cthr_123',
* );
* ```
*/
delete(threadID: string, options?: RequestOptions): APIPromise<ThreadDeleteResponse>;
/**
* List items that belong to a ChatKit thread.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const thread of client.beta.chatkit.threads.listItems(
* 'cthr_123',
* )) {
* // ...
* }
* ```
*/
listItems(threadID: string, query?: ThreadListItemsParams | null | undefined, options?: RequestOptions): PagePromise<ChatKitThreadItemListDataPage, ChatKitThreadUserMessageItem | ChatKitThreadAssistantMessageItem | ChatKitWidgetItem | ChatKitThreadItemList.ChatKitClientToolCall | ChatKitThreadItemList.ChatKitTask | ChatKitThreadItemList.ChatKitTaskGroup>;
}
export type ChatKitThreadsPage = ConversationCursorPage<ChatKitThread>;
export type ChatKitThreadItemListDataPage = ConversationCursorPage<ChatKitThreadUserMessageItem | ChatKitThreadAssistantMessageItem | ChatKitWidgetItem | ChatKitThreadItemList.ChatKitClientToolCall | ChatKitThreadItemList.ChatKitTask | ChatKitThreadItemList.ChatKitTaskGroup>;
/**
* Represents a ChatKit session and its resolved configuration.
*/
export interface ChatSession {
/**
* Identifier for the ChatKit session.
*/
id: string;
/**
* Resolved ChatKit feature configuration for the session.
*/
chatkit_configuration: ChatSessionChatKitConfiguration;
/**
* Ephemeral client secret that authenticates session requests.
*/
client_secret: string;
/**
* Unix timestamp (in seconds) for when the session expires.
*/
expires_at: number;
/**
* Convenience copy of the per-minute request limit.
*/
max_requests_per_1_minute: number;
/**
* Type discriminator that is always `chatkit.session`.
*/
object: 'chatkit.session';
/**
* Resolved rate limit values.
*/
rate_limits: ChatSessionRateLimits;
/**
* Current lifecycle state of the session.
*/
status: ChatSessionStatus;
/**
* User identifier associated with the session.
*/
user: string;
/**
* Workflow metadata for the session.
*/
workflow: ChatKitAPI.ChatKitWorkflow;
}
/**
* Automatic thread title preferences for the session.
*/
export interface ChatSessionAutomaticThreadTitling {
/**
* Whether automatic thread titling is enabled.
*/
enabled: boolean;
}
/**
* ChatKit configuration for the session.
*/
export interface ChatSessionChatKitConfiguration {
/**
* Automatic thread titling preferences.
*/
automatic_thread_titling: ChatSessionAutomaticThreadTitling;
/**
* Upload settings for the session.
*/
file_upload: ChatSessionFileUpload;
/**
* History retention configuration.
*/
history: ChatSessionHistory;
}
/**
* Optional per-session configuration settings for ChatKit behavior.
*/
export interface ChatSessionChatKitConfigurationParam {
/**
* Configuration for automatic thread titling. When omitted, automatic thread
* titling is enabled by default.
*/
automatic_thread_titling?: ChatSessionChatKitConfigurationParam.AutomaticThreadTitling;
/**
* Configuration for upload enablement and limits. When omitted, uploads are
* disabled by default (max_files 10, max_file_size 512 MB).
*/
file_upload?: ChatSessionChatKitConfigurationParam.FileUpload;
/**
* Configuration for chat history retention. When omitted, history is enabled by
* default with no limit on recent_threads (null).
*/
history?: ChatSessionChatKitConfigurationParam.History;
}
export declare namespace ChatSessionChatKitConfigurationParam {
/**
* Configuration for automatic thread titling. When omitted, automatic thread
* titling is enabled by default.
*/
interface AutomaticThreadTitling {
/**
* Enable automatic thread title generation. Defaults to true.
*/
enabled?: boolean;
}
/**
* Configuration for upload enablement and limits. When omitted, uploads are
* disabled by default (max_files 10, max_file_size 512 MB).
*/
interface FileUpload {
/**
* Enable uploads for this session. Defaults to false.
*/
enabled?: boolean;
/**
* Maximum size in megabytes for each uploaded file. Defaults to 512 MB, which is
* the maximum allowable size.
*/
max_file_size?: number;
/**
* Maximum number of files that can be uploaded to the session. Defaults to 10.
*/
max_files?: number;
}
/**
* Configuration for chat history retention. When omitted, history is enabled by
* default with no limit on recent_threads (null).
*/
interface History {
/**
* Enables chat users to access previous ChatKit threads. Defaults to true.
*/
enabled?: boolean;
/**
* Number of recent ChatKit threads users have access to. Defaults to unlimited
* when unset.
*/
recent_threads?: number;
}
}
/**
* Controls when the session expires relative to an anchor timestamp.
*/
export interface ChatSessionExpiresAfterParam {
/**
* Base timestamp used to calculate expiration. Currently fixed to `created_at`.
*/
anchor: 'created_at';
/**
* Number of seconds after the anchor when the session expires.
*/
seconds: number;
}
/**
* Upload permissions and limits applied to the session.
*/
export interface ChatSessionFileUpload {
/**
* Indicates if uploads are enabled for the session.
*/
enabled: boolean;
/**
* Maximum upload size in megabytes.
*/
max_file_size: number | null;
/**
* Maximum number of uploads allowed during the session.
*/
max_files: number | null;
}
/**
* History retention preferences returned for the session.
*/
export interface ChatSessionHistory {
/**
* Indicates if chat history is persisted for the session.
*/
enabled: boolean;
/**
* Number of prior threads surfaced in history views. Defaults to null when all
* history is retained.
*/
recent_threads: number | null;
}
/**
* Active per-minute request limit for the session.
*/
export interface ChatSessionRateLimits {
/**
* Maximum allowed requests per one-minute window.
*/
max_requests_per_1_minute: number;
}
/**
* Controls request rate limits for the session.
*/
export interface ChatSessionRateLimitsParam {
/**
* Maximum number of requests allowed per minute for the session. Defaults to 10.
*/
max_requests_per_1_minute?: number;
}
export type ChatSessionStatus = 'active' | 'expired' | 'cancelled';
/**
* Workflow reference and overrides applied to the chat session.
*/
export interface ChatSessionWorkflowParam {
/**
* Identifier for the workflow invoked by the session.
*/
id: string;
/**
* State variables forwarded to the workflow. Keys may be up to 64 characters,
* values must be primitive types, and the map defaults to an empty object.
*/
state_variables?: {
[key: string]: string | boolean | number;
};
/**
* Optional tracing overrides for the workflow invocation. When omitted, tracing is
* enabled by default.
*/
tracing?: ChatSessionWorkflowParam.Tracing;
/**
* Specific workflow version to run. Defaults to the latest deployed version.
*/
version?: string;
}
export declare namespace ChatSessionWorkflowParam {
/**
* Optional tracing overrides for the workflow invocation. When omitted, tracing is
* enabled by default.
*/
interface Tracing {
/**
* Whether tracing is enabled during the session. Defaults to true.
*/
enabled?: boolean;
}
}
/**
* Attachment metadata included on thread items.
*/
export interface ChatKitAttachment {
/**
* Identifier for the attachment.
*/
id: string;
/**
* MIME type of the attachment.
*/
mime_type: string;
/**
* Original display name for the attachment.
*/
name: string;
/**
* Preview URL for rendering the attachment inline.
*/
preview_url: string | null;
/**
* Attachment discriminator.
*/
type: 'image' | 'file';
}
/**
* Assistant response text accompanied by optional annotations.
*/
export interface ChatKitResponseOutputText {
/**
* Ordered list of annotations attached to the response text.
*/
annotations: Array<ChatKitResponseOutputText.File | ChatKitResponseOutputText.URL>;
/**
* Assistant generated text.
*/
text: string;
/**
* Type discriminator that is always `output_text`.
*/
type: 'output_text';
}
export declare namespace ChatKitResponseOutputText {
/**
* Annotation that references an uploaded file.
*/
interface File {
/**
* File attachment referenced by the annotation.
*/
source: File.Source;
/**
* Type discriminator that is always `file` for this annotation.
*/
type: 'file';
}
namespace File {
/**
* File attachment referenced by the annotation.
*/
interface Source {
/**
* Filename referenced by the annotation.
*/
filename: string;
/**
* Type discriminator that is always `file`.
*/
type: 'file';
}
}
/**
* Annotation that references a URL.
*/
interface URL {
/**
* URL referenced by the annotation.
*/
source: URL.Source;
/**
* Type discriminator that is always `url` for this annotation.
*/
type: 'url';
}
namespace URL {
/**
* URL referenced by the annotation.
*/
interface Source {
/**
* Type discriminator that is always `url`.
*/
type: 'url';
/**
* URL referenced by the annotation.
*/
url: string;
}
}
}
/**
* Represents a ChatKit thread and its current status.
*/
export interface ChatKitThread {
/**
* Identifier of the thread.
*/
id: string;
/**
* Unix timestamp (in seconds) for when the thread was created.
*/
created_at: number;
/**
* Type discriminator that is always `chatkit.thread`.
*/
object: 'chatkit.thread';
/**
* Current status for the thread. Defaults to `active` for newly created threads.
*/
status: ChatKitThread.Active | ChatKitThread.Locked | ChatKitThread.Closed;
/**
* Optional human-readable title for the thread. Defaults to null when no title has
* been generated.
*/
title: string | null;
/**
* Free-form string that identifies your end user who owns the thread.
*/
user: string;
}
export declare namespace ChatKitThread {
/**
* Indicates that a thread is active.
*/
interface Active {
/**
* Status discriminator that is always `active`.
*/
type: 'active';
}
/**
* Indicates that a thread is locked and cannot accept new input.
*/
interface Locked {
/**
* Reason that the thread was locked. Defaults to null when no reason is recorded.
*/
reason: string | null;
/**
* Status discriminator that is always `locked`.
*/
type: 'locked';
}
/**
* Indicates that a thread has been closed.
*/
interface Closed {
/**
* Reason that the thread was closed. Defaults to null when no reason is recorded.
*/
reason: string | null;
/**
* Status discriminator that is always `closed`.
*/
type: 'closed';
}
}
/**
* Assistant-authored message within a thread.
*/
export interface ChatKitThreadAssistantMessageItem {
/**
* Identifier of the thread item.
*/
id: string;
/**
* Ordered assistant response segments.
*/
content: Array<ChatKitResponseOutputText>;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* Identifier of the parent thread.
*/
thread_id: string;
/**
* Type discriminator that is always `chatkit.assistant_message`.
*/
type: 'chatkit.assistant_message';
}
/**
* A paginated list of thread items rendered for the ChatKit API.
*/
export interface ChatKitThreadItemList {
/**
* A list of items
*/
data: Array<ChatKitThreadUserMessageItem | ChatKitThreadAssistantMessageItem | ChatKitWidgetItem | ChatKitThreadItemList.ChatKitClientToolCall | ChatKitThreadItemList.ChatKitTask | ChatKitThreadItemList.ChatKitTaskGroup>;
/**
* The ID of the first item in the list.
*/
first_id: string | null;
/**
* Whether there are more items available.
*/
has_more: boolean;
/**
* The ID of the last item in the list.
*/
last_id: string | null;
/**
* The type of object returned, must be `list`.
*/
object: 'list';
}
export declare namespace ChatKitThreadItemList {
/**
* Record of a client side tool invocation initiated by the assistant.
*/
interface ChatKitClientToolCall {
/**
* Identifier of the thread item.
*/
id: string;
/**
* JSON-encoded arguments that were sent to the tool.
*/
arguments: string;
/**
* Identifier for the client tool call.
*/
call_id: string;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Tool name that was invoked.
*/
name: string;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* JSON-encoded output captured from the tool. Defaults to null while execution is
* in progress.
*/
output: string | null;
/**
* Execution status for the tool call.
*/
status: 'in_progress' | 'completed';
/**
* Identifier of the parent thread.
*/
thread_id: string;
/**
* Type discriminator that is always `chatkit.client_tool_call`.
*/
type: 'chatkit.client_tool_call';
}
/**
* Task emitted by the workflow to show progress and status updates.
*/
interface ChatKitTask {
/**
* Identifier of the thread item.
*/
id: string;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Optional heading for the task. Defaults to null when not provided.
*/
heading: string | null;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* Optional summary that describes the task. Defaults to null when omitted.
*/
summary: string | null;
/**
* Subtype for the task.
*/
task_type: 'custom' | 'thought';
/**
* Identifier of the parent thread.
*/
thread_id: string;
/**
* Type discriminator that is always `chatkit.task`.
*/
type: 'chatkit.task';
}
/**
* Collection of workflow tasks grouped together in the thread.
*/
interface ChatKitTaskGroup {
/**
* Identifier of the thread item.
*/
id: string;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* Tasks included in the group.
*/
tasks: Array<ChatKitTaskGroup.Task>;
/**
* Identifier of the parent thread.
*/
thread_id: string;
/**
* Type discriminator that is always `chatkit.task_group`.
*/
type: 'chatkit.task_group';
}
namespace ChatKitTaskGroup {
/**
* Task entry that appears within a TaskGroup.
*/
interface Task {
/**
* Optional heading for the grouped task. Defaults to null when not provided.
*/
heading: string | null;
/**
* Optional summary that describes the grouped task. Defaults to null when omitted.
*/
summary: string | null;
/**
* Subtype for the grouped task.
*/
type: 'custom' | 'thought';
}
}
}
/**
* User-authored messages within a thread.
*/
export interface ChatKitThreadUserMessageItem {
/**
* Identifier of the thread item.
*/
id: string;
/**
* Attachments associated with the user message. Defaults to an empty list.
*/
attachments: Array<ChatKitAttachment>;
/**
* Ordered content elements supplied by the user.
*/
content: Array<ChatKitThreadUserMessageItem.InputText | ChatKitThreadUserMessageItem.QuotedText>;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Inference overrides applied to the message. Defaults to null when unset.
*/
inference_options: ChatKitThreadUserMessageItem.InferenceOptions | null;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* Identifier of the parent thread.
*/
thread_id: string;
type: 'chatkit.user_message';
}
export declare namespace ChatKitThreadUserMessageItem {
/**
* Text block that a user contributed to the thread.
*/
interface InputText {
/**
* Plain-text content supplied by the user.
*/
text: string;
/**
* Type discriminator that is always `input_text`.
*/
type: 'input_text';
}
/**
* Quoted snippet that the user referenced in their message.
*/
interface QuotedText {
/**
* Quoted text content.
*/
text: string;
/**
* Type discriminator that is always `quoted_text`.
*/
type: 'quoted_text';
}
/**
* Inference overrides applied to the message. Defaults to null when unset.
*/
interface InferenceOptions {
/**
* Model name that generated the response. Defaults to null when using the session
* default.
*/
model: string | null;
/**
* Preferred tool to invoke. Defaults to null when ChatKit should auto-select.
*/
tool_choice: InferenceOptions.ToolChoice | null;
}
namespace InferenceOptions {
/**
* Preferred tool to invoke. Defaults to null when ChatKit should auto-select.
*/
interface ToolChoice {
/**
* Identifier of the requested tool.
*/
id: string;
}
}
}
/**
* Thread item that renders a widget payload.
*/
export interface ChatKitWidgetItem {
/**
* Identifier of the thread item.
*/
id: string;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* Identifier of the parent thread.
*/
thread_id: string;
/**
* Type discriminator that is always `chatkit.widget`.
*/
type: 'chatkit.widget';
/**
* Serialized widget payload rendered in the UI.
*/
widget: string;
}
/**
* Confirmation payload returned after deleting a thread.
*/
export interface ThreadDeleteResponse {
/**
* Identifier of the deleted thread.
*/
id: string;
/**
* Indicates that the thread has been deleted.
*/
deleted: boolean;
/**
* Type discriminator that is always `chatkit.thread.deleted`.
*/
object: 'chatkit.thread.deleted';
}
export interface ThreadListParams extends ConversationCursorPageParams {
/**
* List items created before this thread item ID. Defaults to null for the newest
* results.
*/
before?: string;
/**
* Sort order for results by creation time. Defaults to `desc`.
*/
order?: 'asc' | 'desc';
/**
* Filter threads that belong to this user identifier. Defaults to null to return
* all users.
*/
user?: string;
}
export interface ThreadListItemsParams extends ConversationCursorPageParams {
/**
* List items created before this thread item ID. Defaults to null for the newest
* results.
*/
before?: string;
/**
* Sort order for results by creation time. Defaults to `desc`.
*/
order?: 'asc' | 'desc';
}
export declare namespace Threads {
export { type ChatSession as ChatSession, type ChatSessionAutomaticThreadTitling as ChatSessionAutomaticThreadTitling, type ChatSessionChatKitConfiguration as ChatSessionChatKitConfiguration, type ChatSessionChatKitConfigurationParam as ChatSessionChatKitConfigurationParam, type ChatSessionExpiresAfterParam as ChatSessionExpiresAfterParam, type ChatSessionFileUpload as ChatSessionFileUpload, type ChatSessionHistory as ChatSessionHistory, type ChatSessionRateLimits as ChatSessionRateLimits, type ChatSessionRateLimitsParam as ChatSessionRateLimitsParam, type ChatSessionStatus as ChatSessionStatus, type ChatSessionWorkflowParam as ChatSessionWorkflowParam, type ChatKitAttachment as ChatKitAttachment, type ChatKitResponseOutputText as ChatKitResponseOutputText, type ChatKitThread as ChatKitThread, type ChatKitThreadAssistantMessageItem as ChatKitThreadAssistantMessageItem, type ChatKitThreadItemList as ChatKitThreadItemList, type ChatKitThreadUserMessageItem as ChatKitThreadUserMessageItem, type ChatKitWidgetItem as ChatKitWidgetItem, type ThreadDeleteResponse as ThreadDeleteResponse, type ChatKitThreadsPage as ChatKitThreadsPage, type ChatKitThreadItemListDataPage as ChatKitThreadItemListDataPage, type ThreadListParams as ThreadListParams, type ThreadListItemsParams as ThreadListItemsParams, };
}
//# sourceMappingURL=threads.d.mts.map
File diff suppressed because one or more lines are too long
+811
View File
@@ -0,0 +1,811 @@
import { APIResource } from "../../../core/resource.js";
import * as ChatKitAPI from "./chatkit.js";
import { APIPromise } from "../../../core/api-promise.js";
import { ConversationCursorPage, type ConversationCursorPageParams, PagePromise } from "../../../core/pagination.js";
import { RequestOptions } from "../../../internal/request-options.js";
export declare class Threads extends APIResource {
/**
* Retrieve a ChatKit thread by its identifier.
*
* @example
* ```ts
* const chatkitThread =
* await client.beta.chatkit.threads.retrieve('cthr_123');
* ```
*/
retrieve(threadID: string, options?: RequestOptions): APIPromise<ChatKitThread>;
/**
* List ChatKit threads with optional pagination and user filters.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const chatkitThread of client.beta.chatkit.threads.list()) {
* // ...
* }
* ```
*/
list(query?: ThreadListParams | null | undefined, options?: RequestOptions): PagePromise<ChatKitThreadsPage, ChatKitThread>;
/**
* Delete a ChatKit thread along with its items and stored attachments.
*
* @example
* ```ts
* const thread = await client.beta.chatkit.threads.delete(
* 'cthr_123',
* );
* ```
*/
delete(threadID: string, options?: RequestOptions): APIPromise<ThreadDeleteResponse>;
/**
* List items that belong to a ChatKit thread.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const thread of client.beta.chatkit.threads.listItems(
* 'cthr_123',
* )) {
* // ...
* }
* ```
*/
listItems(threadID: string, query?: ThreadListItemsParams | null | undefined, options?: RequestOptions): PagePromise<ChatKitThreadItemListDataPage, ChatKitThreadUserMessageItem | ChatKitThreadAssistantMessageItem | ChatKitWidgetItem | ChatKitThreadItemList.ChatKitClientToolCall | ChatKitThreadItemList.ChatKitTask | ChatKitThreadItemList.ChatKitTaskGroup>;
}
export type ChatKitThreadsPage = ConversationCursorPage<ChatKitThread>;
export type ChatKitThreadItemListDataPage = ConversationCursorPage<ChatKitThreadUserMessageItem | ChatKitThreadAssistantMessageItem | ChatKitWidgetItem | ChatKitThreadItemList.ChatKitClientToolCall | ChatKitThreadItemList.ChatKitTask | ChatKitThreadItemList.ChatKitTaskGroup>;
/**
* Represents a ChatKit session and its resolved configuration.
*/
export interface ChatSession {
/**
* Identifier for the ChatKit session.
*/
id: string;
/**
* Resolved ChatKit feature configuration for the session.
*/
chatkit_configuration: ChatSessionChatKitConfiguration;
/**
* Ephemeral client secret that authenticates session requests.
*/
client_secret: string;
/**
* Unix timestamp (in seconds) for when the session expires.
*/
expires_at: number;
/**
* Convenience copy of the per-minute request limit.
*/
max_requests_per_1_minute: number;
/**
* Type discriminator that is always `chatkit.session`.
*/
object: 'chatkit.session';
/**
* Resolved rate limit values.
*/
rate_limits: ChatSessionRateLimits;
/**
* Current lifecycle state of the session.
*/
status: ChatSessionStatus;
/**
* User identifier associated with the session.
*/
user: string;
/**
* Workflow metadata for the session.
*/
workflow: ChatKitAPI.ChatKitWorkflow;
}
/**
* Automatic thread title preferences for the session.
*/
export interface ChatSessionAutomaticThreadTitling {
/**
* Whether automatic thread titling is enabled.
*/
enabled: boolean;
}
/**
* ChatKit configuration for the session.
*/
export interface ChatSessionChatKitConfiguration {
/**
* Automatic thread titling preferences.
*/
automatic_thread_titling: ChatSessionAutomaticThreadTitling;
/**
* Upload settings for the session.
*/
file_upload: ChatSessionFileUpload;
/**
* History retention configuration.
*/
history: ChatSessionHistory;
}
/**
* Optional per-session configuration settings for ChatKit behavior.
*/
export interface ChatSessionChatKitConfigurationParam {
/**
* Configuration for automatic thread titling. When omitted, automatic thread
* titling is enabled by default.
*/
automatic_thread_titling?: ChatSessionChatKitConfigurationParam.AutomaticThreadTitling;
/**
* Configuration for upload enablement and limits. When omitted, uploads are
* disabled by default (max_files 10, max_file_size 512 MB).
*/
file_upload?: ChatSessionChatKitConfigurationParam.FileUpload;
/**
* Configuration for chat history retention. When omitted, history is enabled by
* default with no limit on recent_threads (null).
*/
history?: ChatSessionChatKitConfigurationParam.History;
}
export declare namespace ChatSessionChatKitConfigurationParam {
/**
* Configuration for automatic thread titling. When omitted, automatic thread
* titling is enabled by default.
*/
interface AutomaticThreadTitling {
/**
* Enable automatic thread title generation. Defaults to true.
*/
enabled?: boolean;
}
/**
* Configuration for upload enablement and limits. When omitted, uploads are
* disabled by default (max_files 10, max_file_size 512 MB).
*/
interface FileUpload {
/**
* Enable uploads for this session. Defaults to false.
*/
enabled?: boolean;
/**
* Maximum size in megabytes for each uploaded file. Defaults to 512 MB, which is
* the maximum allowable size.
*/
max_file_size?: number;
/**
* Maximum number of files that can be uploaded to the session. Defaults to 10.
*/
max_files?: number;
}
/**
* Configuration for chat history retention. When omitted, history is enabled by
* default with no limit on recent_threads (null).
*/
interface History {
/**
* Enables chat users to access previous ChatKit threads. Defaults to true.
*/
enabled?: boolean;
/**
* Number of recent ChatKit threads users have access to. Defaults to unlimited
* when unset.
*/
recent_threads?: number;
}
}
/**
* Controls when the session expires relative to an anchor timestamp.
*/
export interface ChatSessionExpiresAfterParam {
/**
* Base timestamp used to calculate expiration. Currently fixed to `created_at`.
*/
anchor: 'created_at';
/**
* Number of seconds after the anchor when the session expires.
*/
seconds: number;
}
/**
* Upload permissions and limits applied to the session.
*/
export interface ChatSessionFileUpload {
/**
* Indicates if uploads are enabled for the session.
*/
enabled: boolean;
/**
* Maximum upload size in megabytes.
*/
max_file_size: number | null;
/**
* Maximum number of uploads allowed during the session.
*/
max_files: number | null;
}
/**
* History retention preferences returned for the session.
*/
export interface ChatSessionHistory {
/**
* Indicates if chat history is persisted for the session.
*/
enabled: boolean;
/**
* Number of prior threads surfaced in history views. Defaults to null when all
* history is retained.
*/
recent_threads: number | null;
}
/**
* Active per-minute request limit for the session.
*/
export interface ChatSessionRateLimits {
/**
* Maximum allowed requests per one-minute window.
*/
max_requests_per_1_minute: number;
}
/**
* Controls request rate limits for the session.
*/
export interface ChatSessionRateLimitsParam {
/**
* Maximum number of requests allowed per minute for the session. Defaults to 10.
*/
max_requests_per_1_minute?: number;
}
export type ChatSessionStatus = 'active' | 'expired' | 'cancelled';
/**
* Workflow reference and overrides applied to the chat session.
*/
export interface ChatSessionWorkflowParam {
/**
* Identifier for the workflow invoked by the session.
*/
id: string;
/**
* State variables forwarded to the workflow. Keys may be up to 64 characters,
* values must be primitive types, and the map defaults to an empty object.
*/
state_variables?: {
[key: string]: string | boolean | number;
};
/**
* Optional tracing overrides for the workflow invocation. When omitted, tracing is
* enabled by default.
*/
tracing?: ChatSessionWorkflowParam.Tracing;
/**
* Specific workflow version to run. Defaults to the latest deployed version.
*/
version?: string;
}
export declare namespace ChatSessionWorkflowParam {
/**
* Optional tracing overrides for the workflow invocation. When omitted, tracing is
* enabled by default.
*/
interface Tracing {
/**
* Whether tracing is enabled during the session. Defaults to true.
*/
enabled?: boolean;
}
}
/**
* Attachment metadata included on thread items.
*/
export interface ChatKitAttachment {
/**
* Identifier for the attachment.
*/
id: string;
/**
* MIME type of the attachment.
*/
mime_type: string;
/**
* Original display name for the attachment.
*/
name: string;
/**
* Preview URL for rendering the attachment inline.
*/
preview_url: string | null;
/**
* Attachment discriminator.
*/
type: 'image' | 'file';
}
/**
* Assistant response text accompanied by optional annotations.
*/
export interface ChatKitResponseOutputText {
/**
* Ordered list of annotations attached to the response text.
*/
annotations: Array<ChatKitResponseOutputText.File | ChatKitResponseOutputText.URL>;
/**
* Assistant generated text.
*/
text: string;
/**
* Type discriminator that is always `output_text`.
*/
type: 'output_text';
}
export declare namespace ChatKitResponseOutputText {
/**
* Annotation that references an uploaded file.
*/
interface File {
/**
* File attachment referenced by the annotation.
*/
source: File.Source;
/**
* Type discriminator that is always `file` for this annotation.
*/
type: 'file';
}
namespace File {
/**
* File attachment referenced by the annotation.
*/
interface Source {
/**
* Filename referenced by the annotation.
*/
filename: string;
/**
* Type discriminator that is always `file`.
*/
type: 'file';
}
}
/**
* Annotation that references a URL.
*/
interface URL {
/**
* URL referenced by the annotation.
*/
source: URL.Source;
/**
* Type discriminator that is always `url` for this annotation.
*/
type: 'url';
}
namespace URL {
/**
* URL referenced by the annotation.
*/
interface Source {
/**
* Type discriminator that is always `url`.
*/
type: 'url';
/**
* URL referenced by the annotation.
*/
url: string;
}
}
}
/**
* Represents a ChatKit thread and its current status.
*/
export interface ChatKitThread {
/**
* Identifier of the thread.
*/
id: string;
/**
* Unix timestamp (in seconds) for when the thread was created.
*/
created_at: number;
/**
* Type discriminator that is always `chatkit.thread`.
*/
object: 'chatkit.thread';
/**
* Current status for the thread. Defaults to `active` for newly created threads.
*/
status: ChatKitThread.Active | ChatKitThread.Locked | ChatKitThread.Closed;
/**
* Optional human-readable title for the thread. Defaults to null when no title has
* been generated.
*/
title: string | null;
/**
* Free-form string that identifies your end user who owns the thread.
*/
user: string;
}
export declare namespace ChatKitThread {
/**
* Indicates that a thread is active.
*/
interface Active {
/**
* Status discriminator that is always `active`.
*/
type: 'active';
}
/**
* Indicates that a thread is locked and cannot accept new input.
*/
interface Locked {
/**
* Reason that the thread was locked. Defaults to null when no reason is recorded.
*/
reason: string | null;
/**
* Status discriminator that is always `locked`.
*/
type: 'locked';
}
/**
* Indicates that a thread has been closed.
*/
interface Closed {
/**
* Reason that the thread was closed. Defaults to null when no reason is recorded.
*/
reason: string | null;
/**
* Status discriminator that is always `closed`.
*/
type: 'closed';
}
}
/**
* Assistant-authored message within a thread.
*/
export interface ChatKitThreadAssistantMessageItem {
/**
* Identifier of the thread item.
*/
id: string;
/**
* Ordered assistant response segments.
*/
content: Array<ChatKitResponseOutputText>;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* Identifier of the parent thread.
*/
thread_id: string;
/**
* Type discriminator that is always `chatkit.assistant_message`.
*/
type: 'chatkit.assistant_message';
}
/**
* A paginated list of thread items rendered for the ChatKit API.
*/
export interface ChatKitThreadItemList {
/**
* A list of items
*/
data: Array<ChatKitThreadUserMessageItem | ChatKitThreadAssistantMessageItem | ChatKitWidgetItem | ChatKitThreadItemList.ChatKitClientToolCall | ChatKitThreadItemList.ChatKitTask | ChatKitThreadItemList.ChatKitTaskGroup>;
/**
* The ID of the first item in the list.
*/
first_id: string | null;
/**
* Whether there are more items available.
*/
has_more: boolean;
/**
* The ID of the last item in the list.
*/
last_id: string | null;
/**
* The type of object returned, must be `list`.
*/
object: 'list';
}
export declare namespace ChatKitThreadItemList {
/**
* Record of a client side tool invocation initiated by the assistant.
*/
interface ChatKitClientToolCall {
/**
* Identifier of the thread item.
*/
id: string;
/**
* JSON-encoded arguments that were sent to the tool.
*/
arguments: string;
/**
* Identifier for the client tool call.
*/
call_id: string;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Tool name that was invoked.
*/
name: string;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* JSON-encoded output captured from the tool. Defaults to null while execution is
* in progress.
*/
output: string | null;
/**
* Execution status for the tool call.
*/
status: 'in_progress' | 'completed';
/**
* Identifier of the parent thread.
*/
thread_id: string;
/**
* Type discriminator that is always `chatkit.client_tool_call`.
*/
type: 'chatkit.client_tool_call';
}
/**
* Task emitted by the workflow to show progress and status updates.
*/
interface ChatKitTask {
/**
* Identifier of the thread item.
*/
id: string;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Optional heading for the task. Defaults to null when not provided.
*/
heading: string | null;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* Optional summary that describes the task. Defaults to null when omitted.
*/
summary: string | null;
/**
* Subtype for the task.
*/
task_type: 'custom' | 'thought';
/**
* Identifier of the parent thread.
*/
thread_id: string;
/**
* Type discriminator that is always `chatkit.task`.
*/
type: 'chatkit.task';
}
/**
* Collection of workflow tasks grouped together in the thread.
*/
interface ChatKitTaskGroup {
/**
* Identifier of the thread item.
*/
id: string;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* Tasks included in the group.
*/
tasks: Array<ChatKitTaskGroup.Task>;
/**
* Identifier of the parent thread.
*/
thread_id: string;
/**
* Type discriminator that is always `chatkit.task_group`.
*/
type: 'chatkit.task_group';
}
namespace ChatKitTaskGroup {
/**
* Task entry that appears within a TaskGroup.
*/
interface Task {
/**
* Optional heading for the grouped task. Defaults to null when not provided.
*/
heading: string | null;
/**
* Optional summary that describes the grouped task. Defaults to null when omitted.
*/
summary: string | null;
/**
* Subtype for the grouped task.
*/
type: 'custom' | 'thought';
}
}
}
/**
* User-authored messages within a thread.
*/
export interface ChatKitThreadUserMessageItem {
/**
* Identifier of the thread item.
*/
id: string;
/**
* Attachments associated with the user message. Defaults to an empty list.
*/
attachments: Array<ChatKitAttachment>;
/**
* Ordered content elements supplied by the user.
*/
content: Array<ChatKitThreadUserMessageItem.InputText | ChatKitThreadUserMessageItem.QuotedText>;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Inference overrides applied to the message. Defaults to null when unset.
*/
inference_options: ChatKitThreadUserMessageItem.InferenceOptions | null;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* Identifier of the parent thread.
*/
thread_id: string;
type: 'chatkit.user_message';
}
export declare namespace ChatKitThreadUserMessageItem {
/**
* Text block that a user contributed to the thread.
*/
interface InputText {
/**
* Plain-text content supplied by the user.
*/
text: string;
/**
* Type discriminator that is always `input_text`.
*/
type: 'input_text';
}
/**
* Quoted snippet that the user referenced in their message.
*/
interface QuotedText {
/**
* Quoted text content.
*/
text: string;
/**
* Type discriminator that is always `quoted_text`.
*/
type: 'quoted_text';
}
/**
* Inference overrides applied to the message. Defaults to null when unset.
*/
interface InferenceOptions {
/**
* Model name that generated the response. Defaults to null when using the session
* default.
*/
model: string | null;
/**
* Preferred tool to invoke. Defaults to null when ChatKit should auto-select.
*/
tool_choice: InferenceOptions.ToolChoice | null;
}
namespace InferenceOptions {
/**
* Preferred tool to invoke. Defaults to null when ChatKit should auto-select.
*/
interface ToolChoice {
/**
* Identifier of the requested tool.
*/
id: string;
}
}
}
/**
* Thread item that renders a widget payload.
*/
export interface ChatKitWidgetItem {
/**
* Identifier of the thread item.
*/
id: string;
/**
* Unix timestamp (in seconds) for when the item was created.
*/
created_at: number;
/**
* Type discriminator that is always `chatkit.thread_item`.
*/
object: 'chatkit.thread_item';
/**
* Identifier of the parent thread.
*/
thread_id: string;
/**
* Type discriminator that is always `chatkit.widget`.
*/
type: 'chatkit.widget';
/**
* Serialized widget payload rendered in the UI.
*/
widget: string;
}
/**
* Confirmation payload returned after deleting a thread.
*/
export interface ThreadDeleteResponse {
/**
* Identifier of the deleted thread.
*/
id: string;
/**
* Indicates that the thread has been deleted.
*/
deleted: boolean;
/**
* Type discriminator that is always `chatkit.thread.deleted`.
*/
object: 'chatkit.thread.deleted';
}
export interface ThreadListParams extends ConversationCursorPageParams {
/**
* List items created before this thread item ID. Defaults to null for the newest
* results.
*/
before?: string;
/**
* Sort order for results by creation time. Defaults to `desc`.
*/
order?: 'asc' | 'desc';
/**
* Filter threads that belong to this user identifier. Defaults to null to return
* all users.
*/
user?: string;
}
export interface ThreadListItemsParams extends ConversationCursorPageParams {
/**
* List items created before this thread item ID. Defaults to null for the newest
* results.
*/
before?: string;
/**
* Sort order for results by creation time. Defaults to `desc`.
*/
order?: 'asc' | 'desc';
}
export declare namespace Threads {
export { type ChatSession as ChatSession, type ChatSessionAutomaticThreadTitling as ChatSessionAutomaticThreadTitling, type ChatSessionChatKitConfiguration as ChatSessionChatKitConfiguration, type ChatSessionChatKitConfigurationParam as ChatSessionChatKitConfigurationParam, type ChatSessionExpiresAfterParam as ChatSessionExpiresAfterParam, type ChatSessionFileUpload as ChatSessionFileUpload, type ChatSessionHistory as ChatSessionHistory, type ChatSessionRateLimits as ChatSessionRateLimits, type ChatSessionRateLimitsParam as ChatSessionRateLimitsParam, type ChatSessionStatus as ChatSessionStatus, type ChatSessionWorkflowParam as ChatSessionWorkflowParam, type ChatKitAttachment as ChatKitAttachment, type ChatKitResponseOutputText as ChatKitResponseOutputText, type ChatKitThread as ChatKitThread, type ChatKitThreadAssistantMessageItem as ChatKitThreadAssistantMessageItem, type ChatKitThreadItemList as ChatKitThreadItemList, type ChatKitThreadUserMessageItem as ChatKitThreadUserMessageItem, type ChatKitWidgetItem as ChatKitWidgetItem, type ThreadDeleteResponse as ThreadDeleteResponse, type ChatKitThreadsPage as ChatKitThreadsPage, type ChatKitThreadItemListDataPage as ChatKitThreadItemListDataPage, type ThreadListParams as ThreadListParams, type ThreadListItemsParams as ThreadListItemsParams, };
}
//# sourceMappingURL=threads.d.ts.map
File diff suppressed because one or more lines are too long
+85
View File
@@ -0,0 +1,85 @@
"use strict";
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Threads = void 0;
const resource_1 = require("../../../core/resource.js");
const pagination_1 = require("../../../core/pagination.js");
const headers_1 = require("../../../internal/headers.js");
const path_1 = require("../../../internal/utils/path.js");
class Threads extends resource_1.APIResource {
/**
* Retrieve a ChatKit thread by its identifier.
*
* @example
* ```ts
* const chatkitThread =
* await client.beta.chatkit.threads.retrieve('cthr_123');
* ```
*/
retrieve(threadID, options) {
return this._client.get((0, path_1.path) `/chatkit/threads/${threadID}`, {
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* List ChatKit threads with optional pagination and user filters.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const chatkitThread of client.beta.chatkit.threads.list()) {
* // ...
* }
* ```
*/
list(query = {}, options) {
return this._client.getAPIList('/chatkit/threads', (pagination_1.ConversationCursorPage), {
query,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Delete a ChatKit thread along with its items and stored attachments.
*
* @example
* ```ts
* const thread = await client.beta.chatkit.threads.delete(
* 'cthr_123',
* );
* ```
*/
delete(threadID, options) {
return this._client.delete((0, path_1.path) `/chatkit/threads/${threadID}`, {
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* List items that belong to a ChatKit thread.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const thread of client.beta.chatkit.threads.listItems(
* 'cthr_123',
* )) {
* // ...
* }
* ```
*/
listItems(threadID, query = {}, options) {
return this._client.getAPIList((0, path_1.path) `/chatkit/threads/${threadID}/items`, (pagination_1.ConversationCursorPage), {
query,
...options,
headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
}
exports.Threads = Threads;
//# sourceMappingURL=threads.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"threads.js","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/threads.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,wDAAqD;AAGrD,4DAIkC;AAClC,0DAAyD;AAEzD,0DAAoD;AAEpD,MAAa,OAAQ,SAAQ,sBAAW;IACtC;;;;;;;;OAQG;IACH,QAAQ,CAAC,QAAgB,EAAE,OAAwB;QACjD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,oBAAoB,QAAQ,EAAE,EAAE;YAC1D,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAI,CACF,QAA6C,EAAE,EAC/C,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAA,mCAAqC,CAAA,EAAE;YACxF,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,QAAgB,EAAE,OAAwB;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAA,WAAI,EAAA,oBAAoB,QAAQ,EAAE,EAAE;YAC7D,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,SAAS,CACP,QAAgB,EAChB,QAAkD,EAAE,EACpD,OAAwB;QAUxB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAC5B,IAAA,WAAI,EAAA,oBAAoB,QAAQ,QAAQ,EACxC,CAAA,mCAOC,CAAA,EACD;YACE,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CACF,CAAC;IACJ,CAAC;CACF;AAvGD,0BAuGC"}
+81
View File
@@ -0,0 +1,81 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import { ConversationCursorPage, } from "../../../core/pagination.mjs";
import { buildHeaders } from "../../../internal/headers.mjs";
import { path } from "../../../internal/utils/path.mjs";
export class Threads extends APIResource {
/**
* Retrieve a ChatKit thread by its identifier.
*
* @example
* ```ts
* const chatkitThread =
* await client.beta.chatkit.threads.retrieve('cthr_123');
* ```
*/
retrieve(threadID, options) {
return this._client.get(path `/chatkit/threads/${threadID}`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* List ChatKit threads with optional pagination and user filters.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const chatkitThread of client.beta.chatkit.threads.list()) {
* // ...
* }
* ```
*/
list(query = {}, options) {
return this._client.getAPIList('/chatkit/threads', (ConversationCursorPage), {
query,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* Delete a ChatKit thread along with its items and stored attachments.
*
* @example
* ```ts
* const thread = await client.beta.chatkit.threads.delete(
* 'cthr_123',
* );
* ```
*/
delete(threadID, options) {
return this._client.delete(path `/chatkit/threads/${threadID}`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
/**
* List items that belong to a ChatKit thread.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const thread of client.beta.chatkit.threads.listItems(
* 'cthr_123',
* )) {
* // ...
* }
* ```
*/
listItems(threadID, query = {}, options) {
return this._client.getAPIList(path `/chatkit/threads/${threadID}/items`, (ConversationCursorPage), {
query,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
__security: { bearerAuth: true },
});
}
}
//# sourceMappingURL=threads.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"threads.mjs","sourceRoot":"","sources":["../../../src/resources/beta/chatkit/threads.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,mCAA+B;AAGrD,OAAO,EACL,sBAAsB,GAGvB,qCAAiC;AAClC,OAAO,EAAE,YAAY,EAAE,sCAAkC;AAEzD,OAAO,EAAE,IAAI,EAAE,yCAAqC;AAEpD,MAAM,OAAO,OAAQ,SAAQ,WAAW;IACtC;;;;;;;;OAQG;IACH,QAAQ,CAAC,QAAgB,EAAE,OAAwB;QACjD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,oBAAoB,QAAQ,EAAE,EAAE;YAC1D,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAI,CACF,QAA6C,EAAE,EAC/C,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAA,sBAAqC,CAAA,EAAE;YACxF,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,QAAgB,EAAE,OAAwB;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAA,oBAAoB,QAAQ,EAAE,EAAE;YAC7D,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,SAAS,CACP,QAAgB,EAChB,QAAkD,EAAE,EACpD,OAAwB;QAUxB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAC5B,IAAI,CAAA,oBAAoB,QAAQ,QAAQ,EACxC,CAAA,sBAOC,CAAA,EACD;YACE,KAAK;YACL,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/E,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACjC,CACF,CAAC;IACJ,CAAC;CACF"}