/** * @getmarrow/sdk — MarrowClient Implementation */ import type { MarrowClientOptions, MarrowEnforceOptions, MarrowActionMeta, MarrowAutoWrapOptions, MarrowCheckResult, MarrowLoopState, MarrowOrientResult, MarrowThinkResult, MarrowCommitResult, MarrowModelUsageInput, MarrowModelUsageResult, MarrowAskResult, MarrowQuickStatusResult, MarrowMemory, MarrowMemoryRetrievalResult, MemoryStatus, MemoryShareOptions, MemoryExportOptions, MemoryImportOptions, CreateApiKeyParams, MarrowApiKey, CreateApiKeyResult, ListApiKeysResult, RevokeApiKeyResult, RotateApiKeyResult, GetKeyAuditParams, GetKeyAuditResult, MarrowDashboardResult, MarrowDigestResult, MarrowAgentStatusResult, MarrowValueReportResult, MarrowDecisionBriefRequest, MarrowDecisionBriefResult, MarrowAgentRuntimeRequest, MarrowAgentRuntimeResult, MarrowFirstValueRequest, MarrowFirstValueResult, MarrowWorkflowGateRequest, MarrowWorkflowGateResult, MarrowModeRecommendationRequest, MarrowModeRecommendationResult, MarrowPolicyProfilesResult, MarrowCreatePolicyProfileRequest, MarrowPolicyProfileResult, MarrowAssignProjectPolicyProfileRequest, MarrowProjectPolicyProfileAssignmentResult, MarrowPolicyResolveRequest, MarrowPolicyResolveResult, MarrowAgentPerformanceResult, MarrowRecordFleetLessonInput, MarrowFleetLessonsResult, MarrowDeploymentMemoryInput, MarrowDeploymentMemory, MarrowCreateHandoffInput, MarrowUpdateHandoffInput, MarrowAgentHandoff, MarrowSetMemoryPermissionInput, MarrowMemoryPermissionRecord, MarrowFailureType, MarrowGuardedRunOptions, MarrowGuardedRunResult, MarrowPassiveRuntime, MarrowPassiveRuntimeOptions, MarrowSessionEndResult, MarrowTemplateSummary, MarrowTemplateDetail, MarrowDecisionProvenanceInput } from './types'; export declare function classifyMarrowFailure(error: unknown): MarrowFailureType; interface MarrowFetchWrapOptions { captureModelUsage?: boolean; } export declare class MarrowLoopRequiredError extends Error { readonly code = "MARROW_LOOP_REQUIRED"; readonly state: MarrowLoopState; constructor(message: string, state: MarrowLoopState); } export declare class MarrowClient { private apiKey; private decisionId; private orientWarnings; private enforcement; private loopState; private sessionId; private agentId; private reminderBudget; private baseUrl; private retryQueue; private retryQueueDraining; constructor(apiKey: string, options?: MarrowClientOptions | string); enforce(options?: MarrowEnforceOptions): MarrowCheckResult; check(): MarrowCheckResult; run(description: string, fn: () => Promise | T, options?: { type?: string; context?: Record; }): Promise; runGuarded(options: MarrowGuardedRunOptions): Promise>; /** * Create a passive runtime shim for agents that own their process. * * MCP users usually get passive behavior from `npx @getmarrow/mcp setup`. * SDK users can call this once and wrap common surfaces without manually * stitching together decision briefs, think, commit, and value reporting. */ createPassiveRuntime(options?: MarrowPassiveRuntimeOptions): MarrowPassiveRuntime; beforeAction(meta: MarrowActionMeta): Promise; afterAction(meta: MarrowActionMeta): Promise; wrap(meta: MarrowActionMeta, fn: () => Promise | T): Promise; /** * Wrap every function on an object with Marrow logging. * * @example * const myAgent = new MyAgent(); * const wrapped = marrow.autoWrap(myAgent); * await wrapped.deploy(); // auto-logs 'deploy(...)' with think → commit * * @example * const wrapped = marrow.autoWrap(myAgent, { * exclude: ['getConfig', 'toJSON'], * actionPrefix: 'claims-agent: ', * type: 'process' * }); */ autoWrap(target: T, options?: MarrowAutoWrapOptions): T; /** * Wrap a fetch-compatible function with Marrow logging. * * @example * const wrappedFetch = marrow.wrapFetch(fetch); * await wrappedFetch('https://api.example.com/deploy', { method: 'POST' }); * // auto-logs 'POST https://api.example.com/deploy' */ wrapFetch(fetchFn: typeof fetch, options?: MarrowFetchWrapOptions): typeof fetch; wrapPublish(action: string, fn: () => Promise | T, meta?: Omit): Promise; wrapDeploy(action: string, fn: () => Promise | T, meta?: Omit): Promise; wrapExternalWrite(action: string, fn: () => Promise | T, meta?: Omit): Promise; wrapHandoff(action: string, fn: () => Promise | T, meta?: Omit): Promise; think(params: { action: string; type?: string; context?: Record; previousSuccess?: boolean; previousOutcome?: string; previousCausedBy?: string; checkLoop?: boolean; provenance?: MarrowDecisionProvenanceInput; }): Promise; commit(params: { success: boolean; outcome: string; causedBy?: string; decisionId?: string; gateReceiptId?: string; gate_receipt_id?: string; proof?: Record; modelUsage?: MarrowModelUsageInput; model_usage?: MarrowModelUsageInput; }): Promise; modelUsage(params: MarrowModelUsageInput): Promise; orient(params?: { taskType?: string; autoWarn?: boolean; }): Promise; agentPatterns(params?: { type?: string; limit?: number; }): Promise<{ failurePatterns: Array<{ decisionType: string; failureRate: number; count: number; lastSeen: string; }>; recurringDecisions: Array<{ decisionType: string; frequency: number; avgConfidence: number; trend: string; }>; behavioralDrift: { successRate7d: number; successRate30d: number; drift: string; direction: string; }; topFailureTypes: string[]; generatedAt: string; }>; analytics(): Promise<{ healthScore: { score: number; label: string; breakdown: Record; trend: string; vsLastWeek: string; }; [key: string]: unknown; }>; ask(query: string): Promise; quickStatus(): Promise; createApiKey(params: CreateApiKeyParams): Promise; listApiKeys(): Promise; getApiKey(id: string): Promise; revokeApiKey(id: string): Promise; rotateApiKey(id: string): Promise; getKeyAudit(params?: GetKeyAuditParams): Promise; listMemories(params?: { status?: MemoryStatus; query?: string; includeDeleted?: boolean; limit?: number; agentId?: string; }): Promise; getMemory(id: string): Promise; updateMemory(id: string, patch: { text?: string; source?: string | null; tags?: string[]; actor?: string; note?: string; }): Promise; deleteMemory(id: string, meta?: { actor?: string; note?: string; }): Promise; markOutdated(id: string, meta?: { actor?: string; note?: string; }): Promise; supersedeMemory(id: string, replacement: { text: string; source?: string; tags?: string[]; actor?: string; note?: string; }): Promise<{ old: MarrowMemory; replacement: MarrowMemory; }>; retrieveMemories(query: string, params?: { limit?: number; includeStale?: boolean; from?: string; to?: string; tags?: string; source?: string; status?: MemoryStatus; shared?: boolean; }): Promise; shareMemory(id: string, options: MemoryShareOptions): Promise; exportMemories(options?: MemoryExportOptions): Promise<{ exported_at: string; account_id: string; count: number; memories: MarrowMemory[]; }>; importMemories(options: MemoryImportOptions): Promise<{ imported: number; skipped: number; errors: string[]; }>; /** * List available workflow templates with optional filters. */ listTemplates(filters?: { industry?: string; category?: string; limit?: number; }): Promise; /** * Get full details of a workflow template by slug. */ getTemplate(slug: string): Promise; /** * Install a workflow template into the current account as an active workflow. */ installTemplate(slug: string): Promise<{ workflow_id: string; }>; /** * Get operator dashboard — account health, top failures, workflow status, saves. */ dashboard(): Promise; /** * Get periodic summary of agent activity and Marrow impact. * @param period - '7d' (default), '14d', or '30d' */ digest(period?: string): Promise; /** * Get agent-native proof that Marrow is active and collecting useful signal. * @param period - '7d' (default), '14d', or '30d' * @param agentId - optional agent_id/session_id filter. Defaults to this client's agentId. */ agentStatus(period?: string, agentId?: string | null): Promise; /** * Get an agent-native value report for owner reporting or agent planning. * This is the no-dashboard proof payload: summary, metrics, fleet activity, * risks, recommendations, and improvement data without raw decision text. */ valueReport(period?: string | number, agentId?: string | null): Promise; /** * Get one pre-action operating brief: risk, workflow, handoff, quality checks, * source-of-truth surfaces, proof-pack requirements, and next actions. */ decisionBrief(input: MarrowDecisionBriefRequest): Promise; workflowGate(input: MarrowWorkflowGateRequest): Promise; /** * One-call agent runtime loop: status, decision brief, risk gate, lessons, * template suggestion, proof-pack requirements, and exact next action. */ agentRuntime(input: MarrowAgentRuntimeRequest): Promise; recommendGovernanceMode(input: MarrowModeRecommendationRequest): Promise; listPolicyProfiles(): Promise; createPolicyProfile(input: MarrowCreatePolicyProfileRequest): Promise; updatePolicyProfile(id: string, input: MarrowCreatePolicyProfileRequest): Promise; assignProjectPolicyProfile(input: MarrowAssignProjectPolicyProfileRequest): Promise; resolvePolicy(input: MarrowPolicyResolveRequest): Promise; /** * First-run value proof for installers and agents: capture status, runtime gate, * first useful lesson, and value-proof counters in one response. */ firstValue(input?: MarrowFirstValueRequest): Promise; agentPerformance(period?: string | number, agentId?: string | null): Promise; fleetLessons(options?: { query?: string; type?: string; agentId?: string | null; limit?: number; }): Promise; recordFleetLesson(input: MarrowRecordFleetLessonInput): Promise<{ lesson: MarrowFleetLessonsResult['lessons'][number]; }>; markFleetLessonReused(lessonId: string): Promise<{ lesson: MarrowFleetLessonsResult['lessons'][number]; }>; recordDeploymentMemory(input: MarrowDeploymentMemoryInput): Promise<{ memory: MarrowDeploymentMemory; }>; deploymentMemories(options?: { environment?: string; status?: string; limit?: number; }): Promise<{ memories: MarrowDeploymentMemory[]; count: number; }>; createHandoff(input: MarrowCreateHandoffInput): Promise<{ handoff: MarrowAgentHandoff; }>; updateHandoff(handoffId: string, input: MarrowUpdateHandoffInput): Promise<{ handoff: MarrowAgentHandoff; }>; handoffStatus(options?: { status?: string; agentId?: string | null; limit?: number; }): Promise<{ handoffs: MarrowAgentHandoff[]; summary: Record; }>; setMemoryPermission(input: MarrowSetMemoryPermissionInput): Promise<{ permission: MarrowMemoryPermissionRecord; }>; memoryPermissions(agentId?: string | null): Promise<{ permissions: MarrowMemoryPermissionRecord[]; count: number; }>; /** * Explicitly end the current session. Optionally auto-commits any open decision. * @param autoCommitOpen - whether to auto-commit (default false) */ endSession(autoCommitOpen?: boolean): Promise; /** * Convert a detected decision pattern into an enforced workflow. * @param detectedId - ID from suggested_workflows in orient() response */ acceptDetectedWorkflow(detectedId: string): Promise<{ workflow_id: string; version: number; }>; private mapApiKey; private request; private requestOnce; private normalizeModelUsage; private shouldQueueRequest; private enqueueRetry; private drainRetryQueue; } export {}; //# sourceMappingURL=client.d.ts.map