libretto 0.2.6 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/package.json +12 -12
- package/skill/SKILL.md +20 -18
- package/skill/code-generation-rules.md +3 -3
- package/skill/integration-approach-selection.md +3 -3
- package/dist/cli/cli.js +0 -209
- package/dist/cli/commands/ai.js +0 -21
- package/dist/cli/commands/browser.js +0 -82
- package/dist/cli/commands/execution.js +0 -461
- package/dist/cli/commands/init.js +0 -95
- package/dist/cli/commands/logs.js +0 -93
- package/dist/cli/commands/snapshot.js +0 -106
- package/dist/cli/core/ai-config.js +0 -149
- package/dist/cli/core/browser.js +0 -648
- package/dist/cli/core/context.js +0 -118
- package/dist/cli/core/pause-signals.js +0 -29
- package/dist/cli/core/session-telemetry.js +0 -491
- package/dist/cli/core/session.js +0 -183
- package/dist/cli/core/snapshot-analyzer.js +0 -492
- package/dist/cli/core/telemetry.js +0 -362
- package/dist/cli/index.js +0 -13
- package/dist/cli/workers/run-integration-runtime.js +0 -227
- package/dist/cli/workers/run-integration-worker-protocol.js +0 -12
- package/dist/cli/workers/run-integration-worker.js +0 -66
- package/dist/index.cjs +0 -116
- package/dist/index.d.cts +0 -21
- package/dist/index.d.ts +0 -21
- package/dist/index.js +0 -97
- package/dist/runtime/download/download.cjs +0 -70
- package/dist/runtime/download/download.d.cts +0 -35
- package/dist/runtime/download/download.d.ts +0 -35
- package/dist/runtime/download/download.js +0 -45
- package/dist/runtime/download/index.cjs +0 -30
- package/dist/runtime/download/index.d.cts +0 -3
- package/dist/runtime/download/index.d.ts +0 -3
- package/dist/runtime/download/index.js +0 -8
- package/dist/runtime/extract/extract.cjs +0 -88
- package/dist/runtime/extract/extract.d.cts +0 -23
- package/dist/runtime/extract/extract.d.ts +0 -23
- package/dist/runtime/extract/extract.js +0 -64
- package/dist/runtime/extract/index.cjs +0 -28
- package/dist/runtime/extract/index.d.cts +0 -5
- package/dist/runtime/extract/index.d.ts +0 -5
- package/dist/runtime/extract/index.js +0 -4
- package/dist/runtime/network/index.cjs +0 -28
- package/dist/runtime/network/index.d.cts +0 -4
- package/dist/runtime/network/index.d.ts +0 -4
- package/dist/runtime/network/index.js +0 -6
- package/dist/runtime/network/network.cjs +0 -91
- package/dist/runtime/network/network.d.cts +0 -28
- package/dist/runtime/network/network.d.ts +0 -28
- package/dist/runtime/network/network.js +0 -67
- package/dist/runtime/recovery/agent.cjs +0 -223
- package/dist/runtime/recovery/agent.d.cts +0 -13
- package/dist/runtime/recovery/agent.d.ts +0 -13
- package/dist/runtime/recovery/agent.js +0 -199
- package/dist/runtime/recovery/errors.cjs +0 -124
- package/dist/runtime/recovery/errors.d.cts +0 -31
- package/dist/runtime/recovery/errors.d.ts +0 -31
- package/dist/runtime/recovery/errors.js +0 -100
- package/dist/runtime/recovery/index.cjs +0 -34
- package/dist/runtime/recovery/index.d.cts +0 -7
- package/dist/runtime/recovery/index.d.ts +0 -7
- package/dist/runtime/recovery/index.js +0 -10
- package/dist/runtime/recovery/recovery.cjs +0 -55
- package/dist/runtime/recovery/recovery.d.cts +0 -12
- package/dist/runtime/recovery/recovery.d.ts +0 -12
- package/dist/runtime/recovery/recovery.js +0 -31
- package/dist/shared/config/config.cjs +0 -44
- package/dist/shared/config/config.d.cts +0 -10
- package/dist/shared/config/config.d.ts +0 -10
- package/dist/shared/config/config.js +0 -18
- package/dist/shared/config/index.cjs +0 -32
- package/dist/shared/config/index.d.cts +0 -1
- package/dist/shared/config/index.d.ts +0 -1
- package/dist/shared/config/index.js +0 -10
- package/dist/shared/debug/index.cjs +0 -30
- package/dist/shared/debug/index.d.cts +0 -1
- package/dist/shared/debug/index.d.ts +0 -1
- package/dist/shared/debug/index.js +0 -5
- package/dist/shared/debug/pause.cjs +0 -90
- package/dist/shared/debug/pause.d.cts +0 -16
- package/dist/shared/debug/pause.d.ts +0 -16
- package/dist/shared/debug/pause.js +0 -55
- package/dist/shared/instrumentation/errors.cjs +0 -81
- package/dist/shared/instrumentation/errors.d.cts +0 -12
- package/dist/shared/instrumentation/errors.d.ts +0 -12
- package/dist/shared/instrumentation/errors.js +0 -57
- package/dist/shared/instrumentation/index.cjs +0 -35
- package/dist/shared/instrumentation/index.d.cts +0 -6
- package/dist/shared/instrumentation/index.d.ts +0 -6
- package/dist/shared/instrumentation/index.js +0 -12
- package/dist/shared/instrumentation/instrument.cjs +0 -206
- package/dist/shared/instrumentation/instrument.d.cts +0 -32
- package/dist/shared/instrumentation/instrument.d.ts +0 -32
- package/dist/shared/instrumentation/instrument.js +0 -190
- package/dist/shared/llm/ai-sdk-adapter.cjs +0 -67
- package/dist/shared/llm/ai-sdk-adapter.d.cts +0 -22
- package/dist/shared/llm/ai-sdk-adapter.d.ts +0 -22
- package/dist/shared/llm/ai-sdk-adapter.js +0 -43
- package/dist/shared/llm/client.cjs +0 -139
- package/dist/shared/llm/client.d.cts +0 -6
- package/dist/shared/llm/client.d.ts +0 -6
- package/dist/shared/llm/client.js +0 -115
- package/dist/shared/llm/index.cjs +0 -31
- package/dist/shared/llm/index.d.cts +0 -5
- package/dist/shared/llm/index.d.ts +0 -5
- package/dist/shared/llm/index.js +0 -6
- package/dist/shared/llm/types.cjs +0 -16
- package/dist/shared/llm/types.d.cts +0 -66
- package/dist/shared/llm/types.d.ts +0 -66
- package/dist/shared/llm/types.js +0 -0
- package/dist/shared/logger/index.cjs +0 -37
- package/dist/shared/logger/index.d.cts +0 -2
- package/dist/shared/logger/index.d.ts +0 -2
- package/dist/shared/logger/index.js +0 -13
- package/dist/shared/logger/logger.cjs +0 -213
- package/dist/shared/logger/logger.d.cts +0 -82
- package/dist/shared/logger/logger.d.ts +0 -82
- package/dist/shared/logger/logger.js +0 -188
- package/dist/shared/logger/sinks.cjs +0 -160
- package/dist/shared/logger/sinks.d.cts +0 -9
- package/dist/shared/logger/sinks.d.ts +0 -9
- package/dist/shared/logger/sinks.js +0 -124
- package/dist/shared/paths/paths.cjs +0 -104
- package/dist/shared/paths/paths.d.cts +0 -10
- package/dist/shared/paths/paths.d.ts +0 -10
- package/dist/shared/paths/paths.js +0 -73
- package/dist/shared/run/api.cjs +0 -28
- package/dist/shared/run/api.d.cts +0 -2
- package/dist/shared/run/api.d.ts +0 -2
- package/dist/shared/run/api.js +0 -4
- package/dist/shared/run/browser.cjs +0 -98
- package/dist/shared/run/browser.d.cts +0 -22
- package/dist/shared/run/browser.d.ts +0 -22
- package/dist/shared/run/browser.js +0 -74
- package/dist/shared/state/index.cjs +0 -38
- package/dist/shared/state/index.d.cts +0 -2
- package/dist/shared/state/index.d.ts +0 -2
- package/dist/shared/state/index.js +0 -16
- package/dist/shared/state/session-state.cjs +0 -85
- package/dist/shared/state/session-state.d.cts +0 -34
- package/dist/shared/state/session-state.d.ts +0 -34
- package/dist/shared/state/session-state.js +0 -56
- package/dist/shared/visualization/ghost-cursor.cjs +0 -174
- package/dist/shared/visualization/ghost-cursor.d.cts +0 -37
- package/dist/shared/visualization/ghost-cursor.d.ts +0 -37
- package/dist/shared/visualization/ghost-cursor.js +0 -145
- package/dist/shared/visualization/highlight.cjs +0 -134
- package/dist/shared/visualization/highlight.d.cts +0 -22
- package/dist/shared/visualization/highlight.d.ts +0 -22
- package/dist/shared/visualization/highlight.js +0 -108
- package/dist/shared/visualization/index.cjs +0 -45
- package/dist/shared/visualization/index.d.cts +0 -3
- package/dist/shared/visualization/index.d.ts +0 -3
- package/dist/shared/visualization/index.js +0 -24
- package/dist/shared/workflow/workflow.cjs +0 -47
- package/dist/shared/workflow/workflow.d.cts +0 -21
- package/dist/shared/workflow/workflow.d.ts +0 -21
- package/dist/shared/workflow/workflow.js +0 -21
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var client_exports = {};
|
|
20
|
-
__export(client_exports, {
|
|
21
|
-
createLLMClient: () => createLLMClient
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(client_exports);
|
|
24
|
-
var import_google_vertex = require("@ai-sdk/google-vertex");
|
|
25
|
-
var import_anthropic = require("@ai-sdk/anthropic");
|
|
26
|
-
var import_openai = require("@ai-sdk/openai");
|
|
27
|
-
var import_ai = require("ai");
|
|
28
|
-
function parseModel(model) {
|
|
29
|
-
const slashIndex = model.indexOf("/");
|
|
30
|
-
if (slashIndex === -1) {
|
|
31
|
-
throw new Error(
|
|
32
|
-
`Invalid model string "${model}". Expected format: "provider/model-id" (e.g. "google/gemini-3-flash-preview").`
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
const provider = model.slice(0, slashIndex);
|
|
36
|
-
const modelId = model.slice(slashIndex + 1);
|
|
37
|
-
if (!["google", "anthropic", "openai"].includes(provider)) {
|
|
38
|
-
throw new Error(
|
|
39
|
-
`Unsupported provider "${provider}". Supported providers: google, anthropic, openai.`
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
return { provider, modelId };
|
|
43
|
-
}
|
|
44
|
-
function getProviderModel(provider, modelId) {
|
|
45
|
-
switch (provider) {
|
|
46
|
-
case "google": {
|
|
47
|
-
const project = process.env.GOOGLE_CLOUD_PROJECT || process.env.GCLOUD_PROJECT;
|
|
48
|
-
if (!project) {
|
|
49
|
-
throw new Error(
|
|
50
|
-
"Missing GCP project for Vertex AI. Set GOOGLE_CLOUD_PROJECT environment variable and ensure application default credentials are configured (gcloud auth application-default login)."
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
const vertex = (0, import_google_vertex.createVertex)({
|
|
54
|
-
project,
|
|
55
|
-
location: process.env.GOOGLE_CLOUD_LOCATION || "global"
|
|
56
|
-
});
|
|
57
|
-
return vertex(modelId);
|
|
58
|
-
}
|
|
59
|
-
case "anthropic": {
|
|
60
|
-
const apiKey = process.env.ANTHROPIC_API_KEY;
|
|
61
|
-
if (!apiKey) {
|
|
62
|
-
throw new Error(
|
|
63
|
-
"Missing API key for Anthropic. Set ANTHROPIC_API_KEY environment variable."
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
const anthropic = (0, import_anthropic.createAnthropic)({ apiKey });
|
|
67
|
-
return anthropic(modelId);
|
|
68
|
-
}
|
|
69
|
-
case "openai": {
|
|
70
|
-
const apiKey = process.env.OPENAI_API_KEY;
|
|
71
|
-
if (!apiKey) {
|
|
72
|
-
throw new Error(
|
|
73
|
-
"Missing API key for OpenAI. Set OPENAI_API_KEY environment variable."
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
const openai = (0, import_openai.createOpenAI)({ apiKey });
|
|
77
|
-
return openai(modelId);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function convertUserContentParts(parts) {
|
|
82
|
-
return parts.map((part) => {
|
|
83
|
-
if (part.type === "text") {
|
|
84
|
-
return { type: "text", text: part.text };
|
|
85
|
-
}
|
|
86
|
-
return { type: "image", image: part.image };
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
function convertAssistantContentParts(parts) {
|
|
90
|
-
return parts.filter((part) => part.type === "text").map((part) => ({ type: "text", text: part.text }));
|
|
91
|
-
}
|
|
92
|
-
function convertMessages(messages) {
|
|
93
|
-
return messages.map((msg) => {
|
|
94
|
-
if (msg.role === "user") {
|
|
95
|
-
if (typeof msg.content === "string") {
|
|
96
|
-
return { role: "user", content: msg.content };
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
role: "user",
|
|
100
|
-
content: convertUserContentParts(msg.content)
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
if (typeof msg.content === "string") {
|
|
104
|
-
return { role: "assistant", content: msg.content };
|
|
105
|
-
}
|
|
106
|
-
return {
|
|
107
|
-
role: "assistant",
|
|
108
|
-
content: convertAssistantContentParts(msg.content)
|
|
109
|
-
};
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
function createLLMClient(model) {
|
|
113
|
-
const { provider, modelId } = parseModel(model);
|
|
114
|
-
const aiModel = getProviderModel(provider, modelId);
|
|
115
|
-
return {
|
|
116
|
-
async generateObject(opts) {
|
|
117
|
-
const result = await (0, import_ai.generateObject)({
|
|
118
|
-
model: aiModel,
|
|
119
|
-
prompt: opts.prompt,
|
|
120
|
-
schema: opts.schema,
|
|
121
|
-
temperature: opts.temperature ?? 0
|
|
122
|
-
});
|
|
123
|
-
return result.object;
|
|
124
|
-
},
|
|
125
|
-
async generateObjectFromMessages(opts) {
|
|
126
|
-
const result = await (0, import_ai.generateObject)({
|
|
127
|
-
model: aiModel,
|
|
128
|
-
messages: convertMessages(opts.messages),
|
|
129
|
-
schema: opts.schema,
|
|
130
|
-
temperature: opts.temperature ?? 0
|
|
131
|
-
});
|
|
132
|
-
return result.object;
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
137
|
-
0 && (module.exports = {
|
|
138
|
-
createLLMClient
|
|
139
|
-
});
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { createVertex } from "@ai-sdk/google-vertex";
|
|
2
|
-
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
3
|
-
import { createOpenAI } from "@ai-sdk/openai";
|
|
4
|
-
import { generateObject } from "ai";
|
|
5
|
-
function parseModel(model) {
|
|
6
|
-
const slashIndex = model.indexOf("/");
|
|
7
|
-
if (slashIndex === -1) {
|
|
8
|
-
throw new Error(
|
|
9
|
-
`Invalid model string "${model}". Expected format: "provider/model-id" (e.g. "google/gemini-3-flash-preview").`
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
const provider = model.slice(0, slashIndex);
|
|
13
|
-
const modelId = model.slice(slashIndex + 1);
|
|
14
|
-
if (!["google", "anthropic", "openai"].includes(provider)) {
|
|
15
|
-
throw new Error(
|
|
16
|
-
`Unsupported provider "${provider}". Supported providers: google, anthropic, openai.`
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
return { provider, modelId };
|
|
20
|
-
}
|
|
21
|
-
function getProviderModel(provider, modelId) {
|
|
22
|
-
switch (provider) {
|
|
23
|
-
case "google": {
|
|
24
|
-
const project = process.env.GOOGLE_CLOUD_PROJECT || process.env.GCLOUD_PROJECT;
|
|
25
|
-
if (!project) {
|
|
26
|
-
throw new Error(
|
|
27
|
-
"Missing GCP project for Vertex AI. Set GOOGLE_CLOUD_PROJECT environment variable and ensure application default credentials are configured (gcloud auth application-default login)."
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
const vertex = createVertex({
|
|
31
|
-
project,
|
|
32
|
-
location: process.env.GOOGLE_CLOUD_LOCATION || "global"
|
|
33
|
-
});
|
|
34
|
-
return vertex(modelId);
|
|
35
|
-
}
|
|
36
|
-
case "anthropic": {
|
|
37
|
-
const apiKey = process.env.ANTHROPIC_API_KEY;
|
|
38
|
-
if (!apiKey) {
|
|
39
|
-
throw new Error(
|
|
40
|
-
"Missing API key for Anthropic. Set ANTHROPIC_API_KEY environment variable."
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
const anthropic = createAnthropic({ apiKey });
|
|
44
|
-
return anthropic(modelId);
|
|
45
|
-
}
|
|
46
|
-
case "openai": {
|
|
47
|
-
const apiKey = process.env.OPENAI_API_KEY;
|
|
48
|
-
if (!apiKey) {
|
|
49
|
-
throw new Error(
|
|
50
|
-
"Missing API key for OpenAI. Set OPENAI_API_KEY environment variable."
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
const openai = createOpenAI({ apiKey });
|
|
54
|
-
return openai(modelId);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function convertUserContentParts(parts) {
|
|
59
|
-
return parts.map((part) => {
|
|
60
|
-
if (part.type === "text") {
|
|
61
|
-
return { type: "text", text: part.text };
|
|
62
|
-
}
|
|
63
|
-
return { type: "image", image: part.image };
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
function convertAssistantContentParts(parts) {
|
|
67
|
-
return parts.filter((part) => part.type === "text").map((part) => ({ type: "text", text: part.text }));
|
|
68
|
-
}
|
|
69
|
-
function convertMessages(messages) {
|
|
70
|
-
return messages.map((msg) => {
|
|
71
|
-
if (msg.role === "user") {
|
|
72
|
-
if (typeof msg.content === "string") {
|
|
73
|
-
return { role: "user", content: msg.content };
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
role: "user",
|
|
77
|
-
content: convertUserContentParts(msg.content)
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
if (typeof msg.content === "string") {
|
|
81
|
-
return { role: "assistant", content: msg.content };
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
role: "assistant",
|
|
85
|
-
content: convertAssistantContentParts(msg.content)
|
|
86
|
-
};
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
function createLLMClient(model) {
|
|
90
|
-
const { provider, modelId } = parseModel(model);
|
|
91
|
-
const aiModel = getProviderModel(provider, modelId);
|
|
92
|
-
return {
|
|
93
|
-
async generateObject(opts) {
|
|
94
|
-
const result = await generateObject({
|
|
95
|
-
model: aiModel,
|
|
96
|
-
prompt: opts.prompt,
|
|
97
|
-
schema: opts.schema,
|
|
98
|
-
temperature: opts.temperature ?? 0
|
|
99
|
-
});
|
|
100
|
-
return result.object;
|
|
101
|
-
},
|
|
102
|
-
async generateObjectFromMessages(opts) {
|
|
103
|
-
const result = await generateObject({
|
|
104
|
-
model: aiModel,
|
|
105
|
-
messages: convertMessages(opts.messages),
|
|
106
|
-
schema: opts.schema,
|
|
107
|
-
temperature: opts.temperature ?? 0
|
|
108
|
-
});
|
|
109
|
-
return result.object;
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
export {
|
|
114
|
-
createLLMClient
|
|
115
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var llm_exports = {};
|
|
20
|
-
__export(llm_exports, {
|
|
21
|
-
createLLMClient: () => import_client.createLLMClient,
|
|
22
|
-
createLLMClientFromModel: () => import_ai_sdk_adapter.createLLMClientFromModel
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(llm_exports);
|
|
25
|
-
var import_client = require("./client.js");
|
|
26
|
-
var import_ai_sdk_adapter = require("./ai-sdk-adapter.js");
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
createLLMClient,
|
|
30
|
-
createLLMClientFromModel
|
|
31
|
-
});
|
package/dist/shared/llm/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var types_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(types_exports);
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import z from 'zod';
|
|
2
|
-
|
|
3
|
-
type MessageContentPart = {
|
|
4
|
-
type: "text";
|
|
5
|
-
text: string;
|
|
6
|
-
} | {
|
|
7
|
-
type: "image";
|
|
8
|
-
image: string;
|
|
9
|
-
};
|
|
10
|
-
type Message = {
|
|
11
|
-
role: "user" | "assistant";
|
|
12
|
-
content: string | MessageContentPart[];
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Pluggable LLM client interface.
|
|
16
|
-
*
|
|
17
|
-
* Users provide their own implementation backed by any LLM provider
|
|
18
|
-
* (OpenAI, Anthropic, etc.). Libretto uses this interface for AI extraction,
|
|
19
|
-
* recovery agents, and error detection.
|
|
20
|
-
*
|
|
21
|
-
* **Error handling:** implementations should throw on failure rather than
|
|
22
|
-
* returning sentinel values (e.g. `null` or `undefined`). Libretto relies
|
|
23
|
-
* on exceptions to trigger retry/recovery logic.
|
|
24
|
-
*
|
|
25
|
-
* A ready-made adapter for the Vercel AI SDK is available via
|
|
26
|
-
* {@link createLLMClientFromModel} in `libretto/llm`.
|
|
27
|
-
*/
|
|
28
|
-
interface LLMClient {
|
|
29
|
-
/**
|
|
30
|
-
* Generate a structured object from a single text prompt.
|
|
31
|
-
*
|
|
32
|
-
* The underlying model **must** support structured / JSON output so that
|
|
33
|
-
* the response can be parsed and validated against the provided Zod schema.
|
|
34
|
-
*
|
|
35
|
-
* @param opts.prompt - The text prompt sent to the model.
|
|
36
|
-
* @param opts.schema - A Zod schema describing the expected response shape.
|
|
37
|
-
* @param opts.temperature - Sampling temperature (default chosen by implementation, typically 0).
|
|
38
|
-
* @returns The parsed object matching the schema.
|
|
39
|
-
* @throws On LLM or parsing failure.
|
|
40
|
-
*/
|
|
41
|
-
generateObject<T extends z.ZodType>(opts: {
|
|
42
|
-
prompt: string;
|
|
43
|
-
schema: T;
|
|
44
|
-
temperature?: number;
|
|
45
|
-
}): Promise<z.infer<T>>;
|
|
46
|
-
/**
|
|
47
|
-
* Generate a structured object from a conversation-style message array.
|
|
48
|
-
*
|
|
49
|
-
* Messages may contain **image content** (base64 data URIs via
|
|
50
|
-
* {@link MessageContentPart}), so the backing model must support
|
|
51
|
-
* vision / multimodal input when images are present.
|
|
52
|
-
*
|
|
53
|
-
* @param opts.messages - Ordered list of user/assistant messages, potentially multimodal.
|
|
54
|
-
* @param opts.schema - A Zod schema describing the expected response shape.
|
|
55
|
-
* @param opts.temperature - Sampling temperature (default chosen by implementation, typically 0).
|
|
56
|
-
* @returns The parsed object matching the schema.
|
|
57
|
-
* @throws On LLM or parsing failure.
|
|
58
|
-
*/
|
|
59
|
-
generateObjectFromMessages<T extends z.ZodType>(opts: {
|
|
60
|
-
messages: Message[];
|
|
61
|
-
schema: T;
|
|
62
|
-
temperature?: number;
|
|
63
|
-
}): Promise<z.infer<T>>;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export type { LLMClient, Message, MessageContentPart };
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import z from 'zod';
|
|
2
|
-
|
|
3
|
-
type MessageContentPart = {
|
|
4
|
-
type: "text";
|
|
5
|
-
text: string;
|
|
6
|
-
} | {
|
|
7
|
-
type: "image";
|
|
8
|
-
image: string;
|
|
9
|
-
};
|
|
10
|
-
type Message = {
|
|
11
|
-
role: "user" | "assistant";
|
|
12
|
-
content: string | MessageContentPart[];
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Pluggable LLM client interface.
|
|
16
|
-
*
|
|
17
|
-
* Users provide their own implementation backed by any LLM provider
|
|
18
|
-
* (OpenAI, Anthropic, etc.). Libretto uses this interface for AI extraction,
|
|
19
|
-
* recovery agents, and error detection.
|
|
20
|
-
*
|
|
21
|
-
* **Error handling:** implementations should throw on failure rather than
|
|
22
|
-
* returning sentinel values (e.g. `null` or `undefined`). Libretto relies
|
|
23
|
-
* on exceptions to trigger retry/recovery logic.
|
|
24
|
-
*
|
|
25
|
-
* A ready-made adapter for the Vercel AI SDK is available via
|
|
26
|
-
* {@link createLLMClientFromModel} in `libretto/llm`.
|
|
27
|
-
*/
|
|
28
|
-
interface LLMClient {
|
|
29
|
-
/**
|
|
30
|
-
* Generate a structured object from a single text prompt.
|
|
31
|
-
*
|
|
32
|
-
* The underlying model **must** support structured / JSON output so that
|
|
33
|
-
* the response can be parsed and validated against the provided Zod schema.
|
|
34
|
-
*
|
|
35
|
-
* @param opts.prompt - The text prompt sent to the model.
|
|
36
|
-
* @param opts.schema - A Zod schema describing the expected response shape.
|
|
37
|
-
* @param opts.temperature - Sampling temperature (default chosen by implementation, typically 0).
|
|
38
|
-
* @returns The parsed object matching the schema.
|
|
39
|
-
* @throws On LLM or parsing failure.
|
|
40
|
-
*/
|
|
41
|
-
generateObject<T extends z.ZodType>(opts: {
|
|
42
|
-
prompt: string;
|
|
43
|
-
schema: T;
|
|
44
|
-
temperature?: number;
|
|
45
|
-
}): Promise<z.infer<T>>;
|
|
46
|
-
/**
|
|
47
|
-
* Generate a structured object from a conversation-style message array.
|
|
48
|
-
*
|
|
49
|
-
* Messages may contain **image content** (base64 data URIs via
|
|
50
|
-
* {@link MessageContentPart}), so the backing model must support
|
|
51
|
-
* vision / multimodal input when images are present.
|
|
52
|
-
*
|
|
53
|
-
* @param opts.messages - Ordered list of user/assistant messages, potentially multimodal.
|
|
54
|
-
* @param opts.schema - A Zod schema describing the expected response shape.
|
|
55
|
-
* @param opts.temperature - Sampling temperature (default chosen by implementation, typically 0).
|
|
56
|
-
* @returns The parsed object matching the schema.
|
|
57
|
-
* @throws On LLM or parsing failure.
|
|
58
|
-
*/
|
|
59
|
-
generateObjectFromMessages<T extends z.ZodType>(opts: {
|
|
60
|
-
messages: Message[];
|
|
61
|
-
schema: T;
|
|
62
|
-
temperature?: number;
|
|
63
|
-
}): Promise<z.infer<T>>;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export type { LLMClient, Message, MessageContentPart };
|
package/dist/shared/llm/types.js
DELETED
|
File without changes
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var logger_exports = {};
|
|
20
|
-
__export(logger_exports, {
|
|
21
|
-
Logger: () => import_logger.Logger,
|
|
22
|
-
createFileLogSink: () => import_sinks.createFileLogSink,
|
|
23
|
-
defaultLogger: () => import_logger.defaultLogger,
|
|
24
|
-
jsonlConsoleSink: () => import_sinks.jsonlConsoleSink,
|
|
25
|
-
prettyConsoleSink: () => import_sinks.prettyConsoleSink
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(logger_exports);
|
|
28
|
-
var import_logger = require("./logger.js");
|
|
29
|
-
var import_sinks = require("./sinks.js");
|
|
30
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
-
0 && (module.exports = {
|
|
32
|
-
Logger,
|
|
33
|
-
createFileLogSink,
|
|
34
|
-
defaultLogger,
|
|
35
|
-
jsonlConsoleSink,
|
|
36
|
-
prettyConsoleSink
|
|
37
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Logger, defaultLogger } from "./logger.js";
|
|
2
|
-
import {
|
|
3
|
-
createFileLogSink,
|
|
4
|
-
prettyConsoleSink,
|
|
5
|
-
jsonlConsoleSink
|
|
6
|
-
} from "./sinks.js";
|
|
7
|
-
export {
|
|
8
|
-
Logger,
|
|
9
|
-
createFileLogSink,
|
|
10
|
-
defaultLogger,
|
|
11
|
-
jsonlConsoleSink,
|
|
12
|
-
prettyConsoleSink
|
|
13
|
-
};
|