maritime-sdk 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/README.md +138 -0
- package/dist/index.cjs +424 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +287 -0
- package/dist/index.d.ts +287 -0
- package/dist/index.js +389 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
interface MaritimeClientOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Maritime API key (`mk_...`). Defaults to the `MARITIME_API_KEY` env var.
|
|
4
|
+
* Mint one from the dashboard (Settings → API keys) or `maritime keys create`.
|
|
5
|
+
*/
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
/** API base URL. Defaults to `MARITIME_API_URL` or `https://api.maritime.sh`. */
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
/** Per-request timeout in ms (default 60_000). */
|
|
10
|
+
timeout?: number;
|
|
11
|
+
/** Retries on network errors and 5xx/429 responses (default 2). */
|
|
12
|
+
maxRetries?: number;
|
|
13
|
+
/** Inject a custom fetch (tests, proxies, non-global-fetch runtimes). */
|
|
14
|
+
fetch?: typeof fetch;
|
|
15
|
+
/** Extra headers sent on every request. */
|
|
16
|
+
defaultHeaders?: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
interface RequestOptions {
|
|
19
|
+
method: string;
|
|
20
|
+
path: string;
|
|
21
|
+
query?: Record<string, string | number | boolean | undefined | null>;
|
|
22
|
+
body?: unknown;
|
|
23
|
+
/** Override retry behaviour for a single call (e.g. non-idempotent POST). */
|
|
24
|
+
idempotent?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Thin transport: auth header, JSON encode/decode, typed errors, and bounded
|
|
28
|
+
* retry with exponential backoff on transient failures. No dependencies —
|
|
29
|
+
* uses the runtime's global `fetch` (Node 18+, Bun, Deno, browsers, edge).
|
|
30
|
+
*/
|
|
31
|
+
declare class HttpClient {
|
|
32
|
+
private readonly apiKey;
|
|
33
|
+
private readonly baseUrl;
|
|
34
|
+
private readonly timeout;
|
|
35
|
+
private readonly maxRetries;
|
|
36
|
+
private readonly fetchImpl;
|
|
37
|
+
private readonly defaultHeaders;
|
|
38
|
+
constructor(options?: MaritimeClientOptions);
|
|
39
|
+
private buildUrl;
|
|
40
|
+
request<T>(opts: RequestOptions): Promise<T>;
|
|
41
|
+
private backoff;
|
|
42
|
+
private parseBody;
|
|
43
|
+
private safeDetail;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Framework/template ids accepted by Maritime. Any string is allowed (the API
|
|
47
|
+
* is the source of truth) but these are the common ones with editor help. */
|
|
48
|
+
type Template = 'openclaw' | 'openclaw_identity' | 'openclaw_browser' | 'maritime' | 'hermes' | 'hermes_identity' | 'zeroclaw' | (string & {});
|
|
49
|
+
type Tier = 'smart' | 'extended' | 'always_on';
|
|
50
|
+
type AgentStatus = 'sleeping' | 'active' | 'deploying' | 'error' | 'stopped';
|
|
51
|
+
/** One env var to seed at create time. */
|
|
52
|
+
interface EnvVarInput {
|
|
53
|
+
key: string;
|
|
54
|
+
value: string;
|
|
55
|
+
/** Encrypt at rest + mask in reads. Defaults to true. */
|
|
56
|
+
secret?: boolean;
|
|
57
|
+
}
|
|
58
|
+
interface CreateAgentParams {
|
|
59
|
+
/** Unique (per account) agent name. */
|
|
60
|
+
name: string;
|
|
61
|
+
/** Template/framework. Strongly recommended — a bare framework yields a broken
|
|
62
|
+
* placeholder image. Defaults to `openclaw` in {@link AgentsResource.provision}. */
|
|
63
|
+
template?: Template;
|
|
64
|
+
/** Your own id for this agent (e.g. your end-customer id). Filterable later. */
|
|
65
|
+
externalId?: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
/** Plain-English persona / system prompt. */
|
|
68
|
+
instructions?: string;
|
|
69
|
+
tier?: Tier;
|
|
70
|
+
/** Seed env vars (API keys, config). Secrets are encrypted at rest. */
|
|
71
|
+
env?: EnvVarInput[];
|
|
72
|
+
/** Per-agent resource overrides (else the tier default applies). */
|
|
73
|
+
memMb?: number;
|
|
74
|
+
vcpus?: number;
|
|
75
|
+
/** Idle seconds before auto-sleep. 0 = always-on. */
|
|
76
|
+
idleTtlSeconds?: number;
|
|
77
|
+
diskGb?: number;
|
|
78
|
+
/** GitHub repo to build from instead of a template image. */
|
|
79
|
+
githubRepo?: string;
|
|
80
|
+
/** Explicit Docker image (advanced; usually use `template`). */
|
|
81
|
+
imageName?: string;
|
|
82
|
+
}
|
|
83
|
+
interface Agent {
|
|
84
|
+
id: string;
|
|
85
|
+
name: string;
|
|
86
|
+
description: string | null;
|
|
87
|
+
externalId: string | null;
|
|
88
|
+
framework: string;
|
|
89
|
+
tier: Tier;
|
|
90
|
+
status: AgentStatus;
|
|
91
|
+
publicUrl?: string | null;
|
|
92
|
+
invocationCount: number;
|
|
93
|
+
totalComputeSeconds: number;
|
|
94
|
+
createdAt: string;
|
|
95
|
+
updatedAt: string;
|
|
96
|
+
[key: string]: unknown;
|
|
97
|
+
}
|
|
98
|
+
interface EnvVar {
|
|
99
|
+
key: string;
|
|
100
|
+
value: string;
|
|
101
|
+
isSecret: boolean;
|
|
102
|
+
}
|
|
103
|
+
interface LogEntry {
|
|
104
|
+
id: string;
|
|
105
|
+
level: string;
|
|
106
|
+
message: string;
|
|
107
|
+
source?: string | null;
|
|
108
|
+
timestamp: string | null;
|
|
109
|
+
}
|
|
110
|
+
interface ChatResult {
|
|
111
|
+
/** The agent's reply, or null if delivery failed (see `error`). */
|
|
112
|
+
response: string | null;
|
|
113
|
+
error?: string;
|
|
114
|
+
}
|
|
115
|
+
interface ListAgentsParams {
|
|
116
|
+
/** Exact-match filter on the caller-supplied external id. */
|
|
117
|
+
externalId?: string;
|
|
118
|
+
/** Exact-match filter on agent name. */
|
|
119
|
+
name?: string;
|
|
120
|
+
}
|
|
121
|
+
interface ChatOptions {
|
|
122
|
+
conversationId?: string;
|
|
123
|
+
}
|
|
124
|
+
type ApiKeyScope = 'provision' | 'deploy' | 'secrets' | 'manage' | (string & {});
|
|
125
|
+
interface CreateApiKeyParams {
|
|
126
|
+
name: string;
|
|
127
|
+
/** Defaults to a full-access key. Pass a narrower set to restrict it. */
|
|
128
|
+
scopes?: ApiKeyScope[];
|
|
129
|
+
/** Expiry in days from now. Omit for a non-expiring key. */
|
|
130
|
+
expiresInDays?: number;
|
|
131
|
+
}
|
|
132
|
+
interface ApiKey {
|
|
133
|
+
id: string;
|
|
134
|
+
name: string;
|
|
135
|
+
keyPrefix: string;
|
|
136
|
+
scopes: string[];
|
|
137
|
+
isActive: boolean;
|
|
138
|
+
lastUsedAt: string | null;
|
|
139
|
+
expiresAt: string | null;
|
|
140
|
+
createdAt: string;
|
|
141
|
+
}
|
|
142
|
+
interface CreatedApiKey extends ApiKey {
|
|
143
|
+
/** The full key — shown once. Store it now. */
|
|
144
|
+
rawKey: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Operations on Maritime agents. Access via `maritime.agents`. */
|
|
148
|
+
declare class AgentsResource {
|
|
149
|
+
private readonly http;
|
|
150
|
+
constructor(http: HttpClient);
|
|
151
|
+
/** Create a new agent and kick off its deploy. */
|
|
152
|
+
create(params: CreateAgentParams): Promise<Agent>;
|
|
153
|
+
/**
|
|
154
|
+
* Get-or-create an agent by `externalId` — the idempotent entry point for a
|
|
155
|
+
* "one agent per end-customer" flow. If an agent with that external id
|
|
156
|
+
* already exists it is returned; otherwise a new one is created. Safe to call
|
|
157
|
+
* on every sign-in.
|
|
158
|
+
*/
|
|
159
|
+
provision(params: CreateAgentParams & {
|
|
160
|
+
externalId: string;
|
|
161
|
+
}): Promise<Agent>;
|
|
162
|
+
/** Fetch a single agent by id. */
|
|
163
|
+
get(agentId: string): Promise<Agent>;
|
|
164
|
+
/** List agents, optionally filtered by `externalId` or `name`. */
|
|
165
|
+
list(params?: ListAgentsParams): Promise<Agent[]>;
|
|
166
|
+
/**
|
|
167
|
+
* Send a message to an agent and wait for its reply. Sleeping serverless
|
|
168
|
+
* agents auto-wake. Returns `{ response }` (or `{ response: null, error }`
|
|
169
|
+
* if delivery failed — Maritime does not surface that as an HTTP error).
|
|
170
|
+
*/
|
|
171
|
+
chat(agentId: string, message: string, opts?: ChatOptions): Promise<ChatResult>;
|
|
172
|
+
/** Start / wake an agent. */
|
|
173
|
+
start(agentId: string): Promise<Agent>;
|
|
174
|
+
/** Stop an agent (container stopped, state preserved). */
|
|
175
|
+
stop(agentId: string): Promise<Agent>;
|
|
176
|
+
/** Put an agent to sleep (serverless snapshot; cheapest resting state). */
|
|
177
|
+
sleep(agentId: string): Promise<Agent>;
|
|
178
|
+
/** Restart an agent. */
|
|
179
|
+
restart(agentId: string): Promise<Agent>;
|
|
180
|
+
/** Delete an agent and all its resources (container, volume, network). */
|
|
181
|
+
delete(agentId: string): Promise<void>;
|
|
182
|
+
/** List an agent's env vars (secret values are masked). */
|
|
183
|
+
listEnv(agentId: string): Promise<EnvVar[]>;
|
|
184
|
+
/**
|
|
185
|
+
* Set (upsert) an env var. Secrets are encrypted at rest. Changes reach a
|
|
186
|
+
* running container after {@link reloadEnv} or a restart.
|
|
187
|
+
*/
|
|
188
|
+
setEnv(agentId: string, key: string, value: string, opts?: {
|
|
189
|
+
secret?: boolean;
|
|
190
|
+
}): Promise<EnvVar>;
|
|
191
|
+
/** Delete an env var. */
|
|
192
|
+
deleteEnv(agentId: string, key: string): Promise<void>;
|
|
193
|
+
/** Hot-reload env vars into the running container (falls back to restart). */
|
|
194
|
+
reloadEnv(agentId: string): Promise<Agent>;
|
|
195
|
+
/** Fetch recent log entries for an agent. */
|
|
196
|
+
logs(agentId: string, opts?: {
|
|
197
|
+
limit?: number;
|
|
198
|
+
level?: string;
|
|
199
|
+
}): Promise<LogEntry[]>;
|
|
200
|
+
private lifecycle;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Manage API keys (`mk_...`) programmatically. Access via `maritime.keys`.
|
|
205
|
+
*
|
|
206
|
+
* Minting a key requires the caller's own key to carry the `manage` scope (or
|
|
207
|
+
* be a dashboard session). Hand a narrower-scoped key to a subsystem that only
|
|
208
|
+
* needs part of the surface — e.g. a `deploy`-scoped key for a worker that only
|
|
209
|
+
* chats to agents.
|
|
210
|
+
*/
|
|
211
|
+
declare class KeysResource {
|
|
212
|
+
private readonly http;
|
|
213
|
+
constructor(http: HttpClient);
|
|
214
|
+
/** Mint a new key. The raw key is returned once — store it immediately. */
|
|
215
|
+
create(params: CreateApiKeyParams): Promise<CreatedApiKey>;
|
|
216
|
+
/** List the caller's keys (raw values are never returned again). */
|
|
217
|
+
list(): Promise<ApiKey[]>;
|
|
218
|
+
/** Revoke a key by id. */
|
|
219
|
+
revoke(keyId: string): Promise<void>;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** Base class for every error the SDK throws. Catch this to catch them all. */
|
|
223
|
+
declare class MaritimeError extends Error {
|
|
224
|
+
constructor(message: string);
|
|
225
|
+
}
|
|
226
|
+
/** The request never reached Maritime (DNS, connection refused, timeout, …). */
|
|
227
|
+
declare class MaritimeConnectionError extends MaritimeError {
|
|
228
|
+
readonly cause?: unknown;
|
|
229
|
+
constructor(message: string, cause?: unknown);
|
|
230
|
+
}
|
|
231
|
+
/** Maritime returned a non-2xx response. Subclassed by status below. */
|
|
232
|
+
declare class MaritimeAPIError extends MaritimeError {
|
|
233
|
+
readonly status: number;
|
|
234
|
+
readonly detail: string;
|
|
235
|
+
/** Value of the `x-request-id` response header, when present. */
|
|
236
|
+
readonly requestId?: string;
|
|
237
|
+
constructor(status: number, detail: string, requestId?: string);
|
|
238
|
+
}
|
|
239
|
+
/** 401 / 403 — bad or insufficiently-scoped API key. */
|
|
240
|
+
declare class MaritimeAuthError extends MaritimeAPIError {
|
|
241
|
+
constructor(status: number, detail: string, requestId?: string);
|
|
242
|
+
}
|
|
243
|
+
/** 402 — the account wallet needs funding before this action can proceed. */
|
|
244
|
+
declare class MaritimePaymentRequiredError extends MaritimeAPIError {
|
|
245
|
+
constructor(status: number, detail: string, requestId?: string);
|
|
246
|
+
}
|
|
247
|
+
/** 404 — the agent (or other resource) does not exist or is not yours. */
|
|
248
|
+
declare class MaritimeNotFoundError extends MaritimeAPIError {
|
|
249
|
+
constructor(status: number, detail: string, requestId?: string);
|
|
250
|
+
}
|
|
251
|
+
/** 409 — a uniqueness conflict (e.g. an agent with that name already exists). */
|
|
252
|
+
declare class MaritimeConflictError extends MaritimeAPIError {
|
|
253
|
+
constructor(status: number, detail: string, requestId?: string);
|
|
254
|
+
}
|
|
255
|
+
/** 429 — rate limited. */
|
|
256
|
+
declare class MaritimeRateLimitError extends MaritimeAPIError {
|
|
257
|
+
constructor(status: number, detail: string, requestId?: string);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* The Maritime client. Provision and drive AI agents on Maritime's serverless
|
|
262
|
+
* infrastructure from your own backend.
|
|
263
|
+
*
|
|
264
|
+
* ```ts
|
|
265
|
+
* import { Maritime } from 'maritime-sdk'
|
|
266
|
+
*
|
|
267
|
+
* const maritime = new Maritime({ apiKey: process.env.MARITIME_API_KEY })
|
|
268
|
+
*
|
|
269
|
+
* // When YOUR user signs up, give them their own agent (idempotent):
|
|
270
|
+
* const agent = await maritime.agents.provision({
|
|
271
|
+
* externalId: `customer_${userId}`,
|
|
272
|
+
* name: `assistant-${userId}`,
|
|
273
|
+
* template: 'openclaw',
|
|
274
|
+
* })
|
|
275
|
+
*
|
|
276
|
+
* const { response } = await maritime.agents.chat(agent.id, 'Hello!')
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
declare class Maritime {
|
|
280
|
+
readonly agents: AgentsResource;
|
|
281
|
+
readonly keys: KeysResource;
|
|
282
|
+
/** The underlying transport — escape hatch for endpoints not yet wrapped. */
|
|
283
|
+
readonly http: HttpClient;
|
|
284
|
+
constructor(options?: MaritimeClientOptions);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export { type Agent, type AgentStatus, type ApiKey, type ApiKeyScope, type ChatOptions, type ChatResult, type CreateAgentParams, type CreateApiKeyParams, type CreatedApiKey, type EnvVar, type EnvVarInput, type ListAgentsParams, type LogEntry, Maritime, MaritimeAPIError, MaritimeAuthError, type MaritimeClientOptions, MaritimeConflictError, MaritimeConnectionError, MaritimeError, MaritimeNotFoundError, MaritimePaymentRequiredError, MaritimeRateLimitError, type Template, type Tier, Maritime as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
interface MaritimeClientOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Maritime API key (`mk_...`). Defaults to the `MARITIME_API_KEY` env var.
|
|
4
|
+
* Mint one from the dashboard (Settings → API keys) or `maritime keys create`.
|
|
5
|
+
*/
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
/** API base URL. Defaults to `MARITIME_API_URL` or `https://api.maritime.sh`. */
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
/** Per-request timeout in ms (default 60_000). */
|
|
10
|
+
timeout?: number;
|
|
11
|
+
/** Retries on network errors and 5xx/429 responses (default 2). */
|
|
12
|
+
maxRetries?: number;
|
|
13
|
+
/** Inject a custom fetch (tests, proxies, non-global-fetch runtimes). */
|
|
14
|
+
fetch?: typeof fetch;
|
|
15
|
+
/** Extra headers sent on every request. */
|
|
16
|
+
defaultHeaders?: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
interface RequestOptions {
|
|
19
|
+
method: string;
|
|
20
|
+
path: string;
|
|
21
|
+
query?: Record<string, string | number | boolean | undefined | null>;
|
|
22
|
+
body?: unknown;
|
|
23
|
+
/** Override retry behaviour for a single call (e.g. non-idempotent POST). */
|
|
24
|
+
idempotent?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Thin transport: auth header, JSON encode/decode, typed errors, and bounded
|
|
28
|
+
* retry with exponential backoff on transient failures. No dependencies —
|
|
29
|
+
* uses the runtime's global `fetch` (Node 18+, Bun, Deno, browsers, edge).
|
|
30
|
+
*/
|
|
31
|
+
declare class HttpClient {
|
|
32
|
+
private readonly apiKey;
|
|
33
|
+
private readonly baseUrl;
|
|
34
|
+
private readonly timeout;
|
|
35
|
+
private readonly maxRetries;
|
|
36
|
+
private readonly fetchImpl;
|
|
37
|
+
private readonly defaultHeaders;
|
|
38
|
+
constructor(options?: MaritimeClientOptions);
|
|
39
|
+
private buildUrl;
|
|
40
|
+
request<T>(opts: RequestOptions): Promise<T>;
|
|
41
|
+
private backoff;
|
|
42
|
+
private parseBody;
|
|
43
|
+
private safeDetail;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Framework/template ids accepted by Maritime. Any string is allowed (the API
|
|
47
|
+
* is the source of truth) but these are the common ones with editor help. */
|
|
48
|
+
type Template = 'openclaw' | 'openclaw_identity' | 'openclaw_browser' | 'maritime' | 'hermes' | 'hermes_identity' | 'zeroclaw' | (string & {});
|
|
49
|
+
type Tier = 'smart' | 'extended' | 'always_on';
|
|
50
|
+
type AgentStatus = 'sleeping' | 'active' | 'deploying' | 'error' | 'stopped';
|
|
51
|
+
/** One env var to seed at create time. */
|
|
52
|
+
interface EnvVarInput {
|
|
53
|
+
key: string;
|
|
54
|
+
value: string;
|
|
55
|
+
/** Encrypt at rest + mask in reads. Defaults to true. */
|
|
56
|
+
secret?: boolean;
|
|
57
|
+
}
|
|
58
|
+
interface CreateAgentParams {
|
|
59
|
+
/** Unique (per account) agent name. */
|
|
60
|
+
name: string;
|
|
61
|
+
/** Template/framework. Strongly recommended — a bare framework yields a broken
|
|
62
|
+
* placeholder image. Defaults to `openclaw` in {@link AgentsResource.provision}. */
|
|
63
|
+
template?: Template;
|
|
64
|
+
/** Your own id for this agent (e.g. your end-customer id). Filterable later. */
|
|
65
|
+
externalId?: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
/** Plain-English persona / system prompt. */
|
|
68
|
+
instructions?: string;
|
|
69
|
+
tier?: Tier;
|
|
70
|
+
/** Seed env vars (API keys, config). Secrets are encrypted at rest. */
|
|
71
|
+
env?: EnvVarInput[];
|
|
72
|
+
/** Per-agent resource overrides (else the tier default applies). */
|
|
73
|
+
memMb?: number;
|
|
74
|
+
vcpus?: number;
|
|
75
|
+
/** Idle seconds before auto-sleep. 0 = always-on. */
|
|
76
|
+
idleTtlSeconds?: number;
|
|
77
|
+
diskGb?: number;
|
|
78
|
+
/** GitHub repo to build from instead of a template image. */
|
|
79
|
+
githubRepo?: string;
|
|
80
|
+
/** Explicit Docker image (advanced; usually use `template`). */
|
|
81
|
+
imageName?: string;
|
|
82
|
+
}
|
|
83
|
+
interface Agent {
|
|
84
|
+
id: string;
|
|
85
|
+
name: string;
|
|
86
|
+
description: string | null;
|
|
87
|
+
externalId: string | null;
|
|
88
|
+
framework: string;
|
|
89
|
+
tier: Tier;
|
|
90
|
+
status: AgentStatus;
|
|
91
|
+
publicUrl?: string | null;
|
|
92
|
+
invocationCount: number;
|
|
93
|
+
totalComputeSeconds: number;
|
|
94
|
+
createdAt: string;
|
|
95
|
+
updatedAt: string;
|
|
96
|
+
[key: string]: unknown;
|
|
97
|
+
}
|
|
98
|
+
interface EnvVar {
|
|
99
|
+
key: string;
|
|
100
|
+
value: string;
|
|
101
|
+
isSecret: boolean;
|
|
102
|
+
}
|
|
103
|
+
interface LogEntry {
|
|
104
|
+
id: string;
|
|
105
|
+
level: string;
|
|
106
|
+
message: string;
|
|
107
|
+
source?: string | null;
|
|
108
|
+
timestamp: string | null;
|
|
109
|
+
}
|
|
110
|
+
interface ChatResult {
|
|
111
|
+
/** The agent's reply, or null if delivery failed (see `error`). */
|
|
112
|
+
response: string | null;
|
|
113
|
+
error?: string;
|
|
114
|
+
}
|
|
115
|
+
interface ListAgentsParams {
|
|
116
|
+
/** Exact-match filter on the caller-supplied external id. */
|
|
117
|
+
externalId?: string;
|
|
118
|
+
/** Exact-match filter on agent name. */
|
|
119
|
+
name?: string;
|
|
120
|
+
}
|
|
121
|
+
interface ChatOptions {
|
|
122
|
+
conversationId?: string;
|
|
123
|
+
}
|
|
124
|
+
type ApiKeyScope = 'provision' | 'deploy' | 'secrets' | 'manage' | (string & {});
|
|
125
|
+
interface CreateApiKeyParams {
|
|
126
|
+
name: string;
|
|
127
|
+
/** Defaults to a full-access key. Pass a narrower set to restrict it. */
|
|
128
|
+
scopes?: ApiKeyScope[];
|
|
129
|
+
/** Expiry in days from now. Omit for a non-expiring key. */
|
|
130
|
+
expiresInDays?: number;
|
|
131
|
+
}
|
|
132
|
+
interface ApiKey {
|
|
133
|
+
id: string;
|
|
134
|
+
name: string;
|
|
135
|
+
keyPrefix: string;
|
|
136
|
+
scopes: string[];
|
|
137
|
+
isActive: boolean;
|
|
138
|
+
lastUsedAt: string | null;
|
|
139
|
+
expiresAt: string | null;
|
|
140
|
+
createdAt: string;
|
|
141
|
+
}
|
|
142
|
+
interface CreatedApiKey extends ApiKey {
|
|
143
|
+
/** The full key — shown once. Store it now. */
|
|
144
|
+
rawKey: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Operations on Maritime agents. Access via `maritime.agents`. */
|
|
148
|
+
declare class AgentsResource {
|
|
149
|
+
private readonly http;
|
|
150
|
+
constructor(http: HttpClient);
|
|
151
|
+
/** Create a new agent and kick off its deploy. */
|
|
152
|
+
create(params: CreateAgentParams): Promise<Agent>;
|
|
153
|
+
/**
|
|
154
|
+
* Get-or-create an agent by `externalId` — the idempotent entry point for a
|
|
155
|
+
* "one agent per end-customer" flow. If an agent with that external id
|
|
156
|
+
* already exists it is returned; otherwise a new one is created. Safe to call
|
|
157
|
+
* on every sign-in.
|
|
158
|
+
*/
|
|
159
|
+
provision(params: CreateAgentParams & {
|
|
160
|
+
externalId: string;
|
|
161
|
+
}): Promise<Agent>;
|
|
162
|
+
/** Fetch a single agent by id. */
|
|
163
|
+
get(agentId: string): Promise<Agent>;
|
|
164
|
+
/** List agents, optionally filtered by `externalId` or `name`. */
|
|
165
|
+
list(params?: ListAgentsParams): Promise<Agent[]>;
|
|
166
|
+
/**
|
|
167
|
+
* Send a message to an agent and wait for its reply. Sleeping serverless
|
|
168
|
+
* agents auto-wake. Returns `{ response }` (or `{ response: null, error }`
|
|
169
|
+
* if delivery failed — Maritime does not surface that as an HTTP error).
|
|
170
|
+
*/
|
|
171
|
+
chat(agentId: string, message: string, opts?: ChatOptions): Promise<ChatResult>;
|
|
172
|
+
/** Start / wake an agent. */
|
|
173
|
+
start(agentId: string): Promise<Agent>;
|
|
174
|
+
/** Stop an agent (container stopped, state preserved). */
|
|
175
|
+
stop(agentId: string): Promise<Agent>;
|
|
176
|
+
/** Put an agent to sleep (serverless snapshot; cheapest resting state). */
|
|
177
|
+
sleep(agentId: string): Promise<Agent>;
|
|
178
|
+
/** Restart an agent. */
|
|
179
|
+
restart(agentId: string): Promise<Agent>;
|
|
180
|
+
/** Delete an agent and all its resources (container, volume, network). */
|
|
181
|
+
delete(agentId: string): Promise<void>;
|
|
182
|
+
/** List an agent's env vars (secret values are masked). */
|
|
183
|
+
listEnv(agentId: string): Promise<EnvVar[]>;
|
|
184
|
+
/**
|
|
185
|
+
* Set (upsert) an env var. Secrets are encrypted at rest. Changes reach a
|
|
186
|
+
* running container after {@link reloadEnv} or a restart.
|
|
187
|
+
*/
|
|
188
|
+
setEnv(agentId: string, key: string, value: string, opts?: {
|
|
189
|
+
secret?: boolean;
|
|
190
|
+
}): Promise<EnvVar>;
|
|
191
|
+
/** Delete an env var. */
|
|
192
|
+
deleteEnv(agentId: string, key: string): Promise<void>;
|
|
193
|
+
/** Hot-reload env vars into the running container (falls back to restart). */
|
|
194
|
+
reloadEnv(agentId: string): Promise<Agent>;
|
|
195
|
+
/** Fetch recent log entries for an agent. */
|
|
196
|
+
logs(agentId: string, opts?: {
|
|
197
|
+
limit?: number;
|
|
198
|
+
level?: string;
|
|
199
|
+
}): Promise<LogEntry[]>;
|
|
200
|
+
private lifecycle;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Manage API keys (`mk_...`) programmatically. Access via `maritime.keys`.
|
|
205
|
+
*
|
|
206
|
+
* Minting a key requires the caller's own key to carry the `manage` scope (or
|
|
207
|
+
* be a dashboard session). Hand a narrower-scoped key to a subsystem that only
|
|
208
|
+
* needs part of the surface — e.g. a `deploy`-scoped key for a worker that only
|
|
209
|
+
* chats to agents.
|
|
210
|
+
*/
|
|
211
|
+
declare class KeysResource {
|
|
212
|
+
private readonly http;
|
|
213
|
+
constructor(http: HttpClient);
|
|
214
|
+
/** Mint a new key. The raw key is returned once — store it immediately. */
|
|
215
|
+
create(params: CreateApiKeyParams): Promise<CreatedApiKey>;
|
|
216
|
+
/** List the caller's keys (raw values are never returned again). */
|
|
217
|
+
list(): Promise<ApiKey[]>;
|
|
218
|
+
/** Revoke a key by id. */
|
|
219
|
+
revoke(keyId: string): Promise<void>;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** Base class for every error the SDK throws. Catch this to catch them all. */
|
|
223
|
+
declare class MaritimeError extends Error {
|
|
224
|
+
constructor(message: string);
|
|
225
|
+
}
|
|
226
|
+
/** The request never reached Maritime (DNS, connection refused, timeout, …). */
|
|
227
|
+
declare class MaritimeConnectionError extends MaritimeError {
|
|
228
|
+
readonly cause?: unknown;
|
|
229
|
+
constructor(message: string, cause?: unknown);
|
|
230
|
+
}
|
|
231
|
+
/** Maritime returned a non-2xx response. Subclassed by status below. */
|
|
232
|
+
declare class MaritimeAPIError extends MaritimeError {
|
|
233
|
+
readonly status: number;
|
|
234
|
+
readonly detail: string;
|
|
235
|
+
/** Value of the `x-request-id` response header, when present. */
|
|
236
|
+
readonly requestId?: string;
|
|
237
|
+
constructor(status: number, detail: string, requestId?: string);
|
|
238
|
+
}
|
|
239
|
+
/** 401 / 403 — bad or insufficiently-scoped API key. */
|
|
240
|
+
declare class MaritimeAuthError extends MaritimeAPIError {
|
|
241
|
+
constructor(status: number, detail: string, requestId?: string);
|
|
242
|
+
}
|
|
243
|
+
/** 402 — the account wallet needs funding before this action can proceed. */
|
|
244
|
+
declare class MaritimePaymentRequiredError extends MaritimeAPIError {
|
|
245
|
+
constructor(status: number, detail: string, requestId?: string);
|
|
246
|
+
}
|
|
247
|
+
/** 404 — the agent (or other resource) does not exist or is not yours. */
|
|
248
|
+
declare class MaritimeNotFoundError extends MaritimeAPIError {
|
|
249
|
+
constructor(status: number, detail: string, requestId?: string);
|
|
250
|
+
}
|
|
251
|
+
/** 409 — a uniqueness conflict (e.g. an agent with that name already exists). */
|
|
252
|
+
declare class MaritimeConflictError extends MaritimeAPIError {
|
|
253
|
+
constructor(status: number, detail: string, requestId?: string);
|
|
254
|
+
}
|
|
255
|
+
/** 429 — rate limited. */
|
|
256
|
+
declare class MaritimeRateLimitError extends MaritimeAPIError {
|
|
257
|
+
constructor(status: number, detail: string, requestId?: string);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* The Maritime client. Provision and drive AI agents on Maritime's serverless
|
|
262
|
+
* infrastructure from your own backend.
|
|
263
|
+
*
|
|
264
|
+
* ```ts
|
|
265
|
+
* import { Maritime } from 'maritime-sdk'
|
|
266
|
+
*
|
|
267
|
+
* const maritime = new Maritime({ apiKey: process.env.MARITIME_API_KEY })
|
|
268
|
+
*
|
|
269
|
+
* // When YOUR user signs up, give them their own agent (idempotent):
|
|
270
|
+
* const agent = await maritime.agents.provision({
|
|
271
|
+
* externalId: `customer_${userId}`,
|
|
272
|
+
* name: `assistant-${userId}`,
|
|
273
|
+
* template: 'openclaw',
|
|
274
|
+
* })
|
|
275
|
+
*
|
|
276
|
+
* const { response } = await maritime.agents.chat(agent.id, 'Hello!')
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
declare class Maritime {
|
|
280
|
+
readonly agents: AgentsResource;
|
|
281
|
+
readonly keys: KeysResource;
|
|
282
|
+
/** The underlying transport — escape hatch for endpoints not yet wrapped. */
|
|
283
|
+
readonly http: HttpClient;
|
|
284
|
+
constructor(options?: MaritimeClientOptions);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export { type Agent, type AgentStatus, type ApiKey, type ApiKeyScope, type ChatOptions, type ChatResult, type CreateAgentParams, type CreateApiKeyParams, type CreatedApiKey, type EnvVar, type EnvVarInput, type ListAgentsParams, type LogEntry, Maritime, MaritimeAPIError, MaritimeAuthError, type MaritimeClientOptions, MaritimeConflictError, MaritimeConnectionError, MaritimeError, MaritimeNotFoundError, MaritimePaymentRequiredError, MaritimeRateLimitError, type Template, type Tier, Maritime as default };
|