@usenaive-sdk/server 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/dist/index.cjs +244 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +250 -0
- package/dist/index.d.ts +250 -0
- package/dist/index.js +216 -0
- package/dist/index.js.map +1 -0
- package/package.json +38 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
AgentProfile: () => AgentProfile,
|
|
25
|
+
DeploymentsClient: () => DeploymentsClient,
|
|
26
|
+
Naive: () => Naive,
|
|
27
|
+
RuntimeHandle: () => RuntimeHandle
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(index_exports);
|
|
30
|
+
__reExport(index_exports, require("@usenaive-sdk/node"), module.exports);
|
|
31
|
+
|
|
32
|
+
// src/naive.ts
|
|
33
|
+
var import_node2 = require("@usenaive-sdk/node");
|
|
34
|
+
|
|
35
|
+
// src/agent-profile.ts
|
|
36
|
+
var AgentProfile = class {
|
|
37
|
+
constructor(http, data, toolsFactory) {
|
|
38
|
+
this.http = http;
|
|
39
|
+
this.toolsFactory = toolsFactory;
|
|
40
|
+
this.id = data.id;
|
|
41
|
+
this.userId = data.user_id;
|
|
42
|
+
this.template = data.template;
|
|
43
|
+
this.status = data.status;
|
|
44
|
+
this.needsAction = data.needs_action ?? null;
|
|
45
|
+
this.steps = data.steps ?? [];
|
|
46
|
+
this.toolPolicy = data.tool_policy;
|
|
47
|
+
this.key = data.key;
|
|
48
|
+
this.resources = data.resources ?? {};
|
|
49
|
+
}
|
|
50
|
+
/** True once identity/KYB/comms provisioning has fully completed. */
|
|
51
|
+
get isActive() {
|
|
52
|
+
return this.status === "active";
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The agent profile's governed toolset (Anthropic tool defs + `handle()`), ready to
|
|
56
|
+
* drop into your own agent loop / Eve / LangGraph. Every call routes through
|
|
57
|
+
* the Naïve governance gateway (caps, approvals, audit, revoke).
|
|
58
|
+
*/
|
|
59
|
+
async tools() {
|
|
60
|
+
return this.toolsFactory();
|
|
61
|
+
}
|
|
62
|
+
/** Re-fetch the agent profile's current status (provisioning is async). */
|
|
63
|
+
async refresh() {
|
|
64
|
+
const data = await this.http.get(`/v1/agent-profiles/${this.id}`);
|
|
65
|
+
this.status = data.status;
|
|
66
|
+
this.needsAction = data.needs_action ?? null;
|
|
67
|
+
this.steps = data.steps ?? [];
|
|
68
|
+
this.toolPolicy = data.tool_policy;
|
|
69
|
+
this.resources = data.resources ?? {};
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Absolute revoke: freeze the card, halt sends, rotate credentials, and tear
|
|
74
|
+
* down any runtime — mid-action. Revoking a parent kills the whole system.
|
|
75
|
+
*/
|
|
76
|
+
async revoke() {
|
|
77
|
+
const res = await this.http.post(
|
|
78
|
+
`/v1/agent-profiles/${this.id}/revoke`
|
|
79
|
+
);
|
|
80
|
+
this.status = res.status ?? "revoked";
|
|
81
|
+
return res;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// src/runtime.ts
|
|
86
|
+
var RuntimeHandle = class {
|
|
87
|
+
constructor(http, pool) {
|
|
88
|
+
this.http = http;
|
|
89
|
+
this.pool = pool;
|
|
90
|
+
}
|
|
91
|
+
/** Boot a single agent in the pool for an agentProfile. */
|
|
92
|
+
start(agentProfileId, opts = {}) {
|
|
93
|
+
return this.http.post(`/v1/runtime/${this.pool}/start`, {
|
|
94
|
+
agent_profile_id: agentProfileId,
|
|
95
|
+
goal: opts.goal,
|
|
96
|
+
input: opts.input
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Boot a multi-agent system: a parent agent profile (shared budget) plus sub-agents
|
|
101
|
+
* in their own isolated microVMs. The gateway aggregates spend against the
|
|
102
|
+
* parent cap; `revoke(parent)` kills the whole system.
|
|
103
|
+
*/
|
|
104
|
+
startSystem(opts) {
|
|
105
|
+
return this.http.post(`/v1/runtime/${this.pool}/start-system`, {
|
|
106
|
+
system: opts.system,
|
|
107
|
+
root: opts.root,
|
|
108
|
+
members: opts.members,
|
|
109
|
+
topology: opts.topology,
|
|
110
|
+
goal: opts.goal
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// src/deployments.ts
|
|
116
|
+
var DeploymentsClient = class {
|
|
117
|
+
constructor(http) {
|
|
118
|
+
this.http = http;
|
|
119
|
+
}
|
|
120
|
+
/** Preview the plan (diff) for a project's config without applying. */
|
|
121
|
+
plan(project, config) {
|
|
122
|
+
return this.http.put(`/v1/deployments/${encodeURIComponent(project)}`, config);
|
|
123
|
+
}
|
|
124
|
+
/** Apply: provision infrastructure + register pools/systems/agent profiles. */
|
|
125
|
+
apply(project, config) {
|
|
126
|
+
return this.http.post(
|
|
127
|
+
`/v1/deployments/${encodeURIComponent(project)}/apply`,
|
|
128
|
+
config
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
/** Read a project's deployment, its resources, and resolved outputs. */
|
|
132
|
+
get(project) {
|
|
133
|
+
return this.http.get(`/v1/deployments/${encodeURIComponent(project)}`);
|
|
134
|
+
}
|
|
135
|
+
/** Tear down a project's provisioned infrastructure. */
|
|
136
|
+
down(project) {
|
|
137
|
+
return this.http.delete(`/v1/deployments/${encodeURIComponent(project)}`);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// src/transport.ts
|
|
142
|
+
var import_node = require("@usenaive-sdk/node");
|
|
143
|
+
var DEFAULT_BASE_URL = "https://api.usenaive.ai";
|
|
144
|
+
var Transport = class {
|
|
145
|
+
constructor(opts) {
|
|
146
|
+
if (!opts.apiKey) throw new Error("Naive: apiKey is required");
|
|
147
|
+
this.apiKey = opts.apiKey;
|
|
148
|
+
this.baseUrl = (opts.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
149
|
+
this.fetchImpl = opts.fetch ?? fetch;
|
|
150
|
+
}
|
|
151
|
+
async request(method, path, body) {
|
|
152
|
+
const res = await this.fetchImpl(`${this.baseUrl}${path}`, {
|
|
153
|
+
method,
|
|
154
|
+
headers: {
|
|
155
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
156
|
+
"Content-Type": "application/json"
|
|
157
|
+
},
|
|
158
|
+
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
159
|
+
});
|
|
160
|
+
const text = await res.text();
|
|
161
|
+
const data = text ? JSON.parse(text) : {};
|
|
162
|
+
if (!res.ok) {
|
|
163
|
+
const err = data.error ?? data;
|
|
164
|
+
const e = err;
|
|
165
|
+
throw new import_node.NaiveError(res.status, e.code ?? "unknown", e.message ?? res.statusText, e.hint, e.details);
|
|
166
|
+
}
|
|
167
|
+
return data;
|
|
168
|
+
}
|
|
169
|
+
get(path) {
|
|
170
|
+
return this.request("GET", path);
|
|
171
|
+
}
|
|
172
|
+
post(path, body) {
|
|
173
|
+
return this.request("POST", path, body);
|
|
174
|
+
}
|
|
175
|
+
put(path, body) {
|
|
176
|
+
return this.request("PUT", path, body);
|
|
177
|
+
}
|
|
178
|
+
delete(path) {
|
|
179
|
+
return this.request("DELETE", path);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
// src/naive.ts
|
|
184
|
+
var Naive = class extends import_node2.Naive {
|
|
185
|
+
constructor(opts) {
|
|
186
|
+
super(opts);
|
|
187
|
+
this.transport = new Transport(opts);
|
|
188
|
+
this.deployments = new DeploymentsClient(this.transport);
|
|
189
|
+
}
|
|
190
|
+
forUser(userId) {
|
|
191
|
+
const base = super.forUser(userId);
|
|
192
|
+
return makeAgentProfileScoped(base, this.transport, userId);
|
|
193
|
+
}
|
|
194
|
+
/** Handle to a declared runtime pool (Naïve-hosted microVMs). */
|
|
195
|
+
runtime(pool) {
|
|
196
|
+
return new RuntimeHandle(this.transport, pool);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Direct comms namespace alias. The positioning groups email/phone under
|
|
200
|
+
* "comms"; this exposes `naive.comms.email` / `naive.comms.phone` for the
|
|
201
|
+
* default tenant without breaking the flat `naive.email` / `naive.phone`.
|
|
202
|
+
*/
|
|
203
|
+
get comms() {
|
|
204
|
+
return { email: this.email, phone: this.phone };
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
function makeAgentProfileScoped(base, transport, userId) {
|
|
208
|
+
const extra = {
|
|
209
|
+
async provision(template, opts = {}) {
|
|
210
|
+
const data = await transport.post(`/v1/users/${userId}/agent-profiles`, {
|
|
211
|
+
template: typeof template === "string" ? template : { inline: template },
|
|
212
|
+
idempotency_key: opts.idempotencyKey,
|
|
213
|
+
overrides: opts.overrides,
|
|
214
|
+
parent: opts.parent
|
|
215
|
+
});
|
|
216
|
+
return new AgentProfile(transport, data, () => base.agentTools());
|
|
217
|
+
},
|
|
218
|
+
tools() {
|
|
219
|
+
return base.agentTools();
|
|
220
|
+
},
|
|
221
|
+
get comms() {
|
|
222
|
+
return { email: base.email, phone: base.phone };
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
return new Proxy(base, {
|
|
226
|
+
get(target, prop, receiver) {
|
|
227
|
+
if (prop in extra) {
|
|
228
|
+
const v = extra[prop];
|
|
229
|
+
return typeof v === "function" ? v.bind(extra) : v;
|
|
230
|
+
}
|
|
231
|
+
const value = Reflect.get(target, prop, receiver);
|
|
232
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
237
|
+
0 && (module.exports = {
|
|
238
|
+
AgentProfile,
|
|
239
|
+
DeploymentsClient,
|
|
240
|
+
Naive,
|
|
241
|
+
RuntimeHandle,
|
|
242
|
+
...require("@usenaive-sdk/node")
|
|
243
|
+
});
|
|
244
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/naive.ts","../src/agent-profile.ts","../src/runtime.ts","../src/deployments.ts","../src/transport.ts"],"sourcesContent":["/**\n * @usenaive-sdk/server — run-time SDK for your application.\n *\n * Provision and govern a real-world agent profile per tenant (identity/entity, money,\n * comms, runtime) as one unit, governed on every action and instantly revocable.\n *\n * Re-exports the full `@usenaive-sdk/node` surface for backward compatibility,\n * with an extended `Naive` that adds `forUser(id).provision(template)`,\n * `agentProfile.tools()` / `agentProfile.revoke()`, and `runtime(pool).start()`.\n */\n\n// Full back-compat surface (types, ScopedClient, helpers). The explicit `Naive`\n// export below shadows the base class re-exported here.\nexport * from \"@usenaive-sdk/node\";\n\nexport { Naive } from \"./naive.js\";\nexport type { AgentProfileScopedClient, ProvisionOptions } from \"./naive.js\";\nexport { AgentProfile } from \"./agent-profile.js\";\nexport type { AgentProfileData, AgentProfileStatus, AgentProfileStep } from \"./agent-profile.js\";\nexport { RuntimeHandle } from \"./runtime.js\";\nexport type { StartOptions, StartSystemOptions, RuntimeRun } from \"./runtime.js\";\nexport { DeploymentsClient } from \"./deployments.js\";\nexport type { DeploymentView, DeploymentResource } from \"./deployments.js\";\n\n// Type-only re-exports so apps can type config objects without a second import.\n// The declarative *builders* (defineConfig, cloud, runtime, template, policy,\n// defineModule) live in `@usenaive-sdk/iac` — import them from there (see the docs).\nexport type {\n NaiveConfig,\n TemplateConfig,\n PolicyConfig,\n ApprovalRule,\n ApprovalCondition,\n BudgetPolicy,\n SpendCap,\n SystemConfig,\n RuntimePoolConfig,\n CloudResource,\n ModuleDefinition,\n} from \"@usenaive-sdk/iac\";\n","import {\n Naive as BaseNaive,\n ScopedClient as BaseScopedClient,\n type NaiveAgentToolset,\n type NaiveOptions,\n} from \"@usenaive-sdk/node\";\nimport type { TemplateConfig } from \"@usenaive-sdk/iac\";\nimport { AgentProfile, type AgentProfileData } from \"./agent-profile.js\";\nimport { RuntimeHandle } from \"./runtime.js\";\nimport { DeploymentsClient } from \"./deployments.js\";\nimport { Transport } from \"./transport.js\";\n\n/** The comms namespace (email + phone) grouped per the agent profile positioning. */\nexport interface CommsNamespace {\n email: BaseScopedClient[\"email\"];\n phone: BaseScopedClient[\"phone\"];\n}\n\nexport interface ProvisionOptions {\n /** Make provisioning idempotent — a retried webhook resumes the same agentProfile. */\n idempotencyKey?: string;\n /** Per-tenant overrides applied on top of the template (legalName, domain, …). */\n overrides?: Record<string, unknown>;\n /** Parent agent profile id, for sub-agents that inherit a scoped-down policy + budget. */\n parent?: string;\n}\n\n/**\n * A data-plane client bound to one tenant, extended with agent profile provisioning.\n * Everything from the base `ScopedClient` (cards, comms, vault, …) is available,\n * plus `provision()` to instantiate a governed agent profile and `tools()` sugar.\n */\nexport interface AgentProfileScopedClient extends BaseScopedClient {\n /**\n * Provision a governed real-world agent profile for this tenant from a template\n * (a registered template name, or an inline `template({...})` from\n * `@usenaive-sdk/iac`). Returns immediately with status `provisioning` — entity\n * formation / KYB / A2P / DNS are async; subscribe to agent profile events.\n */\n provision(template: string | TemplateConfig, opts?: ProvisionOptions): Promise<AgentProfile>;\n /** Sugar for the tenant's governed toolset (alias of `agentTools()`). */\n tools(): NaiveAgentToolset;\n /** The tenant's comms namespace (email + phone). */\n readonly comms: CommsNamespace;\n}\n\n/**\n * The Naïve server SDK root client.\n *\n * const naive = new Naive({ apiKey: process.env.NAIVE_SECRET_KEY });\n * const op = await naive.forUser(tenant.id).provision(\"sdr\", {\n * idempotencyKey: `op:${tenant.id}`,\n * });\n * await naive.runtime(\"pool\").start(op.id, { goal: \"Run outbound.\" });\n *\n * Backward-compatible with `@usenaive-sdk/node`: the flat resource API\n * (`naive.cards.create`, `naive.comms`/`naive.email`, `forUser(id).cards.*`)\n * keeps working — agent profiles are an additive governed layer on top.\n */\nexport class Naive extends BaseNaive {\n private readonly transport: Transport;\n /** Path A deployments control plane (plan/apply/get/down) — same as `naive up`. */\n readonly deployments: DeploymentsClient;\n\n constructor(opts: NaiveOptions) {\n super(opts);\n this.transport = new Transport(opts);\n this.deployments = new DeploymentsClient(this.transport);\n }\n\n forUser(userId: string): AgentProfileScopedClient {\n const base = super.forUser(userId);\n return makeAgentProfileScoped(base, this.transport, userId);\n }\n\n /** Handle to a declared runtime pool (Naïve-hosted microVMs). */\n runtime(pool: string): RuntimeHandle {\n return new RuntimeHandle(this.transport, pool);\n }\n\n /**\n * Direct comms namespace alias. The positioning groups email/phone under\n * \"comms\"; this exposes `naive.comms.email` / `naive.comms.phone` for the\n * default tenant without breaking the flat `naive.email` / `naive.phone`.\n */\n get comms(): CommsNamespace {\n return { email: this.email, phone: this.phone };\n }\n}\n\nfunction makeAgentProfileScoped(\n base: BaseScopedClient,\n transport: Transport,\n userId: string,\n): AgentProfileScopedClient {\n const extra = {\n async provision(template: string | TemplateConfig, opts: ProvisionOptions = {}): Promise<AgentProfile> {\n const data = await transport.post<AgentProfileData>(`/v1/users/${userId}/agent-profiles`, {\n template: typeof template === \"string\" ? template : { inline: template },\n idempotency_key: opts.idempotencyKey,\n overrides: opts.overrides,\n parent: opts.parent,\n });\n return new AgentProfile(transport, data, () => base.agentTools());\n },\n tools(): NaiveAgentToolset {\n return base.agentTools();\n },\n get comms(): CommsNamespace {\n return { email: base.email, phone: base.phone };\n },\n };\n\n return new Proxy(base, {\n get(target, prop, receiver) {\n if (prop in extra) {\n const v = (extra as Record<string | symbol, unknown>)[prop];\n return typeof v === \"function\" ? (v as (...a: unknown[]) => unknown).bind(extra) : v;\n }\n const value = Reflect.get(target, prop, receiver);\n return typeof value === \"function\" ? value.bind(target) : value;\n },\n }) as unknown as AgentProfileScopedClient;\n}\n","import type { NaiveAgentToolset } from \"@usenaive-sdk/node\";\nimport type { Transport } from \"./transport.js\";\n\n/** Lifecycle of a per-tenant agent profile's regulated bundle. */\nexport type AgentProfileStatus =\n | \"provisioning\"\n | \"verifying\"\n | \"needs_action\"\n | \"active\"\n | \"failed\"\n | \"revoked\";\n\nexport interface AgentProfileStep {\n kind: string;\n status: \"pending\" | \"running\" | \"done\" | \"needs_action\" | \"awaiting_payment\" | \"failed\";\n requirement: string | null;\n}\n\nexport interface AgentProfileData {\n id: string;\n user_id: string;\n template: string;\n status: AgentProfileStatus;\n /** Surfaced when status is `needs_action` (e.g. KYB doc, A2P rejection). */\n needs_action?: { type: string; message?: string } | null;\n /** The provisioning workflow's step ledger (identity/card/comms/...). */\n steps?: AgentProfileStep[];\n /** Effective tool policy — enabled primitives + capability allow/deny. */\n tool_policy?: { enabled_primitives: string[]; capabilities: { allow: string[]; deny: string[] } };\n /** Per-agent profile scoped API key — present ONCE on provision. */\n key?: string;\n resources?: Record<string, unknown>;\n created_at?: string;\n}\n\n/**\n * A governed real-world agent profile for a single tenant: its own identity/entity,\n * card, comms, and (optionally) runtime, instantiated from a template and\n * governed at the gateway. Returned by `naive.forUser(id).provision(template)`.\n */\nexport class AgentProfile {\n readonly id: string;\n readonly userId: string;\n readonly template: string;\n status: AgentProfileStatus;\n needsAction: AgentProfileData[\"needs_action\"];\n steps: AgentProfileStep[];\n /** Effective tool policy: which primitives/capabilities this agent profile may use. */\n toolPolicy: AgentProfileData[\"tool_policy\"];\n /** Per-agent profile scoped API key — populated ONCE on provision (undefined on refresh). */\n key?: string;\n resources: Record<string, unknown>;\n\n constructor(\n private readonly http: Transport,\n data: AgentProfileData,\n private readonly toolsFactory: () => NaiveAgentToolset,\n ) {\n this.id = data.id;\n this.userId = data.user_id;\n this.template = data.template;\n this.status = data.status;\n this.needsAction = data.needs_action ?? null;\n this.steps = data.steps ?? [];\n this.toolPolicy = data.tool_policy;\n this.key = data.key;\n this.resources = data.resources ?? {};\n }\n\n /** True once identity/KYB/comms provisioning has fully completed. */\n get isActive(): boolean {\n return this.status === \"active\";\n }\n\n /**\n * The agent profile's governed toolset (Anthropic tool defs + `handle()`), ready to\n * drop into your own agent loop / Eve / LangGraph. Every call routes through\n * the Naïve governance gateway (caps, approvals, audit, revoke).\n */\n async tools(): Promise<NaiveAgentToolset> {\n return this.toolsFactory();\n }\n\n /** Re-fetch the agent profile's current status (provisioning is async). */\n async refresh(): Promise<AgentProfile> {\n const data = await this.http.get<AgentProfileData>(`/v1/agent-profiles/${this.id}`);\n this.status = data.status;\n this.needsAction = data.needs_action ?? null;\n this.steps = data.steps ?? [];\n this.toolPolicy = data.tool_policy;\n this.resources = data.resources ?? {};\n return this;\n }\n\n /**\n * Absolute revoke: freeze the card, halt sends, rotate credentials, and tear\n * down any runtime — mid-action. Revoking a parent kills the whole system.\n */\n async revoke(): Promise<{ id: string; status: AgentProfileStatus }> {\n const res = await this.http.post<{ id: string; status: AgentProfileStatus }>(\n `/v1/agent-profiles/${this.id}/revoke`,\n );\n this.status = res.status ?? \"revoked\";\n return res;\n }\n}\n","import type { Transport } from \"./transport.js\";\n\nexport interface StartOptions {\n goal?: string;\n input?: Record<string, unknown>;\n}\n\nexport interface StartSystemOptions {\n /** A registered system NAME (from naive.config.ts `systems`). When set, Naïve\n * provisions the root + members from their templates (shared budget) and starts\n * them — no need to pass UUIDs. */\n system?: string;\n /** Or start already-provisioned agent profiles by id. */\n root?: string;\n members?: string[];\n /** Human-readable coordination topology, e.g. \"manager → [a, b]\". */\n topology?: string;\n goal?: string;\n}\n\nexport interface RuntimeRun {\n id: string;\n pool: string;\n agentProfileId: string;\n status: string;\n}\n\n/**\n * Handle to a declared runtime pool (Naïve-hosted microVMs). Use this only when\n * Naïve hosts the agent; for BYO-runtime, pull `agentProfile.tools()` and run the\n * agent in your own harness / Eve / AgentCore / LangGraph instead.\n */\nexport class RuntimeHandle {\n constructor(\n private readonly http: Transport,\n readonly pool: string,\n ) {}\n\n /** Boot a single agent in the pool for an agentProfile. */\n start(agentProfileId: string, opts: StartOptions = {}): Promise<RuntimeRun> {\n return this.http.post<RuntimeRun>(`/v1/runtime/${this.pool}/start`, {\n agent_profile_id: agentProfileId,\n goal: opts.goal,\n input: opts.input,\n });\n }\n\n /**\n * Boot a multi-agent system: a parent agent profile (shared budget) plus sub-agents\n * in their own isolated microVMs. The gateway aggregates spend against the\n * parent cap; `revoke(parent)` kills the whole system.\n */\n startSystem(opts: StartSystemOptions): Promise<RuntimeRun> {\n return this.http.post<RuntimeRun>(`/v1/runtime/${this.pool}/start-system`, {\n system: opts.system,\n root: opts.root,\n members: opts.members,\n topology: opts.topology,\n goal: opts.goal,\n });\n }\n}\n","import type { Transport } from \"./transport.js\";\n\nexport interface DeploymentResource {\n name: string;\n kind: string;\n provider?: string | null;\n status: string;\n outputs: Record<string, unknown>;\n requirement?: string | null;\n error?: string | null;\n}\n\nexport interface DeploymentView {\n project: string;\n status: string;\n outputs: Record<string, unknown>;\n last_applied_at: string | null;\n resources: DeploymentResource[];\n runtime_pools: Array<{ name: string; status: string; spec: Record<string, unknown>; binding: unknown }>;\n systems: Array<{ name: string; root: string; members: string[]; topology: string | null }>;\n}\n\n/**\n * Admin surface for Path A deployments — the same lifecycle `naive up` drives.\n * Pass an evaluated `naive.config.ts` object (project + infrastructure + runtime\n * + agentProfiles + systems).\n */\nexport class DeploymentsClient {\n constructor(private readonly http: Transport) {}\n\n /** Preview the plan (diff) for a project's config without applying. */\n plan(project: string, config: Record<string, unknown>): Promise<{ plan: unknown }> {\n return this.http.put<{ plan: unknown }>(`/v1/deployments/${encodeURIComponent(project)}`, config);\n }\n\n /** Apply: provision infrastructure + register pools/systems/agent profiles. */\n apply(project: string, config: Record<string, unknown>): Promise<{ deployment: DeploymentView; plan: unknown }> {\n return this.http.post<{ deployment: DeploymentView; plan: unknown }>(\n `/v1/deployments/${encodeURIComponent(project)}/apply`,\n config,\n );\n }\n\n /** Read a project's deployment, its resources, and resolved outputs. */\n get(project: string): Promise<DeploymentView> {\n return this.http.get<DeploymentView>(`/v1/deployments/${encodeURIComponent(project)}`);\n }\n\n /** Tear down a project's provisioned infrastructure. */\n down(project: string): Promise<{ ok: boolean; destroyed: string[] }> {\n return this.http.delete<{ ok: boolean; destroyed: string[] }>(`/v1/deployments/${encodeURIComponent(project)}`);\n }\n}\n","import { NaiveError, type NaiveOptions } from \"@usenaive-sdk/node\";\n\nconst DEFAULT_BASE_URL = \"https://api.usenaive.ai\";\n\n/**\n * Minimal HTTP transport for the agent profile/runtime control-plane endpoints that\n * the base `@usenaive-sdk/node` client does not expose. Mirrors its auth +\n * error-shape conventions so errors are `NaiveError` everywhere.\n */\nexport class Transport {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly fetchImpl: typeof fetch;\n\n constructor(opts: NaiveOptions) {\n if (!opts.apiKey) throw new Error(\"Naive: apiKey is required\");\n this.apiKey = opts.apiKey;\n this.baseUrl = (opts.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.fetchImpl = opts.fetch ?? fetch;\n }\n\n async request<T>(method: string, path: string, body?: unknown): Promise<T> {\n const res = await this.fetchImpl(`${this.baseUrl}${path}`, {\n method,\n headers: {\n Authorization: `Bearer ${this.apiKey}`,\n \"Content-Type\": \"application/json\",\n },\n body: body !== undefined ? JSON.stringify(body) : undefined,\n });\n const text = await res.text();\n const data = text ? JSON.parse(text) : {};\n if (!res.ok) {\n const err = (data as { error?: Record<string, unknown> }).error ?? data;\n const e = err as { code?: string; message?: string; hint?: string; details?: Record<string, unknown> };\n throw new NaiveError(res.status, e.code ?? \"unknown\", e.message ?? res.statusText, e.hint, e.details);\n }\n return data as T;\n }\n\n get<T>(path: string): Promise<T> {\n return this.request<T>(\"GET\", path);\n }\n post<T>(path: string, body?: unknown): Promise<T> {\n return this.request<T>(\"POST\", path, body);\n }\n put<T>(path: string, body?: unknown): Promise<T> {\n return this.request<T>(\"PUT\", path, body);\n }\n delete<T>(path: string): Promise<T> {\n return this.request<T>(\"DELETE\", path);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,0BAAc,+BAbd;;;ACAA,IAAAA,eAKO;;;ACmCA,IAAM,eAAN,MAAmB;AAAA,EAaxB,YACmB,MACjB,MACiB,cACjB;AAHiB;AAEA;AAEjB,SAAK,KAAK,KAAK;AACf,SAAK,SAAS,KAAK;AACnB,SAAK,WAAW,KAAK;AACrB,SAAK,SAAS,KAAK;AACnB,SAAK,cAAc,KAAK,gBAAgB;AACxC,SAAK,QAAQ,KAAK,SAAS,CAAC;AAC5B,SAAK,aAAa,KAAK;AACvB,SAAK,MAAM,KAAK;AAChB,SAAK,YAAY,KAAK,aAAa,CAAC;AAAA,EACtC;AAAA;AAAA,EAGA,IAAI,WAAoB;AACtB,WAAO,KAAK,WAAW;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,QAAoC;AACxC,WAAO,KAAK,aAAa;AAAA,EAC3B;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B;AACzB,aAAO,KAAK,WAAW;AAAA,IACzB;AAAA,IACA,IAAI,QAAwB;AAC1B,aAAO,EAAE,OAAO,KAAK,OAAO,OAAO,KAAK,MAAM;AAAA,IAChD;AAAA,EACF;AAEA,SAAO,IAAI,MAAM,MAAM;AAAA,IACrB,IAAI,QAAQ,MAAM,UAAU;AAC1B,UAAI,QAAQ,OAAO;AACjB,cAAM,IAAK,MAA2C,IAAI;AAC1D,eAAO,OAAO,MAAM,aAAc,EAAmC,KAAK,KAAK,IAAI;AAAA,MACrF;AACA,YAAM,QAAQ,QAAQ,IAAI,QAAQ,MAAM,QAAQ;AAChD,aAAO,OAAO,UAAU,aAAa,MAAM,KAAK,MAAM,IAAI;AAAA,IAC5D;AAAA,EACF,CAAC;AACH;","names":["import_node","BaseNaive"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { NaiveOptions, NaiveAgentToolset, ScopedClient, Naive as Naive$1 } from '@usenaive-sdk/node';
|
|
2
|
+
export * from '@usenaive-sdk/node';
|
|
3
|
+
import { TemplateConfig } from '@usenaive-sdk/iac';
|
|
4
|
+
export { ApprovalCondition, ApprovalRule, BudgetPolicy, CloudResource, ModuleDefinition, NaiveConfig, PolicyConfig, RuntimePoolConfig, SpendCap, SystemConfig, TemplateConfig } from '@usenaive-sdk/iac';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Minimal HTTP transport for the agent profile/runtime control-plane endpoints that
|
|
8
|
+
* the base `@usenaive-sdk/node` client does not expose. Mirrors its auth +
|
|
9
|
+
* error-shape conventions so errors are `NaiveError` everywhere.
|
|
10
|
+
*/
|
|
11
|
+
declare class Transport {
|
|
12
|
+
private readonly apiKey;
|
|
13
|
+
private readonly baseUrl;
|
|
14
|
+
private readonly fetchImpl;
|
|
15
|
+
constructor(opts: NaiveOptions);
|
|
16
|
+
request<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
17
|
+
get<T>(path: string): Promise<T>;
|
|
18
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
19
|
+
put<T>(path: string, body?: unknown): Promise<T>;
|
|
20
|
+
delete<T>(path: string): Promise<T>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Lifecycle of a per-tenant agent profile's regulated bundle. */
|
|
24
|
+
type AgentProfileStatus = "provisioning" | "verifying" | "needs_action" | "active" | "failed" | "revoked";
|
|
25
|
+
interface AgentProfileStep {
|
|
26
|
+
kind: string;
|
|
27
|
+
status: "pending" | "running" | "done" | "needs_action" | "awaiting_payment" | "failed";
|
|
28
|
+
requirement: string | null;
|
|
29
|
+
}
|
|
30
|
+
interface AgentProfileData {
|
|
31
|
+
id: string;
|
|
32
|
+
user_id: string;
|
|
33
|
+
template: string;
|
|
34
|
+
status: AgentProfileStatus;
|
|
35
|
+
/** Surfaced when status is `needs_action` (e.g. KYB doc, A2P rejection). */
|
|
36
|
+
needs_action?: {
|
|
37
|
+
type: string;
|
|
38
|
+
message?: string;
|
|
39
|
+
} | null;
|
|
40
|
+
/** The provisioning workflow's step ledger (identity/card/comms/...). */
|
|
41
|
+
steps?: AgentProfileStep[];
|
|
42
|
+
/** Effective tool policy — enabled primitives + capability allow/deny. */
|
|
43
|
+
tool_policy?: {
|
|
44
|
+
enabled_primitives: string[];
|
|
45
|
+
capabilities: {
|
|
46
|
+
allow: string[];
|
|
47
|
+
deny: string[];
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
/** Per-agent profile scoped API key — present ONCE on provision. */
|
|
51
|
+
key?: string;
|
|
52
|
+
resources?: Record<string, unknown>;
|
|
53
|
+
created_at?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A governed real-world agent profile for a single tenant: its own identity/entity,
|
|
57
|
+
* card, comms, and (optionally) runtime, instantiated from a template and
|
|
58
|
+
* governed at the gateway. Returned by `naive.forUser(id).provision(template)`.
|
|
59
|
+
*/
|
|
60
|
+
declare class AgentProfile {
|
|
61
|
+
private readonly http;
|
|
62
|
+
private readonly toolsFactory;
|
|
63
|
+
readonly id: string;
|
|
64
|
+
readonly userId: string;
|
|
65
|
+
readonly template: string;
|
|
66
|
+
status: AgentProfileStatus;
|
|
67
|
+
needsAction: AgentProfileData["needs_action"];
|
|
68
|
+
steps: AgentProfileStep[];
|
|
69
|
+
/** Effective tool policy: which primitives/capabilities this agent profile may use. */
|
|
70
|
+
toolPolicy: AgentProfileData["tool_policy"];
|
|
71
|
+
/** Per-agent profile scoped API key — populated ONCE on provision (undefined on refresh). */
|
|
72
|
+
key?: string;
|
|
73
|
+
resources: Record<string, unknown>;
|
|
74
|
+
constructor(http: Transport, data: AgentProfileData, toolsFactory: () => NaiveAgentToolset);
|
|
75
|
+
/** True once identity/KYB/comms provisioning has fully completed. */
|
|
76
|
+
get isActive(): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* The agent profile's governed toolset (Anthropic tool defs + `handle()`), ready to
|
|
79
|
+
* drop into your own agent loop / Eve / LangGraph. Every call routes through
|
|
80
|
+
* the Naïve governance gateway (caps, approvals, audit, revoke).
|
|
81
|
+
*/
|
|
82
|
+
tools(): Promise<NaiveAgentToolset>;
|
|
83
|
+
/** Re-fetch the agent profile's current status (provisioning is async). */
|
|
84
|
+
refresh(): Promise<AgentProfile>;
|
|
85
|
+
/**
|
|
86
|
+
* Absolute revoke: freeze the card, halt sends, rotate credentials, and tear
|
|
87
|
+
* down any runtime — mid-action. Revoking a parent kills the whole system.
|
|
88
|
+
*/
|
|
89
|
+
revoke(): Promise<{
|
|
90
|
+
id: string;
|
|
91
|
+
status: AgentProfileStatus;
|
|
92
|
+
}>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
interface StartOptions {
|
|
96
|
+
goal?: string;
|
|
97
|
+
input?: Record<string, unknown>;
|
|
98
|
+
}
|
|
99
|
+
interface StartSystemOptions {
|
|
100
|
+
/** A registered system NAME (from naive.config.ts `systems`). When set, Naïve
|
|
101
|
+
* provisions the root + members from their templates (shared budget) and starts
|
|
102
|
+
* them — no need to pass UUIDs. */
|
|
103
|
+
system?: string;
|
|
104
|
+
/** Or start already-provisioned agent profiles by id. */
|
|
105
|
+
root?: string;
|
|
106
|
+
members?: string[];
|
|
107
|
+
/** Human-readable coordination topology, e.g. "manager → [a, b]". */
|
|
108
|
+
topology?: string;
|
|
109
|
+
goal?: string;
|
|
110
|
+
}
|
|
111
|
+
interface RuntimeRun {
|
|
112
|
+
id: string;
|
|
113
|
+
pool: string;
|
|
114
|
+
agentProfileId: string;
|
|
115
|
+
status: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Handle to a declared runtime pool (Naïve-hosted microVMs). Use this only when
|
|
119
|
+
* Naïve hosts the agent; for BYO-runtime, pull `agentProfile.tools()` and run the
|
|
120
|
+
* agent in your own harness / Eve / AgentCore / LangGraph instead.
|
|
121
|
+
*/
|
|
122
|
+
declare class RuntimeHandle {
|
|
123
|
+
private readonly http;
|
|
124
|
+
readonly pool: string;
|
|
125
|
+
constructor(http: Transport, pool: string);
|
|
126
|
+
/** Boot a single agent in the pool for an agentProfile. */
|
|
127
|
+
start(agentProfileId: string, opts?: StartOptions): Promise<RuntimeRun>;
|
|
128
|
+
/**
|
|
129
|
+
* Boot a multi-agent system: a parent agent profile (shared budget) plus sub-agents
|
|
130
|
+
* in their own isolated microVMs. The gateway aggregates spend against the
|
|
131
|
+
* parent cap; `revoke(parent)` kills the whole system.
|
|
132
|
+
*/
|
|
133
|
+
startSystem(opts: StartSystemOptions): Promise<RuntimeRun>;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
interface DeploymentResource {
|
|
137
|
+
name: string;
|
|
138
|
+
kind: string;
|
|
139
|
+
provider?: string | null;
|
|
140
|
+
status: string;
|
|
141
|
+
outputs: Record<string, unknown>;
|
|
142
|
+
requirement?: string | null;
|
|
143
|
+
error?: string | null;
|
|
144
|
+
}
|
|
145
|
+
interface DeploymentView {
|
|
146
|
+
project: string;
|
|
147
|
+
status: string;
|
|
148
|
+
outputs: Record<string, unknown>;
|
|
149
|
+
last_applied_at: string | null;
|
|
150
|
+
resources: DeploymentResource[];
|
|
151
|
+
runtime_pools: Array<{
|
|
152
|
+
name: string;
|
|
153
|
+
status: string;
|
|
154
|
+
spec: Record<string, unknown>;
|
|
155
|
+
binding: unknown;
|
|
156
|
+
}>;
|
|
157
|
+
systems: Array<{
|
|
158
|
+
name: string;
|
|
159
|
+
root: string;
|
|
160
|
+
members: string[];
|
|
161
|
+
topology: string | null;
|
|
162
|
+
}>;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Admin surface for Path A deployments — the same lifecycle `naive up` drives.
|
|
166
|
+
* Pass an evaluated `naive.config.ts` object (project + infrastructure + runtime
|
|
167
|
+
* + agentProfiles + systems).
|
|
168
|
+
*/
|
|
169
|
+
declare class DeploymentsClient {
|
|
170
|
+
private readonly http;
|
|
171
|
+
constructor(http: Transport);
|
|
172
|
+
/** Preview the plan (diff) for a project's config without applying. */
|
|
173
|
+
plan(project: string, config: Record<string, unknown>): Promise<{
|
|
174
|
+
plan: unknown;
|
|
175
|
+
}>;
|
|
176
|
+
/** Apply: provision infrastructure + register pools/systems/agent profiles. */
|
|
177
|
+
apply(project: string, config: Record<string, unknown>): Promise<{
|
|
178
|
+
deployment: DeploymentView;
|
|
179
|
+
plan: unknown;
|
|
180
|
+
}>;
|
|
181
|
+
/** Read a project's deployment, its resources, and resolved outputs. */
|
|
182
|
+
get(project: string): Promise<DeploymentView>;
|
|
183
|
+
/** Tear down a project's provisioned infrastructure. */
|
|
184
|
+
down(project: string): Promise<{
|
|
185
|
+
ok: boolean;
|
|
186
|
+
destroyed: string[];
|
|
187
|
+
}>;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** The comms namespace (email + phone) grouped per the agent profile positioning. */
|
|
191
|
+
interface CommsNamespace {
|
|
192
|
+
email: ScopedClient["email"];
|
|
193
|
+
phone: ScopedClient["phone"];
|
|
194
|
+
}
|
|
195
|
+
interface ProvisionOptions {
|
|
196
|
+
/** Make provisioning idempotent — a retried webhook resumes the same agentProfile. */
|
|
197
|
+
idempotencyKey?: string;
|
|
198
|
+
/** Per-tenant overrides applied on top of the template (legalName, domain, …). */
|
|
199
|
+
overrides?: Record<string, unknown>;
|
|
200
|
+
/** Parent agent profile id, for sub-agents that inherit a scoped-down policy + budget. */
|
|
201
|
+
parent?: string;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* A data-plane client bound to one tenant, extended with agent profile provisioning.
|
|
205
|
+
* Everything from the base `ScopedClient` (cards, comms, vault, …) is available,
|
|
206
|
+
* plus `provision()` to instantiate a governed agent profile and `tools()` sugar.
|
|
207
|
+
*/
|
|
208
|
+
interface AgentProfileScopedClient extends ScopedClient {
|
|
209
|
+
/**
|
|
210
|
+
* Provision a governed real-world agent profile for this tenant from a template
|
|
211
|
+
* (a registered template name, or an inline `template({...})` from
|
|
212
|
+
* `@usenaive-sdk/iac`). Returns immediately with status `provisioning` — entity
|
|
213
|
+
* formation / KYB / A2P / DNS are async; subscribe to agent profile events.
|
|
214
|
+
*/
|
|
215
|
+
provision(template: string | TemplateConfig, opts?: ProvisionOptions): Promise<AgentProfile>;
|
|
216
|
+
/** Sugar for the tenant's governed toolset (alias of `agentTools()`). */
|
|
217
|
+
tools(): NaiveAgentToolset;
|
|
218
|
+
/** The tenant's comms namespace (email + phone). */
|
|
219
|
+
readonly comms: CommsNamespace;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* The Naïve server SDK root client.
|
|
223
|
+
*
|
|
224
|
+
* const naive = new Naive({ apiKey: process.env.NAIVE_SECRET_KEY });
|
|
225
|
+
* const op = await naive.forUser(tenant.id).provision("sdr", {
|
|
226
|
+
* idempotencyKey: `op:${tenant.id}`,
|
|
227
|
+
* });
|
|
228
|
+
* await naive.runtime("pool").start(op.id, { goal: "Run outbound." });
|
|
229
|
+
*
|
|
230
|
+
* Backward-compatible with `@usenaive-sdk/node`: the flat resource API
|
|
231
|
+
* (`naive.cards.create`, `naive.comms`/`naive.email`, `forUser(id).cards.*`)
|
|
232
|
+
* keeps working — agent profiles are an additive governed layer on top.
|
|
233
|
+
*/
|
|
234
|
+
declare class Naive extends Naive$1 {
|
|
235
|
+
private readonly transport;
|
|
236
|
+
/** Path A deployments control plane (plan/apply/get/down) — same as `naive up`. */
|
|
237
|
+
readonly deployments: DeploymentsClient;
|
|
238
|
+
constructor(opts: NaiveOptions);
|
|
239
|
+
forUser(userId: string): AgentProfileScopedClient;
|
|
240
|
+
/** Handle to a declared runtime pool (Naïve-hosted microVMs). */
|
|
241
|
+
runtime(pool: string): RuntimeHandle;
|
|
242
|
+
/**
|
|
243
|
+
* Direct comms namespace alias. The positioning groups email/phone under
|
|
244
|
+
* "comms"; this exposes `naive.comms.email` / `naive.comms.phone` for the
|
|
245
|
+
* default tenant without breaking the flat `naive.email` / `naive.phone`.
|
|
246
|
+
*/
|
|
247
|
+
get comms(): CommsNamespace;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export { AgentProfile, type AgentProfileData, type AgentProfileScopedClient, type AgentProfileStatus, type AgentProfileStep, type DeploymentResource, type DeploymentView, DeploymentsClient, Naive, type ProvisionOptions, RuntimeHandle, type RuntimeRun, type StartOptions, type StartSystemOptions };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { NaiveOptions, NaiveAgentToolset, ScopedClient, Naive as Naive$1 } from '@usenaive-sdk/node';
|
|
2
|
+
export * from '@usenaive-sdk/node';
|
|
3
|
+
import { TemplateConfig } from '@usenaive-sdk/iac';
|
|
4
|
+
export { ApprovalCondition, ApprovalRule, BudgetPolicy, CloudResource, ModuleDefinition, NaiveConfig, PolicyConfig, RuntimePoolConfig, SpendCap, SystemConfig, TemplateConfig } from '@usenaive-sdk/iac';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Minimal HTTP transport for the agent profile/runtime control-plane endpoints that
|
|
8
|
+
* the base `@usenaive-sdk/node` client does not expose. Mirrors its auth +
|
|
9
|
+
* error-shape conventions so errors are `NaiveError` everywhere.
|
|
10
|
+
*/
|
|
11
|
+
declare class Transport {
|
|
12
|
+
private readonly apiKey;
|
|
13
|
+
private readonly baseUrl;
|
|
14
|
+
private readonly fetchImpl;
|
|
15
|
+
constructor(opts: NaiveOptions);
|
|
16
|
+
request<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
17
|
+
get<T>(path: string): Promise<T>;
|
|
18
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
19
|
+
put<T>(path: string, body?: unknown): Promise<T>;
|
|
20
|
+
delete<T>(path: string): Promise<T>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Lifecycle of a per-tenant agent profile's regulated bundle. */
|
|
24
|
+
type AgentProfileStatus = "provisioning" | "verifying" | "needs_action" | "active" | "failed" | "revoked";
|
|
25
|
+
interface AgentProfileStep {
|
|
26
|
+
kind: string;
|
|
27
|
+
status: "pending" | "running" | "done" | "needs_action" | "awaiting_payment" | "failed";
|
|
28
|
+
requirement: string | null;
|
|
29
|
+
}
|
|
30
|
+
interface AgentProfileData {
|
|
31
|
+
id: string;
|
|
32
|
+
user_id: string;
|
|
33
|
+
template: string;
|
|
34
|
+
status: AgentProfileStatus;
|
|
35
|
+
/** Surfaced when status is `needs_action` (e.g. KYB doc, A2P rejection). */
|
|
36
|
+
needs_action?: {
|
|
37
|
+
type: string;
|
|
38
|
+
message?: string;
|
|
39
|
+
} | null;
|
|
40
|
+
/** The provisioning workflow's step ledger (identity/card/comms/...). */
|
|
41
|
+
steps?: AgentProfileStep[];
|
|
42
|
+
/** Effective tool policy — enabled primitives + capability allow/deny. */
|
|
43
|
+
tool_policy?: {
|
|
44
|
+
enabled_primitives: string[];
|
|
45
|
+
capabilities: {
|
|
46
|
+
allow: string[];
|
|
47
|
+
deny: string[];
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
/** Per-agent profile scoped API key — present ONCE on provision. */
|
|
51
|
+
key?: string;
|
|
52
|
+
resources?: Record<string, unknown>;
|
|
53
|
+
created_at?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A governed real-world agent profile for a single tenant: its own identity/entity,
|
|
57
|
+
* card, comms, and (optionally) runtime, instantiated from a template and
|
|
58
|
+
* governed at the gateway. Returned by `naive.forUser(id).provision(template)`.
|
|
59
|
+
*/
|
|
60
|
+
declare class AgentProfile {
|
|
61
|
+
private readonly http;
|
|
62
|
+
private readonly toolsFactory;
|
|
63
|
+
readonly id: string;
|
|
64
|
+
readonly userId: string;
|
|
65
|
+
readonly template: string;
|
|
66
|
+
status: AgentProfileStatus;
|
|
67
|
+
needsAction: AgentProfileData["needs_action"];
|
|
68
|
+
steps: AgentProfileStep[];
|
|
69
|
+
/** Effective tool policy: which primitives/capabilities this agent profile may use. */
|
|
70
|
+
toolPolicy: AgentProfileData["tool_policy"];
|
|
71
|
+
/** Per-agent profile scoped API key — populated ONCE on provision (undefined on refresh). */
|
|
72
|
+
key?: string;
|
|
73
|
+
resources: Record<string, unknown>;
|
|
74
|
+
constructor(http: Transport, data: AgentProfileData, toolsFactory: () => NaiveAgentToolset);
|
|
75
|
+
/** True once identity/KYB/comms provisioning has fully completed. */
|
|
76
|
+
get isActive(): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* The agent profile's governed toolset (Anthropic tool defs + `handle()`), ready to
|
|
79
|
+
* drop into your own agent loop / Eve / LangGraph. Every call routes through
|
|
80
|
+
* the Naïve governance gateway (caps, approvals, audit, revoke).
|
|
81
|
+
*/
|
|
82
|
+
tools(): Promise<NaiveAgentToolset>;
|
|
83
|
+
/** Re-fetch the agent profile's current status (provisioning is async). */
|
|
84
|
+
refresh(): Promise<AgentProfile>;
|
|
85
|
+
/**
|
|
86
|
+
* Absolute revoke: freeze the card, halt sends, rotate credentials, and tear
|
|
87
|
+
* down any runtime — mid-action. Revoking a parent kills the whole system.
|
|
88
|
+
*/
|
|
89
|
+
revoke(): Promise<{
|
|
90
|
+
id: string;
|
|
91
|
+
status: AgentProfileStatus;
|
|
92
|
+
}>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
interface StartOptions {
|
|
96
|
+
goal?: string;
|
|
97
|
+
input?: Record<string, unknown>;
|
|
98
|
+
}
|
|
99
|
+
interface StartSystemOptions {
|
|
100
|
+
/** A registered system NAME (from naive.config.ts `systems`). When set, Naïve
|
|
101
|
+
* provisions the root + members from their templates (shared budget) and starts
|
|
102
|
+
* them — no need to pass UUIDs. */
|
|
103
|
+
system?: string;
|
|
104
|
+
/** Or start already-provisioned agent profiles by id. */
|
|
105
|
+
root?: string;
|
|
106
|
+
members?: string[];
|
|
107
|
+
/** Human-readable coordination topology, e.g. "manager → [a, b]". */
|
|
108
|
+
topology?: string;
|
|
109
|
+
goal?: string;
|
|
110
|
+
}
|
|
111
|
+
interface RuntimeRun {
|
|
112
|
+
id: string;
|
|
113
|
+
pool: string;
|
|
114
|
+
agentProfileId: string;
|
|
115
|
+
status: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Handle to a declared runtime pool (Naïve-hosted microVMs). Use this only when
|
|
119
|
+
* Naïve hosts the agent; for BYO-runtime, pull `agentProfile.tools()` and run the
|
|
120
|
+
* agent in your own harness / Eve / AgentCore / LangGraph instead.
|
|
121
|
+
*/
|
|
122
|
+
declare class RuntimeHandle {
|
|
123
|
+
private readonly http;
|
|
124
|
+
readonly pool: string;
|
|
125
|
+
constructor(http: Transport, pool: string);
|
|
126
|
+
/** Boot a single agent in the pool for an agentProfile. */
|
|
127
|
+
start(agentProfileId: string, opts?: StartOptions): Promise<RuntimeRun>;
|
|
128
|
+
/**
|
|
129
|
+
* Boot a multi-agent system: a parent agent profile (shared budget) plus sub-agents
|
|
130
|
+
* in their own isolated microVMs. The gateway aggregates spend against the
|
|
131
|
+
* parent cap; `revoke(parent)` kills the whole system.
|
|
132
|
+
*/
|
|
133
|
+
startSystem(opts: StartSystemOptions): Promise<RuntimeRun>;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
interface DeploymentResource {
|
|
137
|
+
name: string;
|
|
138
|
+
kind: string;
|
|
139
|
+
provider?: string | null;
|
|
140
|
+
status: string;
|
|
141
|
+
outputs: Record<string, unknown>;
|
|
142
|
+
requirement?: string | null;
|
|
143
|
+
error?: string | null;
|
|
144
|
+
}
|
|
145
|
+
interface DeploymentView {
|
|
146
|
+
project: string;
|
|
147
|
+
status: string;
|
|
148
|
+
outputs: Record<string, unknown>;
|
|
149
|
+
last_applied_at: string | null;
|
|
150
|
+
resources: DeploymentResource[];
|
|
151
|
+
runtime_pools: Array<{
|
|
152
|
+
name: string;
|
|
153
|
+
status: string;
|
|
154
|
+
spec: Record<string, unknown>;
|
|
155
|
+
binding: unknown;
|
|
156
|
+
}>;
|
|
157
|
+
systems: Array<{
|
|
158
|
+
name: string;
|
|
159
|
+
root: string;
|
|
160
|
+
members: string[];
|
|
161
|
+
topology: string | null;
|
|
162
|
+
}>;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Admin surface for Path A deployments — the same lifecycle `naive up` drives.
|
|
166
|
+
* Pass an evaluated `naive.config.ts` object (project + infrastructure + runtime
|
|
167
|
+
* + agentProfiles + systems).
|
|
168
|
+
*/
|
|
169
|
+
declare class DeploymentsClient {
|
|
170
|
+
private readonly http;
|
|
171
|
+
constructor(http: Transport);
|
|
172
|
+
/** Preview the plan (diff) for a project's config without applying. */
|
|
173
|
+
plan(project: string, config: Record<string, unknown>): Promise<{
|
|
174
|
+
plan: unknown;
|
|
175
|
+
}>;
|
|
176
|
+
/** Apply: provision infrastructure + register pools/systems/agent profiles. */
|
|
177
|
+
apply(project: string, config: Record<string, unknown>): Promise<{
|
|
178
|
+
deployment: DeploymentView;
|
|
179
|
+
plan: unknown;
|
|
180
|
+
}>;
|
|
181
|
+
/** Read a project's deployment, its resources, and resolved outputs. */
|
|
182
|
+
get(project: string): Promise<DeploymentView>;
|
|
183
|
+
/** Tear down a project's provisioned infrastructure. */
|
|
184
|
+
down(project: string): Promise<{
|
|
185
|
+
ok: boolean;
|
|
186
|
+
destroyed: string[];
|
|
187
|
+
}>;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** The comms namespace (email + phone) grouped per the agent profile positioning. */
|
|
191
|
+
interface CommsNamespace {
|
|
192
|
+
email: ScopedClient["email"];
|
|
193
|
+
phone: ScopedClient["phone"];
|
|
194
|
+
}
|
|
195
|
+
interface ProvisionOptions {
|
|
196
|
+
/** Make provisioning idempotent — a retried webhook resumes the same agentProfile. */
|
|
197
|
+
idempotencyKey?: string;
|
|
198
|
+
/** Per-tenant overrides applied on top of the template (legalName, domain, …). */
|
|
199
|
+
overrides?: Record<string, unknown>;
|
|
200
|
+
/** Parent agent profile id, for sub-agents that inherit a scoped-down policy + budget. */
|
|
201
|
+
parent?: string;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* A data-plane client bound to one tenant, extended with agent profile provisioning.
|
|
205
|
+
* Everything from the base `ScopedClient` (cards, comms, vault, …) is available,
|
|
206
|
+
* plus `provision()` to instantiate a governed agent profile and `tools()` sugar.
|
|
207
|
+
*/
|
|
208
|
+
interface AgentProfileScopedClient extends ScopedClient {
|
|
209
|
+
/**
|
|
210
|
+
* Provision a governed real-world agent profile for this tenant from a template
|
|
211
|
+
* (a registered template name, or an inline `template({...})` from
|
|
212
|
+
* `@usenaive-sdk/iac`). Returns immediately with status `provisioning` — entity
|
|
213
|
+
* formation / KYB / A2P / DNS are async; subscribe to agent profile events.
|
|
214
|
+
*/
|
|
215
|
+
provision(template: string | TemplateConfig, opts?: ProvisionOptions): Promise<AgentProfile>;
|
|
216
|
+
/** Sugar for the tenant's governed toolset (alias of `agentTools()`). */
|
|
217
|
+
tools(): NaiveAgentToolset;
|
|
218
|
+
/** The tenant's comms namespace (email + phone). */
|
|
219
|
+
readonly comms: CommsNamespace;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* The Naïve server SDK root client.
|
|
223
|
+
*
|
|
224
|
+
* const naive = new Naive({ apiKey: process.env.NAIVE_SECRET_KEY });
|
|
225
|
+
* const op = await naive.forUser(tenant.id).provision("sdr", {
|
|
226
|
+
* idempotencyKey: `op:${tenant.id}`,
|
|
227
|
+
* });
|
|
228
|
+
* await naive.runtime("pool").start(op.id, { goal: "Run outbound." });
|
|
229
|
+
*
|
|
230
|
+
* Backward-compatible with `@usenaive-sdk/node`: the flat resource API
|
|
231
|
+
* (`naive.cards.create`, `naive.comms`/`naive.email`, `forUser(id).cards.*`)
|
|
232
|
+
* keeps working — agent profiles are an additive governed layer on top.
|
|
233
|
+
*/
|
|
234
|
+
declare class Naive extends Naive$1 {
|
|
235
|
+
private readonly transport;
|
|
236
|
+
/** Path A deployments control plane (plan/apply/get/down) — same as `naive up`. */
|
|
237
|
+
readonly deployments: DeploymentsClient;
|
|
238
|
+
constructor(opts: NaiveOptions);
|
|
239
|
+
forUser(userId: string): AgentProfileScopedClient;
|
|
240
|
+
/** Handle to a declared runtime pool (Naïve-hosted microVMs). */
|
|
241
|
+
runtime(pool: string): RuntimeHandle;
|
|
242
|
+
/**
|
|
243
|
+
* Direct comms namespace alias. The positioning groups email/phone under
|
|
244
|
+
* "comms"; this exposes `naive.comms.email` / `naive.comms.phone` for the
|
|
245
|
+
* default tenant without breaking the flat `naive.email` / `naive.phone`.
|
|
246
|
+
*/
|
|
247
|
+
get comms(): CommsNamespace;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export { AgentProfile, type AgentProfileData, type AgentProfileScopedClient, type AgentProfileStatus, type AgentProfileStep, type DeploymentResource, type DeploymentView, DeploymentsClient, Naive, type ProvisionOptions, RuntimeHandle, type RuntimeRun, type StartOptions, type StartSystemOptions };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
export * from "@usenaive-sdk/node";
|
|
3
|
+
|
|
4
|
+
// src/naive.ts
|
|
5
|
+
import {
|
|
6
|
+
Naive as BaseNaive
|
|
7
|
+
} from "@usenaive-sdk/node";
|
|
8
|
+
|
|
9
|
+
// src/agent-profile.ts
|
|
10
|
+
var AgentProfile = class {
|
|
11
|
+
constructor(http, data, toolsFactory) {
|
|
12
|
+
this.http = http;
|
|
13
|
+
this.toolsFactory = toolsFactory;
|
|
14
|
+
this.id = data.id;
|
|
15
|
+
this.userId = data.user_id;
|
|
16
|
+
this.template = data.template;
|
|
17
|
+
this.status = data.status;
|
|
18
|
+
this.needsAction = data.needs_action ?? null;
|
|
19
|
+
this.steps = data.steps ?? [];
|
|
20
|
+
this.toolPolicy = data.tool_policy;
|
|
21
|
+
this.key = data.key;
|
|
22
|
+
this.resources = data.resources ?? {};
|
|
23
|
+
}
|
|
24
|
+
/** True once identity/KYB/comms provisioning has fully completed. */
|
|
25
|
+
get isActive() {
|
|
26
|
+
return this.status === "active";
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The agent profile's governed toolset (Anthropic tool defs + `handle()`), ready to
|
|
30
|
+
* drop into your own agent loop / Eve / LangGraph. Every call routes through
|
|
31
|
+
* the Naïve governance gateway (caps, approvals, audit, revoke).
|
|
32
|
+
*/
|
|
33
|
+
async tools() {
|
|
34
|
+
return this.toolsFactory();
|
|
35
|
+
}
|
|
36
|
+
/** Re-fetch the agent profile's current status (provisioning is async). */
|
|
37
|
+
async refresh() {
|
|
38
|
+
const data = await this.http.get(`/v1/agent-profiles/${this.id}`);
|
|
39
|
+
this.status = data.status;
|
|
40
|
+
this.needsAction = data.needs_action ?? null;
|
|
41
|
+
this.steps = data.steps ?? [];
|
|
42
|
+
this.toolPolicy = data.tool_policy;
|
|
43
|
+
this.resources = data.resources ?? {};
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Absolute revoke: freeze the card, halt sends, rotate credentials, and tear
|
|
48
|
+
* down any runtime — mid-action. Revoking a parent kills the whole system.
|
|
49
|
+
*/
|
|
50
|
+
async revoke() {
|
|
51
|
+
const res = await this.http.post(
|
|
52
|
+
`/v1/agent-profiles/${this.id}/revoke`
|
|
53
|
+
);
|
|
54
|
+
this.status = res.status ?? "revoked";
|
|
55
|
+
return res;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// src/runtime.ts
|
|
60
|
+
var RuntimeHandle = class {
|
|
61
|
+
constructor(http, pool) {
|
|
62
|
+
this.http = http;
|
|
63
|
+
this.pool = pool;
|
|
64
|
+
}
|
|
65
|
+
/** Boot a single agent in the pool for an agentProfile. */
|
|
66
|
+
start(agentProfileId, opts = {}) {
|
|
67
|
+
return this.http.post(`/v1/runtime/${this.pool}/start`, {
|
|
68
|
+
agent_profile_id: agentProfileId,
|
|
69
|
+
goal: opts.goal,
|
|
70
|
+
input: opts.input
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Boot a multi-agent system: a parent agent profile (shared budget) plus sub-agents
|
|
75
|
+
* in their own isolated microVMs. The gateway aggregates spend against the
|
|
76
|
+
* parent cap; `revoke(parent)` kills the whole system.
|
|
77
|
+
*/
|
|
78
|
+
startSystem(opts) {
|
|
79
|
+
return this.http.post(`/v1/runtime/${this.pool}/start-system`, {
|
|
80
|
+
system: opts.system,
|
|
81
|
+
root: opts.root,
|
|
82
|
+
members: opts.members,
|
|
83
|
+
topology: opts.topology,
|
|
84
|
+
goal: opts.goal
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// src/deployments.ts
|
|
90
|
+
var DeploymentsClient = class {
|
|
91
|
+
constructor(http) {
|
|
92
|
+
this.http = http;
|
|
93
|
+
}
|
|
94
|
+
/** Preview the plan (diff) for a project's config without applying. */
|
|
95
|
+
plan(project, config) {
|
|
96
|
+
return this.http.put(`/v1/deployments/${encodeURIComponent(project)}`, config);
|
|
97
|
+
}
|
|
98
|
+
/** Apply: provision infrastructure + register pools/systems/agent profiles. */
|
|
99
|
+
apply(project, config) {
|
|
100
|
+
return this.http.post(
|
|
101
|
+
`/v1/deployments/${encodeURIComponent(project)}/apply`,
|
|
102
|
+
config
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
/** Read a project's deployment, its resources, and resolved outputs. */
|
|
106
|
+
get(project) {
|
|
107
|
+
return this.http.get(`/v1/deployments/${encodeURIComponent(project)}`);
|
|
108
|
+
}
|
|
109
|
+
/** Tear down a project's provisioned infrastructure. */
|
|
110
|
+
down(project) {
|
|
111
|
+
return this.http.delete(`/v1/deployments/${encodeURIComponent(project)}`);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// src/transport.ts
|
|
116
|
+
import { NaiveError } from "@usenaive-sdk/node";
|
|
117
|
+
var DEFAULT_BASE_URL = "https://api.usenaive.ai";
|
|
118
|
+
var Transport = class {
|
|
119
|
+
constructor(opts) {
|
|
120
|
+
if (!opts.apiKey) throw new Error("Naive: apiKey is required");
|
|
121
|
+
this.apiKey = opts.apiKey;
|
|
122
|
+
this.baseUrl = (opts.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
123
|
+
this.fetchImpl = opts.fetch ?? fetch;
|
|
124
|
+
}
|
|
125
|
+
async request(method, path, body) {
|
|
126
|
+
const res = await this.fetchImpl(`${this.baseUrl}${path}`, {
|
|
127
|
+
method,
|
|
128
|
+
headers: {
|
|
129
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
130
|
+
"Content-Type": "application/json"
|
|
131
|
+
},
|
|
132
|
+
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
133
|
+
});
|
|
134
|
+
const text = await res.text();
|
|
135
|
+
const data = text ? JSON.parse(text) : {};
|
|
136
|
+
if (!res.ok) {
|
|
137
|
+
const err = data.error ?? data;
|
|
138
|
+
const e = err;
|
|
139
|
+
throw new NaiveError(res.status, e.code ?? "unknown", e.message ?? res.statusText, e.hint, e.details);
|
|
140
|
+
}
|
|
141
|
+
return data;
|
|
142
|
+
}
|
|
143
|
+
get(path) {
|
|
144
|
+
return this.request("GET", path);
|
|
145
|
+
}
|
|
146
|
+
post(path, body) {
|
|
147
|
+
return this.request("POST", path, body);
|
|
148
|
+
}
|
|
149
|
+
put(path, body) {
|
|
150
|
+
return this.request("PUT", path, body);
|
|
151
|
+
}
|
|
152
|
+
delete(path) {
|
|
153
|
+
return this.request("DELETE", path);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// src/naive.ts
|
|
158
|
+
var Naive = class extends BaseNaive {
|
|
159
|
+
constructor(opts) {
|
|
160
|
+
super(opts);
|
|
161
|
+
this.transport = new Transport(opts);
|
|
162
|
+
this.deployments = new DeploymentsClient(this.transport);
|
|
163
|
+
}
|
|
164
|
+
forUser(userId) {
|
|
165
|
+
const base = super.forUser(userId);
|
|
166
|
+
return makeAgentProfileScoped(base, this.transport, userId);
|
|
167
|
+
}
|
|
168
|
+
/** Handle to a declared runtime pool (Naïve-hosted microVMs). */
|
|
169
|
+
runtime(pool) {
|
|
170
|
+
return new RuntimeHandle(this.transport, pool);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Direct comms namespace alias. The positioning groups email/phone under
|
|
174
|
+
* "comms"; this exposes `naive.comms.email` / `naive.comms.phone` for the
|
|
175
|
+
* default tenant without breaking the flat `naive.email` / `naive.phone`.
|
|
176
|
+
*/
|
|
177
|
+
get comms() {
|
|
178
|
+
return { email: this.email, phone: this.phone };
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
function makeAgentProfileScoped(base, transport, userId) {
|
|
182
|
+
const extra = {
|
|
183
|
+
async provision(template, opts = {}) {
|
|
184
|
+
const data = await transport.post(`/v1/users/${userId}/agent-profiles`, {
|
|
185
|
+
template: typeof template === "string" ? template : { inline: template },
|
|
186
|
+
idempotency_key: opts.idempotencyKey,
|
|
187
|
+
overrides: opts.overrides,
|
|
188
|
+
parent: opts.parent
|
|
189
|
+
});
|
|
190
|
+
return new AgentProfile(transport, data, () => base.agentTools());
|
|
191
|
+
},
|
|
192
|
+
tools() {
|
|
193
|
+
return base.agentTools();
|
|
194
|
+
},
|
|
195
|
+
get comms() {
|
|
196
|
+
return { email: base.email, phone: base.phone };
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
return new Proxy(base, {
|
|
200
|
+
get(target, prop, receiver) {
|
|
201
|
+
if (prop in extra) {
|
|
202
|
+
const v = extra[prop];
|
|
203
|
+
return typeof v === "function" ? v.bind(extra) : v;
|
|
204
|
+
}
|
|
205
|
+
const value = Reflect.get(target, prop, receiver);
|
|
206
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
export {
|
|
211
|
+
AgentProfile,
|
|
212
|
+
DeploymentsClient,
|
|
213
|
+
Naive,
|
|
214
|
+
RuntimeHandle
|
|
215
|
+
};
|
|
216
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/naive.ts","../src/agent-profile.ts","../src/runtime.ts","../src/deployments.ts","../src/transport.ts"],"sourcesContent":["/**\n * @usenaive-sdk/server — run-time SDK for your application.\n *\n * Provision and govern a real-world agent profile per tenant (identity/entity, money,\n * comms, runtime) as one unit, governed on every action and instantly revocable.\n *\n * Re-exports the full `@usenaive-sdk/node` surface for backward compatibility,\n * with an extended `Naive` that adds `forUser(id).provision(template)`,\n * `agentProfile.tools()` / `agentProfile.revoke()`, and `runtime(pool).start()`.\n */\n\n// Full back-compat surface (types, ScopedClient, helpers). The explicit `Naive`\n// export below shadows the base class re-exported here.\nexport * from \"@usenaive-sdk/node\";\n\nexport { Naive } from \"./naive.js\";\nexport type { AgentProfileScopedClient, ProvisionOptions } from \"./naive.js\";\nexport { AgentProfile } from \"./agent-profile.js\";\nexport type { AgentProfileData, AgentProfileStatus, AgentProfileStep } from \"./agent-profile.js\";\nexport { RuntimeHandle } from \"./runtime.js\";\nexport type { StartOptions, StartSystemOptions, RuntimeRun } from \"./runtime.js\";\nexport { DeploymentsClient } from \"./deployments.js\";\nexport type { DeploymentView, DeploymentResource } from \"./deployments.js\";\n\n// Type-only re-exports so apps can type config objects without a second import.\n// The declarative *builders* (defineConfig, cloud, runtime, template, policy,\n// defineModule) live in `@usenaive-sdk/iac` — import them from there (see the docs).\nexport type {\n NaiveConfig,\n TemplateConfig,\n PolicyConfig,\n ApprovalRule,\n ApprovalCondition,\n BudgetPolicy,\n SpendCap,\n SystemConfig,\n RuntimePoolConfig,\n CloudResource,\n ModuleDefinition,\n} from \"@usenaive-sdk/iac\";\n","import {\n Naive as BaseNaive,\n ScopedClient as BaseScopedClient,\n type NaiveAgentToolset,\n type NaiveOptions,\n} from \"@usenaive-sdk/node\";\nimport type { TemplateConfig } from \"@usenaive-sdk/iac\";\nimport { AgentProfile, type AgentProfileData } from \"./agent-profile.js\";\nimport { RuntimeHandle } from \"./runtime.js\";\nimport { DeploymentsClient } from \"./deployments.js\";\nimport { Transport } from \"./transport.js\";\n\n/** The comms namespace (email + phone) grouped per the agent profile positioning. */\nexport interface CommsNamespace {\n email: BaseScopedClient[\"email\"];\n phone: BaseScopedClient[\"phone\"];\n}\n\nexport interface ProvisionOptions {\n /** Make provisioning idempotent — a retried webhook resumes the same agentProfile. */\n idempotencyKey?: string;\n /** Per-tenant overrides applied on top of the template (legalName, domain, …). */\n overrides?: Record<string, unknown>;\n /** Parent agent profile id, for sub-agents that inherit a scoped-down policy + budget. */\n parent?: string;\n}\n\n/**\n * A data-plane client bound to one tenant, extended with agent profile provisioning.\n * Everything from the base `ScopedClient` (cards, comms, vault, …) is available,\n * plus `provision()` to instantiate a governed agent profile and `tools()` sugar.\n */\nexport interface AgentProfileScopedClient extends BaseScopedClient {\n /**\n * Provision a governed real-world agent profile for this tenant from a template\n * (a registered template name, or an inline `template({...})` from\n * `@usenaive-sdk/iac`). Returns immediately with status `provisioning` — entity\n * formation / KYB / A2P / DNS are async; subscribe to agent profile events.\n */\n provision(template: string | TemplateConfig, opts?: ProvisionOptions): Promise<AgentProfile>;\n /** Sugar for the tenant's governed toolset (alias of `agentTools()`). */\n tools(): NaiveAgentToolset;\n /** The tenant's comms namespace (email + phone). */\n readonly comms: CommsNamespace;\n}\n\n/**\n * The Naïve server SDK root client.\n *\n * const naive = new Naive({ apiKey: process.env.NAIVE_SECRET_KEY });\n * const op = await naive.forUser(tenant.id).provision(\"sdr\", {\n * idempotencyKey: `op:${tenant.id}`,\n * });\n * await naive.runtime(\"pool\").start(op.id, { goal: \"Run outbound.\" });\n *\n * Backward-compatible with `@usenaive-sdk/node`: the flat resource API\n * (`naive.cards.create`, `naive.comms`/`naive.email`, `forUser(id).cards.*`)\n * keeps working — agent profiles are an additive governed layer on top.\n */\nexport class Naive extends BaseNaive {\n private readonly transport: Transport;\n /** Path A deployments control plane (plan/apply/get/down) — same as `naive up`. */\n readonly deployments: DeploymentsClient;\n\n constructor(opts: NaiveOptions) {\n super(opts);\n this.transport = new Transport(opts);\n this.deployments = new DeploymentsClient(this.transport);\n }\n\n forUser(userId: string): AgentProfileScopedClient {\n const base = super.forUser(userId);\n return makeAgentProfileScoped(base, this.transport, userId);\n }\n\n /** Handle to a declared runtime pool (Naïve-hosted microVMs). */\n runtime(pool: string): RuntimeHandle {\n return new RuntimeHandle(this.transport, pool);\n }\n\n /**\n * Direct comms namespace alias. The positioning groups email/phone under\n * \"comms\"; this exposes `naive.comms.email` / `naive.comms.phone` for the\n * default tenant without breaking the flat `naive.email` / `naive.phone`.\n */\n get comms(): CommsNamespace {\n return { email: this.email, phone: this.phone };\n }\n}\n\nfunction makeAgentProfileScoped(\n base: BaseScopedClient,\n transport: Transport,\n userId: string,\n): AgentProfileScopedClient {\n const extra = {\n async provision(template: string | TemplateConfig, opts: ProvisionOptions = {}): Promise<AgentProfile> {\n const data = await transport.post<AgentProfileData>(`/v1/users/${userId}/agent-profiles`, {\n template: typeof template === \"string\" ? template : { inline: template },\n idempotency_key: opts.idempotencyKey,\n overrides: opts.overrides,\n parent: opts.parent,\n });\n return new AgentProfile(transport, data, () => base.agentTools());\n },\n tools(): NaiveAgentToolset {\n return base.agentTools();\n },\n get comms(): CommsNamespace {\n return { email: base.email, phone: base.phone };\n },\n };\n\n return new Proxy(base, {\n get(target, prop, receiver) {\n if (prop in extra) {\n const v = (extra as Record<string | symbol, unknown>)[prop];\n return typeof v === \"function\" ? (v as (...a: unknown[]) => unknown).bind(extra) : v;\n }\n const value = Reflect.get(target, prop, receiver);\n return typeof value === \"function\" ? value.bind(target) : value;\n },\n }) as unknown as AgentProfileScopedClient;\n}\n","import type { NaiveAgentToolset } from \"@usenaive-sdk/node\";\nimport type { Transport } from \"./transport.js\";\n\n/** Lifecycle of a per-tenant agent profile's regulated bundle. */\nexport type AgentProfileStatus =\n | \"provisioning\"\n | \"verifying\"\n | \"needs_action\"\n | \"active\"\n | \"failed\"\n | \"revoked\";\n\nexport interface AgentProfileStep {\n kind: string;\n status: \"pending\" | \"running\" | \"done\" | \"needs_action\" | \"awaiting_payment\" | \"failed\";\n requirement: string | null;\n}\n\nexport interface AgentProfileData {\n id: string;\n user_id: string;\n template: string;\n status: AgentProfileStatus;\n /** Surfaced when status is `needs_action` (e.g. KYB doc, A2P rejection). */\n needs_action?: { type: string; message?: string } | null;\n /** The provisioning workflow's step ledger (identity/card/comms/...). */\n steps?: AgentProfileStep[];\n /** Effective tool policy — enabled primitives + capability allow/deny. */\n tool_policy?: { enabled_primitives: string[]; capabilities: { allow: string[]; deny: string[] } };\n /** Per-agent profile scoped API key — present ONCE on provision. */\n key?: string;\n resources?: Record<string, unknown>;\n created_at?: string;\n}\n\n/**\n * A governed real-world agent profile for a single tenant: its own identity/entity,\n * card, comms, and (optionally) runtime, instantiated from a template and\n * governed at the gateway. Returned by `naive.forUser(id).provision(template)`.\n */\nexport class AgentProfile {\n readonly id: string;\n readonly userId: string;\n readonly template: string;\n status: AgentProfileStatus;\n needsAction: AgentProfileData[\"needs_action\"];\n steps: AgentProfileStep[];\n /** Effective tool policy: which primitives/capabilities this agent profile may use. */\n toolPolicy: AgentProfileData[\"tool_policy\"];\n /** Per-agent profile scoped API key — populated ONCE on provision (undefined on refresh). */\n key?: string;\n resources: Record<string, unknown>;\n\n constructor(\n private readonly http: Transport,\n data: AgentProfileData,\n private readonly toolsFactory: () => NaiveAgentToolset,\n ) {\n this.id = data.id;\n this.userId = data.user_id;\n this.template = data.template;\n this.status = data.status;\n this.needsAction = data.needs_action ?? null;\n this.steps = data.steps ?? [];\n this.toolPolicy = data.tool_policy;\n this.key = data.key;\n this.resources = data.resources ?? {};\n }\n\n /** True once identity/KYB/comms provisioning has fully completed. */\n get isActive(): boolean {\n return this.status === \"active\";\n }\n\n /**\n * The agent profile's governed toolset (Anthropic tool defs + `handle()`), ready to\n * drop into your own agent loop / Eve / LangGraph. Every call routes through\n * the Naïve governance gateway (caps, approvals, audit, revoke).\n */\n async tools(): Promise<NaiveAgentToolset> {\n return this.toolsFactory();\n }\n\n /** Re-fetch the agent profile's current status (provisioning is async). */\n async refresh(): Promise<AgentProfile> {\n const data = await this.http.get<AgentProfileData>(`/v1/agent-profiles/${this.id}`);\n this.status = data.status;\n this.needsAction = data.needs_action ?? null;\n this.steps = data.steps ?? [];\n this.toolPolicy = data.tool_policy;\n this.resources = data.resources ?? {};\n return this;\n }\n\n /**\n * Absolute revoke: freeze the card, halt sends, rotate credentials, and tear\n * down any runtime — mid-action. Revoking a parent kills the whole system.\n */\n async revoke(): Promise<{ id: string; status: AgentProfileStatus }> {\n const res = await this.http.post<{ id: string; status: AgentProfileStatus }>(\n `/v1/agent-profiles/${this.id}/revoke`,\n );\n this.status = res.status ?? \"revoked\";\n return res;\n }\n}\n","import type { Transport } from \"./transport.js\";\n\nexport interface StartOptions {\n goal?: string;\n input?: Record<string, unknown>;\n}\n\nexport interface StartSystemOptions {\n /** A registered system NAME (from naive.config.ts `systems`). When set, Naïve\n * provisions the root + members from their templates (shared budget) and starts\n * them — no need to pass UUIDs. */\n system?: string;\n /** Or start already-provisioned agent profiles by id. */\n root?: string;\n members?: string[];\n /** Human-readable coordination topology, e.g. \"manager → [a, b]\". */\n topology?: string;\n goal?: string;\n}\n\nexport interface RuntimeRun {\n id: string;\n pool: string;\n agentProfileId: string;\n status: string;\n}\n\n/**\n * Handle to a declared runtime pool (Naïve-hosted microVMs). Use this only when\n * Naïve hosts the agent; for BYO-runtime, pull `agentProfile.tools()` and run the\n * agent in your own harness / Eve / AgentCore / LangGraph instead.\n */\nexport class RuntimeHandle {\n constructor(\n private readonly http: Transport,\n readonly pool: string,\n ) {}\n\n /** Boot a single agent in the pool for an agentProfile. */\n start(agentProfileId: string, opts: StartOptions = {}): Promise<RuntimeRun> {\n return this.http.post<RuntimeRun>(`/v1/runtime/${this.pool}/start`, {\n agent_profile_id: agentProfileId,\n goal: opts.goal,\n input: opts.input,\n });\n }\n\n /**\n * Boot a multi-agent system: a parent agent profile (shared budget) plus sub-agents\n * in their own isolated microVMs. The gateway aggregates spend against the\n * parent cap; `revoke(parent)` kills the whole system.\n */\n startSystem(opts: StartSystemOptions): Promise<RuntimeRun> {\n return this.http.post<RuntimeRun>(`/v1/runtime/${this.pool}/start-system`, {\n system: opts.system,\n root: opts.root,\n members: opts.members,\n topology: opts.topology,\n goal: opts.goal,\n });\n }\n}\n","import type { Transport } from \"./transport.js\";\n\nexport interface DeploymentResource {\n name: string;\n kind: string;\n provider?: string | null;\n status: string;\n outputs: Record<string, unknown>;\n requirement?: string | null;\n error?: string | null;\n}\n\nexport interface DeploymentView {\n project: string;\n status: string;\n outputs: Record<string, unknown>;\n last_applied_at: string | null;\n resources: DeploymentResource[];\n runtime_pools: Array<{ name: string; status: string; spec: Record<string, unknown>; binding: unknown }>;\n systems: Array<{ name: string; root: string; members: string[]; topology: string | null }>;\n}\n\n/**\n * Admin surface for Path A deployments — the same lifecycle `naive up` drives.\n * Pass an evaluated `naive.config.ts` object (project + infrastructure + runtime\n * + agentProfiles + systems).\n */\nexport class DeploymentsClient {\n constructor(private readonly http: Transport) {}\n\n /** Preview the plan (diff) for a project's config without applying. */\n plan(project: string, config: Record<string, unknown>): Promise<{ plan: unknown }> {\n return this.http.put<{ plan: unknown }>(`/v1/deployments/${encodeURIComponent(project)}`, config);\n }\n\n /** Apply: provision infrastructure + register pools/systems/agent profiles. */\n apply(project: string, config: Record<string, unknown>): Promise<{ deployment: DeploymentView; plan: unknown }> {\n return this.http.post<{ deployment: DeploymentView; plan: unknown }>(\n `/v1/deployments/${encodeURIComponent(project)}/apply`,\n config,\n );\n }\n\n /** Read a project's deployment, its resources, and resolved outputs. */\n get(project: string): Promise<DeploymentView> {\n return this.http.get<DeploymentView>(`/v1/deployments/${encodeURIComponent(project)}`);\n }\n\n /** Tear down a project's provisioned infrastructure. */\n down(project: string): Promise<{ ok: boolean; destroyed: string[] }> {\n return this.http.delete<{ ok: boolean; destroyed: string[] }>(`/v1/deployments/${encodeURIComponent(project)}`);\n }\n}\n","import { NaiveError, type NaiveOptions } from \"@usenaive-sdk/node\";\n\nconst DEFAULT_BASE_URL = \"https://api.usenaive.ai\";\n\n/**\n * Minimal HTTP transport for the agent profile/runtime control-plane endpoints that\n * the base `@usenaive-sdk/node` client does not expose. Mirrors its auth +\n * error-shape conventions so errors are `NaiveError` everywhere.\n */\nexport class Transport {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly fetchImpl: typeof fetch;\n\n constructor(opts: NaiveOptions) {\n if (!opts.apiKey) throw new Error(\"Naive: apiKey is required\");\n this.apiKey = opts.apiKey;\n this.baseUrl = (opts.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.fetchImpl = opts.fetch ?? fetch;\n }\n\n async request<T>(method: string, path: string, body?: unknown): Promise<T> {\n const res = await this.fetchImpl(`${this.baseUrl}${path}`, {\n method,\n headers: {\n Authorization: `Bearer ${this.apiKey}`,\n \"Content-Type\": \"application/json\",\n },\n body: body !== undefined ? JSON.stringify(body) : undefined,\n });\n const text = await res.text();\n const data = text ? JSON.parse(text) : {};\n if (!res.ok) {\n const err = (data as { error?: Record<string, unknown> }).error ?? data;\n const e = err as { code?: string; message?: string; hint?: string; details?: Record<string, unknown> };\n throw new NaiveError(res.status, e.code ?? \"unknown\", e.message ?? res.statusText, e.hint, e.details);\n }\n return data as T;\n }\n\n get<T>(path: string): Promise<T> {\n return this.request<T>(\"GET\", path);\n }\n post<T>(path: string, body?: unknown): Promise<T> {\n return this.request<T>(\"POST\", path, body);\n }\n put<T>(path: string, body?: unknown): Promise<T> {\n return this.request<T>(\"PUT\", path, body);\n }\n delete<T>(path: string): Promise<T> {\n return this.request<T>(\"DELETE\", path);\n }\n}\n"],"mappings":";AAaA,cAAc;;;ACbd;AAAA,EACE,SAAS;AAAA,OAIJ;;;ACmCA,IAAM,eAAN,MAAmB;AAAA,EAaxB,YACmB,MACjB,MACiB,cACjB;AAHiB;AAEA;AAEjB,SAAK,KAAK,KAAK;AACf,SAAK,SAAS,KAAK;AACnB,SAAK,WAAW,KAAK;AACrB,SAAK,SAAS,KAAK;AACnB,SAAK,cAAc,KAAK,gBAAgB;AACxC,SAAK,QAAQ,KAAK,SAAS,CAAC;AAC5B,SAAK,aAAa,KAAK;AACvB,SAAK,MAAM,KAAK;AAChB,SAAK,YAAY,KAAK,aAAa,CAAC;AAAA,EACtC;AAAA;AAAA,EAGA,IAAI,WAAoB;AACtB,WAAO,KAAK,WAAW;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,QAAoC;AACxC,WAAO,KAAK,aAAa;AAAA,EAC3B;AAAA;AAAA,EAGA,MAAM,UAAiC;AACrC,UAAM,OAAO,MAAM,KAAK,KAAK,IAAsB,sBAAsB,KAAK,EAAE,EAAE;AAClF,SAAK,SAAS,KAAK;AACnB,SAAK,cAAc,KAAK,gBAAgB;AACxC,SAAK,QAAQ,KAAK,SAAS,CAAC;AAC5B,SAAK,aAAa,KAAK;AACvB,SAAK,YA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jB,cAAM,IAAK,MAA2C,IAAI;AAC1D,eAAO,OAAO,MAAM,aAAc,EAAmC,KAAK,KAAK,IAAI;AAAA,MACrF;AACA,YAAM,QAAQ,QAAQ,IAAI,QAAQ,MAAM,QAAQ;AAChD,aAAO,OAAO,UAAU,aAAa,MAAM,KAAK,MAAM,IAAI;AAAA,IAC5D;AAAA,EACF,CAAC;AACH;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@usenaive-sdk/server",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Naïve server SDK — provision and govern a real-world agent profile per tenant (identity, money, comms, runtime) from your application.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"require": "./dist/index.cjs"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@usenaive-sdk/node": "0.12.0",
|
|
25
|
+
"@usenaive-sdk/iac": "0.1.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^22.15.3",
|
|
29
|
+
"tsup": "^8.0.0",
|
|
30
|
+
"typescript": "^5.7.3",
|
|
31
|
+
"vitest": "^2.1.0"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsup",
|
|
35
|
+
"typecheck": "tsc --noEmit",
|
|
36
|
+
"test": "vitest run"
|
|
37
|
+
}
|
|
38
|
+
}
|