needle-cloud 1.10.2 → 1.10.3-dev.14eac62

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.
@@ -0,0 +1,99 @@
1
+ /**
2
+ * List recent AI chats for the authenticated user.
3
+ * @param {ChatAuthOpts} [opts]
4
+ * @returns {Promise<import("@needle-tools/cloud-sdk/types/api.ai").RecentChatsResponse>}
5
+ */
6
+ export function listChats(opts?: ChatAuthOpts): Promise<import("@needle-tools/cloud-sdk/types/api.ai").RecentChatsResponse>;
7
+ /**
8
+ * Read an AI chat by slug. Returns JSON with messages by default.
9
+ * When `reconnect: true`, attempts to reconnect to an active SSE stream.
10
+ * @overload
11
+ * @param {string} slug
12
+ * @param {ChatAuthOpts & { offset?: number, limit?: number, personal?: boolean, reconnect?: false }} [opts]
13
+ * @returns {Promise<import("@needle-tools/cloud-sdk/types/api.ai").AIChatGETResponse>}
14
+ */
15
+ /**
16
+ * @overload
17
+ * @param {string} slug
18
+ * @param {ChatAuthOpts & { personal?: boolean, reconnect: true, signal?: AbortSignal }} opts
19
+ * @returns {Promise<AsyncGenerator<import("@needle-tools/cloud-sdk/types/api.ai").ChatStreamEvent> | null>}
20
+ */
21
+ /**
22
+ * @param {string} slug
23
+ * @param {ChatAuthOpts & { offset?: number, limit?: number, personal?: boolean, reconnect?: boolean, signal?: AbortSignal }} [opts]
24
+ * @returns {Promise<import("@needle-tools/cloud-sdk/types/api.ai").AIChatGETResponse | AsyncGenerator<import("@needle-tools/cloud-sdk/types/api.ai").ChatStreamEvent> | null>}
25
+ */
26
+ export function readChat(slug: string, opts?: ChatAuthOpts & {
27
+ offset?: number;
28
+ limit?: number;
29
+ personal?: boolean;
30
+ reconnect?: boolean;
31
+ signal?: AbortSignal;
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
+ */
39
+ /**
40
+ * Send a message to an AI chat.
41
+ * @overload
42
+ * @param {string} slug
43
+ * @param {string} message
44
+ * @param {ChatAuthOpts & { stream?: false, source?: string, personal?: boolean, full_url?: string, pathname?: string, client_tools?: ClientToolDefinition[], context?: ClientContext[] }} [opts]
45
+ * @returns {Promise<AIChatSyncResponse>}
46
+ */
47
+ /**
48
+ * @overload
49
+ * @param {string} slug
50
+ * @param {string} message
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>>}
53
+ */
54
+ /**
55
+ * @param {string} slug
56
+ * @param {string} message
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>>}
59
+ */
60
+ export function sendChatMessage(slug: string, message: string, opts?: ChatAuthOpts & {
61
+ stream?: boolean;
62
+ source?: string;
63
+ personal?: boolean;
64
+ full_url?: string;
65
+ pathname?: string;
66
+ client_tools?: ClientToolDefinition[];
67
+ context?: ClientContext[];
68
+ }): Promise<AIChatSyncResponse | AsyncGenerator<ChatStreamEvent>>;
69
+ /**
70
+ * Interrupt an active AI generation for the given chat slug.
71
+ * @param {string} slug
72
+ * @param {ChatAuthOpts & { personal?: boolean }} [opts]
73
+ * @returns {Promise<void>}
74
+ */
75
+ export function interruptChat(slug: string, opts?: ChatAuthOpts & {
76
+ personal?: boolean;
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,21 +1,3 @@
1
- /**
2
- * Unfortunately this doesnt get properly bundles in the final output so we have to write the types below directly
3
- * @typedef {import("@needle-tools/cloud-sdk/types").JobType} JobType
4
- * @typedef {import("@needle-tools/cloud-sdk/types").JobStatus} JobStatus
5
- */
6
- /**
7
- * @param {{ org?:string } & ({ name?: string, view_id?:string } | { page: number, limit: number })} opts
8
- * @returns {Promise<Array<import("../web.types.js").Upload>>}
9
- */
10
- export function getUploads(opts: {
11
- org?: string;
12
- } & ({
13
- name?: string;
14
- view_id?: string;
15
- } | {
16
- page: number;
17
- limit: number;
18
- })): Promise<Array<import("../web.types.js").Upload>>;
19
1
  /**
20
2
  * @param {{ org?:string } & { offset?:number, limit?: number }} opts
21
3
  * @returns {Promise<Array<Deployment>>}
@@ -45,14 +27,6 @@ export function getUserLicenses(opts: {
45
27
  export function ownsProduct(opts: {
46
28
  product?: string | string[];
47
29
  }): Promise<boolean>;
48
- /**
49
- * Unfortunately this doesnt get properly bundles in the final output so we have to write the types below directly
50
- */
51
- export type JobType = import("@needle-tools/cloud-sdk/types").JobType;
52
- /**
53
- * Unfortunately this doesnt get properly bundles in the final output so we have to write the types below directly
54
- */
55
- export type JobStatus = import("@needle-tools/cloud-sdk/types").JobStatus;
56
30
  export type Deployment = {
57
31
  name: string;
58
32
  url: string;
@@ -1,3 +1,4 @@
1
1
  export * from "./upload.js";
2
2
  export * from "./get.js";
3
+ export * from "./chat.js";
3
4
  export { startCheckoutSession } from "./checkout.js";
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * @param {Array<Filelike>} files
7
7
  * @param {{org?:string|null} & { name?:string, abort?:AbortSignal, }} opts
8
- * @returns {Promise<{error:string} | {job_id:string, view_id:string, url?:string | null, skipped?:boolean}>}
8
+ * @returns {Promise<{error:string} | {job_id:string, content_id:string, url?:string | null, skipped?:boolean}>}
9
9
  */
10
10
  export function uploadFiles(files: Array<Filelike>, opts: {
11
11
  org?: string | null;
@@ -16,7 +16,7 @@ export function uploadFiles(files: Array<Filelike>, opts: {
16
16
  error: string;
17
17
  } | {
18
18
  job_id: string;
19
- view_id: string;
19
+ content_id: string;
20
20
  url?: string | null;
21
21
  skipped?: boolean;
22
22
  }>;
@@ -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.2",
3
+ "version": "1.10.3-dev.14eac62",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "needle-cloud": "./bin/cli.js"
@@ -31,14 +31,12 @@
31
31
  "devDependencies": {
32
32
  "@needle-tools/cloud-sdk": "1.0.0-alpha",
33
33
  "concurrently": "^9.0.1",
34
- "microbundle": "^0.15.1",
35
- "vitest": "^2.1.1"
34
+ "microbundle": "^0.15.1"
36
35
  },
37
36
  "engines": {
38
37
  "node": ">= 18"
39
38
  },
40
39
  "scripts": {
41
- "test": "vitest",
42
40
  "install-local-deps": "cd ../needle-share-sdk && npm install",
43
41
  "deploy:main": "npm run deploy -- --tag main",
44
42
  "deploy": "npm run dist & npm publish --access public",
@@ -48,10 +46,10 @@
48
46
  "dev:web": "microbundle watch -i ./src/index.js -o dist/index.js --format esm --generateTypes --target web --no-compress",
49
47
  "dev:node": "microbundle watch -i ./src/cli.js -o dist/cli.js --format esm --target node --no-compress",
50
48
  "dist": "npx --yes rimraf dist && npm run dist:web && npm run dist:node",
51
- "dist:web": "microbundle -i ./src/index.js -o dist/index.js --format esm --generateTypes --target web --sourcemap true --compress true --define api_endpoint=https://cloud.needle.tools/api,cloud_base_url=https://cloud.needle.tools",
52
- "dist:web-preview": "microbundle -i ./src/index.js -o dist/index.js --format esm --generateTypes --target web --sourcemap true --compress true --define api_endpoint=https://cloud-staging.needle.tools/api,cloud_base_url=https://cloud-staging.needle.tools",
53
- "dist:node": "microbundle -i ./src/cli.js -o dist/cli.js --format esm --generateTypes --target node --sourcemap false --compress --define api_endpoint=https://cloud.needle.tools/api,cloud_base_url=https://cloud.needle.tools",
54
- "dist:node-preview": "microbundle -i ./src/cli.js -o dist/cli.js --format esm --generateTypes --target node --sourcemap false --compress --define api_endpoint=https://cloud-staging.needle.tools/api,cloud_base_url=https://cloud-staging.needle.tools",
49
+ "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
+ "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",
51
+ "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
+ "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",
55
53
  "dev:mcp": "npx --yes @modelcontextprotocol/inspector mcp-inspector http://localhost:8424/mcp"
56
54
  },
57
55
  "files": [
@@ -65,4 +63,4 @@
65
63
  "access": "public",
66
64
  "registry": "https://registry.npmjs.org/"
67
65
  }
68
- }
66
+ }