@granular-software/sdk 0.4.34 → 0.4.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-evals.d.mts +1 -1
- package/dist/agent-evals.d.ts +1 -1
- package/dist/agent-evals.js +188 -33
- package/dist/agent-evals.js.map +1 -1
- package/dist/agent-evals.mjs +188 -33
- package/dist/agent-evals.mjs.map +1 -1
- package/dist/agent-harness.js +15 -6
- package/dist/agent-harness.js.map +1 -1
- package/dist/agent-harness.mjs +15 -6
- package/dist/agent-harness.mjs.map +1 -1
- package/dist/cli/index.js +173 -27
- package/dist/{client-iw76FL_8.d.mts → client-Cq8onk2D.d.mts} +51 -1
- package/dist/{client-iw76FL_8.d.ts → client-Cq8onk2D.d.ts} +51 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +188 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +188 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/agent-evals.mjs
CHANGED
|
@@ -12352,6 +12352,38 @@ function normalizeUser(user) {
|
|
|
12352
12352
|
permissions: Array.isArray(user.permissions) ? user.permissions : []
|
|
12353
12353
|
};
|
|
12354
12354
|
}
|
|
12355
|
+
function normalizeEnvironmentSetupSummary(setup) {
|
|
12356
|
+
if (!setup) {
|
|
12357
|
+
return null;
|
|
12358
|
+
}
|
|
12359
|
+
const queuedRecords = Number(setup.queuedRecords || 0);
|
|
12360
|
+
const processingRecords = Number(setup.processingRecords || 0);
|
|
12361
|
+
return {
|
|
12362
|
+
...setup,
|
|
12363
|
+
setupRunId: String(setup.setupRunId || ""),
|
|
12364
|
+
environmentId: String(setup.environmentId || ""),
|
|
12365
|
+
sandboxId: String(setup.sandboxId || ""),
|
|
12366
|
+
subjectId: String(setup.subjectId || ""),
|
|
12367
|
+
triggerReason: setup.triggerReason === "fresh_after_version_update" ? "fresh_after_version_update" : "new_environment",
|
|
12368
|
+
lifecycleStatus: setup.lifecycleStatus === "completed" || setup.lifecycleStatus === "failed" ? setup.lifecycleStatus : "running",
|
|
12369
|
+
stage: typeof setup.stage === "string" ? setup.stage : null,
|
|
12370
|
+
totalObjectsToImport: Number(setup.totalObjectsToImport || 0),
|
|
12371
|
+
totalImports: Number(setup.totalImports || 0),
|
|
12372
|
+
activeImports: Number(setup.activeImports || 0),
|
|
12373
|
+
totalRecords: Number(setup.totalRecords || 0),
|
|
12374
|
+
queuedRecords,
|
|
12375
|
+
processingRecords,
|
|
12376
|
+
completedRecords: Number(setup.completedRecords || 0),
|
|
12377
|
+
failedRecords: Number(setup.failedRecords || 0),
|
|
12378
|
+
canceledRecords: Number(setup.canceledRecords || 0),
|
|
12379
|
+
awaitingRecords: Number(setup.awaitingRecords || 0) || queuedRecords + processingRecords,
|
|
12380
|
+
errorMessage: typeof setup.errorMessage === "string" ? setup.errorMessage : null,
|
|
12381
|
+
startedAt: Number(setup.startedAt || Date.now()),
|
|
12382
|
+
hookCompletedAt: setup.hookCompletedAt == null ? null : Number(setup.hookCompletedAt),
|
|
12383
|
+
finishedAt: setup.finishedAt == null ? null : Number(setup.finishedAt),
|
|
12384
|
+
updatedAt: Number(setup.updatedAt || Date.now())
|
|
12385
|
+
};
|
|
12386
|
+
}
|
|
12355
12387
|
function normalizeEnvironmentData(environment) {
|
|
12356
12388
|
const buildPolicy = environment.buildPolicy || environment.tracking || (environment.tagId ? { mode: "tag", tagId: environment.tagId } : {
|
|
12357
12389
|
mode: "pinned",
|
|
@@ -12365,7 +12397,8 @@ function normalizeEnvironmentData(environment) {
|
|
|
12365
12397
|
envName: environmentName,
|
|
12366
12398
|
environment: environmentName,
|
|
12367
12399
|
buildPolicy,
|
|
12368
|
-
tracking: environment.tracking || buildPolicy
|
|
12400
|
+
tracking: environment.tracking || buildPolicy,
|
|
12401
|
+
setup: normalizeEnvironmentSetupSummary(environment.setup)
|
|
12369
12402
|
};
|
|
12370
12403
|
}
|
|
12371
12404
|
var Environment = class {
|
|
@@ -12423,6 +12456,10 @@ var Environment = class {
|
|
|
12423
12456
|
get updateState() {
|
|
12424
12457
|
return this.envData.updateState;
|
|
12425
12458
|
}
|
|
12459
|
+
/** The latest setup/import run summary for this environment, when available. */
|
|
12460
|
+
get setup() {
|
|
12461
|
+
return this.envData.setup || null;
|
|
12462
|
+
}
|
|
12426
12463
|
/** Convenience flag for whether this environment trails the current tag target */
|
|
12427
12464
|
get isOutdated() {
|
|
12428
12465
|
return this.envData.updateState === "update_available";
|
|
@@ -12443,6 +12480,9 @@ var Environment = class {
|
|
|
12443
12480
|
get runtimeBaseUrl() {
|
|
12444
12481
|
return this.getRuntimeBaseUrl();
|
|
12445
12482
|
}
|
|
12483
|
+
syncEnvironmentData(envData) {
|
|
12484
|
+
this.envData = normalizeEnvironmentData(envData);
|
|
12485
|
+
}
|
|
12446
12486
|
get sessions() {
|
|
12447
12487
|
return {
|
|
12448
12488
|
list: async (options) => this.listSessions(options?.status || "active"),
|
|
@@ -13388,7 +13428,8 @@ var Environment = class {
|
|
|
13388
13428
|
method: "POST",
|
|
13389
13429
|
body: JSON.stringify({
|
|
13390
13430
|
records,
|
|
13391
|
-
batchSize: options.batchSize
|
|
13431
|
+
batchSize: options.batchSize,
|
|
13432
|
+
setupRunId: options.setupRunId
|
|
13392
13433
|
})
|
|
13393
13434
|
}
|
|
13394
13435
|
);
|
|
@@ -13536,18 +13577,12 @@ var EnvironmentSession = class extends Session {
|
|
|
13536
13577
|
}
|
|
13537
13578
|
get messages() {
|
|
13538
13579
|
return {
|
|
13539
|
-
list: (options = {}) => this.sessionDataRequest(
|
|
13540
|
-
"/messages",
|
|
13541
|
-
options
|
|
13542
|
-
)
|
|
13580
|
+
list: (options = {}) => this.sessionDataRequest("/messages", options)
|
|
13543
13581
|
};
|
|
13544
13582
|
}
|
|
13545
13583
|
get timeline() {
|
|
13546
13584
|
return {
|
|
13547
|
-
list: (options = {}) => this.sessionDataRequest(
|
|
13548
|
-
"/timeline",
|
|
13549
|
-
options
|
|
13550
|
-
)
|
|
13585
|
+
list: (options = {}) => this.sessionDataRequest("/timeline", options)
|
|
13551
13586
|
};
|
|
13552
13587
|
}
|
|
13553
13588
|
get jobs() {
|
|
@@ -13564,10 +13599,7 @@ var EnvironmentSession = class extends Session {
|
|
|
13564
13599
|
get heap() {
|
|
13565
13600
|
return {
|
|
13566
13601
|
entries: {
|
|
13567
|
-
list: (options = {}) => this.sessionDataRequest(
|
|
13568
|
-
"/heap/entries",
|
|
13569
|
-
options
|
|
13570
|
-
),
|
|
13602
|
+
list: (options = {}) => this.sessionDataRequest("/heap/entries", options),
|
|
13571
13603
|
get: (path2) => this.sessionDataRequest(
|
|
13572
13604
|
`/heap/entries/${encodeURIComponent(path2)}`
|
|
13573
13605
|
)
|
|
@@ -13611,10 +13643,7 @@ var EnvironmentSession = class extends Session {
|
|
|
13611
13643
|
const heap = normalizeHeapSnapshot({
|
|
13612
13644
|
entriesByPath: Object.fromEntries(
|
|
13613
13645
|
entries.map((entry) => {
|
|
13614
|
-
return entry?.path ? [
|
|
13615
|
-
entry.path,
|
|
13616
|
-
entry
|
|
13617
|
-
] : null;
|
|
13646
|
+
return entry?.path ? [entry.path, entry] : null;
|
|
13618
13647
|
}).filter(
|
|
13619
13648
|
(entry) => Boolean(entry)
|
|
13620
13649
|
)
|
|
@@ -13780,6 +13809,15 @@ var OntologyHandle = class {
|
|
|
13780
13809
|
disconnect: async () => this.granular.disconnectEffects(this.ontologyNameOrId)
|
|
13781
13810
|
};
|
|
13782
13811
|
}
|
|
13812
|
+
get importer() {
|
|
13813
|
+
return {
|
|
13814
|
+
onEnvironmentCreate: (handler) => this.granular.registerEnvironmentImporter(
|
|
13815
|
+
this.ontologyNameOrId,
|
|
13816
|
+
handler
|
|
13817
|
+
),
|
|
13818
|
+
clear: () => this.granular.clearEnvironmentImporter(this.ontologyNameOrId)
|
|
13819
|
+
};
|
|
13820
|
+
}
|
|
13783
13821
|
};
|
|
13784
13822
|
var Granular = class _Granular {
|
|
13785
13823
|
apiKey;
|
|
@@ -13796,6 +13834,10 @@ var Granular = class _Granular {
|
|
|
13796
13834
|
sandboxEffectHosts = /* @__PURE__ */ new Map();
|
|
13797
13835
|
/** In-flight host connection promises to avoid duplicate concurrent connects */
|
|
13798
13836
|
sandboxEffectHostPromises = /* @__PURE__ */ new Map();
|
|
13837
|
+
/** Ontology-bound environment importer hooks keyed by the caller's ontology identifier. */
|
|
13838
|
+
ontologyImporters = /* @__PURE__ */ new Map();
|
|
13839
|
+
/** Resolved importer hooks keyed by sandboxId for fast lookups during openEnvironment(). */
|
|
13840
|
+
sandboxImporters = /* @__PURE__ */ new Map();
|
|
13799
13841
|
/**
|
|
13800
13842
|
* Create a new Granular client
|
|
13801
13843
|
* @param options - Client configuration
|
|
@@ -13821,6 +13863,18 @@ var Granular = class _Granular {
|
|
|
13821
13863
|
ontology(ontologyNameOrId) {
|
|
13822
13864
|
return new OntologyHandle(this, ontologyNameOrId);
|
|
13823
13865
|
}
|
|
13866
|
+
registerEnvironmentImporter(ontologyNameOrId, handler) {
|
|
13867
|
+
this.ontologyImporters.set(ontologyNameOrId, handler);
|
|
13868
|
+
if (ontologyNameOrId.startsWith("sbx_")) {
|
|
13869
|
+
this.sandboxImporters.set(ontologyNameOrId, handler);
|
|
13870
|
+
}
|
|
13871
|
+
}
|
|
13872
|
+
clearEnvironmentImporter(ontologyNameOrId) {
|
|
13873
|
+
this.ontologyImporters.delete(ontologyNameOrId);
|
|
13874
|
+
if (ontologyNameOrId.startsWith("sbx_")) {
|
|
13875
|
+
this.sandboxImporters.delete(ontologyNameOrId);
|
|
13876
|
+
}
|
|
13877
|
+
}
|
|
13824
13878
|
/**
|
|
13825
13879
|
* Records/upserts a user and prepares them for sandbox connections
|
|
13826
13880
|
*
|
|
@@ -13937,11 +13991,13 @@ var Granular = class _Granular {
|
|
|
13937
13991
|
* ```
|
|
13938
13992
|
*/
|
|
13939
13993
|
async openEnvironment(options) {
|
|
13940
|
-
const
|
|
13994
|
+
const resolved = await this.resolveOpenEnvironmentData(
|
|
13941
13995
|
options,
|
|
13942
13996
|
"openEnvironment"
|
|
13943
13997
|
);
|
|
13944
|
-
|
|
13998
|
+
const environment = this.bindEnvironmentHandle(resolved.environment);
|
|
13999
|
+
await this.maybeRunEnvironmentImporter(resolved, environment);
|
|
14000
|
+
return environment;
|
|
13945
14001
|
}
|
|
13946
14002
|
/**
|
|
13947
14003
|
* Deprecated compatibility alias for `openEnvironment()`.
|
|
@@ -14028,7 +14084,12 @@ var Granular = class _Granular {
|
|
|
14028
14084
|
)
|
|
14029
14085
|
);
|
|
14030
14086
|
if (currentMatches.length > 0) {
|
|
14031
|
-
return
|
|
14087
|
+
return {
|
|
14088
|
+
environment: currentMatches[0],
|
|
14089
|
+
requestedOntology: ontology,
|
|
14090
|
+
sandboxId: sandbox.sandboxId,
|
|
14091
|
+
subjectId: user.granularId
|
|
14092
|
+
};
|
|
14032
14093
|
}
|
|
14033
14094
|
const outdatedMatches = this.sortEnvironmentsByRecency(
|
|
14034
14095
|
userEnvironments.filter(
|
|
@@ -14036,14 +14097,25 @@ var Granular = class _Granular {
|
|
|
14036
14097
|
)
|
|
14037
14098
|
);
|
|
14038
14099
|
if (outdatedMatches.length > 0 && options.createFreshIfOutdated !== true) {
|
|
14039
|
-
return
|
|
14100
|
+
return {
|
|
14101
|
+
environment: outdatedMatches[0],
|
|
14102
|
+
requestedOntology: ontology,
|
|
14103
|
+
sandboxId: sandbox.sandboxId,
|
|
14104
|
+
subjectId: user.granularId
|
|
14105
|
+
};
|
|
14040
14106
|
}
|
|
14041
|
-
return
|
|
14107
|
+
return {
|
|
14108
|
+
environment: await this.environments.create(sandbox.sandboxId, {
|
|
14109
|
+
subjectId: user.granularId,
|
|
14110
|
+
environment: this.buildManagedEnvironmentName(tagName, targetVersionId),
|
|
14111
|
+
tagId: tag.tagId,
|
|
14112
|
+
permissionProfileId: null
|
|
14113
|
+
}),
|
|
14114
|
+
requestedOntology: ontology,
|
|
14115
|
+
sandboxId: sandbox.sandboxId,
|
|
14042
14116
|
subjectId: user.granularId,
|
|
14043
|
-
|
|
14044
|
-
|
|
14045
|
-
permissionProfileId: null
|
|
14046
|
-
});
|
|
14117
|
+
setupTriggerReason: outdatedMatches.length > 0 ? "fresh_after_version_update" : "new_environment"
|
|
14118
|
+
};
|
|
14047
14119
|
}
|
|
14048
14120
|
/**
|
|
14049
14121
|
* List active (open) sessions for an environment — each session is one agent conversation thread.
|
|
@@ -14160,6 +14232,80 @@ var Granular = class _Granular {
|
|
|
14160
14232
|
});
|
|
14161
14233
|
return this.connectSession({ sessionId, clientId: options?.clientId });
|
|
14162
14234
|
}
|
|
14235
|
+
resolveEnvironmentImporter(requestedOntology, sandboxId) {
|
|
14236
|
+
const resolved = this.sandboxImporters.get(sandboxId) || this.ontologyImporters.get(requestedOntology);
|
|
14237
|
+
if (resolved && !this.sandboxImporters.has(sandboxId) && this.ontologyImporters.get(requestedOntology) === resolved) {
|
|
14238
|
+
this.sandboxImporters.set(sandboxId, resolved);
|
|
14239
|
+
}
|
|
14240
|
+
return resolved;
|
|
14241
|
+
}
|
|
14242
|
+
async maybeRunEnvironmentImporter(resolved, environment) {
|
|
14243
|
+
if (!resolved.setupTriggerReason) {
|
|
14244
|
+
return;
|
|
14245
|
+
}
|
|
14246
|
+
const importer = this.resolveEnvironmentImporter(
|
|
14247
|
+
resolved.requestedOntology,
|
|
14248
|
+
resolved.sandboxId
|
|
14249
|
+
);
|
|
14250
|
+
if (!importer) {
|
|
14251
|
+
return;
|
|
14252
|
+
}
|
|
14253
|
+
const setupRun = await this.request(
|
|
14254
|
+
`/control/environments/${environment.environmentId}/setup-runs`,
|
|
14255
|
+
{
|
|
14256
|
+
method: "POST",
|
|
14257
|
+
body: JSON.stringify({
|
|
14258
|
+
triggerReason: resolved.setupTriggerReason
|
|
14259
|
+
})
|
|
14260
|
+
}
|
|
14261
|
+
);
|
|
14262
|
+
const setupRunId = setupRun.setupRunId;
|
|
14263
|
+
const updateSetupRun = async (patch) => {
|
|
14264
|
+
await this.request(
|
|
14265
|
+
`/control/environment-setup-runs/${setupRunId}`,
|
|
14266
|
+
{
|
|
14267
|
+
method: "PATCH",
|
|
14268
|
+
body: JSON.stringify(patch)
|
|
14269
|
+
}
|
|
14270
|
+
);
|
|
14271
|
+
};
|
|
14272
|
+
const importerContext = {
|
|
14273
|
+
environmentId: environment.environmentId,
|
|
14274
|
+
sandboxId: environment.sandboxId,
|
|
14275
|
+
subjectId: environment.subjectId,
|
|
14276
|
+
reason: resolved.setupTriggerReason,
|
|
14277
|
+
incrementTotalObjectsToImportCount: async (n) => {
|
|
14278
|
+
const safeIncrement = Math.max(0, Math.trunc(n));
|
|
14279
|
+
if (safeIncrement <= 0) {
|
|
14280
|
+
return;
|
|
14281
|
+
}
|
|
14282
|
+
await updateSetupRun({
|
|
14283
|
+
incrementTotalObjectsToImportCount: safeIncrement
|
|
14284
|
+
});
|
|
14285
|
+
},
|
|
14286
|
+
setStage: async (stage) => {
|
|
14287
|
+
await updateSetupRun({ stage });
|
|
14288
|
+
},
|
|
14289
|
+
importRecords: async (records, options) => environment.enqueueRecordImport(records, {
|
|
14290
|
+
batchSize: options?.batchSize,
|
|
14291
|
+
setupRunId
|
|
14292
|
+
})
|
|
14293
|
+
};
|
|
14294
|
+
try {
|
|
14295
|
+
await importer(importerContext);
|
|
14296
|
+
await updateSetupRun({ markHookCompleted: true });
|
|
14297
|
+
const refreshedEnvironment = await this.environments.get(
|
|
14298
|
+
environment.environmentId
|
|
14299
|
+
);
|
|
14300
|
+
environment.syncEnvironmentData(refreshedEnvironment);
|
|
14301
|
+
} catch (error) {
|
|
14302
|
+
await updateSetupRun({
|
|
14303
|
+
status: "failed",
|
|
14304
|
+
errorMessage: error instanceof Error ? error.message : String(error)
|
|
14305
|
+
}).catch(() => void 0);
|
|
14306
|
+
throw error;
|
|
14307
|
+
}
|
|
14308
|
+
}
|
|
14163
14309
|
bindEnvironmentHandle(envData) {
|
|
14164
14310
|
const graphqlEndpoint = `${this.httpUrl}/orchestrator/graphql`;
|
|
14165
14311
|
return new Environment(this, envData, this.apiKey, graphqlEndpoint);
|
|
@@ -15621,12 +15767,11 @@ function buildContinuationInstruction(resultPreview) {
|
|
|
15621
15767
|
"Continue the same user request using the latest structured session state.",
|
|
15622
15768
|
"Take only the minimum next step that directly helps the user.",
|
|
15623
15769
|
"Use the active tasks, decisions, prompts, and heap references as the source of truth instead of replaying old work.",
|
|
15624
|
-
"If the user names a concrete record that is not already in the heap,
|
|
15770
|
+
"If the user names a concrete record that is not already in the heap, resolve it from the graph before saying it is missing: try a broad search, then a small set of normalized/fuzzy variants or a paged scan when the domain supports it.",
|
|
15771
|
+
"If the request needs all matching records, use iterate(...) or page until hasMore is false. A single list(...) or page(...) call is only one page.",
|
|
15625
15772
|
"If this request clearly spans multiple steps and there are no active tasks yet, create 2-4 short user-visible tasks now.",
|
|
15626
15773
|
"Reuse any existing taskId and decisionId values exactly as they appear in AGENT LOOP STATE.",
|
|
15627
|
-
"
|
|
15628
|
-
"Do not ask for confirmation in plain text. Use loop.confirm(...) when approval is needed.",
|
|
15629
|
-
"Await loop.ask_user(...) and loop.confirm(...). Those helpers pause the current job and resume it after the user answers.",
|
|
15774
|
+
"When progress depends on the user's choice, missing detail, or approval, use loop.ask_user(...) or loop.confirm(...) so the job pauses and resumes through the live workflow.",
|
|
15630
15775
|
"After a resumed ask_user or confirm call, continue the same job and perform the newly authorized action when the answer is sufficient. Do not stop with placeholder text like 'I'm ready to do it next.'",
|
|
15631
15776
|
"If you ask the user a new question in this job, do not also close the loop in the same job.",
|
|
15632
15777
|
"Write the smallest straightforward code for the current step. Avoid defensive fallback branches for hypothetical states that are not currently true.",
|
|
@@ -15814,12 +15959,13 @@ ${loopBlock}
|
|
|
15814
15959
|
- Continue from the latest structured state. Treat WORKFLOW SNAPSHOT, EXECUTION CHECKPOINT, RECENT REFERENTS, SESSION HEAP, and AGENT LOOP STATE as the working memory for this request.
|
|
15815
15960
|
- Use CAPABILITY SNAPSHOT to choose the next step, then use DOMAIN REFERENCE for exact signatures and query shapes.
|
|
15816
15961
|
- Take the minimum next step that directly helps the user. Avoid duplicate work, speculative cleanup, or extra fetching that is not needed yet.
|
|
15817
|
-
- If the user names a record that is not already in the heap, fetch it from the graph instead of saying it is not in context.
|
|
15818
|
-
- Treat user-provided names as human references, not exact keys. If one strong partial match exists, use it. If several plausible matches exist, ask the user to choose.
|
|
15819
15962
|
- Use RECENT REFERENTS to resolve follow-up references across turns, such as "that invoice", "that customer", "those products", or "the other one".
|
|
15963
|
+
- Treat user-provided names, numbers, and labels as human references, not exact keys. Resolve them with code: check recent referents/heap first, then query the graph with the broadest supported \`search\` or \`filter\`, then retry with a few normalized/fuzzy/prefix variants when the first pass is empty or ambiguous. Only say a record does not exist after a reasonable lookup across the relevant class.
|
|
15964
|
+
- If one strong match exists, use it. If several plausible matches remain, use \`loop.ask_user({ type: 'choice', ... })\` with the grounded candidates instead of guessing.
|
|
15820
15965
|
- If the request has more than one reasonable interpretation, ask the user to clarify instead of guessing.
|
|
15821
15966
|
- For comparisons, rankings, selections, or summaries, first identify the rule you are using. If that rule is not clear from the user request and DOMAIN REFERENCE, ask the user before choosing anything.
|
|
15822
15967
|
- When the ranking, comparison, or selection rule is unclear, the minimum next step is the clarification itself. Do not run a placeholder query for a provisional winner before asking.
|
|
15968
|
+
- If a user request matches both a domain type/effect and a loop helper, prioritize the domain type/effect. For example, if DOMAIN REFERENCE contains a \`Task\` class and the user asks to create a task, create the domain task record; do not call \`loop.create_task(...)\` unless you are only tracking your own workflow.
|
|
15823
15969
|
- Reuse exact \`taskId\`, \`decisionId\`, and \`closureId\` values from AGENT LOOP STATE. Never invent or rewrite them.
|
|
15824
15970
|
- If the request is ambiguous or clearly multi-step, create 2-4 short user-visible tasks and keep them updated as the workflow advances.
|
|
15825
15971
|
- Use \`loop.ask_user({ type: 'choice', options: [...] })\` when you have a short, grounded shortlist the user can choose from. Otherwise use \`type: 'input'\`.
|
|
@@ -15830,6 +15976,14 @@ ${loopBlock}
|
|
|
15830
15976
|
- Use \`loop.open_decision(...)\` to persist grounded candidates, \`loop.close_decision(...)\` to resolve one, and \`loop.close_loop(...)\` when the workflow is completed, canceled, or blocked.
|
|
15831
15977
|
- If you ask a new question in the current job, do not also close the loop in that same job.
|
|
15832
15978
|
|
|
15979
|
+
\u2500\u2500\u2500 LOOP HELPER REFERENCE \u2500\u2500\u2500
|
|
15980
|
+
- \`loop.ask_user(...)\`: pause the current job for missing input; use \`type: 'choice'\` only for a short grounded shortlist.
|
|
15981
|
+
- \`loop.confirm(...)\`: pause for yes/no approval before a consequential action, then branch on the returned boolean.
|
|
15982
|
+
- \`loop.open_decision(...)\`: save explicit candidates that later jobs can revisit; each candidate needs an \`id\`.
|
|
15983
|
+
- \`loop.close_decision(...)\`: resolve an open decision with a stored \`selectedId\` and optional rationale.
|
|
15984
|
+
- \`loop.create_task(...)\`, \`loop.update_task(...)\`, \`loop.complete_task(...)\`: keep a short resumable task list for the agent's workflow; these are not domain \`Task\` records.
|
|
15985
|
+
- \`loop.close_loop(...)\`: record the workflow outcome when it is completed, canceled, or blocked.
|
|
15986
|
+
|
|
15833
15987
|
\u2500\u2500\u2500 CODE RULES \u2500\u2500\u2500
|
|
15834
15988
|
- Import from \`./sandbox-tools\`.
|
|
15835
15989
|
- If you use \`heap\`, \`loop\`, \`agent_text_message\`, or \`agent_heap_objects\`, import them explicitly from \`./sandbox-tools\`.
|
|
@@ -15839,6 +15993,7 @@ ${loopBlock}
|
|
|
15839
15993
|
- Use \`ClassName.get({ path })\` only for known graph paths when you want a direct graph fetch.
|
|
15840
15994
|
- Use \`ClassName.count()\` for totals, \`ClassName.page({ page, perPage, saveAs })\` when you need \`items\` plus \`totalCount\` or \`hasMore\`, \`ClassName.list({ page, perPage, saveAs })\` for one page of records, and \`ClassName.iterate({ perPage, maxItems })\` for large scans.
|
|
15841
15995
|
- \`perPage\` defaults to \`100\` and is capped at \`100\`.
|
|
15996
|
+
- A single \`list(...)\` or \`page(...)\` call never proves there are no more records. For "all", "every", exports, broad scans, or exhaustive searches, use \`iterate(...)\` when available or loop \`page(...)\` until \`hasMore\` is false.
|
|
15842
15997
|
- Push \`filter\`, \`search\`, and \`sort\` into graph queries instead of fetching a page and processing it locally.
|
|
15843
15998
|
- A property appearing on a record does not make it valid in \`filter\` or \`sort\`; only use fields and operators that are explicitly exposed in DOMAIN REFERENCE.
|
|
15844
15999
|
- Choose \`sort.field\` verbatim from the sortable fields listed in DOMAIN REFERENCE. Do not sort by relationship names, related-record collections, counts, totals, or other derived metrics unless they are explicitly listed as sortable.
|