clawchef 0.1.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.
Files changed (62) hide show
  1. package/README.md +405 -0
  2. package/dist/api.d.ts +14 -0
  3. package/dist/api.js +49 -0
  4. package/dist/assertions.d.ts +2 -0
  5. package/dist/assertions.js +32 -0
  6. package/dist/cli.d.ts +2 -0
  7. package/dist/cli.js +115 -0
  8. package/dist/env.d.ts +1 -0
  9. package/dist/env.js +14 -0
  10. package/dist/errors.d.ts +3 -0
  11. package/dist/errors.js +6 -0
  12. package/dist/index.d.ts +2 -0
  13. package/dist/index.js +18 -0
  14. package/dist/logger.d.ts +7 -0
  15. package/dist/logger.js +17 -0
  16. package/dist/openclaw/command-provider.d.ts +15 -0
  17. package/dist/openclaw/command-provider.js +489 -0
  18. package/dist/openclaw/factory.d.ts +3 -0
  19. package/dist/openclaw/factory.js +13 -0
  20. package/dist/openclaw/mock-provider.d.ts +15 -0
  21. package/dist/openclaw/mock-provider.js +65 -0
  22. package/dist/openclaw/provider.d.ts +20 -0
  23. package/dist/openclaw/provider.js +1 -0
  24. package/dist/openclaw/remote-provider.d.ts +19 -0
  25. package/dist/openclaw/remote-provider.js +158 -0
  26. package/dist/orchestrator.d.ts +4 -0
  27. package/dist/orchestrator.js +243 -0
  28. package/dist/recipe.d.ts +20 -0
  29. package/dist/recipe.js +522 -0
  30. package/dist/schema.d.ts +626 -0
  31. package/dist/schema.js +143 -0
  32. package/dist/template.d.ts +2 -0
  33. package/dist/template.js +30 -0
  34. package/dist/types.d.ts +136 -0
  35. package/dist/types.js +1 -0
  36. package/package.json +41 -0
  37. package/recipes/content-from-sample.yaml +20 -0
  38. package/recipes/openclaw-from-zero.yaml +45 -0
  39. package/recipes/openclaw-local.yaml +65 -0
  40. package/recipes/openclaw-remote-http.yaml +38 -0
  41. package/recipes/openclaw-telegram-mock.yaml +22 -0
  42. package/recipes/openclaw-telegram.yaml +19 -0
  43. package/recipes/sample.yaml +49 -0
  44. package/recipes/snippets/readme-template.md +3 -0
  45. package/src/api.ts +65 -0
  46. package/src/assertions.ts +37 -0
  47. package/src/cli.ts +123 -0
  48. package/src/env.ts +16 -0
  49. package/src/errors.ts +6 -0
  50. package/src/index.ts +20 -0
  51. package/src/logger.ts +17 -0
  52. package/src/openclaw/command-provider.ts +594 -0
  53. package/src/openclaw/factory.ts +16 -0
  54. package/src/openclaw/mock-provider.ts +104 -0
  55. package/src/openclaw/provider.ts +44 -0
  56. package/src/openclaw/remote-provider.ts +264 -0
  57. package/src/orchestrator.ts +271 -0
  58. package/src/recipe.ts +621 -0
  59. package/src/schema.ts +157 -0
  60. package/src/template.ts +41 -0
  61. package/src/types.ts +150 -0
  62. package/tsconfig.json +16 -0
