@nixet/contracts 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 +12 -2
- package/dist/cjs/domains/agents.d.ts +284 -0
- package/dist/cjs/domains/agents.js +244 -0
- package/dist/cjs/domains/api-keys.d.ts +265 -0
- package/dist/cjs/domains/api-keys.js +87 -0
- package/dist/cjs/domains/billing.d.ts +98 -0
- package/dist/cjs/domains/billing.js +122 -0
- package/dist/cjs/domains/connections.d.ts +101 -0
- package/dist/cjs/domains/connections.js +130 -0
- package/dist/cjs/domains/conversations.d.ts +113 -0
- package/dist/cjs/domains/conversations.js +85 -0
- package/dist/cjs/domains/documents.d.ts +48 -0
- package/dist/cjs/domains/documents.js +64 -0
- package/dist/cjs/domains/guardrails.d.ts +211 -0
- package/dist/cjs/domains/guardrails.js +206 -0
- package/dist/cjs/domains/identity.d.ts +55 -0
- package/dist/cjs/domains/identity.js +26 -0
- package/dist/cjs/domains/knowledge.d.ts +167 -0
- package/dist/cjs/domains/knowledge.js +174 -0
- package/dist/cjs/domains/mcp.d.ts +189 -0
- package/dist/cjs/domains/mcp.js +183 -0
- package/dist/cjs/domains/memory.d.ts +109 -0
- package/dist/cjs/domains/memory.js +92 -0
- package/dist/cjs/domains/redaction.d.ts +181 -0
- package/dist/cjs/domains/redaction.js +166 -0
- package/dist/cjs/domains/runs.d.ts +260 -0
- package/dist/cjs/domains/runs.js +260 -0
- package/dist/cjs/domains/secrets.d.ts +56 -0
- package/dist/cjs/domains/secrets.js +72 -0
- package/dist/cjs/domains/skills.d.ts +70 -0
- package/dist/cjs/domains/skills.js +82 -0
- package/dist/cjs/domains/tasks.d.ts +111 -0
- package/dist/cjs/domains/tasks.js +113 -0
- package/dist/cjs/domains/tools.d.ts +159 -0
- package/dist/cjs/domains/tools.js +203 -0
- package/dist/cjs/domains/users.d.ts +40 -0
- package/dist/cjs/domains/users.js +48 -0
- package/dist/cjs/index.d.ts +25 -0
- package/dist/cjs/index.js +41 -0
- package/dist/cjs/primitives.d.ts +75 -0
- package/dist/cjs/primitives.js +117 -0
- package/dist/esm/domains/agents.js +239 -0
- package/dist/esm/domains/api-keys.js +83 -0
- package/dist/esm/domains/billing.js +116 -0
- package/dist/esm/domains/connections.js +127 -0
- package/dist/esm/domains/conversations.js +82 -0
- package/dist/esm/domains/documents.js +61 -0
- package/dist/esm/domains/guardrails.js +202 -0
- package/dist/esm/domains/identity.js +23 -0
- package/dist/esm/domains/knowledge.js +170 -0
- package/dist/esm/domains/mcp.js +178 -0
- package/dist/esm/domains/memory.js +89 -0
- package/dist/esm/domains/redaction.js +162 -0
- package/dist/esm/domains/runs.js +256 -0
- package/dist/esm/domains/secrets.js +68 -0
- package/dist/esm/domains/skills.js +79 -0
- package/dist/esm/domains/tasks.js +109 -0
- package/dist/esm/domains/tools.js +196 -0
- package/dist/esm/domains/users.js +45 -0
- package/dist/esm/index.js +25 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/primitives.js +114 -0
- package/package.json +38 -4
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* MCP servers.
|
|
4
|
+
*
|
|
5
|
+
* A customer registers a server they run, and an agent version names it. The
|
|
6
|
+
* runtime connects, discovers its tools, and the agent can call them.
|
|
7
|
+
*
|
|
8
|
+
* Remote only. `stdio` would mean spawning a process inside our runtime from
|
|
9
|
+
* customer-supplied arguments, which is arbitrary code execution as us, so the
|
|
10
|
+
* transport is not in the enum rather than being rejected later.
|
|
11
|
+
*/
|
|
12
|
+
export declare const mcpTransportSchema: z.ZodEnum<{
|
|
13
|
+
http: "http";
|
|
14
|
+
sse: "sse";
|
|
15
|
+
}>;
|
|
16
|
+
export type McpTransport = z.infer<typeof mcpTransportSchema>;
|
|
17
|
+
/**
|
|
18
|
+
* How an end user's credential for a server was obtained.
|
|
19
|
+
*
|
|
20
|
+
* The scheme decides what connecting costs the user, and what expiry means:
|
|
21
|
+
*
|
|
22
|
+
* - `api_key` the value is supplied directly and does not expire.
|
|
23
|
+
* - `oauth2` the user is sent through the provider's consent screen. The
|
|
24
|
+
* access token expires; a refresh token, where the provider
|
|
25
|
+
* issues one, is stored so it can be replaced without asking
|
|
26
|
+
* the user again.
|
|
27
|
+
* - `session` the credential is a session identifier obtained by calling a
|
|
28
|
+
* tool on the server, and there is nothing to refresh it with.
|
|
29
|
+
* Expiry means sending the user through sign-in again, which is
|
|
30
|
+
* why it is not modelled as a short-lived `oauth2`.
|
|
31
|
+
*/
|
|
32
|
+
export declare const mcpConnectionSchemeSchema: z.ZodEnum<{
|
|
33
|
+
session: "session";
|
|
34
|
+
api_key: "api_key";
|
|
35
|
+
oauth2: "oauth2";
|
|
36
|
+
}>;
|
|
37
|
+
export type McpConnectionScheme = z.infer<typeof mcpConnectionSchemeSchema>;
|
|
38
|
+
/**
|
|
39
|
+
* How Nixet proves who it is to the server.
|
|
40
|
+
*
|
|
41
|
+
* `none` is for a server that is open or already restricted by network. The
|
|
42
|
+
* rest reference a stored secret by name rather than carrying a credential, so
|
|
43
|
+
* a configuration can be read, copied and versioned without the token.
|
|
44
|
+
*/
|
|
45
|
+
export declare const mcpAuthSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
46
|
+
type: z.ZodLiteral<"none">;
|
|
47
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
48
|
+
type: z.ZodLiteral<"bearer">;
|
|
49
|
+
secret: z.ZodString;
|
|
50
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
51
|
+
type: z.ZodLiteral<"header">;
|
|
52
|
+
header: z.ZodString;
|
|
53
|
+
secret: z.ZodString;
|
|
54
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
55
|
+
type: z.ZodLiteral<"oauth">;
|
|
56
|
+
secret: z.ZodString;
|
|
57
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
58
|
+
type: z.ZodLiteral<"per_user">;
|
|
59
|
+
scheme: z.ZodEnum<{
|
|
60
|
+
session: "session";
|
|
61
|
+
api_key: "api_key";
|
|
62
|
+
oauth2: "oauth2";
|
|
63
|
+
}>;
|
|
64
|
+
}, z.core.$strict>], "type">;
|
|
65
|
+
export type McpAuth = z.infer<typeof mcpAuthSchema>;
|
|
66
|
+
/**
|
|
67
|
+
* Whether a server's credential comes from the end user rather than the
|
|
68
|
+
* workspace. A per-user server cannot be reached by a run that names no user.
|
|
69
|
+
*/
|
|
70
|
+
export declare function isPerUserAuth(auth: McpAuth): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* A URL Nixet will connect to.
|
|
73
|
+
*
|
|
74
|
+
* Only the shape is checked here. Whether the host is reachable, and whether it
|
|
75
|
+
* is somewhere we are willing to go, is decided at connect time against the
|
|
76
|
+
* resolved address — a name that passes here can still resolve to a private
|
|
77
|
+
* one, and the check that matters has to happen after resolution.
|
|
78
|
+
*/
|
|
79
|
+
export declare const mcpUrlSchema: z.ZodString;
|
|
80
|
+
/**
|
|
81
|
+
* Tools are their own resource.
|
|
82
|
+
*
|
|
83
|
+
* A server can expose a hundred, each carrying its own tags and its own policy,
|
|
84
|
+
* so they are rows rather than a field on this one. See `domains/tools`.
|
|
85
|
+
*/
|
|
86
|
+
export declare const mcpServerSchema: z.ZodObject<{
|
|
87
|
+
id: z.ZodString;
|
|
88
|
+
name: z.ZodString;
|
|
89
|
+
description: z.ZodNullable<z.ZodString>;
|
|
90
|
+
transport: z.ZodEnum<{
|
|
91
|
+
http: "http";
|
|
92
|
+
sse: "sse";
|
|
93
|
+
}>;
|
|
94
|
+
url: z.ZodString;
|
|
95
|
+
auth: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
96
|
+
type: z.ZodLiteral<"none">;
|
|
97
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
98
|
+
type: z.ZodLiteral<"bearer">;
|
|
99
|
+
secret: z.ZodString;
|
|
100
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
101
|
+
type: z.ZodLiteral<"header">;
|
|
102
|
+
header: z.ZodString;
|
|
103
|
+
secret: z.ZodString;
|
|
104
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
105
|
+
type: z.ZodLiteral<"oauth">;
|
|
106
|
+
secret: z.ZodString;
|
|
107
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
108
|
+
type: z.ZodLiteral<"per_user">;
|
|
109
|
+
scheme: z.ZodEnum<{
|
|
110
|
+
session: "session";
|
|
111
|
+
api_key: "api_key";
|
|
112
|
+
oauth2: "oauth2";
|
|
113
|
+
}>;
|
|
114
|
+
}, z.core.$strict>], "type">;
|
|
115
|
+
tool_count: z.ZodNumber;
|
|
116
|
+
tools_refreshed_at: z.ZodNullable<z.ZodString>;
|
|
117
|
+
last_error: z.ZodNullable<z.ZodString>;
|
|
118
|
+
created_at: z.ZodString;
|
|
119
|
+
updated_at: z.ZodString;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
export type McpServer = z.infer<typeof mcpServerSchema>;
|
|
122
|
+
export declare const mcpNameSchema: z.ZodString;
|
|
123
|
+
export declare const createMcpServerSchema: z.ZodObject<{
|
|
124
|
+
name: z.ZodString;
|
|
125
|
+
url: z.ZodString;
|
|
126
|
+
transport: z.ZodDefault<z.ZodEnum<{
|
|
127
|
+
http: "http";
|
|
128
|
+
sse: "sse";
|
|
129
|
+
}>>;
|
|
130
|
+
description: z.ZodOptional<z.ZodString>;
|
|
131
|
+
auth: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
132
|
+
type: z.ZodLiteral<"none">;
|
|
133
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
134
|
+
type: z.ZodLiteral<"bearer">;
|
|
135
|
+
secret: z.ZodString;
|
|
136
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
137
|
+
type: z.ZodLiteral<"header">;
|
|
138
|
+
header: z.ZodString;
|
|
139
|
+
secret: z.ZodString;
|
|
140
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
141
|
+
type: z.ZodLiteral<"oauth">;
|
|
142
|
+
secret: z.ZodString;
|
|
143
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
144
|
+
type: z.ZodLiteral<"per_user">;
|
|
145
|
+
scheme: z.ZodEnum<{
|
|
146
|
+
session: "session";
|
|
147
|
+
api_key: "api_key";
|
|
148
|
+
oauth2: "oauth2";
|
|
149
|
+
}>;
|
|
150
|
+
}, z.core.$strict>], "type">>;
|
|
151
|
+
}, z.core.$strict>;
|
|
152
|
+
export type CreateMcpServerRequest = z.infer<typeof createMcpServerSchema>;
|
|
153
|
+
export declare const updateMcpServerSchema: z.ZodObject<{
|
|
154
|
+
url: z.ZodOptional<z.ZodString>;
|
|
155
|
+
transport: z.ZodOptional<z.ZodEnum<{
|
|
156
|
+
http: "http";
|
|
157
|
+
sse: "sse";
|
|
158
|
+
}>>;
|
|
159
|
+
description: z.ZodOptional<z.ZodString>;
|
|
160
|
+
auth: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
161
|
+
type: z.ZodLiteral<"none">;
|
|
162
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
163
|
+
type: z.ZodLiteral<"bearer">;
|
|
164
|
+
secret: z.ZodString;
|
|
165
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
166
|
+
type: z.ZodLiteral<"header">;
|
|
167
|
+
header: z.ZodString;
|
|
168
|
+
secret: z.ZodString;
|
|
169
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
170
|
+
type: z.ZodLiteral<"oauth">;
|
|
171
|
+
secret: z.ZodString;
|
|
172
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
173
|
+
type: z.ZodLiteral<"per_user">;
|
|
174
|
+
scheme: z.ZodEnum<{
|
|
175
|
+
session: "session";
|
|
176
|
+
api_key: "api_key";
|
|
177
|
+
oauth2: "oauth2";
|
|
178
|
+
}>;
|
|
179
|
+
}, z.core.$strict>], "type">>;
|
|
180
|
+
}, z.core.$strict>;
|
|
181
|
+
export type UpdateMcpServerRequest = z.infer<typeof updateMcpServerSchema>;
|
|
182
|
+
/**
|
|
183
|
+
* The workspace secret a server's auth refers to, if any.
|
|
184
|
+
*
|
|
185
|
+
* Null for `none`, and null for `per_user`: that credential is the end user's
|
|
186
|
+
* and is not in the workspace secret store at all, so there is no name to
|
|
187
|
+
* return. Callers resolving a per-user server read `mcp.connections` instead.
|
|
188
|
+
*/
|
|
189
|
+
export declare function secretForAuth(auth: McpAuth): string | null;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateMcpServerSchema = exports.createMcpServerSchema = exports.mcpNameSchema = exports.mcpServerSchema = exports.mcpUrlSchema = exports.mcpAuthSchema = exports.mcpConnectionSchemeSchema = exports.mcpTransportSchema = void 0;
|
|
4
|
+
exports.isPerUserAuth = isPerUserAuth;
|
|
5
|
+
exports.secretForAuth = secretForAuth;
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
/**
|
|
8
|
+
* MCP servers.
|
|
9
|
+
*
|
|
10
|
+
* A customer registers a server they run, and an agent version names it. The
|
|
11
|
+
* runtime connects, discovers its tools, and the agent can call them.
|
|
12
|
+
*
|
|
13
|
+
* Remote only. `stdio` would mean spawning a process inside our runtime from
|
|
14
|
+
* customer-supplied arguments, which is arbitrary code execution as us, so the
|
|
15
|
+
* transport is not in the enum rather than being rejected later.
|
|
16
|
+
*/
|
|
17
|
+
exports.mcpTransportSchema = zod_1.z.enum(["http", "sse"]);
|
|
18
|
+
/**
|
|
19
|
+
* How an end user's credential for a server was obtained.
|
|
20
|
+
*
|
|
21
|
+
* The scheme decides what connecting costs the user, and what expiry means:
|
|
22
|
+
*
|
|
23
|
+
* - `api_key` the value is supplied directly and does not expire.
|
|
24
|
+
* - `oauth2` the user is sent through the provider's consent screen. The
|
|
25
|
+
* access token expires; a refresh token, where the provider
|
|
26
|
+
* issues one, is stored so it can be replaced without asking
|
|
27
|
+
* the user again.
|
|
28
|
+
* - `session` the credential is a session identifier obtained by calling a
|
|
29
|
+
* tool on the server, and there is nothing to refresh it with.
|
|
30
|
+
* Expiry means sending the user through sign-in again, which is
|
|
31
|
+
* why it is not modelled as a short-lived `oauth2`.
|
|
32
|
+
*/
|
|
33
|
+
exports.mcpConnectionSchemeSchema = zod_1.z.enum(["api_key", "oauth2", "session"]);
|
|
34
|
+
/**
|
|
35
|
+
* How Nixet proves who it is to the server.
|
|
36
|
+
*
|
|
37
|
+
* `none` is for a server that is open or already restricted by network. The
|
|
38
|
+
* rest reference a stored secret by name rather than carrying a credential, so
|
|
39
|
+
* a configuration can be read, copied and versioned without the token.
|
|
40
|
+
*/
|
|
41
|
+
exports.mcpAuthSchema = zod_1.z.discriminatedUnion("type", [
|
|
42
|
+
zod_1.z.object({ type: zod_1.z.literal("none") }).strict(),
|
|
43
|
+
zod_1.z
|
|
44
|
+
.object({
|
|
45
|
+
type: zod_1.z.literal("bearer"),
|
|
46
|
+
/** Name of a stored secret. Sent as `Authorization: Bearer …`. */
|
|
47
|
+
secret: zod_1.z.string().min(1).max(64),
|
|
48
|
+
})
|
|
49
|
+
.strict(),
|
|
50
|
+
zod_1.z
|
|
51
|
+
.object({
|
|
52
|
+
type: zod_1.z.literal("header"),
|
|
53
|
+
/** For servers wanting their own header, e.g. `X-API-Key`. */
|
|
54
|
+
header: zod_1.z
|
|
55
|
+
.string()
|
|
56
|
+
.trim()
|
|
57
|
+
.min(1)
|
|
58
|
+
.max(64)
|
|
59
|
+
.regex(/^[A-Za-z0-9-]+$/, "A header name may contain letters, numbers and hyphens."),
|
|
60
|
+
secret: zod_1.z.string().min(1).max(64),
|
|
61
|
+
})
|
|
62
|
+
.strict(),
|
|
63
|
+
zod_1.z
|
|
64
|
+
.object({
|
|
65
|
+
type: zod_1.z.literal("oauth"),
|
|
66
|
+
/**
|
|
67
|
+
* An OAuth access token the customer obtained and stored as a secret.
|
|
68
|
+
*
|
|
69
|
+
* Nixet does not run the authorization flow: that would mean holding a
|
|
70
|
+
* client secret and a refresh token per server, which is a larger piece
|
|
71
|
+
* of work than connecting to one. A token that expires stops working and
|
|
72
|
+
* the customer replaces it.
|
|
73
|
+
*/
|
|
74
|
+
secret: zod_1.z.string().min(1).max(64),
|
|
75
|
+
})
|
|
76
|
+
.strict(),
|
|
77
|
+
zod_1.z
|
|
78
|
+
.object({
|
|
79
|
+
type: zod_1.z.literal("per_user"),
|
|
80
|
+
/**
|
|
81
|
+
* The credential belongs to the end user, not to the workspace.
|
|
82
|
+
*
|
|
83
|
+
* Every other variant names one stored secret, which makes a server
|
|
84
|
+
* registration reachable as exactly one identity. That is right for an
|
|
85
|
+
* integration the operator owns — their GitHub, their internal API — and
|
|
86
|
+
* wrong for a product where each end user links their own account. There
|
|
87
|
+
* the URL is identical for everyone and only the token differs, so a
|
|
88
|
+
* registration per user would force an agent version per user, and
|
|
89
|
+
* version history would stop describing behaviour and become a
|
|
90
|
+
* credential registry.
|
|
91
|
+
*
|
|
92
|
+
* So this variant names no secret. The server is registered once, and
|
|
93
|
+
* the credential is resolved per run from the user the run names.
|
|
94
|
+
*/
|
|
95
|
+
scheme: exports.mcpConnectionSchemeSchema,
|
|
96
|
+
})
|
|
97
|
+
.strict(),
|
|
98
|
+
]);
|
|
99
|
+
/**
|
|
100
|
+
* Whether a server's credential comes from the end user rather than the
|
|
101
|
+
* workspace. A per-user server cannot be reached by a run that names no user.
|
|
102
|
+
*/
|
|
103
|
+
function isPerUserAuth(auth) {
|
|
104
|
+
return auth.type === "per_user";
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A URL Nixet will connect to.
|
|
108
|
+
*
|
|
109
|
+
* Only the shape is checked here. Whether the host is reachable, and whether it
|
|
110
|
+
* is somewhere we are willing to go, is decided at connect time against the
|
|
111
|
+
* resolved address — a name that passes here can still resolve to a private
|
|
112
|
+
* one, and the check that matters has to happen after resolution.
|
|
113
|
+
*/
|
|
114
|
+
exports.mcpUrlSchema = zod_1.z
|
|
115
|
+
.string()
|
|
116
|
+
.url()
|
|
117
|
+
.max(500)
|
|
118
|
+
.refine((value) => value.startsWith("https://") || value.startsWith("http://"), {
|
|
119
|
+
message: "Only http and https URLs are supported.",
|
|
120
|
+
});
|
|
121
|
+
/**
|
|
122
|
+
* Tools are their own resource.
|
|
123
|
+
*
|
|
124
|
+
* A server can expose a hundred, each carrying its own tags and its own policy,
|
|
125
|
+
* so they are rows rather than a field on this one. See `domains/tools`.
|
|
126
|
+
*/
|
|
127
|
+
exports.mcpServerSchema = zod_1.z.object({
|
|
128
|
+
id: zod_1.z.string().describe("Unique identifier, prefixed `mcp_`."),
|
|
129
|
+
name: zod_1.z
|
|
130
|
+
.string()
|
|
131
|
+
.describe("Stable handle a version pins, e.g. `github`. Lowercase and hyphenated."),
|
|
132
|
+
description: zod_1.z.string().nullable(),
|
|
133
|
+
transport: exports.mcpTransportSchema,
|
|
134
|
+
url: zod_1.z.string(),
|
|
135
|
+
auth: exports.mcpAuthSchema,
|
|
136
|
+
/**
|
|
137
|
+
* How many tools this server offered when it was last reached.
|
|
138
|
+
*
|
|
139
|
+
* The tools themselves are listed separately, because a server can have more
|
|
140
|
+
* of them than belongs in a response about the server.
|
|
141
|
+
*/
|
|
142
|
+
tool_count: zod_1.z.number(),
|
|
143
|
+
tools_refreshed_at: zod_1.z.string().nullable(),
|
|
144
|
+
/** Why the last connection failed, when it did. */
|
|
145
|
+
last_error: zod_1.z.string().nullable(),
|
|
146
|
+
created_at: zod_1.z.string(),
|
|
147
|
+
updated_at: zod_1.z.string(),
|
|
148
|
+
});
|
|
149
|
+
exports.mcpNameSchema = zod_1.z
|
|
150
|
+
.string()
|
|
151
|
+
.trim()
|
|
152
|
+
.min(1)
|
|
153
|
+
.max(64)
|
|
154
|
+
.regex(/^[a-z0-9]+(-[a-z0-9]+)*$/, "Use lowercase letters, numbers and hyphens, e.g. `github`.");
|
|
155
|
+
exports.createMcpServerSchema = zod_1.z
|
|
156
|
+
.object({
|
|
157
|
+
name: exports.mcpNameSchema,
|
|
158
|
+
url: exports.mcpUrlSchema,
|
|
159
|
+
transport: exports.mcpTransportSchema.default("http"),
|
|
160
|
+
description: zod_1.z.string().trim().max(200).optional(),
|
|
161
|
+
auth: exports.mcpAuthSchema.default({ type: "none" }),
|
|
162
|
+
})
|
|
163
|
+
.strict();
|
|
164
|
+
exports.updateMcpServerSchema = zod_1.z
|
|
165
|
+
.object({
|
|
166
|
+
url: exports.mcpUrlSchema.optional(),
|
|
167
|
+
transport: exports.mcpTransportSchema.optional(),
|
|
168
|
+
description: zod_1.z.string().trim().max(200).optional(),
|
|
169
|
+
auth: exports.mcpAuthSchema.optional(),
|
|
170
|
+
})
|
|
171
|
+
.strict();
|
|
172
|
+
/**
|
|
173
|
+
* The workspace secret a server's auth refers to, if any.
|
|
174
|
+
*
|
|
175
|
+
* Null for `none`, and null for `per_user`: that credential is the end user's
|
|
176
|
+
* and is not in the workspace secret store at all, so there is no name to
|
|
177
|
+
* return. Callers resolving a per-user server read `mcp.connections` instead.
|
|
178
|
+
*/
|
|
179
|
+
function secretForAuth(auth) {
|
|
180
|
+
if (auth.type === "none" || auth.type === "per_user")
|
|
181
|
+
return null;
|
|
182
|
+
return auth.secret;
|
|
183
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Memory.
|
|
4
|
+
*
|
|
5
|
+
* What an agent retains about a person or a thread, as opposed to the
|
|
6
|
+
* transcript, which is the literal record of what was said.
|
|
7
|
+
*/
|
|
8
|
+
export declare const MAX_MEMORY_LENGTH = 4000;
|
|
9
|
+
/**
|
|
10
|
+
* Who a memory belongs to.
|
|
11
|
+
*
|
|
12
|
+
* `conversation` is this thread only, `user` follows a person across every
|
|
13
|
+
* thread they have with an agent, and `agent` is shared by all of its users.
|
|
14
|
+
*/
|
|
15
|
+
export declare const memoryScopeSchema: z.ZodEnum<{
|
|
16
|
+
conversation: "conversation";
|
|
17
|
+
user: "user";
|
|
18
|
+
agent: "agent";
|
|
19
|
+
}>;
|
|
20
|
+
export type MemoryScope = z.infer<typeof memoryScopeSchema>;
|
|
21
|
+
export declare const memorySchema: z.ZodObject<{
|
|
22
|
+
id: z.ZodString;
|
|
23
|
+
scope: z.ZodEnum<{
|
|
24
|
+
conversation: "conversation";
|
|
25
|
+
user: "user";
|
|
26
|
+
agent: "agent";
|
|
27
|
+
}>;
|
|
28
|
+
content: z.ZodString;
|
|
29
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
30
|
+
superseded: z.ZodBoolean;
|
|
31
|
+
superseded_by: z.ZodNullable<z.ZodString>;
|
|
32
|
+
expires_at: z.ZodNullable<z.ZodString>;
|
|
33
|
+
created_at: z.ZodNullable<z.ZodString>;
|
|
34
|
+
updated_at: z.ZodNullable<z.ZodString>;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
export type Memory = z.infer<typeof memorySchema>;
|
|
37
|
+
/** A search hit, with how closely it matched. */
|
|
38
|
+
export declare const memoryMatchSchema: z.ZodObject<{
|
|
39
|
+
id: z.ZodString;
|
|
40
|
+
scope: z.ZodEnum<{
|
|
41
|
+
conversation: "conversation";
|
|
42
|
+
user: "user";
|
|
43
|
+
agent: "agent";
|
|
44
|
+
}>;
|
|
45
|
+
content: z.ZodString;
|
|
46
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
47
|
+
superseded: z.ZodBoolean;
|
|
48
|
+
superseded_by: z.ZodNullable<z.ZodString>;
|
|
49
|
+
expires_at: z.ZodNullable<z.ZodString>;
|
|
50
|
+
created_at: z.ZodNullable<z.ZodString>;
|
|
51
|
+
updated_at: z.ZodNullable<z.ZodString>;
|
|
52
|
+
score: z.ZodNullable<z.ZodNumber>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
export type MemoryMatch = z.infer<typeof memoryMatchSchema>;
|
|
55
|
+
export declare const createMemorySchema: z.ZodObject<{
|
|
56
|
+
scope: z.ZodEnum<{
|
|
57
|
+
conversation: "conversation";
|
|
58
|
+
user: "user";
|
|
59
|
+
agent: "agent";
|
|
60
|
+
}>;
|
|
61
|
+
content: z.ZodString;
|
|
62
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
63
|
+
expires_at: z.ZodOptional<z.ZodString>;
|
|
64
|
+
agent_id: z.ZodString;
|
|
65
|
+
user_id: z.ZodOptional<z.ZodString>;
|
|
66
|
+
conversation_id: z.ZodOptional<z.ZodString>;
|
|
67
|
+
}, z.core.$strict>;
|
|
68
|
+
export type CreateMemoryRequest = z.infer<typeof createMemorySchema>;
|
|
69
|
+
export declare const searchMemorySchema: z.ZodObject<{
|
|
70
|
+
query: z.ZodString;
|
|
71
|
+
scope: z.ZodOptional<z.ZodEnum<{
|
|
72
|
+
conversation: "conversation";
|
|
73
|
+
user: "user";
|
|
74
|
+
agent: "agent";
|
|
75
|
+
}>>;
|
|
76
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
77
|
+
agent_id: z.ZodString;
|
|
78
|
+
user_id: z.ZodOptional<z.ZodString>;
|
|
79
|
+
conversation_id: z.ZodOptional<z.ZodString>;
|
|
80
|
+
}, z.core.$strict>;
|
|
81
|
+
export type SearchMemoryRequest = z.infer<typeof searchMemorySchema>;
|
|
82
|
+
export declare const listMemorySchema: z.ZodObject<{
|
|
83
|
+
scope: z.ZodOptional<z.ZodEnum<{
|
|
84
|
+
conversation: "conversation";
|
|
85
|
+
user: "user";
|
|
86
|
+
agent: "agent";
|
|
87
|
+
}>>;
|
|
88
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
89
|
+
agent_id: z.ZodString;
|
|
90
|
+
user_id: z.ZodOptional<z.ZodString>;
|
|
91
|
+
conversation_id: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$strict>;
|
|
93
|
+
export type ListMemoryRequest = z.infer<typeof listMemorySchema>;
|
|
94
|
+
/** Addressing one memory. The scope is what proves it is ours to touch. */
|
|
95
|
+
export declare const memoryTargetSchema: z.ZodObject<{
|
|
96
|
+
agent_id: z.ZodString;
|
|
97
|
+
user_id: z.ZodOptional<z.ZodString>;
|
|
98
|
+
conversation_id: z.ZodOptional<z.ZodString>;
|
|
99
|
+
}, z.core.$strict>;
|
|
100
|
+
export type MemoryTargetRequest = z.infer<typeof memoryTargetSchema>;
|
|
101
|
+
export declare const updateMemorySchema: z.ZodObject<{
|
|
102
|
+
content: z.ZodOptional<z.ZodString>;
|
|
103
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
104
|
+
expires_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
105
|
+
agent_id: z.ZodString;
|
|
106
|
+
user_id: z.ZodOptional<z.ZodString>;
|
|
107
|
+
conversation_id: z.ZodOptional<z.ZodString>;
|
|
108
|
+
}, z.core.$strict>;
|
|
109
|
+
export type UpdateMemoryRequest = z.infer<typeof updateMemorySchema>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateMemorySchema = exports.memoryTargetSchema = exports.listMemorySchema = exports.searchMemorySchema = exports.createMemorySchema = exports.memoryMatchSchema = exports.memorySchema = exports.memoryScopeSchema = exports.MAX_MEMORY_LENGTH = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* Memory.
|
|
7
|
+
*
|
|
8
|
+
* What an agent retains about a person or a thread, as opposed to the
|
|
9
|
+
* transcript, which is the literal record of what was said.
|
|
10
|
+
*/
|
|
11
|
+
exports.MAX_MEMORY_LENGTH = 4_000;
|
|
12
|
+
/**
|
|
13
|
+
* Who a memory belongs to.
|
|
14
|
+
*
|
|
15
|
+
* `conversation` is this thread only, `user` follows a person across every
|
|
16
|
+
* thread they have with an agent, and `agent` is shared by all of its users.
|
|
17
|
+
*/
|
|
18
|
+
exports.memoryScopeSchema = zod_1.z.enum(["conversation", "user", "agent"]);
|
|
19
|
+
exports.memorySchema = zod_1.z.object({
|
|
20
|
+
id: zod_1.z.string(),
|
|
21
|
+
scope: exports.memoryScopeSchema,
|
|
22
|
+
content: zod_1.z.string().describe("The fact, as the agent would recall it."),
|
|
23
|
+
metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
|
|
24
|
+
/**
|
|
25
|
+
* Set when a later fact replaced this one. The store adds rather than
|
|
26
|
+
* updates, so both survive and the older is marked instead of removed.
|
|
27
|
+
*/
|
|
28
|
+
superseded: zod_1.z.boolean(),
|
|
29
|
+
superseded_by: zod_1.z.string().nullable(),
|
|
30
|
+
/** Set when a memory should stop being recalled after a date. */
|
|
31
|
+
expires_at: zod_1.z.string().nullable(),
|
|
32
|
+
created_at: zod_1.z.string().nullable(),
|
|
33
|
+
updated_at: zod_1.z.string().nullable(),
|
|
34
|
+
});
|
|
35
|
+
/** A search hit, with how closely it matched. */
|
|
36
|
+
exports.memoryMatchSchema = exports.memorySchema.extend({
|
|
37
|
+
score: zod_1.z.number().nullable().describe("Similarity, 0 to 1. Higher is closer."),
|
|
38
|
+
});
|
|
39
|
+
/** Where a request may address memory. Every read and write names one. */
|
|
40
|
+
const target = {
|
|
41
|
+
agent_id: zod_1.z.string().min(1),
|
|
42
|
+
user_id: zod_1.z.string().min(1).optional(),
|
|
43
|
+
conversation_id: zod_1.z.string().min(1).optional(),
|
|
44
|
+
};
|
|
45
|
+
function scopedToItsSubject(schema) {
|
|
46
|
+
return schema
|
|
47
|
+
.refine((value) => value.scope !== "user" || Boolean(value.user_id), {
|
|
48
|
+
message: "user_id is required for user-scoped memory.",
|
|
49
|
+
path: ["user_id"],
|
|
50
|
+
})
|
|
51
|
+
.refine((value) => value.scope !== "conversation" || Boolean(value.conversation_id), {
|
|
52
|
+
message: "conversation_id is required for conversation-scoped memory.",
|
|
53
|
+
path: ["conversation_id"],
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
exports.createMemorySchema = scopedToItsSubject(zod_1.z
|
|
57
|
+
.object({
|
|
58
|
+
...target,
|
|
59
|
+
scope: exports.memoryScopeSchema,
|
|
60
|
+
content: zod_1.z.string().trim().min(1).max(exports.MAX_MEMORY_LENGTH),
|
|
61
|
+
metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
62
|
+
expires_at: zod_1.z.string().datetime().optional(),
|
|
63
|
+
})
|
|
64
|
+
.strict());
|
|
65
|
+
exports.searchMemorySchema = scopedToItsSubject(zod_1.z
|
|
66
|
+
.object({
|
|
67
|
+
...target,
|
|
68
|
+
query: zod_1.z.string().trim().min(1).max(1_000),
|
|
69
|
+
scope: exports.memoryScopeSchema.optional(),
|
|
70
|
+
limit: zod_1.z.number().int().min(1).max(50).default(10),
|
|
71
|
+
})
|
|
72
|
+
.strict());
|
|
73
|
+
exports.listMemorySchema = scopedToItsSubject(zod_1.z
|
|
74
|
+
.object({
|
|
75
|
+
...target,
|
|
76
|
+
scope: exports.memoryScopeSchema.optional(),
|
|
77
|
+
limit: zod_1.z.number().int().min(1).max(100).default(50),
|
|
78
|
+
})
|
|
79
|
+
.strict());
|
|
80
|
+
/** Addressing one memory. The scope is what proves it is ours to touch. */
|
|
81
|
+
exports.memoryTargetSchema = zod_1.z.object(target).strict();
|
|
82
|
+
exports.updateMemorySchema = zod_1.z
|
|
83
|
+
.object({
|
|
84
|
+
...target,
|
|
85
|
+
content: zod_1.z.string().trim().min(1).max(exports.MAX_MEMORY_LENGTH).optional(),
|
|
86
|
+
metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
87
|
+
expires_at: zod_1.z.string().datetime().nullable().optional(),
|
|
88
|
+
})
|
|
89
|
+
.strict()
|
|
90
|
+
.refine((value) => value.content !== undefined ||
|
|
91
|
+
value.metadata !== undefined ||
|
|
92
|
+
value.expires_at !== undefined, { message: "Nothing to update." });
|