@granular-software/sdk 0.4.41 → 0.4.42
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 +137 -3
- package/dist/agent-evals.d.ts +137 -3
- package/dist/agent-evals.js +1075 -26
- package/dist/agent-evals.js.map +1 -1
- package/dist/agent-evals.mjs +1075 -28
- package/dist/agent-evals.mjs.map +1 -1
- package/dist/agent-harness.d.mts +60 -1
- package/dist/agent-harness.d.ts +60 -1
- package/dist/agent-harness.js +475 -0
- package/dist/agent-harness.js.map +1 -1
- package/dist/agent-harness.mjs +467 -1
- package/dist/agent-harness.mjs.map +1 -1
- package/dist/cli/index.js +282 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +475 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +467 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/agent-harness.mjs
CHANGED
|
@@ -1,4 +1,272 @@
|
|
|
1
|
+
// src/agent-harness-templates/action-presentation/0.1.0/manifest.json
|
|
2
|
+
var manifest_default = {
|
|
3
|
+
id: "action-presentation",
|
|
4
|
+
version: "0.1.0",
|
|
5
|
+
status: "candidate",
|
|
6
|
+
owner: "granular",
|
|
7
|
+
createdAt: "2026-05-25T00:00:00.000Z",
|
|
8
|
+
changelog: "Candidate harness template focused on action-request detection and mutation result presentation. It exists to harden cases where the model answers with a terse completion such as Done instead of using tools and reporting the target/action/result.",
|
|
9
|
+
promptBuilder: "buildGranularAgentSystemPrompt:action-presentation",
|
|
10
|
+
continuationBuilder: "buildContinuationInstruction:action-presentation",
|
|
11
|
+
modelOutputInstruction: "agent-evals:modelOutputInstruction",
|
|
12
|
+
codeReviewPolicy: "reviewGeneratedJobCode",
|
|
13
|
+
defaultModel: "gpt-5.4",
|
|
14
|
+
modelMatrix: ["gpt-5.4"],
|
|
15
|
+
temperature: 0,
|
|
16
|
+
compatibility: {
|
|
17
|
+
minSdkVersion: "0.4.40",
|
|
18
|
+
capabilities: [
|
|
19
|
+
"executeCode",
|
|
20
|
+
"readEntities",
|
|
21
|
+
"workflowHelpers",
|
|
22
|
+
"savedData",
|
|
23
|
+
"showRecords"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
evalGates: {
|
|
27
|
+
requiredSuites: [
|
|
28
|
+
"agent-harness-hardening",
|
|
29
|
+
"agent-harness-runtime-e2e",
|
|
30
|
+
"agent-production-readiness-e2e"
|
|
31
|
+
],
|
|
32
|
+
criticalBuckets: [
|
|
33
|
+
"relationship-traversal",
|
|
34
|
+
"cross-turn-reference",
|
|
35
|
+
"ambiguous-target-choice",
|
|
36
|
+
"confirmation-gated-mutation",
|
|
37
|
+
"denied-action-refusal",
|
|
38
|
+
"mutation-presentation"
|
|
39
|
+
],
|
|
40
|
+
maxRegressionPct: 0,
|
|
41
|
+
minPassK: {
|
|
42
|
+
"critical-mutation": 0.9,
|
|
43
|
+
"permission-boundary": 1
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// src/agent-harness-templates/experimental-compact/0.1.0/manifest.json
|
|
49
|
+
var manifest_default2 = {
|
|
50
|
+
id: "experimental-compact",
|
|
51
|
+
version: "0.1.0",
|
|
52
|
+
status: "candidate",
|
|
53
|
+
owner: "granular",
|
|
54
|
+
createdAt: "2026-05-24T00:00:00.000Z",
|
|
55
|
+
changelog: "Candidate harness template used for champion/challenger testing. It adds a compact decision discipline section on top of the stable renderer.",
|
|
56
|
+
promptBuilder: "buildGranularAgentSystemPrompt:experimental-compact",
|
|
57
|
+
continuationBuilder: "buildContinuationInstruction:experimental-compact",
|
|
58
|
+
modelOutputInstruction: "agent-evals:modelOutputInstruction",
|
|
59
|
+
codeReviewPolicy: "reviewGeneratedJobCode",
|
|
60
|
+
defaultModel: "gpt-5.4",
|
|
61
|
+
modelMatrix: ["gpt-5.4"],
|
|
62
|
+
temperature: 0,
|
|
63
|
+
compatibility: {
|
|
64
|
+
minSdkVersion: "0.4.40",
|
|
65
|
+
capabilities: [
|
|
66
|
+
"executeCode",
|
|
67
|
+
"readEntities",
|
|
68
|
+
"workflowHelpers",
|
|
69
|
+
"savedData",
|
|
70
|
+
"showRecords"
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
evalGates: {
|
|
74
|
+
requiredSuites: [
|
|
75
|
+
"agent-harness-hardening",
|
|
76
|
+
"agent-harness-runtime-e2e",
|
|
77
|
+
"agent-production-readiness-e2e"
|
|
78
|
+
],
|
|
79
|
+
criticalBuckets: [
|
|
80
|
+
"relationship-traversal",
|
|
81
|
+
"cross-turn-reference",
|
|
82
|
+
"ambiguous-target-choice",
|
|
83
|
+
"confirmation-gated-mutation",
|
|
84
|
+
"denied-action-refusal",
|
|
85
|
+
"mutation-presentation"
|
|
86
|
+
],
|
|
87
|
+
maxRegressionPct: 0,
|
|
88
|
+
minPassK: {
|
|
89
|
+
"critical-mutation": 0.9,
|
|
90
|
+
"permission-boundary": 1
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// src/agent-harness-templates/stable/1.0.0/manifest.json
|
|
96
|
+
var manifest_default3 = {
|
|
97
|
+
id: "stable",
|
|
98
|
+
version: "1.0.0",
|
|
99
|
+
status: "stable",
|
|
100
|
+
owner: "granular",
|
|
101
|
+
createdAt: "2026-05-24T00:00:00.000Z",
|
|
102
|
+
changelog: "Baseline template wrapping the existing Granular agent harness prompt, continuation instruction, output contract, and generated-job review policy.",
|
|
103
|
+
promptBuilder: "buildGranularAgentSystemPrompt",
|
|
104
|
+
continuationBuilder: "buildContinuationInstruction",
|
|
105
|
+
modelOutputInstruction: "agent-evals:modelOutputInstruction",
|
|
106
|
+
codeReviewPolicy: "reviewGeneratedJobCode",
|
|
107
|
+
defaultModel: "gpt-5.4",
|
|
108
|
+
modelMatrix: ["gpt-5.4"],
|
|
109
|
+
temperature: 0,
|
|
110
|
+
compatibility: {
|
|
111
|
+
minSdkVersion: "0.4.40",
|
|
112
|
+
capabilities: [
|
|
113
|
+
"executeCode",
|
|
114
|
+
"readEntities",
|
|
115
|
+
"workflowHelpers",
|
|
116
|
+
"savedData",
|
|
117
|
+
"showRecords"
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
evalGates: {
|
|
121
|
+
requiredSuites: [
|
|
122
|
+
"agent-harness-hardening",
|
|
123
|
+
"agent-harness-runtime-e2e",
|
|
124
|
+
"agent-production-readiness-e2e"
|
|
125
|
+
],
|
|
126
|
+
criticalBuckets: [
|
|
127
|
+
"relationship-traversal",
|
|
128
|
+
"cross-turn-reference",
|
|
129
|
+
"ambiguous-target-choice",
|
|
130
|
+
"confirmation-gated-mutation",
|
|
131
|
+
"denied-action-refusal",
|
|
132
|
+
"mutation-presentation"
|
|
133
|
+
],
|
|
134
|
+
maxRegressionPct: 0,
|
|
135
|
+
minPassK: {
|
|
136
|
+
"critical-mutation": 0.9,
|
|
137
|
+
"permission-boundary": 1
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
1
142
|
// src/agent-harness.ts
|
|
143
|
+
var HARNESS_TEMPLATE_STATUSES = [
|
|
144
|
+
"draft",
|
|
145
|
+
"candidate",
|
|
146
|
+
"release-candidate",
|
|
147
|
+
"stable",
|
|
148
|
+
"deprecated"
|
|
149
|
+
];
|
|
150
|
+
function requireRecord(value, context) {
|
|
151
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
152
|
+
throw new Error(`${context} must be an object.`);
|
|
153
|
+
}
|
|
154
|
+
return value;
|
|
155
|
+
}
|
|
156
|
+
function requiredString(record, key, context) {
|
|
157
|
+
const value = record[key];
|
|
158
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
159
|
+
throw new Error(`${context}.${key} must be a non-empty string.`);
|
|
160
|
+
}
|
|
161
|
+
return value;
|
|
162
|
+
}
|
|
163
|
+
function requiredNumber(record, key, context) {
|
|
164
|
+
const value = record[key];
|
|
165
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
166
|
+
throw new Error(`${context}.${key} must be a finite number.`);
|
|
167
|
+
}
|
|
168
|
+
return value;
|
|
169
|
+
}
|
|
170
|
+
function requiredStringArray(record, key, context) {
|
|
171
|
+
const value = record[key];
|
|
172
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== "string" || !item.trim())) {
|
|
173
|
+
throw new Error(`${context}.${key} must be an array of non-empty strings.`);
|
|
174
|
+
}
|
|
175
|
+
return [...value];
|
|
176
|
+
}
|
|
177
|
+
function requiredNumberRecord(record, key, context) {
|
|
178
|
+
const value = requireRecord(record[key], `${context}.${key}`);
|
|
179
|
+
const output = {};
|
|
180
|
+
for (const [entryKey, entryValue] of Object.entries(value)) {
|
|
181
|
+
if (typeof entryValue !== "number" || !Number.isFinite(entryValue) || entryValue < 0 || entryValue > 1) {
|
|
182
|
+
throw new Error(
|
|
183
|
+
`${context}.${key}.${entryKey} must be a number between 0 and 1.`
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
output[entryKey] = entryValue;
|
|
187
|
+
}
|
|
188
|
+
return output;
|
|
189
|
+
}
|
|
190
|
+
function validateHarnessTemplateManifest(value, context = "HarnessTemplateManifest") {
|
|
191
|
+
const record = requireRecord(value, context);
|
|
192
|
+
const status = requiredString(record, "status", context);
|
|
193
|
+
if (!HARNESS_TEMPLATE_STATUSES.includes(status)) {
|
|
194
|
+
throw new Error(
|
|
195
|
+
`${context}.status must be one of ${HARNESS_TEMPLATE_STATUSES.join(", ")}.`
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
const createdAt = requiredString(record, "createdAt", context);
|
|
199
|
+
if (Number.isNaN(Date.parse(createdAt))) {
|
|
200
|
+
throw new Error(`${context}.createdAt must be an ISO timestamp.`);
|
|
201
|
+
}
|
|
202
|
+
const compatibility = requireRecord(
|
|
203
|
+
record.compatibility,
|
|
204
|
+
`${context}.compatibility`
|
|
205
|
+
);
|
|
206
|
+
const evalGates = requireRecord(record.evalGates, `${context}.evalGates`);
|
|
207
|
+
const maxRegressionPct = requiredNumber(
|
|
208
|
+
evalGates,
|
|
209
|
+
"maxRegressionPct",
|
|
210
|
+
`${context}.evalGates`
|
|
211
|
+
);
|
|
212
|
+
if (maxRegressionPct < 0 || maxRegressionPct > 1) {
|
|
213
|
+
throw new Error(
|
|
214
|
+
`${context}.evalGates.maxRegressionPct must be between 0 and 1.`
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
id: requiredString(record, "id", context),
|
|
219
|
+
version: requiredString(record, "version", context),
|
|
220
|
+
status,
|
|
221
|
+
owner: requiredString(record, "owner", context),
|
|
222
|
+
createdAt,
|
|
223
|
+
changelog: requiredString(record, "changelog", context),
|
|
224
|
+
promptBuilder: requiredString(record, "promptBuilder", context),
|
|
225
|
+
continuationBuilder: requiredString(record, "continuationBuilder", context),
|
|
226
|
+
modelOutputInstruction: requiredString(
|
|
227
|
+
record,
|
|
228
|
+
"modelOutputInstruction",
|
|
229
|
+
context
|
|
230
|
+
),
|
|
231
|
+
codeReviewPolicy: requiredString(record, "codeReviewPolicy", context),
|
|
232
|
+
defaultModel: requiredString(record, "defaultModel", context),
|
|
233
|
+
modelMatrix: requiredStringArray(record, "modelMatrix", context),
|
|
234
|
+
temperature: requiredNumber(record, "temperature", context),
|
|
235
|
+
compatibility: {
|
|
236
|
+
minSdkVersion: requiredString(
|
|
237
|
+
compatibility,
|
|
238
|
+
"minSdkVersion",
|
|
239
|
+
`${context}.compatibility`
|
|
240
|
+
),
|
|
241
|
+
capabilities: requiredStringArray(
|
|
242
|
+
compatibility,
|
|
243
|
+
"capabilities",
|
|
244
|
+
`${context}.compatibility`
|
|
245
|
+
)
|
|
246
|
+
},
|
|
247
|
+
evalGates: {
|
|
248
|
+
requiredSuites: requiredStringArray(
|
|
249
|
+
evalGates,
|
|
250
|
+
"requiredSuites",
|
|
251
|
+
`${context}.evalGates`
|
|
252
|
+
),
|
|
253
|
+
criticalBuckets: requiredStringArray(
|
|
254
|
+
evalGates,
|
|
255
|
+
"criticalBuckets",
|
|
256
|
+
`${context}.evalGates`
|
|
257
|
+
),
|
|
258
|
+
maxRegressionPct,
|
|
259
|
+
minPassK: requiredNumberRecord(
|
|
260
|
+
evalGates,
|
|
261
|
+
"minPassK",
|
|
262
|
+
`${context}.evalGates`
|
|
263
|
+
)
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function defineHarnessTemplateManifest(value, context) {
|
|
268
|
+
return validateHarnessTemplateManifest(value, context);
|
|
269
|
+
}
|
|
2
270
|
var DEFAULT_IGNORED_REASONING_COMMENT_DIRECTIVES = [
|
|
3
271
|
/^@ts-ignore\b/i,
|
|
4
272
|
/^@ts-expect-error\b/i,
|
|
@@ -101,6 +369,16 @@ function uniqueStrings(values, maxCount) {
|
|
|
101
369
|
}
|
|
102
370
|
return output;
|
|
103
371
|
}
|
|
372
|
+
function stableStringify(value) {
|
|
373
|
+
if (value === null || typeof value !== "object") {
|
|
374
|
+
return JSON.stringify(value);
|
|
375
|
+
}
|
|
376
|
+
if (Array.isArray(value)) {
|
|
377
|
+
return `[${value.map((entry) => stableStringify(entry)).join(",")}]`;
|
|
378
|
+
}
|
|
379
|
+
const record = value;
|
|
380
|
+
return `{${Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${stableStringify(record[key])}`).join(",")}}`;
|
|
381
|
+
}
|
|
104
382
|
function renderConstBlock(name, value) {
|
|
105
383
|
return `const ${name} = ${JSON.stringify(value, null, 2)} as const;`;
|
|
106
384
|
}
|
|
@@ -2045,7 +2323,195 @@ ${knownFactsBlock}
|
|
|
2045
2323
|
[Request]
|
|
2046
2324
|
${input.request?.trim() || "Use the latest user message in the conversation."}`;
|
|
2047
2325
|
}
|
|
2326
|
+
var STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST = defineHarnessTemplateManifest(
|
|
2327
|
+
manifest_default3,
|
|
2328
|
+
"stable@1.0.0 manifest"
|
|
2329
|
+
);
|
|
2330
|
+
function hashHarnessTemplateValue(value) {
|
|
2331
|
+
return hashString(stableStringify(value)) || "00000000";
|
|
2332
|
+
}
|
|
2333
|
+
function renderStableHarnessPrompt(input) {
|
|
2334
|
+
const prompt = buildGranularAgentSystemPrompt(input);
|
|
2335
|
+
const templateHash = hashHarnessTemplateValue(
|
|
2336
|
+
STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
2337
|
+
);
|
|
2338
|
+
return {
|
|
2339
|
+
templateId: STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
2340
|
+
templateVersion: STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
2341
|
+
templateHash,
|
|
2342
|
+
promptInstanceHash: hashHarnessTemplateValue({
|
|
2343
|
+
templateHash,
|
|
2344
|
+
input,
|
|
2345
|
+
prompt
|
|
2346
|
+
}),
|
|
2347
|
+
prompt
|
|
2348
|
+
};
|
|
2349
|
+
}
|
|
2350
|
+
function renderStableHarnessContinuation(resultPreview) {
|
|
2351
|
+
const instruction = buildContinuationInstruction(resultPreview);
|
|
2352
|
+
const templateHash = hashHarnessTemplateValue(
|
|
2353
|
+
STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
2354
|
+
);
|
|
2355
|
+
return {
|
|
2356
|
+
templateId: STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
2357
|
+
templateVersion: STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
2358
|
+
templateHash,
|
|
2359
|
+
instruction
|
|
2360
|
+
};
|
|
2361
|
+
}
|
|
2362
|
+
var STABLE_AGENT_HARNESS_TEMPLATE = {
|
|
2363
|
+
manifest: STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST,
|
|
2364
|
+
renderPrompt: renderStableHarnessPrompt,
|
|
2365
|
+
renderContinuation: renderStableHarnessContinuation
|
|
2366
|
+
};
|
|
2367
|
+
var EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST = defineHarnessTemplateManifest(
|
|
2368
|
+
manifest_default2,
|
|
2369
|
+
"experimental-compact@0.1.0 manifest"
|
|
2370
|
+
);
|
|
2371
|
+
function renderExperimentalCompactHarnessPrompt(input) {
|
|
2372
|
+
const prompt = `${buildGranularAgentSystemPrompt(input)}
|
|
2373
|
+
|
|
2374
|
+
[Candidate Harness Delta: Compact Decision Discipline]
|
|
2375
|
+
- Prefer the smallest action that satisfies the current request.
|
|
2376
|
+
- When several records could match, ask one structured choice question before mutating.
|
|
2377
|
+
- Before any irreversible or outbound mutation, obtain explicit confirmation unless the policy surface already requires it.
|
|
2378
|
+
- Do not compensate for missing tools with raw network calls, synthetic records, or hidden side channels.
|
|
2379
|
+
- Keep the final user-facing reply focused on what was done, what was not done, and any remaining blocker.`;
|
|
2380
|
+
const templateHash = hashHarnessTemplateValue(
|
|
2381
|
+
EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
2382
|
+
);
|
|
2383
|
+
return {
|
|
2384
|
+
templateId: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
2385
|
+
templateVersion: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
2386
|
+
templateHash,
|
|
2387
|
+
promptInstanceHash: hashHarnessTemplateValue({
|
|
2388
|
+
templateHash,
|
|
2389
|
+
input,
|
|
2390
|
+
prompt
|
|
2391
|
+
}),
|
|
2392
|
+
prompt
|
|
2393
|
+
};
|
|
2394
|
+
}
|
|
2395
|
+
function renderExperimentalCompactHarnessContinuation(resultPreview) {
|
|
2396
|
+
const instruction = `${buildContinuationInstruction(resultPreview)}
|
|
2397
|
+
|
|
2398
|
+
Keep the continuation compact: either finish, ask the one blocking question, or run the next smallest safe action.`;
|
|
2399
|
+
const templateHash = hashHarnessTemplateValue(
|
|
2400
|
+
EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
2401
|
+
);
|
|
2402
|
+
return {
|
|
2403
|
+
templateId: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
2404
|
+
templateVersion: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
2405
|
+
templateHash,
|
|
2406
|
+
instruction
|
|
2407
|
+
};
|
|
2408
|
+
}
|
|
2409
|
+
var EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE = {
|
|
2410
|
+
manifest: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST,
|
|
2411
|
+
renderPrompt: renderExperimentalCompactHarnessPrompt,
|
|
2412
|
+
renderContinuation: renderExperimentalCompactHarnessContinuation
|
|
2413
|
+
};
|
|
2414
|
+
var ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST = defineHarnessTemplateManifest(
|
|
2415
|
+
manifest_default,
|
|
2416
|
+
"action-presentation@0.1.0 manifest"
|
|
2417
|
+
);
|
|
2418
|
+
function renderActionPresentationHarnessPrompt(input) {
|
|
2419
|
+
const prompt = `${buildGranularAgentSystemPrompt(input)}
|
|
2420
|
+
|
|
2421
|
+
[Candidate Harness Delta: Action Request And Result Presentation]
|
|
2422
|
+
- Treat requests like "handle it", "take care of it", "send it", "update it", "fix it", "process it", or "do it" as action requests when the message names a business object, target, workflow, or mutation verb.
|
|
2423
|
+
- For action requests involving session data, generated files, records, effects, or workflows, do not use text-only completion. Generate and run code, ask the blocking human question, or clearly refuse if policy/tooling prevents the action.
|
|
2424
|
+
- Never answer only "Done", "OK", "Handled", or similar terse completion text for a mutation request. The final user-facing reply must name the action attempted, the grounded target or blocker, and the actual result.
|
|
2425
|
+
- After a mutation/effect call, base the reply on the returned action result and include a visible target label or identifier when one exists.
|
|
2426
|
+
- If no target can be grounded, say what was searched and what exact identifier or choice is needed; do not pretend the action completed.`;
|
|
2427
|
+
const templateHash = hashHarnessTemplateValue(
|
|
2428
|
+
ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
2429
|
+
);
|
|
2430
|
+
return {
|
|
2431
|
+
templateId: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
2432
|
+
templateVersion: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
2433
|
+
templateHash,
|
|
2434
|
+
promptInstanceHash: hashHarnessTemplateValue({
|
|
2435
|
+
templateHash,
|
|
2436
|
+
input,
|
|
2437
|
+
prompt
|
|
2438
|
+
}),
|
|
2439
|
+
prompt
|
|
2440
|
+
};
|
|
2441
|
+
}
|
|
2442
|
+
function renderActionPresentationHarnessContinuation(resultPreview) {
|
|
2443
|
+
const instruction = `${buildContinuationInstruction(resultPreview)}
|
|
2444
|
+
|
|
2445
|
+
Before finishing, check whether the latest user request asked for an action. If it did, do not finish with a bare completion token; either continue with the needed tool/code step, ask the blocking question, refuse with the policy reason, or report the grounded action result with the target label.`;
|
|
2446
|
+
const templateHash = hashHarnessTemplateValue(
|
|
2447
|
+
ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
2448
|
+
);
|
|
2449
|
+
return {
|
|
2450
|
+
templateId: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
2451
|
+
templateVersion: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
2452
|
+
templateHash,
|
|
2453
|
+
instruction
|
|
2454
|
+
};
|
|
2455
|
+
}
|
|
2456
|
+
var ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE = {
|
|
2457
|
+
manifest: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST,
|
|
2458
|
+
renderPrompt: renderActionPresentationHarnessPrompt,
|
|
2459
|
+
renderContinuation: renderActionPresentationHarnessContinuation
|
|
2460
|
+
};
|
|
2461
|
+
var AGENT_HARNESS_TEMPLATES = {
|
|
2462
|
+
[STABLE_AGENT_HARNESS_TEMPLATE.manifest.id]: STABLE_AGENT_HARNESS_TEMPLATE,
|
|
2463
|
+
[EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE.manifest.id]: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE,
|
|
2464
|
+
[ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE.manifest.id]: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE
|
|
2465
|
+
};
|
|
2466
|
+
function listHarnessTemplates() {
|
|
2467
|
+
return Object.values(AGENT_HARNESS_TEMPLATES).map((template) => ({
|
|
2468
|
+
...template.manifest,
|
|
2469
|
+
compatibility: { ...template.manifest.compatibility },
|
|
2470
|
+
evalGates: {
|
|
2471
|
+
...template.manifest.evalGates,
|
|
2472
|
+
minPassK: { ...template.manifest.evalGates.minPassK }
|
|
2473
|
+
}
|
|
2474
|
+
}));
|
|
2475
|
+
}
|
|
2476
|
+
function resolveHarnessTemplate(templateId = "stable", options) {
|
|
2477
|
+
const resolved = AGENT_HARNESS_TEMPLATES[templateId];
|
|
2478
|
+
if (resolved) return resolved;
|
|
2479
|
+
if (options?.strict) {
|
|
2480
|
+
const known = Object.keys(AGENT_HARNESS_TEMPLATES).join(", ");
|
|
2481
|
+
throw new Error(
|
|
2482
|
+
`Unknown harness template "${templateId}". Known templates: ${known}`
|
|
2483
|
+
);
|
|
2484
|
+
}
|
|
2485
|
+
return STABLE_AGENT_HARNESS_TEMPLATE;
|
|
2486
|
+
}
|
|
2487
|
+
function getDefaultHarnessTemplateId() {
|
|
2488
|
+
if (typeof process !== "undefined") {
|
|
2489
|
+
const configured = process.env.GRANULAR_AGENT_HARNESS_TEMPLATE || process.env.NEXT_PUBLIC_GRANULAR_AGENT_HARNESS_TEMPLATE;
|
|
2490
|
+
if (configured?.trim()) return configured.trim();
|
|
2491
|
+
}
|
|
2492
|
+
return "stable";
|
|
2493
|
+
}
|
|
2494
|
+
function renderGranularAgentSystemPromptFromTemplate(input, options) {
|
|
2495
|
+
const template = resolveHarnessTemplate(
|
|
2496
|
+
options?.templateId || getDefaultHarnessTemplateId(),
|
|
2497
|
+
{ strict: options?.strict ?? true }
|
|
2498
|
+
);
|
|
2499
|
+
return template.renderPrompt(input);
|
|
2500
|
+
}
|
|
2501
|
+
function buildGranularAgentSystemPromptFromTemplate(input, options) {
|
|
2502
|
+
return renderGranularAgentSystemPromptFromTemplate(input, options).prompt;
|
|
2503
|
+
}
|
|
2504
|
+
function renderContinuationInstructionFromTemplate(resultPreview, options) {
|
|
2505
|
+
const template = resolveHarnessTemplate(
|
|
2506
|
+
options?.templateId || getDefaultHarnessTemplateId(),
|
|
2507
|
+
{ strict: options?.strict ?? true }
|
|
2508
|
+
);
|
|
2509
|
+
return template.renderContinuation(resultPreview);
|
|
2510
|
+
}
|
|
2511
|
+
function buildContinuationInstructionFromTemplate(resultPreview, options) {
|
|
2512
|
+
return renderContinuationInstructionFromTemplate(resultPreview, options).instruction;
|
|
2513
|
+
}
|
|
2048
2514
|
|
|
2049
|
-
export { buildContinuationInstruction, buildGranularAgentCheckpointBlock, buildGranularAgentDomainBlock, buildGranularAgentFileBlock, buildGranularAgentHeapBlock, buildGranularAgentLoopBlock, buildGranularAgentReferentBlock, buildGranularAgentRuntimeImportsBlock, buildGranularAgentSessionBlock, buildGranularAgentSystemPrompt, buildGranularAgentToolBlock, buildGranularAgentWorkflowBlock, consumeGranularReasoningOnlyChunk, consumeGranularReasoningTraceChunk, createHarnessVerifierSnapshot, evaluateContinuation, getCurrentClosureId, getExclusivePromptTarget, hasOpenPrompt, projectConversationReferentFocus, projectConversationReferentSummary, projectHeapSummary, projectLoopSummary, projectSessionFileSummary, projectWorkflowFocus, projectWorkflowSummary, reviewGeneratedJobCode, stripGranularReasoningTrace };
|
|
2515
|
+
export { buildContinuationInstruction, buildContinuationInstructionFromTemplate, buildGranularAgentCheckpointBlock, buildGranularAgentDomainBlock, buildGranularAgentFileBlock, buildGranularAgentHeapBlock, buildGranularAgentLoopBlock, buildGranularAgentReferentBlock, buildGranularAgentRuntimeImportsBlock, buildGranularAgentSessionBlock, buildGranularAgentSystemPrompt, buildGranularAgentSystemPromptFromTemplate, buildGranularAgentToolBlock, buildGranularAgentWorkflowBlock, consumeGranularReasoningOnlyChunk, consumeGranularReasoningTraceChunk, createHarnessVerifierSnapshot, evaluateContinuation, getCurrentClosureId, getDefaultHarnessTemplateId, getExclusivePromptTarget, hasOpenPrompt, hashHarnessTemplateValue, listHarnessTemplates, projectConversationReferentFocus, projectConversationReferentSummary, projectHeapSummary, projectLoopSummary, projectSessionFileSummary, projectWorkflowFocus, projectWorkflowSummary, renderContinuationInstructionFromTemplate, renderGranularAgentSystemPromptFromTemplate, resolveHarnessTemplate, reviewGeneratedJobCode, stripGranularReasoningTrace, validateHarnessTemplateManifest };
|
|
2050
2516
|
//# sourceMappingURL=agent-harness.mjs.map
|
|
2051
2517
|
//# sourceMappingURL=agent-harness.mjs.map
|