@granular-software/sdk 0.4.31 → 0.4.32

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.
@@ -1,4 +1,4 @@
1
- import { P as Prompt, f as EnvironmentSession, c as SessionHeapSnapshot, b8 as ManifestContent, aG as RecordObjectOptions, T as ToolWithHandler, G as Granular, C as ConnectOptions, J as CreateEnvironmentData, k as GranularOptions } from './client-CTH1hfwe.mjs';
1
+ import { P as Prompt, f as EnvironmentSession, c as SessionHeapSnapshot, b8 as ManifestContent, aG as RecordObjectOptions, T as ToolWithHandler, G as Granular, C as ConnectOptions, J as CreateEnvironmentData, k as GranularOptions } from './client-C2Gk641P.mjs';
2
2
  import { GeneratedJobCodeIssue, HarnessControllerBudgets } from './agent-harness.mjs';
3
3
  import '@automerge/automerge';
4
4
  import '@automerge/automerge/slim';
@@ -1,4 +1,4 @@
1
- import { P as Prompt, f as EnvironmentSession, c as SessionHeapSnapshot, b8 as ManifestContent, aG as RecordObjectOptions, T as ToolWithHandler, G as Granular, C as ConnectOptions, J as CreateEnvironmentData, k as GranularOptions } from './client-CTH1hfwe.js';
1
+ import { P as Prompt, f as EnvironmentSession, c as SessionHeapSnapshot, b8 as ManifestContent, aG as RecordObjectOptions, T as ToolWithHandler, G as Granular, C as ConnectOptions, J as CreateEnvironmentData, k as GranularOptions } from './client-C2Gk641P.js';
2
2
  import { GeneratedJobCodeIssue, HarnessControllerBudgets } from './agent-harness.js';
3
3
  import '@automerge/automerge';
4
4
  import '@automerge/automerge/slim';
@@ -4010,7 +4010,11 @@ var WSClient = class {
4010
4010
  return null;
4011
4011
  }
4012
4012
  try {
4013
- const payloadRaw = this.decodeBase64Url(parts[1]);
4013
+ const payloadSegment = parts[1];
4014
+ if (!payloadSegment) {
4015
+ return null;
4016
+ }
4017
+ const payloadRaw = this.decodeBase64Url(payloadSegment);
4014
4018
  const payload = JSON.parse(payloadRaw);
4015
4019
  if (typeof payload.exp !== "number" || !Number.isFinite(payload.exp)) {
4016
4020
  return null;
@@ -5087,6 +5091,7 @@ import { ${allImports} } from "./sandbox-tools";
5087
5091
  this.eventListeners.set(event, []);
5088
5092
  }
5089
5093
  this.eventListeners.get(event).push(handler);
5094
+ return () => this.off(event, handler);
5090
5095
  }
5091
5096
  /**
5092
5097
  * Unsubscribe from session events
@@ -5543,6 +5548,16 @@ var JobImplementation = class {
5543
5548
  handler(message);
5544
5549
  }
5545
5550
  }
5551
+ return () => {
5552
+ const handlers = this.eventListeners.get(event);
5553
+ if (!handlers) {
5554
+ return;
5555
+ }
5556
+ this.eventListeners.set(
5557
+ event,
5558
+ handlers.filter((current) => current !== handler)
5559
+ );
5560
+ };
5546
5561
  }
5547
5562
  replayAgentMessage(message) {
5548
5563
  this.captureAgentMessage(message);
@@ -12089,7 +12104,9 @@ var Environment = class {
12089
12104
  }
12090
12105
  );
12091
12106
  if (result.errors?.length) {
12092
- throw new Error(`defineRelationship failed: ${result.errors[0].message}`);
12107
+ throw new Error(
12108
+ `defineRelationship failed: ${result.errors[0]?.message ?? "Unknown GraphQL error"}`
12109
+ );
12093
12110
  }
12094
12111
  return result.data.at.define_relationship;
12095
12112
  }
@@ -12125,7 +12142,9 @@ var Environment = class {
12125
12142
  { path: modelPath }
12126
12143
  );
12127
12144
  if (result.errors?.length) {
12128
- throw new Error(`getRelationships failed: ${result.errors[0].message}`);
12145
+ throw new Error(
12146
+ `getRelationships failed: ${result.errors[0]?.message ?? "Unknown GraphQL error"}`
12147
+ );
12129
12148
  }
12130
12149
  return result.data?.model?.relationships || [];
12131
12150
  }
@@ -12164,7 +12183,7 @@ var Environment = class {
12164
12183
  { target: targetPath }
12165
12184
  );
12166
12185
  if (result.errors?.length) {
12167
- throw new Error(`attach failed: ${result.errors[0].message}`);
12186
+ throw new Error(`attach failed: ${result.errors[0]?.message ?? "Unknown GraphQL error"}`);
12168
12187
  }
12169
12188
  }
12170
12189
  /**
@@ -12199,7 +12218,7 @@ var Environment = class {
12199
12218
  }`
12200
12219
  );
12201
12220
  if (result.errors?.length) {
12202
- throw new Error(`detach failed: ${result.errors[0].message}`);
12221
+ throw new Error(`detach failed: ${result.errors[0]?.message ?? "Unknown GraphQL error"}`);
12203
12222
  }
12204
12223
  }
12205
12224
  /**
@@ -12226,7 +12245,9 @@ var Environment = class {
12226
12245
  }`
12227
12246
  );
12228
12247
  if (result.errors?.length) {
12229
- throw new Error(`listRelated failed: ${result.errors[0].message}`);
12248
+ throw new Error(
12249
+ `listRelated failed: ${result.errors[0]?.message ?? "Unknown GraphQL error"}`
12250
+ );
12230
12251
  }
12231
12252
  return result.data?.at?.at?.list_related || [];
12232
12253
  }
@@ -12319,7 +12340,7 @@ var Environment = class {
12319
12340
  async _runGraphql(query, label) {
12320
12341
  const result = await this.graphql(query);
12321
12342
  if (result.errors?.length) {
12322
- throw new Error(`${label}: ${result.errors[0].message}`);
12343
+ throw new Error(`${label}: ${result.errors[0]?.message ?? "Unknown GraphQL error"}`);
12323
12344
  }
12324
12345
  return result.data;
12325
12346
  }
@@ -12664,7 +12685,11 @@ var Environment = class {
12664
12685
  */
12665
12686
  async recordObject(options) {
12666
12687
  const results = await this.recordObjects([options]);
12667
- return results[0];
12688
+ const result = results[0];
12689
+ if (!result) {
12690
+ throw new Error("recordObject: no result returned for record");
12691
+ }
12692
+ return result;
12668
12693
  }
12669
12694
  /**
12670
12695
  * Batch version of `recordObject()`.
@@ -12716,7 +12741,13 @@ var Environment = class {
12716
12741
  );
12717
12742
  }
12718
12743
  for (let index = 0; index < items.length; index += 1) {
12719
- results[plan.offset + index] = items[index];
12744
+ const item = items[index];
12745
+ if (!item) {
12746
+ throw new Error(
12747
+ `recordObjects: chunk ${plan.chunkIndex + 1} returned an empty result at index ${index}`
12748
+ );
12749
+ }
12750
+ results[plan.offset + index] = item;
12720
12751
  }
12721
12752
  if (onChunk) {
12722
12753
  const info = {