axiom 0.52.0 → 0.52.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +6 -6
- package/dist/{chunk-SD3TFRJI.js → chunk-H3AJU7H6.js} +7 -7
- package/dist/{chunk-QMM7KCYZ.js → chunk-J46CMFBN.js} +7 -7
- package/dist/{chunk-QMM7KCYZ.js.map → chunk-J46CMFBN.js.map} +1 -1
- package/dist/{chunk-YM4B3UES.js → chunk-JOJAEFHB.js} +5 -2
- package/dist/{chunk-YM4B3UES.js.map → chunk-JOJAEFHB.js.map} +1 -1
- package/dist/{chunk-4CHGZ4WT.js → chunk-NAXW7DJD.js} +2 -2
- package/dist/{chunk-2RCYBZZC.js → chunk-S3BXNQXD.js} +6 -6
- package/dist/{chunk-2RCYBZZC.js.map → chunk-S3BXNQXD.js.map} +1 -1
- package/dist/{chunk-I5OOMUQJ.js → chunk-SH524JF2.js} +4 -4
- package/dist/config.js +1 -1
- package/dist/docs/README.md +2 -2
- package/dist/docs/config/README.md +1 -1
- package/dist/docs/config/functions/defineConfig.md +1 -1
- package/dist/docs/config/interfaces/AxiomConfig.md +1 -1
- package/dist/docs/config/type-aliases/AxiomEvalInstrumentationHook.md +1 -1
- package/dist/docs/evals/README.md +1 -1
- package/dist/docs/evals/classes/AxiomReporter.md +1 -1
- package/dist/docs/evals/functions/Eval.md +1 -1
- package/dist/docs/evals/interfaces/EvalBuilder.md +1 -1
- package/dist/docs/evals/interfaces/EvalContextData.md +1 -1
- package/dist/docs/evals/online/README.md +1 -1
- package/dist/docs/evals/online/functions/onlineEval.md +1 -1
- package/dist/docs/evals/online/type-aliases/OnlineEvalParams.md +1 -1
- package/dist/docs/evals/online/type-aliases/OnlineEvalScorerEntry.md +1 -1
- package/dist/docs/evals/online/type-aliases/OnlineEvalScorerInput.md +1 -1
- package/dist/docs/evals/online/type-aliases/SampledOnlineEvalScorer.md +1 -1
- package/dist/docs/evals/online/type-aliases/ScorerSampling.md +1 -1
- package/dist/docs/evals/type-aliases/Case.md +1 -1
- package/dist/docs/evals/type-aliases/Chat.md +1 -1
- package/dist/docs/evals/type-aliases/EvalParams.md +1 -1
- package/dist/docs/evals/type-aliases/EvalTask.md +1 -1
- package/dist/docs/evals/type-aliases/Evaluation.md +1 -1
- package/dist/docs/evals/type-aliases/Task.md +1 -1
- package/dist/docs/feedback/README.md +1 -1
- package/dist/docs/feedback/functions/createFeedbackClient.md +1 -1
- package/dist/docs/feedback/type-aliases/FeedbackClient.md +1 -1
- package/dist/docs/feedback/type-aliases/FeedbackConfig.md +1 -1
- package/dist/docs/feedback/type-aliases/FeedbackErrorContext.md +1 -1
- package/dist/docs/feedback/type-aliases/FeedbackEvent.md +1 -1
- package/dist/docs/feedback/type-aliases/FeedbackInput.md +1 -1
- package/dist/docs/feedback/type-aliases/FeedbackLinks.md +1 -1
- package/dist/docs/feedback/type-aliases/FeedbackSettings.md +1 -1
- package/dist/docs/feedback/type-aliases/SendFeedbackFn.md +1 -1
- package/dist/docs/feedback/variables/Feedback.md +1 -1
- package/dist/docs/index/README.md +1 -1
- package/dist/docs/index/functions/axiomAIMiddleware.md +1 -1
- package/dist/docs/index/functions/axiomAIMiddlewareV1.md +1 -1
- package/dist/docs/index/functions/axiomAIMiddlewareV2.md +1 -1
- package/dist/docs/index/functions/axiomAIMiddlewareV3.md +1 -1
- package/dist/docs/index/functions/createAppScope.md +1 -1
- package/dist/docs/index/functions/experimental_parse.md +1 -1
- package/dist/docs/index/functions/getGlobalTracer.md +1 -1
- package/dist/docs/index/functions/initAxiomAI.md +1 -1
- package/dist/docs/index/functions/resetAxiomAI.md +1 -1
- package/dist/docs/index/functions/withSpan.md +1 -1
- package/dist/docs/index/functions/wrapAISDKModel.md +1 -1
- package/dist/docs/index/functions/wrapTool.md +1 -1
- package/dist/docs/index/functions/wrapTools.md +1 -1
- package/dist/docs/index/interfaces/AxiomTelemetryConfig.md +1 -1
- package/dist/docs/index/interfaces/experimental_AxiomPromptMetadata.md +1 -1
- package/dist/docs/index/interfaces/experimental_ParsedMessage.md +1 -1
- package/dist/docs/index/type-aliases/AxiomAIRedactionPolicy.md +1 -1
- package/dist/docs/index/type-aliases/WithSpanOptions.md +1 -1
- package/dist/docs/index/type-aliases/experimental_InferContext.md +1 -1
- package/dist/docs/index/type-aliases/experimental_InferSchema.md +1 -1
- package/dist/docs/index/type-aliases/experimental_ParsedMessagesArray.md +1 -1
- package/dist/docs/index/type-aliases/experimental_Prompt.md +1 -1
- package/dist/docs/index/type-aliases/experimental_TSchema.md +1 -1
- package/dist/docs/index/variables/RedactionPolicy.md +1 -1
- package/dist/docs/index/variables/experimental_Type.md +1 -1
- package/dist/docs/index/variables/onlineEval.md +1 -1
- package/dist/docs/scorers/aggregations/README.md +1 -1
- package/dist/docs/scorers/aggregations/functions/Mean.md +1 -1
- package/dist/docs/scorers/aggregations/functions/Median.md +1 -1
- package/dist/docs/scorers/aggregations/functions/PassAtK.md +1 -1
- package/dist/docs/scorers/aggregations/functions/PassHatK.md +1 -1
- package/dist/docs/scorers/aggregations/type-aliases/Aggregation.md +1 -1
- package/dist/docs/scorers/aggregations/variables/AllTrialsPass.md +1 -1
- package/dist/docs/scorers/aggregations/variables/AtLeastOneTrialPasses.md +1 -1
- package/dist/docs/scorers/scorers/README.md +1 -1
- package/dist/docs/scorers/scorers/functions/Scorer.md +1 -1
- package/dist/docs/scorers/scorers/type-aliases/Score.md +1 -1
- package/dist/docs/scorers/scorers/type-aliases/ScoreWithName.md +1 -1
- package/dist/docs/scorers/scorers/type-aliases/ScorerLike.md +1 -1
- package/dist/docs/scorers/scorers/type-aliases/ScorerOptions.md +1 -1
- package/dist/docs/scorers/scorers/type-aliases/ScorerType.md +1 -1
- package/dist/evals/online.js +2 -2
- package/dist/evals.js +6 -6
- package/dist/evals.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/{run-vitest-53XCD77T.js → run-vitest-MU6JXBDY.js} +6 -6
- package/package.json +5 -5
- /package/dist/{chunk-SD3TFRJI.js.map → chunk-H3AJU7H6.js.map} +0 -0
- /package/dist/{chunk-4CHGZ4WT.js.map → chunk-NAXW7DJD.js.map} +0 -0
- /package/dist/{chunk-I5OOMUQJ.js.map → chunk-SH524JF2.js.map} +0 -0
- /package/dist/{run-vitest-53XCD77T.js.map → run-vitest-MU6JXBDY.js.map} +0 -0
package/dist/bin.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
extractOverrides,
|
|
4
4
|
loadEvalCommand
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-SH524JF2.js";
|
|
6
6
|
import {
|
|
7
7
|
OAuth,
|
|
8
8
|
fetchOrganizations,
|
|
@@ -14,12 +14,12 @@ import {
|
|
|
14
14
|
startCallbackServer,
|
|
15
15
|
verifyToken,
|
|
16
16
|
waitForCallback
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-JOJAEFHB.js";
|
|
18
|
+
import "./chunk-S3BXNQXD.js";
|
|
19
19
|
import {
|
|
20
20
|
AxiomCLIError
|
|
21
21
|
} from "./chunk-ISSDOC43.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-J46CMFBN.js";
|
|
23
23
|
import "./chunk-MM5FFQJT.js";
|
|
24
24
|
import "./chunk-4TKUTT24.js";
|
|
25
25
|
import "./chunk-KEXKKQVW.js";
|
|
@@ -389,7 +389,7 @@ import { Command } from "commander";
|
|
|
389
389
|
var loadVersionCommand = (program2) => {
|
|
390
390
|
return program2.addCommand(
|
|
391
391
|
new Command("version").description("cli version").action(() => {
|
|
392
|
-
console.log("0.52.
|
|
392
|
+
console.log("0.52.2");
|
|
393
393
|
})
|
|
394
394
|
);
|
|
395
395
|
};
|
|
@@ -399,7 +399,7 @@ var { loadEnvConfig } = pkg;
|
|
|
399
399
|
loadEnvConfig(process.cwd());
|
|
400
400
|
var { cleanedArgv, overrides } = extractOverrides(process.argv.slice(2));
|
|
401
401
|
var program = new Command2();
|
|
402
|
-
program.name("axiom").description("Axiom's CLI to manage your objects and run evals").version("0.52.
|
|
402
|
+
program.name("axiom").description("Axiom's CLI to manage your objects and run evals").version("0.52.2");
|
|
403
403
|
program.hook("preAction", async (_, actionCommand) => {
|
|
404
404
|
const commandName = actionCommand.name();
|
|
405
405
|
const parentCommand = actionCommand.parent;
|
|
@@ -2,19 +2,19 @@ import {
|
|
|
2
2
|
getConsoleUrl,
|
|
3
3
|
loadConfig,
|
|
4
4
|
u
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-SH524JF2.js";
|
|
6
6
|
import {
|
|
7
7
|
dotNotationToNested,
|
|
8
8
|
flattenObject,
|
|
9
9
|
getAxiomConfig
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-S3BXNQXD.js";
|
|
11
11
|
import {
|
|
12
12
|
AxiomCLIError,
|
|
13
13
|
errorToString
|
|
14
14
|
} from "./chunk-ISSDOC43.js";
|
|
15
15
|
import {
|
|
16
16
|
initAxiomAI
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-J46CMFBN.js";
|
|
18
18
|
import {
|
|
19
19
|
__publicField
|
|
20
20
|
} from "./chunk-KEXKKQVW.js";
|
|
@@ -649,11 +649,11 @@ function setupEvalProvider(connection) {
|
|
|
649
649
|
axiomProvider = new NodeTracerProvider({
|
|
650
650
|
resource: resourceFromAttributes({
|
|
651
651
|
["service.name"]: "axiom",
|
|
652
|
-
["service.version"]: "0.52.
|
|
652
|
+
["service.version"]: "0.52.2"
|
|
653
653
|
}),
|
|
654
654
|
spanProcessors: [processor]
|
|
655
655
|
});
|
|
656
|
-
axiomTracer = axiomProvider.getTracer("axiom", "0.52.
|
|
656
|
+
axiomTracer = axiomProvider.getTracer("axiom", "0.52.2");
|
|
657
657
|
}
|
|
658
658
|
async function initInstrumentation(config) {
|
|
659
659
|
if (initialized) {
|
|
@@ -665,7 +665,7 @@ async function initInstrumentation(config) {
|
|
|
665
665
|
}
|
|
666
666
|
initializationPromise = (async () => {
|
|
667
667
|
if (!config.enabled) {
|
|
668
|
-
axiomTracer = trace.getTracer("axiom", "0.52.
|
|
668
|
+
axiomTracer = trace.getTracer("axiom", "0.52.2");
|
|
669
669
|
initialized = true;
|
|
670
670
|
return;
|
|
671
671
|
}
|
|
@@ -780,4 +780,4 @@ export {
|
|
|
780
780
|
startSpan,
|
|
781
781
|
startActiveSpan
|
|
782
782
|
};
|
|
783
|
-
//# sourceMappingURL=chunk-
|
|
783
|
+
//# sourceMappingURL=chunk-H3AJU7H6.js.map
|
|
@@ -24,7 +24,7 @@ var RedactionPolicy = {
|
|
|
24
24
|
mirrorToolPayloadOnToolSpan: false
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
-
var AXIOM_AI_REDACTION_KEY = Symbol.for("__axiom_ai_redaction__");
|
|
27
|
+
var AXIOM_AI_REDACTION_KEY = /* @__PURE__ */ Symbol.for("__axiom_ai_redaction__");
|
|
28
28
|
function getGlobalRedactionPolicy() {
|
|
29
29
|
return globalThis[AXIOM_AI_REDACTION_KEY];
|
|
30
30
|
}
|
|
@@ -62,7 +62,7 @@ import { trace } from "@opentelemetry/api";
|
|
|
62
62
|
// package.json
|
|
63
63
|
var package_default = {
|
|
64
64
|
name: "axiom",
|
|
65
|
-
version: "0.52.
|
|
65
|
+
version: "0.52.2",
|
|
66
66
|
type: "module",
|
|
67
67
|
author: "Axiom, Inc.",
|
|
68
68
|
contributors: [
|
|
@@ -134,16 +134,16 @@ var package_default = {
|
|
|
134
134
|
license: "MIT",
|
|
135
135
|
dependencies: {
|
|
136
136
|
"@next/env": "^15.4.2",
|
|
137
|
-
"@opentelemetry/auto-instrumentations-node": "^0.
|
|
137
|
+
"@opentelemetry/auto-instrumentations-node": "^0.75.0",
|
|
138
138
|
"@opentelemetry/context-async-hooks": "^2.0.1",
|
|
139
|
-
"@opentelemetry/exporter-trace-otlp-http": "
|
|
139
|
+
"@opentelemetry/exporter-trace-otlp-http": "0.217.0",
|
|
140
140
|
"@opentelemetry/resources": "^2.0.1",
|
|
141
141
|
"@opentelemetry/sdk-trace-node": "^2.0.1",
|
|
142
142
|
"@opentelemetry/semantic-conventions": "^1.38.0",
|
|
143
143
|
"@sinclair/typebox": "^0.34.37",
|
|
144
144
|
c12: "^3.3.3",
|
|
145
145
|
commander: "^14.0.0",
|
|
146
|
-
defu: "^6.1.
|
|
146
|
+
defu: "^6.1.7",
|
|
147
147
|
handlebars: "^4.7.8",
|
|
148
148
|
nanoid: "^5.1.5",
|
|
149
149
|
open: "^10.1.0",
|
|
@@ -199,7 +199,7 @@ var package_default = {
|
|
|
199
199
|
};
|
|
200
200
|
|
|
201
201
|
// src/otel/initAxiomAI.ts
|
|
202
|
-
var AXIOM_AI_SCOPE_KEY = Symbol.for("__axiom_ai_scope__");
|
|
202
|
+
var AXIOM_AI_SCOPE_KEY = /* @__PURE__ */ Symbol.for("__axiom_ai_scope__");
|
|
203
203
|
function extractTracerScope(tracer) {
|
|
204
204
|
const tracerAny = tracer;
|
|
205
205
|
const name = tracerAny._instrumentationScope?.name || tracerAny.instrumentationLibrary?.name || package_default.name;
|
|
@@ -259,4 +259,4 @@ export {
|
|
|
259
259
|
getGlobalTracer,
|
|
260
260
|
resetAxiomAI
|
|
261
261
|
};
|
|
262
|
-
//# sourceMappingURL=chunk-
|
|
262
|
+
//# sourceMappingURL=chunk-J46CMFBN.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/otel/utils/redaction.ts","../src/otel/withSpanBaggageKey.ts","../src/otel/initAxiomAI.ts","../package.json"],"sourcesContent":["import { context, propagation, type Baggage, type Span } from '@opentelemetry/api';\nimport { WITHSPAN_REDACTION_POLICY_KEY } from '../withSpanBaggageKey';\n\ntype CaptureMessageContent = 'full' | 'off';\n\nexport type AxiomAIRedactionPolicy = {\n captureMessageContent?: CaptureMessageContent;\n mirrorToolPayloadOnToolSpan?: boolean;\n};\n\nexport const RedactionPolicy = {\n /**\n * Includes message content on chat spans, and mirrors tool\n * payload on tool spans for more convenient querying.\n */\n AxiomDefault: {\n captureMessageContent: 'full',\n mirrorToolPayloadOnToolSpan: true,\n },\n /**\n * Redacts message content on chat spans, and does not put\n * tool payload on tool spans.\n */\n OpenTelemetryDefault: {\n captureMessageContent: 'off',\n mirrorToolPayloadOnToolSpan: false,\n },\n} as const satisfies Record<string, AxiomAIRedactionPolicy>;\n\n// Global key to store redaction policy across all execution contexts\nexport const AXIOM_AI_REDACTION_KEY = Symbol.for('__axiom_ai_redaction__');\n\n/**\n * Get the globally stored redaction policy\n * @returns The global redaction policy or undefined if not set\n */\nfunction getGlobalRedactionPolicy(): AxiomAIRedactionPolicy | undefined {\n return (globalThis as any)[AXIOM_AI_REDACTION_KEY];\n}\n\n/**\n * Resolves the effective redaction policy by merging global and per-call policies.\n * Per-call policies take precedence over global policies.\n *\n * @param globalPolicy - The global redaction policy from initAxiomAI\n * @param localPolicy - The per-call redaction policy from withSpan or middleware\n * @returns The effective redaction policy with all fields resolved\n */\nfunction getEffectiveRedactionPolicy(\n globalPolicy?: AxiomAIRedactionPolicy,\n localPolicy?: AxiomAIRedactionPolicy,\n): AxiomAIRedactionPolicy {\n // Per-call policy overrides global policy, with defaults\n return {\n captureMessageContent:\n localPolicy?.captureMessageContent ??\n globalPolicy?.captureMessageContent ??\n RedactionPolicy.AxiomDefault.captureMessageContent,\n mirrorToolPayloadOnToolSpan:\n localPolicy?.mirrorToolPayloadOnToolSpan ??\n globalPolicy?.mirrorToolPayloadOnToolSpan ??\n RedactionPolicy.AxiomDefault.mirrorToolPayloadOnToolSpan,\n };\n}\n\n/**\n * Get the active redaction policy\n */\nexport function getRedactionPolicy() {\n return getEffectiveRedactionPolicy(getGlobalRedactionPolicy(), getPerCallRedactionPolicy());\n}\n\n/**\n * Conditionally sets a span attribute based on the capture message content policy.\n * When policy is 'off', the attribute is not set at all.\n *\n * @param span - The OpenTelemetry span to set the attribute on\n * @param attribute - The attribute name/key\n * @param value - The attribute value\n * @param captureMessageContent - The capture policy ('full' sets attribute, 'off' skips it)\n */\nexport function handleMaybeRedactedAttribute(\n span: Span,\n attribute: string,\n value: any,\n captureMessageContent?: CaptureMessageContent,\n): void {\n if (captureMessageContent === 'full') {\n span.setAttribute(attribute, value);\n }\n\n // For 'off', don't set the attribute at all\n // Future: Could add callback-based redaction here\n}\n\n/**\n * Extracts the per-call redaction policy from OpenTelemetry baggage context.\n * This allows middleware and tools to access redaction policies passed via withSpan.\n *\n * @returns The per-call redaction policy or undefined if not set\n */\nfunction getPerCallRedactionPolicy(): AxiomAIRedactionPolicy | undefined {\n const baggage: Baggage = propagation.getBaggage(context.active()) || propagation.createBaggage();\n const serializedPolicy = baggage.getEntry(WITHSPAN_REDACTION_POLICY_KEY)?.value;\n\n if (!serializedPolicy) {\n return undefined;\n }\n\n try {\n return JSON.parse(serializedPolicy) as AxiomAIRedactionPolicy;\n } catch (error) {\n console.warn('[AxiomAI] Failed to parse redaction policy from baggage:', error);\n return undefined;\n }\n}\n","/**\n * We need a way to know that we're inside `withSpan`\n * Because we don't own `generateText` and similar functions,\n * we use OTel Baggage to propagate this information. Another\n * consideration might be to use AsyncLocalStorage in Node and\n * some kind of KV in workerd.\n */\nexport const WITHSPAN_BAGGAGE_KEY = '__withspan_gen_ai_call';\nexport const WITHSPAN_REDACTION_POLICY_KEY = '__withspan_redaction_policy';\n","import type { Tracer } from '@opentelemetry/api';\nimport { trace } from '@opentelemetry/api';\nimport packageJson from '../../package.json';\nimport { AXIOM_AI_REDACTION_KEY, type AxiomAIRedactionPolicy } from './utils/redaction';\n\n// Global key to store tracer scope information across all execution contexts\nconst AXIOM_AI_SCOPE_KEY = Symbol.for('__axiom_ai_scope__');\n\ninterface TracerScope {\n name: string;\n version?: string;\n}\n\n/**\n * Extract scope information from a tracer, with fallback to package.json\n */\nfunction extractTracerScope(tracer: Tracer): TracerScope {\n const tracerAny = tracer as any;\n\n // Guard access to private fields with optional chaining\n // Note: These are internal OTEL fields that may change in future versions\n // _instrumentationScope is modern, instrumentationLibrary is legacy (<1.16)\n const name =\n tracerAny._instrumentationScope?.name ||\n tracerAny.instrumentationLibrary?.name ||\n packageJson.name;\n\n const version =\n tracerAny._instrumentationScope?.version ||\n tracerAny.instrumentationLibrary?.version ||\n packageJson.version;\n\n return { name, version };\n}\n\n/**\n * Register this in your `instrumentation.ts` to set up axiom.\n * This function stores the tracer's scope information globally to enable Context Propagation\n * and Instrumentation Scope. The tracer will be available across all execution contexts including Next.js.\n *\n * This function is idempotent - calling it multiple times with the same scope has no additional cost.\n *\n * @param config\n * @param config.tracer - The tracer that you are using in your application.\n * @param config.redactionPolicy - Optional redaction policy to control what data is captured in spans.\n */\nexport function initAxiomAI(config: { tracer: Tracer; redactionPolicy?: AxiomAIRedactionPolicy }) {\n const newScope = extractTracerScope(config.tracer);\n const existingScope = (globalThis as any)[AXIOM_AI_SCOPE_KEY] as TracerScope | undefined;\n\n // Check if already initialized with same scope (idempotent behavior)\n if (\n existingScope &&\n existingScope.name === newScope.name &&\n existingScope.version === newScope.version\n ) {\n return;\n }\n\n // Warn about double initialization with different scopes\n if (existingScope) {\n console.warn(\n '[AxiomAI] initAxiomAI() called multiple times with different scopes. ' +\n `Previous: ${existingScope.name}@${existingScope.version}, ` +\n `New: ${newScope.name}@${newScope.version}`,\n );\n }\n\n // Store scope information globally (works across Next.js contexts)\n (globalThis as any)[AXIOM_AI_SCOPE_KEY] = newScope;\n\n // Store redaction policy globally if provided\n if (config.redactionPolicy) {\n (globalThis as any)[AXIOM_AI_REDACTION_KEY] = config.redactionPolicy;\n }\n}\n\n/**\n * Get a tracer using the globally stored scope information\n * Fall back to package.json defaults if not set\n */\nexport function getGlobalTracer(): Tracer {\n // Get stored scope information or fall back to package defaults\n const scope = (globalThis as any)[AXIOM_AI_SCOPE_KEY] as TracerScope | undefined;\n\n // Warn if initAxiomAI was never called\n if (!scope) {\n const isDebug = process.env.AXIOM_DEBUG === 'true';\n if (!isDebug) {\n console.warn(\n '[AxiomAI] AXIOM_AI_SCOPE_KEY is undefined. This probably means that ' +\n 'initAxiomAI() was never called. ' +\n 'Make sure to call initAxiomAI({ tracer }) in your instrumentation setup.',\n );\n }\n }\n\n let { name, version } = scope || { name: packageJson.name, version: packageJson.version };\n\n if (!name || !version) {\n name = packageJson.name;\n version = packageJson.version;\n if (!name || !version) {\n name = 'axiom';\n version = 'unknown';\n }\n }\n\n // Use OpenTelemetry's standard global provider mechanism\n return trace.getTracer(name, version);\n}\n\n/**\n * Reset AxiomAI configuration (useful for testing)\n */\nexport function resetAxiomAI() {\n (globalThis as any)[AXIOM_AI_SCOPE_KEY] = undefined;\n (globalThis as any)[AXIOM_AI_REDACTION_KEY] = undefined;\n}\n","{\n \"name\": \"axiom\",\n \"version\": \"0.52.0\",\n \"type\": \"module\",\n \"author\": \"Axiom, Inc.\",\n \"contributors\": [\n \"Islam Shehata <islam@axiom.co>\",\n \"Chris Ehrlich <chris@axiom.co>\",\n \"Gabriel de Andrade <gabriel@axiom.co>\"\n ],\n \"scripts\": {\n \"dev\": \"tsup --watch\",\n \"build\": \"tsup && chmod +x dist/bin.js && typedoc && pnpm check:vitest-entrypoints\",\n \"check:vitest-entrypoints\": \"node ./scripts/check-vitest-entrypoints.mjs\",\n \"format\": \"prettier --write .\",\n \"format:check\": \"prettier --check .\",\n \"lint\": \"eslint './**/*.{js,ts}'\",\n \"typecheck\": \"tsc --noEmit\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest --watch\",\n \"test:wrangler-smoke\": \"pnpm build && vitest run --config vitest.smoke.config.ts\",\n \"publint\": \"npx publint\"\n },\n \"types\": \"./dist/index.d.ts\",\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.js\",\n \"bin\": {\n \"axiom\": \"./dist/bin.js\"\n },\n \"exports\": {\n \"./ai\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"./ai/evals\": {\n \"types\": \"./dist/evals.d.ts\",\n \"default\": \"./dist/evals.js\"\n },\n \"./ai/evals/online\": {\n \"types\": \"./dist/evals/online.d.ts\",\n \"default\": \"./dist/evals/online.js\"\n },\n \"./ai/scorers\": {\n \"types\": \"./dist/scorers/scorers.d.ts\",\n \"default\": \"./dist/scorers/scorers.js\"\n },\n \"./ai/scorers/aggregations\": {\n \"types\": \"./dist/scorers/aggregations.d.ts\",\n \"default\": \"./dist/scorers/aggregations.js\"\n },\n \"./ai/config\": {\n \"types\": \"./dist/config.d.ts\",\n \"default\": \"./dist/config.js\"\n },\n \"./ai/feedback\": {\n \"types\": \"./dist/feedback.d.ts\",\n \"default\": \"./dist/feedback.js\"\n }\n },\n \"keywords\": [\n \"axiom\",\n \"logging\",\n \"ai\",\n \"otel\",\n \"opentelemetry\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/axiomhq/ai.git\",\n \"directory\": \"packages/ai\"\n },\n \"license\": \"MIT\",\n \"dependencies\": {\n \"@next/env\": \"^15.4.2\",\n \"@opentelemetry/auto-instrumentations-node\": \"^0.60.1\",\n \"@opentelemetry/context-async-hooks\": \"^2.0.1\",\n \"@opentelemetry/exporter-trace-otlp-http\": \"^0.202.0\",\n \"@opentelemetry/resources\": \"^2.0.1\",\n \"@opentelemetry/sdk-trace-node\": \"^2.0.1\",\n \"@opentelemetry/semantic-conventions\": \"^1.38.0\",\n \"@sinclair/typebox\": \"^0.34.37\",\n \"c12\": \"^3.3.3\",\n \"commander\": \"^14.0.0\",\n \"defu\": \"^6.1.4\",\n \"handlebars\": \"^4.7.8\",\n \"nanoid\": \"^5.1.5\",\n \"open\": \"^10.1.0\",\n \"vite-tsconfig-paths\": \"^5.1.4\",\n \"vitest\": \"^4.0.0\"\n },\n \"peerDependencies\": {\n \"@opentelemetry/api\": \"^1.9.0\",\n \"typescript\": \">=5.4\",\n \"zod\": \"^3.25.0 || ^4.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"typescript\": {\n \"optional\": true\n }\n },\n \"devDependencies\": {\n \"@ai-sdk/anthropicv1\": \"npm:@ai-sdk/anthropic@^1.2.12\",\n \"@ai-sdk/anthropicv2\": \"npm:@ai-sdk/anthropic@^2.0.57\",\n \"@ai-sdk/anthropicv3\": \"npm:@ai-sdk/anthropic@^3.0.9\",\n \"@ai-sdk/openaiv1\": \"npm:@ai-sdk/openai@^1.3.24\",\n \"@ai-sdk/openaiv2\": \"npm:@ai-sdk/openai@^2.0.88\",\n \"@ai-sdk/openaiv3\": \"npm:@ai-sdk/openai@^3.0.7\",\n \"@ai-sdk/providerv1\": \"npm:@ai-sdk/provider@^1.1.3\",\n \"@ai-sdk/providerv2\": \"npm:@ai-sdk/provider@^2.0.1\",\n \"@ai-sdk/providerv3\": \"npm:@ai-sdk/provider@^3.0.2\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/core\": \"^2.0.1\",\n \"@opentelemetry/sdk-trace-base\": \"^2.0.1\",\n \"@opentelemetry/sdk-trace-node\": \"^2.0.1\",\n \"@repo/eslint-config\": \"workspace:*\",\n \"@types/node\": \"^22.15.29\",\n \"@vitest/coverage-v8\": \"^4.0.0\",\n \"aiv4\": \"npm:ai@^4.3.19\",\n \"aiv5\": \"npm:ai@^5.0.118\",\n \"aiv6\": \"npm:ai@^6.0.6\",\n \"esbuild\": \"^0.25.8\",\n \"eslint\": \"catalog:\",\n \"msw\": \"^2.12.2\",\n \"prettier\": \"catalog:\",\n \"tinyrainbow\": \"^2.0.0\",\n \"tsup\": \"catalog:\",\n \"typedoc\": \"^0.28.17\",\n \"typedoc-plugin-markdown\": \"^4.10.0\",\n \"typescript\": \"catalog:\",\n \"vitest\": \"catalog:\",\n \"zod\": \"catalog:\"\n },\n \"files\": [\n \"dist\"\n ],\n \"packageManager\": \"pnpm@10.16.1\"\n}\n"],"mappings":";AAAA,SAAS,SAAS,mBAA4C;;;ACOvD,IAAM,uBAAuB;AAC7B,IAAM,gCAAgC;;;ADEtC,IAAM,kBAAkB;A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,SACnC;AACA;AAAA,EACF;AAGA,MAAI,eAAe;AACjB,YAAQ;AAAA,MACN,kFACe,cAAc,IAAI,IAAI,cAAc,OAAO,UAChD,SAAS,IAAI,IAAI,SAAS,OAAO;AAAA,IAC7C;AAAA,EACF;AAGA,EAAC,WAAmB,kBAAkB,IAAI;AAG1C,MAAI,OAAO,iBAAiB;AAC1B,IAAC,WAAmB,sBAAsB,IAAI,OAAO;AAAA,EACvD;AACF;AAMO,SAAS,kBAA0B;AAExC,QAAM,QAAS,WAAmB,kBAAkB;AAGpD,MAAI,CAAC,OAAO;AACV,UAAM,UAAU,QAAQ,IAAI,gBAAgB;AAC5C,QAAI,CAAC,SAAS;AACZ,cAAQ;AAAA,QACN;AAAA,MAGF;AAAA,IACF;AAAA,EACF;AAEA,MAAI,EAAE,MAAM,QAAQ,IAAI,SAAS,EAAE,MAAM,gBAAY,MAAM,SAAS,gBAAY,QAAQ;AAExF,MAAI,CAAC,QAAQ,CAAC,SAAS;AACrB,WAAO,gBAAY;AACnB,cAAU,gBAAY;AACtB,QAAI,CAAC,QAAQ,CAAC,SAAS;AACrB,aAAO;AACP,gBAAU;AAAA,IACZ;AAAA,EACF;AAGA,SAAO,MAAM,UAAU,MAAM,OAAO;AACtC;AAKO,SAAS,eAAe;AAC7B,EAAC,WAAmB,kBAAkB,IAAI;AAC1C,EAAC,WAAmB,sBAAsB,IAAI;AAChD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/otel/utils/redaction.ts","../src/otel/withSpanBaggageKey.ts","../src/otel/initAxiomAI.ts","../package.json"],"sourcesContent":["import { context, propagation, type Baggage, type Span } from '@opentelemetry/api';\nimport { WITHSPAN_REDACTION_POLICY_KEY } from '../withSpanBaggageKey';\n\ntype CaptureMessageContent = 'full' | 'off';\n\nexport type AxiomAIRedactionPolicy = {\n captureMessageContent?: CaptureMessageContent;\n mirrorToolPayloadOnToolSpan?: boolean;\n};\n\nexport const RedactionPolicy = {\n /**\n * Includes message content on chat spans, and mirrors tool\n * payload on tool spans for more convenient querying.\n */\n AxiomDefault: {\n captureMessageContent: 'full',\n mirrorToolPayloadOnToolSpan: true,\n },\n /**\n * Redacts message content on chat spans, and does not put\n * tool payload on tool spans.\n */\n OpenTelemetryDefault: {\n captureMessageContent: 'off',\n mirrorToolPayloadOnToolSpan: false,\n },\n} as const satisfies Record<string, AxiomAIRedactionPolicy>;\n\n// Global key to store redaction policy across all execution contexts\nexport const AXIOM_AI_REDACTION_KEY = Symbol.for('__axiom_ai_redaction__');\n\n/**\n * Get the globally stored redaction policy\n * @returns The global redaction policy or undefined if not set\n */\nfunction getGlobalRedactionPolicy(): AxiomAIRedactionPolicy | undefined {\n return (globalThis as any)[AXIOM_AI_REDACTION_KEY];\n}\n\n/**\n * Resolves the effective redaction policy by merging global and per-call policies.\n * Per-call policies take precedence over global policies.\n *\n * @param globalPolicy - The global redaction policy from initAxiomAI\n * @param localPolicy - The per-call redaction policy from withSpan or middleware\n * @returns The effective redaction policy with all fields resolved\n */\nfunction getEffectiveRedactionPolicy(\n globalPolicy?: AxiomAIRedactionPolicy,\n localPolicy?: AxiomAIRedactionPolicy,\n): AxiomAIRedactionPolicy {\n // Per-call policy overrides global policy, with defaults\n return {\n captureMessageContent:\n localPolicy?.captureMessageContent ??\n globalPolicy?.captureMessageContent ??\n RedactionPolicy.AxiomDefault.captureMessageContent,\n mirrorToolPayloadOnToolSpan:\n localPolicy?.mirrorToolPayloadOnToolSpan ??\n globalPolicy?.mirrorToolPayloadOnToolSpan ??\n RedactionPolicy.AxiomDefault.mirrorToolPayloadOnToolSpan,\n };\n}\n\n/**\n * Get the active redaction policy\n */\nexport function getRedactionPolicy() {\n return getEffectiveRedactionPolicy(getGlobalRedactionPolicy(), getPerCallRedactionPolicy());\n}\n\n/**\n * Conditionally sets a span attribute based on the capture message content policy.\n * When policy is 'off', the attribute is not set at all.\n *\n * @param span - The OpenTelemetry span to set the attribute on\n * @param attribute - The attribute name/key\n * @param value - The attribute value\n * @param captureMessageContent - The capture policy ('full' sets attribute, 'off' skips it)\n */\nexport function handleMaybeRedactedAttribute(\n span: Span,\n attribute: string,\n value: any,\n captureMessageContent?: CaptureMessageContent,\n): void {\n if (captureMessageContent === 'full') {\n span.setAttribute(attribute, value);\n }\n\n // For 'off', don't set the attribute at all\n // Future: Could add callback-based redaction here\n}\n\n/**\n * Extracts the per-call redaction policy from OpenTelemetry baggage context.\n * This allows middleware and tools to access redaction policies passed via withSpan.\n *\n * @returns The per-call redaction policy or undefined if not set\n */\nfunction getPerCallRedactionPolicy(): AxiomAIRedactionPolicy | undefined {\n const baggage: Baggage = propagation.getBaggage(context.active()) || propagation.createBaggage();\n const serializedPolicy = baggage.getEntry(WITHSPAN_REDACTION_POLICY_KEY)?.value;\n\n if (!serializedPolicy) {\n return undefined;\n }\n\n try {\n return JSON.parse(serializedPolicy) as AxiomAIRedactionPolicy;\n } catch (error) {\n console.warn('[AxiomAI] Failed to parse redaction policy from baggage:', error);\n return undefined;\n }\n}\n","/**\n * We need a way to know that we're inside `withSpan`\n * Because we don't own `generateText` and similar functions,\n * we use OTel Baggage to propagate this information. Another\n * consideration might be to use AsyncLocalStorage in Node and\n * some kind of KV in workerd.\n */\nexport const WITHSPAN_BAGGAGE_KEY = '__withspan_gen_ai_call';\nexport const WITHSPAN_REDACTION_POLICY_KEY = '__withspan_redaction_policy';\n","import type { Tracer } from '@opentelemetry/api';\nimport { trace } from '@opentelemetry/api';\nimport packageJson from '../../package.json';\nimport { AXIOM_AI_REDACTION_KEY, type AxiomAIRedactionPolicy } from './utils/redaction';\n\n// Global key to store tracer scope information across all execution contexts\nconst AXIOM_AI_SCOPE_KEY = Symbol.for('__axiom_ai_scope__');\n\ninterface TracerScope {\n name: string;\n version?: string;\n}\n\n/**\n * Extract scope information from a tracer, with fallback to package.json\n */\nfunction extractTracerScope(tracer: Tracer): TracerScope {\n const tracerAny = tracer as any;\n\n // Guard access to private fields with optional chaining\n // Note: These are internal OTEL fields that may change in future versions\n // _instrumentationScope is modern, instrumentationLibrary is legacy (<1.16)\n const name =\n tracerAny._instrumentationScope?.name ||\n tracerAny.instrumentationLibrary?.name ||\n packageJson.name;\n\n const version =\n tracerAny._instrumentationScope?.version ||\n tracerAny.instrumentationLibrary?.version ||\n packageJson.version;\n\n return { name, version };\n}\n\n/**\n * Register this in your `instrumentation.ts` to set up axiom.\n * This function stores the tracer's scope information globally to enable Context Propagation\n * and Instrumentation Scope. The tracer will be available across all execution contexts including Next.js.\n *\n * This function is idempotent - calling it multiple times with the same scope has no additional cost.\n *\n * @param config\n * @param config.tracer - The tracer that you are using in your application.\n * @param config.redactionPolicy - Optional redaction policy to control what data is captured in spans.\n */\nexport function initAxiomAI(config: { tracer: Tracer; redactionPolicy?: AxiomAIRedactionPolicy }) {\n const newScope = extractTracerScope(config.tracer);\n const existingScope = (globalThis as any)[AXIOM_AI_SCOPE_KEY] as TracerScope | undefined;\n\n // Check if already initialized with same scope (idempotent behavior)\n if (\n existingScope &&\n existingScope.name === newScope.name &&\n existingScope.version === newScope.version\n ) {\n return;\n }\n\n // Warn about double initialization with different scopes\n if (existingScope) {\n console.warn(\n '[AxiomAI] initAxiomAI() called multiple times with different scopes. ' +\n `Previous: ${existingScope.name}@${existingScope.version}, ` +\n `New: ${newScope.name}@${newScope.version}`,\n );\n }\n\n // Store scope information globally (works across Next.js contexts)\n (globalThis as any)[AXIOM_AI_SCOPE_KEY] = newScope;\n\n // Store redaction policy globally if provided\n if (config.redactionPolicy) {\n (globalThis as any)[AXIOM_AI_REDACTION_KEY] = config.redactionPolicy;\n }\n}\n\n/**\n * Get a tracer using the globally stored scope information\n * Fall back to package.json defaults if not set\n */\nexport function getGlobalTracer(): Tracer {\n // Get stored scope information or fall back to package defaults\n const scope = (globalThis as any)[AXIOM_AI_SCOPE_KEY] as TracerScope | undefined;\n\n // Warn if initAxiomAI was never called\n if (!scope) {\n const isDebug = process.env.AXIOM_DEBUG === 'true';\n if (!isDebug) {\n console.warn(\n '[AxiomAI] AXIOM_AI_SCOPE_KEY is undefined. This probably means that ' +\n 'initAxiomAI() was never called. ' +\n 'Make sure to call initAxiomAI({ tracer }) in your instrumentation setup.',\n );\n }\n }\n\n let { name, version } = scope || { name: packageJson.name, version: packageJson.version };\n\n if (!name || !version) {\n name = packageJson.name;\n version = packageJson.version;\n if (!name || !version) {\n name = 'axiom';\n version = 'unknown';\n }\n }\n\n // Use OpenTelemetry's standard global provider mechanism\n return trace.getTracer(name, version);\n}\n\n/**\n * Reset AxiomAI configuration (useful for testing)\n */\nexport function resetAxiomAI() {\n (globalThis as any)[AXIOM_AI_SCOPE_KEY] = undefined;\n (globalThis as any)[AXIOM_AI_REDACTION_KEY] = undefined;\n}\n","{\n \"name\": \"axiom\",\n \"version\": \"0.52.2\",\n \"type\": \"module\",\n \"author\": \"Axiom, Inc.\",\n \"contributors\": [\n \"Islam Shehata <islam@axiom.co>\",\n \"Chris Ehrlich <chris@axiom.co>\",\n \"Gabriel de Andrade <gabriel@axiom.co>\"\n ],\n \"scripts\": {\n \"dev\": \"tsup --watch\",\n \"build\": \"tsup && chmod +x dist/bin.js && typedoc && pnpm check:vitest-entrypoints\",\n \"check:vitest-entrypoints\": \"node ./scripts/check-vitest-entrypoints.mjs\",\n \"format\": \"prettier --write .\",\n \"format:check\": \"prettier --check .\",\n \"lint\": \"eslint './**/*.{js,ts}'\",\n \"typecheck\": \"tsc --noEmit\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest --watch\",\n \"test:wrangler-smoke\": \"pnpm build && vitest run --config vitest.smoke.config.ts\",\n \"publint\": \"npx publint\"\n },\n \"types\": \"./dist/index.d.ts\",\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.js\",\n \"bin\": {\n \"axiom\": \"./dist/bin.js\"\n },\n \"exports\": {\n \"./ai\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"./ai/evals\": {\n \"types\": \"./dist/evals.d.ts\",\n \"default\": \"./dist/evals.js\"\n },\n \"./ai/evals/online\": {\n \"types\": \"./dist/evals/online.d.ts\",\n \"default\": \"./dist/evals/online.js\"\n },\n \"./ai/scorers\": {\n \"types\": \"./dist/scorers/scorers.d.ts\",\n \"default\": \"./dist/scorers/scorers.js\"\n },\n \"./ai/scorers/aggregations\": {\n \"types\": \"./dist/scorers/aggregations.d.ts\",\n \"default\": \"./dist/scorers/aggregations.js\"\n },\n \"./ai/config\": {\n \"types\": \"./dist/config.d.ts\",\n \"default\": \"./dist/config.js\"\n },\n \"./ai/feedback\": {\n \"types\": \"./dist/feedback.d.ts\",\n \"default\": \"./dist/feedback.js\"\n }\n },\n \"keywords\": [\n \"axiom\",\n \"logging\",\n \"ai\",\n \"otel\",\n \"opentelemetry\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/axiomhq/ai.git\",\n \"directory\": \"packages/ai\"\n },\n \"license\": \"MIT\",\n \"dependencies\": {\n \"@next/env\": \"^15.4.2\",\n \"@opentelemetry/auto-instrumentations-node\": \"^0.75.0\",\n \"@opentelemetry/context-async-hooks\": \"^2.0.1\",\n \"@opentelemetry/exporter-trace-otlp-http\": \"0.217.0\",\n \"@opentelemetry/resources\": \"^2.0.1\",\n \"@opentelemetry/sdk-trace-node\": \"^2.0.1\",\n \"@opentelemetry/semantic-conventions\": \"^1.38.0\",\n \"@sinclair/typebox\": \"^0.34.37\",\n \"c12\": \"^3.3.3\",\n \"commander\": \"^14.0.0\",\n \"defu\": \"^6.1.7\",\n \"handlebars\": \"^4.7.8\",\n \"nanoid\": \"^5.1.5\",\n \"open\": \"^10.1.0\",\n \"vite-tsconfig-paths\": \"^5.1.4\",\n \"vitest\": \"^4.0.0\"\n },\n \"peerDependencies\": {\n \"@opentelemetry/api\": \"^1.9.0\",\n \"typescript\": \">=5.4\",\n \"zod\": \"^3.25.0 || ^4.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"typescript\": {\n \"optional\": true\n }\n },\n \"devDependencies\": {\n \"@ai-sdk/anthropicv1\": \"npm:@ai-sdk/anthropic@^1.2.12\",\n \"@ai-sdk/anthropicv2\": \"npm:@ai-sdk/anthropic@^2.0.57\",\n \"@ai-sdk/anthropicv3\": \"npm:@ai-sdk/anthropic@^3.0.9\",\n \"@ai-sdk/openaiv1\": \"npm:@ai-sdk/openai@^1.3.24\",\n \"@ai-sdk/openaiv2\": \"npm:@ai-sdk/openai@^2.0.88\",\n \"@ai-sdk/openaiv3\": \"npm:@ai-sdk/openai@^3.0.7\",\n \"@ai-sdk/providerv1\": \"npm:@ai-sdk/provider@^1.1.3\",\n \"@ai-sdk/providerv2\": \"npm:@ai-sdk/provider@^2.0.1\",\n \"@ai-sdk/providerv3\": \"npm:@ai-sdk/provider@^3.0.2\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/core\": \"^2.0.1\",\n \"@opentelemetry/sdk-trace-base\": \"^2.0.1\",\n \"@opentelemetry/sdk-trace-node\": \"^2.0.1\",\n \"@repo/eslint-config\": \"workspace:*\",\n \"@types/node\": \"^22.15.29\",\n \"@vitest/coverage-v8\": \"^4.0.0\",\n \"aiv4\": \"npm:ai@^4.3.19\",\n \"aiv5\": \"npm:ai@^5.0.118\",\n \"aiv6\": \"npm:ai@^6.0.6\",\n \"esbuild\": \"^0.25.8\",\n \"eslint\": \"catalog:\",\n \"msw\": \"^2.12.2\",\n \"prettier\": \"catalog:\",\n \"tinyrainbow\": \"^2.0.0\",\n \"tsup\": \"catalog:\",\n \"typedoc\": \"^0.28.17\",\n \"typedoc-plugin-markdown\": \"^4.10.0\",\n \"typescript\": \"catalog:\",\n \"vitest\": \"catalog:\",\n \"zod\": \"catalog:\"\n },\n \"files\": [\n \"dist\"\n ],\n \"packageManager\": \"pnpm@10.16.1\"\n}\n"],"mappings":";AAAA,SAAS,SAAS,mBAA4C;;;ACOvD,IAAM,uBAAuB;AAC7B,IAAM,gCAAgC;;;ADEtC,IAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA,EAK7B,cAAc;A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AACjB,YAAQ;AAAA,MACN,kFACe,cAAc,IAAI,IAAI,cAAc,OAAO,UAChD,SAAS,IAAI,IAAI,SAAS,OAAO;AAAA,IAC7C;AAAA,EACF;AAGA,EAAC,WAAmB,kBAAkB,IAAI;AAG1C,MAAI,OAAO,iBAAiB;AAC1B,IAAC,WAAmB,sBAAsB,IAAI,OAAO;AAAA,EACvD;AACF;AAMO,SAAS,kBAA0B;AAExC,QAAM,QAAS,WAAmB,kBAAkB;AAGpD,MAAI,CAAC,OAAO;AACV,UAAM,UAAU,QAAQ,IAAI,gBAAgB;AAC5C,QAAI,CAAC,SAAS;AACZ,cAAQ;AAAA,QACN;AAAA,MAGF;AAAA,IACF;AAAA,EACF;AAEA,MAAI,EAAE,MAAM,QAAQ,IAAI,SAAS,EAAE,MAAM,gBAAY,MAAM,SAAS,gBAAY,QAAQ;AAExF,MAAI,CAAC,QAAQ,CAAC,SAAS;AACrB,WAAO,gBAAY;AACnB,cAAU,gBAAY;AACtB,QAAI,CAAC,QAAQ,CAAC,SAAS;AACrB,aAAO;AACP,gBAAU;AAAA,IACZ;AAAA,EACF;AAGA,SAAO,MAAM,UAAU,MAAM,OAAO;AACtC;AAKO,SAAS,eAAe;AAC7B,EAAC,WAAmB,kBAAkB,IAAI;AAC1C,EAAC,WAAmB,sBAAsB,IAAI;AAChD;","names":[]}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AxiomCLIError
|
|
3
3
|
} from "./chunk-ISSDOC43.js";
|
|
4
|
+
import {
|
|
5
|
+
__publicField
|
|
6
|
+
} from "./chunk-KEXKKQVW.js";
|
|
4
7
|
|
|
5
8
|
// src/cli/auth/config.ts
|
|
6
9
|
import { promises as fs } from "fs";
|
|
@@ -83,7 +86,7 @@ var OAUTH_AUTH_PATH = "/oauth/authorize";
|
|
|
83
86
|
var OAUTH_TOKEN_PATH = "/oauth/token";
|
|
84
87
|
var OAuth = class {
|
|
85
88
|
constructor(oauthBaseUrl) {
|
|
86
|
-
this
|
|
89
|
+
__publicField(this, "oauthBaseUrl", oauthBaseUrl);
|
|
87
90
|
}
|
|
88
91
|
static generateCodeVerifier() {
|
|
89
92
|
return randomBytes(32).toString("base64url");
|
|
@@ -411,4 +414,4 @@ export {
|
|
|
411
414
|
createPartialDefaults,
|
|
412
415
|
validateConfig
|
|
413
416
|
};
|
|
414
|
-
//# sourceMappingURL=chunk-
|
|
417
|
+
//# sourceMappingURL=chunk-JOJAEFHB.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli/auth/config.ts","../src/cli/auth/global-auth.ts","../src/config/index.ts","../src/cli/auth/oauth.ts","../src/cli/auth/api.ts","../src/cli/auth/callback-server.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport path from 'path';\nimport os from 'os';\nimport type { Config, Profile } from './types';\n\nconst CONFIG_FILENAME = 'config.json';\nconst CONFIG_DIR_NAME = 'axiom';\n\n/**\n * Gets the OS-appropriate config directory path.\n * - Linux/Unix: ~/.config/axiom\n * - macOS: ~/Library/Application Support/axiom\n * - Windows: %APPDATA%\\axiom\n */\nexport function getConfigDir(): string {\n const platform = process.platform;\n const homeDir = os.homedir();\n\n // Linux/Unix: ~/.config/axiom (or $XDG_CONFIG_HOME/axiom if set)\n const xdgConfigHome = process.env.XDG_CONFIG_HOME;\n if (xdgConfigHome) {\n return path.join(xdgConfigHome, CONFIG_DIR_NAME);\n }\n\n if (platform === 'win32') {\n // Windows: %APPDATA%\\axiom\n const appData = process.env.APPDATA;\n if (appData) {\n return path.join(appData, CONFIG_DIR_NAME);\n }\n // Fallback to home directory if APPDATA is not set\n return path.join(homeDir, 'AppData', 'Roaming', CONFIG_DIR_NAME);\n }\n\n return path.join(homeDir, '.config', CONFIG_DIR_NAME);\n}\n\n/**\n * Gets the full path to the config file.\n */\nexport function getGlobalConfigPath(): string {\n return path.join(getConfigDir(), CONFIG_FILENAME);\n}\n\nexport async function loadGlobalConfig(): Promise<Config> {\n const configPath = getGlobalConfigPath();\n try {\n const content = await fs.readFile(configPath, 'utf-8');\n return JSON.parse(content);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return { profiles: {} };\n }\n throw error;\n }\n}\n\nexport async function saveGlobalConfig(config: Config): Promise<void> {\n const configPath = getGlobalConfigPath();\n const configDir = path.dirname(configPath);\n const content = JSON.stringify(config, null, 2);\n\n // Ensure config directory exists\n await fs.mkdir(configDir, { recursive: true, mode: 0o700 });\n\n // Write config file\n await fs.writeFile(configPath, content, 'utf-8');\n\n // Set restrictive permissions (read/write for owner only)\n // Note: chmod is a no-op on Windows, but that's fine\n await fs.chmod(configPath, 0o600);\n}\n\nexport function getActiveProfile(config: Config): Profile | null {\n // Get from config\n const profileName = config.active_profile;\n if (!profileName) return null;\n\n const profile = config.profiles[profileName];\n if (!profile) return null;\n\n return profile;\n}\n","import { loadGlobalConfig, getActiveProfile } from './config';\n\nexport interface AuthContext {\n readonly token: string;\n readonly url: string;\n readonly orgId: string;\n}\n\n/**\n * Module-level store for auth context.\n * This provides explicit, type-safe access to auth credentials.\n */\nlet authContext: AuthContext | null = null;\n\n/**\n * Gets the current auth context.\n * Returns null if auth hasn't been set up yet.\n */\nexport function getAuthContext(): AuthContext | null {\n return authContext;\n}\n\n/**\n * Sets up authentication context by loading config and storing it.\n *\n * @throws {AxiomCLIError} If no active profile is found\n */\nexport async function setupGlobalAuth(): Promise<AuthContext | null> {\n const config = await loadGlobalConfig();\n const profile = getActiveProfile(config);\n if (profile) {\n // Store in module-level context for explicit access\n authContext = {\n token: profile.token,\n url: profile.url,\n orgId: profile.org_id,\n };\n }\n\n return authContext;\n}\n\n/**\n * Resets the auth context (useful for testing).\n */\nexport function resetAuthContext(): void {\n authContext = null;\n}\n","import type { TracerProvider } from '@opentelemetry/api';\nimport { type z } from 'zod';\nimport { AxiomCLIError } from '../util/errors';\nimport { getAuthContext } from '../cli/auth';\n\n/**\n * Utility type to make all properties in T required recursively.\n * Keeps the types as-is but removes the optionality.\n */\ntype DeepRequired<T> =\n T extends Array<infer U>\n ? Array<U>\n : T extends (...args: any[]) => any\n ? T\n : T extends object\n ? {\n [P in keyof T]-?: DeepRequired<T[P]>;\n }\n : T;\n\n/**\n * Axiom API connection configuration\n */\nexport interface AxiomConnectionConfig {\n /**\n * Axiom API URL\n * @default 'https://api.axiom.co'\n * @example 'https://api.axiom.co'\n */\n url?: string;\n\n /**\n * Axiom Edge URL for ingest and query operations.\n * When set, this URL is used for sending traces and querying data,\n * while the regular `url` is used for API/console operations.\n * Falls back to `url` if not specified.\n * @example 'https://eu-central-1.aws.edge.axiom.co'\n */\n edgeUrl?: string;\n\n /**\n * Axiom API token (can be undefined if not set)\n * @example process.env.AXIOM_TOKEN\n */\n token?: string | undefined;\n\n /**\n * Axiom dataset name\n * @example process.env.AXIOM_DATASET\n */\n dataset?: string;\n\n /**\n * Axiom organization ID\n * @example process.env.AXIOM_ORG_ID\n */\n orgId?: string;\n}\n\n/**\n * Options passed to the instrumentation hook\n * - url: string\n * - token: string\n * - dataset: string\n */\nexport interface AxiomEvalInstrumentationOptions {\n url: string;\n edgeUrl: string;\n token: string;\n dataset: string;\n orgId?: string;\n}\n\n/**\n * Result returned from the instrumentation hook\n */\nexport interface AxiomEvalInstrumentationResult {\n /**\n * TracerProvider to be flushed when eval finishes.\n *\n * If you use the NodeSDK or register your provider globally, you don't need to return it\n * here as the NodeSDK automatically flushes the global provider.\n *\n * Only return a provider if you want Axiom to explicitly flush it for you and it's not\n * registered as the global tracer provider.\n */\n provider?: TracerProvider;\n}\n\nexport type SyncAxiomEvalInstrumentationHook = (\n options: AxiomEvalInstrumentationOptions,\n) => AxiomEvalInstrumentationResult;\n\nexport type AsyncAxiomEvalInstrumentationHook = (\n options: AxiomEvalInstrumentationOptions,\n) => Promise<AxiomEvalInstrumentationResult>;\n\n/**\n * Hook function to initialize application OpenTelemetry instrumentation.\n * Called before eval execution with resolved Axiom connection details.\n *\n * @param options - Configuration options\n * @param options.url - Axiom API URL\n * @param options.token - Axiom API token\n * @param options.dataset - Axiom dataset name\n * @returns TracerProvider or Promise resolving to TracerProvider\n *\n * @example\n * ```typescript\n * instrumentation: ({ url, token, dataset }) => {\n * return setupAppInstrumentation({ url, token, dataset });\n * }\n * ```\n */\nexport type AxiomEvalInstrumentationHook = (\n options: AxiomEvalInstrumentationOptions,\n) => AxiomEvalInstrumentationResult | Promise<AxiomEvalInstrumentationResult>;\n\n/**\n * Axiom AI SDK base configuration (user-facing, all optional)\n */\nexport const DEFAULT_EVAL_INCLUDE = ['**/*.eval.{ts,js,mts,mjs,cts,cjs}'] as const;\n\nexport interface AxiomConfigBase {\n /**\n * Eval configuration settings\n *\n * @example\n * ```typescript\n * eval: {\n * url: process.env.AXIOM_URL,\n * token: process.env.AXIOM_TOKEN,\n * dataset: process.env.AXIOM_DATASET\n * }\n * ```\n */\n eval?: AxiomConnectionConfig & {\n /**\n * Zod schema for flag validation.\n * When provided, CLI flags (--flag.*) are validated against this schema\n * before eval execution begins.\n *\n * @example\n * ```typescript\n * import { z } from 'zod';\n *\n * export default defineConfig({\n * eval: {\n * flagSchema: z.object({\n * model: z.object({\n * temperature: z.number().min(0).max(2).default(0.7),\n * name: z.string().default('gpt-4o'),\n * }),\n * }),\n * }\n * });\n * ```\n */\n flagSchema?: z.ZodObject<any> | null;\n /**\n * Optional hook to initialize application OpenTelemetry instrumentation.\n * Called before eval execution with resolved Axiom connection details.\n * Return your configured tracer provider/tracer (or void) after registering them.\n */\n instrumentation?: AxiomEvalInstrumentationHook | null;\n /**\n * Timeout for eval execution in milliseconds\n * @default 60000\n */\n timeoutMs?: number;\n /**\n * Glob patterns to include when running evals\n * @default ['**\\/*.eval.{ts,js,mts,mjs,cts,cjs}']\n * @example ['**\\/*.eval.ts', 'tests/**\\/*.test.ts']\n */\n include?: string[];\n /**\n * Glob patterns to exclude when running evals\n * @default ['**\\/node_modules/**', '**\\/dist/**', '**\\/build/**']\n * @example ['**\\/node_modules/**', '**\\/.next/**']\n */\n exclude?: string[];\n /**\n * Optional Vitest config file to load for eval runs.\n *\n * When omitted or set to false, evals run without loading any Vitest config,\n * keeping them isolated from the application's Vite/Vitest plugin graph.\n *\n * @default false\n * @example './vitest.eval.config.ts'\n */\n vitestConfig?: string | false;\n };\n}\n\n/**\n * Resolved Axiom AI SDK configuration with all required keys.\n * This is the type returned after merging user config with defaults.\n *\n * Uses DeepRequired to ensure all optional properties from AxiomConfigBase\n * become required, preventing missing properties in the resolved config.\n */\nexport type ResolvedAxiomConfig = DeepRequired<AxiomConfigBase>;\n\n/**\n * Axiom AI SDK configuration with optional environment-specific overrides.\n *\n * Supports c12 environment overrides using $development, $production, etc.\n *\n * @example\n * ```typescript\n * export default defineConfig({\n * eval: {\n * url: process.env.AXIOM_URL,\n * token: process.env.AXIOM_TOKEN,\n * dataset: process.env.AXIOM_DATASET,\n * },\n * })\n * ```\n */\nexport interface AxiomConfig extends AxiomConfigBase {\n /**\n * Allow c12 environment-specific overrides ($development, $production, $test etc.)\n * but don't show them in autocomplete for now\n */\n [key: `$${string}`]: Partial<AxiomConfigBase> | undefined;\n}\n\n/**\n * Type-safe helper for defining Axiom configuration.\n *\n * @param config - The configuration object\n * @returns The same configuration object with type checking\n *\n * @example\n * ```typescript\n * import { defineConfig } from 'axiom/ai/config';\n *\n * export default defineConfig({\n * eval: {\n * url: process.env.AXIOM_URL,\n * token: process.env.AXIOM_TOKEN,\n * dataset: process.env.AXIOM_DATASET,\n * include: ['**\\/*.eval.{ts,js}'],\n * instrumentation: ({ url, token, dataset }) => setupAppInstrumentation({ url, token, dataset }),\n * },\n * });\n * ```\n */\nexport function defineConfig(config: AxiomConfig): AxiomConfig {\n return config;\n}\n\n/**\n * Create partial default configuration from auth context or environment variables.\n * Does not throw if required values are missing - validation happens after merge.\n *\n * @returns Partial configuration with defaults and auth/env var values\n * @internal\n */\nexport function createPartialDefaults(): Partial<AxiomConfigBase> {\n // Try to get auth context first (available when running via CLI)\n // Fall back to process.env for backward compatibility (e.g., when used outside CLI)\n let token: string | undefined;\n let url: string | undefined;\n let orgId: string | undefined;\n\n try {\n const authContext = getAuthContext();\n if (authContext) {\n token = authContext.token;\n url = authContext.url;\n orgId = authContext.orgId;\n }\n } catch {\n // Auth context not available, fall back to env vars\n }\n\n // Fall back to process.env if auth context not available\n token = token || process.env.AXIOM_TOKEN;\n url = url || process.env.AXIOM_URL;\n orgId = orgId || process.env.AXIOM_ORG_ID;\n\n // Edge URL for ingest and query operations\n const edgeUrl = process.env.AXIOM_EDGE_URL;\n\n return {\n eval: {\n url: url || 'https://api.axiom.co',\n edgeUrl: edgeUrl,\n orgId,\n token,\n dataset: process.env.AXIOM_DATASET,\n flagSchema: undefined,\n instrumentation: null,\n include: [...DEFAULT_EVAL_INCLUDE],\n exclude: [],\n timeoutMs: 60_000,\n vitestConfig: false,\n },\n };\n}\n\n/**\n * Validates and returns a fully resolved Axiom configuration.\n *\n * @param config - Partial configuration to validate\n * @returns Fully resolved configuration with all required fields\n * @throws {AxiomCLIError} If required fields are missing or invalid\n * @internal\n */\nexport function validateConfig(config: Partial<AxiomConfigBase>): ResolvedAxiomConfig {\n const errors: string[] = [];\n const isDebug = process.env.AXIOM_DEBUG === 'true';\n\n if (!isDebug) {\n if (!config.eval?.token) {\n errors.push(\n 'eval.token is required (set in axiom.config.ts or AXIOM_TOKEN environment variable)',\n );\n }\n if (!config.eval?.dataset) {\n errors.push(\n 'eval.dataset is required (set in axiom.config.ts or AXIOM_DATASET environment variable)',\n );\n }\n\n if (!config.eval?.url) {\n console.log(\n 'eval.url was not specified. Defaulting to `https://api.axiom.co`. Please set it in axiom.config.ts or AXIOM_URL environment variable if you want to use a different endpoint.',\n );\n }\n }\n\n const instrumentation = config.eval?.instrumentation;\n if (\n instrumentation !== null &&\n instrumentation !== undefined &&\n typeof instrumentation !== 'function'\n ) {\n errors.push(\n 'eval.instrumentation must be a function returning OTEL setup information or null.',\n );\n }\n\n const vitestConfig = config.eval?.vitestConfig;\n if (vitestConfig !== undefined && vitestConfig !== false && typeof vitestConfig !== 'string') {\n errors.push('eval.vitestConfig must be a string path or false.');\n }\n\n if (errors.length > 0) {\n throw new AxiomCLIError(`Invalid Axiom configuration:\\n - ${errors.join('\\n - ')}`);\n }\n\n return config as ResolvedAxiomConfig;\n}\n","import { randomBytes, createHash } from 'crypto';\nimport type { OAuthTokenResponse } from './types';\n\nconst OAUTH_CLIENT_ID = '264d906a404efc209b027f6595e6b616';\nconst OAUTH_AUTH_PATH = '/oauth/authorize';\nconst OAUTH_TOKEN_PATH = '/oauth/token';\n\nexport interface BuildAuthUrlParams {\n redirectUri: string;\n state: string;\n codeChallenge: string;\n}\n\nexport interface ExchangeCodeParams {\n code: string;\n redirectUri: string;\n codeVerifier: string;\n}\n\nexport class OAuth {\n constructor(private readonly oauthBaseUrl: string) {}\n\n static generateCodeVerifier(): string {\n return randomBytes(32).toString('base64url');\n }\n\n static generateCodeChallenge(verifier: string): string {\n return createHash('sha256').update(verifier).digest('base64url');\n }\n\n static generateState(): string {\n return randomBytes(16).toString('hex');\n }\n\n public buildAuthUrl(params: BuildAuthUrlParams): string {\n const url = new URL(OAUTH_AUTH_PATH, this.oauthBaseUrl);\n url.searchParams.set('client_id', OAUTH_CLIENT_ID);\n url.searchParams.set('redirect_uri', params.redirectUri);\n url.searchParams.set('response_type', 'code');\n url.searchParams.set('state', params.state);\n url.searchParams.set('code_challenge', params.codeChallenge);\n url.searchParams.set('code_challenge_method', 'S256');\n url.searchParams.set('scope', '*');\n return url.toString();\n }\n\n public async exchangeCodeForToken(params: ExchangeCodeParams): Promise<string> {\n const tokenUrl = new URL(OAUTH_TOKEN_PATH, this.oauthBaseUrl);\n\n const body = new URLSearchParams({\n grant_type: 'authorization_code',\n client_id: OAUTH_CLIENT_ID,\n code: params.code,\n redirect_uri: params.redirectUri,\n code_verifier: params.codeVerifier,\n });\n\n const response = await fetch(tokenUrl.toString(), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: body.toString(),\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(`Token exchange failed: ${response.status} ${errorText}`);\n }\n\n const data: OAuthTokenResponse = await response.json();\n return data.access_token;\n }\n}\n","import { AxiomCLIError } from '../../util/errors';\nimport type { Organization } from './types';\n\nexport async function fetchOrganizations(\n token: string,\n apiBaseUrl: string,\n): Promise<Organization[]> {\n const response = await fetch(`${apiBaseUrl}/v2/orgs`, {\n headers: {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw new AxiomCLIError(\n `Failed to fetch organizations: ${response.status} ${response.statusText}`,\n );\n }\n\n const data = await response.json();\n return data as Organization[];\n}\n\nexport async function verifyToken(\n token: string,\n orgId: string,\n apiBaseUrl: string,\n): Promise<boolean> {\n const response = await fetch(`${apiBaseUrl}/v2/user`, {\n headers: {\n Authorization: `Bearer ${token}`,\n 'X-Axiom-Org-Id': orgId,\n 'Content-Type': 'application/json',\n },\n });\n\n return response.ok;\n}\n","import http, { type IncomingMessage, type ServerResponse } from 'http';\nimport type { AddressInfo } from 'net';\n\nfunction escapeHtml(text: string): string {\n const map: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n '`': '`',\n };\n return text.replace(/[&<>\"']/g, (m) => map[m] || m);\n}\n\nconst SVG_LOGO = `<svg width=\"124\" height=\"24\" viewBox=\"0 0 124 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" class=\"logo\">\n<path d=\"M42.9919 16.8116H36.3696L35.5537 19.1572C35.4209 19.539 34.9714 19.8513 34.5548 19.8513H30.9779C30.5614 19.8513 30.3459 19.5449 30.499 19.1703L36.9816 3.31644C37.1346 2.9419 37.6009 2.63546 38.0174 2.63546H41.3718C41.7883 2.63546 42.2541 2.94207 42.4067 3.3168L48.8634 19.17C49.016 19.5447 48.8 19.8513 48.3835 19.8513H44.8067C44.3901 19.8513 43.9406 19.539 43.8078 19.1572L42.9919 16.8116ZM41.8232 13.4223L39.6807 7.18148L37.5383 13.4223H41.8232ZM64.1105 19.8513C63.694 19.8513 63.1767 19.5694 62.9611 19.2247L59.9029 14.3369L56.8447 19.2247C56.6291 19.5694 56.1119 19.8513 55.6953 19.8513H51.3392C50.9227 19.8513 50.7754 19.5801 51.0119 19.2486L56.8978 11.0013L51.5315 3.24414C51.2999 2.90937 51.4513 2.63546 51.8679 2.63546H55.89C56.3066 2.63546 56.8268 2.91563 57.0461 3.25807L59.9029 7.71959L62.7343 3.25955C62.9522 2.9163 63.4713 2.63546 63.8879 2.63546H67.938C68.3545 2.63546 68.5048 2.90868 68.272 3.24261L62.8801 10.9743L68.7935 19.2489C69.0303 19.5802 68.8832 19.8513 68.4666 19.8513H64.1105ZM76.525 19.119C76.525 19.5218 76.1841 19.8513 75.7675 19.8513H72.5522C72.1356 19.8513 71.7947 19.5218 71.7947 19.119V3.36771C71.7947 2.96498 72.1356 2.63546 72.5522 2.63546H75.7675C76.1841 2.63546 76.525 2.96498 76.525 3.36771V19.119ZM79.3736 11.1896C79.3736 6.18625 83.2688 2.15134 89.2511 2.15134C95.2334 2.15134 99.1289 6.18625 99.1289 11.1896C99.1289 16.2199 95.2334 20.2548 89.2511 20.2548C83.2688 20.2548 79.3736 16.2199 79.3736 11.1896ZM94.2873 11.1896C94.2873 8.58038 92.3953 6.21307 89.2511 6.21307C86.1349 6.21307 84.2149 8.58038 84.2149 11.1896C84.2149 13.7989 86.1349 16.2199 89.2511 16.2199C92.3675 16.2199 94.2873 13.7989 94.2873 11.1896ZM119.318 19.8513C118.902 19.8513 118.517 19.5245 118.463 19.1251L117.225 9.89847L113.65 19.1652C113.505 19.5426 113.045 19.8513 112.628 19.8513H111.055C110.638 19.8513 110.179 19.5423 110.034 19.1645L106.457 9.81766L105.218 19.125C105.165 19.5245 104.781 19.8513 104.364 19.8513H101.344C100.927 19.8513 100.633 19.5249 100.69 19.1259L102.932 3.3609C102.988 2.96191 103.376 2.63546 103.792 2.63546H106.59C107.007 2.63546 107.469 2.94351 107.617 3.32002L111.827 14.041L116.064 3.31949C116.213 2.94327 116.676 2.63546 117.092 2.63546H119.89C120.307 2.63546 120.694 2.96191 120.751 3.3609L122.993 19.1259C123.05 19.5249 122.755 19.8513 122.339 19.8513H119.318ZM23.9616 15.6531L18.8054 6.97021C18.5689 6.57115 17.9863 6.24465 17.5106 6.24465H14.2915C13.5433 6.24465 13.2365 5.73171 13.6097 5.1048L15.375 2.13986C15.5151 1.90455 15.5148 1.61487 15.3743 1.37981C15.2337 1.14476 14.9741 1 14.6933 1H10.2025C9.72681 1 9.14291 1.32577 8.90491 1.72395L0.17865 16.3217C-0.0594434 16.7199 -0.0595348 17.3715 0.178285 17.7698L2.42362 21.5297C2.79777 22.1561 3.41129 22.1569 3.78699 21.5313L5.54143 18.6103C5.91722 17.9847 6.53065 17.9854 6.9048 18.6119L8.49538 21.2754C8.7332 21.6737 9.317 21.9995 9.79273 21.9995H20.1698C20.6455 21.9995 21.2293 21.6737 21.4672 21.2754L23.959 17.1028C24.1968 16.7045 24.198 16.0521 23.9616 15.6531ZM16.9981 15.2352C17.3699 15.8629 17.0619 16.3765 16.3136 16.3765H8.24192C7.49372 16.3765 7.1876 15.864 7.56175 15.2375L11.6007 8.47417C11.9748 7.84772 12.5869 7.84774 12.9611 8.47421L16.9981 15.2352Z\" fill=\"#121224\"/>\n</svg>`;\n\nfunction renderCallbackPage(error?: string): string {\n const errorClass = error ? ' class=\"error\"' : '';\n const errorMessage = error ? escapeHtml(error) : '';\n\n return `<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n <title>Axiom</title>\n <link rel=\"icon\" href=\"https://app.axiom.co/static/favicon.ico\">\n <meta name=\"description\" content=\"Axiom CLI\">\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n <style>\n html,\n body,\n .root {\n width: 100%;\n height: 100%;\n text-rendering: optimizeLegibility;\n -webkit-font-smoothing: antialiased;\n }\n body {\n color: #334155;\n font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;\n font-size: 14px;\n font-weight: 500;\n font-variant: tabular-nums;\n line-height: 1.5;\n background-color: #fff;\n font-feature-settings: \"tnum\";\n margin: 0;\n }\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n margin-top: 0;\n margin-bottom: .5em;\n font-weight: 500;\n }\n p {\n margin-top: 0;\n margin-bottom: 1em;\n }\n h2 {\n font-size: 16px;\n font-weight: 600;\n }\n .root {\n display: flex;\n align-items: center;\n justify-content: center;\n }\n .logo {\n width: 92px;\n float: left;\n position: absolute;\n top: 16px;\n left: 16px;\n }\n .center p {\n padding: 8px 0;\n }\n .error .center {\n color: #bf0e08;\n }\n </style>\n</head>\n<body${errorClass}>\n <div class=\"root\">\n <a class=\"\" target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://axiom.co\">\n ${SVG_LOGO}\n </svg>\n </a>\n <div class=\"center\">\n ${\n error\n ? `<h2 id=\"msg\">Login failed</h2>\n <p id=\"details\">${errorMessage}</p>`\n : `<h2 id=\"msg\">Login successful</h2>\n <p id=\"details\">You can close this page and return to your CLI.</p>`\n }\n </div>\n </div>\n <script>\n window.history.replaceState({}, '', \\`\\${window.location.pathname}\\`);\n </script>\n</body>\n</html>`;\n}\n\nexport interface CallbackServerResult {\n server: http.Server;\n port: number;\n url: string;\n}\n\nexport async function startCallbackServer(): Promise<CallbackServerResult> {\n return new Promise((resolve) => {\n const server = http.createServer();\n server.listen(0, '127.0.0.1', () => {\n const address = server.address() as AddressInfo;\n resolve({\n server,\n port: address.port,\n url: `http://127.0.0.1:${address.port}`,\n });\n });\n });\n}\n\nexport interface CallbackResult {\n code: string;\n}\n\nexport async function waitForCallback(\n server: http.Server,\n expectedState: string,\n): Promise<CallbackResult> {\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(\n () => {\n server.close();\n reject(new Error('Authentication timeout after 5 minutes'));\n },\n 5 * 60 * 1000,\n ); // 5 minute timeout\n\n server.on('request', (req: IncomingMessage, res: ServerResponse) => {\n const url = new URL(req.url || '', `http://${req.headers.host}`);\n const code = url.searchParams.get('code');\n const state = url.searchParams.get('state');\n const error = url.searchParams.get('error');\n const errorDescription = url.searchParams.get('error_description');\n\n if (error) {\n const errorMsg = errorDescription || error;\n res.writeHead(400, { 'Content-Type': 'text/html' });\n res.end(renderCallbackPage(errorMsg));\n clearTimeout(timeout);\n server.close();\n reject(new Error(`OAuth error: ${errorMsg}`));\n return;\n }\n\n if (!code || !state) {\n res.writeHead(400, { 'Content-Type': 'text/html' });\n res.end(renderCallbackPage('Missing code or state parameter'));\n return;\n }\n\n if (state !== expectedState) {\n res.writeHead(400, { 'Content-Type': 'text/html' });\n res.end(renderCallbackPage('Invalid state parameter (CSRF protection)'));\n clearTimeout(timeout);\n server.close();\n reject(new Error('Invalid state parameter'));\n return;\n }\n\n res.writeHead(200, { 'Content-Type': 'text/html' });\n res.end(renderCallbackPage());\n\n clearTimeout(timeout);\n server.close();\n resolve({ code });\n });\n });\n}\n"],"mappings":";;;;;AAAA,SAAS,YAAY,UAAU;AAC/B,OAAO,UAAU;AACjB,OAAO,QAAQ;AAGf,IAAM,kBAAkB;AACxB,IAAM,kBAAkB;AAQjB,SAAS,eAAuB;AACrC,QAAM,WAAW,QAAQ;AACzB,QAAM,UAAU,GAAG,QAAQ;AAG3B,QAAM,gBAAgB,QAAQ,IAAI;AAClC,MAAI,eAAe;AACjB,WAAO,KAAK,KAAK,eAAe,eAAe;AAAA,EACjD;AAEA,MAAI,aAAa,SAAS;AAExB,UAAM,UAAU,QAAQ,IAAI;AAC5B,QAAI,SAAS;AACX,aAAO,KAAK,KAAK,SAAS,eAAe;AAAA,IAC3C;AAEA,WAAO,KAAK,KAAK,SAAS,WAAW,WAAW,eAAe;AAAA,EACjE;AAEA,SAAO,KAAK,KAAK,SAAS,WAAW,eAAe;A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AAAA,IACL,MAAM;AAAA,MACJ,KAAK,OAAO;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS,QAAQ,IAAI;AAAA,MACrB,YAAY;AAAA,MACZ,iBAAiB;AAAA,MACjB,SAAS,CAAC,GAAG,oBAAoB;AAAA,MACjC,SAAS,CAAC;AAAA,MACV,WAAW;AAAA,MACX,cAAc;AAAA,IAChB;AAAA,EACF;AACF;AAUO,SAAS,eAAe,QAAuD;AACpF,QAAM,SAAmB,CAAC;AAC1B,QAAM,UAAU,QAAQ,IAAI,gBAAgB;AAE5C,MAAI,CAAC,SAAS;AACZ,QAAI,CAAC,OAAO,MAAM,OAAO;AACvB,aAAO;AAAA,QACL;AAAA,MACF;AAAA,IACF;AACA,QAAI,CAAC,OAAO,MAAM,SAAS;AACzB,aAAO;AAAA,QACL;AAAA,MACF;AAAA,IACF;AAEA,QAAI,CAAC,OAAO,MAAM,KAAK;AACrB,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,kBAAkB,OAAO,MAAM;AACrC,MACE,oBAAoB,QACpB,oBAAoB,UACpB,OAAO,oBAAoB,YAC3B;AACA,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAEA,QAAM,eAAe,OAAO,MAAM;AAClC,MAAI,iBAAiB,UAAa,iBAAiB,SAAS,OAAO,iBAAiB,UAAU;AAC5F,WAAO,KAAK,mDAAmD;AAAA,EACjE;AAEA,MAAI,OAAO,SAAS,GAAG;AACrB,UAAM,IAAI,cAAc;AAAA,MAAqC,OAAO,KAAK,QAAQ,CAAC,EAAE;AAAA,EACtF;AAEA,SAAO;AACT;","names":["authContext"]}
|
|
1
|
+
{"version":3,"sources":["../src/cli/auth/config.ts","../src/cli/auth/global-auth.ts","../src/config/index.ts","../src/cli/auth/oauth.ts","../src/cli/auth/api.ts","../src/cli/auth/callback-server.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport path from 'path';\nimport os from 'os';\nimport type { Config, Profile } from './types';\n\nconst CONFIG_FILENAME = 'config.json';\nconst CONFIG_DIR_NAME = 'axiom';\n\n/**\n * Gets the OS-appropriate config directory path.\n * - Linux/Unix: ~/.config/axiom\n * - macOS: ~/Library/Application Support/axiom\n * - Windows: %APPDATA%\\axiom\n */\nexport function getConfigDir(): string {\n const platform = process.platform;\n const homeDir = os.homedir();\n\n // Linux/Unix: ~/.config/axiom (or $XDG_CONFIG_HOME/axiom if set)\n const xdgConfigHome = process.env.XDG_CONFIG_HOME;\n if (xdgConfigHome) {\n return path.join(xdgConfigHome, CONFIG_DIR_NAME);\n }\n\n if (platform === 'win32') {\n // Windows: %APPDATA%\\axiom\n const appData = process.env.APPDATA;\n if (appData) {\n return path.join(appData, CONFIG_DIR_NAME);\n }\n // Fallback to home directory if APPDATA is not set\n return path.join(homeDir, 'AppData', 'Roaming', CONFIG_DIR_NAME);\n }\n\n return path.join(homeDir, '.config', CONFIG_DIR_NAME);\n}\n\n/**\n * Gets the full path to the config file.\n */\nexport function getGlobalConfigPath(): string {\n return path.join(getConfigDir(), CONFIG_FILENAME);\n}\n\nexport async function loadGlobalConfig(): Promise<Config> {\n const configPath = getGlobalConfigPath();\n try {\n const content = await fs.readFile(configPath, 'utf-8');\n return JSON.parse(content);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return { profiles: {} };\n }\n throw error;\n }\n}\n\nexport async function saveGlobalConfig(config: Config): Promise<void> {\n const configPath = getGlobalConfigPath();\n const configDir = path.dirname(configPath);\n const content = JSON.stringify(config, null, 2);\n\n // Ensure config directory exists\n await fs.mkdir(configDir, { recursive: true, mode: 0o700 });\n\n // Write config file\n await fs.writeFile(configPath, content, 'utf-8');\n\n // Set restrictive permissions (read/write for owner only)\n // Note: chmod is a no-op on Windows, but that's fine\n await fs.chmod(configPath, 0o600);\n}\n\nexport function getActiveProfile(config: Config): Profile | null {\n // Get from config\n const profileName = config.active_profile;\n if (!profileName) return null;\n\n const profile = config.profiles[profileName];\n if (!profile) return null;\n\n return profile;\n}\n","import { loadGlobalConfig, getActiveProfile } from './config';\n\nexport interface AuthContext {\n readonly token: string;\n readonly url: string;\n readonly orgId: string;\n}\n\n/**\n * Module-level store for auth context.\n * This provides explicit, type-safe access to auth credentials.\n */\nlet authContext: AuthContext | null = null;\n\n/**\n * Gets the current auth context.\n * Returns null if auth hasn't been set up yet.\n */\nexport function getAuthContext(): AuthContext | null {\n return authContext;\n}\n\n/**\n * Sets up authentication context by loading config and storing it.\n *\n * @throws {AxiomCLIError} If no active profile is found\n */\nexport async function setupGlobalAuth(): Promise<AuthContext | null> {\n const config = await loadGlobalConfig();\n const profile = getActiveProfile(config);\n if (profile) {\n // Store in module-level context for explicit access\n authContext = {\n token: profile.token,\n url: profile.url,\n orgId: profile.org_id,\n };\n }\n\n return authContext;\n}\n\n/**\n * Resets the auth context (useful for testing).\n */\nexport function resetAuthContext(): void {\n authContext = null;\n}\n","import type { TracerProvider } from '@opentelemetry/api';\nimport { type z } from 'zod';\nimport { AxiomCLIError } from '../util/errors';\nimport { getAuthContext } from '../cli/auth';\n\n/**\n * Utility type to make all properties in T required recursively.\n * Keeps the types as-is but removes the optionality.\n */\ntype DeepRequired<T> =\n T extends Array<infer U>\n ? Array<U>\n : T extends (...args: any[]) => any\n ? T\n : T extends object\n ? {\n [P in keyof T]-?: DeepRequired<T[P]>;\n }\n : T;\n\n/**\n * Axiom API connection configuration\n */\nexport interface AxiomConnectionConfig {\n /**\n * Axiom API URL\n * @default 'https://api.axiom.co'\n * @example 'https://api.axiom.co'\n */\n url?: string;\n\n /**\n * Axiom Edge URL for ingest and query operations.\n * When set, this URL is used for sending traces and querying data,\n * while the regular `url` is used for API/console operations.\n * Falls back to `url` if not specified.\n * @example 'https://eu-central-1.aws.edge.axiom.co'\n */\n edgeUrl?: string;\n\n /**\n * Axiom API token (can be undefined if not set)\n * @example process.env.AXIOM_TOKEN\n */\n token?: string | undefined;\n\n /**\n * Axiom dataset name\n * @example process.env.AXIOM_DATASET\n */\n dataset?: string;\n\n /**\n * Axiom organization ID\n * @example process.env.AXIOM_ORG_ID\n */\n orgId?: string;\n}\n\n/**\n * Options passed to the instrumentation hook\n * - url: string\n * - token: string\n * - dataset: string\n */\nexport interface AxiomEvalInstrumentationOptions {\n url: string;\n edgeUrl: string;\n token: string;\n dataset: string;\n orgId?: string;\n}\n\n/**\n * Result returned from the instrumentation hook\n */\nexport interface AxiomEvalInstrumentationResult {\n /**\n * TracerProvider to be flushed when eval finishes.\n *\n * If you use the NodeSDK or register your provider globally, you don't need to return it\n * here as the NodeSDK automatically flushes the global provider.\n *\n * Only return a provider if you want Axiom to explicitly flush it for you and it's not\n * registered as the global tracer provider.\n */\n provider?: TracerProvider;\n}\n\nexport type SyncAxiomEvalInstrumentationHook = (\n options: AxiomEvalInstrumentationOptions,\n) => AxiomEvalInstrumentationResult;\n\nexport type AsyncAxiomEvalInstrumentationHook = (\n options: AxiomEvalInstrumentationOptions,\n) => Promise<AxiomEvalInstrumentationResult>;\n\n/**\n * Hook function to initialize application OpenTelemetry instrumentation.\n * Called before eval execution with resolved Axiom connection details.\n *\n * @param options - Configuration options\n * @param options.url - Axiom API URL\n * @param options.token - Axiom API token\n * @param options.dataset - Axiom dataset name\n * @returns TracerProvider or Promise resolving to TracerProvider\n *\n * @example\n * ```typescript\n * instrumentation: ({ url, token, dataset }) => {\n * return setupAppInstrumentation({ url, token, dataset });\n * }\n * ```\n */\nexport type AxiomEvalInstrumentationHook = (\n options: AxiomEvalInstrumentationOptions,\n) => AxiomEvalInstrumentationResult | Promise<AxiomEvalInstrumentationResult>;\n\n/**\n * Axiom AI SDK base configuration (user-facing, all optional)\n */\nexport const DEFAULT_EVAL_INCLUDE = ['**/*.eval.{ts,js,mts,mjs,cts,cjs}'] as const;\n\nexport interface AxiomConfigBase {\n /**\n * Eval configuration settings\n *\n * @example\n * ```typescript\n * eval: {\n * url: process.env.AXIOM_URL,\n * token: process.env.AXIOM_TOKEN,\n * dataset: process.env.AXIOM_DATASET\n * }\n * ```\n */\n eval?: AxiomConnectionConfig & {\n /**\n * Zod schema for flag validation.\n * When provided, CLI flags (--flag.*) are validated against this schema\n * before eval execution begins.\n *\n * @example\n * ```typescript\n * import { z } from 'zod';\n *\n * export default defineConfig({\n * eval: {\n * flagSchema: z.object({\n * model: z.object({\n * temperature: z.number().min(0).max(2).default(0.7),\n * name: z.string().default('gpt-4o'),\n * }),\n * }),\n * }\n * });\n * ```\n */\n flagSchema?: z.ZodObject<any> | null;\n /**\n * Optional hook to initialize application OpenTelemetry instrumentation.\n * Called before eval execution with resolved Axiom connection details.\n * Return your configured tracer provider/tracer (or void) after registering them.\n */\n instrumentation?: AxiomEvalInstrumentationHook | null;\n /**\n * Timeout for eval execution in milliseconds\n * @default 60000\n */\n timeoutMs?: number;\n /**\n * Glob patterns to include when running evals\n * @default ['**\\/*.eval.{ts,js,mts,mjs,cts,cjs}']\n * @example ['**\\/*.eval.ts', 'tests/**\\/*.test.ts']\n */\n include?: string[];\n /**\n * Glob patterns to exclude when running evals\n * @default ['**\\/node_modules/**', '**\\/dist/**', '**\\/build/**']\n * @example ['**\\/node_modules/**', '**\\/.next/**']\n */\n exclude?: string[];\n /**\n * Optional Vitest config file to load for eval runs.\n *\n * When omitted or set to false, evals run without loading any Vitest config,\n * keeping them isolated from the application's Vite/Vitest plugin graph.\n *\n * @default false\n * @example './vitest.eval.config.ts'\n */\n vitestConfig?: string | false;\n };\n}\n\n/**\n * Resolved Axiom AI SDK configuration with all required keys.\n * This is the type returned after merging user config with defaults.\n *\n * Uses DeepRequired to ensure all optional properties from AxiomConfigBase\n * become required, preventing missing properties in the resolved config.\n */\nexport type ResolvedAxiomConfig = DeepRequired<AxiomConfigBase>;\n\n/**\n * Axiom AI SDK configuration with optional environment-specific overrides.\n *\n * Supports c12 environment overrides using $development, $production, etc.\n *\n * @example\n * ```typescript\n * export default defineConfig({\n * eval: {\n * url: process.env.AXIOM_URL,\n * token: process.env.AXIOM_TOKEN,\n * dataset: process.env.AXIOM_DATASET,\n * },\n * })\n * ```\n */\nexport interface AxiomConfig extends AxiomConfigBase {\n /**\n * Allow c12 environment-specific overrides ($development, $production, $test etc.)\n * but don't show them in autocomplete for now\n */\n [key: `$${string}`]: Partial<AxiomConfigBase> | undefined;\n}\n\n/**\n * Type-safe helper for defining Axiom configuration.\n *\n * @param config - The configuration object\n * @returns The same configuration object with type checking\n *\n * @example\n * ```typescript\n * import { defineConfig } from 'axiom/ai/config';\n *\n * export default defineConfig({\n * eval: {\n * url: process.env.AXIOM_URL,\n * token: process.env.AXIOM_TOKEN,\n * dataset: process.env.AXIOM_DATASET,\n * include: ['**\\/*.eval.{ts,js}'],\n * instrumentation: ({ url, token, dataset }) => setupAppInstrumentation({ url, token, dataset }),\n * },\n * });\n * ```\n */\nexport function defineConfig(config: AxiomConfig): AxiomConfig {\n return config;\n}\n\n/**\n * Create partial default configuration from auth context or environment variables.\n * Does not throw if required values are missing - validation happens after merge.\n *\n * @returns Partial configuration with defaults and auth/env var values\n * @internal\n */\nexport function createPartialDefaults(): Partial<AxiomConfigBase> {\n // Try to get auth context first (available when running via CLI)\n // Fall back to process.env for backward compatibility (e.g., when used outside CLI)\n let token: string | undefined;\n let url: string | undefined;\n let orgId: string | undefined;\n\n try {\n const authContext = getAuthContext();\n if (authContext) {\n token = authContext.token;\n url = authContext.url;\n orgId = authContext.orgId;\n }\n } catch {\n // Auth context not available, fall back to env vars\n }\n\n // Fall back to process.env if auth context not available\n token = token || process.env.AXIOM_TOKEN;\n url = url || process.env.AXIOM_URL;\n orgId = orgId || process.env.AXIOM_ORG_ID;\n\n // Edge URL for ingest and query operations\n const edgeUrl = process.env.AXIOM_EDGE_URL;\n\n return {\n eval: {\n url: url || 'https://api.axiom.co',\n edgeUrl: edgeUrl,\n orgId,\n token,\n dataset: process.env.AXIOM_DATASET,\n flagSchema: undefined,\n instrumentation: null,\n include: [...DEFAULT_EVAL_INCLUDE],\n exclude: [],\n timeoutMs: 60_000,\n vitestConfig: false,\n },\n };\n}\n\n/**\n * Validates and returns a fully resolved Axiom configuration.\n *\n * @param config - Partial configuration to validate\n * @returns Fully resolved configuration with all required fields\n * @throws {AxiomCLIError} If required fields are missing or invalid\n * @internal\n */\nexport function validateConfig(config: Partial<AxiomConfigBase>): ResolvedAxiomConfig {\n const errors: string[] = [];\n const isDebug = process.env.AXIOM_DEBUG === 'true';\n\n if (!isDebug) {\n if (!config.eval?.token) {\n errors.push(\n 'eval.token is required (set in axiom.config.ts or AXIOM_TOKEN environment variable)',\n );\n }\n if (!config.eval?.dataset) {\n errors.push(\n 'eval.dataset is required (set in axiom.config.ts or AXIOM_DATASET environment variable)',\n );\n }\n\n if (!config.eval?.url) {\n console.log(\n 'eval.url was not specified. Defaulting to `https://api.axiom.co`. Please set it in axiom.config.ts or AXIOM_URL environment variable if you want to use a different endpoint.',\n );\n }\n }\n\n const instrumentation = config.eval?.instrumentation;\n if (\n instrumentation !== null &&\n instrumentation !== undefined &&\n typeof instrumentation !== 'function'\n ) {\n errors.push(\n 'eval.instrumentation must be a function returning OTEL setup information or null.',\n );\n }\n\n const vitestConfig = config.eval?.vitestConfig;\n if (vitestConfig !== undefined && vitestConfig !== false && typeof vitestConfig !== 'string') {\n errors.push('eval.vitestConfig must be a string path or false.');\n }\n\n if (errors.length > 0) {\n throw new AxiomCLIError(`Invalid Axiom configuration:\\n - ${errors.join('\\n - ')}`);\n }\n\n return config as ResolvedAxiomConfig;\n}\n","import { randomBytes, createHash } from 'crypto';\nimport type { OAuthTokenResponse } from './types';\n\nconst OAUTH_CLIENT_ID = '264d906a404efc209b027f6595e6b616';\nconst OAUTH_AUTH_PATH = '/oauth/authorize';\nconst OAUTH_TOKEN_PATH = '/oauth/token';\n\nexport interface BuildAuthUrlParams {\n redirectUri: string;\n state: string;\n codeChallenge: string;\n}\n\nexport interface ExchangeCodeParams {\n code: string;\n redirectUri: string;\n codeVerifier: string;\n}\n\nexport class OAuth {\n constructor(private readonly oauthBaseUrl: string) {}\n\n static generateCodeVerifier(): string {\n return randomBytes(32).toString('base64url');\n }\n\n static generateCodeChallenge(verifier: string): string {\n return createHash('sha256').update(verifier).digest('base64url');\n }\n\n static generateState(): string {\n return randomBytes(16).toString('hex');\n }\n\n public buildAuthUrl(params: BuildAuthUrlParams): string {\n const url = new URL(OAUTH_AUTH_PATH, this.oauthBaseUrl);\n url.searchParams.set('client_id', OAUTH_CLIENT_ID);\n url.searchParams.set('redirect_uri', params.redirectUri);\n url.searchParams.set('response_type', 'code');\n url.searchParams.set('state', params.state);\n url.searchParams.set('code_challenge', params.codeChallenge);\n url.searchParams.set('code_challenge_method', 'S256');\n url.searchParams.set('scope', '*');\n return url.toString();\n }\n\n public async exchangeCodeForToken(params: ExchangeCodeParams): Promise<string> {\n const tokenUrl = new URL(OAUTH_TOKEN_PATH, this.oauthBaseUrl);\n\n const body = new URLSearchParams({\n grant_type: 'authorization_code',\n client_id: OAUTH_CLIENT_ID,\n code: params.code,\n redirect_uri: params.redirectUri,\n code_verifier: params.codeVerifier,\n });\n\n const response = await fetch(tokenUrl.toString(), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: body.toString(),\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(`Token exchange failed: ${response.status} ${errorText}`);\n }\n\n const data: OAuthTokenResponse = await response.json();\n return data.access_token;\n }\n}\n","import { AxiomCLIError } from '../../util/errors';\nimport type { Organization } from './types';\n\nexport async function fetchOrganizations(\n token: string,\n apiBaseUrl: string,\n): Promise<Organization[]> {\n const response = await fetch(`${apiBaseUrl}/v2/orgs`, {\n headers: {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw new AxiomCLIError(\n `Failed to fetch organizations: ${response.status} ${response.statusText}`,\n );\n }\n\n const data = await response.json();\n return data as Organization[];\n}\n\nexport async function verifyToken(\n token: string,\n orgId: string,\n apiBaseUrl: string,\n): Promise<boolean> {\n const response = await fetch(`${apiBaseUrl}/v2/user`, {\n headers: {\n Authorization: `Bearer ${token}`,\n 'X-Axiom-Org-Id': orgId,\n 'Content-Type': 'application/json',\n },\n });\n\n return response.ok;\n}\n","import http, { type IncomingMessage, type ServerResponse } from 'http';\nimport type { AddressInfo } from 'net';\n\nfunction escapeHtml(text: string): string {\n const map: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n '`': '`',\n };\n return text.replace(/[&<>\"']/g, (m) => map[m] || m);\n}\n\nconst SVG_LOGO = `<svg width=\"124\" height=\"24\" viewBox=\"0 0 124 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" class=\"logo\">\n<path d=\"M42.9919 16.8116H36.3696L35.5537 19.1572C35.4209 19.539 34.9714 19.8513 34.5548 19.8513H30.9779C30.5614 19.8513 30.3459 19.5449 30.499 19.1703L36.9816 3.31644C37.1346 2.9419 37.6009 2.63546 38.0174 2.63546H41.3718C41.7883 2.63546 42.2541 2.94207 42.4067 3.3168L48.8634 19.17C49.016 19.5447 48.8 19.8513 48.3835 19.8513H44.8067C44.3901 19.8513 43.9406 19.539 43.8078 19.1572L42.9919 16.8116ZM41.8232 13.4223L39.6807 7.18148L37.5383 13.4223H41.8232ZM64.1105 19.8513C63.694 19.8513 63.1767 19.5694 62.9611 19.2247L59.9029 14.3369L56.8447 19.2247C56.6291 19.5694 56.1119 19.8513 55.6953 19.8513H51.3392C50.9227 19.8513 50.7754 19.5801 51.0119 19.2486L56.8978 11.0013L51.5315 3.24414C51.2999 2.90937 51.4513 2.63546 51.8679 2.63546H55.89C56.3066 2.63546 56.8268 2.91563 57.0461 3.25807L59.9029 7.71959L62.7343 3.25955C62.9522 2.9163 63.4713 2.63546 63.8879 2.63546H67.938C68.3545 2.63546 68.5048 2.90868 68.272 3.24261L62.8801 10.9743L68.7935 19.2489C69.0303 19.5802 68.8832 19.8513 68.4666 19.8513H64.1105ZM76.525 19.119C76.525 19.5218 76.1841 19.8513 75.7675 19.8513H72.5522C72.1356 19.8513 71.7947 19.5218 71.7947 19.119V3.36771C71.7947 2.96498 72.1356 2.63546 72.5522 2.63546H75.7675C76.1841 2.63546 76.525 2.96498 76.525 3.36771V19.119ZM79.3736 11.1896C79.3736 6.18625 83.2688 2.15134 89.2511 2.15134C95.2334 2.15134 99.1289 6.18625 99.1289 11.1896C99.1289 16.2199 95.2334 20.2548 89.2511 20.2548C83.2688 20.2548 79.3736 16.2199 79.3736 11.1896ZM94.2873 11.1896C94.2873 8.58038 92.3953 6.21307 89.2511 6.21307C86.1349 6.21307 84.2149 8.58038 84.2149 11.1896C84.2149 13.7989 86.1349 16.2199 89.2511 16.2199C92.3675 16.2199 94.2873 13.7989 94.2873 11.1896ZM119.318 19.8513C118.902 19.8513 118.517 19.5245 118.463 19.1251L117.225 9.89847L113.65 19.1652C113.505 19.5426 113.045 19.8513 112.628 19.8513H111.055C110.638 19.8513 110.179 19.5423 110.034 19.1645L106.457 9.81766L105.218 19.125C105.165 19.5245 104.781 19.8513 104.364 19.8513H101.344C100.927 19.8513 100.633 19.5249 100.69 19.1259L102.932 3.3609C102.988 2.96191 103.376 2.63546 103.792 2.63546H106.59C107.007 2.63546 107.469 2.94351 107.617 3.32002L111.827 14.041L116.064 3.31949C116.213 2.94327 116.676 2.63546 117.092 2.63546H119.89C120.307 2.63546 120.694 2.96191 120.751 3.3609L122.993 19.1259C123.05 19.5249 122.755 19.8513 122.339 19.8513H119.318ZM23.9616 15.6531L18.8054 6.97021C18.5689 6.57115 17.9863 6.24465 17.5106 6.24465H14.2915C13.5433 6.24465 13.2365 5.73171 13.6097 5.1048L15.375 2.13986C15.5151 1.90455 15.5148 1.61487 15.3743 1.37981C15.2337 1.14476 14.9741 1 14.6933 1H10.2025C9.72681 1 9.14291 1.32577 8.90491 1.72395L0.17865 16.3217C-0.0594434 16.7199 -0.0595348 17.3715 0.178285 17.7698L2.42362 21.5297C2.79777 22.1561 3.41129 22.1569 3.78699 21.5313L5.54143 18.6103C5.91722 17.9847 6.53065 17.9854 6.9048 18.6119L8.49538 21.2754C8.7332 21.6737 9.317 21.9995 9.79273 21.9995H20.1698C20.6455 21.9995 21.2293 21.6737 21.4672 21.2754L23.959 17.1028C24.1968 16.7045 24.198 16.0521 23.9616 15.6531ZM16.9981 15.2352C17.3699 15.8629 17.0619 16.3765 16.3136 16.3765H8.24192C7.49372 16.3765 7.1876 15.864 7.56175 15.2375L11.6007 8.47417C11.9748 7.84772 12.5869 7.84774 12.9611 8.47421L16.9981 15.2352Z\" fill=\"#121224\"/>\n</svg>`;\n\nfunction renderCallbackPage(error?: string): string {\n const errorClass = error ? ' class=\"error\"' : '';\n const errorMessage = error ? escapeHtml(error) : '';\n\n return `<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n <title>Axiom</title>\n <link rel=\"icon\" href=\"https://app.axiom.co/static/favicon.ico\">\n <meta name=\"description\" content=\"Axiom CLI\">\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n <style>\n html,\n body,\n .root {\n width: 100%;\n height: 100%;\n text-rendering: optimizeLegibility;\n -webkit-font-smoothing: antialiased;\n }\n body {\n color: #334155;\n font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;\n font-size: 14px;\n font-weight: 500;\n font-variant: tabular-nums;\n line-height: 1.5;\n background-color: #fff;\n font-feature-settings: \"tnum\";\n margin: 0;\n }\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n margin-top: 0;\n margin-bottom: .5em;\n font-weight: 500;\n }\n p {\n margin-top: 0;\n margin-bottom: 1em;\n }\n h2 {\n font-size: 16px;\n font-weight: 600;\n }\n .root {\n display: flex;\n align-items: center;\n justify-content: center;\n }\n .logo {\n width: 92px;\n float: left;\n position: absolute;\n top: 16px;\n left: 16px;\n }\n .center p {\n padding: 8px 0;\n }\n .error .center {\n color: #bf0e08;\n }\n </style>\n</head>\n<body${errorClass}>\n <div class=\"root\">\n <a class=\"\" target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://axiom.co\">\n ${SVG_LOGO}\n </svg>\n </a>\n <div class=\"center\">\n ${\n error\n ? `<h2 id=\"msg\">Login failed</h2>\n <p id=\"details\">${errorMessage}</p>`\n : `<h2 id=\"msg\">Login successful</h2>\n <p id=\"details\">You can close this page and return to your CLI.</p>`\n }\n </div>\n </div>\n <script>\n window.history.replaceState({}, '', \\`\\${window.location.pathname}\\`);\n </script>\n</body>\n</html>`;\n}\n\nexport interface CallbackServerResult {\n server: http.Server;\n port: number;\n url: string;\n}\n\nexport async function startCallbackServer(): Promise<CallbackServerResult> {\n return new Promise((resolve) => {\n const server = http.createServer();\n server.listen(0, '127.0.0.1', () => {\n const address = server.address() as AddressInfo;\n resolve({\n server,\n port: address.port,\n url: `http://127.0.0.1:${address.port}`,\n });\n });\n });\n}\n\nexport interface CallbackResult {\n code: string;\n}\n\nexport async function waitForCallback(\n server: http.Server,\n expectedState: string,\n): Promise<CallbackResult> {\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(\n () => {\n server.close();\n reject(new Error('Authentication timeout after 5 minutes'));\n },\n 5 * 60 * 1000,\n ); // 5 minute timeout\n\n server.on('request', (req: IncomingMessage, res: ServerResponse) => {\n const url = new URL(req.url || '', `http://${req.headers.host}`);\n const code = url.searchParams.get('code');\n const state = url.searchParams.get('state');\n const error = url.searchParams.get('error');\n const errorDescription = url.searchParams.get('error_description');\n\n if (error) {\n const errorMsg = errorDescription || error;\n res.writeHead(400, { 'Content-Type': 'text/html' });\n res.end(renderCallbackPage(errorMsg));\n clearTimeout(timeout);\n server.close();\n reject(new Error(`OAuth error: ${errorMsg}`));\n return;\n }\n\n if (!code || !state) {\n res.writeHead(400, { 'Content-Type': 'text/html' });\n res.end(renderCallbackPage('Missing code or state parameter'));\n return;\n }\n\n if (state !== expectedState) {\n res.writeHead(400, { 'Content-Type': 'text/html' });\n res.end(renderCallbackPage('Invalid state parameter (CSRF protection)'));\n clearTimeout(timeout);\n server.close();\n reject(new Error('Invalid state parameter'));\n return;\n }\n\n res.writeHead(200, { 'Content-Type': 'text/html' });\n res.end(renderCallbackPage());\n\n clearTimeout(timeout);\n server.close();\n resolve({ code });\n });\n });\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,YAAY,UAAU;AAC/B,OAAO,UAAU;AACjB,OAAO,QAAQ;AAGf,IAAM,kBAAkB;AACxB,IAAM,kBAAkB;AAQjB,SAAS,eAAuB;AACrC,QAAM,WAAW,QAAQ;AACzB,QAAM,UAAU,GAAG,QAAQ;AAG3B,QAAM,gBAAgB,QAAQ,IAAI;AAClC,MAAI,eAAe;AACjB,WAAO,KAAK,KAAK,eAAe,eAAe;AAAA,EACjD;AAEA,MAAI,aAAa,SAAS;AAExB,UAAM,UAAU,QAAQ,IAAI;AAC5B,QAAI,SAAS;AACX,aAAO,KAAK,KAAK,SAAS,eAAe;AAAA,IAC3C;AAEA,WAAO,KAAK,KAAK,SAAS,WAAW,WAAW,eAAe;AAAA,EACjE;AAEA,SAAO,KAAK,KAAK,SAAS,WAAW,eAAe;AACtD;AAKO,SAAS,sBAA8B;AAC5C,SAAO,KAAK,KAAK,aAAa,GAAG,eAAe;AAClD;AAEA,eAAsB,mBAAoC;AACxD,QAAM,aAAa,oBAAoB;AACvC,MAAI;AACF,UAAM,UAAU,MAAM,GAAG,SAAS,YAAY,OAAO;AACrD,WAAO,KAAK,MAAM,OAAO;AAAA,EAC3B,SAAS,OAAO;AACd,QAAK,MAAgC,SAAS,UAAU;AACtD,aAAO,EAAE,UAAU,CAAC,EAAE;AAAA,IACxB;AACA,UAAM;AAAA,EACR;AACF;AAEA,eAAsB,iBAAiB,QAA+B;AACpE,QAAM,aAAa,oBAAoB;AACvC,QAAM,YAAY,KAAK,QAAQ,UAAU;AACzC,QAAM,UAAU,KAAK,UAAU,QAAQ,MAAM,CAAC;AAG9C,QAAM,GAAG,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B,aAAO;AAAA,QACL;AAAA,MACF;AAAA,IACF;AAEA,QAAI,CAAC,OAAO,MAAM,KAAK;AACrB,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,kBAAkB,OAAO,MAAM;AACrC,MACE,oBAAoB,QACpB,oBAAoB,UACpB,OAAO,oBAAoB,YAC3B;AACA,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAEA,QAAM,eAAe,OAAO,MAAM;AAClC,MAAI,iBAAiB,UAAa,iBAAiB,SAAS,OAAO,iBAAiB,UAAU;AAC5F,WAAO,KAAK,mDAAmD;AAAA,EACjE;AAEA,MAAI,OAAO,SAAS,GAAG;AACrB,UAAM,IAAI,cAAc;AAAA,MAAqC,OAAO,KAAK,QAAQ,CAAC,EAAE;AAAA,EACtF;AAEA,SAAO;AACT;","names":["authContext"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getGlobalTracer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-J46CMFBN.js";
|
|
4
4
|
import {
|
|
5
5
|
isValidName
|
|
6
6
|
} from "./chunk-MM5FFQJT.js";
|
|
@@ -280,4 +280,4 @@ async function executeOnlineEvalInternal(name, params, linkContexts) {
|
|
|
280
280
|
export {
|
|
281
281
|
onlineEval
|
|
282
282
|
};
|
|
283
|
-
//# sourceMappingURL=chunk-
|
|
283
|
+
//# sourceMappingURL=chunk-NAXW7DJD.js.map
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
getRedactionPolicy,
|
|
6
6
|
handleMaybeRedactedAttribute,
|
|
7
7
|
package_default
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-J46CMFBN.js";
|
|
9
9
|
import {
|
|
10
10
|
isValidName
|
|
11
11
|
} from "./chunk-MM5FFQJT.js";
|
|
@@ -2030,7 +2030,7 @@ function wrapAISDKModel(model) {
|
|
|
2030
2030
|
}
|
|
2031
2031
|
|
|
2032
2032
|
// src/evals/context/global-flags.ts
|
|
2033
|
-
var GLOBAL_OVERRIDES_SYMBOL = Symbol.for("axiom.global_flag_overrides");
|
|
2033
|
+
var GLOBAL_OVERRIDES_SYMBOL = /* @__PURE__ */ Symbol.for("axiom.global_flag_overrides");
|
|
2034
2034
|
function getRoot() {
|
|
2035
2035
|
return globalThis[GLOBAL_OVERRIDES_SYMBOL] ?? {};
|
|
2036
2036
|
}
|
|
@@ -2048,7 +2048,7 @@ function getGlobalFlagOverrides() {
|
|
|
2048
2048
|
import { trace as trace3 } from "@opentelemetry/api";
|
|
2049
2049
|
|
|
2050
2050
|
// src/evals/context/manager.ts
|
|
2051
|
-
var CONTEXT_MANAGER_SYMBOL = Symbol.for("axiom.context_manager");
|
|
2051
|
+
var CONTEXT_MANAGER_SYMBOL = /* @__PURE__ */ Symbol.for("axiom.context_manager");
|
|
2052
2052
|
var globalScope = globalThis;
|
|
2053
2053
|
function getGlobalContextManager() {
|
|
2054
2054
|
return globalScope[CONTEXT_MANAGER_SYMBOL];
|
|
@@ -2116,14 +2116,14 @@ function createAsyncHook(_name) {
|
|
|
2116
2116
|
}
|
|
2117
2117
|
|
|
2118
2118
|
// src/evals/context/storage.ts
|
|
2119
|
-
var CONFIG_SCOPE_SYMBOL = Symbol.for("axiom.eval.configScope");
|
|
2119
|
+
var CONFIG_SCOPE_SYMBOL = /* @__PURE__ */ Symbol.for("axiom.eval.configScope");
|
|
2120
2120
|
function getGlobalConfigScope() {
|
|
2121
2121
|
return globalThis[CONFIG_SCOPE_SYMBOL];
|
|
2122
2122
|
}
|
|
2123
2123
|
function setGlobalConfigScope(scope) {
|
|
2124
2124
|
globalThis[CONFIG_SCOPE_SYMBOL] = scope;
|
|
2125
2125
|
}
|
|
2126
|
-
var AXIOM_CONFIG_SYMBOL = Symbol.for("axiom.eval.config");
|
|
2126
|
+
var AXIOM_CONFIG_SYMBOL = /* @__PURE__ */ Symbol.for("axiom.eval.config");
|
|
2127
2127
|
function getAxiomConfig() {
|
|
2128
2128
|
return globalThis[AXIOM_CONFIG_SYMBOL];
|
|
2129
2129
|
}
|
|
@@ -3140,4 +3140,4 @@ export {
|
|
|
3140
3140
|
withEvalContext,
|
|
3141
3141
|
getConfigScope
|
|
3142
3142
|
};
|
|
3143
|
-
//# sourceMappingURL=chunk-
|
|
3143
|
+
//# sourceMappingURL=chunk-S3BXNQXD.js.map
|