@north-light/api 0.3.723 → 0.3.725

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.
@@ -76,13 +76,14 @@ const setLeaf = defineLeaf({
76
76
  'Secrets never go in the setup script, because it is baked into the image: store them with `crtr profile env set <profile> --name <NAME>` and every sandbox gets them as environment variables.',
77
77
  ],
78
78
  },
79
- run: async (input) => {
79
+ run: async (input, context) => {
80
80
  const { id } = await resolveProfileViaDaemon(input['profile']);
81
81
  const repos = input['repo'];
82
82
  const file = input['setupScriptFile'];
83
83
  const packages = input['piPackage'];
84
84
  const memory = input['memory'];
85
- const allowPrWrite = input['allowPullRequestWrite'];
85
+ // A bool flag parses to false when absent, so only an explicitly passed flag may change the stored value.
86
+ const allowPrWrite = context?.providedParams.has('allowPullRequestWrite') === true ? input['allowPullRequestWrite'] : undefined;
86
87
  if (memory !== undefined && ![2, 4, 8].includes(memory))
87
88
  throw usage('`--memory` is 2, 4 or 8 (GB).');
88
89
  const req = {
@@ -371,7 +371,7 @@ export async function assertRecordedCwdExists(nodeId, meta) {
371
371
  /** Cleanup deleted this node's managed checkout and its branch, and nothing rebuilds them: refuse on any host, before a caller changes state. */
372
372
  export function assertCheckoutNotRemoved(nodeId, meta) {
373
373
  const worktree = meta.managed_worktree;
374
- if (worktree?.state !== 'closed' || worktree.cleanup !== 'complete' || meta.cwd !== worktree.path)
374
+ if (worktree?.state !== 'closed' || worktree.cleanup !== 'complete')
375
375
  return;
376
376
  throw new InputError({
377
377
  error: 'checkout_removed',
@@ -73,9 +73,10 @@ export function recipeDockerfile(recipe, revision, packagesToken = false) {
73
73
  out.push('WORKDIR /work');
74
74
  out.push(`RUN ${writeRunUserNpmrc()}`);
75
75
  // Warm the image's pnpm store from each repository's lockfile, so `pnpm install` in the sandbox links instead of downloading. A failed fetch only costs that
76
- // warmth, so it is logged and never refuses the sandbox start.
76
+ // warmth, so it is logged and never refuses the sandbox start. The fetch runs as root, so the repository and the store go back to the run user after it:
77
+ // a setup script's `su crtr -c 'pnpm install'` cannot replace a root-owned `node_modules/.modules.yaml`.
77
78
  for (const repo of recipe.repositories) {
78
- out.push(`RUN if [ -f /work/${repo.name}/pnpm-lock.yaml ]; then cd /work/${repo.name} && HOME=/home/${RUN_USER} pnpm fetch >> ${SETUP_LOG_FILE} 2>&1 || echo 'pnpm fetch ${repo.name} failed' >> ${SETUP_LOG_FILE}; fi`);
79
+ out.push(`RUN if [ -f /work/${repo.name}/pnpm-lock.yaml ]; then cd /work/${repo.name} && HOME=/home/${RUN_USER} pnpm fetch >> ${SETUP_LOG_FILE} 2>&1 || echo 'pnpm fetch ${repo.name} failed' >> ${SETUP_LOG_FILE}; chown -R ${RUN_USER}:${RUN_USER} /work/${repo.name} /home/${RUN_USER}; fi`);
79
80
  }
80
81
  for (const source of packages)
81
82
  out.push(guarded(`pi install ${source}`, `HOME=/var/lib/crtr PI_CODING_AGENT_DIR=${RECIPE_PI_AGENT_DIR} pi install ${shellQuote(source)}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/api",
3
- "version": "0.3.723",
3
+ "version": "0.3.725",
4
4
  "description": "Typed crtrd /v1 API contract — DTOs, route builders, the error contract, the CrtrClient, and the command-plugin manifest format. Zero runtime dependencies.",
5
5
  "type": "module",
6
6
  "main": "./dist/api/index.js",