@seclai/sdk 1.0.6 → 1.0.7
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/README.md +24 -1
- package/dist/index.cjs +68 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +113 -29
- package/dist/index.d.ts +113 -29
- package/dist/index.js +68 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ npm install @seclai/sdk
|
|
|
12
12
|
|
|
13
13
|
Online API documentation (latest):
|
|
14
14
|
|
|
15
|
-
https://seclai.github.io/seclai-javascript/1.0.
|
|
15
|
+
https://seclai.github.io/seclai-javascript/1.0.7/
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
@@ -103,10 +103,33 @@ const upload = await client.uploadFileToSource("source_connection_id", {
|
|
|
103
103
|
fileName: "hello.txt",
|
|
104
104
|
mimeType: "text/plain",
|
|
105
105
|
title: "Hello",
|
|
106
|
+
metadata: { category: "docs", author: "Ada" },
|
|
106
107
|
});
|
|
107
108
|
console.log(upload);
|
|
108
109
|
```
|
|
109
110
|
|
|
111
|
+
### Replace an existing content version with a new upload
|
|
112
|
+
|
|
113
|
+
If you need to correct or update an uploaded document while keeping references stable,
|
|
114
|
+
use `uploadFileToContent` to upload a new file and replace the content behind an existing
|
|
115
|
+
`source_connection_content_version`.
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import { Seclai } from "@seclai/sdk";
|
|
119
|
+
|
|
120
|
+
const client = new Seclai({ apiKey: process.env.SECLAI_API_KEY });
|
|
121
|
+
|
|
122
|
+
const replace = await client.uploadFileToContent("content_version_id", {
|
|
123
|
+
file: await fetch("https://example.invalid/updated.pdf").then((r) => r.arrayBuffer()),
|
|
124
|
+
fileName: "updated.pdf",
|
|
125
|
+
mimeType: "application/pdf",
|
|
126
|
+
title: "Updated document",
|
|
127
|
+
metadata: { revision: 2 },
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
console.log(replace);
|
|
131
|
+
```
|
|
132
|
+
|
|
110
133
|
## Development
|
|
111
134
|
|
|
112
135
|
### Base URL
|
package/dist/index.cjs
CHANGED
|
@@ -474,6 +474,8 @@ var Seclai = class {
|
|
|
474
474
|
* @param opts - File payload and optional metadata.
|
|
475
475
|
* @param opts.file - File payload as a `Blob`, `Uint8Array`, or `ArrayBuffer`.
|
|
476
476
|
* @param opts.title - Optional title for the uploaded file.
|
|
477
|
+
* @param opts.metadata - Optional metadata object. This is sent as a JSON string form field named `metadata`.
|
|
478
|
+
* Example: `{ category: "docs", author: "Ada" }`.
|
|
477
479
|
* @param opts.fileName - Optional filename to send with the upload.
|
|
478
480
|
* @param opts.mimeType - Optional MIME type to attach to the upload.
|
|
479
481
|
* @returns Upload response details.
|
|
@@ -500,6 +502,72 @@ var Seclai = class {
|
|
|
500
502
|
if (opts.title !== void 0) {
|
|
501
503
|
form.set("title", opts.title);
|
|
502
504
|
}
|
|
505
|
+
if (opts.metadata !== void 0) {
|
|
506
|
+
form.set("metadata", JSON.stringify(opts.metadata));
|
|
507
|
+
}
|
|
508
|
+
const response = await this.fetcher(url, {
|
|
509
|
+
method: "POST",
|
|
510
|
+
headers,
|
|
511
|
+
body: form
|
|
512
|
+
});
|
|
513
|
+
if (!response.ok) {
|
|
514
|
+
const responseText = await safeText(response);
|
|
515
|
+
if (response.status === 422) {
|
|
516
|
+
const validation = await safeJson(response);
|
|
517
|
+
throw new SeclaiAPIValidationError({
|
|
518
|
+
message: "Validation error",
|
|
519
|
+
statusCode: response.status,
|
|
520
|
+
method: "POST",
|
|
521
|
+
url: url.toString(),
|
|
522
|
+
responseText,
|
|
523
|
+
validationError: validation
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
throw new SeclaiAPIStatusError({
|
|
527
|
+
message: `Request failed with status ${response.status}`,
|
|
528
|
+
statusCode: response.status,
|
|
529
|
+
method: "POST",
|
|
530
|
+
url: url.toString(),
|
|
531
|
+
responseText
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
return await response.json();
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Upload a new file and replace the content backing an existing content version.
|
|
538
|
+
*
|
|
539
|
+
* This endpoint is useful when you need to correct or update an uploaded document while keeping
|
|
540
|
+
* references stable (the content version ID stays the same).
|
|
541
|
+
*
|
|
542
|
+
* Notes:
|
|
543
|
+
* - `metadata` is sent as a JSON string form field named `metadata`.
|
|
544
|
+
* - `title` is a convenience field and may be merged into `metadata.title` by the server.
|
|
545
|
+
*/
|
|
546
|
+
async uploadFileToContent(sourceConnectionContentVersion, opts) {
|
|
547
|
+
const url = buildURL(this.baseUrl, `/contents/${sourceConnectionContentVersion}/upload`);
|
|
548
|
+
const headers = {
|
|
549
|
+
...this.defaultHeaders,
|
|
550
|
+
[this.apiKeyHeader]: this.apiKey
|
|
551
|
+
};
|
|
552
|
+
const form = new FormData();
|
|
553
|
+
let blob;
|
|
554
|
+
if (opts.file instanceof Blob) {
|
|
555
|
+
blob = opts.file;
|
|
556
|
+
} else if (opts.file instanceof ArrayBuffer) {
|
|
557
|
+
const blobOpts = opts.mimeType ? { type: opts.mimeType } : void 0;
|
|
558
|
+
blob = new Blob([new Uint8Array(opts.file)], blobOpts);
|
|
559
|
+
} else {
|
|
560
|
+
const blobOpts = opts.mimeType ? { type: opts.mimeType } : void 0;
|
|
561
|
+
blob = new Blob([opts.file], blobOpts);
|
|
562
|
+
}
|
|
563
|
+
const fileName = opts.fileName ?? "upload";
|
|
564
|
+
form.set("file", blob, fileName);
|
|
565
|
+
if (opts.title !== void 0) {
|
|
566
|
+
form.set("title", opts.title);
|
|
567
|
+
}
|
|
568
|
+
if (opts.metadata !== void 0) {
|
|
569
|
+
form.set("metadata", JSON.stringify(opts.metadata));
|
|
570
|
+
}
|
|
503
571
|
const response = await this.fetcher(url, {
|
|
504
572
|
method: "POST",
|
|
505
573
|
headers,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/client.ts"],"sourcesContent":["export {\n Seclai,\n SECLAI_API_URL,\n type SeclaiOptions,\n type FetchLike,\n} from \"./client\";\n\nexport {\n SeclaiError,\n SeclaiConfigurationError,\n SeclaiAPIStatusError,\n SeclaiAPIValidationError,\n} from \"./errors\";\n\nexport type {\n JSONValue,\n AgentRunRequest,\n AgentRunStreamRequest,\n AgentRunResponse,\n AgentRunListResponse,\n ContentDetailResponse,\n ContentEmbeddingsListResponse,\n SourceListResponse,\n FileUploadResponse,\n HTTPValidationError,\n} from \"./types\";\n","/** Base error class for the Seclai SDK. */\nexport class SeclaiError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"SeclaiError\";\n }\n}\n\n/** Thrown when the SDK is misconfigured (for example, missing API key). */\nexport class SeclaiConfigurationError extends SeclaiError {\n constructor(message: string) {\n super(message);\n this.name = \"SeclaiConfigurationError\";\n }\n}\n\n/**\n * Thrown when the API returns a non-success status code.\n *\n * @remarks\n * Use {@link SeclaiAPIValidationError} for HTTP 422 validation errors.\n */\nexport class SeclaiAPIStatusError extends SeclaiError {\n /** HTTP status code returned by the API. */\n public readonly statusCode: number;\n /** HTTP method used for the request. */\n public readonly method: string;\n /** Full request URL. */\n public readonly url: string;\n /** Best-effort response body text (if available). */\n public readonly responseText: string | undefined;\n\n constructor(opts: {\n /** Human-readable error message. */\n message: string;\n statusCode: number;\n method: string;\n url: string;\n responseText: string | undefined;\n }) {\n super(opts.message);\n this.name = \"SeclaiAPIStatusError\";\n this.statusCode = opts.statusCode;\n this.method = opts.method;\n this.url = opts.url;\n this.responseText = opts.responseText;\n }\n}\n\n/**\n * Thrown when the API returns a validation error response (typically HTTP 422).\n *\n * The `validationError` field contains the decoded validation payload when available.\n */\nexport class SeclaiAPIValidationError extends SeclaiAPIStatusError {\n /** Parsed validation error payload (best-effort). */\n public readonly validationError: unknown;\n\n constructor(opts: {\n message: string;\n statusCode: number;\n method: string;\n url: string;\n responseText: string | undefined;\n validationError: unknown;\n }) {\n super(opts);\n this.name = \"SeclaiAPIValidationError\";\n this.validationError = opts.validationError;\n }\n}\n","import {\n SeclaiAPIStatusError,\n SeclaiAPIValidationError,\n SeclaiConfigurationError,\n SeclaiError,\n} from \"./errors\";\nimport type {\n AgentRunListResponse,\n AgentRunRequest,\n AgentRunResponse,\n AgentRunStreamRequest,\n ContentDetailResponse,\n ContentEmbeddingsListResponse,\n FileUploadResponse,\n HTTPValidationError,\n SourceListResponse,\n} from \"./types\";\n\n/** Default API base URL (can be overridden with `baseUrl` or `SECLAI_API_URL`). */\nexport const SECLAI_API_URL = \"https://api.seclai.com\";\n\n/** A `fetch`-compatible function (e.g. `globalThis.fetch` or `undici.fetch`). */\nexport type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;\n\n/** Configuration for the {@link Seclai} client. */\nexport interface SeclaiOptions {\n /** API key used for authentication. Defaults to `process.env.SECLAI_API_KEY` when available. */\n apiKey?: string;\n /** API base URL. Defaults to `process.env.SECLAI_API_URL` when available, else {@link SECLAI_API_URL}. */\n baseUrl?: string;\n /** Header name to use for the API key. Defaults to `x-api-key`. */\n apiKeyHeader?: string;\n /** Extra headers to include on every request. */\n defaultHeaders?: Record<string, string>;\n /** Optional `fetch` implementation for environments without a global `fetch`. */\n fetch?: FetchLike;\n}\n\nfunction getEnv(name: string): string | undefined {\n const p = (globalThis as any)?.process;\n return p?.env?.[name];\n}\n\nfunction buildURL(baseUrl: string, path: string, query?: Record<string, unknown>): URL {\n const url = new URL(path, baseUrl);\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined || value === null) continue;\n url.searchParams.set(key, String(value));\n }\n }\n return url;\n}\n\nasync function safeText(response: Response): Promise<string | undefined> {\n try {\n return await response.clone().text();\n } catch {\n return undefined;\n }\n}\n\nasync function safeJson(response: Response): Promise<unknown | undefined> {\n try {\n return await response.clone().json();\n } catch {\n return undefined;\n }\n}\n\ntype SseMessage = { event?: string; data?: string };\n\nfunction createSseParser(onMessage: (msg: SseMessage) => void) {\n let buffer = \"\";\n let eventName: string | undefined;\n let dataLines: string[] = [];\n\n function dispatch() {\n if (!eventName && dataLines.length === 0) return;\n const msg: SseMessage = { data: dataLines.join(\"\\n\") };\n if (eventName !== undefined) msg.event = eventName;\n onMessage(msg);\n eventName = undefined;\n dataLines = [];\n }\n\n function feed(textChunk: string) {\n buffer += textChunk;\n while (true) {\n const newlineIdx = buffer.indexOf(\"\\n\");\n if (newlineIdx === -1) return;\n\n let line = buffer.slice(0, newlineIdx);\n buffer = buffer.slice(newlineIdx + 1);\n\n if (line.endsWith(\"\\r\")) line = line.slice(0, -1);\n\n if (line === \"\") {\n dispatch();\n continue;\n }\n\n // Comments/keepalives begin with ':'\n if (line.startsWith(\":\")) continue;\n\n const colon = line.indexOf(\":\");\n const field = colon === -1 ? line : line.slice(0, colon);\n let value = colon === -1 ? \"\" : line.slice(colon + 1);\n if (value.startsWith(\" \")) value = value.slice(1);\n\n if (field === \"event\") {\n eventName = value;\n } else if (field === \"data\") {\n dataLines.push(value);\n }\n }\n }\n\n return { feed, end: dispatch };\n}\n\nfunction anySignal(signals: Array<AbortSignal | undefined>): AbortSignal | undefined {\n const present = signals.filter(Boolean) as AbortSignal[];\n if (present.length === 0) return undefined;\n if (present.length === 1) return present[0];\n const controller = new AbortController();\n const onAbort = () => controller.abort();\n for (const s of present) {\n if (s.aborted) {\n controller.abort();\n break;\n }\n s.addEventListener(\"abort\", onAbort, { once: true });\n }\n return controller.signal;\n}\n\n/**\n * Seclai JavaScript/TypeScript client.\n *\n * @remarks\n * - Uses API key auth via `x-api-key` by default.\n * - Throws SDK exceptions for non-success responses.\n */\nexport class Seclai {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly apiKeyHeader: string;\n private readonly defaultHeaders: Record<string, string>;\n private readonly fetcher: FetchLike;\n\n /**\n * Create a new Seclai client.\n *\n * @param opts - Client configuration.\n * @throws {@link SeclaiConfigurationError} If no API key is provided (and `SECLAI_API_KEY` is not set).\n * @throws {@link SeclaiConfigurationError} If no `fetch` implementation is available.\n */\n constructor(opts: SeclaiOptions = {}) {\n const apiKey = opts.apiKey ?? getEnv(\"SECLAI_API_KEY\");\n if (!apiKey) {\n throw new SeclaiConfigurationError(\n \"Missing API key. Provide apiKey or set SECLAI_API_KEY.\"\n );\n }\n\n const fetcher = opts.fetch ?? (globalThis.fetch as FetchLike | undefined);\n if (!fetcher) {\n throw new SeclaiConfigurationError(\n \"No fetch implementation available. Provide opts.fetch or run in an environment with global fetch.\"\n );\n }\n\n this.apiKey = apiKey;\n this.baseUrl = opts.baseUrl ?? getEnv(\"SECLAI_API_URL\") ?? SECLAI_API_URL;\n this.apiKeyHeader = opts.apiKeyHeader ?? \"x-api-key\";\n this.defaultHeaders = { ...(opts.defaultHeaders ?? {}) };\n this.fetcher = fetcher;\n }\n\n /**\n * Make a raw HTTP request to the Seclai API.\n *\n * This is a low-level escape hatch. For most operations, prefer the typed convenience methods.\n *\n * @param method - HTTP method (e.g. `\"GET\"`, `\"POST\"`).\n * @param path - Request path relative to `baseUrl` (e.g. `\"/sources/\"`).\n * @param opts - Query params, JSON body, and per-request headers.\n * @returns Parsed JSON for JSON responses, raw text for non-JSON responses, or `null` for empty bodies.\n * @throws {@link SeclaiAPIValidationError} For validation errors (typically HTTP 422).\n * @throws {@link SeclaiAPIStatusError} For other non-success HTTP status codes.\n */\n async request(\n method: string,\n path: string,\n opts?: {\n query?: Record<string, unknown>;\n json?: unknown;\n headers?: Record<string, string>;\n }\n ): Promise<unknown | string | null> {\n const url = buildURL(this.baseUrl, path, opts?.query);\n\n const headers: Record<string, string> = {\n ...this.defaultHeaders,\n ...(opts?.headers ?? {}),\n [this.apiKeyHeader]: this.apiKey,\n };\n\n let body: BodyInit | undefined;\n if (opts?.json !== undefined) {\n headers[\"content-type\"] = headers[\"content-type\"] ?? \"application/json\";\n body = JSON.stringify(opts.json);\n }\n\n const init: RequestInit = { method, headers };\n if (body !== undefined) {\n init.body = body;\n }\n const response = await this.fetcher(url, init);\n\n if (response.status === 204) return null;\n\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n const isJson = contentType.includes(\"application/json\");\n\n if (!response.ok) {\n const responseText = await safeText(response);\n if (response.status === 422) {\n const validation = (await safeJson(response)) as HTTPValidationError | undefined;\n throw new SeclaiAPIValidationError({\n message: \"Validation error\",\n statusCode: response.status,\n method,\n url: url.toString(),\n responseText,\n validationError: validation,\n });\n }\n throw new SeclaiAPIStatusError({\n message: `Request failed with status ${response.status}`,\n statusCode: response.status,\n method,\n url: url.toString(),\n responseText,\n });\n }\n\n if (!response.body) return null;\n\n if (isJson) {\n return (await response.json()) as unknown;\n }\n return await response.text();\n }\n\n /**\n * Run an agent.\n *\n * @param agentId - Agent identifier.\n * @param body - Agent run request payload.\n * @returns The created agent run.\n */\n async runAgent(agentId: string, body: AgentRunRequest): Promise<AgentRunResponse> {\n const data = await this.request(\"POST\", `/agents/${agentId}/runs`, { json: body });\n return data as AgentRunResponse;\n }\n\n /**\n * Run an agent in streaming mode (SSE) and block until the final `done` event.\n *\n * @param agentId - Agent identifier.\n * @param body - Streaming agent run request payload.\n * @param opts - Optional timeout + abort signal.\n * @returns Final agent run payload from the `done` event.\n */\n async runStreamingAgentAndWait(\n agentId: string,\n body: AgentRunStreamRequest,\n opts?: { timeoutMs?: number; signal?: AbortSignal }\n ): Promise<AgentRunResponse> {\n const url = buildURL(this.baseUrl, `/agents/${agentId}/runs/stream`);\n\n const headers: Record<string, string> = {\n ...this.defaultHeaders,\n [this.apiKeyHeader]: this.apiKey,\n accept: \"text/event-stream\",\n \"content-type\": \"application/json\",\n };\n\n const timeoutMs = opts?.timeoutMs ?? 60_000;\n const timeoutController = new AbortController();\n let timedOut = false;\n const timeoutId = setTimeout(() => {\n timedOut = true;\n timeoutController.abort();\n }, timeoutMs);\n\n const signal = anySignal([opts?.signal, timeoutController.signal]);\n\n try {\n const init: RequestInit = {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n };\n if (signal) init.signal = signal;\n\n const response = await this.fetcher(url, init);\n\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n const isJson = contentType.includes(\"application/json\");\n\n if (!response.ok) {\n const responseText = await safeText(response);\n if (response.status === 422) {\n const validation = (await safeJson(response)) as HTTPValidationError | undefined;\n throw new SeclaiAPIValidationError({\n message: \"Validation error\",\n statusCode: response.status,\n method: \"POST\",\n url: url.toString(),\n responseText,\n validationError: validation,\n });\n }\n throw new SeclaiAPIStatusError({\n message: `Request failed with status ${response.status}`,\n statusCode: response.status,\n method: \"POST\",\n url: url.toString(),\n responseText,\n });\n }\n\n // Some servers may choose to return a JSON response even when we request SSE.\n if (isJson) {\n return (await response.json()) as AgentRunResponse;\n }\n\n if (!response.body) {\n throw new SeclaiConfigurationError(\n \"Streaming response body is not available in this environment. Provide a fetch implementation that supports ReadableStream bodies.\"\n );\n }\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n\n let final: AgentRunResponse | undefined;\n let lastSeen: AgentRunResponse | undefined;\n\n const parser = createSseParser((msg) => {\n if (!msg.data) return;\n\n // `init` and `done` messages contain JSON payloads in `data:`.\n if (msg.event === \"init\" || msg.event === \"done\") {\n try {\n const parsed = JSON.parse(msg.data) as AgentRunResponse;\n lastSeen = parsed;\n if (msg.event === \"done\") {\n final = parsed;\n }\n } catch {\n // Ignore malformed JSON chunks.\n }\n }\n });\n\n while (!final) {\n const { value, done } = await reader.read();\n if (done) break;\n if (value) parser.feed(decoder.decode(value, { stream: true }));\n }\n\n parser.end();\n\n if (final) return final;\n if (lastSeen && (lastSeen as any).status && (lastSeen as any).status !== \"pending\") {\n return lastSeen;\n }\n\n throw new SeclaiError(\"Stream ended before receiving a 'done' event.\");\n } catch (err) {\n if (timedOut) {\n throw new SeclaiError(`Timed out after ${timeoutMs}ms waiting for streaming agent run to complete.`);\n }\n throw err;\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n /**\n * List agent runs for an agent.\n *\n * @param agentId - Agent identifier.\n * @param opts - Pagination options.\n * @returns A paginated list of runs.\n */\n async listAgentRuns(\n agentId: string,\n opts: { page?: number; limit?: number } = {}\n ): Promise<AgentRunListResponse> {\n const data = await this.request(\"GET\", `/agents/${agentId}/runs`, {\n query: { page: opts.page ?? 1, limit: opts.limit ?? 50 },\n });\n return data as AgentRunListResponse;\n }\n\n /**\n * Get details of a specific agent run.\n *\n * @param runId - Run identifier.\n * @param opts - Optional flags.\n * @returns Agent run details.\n */\n async getAgentRun(\n runId: string,\n opts?: { includeStepOutputs?: boolean }\n ): Promise<AgentRunResponse>;\n /** @deprecated Backwards compatibility; agentId is no longer required. */\n async getAgentRun(\n agentId: string,\n runId: string,\n opts?: { includeStepOutputs?: boolean }\n ): Promise<AgentRunResponse>;\n async getAgentRun(\n arg1: string,\n arg2?: string | { includeStepOutputs?: boolean },\n arg3: { includeStepOutputs?: boolean } = {}\n ): Promise<AgentRunResponse> {\n const hasOldSignature = typeof arg2 === \"string\";\n const runId = hasOldSignature ? (arg2 as string) : arg1;\n const opts = hasOldSignature ? arg3 : ((arg2 as { includeStepOutputs?: boolean } | undefined) ?? {});\n\n const data = await this.request(\n \"GET\",\n `/agents/runs/${runId}`,\n opts.includeStepOutputs ? { query: { include_step_outputs: true } } : undefined\n );\n return data as AgentRunResponse;\n }\n\n /**\n * Cancel an agent run.\n *\n * @param runId - Run identifier.\n * @returns Updated agent run record.\n */\n async deleteAgentRun(runId: string): Promise<AgentRunResponse>;\n /** @deprecated Backwards compatibility; agentId is no longer required. */\n async deleteAgentRun(agentId: string, runId: string): Promise<AgentRunResponse>;\n async deleteAgentRun(arg1: string, arg2?: string): Promise<AgentRunResponse> {\n const runId = arg2 ?? arg1;\n const data = await this.request(\"DELETE\", `/agents/runs/${runId}`);\n return data as AgentRunResponse;\n }\n\n /**\n * Get content detail.\n *\n * Fetches a slice of a content version (use `start`/`end` to page through large content).\n *\n * @param sourceConnectionContentVersion - Content version identifier.\n * @param opts - Range options.\n * @returns Content details for the requested range.\n */\n async getContentDetail(\n sourceConnectionContentVersion: string,\n opts: { start?: number; end?: number } = {}\n ): Promise<ContentDetailResponse> {\n const data = await this.request(\n \"GET\",\n `/contents/${sourceConnectionContentVersion}`,\n { query: { start: opts.start ?? 0, end: opts.end ?? 5000 } }\n );\n return data as ContentDetailResponse;\n }\n\n /**\n * Delete a specific content version.\n *\n * @param sourceConnectionContentVersion - Content version identifier.\n */\n async deleteContent(sourceConnectionContentVersion: string): Promise<void> {\n await this.request(\"DELETE\", `/contents/${sourceConnectionContentVersion}`);\n }\n\n /**\n * List embeddings for a content version.\n *\n * @param sourceConnectionContentVersion - Content version identifier.\n * @param opts - Pagination options.\n * @returns A paginated list of embeddings.\n */\n async listContentEmbeddings(\n sourceConnectionContentVersion: string,\n opts: { page?: number; limit?: number } = {}\n ): Promise<ContentEmbeddingsListResponse> {\n const data = await this.request(\n \"GET\",\n `/contents/${sourceConnectionContentVersion}/embeddings`,\n { query: { page: opts.page ?? 1, limit: opts.limit ?? 20 } }\n );\n return data as ContentEmbeddingsListResponse;\n }\n\n /**\n * List sources.\n *\n * @param opts - Pagination and filter options.\n * @returns A paginated list of sources.\n */\n async listSources(\n opts: {\n page?: number;\n limit?: number;\n sort?: string;\n order?: \"asc\" | \"desc\";\n accountId?: string | null;\n } = {}\n ): Promise<SourceListResponse> {\n const data = await this.request(\"GET\", \"/sources/\", {\n query: {\n page: opts.page ?? 1,\n limit: opts.limit ?? 20,\n sort: opts.sort ?? \"created_at\",\n order: opts.order ?? \"desc\",\n account_id: opts.accountId ?? undefined,\n },\n });\n return data as SourceListResponse;\n }\n\n /**\n * Upload a file to a specific source connection.\n *\n * Maximum file size: 200 MiB.\n *\n * Supported MIME types:\n * - `application/epub+zip`\n * - `application/json`\n * - `application/msword`\n * - `application/pdf`\n * - `application/vnd.ms-excel`\n * - `application/vnd.ms-outlook`\n * - `application/vnd.ms-powerpoint`\n * - `application/vnd.openxmlformats-officedocument.presentationml.presentation`\n * - `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`\n * - `application/vnd.openxmlformats-officedocument.wordprocessingml.document`\n * - `application/xml`\n * - `application/zip`\n * - `audio/flac`, `audio/mp4`, `audio/mpeg`, `audio/ogg`, `audio/wav`\n * - `image/bmp`, `image/gif`, `image/jpeg`, `image/png`, `image/tiff`, `image/webp`\n * - `text/csv`, `text/html`, `text/markdown`, `text/x-markdown`, `text/plain`, `text/xml`\n * - `video/mp4`, `video/quicktime`, `video/x-msvideo`\n *\n * Notes:\n * - If `mimeType` is omitted, the upload is typically sent as `application/octet-stream`.\n * In that case, the server attempts to infer the type from the uploaded filename/extension,\n * so prefer providing `fileName` with a meaningful extension (e.g. `\"recording.mp3\"`).\n *\n * @param sourceConnectionId - Source connection identifier.\n * @param opts - File payload and optional metadata.\n * @param opts.file - File payload as a `Blob`, `Uint8Array`, or `ArrayBuffer`.\n * @param opts.title - Optional title for the uploaded file.\n * @param opts.fileName - Optional filename to send with the upload.\n * @param opts.mimeType - Optional MIME type to attach to the upload.\n * @returns Upload response details.\n */\n async uploadFileToSource(\n sourceConnectionId: string,\n opts: {\n file: Blob | Uint8Array | ArrayBuffer;\n title?: string;\n fileName?: string;\n mimeType?: string;\n }\n ): Promise<FileUploadResponse> {\n const url = buildURL(this.baseUrl, `/sources/${sourceConnectionId}/upload`);\n\n const headers: Record<string, string> = {\n ...this.defaultHeaders,\n [this.apiKeyHeader]: this.apiKey,\n };\n\n const form = new FormData();\n\n let blob: Blob;\n if (opts.file instanceof Blob) {\n blob = opts.file;\n } else if (opts.file instanceof ArrayBuffer) {\n const blobOpts = opts.mimeType ? { type: opts.mimeType } : undefined;\n blob = new Blob([new Uint8Array(opts.file)], blobOpts);\n } else {\n const blobOpts = opts.mimeType ? { type: opts.mimeType } : undefined;\n blob = new Blob([opts.file as unknown as BlobPart], blobOpts);\n }\n\n const fileName = opts.fileName ?? \"upload\";\n form.set(\"file\", blob, fileName);\n\n if (opts.title !== undefined) {\n form.set(\"title\", opts.title);\n }\n\n const response = await this.fetcher(url, {\n method: \"POST\",\n headers,\n body: form,\n });\n\n if (!response.ok) {\n const responseText = await safeText(response);\n if (response.status === 422) {\n const validation = (await safeJson(response)) as HTTPValidationError | undefined;\n throw new SeclaiAPIValidationError({\n message: \"Validation error\",\n statusCode: response.status,\n method: \"POST\",\n url: url.toString(),\n responseText,\n validationError: validation,\n });\n }\n throw new SeclaiAPIStatusError({\n message: `Request failed with status ${response.status}`,\n statusCode: response.status,\n method: \"POST\",\n url: url.toString(),\n responseText,\n });\n }\n\n return (await response.json()) as FileUploadResponse;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCO,IAAM,cAAN,cAA0B,MAAM;AAAA,EACrC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAGO,IAAM,2BAAN,cAAuC,YAAY;AAAA,EACxD,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAQO,IAAM,uBAAN,cAAmC,YAAY;AAAA;AAAA,EAEpC;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,MAOT;AACD,UAAM,KAAK,OAAO;AAClB,SAAK,OAAO;AACZ,SAAK,aAAa,KAAK;AACvB,SAAK,SAAS,KAAK;AACnB,SAAK,MAAM,KAAK;AAChB,SAAK,eAAe,KAAK;AAAA,EAC3B;AACF;AAOO,IAAM,2BAAN,cAAuC,qBAAqB;AAAA;AAAA,EAEjD;AAAA,EAEhB,YAAY,MAOT;AACD,UAAM,IAAI;AACV,SAAK,OAAO;AACZ,SAAK,kBAAkB,KAAK;AAAA,EAC9B;AACF;;;ACnDO,IAAM,iBAAiB;AAmB9B,SAAS,OAAO,MAAkC;AAChD,QAAM,IAAK,YAAoB;AAC/B,SAAO,G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
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/client.ts"],"sourcesContent":["export {\n Seclai,\n SECLAI_API_URL,\n type SeclaiOptions,\n type FetchLike,\n} from \"./client\";\n\nexport {\n SeclaiError,\n SeclaiConfigurationError,\n SeclaiAPIStatusError,\n SeclaiAPIValidationError,\n} from \"./errors\";\n\nexport type {\n JSONValue,\n AgentRunRequest,\n AgentRunStreamRequest,\n AgentRunResponse,\n AgentRunListResponse,\n ContentDetailResponse,\n ContentEmbeddingsListResponse,\n SourceListResponse,\n FileUploadResponse,\n SourceFileUploadResponse,\n ContentFileUploadResponse,\n HTTPValidationError,\n} from \"./types\";\n","/** Base error class for the Seclai SDK. */\nexport class SeclaiError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"SeclaiError\";\n }\n}\n\n/** Thrown when the SDK is misconfigured (for example, missing API key). */\nexport class SeclaiConfigurationError extends SeclaiError {\n constructor(message: string) {\n super(message);\n this.name = \"SeclaiConfigurationError\";\n }\n}\n\n/**\n * Thrown when the API returns a non-success status code.\n *\n * @remarks\n * Use {@link SeclaiAPIValidationError} for HTTP 422 validation errors.\n */\nexport class SeclaiAPIStatusError extends SeclaiError {\n /** HTTP status code returned by the API. */\n public readonly statusCode: number;\n /** HTTP method used for the request. */\n public readonly method: string;\n /** Full request URL. */\n public readonly url: string;\n /** Best-effort response body text (if available). */\n public readonly responseText: string | undefined;\n\n constructor(opts: {\n /** Human-readable error message. */\n message: string;\n statusCode: number;\n method: string;\n url: string;\n responseText: string | undefined;\n }) {\n super(opts.message);\n this.name = \"SeclaiAPIStatusError\";\n this.statusCode = opts.statusCode;\n this.method = opts.method;\n this.url = opts.url;\n this.responseText = opts.responseText;\n }\n}\n\n/**\n * Thrown when the API returns a validation error response (typically HTTP 422).\n *\n * The `validationError` field contains the decoded validation payload when available.\n */\nexport class SeclaiAPIValidationError extends SeclaiAPIStatusError {\n /** Parsed validation error payload (best-effort). */\n public readonly validationError: unknown;\n\n constructor(opts: {\n message: string;\n statusCode: number;\n method: string;\n url: string;\n responseText: string | undefined;\n validationError: unknown;\n }) {\n super(opts);\n this.name = \"SeclaiAPIValidationError\";\n this.validationError = opts.validationError;\n }\n}\n","import {\n SeclaiAPIStatusError,\n SeclaiAPIValidationError,\n SeclaiConfigurationError,\n SeclaiError,\n} from \"./errors\";\nimport type {\n AgentRunListResponse,\n AgentRunRequest,\n AgentRunResponse,\n AgentRunStreamRequest,\n ContentDetailResponse,\n ContentEmbeddingsListResponse,\n FileUploadResponse,\n HTTPValidationError,\n SourceListResponse,\n} from \"./types\";\n\n/** Default API base URL (can be overridden with `baseUrl` or `SECLAI_API_URL`). */\nexport const SECLAI_API_URL = \"https://api.seclai.com\";\n\n/** A `fetch`-compatible function (e.g. `globalThis.fetch` or `undici.fetch`). */\nexport type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;\n\n/** Configuration for the {@link Seclai} client. */\nexport interface SeclaiOptions {\n /** API key used for authentication. Defaults to `process.env.SECLAI_API_KEY` when available. */\n apiKey?: string;\n /** API base URL. Defaults to `process.env.SECLAI_API_URL` when available, else {@link SECLAI_API_URL}. */\n baseUrl?: string;\n /** Header name to use for the API key. Defaults to `x-api-key`. */\n apiKeyHeader?: string;\n /** Extra headers to include on every request. */\n defaultHeaders?: Record<string, string>;\n /** Optional `fetch` implementation for environments without a global `fetch`. */\n fetch?: FetchLike;\n}\n\nfunction getEnv(name: string): string | undefined {\n const p = (globalThis as any)?.process;\n return p?.env?.[name];\n}\n\nfunction buildURL(baseUrl: string, path: string, query?: Record<string, unknown>): URL {\n const url = new URL(path, baseUrl);\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined || value === null) continue;\n url.searchParams.set(key, String(value));\n }\n }\n return url;\n}\n\nasync function safeText(response: Response): Promise<string | undefined> {\n try {\n return await response.clone().text();\n } catch {\n return undefined;\n }\n}\n\nasync function safeJson(response: Response): Promise<unknown | undefined> {\n try {\n return await response.clone().json();\n } catch {\n return undefined;\n }\n}\n\ntype SseMessage = { event?: string; data?: string };\n\nfunction createSseParser(onMessage: (msg: SseMessage) => void) {\n let buffer = \"\";\n let eventName: string | undefined;\n let dataLines: string[] = [];\n\n function dispatch() {\n if (!eventName && dataLines.length === 0) return;\n const msg: SseMessage = { data: dataLines.join(\"\\n\") };\n if (eventName !== undefined) msg.event = eventName;\n onMessage(msg);\n eventName = undefined;\n dataLines = [];\n }\n\n function feed(textChunk: string) {\n buffer += textChunk;\n while (true) {\n const newlineIdx = buffer.indexOf(\"\\n\");\n if (newlineIdx === -1) return;\n\n let line = buffer.slice(0, newlineIdx);\n buffer = buffer.slice(newlineIdx + 1);\n\n if (line.endsWith(\"\\r\")) line = line.slice(0, -1);\n\n if (line === \"\") {\n dispatch();\n continue;\n }\n\n // Comments/keepalives begin with ':'\n if (line.startsWith(\":\")) continue;\n\n const colon = line.indexOf(\":\");\n const field = colon === -1 ? line : line.slice(0, colon);\n let value = colon === -1 ? \"\" : line.slice(colon + 1);\n if (value.startsWith(\" \")) value = value.slice(1);\n\n if (field === \"event\") {\n eventName = value;\n } else if (field === \"data\") {\n dataLines.push(value);\n }\n }\n }\n\n return { feed, end: dispatch };\n}\n\nfunction anySignal(signals: Array<AbortSignal | undefined>): AbortSignal | undefined {\n const present = signals.filter(Boolean) as AbortSignal[];\n if (present.length === 0) return undefined;\n if (present.length === 1) return present[0];\n const controller = new AbortController();\n const onAbort = () => controller.abort();\n for (const s of present) {\n if (s.aborted) {\n controller.abort();\n break;\n }\n s.addEventListener(\"abort\", onAbort, { once: true });\n }\n return controller.signal;\n}\n\n/**\n * Seclai JavaScript/TypeScript client.\n *\n * @remarks\n * - Uses API key auth via `x-api-key` by default.\n * - Throws SDK exceptions for non-success responses.\n */\nexport class Seclai {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly apiKeyHeader: string;\n private readonly defaultHeaders: Record<string, string>;\n private readonly fetcher: FetchLike;\n\n /**\n * Create a new Seclai client.\n *\n * @param opts - Client configuration.\n * @throws {@link SeclaiConfigurationError} If no API key is provided (and `SECLAI_API_KEY` is not set).\n * @throws {@link SeclaiConfigurationError} If no `fetch` implementation is available.\n */\n constructor(opts: SeclaiOptions = {}) {\n const apiKey = opts.apiKey ?? getEnv(\"SECLAI_API_KEY\");\n if (!apiKey) {\n throw new SeclaiConfigurationError(\n \"Missing API key. Provide apiKey or set SECLAI_API_KEY.\"\n );\n }\n\n const fetcher = opts.fetch ?? (globalThis.fetch as FetchLike | undefined);\n if (!fetcher) {\n throw new SeclaiConfigurationError(\n \"No fetch implementation available. Provide opts.fetch or run in an environment with global fetch.\"\n );\n }\n\n this.apiKey = apiKey;\n this.baseUrl = opts.baseUrl ?? getEnv(\"SECLAI_API_URL\") ?? SECLAI_API_URL;\n this.apiKeyHeader = opts.apiKeyHeader ?? \"x-api-key\";\n this.defaultHeaders = { ...(opts.defaultHeaders ?? {}) };\n this.fetcher = fetcher;\n }\n\n /**\n * Make a raw HTTP request to the Seclai API.\n *\n * This is a low-level escape hatch. For most operations, prefer the typed convenience methods.\n *\n * @param method - HTTP method (e.g. `\"GET\"`, `\"POST\"`).\n * @param path - Request path relative to `baseUrl` (e.g. `\"/sources/\"`).\n * @param opts - Query params, JSON body, and per-request headers.\n * @returns Parsed JSON for JSON responses, raw text for non-JSON responses, or `null` for empty bodies.\n * @throws {@link SeclaiAPIValidationError} For validation errors (typically HTTP 422).\n * @throws {@link SeclaiAPIStatusError} For other non-success HTTP status codes.\n */\n async request(\n method: string,\n path: string,\n opts?: {\n query?: Record<string, unknown>;\n json?: unknown;\n headers?: Record<string, string>;\n }\n ): Promise<unknown | string | null> {\n const url = buildURL(this.baseUrl, path, opts?.query);\n\n const headers: Record<string, string> = {\n ...this.defaultHeaders,\n ...(opts?.headers ?? {}),\n [this.apiKeyHeader]: this.apiKey,\n };\n\n let body: BodyInit | undefined;\n if (opts?.json !== undefined) {\n headers[\"content-type\"] = headers[\"content-type\"] ?? \"application/json\";\n body = JSON.stringify(opts.json);\n }\n\n const init: RequestInit = { method, headers };\n if (body !== undefined) {\n init.body = body;\n }\n const response = await this.fetcher(url, init);\n\n if (response.status === 204) return null;\n\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n const isJson = contentType.includes(\"application/json\");\n\n if (!response.ok) {\n const responseText = await safeText(response);\n if (response.status === 422) {\n const validation = (await safeJson(response)) as HTTPValidationError | undefined;\n throw new SeclaiAPIValidationError({\n message: \"Validation error\",\n statusCode: response.status,\n method,\n url: url.toString(),\n responseText,\n validationError: validation,\n });\n }\n throw new SeclaiAPIStatusError({\n message: `Request failed with status ${response.status}`,\n statusCode: response.status,\n method,\n url: url.toString(),\n responseText,\n });\n }\n\n if (!response.body) return null;\n\n if (isJson) {\n return (await response.json()) as unknown;\n }\n return await response.text();\n }\n\n /**\n * Run an agent.\n *\n * @param agentId - Agent identifier.\n * @param body - Agent run request payload.\n * @returns The created agent run.\n */\n async runAgent(agentId: string, body: AgentRunRequest): Promise<AgentRunResponse> {\n const data = await this.request(\"POST\", `/agents/${agentId}/runs`, { json: body });\n return data as AgentRunResponse;\n }\n\n /**\n * Run an agent in streaming mode (SSE) and block until the final `done` event.\n *\n * @param agentId - Agent identifier.\n * @param body - Streaming agent run request payload.\n * @param opts - Optional timeout + abort signal.\n * @returns Final agent run payload from the `done` event.\n */\n async runStreamingAgentAndWait(\n agentId: string,\n body: AgentRunStreamRequest,\n opts?: { timeoutMs?: number; signal?: AbortSignal }\n ): Promise<AgentRunResponse> {\n const url = buildURL(this.baseUrl, `/agents/${agentId}/runs/stream`);\n\n const headers: Record<string, string> = {\n ...this.defaultHeaders,\n [this.apiKeyHeader]: this.apiKey,\n accept: \"text/event-stream\",\n \"content-type\": \"application/json\",\n };\n\n const timeoutMs = opts?.timeoutMs ?? 60_000;\n const timeoutController = new AbortController();\n let timedOut = false;\n const timeoutId = setTimeout(() => {\n timedOut = true;\n timeoutController.abort();\n }, timeoutMs);\n\n const signal = anySignal([opts?.signal, timeoutController.signal]);\n\n try {\n const init: RequestInit = {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n };\n if (signal) init.signal = signal;\n\n const response = await this.fetcher(url, init);\n\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n const isJson = contentType.includes(\"application/json\");\n\n if (!response.ok) {\n const responseText = await safeText(response);\n if (response.status === 422) {\n const validation = (await safeJson(response)) as HTTPValidationError | undefined;\n throw new SeclaiAPIValidationError({\n message: \"Validation error\",\n statusCode: response.status,\n method: \"POST\",\n url: url.toString(),\n responseText,\n validationError: validation,\n });\n }\n throw new SeclaiAPIStatusError({\n message: `Request failed with status ${response.status}`,\n statusCode: response.status,\n method: \"POST\",\n url: url.toString(),\n responseText,\n });\n }\n\n // Some servers may choose to return a JSON response even when we request SSE.\n if (isJson) {\n return (await response.json()) as AgentRunResponse;\n }\n\n if (!response.body) {\n throw new SeclaiConfigurationError(\n \"Streaming response body is not available in this environment. Provide a fetch implementation that supports ReadableStream bodies.\"\n );\n }\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n\n let final: AgentRunResponse | undefined;\n let lastSeen: AgentRunResponse | undefined;\n\n const parser = createSseParser((msg) => {\n if (!msg.data) return;\n\n // `init` and `done` messages contain JSON payloads in `data:`.\n if (msg.event === \"init\" || msg.event === \"done\") {\n try {\n const parsed = JSON.parse(msg.data) as AgentRunResponse;\n lastSeen = parsed;\n if (msg.event === \"done\") {\n final = parsed;\n }\n } catch {\n // Ignore malformed JSON chunks.\n }\n }\n });\n\n while (!final) {\n const { value, done } = await reader.read();\n if (done) break;\n if (value) parser.feed(decoder.decode(value, { stream: true }));\n }\n\n parser.end();\n\n if (final) return final;\n if (lastSeen && (lastSeen as any).status && (lastSeen as any).status !== \"pending\") {\n return lastSeen;\n }\n\n throw new SeclaiError(\"Stream ended before receiving a 'done' event.\");\n } catch (err) {\n if (timedOut) {\n throw new SeclaiError(`Timed out after ${timeoutMs}ms waiting for streaming agent run to complete.`);\n }\n throw err;\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n /**\n * List agent runs for an agent.\n *\n * @param agentId - Agent identifier.\n * @param opts - Pagination options.\n * @returns A paginated list of runs.\n */\n async listAgentRuns(\n agentId: string,\n opts: { page?: number; limit?: number } = {}\n ): Promise<AgentRunListResponse> {\n const data = await this.request(\"GET\", `/agents/${agentId}/runs`, {\n query: { page: opts.page ?? 1, limit: opts.limit ?? 50 },\n });\n return data as AgentRunListResponse;\n }\n\n /**\n * Get details of a specific agent run.\n *\n * @param runId - Run identifier.\n * @param opts - Optional flags.\n * @returns Agent run details.\n */\n async getAgentRun(\n runId: string,\n opts?: { includeStepOutputs?: boolean }\n ): Promise<AgentRunResponse>;\n /** @deprecated Backwards compatibility; agentId is no longer required. */\n async getAgentRun(\n agentId: string,\n runId: string,\n opts?: { includeStepOutputs?: boolean }\n ): Promise<AgentRunResponse>;\n async getAgentRun(\n arg1: string,\n arg2?: string | { includeStepOutputs?: boolean },\n arg3: { includeStepOutputs?: boolean } = {}\n ): Promise<AgentRunResponse> {\n const hasOldSignature = typeof arg2 === \"string\";\n const runId = hasOldSignature ? (arg2 as string) : arg1;\n const opts = hasOldSignature ? arg3 : ((arg2 as { includeStepOutputs?: boolean } | undefined) ?? {});\n\n const data = await this.request(\n \"GET\",\n `/agents/runs/${runId}`,\n opts.includeStepOutputs ? { query: { include_step_outputs: true } } : undefined\n );\n return data as AgentRunResponse;\n }\n\n /**\n * Cancel an agent run.\n *\n * @param runId - Run identifier.\n * @returns Updated agent run record.\n */\n async deleteAgentRun(runId: string): Promise<AgentRunResponse>;\n /** @deprecated Backwards compatibility; agentId is no longer required. */\n async deleteAgentRun(agentId: string, runId: string): Promise<AgentRunResponse>;\n async deleteAgentRun(arg1: string, arg2?: string): Promise<AgentRunResponse> {\n const runId = arg2 ?? arg1;\n const data = await this.request(\"DELETE\", `/agents/runs/${runId}`);\n return data as AgentRunResponse;\n }\n\n /**\n * Get content detail.\n *\n * Fetches a slice of a content version (use `start`/`end` to page through large content).\n *\n * @param sourceConnectionContentVersion - Content version identifier.\n * @param opts - Range options.\n * @returns Content details for the requested range.\n */\n async getContentDetail(\n sourceConnectionContentVersion: string,\n opts: { start?: number; end?: number } = {}\n ): Promise<ContentDetailResponse> {\n const data = await this.request(\n \"GET\",\n `/contents/${sourceConnectionContentVersion}`,\n { query: { start: opts.start ?? 0, end: opts.end ?? 5000 } }\n );\n return data as ContentDetailResponse;\n }\n\n /**\n * Delete a specific content version.\n *\n * @param sourceConnectionContentVersion - Content version identifier.\n */\n async deleteContent(sourceConnectionContentVersion: string): Promise<void> {\n await this.request(\"DELETE\", `/contents/${sourceConnectionContentVersion}`);\n }\n\n /**\n * List embeddings for a content version.\n *\n * @param sourceConnectionContentVersion - Content version identifier.\n * @param opts - Pagination options.\n * @returns A paginated list of embeddings.\n */\n async listContentEmbeddings(\n sourceConnectionContentVersion: string,\n opts: { page?: number; limit?: number } = {}\n ): Promise<ContentEmbeddingsListResponse> {\n const data = await this.request(\n \"GET\",\n `/contents/${sourceConnectionContentVersion}/embeddings`,\n { query: { page: opts.page ?? 1, limit: opts.limit ?? 20 } }\n );\n return data as ContentEmbeddingsListResponse;\n }\n\n /**\n * List sources.\n *\n * @param opts - Pagination and filter options.\n * @returns A paginated list of sources.\n */\n async listSources(\n opts: {\n page?: number;\n limit?: number;\n sort?: string;\n order?: \"asc\" | \"desc\";\n accountId?: string | null;\n } = {}\n ): Promise<SourceListResponse> {\n const data = await this.request(\"GET\", \"/sources/\", {\n query: {\n page: opts.page ?? 1,\n limit: opts.limit ?? 20,\n sort: opts.sort ?? \"created_at\",\n order: opts.order ?? \"desc\",\n account_id: opts.accountId ?? undefined,\n },\n });\n return data as SourceListResponse;\n }\n\n /**\n * Upload a file to a specific source connection.\n *\n * Maximum file size: 200 MiB.\n *\n * Supported MIME types:\n * - `application/epub+zip`\n * - `application/json`\n * - `application/msword`\n * - `application/pdf`\n * - `application/vnd.ms-excel`\n * - `application/vnd.ms-outlook`\n * - `application/vnd.ms-powerpoint`\n * - `application/vnd.openxmlformats-officedocument.presentationml.presentation`\n * - `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`\n * - `application/vnd.openxmlformats-officedocument.wordprocessingml.document`\n * - `application/xml`\n * - `application/zip`\n * - `audio/flac`, `audio/mp4`, `audio/mpeg`, `audio/ogg`, `audio/wav`\n * - `image/bmp`, `image/gif`, `image/jpeg`, `image/png`, `image/tiff`, `image/webp`\n * - `text/csv`, `text/html`, `text/markdown`, `text/x-markdown`, `text/plain`, `text/xml`\n * - `video/mp4`, `video/quicktime`, `video/x-msvideo`\n *\n * Notes:\n * - If `mimeType` is omitted, the upload is typically sent as `application/octet-stream`.\n * In that case, the server attempts to infer the type from the uploaded filename/extension,\n * so prefer providing `fileName` with a meaningful extension (e.g. `\"recording.mp3\"`).\n *\n * @param sourceConnectionId - Source connection identifier.\n * @param opts - File payload and optional metadata.\n * @param opts.file - File payload as a `Blob`, `Uint8Array`, or `ArrayBuffer`.\n * @param opts.title - Optional title for the uploaded file.\n * @param opts.metadata - Optional metadata object. This is sent as a JSON string form field named `metadata`.\n * Example: `{ category: \"docs\", author: \"Ada\" }`.\n * @param opts.fileName - Optional filename to send with the upload.\n * @param opts.mimeType - Optional MIME type to attach to the upload.\n * @returns Upload response details.\n */\n async uploadFileToSource(\n sourceConnectionId: string,\n opts: {\n file: Blob | Uint8Array | ArrayBuffer;\n title?: string;\n metadata?: Record<string, unknown>;\n fileName?: string;\n mimeType?: string;\n }\n ): Promise<FileUploadResponse> {\n const url = buildURL(this.baseUrl, `/sources/${sourceConnectionId}/upload`);\n\n const headers: Record<string, string> = {\n ...this.defaultHeaders,\n [this.apiKeyHeader]: this.apiKey,\n };\n\n const form = new FormData();\n\n let blob: Blob;\n if (opts.file instanceof Blob) {\n blob = opts.file;\n } else if (opts.file instanceof ArrayBuffer) {\n const blobOpts = opts.mimeType ? { type: opts.mimeType } : undefined;\n blob = new Blob([new Uint8Array(opts.file)], blobOpts);\n } else {\n const blobOpts = opts.mimeType ? { type: opts.mimeType } : undefined;\n blob = new Blob([opts.file as unknown as BlobPart], blobOpts);\n }\n\n const fileName = opts.fileName ?? \"upload\";\n form.set(\"file\", blob, fileName);\n\n if (opts.title !== undefined) {\n form.set(\"title\", opts.title);\n }\n\n if (opts.metadata !== undefined) {\n form.set(\"metadata\", JSON.stringify(opts.metadata));\n }\n\n const response = await this.fetcher(url, {\n method: \"POST\",\n headers,\n body: form,\n });\n\n if (!response.ok) {\n const responseText = await safeText(response);\n if (response.status === 422) {\n const validation = (await safeJson(response)) as HTTPValidationError | undefined;\n throw new SeclaiAPIValidationError({\n message: \"Validation error\",\n statusCode: response.status,\n method: \"POST\",\n url: url.toString(),\n responseText,\n validationError: validation,\n });\n }\n throw new SeclaiAPIStatusError({\n message: `Request failed with status ${response.status}`,\n statusCode: response.status,\n method: \"POST\",\n url: url.toString(),\n responseText,\n });\n }\n\n return (await response.json()) as FileUploadResponse;\n }\n\n /**\n * Upload a new file and replace the content backing an existing content version.\n *\n * This endpoint is useful when you need to correct or update an uploaded document while keeping\n * references stable (the content version ID stays the same).\n *\n * Notes:\n * - `metadata` is sent as a JSON string form field named `metadata`.\n * - `title` is a convenience field and may be merged into `metadata.title` by the server.\n */\n async uploadFileToContent(\n sourceConnectionContentVersion: string,\n opts: {\n file: Blob | Uint8Array | ArrayBuffer;\n title?: string;\n metadata?: Record<string, unknown>;\n fileName?: string;\n mimeType?: string;\n }\n ): Promise<FileUploadResponse> {\n const url = buildURL(this.baseUrl, `/contents/${sourceConnectionContentVersion}/upload`);\n\n const headers: Record<string, string> = {\n ...this.defaultHeaders,\n [this.apiKeyHeader]: this.apiKey,\n };\n\n const form = new FormData();\n\n let blob: Blob;\n if (opts.file instanceof Blob) {\n blob = opts.file;\n } else if (opts.file instanceof ArrayBuffer) {\n const blobOpts = opts.mimeType ? { type: opts.mimeType } : undefined;\n blob = new Blob([new Uint8Array(opts.file)], blobOpts);\n } else {\n const blobOpts = opts.mimeType ? { type: opts.mimeType } : undefined;\n blob = new Blob([opts.file as unknown as BlobPart], blobOpts);\n }\n\n const fileName = opts.fileName ?? \"upload\";\n form.set(\"file\", blob, fileName);\n\n if (opts.title !== undefined) {\n form.set(\"title\", opts.title);\n }\n if (opts.metadata !== undefined) {\n form.set(\"metadata\", JSON.stringify(opts.metadata));\n }\n\n const response = await this.fetcher(url, {\n method: \"POST\",\n headers,\n body: form,\n });\n\n if (!response.ok) {\n const responseText = await safeText(response);\n if (response.status === 422) {\n const validation = (await safeJson(response)) as HTTPValidationError | undefined;\n throw new SeclaiAPIValidationError({\n message: \"Validation error\",\n statusCode: response.status,\n method: \"POST\",\n url: url.toString(),\n responseText,\n validationError: validation,\n });\n }\n throw new SeclaiAPIStatusError({\n message: `Request failed with status ${response.status}`,\n statusCode: response.status,\n method: \"POST\",\n url: url.toString(),\n responseText,\n });\n }\n\n return (await response.json()) as FileUploadResponse;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCO,IAAM,cAAN,cAA0B,MAAM;AAAA,EACrC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAGO,IAAM,2BAAN,cAAuC,YAAY;AAAA,EACxD,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAQO,IAAM,uBAAN,cAAmC,YAAY;AAAA;AAAA,EAEpC;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,MAOT;AACD,UAAM,KAAK,OAAO;AAClB,SAAK,OAAO;AACZ,SAAK,aAAa,KAAK;AACvB,SAAK,SAAS,KAAK;AACnB,SAAK,MAAM,KAAK;AAChB,SAAK,eAAe,KAAK;AAAA,EAC3B;AACF;AAOO,IAAM,2BAAN,cAAuC,qBAAqB;AAAA;AAAA,EAEjD;AAAA,EAEhB,YAAY,MAOT;AACD,UAAM,I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AAQ;AAAA,MACR;AAAA,MACA,MAAM;AAAA,IACR,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,eAAe,MAAM,SAAS,QAAQ;AAC5C,UAAI,SAAS,WAAW,KAAK;AAC3B,cAAM,aAAc,MAAM,SAAS,QAAQ;AAC3C,cAAM,IAAI,yBAAyB;AAAA,UACjC,SAAS;AAAA,UACT,YAAY,SAAS;AAAA,UACrB,QAAQ;AAAA,UACR,KAAK,IAAI,SAAS;AAAA,UAClB;AAAA,UACA,iBAAiB;AAAA,QACnB,CAAC;AAAA,MACH;AACA,YAAM,IAAI,qBAAqB;AAAA,QAC7B,SAAS,8BAA8B,SAAS,MAAM;AAAA,QACtD,YAAY,SAAS;AAAA,QACrB,QAAQ;AAAA,QACR,KAAK,IAAI,SAAS;AAAA,QAClB;AAAA,MACF,CAAC;AAAA,IACH;AAEA,WAAQ,MAAM,SAAS,KAAK;AAAA,EAC9B;AACF;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -151,6 +151,25 @@ interface components {
|
|
|
151
151
|
[key: string]: components["schemas"]["JsonValue"];
|
|
152
152
|
} | null;
|
|
153
153
|
};
|
|
154
|
+
/** Body_upload_file_to_content_api_contents__source_connection_content_version__upload_post */
|
|
155
|
+
Body_upload_file_to_content_api_contents__source_connection_content_version__upload_post: {
|
|
156
|
+
/**
|
|
157
|
+
* File
|
|
158
|
+
* Format: binary
|
|
159
|
+
* @description File to upload
|
|
160
|
+
*/
|
|
161
|
+
file: string;
|
|
162
|
+
/**
|
|
163
|
+
* Metadata
|
|
164
|
+
* @description Optional JSON object string of metadata. Example: `{"category":"docs","author":"Ada"}`. `title` will be merged into this dictionary as `metadata.title` if it is not already present.
|
|
165
|
+
*/
|
|
166
|
+
metadata?: string | null;
|
|
167
|
+
/**
|
|
168
|
+
* Title
|
|
169
|
+
* @description Optional title for the content
|
|
170
|
+
*/
|
|
171
|
+
title?: string;
|
|
172
|
+
};
|
|
154
173
|
/** Body_upload_file_to_source_api_sources__source_connection_id__upload_post */
|
|
155
174
|
Body_upload_file_to_source_api_sources__source_connection_id__upload_post: {
|
|
156
175
|
/**
|
|
@@ -159,6 +178,11 @@ interface components {
|
|
|
159
178
|
* @description File to upload
|
|
160
179
|
*/
|
|
161
180
|
file: string;
|
|
181
|
+
/**
|
|
182
|
+
* Metadata
|
|
183
|
+
* @description Optional JSON object string of metadata. Example: `{"author":"Ada","category":"docs"}`. `title` will be merged into this dictionary as `metadata.title` if it is not already present.
|
|
184
|
+
*/
|
|
185
|
+
metadata?: string | null;
|
|
162
186
|
/**
|
|
163
187
|
* Title
|
|
164
188
|
* @description Optional title for the content
|
|
@@ -185,32 +209,6 @@ interface components {
|
|
|
185
209
|
/** Vector */
|
|
186
210
|
vector: number[];
|
|
187
211
|
};
|
|
188
|
-
/**
|
|
189
|
-
* FileUploadResponse
|
|
190
|
-
* @description Response model for file upload
|
|
191
|
-
*/
|
|
192
|
-
FileUploadResponse: {
|
|
193
|
-
/**
|
|
194
|
-
* Content Version Id
|
|
195
|
-
* @description ID of the created content version
|
|
196
|
-
*/
|
|
197
|
-
content_version_id: string | null;
|
|
198
|
-
/**
|
|
199
|
-
* Filename
|
|
200
|
-
* @description Original filename
|
|
201
|
-
*/
|
|
202
|
-
filename: string;
|
|
203
|
-
/**
|
|
204
|
-
* Source Connection Content Version Id
|
|
205
|
-
* @description ID of the duplicate source connection content version
|
|
206
|
-
*/
|
|
207
|
-
source_connection_content_version_id: string | null;
|
|
208
|
-
/**
|
|
209
|
-
* Status
|
|
210
|
-
* @description Processing status
|
|
211
|
-
*/
|
|
212
|
-
status: string;
|
|
213
|
-
};
|
|
214
212
|
/** HTTPValidationError */
|
|
215
213
|
HTTPValidationError: {
|
|
216
214
|
/** Detail */
|
|
@@ -530,6 +528,58 @@ interface components {
|
|
|
530
528
|
data: components["schemas"]["ContentEmbeddingResponse"][];
|
|
531
529
|
pagination: components["schemas"]["PaginationResponse"];
|
|
532
530
|
};
|
|
531
|
+
/**
|
|
532
|
+
* FileUploadResponse
|
|
533
|
+
* @description Response model for content file replacement upload.
|
|
534
|
+
*/
|
|
535
|
+
routers__api__contents__FileUploadResponse: {
|
|
536
|
+
/**
|
|
537
|
+
* Content Version Id
|
|
538
|
+
* @description ID of the content version being replaced
|
|
539
|
+
*/
|
|
540
|
+
content_version_id: string | null;
|
|
541
|
+
/**
|
|
542
|
+
* Filename
|
|
543
|
+
* @description Original filename
|
|
544
|
+
*/
|
|
545
|
+
filename: string;
|
|
546
|
+
/**
|
|
547
|
+
* Source Connection Content Version Id
|
|
548
|
+
* @description ID of the source connection content version
|
|
549
|
+
*/
|
|
550
|
+
source_connection_content_version_id: string | null;
|
|
551
|
+
/**
|
|
552
|
+
* Status
|
|
553
|
+
* @description Processing status
|
|
554
|
+
*/
|
|
555
|
+
status: string;
|
|
556
|
+
};
|
|
557
|
+
/**
|
|
558
|
+
* FileUploadResponse
|
|
559
|
+
* @description Response model for file upload
|
|
560
|
+
*/
|
|
561
|
+
routers__api__sources__FileUploadResponse: {
|
|
562
|
+
/**
|
|
563
|
+
* Content Version Id
|
|
564
|
+
* @description ID of the created content version
|
|
565
|
+
*/
|
|
566
|
+
content_version_id: string | null;
|
|
567
|
+
/**
|
|
568
|
+
* Filename
|
|
569
|
+
* @description Original filename
|
|
570
|
+
*/
|
|
571
|
+
filename: string;
|
|
572
|
+
/**
|
|
573
|
+
* Source Connection Content Version Id
|
|
574
|
+
* @description ID of the duplicate source connection content version
|
|
575
|
+
*/
|
|
576
|
+
source_connection_content_version_id: string | null;
|
|
577
|
+
/**
|
|
578
|
+
* Status
|
|
579
|
+
* @description Processing status
|
|
580
|
+
*/
|
|
581
|
+
status: string;
|
|
582
|
+
};
|
|
533
583
|
/**
|
|
534
584
|
* SourceListResponse
|
|
535
585
|
* @description Response model for paginated source list
|
|
@@ -565,8 +615,22 @@ type ContentDetailResponse = components["schemas"]["routers__api__contents__Cont
|
|
|
565
615
|
type ContentEmbeddingsListResponse = components["schemas"]["routers__api__contents__ContentEmbeddingsListResponse"];
|
|
566
616
|
/** Paginated list response for sources. */
|
|
567
617
|
type SourceListResponse = components["schemas"]["routers__api__sources__SourceListResponse"];
|
|
568
|
-
/** Upload response for source
|
|
569
|
-
type FileUploadResponse = components["schemas"]
|
|
618
|
+
/** Upload response for uploads (source upload and content replacement upload). */
|
|
619
|
+
type FileUploadResponse = components["schemas"] extends {
|
|
620
|
+
FileUploadResponse: infer T;
|
|
621
|
+
} ? T : components["schemas"] extends {
|
|
622
|
+
routers__api__sources__FileUploadResponse: infer T;
|
|
623
|
+
} ? T : components["schemas"] extends {
|
|
624
|
+
routers__api__contents__FileUploadResponse: infer T;
|
|
625
|
+
} ? T : never;
|
|
626
|
+
/** Upload response specifically for source uploads (/sources/{id}/upload). */
|
|
627
|
+
type SourceFileUploadResponse = components["schemas"] extends {
|
|
628
|
+
routers__api__sources__FileUploadResponse: infer T;
|
|
629
|
+
} ? T : FileUploadResponse;
|
|
630
|
+
/** Upload response specifically for content replacement uploads (/contents/{id}/upload). */
|
|
631
|
+
type ContentFileUploadResponse = components["schemas"] extends {
|
|
632
|
+
routers__api__contents__FileUploadResponse: infer T;
|
|
633
|
+
} ? T : FileUploadResponse;
|
|
570
634
|
/** Standard OpenAPI validation error shape (typically HTTP 422). */
|
|
571
635
|
type HTTPValidationError = components["schemas"]["HTTPValidationError"];
|
|
572
636
|
|
|
@@ -754,6 +818,8 @@ declare class Seclai {
|
|
|
754
818
|
* @param opts - File payload and optional metadata.
|
|
755
819
|
* @param opts.file - File payload as a `Blob`, `Uint8Array`, or `ArrayBuffer`.
|
|
756
820
|
* @param opts.title - Optional title for the uploaded file.
|
|
821
|
+
* @param opts.metadata - Optional metadata object. This is sent as a JSON string form field named `metadata`.
|
|
822
|
+
* Example: `{ category: "docs", author: "Ada" }`.
|
|
757
823
|
* @param opts.fileName - Optional filename to send with the upload.
|
|
758
824
|
* @param opts.mimeType - Optional MIME type to attach to the upload.
|
|
759
825
|
* @returns Upload response details.
|
|
@@ -761,6 +827,24 @@ declare class Seclai {
|
|
|
761
827
|
uploadFileToSource(sourceConnectionId: string, opts: {
|
|
762
828
|
file: Blob | Uint8Array | ArrayBuffer;
|
|
763
829
|
title?: string;
|
|
830
|
+
metadata?: Record<string, unknown>;
|
|
831
|
+
fileName?: string;
|
|
832
|
+
mimeType?: string;
|
|
833
|
+
}): Promise<FileUploadResponse>;
|
|
834
|
+
/**
|
|
835
|
+
* Upload a new file and replace the content backing an existing content version.
|
|
836
|
+
*
|
|
837
|
+
* This endpoint is useful when you need to correct or update an uploaded document while keeping
|
|
838
|
+
* references stable (the content version ID stays the same).
|
|
839
|
+
*
|
|
840
|
+
* Notes:
|
|
841
|
+
* - `metadata` is sent as a JSON string form field named `metadata`.
|
|
842
|
+
* - `title` is a convenience field and may be merged into `metadata.title` by the server.
|
|
843
|
+
*/
|
|
844
|
+
uploadFileToContent(sourceConnectionContentVersion: string, opts: {
|
|
845
|
+
file: Blob | Uint8Array | ArrayBuffer;
|
|
846
|
+
title?: string;
|
|
847
|
+
metadata?: Record<string, unknown>;
|
|
764
848
|
fileName?: string;
|
|
765
849
|
mimeType?: string;
|
|
766
850
|
}): Promise<FileUploadResponse>;
|
|
@@ -816,4 +900,4 @@ declare class SeclaiAPIValidationError extends SeclaiAPIStatusError {
|
|
|
816
900
|
});
|
|
817
901
|
}
|
|
818
902
|
|
|
819
|
-
export { type AgentRunListResponse, type AgentRunRequest, type AgentRunResponse, type AgentRunStreamRequest, type ContentDetailResponse, type ContentEmbeddingsListResponse, type FetchLike, type FileUploadResponse, type HTTPValidationError, type JSONValue, SECLAI_API_URL, Seclai, SeclaiAPIStatusError, SeclaiAPIValidationError, SeclaiConfigurationError, SeclaiError, type SeclaiOptions, type SourceListResponse };
|
|
903
|
+
export { type AgentRunListResponse, type AgentRunRequest, type AgentRunResponse, type AgentRunStreamRequest, type ContentDetailResponse, type ContentEmbeddingsListResponse, type ContentFileUploadResponse, type FetchLike, type FileUploadResponse, type HTTPValidationError, type JSONValue, SECLAI_API_URL, Seclai, SeclaiAPIStatusError, SeclaiAPIValidationError, SeclaiConfigurationError, SeclaiError, type SeclaiOptions, type SourceFileUploadResponse, type SourceListResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -151,6 +151,25 @@ interface components {
|
|
|
151
151
|
[key: string]: components["schemas"]["JsonValue"];
|
|
152
152
|
} | null;
|
|
153
153
|
};
|
|
154
|
+
/** Body_upload_file_to_content_api_contents__source_connection_content_version__upload_post */
|
|
155
|
+
Body_upload_file_to_content_api_contents__source_connection_content_version__upload_post: {
|
|
156
|
+
/**
|
|
157
|
+
* File
|
|
158
|
+
* Format: binary
|
|
159
|
+
* @description File to upload
|
|
160
|
+
*/
|
|
161
|
+
file: string;
|
|
162
|
+
/**
|
|
163
|
+
* Metadata
|
|
164
|
+
* @description Optional JSON object string of metadata. Example: `{"category":"docs","author":"Ada"}`. `title` will be merged into this dictionary as `metadata.title` if it is not already present.
|
|
165
|
+
*/
|
|
166
|
+
metadata?: string | null;
|
|
167
|
+
/**
|
|
168
|
+
* Title
|
|
169
|
+
* @description Optional title for the content
|
|
170
|
+
*/
|
|
171
|
+
title?: string;
|
|
172
|
+
};
|
|
154
173
|
/** Body_upload_file_to_source_api_sources__source_connection_id__upload_post */
|
|
155
174
|
Body_upload_file_to_source_api_sources__source_connection_id__upload_post: {
|
|
156
175
|
/**
|
|
@@ -159,6 +178,11 @@ interface components {
|
|
|
159
178
|
* @description File to upload
|
|
160
179
|
*/
|
|
161
180
|
file: string;
|
|
181
|
+
/**
|
|
182
|
+
* Metadata
|
|
183
|
+
* @description Optional JSON object string of metadata. Example: `{"author":"Ada","category":"docs"}`. `title` will be merged into this dictionary as `metadata.title` if it is not already present.
|
|
184
|
+
*/
|
|
185
|
+
metadata?: string | null;
|
|
162
186
|
/**
|
|
163
187
|
* Title
|
|
164
188
|
* @description Optional title for the content
|
|
@@ -185,32 +209,6 @@ interface components {
|
|
|
185
209
|
/** Vector */
|
|
186
210
|
vector: number[];
|
|
187
211
|
};
|
|
188
|
-
/**
|
|
189
|
-
* FileUploadResponse
|
|
190
|
-
* @description Response model for file upload
|
|
191
|
-
*/
|
|
192
|
-
FileUploadResponse: {
|
|
193
|
-
/**
|
|
194
|
-
* Content Version Id
|
|
195
|
-
* @description ID of the created content version
|
|
196
|
-
*/
|
|
197
|
-
content_version_id: string | null;
|
|
198
|
-
/**
|
|
199
|
-
* Filename
|
|
200
|
-
* @description Original filename
|
|
201
|
-
*/
|
|
202
|
-
filename: string;
|
|
203
|
-
/**
|
|
204
|
-
* Source Connection Content Version Id
|
|
205
|
-
* @description ID of the duplicate source connection content version
|
|
206
|
-
*/
|
|
207
|
-
source_connection_content_version_id: string | null;
|
|
208
|
-
/**
|
|
209
|
-
* Status
|
|
210
|
-
* @description Processing status
|
|
211
|
-
*/
|
|
212
|
-
status: string;
|
|
213
|
-
};
|
|
214
212
|
/** HTTPValidationError */
|
|
215
213
|
HTTPValidationError: {
|
|
216
214
|
/** Detail */
|
|
@@ -530,6 +528,58 @@ interface components {
|
|
|
530
528
|
data: components["schemas"]["ContentEmbeddingResponse"][];
|
|
531
529
|
pagination: components["schemas"]["PaginationResponse"];
|
|
532
530
|
};
|
|
531
|
+
/**
|
|
532
|
+
* FileUploadResponse
|
|
533
|
+
* @description Response model for content file replacement upload.
|
|
534
|
+
*/
|
|
535
|
+
routers__api__contents__FileUploadResponse: {
|
|
536
|
+
/**
|
|
537
|
+
* Content Version Id
|
|
538
|
+
* @description ID of the content version being replaced
|
|
539
|
+
*/
|
|
540
|
+
content_version_id: string | null;
|
|
541
|
+
/**
|
|
542
|
+
* Filename
|
|
543
|
+
* @description Original filename
|
|
544
|
+
*/
|
|
545
|
+
filename: string;
|
|
546
|
+
/**
|
|
547
|
+
* Source Connection Content Version Id
|
|
548
|
+
* @description ID of the source connection content version
|
|
549
|
+
*/
|
|
550
|
+
source_connection_content_version_id: string | null;
|
|
551
|
+
/**
|
|
552
|
+
* Status
|
|
553
|
+
* @description Processing status
|
|
554
|
+
*/
|
|
555
|
+
status: string;
|
|
556
|
+
};
|
|
557
|
+
/**
|
|
558
|
+
* FileUploadResponse
|
|
559
|
+
* @description Response model for file upload
|
|
560
|
+
*/
|
|
561
|
+
routers__api__sources__FileUploadResponse: {
|
|
562
|
+
/**
|
|
563
|
+
* Content Version Id
|
|
564
|
+
* @description ID of the created content version
|
|
565
|
+
*/
|
|
566
|
+
content_version_id: string | null;
|
|
567
|
+
/**
|
|
568
|
+
* Filename
|
|
569
|
+
* @description Original filename
|
|
570
|
+
*/
|
|
571
|
+
filename: string;
|
|
572
|
+
/**
|
|
573
|
+
* Source Connection Content Version Id
|
|
574
|
+
* @description ID of the duplicate source connection content version
|
|
575
|
+
*/
|
|
576
|
+
source_connection_content_version_id: string | null;
|
|
577
|
+
/**
|
|
578
|
+
* Status
|
|
579
|
+
* @description Processing status
|
|
580
|
+
*/
|
|
581
|
+
status: string;
|
|
582
|
+
};
|
|
533
583
|
/**
|
|
534
584
|
* SourceListResponse
|
|
535
585
|
* @description Response model for paginated source list
|
|
@@ -565,8 +615,22 @@ type ContentDetailResponse = components["schemas"]["routers__api__contents__Cont
|
|
|
565
615
|
type ContentEmbeddingsListResponse = components["schemas"]["routers__api__contents__ContentEmbeddingsListResponse"];
|
|
566
616
|
/** Paginated list response for sources. */
|
|
567
617
|
type SourceListResponse = components["schemas"]["routers__api__sources__SourceListResponse"];
|
|
568
|
-
/** Upload response for source
|
|
569
|
-
type FileUploadResponse = components["schemas"]
|
|
618
|
+
/** Upload response for uploads (source upload and content replacement upload). */
|
|
619
|
+
type FileUploadResponse = components["schemas"] extends {
|
|
620
|
+
FileUploadResponse: infer T;
|
|
621
|
+
} ? T : components["schemas"] extends {
|
|
622
|
+
routers__api__sources__FileUploadResponse: infer T;
|
|
623
|
+
} ? T : components["schemas"] extends {
|
|
624
|
+
routers__api__contents__FileUploadResponse: infer T;
|
|
625
|
+
} ? T : never;
|
|
626
|
+
/** Upload response specifically for source uploads (/sources/{id}/upload). */
|
|
627
|
+
type SourceFileUploadResponse = components["schemas"] extends {
|
|
628
|
+
routers__api__sources__FileUploadResponse: infer T;
|
|
629
|
+
} ? T : FileUploadResponse;
|
|
630
|
+
/** Upload response specifically for content replacement uploads (/contents/{id}/upload). */
|
|
631
|
+
type ContentFileUploadResponse = components["schemas"] extends {
|
|
632
|
+
routers__api__contents__FileUploadResponse: infer T;
|
|
633
|
+
} ? T : FileUploadResponse;
|
|
570
634
|
/** Standard OpenAPI validation error shape (typically HTTP 422). */
|
|
571
635
|
type HTTPValidationError = components["schemas"]["HTTPValidationError"];
|
|
572
636
|
|
|
@@ -754,6 +818,8 @@ declare class Seclai {
|
|
|
754
818
|
* @param opts - File payload and optional metadata.
|
|
755
819
|
* @param opts.file - File payload as a `Blob`, `Uint8Array`, or `ArrayBuffer`.
|
|
756
820
|
* @param opts.title - Optional title for the uploaded file.
|
|
821
|
+
* @param opts.metadata - Optional metadata object. This is sent as a JSON string form field named `metadata`.
|
|
822
|
+
* Example: `{ category: "docs", author: "Ada" }`.
|
|
757
823
|
* @param opts.fileName - Optional filename to send with the upload.
|
|
758
824
|
* @param opts.mimeType - Optional MIME type to attach to the upload.
|
|
759
825
|
* @returns Upload response details.
|
|
@@ -761,6 +827,24 @@ declare class Seclai {
|
|
|
761
827
|
uploadFileToSource(sourceConnectionId: string, opts: {
|
|
762
828
|
file: Blob | Uint8Array | ArrayBuffer;
|
|
763
829
|
title?: string;
|
|
830
|
+
metadata?: Record<string, unknown>;
|
|
831
|
+
fileName?: string;
|
|
832
|
+
mimeType?: string;
|
|
833
|
+
}): Promise<FileUploadResponse>;
|
|
834
|
+
/**
|
|
835
|
+
* Upload a new file and replace the content backing an existing content version.
|
|
836
|
+
*
|
|
837
|
+
* This endpoint is useful when you need to correct or update an uploaded document while keeping
|
|
838
|
+
* references stable (the content version ID stays the same).
|
|
839
|
+
*
|
|
840
|
+
* Notes:
|
|
841
|
+
* - `metadata` is sent as a JSON string form field named `metadata`.
|
|
842
|
+
* - `title` is a convenience field and may be merged into `metadata.title` by the server.
|
|
843
|
+
*/
|
|
844
|
+
uploadFileToContent(sourceConnectionContentVersion: string, opts: {
|
|
845
|
+
file: Blob | Uint8Array | ArrayBuffer;
|
|
846
|
+
title?: string;
|
|
847
|
+
metadata?: Record<string, unknown>;
|
|
764
848
|
fileName?: string;
|
|
765
849
|
mimeType?: string;
|
|
766
850
|
}): Promise<FileUploadResponse>;
|
|
@@ -816,4 +900,4 @@ declare class SeclaiAPIValidationError extends SeclaiAPIStatusError {
|
|
|
816
900
|
});
|
|
817
901
|
}
|
|
818
902
|
|
|
819
|
-
export { type AgentRunListResponse, type AgentRunRequest, type AgentRunResponse, type AgentRunStreamRequest, type ContentDetailResponse, type ContentEmbeddingsListResponse, type FetchLike, type FileUploadResponse, type HTTPValidationError, type JSONValue, SECLAI_API_URL, Seclai, SeclaiAPIStatusError, SeclaiAPIValidationError, SeclaiConfigurationError, SeclaiError, type SeclaiOptions, type SourceListResponse };
|
|
903
|
+
export { type AgentRunListResponse, type AgentRunRequest, type AgentRunResponse, type AgentRunStreamRequest, type ContentDetailResponse, type ContentEmbeddingsListResponse, type ContentFileUploadResponse, type FetchLike, type FileUploadResponse, type HTTPValidationError, type JSONValue, SECLAI_API_URL, Seclai, SeclaiAPIStatusError, SeclaiAPIValidationError, SeclaiConfigurationError, SeclaiError, type SeclaiOptions, type SourceFileUploadResponse, type SourceListResponse };
|
package/dist/index.js
CHANGED
|
@@ -443,6 +443,8 @@ var Seclai = class {
|
|
|
443
443
|
* @param opts - File payload and optional metadata.
|
|
444
444
|
* @param opts.file - File payload as a `Blob`, `Uint8Array`, or `ArrayBuffer`.
|
|
445
445
|
* @param opts.title - Optional title for the uploaded file.
|
|
446
|
+
* @param opts.metadata - Optional metadata object. This is sent as a JSON string form field named `metadata`.
|
|
447
|
+
* Example: `{ category: "docs", author: "Ada" }`.
|
|
446
448
|
* @param opts.fileName - Optional filename to send with the upload.
|
|
447
449
|
* @param opts.mimeType - Optional MIME type to attach to the upload.
|
|
448
450
|
* @returns Upload response details.
|
|
@@ -469,6 +471,72 @@ var Seclai = class {
|
|
|
469
471
|
if (opts.title !== void 0) {
|
|
470
472
|
form.set("title", opts.title);
|
|
471
473
|
}
|
|
474
|
+
if (opts.metadata !== void 0) {
|
|
475
|
+
form.set("metadata", JSON.stringify(opts.metadata));
|
|
476
|
+
}
|
|
477
|
+
const response = await this.fetcher(url, {
|
|
478
|
+
method: "POST",
|
|
479
|
+
headers,
|
|
480
|
+
body: form
|
|
481
|
+
});
|
|
482
|
+
if (!response.ok) {
|
|
483
|
+
const responseText = await safeText(response);
|
|
484
|
+
if (response.status === 422) {
|
|
485
|
+
const validation = await safeJson(response);
|
|
486
|
+
throw new SeclaiAPIValidationError({
|
|
487
|
+
message: "Validation error",
|
|
488
|
+
statusCode: response.status,
|
|
489
|
+
method: "POST",
|
|
490
|
+
url: url.toString(),
|
|
491
|
+
responseText,
|
|
492
|
+
validationError: validation
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
throw new SeclaiAPIStatusError({
|
|
496
|
+
message: `Request failed with status ${response.status}`,
|
|
497
|
+
statusCode: response.status,
|
|
498
|
+
method: "POST",
|
|
499
|
+
url: url.toString(),
|
|
500
|
+
responseText
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
return await response.json();
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Upload a new file and replace the content backing an existing content version.
|
|
507
|
+
*
|
|
508
|
+
* This endpoint is useful when you need to correct or update an uploaded document while keeping
|
|
509
|
+
* references stable (the content version ID stays the same).
|
|
510
|
+
*
|
|
511
|
+
* Notes:
|
|
512
|
+
* - `metadata` is sent as a JSON string form field named `metadata`.
|
|
513
|
+
* - `title` is a convenience field and may be merged into `metadata.title` by the server.
|
|
514
|
+
*/
|
|
515
|
+
async uploadFileToContent(sourceConnectionContentVersion, opts) {
|
|
516
|
+
const url = buildURL(this.baseUrl, `/contents/${sourceConnectionContentVersion}/upload`);
|
|
517
|
+
const headers = {
|
|
518
|
+
...this.defaultHeaders,
|
|
519
|
+
[this.apiKeyHeader]: this.apiKey
|
|
520
|
+
};
|
|
521
|
+
const form = new FormData();
|
|
522
|
+
let blob;
|
|
523
|
+
if (opts.file instanceof Blob) {
|
|
524
|
+
blob = opts.file;
|
|
525
|
+
} else if (opts.file instanceof ArrayBuffer) {
|
|
526
|
+
const blobOpts = opts.mimeType ? { type: opts.mimeType } : void 0;
|
|
527
|
+
blob = new Blob([new Uint8Array(opts.file)], blobOpts);
|
|
528
|
+
} else {
|
|
529
|
+
const blobOpts = opts.mimeType ? { type: opts.mimeType } : void 0;
|
|
530
|
+
blob = new Blob([opts.file], blobOpts);
|
|
531
|
+
}
|
|
532
|
+
const fileName = opts.fileName ?? "upload";
|
|
533
|
+
form.set("file", blob, fileName);
|
|
534
|
+
if (opts.title !== void 0) {
|
|
535
|
+
form.set("title", opts.title);
|
|
536
|
+
}
|
|
537
|
+
if (opts.metadata !== void 0) {
|
|
538
|
+
form.set("metadata", JSON.stringify(opts.metadata));
|
|
539
|
+
}
|
|
472
540
|
const response = await this.fetcher(url, {
|
|
473
541
|
method: "POST",
|
|
474
542
|
headers,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/client.ts"],"sourcesContent":["/** Base error class for the Seclai SDK. */\nexport class SeclaiError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"SeclaiError\";\n }\n}\n\n/** Thrown when the SDK is misconfigured (for example, missing API key). */\nexport class SeclaiConfigurationError extends SeclaiError {\n constructor(message: string) {\n super(message);\n this.name = \"SeclaiConfigurationError\";\n }\n}\n\n/**\n * Thrown when the API returns a non-success status code.\n *\n * @remarks\n * Use {@link SeclaiAPIValidationError} for HTTP 422 validation errors.\n */\nexport class SeclaiAPIStatusError extends SeclaiError {\n /** HTTP status code returned by the API. */\n public readonly statusCode: number;\n /** HTTP method used for the request. */\n public readonly method: string;\n /** Full request URL. */\n public readonly url: string;\n /** Best-effort response body text (if available). */\n public readonly responseText: string | undefined;\n\n constructor(opts: {\n /** Human-readable error message. */\n message: string;\n statusCode: number;\n method: string;\n url: string;\n responseText: string | undefined;\n }) {\n super(opts.message);\n this.name = \"SeclaiAPIStatusError\";\n this.statusCode = opts.statusCode;\n this.method = opts.method;\n this.url = opts.url;\n this.responseText = opts.responseText;\n }\n}\n\n/**\n * Thrown when the API returns a validation error response (typically HTTP 422).\n *\n * The `validationError` field contains the decoded validation payload when available.\n */\nexport class SeclaiAPIValidationError extends SeclaiAPIStatusError {\n /** Parsed validation error payload (best-effort). */\n public readonly validationError: unknown;\n\n constructor(opts: {\n message: string;\n statusCode: number;\n method: string;\n url: string;\n responseText: string | undefined;\n validationError: unknown;\n }) {\n super(opts);\n this.name = \"SeclaiAPIValidationError\";\n this.validationError = opts.validationError;\n }\n}\n","import {\n SeclaiAPIStatusError,\n SeclaiAPIValidationError,\n SeclaiConfigurationError,\n SeclaiError,\n} from \"./errors\";\nimport type {\n AgentRunListResponse,\n AgentRunRequest,\n AgentRunResponse,\n AgentRunStreamRequest,\n ContentDetailResponse,\n ContentEmbeddingsListResponse,\n FileUploadResponse,\n HTTPValidationError,\n SourceListResponse,\n} from \"./types\";\n\n/** Default API base URL (can be overridden with `baseUrl` or `SECLAI_API_URL`). */\nexport const SECLAI_API_URL = \"https://api.seclai.com\";\n\n/** A `fetch`-compatible function (e.g. `globalThis.fetch` or `undici.fetch`). */\nexport type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;\n\n/** Configuration for the {@link Seclai} client. */\nexport interface SeclaiOptions {\n /** API key used for authentication. Defaults to `process.env.SECLAI_API_KEY` when available. */\n apiKey?: string;\n /** API base URL. Defaults to `process.env.SECLAI_API_URL` when available, else {@link SECLAI_API_URL}. */\n baseUrl?: string;\n /** Header name to use for the API key. Defaults to `x-api-key`. */\n apiKeyHeader?: string;\n /** Extra headers to include on every request. */\n defaultHeaders?: Record<string, string>;\n /** Optional `fetch` implementation for environments without a global `fetch`. */\n fetch?: FetchLike;\n}\n\nfunction getEnv(name: string): string | undefined {\n const p = (globalThis as any)?.process;\n return p?.env?.[name];\n}\n\nfunction buildURL(baseUrl: string, path: string, query?: Record<string, unknown>): URL {\n const url = new URL(path, baseUrl);\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined || value === null) continue;\n url.searchParams.set(key, String(value));\n }\n }\n return url;\n}\n\nasync function safeText(response: Response): Promise<string | undefined> {\n try {\n return await response.clone().text();\n } catch {\n return undefined;\n }\n}\n\nasync function safeJson(response: Response): Promise<unknown | undefined> {\n try {\n return await response.clone().json();\n } catch {\n return undefined;\n }\n}\n\ntype SseMessage = { event?: string; data?: string };\n\nfunction createSseParser(onMessage: (msg: SseMessage) => void) {\n let buffer = \"\";\n let eventName: string | undefined;\n let dataLines: string[] = [];\n\n function dispatch() {\n if (!eventName && dataLines.length === 0) return;\n const msg: SseMessage = { data: dataLines.join(\"\\n\") };\n if (eventName !== undefined) msg.event = eventName;\n onMessage(msg);\n eventName = undefined;\n dataLines = [];\n }\n\n function feed(textChunk: string) {\n buffer += textChunk;\n while (true) {\n const newlineIdx = buffer.indexOf(\"\\n\");\n if (newlineIdx === -1) return;\n\n let line = buffer.slice(0, newlineIdx);\n buffer = buffer.slice(newlineIdx + 1);\n\n if (line.endsWith(\"\\r\")) line = line.slice(0, -1);\n\n if (line === \"\") {\n dispatch();\n continue;\n }\n\n // Comments/keepalives begin with ':'\n if (line.startsWith(\":\")) continue;\n\n const colon = line.indexOf(\":\");\n const field = colon === -1 ? line : line.slice(0, colon);\n let value = colon === -1 ? \"\" : line.slice(colon + 1);\n if (value.startsWith(\" \")) value = value.slice(1);\n\n if (field === \"event\") {\n eventName = value;\n } else if (field === \"data\") {\n dataLines.push(value);\n }\n }\n }\n\n return { feed, end: dispatch };\n}\n\nfunction anySignal(signals: Array<AbortSignal | undefined>): AbortSignal | undefined {\n const present = signals.filter(Boolean) as AbortSignal[];\n if (present.length === 0) return undefined;\n if (present.length === 1) return present[0];\n const controller = new AbortController();\n const onAbort = () => controller.abort();\n for (const s of present) {\n if (s.aborted) {\n controller.abort();\n break;\n }\n s.addEventListener(\"abort\", onAbort, { once: true });\n }\n return controller.signal;\n}\n\n/**\n * Seclai JavaScript/TypeScript client.\n *\n * @remarks\n * - Uses API key auth via `x-api-key` by default.\n * - Throws SDK exceptions for non-success responses.\n */\nexport class Seclai {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly apiKeyHeader: string;\n private readonly defaultHeaders: Record<string, string>;\n private readonly fetcher: FetchLike;\n\n /**\n * Create a new Seclai client.\n *\n * @param opts - Client configuration.\n * @throws {@link SeclaiConfigurationError} If no API key is provided (and `SECLAI_API_KEY` is not set).\n * @throws {@link SeclaiConfigurationError} If no `fetch` implementation is available.\n */\n constructor(opts: SeclaiOptions = {}) {\n const apiKey = opts.apiKey ?? getEnv(\"SECLAI_API_KEY\");\n if (!apiKey) {\n throw new SeclaiConfigurationError(\n \"Missing API key. Provide apiKey or set SECLAI_API_KEY.\"\n );\n }\n\n const fetcher = opts.fetch ?? (globalThis.fetch as FetchLike | undefined);\n if (!fetcher) {\n throw new SeclaiConfigurationError(\n \"No fetch implementation available. Provide opts.fetch or run in an environment with global fetch.\"\n );\n }\n\n this.apiKey = apiKey;\n this.baseUrl = opts.baseUrl ?? getEnv(\"SECLAI_API_URL\") ?? SECLAI_API_URL;\n this.apiKeyHeader = opts.apiKeyHeader ?? \"x-api-key\";\n this.defaultHeaders = { ...(opts.defaultHeaders ?? {}) };\n this.fetcher = fetcher;\n }\n\n /**\n * Make a raw HTTP request to the Seclai API.\n *\n * This is a low-level escape hatch. For most operations, prefer the typed convenience methods.\n *\n * @param method - HTTP method (e.g. `\"GET\"`, `\"POST\"`).\n * @param path - Request path relative to `baseUrl` (e.g. `\"/sources/\"`).\n * @param opts - Query params, JSON body, and per-request headers.\n * @returns Parsed JSON for JSON responses, raw text for non-JSON responses, or `null` for empty bodies.\n * @throws {@link SeclaiAPIValidationError} For validation errors (typically HTTP 422).\n * @throws {@link SeclaiAPIStatusError} For other non-success HTTP status codes.\n */\n async request(\n method: string,\n path: string,\n opts?: {\n query?: Record<string, unknown>;\n json?: unknown;\n headers?: Record<string, string>;\n }\n ): Promise<unknown | string | null> {\n const url = buildURL(this.baseUrl, path, opts?.query);\n\n const headers: Record<string, string> = {\n ...this.defaultHeaders,\n ...(opts?.headers ?? {}),\n [this.apiKeyHeader]: this.apiKey,\n };\n\n let body: BodyInit | undefined;\n if (opts?.json !== undefined) {\n headers[\"content-type\"] = headers[\"content-type\"] ?? \"application/json\";\n body = JSON.stringify(opts.json);\n }\n\n const init: RequestInit = { method, headers };\n if (body !== undefined) {\n init.body = body;\n }\n const response = await this.fetcher(url, init);\n\n if (response.status === 204) return null;\n\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n const isJson = contentType.includes(\"application/json\");\n\n if (!response.ok) {\n const responseText = await safeText(response);\n if (response.status === 422) {\n const validation = (await safeJson(response)) as HTTPValidationError | undefined;\n throw new SeclaiAPIValidationError({\n message: \"Validation error\",\n statusCode: response.status,\n method,\n url: url.toString(),\n responseText,\n validationError: validation,\n });\n }\n throw new SeclaiAPIStatusError({\n message: `Request failed with status ${response.status}`,\n statusCode: response.status,\n method,\n url: url.toString(),\n responseText,\n });\n }\n\n if (!response.body) return null;\n\n if (isJson) {\n return (await response.json()) as unknown;\n }\n return await response.text();\n }\n\n /**\n * Run an agent.\n *\n * @param agentId - Agent identifier.\n * @param body - Agent run request payload.\n * @returns The created agent run.\n */\n async runAgent(agentId: string, body: AgentRunRequest): Promise<AgentRunResponse> {\n const data = await this.request(\"POST\", `/agents/${agentId}/runs`, { json: body });\n return data as AgentRunResponse;\n }\n\n /**\n * Run an agent in streaming mode (SSE) and block until the final `done` event.\n *\n * @param agentId - Agent identifier.\n * @param body - Streaming agent run request payload.\n * @param opts - Optional timeout + abort signal.\n * @returns Final agent run payload from the `done` event.\n */\n async runStreamingAgentAndWait(\n agentId: string,\n body: AgentRunStreamRequest,\n opts?: { timeoutMs?: number; signal?: AbortSignal }\n ): Promise<AgentRunResponse> {\n const url = buildURL(this.baseUrl, `/agents/${agentId}/runs/stream`);\n\n const headers: Record<string, string> = {\n ...this.defaultHeaders,\n [this.apiKeyHeader]: this.apiKey,\n accept: \"text/event-stream\",\n \"content-type\": \"application/json\",\n };\n\n const timeoutMs = opts?.timeoutMs ?? 60_000;\n const timeoutController = new AbortController();\n let timedOut = false;\n const timeoutId = setTimeout(() => {\n timedOut = true;\n timeoutController.abort();\n }, timeoutMs);\n\n const signal = anySignal([opts?.signal, timeoutController.signal]);\n\n try {\n const init: RequestInit = {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n };\n if (signal) init.signal = signal;\n\n const response = await this.fetcher(url, init);\n\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n const isJson = contentType.includes(\"application/json\");\n\n if (!response.ok) {\n const responseText = await safeText(response);\n if (response.status === 422) {\n const validation = (await safeJson(response)) as HTTPValidationError | undefined;\n throw new SeclaiAPIValidationError({\n message: \"Validation error\",\n statusCode: response.status,\n method: \"POST\",\n url: url.toString(),\n responseText,\n validationError: validation,\n });\n }\n throw new SeclaiAPIStatusError({\n message: `Request failed with status ${response.status}`,\n statusCode: response.status,\n method: \"POST\",\n url: url.toString(),\n responseText,\n });\n }\n\n // Some servers may choose to return a JSON response even when we request SSE.\n if (isJson) {\n return (await response.json()) as AgentRunResponse;\n }\n\n if (!response.body) {\n throw new SeclaiConfigurationError(\n \"Streaming response body is not available in this environment. Provide a fetch implementation that supports ReadableStream bodies.\"\n );\n }\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n\n let final: AgentRunResponse | undefined;\n let lastSeen: AgentRunResponse | undefined;\n\n const parser = createSseParser((msg) => {\n if (!msg.data) return;\n\n // `init` and `done` messages contain JSON payloads in `data:`.\n if (msg.event === \"init\" || msg.event === \"done\") {\n try {\n const parsed = JSON.parse(msg.data) as AgentRunResponse;\n lastSeen = parsed;\n if (msg.event === \"done\") {\n final = parsed;\n }\n } catch {\n // Ignore malformed JSON chunks.\n }\n }\n });\n\n while (!final) {\n const { value, done } = await reader.read();\n if (done) break;\n if (value) parser.feed(decoder.decode(value, { stream: true }));\n }\n\n parser.end();\n\n if (final) return final;\n if (lastSeen && (lastSeen as any).status && (lastSeen as any).status !== \"pending\") {\n return lastSeen;\n }\n\n throw new SeclaiError(\"Stream ended before receiving a 'done' event.\");\n } catch (err) {\n if (timedOut) {\n throw new SeclaiError(`Timed out after ${timeoutMs}ms waiting for streaming agent run to complete.`);\n }\n throw err;\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n /**\n * List agent runs for an agent.\n *\n * @param agentId - Agent identifier.\n * @param opts - Pagination options.\n * @returns A paginated list of runs.\n */\n async listAgentRuns(\n agentId: string,\n opts: { page?: number; limit?: number } = {}\n ): Promise<AgentRunListResponse> {\n const data = await this.request(\"GET\", `/agents/${agentId}/runs`, {\n query: { page: opts.page ?? 1, limit: opts.limit ?? 50 },\n });\n return data as AgentRunListResponse;\n }\n\n /**\n * Get details of a specific agent run.\n *\n * @param runId - Run identifier.\n * @param opts - Optional flags.\n * @returns Agent run details.\n */\n async getAgentRun(\n runId: string,\n opts?: { includeStepOutputs?: boolean }\n ): Promise<AgentRunResponse>;\n /** @deprecated Backwards compatibility; agentId is no longer required. */\n async getAgentRun(\n agentId: string,\n runId: string,\n opts?: { includeStepOutputs?: boolean }\n ): Promise<AgentRunResponse>;\n async getAgentRun(\n arg1: string,\n arg2?: string | { includeStepOutputs?: boolean },\n arg3: { includeStepOutputs?: boolean } = {}\n ): Promise<AgentRunResponse> {\n const hasOldSignature = typeof arg2 === \"string\";\n const runId = hasOldSignature ? (arg2 as string) : arg1;\n const opts = hasOldSignature ? arg3 : ((arg2 as { includeStepOutputs?: boolean } | undefined) ?? {});\n\n const data = await this.request(\n \"GET\",\n `/agents/runs/${runId}`,\n opts.includeStepOutputs ? { query: { include_step_outputs: true } } : undefined\n );\n return data as AgentRunResponse;\n }\n\n /**\n * Cancel an agent run.\n *\n * @param runId - Run identifier.\n * @returns Updated agent run record.\n */\n async deleteAgentRun(runId: string): Promise<AgentRunResponse>;\n /** @deprecated Backwards compatibility; agentId is no longer required. */\n async deleteAgentRun(agentId: string, runId: string): Promise<AgentRunResponse>;\n async deleteAgentRun(arg1: string, arg2?: string): Promise<AgentRunResponse> {\n const runId = arg2 ?? arg1;\n const data = await this.request(\"DELETE\", `/agents/runs/${runId}`);\n return data as AgentRunResponse;\n }\n\n /**\n * Get content detail.\n *\n * Fetches a slice of a content version (use `start`/`end` to page through large content).\n *\n * @param sourceConnectionContentVersion - Content version identifier.\n * @param opts - Range options.\n * @returns Content details for the requested range.\n */\n async getContentDetail(\n sourceConnectionContentVersion: string,\n opts: { start?: number; end?: number } = {}\n ): Promise<ContentDetailResponse> {\n const data = await this.request(\n \"GET\",\n `/contents/${sourceConnectionContentVersion}`,\n { query: { start: opts.start ?? 0, end: opts.end ?? 5000 } }\n );\n return data as ContentDetailResponse;\n }\n\n /**\n * Delete a specific content version.\n *\n * @param sourceConnectionContentVersion - Content version identifier.\n */\n async deleteContent(sourceConnectionContentVersion: string): Promise<void> {\n await this.request(\"DELETE\", `/contents/${sourceConnectionContentVersion}`);\n }\n\n /**\n * List embeddings for a content version.\n *\n * @param sourceConnectionContentVersion - Content version identifier.\n * @param opts - Pagination options.\n * @returns A paginated list of embeddings.\n */\n async listContentEmbeddings(\n sourceConnectionContentVersion: string,\n opts: { page?: number; limit?: number } = {}\n ): Promise<ContentEmbeddingsListResponse> {\n const data = await this.request(\n \"GET\",\n `/contents/${sourceConnectionContentVersion}/embeddings`,\n { query: { page: opts.page ?? 1, limit: opts.limit ?? 20 } }\n );\n return data as ContentEmbeddingsListResponse;\n }\n\n /**\n * List sources.\n *\n * @param opts - Pagination and filter options.\n * @returns A paginated list of sources.\n */\n async listSources(\n opts: {\n page?: number;\n limit?: number;\n sort?: string;\n order?: \"asc\" | \"desc\";\n accountId?: string | null;\n } = {}\n ): Promise<SourceListResponse> {\n const data = await this.request(\"GET\", \"/sources/\", {\n query: {\n page: opts.page ?? 1,\n limit: opts.limit ?? 20,\n sort: opts.sort ?? \"created_at\",\n order: opts.order ?? \"desc\",\n account_id: opts.accountId ?? undefined,\n },\n });\n return data as SourceListResponse;\n }\n\n /**\n * Upload a file to a specific source connection.\n *\n * Maximum file size: 200 MiB.\n *\n * Supported MIME types:\n * - `application/epub+zip`\n * - `application/json`\n * - `application/msword`\n * - `application/pdf`\n * - `application/vnd.ms-excel`\n * - `application/vnd.ms-outlook`\n * - `application/vnd.ms-powerpoint`\n * - `application/vnd.openxmlformats-officedocument.presentationml.presentation`\n * - `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`\n * - `application/vnd.openxmlformats-officedocument.wordprocessingml.document`\n * - `application/xml`\n * - `application/zip`\n * - `audio/flac`, `audio/mp4`, `audio/mpeg`, `audio/ogg`, `audio/wav`\n * - `image/bmp`, `image/gif`, `image/jpeg`, `image/png`, `image/tiff`, `image/webp`\n * - `text/csv`, `text/html`, `text/markdown`, `text/x-markdown`, `text/plain`, `text/xml`\n * - `video/mp4`, `video/quicktime`, `video/x-msvideo`\n *\n * Notes:\n * - If `mimeType` is omitted, the upload is typically sent as `application/octet-stream`.\n * In that case, the server attempts to infer the type from the uploaded filename/extension,\n * so prefer providing `fileName` with a meaningful extension (e.g. `\"recording.mp3\"`).\n *\n * @param sourceConnectionId - Source connection identifier.\n * @param opts - File payload and optional metadata.\n * @param opts.file - File payload as a `Blob`, `Uint8Array`, or `ArrayBuffer`.\n * @param opts.title - Optional title for the uploaded file.\n * @param opts.fileName - Optional filename to send with the upload.\n * @param opts.mimeType - Optional MIME type to attach to the upload.\n * @returns Upload response details.\n */\n async uploadFileToSource(\n sourceConnectionId: string,\n opts: {\n file: Blob | Uint8Array | ArrayBuffer;\n title?: string;\n fileName?: string;\n mimeType?: string;\n }\n ): Promise<FileUploadResponse> {\n const url = buildURL(this.baseUrl, `/sources/${sourceConnectionId}/upload`);\n\n const headers: Record<string, string> = {\n ...this.defaultHeaders,\n [this.apiKeyHeader]: this.apiKey,\n };\n\n const form = new FormData();\n\n let blob: Blob;\n if (opts.file instanceof Blob) {\n blob = opts.file;\n } else if (opts.file instanceof ArrayBuffer) {\n const blobOpts = opts.mimeType ? { type: opts.mimeType } : undefined;\n blob = new Blob([new Uint8Array(opts.file)], blobOpts);\n } else {\n const blobOpts = opts.mimeType ? { type: opts.mimeType } : undefined;\n blob = new Blob([opts.file as unknown as BlobPart], blobOpts);\n }\n\n const fileName = opts.fileName ?? \"upload\";\n form.set(\"file\", blob, fileName);\n\n if (opts.title !== undefined) {\n form.set(\"title\", opts.title);\n }\n\n const response = await this.fetcher(url, {\n method: \"POST\",\n headers,\n body: form,\n });\n\n if (!response.ok) {\n const responseText = await safeText(response);\n if (response.status === 422) {\n const validation = (await safeJson(response)) as HTTPValidationError | undefined;\n throw new SeclaiAPIValidationError({\n message: \"Validation error\",\n statusCode: response.status,\n method: \"POST\",\n url: url.toString(),\n responseText,\n validationError: validation,\n });\n }\n throw new SeclaiAPIStatusError({\n message: `Request failed with status ${response.status}`,\n statusCode: response.status,\n method: \"POST\",\n url: url.toString(),\n responseText,\n });\n }\n\n return (await response.json()) as FileUploadResponse;\n }\n}\n"],"mappings":";AACO,IAAM,cAAN,cAA0B,MAAM;AAAA,EACrC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAGO,IAAM,2BAAN,cAAuC,YAAY;AAAA,EACxD,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAQO,IAAM,uBAAN,cAAmC,YAAY;AAAA;AAAA,EAEpC;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,MAOT;AACD,UAAM,KAAK,OAAO;AAClB,SAAK,OAAO;AACZ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UACT,YAAY,SAAS;AAAA,UACrB,QAAQ;AAAA,UACR,KAAK,IAAI,SAAS;AAAA,UAClB;AAAA,UACA,iBAAiB;AAAA,QACnB,CAAC;AAAA,MACH;AACA,YAAM,IAAI,qBAAqB;AAAA,QAC7B,SAAS,8BAA8B,SAAS,MAAM;AAAA,QACtD,YAAY,SAAS;AAAA,QACrB,QAAQ;AAAA,QACR,KAAK,IAAI,SAAS;AAAA,QAClB;AAAA,MACF,CAAC;AAAA,IACH;AAEA,WAAQ,MAAM,SAAS,KAAK;AAAA,EAC9B;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/client.ts"],"sourcesContent":["/** Base error class for the Seclai SDK. */\nexport class SeclaiError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"SeclaiError\";\n }\n}\n\n/** Thrown when the SDK is misconfigured (for example, missing API key). */\nexport class SeclaiConfigurationError extends SeclaiError {\n constructor(message: string) {\n super(message);\n this.name = \"SeclaiConfigurationError\";\n }\n}\n\n/**\n * Thrown when the API returns a non-success status code.\n *\n * @remarks\n * Use {@link SeclaiAPIValidationError} for HTTP 422 validation errors.\n */\nexport class SeclaiAPIStatusError extends SeclaiError {\n /** HTTP status code returned by the API. */\n public readonly statusCode: number;\n /** HTTP method used for the request. */\n public readonly method: string;\n /** Full request URL. */\n public readonly url: string;\n /** Best-effort response body text (if available). */\n public readonly responseText: string | undefined;\n\n constructor(opts: {\n /** Human-readable error message. */\n message: string;\n statusCode: number;\n method: string;\n url: string;\n responseText: string | undefined;\n }) {\n super(opts.message);\n this.name = \"SeclaiAPIStatusError\";\n this.statusCode = opts.statusCode;\n this.method = opts.method;\n this.url = opts.url;\n this.responseText = opts.responseText;\n }\n}\n\n/**\n * Thrown when the API returns a validation error response (typically HTTP 422).\n *\n * The `validationError` field contains the decoded validation payload when available.\n */\nexport class SeclaiAPIValidationError extends SeclaiAPIStatusError {\n /** Parsed validation error payload (best-effort). */\n public readonly validationError: unknown;\n\n constructor(opts: {\n message: string;\n statusCode: number;\n method: string;\n url: string;\n responseText: string | undefined;\n validationError: unknown;\n }) {\n super(opts);\n this.name = \"SeclaiAPIValidationError\";\n this.validationError = opts.validationError;\n }\n}\n","import {\n SeclaiAPIStatusError,\n SeclaiAPIValidationError,\n SeclaiConfigurationError,\n SeclaiError,\n} from \"./errors\";\nimport type {\n AgentRunListResponse,\n AgentRunRequest,\n AgentRunResponse,\n AgentRunStreamRequest,\n ContentDetailResponse,\n ContentEmbeddingsListResponse,\n FileUploadResponse,\n HTTPValidationError,\n SourceListResponse,\n} from \"./types\";\n\n/** Default API base URL (can be overridden with `baseUrl` or `SECLAI_API_URL`). */\nexport const SECLAI_API_URL = \"https://api.seclai.com\";\n\n/** A `fetch`-compatible function (e.g. `globalThis.fetch` or `undici.fetch`). */\nexport type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;\n\n/** Configuration for the {@link Seclai} client. */\nexport interface SeclaiOptions {\n /** API key used for authentication. Defaults to `process.env.SECLAI_API_KEY` when available. */\n apiKey?: string;\n /** API base URL. Defaults to `process.env.SECLAI_API_URL` when available, else {@link SECLAI_API_URL}. */\n baseUrl?: string;\n /** Header name to use for the API key. Defaults to `x-api-key`. */\n apiKeyHeader?: string;\n /** Extra headers to include on every request. */\n defaultHeaders?: Record<string, string>;\n /** Optional `fetch` implementation for environments without a global `fetch`. */\n fetch?: FetchLike;\n}\n\nfunction getEnv(name: string): string | undefined {\n const p = (globalThis as any)?.process;\n return p?.env?.[name];\n}\n\nfunction buildURL(baseUrl: string, path: string, query?: Record<string, unknown>): URL {\n const url = new URL(path, baseUrl);\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined || value === null) continue;\n url.searchParams.set(key, String(value));\n }\n }\n return url;\n}\n\nasync function safeText(response: Response): Promise<string | undefined> {\n try {\n return await response.clone().text();\n } catch {\n return undefined;\n }\n}\n\nasync function safeJson(response: Response): Promise<unknown | undefined> {\n try {\n return await response.clone().json();\n } catch {\n return undefined;\n }\n}\n\ntype SseMessage = { event?: string; data?: string };\n\nfunction createSseParser(onMessage: (msg: SseMessage) => void) {\n let buffer = \"\";\n let eventName: string | undefined;\n let dataLines: string[] = [];\n\n function dispatch() {\n if (!eventName && dataLines.length === 0) return;\n const msg: SseMessage = { data: dataLines.join(\"\\n\") };\n if (eventName !== undefined) msg.event = eventName;\n onMessage(msg);\n eventName = undefined;\n dataLines = [];\n }\n\n function feed(textChunk: string) {\n buffer += textChunk;\n while (true) {\n const newlineIdx = buffer.indexOf(\"\\n\");\n if (newlineIdx === -1) return;\n\n let line = buffer.slice(0, newlineIdx);\n buffer = buffer.slice(newlineIdx + 1);\n\n if (line.endsWith(\"\\r\")) line = line.slice(0, -1);\n\n if (line === \"\") {\n dispatch();\n continue;\n }\n\n // Comments/keepalives begin with ':'\n if (line.startsWith(\":\")) continue;\n\n const colon = line.indexOf(\":\");\n const field = colon === -1 ? line : line.slice(0, colon);\n let value = colon === -1 ? \"\" : line.slice(colon + 1);\n if (value.startsWith(\" \")) value = value.slice(1);\n\n if (field === \"event\") {\n eventName = value;\n } else if (field === \"data\") {\n dataLines.push(value);\n }\n }\n }\n\n return { feed, end: dispatch };\n}\n\nfunction anySignal(signals: Array<AbortSignal | undefined>): AbortSignal | undefined {\n const present = signals.filter(Boolean) as AbortSignal[];\n if (present.length === 0) return undefined;\n if (present.length === 1) return present[0];\n const controller = new AbortController();\n const onAbort = () => controller.abort();\n for (const s of present) {\n if (s.aborted) {\n controller.abort();\n break;\n }\n s.addEventListener(\"abort\", onAbort, { once: true });\n }\n return controller.signal;\n}\n\n/**\n * Seclai JavaScript/TypeScript client.\n *\n * @remarks\n * - Uses API key auth via `x-api-key` by default.\n * - Throws SDK exceptions for non-success responses.\n */\nexport class Seclai {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly apiKeyHeader: string;\n private readonly defaultHeaders: Record<string, string>;\n private readonly fetcher: FetchLike;\n\n /**\n * Create a new Seclai client.\n *\n * @param opts - Client configuration.\n * @throws {@link SeclaiConfigurationError} If no API key is provided (and `SECLAI_API_KEY` is not set).\n * @throws {@link SeclaiConfigurationError} If no `fetch` implementation is available.\n */\n constructor(opts: SeclaiOptions = {}) {\n const apiKey = opts.apiKey ?? getEnv(\"SECLAI_API_KEY\");\n if (!apiKey) {\n throw new SeclaiConfigurationError(\n \"Missing API key. Provide apiKey or set SECLAI_API_KEY.\"\n );\n }\n\n const fetcher = opts.fetch ?? (globalThis.fetch as FetchLike | undefined);\n if (!fetcher) {\n throw new SeclaiConfigurationError(\n \"No fetch implementation available. Provide opts.fetch or run in an environment with global fetch.\"\n );\n }\n\n this.apiKey = apiKey;\n this.baseUrl = opts.baseUrl ?? getEnv(\"SECLAI_API_URL\") ?? SECLAI_API_URL;\n this.apiKeyHeader = opts.apiKeyHeader ?? \"x-api-key\";\n this.defaultHeaders = { ...(opts.defaultHeaders ?? {}) };\n this.fetcher = fetcher;\n }\n\n /**\n * Make a raw HTTP request to the Seclai API.\n *\n * This is a low-level escape hatch. For most operations, prefer the typed convenience methods.\n *\n * @param method - HTTP method (e.g. `\"GET\"`, `\"POST\"`).\n * @param path - Request path relative to `baseUrl` (e.g. `\"/sources/\"`).\n * @param opts - Query params, JSON body, and per-request headers.\n * @returns Parsed JSON for JSON responses, raw text for non-JSON responses, or `null` for empty bodies.\n * @throws {@link SeclaiAPIValidationError} For validation errors (typically HTTP 422).\n * @throws {@link SeclaiAPIStatusError} For other non-success HTTP status codes.\n */\n async request(\n method: string,\n path: string,\n opts?: {\n query?: Record<string, unknown>;\n json?: unknown;\n headers?: Record<string, string>;\n }\n ): Promise<unknown | string | null> {\n const url = buildURL(this.baseUrl, path, opts?.query);\n\n const headers: Record<string, string> = {\n ...this.defaultHeaders,\n ...(opts?.headers ?? {}),\n [this.apiKeyHeader]: this.apiKey,\n };\n\n let body: BodyInit | undefined;\n if (opts?.json !== undefined) {\n headers[\"content-type\"] = headers[\"content-type\"] ?? \"application/json\";\n body = JSON.stringify(opts.json);\n }\n\n const init: RequestInit = { method, headers };\n if (body !== undefined) {\n init.body = body;\n }\n const response = await this.fetcher(url, init);\n\n if (response.status === 204) return null;\n\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n const isJson = contentType.includes(\"application/json\");\n\n if (!response.ok) {\n const responseText = await safeText(response);\n if (response.status === 422) {\n const validation = (await safeJson(response)) as HTTPValidationError | undefined;\n throw new SeclaiAPIValidationError({\n message: \"Validation error\",\n statusCode: response.status,\n method,\n url: url.toString(),\n responseText,\n validationError: validation,\n });\n }\n throw new SeclaiAPIStatusError({\n message: `Request failed with status ${response.status}`,\n statusCode: response.status,\n method,\n url: url.toString(),\n responseText,\n });\n }\n\n if (!response.body) return null;\n\n if (isJson) {\n return (await response.json()) as unknown;\n }\n return await response.text();\n }\n\n /**\n * Run an agent.\n *\n * @param agentId - Agent identifier.\n * @param body - Agent run request payload.\n * @returns The created agent run.\n */\n async runAgent(agentId: string, body: AgentRunRequest): Promise<AgentRunResponse> {\n const data = await this.request(\"POST\", `/agents/${agentId}/runs`, { json: body });\n return data as AgentRunResponse;\n }\n\n /**\n * Run an agent in streaming mode (SSE) and block until the final `done` event.\n *\n * @param agentId - Agent identifier.\n * @param body - Streaming agent run request payload.\n * @param opts - Optional timeout + abort signal.\n * @returns Final agent run payload from the `done` event.\n */\n async runStreamingAgentAndWait(\n agentId: string,\n body: AgentRunStreamRequest,\n opts?: { timeoutMs?: number; signal?: AbortSignal }\n ): Promise<AgentRunResponse> {\n const url = buildURL(this.baseUrl, `/agents/${agentId}/runs/stream`);\n\n const headers: Record<string, string> = {\n ...this.defaultHeaders,\n [this.apiKeyHeader]: this.apiKey,\n accept: \"text/event-stream\",\n \"content-type\": \"application/json\",\n };\n\n const timeoutMs = opts?.timeoutMs ?? 60_000;\n const timeoutController = new AbortController();\n let timedOut = false;\n const timeoutId = setTimeout(() => {\n timedOut = true;\n timeoutController.abort();\n }, timeoutMs);\n\n const signal = anySignal([opts?.signal, timeoutController.signal]);\n\n try {\n const init: RequestInit = {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n };\n if (signal) init.signal = signal;\n\n const response = await this.fetcher(url, init);\n\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n const isJson = contentType.includes(\"application/json\");\n\n if (!response.ok) {\n const responseText = await safeText(response);\n if (response.status === 422) {\n const validation = (await safeJson(response)) as HTTPValidationError | undefined;\n throw new SeclaiAPIValidationError({\n message: \"Validation error\",\n statusCode: response.status,\n method: \"POST\",\n url: url.toString(),\n responseText,\n validationError: validation,\n });\n }\n throw new SeclaiAPIStatusError({\n message: `Request failed with status ${response.status}`,\n statusCode: response.status,\n method: \"POST\",\n url: url.toString(),\n responseText,\n });\n }\n\n // Some servers may choose to return a JSON response even when we request SSE.\n if (isJson) {\n return (await response.json()) as AgentRunResponse;\n }\n\n if (!response.body) {\n throw new SeclaiConfigurationError(\n \"Streaming response body is not available in this environment. Provide a fetch implementation that supports ReadableStream bodies.\"\n );\n }\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n\n let final: AgentRunResponse | undefined;\n let lastSeen: AgentRunResponse | undefined;\n\n const parser = createSseParser((msg) => {\n if (!msg.data) return;\n\n // `init` and `done` messages contain JSON payloads in `data:`.\n if (msg.event === \"init\" || msg.event === \"done\") {\n try {\n const parsed = JSON.parse(msg.data) as AgentRunResponse;\n lastSeen = parsed;\n if (msg.event === \"done\") {\n final = parsed;\n }\n } catch {\n // Ignore malformed JSON chunks.\n }\n }\n });\n\n while (!final) {\n const { value, done } = await reader.read();\n if (done) break;\n if (value) parser.feed(decoder.decode(value, { stream: true }));\n }\n\n parser.end();\n\n if (final) return final;\n if (lastSeen && (lastSeen as any).status && (lastSeen as any).status !== \"pending\") {\n return lastSeen;\n }\n\n throw new SeclaiError(\"Stream ended before receiving a 'done' event.\");\n } catch (err) {\n if (timedOut) {\n throw new SeclaiError(`Timed out after ${timeoutMs}ms waiting for streaming agent run to complete.`);\n }\n throw err;\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n /**\n * List agent runs for an agent.\n *\n * @param agentId - Agent identifier.\n * @param opts - Pagination options.\n * @returns A paginated list of runs.\n */\n async listAgentRuns(\n agentId: string,\n opts: { page?: number; limit?: number } = {}\n ): Promise<AgentRunListResponse> {\n const data = await this.request(\"GET\", `/agents/${agentId}/runs`, {\n query: { page: opts.page ?? 1, limit: opts.limit ?? 50 },\n });\n return data as AgentRunListResponse;\n }\n\n /**\n * Get details of a specific agent run.\n *\n * @param runId - Run identifier.\n * @param opts - Optional flags.\n * @returns Agent run details.\n */\n async getAgentRun(\n runId: string,\n opts?: { includeStepOutputs?: boolean }\n ): Promise<AgentRunResponse>;\n /** @deprecated Backwards compatibility; agentId is no longer required. */\n async getAgentRun(\n agentId: string,\n runId: string,\n opts?: { includeStepOutputs?: boolean }\n ): Promise<AgentRunResponse>;\n async getAgentRun(\n arg1: string,\n arg2?: string | { includeStepOutputs?: boolean },\n arg3: { includeStepOutputs?: boolean } = {}\n ): Promise<AgentRunResponse> {\n const hasOldSignature = typeof arg2 === \"string\";\n const runId = hasOldSignature ? (arg2 as string) : arg1;\n const opts = hasOldSignature ? arg3 : ((arg2 as { includeStepOutputs?: boolean } | undefined) ?? {});\n\n const data = await this.request(\n \"GET\",\n `/agents/runs/${runId}`,\n opts.includeStepOutputs ? { query: { include_step_outputs: true } } : undefined\n );\n return data as AgentRunResponse;\n }\n\n /**\n * Cancel an agent run.\n *\n * @param runId - Run identifier.\n * @returns Updated agent run record.\n */\n async deleteAgentRun(runId: string): Promise<AgentRunResponse>;\n /** @deprecated Backwards compatibility; agentId is no longer required. */\n async deleteAgentRun(agentId: string, runId: string): Promise<AgentRunResponse>;\n async deleteAgentRun(arg1: string, arg2?: string): Promise<AgentRunResponse> {\n const runId = arg2 ?? arg1;\n const data = await this.request(\"DELETE\", `/agents/runs/${runId}`);\n return data as AgentRunResponse;\n }\n\n /**\n * Get content detail.\n *\n * Fetches a slice of a content version (use `start`/`end` to page through large content).\n *\n * @param sourceConnectionContentVersion - Content version identifier.\n * @param opts - Range options.\n * @returns Content details for the requested range.\n */\n async getContentDetail(\n sourceConnectionContentVersion: string,\n opts: { start?: number; end?: number } = {}\n ): Promise<ContentDetailResponse> {\n const data = await this.request(\n \"GET\",\n `/contents/${sourceConnectionContentVersion}`,\n { query: { start: opts.start ?? 0, end: opts.end ?? 5000 } }\n );\n return data as ContentDetailResponse;\n }\n\n /**\n * Delete a specific content version.\n *\n * @param sourceConnectionContentVersion - Content version identifier.\n */\n async deleteContent(sourceConnectionContentVersion: string): Promise<void> {\n await this.request(\"DELETE\", `/contents/${sourceConnectionContentVersion}`);\n }\n\n /**\n * List embeddings for a content version.\n *\n * @param sourceConnectionContentVersion - Content version identifier.\n * @param opts - Pagination options.\n * @returns A paginated list of embeddings.\n */\n async listContentEmbeddings(\n sourceConnectionContentVersion: string,\n opts: { page?: number; limit?: number } = {}\n ): Promise<ContentEmbeddingsListResponse> {\n const data = await this.request(\n \"GET\",\n `/contents/${sourceConnectionContentVersion}/embeddings`,\n { query: { page: opts.page ?? 1, limit: opts.limit ?? 20 } }\n );\n return data as ContentEmbeddingsListResponse;\n }\n\n /**\n * List sources.\n *\n * @param opts - Pagination and filter options.\n * @returns A paginated list of sources.\n */\n async listSources(\n opts: {\n page?: number;\n limit?: number;\n sort?: string;\n order?: \"asc\" | \"desc\";\n accountId?: string | null;\n } = {}\n ): Promise<SourceListResponse> {\n const data = await this.request(\"GET\", \"/sources/\", {\n query: {\n page: opts.page ?? 1,\n limit: opts.limit ?? 20,\n sort: opts.sort ?? \"created_at\",\n order: opts.order ?? \"desc\",\n account_id: opts.accountId ?? undefined,\n },\n });\n return data as SourceListResponse;\n }\n\n /**\n * Upload a file to a specific source connection.\n *\n * Maximum file size: 200 MiB.\n *\n * Supported MIME types:\n * - `application/epub+zip`\n * - `application/json`\n * - `application/msword`\n * - `application/pdf`\n * - `application/vnd.ms-excel`\n * - `application/vnd.ms-outlook`\n * - `application/vnd.ms-powerpoint`\n * - `application/vnd.openxmlformats-officedocument.presentationml.presentation`\n * - `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`\n * - `application/vnd.openxmlformats-officedocument.wordprocessingml.document`\n * - `application/xml`\n * - `application/zip`\n * - `audio/flac`, `audio/mp4`, `audio/mpeg`, `audio/ogg`, `audio/wav`\n * - `image/bmp`, `image/gif`, `image/jpeg`, `image/png`, `image/tiff`, `image/webp`\n * - `text/csv`, `text/html`, `text/markdown`, `text/x-markdown`, `text/plain`, `text/xml`\n * - `video/mp4`, `video/quicktime`, `video/x-msvideo`\n *\n * Notes:\n * - If `mimeType` is omitted, the upload is typically sent as `application/octet-stream`.\n * In that case, the server attempts to infer the type from the uploaded filename/extension,\n * so prefer providing `fileName` with a meaningful extension (e.g. `\"recording.mp3\"`).\n *\n * @param sourceConnectionId - Source connection identifier.\n * @param opts - File payload and optional metadata.\n * @param opts.file - File payload as a `Blob`, `Uint8Array`, or `ArrayBuffer`.\n * @param opts.title - Optional title for the uploaded file.\n * @param opts.metadata - Optional metadata object. This is sent as a JSON string form field named `metadata`.\n * Example: `{ category: \"docs\", author: \"Ada\" }`.\n * @param opts.fileName - Optional filename to send with the upload.\n * @param opts.mimeType - Optional MIME type to attach to the upload.\n * @returns Upload response details.\n */\n async uploadFileToSource(\n sourceConnectionId: string,\n opts: {\n file: Blob | Uint8Array | ArrayBuffer;\n title?: string;\n metadata?: Record<string, unknown>;\n fileName?: string;\n mimeType?: string;\n }\n ): Promise<FileUploadResponse> {\n const url = buildURL(this.baseUrl, `/sources/${sourceConnectionId}/upload`);\n\n const headers: Record<string, string> = {\n ...this.defaultHeaders,\n [this.apiKeyHeader]: this.apiKey,\n };\n\n const form = new FormData();\n\n let blob: Blob;\n if (opts.file instanceof Blob) {\n blob = opts.file;\n } else if (opts.file instanceof ArrayBuffer) {\n const blobOpts = opts.mimeType ? { type: opts.mimeType } : undefined;\n blob = new Blob([new Uint8Array(opts.file)], blobOpts);\n } else {\n const blobOpts = opts.mimeType ? { type: opts.mimeType } : undefined;\n blob = new Blob([opts.file as unknown as BlobPart], blobOpts);\n }\n\n const fileName = opts.fileName ?? \"upload\";\n form.set(\"file\", blob, fileName);\n\n if (opts.title !== undefined) {\n form.set(\"title\", opts.title);\n }\n\n if (opts.metadata !== undefined) {\n form.set(\"metadata\", JSON.stringify(opts.metadata));\n }\n\n const response = await this.fetcher(url, {\n method: \"POST\",\n headers,\n body: form,\n });\n\n if (!response.ok) {\n const responseText = await safeText(response);\n if (response.status === 422) {\n const validation = (await safeJson(response)) as HTTPValidationError | undefined;\n throw new SeclaiAPIValidationError({\n message: \"Validation error\",\n statusCode: response.status,\n method: \"POST\",\n url: url.toString(),\n responseText,\n validationError: validation,\n });\n }\n throw new SeclaiAPIStatusError({\n message: `Request failed with status ${response.status}`,\n statusCode: response.status,\n method: \"POST\",\n url: url.toString(),\n responseText,\n });\n }\n\n return (await response.json()) as FileUploadResponse;\n }\n\n /**\n * Upload a new file and replace the content backing an existing content version.\n *\n * This endpoint is useful when you need to correct or update an uploaded document while keeping\n * references stable (the content version ID stays the same).\n *\n * Notes:\n * - `metadata` is sent as a JSON string form field named `metadata`.\n * - `title` is a convenience field and may be merged into `metadata.title` by the server.\n */\n async uploadFileToContent(\n sourceConnectionContentVersion: string,\n opts: {\n file: Blob | Uint8Array | ArrayBuffer;\n title?: string;\n metadata?: Record<string, unknown>;\n fileName?: string;\n mimeType?: string;\n }\n ): Promise<FileUploadResponse> {\n const url = buildURL(this.baseUrl, `/contents/${sourceConnectionContentVersion}/upload`);\n\n const headers: Record<string, string> = {\n ...this.defaultHeaders,\n [this.apiKeyHeader]: this.apiKey,\n };\n\n const form = new FormData();\n\n let blob: Blob;\n if (opts.file instanceof Blob) {\n blob = opts.file;\n } else if (opts.file instanceof ArrayBuffer) {\n const blobOpts = opts.mimeType ? { type: opts.mimeType } : undefined;\n blob = new Blob([new Uint8Array(opts.file)], blobOpts);\n } else {\n const blobOpts = opts.mimeType ? { type: opts.mimeType } : undefined;\n blob = new Blob([opts.file as unknown as BlobPart], blobOpts);\n }\n\n const fileName = opts.fileName ?? \"upload\";\n form.set(\"file\", blob, fileName);\n\n if (opts.title !== undefined) {\n form.set(\"title\", opts.title);\n }\n if (opts.metadata !== undefined) {\n form.set(\"metadata\", JSON.stringify(opts.metadata));\n }\n\n const response = await this.fetcher(url, {\n method: \"POST\",\n headers,\n body: form,\n });\n\n if (!response.ok) {\n const responseText = await safeText(response);\n if (response.status === 422) {\n const validation = (await safeJson(response)) as HTTPValidationError | undefined;\n throw new SeclaiAPIValidationError({\n message: \"Validation error\",\n statusCode: response.status,\n method: \"POST\",\n url: url.toString(),\n responseText,\n validationError: validation,\n });\n }\n throw new SeclaiAPIStatusError({\n message: `Request failed with status ${response.status}`,\n statusCode: response.status,\n method: \"POST\",\n url: url.toString(),\n responseText,\n });\n }\n\n return (await response.json()) as FileUploadResponse;\n }\n}\n"],"mappings":";AACO,IAAM,cAAN,cAA0B,MAAM;AAAA,EACrC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAGO,IAAM,2BAAN,cAAuC,YAAY;AAAA,EACxD,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAQO,IAAM,uBAAN,cAAmC,YAAY;AAAA;AAAA,EAEpC;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,MAOT;AACD,UAAM,KAAK,OAAO;AAClB,SAAK,OAAO;AACZ,SAAK,aAAa,KAAK;AACvB,SAAK,SAAS,KAAK;AACnB,SAAK,MAAM,KAAK;AAChB,SAAK,eAAe,KAAK;AAAA,EAC3B;AACF;AAOO,IAAM,2BAAN,cAAuC,qBAAqB;AAAA;AAAA,EAEjD;AAAA,EAEhB,YAAY,MAOT;AACD,UAAM,IAAI;AACV,SAAK,OAAO;AACZ,SAAK,kBAAkB,KAAK;AAAA,EAC9B;AACF;;;ACnDO,IAAM,iBAA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