langwatch 0.4.1 → 0.5.1
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/{add-RGWB3264.js → add-4WXEWG5H.js} +63 -34
- package/dist/add-4WXEWG5H.js.map +1 -0
- package/dist/{add-WLUMK5VQ.mjs → add-D2WVVKIP.mjs} +48 -19
- package/dist/add-D2WVVKIP.mjs.map +1 -0
- package/dist/{chunk-K64Y6YUG.js → chunk-7OZKH5K2.js} +59 -19
- package/dist/chunk-7OZKH5K2.js.map +1 -0
- package/dist/{chunk-HA3LI5IK.js → chunk-AZHZ4NB4.js} +1 -1
- package/dist/{chunk-HA3LI5IK.js.map → chunk-AZHZ4NB4.js.map} +1 -1
- package/dist/{chunk-4NRLVT2U.mjs → chunk-BTBSMJTY.mjs} +1 -1
- package/dist/chunk-BTBSMJTY.mjs.map +1 -0
- package/dist/{chunk-D2CSG4SJ.js → chunk-CAZONSXV.js} +5 -5
- package/dist/{chunk-D2CSG4SJ.js.map → chunk-CAZONSXV.js.map} +1 -1
- package/dist/{chunk-HUI45ULC.mjs → chunk-CKVDNVFL.mjs} +3 -3
- package/dist/{chunk-ECUXLXFT.mjs → chunk-DLJO7AK5.mjs} +53 -13
- package/dist/chunk-DLJO7AK5.mjs.map +1 -0
- package/dist/{chunk-AZELEDOV.js → chunk-DSIQSULK.js} +15 -18
- package/dist/chunk-DSIQSULK.js.map +1 -0
- package/dist/{chunk-M4VUHTT2.js → chunk-ECOC36EA.js} +11 -11
- package/dist/chunk-ECOC36EA.js.map +1 -0
- package/dist/{chunk-IZ2U3ABC.mjs → chunk-H5PON53W.mjs} +67 -127
- package/dist/chunk-H5PON53W.mjs.map +1 -0
- package/dist/{chunk-4TF2O2TH.js → chunk-P4SQTYGN.js} +14 -14
- package/dist/{chunk-4TF2O2TH.js.map → chunk-P4SQTYGN.js.map} +1 -1
- package/dist/{chunk-DEVJ7BPE.js → chunk-QCYYSMCU.js} +2 -2
- package/dist/chunk-QCYYSMCU.js.map +1 -0
- package/dist/{chunk-EJWJXTPU.mjs → chunk-QZGTM76F.mjs} +8 -8
- package/dist/chunk-QZGTM76F.mjs.map +1 -0
- package/dist/{chunk-SGNJDRCT.js → chunk-R6FBJN7K.js} +22 -7
- package/dist/chunk-R6FBJN7K.js.map +1 -0
- package/dist/{chunk-5N5BUR2Z.js → chunk-SVXNUWZI.js} +68 -128
- package/dist/chunk-SVXNUWZI.js.map +1 -0
- package/dist/{chunk-SYMZPWZE.mjs → chunk-V5M3HUBV.mjs} +22 -7
- package/dist/chunk-V5M3HUBV.mjs.map +1 -0
- package/dist/{chunk-4ILMGMAP.mjs → chunk-YEGQXDTE.mjs} +5 -8
- package/dist/{chunk-4ILMGMAP.mjs.map → chunk-YEGQXDTE.mjs.map} +1 -1
- package/dist/{chunk-FQSWUK5N.mjs → chunk-YKFTFYKK.mjs} +2 -2
- package/dist/chunk-YKFTFYKK.mjs.map +1 -0
- package/dist/{chunk-ZJZ3MIWE.mjs → chunk-ZIULPOMQ.mjs} +2 -2
- package/dist/cli/index.js +9 -9
- package/dist/cli/index.mjs +8 -8
- package/dist/{create-7K2CC4KQ.js → create-4LG4N2A4.js} +27 -16
- package/dist/create-4LG4N2A4.js.map +1 -0
- package/dist/{create-MK7NEGCM.mjs → create-OQEMO4MU.mjs} +22 -11
- package/dist/create-OQEMO4MU.mjs.map +1 -0
- package/dist/{implementation-CzemP9jY.d.ts → implementation-BIlL6-SW.d.ts} +1 -1
- package/dist/{implementation-C4lvooSg.d.mts → implementation-fAgqv8OM.d.mts} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -7
- package/dist/index.mjs +6 -6
- package/dist/init-EKNL2SQE.js +16 -0
- package/dist/{init-GDKJICSS.js.map → init-EKNL2SQE.js.map} +1 -1
- package/dist/{init-RINSTP4L.mjs → init-MQXXHCNT.mjs} +5 -5
- package/dist/{list-DBUK47MA.js → list-GIAXAAH5.js} +10 -10
- package/dist/list-GIAXAAH5.js.map +1 -0
- package/dist/{list-ZOMRKOBV.mjs → list-PFWV7IU6.mjs} +7 -7
- package/dist/list-PFWV7IU6.mjs.map +1 -0
- package/dist/{login-A7LEPNBR.js → login-3STX2FAO.js} +3 -3
- package/dist/{login-A7LEPNBR.js.map → login-3STX2FAO.js.map} +1 -1
- package/dist/{login-ULPHWIAX.mjs → login-BYLXS23I.mjs} +2 -2
- package/dist/observability-sdk/index.d.mts +3 -3
- package/dist/observability-sdk/index.d.ts +3 -3
- package/dist/observability-sdk/index.js +4 -4
- package/dist/observability-sdk/index.mjs +3 -3
- package/dist/observability-sdk/instrumentation/langchain/index.d.mts +1 -1
- package/dist/observability-sdk/instrumentation/langchain/index.d.ts +1 -1
- package/dist/observability-sdk/instrumentation/langchain/index.js +3 -3
- package/dist/observability-sdk/instrumentation/langchain/index.mjs +1 -1
- package/dist/observability-sdk/setup/node/index.d.mts +1 -1
- package/dist/observability-sdk/setup/node/index.d.ts +1 -1
- package/dist/observability-sdk/setup/node/index.js +10 -10
- package/dist/observability-sdk/setup/node/index.mjs +2 -2
- package/dist/{remove-RAJBGHQQ.mjs → remove-FTF3EBYV.mjs} +8 -8
- package/dist/{remove-ODTJLFWR.js → remove-U3PILQDV.js} +16 -16
- package/dist/{remove-ODTJLFWR.js.map → remove-U3PILQDV.js.map} +1 -1
- package/dist/{sync-2IXPWN64.mjs → sync-FOW7DHAH.mjs} +27 -19
- package/dist/sync-FOW7DHAH.mjs.map +1 -0
- package/dist/{sync-PBOL5ODF.js → sync-T3T22GVZ.js} +45 -37
- package/dist/sync-T3T22GVZ.js.map +1 -0
- package/dist/{types-C9k5gGhU.d.ts → types-DyUmlaDx.d.ts} +973 -533
- package/dist/{types-1q5wIYP5.d.mts → types-jrEEZt9d.d.mts} +973 -533
- package/package.json +16 -14
- package/dist/add-RGWB3264.js.map +0 -1
- package/dist/add-WLUMK5VQ.mjs.map +0 -1
- package/dist/chunk-4NRLVT2U.mjs.map +0 -1
- package/dist/chunk-5N5BUR2Z.js.map +0 -1
- package/dist/chunk-AZELEDOV.js.map +0 -1
- package/dist/chunk-DEVJ7BPE.js.map +0 -1
- package/dist/chunk-ECUXLXFT.mjs.map +0 -1
- package/dist/chunk-EJWJXTPU.mjs.map +0 -1
- package/dist/chunk-FQSWUK5N.mjs.map +0 -1
- package/dist/chunk-IZ2U3ABC.mjs.map +0 -1
- package/dist/chunk-K64Y6YUG.js.map +0 -1
- package/dist/chunk-M4VUHTT2.js.map +0 -1
- package/dist/chunk-SGNJDRCT.js.map +0 -1
- package/dist/chunk-SYMZPWZE.mjs.map +0 -1
- package/dist/create-7K2CC4KQ.js.map +0 -1
- package/dist/create-MK7NEGCM.mjs.map +0 -1
- package/dist/init-GDKJICSS.js +0 -16
- package/dist/list-DBUK47MA.js.map +0 -1
- package/dist/list-ZOMRKOBV.mjs.map +0 -1
- package/dist/sync-2IXPWN64.mjs.map +0 -1
- package/dist/sync-PBOL5ODF.js.map +0 -1
- /package/dist/{chunk-HUI45ULC.mjs.map → chunk-CKVDNVFL.mjs.map} +0 -0
- /package/dist/{chunk-ZJZ3MIWE.mjs.map → chunk-ZIULPOMQ.mjs.map} +0 -0
- /package/dist/{init-RINSTP4L.mjs.map → init-MQXXHCNT.mjs.map} +0 -0
- /package/dist/{login-ULPHWIAX.mjs.map → login-BYLXS23I.mjs.map} +0 -0
- /package/dist/{remove-RAJBGHQQ.mjs.map → remove-FTF3EBYV.mjs.map} +0 -0
|
@@ -13,8 +13,11 @@ var PromptConverter = class {
|
|
|
13
13
|
model: prompt.model,
|
|
14
14
|
messages: prompt.messages,
|
|
15
15
|
prompt: prompt.prompt,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
temperature: prompt.temperature,
|
|
17
|
+
maxTokens: prompt.maxTokens,
|
|
18
|
+
inputs: prompt.inputs,
|
|
19
|
+
outputs: prompt.outputs,
|
|
20
|
+
updatedAt: prompt.updatedAt
|
|
18
21
|
};
|
|
19
22
|
}
|
|
20
23
|
/**
|
|
@@ -22,10 +25,20 @@ var PromptConverter = class {
|
|
|
22
25
|
* for saving to .prompt.yaml files.
|
|
23
26
|
*/
|
|
24
27
|
static fromMaterializedToYaml(prompt) {
|
|
25
|
-
|
|
28
|
+
const result = {
|
|
26
29
|
model: prompt.model,
|
|
27
30
|
messages: prompt.messages
|
|
28
31
|
};
|
|
32
|
+
if (prompt.temperature !== void 0 || prompt.maxTokens !== void 0) {
|
|
33
|
+
result.modelParameters = {};
|
|
34
|
+
if (prompt.temperature !== void 0) {
|
|
35
|
+
result.modelParameters.temperature = prompt.temperature;
|
|
36
|
+
}
|
|
37
|
+
if (prompt.maxTokens !== void 0) {
|
|
38
|
+
result.modelParameters.maxTokens = prompt.maxTokens;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
29
42
|
}
|
|
30
43
|
/**
|
|
31
44
|
* Converts a LocalPromptConfig (loaded from YAML) to the format
|
|
@@ -43,8 +56,8 @@ var PromptConverter = class {
|
|
|
43
56
|
* Used when converting to API format that separates system prompt from messages.
|
|
44
57
|
*/
|
|
45
58
|
static extractSystemPrompt(messages) {
|
|
46
|
-
var _a;
|
|
47
|
-
return ((_a = messages.find((m) => m.role === "system")) == null ? void 0 : _a.content)
|
|
59
|
+
var _a, _b;
|
|
60
|
+
return (_b = (_a = messages.find((m) => m.role === "system")) == null ? void 0 : _a.content) != null ? _b : "";
|
|
48
61
|
}
|
|
49
62
|
/**
|
|
50
63
|
* Filters out system messages from the messages array.
|
|
@@ -83,7 +96,9 @@ var PromptConverter = class {
|
|
|
83
96
|
config.messages.forEach((message, index) => {
|
|
84
97
|
var _a2;
|
|
85
98
|
if (!["system", "user", "assistant"].includes(message.role)) {
|
|
86
|
-
errors.push(
|
|
99
|
+
errors.push(
|
|
100
|
+
`Message ${index}: role must be 'system', 'user', or 'assistant'`
|
|
101
|
+
);
|
|
87
102
|
}
|
|
88
103
|
if (!((_a2 = message.content) == null ? void 0 : _a2.trim())) {
|
|
89
104
|
errors.push(`Message ${index}: content cannot be empty`);
|
|
@@ -97,4 +112,4 @@ var PromptConverter = class {
|
|
|
97
112
|
export {
|
|
98
113
|
PromptConverter
|
|
99
114
|
};
|
|
100
|
-
//# sourceMappingURL=chunk-
|
|
115
|
+
//# sourceMappingURL=chunk-V5M3HUBV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/utils/promptConverter.ts"],"sourcesContent":["import type { Prompt } from \"@/client-sdk/services/prompts/prompt\";\nimport type { LocalPromptConfig, MaterializedPrompt } from \"../types\";\n\n/**\n * Converter utility for transforming between YAML prompt format and API service format.\n *\n * The YAML format follows the GitHub .prompt.yaml file format standard,\n * while the API format is our internal prompt service schema tied to the database.\n *\n * This separation allows us to maintain and evolve both formats independently\n * while keeping the conversion logic centralized and well-tested.\n */\nexport class PromptConverter {\n /**\n * Converts a Prompt instance from the API service to the MaterializedPrompt format\n * used for saving to the .materialized directory.\n */\n static fromApiToMaterialized(prompt: Prompt): MaterializedPrompt {\n return {\n id: prompt.id,\n name: prompt.name,\n version: prompt.version,\n versionId: prompt.versionId,\n model: prompt.model,\n messages: prompt.messages,\n prompt: prompt.prompt,\n temperature: prompt.temperature,\n maxTokens: prompt.maxTokens,\n inputs: prompt.inputs,\n outputs: prompt.outputs,\n updatedAt: prompt.updatedAt,\n };\n }\n\n /**\n * Converts a MaterializedPrompt to the YAML content structure\n * for saving to .prompt.yaml files.\n */\n static fromMaterializedToYaml(prompt: MaterializedPrompt): {\n model: string;\n modelParameters?: {\n temperature?: number;\n maxTokens?: number;\n };\n messages: Array<{\n role: \"system\" | \"user\" | \"assistant\";\n content: string;\n }>;\n } {\n const result: any = {\n model: prompt.model,\n messages: prompt.messages,\n };\n\n // Add modelParameters if temperature or maxTokens exist\n if (prompt.temperature !== undefined || prompt.maxTokens !== undefined) {\n result.modelParameters = {};\n if (prompt.temperature !== undefined) {\n result.modelParameters.temperature = prompt.temperature;\n }\n if (prompt.maxTokens !== undefined) {\n result.modelParameters.maxTokens = prompt.maxTokens;\n }\n }\n\n return result;\n }\n\n /**\n * Converts a LocalPromptConfig (loaded from YAML) to the format\n * expected by the API service for upserting.\n */\n static fromLocalToApiFormat(config: LocalPromptConfig): {\n model: string;\n modelParameters?: {\n temperature?: number;\n max_tokens?: number;\n };\n messages: Array<{\n role: \"system\" | \"user\" | \"assistant\";\n content: string;\n }>;\n } {\n return {\n model: config.model,\n modelParameters: config.modelParameters,\n messages: config.messages,\n };\n }\n\n /**\n * Extracts the system prompt from messages array.\n * Used when converting to API format that separates system prompt from messages.\n */\n static extractSystemPrompt(\n messages: Array<{ role: string; content: string }>,\n ): string {\n return messages.find((m) => m.role === \"system\")?.content ?? \"\";\n }\n\n /**\n * Filters out system messages from the messages array.\n * Used when converting to API format that handles system prompt separately.\n */\n static filterNonSystemMessages(\n messages: Array<{\n role: \"system\" | \"user\" | \"assistant\";\n content: string;\n }>,\n ): Array<{ role: \"user\" | \"assistant\"; content: string }> {\n return messages.filter((m) => m.role !== \"system\") as Array<{\n role: \"user\" | \"assistant\";\n content: string;\n }>;\n }\n\n /**\n * Converts version specification strings to actual version constraints.\n * Handles npm-style version specs like \"latest\", \"5\", \"^5\", etc.\n */\n static parseVersionSpec(versionSpec: string): {\n type: \"latest\" | \"exact\" | \"tag\";\n value: string;\n } {\n if (versionSpec === \"latest\") {\n return { type: \"latest\", value: \"latest\" };\n }\n\n // For now, treat everything else as tags until we implement proper semver\n if (/^\\d+$/.test(versionSpec)) {\n return { type: \"exact\", value: versionSpec };\n }\n\n // Handle prefixes like ^, ~, etc. as tags for now\n return { type: \"tag\", value: versionSpec };\n }\n\n /**\n * Validates that a YAML config can be safely converted to API format.\n * Returns validation errors if any, or null if valid.\n */\n static validateForApiConversion(config: LocalPromptConfig): string[] {\n const errors: string[] = [];\n\n if (!config.model?.trim()) {\n errors.push(\"Model is required and cannot be empty\");\n }\n\n if (!config.messages || config.messages.length === 0) {\n errors.push(\"At least one message is required\");\n }\n\n if (config.messages) {\n config.messages.forEach((message, index) => {\n if (![\"system\", \"user\", \"assistant\"].includes(message.role)) {\n errors.push(\n `Message ${index}: role must be 'system', 'user', or 'assistant'`,\n );\n }\n if (!message.content?.trim()) {\n errors.push(`Message ${index}: content cannot be empty`);\n }\n });\n }\n\n return errors;\n }\n}\n"],"mappings":";AAYO,IAAM,kBAAN,MAAsB;AAAA;AAAA;AAAA;AAAA;AAAA,EAK3B,OAAO,sBAAsB,QAAoC;AAC/D,WAAO;AAAA,MACL,IAAI,OAAO;AAAA,MACX,MAAM,OAAO;AAAA,MACb,SAAS,OAAO;AAAA,MAChB,WAAW,OAAO;AAAA,MAClB,OAAO,OAAO;AAAA,MACd,UAAU,OAAO;AAAA,MACjB,QAAQ,OAAO;AAAA,MACf,aAAa,OAAO;AAAA,MACpB,WAAW,OAAO;AAAA,MAClB,QAAQ,OAAO;AAAA,MACf,SAAS,OAAO;AAAA,MAChB,WAAW,OAAO;AAAA,IACpB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,uBAAuB,QAU5B;AACA,UAAM,SAAc;AAAA,MAClB,OAAO,OAAO;AAAA,MACd,UAAU,OAAO;AAAA,IACnB;AAGA,QAAI,OAAO,gBAAgB,UAAa,OAAO,cAAc,QAAW;AACtE,aAAO,kBAAkB,CAAC;AAC1B,UAAI,OAAO,gBAAgB,QAAW;AACpC,eAAO,gBAAgB,cAAc,OAAO;AAAA,MAC9C;AACA,UAAI,OAAO,cAAc,QAAW;AAClC,eAAO,gBAAgB,YAAY,OAAO;AAAA,MAC5C;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,qBAAqB,QAU1B;AACA,WAAO;AAAA,MACL,OAAO,OAAO;AAAA,MACd,iBAAiB,OAAO;AAAA,MACxB,UAAU,OAAO;AAAA,IACnB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,oBACL,UACQ;AAhGZ;AAiGI,YAAO,oBAAS,KAAK,CAAC,MAAM,EAAE,SAAS,QAAQ,MAAxC,mBAA2C,YAA3C,YAAsD;AAAA,EAC/D;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,wBACL,UAIwD;AACxD,WAAO,SAAS,OAAO,CAAC,MAAM,EAAE,SAAS,QAAQ;AAAA,EAInD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,iBAAiB,aAGtB;AACA,QAAI,gBAAgB,UAAU;AAC5B,aAAO,EAAE,MAAM,UAAU,OAAO,SAAS;AAAA,IAC3C;AAGA,QAAI,QAAQ,KAAK,WAAW,GAAG;AAC7B,aAAO,EAAE,MAAM,SAAS,OAAO,YAAY;AAAA,IAC7C;AAGA,WAAO,EAAE,MAAM,OAAO,OAAO,YAAY;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,yBAAyB,QAAqC;AA7IvE;AA8II,UAAM,SAAmB,CAAC;AAE1B,QAAI,GAAC,YAAO,UAAP,mBAAc,SAAQ;AACzB,aAAO,KAAK,uCAAuC;AAAA,IACrD;AAEA,QAAI,CAAC,OAAO,YAAY,OAAO,SAAS,WAAW,GAAG;AACpD,aAAO,KAAK,kCAAkC;AAAA,IAChD;AAEA,QAAI,OAAO,UAAU;AACnB,aAAO,SAAS,QAAQ,CAAC,SAAS,UAAU;AAzJlD,YAAAA;AA0JQ,YAAI,CAAC,CAAC,UAAU,QAAQ,WAAW,EAAE,SAAS,QAAQ,IAAI,GAAG;AAC3D,iBAAO;AAAA,YACL,WAAW,KAAK;AAAA,UAClB;AAAA,QACF;AACA,YAAI,GAACA,MAAA,QAAQ,YAAR,gBAAAA,IAAiB,SAAQ;AAC5B,iBAAO,KAAK,WAAW,KAAK,2BAA2B;AAAA,QACzD;AAAA,MACF,CAAC;AAAA,IACH;AAEA,WAAO;AAAA,EACT;AACF;","names":["_a"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PromptsFacade,
|
|
3
3
|
createTracingProxy
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-H5PON53W.mjs";
|
|
5
5
|
import {
|
|
6
6
|
getLangWatchTracer
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-QZGTM76F.mjs";
|
|
8
8
|
import {
|
|
9
9
|
DEFAULT_ENDPOINT,
|
|
10
10
|
LANGWATCH_SDK_LANGUAGE,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
LANGWATCH_SDK_RUNTIME,
|
|
14
14
|
LANGWATCH_SDK_VERSION,
|
|
15
15
|
version
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-YKFTFYKK.mjs";
|
|
17
17
|
import {
|
|
18
18
|
NoOpLogger
|
|
19
19
|
} from "./chunk-YNQ44U6D.mjs";
|
|
@@ -103,19 +103,16 @@ var TracesService = class {
|
|
|
103
103
|
};
|
|
104
104
|
|
|
105
105
|
// src/client-sdk/services/traces/facade.ts
|
|
106
|
-
var
|
|
106
|
+
var _service;
|
|
107
107
|
var TracesFacade = class {
|
|
108
108
|
constructor(config) {
|
|
109
|
-
__privateAdd(this, _config);
|
|
110
109
|
__privateAdd(this, _service);
|
|
111
|
-
__privateSet(this, _config, config);
|
|
112
110
|
__privateSet(this, _service, new TracesService(config));
|
|
113
111
|
}
|
|
114
112
|
async get(traceId, params) {
|
|
115
113
|
return __privateGet(this, _service).get(traceId, params);
|
|
116
114
|
}
|
|
117
115
|
};
|
|
118
|
-
_config = new WeakMap();
|
|
119
116
|
_service = new WeakMap();
|
|
120
117
|
|
|
121
118
|
// src/client-sdk/index.ts
|
|
@@ -152,4 +149,4 @@ createInternalConfig_fn = function({
|
|
|
152
149
|
export {
|
|
153
150
|
LangWatch
|
|
154
151
|
};
|
|
155
|
-
//# sourceMappingURL=chunk-
|
|
152
|
+
//# sourceMappingURL=chunk-YEGQXDTE.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal/api/client.ts","../src/client-sdk/services/traces/types.ts","../src/client-sdk/services/traces/tracing/tracer.ts","../src/client-sdk/services/traces/service.ts","../src/client-sdk/services/traces/facade.ts","../src/client-sdk/index.ts"],"sourcesContent":["import openApiCreateClient from \"openapi-fetch\";\nimport type { paths } from \"../generated/openapi/api-client\";\nimport { version } from \"../../../package.json\";\nimport {\n LANGWATCH_SDK_LANGUAGE,\n LANGWATCH_SDK_NAME_OBSERVABILITY,\n LANGWATCH_SDK_RUNTIME,\n LANGWATCH_SDK_VERSION,\n} from \"../constants\";\n\nexport type LangwatchApiClient = ReturnType<typeof openApiCreateClient<paths>>;\n\nexport function createLangWatchApiClient(\n apiKey?: string,\n endpoint?: string\n): LangwatchApiClient {\n return openApiCreateClient<paths>({\n baseUrl: endpoint,\n headers: {\n ...(apiKey ? { authorization: `Bearer ${apiKey}`, 'x-auth-token': apiKey } : {}),\n \"content-type\": \"application/json\",\n \"user-agent\": `langwatch-sdk-node/${version}`,\n \"x-langwatch-sdk-name\": LANGWATCH_SDK_NAME_OBSERVABILITY,\n \"x-langwatch-sdk-language\": LANGWATCH_SDK_LANGUAGE,\n \"x-langwatch-sdk-version\": LANGWATCH_SDK_VERSION,\n \"x-langwatch-sdk-platform\": LANGWATCH_SDK_RUNTIME(),\n },\n });\n}\n","import type { paths } from \"@/internal/generated/openapi/api-client\";\n\nexport interface GetTraceParams {\n includeSpans?: boolean;\n}\n\nexport type GetTraceResponse = NonNullable<\n paths[\"/api/trace/{id}\"][\"get\"][\"responses\"][\"200\"][\"content\"][\"application/json\"]\n>;\n\n/**\n * Custom error class for Traces API operations.\n * Provides context about the failed operation and the original error.\n */\nexport class TracesError extends Error {\n constructor(\n message: string,\n public readonly operation: string,\n public readonly originalError?: any,\n ) {\n super(message);\n this.name = \"TracesError\";\n }\n}\n","import { LANGWATCH_SDK_NAME_CLIENT, LANGWATCH_SDK_VERSION } from \"@/internal/constants\";\nimport { getLangWatchTracer } from \"@/observability-sdk/tracer\";\n\nexport const tracer = getLangWatchTracer(`${LANGWATCH_SDK_NAME_CLIENT}.traces`, LANGWATCH_SDK_VERSION);\n","import { createTracingProxy } from \"@/client-sdk/tracing/create-tracing-proxy\";\nimport { type InternalConfig } from \"@/client-sdk/types\";\nimport { type GetTraceParams, TracesError, type GetTraceResponse } from \"./types\";\nimport { tracer } from \"./tracing\";\n\n/**\n * Service for managing trace resources via the Langwatch API.\n * Constructor creates a proxy that wraps the service and traces all methods.\n *\n * Responsibilities:\n * - Retrieving trace data\n * - Error handling with contextual information\n *\n * All methods return trace response objects directly.\n */\nexport class TracesService {\n private config: InternalConfig;\n\n constructor(config: InternalConfig) {\n this.config = config;\n\n /**\n * Wraps the service in a tracing proxy via the decorator.\n */\n return createTracingProxy(\n this as TracesService,\n tracer,\n );\n }\n\n /**\n * Handles API errors by throwing a TracesError with operation context.\n * @param operation Description of the operation being performed.\n * @param error The error object returned from the API client.\n * @throws {TracesError}\n */\n private handleApiError(operation: string, error: any): never {\n const errorMessage =\n typeof error === \"string\"\n ? error\n : error?.error ?? error?.message ?? \"Unknown error occurred\";\n throw new TracesError(\n `Failed to ${operation}: ${errorMessage}`,\n operation,\n error,\n );\n }\n\n /**\n * Retrieves a trace by its ID.\n * @param traceId The trace's unique identifier.\n * @param params Optional parameters for the request.\n * @returns The trace response object.\n * @throws {TracesError} If the API call fails.\n */\n async get(\n traceId: string,\n params?: GetTraceParams,\n ): Promise<GetTraceResponse> {\n const { data, error } = await this.config.langwatchApiClient.GET(\"/api/trace/{id}\", {\n params: {\n path: {\n id: traceId,\n },\n },\n query: params,\n });\n\n if (error) {\n this.handleApiError(\"get trace\", error);\n }\n\n return data;\n }\n}\n","import { type InternalConfig } from \"../../types\";\nimport { TracesService } from \"./service\";\nimport { type GetTraceParams, type GetTraceResponse } from \"./types\";\n\nexport class TracesFacade {\n readonly #
|
|
1
|
+
{"version":3,"sources":["../src/internal/api/client.ts","../src/client-sdk/services/traces/types.ts","../src/client-sdk/services/traces/tracing/tracer.ts","../src/client-sdk/services/traces/service.ts","../src/client-sdk/services/traces/facade.ts","../src/client-sdk/index.ts"],"sourcesContent":["import openApiCreateClient from \"openapi-fetch\";\nimport type { paths } from \"../generated/openapi/api-client\";\nimport { version } from \"../../../package.json\";\nimport {\n LANGWATCH_SDK_LANGUAGE,\n LANGWATCH_SDK_NAME_OBSERVABILITY,\n LANGWATCH_SDK_RUNTIME,\n LANGWATCH_SDK_VERSION,\n} from \"../constants\";\n\nexport type LangwatchApiClient = ReturnType<typeof openApiCreateClient<paths>>;\n\nexport function createLangWatchApiClient(\n apiKey?: string,\n endpoint?: string\n): LangwatchApiClient {\n return openApiCreateClient<paths>({\n baseUrl: endpoint,\n headers: {\n ...(apiKey ? { authorization: `Bearer ${apiKey}`, 'x-auth-token': apiKey } : {}),\n \"content-type\": \"application/json\",\n \"user-agent\": `langwatch-sdk-node/${version}`,\n \"x-langwatch-sdk-name\": LANGWATCH_SDK_NAME_OBSERVABILITY,\n \"x-langwatch-sdk-language\": LANGWATCH_SDK_LANGUAGE,\n \"x-langwatch-sdk-version\": LANGWATCH_SDK_VERSION,\n \"x-langwatch-sdk-platform\": LANGWATCH_SDK_RUNTIME(),\n },\n });\n}\n","import type { paths } from \"@/internal/generated/openapi/api-client\";\n\nexport interface GetTraceParams {\n includeSpans?: boolean;\n}\n\nexport type GetTraceResponse = NonNullable<\n paths[\"/api/trace/{id}\"][\"get\"][\"responses\"][\"200\"][\"content\"][\"application/json\"]\n>;\n\n/**\n * Custom error class for Traces API operations.\n * Provides context about the failed operation and the original error.\n */\nexport class TracesError extends Error {\n constructor(\n message: string,\n public readonly operation: string,\n public readonly originalError?: any,\n ) {\n super(message);\n this.name = \"TracesError\";\n }\n}\n","import { LANGWATCH_SDK_NAME_CLIENT, LANGWATCH_SDK_VERSION } from \"@/internal/constants\";\nimport { getLangWatchTracer } from \"@/observability-sdk/tracer\";\n\nexport const tracer = getLangWatchTracer(`${LANGWATCH_SDK_NAME_CLIENT}.traces`, LANGWATCH_SDK_VERSION);\n","import { createTracingProxy } from \"@/client-sdk/tracing/create-tracing-proxy\";\nimport { type InternalConfig } from \"@/client-sdk/types\";\nimport { type GetTraceParams, TracesError, type GetTraceResponse } from \"./types\";\nimport { tracer } from \"./tracing\";\n\n/**\n * Service for managing trace resources via the Langwatch API.\n * Constructor creates a proxy that wraps the service and traces all methods.\n *\n * Responsibilities:\n * - Retrieving trace data\n * - Error handling with contextual information\n *\n * All methods return trace response objects directly.\n */\nexport class TracesService {\n private config: InternalConfig;\n\n constructor(config: InternalConfig) {\n this.config = config;\n\n /**\n * Wraps the service in a tracing proxy via the decorator.\n */\n return createTracingProxy(\n this as TracesService,\n tracer,\n );\n }\n\n /**\n * Handles API errors by throwing a TracesError with operation context.\n * @param operation Description of the operation being performed.\n * @param error The error object returned from the API client.\n * @throws {TracesError}\n */\n private handleApiError(operation: string, error: any): never {\n const errorMessage =\n typeof error === \"string\"\n ? error\n : error?.error ?? error?.message ?? \"Unknown error occurred\";\n throw new TracesError(\n `Failed to ${operation}: ${errorMessage}`,\n operation,\n error,\n );\n }\n\n /**\n * Retrieves a trace by its ID.\n * @param traceId The trace's unique identifier.\n * @param params Optional parameters for the request.\n * @returns The trace response object.\n * @throws {TracesError} If the API call fails.\n */\n async get(\n traceId: string,\n params?: GetTraceParams,\n ): Promise<GetTraceResponse> {\n const { data, error } = await this.config.langwatchApiClient.GET(\"/api/trace/{id}\", {\n params: {\n path: {\n id: traceId,\n },\n },\n query: params,\n });\n\n if (error) {\n this.handleApiError(\"get trace\", error);\n }\n\n return data;\n }\n}\n","import { type InternalConfig } from \"../../types\";\nimport { TracesService } from \"./service\";\nimport { type GetTraceParams, type GetTraceResponse } from \"./types\";\n\nexport class TracesFacade {\n readonly #service: TracesService;\n\n constructor(config: InternalConfig) {\n this.#service = new TracesService(config);\n }\n\n async get(traceId: string, params?: GetTraceParams): Promise<GetTraceResponse> {\n return this.#service.get(traceId, params);\n }\n}\n","import { PromptFacade as PromptsFacade } from \"./services/prompts\";\nimport { type InternalConfig } from \"./types\";\nimport { createLangWatchApiClient } from \"../internal/api/client\";\nimport { type Logger, NoOpLogger } from \"../logger\";\nimport { TracesFacade } from \"./services/traces/facade\";\nimport { getLangWatchTracer, type LangWatchTracer } from \"@/observability-sdk\";\nimport { LANGWATCH_SDK_NAME_CLIENT, LANGWATCH_SDK_VERSION, DEFAULT_ENDPOINT } from \"@/internal/constants\";\nexport interface LangWatchConstructorOptions {\n apiKey?: string;\n endpoint?: string;\n options?: {\n logger?: Logger;\n };\n}\n\nexport class LangWatch {\n private readonly config: InternalConfig;\n private readonly tracer: LangWatchTracer = getLangWatchTracer(LANGWATCH_SDK_NAME_CLIENT, LANGWATCH_SDK_VERSION);\n\n readonly prompts: PromptsFacade;\n readonly traces: TracesFacade;\n\n constructor(options: LangWatchConstructorOptions = {}) {\n const apiKey = options.apiKey ?? process.env.LANGWATCH_API_KEY ?? \"\";\n const endpoint = options.endpoint ?? process.env.LANGWATCH_ENDPOINT ?? DEFAULT_ENDPOINT;\n\n this.config = this.#createInternalConfig({\n apiKey,\n endpoint,\n options: options.options,\n });\n\n this.prompts = new PromptsFacade(this.config);\n this.traces = new TracesFacade(this.config);\n }\n\n #createInternalConfig({\n apiKey,\n endpoint,\n options,\n }: {\n apiKey: string;\n endpoint: string;\n options?: LangWatchConstructorOptions[\"options\"];\n }): InternalConfig {\n return {\n logger: options?.logger ?? new NoOpLogger(),\n langwatchApiClient: createLangWatchApiClient(apiKey, endpoint),\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,yBAAyB;AAYzB,SAAS,yBACd,QACA,UACoB;AACpB,SAAO,oBAA2B;AAAA,IAChC,SAAS;AAAA,IACT,SAAS,iCACH,SAAS,EAAE,eAAe,UAAU,MAAM,IAAI,gBAAgB,OAAO,IAAI,CAAC,IADvE;AAAA,MAEP,gBAAgB;AAAA,MAChB,cAAc,sBAAsB,OAAO;AAAA,MAC3C,wBAAwB;AAAA,MACxB,4BAA4B;AAAA,MAC5B,2BAA2B;AAAA,MAC3B,4BAA4B,sBAAsB;AAAA,IACpD;AAAA,EACF,CAAC;AACH;;;ACdO,IAAM,cAAN,cAA0B,MAAM;AAAA,EACrC,YACE,SACgB,WACA,eAChB;AACA,UAAM,OAAO;AAHG;AACA;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;;;ACpBO,IAAM,SAAS,mBAAmB,GAAG,yBAAyB,WAAW,qBAAqB;;;ACY9F,IAAM,gBAAN,MAAoB;AAAA,EAGzB,YAAY,QAAwB;AAClC,SAAK,SAAS;AAKd,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQQ,eAAe,WAAmB,OAAmB;AApC/D;AAqCI,UAAM,eACJ,OAAO,UAAU,WACb,SACA,0CAAO,UAAP,YAAgB,+BAAO,YAAvB,YAAkC;AACxC,UAAM,IAAI;AAAA,MACR,aAAa,SAAS,KAAK,YAAY;AAAA,MACvC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,IACJ,SACA,QAC2B;AAC3B,UAAM,EAAE,MAAM,MAAM,IAAI,MAAM,KAAK,OAAO,mBAAmB,IAAI,mBAAmB;AAAA,MAClF,QAAQ;AAAA,QACN,MAAM;AAAA,UACJ,IAAI;AAAA,QACN;AAAA,MACF;AAAA,MACA,OAAO;AAAA,IACT,CAAC;AAED,QAAI,OAAO;AACT,WAAK,eAAe,aAAa,KAAK;AAAA,IACxC;AAEA,WAAO;AAAA,EACT;AACF;;;AC1EA;AAIO,IAAM,eAAN,MAAmB;AAAA,EAGxB,YAAY,QAAwB;AAFpC,uBAAS;AAGP,uBAAK,UAAW,IAAI,cAAc,MAAM;AAAA,EAC1C;AAAA,EAEA,MAAM,IAAI,SAAiB,QAAoD;AAC7E,WAAO,mBAAK,UAAS,IAAI,SAAS,MAAM;AAAA,EAC1C;AACF;AATW;;;ACLX;AAeO,IAAM,YAAN,MAAgB;AAAA,EAOrB,YAAY,UAAuC,CAAC,GAAG;AAPlD;AAEL,SAAiB,SAA0B,mBAAmB,2BAA2B,qBAAqB;AAjBhH;AAuBI,UAAM,UAAS,mBAAQ,WAAR,YAAkB,QAAQ,IAAI,sBAA9B,YAAmD;AAClE,UAAM,YAAW,mBAAQ,aAAR,YAAoB,QAAQ,IAAI,uBAAhC,YAAsD;AAEvE,SAAK,SAAS,sBAAK,+CAAL,WAA2B;AAAA,MACvC;AAAA,MACA;AAAA,MACA,SAAS,QAAQ;AAAA,IACnB;AAEA,SAAK,UAAU,IAAI,cAAc,KAAK,MAAM;AAC5C,SAAK,SAAS,IAAI,aAAa,KAAK,MAAM;AAAA,EAC5C;AAgBF;AAnCO;AAqBL,0BAAqB,SAAC;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AACF,GAImB;AA5CrB;AA6CI,SAAO;AAAA,IACL,SAAQ,wCAAS,WAAT,YAAmB,IAAI,WAAW;AAAA,IAC1C,oBAAoB,yBAAyB,QAAQ,QAAQ;AAAA,EAC/D;AACF;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.
|
|
2
|
+
var version = "0.5.1";
|
|
3
3
|
|
|
4
4
|
// src/internal/runtime.ts
|
|
5
5
|
var _runtime;
|
|
@@ -60,4 +60,4 @@ export {
|
|
|
60
60
|
TRACES_PATH,
|
|
61
61
|
LOGS_PATH
|
|
62
62
|
};
|
|
63
|
-
//# sourceMappingURL=chunk-
|
|
63
|
+
//# sourceMappingURL=chunk-YKFTFYKK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/internal/runtime.ts","../src/internal/constants.ts"],"sourcesContent":["{\n \"name\": \"langwatch\",\n \"version\": \"0.5.1\",\n \"description\": \"LangWatch TypeScript/JavaScript SDK. Interact with the full LangWatch API and use the LangWatch OpenTelemetry SDK to instrument your application. For more information, see https://docs.langwatch.ai/integration/typescript/guide\",\n \"main\": \"dist/index.js\",\n \"module\": \"dist/index.mjs\",\n \"types\": \"dist/index.d.ts\",\n \"author\": \"LangWatch\",\n \"license\": \"MIT\",\n \"engines\": {\n \"node\": \">=20\",\n \"pnpm\": \">=8\"\n },\n \"files\": [\n \"dist\",\n \"README.md\",\n \"LICENSE\"\n ],\n \"bin\": {\n \"langwatch\": \"./dist/cli/index.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./observability\": {\n \"types\": \"./dist/observability-sdk/index.d.ts\",\n \"require\": \"./dist/observability-sdk/index.js\",\n \"import\": \"./dist/observability-sdk/index.mjs\"\n },\n \"./observability/node\": {\n \"types\": \"./dist/observability-sdk/setup/node/index.d.ts\",\n \"require\": \"./dist/observability-sdk/setup/node/index.js\",\n \"import\": \"./dist/observability-sdk/setup/node/index.mjs\"\n },\n \"./observability/instrumentation/langchain\": {\n \"types\": \"./dist/observability-sdk/instrumentation/langchain/index.d.ts\",\n \"require\": \"./dist/observability-sdk/instrumentation/langchain/index.js\",\n \"import\": \"./dist/observability-sdk/instrumentation/langchain/index.mjs\"\n }\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/langwatch/langwatch.git\",\n \"directory\": \"typescript-sdk\"\n },\n \"scripts\": {\n \"prepare\": \"pnpm run generate:server-types && pnpm run generate:openapi-types\",\n \"cli\": \"node dist/cli/index.js\",\n \"lint\": \"eslint .\",\n \"test\": \"vitest\",\n \"test:e2e\": \"vitest run -c ./vitest.e2e.config.mts\",\n \"prebuild\": \"pnpm i && pnpm run prepare\",\n \"build\": \"tsgo --noEmit && tsup\",\n \"typecheck\": \"tsgo --noEmit\",\n \"prepublish\": \"pnpm run build\",\n \"generate:openapi-types\": \"npx openapi-typescript ../langwatch/src/app/api/openapiLangWatch.json -o ./src/internal/generated/openapi/api-client.ts\",\n \"generate:server-types\": \"./copy-types.sh\"\n },\n \"devDependencies\": {\n \"@eslint/js\": \"^9.32.0\",\n \"@opentelemetry/sdk-node\": \">=0.203.0\",\n \"@opentelemetry/sdk-trace-node\": \"^2.0.1\",\n \"@opentelemetry/sdk-trace-web\": \">=2.0.1\",\n \"@types/debug\": \"^4.1.12\",\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^24.1.0\",\n \"@typescript/native-preview\": \"7.0.0-dev.20250804.1\",\n \"@vercel/otel\": \"^1.13.0\",\n \"@vitest/coverage-v8\": \"3.2.4\",\n \"esbuild\": \"^0.25.8\",\n \"eslint\": \"^9.32.0\",\n \"fets\": \"^0.8.5\",\n \"fishery\": \"^2.3.1\",\n \"msw\": \"^2.10.4\",\n \"nock\": \"^14.0.8\",\n \"openapi-msw\": \"^1.2.0\",\n \"ts-to-zod\": \"3.15.0\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^5.9.2\",\n \"typescript-eslint\": \"^8.38.0\",\n \"vitest\": \"^3.2.4\",\n \"yaml\": \"^2.8.1\"\n },\n \"dependencies\": {\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/api-logs\": \"0.203.0\",\n \"@opentelemetry/core\": \"^2.0.1\",\n \"@opentelemetry/exporter-logs-otlp-http\": \"0.203.0\",\n \"@opentelemetry/exporter-trace-otlp-http\": \"0.203.0\",\n \"@opentelemetry/instrumentation\": \"0.203.0\",\n \"@opentelemetry/resources\": \"^2.0.1\",\n \"@opentelemetry/sdk-logs\": \"0.203.0\",\n \"@opentelemetry/sdk-metrics\": \"^2.0.1\",\n \"@opentelemetry/sdk-trace-base\": \"^2.0.1\",\n \"@opentelemetry/semantic-conventions\": \"^1.36.0\",\n \"@types/prompts\": \"^2.4.9\",\n \"chalk\": \"^4.1.2\",\n \"commander\": \"^12.0.0\",\n \"dotenv\": \"^16.6.1\",\n \"js-yaml\": \"^4.1.0\",\n \"liquidjs\": \"^10.21.1\",\n \"open\": \"^10.2.0\",\n \"openapi-fetch\": \"^0.14.0\",\n \"ora\": \"^5.4.1\",\n \"prompts\": \"^2.4.2\",\n \"xksuid\": \"^0.0.4\",\n \"zod\": \"^4.0.14\"\n },\n \"peerDependencies\": {\n \"@ai-sdk/openai\": \">=2.0.0 <3.0.0\",\n \"@langchain/core\": \">=0.3.0 <1.0.0\",\n \"@langchain/langgraph\": \">=0.4.0 <1.0.0\",\n \"@langchain/openai\": \">=0.6.0 <1.0.0\",\n \"@opentelemetry/context-async-hooks\": \">=1.19.0 <3.0.0\",\n \"@opentelemetry/context-zone\": \">=1.19.0 <3.0.0\",\n \"@opentelemetry/sdk-node\": \">=0.200.0 <1.0.0\",\n \"@opentelemetry/sdk-trace-web\": \">=1.19.0 <3.0.0\",\n \"langchain\": \">=0.3.0 <1.0.0\"\n }\n}\n","export type JsRuntime = \"node\" | \"deno\" | \"bun\" | \"web\" | \"unknown\";\n\nlet _runtime: JsRuntime | undefined;\n\n/**\n * Gets the cached JavaScript runtime environment.\n * @returns The detected runtime environment\n */\nexport const getRuntime = (): JsRuntime => {\n _runtime ??= detectRuntime();\n return _runtime;\n};\n\n/**\n * Resets the cached runtime. Only used for testing.\n * @internal\n */\nexport const resetRuntimeCache = (): void => {\n _runtime = undefined;\n};\n\n/**\n * Detects the JavaScript runtime environment.\n * @param globals - (Test only) Optionally override the global object for environment simulation. Only used if NODE_ENV === 'test'.\n */\nexport function detectRuntime(globals?: any): JsRuntime {\n let g = globalThis;\n if (globals) {\n if (process.env.NODE_ENV === \"test\") {\n g = globals;\n } else {\n console.warn(\"[LangWatch Observability] overriding detectRuntime is only supported when running in NODE_ENV=test\");\n }\n }\n\n try {\n if (\n \"Deno\" in g &&\n typeof g.Deno === \"object\" &&\n g.Deno &&\n 'version' in g.Deno &&\n typeof g.Deno.version === \"object\"\n ) {\n return \"deno\";\n }\n if (\n \"Bun\" in g &&\n typeof g.Bun === \"object\" &&\n g.Bun &&\n 'version' in g.Bun &&\n typeof g.Bun.version === \"string\"\n ) {\n return \"bun\";\n }\n if (\n \"process\" in g &&\n typeof g.process === \"object\" &&\n g.process &&\n typeof g.process.versions === \"object\" &&\n typeof g.process.versions.node === \"string\"\n ) {\n return \"node\";\n }\n if (\n typeof g.window?.document !== \"undefined\" &&\n g === g.window\n ) {\n return \"web\";\n }\n return \"unknown\";\n } catch (error) {\n console.warn(\"[LangWatch Observability] Failed to detect runtime\", error);\n return \"unknown\";\n }\n}\n","import { version } from \"../../package.json\";\nimport { getRuntime } from \"./runtime\";\n\nexport const LANGWATCH_SDK_RUNTIME = getRuntime;\n\nexport const LANGWATCH_SDK_NAME_OBSERVABILITY = \"langwatch-observability-sdk\";\nexport const LANGWATCH_SDK_NAME_CLIENT = \"langwatch-client-sdk\";\nexport const LANGWATCH_SDK_LANGUAGE = \"typescript\";\nexport const LANGWATCH_SDK_VERSION = version;\n\nexport const DEFAULT_ENDPOINT = \"https://app.langwatch.ai/\";\nexport const DEFAULT_SERVICE_NAME = \"unknown-service.langwatch\";\n\nexport const TRACES_PATH = \"/api/otel/v1/traces\";\nexport const LOGS_PATH = \"/api/otel/v1/logs\";\nexport const METRICS_PATH = \"/api/otel/v1/metrics\";\n"],"mappings":";AAEI,cAAW;;;ACAf,IAAI;AAMG,IAAM,aAAa,MAAiB;AACzC,2CAAa,cAAc;AAC3B,SAAO;AACT;AAcO,SAAS,cAAc,SAA0B;AAzBxD;AA0BE,MAAI,IAAI;AACR,MAAI,SAAS;AACX,QAAI,QAAQ,IAAI,aAAa,QAAQ;AACnC,UAAI;AAAA,IACN,OAAO;AACL,cAAQ,KAAK,oGAAoG;AAAA,IACnH;AAAA,EACF;AAEA,MAAI;AACF,QACE,UAAU,KACV,OAAO,EAAE,SAAS,YAClB,EAAE,QACF,aAAa,EAAE,QACf,OAAO,EAAE,KAAK,YAAY,UAC1B;AACA,aAAO;AAAA,IACT;AACA,QACE,SAAS,KACT,OAAO,EAAE,QAAQ,YACjB,EAAE,OACF,aAAa,EAAE,OACf,OAAO,EAAE,IAAI,YAAY,UACzB;AACA,aAAO;AAAA,IACT;AACA,QACE,aAAa,KACb,OAAO,EAAE,YAAY,YACrB,EAAE,WACF,OAAO,EAAE,QAAQ,aAAa,YAC9B,OAAO,EAAE,QAAQ,SAAS,SAAS,UACnC;AACA,aAAO;AAAA,IACT;AACA,QACE,SAAO,OAAE,WAAF,mBAAU,cAAa,eAC9B,MAAM,EAAE,QACR;AACA,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,KAAK,sDAAsD,KAAK;AACxE,WAAO;AAAA,EACT;AACF;;;ACvEO,IAAM,wBAAwB;AAE9B,IAAM,mCAAmC;AACzC,IAAM,4BAA4B;AAClC,IAAM,yBAAyB;AAC/B,IAAM,wBAAwB;AAE9B,IAAM,mBAAmB;AACzB,IAAM,uBAAuB;AAE7B,IAAM,cAAc;AACpB,IAAM,YAAY;","names":[]}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
LANGWATCH_SDK_VERSION,
|
|
7
7
|
LOGS_PATH,
|
|
8
8
|
TRACES_PATH
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YKFTFYKK.mjs";
|
|
10
10
|
import {
|
|
11
11
|
shouldCaptureOutput
|
|
12
12
|
} from "./chunk-YNQ44U6D.mjs";
|
|
@@ -204,4 +204,4 @@ export {
|
|
|
204
204
|
getLangWatchLogger,
|
|
205
205
|
getLangWatchLoggerFromProvider
|
|
206
206
|
};
|
|
207
|
-
//# sourceMappingURL=chunk-
|
|
207
|
+
//# sourceMappingURL=chunk-ZIULPOMQ.mjs.map
|
package/dist/cli/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict"; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkAZHZ4NB4js = require('../chunk-AZHZ4NB4.js');
|
|
5
5
|
require('../chunk-OXBO24RB.js');
|
|
6
6
|
|
|
7
7
|
// src/cli/index.ts
|
|
@@ -9,31 +9,31 @@ var _dotenv = require('dotenv');
|
|
|
9
9
|
var _commander = require('commander');
|
|
10
10
|
_dotenv.config.call(void 0, );
|
|
11
11
|
var addCommand = async (name, options) => {
|
|
12
|
-
const { addCommand: addCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../add-
|
|
12
|
+
const { addCommand: addCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../add-4WXEWG5H.js")));
|
|
13
13
|
return addCommandImpl(name, options);
|
|
14
14
|
};
|
|
15
15
|
var removeCommand = async (name) => {
|
|
16
|
-
const { removeCommand: removeCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../remove-
|
|
16
|
+
const { removeCommand: removeCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../remove-U3PILQDV.js")));
|
|
17
17
|
return removeCommandImpl(name);
|
|
18
18
|
};
|
|
19
19
|
var initCommand = async () => {
|
|
20
|
-
const { initCommand: initCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../init-
|
|
20
|
+
const { initCommand: initCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../init-EKNL2SQE.js")));
|
|
21
21
|
return initCommandImpl();
|
|
22
22
|
};
|
|
23
23
|
var loginCommand = async () => {
|
|
24
|
-
const { loginCommand: loginCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../login-
|
|
24
|
+
const { loginCommand: loginCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../login-3STX2FAO.js")));
|
|
25
25
|
return loginCommandImpl();
|
|
26
26
|
};
|
|
27
27
|
var listCommand = async () => {
|
|
28
|
-
const { listCommand: listCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../list-
|
|
28
|
+
const { listCommand: listCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../list-GIAXAAH5.js")));
|
|
29
29
|
return listCommandImpl();
|
|
30
30
|
};
|
|
31
31
|
var syncCommand = async () => {
|
|
32
|
-
const { syncCommand: syncCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../sync-
|
|
32
|
+
const { syncCommand: syncCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../sync-T3T22GVZ.js")));
|
|
33
33
|
return syncCommandImpl();
|
|
34
34
|
};
|
|
35
35
|
var createCommand = async (name, options) => {
|
|
36
|
-
const { createCommand: createCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../create-
|
|
36
|
+
const { createCommand: createCommandImpl } = await Promise.resolve().then(() => _interopRequireWildcard(require("../create-4LG4N2A4.js")));
|
|
37
37
|
return createCommandImpl(name, options);
|
|
38
38
|
};
|
|
39
39
|
var program = new (0, _commander.Command)();
|
|
@@ -70,7 +70,7 @@ promptCmd.command("add <spec> [localFile]").description("Add a prompt dependency
|
|
|
70
70
|
if (localFile) {
|
|
71
71
|
await addCommand(spec, { localFile });
|
|
72
72
|
} else {
|
|
73
|
-
const { name, version } =
|
|
73
|
+
const { name, version } = _chunkAZHZ4NB4js.parsePromptSpec.call(void 0, spec);
|
|
74
74
|
await addCommand(name, { version });
|
|
75
75
|
}
|
|
76
76
|
} catch (error) {
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
parsePromptSpec
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-BTBSMJTY.mjs";
|
|
5
5
|
import "../chunk-CU3443HD.mjs";
|
|
6
6
|
|
|
7
7
|
// src/cli/index.ts
|
|
@@ -9,31 +9,31 @@ import { config } from "dotenv";
|
|
|
9
9
|
import { Command } from "commander";
|
|
10
10
|
config();
|
|
11
11
|
var addCommand = async (name, options) => {
|
|
12
|
-
const { addCommand: addCommandImpl } = await import("../add-
|
|
12
|
+
const { addCommand: addCommandImpl } = await import("../add-D2WVVKIP.mjs");
|
|
13
13
|
return addCommandImpl(name, options);
|
|
14
14
|
};
|
|
15
15
|
var removeCommand = async (name) => {
|
|
16
|
-
const { removeCommand: removeCommandImpl } = await import("../remove-
|
|
16
|
+
const { removeCommand: removeCommandImpl } = await import("../remove-FTF3EBYV.mjs");
|
|
17
17
|
return removeCommandImpl(name);
|
|
18
18
|
};
|
|
19
19
|
var initCommand = async () => {
|
|
20
|
-
const { initCommand: initCommandImpl } = await import("../init-
|
|
20
|
+
const { initCommand: initCommandImpl } = await import("../init-MQXXHCNT.mjs");
|
|
21
21
|
return initCommandImpl();
|
|
22
22
|
};
|
|
23
23
|
var loginCommand = async () => {
|
|
24
|
-
const { loginCommand: loginCommandImpl } = await import("../login-
|
|
24
|
+
const { loginCommand: loginCommandImpl } = await import("../login-BYLXS23I.mjs");
|
|
25
25
|
return loginCommandImpl();
|
|
26
26
|
};
|
|
27
27
|
var listCommand = async () => {
|
|
28
|
-
const { listCommand: listCommandImpl } = await import("../list-
|
|
28
|
+
const { listCommand: listCommandImpl } = await import("../list-PFWV7IU6.mjs");
|
|
29
29
|
return listCommandImpl();
|
|
30
30
|
};
|
|
31
31
|
var syncCommand = async () => {
|
|
32
|
-
const { syncCommand: syncCommandImpl } = await import("../sync-
|
|
32
|
+
const { syncCommand: syncCommandImpl } = await import("../sync-FOW7DHAH.mjs");
|
|
33
33
|
return syncCommandImpl();
|
|
34
34
|
};
|
|
35
35
|
var createCommand = async (name, options) => {
|
|
36
|
-
const { createCommand: createCommandImpl } = await import("../create-
|
|
36
|
+
const { createCommand: createCommandImpl } = await import("../create-OQEMO4MU.mjs");
|
|
37
37
|
return createCommandImpl(name, options);
|
|
38
38
|
};
|
|
39
39
|
var program = new Command();
|
|
@@ -3,36 +3,42 @@
|
|
|
3
3
|
var _chunkF6E4XQQUjs = require('./chunk-F6E4XQQU.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk7OZKH5K2js = require('./chunk-7OZKH5K2.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
10
|
-
require('./chunk-
|
|
11
|
-
require('./chunk-
|
|
9
|
+
var _chunkCAZONSXVjs = require('./chunk-CAZONSXV.js');
|
|
10
|
+
require('./chunk-R6FBJN7K.js');
|
|
11
|
+
require('./chunk-AZHZ4NB4.js');
|
|
12
12
|
require('./chunk-OXBO24RB.js');
|
|
13
13
|
|
|
14
14
|
// src/cli/commands/create.ts
|
|
15
15
|
var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
|
|
16
16
|
var _path = require('path'); var path = _interopRequireWildcard(_path);
|
|
17
17
|
var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
|
|
18
|
-
var createCommand = async (name,
|
|
18
|
+
var createCommand = async (name, _options) => {
|
|
19
19
|
try {
|
|
20
20
|
if (!name || name.trim() === "") {
|
|
21
21
|
console.error(_chalk2.default.red("Error: Prompt name cannot be empty"));
|
|
22
22
|
process.exit(1);
|
|
23
23
|
}
|
|
24
24
|
_chunkF6E4XQQUjs.checkApiKey.call(void 0, );
|
|
25
|
-
await
|
|
26
|
-
const promptPath = path.join(
|
|
25
|
+
await _chunk7OZKH5K2js.ensureProjectInitialized.call(void 0, );
|
|
26
|
+
const promptPath = path.join(
|
|
27
|
+
process.cwd(),
|
|
28
|
+
"prompts",
|
|
29
|
+
`${name}.prompt.yaml`
|
|
30
|
+
);
|
|
27
31
|
if (fs.existsSync(promptPath)) {
|
|
28
|
-
console.error(
|
|
32
|
+
console.error(
|
|
33
|
+
_chalk2.default.red(`Error: Prompt file already exists at ${promptPath}`)
|
|
34
|
+
);
|
|
29
35
|
process.exit(1);
|
|
30
36
|
}
|
|
31
37
|
const promptsDir = path.dirname(promptPath);
|
|
32
38
|
if (!fs.existsSync(promptsDir)) {
|
|
33
39
|
fs.mkdirSync(promptsDir, { recursive: true });
|
|
34
40
|
}
|
|
35
|
-
const defaultContent = `model: openai/gpt-
|
|
41
|
+
const defaultContent = `model: openai/gpt-5
|
|
36
42
|
modelParameters:
|
|
37
43
|
temperature: 0.7
|
|
38
44
|
messages:
|
|
@@ -42,11 +48,11 @@ messages:
|
|
|
42
48
|
content: "{{input}}"
|
|
43
49
|
`;
|
|
44
50
|
fs.writeFileSync(promptPath, defaultContent, "utf8");
|
|
45
|
-
const promptsConfig =
|
|
51
|
+
const promptsConfig = _chunkCAZONSXVjs.FileManager.loadPromptsConfig();
|
|
46
52
|
const relativePath = path.relative(process.cwd(), promptPath);
|
|
47
53
|
promptsConfig.prompts[name] = `file:${relativePath}`;
|
|
48
|
-
|
|
49
|
-
const lock =
|
|
54
|
+
_chunkCAZONSXVjs.FileManager.savePromptsConfig(promptsConfig);
|
|
55
|
+
const lock = _chunkCAZONSXVjs.FileManager.loadPromptsLock();
|
|
50
56
|
lock.prompts[name] = {
|
|
51
57
|
version: 0,
|
|
52
58
|
// Local files start at version 0
|
|
@@ -54,17 +60,22 @@ messages:
|
|
|
54
60
|
materialized: relativePath
|
|
55
61
|
// Store the original file path
|
|
56
62
|
};
|
|
57
|
-
|
|
63
|
+
_chunkCAZONSXVjs.FileManager.savePromptsLock(lock);
|
|
58
64
|
const displayPath = `./${relativePath}`;
|
|
59
|
-
console.log(
|
|
65
|
+
console.log(
|
|
66
|
+
_chalk2.default.green(`\u2713 Created prompt file: ${_chalk2.default.cyan(displayPath)}`)
|
|
67
|
+
);
|
|
60
68
|
console.log(_chalk2.default.gray(` Edit this file and then run:`));
|
|
61
69
|
console.log(_chalk2.default.cyan(` langwatch prompt sync`));
|
|
62
70
|
} catch (error) {
|
|
63
|
-
console.error(
|
|
71
|
+
console.error(
|
|
72
|
+
_chalk2.default.red("Unexpected error:"),
|
|
73
|
+
error instanceof Error ? error.message : error
|
|
74
|
+
);
|
|
64
75
|
process.exit(1);
|
|
65
76
|
}
|
|
66
77
|
};
|
|
67
78
|
|
|
68
79
|
|
|
69
80
|
exports.createCommand = createCommand;
|
|
70
|
-
//# sourceMappingURL=create-
|
|
81
|
+
//# sourceMappingURL=create-4LG4N2A4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/create-4LG4N2A4.js","../src/cli/commands/create.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B;AACA;ACbA,+DAAoB;AACpB,uEAAsB;AACtB,4EAAkB;AAOX,IAAM,cAAA,EAAgB,MAAA,CAC3B,IAAA,EACA,QAAA,EAAA,GACkB;AAClB,EAAA,IAAI;AAEF,IAAA,GAAA,CAAI,CAAC,KAAA,GAAQ,IAAA,CAAK,IAAA,CAAK,EAAA,IAAM,EAAA,EAAI;AAC/B,MAAA,OAAA,CAAQ,KAAA,CAAM,eAAA,CAAM,GAAA,CAAI,oCAAoC,CAAC,CAAA;AAC7D,MAAA,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA;AAAA,IAChB;AAGA,IAAA,0CAAA,CAAY;AAGZ,IAAA,MAAM,uDAAA,CAAyB;AAG/B,IAAA,MAAM,WAAA,EAAkB,IAAA,CAAA,IAAA;AAAA,MACtB,OAAA,CAAQ,GAAA,CAAI,CAAA;AAAA,MACZ,SAAA;AAAA,MACA,CAAA,EAAA;AACF,IAAA;AAEA,IAAA;AACE,MAAA;AAAQ,QAAA;AAER,MAAA;AACA,MAAA;AACF,IAAA;AAGA,IAAA;AACA,IAAA;AACK,MAAA;AACL,IAAA;AAGA,IAAA;AAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWpB,IAAA;AAGH,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAGA,IAAA;AACA,IAAA;AACE,MAAA;AAAS;AACT,MAAA;AACA,MAAA;AAAc;AAChB,IAAA;AACA,IAAA;AAEA,IAAA;AACA,IAAA;AACE,MAAA;AACF,IAAA;AACA,IAAA;AACA,IAAA;AACF,EAAA;AACE,IAAA;AACE,MAAA;AACA,MAAA;AACF,IAAA;AACA,IAAA;AACF,EAAA;AACF;ADXO;AACA;AACA","file":"/home/runner/work/langwatch/langwatch/typescript-sdk/dist/create-4LG4N2A4.js","sourcesContent":[null,"import * as fs from \"fs\";\nimport * as path from \"path\";\nimport chalk from \"chalk\";\nimport { FileManager } from \"../utils/fileManager\";\nimport { checkApiKey } from \"../utils/apiKey\";\nimport { ensureProjectInitialized } from \"../utils/init\";\n\ntype CreateOptions = Record<string, unknown>;\n\nexport const createCommand = async (\n name: string,\n _options: CreateOptions,\n): Promise<void> => {\n try {\n // Validate prompt name\n if (!name || name.trim() === \"\") {\n console.error(chalk.red(\"Error: Prompt name cannot be empty\"));\n process.exit(1);\n }\n\n // Check API key before doing anything else\n checkApiKey();\n\n // Ensure project is initialized\n await ensureProjectInitialized();\n\n // Check if file already exists\n const promptPath = path.join(\n process.cwd(),\n \"prompts\",\n `${name}.prompt.yaml`,\n );\n\n if (fs.existsSync(promptPath)) {\n console.error(\n chalk.red(`Error: Prompt file already exists at ${promptPath}`),\n );\n process.exit(1);\n }\n\n // Create prompts directory if it doesn't exist\n const promptsDir = path.dirname(promptPath);\n if (!fs.existsSync(promptsDir)) {\n fs.mkdirSync(promptsDir, { recursive: true });\n }\n\n // Default prompt content\n const defaultContent = `model: openai/gpt-5\nmodelParameters:\n temperature: 0.7\nmessages:\n - role: system\n content: You are a helpful assistant.\n - role: user\n content: \"{{input}}\"\n`;\n\n // Write the file\n fs.writeFileSync(promptPath, defaultContent, \"utf8\");\n\n // Add to prompts.json as a file: dependency\n const promptsConfig = FileManager.loadPromptsConfig();\n const relativePath = path.relative(process.cwd(), promptPath);\n promptsConfig.prompts[name] = `file:${relativePath}`;\n FileManager.savePromptsConfig(promptsConfig);\n\n // Update lock file\n const lock = FileManager.loadPromptsLock();\n lock.prompts[name] = {\n version: 0, // Local files start at version 0\n versionId: \"local\",\n materialized: relativePath, // Store the original file path\n };\n FileManager.savePromptsLock(lock);\n\n const displayPath = `./${relativePath}`;\n console.log(\n chalk.green(`✓ Created prompt file: ${chalk.cyan(displayPath)}`),\n );\n console.log(chalk.gray(` Edit this file and then run:`));\n console.log(chalk.cyan(` langwatch prompt sync`));\n } catch (error) {\n console.error(\n chalk.red(\"Unexpected error:\"),\n error instanceof Error ? error.message : error,\n );\n process.exit(1);\n }\n};\n"]}
|
|
@@ -3,19 +3,19 @@ import {
|
|
|
3
3
|
} from "./chunk-DHJKJVY7.mjs";
|
|
4
4
|
import {
|
|
5
5
|
ensureProjectInitialized
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DLJO7AK5.mjs";
|
|
7
7
|
import {
|
|
8
8
|
FileManager
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-CKVDNVFL.mjs";
|
|
10
|
+
import "./chunk-V5M3HUBV.mjs";
|
|
11
|
+
import "./chunk-BTBSMJTY.mjs";
|
|
12
12
|
import "./chunk-CU3443HD.mjs";
|
|
13
13
|
|
|
14
14
|
// src/cli/commands/create.ts
|
|
15
15
|
import * as fs from "fs";
|
|
16
16
|
import * as path from "path";
|
|
17
17
|
import chalk from "chalk";
|
|
18
|
-
var createCommand = async (name,
|
|
18
|
+
var createCommand = async (name, _options) => {
|
|
19
19
|
try {
|
|
20
20
|
if (!name || name.trim() === "") {
|
|
21
21
|
console.error(chalk.red("Error: Prompt name cannot be empty"));
|
|
@@ -23,16 +23,22 @@ var createCommand = async (name, options) => {
|
|
|
23
23
|
}
|
|
24
24
|
checkApiKey();
|
|
25
25
|
await ensureProjectInitialized();
|
|
26
|
-
const promptPath = path.join(
|
|
26
|
+
const promptPath = path.join(
|
|
27
|
+
process.cwd(),
|
|
28
|
+
"prompts",
|
|
29
|
+
`${name}.prompt.yaml`
|
|
30
|
+
);
|
|
27
31
|
if (fs.existsSync(promptPath)) {
|
|
28
|
-
console.error(
|
|
32
|
+
console.error(
|
|
33
|
+
chalk.red(`Error: Prompt file already exists at ${promptPath}`)
|
|
34
|
+
);
|
|
29
35
|
process.exit(1);
|
|
30
36
|
}
|
|
31
37
|
const promptsDir = path.dirname(promptPath);
|
|
32
38
|
if (!fs.existsSync(promptsDir)) {
|
|
33
39
|
fs.mkdirSync(promptsDir, { recursive: true });
|
|
34
40
|
}
|
|
35
|
-
const defaultContent = `model: openai/gpt-
|
|
41
|
+
const defaultContent = `model: openai/gpt-5
|
|
36
42
|
modelParameters:
|
|
37
43
|
temperature: 0.7
|
|
38
44
|
messages:
|
|
@@ -56,15 +62,20 @@ messages:
|
|
|
56
62
|
};
|
|
57
63
|
FileManager.savePromptsLock(lock);
|
|
58
64
|
const displayPath = `./${relativePath}`;
|
|
59
|
-
console.log(
|
|
65
|
+
console.log(
|
|
66
|
+
chalk.green(`\u2713 Created prompt file: ${chalk.cyan(displayPath)}`)
|
|
67
|
+
);
|
|
60
68
|
console.log(chalk.gray(` Edit this file and then run:`));
|
|
61
69
|
console.log(chalk.cyan(` langwatch prompt sync`));
|
|
62
70
|
} catch (error) {
|
|
63
|
-
console.error(
|
|
71
|
+
console.error(
|
|
72
|
+
chalk.red("Unexpected error:"),
|
|
73
|
+
error instanceof Error ? error.message : error
|
|
74
|
+
);
|
|
64
75
|
process.exit(1);
|
|
65
76
|
}
|
|
66
77
|
};
|
|
67
78
|
export {
|
|
68
79
|
createCommand
|
|
69
80
|
};
|
|
70
|
-
//# sourceMappingURL=create-
|
|
81
|
+
//# sourceMappingURL=create-OQEMO4MU.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/create.ts"],"sourcesContent":["import * as fs from \"fs\";\nimport * as path from \"path\";\nimport chalk from \"chalk\";\nimport { FileManager } from \"../utils/fileManager\";\nimport { checkApiKey } from \"../utils/apiKey\";\nimport { ensureProjectInitialized } from \"../utils/init\";\n\ntype CreateOptions = Record<string, unknown>;\n\nexport const createCommand = async (\n name: string,\n _options: CreateOptions,\n): Promise<void> => {\n try {\n // Validate prompt name\n if (!name || name.trim() === \"\") {\n console.error(chalk.red(\"Error: Prompt name cannot be empty\"));\n process.exit(1);\n }\n\n // Check API key before doing anything else\n checkApiKey();\n\n // Ensure project is initialized\n await ensureProjectInitialized();\n\n // Check if file already exists\n const promptPath = path.join(\n process.cwd(),\n \"prompts\",\n `${name}.prompt.yaml`,\n );\n\n if (fs.existsSync(promptPath)) {\n console.error(\n chalk.red(`Error: Prompt file already exists at ${promptPath}`),\n );\n process.exit(1);\n }\n\n // Create prompts directory if it doesn't exist\n const promptsDir = path.dirname(promptPath);\n if (!fs.existsSync(promptsDir)) {\n fs.mkdirSync(promptsDir, { recursive: true });\n }\n\n // Default prompt content\n const defaultContent = `model: openai/gpt-5\nmodelParameters:\n temperature: 0.7\nmessages:\n - role: system\n content: You are a helpful assistant.\n - role: user\n content: \"{{input}}\"\n`;\n\n // Write the file\n fs.writeFileSync(promptPath, defaultContent, \"utf8\");\n\n // Add to prompts.json as a file: dependency\n const promptsConfig = FileManager.loadPromptsConfig();\n const relativePath = path.relative(process.cwd(), promptPath);\n promptsConfig.prompts[name] = `file:${relativePath}`;\n FileManager.savePromptsConfig(promptsConfig);\n\n // Update lock file\n const lock = FileManager.loadPromptsLock();\n lock.prompts[name] = {\n version: 0, // Local files start at version 0\n versionId: \"local\",\n materialized: relativePath, // Store the original file path\n };\n FileManager.savePromptsLock(lock);\n\n const displayPath = `./${relativePath}`;\n console.log(\n chalk.green(`✓ Created prompt file: ${chalk.cyan(displayPath)}`),\n );\n console.log(chalk.gray(` Edit this file and then run:`));\n console.log(chalk.cyan(` langwatch prompt sync`));\n } catch (error) {\n console.error(\n chalk.red(\"Unexpected error:\"),\n error instanceof Error ? error.message : error,\n );\n process.exit(1);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,OAAO,WAAW;AAOX,IAAM,gBAAgB,OAC3B,MACA,aACkB;AAClB,MAAI;AAEF,QAAI,CAAC,QAAQ,KAAK,KAAK,MAAM,IAAI;AAC/B,cAAQ,MAAM,MAAM,IAAI,oCAAoC,CAAC;AAC7D,cAAQ,KAAK,CAAC;AAAA,IAChB;AAGA,gBAAY;AAGZ,UAAM,yBAAyB;AAG/B,UAAM,aAAkB;AAAA,MACtB,QAAQ,IAAI;AAAA,MACZ;AAAA,MACA,GAAG,IAAI;AAAA,IACT;AAEA,QAAO,cAAW,UAAU,GAAG;AAC7B,cAAQ;AAAA,QACN,MAAM,IAAI,wCAAwC,UAAU,EAAE;AAAA,MAChE;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAGA,UAAM,aAAkB,aAAQ,UAAU;AAC1C,QAAI,CAAI,cAAW,UAAU,GAAG;AAC9B,MAAG,aAAU,YAAY,EAAE,WAAW,KAAK,CAAC;AAAA,IAC9C;AAGA,UAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWvB,IAAG,iBAAc,YAAY,gBAAgB,MAAM;AAGnD,UAAM,gBAAgB,YAAY,kBAAkB;AACpD,UAAM,eAAoB,cAAS,QAAQ,IAAI,GAAG,UAAU;AAC5D,kBAAc,QAAQ,IAAI,IAAI,QAAQ,YAAY;AAClD,gBAAY,kBAAkB,aAAa;AAG3C,UAAM,OAAO,YAAY,gBAAgB;AACzC,SAAK,QAAQ,IAAI,IAAI;AAAA,MACnB,SAAS;AAAA;AAAA,MACT,WAAW;AAAA,MACX,cAAc;AAAA;AAAA,IAChB;AACA,gBAAY,gBAAgB,IAAI;AAEhC,UAAM,cAAc,KAAK,YAAY;AACrC,YAAQ;AAAA,MACN,MAAM,MAAM,+BAA0B,MAAM,KAAK,WAAW,CAAC,EAAE;AAAA,IACjE;AACA,YAAQ,IAAI,MAAM,KAAK,gCAAgC,CAAC;AACxD,YAAQ,IAAI,MAAM,KAAK,yBAAyB,CAAC;AAAA,EACnD,SAAS,OAAO;AACd,YAAQ;AAAA,MACN,MAAM,IAAI,mBAAmB;AAAA,MAC7B,iBAAiB,QAAQ,MAAM,UAAU;AAAA,IAC3C;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;","names":[]}
|
|
@@ -3,7 +3,7 @@ import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
|
3
3
|
import { Logger, LogRecord, LoggerProvider } from '@opentelemetry/api-logs';
|
|
4
4
|
import { a as SemConvLogRecordAttributes, S as SemConvAttributes } from './types-DRiQaKFG.js';
|
|
5
5
|
import { TracerProvider } from '@opentelemetry/api';
|
|
6
|
-
import { a as LangWatchTracer } from './types-
|
|
6
|
+
import { a as LangWatchTracer } from './types-DyUmlaDx.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Filterable Batch Span Exporter for OpenTelemetry
|
|
@@ -3,7 +3,7 @@ import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
|
3
3
|
import { Logger, LogRecord, LoggerProvider } from '@opentelemetry/api-logs';
|
|
4
4
|
import { a as SemConvLogRecordAttributes, S as SemConvAttributes } from './types-DRiQaKFG.mjs';
|
|
5
5
|
import { TracerProvider } from '@opentelemetry/api';
|
|
6
|
-
import { a as LangWatchTracer } from './types-
|
|
6
|
+
import { a as LangWatchTracer } from './types-jrEEZt9d.mjs';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Filterable Batch Span Exporter for OpenTelemetry
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
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-
|
|
2
|
+
export { F as FilterableBatchSpanProcessor, L as LangWatchExporter, S as SpanProcessingExcludeRule, g as getLangWatchLogger, d as getLangWatchTracer } from './implementation-fAgqv8OM.mjs';
|
|
3
3
|
export { l as attributes } from './types-DRiQaKFG.mjs';
|
|
4
|
-
import { p as paths, P as PromptResponse, g as Prompt } from './types-
|
|
4
|
+
import { p as paths, P as PromptResponse, g as Prompt } from './types-jrEEZt9d.mjs';
|
|
5
5
|
import openApiCreateClient from 'openapi-fetch';
|
|
6
6
|
import '@opentelemetry/sdk-trace-base';
|
|
7
7
|
import '@opentelemetry/exporter-trace-otlp-http';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
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-
|
|
2
|
+
export { F as FilterableBatchSpanProcessor, L as LangWatchExporter, S as SpanProcessingExcludeRule, g as getLangWatchLogger, d as getLangWatchTracer } from './implementation-BIlL6-SW.js';
|
|
3
3
|
export { l as attributes } from './types-DRiQaKFG.js';
|
|
4
|
-
import { p as paths, P as PromptResponse, g as Prompt } from './types-
|
|
4
|
+
import { p as paths, P as PromptResponse, g as Prompt } from './types-DyUmlaDx.js';
|
|
5
5
|
import openApiCreateClient from 'openapi-fetch';
|
|
6
6
|
import '@opentelemetry/sdk-trace-base';
|
|
7
7
|
import '@opentelemetry/exporter-trace-otlp-http';
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var _chunkDSIQSULKjs = require('./chunk-DSIQSULK.js');
|
|
4
|
+
require('./chunk-SVXNUWZI.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
var _chunkYH5TIVK2js = require('./chunk-YH5TIVK2.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkECOC36EAjs = require('./chunk-ECOC36EA.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
15
|
-
require('./chunk-
|
|
14
|
+
var _chunkP4SQTYGNjs = require('./chunk-P4SQTYGN.js');
|
|
15
|
+
require('./chunk-QCYYSMCU.js');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
var _chunkDISMHYXCjs = require('./chunk-DISMHYXC.js');
|
|
21
|
-
require('./chunk-
|
|
21
|
+
require('./chunk-R6FBJN7K.js');
|
|
22
22
|
require('./chunk-OXBO24RB.js');
|
|
23
23
|
|
|
24
24
|
// src/index.ts
|
|
@@ -34,5 +34,5 @@ var logger = {
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
exports.FilterableBatchSpanProcessor = _chunkYH5TIVK2js.FilterableBatchSpanProcessor; exports.LangWatch =
|
|
37
|
+
exports.FilterableBatchSpanProcessor = _chunkYH5TIVK2js.FilterableBatchSpanProcessor; exports.LangWatch = _chunkDSIQSULKjs.LangWatch; exports.LangWatchExporter = _chunkP4SQTYGNjs.LangWatchTraceExporter; exports.attributes = _chunkDISMHYXCjs.attributes_exports; exports.getLangWatchLogger = _chunkP4SQTYGNjs.getLangWatchLogger; exports.getLangWatchTracer = _chunkECOC36EAjs.getLangWatchTracer; exports.logger = logger;
|
|
38
38
|
//# sourceMappingURL=index.js.map
|