@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/index.js
CHANGED
|
@@ -16079,7 +16079,275 @@ var Granular = class _Granular {
|
|
|
16079
16079
|
}
|
|
16080
16080
|
};
|
|
16081
16081
|
|
|
16082
|
+
// src/agent-harness-templates/action-presentation/0.1.0/manifest.json
|
|
16083
|
+
var manifest_default = {
|
|
16084
|
+
id: "action-presentation",
|
|
16085
|
+
version: "0.1.0",
|
|
16086
|
+
status: "candidate",
|
|
16087
|
+
owner: "granular",
|
|
16088
|
+
createdAt: "2026-05-25T00:00:00.000Z",
|
|
16089
|
+
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.",
|
|
16090
|
+
promptBuilder: "buildGranularAgentSystemPrompt:action-presentation",
|
|
16091
|
+
continuationBuilder: "buildContinuationInstruction:action-presentation",
|
|
16092
|
+
modelOutputInstruction: "agent-evals:modelOutputInstruction",
|
|
16093
|
+
codeReviewPolicy: "reviewGeneratedJobCode",
|
|
16094
|
+
defaultModel: "gpt-5.4",
|
|
16095
|
+
modelMatrix: ["gpt-5.4"],
|
|
16096
|
+
temperature: 0,
|
|
16097
|
+
compatibility: {
|
|
16098
|
+
minSdkVersion: "0.4.40",
|
|
16099
|
+
capabilities: [
|
|
16100
|
+
"executeCode",
|
|
16101
|
+
"readEntities",
|
|
16102
|
+
"workflowHelpers",
|
|
16103
|
+
"savedData",
|
|
16104
|
+
"showRecords"
|
|
16105
|
+
]
|
|
16106
|
+
},
|
|
16107
|
+
evalGates: {
|
|
16108
|
+
requiredSuites: [
|
|
16109
|
+
"agent-harness-hardening",
|
|
16110
|
+
"agent-harness-runtime-e2e",
|
|
16111
|
+
"agent-production-readiness-e2e"
|
|
16112
|
+
],
|
|
16113
|
+
criticalBuckets: [
|
|
16114
|
+
"relationship-traversal",
|
|
16115
|
+
"cross-turn-reference",
|
|
16116
|
+
"ambiguous-target-choice",
|
|
16117
|
+
"confirmation-gated-mutation",
|
|
16118
|
+
"denied-action-refusal",
|
|
16119
|
+
"mutation-presentation"
|
|
16120
|
+
],
|
|
16121
|
+
maxRegressionPct: 0,
|
|
16122
|
+
minPassK: {
|
|
16123
|
+
"critical-mutation": 0.9,
|
|
16124
|
+
"permission-boundary": 1
|
|
16125
|
+
}
|
|
16126
|
+
}
|
|
16127
|
+
};
|
|
16128
|
+
|
|
16129
|
+
// src/agent-harness-templates/experimental-compact/0.1.0/manifest.json
|
|
16130
|
+
var manifest_default2 = {
|
|
16131
|
+
id: "experimental-compact",
|
|
16132
|
+
version: "0.1.0",
|
|
16133
|
+
status: "candidate",
|
|
16134
|
+
owner: "granular",
|
|
16135
|
+
createdAt: "2026-05-24T00:00:00.000Z",
|
|
16136
|
+
changelog: "Candidate harness template used for champion/challenger testing. It adds a compact decision discipline section on top of the stable renderer.",
|
|
16137
|
+
promptBuilder: "buildGranularAgentSystemPrompt:experimental-compact",
|
|
16138
|
+
continuationBuilder: "buildContinuationInstruction:experimental-compact",
|
|
16139
|
+
modelOutputInstruction: "agent-evals:modelOutputInstruction",
|
|
16140
|
+
codeReviewPolicy: "reviewGeneratedJobCode",
|
|
16141
|
+
defaultModel: "gpt-5.4",
|
|
16142
|
+
modelMatrix: ["gpt-5.4"],
|
|
16143
|
+
temperature: 0,
|
|
16144
|
+
compatibility: {
|
|
16145
|
+
minSdkVersion: "0.4.40",
|
|
16146
|
+
capabilities: [
|
|
16147
|
+
"executeCode",
|
|
16148
|
+
"readEntities",
|
|
16149
|
+
"workflowHelpers",
|
|
16150
|
+
"savedData",
|
|
16151
|
+
"showRecords"
|
|
16152
|
+
]
|
|
16153
|
+
},
|
|
16154
|
+
evalGates: {
|
|
16155
|
+
requiredSuites: [
|
|
16156
|
+
"agent-harness-hardening",
|
|
16157
|
+
"agent-harness-runtime-e2e",
|
|
16158
|
+
"agent-production-readiness-e2e"
|
|
16159
|
+
],
|
|
16160
|
+
criticalBuckets: [
|
|
16161
|
+
"relationship-traversal",
|
|
16162
|
+
"cross-turn-reference",
|
|
16163
|
+
"ambiguous-target-choice",
|
|
16164
|
+
"confirmation-gated-mutation",
|
|
16165
|
+
"denied-action-refusal",
|
|
16166
|
+
"mutation-presentation"
|
|
16167
|
+
],
|
|
16168
|
+
maxRegressionPct: 0,
|
|
16169
|
+
minPassK: {
|
|
16170
|
+
"critical-mutation": 0.9,
|
|
16171
|
+
"permission-boundary": 1
|
|
16172
|
+
}
|
|
16173
|
+
}
|
|
16174
|
+
};
|
|
16175
|
+
|
|
16176
|
+
// src/agent-harness-templates/stable/1.0.0/manifest.json
|
|
16177
|
+
var manifest_default3 = {
|
|
16178
|
+
id: "stable",
|
|
16179
|
+
version: "1.0.0",
|
|
16180
|
+
status: "stable",
|
|
16181
|
+
owner: "granular",
|
|
16182
|
+
createdAt: "2026-05-24T00:00:00.000Z",
|
|
16183
|
+
changelog: "Baseline template wrapping the existing Granular agent harness prompt, continuation instruction, output contract, and generated-job review policy.",
|
|
16184
|
+
promptBuilder: "buildGranularAgentSystemPrompt",
|
|
16185
|
+
continuationBuilder: "buildContinuationInstruction",
|
|
16186
|
+
modelOutputInstruction: "agent-evals:modelOutputInstruction",
|
|
16187
|
+
codeReviewPolicy: "reviewGeneratedJobCode",
|
|
16188
|
+
defaultModel: "gpt-5.4",
|
|
16189
|
+
modelMatrix: ["gpt-5.4"],
|
|
16190
|
+
temperature: 0,
|
|
16191
|
+
compatibility: {
|
|
16192
|
+
minSdkVersion: "0.4.40",
|
|
16193
|
+
capabilities: [
|
|
16194
|
+
"executeCode",
|
|
16195
|
+
"readEntities",
|
|
16196
|
+
"workflowHelpers",
|
|
16197
|
+
"savedData",
|
|
16198
|
+
"showRecords"
|
|
16199
|
+
]
|
|
16200
|
+
},
|
|
16201
|
+
evalGates: {
|
|
16202
|
+
requiredSuites: [
|
|
16203
|
+
"agent-harness-hardening",
|
|
16204
|
+
"agent-harness-runtime-e2e",
|
|
16205
|
+
"agent-production-readiness-e2e"
|
|
16206
|
+
],
|
|
16207
|
+
criticalBuckets: [
|
|
16208
|
+
"relationship-traversal",
|
|
16209
|
+
"cross-turn-reference",
|
|
16210
|
+
"ambiguous-target-choice",
|
|
16211
|
+
"confirmation-gated-mutation",
|
|
16212
|
+
"denied-action-refusal",
|
|
16213
|
+
"mutation-presentation"
|
|
16214
|
+
],
|
|
16215
|
+
maxRegressionPct: 0,
|
|
16216
|
+
minPassK: {
|
|
16217
|
+
"critical-mutation": 0.9,
|
|
16218
|
+
"permission-boundary": 1
|
|
16219
|
+
}
|
|
16220
|
+
}
|
|
16221
|
+
};
|
|
16222
|
+
|
|
16082
16223
|
// src/agent-harness.ts
|
|
16224
|
+
var HARNESS_TEMPLATE_STATUSES = [
|
|
16225
|
+
"draft",
|
|
16226
|
+
"candidate",
|
|
16227
|
+
"release-candidate",
|
|
16228
|
+
"stable",
|
|
16229
|
+
"deprecated"
|
|
16230
|
+
];
|
|
16231
|
+
function requireRecord(value, context) {
|
|
16232
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
16233
|
+
throw new Error(`${context} must be an object.`);
|
|
16234
|
+
}
|
|
16235
|
+
return value;
|
|
16236
|
+
}
|
|
16237
|
+
function requiredString(record, key, context) {
|
|
16238
|
+
const value = record[key];
|
|
16239
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
16240
|
+
throw new Error(`${context}.${key} must be a non-empty string.`);
|
|
16241
|
+
}
|
|
16242
|
+
return value;
|
|
16243
|
+
}
|
|
16244
|
+
function requiredNumber(record, key, context) {
|
|
16245
|
+
const value = record[key];
|
|
16246
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
16247
|
+
throw new Error(`${context}.${key} must be a finite number.`);
|
|
16248
|
+
}
|
|
16249
|
+
return value;
|
|
16250
|
+
}
|
|
16251
|
+
function requiredStringArray(record, key, context) {
|
|
16252
|
+
const value = record[key];
|
|
16253
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== "string" || !item.trim())) {
|
|
16254
|
+
throw new Error(`${context}.${key} must be an array of non-empty strings.`);
|
|
16255
|
+
}
|
|
16256
|
+
return [...value];
|
|
16257
|
+
}
|
|
16258
|
+
function requiredNumberRecord(record, key, context) {
|
|
16259
|
+
const value = requireRecord(record[key], `${context}.${key}`);
|
|
16260
|
+
const output = {};
|
|
16261
|
+
for (const [entryKey, entryValue] of Object.entries(value)) {
|
|
16262
|
+
if (typeof entryValue !== "number" || !Number.isFinite(entryValue) || entryValue < 0 || entryValue > 1) {
|
|
16263
|
+
throw new Error(
|
|
16264
|
+
`${context}.${key}.${entryKey} must be a number between 0 and 1.`
|
|
16265
|
+
);
|
|
16266
|
+
}
|
|
16267
|
+
output[entryKey] = entryValue;
|
|
16268
|
+
}
|
|
16269
|
+
return output;
|
|
16270
|
+
}
|
|
16271
|
+
function validateHarnessTemplateManifest(value, context = "HarnessTemplateManifest") {
|
|
16272
|
+
const record = requireRecord(value, context);
|
|
16273
|
+
const status = requiredString(record, "status", context);
|
|
16274
|
+
if (!HARNESS_TEMPLATE_STATUSES.includes(status)) {
|
|
16275
|
+
throw new Error(
|
|
16276
|
+
`${context}.status must be one of ${HARNESS_TEMPLATE_STATUSES.join(", ")}.`
|
|
16277
|
+
);
|
|
16278
|
+
}
|
|
16279
|
+
const createdAt = requiredString(record, "createdAt", context);
|
|
16280
|
+
if (Number.isNaN(Date.parse(createdAt))) {
|
|
16281
|
+
throw new Error(`${context}.createdAt must be an ISO timestamp.`);
|
|
16282
|
+
}
|
|
16283
|
+
const compatibility = requireRecord(
|
|
16284
|
+
record.compatibility,
|
|
16285
|
+
`${context}.compatibility`
|
|
16286
|
+
);
|
|
16287
|
+
const evalGates = requireRecord(record.evalGates, `${context}.evalGates`);
|
|
16288
|
+
const maxRegressionPct = requiredNumber(
|
|
16289
|
+
evalGates,
|
|
16290
|
+
"maxRegressionPct",
|
|
16291
|
+
`${context}.evalGates`
|
|
16292
|
+
);
|
|
16293
|
+
if (maxRegressionPct < 0 || maxRegressionPct > 1) {
|
|
16294
|
+
throw new Error(
|
|
16295
|
+
`${context}.evalGates.maxRegressionPct must be between 0 and 1.`
|
|
16296
|
+
);
|
|
16297
|
+
}
|
|
16298
|
+
return {
|
|
16299
|
+
id: requiredString(record, "id", context),
|
|
16300
|
+
version: requiredString(record, "version", context),
|
|
16301
|
+
status,
|
|
16302
|
+
owner: requiredString(record, "owner", context),
|
|
16303
|
+
createdAt,
|
|
16304
|
+
changelog: requiredString(record, "changelog", context),
|
|
16305
|
+
promptBuilder: requiredString(record, "promptBuilder", context),
|
|
16306
|
+
continuationBuilder: requiredString(record, "continuationBuilder", context),
|
|
16307
|
+
modelOutputInstruction: requiredString(
|
|
16308
|
+
record,
|
|
16309
|
+
"modelOutputInstruction",
|
|
16310
|
+
context
|
|
16311
|
+
),
|
|
16312
|
+
codeReviewPolicy: requiredString(record, "codeReviewPolicy", context),
|
|
16313
|
+
defaultModel: requiredString(record, "defaultModel", context),
|
|
16314
|
+
modelMatrix: requiredStringArray(record, "modelMatrix", context),
|
|
16315
|
+
temperature: requiredNumber(record, "temperature", context),
|
|
16316
|
+
compatibility: {
|
|
16317
|
+
minSdkVersion: requiredString(
|
|
16318
|
+
compatibility,
|
|
16319
|
+
"minSdkVersion",
|
|
16320
|
+
`${context}.compatibility`
|
|
16321
|
+
),
|
|
16322
|
+
capabilities: requiredStringArray(
|
|
16323
|
+
compatibility,
|
|
16324
|
+
"capabilities",
|
|
16325
|
+
`${context}.compatibility`
|
|
16326
|
+
)
|
|
16327
|
+
},
|
|
16328
|
+
evalGates: {
|
|
16329
|
+
requiredSuites: requiredStringArray(
|
|
16330
|
+
evalGates,
|
|
16331
|
+
"requiredSuites",
|
|
16332
|
+
`${context}.evalGates`
|
|
16333
|
+
),
|
|
16334
|
+
criticalBuckets: requiredStringArray(
|
|
16335
|
+
evalGates,
|
|
16336
|
+
"criticalBuckets",
|
|
16337
|
+
`${context}.evalGates`
|
|
16338
|
+
),
|
|
16339
|
+
maxRegressionPct,
|
|
16340
|
+
minPassK: requiredNumberRecord(
|
|
16341
|
+
evalGates,
|
|
16342
|
+
"minPassK",
|
|
16343
|
+
`${context}.evalGates`
|
|
16344
|
+
)
|
|
16345
|
+
}
|
|
16346
|
+
};
|
|
16347
|
+
}
|
|
16348
|
+
function defineHarnessTemplateManifest(value, context) {
|
|
16349
|
+
return validateHarnessTemplateManifest(value, context);
|
|
16350
|
+
}
|
|
16083
16351
|
var DEFAULT_IGNORED_REASONING_COMMENT_DIRECTIVES = [
|
|
16084
16352
|
/^@ts-ignore\b/i,
|
|
16085
16353
|
/^@ts-expect-error\b/i,
|
|
@@ -16182,6 +16450,16 @@ function uniqueStrings(values, maxCount) {
|
|
|
16182
16450
|
}
|
|
16183
16451
|
return output;
|
|
16184
16452
|
}
|
|
16453
|
+
function stableStringify(value) {
|
|
16454
|
+
if (value === null || typeof value !== "object") {
|
|
16455
|
+
return JSON.stringify(value);
|
|
16456
|
+
}
|
|
16457
|
+
if (Array.isArray(value)) {
|
|
16458
|
+
return `[${value.map((entry) => stableStringify(entry)).join(",")}]`;
|
|
16459
|
+
}
|
|
16460
|
+
const record = value;
|
|
16461
|
+
return `{${Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${stableStringify(record[key])}`).join(",")}}`;
|
|
16462
|
+
}
|
|
16185
16463
|
function renderConstBlock(name, value) {
|
|
16186
16464
|
return `const ${name} = ${JSON.stringify(value, null, 2)} as const;`;
|
|
16187
16465
|
}
|
|
@@ -18126,6 +18404,194 @@ ${knownFactsBlock}
|
|
|
18126
18404
|
[Request]
|
|
18127
18405
|
${input.request?.trim() || "Use the latest user message in the conversation."}`;
|
|
18128
18406
|
}
|
|
18407
|
+
var STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST = defineHarnessTemplateManifest(
|
|
18408
|
+
manifest_default3,
|
|
18409
|
+
"stable@1.0.0 manifest"
|
|
18410
|
+
);
|
|
18411
|
+
function hashHarnessTemplateValue(value) {
|
|
18412
|
+
return hashString(stableStringify(value)) || "00000000";
|
|
18413
|
+
}
|
|
18414
|
+
function renderStableHarnessPrompt(input) {
|
|
18415
|
+
const prompt = buildGranularAgentSystemPrompt(input);
|
|
18416
|
+
const templateHash = hashHarnessTemplateValue(
|
|
18417
|
+
STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
18418
|
+
);
|
|
18419
|
+
return {
|
|
18420
|
+
templateId: STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
18421
|
+
templateVersion: STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
18422
|
+
templateHash,
|
|
18423
|
+
promptInstanceHash: hashHarnessTemplateValue({
|
|
18424
|
+
templateHash,
|
|
18425
|
+
input,
|
|
18426
|
+
prompt
|
|
18427
|
+
}),
|
|
18428
|
+
prompt
|
|
18429
|
+
};
|
|
18430
|
+
}
|
|
18431
|
+
function renderStableHarnessContinuation(resultPreview) {
|
|
18432
|
+
const instruction = buildContinuationInstruction(resultPreview);
|
|
18433
|
+
const templateHash = hashHarnessTemplateValue(
|
|
18434
|
+
STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
18435
|
+
);
|
|
18436
|
+
return {
|
|
18437
|
+
templateId: STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
18438
|
+
templateVersion: STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
18439
|
+
templateHash,
|
|
18440
|
+
instruction
|
|
18441
|
+
};
|
|
18442
|
+
}
|
|
18443
|
+
var STABLE_AGENT_HARNESS_TEMPLATE = {
|
|
18444
|
+
manifest: STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST,
|
|
18445
|
+
renderPrompt: renderStableHarnessPrompt,
|
|
18446
|
+
renderContinuation: renderStableHarnessContinuation
|
|
18447
|
+
};
|
|
18448
|
+
var EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST = defineHarnessTemplateManifest(
|
|
18449
|
+
manifest_default2,
|
|
18450
|
+
"experimental-compact@0.1.0 manifest"
|
|
18451
|
+
);
|
|
18452
|
+
function renderExperimentalCompactHarnessPrompt(input) {
|
|
18453
|
+
const prompt = `${buildGranularAgentSystemPrompt(input)}
|
|
18454
|
+
|
|
18455
|
+
[Candidate Harness Delta: Compact Decision Discipline]
|
|
18456
|
+
- Prefer the smallest action that satisfies the current request.
|
|
18457
|
+
- When several records could match, ask one structured choice question before mutating.
|
|
18458
|
+
- Before any irreversible or outbound mutation, obtain explicit confirmation unless the policy surface already requires it.
|
|
18459
|
+
- Do not compensate for missing tools with raw network calls, synthetic records, or hidden side channels.
|
|
18460
|
+
- Keep the final user-facing reply focused on what was done, what was not done, and any remaining blocker.`;
|
|
18461
|
+
const templateHash = hashHarnessTemplateValue(
|
|
18462
|
+
EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
18463
|
+
);
|
|
18464
|
+
return {
|
|
18465
|
+
templateId: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
18466
|
+
templateVersion: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
18467
|
+
templateHash,
|
|
18468
|
+
promptInstanceHash: hashHarnessTemplateValue({
|
|
18469
|
+
templateHash,
|
|
18470
|
+
input,
|
|
18471
|
+
prompt
|
|
18472
|
+
}),
|
|
18473
|
+
prompt
|
|
18474
|
+
};
|
|
18475
|
+
}
|
|
18476
|
+
function renderExperimentalCompactHarnessContinuation(resultPreview) {
|
|
18477
|
+
const instruction = `${buildContinuationInstruction(resultPreview)}
|
|
18478
|
+
|
|
18479
|
+
Keep the continuation compact: either finish, ask the one blocking question, or run the next smallest safe action.`;
|
|
18480
|
+
const templateHash = hashHarnessTemplateValue(
|
|
18481
|
+
EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
18482
|
+
);
|
|
18483
|
+
return {
|
|
18484
|
+
templateId: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
18485
|
+
templateVersion: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
18486
|
+
templateHash,
|
|
18487
|
+
instruction
|
|
18488
|
+
};
|
|
18489
|
+
}
|
|
18490
|
+
var EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE = {
|
|
18491
|
+
manifest: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST,
|
|
18492
|
+
renderPrompt: renderExperimentalCompactHarnessPrompt,
|
|
18493
|
+
renderContinuation: renderExperimentalCompactHarnessContinuation
|
|
18494
|
+
};
|
|
18495
|
+
var ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST = defineHarnessTemplateManifest(
|
|
18496
|
+
manifest_default,
|
|
18497
|
+
"action-presentation@0.1.0 manifest"
|
|
18498
|
+
);
|
|
18499
|
+
function renderActionPresentationHarnessPrompt(input) {
|
|
18500
|
+
const prompt = `${buildGranularAgentSystemPrompt(input)}
|
|
18501
|
+
|
|
18502
|
+
[Candidate Harness Delta: Action Request And Result Presentation]
|
|
18503
|
+
- 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.
|
|
18504
|
+
- 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.
|
|
18505
|
+
- 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.
|
|
18506
|
+
- After a mutation/effect call, base the reply on the returned action result and include a visible target label or identifier when one exists.
|
|
18507
|
+
- If no target can be grounded, say what was searched and what exact identifier or choice is needed; do not pretend the action completed.`;
|
|
18508
|
+
const templateHash = hashHarnessTemplateValue(
|
|
18509
|
+
ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
18510
|
+
);
|
|
18511
|
+
return {
|
|
18512
|
+
templateId: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
18513
|
+
templateVersion: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
18514
|
+
templateHash,
|
|
18515
|
+
promptInstanceHash: hashHarnessTemplateValue({
|
|
18516
|
+
templateHash,
|
|
18517
|
+
input,
|
|
18518
|
+
prompt
|
|
18519
|
+
}),
|
|
18520
|
+
prompt
|
|
18521
|
+
};
|
|
18522
|
+
}
|
|
18523
|
+
function renderActionPresentationHarnessContinuation(resultPreview) {
|
|
18524
|
+
const instruction = `${buildContinuationInstruction(resultPreview)}
|
|
18525
|
+
|
|
18526
|
+
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.`;
|
|
18527
|
+
const templateHash = hashHarnessTemplateValue(
|
|
18528
|
+
ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
18529
|
+
);
|
|
18530
|
+
return {
|
|
18531
|
+
templateId: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
18532
|
+
templateVersion: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
18533
|
+
templateHash,
|
|
18534
|
+
instruction
|
|
18535
|
+
};
|
|
18536
|
+
}
|
|
18537
|
+
var ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE = {
|
|
18538
|
+
manifest: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST,
|
|
18539
|
+
renderPrompt: renderActionPresentationHarnessPrompt,
|
|
18540
|
+
renderContinuation: renderActionPresentationHarnessContinuation
|
|
18541
|
+
};
|
|
18542
|
+
var AGENT_HARNESS_TEMPLATES = {
|
|
18543
|
+
[STABLE_AGENT_HARNESS_TEMPLATE.manifest.id]: STABLE_AGENT_HARNESS_TEMPLATE,
|
|
18544
|
+
[EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE.manifest.id]: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE,
|
|
18545
|
+
[ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE.manifest.id]: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE
|
|
18546
|
+
};
|
|
18547
|
+
function listHarnessTemplates() {
|
|
18548
|
+
return Object.values(AGENT_HARNESS_TEMPLATES).map((template) => ({
|
|
18549
|
+
...template.manifest,
|
|
18550
|
+
compatibility: { ...template.manifest.compatibility },
|
|
18551
|
+
evalGates: {
|
|
18552
|
+
...template.manifest.evalGates,
|
|
18553
|
+
minPassK: { ...template.manifest.evalGates.minPassK }
|
|
18554
|
+
}
|
|
18555
|
+
}));
|
|
18556
|
+
}
|
|
18557
|
+
function resolveHarnessTemplate(templateId = "stable", options) {
|
|
18558
|
+
const resolved = AGENT_HARNESS_TEMPLATES[templateId];
|
|
18559
|
+
if (resolved) return resolved;
|
|
18560
|
+
if (options?.strict) {
|
|
18561
|
+
const known = Object.keys(AGENT_HARNESS_TEMPLATES).join(", ");
|
|
18562
|
+
throw new Error(
|
|
18563
|
+
`Unknown harness template "${templateId}". Known templates: ${known}`
|
|
18564
|
+
);
|
|
18565
|
+
}
|
|
18566
|
+
return STABLE_AGENT_HARNESS_TEMPLATE;
|
|
18567
|
+
}
|
|
18568
|
+
function getDefaultHarnessTemplateId() {
|
|
18569
|
+
if (typeof process !== "undefined") {
|
|
18570
|
+
const configured = process.env.GRANULAR_AGENT_HARNESS_TEMPLATE || process.env.NEXT_PUBLIC_GRANULAR_AGENT_HARNESS_TEMPLATE;
|
|
18571
|
+
if (configured?.trim()) return configured.trim();
|
|
18572
|
+
}
|
|
18573
|
+
return "stable";
|
|
18574
|
+
}
|
|
18575
|
+
function renderGranularAgentSystemPromptFromTemplate(input, options) {
|
|
18576
|
+
const template = resolveHarnessTemplate(
|
|
18577
|
+
options?.templateId || getDefaultHarnessTemplateId(),
|
|
18578
|
+
{ strict: options?.strict ?? true }
|
|
18579
|
+
);
|
|
18580
|
+
return template.renderPrompt(input);
|
|
18581
|
+
}
|
|
18582
|
+
function buildGranularAgentSystemPromptFromTemplate(input, options) {
|
|
18583
|
+
return renderGranularAgentSystemPromptFromTemplate(input, options).prompt;
|
|
18584
|
+
}
|
|
18585
|
+
function renderContinuationInstructionFromTemplate(resultPreview, options) {
|
|
18586
|
+
const template = resolveHarnessTemplate(
|
|
18587
|
+
options?.templateId || getDefaultHarnessTemplateId(),
|
|
18588
|
+
{ strict: options?.strict ?? true }
|
|
18589
|
+
);
|
|
18590
|
+
return template.renderContinuation(resultPreview);
|
|
18591
|
+
}
|
|
18592
|
+
function buildContinuationInstructionFromTemplate(resultPreview, options) {
|
|
18593
|
+
return renderContinuationInstructionFromTemplate(resultPreview, options).instruction;
|
|
18594
|
+
}
|
|
18129
18595
|
|
|
18130
18596
|
// src/openai-usage.ts
|
|
18131
18597
|
var OPENAI_PRICING_SOURCE_URL = "https://developers.openai.com/api/docs/models/gpt-5.4/";
|
|
@@ -18230,6 +18696,7 @@ exports.OntologyHandle = OntologyHandle;
|
|
|
18230
18696
|
exports.Session = Session;
|
|
18231
18697
|
exports.WSClient = WSClient;
|
|
18232
18698
|
exports.buildContinuationInstruction = buildContinuationInstruction;
|
|
18699
|
+
exports.buildContinuationInstructionFromTemplate = buildContinuationInstructionFromTemplate;
|
|
18233
18700
|
exports.buildGranularAgentCheckpointBlock = buildGranularAgentCheckpointBlock;
|
|
18234
18701
|
exports.buildGranularAgentDomainBlock = buildGranularAgentDomainBlock;
|
|
18235
18702
|
exports.buildGranularAgentFileBlock = buildGranularAgentFileBlock;
|
|
@@ -18239,6 +18706,7 @@ exports.buildGranularAgentReferentBlock = buildGranularAgentReferentBlock;
|
|
|
18239
18706
|
exports.buildGranularAgentRuntimeImportsBlock = buildGranularAgentRuntimeImportsBlock;
|
|
18240
18707
|
exports.buildGranularAgentSessionBlock = buildGranularAgentSessionBlock;
|
|
18241
18708
|
exports.buildGranularAgentSystemPrompt = buildGranularAgentSystemPrompt;
|
|
18709
|
+
exports.buildGranularAgentSystemPromptFromTemplate = buildGranularAgentSystemPromptFromTemplate;
|
|
18242
18710
|
exports.buildGranularAgentToolBlock = buildGranularAgentToolBlock;
|
|
18243
18711
|
exports.buildGranularAgentWorkflowBlock = buildGranularAgentWorkflowBlock;
|
|
18244
18712
|
exports.buildOpenAISpendEventId = buildOpenAISpendEventId;
|
|
@@ -18250,11 +18718,14 @@ exports.createHarnessVerifierSnapshot = createHarnessVerifierSnapshot;
|
|
|
18250
18718
|
exports.evaluateContinuation = evaluateContinuation;
|
|
18251
18719
|
exports.extractPromptTokens = extractPromptTokens;
|
|
18252
18720
|
exports.getCurrentClosureId = getCurrentClosureId;
|
|
18721
|
+
exports.getDefaultHarnessTemplateId = getDefaultHarnessTemplateId;
|
|
18253
18722
|
exports.getExclusivePromptTarget = getExclusivePromptTarget;
|
|
18254
18723
|
exports.getOpenAIModelPricing = getOpenAIModelPricing;
|
|
18255
18724
|
exports.hasOpenPrompt = hasOpenPrompt;
|
|
18725
|
+
exports.hashHarnessTemplateValue = hashHarnessTemplateValue;
|
|
18256
18726
|
exports.invokeRegisteredEffect = invokeRegisteredEffect;
|
|
18257
18727
|
exports.isLocalApiUrl = isLocalApiUrl;
|
|
18728
|
+
exports.listHarnessTemplates = listHarnessTemplates;
|
|
18258
18729
|
exports.normalizeEffectBehaviors = normalizeEffectBehaviors;
|
|
18259
18730
|
exports.normalizeOpenAIUsage = normalizeOpenAIUsage;
|
|
18260
18731
|
exports.normalizePrompt = normalizePrompt;
|
|
@@ -18269,13 +18740,17 @@ exports.projectSessionFileSummary = projectSessionFileSummary;
|
|
|
18269
18740
|
exports.projectWorkflowFocus = projectWorkflowFocus;
|
|
18270
18741
|
exports.projectWorkflowSummary = projectWorkflowSummary;
|
|
18271
18742
|
exports.recordOpenAIUsageSpend = recordOpenAIUsageSpend;
|
|
18743
|
+
exports.renderContinuationInstructionFromTemplate = renderContinuationInstructionFromTemplate;
|
|
18744
|
+
exports.renderGranularAgentSystemPromptFromTemplate = renderGranularAgentSystemPromptFromTemplate;
|
|
18272
18745
|
exports.resolveApiUrl = resolveApiUrl;
|
|
18273
18746
|
exports.resolveAuthTokenForApiUrl = resolveAuthTokenForApiUrl;
|
|
18747
|
+
exports.resolveHarnessTemplate = resolveHarnessTemplate;
|
|
18274
18748
|
exports.resolveJobPresentation = resolveJobPresentation;
|
|
18275
18749
|
exports.resolvePromptAnswer = resolvePromptAnswer;
|
|
18276
18750
|
exports.reviewGeneratedJobCode = reviewGeneratedJobCode;
|
|
18277
18751
|
exports.scorePromptChoiceMatch = scorePromptChoiceMatch;
|
|
18278
18752
|
exports.stripGranularReasoningTrace = stripGranularReasoningTrace;
|
|
18279
18753
|
exports.toGranularHttpBase = toGranularHttpBase;
|
|
18754
|
+
exports.validateHarnessTemplateManifest = validateHarnessTemplateManifest;
|
|
18280
18755
|
//# sourceMappingURL=index.js.map
|
|
18281
18756
|
//# sourceMappingURL=index.js.map
|