@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.
Files changed (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -2
  3. package/dist/cjs/domains/agents.d.ts +284 -0
  4. package/dist/cjs/domains/agents.js +244 -0
  5. package/dist/cjs/domains/api-keys.d.ts +265 -0
  6. package/dist/cjs/domains/api-keys.js +87 -0
  7. package/dist/cjs/domains/billing.d.ts +98 -0
  8. package/dist/cjs/domains/billing.js +122 -0
  9. package/dist/cjs/domains/connections.d.ts +101 -0
  10. package/dist/cjs/domains/connections.js +130 -0
  11. package/dist/cjs/domains/conversations.d.ts +113 -0
  12. package/dist/cjs/domains/conversations.js +85 -0
  13. package/dist/cjs/domains/documents.d.ts +48 -0
  14. package/dist/cjs/domains/documents.js +64 -0
  15. package/dist/cjs/domains/guardrails.d.ts +211 -0
  16. package/dist/cjs/domains/guardrails.js +206 -0
  17. package/dist/cjs/domains/identity.d.ts +55 -0
  18. package/dist/cjs/domains/identity.js +26 -0
  19. package/dist/cjs/domains/knowledge.d.ts +167 -0
  20. package/dist/cjs/domains/knowledge.js +174 -0
  21. package/dist/cjs/domains/mcp.d.ts +189 -0
  22. package/dist/cjs/domains/mcp.js +183 -0
  23. package/dist/cjs/domains/memory.d.ts +109 -0
  24. package/dist/cjs/domains/memory.js +92 -0
  25. package/dist/cjs/domains/redaction.d.ts +181 -0
  26. package/dist/cjs/domains/redaction.js +166 -0
  27. package/dist/cjs/domains/runs.d.ts +260 -0
  28. package/dist/cjs/domains/runs.js +260 -0
  29. package/dist/cjs/domains/secrets.d.ts +56 -0
  30. package/dist/cjs/domains/secrets.js +72 -0
  31. package/dist/cjs/domains/skills.d.ts +70 -0
  32. package/dist/cjs/domains/skills.js +82 -0
  33. package/dist/cjs/domains/tasks.d.ts +111 -0
  34. package/dist/cjs/domains/tasks.js +113 -0
  35. package/dist/cjs/domains/tools.d.ts +159 -0
  36. package/dist/cjs/domains/tools.js +203 -0
  37. package/dist/cjs/domains/users.d.ts +40 -0
  38. package/dist/cjs/domains/users.js +48 -0
  39. package/dist/cjs/index.d.ts +25 -0
  40. package/dist/cjs/index.js +41 -0
  41. package/dist/cjs/primitives.d.ts +75 -0
  42. package/dist/cjs/primitives.js +117 -0
  43. package/dist/esm/domains/agents.js +239 -0
  44. package/dist/esm/domains/api-keys.js +83 -0
  45. package/dist/esm/domains/billing.js +116 -0
  46. package/dist/esm/domains/connections.js +127 -0
  47. package/dist/esm/domains/conversations.js +82 -0
  48. package/dist/esm/domains/documents.js +61 -0
  49. package/dist/esm/domains/guardrails.js +202 -0
  50. package/dist/esm/domains/identity.js +23 -0
  51. package/dist/esm/domains/knowledge.js +170 -0
  52. package/dist/esm/domains/mcp.js +178 -0
  53. package/dist/esm/domains/memory.js +89 -0
  54. package/dist/esm/domains/redaction.js +162 -0
  55. package/dist/esm/domains/runs.js +256 -0
  56. package/dist/esm/domains/secrets.js +68 -0
  57. package/dist/esm/domains/skills.js +79 -0
  58. package/dist/esm/domains/tasks.js +109 -0
  59. package/dist/esm/domains/tools.js +196 -0
  60. package/dist/esm/domains/users.js +45 -0
  61. package/dist/esm/index.js +25 -0
  62. package/dist/esm/package.json +1 -0
  63. package/dist/esm/primitives.js +114 -0
  64. package/package.json +38 -4
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listTasksSchema = exports.createTaskSchema = exports.taskSchema = exports.DEFAULT_MAX_ATTEMPTS = exports.MAX_TASK_INPUT = exports.TERMINAL_TASK_STATES = exports.UNREACHABLE_TASK_STATES = exports.taskStatusSchema = void 0;
4
+ exports.backoffMs = backoffMs;
5
+ const zod_1 = require("zod");
6
+ const conversations_js_1 = require("./conversations.js");
7
+ const agents_js_1 = require("./agents.js");
8
+ /**
9
+ * Tasks.
10
+ *
11
+ * A run is one HTTP request: the caller waits, and the work has to finish
12
+ * inside that request. A task is work that outlives the request — research,
13
+ * a long report, anything that would otherwise time out.
14
+ *
15
+ * A task owns the lifecycle; a run owns the execution. The worker starts a run
16
+ * and records its id, so a task's trace, cost and redaction are the run's and
17
+ * nothing is duplicated.
18
+ */
19
+ /**
20
+ * Every state a task can report.
21
+ *
22
+ * Five are reachable today. `waiting_for_tool`, `waiting_for_approval`,
23
+ * `waiting_for_user` and `paused` are declared because the platform will
24
+ * produce them once tools, policies and a resume mechanism exist — widening a
25
+ * published enum later would break an exhaustive switch a customer already
26
+ * wrote. Until then nothing sets them, and the documentation says so.
27
+ */
28
+ exports.taskStatusSchema = zod_1.z.enum([
29
+ "queued",
30
+ "running",
31
+ "waiting_for_tool",
32
+ "waiting_for_approval",
33
+ "waiting_for_user",
34
+ "paused",
35
+ "completed",
36
+ "failed",
37
+ "cancelled",
38
+ ]);
39
+ /** States nothing currently produces. Exported so the docs cannot drift. */
40
+ exports.UNREACHABLE_TASK_STATES = [
41
+ "waiting_for_tool",
42
+ "waiting_for_approval",
43
+ "waiting_for_user",
44
+ "paused",
45
+ ];
46
+ /** A task that has stopped for good, whatever the outcome. */
47
+ exports.TERMINAL_TASK_STATES = [
48
+ "completed",
49
+ "failed",
50
+ "cancelled",
51
+ ];
52
+ exports.MAX_TASK_INPUT = 32_000;
53
+ exports.DEFAULT_MAX_ATTEMPTS = 3;
54
+ exports.taskSchema = zod_1.z.object({
55
+ id: zod_1.z.string().describe("Unique identifier, prefixed `tsk_`."),
56
+ agent_id: zod_1.z.string(),
57
+ agent_version: zod_1.z
58
+ .string()
59
+ .describe("Pinned when the task is queued, not when it runs."),
60
+ version_digest: zod_1.z
61
+ .string()
62
+ .describe("Content hash of the configuration that will produce this task."),
63
+ status: exports.taskStatusSchema,
64
+ input: zod_1.z.string(),
65
+ output: zod_1.z
66
+ .string()
67
+ .nullable()
68
+ .describe("Final text, present once the task completes."),
69
+ error: zod_1.z
70
+ .string()
71
+ .nullable()
72
+ .describe("Safe failure reason. Never a stack trace or provider payload."),
73
+ /** Where the trace, events and cost live. Null until a worker starts it. */
74
+ run_id: zod_1.z.string().nullable(),
75
+ conversation_id: zod_1.z.string().nullable(),
76
+ user_id: zod_1.z.string().nullable(),
77
+ attempt: zod_1.z.number().int().nonnegative().describe("Attempts started so far."),
78
+ max_attempts: zod_1.z.number().int().positive(),
79
+ /** Set when a failed task is waiting out its backoff before the next attempt. */
80
+ run_after: zod_1.z.string().nullable(),
81
+ created_at: zod_1.z.string(),
82
+ updated_at: zod_1.z.string(),
83
+ completed_at: zod_1.z.string().nullable(),
84
+ });
85
+ exports.createTaskSchema = zod_1.z
86
+ .object({
87
+ input: zod_1.z.string().trim().min(1).max(exports.MAX_TASK_INPUT),
88
+ /** Pins a version. Defaults to whatever is published when queued. */
89
+ agent_version: zod_1.z.string().min(1).optional(),
90
+ conversation_id: zod_1.z.string().min(1).optional(),
91
+ user_id: zod_1.z.string().min(1).optional(),
92
+ provider: agents_js_1.providerSchema.optional(),
93
+ memory: conversations_js_1.memoryPolicySchema.partial().optional(),
94
+ max_attempts: zod_1.z.number().int().min(1).max(10).default(exports.DEFAULT_MAX_ATTEMPTS),
95
+ })
96
+ .strict();
97
+ exports.listTasksSchema = zod_1.z
98
+ .object({
99
+ status: exports.taskStatusSchema.optional(),
100
+ agent_id: zod_1.z.string().min(1).optional(),
101
+ conversation_id: zod_1.z.string().min(1).optional(),
102
+ })
103
+ .strict();
104
+ /**
105
+ * How long to wait before attempt `n`.
106
+ *
107
+ * Exponential from ten seconds, capped at five minutes. A failure is usually a
108
+ * rate limit or a provider blip, so retrying immediately tends to fail the same
109
+ * way; waiting an hour is longer than anyone will tolerate.
110
+ */
111
+ function backoffMs(attempt) {
112
+ return Math.min(10_000 * 2 ** Math.max(0, attempt - 1), 300_000);
113
+ }
@@ -0,0 +1,159 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Tool access.
4
+ *
5
+ * A server can expose a hundred tools, and a customer rarely wants an agent to
6
+ * have all of them. This is how they say which.
7
+ *
8
+ * Two separate ideas live here, and conflating them is the mistake to avoid:
9
+ *
10
+ * A **tag** describes what a tool does. It comes from the server's own
11
+ * annotations where it published any, and from Nixet's reading of the name
12
+ * and description where it did not. Either way it is a claim, not a
13
+ * guarantee — the MCP specification is explicit that a server can annotate a
14
+ * tool `readOnlyHint: true` and delete your files anyway. A tag decides what
15
+ * a customer is shown and what the default policy is. It enforces nothing.
16
+ *
17
+ * A **policy** is what Nixet will actually do. It is decided by the customer,
18
+ * frozen into an agent version, and enforced before a tool is offered to the
19
+ * model. This is the part that holds.
20
+ */
21
+ /**
22
+ * What a tool does, as far as anyone can tell.
23
+ *
24
+ * Deliberately coarser than MCP's four booleans. `readOnlyHint` and
25
+ * `destructiveHint` and `idempotentHint` describe behaviour precisely and
26
+ * answer no question a person actually asks, which is "should this thing be
27
+ * allowed to run on its own".
28
+ */
29
+ export declare const toolTagSchema: z.ZodEnum<{
30
+ read: "read";
31
+ write: "write";
32
+ destructive: "destructive";
33
+ external: "external";
34
+ }>;
35
+ export type ToolTag = z.infer<typeof toolTagSchema>;
36
+ /** Where a tag came from, because the two deserve different trust. */
37
+ export declare const tagSourceSchema: z.ZodEnum<{
38
+ server: "server";
39
+ inferred: "inferred";
40
+ }>;
41
+ export type TagSource = z.infer<typeof tagSourceSchema>;
42
+ /**
43
+ * What Nixet does when the agent reaches for a tool.
44
+ *
45
+ * `ask` is declared and not yet enforceable: nothing can pause a run for a
46
+ * human until approvals exist. Until then it refuses, with a reason saying so,
47
+ * rather than quietly behaving as `allow` — a policy that silently does the
48
+ * opposite of what it says is worse than one that does not work.
49
+ */
50
+ export declare const toolPolicySchema: z.ZodEnum<{
51
+ allow: "allow";
52
+ ask: "ask";
53
+ deny: "deny";
54
+ }>;
55
+ export type ToolPolicy = z.infer<typeof toolPolicySchema>;
56
+ /**
57
+ * The policy a tag gets when the customer has not named one.
58
+ *
59
+ * A customer publishing against a hundred-tool server should get something
60
+ * sensible without enumerating all hundred, and the tools whose mistakes are
61
+ * expensive should not be the ones that slip through.
62
+ *
63
+ * `write` is `allow` in this release and becomes `ask` once approvals exist.
64
+ * Defaulting it to `ask` now would mean every write tool refusing on day one,
65
+ * since `ask` cannot yet pause for anyone. That is a behaviour change, and it
66
+ * is documented rather than sprung.
67
+ */
68
+ export declare const DEFAULT_TOOL_POLICY: Record<ToolTag, ToolPolicy>;
69
+ /** MCP's own annotations, as a server publishes them. */
70
+ export declare const mcpToolAnnotationsSchema: z.ZodObject<{
71
+ title: z.ZodOptional<z.ZodString>;
72
+ readOnlyHint: z.ZodOptional<z.ZodBoolean>;
73
+ destructiveHint: z.ZodOptional<z.ZodBoolean>;
74
+ idempotentHint: z.ZodOptional<z.ZodBoolean>;
75
+ openWorldHint: z.ZodOptional<z.ZodBoolean>;
76
+ }, z.core.$loose>;
77
+ export type McpToolAnnotations = z.infer<typeof mcpToolAnnotationsSchema>;
78
+ /** One tool, as discovered from a server. */
79
+ export declare const toolSchema: z.ZodObject<{
80
+ id: z.ZodString;
81
+ server_id: z.ZodString;
82
+ server_name: z.ZodString;
83
+ name: z.ZodString;
84
+ description: z.ZodNullable<z.ZodString>;
85
+ tags: z.ZodArray<z.ZodEnum<{
86
+ read: "read";
87
+ write: "write";
88
+ destructive: "destructive";
89
+ external: "external";
90
+ }>>;
91
+ tag_source: z.ZodEnum<{
92
+ server: "server";
93
+ inferred: "inferred";
94
+ }>;
95
+ annotations: z.ZodNullable<z.ZodObject<{
96
+ title: z.ZodOptional<z.ZodString>;
97
+ readOnlyHint: z.ZodOptional<z.ZodBoolean>;
98
+ destructiveHint: z.ZodOptional<z.ZodBoolean>;
99
+ idempotentHint: z.ZodOptional<z.ZodBoolean>;
100
+ openWorldHint: z.ZodOptional<z.ZodBoolean>;
101
+ }, z.core.$loose>>;
102
+ default_policy: z.ZodEnum<{
103
+ allow: "allow";
104
+ ask: "ask";
105
+ deny: "deny";
106
+ }>;
107
+ discovered_at: z.ZodString;
108
+ updated_at: z.ZodString;
109
+ }, z.core.$strip>;
110
+ export type Tool = z.infer<typeof toolSchema>;
111
+ /**
112
+ * A version's overrides, as `server.tool` to `policy`.
113
+ *
114
+ * Qualified by server because two servers can both offer `search`, and a policy
115
+ * that silently applied to both would be a way to grant access nobody asked
116
+ * for. `"github.delete_repo": "deny"`.
117
+ *
118
+ * Only the exceptions are stored. Everything unnamed takes its tag's default,
119
+ * so a version stays readable and does not need rewriting when a server adds a
120
+ * tool.
121
+ */
122
+ export declare const toolPoliciesSchema: z.ZodRecord<z.ZodString, z.ZodEnum<{
123
+ allow: "allow";
124
+ ask: "ask";
125
+ deny: "deny";
126
+ }>>;
127
+ export type ToolPolicies = z.infer<typeof toolPoliciesSchema>;
128
+ /** How a version addresses one tool. */
129
+ export declare const toolKey: (server: string, tool: string) => string;
130
+ /**
131
+ * What a version does about one tool.
132
+ *
133
+ * An explicit override wins; otherwise the tool's tags decide, and the
134
+ * strictest tag wins. A tool tagged both `read` and `destructive` is
135
+ * destructive — a thing that reads and deletes is a thing that deletes.
136
+ */
137
+ export declare function resolveToolPolicy(tool: {
138
+ name: string;
139
+ tags: readonly ToolTag[];
140
+ }, serverName: string, policies: ToolPolicies | undefined): ToolPolicy;
141
+ /**
142
+ * Tags for a tool, from the server's annotations where it published any.
143
+ *
144
+ * MCP's defaults are deliberately pessimistic: a tool that says nothing is
145
+ * assumed destructive. That default is right for a client deciding whether to
146
+ * prompt, and wrong here, because it would tag every unannotated tool on every
147
+ * unannotated server as destructive and make the tag meaningless. So absence is
148
+ * treated as absence: no annotations means we infer instead.
149
+ */
150
+ export declare function tagsFromAnnotations(annotations: McpToolAnnotations | null | undefined): ToolTag[] | null;
151
+ /**
152
+ * Nixet's reading of a tool, when the server said nothing.
153
+ *
154
+ * A guess, and labelled as one. `archive_record` and `sync_all` are exactly the
155
+ * cases this gets wrong, which is why an unrecognised verb is treated as a
156
+ * write rather than a read: unknown is closer to "changes something" than to
157
+ * "changes nothing".
158
+ */
159
+ export declare function inferTags(name: string, description?: string | null): ToolTag[];
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toolKey = exports.toolPoliciesSchema = exports.toolSchema = exports.mcpToolAnnotationsSchema = exports.DEFAULT_TOOL_POLICY = exports.toolPolicySchema = exports.tagSourceSchema = exports.toolTagSchema = void 0;
4
+ exports.resolveToolPolicy = resolveToolPolicy;
5
+ exports.tagsFromAnnotations = tagsFromAnnotations;
6
+ exports.inferTags = inferTags;
7
+ const zod_1 = require("zod");
8
+ /**
9
+ * Tool access.
10
+ *
11
+ * A server can expose a hundred tools, and a customer rarely wants an agent to
12
+ * have all of them. This is how they say which.
13
+ *
14
+ * Two separate ideas live here, and conflating them is the mistake to avoid:
15
+ *
16
+ * A **tag** describes what a tool does. It comes from the server's own
17
+ * annotations where it published any, and from Nixet's reading of the name
18
+ * and description where it did not. Either way it is a claim, not a
19
+ * guarantee — the MCP specification is explicit that a server can annotate a
20
+ * tool `readOnlyHint: true` and delete your files anyway. A tag decides what
21
+ * a customer is shown and what the default policy is. It enforces nothing.
22
+ *
23
+ * A **policy** is what Nixet will actually do. It is decided by the customer,
24
+ * frozen into an agent version, and enforced before a tool is offered to the
25
+ * model. This is the part that holds.
26
+ */
27
+ /**
28
+ * What a tool does, as far as anyone can tell.
29
+ *
30
+ * Deliberately coarser than MCP's four booleans. `readOnlyHint` and
31
+ * `destructiveHint` and `idempotentHint` describe behaviour precisely and
32
+ * answer no question a person actually asks, which is "should this thing be
33
+ * allowed to run on its own".
34
+ */
35
+ exports.toolTagSchema = zod_1.z.enum([
36
+ /** Reads. Changes nothing. */
37
+ "read",
38
+ /** Changes something, additively — creating, appending, updating. */
39
+ "write",
40
+ /** Removes or overwrites. The one whose mistakes are not undoable. */
41
+ "destructive",
42
+ /** Reaches something outside the server: the open web, a third party. */
43
+ "external",
44
+ ]);
45
+ /** Where a tag came from, because the two deserve different trust. */
46
+ exports.tagSourceSchema = zod_1.z.enum([
47
+ /** The server's own MCP annotations. Its claim about itself. */
48
+ "server",
49
+ /** Nixet's reading of the name and description. A guess. */
50
+ "inferred",
51
+ ]);
52
+ /**
53
+ * What Nixet does when the agent reaches for a tool.
54
+ *
55
+ * `ask` is declared and not yet enforceable: nothing can pause a run for a
56
+ * human until approvals exist. Until then it refuses, with a reason saying so,
57
+ * rather than quietly behaving as `allow` — a policy that silently does the
58
+ * opposite of what it says is worse than one that does not work.
59
+ */
60
+ exports.toolPolicySchema = zod_1.z.enum(["allow", "ask", "deny"]);
61
+ /**
62
+ * The policy a tag gets when the customer has not named one.
63
+ *
64
+ * A customer publishing against a hundred-tool server should get something
65
+ * sensible without enumerating all hundred, and the tools whose mistakes are
66
+ * expensive should not be the ones that slip through.
67
+ *
68
+ * `write` is `allow` in this release and becomes `ask` once approvals exist.
69
+ * Defaulting it to `ask` now would mean every write tool refusing on day one,
70
+ * since `ask` cannot yet pause for anyone. That is a behaviour change, and it
71
+ * is documented rather than sprung.
72
+ */
73
+ exports.DEFAULT_TOOL_POLICY = {
74
+ read: "allow",
75
+ write: "allow",
76
+ destructive: "ask",
77
+ external: "allow",
78
+ };
79
+ /** MCP's own annotations, as a server publishes them. */
80
+ exports.mcpToolAnnotationsSchema = zod_1.z
81
+ .object({
82
+ title: zod_1.z.string().optional(),
83
+ readOnlyHint: zod_1.z.boolean().optional(),
84
+ destructiveHint: zod_1.z.boolean().optional(),
85
+ idempotentHint: zod_1.z.boolean().optional(),
86
+ openWorldHint: zod_1.z.boolean().optional(),
87
+ })
88
+ .loose();
89
+ /** One tool, as discovered from a server. */
90
+ exports.toolSchema = zod_1.z.object({
91
+ id: zod_1.z.string().describe("Unique identifier, prefixed `tol_`."),
92
+ server_id: zod_1.z.string(),
93
+ server_name: zod_1.z.string().describe("The handle an agent version pins."),
94
+ name: zod_1.z.string().describe("The tool's own name, as the server reports it."),
95
+ description: zod_1.z.string().nullable(),
96
+ tags: zod_1.z.array(exports.toolTagSchema),
97
+ tag_source: exports.tagSourceSchema,
98
+ /** What the server claimed, kept so a reader can check our reading of it. */
99
+ annotations: exports.mcpToolAnnotationsSchema.nullable(),
100
+ /** What this tool gets when a version does not name it. */
101
+ default_policy: exports.toolPolicySchema,
102
+ discovered_at: zod_1.z.string(),
103
+ updated_at: zod_1.z.string(),
104
+ });
105
+ /**
106
+ * A version's overrides, as `server.tool` to `policy`.
107
+ *
108
+ * Qualified by server because two servers can both offer `search`, and a policy
109
+ * that silently applied to both would be a way to grant access nobody asked
110
+ * for. `"github.delete_repo": "deny"`.
111
+ *
112
+ * Only the exceptions are stored. Everything unnamed takes its tag's default,
113
+ * so a version stays readable and does not need rewriting when a server adds a
114
+ * tool.
115
+ */
116
+ exports.toolPoliciesSchema = zod_1.z
117
+ .record(zod_1.z
118
+ .string()
119
+ .regex(/^[a-z0-9-]+\.[A-Za-z0-9_-]+$/, "Name a tool as `server.tool`, e.g. `github.delete_repo`."), exports.toolPolicySchema)
120
+ .refine((policies) => Object.keys(policies).length <= 200, {
121
+ message: "A version may override at most 200 tools.",
122
+ });
123
+ /** How a version addresses one tool. */
124
+ const toolKey = (server, tool) => `${server}.${tool}`;
125
+ exports.toolKey = toolKey;
126
+ /**
127
+ * What a version does about one tool.
128
+ *
129
+ * An explicit override wins; otherwise the tool's tags decide, and the
130
+ * strictest tag wins. A tool tagged both `read` and `destructive` is
131
+ * destructive — a thing that reads and deletes is a thing that deletes.
132
+ */
133
+ function resolveToolPolicy(tool, serverName, policies) {
134
+ const override = policies?.[(0, exports.toolKey)(serverName, tool.name)];
135
+ if (override)
136
+ return override;
137
+ const order = ["allow", "ask", "deny"];
138
+ return tool.tags.reduce((strictest, tag) => {
139
+ const candidate = exports.DEFAULT_TOOL_POLICY[tag];
140
+ return order.indexOf(candidate) > order.indexOf(strictest) ? candidate : strictest;
141
+ }, "allow");
142
+ }
143
+ /**
144
+ * Tags for a tool, from the server's annotations where it published any.
145
+ *
146
+ * MCP's defaults are deliberately pessimistic: a tool that says nothing is
147
+ * assumed destructive. That default is right for a client deciding whether to
148
+ * prompt, and wrong here, because it would tag every unannotated tool on every
149
+ * unannotated server as destructive and make the tag meaningless. So absence is
150
+ * treated as absence: no annotations means we infer instead.
151
+ */
152
+ function tagsFromAnnotations(annotations) {
153
+ if (!annotations)
154
+ return null;
155
+ const stated = annotations.readOnlyHint !== undefined || annotations.destructiveHint !== undefined;
156
+ if (!stated)
157
+ return null;
158
+ const tags = [];
159
+ if (annotations.readOnlyHint)
160
+ tags.push("read");
161
+ else
162
+ tags.push(annotations.destructiveHint === false ? "write" : "destructive");
163
+ // A read-only tool that reaches the open web still leaves the building, which
164
+ // is worth showing even though it changes nothing.
165
+ if (annotations.openWorldHint)
166
+ tags.push("external");
167
+ return tags;
168
+ }
169
+ /**
170
+ * Verbs that give a tool away.
171
+ *
172
+ * Used only when a server published no annotations. Ordered destructive first,
173
+ * because the cost of the two mistakes is not symmetric: reading a destructive
174
+ * tool as safe is how something gets deleted, and reading a safe tool as
175
+ * destructive only means someone is asked a question they did not need.
176
+ */
177
+ const DESTRUCTIVE = /^(delete|remove|destroy|drop|purge|truncate|revoke|kill|terminate|uninstall|reset|overwrite|replace|clear|wipe|prune|archive|close|cancel|merge|force)/i;
178
+ const WRITE = /^(create|add|insert|update|edit|modify|set|put|post|patch|write|append|send|publish|upload|push|assign|invite|comment|apply|run|execute|trigger|start|schedule|move|rename|copy|sync|import|export)/i;
179
+ const READ = /^(get|list|read|fetch|find|search|query|show|view|describe|inspect|check|count|lookup|resolve|status|health|ping|has|is)/i;
180
+ const EXTERNAL = /\b(http|https|url|web|browse|crawl|scrape|download|fetch_url|request)\b/i;
181
+ /**
182
+ * Nixet's reading of a tool, when the server said nothing.
183
+ *
184
+ * A guess, and labelled as one. `archive_record` and `sync_all` are exactly the
185
+ * cases this gets wrong, which is why an unrecognised verb is treated as a
186
+ * write rather than a read: unknown is closer to "changes something" than to
187
+ * "changes nothing".
188
+ */
189
+ function inferTags(name, description) {
190
+ const subject = `${name} ${description ?? ""}`;
191
+ const tags = [];
192
+ if (DESTRUCTIVE.test(name))
193
+ tags.push("destructive");
194
+ else if (READ.test(name))
195
+ tags.push("read");
196
+ else if (WRITE.test(name))
197
+ tags.push("write");
198
+ else
199
+ tags.push("write");
200
+ if (EXTERNAL.test(subject))
201
+ tags.push("external");
202
+ return tags;
203
+ }
@@ -0,0 +1,40 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Users.
4
+ *
5
+ * The people a customer's agent serves, not the people who log into the Nixet
6
+ * console — those are members. A user belongs to one workspace and environment,
7
+ * so two customers can use the same reference for different people.
8
+ */
9
+ export declare const MAX_USER_REFERENCE = 128;
10
+ /**
11
+ * The customer's own identifier for this person.
12
+ *
13
+ * Opaque to Nixet and unique within a scope. Customers should keep personal
14
+ * data out of it; `email` and `name` exist for that, and can be erased without
15
+ * breaking the reference their systems rely on.
16
+ */
17
+ export declare const userReferenceSchema: z.ZodString;
18
+ export declare const userSchema: z.ZodObject<{
19
+ id: z.ZodString;
20
+ reference: z.ZodString;
21
+ email: z.ZodNullable<z.ZodString>;
22
+ name: z.ZodNullable<z.ZodString>;
23
+ metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
24
+ created_at: z.ZodString;
25
+ updated_at: z.ZodString;
26
+ }, z.core.$strip>;
27
+ export type User = z.infer<typeof userSchema>;
28
+ export declare const createUserSchema: z.ZodObject<{
29
+ reference: z.ZodString;
30
+ email: z.ZodOptional<z.ZodString>;
31
+ name: z.ZodOptional<z.ZodString>;
32
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
33
+ }, z.core.$strict>;
34
+ export type CreateUserRequest = z.infer<typeof createUserSchema>;
35
+ export declare const updateUserSchema: z.ZodObject<{
36
+ email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
37
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
38
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
39
+ }, z.core.$strict>;
40
+ export type UpdateUserRequest = z.infer<typeof updateUserSchema>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateUserSchema = exports.createUserSchema = exports.userSchema = exports.userReferenceSchema = exports.MAX_USER_REFERENCE = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * Users.
7
+ *
8
+ * The people a customer's agent serves, not the people who log into the Nixet
9
+ * console — those are members. A user belongs to one workspace and environment,
10
+ * so two customers can use the same reference for different people.
11
+ */
12
+ exports.MAX_USER_REFERENCE = 128;
13
+ /**
14
+ * The customer's own identifier for this person.
15
+ *
16
+ * Opaque to Nixet and unique within a scope. Customers should keep personal
17
+ * data out of it; `email` and `name` exist for that, and can be erased without
18
+ * breaking the reference their systems rely on.
19
+ */
20
+ exports.userReferenceSchema = zod_1.z
21
+ .string()
22
+ .trim()
23
+ .min(1)
24
+ .max(exports.MAX_USER_REFERENCE);
25
+ exports.userSchema = zod_1.z.object({
26
+ id: zod_1.z.string().describe("Unique identifier, prefixed `usr_`."),
27
+ reference: exports.userReferenceSchema.describe("Your identifier for this person."),
28
+ email: zod_1.z.string().nullable(),
29
+ name: zod_1.z.string().nullable(),
30
+ metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).describe("Your own fields."),
31
+ created_at: zod_1.z.string(),
32
+ updated_at: zod_1.z.string(),
33
+ });
34
+ exports.createUserSchema = zod_1.z
35
+ .object({
36
+ reference: exports.userReferenceSchema,
37
+ email: zod_1.z.string().trim().email().max(320).optional(),
38
+ name: zod_1.z.string().trim().min(1).max(200).optional(),
39
+ metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
40
+ })
41
+ .strict();
42
+ exports.updateUserSchema = zod_1.z
43
+ .object({
44
+ email: zod_1.z.string().trim().email().max(320).nullable().optional(),
45
+ name: zod_1.z.string().trim().min(1).max(200).nullable().optional(),
46
+ metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
47
+ })
48
+ .strict();
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Public Nixet wire contract.
3
+ *
4
+ * One definition shared by the API, the TypeScript client and the dashboard
5
+ * bindings, so a released shape cannot drift between them.
6
+ */
7
+ export * from "./primitives.js";
8
+ export * from "./domains/identity.js";
9
+ export * from "./domains/api-keys.js";
10
+ export * from "./domains/agents.js";
11
+ export * from "./domains/skills.js";
12
+ export * from "./domains/runs.js";
13
+ export * from "./domains/users.js";
14
+ export * from "./domains/conversations.js";
15
+ export * from "./domains/memory.js";
16
+ export * from "./domains/redaction.js";
17
+ export * from "./domains/mcp.js";
18
+ export * from "./domains/connections.js";
19
+ export * from "./domains/documents.js";
20
+ export * from "./domains/guardrails.js";
21
+ export * from "./domains/tools.js";
22
+ export * from "./domains/knowledge.js";
23
+ export * from "./domains/billing.js";
24
+ export * from "./domains/secrets.js";
25
+ export * from "./domains/tasks.js";
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ /**
18
+ * Public Nixet wire contract.
19
+ *
20
+ * One definition shared by the API, the TypeScript client and the dashboard
21
+ * bindings, so a released shape cannot drift between them.
22
+ */
23
+ __exportStar(require("./primitives.js"), exports);
24
+ __exportStar(require("./domains/identity.js"), exports);
25
+ __exportStar(require("./domains/api-keys.js"), exports);
26
+ __exportStar(require("./domains/agents.js"), exports);
27
+ __exportStar(require("./domains/skills.js"), exports);
28
+ __exportStar(require("./domains/runs.js"), exports);
29
+ __exportStar(require("./domains/users.js"), exports);
30
+ __exportStar(require("./domains/conversations.js"), exports);
31
+ __exportStar(require("./domains/memory.js"), exports);
32
+ __exportStar(require("./domains/redaction.js"), exports);
33
+ __exportStar(require("./domains/mcp.js"), exports);
34
+ __exportStar(require("./domains/connections.js"), exports);
35
+ __exportStar(require("./domains/documents.js"), exports);
36
+ __exportStar(require("./domains/guardrails.js"), exports);
37
+ __exportStar(require("./domains/tools.js"), exports);
38
+ __exportStar(require("./domains/knowledge.js"), exports);
39
+ __exportStar(require("./domains/billing.js"), exports);
40
+ __exportStar(require("./domains/secrets.js"), exports);
41
+ __exportStar(require("./domains/tasks.js"), exports);