@lucern/sdk 0.2.0-alpha.1 → 0.2.0-alpha.10

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.
Files changed (275) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +691 -61
  3. package/dist/adminClient.d.ts +409 -0
  4. package/dist/adminClient.js +755 -0
  5. package/dist/adminClient.js.map +1 -0
  6. package/dist/answersClient.d.ts +23 -0
  7. package/dist/answersClient.js +333 -0
  8. package/dist/answersClient.js.map +1 -0
  9. package/dist/{packages/sdk/src/audiencesClient.d.ts → audiencesClient.d.ts} +30 -18
  10. package/dist/audiencesClient.js +472 -0
  11. package/dist/audiencesClient.js.map +1 -0
  12. package/dist/auditClient.d.ts +29 -0
  13. package/dist/auditClient.js +386 -0
  14. package/dist/auditClient.js.map +1 -0
  15. package/dist/beliefsClient.d.ts +242 -0
  16. package/dist/beliefsClient.js +616 -0
  17. package/dist/beliefsClient.js.map +1 -0
  18. package/dist/client.d.ts +2398 -0
  19. package/dist/client.js +6378 -0
  20. package/dist/client.js.map +1 -0
  21. package/dist/contextClient.d.ts +27 -0
  22. package/dist/contextClient.js +396 -0
  23. package/dist/contextClient.js.map +1 -0
  24. package/dist/contextFacade.d.ts +2 -0
  25. package/dist/contextFacade.js +73 -0
  26. package/dist/contextFacade.js.map +1 -0
  27. package/dist/{lucern/packages/domain-context/src/context-pack-compiler.d.ts → contextPackCompiler.d.ts} +11 -10
  28. package/dist/contextPackCompiler.js +1091 -0
  29. package/dist/contextPackCompiler.js.map +1 -0
  30. package/dist/contextPackPolicy.d.ts +84 -0
  31. package/dist/contextPackPolicy.js +347 -0
  32. package/dist/contextPackPolicy.js.map +1 -0
  33. package/dist/contextPackSchema.d.ts +7 -0
  34. package/dist/contextPackSchema.js +203 -0
  35. package/dist/contextPackSchema.js.map +1 -0
  36. package/dist/contextTypes.d.ts +135 -0
  37. package/dist/contextTypes.js +3 -0
  38. package/dist/contextTypes.js.map +1 -0
  39. package/dist/contracts/api-enums.contract.d.ts +81 -0
  40. package/dist/contracts/api-enums.contract.js +98 -0
  41. package/dist/contracts/api-enums.contract.js.map +1 -0
  42. package/dist/{lucern/contracts/src → contracts}/auth-session.contract.d.ts +14 -12
  43. package/dist/contracts/auth-session.contract.js +48 -0
  44. package/dist/contracts/auth-session.contract.js.map +1 -0
  45. package/dist/{lucern/contracts/src → contracts}/context-pack.contract.d.ts +56 -58
  46. package/dist/contracts/context-pack.contract.js +98 -0
  47. package/dist/contracts/context-pack.contract.js.map +1 -0
  48. package/dist/contracts/contextPack.d.ts +1 -0
  49. package/dist/contracts/contextPack.js +98 -0
  50. package/dist/contracts/contextPack.js.map +1 -0
  51. package/dist/contracts/index.d.ts +9 -0
  52. package/dist/contracts/index.js +4928 -0
  53. package/dist/contracts/index.js.map +1 -0
  54. package/dist/{lucern/contracts/src → contracts}/lens-filter.contract.d.ts +10 -8
  55. package/dist/contracts/lens-filter.contract.js +71 -0
  56. package/dist/contracts/lens-filter.contract.js.map +1 -0
  57. package/dist/contracts/lens-workflow.contract.d.ts +87 -0
  58. package/dist/contracts/lens-workflow.contract.js +123 -0
  59. package/dist/contracts/lens-workflow.contract.js.map +1 -0
  60. package/dist/contracts/lensFilter.d.ts +1 -0
  61. package/dist/contracts/lensFilter.js +71 -0
  62. package/dist/contracts/lensFilter.js.map +1 -0
  63. package/dist/contracts/lensWorkflow.d.ts +2 -0
  64. package/dist/contracts/lensWorkflow.js +123 -0
  65. package/dist/contracts/lensWorkflow.js.map +1 -0
  66. package/dist/contracts/mcp-tools.contract.d.ts +1 -0
  67. package/dist/contracts/mcp-tools.contract.js +3016 -0
  68. package/dist/contracts/mcp-tools.contract.js.map +1 -0
  69. package/dist/contracts/mcpTools.d.ts +1 -0
  70. package/dist/contracts/mcpTools.js +3016 -0
  71. package/dist/contracts/mcpTools.js.map +1 -0
  72. package/dist/contracts/prompt.contract.d.ts +26 -0
  73. package/dist/contracts/prompt.contract.js +12 -0
  74. package/dist/contracts/prompt.contract.js.map +1 -0
  75. package/dist/contracts/prompt.d.ts +1 -0
  76. package/dist/contracts/prompt.js +12 -0
  77. package/dist/contracts/prompt.js.map +1 -0
  78. package/dist/contracts/sdk-tools.contract.d.ts +2 -0
  79. package/dist/contracts/sdk-tools.contract.js +4164 -0
  80. package/dist/contracts/sdk-tools.contract.js.map +1 -0
  81. package/dist/contracts/sdkTools.d.ts +2 -0
  82. package/dist/contracts/sdkTools.js +4164 -0
  83. package/dist/contracts/sdkTools.js.map +1 -0
  84. package/dist/contracts/workflow-runtime.contract.d.ts +163 -0
  85. package/dist/contracts/workflow-runtime.contract.js +245 -0
  86. package/dist/contracts/workflow-runtime.contract.js.map +1 -0
  87. package/dist/contracts/workflowRuntime.d.ts +1 -0
  88. package/dist/contracts/workflowRuntime.js +245 -0
  89. package/dist/contracts/workflowRuntime.js.map +1 -0
  90. package/dist/{packages/sdk/src/controlObjectOwnership.d.ts → controlObjectOwnership.d.ts} +35 -18
  91. package/dist/controlObjectOwnership.js +215 -0
  92. package/dist/controlObjectOwnership.js.map +1 -0
  93. package/dist/{packages/sdk/src/coreClient.d.ts → coreClient.d.ts} +38 -14
  94. package/dist/coreClient.js +339 -0
  95. package/dist/coreClient.js.map +1 -0
  96. package/dist/customTools.d.ts +88 -0
  97. package/dist/customTools.js +248 -0
  98. package/dist/customTools.js.map +1 -0
  99. package/dist/decisionsClient.d.ts +111 -0
  100. package/dist/decisionsClient.js +522 -0
  101. package/dist/decisionsClient.js.map +1 -0
  102. package/dist/domainContext.d.ts +1 -0
  103. package/dist/domainContext.js +3 -0
  104. package/dist/domainContext.js.map +1 -0
  105. package/dist/events.d.ts +178 -0
  106. package/dist/events.js +249 -0
  107. package/dist/events.js.map +1 -0
  108. package/dist/eventsCore.d.ts +49 -0
  109. package/dist/eventsCore.js +429 -0
  110. package/dist/eventsCore.js.map +1 -0
  111. package/dist/evidenceClient.d.ts +119 -0
  112. package/dist/evidenceClient.js +350 -0
  113. package/dist/evidenceClient.js.map +1 -0
  114. package/dist/facade/context.d.ts +18 -0
  115. package/dist/facade/context.js +73 -0
  116. package/dist/facade/context.js.map +1 -0
  117. package/dist/gatewayFacades.d.ts +589 -0
  118. package/dist/gatewayFacades.js +1976 -0
  119. package/dist/gatewayFacades.js.map +1 -0
  120. package/dist/graphClient.d.ts +271 -0
  121. package/dist/graphClient.js +698 -0
  122. package/dist/graphClient.js.map +1 -0
  123. package/dist/{packages/sdk/src/harnessClient.d.ts → harnessClient.d.ts} +127 -35
  124. package/dist/harnessClient.js +607 -0
  125. package/dist/harnessClient.js.map +1 -0
  126. package/dist/identityClient.d.ts +140 -0
  127. package/dist/identityClient.js +497 -0
  128. package/dist/identityClient.js.map +1 -0
  129. package/dist/index.d.ts +45 -0
  130. package/dist/index.js +5263 -2579
  131. package/dist/index.js.map +1 -1
  132. package/dist/learningClient.d.ts +46 -0
  133. package/dist/learningClient.js +409 -0
  134. package/dist/learningClient.js.map +1 -0
  135. package/dist/{packages/sdk/src/mcpParityClient.d.ts → mcpParityClient.d.ts} +11 -5
  136. package/dist/mcpParityClient.js +516 -0
  137. package/dist/mcpParityClient.js.map +1 -0
  138. package/dist/mcpParitySurface.d.ts +12 -0
  139. package/dist/mcpParitySurface.js +65 -0
  140. package/dist/mcpParitySurface.js.map +1 -0
  141. package/dist/mcpTools-DPZxowDX.d.ts +254 -0
  142. package/dist/{packages/sdk/src/ontologyClient.d.ts → ontologyClient.d.ts} +44 -22
  143. package/dist/ontologyClient.js +513 -0
  144. package/dist/ontologyClient.js.map +1 -0
  145. package/dist/packRuntime.d.ts +2 -0
  146. package/dist/packRuntime.js +3 -0
  147. package/dist/packRuntime.js.map +1 -0
  148. package/dist/packsClient.d.ts +131 -0
  149. package/dist/packsClient.js +525 -0
  150. package/dist/packsClient.js.map +1 -0
  151. package/dist/{packages/sdk/src/policyClient.d.ts → policyClient.d.ts} +113 -18
  152. package/dist/policyClient.js +625 -0
  153. package/dist/policyClient.js.map +1 -0
  154. package/dist/realtime/index.d.ts +29 -0
  155. package/dist/realtime/index.js +23 -0
  156. package/dist/realtime/index.js.map +1 -0
  157. package/dist/realtime/refs.d.ts +17 -0
  158. package/dist/realtime/refs.js +9 -0
  159. package/dist/realtime/refs.js.map +1 -0
  160. package/dist/reportsClient.d.ts +41 -0
  161. package/dist/reportsClient.js +418 -0
  162. package/dist/reportsClient.js.map +1 -0
  163. package/dist/schemaClient.d.ts +64 -0
  164. package/dist/schemaClient.js +434 -0
  165. package/dist/schemaClient.js.map +1 -0
  166. package/dist/sdkSurface.d.ts +61 -0
  167. package/dist/sdkSurface.js +112 -0
  168. package/dist/sdkSurface.js.map +1 -0
  169. package/dist/sdkTools-CwXJDACb.d.ts +150 -0
  170. package/dist/sourcesClient.d.ts +24 -0
  171. package/dist/sourcesClient.js +339 -0
  172. package/dist/sourcesClient.js.map +1 -0
  173. package/dist/topicsClient.d.ts +84 -0
  174. package/dist/topicsClient.js +492 -0
  175. package/dist/topicsClient.js.map +1 -0
  176. package/dist/types.d.ts +715 -0
  177. package/dist/types.js +3 -0
  178. package/dist/types.js.map +1 -0
  179. package/dist/version.d.ts +4 -0
  180. package/dist/version.js +6 -0
  181. package/dist/version.js.map +1 -0
  182. package/dist/workflowClient.d.ts +316 -0
  183. package/dist/workflowClient.js +830 -0
  184. package/dist/workflowClient.js.map +1 -0
  185. package/package.json +41 -37
  186. package/dist/lucern/contracts/src/lens-workflow.contract.d.ts +0 -84
  187. package/dist/lucern/contracts/src/mcp-tools.contract.d.ts +0 -151
  188. package/dist/lucern/contracts/src/workflow-runtime.contract.d.ts +0 -161
  189. package/dist/lucern/mcp-server/src/context-pack-policy.d.ts +0 -119
  190. package/dist/lucern/mcp-server/src/context-pack-schema.d.ts +0 -18
  191. package/dist/lucern/modules/graph-primitives/src/ontology-matching.d.ts +0 -78
  192. package/dist/lucern/modules/graph-primitives/src/text-matching.d.ts +0 -53
  193. package/dist/lucern/packages/client-core/src/beliefs.d.ts +0 -30
  194. package/dist/lucern/packages/client-core/src/context.d.ts +0 -29
  195. package/dist/lucern/packages/client-core/src/contradictions.d.ts +0 -11
  196. package/dist/lucern/packages/client-core/src/edges.d.ts +0 -11
  197. package/dist/lucern/packages/client-core/src/events.d.ts +0 -9
  198. package/dist/lucern/packages/client-core/src/evidence.d.ts +0 -21
  199. package/dist/lucern/packages/client-core/src/graph.d.ts +0 -17
  200. package/dist/lucern/packages/client-core/src/identity.d.ts +0 -7
  201. package/dist/lucern/packages/client-core/src/ids.d.ts +0 -7
  202. package/dist/lucern/packages/client-core/src/ontologies.d.ts +0 -13
  203. package/dist/lucern/packages/client-core/src/questions.d.ts +0 -39
  204. package/dist/lucern/packages/client-core/src/search.d.ts +0 -7
  205. package/dist/lucern/packages/client-core/src/tasks.d.ts +0 -13
  206. package/dist/lucern/packages/client-core/src/topics.d.ts +0 -17
  207. package/dist/lucern/packages/client-core/src/webhooks.d.ts +0 -35
  208. package/dist/lucern/packages/client-core/src/worktrees.d.ts +0 -17
  209. package/dist/lucern/packages/domain-beliefs/src/beliefs.d.ts +0 -283
  210. package/dist/lucern/packages/domain-beliefs/src/index.d.ts +0 -1
  211. package/dist/lucern/packages/domain-context/src/compile.d.ts +0 -11
  212. package/dist/lucern/packages/domain-context/src/index.d.ts +0 -4
  213. package/dist/lucern/packages/domain-context/src/ports.d.ts +0 -58
  214. package/dist/lucern/packages/domain-context/src/public-types.d.ts +0 -1
  215. package/dist/lucern/packages/domain-edges/src/contradictions.d.ts +0 -59
  216. package/dist/lucern/packages/domain-edges/src/edges.d.ts +0 -91
  217. package/dist/lucern/packages/domain-edges/src/index.d.ts +0 -2
  218. package/dist/lucern/packages/domain-evidence/src/evidence.d.ts +0 -115
  219. package/dist/lucern/packages/domain-evidence/src/index.d.ts +0 -1
  220. package/dist/lucern/packages/domain-graph/src/graph.d.ts +0 -150
  221. package/dist/lucern/packages/domain-identity/src/index.d.ts +0 -1
  222. package/dist/lucern/packages/domain-identity/src/whoami.d.ts +0 -13
  223. package/dist/lucern/packages/domain-ontologies/src/ontologies.d.ts +0 -123
  224. package/dist/lucern/packages/domain-questions/src/index.d.ts +0 -1
  225. package/dist/lucern/packages/domain-questions/src/questions.d.ts +0 -147
  226. package/dist/lucern/packages/domain-search/src/search.d.ts +0 -97
  227. package/dist/lucern/packages/domain-tasks/src/index.d.ts +0 -1
  228. package/dist/lucern/packages/domain-tasks/src/tasks.d.ts +0 -102
  229. package/dist/lucern/packages/domain-topics/src/index.d.ts +0 -1
  230. package/dist/lucern/packages/domain-topics/src/topics.d.ts +0 -147
  231. package/dist/lucern/packages/domain-worktrees/src/index.d.ts +0 -1
  232. package/dist/lucern/packages/domain-worktrees/src/worktrees.d.ts +0 -185
  233. package/dist/lucern/packages/events/src/index.d.ts +0 -4
  234. package/dist/lucern/packages/events/src/matching.d.ts +0 -3
  235. package/dist/lucern/packages/events/src/outbox.d.ts +0 -15
  236. package/dist/lucern/packages/events/src/types.d.ts +0 -151
  237. package/dist/lucern/packages/events/src/webhooks.d.ts +0 -9
  238. package/dist/lucern/packages/sdk-typescript/src/facade/beliefs.d.ts +0 -15
  239. package/dist/lucern/packages/sdk-typescript/src/facade/context.d.ts +0 -12
  240. package/dist/lucern/packages/sdk-typescript/src/facade/contradictions.d.ts +0 -7
  241. package/dist/lucern/packages/sdk-typescript/src/facade/edges.d.ts +0 -7
  242. package/dist/lucern/packages/sdk-typescript/src/facade/events.d.ts +0 -6
  243. package/dist/lucern/packages/sdk-typescript/src/facade/evidence.d.ts +0 -21
  244. package/dist/lucern/packages/sdk-typescript/src/facade/graph.d.ts +0 -10
  245. package/dist/lucern/packages/sdk-typescript/src/facade/identity.d.ts +0 -5
  246. package/dist/lucern/packages/sdk-typescript/src/facade/ontologies.d.ts +0 -8
  247. package/dist/lucern/packages/sdk-typescript/src/facade/questions.d.ts +0 -39
  248. package/dist/lucern/packages/sdk-typescript/src/facade/search.d.ts +0 -5
  249. package/dist/lucern/packages/sdk-typescript/src/facade/tasks.d.ts +0 -8
  250. package/dist/lucern/packages/sdk-typescript/src/facade/topics.d.ts +0 -10
  251. package/dist/lucern/packages/sdk-typescript/src/facade/webhooks.d.ts +0 -16
  252. package/dist/lucern/packages/sdk-typescript/src/facade/worktrees.d.ts +0 -10
  253. package/dist/lucern/packages/sdk-typescript/src/index.d.ts +0 -28
  254. package/dist/packages/sdk/src/adminClient.d.ts +0 -89
  255. package/dist/packages/sdk/src/answersClient.d.ts +0 -5
  256. package/dist/packages/sdk/src/auditClient.d.ts +0 -23
  257. package/dist/packages/sdk/src/beliefsClient.d.ts +0 -54
  258. package/dist/packages/sdk/src/client.d.ts +0 -1610
  259. package/dist/packages/sdk/src/contextClient.d.ts +0 -9
  260. package/dist/packages/sdk/src/contracts/api-enums.contract.d.ts +0 -58
  261. package/dist/packages/sdk/src/customTools.d.ts +0 -65
  262. package/dist/packages/sdk/src/decisionsClient.d.ts +0 -110
  263. package/dist/packages/sdk/src/graphClient.d.ts +0 -209
  264. package/dist/packages/sdk/src/identityClient.d.ts +0 -104
  265. package/dist/packages/sdk/src/index.d.ts +0 -28
  266. package/dist/packages/sdk/src/learningClient.d.ts +0 -43
  267. package/dist/packages/sdk/src/mcpParitySurface.d.ts +0 -8
  268. package/dist/packages/sdk/src/packsClient.d.ts +0 -101
  269. package/dist/packages/sdk/src/reportsClient.d.ts +0 -31
  270. package/dist/packages/sdk/src/schemaClient.d.ts +0 -54
  271. package/dist/packages/sdk/src/sdkSurface.d.ts +0 -56
  272. package/dist/packages/sdk/src/topicsClient.d.ts +0 -45
  273. package/dist/packages/sdk/src/types.d.ts +0 -489
  274. package/dist/packages/sdk/src/version.d.ts +0 -2
  275. package/dist/packages/sdk/src/workflowClient.d.ts +0 -274
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/coreClient.ts","../src/sdkSurface.ts","../src/graphClient.ts"],"names":[],"mappings":";AAuDO,IAAM,cAAA,GAAN,cAA6B,KAAA,CAAM;AAAA,EACxB,IAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAA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,CAAc,KAAK,CAAC,CAAA;AAAA,OACzD,CAAA;AAAA,IACH,CAAA;AAAA;AAAA;AAAA;AAAA,IAKA,MAAM,YAAA,CAAa,KAAA,GAAwB,EAAC,EAAG;AAC7C,MAAA,OAAO,QAAQ,OAAA,CAAgC;AAAA,QAC7C,IAAA,EAAM,CAAA,gCAAA,EAAmC,aAAA,CAAc,KAAK,CAAC,CAAA;AAAA,OAC9D,CAAA;AAAA,IACH;AAAA,GACF;AACF","file":"graphClient.js","sourcesContent":["import type { JsonObject, JsonValue } from \"./types\";\n\n/** Tenant and workspace identifiers used to scope gateway requests. */\nexport type GatewayScope = {\n tenantId?: string;\n workspaceId?: string;\n};\n\n/** Successful response envelope from the platform gateway with correlation metadata. */\nexport type PlatformGatewaySuccess<T> = {\n success: true;\n data: T;\n correlationId: string;\n policyTraceId: string | null;\n idempotentReplay: boolean;\n};\n\n/** Failed response envelope with structured error codes and optional invariant references. */\nexport type PlatformGatewayFailure = {\n success: false;\n /**\n * Error string is the canonical envelope field.\n * Object form is legacy-only compatibility for older gateway responses.\n */\n error:\n | string\n | {\n code: string;\n message: string;\n details?: JsonValue;\n };\n code?: string;\n invariant?: string | null;\n suggestion?: string | null;\n details?: JsonValue;\n legacyError?: {\n code: string;\n message: string;\n details?: JsonValue;\n };\n correlationId: string;\n policyTraceId: string | null;\n};\n\n/** Discriminated union of success and failure gateway responses. */\nexport type PlatformGatewayEnvelope<T> =\n | PlatformGatewaySuccess<T>\n | PlatformGatewayFailure;\n\n/**\n * Structured error thrown when a platform API request fails.\n *\n * Includes HTTP status, machine-readable error code, optional invariant\n * reference, and actionable suggestions for common failure modes.\n */\nexport class LucernApiError extends Error {\n public readonly code: string;\n public readonly status: number;\n public readonly invariant?: string | null;\n public readonly suggestion?: string | null;\n public readonly details?: JsonValue;\n public readonly requestId?: string;\n public readonly correlationId?: string;\n public readonly policyTraceId?: string | null;\n\n constructor(args: {\n code: string;\n message: string;\n status: number;\n invariant?: string | null;\n suggestion?: string | null;\n details?: JsonValue;\n requestId?: string;\n correlationId?: string;\n policyTraceId?: string | null;\n }) {\n super(args.message);\n this.name = \"LucernApiError\";\n this.code = args.code;\n this.status = args.status;\n this.invariant = args.invariant;\n this.suggestion = args.suggestion;\n this.details = args.details;\n this.requestId = args.requestId;\n this.correlationId = args.correlationId;\n this.policyTraceId = args.policyTraceId;\n }\n}\n\n/** Supported HTTP methods for gateway requests. */\nexport type GatewayHttpMethod = \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\ntype FetchLike = (\n input: RequestInfo | URL,\n init?: RequestInit\n) => Promise<Response>;\n\n/** Context passed to the `onRequest` hook before each gateway request attempt. */\nexport type GatewayRequestHookContext = {\n requestId: string;\n attempt: number;\n maxRetries: number;\n method: GatewayHttpMethod;\n path: string;\n url: string;\n headers: Headers;\n body?: string;\n timeoutMs: number;\n};\n\n/** Context passed to the `onResponse` hook after each gateway request attempt (including retries and failures). */\nexport type GatewayResponseHookContext = GatewayRequestHookContext & {\n durationMs: number;\n status?: number;\n response?: Response;\n error?: unknown;\n correlationId?: string;\n policyTraceId?: string | null;\n idempotentReplay?: boolean;\n retryAfterMs?: number | null;\n willRetry: boolean;\n};\n\n/**\n * Low-level transport configuration for the platform gateway client.\n *\n * Most developers should use {@link createLucernClient} instead, which wraps\n * this config with higher-level conveniences like `apiKey` and `environment`.\n */\nexport type GatewayClientConfig = {\n baseUrl?: string;\n fetchImpl?: FetchLike;\n getAuthHeaders?:\n | (() => Promise<Record<string, string>>)\n | (() => Record<string, string>);\n /** Max retries for transient errors (5xx, network). Defaults to 2. */\n maxRetries?: number;\n /** Request timeout in ms. Defaults to 15000. */\n timeoutMs?: number;\n /** Optional timeout overrides by HTTP method. */\n timeoutMsByMethod?: Partial<Record<GatewayHttpMethod, number>>;\n /** Optional request ID factory used for correlation headers. */\n requestIdFactory?: () => string;\n /** Invoked before each request attempt, including retries. */\n onRequest?:\n | ((context: GatewayRequestHookContext) => void)\n | ((context: GatewayRequestHookContext) => Promise<void>);\n /** Invoked after each request attempt, including retries and failures. */\n onResponse?:\n | ((context: GatewayResponseHookContext) => void)\n | ((context: GatewayResponseHookContext) => Promise<void>);\n};\n\n/**\n * Serialize a gateway query object into a URL query string.\n */\nexport function toQueryString(\n scope: GatewayScope & Record<string, string | number | boolean | undefined>\n): string {\n const params = new URLSearchParams();\n if (scope.tenantId) {\n params.set(\"tenantId\", scope.tenantId);\n }\n if (scope.workspaceId) {\n params.set(\"workspaceId\", scope.workspaceId);\n }\n for (const [key, value] of Object.entries(scope)) {\n if (key === \"tenantId\" || key === \"workspaceId\") {\n continue;\n }\n if (value === undefined) {\n continue;\n }\n params.set(key, String(value));\n }\n const serialized = params.toString();\n return serialized.length > 0 ? `?${serialized}` : \"\";\n}\n\nfunction fillRandomBytes(length: number): Uint8Array {\n const bytes = new Uint8Array(length);\n if (typeof globalThis.crypto?.getRandomValues === \"function\") {\n globalThis.crypto.getRandomValues(bytes);\n return bytes;\n }\n\n for (let index = 0; index < length; index += 1) {\n bytes[index] = Math.floor(Math.random() * 256);\n }\n return bytes;\n}\n\nfunction generatePortableRequestId(): string {\n if (typeof globalThis.crypto?.randomUUID === \"function\") {\n return globalThis.crypto.randomUUID();\n }\n\n const bytes = fillRandomBytes(16);\n bytes[6] = (bytes[6] & 0x0f) | 0x40;\n bytes[8] = (bytes[8] & 0x3f) | 0x80;\n const hex = Array.from(bytes, (value) => value.toString(16).padStart(2, \"0\"));\n return `${hex.slice(0, 4).join(\"\")}-${hex.slice(4, 6).join(\"\")}-${hex.slice(\n 6,\n 8\n ).join(\"\")}-${hex.slice(8, 10).join(\"\")}-${hex.slice(10).join(\"\")}`;\n}\n\n/**\n * Generate a random idempotency key for retry-safe writes.\n */\nexport function randomIdempotencyKey(): string {\n return generatePortableRequestId();\n}\n\nfunction isRetryableStatus(status: number): boolean {\n return status >= 500 || status === 408 || status === 429;\n}\n\nfunction fallbackErrorCode(status: number): string {\n if (status === 401) {\n return \"AUTHENTICATION_REQUIRED\";\n }\n if (status === 403) {\n return \"FORBIDDEN\";\n }\n if (status === 404) {\n return \"NOT_FOUND\";\n }\n if (status === 408) {\n return \"UPSTREAM_ERROR\";\n }\n if (status === 409) {\n return \"CONFLICT\";\n }\n if (status === 429) {\n return \"RATE_LIMIT_EXCEEDED\";\n }\n if (status >= 500) {\n return \"UPSTREAM_ERROR\";\n }\n return \"INTERNAL_ERROR\";\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nfunction parseRetryAfterMs(value: string | null): number | null {\n if (!value) {\n return null;\n }\n const trimmed = value.trim();\n if (!trimmed) {\n return null;\n }\n const numeric = Number(trimmed);\n if (Number.isFinite(numeric)) {\n return Math.max(0, Math.round(numeric * 1000));\n }\n const parsedDate = Date.parse(trimmed);\n if (Number.isFinite(parsedDate)) {\n return Math.max(0, parsedDate - Date.now());\n }\n return null;\n}\n\nfunction computeRetryDelayMs(args: {\n attempt: number;\n status?: number;\n retryAfterMs?: number | null;\n}): number {\n const baseDelay =\n args.status === 429\n ? Math.max(\n args.retryAfterMs ?? 0,\n Math.min(1000 * 2 ** args.attempt, 10_000)\n )\n : Math.min(1000 * 2 ** args.attempt, 4000);\n\n if (args.status !== 429) {\n return baseDelay;\n }\n\n const jitterWindow = Math.max(250, Math.round(baseDelay * 0.25));\n return baseDelay + Math.round(Math.random() * jitterWindow);\n}\n\nfunction timeoutError(timeoutMs: number): Error {\n const error = new Error(`Request timed out after ${timeoutMs}ms`);\n error.name = \"AbortError\";\n return error;\n}\n\nfunction readPolicySummaryFromDetails(details?: JsonValue): string | null {\n if (!details || typeof details !== \"object\" || Array.isArray(details)) {\n return null;\n }\n\n const directSummary = (details as { summary?: JsonValue }).summary;\n if (typeof directSummary === \"string\" && directSummary.trim().length > 0) {\n return directSummary.trim();\n }\n\n const policy = (details as { policy?: JsonValue }).policy;\n if (!policy || typeof policy !== \"object\" || Array.isArray(policy)) {\n return null;\n }\n\n const explanation = (policy as { explanation?: JsonValue }).explanation;\n if (!explanation || typeof explanation !== \"object\" || Array.isArray(explanation)) {\n return null;\n }\n\n const nestedSummary = (explanation as { summary?: JsonValue }).summary;\n if (typeof nestedSummary === \"string\" && nestedSummary.trim().length > 0) {\n return nestedSummary.trim();\n }\n\n return null;\n}\n\n/**\n * Create the transport client used by all SDK modules.\n */\nexport function createGatewayRequestClient(config: GatewayClientConfig = {}) {\n const fetchImpl = config.fetchImpl ?? fetch;\n const baseUrl = config.baseUrl?.replace(/\\/+$/, \"\") ?? \"\";\n const maxRetries = config.maxRetries ?? 2;\n const requestIdFactory = config.requestIdFactory ?? (() => generatePortableRequestId());\n\n async function resolveAuthHeaders(): Promise<Record<string, string>> {\n if (!config.getAuthHeaders) {\n return {};\n }\n return await config.getAuthHeaders();\n }\n\n async function fetchWithTimeout(\n url: string,\n init: RequestInit,\n timeoutMs: number\n ): Promise<Response> {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeoutMs);\n try {\n return await fetchImpl(url, { ...init, signal: controller.signal });\n } catch (error) {\n if (controller.signal.aborted) {\n throw timeoutError(timeoutMs);\n }\n throw error;\n } finally {\n clearTimeout(timer);\n }\n }\n\n async function parsePayload<T>(\n response: Response\n ): Promise<PlatformGatewayEnvelope<T> | null> {\n const text = await response.text();\n if (!text) {\n return null;\n }\n try {\n return JSON.parse(text) as PlatformGatewayEnvelope<T>;\n } catch {\n return null;\n }\n }\n\n function resolveTimeoutMs(\n method: GatewayHttpMethod,\n requestTimeoutMs?: number\n ): number {\n if (typeof requestTimeoutMs === \"number\") {\n return requestTimeoutMs;\n }\n const methodTimeoutMs = config.timeoutMsByMethod?.[method];\n if (typeof methodTimeoutMs === \"number\") {\n return methodTimeoutMs;\n }\n return config.timeoutMs ?? 15_000;\n }\n\n function buildApiError(args: {\n requestId: string;\n response: Response;\n failure?: PlatformGatewayFailure | null;\n }): LucernApiError {\n const failure = args.failure;\n const legacyError =\n failure && typeof failure.error === \"object\" && failure.error !== null\n ? failure.error\n : failure?.legacyError;\n const correlationId =\n failure?.correlationId ??\n args.response.headers.get(\"x-lucern-correlation-id\")?.trim() ??\n args.requestId;\n const policyTraceId =\n failure?.policyTraceId ??\n args.response.headers.get(\"x-lucern-policy-trace-id\")?.trim() ??\n null;\n const details = failure?.details ?? legacyError?.details;\n const policySummary = readPolicySummaryFromDetails(details);\n\n return new LucernApiError({\n code: failure?.code ?? legacyError?.code ?? fallbackErrorCode(args.response.status),\n message:\n policySummary ??\n (typeof failure?.error === \"string\"\n ? failure.error\n : legacyError?.message ??\n (args.response.ok\n ? \"Platform API returned an invalid success payload.\"\n : \"Platform API request failed.\")),\n status: args.response.status,\n invariant: failure?.invariant,\n suggestion: failure?.suggestion,\n details,\n requestId: args.requestId,\n correlationId,\n policyTraceId,\n });\n }\n\n async function request<T>(args: {\n path: string;\n method?: GatewayHttpMethod;\n body?: JsonObject;\n idempotencyKey?: string;\n requestId?: string;\n timeoutMs?: number;\n }): Promise<PlatformGatewaySuccess<T>> {\n const authHeaders = await resolveAuthHeaders();\n const method = args.method ?? \"GET\";\n const timeoutMs = resolveTimeoutMs(method, args.timeoutMs);\n const headers = new Headers({\n \"content-type\": \"application/json\",\n ...authHeaders,\n });\n if (args.idempotencyKey) {\n headers.set(\"idempotency-key\", args.idempotencyKey);\n }\n const requestId =\n headers.get(\"x-correlation-id\")?.trim() ||\n headers.get(\"x-request-id\")?.trim() ||\n args.requestId ||\n requestIdFactory();\n if (!headers.has(\"x-correlation-id\") && !headers.has(\"x-request-id\")) {\n headers.set(\"x-correlation-id\", requestId);\n }\n\n const url = `${baseUrl}${args.path}`;\n const serializedBody = args.body ? JSON.stringify(args.body) : undefined;\n const init: RequestInit = {\n method,\n headers,\n body: serializedBody,\n };\n\n let lastError: unknown;\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n const hookRequestContext: GatewayRequestHookContext = {\n requestId,\n attempt,\n maxRetries,\n method,\n path: args.path,\n url,\n headers: new Headers(headers),\n body: serializedBody,\n timeoutMs,\n };\n await config.onRequest?.(hookRequestContext);\n const startedAt = Date.now();\n try {\n const response = await fetchWithTimeout(url, init, timeoutMs);\n const responseClone = response.clone();\n const payload = await parsePayload<T>(response);\n const retryAfterMs = parseRetryAfterMs(\n response.headers.get(\"Retry-After\")\n );\n\n if (!response.ok || !payload?.success) {\n const failure =\n payload && !payload.success ? (payload as PlatformGatewayFailure) : null;\n const apiError = buildApiError({\n requestId,\n response,\n failure,\n });\n const willRetry = attempt < maxRetries && isRetryableStatus(response.status);\n\n await config.onResponse?.({\n ...hookRequestContext,\n durationMs: Date.now() - startedAt,\n status: response.status,\n response: responseClone,\n error: apiError,\n correlationId: apiError.correlationId ?? requestId,\n policyTraceId: apiError.policyTraceId ?? null,\n retryAfterMs,\n willRetry,\n });\n\n if (willRetry) {\n lastError = apiError;\n await delay(\n computeRetryDelayMs({\n attempt,\n status: response.status,\n retryAfterMs,\n })\n );\n continue;\n }\n\n throw apiError;\n }\n\n const successPayload = payload as PlatformGatewaySuccess<T>;\n await config.onResponse?.({\n ...hookRequestContext,\n durationMs: Date.now() - startedAt,\n status: response.status,\n response: responseClone,\n correlationId:\n successPayload.correlationId ??\n response.headers.get(\"x-lucern-correlation-id\")?.trim() ??\n requestId,\n policyTraceId:\n successPayload.policyTraceId ??\n response.headers.get(\"x-lucern-policy-trace-id\")?.trim() ??\n null,\n idempotentReplay: successPayload.idempotentReplay,\n retryAfterMs,\n willRetry: false,\n });\n\n return successPayload;\n } catch (fetchError) {\n if (fetchError instanceof LucernApiError) {\n throw fetchError;\n }\n const willRetry = attempt < maxRetries;\n await config.onResponse?.({\n ...hookRequestContext,\n durationMs: Date.now() - startedAt,\n error: fetchError,\n correlationId: requestId,\n policyTraceId: null,\n willRetry,\n });\n lastError = fetchError;\n if (willRetry) {\n await delay(computeRetryDelayMs({ attempt }));\n }\n }\n }\n\n throw lastError instanceof Error\n ? lastError\n : new Error(\"Platform API request failed after retries.\");\n }\n\n return {\n request,\n };\n}\n","import type { PlatformGatewaySuccess } from \"./coreClient\";\nimport type { JsonObject, ListResult } from \"./types\";\n\ntype TopicScopedValue = {\n topicId?: string;\n};\n\ntype TextScopedValue = {\n text?: string;\n canonicalText?: string;\n};\n\ntype AnyRecord = Record<string, unknown>;\n\nfunction asRecord(value: unknown): AnyRecord {\n return value && typeof value === \"object\" ? (value as AnyRecord) : {};\n}\n\nfunction cleanString(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim().length > 0\n ? value.trim()\n : undefined;\n}\n\nfunction normalizeVerificationStatus(value: unknown): string | undefined {\n const status = cleanString(value);\n if (!status) {\n return undefined;\n }\n if (status === \"verified\") {\n return \"human_verified\";\n }\n if (status === \"rejected\") {\n return \"contradicted\";\n }\n return status;\n}\n\nfunction cloneWith<T extends AnyRecord>(value: T, patch: AnyRecord): T {\n return { ...value, ...patch } as T;\n}\n\n/**\n * Resolve the canonical topic identifier.\n */\nexport function resolveTopicId(value: TopicScopedValue): string | undefined {\n return cleanString(value.topicId);\n}\n\n/**\n * Resolve the canonical text field from text-first or legacy canonicalText-first inputs.\n */\nexport function resolveText(value: TextScopedValue): string | undefined {\n return cleanString(value.text) ?? cleanString(value.canonicalText);\n}\n\n/**\n * Attach the topicId to a record.\n */\nexport function withTopicAlias<T extends AnyRecord>(value: T): T {\n const topicId = cleanString(value.topicId) ?? undefined;\n if (!topicId) {\n return value;\n }\n return cloneWith(value, { topicId });\n}\n\n/**\n * Attach the text/canonicalText alias pair to a record.\n */\nexport function withTextAlias<T extends AnyRecord>(value: T): T {\n const text =\n cleanString(value.text) ?? cleanString(value.canonicalText) ?? undefined;\n if (!text) {\n return value;\n }\n return cloneWith(value, { text, canonicalText: text });\n}\n\n/**\n * Attach topic and text aliases to SDK node-like records.\n */\nexport function withSdkAliases<T extends AnyRecord>(value: T): T {\n return withTopicAlias(withTextAlias(value));\n}\n\n/**\n * Normalize a belief/question/evidence write payload to the canonical gateway shape.\n */\nexport function normalizeNodeWriteInput<T extends JsonObject>(value: T): T {\n const topicId = resolveTopicId(value);\n const text = resolveText(value);\n const verificationStatus = normalizeVerificationStatus(value.verificationStatus);\n const next = { ...value } as JsonObject;\n\n if (topicId) {\n next.topicId = topicId;\n }\n if (text) {\n next.text = text;\n next.canonicalText = text;\n }\n if (verificationStatus) {\n next.verificationStatus = verificationStatus;\n }\n\n return next as T;\n}\n\nexport function normalizeNodeVerificationStatus(value: unknown) {\n return normalizeVerificationStatus(value);\n}\n\n/**\n * Build a topic-aware query object.\n */\nexport function normalizeTopicQuery<T extends JsonObject>(value: T): T {\n const topicId = cleanString(value.topicId);\n if (!topicId) {\n return value;\n }\n return { ...value, topicId } as T;\n}\n\n/**\n * Extract list items from array or list-envelope payloads.\n */\nexport function asListItems<T>(data: unknown, legacyKey?: string): T[] {\n if (Array.isArray(data)) {\n return data as T[];\n }\n\n const record = asRecord(data);\n if (Array.isArray(record.items)) {\n return record.items as T[];\n }\n if (legacyKey && Array.isArray(record[legacyKey])) {\n return record[legacyKey] as T[];\n }\n\n return [];\n}\n\n/**\n * Standardize list data to { items, total } while retaining an optional legacy array key.\n */\nexport function createListResult<T, LegacyKey extends string>(\n items: T[],\n legacyKey?: LegacyKey\n): ListResult<T, LegacyKey> {\n const result = {\n items,\n total: items.length,\n } as ListResult<T, LegacyKey>;\n\n if (legacyKey) {\n (result as Record<string, unknown>)[legacyKey] = items;\n }\n\n return result;\n}\n\n/**\n * Map a gateway success envelope's data while preserving the transport metadata.\n */\nexport function mapGatewayData<T, U>(\n response: PlatformGatewaySuccess<T>,\n mapper: (data: T) => U\n): PlatformGatewaySuccess<U> {\n return {\n ...response,\n data: mapper(response.data),\n };\n}\n\n/**\n * Apply SDK aliases across all items in a list-like payload.\n */\nexport function mapAliasedList<\n TItem extends AnyRecord,\n LegacyKey extends string,\n>(\n data: unknown,\n legacyKey?: LegacyKey\n): ListResult<TItem, LegacyKey> {\n const items = asListItems<TItem>(data, legacyKey).map((item) =>\n withSdkAliases(item)\n );\n return createListResult(items, legacyKey);\n}\n","import {\n createGatewayRequestClient,\n type GatewayClientConfig,\n LucernApiError,\n randomIdempotencyKey,\n toQueryString,\n} from \"./coreClient\";\nimport {\n mapAliasedList,\n mapGatewayData,\n normalizeNodeWriteInput,\n normalizeNodeVerificationStatus,\n normalizeTopicQuery,\n withSdkAliases,\n} from \"./sdkSurface\";\nimport type {\n CreateEdgeResponse,\n CreateNodeResponse,\n DeleteEdgeResponse,\n GraphAnalyticsMetric,\n GraphAnalyticsResponse,\n GraphNeighborhoodResponse,\n GraphPathResponse,\n JsonObject,\n ListResult,\n PlatformGraphEdge,\n PlatformGraphNode,\n QueryEdgesResponse,\n QueryNodesResponse,\n TextAliasInput,\n TopicIdentifierInput,\n UpdateNodeResponse,\n} from \"./types\";\n\nexport { LucernApiError };\nexport type { GatewayScope, PlatformGatewaySuccess } from \"./coreClient\";\nexport type {\n CreateEdgeResponse,\n CreateNodeResponse,\n DeleteEdgeResponse,\n GraphAnalyticsMetric,\n GraphAnalyticsResponse,\n GraphNeighborhoodResponse,\n GraphPathResponse,\n ListResult,\n QueryEdgesResponse,\n QueryNodesResponse,\n UpdateNodeResponse,\n} from \"./types\";\n\n/** Configuration for the graph client. */\nexport type GraphClientConfig = GatewayClientConfig;\n\n/** Filter parameters for listing graph nodes. */\nexport type ListNodesInput = {\n nodeId?: string;\n globalId?: string;\n topicId?: string;\n nodeType?: string;\n limit?: number;\n} & TopicIdentifierInput;\n\n/** Paginated list response containing graph nodes. */\nexport type ListNodesResponse = ListResult<PlatformGraphNode, \"nodes\">;\n\n/** @deprecated Use ListNodesInput. */\nexport type QueryNodesInput = ListNodesInput;\n\n/** Input for creating a new graph node. */\nexport type CreateNodeInput = {\n text?: string;\n /** @deprecated Use text. */\n canonicalText?: string;\n nodeType: string;\n topicId?: string;\n content?: string;\n contentHash?: string;\n globalId?: string;\n sourceType?: string;\n subtype?: string;\n title?: string;\n confidence?: number;\n status?: string;\n tags?: string[];\n metadata?: JsonObject;\n verificationStatus?: string;\n} & TextAliasInput &\n TopicIdentifierInput;\n\n/** Input for updating an existing graph node. */\nexport type UpdateNodeInput = {\n nodeId: string;\n text?: string;\n canonicalText?: string;\n content?: string;\n contentHash?: string;\n title?: string;\n subtype?: string;\n confidence?: number;\n status?: string;\n tags?: string[];\n metadata?: JsonObject;\n verificationStatus?: string;\n} & TextAliasInput;\n\n/** Input for retrieving a single graph node by canonical identifier. */\nexport type GetNodeInput = {\n nodeId?: string;\n globalId?: string;\n};\n\n/** Filter parameters for listing graph edges. */\nexport type ListEdgesInput = {\n edgeId?: string;\n topicId?: string;\n fromNodeId?: string;\n toNodeId?: string;\n edgeType?: string;\n limit?: number;\n} & TopicIdentifierInput;\n\n/** Paginated list response containing graph edges. */\nexport type ListEdgesResponse = ListResult<PlatformGraphEdge, \"edges\">;\n\n/** @deprecated Use ListEdgesInput. */\nexport type QueryEdgesInput = ListEdgesInput;\n\n/** Input for creating a typed edge between two graph nodes. */\nexport type CreateEdgeInput = {\n fromNodeId: string;\n toNodeId: string;\n edgeType: string;\n globalId?: string;\n topicId?: string;\n confidence?: number;\n weight?: number;\n context?: string;\n derivationType?: string;\n} & TopicIdentifierInput;\n\n/** Filter for selecting edges to delete. */\nexport type DeleteEdgeInput = {\n edgeId?: string;\n fromNodeId?: string;\n toNodeId?: string;\n edgeType?: string;\n};\n\n/** Input for batch-creating multiple graph nodes. */\nexport type BatchCreateNodesInput = {\n nodes: Array<CreateNodeInput>;\n};\n\n/** Input for superseding an existing graph node with a new version. */\nexport type SupersedeNodeInput = {\n oldNodeId?: string;\n nodeId?: string;\n newGlobalId?: string;\n newCanonicalText?: string;\n text?: string;\n canonicalText?: string;\n newContentHash?: string;\n reason?: string;\n};\n\n/** Input for updating a node's verification state. */\nexport type VerifyNodeInput = {\n nodeId?: string;\n id?: string;\n verificationStatus: string;\n confidence?: number;\n};\n\n/** Input for permanently deleting a node via admin-only API. */\nexport type HardDeleteNodeInput = {\n nodeId?: string;\n id?: string;\n reason: string;\n allowBeliefHardDelete?: boolean;\n};\n\n/** Input for retrieving the local neighborhood around a graph node. */\nexport type NeighborhoodInput = {\n globalId?: string;\n globalIds?: string;\n maxDepth?: number;\n};\n\n/** Input for finding the shortest path between two graph nodes. */\nexport type PathInput = {\n fromGlobalId: string;\n toGlobalId: string;\n maxDepth?: number;\n};\n\n/** Input for retrieving a specific graph analytics metric. */\nexport type AnalyticsInput = {\n metric?: GraphAnalyticsMetric;\n limit?: number;\n};\n\n/** Input for traversing the graph from a starting node. */\nexport type TraverseInput = {\n startNode: string;\n direction?: string;\n maxDepth?: number;\n topicId?: string;\n} & TopicIdentifierInput;\n\n/** Input for structural analysis of a topic graph. */\nexport type AnalyzeInput = {\n topicId?: string;\n metric?: GraphAnalyticsMetric;\n limit?: number;\n} & TopicIdentifierInput;\n\n/** Input for detecting confirmation-bias patterns in a topic graph. */\nexport type BiasInput = {\n topicId?: string;\n threshold?: number;\n limit?: number;\n} & TopicIdentifierInput;\n\n/** Input for finding beliefs without sufficient testing questions. */\nexport type GapsInput = {\n topicId?: string;\n minConfidence?: number;\n} & TopicIdentifierInput;\n\n/** Input for cross-resource search within a topic scope. */\nexport type SearchInput = {\n q?: string;\n query?: string;\n topicId?: string;\n types?: string[];\n status?: string;\n minConfidence?: number;\n limit?: number;\n cursor?: string;\n} & TopicIdentifierInput;\n\n/**\n * Create the low-level graph client for nodes, edges, and graph analytics.\n * @param config - Gateway transport configuration.\n * @returns An object with methods for CRUD on nodes/edges plus analytics, traversal, and search.\n */\nexport function createGraphClient(config: GraphClientConfig = {}) {\n const gateway = createGatewayRequestClient(config);\n\n return {\n /**\n * List graph nodes matching the provided filters.\n */\n async listNodes(query: ListNodesInput) {\n return gateway.request<ListNodesResponse>({\n path: `/api/platform/v1/graph/nodes${toQueryString(\n normalizeTopicQuery(query)\n )}`,\n }).then((response) =>\n mapGatewayData(response, (data) => mapAliasedList<PlatformGraphNode, \"nodes\">(data, \"nodes\"))\n );\n },\n\n /**\n * @deprecated Use listNodes.\n */\n async queryNodes(query: QueryNodesInput) {\n return this.listNodes(query);\n },\n\n /**\n * Retrieve a single graph node by nodeId or globalId.\n */\n async getNode(query: GetNodeInput) {\n return gateway.request<PlatformGraphNode>({\n path: `/api/platform/v1/graph/nodes${toQueryString(query)}`,\n }).then((response) =>\n mapGatewayData(response, (data) =>\n withSdkAliases(data as Record<string, unknown>) as PlatformGraphNode\n )\n );\n },\n\n /**\n * Create a graph node.\n */\n async createNode(input: CreateNodeInput, idempotencyKey?: string) {\n return gateway.request<CreateNodeResponse>({\n path: \"/api/platform/v1/graph/nodes\",\n method: \"POST\",\n body: normalizeNodeWriteInput(input),\n idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),\n }).then((response) =>\n mapGatewayData(response, (data) =>\n withSdkAliases(data as Record<string, unknown>) as CreateNodeResponse\n )\n );\n },\n\n /**\n * Update a graph node.\n */\n async updateNode(input: UpdateNodeInput, idempotencyKey?: string) {\n return gateway.request<UpdateNodeResponse>({\n path: \"/api/platform/v1/graph/nodes\",\n method: \"PUT\",\n body: normalizeNodeWriteInput(input as UpdateNodeInput & JsonObject),\n idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),\n }).then((response) =>\n mapGatewayData(response, (data) =>\n withSdkAliases(data as Record<string, unknown>) as UpdateNodeResponse\n )\n );\n },\n\n /**\n * Batch create graph nodes through the admin route surface.\n */\n async batchCreateNodes(\n input: BatchCreateNodesInput,\n idempotencyKey?: string\n ) {\n return gateway.request<Record<string, unknown>>({\n path: \"/api/platform/v1/graph/nodes/batch\",\n method: \"POST\",\n body: {\n nodes: input.nodes.map((node) => normalizeNodeWriteInput(node)),\n } as JsonObject,\n idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),\n });\n },\n\n /**\n * Supersede an existing graph node with a new canonical version.\n */\n async supersedeNode(input: SupersedeNodeInput, idempotencyKey?: string) {\n return gateway.request<Record<string, unknown>>({\n path: \"/api/platform/v1/graph/nodes/supersede\",\n method: \"POST\",\n body: input as JsonObject,\n idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),\n });\n },\n\n /**\n * Update a node's verification status.\n */\n async verifyNode(input: VerifyNodeInput, idempotencyKey?: string) {\n const verificationStatus =\n normalizeNodeVerificationStatus(input.verificationStatus) ??\n input.verificationStatus;\n return gateway.request<Record<string, unknown>>({\n path: \"/api/platform/v1/graph/nodes/verify\",\n method: \"POST\",\n body: {\n ...input,\n verificationStatus,\n } as JsonObject,\n idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),\n });\n },\n\n /**\n * Permanently delete a node via the admin-only hard-delete route.\n */\n async hardDeleteNode(input: HardDeleteNodeInput, idempotencyKey?: string) {\n return gateway.request<Record<string, unknown>>({\n path: \"/api/platform/v1/graph/nodes/hard-delete\",\n method: \"POST\",\n body: input as JsonObject,\n idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),\n });\n },\n\n /**\n * List graph edges matching the provided filters.\n */\n async listEdges(query: ListEdgesInput) {\n return gateway.request<ListEdgesResponse>({\n path: `/api/platform/v1/graph/edges${toQueryString(\n normalizeTopicQuery(query)\n )}`,\n }).then((response) =>\n mapGatewayData(response, (data) =>\n mapAliasedList<PlatformGraphEdge, \"edges\">(data, \"edges\")\n )\n );\n },\n\n /**\n * @deprecated Use listEdges.\n */\n async queryEdges(query: QueryEdgesInput) {\n return this.listEdges(query);\n },\n\n /**\n * Create a graph edge.\n */\n async createEdge(input: CreateEdgeInput, idempotencyKey?: string) {\n return gateway.request<CreateEdgeResponse>({\n path: \"/api/platform/v1/graph/edges\",\n method: \"POST\",\n body: normalizeTopicQuery(input as CreateEdgeInput & JsonObject),\n idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),\n });\n },\n\n /**\n * Delete one or more edges matching the provided filter.\n */\n async deleteEdge(query: DeleteEdgeInput, idempotencyKey?: string) {\n return gateway.request<DeleteEdgeResponse>({\n path: `/api/platform/v1/graph/edges${toQueryString(query)}`,\n method: \"DELETE\",\n idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),\n });\n },\n\n /**\n * Retrieve a graph neighborhood around a root node.\n */\n async neighborhood(query: NeighborhoodInput) {\n return gateway.request<GraphNeighborhoodResponse>({\n path: `/api/platform/v1/graph/neighborhood${toQueryString(query)}`,\n });\n },\n\n /**\n * Traverse the graph from a starting node.\n */\n async traverse(query: TraverseInput) {\n return gateway.request<Record<string, unknown>>({\n path: \"/api/platform/v1/graph/traverse\",\n method: \"POST\",\n body: normalizeTopicQuery(query as TraverseInput & JsonObject),\n });\n },\n\n /**\n * Analyze graph structure for a topic.\n */\n async analyze(query: AnalyzeInput = {}) {\n const normalized = normalizeTopicQuery(query as AnalyzeInput & JsonObject);\n return gateway.request<Record<string, unknown>>({\n path: `/api/platform/v1/graph/analyze${toQueryString({\n topicId:\n typeof normalized.topicId === \"string\" ? normalized.topicId : undefined,\n metric:\n typeof normalized.metric === \"string\" ? normalized.metric : undefined,\n limit:\n typeof normalized.limit === \"number\" ? normalized.limit : undefined,\n })}`,\n });\n },\n\n /**\n * Detect confirmation-bias patterns for a topic graph.\n */\n async bias(query: BiasInput = {}) {\n const normalized = normalizeTopicQuery(query as BiasInput & JsonObject);\n return gateway.request<Record<string, unknown>>({\n path: `/api/platform/v1/graph/bias${toQueryString({\n topicId:\n typeof normalized.topicId === \"string\" ? normalized.topicId : undefined,\n threshold:\n typeof normalized.threshold === \"number\"\n ? normalized.threshold\n : undefined,\n limit:\n typeof normalized.limit === \"number\" ? normalized.limit : undefined,\n })}`,\n });\n },\n\n /**\n * Find graph gaps for beliefs that still need testing.\n */\n async gaps(query: GapsInput) {\n const normalized = normalizeTopicQuery(query as GapsInput & JsonObject);\n return gateway.request<Record<string, unknown>>({\n path: `/api/platform/v1/graph/gaps${toQueryString({\n topicId:\n typeof normalized.topicId === \"string\" ? normalized.topicId : undefined,\n minConfidence:\n typeof normalized.minConfidence === \"number\"\n ? normalized.minConfidence\n : undefined,\n })}`,\n });\n },\n\n /**\n * Search across graph resources within a topic.\n */\n async search(query: SearchInput) {\n return gateway.request<Record<string, unknown>>({\n path: \"/api/platform/v1/search\",\n method: \"POST\",\n body: normalizeTopicQuery(query as SearchInput & JsonObject),\n });\n },\n\n /**\n * Retrieve a graph neighborhood around a root node.\n */\n async getNeighborhood(query: NeighborhoodInput) {\n return this.neighborhood(query);\n },\n\n /**\n * Retrieve the shortest known path between two graph nodes.\n */\n async getPath(query: PathInput) {\n return gateway.request<GraphPathResponse>({\n path: `/api/platform/v1/graph/path${toQueryString(query)}`,\n });\n },\n\n /**\n * Retrieve graph analytics for the requested metric.\n */\n async getAnalytics(query: AnalyticsInput = {}) {\n return gateway.request<GraphAnalyticsResponse>({\n path: `/api/platform/v1/graph/analytics${toQueryString(query)}`,\n });\n },\n };\n}\n"]}
@@ -1,9 +1,28 @@
1
- import { type GatewayClientConfig, type GatewayScope, LucernApiError } from "./coreClient";
2
- import type { JsonObject, JsonValue, TopicIdentifierInput } from "./types";
3
- export { LucernApiError };
4
- export type { GatewayScope, PlatformGatewaySuccess } from "./coreClient";
5
- export type HarnessClientConfig = GatewayClientConfig;
6
- export type HarnessAgentWriteInput = GatewayScope & {
1
+ import { GatewayClientConfig, GatewayScope, PlatformGatewaySuccess } from './coreClient.js';
2
+ export { LucernApiError } from './coreClient.js';
3
+ import { JsonObject, JsonValue, TopicIdentifierInput, ListResult } from './types.js';
4
+ import './contracts/workflow-runtime.contract.js';
5
+ import './contracts/lens-workflow.contract.js';
6
+ import './contracts/lens-filter.contract.js';
7
+
8
+ /** Configuration for the harness client. Inherits gateway transport settings. */
9
+ type HarnessClientConfig = GatewayClientConfig;
10
+ type HarnessAgentGuardrails = {
11
+ isolationMode?: "direct" | "sandbox";
12
+ maxExecutionMs?: number;
13
+ heartbeatIntervalMs?: number;
14
+ maxToolCalls?: number;
15
+ allowNetworkEgress?: boolean;
16
+ allowedOrigins?: string[];
17
+ };
18
+ type HarnessAgentRuntimeConfig = {
19
+ entryPoint?: string;
20
+ callbackUrl?: string;
21
+ modelRouting?: "model_machine" | "tenant_proxy" | "bring_your_own";
22
+ auditMode?: "harness" | "master_control";
23
+ };
24
+ /** Input for creating or updating an agent definition in the harness registry. */
25
+ type HarnessAgentWriteInput = GatewayScope & {
7
26
  agentDefinitionId?: string;
8
27
  agentKey: string;
9
28
  displayName: string;
@@ -13,14 +32,23 @@ export type HarnessAgentWriteInput = GatewayScope & {
13
32
  executionAdapter: "convex_mutation" | "convex_action" | "http_callback" | "mcp_tool" | "sdk_invocation" | "external_observed";
14
33
  scopeRequirements?: string[];
15
34
  promptReleaseChannel?: "dev" | "staging" | "prod";
35
+ promptName?: string;
36
+ systemPrompt?: string;
37
+ toolIds?: string[];
38
+ modelSlot?: string;
39
+ requiredModelCapabilities?: string[];
16
40
  parameterSchema?: JsonObject;
41
+ outputSchema?: JsonObject;
42
+ guardrails?: HarnessAgentGuardrails;
43
+ runtimeConfig?: HarnessAgentRuntimeConfig;
17
44
  exampleInvocations?: Array<{
18
45
  input: JsonObject;
19
46
  expectedOutput?: JsonValue;
20
47
  }>;
21
48
  metadata?: JsonObject;
22
49
  };
23
- export type HarnessToolWriteInput = GatewayScope & {
50
+ /** Input for creating or updating a tool definition in the harness registry. */
51
+ type HarnessToolWriteInput = GatewayScope & {
24
52
  toolId?: string;
25
53
  toolName: string;
26
54
  description: string;
@@ -48,20 +76,73 @@ export type HarnessToolWriteInput = GatewayScope & {
48
76
  }>;
49
77
  metadata?: JsonObject;
50
78
  };
51
- export type HarnessStartRunInput = GatewayScope & {
79
+ type HarnessExecuteToolInput = GatewayScope & {
80
+ input?: JsonObject;
81
+ version?: string;
82
+ transportKind?: string;
83
+ };
84
+ type HarnessExecuteToolResult = {
85
+ tool: {
86
+ toolId: string;
87
+ toolName: string;
88
+ version: string;
89
+ status: "active" | "deprecated" | "disabled";
90
+ executionAdapter: "convex_mutation" | "convex_action" | "http_callback" | "mcp_tool" | "sdk_invocation" | "external_observed";
91
+ gateClassification: "core" | "shimmed";
92
+ scopeRequirements: string[];
93
+ safetyMetadata: {
94
+ readOnly: boolean;
95
+ idempotent: boolean;
96
+ sideEffectLevel: "none" | "low" | "high";
97
+ };
98
+ };
99
+ execution: {
100
+ input: JsonObject;
101
+ transportKind: string;
102
+ startedAt: number;
103
+ completedAt: number;
104
+ durationMs: number;
105
+ };
106
+ envelope: JsonObject | null;
107
+ audit: {
108
+ toolName: string;
109
+ contractName: string;
110
+ transportKind: string;
111
+ authMode: string;
112
+ requiredScopes: string[];
113
+ source: "gateway_envelope";
114
+ isError: boolean;
115
+ code?: string;
116
+ status?: number;
117
+ correlationId?: string | null;
118
+ policyTraceId?: string | null;
119
+ invariant?: string | null;
120
+ } | null;
121
+ output: {
122
+ isError: boolean;
123
+ parsed: JsonValue;
124
+ raw: JsonValue;
125
+ };
126
+ };
127
+ /** Input for starting a new harness run (agent execution session). */
128
+ type HarnessStartRunInput = GatewayScope & {
52
129
  agentDefinitionId: string;
53
130
  agentVersion: string;
54
131
  executionAdapter: "convex_mutation" | "convex_action" | "http_callback" | "mcp_tool" | "sdk_invocation" | "external_observed";
55
132
  promptReleaseChannel?: "dev" | "staging" | "prod";
56
133
  chatId?: string;
57
- sprintId?: string;
134
+ worktreeId?: string;
58
135
  topicId?: string;
59
- /** @deprecated Use topicId. */
60
- projectId?: string;
61
136
  langfuseTraceId?: string;
62
137
  metadata?: JsonObject;
63
138
  } & TopicIdentifierInput;
64
- export type HarnessRunReportInput = {
139
+ type HarnessInvokeManagedAgentInput = GatewayScope & {
140
+ agentDefinitionId: string;
141
+ input?: JsonObject;
142
+ metadata?: JsonObject;
143
+ };
144
+ /** Input for reporting a ledger event (tool call, prompt resolution, or policy decision) within a run. */
145
+ type HarnessRunReportInput = {
65
146
  reportingToken: string;
66
147
  type: "tool_call" | "prompt_resolution" | "policy_decision";
67
148
  metadata?: JsonObject;
@@ -91,7 +172,8 @@ export type HarnessRunReportInput = {
91
172
  details?: JsonValue;
92
173
  };
93
174
  };
94
- export type HarnessCompleteRunInput = {
175
+ /** Input for completing a harness run with a terminal status. */
176
+ type HarnessCompleteRunInput = {
95
177
  reportingToken: string;
96
178
  status: "completed" | "failed" | "timeout";
97
179
  error?: {
@@ -103,7 +185,7 @@ export type HarnessCompleteRunInput = {
103
185
  /**
104
186
  * Create the harness client for agent and tool registry operations.
105
187
  */
106
- export declare function createHarnessClient(config?: HarnessClientConfig): {
188
+ declare function createHarnessClient(config?: HarnessClientConfig): {
107
189
  /**
108
190
  * List agent definitions.
109
191
  */
@@ -111,23 +193,27 @@ export declare function createHarnessClient(config?: HarnessClientConfig): {
111
193
  status?: string;
112
194
  limit?: number;
113
195
  cursor?: string;
114
- }): Promise<import("./coreClient").PlatformGatewaySuccess<import("./types").ListResult<any, "agents">>>;
196
+ }): Promise<PlatformGatewaySuccess<ListResult<any, "agents">>>;
115
197
  /**
116
198
  * Get an agent definition.
117
199
  */
118
- getAgentDefinition(agentId: string, scope?: GatewayScope): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
200
+ getAgentDefinition(agentId: string, scope?: GatewayScope): Promise<PlatformGatewaySuccess<unknown>>;
119
201
  /**
120
202
  * Create an agent definition.
121
203
  */
122
- createAgentDefinition(input: HarnessAgentWriteInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
204
+ createAgentDefinition(input: HarnessAgentWriteInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
123
205
  /**
124
206
  * @deprecated Use createAgentDefinition.
125
207
  */
126
- registerAgentDefinition(input: HarnessAgentWriteInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
208
+ registerAgentDefinition(input: HarnessAgentWriteInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
127
209
  /**
128
210
  * Update an agent definition.
129
211
  */
130
- updateAgentDefinition(agentId: string, input: HarnessAgentWriteInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
212
+ updateAgentDefinition(agentId: string, input: HarnessAgentWriteInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
213
+ /**
214
+ * Invoke a managed agent definition.
215
+ */
216
+ invokeManagedAgentDefinition(agentId: string, input: Omit<HarnessInvokeManagedAgentInput, "agentDefinitionId">, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
131
217
  /**
132
218
  * List runs for an agent definition.
133
219
  */
@@ -135,7 +221,7 @@ export declare function createHarnessClient(config?: HarnessClientConfig): {
135
221
  status?: string;
136
222
  limit?: number;
137
223
  cursor?: string;
138
- }): Promise<import("./coreClient").PlatformGatewaySuccess<import("./types").ListResult<any, "runs">>>;
224
+ }): Promise<PlatformGatewaySuccess<ListResult<any, "runs">>>;
139
225
  /**
140
226
  * @deprecated Use listAgentRuns.
141
227
  */
@@ -143,7 +229,7 @@ export declare function createHarnessClient(config?: HarnessClientConfig): {
143
229
  status?: string;
144
230
  limit?: number;
145
231
  cursor?: string;
146
- }): Promise<import("./coreClient").PlatformGatewaySuccess<import("./types").ListResult<any, "runs">>>;
232
+ }): Promise<PlatformGatewaySuccess<ListResult<any, "runs">>>;
147
233
  /**
148
234
  * List tool definitions.
149
235
  */
@@ -152,23 +238,27 @@ export declare function createHarnessClient(config?: HarnessClientConfig): {
152
238
  limit?: number;
153
239
  cursor?: string;
154
240
  gateClassification?: string;
155
- }): Promise<import("./coreClient").PlatformGatewaySuccess<import("./types").ListResult<any, "tools">>>;
241
+ }): Promise<PlatformGatewaySuccess<ListResult<any, "tools">>>;
156
242
  /**
157
243
  * Get a tool definition.
158
244
  */
159
- getToolDefinition(toolId: string, scope?: GatewayScope): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
245
+ getToolDefinition(toolId: string, scope?: GatewayScope): Promise<PlatformGatewaySuccess<unknown>>;
160
246
  /**
161
247
  * Create a tool definition.
162
248
  */
163
- createToolDefinition(input: HarnessToolWriteInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
249
+ createToolDefinition(input: HarnessToolWriteInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
164
250
  /**
165
251
  * @deprecated Use createToolDefinition.
166
252
  */
167
- registerToolDefinition(input: HarnessToolWriteInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
253
+ registerToolDefinition(input: HarnessToolWriteInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
168
254
  /**
169
255
  * Update a tool definition.
170
256
  */
171
- updateToolDefinition(toolId: string, input: HarnessToolWriteInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
257
+ updateToolDefinition(toolId: string, input: HarnessToolWriteInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
258
+ /**
259
+ * Execute a tool definition.
260
+ */
261
+ executeToolDefinition(toolId: string, input?: HarnessExecuteToolInput): Promise<PlatformGatewaySuccess<HarnessExecuteToolResult>>;
172
262
  /**
173
263
  * List run ledger entries.
174
264
  */
@@ -176,7 +266,7 @@ export declare function createHarnessClient(config?: HarnessClientConfig): {
176
266
  status?: string;
177
267
  limit?: number;
178
268
  cursor?: string;
179
- }): Promise<import("./coreClient").PlatformGatewaySuccess<import("./types").ListResult<any, "runs">>>;
269
+ }): Promise<PlatformGatewaySuccess<ListResult<any, "runs">>>;
180
270
  /**
181
271
  * @deprecated Use listRunEntries.
182
272
  */
@@ -184,29 +274,29 @@ export declare function createHarnessClient(config?: HarnessClientConfig): {
184
274
  status?: string;
185
275
  limit?: number;
186
276
  cursor?: string;
187
- }): Promise<import("./coreClient").PlatformGatewaySuccess<import("./types").ListResult<any, "runs">>>;
277
+ }): Promise<PlatformGatewaySuccess<ListResult<any, "runs">>>;
188
278
  /**
189
279
  * Create a harness run.
190
280
  */
191
- startHarnessRun(input: HarnessStartRunInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
281
+ startHarnessRun(input: HarnessStartRunInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
192
282
  /**
193
283
  * Get a run ledger entry.
194
284
  */
195
- getRunLedgerEntry(runId: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
285
+ getRunLedgerEntry(runId: string): Promise<PlatformGatewaySuccess<unknown>>;
196
286
  /**
197
287
  * Update a harness run with a ledger event.
198
288
  */
199
- reportHarnessRunEvent(runId: string, input: HarnessRunReportInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
289
+ reportHarnessRunEvent(runId: string, input: HarnessRunReportInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
200
290
  /**
201
291
  * Update a harness run heartbeat.
202
292
  */
203
293
  heartbeatHarnessRun(runId: string, input: {
204
294
  reportingToken: string;
205
- }, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
295
+ }, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
206
296
  /**
207
297
  * Complete a harness run.
208
298
  */
209
- completeHarnessRun(runId: string, input: HarnessCompleteRunInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
299
+ completeHarnessRun(runId: string, input: HarnessCompleteRunInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
210
300
  /**
211
301
  * List prompt resolutions.
212
302
  */
@@ -214,9 +304,11 @@ export declare function createHarnessClient(config?: HarnessClientConfig): {
214
304
  runId?: string;
215
305
  promptName?: string;
216
306
  limit?: number;
217
- }): Promise<import("./coreClient").PlatformGatewaySuccess<import("./types").ListResult<any, "prompts">>>;
307
+ }): Promise<PlatformGatewaySuccess<ListResult<any, "prompts">>>;
218
308
  /**
219
309
  * Get the harness scope taxonomy.
220
310
  */
221
- getScopeTaxonomy(): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
311
+ getScopeTaxonomy(): Promise<PlatformGatewaySuccess<unknown>>;
222
312
  };
313
+
314
+ export { GatewayScope, type HarnessAgentGuardrails, type HarnessAgentRuntimeConfig, type HarnessAgentWriteInput, type HarnessClientConfig, type HarnessCompleteRunInput, type HarnessExecuteToolInput, type HarnessExecuteToolResult, type HarnessInvokeManagedAgentInput, type HarnessRunReportInput, type HarnessStartRunInput, type HarnessToolWriteInput, PlatformGatewaySuccess, createHarnessClient };