mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-01 18:07:00 +01:00
Integrate bounded Pi installer review corrections
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
commit
021416d254
7 files changed
+120
-22
No files matched your search
@@ -4,7 +4,7 @@ import { join } from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { Command } from "commander";
|
||||
import { afterEach, expect, it } from "vitest";
|
||||
import { registerRuntimeCommands, resolvePiProvisioner, resolveRemoteCompanionImporter } from "../commands/runtime.js";
|
||||
import { buildPiSetupEnvironment, registerRuntimeCommands, resolvePiProvisioner, resolveRemoteCompanionImporter } from "../commands/runtime.js";
|
||||
const roots: string[] = [];
|
||||
afterEach(async () => { await Promise.all(roots.splice(0).map(root => rm(root, { recursive: true, force: true }))); });
|
||||
async function fixture() {
|
||||
@@ -43,3 +43,10 @@ it("requires an explicit digest for the companion import command", async () => {
|
||||
const program = new Command(); program.exitOverride().configureOutput({ writeErr() {} }); registerRuntimeCommands(program);
|
||||
await expect(program.parseAsync(["node", "paperclipai", "runtime", "import-remote", "/unused"])).rejects.toThrow("sha256");
|
||||
});
|
||||
|
||||
it("passes explicit setup network settings without provider keys or ambient Node/npm configuration", () => {
|
||||
const network = { PATH: "/public/bin", LC_ALL: "C.UTF-8", HTTPS_PROXY: "http://proxy.example:8080", HTTP_PROXY: "http://proxy.example:8080", NO_PROXY: "localhost", SSL_CERT_FILE: "/public/ca.pem", SSL_CERT_DIR: "/public/certs", NODE_EXTRA_CA_CERTS: "/public/extra-ca.pem" };
|
||||
const environment = buildPiSetupEnvironment({ ...network, LANG: "foreign", HOME: "/private/home", OPENROUTER_API_KEY: "must-not-forward", ANTHROPIC_API_KEY: "must-not-forward", NPM_TOKEN: "must-not-forward", npm_config_registry: "https://foreign.example", NODE_OPTIONS: "--require /foreign.js", NODE_PATH: "/foreign/modules", NODE_TLS_REJECT_UNAUTHORIZED: "0" });
|
||||
expect(environment).toEqual({ ...network, LANG: "C.UTF-8" });
|
||||
expect(buildPiSetupEnvironment({})).toEqual({ PATH: "/usr/bin:/bin", LANG: "C.UTF-8" });
|
||||
});
|
||||
@@ -27,12 +27,21 @@ export async function resolveRemoteCompanionImporter(serverUrl: string): Promise
|
||||
return modulePath;
|
||||
}
|
||||
|
||||
/** Public downloads may use operator network settings, never application secrets. */
|
||||
export function buildPiSetupEnvironment(source: NodeJS.ProcessEnv = process.env): NodeJS.ProcessEnv {
|
||||
const environment: NodeJS.ProcessEnv = { PATH: source.PATH ?? "/usr/bin:/bin", LANG: "C.UTF-8" };
|
||||
for (const key of ["LC_ALL", "HTTPS_PROXY", "HTTP_PROXY", "NO_PROXY", "SSL_CERT_FILE", "SSL_CERT_DIR", "NODE_EXTRA_CA_CERTS"]) {
|
||||
if (typeof source[key] === "string") environment[key] = source[key];
|
||||
}
|
||||
return environment;
|
||||
}
|
||||
|
||||
export async function setupPiRuntime(): Promise<void> {
|
||||
const provisioner = await resolvePiProvisioner(import.meta.resolve("@paperclipai/server"));
|
||||
// Only the explicit setup command can download pinned public dependencies.
|
||||
// Do not forward provider credentials, proxy/npm config, HOME or NODE_OPTIONS.
|
||||
const child = spawn(process.execPath, [provisioner], {
|
||||
stdio: "inherit", env: { PATH: process.env.PATH ?? "/usr/bin:/bin", LANG: "C.UTF-8" },
|
||||
// Only explicit setup downloads. Enable Node's proxy handling for the helper;
|
||||
// provider keys, npm configuration, HOME and Node injection remain excluded.
|
||||
const child = spawn(process.execPath, ["--use-env-proxy", provisioner], {
|
||||
stdio: "inherit", env: buildPiSetupEnvironment(),
|
||||
});
|
||||
const cancel = () => { if (child.exitCode === null && child.signalCode === null) child.kill("SIGTERM"); };
|
||||
process.on("SIGINT", cancel); process.on("SIGTERM", cancel);
|
||||
|
||||
@@ -1129,8 +1129,12 @@ perform it automatically. It installs only this host's supported platform
|
||||
(macOS ARM64, macOS x64, or Linux x64), using the source-pinned Node archive, npm
|
||||
lock, wrapper patch and complete Pi closure. Node 24, npm, git, tar and the normal
|
||||
platform dependency inspector (`otool` or `ldd`) must be available. The server
|
||||
package must be writable by the installing account. Setup forwards no instance
|
||||
configuration, provider credentials, npm configuration or proxy credentials.
|
||||
package must be writable by the installing account. Explicit setup preserves
|
||||
`HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY`, `SSL_CERT_FILE`, `SSL_CERT_DIR` and
|
||||
`NODE_EXTRA_CA_CERTS` for public downloads, and enables Node's environment proxy
|
||||
handling. The provisioner keeps the same closed allowlist. Instance settings,
|
||||
provider credentials, user npm configuration, `HOME`, `NODE_OPTIONS` and
|
||||
`NODE_PATH` are excluded; TLS certificate validation stays enabled.
|
||||
|
||||
The public server carries a self-contained setup tool and small pinned inputs in
|
||||
`dist/vendor/paperclip-runner/cli`; the installed host closure lives in that
|
||||
|
||||
@@ -25,9 +25,9 @@ qualification. The existing draft stack must be reviewed in dependency order.
|
||||
| Live lifecycle | Pending native question survives controller restart in the original process; one creation and resolution; stale answer after provider death rejected; Stop retires owned processes; three warm turns keep process identity | Frozen shipping source `0bd040093` passes local Stop, steering, controller restart, native questions and warm continuity. Daytona warm continuity, human denial, corrected Stop and first steering pass. Native questions, native controller-restart and provider-death remain failed. Prior failed attempts remain unchanged. |
|
||||
| Product workflows | All 26 explicit Pi Product E2E cells (13 local, 13 Daytona); screenshots, public state, independent artifacts, terminal and cleanup evidence | All 26 cells are attempted at frozen shipping source `0bd040093`: 20 pass and six remain failed. Local has 11 passes and two failures: agent-files and file-edit. Daytona has nine passes and four failures: native-questions, native controller-restart, agent-files and provider-death. The separately corrected Daytona file-edit attempt passes all seven matchers and canonical cleanup on extended definitions 3; its original failure remains failed. Human denial passes nine matchers and cleanup on native definitions 5. Corrected Stop passes five matchers; first steering passes eight; both pass cleanup on controls definitions 8. No cells remain unattempted or running. Original grades and source fingerprints are preserved. |
|
||||
| Runner protocol | Pi roster passes through the native packaged runner and authenticated mock control plane; lifecycle/denial/control cases remain distinct from Product tests | All seven cases are attempted at `0bd040093`: five pass; context-before-action retains its 120-second terminal timeout, and finish-task retains use of the advisory report without the required task mutation. One context/document workflow retry passes only after verified protection against the recorded host sleep; its original failure stays unchanged. The seven `b148b73ea` passes remain historical. |
|
||||
| Installed distribution | Public CLI/server tars on ARM Mac, Intel Mac and Linux; normal Pi setup; exact Linux companion and immutable Daytona image imported without binary override | Exact-source public CLI/server installation and normal Pi setup pass on all three platforms. Public immutable image `ghcr.io/paperclipai/paperclip-daytona-runner@sha256:342f1fd5cb8cabfa2242f38f4f686608b28b6536aa879c54b0cb0da6fba9ef47` imports into native Linux Daytona and passes closed admission. Temporary sandbox cleanup passes. Image jobs 37102904889, 37106313185 and 37110683910 are terminal/cancelled. |
|
||||
| Installed distribution | Public CLI/server tars on ARM Mac, Intel Mac and Linux; normal Pi setup; exact Linux companion and immutable Daytona image imported without binary override | Public CLI/server installation and normal Pi setup pass on all three platforms at original execution source `0bd040093`. The installer correction at `fcef1eae9` changes CLI and provisioner bytes; fresh normal public artifact/install proof must bind the updated source. Old artifact proofs keep their original labels. Public immutable image `ghcr.io/paperclipai/paperclip-daytona-runner@sha256:342f1fd5cb8cabfa2242f38f4f686608b28b6536aa879c54b0cb0da6fba9ef47` imports into native Linux Daytona and passes closed admission. Temporary sandbox cleanup passes. Image jobs 37102904889, 37106313185 and 37110683910 are terminal/cancelled. |
|
||||
| Governance and spend | Company isolation, human-only permission, duplicate/stale answers, Stop and budget hard stop; pricing estimates never become claimed bills | 58 focused governance/cost/session invariants pass at `f5f57e380`. Live pending-permission Stop passes at `03dd6ef93`. The qualification key cap is not proof of Paperclip budget enforcement. |
|
||||
| Integration and rollout | Review each prerequisite; final-head typecheck, tests, build and CI pass; no unresolved review; exact artifacts; rollback recorded | Last verified readiness head `baaf444ed` has 53 successful CI checks, two skips, Greptile 5/5 and no unresolved root threads, including full Linux build and typecheck. The prerequisite ancestry reconciliation preserves that tracked source tree before this plan update; the integration must receive its own completed current-head CI and review. All 116 targeted native Linux fixture tests and 13 browser-case collections pass at `04f639eeb`; the new descriptor correction separately passes all 17 free native Linux fault tests. Full typecheck, complete test and build evidence remains recorded below; original failed commands remain failed. Shipping inputs stay equivalent to `0bd040093`. Four prerequisite findings now have scoped upstream corrections with focused verification. The admission finding remains open and standalone prerequisite CI/review is pending on the corrected heads. Production stays held for eight failed gates and prerequisite disposition. No merge or release. |
|
||||
| Integration and rollout | Review each prerequisite; final-head typecheck, tests, build and CI pass; no unresolved review; exact artifacts; rollback recorded | Last verified readiness head `146f578c0` has 53 successful CI checks, two skips, current-head Greptile 5/5 and no unresolved root threads, including full build and typecheck. The new installer integration must receive its own completed current-head CI, review and updated public artifact/install proof. All 116 targeted native Linux fixture tests and 13 browser-case collections pass at `04f639eeb`; the new descriptor correction separately passes all 17 free native Linux fault tests. Full typecheck, complete test and build evidence remains recorded below; original failed commands remain failed. Frozen Pi execution inputs remain equivalent to `0bd040093`; the explicit installer has two changed executable inputs. Prerequisite #14921 passes every test/build/typecheck check but its valid admission review blocks merge. The retained SDK and setup network findings receive scoped corrections with focused verification; their new heads require fresh CI and review. Production stays held for eight failed gates and prerequisite disposition. No merge or release. |
|
||||
|
||||
## Bounded execution
|
||||
|
||||
@@ -82,8 +82,8 @@ success label is corrected by its strict verdict. All three owned sandboxes are
|
||||
deleted. The original paid rejection stage remains unproven.
|
||||
|
||||
Prerequisite fixes preserve every previous commit. The latest heads are
|
||||
#14921 `89f444850`, #14922 `ec67ba1e0`, #14923 `3250c3f68`, and #14924
|
||||
`9753f0716`. They carry the scoped UI/profile assertions and notice-display
|
||||
#14921 `7f452cbd7`, #14922 `fcef1eae9`, #14923 `5aff21d77`, and #14924
|
||||
`5120ddc8f`. They carry the scoped UI/profile assertions and notice-display
|
||||
corrections. The first prerequisite also receives the existing package-local
|
||||
Runner probe import repair and remaining admission assertions already present
|
||||
downstream. The complete repair includes both public probe export surfaces.
|
||||
@@ -100,8 +100,10 @@ remain failed or insufficient evidence. The corrected private verification uses
|
||||
exact source aliases and the pinned Node directory; no repository configuration
|
||||
changes occur.
|
||||
|
||||
The additive readiness integration has an identical tracked tree to
|
||||
`337ca6bd1` before this plan update. The preceding `aef3b84ce` completes 53 successful
|
||||
The preceding readiness integration `146f578c0` completes 53 successful CI
|
||||
checks, two skips and a current-head 5/5 review. The new additive integration
|
||||
changes only the six scoped installer/fixture/documentation files before this
|
||||
plan update. The preceding `aef3b84ce` completes 53 successful
|
||||
CI checks and two skips after one bounded rerun of the serialized sidebar job.
|
||||
All six sidebar tests also pass locally. The original HTTP 500 cause remains
|
||||
unproven; the failed log is retained. The earliest prerequisite's original
|
||||
@@ -114,12 +116,46 @@ errors; the complete repair above supplies those exports. New-head CI and review
|
||||
require their own terminal results. Old passes do not qualify a new head.
|
||||
No repeated unchanged rerun is authorized.
|
||||
|
||||
Runtime artifacts, profile 14, model/low and suite fingerprints are unchanged.
|
||||
Pi execution inputs, profile 14, model/low and suite fingerprints are unchanged.
|
||||
The public installer is corrected separately below; original installation
|
||||
artifacts do not become proof of the updated bytes.
|
||||
The source still declares Pi qualified: the production hold is the draft/release
|
||||
gate, not a closed code admission gate. That admission review remains open.
|
||||
No GitHub PR merge, release, automatic paid retry, fallback key or model change
|
||||
occurs.
|
||||
|
||||
## Public installer review corrections — 2026-10-05
|
||||
|
||||
The SDK fixture now derives the publication version from the actual SDK
|
||||
manifest instead of pinning 0.3.1. Exact dependency identity, byte seals,
|
||||
canonical roots and all existing ambient-Node negative fixtures stay enforced.
|
||||
|
||||
The explicit CLI setup child and its bundled provisioner now preserve the same
|
||||
closed allowlist: `PATH`, fixed `LANG`, optional `LC_ALL`, `HTTP_PROXY`,
|
||||
`HTTPS_PROXY`, `NO_PROXY`, `SSL_CERT_FILE`, `SSL_CERT_DIR` and
|
||||
`NODE_EXTRA_CA_CERTS`. The CLI enables Node's environment proxy handling before
|
||||
the helper starts. Provider keys, `HOME`, npm configuration, `NODE_OPTIONS`,
|
||||
`NODE_PATH` and TLS-validation bypass remain excluded. These settings apply to
|
||||
explicit public downloads; the Pi execution closure and profile do not change.
|
||||
|
||||
At prerequisite #14922 `fcef1eae9`, six CLI tests, eight installed-plugin tests
|
||||
and two bundled boundary tests pass with zero provider calls/downloads. The
|
||||
real CLI child verifies proxy activation and credential exclusion. The actual
|
||||
bundled provisioner verifies its post-sanitization environment and rejects a
|
||||
corrupt cache with network/child creation denied. At #14924 `5120ddc8f`, all
|
||||
18 focused checks pass, including the two pre-existing ambient-Node negative
|
||||
fixtures. The corrections are forwarded through additive merges. An initially
|
||||
over-broad SDK whole-file equality guard is retained as a local verification
|
||||
failure; the exact correction delta and preserved negative tests then pass.
|
||||
Local missing-Commander and incomplete Product source-alias setup failures are
|
||||
retained separately; no repository test configuration changes occur.
|
||||
|
||||
Normal updated CLI/server tar installation and setup on ARM Mac, Intel Mac and
|
||||
Linux remain required before releasing these installer bytes. Original
|
||||
`0bd040093` artifacts and all 33 paid grades retain their exact source labels.
|
||||
Current production results remain 25 passes and eight failures. No paid retry,
|
||||
model/profile change, lockfile edit, workflow edit, merge or release occurs.
|
||||
|
||||
## Accepted corrections — 2026-10-04
|
||||
|
||||
The operator accepts the scoped Product E2E fixture corrections and authorizes
|
||||
|
||||
@@ -5,6 +5,7 @@ import { tmpdir } from "node:os";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
import { createRequire } from "node:module";
|
||||
import test from "node:test";
|
||||
import { build } from "esbuild";
|
||||
import { bundlePiProvisioner } from "./build-verified-provider-entrypoints.mjs";
|
||||
|
||||
test("public server tar layout carries a self-contained host provisioner and exact small inputs", async t => {
|
||||
@@ -33,13 +34,44 @@ test("public server tar layout carries a self-contained host provisioner and exa
|
||||
const installedPackage = join(installed, "package"); const entry = join(installedPackage, "dist/vendor/paperclip-runner/cli/provision-pi.cjs");
|
||||
const api = createRequire(import.meta.url)(entry);
|
||||
assert.equal((await api.provisionPackageRoot(entry)).root, installedPackage);
|
||||
const network = { PATH: "/usr/bin:/bin", HTTPS_PROXY: "http://proxy.example:8080", HTTP_PROXY: "http://proxy.example:8080", NO_PROXY: "localhost", SSL_CERT_FILE: "/public/ca.pem", SSL_CERT_DIR: "/public/certs", NODE_EXTRA_CA_CERTS: "/public/extra-ca.pem" };
|
||||
assert.deepEqual(api.provisionEnvironment({ ...network, HOME: "/private/home", OPENROUTER_API_KEY: "sensitive-canary", NPM_TOKEN: "sensitive-canary", NODE_OPTIONS: "--require /foreign.js", NODE_PATH: "/foreign", NODE_TLS_REJECT_UNAUTHORIZED: "0" }), { ...network, LANG: "C.UTF-8" });
|
||||
// Real, unmocked installation verifier rejects a corrupt cache before any
|
||||
// download/process. The positive full-closure proof uses real platform packs.
|
||||
await mkdir(join(installedPackage, "provider-assets/pi", `${process.platform}-${process.arch}`, "runtime"), { recursive: true });
|
||||
const deny = join(root, "deny.cjs");
|
||||
await writeFile(deny, `const fail=()=>{throw Error('UNEXPECTED_NETWORK_OR_CHILD')}; globalThis.fetch=fail; for(const m of ['node:net','node:tls','node:http','node:https']){const x=require(m);for(const k of ['connect','createConnection','request','get'])if(k in x)x[k]=fail;}const c=require('node:child_process');for(const k of ['spawn','execFile','exec'])c[k]=fail;`);
|
||||
const result = spawnSync(process.execPath, ["--require", deny, entry], { encoding: "utf8", env: { PATH: "/usr/bin:/bin", OPENROUTER_API_KEY: "sensitive-canary", NODE_OPTIONS: "" }, timeout: 10_000 });
|
||||
await writeFile(deny, `process.nextTick(()=>{const assert=require('node:assert/strict');assert.equal(process.env.HTTP_PROXY,'http://127.0.0.1:9');assert.equal(process.env.HTTPS_PROXY,'http://127.0.0.1:9');assert.equal(process.env.NO_PROXY,'localhost');assert.equal(process.env.NODE_EXTRA_CA_CERTS,'/dev/null');for(const key of ['OPENROUTER_API_KEY','NPM_TOKEN','HOME','NODE_OPTIONS','NODE_PATH','NODE_TLS_REJECT_UNAUTHORIZED'])assert.equal(process.env[key],undefined,key);});const fail=()=>{throw Error('UNEXPECTED_NETWORK_OR_CHILD')}; globalThis.fetch=fail; for(const m of ['node:net','node:tls','node:http','node:https']){const x=require(m);for(const k of ['connect','createConnection','request','get'])if(k in x)x[k]=fail;}const c=require('node:child_process');for(const k of ['spawn','execFile','exec'])c[k]=fail;`);
|
||||
const result = spawnSync(process.execPath, ["--require", deny, entry], { encoding: "utf8", env: { PATH: "/usr/bin:/bin", HTTP_PROXY: "http://127.0.0.1:9", HTTPS_PROXY: "http://127.0.0.1:9", NO_PROXY: "localhost", NODE_EXTRA_CA_CERTS: "/dev/null", OPENROUTER_API_KEY: "sensitive-canary", NPM_TOKEN: "sensitive-canary", HOME: "/private/home", NODE_OPTIONS: "", NODE_PATH: "/foreign", NODE_TLS_REJECT_UNAUTHORIZED: "0" }, timeout: 10_000 });
|
||||
assert.ifError(result.error); assert.equal(result.status, 1); assert.match(result.stderr, /Pi setup failed/);
|
||||
assert.doesNotMatch(result.stderr, /UNEXPECTED_NETWORK_OR_CHILD|sensitive-canary/);
|
||||
assert.deepEqual(await readdir(join(installedPackage, "provider-assets/pi")), [`${process.platform}-${process.arch}`]);
|
||||
});
|
||||
|
||||
test("explicit CLI setup passes only network settings to its real child and enables Node proxy handling", async t => {
|
||||
const root = await mkdtemp(join(tmpdir(), "paperclip-pi-setup-environment-"));
|
||||
t.after(() => rm(root, { recursive: true, force: true }));
|
||||
const server = join(root, "node_modules/@paperclipai/server");
|
||||
const cli = join(server, "dist/vendor/paperclip-runner/cli");
|
||||
await mkdir(cli, { recursive: true });
|
||||
await writeFile(join(server, "package.json"), JSON.stringify({ name: "@paperclipai/server", type: "module", exports: "./dist/index.js" }));
|
||||
await writeFile(join(server, "dist/index.js"), "throw Error('server must not start')");
|
||||
// A capture child models the public layout only. It cannot download or launch Pi.
|
||||
await writeFile(join(cli, "provision-pi.cjs"), `const assert=require('node:assert/strict');
|
||||
assert.deepEqual(process.execArgv,['--use-env-proxy']);
|
||||
assert.equal(process.env.HTTP_PROXY,'http://127.0.0.1:9');
|
||||
assert.equal(process.env.HTTPS_PROXY,'http://127.0.0.1:9');
|
||||
assert.equal(process.env.NO_PROXY,'localhost');
|
||||
assert.equal(process.env.SSL_CERT_FILE,'/public/ca.pem');
|
||||
assert.equal(process.env.SSL_CERT_DIR,'/public/certs');
|
||||
assert.equal(process.env.NODE_EXTRA_CA_CERTS,'/dev/null');
|
||||
for(const key of ['OPENROUTER_API_KEY','NPM_TOKEN','HOME','NODE_OPTIONS','NODE_PATH','NODE_TLS_REJECT_UNAUTHORIZED']) assert.equal(process.env[key],undefined,key);
|
||||
console.log('SETUP_NETWORK_BOUNDARY_PASS');`);
|
||||
const modulePath = join(root, "runtime.mjs");
|
||||
await build({ entryPoints: [resolve(dirname(new URL(import.meta.url).pathname), "../../../cli/src/commands/runtime.ts")], outfile: modulePath, bundle: true, platform: "node", format: "esm", target: "node24", logLevel: "silent" });
|
||||
const result = spawnSync(process.execPath, ["--input-type=module", "-e", "const runtime=await import(process.argv[1]);await runtime.setupPiRuntime();", modulePath], {
|
||||
encoding: "utf8", timeout: 10_000, env: { PATH: "/usr/bin:/bin", HTTP_PROXY: "http://127.0.0.1:9", HTTPS_PROXY: "http://127.0.0.1:9", NO_PROXY: "localhost", SSL_CERT_FILE: "/public/ca.pem", SSL_CERT_DIR: "/public/certs", NODE_EXTRA_CA_CERTS: "/dev/null", OPENROUTER_API_KEY: "sensitive-canary", NPM_TOKEN: "sensitive-canary", HOME: "/private/home", NODE_PATH: "/foreign", NODE_TLS_REJECT_UNAUTHORIZED: "0" },
|
||||
});
|
||||
assert.ifError(result.error); assert.equal(result.status, 0, result.stderr);
|
||||
assert.match(result.stdout, /SETUP_NETWORK_BOUNDARY_PASS/);
|
||||
assert.doesNotMatch(result.stdout + result.stderr, /sensitive-canary/);
|
||||
});
|
||||
@@ -9,6 +9,14 @@ import { verifyPiInstallation } from "../src/drivers/acpx/pi-installation.ts";
|
||||
import { QUALIFIED_ACPX_PROFILES } from "../src/drivers/acpx/qualified-profiles.ts";
|
||||
import { PI_DISTRIBUTION_CLOSURE_SHA256 } from "../src/drivers/acpx/pi-closure-pins.ts";
|
||||
|
||||
export function provisionEnvironment(source = process.env) {
|
||||
const environment = { PATH: source.PATH ?? "/usr/bin:/bin", LANG: "C.UTF-8" };
|
||||
for (const key of ["LC_ALL", "HTTPS_PROXY", "HTTP_PROXY", "NO_PROXY", "SSL_CERT_FILE", "SSL_CERT_DIR", "NODE_EXTRA_CA_CERTS"]) {
|
||||
if (typeof source[key] === "string") environment[key] = source[key];
|
||||
}
|
||||
return environment;
|
||||
}
|
||||
|
||||
export async function provisionPackageRoot(entrypoint) {
|
||||
const canonical = await realpath(entrypoint);
|
||||
if (canonical !== resolve(entrypoint)) throw new Error("Pi setup entrypoint must not be linked");
|
||||
@@ -116,9 +124,9 @@ export async function provisionPi(entrypoint, checkCancelled = () => {}) {
|
||||
if (process.argv[1] && pathToFileURL(resolve(process.argv[1])).href === import.meta.url) {
|
||||
const args = process.argv.slice(2);
|
||||
if (args.length) throw new Error("Usage: paperclipai runtime setup pi (explicit host-platform installation; no model calls)");
|
||||
// Setup uses only public, source-pinned downloads. Never forward credentials,
|
||||
// HOME config, proxy configuration, NODE_OPTIONS or npm configuration.
|
||||
const environment = { PATH: process.env.PATH ?? "/usr/bin:/bin", LANG: "C.UTF-8" };
|
||||
// Preserve the same closed network allowlist as the explicit CLI command.
|
||||
// Never forward provider keys, HOME config, NODE_OPTIONS or npm configuration.
|
||||
const environment = provisionEnvironment();
|
||||
for (const key of Object.keys(process.env)) delete process.env[key]; Object.assign(process.env, environment);
|
||||
let cancelled = false;
|
||||
const cancel = () => { cancelled = true; };
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { createHash } from "node:crypto";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { mkdtemp, mkdir, realpath, rm, symlink, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
@@ -10,6 +11,7 @@ import { buildPaperclipServerEnvironment } from "./harness-env.js";
|
||||
import { setupLiveFixtures } from "./live-fixtures.js";
|
||||
import type { RunnerApi } from "./api.js";
|
||||
const cell = runnerMatrix.find(e => e.id === "extended-harnesses.runner-acpx-pi.daytona.hello-complete")!;
|
||||
const sdkVersion: string = JSON.parse(readFileSync(new URL("../../packages/plugins/sdk/package.json", import.meta.url), "utf8")).version;
|
||||
const roots: string[] = [];
|
||||
const hash = (v: string) => createHash("sha256").update(v).digest("hex");
|
||||
afterEach(async () => { vi.unstubAllEnvs(); await Promise.all(roots.splice(0).map(root => rm(root, { recursive: true, force: true }))); });
|
||||
@@ -21,9 +23,9 @@ async function fixture() {
|
||||
await writeFile(join(dir, "package.json"), content); await writeFile(join(dir, entry), "// compiled");
|
||||
return { root: dir, packageSha256: hash(content), entry, entrySha256: hash("// compiled") };
|
||||
}
|
||||
const plugin = await pkg("@paperclipai/plugin-daytona", "0.1.1", { "@paperclipai/plugin-sdk": "0.3.1", "@daytonaio/sdk": "0.203.0" }, { paperclipPlugin: { manifest: "./dist/manifest.js", worker: "./dist/worker.js" } });
|
||||
const plugin = await pkg("@paperclipai/plugin-daytona", "0.1.1", { "@paperclipai/plugin-sdk": sdkVersion, "@daytonaio/sdk": "0.203.0" }, { paperclipPlugin: { manifest: "./dist/manifest.js", worker: "./dist/worker.js" } });
|
||||
await writeFile(join(plugin.root, "dist/manifest.js"), "// manifest"); await writeFile(join(plugin.root, "dist/worker.js"), "// worker");
|
||||
const authority: InstalledDaytonaPluginAuthority = { schema: "paperclip.e2e.installed-daytona-plugin/v1", graphRoot: root, plugin: { ...plugin, manifestSha256: hash("// manifest"), workerSha256: hash("// worker") }, sdk: await pkg("@paperclipai/plugin-sdk", "0.3.1", { "@paperclipai/shared": "0.3.1" }), shared: await pkg("@paperclipai/shared", "0.3.1"), daytona: await pkg("@daytonaio/sdk", "0.203.0") };
|
||||
const authority: InstalledDaytonaPluginAuthority = { schema: "paperclip.e2e.installed-daytona-plugin/v1", graphRoot: root, plugin: { ...plugin, manifestSha256: hash("// manifest"), workerSha256: hash("// worker") }, sdk: await pkg("@paperclipai/plugin-sdk", sdkVersion, { "@paperclipai/shared": "0.3.1" }), shared: await pkg("@paperclipai/shared", "0.3.1"), daytona: await pkg("@daytonaio/sdk", "0.203.0") };
|
||||
const authorityPath = join(root, "authority.json");
|
||||
const env: NodeJS.ProcessEnv = { PAPERCLIP_RUNNER_E2E_INSTALLED_CLI: "/reviewed/cli", PAPERCLIP_RUNNER_E2E_INSTALLED_CLI_SHA256: "reviewed-separately", PAPERCLIP_RUNNER_E2E_INSTALLED_SERVER_ROOT: "/reviewed/server", PAPERCLIP_RUNNER_E2E_INSTALLED_SERVER_SHA256: "reviewed-separately", PAPERCLIP_RUNNER_E2E_INSTALLED_DAYTONA_PLUGIN: plugin.root, PAPERCLIP_RUNNER_E2E_INSTALLED_DAYTONA_PLUGIN_AUTHORITY: authorityPath };
|
||||
async function seal() { const bytes = JSON.stringify(authority); await writeFile(authorityPath, bytes); env.PAPERCLIP_RUNNER_E2E_INSTALLED_DAYTONA_PLUGIN_AUTHORITY_SHA256 = hash(bytes); }
|
||||
@@ -51,7 +53,7 @@ it("rejects stale authority, worker, manifest and dependency entry bytes", async
|
||||
});
|
||||
it("rejects source exports and workspace dependency versions even with refreshed pins", async () => {
|
||||
const f = await fixture(); const p = join(f.authority.plugin.root,"package.json");
|
||||
const original = { name:"@paperclipai/plugin-daytona",version:"0.1.1",exports:{".":{import:"./dist/index.js"}},paperclipPlugin:{manifest:"./dist/manifest.js",worker:"./dist/worker.js"},dependencies:{"@paperclipai/plugin-sdk":"0.3.1","@daytonaio/sdk":"0.203.0"} };
|
||||
const original = { name:"@paperclipai/plugin-daytona",version:"0.1.1",exports:{".":{import:"./dist/index.js"}},paperclipPlugin:{manifest:"./dist/manifest.js",worker:"./dist/worker.js"},dependencies:{"@paperclipai/plugin-sdk":sdkVersion,"@daytonaio/sdk":"0.203.0"} };
|
||||
for (const manifest of [{ ...original, exports:{".":{import:"./src/index.ts"}} }, { ...original, dependencies:{ ...original.dependencies,"@paperclipai/plugin-sdk":"workspace:*" } }]) {
|
||||
const bytes=JSON.stringify(manifest);await writeFile(p,bytes);f.authority.plugin.packageSha256=hash(bytes);await f.seal();await expect(verifyInstalledDaytonaPlugin(f.env,[cell])).rejects.toThrow(/compiled package exports|dependency identity/);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user