needle-cloud 1.10.3-dev.5aa26d7 → 1.10.3-dev.a391912

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.
@@ -62,6 +62,11 @@ export namespace Auth {
62
62
  * Initiate the sign-in process
63
63
  */
64
64
  function signIn(): Promise<void>;
65
+ /**
66
+ * Get the user's default team/org ID from their Logto custom_data.
67
+ * @returns {string | undefined}
68
+ */
69
+ function getDefaultTeamId(): string;
65
70
  /**
66
71
  * Sign out the current user
67
72
  */
@@ -1,74 +1,99 @@
1
1
  /**
2
2
  * List recent AI chats for the authenticated user.
3
- * @param {{ org?: string }} [opts]
3
+ * @param {ChatAuthOpts} [opts]
4
4
  * @returns {Promise<import("@needle-tools/cloud-sdk/types/api.ai").RecentChatsResponse>}
5
5
  */
6
- export function listChats(opts?: {
7
- org?: string;
8
- }): Promise<import("@needle-tools/cloud-sdk/types/api.ai").RecentChatsResponse>;
6
+ export function listChats(opts?: ChatAuthOpts): Promise<import("@needle-tools/cloud-sdk/types/api.ai").RecentChatsResponse>;
9
7
  /**
10
8
  * Read an AI chat by slug. Returns JSON with messages by default.
11
9
  * When `reconnect: true`, attempts to reconnect to an active SSE stream.
12
10
  * @overload
13
11
  * @param {string} slug
14
- * @param {{ org?: string, offset?: number, limit?: number, personal?: boolean, reconnect?: false }} [opts]
12
+ * @param {ChatAuthOpts & { offset?: number, limit?: number, personal?: boolean, reconnect?: false }} [opts]
15
13
  * @returns {Promise<import("@needle-tools/cloud-sdk/types/api.ai").AIChatGETResponse>}
16
14
  */
17
15
  /**
18
16
  * @overload
19
17
  * @param {string} slug
20
- * @param {{ org?: string, personal?: boolean, reconnect: true, signal?: AbortSignal }} opts
18
+ * @param {ChatAuthOpts & { personal?: boolean, reconnect: true, signal?: AbortSignal }} opts
21
19
  * @returns {Promise<AsyncGenerator<import("@needle-tools/cloud-sdk/types/api.ai").ChatStreamEvent> | null>}
22
20
  */
23
21
  /**
24
22
  * @param {string} slug
25
- * @param {{ org?: string, offset?: number, limit?: number, personal?: boolean, reconnect?: boolean, signal?: AbortSignal }} [opts]
23
+ * @param {ChatAuthOpts & { offset?: number, limit?: number, personal?: boolean, reconnect?: boolean, signal?: AbortSignal }} [opts]
26
24
  * @returns {Promise<import("@needle-tools/cloud-sdk/types/api.ai").AIChatGETResponse | AsyncGenerator<import("@needle-tools/cloud-sdk/types/api.ai").ChatStreamEvent> | null>}
27
25
  */
28
- export function readChat(slug: string, opts?: {
29
- org?: string;
26
+ export function readChat(slug: string, opts?: ChatAuthOpts & {
30
27
  offset?: number;
31
28
  limit?: number;
32
29
  personal?: boolean;
33
30
  reconnect?: boolean;
34
31
  signal?: AbortSignal;
35
32
  }): Promise<import("@needle-tools/cloud-sdk/types/api.ai").AIChatGETResponse | AsyncGenerator<import("@needle-tools/cloud-sdk/types/api.ai").ChatStreamEvent> | null>;
33
+ /**
34
+ * @typedef {import("@needle-tools/cloud-sdk/types/api.ai").ClientToolDefinition} ClientToolDefinition
35
+ * @typedef {import("@needle-tools/cloud-sdk/types/api.ai").ClientContext} ClientContext
36
+ * @typedef {import("@needle-tools/cloud-sdk/types/api.ai").ChatStreamEvent} ChatStreamEvent
37
+ * @typedef {import("@needle-tools/cloud-sdk/types/api.ai").AIChatSyncResponse} AIChatSyncResponse
38
+ */
36
39
  /**
37
40
  * Send a message to an AI chat.
38
41
  * @overload
39
42
  * @param {string} slug
40
43
  * @param {string} message
41
- * @param {{ org?: string, stream?: false, source?: string, personal?: boolean, full_url?: string, pathname?: string }} [opts]
42
- * @returns {Promise<import("@needle-tools/cloud-sdk/types/api.ai").AIChatSyncResponse>}
44
+ * @param {ChatAuthOpts & { stream?: false, source?: string, personal?: boolean, full_url?: string, pathname?: string, client_tools?: ClientToolDefinition[], context?: ClientContext[] }} [opts]
45
+ * @returns {Promise<AIChatSyncResponse>}
43
46
  */
44
47
  /**
45
48
  * @overload
46
49
  * @param {string} slug
47
50
  * @param {string} message
48
- * @param {{ org?: string, stream: true, source?: string, personal?: boolean, full_url?: string, pathname?: string }} opts
49
- * @returns {Promise<AsyncGenerator<import("@needle-tools/cloud-sdk/types/api.ai").ChatStreamEvent>>}
51
+ * @param {ChatAuthOpts & { stream: true, source?: string, personal?: boolean, full_url?: string, pathname?: string, client_tools?: ClientToolDefinition[], context?: ClientContext[] }} opts
52
+ * @returns {Promise<AsyncGenerator<ChatStreamEvent>>}
50
53
  */
51
54
  /**
52
55
  * @param {string} slug
53
56
  * @param {string} message
54
- * @param {{ org?: string, stream?: boolean, source?: string, personal?: boolean, full_url?: string, pathname?: string }} [opts]
55
- * @returns {Promise<import("@needle-tools/cloud-sdk/types/api.ai").AIChatSyncResponse | AsyncGenerator<import("@needle-tools/cloud-sdk/types/api.ai").ChatStreamEvent>>}
57
+ * @param {ChatAuthOpts & { stream?: boolean, source?: string, personal?: boolean, full_url?: string, pathname?: string, client_tools?: ClientToolDefinition[], context?: ClientContext[] }} [opts]
58
+ * @returns {Promise<AIChatSyncResponse | AsyncGenerator<ChatStreamEvent>>}
56
59
  */
57
- export function sendChatMessage(slug: string, message: string, opts?: {
58
- org?: string;
60
+ export function sendChatMessage(slug: string, message: string, opts?: ChatAuthOpts & {
59
61
  stream?: boolean;
60
62
  source?: string;
61
63
  personal?: boolean;
62
64
  full_url?: string;
63
65
  pathname?: string;
64
- }): Promise<import("@needle-tools/cloud-sdk/types/api.ai").AIChatSyncResponse | AsyncGenerator<import("@needle-tools/cloud-sdk/types/api.ai").ChatStreamEvent>>;
66
+ client_tools?: ClientToolDefinition[];
67
+ context?: ClientContext[];
68
+ }): Promise<AIChatSyncResponse | AsyncGenerator<ChatStreamEvent>>;
65
69
  /**
66
70
  * Interrupt an active AI generation for the given chat slug.
67
71
  * @param {string} slug
68
- * @param {{ org?: string, personal?: boolean }} [opts]
72
+ * @param {ChatAuthOpts & { personal?: boolean }} [opts]
69
73
  * @returns {Promise<void>}
70
74
  */
71
- export function interruptChat(slug: string, opts?: {
72
- org?: string;
75
+ export function interruptChat(slug: string, opts?: ChatAuthOpts & {
73
76
  personal?: boolean;
74
77
  }): Promise<void>;
78
+ /**
79
+ * Submit a client-side tool execution result back to the server.
80
+ * Call this when you receive a `client_tool_request` event from the SSE stream.
81
+ * @param {string} requestId - The `request_id` from the `client_tool_request` event
82
+ * @param {{ result?: any, error?: string }} outcome - The tool result or error
83
+ * @param {ChatAuthOpts & { personal?: boolean }} [opts]
84
+ * @returns {Promise<void>}
85
+ */
86
+ export function submitToolResult(requestId: string, outcome: {
87
+ result?: any;
88
+ error?: string;
89
+ }, opts?: ChatAuthOpts & {
90
+ personal?: boolean;
91
+ }): Promise<void>;
92
+ export type ChatAuthOpts = {
93
+ org?: string;
94
+ authToken?: string;
95
+ };
96
+ export type ClientToolDefinition = import("@needle-tools/cloud-sdk/types/api.ai").ClientToolDefinition;
97
+ export type ClientContext = import("@needle-tools/cloud-sdk/types/api.ai").ClientContext;
98
+ export type ChatStreamEvent = import("@needle-tools/cloud-sdk/types/api.ai").ChatStreamEvent;
99
+ export type AIChatSyncResponse = import("@needle-tools/cloud-sdk/types/api.ai").AIChatSyncResponse;
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * @param {string | null | undefined} [org]
3
+ * @param {string | null | undefined} [authToken] - Explicit auth token. If provided, skips Auth.requestAccessToken().
3
4
  * @returns {Promise<import("../web.types").AuthData>}
4
5
  */
5
- export function getAuthHeader(org?: string | null | undefined): Promise<import("../web.types").AuthData>;
6
+ export function getAuthHeader(org?: string | null | undefined, authToken?: string | null | undefined): Promise<import("../web.types").AuthData>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "needle-cloud",
3
- "version": "1.10.3-dev.5aa26d7",
3
+ "version": "1.10.3-dev.a391912",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "needle-cloud": "./bin/cli.js"