langwatch 0.7.4 → 0.8.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 +48 -0
- package/dist/{add-XLEUNNZI.mjs → add-TMFGG3SC.mjs} +4 -4
- package/dist/{add-Y543UEBX.js → add-VOEIH432.js} +7 -7
- package/dist/{add-Y543UEBX.js.map → add-VOEIH432.js.map} +1 -1
- package/dist/{chunk-BKVMRI32.js → chunk-B5K6DU6G.js} +2 -2
- package/dist/{chunk-BKVMRI32.js.map → chunk-B5K6DU6G.js.map} +1 -1
- package/dist/{chunk-VMI2XPCC.mjs → chunk-GMQHOSEU.mjs} +2 -2
- package/dist/{chunk-VMI2XPCC.mjs.map → chunk-GMQHOSEU.mjs.map} +1 -1
- package/dist/{chunk-QPHTXDJ5.mjs → chunk-SC4YBWRM.mjs} +2 -2
- package/dist/{chunk-HRPIRC67.mjs → chunk-VH7IIHFW.mjs} +109 -20
- package/dist/chunk-VH7IIHFW.mjs.map +1 -0
- package/dist/{chunk-MZ2O5ZJL.js → chunk-VWZCWYRH.js} +121 -32
- package/dist/chunk-VWZCWYRH.js.map +1 -0
- package/dist/{chunk-J4YLJUX5.js → chunk-XHNJY5BP.js} +9 -9
- package/dist/{chunk-J4YLJUX5.js.map → chunk-XHNJY5BP.js.map} +1 -1
- package/dist/cli/index.js +5 -5
- package/dist/cli/index.mjs +5 -5
- package/dist/{implementation-JKO2kHPl.d.ts → implementation-TF91Gn0l.d.ts} +154 -20
- package/dist/{implementation-BhgBtqp4.d.mts → implementation-pq0g2B5y.d.mts} +154 -20
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +11 -11
- package/dist/index.mjs +3 -3
- package/dist/{list-LULA2BWM.js → list-42DGIFAC.js} +7 -7
- package/dist/{list-LULA2BWM.js.map → list-42DGIFAC.js.map} +1 -1
- package/dist/{list-5C6V2OEO.mjs → list-KDYBQLVU.mjs} +4 -4
- package/dist/{login-RUMQOHW4.js → login-IRO5FBZI.js} +3 -3
- package/dist/{login-RUMQOHW4.js.map → login-IRO5FBZI.js.map} +1 -1
- package/dist/{login-XY2RAXYR.mjs → login-RNWEYFQK.mjs} +2 -2
- package/dist/observability-sdk/index.d.mts +4 -3
- package/dist/observability-sdk/index.d.ts +4 -3
- package/dist/observability-sdk/index.js +3 -3
- package/dist/observability-sdk/index.mjs +2 -2
- 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/setup/node/index.js +10 -10
- package/dist/observability-sdk/setup/node/index.mjs +2 -2
- package/dist/{remove-NIEHQCQN.js → remove-5EXAIGBX.js} +6 -6
- package/dist/{remove-NIEHQCQN.js.map → remove-5EXAIGBX.js.map} +1 -1
- package/dist/{remove-GA3OQ5AQ.mjs → remove-UWKI7GIJ.mjs} +4 -4
- package/dist/{sync-J2FH4OZC.js → sync-MOBSZVYV.js} +6 -6
- package/dist/{sync-J2FH4OZC.js.map → sync-MOBSZVYV.js.map} +1 -1
- package/dist/{sync-X3KE2DNE.mjs → sync-WJSJIKEW.mjs} +4 -4
- package/dist/{types-DOVKZCnN.d.ts → types-CAQOMGrf.d.ts} +141 -33
- package/dist/{types-DoNHhlm6.d.mts → types-DhEYjnRD.d.mts} +141 -33
- package/package.json +1 -1
- package/dist/chunk-HRPIRC67.mjs.map +0 -1
- package/dist/chunk-MZ2O5ZJL.js.map +0 -1
- /package/dist/{add-XLEUNNZI.mjs.map → add-TMFGG3SC.mjs.map} +0 -0
- /package/dist/{chunk-QPHTXDJ5.mjs.map → chunk-SC4YBWRM.mjs.map} +0 -0
- /package/dist/{list-5C6V2OEO.mjs.map → list-KDYBQLVU.mjs.map} +0 -0
- /package/dist/{login-XY2RAXYR.mjs.map → login-RNWEYFQK.mjs.map} +0 -0
- /package/dist/{remove-GA3OQ5AQ.mjs.map → remove-UWKI7GIJ.mjs.map} +0 -0
- /package/dist/{sync-X3KE2DNE.mjs.map → sync-WJSJIKEW.mjs.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/list-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/list-42DGIFAC.js","../src/cli/commands/list.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B;AACA;AChBA,4EAAkB;AAClB,oEAAgB;AAKhB,IAAM,UAAA,EAAY,CAAC,GAAA,EAAA,GAAwB;AAEzC,EAAA,OAAO,GAAA,CAAI,OAAA,CAAQ,mBAAA,EAAqB,EAAE,CAAA;AAC5C,CAAA;AAGA,IAAM,YAAA,EAAc,CAClB,IAAA,EACA,OAAA,EAAA,GACS;AACT,EAAA,GAAA,CAAI,IAAA,CAAK,OAAA,IAAW,CAAA,EAAG;AACrB,IAAA,OAAA,CAAQ,GAAA,CAAI,eAAA,CAAM,IAAA,CAAK,kBAAkB,CAAC,CAAA;AAC1C,IAAA,MAAA;AAAA,EACF;AAGA,EAAA,MAAM,UAAA,EAAoC,CAAC,CAAA;AAC3C,EAAA,OAAA,CAAQ,OAAA,CAAQ,CAAC,MAAA,EAAA,GAAW;AAC1B,IAAA,SAAA,CAAU,MAAM,EAAA,EAAI,IAAA,CAAK,GAAA;AAAA,MACvB,MAAA,CAAO,MAAA;AAAA,MACP,GAAG,IAAA,CAAK,GAAA,CAAI,CAAC,GAAA,EAAA,GAAK;AA1BxB,QAAA,IAAA,EAAA;AA0B2B,QAAA,OAAA,SAAA,CAAA,CAAU,GAAA,EAAA,GAAA,CAAI,MAAM,CAAA,EAAA,GAAV,KAAA,EAAA,GAAA,EAAe,EAAE,CA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EAAG,OAAO,CAAA,EAAA;AACC,EAAA;AACF,EAAA;AACC,EAAA;AACL,EAAA;AACA,EAAA;AACnB;AAE2B;AACrB,EAAA;AAEU,IAAA;AAGN,IAAA;AAEc,IAAA;AAEhB,IAAA;AAEiB,MAAA;AACH,MAAA;AACV,MAAA;AAEE,MAAA;AACW,QAAA;AAIR,UAAA;AAGP,QAAA;AACJ,MAAA;AAEY,MAAA;AACE,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACZ,QAAA;AACF,MAAA;AAEY,MAAA;AAGM,MAAA;AA7HxB,QAAA;AA6HiD,QAAA;AACnC,UAAA;AACG,UAAA;AACF,UAAA;AACE,UAAA;AACX,QAAA;AAAE,MAAA;AAGU,MAAA;AAEA,MAAA;AACJ,MAAA;AACA,QAAA;AACS,UAAA;AACX,YAAA;AACD,UAAA;AACH,QAAA;AACF,MAAA;AACc,IAAA;AACD,MAAA;AACT,MAAA;AACY,QAAA;AACT,MAAA;AACG,QAAA;AACA,UAAA;AACJ,YAAA;AAGF,UAAA;AACF,QAAA;AACF,MAAA;AACc,MAAA;AAChB,IAAA;AACc,EAAA;AACO,IAAA;AACL,MAAA;AACT,IAAA;AACG,MAAA;AACA,QAAA;AACJ,UAAA;AAGF,QAAA;AACF,MAAA;AACF,IAAA;AACc,IAAA;AAChB,EAAA;AACF;AD5ByB;AACA;AACA","file":"/home/runner/work/langwatch/langwatch/typescript-sdk/dist/list-42DGIFAC.js","sourcesContent":[null,"import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { PromptsApiService, PromptsError } from \"@/client-sdk/services/prompts\";\nimport { checkApiKey } from \"../utils/apiKey\";\n\n// Helper to strip ANSI codes for length calculation\nconst stripAnsi = (str: string): string => {\n // eslint-disable-next-line no-control-regex\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 prompts API service\n const promptsApiService = new PromptsApiService();\n\n const spinner = ora(\"Fetching prompts from server...\").start();\n\n try {\n // Fetch all prompts\n const allPrompts = await promptsApiService.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${\n prompts.length !== 1 ? \"s\" : \"\"\n } ` +\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"]}
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
PromptsApiService,
|
|
6
6
|
PromptsError
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-SC4YBWRM.mjs";
|
|
8
8
|
import "./chunk-FEL5FLHA.mjs";
|
|
9
9
|
import "./chunk-DQU2PZAL.mjs";
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-VH7IIHFW.mjs";
|
|
11
|
+
import "./chunk-GMQHOSEU.mjs";
|
|
12
12
|
import "./chunk-I2SOBPAF.mjs";
|
|
13
13
|
import "./chunk-O6D3W3PG.mjs";
|
|
14
14
|
import "./chunk-BTBSMJTY.mjs";
|
|
@@ -145,4 +145,4 @@ var listCommand = async () => {
|
|
|
145
145
|
export {
|
|
146
146
|
listCommand
|
|
147
147
|
};
|
|
148
|
-
//# sourceMappingURL=list-
|
|
148
|
+
//# sourceMappingURL=list-KDYBQLVU.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkB5K6DU6Gjs = require('./chunk-B5K6DU6G.js');
|
|
4
4
|
require('./chunk-OHM7JUMR.js');
|
|
5
5
|
|
|
6
6
|
// src/cli/commands/login.ts
|
|
@@ -11,7 +11,7 @@ var _ora = require('ora'); var _ora2 = _interopRequireDefault(_ora);
|
|
|
11
11
|
var _prompts = require('prompts'); var _prompts2 = _interopRequireDefault(_prompts);
|
|
12
12
|
var getEndpoint = () => {
|
|
13
13
|
var _a;
|
|
14
|
-
return (_a = process.env.LANGWATCH_ENDPOINT) != null ? _a :
|
|
14
|
+
return (_a = process.env.LANGWATCH_ENDPOINT) != null ? _a : _chunkB5K6DU6Gjs.DEFAULT_ENDPOINT;
|
|
15
15
|
};
|
|
16
16
|
var updateEnvFile = (apiKey) => {
|
|
17
17
|
const envPath = path.join(process.cwd(), ".env");
|
|
@@ -111,4 +111,4 @@ var loginCommand = async () => {
|
|
|
111
111
|
|
|
112
112
|
|
|
113
113
|
exports.loginCommand = loginCommand;
|
|
114
|
-
//# sourceMappingURL=login-
|
|
114
|
+
//# sourceMappingURL=login-IRO5FBZI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/login-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/login-IRO5FBZI.js","../src/cli/commands/login.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B;AACA;ACLA,+DAAoB;AACpB,uEAAsB;AACtB,4EAAkB;AAClB,oEAAgB;AAChB,oFAAoB;AAGpB,IAAM,YAAA,EAAc,CAAA,EAAA,GAAc;AAPlC,EAAA,IAAA,EAAA;AAQE,EAAA,OAAA,CAAO,GAAA,EAAA,OAAA,CAAQ,GAAA,CAAI,kBAAA,EAAA,GAAZ,KAAA,EAAA,GAAA,EAAkC,iCAAA;AAC3C,CAAA;AAEA,IAAM,cAAA,EAAgB,CACpB,MAAA,EAAA,GACyD;AACzD,EAAA,MAAM,QAAA,EAAe,IAAA,CAAA,IAAA,CAAK,OAAA,CAAQ,GAAA,CAAI,CAAA,EAAG,MAAM,CAAA;AAG/C,EAAA,GAAA,CAAI,CAAI,EAAA,CAAA,UAAA,CAAW,OAAO,CAAA,EAAG;AAE3B,IAAG,EAAA,CAAA,aAAA,CAAc,OAAA,EAAS,CAAA,kBAAA,EAAqB,MAAM,CAAA;AAAA,CAAI,CAAA;AACzD,IAAA,OAAO,EAAE,OAAA,EAAS,IAAA,EAAM,OAAA,EAAS,KAAA,EAAO,IAAA,EAAM,QAAQ,CAAA;AAAA,EACxD;AAGA,EAAA,MAAM,QAAA,EAAa,EAAA,CAAA,YAAA,CAAa,OAAA,EAAS,OAAO,CAAA;AAChD,EAAA,MAAM,MAAA,EAAQ,OAAA,CAAQ,KAAA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home/runner/work/langwatch/langwatch/typescript-sdk/dist/login-IRO5FBZI.js","sourcesContent":[null,"import * as fs from \"fs\";\nimport * as path from \"path\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\nimport prompts from \"prompts\";\nimport { DEFAULT_ENDPOINT } from \"@/internal/constants\";\n\nconst getEndpoint = (): string => {\n return process.env.LANGWATCH_ENDPOINT ?? DEFAULT_ENDPOINT;\n};\n\nconst updateEnvFile = (\n apiKey: string,\n): { created: boolean; updated: boolean; path: string } => {\n const envPath = path.join(process.cwd(), \".env\");\n\n // Check if .env exists\n if (!fs.existsSync(envPath)) {\n // Create new .env file\n fs.writeFileSync(envPath, `LANGWATCH_API_KEY=${apiKey}\\n`);\n return { created: true, updated: false, path: envPath };\n }\n\n // Read existing .env file\n const content = fs.readFileSync(envPath, \"utf-8\");\n const lines = content.split(\"\\n\");\n\n // Check if LANGWATCH_API_KEY already exists and update it\n let found = false;\n const updatedLines = lines.map((line) => {\n if (line.startsWith(\"LANGWATCH_API_KEY=\")) {\n found = true;\n return `LANGWATCH_API_KEY=${apiKey}`;\n }\n return line;\n });\n\n if (!found) {\n // Add to end of file\n if (content.endsWith(\"\\n\") || content === \"\") {\n updatedLines.push(`LANGWATCH_API_KEY=${apiKey}`);\n } else {\n updatedLines.push(\"\", `LANGWATCH_API_KEY=${apiKey}`);\n }\n }\n\n fs.writeFileSync(envPath, updatedLines.join(\"\\n\"));\n return { created: false, updated: found, path: envPath };\n};\n\nexport const loginCommand = async (): Promise<void> => {\n try {\n console.log(chalk.blue(\"🔐 LangWatch Login\"));\n console.log(\n chalk.gray(\n \"This will open your browser to get an API key from LangWatch.\",\n ),\n );\n console.log();\n\n // Get the authorization URL\n const endpoint = getEndpoint();\n const authUrl = `${endpoint}/authorize`;\n\n console.log(chalk.cyan(`Opening: ${authUrl}`));\n\n // Open browser\n const spinner = ora(\"Opening browser...\").start();\n\n try {\n const open = (await import(\"open\")).default;\n await open(authUrl);\n spinner.succeed(\"Browser opened\");\n } catch (error) {\n spinner.fail(\"Failed to open browser\");\n console.log(chalk.yellow(`Please manually open: ${chalk.cyan(authUrl)}`));\n }\n\n console.log();\n console.log(chalk.gray(\"1. Log in to LangWatch in your browser\"));\n console.log(chalk.gray(\"2. Copy your API key\"));\n console.log(chalk.gray(\"3. Come back here and paste it\"));\n console.log();\n\n // Wait for user input using prompts library\n const response = await prompts({\n type: \"password\",\n name: \"apiKey\",\n message: \"Paste your API key here:\",\n validate: (value: string) => {\n if (!value || value.trim() === \"\") {\n return \"API key is required\";\n }\n if (value.length < 10) {\n return \"API key seems too short. Please check and try again.\";\n }\n return true;\n },\n });\n\n if (!response.apiKey) {\n console.log(chalk.yellow(\"Login cancelled\"));\n process.exit(0);\n }\n\n const apiKey = response.apiKey.trim();\n\n // Save to .env file\n const envResult = updateEnvFile(apiKey);\n\n console.log();\n console.log(chalk.green(\"✓ API key saved successfully!\"));\n\n if (envResult.created) {\n console.log(chalk.gray(`• Created .env file with your API key`));\n } else if (envResult.updated) {\n console.log(chalk.gray(`• Updated existing API key in .env file`));\n } else {\n console.log(chalk.gray(`• Added API key to existing .env file`));\n }\n\n console.log();\n console.log(chalk.green(\"🎉 You're all set! You can now use:\"));\n console.log(chalk.cyan(\" langwatch prompt add <name>\"));\n console.log(chalk.cyan(\" langwatch prompt sync\"));\n } catch (error) {\n console.error(\n chalk.red(\n `Error during login: ${\n error instanceof Error ? error.message : \"Unknown error\"\n }`,\n ),\n );\n process.exit(1);\n }\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_ENDPOINT
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GMQHOSEU.mjs";
|
|
4
4
|
import "./chunk-URTD2WOC.mjs";
|
|
5
5
|
|
|
6
6
|
// src/cli/commands/login.ts
|
|
@@ -111,4 +111,4 @@ var loginCommand = async () => {
|
|
|
111
111
|
export {
|
|
112
112
|
loginCommand
|
|
113
113
|
};
|
|
114
|
-
//# sourceMappingURL=login-
|
|
114
|
+
//# sourceMappingURL=login-RNWEYFQK.mjs.map
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
export { F as FilterableBatchSpanProcessor, L as LangWatchExporter, a as LangWatchExporterOptions, c as LangWatchLogger, L as LangWatchTraceExporter, a as LangWatchTraceExporterOptions, S as SpanProcessingExcludeRule, g as getLangWatchLogger, b as getLangWatchLoggerFromProvider, d as getLangWatchTracer, e as getLangWatchTracerFromProvider } from '../implementation-
|
|
1
|
+
export { F as FilterableBatchSpanProcessor, L as LangWatchExporter, a as LangWatchExporterOptions, c as LangWatchLogger, L as LangWatchTraceExporter, a as LangWatchTraceExporterOptions, S as SpanProcessingExcludeRule, g as getLangWatchLogger, b as getLangWatchLoggerFromProvider, d as getLangWatchTracer, e as getLangWatchTracerFromProvider } from '../implementation-pq0g2B5y.mjs';
|
|
2
2
|
import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http';
|
|
3
3
|
import { a as DataCaptureMode } from '../types-Dmazk5Bk.mjs';
|
|
4
4
|
export { b as DataCaptureConfig, c as DataCaptureContext, D as DataCaptureOptions, d as DataCapturePredicate } from '../types-Dmazk5Bk.mjs';
|
|
5
|
-
import { L as LangWatchSpan } from '../types-
|
|
6
|
-
export { f as INPUT_OUTPUT_TYPES, I as InputOutputType, J as JsonSerializable, b as LangWatchSpanMetrics, d as LangWatchSpanOptions, c as LangWatchSpanRAGContext, a as LangWatchTracer, e as SimpleChatMessage, S as SpanType, s as spanTypes } from '../types-
|
|
5
|
+
import { L as LangWatchSpan } from '../types-DhEYjnRD.mjs';
|
|
6
|
+
export { f as INPUT_OUTPUT_TYPES, I as InputOutputType, J as JsonSerializable, b as LangWatchSpanMetrics, d as LangWatchSpanOptions, c as LangWatchSpanRAGContext, a as LangWatchTracer, e as SimpleChatMessage, S as SpanType, s as spanTypes } from '../types-DhEYjnRD.mjs';
|
|
7
7
|
import { Span } from '@opentelemetry/api';
|
|
8
8
|
export { b as SemConvAttributeKey, S as SemConvAttributes, a as SemConvLogRecordAttributes, l as attributes } from '../types-DRiQaKFG.mjs';
|
|
9
9
|
import '@opentelemetry/sdk-trace-base';
|
|
10
10
|
import '@opentelemetry/exporter-trace-otlp-http';
|
|
11
|
+
import '@opentelemetry/core';
|
|
11
12
|
import '@opentelemetry/api-logs';
|
|
12
13
|
import 'zod';
|
|
13
14
|
import '@opentelemetry/semantic-conventions';
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
export { F as FilterableBatchSpanProcessor, L as LangWatchExporter, a as LangWatchExporterOptions, c as LangWatchLogger, L as LangWatchTraceExporter, a as LangWatchTraceExporterOptions, S as SpanProcessingExcludeRule, g as getLangWatchLogger, b as getLangWatchLoggerFromProvider, d as getLangWatchTracer, e as getLangWatchTracerFromProvider } from '../implementation-
|
|
1
|
+
export { F as FilterableBatchSpanProcessor, L as LangWatchExporter, a as LangWatchExporterOptions, c as LangWatchLogger, L as LangWatchTraceExporter, a as LangWatchTraceExporterOptions, S as SpanProcessingExcludeRule, g as getLangWatchLogger, b as getLangWatchLoggerFromProvider, d as getLangWatchTracer, e as getLangWatchTracerFromProvider } from '../implementation-TF91Gn0l.js';
|
|
2
2
|
import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http';
|
|
3
3
|
import { a as DataCaptureMode } from '../types-Dmazk5Bk.js';
|
|
4
4
|
export { b as DataCaptureConfig, c as DataCaptureContext, D as DataCaptureOptions, d as DataCapturePredicate } from '../types-Dmazk5Bk.js';
|
|
5
|
-
import { L as LangWatchSpan } from '../types-
|
|
6
|
-
export { f as INPUT_OUTPUT_TYPES, I as InputOutputType, J as JsonSerializable, b as LangWatchSpanMetrics, d as LangWatchSpanOptions, c as LangWatchSpanRAGContext, a as LangWatchTracer, e as SimpleChatMessage, S as SpanType, s as spanTypes } from '../types-
|
|
5
|
+
import { L as LangWatchSpan } from '../types-CAQOMGrf.js';
|
|
6
|
+
export { f as INPUT_OUTPUT_TYPES, I as InputOutputType, J as JsonSerializable, b as LangWatchSpanMetrics, d as LangWatchSpanOptions, c as LangWatchSpanRAGContext, a as LangWatchTracer, e as SimpleChatMessage, S as SpanType, s as spanTypes } from '../types-CAQOMGrf.js';
|
|
7
7
|
import { Span } from '@opentelemetry/api';
|
|
8
8
|
export { b as SemConvAttributeKey, S as SemConvAttributes, a as SemConvLogRecordAttributes, l as attributes } from '../types-DRiQaKFG.js';
|
|
9
9
|
import '@opentelemetry/sdk-trace-base';
|
|
10
10
|
import '@opentelemetry/exporter-trace-otlp-http';
|
|
11
|
+
import '@opentelemetry/core';
|
|
11
12
|
import '@opentelemetry/api-logs';
|
|
12
13
|
import 'zod';
|
|
13
14
|
import '@opentelemetry/semantic-conventions';
|
|
@@ -13,8 +13,8 @@ var _chunkBP2WGNIVjs = require('../chunk-BP2WGNIV.js');
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
17
|
-
require('../chunk-
|
|
16
|
+
var _chunkVWZCWYRHjs = require('../chunk-VWZCWYRH.js');
|
|
17
|
+
require('../chunk-B5K6DU6G.js');
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
@@ -38,5 +38,5 @@ require('../chunk-OHM7JUMR.js');
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
exports.DataCapturePresets = _chunkSNDTNU3Tjs.DataCapturePresets; exports.FilterableBatchSpanProcessor = _chunkSNDTNU3Tjs.FilterableBatchSpanProcessor; exports.LangWatchExporter =
|
|
41
|
+
exports.DataCapturePresets = _chunkSNDTNU3Tjs.DataCapturePresets; exports.FilterableBatchSpanProcessor = _chunkSNDTNU3Tjs.FilterableBatchSpanProcessor; exports.LangWatchExporter = _chunkVWZCWYRHjs.LangWatchTraceExporter; exports.LangWatchLogsExporter = _chunkVWZCWYRHjs.LangWatchLogsExporter; exports.LangWatchTraceExporter = _chunkVWZCWYRHjs.LangWatchTraceExporter; exports.attributes = _chunkCKIZDPIJjs.attributes_exports; exports.createLangWatchSpan = _chunkBP2WGNIVjs.createLangWatchSpan; exports.getDataCaptureMode = _chunkCKIZDPIJjs.getDataCaptureMode; exports.getLangWatchLogger = _chunkVWZCWYRHjs.getLangWatchLogger; exports.getLangWatchLoggerFromProvider = _chunkVWZCWYRHjs.getLangWatchLoggerFromProvider; exports.getLangWatchTracer = _chunkBP2WGNIVjs.getLangWatchTracer; exports.getLangWatchTracerFromProvider = _chunkBP2WGNIVjs.getLangWatchTracerFromProvider; exports.shouldCaptureInput = _chunkCKIZDPIJjs.shouldCaptureInput; exports.shouldCaptureOutput = _chunkCKIZDPIJjs.shouldCaptureOutput; exports.spanTypes = _chunkBP2WGNIVjs.spanTypes;
|
|
42
42
|
//# sourceMappingURL=index.js.map
|
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
LangWatchTraceExporter,
|
|
14
14
|
getLangWatchLogger,
|
|
15
15
|
getLangWatchLoggerFromProvider
|
|
16
|
-
} from "../chunk-
|
|
17
|
-
import "../chunk-
|
|
16
|
+
} from "../chunk-VH7IIHFW.mjs";
|
|
17
|
+
import "../chunk-GMQHOSEU.mjs";
|
|
18
18
|
import {
|
|
19
19
|
attributes_exports,
|
|
20
20
|
getDataCaptureMode,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _opentelemetry_api from '@opentelemetry/api';
|
|
2
2
|
import { Attributes } from '@opentelemetry/api';
|
|
3
|
-
import { L as LangWatchSpan, a as LangWatchTracer, C as ChatMessage } from '../../../types-
|
|
3
|
+
import { L as LangWatchSpan, a as LangWatchTracer, C as ChatMessage } from '../../../types-DhEYjnRD.mjs';
|
|
4
4
|
import { AgentAction, AgentFinish } from '@langchain/core/agents';
|
|
5
5
|
import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
|
|
6
6
|
import { DocumentInterface } from '@langchain/core/documents';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _opentelemetry_api from '@opentelemetry/api';
|
|
2
2
|
import { Attributes } from '@opentelemetry/api';
|
|
3
|
-
import { L as LangWatchSpan, a as LangWatchTracer, C as ChatMessage } from '../../../types-
|
|
3
|
+
import { L as LangWatchSpan, a as LangWatchTracer, C as ChatMessage } from '../../../types-CAQOMGrf.js';
|
|
4
4
|
import { AgentAction, AgentFinish } from '@langchain/core/agents';
|
|
5
5
|
import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
|
|
6
6
|
import { DocumentInterface } from '@langchain/core/documents';
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkVWZCWYRHjs = require('../../../chunk-VWZCWYRH.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkB5K6DU6Gjs = require('../../../chunk-B5K6DU6G.js');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
@@ -30,12 +30,12 @@ var _resources = require('@opentelemetry/resources');
|
|
|
30
30
|
var _incubating = require('@opentelemetry/semantic-conventions/incubating'); var semconv = _interopRequireWildcard(_incubating);
|
|
31
31
|
function createMergedResource(attributes, serviceName, givenResource) {
|
|
32
32
|
const langwatchResource = _resources.resourceFromAttributes.call(void 0, {
|
|
33
|
-
[semconv.ATTR_TELEMETRY_SDK_NAME]:
|
|
34
|
-
[semconv.ATTR_TELEMETRY_SDK_LANGUAGE]:
|
|
35
|
-
[semconv.ATTR_TELEMETRY_SDK_VERSION]:
|
|
33
|
+
[semconv.ATTR_TELEMETRY_SDK_NAME]: _chunkB5K6DU6Gjs.LANGWATCH_SDK_NAME_OBSERVABILITY,
|
|
34
|
+
[semconv.ATTR_TELEMETRY_SDK_LANGUAGE]: _chunkB5K6DU6Gjs.LANGWATCH_SDK_LANGUAGE,
|
|
35
|
+
[semconv.ATTR_TELEMETRY_SDK_VERSION]: _chunkB5K6DU6Gjs.LANGWATCH_SDK_VERSION
|
|
36
36
|
});
|
|
37
37
|
const userResource = _resources.resourceFromAttributes.call(void 0, _chunkOHM7JUMRjs.__spreadValues.call(void 0, {
|
|
38
|
-
[semconv.ATTR_SERVICE_NAME]: serviceName != null ? serviceName :
|
|
38
|
+
[semconv.ATTR_SERVICE_NAME]: serviceName != null ? serviceName : _chunkB5K6DU6Gjs.DEFAULT_SERVICE_NAME
|
|
39
39
|
}, attributes != null ? attributes : {}));
|
|
40
40
|
return (givenResource != null ? givenResource : _resources.defaultResource.call(void 0, )).merge(langwatchResource).merge(userResource);
|
|
41
41
|
}
|
|
@@ -91,7 +91,7 @@ var getLangWatchConfig = (options) => {
|
|
|
91
91
|
return {
|
|
92
92
|
disabled: isDisabled,
|
|
93
93
|
apiKey: isDisabled ? void 0 : (_a = config.apiKey) != null ? _a : process.env.LANGWATCH_API_KEY,
|
|
94
|
-
endpoint: isDisabled ? void 0 : (_c = (_b = config.endpoint) != null ? _b : process.env.LANGWATCH_ENDPOINT) != null ? _c :
|
|
94
|
+
endpoint: isDisabled ? void 0 : (_c = (_b = config.endpoint) != null ? _b : process.env.LANGWATCH_ENDPOINT) != null ? _c : _chunkB5K6DU6Gjs.DEFAULT_ENDPOINT,
|
|
95
95
|
processorType: (_d = config.processorType) != null ? _d : "simple"
|
|
96
96
|
};
|
|
97
97
|
};
|
|
@@ -198,11 +198,11 @@ function createAndStartNodeSdk(options, logger, resource) {
|
|
|
198
198
|
logger.debug("Console recording of logs enabled; adding console log record processor");
|
|
199
199
|
}
|
|
200
200
|
if (!langwatch.disabled) {
|
|
201
|
-
const traceExporter = new (0,
|
|
201
|
+
const traceExporter = new (0, _chunkVWZCWYRHjs.LangWatchTraceExporter)({
|
|
202
202
|
apiKey: langwatch.apiKey,
|
|
203
203
|
endpoint: langwatch.endpoint
|
|
204
204
|
});
|
|
205
|
-
const logExporter = new (0,
|
|
205
|
+
const logExporter = new (0, _chunkVWZCWYRHjs.LangWatchLogsExporter)({
|
|
206
206
|
apiKey: langwatch.apiKey,
|
|
207
207
|
endpoint: langwatch.endpoint
|
|
208
208
|
});
|
|
@@ -272,7 +272,7 @@ function createAndStartNodeSdk(options, logger, resource) {
|
|
|
272
272
|
});
|
|
273
273
|
}
|
|
274
274
|
if (loggerProvider) {
|
|
275
|
-
|
|
275
|
+
_chunkVWZCWYRHjs.setLangWatchLoggerProvider.call(void 0, loggerProvider);
|
|
276
276
|
logger.debug("Set LangWatch logger provider");
|
|
277
277
|
}
|
|
278
278
|
if (!((_e = options.advanced) == null ? void 0 : _e.disableAutoShutdown)) {
|
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
LangWatchLogsExporter,
|
|
3
3
|
LangWatchTraceExporter,
|
|
4
4
|
setLangWatchLoggerProvider
|
|
5
|
-
} from "../../../chunk-
|
|
5
|
+
} from "../../../chunk-VH7IIHFW.mjs";
|
|
6
6
|
import {
|
|
7
7
|
DEFAULT_ENDPOINT,
|
|
8
8
|
DEFAULT_SERVICE_NAME,
|
|
9
9
|
LANGWATCH_SDK_LANGUAGE,
|
|
10
10
|
LANGWATCH_SDK_NAME_OBSERVABILITY,
|
|
11
11
|
LANGWATCH_SDK_VERSION
|
|
12
|
-
} from "../../../chunk-
|
|
12
|
+
} from "../../../chunk-GMQHOSEU.mjs";
|
|
13
13
|
import {
|
|
14
14
|
ConsoleLogger,
|
|
15
15
|
initializeObservabilitySdkConfig
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkXHNJY5BPjs = require('./chunk-XHNJY5BP.js');
|
|
4
4
|
require('./chunk-SNDTNU3T.js');
|
|
5
5
|
require('./chunk-BP2WGNIV.js');
|
|
6
|
-
require('./chunk-
|
|
7
|
-
require('./chunk-
|
|
6
|
+
require('./chunk-VWZCWYRH.js');
|
|
7
|
+
require('./chunk-B5K6DU6G.js');
|
|
8
8
|
require('./chunk-CKIZDPIJ.js');
|
|
9
9
|
|
|
10
10
|
|
|
@@ -87,7 +87,7 @@ var removeCommand = async (name) => {
|
|
|
87
87
|
}
|
|
88
88
|
} catch (error) {
|
|
89
89
|
spinner.fail();
|
|
90
|
-
if (error instanceof
|
|
90
|
+
if (error instanceof _chunkXHNJY5BPjs.PromptsError) {
|
|
91
91
|
console.error(_chalk2.default.red(`Error: ${error.message}`));
|
|
92
92
|
} else {
|
|
93
93
|
console.error(_chalk2.default.red(`Error removing prompt: ${error instanceof Error ? error.message : "Unknown error"}`));
|
|
@@ -95,7 +95,7 @@ var removeCommand = async (name) => {
|
|
|
95
95
|
process.exit(1);
|
|
96
96
|
}
|
|
97
97
|
} catch (error) {
|
|
98
|
-
if (error instanceof
|
|
98
|
+
if (error instanceof _chunkXHNJY5BPjs.PromptsError) {
|
|
99
99
|
console.error(_chalk2.default.red(`Error: ${error.message}`));
|
|
100
100
|
} else {
|
|
101
101
|
console.error(_chalk2.default.red(`Unexpected error: ${error instanceof Error ? error.message : "Unknown error"}`));
|
|
@@ -106,4 +106,4 @@ var removeCommand = async (name) => {
|
|
|
106
106
|
|
|
107
107
|
|
|
108
108
|
exports.removeCommand = removeCommand;
|
|
109
|
-
//# sourceMappingURL=remove-
|
|
109
|
+
//# sourceMappingURL=remove-5EXAIGBX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/remove-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/remove-5EXAIGBX.js","../src/cli/commands/remove.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,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AA;AACtE,QAAA;AACW,UAAA;AACqD,UAAA;AACvE,QAAA;AAEyB,QAAA;AAC3B,MAAA;AAGmC,MAAA;AACN,MAAA;AACiC,QAAA;AACvB,QAAA;AACL,UAAA;AAGuB,UAAA;AACM,UAAA;AAE1C,UAAA;AACqE,UAAA;AAChF,YAAA;AACuC,cAAA;AACf,cAAA;AACD,gBAAA;AACa,gBAAA;AAC/B,cAAA;AACL,gBAAA;AACF,cAAA;AACM,YAAA;AACN,cAAA;AACF,YAAA;AACF,UAAA;AACF,QAAA;AACF,MAAA;AAG0B,MAAA;AACF,MAAA;AAGY,MAAA;AACJ,MAAA;AAEZ,MAAA;AACF,QAAA;AAC0D,QAAA;AAC5E,MAAA;AAEc,IAAA;AACD,MAAA;AACsB,MAAA;AACiB,QAAA;AAC7C,MAAA;AACsF,QAAA;AAC7F,MAAA;AACc,MAAA;AAChB,IAAA;AAEc,EAAA;AACqB,IAAA;AACiB,MAAA;AAC7C,IAAA;AACiF,MAAA;AACxF,IAAA;AACc,IAAA;AAChB,EAAA;AACF;ADdoG;AACA;AACA","file":"/home/runner/work/langwatch/langwatch/typescript-sdk/dist/remove-5EXAIGBX.js","sourcesContent":[null,"import * as fs from \"fs\";\nimport * as path from \"path\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\nimport { FileManager } from \"../utils/fileManager\";\nimport { PromptsError } from \"@/client-sdk/services/prompts\";\n\nexport const removeCommand = async (name: string): 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 // Load existing config and lock\n const config = FileManager.loadPromptsConfig();\n const lock = FileManager.loadPromptsLock();\n\n // Check if prompt exists in dependencies\n if (!config.prompts[name]) {\n console.error(chalk.red(`Error: Prompt \"${name}\" not found in dependencies`));\n console.log(chalk.gray(`Available prompts: ${Object.keys(config.prompts).join(', ') || 'none'}`));\n process.exit(1);\n }\n\n const dependency = config.prompts[name];\n const isLocalPrompt = (typeof dependency === \"string\" && dependency.startsWith(\"file:\")) ||\n (typeof dependency === \"object\" && dependency.file);\n\n const spinner = ora(`Removing ${chalk.cyan(name)}...`).start();\n\n try {\n // Handle local prompts\n if (isLocalPrompt) {\n let localFilePath: string;\n\n if (typeof dependency === \"string\" && dependency.startsWith(\"file:\")) {\n localFilePath = path.resolve(dependency.slice(5)); // Remove \"file:\" prefix\n } else if (typeof dependency === \"object\" && dependency.file) {\n localFilePath = path.resolve(dependency.file);\n } else {\n // Fallback: assume it's in the prompts directory\n localFilePath = path.join(FileManager.getPromptsDir(), `${name}.prompt.yaml`);\n }\n\n // Delete the local file if it exists\n if (fs.existsSync(localFilePath)) {\n fs.unlinkSync(localFilePath);\n const relativePath = path.relative(process.cwd(), localFilePath);\n spinner.succeed();\n console.log(chalk.green(`✓ Removed local file ${chalk.gray(relativePath)}`));\n } else {\n spinner.succeed();\n console.log(chalk.yellow(`⚠ Local file not found (already deleted?)`));\n }\n\n console.log(chalk.yellow(`⚠ Note: This prompt may still exist on the server. Visit LangWatch to fully delete it.`));\n }\n\n // Remove materialized file if it exists\n const lockEntry = lock.prompts[name];\n if (lockEntry?.materialized) {\n const materializedPath = path.resolve(lockEntry.materialized);\n if (fs.existsSync(materializedPath)) {\n fs.unlinkSync(materializedPath);\n\n // Clean up empty directories\n const materializedDir = path.dirname(materializedPath);\n const rootMaterializedDir = FileManager.getMaterializedDir();\n\n let currentDir = materializedDir;\n while (currentDir !== rootMaterializedDir && currentDir !== path.dirname(currentDir)) {\n try {\n const entries = fs.readdirSync(currentDir);\n if (entries.length === 0) {\n fs.rmdirSync(currentDir);\n currentDir = path.dirname(currentDir);\n } else {\n break;\n }\n } catch {\n break;\n }\n }\n }\n }\n\n // Remove from config and lock\n delete config.prompts[name];\n delete lock.prompts[name];\n\n // Save updated files\n FileManager.savePromptsConfig(config);\n FileManager.savePromptsLock(lock);\n\n if (!isLocalPrompt) {\n spinner.succeed();\n console.log(chalk.green(`✓ Removed ${chalk.cyan(name)} from dependencies`));\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(chalk.red(`Error removing prompt: ${error instanceof Error ? error.message : \"Unknown error\"}`));\n }\n process.exit(1);\n }\n\n } catch (error) {\n if (error instanceof PromptsError) {\n console.error(chalk.red(`Error: ${error.message}`));\n } else {\n console.error(chalk.red(`Unexpected error: ${error instanceof Error ? error.message : \"Unknown error\"}`));\n }\n process.exit(1);\n }\n};\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PromptsError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SC4YBWRM.mjs";
|
|
4
4
|
import "./chunk-FEL5FLHA.mjs";
|
|
5
5
|
import "./chunk-DQU2PZAL.mjs";
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-VH7IIHFW.mjs";
|
|
7
|
+
import "./chunk-GMQHOSEU.mjs";
|
|
8
8
|
import "./chunk-I2SOBPAF.mjs";
|
|
9
9
|
import {
|
|
10
10
|
FileManager
|
|
@@ -106,4 +106,4 @@ var removeCommand = async (name) => {
|
|
|
106
106
|
export {
|
|
107
107
|
removeCommand
|
|
108
108
|
};
|
|
109
|
-
//# sourceMappingURL=remove-
|
|
109
|
+
//# sourceMappingURL=remove-UWKI7GIJ.mjs.map
|
|
@@ -4,11 +4,11 @@ var _chunkF6E4XQQUjs = require('./chunk-F6E4XQQU.js');
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkXHNJY5BPjs = require('./chunk-XHNJY5BP.js');
|
|
8
8
|
require('./chunk-SNDTNU3T.js');
|
|
9
9
|
require('./chunk-BP2WGNIV.js');
|
|
10
|
-
require('./chunk-
|
|
11
|
-
require('./chunk-
|
|
10
|
+
require('./chunk-VWZCWYRH.js');
|
|
11
|
+
require('./chunk-B5K6DU6G.js');
|
|
12
12
|
require('./chunk-CKIZDPIJ.js');
|
|
13
13
|
|
|
14
14
|
|
|
@@ -74,7 +74,7 @@ var syncCommand = async () => {
|
|
|
74
74
|
const startTime = Date.now();
|
|
75
75
|
try {
|
|
76
76
|
_chunkF6E4XQQUjs.checkApiKey.call(void 0, );
|
|
77
|
-
const promptsApiService = new (0,
|
|
77
|
+
const promptsApiService = new (0, _chunkXHNJY5BPjs.PromptsApiService)();
|
|
78
78
|
await _chunkGC7VHCU5js.ensureProjectInitialized.call(void 0, false);
|
|
79
79
|
const config = _chunkWAAQLJ67js.FileManager.loadPromptsConfig();
|
|
80
80
|
const lock = _chunkWAAQLJ67js.FileManager.loadPromptsLock();
|
|
@@ -395,7 +395,7 @@ Tip: Add these to prompts.json to include them in sync operations.`
|
|
|
395
395
|
process.exit(1);
|
|
396
396
|
}
|
|
397
397
|
} catch (error) {
|
|
398
|
-
if (error instanceof
|
|
398
|
+
if (error instanceof _chunkXHNJY5BPjs.PromptsError) {
|
|
399
399
|
console.error(_chalk2.default.red(`Error: ${error.message}`));
|
|
400
400
|
} else {
|
|
401
401
|
console.error(
|
|
@@ -410,4 +410,4 @@ Tip: Add these to prompts.json to include them in sync operations.`
|
|
|
410
410
|
|
|
411
411
|
|
|
412
412
|
exports.syncCommand = syncCommand;
|
|
413
|
-
//# sourceMappingURL=sync-
|
|
413
|
+
//# sourceMappingURL=sync-MOBSZVYV.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/sync-J2FH4OZC.js","../src/cli/commands/sync.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B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MAAA;AACF,IAAA;AAGgC,IAAA;AACe,MAAA;AACL,QAAA;AAEW,QAAA;AACxC,UAAA;AACT,QAAA;AACiD,QAAA;AACxC,UAAA;AACT,QAAA;AACO,QAAA;AACR,MAAA;AACH,IAAA;AAGc,IAAA;AACe,IAAA;AACV,MAAA;AAC4B,MAAA;AAC/C,IAAA;AAGgC,IAAA;AAGD,IAAA;AACuB,MAAA;AAEf,QAAA;AACf,QAAA;AAIZ,QAAA;AACA,UAAA;AACyC,YAAA;AACxB,cAAA;AACS,YAAA;AAChC,UAAA;AACF,QAAA;AACF,MAAA;AACF,IAAA;AAE8B,IAAA;AACmB,MAAA;AACV,QAAA;AAC3B,QAAA;AACA,UAAA;AACkC,YAAA;AACjB,cAAA;AACU,YAAA;AACjC,UAAA;AACF,QAAA;AACF,MAAA;AACF,IAAA;AAG+B,IAAA;AACM,MAAA;AACzB,QAAA;AACA,UAAA;AACyB,YAAA;AAC/B,UAAA;AACF,QAAA;AACF,MAAA;AACF,IAAA;AAG8B,IAAA;AACiB,MAAA;AACM,QAAA;AACnD,MAAA;AACF,IAAA;AAG2D,IAAA;AAE1B,IAAA;AAEqB,IAAA;AACR,MAAA;AACvC,IAAA;AACY,MAAA;AACW,MAAA;AACqB,QAAA;AACtB,MAAA;AACoB,QAAA;AACnB,MAAA;AACqB,QAAA;AACtB,MAAA;AACoB,QAAA;AAEI,MAAA;AACrD,IAAA;AAE8B,IAAA;AACd,MAAA;AAChB,IAAA;AACc,EAAA;AACqB,IAAA;AACiB,MAAA;AAC7C,IAAA;AACG,MAAA;AACA,QAAA;AAE6B,UAAA;AAEnC,QAAA;AACF,MAAA;AACF,IAAA;AACc,IAAA;AAChB,EAAA;AACF;AD/G8D;AACA;AACA","file":"/home/runner/work/langwatch/langwatch/typescript-sdk/dist/sync-J2FH4OZC.js","sourcesContent":[null,"import * as fs from \"fs\";\nimport * as path from \"path\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\nimport * as yaml from \"js-yaml\";\nimport { PromptConverter } from \"@/cli/utils/promptConverter\";\nimport {\n type ConfigData,\n PromptsApiService,\n PromptsError,\n type SyncAction,\n} from \"@/client-sdk/services/prompts\";\nimport type { SyncResult } from \"../types\";\nimport { FileManager } from \"../utils/fileManager\";\nimport { ensureProjectInitialized } from \"../utils/init\";\nimport { checkApiKey } from \"../utils/apiKey\";\nimport readline from \"node:readline\";\n\n// Handle conflict resolution - show diff and ask user to choose\nconst handleConflict = async (\n promptName: string,\n conflictInfo: {\n localVersion: number;\n remoteVersion: number;\n differences: string[];\n remoteConfigData: any;\n }\n): Promise<\"local\" | \"remote\" | \"abort\"> => {\n console.log(\n chalk.yellow(`\\n⚠ Conflict detected for prompt: ${chalk.cyan(promptName)}`)\n );\n console.log(\n chalk.gray(\n `Local version: ${conflictInfo.localVersion}, Remote version: ${conflictInfo.remoteVersion}`\n )\n );\n\n if (conflictInfo.differences.length > 0) {\n console.log(chalk.yellow(\"\\nDifferences:\"));\n conflictInfo.differences.forEach((diff) => {\n console.log(chalk.gray(` • ${diff}`));\n });\n }\n\n console.log(chalk.yellow(\"\\nOptions:\"));\n console.log(\" [l] Use local version (overwrite remote)\");\n console.log(\" [r] Use remote version (overwrite local)\");\n console.log(\" [a] Abort sync for this prompt\");\n\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n rl.question(\"Choose resolution (l/r/a): \", (answer: string) => {\n rl.close();\n const choice = answer.toLowerCase();\n if (choice === \"l\" || choice === \"local\") {\n resolve(\"local\");\n } else if (choice === \"r\" || choice === \"remote\") {\n resolve(\"remote\");\n } else {\n resolve(\"abort\");\n }\n });\n });\n};\n\nexport const syncCommand = async (): Promise<void> => {\n console.log(\"🔄 Starting sync...\");\n\n const startTime = Date.now();\n\n try {\n // Check API key before doing anything else\n checkApiKey();\n\n // Get prompts API service\n const promptsApiService = new PromptsApiService();\n\n // Ensure project is initialized (prompts.json, lock file, directories)\n await ensureProjectInitialized(false); // Don't prompt for .gitignore in sync\n\n // Load prompts config and lock\n const config = FileManager.loadPromptsConfig();\n const lock = FileManager.loadPromptsLock();\n\n const result: SyncResult = {\n fetched: [],\n pushed: [],\n unchanged: [],\n cleaned: [],\n errors: [],\n };\n\n // Process remote prompts (fetch and materialize)\n const remoteDeps = Object.entries(config.prompts).filter(\n ([, dependency]) => {\n // Skip local file dependencies (both object format and string format)\n if (typeof dependency === \"object\" && dependency.file) {\n return false;\n }\n if (typeof dependency === \"string\" && dependency.startsWith(\"file:\")) {\n return false;\n }\n return true;\n }\n );\n\n if (remoteDeps.length > 0) {\n const fetchSpinner = ora(\n `Checking ${remoteDeps.length} remote prompts...`\n ).start();\n\n for (const [name, dependency] of remoteDeps) {\n try {\n const versionSpec =\n typeof dependency === \"string\"\n ? dependency\n : dependency.version ?? \"latest\";\n\n // Check if we already have this prompt with the same version\n const lockEntry = lock.prompts[name];\n\n // Fetch the prompt from the API to check current version\n const prompt = await promptsApiService.get(name);\n\n if (prompt) {\n // Check if we need to update (new version or not materialized)\n const needsUpdate =\n !lockEntry ||\n lockEntry.version !== prompt.version ||\n !lockEntry.materialized ||\n !fs.existsSync(path.resolve(lockEntry.materialized));\n\n if (needsUpdate) {\n // Convert to MaterializedPrompt format using the converter\n const materializedPrompt =\n PromptConverter.fromApiToMaterialized(prompt);\n\n const savedPath = FileManager.saveMaterializedPrompt(\n name,\n materializedPrompt\n );\n const relativePath = path.relative(process.cwd(), savedPath);\n result.fetched.push({\n name,\n version: prompt.version,\n versionSpec,\n });\n\n // Update lock file entry\n FileManager.updateLockEntry(\n lock,\n name,\n materializedPrompt,\n savedPath\n );\n\n fetchSpinner.text = `Fetched ${chalk.cyan(\n `${name}@${versionSpec}`\n )} ${chalk.gray(`(version ${prompt.version})`)} → ${chalk.gray(\n relativePath\n )}`;\n } else {\n // No change needed, track as unchanged\n result.unchanged.push(name);\n }\n } else {\n result.errors.push({ name, error: \"Prompt not found\" });\n }\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error\";\n result.errors.push({ name, error: errorMessage });\n }\n }\n\n fetchSpinner.stop();\n }\n\n // Process local prompts (push to API) - only those explicitly declared in prompts.json\n const localFileRefs = Object.entries(config.prompts).filter(\n ([, dependency]) => {\n return typeof dependency === \"string\" && dependency.startsWith(\"file:\");\n }\n );\n\n if (localFileRefs.length > 0) {\n const pushSpinner = ora(\n `Pushing ${localFileRefs.length} local prompts...`\n ).start();\n\n // Use the existing lock file instead of reloading it\n // const lock = FileManager.loadPromptsLock(); // Don't reload - use existing lock\n\n for (const [promptName, dependency] of localFileRefs) {\n try {\n const filePath = (dependency as string).slice(5); // Remove \"file:\" prefix\n\n // Load local prompt config\n const localConfig = FileManager.loadLocalPrompt(filePath);\n\n // Get current version from lock file\n const currentVersion = lock.prompts[promptName]?.version;\n\n // Convert local config to API configData format\n const configData: ConfigData = {\n model: localConfig.model,\n prompt: PromptConverter.extractSystemPrompt(localConfig.messages),\n messages: PromptConverter.filterNonSystemMessages(\n localConfig.messages\n ) as Array<{\n role: \"system\" | \"user\" | \"assistant\";\n content: string;\n }>,\n temperature: localConfig.modelParameters?.temperature,\n max_tokens: localConfig.modelParameters?.max_tokens,\n inputs: [{ identifier: \"input\", type: \"str\" }],\n outputs: [{ identifier: \"output\", type: \"str\" }],\n };\n\n // Use new sync API with conflict detection\n const syncResult = await promptsApiService.sync({\n name: promptName,\n configData,\n localVersion: currentVersion,\n commitMessage: `Synced from local file: ${path.basename(filePath)}`,\n });\n\n const relativePath = path.relative(process.cwd(), filePath);\n\n let conflictResolution: \"local\" | \"remote\" | \"abort\" | null = null;\n if (syncResult.action === \"conflict\") {\n // Handle conflict - prompt user for resolution\n pushSpinner.stop();\n conflictResolution = await handleConflict(\n promptName,\n syncResult.conflictInfo!\n );\n if (conflictResolution === \"abort\") {\n result.errors.push({\n name: promptName,\n error: \"Sync aborted due to conflict\",\n });\n continue;\n }\n\n // If user chose remote, we should pull the remote version to local file\n if (conflictResolution === \"remote\" && syncResult.conflictInfo) {\n // Update local file with remote content\n const remoteConfig = {\n model: syncResult.conflictInfo.remoteConfigData.model,\n modelParameters: {\n temperature:\n syncResult.conflictInfo.remoteConfigData.temperature,\n max_tokens:\n syncResult.conflictInfo.remoteConfigData.max_tokens,\n },\n messages: [\n {\n role: \"system\" as const,\n content: syncResult.conflictInfo.remoteConfigData.prompt,\n },\n ...(syncResult.conflictInfo.remoteConfigData.messages ?? []),\n ],\n };\n\n const yamlContent = yaml.dump(remoteConfig, {\n lineWidth: -1,\n noRefs: true,\n sortKeys: false,\n });\n\n fs.writeFileSync(filePath, yamlContent);\n }\n\n // If user chose to proceed, we continue with the sync\n pushSpinner.start();\n }\n\n // Update lock file with new version info\n if (syncResult.prompt) {\n lock.prompts[promptName] = {\n version: syncResult.prompt.version,\n versionId: syncResult.prompt.versionId,\n materialized: filePath,\n };\n } else if (syncResult.action === \"conflict\") {\n const remoteVersion = syncResult.conflictInfo?.remoteVersion ?? 0;\n if (conflictResolution === \"remote\") {\n // User chose remote - use remote version\n lock.prompts[promptName] = {\n version: remoteVersion,\n versionId: \"remote_version\", // We don't have the actual versionId from conflict info\n materialized: filePath,\n };\n } else {\n // User chose local - force push\n const formattedConfig = PromptConverter.fromLocalToApiFormat(localConfig);\n const updatedPrompt = await promptsApiService.update(promptName, {\n ...formattedConfig,\n commitMessage: `Updated via CLI: synced from local file`\n });\n lock.prompts[promptName] = {\n version: updatedPrompt.version,\n versionId: updatedPrompt.versionId,\n materialized: filePath,\n };\n }\n }\n\n // Determine the action text based on sync result and conflict resolution\n let actionText: string;\n if (syncResult.action === \"conflict\") {\n if (conflictResolution === \"remote\") {\n actionText = \"Pulled\"; // User chose to use remote version\n result.fetched.push({\n name: promptName,\n version: syncResult.conflictInfo?.remoteVersion ?? 0,\n versionSpec: \"latest\", // Default for conflict resolution\n });\n } else {\n actionText = \"Pushed\"; // User chose to use local version (or forced push)\n result.pushed.push({\n name: promptName,\n version: (syncResult.conflictInfo?.remoteVersion ?? 0) + 1, // New version after push\n });\n }\n } else if (syncResult.action === \"up_to_date\") {\n // For up-to-date prompts, add to unchanged instead of pushed\n actionText = \"Up-to-date\";\n result.unchanged.push(promptName);\n } else {\n const actionMap: Record<SyncAction, string> = {\n created: \"Created\",\n updated: \"Updated\",\n conflict: \"Conflict resolved\",\n up_to_date: \"Up to date\",\n };\n actionText = actionMap[syncResult.action as SyncAction] || \"Pushed\";\n result.pushed.push({\n name: promptName,\n version: syncResult.prompt?.version ?? 0,\n });\n }\n\n pushSpinner.text = `${actionText} ${chalk.cyan(\n promptName\n )} ${chalk.gray(\n `(version ${\n syncResult.prompt?.version ??\n syncResult.conflictInfo?.remoteVersion ??\n \"unknown\"\n })`\n )} ${conflictResolution === \"remote\" ? \"to\" : \"from\"} ${chalk.gray(\n relativePath\n )}`;\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error\";\n result.errors.push({ name: promptName, error: errorMessage });\n }\n }\n\n // Save lock file with all updates\n FileManager.savePromptsLock(lock);\n\n pushSpinner.stop();\n }\n\n // Check for orphan local prompt files and show helpful warnings\n const discoveredLocalFiles = FileManager.getLocalPromptFiles();\n const orphanFiles = discoveredLocalFiles.filter((filePath) => {\n const promptName = FileManager.promptNameFromPath(filePath);\n return !config.prompts[promptName]; // Not declared in prompts.json\n });\n\n if (orphanFiles.length > 0) {\n console.log(\n chalk.yellow(\n `\\n⚠ Found ${orphanFiles.length} orphan prompt file${\n orphanFiles.length > 1 ? \"s\" : \"\"\n }:`\n )\n );\n\n for (const filePath of orphanFiles) {\n const promptName = FileManager.promptNameFromPath(filePath);\n const relativePath = path.relative(process.cwd(), filePath);\n\n console.log(chalk.yellow(` ${relativePath}`));\n console.log(\n chalk.gray(\n ` Add to prompts.json: \"${promptName}\": \"file:${relativePath}\"`\n )\n );\n }\n\n console.log(\n chalk.gray(\n `\\nTip: Add these to prompts.json to include them in sync operations.`\n )\n );\n }\n\n // Cleanup orphaned materialized files\n const currentDependencies = new Set(\n Object.keys(config.prompts).filter((name) => {\n const dependency = config.prompts[name];\n // Only include remote dependencies (not local file: dependencies)\n if (typeof dependency === \"object\" && dependency.file) {\n return false;\n }\n if (typeof dependency === \"string\" && dependency.startsWith(\"file:\")) {\n return false;\n }\n return true;\n })\n );\n\n const cleanedFiles =\n FileManager.cleanupOrphanedMaterializedFiles(currentDependencies);\n if (cleanedFiles.length > 0) {\n result.cleaned = cleanedFiles;\n FileManager.removeFromLock(lock, cleanedFiles);\n }\n\n // Save the updated lock file\n FileManager.savePromptsLock(lock);\n\n // Print individual results if there were actions\n if (result.fetched.length > 0) {\n for (const { name, version, versionSpec } of result.fetched) {\n // Get the actual saved path from lock file for display consistency\n const lockEntry = lock.prompts[name];\n const displayPath = lockEntry?.materialized\n ? `./${lockEntry.materialized}`\n : `./prompts/.materialized/${name}.prompt.yaml`;\n\n console.log(\n chalk.green(\n `✓ Pulled ${chalk.cyan(`${name}@${versionSpec}`)} ${chalk.gray(\n `(version ${version})`\n )} → ${chalk.gray(displayPath)}`\n )\n );\n }\n }\n\n if (result.pushed.length > 0) {\n for (const { name, version } of result.pushed) {\n const localPath = `./prompts/${name}.prompt.yaml`;\n console.log(\n chalk.green(\n `✓ Pushed ${chalk.cyan(name)} ${chalk.gray(\n `(version ${version})`\n )} from ${chalk.gray(localPath)}`\n )\n );\n }\n }\n\n // Print cleaned up files\n if (result.cleaned.length > 0) {\n for (const name of result.cleaned) {\n console.log(\n chalk.yellow(\n `✓ Cleaned ${chalk.cyan(name)} (no longer in dependencies)`\n )\n );\n }\n }\n\n // Print errors\n if (result.errors.length > 0) {\n for (const { name, error } of result.errors) {\n console.log(chalk.red(`✗ Failed ${chalk.cyan(name)}: ${error}`));\n }\n }\n\n // Print summary\n const duration = ((Date.now() - startTime) / 1000).toFixed(1);\n const totalActions =\n result.fetched.length + result.pushed.length + result.cleaned.length;\n\n if (totalActions === 0 && result.errors.length === 0) {\n console.log(chalk.gray(`Synced in ${duration}s, no changes`));\n } else {\n const summary = [];\n if (result.fetched.length > 0)\n summary.push(`${result.fetched.length} fetched`);\n if (result.pushed.length > 0)\n summary.push(`${result.pushed.length} pushed`);\n if (result.cleaned.length > 0)\n summary.push(`${result.cleaned.length} cleaned`);\n if (result.errors.length > 0)\n summary.push(`${result.errors.length} errors`);\n\n console.log(chalk.gray(`Synced ${summary.join(\", \")} in ${duration}s`));\n }\n\n if (result.errors.length > 0) {\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"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/langwatch/langwatch/typescript-sdk/dist/sync-MOBSZVYV.js","../src/cli/commands/sync.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACA;AACF,sDAA4B;AAC5B;AACA;ACzBA,+DAAoB;AACpB,uEAAsB;AACtB,4EAAkB;AAClB,oEAAgB;AAChB,8EAAsB;AAYtB,wFAAqB;AAGrB,IAAM,eAAA,EAAiB,MAAA,CACrB,UAAA,EACA,YAAA,EAAA,GAM0C;AAC1C,EAAA,OAAA,CAAQ,GAAA;AAAA,IACN,eAAA,CAAM,MAAA,CAAO,CAAA;AAAA,qCAAA,EAAqC,eAAA,CAAM,IAAA,CAAK,UAAU,CAAC,CAAA,CAAA;AAC1E,EAAA;AACQ,EAAA;AACA,IAAA;AACuC,MAAA;AAC7C,IAAA;AACF,EAAA;AAEyC,EAAA;AACG,IAAA;AACC,IAAA;AACJ,MAAA;AACtC,IAAA;AACH,EAAA;AAEsC,EAAA;AACkB,EA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,MAAA;AACF,IAAA;AAG+B,IAAA;AACM,MAAA;AACzB,QAAA;AACA,UAAA;AACyB,YAAA;AAC/B,UAAA;AACF,QAAA;AACF,MAAA;AACF,IAAA;AAG8B,IAAA;AACiB,MAAA;AACM,QAAA;AACnD,MAAA;AACF,IAAA;AAG2D,IAAA;AAE1B,IAAA;AAEqB,IAAA;AACR,MAAA;AACvC,IAAA;AACY,MAAA;AACW,MAAA;AACqB,QAAA;AACtB,MAAA;AACoB,QAAA;AACnB,MAAA;AACqB,QAAA;AACtB,MAAA;AACoB,QAAA;AAEI,MAAA;AACrD,IAAA;AAE8B,IAAA;AACd,MAAA;AAChB,IAAA;AACc,EAAA;AACqB,IAAA;AACiB,MAAA;AAC7C,IAAA;AACG,MAAA;AACA,QAAA;AAE6B,UAAA;AAEnC,QAAA;AACF,MAAA;AACF,IAAA;AACc,IAAA;AAChB,EAAA;AACF;AD/G8D;AACA;AACA","file":"/home/runner/work/langwatch/langwatch/typescript-sdk/dist/sync-MOBSZVYV.js","sourcesContent":[null,"import * as fs from \"fs\";\nimport * as path from \"path\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\nimport * as yaml from \"js-yaml\";\nimport { PromptConverter } from \"@/cli/utils/promptConverter\";\nimport {\n type ConfigData,\n PromptsApiService,\n PromptsError,\n type SyncAction,\n} from \"@/client-sdk/services/prompts\";\nimport type { SyncResult } from \"../types\";\nimport { FileManager } from \"../utils/fileManager\";\nimport { ensureProjectInitialized } from \"../utils/init\";\nimport { checkApiKey } from \"../utils/apiKey\";\nimport readline from \"node:readline\";\n\n// Handle conflict resolution - show diff and ask user to choose\nconst handleConflict = async (\n promptName: string,\n conflictInfo: {\n localVersion: number;\n remoteVersion: number;\n differences: string[];\n remoteConfigData: any;\n }\n): Promise<\"local\" | \"remote\" | \"abort\"> => {\n console.log(\n chalk.yellow(`\\n⚠ Conflict detected for prompt: ${chalk.cyan(promptName)}`)\n );\n console.log(\n chalk.gray(\n `Local version: ${conflictInfo.localVersion}, Remote version: ${conflictInfo.remoteVersion}`\n )\n );\n\n if (conflictInfo.differences.length > 0) {\n console.log(chalk.yellow(\"\\nDifferences:\"));\n conflictInfo.differences.forEach((diff) => {\n console.log(chalk.gray(` • ${diff}`));\n });\n }\n\n console.log(chalk.yellow(\"\\nOptions:\"));\n console.log(\" [l] Use local version (overwrite remote)\");\n console.log(\" [r] Use remote version (overwrite local)\");\n console.log(\" [a] Abort sync for this prompt\");\n\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n rl.question(\"Choose resolution (l/r/a): \", (answer: string) => {\n rl.close();\n const choice = answer.toLowerCase();\n if (choice === \"l\" || choice === \"local\") {\n resolve(\"local\");\n } else if (choice === \"r\" || choice === \"remote\") {\n resolve(\"remote\");\n } else {\n resolve(\"abort\");\n }\n });\n });\n};\n\nexport const syncCommand = async (): Promise<void> => {\n console.log(\"🔄 Starting sync...\");\n\n const startTime = Date.now();\n\n try {\n // Check API key before doing anything else\n checkApiKey();\n\n // Get prompts API service\n const promptsApiService = new PromptsApiService();\n\n // Ensure project is initialized (prompts.json, lock file, directories)\n await ensureProjectInitialized(false); // Don't prompt for .gitignore in sync\n\n // Load prompts config and lock\n const config = FileManager.loadPromptsConfig();\n const lock = FileManager.loadPromptsLock();\n\n const result: SyncResult = {\n fetched: [],\n pushed: [],\n unchanged: [],\n cleaned: [],\n errors: [],\n };\n\n // Process remote prompts (fetch and materialize)\n const remoteDeps = Object.entries(config.prompts).filter(\n ([, dependency]) => {\n // Skip local file dependencies (both object format and string format)\n if (typeof dependency === \"object\" && dependency.file) {\n return false;\n }\n if (typeof dependency === \"string\" && dependency.startsWith(\"file:\")) {\n return false;\n }\n return true;\n }\n );\n\n if (remoteDeps.length > 0) {\n const fetchSpinner = ora(\n `Checking ${remoteDeps.length} remote prompts...`\n ).start();\n\n for (const [name, dependency] of remoteDeps) {\n try {\n const versionSpec =\n typeof dependency === \"string\"\n ? dependency\n : dependency.version ?? \"latest\";\n\n // Check if we already have this prompt with the same version\n const lockEntry = lock.prompts[name];\n\n // Fetch the prompt from the API to check current version\n const prompt = await promptsApiService.get(name);\n\n if (prompt) {\n // Check if we need to update (new version or not materialized)\n const needsUpdate =\n !lockEntry ||\n lockEntry.version !== prompt.version ||\n !lockEntry.materialized ||\n !fs.existsSync(path.resolve(lockEntry.materialized));\n\n if (needsUpdate) {\n // Convert to MaterializedPrompt format using the converter\n const materializedPrompt =\n PromptConverter.fromApiToMaterialized(prompt);\n\n const savedPath = FileManager.saveMaterializedPrompt(\n name,\n materializedPrompt\n );\n const relativePath = path.relative(process.cwd(), savedPath);\n result.fetched.push({\n name,\n version: prompt.version,\n versionSpec,\n });\n\n // Update lock file entry\n FileManager.updateLockEntry(\n lock,\n name,\n materializedPrompt,\n savedPath\n );\n\n fetchSpinner.text = `Fetched ${chalk.cyan(\n `${name}@${versionSpec}`\n )} ${chalk.gray(`(version ${prompt.version})`)} → ${chalk.gray(\n relativePath\n )}`;\n } else {\n // No change needed, track as unchanged\n result.unchanged.push(name);\n }\n } else {\n result.errors.push({ name, error: \"Prompt not found\" });\n }\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error\";\n result.errors.push({ name, error: errorMessage });\n }\n }\n\n fetchSpinner.stop();\n }\n\n // Process local prompts (push to API) - only those explicitly declared in prompts.json\n const localFileRefs = Object.entries(config.prompts).filter(\n ([, dependency]) => {\n return typeof dependency === \"string\" && dependency.startsWith(\"file:\");\n }\n );\n\n if (localFileRefs.length > 0) {\n const pushSpinner = ora(\n `Pushing ${localFileRefs.length} local prompts...`\n ).start();\n\n // Use the existing lock file instead of reloading it\n // const lock = FileManager.loadPromptsLock(); // Don't reload - use existing lock\n\n for (const [promptName, dependency] of localFileRefs) {\n try {\n const filePath = (dependency as string).slice(5); // Remove \"file:\" prefix\n\n // Load local prompt config\n const localConfig = FileManager.loadLocalPrompt(filePath);\n\n // Get current version from lock file\n const currentVersion = lock.prompts[promptName]?.version;\n\n // Convert local config to API configData format\n const configData: ConfigData = {\n model: localConfig.model,\n prompt: PromptConverter.extractSystemPrompt(localConfig.messages),\n messages: PromptConverter.filterNonSystemMessages(\n localConfig.messages\n ) as Array<{\n role: \"system\" | \"user\" | \"assistant\";\n content: string;\n }>,\n temperature: localConfig.modelParameters?.temperature,\n max_tokens: localConfig.modelParameters?.max_tokens,\n inputs: [{ identifier: \"input\", type: \"str\" }],\n outputs: [{ identifier: \"output\", type: \"str\" }],\n };\n\n // Use new sync API with conflict detection\n const syncResult = await promptsApiService.sync({\n name: promptName,\n configData,\n localVersion: currentVersion,\n commitMessage: `Synced from local file: ${path.basename(filePath)}`,\n });\n\n const relativePath = path.relative(process.cwd(), filePath);\n\n let conflictResolution: \"local\" | \"remote\" | \"abort\" | null = null;\n if (syncResult.action === \"conflict\") {\n // Handle conflict - prompt user for resolution\n pushSpinner.stop();\n conflictResolution = await handleConflict(\n promptName,\n syncResult.conflictInfo!\n );\n if (conflictResolution === \"abort\") {\n result.errors.push({\n name: promptName,\n error: \"Sync aborted due to conflict\",\n });\n continue;\n }\n\n // If user chose remote, we should pull the remote version to local file\n if (conflictResolution === \"remote\" && syncResult.conflictInfo) {\n // Update local file with remote content\n const remoteConfig = {\n model: syncResult.conflictInfo.remoteConfigData.model,\n modelParameters: {\n temperature:\n syncResult.conflictInfo.remoteConfigData.temperature,\n max_tokens:\n syncResult.conflictInfo.remoteConfigData.max_tokens,\n },\n messages: [\n {\n role: \"system\" as const,\n content: syncResult.conflictInfo.remoteConfigData.prompt,\n },\n ...(syncResult.conflictInfo.remoteConfigData.messages ?? []),\n ],\n };\n\n const yamlContent = yaml.dump(remoteConfig, {\n lineWidth: -1,\n noRefs: true,\n sortKeys: false,\n });\n\n fs.writeFileSync(filePath, yamlContent);\n }\n\n // If user chose to proceed, we continue with the sync\n pushSpinner.start();\n }\n\n // Update lock file with new version info\n if (syncResult.prompt) {\n lock.prompts[promptName] = {\n version: syncResult.prompt.version,\n versionId: syncResult.prompt.versionId,\n materialized: filePath,\n };\n } else if (syncResult.action === \"conflict\") {\n const remoteVersion = syncResult.conflictInfo?.remoteVersion ?? 0;\n if (conflictResolution === \"remote\") {\n // User chose remote - use remote version\n lock.prompts[promptName] = {\n version: remoteVersion,\n versionId: \"remote_version\", // We don't have the actual versionId from conflict info\n materialized: filePath,\n };\n } else {\n // User chose local - force push\n const formattedConfig = PromptConverter.fromLocalToApiFormat(localConfig);\n const updatedPrompt = await promptsApiService.update(promptName, {\n ...formattedConfig,\n commitMessage: `Updated via CLI: synced from local file`\n });\n lock.prompts[promptName] = {\n version: updatedPrompt.version,\n versionId: updatedPrompt.versionId,\n materialized: filePath,\n };\n }\n }\n\n // Determine the action text based on sync result and conflict resolution\n let actionText: string;\n if (syncResult.action === \"conflict\") {\n if (conflictResolution === \"remote\") {\n actionText = \"Pulled\"; // User chose to use remote version\n result.fetched.push({\n name: promptName,\n version: syncResult.conflictInfo?.remoteVersion ?? 0,\n versionSpec: \"latest\", // Default for conflict resolution\n });\n } else {\n actionText = \"Pushed\"; // User chose to use local version (or forced push)\n result.pushed.push({\n name: promptName,\n version: (syncResult.conflictInfo?.remoteVersion ?? 0) + 1, // New version after push\n });\n }\n } else if (syncResult.action === \"up_to_date\") {\n // For up-to-date prompts, add to unchanged instead of pushed\n actionText = \"Up-to-date\";\n result.unchanged.push(promptName);\n } else {\n const actionMap: Record<SyncAction, string> = {\n created: \"Created\",\n updated: \"Updated\",\n conflict: \"Conflict resolved\",\n up_to_date: \"Up to date\",\n };\n actionText = actionMap[syncResult.action as SyncAction] || \"Pushed\";\n result.pushed.push({\n name: promptName,\n version: syncResult.prompt?.version ?? 0,\n });\n }\n\n pushSpinner.text = `${actionText} ${chalk.cyan(\n promptName\n )} ${chalk.gray(\n `(version ${\n syncResult.prompt?.version ??\n syncResult.conflictInfo?.remoteVersion ??\n \"unknown\"\n })`\n )} ${conflictResolution === \"remote\" ? \"to\" : \"from\"} ${chalk.gray(\n relativePath\n )}`;\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error\";\n result.errors.push({ name: promptName, error: errorMessage });\n }\n }\n\n // Save lock file with all updates\n FileManager.savePromptsLock(lock);\n\n pushSpinner.stop();\n }\n\n // Check for orphan local prompt files and show helpful warnings\n const discoveredLocalFiles = FileManager.getLocalPromptFiles();\n const orphanFiles = discoveredLocalFiles.filter((filePath) => {\n const promptName = FileManager.promptNameFromPath(filePath);\n return !config.prompts[promptName]; // Not declared in prompts.json\n });\n\n if (orphanFiles.length > 0) {\n console.log(\n chalk.yellow(\n `\\n⚠ Found ${orphanFiles.length} orphan prompt file${\n orphanFiles.length > 1 ? \"s\" : \"\"\n }:`\n )\n );\n\n for (const filePath of orphanFiles) {\n const promptName = FileManager.promptNameFromPath(filePath);\n const relativePath = path.relative(process.cwd(), filePath);\n\n console.log(chalk.yellow(` ${relativePath}`));\n console.log(\n chalk.gray(\n ` Add to prompts.json: \"${promptName}\": \"file:${relativePath}\"`\n )\n );\n }\n\n console.log(\n chalk.gray(\n `\\nTip: Add these to prompts.json to include them in sync operations.`\n )\n );\n }\n\n // Cleanup orphaned materialized files\n const currentDependencies = new Set(\n Object.keys(config.prompts).filter((name) => {\n const dependency = config.prompts[name];\n // Only include remote dependencies (not local file: dependencies)\n if (typeof dependency === \"object\" && dependency.file) {\n return false;\n }\n if (typeof dependency === \"string\" && dependency.startsWith(\"file:\")) {\n return false;\n }\n return true;\n })\n );\n\n const cleanedFiles =\n FileManager.cleanupOrphanedMaterializedFiles(currentDependencies);\n if (cleanedFiles.length > 0) {\n result.cleaned = cleanedFiles;\n FileManager.removeFromLock(lock, cleanedFiles);\n }\n\n // Save the updated lock file\n FileManager.savePromptsLock(lock);\n\n // Print individual results if there were actions\n if (result.fetched.length > 0) {\n for (const { name, version, versionSpec } of result.fetched) {\n // Get the actual saved path from lock file for display consistency\n const lockEntry = lock.prompts[name];\n const displayPath = lockEntry?.materialized\n ? `./${lockEntry.materialized}`\n : `./prompts/.materialized/${name}.prompt.yaml`;\n\n console.log(\n chalk.green(\n `✓ Pulled ${chalk.cyan(`${name}@${versionSpec}`)} ${chalk.gray(\n `(version ${version})`\n )} → ${chalk.gray(displayPath)}`\n )\n );\n }\n }\n\n if (result.pushed.length > 0) {\n for (const { name, version } of result.pushed) {\n const localPath = `./prompts/${name}.prompt.yaml`;\n console.log(\n chalk.green(\n `✓ Pushed ${chalk.cyan(name)} ${chalk.gray(\n `(version ${version})`\n )} from ${chalk.gray(localPath)}`\n )\n );\n }\n }\n\n // Print cleaned up files\n if (result.cleaned.length > 0) {\n for (const name of result.cleaned) {\n console.log(\n chalk.yellow(\n `✓ Cleaned ${chalk.cyan(name)} (no longer in dependencies)`\n )\n );\n }\n }\n\n // Print errors\n if (result.errors.length > 0) {\n for (const { name, error } of result.errors) {\n console.log(chalk.red(`✗ Failed ${chalk.cyan(name)}: ${error}`));\n }\n }\n\n // Print summary\n const duration = ((Date.now() - startTime) / 1000).toFixed(1);\n const totalActions =\n result.fetched.length + result.pushed.length + result.cleaned.length;\n\n if (totalActions === 0 && result.errors.length === 0) {\n console.log(chalk.gray(`Synced in ${duration}s, no changes`));\n } else {\n const summary = [];\n if (result.fetched.length > 0)\n summary.push(`${result.fetched.length} fetched`);\n if (result.pushed.length > 0)\n summary.push(`${result.pushed.length} pushed`);\n if (result.cleaned.length > 0)\n summary.push(`${result.cleaned.length} cleaned`);\n if (result.errors.length > 0)\n summary.push(`${result.errors.length} errors`);\n\n console.log(chalk.gray(`Synced ${summary.join(\", \")} in ${duration}s`));\n }\n\n if (result.errors.length > 0) {\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"]}
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
PromptsApiService,
|
|
6
6
|
PromptsError
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-SC4YBWRM.mjs";
|
|
8
8
|
import "./chunk-FEL5FLHA.mjs";
|
|
9
9
|
import "./chunk-DQU2PZAL.mjs";
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-VH7IIHFW.mjs";
|
|
11
|
+
import "./chunk-GMQHOSEU.mjs";
|
|
12
12
|
import "./chunk-I2SOBPAF.mjs";
|
|
13
13
|
import {
|
|
14
14
|
ensureProjectInitialized
|
|
@@ -410,4 +410,4 @@ Tip: Add these to prompts.json to include them in sync operations.`
|
|
|
410
410
|
export {
|
|
411
411
|
syncCommand
|
|
412
412
|
};
|
|
413
|
-
//# sourceMappingURL=sync-
|
|
413
|
+
//# sourceMappingURL=sync-WJSJIKEW.mjs.map
|