package/src/schema.ts ADDED
@@ -0,0 +1,157 @@
1
+ import { z } from "zod";
2
+
3
+ const paramDefSchema = z.object({
4
+ default: z.string().optional(),
5
+ required: z.boolean().optional(),
6
+ description: z.string().optional(),
7
+ });
8
+
9
+ const openClawCommandsSchema = z
10
+ .object({
11
+ use_version: z.string().optional(),
12
+ install_version: z.string().optional(),
13
+ uninstall_version: z.string().optional(),
14
+ factory_reset: z.string().optional(),
15
+ start_gateway: z.string().optional(),
16
+ enable_plugin: z.string().optional(),
17
+ login_channel: z.string().optional(),
18
+ create_workspace: z.string().optional(),
19
+ create_agent: z.string().optional(),
20
+ install_skill: z.string().optional(),
21
+ send_message: z.string().optional(),
22
+ run_agent: z.string().optional(),
23
+ })
24
+ .strict();
25
+
26
+ const openClawBootstrapSchema = z
27
+ .object({
28
+ non_interactive: z.boolean().optional(),
29
+ accept_risk: z.boolean().optional(),
30
+ mode: z.enum(["local", "remote"]).optional(),
31
+ flow: z.enum(["quickstart", "advanced", "manual"]).optional(),
32
+ auth_choice: z.string().optional(),
33
+ workspace: z.string().optional(),
34
+ reset: z.boolean().optional(),
35
+ skip_channels: z.boolean().optional(),
36
+ skip_skills: z.boolean().optional(),
37
+ skip_health: z.boolean().optional(),
38
+ skip_ui: z.boolean().optional(),
39
+ skip_daemon: z.boolean().optional(),
40
+ install_daemon: z.boolean().optional(),
41
+ openai_api_key: z.string().optional(),
42
+ anthropic_api_key: z.string().optional(),
43
+ openrouter_api_key: z.string().optional(),
44
+ xai_api_key: z.string().optional(),
45
+ gemini_api_key: z.string().optional(),
46
+ ai_gateway_api_key: z.string().optional(),
47
+ cloudflare_ai_gateway_api_key: z.string().optional(),
48
+ cloudflare_ai_gateway_account_id: z.string().optional(),
49
+ cloudflare_ai_gateway_gateway_id: z.string().optional(),
50
+ token: z.string().optional(),
51
+ token_provider: z.string().optional(),
52
+ token_profile_id: z.string().optional(),
53
+ })
54
+ .strict();
55
+
56
+ const openClawSchema = z
57
+ .object({
58
+ bin: z.string().optional(),
59
+ version: z.string(),
60
+ install: z.enum(["auto", "always", "never"]).optional(),
61
+ bootstrap: openClawBootstrapSchema.optional(),
62
+ commands: openClawCommandsSchema.optional(),
63
+ })
64
+ .strict();
65
+
66
+ const workspaceSchema = z
67
+ .object({
68
+ name: z.string().min(1),
69
+ path: z.string().min(1).optional(),
70
+ })
71
+ .strict();
72
+
73
+ const channelSchema = z
74
+ .object({
75
+ channel: z.string().min(1),
76
+ account: z.string().min(1).optional(),
77
+ login: z.boolean().optional(),
78
+ login_mode: z.enum(["interactive"]).optional(),
79
+ login_account: z.string().min(1).optional(),
80
+ name: z.string().min(1).optional(),
81
+ token: z.string().min(1).optional(),
82
+ token_file: z.string().min(1).optional(),
83
+ use_env: z.boolean().optional(),
84
+ bot_token: z.string().min(1).optional(),
85
+ access_token: z.string().min(1).optional(),
86
+ app_token: z.string().min(1).optional(),
87
+ webhook_url: z.string().min(1).optional(),
88
+ webhook_path: z.string().min(1).optional(),
89
+ signal_number: z.string().min(1).optional(),
90
+ password: z.string().min(1).optional(),
91
+ extra_flags: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional(),
92
+ })
93
+ .strict();
94
+
95
+ const agentSchema = z
96
+ .object({
97
+ workspace: z.string().min(1),
98
+ name: z.string().min(1),
99
+ model: z.string().optional(),
100
+ skills: z.array(z.string().min(1)).optional(),
101
+ })
102
+ .strict();
103
+
104
+ const fileSchema = z
105
+ .object({
106
+ workspace: z.string().min(1),
107
+ path: z.string().min(1),
108
+ content: z.string().optional(),
109
+ content_from: z.string().min(1).optional(),
110
+ source: z.string().optional(),
111
+ overwrite: z.boolean().optional(),
112
+ })
113
+ .strict()
114
+ .refine((v) => [v.content, v.content_from, v.source].filter((item) => item !== undefined).length === 1, {
115
+ message: "files[] requires exactly one of content, content_from, or source",
116
+ });
117
+
118
+ const conversationExpectSchema = z
119
+ .object({
120
+ contains: z.array(z.string()).optional(),
121
+ not_contains: z.array(z.string()).optional(),
122
+ regex: z.array(z.string()).optional(),
123
+ equals: z.string().optional(),
124
+ })
125
+ .strict();
126
+
127
+ const messageSchema = z
128
+ .object({
129
+ content: z.string(),
130
+ expect: conversationExpectSchema.optional(),
131
+ })
132
+ .strict();
133
+
134
+ const conversationSchema = z
135
+ .object({
136
+ workspace: z.string().min(1),
137
+ agent: z.string().min(1),
138
+ messages: z.array(messageSchema).min(1),
139
+ run: z.boolean().optional(),
140
+ })
141
+ .strict();
142
+
143
+ export const recipeSchema = z
144
+ .object({
145
+ version: z.string().min(1),
146
+ name: z.string().min(1),
147
+ params: z.record(z.string(), paramDefSchema).optional(),
148
+ openclaw: openClawSchema,
149
+ workspaces: z.array(workspaceSchema).optional(),
150
+ channels: z.array(channelSchema).optional(),
151
+ agents: z.array(agentSchema).optional(),
152
+ files: z.array(fileSchema).optional(),
153
+ conversations: z.array(conversationSchema).optional(),
154
+ })
155
+ .strict();
156
+
157
+ export type RecipeSchema = z.infer<typeof recipeSchema>;
@@ -0,0 +1,41 @@
1
+ import { ClawChefError } from "./errors.js";
2
+
3
+ const TOKEN_RE = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
4
+
5
+ export function resolveTemplate(
6
+ value: string,
7
+ vars: Record<string, string>,
8
+ allowMissing: boolean,
9
+ ): string {
10
+ return value.replace(TOKEN_RE, (_, key: string) => {
11
+ if (Object.prototype.hasOwnProperty.call(vars, key)) {
12
+ return vars[key];
13
+ }
14
+ if (allowMissing) {
15
+ return `\${${key}}`;
16
+ }
17
+ throw new ClawChefError(`Missing parameter: ${key}`);
18
+ });
19
+ }
20
+
21
+ export function deepResolveTemplates<T>(
22
+ input: T,
23
+ vars: Record<string, string>,
24
+ allowMissing: boolean,
25
+ ): T {
26
+ if (typeof input === "string") {
27
+ return resolveTemplate(input, vars, allowMissing) as T;
28
+ }
29
+ if (Array.isArray(input)) {
30
+ return input.map((v) => deepResolveTemplates(v, vars, allowMissing)) as T;
31
+ }
32
+ if (input && typeof input === "object") {
33
+ const obj = input as Record<string, unknown>;
34
+ const out: Record<string, unknown> = {};
35
+ for (const [key, value] of Object.entries(obj)) {
36
+ out[key] = deepResolveTemplates(value, vars, allowMissing);
37
+ }
38
+ return out as T;
39
+ }
40
+ return input;
41
+ }
package/src/types.ts ADDED
@@ -0,0 +1,150 @@
1
+ export type InstallPolicy = "auto" | "always" | "never";
2
+ export type OpenClawProvider = "command" | "mock" | "remote";
3
+
4
+ export interface OpenClawRemoteConfig {
5
+ base_url: string;
6
+ api_key?: string;
7
+ api_header?: string;
8
+ api_scheme?: string;
9
+ timeout_ms?: number;
10
+ operation_path?: string;
11
+ }
12
+
13
+ export interface ParamDef {
14
+ default?: string;
15
+ required?: boolean;
16
+ description?: string;
17
+ }
18
+
19
+ export interface OpenClawCommandOverrides {
20
+ use_version?: string;
21
+ install_version?: string;
22
+ uninstall_version?: string;
23
+ factory_reset?: string;
24
+ start_gateway?: string;
25
+ enable_plugin?: string;
26
+ login_channel?: string;
27
+ create_workspace?: string;
28
+ create_agent?: string;
29
+ install_skill?: string;
30
+ send_message?: string;
31
+ run_agent?: string;
32
+ }
33
+
34
+ export interface OpenClawBootstrap {
35
+ non_interactive?: boolean;
36
+ accept_risk?: boolean;
37
+ mode?: "local" | "remote";
38
+ flow?: "quickstart" | "advanced" | "manual";
39
+ auth_choice?: string;
40
+ workspace?: string;
41
+ reset?: boolean;
42
+ skip_channels?: boolean;
43
+ skip_skills?: boolean;
44
+ skip_health?: boolean;
45
+ skip_ui?: boolean;
46
+ skip_daemon?: boolean;
47
+ install_daemon?: boolean;
48
+ openai_api_key?: string;
49
+ anthropic_api_key?: string;
50
+ openrouter_api_key?: string;
51
+ xai_api_key?: string;
52
+ gemini_api_key?: string;
53
+ ai_gateway_api_key?: string;
54
+ cloudflare_ai_gateway_api_key?: string;
55
+ cloudflare_ai_gateway_account_id?: string;
56
+ cloudflare_ai_gateway_gateway_id?: string;
57
+ token?: string;
58
+ token_provider?: string;
59
+ token_profile_id?: string;
60
+ }
61
+
62
+ export interface OpenClawSection {
63
+ bin?: string;
64
+ version: string;
65
+ install?: InstallPolicy;
66
+ bootstrap?: OpenClawBootstrap;
67
+ commands?: OpenClawCommandOverrides;
68
+ }
69
+
70
+ export interface WorkspaceDef {
71
+ name: string;
72
+ path?: string;
73
+ }
74
+
75
+ export interface ChannelDef {
76
+ channel: string;
77
+ account?: string;
78
+ login?: boolean;
79
+ login_mode?: "interactive";
80
+ login_account?: string;
81
+ name?: string;
82
+ token?: string;
83
+ token_file?: string;
84
+ use_env?: boolean;
85
+ bot_token?: string;
86
+ access_token?: string;
87
+ app_token?: string;
88
+ webhook_url?: string;
89
+ webhook_path?: string;
90
+ signal_number?: string;
91
+ password?: string;
92
+ extra_flags?: Record<string, string | number | boolean>;
93
+ }
94
+
95
+ export interface AgentDef {
96
+ workspace: string;
97
+ name: string;
98
+ model?: string;
99
+ skills?: string[];
100
+ }
101
+
102
+ export interface FileDef {
103
+ workspace: string;
104
+ path: string;
105
+ content?: string;
106
+ content_from?: string;
107
+ source?: string;
108
+ overwrite?: boolean;
109
+ }
110
+
111
+ export interface MessageDef {
112
+ content: string;
113
+ expect?: ConversationExpectDef;
114
+ }
115
+
116
+ export interface ConversationExpectDef {
117
+ contains?: string[];
118
+ not_contains?: string[];
119
+ regex?: string[];
120
+ equals?: string;
121
+ }
122
+
123
+ export interface ConversationDef {
124
+ workspace: string;
125
+ agent: string;
126
+ messages: MessageDef[];
127
+ run?: boolean;
128
+ }
129
+
130
+ export interface Recipe {
131
+ version: string;
132
+ name: string;
133
+ params?: Record<string, ParamDef>;
134
+ openclaw: OpenClawSection;
135
+ workspaces?: WorkspaceDef[];
136
+ channels?: ChannelDef[];
137
+ agents?: AgentDef[];
138
+ files?: FileDef[];
139
+ conversations?: ConversationDef[];
140
+ }
141
+
142
+ export interface RunOptions {
143
+ vars: Record<string, string>;
144
+ dryRun: boolean;
145
+ allowMissing: boolean;
146
+ verbose: boolean;
147
+ silent: boolean;
148
+ provider: OpenClawProvider;
149
+ remote: Partial<OpenClawRemoteConfig>;
150
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "strict": true,
7
+ "esModuleInterop": true,
8
+ "forceConsistentCasingInFileNames": true,
9
+ "skipLibCheck": true,
10
+ "declaration": true,
11
+ "outDir": "dist",
12
+ "rootDir": "src",
13
+ "resolveJsonModule": true
14
+ },
15
+ "include": ["src/**/*.ts"]
16
+ }