import type { HttpClient } from "../core/http.js"; import { type OtelStreamEvent, type OtelStreamOptions, type OtelSummary, type OtelThreat, type OtelTopology } from "./otel.js"; import type { ApprovalListResponse, CreatePlatformAppRequest, UpdatePlatformAppRequest, PlatformAppResponse, PlatformAppCreatedResponse, PlatformAppListResponse, CreateTemplateRequest, TemplateResponse, TemplateListResponse, FleetSummaryResponse, ListFleetAgentsResponse, BulkPatchFleetResponse, FleetRolloutRequest, FleetRolloutResponse, PauseFleetResponse, UpsertPlatformUserRequest, PlatformUserResponse, PlatformConnectedUserListResponse, BootstrapRequest, BootstrapResponse, ReissueClaimRequest, ReissueClaimResponse, ConnectedAppListResponse, ClaimPreviewResponse, ClaimRedeemResponse, RotatePlatformKeyRequest, RotatePlatformKeyResponse, MarketplaceResponse, GrantResourcesRequest, GrantResourcesResponse, GrantListResponse, UpdateConnectionDelegationRequest, OneclawResponse, AppUsageReport } from "../types.js"; export interface CreateSpendPolicyRequest { user_id?: string; to_allowlist?: string[]; to_denylist?: string[]; max_value_per_tx_eth?: string; daily_limit_eth?: string; allowed_chains?: string[]; allowed_tokens?: string[]; max_transactions_per_day?: number; inference_allowance_usd?: string; inference_reserved_pct?: number; inference_hard_stop?: boolean; inference_allowance_mode?: string; max_request_cost_usd?: string; } export interface SpendPolicyResponse { id: string; platform_app_id: string; user_id?: string; to_allowlist?: string[]; to_denylist?: string[]; max_value_per_tx_eth?: string; daily_limit_eth?: string; allowed_chains?: string[]; allowed_tokens?: string[]; max_transactions_per_day?: number; inference_allowance_usd?: string; inference_reserved_pct?: number; inference_hard_stop?: boolean; inference_allowance_mode?: string; max_request_cost_usd?: string; created_at: string; updated_at: string; } export interface SiweChallengeRequest { domain?: string; } export interface SiweChallengeResponse { nonce: string; expires_in: number; domain: string; } export interface ClaimStatusResponse { status: string; redeemed_at?: string; } export interface ConnectionDetailResponse { connection_id: string; user_id: string; status: string; entitlement_status: string; /** Tier granted to end-user org when billing_model is platform_pays. */ provisioned_tier?: string | null; wallet_address?: string; vault_ids: string[]; agent_ids: string[]; runtime_ids?: string[]; automation_ids?: string[]; claimed_at?: string; claim: ClaimStatusResponse; } export interface CreateConnectionRuntimeRequest { name: string; agent_id?: string; template?: string; preset?: string; env_public?: Record; idle_timeout_secs?: number; expose_http?: boolean; slug?: string; inbound_auth?: string; startup_command?: string; } export interface ConnectionRuntimeResponse { id: string; agent_id: string; name: string; template?: string; preset: string; provider: string; status: string; } export interface ConnectionAgentChatRequest { message: string; conversation_id?: string; mode?: string; model?: string; provider?: string; system_prompt?: string; /** Alias for system_prompt (OpenAI-style). */ system?: string; messages?: Array<{ role: string; content: string; }>; } export interface CreateConnectionPendingApprovalRequest { agent_id?: string; policy_id?: string; action?: string; action_payload: Record; summary?: string; } export interface CreateConnectionPendingApprovalResponse { pending_approval_id: string; required_approvals: number; current_approvals: number; expires_at: string; status: string; message: string; } export interface InspectContentRequest { content: string; context?: "input" | "output"; } export interface InspectContentResponse { safe: boolean; verdict: "clean" | "malicious"; threat_count: number; threats: Array<{ type: string; pattern: string; severity: string; }>; unicode_normalized?: boolean; normalized_content?: string; } export interface PlatformWebhookInfoResponse { app_id: string; webhook_configured: boolean; webhook_url_host?: string; platform_events: string[]; org_webhooks_note: string; } export interface DecideConnectionPendingApprovalRequest { decision: "approve" | "reject" | "approved" | "rejected"; payload_hash: string; reason?: string; credential_type?: string; } export interface DecideConnectionApprovalRequest { decision: "approved" | "rejected" | "approve" | "reject"; reason?: string; } export interface ConnectionUsageResponse { connection_id: string; period: string; inference_spent_usd: string; } export interface EntitlementEvaluationResponse { id: string; status: string; watch_kind: string; chain: string; holder_address: string; last_value_raw?: string; last_checked_at?: string; } export interface EntitlementsListResponse { evaluations: EntitlementEvaluationResponse[]; } export interface TemplatePreviewRequest { parameters?: Record; subject?: { user_id?: string; external_subject?: string; wallet_address?: string; email?: string; }; } export interface TemplatePreviewResponse { resolved_spec: Record; } export interface InferenceBudgetResponse { allowance_usd: string; spent_usd: string; remaining_usd: string; reserved_pct: number; max_request_cost_usd: string; period_end: string; connection_id?: string; } export interface ConnectionSigningKeyPublic { chain: string; address: string; public_key: string; curve: string; } export interface ConnectionSigningKeyListResponse { agent_id: string; keys: ConnectionSigningKeyPublic[]; } export interface ConnectionSigningKeyDetailResponse { agent_id: string; chain: string; address: string; public_key: string; curve: string; } export interface SpendPolicyListResponse { policies: SpendPolicyResponse[]; } export interface UpdateTemplateRequest { name?: string; description?: string; spec?: Record; is_active?: boolean; } export interface PlatformAuditEvent { id: string; action: string; actor_id: string; resource_type?: string; resource_id?: string; metadata?: Record; created_at: string; } export interface PlatformAuditResponse { events: PlatformAuditEvent[]; total: number; } export interface PlatformRuntimesResponse { runtimes: Array>; } export interface PlatformAutomationsResponse { automations: Array>; } export interface PlatformAppStatsResponse { total_connections: number; active_connections: number; claimed_connections: number; total_bootstraps: number; total_grants: number; } export interface RotateWebhookSecretResponse { webhook_secret: string; } export interface PlatformAppDeleteResponse { deleted: boolean; soft_delete: boolean; slug_released: boolean; former_slug: string; } export interface TransferPlatformAppOwnershipRequest { target_org_id?: string; target_user_email?: string; } export interface TransferPlatformAppOwnershipResponse { app_id: string; former_org_id: string; new_org_id: string; message: string; } export interface ConnectionSpendPolicyResponse { policy: SpendPolicyResponse | null; } /** * Platform API — build multi-tenant apps on top of 1Claw. * Manage platform apps, templates, user provisioning, and bootstrapping. */ export declare class PlatformResource { private readonly http; constructor(http: HttpClient); /** Create a new platform app. Returns the app record and a one-time API key. */ createApp(data: CreatePlatformAppRequest): Promise>; /** List all platform apps in the current organization. */ listApps(): Promise>; /** Fetch a single platform app by ID. */ getApp(appId: string): Promise>; /** Update a platform app's settings. */ updateApp(appId: string, data: UpdatePlatformAppRequest): Promise>; /** Soft-delete a platform app and release its slug. */ deleteApp(appId: string): Promise>; /** Transfer app ownership to another organization (step-up auth required). */ transferAppOwnership(appId: string, body: TransferPlatformAppOwnershipRequest, options?: { confirmToken?: string; }): Promise>; /** Rotate a platform app's API key. Returns the new one-time key. */ rotateKey(appId: string, data?: RotatePlatformKeyRequest): Promise>; /** Rotate a platform app's webhook signing secret. Returns the new secret (one-time). */ rotateWebhookSecret(appId: string): Promise>; /** Get aggregate statistics for a platform app (connections, bootstraps, grants). */ getAppStats(appId: string): Promise>; /** Browse the public platform marketplace (no auth required). */ marketplace(params?: { page?: number; per_page?: number; q?: string; category?: string; }): Promise>; /** Create a template for a platform app. */ createTemplate(appId: string, data: CreateTemplateRequest): Promise>; /** List all templates for a platform app. */ listTemplates(appId: string): Promise>; /** Get a single bootstrap template by ID. */ getTemplate(appId: string, templateId: string): Promise>; /** * Fleet summary: how many agents the template provisioned, how they split * across the versions they were built from, and how many a previous * rollout declined to touch. */ getFleet(appId: string, templateId: string): Promise>; /** List the agents in a fleet. */ listFleetAgents(appId: string, templateId: string, params?: { limit?: number; offset?: number; }): Promise>; /** * Apply one patch to every agent in the cohort. * * The allowlist is narrower than a single-agent patch: guardrails and * capability flags (`intents_api_enabled`, `execution_intents_enabled`) * are refused, because changing them for a thousand agents in one request * is a thousand decisions nobody made individually. Read the current * allowlist from `getFleet().bulk_patchable_fields` rather than hard-coding * it. A field outside it returns 400 naming the field, and refuses the * whole patch rather than applying it in part. */ bulkPatchFleet(appId: string, templateId: string, patch: Record): Promise>; /** * Bring the cohort up to the template's current version. * * An agent changed outside fleet control is skipped rather than corrected — * someone changed it for a reason, and a rollout that overwrites that * reason at cohort scale destroys a thousand of them at once. `force: true` * overrides the skip but still cannot carry a guardrail or a capability * flag. `dry_run: true` reports the plan, claims no job, and so never * blocks the real rollout that follows it. * * Only one rollout may run per template at a time; a second returns 409. */ rolloutFleet(appId: string, templateId: string, options?: FleetRolloutRequest): Promise>; /** * Deactivate every agent in the cohort. The blast radius is the point: * this exists for the moment an operator needs a thousand agents to stop. */ pauseFleet(appId: string, templateId: string): Promise>; /** * Upsert (create or match) a platform user via token exchange or email. * * When the user exists in a different org, the API returns 409 with a * `link_required` payload containing an OAuth authorize URL. This method * treats 409 as a successful typed response so callers can branch on * `result.data?.link_required`. */ upsertUser(data: UpsertPlatformUserRequest): Promise>; /** List connected users for a platform app. */ listUsers(appId: string): Promise>; /** Bootstrap a connected user with vaults, agents, and policies from a template. */ bootstrapUser(connectionId: string, data: BootstrapRequest): Promise>; /** List apps connected to the calling user (user-side view). */ listConnectedApps(): Promise>; /** Reissue a claim URL for an existing bootstrapped connection (no re-provisioning). */ reissueClaim(connectionId: string, data?: ReissueClaimRequest): Promise>; /** Disconnect from a platform app. */ disconnectApp(connectionId: string): Promise>; /** Preview a claim token (public, no auth required). */ claimPreview(token: string): Promise>; /** Redeem a claim token to claim bootstrapped resources (public, no auth required). */ claimRedeem(token: string): Promise>; /** Create a spend policy for a platform app. */ createSpendPolicy(appId: string, body: CreateSpendPolicyRequest): Promise>; /** List spend policies for a platform app. */ listSpendPolicies(appId: string): Promise>; /** Get a single spend policy by ID (platform org human JWT). */ getSpendPolicy(appId: string, policyId: string): Promise>; /** Effective spend policy for a connection (`plt_` auth). */ getConnectionSpendPolicy(connectionId: string): Promise>; /** Approvals for a connected user (`plt_` auth). */ listConnectionApprovals(connectionId: string, params?: { status?: "pending" | "approved" | "denied"; risk_tier?: number; limit?: number; offset?: number; }): Promise>; /** Single approval for a connection (`plt_` auth). */ getConnectionApproval(connectionId: string, approvalId: string): Promise>; /** Pending consensus approvals for a connection (`plt_` auth). */ listConnectionPendingApprovals(connectionId: string, params?: { status?: string; limit?: number; offset?: number; }): Promise; payload_hash: string; status: string; }>; total: number; }>>; /** Create a pending consensus approval for a connection agent (`plt_` auth). */ createConnectionPendingApproval(connectionId: string, body: CreateConnectionPendingApprovalRequest): Promise>; /** Single pending consensus approval for a connection (`plt_` auth). */ getConnectionPendingApproval(connectionId: string, approvalId: string): Promise>>; /** Vote on a pending consensus approval (`plt_` auth). */ decideConnectionPendingApproval(connectionId: string, approvalId: string, body: DecideConnectionPendingApprovalRequest): Promise>>; /** Decide a mobile approval for a connection (`plt_` auth). */ decideConnectionApproval(connectionId: string, approvalId: string, body: DecideConnectionApprovalRequest): Promise>>; /** Platform webhook catalog (`plt_` or user JWT). */ getPlatformWebhooks(appId: string): Promise>; /** Create a Cloud Runtime for an agent on a connection (`plt_` auth). */ createConnectionRuntime(connectionId: string, body: CreateConnectionRuntimeRequest): Promise>; /** Get a runtime provisioned on a connection (`plt_` auth). */ getConnectionRuntime(connectionId: string, runtimeId: string): Promise>; /** Topology restricted to what the connection's agents reach (`plt_` auth). */ getConnectionOtelTopology(connectionId: string): Promise>; /** Threats on the connection's agents, highest blast radius first (`plt_` auth). */ getConnectionOtelThreats(connectionId: string, state?: "open" | "all"): Promise>; /** Posture score and counts over the connection's agents (`plt_` auth). */ getConnectionOtelSummary(connectionId: string): Promise>; /** * Live signals for the connection's agents as an async iterator (`plt_` * auth). Same protocol as `client.otel.stream()`; signals with no agent * are never emitted here. Slots are counted per platform app (five). */ connectionOtelStream(connectionId: string, opts?: OtelStreamOptions): AsyncGenerator; /** Begin WebAuthn passkey enrollment for a connected end-user (`plt_` auth). */ connectionPasskeyEnrollBegin(connectionId: string): Promise>>; /** Complete WebAuthn passkey enrollment for a connected end-user (`plt_` auth). */ connectionPasskeyEnrollComplete(connectionId: string, body: Record): Promise>>; /** Chat with an agent provisioned on a connection (`plt_` auth). */ connectionAgentChat(connectionId: string, agentId: string, body: ConnectionAgentChatRequest): Promise>>; /** List signing keys for a connection agent (`plt_` auth). Public metadata only. */ listConnectionSigningKeys(connectionId: string, agentId?: string): Promise>; /** Get a signing key for a connection agent by chain (`plt_` auth). Public metadata only. */ getConnectionSigningKey(connectionId: string, chain: string, agentId?: string): Promise>; /** Deactivate a signing key for a connection agent (`plt_` auth). */ deactivateConnectionSigningKey(connectionId: string, chain: string, agentId?: string): Promise>; /** Patch limited agent settings on a connection (`plt_` auth). */ patchConnectionAgent(connectionId: string, agentId: string, body: { intents_api_enabled?: boolean; execution_intents_enabled?: boolean; system_prompt?: string | null; }): Promise>; /** Portfolio/balances for connection agents (`plt_` auth). */ getConnectionPortfolio(connectionId: string, query?: { chains?: string; include_tokens?: boolean; }): Promise>>; /** Alias for getConnectionPortfolio. */ getConnectionBalances(connectionId: string, query?: { chains?: string; }): Promise>>; /** List automations for agents on a connection (`plt_` auth). */ listConnectionAutomations(connectionId: string): Promise>; /** Create automation for a connection agent (`plt_` auth). */ createConnectionAutomation(connectionId: string, body: Record): Promise>>; /** Cancel an automation run (connection-scoped, `plt_` auth). */ cancelConnectionAutomationRun(connectionId: string, automationId: string, runId: string): Promise>>; /** Get agent memory on a connection (`plt_` auth). */ getConnectionMemory(connectionId: string, namespace: string, key: string, agentId?: string): Promise>>; /** Upsert agent memory on a connection (`plt_` auth). */ putConnectionMemory(connectionId: string, namespace: string, key: string, body: Record, agentId?: string): Promise>>; /** Delete agent memory on a connection (`plt_` auth). */ deleteConnectionMemory(connectionId: string, namespace: string, key: string, agentId?: string): Promise>; /** Set a spend policy on a user connection. */ setUserSpendPolicy(connectionId: string, body: CreateSpendPolicyRequest, options?: { idempotencyKey?: string; }): Promise>; /** Delete a spend policy from a platform app. */ deleteSpendPolicy(appId: string, policyId: string): Promise>; /** * Grant a platform app access to specific vaults and agents. * User-authenticated — the calling user must own the connection and resources. */ grantAccess(connectionId: string, data: GrantResourcesRequest): Promise>; /** List active resource grants for a connection. */ listGrants(connectionId: string): Promise>; /** Revoke a specific resource grant. */ revokeGrant(connectionId: string, grantId: string): Promise>; /** Update delegation settings (enabled, scopes) on a connected app. User-only. */ updateConnectionDelegation(connectionId: string, data: UpdateConnectionDelegationRequest): Promise>>; /** List all resources managed by this platform app for a connection. */ listConnectionResources(connectionId: string): Promise>>; /** Get the delegation audit log for a connection. */ getDelegationLog(connectionId: string, params?: { limit?: number; offset?: number; }): Promise>; /** Update a template for a platform app. */ updateTemplate(appId: string, templateId: string, data: UpdateTemplateRequest): Promise>; /** Delete a template from a platform app. */ deleteTemplate(appId: string, templateId: string): Promise>; /** Fetch platform audit events for an app. */ platformAudit(appId: string, params?: { limit?: number; offset?: number; }): Promise>; /** List runtimes managed by a platform app. */ listPlatformRuntimes(appId: string): Promise>; /** List automations managed by a platform app. */ listPlatformAutomations(appId: string): Promise>; /** SIWE challenge for wallet-native user provisioning. */ siweChallenge(data?: SiweChallengeRequest): Promise>; /** Get connection details including claim and entitlement status. */ getConnection(connectionId: string): Promise>; /** Per-connection inference usage for the current billing period. */ getConnectionUsage(connectionId: string): Promise>; /** * Usage for every connection on an app, plus what could not be charged to * one. * * Read `unattributed` — summing only `connections` gives a figure that will * not match the invoice you are reconciling against. `has_ambiguous_usage` * means some usage belongs to an end-user who cannot be identified, which is * the case worth acting on; `unattributed.none` is ordinary unlinked traffic. * * `totals` is derived from the parts, so it cannot disagree with them. */ getAppUsage(appId: string): Promise>; /** * The same report as CSV, including the ambiguous, none and total rows. * * Returned as text — a CSV listing only connections looks complete and is * not, and whoever imports it has no way to tell. */ exportAppUsage(appId: string): Promise>; /** List on-chain entitlement evaluations for a connection. */ listEntitlements(connectionId: string): Promise>; /** Trigger an immediate entitlement monitor refresh for the connection's org. */ refreshEntitlements(connectionId: string): Promise>; /** Dry-run template parameter substitution. */ previewTemplate(appId: string, templateId: string, data: TemplatePreviewRequest): Promise>; /** * Returns a scoped client that auto-sets `X-Platform-Connection` on all * requests. Allows platform developers to perform CRUD in a connected * user's org using standard resource methods. */ withConnection(connectionId: string): ScopedPlatformClient; } /** * A scoped client that automatically attaches the `X-Platform-Connection` * header to every request, enabling platform developers to manage resources * in a connected user's org. */ export declare class ScopedPlatformClient { private readonly http; private readonly connectionId; constructor(http: HttpClient, connectionId: string); /** * Generic scoped request — attaches the connection header automatically. * Use the specific resource helpers below for typed responses. */ request(method: string, path: string, options?: { body?: unknown; query?: Record; }): Promise>; get vaults(): { create: (data: { name: string; description?: string; }) => Promise>; list: () => Promise>; }; get agents(): { create: (data: Record) => Promise>; list: () => Promise>; update: (agentId: string, data: Record) => Promise>; }; get automations(): { create: (data: Record) => Promise>; list: () => Promise>; delete: (id: string) => Promise>; }; get runtimes(): { create: (data: Record) => Promise>; list: () => Promise>; start: (id: string) => Promise>; stop: (id: string) => Promise>; delete: (id: string) => Promise>; }; } //# sourceMappingURL=platform.d.ts.map