maritime-sdk 0.1.0 → 0.2.1

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 CHANGED
@@ -400,12 +400,46 @@ var KeysResource = class {
400
400
  }
401
401
  };
402
402
 
403
+ // src/resources/webhooks.ts
404
+ var WebhooksResource = class {
405
+ constructor(http) {
406
+ this.http = http;
407
+ }
408
+ /** Create a subscription. The signing `secret` is returned once. */
409
+ async create(params) {
410
+ return this.http.request({
411
+ method: "POST",
412
+ path: "/api/v1/webhooks",
413
+ body: { url: params.url, events: params.events ?? [] }
414
+ });
415
+ }
416
+ /** List your subscriptions (secrets are never returned again). */
417
+ async list() {
418
+ return this.http.request({ method: "GET", path: "/api/v1/webhooks" });
419
+ }
420
+ /** Delete a subscription. */
421
+ async delete(id) {
422
+ await this.http.request({
423
+ method: "DELETE",
424
+ path: `/api/v1/webhooks/${encodeURIComponent(id)}`
425
+ });
426
+ }
427
+ /** Send a synthetic `ping` to the subscription's URL and return the result. */
428
+ async test(id) {
429
+ return this.http.request({
430
+ method: "POST",
431
+ path: `/api/v1/webhooks/${encodeURIComponent(id)}/test`
432
+ });
433
+ }
434
+ };
435
+
403
436
  // src/index.ts
404
437
  var Maritime = class {
405
438
  constructor(options = {}) {
406
439
  this.http = new HttpClient(options);
407
440
  this.agents = new AgentsResource(this.http);
408
441
  this.keys = new KeysResource(this.http);
442
+ this.webhooks = new WebhooksResource(this.http);
409
443
  }
410
444
  };
