@superbased/sdk 0.0.0-stage → 0.1.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.
Files changed (119) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +4 -0
  3. package/README.md +438 -2
  4. package/dist/cjs/admit.d.ts +139 -0
  5. package/dist/cjs/admit.js +442 -0
  6. package/dist/cjs/admit.js.map +1 -0
  7. package/dist/cjs/attrs.d.ts +113 -0
  8. package/dist/cjs/attrs.js +183 -0
  9. package/dist/cjs/attrs.js.map +1 -0
  10. package/dist/cjs/config.d.ts +202 -0
  11. package/dist/cjs/config.js +386 -0
  12. package/dist/cjs/config.js.map +1 -0
  13. package/dist/cjs/context.d.ts +102 -0
  14. package/dist/cjs/context.js +234 -0
  15. package/dist/cjs/context.js.map +1 -0
  16. package/dist/cjs/control.d.ts +99 -0
  17. package/dist/cjs/control.js +243 -0
  18. package/dist/cjs/control.js.map +1 -0
  19. package/dist/cjs/cost.d.ts +108 -0
  20. package/dist/cjs/cost.js +211 -0
  21. package/dist/cjs/cost.js.map +1 -0
  22. package/dist/cjs/destination.d.ts +125 -0
  23. package/dist/cjs/destination.js +357 -0
  24. package/dist/cjs/destination.js.map +1 -0
  25. package/dist/cjs/experiments.d.ts +237 -0
  26. package/dist/cjs/experiments.js +678 -0
  27. package/dist/cjs/experiments.js.map +1 -0
  28. package/dist/cjs/export.d.ts +84 -0
  29. package/dist/cjs/export.js +328 -0
  30. package/dist/cjs/export.js.map +1 -0
  31. package/dist/cjs/index.d.ts +168 -0
  32. package/dist/cjs/index.js +581 -0
  33. package/dist/cjs/index.js.map +1 -0
  34. package/dist/cjs/instrument.d.ts +88 -0
  35. package/dist/cjs/instrument.js +397 -0
  36. package/dist/cjs/instrument.js.map +1 -0
  37. package/dist/cjs/package.json +1 -0
  38. package/dist/cjs/policy.d.ts +77 -0
  39. package/dist/cjs/policy.js +252 -0
  40. package/dist/cjs/policy.js.map +1 -0
  41. package/dist/cjs/prompts.d.ts +175 -0
  42. package/dist/cjs/prompts.js +476 -0
  43. package/dist/cjs/prompts.js.map +1 -0
  44. package/dist/cjs/propagation.d.ts +34 -0
  45. package/dist/cjs/propagation.js +151 -0
  46. package/dist/cjs/propagation.js.map +1 -0
  47. package/dist/cjs/req.d.ts +10 -0
  48. package/dist/cjs/req.js +3 -0
  49. package/dist/cjs/req.js.map +1 -0
  50. package/dist/cjs/runtime.d.ts +44 -0
  51. package/dist/cjs/runtime.js +67 -0
  52. package/dist/cjs/runtime.js.map +1 -0
  53. package/dist/cjs/scores.d.ts +102 -0
  54. package/dist/cjs/scores.js +226 -0
  55. package/dist/cjs/scores.js.map +1 -0
  56. package/dist/cjs/spans.d.ts +193 -0
  57. package/dist/cjs/spans.js +398 -0
  58. package/dist/cjs/spans.js.map +1 -0
  59. package/dist/cjs/vendor.d.ts +33 -0
  60. package/dist/cjs/vendor.js +67 -0
  61. package/dist/cjs/vendor.js.map +1 -0
  62. package/dist/esm/admit.d.ts +139 -0
  63. package/dist/esm/admit.js +432 -0
  64. package/dist/esm/admit.js.map +1 -0
  65. package/dist/esm/attrs.d.ts +113 -0
  66. package/dist/esm/attrs.js +179 -0
  67. package/dist/esm/attrs.js.map +1 -0
  68. package/dist/esm/config.d.ts +202 -0
  69. package/dist/esm/config.js +364 -0
  70. package/dist/esm/config.js.map +1 -0
  71. package/dist/esm/context.d.ts +102 -0
  72. package/dist/esm/context.js +221 -0
  73. package/dist/esm/context.js.map +1 -0
  74. package/dist/esm/control.d.ts +99 -0
  75. package/dist/esm/control.js +230 -0
  76. package/dist/esm/control.js.map +1 -0
  77. package/dist/esm/cost.d.ts +108 -0
  78. package/dist/esm/cost.js +202 -0
  79. package/dist/esm/cost.js.map +1 -0
  80. package/dist/esm/destination.d.ts +125 -0
  81. package/dist/esm/destination.js +346 -0
  82. package/dist/esm/destination.js.map +1 -0
  83. package/dist/esm/experiments.d.ts +237 -0
  84. package/dist/esm/experiments.js +666 -0
  85. package/dist/esm/experiments.js.map +1 -0
  86. package/dist/esm/export.d.ts +84 -0
  87. package/dist/esm/export.js +314 -0
  88. package/dist/esm/export.js.map +1 -0
  89. package/dist/esm/index.d.ts +168 -0
  90. package/dist/esm/index.js +500 -0
  91. package/dist/esm/index.js.map +1 -0
  92. package/dist/esm/instrument.d.ts +88 -0
  93. package/dist/esm/instrument.js +391 -0
  94. package/dist/esm/instrument.js.map +1 -0
  95. package/dist/esm/policy.d.ts +77 -0
  96. package/dist/esm/policy.js +240 -0
  97. package/dist/esm/policy.js.map +1 -0
  98. package/dist/esm/prompts.d.ts +175 -0
  99. package/dist/esm/prompts.js +460 -0
  100. package/dist/esm/prompts.js.map +1 -0
  101. package/dist/esm/propagation.d.ts +34 -0
  102. package/dist/esm/propagation.js +145 -0
  103. package/dist/esm/propagation.js.map +1 -0
  104. package/dist/esm/req.d.ts +10 -0
  105. package/dist/esm/req.js +2 -0
  106. package/dist/esm/req.js.map +1 -0
  107. package/dist/esm/runtime.d.ts +44 -0
  108. package/dist/esm/runtime.js +59 -0
  109. package/dist/esm/runtime.js.map +1 -0
  110. package/dist/esm/scores.d.ts +102 -0
  111. package/dist/esm/scores.js +219 -0
  112. package/dist/esm/scores.js.map +1 -0
  113. package/dist/esm/spans.d.ts +193 -0
  114. package/dist/esm/spans.js +378 -0
  115. package/dist/esm/spans.js.map +1 -0
  116. package/dist/esm/vendor.d.ts +33 -0
  117. package/dist/esm/vendor.js +61 -0
  118. package/dist/esm/vendor.js.map +1 -0
  119. package/package.json +130 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admit.js","sourceRoot":"","sources":["../../src/admit.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AA6IH,kCAMC;AAcD,0CAKC;AAkCD,0DAEC;AAGD,kDAEC;AA4BD,oCAoBC;AA0FD,kCAIC;AAcD,sBAgDC;AAzZD,4CAA2C;AAE3C,2CAAkF;AAClF,6CAAoD;AACpD,qDAAiD;AACjD,6CAAyD;AAEzD,2FA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,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC;YAClF,OAAO,IAAI,CACT,gBAAQ,CAAC,YAAY,EACrB,IAAI,CAAC,MAAM,EACX,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,sDAAsD,CAAC,CAAC,CAAC,oBAAoB,IAAI,iBAAiB,CACvH,CAAC;QACJ,CAAC;QACD,MAAM,MAAM,GAAG,IAA+B,CAAC;QAC/C,eAAe,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,sBAAc,CAAC,CAAC,CAAC;QACrE,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,OAAO,CAAC,CAAC;IACX,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,IAAI,CAAC,gBAAQ,CAAC,YAAY,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IACrD,CAAC;YAAS,CAAC;QACT,IAAI,KAAK;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;AACH,CAAC","sourcesContent":["/**\n * `admit()`: the input-admission pre-flight check (admission spec §6.1).\n *\n * Never throws or rejects. Any failure (transport, timeout, HTTP error, a body\n * that is not a JSON object, a field of the wrong type) yields a degraded\n * verdict that admits (fail open, the default) or denies (`failClosed`).\n */\n\nimport { trace } from \"@opentelemetry/api\";\n\nimport { envFlag, onlineUsable, resolveServiceName, type Env } from \"./config.js\";\nimport { getCurrentAttributes } from \"./context.js\";\nimport { isLoopbackUrl } from \"./destination.js\";\nimport { destinationKnown, runtime } from \"./runtime.js\";\n\n/** Default admission-check endpoint: this machine's Observer API on the dashboard port. */\nexport const DEFAULT_ADMISSION_ENDPOINT = \"http://127.0.0.1:8081/api/obs/admission/check\";\n/** The path of a machine's admission check. */\nconst MACHINE_ADMISSION_PATH = \"/api/obs/admission/check\";\n/** Path of the org SDK control API's admission endpoint, under an org URL. */\nexport const SDK_ADMIT_PATH = \"/v1/sdk/admit\";\n/**\n * Default client timeout (ms). Longer than the server's 10 s judge budget, so\n * the client does not fail open on a request the server would still decide.\n * A server that advertises a recommended timeout (the\n * `recommended_client_timeout_ms` body field or the\n * `X-SBO-Recommended-Timeout-Ms` header, sent by both the org SDK control API\n * and the local machine) overrides it for later calls.\n */\nexport const DEFAULT_ADMIT_TIMEOUT_MS = 12_000;\n\n/**\n * The advertised-timeout names, canonical first. The second of each pair is\n * the pre-release spelling, still read so an older server keeps working.\n */\nexport const TIMEOUT_HEADERS = [\"x-sbo-recommended-timeout-ms\", \"x-superbased-admit-timeout-ms\"] as const;\nexport const TIMEOUT_FIELDS = [\"recommended_client_timeout_ms\", \"recommended_timeout_ms\"] as const;\n\n/** Client-side degraded reasons (`Verdict.degraded`). Server values pass through. */\nexport const Degraded = {\n /** HTTP 403/404: admission is off on the server or not permitted. */\n UNAVAILABLE: \"admission-unavailable\",\n TIMEOUT: \"client-timeout\",\n TRANSPORT: \"client-transport\",\n HTTP_ERROR: \"client-http-error\",\n BAD_RESPONSE: \"client-bad-response\",\n /**\n * The organization answered mode `off`: it has no admission policy, so it\n * made no decision (live finding L-05, ruling D29). Under destination `both`\n * the SDK then asks this machine; otherwise the verdict is degraded.\n */\n ADMISSION_OFF: \"admission-off\",\n} as const;\n\n/** The result of an {@link admit} check. */\nexport interface Verdict {\n /**\n * What the app should honour. In `observe` mode the server always returns\n * `true` and records the shadow verdict; in `enforce` mode it returns the\n * real decision (`ask`/`deny` → `false`, `flag` still admits).\n */\n allowed: boolean;\n /** The raw decision, one of: allow / flag / ask / deny. */\n decision: string;\n severity: string;\n /** The criterion id that fired, if any. */\n criterion: string;\n /** A short string to surface to the user on a block. */\n reason: string;\n mode: string;\n /** What enforce mode WOULD decide, so you can measure before flipping. */\n enforceDecision: string;\n /** Empty for a clean decision; otherwise why it is not one (see {@link Degraded}). */\n degraded: string;\n /** Whether the server consulted its LLM judge (server field `judge_used`). */\n judgeUsed: boolean;\n /** Server-side decision latency; for a client-degraded verdict, the client's elapsed time (`latency_ms`). */\n latencyMs: number;\n /** The server's id for the recorded verdict, when it returns one. */\n verdictId: string;\n /** HTTP status of the response (0 when none arrived). */\n httpStatus: number;\n /** Detail for a client-degraded verdict. */\n error: string;\n}\n\nexport interface AdmitOptions {\n /** The app's tenant. Defaults to the request scope's (`propagateAttributes`), then `init`'s. */\n tenant?: string;\n /** The app's end user. Defaults to the request scope's, then `init`'s. */\n user?: string;\n /** The app's session. Defaults to the request scope's `sessionId`, then `init`'s. */\n session?: string;\n /** Defaults to the active span's trace id. */\n traceId?: string;\n requestId?: string;\n /** Full admission URL. Defaults to $SUPERBASED_ADMISSION_ENDPOINT, then the destination (see resolveTarget), then this machine. */\n endpoint?: string;\n /** Org base URL; the check goes to `<orgUrl>/v1/sdk/admit`. Env: SUPERBASED_ORG_URL. */\n orgUrl?: string;\n /**\n * SDK credential, sent as `Authorization: Bearer`. Env: SUPERBASED_API_KEY.\n * Only an explicit `apiKey` goes to a loopback endpoint; the configured key\n * rides only to an org URL or an explicit remote endpoint.\n */\n apiKey?: string;\n /** Extra or overriding request headers. */\n headers?: Record<string, string>;\n /** Per-call timeout in ms. Default: the server-advertised timeout, else 12000. */\n timeoutMs?: number;\n /** Deny when no decision could be obtained. Env: SUPERBASED_ADMISSION_FAIL_CLOSED. Default false. */\n failClosed?: boolean;\n}\n\nconst advertised = new Map<string, number>();\n\n// --- saying so when admit() could not decide (review E-39) -------------------\n//\n// admit() fails open (the contract), but never silently: every degraded\n// verdict is counted for diagnostics(), and one console.warn per cause per\n// minute names the cause and the fix. Python does the same (logging).\n\n/** How often (ms) admit() may warn about the same cause. */\nexport const DEGRADED_LOG_INTERVAL_MS = 60_000;\n\n/** [cause, lowest status, highest status, what to fix, where]: the first matching row wins; 0..999 matches any status; where is \"machine\" (the check went to a machine's admission path) or \"\" for any address. Python has the same table. */\nconst FIXES: ReadonlyArray<[string, number, number, string, string]> = [\n [\n Degraded.UNAVAILABLE,\n 404,\n 404,\n \"this machine has no admission check: update Observer (a current machine answers allow while no admission policy is set), or turn admission on\",\n \"machine\",\n ],\n [Degraded.HTTP_ERROR, 300, 399, \"the address redirects, and admit() never follows a redirect (the key must not move hosts): use the final URL\", \"\"],\n [Degraded.HTTP_ERROR, 401, 401, \"the SDK key was refused: check apiKey / SUPERBASED_API_KEY, or sign in again\", \"\"],\n [Degraded.UNAVAILABLE, 403, 403, \"the key may not run admission checks, or admission is off for this app\", \"\"],\n [Degraded.UNAVAILABLE, 404, 404, \"no admission check at this address: point orgUrl / SUPERBASED_ORG_URL at the AI Apps gateway (not the dashboard), or turn admission on\", \"\"],\n [Degraded.HTTP_ERROR, 429, 429, \"the server is rate limiting admission checks\", \"\"],\n [Degraded.HTTP_ERROR, 0, 999, \"the admission server answered with an error\", \"\"],\n [Degraded.TIMEOUT, 0, 999, \"no answer within the timeout: raise timeoutMs, or check the server\", \"\"],\n [Degraded.TRANSPORT, 0, 999, \"nothing answered at this address: check the URL and that Observer is running\", \"\"],\n [Degraded.BAD_RESPONSE, 0, 999, \"the address did not answer like an admission check: check the URL\", \"\"],\n [Degraded.ADMISSION_OFF, 0, 999, \"your organization has no admission policy for AI Apps (mode off): ask an admin to turn admission on, or use destination both so this machine's policy applies\", \"\"],\n];\n\n/** What to fix for a degraded verdict (\"\" for a server-side reason). */\nexport function degradedFix(cause: string, status: number, url = \"\"): string {\n const machine = isMachineAdmission(url);\n for (const [c, lo, hi, fix, at] of FIXES) {\n if (c === cause && status >= lo && status <= hi && (!at || (at === \"machine\") === machine)) return fix;\n }\n return \"\";\n}\n\n/** Whether url is a machine's admission check (its path). */\nfunction isMachineAdmission(url: string): boolean {\n try {\n return new URL(url).pathname.replace(/\\/+$/, \"\").endsWith(MACHINE_ADMISSION_PATH);\n } catch {\n return false;\n }\n}\n\n/** Process-wide admit() counters, read by diagnostics(). */\nexport const admitStats = { degraded: 0, lastError: \"\", lastErrorAt: 0, loggedAt: new Map<string, number>() };\n\nexport function resetAdmitStats(): void {\n admitStats.degraded = 0;\n admitStats.lastError = \"\";\n admitStats.lastErrorAt = 0;\n admitStats.loggedAt.clear();\n}\n\n/** scheme://host[:port]/path of a URL: no user info, no query. */\nfunction where(url: string): string {\n try {\n const u = new URL(url);\n return `${u.protocol}//${u.host}${u.pathname}`;\n } catch {\n return \"the admission address\";\n }\n}\n\nfunction noteDegraded(v: Verdict, url: string): void {\n try {\n const detail = v.httpStatus ? `HTTP ${v.httpStatus}` : v.error || v.degraded;\n const fix = degradedFix(v.degraded, v.httpStatus, url);\n const outcome = v.allowed ? \"admitted (fail open)\" : \"denied (failClosed)\";\n const msg =\n `admit() got no decision${url ? ` from ${where(url)}` : \"\"} (${v.degraded}: ${detail}); the message was ${outcome}` +\n (fix ? `. Fix: ${fix}` : \"\");\n const now = Date.now();\n admitStats.degraded += 1;\n admitStats.lastError = msg.slice(0, 500);\n admitStats.lastErrorAt = now;\n const key = `${v.degraded}:${v.httpStatus}`;\n if (!runtime.settings?.debug && now - (admitStats.loggedAt.get(key) ?? -Infinity) < DEGRADED_LOG_INTERVAL_MS) return;\n admitStats.loggedAt.set(key, now);\n console.warn(`@superbased/sdk: ${msg}`);\n } catch {\n // reporting never breaks admit()\n }\n}\n\n/** Forget server-advertised timeouts (tests). */\nexport function resetAdvertisedTimeouts(): void {\n advertised.clear();\n}\n\n/** The server-advertised timeout remembered for url, in ms (tests). */\nexport function advertisedTimeoutMs(url: string): number | undefined {\n return advertised.get(url);\n}\n\n/** The first of names whose get(name) is neither null nor undefined. */\nfunction firstPresent(get: (name: string) => unknown, names: readonly string[]): unknown {\n for (const n of names) {\n const v = get(n);\n if (v !== null && v !== undefined) return v;\n }\n return undefined;\n}\n\nfunction str(d: Record<string, unknown>, k: string): string {\n const v = d[k];\n return typeof v === \"string\" ? v : \"\";\n}\n\nfunction num(d: Record<string, unknown>, k: string): number {\n const v = d[k];\n return typeof v === \"number\" && Number.isFinite(v) ? Math.trunc(v) : 0;\n}\n\nfunction rememberTimeout(url: string, raw: unknown): void {\n if (raw == null || typeof raw === \"boolean\") return;\n const ms = Number(raw);\n if (Number.isFinite(ms) && ms >= 100 && ms <= 120_000) advertised.set(url, ms);\n}\n\n/** Normalize a parsed response body into a Verdict; null when it is not one. */\nexport function parseVerdict(body: unknown): Verdict | null {\n if (body === null || typeof body !== \"object\" || Array.isArray(body)) return null;\n const d = body as Record<string, unknown>;\n if (typeof d.allowed !== \"boolean\") return null;\n const vid = d.verdict_id ?? d.id;\n return {\n allowed: d.allowed,\n decision: str(d, \"decision\") || (d.allowed ? \"allow\" : \"deny\"),\n severity: str(d, \"severity\"),\n criterion: str(d, \"criterion\"),\n reason: str(d, \"reason\"),\n mode: str(d, \"mode\"),\n enforceDecision: str(d, \"enforce_decision\"),\n degraded: str(d, \"degraded\"),\n judgeUsed: d.judge_used === true,\n latencyMs: num(d, \"latency_ms\"),\n verdictId: typeof vid === \"string\" || (typeof vid === \"number\" && Number.isFinite(vid)) ? String(vid) : \"\",\n httpStatus: 0,\n error: \"\",\n };\n}\n\n/**\n * Where the check goes and whether the SDK key rides with it (contract\n * destination.md section 8): an explicit `endpoint` / `orgUrl` wins, then\n * SUPERBASED_ADMISSION_ENDPOINT; after init, the destination decides (`local`\n * the machine, `online` / `both` with a usable gateway the org, degraded the\n * machine); before init, SUPERBASED_ORG_URL, else the machine. The configured\n * key is sent to the org, or to a remote endpoint you named, never to a\n * loopback address (only an explicit `apiKey` goes there).\n */\nfunction resolveTarget(opts: AdmitOptions, env: Env): Target {\n if (opts.endpoint) return { url: opts.endpoint, sendKey: !isLoopbackUrl(opts.endpoint), org: \"\" };\n if (opts.orgUrl) return { url: opts.orgUrl.replace(/\\/+$/, \"\") + SDK_ADMIT_PATH, sendKey: true, org: \"named\" };\n const ep = (env.SUPERBASED_ADMISSION_ENDPOINT ?? \"\").trim();\n if (ep) return { url: ep, sendKey: !isLoopbackUrl(ep), org: \"\" };\n const s = runtime.settings;\n const machine = machineAdmissionUrl();\n if (s && runtime.destinationSource) {\n if ((runtime.destination === \"online\" || runtime.destination === \"both\") && s.orgUrl && onlineUsable(s)) {\n return { url: s.orgUrl + SDK_ADMIT_PATH, sendKey: true, org: \"plan\" };\n }\n if (runtime.destination) return { url: machine, sendKey: false, org: \"\" };\n }\n const org = (env.SUPERBASED_ORG_URL ?? \"\").trim();\n if (org) return { url: org.replace(/\\/+$/, \"\") + SDK_ADMIT_PATH, sendKey: true, org: \"named\" };\n return { url: machine, sendKey: false, org: \"\" };\n}\n\n/** Where the check goes; `org` says whether it is the org init's destination chose (plan) or one the caller named. */\ninterface Target {\n url: string;\n sendKey: boolean;\n org: \"\" | \"plan\" | \"named\";\n}\n\n/** This machine's admission check: the one discovery advertised (loopback only), else the machine URL's route. */\nfunction machineAdmissionUrl(): string {\n const s = runtime.settings;\n return runtime.admissionUrl || (s ? s.nodeUrl + MACHINE_ADMISSION_PATH : DEFAULT_ADMISSION_ENDPOINT);\n}\n\nfunction activeTraceId(): string {\n try {\n const ctx = trace.getActiveSpan()?.spanContext();\n if (ctx && /^[0-9a-f]{32}$/.test(ctx.traceId) && !/^0+$/.test(ctx.traceId)) return ctx.traceId;\n } catch {\n // ignore\n }\n return \"\";\n}\n\nfunction stampSpan(v: Verdict): void {\n try {\n const sp = trace.getActiveSpan();\n if (!sp || !sp.isRecording()) return;\n sp.setAttribute(\"sbo.admission.allowed\", v.allowed);\n sp.setAttribute(\"sbo.admission.decision\", v.decision);\n if (v.verdictId) sp.setAttribute(\"sbo.admission.verdict_id\", v.verdictId);\n if (v.degraded) sp.setAttribute(\"sbo.admission.degraded\", v.degraded);\n } catch {\n // ignore\n }\n}\n\nfunction degraded(cause: string, failClosed: boolean, started: number, httpStatus = 0, error = \"\"): Verdict {\n return {\n allowed: !failClosed,\n decision: failClosed ? \"deny\" : \"allow\",\n severity: \"\",\n criterion: \"\",\n reason: failClosed ? \"admission check unavailable\" : \"\",\n mode: \"\",\n enforceDecision: \"\",\n degraded: cause,\n judgeUsed: false,\n latencyMs: Math.round(Date.now() - started),\n verdictId: \"\",\n httpStatus,\n error: error.slice(0, 300),\n };\n}\n\n/**\n * The `service.name` the app's spans carry: the resource of the last span\n * the SDK saw (its own provider's, or the app's when attached), else the\n * configured name (serviceName, SUPERBASED_SERVICE_NAME, OTEL_SERVICE_NAME,\n * OTEL_RESOURCE_ATTRIBUTES, custom-app). OpenTelemetry's `unknown_service`\n * default is no name.\n */\nexport function serviceName(env: Env): string {\n const seen = runtime.resourceService.trim();\n if (seen && !seen.startsWith(\"unknown_service\")) return seen;\n return runtime.settings?.serviceName || resolveServiceName(undefined, env);\n}\n\n/**\n * Check an incoming user message against the app's admission policy BEFORE\n * running the agent, and get an allow/flag/ask/deny verdict.\n *\n * ```ts\n * const v = await admit(userMessage, { user: \"alice\", session: \"s1\" });\n * if (!v.allowed) return v.reason; // or route to a human on `ask`\n * ```\n *\n * Never rejects. When no decision can be obtained it admits, unless\n * `failClosed` is set; `degraded` says why.\n */\nexport async function admit(message: string, opts: AdmitOptions = {}): Promise<Verdict> {\n const started = Date.now();\n const env = (typeof process !== \"undefined\" ? process.env : {}) as Env;\n const failClosed = opts.failClosed ?? envFlag(env, [\"SUPERBASED_ADMISSION_FAIL_CLOSED\"], false);\n let url = DEFAULT_ADMISSION_ENDPOINT;\n try {\n // The org or the machine is known only once discovery answered (review E-33).\n await destinationKnown();\n const target = resolveTarget(opts, env);\n url = target.url;\n // Identity: the argument, else the request scope (propagateAttributes),\n // else init's process-wide value (contract section 2), as in Python.\n const cur = getCurrentAttributes();\n const s = runtime.settings;\n const payload = JSON.stringify({\n text: message == null ? \"\" : String(message),\n tenant: opts.tenant || cur.tenant || s?.tenant || \"\",\n user: opts.user || cur.user || s?.user || \"\",\n session: opts.session || cur.sessionId || s?.sessionId || \"\",\n // service.name: service-scoped budget caps bind on it, on the machine\n // and on the org.\n service: serviceName(env),\n trace_id: opts.traceId ?? activeTraceId(),\n request_id: opts.requestId ?? \"\",\n });\n const key = opts.apiKey ?? (target.sendKey ? (runtime.settings?.apiKey || env.SUPERBASED_API_KEY || \"\") : \"\");\n let v = await post(url, key, payload, opts, failClosed, started);\n if (target.org && !v.degraded && v.mode === \"off\") {\n // The org has no admission policy, so it made no decision (L-05).\n // Under destination both, this machine's policy decides (the key never\n // goes there); otherwise the verdict says nothing decided.\n if (target.org === \"plan\" && runtime.destination === \"both\") {\n url = machineAdmissionUrl();\n v = await post(url, \"\", payload, { ...opts, headers: withoutAuthorization(opts.headers) }, failClosed, started);\n } else {\n v = degraded(Degraded.ADMISSION_OFF, failClosed, started, v.httpStatus, \"the organization answered mode off\");\n noteDegraded(v, url);\n }\n }\n stampSpan(v);\n return v;\n } catch (err) {\n // The last line of defence: never reject into the host.\n const v = degraded(Degraded.BAD_RESPONSE, failClosed, started, 0, String(err));\n stampSpan(v);\n noteDegraded(v, url);\n return v;\n }\n}\n\nfunction withoutAuthorization(h: Record<string, string> | undefined): Record<string, string> | undefined {\n if (!h) return h;\n return Object.fromEntries(Object.entries(h).filter(([k]) => k.toLowerCase() !== \"authorization\"));\n}\n\n/** One admission request to url; a failure is a counted degraded verdict. The caller stamps the span. */\nasync function post(url: string, key: string, payload: string, opts: AdmitOptions, failClosed: boolean, started: number): Promise<Verdict> {\n const fail = (cause: string, status = 0, error = \"\"): Verdict => {\n const v = degraded(cause, failClosed, started, status, error);\n noteDegraded(v, url);\n return v;\n };\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n const timeoutMs = opts.timeoutMs ?? advertised.get(url) ?? DEFAULT_ADMIT_TIMEOUT_MS;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\", Accept: \"application/json\" };\n if (key) headers.Authorization = `Bearer ${key}`;\n if (opts.headers) Object.assign(headers, opts.headers);\n const controller = new AbortController();\n let timedOut = false;\n timer = setTimeout(() => {\n timedOut = true;\n controller.abort();\n }, timeoutMs);\n let resp: Response;\n try {\n resp = await fetch(url, {\n method: \"POST\",\n headers,\n body: payload,\n signal: controller.signal,\n // Never follow a redirect: the key must not ride to a host it was not sent to (R-B26).\n redirect: \"manual\",\n });\n } catch (err) {\n if (timedOut) return fail(Degraded.TIMEOUT, 0, `timed out after ${timeoutMs}ms`);\n const cause = (err as { cause?: { code?: string; message?: string } }).cause;\n return fail(Degraded.TRANSPORT, 0, cause?.code ?? cause?.message ?? String(err));\n }\n rememberTimeout(url, firstPresent((n) => resp.headers.get(n), TIMEOUT_HEADERS));\n if (resp.status === 403 || resp.status === 404) {\n void resp.body?.cancel().catch(() => undefined);\n return fail(Degraded.UNAVAILABLE, resp.status, `HTTP ${resp.status}`);\n }\n if (!resp.ok) {\n void resp.body?.cancel().catch(() => undefined);\n return fail(Degraded.HTTP_ERROR, resp.status, `HTTP ${resp.status}`);\n }\n let text: string;\n try {\n text = await resp.text();\n } catch (err) {\n if (timedOut) return fail(Degraded.TIMEOUT, resp.status, `timed out after ${timeoutMs}ms`);\n return fail(Degraded.TRANSPORT, resp.status, String(err));\n }\n let body: unknown;\n try {\n body = JSON.parse(text);\n } catch (err) {\n return fail(Degraded.BAD_RESPONSE, resp.status, String(err));\n }\n const v = parseVerdict(body);\n if (!v) {\n const kind = body === null ? \"null\" : Array.isArray(body) ? \"array\" : typeof body;\n return fail(\n Degraded.BAD_RESPONSE,\n resp.status,\n kind === \"object\" ? \"response field 'allowed' is missing or not a boolean\" : `response body is ${kind}, not an object`,\n );\n }\n const fields = body as Record<string, unknown>;\n rememberTimeout(url, firstPresent((n) => fields[n], TIMEOUT_FIELDS));\n v.httpStatus = resp.status;\n return v;\n } catch (err) {\n return fail(Degraded.BAD_RESPONSE, 0, String(err));\n } finally {\n if (timer) clearTimeout(timer);\n }\n}\n"]}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Every span-attribute key the SDK writes, in one place.
