priiisk 0.1.4 → 0.1.6

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.
@@ -1152,7 +1152,7 @@ var numberArgument = (parameters, name) => {
1152
1152
  const value = parameters[name];
1153
1153
  return typeof value === "number" && Number.isFinite(value) ? value : void 0;
1154
1154
  };
1155
- var campUiExploredReadPath = (parameters) => stringArgument(parameters, "path") ?? stringArgument(parameters, "file_path");
1155
+ var campUiExploredReadPath = (parameters) => stringArgument(parameters, "path");
1156
1156
  var campUiExploredReadRange = (parameters) => {
1157
1157
  const offset = numberArgument(parameters, "offset");
1158
1158
  const limit = numberArgument(parameters, "limit");
@@ -1196,7 +1196,14 @@ var collectNodes = (reads) => {
1196
1196
  node.errorMessage = read.errorMessage;
1197
1197
  }
1198
1198
  }
1199
- return [...byPath.values()];
1199
+ const directoryOrder = /* @__PURE__ */ new Map();
1200
+ for (const node of byPath.values()) {
1201
+ if (!directoryOrder.has(node.directory))
1202
+ directoryOrder.set(node.directory, directoryOrder.size);
1203
+ }
1204
+ return [...byPath.values()].sort(
1205
+ (left, right) => (directoryOrder.get(left.directory) ?? 0) - (directoryOrder.get(right.directory) ?? 0)
1206
+ );
1200
1207
  };
