@primitive.ai/prim 0.1.0-alpha.100 → 0.1.0-alpha.102

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.
@@ -20626,6 +20626,7 @@ function pendingJournalStats() {
20626
20626
  // src/flusher.ts
20627
20627
  var BATCH_SIZE = 500;
20628
20628
  var BATCH_MAX_BYTES = 1048576;
20629
+ var MAX_INGEST_REQUEST_BYTES = 4 * 1048576;
20629
20630
  var HTTP_TIMEOUT_MS = 1e4;
20630
20631
  var ORPHAN_QUARANTINE_MS = 6e4;
20631
20632
  function exceedsBatchBytes(count, bytes, nextBytes, maxBytes) {
@@ -20653,7 +20654,16 @@ function isVersionedInvalidMoveDisposition(body) {
20653
20654
  const record = body;
20654
20655
  return Object.keys(record).length === 2 && record.error === "invalid_move" && record.errorVersion === 1;
20655
20656
  }
20657
+ var IngestRequestTooLargeError = class extends Error {
20658
+ constructor() {
20659
+ super("ingest request exceeds the server body limit");
20660
+ this.name = "IngestRequestTooLargeError";
20661
+ }
20662
+ };
20656
20663
  function deadLetterReason(error) {
20664
+ if (error instanceof IngestRequestTooLargeError) {
20665
+ return "oversized_move";
20666
+ }
20657
20667
  if (error instanceof InvalidJournalEnvelopeError) {
20658
20668
  return "invalid_move";
20659
20669
  }
@@ -20663,6 +20673,9 @@ function deadLetterReason(error) {
20663
20673
  if (error.status === 400 && isVersionedInvalidMoveDisposition(error.body)) {
20664
20674
  return "invalid_move";
20665
20675
  }
20676
+ if (error.status === 413 && typeof error.body === "object" && error.body !== null && !Array.isArray(error.body) && error.body.error === "ingest_batch_too_large") {
20677
+ return "oversized_move";
20678
+ }
20666
20679
  if (error.status === 409 && typeof error.body === "object" && error.body !== null && !Array.isArray(error.body)) {
20667
20680
  const errorCode = error.body.error;
20668
20681
  if (errorCode === "move_id_conflict") {
@@ -20742,6 +20755,9 @@ async function drainFlushingPath(flushingPath, client2, binding, options = {}) {
20742
20755
  const moves = batch2.map((entry) => entry.move);
20743
20756
  try {
20744
20757
  const request2 = buildOrganizationBoundMoveRequest(moves, binding);
20758
+ if (Buffer.byteLength(JSON.stringify(request2)) > MAX_INGEST_REQUEST_BYTES) {
20759
+ throw new IngestRequestTooLargeError();
20760
+ }
20745
20761
  const response = await client2.post("/api/cli/moves/ingest", request2, {
20746
20762
  signal: AbortSignal.timeout(HTTP_TIMEOUT_MS)
20747
20763
  });
@@ -20626,6 +20626,7 @@ function pendingJournalStats() {
20626
20626
  // src/flusher.ts
20627
20627
  var BATCH_SIZE = 500;
20628
20628
  var BATCH_MAX_BYTES = 1048576;
20629
+ var MAX_INGEST_REQUEST_BYTES = 4 * 1048576;
20629
20630
  var HTTP_TIMEOUT_MS = 1e4;
20630
20631
  var ORPHAN_QUARANTINE_MS = 6e4;
20631
20632
  function exceedsBatchBytes(count, bytes, nextBytes, maxBytes) {
@@ -20653,7 +20654,16 @@ function isVersionedInvalidMoveDisposition(body) {
20653
20654
  const record = body;
20654
20655
  return Object.keys(record).length === 2 && record.error === "invalid_move" && record.errorVersion === 1;
20655
20656
  }
20657
+ var IngestRequestTooLargeError = class extends Error {
20658
+ constructor() {
20659
+ super("ingest request exceeds the server body limit");
20660
+ this.name = "IngestRequestTooLargeError";
20661
+ }
20662
+ };
20656
20663
  function deadLetterReason(error) {
20664
+ if (error instanceof IngestRequestTooLargeError) {
20665
+ return "oversized_move";
20666
+ }
20657
20667
  if (error instanceof InvalidJournalEnvelopeError) {
20658
20668
  return "invalid_move";
20659
20669
  }
@@ -20663,6 +20673,9 @@ function deadLetterReason(error) {
20663
20673
  if (error.status === 400 && isVersionedInvalidMoveDisposition(error.body)) {
20664
20674
  return "invalid_move";
20665
20675
  }
20676
+ if (error.status === 413 && typeof error.body === "object" && error.body !== null && !Array.isArray(error.body) && error.body.error === "ingest_batch_too_large") {
20677
+ return "oversized_move";
20678
+ }
20666
20679
  if (error.status === 409 && typeof error.body === "object" && error.body !== null && !Array.isArray(error.body)) {
20667
20680
  const errorCode = error.body.error;
20668
20681
  if (errorCode === "move_id_conflict") {
@@ -20742,6 +20755,9 @@ async function drainFlushingPath(flushingPath, client2, binding, options = {}) {
20742
20755
  const moves = batch2.map((entry) => entry.move);
20743
20756
  try {
20744
20757
  const request2 = buildOrganizationBoundMoveRequest(moves, binding);
20758
+ if (Buffer.byteLength(JSON.stringify(request2)) > MAX_INGEST_REQUEST_BYTES) {
20759
+ throw new IngestRequestTooLargeError();
20760
+ }
20745
20761
  const response = await client2.post("/api/cli/moves/ingest", request2, {
20746
20762
  signal: AbortSignal.timeout(HTTP_TIMEOUT_MS)
20747
20763
  });
@@ -50773,6 +50773,7 @@ function requireDurableIngestAcknowledgement(value, expected, cwd = process.cwd(
50773
50773
  // src/flusher.ts
50774
50774
  var BATCH_SIZE = 500;
50775
50775
  var BATCH_MAX_BYTES = 1048576;
50776
+ var MAX_INGEST_REQUEST_BYTES = 4 * 1048576;
50776
50777
  var HTTP_TIMEOUT_MS = 1e4;
50777
50778
  var OPPORTUNISTIC_FLUSH_AFTER_MS = 6e4;
50778
50779
  var ORPHAN_QUARANTINE_MS = 6e4;
@@ -50801,7 +50802,16 @@ function isVersionedInvalidMoveDisposition(body) {
50801
50802
  const record3 = body;
50802
50803
  return Object.keys(record3).length === 2 && record3.error === "invalid_move" && record3.errorVersion === 1;
50803
50804
  }
50805
+ var IngestRequestTooLargeError = class extends Error {
50806
+ constructor() {
50807
+ super("ingest request exceeds the server body limit");
50808
+ this.name = "IngestRequestTooLargeError";
50809
+ }
50810
+ };
50804
50811
  function deadLetterReason(error) {
50812
+ if (error instanceof IngestRequestTooLargeError) {
50813
+ return "oversized_move";
50814
+ }
50805
50815
  if (error instanceof InvalidJournalEnvelopeError) {
50806
50816
  return "invalid_move";
50807
50817
  }
@@ -50811,6 +50821,9 @@ function deadLetterReason(error) {
50811
50821
  if (error.status === 400 && isVersionedInvalidMoveDisposition(error.body)) {
50812
50822
  return "invalid_move";
50813
50823
  }
50824
+ if (error.status === 413 && typeof error.body === "object" && error.body !== null && !Array.isArray(error.body) && error.body.error === "ingest_batch_too_large") {
50825
+ return "oversized_move";
50826
+ }
50814
50827
  if (error.status === 409 && typeof error.body === "object" && error.body !== null && !Array.isArray(error.body)) {
50815
50828
  const errorCode2 = error.body.error;
50816
50829
  if (errorCode2 === "move_id_conflict") {
@@ -50890,6 +50903,9 @@ async function drainFlushingPath(flushingPath, client, binding, options = {}) {
50890
50903
  const moves = batch2.map((entry) => entry.move);
50891
50904
  try {
50892
50905
  const request2 = buildOrganizationBoundMoveRequest(moves, binding);
50906
+ if (Buffer.byteLength(JSON.stringify(request2)) > MAX_INGEST_REQUEST_BYTES) {
50907
+ throw new IngestRequestTooLargeError();
50908
+ }
50893
50909
  const response = await client.post("/api/cli/moves/ingest", request2, {
50894
50910
  signal: AbortSignal.timeout(HTTP_TIMEOUT_MS)
50895
50911
  });
package/dist/index.js CHANGED
@@ -8211,6 +8211,7 @@ function quarantineRawLine(flushingPath, rawLine, now = Date.now, options = {})
8211
8211
  // src/flusher.ts
8212
8212
  var BATCH_SIZE = 500;
8213
8213
  var BATCH_MAX_BYTES = 1048576;
8214
+ var MAX_INGEST_REQUEST_BYTES = 4 * 1048576;
8214
8215
  var HTTP_TIMEOUT_MS = 1e4;
8215
8216
  var OPPORTUNISTIC_FLUSH_AFTER_MS = 6e4;
8216
8217
  var ORPHAN_QUARANTINE_MS = 6e4;
@@ -8239,7 +8240,16 @@ function isVersionedInvalidMoveDisposition(body) {
8239
8240
  const record3 = body;
8240
8241
  return Object.keys(record3).length === 2 && record3.error === "invalid_move" && record3.errorVersion === 1;
8241
8242
  }
8243
+ var IngestRequestTooLargeError = class extends Error {
8244
+ constructor() {
8245
+ super("ingest request exceeds the server body limit");
8246
+ this.name = "IngestRequestTooLargeError";
8247
+ }
8248
+ };
8242
8249
  function deadLetterReason(error) {
8250
+ if (error instanceof IngestRequestTooLargeError) {
8251
+ return "oversized_move";
8252
+ }
8243
8253
  if (error instanceof InvalidJournalEnvelopeError) {
8244
8254
  return "invalid_move";
8245
8255
  }
@@ -8249,6 +8259,9 @@ function deadLetterReason(error) {
8249
8259
  if (error.status === 400 && isVersionedInvalidMoveDisposition(error.body)) {
8250
8260
  return "invalid_move";
8251
8261
  }
8262
+ if (error.status === 413 && typeof error.body === "object" && error.body !== null && !Array.isArray(error.body) && error.body.error === "ingest_batch_too_large") {
8263
+ return "oversized_move";
8264
+ }
8252
8265
  if (error.status === 409 && typeof error.body === "object" && error.body !== null && !Array.isArray(error.body)) {
8253
8266
  const errorCode = error.body.error;
8254
8267
  if (errorCode === "move_id_conflict") {
@@ -8328,6 +8341,9 @@ async function drainFlushingPath(flushingPath, client, binding, options = {}) {
8328
8341
  const moves = batch2.map((entry) => entry.move);
8329
8342
  try {
8330
8343
  const request = buildOrganizationBoundMoveRequest(moves, binding);
8344
+ if (Buffer.byteLength(JSON.stringify(request)) > MAX_INGEST_REQUEST_BYTES) {
8345
+ throw new IngestRequestTooLargeError();
8346
+ }
8331
8347
  const response = await client.post("/api/cli/moves/ingest", request, {
8332
8348
  signal: AbortSignal.timeout(HTTP_TIMEOUT_MS)
8333
8349
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primitive.ai/prim",
3
- "version": "0.1.0-alpha.100",
3
+ "version": "0.1.0-alpha.102",
4
4
  "description": "CLI for Primitive's decision graph — passive decision capture, conflict gate, and team presence",
5
5
  "type": "module",
6
6
  "license": "MIT",