411
445
  var index_default = Maritime;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/http.ts","../src/resources/agents.ts","../src/resources/keys.ts"],"sourcesContent":["import { HttpClient, type MaritimeClientOptions } from './http.js'\nimport { AgentsResource } from './resources/agents.js'\nimport { KeysResource } from './resources/keys.js'\n\nexport type { MaritimeClientOptions } from './http.js'\nexport * from './types.js'\nexport {\n MaritimeError,\n MaritimeConnectionError,\n MaritimeAPIError,\n MaritimeAuthError,\n MaritimePaymentRequiredError,\n MaritimeNotFoundError,\n MaritimeConflictError,\n MaritimeRateLimitError,\n} from './errors.js'\n\n/**\n * The Maritime client. Provision and drive AI agents on Maritime's serverless\n * infrastructure from your own backend.\n *\n * ```ts\n * import { Maritime } from 'maritime-sdk'\n *\n * const maritime = new Maritime({ apiKey: process.env.MARITIME_API_KEY })\n *\n * // When YOUR user signs up, give them their own agent (idempotent):\n * const agent = await maritime.agents.provision({\n * externalId: `customer_${userId}`,\n * name: `assistant-${userId}`,\n * template: 'openclaw',\n * })\n *\n * const { response } = await maritime.agents.chat(agent.id, 'Hello!')\n * ```\n */\nexport class Maritime {\n readonly agents: AgentsResource\n readonly keys: KeysResource\n /** The underlying transport — escape hatch for endpoints not yet wrapped. */\n readonly http: HttpClient\n\n constructor(options: MaritimeClientOptions = {}) {\n this.http = new HttpClient(options)\n this.agents = new AgentsResource(this.http)\n this.keys = new KeysResource(this.http)\n }\n}\n\nexport default Maritime\n","/** Base class for every error the SDK throws. Catch this to catch them all. */\nexport class MaritimeError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'MaritimeError'\n // Restore prototype chain when compiled to ES5-ish targets.\n Object.setPrototypeOf(this, new.target.prototype)\n }\n}\n\n/** The request never reached Maritime (DNS, connection refused, timeout, …). */\nexport class MaritimeConnectionError extends MaritimeError {\n readonly cause?: unknown\n constructor(message: string, cause?: unknown) {\n super(message)\n this.name = 'MaritimeConnectionError'\n this.cause = cause\n }\n}\n\n/** Maritime returned a non-2xx response. Subclassed by status below. */\nexport class MaritimeAPIError extends MaritimeError {\n readonly status: number\n readonly detail: string\n /** Value of the `x-request-id` response header, when present. */\n readonly requestId?: string\n\n constructor(status: number, detail: string, requestId?: string) {\n super(`Maritime API error ${status}: ${detail}`)\n this.name = 'MaritimeAPIError'\n this.status = status\n this.detail = detail\n this.requestId = requestId\n }\n}\n\n/** 401 / 403 — bad or insufficiently-scoped API key. */\nexport class MaritimeAuthError extends MaritimeAPIError {\n constructor(status: number, detail: string, requestId?: string) {\n super(status, detail, requestId)\n this.name = 'MaritimeAuthError'\n }\n}\n\n/** 402 — the account wallet needs funding before this action can proceed. */\nexport class MaritimePaymentRequiredError extends MaritimeAPIError {\n constructor(status: number, detail: string, requestId?: string) {\n super(status, detail, requestId)\n this.name = 'MaritimePaymentRequiredError'\n }\n}\n\n/** 404 — the agent (or other resource) does not exist or is not yours. */\nexport class MaritimeNotFoundError extends MaritimeAPIError {\n constructor(status: number, detail: string, requestId?: string) {\n super(status, detail, requestId)\n this.name = 'MaritimeNotFoundError'\n }\n}\n\n/** 409 — a uniqueness conflict (e.g. an agent with that name already exists). */\nexport class MaritimeConflictError extends MaritimeAPIError {\n constructor(status: number, detail: string, requestId?: string) {\n super(status, detail, requestId)\n this.name = 'MaritimeConflictError'\n }\n}\n\n/** 429 — rate limited. */\nexport class MaritimeRateLimitError extends MaritimeAPIError {\n constructor(status: number, detail: string, requestId?: string) {\n super(status, detail, requestId)\n this.name = 'MaritimeRateLimitError'\n }\n}\n\n/** Build the most specific error subclass for an HTTP status. */\nexport function apiErrorFromStatus(\n status: number,\n detail: string,\n requestId?: string,\n): MaritimeAPIError {\n switch (status) {\n case 401:\n case 403:\n return new MaritimeAuthError(status, detail, requestId)\n case 402:\n return new MaritimePaymentRequiredError(status, detail, requestId)\n case 404:\n return new MaritimeNotFoundError(status, detail, requestId)\n case 409:\n return new MaritimeConflictError(status, detail, requestId)\n case 429:\n return new MaritimeRateLimitError(status, detail, requestId)\n default:\n return new MaritimeAPIError(status, detail, requestId)\n }\n}\n","import { apiErrorFromStatus, MaritimeConnectionError, MaritimeError } from './errors.js'\n\nexport interface MaritimeClientOptions {\n /**\n * Maritime API key (`mk_...`). Defaults to the `MARITIME_API_KEY` env var.\n * Mint one from the dashboard (Settings → API keys) or `maritime keys create`.\n */\n apiKey?: string\n /** API base URL. Defaults to `MARITIME_API_URL` or `https://api.maritime.sh`. */\n baseUrl?: string\n /** Per-request timeout in ms (default 60_000). */\n timeout?: number\n /** Retries on network errors and 5xx/429 responses (default 2). */\n maxRetries?: number\n /** Inject a custom fetch (tests, proxies, non-global-fetch runtimes). */\n fetch?: typeof fetch\n /** Extra headers sent on every request. */\n defaultHeaders?: Record<string, string>\n}\n\ninterface RequestOptions {\n method: string\n path: string\n query?: Record<string, string | number | boolean | undefined | null>\n body?: unknown\n /** Override retry behaviour for a single call (e.g. non-idempotent POST). */\n idempotent?: boolean\n}\n\nconst DEFAULT_BASE_URL = 'https://api.maritime.sh'\nconst RETRYABLE_STATUS = new Set([429, 500, 502, 503, 504])\n\nfunction resolveApiKey(explicit?: string): string {\n const key = explicit ?? (typeof process !== 'undefined' ? process.env?.MARITIME_API_KEY : undefined)\n if (!key) {\n throw new MaritimeError(\n 'Missing Maritime API key. Pass { apiKey } to the client or set MARITIME_API_KEY.',\n )\n }\n return key\n}\n\nfunction resolveBaseUrl(explicit?: string): string {\n const url =\n explicit ??\n (typeof process !== 'undefined' ? process.env?.MARITIME_API_URL : undefined) ??\n DEFAULT_BASE_URL\n return url.replace(/\\/+$/, '')\n}\n\nconst sleep = (ms: number) => new Promise((r) => setTimeout(r, ms))\n\n/**\n * Thin transport: auth header, JSON encode/decode, typed errors, and bounded\n * retry with exponential backoff on transient failures. No dependencies —\n * uses the runtime's global `fetch` (Node 18+, Bun, Deno, browsers, edge).\n */\nexport class HttpClient {\n private readonly apiKey: string\n private readonly baseUrl: string\n private readonly timeout: number\n private readonly maxRetries: number\n private readonly fetchImpl: typeof fetch\n private readonly defaultHeaders: Record<string, string>\n\n constructor(options: MaritimeClientOptions = {}) {\n this.apiKey = resolveApiKey(options.apiKey)\n this.baseUrl = resolveBaseUrl(options.baseUrl)\n this.timeout = options.timeout ?? 60_000\n this.maxRetries = options.maxRetries ?? 2\n const f = options.fetch ?? (typeof fetch !== 'undefined' ? fetch : undefined)\n if (!f) {\n throw new MaritimeError(\n 'No global fetch available. Use Node 18+, or pass a { fetch } implementation.',\n )\n }\n // Bind so `this` inside native fetch stays correct.\n this.fetchImpl = f.bind(globalThis) as typeof fetch\n this.defaultHeaders = options.defaultHeaders ?? {}\n }\n\n private buildUrl(path: string, query?: RequestOptions['query']): string {\n const url = new URL(this.baseUrl + path)\n if (query) {\n for (const [k, v] of Object.entries(query)) {\n if (v !== undefined && v !== null) url.searchParams.set(k, String(v))\n }\n }\n return url.toString()\n }\n\n async request<T>(opts: RequestOptions): Promise<T> {\n const url = this.buildUrl(opts.path, opts.query)\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.apiKey}`,\n Accept: 'application/json',\n 'User-Agent': 'maritime-sdk',\n ...this.defaultHeaders,\n }\n const init: RequestInit = { method: opts.method, headers }\n if (opts.body !== undefined) {\n headers['Content-Type'] = 'application/json'\n init.body = JSON.stringify(opts.body)\n }\n\n // GET/DELETE are idempotent and safe to retry; POST/PUT retry only on\n // network errors + 429/503 (never on a 5xx that may have applied a write),\n // unless the caller explicitly marks the call idempotent.\n const method = opts.method.toUpperCase()\n const retrySafe = opts.idempotent ?? (method === 'GET' || method === 'DELETE')\n\n let lastErr: unknown\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), this.timeout)\n\n let res: Response\n try {\n res = await this.fetchImpl(url, { ...init, signal: controller.signal })\n } catch (err) {\n // Transport-level failure (DNS, connection, timeout/abort). Retry.\n clearTimeout(timer)\n lastErr = err\n if (attempt < this.maxRetries) {\n await sleep(this.backoff(attempt))\n continue\n }\n const reason = err instanceof Error ? err.message : String(err)\n throw new MaritimeConnectionError(\n `Failed to reach Maritime at ${this.baseUrl}: ${reason}`,\n err,\n )\n }\n clearTimeout(timer)\n\n if (res.ok) return (await this.parseBody(res)) as T\n\n const detail = await this.safeDetail(res)\n const requestId = res.headers.get('x-request-id') ?? undefined\n const retryable =\n attempt < this.maxRetries &&\n RETRYABLE_STATUS.has(res.status) &&\n (retrySafe || res.status === 429 || res.status === 503)\n if (retryable) {\n lastErr = apiErrorFromStatus(res.status, detail, requestId)\n await sleep(this.backoff(attempt, res))\n continue\n }\n throw apiErrorFromStatus(res.status, detail, requestId)\n }\n\n // Exhausted retries on a retryable HTTP status.\n if (lastErr instanceof MaritimeError) throw lastErr\n throw new MaritimeConnectionError(`Request to ${url} failed after retries`, lastErr)\n }\n\n private backoff(attempt: number, res?: Response): number {\n // Honour Retry-After (seconds) when the server sends it.\n const retryAfter = res?.headers.get('retry-after')\n if (retryAfter) {\n const secs = Number(retryAfter)\n if (!Number.isNaN(secs)) return Math.min(secs * 1000, 20_000)\n }\n return Math.min(500 * 2 ** attempt, 8_000)\n }\n\n private async parseBody(res: Response): Promise<unknown> {\n if (res.status === 204) return undefined\n const text = await res.text()\n if (!text) return undefined\n try {\n return JSON.parse(text)\n } catch {\n return text\n }\n }\n\n private async safeDetail(res: Response): Promise<string> {\n try {\n const body = await this.parseBody(res)\n if (body && typeof body === 'object' && 'detail' in body) {\n const d = (body as { detail: unknown }).detail\n if (typeof d === 'string') return d\n return JSON.stringify(d)\n }\n if (typeof body === 'string' && body) return body\n } catch {\n /* fall through */\n }\n return `Request failed with status ${res.status}`\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type {\n Agent,\n ChatOptions,\n ChatResult,\n CreateAgentParams,\n EnvVar,\n ListAgentsParams,\n LogEntry,\n} from '../types.js'\n\n/** Operations on Maritime agents. Access via `maritime.agents`. */\nexport class AgentsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a new agent and kick off its deploy. */\n async create(params: CreateAgentParams): Promise<Agent> {\n return this.http.request<Agent>({\n method: 'POST',\n path: '/api/agents',\n body: toCreateBody(params),\n })\n }\n\n /**\n * Get-or-create an agent by `externalId` — the idempotent entry point for a\n * \"one agent per end-customer\" flow. If an agent with that external id\n * already exists it is returned; otherwise a new one is created. Safe to call\n * on every sign-in.\n */\n async provision(params: CreateAgentParams & { externalId: string }): Promise<Agent> {\n const existing = await this.list({ externalId: params.externalId })\n if (existing.length > 0) return existing[0] as Agent\n // Default the template so we never create a broken bare-framework agent.\n const withTemplate: CreateAgentParams = {\n template: 'openclaw',\n ...params,\n }\n try {\n return await this.create(withTemplate)\n } catch (err) {\n // Lost a race with a concurrent provisioner (unique-name 409). Re-read.\n const raced = await this.list({ externalId: params.externalId })\n if (raced.length > 0) return raced[0] as Agent\n throw err\n }\n }\n\n /** Fetch a single agent by id. */\n async get(agentId: string): Promise<Agent> {\n return this.http.request<Agent>({ method: 'GET', path: `/api/agents/${enc(agentId)}` })\n }\n\n /** List agents, optionally filtered by `externalId` or `name`. */\n async list(params: ListAgentsParams = {}): Promise<Agent[]> {\n return this.http.request<Agent[]>({\n method: 'GET',\n path: '/api/agents',\n query: { externalId: params.externalId, name: params.name },\n })\n }\n\n /**\n * Send a message to an agent and wait for its reply. Sleeping serverless\n * agents auto-wake. Returns `{ response }` (or `{ response: null, error }`\n * if delivery failed — Maritime does not surface that as an HTTP error).\n */\n async chat(agentId: string, message: string, opts: ChatOptions = {}): Promise<ChatResult> {\n return this.http.request<ChatResult>({\n method: 'POST',\n path: `/api/agents/${enc(agentId)}/chat`,\n body: { message, conversation_id: opts.conversationId },\n })\n }\n\n /** Start / wake an agent. */\n async start(agentId: string): Promise<Agent> {\n return this.lifecycle(agentId, 'start')\n }\n\n /** Stop an agent (container stopped, state preserved). */\n async stop(agentId: string): Promise<Agent> {\n return this.lifecycle(agentId, 'stop')\n }\n\n /** Put an agent to sleep (serverless snapshot; cheapest resting state). */\n async sleep(agentId: string): Promise<Agent> {\n return this.lifecycle(agentId, 'sleep')\n }\n\n /** Restart an agent. */\n async restart(agentId: string): Promise<Agent> {\n return this.lifecycle(agentId, 'restart')\n }\n\n /** Delete an agent and all its resources (container, volume, network). */\n async delete(agentId: string): Promise<void> {\n await this.http.request<void>({ method: 'DELETE', path: `/api/agents/${enc(agentId)}` })\n }\n\n /** List an agent's env vars (secret values are masked). */\n async listEnv(agentId: string): Promise<EnvVar[]> {\n return this.http.request<EnvVar[]>({ method: 'GET', path: `/api/agents/${enc(agentId)}/env` })\n }\n\n /**\n * Set (upsert) an env var. Secrets are encrypted at rest. Changes reach a\n * running container after {@link reloadEnv} or a restart.\n */\n async setEnv(\n agentId: string,\n key: string,\n value: string,\n opts: { secret?: boolean } = {},\n ): Promise<EnvVar> {\n return this.http.request<EnvVar>({\n method: 'POST',\n path: `/api/agents/${enc(agentId)}/env`,\n body: { key, value, isSecret: opts.secret ?? true },\n })\n }\n\n /** Delete an env var. */\n async deleteEnv(agentId: string, key: string): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/api/agents/${enc(agentId)}/env/${enc(key)}`,\n })\n }\n\n /** Hot-reload env vars into the running container (falls back to restart). */\n async reloadEnv(agentId: string): Promise<Agent> {\n return this.lifecycle(agentId, 'reload-env')\n }\n\n /** Fetch recent log entries for an agent. */\n async logs(\n agentId: string,\n opts: { limit?: number; level?: string } = {},\n ): Promise<LogEntry[]> {\n return this.http.request<LogEntry[]>({\n method: 'GET',\n path: `/api/agents/${enc(agentId)}/logs`,\n query: { limit: opts.limit, level: opts.level },\n })\n }\n\n private lifecycle(agentId: string, action: string): Promise<Agent> {\n return this.http.request<Agent>({\n method: 'POST',\n path: `/api/agents/${enc(agentId)}/${action}`,\n // Lifecycle transitions are effectively idempotent; safe to retry.\n idempotent: true,\n })\n }\n}\n\nconst enc = encodeURIComponent\n\nfunction toCreateBody(p: CreateAgentParams): Record<string, unknown> {\n return {\n name: p.name,\n templateId: p.template,\n externalId: p.externalId,\n description: p.description,\n instructions: p.instructions,\n tier: p.tier,\n memMb: p.memMb,\n vcpus: p.vcpus,\n idleTtlSeconds: p.idleTtlSeconds,\n diskGb: p.diskGb,\n githubRepo: p.githubRepo,\n imageName: p.imageName,\n initialEnvVars: p.env?.map((e) => ({\n key: e.key,\n value: e.value,\n isSecret: e.secret ?? true,\n })),\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { ApiKey, CreatedApiKey, CreateApiKeyParams } from '../types.js'\n\n/**\n * Manage API keys (`mk_...`) programmatically. Access via `maritime.keys`.\n *\n * Minting a key requires the caller's own key to carry the `manage` scope (or\n * be a dashboard session). Hand a narrower-scoped key to a subsystem that only\n * needs part of the surface — e.g. a `deploy`-scoped key for a worker that only\n * chats to agents.\n */\nexport class KeysResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Mint a new key. The raw key is returned once — store it immediately. */\n async create(params: CreateApiKeyParams): Promise<CreatedApiKey> {\n return this.http.request<CreatedApiKey>({\n method: 'POST',\n path: '/api/v1/keys',\n body: {\n name: params.name,\n scopes: params.scopes ?? ['provision', 'deploy', 'secrets', 'manage'],\n expires_in_days: params.expiresInDays,\n },\n })\n }\n\n /** List the caller's keys (raw values are never returned again). */\n async list(): Promise<ApiKey[]> {\n return this.http.request<ApiKey[]>({ method: 'GET', path: '/api/v1/keys' })\n }\n\n /** Revoke a key by id. */\n async revoke(keyId: string): Promise<void> {\n await this.http.request<void>({ method: 'DELETE', path: `/api/v1/keys/${encodeURIComponent(keyId)}` })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAEZ,WAAO,eAAe,MAAM,WAAW,SAAS;AAAA,EAClD;AACF;AAGO,IAAM,0BAAN,cAAsC,cAAc;AAAA,EAEzD,YAAY,SAAiB,OAAiB;AAC5C,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,QAAQ;AAAA,EACf;AACF;AAGO,IAAM,mBAAN,cAA+B,cAAc;AAAA,EAMlD,YAAY,QAAgB,QAAgB,WAAoB;AAC9D,UAAM,sBAAsB,MAAM,KAAK,MAAM,EAAE;AAC/C,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,SAAS;AACd,SAAK,YAAY;AAAA,EACnB;AACF;AAG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AAAA;AAAA,EAGA,MAAM,OAA0B;AAC9B,WAAO,KAAK,KAAK,QAAkB,EAAE,QAAQ,OAAO,MAAM,eAAe,CAAC;AAAA,EAC5E;AAAA;AAAA,EAGA,MAAM,OAAO,OAA8B;AACzC,UAAM,KAAK,KAAK,QAAc,EAAE,QAAQ,UAAU,MAAM,gBAAgB,mBAAmB,KAAK,CAAC,GAAG,CAAC;AAAA,EACvG;AACF;;;AJAO,IAAM,WAAN,MAAe;AAAA,EAMpB,YAAY,UAAiC,CAAC,GAAG;AAC/C,SAAK,OAAO,IAAI,WAAW,OAAO;AAClC,SAAK,SAAS,IAAI,eAAe,KAAK,IAAI;AAC1C,SAAK,OAAO,IAAI,aAAa,KAAK,IAAI;AAAA,EACxC;AACF;AAEA,IAAO,gBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/http.ts","../src/resources/agents.ts","../src/resources/keys.ts","../src/resources/webhooks.ts"],"sourcesContent":["import { HttpClient, type MaritimeClientOptions } from './http.js'\nimport { AgentsResource } from './resources/agents.js'\nimport { KeysResource } from './resources/keys.js'\nimport { WebhooksResource } from './resources/webhooks.js'\n\nexport type { MaritimeClientOptions } from './http.js'\nexport * from './types.js'\nexport {\n MaritimeError,\n MaritimeConnectionError,\n MaritimeAPIError,\n MaritimeAuthError,\n MaritimePaymentRequiredError,\n MaritimeNotFoundError,\n MaritimeConflictError,\n MaritimeRateLimitError,\n} from './errors.js'\n\n/**\n * The Maritime client. Provision and drive AI agents on Maritime's serverless\n * infrastructure from your own backend.\n *\n * ```ts\n * import { Maritime } from 'maritime-sdk'\n *\n * const maritime = new Maritime({ apiKey: process.env.MARITIME_API_KEY })\n *\n * // When YOUR user signs up, give them their own agent (idempotent):\n * const agent = await maritime.agents.provision({\n * externalId: `customer_${userId}`,\n * name: `assistant-${userId}`,\n * template: 'openclaw',\n * })\n *\n * const { response } = await maritime.agents.chat(agent.id, 'Hello!')\n * ```\n */\nexport class Maritime {\n readonly agents: AgentsResource\n readonly keys: KeysResource\n readonly webhooks: WebhooksResource\n /** The underlying transport — escape hatch for endpoints not yet wrapped. */\n readonly http: HttpClient\n\n constructor(options: MaritimeClientOptions = {}) {\n this.http = new HttpClient(options)\n this.agents = new AgentsResource(this.http)\n this.keys = new KeysResource(this.http)\n this.webhooks = new WebhooksResource(this.http)\n }\n}\n\nexport default Maritime\n","/** Base class for every error the SDK throws. Catch this to catch them all. */\nexport class MaritimeError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'MaritimeError'\n // Restore prototype chain when compiled to ES5-ish targets.\n Object.setPrototypeOf(this, new.target.prototype)\n }\n}\n\n/** The request never reached Maritime (DNS, connection refused, timeout, …). */\nexport class MaritimeConnectionError extends MaritimeError {\n readonly cause?: unknown\n constructor(message: string, cause?: unknown) {\n super(message)\n this.name = 'MaritimeConnectionError'\n this.cause = cause\n }\n}\n\n/** Maritime returned a non-2xx response. Subclassed by status below. */\nexport class MaritimeAPIError extends MaritimeError {\n readonly status: number\n readonly detail: string\n /** Value of the `x-request-id` response header, when present. */\n readonly requestId?: string\n\n constructor(status: number, detail: string, requestId?: string) {\n super(`Maritime API error ${status}: ${detail}`)\n this.name = 'MaritimeAPIError'\n this.status = status\n this.detail = detail\n this.requestId = requestId\n }\n}\n\n/** 401 / 403 — bad or insufficiently-scoped API key. */\nexport class MaritimeAuthError extends MaritimeAPIError {\n constructor(status: number, detail: string, requestId?: string) {\n super(status, detail, requestId)\n this.name = 'MaritimeAuthError'\n }\n}\n\n/** 402 — the account wallet needs funding before this action can proceed. */\nexport class MaritimePaymentRequiredError extends MaritimeAPIError {\n constructor(status: number, detail: string, requestId?: string) {\n super(status, detail, requestId)\n this.name = 'MaritimePaymentRequiredError'\n }\n}\n\n/** 404 — the agent (or other resource) does not exist or is not yours. */\nexport class MaritimeNotFoundError extends MaritimeAPIError {\n constructor(status: number, detail: string, requestId?: string) {\n super(status, detail, requestId)\n this.name = 'MaritimeNotFoundError'\n }\n}\n\n/** 409 — a uniqueness conflict (e.g. an agent with that name already exists). */\nexport class MaritimeConflictError extends MaritimeAPIError {\n constructor(status: number, detail: string, requestId?: string) {\n super(status, detail, requestId)\n this.name = 'MaritimeConflictError'\n }\n}\n\n/** 429 — rate limited. */\nexport class MaritimeRateLimitError extends MaritimeAPIError {\n constructor(status: number, detail: string, requestId?: string) {\n super(status, detail, requestId)\n this.name = 'MaritimeRateLimitError'\n }\n}\n\n/** Build the most specific error subclass for an HTTP status. */\nexport function apiErrorFromStatus(\n status: number,\n detail: string,\n requestId?: string,\n): MaritimeAPIError {\n switch (status) {\n case 401:\n case 403:\n return new MaritimeAuthError(status, detail, requestId)\n case 402:\n return new MaritimePaymentRequiredError(status, detail, requestId)\n case 404:\n return new MaritimeNotFoundError(status, detail, requestId)\n case 409:\n return new MaritimeConflictError(status, detail, requestId)\n case 429:\n return new MaritimeRateLimitError(status, detail, requestId)\n default:\n return new MaritimeAPIError(status, detail, requestId)\n }\n}\n","import { apiErrorFromStatus, MaritimeConnectionError, MaritimeError } from './errors.js'\n\nexport interface MaritimeClientOptions {\n /**\n * Maritime API key (`mk_...`). Defaults to the `MARITIME_API_KEY` env var.\n * Mint one from the dashboard (Settings → API keys) or `maritime keys create`.\n */\n apiKey?: string\n /** API base URL. Defaults to `MARITIME_API_URL` or `https://api.maritime.sh`. */\n baseUrl?: string\n /** Per-request timeout in ms (default 60_000). */\n timeout?: number\n /** Retries on network errors and 5xx/429 responses (default 2). */\n maxRetries?: number\n /** Inject a custom fetch (tests, proxies, non-global-fetch runtimes). */\n fetch?: typeof fetch\n /** Extra headers sent on every request. */\n defaultHeaders?: Record<string, string>\n}\n\ninterface RequestOptions {\n method: string\n path: string\n query?: Record<string, string | number | boolean | undefined | null>\n body?: unknown\n /** Override retry behaviour for a single call (e.g. non-idempotent POST). */\n idempotent?: boolean\n}\n\nconst DEFAULT_BASE_URL = 'https://api.maritime.sh'\nconst RETRYABLE_STATUS = new Set([429, 500, 502, 503, 504])\n\nfunction resolveApiKey(explicit?: string): string {\n const key = explicit ?? (typeof process !== 'undefined' ? process.env?.MARITIME_API_KEY : undefined)\n if (!key) {\n throw new MaritimeError(\n 'Missing Maritime API key. Pass { apiKey } to the client or set MARITIME_API_KEY.',\n )\n }\n return key\n}\n\nfunction resolveBaseUrl(explicit?: string): string {\n const url =\n explicit ??\n (typeof process !== 'undefined' ? process.env?.MARITIME_API_URL : undefined) ??\n DEFAULT_BASE_URL\n return url.replace(/\\/+$/, '')\n}\n\nconst sleep = (ms: number) => new Promise((r) => setTimeout(r, ms))\n\n/**\n * Thin transport: auth header, JSON encode/decode, typed errors, and bounded\n * retry with exponential backoff on transient failures. No dependencies —\n * uses the runtime's global `fetch` (Node 18+, Bun, Deno, browsers, edge).\n */\nexport class HttpClient {\n private readonly apiKey: string\n private readonly baseUrl: string\n private readonly timeout: number\n private readonly maxRetries: number\n private readonly fetchImpl: typeof fetch\n private readonly defaultHeaders: Record<string, string>\n\n constructor(options: MaritimeClientOptions = {}) {\n this.apiKey = resolveApiKey(options.apiKey)\n this.baseUrl = resolveBaseUrl(options.baseUrl)\n this.timeout = options.timeout ?? 60_000\n this.maxRetries = options.maxRetries ?? 2\n const f = options.fetch ?? (typeof fetch !== 'undefined' ? fetch : undefined)\n if (!f) {\n throw new MaritimeError(\n 'No global fetch available. Use Node 18+, or pass a { fetch } implementation.',\n )\n }\n // Bind so `this` inside native fetch stays correct.\n this.fetchImpl = f.bind(globalThis) as typeof fetch\n this.defaultHeaders = options.defaultHeaders ?? {}\n }\n\n private buildUrl(path: string, query?: RequestOptions['query']): string {\n const url = new URL(this.baseUrl + path)\n if (query) {\n for (const [k, v] of Object.entries(query)) {\n if (v !== undefined && v !== null) url.searchParams.set(k, String(v))\n }\n }\n return url.toString()\n }\n\n async request<T>(opts: RequestOptions): Promise<T> {\n const url = this.buildUrl(opts.path, opts.query)\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.apiKey}`,\n Accept: 'application/json',\n 'User-Agent': 'maritime-sdk',\n ...this.defaultHeaders,\n }\n const init: RequestInit = { method: opts.method, headers }\n if (opts.body !== undefined) {\n headers['Content-Type'] = 'application/json'\n init.body = JSON.stringify(opts.body)\n }\n\n // GET/DELETE are idempotent and safe to retry; POST/PUT retry only on\n // network errors + 429/503 (never on a 5xx that may have applied a write),\n // unless the caller explicitly marks the call idempotent.\n const method = opts.method.toUpperCase()\n const retrySafe = opts.idempotent ?? (method === 'GET' || method === 'DELETE')\n\n let lastErr: unknown\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), this.timeout)\n\n let res: Response\n try {\n res = await this.fetchImpl(url, { ...init, signal: controller.signal })\n } catch (err) {\n // Transport-level failure (DNS, connection, timeout/abort). Retry.\n clearTimeout(timer)\n lastErr = err\n if (attempt < this.maxRetries) {\n await sleep(this.backoff(attempt))\n continue\n }\n const reason = err instanceof Error ? err.message : String(err)\n throw new MaritimeConnectionError(\n `Failed to reach Maritime at ${this.baseUrl}: ${reason}`,\n err,\n )\n }\n clearTimeout(timer)\n\n if (res.ok) return (await this.parseBody(res)) as T\n\n const detail = await this.safeDetail(res)\n const requestId = res.headers.get('x-request-id') ?? undefined\n const retryable =\n attempt < this.maxRetries &&\n RETRYABLE_STATUS.has(res.status) &&\n (retrySafe || res.status === 429 || res.status === 503)\n if (retryable) {\n lastErr = apiErrorFromStatus(res.status, detail, requestId)\n await sleep(this.backoff(attempt, res))\n continue\n }\n throw apiErrorFromStatus(res.status, detail, requestId)\n }\n\n // Exhausted retries on a retryable HTTP status.\n if (lastErr instanceof MaritimeError) throw lastErr\n throw new MaritimeConnectionError(`Request to ${url} failed after retries`, lastErr)\n }\n\n private backoff(attempt: number, res?: Response): number {\n // Honour Retry-After (seconds) when the server sends it.\n const retryAfter = res?.headers.get('retry-after')\n if (retryAfter) {\n const secs = Number(retryAfter)\n if (!Number.isNaN(secs)) return Math.min(secs * 1000, 20_000)\n }\n return Math.min(500 * 2 ** attempt, 8_000)\n }\n\n private async parseBody(res: Response): Promise<unknown> {\n if (res.status === 204) return undefined\n const text = await res.text()\n if (!text) return undefined\n try {\n return JSON.parse(text)\n } catch {\n return text\n }\n }\n\n private async safeDetail(res: Response): Promise<string> {\n try {\n const body = await this.parseBody(res)\n if (body && typeof body === 'object' && 'detail' in body) {\n const d = (body as { detail: unknown }).detail\n if (typeof d === 'string') return d\n return JSON.stringify(d)\n }\n if (typeof body === 'string' && body) return body\n } catch {\n /* fall through */\n }\n return `Request failed with status ${res.status}`\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type {\n Agent,\n ChatOptions,\n ChatResult,\n CreateAgentParams,\n EnvVar,\n ListAgentsParams,\n LogEntry,\n} from '../types.js'\n\n/** Operations on Maritime agents. Access via `maritime.agents`. */\nexport class AgentsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a new agent and kick off its deploy. */\n async create(params: CreateAgentParams): Promise<Agent> {\n return this.http.request<Agent>({\n method: 'POST',\n path: '/api/agents',\n body: toCreateBody(params),\n })\n }\n\n /**\n * Get-or-create an agent by `externalId` — the idempotent entry point for a\n * \"one agent per end-customer\" flow. If an agent with that external id\n * already exists it is returned; otherwise a new one is created. Safe to call\n * on every sign-in.\n */\n async provision(params: CreateAgentParams & { externalId: string }): Promise<Agent> {\n const existing = await this.list({ externalId: params.externalId })\n if (existing.length > 0) return existing[0] as Agent\n // Default the template so we never create a broken bare-framework agent.\n const withTemplate: CreateAgentParams = {\n template: 'openclaw',\n ...params,\n }\n try {\n return await this.create(withTemplate)\n } catch (err) {\n // Lost a race with a concurrent provisioner (unique-name 409). Re-read.\n const raced = await this.list({ externalId: params.externalId })\n if (raced.length > 0) return raced[0] as Agent\n throw err\n }\n }\n\n /** Fetch a single agent by id. */\n async get(agentId: string): Promise<Agent> {\n return this.http.request<Agent>({ method: 'GET', path: `/api/agents/${enc(agentId)}` })\n }\n\n /** List agents, optionally filtered by `externalId` or `name`. */\n async list(params: ListAgentsParams = {}): Promise<Agent[]> {\n return this.http.request<Agent[]>({\n method: 'GET',\n path: '/api/agents',\n query: { externalId: params.externalId, name: params.name },\n })\n }\n\n /**\n * Send a message to an agent and wait for its reply. Sleeping serverless\n * agents auto-wake. Returns `{ response }` (or `{ response: null, error }`\n * if delivery failed — Maritime does not surface that as an HTTP error).\n */\n async chat(agentId: string, message: string, opts: ChatOptions = {}): Promise<ChatResult> {\n return this.http.request<ChatResult>({\n method: 'POST',\n path: `/api/agents/${enc(agentId)}/chat`,\n body: { message, conversation_id: opts.conversationId },\n })\n }\n\n /** Start / wake an agent. */\n async start(agentId: string): Promise<Agent> {\n return this.lifecycle(agentId, 'start')\n }\n\n /** Stop an agent (container stopped, state preserved). */\n async stop(agentId: string): Promise<Agent> {\n return this.lifecycle(agentId, 'stop')\n }\n\n /** Put an agent to sleep (serverless snapshot; cheapest resting state). */\n async sleep(agentId: string): Promise<Agent> {\n return this.lifecycle(agentId, 'sleep')\n }\n\n /** Restart an agent. */\n async restart(agentId: string): Promise<Agent> {\n return this.lifecycle(agentId, 'restart')\n }\n\n /** Delete an agent and all its resources (container, volume, network). */\n async delete(agentId: string): Promise<void> {\n await this.http.request<void>({ method: 'DELETE', path: `/api/agents/${enc(agentId)}` })\n }\n\n /** List an agent's env vars (secret values are masked). */\n async listEnv(agentId: string): Promise<EnvVar[]> {\n return this.http.request<EnvVar[]>({ method: 'GET', path: `/api/agents/${enc(agentId)}/env` })\n }\n\n /**\n * Set (upsert) an env var. Secrets are encrypted at rest. Changes reach a\n * running container after {@link reloadEnv} or a restart.\n */\n async setEnv(\n agentId: string,\n key: string,\n value: string,\n opts: { secret?: boolean } = {},\n ): Promise<EnvVar> {\n return this.http.request<EnvVar>({\n method: 'POST',\n path: `/api/agents/${enc(agentId)}/env`,\n body: { key, value, isSecret: opts.secret ?? true },\n })\n }\n\n /** Delete an env var. */\n async deleteEnv(agentId: string, key: string): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/api/agents/${enc(agentId)}/env/${enc(key)}`,\n })\n }\n\n /** Hot-reload env vars into the running container (falls back to restart). */\n async reloadEnv(agentId: string): Promise<Agent> {\n return this.lifecycle(agentId, 'reload-env')\n }\n\n /** Fetch recent log entries for an agent. */\n async logs(\n agentId: string,\n opts: { limit?: number; level?: string } = {},\n ): Promise<LogEntry[]> {\n return this.http.request<LogEntry[]>({\n method: 'GET',\n path: `/api/agents/${enc(agentId)}/logs`,\n query: { limit: opts.limit, level: opts.level },\n })\n }\n\n private lifecycle(agentId: string, action: string): Promise<Agent> {\n return this.http.request<Agent>({\n method: 'POST',\n path: `/api/agents/${enc(agentId)}/${action}`,\n // Lifecycle transitions are effectively idempotent; safe to retry.\n idempotent: true,\n })\n }\n}\n\nconst enc = encodeURIComponent\n\nfunction toCreateBody(p: CreateAgentParams): Record<string, unknown> {\n return {\n name: p.name,\n templateId: p.template,\n externalId: p.externalId,\n description: p.description,\n instructions: p.instructions,\n tier: p.tier,\n memMb: p.memMb,\n vcpus: p.vcpus,\n idleTtlSeconds: p.idleTtlSeconds,\n diskGb: p.diskGb,\n githubRepo: p.githubRepo,\n imageName: p.imageName,\n initialEnvVars: p.env?.map((e) => ({\n key: e.key,\n value: e.value,\n isSecret: e.secret ?? true,\n })),\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { ApiKey, CreatedApiKey, CreateApiKeyParams } from '../types.js'\n\n/**\n * Manage API keys (`mk_...`) programmatically. Access via `maritime.keys`.\n *\n * Minting a key requires the caller's own key to carry the `manage` scope (or\n * be a dashboard session). Hand a narrower-scoped key to a subsystem that only\n * needs part of the surface — e.g. a `deploy`-scoped key for a worker that only\n * chats to agents.\n */\nexport class KeysResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Mint a new key. The raw key is returned once — store it immediately. */\n async create(params: CreateApiKeyParams): Promise<CreatedApiKey> {\n return this.http.request<CreatedApiKey>({\n method: 'POST',\n path: '/api/v1/keys',\n body: {\n name: params.name,\n scopes: params.scopes ?? ['provision', 'deploy', 'secrets', 'manage'],\n expires_in_days: params.expiresInDays,\n },\n })\n }\n\n /** List the caller's keys (raw values are never returned again). */\n async list(): Promise<ApiKey[]> {\n return this.http.request<ApiKey[]>({ method: 'GET', path: '/api/v1/keys' })\n }\n\n /** Revoke a key by id. */\n async revoke(keyId: string): Promise<void> {\n await this.http.request<void>({ method: 'DELETE', path: `/api/v1/keys/${encodeURIComponent(keyId)}` })\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { CreatedWebhook, CreateWebhookParams, Webhook, WebhookTestResult } from '../types.js'\n\n/**\n * Manage outbound webhook subscriptions. Access via `maritime.webhooks`.\n *\n * Subscribe a URL to receive signed agent lifecycle events (agent.deployed,\n * agent.error, agent.sleeping, agent.woken, agent.restarted, agent.stopped)\n * instead of polling. Each delivery carries an `X-Maritime-Signature:\n * sha256=<hmac>` header — verify it with the subscription's secret. The event\n * body includes the agent's `external_id` so you can route to your own customer.\n */\nexport class WebhooksResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a subscription. The signing `secret` is returned once. */\n async create(params: CreateWebhookParams): Promise<CreatedWebhook> {\n return this.http.request<CreatedWebhook>({\n method: 'POST',\n path: '/api/v1/webhooks',\n body: { url: params.url, events: params.events ?? [] },\n })\n }\n\n /** List your subscriptions (secrets are never returned again). */\n async list(): Promise<Webhook[]> {\n return this.http.request<Webhook[]>({ method: 'GET', path: '/api/v1/webhooks' })\n }\n\n /** Delete a subscription. */\n async delete(id: string): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/api/v1/webhooks/${encodeURIComponent(id)}`,\n })\n }\n\n /** Send a synthetic `ping` to the subscription's URL and return the result. */\n async test(id: string): Promise<WebhookTestResult> {\n return this.http.request<WebhookTestResult>({\n method: 'POST',\n path: `/api/v1/webhooks/${encodeURIComponent(id)}/test`,\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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AAA,MAC5B,QAAQ;AAAA,MACR,MAAM,oBAAoB,mBAAmB,EAAE,CAAC;AAAA,IAClD,CAAC;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,KAAK,IAAwC;AACjD,WAAO,KAAK,KAAK,QAA2B;AAAA,MAC1C,QAAQ;AAAA,MACR,MAAM,oBAAoB,mBAAmB,EAAE,CAAC;AAAA,IAClD,CAAC;AAAA,EACH;AACF;;;ALPO,IAAM,WAAN,MAAe;AAAA,EAOpB,YAAY,UAAiC,CAAC,GAAG;AAC/C,SAAK,OAAO,IAAI,WAAW,OAAO;AAClC,SAAK,SAAS,IAAI,eAAe,KAAK,IAAI;AAC1C,SAAK,OAAO,IAAI,aAAa,KAAK,IAAI;AACtC,SAAK,WAAW,IAAI,iBAAiB,KAAK,IAAI;AAAA,EAChD;AACF;AAEA,IAAO,gBAAQ;","names":[]}
