@granular-software/sdk 0.4.41 → 0.4.43
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 +1197 -79
- package/dist/agent-evals.js.map +1 -1
- package/dist/agent-evals.mjs +1197 -81
- 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 +597 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +589 -54
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -159,9 +159,9 @@ var require_node_gyp_build = __commonJS({
|
|
|
159
159
|
}
|
|
160
160
|
function parseTags(file) {
|
|
161
161
|
var arr = file.split(".");
|
|
162
|
-
var
|
|
162
|
+
var extension2 = arr.pop();
|
|
163
163
|
var tags = { file, specificity: 0 };
|
|
164
|
-
if (
|
|
164
|
+
if (extension2 !== "node") return;
|
|
165
165
|
for (var i = 0; i < arr.length; i++) {
|
|
166
166
|
var tag = arr[i];
|
|
167
167
|
if (tag === "node" || tag === "electron" || tag === "node-webkit") {
|
|
@@ -409,7 +409,7 @@ var require_permessage_deflate = __commonJS({
|
|
|
409
409
|
var kBuffers = Symbol("buffers");
|
|
410
410
|
var kError = Symbol("error");
|
|
411
411
|
var zlibLimiter;
|
|
412
|
-
var
|
|
412
|
+
var PerMessageDeflate2 = class {
|
|
413
413
|
/**
|
|
414
414
|
* Creates a PerMessageDeflate instance.
|
|
415
415
|
*
|
|
@@ -420,6 +420,9 @@ var require_permessage_deflate = __commonJS({
|
|
|
420
420
|
* acknowledge disabling of client context takeover
|
|
421
421
|
* @param {Number} [options.concurrencyLimit=10] The number of concurrent
|
|
422
422
|
* calls to zlib
|
|
423
|
+
* @param {Boolean} [options.isServer=false] Create the instance in either
|
|
424
|
+
* server or client mode
|
|
425
|
+
* @param {Number} [options.maxPayload=0] The maximum allowed message length
|
|
423
426
|
* @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
|
|
424
427
|
* use of a custom server window size
|
|
425
428
|
* @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
|
|
@@ -430,15 +433,12 @@ var require_permessage_deflate = __commonJS({
|
|
|
430
433
|
* deflate
|
|
431
434
|
* @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
|
|
432
435
|
* inflate
|
|
433
|
-
* @param {Boolean} [isServer=false] Create the instance in either server or
|
|
434
|
-
* client mode
|
|
435
|
-
* @param {Number} [maxPayload=0] The maximum allowed message length
|
|
436
436
|
*/
|
|
437
|
-
constructor(options
|
|
438
|
-
this._maxPayload = maxPayload | 0;
|
|
437
|
+
constructor(options) {
|
|
439
438
|
this._options = options || {};
|
|
440
439
|
this._threshold = this._options.threshold !== void 0 ? this._options.threshold : 1024;
|
|
441
|
-
this.
|
|
440
|
+
this._maxPayload = this._options.maxPayload | 0;
|
|
441
|
+
this._isServer = !!this._options.isServer;
|
|
442
442
|
this._deflate = null;
|
|
443
443
|
this._inflate = null;
|
|
444
444
|
this.params = null;
|
|
@@ -747,7 +747,7 @@ var require_permessage_deflate = __commonJS({
|
|
|
747
747
|
});
|
|
748
748
|
}
|
|
749
749
|
};
|
|
750
|
-
module.exports =
|
|
750
|
+
module.exports = PerMessageDeflate2;
|
|
751
751
|
function deflateOnData(chunk) {
|
|
752
752
|
this[kBuffers].push(chunk);
|
|
753
753
|
this[kTotalLength] += chunk.length;
|
|
@@ -1027,7 +1027,7 @@ var require_validation = __commonJS({
|
|
|
1027
1027
|
var require_receiver = __commonJS({
|
|
1028
1028
|
"../../node_modules/ws/lib/receiver.js"(exports, module) {
|
|
1029
1029
|
var { Writable } = __require("stream");
|
|
1030
|
-
var
|
|
1030
|
+
var PerMessageDeflate2 = require_permessage_deflate();
|
|
1031
1031
|
var {
|
|
1032
1032
|
BINARY_TYPES,
|
|
1033
1033
|
EMPTY_BUFFER,
|
|
@@ -1057,6 +1057,10 @@ var require_receiver = __commonJS({
|
|
|
1057
1057
|
* extensions
|
|
1058
1058
|
* @param {Boolean} [options.isServer=false] Specifies whether to operate in
|
|
1059
1059
|
* client or server mode
|
|
1060
|
+
* @param {Number} [options.maxBufferedChunks=0] The maximum number of
|
|
1061
|
+
* buffered data chunks
|
|
1062
|
+
* @param {Number} [options.maxFragments=0] The maximum number of message
|
|
1063
|
+
* fragments
|
|
1060
1064
|
* @param {Number} [options.maxPayload=0] The maximum allowed message length
|
|
1061
1065
|
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
|
1062
1066
|
* not to skip UTF-8 validation for text and close messages
|
|
@@ -1067,6 +1071,8 @@ var require_receiver = __commonJS({
|
|
|
1067
1071
|
this._binaryType = options.binaryType || BINARY_TYPES[0];
|
|
1068
1072
|
this._extensions = options.extensions || {};
|
|
1069
1073
|
this._isServer = !!options.isServer;
|
|
1074
|
+
this._maxBufferedChunks = options.maxBufferedChunks | 0;
|
|
1075
|
+
this._maxFragments = options.maxFragments | 0;
|
|
1070
1076
|
this._maxPayload = options.maxPayload | 0;
|
|
1071
1077
|
this._skipUTF8Validation = !!options.skipUTF8Validation;
|
|
1072
1078
|
this[kWebSocket] = void 0;
|
|
@@ -1096,6 +1102,18 @@ var require_receiver = __commonJS({
|
|
|
1096
1102
|
*/
|
|
1097
1103
|
_write(chunk, encoding, cb) {
|
|
1098
1104
|
if (this._opcode === 8 && this._state == GET_INFO) return cb();
|
|
1105
|
+
if (this._maxBufferedChunks > 0 && this._buffers.length >= this._maxBufferedChunks) {
|
|
1106
|
+
cb(
|
|
1107
|
+
this.createError(
|
|
1108
|
+
RangeError,
|
|
1109
|
+
"Too many buffered chunks",
|
|
1110
|
+
false,
|
|
1111
|
+
1008,
|
|
1112
|
+
"WS_ERR_TOO_MANY_BUFFERED_PARTS"
|
|
1113
|
+
)
|
|
1114
|
+
);
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1099
1117
|
this._bufferedBytes += chunk.length;
|
|
1100
1118
|
this._buffers.push(chunk);
|
|
1101
1119
|
this.startLoop(cb);
|
|
@@ -1194,7 +1212,7 @@ var require_receiver = __commonJS({
|
|
|
1194
1212
|
return;
|
|
1195
1213
|
}
|
|
1196
1214
|
const compressed = (buf[0] & 64) === 64;
|
|
1197
|
-
if (compressed && !this._extensions[
|
|
1215
|
+
if (compressed && !this._extensions[PerMessageDeflate2.extensionName]) {
|
|
1198
1216
|
const error = this.createError(
|
|
1199
1217
|
RangeError,
|
|
1200
1218
|
"RSV1 must be clear",
|
|
@@ -1425,6 +1443,17 @@ var require_receiver = __commonJS({
|
|
|
1425
1443
|
return;
|
|
1426
1444
|
}
|
|
1427
1445
|
if (data.length) {
|
|
1446
|
+
if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
|
|
1447
|
+
const error = this.createError(
|
|
1448
|
+
RangeError,
|
|
1449
|
+
"Too many message fragments",
|
|
1450
|
+
false,
|
|
1451
|
+
1008,
|
|
1452
|
+
"WS_ERR_TOO_MANY_BUFFERED_PARTS"
|
|
1453
|
+
);
|
|
1454
|
+
cb(error);
|
|
1455
|
+
return;
|
|
1456
|
+
}
|
|
1428
1457
|
this._messageLength = this._totalPayloadLength;
|
|
1429
1458
|
this._fragments.push(data);
|
|
1430
1459
|
}
|
|
@@ -1438,7 +1467,7 @@ var require_receiver = __commonJS({
|
|
|
1438
1467
|
* @private
|
|
1439
1468
|
*/
|
|
1440
1469
|
decompress(data, cb) {
|
|
1441
|
-
const perMessageDeflate = this._extensions[
|
|
1470
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
|
|
1442
1471
|
perMessageDeflate.decompress(data, this._fin, (err, buf) => {
|
|
1443
1472
|
if (err) return cb(err);
|
|
1444
1473
|
if (buf.length) {
|
|
@@ -1454,6 +1483,17 @@ var require_receiver = __commonJS({
|
|
|
1454
1483
|
cb(error);
|
|
1455
1484
|
return;
|
|
1456
1485
|
}
|
|
1486
|
+
if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
|
|
1487
|
+
const error = this.createError(
|
|
1488
|
+
RangeError,
|
|
1489
|
+
"Too many message fragments",
|
|
1490
|
+
false,
|
|
1491
|
+
1008,
|
|
1492
|
+
"WS_ERR_TOO_MANY_BUFFERED_PARTS"
|
|
1493
|
+
);
|
|
1494
|
+
cb(error);
|
|
1495
|
+
return;
|
|
1496
|
+
}
|
|
1457
1497
|
this._fragments.push(buf);
|
|
1458
1498
|
}
|
|
1459
1499
|
this.dataMessage(cb);
|
|
@@ -1619,7 +1659,10 @@ var require_sender = __commonJS({
|
|
|
1619
1659
|
"../../node_modules/ws/lib/sender.js"(exports, module) {
|
|
1620
1660
|
var { Duplex } = __require("stream");
|
|
1621
1661
|
var { randomFillSync } = __require("crypto");
|
|
1622
|
-
var
|
|
1662
|
+
var {
|
|
1663
|
+
types: { isUint8Array }
|
|
1664
|
+
} = __require("util");
|
|
1665
|
+
var PerMessageDeflate2 = require_permessage_deflate();
|
|
1623
1666
|
var { EMPTY_BUFFER, kWebSocket, NOOP } = require_constants();
|
|
1624
1667
|
var { isBlob, isValidStatusCode } = require_validation();
|
|
1625
1668
|
var { mask: applyMask, toBuffer } = require_buffer_util();
|
|
@@ -1772,8 +1815,10 @@ var require_sender = __commonJS({
|
|
|
1772
1815
|
buf.writeUInt16BE(code, 0);
|
|
1773
1816
|
if (typeof data === "string") {
|
|
1774
1817
|
buf.write(data, 2);
|
|
1775
|
-
} else {
|
|
1818
|
+
} else if (isUint8Array(data)) {
|
|
1776
1819
|
buf.set(data, 2);
|
|
1820
|
+
} else {
|
|
1821
|
+
throw new TypeError("Second argument must be a string or a Uint8Array");
|
|
1777
1822
|
}
|
|
1778
1823
|
}
|
|
1779
1824
|
const options = {
|
|
@@ -1903,7 +1948,7 @@ var require_sender = __commonJS({
|
|
|
1903
1948
|
* @public
|
|
1904
1949
|
*/
|
|
1905
1950
|
send(data, options, cb) {
|
|
1906
|
-
const perMessageDeflate = this._extensions[
|
|
1951
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
|
|
1907
1952
|
let opcode = options.binary ? 2 : 1;
|
|
1908
1953
|
let rsv1 = options.compress;
|
|
1909
1954
|
let byteLength;
|
|
@@ -2027,7 +2072,7 @@ var require_sender = __commonJS({
|
|
|
2027
2072
|
this.sendFrame(_Sender.frame(data, options), cb);
|
|
2028
2073
|
return;
|
|
2029
2074
|
}
|
|
2030
|
-
const perMessageDeflate = this._extensions[
|
|
2075
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
|
|
2031
2076
|
this._bufferedBytes += options[kByteLength];
|
|
2032
2077
|
this._state = DEFLATING;
|
|
2033
2078
|
perMessageDeflate.compress(data, options.fin, (_, buf) => {
|
|
@@ -2463,11 +2508,11 @@ var require_extension = __commonJS({
|
|
|
2463
2508
|
return offers;
|
|
2464
2509
|
}
|
|
2465
2510
|
function format(extensions) {
|
|
2466
|
-
return Object.keys(extensions).map((
|
|
2467
|
-
let configurations = extensions[
|
|
2511
|
+
return Object.keys(extensions).map((extension2) => {
|
|
2512
|
+
let configurations = extensions[extension2];
|
|
2468
2513
|
if (!Array.isArray(configurations)) configurations = [configurations];
|
|
2469
2514
|
return configurations.map((params) => {
|
|
2470
|
-
return [
|
|
2515
|
+
return [extension2].concat(
|
|
2471
2516
|
Object.keys(params).map((k) => {
|
|
2472
2517
|
let values = params[k];
|
|
2473
2518
|
if (!Array.isArray(values)) values = [values];
|
|
@@ -2492,7 +2537,7 @@ var require_websocket = __commonJS({
|
|
|
2492
2537
|
var { randomBytes, createHash } = __require("crypto");
|
|
2493
2538
|
var { Duplex, Readable } = __require("stream");
|
|
2494
2539
|
var { URL: URL2 } = __require("url");
|
|
2495
|
-
var
|
|
2540
|
+
var PerMessageDeflate2 = require_permessage_deflate();
|
|
2496
2541
|
var Receiver2 = require_receiver();
|
|
2497
2542
|
var Sender2 = require_sender();
|
|
2498
2543
|
var { isBlob } = require_validation();
|
|
@@ -2651,6 +2696,10 @@ var require_websocket = __commonJS({
|
|
|
2651
2696
|
* multiple times in the same tick
|
|
2652
2697
|
* @param {Function} [options.generateMask] The function used to generate the
|
|
2653
2698
|
* masking key
|
|
2699
|
+
* @param {Number} [options.maxBufferedChunks=0] The maximum number of
|
|
2700
|
+
* buffered data chunks
|
|
2701
|
+
* @param {Number} [options.maxFragments=0] The maximum number of message
|
|
2702
|
+
* fragments
|
|
2654
2703
|
* @param {Number} [options.maxPayload=0] The maximum allowed message size
|
|
2655
2704
|
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
|
2656
2705
|
* not to skip UTF-8 validation for text and close messages
|
|
@@ -2662,6 +2711,8 @@ var require_websocket = __commonJS({
|
|
|
2662
2711
|
binaryType: this.binaryType,
|
|
2663
2712
|
extensions: this._extensions,
|
|
2664
2713
|
isServer: this._isServer,
|
|
2714
|
+
maxBufferedChunks: options.maxBufferedChunks,
|
|
2715
|
+
maxFragments: options.maxFragments,
|
|
2665
2716
|
maxPayload: options.maxPayload,
|
|
2666
2717
|
skipUTF8Validation: options.skipUTF8Validation
|
|
2667
2718
|
});
|
|
@@ -2700,8 +2751,8 @@ var require_websocket = __commonJS({
|
|
|
2700
2751
|
this.emit("close", this._closeCode, this._closeMessage);
|
|
2701
2752
|
return;
|
|
2702
2753
|
}
|
|
2703
|
-
if (this._extensions[
|
|
2704
|
-
this._extensions[
|
|
2754
|
+
if (this._extensions[PerMessageDeflate2.extensionName]) {
|
|
2755
|
+
this._extensions[PerMessageDeflate2.extensionName].cleanup();
|
|
2705
2756
|
}
|
|
2706
2757
|
this._receiver.removeAllListeners();
|
|
2707
2758
|
this._readyState = _WebSocket.CLOSED;
|
|
@@ -2863,7 +2914,7 @@ var require_websocket = __commonJS({
|
|
|
2863
2914
|
fin: true,
|
|
2864
2915
|
...options
|
|
2865
2916
|
};
|
|
2866
|
-
if (!this._extensions[
|
|
2917
|
+
if (!this._extensions[PerMessageDeflate2.extensionName]) {
|
|
2867
2918
|
opts.compress = false;
|
|
2868
2919
|
}
|
|
2869
2920
|
this._sender.send(data || EMPTY_BUFFER, opts, cb);
|
|
@@ -2961,6 +3012,8 @@ var require_websocket = __commonJS({
|
|
|
2961
3012
|
autoPong: true,
|
|
2962
3013
|
closeTimeout: CLOSE_TIMEOUT,
|
|
2963
3014
|
protocolVersion: protocolVersions[1],
|
|
3015
|
+
maxBufferedChunks: 1024 * 1024,
|
|
3016
|
+
maxFragments: 128 * 1024,
|
|
2964
3017
|
maxPayload: 100 * 1024 * 1024,
|
|
2965
3018
|
skipUTF8Validation: false,
|
|
2966
3019
|
perMessageDeflate: true,
|
|
@@ -2989,7 +3042,7 @@ var require_websocket = __commonJS({
|
|
|
2989
3042
|
} else {
|
|
2990
3043
|
try {
|
|
2991
3044
|
parsedUrl = new URL2(address);
|
|
2992
|
-
} catch
|
|
3045
|
+
} catch {
|
|
2993
3046
|
throw new SyntaxError(`Invalid URL: ${address}`);
|
|
2994
3047
|
}
|
|
2995
3048
|
}
|
|
@@ -3037,13 +3090,13 @@ var require_websocket = __commonJS({
|
|
|
3037
3090
|
opts.path = parsedUrl.pathname + parsedUrl.search;
|
|
3038
3091
|
opts.timeout = opts.handshakeTimeout;
|
|
3039
3092
|
if (opts.perMessageDeflate) {
|
|
3040
|
-
perMessageDeflate = new
|
|
3041
|
-
opts.perMessageDeflate
|
|
3042
|
-
false,
|
|
3043
|
-
opts.maxPayload
|
|
3044
|
-
);
|
|
3093
|
+
perMessageDeflate = new PerMessageDeflate2({
|
|
3094
|
+
...opts.perMessageDeflate,
|
|
3095
|
+
isServer: false,
|
|
3096
|
+
maxPayload: opts.maxPayload
|
|
3097
|
+
});
|
|
3045
3098
|
opts.headers["Sec-WebSocket-Extensions"] = format({
|
|
3046
|
-
[
|
|
3099
|
+
[PerMessageDeflate2.extensionName]: perMessageDeflate.offer()
|
|
3047
3100
|
});
|
|
3048
3101
|
}
|
|
3049
3102
|
if (protocols.length) {
|
|
@@ -3186,23 +3239,25 @@ var require_websocket = __commonJS({
|
|
|
3186
3239
|
return;
|
|
3187
3240
|
}
|
|
3188
3241
|
const extensionNames = Object.keys(extensions);
|
|
3189
|
-
if (extensionNames.length !== 1 || extensionNames[0] !==
|
|
3242
|
+
if (extensionNames.length !== 1 || extensionNames[0] !== PerMessageDeflate2.extensionName) {
|
|
3190
3243
|
const message = "Server indicated an extension that was not requested";
|
|
3191
3244
|
abortHandshake(websocket, socket, message);
|
|
3192
3245
|
return;
|
|
3193
3246
|
}
|
|
3194
3247
|
try {
|
|
3195
|
-
perMessageDeflate.accept(extensions[
|
|
3248
|
+
perMessageDeflate.accept(extensions[PerMessageDeflate2.extensionName]);
|
|
3196
3249
|
} catch (err) {
|
|
3197
3250
|
const message = "Invalid Sec-WebSocket-Extensions header";
|
|
3198
3251
|
abortHandshake(websocket, socket, message);
|
|
3199
3252
|
return;
|
|
3200
3253
|
}
|
|
3201
|
-
websocket._extensions[
|
|
3254
|
+
websocket._extensions[PerMessageDeflate2.extensionName] = perMessageDeflate;
|
|
3202
3255
|
}
|
|
3203
3256
|
websocket.setSocket(socket, head, {
|
|
3204
3257
|
allowSynchronousEvents: opts.allowSynchronousEvents,
|
|
3205
3258
|
generateMask: opts.generateMask,
|
|
3259
|
+
maxBufferedChunks: opts.maxBufferedChunks,
|
|
3260
|
+
maxFragments: opts.maxFragments,
|
|
3206
3261
|
maxPayload: opts.maxPayload,
|
|
3207
3262
|
skipUTF8Validation: opts.skipUTF8Validation
|
|
3208
3263
|
});
|
|
@@ -3514,9 +3569,9 @@ var require_websocket_server = __commonJS({
|
|
|
3514
3569
|
var http = __require("http");
|
|
3515
3570
|
var { Duplex } = __require("stream");
|
|
3516
3571
|
var { createHash } = __require("crypto");
|
|
3517
|
-
var
|
|
3518
|
-
var
|
|
3519
|
-
var
|
|
3572
|
+
var extension2 = require_extension();
|
|
3573
|
+
var PerMessageDeflate2 = require_permessage_deflate();
|
|
3574
|
+
var subprotocol2 = require_subprotocol();
|
|
3520
3575
|
var WebSocket2 = require_websocket();
|
|
3521
3576
|
var { CLOSE_TIMEOUT, GUID, kWebSocket } = require_constants();
|
|
3522
3577
|
var keyRegex = /^[+/0-9A-Za-z]{22}==$/;
|
|
@@ -3542,6 +3597,10 @@ var require_websocket_server = __commonJS({
|
|
|
3542
3597
|
* called
|
|
3543
3598
|
* @param {Function} [options.handleProtocols] A hook to handle protocols
|
|
3544
3599
|
* @param {String} [options.host] The hostname where to bind the server
|
|
3600
|
+
* @param {Number} [options.maxBufferedChunks=1048576] The maximum number of
|
|
3601
|
+
* buffered data chunks
|
|
3602
|
+
* @param {Number} [options.maxFragments=131072] The maximum number of message
|
|
3603
|
+
* fragments
|
|
3545
3604
|
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
3546
3605
|
* size
|
|
3547
3606
|
* @param {Boolean} [options.noServer=false] Enable no server mode
|
|
@@ -3563,6 +3622,8 @@ var require_websocket_server = __commonJS({
|
|
|
3563
3622
|
options = {
|
|
3564
3623
|
allowSynchronousEvents: true,
|
|
3565
3624
|
autoPong: true,
|
|
3625
|
+
maxBufferedChunks: 1024 * 1024,
|
|
3626
|
+
maxFragments: 128 * 1024,
|
|
3566
3627
|
maxPayload: 100 * 1024 * 1024,
|
|
3567
3628
|
skipUTF8Validation: false,
|
|
3568
3629
|
perMessageDeflate: false,
|
|
@@ -3739,7 +3800,7 @@ var require_websocket_server = __commonJS({
|
|
|
3739
3800
|
let protocols = /* @__PURE__ */ new Set();
|
|
3740
3801
|
if (secWebSocketProtocol !== void 0) {
|
|
3741
3802
|
try {
|
|
3742
|
-
protocols =
|
|
3803
|
+
protocols = subprotocol2.parse(secWebSocketProtocol);
|
|
3743
3804
|
} catch (err) {
|
|
3744
3805
|
const message = "Invalid Sec-WebSocket-Protocol header";
|
|
3745
3806
|
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
@@ -3749,16 +3810,16 @@ var require_websocket_server = __commonJS({
|
|
|
3749
3810
|
const secWebSocketExtensions = req.headers["sec-websocket-extensions"];
|
|
3750
3811
|
const extensions = {};
|
|
3751
3812
|
if (this.options.perMessageDeflate && secWebSocketExtensions !== void 0) {
|
|
3752
|
-
const perMessageDeflate = new
|
|
3753
|
-
this.options.perMessageDeflate,
|
|
3754
|
-
true,
|
|
3755
|
-
this.options.maxPayload
|
|
3756
|
-
);
|
|
3813
|
+
const perMessageDeflate = new PerMessageDeflate2({
|
|
3814
|
+
...this.options.perMessageDeflate,
|
|
3815
|
+
isServer: true,
|
|
3816
|
+
maxPayload: this.options.maxPayload
|
|
3817
|
+
});
|
|
3757
3818
|
try {
|
|
3758
|
-
const offers =
|
|
3759
|
-
if (offers[
|
|
3760
|
-
perMessageDeflate.accept(offers[
|
|
3761
|
-
extensions[
|
|
3819
|
+
const offers = extension2.parse(secWebSocketExtensions);
|
|
3820
|
+
if (offers[PerMessageDeflate2.extensionName]) {
|
|
3821
|
+
perMessageDeflate.accept(offers[PerMessageDeflate2.extensionName]);
|
|
3822
|
+
extensions[PerMessageDeflate2.extensionName] = perMessageDeflate;
|
|
3762
3823
|
}
|
|
3763
3824
|
} catch (err) {
|
|
3764
3825
|
const message = "Invalid or unacceptable Sec-WebSocket-Extensions header";
|
|
@@ -3829,10 +3890,10 @@ var require_websocket_server = __commonJS({
|
|
|
3829
3890
|
ws._protocol = protocol;
|
|
3830
3891
|
}
|
|
3831
3892
|
}
|
|
3832
|
-
if (extensions[
|
|
3833
|
-
const params = extensions[
|
|
3834
|
-
const value =
|
|
3835
|
-
[
|
|
3893
|
+
if (extensions[PerMessageDeflate2.extensionName]) {
|
|
3894
|
+
const params = extensions[PerMessageDeflate2.extensionName].params;
|
|
3895
|
+
const value = extension2.format({
|
|
3896
|
+
[PerMessageDeflate2.extensionName]: [params]
|
|
3836
3897
|
});
|
|
3837
3898
|
headers.push(`Sec-WebSocket-Extensions: ${value}`);
|
|
3838
3899
|
ws._extensions = extensions;
|
|
@@ -3842,6 +3903,8 @@ var require_websocket_server = __commonJS({
|
|
|
3842
3903
|
socket.removeListener("error", socketOnError);
|
|
3843
3904
|
ws.setSocket(socket, head, {
|
|
3844
3905
|
allowSynchronousEvents: this.options.allowSynchronousEvents,
|
|
3906
|
+
maxBufferedChunks: this.options.maxBufferedChunks,
|
|
3907
|
+
maxFragments: this.options.maxFragments,
|
|
3845
3908
|
maxPayload: this.options.maxPayload,
|
|
3846
3909
|
skipUTF8Validation: this.options.skipUTF8Validation
|
|
3847
3910
|
});
|
|
@@ -3902,19 +3965,25 @@ var require_websocket_server = __commonJS({
|
|
|
3902
3965
|
// ../../node_modules/ws/wrapper.mjs
|
|
3903
3966
|
var wrapper_exports = {};
|
|
3904
3967
|
__export(wrapper_exports, {
|
|
3968
|
+
PerMessageDeflate: () => import_permessage_deflate.default,
|
|
3905
3969
|
Receiver: () => import_receiver.default,
|
|
3906
3970
|
Sender: () => import_sender.default,
|
|
3907
3971
|
WebSocket: () => import_websocket.default,
|
|
3908
3972
|
WebSocketServer: () => import_websocket_server.default,
|
|
3909
3973
|
createWebSocketStream: () => import_stream.default,
|
|
3910
|
-
default: () => wrapper_default
|
|
3974
|
+
default: () => wrapper_default,
|
|
3975
|
+
extension: () => import_extension.default,
|
|
3976
|
+
subprotocol: () => import_subprotocol.default
|
|
3911
3977
|
});
|
|
3912
|
-
var import_stream, import_receiver, import_sender, import_websocket, import_websocket_server, wrapper_default;
|
|
3978
|
+
var import_stream, import_extension, import_permessage_deflate, import_receiver, import_sender, import_subprotocol, import_websocket, import_websocket_server, wrapper_default;
|
|
3913
3979
|
var init_wrapper = __esm({
|
|
3914
3980
|
"../../node_modules/ws/wrapper.mjs"() {
|
|
3915
3981
|
import_stream = __toESM(require_stream());
|
|
3982
|
+
import_extension = __toESM(require_extension());
|
|
3983
|
+
import_permessage_deflate = __toESM(require_permessage_deflate());
|
|
3916
3984
|
import_receiver = __toESM(require_receiver());
|
|
3917
3985
|
import_sender = __toESM(require_sender());
|
|
3986
|
+
import_subprotocol = __toESM(require_subprotocol());
|
|
3918
3987
|
import_websocket = __toESM(require_websocket());
|
|
3919
3988
|
import_websocket_server = __toESM(require_websocket_server());
|
|
3920
3989
|
wrapper_default = import_websocket.default;
|
|
@@ -16057,7 +16126,275 @@ var Granular = class _Granular {
|
|
|
16057
16126
|
}
|
|
16058
16127
|
};
|
|
16059
16128
|
|
|
16129
|
+
// src/agent-harness-templates/action-presentation/0.1.0/manifest.json
|
|
16130
|
+
var manifest_default = {
|
|
16131
|
+
id: "action-presentation",
|
|
16132
|
+
version: "0.1.0",
|
|
16133
|
+
status: "candidate",
|
|
16134
|
+
owner: "granular",
|
|
16135
|
+
createdAt: "2026-05-25T00:00:00.000Z",
|
|
16136
|
+
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.",
|
|
16137
|
+
promptBuilder: "buildGranularAgentSystemPrompt:action-presentation",
|
|
16138
|
+
continuationBuilder: "buildContinuationInstruction:action-presentation",
|
|
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/experimental-compact/0.1.0/manifest.json
|
|
16177
|
+
var manifest_default2 = {
|
|
16178
|
+
id: "experimental-compact",
|
|
16179
|
+
version: "0.1.0",
|
|
16180
|
+
status: "candidate",
|
|
16181
|
+
owner: "granular",
|
|
16182
|
+
createdAt: "2026-05-24T00:00:00.000Z",
|
|
16183
|
+
changelog: "Candidate harness template used for champion/challenger testing. It adds a compact decision discipline section on top of the stable renderer.",
|
|
16184
|
+
promptBuilder: "buildGranularAgentSystemPrompt:experimental-compact",
|
|
16185
|
+
continuationBuilder: "buildContinuationInstruction:experimental-compact",
|
|
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
|
+
|
|
16223
|
+
// src/agent-harness-templates/stable/1.0.0/manifest.json
|
|
16224
|
+
var manifest_default3 = {
|
|
16225
|
+
id: "stable",
|
|
16226
|
+
version: "1.0.0",
|
|
16227
|
+
status: "stable",
|
|
16228
|
+
owner: "granular",
|
|
16229
|
+
createdAt: "2026-05-24T00:00:00.000Z",
|
|
16230
|
+
changelog: "Baseline template wrapping the existing Granular agent harness prompt, continuation instruction, output contract, and generated-job review policy.",
|
|
16231
|
+
promptBuilder: "buildGranularAgentSystemPrompt",
|
|
16232
|
+
continuationBuilder: "buildContinuationInstruction",
|
|
16233
|
+
modelOutputInstruction: "agent-evals:modelOutputInstruction",
|
|
16234
|
+
codeReviewPolicy: "reviewGeneratedJobCode",
|
|
16235
|
+
defaultModel: "gpt-5.4",
|
|
16236
|
+
modelMatrix: ["gpt-5.4"],
|
|
16237
|
+
temperature: 0,
|
|
16238
|
+
compatibility: {
|
|
16239
|
+
minSdkVersion: "0.4.40",
|
|
16240
|
+
capabilities: [
|
|
16241
|
+
"executeCode",
|
|
16242
|
+
"readEntities",
|
|
16243
|
+
"workflowHelpers",
|
|
16244
|
+
"savedData",
|
|
16245
|
+
"showRecords"
|
|
16246
|
+
]
|
|
16247
|
+
},
|
|
16248
|
+
evalGates: {
|
|
16249
|
+
requiredSuites: [
|
|
16250
|
+
"agent-harness-hardening",
|
|
16251
|
+
"agent-harness-runtime-e2e",
|
|
16252
|
+
"agent-production-readiness-e2e"
|
|
16253
|
+
],
|
|
16254
|
+
criticalBuckets: [
|
|
16255
|
+
"relationship-traversal",
|
|
16256
|
+
"cross-turn-reference",
|
|
16257
|
+
"ambiguous-target-choice",
|
|
16258
|
+
"confirmation-gated-mutation",
|
|
16259
|
+
"denied-action-refusal",
|
|
16260
|
+
"mutation-presentation"
|
|
16261
|
+
],
|
|
16262
|
+
maxRegressionPct: 0,
|
|
16263
|
+
minPassK: {
|
|
16264
|
+
"critical-mutation": 0.9,
|
|
16265
|
+
"permission-boundary": 1
|
|
16266
|
+
}
|
|
16267
|
+
}
|
|
16268
|
+
};
|
|
16269
|
+
|
|
16060
16270
|
// src/agent-harness.ts
|
|
16271
|
+
var HARNESS_TEMPLATE_STATUSES = [
|
|
16272
|
+
"draft",
|
|
16273
|
+
"candidate",
|
|
16274
|
+
"release-candidate",
|
|
16275
|
+
"stable",
|
|
16276
|
+
"deprecated"
|
|
16277
|
+
];
|
|
16278
|
+
function requireRecord(value, context) {
|
|
16279
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
16280
|
+
throw new Error(`${context} must be an object.`);
|
|
16281
|
+
}
|
|
16282
|
+
return value;
|
|
16283
|
+
}
|
|
16284
|
+
function requiredString(record, key, context) {
|
|
16285
|
+
const value = record[key];
|
|
16286
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
16287
|
+
throw new Error(`${context}.${key} must be a non-empty string.`);
|
|
16288
|
+
}
|
|
16289
|
+
return value;
|
|
16290
|
+
}
|
|
16291
|
+
function requiredNumber(record, key, context) {
|
|
16292
|
+
const value = record[key];
|
|
16293
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
16294
|
+
throw new Error(`${context}.${key} must be a finite number.`);
|
|
16295
|
+
}
|
|
16296
|
+
return value;
|
|
16297
|
+
}
|
|
16298
|
+
function requiredStringArray(record, key, context) {
|
|
16299
|
+
const value = record[key];
|
|
16300
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== "string" || !item.trim())) {
|
|
16301
|
+
throw new Error(`${context}.${key} must be an array of non-empty strings.`);
|
|
16302
|
+
}
|
|
16303
|
+
return [...value];
|
|
16304
|
+
}
|
|
16305
|
+
function requiredNumberRecord(record, key, context) {
|
|
16306
|
+
const value = requireRecord(record[key], `${context}.${key}`);
|
|
16307
|
+
const output = {};
|
|
16308
|
+
for (const [entryKey, entryValue] of Object.entries(value)) {
|
|
16309
|
+
if (typeof entryValue !== "number" || !Number.isFinite(entryValue) || entryValue < 0 || entryValue > 1) {
|
|
16310
|
+
throw new Error(
|
|
16311
|
+
`${context}.${key}.${entryKey} must be a number between 0 and 1.`
|
|
16312
|
+
);
|
|
16313
|
+
}
|
|
16314
|
+
output[entryKey] = entryValue;
|
|
16315
|
+
}
|
|
16316
|
+
return output;
|
|
16317
|
+
}
|
|
16318
|
+
function validateHarnessTemplateManifest(value, context = "HarnessTemplateManifest") {
|
|
16319
|
+
const record = requireRecord(value, context);
|
|
16320
|
+
const status = requiredString(record, "status", context);
|
|
16321
|
+
if (!HARNESS_TEMPLATE_STATUSES.includes(status)) {
|
|
16322
|
+
throw new Error(
|
|
16323
|
+
`${context}.status must be one of ${HARNESS_TEMPLATE_STATUSES.join(", ")}.`
|
|
16324
|
+
);
|
|
16325
|
+
}
|
|
16326
|
+
const createdAt = requiredString(record, "createdAt", context);
|
|
16327
|
+
if (Number.isNaN(Date.parse(createdAt))) {
|
|
16328
|
+
throw new Error(`${context}.createdAt must be an ISO timestamp.`);
|
|
16329
|
+
}
|
|
16330
|
+
const compatibility = requireRecord(
|
|
16331
|
+
record.compatibility,
|
|
16332
|
+
`${context}.compatibility`
|
|
16333
|
+
);
|
|
16334
|
+
const evalGates = requireRecord(record.evalGates, `${context}.evalGates`);
|
|
16335
|
+
const maxRegressionPct = requiredNumber(
|
|
16336
|
+
evalGates,
|
|
16337
|
+
"maxRegressionPct",
|
|
16338
|
+
`${context}.evalGates`
|
|
16339
|
+
);
|
|
16340
|
+
if (maxRegressionPct < 0 || maxRegressionPct > 1) {
|
|
16341
|
+
throw new Error(
|
|
16342
|
+
`${context}.evalGates.maxRegressionPct must be between 0 and 1.`
|
|
16343
|
+
);
|
|
16344
|
+
}
|
|
16345
|
+
return {
|
|
16346
|
+
id: requiredString(record, "id", context),
|
|
16347
|
+
version: requiredString(record, "version", context),
|
|
16348
|
+
status,
|
|
16349
|
+
owner: requiredString(record, "owner", context),
|
|
16350
|
+
createdAt,
|
|
16351
|
+
changelog: requiredString(record, "changelog", context),
|
|
16352
|
+
promptBuilder: requiredString(record, "promptBuilder", context),
|
|
16353
|
+
continuationBuilder: requiredString(record, "continuationBuilder", context),
|
|
16354
|
+
modelOutputInstruction: requiredString(
|
|
16355
|
+
record,
|
|
16356
|
+
"modelOutputInstruction",
|
|
16357
|
+
context
|
|
16358
|
+
),
|
|
16359
|
+
codeReviewPolicy: requiredString(record, "codeReviewPolicy", context),
|
|
16360
|
+
defaultModel: requiredString(record, "defaultModel", context),
|
|
16361
|
+
modelMatrix: requiredStringArray(record, "modelMatrix", context),
|
|
16362
|
+
temperature: requiredNumber(record, "temperature", context),
|
|
16363
|
+
compatibility: {
|
|
16364
|
+
minSdkVersion: requiredString(
|
|
16365
|
+
compatibility,
|
|
16366
|
+
"minSdkVersion",
|
|
16367
|
+
`${context}.compatibility`
|
|
16368
|
+
),
|
|
16369
|
+
capabilities: requiredStringArray(
|
|
16370
|
+
compatibility,
|
|
16371
|
+
"capabilities",
|
|
16372
|
+
`${context}.compatibility`
|
|
16373
|
+
)
|
|
16374
|
+
},
|
|
16375
|
+
evalGates: {
|
|
16376
|
+
requiredSuites: requiredStringArray(
|
|
16377
|
+
evalGates,
|
|
16378
|
+
"requiredSuites",
|
|
16379
|
+
`${context}.evalGates`
|
|
16380
|
+
),
|
|
16381
|
+
criticalBuckets: requiredStringArray(
|
|
16382
|
+
evalGates,
|
|
16383
|
+
"criticalBuckets",
|
|
16384
|
+
`${context}.evalGates`
|
|
16385
|
+
),
|
|
16386
|
+
maxRegressionPct,
|
|
16387
|
+
minPassK: requiredNumberRecord(
|
|
16388
|
+
evalGates,
|
|
16389
|
+
"minPassK",
|
|
16390
|
+
`${context}.evalGates`
|
|
16391
|
+
)
|
|
16392
|
+
}
|
|
16393
|
+
};
|
|
16394
|
+
}
|
|
16395
|
+
function defineHarnessTemplateManifest(value, context) {
|
|
16396
|
+
return validateHarnessTemplateManifest(value, context);
|
|
16397
|
+
}
|
|
16061
16398
|
var DEFAULT_IGNORED_REASONING_COMMENT_DIRECTIVES = [
|
|
16062
16399
|
/^@ts-ignore\b/i,
|
|
16063
16400
|
/^@ts-expect-error\b/i,
|
|
@@ -16160,6 +16497,16 @@ function uniqueStrings(values, maxCount) {
|
|
|
16160
16497
|
}
|
|
16161
16498
|
return output;
|
|
16162
16499
|
}
|
|
16500
|
+
function stableStringify(value) {
|
|
16501
|
+
if (value === null || typeof value !== "object") {
|
|
16502
|
+
return JSON.stringify(value);
|
|
16503
|
+
}
|
|
16504
|
+
if (Array.isArray(value)) {
|
|
16505
|
+
return `[${value.map((entry) => stableStringify(entry)).join(",")}]`;
|
|
16506
|
+
}
|
|
16507
|
+
const record = value;
|
|
16508
|
+
return `{${Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${stableStringify(record[key])}`).join(",")}}`;
|
|
16509
|
+
}
|
|
16163
16510
|
function renderConstBlock(name, value) {
|
|
16164
16511
|
return `const ${name} = ${JSON.stringify(value, null, 2)} as const;`;
|
|
16165
16512
|
}
|
|
@@ -18104,6 +18451,194 @@ ${knownFactsBlock}
|
|
|
18104
18451
|
[Request]
|
|
18105
18452
|
${input.request?.trim() || "Use the latest user message in the conversation."}`;
|
|
18106
18453
|
}
|
|
18454
|
+
var STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST = defineHarnessTemplateManifest(
|
|
18455
|
+
manifest_default3,
|
|
18456
|
+
"stable@1.0.0 manifest"
|
|
18457
|
+
);
|
|
18458
|
+
function hashHarnessTemplateValue(value) {
|
|
18459
|
+
return hashString(stableStringify(value)) || "00000000";
|
|
18460
|
+
}
|
|
18461
|
+
function renderStableHarnessPrompt(input) {
|
|
18462
|
+
const prompt = buildGranularAgentSystemPrompt(input);
|
|
18463
|
+
const templateHash = hashHarnessTemplateValue(
|
|
18464
|
+
STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
18465
|
+
);
|
|
18466
|
+
return {
|
|
18467
|
+
templateId: STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
18468
|
+
templateVersion: STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
18469
|
+
templateHash,
|
|
18470
|
+
promptInstanceHash: hashHarnessTemplateValue({
|
|
18471
|
+
templateHash,
|
|
18472
|
+
input,
|
|
18473
|
+
prompt
|
|
18474
|
+
}),
|
|
18475
|
+
prompt
|
|
18476
|
+
};
|
|
18477
|
+
}
|
|
18478
|
+
function renderStableHarnessContinuation(resultPreview) {
|
|
18479
|
+
const instruction = buildContinuationInstruction(resultPreview);
|
|
18480
|
+
const templateHash = hashHarnessTemplateValue(
|
|
18481
|
+
STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
18482
|
+
);
|
|
18483
|
+
return {
|
|
18484
|
+
templateId: STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
18485
|
+
templateVersion: STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
18486
|
+
templateHash,
|
|
18487
|
+
instruction
|
|
18488
|
+
};
|
|
18489
|
+
}
|
|
18490
|
+
var STABLE_AGENT_HARNESS_TEMPLATE = {
|
|
18491
|
+
manifest: STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST,
|
|
18492
|
+
renderPrompt: renderStableHarnessPrompt,
|
|
18493
|
+
renderContinuation: renderStableHarnessContinuation
|
|
18494
|
+
};
|
|
18495
|
+
var EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST = defineHarnessTemplateManifest(
|
|
18496
|
+
manifest_default2,
|
|
18497
|
+
"experimental-compact@0.1.0 manifest"
|
|
18498
|
+
);
|
|
18499
|
+
function renderExperimentalCompactHarnessPrompt(input) {
|
|
18500
|
+
const prompt = `${buildGranularAgentSystemPrompt(input)}
|
|
18501
|
+
|
|
18502
|
+
[Candidate Harness Delta: Compact Decision Discipline]
|
|
18503
|
+
- Prefer the smallest action that satisfies the current request.
|
|
18504
|
+
- When several records could match, ask one structured choice question before mutating.
|
|
18505
|
+
- Before any irreversible or outbound mutation, obtain explicit confirmation unless the policy surface already requires it.
|
|
18506
|
+
- Do not compensate for missing tools with raw network calls, synthetic records, or hidden side channels.
|
|
18507
|
+
- Keep the final user-facing reply focused on what was done, what was not done, and any remaining blocker.`;
|
|
18508
|
+
const templateHash = hashHarnessTemplateValue(
|
|
18509
|
+
EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
18510
|
+
);
|
|
18511
|
+
return {
|
|
18512
|
+
templateId: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
18513
|
+
templateVersion: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
18514
|
+
templateHash,
|
|
18515
|
+
promptInstanceHash: hashHarnessTemplateValue({
|
|
18516
|
+
templateHash,
|
|
18517
|
+
input,
|
|
18518
|
+
prompt
|
|
18519
|
+
}),
|
|
18520
|
+
prompt
|
|
18521
|
+
};
|
|
18522
|
+
}
|
|
18523
|
+
function renderExperimentalCompactHarnessContinuation(resultPreview) {
|
|
18524
|
+
const instruction = `${buildContinuationInstruction(resultPreview)}
|
|
18525
|
+
|
|
18526
|
+
Keep the continuation compact: either finish, ask the one blocking question, or run the next smallest safe action.`;
|
|
18527
|
+
const templateHash = hashHarnessTemplateValue(
|
|
18528
|
+
EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
18529
|
+
);
|
|
18530
|
+
return {
|
|
18531
|
+
templateId: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
18532
|
+
templateVersion: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
18533
|
+
templateHash,
|
|
18534
|
+
instruction
|
|
18535
|
+
};
|
|
18536
|
+
}
|
|
18537
|
+
var EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE = {
|
|
18538
|
+
manifest: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST,
|
|
18539
|
+
renderPrompt: renderExperimentalCompactHarnessPrompt,
|
|
18540
|
+
renderContinuation: renderExperimentalCompactHarnessContinuation
|
|
18541
|
+
};
|
|
18542
|
+
var ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST = defineHarnessTemplateManifest(
|
|
18543
|
+
manifest_default,
|
|
18544
|
+
"action-presentation@0.1.0 manifest"
|
|
18545
|
+
);
|
|
18546
|
+
function renderActionPresentationHarnessPrompt(input) {
|
|
18547
|
+
const prompt = `${buildGranularAgentSystemPrompt(input)}
|
|
18548
|
+
|
|
18549
|
+
[Candidate Harness Delta: Action Request And Result Presentation]
|
|
18550
|
+
- 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.
|
|
18551
|
+
- 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.
|
|
18552
|
+
- 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.
|
|
18553
|
+
- After a mutation/effect call, base the reply on the returned action result and include a visible target label or identifier when one exists.
|
|
18554
|
+
- If no target can be grounded, say what was searched and what exact identifier or choice is needed; do not pretend the action completed.`;
|
|
18555
|
+
const templateHash = hashHarnessTemplateValue(
|
|
18556
|
+
ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
18557
|
+
);
|
|
18558
|
+
return {
|
|
18559
|
+
templateId: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
18560
|
+
templateVersion: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
18561
|
+
templateHash,
|
|
18562
|
+
promptInstanceHash: hashHarnessTemplateValue({
|
|
18563
|
+
templateHash,
|
|
18564
|
+
input,
|
|
18565
|
+
prompt
|
|
18566
|
+
}),
|
|
18567
|
+
prompt
|
|
18568
|
+
};
|
|
18569
|
+
}
|
|
18570
|
+
function renderActionPresentationHarnessContinuation(resultPreview) {
|
|
18571
|
+
const instruction = `${buildContinuationInstruction(resultPreview)}
|
|
18572
|
+
|
|
18573
|
+
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.`;
|
|
18574
|
+
const templateHash = hashHarnessTemplateValue(
|
|
18575
|
+
ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
18576
|
+
);
|
|
18577
|
+
return {
|
|
18578
|
+
templateId: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
18579
|
+
templateVersion: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
18580
|
+
templateHash,
|
|
18581
|
+
instruction
|
|
18582
|
+
};
|
|
18583
|
+
}
|
|
18584
|
+
var ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE = {
|
|
18585
|
+
manifest: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST,
|
|
18586
|
+
renderPrompt: renderActionPresentationHarnessPrompt,
|
|
18587
|
+
renderContinuation: renderActionPresentationHarnessContinuation
|
|
18588
|
+
};
|
|
18589
|
+
var AGENT_HARNESS_TEMPLATES = {
|
|
18590
|
+
[STABLE_AGENT_HARNESS_TEMPLATE.manifest.id]: STABLE_AGENT_HARNESS_TEMPLATE,
|
|
18591
|
+
[EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE.manifest.id]: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE,
|
|
18592
|
+
[ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE.manifest.id]: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE
|
|
18593
|
+
};
|
|
18594
|
+
function listHarnessTemplates() {
|
|
18595
|
+
return Object.values(AGENT_HARNESS_TEMPLATES).map((template) => ({
|
|
18596
|
+
...template.manifest,
|
|
18597
|
+
compatibility: { ...template.manifest.compatibility },
|
|
18598
|
+
evalGates: {
|
|
18599
|
+
...template.manifest.evalGates,
|
|
18600
|
+
minPassK: { ...template.manifest.evalGates.minPassK }
|
|
18601
|
+
}
|
|
18602
|
+
}));
|
|
18603
|
+
}
|
|
18604
|
+
function resolveHarnessTemplate(templateId = "stable", options) {
|
|
18605
|
+
const resolved = AGENT_HARNESS_TEMPLATES[templateId];
|
|
18606
|
+
if (resolved) return resolved;
|
|
18607
|
+
if (options?.strict) {
|
|
18608
|
+
const known = Object.keys(AGENT_HARNESS_TEMPLATES).join(", ");
|
|
18609
|
+
throw new Error(
|
|
18610
|
+
`Unknown harness template "${templateId}". Known templates: ${known}`
|
|
18611
|
+
);
|
|
18612
|
+
}
|
|
18613
|
+
return STABLE_AGENT_HARNESS_TEMPLATE;
|
|
18614
|
+
}
|
|
18615
|
+
function getDefaultHarnessTemplateId() {
|
|
18616
|
+
if (typeof process !== "undefined") {
|
|
18617
|
+
const configured = process.env.GRANULAR_AGENT_HARNESS_TEMPLATE || process.env.NEXT_PUBLIC_GRANULAR_AGENT_HARNESS_TEMPLATE;
|
|
18618
|
+
if (configured?.trim()) return configured.trim();
|
|
18619
|
+
}
|
|
18620
|
+
return "stable";
|
|
18621
|
+
}
|
|
18622
|
+
function renderGranularAgentSystemPromptFromTemplate(input, options) {
|
|
18623
|
+
const template = resolveHarnessTemplate(
|
|
18624
|
+
options?.templateId || getDefaultHarnessTemplateId(),
|
|
18625
|
+
{ strict: options?.strict ?? true }
|
|
18626
|
+
);
|
|
18627
|
+
return template.renderPrompt(input);
|
|
18628
|
+
}
|
|
18629
|
+
function buildGranularAgentSystemPromptFromTemplate(input, options) {
|
|
18630
|
+
return renderGranularAgentSystemPromptFromTemplate(input, options).prompt;
|
|
18631
|
+
}
|
|
18632
|
+
function renderContinuationInstructionFromTemplate(resultPreview, options) {
|
|
18633
|
+
const template = resolveHarnessTemplate(
|
|
18634
|
+
options?.templateId || getDefaultHarnessTemplateId(),
|
|
18635
|
+
{ strict: options?.strict ?? true }
|
|
18636
|
+
);
|
|
18637
|
+
return template.renderContinuation(resultPreview);
|
|
18638
|
+
}
|
|
18639
|
+
function buildContinuationInstructionFromTemplate(resultPreview, options) {
|
|
18640
|
+
return renderContinuationInstructionFromTemplate(resultPreview, options).instruction;
|
|
18641
|
+
}
|
|
18107
18642
|
|
|
18108
18643
|
// src/openai-usage.ts
|
|
18109
18644
|
var OPENAI_PRICING_SOURCE_URL = "https://developers.openai.com/api/docs/models/gpt-5.4/";
|
|
@@ -18200,6 +18735,6 @@ function calculateOpenAITokenSpend(model, rawUsage) {
|
|
|
18200
18735
|
};
|
|
18201
18736
|
}
|
|
18202
18737
|
|
|
18203
|
-
export { Environment, EnvironmentSession, Granular, OPENAI_MODEL_PRICING_USD_PER_MILLION, OntologyHandle, Session, WSClient, buildContinuationInstruction, buildGranularAgentCheckpointBlock, buildGranularAgentDomainBlock, buildGranularAgentFileBlock, buildGranularAgentHeapBlock, buildGranularAgentLoopBlock, buildGranularAgentReferentBlock, buildGranularAgentRuntimeImportsBlock, buildGranularAgentSessionBlock, buildGranularAgentSystemPrompt, buildGranularAgentToolBlock, buildGranularAgentWorkflowBlock, buildOpenAISpendEventId, buildSessionTranscript, calculateOpenAITokenSpend, consumeGranularReasoningOnlyChunk, consumeGranularReasoningTraceChunk, createHarnessVerifierSnapshot, evaluateContinuation, extractPromptTokens, getCurrentClosureId, getExclusivePromptTarget, getOpenAIModelPricing, hasOpenPrompt, invokeRegisteredEffect, isLocalApiUrl, normalizeEffectBehaviors, normalizeOpenAIUsage, normalizePrompt, normalizePromptChoiceOption, normalizePromptText, normalizePromptType, projectConversationReferentFocus, projectConversationReferentSummary, projectHeapSummary, projectLoopSummary, projectSessionFileSummary, projectWorkflowFocus, projectWorkflowSummary, recordOpenAIUsageSpend, resolveApiUrl, resolveAuthTokenForApiUrl, resolveJobPresentation, resolvePromptAnswer, reviewGeneratedJobCode, scorePromptChoiceMatch, stripGranularReasoningTrace, toGranularHttpBase };
|
|
18738
|
+
export { Environment, EnvironmentSession, Granular, OPENAI_MODEL_PRICING_USD_PER_MILLION, OntologyHandle, Session, WSClient, buildContinuationInstruction, buildContinuationInstructionFromTemplate, buildGranularAgentCheckpointBlock, buildGranularAgentDomainBlock, buildGranularAgentFileBlock, buildGranularAgentHeapBlock, buildGranularAgentLoopBlock, buildGranularAgentReferentBlock, buildGranularAgentRuntimeImportsBlock, buildGranularAgentSessionBlock, buildGranularAgentSystemPrompt, buildGranularAgentSystemPromptFromTemplate, buildGranularAgentToolBlock, buildGranularAgentWorkflowBlock, buildOpenAISpendEventId, buildSessionTranscript, calculateOpenAITokenSpend, consumeGranularReasoningOnlyChunk, consumeGranularReasoningTraceChunk, createHarnessVerifierSnapshot, evaluateContinuation, extractPromptTokens, getCurrentClosureId, getDefaultHarnessTemplateId, getExclusivePromptTarget, getOpenAIModelPricing, hasOpenPrompt, hashHarnessTemplateValue, invokeRegisteredEffect, isLocalApiUrl, listHarnessTemplates, normalizeEffectBehaviors, normalizeOpenAIUsage, normalizePrompt, normalizePromptChoiceOption, normalizePromptText, normalizePromptType, projectConversationReferentFocus, projectConversationReferentSummary, projectHeapSummary, projectLoopSummary, projectSessionFileSummary, projectWorkflowFocus, projectWorkflowSummary, recordOpenAIUsageSpend, renderContinuationInstructionFromTemplate, renderGranularAgentSystemPromptFromTemplate, resolveApiUrl, resolveAuthTokenForApiUrl, resolveHarnessTemplate, resolveJobPresentation, resolvePromptAnswer, reviewGeneratedJobCode, scorePromptChoiceMatch, stripGranularReasoningTrace, toGranularHttpBase, validateHarnessTemplateManifest };
|
|
18204
18739
|
//# sourceMappingURL=index.mjs.map
|
|
18205
18740
|
//# sourceMappingURL=index.mjs.map
|