@dual-os/cli 0.12.0 → 0.12.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"archive.d.ts","names":["PluginPackage.PackageError","PluginPackage.Service","PluginValidation.Service"],"sources":["../../src/plugin/archive.ts"],"mappings":";;;;;;;;;YAyBY,kBAAkB,SAAS;qBAC1B,UAAQ,OAAA;;;;;;;;;YAST;WACD,QACP,mBACA,mBACG,OAAO,OAAO,UAAUA;;;qBAElB,gBAAgB;qBAIhB,OAAK,MAAA,MAAA,SAAA,cAAA,eAAA,oBAAA,sBAAA,OAAA,SAAA,WAAA,aAAA,KAAA,OAAAC,YAAAC"}
1
+ {"version":3,"file":"archive.d.ts","names":["PluginPackage.PackageError","PluginPackage.Service","PluginValidation.Service"],"sources":["../../src/plugin/archive.ts"],"mappings":";;;;;;;;;YA2BY,kBAAkB,SAAS;qBAC1B,UAAQ,OAAA;;;;;;;;;YAST;WACD,QACP,mBACA,mBACG,OAAO,OAAO,UAAUA;;;qBAElB,gBAAgB;qBAIhB,OAAK,MAAA,MAAA,SAAA,cAAA,eAAA,oBAAA,sBAAA,OAAA,SAAA,WAAA,aAAA,KAAA,OAAAC,YAAAC"}
@@ -9,6 +9,7 @@ import { Digest } from "effect/crypto";
9
9
  import { Hex } from "effect/encoding";
10
10
  import { ChildProcess, ChildProcessSpawner } from "effect/process";
11
11
  import * as tar from "tar";
12
+ import { PluginRuntime } from "@dual-os/sdk/PluginRuntime";
12
13
  // src/plugin/archive.ts