package/dist/index.d.cts CHANGED
@@ -143,6 +143,32 @@ interface CreatedApiKey extends ApiKey {
143
143
  /** The full key — shown once. Store it now. */
144
144
  rawKey: string;
145
145
  }
146
+ type WebhookEvent = 'agent.deployed' | 'agent.error' | 'agent.sleeping' | 'agent.woken' | 'agent.restarted' | 'agent.stopped';
147
+ interface CreateWebhookParams {
148
+ /** HTTPS endpoint that will receive POSTed events. */
149
+ url: string;
150
+ /** Events to receive. Omit or empty for all events. */
151
+ events?: WebhookEvent[];
152
+ }
153
+ interface Webhook {
154
+ id: string;
155
+ url: string;
156
+ events: WebhookEvent[];
157
+ isActive: boolean;
158
+ lastDeliveredAt: string | null;
159
+ lastStatusCode: number | null;
160
+ consecutiveFailures: number;
161
+ createdAt: string;
162
+ }
163
+ interface CreatedWebhook extends Webhook {
164
+ /** Signing secret — shown once. Verify `X-Maritime-Signature` with it. */
165
+ secret: string;
166
+ }
167
+ interface WebhookTestResult {
168
+ delivered: boolean;
169
+ statusCode: number | null;
170
+ error?: string;
171
+ }
146
172
 
