pantheon-cli 0.2.72 → 0.2.75

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.
Files changed (2) hide show
  1. package/dist/pantheon.mjs +57 -11
  2. package/package.json +1 -1
package/dist/pantheon.mjs CHANGED
@@ -43701,6 +43701,7 @@ import { gzipSync } from "node:zlib";
43701
43701
  var DRIVE_MAX_FILE_BYTES = 200 * 1024 * 1024;
43702
43702
  var DRIVE_MAX_CHANGE_BYTES = 256 * 1024 * 1024;
43703
43703
  var DRIVE_MAX_CHANGES = 100;
43704
+ var DRIVE_MAX_REQUEST_BYTES = 3 * 1024 * 1024;
43704
43705
  var CONTROL_NAMES = /* @__PURE__ */ new Set([
43705
43706
  ".git",
43706
43707
  ".pantheon",
@@ -43891,17 +43892,62 @@ async function responseError(response) {
43891
43892
  );
43892
43893
  }
43893
43894
  async function publishOutbox(config2, credentials, outbox, fetcher) {
43894
- const response = await fetcher(`${config2.apiUrl}/api/cli/workspace/sync`, {
43895
- method: "POST",
43896
- headers: {
43897
- ...auth(config2, credentials),
43898
- "content-type": "application/json"
43899
- },
43900
- body: JSON.stringify(outbox),
43901
- signal: AbortSignal.timeout(3e4)
43902
- });
43903
- if (!response.ok) throw await responseError(response);
43904
- return await response.json();
43895
+ const requestBudget = DRIVE_MAX_REQUEST_BYTES - 256 * 1024;
43896
+ const groups = [];
43897
+ let group = [];
43898
+ let groupBytes = 0;
43899
+ for (const change of outbox.changes) {
43900
+ const bytes = Buffer.byteLength(JSON.stringify(change)) + 1;
43901
+ if (bytes > requestBudget) {
43902
+ throw new Error(
43903
+ `Compressed workspace file ${change.path} exceeds the Drive request limit.`
43904
+ );
43905
+ }
43906
+ if (group.length && groupBytes + bytes > requestBudget) {
43907
+ groups.push(group);
43908
+ group = [];
43909
+ groupBytes = 0;
43910
+ }
43911
+ group.push(change);
43912
+ groupBytes += bytes;
43913
+ }
43914
+ if (group.length || !groups.length) groups.push(group);
43915
+ let baseRevision = outbox.baseRevision;
43916
+ let published;
43917
+ let merged = false;
43918
+ for (let index = 0; index < groups.length; index += 1) {
43919
+ const requestId = groups.length === 1 ? outbox.requestId : `${outbox.requestId}.${index + 1}.${groups.length}`;
43920
+ const batch = {
43921
+ ...outbox,
43922
+ requestId,
43923
+ baseRevision,
43924
+ changes: groups[index],
43925
+ deletes: index === groups.length - 1 ? outbox.deletes : [],
43926
+ message: groups.length === 1 ? outbox.message : `${outbox.message || "Sync Pantheon vault"} (${index + 1}/${groups.length})`
43927
+ };
43928
+ const body = JSON.stringify(batch);
43929
+ if (Buffer.byteLength(body) > DRIVE_MAX_REQUEST_BYTES) {
43930
+ throw new Error("Drive sync batch exceeds the request limit.");
43931
+ }
43932
+ const response = await fetcher(`${config2.apiUrl}/api/cli/workspace/sync`, {
43933
+ method: "POST",
43934
+ headers: {
43935
+ ...auth(config2, credentials),
43936
+ "content-type": "application/json"
43937
+ },
43938
+ body,
43939
+ signal: AbortSignal.timeout(3e4)
43940
+ });
43941
+ if (!response.ok) throw await responseError(response);
43942
+ published = await response.json();
43943
+ baseRevision = published.revision;
43944
+ merged ||= Boolean(published.merged);
43945
+ }
43946
+ if (!published) throw new Error("Drive sync did not publish any batches.");
43947
+ return {
43948
+ ...published,
43949
+ ...merged ? { merged: true } : {}
43950
+ };
43905
43951
  }
43906
43952
  function httpDriveWorkspaceHooks(config2, credentials, fetcher = fetch) {
43907
43953
  const paths = driveWorkspaceStatePaths(config2.home);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pantheon-cli",
3
- "version": "0.2.72",
3
+ "version": "0.2.75",
4
4
  "description": "Carry agent conscience between AI coding agents. Hand off a conversation in one agent, resume it in another.",
5
5
  "license": "MIT",
6
6
  "type": "module",