@nixet/sdk 0.0.0-stage → 0.1.1
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/CHANGELOG.md +50 -0
- package/LICENSE +21 -0
- package/README.md +870 -2
- package/SECURITY.md +30 -0
- package/api.md +485 -0
- package/dist/cjs/errors.d.ts +37 -0
- package/dist/cjs/errors.js +79 -0
- package/dist/cjs/index.d.ts +89 -0
- package/dist/cjs/index.js +118 -0
- package/dist/cjs/resources/agents.d.ts +67 -0
- package/dist/cjs/resources/agents.js +74 -0
- package/dist/cjs/resources/connections.d.ts +94 -0
- package/dist/cjs/resources/connections.js +106 -0
- package/dist/cjs/resources/conversations.d.ts +62 -0
- package/dist/cjs/resources/conversations.js +86 -0
- package/dist/cjs/resources/documents.d.ts +65 -0
- package/dist/cjs/resources/documents.js +61 -0
- package/dist/cjs/resources/guardrails.d.ts +56 -0
- package/dist/cjs/resources/guardrails.js +76 -0
- package/dist/cjs/resources/knowledge.d.ts +189 -0
- package/dist/cjs/resources/knowledge.js +218 -0
- package/dist/cjs/resources/mcp-servers.d.ts +83 -0
- package/dist/cjs/resources/mcp-servers.js +107 -0
- package/dist/cjs/resources/memory.d.ts +95 -0
- package/dist/cjs/resources/memory.js +127 -0
- package/dist/cjs/resources/runs.d.ts +78 -0
- package/dist/cjs/resources/runs.js +87 -0
- package/dist/cjs/resources/secrets.d.ts +60 -0
- package/dist/cjs/resources/secrets.js +85 -0
- package/dist/cjs/resources/skills.d.ts +57 -0
- package/dist/cjs/resources/skills.js +78 -0
- package/dist/cjs/resources/tasks.d.ts +91 -0
- package/dist/cjs/resources/tasks.js +129 -0
- package/dist/cjs/resources/tools.d.ts +42 -0
- package/dist/cjs/resources/tools.js +57 -0
- package/dist/cjs/resources/users.d.ts +39 -0
- package/dist/cjs/resources/users.js +57 -0
- package/dist/cjs/resources/versions.d.ts +105 -0
- package/dist/cjs/resources/versions.js +78 -0
- package/dist/cjs/stream.d.ts +57 -0
- package/dist/cjs/stream.js +170 -0
- package/dist/cjs/transport.d.ts +45 -0
- package/dist/cjs/transport.js +106 -0
- package/dist/cjs/types.d.ts +537 -0
- package/dist/cjs/types.js +3 -0
- package/dist/esm/errors.js +66 -0
- package/dist/esm/index.js +103 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/resources/agents.js +70 -0
- package/dist/esm/resources/connections.js +102 -0
- package/dist/esm/resources/conversations.js +82 -0
- package/dist/esm/resources/documents.js +57 -0
- package/dist/esm/resources/guardrails.js +72 -0
- package/dist/esm/resources/knowledge.js +212 -0
- package/dist/esm/resources/mcp-servers.js +103 -0
- package/dist/esm/resources/memory.js +123 -0
- package/dist/esm/resources/runs.js +83 -0
- package/dist/esm/resources/secrets.js +81 -0
- package/dist/esm/resources/skills.js +74 -0
- package/dist/esm/resources/tasks.js +125 -0
- package/dist/esm/resources/tools.js +53 -0
- package/dist/esm/resources/users.js +53 -0
- package/dist/esm/resources/versions.js +74 -0
- package/dist/esm/stream.js +166 -0
- package/dist/esm/transport.js +102 -0
- package/dist/esm/types.js +2 -0
- package/package.json +59 -4
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Conversations = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Conversations: a durable thread between an agent and a user.
|
|
6
|
+
*
|
|
7
|
+
* Each message creates a run, so cost, usage and the trace work exactly as
|
|
8
|
+
* they do for a single-shot run. The conversation adds the history around them.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const convo = await nixet.conversations.create({
|
|
12
|
+
* agentId: agent.id,
|
|
13
|
+
* userId: user.id,
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* await nixet.conversations.send(convo.id, { input: "Hi, I'm Sam." });
|
|
17
|
+
* await nixet.conversations.send(convo.id, { input: "What's my name?" });
|
|
18
|
+
* // → "Sam"
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
class Conversations {
|
|
22
|
+
transport;
|
|
23
|
+
constructor(transport) {
|
|
24
|
+
this.transport = transport;
|
|
25
|
+
}
|
|
26
|
+
create(params, options = {}) {
|
|
27
|
+
return this.transport.request({
|
|
28
|
+
method: "POST",
|
|
29
|
+
path: "/conversations",
|
|
30
|
+
body: {
|
|
31
|
+
agent_id: params.agentId,
|
|
32
|
+
...(params.userId ? { user_id: params.userId } : {}),
|
|
33
|
+
...(params.title ? { title: params.title } : {}),
|
|
34
|
+
...(params.agentVersion ? { agent_version: params.agentVersion } : {}),
|
|
35
|
+
...(params.memory ? { memory: params.memory } : {}),
|
|
36
|
+
},
|
|
37
|
+
signal: options.signal,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
retrieve(conversationId, options = {}) {
|
|
41
|
+
return this.transport.request({
|
|
42
|
+
method: "GET",
|
|
43
|
+
path: `/conversations/${encodeURIComponent(conversationId)}`,
|
|
44
|
+
signal: options.signal,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
list(params = {}, options = {}) {
|
|
48
|
+
return this.transport.requestPage({
|
|
49
|
+
method: "GET",
|
|
50
|
+
path: "/conversations",
|
|
51
|
+
query: {
|
|
52
|
+
$limit: params.limit,
|
|
53
|
+
$offset: params.offset,
|
|
54
|
+
agent_id: params.agentId,
|
|
55
|
+
user_id: params.userId,
|
|
56
|
+
},
|
|
57
|
+
signal: options.signal,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/** Send a message and wait for the reply. */
|
|
61
|
+
send(conversationId, params, options = {}) {
|
|
62
|
+
return this.transport.request({
|
|
63
|
+
method: "POST",
|
|
64
|
+
path: `/conversations/${encodeURIComponent(conversationId)}/messages`,
|
|
65
|
+
body: {
|
|
66
|
+
input: params.input,
|
|
67
|
+
...(params.provider ? { provider: params.provider } : {}),
|
|
68
|
+
},
|
|
69
|
+
signal: options.signal,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The full transcript, oldest first.
|
|
74
|
+
*
|
|
75
|
+
* Includes turns a summary has since replaced, so what a person actually
|
|
76
|
+
* said is still readable even after the thread has been compacted.
|
|
77
|
+
*/
|
|
78
|
+
messages(conversationId, options = {}) {
|
|
79
|
+
return this.transport.requestPage({
|
|
80
|
+
method: "GET",
|
|
81
|
+
path: `/conversations/${encodeURIComponent(conversationId)}/messages`,
|
|
82
|
+
signal: options.signal,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.Conversations = Conversations;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Transport } from "../transport.js";
|
|
2
|
+
import type { DocumentConversionResult } from "@nixet/contracts";
|
|
3
|
+
export interface ConvertDocumentParams {
|
|
4
|
+
/**
|
|
5
|
+
* The document.
|
|
6
|
+
*
|
|
7
|
+
* A `Blob` or `File` in a browser and in Node 20+, or a `Uint8Array` with a
|
|
8
|
+
* filename. The name matters only for formats with no signature of their own
|
|
9
|
+
* — CSV is the one that needs it — because the format is otherwise read from
|
|
10
|
+
* the content.
|
|
11
|
+
*/
|
|
12
|
+
file: Blob | Uint8Array;
|
|
13
|
+
/** Required when `file` is bytes rather than a `File`. */
|
|
14
|
+
filename?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Opens a password protected PDF.
|
|
17
|
+
*
|
|
18
|
+
* Used to read the document and then dropped: it is not stored, not logged
|
|
19
|
+
* and not returned. A protected document cannot also be stored in a
|
|
20
|
+
* collection, because nothing would be able to open the original again.
|
|
21
|
+
*/
|
|
22
|
+
password?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Keep the document as a knowledge source in this collection.
|
|
25
|
+
*
|
|
26
|
+
* Omitted, nothing is stored: the bytes live for the length of the request
|
|
27
|
+
* and the Markdown is the whole answer. Named, the document is also chunked
|
|
28
|
+
* and embedded so an agent can search it, which needs `knowledge:write`.
|
|
29
|
+
*/
|
|
30
|
+
collection?: string;
|
|
31
|
+
/** Defaults to the file's own name. Only used when storing. */
|
|
32
|
+
title?: string;
|
|
33
|
+
signal?: AbortSignal;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Reading a document.
|
|
37
|
+
*
|
|
38
|
+
* Converts fourteen formats to Markdown — PDF, Word, Excel, PowerPoint and the
|
|
39
|
+
* rest — locally, with no third party seeing the file. A PDF whose pages are
|
|
40
|
+
* scans needs an OCR engine and reports which pages it read that way.
|
|
41
|
+
*
|
|
42
|
+
* Separate from knowledge because the intent is different. A knowledge source
|
|
43
|
+
* is converted so an agent can search it, and what comes back are chunks
|
|
44
|
+
* ordered by similarity. This returns the document.
|
|
45
|
+
*
|
|
46
|
+
* ```ts
|
|
47
|
+
* const { markdown } = await nixet.documents.convert({
|
|
48
|
+
* file: await fs.openAsBlob("statement.pdf"),
|
|
49
|
+
* password: "secret",
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare class Documents {
|
|
54
|
+
private readonly transport;
|
|
55
|
+
constructor(transport: Transport);
|
|
56
|
+
/**
|
|
57
|
+
* Convert a document to Markdown.
|
|
58
|
+
*
|
|
59
|
+
* Synchronous: the Markdown is in the response. That holds below the size
|
|
60
|
+
* limit, which is lower than the knowledge upload limit for the same reason
|
|
61
|
+
* — a caller is waiting on this, where an ingested document is converted by
|
|
62
|
+
* a worker that can take as long as it needs.
|
|
63
|
+
*/
|
|
64
|
+
convert(params: ConvertDocumentParams): Promise<DocumentConversionResult>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Documents = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Reading a document.
|
|
6
|
+
*
|
|
7
|
+
* Converts fourteen formats to Markdown — PDF, Word, Excel, PowerPoint and the
|
|
8
|
+
* rest — locally, with no third party seeing the file. A PDF whose pages are
|
|
9
|
+
* scans needs an OCR engine and reports which pages it read that way.
|
|
10
|
+
*
|
|
11
|
+
* Separate from knowledge because the intent is different. A knowledge source
|
|
12
|
+
* is converted so an agent can search it, and what comes back are chunks
|
|
13
|
+
* ordered by similarity. This returns the document.
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* const { markdown } = await nixet.documents.convert({
|
|
17
|
+
* file: await fs.openAsBlob("statement.pdf"),
|
|
18
|
+
* password: "secret",
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
class Documents {
|
|
23
|
+
transport;
|
|
24
|
+
constructor(transport) {
|
|
25
|
+
this.transport = transport;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Convert a document to Markdown.
|
|
29
|
+
*
|
|
30
|
+
* Synchronous: the Markdown is in the response. That holds below the size
|
|
31
|
+
* limit, which is lower than the knowledge upload limit for the same reason
|
|
32
|
+
* — a caller is waiting on this, where an ingested document is converted by
|
|
33
|
+
* a worker that can take as long as it needs.
|
|
34
|
+
*/
|
|
35
|
+
async convert(params) {
|
|
36
|
+
const form = new FormData();
|
|
37
|
+
// A Blob keeps its own name; bytes need one supplied. `document` is the
|
|
38
|
+
// fallback rather than an error, because the name is only consulted for
|
|
39
|
+
// signature-less formats.
|
|
40
|
+
if (params.file instanceof Blob) {
|
|
41
|
+
form.append("file", params.file, params.filename ?? "document");
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
form.append("file", new Blob([params.file]), params.filename ?? "document");
|
|
45
|
+
}
|
|
46
|
+
if (params.password)
|
|
47
|
+
form.append("password", params.password);
|
|
48
|
+
if (params.collection)
|
|
49
|
+
form.append("collection", params.collection);
|
|
50
|
+
if (params.title)
|
|
51
|
+
form.append("title", params.title);
|
|
52
|
+
return this.transport.request({
|
|
53
|
+
method: "POST",
|
|
54
|
+
path: "/documents/convert",
|
|
55
|
+
body: form,
|
|
56
|
+
form: true,
|
|
57
|
+
signal: params.signal,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.Documents = Documents;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Transport } from "../transport.js";
|
|
2
|
+
import type { CreateGuardrailParams, Guardrail, GuardrailStage } from "@nixet/contracts";
|
|
3
|
+
import type { ListParams, Page } from "../types.js";
|
|
4
|
+
export interface ListGuardrailParams extends ListParams {
|
|
5
|
+
name?: string;
|
|
6
|
+
stage?: GuardrailStage;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Guardrails: what an agent may be given, and what it may say.
|
|
10
|
+
*
|
|
11
|
+
* Defined once for the workspace and named by a version, the same way MCP
|
|
12
|
+
* servers and knowledge collections are. A rule like "never name a specific
|
|
13
|
+
* fund" applies to every agent a customer runs, so it is defined in one place
|
|
14
|
+
* rather than once per version.
|
|
15
|
+
*
|
|
16
|
+
* Three stages. `input` runs before a model sees the text, `output` before a
|
|
17
|
+
* caller does, and `tool_result` on what a tool returned — the one that
|
|
18
|
+
* matters for an agent rendering structured data, because that never passes
|
|
19
|
+
* through the agent's text and an output guard never sees it.
|
|
20
|
+
*
|
|
21
|
+
* Four actions. `modify` is the useful one: scrubbing a fund name and letting
|
|
22
|
+
* the rest through is better behaviour than refusing the turn.
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* await nixet.guardrails.create({
|
|
26
|
+
* name: "pii-scrub",
|
|
27
|
+
* stage: "output",
|
|
28
|
+
* action: "modify",
|
|
29
|
+
* patterns: [{ match: "\\b\\d{12}\\b", replace: "[ACCOUNT]" }],
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* await nixet.agents.versions.create(agentId, {
|
|
33
|
+
* instructions: "…",
|
|
34
|
+
* guardrails: { output: ["pii-scrub"], mode: "run_all" },
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* There is no update and no delete. A version pins a guard by name, so
|
|
39
|
+
* renaming one would silently redirect what a published agent applies, and
|
|
40
|
+
* removing one would leave a version naming a rule that no longer exists.
|
|
41
|
+
* Editing a guard's rules does take effect on the next run everywhere it is
|
|
42
|
+
* named, which is the point of defining it at workspace level.
|
|
43
|
+
*/
|
|
44
|
+
export declare class Guardrails {
|
|
45
|
+
private readonly transport;
|
|
46
|
+
constructor(transport: Transport);
|
|
47
|
+
create(params: CreateGuardrailParams, options?: {
|
|
48
|
+
signal?: AbortSignal;
|
|
49
|
+
}): Promise<Guardrail>;
|
|
50
|
+
list(params?: ListGuardrailParams, options?: {
|
|
51
|
+
signal?: AbortSignal;
|
|
52
|
+
}): Promise<Page<Guardrail>>;
|
|
53
|
+
retrieve(id: string, options?: {
|
|
54
|
+
signal?: AbortSignal;
|
|
55
|
+
}): Promise<Guardrail>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Guardrails = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Guardrails: what an agent may be given, and what it may say.
|
|
6
|
+
*
|
|
7
|
+
* Defined once for the workspace and named by a version, the same way MCP
|
|
8
|
+
* servers and knowledge collections are. A rule like "never name a specific
|
|
9
|
+
* fund" applies to every agent a customer runs, so it is defined in one place
|
|
10
|
+
* rather than once per version.
|
|
11
|
+
*
|
|
12
|
+
* Three stages. `input` runs before a model sees the text, `output` before a
|
|
13
|
+
* caller does, and `tool_result` on what a tool returned — the one that
|
|
14
|
+
* matters for an agent rendering structured data, because that never passes
|
|
15
|
+
* through the agent's text and an output guard never sees it.
|
|
16
|
+
*
|
|
17
|
+
* Four actions. `modify` is the useful one: scrubbing a fund name and letting
|
|
18
|
+
* the rest through is better behaviour than refusing the turn.
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* await nixet.guardrails.create({
|
|
22
|
+
* name: "pii-scrub",
|
|
23
|
+
* stage: "output",
|
|
24
|
+
* action: "modify",
|
|
25
|
+
* patterns: [{ match: "\\b\\d{12}\\b", replace: "[ACCOUNT]" }],
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* await nixet.agents.versions.create(agentId, {
|
|
29
|
+
* instructions: "…",
|
|
30
|
+
* guardrails: { output: ["pii-scrub"], mode: "run_all" },
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* There is no update and no delete. A version pins a guard by name, so
|
|
35
|
+
* renaming one would silently redirect what a published agent applies, and
|
|
36
|
+
* removing one would leave a version naming a rule that no longer exists.
|
|
37
|
+
* Editing a guard's rules does take effect on the next run everywhere it is
|
|
38
|
+
* named, which is the point of defining it at workspace level.
|
|
39
|
+
*/
|
|
40
|
+
class Guardrails {
|
|
41
|
+
transport;
|
|
42
|
+
constructor(transport) {
|
|
43
|
+
this.transport = transport;
|
|
44
|
+
}
|
|
45
|
+
create(params, options = {}) {
|
|
46
|
+
return this.transport.request({
|
|
47
|
+
method: "POST",
|
|
48
|
+
path: "/guardrails",
|
|
49
|
+
body: params,
|
|
50
|
+
signal: options.signal,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
list(params = {}, options = {}) {
|
|
54
|
+
return this.transport.requestPage({
|
|
55
|
+
method: "GET",
|
|
56
|
+
path: "/guardrails",
|
|
57
|
+
// Mapped rather than spread: `$limit` is the wire name and `limit` is
|
|
58
|
+
// the one a caller writes, and spreading would send both.
|
|
59
|
+
query: {
|
|
60
|
+
$limit: params.limit,
|
|
61
|
+
$offset: params.offset,
|
|
62
|
+
name: params.name,
|
|
63
|
+
stage: params.stage,
|
|
64
|
+
},
|
|
65
|
+
signal: options.signal,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
retrieve(id, options = {}) {
|
|
69
|
+
return this.transport.request({
|
|
70
|
+
method: "GET",
|
|
71
|
+
path: `/guardrails/${id}`,
|
|
72
|
+
signal: options.signal,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.Guardrails = Guardrails;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import type { Transport } from "../transport.js";
|
|
2
|
+
import type { ChunkStrategy, KnowledgeCollection, KnowledgeSource, ListParams, Page, SourceStatus } from "../types.js";
|
|
3
|
+
export interface CreateKnowledgeCollectionParams {
|
|
4
|
+
/** Lowercase and hyphenated. This is what an agent version pins. */
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
/** Defaults to `recursive`. Fixed once the collection exists. */
|
|
8
|
+
chunkStrategy?: ChunkStrategy;
|
|
9
|
+
/** Characters per chunk, 128 to 8000. Defaults to 1000. Fixed at creation. */
|
|
10
|
+
chunkSize?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Characters each chunk repeats from the one before, 0 to 2000. Defaults to
|
|
13
|
+
* 200, and must be smaller than `chunkSize`. Fixed at creation.
|
|
14
|
+
*/
|
|
15
|
+
chunkOverlap?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface ListKnowledgeCollectionParams extends ListParams {
|
|
18
|
+
/** Find one collection by its name. */
|
|
19
|
+
name?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface CreateKnowledgeSourceParams {
|
|
22
|
+
/** The collection's name, not its id — the same handle a version pins. */
|
|
23
|
+
collection: string;
|
|
24
|
+
/** `file` is not here: bytes arrive as multipart, on the upload route. */
|
|
25
|
+
kind: "text" | "url";
|
|
26
|
+
title: string;
|
|
27
|
+
/** The text itself for `text`, the address for `url`. */
|
|
28
|
+
content: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ListKnowledgeSourceParams extends ListParams {
|
|
31
|
+
collectionId?: string;
|
|
32
|
+
/** Usually `ready` or `failed`: what an agent can search, and what went wrong. */
|
|
33
|
+
status?: SourceStatus;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Collections: the named indexes an agent version searches.
|
|
37
|
+
*
|
|
38
|
+
* A collection is a container and a chunking rule, nothing more. The documents
|
|
39
|
+
* in it are sources, and the chunks those produce live in the vector store the
|
|
40
|
+
* runtime owns.
|
|
41
|
+
*
|
|
42
|
+
* There is no update. The chunk settings are what a collection is, and they
|
|
43
|
+
* cannot change without the chunks already stored disagreeing with the ones
|
|
44
|
+
* added next: half an index split at 1000 characters and half at 400 retrieves
|
|
45
|
+
* badly, and nothing could honestly report which half a run searched. The name
|
|
46
|
+
* is fixed for the reason a secret's name is, since a published version pins
|
|
47
|
+
* it and a rename would silently redirect what a running agent searches.
|
|
48
|
+
* Re-chunking means creating another collection.
|
|
49
|
+
*/
|
|
50
|
+
export declare class KnowledgeCollections {
|
|
51
|
+
private readonly transport;
|
|
52
|
+
constructor(transport: Transport);
|
|
53
|
+
create(params: CreateKnowledgeCollectionParams, options?: {
|
|
54
|
+
signal?: AbortSignal;
|
|
55
|
+
}): Promise<KnowledgeCollection>;
|
|
56
|
+
retrieve(collectionId: string, options?: {
|
|
57
|
+
signal?: AbortSignal;
|
|
58
|
+
}): Promise<KnowledgeCollection>;
|
|
59
|
+
/**
|
|
60
|
+
* Collections, by name.
|
|
61
|
+
*
|
|
62
|
+
* `source_count` is every document whatever its status, while `chunk_count`
|
|
63
|
+
* covers only the sources that finished, so an index still being ingested
|
|
64
|
+
* reads as emptier than it will be.
|
|
65
|
+
*/
|
|
66
|
+
list(params?: ListKnowledgeCollectionParams, options?: {
|
|
67
|
+
signal?: AbortSignal;
|
|
68
|
+
}): Promise<Page<KnowledgeCollection>>;
|
|
69
|
+
/**
|
|
70
|
+
* Delete a collection.
|
|
71
|
+
*
|
|
72
|
+
* Refused while it still holds sources. Their chunks are in the vector store
|
|
73
|
+
* rather than beside this row, so dropping the collection first would leave
|
|
74
|
+
* them with nothing describing them and no scope key that resolves —
|
|
75
|
+
* orphaned vectors a later search could still match. Remove the sources
|
|
76
|
+
* first; their chunks go with them.
|
|
77
|
+
*
|
|
78
|
+
* A published version that named this collection can no longer search it,
|
|
79
|
+
* because a version is frozen and cannot be edited to drop the reference.
|
|
80
|
+
*/
|
|
81
|
+
del(collectionId: string, options?: {
|
|
82
|
+
signal?: AbortSignal;
|
|
83
|
+
}): Promise<KnowledgeCollection>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Sources: the documents inside a collection.
|
|
87
|
+
*
|
|
88
|
+
* Registering one writes a row and returns. Converting, OCR'ing, chunking and
|
|
89
|
+
* embedding all happen afterwards in a worker, because a scanned PDF of three
|
|
90
|
+
* hundred pages takes minutes and nothing useful comes of holding an HTTP
|
|
91
|
+
* request open for it. So `create` answers `pending` rather than `ready`, and
|
|
92
|
+
* `status` is the honest answer to "can my agent use this yet" — which is why
|
|
93
|
+
* it names the step in progress rather than a generic "processing".
|
|
94
|
+
*
|
|
95
|
+
* Uploading a file is `POST /v1/knowledge/sources/upload`, a multipart request
|
|
96
|
+
* this SDK does not yet wrap; `create` covers `text` and `url`, since bytes do
|
|
97
|
+
* not belong in JSON.
|
|
98
|
+
*
|
|
99
|
+
* There is no update. A source is what was ingested: its chunks were produced
|
|
100
|
+
* from the bytes on record, so editing the title or the content here would
|
|
101
|
+
* leave a row describing something other than what an agent actually searches.
|
|
102
|
+
* Replacing a document means ingesting it again.
|
|
103
|
+
*/
|
|
104
|
+
export declare class KnowledgeSources {
|
|
105
|
+
private readonly transport;
|
|
106
|
+
constructor(transport: Transport);
|
|
107
|
+
/**
|
|
108
|
+
* Register a document. Returns before it is searchable.
|
|
109
|
+
*
|
|
110
|
+
* Poll `retrieve` until `status` is `ready`, or `failed` with `error` saying
|
|
111
|
+
* why. A URL is fetched by the worker rather than by this call, so an
|
|
112
|
+
* address that cannot be reached surfaces there too.
|
|
113
|
+
*/
|
|
114
|
+
create(params: CreateKnowledgeSourceParams, options?: {
|
|
115
|
+
signal?: AbortSignal;
|
|
116
|
+
}): Promise<KnowledgeSource>;
|
|
117
|
+
retrieve(sourceId: string, options?: {
|
|
118
|
+
signal?: AbortSignal;
|
|
119
|
+
}): Promise<KnowledgeSource>;
|
|
120
|
+
/**
|
|
121
|
+
* Sources, newest first, because the one someone is waiting on is the one
|
|
122
|
+
* they just added. Filter on `status` to see what is actually searchable.
|
|
123
|
+
*/
|
|
124
|
+
list(params?: ListKnowledgeSourceParams, options?: {
|
|
125
|
+
signal?: AbortSignal;
|
|
126
|
+
}): Promise<Page<KnowledgeSource>>;
|
|
127
|
+
/**
|
|
128
|
+
* Delete a source.
|
|
129
|
+
*
|
|
130
|
+
* This is what removes a document from an index, and therefore what an
|
|
131
|
+
* erasure request is served by. The original is deleted before the row, so a
|
|
132
|
+
* failure leaves something to retry rather than a file in storage with
|
|
133
|
+
* nothing pointing at it.
|
|
134
|
+
*/
|
|
135
|
+
del(sourceId: string, options?: {
|
|
136
|
+
signal?: AbortSignal;
|
|
137
|
+
}): Promise<KnowledgeSource>;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Knowledge: your own documents, searchable by an agent.
|
|
141
|
+
*
|
|
142
|
+
* ```ts
|
|
143
|
+
* const collection = await nixet.knowledge.collections.create({
|
|
144
|
+
* name: "support-policies",
|
|
145
|
+
* chunkStrategy: "markdown",
|
|
146
|
+
* });
|
|
147
|
+
*
|
|
148
|
+
* const source = await nixet.knowledge.sources.create({
|
|
149
|
+
* collection: collection.name,
|
|
150
|
+
* kind: "text",
|
|
151
|
+
* title: "Refunds",
|
|
152
|
+
* content: "The refund window is thirty days.",
|
|
153
|
+
* });
|
|
154
|
+
*
|
|
155
|
+
* // Ingestion is asynchronous, so the source is `pending` here. Poll until
|
|
156
|
+
* // it is `ready` before expecting an agent to find anything in it.
|
|
157
|
+
* source.status; // "pending"
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* Two sub-resources rather than one, because a collection and a source are
|
|
161
|
+
* different lifetimes: a collection is a chunking rule fixed at creation, and
|
|
162
|
+
* a source is a document that arrives, is processed and can be removed on its
|
|
163
|
+
* own. A version pins a collection by name, the way it pins an MCP server, so
|
|
164
|
+
* adding a document changes what a published agent can find without
|
|
165
|
+
* republishing it.
|
|
166
|
+
*/
|
|
167
|
+
export declare class Knowledge {
|
|
168
|
+
/** Sub-resource, so `nixet.knowledge.collections.create(...)` reads naturally. */
|
|
169
|
+
readonly collections: KnowledgeCollections;
|
|
170
|
+
/**
|
|
171
|
+
* Sub-resource for the documents in a collection.
|
|
172
|
+
*
|
|
173
|
+
* Uploading a file is `POST /v1/knowledge/sources/upload` as multipart,
|
|
174
|
+
* which this SDK does not yet wrap; `sources.create` covers `text` and
|
|
175
|
+
* `url`.
|
|
176
|
+
*/
|
|
177
|
+
readonly sources: KnowledgeSources;
|
|
178
|
+
constructor(
|
|
179
|
+
/** Sub-resource, so `nixet.knowledge.collections.create(...)` reads naturally. */
|
|
180
|
+
collections: KnowledgeCollections,
|
|
181
|
+
/**
|
|
182
|
+
* Sub-resource for the documents in a collection.
|
|
183
|
+
*
|
|
184
|
+
* Uploading a file is `POST /v1/knowledge/sources/upload` as multipart,
|
|
185
|
+
* which this SDK does not yet wrap; `sources.create` covers `text` and
|
|
186
|
+
* `url`.
|
|
187
|
+
*/
|
|
188
|
+
sources: KnowledgeSources);
|
|
189
|
+
}
|