147
173
  /** Operations on Maritime agents. Access via `maritime.agents`. */
148
174
  declare class AgentsResource {
@@ -219,6 +245,28 @@ declare class KeysResource {
219
245
  revoke(keyId: string): Promise<void>;
220
246
  }
221
247
 
248
+ /**
249
+ * Manage outbound webhook subscriptions. Access via `maritime.webhooks`.
250
+ *
251
+ * Subscribe a URL to receive signed agent lifecycle events (agent.deployed,
252
+ * agent.error, agent.sleeping, agent.woken, agent.restarted, agent.stopped)
253
+ * instead of polling. Each delivery carries an `X-Maritime-Signature:
254
+ * sha256=<hmac>` header — verify it with the subscription's secret. The event
255
+ * body includes the agent's `external_id` so you can route to your own customer.
256
+ */
257
+ declare class WebhooksResource {
258
+ private readonly http;
259
+ constructor(http: HttpClient);
260
+ /** Create a subscription. The signing `secret` is returned once. */
261
+ create(params: CreateWebhookParams): Promise<CreatedWebhook>;
262
+ /** List your subscriptions (secrets are never returned again). */
263
+ list(): Promise<Webhook[]>;
264
+ /** Delete a subscription. */
265
+ delete(id: string): Promise<void>;
266
+ /** Send a synthetic `ping` to the subscription's URL and return the result. */
267
+ test(id: string): Promise<WebhookTestResult>;
268
+ }
269
+
222
270
  /** Base class for every error the SDK throws. Catch this to catch them all. */
223
271
  declare class MaritimeError extends Error {
224
272
  constructor(message: string);
@@ -279,9 +327,10 @@ declare class MaritimeRateLimitError extends MaritimeAPIError {
279
327
  declare class Maritime {
280
328
  readonly agents: AgentsResource;
281
329
  readonly keys: KeysResource;
330
+ readonly webhooks: WebhooksResource;
282
331
  /** The underlying transport — escape hatch for endpoints not yet wrapped. */
283
332
  readonly http: HttpClient;
284
333
  constructor(options?: MaritimeClientOptions);
285
334
  }
286
335
 
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 };
336
+ export { type Agent, type AgentStatus, type ApiKey, type ApiKeyScope, type ChatOptions, type ChatResult, type CreateAgentParams, type CreateApiKeyParams, type CreateWebhookParams, type CreatedApiKey, type CreatedWebhook, type EnvVar, type EnvVarInput, type ListAgentsParams, type LogEntry, Maritime, MaritimeAPIError, MaritimeAuthError, type MaritimeClientOptions, MaritimeConflictError, MaritimeConnectionError, MaritimeError, MaritimeNotFoundError, MaritimePaymentRequiredError, MaritimeRateLimitError, type Template, type Tier, type Webhook, type WebhookEvent, type WebhookTestResult, Maritime as default };
package/dist/index.d.ts CHANGED
@@ -143,6 +143,32 @@ interface CreatedApiKey extends ApiKey {
143
143
  /** The full key — shown once. Store it now. */
144
144
  rawKey: string;
145
145
  }
146
+ type WebhookEvent = 'agent.deployed' | 'agent.error' | 'agent.sleeping' | 'agent.woken' | 'agent.restarted' | 'agent.stopped';
147
+ interface CreateWebhookParams {
148
+ /** HTTPS endpoint that will receive POSTed events. */
149
+ url: string;
150
+ /** Events to receive. Omit or empty for all events. */
151
+ events?: WebhookEvent[];
152
+ }
153
+ interface Webhook {
154
+ id: string;
155
+ url: string;
156
+ events: WebhookEvent[];
157
+ isActive: boolean;
158
+ lastDeliveredAt: string | null;
159
+ lastStatusCode: number | null;
160
+ consecutiveFailures: number;
161
+ createdAt: string;
162
+ }
163
+ interface CreatedWebhook extends Webhook {
164
+ /** Signing secret — shown once. Verify `X-Maritime-Signature` with it. */
165
+ secret: string;
166
+ }
167
+ interface WebhookTestResult {
168
+ delivered: boolean;
169
+ statusCode: number | null;
170
+ error?: string;
171
+ }
146
172
 
147
173
  /** Operations on Maritime agents. Access via `maritime.agents`. */
148
174
  declare class AgentsResource {
@@ -219,6 +245,28 @@ declare class KeysResource {
219
245
  revoke(keyId: string): Promise<void>;
220
246
  }
221
247
 
248
+ /**
249
+ * Manage outbound webhook subscriptions. Access via `maritime.webhooks`.
250
+ *
251
+ * Subscribe a URL to receive signed agent lifecycle events (agent.deployed,
252
+ * agent.error, agent.sleeping, agent.woken, agent.restarted, agent.stopped)
253
+ * instead of polling. Each delivery carries an `X-Maritime-Signature:
254
+ * sha256=<hmac>` header — verify it with the subscription's secret. The event
255
+ * body includes the agent's `external_id` so you can route to your own customer.
256
+ */
257
+ declare class WebhooksResource {
258
+ private readonly http;
259
+ constructor(http: HttpClient);
260
+ /** Create a subscription. The signing `secret` is returned once. */
261
+ create(params: CreateWebhookParams): Promise<CreatedWebhook>;
262
+ /** List your subscriptions (secrets are never returned again). */
263
+ list(): Promise<Webhook[]>;
264
+ /** Delete a subscription. */
265
+ delete(id: string): Promise<void>;
266
+ /** Send a synthetic `ping` to the subscription's URL and return the result. */
267
+ test(id: string): Promise<WebhookTestResult>;
268
+ }
269
+
222
270
  /** Base class for every error the SDK throws. Catch this to catch them all. */
223
271
  declare class MaritimeError extends Error {
224
272
  constructor(message: string);
@@ -279,9 +327,10 @@ declare class MaritimeRateLimitError extends MaritimeAPIError {
279
327
  declare class Maritime {
280
328
  readonly agents: AgentsResource;
281
329
  readonly keys: KeysResource;
330
+ readonly webhooks: WebhooksResource;
282
331
  /** The underlying transport — escape hatch for endpoints not yet wrapped. */
283
332
  readonly http: HttpClient;
284
333
  constructor(options?: MaritimeClientOptions);
285
334
  }
286
335
 
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 };
336
+ export { type Agent, type AgentStatus, type ApiKey, type ApiKeyScope, type ChatOptions, type ChatResult, type CreateAgentParams, type CreateApiKeyParams, type CreateWebhookParams, type CreatedApiKey, type CreatedWebhook, type EnvVar, type EnvVarInput, type ListAgentsParams, type LogEntry, Maritime, MaritimeAPIError, MaritimeAuthError, type MaritimeClientOptions, MaritimeConflictError, MaritimeConnectionError, MaritimeError, MaritimeNotFoundError, MaritimePaymentRequiredError, MaritimeRateLimitError, type Template, type Tier, type Webhook, type WebhookEvent, type WebhookTestResult, Maritime as default };
package/dist/index.js CHANGED
@@ -365,12 +365,46 @@ var KeysResource = class {
365
365
  }
366
366
  };
367
367
 
368
+ // src/resources/webhooks.ts
369
+ var WebhooksResource = class {
370
+ constructor(http) {
371
+ this.http = http;
372
+ }
373
+ /** Create a subscription. The signing `secret` is returned once. */
374
+ async create(params) {
375
+ return this.http.request({
376
+ method: "POST",
377
+ path: "/api/v1/webhooks",
378
+ body: { url: params.url, events: params.events ?? [] }
379
+ });
380
+ }
381
+ /** List your subscriptions (secrets are never returned again). */
382
+ async list() {
383
+ return this.http.request({ method: "GET", path: "/api/v1/webhooks" });
384
+ }
385
+ /** Delete a subscription. */
386
+ async delete(id) {
387
+ await this.http.request({
388
+ method: "DELETE",
389
+ path: `/api/v1/webhooks/${encodeURIComponent(id)}`
390
+ });
391
+ }
392
+ /** Send a synthetic `ping` to the subscription's URL and return the result. */
393
+ async test(id) {
394
+ return this.http.request({
395
+ method: "POST",
396
+ path: `/api/v1/webhooks/${encodeURIComponent(id)}/test`
397
+ });
398
+ }
399
+ };
400
+
368
401
  // src/index.ts
369
402
  var Maritime = class {
370
403
  constructor(options = {}) {
371
404
  this.http = new HttpClient(options);
372
405
  this.agents = new AgentsResource(this.http);
373
406
  this.keys = new KeysResource(this.http);
407
+ this.webhooks = new WebhooksResource(this.http);
374
408
  }
375
409
  };
376
410
  var index_default = Maritime;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/http.ts","../src/resources/agents.ts","../src/resources/keys.ts","../src/index.ts"],"sourcesContent":["/** Base class for every error the SDK throws. Catch this to catch them all. */\nexport class MaritimeError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'MaritimeError'\n // Restore prototype chain when compiled to ES5-ish targets.\n Object.setPrototypeOf(this, new.target.prototype)\n }\n}\n\n/** The request never reached Maritime (DNS, connection refused, timeout, …). */\nexport class MaritimeConnectionError extends MaritimeError {\n readonly cause?: unknown\n constructor(message: string, cause?: unknown) {\n super(message)\n this.name = 'MaritimeConnectionError'\n this.cause = cause\n }\n}\n\n/** Maritime returned a non-2xx response. Subclassed by status below. */\nexport class MaritimeAPIError extends MaritimeError {\n readonly status: number\n readonly detail: string\n /** Value of the `x-request-id` response header, when present. */\n readonly requestId?: string\n\n constructor(status: number, detail: string, requestId?: string) {\n super(`Maritime API error ${status}: ${detail}`)\n this.name = 'MaritimeAPIError'\n this.status = status\n this.detail = detail\n this.requestId = requestId\n }\n}\n\n/** 401 / 403 — bad or insufficiently-scoped API key. */\nexport class MaritimeAuthError extends MaritimeAPIError {\n constructor(status: number, detail: string, requestId?: string) {\n super(status, detail, requestId)\n this.name = 'MaritimeAuthError'\n }\n}\n\n/** 402 — the account wallet needs funding before this action can proceed. */\nexport class MaritimePaymentRequiredError extends MaritimeAPIError {\n constructor(status: number, detail: string, requestId?: string) {\n super(status, detail, requestId)\n this.name = 'MaritimePaymentRequiredError'\n }\n}\n\n/** 404 — the agent (or other resource) does not exist or is not yours. */\nexport class MaritimeNotFoundError extends MaritimeAPIError {\n constructor(status: number, detail: string, requestId?: string) {\n super(status, detail, requestId)\n this.name = 'MaritimeNotFoundError'\n }\n}\n\n/** 409 — a uniqueness conflict (e.g. an agent with that name already exists). */\nexport class MaritimeConflictError extends MaritimeAPIError {\n constructor(status: number, detail: string, requestId?: string) {\n super(status, detail, requestId)\n this.name = 'MaritimeConflictError'\n }\n}\n\n/** 429 — rate limited. */\nexport class MaritimeRateLimitError extends MaritimeAPIError {\n constructor(status: number, detail: string, requestId?: string) {\n super(status, detail, requestId)\n this.name = 'MaritimeRateLimitError'\n }\n}\n\n/** Build the most specific error subclass for an HTTP status. */\nexport function apiErrorFromStatus(\n status: number,\n detail: string,\n requestId?: string,\n): MaritimeAPIError {\n switch (status) {\n case 401:\n case 403:\n return new MaritimeAuthError(status, detail, requestId)\n case 402:\n return new MaritimePaymentRequiredError(status, detail, requestId)\n case 404:\n return new MaritimeNotFoundError(status, detail, requestId)\n case 409:\n return new MaritimeConflictError(status, detail, requestId)\n case 429:\n return new MaritimeRateLimitError(status, detail, requestId)\n default:\n return new MaritimeAPIError(status, detail, requestId)\n }\n}\n","import { apiErrorFromStatus, MaritimeConnectionError, MaritimeError } from './errors.js'\n\nexport interface MaritimeClientOptions {\n /**\n * Maritime API key (`mk_...`). Defaults to the `MARITIME_API_KEY` env var.\n * Mint one from the dashboard (Settings → API keys) or `maritime keys create`.\n */\n apiKey?: string\n /** API base URL. Defaults to `MARITIME_API_URL` or `https://api.maritime.sh`. */\n baseUrl?: string\n /** Per-request timeout in ms (default 60_000). */\n timeout?: number\n /** Retries on network errors and 5xx/429 responses (default 2). */\n maxRetries?: number\n /** Inject a custom fetch (tests, proxies, non-global-fetch runtimes). */\n fetch?: typeof fetch\n /** Extra headers sent on every request. */\n defaultHeaders?: Record<string, string>\n}\n\ninterface RequestOptions {\n method: string\n path: string\n query?: Record<string, string | number | boolean | undefined | null>\n body?: unknown\n /** Override retry behaviour for a single call (e.g. non-idempotent POST). */\n idempotent?: boolean\n}\n\nconst DEFAULT_BASE_URL = 'https://api.maritime.sh'\nconst RETRYABLE_STATUS = new Set([429, 500, 502, 503, 504])\n\nfunction resolveApiKey(explicit?: string): string {\n const key = explicit ?? (typeof process !== 'undefined' ? process.env?.MARITIME_API_KEY : undefined)\n if (!key) {\n throw new MaritimeError(\n 'Missing Maritime API key. Pass { apiKey } to the client or set MARITIME_API_KEY.',\n )\n }\n return key\n}\n\nfunction resolveBaseUrl(explicit?: string): string {\n const url =\n explicit ??\n (typeof process !== 'undefined' ? process.env?.MARITIME_API_URL : undefined) ??\n DEFAULT_BASE_URL\n return url.replace(/\\/+$/, '')\n}\n\nconst sleep = (ms: number) => new Promise((r) => setTimeout(r, ms))\n\n/**\n * Thin transport: auth header, JSON encode/decode, typed errors, and bounded\n * retry with exponential backoff on transient failures. No dependencies —\n * uses the runtime's global `fetch` (Node 18+, Bun, Deno, browsers, edge).\n */\nexport class HttpClient {\n private readonly apiKey: string\n private readonly baseUrl: string\n private readonly timeout: number\n private readonly maxRetries: number\n private readonly fetchImpl: typeof fetch\n private readonly defaultHeaders: Record<string, string>\n\n constructor(options: MaritimeClientOptions = {}) {\n this.apiKey = resolveApiKey(options.apiKey)\n this.baseUrl = resolveBaseUrl(options.baseUrl)\n this.timeout = options.timeout ?? 60_000\n this.maxRetries = options.maxRetries ?? 2\n const f = options.fetch ?? (typeof fetch !== 'undefined' ? fetch : undefined)\n if (!f) {\n throw new MaritimeError(\n 'No global fetch available. Use Node 18+, or pass a { fetch } implementation.',\n )\n }\n // Bind so `this` inside native fetch stays correct.\n this.fetchImpl = f.bind(globalThis) as typeof fetch\n this.defaultHeaders = options.defaultHeaders ?? {}\n }\n\n private buildUrl(path: string, query?: RequestOptions['query']): string {\n const url = new URL(this.baseUrl + path)\n if (query) {\n for (const [k, v] of Object.entries(query)) {\n if (v !== undefined && v !== null) url.searchParams.set(k, String(v))\n }\n }\n return url.toString()\n }\n\n async request<T>(opts: RequestOptions): Promise<T> {\n const url = this.buildUrl(opts.path, opts.query)\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.apiKey}`,\n Accept: 'application/json',\n 'User-Agent': 'maritime-sdk',\n ...this.defaultHeaders,\n }\n const init: RequestInit = { method: opts.method, headers }\n if (opts.body !== undefined) {\n headers['Content-Type'] = 'application/json'\n init.body = JSON.stringify(opts.body)\n }\n\n // GET/DELETE are idempotent and safe to retry; POST/PUT retry only on\n // network errors + 429/503 (never on a 5xx that may have applied a write),\n // unless the caller explicitly marks the call idempotent.\n const method = opts.method.toUpperCase()\n const retrySafe = opts.idempotent ?? (method === 'GET' || method === 'DELETE')\n\n let lastErr: unknown\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), this.timeout)\n\n let res: Response\n try {\n res = await this.fetchImpl(url, { ...init, signal: controller.signal })\n } catch (err) {\n // Transport-level failure (DNS, connection, timeout/abort). Retry.\n clearTimeout(timer)\n lastErr = err\n if (attempt < this.maxRetries) {\n await sleep(this.backoff(attempt))\n continue\n }\n const reason = err instanceof Error ? err.message : String(err)\n throw new MaritimeConnectionError(\n `Failed to reach Maritime at ${this.baseUrl}: ${reason}`,\n err,\n )\n }\n clearTimeout(timer)\n\n if (res.ok) return (await this.parseBody(res)) as T\n\n const detail = await this.safeDetail(res)\n const requestId = res.headers.get('x-request-id') ?? undefined\n const retryable =\n attempt < this.maxRetries &&\n RETRYABLE_STATUS.has(res.status) &&\n (retrySafe || res.status === 429 || res.status === 503)\n if (retryable) {\n lastErr = apiErrorFromStatus(res.status, detail, requestId)\n await sleep(this.backoff(attempt, res))\n continue\n }\n throw apiErrorFromStatus(res.status, detail, requestId)\n }\n\n // Exhausted retries on a retryable HTTP status.\n if (lastErr instanceof MaritimeError) throw lastErr\n throw new MaritimeConnectionError(`Request to ${url} failed after retries`, lastErr)\n }\n\n private backoff(attempt: number, res?: Response): number {\n // Honour Retry-After (seconds) when the server sends it.\n const retryAfter = res?.headers.get('retry-after')\n if (retryAfter) {\n const secs = Number(retryAfter)\n if (!Number.isNaN(secs)) return Math.min(secs * 1000, 20_000)\n }\n return Math.min(500 * 2 ** attempt, 8_000)\n }\n\n private async parseBody(res: Response): Promise<unknown> {\n if (res.status === 204) return undefined\n const text = await res.text()\n if (!text) return undefined\n try {\n return JSON.parse(text)\n } catch {\n return text\n }\n }\n\n private async safeDetail(res: Response): Promise<string> {\n try {\n const body = await this.parseBody(res)\n if (body && typeof body === 'object' && 'detail' in body) {\n const d = (body as { detail: unknown }).detail\n if (typeof d === 'string') return d\n return JSON.stringify(d)\n }\n if (typeof body === 'string' && body) return body\n } catch {\n /* fall through */\n }\n return `Request failed with status ${res.status}`\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type {\n Agent,\n ChatOptions,\n ChatResult,\n CreateAgentParams,\n EnvVar,\n ListAgentsParams,\n LogEntry,\n} from '../types.js'\n\n/** Operations on Maritime agents. Access via `maritime.agents`. */\nexport class AgentsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a new agent and kick off its deploy. */\n async create(params: CreateAgentParams): Promise<Agent> {\n return this.http.request<Agent>({\n method: 'POST',\n path: '/api/agents',\n body: toCreateBody(params),\n })\n }\n\n /**\n * Get-or-create an agent by `externalId` — the idempotent entry point for a\n * \"one agent per end-customer\" flow. If an agent with that external id\n * already exists it is returned; otherwise a new one is created. Safe to call\n * on every sign-in.\n */\n async provision(params: CreateAgentParams & { externalId: string }): Promise<Agent> {\n const existing = await this.list({ externalId: params.externalId })\n if (existing.length > 0) return existing[0] as Agent\n // Default the template so we never create a broken bare-framework agent.\n const withTemplate: CreateAgentParams = {\n template: 'openclaw',\n ...params,\n }\n try {\n return await this.create(withTemplate)\n } catch (err) {\n // Lost a race with a concurrent provisioner (unique-name 409). Re-read.\n const raced = await this.list({ externalId: params.externalId })\n if (raced.length > 0) return raced[0] as Agent\n throw err\n }\n }\n\n /** Fetch a single agent by id. */\n async get(agentId: string): Promise<Agent> {\n return this.http.request<Agent>({ method: 'GET', path: `/api/agents/${enc(agentId)}` })\n }\n\n /** List agents, optionally filtered by `externalId` or `name`. */\n async list(params: ListAgentsParams = {}): Promise<Agent[]> {\n return this.http.request<Agent[]>({\n method: 'GET',\n path: '/api/agents',\n query: { externalId: params.externalId, name: params.name },\n })\n }\n\n /**\n * Send a message to an agent and wait for its reply. Sleeping serverless\n * agents auto-wake. Returns `{ response }` (or `{ response: null, error }`\n * if delivery failed — Maritime does not surface that as an HTTP error).\n */\n async chat(agentId: string, message: string, opts: ChatOptions = {}): Promise<ChatResult> {\n return this.http.request<ChatResult>({\n method: 'POST',\n path: `/api/agents/${enc(agentId)}/chat`,\n body: { message, conversation_id: opts.conversationId },\n })\n }\n\n /** Start / wake an agent. */\n async start(agentId: string): Promise<Agent> {\n return this.lifecycle(agentId, 'start')\n }\n\n /** Stop an agent (container stopped, state preserved). */\n async stop(agentId: string): Promise<Agent> {\n return this.lifecycle(agentId, 'stop')\n }\n\n /** Put an agent to sleep (serverless snapshot; cheapest resting state). */\n async sleep(agentId: string): Promise<Agent> {\n return this.lifecycle(agentId, 'sleep')\n }\n\n /** Restart an agent. */\n async restart(agentId: string): Promise<Agent> {\n return this.lifecycle(agentId, 'restart')\n }\n\n /** Delete an agent and all its resources (container, volume, network). */\n async delete(agentId: string): Promise<void> {\n await this.http.request<void>({ method: 'DELETE', path: `/api/agents/${enc(agentId)}` })\n }\n\n /** List an agent's env vars (secret values are masked). */\n async listEnv(agentId: string): Promise<EnvVar[]> {\n return this.http.request<EnvVar[]>({ method: 'GET', path: `/api/agents/${enc(agentId)}/env` })\n }\n\n /**\n * Set (upsert) an env var. Secrets are encrypted at rest. Changes reach a\n * running container after {@link reloadEnv} or a restart.\n */\n async setEnv(\n agentId: string,\n key: string,\n value: string,\n opts: { secret?: boolean } = {},\n ): Promise<EnvVar> {\n return this.http.request<EnvVar>({\n method: 'POST',\n path: `/api/agents/${enc(agentId)}/env`,\n body: { key, value, isSecret: opts.secret ?? true },\n })\n }\n\n /** Delete an env var. */\n async deleteEnv(agentId: string, key: string): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/api/agents/${enc(agentId)}/env/${enc(key)}`,\n })\n }\n\n /** Hot-reload env vars into the running container (falls back to restart). */\n async reloadEnv(agentId: string): Promise<Agent> {\n return this.lifecycle(agentId, 'reload-env')\n }\n\n /** Fetch recent log entries for an agent. */\n async logs(\n agentId: string,\n opts: { limit?: number; level?: string } = {},\n ): Promise<LogEntry[]> {\n return this.http.request<LogEntry[]>({\n method: 'GET',\n path: `/api/agents/${enc(agentId)}/logs`,\n query: { limit: opts.limit, level: opts.level },\n })\n }\n\n private lifecycle(agentId: string, action: string): Promise<Agent> {\n return this.http.request<Agent>({\n method: 'POST',\n path: `/api/agents/${enc(agentId)}/${action}`,\n // Lifecycle transitions are effectively idempotent; safe to retry.\n idempotent: true,\n })\n }\n}\n\nconst enc = encodeURIComponent\n\nfunction toCreateBody(p: CreateAgentParams): Record<string, unknown> {\n return {\n name: p.name,\n templateId: p.template,\n externalId: p.externalId,\n description: p.description,\n instructions: p.instructions,\n tier: p.tier,\n memMb: p.memMb,\n vcpus: p.vcpus,\n idleTtlSeconds: p.idleTtlSeconds,\n diskGb: p.diskGb,\n githubRepo: p.githubRepo,\n imageName: p.imageName,\n initialEnvVars: p.env?.map((e) => ({\n key: e.key,\n value: e.value,\n isSecret: e.secret ?? true,\n })),\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { ApiKey, CreatedApiKey, CreateApiKeyParams } from '../types.js'\n\n/**\n * Manage API keys (`mk_...`) programmatically. Access via `maritime.keys`.\n *\n * Minting a key requires the caller's own key to carry the `manage` scope (or\n * be a dashboard session). Hand a narrower-scoped key to a subsystem that only\n * needs part of the surface — e.g. a `deploy`-scoped key for a worker that only\n * chats to agents.\n */\nexport class KeysResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Mint a new key. The raw key is returned once — store it immediately. */\n async create(params: CreateApiKeyParams): Promise<CreatedApiKey> {\n return this.http.request<CreatedApiKey>({\n method: 'POST',\n path: '/api/v1/keys',\n body: {\n name: params.name,\n scopes: params.scopes ?? ['provision', 'deploy', 'secrets', 'manage'],\n expires_in_days: params.expiresInDays,\n },\n })\n }\n\n /** List the caller's keys (raw values are never returned again). */\n async list(): Promise<ApiKey[]> {\n return this.http.request<ApiKey[]>({ method: 'GET', path: '/api/v1/keys' })\n }\n\n /** Revoke a key by id. */\n async revoke(keyId: string): Promise<void> {\n await this.http.request<void>({ method: 'DELETE', path: `/api/v1/keys/${encodeURIComponent(keyId)}` })\n }\n}\n","import { HttpClient, type MaritimeClientOptions } from './http.js'\nimport { AgentsResource } from './resources/agents.js'\nimport { KeysResource } from './resources/keys.js'\n\nexport type { MaritimeClientOptions } from './http.js'\nexport * from './types.js'\nexport {\n MaritimeError,\n MaritimeConnectionError,\n MaritimeAPIError,\n MaritimeAuthError,\n MaritimePaymentRequiredError,\n MaritimeNotFoundError,\n MaritimeConflictError,\n MaritimeRateLimitError,\n} from './errors.js'\n\n/**\n * The Maritime client. Provision and drive AI agents on Maritime's serverless\n * infrastructure from your own backend.\n *\n * ```ts\n * import { Maritime } from 'maritime-sdk'\n *\n * const maritime = new Maritime({ apiKey: process.env.MARITIME_API_KEY })\n *\n * // When YOUR user signs up, give them their own agent (idempotent):\n * const agent = await maritime.agents.provision({\n * externalId: `customer_${userId}`,\n * name: `assistant-${userId}`,\n * template: 'openclaw',\n * })\n *\n * const { response } = await maritime.agents.chat(agent.id, 'Hello!')\n * ```\n */\nexport class Maritime {\n readonly agents: AgentsResource\n readonly keys: KeysResource\n /** The underlying transport — escape hatch for endpoints not yet wrapped. */\n readonly http: HttpClient\n\n constructor(options: MaritimeClientOptions = {}) {\n this.http = new HttpClient(options)\n this.agents = new AgentsResource(this.http)\n this.keys = new KeysResource(this.http)\n }\n}\n\nexport default Maritime\n"],"mappings":";AACO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAEZ,WAAO,eAAe,MAAM,WAAW,SAAS;AAAA,EAClD;AACF;AAGO,IAAM,0BAAN,cAAsC,cAAc;AAAA,EAEzD,YAAY,SAAiB,OAAiB;AAC5C,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,QAAQ;AAAA,EACf;AACF;AAGO,IAAM,mBAAN,cAA+B,cAAc;AAAA,EAMlD,YAAY,QAAgB,QAAgB,WAAoB;AAC9D,UAAM,sBAAsB,MAAM,KAAK,MAAM,EAAE;AAC/C,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,SAAS;AACd,SAAK,YAAY;AAAA,EACnB;AACF;AAGO,IAAM,oBAAN,cAA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AAM,OAA0B;AAC9B,WAAO,KAAK,KAAK,QAAkB,EAAE,QAAQ,OAAO,MAAM,eAAe,CAAC;AAAA,EAC5E;AAAA;AAAA,EAGA,MAAM,OAAO,OAA8B;AACzC,UAAM,KAAK,KAAK,QAAc,EAAE,QAAQ,UAAU,MAAM,gBAAgB,mBAAmB,KAAK,CAAC,GAAG,CAAC;AAAA,EACvG;AACF;;;ACAO,IAAM,WAAN,MAAe;AAAA,EAMpB,YAAY,UAAiC,CAAC,GAAG;AAC/C,SAAK,OAAO,IAAI,WAAW,OAAO;AAClC,SAAK,SAAS,IAAI,eAAe,KAAK,IAAI;AAC1C,SAAK,OAAO,IAAI,aAAa,KAAK,IAAI;AAAA,EACxC;AACF;AAEA,IAAO,gBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/http.ts","../src/resources/agents.ts","../src/resources/keys.ts","../src/resources/webhooks.ts","../src/index.ts"],"sourcesContent":["/** Base class for every error the SDK throws. Catch this to catch them all. */\nexport class MaritimeError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'MaritimeError'\n // Restore prototype chain when compiled to ES5-ish targets.\n Object.setPrototypeOf(this, new.target.prototype)\n }\n}\n\n/** The request never reached Maritime (DNS, connection refused, timeout, …). */\nexport class MaritimeConnectionError extends MaritimeError {\n readonly cause?: unknown\n constructor(message: string, cause?: unknown) {\n super(message)\n this.name = 'MaritimeConnectionError'\n this.cause = cause\n }\n}\n\n/** Maritime returned a non-2xx response. Subclassed by status below. */\nexport class MaritimeAPIError extends MaritimeError {\n readonly status: number\n readonly detail: string\n /** Value of the `x-request-id` response header, when present. */\n readonly requestId?: string\n\n constructor(status: number, detail: string, requestId?: string) {\n super(`Maritime API error ${status}: ${detail}`)\n this.name = 'MaritimeAPIError'\n this.status = status\n this.detail = detail\n this.requestId = requestId\n }\n}\n\n/** 401 / 403 — bad or insufficiently-scoped API key. */\nexport class MaritimeAuthError extends MaritimeAPIError {\n constructor(status: number, detail: string, requestId?: string) {\n super(status, detail, requestId)\n this.name = 'MaritimeAuthError'\n }\n}\n\n/** 402 — the account wallet needs funding before this action can proceed. */\nexport class MaritimePaymentRequiredError extends MaritimeAPIError {\n constructor(status: number, detail: string, requestId?: string) {\n super(status, detail, requestId)\n this.name = 'MaritimePaymentRequiredError'\n }\n}\n\n/** 404 — the agent (or other resource) does not exist or is not yours. */\nexport class MaritimeNotFoundError extends MaritimeAPIError {\n constructor(status: number, detail: string, requestId?: string) {\n super(status, detail, requestId)\n this.name = 'MaritimeNotFoundError'\n }\n}\n\n/** 409 — a uniqueness conflict (e.g. an agent with that name already exists). */\nexport class MaritimeConflictError extends MaritimeAPIError {\n constructor(status: number, detail: string, requestId?: string) {\n super(status, detail, requestId)\n this.name = 'MaritimeConflictError'\n }\n}\n\n/** 429 — rate limited. */\nexport class MaritimeRateLimitError extends MaritimeAPIError {\n constructor(status: number, detail: string, requestId?: string) {\n super(status, detail, requestId)\n this.name = 'MaritimeRateLimitError'\n }\n}\n\n/** Build the most specific error subclass for an HTTP status. */\nexport function apiErrorFromStatus(\n status: number,\n detail: string,\n requestId?: string,\n): MaritimeAPIError {\n switch (status) {\n case 401:\n case 403:\n return new MaritimeAuthError(status, detail, requestId)\n case 402:\n return new MaritimePaymentRequiredError(status, detail, requestId)\n case 404:\n return new MaritimeNotFoundError(status, detail, requestId)\n case 409:\n return new MaritimeConflictError(status, detail, requestId)\n case 429:\n return new MaritimeRateLimitError(status, detail, requestId)\n default:\n return new MaritimeAPIError(status, detail, requestId)\n }\n}\n","import { apiErrorFromStatus, MaritimeConnectionError, MaritimeError } from './errors.js'\n\nexport interface MaritimeClientOptions {\n /**\n * Maritime API key (`mk_...`). Defaults to the `MARITIME_API_KEY` env var.\n * Mint one from the dashboard (Settings → API keys) or `maritime keys create`.\n */\n apiKey?: string\n /** API base URL. Defaults to `MARITIME_API_URL` or `https://api.maritime.sh`. */\n baseUrl?: string\n /** Per-request timeout in ms (default 60_000). */\n timeout?: number\n /** Retries on network errors and 5xx/429 responses (default 2). */\n maxRetries?: number\n /** Inject a custom fetch (tests, proxies, non-global-fetch runtimes). */\n fetch?: typeof fetch\n /** Extra headers sent on every request. */\n defaultHeaders?: Record<string, string>\n}\n\ninterface RequestOptions {\n method: string\n path: string\n query?: Record<string, string | number | boolean | undefined | null>\n body?: unknown\n /** Override retry behaviour for a single call (e.g. non-idempotent POST). */\n idempotent?: boolean\n}\n\nconst DEFAULT_BASE_URL = 'https://api.maritime.sh'\nconst RETRYABLE_STATUS = new Set([429, 500, 502, 503, 504])\n\nfunction resolveApiKey(explicit?: string): string {\n const key = explicit ?? (typeof process !== 'undefined' ? process.env?.MARITIME_API_KEY : undefined)\n if (!key) {\n throw new MaritimeError(\n 'Missing Maritime API key. Pass { apiKey } to the client or set MARITIME_API_KEY.',\n )\n }\n return key\n}\n\nfunction resolveBaseUrl(explicit?: string): string {\n const url =\n explicit ??\n (typeof process !== 'undefined' ? process.env?.MARITIME_API_URL : undefined) ??\n DEFAULT_BASE_URL\n return url.replace(/\\/+$/, '')\n}\n\nconst sleep = (ms: number) => new Promise((r) => setTimeout(r, ms))\n\n/**\n * Thin transport: auth header, JSON encode/decode, typed errors, and bounded\n * retry with exponential backoff on transient failures. No dependencies —\n * uses the runtime's global `fetch` (Node 18+, Bun, Deno, browsers, edge).\n */\nexport class HttpClient {\n private readonly apiKey: string\n private readonly baseUrl: string\n private readonly timeout: number\n private readonly maxRetries: number\n private readonly fetchImpl: typeof fetch\n private readonly defaultHeaders: Record<string, string>\n\n constructor(options: MaritimeClientOptions = {}) {\n this.apiKey = resolveApiKey(options.apiKey)\n this.baseUrl = resolveBaseUrl(options.baseUrl)\n this.timeout = options.timeout ?? 60_000\n this.maxRetries = options.maxRetries ?? 2\n const f = options.fetch ?? (typeof fetch !== 'undefined' ? fetch : undefined)\n if (!f) {\n throw new MaritimeError(\n 'No global fetch available. Use Node 18+, or pass a { fetch } implementation.',\n )\n }\n // Bind so `this` inside native fetch stays correct.\n this.fetchImpl = f.bind(globalThis) as typeof fetch\n this.defaultHeaders = options.defaultHeaders ?? {}\n }\n\n private buildUrl(path: string, query?: RequestOptions['query']): string {\n const url = new URL(this.baseUrl + path)\n if (query) {\n for (const [k, v] of Object.entries(query)) {\n if (v !== undefined && v !== null) url.searchParams.set(k, String(v))\n }\n }\n return url.toString()\n }\n\n async request<T>(opts: RequestOptions): Promise<T> {\n const url = this.buildUrl(opts.path, opts.query)\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.apiKey}`,\n Accept: 'application/json',\n 'User-Agent': 'maritime-sdk',\n ...this.defaultHeaders,\n }\n const init: RequestInit = { method: opts.method, headers }\n if (opts.body !== undefined) {\n headers['Content-Type'] = 'application/json'\n init.body = JSON.stringify(opts.body)\n }\n\n // GET/DELETE are idempotent and safe to retry; POST/PUT retry only on\n // network errors + 429/503 (never on a 5xx that may have applied a write),\n // unless the caller explicitly marks the call idempotent.\n const method = opts.method.toUpperCase()\n const retrySafe = opts.idempotent ?? (method === 'GET' || method === 'DELETE')\n\n let lastErr: unknown\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), this.timeout)\n\n let res: Response\n try {\n res = await this.fetchImpl(url, { ...init, signal: controller.signal })\n } catch (err) {\n // Transport-level failure (DNS, connection, timeout/abort). Retry.\n clearTimeout(timer)\n lastErr = err\n if (attempt < this.maxRetries) {\n await sleep(this.backoff(attempt))\n continue\n }\n const reason = err instanceof Error ? err.message : String(err)\n throw new MaritimeConnectionError(\n `Failed to reach Maritime at ${this.baseUrl}: ${reason}`,\n err,\n )\n }\n clearTimeout(timer)\n\n if (res.ok) return (await this.parseBody(res)) as T\n\n const detail = await this.safeDetail(res)\n const requestId = res.headers.get('x-request-id') ?? undefined\n const retryable =\n attempt < this.maxRetries &&\n RETRYABLE_STATUS.has(res.status) &&\n (retrySafe || res.status === 429 || res.status === 503)\n if (retryable) {\n lastErr = apiErrorFromStatus(res.status, detail, requestId)\n await sleep(this.backoff(attempt, res))\n continue\n }\n throw apiErrorFromStatus(res.status, detail, requestId)\n }\n\n // Exhausted retries on a retryable HTTP status.\n if (lastErr instanceof MaritimeError) throw lastErr\n throw new MaritimeConnectionError(`Request to ${url} failed after retries`, lastErr)\n }\n\n private backoff(attempt: number, res?: Response): number {\n // Honour Retry-After (seconds) when the server sends it.\n const retryAfter = res?.headers.get('retry-after')\n if (retryAfter) {\n const secs = Number(retryAfter)\n if (!Number.isNaN(secs)) return Math.min(secs * 1000, 20_000)\n }\n return Math.min(500 * 2 ** attempt, 8_000)\n }\n\n private async parseBody(res: Response): Promise<unknown> {\n if (res.status === 204) return undefined\n const text = await res.text()\n if (!text) return undefined\n try {\n return JSON.parse(text)\n } catch {\n return text\n }\n }\n\n private async safeDetail(res: Response): Promise<string> {\n try {\n const body = await this.parseBody(res)\n if (body && typeof body === 'object' && 'detail' in body) {\n const d = (body as { detail: unknown }).detail\n if (typeof d === 'string') return d\n return JSON.stringify(d)\n }\n if (typeof body === 'string' && body) return body\n } catch {\n /* fall through */\n }\n return `Request failed with status ${res.status}`\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type {\n Agent,\n ChatOptions,\n ChatResult,\n CreateAgentParams,\n EnvVar,\n ListAgentsParams,\n LogEntry,\n} from '../types.js'\n\n/** Operations on Maritime agents. Access via `maritime.agents`. */\nexport class AgentsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a new agent and kick off its deploy. */\n async create(params: CreateAgentParams): Promise<Agent> {\n return this.http.request<Agent>({\n method: 'POST',\n path: '/api/agents',\n body: toCreateBody(params),\n })\n }\n\n /**\n * Get-or-create an agent by `externalId` — the idempotent entry point for a\n * \"one agent per end-customer\" flow. If an agent with that external id\n * already exists it is returned; otherwise a new one is created. Safe to call\n * on every sign-in.\n */\n async provision(params: CreateAgentParams & { externalId: string }): Promise<Agent> {\n const existing = await this.list({ externalId: params.externalId })\n if (existing.length > 0) return existing[0] as Agent\n // Default the template so we never create a broken bare-framework agent.\n const withTemplate: CreateAgentParams = {\n template: 'openclaw',\n ...params,\n }\n try {\n return await this.create(withTemplate)\n } catch (err) {\n // Lost a race with a concurrent provisioner (unique-name 409). Re-read.\n const raced = await this.list({ externalId: params.externalId })\n if (raced.length > 0) return raced[0] as Agent\n throw err\n }\n }\n\n /** Fetch a single agent by id. */\n async get(agentId: string): Promise<Agent> {\n return this.http.request<Agent>({ method: 'GET', path: `/api/agents/${enc(agentId)}` })\n }\n\n /** List agents, optionally filtered by `externalId` or `name`. */\n async list(params: ListAgentsParams = {}): Promise<Agent[]> {\n return this.http.request<Agent[]>({\n method: 'GET',\n path: '/api/agents',\n query: { externalId: params.externalId, name: params.name },\n })\n }\n\n /**\n * Send a message to an agent and wait for its reply. Sleeping serverless\n * agents auto-wake. Returns `{ response }` (or `{ response: null, error }`\n * if delivery failed — Maritime does not surface that as an HTTP error).\n */\n async chat(agentId: string, message: string, opts: ChatOptions = {}): Promise<ChatResult> {\n return this.http.request<ChatResult>({\n method: 'POST',\n path: `/api/agents/${enc(agentId)}/chat`,\n body: { message, conversation_id: opts.conversationId },\n })\n }\n\n /** Start / wake an agent. */\n async start(agentId: string): Promise<Agent> {\n return this.lifecycle(agentId, 'start')\n }\n\n /** Stop an agent (container stopped, state preserved). */\n async stop(agentId: string): Promise<Agent> {\n return this.lifecycle(agentId, 'stop')\n }\n\n /** Put an agent to sleep (serverless snapshot; cheapest resting state). */\n async sleep(agentId: string): Promise<Agent> {\n return this.lifecycle(agentId, 'sleep')\n }\n\n /** Restart an agent. */\n async restart(agentId: string): Promise<Agent> {\n return this.lifecycle(agentId, 'restart')\n }\n\n /** Delete an agent and all its resources (container, volume, network). */\n async delete(agentId: string): Promise<void> {\n await this.http.request<void>({ method: 'DELETE', path: `/api/agents/${enc(agentId)}` })\n }\n\n /** List an agent's env vars (secret values are masked). */\n async listEnv(agentId: string): Promise<EnvVar[]> {\n return this.http.request<EnvVar[]>({ method: 'GET', path: `/api/agents/${enc(agentId)}/env` })\n }\n\n /**\n * Set (upsert) an env var. Secrets are encrypted at rest. Changes reach a\n * running container after {@link reloadEnv} or a restart.\n */\n async setEnv(\n agentId: string,\n key: string,\n value: string,\n opts: { secret?: boolean } = {},\n ): Promise<EnvVar> {\n return this.http.request<EnvVar>({\n method: 'POST',\n path: `/api/agents/${enc(agentId)}/env`,\n body: { key, value, isSecret: opts.secret ?? true },\n })\n }\n\n /** Delete an env var. */\n async deleteEnv(agentId: string, key: string): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/api/agents/${enc(agentId)}/env/${enc(key)}`,\n })\n }\n\n /** Hot-reload env vars into the running container (falls back to restart). */\n async reloadEnv(agentId: string): Promise<Agent> {\n return this.lifecycle(agentId, 'reload-env')\n }\n\n /** Fetch recent log entries for an agent. */\n async logs(\n agentId: string,\n opts: { limit?: number; level?: string } = {},\n ): Promise<LogEntry[]> {\n return this.http.request<LogEntry[]>({\n method: 'GET',\n path: `/api/agents/${enc(agentId)}/logs`,\n query: { limit: opts.limit, level: opts.level },\n })\n }\n\n private lifecycle(agentId: string, action: string): Promise<Agent> {\n return this.http.request<Agent>({\n method: 'POST',\n path: `/api/agents/${enc(agentId)}/${action}`,\n // Lifecycle transitions are effectively idempotent; safe to retry.\n idempotent: true,\n })\n }\n}\n\nconst enc = encodeURIComponent\n\nfunction toCreateBody(p: CreateAgentParams): Record<string, unknown> {\n return {\n name: p.name,\n templateId: p.template,\n externalId: p.externalId,\n description: p.description,\n instructions: p.instructions,\n tier: p.tier,\n memMb: p.memMb,\n vcpus: p.vcpus,\n idleTtlSeconds: p.idleTtlSeconds,\n diskGb: p.diskGb,\n githubRepo: p.githubRepo,\n imageName: p.imageName,\n initialEnvVars: p.env?.map((e) => ({\n key: e.key,\n value: e.value,\n isSecret: e.secret ?? true,\n })),\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { ApiKey, CreatedApiKey, CreateApiKeyParams } from '../types.js'\n\n/**\n * Manage API keys (`mk_...`) programmatically. Access via `maritime.keys`.\n *\n * Minting a key requires the caller's own key to carry the `manage` scope (or\n * be a dashboard session). Hand a narrower-scoped key to a subsystem that only\n * needs part of the surface — e.g. a `deploy`-scoped key for a worker that only\n * chats to agents.\n */\nexport class KeysResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Mint a new key. The raw key is returned once — store it immediately. */\n async create(params: CreateApiKeyParams): Promise<CreatedApiKey> {\n return this.http.request<CreatedApiKey>({\n method: 'POST',\n path: '/api/v1/keys',\n body: {\n name: params.name,\n scopes: params.scopes ?? ['provision', 'deploy', 'secrets', 'manage'],\n expires_in_days: params.expiresInDays,\n },\n })\n }\n\n /** List the caller's keys (raw values are never returned again). */\n async list(): Promise<ApiKey[]> {\n return this.http.request<ApiKey[]>({ method: 'GET', path: '/api/v1/keys' })\n }\n\n /** Revoke a key by id. */\n async revoke(keyId: string): Promise<void> {\n await this.http.request<void>({ method: 'DELETE', path: `/api/v1/keys/${encodeURIComponent(keyId)}` })\n }\n}\n","import type { HttpClient } from '../http.js'\nimport type { CreatedWebhook, CreateWebhookParams, Webhook, WebhookTestResult } from '../types.js'\n\n/**\n * Manage outbound webhook subscriptions. Access via `maritime.webhooks`.\n *\n * Subscribe a URL to receive signed agent lifecycle events (agent.deployed,\n * agent.error, agent.sleeping, agent.woken, agent.restarted, agent.stopped)\n * instead of polling. Each delivery carries an `X-Maritime-Signature:\n * sha256=<hmac>` header — verify it with the subscription's secret. The event\n * body includes the agent's `external_id` so you can route to your own customer.\n */\nexport class WebhooksResource {\n constructor(private readonly http: HttpClient) {}\n\n /** Create a subscription. The signing `secret` is returned once. */\n async create(params: CreateWebhookParams): Promise<CreatedWebhook> {\n return this.http.request<CreatedWebhook>({\n method: 'POST',\n path: '/api/v1/webhooks',\n body: { url: params.url, events: params.events ?? [] },\n })\n }\n\n /** List your subscriptions (secrets are never returned again). */\n async list(): Promise<Webhook[]> {\n return this.http.request<Webhook[]>({ method: 'GET', path: '/api/v1/webhooks' })\n }\n\n /** Delete a subscription. */\n async delete(id: string): Promise<void> {\n await this.http.request<void>({\n method: 'DELETE',\n path: `/api/v1/webhooks/${encodeURIComponent(id)}`,\n })\n }\n\n /** Send a synthetic `ping` to the subscription's URL and return the result. */\n async test(id: string): Promise<WebhookTestResult> {\n return this.http.request<WebhookTestResult>({\n method: 'POST',\n path: `/api/v1/webhooks/${encodeURIComponent(id)}/test`,\n })\n }\n}\n","import { HttpClient, type MaritimeClientOptions } from './http.js'\nimport { AgentsResource } from './resources/agents.js'\nimport { KeysResource } from './resources/keys.js'\nimport { WebhooksResource } from './resources/webhooks.js'\n\nexport type { MaritimeClientOptions } from './http.js'\nexport * from './types.js'\nexport {\n MaritimeError,\n MaritimeConnectionError,\n MaritimeAPIError,\n MaritimeAuthError,\n MaritimePaymentRequiredError,\n MaritimeNotFoundError,\n MaritimeConflictError,\n MaritimeRateLimitError,\n} from './errors.js'\n\n/**\n * The Maritime client. Provision and drive AI agents on Maritime's serverless\n * infrastructure from your own backend.\n *\n * ```ts\n * import { Maritime } from 'maritime-sdk'\n *\n * const maritime = new Maritime({ apiKey: process.env.MARITIME_API_KEY })\n *\n * // When YOUR user signs up, give them their own agent (idempotent):\n * const agent = await maritime.agents.provision({\n * externalId: `customer_${userId}`,\n * name: `assistant-${userId}`,\n * template: 'openclaw',\n * })\n *\n * const { response } = await maritime.agents.chat(agent.id, 'Hello!')\n * ```\n */\nexport class Maritime {\n readonly agents: AgentsResource\n readonly keys: KeysResource\n readonly webhooks: WebhooksResource\n /** The underlying transport — escape hatch for endpoints not yet wrapped. */\n readonly http: HttpClient\n\n constructor(options: MaritimeClientOptions = {}) {\n this.http = new HttpClient(options)\n this.agents = new AgentsResource(this.http)\n this.keys = new KeysResource(this.http)\n this.webhooks = new WebhooksResource(this.http)\n }\n}\n\nexport default Maritime\n"],"mappings":";AACO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAEZ,WAAO,eAAe,MAAM,WAAW,SA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;AACjD,WAAO,KAAK,KAAK,QAA2B;AAAA,MAC1C,QAAQ;AAAA,MACR,MAAM,oBAAoB,mBAAmB,EAAE,CAAC;AAAA,IAClD,CAAC;AAAA,EACH;AACF;;;ACPO,IAAM,WAAN,MAAe;AAAA,EAOpB,YAAY,UAAiC,CAAC,GAAG;AAC/C,SAAK,OAAO,IAAI,WAAW,OAAO;AAClC,SAAK,SAAS,IAAI,eAAe,KAAK,IAAI;AAC1C,SAAK,OAAO,IAAI,aAAa,KAAK,IAAI;AACtC,SAAK,WAAW,IAAI,iBAAiB,KAAK,IAAI;AAAA,EAChD;AACF;AAEA,IAAO,gBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maritime-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Official TypeScript SDK for Maritime — provision and drive AI agents on Maritime's serverless infrastructure from your own backend.",
5
5
  "keywords": [
6
6
  "maritime",
@@ -11,14 +11,14 @@
11
11
  "serverless",
12
12
  "agent-infrastructure"
13
13
  ],
14
- "homepage": "https://maritime.sh",
14
+ "homepage": "https://maritime.sh/docs/build",
15
15
  "repository": {
16
16
  "type": "git",
17
- "url": "git+https://github.com/mariagorskikh/maritime.git",
18
- "directory": "frontend/sdk"
17
+ "url": "git+https://github.com/mariagorskikh/maritime-sdk.git",
18
+ "directory": "typescript"
19
19
  },
20
20
  "bugs": {
21
- "url": "https://github.com/mariagorskikh/maritime/issues"
21
+ "url": "https://github.com/mariagorskikh/maritime-sdk/issues"
22
22
  },
23
23
  "license": "MIT",
24
24
  "author": "Maritime",
@@ -47,6 +47,7 @@
47
47
  "prepublishOnly": "npm run build"
48
48
  },
49
49
  "devDependencies": {
50
+ "@types/node": "^20.19.43",
50
51
  "tsup": "^8.3.5",
51
52
  "typescript": "^5.6.3",
52
53
  "vitest": "^2.1.5"