13
14
  var archive_exports = /* @__PURE__ */ __exportAll({
14
15
  Artifact: () => Artifact,
@@ -72,7 +73,10 @@ const layer = Layer.effect(Service, Effect.gen(function* () {
72
73
  const prepared = yield* packages.inspect(root);
73
74
  const original = yield* validation.validate(root);
74
75
  const compiled = yield* buildBundle(root, prepared);
76
+ const contracts = "dual-contracts.json";
77
+ if (yield* fs.exists(path.join(compiled.output, contracts))) return yield* PackageError.make({ message: `${contracts} is reserved for the bundled plugin contracts` });
75
78
  const declaration = {
79
+ contracts,
76
80
  entrypoint: compiled.entrypoint.replaceAll("\\", "/"),
77
81
  export: prepared.export,
78
82
  format: 2,
@@ -104,6 +108,10 @@ const layer = Layer.effect(Service, Effect.gen(function* () {
104
108
  },
105
109
  packages: compiled.packages
106
110
  });
111
+ const bundled = yield* validation.validate(compiled.output);
112
+ const metadata = yield* Schema.encodeUnknownEffect(Schema.fromJsonString(Schema.Json))(bundled.registry);
113
+ if (Buffer.byteLength(metadata) > PluginRuntime.maxMetadataBytes) return yield* PackageError.make({ message: "Bundled plugin contracts exceed the 64 MiB metadata limit" });
114
+ yield* fs.writeFileString(path.join(compiled.output, contracts), metadata);
107
115
  const names = Array.sort(yield* fs.glob("**/*", { root: compiled.output }), Order.String);
108
116
  const files = MutableList.make();
109
117
  for (const name of names) if ((yield* fs.stat(path.join(compiled.output, name))).type === "File") MutableList.append(files, name);
@@ -144,7 +152,7 @@ const layer = Layer.effect(Service, Effect.gen(function* () {
144
152
  const finalExports = yield* publicExports(isolated, Array.map(compiled.publicJavaScript, (entry) => [entry.source, entry.output]));
145
153
  if (JSON.stringify(originalExports) !== JSON.stringify(finalExports)) return yield* PackageError.make({ message: "The final tarball changed public JavaScript exports; no archive was written" });
146
154
  const encode = Schema.encodeEffect(Schema.fromJsonString(Result$1));
147
- if ((yield* encode(original)) !== (yield* encode(inspected))) return yield* PackageError.make({ message: "The packaged plugin identity or contracts differ from the project inspection; no archive was written" });
155
+ if ((yield* encode(original)) !== (yield* encode(inspected)) || (yield* encode(bundled)) !== (yield* encode(inspected)) || (yield* fs.readFileString(path.join(isolated, contracts))) !== metadata) return yield* PackageError.make({ message: "The packaged plugin identity or contracts differ from the project inspection; no archive was written" });
148
156
  const bytes = yield* fs.readFile(archive);
149
157
  const file = path.resolve(output);
150
158
  yield* fs.makeDirectory(path.dirname(file), { recursive: true });
@@ -1 +1 @@
1
- {"version":3,"file":"archive.js","names":["PluginPackage.Service","PluginValidation.Service","makeBundle","PluginInspection.Result","PluginPackage.PackageError","PluginPackage.fromCause"],"sources":["../../src/plugin/archive.ts"],"sourcesContent":["import type { PlatformError } from \"effect\";\nimport {\n Array,\n Context,\n DateTime,\n Effect,\n FileSystem,\n Layer,\n MutableList,\n Order,\n Path,\n Schema,\n} from \"effect\";\n\nimport { Digest } from \"effect/crypto\";\nimport { Hex } from \"effect/encoding\";\nimport { ChildProcess, ChildProcessSpawner } from \"effect/process\";\nimport * as tar from \"tar\";\n\nimport { make as makeBundle } from \"./bundle.ts\";\nimport { PluginInspection } from \"./inspection.ts\";\nimport { PluginPackage } from \"./package.ts\";\nimport { PluginValidation } from \"./validation.ts\";\n\nconst Manifest = Schema.Struct({ scripts: Schema.Record(Schema.String, Schema.String) });\nexport type Artifact = typeof Artifact.Type;\nexport const Artifact = Schema.Struct({\n activated: Schema.Literal(false),\n digest: Schema.String,\n file: Schema.String,\n plugin: Schema.String,\n published: Schema.Literal(false),\n size: Schema.Finite,\n version: Schema.String,\n});\nexport type Interface = {\n readonly build: (\n directory: string,\n output: string,\n ) => Effect.Effect<Artifact, PluginPackage.PackageError>;\n};\nexport class Service extends Context.Service<Service, Interface>()(\n \"@dual-os/cli/plugin/archive/Service\",\n) {}\n\nexport const layer = Layer.effect(\n Service,\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const crypto = yield* Digest.Digest;\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n const packages = yield* PluginPackage.Service;\n const validation = yield* PluginValidation.Service;\n const buildBundle = yield* makeBundle;\n const executable = (yield* spawner.string(ChildProcess.make(\"which\", [\"bun\"]))).trim();\n return Service.of({\n build: Effect.fn(\"PluginArchive.build\")(\n function* (directory, output) {\n const root = yield* fs.realPath(path.resolve(directory));\n const lockRoot = Effect.fnUntraced(function* (\n current: string,\n ): Effect.fn.Return<string, PlatformError.PlatformError | PluginPackage.PackageError> {\n if (yield* fs.exists(path.join(current, \"bun.lock\"))) return current;\n const parent = path.dirname(current);\n if (parent === current)\n return yield* PluginPackage.PackageError.make({\n message: \"A frozen bun.lock is required to build a plugin\",\n });\n return yield* lockRoot(parent);\n });\n const locked = yield* lockRoot(root);\n const command = Effect.fnUntraced(function* (\n executable: string,\n args: string[],\n cwd: string,\n ) {\n const code = yield* spawner.exitCode(\n ChildProcess.make(executable, args, {\n cwd,\n stdin: \"ignore\",\n stdout: \"ignore\",\n stderr: \"inherit\",\n }),\n );\n if (code !== 0)\n return yield* PluginPackage.PackageError.make({\n message: `Plugin build failed: ${executable} ${Array.join(args, \" \")}`,\n });\n });\n const bun = (yield* spawner.string(ChildProcess.make(\"bun\", [\"--version\"]))).trim();\n if (bun !== \"1.4.2\")\n return yield* PluginPackage.PackageError.make({\n message: \"Plugin builds require Bun 1.4.2\",\n });\n yield* command(\n \"bun\",\n [\"install\", \"--frozen-lockfile\", \"--ignore-scripts\", \"--no-env-file\"],\n locked,\n );\n const manifest = yield* Schema.decodeEffect(Schema.fromJsonString(Manifest))(\n yield* fs.readFileString(path.join(root, \"package.json\")),\n );\n const build = manifest.scripts[\"build\"] ? \"build\" : \"prepack\";\n if (!manifest.scripts[build])\n return yield* PluginPackage.PackageError.make({\n message: \"Declare scripts.build or scripts.prepack before building a plugin\",\n });\n yield* command(\"bun\", [\"run\", \"--no-env-file\", build], root);\n const prepared = yield* packages.inspect(root);\n const original = yield* validation.validate(root);\n const compiled = yield* buildBundle(root, prepared);\n const declaration = {\n entrypoint: compiled.entrypoint.replaceAll(\"\\\\\", \"/\"),\n export: prepared.export,\n format: 2,\n plugin: original.plugin,\n runner: compiled.runner,\n sdk_version: compiled.sdkVersion,\n version: original.version,\n };\n const write = (name: string, value: Schema.Json) =>\n Effect.flatMap(Schema.encodeEffect(Schema.fromJsonString(Schema.Json))(value), text =>\n fs.writeFileString(path.join(compiled.output, name), text),\n );\n yield* write(\"package.json\", {\n ...compiled.manifest,\n dependencies: {},\n devDependencies: {},\n peerDependencies: {},\n optionalDependencies: {},\n scripts: {},\n files: [\"**/*\"],\n dual: { plugin: { ...declaration, assets: compiled.assets } },\n });\n yield* write(\"dual-plugin.json\", declaration);\n yield* write(\"bundle-inventory.json\", {\n format: 1,\n toolchain: {\n bun,\n lockfile_sha512: Hex.encode(\n yield* crypto.digest(\n Digest.sha512,\n yield* fs.readFile(path.join(locked, \"bun.lock\")),\n ),\n ),\n },\n packages: compiled.packages,\n });\n const names = Array.sort(yield* fs.glob(\"**/*\", { root: compiled.output }), Order.String);\n const files = MutableList.make<string>();\n for (const name of names)\n if ((yield* fs.stat(path.join(compiled.output, name))).type === \"File\")\n MutableList.append(files, name);\n const staged = yield* fs.makeTempDirectoryScoped({ prefix: \"dual-plugin-tarball-\" });\n const archive = path.join(staged, \"plugin.tgz\");\n yield* Effect.tryPromise(() =>\n tar.create(\n {\n cwd: compiled.output,\n file: archive,\n gzip: true,\n portable: true,\n mtime: DateTime.toDateUtc(DateTime.makeUnsafe(\"1980-01-01T00:00:00Z\")),\n prefix: \"package\",\n },\n MutableList.toArray(files),\n ),\n );\n const isolated = path.join(staged, \"isolated\");\n yield* fs.makeDirectory(isolated);\n yield* Effect.tryPromise(() =>\n tar.extract({ cwd: isolated, file: archive, strip: 1, strict: true }),\n );\n const inspected = yield* validation.validate(isolated);\n const publicExports = Effect.fnUntraced(function* (\n directory: string,\n entries: (readonly [string, string])[],\n ) {\n const output = yield* spawner.string(\n ChildProcess.make(\n executable,\n [\n \"--no-env-file\",\n \"--no-install\",\n \"--eval\",\n 'import { pathToFileURL } from \"node:url\"; const result = {}; for (const [source,file] of JSON.parse(process.argv[1])) result[source] = Object.keys(await import(pathToFileURL(process.cwd()+\"/\"+file).href)).sort(); console.log(JSON.stringify(result));',\n JSON.stringify(entries),\n ],\n { cwd: directory, env: {}, stdin: \"ignore\" },\n ),\n );\n return yield* Schema.decodeEffect(\n Schema.fromJsonString(Schema.Record(Schema.String, Schema.Array(Schema.String))),\n )(output.trim());\n });\n const originalExports = yield* publicExports(\n root,\n Array.map(compiled.publicJavaScript, entry => [entry.source, entry.source] as const),\n );\n const finalExports = yield* publicExports(\n isolated,\n Array.map(compiled.publicJavaScript, entry => [entry.source, entry.output] as const),\n );\n if (JSON.stringify(originalExports) !== JSON.stringify(finalExports))\n return yield* PluginPackage.PackageError.make({\n message:\n \"The final tarball changed public JavaScript exports; no archive was written\",\n });\n const encode = Schema.encodeEffect(Schema.fromJsonString(PluginInspection.Result));\n if ((yield* encode(original)) !== (yield* encode(inspected)))\n return yield* PluginPackage.PackageError.make({\n message:\n \"The packaged plugin identity or contracts differ from the project inspection; no archive was written\",\n });\n const bytes = yield* fs.readFile(archive);\n const file = path.resolve(output);\n yield* fs.makeDirectory(path.dirname(file), { recursive: true });\n const temporary = yield* fs.makeTempFileScoped({\n directory: path.dirname(file),\n prefix: \".dual-plugin-\",\n });\n yield* fs.writeFile(temporary, bytes);\n yield* fs.rename(temporary, file);\n return {\n activated: false,\n digest: Hex.encode(yield* crypto.digest(Digest.sha512, bytes)),\n file,\n plugin: original.plugin,\n published: false,\n size: bytes.length,\n version: original.version,\n } satisfies Artifact;\n },\n Effect.scoped,\n Effect.mapError(cause =>\n Schema.is(PluginPackage.PackageError)(cause) ? cause : PluginPackage.fromCause(cause),\n ),\n ),\n });\n }),\n);\n\nexport * as PluginArchive from \"./archive.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwBA,MAAM,WAAW,OAAO,OAAO,EAAE,SAAS,OAAO,OAAO,OAAO,QAAQ,OAAO,MAAM,EAAE,CAAC;AAEvF,MAAa,WAAW,OAAO,OAAO;CACpC,WAAW,OAAO,QAAQ,KAAK;CAC/B,QAAQ,OAAO;CACf,MAAM,OAAO;CACb,QAAQ,OAAO;CACf,WAAW,OAAO,QAAQ,KAAK;CAC/B,MAAM,OAAO;CACb,SAAS,OAAO;AAClB,CAAC;AAOD,IAAa,UAAb,cAA6B,QAAQ,QAA4B,CAAC,CAChE,qCACF,CAAC,CAAC,CA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ive.js","names":["PluginPackage.Service","PluginValidation.Service","makeBundle","PluginInspection.Result","PluginPackage.PackageError","PluginPackage.fromCause"],"sources":["../../src/plugin/archive.ts"],"sourcesContent":["import type { PlatformError } from \"effect\";\nimport {\n Array,\n Context,\n DateTime,\n Effect,\n FileSystem,\n Layer,\n MutableList,\n Order,\n Path,\n Schema,\n} from \"effect\";\n\nimport { Digest } from \"effect/crypto\";\nimport { Hex } from \"effect/encoding\";\nimport { ChildProcess, ChildProcessSpawner } from \"effect/process\";\nimport * as tar from \"tar\";\n\nimport { PluginRuntime } from \"@dual-os/sdk/PluginRuntime\";\n\nimport { make as makeBundle } from \"./bundle.ts\";\nimport { PluginInspection } from \"./inspection.ts\";\nimport { PluginPackage } from \"./package.ts\";\nimport { PluginValidation } from \"./validation.ts\";\n\nconst Manifest = Schema.Struct({ scripts: Schema.Record(Schema.String, Schema.String) });\nexport type Artifact = typeof Artifact.Type;\nexport const Artifact = Schema.Struct({\n activated: Schema.Literal(false),\n digest: Schema.String,\n file: Schema.String,\n plugin: Schema.String,\n published: Schema.Literal(false),\n size: Schema.Finite,\n version: Schema.String,\n});\nexport type Interface = {\n readonly build: (\n directory: string,\n output: string,\n ) => Effect.Effect<Artifact, PluginPackage.PackageError>;\n};\nexport class Service extends Context.Service<Service, Interface>()(\n \"@dual-os/cli/plugin/archive/Service\",\n) {}\n\nexport const layer = Layer.effect(\n Service,\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const crypto = yield* Digest.Digest;\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n const packages = yield* PluginPackage.Service;\n const validation = yield* PluginValidation.Service;\n const buildBundle = yield* makeBundle;\n const executable = (yield* spawner.string(ChildProcess.make(\"which\", [\"bun\"]))).trim();\n return Service.of({\n build: Effect.fn(\"PluginArchive.build\")(\n function* (directory, output) {\n const root = yield* fs.realPath(path.resolve(directory));\n const lockRoot = Effect.fnUntraced(function* (\n current: string,\n ): Effect.fn.Return<string, PlatformError.PlatformError | PluginPackage.PackageError> {\n if (yield* fs.exists(path.join(current, \"bun.lock\"))) return current;\n const parent = path.dirname(current);\n if (parent === current)\n return yield* PluginPackage.PackageError.make({\n message: \"A frozen bun.lock is required to build a plugin\",\n });\n return yield* lockRoot(parent);\n });\n const locked = yield* lockRoot(root);\n const command = Effect.fnUntraced(function* (\n executable: string,\n args: string[],\n cwd: string,\n ) {\n const code = yield* spawner.exitCode(\n ChildProcess.make(executable, args, {\n cwd,\n stdin: \"ignore\",\n stdout: \"ignore\",\n stderr: \"inherit\",\n }),\n );\n if (code !== 0)\n return yield* PluginPackage.PackageError.make({\n message: `Plugin build failed: ${executable} ${Array.join(args, \" \")}`,\n });\n });\n const bun = (yield* spawner.string(ChildProcess.make(\"bun\", [\"--version\"]))).trim();\n if (bun !== \"1.4.2\")\n return yield* PluginPackage.PackageError.make({\n message: \"Plugin builds require Bun 1.4.2\",\n });\n yield* command(\n \"bun\",\n [\"install\", \"--frozen-lockfile\", \"--ignore-scripts\", \"--no-env-file\"],\n locked,\n );\n const manifest = yield* Schema.decodeEffect(Schema.fromJsonString(Manifest))(\n yield* fs.readFileString(path.join(root, \"package.json\")),\n );\n const build = manifest.scripts[\"build\"] ? \"build\" : \"prepack\";\n if (!manifest.scripts[build])\n return yield* PluginPackage.PackageError.make({\n message: \"Declare scripts.build or scripts.prepack before building a plugin\",\n });\n yield* command(\"bun\", [\"run\", \"--no-env-file\", build], root);\n const prepared = yield* packages.inspect(root);\n const original = yield* validation.validate(root);\n const compiled = yield* buildBundle(root, prepared);\n const contracts = \"dual-contracts.json\";\n if (yield* fs.exists(path.join(compiled.output, contracts)))\n return yield* PluginPackage.PackageError.make({\n message: `${contracts} is reserved for the bundled plugin contracts`,\n });\n const declaration = {\n contracts,\n entrypoint: compiled.entrypoint.replaceAll(\"\\\\\", \"/\"),\n export: prepared.export,\n format: 2,\n plugin: original.plugin,\n runner: compiled.runner,\n sdk_version: compiled.sdkVersion,\n version: original.version,\n };\n const write = (name: string, value: Schema.Json) =>\n Effect.flatMap(Schema.encodeEffect(Schema.fromJsonString(Schema.Json))(value), text =>\n fs.writeFileString(path.join(compiled.output, name), text),\n );\n yield* write(\"package.json\", {\n ...compiled.manifest,\n dependencies: {},\n devDependencies: {},\n peerDependencies: {},\n optionalDependencies: {},\n scripts: {},\n files: [\"**/*\"],\n dual: { plugin: { ...declaration, assets: compiled.assets } },\n });\n yield* write(\"dual-plugin.json\", declaration);\n yield* write(\"bundle-inventory.json\", {\n format: 1,\n toolchain: {\n bun,\n lockfile_sha512: Hex.encode(\n yield* crypto.digest(\n Digest.sha512,\n yield* fs.readFile(path.join(locked, \"bun.lock\")),\n ),\n ),\n },\n packages: compiled.packages,\n });\n const bundled = yield* validation.validate(compiled.output);\n const metadata = yield* Schema.encodeUnknownEffect(Schema.fromJsonString(Schema.Json))(\n bundled.registry,\n );\n if (Buffer.byteLength(metadata) > PluginRuntime.maxMetadataBytes)\n return yield* PluginPackage.PackageError.make({\n message: \"Bundled plugin contracts exceed the 64 MiB metadata limit\",\n });\n yield* fs.writeFileString(path.join(compiled.output, contracts), metadata);\n const names = Array.sort(yield* fs.glob(\"**/*\", { root: compiled.output }), Order.String);\n const files = MutableList.make<string>();\n for (const name of names)\n if ((yield* fs.stat(path.join(compiled.output, name))).type === \"File\")\n MutableList.append(files, name);\n const staged = yield* fs.makeTempDirectoryScoped({ prefix: \"dual-plugin-tarball-\" });\n const archive = path.join(staged, \"plugin.tgz\");\n yield* Effect.tryPromise(() =>\n tar.create(\n {\n cwd: compiled.output,\n file: archive,\n gzip: true,\n portable: true,\n mtime: DateTime.toDateUtc(DateTime.makeUnsafe(\"1980-01-01T00:00:00Z\")),\n prefix: \"package\",\n },\n MutableList.toArray(files),\n ),\n );\n const isolated = path.join(staged, \"isolated\");\n yield* fs.makeDirectory(isolated);\n yield* Effect.tryPromise(() =>\n tar.extract({ cwd: isolated, file: archive, strip: 1, strict: true }),\n );\n const inspected = yield* validation.validate(isolated);\n const publicExports = Effect.fnUntraced(function* (\n directory: string,\n entries: (readonly [string, string])[],\n ) {\n const output = yield* spawner.string(\n ChildProcess.make(\n executable,\n [\n \"--no-env-file\",\n \"--no-install\",\n \"--eval\",\n 'import { pathToFileURL } from \"node:url\"; const result = {}; for (const [source,file] of JSON.parse(process.argv[1])) result[source] = Object.keys(await import(pathToFileURL(process.cwd()+\"/\"+file).href)).sort(); console.log(JSON.stringify(result));',\n JSON.stringify(entries),\n ],\n { cwd: directory, env: {}, stdin: \"ignore\" },\n ),\n );\n return yield* Schema.decodeEffect(\n Schema.fromJsonString(Schema.Record(Schema.String, Schema.Array(Schema.String))),\n )(output.trim());\n });\n const originalExports = yield* publicExports(\n root,\n Array.map(compiled.publicJavaScript, entry => [entry.source, entry.source] as const),\n );\n const finalExports = yield* publicExports(\n isolated,\n Array.map(compiled.publicJavaScript, entry => [entry.source, entry.output] as const),\n );\n if (JSON.stringify(originalExports) !== JSON.stringify(finalExports))\n return yield* PluginPackage.PackageError.make({\n message:\n \"The final tarball changed public JavaScript exports; no archive was written\",\n });\n const encode = Schema.encodeEffect(Schema.fromJsonString(PluginInspection.Result));\n if (\n (yield* encode(original)) !== (yield* encode(inspected)) ||\n (yield* encode(bundled)) !== (yield* encode(inspected)) ||\n (yield* fs.readFileString(path.join(isolated, contracts))) !== metadata\n )\n return yield* PluginPackage.PackageError.make({\n message:\n \"The packaged plugin identity or contracts differ from the project inspection; no archive was written\",\n });\n const bytes = yield* fs.readFile(archive);\n const file = path.resolve(output);\n yield* fs.makeDirectory(path.dirname(file), { recursive: true });\n const temporary = yield* fs.makeTempFileScoped({\n directory: path.dirname(file),\n prefix: \".dual-plugin-\",\n });\n yield* fs.writeFile(temporary, bytes);\n yield* fs.rename(temporary, file);\n return {\n activated: false,\n digest: Hex.encode(yield* crypto.digest(Digest.sha512, bytes)),\n file,\n plugin: original.plugin,\n published: false,\n size: bytes.length,\n version: original.version,\n } satisfies Artifact;\n },\n Effect.scoped,\n Effect.mapError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UAAS,CAAC,MAAM,QAAQ,MAAM,MAAM,CAAU,CACrF;EACA,IAAI,KAAK,UAAU,eAAe,MAAM,KAAK,UAAU,YAAY,GACjE,OAAO,OAAA,aAAkC,KAAK,EAC5C,SACE,8EACJ,CAAC;EACH,MAAM,SAAS,OAAO,aAAa,OAAO,eAAeC,QAAuB,CAAC;EACjF,KACG,OAAO,OAAO,QAAQ,QAAQ,OAAO,OAAO,SAAS,OACrD,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO,SAAS,OACpD,OAAO,GAAG,eAAe,KAAK,KAAK,UAAU,SAAS,CAAC,OAAO,UAE/D,OAAO,OAAA,aAAkC,KAAK,EAC5C,SACE,uGACJ,CAAC;EACH,MAAM,QAAQ,OAAO,GAAG,SAAS,OAAO;EACxC,MAAM,OAAO,KAAK,QAAQ,MAAM;EAChC,OAAO,GAAG,cAAc,KAAK,QAAQ,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;EAC/D,MAAM,YAAY,OAAO,GAAG,mBAAmB;GAC7C,WAAW,KAAK,QAAQ,IAAI;GAC5B,QAAQ;EACV,CAAC;EACD,OAAO,GAAG,UAAU,WAAW,KAAK;EACpC,OAAO,GAAG,OAAO,WAAW,IAAI;EAChC,OAAO;GACL,WAAW;GACX,QAAQ,IAAI,OAAO,OAAO,OAAO,OAAO,OAAO,QAAQ,KAAK,CAAC;GAC7D;GACA,QAAQ,SAAS;GACjB,WAAW;GACX,MAAM,MAAM;GACZ,SAAS,SAAS;EACpB;CACF,GACA,OAAO,QACP,OAAO,UAAS,UACd,OAAO,GAAGC,YAA0B,CAAC,CAAC,KAAK,IAAI,QAAQC,UAAwB,KAAK,CACtF,CACF,EACF,CAAC;AACH,CAAC,CACH"}
@@ -5,10 +5,10 @@ import "./validation.js";
5
5
  import { createRequire } from "node:module";
6
6
  import { Context, Effect, Fiber, FileSystem, Layer, Path, Schema, Scope, Stream, pipe } from "effect";
7
7
  import { ChildProcess, ChildProcessSpawner } from "effect/process";
8
+ import { PluginRuntime } from "@dual-os/sdk/PluginRuntime";
8
9
  import { ReleaseManifest } from "#release/release-manifest";
9
10
  import { fork } from "node:child_process";
10
11
  import { NodeStream } from "@effect/platform-node";
11
- import { PluginRuntime } from "@dual-os/sdk/PluginRuntime";
12
12
  import { RemoteRuntime } from "@dual-os/sdk/RemoteRuntime";
13
13
  // src/plugin/validation.ts
14
14
  var validation_exports = /* @__PURE__ */ __exportAll({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dual-os/cli",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "license": "UNLICENSED",
5
5
  "bin": {
6
6
  "dual": "./dist/bin.js"
@@ -17,6 +17,8 @@ import { Hex } from "effect/encoding";
17
17
  import { ChildProcess, ChildProcessSpawner } from "effect/process";
18
18
  import * as tar from "tar";
19
19
 
20
+ import { PluginRuntime } from "@dual-os/sdk/PluginRuntime";
21
+
20
22
  import { make as makeBundle } from "./bundle.ts";
21
23
  import { PluginInspection } from "./inspection.ts";
22
24
  import { PluginPackage } from "./package.ts";
@@ -110,7 +112,13 @@ export const layer = Layer.effect(
110
112
  const prepared = yield* packages.inspect(root);
111
113
  const original = yield* validation.validate(root);
112
114
  const compiled = yield* buildBundle(root, prepared);
115
+ const contracts = "dual-contracts.json";
116
+ if (yield* fs.exists(path.join(compiled.output, contracts)))
117
+ return yield* PluginPackage.PackageError.make({
118
+ message: `${contracts} is reserved for the bundled plugin contracts`,
119
+ });
113
120
  const declaration = {
121
+ contracts,
114
122
  entrypoint: compiled.entrypoint.replaceAll("\\", "/"),
115
123
  export: prepared.export,
116
124
  format: 2,
@@ -147,6 +155,15 @@ export const layer = Layer.effect(
147
155
  },
148
156
  packages: compiled.packages,
149
157
  });
158
+ const bundled = yield* validation.validate(compiled.output);
159
+ const metadata = yield* Schema.encodeUnknownEffect(Schema.fromJsonString(Schema.Json))(
160
+ bundled.registry,
161
+ );
162
+ if (Buffer.byteLength(metadata) > PluginRuntime.maxMetadataBytes)
163
+ return yield* PluginPackage.PackageError.make({
164
+ message: "Bundled plugin contracts exceed the 64 MiB metadata limit",
165
+ });
166
+ yield* fs.writeFileString(path.join(compiled.output, contracts), metadata);
150
167
  const names = Array.sort(yield* fs.glob("**/*", { root: compiled.output }), Order.String);
151
168
  const files = MutableList.make<string>();
152
169
  for (const name of names)
@@ -208,7 +225,11 @@ export const layer = Layer.effect(
208
225
  "The final tarball changed public JavaScript exports; no archive was written",
209
226
  });
210
227
  const encode = Schema.encodeEffect(Schema.fromJsonString(PluginInspection.Result));
211
- if ((yield* encode(original)) !== (yield* encode(inspected)))
228
+ if (
229
+ (yield* encode(original)) !== (yield* encode(inspected)) ||
230
+ (yield* encode(bundled)) !== (yield* encode(inspected)) ||
231
+ (yield* fs.readFileString(path.join(isolated, contracts))) !== metadata
232
+ )
212
233
  return yield* PluginPackage.PackageError.make({
213
234
  message:
214
235
  "The packaged plugin identity or contracts differ from the project inspection; no archive was written",