@apo-ai/sdk 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +314 -0
- package/dist/agent-task/integrations/ai-sdk.d.ts +121 -0
- package/dist/agent-task/integrations/ai-sdk.js +10 -0
- package/dist/agent-task/integrations/ai-sdk.js.map +1 -0
- package/dist/agent-task/integrations/anthropic.d.ts +67 -0
- package/dist/agent-task/integrations/anthropic.js +10 -0
- package/dist/agent-task/integrations/anthropic.js.map +1 -0
- package/dist/agent-task/integrations/openai.d.ts +77 -0
- package/dist/agent-task/integrations/openai.js +10 -0
- package/dist/agent-task/integrations/openai.js.map +1 -0
- package/dist/agent-task/public.d.ts +1326 -0
- package/dist/agent-task/public.js +3026 -0
- package/dist/agent-task/public.js.map +1 -0
- package/dist/chunk-DT2LMB7O.js +80 -0
- package/dist/chunk-DT2LMB7O.js.map +1 -0
- package/dist/chunk-GDB6SDGN.js +75 -0
- package/dist/chunk-GDB6SDGN.js.map +1 -0
- package/dist/chunk-HKLBPIB4.js +232 -0
- package/dist/chunk-HKLBPIB4.js.map +1 -0
- package/dist/chunk-HWZVL6TS.js +37 -0
- package/dist/chunk-HWZVL6TS.js.map +1 -0
- package/dist/chunk-PMYLL2H4.js +495 -0
- package/dist/chunk-PMYLL2H4.js.map +1 -0
- package/dist/chunk-SZDSIPXC.js +74 -0
- package/dist/chunk-SZDSIPXC.js.map +1 -0
- package/dist/index.d.ts +95 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/otel/index.d.ts +270 -0
- package/dist/otel/index.js +32 -0
- package/dist/otel/index.js.map +1 -0
- package/dist/tracing-DtbhYQV6.d.ts +26 -0
- package/dist/types-C-nrDEVf.d.ts +140 -0
- package/package.json +92 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
type ParameterOverrides = Record<string, unknown>;
|
|
2
|
+
interface ClientOptions {
|
|
3
|
+
parameterOverrides?: ParameterOverrides;
|
|
4
|
+
runEvals?: boolean;
|
|
5
|
+
}
|
|
6
|
+
interface IngestionEvent {
|
|
7
|
+
id: string;
|
|
8
|
+
timestamp: Date;
|
|
9
|
+
type: "run-create" | "call-create" | "call-update" | "score-create";
|
|
10
|
+
body: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
interface CreateTraceParams {
|
|
13
|
+
id?: string;
|
|
14
|
+
project: string;
|
|
15
|
+
task_id?: string;
|
|
16
|
+
flow_name?: string;
|
|
17
|
+
version?: string;
|
|
18
|
+
user_id?: string;
|
|
19
|
+
session_id?: string;
|
|
20
|
+
environment?: string;
|
|
21
|
+
external_id?: string;
|
|
22
|
+
tags?: string[];
|
|
23
|
+
run_metadata?: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
interface CreateSpanParams {
|
|
26
|
+
id?: string;
|
|
27
|
+
project: string;
|
|
28
|
+
task_id: string;
|
|
29
|
+
run_id?: string;
|
|
30
|
+
parent_call_id?: string;
|
|
31
|
+
flow_name?: string;
|
|
32
|
+
step_name?: string;
|
|
33
|
+
step_index?: number;
|
|
34
|
+
version?: string;
|
|
35
|
+
model?: string;
|
|
36
|
+
input?: Record<string, unknown>;
|
|
37
|
+
messages?: Record<string, unknown>[];
|
|
38
|
+
output?: Record<string, unknown>;
|
|
39
|
+
observation_type?: "GENERATION" | "SPAN" | "TOOL" | "CHAIN" | "RETRIEVER" | "EVALUATOR" | "EMBEDDING" | "GUARDRAIL" | "AGENT";
|
|
40
|
+
level?: "DEBUG" | "DEFAULT" | "WARNING" | "ERROR";
|
|
41
|
+
user_id?: string;
|
|
42
|
+
metadata?: Record<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
interface EndSpanParams {
|
|
45
|
+
id: string;
|
|
46
|
+
output?: Record<string, unknown>;
|
|
47
|
+
latency_ms?: number;
|
|
48
|
+
prompt_tokens?: number;
|
|
49
|
+
completion_tokens?: number;
|
|
50
|
+
status_message?: string;
|
|
51
|
+
level?: "DEBUG" | "DEFAULT" | "WARNING" | "ERROR";
|
|
52
|
+
metadata?: Record<string, unknown>;
|
|
53
|
+
}
|
|
54
|
+
interface TraceRunRootSpanOptions extends Omit<CreateSpanParams, "project" | "run_id" | "parent_call_id"> {
|
|
55
|
+
}
|
|
56
|
+
interface TraceRunOptions extends Omit<CreateTraceParams, "project"> {
|
|
57
|
+
project?: string;
|
|
58
|
+
rootSpan?: TraceRunRootSpanOptions;
|
|
59
|
+
}
|
|
60
|
+
interface TraceStepOptions extends Omit<CreateSpanParams, "project" | "task_id" | "run_id" | "output"> {
|
|
61
|
+
task_id?: string;
|
|
62
|
+
summarize?: (result: unknown) => Record<string, unknown> | undefined;
|
|
63
|
+
}
|
|
64
|
+
interface TraceEventOptions extends Omit<CreateSpanParams, "project" | "task_id" | "run_id"> {
|
|
65
|
+
task_id?: string;
|
|
66
|
+
latency_ms?: number;
|
|
67
|
+
}
|
|
68
|
+
interface TraceRunContext {
|
|
69
|
+
runId: string;
|
|
70
|
+
rootSpanId: string;
|
|
71
|
+
step<T>(options: TraceStepOptions, fn: (spanId: string) => Promise<T>): Promise<T>;
|
|
72
|
+
recordEvent(options: TraceEventOptions): string;
|
|
73
|
+
endRoot(params?: Omit<EndSpanParams, "id">): void;
|
|
74
|
+
traceTool<T>(name: string, params: Record<string, unknown>, fn: () => Promise<T>): Promise<T>;
|
|
75
|
+
traceRetriever<T>(query: string, fn: () => Promise<T>): Promise<T>;
|
|
76
|
+
traceChain<T>(name: string, fn: () => Promise<T>): Promise<T>;
|
|
77
|
+
traceAgent<T>(name: string, fn: () => Promise<T>): Promise<T>;
|
|
78
|
+
traceGuardrail<T>(name: string, fn: () => Promise<T>): Promise<T>;
|
|
79
|
+
traceEmbedding<T>(model: string, input: unknown, fn: () => Promise<T>): Promise<T>;
|
|
80
|
+
score(params: CreateScoreParams): Promise<void>;
|
|
81
|
+
}
|
|
82
|
+
interface CreateScoreParams {
|
|
83
|
+
name: string;
|
|
84
|
+
value: number | string | boolean;
|
|
85
|
+
dataType?: "NUMERIC" | "CATEGORICAL" | "BOOLEAN";
|
|
86
|
+
source?: "API" | "EVAL" | "ANNOTATION";
|
|
87
|
+
configId?: number;
|
|
88
|
+
comment?: string;
|
|
89
|
+
observationId?: string;
|
|
90
|
+
}
|
|
91
|
+
interface ObserveOptions {
|
|
92
|
+
/** Unique ID for this observation (trace or span) */
|
|
93
|
+
id?: string;
|
|
94
|
+
/** Project name for grouping traces */
|
|
95
|
+
project?: string;
|
|
96
|
+
/** Flow name (alternative to project) */
|
|
97
|
+
flowName?: string;
|
|
98
|
+
/** Step name for spans */
|
|
99
|
+
stepName?: string;
|
|
100
|
+
/** Observation name (defaults to method name if not provided) */
|
|
101
|
+
name?: string;
|
|
102
|
+
/** User ID for tracking */
|
|
103
|
+
userId?: string;
|
|
104
|
+
/** Session ID for session tracking */
|
|
105
|
+
sessionId?: string;
|
|
106
|
+
/** Environment (e.g., "production", "development") */
|
|
107
|
+
environment?: string;
|
|
108
|
+
/** External ID for linking to external systems */
|
|
109
|
+
externalId?: string;
|
|
110
|
+
/** Tags for filtering and grouping */
|
|
111
|
+
tags?: string[];
|
|
112
|
+
/** Metadata for additional context */
|
|
113
|
+
metadata?: Record<string, unknown>;
|
|
114
|
+
/** Model name (for spans) */
|
|
115
|
+
model?: string;
|
|
116
|
+
/** Explicit input data (overrides automatic extraction) */
|
|
117
|
+
input?: Record<string, unknown>;
|
|
118
|
+
/** Messages array (for chat completions) */
|
|
119
|
+
messages?: Record<string, unknown>[];
|
|
120
|
+
/** Observation type (Langfuse-style) */
|
|
121
|
+
observationType?: "GENERATION" | "SPAN" | "TOOL" | "CHAIN" | "RETRIEVER" | "EVALUATOR" | "EMBEDDING" | "GUARDRAIL" | "AGENT";
|
|
122
|
+
/** Shorthand for observation type */
|
|
123
|
+
as?: "tool" | "retriever" | "chain" | "agent" | "guardrail" | "embedding";
|
|
124
|
+
/** Observation level */
|
|
125
|
+
level?: "DEBUG" | "DEFAULT" | "WARNING" | "ERROR";
|
|
126
|
+
/** Whether to capture output (default: true) */
|
|
127
|
+
captureOutput?: boolean;
|
|
128
|
+
}
|
|
129
|
+
interface ObservationContext {
|
|
130
|
+
/** Trace ID (run ID) */
|
|
131
|
+
traceId: string;
|
|
132
|
+
/** Current span ID */
|
|
133
|
+
spanId: string;
|
|
134
|
+
/** Flow name */
|
|
135
|
+
flowName: string;
|
|
136
|
+
/** Project name */
|
|
137
|
+
projectName: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export type { CreateSpanParams as C, EndSpanParams as E, IngestionEvent as I, ObservationContext as O, ParameterOverrides as P, TraceRunContext as T, TraceRunOptions as a, ClientOptions as b, CreateScoreParams as c, CreateTraceParams as d, ObserveOptions as e, TraceEventOptions as f, TraceStepOptions as g };
|
package/package.json
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@apo-ai/sdk",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "TypeScript SDK for testing and observing AI agents with Apo",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"LICENSE",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=20"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/samikuikka/apo.git",
|
|
20
|
+
"directory": "packages/sdk"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/samikuikka/apo#readme",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/samikuikka/apo/issues"
|
|
25
|
+
},
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js",
|
|
30
|
+
"default": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./otel": {
|
|
33
|
+
"types": "./dist/otel/index.d.ts",
|
|
34
|
+
"import": "./dist/otel/index.js",
|
|
35
|
+
"default": "./dist/otel/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./agent-task": {
|
|
38
|
+
"types": "./dist/agent-task/public.d.ts",
|
|
39
|
+
"import": "./dist/agent-task/public.js",
|
|
40
|
+
"default": "./dist/agent-task/public.js"
|
|
41
|
+
},
|
|
42
|
+
"./agent-task/integrations/ai-sdk": {
|
|
43
|
+
"types": "./dist/agent-task/integrations/ai-sdk.d.ts",
|
|
44
|
+
"import": "./dist/agent-task/integrations/ai-sdk.js",
|
|
45
|
+
"default": "./dist/agent-task/integrations/ai-sdk.js"
|
|
46
|
+
},
|
|
47
|
+
"./agent-task/integrations/openai": {
|
|
48
|
+
"types": "./dist/agent-task/integrations/openai.d.ts",
|
|
49
|
+
"import": "./dist/agent-task/integrations/openai.js",
|
|
50
|
+
"default": "./dist/agent-task/integrations/openai.js"
|
|
51
|
+
},
|
|
52
|
+
"./agent-task/integrations/anthropic": {
|
|
53
|
+
"types": "./dist/agent-task/integrations/anthropic.d.ts",
|
|
54
|
+
"import": "./dist/agent-task/integrations/anthropic.js",
|
|
55
|
+
"default": "./dist/agent-task/integrations/anthropic.js"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public",
|
|
60
|
+
"registry": "https://registry.npmjs.org/"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@types/node": "^20.0.0",
|
|
64
|
+
"@vitest/coverage-v8": "^4.1.9",
|
|
65
|
+
"esbuild": "^0.21.5",
|
|
66
|
+
"publint": "^0.3.22",
|
|
67
|
+
"tsup": "^8.5.1",
|
|
68
|
+
"typescript": "^5.0.0",
|
|
69
|
+
"vitest": "^4.1.9",
|
|
70
|
+
"zod": "^3.22.0"
|
|
71
|
+
},
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"@opentelemetry/api": "^1.9.1",
|
|
74
|
+
"@opentelemetry/context-async-hooks": "^2.9.0",
|
|
75
|
+
"@opentelemetry/core": "^2.9.0",
|
|
76
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.220.0",
|
|
77
|
+
"@opentelemetry/resources": "^2.9.0",
|
|
78
|
+
"@opentelemetry/sdk-trace-base": "^2.9.0",
|
|
79
|
+
"@opentelemetry/semantic-conventions": "^1.43.0",
|
|
80
|
+
"effect": "^3.19.12"
|
|
81
|
+
},
|
|
82
|
+
"scripts": {
|
|
83
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.type-tests.json",
|
|
84
|
+
"build": "tsup",
|
|
85
|
+
"build:watch": "tsup --watch",
|
|
86
|
+
"build:agent-task-runtime": "node scripts/build-agent-task-runtime.mjs",
|
|
87
|
+
"package:check": "node scripts/verify-package.mjs",
|
|
88
|
+
"test": "vitest run",
|
|
89
|
+
"test:watch": "vitest",
|
|
90
|
+
"test:coverage": "vitest run --coverage"
|
|
91
|
+
}
|
|
92
|
+
}
|