@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/index.js
CHANGED
|
@@ -12372,6 +12372,38 @@ function normalizeUser(user) {
|
|
|
12372
12372
|
permissions: Array.isArray(user.permissions) ? user.permissions : []
|
|
12373
12373
|
};
|
|
12374
12374
|
}
|
|
12375
|
+
function normalizeEnvironmentSetupSummary(setup) {
|
|
12376
|
+
if (!setup) {
|
|
12377
|
+
return null;
|
|
12378
|
+
}
|
|
12379
|
+
const queuedRecords = Number(setup.queuedRecords || 0);
|
|
12380
|
+
const processingRecords = Number(setup.processingRecords || 0);
|
|
12381
|
+
return {
|
|
12382
|
+
...setup,
|
|
12383
|
+
setupRunId: String(setup.setupRunId || ""),
|
|
12384
|
+
environmentId: String(setup.environmentId || ""),
|
|
12385
|
+
sandboxId: String(setup.sandboxId || ""),
|
|
12386
|
+
subjectId: String(setup.subjectId || ""),
|
|
12387
|
+
triggerReason: setup.triggerReason === "fresh_after_version_update" ? "fresh_after_version_update" : "new_environment",
|
|
12388
|
+
lifecycleStatus: setup.lifecycleStatus === "completed" || setup.lifecycleStatus === "failed" ? setup.lifecycleStatus : "running",
|
|
12389
|
+
stage: typeof setup.stage === "string" ? setup.stage : null,
|
|
12390
|
+
totalObjectsToImport: Number(setup.totalObjectsToImport || 0),
|
|
12391
|
+
totalImports: Number(setup.totalImports || 0),
|
|
12392
|
+
activeImports: Number(setup.activeImports || 0),
|
|
12393
|
+
totalRecords: Number(setup.totalRecords || 0),
|
|
12394
|
+
queuedRecords,
|
|
12395
|
+
processingRecords,
|
|
12396
|
+
completedRecords: Number(setup.completedRecords || 0),
|
|
12397
|
+
failedRecords: Number(setup.failedRecords || 0),
|
|
12398
|
+
canceledRecords: Number(setup.canceledRecords || 0),
|
|
12399
|
+
awaitingRecords: Number(setup.awaitingRecords || 0) || queuedRecords + processingRecords,
|
|
12400
|
+
errorMessage: typeof setup.errorMessage === "string" ? setup.errorMessage : null,
|
|
12401
|
+
startedAt: Number(setup.startedAt || Date.now()),
|
|
12402
|
+
hookCompletedAt: setup.hookCompletedAt == null ? null : Number(setup.hookCompletedAt),
|
|
12403
|
+
finishedAt: setup.finishedAt == null ? null : Number(setup.finishedAt),
|
|
12404
|
+
updatedAt: Number(setup.updatedAt || Date.now())
|
|
12405
|
+
};
|
|
12406
|
+
}
|
|
12375
12407
|
function normalizeEnvironmentData(environment) {
|
|
12376
12408
|
const buildPolicy = environment.buildPolicy || environment.tracking || (environment.tagId ? { mode: "tag", tagId: environment.tagId } : {
|
|
12377
12409
|
mode: "pinned",
|
|
@@ -12385,7 +12417,8 @@ function normalizeEnvironmentData(environment) {
|
|
|
12385
12417
|
envName: environmentName,
|
|
12386
12418
|
environment: environmentName,
|
|
12387
12419
|
buildPolicy,
|
|
12388
|
-
tracking: environment.tracking || buildPolicy
|
|
12420
|
+
tracking: environment.tracking || buildPolicy,
|
|
12421
|
+
setup: normalizeEnvironmentSetupSummary(environment.setup)
|
|
12389
12422
|
};
|
|
12390
12423
|
}
|
|
12391
12424
|
var Environment = class {
|
|
@@ -12443,6 +12476,10 @@ var Environment = class {
|
|
|
12443
12476
|
get updateState() {
|
|
12444
12477
|
return this.envData.updateState;
|
|
12445
12478
|
}
|
|
12479
|
+
/** The latest setup/import run summary for this environment, when available. */
|
|
12480
|
+
get setup() {
|
|
12481
|
+
return this.envData.setup || null;
|
|
12482
|
+
}
|
|
12446
12483
|
/** Convenience flag for whether this environment trails the current tag target */
|
|
12447
12484
|
get isOutdated() {
|
|
12448
12485
|
return this.envData.updateState === "update_available";
|
|
@@ -12463,6 +12500,9 @@ var Environment = class {
|
|
|
12463
12500
|
get runtimeBaseUrl() {
|
|
12464
12501
|
return this.getRuntimeBaseUrl();
|
|
12465
12502
|
}
|
|
12503
|
+
syncEnvironmentData(envData) {
|
|
12504
|
+
this.envData = normalizeEnvironmentData(envData);
|
|
12505
|
+
}
|
|
12466
12506
|
get sessions() {
|
|
12467
12507
|
return {
|
|
12468
12508
|
list: async (options) => this.listSessions(options?.status || "active"),
|
|
@@ -13408,7 +13448,8 @@ var Environment = class {
|
|
|
13408
13448
|
method: "POST",
|
|
13409
13449
|
body: JSON.stringify({
|
|
13410
13450
|
records,
|
|
13411
|
-
batchSize: options.batchSize
|
|
13451
|
+
batchSize: options.batchSize,
|
|
13452
|
+
setupRunId: options.setupRunId
|
|
13412
13453
|
})
|
|
13413
13454
|
}
|
|
13414
13455
|
);
|
|
@@ -13556,18 +13597,12 @@ var EnvironmentSession = class extends Session {
|
|
|
13556
13597
|
}
|
|
13557
13598
|
get messages() {
|
|
13558
13599
|
return {
|
|
13559
|
-
list: (options = {}) => this.sessionDataRequest(
|
|
13560
|
-
"/messages",
|
|
13561
|
-
options
|
|
13562
|
-
)
|
|
13600
|
+
list: (options = {}) => this.sessionDataRequest("/messages", options)
|
|
13563
13601
|
};
|
|
13564
13602
|
}
|
|
13565
13603
|
get timeline() {
|
|
13566
13604
|
return {
|
|
13567
|
-
list: (options = {}) => this.sessionDataRequest(
|
|
13568
|
-
"/timeline",
|
|
13569
|
-
options
|
|
13570
|
-
)
|
|
13605
|
+
list: (options = {}) => this.sessionDataRequest("/timeline", options)
|
|
13571
13606
|
};
|
|
13572
13607
|
}
|
|
13573
13608
|
get jobs() {
|
|
@@ -13584,10 +13619,7 @@ var EnvironmentSession = class extends Session {
|
|
|
13584
13619
|
get heap() {
|
|
13585
13620
|
return {
|
|
13586
13621
|
entries: {
|
|
13587
|
-
list: (options = {}) => this.sessionDataRequest(
|
|
13588
|
-
"/heap/entries",
|
|
13589
|
-
options
|
|
13590
|
-
),
|
|
13622
|
+
list: (options = {}) => this.sessionDataRequest("/heap/entries", options),
|
|
13591
13623
|
get: (path) => this.sessionDataRequest(
|
|
13592
13624
|
`/heap/entries/${encodeURIComponent(path)}`
|
|
13593
13625
|
)
|
|
@@ -13631,10 +13663,7 @@ var EnvironmentSession = class extends Session {
|
|
|
13631
13663
|
const heap = normalizeHeapSnapshot({
|
|
13632
13664
|
entriesByPath: Object.fromEntries(
|
|
13633
13665
|
entries.map((entry) => {
|
|
13634
|
-
return entry?.path ? [
|
|
13635
|
-
entry.path,
|
|
13636
|
-
entry
|
|
13637
|
-
] : null;
|
|
13666
|
+
return entry?.path ? [entry.path, entry] : null;
|
|
13638
13667
|
}).filter(
|
|
13639
13668
|
(entry) => Boolean(entry)
|
|
13640
13669
|
)
|
|
@@ -13800,6 +13829,15 @@ var OntologyHandle = class {
|
|
|
13800
13829
|
disconnect: async () => this.granular.disconnectEffects(this.ontologyNameOrId)
|
|
13801
13830
|
};
|
|
13802
13831
|
}
|
|
13832
|
+
get importer() {
|
|
13833
|
+
return {
|
|
13834
|
+
onEnvironmentCreate: (handler) => this.granular.registerEnvironmentImporter(
|
|
13835
|
+
this.ontologyNameOrId,
|
|
13836
|
+
handler
|
|
13837
|
+
),
|
|
13838
|
+
clear: () => this.granular.clearEnvironmentImporter(this.ontologyNameOrId)
|
|
13839
|
+
};
|
|
13840
|
+
}
|
|
13803
13841
|
};
|
|
13804
13842
|
var Granular = class _Granular {
|
|
13805
13843
|
apiKey;
|
|
@@ -13816,6 +13854,10 @@ var Granular = class _Granular {
|
|
|
13816
13854
|
sandboxEffectHosts = /* @__PURE__ */ new Map();
|
|
13817
13855
|
/** In-flight host connection promises to avoid duplicate concurrent connects */
|
|
13818
13856
|
sandboxEffectHostPromises = /* @__PURE__ */ new Map();
|
|
13857
|
+
/** Ontology-bound environment importer hooks keyed by the caller's ontology identifier. */
|
|
13858
|
+
ontologyImporters = /* @__PURE__ */ new Map();
|
|
13859
|
+
/** Resolved importer hooks keyed by sandboxId for fast lookups during openEnvironment(). */
|
|
13860
|
+
sandboxImporters = /* @__PURE__ */ new Map();
|
|
13819
13861
|
/**
|
|
13820
13862
|
* Create a new Granular client
|
|
13821
13863
|
* @param options - Client configuration
|
|
@@ -13841,6 +13883,18 @@ var Granular = class _Granular {
|
|
|
13841
13883
|
ontology(ontologyNameOrId) {
|
|
13842
13884
|
return new OntologyHandle(this, ontologyNameOrId);
|
|
13843
13885
|
}
|
|
13886
|
+
registerEnvironmentImporter(ontologyNameOrId, handler) {
|
|
13887
|
+
this.ontologyImporters.set(ontologyNameOrId, handler);
|
|
13888
|
+
if (ontologyNameOrId.startsWith("sbx_")) {
|
|
13889
|
+
this.sandboxImporters.set(ontologyNameOrId, handler);
|
|
13890
|
+
}
|
|
13891
|
+
}
|
|
13892
|
+
clearEnvironmentImporter(ontologyNameOrId) {
|
|
13893
|
+
this.ontologyImporters.delete(ontologyNameOrId);
|
|
13894
|
+
if (ontologyNameOrId.startsWith("sbx_")) {
|
|
13895
|
+
this.sandboxImporters.delete(ontologyNameOrId);
|
|
13896
|
+
}
|
|
13897
|
+
}
|
|
13844
13898
|
/**
|
|
13845
13899
|
* Records/upserts a user and prepares them for sandbox connections
|
|
13846
13900
|
*
|
|
@@ -13957,11 +14011,13 @@ var Granular = class _Granular {
|
|
|
13957
14011
|
* ```
|
|
13958
14012
|
*/
|
|
13959
14013
|
async openEnvironment(options) {
|
|
13960
|
-
const
|
|
14014
|
+
const resolved = await this.resolveOpenEnvironmentData(
|
|
13961
14015
|
options,
|
|
13962
14016
|
"openEnvironment"
|
|
13963
14017
|
);
|
|
13964
|
-
|
|
14018
|
+
const environment = this.bindEnvironmentHandle(resolved.environment);
|
|
14019
|
+
await this.maybeRunEnvironmentImporter(resolved, environment);
|
|
14020
|
+
return environment;
|
|
13965
14021
|
}
|
|
13966
14022
|
/**
|
|
13967
14023
|
* Deprecated compatibility alias for `openEnvironment()`.
|
|
@@ -14048,7 +14104,12 @@ var Granular = class _Granular {
|
|
|
14048
14104
|
)
|
|
14049
14105
|
);
|
|
14050
14106
|
if (currentMatches.length > 0) {
|
|
14051
|
-
return
|
|
14107
|
+
return {
|
|
14108
|
+
environment: currentMatches[0],
|
|
14109
|
+
requestedOntology: ontology,
|
|
14110
|
+
sandboxId: sandbox.sandboxId,
|
|
14111
|
+
subjectId: user.granularId
|
|
14112
|
+
};
|
|
14052
14113
|
}
|
|
14053
14114
|
const outdatedMatches = this.sortEnvironmentsByRecency(
|
|
14054
14115
|
userEnvironments.filter(
|
|
@@ -14056,14 +14117,25 @@ var Granular = class _Granular {
|
|
|
14056
14117
|
)
|
|
14057
14118
|
);
|
|
14058
14119
|
if (outdatedMatches.length > 0 && options.createFreshIfOutdated !== true) {
|
|
14059
|
-
return
|
|
14120
|
+
return {
|
|
14121
|
+
environment: outdatedMatches[0],
|
|
14122
|
+
requestedOntology: ontology,
|
|
14123
|
+
sandboxId: sandbox.sandboxId,
|
|
14124
|
+
subjectId: user.granularId
|
|
14125
|
+
};
|
|
14060
14126
|
}
|
|
14061
|
-
return
|
|
14127
|
+
return {
|
|
14128
|
+
environment: await this.environments.create(sandbox.sandboxId, {
|
|
14129
|
+
subjectId: user.granularId,
|
|
14130
|
+
environment: this.buildManagedEnvironmentName(tagName, targetVersionId),
|
|
14131
|
+
tagId: tag.tagId,
|
|
14132
|
+
permissionProfileId: null
|
|
14133
|
+
}),
|
|
14134
|
+
requestedOntology: ontology,
|
|
14135
|
+
sandboxId: sandbox.sandboxId,
|
|
14062
14136
|
subjectId: user.granularId,
|
|
14063
|
-
|
|
14064
|
-
|
|
14065
|
-
permissionProfileId: null
|
|
14066
|
-
});
|
|
14137
|
+
setupTriggerReason: outdatedMatches.length > 0 ? "fresh_after_version_update" : "new_environment"
|
|
14138
|
+
};
|
|
14067
14139
|
}
|
|
14068
14140
|
/**
|
|
14069
14141
|
* List active (open) sessions for an environment — each session is one agent conversation thread.
|
|
@@ -14180,6 +14252,80 @@ var Granular = class _Granular {
|
|
|
14180
14252
|
});
|
|
14181
14253
|
return this.connectSession({ sessionId, clientId: options?.clientId });
|
|
14182
14254
|
}
|
|
14255
|
+
resolveEnvironmentImporter(requestedOntology, sandboxId) {
|
|
14256
|
+
const resolved = this.sandboxImporters.get(sandboxId) || this.ontologyImporters.get(requestedOntology);
|
|
14257
|
+
if (resolved && !this.sandboxImporters.has(sandboxId) && this.ontologyImporters.get(requestedOntology) === resolved) {
|
|
14258
|
+
this.sandboxImporters.set(sandboxId, resolved);
|
|
14259
|
+
}
|
|
14260
|
+
return resolved;
|
|
14261
|
+
}
|
|
14262
|
+
async maybeRunEnvironmentImporter(resolved, environment) {
|
|
14263
|
+
if (!resolved.setupTriggerReason) {
|
|
14264
|
+
return;
|
|
14265
|
+
}
|
|
14266
|
+
const importer = this.resolveEnvironmentImporter(
|
|
14267
|
+
resolved.requestedOntology,
|
|
14268
|
+
resolved.sandboxId
|
|
14269
|
+
);
|
|
14270
|
+
if (!importer) {
|
|
14271
|
+
return;
|
|
14272
|
+
}
|
|
14273
|
+
const setupRun = await this.request(
|
|
14274
|
+
`/control/environments/${environment.environmentId}/setup-runs`,
|
|
14275
|
+
{
|
|
14276
|
+
method: "POST",
|
|
14277
|
+
body: JSON.stringify({
|
|
14278
|
+
triggerReason: resolved.setupTriggerReason
|
|
14279
|
+
})
|
|
14280
|
+
}
|
|
14281
|
+
);
|
|
14282
|
+
const setupRunId = setupRun.setupRunId;
|
|
14283
|
+
const updateSetupRun = async (patch) => {
|
|
14284
|
+
await this.request(
|
|
14285
|
+
`/control/environment-setup-runs/${setupRunId}`,
|
|
14286
|
+
{
|
|
14287
|
+
method: "PATCH",
|
|
14288
|
+
body: JSON.stringify(patch)
|
|
14289
|
+
}
|
|
14290
|
+
);
|
|
14291
|
+
};
|
|
14292
|
+
const importerContext = {
|
|
14293
|
+
environmentId: environment.environmentId,
|
|
14294
|
+
sandboxId: environment.sandboxId,
|
|
14295
|
+
subjectId: environment.subjectId,
|
|
14296
|
+
reason: resolved.setupTriggerReason,
|
|
14297
|
+
incrementTotalObjectsToImportCount: async (n) => {
|
|
14298
|
+
const safeIncrement = Math.max(0, Math.trunc(n));
|
|
14299
|
+
if (safeIncrement <= 0) {
|
|
14300
|
+
return;
|
|
14301
|
+
}
|
|
14302
|
+
await updateSetupRun({
|
|
14303
|
+
incrementTotalObjectsToImportCount: safeIncrement
|
|
14304
|
+
});
|
|
14305
|
+
},
|
|
14306
|
+
setStage: async (stage) => {
|
|
14307
|
+
await updateSetupRun({ stage });
|
|
14308
|
+
},
|
|
14309
|
+
importRecords: async (records, options) => environment.enqueueRecordImport(records, {
|
|
14310
|
+
batchSize: options?.batchSize,
|
|
14311
|
+
setupRunId
|
|
14312
|
+
})
|
|
14313
|
+
};
|
|
14314
|
+
try {
|
|
14315
|
+
await importer(importerContext);
|
|
14316
|
+
await updateSetupRun({ markHookCompleted: true });
|
|
14317
|
+
const refreshedEnvironment = await this.environments.get(
|
|
14318
|
+
environment.environmentId
|
|
14319
|
+
);
|
|
14320
|
+
environment.syncEnvironmentData(refreshedEnvironment);
|
|
14321
|
+
} catch (error) {
|
|
14322
|
+
await updateSetupRun({
|
|
14323
|
+
status: "failed",
|
|
14324
|
+
errorMessage: error instanceof Error ? error.message : String(error)
|
|
14325
|
+
}).catch(() => void 0);
|
|
14326
|
+
throw error;
|
|
14327
|
+
}
|
|
14328
|
+
}
|
|
14183
14329
|
bindEnvironmentHandle(envData) {
|
|
14184
14330
|
const graphqlEndpoint = `${this.httpUrl}/orchestrator/graphql`;
|
|
14185
14331
|
return new Environment(this, envData, this.apiKey, graphqlEndpoint);
|
|
@@ -15821,12 +15967,11 @@ function buildContinuationInstruction(resultPreview) {
|
|
|
15821
15967
|
"Continue the same user request using the latest structured session state.",
|
|
15822
15968
|
"Take only the minimum next step that directly helps the user.",
|
|
15823
15969
|
"Use the active tasks, decisions, prompts, and heap references as the source of truth instead of replaying old work.",
|
|
15824
|
-
"If the user names a concrete record that is not already in the heap,
|
|
15970
|
+
"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.",
|
|
15971
|
+
"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.",
|
|
15825
15972
|
"If this request clearly spans multiple steps and there are no active tasks yet, create 2-4 short user-visible tasks now.",
|
|
15826
15973
|
"Reuse any existing taskId and decisionId values exactly as they appear in AGENT LOOP STATE.",
|
|
15827
|
-
"
|
|
15828
|
-
"Do not ask for confirmation in plain text. Use loop.confirm(...) when approval is needed.",
|
|
15829
|
-
"Await loop.ask_user(...) and loop.confirm(...). Those helpers pause the current job and resume it after the user answers.",
|
|
15974
|
+
"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.",
|
|
15830
15975
|
"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.'",
|
|
15831
15976
|
"If you ask the user a new question in this job, do not also close the loop in the same job.",
|
|
15832
15977
|
"Write the smallest straightforward code for the current step. Avoid defensive fallback branches for hypothetical states that are not currently true.",
|
|
@@ -16014,12 +16159,13 @@ ${loopBlock}
|
|
|
16014
16159
|
- 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.
|
|
16015
16160
|
- Use CAPABILITY SNAPSHOT to choose the next step, then use DOMAIN REFERENCE for exact signatures and query shapes.
|
|
16016
16161
|
- Take the minimum next step that directly helps the user. Avoid duplicate work, speculative cleanup, or extra fetching that is not needed yet.
|
|
16017
|
-
- 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.
|
|
16018
|
-
- 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.
|
|
16019
16162
|
- Use RECENT REFERENTS to resolve follow-up references across turns, such as "that invoice", "that customer", "those products", or "the other one".
|
|
16163
|
+
- 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.
|
|
16164
|
+
- 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.
|
|
16020
16165
|
- If the request has more than one reasonable interpretation, ask the user to clarify instead of guessing.
|
|
16021
16166
|
- 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.
|
|
16022
16167
|
- 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.
|
|
16168
|
+
- 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.
|
|
16023
16169
|
- Reuse exact \`taskId\`, \`decisionId\`, and \`closureId\` values from AGENT LOOP STATE. Never invent or rewrite them.
|
|
16024
16170
|
- If the request is ambiguous or clearly multi-step, create 2-4 short user-visible tasks and keep them updated as the workflow advances.
|
|
16025
16171
|
- Use \`loop.ask_user({ type: 'choice', options: [...] })\` when you have a short, grounded shortlist the user can choose from. Otherwise use \`type: 'input'\`.
|
|
@@ -16030,6 +16176,14 @@ ${loopBlock}
|
|
|
16030
16176
|
- 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.
|
|
16031
16177
|
- If you ask a new question in the current job, do not also close the loop in that same job.
|
|
16032
16178
|
|
|
16179
|
+
\u2500\u2500\u2500 LOOP HELPER REFERENCE \u2500\u2500\u2500
|
|
16180
|
+
- \`loop.ask_user(...)\`: pause the current job for missing input; use \`type: 'choice'\` only for a short grounded shortlist.
|
|
16181
|
+
- \`loop.confirm(...)\`: pause for yes/no approval before a consequential action, then branch on the returned boolean.
|
|
16182
|
+
- \`loop.open_decision(...)\`: save explicit candidates that later jobs can revisit; each candidate needs an \`id\`.
|
|
16183
|
+
- \`loop.close_decision(...)\`: resolve an open decision with a stored \`selectedId\` and optional rationale.
|
|
16184
|
+
- \`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.
|
|
16185
|
+
- \`loop.close_loop(...)\`: record the workflow outcome when it is completed, canceled, or blocked.
|
|
16186
|
+
|
|
16033
16187
|
\u2500\u2500\u2500 CODE RULES \u2500\u2500\u2500
|
|
16034
16188
|
- Import from \`./sandbox-tools\`.
|
|
16035
16189
|
- If you use \`heap\`, \`loop\`, \`agent_text_message\`, or \`agent_heap_objects\`, import them explicitly from \`./sandbox-tools\`.
|
|
@@ -16039,6 +16193,7 @@ ${loopBlock}
|
|
|
16039
16193
|
- Use \`ClassName.get({ path })\` only for known graph paths when you want a direct graph fetch.
|
|
16040
16194
|
- 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.
|
|
16041
16195
|
- \`perPage\` defaults to \`100\` and is capped at \`100\`.
|
|
16196
|
+
- 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.
|
|
16042
16197
|
- Push \`filter\`, \`search\`, and \`sort\` into graph queries instead of fetching a page and processing it locally.
|
|
16043
16198
|
- 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.
|
|
16044
16199
|
- 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.
|