3
+ *
4
+ * The keys come from the Observer vocabulary: `internal/genaiattr` (GenAI
5
+ * semconv pinned to open-telemetry/semantic-conventions-genai at
6
+ * `SEMCONV_COMMIT`, plus the OpenInference names Observer reads) and
7
+ * `internal/otelident` (identity), plus the SDK-owned `sbo.*` keys of
8
+ * contract sdk-api-surface.md section 9. The SDK never invents a key:
9
+ * `vocabulary.test.mjs` checks each one against those Go files and against
10
+ * `sdk/contract/sdk-attribute-keys.json`.
11
+ */
12
+ /** The pinned GenAI semconv state (`internal/genaiattr.SemconvCommit`). */
13
+ export declare const SEMCONV_COMMIT = "76e0c19e7fe11dc693fe258642363a438af4d3aa";
14
+ export declare const SEMCONV_SCHEMA_URL = "https://opentelemetry.io/schemas/gen-ai-dev/1.42.0-dev";
15
+ export declare const K: {
16
+ readonly spanKind: "openinference.span.kind";
17
+ readonly operation: "gen_ai.operation.name";
18
+ readonly provider: "gen_ai.provider.name";
19
+ readonly systemLegacy: "gen_ai.system";
20
+ readonly requestModel: "gen_ai.request.model";
21
+ readonly responseModel: "gen_ai.response.model";
22
+ readonly responseId: "gen_ai.response.id";
23
+ readonly finishReasons: "gen_ai.response.finish_reasons";
24
+ readonly inputTokens: "gen_ai.usage.input_tokens";
25
+ readonly totalTokens: "gen_ai.usage.total_tokens";
26
+ readonly outputTokens: "gen_ai.usage.output_tokens";
27
+ readonly cacheReadTokens: "gen_ai.usage.cache_read.input_tokens";
28
+ readonly cacheWriteTokens: "gen_ai.usage.cache_write.input_tokens";
29
+ readonly reasoningTokens: "gen_ai.usage.reasoning.output_tokens";
30
+ readonly cost: "gen_ai.usage.cost";
31
+ readonly toolName: "gen_ai.tool.name";
32
+ readonly toolCallId: "gen_ai.tool.call.id";
33
+ readonly toolArguments: "gen_ai.tool.call.arguments";
34
+ readonly toolResult: "gen_ai.tool.call.result";
35
+ readonly agentName: "gen_ai.agent.name";
36
+ readonly agentId: "gen_ai.agent.id";
37
+ readonly retrievalQuery: "gen_ai.retrieval.query.text";
38
+ readonly retrievalDocuments: "gen_ai.retrieval.documents";
39
+ readonly inputMessages: "gen_ai.input.messages";
40
+ readonly outputMessages: "gen_ai.output.messages";
41
+ readonly systemInstructions: "gen_ai.system_instructions";
42
+ readonly errorType: "error.type";
43
+ readonly oiModel: "llm.model_name";
44
+ readonly oiProvider: "llm.provider";
45
+ readonly oiToolName: "tool.name";
46
+ readonly oiAgentName: "agent.name";
47
+ readonly inputValue: "input.value";
48
+ readonly outputValue: "output.value";
49
+ readonly requestId: "request_id";
50
+ readonly tenant: "sbo.tenant";
51
+ readonly user: "sbo.user";
52
+ readonly session: "session.id";
53
+ readonly environment: "sbo.environment";
54
+ readonly release: "sbo.release";
55
+ readonly tags: "sbo.tags";
56
+ readonly metadataPrefix: "sbo.metadata.";
57
+ readonly serviceVersion: "service.version";
58
+ readonly deploymentEnvironment: "deployment.environment.name";
59
+ readonly sdk: "sbo.sdk";
60
+ readonly experimentRunId: "sbo.experiment.run_id";
61
+ readonly experimentItemId: "sbo.experiment.item_id";
62
+ readonly promptName: "sbo.prompt.name";
63
+ readonly promptVersion: "sbo.prompt.version";
64
+ readonly promptLabel: "sbo.prompt.label";
65
+ /** Which side of a staged rollout served the prompt (prompts.md v2 section 9.4; genaiattr field prompt_cohort, lane C8). */
66
+ readonly promptCohort: "sbo.prompt.cohort";
67
+ readonly admissionAllowed: "sbo.admission.allowed";
68
+ readonly admissionDecision: "sbo.admission.decision";
69
+ readonly admissionVerdictId: "sbo.admission.verdict_id";
70
+ readonly admissionDegraded: "sbo.admission.degraded";
71
+ };
72
+ /**
73
+ * Content-bearing keys and prefixes: the ones `captureContent`, the
74
+ * `maxContentChars` clip and the `mask` hook apply to at export, whichever
75
+ * instrumentation wrote them (genaiattr content fields, every dialect).
76
+ */
77
+ export declare const CONTENT_KEYS: ReadonlySet<string>;
78
+ export declare const CONTENT_PREFIXES: readonly string[];
79
+ /**
80
+ * Content an instrumentation emits under keys the Go vocabulary does not map
81
+ * (yet): the contract's `extra_content_prefixes`, exactly as Python's
82
+ * EXTRA_CONTENT_PREFIXES. The SDK never writes them, but an instrumentation
83
+ * does, so they are masked, clipped and dropped like the rest: content never
84
+ * leaves unmasked because Observer does not read it. Each is a prefix (an
85
+ * exact key is its own prefix: OpenInference's `llm.prompts` is one key).
86
+ */
87
+ export declare const EXTRA_CONTENT_PREFIXES: readonly string[];
88
+ /** Indexed-list members that are structure, not content (`gen_ai.prompt.0.role`). */
89
+ export declare const CONTENT_PREFIX_EXEMPT_SUFFIXES: readonly string[];
90
+ /** True when `key` carries prompt, response or tool I/O content (Python's is_content_key). */
91
+ export declare function isContentKey(key: string): boolean;
92
+ /** `setRequestParams` option -> `gen_ai.request.*` key (the genaiattr Params names). */
93
+ export declare const REQUEST_PARAMS: {
94
+ readonly maxTokens: "gen_ai.request.max_tokens";
95
+ readonly temperature: "gen_ai.request.temperature";
96
+ readonly topP: "gen_ai.request.top_p";
97
+ readonly topK: "gen_ai.request.top_k";
98
+ readonly stopSequences: "gen_ai.request.stop_sequences";
99
+ readonly frequencyPenalty: "gen_ai.request.frequency_penalty";
100
+ readonly presencePenalty: "gen_ai.request.presence_penalty";
101
+ readonly seed: "gen_ai.request.seed";
102
+ readonly stream: "gen_ai.request.stream";
103
+ readonly reasoningLevel: "gen_ai.request.reasoning.level";
104
+ };
105
+ /** Bounds of the identity contract (`internal/otelident`): ingest clamps with the same numbers. */
106
+ export declare const LIMITS: {
107
+ readonly valueLen: 256;
108
+ readonly tags: 32;
109
+ readonly tagLen: 128;
110
+ readonly metadataKeys: 32;
111
+ readonly metadataKeyLen: 128;
112
+ readonly metadataValueLen: 512;
113
+ };
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ /**
3
+ * Every span-attribute key the SDK writes, in one place.
4
+ *
5
+ * The keys come from the Observer vocabulary: `internal/genaiattr` (GenAI
6
+ * semconv pinned to open-telemetry/semantic-conventions-genai at
7
+ * `SEMCONV_COMMIT`, plus the OpenInference names Observer reads) and
8
+ * `internal/otelident` (identity), plus the SDK-owned `sbo.*` keys of
9
+ * contract sdk-api-surface.md section 9. The SDK never invents a key:
10
+ * `vocabulary.test.mjs` checks each one against those Go files and against
11
+ * `sdk/contract/sdk-attribute-keys.json`.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.LIMITS = exports.REQUEST_PARAMS = exports.CONTENT_PREFIX_EXEMPT_SUFFIXES = exports.EXTRA_CONTENT_PREFIXES = exports.CONTENT_PREFIXES = exports.CONTENT_KEYS = exports.K = exports.SEMCONV_SCHEMA_URL = exports.SEMCONV_COMMIT = void 0;
15
+ exports.isContentKey = isContentKey;
16
+ /** The pinned GenAI semconv state (`internal/genaiattr.SemconvCommit`). */
17
+ exports.SEMCONV_COMMIT = "76e0c19e7fe11dc693fe258642363a438af4d3aa";
18
+ exports.SEMCONV_SCHEMA_URL = "https://opentelemetry.io/schemas/gen-ai-dev/1.42.0-dev";
19
+ exports.K = {
20
+ // OpenInference span kind (Observer normalizes either case).
21
+ spanKind: "openinference.span.kind",
22
+ // GenAI semconv.
23
+ operation: "gen_ai.operation.name",
24
+ provider: "gen_ai.provider.name",
25
+ systemLegacy: "gen_ai.system",
26
+ requestModel: "gen_ai.request.model",
27
+ responseModel: "gen_ai.response.model",
28
+ responseId: "gen_ai.response.id",
29
+ finishReasons: "gen_ai.response.finish_reasons",
30
+ inputTokens: "gen_ai.usage.input_tokens",
31
+ totalTokens: "gen_ai.usage.total_tokens",
32
+ outputTokens: "gen_ai.usage.output_tokens",
33
+ cacheReadTokens: "gen_ai.usage.cache_read.input_tokens",
34
+ cacheWriteTokens: "gen_ai.usage.cache_write.input_tokens",
35
+ reasoningTokens: "gen_ai.usage.reasoning.output_tokens",
36
+ cost: "gen_ai.usage.cost",
37
+ toolName: "gen_ai.tool.name",
38
+ toolCallId: "gen_ai.tool.call.id",
39
+ toolArguments: "gen_ai.tool.call.arguments",
40
+ toolResult: "gen_ai.tool.call.result",
41
+ agentName: "gen_ai.agent.name",
42
+ agentId: "gen_ai.agent.id",
43
+ retrievalQuery: "gen_ai.retrieval.query.text",
44
+ retrievalDocuments: "gen_ai.retrieval.documents",
45
+ inputMessages: "gen_ai.input.messages",
46
+ outputMessages: "gen_ai.output.messages",
47
+ systemInstructions: "gen_ai.system_instructions",
48
+ errorType: "error.type",
49
+ // OpenInference.
50
+ oiModel: "llm.model_name",
51
+ oiProvider: "llm.provider",
52
+ oiToolName: "tool.name",
53
+ oiAgentName: "agent.name",
54
+ inputValue: "input.value",
55
+ outputValue: "output.value",
56
+ // Generic.
57
+ requestId: "request_id",
58
+ // Identity (internal/otelident).
59
+ tenant: "sbo.tenant",
60
+ user: "sbo.user",
61
+ session: "session.id",
62
+ environment: "sbo.environment",
63
+ release: "sbo.release",
64
+ tags: "sbo.tags",
65
+ metadataPrefix: "sbo.metadata.",
66
+ serviceVersion: "service.version",
67
+ deploymentEnvironment: "deployment.environment.name",
68
+ sdk: "sbo.sdk",
69
+ // Experiment item (W3-2, SDK-owned).
70
+ experimentRunId: "sbo.experiment.run_id",
71
+ experimentItemId: "sbo.experiment.item_id",
72
+ // Prompt registry stamp (W3-3).
73
+ promptName: "sbo.prompt.name",
74
+ promptVersion: "sbo.prompt.version",
75
+ promptLabel: "sbo.prompt.label",
76
+ /** Which side of a staged rollout served the prompt (prompts.md v2 section 9.4; genaiattr field prompt_cohort, lane C8). */
77
+ promptCohort: "sbo.prompt.cohort",
78
+ // Admission verdict stamp (W2-1).
79
+ admissionAllowed: "sbo.admission.allowed",
80
+ admissionDecision: "sbo.admission.decision",
81
+ admissionVerdictId: "sbo.admission.verdict_id",
82
+ admissionDegraded: "sbo.admission.degraded",
83
+ };
84
+ /**
85
+ * Content-bearing keys and prefixes: the ones `captureContent`, the
86
+ * `maxContentChars` clip and the `mask` hook apply to at export, whichever
87
+ * instrumentation wrote them (genaiattr content fields, every dialect).
88
+ */
89
+ exports.CONTENT_KEYS = new Set([
90
+ "input.value",
91
+ "output.value",
92
+ "gen_ai.input.messages",
93
+ "gen_ai.output.messages",
94
+ "gen_ai.system_instructions",
95
+ "gen_ai.tool.call.arguments",
96
+ "gen_ai.tool.call.result",
97
+ "gen_ai.retrieval.query.text",
98
+ "gen_ai.retrieval.documents",
99
+ "gen_ai.prompt",
100
+ "gen_ai.completion",
101
+ "gen_ai.output.value",
102
+ "gen_ai.tool.input",
103
+ "gen_ai.tool.output",
104
+ "tool.parameters",
105
+ "tool.result",
106
+ "tool_call.function.arguments",
107
+ "tool_call.result",
108
+ "traceloop.entity.input",
109
+ "traceloop.entity.output",
110
+ // The langfuse dialect (W5-2): a Langfuse SDK's observation and trace
111
+ // input/output.
112
+ "langfuse.observation.input",
113
+ "langfuse.observation.output",
114
+ "langfuse.trace.input",
115
+ "langfuse.trace.output",
116
+ "llm.prompt",
117
+ "llm.completion",
118
+ "prompt",
119
+ "completion",
120
+ ]);
121
+ exports.CONTENT_PREFIXES = [
122
+ "gen_ai.prompt.",
123
+ "gen_ai.completion.",
124
+ "llm.input_messages.",
125
+ "llm.output_messages.",
126
+ ];
127
+ /**
128
+ * Content an instrumentation emits under keys the Go vocabulary does not map
129
+ * (yet): the contract's `extra_content_prefixes`, exactly as Python's
130
+ * EXTRA_CONTENT_PREFIXES. The SDK never writes them, but an instrumentation
131
+ * does, so they are masked, clipped and dropped like the rest: content never
132
+ * leaves unmasked because Observer does not read it. Each is a prefix (an
133
+ * exact key is its own prefix: OpenInference's `llm.prompts` is one key).
134
+ */
135
+ exports.EXTRA_CONTENT_PREFIXES = [
136
+ // OpenInference embedding inputs (text and vectors).
137
+ "embedding.embeddings.",
138
+ // OpenInference retriever documents, prompt templates and their variables,
139
+ // and the rendered prompt list of a completion call.
140
+ "retrieval.documents.",
141
+ "llm.prompt_template.",
142
+ "llm.prompts",
143
+ // Pydantic AI's own agent-span content.
144
+ "final_result",
145
+ "pydantic_ai.all_messages",
146
+ // OpenInference CrewAI: the crew's inputs, task descriptions and agents.
147
+ "crew_inputs",
148
+ "crew_tasks",
149
+ "crew_agents",
150
+ ];
151
+ /** Indexed-list members that are structure, not content (`gen_ai.prompt.0.role`). */
152
+ exports.CONTENT_PREFIX_EXEMPT_SUFFIXES = [".role", ".finish_reason"];
153
+ /** True when `key` carries prompt, response or tool I/O content (Python's is_content_key). */
154
+ function isContentKey(key) {
155
+ if (exports.CONTENT_KEYS.has(key))
156
+ return true;
157
+ if (exports.CONTENT_PREFIXES.some((p) => key.startsWith(p)))
158
+ return !exports.CONTENT_PREFIX_EXEMPT_SUFFIXES.some((s) => key.endsWith(s));
159
+ return exports.EXTRA_CONTENT_PREFIXES.some((p) => key.startsWith(p));
160
+ }
161
+ /** `setRequestParams` option -> `gen_ai.request.*` key (the genaiattr Params names). */
162
+ exports.REQUEST_PARAMS = {
163
+ maxTokens: "gen_ai.request.max_tokens",
164
+ temperature: "gen_ai.request.temperature",
165
+ topP: "gen_ai.request.top_p",
166
+ topK: "gen_ai.request.top_k",
167
+ stopSequences: "gen_ai.request.stop_sequences",
168
+ frequencyPenalty: "gen_ai.request.frequency_penalty",
169
+ presencePenalty: "gen_ai.request.presence_penalty",
170
+ seed: "gen_ai.request.seed",
171
+ stream: "gen_ai.request.stream",
172
+ reasoningLevel: "gen_ai.request.reasoning.level",
173
+ };
174
+ /** Bounds of the identity contract (`internal/otelident`): ingest clamps with the same numbers. */
175
+ exports.LIMITS = {
176
+ valueLen: 256,
177
+ tags: 32,
178
+ tagLen: 128,
179
+ metadataKeys: 32,
180
+ metadataKeyLen: 128,
181
+ metadataValueLen: 512,
182
+ };
183
+ //# sourceMappingURL=attrs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attrs.js","sourceRoot":"","sources":["../../src/attrs.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAgJH,oCAIC;AAlJD,2EAA2E;AAC9D,QAAA,cAAc,GAAG,0CAA0C,CAAC;AAC5D,QAAA,kBAAkB,GAAG,wDAAwD,CAAC;AAE9E,QAAA,CAAC,GAAG;IACf,6DAA6D;IAC7D,QAAQ,EAAE,yBAAyB;IACnC,iBAAiB;IACjB,SAAS,EAAE,uBAAuB;IAClC,QAAQ,EA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AC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACvC,IAAI,wBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,sCAA8B,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACzH,OAAO,8BAAsB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED,wFAAwF;AAC3E,QAAA,cAAc,GAAG;IAC5B,SAAS,EAAE,2BAA2B;IACtC,WAAW,EAAE,4BAA4B;IACzC,IAAI,EAAE,sBAAsB;IAC5B,IAAI,EAAE,sBAAsB;IAC5B,aAAa,EAAE,+BAA+B;IAC9C,gBAAgB,EAAE,kCAAkC;IACpD,eAAe,EAAE,iCAAiC;IAClD,IAAI,EAAE,qBAAqB;IAC3B,MAAM,EAAE,uBAAuB;IAC/B,cAAc,EAAE,gCAAgC;CACxC,CAAC;AAEX,mGAAmG;AACtF,QAAA,MAAM,GAAG;IACpB,QAAQ,EAAE,GAAG;IACb,IAAI,EAAE,EAAE;IACR,MAAM,EAAE,GAAG;IACX,YAAY,EAAE,EAAE;IAChB,cAAc,EAAE,GAAG;IACnB,gBAAgB,EAAE,GAAG;CACb,CAAC","sourcesContent":["/**\n * Every span-attribute key the SDK writes, in one place.\n *\n * The keys come from the Observer vocabulary: `internal/genaiattr` (GenAI\n * semconv pinned to open-telemetry/semantic-conventions-genai at\n * `SEMCONV_COMMIT`, plus the OpenInference names Observer reads) and\n * `internal/otelident` (identity), plus the SDK-owned `sbo.*` keys of\n * contract sdk-api-surface.md section 9. The SDK never invents a key:\n * `vocabulary.test.mjs` checks each one against those Go files and against\n * `sdk/contract/sdk-attribute-keys.json`.\n */\n\n/** The pinned GenAI semconv state (`internal/genaiattr.SemconvCommit`). */\nexport const SEMCONV_COMMIT = \"76e0c19e7fe11dc693fe258642363a438af4d3aa\";\nexport const SEMCONV_SCHEMA_URL = \"https://opentelemetry.io/schemas/gen-ai-dev/1.42.0-dev\";\n\nexport const K = {\n // OpenInference span kind (Observer normalizes either case).\n spanKind: \"openinference.span.kind\",\n // GenAI semconv.\n operation: \"gen_ai.operation.name\",\n provider: \"gen_ai.provider.name\",\n systemLegacy: \"gen_ai.system\",\n requestModel: \"gen_ai.request.model\",\n responseModel: \"gen_ai.response.model\",\n responseId: \"gen_ai.response.id\",\n finishReasons: \"gen_ai.response.finish_reasons\",\n inputTokens: \"gen_ai.usage.input_tokens\",\n totalTokens: \"gen_ai.usage.total_tokens\",\n outputTokens: \"gen_ai.usage.output_tokens\",\n cacheReadTokens: \"gen_ai.usage.cache_read.input_tokens\",\n cacheWriteTokens: \"gen_ai.usage.cache_write.input_tokens\",\n reasoningTokens: \"gen_ai.usage.reasoning.output_tokens\",\n cost: \"gen_ai.usage.cost\",\n toolName: \"gen_ai.tool.name\",\n toolCallId: \"gen_ai.tool.call.id\",\n toolArguments: \"gen_ai.tool.call.arguments\",\n toolResult: \"gen_ai.tool.call.result\",\n agentName: \"gen_ai.agent.name\",\n agentId: \"gen_ai.agent.id\",\n retrievalQuery: \"gen_ai.retrieval.query.text\",\n retrievalDocuments: \"gen_ai.retrieval.documents\",\n inputMessages: \"gen_ai.input.messages\",\n outputMessages: \"gen_ai.output.messages\",\n systemInstructions: \"gen_ai.system_instructions\",\n errorType: \"error.type\",\n // OpenInference.\n oiModel: \"llm.model_name\",\n oiProvider: \"llm.provider\",\n oiToolName: \"tool.name\",\n oiAgentName: \"agent.name\",\n inputValue: \"input.value\",\n outputValue: \"output.value\",\n // Generic.\n requestId: \"request_id\",\n // Identity (internal/otelident).\n tenant: \"sbo.tenant\",\n user: \"sbo.user\",\n session: \"session.id\",\n environment: \"sbo.environment\",\n release: \"sbo.release\",\n tags: \"sbo.tags\",\n metadataPrefix: \"sbo.metadata.\",\n serviceVersion: \"service.version\",\n deploymentEnvironment: \"deployment.environment.name\",\n sdk: \"sbo.sdk\",\n // Experiment item (W3-2, SDK-owned).\n experimentRunId: \"sbo.experiment.run_id\",\n experimentItemId: \"sbo.experiment.item_id\",\n // Prompt registry stamp (W3-3).\n promptName: \"sbo.prompt.name\",\n promptVersion: \"sbo.prompt.version\",\n promptLabel: \"sbo.prompt.label\",\n /** Which side of a staged rollout served the prompt (prompts.md v2 section 9.4; genaiattr field prompt_cohort, lane C8). */\n promptCohort: \"sbo.prompt.cohort\",\n // Admission verdict stamp (W2-1).\n admissionAllowed: \"sbo.admission.allowed\",\n admissionDecision: \"sbo.admission.decision\",\n admissionVerdictId: \"sbo.admission.verdict_id\",\n admissionDegraded: \"sbo.admission.degraded\",\n} as const;\n\n/**\n * Content-bearing keys and prefixes: the ones `captureContent`, the\n * `maxContentChars` clip and the `mask` hook apply to at export, whichever\n * instrumentation wrote them (genaiattr content fields, every dialect).\n */\nexport const CONTENT_KEYS: ReadonlySet<string> = new Set([\n \"input.value\",\n \"output.value\",\n \"gen_ai.input.messages\",\n \"gen_ai.output.messages\",\n \"gen_ai.system_instructions\",\n \"gen_ai.tool.call.arguments\",\n \"gen_ai.tool.call.result\",\n \"gen_ai.retrieval.query.text\",\n \"gen_ai.retrieval.documents\",\n \"gen_ai.prompt\",\n \"gen_ai.completion\",\n \"gen_ai.output.value\",\n \"gen_ai.tool.input\",\n \"gen_ai.tool.output\",\n \"tool.parameters\",\n \"tool.result\",\n \"tool_call.function.arguments\",\n \"tool_call.result\",\n \"traceloop.entity.input\",\n \"traceloop.entity.output\",\n // The langfuse dialect (W5-2): a Langfuse SDK's observation and trace\n // input/output.\n \"langfuse.observation.input\",\n \"langfuse.observation.output\",\n \"langfuse.trace.input\",\n \"langfuse.trace.output\",\n \"llm.prompt\",\n \"llm.completion\",\n \"prompt\",\n \"completion\",\n]);\nexport const CONTENT_PREFIXES: readonly string[] = [\n \"gen_ai.prompt.\",\n \"gen_ai.completion.\",\n \"llm.input_messages.\",\n \"llm.output_messages.\",\n];\n/**\n * Content an instrumentation emits under keys the Go vocabulary does not map\n * (yet): the contract's `extra_content_prefixes`, exactly as Python's\n * EXTRA_CONTENT_PREFIXES. The SDK never writes them, but an instrumentation\n * does, so they are masked, clipped and dropped like the rest: content never\n * leaves unmasked because Observer does not read it. Each is a prefix (an\n * exact key is its own prefix: OpenInference's `llm.prompts` is one key).\n */\nexport const EXTRA_CONTENT_PREFIXES: readonly string[] = [\n // OpenInference embedding inputs (text and vectors).\n \"embedding.embeddings.\",\n // OpenInference retriever documents, prompt templates and their variables,\n // and the rendered prompt list of a completion call.\n \"retrieval.documents.\",\n \"llm.prompt_template.\",\n \"llm.prompts\",\n // Pydantic AI's own agent-span content.\n \"final_result\",\n \"pydantic_ai.all_messages\",\n // OpenInference CrewAI: the crew's inputs, task descriptions and agents.\n \"crew_inputs\",\n \"crew_tasks\",\n \"crew_agents\",\n];\n\n/** Indexed-list members that are structure, not content (`gen_ai.prompt.0.role`). */\nexport const CONTENT_PREFIX_EXEMPT_SUFFIXES: readonly string[] = [\".role\", \".finish_reason\"];\n\n/** True when `key` carries prompt, response or tool I/O content (Python's is_content_key). */\nexport function isContentKey(key: string): boolean {\n if (CONTENT_KEYS.has(key)) return true;\n if (CONTENT_PREFIXES.some((p) => key.startsWith(p))) return !CONTENT_PREFIX_EXEMPT_SUFFIXES.some((s) => key.endsWith(s));\n return EXTRA_CONTENT_PREFIXES.some((p) => key.startsWith(p));\n}\n\n/** `setRequestParams` option -> `gen_ai.request.*` key (the genaiattr Params names). */\nexport const REQUEST_PARAMS = {\n maxTokens: \"gen_ai.request.max_tokens\",\n temperature: \"gen_ai.request.temperature\",\n topP: \"gen_ai.request.top_p\",\n topK: \"gen_ai.request.top_k\",\n stopSequences: \"gen_ai.request.stop_sequences\",\n frequencyPenalty: \"gen_ai.request.frequency_penalty\",\n presencePenalty: \"gen_ai.request.presence_penalty\",\n seed: \"gen_ai.request.seed\",\n stream: \"gen_ai.request.stream\",\n reasoningLevel: \"gen_ai.request.reasoning.level\",\n} as const;\n\n/** Bounds of the identity contract (`internal/otelident`): ingest clamps with the same numbers. */\nexport const LIMITS = {\n valueLen: 256,\n tags: 32,\n tagLen: 128,\n metadataKeys: 32,\n metadataKeyLen: 128,\n metadataValueLen: 512,\n} as const;\n"]}
@@ -0,0 +1,202 @@
1
+ /**
2
+ * SDK settings: one options object, each field mapped to an env var.
3
+ *
4
+ * Resolution for every field: explicit `init()` option, then the
5
+ * `SUPERBASED_*` variable, then the standard OpenTelemetry variable (where
6
+ * one exists), then (destination, gateway URL and credential only) what the
7
+ * local Observer advertises, then the default. Pure over an env record, so it
8
+ * is testable without touching `process.env`.
9
+ *
10
+ * Export goes to a list of destinations (endpoint, headers, timeout each):
11
+ * this machine's Observer, the org or SaaS gateway, or both (D18, contract
12
+ * `contracts/destination.md`). `destinations()` turns the resolved choice
13
+ * into that list; destination.ts makes the choice.
14
+ */
15
+ export type Env = Record<string, string | undefined>;
16
+ export declare const DEFAULT_ENDPOINT = "http://127.0.0.1:4318/v1/traces";
17
+ export declare const DEFAULT_SERVICE_NAME = "custom-app";
18
+ export declare const DEFAULT_MAX_CONTENT_CHARS = 8000;
19
+ export declare const DEFAULT_EXPORT_TIMEOUT_MS = 5000;
20
+ export declare const DEFAULT_SHUTDOWN_TIMEOUT_MS = 2000;
21
+ /** This machine's Observer dashboard API (admission, discovery, the local control API). */
22
+ export declare const DEFAULT_NODE_URL = "http://127.0.0.1:8081";
23
+ /** Discovery timeout (contract destination.md section 4: 500 ms total, one attempt). */
24
+ export declare const DEFAULT_DISCOVER_TIMEOUT_MS = 500;
25
+ export declare const DEFAULT_API_TIMEOUT_MS = 5000;
26
+ export declare const DEFAULT_PROMPT_CACHE_TTL_MS = 60000;
27
+ export declare const TRACES_PATH = "/v1/traces";
28
+ /** Where SDK data is saved (D18). */
29
+ export type DestinationChoice = "local" | "online" | "both";
30
+ export declare const DESTINATION_CHOICES: readonly DestinationChoice[];
31
+ /** One OTLP/HTTP export target. */
32
+ export interface Destination {
33
+ /** `local` (this machine, or the collector `endpoint` names) or `online` (the org or SaaS gateway). */
34
+ name: "local" | "online";
35
+ endpoint: string;
36
+ headers: Record<string, string>;
37
+ timeoutMs: number;
38
+ }
39
+ /** Every SDK option, fully resolved. See the README's settings table. */
40
+ export interface Settings {
41
+ /**
42
+ * The local destination's OTLP traces URL: the option > SUPERBASED_OTLP_ENDPOINT >
43
+ * (destination `local` only) OTEL_EXPORTER_OTLP_TRACES_ENDPOINT > OTEL_EXPORTER_OTLP_ENDPOINT
44
+ * (+ /v1/traces) > what the machine advertises > the built-in receiver.
45
+ * This field holds the first of the option / env values (or the default);
46
+ * `localTracesUrl(settings, choice)` applies the rest.
47
+ */
48
+ endpoint: string;
49
+ /** Where `endpoint` came from: `argument`, `env` (SUPERBASED_OTLP_ENDPOINT), `otel` (an OTEL_* variable) or `default`. */
50
+ endpointSource: "argument" | "env" | "otel" | "default";
51
+ /** OTEL_EXPORTER_OTLP_HEADERS, OTEL_EXPORTER_OTLP_TRACES_HEADERS, SUPERBASED_OTLP_HEADERS (merged, option on top). The OTEL ones go to the local destination only when it is `local`. */
52
+ headers: Record<string, string>;
53
+ /** SUPERBASED_API_KEY, sent as `Authorization: Bearer` to the gateway only. */
54
+ apiKey: string;
55
+ /** SUPERBASED_SERVICE_NAME > OTEL_SERVICE_NAME > service.name in OTEL_RESOURCE_ATTRIBUTES. */
56
+ serviceName: string;
57
+ /** OTEL_RESOURCE_ATTRIBUTES. */
58
+ resourceAttributes: Record<string, string>;
59
+ /** SUPERBASED_TENANT. */
60
+ tenant: string;
61
+ /** SUPERBASED_USER. */
62
+ user: string;
63
+ /** SUPERBASED_SESSION_ID. */
64
+ sessionId: string;
65
+ /** SUPERBASED_CAPTURE_CONTENT (legacy OBSERVER_CAPTURE_CONTENT). */
66
+ captureContent: boolean;
67
+ /** SUPERBASED_MAX_CONTENT_CHARS. */
68
+ maxContentChars: number;
69
+ /** SUPERBASED_EXPORT_TIMEOUT_MS > OTEL_EXPORTER_OTLP_TRACES_TIMEOUT > OTEL_EXPORTER_OTLP_TIMEOUT. */
70
+ exportTimeoutMs: number;
71
+ /** SUPERBASED_SHUTDOWN_TIMEOUT_MS: bound on flush() and shutdown(). */
72
+ shutdownTimeoutMs: number;
73
+ /** SUPERBASED_EXIT_HOOK: flush pending spans on process `beforeExit`. */
74
+ exitHook: boolean;
75
+ /** SUPERBASED_DEBUG: log each failure to the console (default: at most one line a minute). */
76
+ debug: boolean;
77
+ /** SUPERBASED_RELEASE: the app's release, on the resource as `service.version`. */
78
+ release: string;
79
+ /** SUPERBASED_ENVIRONMENT: the app's environment, on the resource as `deployment.environment.name`. */
80
+ environment: string;
81
+ /** SUPERBASED_TAGS (comma list): tags on every trace (`sbo.tags`). */
82
+ tags: string[];
83
+ /** SUPERBASED_METADATA (`k=v,k2=v2`): metadata on every trace (`sbo.metadata.<k>`). */
84
+ metadata: Record<string, string>;
85
+ /** SUPERBASED_SAMPLE_RATE (0..1), else OTEL_TRACES_SAMPLER[_ARG]. Whole traces are kept or dropped. */
86
+ sampleRate: number;
87
+ /** Whether the sampler is parent-based (a sampled parent keeps its children). */
88
+ parentBased: boolean;
89
+ /** SUPERBASED_DESTINATION: local, online or both. Empty = not chosen (ask the machine, then local). */
90
+ destination: DestinationChoice | "";
91
+ /** Why an explicit destination value was refused ("" when none was, or it was valid). */
92
+ destinationInvalid: string;
93
+ /** Why an environment sampling value was ignored ("" when none was). */
94
+ samplingInvalid: string;
95
+ /** The OTLP traces URL the machine advertised in discovery ("" when none). Internal. */
96
+ advertisedEndpoint: string;
97
+ /** SUPERBASED_ORG_URL: base URL of the org or SaaS gateway (OTLP at `/v1/traces`, control API at `/v1/sdk`). */
98
+ orgUrl: string;
99
+ /** Headers for the gateway: the `headers` option and SUPERBASED_OTLP_HEADERS, never the OTEL_* ones. */
100
+ onlineHeaders: Record<string, string>;
101
+ /** SUPERBASED_NODE_URL: this machine's Observer dashboard API (scheme, host and port). */
102
+ nodeUrl: string;
103
+ /** SUPERBASED_DISCOVER: ask the machine for its destination default. */
104
+ discover: boolean;
105
+ /** SUPERBASED_DISCOVER_TIMEOUT_MS: bound on that request. */
106
+ discoverTimeoutMs: number;
107
+ /** SUPERBASED_API_TIMEOUT_MS: bound on each control API call (scores, prompts, datasets, experiments). */
108
+ apiTimeoutMs: number;
109
+ /** SUPERBASED_PROMPT_CACHE_TTL_MS: how long a fetched prompt is fresh. */
110
+ promptCacheTtlMs: number;
111
+ /** True when `endpoint` was set explicitly (option, SUPERBASED_OTLP_ENDPOINT or an OTEL_* variable). */
112
+ endpointExplicit: boolean;
113
+ /** Where `apiKey` came from: `argument`, `env`, `file` (the machine's credential file) or "". */
114
+ credentialSource: "argument" | "env" | "file" | "";
115
+ }
116
+ /** The subset a caller may pass to `init()`; unset fields come from env. */
117
+ export type SettingsInput = Partial<Omit<Settings, "endpointExplicit" | "endpointSource" | "onlineHeaders" | "destinationInvalid" | "samplingInvalid" | "parentBased" | "destination" | "advertisedEndpoint" | "credentialSource">> & {
118
+ destination?: string;
119
+ };
120
+ /** Parse the first set boolean-ish env var in `names`; none set gives `def`. */
121
+ export declare function envFlag(env: Env, names: string[], def: boolean): boolean;
122
+ /** Parse the OTel `k1=v1,k2=v2` list (percent-decoded); malformed members skipped. */
123
+ export declare function parseKvList(raw: string | undefined): Record<string, string>;
124
+ /** Parse a comma list (empty members dropped). */
125
+ export declare function parseList(raw: string | undefined): string[];
126
+ export declare function resolveEndpoint(explicit: string | undefined, env: Env): string;
127
+ /** The endpoint and where it came from (see `Settings.endpoint`). */
128
+ export declare function resolveEndpointWithSource(explicit: string | undefined, env: Env): [string, Settings["endpointSource"]];
129
+ export declare function resolveHeaders(explicit: Record<string, string> | undefined, env: Env): Record<string, string>;
130
+ export declare function resolveServiceName(explicit: string | undefined, env: Env): string;
131
+ /**
132
+ * The head sampling rate and whether it is parent-based: the option,
133
+ * SUPERBASED_SAMPLE_RATE, then the standard OTEL_TRACES_SAMPLER (+ _ARG). An
134
+ * explicit rate outside 0..1 is a programmer error (RangeError); a bad
135
+ * environment value is ignored and named in `invalid` (review E-38; as
136
+ * Python), so a stray host variable never stops the app.
137
+ */
138
+ export declare function resolveSampling(explicit: number | undefined, env: Env): {
139
+ rate: number;
140
+ parentBased: boolean;
141
+ invalid: string;
142
+ };
143
+ /**
144
+ * The destination from the option, then SUPERBASED_DESTINATION. An invalid
145
+ * value is refused loudly (reported in `invalid`) and the next source is
146
+ * used (contract destination.md section 1).
147
+ */
148
+ export declare function resolveDestinationChoice(explicit: string | undefined, env: Env): {
149
+ choice: DestinationChoice | "";
150
+ source: string;
151
+ invalid: string;
152
+ };
153
+ export declare function trimSlash(u: string): string;
154
+ /** Build settings from explicit options (undefined = unset) over env. */
155
+ export declare function resolveSettings(env: Env, explicit?: SettingsInput): Settings;
156
+ /** The online OTLP traces URL ("" when no gateway is configured). */
157
+ export declare function onlineTracesUrl(s: Settings): string;
158
+ /**
159
+ * The local OTLP traces URL for a destination choice: the `endpoint` option
160
+ * or SUPERBASED_OTLP_ENDPOINT as given; an OTEL_* endpoint only when the
161
+ * destination is `local` (so an app's existing OTEL variables, pointing at
162
+ * another vendor, never replace the machine under `both`); else what the
163
+ * machine advertised; else the built-in receiver.
164
+ */
165
+ export declare function localTracesUrl(s: Settings, choice?: DestinationChoice | ""): string;
166
+ /**
167
+ * Whether the app named the local destination's endpoint itself (the
168
+ * first rungs of `localTracesUrl`), so the machine's advertised receiver is
169
+ * not needed.
170
+ */
171
+ export declare function localEndpointNamed(s: Settings, choice?: DestinationChoice | ""): boolean;
172
+ /** Whether the online destination is usable: a gateway URL and a credential. */
173
+ export declare function onlineUsable(s: Settings): boolean;
174
+ /**
175
+ * Whether the local exporter may carry the credential: only to a collector
176
+ * the app named itself (the `endpoint` option or SUPERBASED_OTLP_ENDPOINT)
177
+ * that is not on loopback. Never to this machine, and never to an endpoint
178
+ * that came from OTEL_EXPORTER_OTLP_* (an app exporting to another vendor
179
+ * must not leak the superbased key there; review finding R-B26).
180
+ */
181
+ export declare function localCarriesKey(s: Settings, endpoint: string): boolean;
182
+ /** Whether a URL's host is loopback. */
183
+ export declare function isLoopbackHost(url: string): boolean;
184
+ /**
185
+ * Where spans are exported, for a destination choice (D18).
186
+ *
187
+ * - `local`: this machine's Observer (or the collector `endpoint` names).
188
+ * Headers: the OTEL_* ones (destination `local` only), SUPERBASED_OTLP_HEADERS
189
+ * and the `headers` option. The credential only per `localCarriesKey`.
190
+ * - `online`: the gateway with `apiKey` as the bearer, configured only from
191
+ * the SDK's own settings (an app's OTEL_* variables never redirect it).
192
+ * - `both`: one exporter for each; one failing never blocks the other.
193
+ *
194
+ * The degraded cases (contract destination.md section 7): `online` with no
195
+ * usable gateway exports nothing, `both` exports to the machine only; the
196
+ * caller reports why (`destinationProblems`).
197
+ */
198
+ export declare function destinations(s: Settings, choice?: DestinationChoice | ""): Destination[];
199
+ /** The fix to name when the online destination is not usable (the verb is `observer sdk sign-in`, R-B17). */
200
+ export declare const ONLINE_FIX = "run `observer sdk sign-in`, or set SUPERBASED_ORG_URL and SUPERBASED_API_KEY";
201
+ /** Why a destination choice cannot be honoured in full (empty = fine). */
202
+ export declare function destinationProblems(s: Settings, choice: DestinationChoice | ""): string[];