@granular-software/sdk 0.4.19 → 0.4.21
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/README.md +44 -4
- package/dist/agent-evals.d.mts +1 -1
- package/dist/agent-evals.d.ts +1 -1
- package/dist/agent-evals.js +169 -36
- package/dist/agent-evals.js.map +1 -1
- package/dist/agent-evals.mjs +169 -36
- package/dist/agent-evals.mjs.map +1 -1
- package/dist/agent-harness.js +5 -2
- package/dist/agent-harness.js.map +1 -1
- package/dist/agent-harness.mjs +5 -2
- package/dist/agent-harness.mjs.map +1 -1
- package/dist/cli/index.js +162 -31
- package/dist/{client-BQw_gUK3.d.mts → client-DLGC0mJk.d.mts} +67 -6
- package/dist/{client-BQw_gUK3.d.ts → client-DLGC0mJk.d.ts} +67 -6
- package/dist/index.d.mts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +166 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +164 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -8941,7 +8941,7 @@ function manifestGuideEndToEndSection() {
|
|
|
8941
8941
|
| 2 | \`granular build\` | Manifest **uploaded**; ontology version created or reused; build run compiles it; errors surface here |
|
|
8942
8942
|
| 3 | (Optional) Run your **effects host** \u2014 e.g. \`npx tsx granular-effects.ts\` \u2014 calling \`registerEffects(sandboxId, \u2026)\` | Effect **handlers** attached in **your** process |
|
|
8943
8943
|
| 4 | \`new Granular({ apiKey })\` then \`connect({ ontology, environment, userId, permissions })\` | **\`Environment\`** for that ontology environment slot |
|
|
8944
|
-
| 5 | \`recordObject\` / \`recordObjects\` | **Records** stored with correct fields and relationship keys |
|
|
8944
|
+
| 5 | \`recordObject\` / \`recordObjects\` | **Records** stored with correct fields and relationship keys. \`recordObjects\` chunks to the control plane (default 100 rows/request); pass \`onChunkComplete\` / \`concurrency\` for UI progress. For async bulk loads use \`enqueueRecordImport\` + import status APIs. |
|
|
8945
8945
|
| 6 | \`submitJob(\`\u2026\`)\` with imports from \`./sandbox-tools\` | **Jobs** run; may call **effects** \u2192 your handlers execute and return results |
|
|
8946
8946
|
|
|
8947
8947
|
**Accuracy tip:** After changing the manifest, always **re-build** before assuming generated types, \`./sandbox-tools\` names, or effect signatures match the file on disk.`;
|
|
@@ -14961,8 +14961,8 @@ ${effectMetamodelTable}
|
|
|
14961
14961
|
|-----|---------|
|
|
14962
14962
|
| \`environmentId\`, \`sandboxId\`, \`apiEndpoint\`, \u2026 | Session context. |
|
|
14963
14963
|
| \`applyManifest(manifest)\` | Apply manifest operations at runtime (alternative to CLI build for dynamic ontologies). |
|
|
14964
|
-
| \`recordObject\` / \`recordObjects\` | Upsert instances and relationships. |
|
|
14965
|
-
| \`enqueueRecordImport\`, \`listRecordImports\`, \`getRecordImportSummary\`, \u2026 |
|
|
14964
|
+
| \`recordObject\` / \`recordObjects\` | Upsert instances and relationships. \`recordObjects\` uses chunked HTTP batch writes (default 100 rows/chunk); optional \`onChunkComplete\`, \`batchSize\`, \`concurrency\`. |
|
|
14965
|
+
| \`enqueueRecordImport\`, \`listRecordImports\`, \`getRecordImportSummary\`, \u2026 | **Async** bulk import (worker queue + aggregate progress). Prefer when loads are huge and fire-and-forget is OK. |
|
|
14966
14966
|
| \`graphql(query, variables?)\` | **GraphQL** \u2014 see dedicated subsection below. |
|
|
14967
14967
|
| \`defineRelationship\`, \`getRelationships\`, \`attach\`, \`detach\`, \`listRelated\` | Imperative relationship operations (same ideas as manifest \`defineRelationship\`). |
|
|
14968
14968
|
| \`submitJob(code)\` | Run code in the sandbox; import from \`./sandbox-tools\`. |
|
|
@@ -15502,6 +15502,7 @@ edit granular.json -> granular build -> granular document -> run tests -> option
|
|
|
15502
15502
|
|
|
15503
15503
|
- Default auth story: \`granular login\`. Manual \`.env.local\` editing is fallback guidance only.
|
|
15504
15504
|
- Read \`GRANULAR_SANDBOX.md\` before writing \`recordObject\` payloads or relationship keys.
|
|
15505
|
+
- Large ingests: use \`recordObjects(rows, { onChunkComplete, concurrency })\` for synchronous chunked writes with progress, or \`enqueueRecordImport\` + \`getRecordImport\` for async queue-based bulk loads.
|
|
15505
15506
|
- Build failures should be mapped to the exact class, relationship, or effect declaration that caused them.
|
|
15506
15507
|
- If the user starts from the control plane UI, converge back to the same repo state and the same CLI commands.
|
|
15507
15508
|
`
|
|
@@ -17989,10 +17990,15 @@ var Session = class {
|
|
|
17989
17990
|
* ```typescript
|
|
17990
17991
|
* import { Author, Book, global_search } from './sandbox-tools';
|
|
17991
17992
|
*
|
|
17992
|
-
* const
|
|
17993
|
+
* const totalAuthors = await Author.count();
|
|
17994
|
+
* const firstAuthorsPage = await Author.page({ page: 1, perPage: 10, saveAs: 'recent_authors' });
|
|
17995
|
+
* const authors = firstAuthorsPage.items;
|
|
17993
17996
|
* const tolkien = await Author.get({ path: 'author_tolkien' });
|
|
17994
17997
|
* const bio = await tolkien.get_bio({ detailed: true });
|
|
17995
17998
|
* const books = await tolkien.get_books();
|
|
17999
|
+
* for await (const author of Author.iterate({ perPage: 100, maxItems: 500 })) {
|
|
18000
|
+
* console.log(author.id);
|
|
18001
|
+
* }
|
|
17996
18002
|
* ```
|
|
17997
18003
|
*
|
|
17998
18004
|
* Effect calls (instance methods, static methods, global functions) trigger
|
|
@@ -18859,14 +18865,49 @@ var STANDARD_MODULES_OPERATIONS = [
|
|
|
18859
18865
|
{ create: "class", extends: "entity", has: {} },
|
|
18860
18866
|
{ create: "user", extends: "entity", has: { email: { value: void 0 }, firstName: { value: void 0 }, lastName: { value: void 0 } } },
|
|
18861
18867
|
{ create: "company", extends: "entity", has: { name: { value: void 0 }, website: { value: void 0 } } },
|
|
18862
|
-
{ create: "string", has: {
|
|
18863
|
-
{ create: "number", has: {
|
|
18864
|
-
{ create: "boolean", has: {
|
|
18868
|
+
{ create: "string", has: {} },
|
|
18869
|
+
{ create: "number", has: {} },
|
|
18870
|
+
{ create: "boolean", has: {} },
|
|
18865
18871
|
{ create: "tool_parameter", has: { name: { value: void 0 }, type: { value: "string" }, description: { value: void 0 }, required: { value: false } } }
|
|
18866
18872
|
];
|
|
18867
18873
|
var BUILTIN_MODULES = {
|
|
18868
18874
|
"standard_modules": STANDARD_MODULES_OPERATIONS
|
|
18869
18875
|
};
|
|
18876
|
+
var DEFAULT_DIRECT_RECORD_OBJECTS_REQUEST_BATCH_SIZE = 100;
|
|
18877
|
+
var MAX_RECORD_OBJECTS_CONCURRENCY = 16;
|
|
18878
|
+
var DEFAULT_DIRECT_RECORD_OBJECTS_RETRY_COUNT = 3;
|
|
18879
|
+
var DEFAULT_DIRECT_RECORD_OBJECTS_RETRY_DELAY_MS = 1e3;
|
|
18880
|
+
var LOCAL_CONTROL_REQUEST_RETRY_COUNT = 4;
|
|
18881
|
+
var LOCAL_CONTROL_REQUEST_RETRY_DELAY_MS = 500;
|
|
18882
|
+
function planRecordObjectsChunks(records, batchSize) {
|
|
18883
|
+
const total = records.length;
|
|
18884
|
+
const size = Math.max(1, Math.min(batchSize, total));
|
|
18885
|
+
const chunkCount = Math.ceil(total / size);
|
|
18886
|
+
const plans = [];
|
|
18887
|
+
for (let offset = 0, chunkIndex = 0; offset < total; offset += size, chunkIndex += 1) {
|
|
18888
|
+
const slice = records.slice(offset, offset + size);
|
|
18889
|
+
plans.push({ chunkIndex, chunkCount, offset, slice });
|
|
18890
|
+
}
|
|
18891
|
+
return plans;
|
|
18892
|
+
}
|
|
18893
|
+
function sleep(ms) {
|
|
18894
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
18895
|
+
}
|
|
18896
|
+
function isLocalControlUrl(url) {
|
|
18897
|
+
try {
|
|
18898
|
+
const parsed = new URL(url);
|
|
18899
|
+
return parsed.hostname === "127.0.0.1" || parsed.hostname === "localhost" || parsed.hostname === "::1";
|
|
18900
|
+
} catch {
|
|
18901
|
+
return false;
|
|
18902
|
+
}
|
|
18903
|
+
}
|
|
18904
|
+
function isRetryableLocalWorkerRestart(status, body, url) {
|
|
18905
|
+
return isLocalControlUrl(url) && (status === 503 && body.includes("Your worker restarted mid-request") || status === 500 && body.includes("Network connection lost"));
|
|
18906
|
+
}
|
|
18907
|
+
function isRetryableRecordObjectsError(error2) {
|
|
18908
|
+
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
18909
|
+
return /worker restarted mid-request|econnreset|network|socket connection was closed unexpectedly|timed out/i.test(message);
|
|
18910
|
+
}
|
|
18870
18911
|
function computeEffectKey2(effect) {
|
|
18871
18912
|
const attachedClass = effect.className?.trim();
|
|
18872
18913
|
if (!attachedClass) {
|
|
@@ -19824,24 +19865,101 @@ var Environment = class extends Session {
|
|
|
19824
19865
|
/**
|
|
19825
19866
|
* Batch version of `recordObject()`.
|
|
19826
19867
|
*
|
|
19827
|
-
* Sends
|
|
19828
|
-
*
|
|
19868
|
+
* Sends rows through the control-plane **`/records/batch`** endpoint in **chunks** (default
|
|
19869
|
+
* **100** records per HTTP request) so individual requests stay bounded and gateway timeouts are
|
|
19870
|
+
* unlikely. Each chunk is retried on transient network / worker errors.
|
|
19871
|
+
*
|
|
19872
|
+
* Use the optional second argument to:
|
|
19873
|
+
* - **`batchSize`** — rows per POST (smaller = more progress events; larger = fewer round trips).
|
|
19874
|
+
* - **`concurrency`** — run up to N chunk POSTs in parallel (capped at 16) when you want lower wall time.
|
|
19875
|
+
* - **`onChunkComplete`** — hook for UIs after each chunk succeeds (row order in the returned array
|
|
19876
|
+
* always matches `records`; chunk **completion** order may differ when `concurrency > 1`).
|
|
19877
|
+
*
|
|
19878
|
+
* For **asynchronous** ingestion with worker-side batching and aggregate counters (`queued`,
|
|
19879
|
+
* `completed`, …), use **`enqueueRecordImport`** and poll **`getRecordImport`** /
|
|
19880
|
+
* **`getRecordImportSummary`** — best for very large fire-and-forget loads when immediate
|
|
19881
|
+
* synchronous commit of every row is not required.
|
|
19829
19882
|
*/
|
|
19830
|
-
async recordObjects(records) {
|
|
19883
|
+
async recordObjects(records, options) {
|
|
19831
19884
|
if (!Array.isArray(records) || records.length === 0) {
|
|
19832
19885
|
return [];
|
|
19833
19886
|
}
|
|
19834
|
-
const
|
|
19835
|
-
|
|
19836
|
-
|
|
19837
|
-
|
|
19838
|
-
|
|
19839
|
-
|
|
19887
|
+
const batchSize = Math.max(
|
|
19888
|
+
1,
|
|
19889
|
+
Math.min(
|
|
19890
|
+
records.length,
|
|
19891
|
+
options?.batchSize ?? DEFAULT_DIRECT_RECORD_OBJECTS_REQUEST_BATCH_SIZE
|
|
19892
|
+
)
|
|
19840
19893
|
);
|
|
19841
|
-
|
|
19894
|
+
const concurrency = Math.min(
|
|
19895
|
+
MAX_RECORD_OBJECTS_CONCURRENCY,
|
|
19896
|
+
Math.max(1, options?.concurrency ?? 1)
|
|
19897
|
+
);
|
|
19898
|
+
const plans = planRecordObjectsChunks(records, batchSize);
|
|
19899
|
+
const total = records.length;
|
|
19900
|
+
const results = new Array(total);
|
|
19901
|
+
const onChunk = options?.onChunkComplete;
|
|
19902
|
+
for (let waveStart = 0; waveStart < plans.length; waveStart += concurrency) {
|
|
19903
|
+
const wave = plans.slice(waveStart, waveStart + concurrency);
|
|
19904
|
+
await Promise.all(
|
|
19905
|
+
wave.map(async (plan) => {
|
|
19906
|
+
const { items, durationMs } = await this.executeRecordObjectsChunk(plan.slice);
|
|
19907
|
+
if (items.length !== plan.slice.length) {
|
|
19908
|
+
throw new Error(
|
|
19909
|
+
`recordObjects: chunk ${plan.chunkIndex + 1} returned ${items.length} results, expected ${plan.slice.length}`
|
|
19910
|
+
);
|
|
19911
|
+
}
|
|
19912
|
+
for (let index = 0; index < items.length; index += 1) {
|
|
19913
|
+
results[plan.offset + index] = items[index];
|
|
19914
|
+
}
|
|
19915
|
+
if (onChunk) {
|
|
19916
|
+
const info2 = {
|
|
19917
|
+
chunkIndex: plan.chunkIndex,
|
|
19918
|
+
totalChunks: plan.chunkCount,
|
|
19919
|
+
offset: plan.offset,
|
|
19920
|
+
recordCount: plan.slice.length,
|
|
19921
|
+
durationMs,
|
|
19922
|
+
results: items
|
|
19923
|
+
};
|
|
19924
|
+
await onChunk(info2);
|
|
19925
|
+
}
|
|
19926
|
+
})
|
|
19927
|
+
);
|
|
19928
|
+
}
|
|
19929
|
+
return results;
|
|
19930
|
+
}
|
|
19931
|
+
async executeRecordObjectsChunk(chunk) {
|
|
19932
|
+
const wallStart = Date.now();
|
|
19933
|
+
let lastError;
|
|
19934
|
+
for (let attempt = 1; attempt <= DEFAULT_DIRECT_RECORD_OBJECTS_RETRY_COUNT; attempt += 1) {
|
|
19935
|
+
try {
|
|
19936
|
+
const response = await this.controlPlaneRequest(
|
|
19937
|
+
`/control/environments/${this.environmentId}/records/batch`,
|
|
19938
|
+
{
|
|
19939
|
+
method: "POST",
|
|
19940
|
+
body: JSON.stringify({ records: chunk })
|
|
19941
|
+
}
|
|
19942
|
+
);
|
|
19943
|
+
const items = Array.isArray(response.items) ? response.items : [];
|
|
19944
|
+
return { items, durationMs: Date.now() - wallStart };
|
|
19945
|
+
} catch (error2) {
|
|
19946
|
+
lastError = error2;
|
|
19947
|
+
if (!isRetryableRecordObjectsError(error2) || attempt === DEFAULT_DIRECT_RECORD_OBJECTS_RETRY_COUNT) {
|
|
19948
|
+
throw error2;
|
|
19949
|
+
}
|
|
19950
|
+
await sleep(DEFAULT_DIRECT_RECORD_OBJECTS_RETRY_DELAY_MS * attempt);
|
|
19951
|
+
}
|
|
19952
|
+
}
|
|
19953
|
+
throw lastError instanceof Error ? lastError : new Error(String(lastError));
|
|
19842
19954
|
}
|
|
19843
19955
|
/**
|
|
19844
|
-
* Queue a background record import for this environment.
|
|
19956
|
+
* Queue a background record import for this environment (async worker pipeline).
|
|
19957
|
+
*
|
|
19958
|
+
* **vs `recordObjects`:** this path accepts the full payload in one request, returns an
|
|
19959
|
+
* **`importId`**, and processes rows in the background — use **`getRecordImport`** /
|
|
19960
|
+
* **`getRecordImportSummary`** for progress. Choose it for large bulk loads where you do not
|
|
19961
|
+
* need every row committed before the HTTP call returns. Use **`recordObjects`** when you need
|
|
19962
|
+
* synchronous upserts and fine-grained chunk progress via **`onChunkComplete`**.
|
|
19845
19963
|
*/
|
|
19846
19964
|
async enqueueRecordImport(records, options = {}) {
|
|
19847
19965
|
return this.controlPlaneRequest(
|
|
@@ -20809,23 +20927,36 @@ var Granular = class _Granular {
|
|
|
20809
20927
|
if (this.debugHttp) {
|
|
20810
20928
|
console.log(`[SDK] Requesting: ${url}`);
|
|
20811
20929
|
}
|
|
20812
|
-
|
|
20813
|
-
|
|
20814
|
-
|
|
20815
|
-
|
|
20816
|
-
|
|
20817
|
-
|
|
20818
|
-
|
|
20930
|
+
for (let attempt = 1; attempt <= LOCAL_CONTROL_REQUEST_RETRY_COUNT; attempt += 1) {
|
|
20931
|
+
const response = await fetch(url, {
|
|
20932
|
+
...options,
|
|
20933
|
+
headers: {
|
|
20934
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
20935
|
+
"Content-Type": "application/json",
|
|
20936
|
+
"Connection": "close",
|
|
20937
|
+
...options.headers
|
|
20938
|
+
}
|
|
20939
|
+
});
|
|
20940
|
+
if (response.ok) {
|
|
20941
|
+
if (response.status === 204) {
|
|
20942
|
+
return { deleted: true };
|
|
20943
|
+
}
|
|
20944
|
+
return response.json();
|
|
20819
20945
|
}
|
|
20820
|
-
});
|
|
20821
|
-
if (!response.ok) {
|
|
20822
20946
|
const errorText = await response.text();
|
|
20947
|
+
const retryable = isRetryableLocalWorkerRestart(response.status, errorText, url);
|
|
20948
|
+
if (retryable && attempt < LOCAL_CONTROL_REQUEST_RETRY_COUNT) {
|
|
20949
|
+
if (this.debugHttp) {
|
|
20950
|
+
console.warn(
|
|
20951
|
+
`[SDK] Retrying local control request after worker restart (${attempt}/${LOCAL_CONTROL_REQUEST_RETRY_COUNT - 1} retries used): ${url}`
|
|
20952
|
+
);
|
|
20953
|
+
}
|
|
20954
|
+
await sleep(LOCAL_CONTROL_REQUEST_RETRY_DELAY_MS * attempt);
|
|
20955
|
+
continue;
|
|
20956
|
+
}
|
|
20823
20957
|
throw new Error(`Granular API Error (${response.status}): ${errorText}`);
|
|
20824
20958
|
}
|
|
20825
|
-
|
|
20826
|
-
return { deleted: true };
|
|
20827
|
-
}
|
|
20828
|
-
return response.json();
|
|
20959
|
+
throw new Error(`Granular API Error: exhausted retries for ${url}`);
|
|
20829
20960
|
}
|
|
20830
20961
|
};
|
|
20831
20962
|
|
|
@@ -862,6 +862,43 @@ interface RecordObjectResult {
|
|
|
862
862
|
/** Whether the instance was newly created (false = updated) */
|
|
863
863
|
created: boolean;
|
|
864
864
|
}
|
|
865
|
+
/**
|
|
866
|
+
* Metadata for one completed HTTP chunk in `recordObjects()`.
|
|
867
|
+
* Chunk indices follow input order; when concurrency is greater than 1, completion order may differ.
|
|
868
|
+
*/
|
|
869
|
+
interface RecordObjectsChunkInfo {
|
|
870
|
+
/** Zero-based chunk index */
|
|
871
|
+
chunkIndex: number;
|
|
872
|
+
totalChunks: number;
|
|
873
|
+
/** Zero-based offset into the original `records` array */
|
|
874
|
+
offset: number;
|
|
875
|
+
/** Number of records in this chunk */
|
|
876
|
+
recordCount: number;
|
|
877
|
+
/** Wall time for this chunk’s POST (including retries) */
|
|
878
|
+
durationMs: number;
|
|
879
|
+
/** Acknowledgements for this chunk, in the same order as the slice sent */
|
|
880
|
+
results: RecordObjectResult[];
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Optional tuning for `recordObjects()` — batching, parallelism, and progress hooks.
|
|
884
|
+
*/
|
|
885
|
+
interface RecordObjectsOptions {
|
|
886
|
+
/**
|
|
887
|
+
* Max records per HTTP POST to the control-plane batch endpoint. Default 100.
|
|
888
|
+
* Smaller values: more round trips and finer `onChunkComplete` updates.
|
|
889
|
+
* Larger values: fewer requests (watch request size/timeouts).
|
|
890
|
+
*/
|
|
891
|
+
batchSize?: number;
|
|
892
|
+
/**
|
|
893
|
+
* How many chunk POSTs may run concurrently. Default 1 (strictly sequential).
|
|
894
|
+
* Values above 1 can reduce wall time when the server can overlap work; capped at 16.
|
|
895
|
+
*/
|
|
896
|
+
concurrency?: number;
|
|
897
|
+
/**
|
|
898
|
+
* Called after each chunk succeeds (after retries). Useful for UI progress bars.
|
|
899
|
+
*/
|
|
900
|
+
onChunkComplete?: (info: RecordObjectsChunkInfo) => void | Promise<void>;
|
|
901
|
+
}
|
|
865
902
|
type RecordImportStatus = 'queued' | 'processing' | 'completed' | 'failed' | 'canceled';
|
|
866
903
|
type RecordImportItemStatus = 'queued' | 'processing' | 'completed' | 'failed' | 'canceled';
|
|
867
904
|
interface RecordImportStats {
|
|
@@ -1277,10 +1314,15 @@ declare class Session {
|
|
|
1277
1314
|
* ```typescript
|
|
1278
1315
|
* import { Author, Book, global_search } from './sandbox-tools';
|
|
1279
1316
|
*
|
|
1280
|
-
* const
|
|
1317
|
+
* const totalAuthors = await Author.count();
|
|
1318
|
+
* const firstAuthorsPage = await Author.page({ page: 1, perPage: 10, saveAs: 'recent_authors' });
|
|
1319
|
+
* const authors = firstAuthorsPage.items;
|
|
1281
1320
|
* const tolkien = await Author.get({ path: 'author_tolkien' });
|
|
1282
1321
|
* const bio = await tolkien.get_bio({ detailed: true });
|
|
1283
1322
|
* const books = await tolkien.get_books();
|
|
1323
|
+
* for await (const author of Author.iterate({ perPage: 100, maxItems: 500 })) {
|
|
1324
|
+
* console.log(author.id);
|
|
1325
|
+
* }
|
|
1284
1326
|
* ```
|
|
1285
1327
|
*
|
|
1286
1328
|
* Effect calls (instance methods, static methods, global functions) trigger
|
|
@@ -1682,12 +1724,31 @@ declare class Environment extends Session {
|
|
|
1682
1724
|
/**
|
|
1683
1725
|
* Batch version of `recordObject()`.
|
|
1684
1726
|
*
|
|
1685
|
-
* Sends
|
|
1686
|
-
*
|
|
1727
|
+
* Sends rows through the control-plane **`/records/batch`** endpoint in **chunks** (default
|
|
1728
|
+
* **100** records per HTTP request) so individual requests stay bounded and gateway timeouts are
|
|
1729
|
+
* unlikely. Each chunk is retried on transient network / worker errors.
|
|
1730
|
+
*
|
|
1731
|
+
* Use the optional second argument to:
|
|
1732
|
+
* - **`batchSize`** — rows per POST (smaller = more progress events; larger = fewer round trips).
|
|
1733
|
+
* - **`concurrency`** — run up to N chunk POSTs in parallel (capped at 16) when you want lower wall time.
|
|
1734
|
+
* - **`onChunkComplete`** — hook for UIs after each chunk succeeds (row order in the returned array
|
|
1735
|
+
* always matches `records`; chunk **completion** order may differ when `concurrency > 1`).
|
|
1736
|
+
*
|
|
1737
|
+
* For **asynchronous** ingestion with worker-side batching and aggregate counters (`queued`,
|
|
1738
|
+
* `completed`, …), use **`enqueueRecordImport`** and poll **`getRecordImport`** /
|
|
1739
|
+
* **`getRecordImportSummary`** — best for very large fire-and-forget loads when immediate
|
|
1740
|
+
* synchronous commit of every row is not required.
|
|
1687
1741
|
*/
|
|
1688
|
-
recordObjects(records: RecordObjectOptions[]): Promise<RecordObjectResult[]>;
|
|
1742
|
+
recordObjects(records: RecordObjectOptions[], options?: RecordObjectsOptions): Promise<RecordObjectResult[]>;
|
|
1743
|
+
private executeRecordObjectsChunk;
|
|
1689
1744
|
/**
|
|
1690
|
-
* Queue a background record import for this environment.
|
|
1745
|
+
* Queue a background record import for this environment (async worker pipeline).
|
|
1746
|
+
*
|
|
1747
|
+
* **vs `recordObjects`:** this path accepts the full payload in one request, returns an
|
|
1748
|
+
* **`importId`**, and processes rows in the background — use **`getRecordImport`** /
|
|
1749
|
+
* **`getRecordImportSummary`** for progress. Choose it for large bulk loads where you do not
|
|
1750
|
+
* need every row committed before the HTTP call returns. Use **`recordObjects`** when you need
|
|
1751
|
+
* synchronous upserts and fine-grained chunk progress via **`onChunkComplete`**.
|
|
1691
1752
|
*/
|
|
1692
1753
|
enqueueRecordImport(records: RecordObjectOptions[], options?: {
|
|
1693
1754
|
batchSize?: number;
|
|
@@ -1992,4 +2053,4 @@ declare class Granular {
|
|
|
1992
2053
|
private request;
|
|
1993
2054
|
}
|
|
1994
2055
|
|
|
1995
|
-
export { type EffectInvocationMode as $, type AccessTokenProvider as A, type BuildPolicy as B, type ConnectOptions as C, type DomainState as D, type
|
|
2056
|
+
export { type EffectInvocationMode as $, type AccessTokenProvider as A, type BuildPolicy as B, type ConnectOptions as C, type DomainState as D, type EndpointMode as E, type Manifest as F, Granular as G, type ManifestListResponse as H, type InstanceToolHandler as I, type BuildStatus as J, type Build as K, type Version as L, type ManifestEffectMetamodelSpec as M, type BuildListResponse as N, type SemanticVersionDiffEntry as O, type Prompt as P, type SemanticVersionDiff as Q, type ResolvedEffectBehaviors as R, type SessionHeapEntry as S, type ToolWithHandler as T, type User as U, type VersionTracking as V, WSClient as W, type ResolvedEffectPostCondition as X, type ResolvedEffectDryRun as Y, type ResolvedEffectReverse as Z, type ResolvedEffectApprovalRequired as _, type EffectHandlerContext as a, type ManifestContent as a$, type EffectInvocationMetadata as a0, type EffectSchema as a1, type EffectWithHandler as a2, type PublishEffectsResult as a3, type ToolInfo as a4, type EffectInfo as a5, type ToolsChangedEvent as a6, type EffectsChangedEvent as a7, type EffectHandler as a8, type InstanceEffectHandler as a9, type RecordObjectsOptions as aA, type RecordImportStatus as aB, type RecordImportItemStatus as aC, type RecordImportStats as aD, type RecordImportItem as aE, type RecordImport as aF, type EnvironmentRecordImportSummary as aG, type ManifestPropertySpec as aH, type ManifestValidationOperator as aI, type ManifestEnumRuleSpec as aJ, type ManifestFilterBySpec as aK, type ManifestValidationRuleSpec as aL, type ManifestStateMachineStateSpec as aM, type ManifestStateMachineTransitionSpec as aN, type ManifestStateMachineSpec as aO, type ManifestPostConditionSpec as aP, type ManifestDryRunSpec as aQ, type ManifestReverseSpec as aR, type ManifestApprovalRequiredSpec as aS, type ManifestRelationshipDef as aT, type ManifestEffectSchema as aU, type ManifestEffectDeclaration as aV, type ManifestEventTypeDef as aW, type ManifestEventStreamDef as aX, type ManifestOperation as aY, type ManifestImport as aZ, type ManifestVolume as a_, type JobStatus as aa, type JobFeedbackSentiment as ab, type JobFeedbackToolCall as ac, type JobFeedbackMetadata as ad, type JobFeedbackInput as ae, type JobFeedbackRecord as af, type JobSubmitResult as ag, type Job as ah, type SessionHeapFieldType as ai, type SessionHeapFieldValue as aj, type SessionHeapVariable as ak, type WSDisconnectInfo as al, type WSReconnectErrorInfo as am, type WSClientOptions as an, type RPCRequest as ao, type RPCResponse as ap, type SyncMessage as aq, type RPCRequestFromServer as ar, type ToolInvokeParams as as, type ToolResultParams as at, type ModelRef as au, type RelationshipInfo as av, type DefineRelationshipOptions as aw, type RecordObjectOptions as ax, type RecordObjectResult as ay, type RecordObjectsChunkInfo as az, type SessionHeapList as b, type GraphQLResult as b0, type APIError as b1, type DeleteResponse as b2, type StreamEvent as b3, type StreamSubscription as b4, type StreamStats as b5, type SessionHeapSnapshot as c, Environment as d, Session as e, type ToolSchema as f, type PublishToolsResult as g, type ToolHandler as h, type GranularOptions as i, type GranularAuth as j, type RecordUserOptions as k, type Subject as l, type ConversationSessionInfo as m, type Sandbox as n, type CreateSandboxData as o, type SandboxListResponse as p, type PermissionRules as q, type PermissionProfile as r, type CreatePermissionProfileData as s, type PermissionProfileListResponse as t, type Assignment as u, type AssignmentListResponse as v, type VersionTag as w, type EnvironmentData as x, type CreateEnvironmentData as y, type EnvironmentListResponse as z };
|
|
@@ -862,6 +862,43 @@ interface RecordObjectResult {
|
|
|
862
862
|
/** Whether the instance was newly created (false = updated) */
|
|
863
863
|
created: boolean;
|
|
864
864
|
}
|
|
865
|
+
/**
|
|
866
|
+
* Metadata for one completed HTTP chunk in `recordObjects()`.
|
|
867
|
+
* Chunk indices follow input order; when concurrency is greater than 1, completion order may differ.
|
|
868
|
+
*/
|
|
869
|
+
interface RecordObjectsChunkInfo {
|
|
870
|
+
/** Zero-based chunk index */
|
|
871
|
+
chunkIndex: number;
|
|
872
|
+
totalChunks: number;
|
|
873
|
+
/** Zero-based offset into the original `records` array */
|
|
874
|
+
offset: number;
|
|
875
|
+
/** Number of records in this chunk */
|
|
876
|
+
recordCount: number;
|
|
877
|
+
/** Wall time for this chunk’s POST (including retries) */
|
|
878
|
+
durationMs: number;
|
|
879
|
+
/** Acknowledgements for this chunk, in the same order as the slice sent */
|
|
880
|
+
results: RecordObjectResult[];
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Optional tuning for `recordObjects()` — batching, parallelism, and progress hooks.
|
|
884
|
+
*/
|
|
885
|
+
interface RecordObjectsOptions {
|
|
886
|
+
/**
|
|
887
|
+
* Max records per HTTP POST to the control-plane batch endpoint. Default 100.
|
|
888
|
+
* Smaller values: more round trips and finer `onChunkComplete` updates.
|
|
889
|
+
* Larger values: fewer requests (watch request size/timeouts).
|
|
890
|
+
*/
|
|
891
|
+
batchSize?: number;
|
|
892
|
+
/**
|
|
893
|
+
* How many chunk POSTs may run concurrently. Default 1 (strictly sequential).
|
|
894
|
+
* Values above 1 can reduce wall time when the server can overlap work; capped at 16.
|
|
895
|
+
*/
|
|
896
|
+
concurrency?: number;
|
|
897
|
+
/**
|
|
898
|
+
* Called after each chunk succeeds (after retries). Useful for UI progress bars.
|
|
899
|
+
*/
|
|
900
|
+
onChunkComplete?: (info: RecordObjectsChunkInfo) => void | Promise<void>;
|
|
901
|
+
}
|
|
865
902
|
type RecordImportStatus = 'queued' | 'processing' | 'completed' | 'failed' | 'canceled';
|
|
866
903
|
type RecordImportItemStatus = 'queued' | 'processing' | 'completed' | 'failed' | 'canceled';
|
|
867
904
|
interface RecordImportStats {
|
|
@@ -1277,10 +1314,15 @@ declare class Session {
|
|
|
1277
1314
|
* ```typescript
|
|
1278
1315
|
* import { Author, Book, global_search } from './sandbox-tools';
|
|
1279
1316
|
*
|
|
1280
|
-
* const
|
|
1317
|
+
* const totalAuthors = await Author.count();
|
|
1318
|
+
* const firstAuthorsPage = await Author.page({ page: 1, perPage: 10, saveAs: 'recent_authors' });
|
|
1319
|
+
* const authors = firstAuthorsPage.items;
|
|
1281
1320
|
* const tolkien = await Author.get({ path: 'author_tolkien' });
|
|
1282
1321
|
* const bio = await tolkien.get_bio({ detailed: true });
|
|
1283
1322
|
* const books = await tolkien.get_books();
|
|
1323
|
+
* for await (const author of Author.iterate({ perPage: 100, maxItems: 500 })) {
|
|
1324
|
+
* console.log(author.id);
|
|
1325
|
+
* }
|
|
1284
1326
|
* ```
|
|
1285
1327
|
*
|
|
1286
1328
|
* Effect calls (instance methods, static methods, global functions) trigger
|
|
@@ -1682,12 +1724,31 @@ declare class Environment extends Session {
|
|
|
1682
1724
|
/**
|
|
1683
1725
|
* Batch version of `recordObject()`.
|
|
1684
1726
|
*
|
|
1685
|
-
* Sends
|
|
1686
|
-
*
|
|
1727
|
+
* Sends rows through the control-plane **`/records/batch`** endpoint in **chunks** (default
|
|
1728
|
+
* **100** records per HTTP request) so individual requests stay bounded and gateway timeouts are
|
|
1729
|
+
* unlikely. Each chunk is retried on transient network / worker errors.
|
|
1730
|
+
*
|
|
1731
|
+
* Use the optional second argument to:
|
|
1732
|
+
* - **`batchSize`** — rows per POST (smaller = more progress events; larger = fewer round trips).
|
|
1733
|
+
* - **`concurrency`** — run up to N chunk POSTs in parallel (capped at 16) when you want lower wall time.
|
|
1734
|
+
* - **`onChunkComplete`** — hook for UIs after each chunk succeeds (row order in the returned array
|
|
1735
|
+
* always matches `records`; chunk **completion** order may differ when `concurrency > 1`).
|
|
1736
|
+
*
|
|
1737
|
+
* For **asynchronous** ingestion with worker-side batching and aggregate counters (`queued`,
|
|
1738
|
+
* `completed`, …), use **`enqueueRecordImport`** and poll **`getRecordImport`** /
|
|
1739
|
+
* **`getRecordImportSummary`** — best for very large fire-and-forget loads when immediate
|
|
1740
|
+
* synchronous commit of every row is not required.
|
|
1687
1741
|
*/
|
|
1688
|
-
recordObjects(records: RecordObjectOptions[]): Promise<RecordObjectResult[]>;
|
|
1742
|
+
recordObjects(records: RecordObjectOptions[], options?: RecordObjectsOptions): Promise<RecordObjectResult[]>;
|
|
1743
|
+
private executeRecordObjectsChunk;
|
|
1689
1744
|
/**
|
|
1690
|
-
* Queue a background record import for this environment.
|
|
1745
|
+
* Queue a background record import for this environment (async worker pipeline).
|
|
1746
|
+
*
|
|
1747
|
+
* **vs `recordObjects`:** this path accepts the full payload in one request, returns an
|
|
1748
|
+
* **`importId`**, and processes rows in the background — use **`getRecordImport`** /
|
|
1749
|
+
* **`getRecordImportSummary`** for progress. Choose it for large bulk loads where you do not
|
|
1750
|
+
* need every row committed before the HTTP call returns. Use **`recordObjects`** when you need
|
|
1751
|
+
* synchronous upserts and fine-grained chunk progress via **`onChunkComplete`**.
|
|
1691
1752
|
*/
|
|
1692
1753
|
enqueueRecordImport(records: RecordObjectOptions[], options?: {
|
|
1693
1754
|
batchSize?: number;
|
|
@@ -1992,4 +2053,4 @@ declare class Granular {
|
|
|
1992
2053
|
private request;
|
|
1993
2054
|
}
|
|
1994
2055
|
|
|
1995
|
-
export { type EffectInvocationMode as $, type AccessTokenProvider as A, type BuildPolicy as B, type ConnectOptions as C, type DomainState as D, type
|
|
2056
|
+
export { type EffectInvocationMode as $, type AccessTokenProvider as A, type BuildPolicy as B, type ConnectOptions as C, type DomainState as D, type EndpointMode as E, type Manifest as F, Granular as G, type ManifestListResponse as H, type InstanceToolHandler as I, type BuildStatus as J, type Build as K, type Version as L, type ManifestEffectMetamodelSpec as M, type BuildListResponse as N, type SemanticVersionDiffEntry as O, type Prompt as P, type SemanticVersionDiff as Q, type ResolvedEffectBehaviors as R, type SessionHeapEntry as S, type ToolWithHandler as T, type User as U, type VersionTracking as V, WSClient as W, type ResolvedEffectPostCondition as X, type ResolvedEffectDryRun as Y, type ResolvedEffectReverse as Z, type ResolvedEffectApprovalRequired as _, type EffectHandlerContext as a, type ManifestContent as a$, type EffectInvocationMetadata as a0, type EffectSchema as a1, type EffectWithHandler as a2, type PublishEffectsResult as a3, type ToolInfo as a4, type EffectInfo as a5, type ToolsChangedEvent as a6, type EffectsChangedEvent as a7, type EffectHandler as a8, type InstanceEffectHandler as a9, type RecordObjectsOptions as aA, type RecordImportStatus as aB, type RecordImportItemStatus as aC, type RecordImportStats as aD, type RecordImportItem as aE, type RecordImport as aF, type EnvironmentRecordImportSummary as aG, type ManifestPropertySpec as aH, type ManifestValidationOperator as aI, type ManifestEnumRuleSpec as aJ, type ManifestFilterBySpec as aK, type ManifestValidationRuleSpec as aL, type ManifestStateMachineStateSpec as aM, type ManifestStateMachineTransitionSpec as aN, type ManifestStateMachineSpec as aO, type ManifestPostConditionSpec as aP, type ManifestDryRunSpec as aQ, type ManifestReverseSpec as aR, type ManifestApprovalRequiredSpec as aS, type ManifestRelationshipDef as aT, type ManifestEffectSchema as aU, type ManifestEffectDeclaration as aV, type ManifestEventTypeDef as aW, type ManifestEventStreamDef as aX, type ManifestOperation as aY, type ManifestImport as aZ, type ManifestVolume as a_, type JobStatus as aa, type JobFeedbackSentiment as ab, type JobFeedbackToolCall as ac, type JobFeedbackMetadata as ad, type JobFeedbackInput as ae, type JobFeedbackRecord as af, type JobSubmitResult as ag, type Job as ah, type SessionHeapFieldType as ai, type SessionHeapFieldValue as aj, type SessionHeapVariable as ak, type WSDisconnectInfo as al, type WSReconnectErrorInfo as am, type WSClientOptions as an, type RPCRequest as ao, type RPCResponse as ap, type SyncMessage as aq, type RPCRequestFromServer as ar, type ToolInvokeParams as as, type ToolResultParams as at, type ModelRef as au, type RelationshipInfo as av, type DefineRelationshipOptions as aw, type RecordObjectOptions as ax, type RecordObjectResult as ay, type RecordObjectsChunkInfo as az, type SessionHeapList as b, type GraphQLResult as b0, type APIError as b1, type DeleteResponse as b2, type StreamEvent as b3, type StreamSubscription as b4, type StreamStats as b5, type SessionHeapSnapshot as c, Environment as d, Session as e, type ToolSchema as f, type PublishToolsResult as g, type ToolHandler as h, type GranularOptions as i, type GranularAuth as j, type RecordUserOptions as k, type Subject as l, type ConversationSessionInfo as m, type Sandbox as n, type CreateSandboxData as o, type SandboxListResponse as p, type PermissionRules as q, type PermissionProfile as r, type CreatePermissionProfileData as s, type PermissionProfileListResponse as t, type Assignment as u, type AssignmentListResponse as v, type VersionTag as w, type EnvironmentData as x, type CreateEnvironmentData as y, type EnvironmentListResponse as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
|
-
import { T as ToolWithHandler,
|
|
2
|
-
export {
|
|
1
|
+
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 } from './client-DLGC0mJk.mjs';
|
|
2
|
+
export { b1 as APIError, A as AccessTokenProvider, u as Assignment, v as AssignmentListResponse, K as Build, N as BuildListResponse, B as BuildPolicy, J as BuildStatus, C as ConnectOptions, m as ConversationSessionInfo, y as CreateEnvironmentData, s as CreatePermissionProfileData, o as CreateSandboxData, aw as DefineRelationshipOptions, b2 as DeleteResponse, D as DomainState, a8 as EffectHandler, a5 as EffectInfo, a0 as EffectInvocationMetadata, $ as EffectInvocationMode, a1 as EffectSchema, a2 as EffectWithHandler, a7 as EffectsChangedEvent, d as Environment, x as EnvironmentData, z as EnvironmentListResponse, aG as EnvironmentRecordImportSummary, G as Granular, j as GranularAuth, i as GranularOptions, b0 as GraphQLResult, a9 as InstanceEffectHandler, I as InstanceToolHandler, ah as Job, ae as JobFeedbackInput, ad as JobFeedbackMetadata, af as JobFeedbackRecord, ab as JobFeedbackSentiment, ac as JobFeedbackToolCall, aa as JobStatus, ag as JobSubmitResult, F as Manifest, aS as ManifestApprovalRequiredSpec, a$ as ManifestContent, aQ as ManifestDryRunSpec, aV as ManifestEffectDeclaration, aU as ManifestEffectSchema, aJ as ManifestEnumRuleSpec, aX as ManifestEventStreamDef, aW as ManifestEventTypeDef, aK as ManifestFilterBySpec, aZ as ManifestImport, H as ManifestListResponse, aY as ManifestOperation, aP as ManifestPostConditionSpec, aH as ManifestPropertySpec, aT as ManifestRelationshipDef, aR as ManifestReverseSpec, aO as ManifestStateMachineSpec, aM as ManifestStateMachineStateSpec, aN as ManifestStateMachineTransitionSpec, aI as ManifestValidationOperator, aL as ManifestValidationRuleSpec, a_ as ManifestVolume, au as ModelRef, r as PermissionProfile, t as PermissionProfileListResponse, q as PermissionRules, a3 as PublishEffectsResult, g as PublishToolsResult, ao as RPCRequest, ar as RPCRequestFromServer, ap as RPCResponse, aF as RecordImport, aE as RecordImportItem, aC as RecordImportItemStatus, aD as RecordImportStats, aB as RecordImportStatus, ax as RecordObjectOptions, ay as RecordObjectResult, az as RecordObjectsChunkInfo, aA as RecordObjectsOptions, k as RecordUserOptions, av as RelationshipInfo, _ as ResolvedEffectApprovalRequired, Y as ResolvedEffectDryRun, X as ResolvedEffectPostCondition, Z as ResolvedEffectReverse, n as Sandbox, p as SandboxListResponse, Q as SemanticVersionDiff, O as SemanticVersionDiffEntry, e as Session, ai as SessionHeapFieldType, aj as SessionHeapFieldValue, ak as SessionHeapVariable, b3 as StreamEvent, b5 as StreamStats, b4 as StreamSubscription, l as Subject, aq as SyncMessage, h as ToolHandler, a4 as ToolInfo, as as ToolInvokeParams, at as ToolResultParams, f as ToolSchema, a6 as ToolsChangedEvent, U as User, L as Version, w as VersionTag, V as VersionTracking, W as WSClient, an as WSClientOptions, al as WSDisconnectInfo, am as WSReconnectErrorInfo } from './client-DLGC0mJk.mjs';
|
|
3
3
|
export { BuildGranularAgentSystemPromptInput, GeneratedJobCodeIssue, GranularAgentExecutionCheckpoint, GranularAgentHeapSummaryOptions, GranularAgentSessionContext, GranularAgentToolInfo, GranularAgentWorkflowFocus, HarnessContinuationDecision, HarnessControllerBudgets, HarnessProjectionOptions, HarnessPromptLike, HarnessVerifierSnapshot, HarnessVerifierSnapshotInput, buildContinuationInstruction, buildGranularAgentCheckpointBlock, buildGranularAgentDomainBlock, buildGranularAgentHeapBlock, buildGranularAgentLoopBlock, buildGranularAgentSessionBlock, buildGranularAgentSystemPrompt, buildGranularAgentToolBlock, buildGranularAgentWorkflowBlock, createHarnessVerifierSnapshot, evaluateContinuation, getCurrentClosureId, getExclusivePromptTarget, hasOpenPrompt, projectHeapSummary, projectLoopSummary, projectWorkflowFocus, projectWorkflowSummary, reviewGeneratedJobCode } from './agent-harness.mjs';
|
|
4
4
|
import '@automerge/automerge';
|
|
5
5
|
import '@automerge/automerge/slim';
|
|
6
6
|
|
|
7
|
+
declare function isLocalApiUrl(url: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Local dev + `sk_*` (WorkOS org key in env): map to the local gn_sk e2e key by default so every
|
|
10
|
+
* request (HTTP + WebSocket) uses the same tenant as the v2 UI on localhost (`default`). Without
|
|
11
|
+
* this, the SDK passes `sk_*` through → gateway resolves org_… while the UI still uses gn_sk →
|
|
12
|
+
* you only see old default-tenant sandboxes and new ingest data looks “missing”.
|
|
13
|
+
*
|
|
14
|
+
* - `GRANULAR_LOCAL_API_KEY` — explicit key to use instead (e.g. another gn_sk).
|
|
15
|
+
* - `GRANULAR_DISABLE_LOCAL_API_KEY_FALLBACK=1` — do not swap; send the real `sk_*` (org tenant +
|
|
16
|
+
* WorkOS validation on the gateway). Use when the UI is also on that org (e.g. session auth +
|
|
17
|
+
* NEXT_PUBLIC_DISABLE_LOCAL_API_KEY_FALLBACK on the app).
|
|
18
|
+
*/
|
|
19
|
+
declare function resolveAuthTokenForApiUrl(authToken: string, apiUrl: string): string;
|
|
20
|
+
declare function resolveApiUrl(explicitApiUrl?: string, mode?: EndpointMode): string;
|
|
21
|
+
|
|
7
22
|
type EffectRuntimeRequest = {
|
|
8
23
|
effectKey: string;
|
|
9
24
|
effectName: string;
|
|
@@ -41,4 +56,4 @@ declare function normalizePromptType(raw: Record<string, unknown> | null | undef
|
|
|
41
56
|
declare function normalizePrompt(rawValue: unknown): Prompt | null;
|
|
42
57
|
declare function resolvePromptAnswer(prompt: Prompt | undefined, answer: unknown): unknown;
|
|
43
58
|
|
|
44
|
-
export { EffectHandlerContext, type JobPresentation, ManifestEffectMetamodelSpec, Prompt, ResolvedEffectBehaviors, SessionHeapEntry, SessionHeapList, SessionHeapSnapshot, ToolWithHandler, extractPromptTokens, invokeRegisteredEffect, normalizeEffectBehaviors, normalizePrompt, normalizePromptText, normalizePromptType, resolveJobPresentation, resolvePromptAnswer, scorePromptChoiceMatch };
|
|
59
|
+
export { EffectHandlerContext, EndpointMode, type JobPresentation, ManifestEffectMetamodelSpec, Prompt, ResolvedEffectBehaviors, SessionHeapEntry, SessionHeapList, SessionHeapSnapshot, ToolWithHandler, extractPromptTokens, invokeRegisteredEffect, isLocalApiUrl, normalizeEffectBehaviors, normalizePrompt, normalizePromptText, normalizePromptType, resolveApiUrl, resolveAuthTokenForApiUrl, resolveJobPresentation, resolvePromptAnswer, scorePromptChoiceMatch };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
|
-
import { T as ToolWithHandler,
|
|
2
|
-
export {
|
|
1
|
+
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 } from './client-DLGC0mJk.js';
|
|
2
|
+
export { b1 as APIError, A as AccessTokenProvider, u as Assignment, v as AssignmentListResponse, K as Build, N as BuildListResponse, B as BuildPolicy, J as BuildStatus, C as ConnectOptions, m as ConversationSessionInfo, y as CreateEnvironmentData, s as CreatePermissionProfileData, o as CreateSandboxData, aw as DefineRelationshipOptions, b2 as DeleteResponse, D as DomainState, a8 as EffectHandler, a5 as EffectInfo, a0 as EffectInvocationMetadata, $ as EffectInvocationMode, a1 as EffectSchema, a2 as EffectWithHandler, a7 as EffectsChangedEvent, d as Environment, x as EnvironmentData, z as EnvironmentListResponse, aG as EnvironmentRecordImportSummary, G as Granular, j as GranularAuth, i as GranularOptions, b0 as GraphQLResult, a9 as InstanceEffectHandler, I as InstanceToolHandler, ah as Job, ae as JobFeedbackInput, ad as JobFeedbackMetadata, af as JobFeedbackRecord, ab as JobFeedbackSentiment, ac as JobFeedbackToolCall, aa as JobStatus, ag as JobSubmitResult, F as Manifest, aS as ManifestApprovalRequiredSpec, a$ as ManifestContent, aQ as ManifestDryRunSpec, aV as ManifestEffectDeclaration, aU as ManifestEffectSchema, aJ as ManifestEnumRuleSpec, aX as ManifestEventStreamDef, aW as ManifestEventTypeDef, aK as ManifestFilterBySpec, aZ as ManifestImport, H as ManifestListResponse, aY as ManifestOperation, aP as ManifestPostConditionSpec, aH as ManifestPropertySpec, aT as ManifestRelationshipDef, aR as ManifestReverseSpec, aO as ManifestStateMachineSpec, aM as ManifestStateMachineStateSpec, aN as ManifestStateMachineTransitionSpec, aI as ManifestValidationOperator, aL as ManifestValidationRuleSpec, a_ as ManifestVolume, au as ModelRef, r as PermissionProfile, t as PermissionProfileListResponse, q as PermissionRules, a3 as PublishEffectsResult, g as PublishToolsResult, ao as RPCRequest, ar as RPCRequestFromServer, ap as RPCResponse, aF as RecordImport, aE as RecordImportItem, aC as RecordImportItemStatus, aD as RecordImportStats, aB as RecordImportStatus, ax as RecordObjectOptions, ay as RecordObjectResult, az as RecordObjectsChunkInfo, aA as RecordObjectsOptions, k as RecordUserOptions, av as RelationshipInfo, _ as ResolvedEffectApprovalRequired, Y as ResolvedEffectDryRun, X as ResolvedEffectPostCondition, Z as ResolvedEffectReverse, n as Sandbox, p as SandboxListResponse, Q as SemanticVersionDiff, O as SemanticVersionDiffEntry, e as Session, ai as SessionHeapFieldType, aj as SessionHeapFieldValue, ak as SessionHeapVariable, b3 as StreamEvent, b5 as StreamStats, b4 as StreamSubscription, l as Subject, aq as SyncMessage, h as ToolHandler, a4 as ToolInfo, as as ToolInvokeParams, at as ToolResultParams, f as ToolSchema, a6 as ToolsChangedEvent, U as User, L as Version, w as VersionTag, V as VersionTracking, W as WSClient, an as WSClientOptions, al as WSDisconnectInfo, am as WSReconnectErrorInfo } from './client-DLGC0mJk.js';
|
|
3
3
|
export { BuildGranularAgentSystemPromptInput, GeneratedJobCodeIssue, GranularAgentExecutionCheckpoint, GranularAgentHeapSummaryOptions, GranularAgentSessionContext, GranularAgentToolInfo, GranularAgentWorkflowFocus, HarnessContinuationDecision, HarnessControllerBudgets, HarnessProjectionOptions, HarnessPromptLike, HarnessVerifierSnapshot, HarnessVerifierSnapshotInput, buildContinuationInstruction, buildGranularAgentCheckpointBlock, buildGranularAgentDomainBlock, buildGranularAgentHeapBlock, buildGranularAgentLoopBlock, buildGranularAgentSessionBlock, buildGranularAgentSystemPrompt, buildGranularAgentToolBlock, buildGranularAgentWorkflowBlock, createHarnessVerifierSnapshot, evaluateContinuation, getCurrentClosureId, getExclusivePromptTarget, hasOpenPrompt, projectHeapSummary, projectLoopSummary, projectWorkflowFocus, projectWorkflowSummary, reviewGeneratedJobCode } from './agent-harness.js';
|
|
4
4
|
import '@automerge/automerge';
|
|
5
5
|
import '@automerge/automerge/slim';
|
|
6
6
|
|
|
7
|
+
declare function isLocalApiUrl(url: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Local dev + `sk_*` (WorkOS org key in env): map to the local gn_sk e2e key by default so every
|
|
10
|
+
* request (HTTP + WebSocket) uses the same tenant as the v2 UI on localhost (`default`). Without
|
|
11
|
+
* this, the SDK passes `sk_*` through → gateway resolves org_… while the UI still uses gn_sk →
|
|
12
|
+
* you only see old default-tenant sandboxes and new ingest data looks “missing”.
|
|
13
|
+
*
|
|
14
|
+
* - `GRANULAR_LOCAL_API_KEY` — explicit key to use instead (e.g. another gn_sk).
|
|
15
|
+
* - `GRANULAR_DISABLE_LOCAL_API_KEY_FALLBACK=1` — do not swap; send the real `sk_*` (org tenant +
|
|
16
|
+
* WorkOS validation on the gateway). Use when the UI is also on that org (e.g. session auth +
|
|
17
|
+
* NEXT_PUBLIC_DISABLE_LOCAL_API_KEY_FALLBACK on the app).
|
|
18
|
+
*/
|
|
19
|
+
declare function resolveAuthTokenForApiUrl(authToken: string, apiUrl: string): string;
|
|
20
|
+
declare function resolveApiUrl(explicitApiUrl?: string, mode?: EndpointMode): string;
|
|
21
|
+
|
|
7
22
|
type EffectRuntimeRequest = {
|
|
8
23
|
effectKey: string;
|
|
9
24
|
effectName: string;
|
|
@@ -41,4 +56,4 @@ declare function normalizePromptType(raw: Record<string, unknown> | null | undef
|
|
|
41
56
|
declare function normalizePrompt(rawValue: unknown): Prompt | null;
|
|
42
57
|
declare function resolvePromptAnswer(prompt: Prompt | undefined, answer: unknown): unknown;
|
|
43
58
|
|
|
44
|
-
export { EffectHandlerContext, type JobPresentation, ManifestEffectMetamodelSpec, Prompt, ResolvedEffectBehaviors, SessionHeapEntry, SessionHeapList, SessionHeapSnapshot, ToolWithHandler, extractPromptTokens, invokeRegisteredEffect, normalizeEffectBehaviors, normalizePrompt, normalizePromptText, normalizePromptType, resolveJobPresentation, resolvePromptAnswer, scorePromptChoiceMatch };
|
|
59
|
+
export { EffectHandlerContext, EndpointMode, type JobPresentation, ManifestEffectMetamodelSpec, Prompt, ResolvedEffectBehaviors, SessionHeapEntry, SessionHeapList, SessionHeapSnapshot, ToolWithHandler, extractPromptTokens, invokeRegisteredEffect, isLocalApiUrl, normalizeEffectBehaviors, normalizePrompt, normalizePromptText, normalizePromptType, resolveApiUrl, resolveAuthTokenForApiUrl, resolveJobPresentation, resolvePromptAnswer, scorePromptChoiceMatch };
|