@crewhaus/target-cf-worker-workflow 0.1.8 → 0.2.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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CrewhausError } from "@crewhaus/errors";
2
- import type { Bundle, IrWorkflowV0 } from "@crewhaus/ir";
2
+ import { type Bundle, type IrWorkflowV0 } from "@crewhaus/ir";
3
3
  export type EmitOptions = {
4
4
  /**
5
5
  * Origins the generated Worker should accept on `/chat`. Defaults to the
@@ -8,6 +8,8 @@ export type EmitOptions = {
8
8
  * anywhere (pages.dev, ngrok, LAN IP) without editing the emitter.
9
9
  */
10
10
  readonly allowedOrigins?: readonly string[];
11
+ /** Item 42 — emit a generated README.md into the bundle. Default true. */
12
+ readonly readme?: boolean;
11
13
  };
12
14
  /**
13
15
  * Emit a Cloudflare Worker bundle for a WORKFLOW-target IR. Workflow sibling
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { CrewhausError } from "@crewhaus/errors";
2
2
  import { escapeJsonString } from "@crewhaus/infra-utils";
3
+ import { renderBundleReadme } from "@crewhaus/ir";
3
4
  import { parseModelString } from "@crewhaus/model-router";
4
5
  const DEFAULT_ALLOWED_ORIGINS = ["https://studio.crewhaus.ai", "http://localhost:4322"];
5
6
  /**
@@ -40,14 +41,32 @@ export function emitCfWorkerWorkflow(ir, opts = {}) {
40
41
  const allowedOrigins = opts.allowedOrigins && opts.allowedOrigins.length > 0
41
42
  ? [...opts.allowedOrigins]
42
43
  : DEFAULT_ALLOWED_ORIGINS;
43
- return {
44
- files: [
45
- { path: "worker.js", content: renderWorker(ir, allowedOrigins) },
46
- { path: "wrangler.toml", content: renderWrangler(ir) },
47
- { path: "package.json", content: renderPackageJson(ir) },
48
- ],
49
- };
44
+ const files = [
45
+ { path: "worker.js", content: renderWorker(ir, allowedOrigins) },
46
+ { path: "wrangler.toml", content: renderWrangler(ir) },
47
+ { path: "package.json", content: renderPackageJson(ir) },
48
+ ];
49
+ // Item 42 — generated bundle README; default ON. The default per-target
50
+ // run snippet keys on ir.target ("workflow" → `bun agent.ts`), which is
51
+ // wrong for a Worker bundle, so substitute the wrangler flow.
52
+ if (opts.readme !== false) {
53
+ files.push({ path: "README.md", content: renderBundleReadme(ir, CF_WORKER_README_OPTS) });
54
+ }
55
+ return { files };
50
56
  }
57
+ const CF_WORKER_README_OPTS = {
58
+ usage: {
59
+ heading: "Deploy",
60
+ body: [
61
+ "```sh",
62
+ "wrangler secret put ANTHROPIC_API_KEY # one-time Worker secret",
63
+ "wrangler deploy",
64
+ "```",
65
+ ].join("\n"),
66
+ },
67
+ // A deployed Worker has no local `.crewhaus/` workspace.
68
+ includeWorkspaceNote: false,
69
+ };
51
70
  export class TargetEmitError extends CrewhausError {
52
71
  name = "TargetEmitError";
53
72
  constructor(message, cause) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crewhaus/target-cf-worker-workflow",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "Codegen backend for the workflow target emitted as a Cloudflare Worker. Sibling of target-cf-worker-cli; reads the same IrWorkflowV0 variant, emits a self-contained Worker bundle that runs the steps sequentially.",
6
6
  "main": "dist/index.js",
@@ -15,10 +15,10 @@
15
15
  "test": "bun test src"
16
16
  },
17
17
  "dependencies": {
18
- "@crewhaus/errors": "0.1.8",
19
- "@crewhaus/infra-utils": "0.1.8",
20
- "@crewhaus/ir": "0.1.8",
21
- "@crewhaus/model-router": "0.1.8"
18
+ "@crewhaus/errors": "0.2.0",
19
+ "@crewhaus/infra-utils": "0.2.0",
20
+ "@crewhaus/ir": "0.2.0",
21
+ "@crewhaus/model-router": "0.2.0"
22
22
  },
23
23
  "license": "Apache-2.0",
24
24
  "author": {