@granular-software/sdk 0.4.75 → 0.4.76
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.
- package/dist/agent-evals.d.mts +1 -1
- package/dist/agent-evals.d.ts +1 -1
- package/dist/agent-evals.js +54 -8
- package/dist/agent-evals.js.map +1 -1
- package/dist/agent-evals.mjs +54 -8
- package/dist/agent-evals.mjs.map +1 -1
- package/dist/cli/index.js +55 -9
- package/dist/{client-CljnHfK3.d.mts → client-BZtpnc8M.d.mts} +7 -1
- package/dist/{client-Dbam34Zn.d.ts → client-C7bj1UeD.d.ts} +7 -1
- package/dist/index.d.mts +16 -3
- package/dist/index.d.ts +16 -3
- package/dist/index.js +55 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/agent-evals.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as Prompt, h as RecordObjectOptions, i as ManifestContent, t as EnvironmentSession, m as SessionHeapSnapshot, T as ToolWithHandler, G as Granular, a_ as ConnectOptions, be as CreateEnvironmentData, aY as GranularOptions } from './client-
|
|
1
|
+
import { n as Prompt, h as RecordObjectOptions, i as ManifestContent, t as EnvironmentSession, m as SessionHeapSnapshot, T as ToolWithHandler, G as Granular, a_ as ConnectOptions, be as CreateEnvironmentData, aY as GranularOptions } from './client-BZtpnc8M.mjs';
|
|
2
2
|
import { GranularAgentToolInfo, GeneratedJobCodeIssue, BuildGranularAgentSystemPromptInput, HarnessRenderedPrompt, HarnessRenderedContinuation, HarnessControllerBudgets } from './agent-harness.mjs';
|
|
3
3
|
import { G as GranularSpendContext, a as OpenAITokenSpend } from './spend-ZMtzJoMN.mjs';
|
|
4
4
|
import '@automerge/automerge';
|
package/dist/agent-evals.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as Prompt, h as RecordObjectOptions, i as ManifestContent, t as EnvironmentSession, m as SessionHeapSnapshot, T as ToolWithHandler, G as Granular, a_ as ConnectOptions, be as CreateEnvironmentData, aY as GranularOptions } from './client-
|
|
1
|
+
import { n as Prompt, h as RecordObjectOptions, i as ManifestContent, t as EnvironmentSession, m as SessionHeapSnapshot, T as ToolWithHandler, G as Granular, a_ as ConnectOptions, be as CreateEnvironmentData, aY as GranularOptions } from './client-C7bj1UeD.js';
|
|
2
2
|
import { GranularAgentToolInfo, GeneratedJobCodeIssue, BuildGranularAgentSystemPromptInput, HarnessRenderedPrompt, HarnessRenderedContinuation, HarnessControllerBudgets } from './agent-harness.js';
|
|
3
3
|
import { G as GranularSpendContext, a as OpenAITokenSpend } from './spend-ZMtzJoMN.js';
|
|
4
4
|
import '@automerge/automerge';
|
package/dist/agent-evals.js
CHANGED
|
@@ -4019,6 +4019,34 @@ var init_wrapper = __esm({
|
|
|
4019
4019
|
}
|
|
4020
4020
|
});
|
|
4021
4021
|
|
|
4022
|
+
// src/api-error.ts
|
|
4023
|
+
var GranularApiError = class extends Error {
|
|
4024
|
+
constructor(message, status, path2, details = {}) {
|
|
4025
|
+
super(message);
|
|
4026
|
+
this.status = status;
|
|
4027
|
+
this.path = path2;
|
|
4028
|
+
this.name = "GranularApiError";
|
|
4029
|
+
this.idempotencyKey = details.idempotencyKey;
|
|
4030
|
+
let body = details.body;
|
|
4031
|
+
if (typeof body === "string") {
|
|
4032
|
+
try {
|
|
4033
|
+
body = JSON.parse(body);
|
|
4034
|
+
} catch {
|
|
4035
|
+
}
|
|
4036
|
+
}
|
|
4037
|
+
this.body = body;
|
|
4038
|
+
const payload = body && typeof body === "object" ? body : void 0;
|
|
4039
|
+
const firstError = Array.isArray(payload?.errors) ? payload.errors[0] : void 0;
|
|
4040
|
+
const extensions = firstError && typeof firstError === "object" ? firstError.extensions : void 0;
|
|
4041
|
+
this.code = [payload?.code, extensions?.code, firstError?.code].find(
|
|
4042
|
+
(value) => typeof value === "string" && value.length > 0
|
|
4043
|
+
) ?? `HTTP_${status}`;
|
|
4044
|
+
}
|
|
4045
|
+
code;
|
|
4046
|
+
body;
|
|
4047
|
+
idempotencyKey;
|
|
4048
|
+
};
|
|
4049
|
+
|
|
4022
4050
|
// ../../node_modules/zod/v3/external.js
|
|
4023
4051
|
var external_exports = {};
|
|
4024
4052
|
__export(external_exports, {
|
|
@@ -16942,8 +16970,12 @@ var Environment = class _Environment {
|
|
|
16942
16970
|
}
|
|
16943
16971
|
});
|
|
16944
16972
|
if (!response.ok) {
|
|
16945
|
-
|
|
16946
|
-
|
|
16973
|
+
const errorText = await response.text();
|
|
16974
|
+
throw new GranularApiError(
|
|
16975
|
+
`Control Plane API Error (${response.status}): ${errorText}`,
|
|
16976
|
+
response.status,
|
|
16977
|
+
path2,
|
|
16978
|
+
{ body: errorText }
|
|
16947
16979
|
);
|
|
16948
16980
|
}
|
|
16949
16981
|
return response.json();
|
|
@@ -17000,12 +17032,12 @@ var Environment = class _Environment {
|
|
|
17000
17032
|
* );
|
|
17001
17033
|
* ```
|
|
17002
17034
|
*/
|
|
17003
|
-
async graphql(query, variables) {
|
|
17035
|
+
async graphql(query, variables, options) {
|
|
17004
17036
|
const authToken = await this.resolveAuthToken();
|
|
17005
17037
|
if (this._beforeMutationSend && isGraphQLMutationDocument(query)) {
|
|
17006
17038
|
this._beforeMutationSend?.();
|
|
17007
17039
|
}
|
|
17008
|
-
const idempotencyKey = this._graphqlIdempotencyKey?.(query, variables)
|
|
17040
|
+
const idempotencyKey = options?.idempotencyKey || this._graphqlIdempotencyKey?.(query, variables) || `gr1:${Date.now()}:${crypto.randomUUID()}`;
|
|
17009
17041
|
const response = await fetch(this._apiEndpoint, {
|
|
17010
17042
|
method: "POST",
|
|
17011
17043
|
headers: {
|
|
@@ -17016,12 +17048,18 @@ var Environment = class _Environment {
|
|
|
17016
17048
|
body: JSON.stringify({
|
|
17017
17049
|
environmentId: this.environmentId,
|
|
17018
17050
|
query,
|
|
17019
|
-
variables
|
|
17051
|
+
variables,
|
|
17052
|
+
...options?.readPreference ? { readPreference: options.readPreference } : {}
|
|
17020
17053
|
})
|
|
17021
17054
|
});
|
|
17022
17055
|
if (!response.ok) {
|
|
17023
17056
|
const errorText = await response.text();
|
|
17024
|
-
throw new
|
|
17057
|
+
throw new GranularApiError(
|
|
17058
|
+
`GraphQL API Error (${response.status}): ${errorText}`,
|
|
17059
|
+
response.status,
|
|
17060
|
+
this._apiEndpoint,
|
|
17061
|
+
{ body: errorText, idempotencyKey }
|
|
17062
|
+
);
|
|
17025
17063
|
}
|
|
17026
17064
|
return response.json();
|
|
17027
17065
|
}
|
|
@@ -19173,7 +19211,7 @@ var Granular = class _Granular {
|
|
|
19173
19211
|
const outdatedMatches = this.sortEnvironmentsByRecency(
|
|
19174
19212
|
userEnvironments.filter((environment2) => environment2.tagId === tag.tagId)
|
|
19175
19213
|
);
|
|
19176
|
-
if (outdatedMatches.length > 0 && options.createFreshIfOutdated !== true) {
|
|
19214
|
+
if (!resetKey && outdatedMatches.length > 0 && options.createFreshIfOutdated !== true) {
|
|
19177
19215
|
requireMatchingEnvironmentProfile(outdatedMatches[0]);
|
|
19178
19216
|
const environment2 = requireMatchingEnvironmentProfile(
|
|
19179
19217
|
await activate(outdatedMatches[0])
|
|
@@ -20337,6 +20375,9 @@ var Granular = class _Granular {
|
|
|
20337
20375
|
)
|
|
20338
20376
|
);
|
|
20339
20377
|
},
|
|
20378
|
+
/** Retire a settled environment and release its named slot. Ordinary
|
|
20379
|
+
* access is revoked; durable graph data and history are retained.
|
|
20380
|
+
* Mounted or unsettled environments reject with HTTP409. */
|
|
20340
20381
|
delete: async (environmentId) => {
|
|
20341
20382
|
return this.request(
|
|
20342
20383
|
`/control/environments/${environmentId}`,
|
|
@@ -20551,7 +20592,12 @@ var Granular = class _Granular {
|
|
|
20551
20592
|
await sleep(LOCAL_CONTROL_REQUEST_RETRY_DELAY_MS * attempt);
|
|
20552
20593
|
continue;
|
|
20553
20594
|
}
|
|
20554
|
-
throw new
|
|
20595
|
+
throw new GranularApiError(
|
|
20596
|
+
`Granular API Error (${response.status}): ${errorText}`,
|
|
20597
|
+
response.status,
|
|
20598
|
+
path2,
|
|
20599
|
+
{ body: errorText }
|
|
20600
|
+
);
|
|
20555
20601
|
}
|
|
20556
20602
|
throw new Error(`Granular API Error: exhausted retries for ${url}`);
|
|
20557
20603
|
}
|