@nixet/sdk 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +164 -2
- package/dist/cjs/errors.d.ts +37 -0
- package/dist/cjs/errors.js +79 -0
- package/dist/cjs/index.d.ts +88 -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 +192 -0
- package/dist/cjs/resources/knowledge.js +221 -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 +215 -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 +42 -4
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemoryResource = void 0;
|
|
4
|
+
function target(params) {
|
|
5
|
+
return {
|
|
6
|
+
agent_id: params.agentId,
|
|
7
|
+
...(params.userId ? { user_id: params.userId } : {}),
|
|
8
|
+
...(params.conversationId ? { conversation_id: params.conversationId } : {}),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Memory: what an agent retains about a person or a thread.
|
|
13
|
+
*
|
|
14
|
+
* Distinct from a conversation transcript, which is the literal record of what
|
|
15
|
+
* was said. A memory is a fact worth keeping — a preference, a constraint, a
|
|
16
|
+
* problem — extracted from conversations or written directly.
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* await nixet.memory.create({
|
|
20
|
+
* scope: "user",
|
|
21
|
+
* agentId: agent.id,
|
|
22
|
+
* userId: user.id,
|
|
23
|
+
* content: "Prefers metric units and short answers.",
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* const found = await nixet.memory.search({
|
|
27
|
+
* query: "what are their preferences?",
|
|
28
|
+
* agentId: agent.id,
|
|
29
|
+
* userId: user.id,
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
class MemoryResource {
|
|
34
|
+
transport;
|
|
35
|
+
constructor(transport) {
|
|
36
|
+
this.transport = transport;
|
|
37
|
+
}
|
|
38
|
+
/** Recall memories relevant to a query, most relevant first. */
|
|
39
|
+
search(params, options = {}) {
|
|
40
|
+
return this.transport.request({
|
|
41
|
+
method: "POST",
|
|
42
|
+
path: "/memory/search",
|
|
43
|
+
body: {
|
|
44
|
+
...target(params),
|
|
45
|
+
query: params.query,
|
|
46
|
+
...(params.scope ? { scope: params.scope } : {}),
|
|
47
|
+
limit: params.limit ?? 10,
|
|
48
|
+
},
|
|
49
|
+
signal: options.signal,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Everything an agent holds, newest first.
|
|
54
|
+
*
|
|
55
|
+
* Use this to browse. `search` asks a question; this asks for the lot.
|
|
56
|
+
*/
|
|
57
|
+
list(params, options = {}) {
|
|
58
|
+
return this.transport.request({
|
|
59
|
+
method: "POST",
|
|
60
|
+
path: "/memory/list",
|
|
61
|
+
body: {
|
|
62
|
+
...target(params),
|
|
63
|
+
...(params.scope ? { scope: params.scope } : {}),
|
|
64
|
+
limit: params.limit ?? 50,
|
|
65
|
+
},
|
|
66
|
+
signal: options.signal,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Store a memory directly.
|
|
71
|
+
*
|
|
72
|
+
* Use this for facts you already know — a plan tier, an account setting —
|
|
73
|
+
* rather than waiting for them to be said in a conversation.
|
|
74
|
+
*/
|
|
75
|
+
create(params, options = {}) {
|
|
76
|
+
return this.transport.request({
|
|
77
|
+
method: "POST",
|
|
78
|
+
path: "/memory",
|
|
79
|
+
body: {
|
|
80
|
+
...target(params),
|
|
81
|
+
scope: params.scope,
|
|
82
|
+
content: params.content,
|
|
83
|
+
...(params.metadata ? { metadata: params.metadata } : {}),
|
|
84
|
+
...(params.expiresAt ? { expires_at: params.expiresAt } : {}),
|
|
85
|
+
},
|
|
86
|
+
signal: options.signal,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/** One memory by id. */
|
|
90
|
+
get(memoryId, params, options = {}) {
|
|
91
|
+
return this.transport.request({
|
|
92
|
+
method: "GET",
|
|
93
|
+
path: `/memory/${encodeURIComponent(memoryId)}`,
|
|
94
|
+
query: target(params),
|
|
95
|
+
signal: options.signal,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/** Correct a memory in place. */
|
|
99
|
+
update(memoryId, params, options = {}) {
|
|
100
|
+
return this.transport.request({
|
|
101
|
+
method: "PATCH",
|
|
102
|
+
path: `/memory/${encodeURIComponent(memoryId)}`,
|
|
103
|
+
body: {
|
|
104
|
+
...target(params),
|
|
105
|
+
...(params.content !== undefined ? { content: params.content } : {}),
|
|
106
|
+
...(params.metadata !== undefined ? { metadata: params.metadata } : {}),
|
|
107
|
+
...(params.expiresAt !== undefined ? { expires_at: params.expiresAt } : {}),
|
|
108
|
+
},
|
|
109
|
+
signal: options.signal,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Forget a memory.
|
|
114
|
+
*
|
|
115
|
+
* The only way to erase what an agent knows about a person, so it is also
|
|
116
|
+
* what an erasure request is served by.
|
|
117
|
+
*/
|
|
118
|
+
delete(memoryId, params, options = {}) {
|
|
119
|
+
return this.transport.request({
|
|
120
|
+
method: "DELETE",
|
|
121
|
+
path: `/memory/${encodeURIComponent(memoryId)}`,
|
|
122
|
+
query: target(params),
|
|
123
|
+
signal: options.signal,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.MemoryResource = MemoryResource;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { RunStream } from "../stream.js";
|
|
2
|
+
import type { Transport } from "../transport.js";
|
|
3
|
+
import type { ListParams, Page, Provider, Run, RunEvent } from "../types.js";
|
|
4
|
+
export interface CreateRunParams {
|
|
5
|
+
/** Message sent to the agent. */
|
|
6
|
+
input: string;
|
|
7
|
+
/** Pin a specific version. Defaults to the agent's published one. */
|
|
8
|
+
version?: string;
|
|
9
|
+
/** Override the version's provider for this run only. */
|
|
10
|
+
provider?: Provider;
|
|
11
|
+
/** Group related runs into one conversation. */
|
|
12
|
+
sessionId?: string;
|
|
13
|
+
/** Who the agent is serving. Decides whose MCP connections it may use. */
|
|
14
|
+
userId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Values for the placeholders the version declared.
|
|
17
|
+
*
|
|
18
|
+
* A version whose instructions hold `{{data_context}}` requires it here.
|
|
19
|
+
* Every declared placeholder must be supplied and nothing else may be: an
|
|
20
|
+
* unknown key is refused rather than ignored, so a caller cannot reach a
|
|
21
|
+
* slot the version never named.
|
|
22
|
+
*/
|
|
23
|
+
variables?: Record<string, string>;
|
|
24
|
+
/**
|
|
25
|
+
* Narrow this run to some of the version's MCP servers.
|
|
26
|
+
*
|
|
27
|
+
* A subset, never an addition — the version's list is the boundary of what
|
|
28
|
+
* the agent may reach. Useful when a user has connected one provider of
|
|
29
|
+
* three and the run should use that one rather than failing on the others.
|
|
30
|
+
*/
|
|
31
|
+
mcpServers?: string[];
|
|
32
|
+
}
|
|
33
|
+
export interface ListEventsParams extends ListParams {
|
|
34
|
+
/** Return only events after this sequence number, to resume a lost stream. */
|
|
35
|
+
after?: number;
|
|
36
|
+
type?: RunEvent["type"];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Agent execution.
|
|
40
|
+
*
|
|
41
|
+
* `create` waits and returns the finished run; `stream` returns events as they
|
|
42
|
+
* are produced. Both record the same run, so a stream that drops can still be
|
|
43
|
+
* read afterwards.
|
|
44
|
+
*/
|
|
45
|
+
export declare class Runs {
|
|
46
|
+
private readonly transport;
|
|
47
|
+
constructor(transport: Transport);
|
|
48
|
+
/** Run an agent and wait for it to finish. */
|
|
49
|
+
create(agentId: string, params: CreateRunParams, options?: {
|
|
50
|
+
signal?: AbortSignal;
|
|
51
|
+
}): Promise<Run>;
|
|
52
|
+
/**
|
|
53
|
+
* Run an agent and receive events as they happen.
|
|
54
|
+
*
|
|
55
|
+
* ```ts
|
|
56
|
+
* const stream = await nixet.runs.stream(agentId, { input: "Hello" });
|
|
57
|
+
* for await (const chunk of stream.chunks()) process.stdout.write(chunk);
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
stream(agentId: string, params: CreateRunParams, options?: {
|
|
61
|
+
signal?: AbortSignal;
|
|
62
|
+
}): Promise<RunStream>;
|
|
63
|
+
retrieve(runId: string, options?: {
|
|
64
|
+
signal?: AbortSignal;
|
|
65
|
+
}): Promise<Run>;
|
|
66
|
+
list(agentId: string, params?: ListParams, options?: {
|
|
67
|
+
signal?: AbortSignal;
|
|
68
|
+
}): Promise<Page<Run>>;
|
|
69
|
+
/**
|
|
70
|
+
* The recorded event log.
|
|
71
|
+
*
|
|
72
|
+
* Pass `after` to resume from the last event already seen, rather than
|
|
73
|
+
* running the agent again.
|
|
74
|
+
*/
|
|
75
|
+
events(runId: string, params?: ListEventsParams, options?: {
|
|
76
|
+
signal?: AbortSignal;
|
|
77
|
+
}): Promise<Page<RunEvent>>;
|
|
78
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Runs = void 0;
|
|
4
|
+
const stream_js_1 = require("../stream.js");
|
|
5
|
+
/**
|
|
6
|
+
* Agent execution.
|
|
7
|
+
*
|
|
8
|
+
* `create` waits and returns the finished run; `stream` returns events as they
|
|
9
|
+
* are produced. Both record the same run, so a stream that drops can still be
|
|
10
|
+
* read afterwards.
|
|
11
|
+
*/
|
|
12
|
+
class Runs {
|
|
13
|
+
transport;
|
|
14
|
+
constructor(transport) {
|
|
15
|
+
this.transport = transport;
|
|
16
|
+
}
|
|
17
|
+
/** Run an agent and wait for it to finish. */
|
|
18
|
+
async create(agentId, params, options = {}) {
|
|
19
|
+
return this.transport.request({
|
|
20
|
+
method: "POST",
|
|
21
|
+
path: `/agents/${encodeURIComponent(agentId)}/runs`,
|
|
22
|
+
body: toBody(params),
|
|
23
|
+
signal: options.signal,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Run an agent and receive events as they happen.
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* const stream = await nixet.runs.stream(agentId, { input: "Hello" });
|
|
31
|
+
* for await (const chunk of stream.chunks()) process.stdout.write(chunk);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
async stream(agentId, params, options = {}) {
|
|
35
|
+
const response = await this.transport.stream({
|
|
36
|
+
method: "POST",
|
|
37
|
+
path: `/agents/${encodeURIComponent(agentId)}/runs/stream`,
|
|
38
|
+
body: toBody(params),
|
|
39
|
+
signal: options.signal,
|
|
40
|
+
});
|
|
41
|
+
return new stream_js_1.RunStream(response);
|
|
42
|
+
}
|
|
43
|
+
async retrieve(runId, options = {}) {
|
|
44
|
+
return this.transport.request({
|
|
45
|
+
method: "GET",
|
|
46
|
+
path: `/runs/${encodeURIComponent(runId)}`,
|
|
47
|
+
signal: options.signal,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
async list(agentId, params = {}, options = {}) {
|
|
51
|
+
return this.transport.requestPage({
|
|
52
|
+
method: "GET",
|
|
53
|
+
path: `/agents/${encodeURIComponent(agentId)}/runs`,
|
|
54
|
+
query: { $limit: params.limit, $offset: params.offset },
|
|
55
|
+
signal: options.signal,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The recorded event log.
|
|
60
|
+
*
|
|
61
|
+
* Pass `after` to resume from the last event already seen, rather than
|
|
62
|
+
* running the agent again.
|
|
63
|
+
*/
|
|
64
|
+
async events(runId, params = {}, options = {}) {
|
|
65
|
+
return this.transport.requestPage({
|
|
66
|
+
method: "GET",
|
|
67
|
+
path: `/runs/${encodeURIComponent(runId)}/events`,
|
|
68
|
+
query: {
|
|
69
|
+
"sequence[$gt]": params.after,
|
|
70
|
+
type: params.type,
|
|
71
|
+
$limit: params.limit,
|
|
72
|
+
$offset: params.offset,
|
|
73
|
+
},
|
|
74
|
+
signal: options.signal,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.Runs = Runs;
|
|
79
|
+
const toBody = (params) => ({
|
|
80
|
+
input: params.input,
|
|
81
|
+
...(params.version ? { agent_version: params.version } : {}),
|
|
82
|
+
...(params.provider ? { provider: params.provider } : {}),
|
|
83
|
+
...(params.sessionId ? { session_id: params.sessionId } : {}),
|
|
84
|
+
...(params.userId ? { user_id: params.userId } : {}),
|
|
85
|
+
...(params.variables ? { variables: params.variables } : {}),
|
|
86
|
+
...(params.mcpServers ? { mcp_servers: params.mcpServers } : {}),
|
|
87
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Transport } from "../transport.js";
|
|
2
|
+
import type { ListParams, Page, Secret } from "../types.js";
|
|
3
|
+
export interface CreateSecretParams {
|
|
4
|
+
/** Lowercase and hyphenated. A version pins this, so it cannot change. */
|
|
5
|
+
name: string;
|
|
6
|
+
value: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface UpdateSecretParams {
|
|
10
|
+
/** Replaces the stored credential. */
|
|
11
|
+
value?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Secrets: credentials you give us so an agent can reach something of yours.
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* await nixet.secrets.create({ name: "github-token", value: process.env.GH_PAT });
|
|
19
|
+
*
|
|
20
|
+
* await nixet.mcpServers.create({
|
|
21
|
+
* name: "github",
|
|
22
|
+
* url: "https://mcp.example.com/mcp",
|
|
23
|
+
* auth: { type: "bearer", secret: "github-token" },
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* A value is written once and never returned — `retrieve` and `list` carry a
|
|
28
|
+
* name and a hint, and no route exists that could answer with the credential.
|
|
29
|
+
* To rotate one, store a new value under the same name; whatever refers to it
|
|
30
|
+
* picks the new value up on the next run.
|
|
31
|
+
*/
|
|
32
|
+
export declare class Secrets {
|
|
33
|
+
private readonly transport;
|
|
34
|
+
constructor(transport: Transport);
|
|
35
|
+
create(params: CreateSecretParams, options?: {
|
|
36
|
+
signal?: AbortSignal;
|
|
37
|
+
}): Promise<Secret>;
|
|
38
|
+
/** Metadata only. The value is not part of this response by design. */
|
|
39
|
+
retrieve(secretId: string, options?: {
|
|
40
|
+
signal?: AbortSignal;
|
|
41
|
+
}): Promise<Secret>;
|
|
42
|
+
list(params?: ListParams & {
|
|
43
|
+
name?: string;
|
|
44
|
+
}, options?: {
|
|
45
|
+
signal?: AbortSignal;
|
|
46
|
+
}): Promise<Page<Secret>>;
|
|
47
|
+
/** Replace the value, or the description. The name is fixed. */
|
|
48
|
+
update(secretId: string, params: UpdateSecretParams, options?: {
|
|
49
|
+
signal?: AbortSignal;
|
|
50
|
+
}): Promise<Secret>;
|
|
51
|
+
/**
|
|
52
|
+
* Delete a secret.
|
|
53
|
+
*
|
|
54
|
+
* Anything that names it stops authenticating, so a published version
|
|
55
|
+
* referring to this secret will start failing against its server.
|
|
56
|
+
*/
|
|
57
|
+
del(secretId: string, options?: {
|
|
58
|
+
signal?: AbortSignal;
|
|
59
|
+
}): Promise<Secret>;
|
|
60
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Secrets = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Secrets: credentials you give us so an agent can reach something of yours.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* await nixet.secrets.create({ name: "github-token", value: process.env.GH_PAT });
|
|
9
|
+
*
|
|
10
|
+
* await nixet.mcpServers.create({
|
|
11
|
+
* name: "github",
|
|
12
|
+
* url: "https://mcp.example.com/mcp",
|
|
13
|
+
* auth: { type: "bearer", secret: "github-token" },
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* A value is written once and never returned — `retrieve` and `list` carry a
|
|
18
|
+
* name and a hint, and no route exists that could answer with the credential.
|
|
19
|
+
* To rotate one, store a new value under the same name; whatever refers to it
|
|
20
|
+
* picks the new value up on the next run.
|
|
21
|
+
*/
|
|
22
|
+
class Secrets {
|
|
23
|
+
transport;
|
|
24
|
+
constructor(transport) {
|
|
25
|
+
this.transport = transport;
|
|
26
|
+
}
|
|
27
|
+
create(params, options = {}) {
|
|
28
|
+
return this.transport.request({
|
|
29
|
+
method: "POST",
|
|
30
|
+
path: "/secrets",
|
|
31
|
+
body: {
|
|
32
|
+
name: params.name,
|
|
33
|
+
value: params.value,
|
|
34
|
+
...(params.description ? { description: params.description } : {}),
|
|
35
|
+
},
|
|
36
|
+
signal: options.signal,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/** Metadata only. The value is not part of this response by design. */
|
|
40
|
+
retrieve(secretId, options = {}) {
|
|
41
|
+
return this.transport.request({
|
|
42
|
+
method: "GET",
|
|
43
|
+
path: `/secrets/${encodeURIComponent(secretId)}`,
|
|
44
|
+
signal: options.signal,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
list(params = {}, options = {}) {
|
|
48
|
+
return this.transport.requestPage({
|
|
49
|
+
method: "GET",
|
|
50
|
+
path: "/secrets",
|
|
51
|
+
query: {
|
|
52
|
+
$limit: params.limit,
|
|
53
|
+
$offset: params.offset,
|
|
54
|
+
name: params.name,
|
|
55
|
+
},
|
|
56
|
+
signal: options.signal,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/** Replace the value, or the description. The name is fixed. */
|
|
60
|
+
update(secretId, params, options = {}) {
|
|
61
|
+
return this.transport.request({
|
|
62
|
+
method: "PATCH",
|
|
63
|
+
path: `/secrets/${encodeURIComponent(secretId)}`,
|
|
64
|
+
body: {
|
|
65
|
+
...(params.value === undefined ? {} : { value: params.value }),
|
|
66
|
+
...(params.description === undefined ? {} : { description: params.description }),
|
|
67
|
+
},
|
|
68
|
+
signal: options.signal,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Delete a secret.
|
|
73
|
+
*
|
|
74
|
+
* Anything that names it stops authenticating, so a published version
|
|
75
|
+
* referring to this secret will start failing against its server.
|
|
76
|
+
*/
|
|
77
|
+
del(secretId, options = {}) {
|
|
78
|
+
return this.transport.request({
|
|
79
|
+
method: "DELETE",
|
|
80
|
+
path: `/secrets/${encodeURIComponent(secretId)}`,
|
|
81
|
+
signal: options.signal,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.Secrets = Secrets;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Transport } from "../transport.js";
|
|
2
|
+
import type { ListParams, Page, Skill, SkillVersion, ToolRef } from "../types.js";
|
|
3
|
+
export interface CreateSkillParams {
|
|
4
|
+
/** Lowercase, optionally namespaced as `group/name`. */
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
/** Supplying instructions also publishes the first version. */
|
|
8
|
+
instructions?: string;
|
|
9
|
+
tools?: (ToolRef | string)[];
|
|
10
|
+
}
|
|
11
|
+
export interface CreateSkillVersionParams {
|
|
12
|
+
instructions: string;
|
|
13
|
+
tools?: (ToolRef | string)[];
|
|
14
|
+
/** Make this the version bare references resolve to. Defaults to true. */
|
|
15
|
+
publish?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Skills: reusable expertise an agent can use.
|
|
19
|
+
*
|
|
20
|
+
* A skill is instructions plus the tools that expertise needs, versioned like
|
|
21
|
+
* an agent. An agent version references one as `name` or `name@v2`.
|
|
22
|
+
*/
|
|
23
|
+
export declare class Skills {
|
|
24
|
+
private readonly transport;
|
|
25
|
+
constructor(transport: Transport);
|
|
26
|
+
/**
|
|
27
|
+
* Create a skill, optionally publishing its first version.
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* await nixet.skills.create({
|
|
31
|
+
* name: "research/company-lookup",
|
|
32
|
+
* instructions: "State the industry and size of any company asked about.",
|
|
33
|
+
* tools: ["current_time"],
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
create(params: CreateSkillParams, options?: {
|
|
38
|
+
signal?: AbortSignal;
|
|
39
|
+
}): Promise<Skill & {
|
|
40
|
+
version?: SkillVersion;
|
|
41
|
+
}>;
|
|
42
|
+
retrieve(skillId: string, options?: {
|
|
43
|
+
signal?: AbortSignal;
|
|
44
|
+
}): Promise<Skill>;
|
|
45
|
+
list(params?: ListParams, options?: {
|
|
46
|
+
signal?: AbortSignal;
|
|
47
|
+
}): Promise<Page<Skill>>;
|
|
48
|
+
/** Immutable versions of a skill. */
|
|
49
|
+
readonly versions: {
|
|
50
|
+
create: (skillId: string, params: CreateSkillVersionParams, options?: {
|
|
51
|
+
signal?: AbortSignal;
|
|
52
|
+
}) => Promise<SkillVersion>;
|
|
53
|
+
list: (skillId: string, params?: ListParams, options?: {
|
|
54
|
+
signal?: AbortSignal;
|
|
55
|
+
}) => Promise<Page<SkillVersion>>;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Skills = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Skills: reusable expertise an agent can use.
|
|
6
|
+
*
|
|
7
|
+
* A skill is instructions plus the tools that expertise needs, versioned like
|
|
8
|
+
* an agent. An agent version references one as `name` or `name@v2`.
|
|
9
|
+
*/
|
|
10
|
+
class Skills {
|
|
11
|
+
transport;
|
|
12
|
+
constructor(transport) {
|
|
13
|
+
this.transport = transport;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create a skill, optionally publishing its first version.
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* await nixet.skills.create({
|
|
20
|
+
* name: "research/company-lookup",
|
|
21
|
+
* instructions: "State the industry and size of any company asked about.",
|
|
22
|
+
* tools: ["current_time"],
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
async create(params, options = {}) {
|
|
27
|
+
const skill = await this.transport.request({
|
|
28
|
+
method: "POST",
|
|
29
|
+
path: "/skills",
|
|
30
|
+
body: {
|
|
31
|
+
name: params.name,
|
|
32
|
+
...(params.description ? { description: params.description } : {}),
|
|
33
|
+
},
|
|
34
|
+
signal: options.signal,
|
|
35
|
+
});
|
|
36
|
+
if (!params.instructions)
|
|
37
|
+
return skill;
|
|
38
|
+
const version = await this.versions.create(skill.id, { instructions: params.instructions, tools: params.tools }, options);
|
|
39
|
+
// The skill was read before the version published, so its pointer is stale.
|
|
40
|
+
return { ...skill, current_version: version.version, version };
|
|
41
|
+
}
|
|
42
|
+
async retrieve(skillId, options = {}) {
|
|
43
|
+
return this.transport.request({
|
|
44
|
+
method: "GET",
|
|
45
|
+
path: `/skills/${encodeURIComponent(skillId)}`,
|
|
46
|
+
signal: options.signal,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async list(params = {}, options = {}) {
|
|
50
|
+
return this.transport.requestPage({
|
|
51
|
+
method: "GET",
|
|
52
|
+
path: "/skills",
|
|
53
|
+
query: { $limit: params.limit, $offset: params.offset },
|
|
54
|
+
signal: options.signal,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** Immutable versions of a skill. */
|
|
58
|
+
versions = {
|
|
59
|
+
create: async (skillId, params, options = {}) => this.transport.request({
|
|
60
|
+
method: "POST",
|
|
61
|
+
path: `/skills/${encodeURIComponent(skillId)}/versions`,
|
|
62
|
+
body: {
|
|
63
|
+
instructions: params.instructions,
|
|
64
|
+
...(params.tools ? { tools: params.tools.map(toToolRef) } : {}),
|
|
65
|
+
...(params.publish === undefined ? {} : { publish: params.publish }),
|
|
66
|
+
},
|
|
67
|
+
signal: options.signal,
|
|
68
|
+
}),
|
|
69
|
+
list: async (skillId, params = {}, options = {}) => this.transport.requestPage({
|
|
70
|
+
method: "GET",
|
|
71
|
+
path: `/skills/${encodeURIComponent(skillId)}/versions`,
|
|
72
|
+
query: { $limit: params.limit, $offset: params.offset },
|
|
73
|
+
signal: options.signal,
|
|
74
|
+
}),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
exports.Skills = Skills;
|
|
78
|
+
const toToolRef = (tool) => typeof tool === "string" ? { name: tool } : tool;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { Transport } from "../transport.js";
|
|
2
|
+
import type { ListParams, MemoryPolicy, Page, Provider, Task, TaskStatus } from "../types.js";
|
|
3
|
+
export interface CreateTaskParams {
|
|
4
|
+
agentId: string;
|
|
5
|
+
input: string;
|
|
6
|
+
/** Pins a version. Defaults to whatever is published when the task is queued. */
|
|
7
|
+
version?: string;
|
|
8
|
+
conversationId?: string;
|
|
9
|
+
userId?: string;
|
|
10
|
+
provider?: Provider;
|
|
11
|
+
memory?: MemoryPolicy;
|
|
12
|
+
/** How many times to try before giving up. Defaults to three. */
|
|
13
|
+
maxAttempts?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface ListTaskParams extends ListParams {
|
|
16
|
+
status?: TaskStatus;
|
|
17
|
+
agentId?: string;
|
|
18
|
+
conversationId?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Tasks: work that outlives the request that asked for it.
|
|
22
|
+
*
|
|
23
|
+
* A run has to finish inside its HTTP request. A task does not: it is queued,
|
|
24
|
+
* executed by a worker, and polled for. Use it for anything that would
|
|
25
|
+
* otherwise time out — research, a long report, a batch of lookups.
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* const task = await nixet.tasks.create({
|
|
29
|
+
* agentId: agent.id,
|
|
30
|
+
* input: "Research this company and produce a report.",
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* const finished = await nixet.tasks.wait(task.id);
|
|
34
|
+
* console.log(finished.output);
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* The work runs as a normal run, so `task.run_id` is where the trace, the
|
|
38
|
+
* events and the cost live.
|
|
39
|
+
*/
|
|
40
|
+
export declare class Tasks {
|
|
41
|
+
private readonly transport;
|
|
42
|
+
constructor(transport: Transport);
|
|
43
|
+
/** Queue a task. Returns immediately, before the work starts. */
|
|
44
|
+
create(params: CreateTaskParams, options?: {
|
|
45
|
+
signal?: AbortSignal;
|
|
46
|
+
}): Promise<Task>;
|
|
47
|
+
retrieve(taskId: string, options?: {
|
|
48
|
+
signal?: AbortSignal;
|
|
49
|
+
}): Promise<Task>;
|
|
50
|
+
list(params?: ListTaskParams, options?: {
|
|
51
|
+
signal?: AbortSignal;
|
|
52
|
+
}): Promise<Page<Task>>;
|
|
53
|
+
/**
|
|
54
|
+
* Stop a task.
|
|
55
|
+
*
|
|
56
|
+
* A queued task stops immediately. A running one is marked cancelled and the
|
|
57
|
+
* worker notices when its run finishes, because interrupting a model call
|
|
58
|
+
* mid-flight would still be billed for.
|
|
59
|
+
*/
|
|
60
|
+
cancel(taskId: string, options?: {
|
|
61
|
+
signal?: AbortSignal;
|
|
62
|
+
}): Promise<Task>;
|
|
63
|
+
/** Try a failed or cancelled task again, with its attempts reset. */
|
|
64
|
+
retry(taskId: string, options?: {
|
|
65
|
+
signal?: AbortSignal;
|
|
66
|
+
}): Promise<Task>;
|
|
67
|
+
/**
|
|
68
|
+
* Continue a paused task.
|
|
69
|
+
*
|
|
70
|
+
* Nothing pauses a task yet — that arrives with tools and approvals — so
|
|
71
|
+
* this currently answers that there is nothing to resume.
|
|
72
|
+
*/
|
|
73
|
+
resume(taskId: string, options?: {
|
|
74
|
+
signal?: AbortSignal;
|
|
75
|
+
}): Promise<Task>;
|
|
76
|
+
/**
|
|
77
|
+
* Poll until the task stops, and return it.
|
|
78
|
+
*
|
|
79
|
+
* Convenience over `retrieve`, not a different mechanism: there is no push
|
|
80
|
+
* for tasks yet, so this is the loop everyone would otherwise write. The
|
|
81
|
+
* timeout exists so a stuck task fails the caller rather than hanging.
|
|
82
|
+
*/
|
|
83
|
+
wait(taskId: string, options?: {
|
|
84
|
+
signal?: AbortSignal;
|
|
85
|
+
/** How often to check. Default two seconds. */
|
|
86
|
+
intervalMs?: number;
|
|
87
|
+
/** How long to keep checking. Default ten minutes. */
|
|
88
|
+
timeoutMs?: number;
|
|
89
|
+
onUpdate?: (task: Task) => void;
|
|
90
|
+
}): Promise<Task>;
|
|
91
|
+
}
|