libretto 0.6.18 → 0.6.20
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 +10 -13
- package/README.template.md +10 -13
- package/dist/cli/cli.js +2 -16
- package/dist/cli/commands/browser.js +3 -3
- package/dist/cli/commands/deploy.js +5 -0
- package/dist/cli/commands/execution.js +2 -2
- package/dist/cli/commands/update.js +47 -18
- package/dist/cli/core/daemon/daemon.js +2 -0
- package/dist/cli/core/skill-version.js +49 -15
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -0
- package/dist/shared/workflow/workflow.d.ts +6 -1
- package/dist/shared/workflow/workflow.js +13 -10
- package/docs/releasing.md +6 -4
- package/package.json +1 -1
- package/skills/libretto/SKILL.md +36 -35
- package/skills/libretto/references/auth-profiles.md +3 -3
- package/skills/libretto/references/code-generation-rules.md +2 -2
- package/skills/libretto/references/configuration-file-reference.md +10 -10
- package/skills/libretto/references/pages-and-page-targeting.md +3 -3
- package/skills/libretto-readonly/SKILL.md +1 -1
- package/src/cli/cli.ts +2 -19
- package/src/cli/commands/browser.ts +3 -3
- package/src/cli/commands/deploy.ts +5 -0
- package/src/cli/commands/execution.ts +2 -2
- package/src/cli/commands/update.ts +57 -19
- package/src/cli/core/daemon/daemon.ts +2 -0
- package/src/cli/core/skill-version.ts +67 -17
- package/src/index.ts +2 -0
- package/src/shared/workflow/workflow.ts +27 -10
package/src/index.ts
CHANGED
|
@@ -100,11 +100,13 @@ export {
|
|
|
100
100
|
LibrettoWorkflow,
|
|
101
101
|
LibrettoWorkflowInputError,
|
|
102
102
|
LIBRETTO_WORKFLOW_BRAND,
|
|
103
|
+
validateWorkflowInput,
|
|
103
104
|
workflow,
|
|
104
105
|
type ExportedLibrettoWorkflow,
|
|
105
106
|
type LibrettoWorkflowContext,
|
|
106
107
|
type LibrettoWorkflowHandler,
|
|
107
108
|
type LibrettoWorkflowSchemas,
|
|
109
|
+
type WorkflowInputValidator,
|
|
108
110
|
} from "./shared/workflow/workflow.js";
|
|
109
111
|
const isDirectExecution = (): boolean => {
|
|
110
112
|
const entryArg = process.argv[1];
|
|
@@ -49,6 +49,32 @@ function formatZodErrorMessage(
|
|
|
49
49
|
].join("\n");
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
function parseWorkflowInput<InputSchema extends z.ZodType>(
|
|
53
|
+
workflowName: string,
|
|
54
|
+
inputSchema: InputSchema | undefined,
|
|
55
|
+
input: unknown,
|
|
56
|
+
): z.infer<InputSchema> {
|
|
57
|
+
if (!inputSchema) return input as z.infer<InputSchema>;
|
|
58
|
+
|
|
59
|
+
const result = inputSchema.safeParse(input);
|
|
60
|
+
if (!result.success) {
|
|
61
|
+
throw new LibrettoWorkflowInputError(workflowName, result.error);
|
|
62
|
+
}
|
|
63
|
+
return result.data;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type WorkflowInputValidator = {
|
|
67
|
+
readonly name: string;
|
|
68
|
+
readonly inputSchema?: z.ZodType;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export function validateWorkflowInput(
|
|
72
|
+
workflow: WorkflowInputValidator,
|
|
73
|
+
input: unknown,
|
|
74
|
+
): void {
|
|
75
|
+
parseWorkflowInput(workflow.name, workflow.inputSchema, input);
|
|
76
|
+
}
|
|
77
|
+
|
|
52
78
|
export class LibrettoWorkflow<
|
|
53
79
|
InputSchema extends z.ZodType = z.ZodType<unknown>,
|
|
54
80
|
OutputSchema extends z.ZodType = z.ZodType<unknown>,
|
|
@@ -86,16 +112,7 @@ export class LibrettoWorkflow<
|
|
|
86
112
|
ctx: LibrettoWorkflowContext,
|
|
87
113
|
input: unknown,
|
|
88
114
|
): Promise<z.infer<OutputSchema>> {
|
|
89
|
-
|
|
90
|
-
if (this.inputSchema) {
|
|
91
|
-
const result = this.inputSchema.safeParse(input);
|
|
92
|
-
if (!result.success) {
|
|
93
|
-
throw new LibrettoWorkflowInputError(this.name, result.error);
|
|
94
|
-
}
|
|
95
|
-
parsed = result.data;
|
|
96
|
-
} else {
|
|
97
|
-
parsed = input as z.infer<InputSchema>;
|
|
98
|
-
}
|
|
115
|
+
const parsed = parseWorkflowInput(this.name, this.inputSchema, input);
|
|
99
116
|
return this.handler(ctx, parsed);
|
|
100
117
|
}
|
|
101
118
|
}
|