1201
1208
  var toneByStatus = {
1202
1209
  completed: CampUiTone.success,
@@ -10643,16 +10643,42 @@ var currentDirectToolSandbox = () => {
10643
10643
  cached2 ??= detectDirectToolSandbox();
10644
10644
  return cached2;
10645
10645
  };
10646
+ var DIRECT_TOOL_SANDBOX_STATUS_FD = 3;
10646
10647
  var directToolSandboxCommand = (sandbox2, executablePath, args, options4) => sandbox2.kind === DirectToolSandboxKind.bubblewrap && sandbox2.command !== void 0 ? {
10647
10648
  command: sandbox2.command,
10648
- args: [...sandboxArguments(options4.cwd, true), executablePath, ...args]
10649
+ args: [
10650
+ "--json-status-fd",
10651
+ String(DIRECT_TOOL_SANDBOX_STATUS_FD),
10652
+ ...sandboxArguments(options4.cwd, true),
10653
+ executablePath,
10654
+ ...args
10655
+ ],
10656
+ statusFd: DIRECT_TOOL_SANDBOX_STATUS_FD
10649
10657
  } : { command: executablePath, args };
10650
- var isDirectToolSandboxFailure = (stderr3) => stderr3.startsWith("bwrap:");
10658
+ var parseDirectToolSandboxStatus = (status) => {
10659
+ let started = false;
10660
+ let exitCode3;
10661
+ for (const line of status.split("\n")) {
10662
+ const trimmed = line.trim();
10663
+ if (trimmed === "") continue;
10664
+ let document;
10665
+ try {
10666
+ document = JSON.parse(trimmed);
10667
+ } catch {
10668
+ continue;
10669
+ }
10670
+ if (typeof document !== "object" || document === null) continue;
10671
+ if ("child-pid" in document) started = true;
10672
+ const reported = document["exit-code"];
10673
+ if (typeof reported === "number") exitCode3 = reported;
10674
+ }
10675
+ return { started, ...exitCode3 === void 0 ? {} : { exitCode: exitCode3 } };
10676
+ };
10651
10677
  var describeDirectToolSandbox = (sandbox2) => sandbox2.kind === DirectToolSandboxKind.bubblewrap ? "External binaries run in a bubblewrap sandbox: read-only filesystem, writable worker directory, no network" : sandbox2.absence === DirectToolSandboxAbsence.disabled ? `External binaries run without an OS sandbox: disabled by ${DIRECT_TOOL_SANDBOX_ENV}` : sandbox2.absence === DirectToolSandboxAbsence.unsupportedPlatform ? `External binaries run without an OS sandbox: no supported mechanism on ${sandbox2.detail ?? "this platform"}` : sandbox2.absence === DirectToolSandboxAbsence.binaryMissing ? "External binaries run without an OS sandbox: bubblewrap (bwrap) is not installed" : "External binaries run without an OS sandbox: bubblewrap is present but cannot start";
10652
10678
 
10653
10679
  // packages/protocol/src/domain/protocolVersion.ts
10654
10680
  var PRIIISK_PROTOCOL_VERSION = "11";
10655
- var PRIIISK_PROTOCOL_PACKAGE_VERSION = "0.1.4";
10681
+ var PRIIISK_PROTOCOL_PACKAGE_VERSION = "0.1.6";
10656
10682
  var ProtocolVersionSchema = Schema_exports.String.pipe(Schema_exports.minLength(1));
10657
10683
 
10658
10684
  // packages/protocol/src/domain/protocolIdentifiers.ts
@@ -13527,7 +13553,7 @@ var CampProtocol = class extends RpcGroup_exports.make(
13527
13553
  };
13528
13554
 
13529
13555
  // packages/camp-state/src/bootstrap/campHostVersion.ts
13530
- var PRIIISK_HOST_VERSION = "0.1.4";
13556
+ var PRIIISK_HOST_VERSION = "0.1.6";
13531
13557
 
13532
13558
  // packages/surface/src/domain/surfaceModel.ts
13533
13559
  var NonEmptyString7 = Schema_exports.String.pipe(Schema_exports.minLength(1));
@@ -14909,7 +14935,7 @@ export {
14909
14935
  resolveExecutablePath,
14910
14936
  currentDirectToolSandbox,
14911
14937
  directToolSandboxCommand,
14912
- isDirectToolSandboxFailure,
14938
+ parseDirectToolSandboxStatus,
14913
14939
  describeDirectToolSandbox,
14914
14940
  NetSocket,
14915
14941
  fromDuplex,
@@ -28,7 +28,7 @@ import {
28
28
  makePlatform,
29
29
  makeRunMain,
30
30
  stdin
31
- } from "./chunk-QX5EESCS.js";
31
+ } from "./chunk-3NSS6BZD.js";
32
32
  import {
33
33
  BaseProto,
34
34
  __export,
@@ -84,7 +84,7 @@ import {
84
84
  selectCampRun,
85
85
  styleCampUiTone,
86
86
  uniqueCampUiNames
87
- } from "./chunk-62BTCFUO.js";
87
+ } from "./chunk-32R4IEGS.js";
88
88
  import "./chunk-KFSFN6L5.js";
89
89
  export {
90
90
  CAMP_UI_BASH_PREVIEW_LINES,
@@ -20,7 +20,7 @@ import {
20
20
  layerNet,
21
21
  makeCampSurfaceName,
22
22
  resolveProjectScopeSync
23
- } from "./chunk-QX5EESCS.js";
23
+ } from "./chunk-3NSS6BZD.js";
24
24
  import {
25
25
  Clock_exports,
26
26
  Config_exports,
@@ -111,7 +111,7 @@ var CliSurfaceSelectionError = class extends Data_exports.TaggedError("CliSurfac
111
111
  import { randomUUID } from "node:crypto";
112
112
 
113
113
  // packages/cli/src/domain/cliVersion.ts
114
- var PRIIISK_CLI_VERSION = "0.1.4";
114
+ var PRIIISK_CLI_VERSION = "0.1.6";
115
115
 
116
116
  // packages/cli/src/client/campRpcConnection.ts
117
117
  var PRIIISK_CONTROLLER_ID_ENV = "PRIIISK_CONTROLLER_ID";
@@ -8,13 +8,13 @@ import {
8
8
  makeDoctorReport,
9
9
  resolveCampSurface,
10
10
  withCampRpc
11
- } from "./chunk-XI3HWC7Q.js";
11
+ } from "./chunk-UDDSOI3H.js";
12
12
  import {
13
13
  PI_RUNTIME_VERSION,
14
14
  PiModelCatalogIssueCode,
15
15
  inspectPiModelCatalog,
16
16
  makePiOperatorResources
17
- } from "./chunk-44I2RCT5.js";
17
+ } from "./chunk-ZNRMKVX3.js";
18
18
  import {
19
19
  CampHealthComponentStatus,
20
20
  CampHealthOverallStatus,
@@ -48,7 +48,7 @@ import {
48
48
  resolveCredentialsPath,
49
49
  resolveProjectScope,
50
50
  resolveWorkerConfigPath
51
- } from "./chunk-QX5EESCS.js";
51
+ } from "./chunk-3NSS6BZD.js";
52
52
  import {
53
53
  Clock_exports,
54
54
  Effect_exports,
@@ -3,7 +3,7 @@ const require = __priiiskCreateRequire(import.meta.url);
3
3
  import {
4
4
  FileSystem_exports,
5
5
  PRIIISK_PI_AGENT_DIR_ENV
6
- } from "./chunk-QX5EESCS.js";
6
+ } from "./chunk-3NSS6BZD.js";
7
7
  import {
8
8
  CampDeliveryPort,
9
9
  CampFailureCode,
@@ -4,14 +4,14 @@ const require = __priiiskCreateRequire(import.meta.url);
4
4
  import {
5
5
  NodeContext_exports,
6
6
  NodeRuntime_exports
7
- } from "./chunk-GLWKYPVL.js";
7
+ } from "./chunk-JWVO4S72.js";
8
8
  import {
9
9
  CampUiBackendError,
10
10
  CampUiHealthStatus,
11
11
  CampUiPlacement,
12
12
  CampUiRuntimeStatus,
13
13
  mountPiCampUi
14
- } from "./chunk-62BTCFUO.js";
14
+ } from "./chunk-32R4IEGS.js";
15
15
  import {
16
16
  PiTransport,
17
17
  makePiOperatorResources,
@@ -19,7 +19,7 @@ import {
19
19
  makePiTransportLayer,
20
20
  requirePiModelCatalog,
21
21
  require_undici
22
- } from "./chunk-44I2RCT5.js";
22
+ } from "./chunk-ZNRMKVX3.js";
23
23
  import {
24
24
  AgentRole,
25
25
  AgentRoleSchema,
@@ -73,11 +73,11 @@ import {
73
73
  fromDuplex,
74
74
  fromWebSocket,
75
75
  hostStoppedCampManifest,
76
- isDirectToolSandboxFailure,
77
76
  listWorkerModelCatalogEntries,
78
77
  loadCampManifest,
79
78
  loadReferencedMcpCredentials,
80
79
  loadWorkerConfig,
80
+ parseDirectToolSandboxStatus,
81
81
  prepareCampRunStorage,
82
82
  prepareCampStorage,
83
83
  projectScopeFromCwd,
@@ -100,7 +100,7 @@ import {
100
100
  runningCampManifest,
101
101
  saveCampHealth,
102
102
  saveCampManifest
103
- } from "./chunk-QX5EESCS.js";
103
+ } from "./chunk-3NSS6BZD.js";
104
104
  import {
105
105
  CampAskRouter,
106
106
  CampCancellationCode,
@@ -11198,7 +11198,7 @@ var require_cross_spawn = __commonJS({
11198
11198
  var cp = __require("child_process");
11199
11199
  var parse3 = require_parse();
11200
11200
  var enoent = require_enoent();
11201
- function spawn2(command, args, options) {
11201
+ function spawn3(command, args, options) {
11202
11202
  const parsed = parse3(command, args, options);
11203
11203
  const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
11204
11204
  enoent.hookChildProcess(spawned, parsed);
@@ -11210,8 +11210,8 @@ var require_cross_spawn = __commonJS({
11210
11210
  result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
11211
11211
  return result;
11212
11212
  }
11213
- module.exports = spawn2;
11214
- module.exports.spawn = spawn2;
11213
+ module.exports = spawn3;
11214
+ module.exports.spawn = spawn3;
11215
11215
  module.exports.sync = spawnSync;
11216
11216
  module.exports._parse = parse3;
11217
11217
  module.exports._enoent = enoent;
@@ -22416,7 +22416,7 @@ var Client = class extends Protocol {
22416
22416
  };
22417
22417
 
22418
22418
  // packages/mcp-backend/src/connections/clientIdentity.ts
22419
- var backendVersion = "0.1.4";
22419
+ var backendVersion = "0.1.6";
22420
22420
 
22421
22421
  // packages/mcp-backend/src/connections/mcpFailure.ts
22422
22422
  var McpFailure = class extends Data_exports.TaggedError("McpFailure") {
@@ -26376,7 +26376,7 @@ var makeCampRpcServerLayer = (socketPath) => {
26376
26376
  };
26377
26377
 
26378
26378
  // packages/host/src/tools/directTools.ts
26379
- import { execFile } from "node:child_process";
26379
+ import { spawn as spawn2 } from "node:child_process";
26380
26380
 
26381
26381
  // packages/host/src/tools/directToolPolicy.ts
26382
26382
  var flagName = (argument) => {
@@ -26391,7 +26391,19 @@ var violatesFlag = (argument, denied) => {
26391
26391
  const letter = denied.charAt(1);
26392
26392
  return !name.startsWith("--") && name.slice(1).includes(letter);
26393
26393
  };
26394
- var findSubcommand = (args) => args.find((argument) => !argument.startsWith("-"));
26394
+ var findSubcommand = (args, allowed) => {
26395
+ let previousWasFlag = false;
26396
+ for (const argument of args) {
26397
+ if (argument.startsWith("-")) {
26398
+ previousWasFlag = !argument.includes("=");
26399
+ continue;
26400
+ }
26401
+ if (allowed.includes(argument)) return argument;
26402
+ if (!previousWasFlag) return argument;
26403
+ previousWasFlag = false;
26404
+ }
26405
+ return void 0;
26406
+ };
26395
26407
  var checkDirectToolArguments = (policy, args) => {
26396
26408
  const invalid = args.find((argument) => argument.includes("\0"));
26397
26409
  if (invalid !== void 0) return { reason: "invalid_argument", argument: invalid };
@@ -26400,7 +26412,7 @@ var checkDirectToolArguments = (policy, args) => {
26400
26412
  if (denied !== void 0) return { reason: "denied_flag", argument: denied };
26401
26413
  }
26402
26414
  if (policy.allowedSubcommands === void 0) return void 0;
26403
- const subcommand = findSubcommand(args);
26415
+ const subcommand = findSubcommand(args, policy.allowedSubcommands);
26404
26416
  if (subcommand === void 0) return { reason: "missing_subcommand" };
26405
26417
  return policy.allowedSubcommands.includes(subcommand) ? void 0 : { reason: "unknown_subcommand", argument: subcommand };
26406
26418
  };
@@ -26423,34 +26435,70 @@ var truncate = (value, limit) => {
26423
26435
  return encoded.byteLength <= limit ? { text: value, truncated: false } : { text: encoded.subarray(0, limit).toString("utf8"), truncated: true };
26424
26436
  };
26425
26437
  var binaryCandidates = (bin) => bin === "fd" ? ["fd", "fdfind"] : [bin];
26438
+ var collect = (stream, onOverflow) => {
26439
+ const chunks = [];
26440
+ let size = 0;
26441
+ let overflowed = false;
26442
+ stream?.on("data", (chunk) => {
26443
+ if (overflowed) return;
26444
+ size += chunk.byteLength;
26445
+ if (size > MAX_BUFFER_BYTES) {
26446
+ overflowed = true;
26447
+ onOverflow();
26448
+ return;
26449
+ }
26450
+ chunks.push(chunk);
26451
+ });
26452
+ return { text: () => Buffer.concat(chunks).toString("utf8") };
26453
+ };
26426
26454
  var runBinary = (executablePath, args, options, environment, signal) => {
26427
26455
  const sandbox = options.sandbox ?? currentDirectToolSandbox();
26428
26456
  const launch = directToolSandboxCommand(sandbox, executablePath, args, { cwd: options.cwd });
26457
+ const sandboxed = launch.statusFd !== void 0;
26429
26458
  return new Promise((resolve) => {
26430
- const child = execFile(
26431
- launch.command,
26432
- [...launch.args],
26433
- {
26434
- cwd: options.cwd,
26435
- env: environment,
26436
- timeout: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
26437
- maxBuffer: MAX_BUFFER_BYTES,
26438
- ...signal === void 0 ? {} : { signal }
26439
- },
26440
- (error2, stdout, stderr) => {
26441
- const failure = error2;
26442
- const sandboxed = launch.command !== executablePath;
26443
- resolve({
26444
- stdout,
26445
- stderr,
26446
- exitCode: typeof failure?.code === "number" ? failure.code : failure === null ? 0 : 1,
26447
- signal: child.signalCode ?? void 0,
26448
- timedOut: failure?.killed === true,
26449
- ...sandboxed && isDirectToolSandboxFailure(stderr) ? { sandboxFailed: true } : {},
26450
- ...typeof failure?.code === "string" && failure.code !== "" ? { launchError: `${failure.code}: ${failure.message}` } : {}
26451
- });
26452
- }
26459
+ const child = spawn2(launch.command, [...launch.args], {
26460
+ cwd: options.cwd,
26461
+ env: environment,
26462
+ stdio: sandboxed ? ["ignore", "pipe", "pipe", "pipe"] : ["ignore", "pipe", "pipe"],
26463
+ ...signal === void 0 ? {} : { signal }
26464
+ });
26465
+ let timedOut = false;
26466
+ let launchError;
26467
+ const stop = () => {
26468
+ child.kill("SIGTERM");
26469
+ };
26470
+ const stdout = collect(child.stdout, stop);
26471
+ const stderr = collect(child.stderr, stop);
26472
+ const status = collect(
26473
+ sandboxed ? child.stdio[launch.statusFd ?? 3] ?? null : null,
26474
+ stop
26453
26475
  );
26476
+ const timer = setTimeout(() => {
26477
+ timedOut = true;
26478
+ stop();
26479
+ }, options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
26480
+ child.on("error", (cause) => {
26481
+ if (signal?.aborted === true || cause.name === "AbortError") return;
26482
+ launchError = `${cause.code ?? cause.name}: ${cause.message}`;
26483
+ });
26484
+ child.on("close", (code, terminatedBy) => {
26485
+ clearTimeout(timer);
26486
+ const sandboxStatus = sandboxed ? parseDirectToolSandboxStatus(status.text()) : void 0;
26487
+ resolve({
26488
+ stdout: stdout.text(),
26489
+ stderr: stderr.text(),
26490
+ exitCode: sandboxStatus?.exitCode ?? code ?? void 0,
26491
+ signal: terminatedBy ?? void 0,
26492
+ timedOut,
26493
+ /*
26494
+ * A sandbox that never reached the command is only a refusal when the
26495
+ * command was not stopped from the outside: a killed sandbox reports no
26496
+ * child either, and that is the timeout, not the boundary.
26497
+ */
26498
+ ...sandboxStatus !== void 0 && !sandboxStatus.started && !timedOut && launchError === void 0 ? { sandboxFailed: true } : {},
26499
+ ...launchError === void 0 ? {} : { launchError }
26500
+ });
26501
+ });
26454
26502
  });
26455
26503
  };
26456
26504
  var runWithFallback = async (policy, args, options, signal) => {
package/dist/priiisk.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  fromReadable,
6
6
  layer,
7
7
  runMain
8
- } from "./chunk-GLWKYPVL.js";
8
+ } from "./chunk-JWVO4S72.js";
9
9
  import {
10
10
  CliCampLifecycleError,
11
11
  CliEquipmentConflict,
@@ -23,7 +23,7 @@ import {
23
23
  resolveCampSurface,
24
24
  withCampRpc,
25
25
  withCampRpcSession
26
- } from "./chunk-XI3HWC7Q.js";
26
+ } from "./chunk-UDDSOI3H.js";
27
27
  import {
28
28
  CampCommandFailure,
29
29
  CampHostReadiness,
@@ -58,7 +58,7 @@ import {
58
58
  resolveProjectScopeSync,
59
59
  saveCampManifest,
60
60
  startingCampManifest
61
- } from "./chunk-QX5EESCS.js";
61
+ } from "./chunk-3NSS6BZD.js";
62
62
  import {
63
63
  Cause_exports,
64
64
  CommitPrototype,
@@ -19903,7 +19903,7 @@ var campResumeListCommand = Command_exports.make(
19903
19903
  )
19904
19904
  ).pipe(Command_exports.withDescription("Lists saved runs of this project that resume can restore."));
19905
19905
  var runIdArgument = Args_exports.text({ name: "runId" }).pipe(Args_exports.optional);
19906
- var selectCampRunOnDemand = (items) => Effect_exports.promise(() => import("./chunk-JFAW425C.js")).pipe(
19906
+ var selectCampRunOnDemand = (items) => Effect_exports.promise(() => import("./chunk-TOVFB7H6.js")).pipe(
19907
19907
  Effect_exports.flatMap((ui) => ui.selectCampRun({ items }))
19908
19908
  );
19909
19909
  var selectAndResume = (json) => {
@@ -19976,7 +19976,7 @@ var rootCommand = Command_exports.make(
19976
19976
  ).pipe(Command_exports.withDescription("Runs and observes a camp of collaborating workers."));
19977
19977
 
19978
19978
  // packages/cli/src/commands/doctorCommand.ts
19979
- var runDoctorOnDemand = Effect_exports.promise(() => import("./chunk-GZTHKLSX.js")).pipe(
19979
+ var runDoctorOnDemand = Effect_exports.promise(() => import("./chunk-X4GVQOCR.js")).pipe(
19980
19980
  Effect_exports.flatMap((doctor) => doctor.runDoctor)
19981
19981
  );
19982
19982
  var statusLabel = {
@@ -20672,7 +20672,7 @@ var command = rootCommand.pipe(
20672
20672
  );
20673
20673
  var cli = Command_exports.run(command, {
20674
20674
  name: "priiisk camp control",
20675
- version: "0.1.4"
20675
+ version: "0.1.6"
20676
20676
  });
20677
20677
  var runCliCommand = (argumentsList) => cli(argumentsList).pipe(
20678
20678
  Effect_exports.matchEffect({
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "priiisk",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "CLI for running and observing a camp of collaborating agents",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "priiisk": "./dist/priiisk.js"
8
8
  },
9
9
  "files": [
10
- "dist/chunk-44I2RCT5.js",
11
- "dist/chunk-44I2RCT5.js.LEGAL.txt",
12
- "dist/chunk-62BTCFUO.js",
13
- "dist/chunk-GLWKYPVL.js",
14
- "dist/chunk-GZTHKLSX.js",
15
- "dist/chunk-JFAW425C.js",
10
+ "dist/chunk-32R4IEGS.js",
11
+ "dist/chunk-3NSS6BZD.js",
12
+ "dist/chunk-3NSS6BZD.js.LEGAL.txt",
13
+ "dist/chunk-JWVO4S72.js",
16
14
  "dist/chunk-KFSFN6L5.js",
17
- "dist/chunk-QX5EESCS.js",
18
- "dist/chunk-QX5EESCS.js.LEGAL.txt",
19
- "dist/chunk-XI3HWC7Q.js",
15
+ "dist/chunk-TOVFB7H6.js",
16
+ "dist/chunk-UDDSOI3H.js",
17
+ "dist/chunk-X4GVQOCR.js",
18
+ "dist/chunk-ZNRMKVX3.js",
19
+ "dist/chunk-ZNRMKVX3.js.LEGAL.txt",
20
20
  "dist/priiisk-host.js",
21
21
  "dist/priiisk.js",
22
22
  "profiles",