langwatch 0.3.1 → 0.4.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/README.md +5 -2
- package/dist/{add-LBBS4I3H.js → add-35QACTIV.js} +34 -28
- package/dist/add-35QACTIV.js.map +1 -0
- package/dist/{add-RD3ZKFAT.mjs → add-TRJAXM4D.mjs} +22 -16
- package/dist/add-TRJAXM4D.mjs.map +1 -0
- package/dist/chunk-4ZSSHX6F.js +636 -0
- package/dist/chunk-4ZSSHX6F.js.map +1 -0
- package/dist/chunk-5EVBOHJY.js +155 -0
- package/dist/chunk-5EVBOHJY.js.map +1 -0
- package/dist/{chunk-YN4436PK.mjs → chunk-CU3443HD.mjs} +14 -9
- package/dist/{chunk-2JU376G7.js → chunk-D2CSG4SJ.js} +4 -4
- package/dist/chunk-D2CSG4SJ.js.map +1 -0
- package/dist/chunk-DISMHYXC.js +184 -0
- package/dist/chunk-DISMHYXC.js.map +1 -0
- package/dist/{chunk-E7UE2MPD.mjs → chunk-ECUXLXFT.mjs} +2 -2
- package/dist/chunk-EJWJXTPU.mjs +626 -0
- package/dist/chunk-EJWJXTPU.mjs.map +1 -0
- package/dist/chunk-GQMDZ4GY.mjs +155 -0
- package/dist/chunk-GQMDZ4GY.mjs.map +1 -0
- package/dist/{chunk-3GKPQB4R.mjs → chunk-HUI45ULC.mjs} +4 -4
- package/dist/chunk-HUI45ULC.mjs.map +1 -0
- package/dist/{chunk-HJU67C7H.js → chunk-K64Y6YUG.js} +10 -10
- package/dist/{chunk-HJU67C7H.js.map → chunk-K64Y6YUG.js.map} +1 -1
- package/dist/chunk-LP76VXI3.mjs +636 -0
- package/dist/chunk-LP76VXI3.mjs.map +1 -0
- package/dist/chunk-M4VUHTT2.js +626 -0
- package/dist/chunk-M4VUHTT2.js.map +1 -0
- package/dist/{chunk-PR3JDWC3.mjs → chunk-N2V6J3U2.mjs} +28 -3
- package/dist/chunk-N2V6J3U2.mjs.map +1 -0
- package/dist/chunk-OUCVXP4G.js +258 -0
- package/dist/chunk-OUCVXP4G.js.map +1 -0
- package/dist/{chunk-FJLK5CFL.js → chunk-OXBO24RB.js} +13 -8
- package/dist/chunk-OXBO24RB.js.map +1 -0
- package/dist/chunk-PGWR3OQY.mjs +258 -0
- package/dist/chunk-PGWR3OQY.mjs.map +1 -0
- package/dist/{chunk-SMXXAVMB.js → chunk-SGNJDRCT.js} +2 -2
- package/dist/chunk-SGNJDRCT.js.map +1 -0
- package/dist/{chunk-W5ZEP3CI.mjs → chunk-SYMZPWZE.mjs} +2 -2
- package/dist/chunk-SYMZPWZE.mjs.map +1 -0
- package/dist/{chunk-KGDAENGD.js → chunk-YH5TIVK2.js} +28 -3
- package/dist/chunk-YH5TIVK2.js.map +1 -0
- package/dist/chunk-YNQ44U6D.mjs +184 -0
- package/dist/chunk-YNQ44U6D.mjs.map +1 -0
- package/dist/cli/index.js +8 -8
- package/dist/cli/index.mjs +8 -8
- package/dist/{create-G5MTGOOH.js → create-7K2CC4KQ.js} +11 -11
- package/dist/{create-G5MTGOOH.js.map → create-7K2CC4KQ.js.map} +1 -1
- package/dist/{create-QUZYBMQB.mjs → create-MK7NEGCM.mjs} +8 -8
- package/dist/implementation-C4lvooSg.d.mts +576 -0
- package/dist/implementation-CzemP9jY.d.ts +576 -0
- package/dist/index-DTEZr0Jn.d.mts +34 -0
- package/dist/index-DTEZr0Jn.d.ts +34 -0
- package/dist/index.d.mts +122 -41
- package/dist/index.d.ts +122 -41
- package/dist/index.js +16 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -23
- package/dist/index.mjs.map +1 -1
- package/dist/init-GDKJICSS.js +16 -0
- package/dist/{init-XU2JFY6N.js.map → init-GDKJICSS.js.map} +1 -1
- package/dist/{init-H67RW22E.mjs → init-RINSTP4L.mjs} +5 -5
- package/dist/{list-7NPSX2E4.mjs → list-7L23G5DY.mjs} +28 -16
- package/dist/list-7L23G5DY.mjs.map +1 -0
- package/dist/{list-ZXFLAF52.js → list-OLLQ7XKZ.js} +29 -17
- package/dist/list-OLLQ7XKZ.js.map +1 -0
- package/dist/{login-EK4WVOI2.mjs → login-RCNKL5AM.mjs} +6 -5
- package/dist/login-RCNKL5AM.mjs.map +1 -0
- package/dist/{login-76NQIHKR.js → login-XF3BQQPV.js} +7 -6
- package/dist/login-XF3BQQPV.js.map +1 -0
- package/dist/observability-sdk/index.d.mts +134 -0
- package/dist/observability-sdk/index.d.ts +134 -0
- package/dist/observability-sdk/index.js +41 -0
- package/dist/observability-sdk/index.js.map +1 -0
- package/dist/observability-sdk/index.mjs +41 -0
- package/dist/observability-sdk/instrumentation/langchain/index.d.mts +69 -0
- package/dist/observability-sdk/instrumentation/langchain/index.d.ts +69 -0
- package/dist/observability-sdk/instrumentation/langchain/index.js +518 -0
- package/dist/observability-sdk/instrumentation/langchain/index.js.map +1 -0
- package/dist/observability-sdk/instrumentation/langchain/index.mjs +518 -0
- package/dist/observability-sdk/instrumentation/langchain/index.mjs.map +1 -0
- package/dist/observability-sdk/setup/node/index.d.mts +368 -0
- package/dist/observability-sdk/setup/node/index.d.ts +368 -0
- package/dist/observability-sdk/setup/node/index.js +276 -0
- package/dist/observability-sdk/setup/node/index.js.map +1 -0
- package/dist/observability-sdk/setup/node/index.mjs +276 -0
- package/dist/observability-sdk/setup/node/index.mjs.map +1 -0
- package/dist/{remove-SDJYEPAY.mjs → remove-3VLQNVHN.mjs} +11 -8
- package/dist/remove-3VLQNVHN.mjs.map +1 -0
- package/dist/{remove-XBNGIVMR.js → remove-L6JVJBWY.js} +18 -15
- package/dist/remove-L6JVJBWY.js.map +1 -0
- package/dist/{sync-ST2IWXSB.mjs → sync-DPMTUTVL.mjs} +39 -33
- package/dist/sync-DPMTUTVL.mjs.map +1 -0
- package/dist/{sync-EISKGPTL.js → sync-PSU3F5Z4.js} +52 -46
- package/dist/sync-PSU3F5Z4.js.map +1 -0
- package/dist/{prompt-D-jpMrLS.d.mts → types-1q5wIYP5.d.mts} +628 -14
- package/dist/{prompt-D-jpMrLS.d.ts → types-C9k5gGhU.d.ts} +628 -14
- package/dist/types-DRiQaKFG.d.mts +254 -0
- package/dist/types-DRiQaKFG.d.ts +254 -0
- package/dist/types-Dmazk5Bk.d.mts +44 -0
- package/dist/types-Dmazk5Bk.d.ts +44 -0
- package/package.json +40 -40
- package/dist/add-LBBS4I3H.js.map +0 -1
- package/dist/add-RD3ZKFAT.mjs.map +0 -1
- package/dist/chunk-2JU376G7.js.map +0 -1
- package/dist/chunk-2ODBGSBI.js +0 -4
- package/dist/chunk-2ODBGSBI.js.map +0 -1
- package/dist/chunk-3GKPQB4R.mjs.map +0 -1
- package/dist/chunk-52GXX3MA.js +0 -426
- package/dist/chunk-52GXX3MA.js.map +0 -1
- package/dist/chunk-5NC5ILKA.js +0 -94
- package/dist/chunk-5NC5ILKA.js.map +0 -1
- package/dist/chunk-6I4EA43Y.js +0 -39
- package/dist/chunk-6I4EA43Y.js.map +0 -1
- package/dist/chunk-DTEKFQ4U.js +0 -159
- package/dist/chunk-DTEKFQ4U.js.map +0 -1
- package/dist/chunk-F63YKTXA.mjs +0 -47
- package/dist/chunk-F63YKTXA.mjs.map +0 -1
- package/dist/chunk-FJLK5CFL.js.map +0 -1
- package/dist/chunk-GJSEBQXF.mjs +0 -392
- package/dist/chunk-GJSEBQXF.mjs.map +0 -1
- package/dist/chunk-J7ICRUU4.mjs +0 -426
- package/dist/chunk-J7ICRUU4.mjs.map +0 -1
- package/dist/chunk-KGDAENGD.js.map +0 -1
- package/dist/chunk-LD74LVRU.js +0 -47
- package/dist/chunk-LD74LVRU.js.map +0 -1
- package/dist/chunk-PCQVQ7SB.js +0 -45
- package/dist/chunk-PCQVQ7SB.js.map +0 -1
- package/dist/chunk-PR3JDWC3.mjs.map +0 -1
- package/dist/chunk-PWZBLTHR.js +0 -118
- package/dist/chunk-PWZBLTHR.js.map +0 -1
- package/dist/chunk-QEWDG5QE.mjs +0 -45
- package/dist/chunk-QEWDG5QE.mjs.map +0 -1
- package/dist/chunk-SMXXAVMB.js.map +0 -1
- package/dist/chunk-STV4ZVNA.mjs +0 -118
- package/dist/chunk-STV4ZVNA.mjs.map +0 -1
- package/dist/chunk-T5AZMMVS.mjs +0 -94
- package/dist/chunk-T5AZMMVS.mjs.map +0 -1
- package/dist/chunk-UU33HCCZ.mjs +0 -159
- package/dist/chunk-UU33HCCZ.mjs.map +0 -1
- package/dist/chunk-VGHLQXKB.js +0 -392
- package/dist/chunk-VGHLQXKB.js.map +0 -1
- package/dist/chunk-W5ZEP3CI.mjs.map +0 -1
- package/dist/chunk-Y666BJA5.mjs +0 -4
- package/dist/chunk-YFUZF7JM.mjs +0 -39
- package/dist/chunk-YFUZF7JM.mjs.map +0 -1
- package/dist/chunk-YN4436PK.mjs.map +0 -1
- package/dist/client-B2HqIKg6.d.ts +0 -51
- package/dist/client-XyCqclCi.d.mts +0 -51
- package/dist/client-browser.d.mts +0 -8
- package/dist/client-browser.d.ts +0 -8
- package/dist/client-browser.js +0 -85
- package/dist/client-browser.js.map +0 -1
- package/dist/client-browser.mjs +0 -85
- package/dist/client-browser.mjs.map +0 -1
- package/dist/client-node.d.mts +0 -8
- package/dist/client-node.d.ts +0 -8
- package/dist/client-node.js +0 -92
- package/dist/client-node.js.map +0 -1
- package/dist/client-node.mjs +0 -92
- package/dist/client-node.mjs.map +0 -1
- package/dist/evaluation/index.d.mts +0 -897
- package/dist/evaluation/index.d.ts +0 -897
- package/dist/evaluation/index.js +0 -14
- package/dist/evaluation/index.js.map +0 -1
- package/dist/evaluation/index.mjs +0 -14
- package/dist/filterable-batch-span-processor-zO5kcjBY.d.mts +0 -64
- package/dist/filterable-batch-span-processor-zO5kcjBY.d.ts +0 -64
- package/dist/init-XU2JFY6N.js +0 -16
- package/dist/list-7NPSX2E4.mjs.map +0 -1
- package/dist/list-ZXFLAF52.js.map +0 -1
- package/dist/login-76NQIHKR.js.map +0 -1
- package/dist/login-EK4WVOI2.mjs.map +0 -1
- package/dist/observability/index.d.mts +0 -260
- package/dist/observability/index.d.ts +0 -260
- package/dist/observability/index.js +0 -21
- package/dist/observability/index.js.map +0 -1
- package/dist/observability/index.mjs +0 -21
- package/dist/observability/index.mjs.map +0 -1
- package/dist/observability/instrumentation/langchain/index.d.mts +0 -40
- package/dist/observability/instrumentation/langchain/index.d.ts +0 -40
- package/dist/observability/instrumentation/langchain/index.js +0 -668
- package/dist/observability/instrumentation/langchain/index.js.map +0 -1
- package/dist/observability/instrumentation/langchain/index.mjs +0 -668
- package/dist/observability/instrumentation/langchain/index.mjs.map +0 -1
- package/dist/prompt/index.d.mts +0 -10
- package/dist/prompt/index.d.ts +0 -10
- package/dist/prompt/index.js +0 -22
- package/dist/prompt/index.js.map +0 -1
- package/dist/prompt/index.mjs +0 -22
- package/dist/prompt/index.mjs.map +0 -1
- package/dist/record-evaluation-CmxMXa-3.d.mts +0 -25
- package/dist/record-evaluation-CmxMXa-3.d.ts +0 -25
- package/dist/remove-SDJYEPAY.mjs.map +0 -1
- package/dist/remove-XBNGIVMR.js.map +0 -1
- package/dist/sync-EISKGPTL.js.map +0 -1
- package/dist/sync-ST2IWXSB.mjs.map +0 -1
- package/dist/trace-CqaKo0kZ.d.ts +0 -622
- package/dist/trace-DtVc5GhF.d.mts +0 -622
- /package/dist/{chunk-Y666BJA5.mjs.map → chunk-CU3443HD.mjs.map} +0 -0
- /package/dist/{chunk-E7UE2MPD.mjs.map → chunk-ECUXLXFT.mjs.map} +0 -0
- /package/dist/{create-QUZYBMQB.mjs.map → create-MK7NEGCM.mjs.map} +0 -0
- /package/dist/{init-H67RW22E.mjs.map → init-RINSTP4L.mjs.map} +0 -0
- /package/dist/{evaluation → observability-sdk}/index.mjs.map +0 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,48 +1,129 @@
|
|
|
1
|
-
|
|
2
|
-
export { F as FilterableBatchSpanProcessor, S as SpanProcessingExcludeRule } from './
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export { getPrompt, getPromptVersion } from './prompt/index.mjs';
|
|
7
|
-
import '@opentelemetry/api';
|
|
8
|
-
import './prompt-D-jpMrLS.mjs';
|
|
1
|
+
import { L as Logger, C as ConsoleLogger, N as NoOpLogger } from './index-DTEZr0Jn.mjs';
|
|
2
|
+
export { F as FilterableBatchSpanProcessor, L as LangWatchExporter, S as SpanProcessingExcludeRule, g as getLangWatchLogger, d as getLangWatchTracer } from './implementation-C4lvooSg.mjs';
|
|
3
|
+
export { l as attributes } from './types-DRiQaKFG.mjs';
|
|
4
|
+
import { p as paths, P as PromptResponse, g as Prompt } from './types-1q5wIYP5.mjs';
|
|
5
|
+
import openApiCreateClient from 'openapi-fetch';
|
|
9
6
|
import '@opentelemetry/sdk-trace-base';
|
|
7
|
+
import '@opentelemetry/exporter-trace-otlp-http';
|
|
8
|
+
import '@opentelemetry/api-logs';
|
|
9
|
+
import '@opentelemetry/api';
|
|
10
|
+
import '@opentelemetry/semantic-conventions';
|
|
11
|
+
import '@opentelemetry/semantic-conventions/incubating';
|
|
12
|
+
|
|
13
|
+
type LangwatchApiClient = ReturnType<typeof openApiCreateClient<paths>>;
|
|
14
|
+
|
|
15
|
+
interface InternalConfig {
|
|
16
|
+
langwatchApiClient: LangwatchApiClient;
|
|
17
|
+
logger: Logger;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type CreatePromptBody = NonNullable<paths["/api/prompts"]["post"]["requestBody"]>["content"]["application/json"];
|
|
21
|
+
type UpdatePromptBody = NonNullable<paths["/api/prompts/{id}"]["put"]["requestBody"]>["content"]["application/json"];
|
|
22
|
+
|
|
23
|
+
type SyncAction = "created" | "updated" | "conflict" | "up_to_date";
|
|
24
|
+
type ConfigData = NonNullable<paths["/api/prompts/{id}/sync"]["post"]["requestBody"]>["content"]["application/json"]["configData"];
|
|
25
|
+
interface SyncResult {
|
|
26
|
+
action: SyncAction;
|
|
27
|
+
prompt?: PromptResponse;
|
|
28
|
+
conflictInfo?: {
|
|
29
|
+
localVersion: number;
|
|
30
|
+
remoteVersion: number;
|
|
31
|
+
differences: string[];
|
|
32
|
+
remoteConfigData: ConfigData;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
10
35
|
|
|
11
36
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* This exporter automatically configures:
|
|
16
|
-
* - Authorization headers using the provided API key or environment variables/fallback
|
|
17
|
-
* - SDK version and language identification headers
|
|
18
|
-
* - Proper endpoint configuration for LangWatch ingestion using provided URL or environment variables/fallback
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* import { LangWatchExporter } from '@langwatch/observability';
|
|
23
|
-
*
|
|
24
|
-
* // Using environment variables/fallback configuration
|
|
25
|
-
* const exporter = new LangWatchExporter();
|
|
26
|
-
*
|
|
27
|
-
* // Using custom API key and endpoint
|
|
28
|
-
*
|
|
29
|
-
* // With environment variables/fallback configuration
|
|
30
|
-
* const exporter = new LangWatchExporter();
|
|
31
|
-
*
|
|
32
|
-
* // With custom API key and endpoint
|
|
33
|
-
* const exporter = new LangWatchExporter('api-key', 'https://custom.langwatch.com');
|
|
34
|
-
* ```
|
|
37
|
+
* Facade for prompt operations in the LangWatch SDK.
|
|
38
|
+
* Provides a simplified interface for common prompt management tasks.
|
|
35
39
|
*/
|
|
36
|
-
declare class
|
|
40
|
+
declare class PromptsFacade {
|
|
41
|
+
private readonly service;
|
|
42
|
+
private readonly config;
|
|
43
|
+
constructor(config: InternalConfig);
|
|
44
|
+
/**
|
|
45
|
+
* Creates a new prompt.
|
|
46
|
+
* @param data The prompt creation payload.
|
|
47
|
+
* @returns The created Prompt instance.
|
|
48
|
+
* @throws {PromptsError} If the API call fails.
|
|
49
|
+
*/
|
|
50
|
+
create(data: CreatePromptBody): Promise<Prompt>;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves a prompt by handle or ID.
|
|
53
|
+
* @param handleOrId The prompt's handle or unique identifier.
|
|
54
|
+
* @param options Optional parameters for the request.
|
|
55
|
+
* @returns The Prompt instance or null if not found.
|
|
56
|
+
* @throws {PromptsError} If the API call fails.
|
|
57
|
+
*/
|
|
58
|
+
get(handleOrId: string, options?: {
|
|
59
|
+
version?: string;
|
|
60
|
+
}): Promise<Prompt | null>;
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves all prompts.
|
|
63
|
+
* @returns Array of Prompt instances.
|
|
64
|
+
* @throws {PromptsError} If the API call fails.
|
|
65
|
+
*/
|
|
66
|
+
getAll(): Promise<Prompt[]>;
|
|
37
67
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
68
|
+
* Updates an existing prompt.
|
|
69
|
+
* @param handleOrId The prompt's handle or unique identifier.
|
|
70
|
+
* @param newData The update payload.
|
|
71
|
+
* @returns The updated Prompt instance.
|
|
72
|
+
* @throws {PromptsError} If the API call fails.
|
|
73
|
+
*/
|
|
74
|
+
update(handleOrId: string, newData: UpdatePromptBody): Promise<Prompt>;
|
|
75
|
+
/**
|
|
76
|
+
* Deletes a prompt by handle or ID.
|
|
77
|
+
* @param handleOrId The prompt's handle or unique identifier.
|
|
78
|
+
* @throws {PromptsError} If the API call fails.
|
|
79
|
+
*/
|
|
80
|
+
delete(handleOrId: string): Promise<{
|
|
81
|
+
success: boolean;
|
|
82
|
+
}>;
|
|
83
|
+
/**
|
|
84
|
+
* Syncs a prompt with the server.
|
|
85
|
+
* @param params The sync parameters.
|
|
86
|
+
* @returns The sync result.
|
|
87
|
+
* @throws {PromptsError} If the API call fails.
|
|
88
|
+
*/
|
|
89
|
+
sync(params: {
|
|
90
|
+
name: string;
|
|
91
|
+
configData: any;
|
|
92
|
+
localVersion?: number;
|
|
93
|
+
commitMessage?: string;
|
|
94
|
+
}): Promise<SyncResult>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
interface GetTraceParams {
|
|
98
|
+
includeSpans?: boolean;
|
|
99
|
+
}
|
|
100
|
+
type GetTraceResponse = NonNullable<paths["/api/trace/{id}"]["get"]["responses"]["200"]["content"]["application/json"]>;
|
|
101
|
+
|
|
102
|
+
declare class TracesFacade {
|
|
103
|
+
#private;
|
|
104
|
+
constructor(config: InternalConfig);
|
|
105
|
+
get(traceId: string, params?: GetTraceParams): Promise<GetTraceResponse>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
interface LangWatchConstructorOptions {
|
|
109
|
+
apiKey?: string;
|
|
110
|
+
endpoint?: string;
|
|
111
|
+
options?: {
|
|
112
|
+
logger?: Logger;
|
|
113
|
+
};
|
|
46
114
|
}
|
|
115
|
+
declare class LangWatch {
|
|
116
|
+
#private;
|
|
117
|
+
private readonly config;
|
|
118
|
+
private readonly tracer;
|
|
119
|
+
readonly prompts: PromptsFacade;
|
|
120
|
+
readonly traces: TracesFacade;
|
|
121
|
+
constructor(options?: LangWatchConstructorOptions);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare const logger: {
|
|
125
|
+
ConsoleLogger: typeof ConsoleLogger;
|
|
126
|
+
NoOpLogger: typeof NoOpLogger;
|
|
127
|
+
};
|
|
47
128
|
|
|
48
|
-
export {
|
|
129
|
+
export { LangWatch, logger };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,48 +1,129 @@
|
|
|
1
|
-
|
|
2
|
-
export { F as FilterableBatchSpanProcessor, S as SpanProcessingExcludeRule } from './
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export { getPrompt, getPromptVersion } from './prompt/index.js';
|
|
7
|
-
import '@opentelemetry/api';
|
|
8
|
-
import './prompt-D-jpMrLS.js';
|
|
1
|
+
import { L as Logger, C as ConsoleLogger, N as NoOpLogger } from './index-DTEZr0Jn.js';
|
|
2
|
+
export { F as FilterableBatchSpanProcessor, L as LangWatchExporter, S as SpanProcessingExcludeRule, g as getLangWatchLogger, d as getLangWatchTracer } from './implementation-CzemP9jY.js';
|
|
3
|
+
export { l as attributes } from './types-DRiQaKFG.js';
|
|
4
|
+
import { p as paths, P as PromptResponse, g as Prompt } from './types-C9k5gGhU.js';
|
|
5
|
+
import openApiCreateClient from 'openapi-fetch';
|
|
9
6
|
import '@opentelemetry/sdk-trace-base';
|
|
7
|
+
import '@opentelemetry/exporter-trace-otlp-http';
|
|
8
|
+
import '@opentelemetry/api-logs';
|
|
9
|
+
import '@opentelemetry/api';
|
|
10
|
+
import '@opentelemetry/semantic-conventions';
|
|
11
|
+
import '@opentelemetry/semantic-conventions/incubating';
|
|
12
|
+
|
|
13
|
+
type LangwatchApiClient = ReturnType<typeof openApiCreateClient<paths>>;
|
|
14
|
+
|
|
15
|
+
interface InternalConfig {
|
|
16
|
+
langwatchApiClient: LangwatchApiClient;
|
|
17
|
+
logger: Logger;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type CreatePromptBody = NonNullable<paths["/api/prompts"]["post"]["requestBody"]>["content"]["application/json"];
|
|
21
|
+
type UpdatePromptBody = NonNullable<paths["/api/prompts/{id}"]["put"]["requestBody"]>["content"]["application/json"];
|
|
22
|
+
|
|
23
|
+
type SyncAction = "created" | "updated" | "conflict" | "up_to_date";
|
|
24
|
+
type ConfigData = NonNullable<paths["/api/prompts/{id}/sync"]["post"]["requestBody"]>["content"]["application/json"]["configData"];
|
|
25
|
+
interface SyncResult {
|
|
26
|
+
action: SyncAction;
|
|
27
|
+
prompt?: PromptResponse;
|
|
28
|
+
conflictInfo?: {
|
|
29
|
+
localVersion: number;
|
|
30
|
+
remoteVersion: number;
|
|
31
|
+
differences: string[];
|
|
32
|
+
remoteConfigData: ConfigData;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
10
35
|
|
|
11
36
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* This exporter automatically configures:
|
|
16
|
-
* - Authorization headers using the provided API key or environment variables/fallback
|
|
17
|
-
* - SDK version and language identification headers
|
|
18
|
-
* - Proper endpoint configuration for LangWatch ingestion using provided URL or environment variables/fallback
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* import { LangWatchExporter } from '@langwatch/observability';
|
|
23
|
-
*
|
|
24
|
-
* // Using environment variables/fallback configuration
|
|
25
|
-
* const exporter = new LangWatchExporter();
|
|
26
|
-
*
|
|
27
|
-
* // Using custom API key and endpoint
|
|
28
|
-
*
|
|
29
|
-
* // With environment variables/fallback configuration
|
|
30
|
-
* const exporter = new LangWatchExporter();
|
|
31
|
-
*
|
|
32
|
-
* // With custom API key and endpoint
|
|
33
|
-
* const exporter = new LangWatchExporter('api-key', 'https://custom.langwatch.com');
|
|
34
|
-
* ```
|
|
37
|
+
* Facade for prompt operations in the LangWatch SDK.
|
|
38
|
+
* Provides a simplified interface for common prompt management tasks.
|
|
35
39
|
*/
|
|
36
|
-
declare class
|
|
40
|
+
declare class PromptsFacade {
|
|
41
|
+
private readonly service;
|
|
42
|
+
private readonly config;
|
|
43
|
+
constructor(config: InternalConfig);
|
|
44
|
+
/**
|
|
45
|
+
* Creates a new prompt.
|
|
46
|
+
* @param data The prompt creation payload.
|
|
47
|
+
* @returns The created Prompt instance.
|
|
48
|
+
* @throws {PromptsError} If the API call fails.
|
|
49
|
+
*/
|
|
50
|
+
create(data: CreatePromptBody): Promise<Prompt>;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves a prompt by handle or ID.
|
|
53
|
+
* @param handleOrId The prompt's handle or unique identifier.
|
|
54
|
+
* @param options Optional parameters for the request.
|
|
55
|
+
* @returns The Prompt instance or null if not found.
|
|
56
|
+
* @throws {PromptsError} If the API call fails.
|
|
57
|
+
*/
|
|
58
|
+
get(handleOrId: string, options?: {
|
|
59
|
+
version?: string;
|
|
60
|
+
}): Promise<Prompt | null>;
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves all prompts.
|
|
63
|
+
* @returns Array of Prompt instances.
|
|
64
|
+
* @throws {PromptsError} If the API call fails.
|
|
65
|
+
*/
|
|
66
|
+
getAll(): Promise<Prompt[]>;
|
|
37
67
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
68
|
+
* Updates an existing prompt.
|
|
69
|
+
* @param handleOrId The prompt's handle or unique identifier.
|
|
70
|
+
* @param newData The update payload.
|
|
71
|
+
* @returns The updated Prompt instance.
|
|
72
|
+
* @throws {PromptsError} If the API call fails.
|
|
73
|
+
*/
|
|
74
|
+
update(handleOrId: string, newData: UpdatePromptBody): Promise<Prompt>;
|
|
75
|
+
/**
|
|
76
|
+
* Deletes a prompt by handle or ID.
|
|
77
|
+
* @param handleOrId The prompt's handle or unique identifier.
|
|
78
|
+
* @throws {PromptsError} If the API call fails.
|
|
79
|
+
*/
|
|
80
|
+
delete(handleOrId: string): Promise<{
|
|
81
|
+
success: boolean;
|
|
82
|
+
}>;
|
|
83
|
+
/**
|
|
84
|
+
* Syncs a prompt with the server.
|
|
85
|
+
* @param params The sync parameters.
|
|
86
|
+
* @returns The sync result.
|
|
87
|
+
* @throws {PromptsError} If the API call fails.
|
|
88
|
+
*/
|
|
89
|
+
sync(params: {
|
|
90
|
+
name: string;
|
|
91
|
+
configData: any;
|
|
92
|
+
localVersion?: number;
|
|
93
|
+
commitMessage?: string;
|
|
94
|
+
}): Promise<SyncResult>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
interface GetTraceParams {
|
|
98
|
+
includeSpans?: boolean;
|
|
99
|
+
}
|
|
100
|
+
type GetTraceResponse = NonNullable<paths["/api/trace/{id}"]["get"]["responses"]["200"]["content"]["application/json"]>;
|
|
101
|
+
|
|
102
|
+
declare class TracesFacade {
|
|
103
|
+
#private;
|
|
104
|
+
constructor(config: InternalConfig);
|
|
105
|
+
get(traceId: string, params?: GetTraceParams): Promise<GetTraceResponse>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
interface LangWatchConstructorOptions {
|
|
109
|
+
apiKey?: string;
|
|
110
|
+
endpoint?: string;
|
|
111
|
+
options?: {
|
|
112
|
+
logger?: Logger;
|
|
113
|
+
};
|
|
46
114
|
}
|
|
115
|
+
declare class LangWatch {
|
|
116
|
+
#private;
|
|
117
|
+
private readonly config;
|
|
118
|
+
private readonly tracer;
|
|
119
|
+
readonly prompts: PromptsFacade;
|
|
120
|
+
readonly traces: TracesFacade;
|
|
121
|
+
constructor(options?: LangWatchConstructorOptions);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare const logger: {
|
|
125
|
+
ConsoleLogger: typeof ConsoleLogger;
|
|
126
|
+
NoOpLogger: typeof NoOpLogger;
|
|
127
|
+
};
|
|
47
128
|
|
|
48
|
-
export {
|
|
129
|
+
export { LangWatch, logger };
|
package/dist/index.js
CHANGED
|
@@ -1,33 +1,37 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk5EVBOHJYjs = require('./chunk-5EVBOHJY.js');
|
|
4
|
+
require('./chunk-4ZSSHX6F.js');
|
|
4
5
|
|
|
5
6
|
|
|
6
|
-
var
|
|
7
|
-
require('./chunk-2ODBGSBI.js');
|
|
7
|
+
var _chunkYH5TIVK2js = require('./chunk-YH5TIVK2.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkM4VUHTT2js = require('./chunk-M4VUHTT2.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
15
|
-
require('./chunk-VGHLQXKB.js');
|
|
16
|
-
require('./chunk-SMXXAVMB.js');
|
|
17
|
-
require('./chunk-PCQVQ7SB.js');
|
|
14
|
+
var _chunkOUCVXP4Gjs = require('./chunk-OUCVXP4G.js');
|
|
18
15
|
|
|
19
16
|
|
|
20
17
|
|
|
21
|
-
var _chunk52GXX3MAjs = require('./chunk-52GXX3MA.js');
|
|
22
|
-
require('./chunk-DTEKFQ4U.js');
|
|
23
|
-
require('./chunk-FJLK5CFL.js');
|
|
24
18
|
|
|
19
|
+
var _chunkDISMHYXCjs = require('./chunk-DISMHYXC.js');
|
|
20
|
+
require('./chunk-SGNJDRCT.js');
|
|
21
|
+
require('./chunk-OXBO24RB.js');
|
|
25
22
|
|
|
23
|
+
// src/index.ts
|
|
24
|
+
var logger = {
|
|
25
|
+
ConsoleLogger: _chunkDISMHYXCjs.ConsoleLogger,
|
|
26
|
+
NoOpLogger: _chunkDISMHYXCjs.NoOpLogger
|
|
27
|
+
};
|
|
26
28
|
|
|
27
29
|
|
|
28
30
|
|
|
29
31
|
|
|
30
32
|
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
exports.FilterableBatchSpanProcessor = _chunkYH5TIVK2js.FilterableBatchSpanProcessor; exports.LangWatch = _chunk5EVBOHJYjs.LangWatch; exports.LangWatchExporter = _chunkOUCVXP4Gjs.LangWatchTraceExporter; exports.attributes = _chunkDISMHYXCjs.attributes_exports; exports.getLangWatchLogger = _chunkOUCVXP4Gjs.getLangWatchLogger; exports.getLangWatchTracer = _chunkM4VUHTT2js.getLangWatchTracer; exports.logger = logger;
|
|
33
37
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/index.js"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/index.js","../src/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B;AACA;ACPO,IAAM,OAAA,EAAS;AAAA,EACpB,6CAAA;AAAA,EACA;AACF,CAAA;ADSA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,iaAAC","file":"/home/runner/work/langwatch/langwatch/typescript-sdk/dist/index.js","sourcesContent":[null,"import { ConsoleLogger, NoOpLogger } from \"./logger\";\n\nexport {\n getLangWatchTracer,\n getLangWatchLogger,\n attributes,\n} from \"./observability-sdk\";\n\nexport {\n FilterableBatchSpanProcessor,\n type SpanProcessingExcludeRule,\n} from \"./observability-sdk/processors\";\nexport { LangWatchExporter } from \"./observability-sdk/exporters\";\nexport { LangWatch } from \"./client-sdk\";\n\nexport const logger = {\n ConsoleLogger,\n NoOpLogger,\n};\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,33 +1,37 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import
|
|
5
|
-
runEvaluation
|
|
6
|
-
} from "./chunk-STV4ZVNA.mjs";
|
|
7
|
-
import "./chunk-Y666BJA5.mjs";
|
|
2
|
+
LangWatch
|
|
3
|
+
} from "./chunk-GQMDZ4GY.mjs";
|
|
4
|
+
import "./chunk-LP76VXI3.mjs";
|
|
8
5
|
import {
|
|
9
6
|
FilterableBatchSpanProcessor
|
|
10
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-N2V6J3U2.mjs";
|
|
11
8
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from "./chunk-T5AZMMVS.mjs";
|
|
15
|
-
import "./chunk-GJSEBQXF.mjs";
|
|
16
|
-
import "./chunk-W5ZEP3CI.mjs";
|
|
17
|
-
import "./chunk-QEWDG5QE.mjs";
|
|
9
|
+
getLangWatchTracer
|
|
10
|
+
} from "./chunk-EJWJXTPU.mjs";
|
|
18
11
|
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
} from "./chunk-
|
|
22
|
-
import
|
|
23
|
-
|
|
12
|
+
LangWatchTraceExporter,
|
|
13
|
+
getLangWatchLogger
|
|
14
|
+
} from "./chunk-PGWR3OQY.mjs";
|
|
15
|
+
import {
|
|
16
|
+
ConsoleLogger,
|
|
17
|
+
NoOpLogger,
|
|
18
|
+
attributes_exports
|
|
19
|
+
} from "./chunk-YNQ44U6D.mjs";
|
|
20
|
+
import "./chunk-SYMZPWZE.mjs";
|
|
21
|
+
import "./chunk-CU3443HD.mjs";
|
|
22
|
+
|
|
23
|
+
// src/index.ts
|
|
24
|
+
var logger = {
|
|
25
|
+
ConsoleLogger,
|
|
26
|
+
NoOpLogger
|
|
27
|
+
};
|
|
24
28
|
export {
|
|
25
29
|
FilterableBatchSpanProcessor,
|
|
26
|
-
|
|
30
|
+
LangWatch,
|
|
31
|
+
LangWatchTraceExporter as LangWatchExporter,
|
|
32
|
+
attributes_exports as attributes,
|
|
33
|
+
getLangWatchLogger,
|
|
27
34
|
getLangWatchTracer,
|
|
28
|
-
|
|
29
|
-
getPromptVersion,
|
|
30
|
-
recordEvaluation,
|
|
31
|
-
runEvaluation
|
|
35
|
+
logger
|
|
32
36
|
};
|
|
33
37
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { ConsoleLogger, NoOpLogger } from \"./logger\";\n\nexport {\n getLangWatchTracer,\n getLangWatchLogger,\n attributes,\n} from \"./observability-sdk\";\n\nexport {\n FilterableBatchSpanProcessor,\n type SpanProcessingExcludeRule,\n} from \"./observability-sdk/processors\";\nexport { LangWatchExporter } from \"./observability-sdk/exporters\";\nexport { LangWatch } from \"./client-sdk\";\n\nexport const logger = {\n ConsoleLogger,\n NoOpLogger,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAeO,IAAM,SAAS;AAAA,EACpB;AAAA,EACA;AACF;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkK64Y6YUGjs = require('./chunk-K64Y6YUG.js');
|
|
4
|
+
require('./chunk-D2CSG4SJ.js');
|
|
5
|
+
require('./chunk-SGNJDRCT.js');
|
|
6
|
+
require('./chunk-HA3LI5IK.js');
|
|
7
|
+
require('./chunk-OXBO24RB.js');
|
|
8
|
+
|
|
9
|
+
// src/cli/commands/init.ts
|
|
10
|
+
var initCommand = async () => {
|
|
11
|
+
await _chunkK64Y6YUGjs.initializeProject.call(void 0, );
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.initCommand = initCommand;
|
|
16
|
+
//# sourceMappingURL=init-GDKJICSS.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/init-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/init-GDKJICSS.js","../src/cli/commands/init.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B;AACA;ACNO,IAAM,YAAA,EAAc,MAAA,CAAA,EAAA,GAA2B;AACpD,EAAA,MAAM,gDAAA,CAAkB;AAC1B,CAAA;ADQA;AACE;AACF,kCAAC","file":"/home/runner/work/langwatch/langwatch/typescript-sdk/dist/init-GDKJICSS.js","sourcesContent":[null,"import { initializeProject } from \"../utils/init\";\n\nexport const initCommand = async (): Promise<void> => {\n await initializeProject();\n};"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
initializeProject
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-ECUXLXFT.mjs";
|
|
4
|
+
import "./chunk-HUI45ULC.mjs";
|
|
5
|
+
import "./chunk-SYMZPWZE.mjs";
|
|
5
6
|
import "./chunk-4NRLVT2U.mjs";
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-YN4436PK.mjs";
|
|
7
|
+
import "./chunk-CU3443HD.mjs";
|
|
8
8
|
|
|
9
9
|
// src/cli/commands/init.ts
|
|
10
10
|
var initCommand = async () => {
|
|
@@ -13,4 +13,4 @@ var initCommand = async () => {
|
|
|
13
13
|
export {
|
|
14
14
|
initCommand
|
|
15
15
|
};
|
|
16
|
-
//# sourceMappingURL=init-
|
|
16
|
+
//# sourceMappingURL=init-RINSTP4L.mjs.map
|
|
@@ -2,12 +2,17 @@ import {
|
|
|
2
2
|
checkApiKey
|
|
3
3
|
} from "./chunk-DHJKJVY7.mjs";
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
LangWatch
|
|
6
|
+
} from "./chunk-GQMDZ4GY.mjs";
|
|
7
|
+
import {
|
|
6
8
|
PromptsError
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-LP76VXI3.mjs";
|
|
10
|
+
import "./chunk-N2V6J3U2.mjs";
|
|
11
|
+
import "./chunk-EJWJXTPU.mjs";
|
|
12
|
+
import "./chunk-PGWR3OQY.mjs";
|
|
13
|
+
import "./chunk-YNQ44U6D.mjs";
|
|
14
|
+
import "./chunk-SYMZPWZE.mjs";
|
|
15
|
+
import "./chunk-CU3443HD.mjs";
|
|
11
16
|
|
|
12
17
|
// src/cli/commands/list.ts
|
|
13
18
|
import chalk from "chalk";
|
|
@@ -24,7 +29,10 @@ var formatTable = (data, headers) => {
|
|
|
24
29
|
headers.forEach((header) => {
|
|
25
30
|
colWidths[header] = Math.max(
|
|
26
31
|
header.length,
|
|
27
|
-
...data.map((row) =>
|
|
32
|
+
...data.map((row) => {
|
|
33
|
+
var _a;
|
|
34
|
+
return stripAnsi((_a = row[header]) != null ? _a : "").length;
|
|
35
|
+
})
|
|
28
36
|
);
|
|
29
37
|
});
|
|
30
38
|
const headerRow = headers.map((header) => chalk.bold(header.padEnd(colWidths[header]))).join(" ");
|
|
@@ -33,7 +41,8 @@ var formatTable = (data, headers) => {
|
|
|
33
41
|
console.log(chalk.gray(separator));
|
|
34
42
|
data.forEach((row) => {
|
|
35
43
|
const dataRow = headers.map((header) => {
|
|
36
|
-
|
|
44
|
+
var _a;
|
|
45
|
+
const value = (_a = row[header]) != null ? _a : "";
|
|
37
46
|
const strippedLength = stripAnsi(value).length;
|
|
38
47
|
const paddingNeeded = colWidths[header] - strippedLength;
|
|
39
48
|
const paddedValue = value + " ".repeat(Math.max(0, paddingNeeded));
|
|
@@ -70,10 +79,10 @@ var formatRelativeTime = (dateString) => {
|
|
|
70
79
|
var listCommand = async () => {
|
|
71
80
|
try {
|
|
72
81
|
checkApiKey();
|
|
73
|
-
const
|
|
82
|
+
const langwatch = new LangWatch();
|
|
74
83
|
const spinner = ora("Fetching prompts from server...").start();
|
|
75
84
|
try {
|
|
76
|
-
const allPrompts = await
|
|
85
|
+
const allPrompts = await langwatch.prompts.getAll();
|
|
77
86
|
const prompts = allPrompts.filter((prompt) => prompt.version);
|
|
78
87
|
const draftPrompts = allPrompts.filter((prompt) => !prompt.version);
|
|
79
88
|
spinner.succeed(
|
|
@@ -89,12 +98,15 @@ var listCommand = async () => {
|
|
|
89
98
|
return;
|
|
90
99
|
}
|
|
91
100
|
console.log();
|
|
92
|
-
const tableData = prompts.map((prompt) =>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
101
|
+
const tableData = prompts.map((prompt) => {
|
|
102
|
+
var _a, _b;
|
|
103
|
+
return {
|
|
104
|
+
Name: (_a = prompt.handle) != null ? _a : `${prompt.name} ` + chalk.gray(`(${prompt.id})`),
|
|
105
|
+
Version: prompt.version ? `${prompt.version}` : "N/A",
|
|
106
|
+
Model: (_b = prompt.model) != null ? _b : "N/A",
|
|
107
|
+
Updated: formatRelativeTime(prompt.updatedAt)
|
|
108
|
+
};
|
|
109
|
+
});
|
|
98
110
|
formatTable(tableData, ["Name", "Version", "Model", "Updated"]);
|
|
99
111
|
console.log();
|
|
100
112
|
console.log(
|
|
@@ -133,4 +145,4 @@ var listCommand = async () => {
|
|
|
133
145
|
export {
|
|
134
146
|
listCommand
|
|
135
147
|
};
|
|
136
|
-
//# sourceMappingURL=list-
|
|
148
|
+
//# sourceMappingURL=list-7L23G5DY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/list.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { PromptsError } from \"@/client-sdk/services/prompts\";\nimport { LangWatch } from \"@/client-sdk\";\nimport { checkApiKey } from \"../utils/apiKey\";\n\n// Helper to strip ANSI codes for length calculation\nconst stripAnsi = (str: string): string => {\n return str.replace(/\\u001b\\[[0-9;]*m/g, \"\");\n};\n\n// Simple table formatting helper\nconst formatTable = (\n data: Array<Record<string, string>>,\n headers: string[],\n): void => {\n if (data.length === 0) {\n console.log(chalk.gray(\"No prompts found\"));\n return;\n }\n\n // Calculate column widths (strip ANSI codes for accurate length calculation)\n const colWidths: Record<string, number> = {};\n headers.forEach((header) => {\n colWidths[header] = Math.max(\n header.length,\n ...data.map((row) => stripAnsi(row[header] ?? \"\").length),\n );\n });\n\n // Print header\n const headerRow = headers\n .map((header) => chalk.bold(header.padEnd(colWidths[header]!)))\n .join(\" \");\n console.log(headerRow);\n\n // Print separator\n const separator = headers\n .map((header) => \"─\".repeat(colWidths[header]!))\n .join(\" \");\n console.log(chalk.gray(separator));\n\n // Print data rows\n data.forEach((row) => {\n const dataRow = headers\n .map((header) => {\n const value = row[header] ?? \"\";\n const strippedLength = stripAnsi(value).length;\n const paddingNeeded = colWidths[header]! - strippedLength;\n const paddedValue = value + \" \".repeat(Math.max(0, paddingNeeded));\n\n // Color coding\n if (header === \"Name\") {\n return chalk.cyan(paddedValue);\n } else if (header === \"Version\") {\n return chalk.green(paddedValue);\n } else if (header === \"Model\") {\n return chalk.yellow(paddedValue);\n } else {\n return chalk.gray(paddedValue);\n }\n })\n .join(\" \");\n console.log(dataRow);\n });\n};\n\nconst formatRelativeTime = (dateString: string): string => {\n const date = new Date(dateString);\n const now = new Date();\n const diffMs = now.getTime() - date.getTime();\n\n const seconds = Math.floor(diffMs / 1000);\n const minutes = Math.floor(seconds / 60);\n const hours = Math.floor(minutes / 60);\n const days = Math.floor(hours / 24);\n const months = Math.floor(days / 30);\n const years = Math.floor(days / 365);\n\n if (years > 0) return `${years}y ago`;\n if (months > 0) return `${months}mo ago`;\n if (days > 0) return `${days}d ago`;\n if (hours > 0) return `${hours}h ago`;\n if (minutes > 0) return `${minutes}m ago`;\n return `${seconds}s ago`;\n};\n\nexport const listCommand = async (): Promise<void> => {\n try {\n // Check API key before doing anything else\n checkApiKey();\n\n // Get LangWatch client\n const langwatch = new LangWatch();\n\n const spinner = ora(\"Fetching prompts from server...\").start();\n\n try {\n // Fetch all prompts\n const allPrompts = await langwatch.prompts.getAll();\n const prompts = allPrompts.filter((prompt) => prompt.version);\n const draftPrompts = allPrompts.filter((prompt) => !prompt.version);\n\n spinner.succeed(\n `Found ${prompts.length} published prompt${prompts.length !== 1 ? \"s\" : \"\"} ` +\n chalk.gray(\n `(+${draftPrompts.length} draft${\n draftPrompts.length !== 1 ? \"s\" : \"\"\n })`,\n ),\n );\n\n if (prompts.length === 0) {\n console.log();\n console.log(chalk.gray(\"No prompts found on the server.\"));\n console.log(chalk.gray(\"Create your first prompt with:\"));\n console.log(chalk.cyan(\" langwatch prompt init\"));\n return;\n }\n\n console.log();\n\n // Format prompts for table display\n const tableData = prompts.map((prompt) => ({\n Name: prompt.handle ?? `${prompt.name} ` + chalk.gray(`(${prompt.id})`),\n Version: prompt.version ? `${prompt.version}` : \"N/A\",\n Model: prompt.model ?? \"N/A\",\n Updated: formatRelativeTime(prompt.updatedAt),\n }));\n\n // Display table\n formatTable(tableData, [\"Name\", \"Version\", \"Model\", \"Updated\"]);\n\n console.log();\n console.log(\n chalk.gray(\n `Use ${chalk.cyan(\n \"langwatch prompt add <name>\",\n )} to add a prompt to your project`,\n ),\n );\n } catch (error) {\n spinner.fail();\n if (error instanceof PromptsError) {\n console.error(chalk.red(`Error: ${error.message}`));\n } else {\n console.error(\n chalk.red(\n `Error fetching prompts: ${\n error instanceof Error ? error.message : \"Unknown error\"\n }`,\n ),\n );\n }\n process.exit(1);\n }\n } catch (error) {\n if (error instanceof PromptsError) {\n console.error(chalk.red(`Error: ${error.message}`));\n } else {\n console.error(\n chalk.red(\n `Unexpected error: ${\n error instanceof Error ? error.message : \"Unknown error\"\n }`,\n ),\n );\n }\n process.exit(1);\n }\n};\n"],"mappings":"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","names":[]}
|