@vertesia/create-worker 0.81.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 ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2024 Composable
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,243 @@
1
+ # @vertesia/create-worker
2
+
3
+ This package scaffolds a Vertesia custom Temporal worker project.
4
+ Custom workers allow you to deploy your own Temporal workflows and activities to the Vertesia cloud platform.
5
+
6
+ Visit https://vertesiahq.com for more information about Vertesia.
7
+
8
+ ## Requirements
9
+
10
+ 1. Docker (with buildx support) installed locally.
11
+ 2. Vertesia CLI application. The CLI will be automatically installed when initializing the worker project if you didn't install it previously.
12
+
13
+ ## Initialize a Vertesia worker project
14
+
15
+ Run the following command:
16
+
17
+ ```bash
18
+ npm init @vertesia/worker
19
+ ```
20
+
21
+ Follow the instructions on screen. You need to define an organization and a name for your worker. The organization must be unique inside Vertesia and is usually the name of your Vertesia organization account. The worker name identifies the project within your organization.
22
+
23
+ The generated project is a TypeScript project using [Temporal](https://temporal.io/) as the workflow system.
24
+
25
+ ## Project Structure
26
+
27
+ The generated project includes:
28
+
29
+ ```
30
+ ├── src/
31
+ │ ├── activities.ts # Activity implementations (API calls, I/O operations)
32
+ │ ├── workflows.ts # Workflow definitions (orchestration logic)
33
+ │ ├── main.ts # Worker entry point
34
+ │ ├── debug-replayer.ts # Debugging tool for workflow replay
35
+ │ ├── activities.test.ts # Unit tests for activities
36
+ │ └── test/
37
+ │ └── utils.ts # Test utilities
38
+ ├── bin/
39
+ │ └── bundle-workflows.mjs # Workflow bundler script
40
+ ├── vitest.config.ts # Test configuration
41
+ ├── tsconfig.json # TypeScript configuration
42
+ ├── tsconfig.test.json # TypeScript configuration for tests
43
+ ├── Dockerfile # Container build configuration
44
+ └── package.json # Project configuration
45
+ ```
46
+
47
+ ## Development
48
+
49
+ ### Building
50
+
51
+ ```bash
52
+ pnpm install
53
+ pnpm run build
54
+ ```
55
+
56
+ The build process:
57
+
58
+ 1. Compiles TypeScript to JavaScript
59
+ 2. Bundles workflows into a single file (required by Temporal)
60
+
61
+ ### Testing
62
+
63
+ The project uses Vitest with Temporal's `MockActivityEnvironment` for testing activities.
64
+
65
+ ```bash
66
+ pnpm test
67
+ ```
68
+
69
+ Tests are located in `*.test.ts` files alongside the source code.
70
+
71
+ ### Developing workflows and activities
72
+
73
+ **Activities** (`src/activities.ts`):
74
+
75
+ - Activities are functions that perform I/O operations (API calls, file access, etc.)
76
+ - They run outside the Temporal workflow sandbox
77
+ - Use `getVertesiaClient(payload)` to get an authenticated Vertesia client
78
+ - Activities can be retried automatically on failure
79
+
80
+ **Workflows** (`src/workflows.ts`):
81
+
82
+ - Workflows orchestrate activities and define the business logic
83
+ - They must be deterministic (no direct I/O, random, or time operations)
84
+ - Use `proxyActivities` to call activities from workflows
85
+ - Workflows receive `WorkflowExecutionPayload` with `objectIds` and `vars`
86
+
87
+ Export your workflows and activities from these files to make them available to the worker.
88
+
89
+ ## Run with a local Temporal server
90
+
91
+ Running with a local Temporal server is useful for integration testing before deployment.
92
+
93
+ ### 1. Install and start Temporal
94
+
95
+ Install the [Temporal CLI](https://docs.temporal.io/cli), then start the dev server:
96
+
97
+ ```bash
98
+ temporal server start-dev
99
+ ```
100
+
101
+ ### 2. Start the worker
102
+
103
+ In another terminal:
104
+
105
+ ```bash
106
+ pnpm run start
107
+ ```
108
+
109
+ ### 3. Execute a workflow
110
+
111
+ Using the Temporal CLI:
112
+
113
+ ```bash
114
+ temporal workflow start --name exampleWorkflow -t agents/your-org/your-worker --input-file INPUT.json
115
+ ```
116
+
117
+ Where `INPUT.json` contains the workflow parameters:
118
+
119
+ ```json
120
+ {
121
+ "objectIds": ["content-object-id"],
122
+ "event": "workflow_execution_request",
123
+ "auth_token": "your-auth-token",
124
+ "account_id": "your-account-id",
125
+ "project_id": "your-project-id",
126
+ "config": {
127
+ "store_url": "https://zeno-server.api.vertesia.io",
128
+ "studio_url": "https://studio-server.api.vertesia.io"
129
+ },
130
+ "vars": {
131
+ "dryRun": true
132
+ }
133
+ }
134
+ ```
135
+
136
+ ## Debugging workflows
137
+
138
+ You can debug workflows by replaying them locally using the Temporal replayer in `src/debug-replayer.ts`.
139
+
140
+ See https://docs.temporal.io/develop/typescript/debugging for more information.
141
+
142
+ ## Configuration
143
+
144
+ Worker configuration is defined in `package.json` under the `vertesia` section:
145
+
146
+ ```json
147
+ {
148
+ "vertesia": {
149
+ "pm": "pnpm",
150
+ "image": {
151
+ "repository": "us-docker.pkg.dev/dengenlabs/us.gcr.io",
152
+ "organization": "your-org",
153
+ "name": "your-worker"
154
+ }
155
+ }
156
+ }
157
+ ```
158
+
159
+ The worker domain (task queue) is automatically constructed as: `agents/{organization}/{name}`
160
+
161
+ ## Deployment
162
+
163
+ ### Build the Docker image
164
+
165
+ ```bash
166
+ vertesia worker build
167
+ ```
168
+
169
+ This builds a Docker image tagged as `your-organization/your-worker:latest`.
170
+ This image is only for local testing.
171
+
172
+ ### Create a release version
173
+
174
+ ```bash
175
+ vertesia worker release <version>
176
+ ```
177
+
178
+ The version must be in `major.minor.patch[-modifier]` format (e.g., `1.0.0`, `1.0.0-rc1`).
179
+
180
+ This creates a new Docker tag `your-organization/your-worker:version` from the `latest` image.
181
+
182
+ ### Publish to Vertesia
183
+
184
+ ```bash
185
+ vertesia worker publish <version>
186
+ ```
187
+
188
+ This pushes the image to Vertesia and deploys the worker.
189
+
190
+ Options:
191
+
192
+ - `--push-only`: Only push the image without deploying
193
+ - `--deploy-only`: Deploy a previously uploaded version
194
+
195
+ ### View versions
196
+
197
+ ```bash
198
+ vertesia worker versions
199
+ ```
200
+
201
+ ## Running deployed workflows
202
+
203
+ Once deployed, workflows can be triggered via:
204
+
205
+ **SDK:**
206
+
207
+ ```javascript
208
+ const run = await client.workflows.execute("exampleWorkflow", {
209
+ task_queue: "agents/your-org/your-worker",
210
+ objectIds: ["content-object-id"],
211
+ vars: {
212
+ dryRun: false,
213
+ },
214
+ });
215
+ ```
216
+
217
+ **CLI:**
218
+
219
+ ```bash
220
+ vertesia workflows execute exampleWorkflow -o <OBJECT_ID> --queue "agents/your-org/your-worker" -f vars.json
221
+ ```
222
+
223
+ **API:**
224
+
225
+ ```bash
226
+ curl --location 'https://api.vertesia.io/api/v1/workflows/execute/exampleWorkflow' \
227
+ --header 'Authorization: Bearer <YOUR_JWT_TOKEN>' \
228
+ --header 'Content-Type: application/json' \
229
+ --data '{
230
+ "vars": { "dryRun": false },
231
+ "task_queue": "agents/your-org/your-worker",
232
+ "objectIds": ["content-object-id"]
233
+ }'
234
+ ```
235
+
236
+ ## Dependencies
237
+
238
+ Built with:
239
+
240
+ - **Temporal**: Workflow orchestration
241
+ - **Vertesia SDK**: Platform integration
242
+ - **TypeScript**: Type-safe development
243
+ - **Vitest**: Testing framework
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../lib/main.js"
package/lib/main.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @vertesia/create-worker
4
+ *
5
+ * This package has been deprecated in favor of @vertesia/create-plugin.
6
+ * It now acts as a thin wrapper that redirects to create-plugin with the worker template pre-selected.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AAEA;;;;;GAKG"}
package/lib/main.js ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @vertesia/create-worker
4
+ *
5
+ * This package has been deprecated in favor of @vertesia/create-plugin.
6
+ * It now acts as a thin wrapper that redirects to create-plugin with the worker template pre-selected.
7
+ */
8
+ import { spawn } from 'child_process';
9
+ const DEPRECATION_MESSAGE = `
10
+ ┌─────────────────────────────────────────────────────────────────────────────┐
11
+ │ │
12
+ │ ⚠️ @vertesia/create-worker is deprecated │
13
+ │ │
14
+ │ Please use @vertesia/create-plugin instead: │
15
+ │ │
16
+ │ pnpm create @vertesia/plugin my-worker │
17
+ │ npm create @vertesia/plugin my-worker │
18
+ │ │
19
+ │ Then select "Vertesia Workflow Worker" from the template list. │
20
+ │ │
21
+ │ Continuing with legacy behavior for backwards compatibility... │
22
+ │ │
23
+ └─────────────────────────────────────────────────────────────────────────────┘
24
+ `;
25
+ async function main(argv) {
26
+ console.log(DEPRECATION_MESSAGE);
27
+ const projectName = argv[2];
28
+ if (!projectName) {
29
+ console.error('Please specify a project name:');
30
+ console.error(' npx @vertesia/create-worker my-worker');
31
+ process.exit(1);
32
+ }
33
+ // Forward to create-plugin - user will need to select the worker template
34
+ console.log('Launching @vertesia/create-plugin...\n');
35
+ const child = spawn('npx', ['@vertesia/create-plugin', projectName], {
36
+ stdio: 'inherit',
37
+ shell: true
38
+ });
39
+ child.on('close', (code) => {
40
+ process.exit(code || 0);
41
+ });
42
+ child.on('error', (err) => {
43
+ console.error('Failed to launch create-plugin:', err.message);
44
+ console.error('\nPlease install and run create-plugin directly:');
45
+ console.error(` npx @vertesia/create-plugin ${projectName}`);
46
+ process.exit(1);
47
+ });
48
+ }
49
+ main(process.argv).catch(err => {
50
+ console.error("Error: ", err);
51
+ process.exit(1);
52
+ });
53
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,MAAM,mBAAmB,GA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AAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@vertesia/create-worker",
3
+ "version": "0.81.0",
4
+ "description": "Initialize workflow worker package (deprecated - use @vertesia/create-plugin instead)",
5
+ "type": "module",
6
+ "bin": {
7
+ "create-worker": "./bin/create-worker.mjs"
8
+ },
9
+ "main": "./lib/main.js",
10
+ "types": "./lib/main.d.ts",
11
+ "files": [
12
+ "lib",
13
+ "bin"
14
+ ],
15
+ "license": "Apache-2.0",
16
+ "homepage": "https://docs.vertesiahq.com",
17
+ "keywords": [
18
+ "workflow",
19
+ "temporal",
20
+ "agent",
21
+ "llm",
22
+ "composable",
23
+ "deprecated"
24
+ ],
25
+ "dependencies": {},
26
+ "devDependencies": {
27
+ "@types/node": "^22.5.0",
28
+ "typescript": "^5.7.2"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/vertesia/composableai.git",
33
+ "directory": "packages/create-worker"
34
+ },
35
+ "scripts": {
36
+ "eslint": "eslint './src/**/*.{jsx,js,tsx,ts}'",
37
+ "build": "rm -rf ./lib ./tsconfig.tsbuildinfo && tsc --build",
38
+ "clean": "rimraf ./node_modules ./lib ./tsconfig.tsbuildinfo"
39
+ }
40
+ }