libretto 0.5.3-experimental.2 → 0.5.3-experimental.4

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.
@@ -73,7 +73,7 @@ const deployInput = SimpleCLI.input({
73
73
  (value) => value?.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0) ?? []
74
74
  ),
75
75
  {
76
- help: "Comma-separated packages to externalize and install at runtime"
76
+ help: "Comma-separated packages to keep out of the bundle and install into the deployed package"
77
77
  }
78
78
  )
79
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libretto",
3
- "version": "0.5.3-experimental.2",
3
+ "version": "0.5.3-experimental.4",
4
4
  "description": "AI-powered browser automation library and CLI built on Playwright",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -113,7 +113,8 @@ export const deployInput = SimpleCLI.input({
113
113
  .filter((entry) => entry.length > 0) ?? [],
114
114
  ),
115
115
  {
116
- help: "Comma-separated packages to externalize and install at runtime",
116
+ help:
117
+ "Comma-separated packages to keep out of the bundle and install into the deployed package",
117
118
  },
118
119
  ),
119
120
  },
@@ -127,6 +128,9 @@ export const deployCommand = SimpleCLI.command({
127
128
  .handle(async ({ input }) => {
128
129
  const { apiUrl, apiKey } = getConfig();
129
130
 
131
+ // Hosted deploy uploads a generated artifact with a deploy entrypoint and
132
+ // a minimal manifest. Bundled code is embedded in the generated files;
133
+ // external packages are listed in the manifest for installation.
130
134
  console.log("Bundling hosted deployment artifact...");
131
135
  const { entryPoint, source } = await buildHostedDeployTarball({
132
136
  additionalExternals: input.external,
@@ -441,6 +441,9 @@ function workspaceSourcePlugin(
441
441
  callback: (args: { path: string }) => { path: string } | null,
442
442
  ) => void;
443
443
  }) {
444
+ // Workspace imports are treated as bundle input, so their code is
445
+ // embedded into the generated implementation file. The deployed package
446
+ // does not depend on the original monorepo layout or workspace:* links.
444
447
  buildApi.onResolve({ filter: /^[^./].*/ }, (args) => {
445
448
  if (externalPackages.has(args.path)) {
446
449
  return null;
@@ -640,6 +643,10 @@ function createBootstrapSource(args: {
640
643
  ? 'export default createWorkflowProxy("default");'
641
644
  : "";
642
645
 
646
+ // The deploy entrypoint is tiny on purpose. Hosted build imports this module
647
+ // to discover workflow exports. The implementation bundle stays embedded in
648
+ // the file, while external packages are resolved from node_modules when the
649
+ // deployed code loads them.
643
650
  return `import { createRequire } from "node:module";
644
651
  import { existsSync, writeFileSync } from "node:fs";
645
652
  import { tmpdir } from "node:os";
@@ -696,6 +703,9 @@ export async function createHostedDeployPackage(
696
703
  mkdirSync(outputDir, { recursive: true });
697
704
 
698
705
  const additionalExternals = [...new Set(args.additionalExternals ?? [])];
706
+ // These packages stay out of the implementation bundle. The generated
707
+ // package.json carries them into deploy-time installation, and the deployed
708
+ // code resolves them from node_modules.
699
709
  const externalPackages = new Set<string>([
700
710
  ...DEFAULT_RUNTIME_EXTERNALS,
701
711
  ...additionalExternals,
@@ -703,6 +713,9 @@ export async function createHostedDeployPackage(
703
713
  const workspacePackages = discoverWorkspacePackages(absSourceDir);
704
714
 
705
715
  try {
716
+ // The implementation bundle is CommonJS so the bootstrap can load it lazily
717
+ // with createRequire() after workflow discovery, while external packages
718
+ // continue to load through normal Node module resolution.
706
719
  const implementationBuild = await build({
707
720
  absWorkingDir: absSourceDir,
708
721
  bundle: true,
@@ -724,6 +737,9 @@ export async function createHostedDeployPackage(
724
737
  throw new Error("Bundler did not produce a deployment implementation file.");
725
738
  }
726
739
 
740
+ // A separate ESM bundle is used only to read the entry module's exported
741
+ // workflow names. Scanning the CommonJS bundle would also see exports from
742
+ // bundled dependencies, which is not the deploy surface.
727
743
  const exportBuild = await build({
728
744
  absWorkingDir: absSourceDir,
729
745
  bundle: true,
@@ -767,6 +783,9 @@ export async function createHostedDeployPackage(
767
783
  );
768
784
  }
769
785
 
786
+ // The generated manifest lists only packages that stay outside the
787
+ // implementation bundle. Hosted deploy installs them into the deployed
788
+ // package, and the deployed code loads them from node_modules.
770
789
  writeDeployManifest({
771
790
  additionalExternals,
772
791
  deploymentName: args.deploymentName,