needle-cloud 1.10.3-dev.2679141 → 1.10.3-dev.383c90c
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/dist/cli.esm.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/web/auth.d.ts +6 -0
- package/dist/web/functions/chat.d.ts +34 -26
- package/dist/web/functions/utils.d.ts +2 -1
- package/package.json +14 -10
package/dist/web/auth.d.ts
CHANGED
|
@@ -62,12 +62,18 @@ 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
|
*/
|
|
68
73
|
function signOut(): Promise<void>;
|
|
69
74
|
}
|
|
70
75
|
export type UserInfoResponse = import("@logto/browser").UserInfoResponse;
|
|
76
|
+
export type LogtoUserCustomData = import("@needle-tools/cloud-sdk/types/logto").LogtoUserCustomData;
|
|
71
77
|
export type ResourceUrl = "https://cloud.needle.tools/api" | ({} & string);
|
|
72
78
|
export type AuthInitOpts = {
|
|
73
79
|
appId?: string;
|
|
@@ -1,77 +1,78 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* List recent AI chats for the authenticated user.
|
|
3
|
-
* @param {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
42
|
-
* @returns {Promise<
|
|
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 {
|
|
49
|
-
* @returns {Promise<AsyncGenerator<
|
|
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 {
|
|
55
|
-
* @returns {Promise<
|
|
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
|
-
client_tools?:
|
|
65
|
-
context?:
|
|
66
|
-
}): Promise<
|
|
66
|
+
client_tools?: ClientToolDefinition[];
|
|
67
|
+
context?: ClientContext[];
|
|
68
|
+
}): Promise<AIChatSyncResponse | AsyncGenerator<ChatStreamEvent>>;
|
|
67
69
|
/**
|
|
68
70
|
* Interrupt an active AI generation for the given chat slug.
|
|
69
71
|
* @param {string} slug
|
|
70
|
-
* @param {
|
|
72
|
+
* @param {ChatAuthOpts & { personal?: boolean }} [opts]
|
|
71
73
|
* @returns {Promise<void>}
|
|
72
74
|
*/
|
|
73
|
-
export function interruptChat(slug: string, opts?: {
|
|
74
|
-
org?: string;
|
|
75
|
+
export function interruptChat(slug: string, opts?: ChatAuthOpts & {
|
|
75
76
|
personal?: boolean;
|
|
76
77
|
}): Promise<void>;
|
|
77
78
|
/**
|
|
@@ -79,13 +80,20 @@ export function interruptChat(slug: string, opts?: {
|
|
|
79
80
|
* Call this when you receive a `client_tool_request` event from the SSE stream.
|
|
80
81
|
* @param {string} requestId - The `request_id` from the `client_tool_request` event
|
|
81
82
|
* @param {{ result?: any, error?: string }} outcome - The tool result or error
|
|
82
|
-
* @param {
|
|
83
|
+
* @param {ChatAuthOpts & { personal?: boolean }} [opts]
|
|
83
84
|
* @returns {Promise<void>}
|
|
84
85
|
*/
|
|
85
86
|
export function submitToolResult(requestId: string, outcome: {
|
|
86
87
|
result?: any;
|
|
87
88
|
error?: string;
|
|
88
|
-
}, opts?: {
|
|
89
|
-
org?: string;
|
|
89
|
+
}, opts?: ChatAuthOpts & {
|
|
90
90
|
personal?: boolean;
|
|
91
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.
|
|
3
|
+
"version": "1.10.3-dev.383c90c",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"needle-cloud": "./bin/cli.js"
|
|
@@ -11,6 +11,13 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"node": "./dist/cli.esm.js"
|
|
13
13
|
},
|
|
14
|
+
"files": [
|
|
15
|
+
"bin/",
|
|
16
|
+
"dist/",
|
|
17
|
+
"README.md",
|
|
18
|
+
"CHANGELOG.md",
|
|
19
|
+
"package-lock.json"
|
|
20
|
+
],
|
|
14
21
|
"dependencies": {
|
|
15
22
|
"@caporal/core": "^2.0.7",
|
|
16
23
|
"@logto/browser": "^3.0.7",
|
|
@@ -30,8 +37,11 @@
|
|
|
30
37
|
},
|
|
31
38
|
"devDependencies": {
|
|
32
39
|
"@needle-tools/cloud-sdk": "1.0.0-alpha",
|
|
40
|
+
"@rollup/plugin-alias": "^6.0.0",
|
|
33
41
|
"concurrently": "^9.0.1",
|
|
34
|
-
"microbundle": "^0.15.1"
|
|
42
|
+
"microbundle": "^0.15.1",
|
|
43
|
+
"rollup": "^4.60.3",
|
|
44
|
+
"rollup-plugin-dts": "^6.4.1"
|
|
35
45
|
},
|
|
36
46
|
"engines": {
|
|
37
47
|
"node": ">= 18"
|
|
@@ -45,20 +55,14 @@
|
|
|
45
55
|
"dev": "concurrently --kill-others \"npm run dev:web\" \"npm run dev:node\"",
|
|
46
56
|
"dev:web": "microbundle watch -i ./src/index.js -o dist/index.js --format esm --generateTypes --target web --no-compress",
|
|
47
57
|
"dev:node": "microbundle watch -i ./src/cli.js -o dist/cli.js --format esm --target node --no-compress",
|
|
48
|
-
"dist": "npx --yes rimraf dist && npm run dist:web && npm run dist:node",
|
|
58
|
+
"dist": "npx --yes rimraf dist && npm run dist:web && npm run dist:types && npm run dist:node",
|
|
49
59
|
"dist:web": "microbundle -i ./src/index.js -o dist/index.js --format esm --generateTypes --target web --sourcemap false --compress true --define api_endpoint=https://cloud.needle.tools/api,cloud_base_url=https://cloud.needle.tools,logto_endpoint=https://auth.needle.tools,logto_app_id=2stnsoa6a1b0gwc7lra55,logto_app_secret=seV1T6iKBKLlttjdk25I2px43ZCEHnPJ",
|
|
50
60
|
"dist:web-preview": "microbundle -i ./src/index.js -o dist/index.js --format esm --generateTypes --target web --sourcemap false --compress true --define api_endpoint=https://cloud-staging.needle.tools/api,cloud_base_url=https://cloud-staging.needle.tools,logto_endpoint=https://auth.needle.tools,logto_app_id=2stnsoa6a1b0gwc7lra55,logto_app_secret=seV1T6iKBKLlttjdk25I2px43ZCEHnPJ",
|
|
61
|
+
"dist:types": "cp src/web/web.types.d.ts dist/web/web.types.d.ts && rollup -c rollup.dts.config.mjs && node tools/clean-intermediate-dts.mjs",
|
|
51
62
|
"dist:node": "microbundle -i ./src/cli.js -o dist/cli.js --format esm --target node --generateTypes false --sourcemap false --compress --define api_endpoint=https://cloud.needle.tools/api,cloud_base_url=https://cloud.needle.tools,logto_endpoint=https://auth.needle.tools,logto_app_id=2stnsoa6a1b0gwc7lra55,logto_app_secret=seV1T6iKBKLlttjdk25I2px43ZCEHnPJ",
|
|
52
63
|
"dist:node-preview": "microbundle -i ./src/cli.js -o dist/cli.js --format esm --target node --generateTypes false --sourcemap false --compress --define api_endpoint=https://cloud-staging.needle.tools/api,cloud_base_url=https://cloud-staging.needle.tools,logto_endpoint=https://auth.needle.tools,logto_app_id=2stnsoa6a1b0gwc7lra55,logto_app_secret=seV1T6iKBKLlttjdk25I2px43ZCEHnPJ",
|
|
53
64
|
"dev:mcp": "npx --yes @modelcontextprotocol/inspector mcp-inspector http://localhost:8424/mcp"
|
|
54
65
|
},
|
|
55
|
-
"files": [
|
|
56
|
-
"bin/",
|
|
57
|
-
"dist/",
|
|
58
|
-
"README.md",
|
|
59
|
-
"CHANGELOG.md",
|
|
60
|
-
"package-lock.json"
|
|
61
|
-
],
|
|
62
66
|
"publishConfig": {
|
|
63
67
|
"access": "public",
|
|
64
68
|
"registry": "https://registry.npmjs.org/"
|