@granular-software/sdk 0.4.44 → 0.4.46
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 +7 -3
- package/dist/agent-evals.d.ts +7 -3
- package/dist/agent-evals.js +423 -37
- package/dist/agent-evals.js.map +1 -1
- package/dist/agent-evals.mjs +423 -37
- package/dist/agent-evals.mjs.map +1 -1
- package/dist/agent-harness.d.mts +1 -0
- package/dist/agent-harness.d.ts +1 -0
- package/dist/agent-harness.js +87 -11
- package/dist/agent-harness.js.map +1 -1
- package/dist/agent-harness.mjs +87 -11
- package/dist/agent-harness.mjs.map +1 -1
- package/dist/cli/index.js +114 -18
- package/dist/{client-BZ8NuQ_e.d.ts → client-ButG6ePW.d.ts} +7 -1
- package/dist/{client-CBQFvuKf.d.mts → client-C1UqPDwe.d.mts} +7 -1
- package/dist/index.d.mts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.js +201 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +201 -29
- package/dist/index.mjs.map +1 -1
- package/dist/{spend-tAz2a16I.d.mts → spend-D2Vy3N1D.d.mts} +113 -4
- package/dist/{spend-tAz2a16I.d.ts → spend-D2Vy3N1D.d.ts} +113 -4
- package/dist/spend.d.mts +1 -2
- package/dist/spend.d.ts +1 -2
- package/package.json +2 -2
package/dist/cli/index.js
CHANGED
|
@@ -18908,6 +18908,9 @@ var MAX_TIMER_DELAY_MS = 2147483647;
|
|
|
18908
18908
|
var DEBUG_WS = process.env.GRANULAR_DEBUG_WS === "1";
|
|
18909
18909
|
var DEFAULT_RPC_TIMEOUT_MS = 3e4;
|
|
18910
18910
|
var DOMAIN_PACKAGE_RPC_TIMEOUT_MS = 12e4;
|
|
18911
|
+
var EFFECT_CONTROL_RPC_TIMEOUT_MS = 12e4;
|
|
18912
|
+
var DEFAULT_RECONNECT_DELAY_MS = 3e3;
|
|
18913
|
+
var DEFAULT_MAX_RECONNECT_ATTEMPTS = 5;
|
|
18911
18914
|
function debugWs(...args) {
|
|
18912
18915
|
if (DEBUG_WS) {
|
|
18913
18916
|
console.log(...args);
|
|
@@ -18918,6 +18921,10 @@ function rpcTimeoutMsForMethod(method) {
|
|
|
18918
18921
|
case "domain.fetchPackagePart":
|
|
18919
18922
|
case "domain.getSummary":
|
|
18920
18923
|
return DOMAIN_PACKAGE_RPC_TIMEOUT_MS;
|
|
18924
|
+
case "client.heartbeat":
|
|
18925
|
+
case "effects.publishCatalog":
|
|
18926
|
+
case "effects.refresh":
|
|
18927
|
+
return EFFECT_CONTROL_RPC_TIMEOUT_MS;
|
|
18921
18928
|
default:
|
|
18922
18929
|
return DEFAULT_RPC_TIMEOUT_MS;
|
|
18923
18930
|
}
|
|
@@ -18937,6 +18944,7 @@ var WSClient = class {
|
|
|
18937
18944
|
reconnectTimer = null;
|
|
18938
18945
|
tokenRefreshTimer = null;
|
|
18939
18946
|
isExplicitlyDisconnected = false;
|
|
18947
|
+
reconnectAttempts = 0;
|
|
18940
18948
|
options;
|
|
18941
18949
|
constructor(options) {
|
|
18942
18950
|
this.options = options;
|
|
@@ -19091,6 +19099,7 @@ var WSClient = class {
|
|
|
19091
19099
|
clearTimeout(this.reconnectTimer);
|
|
19092
19100
|
this.reconnectTimer = null;
|
|
19093
19101
|
}
|
|
19102
|
+
this.reconnectAttempts = 0;
|
|
19094
19103
|
this.emit("open", {});
|
|
19095
19104
|
resolve2();
|
|
19096
19105
|
});
|
|
@@ -19122,6 +19131,7 @@ var WSClient = class {
|
|
|
19122
19131
|
clearTimeout(this.reconnectTimer);
|
|
19123
19132
|
this.reconnectTimer = null;
|
|
19124
19133
|
}
|
|
19134
|
+
this.reconnectAttempts = 0;
|
|
19125
19135
|
this.emit("open", {});
|
|
19126
19136
|
resolve2();
|
|
19127
19137
|
};
|
|
@@ -19181,7 +19191,8 @@ var WSClient = class {
|
|
|
19181
19191
|
return new Error(`WebSocket disconnected${suffix}`);
|
|
19182
19192
|
}
|
|
19183
19193
|
handleDisconnect(close = {}) {
|
|
19184
|
-
const
|
|
19194
|
+
const baseReconnectDelayMs = typeof this.options.reconnectDelayMs === "number" && Number.isFinite(this.options.reconnectDelayMs) && this.options.reconnectDelayMs > 0 ? this.options.reconnectDelayMs : DEFAULT_RECONNECT_DELAY_MS;
|
|
19195
|
+
const maxReconnectAttempts = typeof this.options.maxReconnectAttempts === "number" && Number.isFinite(this.options.maxReconnectAttempts) && this.options.maxReconnectAttempts >= 0 ? Math.floor(this.options.maxReconnectAttempts) : DEFAULT_MAX_RECONNECT_ATTEMPTS;
|
|
19185
19196
|
const unexpected = !this.isExplicitlyDisconnected;
|
|
19186
19197
|
const info2 = {
|
|
19187
19198
|
code: close.code,
|
|
@@ -19201,6 +19212,30 @@ var WSClient = class {
|
|
|
19201
19212
|
const disconnectError = this.buildDisconnectError(info2);
|
|
19202
19213
|
this.rejectPending(disconnectError);
|
|
19203
19214
|
this.emit("disconnect", info2);
|
|
19215
|
+
if (this.reconnectAttempts >= maxReconnectAttempts) {
|
|
19216
|
+
const reconnectInfo = {
|
|
19217
|
+
error: `WebSocket reconnect attempts exhausted after ${maxReconnectAttempts} attempt(s).`,
|
|
19218
|
+
sessionId: this.sessionId,
|
|
19219
|
+
timestamp: Date.now()
|
|
19220
|
+
};
|
|
19221
|
+
this.emit("reconnect_error", reconnectInfo);
|
|
19222
|
+
if (this.options.onReconnectError) {
|
|
19223
|
+
try {
|
|
19224
|
+
this.options.onReconnectError(reconnectInfo);
|
|
19225
|
+
} catch (callbackError) {
|
|
19226
|
+
console.error(
|
|
19227
|
+
"[Granular] onReconnectError callback failed:",
|
|
19228
|
+
callbackError
|
|
19229
|
+
);
|
|
19230
|
+
}
|
|
19231
|
+
}
|
|
19232
|
+
return;
|
|
19233
|
+
}
|
|
19234
|
+
this.reconnectAttempts += 1;
|
|
19235
|
+
const reconnectDelayMs = Math.min(
|
|
19236
|
+
3e4,
|
|
19237
|
+
baseReconnectDelayMs * 2 ** Math.max(0, this.reconnectAttempts - 1)
|
|
19238
|
+
);
|
|
19204
19239
|
info2.reconnectScheduled = true;
|
|
19205
19240
|
info2.reconnectDelayMs = reconnectDelayMs;
|
|
19206
19241
|
if (this.options.onUnexpectedClose) {
|
|
@@ -19655,6 +19690,9 @@ var Session = class {
|
|
|
19655
19690
|
promptCache = /* @__PURE__ */ new Map();
|
|
19656
19691
|
/** Prompt ids locally answered before the document sync catches up. */
|
|
19657
19692
|
hiddenPromptIds = /* @__PURE__ */ new Set();
|
|
19693
|
+
domainPackagePartCache = /* @__PURE__ */ new Map();
|
|
19694
|
+
domainPackagePartPromises = /* @__PURE__ */ new Map();
|
|
19695
|
+
domainPackageFetchQueue = Promise.resolve();
|
|
19658
19696
|
constructor(client, clientId, options = {}) {
|
|
19659
19697
|
this.client = client;
|
|
19660
19698
|
this.clientId = clientId || `client_${Date.now()}`;
|
|
@@ -19862,12 +19900,18 @@ var Session = class {
|
|
|
19862
19900
|
const resolvedAnswer = resolvePromptAnswer(prompt3, answer);
|
|
19863
19901
|
this.promptCache.delete(promptId);
|
|
19864
19902
|
this.hiddenPromptIds.add(promptId);
|
|
19903
|
+
this.emit("prompt", { id: promptId, status: "answered" });
|
|
19865
19904
|
try {
|
|
19866
|
-
await this.client.call("prompt.answer", {
|
|
19905
|
+
const response = await this.client.call("prompt.answer", {
|
|
19867
19906
|
promptId,
|
|
19868
19907
|
answer: resolvedAnswer,
|
|
19869
19908
|
value: resolvedAnswer
|
|
19870
19909
|
});
|
|
19910
|
+
if (response && typeof response === "object" && "ok" in response && response.ok === false) {
|
|
19911
|
+
const rejected = response;
|
|
19912
|
+
const errorMessage = typeof rejected.error === "string" ? rejected.error : "Prompt answer was rejected.";
|
|
19913
|
+
throw new Error(errorMessage);
|
|
19914
|
+
}
|
|
19871
19915
|
} catch (error2) {
|
|
19872
19916
|
this.hiddenPromptIds.delete(promptId);
|
|
19873
19917
|
if (prompt3) {
|
|
@@ -20095,11 +20139,33 @@ var Session = class {
|
|
|
20095
20139
|
* Fetch a domain package part from the backend (no fallback).
|
|
20096
20140
|
*/
|
|
20097
20141
|
async fetchDomainPart(part) {
|
|
20098
|
-
const
|
|
20099
|
-
|
|
20100
|
-
|
|
20142
|
+
const cached = this.domainPackagePartCache.get(part);
|
|
20143
|
+
if (cached !== void 0) {
|
|
20144
|
+
return cached;
|
|
20145
|
+
}
|
|
20146
|
+
const inFlight = this.domainPackagePartPromises.get(part);
|
|
20147
|
+
if (inFlight) {
|
|
20148
|
+
return inFlight;
|
|
20149
|
+
}
|
|
20150
|
+
const fetchPromise = this.domainPackageFetchQueue.then(async () => {
|
|
20151
|
+
const result = await this.client.call("domain.fetchPackagePart", {
|
|
20152
|
+
moduleSpecifier: "@sandbox/domain",
|
|
20153
|
+
part
|
|
20154
|
+
});
|
|
20155
|
+
const content = result?.content ?? "";
|
|
20156
|
+
this.domainPackagePartCache.set(part, content);
|
|
20157
|
+
return content;
|
|
20101
20158
|
});
|
|
20102
|
-
|
|
20159
|
+
this.domainPackagePartPromises.set(part, fetchPromise);
|
|
20160
|
+
this.domainPackageFetchQueue = fetchPromise.then(
|
|
20161
|
+
() => void 0,
|
|
20162
|
+
() => void 0
|
|
20163
|
+
);
|
|
20164
|
+
try {
|
|
20165
|
+
return await fetchPromise;
|
|
20166
|
+
} finally {
|
|
20167
|
+
this.domainPackagePartPromises.delete(part);
|
|
20168
|
+
}
|
|
20103
20169
|
}
|
|
20104
20170
|
/**
|
|
20105
20171
|
* Get TypeScript class declarations for the current domain (for LLM/code gen).
|
|
@@ -20349,7 +20415,10 @@ import { ${allImports} } from "./sandbox-tools";
|
|
|
20349
20415
|
const emitPrompt = (payload) => {
|
|
20350
20416
|
const prompt3 = normalizePrompt(payload);
|
|
20351
20417
|
if (!prompt3) return;
|
|
20352
|
-
this.hiddenPromptIds.
|
|
20418
|
+
if (this.hiddenPromptIds.has(prompt3.id)) {
|
|
20419
|
+
this.emit("prompt", { ...prompt3, status: "answered" });
|
|
20420
|
+
return;
|
|
20421
|
+
}
|
|
20353
20422
|
this.promptCache.set(prompt3.id, prompt3);
|
|
20354
20423
|
this.emit("prompt", prompt3);
|
|
20355
20424
|
};
|
|
@@ -21909,6 +21978,7 @@ var LOCAL_CONTROL_REQUEST_RETRY_DELAY_MS = 500;
|
|
|
21909
21978
|
var SESSION_DATA_REQUEST_RETRY_COUNT = 4;
|
|
21910
21979
|
var SESSION_DATA_REQUEST_RETRY_DELAY_MS = 500;
|
|
21911
21980
|
var EFFECT_HOST_CONNECT_TIMEOUT_MS = 15e3;
|
|
21981
|
+
var SESSION_CONNECT_TIMEOUT_MS = 15e3;
|
|
21912
21982
|
function filenameFromUploadBody(body) {
|
|
21913
21983
|
const maybe = body;
|
|
21914
21984
|
return typeof maybe.name === "string" && maybe.name.trim() ? maybe.name.trim() : null;
|
|
@@ -21928,7 +21998,7 @@ function bodyInitFromSessionFileUpload(body) {
|
|
|
21928
21998
|
}
|
|
21929
21999
|
return body;
|
|
21930
22000
|
}
|
|
21931
|
-
var EFFECT_CATALOG_SYNC_TIMEOUT_MS =
|
|
22001
|
+
var EFFECT_CATALOG_SYNC_TIMEOUT_MS = 12e4;
|
|
21932
22002
|
var EFFECT_CATALOG_SYNC_RETRY_COUNT = 3;
|
|
21933
22003
|
var EFFECT_CATALOG_SYNC_RETRY_DELAY_MS = 1e3;
|
|
21934
22004
|
function planRecordObjectsChunks(records, batchSize) {
|
|
@@ -23884,7 +23954,14 @@ var Granular = class _Granular {
|
|
|
23884
23954
|
return tag2;
|
|
23885
23955
|
}
|
|
23886
23956
|
buildManagedEnvironmentName(tag2, versionId) {
|
|
23887
|
-
return `__sdk__${tag2}__${versionId}`;
|
|
23957
|
+
return `__sdk__${tag2}__${versionId}__pinned`;
|
|
23958
|
+
}
|
|
23959
|
+
isManagedEnvironmentName(environment, tagName) {
|
|
23960
|
+
const name = environment.environment || environment.envName || "";
|
|
23961
|
+
return name.startsWith(`__sdk__${tagName}__`);
|
|
23962
|
+
}
|
|
23963
|
+
isPinnedToVersion(environment, versionId) {
|
|
23964
|
+
return environment.buildPolicy.mode === "pinned" && (environment.versionId === versionId || environment.buildPolicy.versionId === versionId || environment.buildPolicy.buildId === versionId);
|
|
23888
23965
|
}
|
|
23889
23966
|
matchesTagTrackedEnvironment(environment, tagName, tagId) {
|
|
23890
23967
|
const environmentTagName = environment.tag?.name || environment.buildPolicy.tagName || null;
|
|
@@ -23945,7 +24022,7 @@ var Granular = class _Granular {
|
|
|
23945
24022
|
);
|
|
23946
24023
|
const currentMatches = this.sortEnvironmentsByRecency(
|
|
23947
24024
|
userEnvironments.filter(
|
|
23948
|
-
(environment) => this.matchesTagTrackedEnvironment(environment, tagName, tag2.tagId) && environment.versionId === targetVersionId
|
|
24025
|
+
(environment) => this.matchesTagTrackedEnvironment(environment, tagName, tag2.tagId) && environment.versionId === targetVersionId && (!this.isManagedEnvironmentName(environment, tagName) || this.isPinnedToVersion(environment, targetVersionId))
|
|
23949
24026
|
)
|
|
23950
24027
|
);
|
|
23951
24028
|
if (currentMatches.length > 0) {
|
|
@@ -23974,6 +24051,7 @@ var Granular = class _Granular {
|
|
|
23974
24051
|
subjectId: user.granularId,
|
|
23975
24052
|
environment: this.buildManagedEnvironmentName(tagName, targetVersionId),
|
|
23976
24053
|
tagId: tag2.tagId,
|
|
24054
|
+
versionId: targetVersionId,
|
|
23977
24055
|
permissionProfileId: null
|
|
23978
24056
|
}),
|
|
23979
24057
|
requestedOntology: ontology,
|
|
@@ -24019,6 +24097,7 @@ var Granular = class _Granular {
|
|
|
24019
24097
|
row.summaryUpdatedAt ?? row.summary_updated_at
|
|
24020
24098
|
) : null,
|
|
24021
24099
|
subjectId: row.subjectId != null ? String(row.subjectId) : null,
|
|
24100
|
+
sessionScope: row.sessionScope != null || row.session_scope != null ? String(row.sessionScope ?? row.session_scope) : null,
|
|
24022
24101
|
jobCount: typeof row.jobCount === "number" ? row.jobCount : void 0,
|
|
24023
24102
|
toolCallCount: typeof row.toolCallCount === "number" ? row.toolCallCount : void 0
|
|
24024
24103
|
};
|
|
@@ -24226,7 +24305,11 @@ var Granular = class _Granular {
|
|
|
24226
24305
|
onUnexpectedClose: this.onUnexpectedClose,
|
|
24227
24306
|
onReconnectError: this.onReconnectError
|
|
24228
24307
|
});
|
|
24229
|
-
await
|
|
24308
|
+
await withTimeout(
|
|
24309
|
+
client.connect(),
|
|
24310
|
+
SESSION_CONNECT_TIMEOUT_MS,
|
|
24311
|
+
`session WebSocket connect for ${session2.sessionId}`
|
|
24312
|
+
);
|
|
24230
24313
|
const environmentSession = new EnvironmentSession(
|
|
24231
24314
|
client,
|
|
24232
24315
|
environment,
|
|
@@ -24397,12 +24480,24 @@ var Granular = class _Granular {
|
|
|
24397
24480
|
host.heartbeatInFlight = false;
|
|
24398
24481
|
}
|
|
24399
24482
|
async synchronizeEffectHost(host) {
|
|
24400
|
-
|
|
24401
|
-
|
|
24402
|
-
|
|
24403
|
-
|
|
24404
|
-
|
|
24405
|
-
|
|
24483
|
+
if (host.syncPromise) {
|
|
24484
|
+
return host.syncPromise;
|
|
24485
|
+
}
|
|
24486
|
+
host.syncPromise = (async () => {
|
|
24487
|
+
await host.wsClient.call("client.hello", {
|
|
24488
|
+
clientId: host.clientId,
|
|
24489
|
+
protocolVersion: "2.0"
|
|
24490
|
+
});
|
|
24491
|
+
await this.publishSandboxEffectCatalog(host);
|
|
24492
|
+
this.startEffectHostHeartbeat(host);
|
|
24493
|
+
})();
|
|
24494
|
+
try {
|
|
24495
|
+
await host.syncPromise;
|
|
24496
|
+
} finally {
|
|
24497
|
+
if (host.syncPromise) {
|
|
24498
|
+
host.syncPromise = null;
|
|
24499
|
+
}
|
|
24500
|
+
}
|
|
24406
24501
|
}
|
|
24407
24502
|
async ensureSandboxEffectHost(sandboxId) {
|
|
24408
24503
|
const existing = this.sandboxEffectHosts.get(sandboxId);
|
|
@@ -24438,7 +24533,8 @@ var Granular = class _Granular {
|
|
|
24438
24533
|
wsClient,
|
|
24439
24534
|
heartbeatTimer: null,
|
|
24440
24535
|
heartbeatInFlight: false,
|
|
24441
|
-
recovering: false
|
|
24536
|
+
recovering: false,
|
|
24537
|
+
syncPromise: null
|
|
24442
24538
|
};
|
|
24443
24539
|
wsClient.registerRpcHandler("effect.invoke", async (params) => {
|
|
24444
24540
|
const request = params;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bf as WSClientOptions, a7 as GranularQuotaProgress, T as ToolWithHandler, f as PublishToolsResult, aT as Job, g as ToolHandler, I as InstanceToolHandler, aV as ConversationMessageInput, aW as ConversationAppendResult, aG as EffectInfo, P as Prompt, aF as ToolInfo, aI as EffectsChangedEvent, aH as ToolsChangedEvent, D as DomainState, Q as GranularOptions, bG as EnvironmentImporter, W as RecordUserOptions, V as User, Y as OpenEnvironmentOptions, ak as EnvironmentData, ah as BuildPolicy, bE as EnvironmentSetupSummary, $ as ConversationSessionInfo, _ as CreateSessionOptions, bp as RecordObjectOptions, bq as RecordObjectResult, bs as RecordObjectsOptions, bz as RecordImport, bv as RecordImportStatus, bA as EnvironmentRecordImportSummary, aR as EnvironmentFeedbackRecord, c as SessionHeapSnapshot, b9 as SessionDocumentResult, ba as SessionCollectionListOptions, bc as SessionCollectionListResult, aX as SessionConversationMessage, aY as SessionTimelineEvent, bb as SessionJobListOptions, b2 as SessionJobRecord, b0 as SessionFileRecord, b1 as SessionFileUploadOptions, S as SessionHeapEntry, b as SessionHeapList, b5 as SessionHeapVariable, d as SessionTranscriptEntry, c0 as GraphQLResult, b7 as RecordSearchOptions, b6 as RecordSearchResult, b8 as RecordMentionInput, bo as DefineRelationshipOptions, bn as RelationshipInfo, bm as ModelRef, b$ as ManifestContent, bu as RecordImportOptions, Z as ConnectOptions, bC as RunEnvironmentImporterOptions, l as OpenAIUsageSpendEvent, G as GranularSpendContext, o as RecordOpenAIUsageSpendResult, aa as SandboxListResponse, a8 as Sandbox, a9 as CreateSandboxData, c2 as DeleteResponse, ac as PermissionProfile, ad as CreatePermissionProfileData, al as CreateEnvironmentData, c3 as StreamEvent, c4 as StreamSubscription, c5 as StreamStats, X as Subject, ag as AssignmentListResponse } from './spend-D2Vy3N1D.js';
|
|
2
2
|
import * as Automerge from '@automerge/automerge';
|
|
3
3
|
import { Doc } from '@automerge/automerge/slim';
|
|
4
4
|
|
|
@@ -17,6 +17,7 @@ declare class WSClient {
|
|
|
17
17
|
private reconnectTimer;
|
|
18
18
|
private tokenRefreshTimer;
|
|
19
19
|
private isExplicitlyDisconnected;
|
|
20
|
+
private reconnectAttempts;
|
|
20
21
|
private options;
|
|
21
22
|
constructor(options: WSClientOptions);
|
|
22
23
|
get currentSessionId(): string;
|
|
@@ -94,6 +95,9 @@ declare class Session {
|
|
|
94
95
|
private promptCache;
|
|
95
96
|
/** Prompt ids locally answered before the document sync catches up. */
|
|
96
97
|
private hiddenPromptIds;
|
|
98
|
+
private domainPackagePartCache;
|
|
99
|
+
private domainPackagePartPromises;
|
|
100
|
+
private domainPackageFetchQueue;
|
|
97
101
|
constructor(client: WSClient, clientId?: string, options?: {
|
|
98
102
|
initialQuota?: GranularQuotaProgress | null;
|
|
99
103
|
});
|
|
@@ -881,6 +885,8 @@ declare class Granular {
|
|
|
881
885
|
runEnvironmentImporterForEnvironment(environmentId: string, options?: RunEnvironmentImporterOptions): Promise<EnvironmentSetupSummary | null>;
|
|
882
886
|
private resolveRequestedTag;
|
|
883
887
|
private buildManagedEnvironmentName;
|
|
888
|
+
private isManagedEnvironmentName;
|
|
889
|
+
private isPinnedToVersion;
|
|
884
890
|
private matchesTagTrackedEnvironment;
|
|
885
891
|
private sortEnvironmentsByRecency;
|
|
886
892
|
private resolveOpenEnvironmentData;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bf as WSClientOptions, a7 as GranularQuotaProgress, T as ToolWithHandler, f as PublishToolsResult, aT as Job, g as ToolHandler, I as InstanceToolHandler, aV as ConversationMessageInput, aW as ConversationAppendResult, aG as EffectInfo, P as Prompt, aF as ToolInfo, aI as EffectsChangedEvent, aH as ToolsChangedEvent, D as DomainState, Q as GranularOptions, bG as EnvironmentImporter, W as RecordUserOptions, V as User, Y as OpenEnvironmentOptions, ak as EnvironmentData, ah as BuildPolicy, bE as EnvironmentSetupSummary, $ as ConversationSessionInfo, _ as CreateSessionOptions, bp as RecordObjectOptions, bq as RecordObjectResult, bs as RecordObjectsOptions, bz as RecordImport, bv as RecordImportStatus, bA as EnvironmentRecordImportSummary, aR as EnvironmentFeedbackRecord, c as SessionHeapSnapshot, b9 as SessionDocumentResult, ba as SessionCollectionListOptions, bc as SessionCollectionListResult, aX as SessionConversationMessage, aY as SessionTimelineEvent, bb as SessionJobListOptions, b2 as SessionJobRecord, b0 as SessionFileRecord, b1 as SessionFileUploadOptions, S as SessionHeapEntry, b as SessionHeapList, b5 as SessionHeapVariable, d as SessionTranscriptEntry, c0 as GraphQLResult, b7 as RecordSearchOptions, b6 as RecordSearchResult, b8 as RecordMentionInput, bo as DefineRelationshipOptions, bn as RelationshipInfo, bm as ModelRef, b$ as ManifestContent, bu as RecordImportOptions, Z as ConnectOptions, bC as RunEnvironmentImporterOptions, l as OpenAIUsageSpendEvent, G as GranularSpendContext, o as RecordOpenAIUsageSpendResult, aa as SandboxListResponse, a8 as Sandbox, a9 as CreateSandboxData, c2 as DeleteResponse, ac as PermissionProfile, ad as CreatePermissionProfileData, al as CreateEnvironmentData, c3 as StreamEvent, c4 as StreamSubscription, c5 as StreamStats, X as Subject, ag as AssignmentListResponse } from './spend-D2Vy3N1D.mjs';
|
|
2
2
|
import * as Automerge from '@automerge/automerge';
|
|
3
3
|
import { Doc } from '@automerge/automerge/slim';
|
|
4
4
|
|
|
@@ -17,6 +17,7 @@ declare class WSClient {
|
|
|
17
17
|
private reconnectTimer;
|
|
18
18
|
private tokenRefreshTimer;
|
|
19
19
|
private isExplicitlyDisconnected;
|
|
20
|
+
private reconnectAttempts;
|
|
20
21
|
private options;
|
|
21
22
|
constructor(options: WSClientOptions);
|
|
22
23
|
get currentSessionId(): string;
|
|
@@ -94,6 +95,9 @@ declare class Session {
|
|
|
94
95
|
private promptCache;
|
|
95
96
|
/** Prompt ids locally answered before the document sync catches up. */
|
|
96
97
|
private hiddenPromptIds;
|
|
98
|
+
private domainPackagePartCache;
|
|
99
|
+
private domainPackagePartPromises;
|
|
100
|
+
private domainPackageFetchQueue;
|
|
97
101
|
constructor(client: WSClient, clientId?: string, options?: {
|
|
98
102
|
initialQuota?: GranularQuotaProgress | null;
|
|
99
103
|
});
|
|
@@ -881,6 +885,8 @@ declare class Granular {
|
|
|
881
885
|
runEnvironmentImporterForEnvironment(environmentId: string, options?: RunEnvironmentImporterOptions): Promise<EnvironmentSetupSummary | null>;
|
|
882
886
|
private resolveRequestedTag;
|
|
883
887
|
private buildManagedEnvironmentName;
|
|
888
|
+
private isManagedEnvironmentName;
|
|
889
|
+
private isPinnedToVersion;
|
|
884
890
|
private matchesTagTrackedEnvironment;
|
|
885
891
|
private sortEnvironmentsByRecency;
|
|
886
892
|
private resolveOpenEnvironmentData;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export { E as Environment, a as EnvironmentSession, G as Granular, O as OntologyHandle, S as Session, W as WSClient } from './client-
|
|
2
|
-
import { E as EndpointMode, T as ToolWithHandler, a as EffectHandlerContext, M as ManifestEffectMetamodelSpec, R as ResolvedEffectBehaviors, S as SessionHeapEntry, b as SessionHeapList, c as SessionHeapSnapshot, P as Prompt, d as SessionTranscriptEntry } from './spend-
|
|
3
|
-
export {
|
|
4
|
-
export { ConditionIR, ConditionalPolicySpec, LimitPolicySpec, MatchedPolicy, PermissionActionSpec, PermissionPolicySpec, PermissionProfileFile, PolicyDecision, PolicyEvaluationContext, PolicyOutcome, PolicyRuleIR } from '@granular-software/policy-engine';
|
|
1
|
+
export { E as Environment, a as EnvironmentSession, G as Granular, O as OntologyHandle, S as Session, W as WSClient } from './client-C1UqPDwe.mjs';
|
|
2
|
+
import { E as EndpointMode, T as ToolWithHandler, a as EffectHandlerContext, M as ManifestEffectMetamodelSpec, R as ResolvedEffectBehaviors, S as SessionHeapEntry, b as SessionHeapList, c as SessionHeapSnapshot, P as Prompt, d as SessionTranscriptEntry } from './spend-D2Vy3N1D.mjs';
|
|
3
|
+
export { c1 as APIError, K as AccessTokenProvider, af as Assignment, ag as AssignmentListResponse, aq as Build, as as BuildListResponse, ah as BuildPolicy, ap as BuildStatus, C as ConditionIR, J as ConditionalPolicySpec, Z as ConnectOptions, aW as ConversationAppendResult, aV as ConversationMessageInput, aU as ConversationMessageShowRefs, $ as ConversationSessionInfo, al as CreateEnvironmentData, ad as CreatePermissionProfileData, a9 as CreateSandboxData, _ as CreateSessionOptions, bo as DefineRelationshipOptions, c2 as DeleteResponse, D as DomainState, aJ as EffectHandler, aG as EffectInfo, aA as EffectInvocationMetadata, az as EffectInvocationMode, aB as EffectSchema, aE as EffectVersionSelector, aC as EffectWithHandler, aI as EffectsChangedEvent, ak as EnvironmentData, aR as EnvironmentFeedbackRecord, bG as EnvironmentImporter, bF as EnvironmentImporterImportOptions, am as EnvironmentListResponse, bA as EnvironmentRecordImportSummary, bD as EnvironmentSetupLifecycleStatus, bE as EnvironmentSetupSummary, bB as EnvironmentSetupTriggerReason, U as GranularAuth, Q as GranularOptions, a6 as GranularQuotaPolicy, a7 as GranularQuotaProgress, G as GranularSpendContext, c0 as GraphQLResult, aK as InstanceEffectHandler, I as InstanceToolHandler, aT as Job, aP as JobFeedbackInput, aO as JobFeedbackMetadata, aQ as JobFeedbackRecord, aM as JobFeedbackSentiment, aN as JobFeedbackToolCall, aL as JobStatus, aS as JobSubmitResult, L as LimitPolicySpec, an as Manifest, bS as ManifestApprovalRequiredSpec, b$ as ManifestContent, bQ as ManifestDryRunSpec, bV as ManifestEffectDeclaration, bU as ManifestEffectSchema, bJ as ManifestEnumRuleSpec, bX as ManifestEventStreamDef, bW as ManifestEventTypeDef, bK as ManifestFilterBySpec, bZ as ManifestImport, ao as ManifestListResponse, bY as ManifestOperation, bP as ManifestPostConditionSpec, bH as ManifestPropertySpec, bT as ManifestRelationshipDef, bR as ManifestReverseSpec, bO as ManifestStateMachineSpec, bM as ManifestStateMachineStateSpec, bN as ManifestStateMachineTransitionSpec, bI as ManifestValidationOperator, bL as ManifestValidationRuleSpec, b_ as ManifestVolume, y as MatchedPolicy, bm as ModelRef, N as NormalizedOpenAIUsage, i as OPENAI_MODEL_PRICING_USD_PER_MILLION, O as OpenAIModelPricing, h as OpenAITokenSpend, l as OpenAIUsageSpendEvent, Y as OpenEnvironmentOptions, H as PermissionActionSpec, F as PermissionPolicySpec, ac as PermissionProfile, B as PermissionProfileFile, ae as PermissionProfileListResponse, ab as PermissionRules, z as PolicyDecision, A as PolicyEvaluationContext, v as PolicyOperator, w as PolicyOrigin, q as PolicyOutcome, u as PolicyPredicateSource, x as PolicyRuleIR, s as PolicySource, aD as PublishEffectsResult, f as PublishToolsResult, a5 as QuotaLineItemFilter, a2 as QuotaPeriod, a1 as QuotaScopeType, a3 as QuotaStatus, bg as RPCRequest, bj as RPCRequestFromServer, bh as RPCResponse, bz as RecordImport, by as RecordImportItem, bw as RecordImportItemStatus, bu as RecordImportOptions, bx as RecordImportStats, bv as RecordImportStatus, bt as RecordImportWriteMode, b8 as RecordMentionInput, bp as RecordObjectOptions, bq as RecordObjectResult, br as RecordObjectsChunkInfo, bs as RecordObjectsOptions, m as RecordOpenAIUsageSpendOptions, o as RecordOpenAIUsageSpendResult, b7 as RecordSearchOptions, b6 as RecordSearchResult, W as RecordUserOptions, bn as RelationshipInfo, ay as ResolvedEffectApprovalRequired, aw as ResolvedEffectDryRun, av as ResolvedEffectPostCondition, ax as ResolvedEffectReverse, bC as RunEnvironmentImporterOptions, a8 as Sandbox, aa as SandboxListResponse, au as SemanticVersionDiff, at as SemanticVersionDiffEntry, ba as SessionCollectionListOptions, bc as SessionCollectionListResult, aX as SessionConversationMessage, b9 as SessionDocumentResult, a_ as SessionFileKind, b0 as SessionFileRecord, aZ as SessionFileSource, a$ as SessionFileStatus, b1 as SessionFileUploadOptions, b3 as SessionHeapFieldType, b4 as SessionHeapFieldValue, b5 as SessionHeapVariable, bb as SessionJobListOptions, b2 as SessionJobRecord, aY as SessionTimelineEvent, a0 as SpendLineItemType, a4 as SpendSummary, c3 as StreamEvent, c5 as StreamStats, c4 as StreamSubscription, X as Subject, bi as SyncMessage, g as ToolHandler, aF as ToolInfo, bk as ToolInvokeParams, bl as ToolResultParams, e as ToolSchema, aH as ToolsChangedEvent, V as User, ar as Version, aj as VersionTag, ai as VersionTracking, bf as WSClientOptions, bd as WSDisconnectInfo, be as WSReconnectErrorInfo, p as buildOpenAISpendEventId, k as calculateOpenAITokenSpend, j as getOpenAIModelPricing, n as normalizeOpenAIUsage, r as recordOpenAIUsageSpend, t as toGranularHttpBase } from './spend-D2Vy3N1D.mjs';
|
|
5
4
|
export { BuildGranularAgentSystemPromptInput, GeneratedJobCodeIssue, GranularAgentExecutionCheckpoint, GranularAgentHeapSummaryOptions, GranularAgentPromptCapabilities, GranularAgentReferentFocus, GranularAgentSessionContext, GranularAgentToolInfo, GranularAgentWorkflowFocus, GranularReasoningTraceChunkResult, GranularReasoningTraceOptions, HarnessContinuationDecision, HarnessControllerBudgets, HarnessProjectionOptions, HarnessPromptLike, HarnessRenderedContinuation, HarnessRenderedPrompt, HarnessTemplate, HarnessTemplateManifest, HarnessTemplateSelectionOptions, HarnessTemplateStatus, HarnessVerifierSnapshot, HarnessVerifierSnapshotInput, ReviewGeneratedJobCodeOptions, buildContinuationInstruction, buildContinuationInstructionFromTemplate, buildGranularAgentCheckpointBlock, buildGranularAgentDomainBlock, buildGranularAgentFileBlock, buildGranularAgentHeapBlock, buildGranularAgentLoopBlock, buildGranularAgentReferentBlock, buildGranularAgentRuntimeImportsBlock, buildGranularAgentSessionBlock, buildGranularAgentSystemPrompt, buildGranularAgentSystemPromptFromTemplate, buildGranularAgentToolBlock, buildGranularAgentWorkflowBlock, consumeGranularReasoningOnlyChunk, consumeGranularReasoningTraceChunk, createHarnessVerifierSnapshot, evaluateContinuation, getCurrentClosureId, getDefaultHarnessTemplateId, getExclusivePromptTarget, hasOpenPrompt, hashHarnessTemplateValue, listHarnessTemplates, projectConversationReferentFocus, projectConversationReferentSummary, projectHeapSummary, projectLoopSummary, projectSessionFileSummary, projectWorkflowFocus, projectWorkflowSummary, renderContinuationInstructionFromTemplate, renderGranularAgentSystemPromptFromTemplate, resolveHarnessTemplate, reviewGeneratedJobCode, stripGranularReasoningTrace, validateHarnessTemplateManifest } from './agent-harness.mjs';
|
|
6
5
|
import '@automerge/automerge';
|
|
7
6
|
import '@automerge/automerge/slim';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export { E as Environment, a as EnvironmentSession, G as Granular, O as OntologyHandle, S as Session, W as WSClient } from './client-
|
|
2
|
-
import { E as EndpointMode, T as ToolWithHandler, a as EffectHandlerContext, M as ManifestEffectMetamodelSpec, R as ResolvedEffectBehaviors, S as SessionHeapEntry, b as SessionHeapList, c as SessionHeapSnapshot, P as Prompt, d as SessionTranscriptEntry } from './spend-
|
|
3
|
-
export {
|
|
4
|
-
export { ConditionIR, ConditionalPolicySpec, LimitPolicySpec, MatchedPolicy, PermissionActionSpec, PermissionPolicySpec, PermissionProfileFile, PolicyDecision, PolicyEvaluationContext, PolicyOutcome, PolicyRuleIR } from '@granular-software/policy-engine';
|
|
1
|
+
export { E as Environment, a as EnvironmentSession, G as Granular, O as OntologyHandle, S as Session, W as WSClient } from './client-ButG6ePW.js';
|
|
2
|
+
import { E as EndpointMode, T as ToolWithHandler, a as EffectHandlerContext, M as ManifestEffectMetamodelSpec, R as ResolvedEffectBehaviors, S as SessionHeapEntry, b as SessionHeapList, c as SessionHeapSnapshot, P as Prompt, d as SessionTranscriptEntry } from './spend-D2Vy3N1D.js';
|
|
3
|
+
export { c1 as APIError, K as AccessTokenProvider, af as Assignment, ag as AssignmentListResponse, aq as Build, as as BuildListResponse, ah as BuildPolicy, ap as BuildStatus, C as ConditionIR, J as ConditionalPolicySpec, Z as ConnectOptions, aW as ConversationAppendResult, aV as ConversationMessageInput, aU as ConversationMessageShowRefs, $ as ConversationSessionInfo, al as CreateEnvironmentData, ad as CreatePermissionProfileData, a9 as CreateSandboxData, _ as CreateSessionOptions, bo as DefineRelationshipOptions, c2 as DeleteResponse, D as DomainState, aJ as EffectHandler, aG as EffectInfo, aA as EffectInvocationMetadata, az as EffectInvocationMode, aB as EffectSchema, aE as EffectVersionSelector, aC as EffectWithHandler, aI as EffectsChangedEvent, ak as EnvironmentData, aR as EnvironmentFeedbackRecord, bG as EnvironmentImporter, bF as EnvironmentImporterImportOptions, am as EnvironmentListResponse, bA as EnvironmentRecordImportSummary, bD as EnvironmentSetupLifecycleStatus, bE as EnvironmentSetupSummary, bB as EnvironmentSetupTriggerReason, U as GranularAuth, Q as GranularOptions, a6 as GranularQuotaPolicy, a7 as GranularQuotaProgress, G as GranularSpendContext, c0 as GraphQLResult, aK as InstanceEffectHandler, I as InstanceToolHandler, aT as Job, aP as JobFeedbackInput, aO as JobFeedbackMetadata, aQ as JobFeedbackRecord, aM as JobFeedbackSentiment, aN as JobFeedbackToolCall, aL as JobStatus, aS as JobSubmitResult, L as LimitPolicySpec, an as Manifest, bS as ManifestApprovalRequiredSpec, b$ as ManifestContent, bQ as ManifestDryRunSpec, bV as ManifestEffectDeclaration, bU as ManifestEffectSchema, bJ as ManifestEnumRuleSpec, bX as ManifestEventStreamDef, bW as ManifestEventTypeDef, bK as ManifestFilterBySpec, bZ as ManifestImport, ao as ManifestListResponse, bY as ManifestOperation, bP as ManifestPostConditionSpec, bH as ManifestPropertySpec, bT as ManifestRelationshipDef, bR as ManifestReverseSpec, bO as ManifestStateMachineSpec, bM as ManifestStateMachineStateSpec, bN as ManifestStateMachineTransitionSpec, bI as ManifestValidationOperator, bL as ManifestValidationRuleSpec, b_ as ManifestVolume, y as MatchedPolicy, bm as ModelRef, N as NormalizedOpenAIUsage, i as OPENAI_MODEL_PRICING_USD_PER_MILLION, O as OpenAIModelPricing, h as OpenAITokenSpend, l as OpenAIUsageSpendEvent, Y as OpenEnvironmentOptions, H as PermissionActionSpec, F as PermissionPolicySpec, ac as PermissionProfile, B as PermissionProfileFile, ae as PermissionProfileListResponse, ab as PermissionRules, z as PolicyDecision, A as PolicyEvaluationContext, v as PolicyOperator, w as PolicyOrigin, q as PolicyOutcome, u as PolicyPredicateSource, x as PolicyRuleIR, s as PolicySource, aD as PublishEffectsResult, f as PublishToolsResult, a5 as QuotaLineItemFilter, a2 as QuotaPeriod, a1 as QuotaScopeType, a3 as QuotaStatus, bg as RPCRequest, bj as RPCRequestFromServer, bh as RPCResponse, bz as RecordImport, by as RecordImportItem, bw as RecordImportItemStatus, bu as RecordImportOptions, bx as RecordImportStats, bv as RecordImportStatus, bt as RecordImportWriteMode, b8 as RecordMentionInput, bp as RecordObjectOptions, bq as RecordObjectResult, br as RecordObjectsChunkInfo, bs as RecordObjectsOptions, m as RecordOpenAIUsageSpendOptions, o as RecordOpenAIUsageSpendResult, b7 as RecordSearchOptions, b6 as RecordSearchResult, W as RecordUserOptions, bn as RelationshipInfo, ay as ResolvedEffectApprovalRequired, aw as ResolvedEffectDryRun, av as ResolvedEffectPostCondition, ax as ResolvedEffectReverse, bC as RunEnvironmentImporterOptions, a8 as Sandbox, aa as SandboxListResponse, au as SemanticVersionDiff, at as SemanticVersionDiffEntry, ba as SessionCollectionListOptions, bc as SessionCollectionListResult, aX as SessionConversationMessage, b9 as SessionDocumentResult, a_ as SessionFileKind, b0 as SessionFileRecord, aZ as SessionFileSource, a$ as SessionFileStatus, b1 as SessionFileUploadOptions, b3 as SessionHeapFieldType, b4 as SessionHeapFieldValue, b5 as SessionHeapVariable, bb as SessionJobListOptions, b2 as SessionJobRecord, aY as SessionTimelineEvent, a0 as SpendLineItemType, a4 as SpendSummary, c3 as StreamEvent, c5 as StreamStats, c4 as StreamSubscription, X as Subject, bi as SyncMessage, g as ToolHandler, aF as ToolInfo, bk as ToolInvokeParams, bl as ToolResultParams, e as ToolSchema, aH as ToolsChangedEvent, V as User, ar as Version, aj as VersionTag, ai as VersionTracking, bf as WSClientOptions, bd as WSDisconnectInfo, be as WSReconnectErrorInfo, p as buildOpenAISpendEventId, k as calculateOpenAITokenSpend, j as getOpenAIModelPricing, n as normalizeOpenAIUsage, r as recordOpenAIUsageSpend, t as toGranularHttpBase } from './spend-D2Vy3N1D.js';
|
|
5
4
|
export { BuildGranularAgentSystemPromptInput, GeneratedJobCodeIssue, GranularAgentExecutionCheckpoint, GranularAgentHeapSummaryOptions, GranularAgentPromptCapabilities, GranularAgentReferentFocus, GranularAgentSessionContext, GranularAgentToolInfo, GranularAgentWorkflowFocus, GranularReasoningTraceChunkResult, GranularReasoningTraceOptions, HarnessContinuationDecision, HarnessControllerBudgets, HarnessProjectionOptions, HarnessPromptLike, HarnessRenderedContinuation, HarnessRenderedPrompt, HarnessTemplate, HarnessTemplateManifest, HarnessTemplateSelectionOptions, HarnessTemplateStatus, HarnessVerifierSnapshot, HarnessVerifierSnapshotInput, ReviewGeneratedJobCodeOptions, buildContinuationInstruction, buildContinuationInstructionFromTemplate, buildGranularAgentCheckpointBlock, buildGranularAgentDomainBlock, buildGranularAgentFileBlock, buildGranularAgentHeapBlock, buildGranularAgentLoopBlock, buildGranularAgentReferentBlock, buildGranularAgentRuntimeImportsBlock, buildGranularAgentSessionBlock, buildGranularAgentSystemPrompt, buildGranularAgentSystemPromptFromTemplate, buildGranularAgentToolBlock, buildGranularAgentWorkflowBlock, consumeGranularReasoningOnlyChunk, consumeGranularReasoningTraceChunk, createHarnessVerifierSnapshot, evaluateContinuation, getCurrentClosureId, getDefaultHarnessTemplateId, getExclusivePromptTarget, hasOpenPrompt, hashHarnessTemplateValue, listHarnessTemplates, projectConversationReferentFocus, projectConversationReferentSummary, projectHeapSummary, projectLoopSummary, projectSessionFileSummary, projectWorkflowFocus, projectWorkflowSummary, renderContinuationInstructionFromTemplate, renderGranularAgentSystemPromptFromTemplate, resolveHarnessTemplate, reviewGeneratedJobCode, stripGranularReasoningTrace, validateHarnessTemplateManifest } from './agent-harness.js';
|
|
6
5
|
import '@automerge/automerge';
|
|
7
6
|
import '@automerge/automerge/slim';
|