@zespan/sdk 1.3.3 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +55 -3
- package/dist/index.d.ts +55 -3
- package/dist/index.js +12 -12
- package/dist/index.mjs +12 -12
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -70,6 +70,11 @@ interface PromptOptions {
|
|
|
70
70
|
version?: number;
|
|
71
71
|
label?: string;
|
|
72
72
|
cache?: boolean;
|
|
73
|
+
fallback?: {
|
|
74
|
+
type?: "text" | "chat";
|
|
75
|
+
prompt: any;
|
|
76
|
+
config?: any;
|
|
77
|
+
};
|
|
73
78
|
}
|
|
74
79
|
interface Prompt {
|
|
75
80
|
id: string;
|
|
@@ -84,6 +89,11 @@ interface Prompt {
|
|
|
84
89
|
createdAt: string;
|
|
85
90
|
updatedAt: string;
|
|
86
91
|
promptHash: string;
|
|
92
|
+
isFallback?: boolean;
|
|
93
|
+
}
|
|
94
|
+
interface ChatMessage {
|
|
95
|
+
role: string;
|
|
96
|
+
content: string;
|
|
87
97
|
}
|
|
88
98
|
declare class PromptClient {
|
|
89
99
|
private client;
|
|
@@ -116,9 +126,12 @@ declare class PromptClient {
|
|
|
116
126
|
*/
|
|
117
127
|
updateLabels(name: string, version: number, labels: string[]): Promise<Prompt>;
|
|
118
128
|
/**
|
|
119
|
-
* Compile a prompt with
|
|
129
|
+
* Compile a prompt with `{{var}}` substitution and chat message placeholders.
|
|
130
|
+
* - text prompt -> substituted string.
|
|
131
|
+
* - chat prompt -> message array with placeholders spliced in order
|
|
132
|
+
* (unfilled dropped) and vars substituted across all message contents.
|
|
120
133
|
*/
|
|
121
|
-
compile(prompt: Prompt, variables
|
|
134
|
+
compile(prompt: Prompt, variables?: Record<string, string>, placeholders?: Record<string, ChatMessage[]>): string | ChatMessage[];
|
|
122
135
|
/**
|
|
123
136
|
* Clear cache for a specific prompt or all prompts
|
|
124
137
|
*/
|
|
@@ -127,6 +140,40 @@ declare class PromptClient {
|
|
|
127
140
|
private invalidateCache;
|
|
128
141
|
}
|
|
129
142
|
|
|
143
|
+
interface DatasetItem {
|
|
144
|
+
id: string;
|
|
145
|
+
datasetId: string;
|
|
146
|
+
input: unknown;
|
|
147
|
+
expectedOutput?: unknown;
|
|
148
|
+
metadata?: Record<string, unknown>;
|
|
149
|
+
}
|
|
150
|
+
interface DatasetRun {
|
|
151
|
+
id: string;
|
|
152
|
+
datasetId: string;
|
|
153
|
+
name: string;
|
|
154
|
+
description: string | null;
|
|
155
|
+
}
|
|
156
|
+
declare class DatasetRunHandle {
|
|
157
|
+
private client;
|
|
158
|
+
private datasetId;
|
|
159
|
+
readonly run: DatasetRun;
|
|
160
|
+
constructor(client: ZespanClient, datasetId: string, run: DatasetRun);
|
|
161
|
+
/** Links a dataset item to this run via the trace your own code just produced. */
|
|
162
|
+
link(datasetItemId: string, traceId: string, observationId?: string): Promise<void>;
|
|
163
|
+
}
|
|
164
|
+
declare class DatasetsClient {
|
|
165
|
+
private client;
|
|
166
|
+
private datasetIdByName;
|
|
167
|
+
constructor(client: ZespanClient);
|
|
168
|
+
private resolveDatasetId;
|
|
169
|
+
/** Lists a dataset's items by dataset name. */
|
|
170
|
+
getItems(datasetName: string): Promise<DatasetItem[]>;
|
|
171
|
+
/** Creates or fetches a named run (idempotent — safe to call every time a job starts). */
|
|
172
|
+
createRun(datasetName: string, runName: string, opts?: {
|
|
173
|
+
description?: string;
|
|
174
|
+
}): Promise<DatasetRunHandle>;
|
|
175
|
+
}
|
|
176
|
+
|
|
130
177
|
/**
|
|
131
178
|
* SDK ConfigClient — zero-infra runtime configuration client.
|
|
132
179
|
*
|
|
@@ -268,6 +315,7 @@ declare class ZespanClient {
|
|
|
268
315
|
readonly debug: boolean;
|
|
269
316
|
readonly enableOTel: boolean;
|
|
270
317
|
readonly prompts: PromptClient;
|
|
318
|
+
readonly datasets: DatasetsClient;
|
|
271
319
|
readonly configClient: ConfigClient | null;
|
|
272
320
|
readonly projectId: string | undefined;
|
|
273
321
|
private batch;
|
|
@@ -473,6 +521,8 @@ interface AgentOptions {
|
|
|
473
521
|
name: string;
|
|
474
522
|
role?: string;
|
|
475
523
|
framework?: string;
|
|
524
|
+
version?: string;
|
|
525
|
+
description?: string;
|
|
476
526
|
tools?: ToolDefinition[];
|
|
477
527
|
metadata?: Record<string, unknown>;
|
|
478
528
|
}
|
|
@@ -579,6 +629,8 @@ declare const zespan: {
|
|
|
579
629
|
createSpan: typeof createSpan;
|
|
580
630
|
withSpan: typeof withSpan;
|
|
581
631
|
PromptClient: typeof PromptClient;
|
|
632
|
+
DatasetsClient: typeof DatasetsClient;
|
|
633
|
+
DatasetRunHandle: typeof DatasetRunHandle;
|
|
582
634
|
CallbackHandler: typeof ZespanCallbackHandler;
|
|
583
635
|
ADKCallbackHandler: typeof ZespanADKCallbackHandler;
|
|
584
636
|
autopatch: typeof autopatch;
|
|
@@ -589,4 +641,4 @@ declare const zespan: {
|
|
|
589
641
|
ZespanLlamaIndexHandler: typeof ZespanLlamaIndexHandler;
|
|
590
642
|
};
|
|
591
643
|
|
|
592
|
-
export { type ADKAgentOptions, type ADKRunnerOptions, AgentContext, type AgentOptions, BaggageSpanProcessor, CREWAI_OTEL_ENV, GuardrailBlockedError, type GuardrailCheckInput, type GuardrailCheckResponse, type GuardrailResult, type InstrumentADKOptions, type OTelConfig, type PiiCategory, type PiiPreset, type PiiRedactionMode, type Prompt, PromptClient, type PromptOptions, type ResolvedWrapperGuardrailsSettings, type WrapperGuardrailsOptions, type WrapperGuardrailsSettings, ZespanADKCallbackHandler, ZespanCallbackHandler, ZespanClient, type ZespanContextOptions, ZespanLlamaIndexHandler, type ZespanOptions, type ZespanPiiConfig, attachTraceToAutoGenMessage, autopatch, createSpan, extractAgentContext, extractAgentContext as extractAutoGenContext, extractTraceFromAutoGenMessage, getCrewAIInstrumentationGuide, getPydanticAIConfig, getTracer, getZespanClient, getZespanVercelTelemetry, init, initOTel, initZespan, injectAgentContext, injectAgentContext as injectAutoGenContext, instrumentADK, instrumentVercelAI, markFrameworkActive, markFrameworkInactive, startSpan, withAgent, withSpan, withZespan, withZespanContext, withZespanTrace, wrapADKAgent, wrapADKRunner, wrapAnthropic, wrapBedrock, wrapGoogle, wrapGoogleGenAI, wrapGroq, wrapLiteLLM, wrapMistral, wrapOpenAI, wrapOpenRouter, wrapZespanADKAgent, zespan };
|
|
644
|
+
export { type ADKAgentOptions, type ADKRunnerOptions, AgentContext, type AgentOptions, BaggageSpanProcessor, CREWAI_OTEL_ENV, type DatasetItem, type DatasetRun, DatasetRunHandle, DatasetsClient, GuardrailBlockedError, type GuardrailCheckInput, type GuardrailCheckResponse, type GuardrailResult, type InstrumentADKOptions, type OTelConfig, type PiiCategory, type PiiPreset, type PiiRedactionMode, type Prompt, PromptClient, type PromptOptions, type ResolvedWrapperGuardrailsSettings, type WrapperGuardrailsOptions, type WrapperGuardrailsSettings, ZespanADKCallbackHandler, ZespanCallbackHandler, ZespanClient, type ZespanContextOptions, ZespanLlamaIndexHandler, type ZespanOptions, type ZespanPiiConfig, attachTraceToAutoGenMessage, autopatch, createSpan, extractAgentContext, extractAgentContext as extractAutoGenContext, extractTraceFromAutoGenMessage, getCrewAIInstrumentationGuide, getPydanticAIConfig, getTracer, getZespanClient, getZespanVercelTelemetry, init, initOTel, initZespan, injectAgentContext, injectAgentContext as injectAutoGenContext, instrumentADK, instrumentVercelAI, markFrameworkActive, markFrameworkInactive, startSpan, withAgent, withSpan, withZespan, withZespanContext, withZespanTrace, wrapADKAgent, wrapADKRunner, wrapAnthropic, wrapBedrock, wrapGoogle, wrapGoogleGenAI, wrapGroq, wrapLiteLLM, wrapMistral, wrapOpenAI, wrapOpenRouter, wrapZespanADKAgent, zespan };
|
package/dist/index.d.ts
CHANGED
|
@@ -70,6 +70,11 @@ interface PromptOptions {
|
|
|
70
70
|
version?: number;
|
|
71
71
|
label?: string;
|
|
72
72
|
cache?: boolean;
|
|
73
|
+
fallback?: {
|
|
74
|
+
type?: "text" | "chat";
|
|
75
|
+
prompt: any;
|
|
76
|
+
config?: any;
|
|
77
|
+
};
|
|
73
78
|
}
|
|
74
79
|
interface Prompt {
|
|
75
80
|
id: string;
|
|
@@ -84,6 +89,11 @@ interface Prompt {
|
|
|
84
89
|
createdAt: string;
|
|
85
90
|
updatedAt: string;
|
|
86
91
|
promptHash: string;
|
|
92
|
+
isFallback?: boolean;
|
|
93
|
+
}
|
|
94
|
+
interface ChatMessage {
|
|
95
|
+
role: string;
|
|
96
|
+
content: string;
|
|
87
97
|
}
|
|
88
98
|
declare class PromptClient {
|
|
89
99
|
private client;
|
|
@@ -116,9 +126,12 @@ declare class PromptClient {
|
|
|
116
126
|
*/
|
|
117
127
|
updateLabels(name: string, version: number, labels: string[]): Promise<Prompt>;
|
|
118
128
|
/**
|
|
119
|
-
* Compile a prompt with
|
|
129
|
+
* Compile a prompt with `{{var}}` substitution and chat message placeholders.
|
|
130
|
+
* - text prompt -> substituted string.
|
|
131
|
+
* - chat prompt -> message array with placeholders spliced in order
|
|
132
|
+
* (unfilled dropped) and vars substituted across all message contents.
|
|
120
133
|
*/
|
|
121
|
-
compile(prompt: Prompt, variables
|
|
134
|
+
compile(prompt: Prompt, variables?: Record<string, string>, placeholders?: Record<string, ChatMessage[]>): string | ChatMessage[];
|
|
122
135
|
/**
|
|
123
136
|
* Clear cache for a specific prompt or all prompts
|
|
124
137
|
*/
|
|
@@ -127,6 +140,40 @@ declare class PromptClient {
|
|
|
127
140
|
private invalidateCache;
|
|
128
141
|
}
|
|
129
142
|
|
|
143
|
+
interface DatasetItem {
|
|
144
|
+
id: string;
|
|
145
|
+
datasetId: string;
|
|
146
|
+
input: unknown;
|
|
147
|
+
expectedOutput?: unknown;
|
|
148
|
+
metadata?: Record<string, unknown>;
|
|
149
|
+
}
|
|
150
|
+
interface DatasetRun {
|
|
151
|
+
id: string;
|
|
152
|
+
datasetId: string;
|
|
153
|
+
name: string;
|
|
154
|
+
description: string | null;
|
|
155
|
+
}
|
|
156
|
+
declare class DatasetRunHandle {
|
|
157
|
+
private client;
|
|
158
|
+
private datasetId;
|
|
159
|
+
readonly run: DatasetRun;
|
|
160
|
+
constructor(client: ZespanClient, datasetId: string, run: DatasetRun);
|
|
161
|
+
/** Links a dataset item to this run via the trace your own code just produced. */
|
|
162
|
+
link(datasetItemId: string, traceId: string, observationId?: string): Promise<void>;
|
|
163
|
+
}
|
|
164
|
+
declare class DatasetsClient {
|
|
165
|
+
private client;
|
|
166
|
+
private datasetIdByName;
|
|
167
|
+
constructor(client: ZespanClient);
|
|
168
|
+
private resolveDatasetId;
|
|
169
|
+
/** Lists a dataset's items by dataset name. */
|
|
170
|
+
getItems(datasetName: string): Promise<DatasetItem[]>;
|
|
171
|
+
/** Creates or fetches a named run (idempotent — safe to call every time a job starts). */
|
|
172
|
+
createRun(datasetName: string, runName: string, opts?: {
|
|
173
|
+
description?: string;
|
|
174
|
+
}): Promise<DatasetRunHandle>;
|
|
175
|
+
}
|
|
176
|
+
|
|
130
177
|
/**
|
|
131
178
|
* SDK ConfigClient — zero-infra runtime configuration client.
|
|
132
179
|
*
|
|
@@ -268,6 +315,7 @@ declare class ZespanClient {
|
|
|
268
315
|
readonly debug: boolean;
|
|
269
316
|
readonly enableOTel: boolean;
|
|
270
317
|
readonly prompts: PromptClient;
|
|
318
|
+
readonly datasets: DatasetsClient;
|
|
271
319
|
readonly configClient: ConfigClient | null;
|
|
272
320
|
readonly projectId: string | undefined;
|
|
273
321
|
private batch;
|
|
@@ -473,6 +521,8 @@ interface AgentOptions {
|
|
|
473
521
|
name: string;
|
|
474
522
|
role?: string;
|
|
475
523
|
framework?: string;
|
|
524
|
+
version?: string;
|
|
525
|
+
description?: string;
|
|
476
526
|
tools?: ToolDefinition[];
|
|
477
527
|
metadata?: Record<string, unknown>;
|
|
478
528
|
}
|
|
@@ -579,6 +629,8 @@ declare const zespan: {
|
|
|
579
629
|
createSpan: typeof createSpan;
|
|
580
630
|
withSpan: typeof withSpan;
|
|
581
631
|
PromptClient: typeof PromptClient;
|
|
632
|
+
DatasetsClient: typeof DatasetsClient;
|
|
633
|
+
DatasetRunHandle: typeof DatasetRunHandle;
|
|
582
634
|
CallbackHandler: typeof ZespanCallbackHandler;
|
|
583
635
|
ADKCallbackHandler: typeof ZespanADKCallbackHandler;
|
|
584
636
|
autopatch: typeof autopatch;
|
|
@@ -589,4 +641,4 @@ declare const zespan: {
|
|
|
589
641
|
ZespanLlamaIndexHandler: typeof ZespanLlamaIndexHandler;
|
|
590
642
|
};
|
|
591
643
|
|
|
592
|
-
export { type ADKAgentOptions, type ADKRunnerOptions, AgentContext, type AgentOptions, BaggageSpanProcessor, CREWAI_OTEL_ENV, GuardrailBlockedError, type GuardrailCheckInput, type GuardrailCheckResponse, type GuardrailResult, type InstrumentADKOptions, type OTelConfig, type PiiCategory, type PiiPreset, type PiiRedactionMode, type Prompt, PromptClient, type PromptOptions, type ResolvedWrapperGuardrailsSettings, type WrapperGuardrailsOptions, type WrapperGuardrailsSettings, ZespanADKCallbackHandler, ZespanCallbackHandler, ZespanClient, type ZespanContextOptions, ZespanLlamaIndexHandler, type ZespanOptions, type ZespanPiiConfig, attachTraceToAutoGenMessage, autopatch, createSpan, extractAgentContext, extractAgentContext as extractAutoGenContext, extractTraceFromAutoGenMessage, getCrewAIInstrumentationGuide, getPydanticAIConfig, getTracer, getZespanClient, getZespanVercelTelemetry, init, initOTel, initZespan, injectAgentContext, injectAgentContext as injectAutoGenContext, instrumentADK, instrumentVercelAI, markFrameworkActive, markFrameworkInactive, startSpan, withAgent, withSpan, withZespan, withZespanContext, withZespanTrace, wrapADKAgent, wrapADKRunner, wrapAnthropic, wrapBedrock, wrapGoogle, wrapGoogleGenAI, wrapGroq, wrapLiteLLM, wrapMistral, wrapOpenAI, wrapOpenRouter, wrapZespanADKAgent, zespan };
|
|
644
|
+
export { type ADKAgentOptions, type ADKRunnerOptions, AgentContext, type AgentOptions, BaggageSpanProcessor, CREWAI_OTEL_ENV, type DatasetItem, type DatasetRun, DatasetRunHandle, DatasetsClient, GuardrailBlockedError, type GuardrailCheckInput, type GuardrailCheckResponse, type GuardrailResult, type InstrumentADKOptions, type OTelConfig, type PiiCategory, type PiiPreset, type PiiRedactionMode, type Prompt, PromptClient, type PromptOptions, type ResolvedWrapperGuardrailsSettings, type WrapperGuardrailsOptions, type WrapperGuardrailsSettings, ZespanADKCallbackHandler, ZespanCallbackHandler, ZespanClient, type ZespanContextOptions, ZespanLlamaIndexHandler, type ZespanOptions, type ZespanPiiConfig, attachTraceToAutoGenMessage, autopatch, createSpan, extractAgentContext, extractAgentContext as extractAutoGenContext, extractTraceFromAutoGenMessage, getCrewAIInstrumentationGuide, getPydanticAIConfig, getTracer, getZespanClient, getZespanVercelTelemetry, init, initOTel, initZespan, injectAgentContext, injectAgentContext as injectAutoGenContext, instrumentADK, instrumentVercelAI, markFrameworkActive, markFrameworkInactive, startSpan, withAgent, withSpan, withZespan, withZespanContext, withZespanTrace, wrapADKAgent, wrapADKRunner, wrapAnthropic, wrapBedrock, wrapGoogle, wrapGoogleGenAI, wrapGroq, wrapLiteLLM, wrapMistral, wrapOpenAI, wrapOpenRouter, wrapZespanADKAgent, zespan };
|