@granular-software/sdk 0.4.62 → 0.4.64
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 +2 -2
- package/dist/agent-evals.d.ts +2 -2
- package/dist/agent-evals.js +81 -38
- package/dist/agent-evals.js.map +1 -1
- package/dist/agent-evals.mjs +81 -38
- package/dist/agent-evals.mjs.map +1 -1
- package/dist/cli/index.js +113 -60
- package/dist/{client-Bx5jIDGB.d.ts → client-BziqnDTl.d.ts} +3 -1
- package/dist/{client-Dg0I_5B_.d.mts → client-IQeOoPnO.d.mts} +3 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +81 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -38
- package/dist/index.mjs.map +1 -1
- package/dist/{spend-C8OQnF6E.d.mts → spend-CDLmk-KW.d.mts} +22 -7
- package/dist/{spend-C8OQnF6E.d.ts → spend-CDLmk-KW.d.ts} +22 -7
- package/dist/spend.d.mts +1 -1
- package/dist/spend.d.ts +1 -1
- package/package.json +1 -1
package/dist/agent-evals.mjs
CHANGED
|
@@ -12172,8 +12172,12 @@ external_exports.union([
|
|
|
12172
12172
|
external_exports.array(external_exports.string()),
|
|
12173
12173
|
external_exports.object({
|
|
12174
12174
|
values: external_exports.array(external_exports.string()),
|
|
12175
|
+
labels: external_exports.array(external_exports.string().min(1)).optional(),
|
|
12175
12176
|
message: external_exports.string().optional()
|
|
12176
|
-
}).strict()
|
|
12177
|
+
}).strict().refine(
|
|
12178
|
+
(rule) => !rule.labels || rule.labels.length === rule.values.length,
|
|
12179
|
+
{ message: "Enum labels must match enum values one-for-one" }
|
|
12180
|
+
)
|
|
12177
12181
|
]);
|
|
12178
12182
|
external_exports.union([
|
|
12179
12183
|
external_exports.boolean(),
|
|
@@ -12201,7 +12205,7 @@ var StateMachineStateSchema = external_exports.union([
|
|
|
12201
12205
|
external_exports.string(),
|
|
12202
12206
|
external_exports.object({
|
|
12203
12207
|
name: external_exports.string().min(1),
|
|
12204
|
-
label: external_exports.string().optional(),
|
|
12208
|
+
label: external_exports.string().min(1).optional(),
|
|
12205
12209
|
description: external_exports.string().optional(),
|
|
12206
12210
|
isFinal: external_exports.boolean().optional()
|
|
12207
12211
|
}).strict()
|
|
@@ -13095,7 +13099,7 @@ function resolveHandlerForMode(effectMap, effect, request) {
|
|
|
13095
13099
|
if (mode === "artifactOptions") {
|
|
13096
13100
|
if (!effect.artifactOptionsHandler) {
|
|
13097
13101
|
throw new Error(
|
|
13098
|
-
`Artifact
|
|
13102
|
+
`Artifact field options are not supported for ${request.effectKey}`
|
|
13099
13103
|
);
|
|
13100
13104
|
}
|
|
13101
13105
|
return {
|
|
@@ -13597,18 +13601,24 @@ function normalizeEnumInput(enumSpec) {
|
|
|
13597
13601
|
(value) => typeof value === "string" && value.length > 0
|
|
13598
13602
|
);
|
|
13599
13603
|
if (values.length === 0) return null;
|
|
13600
|
-
|
|
13604
|
+
const labels = Array.isArray(config.labels) && config.labels.length === values.length ? config.labels : values;
|
|
13605
|
+
return {
|
|
13606
|
+
values,
|
|
13607
|
+
labels,
|
|
13608
|
+
...config.message ? { message: config.message } : {}
|
|
13609
|
+
};
|
|
13601
13610
|
}
|
|
13602
13611
|
function buildEnumFieldMutations(fieldPath, enumSpec) {
|
|
13603
13612
|
const normalized = normalizeEnumInput(enumSpec);
|
|
13604
13613
|
if (!normalized) return [];
|
|
13605
13614
|
const messageArg = normalized.message ? `, message: ${JSON.stringify(normalized.message)}` : "";
|
|
13615
|
+
const labelsArg = normalized.labels ? `, labels: ${JSON.stringify(normalized.labels)}` : "";
|
|
13606
13616
|
return [
|
|
13607
13617
|
{
|
|
13608
13618
|
label: `set enum on ${fieldPath}`,
|
|
13609
13619
|
query: `mutation { at(path: ${JSON.stringify(fieldPath)}) { set_enum(values: ${JSON.stringify(
|
|
13610
13620
|
normalized.values
|
|
13611
|
-
)}${messageArg}) { values } } }`
|
|
13621
|
+
)}${labelsArg}${messageArg}) { values labels } } }`
|
|
13612
13622
|
}
|
|
13613
13623
|
];
|
|
13614
13624
|
}
|
|
@@ -13618,7 +13628,7 @@ var enumMetamodelPackage = defineMetamodelPackage({
|
|
|
13618
13628
|
fieldRows: [
|
|
13619
13629
|
{
|
|
13620
13630
|
key: "enum",
|
|
13621
|
-
description: 'Allowed values.
|
|
13631
|
+
description: 'Allowed values. Use `{ "values": [...], "labels": [...] }` for authored display labels; otherwise each unchanged value is its display fallback.'
|
|
13622
13632
|
}
|
|
13623
13633
|
]
|
|
13624
13634
|
},
|
|
@@ -13628,6 +13638,7 @@ var enumMetamodelPackage = defineMetamodelPackage({
|
|
|
13628
13638
|
type EnumMetamodel {
|
|
13629
13639
|
model: Model!
|
|
13630
13640
|
values: [String!]!
|
|
13641
|
+
labels: [String!]!
|
|
13631
13642
|
message: String
|
|
13632
13643
|
}
|
|
13633
13644
|
|
|
@@ -13636,7 +13647,7 @@ var enumMetamodelPackage = defineMetamodelPackage({
|
|
|
13636
13647
|
}
|
|
13637
13648
|
|
|
13638
13649
|
extend type ModelMutation {
|
|
13639
|
-
set_enum(values: [String!]!, message: String): EnumMetamodel
|
|
13650
|
+
set_enum(values: [String!]!, labels: [String!], message: String): EnumMetamodel
|
|
13640
13651
|
}
|
|
13641
13652
|
`
|
|
13642
13653
|
],
|
|
@@ -13645,15 +13656,19 @@ var enumMetamodelPackage = defineMetamodelPackage({
|
|
|
13645
13656
|
EnumMetamodel: {
|
|
13646
13657
|
model: (value) => value.model,
|
|
13647
13658
|
values: (value) => value.values,
|
|
13659
|
+
labels: (value) => value.labels || [],
|
|
13648
13660
|
message: (value) => value.message || null
|
|
13649
13661
|
},
|
|
13650
13662
|
Model: {
|
|
13651
13663
|
enum_rule: async (ant) => await run(ant.enum_rule())
|
|
13652
13664
|
},
|
|
13653
13665
|
ModelMutation: {
|
|
13654
|
-
set_enum: async (ant, { values, message }) => {
|
|
13655
|
-
const
|
|
13656
|
-
|
|
13666
|
+
set_enum: async (ant, { values, labels, message }) => {
|
|
13667
|
+
const resolvedLabels = Array.isArray(labels) && labels.length === values.length ? labels : values;
|
|
13668
|
+
const model = await run(
|
|
13669
|
+
ant.set_enum(values, resolvedLabels, message)
|
|
13670
|
+
);
|
|
13671
|
+
return { model, values, labels: resolvedLabels, message };
|
|
13657
13672
|
}
|
|
13658
13673
|
}
|
|
13659
13674
|
};
|
|
@@ -13666,7 +13681,7 @@ var enumMetamodelPackage = defineMetamodelPackage({
|
|
|
13666
13681
|
},
|
|
13667
13682
|
summary: {
|
|
13668
13683
|
selections: {
|
|
13669
|
-
propertyFields: [`enum_rule { values message }`]
|
|
13684
|
+
propertyFields: [`enum_rule { values labels message }`]
|
|
13670
13685
|
},
|
|
13671
13686
|
readPropertySummary(rawProperty) {
|
|
13672
13687
|
const values = Array.isArray(rawProperty.enum_rule?.values) ? rawProperty.enum_rule.values.filter(
|
|
@@ -13674,8 +13689,15 @@ var enumMetamodelPackage = defineMetamodelPackage({
|
|
|
13674
13689
|
) : [];
|
|
13675
13690
|
if (values.length === 0) return { enumRule: null };
|
|
13676
13691
|
const message = typeof rawProperty.enum_rule?.message === "string" ? rawProperty.enum_rule.message : null;
|
|
13692
|
+
const labels = Array.isArray(rawProperty.enum_rule?.labels) ? rawProperty.enum_rule.labels.filter(
|
|
13693
|
+
(label) => typeof label === "string" && label.length > 0
|
|
13694
|
+
) : [];
|
|
13677
13695
|
return {
|
|
13678
|
-
enumRule:
|
|
13696
|
+
enumRule: {
|
|
13697
|
+
values,
|
|
13698
|
+
...labels.length === values.length ? { labels } : {},
|
|
13699
|
+
...message ? { message } : {}
|
|
13700
|
+
}
|
|
13679
13701
|
};
|
|
13680
13702
|
}
|
|
13681
13703
|
},
|
|
@@ -15208,7 +15230,6 @@ function buildEffectMetamodelMutations(toolPath, spec) {
|
|
|
15208
15230
|
// src/client.ts
|
|
15209
15231
|
var DEFAULT_CONVERSATION_SESSION_LIST_LIMIT = 100;
|
|
15210
15232
|
var MAX_CONVERSATION_SESSION_LIST_LIMIT = 500;
|
|
15211
|
-
var MAX_CONVERSATION_SESSION_LIST_OFFSET = 1e5;
|
|
15212
15233
|
function requireUserEnvironmentSequence(value, field) {
|
|
15213
15234
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
|
|
15214
15235
|
throw new Error(
|
|
@@ -15588,6 +15609,10 @@ var Environment = class _Environment {
|
|
|
15588
15609
|
get sessions() {
|
|
15589
15610
|
return {
|
|
15590
15611
|
list: async (options = {}) => this.listSessions(options),
|
|
15612
|
+
page: async (options = {}) => this.granular.listSessionsPage({
|
|
15613
|
+
...options,
|
|
15614
|
+
environmentId: this.environmentId
|
|
15615
|
+
}),
|
|
15591
15616
|
create: async (options) => this.createSession(options),
|
|
15592
15617
|
connect: async (sessionId, options) => this.connectSession(sessionId, options),
|
|
15593
15618
|
reopen: async (sessionId, options) => this.reopenSession(sessionId, options),
|
|
@@ -15843,7 +15868,6 @@ var Environment = class _Environment {
|
|
|
15843
15868
|
headers: {
|
|
15844
15869
|
Authorization: `Bearer ${this._apiKey}`,
|
|
15845
15870
|
"Content-Type": "application/json",
|
|
15846
|
-
Connection: "close",
|
|
15847
15871
|
...options.headers
|
|
15848
15872
|
}
|
|
15849
15873
|
});
|
|
@@ -17367,8 +17391,7 @@ var EnvironmentSession = class extends Session {
|
|
|
17367
17391
|
method: "POST",
|
|
17368
17392
|
headers: {
|
|
17369
17393
|
"Content-Type": "application/json",
|
|
17370
|
-
Authorization: `Bearer ${this.environment.authToken}
|
|
17371
|
-
Connection: "close"
|
|
17394
|
+
Authorization: `Bearer ${this.environment.authToken}`
|
|
17372
17395
|
},
|
|
17373
17396
|
body: JSON.stringify({
|
|
17374
17397
|
reason: "sdk_disconnect_http_fallback",
|
|
@@ -18070,6 +18093,21 @@ var Granular = class _Granular {
|
|
|
18070
18093
|
* List indexed sessions using ownership filters and bounded pagination.
|
|
18071
18094
|
*/
|
|
18072
18095
|
async listSessions(options) {
|
|
18096
|
+
const items = [];
|
|
18097
|
+
let cursor = options.cursor?.trim() || void 0;
|
|
18098
|
+
let pageCount = 0;
|
|
18099
|
+
do {
|
|
18100
|
+
const page = await this.listSessionsPage({ ...options, cursor });
|
|
18101
|
+
items.push(...page.items);
|
|
18102
|
+
cursor = page.nextCursor || void 0;
|
|
18103
|
+
pageCount += 1;
|
|
18104
|
+
if (pageCount > 1e4) {
|
|
18105
|
+
throw new Error("Session pagination exceeded the safe page limit");
|
|
18106
|
+
}
|
|
18107
|
+
} while (cursor);
|
|
18108
|
+
return items;
|
|
18109
|
+
}
|
|
18110
|
+
async listSessionsPage(options) {
|
|
18073
18111
|
const environmentId = options.environmentId?.trim();
|
|
18074
18112
|
const sandboxId = options.sandboxId?.trim();
|
|
18075
18113
|
const subjectId = options.subjectId?.trim();
|
|
@@ -18097,17 +18135,14 @@ var Granular = class _Granular {
|
|
|
18097
18135
|
1,
|
|
18098
18136
|
MAX_CONVERSATION_SESSION_LIST_LIMIT
|
|
18099
18137
|
);
|
|
18100
|
-
const
|
|
18101
|
-
|
|
18102
|
-
"
|
|
18103
|
-
|
|
18104
|
-
0,
|
|
18105
|
-
MAX_CONVERSATION_SESSION_LIST_OFFSET
|
|
18106
|
-
);
|
|
18138
|
+
const cursor = options.cursor?.trim();
|
|
18139
|
+
if (options.cursor !== void 0 && !cursor) {
|
|
18140
|
+
throw new Error("Session list cursor must be a non-empty string.");
|
|
18141
|
+
}
|
|
18107
18142
|
const query = new URLSearchParams({
|
|
18108
|
-
limit: String(limit)
|
|
18109
|
-
offset: String(offset)
|
|
18143
|
+
limit: String(limit)
|
|
18110
18144
|
});
|
|
18145
|
+
if (cursor) query.set("cursor", cursor);
|
|
18111
18146
|
if (environmentId) query.set("environmentId", environmentId);
|
|
18112
18147
|
if (sandboxId) query.set("sandboxId", sandboxId);
|
|
18113
18148
|
if (subjectId) query.set("userId", subjectId);
|
|
@@ -18115,11 +18150,13 @@ var Granular = class _Granular {
|
|
|
18115
18150
|
query.set("sessionScope", options.sessionScope.trim());
|
|
18116
18151
|
}
|
|
18117
18152
|
if (status !== "all") query.set("status", status);
|
|
18118
|
-
const res = await this.request(
|
|
18119
|
-
|
|
18120
|
-
|
|
18121
|
-
|
|
18122
|
-
|
|
18153
|
+
const res = await this.request(`/control/sessions?${query.toString()}`);
|
|
18154
|
+
const items = Array.isArray(res.items) ? res.items.map((row) => this.normalizeConversationSession(row)) : [];
|
|
18155
|
+
const nextCursor = res.nextCursor ?? null;
|
|
18156
|
+
if (nextCursor === cursor) {
|
|
18157
|
+
throw new Error("Session pagination cursor did not advance");
|
|
18158
|
+
}
|
|
18159
|
+
return { items, nextCursor };
|
|
18123
18160
|
}
|
|
18124
18161
|
/**
|
|
18125
18162
|
* List active (open) sessions for an environment.
|
|
@@ -18146,9 +18183,6 @@ var Granular = class _Granular {
|
|
|
18146
18183
|
if (typeof options.limit === "number") {
|
|
18147
18184
|
query.set("limit", String(options.limit));
|
|
18148
18185
|
}
|
|
18149
|
-
if (typeof options.offset === "number") {
|
|
18150
|
-
query.set("offset", String(options.offset));
|
|
18151
|
-
}
|
|
18152
18186
|
const state = await this.request(
|
|
18153
18187
|
`/sdk/user-environment-state?${query.toString()}`
|
|
18154
18188
|
);
|
|
@@ -19082,10 +19116,20 @@ var Granular = class _Granular {
|
|
|
19082
19116
|
get environments() {
|
|
19083
19117
|
return {
|
|
19084
19118
|
list: async (sandboxId) => {
|
|
19085
|
-
const
|
|
19086
|
-
|
|
19087
|
-
|
|
19088
|
-
|
|
19119
|
+
const environments = [];
|
|
19120
|
+
let cursor = null;
|
|
19121
|
+
do {
|
|
19122
|
+
const query = cursor ? `?limit=100&cursor=${encodeURIComponent(cursor)}` : "";
|
|
19123
|
+
const result = await this.request(
|
|
19124
|
+
`/control/sandboxes/${sandboxId}/environments${query}`
|
|
19125
|
+
);
|
|
19126
|
+
environments.push(...result.items.map(normalizeEnvironmentData));
|
|
19127
|
+
if (result.nextCursor && result.nextCursor === cursor) {
|
|
19128
|
+
throw new Error("Environment pagination cursor did not advance");
|
|
19129
|
+
}
|
|
19130
|
+
cursor = result.nextCursor;
|
|
19131
|
+
} while (cursor);
|
|
19132
|
+
return environments;
|
|
19089
19133
|
},
|
|
19090
19134
|
get: async (environmentId) => {
|
|
19091
19135
|
return normalizeEnvironmentData(
|
|
@@ -19295,7 +19339,6 @@ var Granular = class _Granular {
|
|
|
19295
19339
|
headers: {
|
|
19296
19340
|
Authorization: `Bearer ${this.apiKey}`,
|
|
19297
19341
|
"Content-Type": "application/json",
|
|
19298
|
-
Connection: "close",
|
|
19299
19342
|
...options.headers
|
|
19300
19343
|
}
|
|
19301
19344
|
});
|