@vorim/sdk 3.12.0 → 3.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +14 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/anthropic.d.cts +1 -1
- package/dist/integrations/anthropic.d.ts +1 -1
- package/dist/integrations/ap2.d.cts +1 -1
- package/dist/integrations/ap2.d.ts +1 -1
- package/dist/integrations/aws-iam.cjs +225 -0
- package/dist/integrations/aws-iam.cjs.map +1 -0
- package/dist/integrations/aws-iam.d.cts +156 -0
- package/dist/integrations/aws-iam.d.ts +156 -0
- package/dist/integrations/aws-iam.js +199 -0
- package/dist/integrations/aws-iam.js.map +1 -0
- package/dist/integrations/bank-rails.d.cts +1 -1
- package/dist/integrations/bank-rails.d.ts +1 -1
- package/dist/integrations/circle.d.cts +1 -1
- package/dist/integrations/circle.d.ts +1 -1
- package/dist/integrations/cloudflare.d.cts +1 -1
- package/dist/integrations/cloudflare.d.ts +1 -1
- package/dist/integrations/coinbase-cdp.cjs +230 -0
- package/dist/integrations/coinbase-cdp.cjs.map +1 -0
- package/dist/integrations/coinbase-cdp.d.cts +169 -0
- package/dist/integrations/coinbase-cdp.d.ts +169 -0
- package/dist/integrations/coinbase-cdp.js +204 -0
- package/dist/integrations/coinbase-cdp.js.map +1 -0
- package/dist/integrations/crewai.d.cts +1 -1
- package/dist/integrations/crewai.d.ts +1 -1
- package/dist/integrations/entra.cjs +225 -0
- package/dist/integrations/entra.cjs.map +1 -0
- package/dist/integrations/entra.d.cts +155 -0
- package/dist/integrations/entra.d.ts +155 -0
- package/dist/integrations/entra.js +199 -0
- package/dist/integrations/entra.js.map +1 -0
- package/dist/integrations/fhir.cjs +304 -0
- package/dist/integrations/fhir.cjs.map +1 -0
- package/dist/integrations/fhir.d.cts +185 -0
- package/dist/integrations/fhir.d.ts +185 -0
- package/dist/integrations/fhir.js +278 -0
- package/dist/integrations/fhir.js.map +1 -0
- package/dist/integrations/guidewire.cjs +363 -0
- package/dist/integrations/guidewire.cjs.map +1 -0
- package/dist/integrations/guidewire.d.cts +258 -0
- package/dist/integrations/guidewire.d.ts +258 -0
- package/dist/integrations/guidewire.js +337 -0
- package/dist/integrations/guidewire.js.map +1 -0
- package/dist/integrations/hermes.d.cts +1 -1
- package/dist/integrations/hermes.d.ts +1 -1
- package/dist/integrations/langchain.d.cts +1 -1
- package/dist/integrations/langchain.d.ts +1 -1
- package/dist/integrations/langgraph.d.cts +1 -1
- package/dist/integrations/langgraph.d.ts +1 -1
- package/dist/integrations/legal.cjs +339 -0
- package/dist/integrations/legal.cjs.map +1 -0
- package/dist/integrations/legal.d.cts +225 -0
- package/dist/integrations/legal.d.ts +225 -0
- package/dist/integrations/legal.js +313 -0
- package/dist/integrations/legal.js.map +1 -0
- package/dist/integrations/life-sciences.cjs +335 -0
- package/dist/integrations/life-sciences.cjs.map +1 -0
- package/dist/integrations/life-sciences.d.cts +214 -0
- package/dist/integrations/life-sciences.d.ts +214 -0
- package/dist/integrations/life-sciences.js +309 -0
- package/dist/integrations/life-sciences.js.map +1 -0
- package/dist/integrations/lithic.cjs +290 -0
- package/dist/integrations/lithic.cjs.map +1 -0
- package/dist/integrations/lithic.d.cts +130 -0
- package/dist/integrations/lithic.d.ts +130 -0
- package/dist/integrations/lithic.js +264 -0
- package/dist/integrations/lithic.js.map +1 -0
- package/dist/integrations/llamaindex.d.cts +1 -1
- package/dist/integrations/llamaindex.d.ts +1 -1
- package/dist/integrations/marqeta.cjs +285 -0
- package/dist/integrations/marqeta.cjs.map +1 -0
- package/dist/integrations/marqeta.d.cts +121 -0
- package/dist/integrations/marqeta.d.ts +121 -0
- package/dist/integrations/marqeta.js +259 -0
- package/dist/integrations/marqeta.js.map +1 -0
- package/dist/integrations/modern-treasury.d.cts +1 -1
- package/dist/integrations/modern-treasury.d.ts +1 -1
- package/dist/integrations/nekuda.d.cts +1 -1
- package/dist/integrations/nekuda.d.ts +1 -1
- package/dist/integrations/okta.cjs +229 -0
- package/dist/integrations/okta.cjs.map +1 -0
- package/dist/integrations/okta.d.cts +172 -0
- package/dist/integrations/okta.d.ts +172 -0
- package/dist/integrations/okta.js +203 -0
- package/dist/integrations/okta.js.map +1 -0
- package/dist/integrations/openai.d.cts +1 -1
- package/dist/integrations/openai.d.ts +1 -1
- package/dist/integrations/paypal-agent.d.cts +1 -1
- package/dist/integrations/paypal-agent.d.ts +1 -1
- package/dist/integrations/plaid.d.cts +1 -1
- package/dist/integrations/plaid.d.ts +1 -1
- package/dist/integrations/ramp.cjs +206 -0
- package/dist/integrations/ramp.cjs.map +1 -0
- package/dist/integrations/ramp.d.cts +139 -0
- package/dist/integrations/ramp.d.ts +139 -0
- package/dist/integrations/ramp.js +180 -0
- package/dist/integrations/ramp.js.map +1 -0
- package/dist/integrations/shopify.d.cts +1 -1
- package/dist/integrations/shopify.d.ts +1 -1
- package/dist/integrations/siem.d.cts +1 -1
- package/dist/integrations/siem.d.ts +1 -1
- package/dist/integrations/skyfire.d.cts +1 -1
- package/dist/integrations/skyfire.d.ts +1 -1
- package/dist/integrations/stripe-acp.d.cts +1 -1
- package/dist/integrations/stripe-acp.d.ts +1 -1
- package/dist/integrations/stripe-issuing.cjs +316 -0
- package/dist/integrations/stripe-issuing.cjs.map +1 -0
- package/dist/integrations/stripe-issuing.d.cts +154 -0
- package/dist/integrations/stripe-issuing.d.ts +154 -0
- package/dist/integrations/stripe-issuing.js +290 -0
- package/dist/integrations/stripe-issuing.js.map +1 -0
- package/dist/integrations/truanon.d.cts +1 -1
- package/dist/integrations/truanon.d.ts +1 -1
- package/dist/integrations/ucp.d.cts +1 -1
- package/dist/integrations/ucp.d.ts +1 -1
- package/dist/integrations/vercel-ai.d.cts +1 -1
- package/dist/integrations/vercel-ai.d.ts +1 -1
- package/dist/integrations/x402.d.cts +1 -1
- package/dist/integrations/x402.d.ts +1 -1
- package/dist/{types-zzK9YOoa.d.cts → types-Lp1iHEDz.d.cts} +21 -1
- package/dist/{types-zzK9YOoa.d.ts → types-Lp1iHEDz.d.ts} +21 -1
- package/package.json +121 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/fhir.ts"],"sourcesContent":["// ============================================================================\n// Vorim AI — Healthcare (HL7 FHIR R4 / SMART on FHIR) Integration\n//\n// This guards an AI agent that writes to an electronic health record through the\n// vendor-neutral HL7 FHIR R4 REST API (the surface Epic, Oracle Health, and any\n// ONC g(10)-certified server share). Before each write runs it checks the acting\n// agent holds the right permission and that the FHIR resource type is within the\n// agent's allowed set; for the highest-stakes orders (a prescription or a lab/\n// imaging order) it forces the write to remain an UNSIGNED draft and escalates\n// to a clinician to sign. Either way it signs a tamper-evident record of which\n// agent proposed which mutation and under what authority.\n//\n// WHY FHIR R4, NOT A VENDOR API\n// R4 (4.0.1) is the ONC-mandated baseline every certified EHR exposes; SMART on\n// FHIR is the shared auth layer. One connector runs against every server —\n// vendor differences (base URL, token URL, scope version) are configuration.\n//\n// ALIGNS WITH THE EHR'S OWN MODEL\n// On Epic, agent-writable orders (MedicationRequest, ServiceRequest) are created\n// as \"Unsigned\" drafts that a human clinician signs; the API deliberately does\n// not let software finalize an order. Vorim's escalate-to-human step matches\n// that draft-then-sign model rather than fighting it, and adds the attributable,\n// cryptographic record of which agent proposed the order — which the base FHIR\n// API and the EHR audit log do not natively provide for autonomous agents.\n//\n// SCOPE MAPPING (uses Vorim's real scopes; mirrors SMART v2 CRUDS)\n// read / search (.r .s) -> agent:read\n// create / update / patch -> agent:write\n// an order that needs a -> agent:elevate (draft + clinician sign;\n// clinician signature segregation of duties)\n//\n// HONEST COMPLIANCE FRAMING\n// HIPAA §164.312(b) audit controls and (c)(2) integrity, and 21 CFR Part 11\n// §11.10(e) audit trails, require tamper-evident, attributable, time-stamped\n// records — which a signed Vorim record satisfies. NEITHER mandates a\n// cryptographic signature as the mechanism. Say \"supports HIPAA §164.312 audit\n// controls and integrity\", never \"required by HIPAA\". A Vorim record is not a\n// Part 11 electronic signature.\n//\n// This layer never holds a SMART token and never calls the FHIR server itself.\n// You pass the write to run; it authorizes, escalates if needed, runs it, signs\n// the receipt.\n//\n// Usage:\n// import createVorim from '@vorim/sdk';\n// import { createVorimFhir } from '@vorim/sdk/integrations/fhir';\n//\n// const vorim = createVorim({ apiKey: 'agid_sk_...' });\n// const fhir = createVorimFhir(vorim, {\n// agentId: 'agid_abc123',\n// fhirBaseUrl: 'https://fhir.epic.com/.../api/FHIR/R4',\n// allowedResources: ['DocumentReference', 'Observation'], // resource-type cap\n// readOnly: false,\n// clinicianId: 'dr_42', // who signs an escalated order\n// });\n//\n// const { receipt, value } = await fhir.guardedCreate(\n// { resourceType: 'Observation', resourceId: 'obs-1' },\n// () => fhirClient.create('Observation', body),\n// );\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\nimport type { PermissionScope } from '../types.js';\n\n/** A FHIR REST write interaction. Reads/searches pass through as 'read'. */\nexport type FhirInteraction = 'create' | 'update' | 'patch' | 'transaction' | 'read';\n\n/** The two order resource types that, on real EHRs, must be signed by a\n * clinician — Vorim forces these to a draft and escalates. Any resource can be\n * added to this behaviour via `orderResources`. */\nconst DEFAULT_ORDER_RESOURCES = ['MedicationRequest', 'ServiceRequest'];\n\nexport interface FhirGuardConfig {\n /** The acting agent's Vorim id (agid_...). */\n agentId: string;\n /** The FHIR R4 base URL, e.g. an Epic/Oracle R4 endpoint. Recorded on every\n * receipt so a write is attributable to one server. */\n fhirBaseUrl: string;\n /** Attenuation: restrict this agent to these FHIR resource types. A write to\n * any other type is denied. Omit to allow any type (subject to readOnly). */\n allowedResources?: string[];\n /** Attenuation: cap this agent to read/search only. Any create/update/patch is\n * denied even if the SMART token was over-scoped. Default false. */\n readOnly?: boolean;\n /** Resource types that must be written as an UNSIGNED draft and signed by a\n * clinician (escalation). Defaults to MedicationRequest + ServiceRequest —\n * the order resources EHRs gate this way. */\n orderResources?: string[];\n /** The clinician who signs an escalated order. Required if any order-resource\n * write will be run. Recorded as the signer on the record. */\n clinicianId?: string;\n /** For an order resource, escalate to the clinician and wait for the signature\n * instead of denying. Requires the runtime decision plane. Default true.\n * Ignored when readOnly. */\n escalateOrders?: boolean;\n /** Max time to wait for a clinician signature, ms. Default 300000 (5 min). */\n escalationTimeoutMs?: number;\n /** Minimum trust score the agent must hold before any write. Default 0 (off). */\n minTrustScore?: number;\n /** Fail closed (deny on any Vorim error) or fail open. Default 'closed'. */\n onError?: 'closed' | 'open';\n}\n\nexport interface FhirAction {\n /** The FHIR interaction, e.g. 'create'. Drives the scope. Reads pass as\n * 'read'. Unknown labels are treated as a write. */\n interaction: FhirInteraction | string;\n /** The FHIR resource type, e.g. 'Observation'. Checked against\n * allowedResources and the order-resource set. */\n resourceType: string;\n /** The resource id, when known (update/patch, or the created id). */\n resourceId?: string;\n /** Optional hash of the resource body so the receipt covers the exact input\n * without the guard storing PHI. */\n inputHash?: string;\n}\n\n/** How an order-resource write resolved. */\nexport type OrderOutcome = 'not-an-order' | 'signed-by-clinician' | 'order-denied' | 'blocked-read-only';\n\n/** An offline-verifiable receipt for one FHIR write. Contains no PHI — only the\n * resource type/id, the agent, and the authorization outcome. */\nexport interface FhirReceipt {\n authorized: boolean;\n agentId: string;\n fhirBaseUrl: string;\n interaction: string;\n resourceType: string;\n resourceId?: string;\n /** True when the resource is an order that requires a clinician signature. */\n isOrder: boolean;\n orderOutcome: OrderOutcome;\n /** The clinician who signed, when an order was escalated and signed. */\n signerId?: string;\n result: 'success' | 'denied' | 'error';\n scope: PermissionScope;\n reason?: string;\n decisionId?: string;\n recorded: boolean;\n}\n\nexport class VorimFhir {\n private sdk: VorimSDK;\n private agentId: string;\n private fhirBaseUrl: string;\n private allowedResources?: Set<string>;\n private readOnly: boolean;\n private orderResources: Set<string>;\n private clinicianId?: string;\n private escalateOrders: boolean;\n private escalationTimeoutMs: number;\n private minTrustScore: number;\n private onError: 'closed' | 'open';\n\n constructor(sdk: VorimSDK, config: FhirGuardConfig) {\n if (!config?.agentId) throw new Error('[vorim] FHIR integration requires an agentId.');\n if (!config?.fhirBaseUrl) throw new Error('[vorim] FHIR integration requires a fhirBaseUrl.');\n this.sdk = sdk;\n this.agentId = config.agentId;\n this.fhirBaseUrl = config.fhirBaseUrl;\n this.allowedResources = config.allowedResources ? new Set(config.allowedResources) : undefined;\n this.readOnly = config.readOnly ?? false;\n this.orderResources = new Set(config.orderResources ?? DEFAULT_ORDER_RESOURCES);\n this.clinicianId = config.clinicianId;\n this.escalateOrders = config.escalateOrders ?? true;\n this.escalationTimeoutMs = config.escalationTimeoutMs ?? 300_000;\n this.minTrustScore = config.minTrustScore ?? 0;\n this.onError = config.onError ?? 'closed';\n }\n\n private isRead(interaction: string): boolean {\n return interaction === 'read';\n }\n\n private isOrder(action: FhirAction): boolean {\n return !this.isRead(action.interaction) && this.orderResources.has(action.resourceType);\n }\n\n /** The Vorim scope an action requires. Reads need read; order-resource writes\n * are elevated (draft + clinician sign); other writes need write. */\n private scopeFor(action: FhirAction): PermissionScope {\n if (this.isRead(action.interaction)) return 'agent:read';\n if (this.isOrder(action)) return 'agent:elevate';\n return 'agent:write';\n }\n\n /**\n * Decide whether the acting agent may run this FHIR interaction, before it\n * runs. Order: trust floor, read-only cap, resource-type cap, order gate\n * (escalate to clinician), then permission scope.\n */\n async authorize(\n action: FhirAction,\n ): Promise<{\n authorized: boolean;\n reason?: string;\n orderOutcome: OrderOutcome;\n signerId?: string;\n decisionId?: string;\n }> {\n const isRead = this.isRead(action.interaction);\n const isOrder = this.isOrder(action);\n const scope = this.scopeFor(action);\n\n // Read-only cap: enforced before any Vorim round-trip. A write cannot happen\n // even if the SMART token was over-scoped.\n if (!isRead && this.readOnly) {\n return {\n authorized: false,\n reason: 'agent is read-only; writes are not permitted',\n orderOutcome: isOrder ? 'blocked-read-only' : 'not-an-order',\n };\n }\n // Resource-type cap: also before any round-trip.\n if (!isRead && this.allowedResources && !this.allowedResources.has(action.resourceType)) {\n return {\n authorized: false,\n reason: `resource type ${action.resourceType} is not in this agent's allowed set`,\n orderOutcome: isOrder ? 'order-denied' : 'not-an-order',\n };\n }\n\n try {\n if (this.minTrustScore > 0) {\n const trust = await this.sdk.verify(this.agentId);\n if ((trust?.trust_score ?? 0) < this.minTrustScore) {\n return {\n authorized: false,\n reason: `trust score below ${this.minTrustScore}`,\n orderOutcome: isOrder ? 'order-denied' : 'not-an-order',\n };\n }\n }\n\n if (isOrder) {\n if (!this.escalateOrders) {\n return {\n authorized: false,\n reason: 'order resource requires a clinician signature and escalateOrders is off',\n orderOutcome: 'order-denied',\n };\n }\n if (!this.clinicianId) {\n return {\n authorized: false,\n reason: 'order resource requires a configured clinicianId (the signing clinician)',\n orderOutcome: 'order-denied',\n };\n }\n const esc = await this.escalate(action, scope);\n return {\n authorized: esc.approved,\n reason: esc.approved ? undefined : (esc.reason ?? 'clinician did not sign the order'),\n orderOutcome: esc.approved ? 'signed-by-clinician' : 'order-denied',\n signerId: esc.approved ? this.clinicianId : undefined,\n decisionId: esc.decisionId,\n };\n }\n\n const perm = await this.sdk.check(this.agentId, scope);\n return perm.allowed\n ? { authorized: true, orderOutcome: 'not-an-order' }\n : {\n authorized: false,\n reason: perm.reason ?? `missing scope ${scope}`,\n orderOutcome: 'not-an-order',\n };\n } catch (e: any) {\n return this.onError === 'open'\n ? {\n authorized: true,\n reason: 'vorim unreachable, failed open',\n orderOutcome: isOrder ? 'signed-by-clinician' : 'not-an-order',\n }\n : {\n authorized: false,\n reason: `vorim unreachable: ${e?.message ?? 'error'}`,\n orderOutcome: isOrder ? 'order-denied' : 'not-an-order',\n };\n }\n }\n\n /**\n * Route an order-resource write through the runtime decision plane so a\n * clinician can sign (approve) or refuse the unsigned draft, and wait. The\n * elevate scope marks the segregation-of-duties gate: the agent proposes the\n * order, the clinician signs it.\n */\n private async escalate(\n action: FhirAction,\n scope: PermissionScope,\n ): Promise<{ approved: boolean; reason?: string; decisionId?: string }> {\n const decision = await this.sdk.beforeAction(\n {\n agentId: this.agentId,\n actionType: 'api_request',\n actionTarget: `fhir:${action.interaction}:${action.resourceType}`,\n requiredScope: scope,\n payload: {\n interaction: action.interaction,\n resource_type: action.resourceType,\n resource_id: action.resourceId,\n order_status: 'unsigned-draft',\n },\n context: {\n integration: 'fhir-r4',\n fhir_base_url: this.fhirBaseUrl,\n requires_clinician_signature: true,\n clinician_hint: this.clinicianId,\n },\n },\n { throwOnDeny: false },\n );\n\n if (decision.decision === 'escalate') {\n const resolved = await this.sdk.waitForDecisionResolution(decision.decisionId, {\n timeoutMs: this.escalationTimeoutMs,\n });\n const approved = resolved.decision === 'allow' || resolved.escalationResolution === 'approved';\n return {\n approved,\n reason: approved ? undefined : 'clinician refused to sign the order',\n decisionId: decision.decisionId,\n };\n }\n if (decision.decision === 'allow') return { approved: true, decisionId: decision.decisionId };\n if (decision.decision === 'fallback')\n return { approved: this.onError === 'open', reason: 'runtime unreachable', decisionId: decision.decisionId };\n return { approved: false, reason: decision.reason ?? 'denied', decisionId: decision.decisionId };\n }\n\n /**\n * Emit a source-signed audit event for a FHIR write and return whether it was\n * recorded. The event names the agent, the server, the resource type/id, and\n * any clinician signer — attributable and independently verifiable offline,\n * supporting HIPAA §164.312(b) audit controls. It carries NO PHI.\n */\n async record(\n action: FhirAction,\n result: 'success' | 'denied' | 'error',\n extra: { reason?: string; orderOutcome?: OrderOutcome; signerId?: string; decisionId?: string } = {},\n ): Promise<boolean> {\n const scope = this.scopeFor(action);\n try {\n await this.sdk.emit(\n {\n agent_id: this.agentId,\n event_type: 'api_request',\n action: `fhir:${action.interaction} ${action.resourceType}${action.resourceId ? '/' + action.resourceId : ''}`,\n resource: `${action.resourceType}${action.resourceId ? '/' + action.resourceId : ''}`,\n permission: scope,\n result,\n input_hash: action.inputHash,\n metadata: {\n integration: 'fhir-r4',\n fhir_base_url: this.fhirBaseUrl,\n interaction: action.interaction,\n resource_type: action.resourceType,\n is_order: this.isOrder(action),\n ...(extra.orderOutcome ? { order_outcome: extra.orderOutcome } : {}),\n ...(extra.signerId ? { signed_by_clinician: extra.signerId, signed_at: new Date().toISOString() } : {}),\n ...(extra.decisionId ? { decision_id: extra.decisionId } : {}),\n ...(extra.reason ? { reason: extra.reason } : {}),\n },\n },\n { sign: true }, // source-signed: the agent's key signs the record\n );\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * The full flow for one FHIR interaction: authorize (trust, caps, order gate,\n * scope), run the FHIR call if allowed, sign a receipt either way. If not\n * authorized, `run` is never called. Rethrows a FHIR error from `run` after\n * recording it, with the receipt attached as `vorimReceipt`.\n */\n async guard<T>(action: FhirAction, run: () => Promise<T>): Promise<{ receipt: FhirReceipt; value?: T }> {\n const auth = await this.authorize(action);\n if (!auth.authorized) {\n const recorded = await this.record(action, 'denied', {\n reason: auth.reason,\n orderOutcome: auth.orderOutcome,\n signerId: auth.signerId,\n decisionId: auth.decisionId,\n });\n return { receipt: this.receipt(action, false, 'denied', auth, recorded) };\n }\n try {\n const value = await run();\n const recorded = await this.record(action, 'success', {\n orderOutcome: auth.orderOutcome,\n signerId: auth.signerId,\n decisionId: auth.decisionId,\n });\n return { receipt: this.receipt(action, true, 'success', auth, recorded), value };\n } catch (e: any) {\n const recorded = await this.record(action, 'error', {\n reason: e?.message,\n orderOutcome: auth.orderOutcome,\n signerId: auth.signerId,\n decisionId: auth.decisionId,\n });\n throw Object.assign(e ?? new Error('fhir operation failed'), {\n vorimReceipt: this.receipt(action, true, 'error', { ...auth, reason: e?.message }, recorded),\n });\n }\n }\n\n // --- Named helpers ---------------------------------------------------------\n\n /** Guard a FHIR `create` (POST [base]/[type]). Requires agent:write, or\n * agent:elevate + a clinician signature for an order resource. */\n guardedCreate<T>(meta: { resourceType: string; resourceId?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ interaction: 'create', resourceType: meta.resourceType, resourceId: meta.resourceId, inputHash: meta.inputHash }, run);\n }\n\n /** Guard a FHIR `update` (PUT [base]/[type]/[id]). */\n guardedUpdate<T>(meta: { resourceType: string; resourceId?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ interaction: 'update', resourceType: meta.resourceType, resourceId: meta.resourceId, inputHash: meta.inputHash }, run);\n }\n\n /** Guard a FHIR `patch` (PATCH [base]/[type]/[id]). */\n guardedPatch<T>(meta: { resourceType: string; resourceId?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ interaction: 'patch', resourceType: meta.resourceType, resourceId: meta.resourceId, inputHash: meta.inputHash }, run);\n }\n\n private receipt(\n action: FhirAction,\n authorized: boolean,\n result: 'success' | 'denied' | 'error',\n auth: { reason?: string; orderOutcome?: OrderOutcome; signerId?: string; decisionId?: string },\n recorded: boolean,\n ): FhirReceipt {\n return {\n authorized,\n agentId: this.agentId,\n fhirBaseUrl: this.fhirBaseUrl,\n interaction: action.interaction,\n resourceType: action.resourceType,\n resourceId: action.resourceId,\n isOrder: this.isOrder(action),\n orderOutcome: auth.orderOutcome ?? 'not-an-order',\n signerId: auth.signerId,\n result,\n scope: this.scopeFor(action),\n reason: auth.reason,\n decisionId: auth.decisionId,\n recorded,\n };\n }\n}\n\n/**\n * Create a VorimFhir guard around a Vorim SDK instance.\n *\n * @example\n * ```typescript\n * import createVorim from '@vorim/sdk';\n * import { createVorimFhir } from '@vorim/sdk/integrations/fhir';\n *\n * const vorim = createVorim({ apiKey: 'agid_sk_...' });\n * const fhir = createVorimFhir(vorim, {\n * agentId: 'agid_abc123',\n * fhirBaseUrl: 'https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4',\n * allowedResources: ['DocumentReference', 'Observation'],\n * clinicianId: 'dr_42',\n * });\n *\n * // An order resource forces a draft + clinician signature:\n * const { receipt } = await fhir.guardedCreate(\n * { resourceType: 'MedicationRequest' },\n * () => fhirClient.create('MedicationRequest', unsignedDraft),\n * );\n * ```\n */\nexport function createVorimFhir(sdk: VorimSDK, config: FhirGuardConfig): VorimFhir {\n return new Vorim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AAW,KAAK,UAAU,GAAG,GAAG;AAAA,EAC3I;AAAA;AAAA,EAGA,cAAiB,MAAyE,KAAuB;AAC/G,WAAO,KAAK,MAAM,EAAE,aAAa,UAAU,cAAc,KAAK,cAAc,YAAY,KAAK,YAAY,WAAW,KAAK,UAAU,GAAG,GAAG;AAAA,EAC3I;AAAA;AAAA,EAGA,aAAgB,MAAyE,KAAuB;AAC9G,WAAO,KAAK,MAAM,EAAE,aAAa,SAAS,cAAc,KAAK,cAAc,YAAY,KAAK,YAAY,WAAW,KAAK,UAAU,GAAG,GAAG;AAAA,EAC1I;AAAA,EAEQ,QACN,QACA,YACA,QACA,MACA,UACa;AACb,WAAO;AAAA,MACL;AAAA,MACA,SAAS,KAAK;AAAA,MACd,aAAa,KAAK;AAAA,MAClB,aAAa,OAAO;AAAA,MACpB,cAAc,OAAO;AAAA,MACrB,YAAY,OAAO;AAAA,MACnB,SAAS,KAAK,QAAQ,MAAM;AAAA,MAC5B,cAAc,KAAK,gBAAgB;AAAA,MACnC,UAAU,KAAK;AAAA,MACf;AAAA,MACA,OAAO,KAAK,SAAS,MAAM;AAAA,MAC3B,QAAQ,KAAK;AAAA,MACb,YAAY,KAAK;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AACF;AAyBO,SAAS,gBAAgB,KAAe,QAAoC;AACjF,SAAO,IAAI,UAAU,KAAK,MAAM;AAClC;","names":[]}
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/integrations/guidewire.ts
|
|
21
|
+
var guidewire_exports = {};
|
|
22
|
+
__export(guidewire_exports, {
|
|
23
|
+
VorimGuidewire: () => VorimGuidewire,
|
|
24
|
+
createVorimGuidewire: () => createVorimGuidewire
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(guidewire_exports);
|
|
27
|
+
var OPERATION_SCOPE = {
|
|
28
|
+
read: "agent:read",
|
|
29
|
+
claimCreate: "agent:write",
|
|
30
|
+
claimAssign: "agent:write",
|
|
31
|
+
endorsement: "agent:write",
|
|
32
|
+
checkSet: "agent:transact",
|
|
33
|
+
reserveSet: "agent:transact",
|
|
34
|
+
recoveryReserveSet: "agent:transact",
|
|
35
|
+
policyBindIssue: "agent:transact",
|
|
36
|
+
premiumRefund: "agent:transact"
|
|
37
|
+
};
|
|
38
|
+
var OPERATION_CEILING = {
|
|
39
|
+
checkSet: "payment",
|
|
40
|
+
premiumRefund: "payment",
|
|
41
|
+
recoveryReserveSet: "payment",
|
|
42
|
+
reserveSet: "reserve",
|
|
43
|
+
policyBindIssue: "premium",
|
|
44
|
+
endorsement: "premium"
|
|
45
|
+
};
|
|
46
|
+
var VorimGuidewire = class {
|
|
47
|
+
sdk;
|
|
48
|
+
agentId;
|
|
49
|
+
instance;
|
|
50
|
+
humanId;
|
|
51
|
+
minTrustScore;
|
|
52
|
+
maxPaymentAmount;
|
|
53
|
+
maxReserveAmount;
|
|
54
|
+
maxPremiumAmount;
|
|
55
|
+
escalateOverCeiling;
|
|
56
|
+
escalationTimeoutMs;
|
|
57
|
+
onError;
|
|
58
|
+
constructor(sdk, config) {
|
|
59
|
+
if (!config?.agentId) throw new Error("[vorim] Guidewire integration requires an agentId.");
|
|
60
|
+
if (!config?.instance) throw new Error("[vorim] Guidewire integration requires an instance.");
|
|
61
|
+
this.sdk = sdk;
|
|
62
|
+
this.agentId = config.agentId;
|
|
63
|
+
this.instance = config.instance;
|
|
64
|
+
this.humanId = config.humanId;
|
|
65
|
+
this.minTrustScore = config.minTrustScore ?? 0;
|
|
66
|
+
this.maxPaymentAmount = config.maxPaymentAmount;
|
|
67
|
+
this.maxReserveAmount = config.maxReserveAmount;
|
|
68
|
+
this.maxPremiumAmount = config.maxPremiumAmount;
|
|
69
|
+
this.escalateOverCeiling = config.escalateOverCeiling ?? false;
|
|
70
|
+
this.escalationTimeoutMs = config.escalationTimeoutMs ?? 6e4;
|
|
71
|
+
this.onError = config.onError ?? "closed";
|
|
72
|
+
}
|
|
73
|
+
/** The Vorim scope a given operation requires. Unknown mutations fall back to
|
|
74
|
+
* agent:write. */
|
|
75
|
+
scopeFor(operation) {
|
|
76
|
+
return OPERATION_SCOPE[operation] ?? "agent:write";
|
|
77
|
+
}
|
|
78
|
+
/** The ceiling that applies to an operation, and this agent's configured
|
|
79
|
+
* limit for it. Returns { kind: null } when the operation moves no money or
|
|
80
|
+
* no ceiling is set. */
|
|
81
|
+
ceilingFor(operation) {
|
|
82
|
+
const kind = OPERATION_CEILING[operation] ?? null;
|
|
83
|
+
if (kind === "payment") return { kind, limit: this.maxPaymentAmount };
|
|
84
|
+
if (kind === "reserve") return { kind, limit: this.maxReserveAmount };
|
|
85
|
+
if (kind === "premium") return { kind, limit: this.maxPremiumAmount };
|
|
86
|
+
return { kind: null };
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Decide whether the acting agent may run this operation, before it runs.
|
|
90
|
+
* Order: trust floor, then the dollar ceiling (deny or escalate over it),
|
|
91
|
+
* then permission scope. Returns the authorization plus how the ceiling
|
|
92
|
+
* resolved and the runtime decision id when one was created.
|
|
93
|
+
*/
|
|
94
|
+
async authorize(action) {
|
|
95
|
+
const scope = this.scopeFor(action.operation);
|
|
96
|
+
const { kind, limit } = this.ceilingFor(action.operation);
|
|
97
|
+
const overCeiling = kind != null && limit != null && typeof action.amount === "number" && action.amount > limit;
|
|
98
|
+
try {
|
|
99
|
+
if (this.minTrustScore > 0) {
|
|
100
|
+
const trust = await this.sdk.verify(this.agentId);
|
|
101
|
+
if ((trust?.trust_score ?? 0) < this.minTrustScore) {
|
|
102
|
+
return {
|
|
103
|
+
authorized: false,
|
|
104
|
+
reason: `trust score below ${this.minTrustScore}`,
|
|
105
|
+
ceilingOutcome: overCeiling ? "over-ceiling" : "within"
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (overCeiling) {
|
|
110
|
+
if (!this.escalateOverCeiling) {
|
|
111
|
+
return {
|
|
112
|
+
authorized: false,
|
|
113
|
+
reason: `${kind} ${action.amount} exceeds this agent's ceiling of ${limit}`,
|
|
114
|
+
ceilingOutcome: "over-ceiling"
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
const esc = await this.escalate(action, scope, kind, limit);
|
|
118
|
+
return {
|
|
119
|
+
authorized: esc.approved,
|
|
120
|
+
reason: esc.approved ? void 0 : esc.reason ?? "escalation denied",
|
|
121
|
+
ceilingOutcome: esc.approved ? "escalated-approved" : "escalated-denied",
|
|
122
|
+
approverId: this.humanId,
|
|
123
|
+
decisionId: esc.decisionId
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
const perm = await this.sdk.check(this.agentId, scope);
|
|
127
|
+
return perm.allowed ? { authorized: true, ceilingOutcome: "within" } : {
|
|
128
|
+
authorized: false,
|
|
129
|
+
reason: perm.reason ?? `missing scope ${scope}`,
|
|
130
|
+
ceilingOutcome: "within"
|
|
131
|
+
};
|
|
132
|
+
} catch (e) {
|
|
133
|
+
return this.onError === "open" ? {
|
|
134
|
+
authorized: true,
|
|
135
|
+
reason: "vorim unreachable, failed open",
|
|
136
|
+
ceilingOutcome: overCeiling ? "over-ceiling" : "within"
|
|
137
|
+
} : {
|
|
138
|
+
authorized: false,
|
|
139
|
+
reason: `vorim unreachable: ${e?.message ?? "error"}`,
|
|
140
|
+
ceilingOutcome: overCeiling ? "over-ceiling" : "within"
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Route an over-ceiling money action through the runtime decision plane so a
|
|
146
|
+
* named human approver can allow or deny it, and wait for that decision. The
|
|
147
|
+
* elevated scope (agent:elevate) marks this as a segregation-of-duties gate:
|
|
148
|
+
* the agent that initiates the payment cannot also approve it above its limit.
|
|
149
|
+
*/
|
|
150
|
+
async escalate(action, scope, kind, limit) {
|
|
151
|
+
const decision = await this.sdk.beforeAction(
|
|
152
|
+
{
|
|
153
|
+
agentId: this.agentId,
|
|
154
|
+
actionType: "api_request",
|
|
155
|
+
actionTarget: `guidewire:${action.operation}`,
|
|
156
|
+
requiredScope: scope,
|
|
157
|
+
payload: {
|
|
158
|
+
amount: action.amount,
|
|
159
|
+
currency: action.currency,
|
|
160
|
+
ceiling: kind,
|
|
161
|
+
limit,
|
|
162
|
+
resource_id: action.resourceId
|
|
163
|
+
},
|
|
164
|
+
context: {
|
|
165
|
+
integration: "guidewire-cloud",
|
|
166
|
+
instance: this.instance,
|
|
167
|
+
requires_named_approver: true,
|
|
168
|
+
approver_hint: this.humanId
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
{ throwOnDeny: false }
|
|
172
|
+
);
|
|
173
|
+
if (decision.decision === "escalate") {
|
|
174
|
+
const resolved = await this.sdk.waitForDecisionResolution(decision.decisionId, {
|
|
175
|
+
timeoutMs: this.escalationTimeoutMs
|
|
176
|
+
});
|
|
177
|
+
const approved = resolved.decision === "allow" || resolved.escalationResolution === "approved";
|
|
178
|
+
return {
|
|
179
|
+
approved,
|
|
180
|
+
reason: approved ? void 0 : "named approver denied",
|
|
181
|
+
decisionId: decision.decisionId
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
if (decision.decision === "allow") return { approved: true, decisionId: decision.decisionId };
|
|
185
|
+
if (decision.decision === "fallback")
|
|
186
|
+
return { approved: this.onError === "open", reason: "runtime unreachable", decisionId: decision.decisionId };
|
|
187
|
+
return { approved: false, reason: decision.reason ?? "denied", decisionId: decision.decisionId };
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Emit a source-signed audit event for a core-system operation and return
|
|
191
|
+
* whether it was recorded. Called after the mutation runs (or after a denial).
|
|
192
|
+
* The event names the agent, the instance, the human the agent acts for, the
|
|
193
|
+
* amount vs. its ceiling, and any approver — so the record is attributable and
|
|
194
|
+
* independently verifiable offline, and carries the amount/authority/approval
|
|
195
|
+
* an insurance examiner looks for.
|
|
196
|
+
*/
|
|
197
|
+
async record(action, result, extra = {}) {
|
|
198
|
+
const scope = this.scopeFor(action.operation);
|
|
199
|
+
const { kind } = this.ceilingFor(action.operation);
|
|
200
|
+
try {
|
|
201
|
+
await this.sdk.emit(
|
|
202
|
+
{
|
|
203
|
+
agent_id: this.agentId,
|
|
204
|
+
event_type: "api_request",
|
|
205
|
+
action: `guidewire:${action.operation}${action.resourceId ? " " + action.resourceId : ""}`,
|
|
206
|
+
resource: action.resourceId || this.instance,
|
|
207
|
+
permission: scope,
|
|
208
|
+
result,
|
|
209
|
+
input_hash: action.inputHash,
|
|
210
|
+
metadata: {
|
|
211
|
+
integration: "guidewire-cloud",
|
|
212
|
+
instance: this.instance,
|
|
213
|
+
acts_for_human: this.humanId,
|
|
214
|
+
operation: action.operation,
|
|
215
|
+
...action.amount != null ? { amount: action.amount } : {},
|
|
216
|
+
...action.currency ? { currency: action.currency } : {},
|
|
217
|
+
...kind ? { ceiling_kind: kind } : {},
|
|
218
|
+
...extra.ceilingOutcome ? { ceiling_outcome: extra.ceilingOutcome } : {},
|
|
219
|
+
...extra.approverId ? { approver_id: extra.approverId } : {},
|
|
220
|
+
...extra.decisionId ? { decision_id: extra.decisionId } : {},
|
|
221
|
+
...extra.reason ? { reason: extra.reason } : {}
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
{ sign: true }
|
|
225
|
+
// source-signed: the agent's key signs the record
|
|
226
|
+
);
|
|
227
|
+
return true;
|
|
228
|
+
} catch {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* The full flow for one core-system operation: authorize (trust, ceiling with
|
|
234
|
+
* escalation, scope), run the Cloud API call if allowed, sign a receipt either
|
|
235
|
+
* way. If not authorized, `run` is never called. Rethrows an error from `run`
|
|
236
|
+
* after recording it, with the receipt attached as `vorimReceipt`, so your
|
|
237
|
+
* handler still sees Guidewire failures.
|
|
238
|
+
*/
|
|
239
|
+
async guard(action, run) {
|
|
240
|
+
const auth = await this.authorize(action);
|
|
241
|
+
if (!auth.authorized) {
|
|
242
|
+
const recorded = await this.record(action, "denied", {
|
|
243
|
+
reason: auth.reason,
|
|
244
|
+
ceilingOutcome: auth.ceilingOutcome,
|
|
245
|
+
approverId: auth.approverId,
|
|
246
|
+
decisionId: auth.decisionId
|
|
247
|
+
});
|
|
248
|
+
return {
|
|
249
|
+
receipt: this.receipt(action, false, "denied", auth, recorded)
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
try {
|
|
253
|
+
const value = await run();
|
|
254
|
+
const recorded = await this.record(action, "success", {
|
|
255
|
+
ceilingOutcome: auth.ceilingOutcome,
|
|
256
|
+
approverId: auth.approverId,
|
|
257
|
+
decisionId: auth.decisionId
|
|
258
|
+
});
|
|
259
|
+
return { receipt: this.receipt(action, true, "success", auth, recorded), value };
|
|
260
|
+
} catch (e) {
|
|
261
|
+
const recorded = await this.record(action, "error", {
|
|
262
|
+
reason: e?.message,
|
|
263
|
+
ceilingOutcome: auth.ceilingOutcome,
|
|
264
|
+
approverId: auth.approverId,
|
|
265
|
+
decisionId: auth.decisionId
|
|
266
|
+
});
|
|
267
|
+
throw Object.assign(e ?? new Error("guidewire operation failed"), {
|
|
268
|
+
vorimReceipt: this.receipt(action, true, "error", { ...auth, reason: e?.message }, recorded)
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
// --- Named helpers for the high-risk Cloud API mutations -------------------
|
|
273
|
+
// Each wraps guard() with the right operation label so the scope, ceiling, and
|
|
274
|
+
// receipt are correct without the caller remembering the mapping. You pass the
|
|
275
|
+
// Cloud API call as `run`; this layer never talks to Guidewire itself.
|
|
276
|
+
/** Guard a claim payment (`POST /claims/{claimId}/check-sets`). Requires
|
|
277
|
+
* agent:transact and stays within `maxPaymentAmount`; above it, escalates to
|
|
278
|
+
* a named adjuster when `escalateOverCeiling` is on. `amount` is minor units
|
|
279
|
+
* (the check-set total). */
|
|
280
|
+
guardedCheckSet(meta, run) {
|
|
281
|
+
return this.guard(
|
|
282
|
+
{ operation: "checkSet", resourceId: meta.claimId, amount: meta.amount, currency: meta.currency, inputHash: meta.inputHash },
|
|
283
|
+
run
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
/** Guard a reserve change (`POST /claims/{claimId}/reserve-sets`). Requires
|
|
287
|
+
* agent:transact and stays within `maxReserveAmount`. */
|
|
288
|
+
guardedReserveSet(meta, run) {
|
|
289
|
+
return this.guard(
|
|
290
|
+
{ operation: "reserveSet", resourceId: meta.claimId, amount: meta.amount, currency: meta.currency, inputHash: meta.inputHash },
|
|
291
|
+
run
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
/** Guard a recovery reserve (`POST /claims/{claimId}/recovery-reserve-sets`).
|
|
295
|
+
* Requires agent:transact; checked against the payment ceiling. */
|
|
296
|
+
guardedRecoveryReserveSet(meta, run) {
|
|
297
|
+
return this.guard(
|
|
298
|
+
{ operation: "recoveryReserveSet", resourceId: meta.claimId, amount: meta.amount, currency: meta.currency, inputHash: meta.inputHash },
|
|
299
|
+
run
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
/** Guard a policy bind + issue (`POST /job/v1/jobs/{jobId}/bind-and-issue`).
|
|
303
|
+
* Requires agent:transact; checked against the premium ceiling. Pass the
|
|
304
|
+
* premium as `amount` (minor units) to attenuate on it. */
|
|
305
|
+
guardedPolicyBind(meta, run) {
|
|
306
|
+
return this.guard(
|
|
307
|
+
{ operation: "policyBindIssue", resourceId: meta.jobId, amount: meta.amount, currency: meta.currency, inputHash: meta.inputHash },
|
|
308
|
+
run
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
/** Guard an endorsement / mid-term policy change job. Requires agent:write by
|
|
312
|
+
* default; pass the premium delta as `amount` to attenuate on the premium
|
|
313
|
+
* ceiling. */
|
|
314
|
+
guardedEndorsement(meta, run) {
|
|
315
|
+
return this.guard(
|
|
316
|
+
{ operation: "endorsement", resourceId: meta.jobId, amount: meta.amount, currency: meta.currency, inputHash: meta.inputHash },
|
|
317
|
+
run
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
/** Guard a premium refund / billing credit. Requires agent:transact; checked
|
|
321
|
+
* against the payment ceiling, like the Shopify refund cap. */
|
|
322
|
+
guardedPremiumRefund(meta, run) {
|
|
323
|
+
return this.guard(
|
|
324
|
+
{ operation: "premiumRefund", resourceId: meta.resourceId, amount: meta.amount, currency: meta.currency, inputHash: meta.inputHash },
|
|
325
|
+
run
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
/** Guard a claim assignment (`POST /claims/{claimId}/assign`). Requires
|
|
329
|
+
* agent:write; no money moves. */
|
|
330
|
+
guardedClaimAssign(meta, run) {
|
|
331
|
+
return this.guard({ operation: "claimAssign", resourceId: meta.claimId, inputHash: meta.inputHash }, run);
|
|
332
|
+
}
|
|
333
|
+
receipt(action, authorized, result, auth, recorded) {
|
|
334
|
+
const { kind } = this.ceilingFor(action.operation);
|
|
335
|
+
return {
|
|
336
|
+
authorized,
|
|
337
|
+
agentId: this.agentId,
|
|
338
|
+
humanId: this.humanId,
|
|
339
|
+
instance: this.instance,
|
|
340
|
+
operation: action.operation,
|
|
341
|
+
resourceId: action.resourceId,
|
|
342
|
+
amount: action.amount,
|
|
343
|
+
currency: action.currency,
|
|
344
|
+
ceiling: kind ?? void 0,
|
|
345
|
+
ceilingOutcome: auth.ceilingOutcome,
|
|
346
|
+
approverId: auth.approverId,
|
|
347
|
+
result,
|
|
348
|
+
scope: this.scopeFor(action.operation),
|
|
349
|
+
reason: auth.reason,
|
|
350
|
+
decisionId: auth.decisionId,
|
|
351
|
+
recorded
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
function createVorimGuidewire(sdk, config) {
|
|
356
|
+
return new VorimGuidewire(sdk, config);
|
|
357
|
+
}
|
|
358
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
359
|
+
0 && (module.exports = {
|
|
360
|
+
VorimGuidewire,
|
|
361
|
+
createVorimGuidewire
|
|
362
|
+
});
|
|
363
|
+
//# sourceMappingURL=guidewire.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/guidewire.ts"],"sourcesContent":["// ============================================================================\n// Vorim AI — Guidewire (P&C insurance core) Integration\n//\n// This guards an AI agent that acts on a Guidewire InsuranceSuite core system\n// (ClaimCenter / PolicyCenter / BillingCenter) through the Cloud API — paying\n// claims, setting reserves, binding policies, endorsing, issuing premium\n// refunds. Before each mutation runs it checks the acting agent holds the right\n// permission and that any money amount is within a delegated ceiling; above the\n// ceiling it escalates to a named human adjuster (segregation of duties) and\n// waits for that decision. Either way it signs a tamper-evident record of what\n// the agent did, under which authority, and who approved it.\n//\n// WHY THIS LAYER\n// Guidewire's own Cloud API authenticates a service with one OAuth token and\n// coarse API roles: every agent on that token looks identical, there is no way\n// to cap a sub-agent's claim-payment authority below the human's, and nothing\n// proves agent X (not agent Y) issued a given check-set. Guidewire's Qusar\n// release (Aug 2026) ships an Agentic Framework that helps insurers BUILD these\n// agents — this layer is the accountability and attenuation overlay ON those\n// agents. It composes with Guidewire, it does not replace the Cloud API.\n//\n// THE DOLLAR CEILING IS THE WEDGE\n// ClaimCenter's financial model is built on check-sets and reserve-sets that\n// carry explicit amounts and pass through a native \"Ability to pay\" / approval\n// gate. That maps 1:1 onto a delegated spend ceiling: an agent may pay claims\n// and set reserves up to a signed limit; anything above auto-escalates to a\n// named human adjuster. This is the shipped Shopify refund-ceiling attenuation,\n// re-pointed at a higher-stakes system of record.\n//\n// SCOPE MAPPING (uses Vorim's real scopes)\n// read core data -> agent:read\n// mutate a policy/claim (non-money) -> agent:write (assign, endorse draft)\n// move money (pay claim, refund, -> agent:transact + amount ceiling\n// set reserve, bind+issue)\n//\n// COMPLIANCE FRAMING (be precise — see the research memo)\n// The signed record is EVIDENCE for the documented, attributable, auditable\n// AI-decision obligations under the NAIC Model Bulletin on Use of AI Systems by\n// Insurers, the Unfair Claims Settlement Practices Act, and adverse-action\n// rules. No cited regime MANDATES a cryptographic signature; signing hardens\n// those records against tampering and makes them independently verifiable. Say\n// \"tamper-evident proof of documented, attributable AI claim decisions\", never\n// \"required by NAIC\".\n//\n// This layer never holds a Guidewire token and never calls Guidewire itself.\n// You pass it the Cloud API call to run; it authorizes, escalates if needed,\n// runs it, and signs the receipt.\n//\n// Usage:\n// import createVorim from '@vorim/sdk';\n// import { createVorimGuidewire } from '@vorim/sdk/integrations/guidewire';\n//\n// const vorim = createVorim({ apiKey: 'agid_sk_...' });\n// const gw = createVorimGuidewire(vorim, {\n// agentId: 'agid_abc123',\n// instance: 'acme.guidewire.net', // recorded on every receipt\n// humanId: 'adjuster_42', // the person the agent acts for\n// maxPaymentAmount: 500000, // pay claims up to $5,000.00 (cents)\n// maxReserveAmount: 2500000, // set reserves up to $25,000.00 (cents)\n// escalateOverCeiling: true, // above ceiling -> named-approver wait\n// });\n//\n// const { receipt, value } = await gw.guardedCheckSet(\n// { claimId: 'cc:42', amount: 499900, currency: 'USD' },\n// () => cloudApi.post(`/claims/cc:42/check-sets`, checkSet),\n// );\n// if (!receipt.authorized) console.warn(receipt.reason);\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\nimport type { PermissionScope } from '../types.js';\n\n/** The Guidewire Cloud API mutations this guard classifies. Any other label is\n * accepted too; it defaults to the 'write' risk tier (a mutation is at least a\n * write). The money-moving operations require agent:transact and are subject to\n * the dollar ceiling. */\nexport type GuidewireOperation =\n | 'checkSet' // POST /claims/{claimId}/check-sets — PAY a claim\n | 'reserveSet' // POST /claims/{claimId}/reserve-sets — SET reserves\n | 'recoveryReserveSet' // POST /claims/{claimId}/recovery-reserve-sets\n | 'policyBindIssue' // POST /job/v1/jobs/{jobId}/bind-and-issue\n | 'endorsement' // policy-change job — endorse / mid-term change\n | 'premiumRefund' // BillingCenter refund / credit\n | 'claimCreate' // FNOL — create draft claim\n | 'claimAssign' // POST /claims/{claimId}/assign\n | 'read';\n\n/** Map each operation to the least Vorim scope required to run it. Reads need\n * read; non-money mutations need write; anything that moves money (paying a\n * claim, setting a reserve, binding a policy, refunding premium) needs transact\n * and is bounded by the dollar ceiling. */\nconst OPERATION_SCOPE: Record<string, PermissionScope> = {\n read: 'agent:read',\n claimCreate: 'agent:write',\n claimAssign: 'agent:write',\n endorsement: 'agent:write',\n checkSet: 'agent:transact',\n reserveSet: 'agent:transact',\n recoveryReserveSet: 'agent:transact',\n policyBindIssue: 'agent:transact',\n premiumRefund: 'agent:transact',\n};\n\n/** Which ceiling a money-moving operation is checked against. Claim payments,\n * refunds and recoveries draw on the payment ceiling; reserves on the reserve\n * ceiling; policy bind/issue and endorsements on the premium ceiling. */\ntype CeilingKind = 'payment' | 'reserve' | 'premium' | null;\nconst OPERATION_CEILING: Record<string, CeilingKind> = {\n checkSet: 'payment',\n premiumRefund: 'payment',\n recoveryReserveSet: 'payment',\n reserveSet: 'reserve',\n policyBindIssue: 'premium',\n endorsement: 'premium',\n};\n\nexport interface GuidewireGuardConfig {\n /** The acting agent's Vorim id (agid_...). */\n agentId: string;\n /** The Guidewire instance this agent operates on, e.g. 'acme.guidewire.net'.\n * Recorded on every receipt so an action is attributable to one tenant. */\n instance: string;\n /** The human/adjuster/underwriter the agent acts for. Recorded on every\n * receipt so a core-system action is attributable to a person. Also the\n * default escalation target when a money amount exceeds the ceiling. */\n humanId?: string;\n /** Minimum trust score the acting agent must hold before any mutation runs.\n * Default 0 (off). */\n minTrustScore?: number;\n /** Attenuation: cap a single claim payment (check-set), premium refund, or\n * recovery, in the currency's minor unit (cents). Omit for no ceiling. */\n maxPaymentAmount?: number;\n /** Attenuation: cap a single reserve-set amount, in minor units. Omit for no\n * ceiling. */\n maxReserveAmount?: number;\n /** Attenuation: cap the premium (or premium delta) an agent may bind/endorse,\n * in minor units. Omit for no ceiling. */\n maxPremiumAmount?: number;\n /** When a money amount exceeds its ceiling, escalate to a named human\n * approver and wait for the decision instead of denying outright. Requires\n * the runtime decision plane (beforeAction). Default false: over-ceiling is a\n * hard deny. This is the segregation-of-duties gate. */\n escalateOverCeiling?: boolean;\n /** Max time to wait for an escalation decision, ms. Default 60000. */\n escalationTimeoutMs?: number;\n /** Fail closed (deny on any Vorim error) or fail open. Default 'closed'. */\n onError?: 'closed' | 'open';\n}\n\nexport interface GuidewireAction {\n /** The Cloud API operation being run, e.g. 'checkSet'. Drives the scope\n * requirement and which ceiling applies. Unknown labels default to write. */\n operation: GuidewireOperation | string;\n /** The claim / job / policy id the action targets, e.g. 'cc:42'. */\n resourceId?: string;\n /** For money-moving operations: the amount, in the minor unit (cents).\n * Checked against the relevant ceiling. */\n amount?: number;\n /** Currency code for `amount`, e.g. 'USD'. Recorded on the receipt. */\n currency?: string;\n /** Optional hash of the request body so the receipt covers the exact input\n * without the guard storing it. */\n inputHash?: string;\n}\n\n/** How an over-ceiling amount was resolved. */\nexport type CeilingOutcome = 'within' | 'escalated-approved' | 'escalated-denied' | 'over-ceiling';\n\n/** An offline-verifiable receipt for one Guidewire core-system operation. */\nexport interface GuidewireReceipt {\n authorized: boolean;\n agentId: string;\n humanId?: string;\n instance: string;\n operation: string;\n resourceId?: string;\n amount?: number;\n currency?: string;\n /** Which ceiling applied ('payment' | 'reserve' | 'premium'), if any. */\n ceiling?: Exclude<CeilingKind, null>;\n /** How the amount check resolved. */\n ceilingOutcome?: CeilingOutcome;\n /** The named approver, when the action escalated. */\n approverId?: string;\n result: 'success' | 'denied' | 'error';\n scope: PermissionScope;\n /** Reason a check failed, when authorized is false. */\n reason?: string;\n /** The runtime decision id, when the action went through beforeAction. */\n decisionId?: string;\n /** True once the audit event was signed and ingested. */\n recorded: boolean;\n}\n\nexport class VorimGuidewire {\n private sdk: VorimSDK;\n private agentId: string;\n private instance: string;\n private humanId?: string;\n private minTrustScore: number;\n private maxPaymentAmount?: number;\n private maxReserveAmount?: number;\n private maxPremiumAmount?: number;\n private escalateOverCeiling: boolean;\n private escalationTimeoutMs: number;\n private onError: 'closed' | 'open';\n\n constructor(sdk: VorimSDK, config: GuidewireGuardConfig) {\n if (!config?.agentId) throw new Error('[vorim] Guidewire integration requires an agentId.');\n if (!config?.instance) throw new Error('[vorim] Guidewire integration requires an instance.');\n this.sdk = sdk;\n this.agentId = config.agentId;\n this.instance = config.instance;\n this.humanId = config.humanId;\n this.minTrustScore = config.minTrustScore ?? 0;\n this.maxPaymentAmount = config.maxPaymentAmount;\n this.maxReserveAmount = config.maxReserveAmount;\n this.maxPremiumAmount = config.maxPremiumAmount;\n this.escalateOverCeiling = config.escalateOverCeiling ?? false;\n this.escalationTimeoutMs = config.escalationTimeoutMs ?? 60_000;\n this.onError = config.onError ?? 'closed';\n }\n\n /** The Vorim scope a given operation requires. Unknown mutations fall back to\n * agent:write. */\n private scopeFor(operation: string): PermissionScope {\n return OPERATION_SCOPE[operation] ?? 'agent:write';\n }\n\n /** The ceiling that applies to an operation, and this agent's configured\n * limit for it. Returns { kind: null } when the operation moves no money or\n * no ceiling is set. */\n private ceilingFor(operation: string): { kind: CeilingKind; limit?: number } {\n const kind = OPERATION_CEILING[operation] ?? null;\n if (kind === 'payment') return { kind, limit: this.maxPaymentAmount };\n if (kind === 'reserve') return { kind, limit: this.maxReserveAmount };\n if (kind === 'premium') return { kind, limit: this.maxPremiumAmount };\n return { kind: null };\n }\n\n /**\n * Decide whether the acting agent may run this operation, before it runs.\n * Order: trust floor, then the dollar ceiling (deny or escalate over it),\n * then permission scope. Returns the authorization plus how the ceiling\n * resolved and the runtime decision id when one was created.\n */\n async authorize(\n action: GuidewireAction,\n ): Promise<{\n authorized: boolean;\n reason?: string;\n ceilingOutcome: CeilingOutcome;\n approverId?: string;\n decisionId?: string;\n }> {\n const scope = this.scopeFor(action.operation);\n const { kind, limit } = this.ceilingFor(action.operation);\n const overCeiling =\n kind != null && limit != null && typeof action.amount === 'number' && action.amount > limit;\n\n try {\n // Trust floor (optional): refuse low-trust agents up front.\n if (this.minTrustScore > 0) {\n const trust = await this.sdk.verify(this.agentId);\n if ((trust?.trust_score ?? 0) < this.minTrustScore) {\n return {\n authorized: false,\n reason: `trust score below ${this.minTrustScore}`,\n ceilingOutcome: overCeiling ? 'over-ceiling' : 'within',\n };\n }\n }\n\n // Dollar ceiling: the attenuation wedge. An amount above this agent's\n // delegated limit either hard-denies, or (when escalateOverCeiling is on)\n // routes to a named human approver and waits — segregation of duties.\n if (overCeiling) {\n if (!this.escalateOverCeiling) {\n return {\n authorized: false,\n reason: `${kind} ${action.amount} exceeds this agent's ceiling of ${limit}`,\n ceilingOutcome: 'over-ceiling',\n };\n }\n const esc = await this.escalate(action, scope, kind!, limit!);\n return {\n authorized: esc.approved,\n reason: esc.approved ? undefined : (esc.reason ?? 'escalation denied'),\n ceilingOutcome: esc.approved ? 'escalated-approved' : 'escalated-denied',\n approverId: this.humanId,\n decisionId: esc.decisionId,\n };\n }\n\n // Within ceiling (or no ceiling): a plain permission check on the scope.\n const perm = await this.sdk.check(this.agentId, scope);\n return perm.allowed\n ? { authorized: true, ceilingOutcome: 'within' }\n : {\n authorized: false,\n reason: perm.reason ?? `missing scope ${scope}`,\n ceilingOutcome: 'within',\n };\n } catch (e: any) {\n // Fail closed by default: a check we could not complete is a deny.\n return this.onError === 'open'\n ? {\n authorized: true,\n reason: 'vorim unreachable, failed open',\n ceilingOutcome: overCeiling ? 'over-ceiling' : 'within',\n }\n : {\n authorized: false,\n reason: `vorim unreachable: ${e?.message ?? 'error'}`,\n ceilingOutcome: overCeiling ? 'over-ceiling' : 'within',\n };\n }\n }\n\n /**\n * Route an over-ceiling money action through the runtime decision plane so a\n * named human approver can allow or deny it, and wait for that decision. The\n * elevated scope (agent:elevate) marks this as a segregation-of-duties gate:\n * the agent that initiates the payment cannot also approve it above its limit.\n */\n private async escalate(\n action: GuidewireAction,\n scope: PermissionScope,\n kind: Exclude<CeilingKind, null>,\n limit: number,\n ): Promise<{ approved: boolean; reason?: string; decisionId?: string }> {\n const decision = await this.sdk.beforeAction(\n {\n agentId: this.agentId,\n actionType: 'api_request',\n actionTarget: `guidewire:${action.operation}`,\n requiredScope: scope,\n payload: {\n amount: action.amount,\n currency: action.currency,\n ceiling: kind,\n limit,\n resource_id: action.resourceId,\n },\n context: {\n integration: 'guidewire-cloud',\n instance: this.instance,\n requires_named_approver: true,\n approver_hint: this.humanId,\n },\n },\n { throwOnDeny: false },\n );\n\n // Resolve the escalate verdict: wait for the named approver's decision.\n if (decision.decision === 'escalate') {\n const resolved = await this.sdk.waitForDecisionResolution(decision.decisionId, {\n timeoutMs: this.escalationTimeoutMs,\n });\n const approved = resolved.decision === 'allow' || resolved.escalationResolution === 'approved';\n return {\n approved,\n reason: approved ? undefined : 'named approver denied',\n decisionId: decision.decisionId,\n };\n }\n // A non-escalate verdict resolves immediately. 'allow' / 'fallback' pass;\n // 'deny' fails. Fallback (control plane unreachable) obeys onError.\n if (decision.decision === 'allow') return { approved: true, decisionId: decision.decisionId };\n if (decision.decision === 'fallback')\n return { approved: this.onError === 'open', reason: 'runtime unreachable', decisionId: decision.decisionId };\n return { approved: false, reason: decision.reason ?? 'denied', decisionId: decision.decisionId };\n }\n\n /**\n * Emit a source-signed audit event for a core-system operation and return\n * whether it was recorded. Called after the mutation runs (or after a denial).\n * The event names the agent, the instance, the human the agent acts for, the\n * amount vs. its ceiling, and any approver — so the record is attributable and\n * independently verifiable offline, and carries the amount/authority/approval\n * an insurance examiner looks for.\n */\n async record(\n action: GuidewireAction,\n result: 'success' | 'denied' | 'error',\n extra: { reason?: string; ceilingOutcome?: CeilingOutcome; approverId?: string; decisionId?: string } = {},\n ): Promise<boolean> {\n const scope = this.scopeFor(action.operation);\n const { kind } = this.ceilingFor(action.operation);\n try {\n await this.sdk.emit(\n {\n agent_id: this.agentId,\n event_type: 'api_request',\n action: `guidewire:${action.operation}${action.resourceId ? ' ' + action.resourceId : ''}`,\n resource: action.resourceId || this.instance,\n permission: scope,\n result,\n input_hash: action.inputHash,\n metadata: {\n integration: 'guidewire-cloud',\n instance: this.instance,\n acts_for_human: this.humanId,\n operation: action.operation,\n ...(action.amount != null ? { amount: action.amount } : {}),\n ...(action.currency ? { currency: action.currency } : {}),\n ...(kind ? { ceiling_kind: kind } : {}),\n ...(extra.ceilingOutcome ? { ceiling_outcome: extra.ceilingOutcome } : {}),\n ...(extra.approverId ? { approver_id: extra.approverId } : {}),\n ...(extra.decisionId ? { decision_id: extra.decisionId } : {}),\n ...(extra.reason ? { reason: extra.reason } : {}),\n },\n },\n { sign: true }, // source-signed: the agent's key signs the record\n );\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * The full flow for one core-system operation: authorize (trust, ceiling with\n * escalation, scope), run the Cloud API call if allowed, sign a receipt either\n * way. If not authorized, `run` is never called. Rethrows an error from `run`\n * after recording it, with the receipt attached as `vorimReceipt`, so your\n * handler still sees Guidewire failures.\n */\n async guard<T>(\n action: GuidewireAction,\n run: () => Promise<T>,\n ): Promise<{ receipt: GuidewireReceipt; value?: T }> {\n const auth = await this.authorize(action);\n if (!auth.authorized) {\n const recorded = await this.record(action, 'denied', {\n reason: auth.reason,\n ceilingOutcome: auth.ceilingOutcome,\n approverId: auth.approverId,\n decisionId: auth.decisionId,\n });\n return {\n receipt: this.receipt(action, false, 'denied', auth, recorded),\n };\n }\n try {\n const value = await run();\n const recorded = await this.record(action, 'success', {\n ceilingOutcome: auth.ceilingOutcome,\n approverId: auth.approverId,\n decisionId: auth.decisionId,\n });\n return { receipt: this.receipt(action, true, 'success', auth, recorded), value };\n } catch (e: any) {\n const recorded = await this.record(action, 'error', {\n reason: e?.message,\n ceilingOutcome: auth.ceilingOutcome,\n approverId: auth.approverId,\n decisionId: auth.decisionId,\n });\n throw Object.assign(e ?? new Error('guidewire operation failed'), {\n vorimReceipt: this.receipt(action, true, 'error', { ...auth, reason: e?.message }, recorded),\n });\n }\n }\n\n // --- Named helpers for the high-risk Cloud API mutations -------------------\n // Each wraps guard() with the right operation label so the scope, ceiling, and\n // receipt are correct without the caller remembering the mapping. You pass the\n // Cloud API call as `run`; this layer never talks to Guidewire itself.\n\n /** Guard a claim payment (`POST /claims/{claimId}/check-sets`). Requires\n * agent:transact and stays within `maxPaymentAmount`; above it, escalates to\n * a named adjuster when `escalateOverCeiling` is on. `amount` is minor units\n * (the check-set total). */\n guardedCheckSet<T>(\n meta: { claimId?: string; amount?: number; currency?: string; inputHash?: string },\n run: () => Promise<T>,\n ) {\n return this.guard(\n { operation: 'checkSet', resourceId: meta.claimId, amount: meta.amount, currency: meta.currency, inputHash: meta.inputHash },\n run,\n );\n }\n\n /** Guard a reserve change (`POST /claims/{claimId}/reserve-sets`). Requires\n * agent:transact and stays within `maxReserveAmount`. */\n guardedReserveSet<T>(\n meta: { claimId?: string; amount?: number; currency?: string; inputHash?: string },\n run: () => Promise<T>,\n ) {\n return this.guard(\n { operation: 'reserveSet', resourceId: meta.claimId, amount: meta.amount, currency: meta.currency, inputHash: meta.inputHash },\n run,\n );\n }\n\n /** Guard a recovery reserve (`POST /claims/{claimId}/recovery-reserve-sets`).\n * Requires agent:transact; checked against the payment ceiling. */\n guardedRecoveryReserveSet<T>(\n meta: { claimId?: string; amount?: number; currency?: string; inputHash?: string },\n run: () => Promise<T>,\n ) {\n return this.guard(\n { operation: 'recoveryReserveSet', resourceId: meta.claimId, amount: meta.amount, currency: meta.currency, inputHash: meta.inputHash },\n run,\n );\n }\n\n /** Guard a policy bind + issue (`POST /job/v1/jobs/{jobId}/bind-and-issue`).\n * Requires agent:transact; checked against the premium ceiling. Pass the\n * premium as `amount` (minor units) to attenuate on it. */\n guardedPolicyBind<T>(\n meta: { jobId?: string; amount?: number; currency?: string; inputHash?: string },\n run: () => Promise<T>,\n ) {\n return this.guard(\n { operation: 'policyBindIssue', resourceId: meta.jobId, amount: meta.amount, currency: meta.currency, inputHash: meta.inputHash },\n run,\n );\n }\n\n /** Guard an endorsement / mid-term policy change job. Requires agent:write by\n * default; pass the premium delta as `amount` to attenuate on the premium\n * ceiling. */\n guardedEndorsement<T>(\n meta: { jobId?: string; amount?: number; currency?: string; inputHash?: string },\n run: () => Promise<T>,\n ) {\n return this.guard(\n { operation: 'endorsement', resourceId: meta.jobId, amount: meta.amount, currency: meta.currency, inputHash: meta.inputHash },\n run,\n );\n }\n\n /** Guard a premium refund / billing credit. Requires agent:transact; checked\n * against the payment ceiling, like the Shopify refund cap. */\n guardedPremiumRefund<T>(\n meta: { resourceId?: string; amount?: number; currency?: string; inputHash?: string },\n run: () => Promise<T>,\n ) {\n return this.guard(\n { operation: 'premiumRefund', resourceId: meta.resourceId, amount: meta.amount, currency: meta.currency, inputHash: meta.inputHash },\n run,\n );\n }\n\n /** Guard a claim assignment (`POST /claims/{claimId}/assign`). Requires\n * agent:write; no money moves. */\n guardedClaimAssign<T>(meta: { claimId?: string; inputHash?: string }, run: () => Promise<T>) {\n return this.guard({ operation: 'claimAssign', resourceId: meta.claimId, inputHash: meta.inputHash }, run);\n }\n\n private receipt(\n action: GuidewireAction,\n authorized: boolean,\n result: 'success' | 'denied' | 'error',\n auth: { reason?: string; ceilingOutcome?: CeilingOutcome; approverId?: string; decisionId?: string },\n recorded: boolean,\n ): GuidewireReceipt {\n const { kind } = this.ceilingFor(action.operation);\n return {\n authorized,\n agentId: this.agentId,\n humanId: this.humanId,\n instance: this.instance,\n operation: action.operation,\n resourceId: action.resourceId,\n amount: action.amount,\n currency: action.currency,\n ceiling: kind ?? undefined,\n ceilingOutcome: auth.ceilingOutcome,\n approverId: auth.approverId,\n result,\n scope: this.scopeFor(action.operation),\n reason: auth.reason,\n decisionId: auth.decisionId,\n recorded,\n };\n }\n}\n\n/**\n * Create a VorimGuidewire guard around a Vorim SDK instance.\n *\n * @example\n * ```typescript\n * import createVorim from '@vorim/sdk';\n * import { createVorimGuidewire } from '@vorim/sdk/integrations/guidewire';\n *\n * const vorim = createVorim({ apiKey: 'agid_sk_...' });\n * const gw = createVorimGuidewire(vorim, {\n * agentId: 'agid_abc123',\n * instance: 'acme.guidewire.net',\n * humanId: 'adjuster_42',\n * maxPaymentAmount: 500000, // pay claims up to $5,000.00\n * escalateOverCeiling: true, // above that -> named adjuster approval\n * });\n *\n * const { receipt, value } = await gw.guardedCheckSet(\n * { claimId: 'cc:42', amount: 499900, currency: 'USD' },\n * () => cloudApi.post('/claims/cc:42/check-sets', checkSet),\n * );\n * ```\n */\nexport function createVorimGuidewire(sdk: VorimSDK, config: GuidewireGuardConfig): VorimGuidewire {\n return new VorimGuidewire(sdk, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2FA,IAAM,kBAAmD;AAAA,EACvD,MAAM;AAAA,EACN,aAAa;AAAA,EACb,aAAa;AAAA,EACb,aAAa;AAAA,EACb,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,oBAAoB;AAAA,EACpB,iBAAiB;AAAA,EACjB,eAAe;AACjB;AAMA,IAAM,oBAAiD;AAAA,EACrD,UAAU;AAAA,EACV,eAAe;AAAA,EACf,oBAAoB;AAAA,EACpB,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,aAAa;AACf;AAgFO,IAAM,iBAAN,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