@granular-software/sdk 0.4.73 → 0.4.74

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,5 +1,5 @@
1
- import { a as EnvironmentSession, G as Granular } from './client-U0rb2nG5.mjs';
2
- import { aI as GranularSpendContext, aD as OpenAITokenSpend, n as Prompt, h as RecordObjectOptions, i as ManifestContent, m as SessionHeapSnapshot, T as ToolWithHandler, b2 as ConnectOptions, bs as CreateEnvironmentData, aX as GranularOptions } from './spend-k8V2Y1Tt.mjs';
1
+ import { a as EnvironmentSession, G as Granular } from './client-6d1OsWJf.mjs';
2
+ import { aI as GranularSpendContext, aD as OpenAITokenSpend, n as Prompt, h as RecordObjectOptions, i as ManifestContent, m as SessionHeapSnapshot, T as ToolWithHandler, b2 as ConnectOptions, bs as CreateEnvironmentData, aX as GranularOptions } from './spend-DBRQOSaj.mjs';
3
3
  import { GranularAgentToolInfo, GeneratedJobCodeIssue, BuildGranularAgentSystemPromptInput, HarnessRenderedPrompt, HarnessRenderedContinuation, HarnessControllerBudgets } from './agent-harness.mjs';
4
4
  import '@automerge/automerge';
5
5
  import '@automerge/automerge/slim';
@@ -1,5 +1,5 @@
1
- import { a as EnvironmentSession, G as Granular } from './client-WJrPOw6N.js';
2
- import { aI as GranularSpendContext, aD as OpenAITokenSpend, n as Prompt, h as RecordObjectOptions, i as ManifestContent, m as SessionHeapSnapshot, T as ToolWithHandler, b2 as ConnectOptions, bs as CreateEnvironmentData, aX as GranularOptions } from './spend-k8V2Y1Tt.js';
1
+ import { a as EnvironmentSession, G as Granular } from './client-DdEXINlv.js';
2
+ import { aI as GranularSpendContext, aD as OpenAITokenSpend, n as Prompt, h as RecordObjectOptions, i as ManifestContent, m as SessionHeapSnapshot, T as ToolWithHandler, b2 as ConnectOptions, bs as CreateEnvironmentData, aX as GranularOptions } from './spend-DBRQOSaj.js';
3
3
  import { GranularAgentToolInfo, GeneratedJobCodeIssue, BuildGranularAgentSystemPromptInput, HarnessRenderedPrompt, HarnessRenderedContinuation, HarnessControllerBudgets } from './agent-harness.js';
4
4
  import '@automerge/automerge';
5
5
  import '@automerge/automerge/slim';
@@ -16456,13 +16456,15 @@ var Environment = class _Environment {
16456
16456
  _apiEndpoint;
16457
16457
  _tokenProvider;
16458
16458
  _beforeMutationSend;
16459
- constructor(granular, envData, apiKey, apiEndpoint, tokenProvider, beforeMutationSend) {
16459
+ _graphqlIdempotencyKey;
16460
+ constructor(granular, envData, apiKey, apiEndpoint, tokenProvider, beforeMutationSend, graphqlIdempotencyKey) {
16460
16461
  this.granular = granular;
16461
16462
  this.envData = envData;
16462
16463
  this._apiKey = apiKey;
16463
16464
  this._apiEndpoint = apiEndpoint;
16464
16465
  this._tokenProvider = tokenProvider;
16465
16466
  this._beforeMutationSend = beforeMutationSend;
16467
+ this._graphqlIdempotencyKey = graphqlIdempotencyKey;
16466
16468
  }
16467
16469
  /** The environment ID */
16468
16470
  get environmentId() {
@@ -17005,11 +17007,13 @@ var Environment = class _Environment {
17005
17007
  if (this._beforeMutationSend && isGraphQLMutationDocument(query)) {
17006
17008
  this._beforeMutationSend?.();
17007
17009
  }
17010
+ const idempotencyKey = this._graphqlIdempotencyKey?.(query, variables);
17008
17011
  const response = await fetch(this._apiEndpoint, {
17009
17012
  method: "POST",
17010
17013
  headers: {
17011
17014
  "Content-Type": "application/json",
17012
- Authorization: `Bearer ${authToken}`
17015
+ Authorization: `Bearer ${authToken}`,
17016
+ ...idempotencyKey ? { "Idempotency-Key": idempotencyKey } : {}
17013
17017
  },
17014
17018
  body: JSON.stringify({
17015
17019
  environmentId: this.environmentId,
@@ -18583,6 +18587,7 @@ var Granular = class _Granular {
18583
18587
  onUnexpectedClose;
18584
18588
  onReconnectError;
18585
18589
  effectHostUrl;
18590
+ graphqlIdempotencyKey;
18586
18591
  debugHttp = process.env.GRANULAR_DEBUG_HTTP === "1";
18587
18592
  /** Sandbox-level effect registry: sandboxId → (effectKey@selector → ToolWithHandler) */
18588
18593
  sandboxEffects = /* @__PURE__ */ new Map();
@@ -18612,6 +18617,7 @@ var Granular = class _Granular {
18612
18617
  this.onUnexpectedClose = options.onUnexpectedClose;
18613
18618
  this.onReconnectError = options.onReconnectError;
18614
18619
  this.effectHostUrl = options.effectHostUrl;
18620
+ this.graphqlIdempotencyKey = options.graphqlIdempotencyKey;
18615
18621
  this.httpUrl = this.apiUrl.replace(/^wss:\/\//, "https://").replace(/^ws:\/\//, "http://").replace(/\/ws$/, "");
18616
18622
  }
18617
18623
  /**
@@ -19627,7 +19633,9 @@ var Granular = class _Granular {
19627
19633
  envData,
19628
19634
  this.apiKey,
19629
19635
  graphqlEndpoint,
19630
- this.tokenProvider
19636
+ this.tokenProvider,
19637
+ void 0,
19638
+ this.graphqlIdempotencyKey
19631
19639
  );
19632
19640
  }
19633
19641
  async bindWebSocketEnvironmentSession(environment, clientId, session, transportOptions = {}) {