@dexto/core 1.2.5 → 1.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/README.md +47 -13
- package/dist/agent/DextoAgent.cjs +92 -34
- package/dist/agent/DextoAgent.d.ts +3 -3
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +93 -36
- package/dist/agent/schemas.cjs +24 -20
- package/dist/agent/schemas.d.ts +111 -107
- package/dist/agent/schemas.d.ts.map +1 -1
- package/dist/agent/schemas.js +8 -4
- package/dist/agent/types.d.ts +0 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/approval/schemas.cjs +2 -1
- package/dist/approval/schemas.d.ts +21 -20
- package/dist/approval/schemas.d.ts.map +1 -1
- package/dist/approval/schemas.js +2 -1
- package/dist/context/manager.cjs +7 -0
- package/dist/context/manager.d.ts.map +1 -1
- package/dist/context/manager.js +7 -0
- package/dist/context/types.d.ts +6 -2
- package/dist/context/types.d.ts.map +1 -1
- package/dist/errors/types.cjs +1 -0
- package/dist/errors/types.d.ts +4 -2
- package/dist/errors/types.d.ts.map +1 -1
- package/dist/errors/types.js +1 -0
- package/dist/events/index.cjs +4 -1
- package/dist/events/index.d.ts +23 -52
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +4 -1
- package/dist/llm/formatters/openai.cjs +8 -1
- package/dist/llm/formatters/openai.d.ts.map +1 -1
- package/dist/llm/formatters/openai.js +8 -1
- package/dist/llm/tokenizer/openai.d.ts +8 -0
- package/dist/llm/tokenizer/openai.d.ts.map +1 -1
- package/dist/logger/v2/schemas.cjs +1 -1
- package/dist/logger/v2/schemas.js +1 -1
- package/dist/memory/index.cjs +2 -0
- package/dist/memory/index.d.ts +1 -1
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +3 -1
- package/dist/memory/schemas.cjs +10 -0
- package/dist/memory/schemas.d.ts +33 -4
- package/dist/memory/schemas.d.ts.map +1 -1
- package/dist/memory/schemas.js +9 -0
- package/dist/plugins/error-codes.cjs +1 -0
- package/dist/plugins/error-codes.d.ts +3 -1
- package/dist/plugins/error-codes.d.ts.map +1 -1
- package/dist/plugins/error-codes.js +1 -0
- package/dist/plugins/loader.cjs +25 -5
- package/dist/plugins/loader.d.ts.map +1 -1
- package/dist/plugins/loader.js +25 -5
- package/dist/prompts/index.cjs +6 -8
- package/dist/prompts/index.d.ts +2 -4
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +4 -6
- package/dist/prompts/prompt-manager.cjs +2 -4
- package/dist/prompts/prompt-manager.d.ts.map +1 -1
- package/dist/prompts/prompt-manager.js +2 -4
- package/dist/prompts/providers/config-prompt-provider.cjs +331 -0
- package/dist/prompts/providers/config-prompt-provider.d.ts +34 -0
- package/dist/prompts/providers/config-prompt-provider.d.ts.map +1 -0
- package/dist/prompts/providers/config-prompt-provider.js +308 -0
- package/dist/prompts/providers/custom-prompt-provider.cjs +2 -2
- package/dist/prompts/providers/custom-prompt-provider.d.ts +1 -1
- package/dist/prompts/providers/custom-prompt-provider.d.ts.map +1 -1
- package/dist/prompts/providers/custom-prompt-provider.js +2 -2
- package/dist/prompts/schemas.cjs +42 -23
- package/dist/prompts/schemas.d.ts +121 -12
- package/dist/prompts/schemas.d.ts.map +1 -1
- package/dist/prompts/schemas.js +39 -22
- package/dist/prompts/types.d.ts +1 -1
- package/dist/prompts/types.d.ts.map +1 -1
- package/dist/storage/cache/factory.cjs +6 -2
- package/dist/storage/cache/factory.d.ts +2 -1
- package/dist/storage/cache/factory.d.ts.map +1 -1
- package/dist/storage/cache/factory.js +6 -2
- package/dist/storage/database/factory.cjs +11 -17
- package/dist/storage/database/factory.d.ts +2 -1
- package/dist/storage/database/factory.d.ts.map +1 -1
- package/dist/storage/database/factory.js +11 -17
- package/dist/storage/database/sqlite-store.cjs +8 -0
- package/dist/storage/database/sqlite-store.d.ts.map +1 -1
- package/dist/storage/database/sqlite-store.js +8 -0
- package/dist/storage/error-codes.cjs +1 -0
- package/dist/storage/error-codes.d.ts +1 -0
- package/dist/storage/error-codes.d.ts.map +1 -1
- package/dist/storage/error-codes.js +1 -0
- package/dist/storage/errors.cjs +17 -0
- package/dist/storage/errors.d.ts +9 -0
- package/dist/storage/errors.d.ts.map +1 -1
- package/dist/storage/errors.js +17 -0
- package/dist/systemPrompt/in-built-prompts.cjs +0 -5
- package/dist/systemPrompt/in-built-prompts.d.ts +1 -2
- package/dist/systemPrompt/in-built-prompts.d.ts.map +1 -1
- package/dist/systemPrompt/in-built-prompts.js +0 -4
- package/dist/systemPrompt/manager.cjs +24 -19
- package/dist/systemPrompt/manager.d.ts +2 -2
- package/dist/systemPrompt/manager.d.ts.map +1 -1
- package/dist/systemPrompt/manager.js +24 -19
- package/dist/systemPrompt/registry.cjs +1 -2
- package/dist/systemPrompt/registry.d.ts +1 -1
- package/dist/systemPrompt/registry.d.ts.map +1 -1
- package/dist/systemPrompt/registry.js +1 -2
- package/dist/systemPrompt/schemas.cjs +3 -17
- package/dist/systemPrompt/schemas.d.ts +13 -189
- package/dist/systemPrompt/schemas.d.ts.map +1 -1
- package/dist/systemPrompt/schemas.js +3 -17
- package/dist/telemetry/error-codes.cjs +36 -0
- package/dist/telemetry/error-codes.d.ts +13 -0
- package/dist/telemetry/error-codes.d.ts.map +1 -0
- package/dist/telemetry/error-codes.js +13 -0
- package/dist/telemetry/errors.cjs +105 -0
- package/dist/telemetry/errors.d.ts +28 -0
- package/dist/telemetry/errors.d.ts.map +1 -0
- package/dist/telemetry/errors.js +82 -0
- package/dist/telemetry/telemetry.cjs +92 -26
- package/dist/telemetry/telemetry.d.ts +1 -1
- package/dist/telemetry/telemetry.d.ts.map +1 -1
- package/dist/telemetry/telemetry.js +74 -18
- package/dist/tools/schemas.cjs +1 -1
- package/dist/tools/schemas.js +1 -1
- package/dist/tools/types.d.ts +0 -11
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/utils/schema.d.ts +6 -0
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/service-initializer.cjs +1 -0
- package/dist/utils/service-initializer.d.ts.map +1 -1
- package/dist/utils/service-initializer.js +1 -0
- package/package.json +52 -14
- package/dist/prompts/providers/file-prompt-provider.cjs +0 -401
- package/dist/prompts/providers/file-prompt-provider.d.ts +0 -49
- package/dist/prompts/providers/file-prompt-provider.d.ts.map +0 -1
- package/dist/prompts/providers/file-prompt-provider.js +0 -378
- package/dist/prompts/providers/starter-prompt-provider.cjs +0 -172
- package/dist/prompts/providers/starter-prompt-provider.d.ts +0 -47
- package/dist/prompts/providers/starter-prompt-provider.d.ts.map +0 -1
- package/dist/prompts/providers/starter-prompt-provider.js +0 -149
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-prompt-provider.d.ts","sourceRoot":"","sources":["../../../src/prompts/providers/custom-prompt-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACjB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAuB7D,MAAM,WAAW,uBAAuB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,cAAc,EAAE,CAAC;IAC7B,QAAQ,CAAC,EAAE;QACP,
|
|
1
|
+
{"version":3,"file":"custom-prompt-provider.d.ts","sourceRoot":"","sources":["../../../src/prompts/providers/custom-prompt-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACjB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAuB7D,MAAM,WAAW,uBAAuB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,cAAc,EAAE,CAAC;IAC7B,QAAQ,CAAC,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACL;AAED,qBAAa,oBAAqB,YAAW,cAAc;IAOnD,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,eAAe;IAP3B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,aAAa,CAA8C;IACnE,OAAO,CAAC,MAAM,CAAe;gBAGjB,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe,EACxC,MAAM,EAAE,YAAY;IAKxB,SAAS,IAAI,MAAM;IAInB,eAAe,IAAI,IAAI;IAMjB,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAQxD,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IAiEjF,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAcnE,YAAY,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,UAAU,CAAC;IAsEjE,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAuBjC,UAAU;IAkDxB,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,OAAO;IAUf,OAAO,CAAC,cAAc;CA4CzB"}
|
|
@@ -112,8 +112,8 @@ class CustomPromptProvider {
|
|
|
112
112
|
if (input.resource) {
|
|
113
113
|
try {
|
|
114
114
|
const blobService = this.resourceManager.getBlobStore();
|
|
115
|
-
const {
|
|
116
|
-
const blobRef = await blobService.store(
|
|
115
|
+
const { data, mimeType, filename } = input.resource;
|
|
116
|
+
const blobRef = await blobService.store(data, {
|
|
117
117
|
mimeType,
|
|
118
118
|
originalName: filename,
|
|
119
119
|
source: "system"
|
package/dist/prompts/schemas.cjs
CHANGED
|
@@ -18,37 +18,56 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var schemas_exports = {};
|
|
20
20
|
__export(schemas_exports, {
|
|
21
|
-
|
|
21
|
+
FilePromptSchema: () => FilePromptSchema,
|
|
22
|
+
InlinePromptSchema: () => InlinePromptSchema,
|
|
23
|
+
PromptsSchema: () => PromptsSchema
|
|
22
24
|
});
|
|
23
25
|
module.exports = __toCommonJS(schemas_exports);
|
|
24
26
|
var import_zod = require("zod");
|
|
25
27
|
var import_name_validation = require("./name-validation.js");
|
|
26
|
-
const
|
|
27
|
-
import_zod.z.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
).
|
|
28
|
+
const InlinePromptSchema = import_zod.z.object({
|
|
29
|
+
type: import_zod.z.literal("inline").describe("Inline prompt type"),
|
|
30
|
+
id: import_zod.z.string().min(1).max(64).regex(import_name_validation.PROMPT_NAME_REGEX, `Prompt id must be ${import_name_validation.PROMPT_NAME_GUIDANCE}`).describe("Kebab-case slug id for the prompt (e.g., quick-start)"),
|
|
31
|
+
title: import_zod.z.string().optional().describe("Display title for the prompt"),
|
|
32
|
+
description: import_zod.z.string().optional().default("").describe("Description shown on hover or in the UI"),
|
|
33
|
+
prompt: import_zod.z.string().describe("The actual prompt text"),
|
|
34
|
+
category: import_zod.z.string().optional().default("general").describe("Category for organizing prompts (e.g., general, coding, analysis, tools)"),
|
|
35
|
+
priority: import_zod.z.number().optional().default(0).describe("Higher numbers appear first in the list"),
|
|
36
|
+
showInStarters: import_zod.z.boolean().optional().default(false).describe("Show as a clickable button in WebUI starter prompts")
|
|
37
|
+
}).strict().describe("Inline prompt with text defined directly in config");
|
|
38
|
+
const FilePromptSchema = import_zod.z.object({
|
|
39
|
+
type: import_zod.z.literal("file").describe("File-based prompt type"),
|
|
40
|
+
file: import_zod.z.string().describe(
|
|
41
|
+
"Path to markdown file containing prompt (supports ${{dexto.agent_dir}} template)"
|
|
42
|
+
),
|
|
43
|
+
showInStarters: import_zod.z.boolean().optional().default(false).describe("Show as a clickable button in WebUI starter prompts")
|
|
44
|
+
}).strict().describe("File-based prompt loaded from a markdown file");
|
|
45
|
+
const PromptsSchema = import_zod.z.array(import_zod.z.discriminatedUnion("type", [InlinePromptSchema, FilePromptSchema])).superRefine((arr, ctx) => {
|
|
38
46
|
const seen = /* @__PURE__ */ new Map();
|
|
39
47
|
arr.forEach((p, idx) => {
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
if (p.type === "inline") {
|
|
49
|
+
if (seen.has(p.id)) {
|
|
50
|
+
ctx.addIssue({
|
|
51
|
+
code: import_zod.z.ZodIssueCode.custom,
|
|
52
|
+
message: `Duplicate prompt id: ${p.id}`,
|
|
53
|
+
path: [idx, "id"]
|
|
54
|
+
});
|
|
55
|
+
} else {
|
|
56
|
+
seen.set(p.id, idx);
|
|
57
|
+
}
|
|
48
58
|
}
|
|
49
59
|
});
|
|
50
|
-
}).transform(
|
|
60
|
+
}).transform(
|
|
61
|
+
(arr) => arr.map((p) => {
|
|
62
|
+
if (p.type === "inline") {
|
|
63
|
+
return { ...p, title: p.title ?? p.id.replace(/-/g, " ") };
|
|
64
|
+
}
|
|
65
|
+
return p;
|
|
66
|
+
})
|
|
67
|
+
).default([]).describe("Agent prompts - inline text or file-based");
|
|
51
68
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
69
|
0 && (module.exports = {
|
|
53
|
-
|
|
70
|
+
FilePromptSchema,
|
|
71
|
+
InlinePromptSchema,
|
|
72
|
+
PromptsSchema
|
|
54
73
|
});
|
|
@@ -1,65 +1,174 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Zod schemas for prompt-related configurations
|
|
3
|
+
*
|
|
4
|
+
* Unified prompt system with discriminated union:
|
|
5
|
+
* - type: 'inline' - Prompt text defined directly in config
|
|
6
|
+
* - type: 'file' - Prompt loaded from a markdown file
|
|
7
|
+
*
|
|
8
|
+
* Both support showInStarters flag to control WebUI button display.
|
|
3
9
|
*/
|
|
4
10
|
import { z } from 'zod';
|
|
5
11
|
/**
|
|
6
|
-
* Schema for
|
|
7
|
-
*
|
|
8
|
-
* Starter prompts appear as clickable buttons in the WebUI, providing users
|
|
9
|
-
* with quick-start templates for common tasks and interactions.
|
|
12
|
+
* Schema for inline prompts - text defined directly in config
|
|
10
13
|
*/
|
|
11
|
-
export declare const
|
|
14
|
+
export declare const InlinePromptSchema: z.ZodObject<{
|
|
15
|
+
type: z.ZodLiteral<"inline">;
|
|
12
16
|
id: z.ZodString;
|
|
13
17
|
title: z.ZodOptional<z.ZodString>;
|
|
14
18
|
description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
15
19
|
prompt: z.ZodString;
|
|
16
20
|
category: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
17
21
|
priority: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
22
|
+
showInStarters: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
18
23
|
}, "strict", z.ZodTypeAny, {
|
|
19
24
|
prompt: string;
|
|
20
25
|
description: string;
|
|
26
|
+
type: "inline";
|
|
21
27
|
id: string;
|
|
22
28
|
priority: number;
|
|
23
29
|
category: string;
|
|
30
|
+
showInStarters: boolean;
|
|
24
31
|
title?: string | undefined;
|
|
25
32
|
}, {
|
|
26
33
|
prompt: string;
|
|
34
|
+
type: "inline";
|
|
27
35
|
id: string;
|
|
28
36
|
description?: string | undefined;
|
|
29
37
|
title?: string | undefined;
|
|
30
38
|
priority?: number | undefined;
|
|
31
39
|
category?: string | undefined;
|
|
32
|
-
|
|
40
|
+
showInStarters?: boolean | undefined;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Schema for file-based prompts - loaded from markdown files
|
|
44
|
+
*/
|
|
45
|
+
export declare const FilePromptSchema: z.ZodObject<{
|
|
46
|
+
type: z.ZodLiteral<"file">;
|
|
47
|
+
file: z.ZodString;
|
|
48
|
+
showInStarters: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
49
|
+
}, "strict", z.ZodTypeAny, {
|
|
50
|
+
file: string;
|
|
51
|
+
type: "file";
|
|
52
|
+
showInStarters: boolean;
|
|
53
|
+
}, {
|
|
54
|
+
file: string;
|
|
55
|
+
type: "file";
|
|
56
|
+
showInStarters?: boolean | undefined;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Unified prompts schema - array of inline or file-based prompts
|
|
60
|
+
* Replaces the old StarterPromptsSchema
|
|
61
|
+
*/
|
|
62
|
+
export declare const PromptsSchema: z.ZodDefault<z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
63
|
+
type: z.ZodLiteral<"inline">;
|
|
64
|
+
id: z.ZodString;
|
|
65
|
+
title: z.ZodOptional<z.ZodString>;
|
|
66
|
+
description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
67
|
+
prompt: z.ZodString;
|
|
68
|
+
category: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
69
|
+
priority: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
70
|
+
showInStarters: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
71
|
+
}, "strict", z.ZodTypeAny, {
|
|
33
72
|
prompt: string;
|
|
34
73
|
description: string;
|
|
74
|
+
type: "inline";
|
|
35
75
|
id: string;
|
|
36
76
|
priority: number;
|
|
37
77
|
category: string;
|
|
78
|
+
showInStarters: boolean;
|
|
38
79
|
title?: string | undefined;
|
|
39
|
-
}
|
|
80
|
+
}, {
|
|
40
81
|
prompt: string;
|
|
82
|
+
type: "inline";
|
|
41
83
|
id: string;
|
|
42
84
|
description?: string | undefined;
|
|
43
85
|
title?: string | undefined;
|
|
44
86
|
priority?: number | undefined;
|
|
45
87
|
category?: string | undefined;
|
|
46
|
-
|
|
88
|
+
showInStarters?: boolean | undefined;
|
|
89
|
+
}>, z.ZodObject<{
|
|
90
|
+
type: z.ZodLiteral<"file">;
|
|
91
|
+
file: z.ZodString;
|
|
92
|
+
showInStarters: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
93
|
+
}, "strict", z.ZodTypeAny, {
|
|
94
|
+
file: string;
|
|
95
|
+
type: "file";
|
|
96
|
+
showInStarters: boolean;
|
|
97
|
+
}, {
|
|
98
|
+
file: string;
|
|
99
|
+
type: "file";
|
|
100
|
+
showInStarters?: boolean | undefined;
|
|
101
|
+
}>]>, "many">, ({
|
|
102
|
+
prompt: string;
|
|
103
|
+
description: string;
|
|
104
|
+
type: "inline";
|
|
105
|
+
id: string;
|
|
106
|
+
priority: number;
|
|
107
|
+
category: string;
|
|
108
|
+
showInStarters: boolean;
|
|
109
|
+
title?: string | undefined;
|
|
110
|
+
} | {
|
|
111
|
+
file: string;
|
|
112
|
+
type: "file";
|
|
113
|
+
showInStarters: boolean;
|
|
114
|
+
})[], ({
|
|
115
|
+
prompt: string;
|
|
116
|
+
type: "inline";
|
|
117
|
+
id: string;
|
|
118
|
+
description?: string | undefined;
|
|
119
|
+
title?: string | undefined;
|
|
120
|
+
priority?: number | undefined;
|
|
121
|
+
category?: string | undefined;
|
|
122
|
+
showInStarters?: boolean | undefined;
|
|
123
|
+
} | {
|
|
124
|
+
file: string;
|
|
125
|
+
type: "file";
|
|
126
|
+
showInStarters?: boolean | undefined;
|
|
127
|
+
})[]>, ({
|
|
128
|
+
file: string;
|
|
129
|
+
type: "file";
|
|
130
|
+
showInStarters: boolean;
|
|
131
|
+
} | {
|
|
47
132
|
title: string;
|
|
48
133
|
prompt: string;
|
|
49
134
|
description: string;
|
|
135
|
+
type: "inline";
|
|
50
136
|
id: string;
|
|
51
137
|
priority: number;
|
|
52
138
|
category: string;
|
|
53
|
-
|
|
139
|
+
showInStarters: boolean;
|
|
140
|
+
})[], ({
|
|
54
141
|
prompt: string;
|
|
142
|
+
type: "inline";
|
|
55
143
|
id: string;
|
|
56
144
|
description?: string | undefined;
|
|
57
145
|
title?: string | undefined;
|
|
58
146
|
priority?: number | undefined;
|
|
59
147
|
category?: string | undefined;
|
|
60
|
-
|
|
148
|
+
showInStarters?: boolean | undefined;
|
|
149
|
+
} | {
|
|
150
|
+
file: string;
|
|
151
|
+
type: "file";
|
|
152
|
+
showInStarters?: boolean | undefined;
|
|
153
|
+
})[]>>;
|
|
154
|
+
/**
|
|
155
|
+
* Type for a single inline prompt (validated)
|
|
156
|
+
*/
|
|
157
|
+
export type ValidatedInlinePrompt = z.output<typeof InlinePromptSchema>;
|
|
158
|
+
/**
|
|
159
|
+
* Type for a single file-based prompt (validated)
|
|
160
|
+
*/
|
|
161
|
+
export type ValidatedFilePrompt = z.output<typeof FilePromptSchema>;
|
|
162
|
+
/**
|
|
163
|
+
* Type for a single prompt (either inline or file)
|
|
164
|
+
*/
|
|
165
|
+
export type ValidatedPrompt = ValidatedInlinePrompt | ValidatedFilePrompt;
|
|
166
|
+
/**
|
|
167
|
+
* Validated prompts configuration type
|
|
168
|
+
*/
|
|
169
|
+
export type ValidatedPromptsConfig = z.output<typeof PromptsSchema>;
|
|
61
170
|
/**
|
|
62
|
-
*
|
|
171
|
+
* Input type for prompts configuration (before validation)
|
|
63
172
|
*/
|
|
64
|
-
export type
|
|
173
|
+
export type PromptsConfig = z.input<typeof PromptsSchema>;
|
|
65
174
|
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/prompts/schemas.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/prompts/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCoC,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;EAeiC,CAAC;AAE/D;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA6BgC,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,qBAAqB,GAAG,mBAAmB,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
|
package/dist/prompts/schemas.js
CHANGED
|
@@ -1,31 +1,48 @@
|
|
|
1
1
|
import "../chunk-C6A6W6XS.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { PROMPT_NAME_REGEX, PROMPT_NAME_GUIDANCE } from "./name-validation.js";
|
|
4
|
-
const
|
|
5
|
-
z.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
).
|
|
4
|
+
const InlinePromptSchema = z.object({
|
|
5
|
+
type: z.literal("inline").describe("Inline prompt type"),
|
|
6
|
+
id: z.string().min(1).max(64).regex(PROMPT_NAME_REGEX, `Prompt id must be ${PROMPT_NAME_GUIDANCE}`).describe("Kebab-case slug id for the prompt (e.g., quick-start)"),
|
|
7
|
+
title: z.string().optional().describe("Display title for the prompt"),
|
|
8
|
+
description: z.string().optional().default("").describe("Description shown on hover or in the UI"),
|
|
9
|
+
prompt: z.string().describe("The actual prompt text"),
|
|
10
|
+
category: z.string().optional().default("general").describe("Category for organizing prompts (e.g., general, coding, analysis, tools)"),
|
|
11
|
+
priority: z.number().optional().default(0).describe("Higher numbers appear first in the list"),
|
|
12
|
+
showInStarters: z.boolean().optional().default(false).describe("Show as a clickable button in WebUI starter prompts")
|
|
13
|
+
}).strict().describe("Inline prompt with text defined directly in config");
|
|
14
|
+
const FilePromptSchema = z.object({
|
|
15
|
+
type: z.literal("file").describe("File-based prompt type"),
|
|
16
|
+
file: z.string().describe(
|
|
17
|
+
"Path to markdown file containing prompt (supports ${{dexto.agent_dir}} template)"
|
|
18
|
+
),
|
|
19
|
+
showInStarters: z.boolean().optional().default(false).describe("Show as a clickable button in WebUI starter prompts")
|
|
20
|
+
}).strict().describe("File-based prompt loaded from a markdown file");
|
|
21
|
+
const PromptsSchema = z.array(z.discriminatedUnion("type", [InlinePromptSchema, FilePromptSchema])).superRefine((arr, ctx) => {
|
|
16
22
|
const seen = /* @__PURE__ */ new Map();
|
|
17
23
|
arr.forEach((p, idx) => {
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
if (p.type === "inline") {
|
|
25
|
+
if (seen.has(p.id)) {
|
|
26
|
+
ctx.addIssue({
|
|
27
|
+
code: z.ZodIssueCode.custom,
|
|
28
|
+
message: `Duplicate prompt id: ${p.id}`,
|
|
29
|
+
path: [idx, "id"]
|
|
30
|
+
});
|
|
31
|
+
} else {
|
|
32
|
+
seen.set(p.id, idx);
|
|
33
|
+
}
|
|
26
34
|
}
|
|
27
35
|
});
|
|
28
|
-
}).transform(
|
|
36
|
+
}).transform(
|
|
37
|
+
(arr) => arr.map((p) => {
|
|
38
|
+
if (p.type === "inline") {
|
|
39
|
+
return { ...p, title: p.title ?? p.id.replace(/-/g, " ") };
|
|
40
|
+
}
|
|
41
|
+
return p;
|
|
42
|
+
})
|
|
43
|
+
).default([]).describe("Agent prompts - inline text or file-based");
|
|
29
44
|
export {
|
|
30
|
-
|
|
45
|
+
FilePromptSchema,
|
|
46
|
+
InlinePromptSchema,
|
|
47
|
+
PromptsSchema
|
|
31
48
|
};
|
package/dist/prompts/types.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export interface PromptDefinition {
|
|
|
22
22
|
* Enhanced prompt info with MCP-compliant structure
|
|
23
23
|
*/
|
|
24
24
|
export interface PromptInfo extends PromptDefinition {
|
|
25
|
-
source: 'mcp' | '
|
|
25
|
+
source: 'mcp' | 'config' | 'custom';
|
|
26
26
|
metadata?: Record<string, unknown>;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/prompts/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE1E;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,SAAS,CAAC,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,UAAW,SAAQ,gBAAgB;IAChD,MAAM,EAAE,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/prompts/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE1E;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,SAAS,CAAC,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,UAAW,SAAQ,gBAAgB;IAChD,MAAM,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B;;OAEG;IACH,SAAS,IAAI,MAAM,CAAC;IAEpB;;OAEG;IACH,eAAe,IAAI,IAAI,CAAC;IAExB;;OAEG;IACH,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAExD;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAElF;;OAEG;IACH,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;CACvE"}
|
|
@@ -32,6 +32,7 @@ __export(factory_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(factory_exports);
|
|
34
34
|
var import_memory_cache_store = require("./memory-cache-store.js");
|
|
35
|
+
var import_errors = require("../errors.js");
|
|
35
36
|
let RedisStore = null;
|
|
36
37
|
async function createCache(config, logger) {
|
|
37
38
|
switch (config.type) {
|
|
@@ -52,8 +53,11 @@ async function createRedisStore(config, logger) {
|
|
|
52
53
|
logger.info(`Connecting to Redis at ${config.host}:${config.port}`);
|
|
53
54
|
return new RedisStore(config, logger);
|
|
54
55
|
} catch (error) {
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
const err = error;
|
|
57
|
+
if (err.code === "ERR_MODULE_NOT_FOUND") {
|
|
58
|
+
throw import_errors.StorageError.dependencyNotInstalled("Redis", "ioredis", "npm install ioredis");
|
|
59
|
+
}
|
|
60
|
+
throw error;
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
63
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -3,7 +3,8 @@ import type { CacheConfig } from '../schemas.js';
|
|
|
3
3
|
import type { IDextoLogger } from '../../logger/v2/types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Create a cache store based on configuration.
|
|
6
|
-
* Handles lazy loading of optional dependencies
|
|
6
|
+
* Handles lazy loading of optional dependencies.
|
|
7
|
+
* Throws StorageError.dependencyNotInstalled if required package is missing.
|
|
7
8
|
* @param config Cache configuration
|
|
8
9
|
* @param logger Logger instance for logging
|
|
9
10
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/storage/cache/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAoB,WAAW,EAAE,MAAM,eAAe,CAAC;AAEnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/storage/cache/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAoB,WAAW,EAAE,MAAM,eAAe,CAAC;AAEnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAW7D;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,CAU3F"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "../../chunk-C6A6W6XS.js";
|
|
2
2
|
import { MemoryCacheStore } from "./memory-cache-store.js";
|
|
3
|
+
import { StorageError } from "../errors.js";
|
|
3
4
|
let RedisStore = null;
|
|
4
5
|
async function createCache(config, logger) {
|
|
5
6
|
switch (config.type) {
|
|
@@ -20,8 +21,11 @@ async function createRedisStore(config, logger) {
|
|
|
20
21
|
logger.info(`Connecting to Redis at ${config.host}:${config.port}`);
|
|
21
22
|
return new RedisStore(config, logger);
|
|
22
23
|
} catch (error) {
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
const err = error;
|
|
25
|
+
if (err.code === "ERR_MODULE_NOT_FOUND") {
|
|
26
|
+
throw StorageError.dependencyNotInstalled("Redis", "ioredis", "npm install ioredis");
|
|
27
|
+
}
|
|
28
|
+
throw error;
|
|
25
29
|
}
|
|
26
30
|
}
|
|
27
31
|
export {
|
|
@@ -32,6 +32,7 @@ __export(factory_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(factory_exports);
|
|
34
34
|
var import_memory_database_store = require("./memory-database-store.js");
|
|
35
|
+
var import_errors = require("../errors.js");
|
|
35
36
|
let SQLiteStore = null;
|
|
36
37
|
let PostgresStore = null;
|
|
37
38
|
async function createDatabase(config, logger) {
|
|
@@ -55,27 +56,20 @@ async function createPostgresStore(config, logger) {
|
|
|
55
56
|
logger.info("Connecting to PostgreSQL database");
|
|
56
57
|
return new PostgresStore(config, logger);
|
|
57
58
|
} catch (error) {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
const err = error;
|
|
60
|
+
if (err.code === "ERR_MODULE_NOT_FOUND") {
|
|
61
|
+
throw import_errors.StorageError.dependencyNotInstalled("PostgreSQL", "pg", "npm install pg");
|
|
62
|
+
}
|
|
63
|
+
throw error;
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
async function createSQLiteStore(config, logger) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
SQLiteStore = module2.SQLiteStore;
|
|
70
|
-
}
|
|
71
|
-
logger.info(`Creating SQLite database store: ${config.path}`);
|
|
72
|
-
return new SQLiteStore(config, logger);
|
|
73
|
-
} catch (error) {
|
|
74
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
75
|
-
logger.error(`SQLite store failed to load: ${err.message}`, { error: err.message });
|
|
76
|
-
logger.warn("Falling back to in-memory database store");
|
|
77
|
-
return new import_memory_database_store.MemoryDatabaseStore();
|
|
67
|
+
if (!SQLiteStore) {
|
|
68
|
+
const module2 = await import("./sqlite-store.js");
|
|
69
|
+
SQLiteStore = module2.SQLiteStore;
|
|
78
70
|
}
|
|
71
|
+
logger.info(`Creating SQLite database store: ${config.path}`);
|
|
72
|
+
return new SQLiteStore(config, logger);
|
|
79
73
|
}
|
|
80
74
|
// Annotate the CommonJS export names for ESM import in node:
|
|
81
75
|
0 && (module.exports = {
|
|
@@ -3,7 +3,8 @@ import type { DatabaseConfig } from '../schemas.js';
|
|
|
3
3
|
import type { IDextoLogger } from '../../logger/v2/types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Create a database store based on configuration.
|
|
6
|
-
* Handles lazy loading of optional dependencies
|
|
6
|
+
* Handles lazy loading of optional dependencies.
|
|
7
|
+
* Throws StorageError.dependencyNotInstalled if required package is missing.
|
|
7
8
|
* Database paths are provided via CLI enrichment layer.
|
|
8
9
|
* @param config Database configuration with explicit paths
|
|
9
10
|
* @param logger Logger instance for logging
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/storage/database/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAgD,MAAM,eAAe,CAAC;AAElG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/storage/database/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAgD,MAAM,eAAe,CAAC;AAElG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAgB7D;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAChC,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,YAAY,GACrB,OAAO,CAAC,QAAQ,CAAC,CAanB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "../../chunk-C6A6W6XS.js";
|
|
2
2
|
import { MemoryDatabaseStore } from "./memory-database-store.js";
|
|
3
|
+
import { StorageError } from "../errors.js";
|
|
3
4
|
let SQLiteStore = null;
|
|
4
5
|
let PostgresStore = null;
|
|
5
6
|
async function createDatabase(config, logger) {
|
|
@@ -23,27 +24,20 @@ async function createPostgresStore(config, logger) {
|
|
|
23
24
|
logger.info("Connecting to PostgreSQL database");
|
|
24
25
|
return new PostgresStore(config, logger);
|
|
25
26
|
} catch (error) {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const err = error;
|
|
28
|
+
if (err.code === "ERR_MODULE_NOT_FOUND") {
|
|
29
|
+
throw StorageError.dependencyNotInstalled("PostgreSQL", "pg", "npm install pg");
|
|
30
|
+
}
|
|
31
|
+
throw error;
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
async function createSQLiteStore(config, logger) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
SQLiteStore = module.SQLiteStore;
|
|
38
|
-
}
|
|
39
|
-
logger.info(`Creating SQLite database store: ${config.path}`);
|
|
40
|
-
return new SQLiteStore(config, logger);
|
|
41
|
-
} catch (error) {
|
|
42
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
43
|
-
logger.error(`SQLite store failed to load: ${err.message}`, { error: err.message });
|
|
44
|
-
logger.warn("Falling back to in-memory database store");
|
|
45
|
-
return new MemoryDatabaseStore();
|
|
35
|
+
if (!SQLiteStore) {
|
|
36
|
+
const module = await import("./sqlite-store.js");
|
|
37
|
+
SQLiteStore = module.SQLiteStore;
|
|
46
38
|
}
|
|
39
|
+
logger.info(`Creating SQLite database store: ${config.path}`);
|
|
40
|
+
return new SQLiteStore(config, logger);
|
|
47
41
|
}
|
|
48
42
|
export {
|
|
49
43
|
createDatabase
|
|
@@ -91,6 +91,14 @@ class SQLiteStore {
|
|
|
91
91
|
const module2 = await import("better-sqlite3");
|
|
92
92
|
BetterSqlite3Database = module2.default || module2;
|
|
93
93
|
} catch (error) {
|
|
94
|
+
const err = error;
|
|
95
|
+
if (err.code === "ERR_MODULE_NOT_FOUND") {
|
|
96
|
+
throw import_errors.StorageError.dependencyNotInstalled(
|
|
97
|
+
"SQLite",
|
|
98
|
+
"better-sqlite3",
|
|
99
|
+
"npm install better-sqlite3"
|
|
100
|
+
);
|
|
101
|
+
}
|
|
94
102
|
throw import_errors.StorageError.connectionFailed(
|
|
95
103
|
`Failed to import better-sqlite3: ${error instanceof Error ? error.message : String(error)}`
|
|
96
104
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-store.d.ts","sourceRoot":"","sources":["../../../src/storage/database/sqlite-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAMzD;;;GAGG;AACH,qBAAa,WAAY,YAAW,QAAQ;IACxC,OAAO,CAAC,EAAE,CAAoB;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,MAAM,CAAe;gBAEjB,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,YAAY;IAO9D,OAAO,CAAC,gBAAgB;IA8ClB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"sqlite-store.d.ts","sourceRoot":"","sources":["../../../src/storage/database/sqlite-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAMzD;;;GAGG;AACH,qBAAa,WAAY,YAAW,QAAQ;IACxC,OAAO,CAAC,EAAE,CAAoB;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,MAAM,CAAe;gBAEjB,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,YAAY;IAO9D,OAAO,CAAC,gBAAgB;IA8ClB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA0ExB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAOjC,WAAW,IAAI,OAAO;IAItB,YAAY,IAAI,MAAM;IAKhB,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAgB3C,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB5C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAelC,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IA0BvC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB9C,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAqB1E,OAAO,CAAC,eAAe;IAOjB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAKvB,QAAQ,IAAI,OAAO,CAAC;QACtB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;KAClB,CAAC;CAqBL"}
|
|
@@ -59,6 +59,14 @@ class SQLiteStore {
|
|
|
59
59
|
const module = await import("better-sqlite3");
|
|
60
60
|
BetterSqlite3Database = module.default || module;
|
|
61
61
|
} catch (error) {
|
|
62
|
+
const err = error;
|
|
63
|
+
if (err.code === "ERR_MODULE_NOT_FOUND") {
|
|
64
|
+
throw StorageError.dependencyNotInstalled(
|
|
65
|
+
"SQLite",
|
|
66
|
+
"better-sqlite3",
|
|
67
|
+
"npm install better-sqlite3"
|
|
68
|
+
);
|
|
69
|
+
}
|
|
62
70
|
throw StorageError.connectionFailed(
|
|
63
71
|
`Failed to import better-sqlite3: ${error instanceof Error ? error.message : String(error)}`
|
|
64
72
|
);
|
|
@@ -24,6 +24,7 @@ module.exports = __toCommonJS(error_codes_exports);
|
|
|
24
24
|
var StorageErrorCode = /* @__PURE__ */ ((StorageErrorCode2) => {
|
|
25
25
|
StorageErrorCode2["MANAGER_NOT_INITIALIZED"] = "storage_manager_not_initialized";
|
|
26
26
|
StorageErrorCode2["MANAGER_NOT_CONNECTED"] = "storage_manager_not_connected";
|
|
27
|
+
StorageErrorCode2["DEPENDENCY_NOT_INSTALLED"] = "storage_dependency_not_installed";
|
|
27
28
|
StorageErrorCode2["CONNECTION_FAILED"] = "storage_connection_failed";
|
|
28
29
|
StorageErrorCode2["CONNECTION_CONFIG_MISSING"] = "storage_connection_config_missing";
|
|
29
30
|
StorageErrorCode2["READ_FAILED"] = "storage_read_failed";
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
export declare enum StorageErrorCode {
|
|
6
6
|
MANAGER_NOT_INITIALIZED = "storage_manager_not_initialized",
|
|
7
7
|
MANAGER_NOT_CONNECTED = "storage_manager_not_connected",
|
|
8
|
+
DEPENDENCY_NOT_INSTALLED = "storage_dependency_not_installed",
|
|
8
9
|
CONNECTION_FAILED = "storage_connection_failed",
|
|
9
10
|
CONNECTION_CONFIG_MISSING = "storage_connection_config_missing",
|
|
10
11
|
READ_FAILED = "storage_read_failed",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../../src/storage/error-codes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,gBAAgB;IAExB,uBAAuB,oCAAoC;IAC3D,qBAAqB,kCAAkC;IAGvD,iBAAiB,8BAA8B;IAC/C,yBAAyB,sCAAsC;IAG/D,WAAW,wBAAwB;IACnC,YAAY,yBAAyB;IACrC,aAAa,0BAA0B;IAGvC,gBAAgB,6BAA6B;IAC7C,uBAAuB,oCAAoC;IAG3D,mBAAmB,wBAAwB;IAG3C,kBAAkB,uBAAuB;IACzC,wBAAwB,6BAA6B;IACrD,kBAAkB,uBAAuB;IACzC,mBAAmB,wBAAwB;IAG3C,cAAc,mBAAmB;IACjC,sBAAsB,2BAA2B;IACjD,kBAAkB,uBAAuB;IACzC,cAAc,mBAAmB;IAGjC,0BAA0B,+BAA+B;IACzD,wBAAwB,6BAA6B;IAGrD,mBAAmB,wBAAwB;IAC3C,qBAAqB,0BAA0B;CAClD"}
|
|
1
|
+
{"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../../src/storage/error-codes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,gBAAgB;IAExB,uBAAuB,oCAAoC;IAC3D,qBAAqB,kCAAkC;IAGvD,wBAAwB,qCAAqC;IAG7D,iBAAiB,8BAA8B;IAC/C,yBAAyB,sCAAsC;IAG/D,WAAW,wBAAwB;IACnC,YAAY,yBAAyB;IACrC,aAAa,0BAA0B;IAGvC,gBAAgB,6BAA6B;IAC7C,uBAAuB,oCAAoC;IAG3D,mBAAmB,wBAAwB;IAG3C,kBAAkB,uBAAuB;IACzC,wBAAwB,6BAA6B;IACrD,kBAAkB,uBAAuB;IACzC,mBAAmB,wBAAwB;IAG3C,cAAc,mBAAmB;IACjC,sBAAsB,2BAA2B;IACjD,kBAAkB,uBAAuB;IACzC,cAAc,mBAAmB;IAGjC,0BAA0B,+BAA+B;IACzD,wBAAwB,6BAA6B;IAGrD,mBAAmB,wBAAwB;IAC3C,qBAAqB,0BAA0B;CAClD"}
|
|
@@ -2,6 +2,7 @@ import "../chunk-C6A6W6XS.js";
|
|
|
2
2
|
var StorageErrorCode = /* @__PURE__ */ ((StorageErrorCode2) => {
|
|
3
3
|
StorageErrorCode2["MANAGER_NOT_INITIALIZED"] = "storage_manager_not_initialized";
|
|
4
4
|
StorageErrorCode2["MANAGER_NOT_CONNECTED"] = "storage_manager_not_connected";
|
|
5
|
+
StorageErrorCode2["DEPENDENCY_NOT_INSTALLED"] = "storage_dependency_not_installed";
|
|
5
6
|
StorageErrorCode2["CONNECTION_FAILED"] = "storage_connection_failed";
|
|
6
7
|
StorageErrorCode2["CONNECTION_CONFIG_MISSING"] = "storage_connection_config_missing";
|
|
7
8
|
StorageErrorCode2["READ_FAILED"] = "storage_read_failed";
|