@camstack/agent 1.1.52 → 1.1.53

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/cli.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  import { createRequire as __cr } from 'node:module'; const require = globalThis.require ?? __cr(import.meta.url);
3
3
  import {
4
4
  startAgent
5
- } from "./chunk-67UOSAWB.mjs";
5
+ } from "./chunk-Y3WG77PU.mjs";
6
6
  import "./chunk-KPUXW5YX.mjs";
7
7
 
8
8
  // src/cli.ts
package/dist/index.d.ts CHANGED
@@ -77,6 +77,19 @@ interface AgentServiceDeps {
77
77
  readonly expectedClusterSecretHash?: string;
78
78
  /** Pull-install a published addon from npm/GHCR (wired by agent-bootstrap). */
79
79
  readonly installFromNpm?: (packageName: string, version: string) => Promise<void>;
80
+ /**
81
+ * Install a deployed `.tgz` bundle through the agent's `AddonInstaller`
82
+ * (`installFromTgz`): staged extract → `@camstack/*` manifest strip →
83
+ * runtime-deps `npm install` (FATAL on failure) → manifest-driven native
84
+ * deps → atomic rename swap. Wired by agent-bootstrap. When absent the
85
+ * deploy handler falls back to the plain tar swap (`applyDeployedBundle`) —
86
+ * the pre-#17 path that silently LOSES native deps (sharp on the Mac
87
+ * Electron agent) because it never runs the installer's post-install.
88
+ */
89
+ readonly installBundleTgz?: (tgzPath: string) => Promise<{
90
+ name: string;
91
+ version: string;
92
+ }>;
80
93
  }
81
94
  declare function createAgentService(deps: AgentServiceDeps): ServiceSchema;
82
95
 
package/dist/index.js CHANGED
@@ -1631,13 +1631,39 @@ function createAgentService(deps) {
1631
1631
  }
1632
1632
  return deps.installFromNpm(pkg, v);
1633
1633
  },
1634
- applyBundle: (buf) => applyDeployedBundle({
1635
- addonsDir: deps.addonsDir,
1636
- addonId,
1637
- bundle: buf,
1638
- extract,
1639
- logger: deploySwapLogger
1640
- }),
1634
+ // #17: route the bundle through the agent's AddonInstaller when
1635
+ // wired — installFromTgz runs the FULL post-install (manifest
1636
+ // strip, runtime-deps npm install, manifest-driven NATIVE deps)
1637
+ // with its own staged extract + atomic swap. The plain tar swap
1638
+ // below never installed deps, so every pipeline/post-analysis
1639
+ // deploy on the Mac Electron agent silently shipped without
1640
+ // `sharp` et al. Fallback kept for agents without an installer
1641
+ // (test harnesses).
1642
+ applyBundle: async (buf) => {
1643
+ if (deps.installBundleTgz) {
1644
+ const tgzPath = path3.join(
1645
+ os2.tmpdir(),
1646
+ `camstack-deploy-${addonId.replace(/[^\w.-]/g, "_")}-${Date.now()}.tgz`
1647
+ );
1648
+ fs3.writeFileSync(tgzPath, buf);
1649
+ try {
1650
+ const { name } = await deps.installBundleTgz(tgzPath);
1651
+ return { addonDir: path3.join(deps.addonsDir, name) };
1652
+ } finally {
1653
+ try {
1654
+ fs3.unlinkSync(tgzPath);
1655
+ } catch {
1656
+ }
1657
+ }
1658
+ }
1659
+ return applyDeployedBundle({
1660
+ addonsDir: deps.addonsDir,
1661
+ addonId,
1662
+ bundle: buf,
1663
+ extract,
1664
+ logger: deploySwapLogger
1665
+ });
1666
+ },
1641
1667
  fetchBundle: (s) => fetchBundleFromHub(s),
1642
1668
  // Evict every addon DECLARATION id this package contributes
1643
1669
  // from `loadedAddons` so the follow-up `$agent.reload` actually
@@ -2691,7 +2717,11 @@ async function startAgent(configPath) {
2691
2717
  expectedClusterSecretHash: config.secret ? (0, import_system3.hashClusterSecret)(config.secret) : void 0,
2692
2718
  installFromNpm: async (pkg, version) => {
2693
2719
  await installer.install(pkg, version);
2694
- }
2720
+ },
2721
+ // #17: deployed bundles go through the installer's full post-install
2722
+ // (manifest strip + runtime deps + native deps + atomic swap) instead of
2723
+ // the bare tar swap that shipped addons without their node_modules.
2724
+ installBundleTgz: (tgzPath) => installer.installFromTgz(tgzPath)
2695
2725
  });
2696
2726
  broker.createService(agentServiceSchema);
2697
2727
  const agentTcpPort = (0, import_system3.deriveAgentListenPort)(broker.nodeID);