@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.js
CHANGED
|
@@ -181,9 +181,9 @@ var require_node_gyp_build = __commonJS({
|
|
|
181
181
|
}
|
|
182
182
|
function parseTags(file) {
|
|
183
183
|
var arr = file.split(".");
|
|
184
|
-
var
|
|
184
|
+
var extension2 = arr.pop();
|
|
185
185
|
var tags = { file, specificity: 0 };
|
|
186
|
-
if (
|
|
186
|
+
if (extension2 !== "node") return;
|
|
187
187
|
for (var i = 0; i < arr.length; i++) {
|
|
188
188
|
var tag = arr[i];
|
|
189
189
|
if (tag === "node" || tag === "electron" || tag === "node-webkit") {
|
|
@@ -431,7 +431,7 @@ var require_permessage_deflate = __commonJS({
|
|
|
431
431
|
var kBuffers = Symbol("buffers");
|
|
432
432
|
var kError = Symbol("error");
|
|
433
433
|
var zlibLimiter;
|
|
434
|
-
var
|
|
434
|
+
var PerMessageDeflate2 = class {
|
|
435
435
|
/**
|
|
436
436
|
* Creates a PerMessageDeflate instance.
|
|
437
437
|
*
|
|
@@ -442,6 +442,9 @@ var require_permessage_deflate = __commonJS({
|
|
|
442
442
|
* acknowledge disabling of client context takeover
|
|
443
443
|
* @param {Number} [options.concurrencyLimit=10] The number of concurrent
|
|
444
444
|
* calls to zlib
|
|
445
|
+
* @param {Boolean} [options.isServer=false] Create the instance in either
|
|
446
|
+
* server or client mode
|
|
447
|
+
* @param {Number} [options.maxPayload=0] The maximum allowed message length
|
|
445
448
|
* @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
|
|
446
449
|
* use of a custom server window size
|
|
447
450
|
* @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
|
|
@@ -452,15 +455,12 @@ var require_permessage_deflate = __commonJS({
|
|
|
452
455
|
* deflate
|
|
453
456
|
* @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
|
|
454
457
|
* inflate
|
|
455
|
-
* @param {Boolean} [isServer=false] Create the instance in either server or
|
|
456
|
-
* client mode
|
|
457
|
-
* @param {Number} [maxPayload=0] The maximum allowed message length
|
|
458
458
|
*/
|
|
459
|
-
constructor(options
|
|
460
|
-
this._maxPayload = maxPayload | 0;
|
|
459
|
+
constructor(options) {
|
|
461
460
|
this._options = options || {};
|
|
462
461
|
this._threshold = this._options.threshold !== void 0 ? this._options.threshold : 1024;
|
|
463
|
-
this.
|
|
462
|
+
this._maxPayload = this._options.maxPayload | 0;
|
|
463
|
+
this._isServer = !!this._options.isServer;
|
|
464
464
|
this._deflate = null;
|
|
465
465
|
this._inflate = null;
|
|
466
466
|
this.params = null;
|
|
@@ -769,7 +769,7 @@ var require_permessage_deflate = __commonJS({
|
|
|
769
769
|
});
|
|
770
770
|
}
|
|
771
771
|
};
|
|
772
|
-
module.exports =
|
|
772
|
+
module.exports = PerMessageDeflate2;
|
|
773
773
|
function deflateOnData(chunk) {
|
|
774
774
|
this[kBuffers].push(chunk);
|
|
775
775
|
this[kTotalLength] += chunk.length;
|
|
@@ -1049,7 +1049,7 @@ var require_validation = __commonJS({
|
|
|
1049
1049
|
var require_receiver = __commonJS({
|
|
1050
1050
|
"../../node_modules/ws/lib/receiver.js"(exports, module) {
|
|
1051
1051
|
var { Writable } = __require("stream");
|
|
1052
|
-
var
|
|
1052
|
+
var PerMessageDeflate2 = require_permessage_deflate();
|
|
1053
1053
|
var {
|
|
1054
1054
|
BINARY_TYPES,
|
|
1055
1055
|
EMPTY_BUFFER,
|
|
@@ -1079,6 +1079,10 @@ var require_receiver = __commonJS({
|
|
|
1079
1079
|
* extensions
|
|
1080
1080
|
* @param {Boolean} [options.isServer=false] Specifies whether to operate in
|
|
1081
1081
|
* client or server mode
|
|
1082
|
+
* @param {Number} [options.maxBufferedChunks=0] The maximum number of
|
|
1083
|
+
* buffered data chunks
|
|
1084
|
+
* @param {Number} [options.maxFragments=0] The maximum number of message
|
|
1085
|
+
* fragments
|
|
1082
1086
|
* @param {Number} [options.maxPayload=0] The maximum allowed message length
|
|
1083
1087
|
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
|
1084
1088
|
* not to skip UTF-8 validation for text and close messages
|
|
@@ -1089,6 +1093,8 @@ var require_receiver = __commonJS({
|
|
|
1089
1093
|
this._binaryType = options.binaryType || BINARY_TYPES[0];
|
|
1090
1094
|
this._extensions = options.extensions || {};
|
|
1091
1095
|
this._isServer = !!options.isServer;
|
|
1096
|
+
this._maxBufferedChunks = options.maxBufferedChunks | 0;
|
|
1097
|
+
this._maxFragments = options.maxFragments | 0;
|
|
1092
1098
|
this._maxPayload = options.maxPayload | 0;
|
|
1093
1099
|
this._skipUTF8Validation = !!options.skipUTF8Validation;
|
|
1094
1100
|
this[kWebSocket] = void 0;
|
|
@@ -1118,6 +1124,18 @@ var require_receiver = __commonJS({
|
|
|
1118
1124
|
*/
|
|
1119
1125
|
_write(chunk, encoding, cb) {
|
|
1120
1126
|
if (this._opcode === 8 && this._state == GET_INFO) return cb();
|
|
1127
|
+
if (this._maxBufferedChunks > 0 && this._buffers.length >= this._maxBufferedChunks) {
|
|
1128
|
+
cb(
|
|
1129
|
+
this.createError(
|
|
1130
|
+
RangeError,
|
|
1131
|
+
"Too many buffered chunks",
|
|
1132
|
+
false,
|
|
1133
|
+
1008,
|
|
1134
|
+
"WS_ERR_TOO_MANY_BUFFERED_PARTS"
|
|
1135
|
+
)
|
|
1136
|
+
);
|
|
1137
|
+
return;
|
|
1138
|
+
}
|
|
1121
1139
|
this._bufferedBytes += chunk.length;
|
|
1122
1140
|
this._buffers.push(chunk);
|
|
1123
1141
|
this.startLoop(cb);
|
|
@@ -1216,7 +1234,7 @@ var require_receiver = __commonJS({
|
|
|
1216
1234
|
return;
|
|
1217
1235
|
}
|
|
1218
1236
|
const compressed = (buf[0] & 64) === 64;
|
|
1219
|
-
if (compressed && !this._extensions[
|
|
1237
|
+
if (compressed && !this._extensions[PerMessageDeflate2.extensionName]) {
|
|
1220
1238
|
const error = this.createError(
|
|
1221
1239
|
RangeError,
|
|
1222
1240
|
"RSV1 must be clear",
|
|
@@ -1447,6 +1465,17 @@ var require_receiver = __commonJS({
|
|
|
1447
1465
|
return;
|
|
1448
1466
|
}
|
|
1449
1467
|
if (data.length) {
|
|
1468
|
+
if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
|
|
1469
|
+
const error = this.createError(
|
|
1470
|
+
RangeError,
|
|
1471
|
+
"Too many message fragments",
|
|
1472
|
+
false,
|
|
1473
|
+
1008,
|
|
1474
|
+
"WS_ERR_TOO_MANY_BUFFERED_PARTS"
|
|
1475
|
+
);
|
|
1476
|
+
cb(error);
|
|
1477
|
+
return;
|
|
1478
|
+
}
|
|
1450
1479
|
this._messageLength = this._totalPayloadLength;
|
|
1451
1480
|
this._fragments.push(data);
|
|
1452
1481
|
}
|
|
@@ -1460,7 +1489,7 @@ var require_receiver = __commonJS({
|
|
|
1460
1489
|
* @private
|
|
1461
1490
|
*/
|
|
1462
1491
|
decompress(data, cb) {
|
|
1463
|
-
const perMessageDeflate = this._extensions[
|
|
1492
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
|
|
1464
1493
|
perMessageDeflate.decompress(data, this._fin, (err, buf) => {
|
|
1465
1494
|
if (err) return cb(err);
|
|
1466
1495
|
if (buf.length) {
|
|
@@ -1476,6 +1505,17 @@ var require_receiver = __commonJS({
|
|
|
1476
1505
|
cb(error);
|
|
1477
1506
|
return;
|
|
1478
1507
|
}
|
|
1508
|
+
if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
|
|
1509
|
+
const error = this.createError(
|
|
1510
|
+
RangeError,
|
|
1511
|
+
"Too many message fragments",
|
|
1512
|
+
false,
|
|
1513
|
+
1008,
|
|
1514
|
+
"WS_ERR_TOO_MANY_BUFFERED_PARTS"
|
|
1515
|
+
);
|
|
1516
|
+
cb(error);
|
|
1517
|
+
return;
|
|
1518
|
+
}
|
|
1479
1519
|
this._fragments.push(buf);
|
|
1480
1520
|
}
|
|
1481
1521
|
this.dataMessage(cb);
|
|
@@ -1641,7 +1681,10 @@ var require_sender = __commonJS({
|
|
|
1641
1681
|
"../../node_modules/ws/lib/sender.js"(exports, module) {
|
|
1642
1682
|
var { Duplex } = __require("stream");
|
|
1643
1683
|
var { randomFillSync } = __require("crypto");
|
|
1644
|
-
var
|
|
1684
|
+
var {
|
|
1685
|
+
types: { isUint8Array }
|
|
1686
|
+
} = __require("util");
|
|
1687
|
+
var PerMessageDeflate2 = require_permessage_deflate();
|
|
1645
1688
|
var { EMPTY_BUFFER, kWebSocket, NOOP } = require_constants();
|
|
1646
1689
|
var { isBlob, isValidStatusCode } = require_validation();
|
|
1647
1690
|
var { mask: applyMask, toBuffer } = require_buffer_util();
|
|
@@ -1794,8 +1837,10 @@ var require_sender = __commonJS({
|
|
|
1794
1837
|
buf.writeUInt16BE(code, 0);
|
|
1795
1838
|
if (typeof data === "string") {
|
|
1796
1839
|
buf.write(data, 2);
|
|
1797
|
-
} else {
|
|
1840
|
+
} else if (isUint8Array(data)) {
|
|
1798
1841
|
buf.set(data, 2);
|
|
1842
|
+
} else {
|
|
1843
|
+
throw new TypeError("Second argument must be a string or a Uint8Array");
|
|
1799
1844
|
}
|
|
1800
1845
|
}
|
|
1801
1846
|
const options = {
|
|
@@ -1925,7 +1970,7 @@ var require_sender = __commonJS({
|
|
|
1925
1970
|
* @public
|
|
1926
1971
|
*/
|
|
1927
1972
|
send(data, options, cb) {
|
|
1928
|
-
const perMessageDeflate = this._extensions[
|
|
1973
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
|
|
1929
1974
|
let opcode = options.binary ? 2 : 1;
|
|
1930
1975
|
let rsv1 = options.compress;
|
|
1931
1976
|
let byteLength;
|
|
@@ -2049,7 +2094,7 @@ var require_sender = __commonJS({
|
|
|
2049
2094
|
this.sendFrame(_Sender.frame(data, options), cb);
|
|
2050
2095
|
return;
|
|
2051
2096
|
}
|
|
2052
|
-
const perMessageDeflate = this._extensions[
|
|
2097
|
+
const perMessageDeflate = this._extensions[PerMessageDeflate2.extensionName];
|
|
2053
2098
|
this._bufferedBytes += options[kByteLength];
|
|
2054
2099
|
this._state = DEFLATING;
|
|
2055
2100
|
perMessageDeflate.compress(data, options.fin, (_, buf) => {
|
|
@@ -2485,11 +2530,11 @@ var require_extension = __commonJS({
|
|
|
2485
2530
|
return offers;
|
|
2486
2531
|
}
|
|
2487
2532
|
function format(extensions) {
|
|
2488
|
-
return Object.keys(extensions).map((
|
|
2489
|
-
let configurations = extensions[
|
|
2533
|
+
return Object.keys(extensions).map((extension2) => {
|
|
2534
|
+
let configurations = extensions[extension2];
|
|
2490
2535
|
if (!Array.isArray(configurations)) configurations = [configurations];
|
|
2491
2536
|
return configurations.map((params) => {
|
|
2492
|
-
return [
|
|
2537
|
+
return [extension2].concat(
|
|
2493
2538
|
Object.keys(params).map((k) => {
|
|
2494
2539
|
let values = params[k];
|
|
2495
2540
|
if (!Array.isArray(values)) values = [values];
|
|
@@ -2514,7 +2559,7 @@ var require_websocket = __commonJS({
|
|
|
2514
2559
|
var { randomBytes, createHash } = __require("crypto");
|
|
2515
2560
|
var { Duplex, Readable } = __require("stream");
|
|
2516
2561
|
var { URL: URL2 } = __require("url");
|
|
2517
|
-
var
|
|
2562
|
+
var PerMessageDeflate2 = require_permessage_deflate();
|
|
2518
2563
|
var Receiver2 = require_receiver();
|
|
2519
2564
|
var Sender2 = require_sender();
|
|
2520
2565
|
var { isBlob } = require_validation();
|
|
@@ -2673,6 +2718,10 @@ var require_websocket = __commonJS({
|
|
|
2673
2718
|
* multiple times in the same tick
|
|
2674
2719
|
* @param {Function} [options.generateMask] The function used to generate the
|
|
2675
2720
|
* masking key
|
|
2721
|
+
* @param {Number} [options.maxBufferedChunks=0] The maximum number of
|
|
2722
|
+
* buffered data chunks
|
|
2723
|
+
* @param {Number} [options.maxFragments=0] The maximum number of message
|
|
2724
|
+
* fragments
|
|
2676
2725
|
* @param {Number} [options.maxPayload=0] The maximum allowed message size
|
|
2677
2726
|
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
|
2678
2727
|
* not to skip UTF-8 validation for text and close messages
|
|
@@ -2684,6 +2733,8 @@ var require_websocket = __commonJS({
|
|
|
2684
2733
|
binaryType: this.binaryType,
|
|
2685
2734
|
extensions: this._extensions,
|
|
2686
2735
|
isServer: this._isServer,
|
|
2736
|
+
maxBufferedChunks: options.maxBufferedChunks,
|
|
2737
|
+
maxFragments: options.maxFragments,
|
|
2687
2738
|
maxPayload: options.maxPayload,
|
|
2688
2739
|
skipUTF8Validation: options.skipUTF8Validation
|
|
2689
2740
|
});
|
|
@@ -2722,8 +2773,8 @@ var require_websocket = __commonJS({
|
|
|
2722
2773
|
this.emit("close", this._closeCode, this._closeMessage);
|
|
2723
2774
|
return;
|
|
2724
2775
|
}
|
|
2725
|
-
if (this._extensions[
|
|
2726
|
-
this._extensions[
|
|
2776
|
+
if (this._extensions[PerMessageDeflate2.extensionName]) {
|
|
2777
|
+
this._extensions[PerMessageDeflate2.extensionName].cleanup();
|
|
2727
2778
|
}
|
|
2728
2779
|
this._receiver.removeAllListeners();
|
|
2729
2780
|
this._readyState = _WebSocket.CLOSED;
|
|
@@ -2885,7 +2936,7 @@ var require_websocket = __commonJS({
|
|
|
2885
2936
|
fin: true,
|
|
2886
2937
|
...options
|
|
2887
2938
|
};
|
|
2888
|
-
if (!this._extensions[
|
|
2939
|
+
if (!this._extensions[PerMessageDeflate2.extensionName]) {
|
|
2889
2940
|
opts.compress = false;
|
|
2890
2941
|
}
|
|
2891
2942
|
this._sender.send(data || EMPTY_BUFFER, opts, cb);
|
|
@@ -2983,6 +3034,8 @@ var require_websocket = __commonJS({
|
|
|
2983
3034
|
autoPong: true,
|
|
2984
3035
|
closeTimeout: CLOSE_TIMEOUT,
|
|
2985
3036
|
protocolVersion: protocolVersions[1],
|
|
3037
|
+
maxBufferedChunks: 1024 * 1024,
|
|
3038
|
+
maxFragments: 128 * 1024,
|
|
2986
3039
|
maxPayload: 100 * 1024 * 1024,
|
|
2987
3040
|
skipUTF8Validation: false,
|
|
2988
3041
|
perMessageDeflate: true,
|
|
@@ -3011,7 +3064,7 @@ var require_websocket = __commonJS({
|
|
|
3011
3064
|
} else {
|
|
3012
3065
|
try {
|
|
3013
3066
|
parsedUrl = new URL2(address);
|
|
3014
|
-
} catch
|
|
3067
|
+
} catch {
|
|
3015
3068
|
throw new SyntaxError(`Invalid URL: ${address}`);
|
|
3016
3069
|
}
|
|
3017
3070
|
}
|
|
@@ -3059,13 +3112,13 @@ var require_websocket = __commonJS({
|
|
|
3059
3112
|
opts.path = parsedUrl.pathname + parsedUrl.search;
|
|
3060
3113
|
opts.timeout = opts.handshakeTimeout;
|
|
3061
3114
|
if (opts.perMessageDeflate) {
|
|
3062
|
-
perMessageDeflate = new
|
|
3063
|
-
opts.perMessageDeflate
|
|
3064
|
-
false,
|
|
3065
|
-
opts.maxPayload
|
|
3066
|
-
);
|
|
3115
|
+
perMessageDeflate = new PerMessageDeflate2({
|
|
3116
|
+
...opts.perMessageDeflate,
|
|
3117
|
+
isServer: false,
|
|
3118
|
+
maxPayload: opts.maxPayload
|
|
3119
|
+
});
|
|
3067
3120
|
opts.headers["Sec-WebSocket-Extensions"] = format({
|
|
3068
|
-
[
|
|
3121
|
+
[PerMessageDeflate2.extensionName]: perMessageDeflate.offer()
|
|
3069
3122
|
});
|
|
3070
3123
|
}
|
|
3071
3124
|
if (protocols.length) {
|
|
@@ -3208,23 +3261,25 @@ var require_websocket = __commonJS({
|
|
|
3208
3261
|
return;
|
|
3209
3262
|
}
|
|
3210
3263
|
const extensionNames = Object.keys(extensions);
|
|
3211
|
-
if (extensionNames.length !== 1 || extensionNames[0] !==
|
|
3264
|
+
if (extensionNames.length !== 1 || extensionNames[0] !== PerMessageDeflate2.extensionName) {
|
|
3212
3265
|
const message = "Server indicated an extension that was not requested";
|
|
3213
3266
|
abortHandshake(websocket, socket, message);
|
|
3214
3267
|
return;
|
|
3215
3268
|
}
|
|
3216
3269
|
try {
|
|
3217
|
-
perMessageDeflate.accept(extensions[
|
|
3270
|
+
perMessageDeflate.accept(extensions[PerMessageDeflate2.extensionName]);
|
|
3218
3271
|
} catch (err) {
|
|
3219
3272
|
const message = "Invalid Sec-WebSocket-Extensions header";
|
|
3220
3273
|
abortHandshake(websocket, socket, message);
|
|
3221
3274
|
return;
|
|
3222
3275
|
}
|
|
3223
|
-
websocket._extensions[
|
|
3276
|
+
websocket._extensions[PerMessageDeflate2.extensionName] = perMessageDeflate;
|
|
3224
3277
|
}
|
|
3225
3278
|
websocket.setSocket(socket, head, {
|
|
3226
3279
|
allowSynchronousEvents: opts.allowSynchronousEvents,
|
|
3227
3280
|
generateMask: opts.generateMask,
|
|
3281
|
+
maxBufferedChunks: opts.maxBufferedChunks,
|
|
3282
|
+
maxFragments: opts.maxFragments,
|
|
3228
3283
|
maxPayload: opts.maxPayload,
|
|
3229
3284
|
skipUTF8Validation: opts.skipUTF8Validation
|
|
3230
3285
|
});
|
|
@@ -3536,9 +3591,9 @@ var require_websocket_server = __commonJS({
|
|
|
3536
3591
|
var http = __require("http");
|
|
3537
3592
|
var { Duplex } = __require("stream");
|
|
3538
3593
|
var { createHash } = __require("crypto");
|
|
3539
|
-
var
|
|
3540
|
-
var
|
|
3541
|
-
var
|
|
3594
|
+
var extension2 = require_extension();
|
|
3595
|
+
var PerMessageDeflate2 = require_permessage_deflate();
|
|
3596
|
+
var subprotocol2 = require_subprotocol();
|
|
3542
3597
|
var WebSocket2 = require_websocket();
|
|
3543
3598
|
var { CLOSE_TIMEOUT, GUID, kWebSocket } = require_constants();
|
|
3544
3599
|
var keyRegex = /^[+/0-9A-Za-z]{22}==$/;
|
|
@@ -3564,6 +3619,10 @@ var require_websocket_server = __commonJS({
|
|
|
3564
3619
|
* called
|
|
3565
3620
|
* @param {Function} [options.handleProtocols] A hook to handle protocols
|
|
3566
3621
|
* @param {String} [options.host] The hostname where to bind the server
|
|
3622
|
+
* @param {Number} [options.maxBufferedChunks=1048576] The maximum number of
|
|
3623
|
+
* buffered data chunks
|
|
3624
|
+
* @param {Number} [options.maxFragments=131072] The maximum number of message
|
|
3625
|
+
* fragments
|
|
3567
3626
|
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
3568
3627
|
* size
|
|
3569
3628
|
* @param {Boolean} [options.noServer=false] Enable no server mode
|
|
@@ -3585,6 +3644,8 @@ var require_websocket_server = __commonJS({
|
|
|
3585
3644
|
options = {
|
|
3586
3645
|
allowSynchronousEvents: true,
|
|
3587
3646
|
autoPong: true,
|
|
3647
|
+
maxBufferedChunks: 1024 * 1024,
|
|
3648
|
+
maxFragments: 128 * 1024,
|
|
3588
3649
|
maxPayload: 100 * 1024 * 1024,
|
|
3589
3650
|
skipUTF8Validation: false,
|
|
3590
3651
|
perMessageDeflate: false,
|
|
@@ -3761,7 +3822,7 @@ var require_websocket_server = __commonJS({
|
|
|
3761
3822
|
let protocols = /* @__PURE__ */ new Set();
|
|
3762
3823
|
if (secWebSocketProtocol !== void 0) {
|
|
3763
3824
|
try {
|
|
3764
|
-
protocols =
|
|
3825
|
+
protocols = subprotocol2.parse(secWebSocketProtocol);
|
|
3765
3826
|
} catch (err) {
|
|
3766
3827
|
const message = "Invalid Sec-WebSocket-Protocol header";
|
|
3767
3828
|
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
@@ -3771,16 +3832,16 @@ var require_websocket_server = __commonJS({
|
|
|
3771
3832
|
const secWebSocketExtensions = req.headers["sec-websocket-extensions"];
|
|
3772
3833
|
const extensions = {};
|
|
3773
3834
|
if (this.options.perMessageDeflate && secWebSocketExtensions !== void 0) {
|
|
3774
|
-
const perMessageDeflate = new
|
|
3775
|
-
this.options.perMessageDeflate,
|
|
3776
|
-
true,
|
|
3777
|
-
this.options.maxPayload
|
|
3778
|
-
);
|
|
3835
|
+
const perMessageDeflate = new PerMessageDeflate2({
|
|
3836
|
+
...this.options.perMessageDeflate,
|
|
3837
|
+
isServer: true,
|
|
3838
|
+
maxPayload: this.options.maxPayload
|
|
3839
|
+
});
|
|
3779
3840
|
try {
|
|
3780
|
-
const offers =
|
|
3781
|
-
if (offers[
|
|
3782
|
-
perMessageDeflate.accept(offers[
|
|
3783
|
-
extensions[
|
|
3841
|
+
const offers = extension2.parse(secWebSocketExtensions);
|
|
3842
|
+
if (offers[PerMessageDeflate2.extensionName]) {
|
|
3843
|
+
perMessageDeflate.accept(offers[PerMessageDeflate2.extensionName]);
|
|
3844
|
+
extensions[PerMessageDeflate2.extensionName] = perMessageDeflate;
|
|
3784
3845
|
}
|
|
3785
3846
|
} catch (err) {
|
|
3786
3847
|
const message = "Invalid or unacceptable Sec-WebSocket-Extensions header";
|
|
@@ -3851,10 +3912,10 @@ var require_websocket_server = __commonJS({
|
|
|
3851
3912
|
ws._protocol = protocol;
|
|
3852
3913
|
}
|
|
3853
3914
|
}
|
|
3854
|
-
if (extensions[
|
|
3855
|
-
const params = extensions[
|
|
3856
|
-
const value =
|
|
3857
|
-
[
|
|
3915
|
+
if (extensions[PerMessageDeflate2.extensionName]) {
|
|
3916
|
+
const params = extensions[PerMessageDeflate2.extensionName].params;
|
|
3917
|
+
const value = extension2.format({
|
|
3918
|
+
[PerMessageDeflate2.extensionName]: [params]
|
|
3858
3919
|
});
|
|
3859
3920
|
headers.push(`Sec-WebSocket-Extensions: ${value}`);
|
|
3860
3921
|
ws._extensions = extensions;
|
|
@@ -3864,6 +3925,8 @@ var require_websocket_server = __commonJS({
|
|
|
3864
3925
|
socket.removeListener("error", socketOnError);
|
|
3865
3926
|
ws.setSocket(socket, head, {
|
|
3866
3927
|
allowSynchronousEvents: this.options.allowSynchronousEvents,
|
|
3928
|
+
maxBufferedChunks: this.options.maxBufferedChunks,
|
|
3929
|
+
maxFragments: this.options.maxFragments,
|
|
3867
3930
|
maxPayload: this.options.maxPayload,
|
|
3868
3931
|
skipUTF8Validation: this.options.skipUTF8Validation
|
|
3869
3932
|
});
|
|
@@ -3924,19 +3987,25 @@ var require_websocket_server = __commonJS({
|
|
|
3924
3987
|
// ../../node_modules/ws/wrapper.mjs
|
|
3925
3988
|
var wrapper_exports = {};
|
|
3926
3989
|
__export(wrapper_exports, {
|
|
3990
|
+
PerMessageDeflate: () => import_permessage_deflate.default,
|
|
3927
3991
|
Receiver: () => import_receiver.default,
|
|
3928
3992
|
Sender: () => import_sender.default,
|
|
3929
3993
|
WebSocket: () => import_websocket.default,
|
|
3930
3994
|
WebSocketServer: () => import_websocket_server.default,
|
|
3931
3995
|
createWebSocketStream: () => import_stream.default,
|
|
3932
|
-
default: () => wrapper_default
|
|
3996
|
+
default: () => wrapper_default,
|
|
3997
|
+
extension: () => import_extension.default,
|
|
3998
|
+
subprotocol: () => import_subprotocol.default
|
|
3933
3999
|
});
|
|
3934
|
-
var import_stream, import_receiver, import_sender, import_websocket, import_websocket_server, wrapper_default;
|
|
4000
|
+
var import_stream, import_extension, import_permessage_deflate, import_receiver, import_sender, import_subprotocol, import_websocket, import_websocket_server, wrapper_default;
|
|
3935
4001
|
var init_wrapper = __esm({
|
|
3936
4002
|
"../../node_modules/ws/wrapper.mjs"() {
|
|
3937
4003
|
import_stream = __toESM(require_stream());
|
|
4004
|
+
import_extension = __toESM(require_extension());
|
|
4005
|
+
import_permessage_deflate = __toESM(require_permessage_deflate());
|
|
3938
4006
|
import_receiver = __toESM(require_receiver());
|
|
3939
4007
|
import_sender = __toESM(require_sender());
|
|
4008
|
+
import_subprotocol = __toESM(require_subprotocol());
|
|
3940
4009
|
import_websocket = __toESM(require_websocket());
|
|
3941
4010
|
import_websocket_server = __toESM(require_websocket_server());
|
|
3942
4011
|
wrapper_default = import_websocket.default;
|
|
@@ -16079,7 +16148,275 @@ var Granular = class _Granular {
|
|
|
16079
16148
|
}
|
|
16080
16149
|
};
|
|
16081
16150
|
|
|
16151
|
+
// src/agent-harness-templates/action-presentation/0.1.0/manifest.json
|
|
16152
|
+
var manifest_default = {
|
|
16153
|
+
id: "action-presentation",
|
|
16154
|
+
version: "0.1.0",
|
|
16155
|
+
status: "candidate",
|
|
16156
|
+
owner: "granular",
|
|
16157
|
+
createdAt: "2026-05-25T00:00:00.000Z",
|
|
16158
|
+
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.",
|
|
16159
|
+
promptBuilder: "buildGranularAgentSystemPrompt:action-presentation",
|
|
16160
|
+
continuationBuilder: "buildContinuationInstruction:action-presentation",
|
|
16161
|
+
modelOutputInstruction: "agent-evals:modelOutputInstruction",
|
|
16162
|
+
codeReviewPolicy: "reviewGeneratedJobCode",
|
|
16163
|
+
defaultModel: "gpt-5.4",
|
|
16164
|
+
modelMatrix: ["gpt-5.4"],
|
|
16165
|
+
temperature: 0,
|
|
16166
|
+
compatibility: {
|
|
16167
|
+
minSdkVersion: "0.4.40",
|
|
16168
|
+
capabilities: [
|
|
16169
|
+
"executeCode",
|
|
16170
|
+
"readEntities",
|
|
16171
|
+
"workflowHelpers",
|
|
16172
|
+
"savedData",
|
|
16173
|
+
"showRecords"
|
|
16174
|
+
]
|
|
16175
|
+
},
|
|
16176
|
+
evalGates: {
|
|
16177
|
+
requiredSuites: [
|
|
16178
|
+
"agent-harness-hardening",
|
|
16179
|
+
"agent-harness-runtime-e2e",
|
|
16180
|
+
"agent-production-readiness-e2e"
|
|
16181
|
+
],
|
|
16182
|
+
criticalBuckets: [
|
|
16183
|
+
"relationship-traversal",
|
|
16184
|
+
"cross-turn-reference",
|
|
16185
|
+
"ambiguous-target-choice",
|
|
16186
|
+
"confirmation-gated-mutation",
|
|
16187
|
+
"denied-action-refusal",
|
|
16188
|
+
"mutation-presentation"
|
|
16189
|
+
],
|
|
16190
|
+
maxRegressionPct: 0,
|
|
16191
|
+
minPassK: {
|
|
16192
|
+
"critical-mutation": 0.9,
|
|
16193
|
+
"permission-boundary": 1
|
|
16194
|
+
}
|
|
16195
|
+
}
|
|
16196
|
+
};
|
|
16197
|
+
|
|
16198
|
+
// src/agent-harness-templates/experimental-compact/0.1.0/manifest.json
|
|
16199
|
+
var manifest_default2 = {
|
|
16200
|
+
id: "experimental-compact",
|
|
16201
|
+
version: "0.1.0",
|
|
16202
|
+
status: "candidate",
|
|
16203
|
+
owner: "granular",
|
|
16204
|
+
createdAt: "2026-05-24T00:00:00.000Z",
|
|
16205
|
+
changelog: "Candidate harness template used for champion/challenger testing. It adds a compact decision discipline section on top of the stable renderer.",
|
|
16206
|
+
promptBuilder: "buildGranularAgentSystemPrompt:experimental-compact",
|
|
16207
|
+
continuationBuilder: "buildContinuationInstruction:experimental-compact",
|
|
16208
|
+
modelOutputInstruction: "agent-evals:modelOutputInstruction",
|
|
16209
|
+
codeReviewPolicy: "reviewGeneratedJobCode",
|
|
16210
|
+
defaultModel: "gpt-5.4",
|
|
16211
|
+
modelMatrix: ["gpt-5.4"],
|
|
16212
|
+
temperature: 0,
|
|
16213
|
+
compatibility: {
|
|
16214
|
+
minSdkVersion: "0.4.40",
|
|
16215
|
+
capabilities: [
|
|
16216
|
+
"executeCode",
|
|
16217
|
+
"readEntities",
|
|
16218
|
+
"workflowHelpers",
|
|
16219
|
+
"savedData",
|
|
16220
|
+
"showRecords"
|
|
16221
|
+
]
|
|
16222
|
+
},
|
|
16223
|
+
evalGates: {
|
|
16224
|
+
requiredSuites: [
|
|
16225
|
+
"agent-harness-hardening",
|
|
16226
|
+
"agent-harness-runtime-e2e",
|
|
16227
|
+
"agent-production-readiness-e2e"
|
|
16228
|
+
],
|
|
16229
|
+
criticalBuckets: [
|
|
16230
|
+
"relationship-traversal",
|
|
16231
|
+
"cross-turn-reference",
|
|
16232
|
+
"ambiguous-target-choice",
|
|
16233
|
+
"confirmation-gated-mutation",
|
|
16234
|
+
"denied-action-refusal",
|
|
16235
|
+
"mutation-presentation"
|
|
16236
|
+
],
|
|
16237
|
+
maxRegressionPct: 0,
|
|
16238
|
+
minPassK: {
|
|
16239
|
+
"critical-mutation": 0.9,
|
|
16240
|
+
"permission-boundary": 1
|
|
16241
|
+
}
|
|
16242
|
+
}
|
|
16243
|
+
};
|
|
16244
|
+
|
|
16245
|
+
// src/agent-harness-templates/stable/1.0.0/manifest.json
|
|
16246
|
+
var manifest_default3 = {
|
|
16247
|
+
id: "stable",
|
|
16248
|
+
version: "1.0.0",
|
|
16249
|
+
status: "stable",
|
|
16250
|
+
owner: "granular",
|
|
16251
|
+
createdAt: "2026-05-24T00:00:00.000Z",
|
|
16252
|
+
changelog: "Baseline template wrapping the existing Granular agent harness prompt, continuation instruction, output contract, and generated-job review policy.",
|
|
16253
|
+
promptBuilder: "buildGranularAgentSystemPrompt",
|
|
16254
|
+
continuationBuilder: "buildContinuationInstruction",
|
|
16255
|
+
modelOutputInstruction: "agent-evals:modelOutputInstruction",
|
|
16256
|
+
codeReviewPolicy: "reviewGeneratedJobCode",
|
|
16257
|
+
defaultModel: "gpt-5.4",
|
|
16258
|
+
modelMatrix: ["gpt-5.4"],
|
|
16259
|
+
temperature: 0,
|
|
16260
|
+
compatibility: {
|
|
16261
|
+
minSdkVersion: "0.4.40",
|
|
16262
|
+
capabilities: [
|
|
16263
|
+
"executeCode",
|
|
16264
|
+
"readEntities",
|
|
16265
|
+
"workflowHelpers",
|
|
16266
|
+
"savedData",
|
|
16267
|
+
"showRecords"
|
|
16268
|
+
]
|
|
16269
|
+
},
|
|
16270
|
+
evalGates: {
|
|
16271
|
+
requiredSuites: [
|
|
16272
|
+
"agent-harness-hardening",
|
|
16273
|
+
"agent-harness-runtime-e2e",
|
|
16274
|
+
"agent-production-readiness-e2e"
|
|
16275
|
+
],
|
|
16276
|
+
criticalBuckets: [
|
|
16277
|
+
"relationship-traversal",
|
|
16278
|
+
"cross-turn-reference",
|
|
16279
|
+
"ambiguous-target-choice",
|
|
16280
|
+
"confirmation-gated-mutation",
|
|
16281
|
+
"denied-action-refusal",
|
|
16282
|
+
"mutation-presentation"
|
|
16283
|
+
],
|
|
16284
|
+
maxRegressionPct: 0,
|
|
16285
|
+
minPassK: {
|
|
16286
|
+
"critical-mutation": 0.9,
|
|
16287
|
+
"permission-boundary": 1
|
|
16288
|
+
}
|
|
16289
|
+
}
|
|
16290
|
+
};
|
|
16291
|
+
|
|
16082
16292
|
// src/agent-harness.ts
|
|
16293
|
+
var HARNESS_TEMPLATE_STATUSES = [
|
|
16294
|
+
"draft",
|
|
16295
|
+
"candidate",
|
|
16296
|
+
"release-candidate",
|
|
16297
|
+
"stable",
|
|
16298
|
+
"deprecated"
|
|
16299
|
+
];
|
|
16300
|
+
function requireRecord(value, context) {
|
|
16301
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
16302
|
+
throw new Error(`${context} must be an object.`);
|
|
16303
|
+
}
|
|
16304
|
+
return value;
|
|
16305
|
+
}
|
|
16306
|
+
function requiredString(record, key, context) {
|
|
16307
|
+
const value = record[key];
|
|
16308
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
16309
|
+
throw new Error(`${context}.${key} must be a non-empty string.`);
|
|
16310
|
+
}
|
|
16311
|
+
return value;
|
|
16312
|
+
}
|
|
16313
|
+
function requiredNumber(record, key, context) {
|
|
16314
|
+
const value = record[key];
|
|
16315
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
16316
|
+
throw new Error(`${context}.${key} must be a finite number.`);
|
|
16317
|
+
}
|
|
16318
|
+
return value;
|
|
16319
|
+
}
|
|
16320
|
+
function requiredStringArray(record, key, context) {
|
|
16321
|
+
const value = record[key];
|
|
16322
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== "string" || !item.trim())) {
|
|
16323
|
+
throw new Error(`${context}.${key} must be an array of non-empty strings.`);
|
|
16324
|
+
}
|
|
16325
|
+
return [...value];
|
|
16326
|
+
}
|
|
16327
|
+
function requiredNumberRecord(record, key, context) {
|
|
16328
|
+
const value = requireRecord(record[key], `${context}.${key}`);
|
|
16329
|
+
const output = {};
|
|
16330
|
+
for (const [entryKey, entryValue] of Object.entries(value)) {
|
|
16331
|
+
if (typeof entryValue !== "number" || !Number.isFinite(entryValue) || entryValue < 0 || entryValue > 1) {
|
|
16332
|
+
throw new Error(
|
|
16333
|
+
`${context}.${key}.${entryKey} must be a number between 0 and 1.`
|
|
16334
|
+
);
|
|
16335
|
+
}
|
|
16336
|
+
output[entryKey] = entryValue;
|
|
16337
|
+
}
|
|
16338
|
+
return output;
|
|
16339
|
+
}
|
|
16340
|
+
function validateHarnessTemplateManifest(value, context = "HarnessTemplateManifest") {
|
|
16341
|
+
const record = requireRecord(value, context);
|
|
16342
|
+
const status = requiredString(record, "status", context);
|
|
16343
|
+
if (!HARNESS_TEMPLATE_STATUSES.includes(status)) {
|
|
16344
|
+
throw new Error(
|
|
16345
|
+
`${context}.status must be one of ${HARNESS_TEMPLATE_STATUSES.join(", ")}.`
|
|
16346
|
+
);
|
|
16347
|
+
}
|
|
16348
|
+
const createdAt = requiredString(record, "createdAt", context);
|
|
16349
|
+
if (Number.isNaN(Date.parse(createdAt))) {
|
|
16350
|
+
throw new Error(`${context}.createdAt must be an ISO timestamp.`);
|
|
16351
|
+
}
|
|
16352
|
+
const compatibility = requireRecord(
|
|
16353
|
+
record.compatibility,
|
|
16354
|
+
`${context}.compatibility`
|
|
16355
|
+
);
|
|
16356
|
+
const evalGates = requireRecord(record.evalGates, `${context}.evalGates`);
|
|
16357
|
+
const maxRegressionPct = requiredNumber(
|
|
16358
|
+
evalGates,
|
|
16359
|
+
"maxRegressionPct",
|
|
16360
|
+
`${context}.evalGates`
|
|
16361
|
+
);
|
|
16362
|
+
if (maxRegressionPct < 0 || maxRegressionPct > 1) {
|
|
16363
|
+
throw new Error(
|
|
16364
|
+
`${context}.evalGates.maxRegressionPct must be between 0 and 1.`
|
|
16365
|
+
);
|
|
16366
|
+
}
|
|
16367
|
+
return {
|
|
16368
|
+
id: requiredString(record, "id", context),
|
|
16369
|
+
version: requiredString(record, "version", context),
|
|
16370
|
+
status,
|
|
16371
|
+
owner: requiredString(record, "owner", context),
|
|
16372
|
+
createdAt,
|
|
16373
|
+
changelog: requiredString(record, "changelog", context),
|
|
16374
|
+
promptBuilder: requiredString(record, "promptBuilder", context),
|
|
16375
|
+
continuationBuilder: requiredString(record, "continuationBuilder", context),
|
|
16376
|
+
modelOutputInstruction: requiredString(
|
|
16377
|
+
record,
|
|
16378
|
+
"modelOutputInstruction",
|
|
16379
|
+
context
|
|
16380
|
+
),
|
|
16381
|
+
codeReviewPolicy: requiredString(record, "codeReviewPolicy", context),
|
|
16382
|
+
defaultModel: requiredString(record, "defaultModel", context),
|
|
16383
|
+
modelMatrix: requiredStringArray(record, "modelMatrix", context),
|
|
16384
|
+
temperature: requiredNumber(record, "temperature", context),
|
|
16385
|
+
compatibility: {
|
|
16386
|
+
minSdkVersion: requiredString(
|
|
16387
|
+
compatibility,
|
|
16388
|
+
"minSdkVersion",
|
|
16389
|
+
`${context}.compatibility`
|
|
16390
|
+
),
|
|
16391
|
+
capabilities: requiredStringArray(
|
|
16392
|
+
compatibility,
|
|
16393
|
+
"capabilities",
|
|
16394
|
+
`${context}.compatibility`
|
|
16395
|
+
)
|
|
16396
|
+
},
|
|
16397
|
+
evalGates: {
|
|
16398
|
+
requiredSuites: requiredStringArray(
|
|
16399
|
+
evalGates,
|
|
16400
|
+
"requiredSuites",
|
|
16401
|
+
`${context}.evalGates`
|
|
16402
|
+
),
|
|
16403
|
+
criticalBuckets: requiredStringArray(
|
|
16404
|
+
evalGates,
|
|
16405
|
+
"criticalBuckets",
|
|
16406
|
+
`${context}.evalGates`
|
|
16407
|
+
),
|
|
16408
|
+
maxRegressionPct,
|
|
16409
|
+
minPassK: requiredNumberRecord(
|
|
16410
|
+
evalGates,
|
|
16411
|
+
"minPassK",
|
|
16412
|
+
`${context}.evalGates`
|
|
16413
|
+
)
|
|
16414
|
+
}
|
|
16415
|
+
};
|
|
16416
|
+
}
|
|
16417
|
+
function defineHarnessTemplateManifest(value, context) {
|
|
16418
|
+
return validateHarnessTemplateManifest(value, context);
|
|
16419
|
+
}
|
|
16083
16420
|
var DEFAULT_IGNORED_REASONING_COMMENT_DIRECTIVES = [
|
|
16084
16421
|
/^@ts-ignore\b/i,
|
|
16085
16422
|
/^@ts-expect-error\b/i,
|
|
@@ -16182,6 +16519,16 @@ function uniqueStrings(values, maxCount) {
|
|
|
16182
16519
|
}
|
|
16183
16520
|
return output;
|
|
16184
16521
|
}
|
|
16522
|
+
function stableStringify(value) {
|
|
16523
|
+
if (value === null || typeof value !== "object") {
|
|
16524
|
+
return JSON.stringify(value);
|
|
16525
|
+
}
|
|
16526
|
+
if (Array.isArray(value)) {
|
|
16527
|
+
return `[${value.map((entry) => stableStringify(entry)).join(",")}]`;
|
|
16528
|
+
}
|
|
16529
|
+
const record = value;
|
|
16530
|
+
return `{${Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${stableStringify(record[key])}`).join(",")}}`;
|
|
16531
|
+
}
|
|
16185
16532
|
function renderConstBlock(name, value) {
|
|
16186
16533
|
return `const ${name} = ${JSON.stringify(value, null, 2)} as const;`;
|
|
16187
16534
|
}
|
|
@@ -18126,6 +18473,194 @@ ${knownFactsBlock}
|
|
|
18126
18473
|
[Request]
|
|
18127
18474
|
${input.request?.trim() || "Use the latest user message in the conversation."}`;
|
|
18128
18475
|
}
|
|
18476
|
+
var STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST = defineHarnessTemplateManifest(
|
|
18477
|
+
manifest_default3,
|
|
18478
|
+
"stable@1.0.0 manifest"
|
|
18479
|
+
);
|
|
18480
|
+
function hashHarnessTemplateValue(value) {
|
|
18481
|
+
return hashString(stableStringify(value)) || "00000000";
|
|
18482
|
+
}
|
|
18483
|
+
function renderStableHarnessPrompt(input) {
|
|
18484
|
+
const prompt = buildGranularAgentSystemPrompt(input);
|
|
18485
|
+
const templateHash = hashHarnessTemplateValue(
|
|
18486
|
+
STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
18487
|
+
);
|
|
18488
|
+
return {
|
|
18489
|
+
templateId: STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
18490
|
+
templateVersion: STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
18491
|
+
templateHash,
|
|
18492
|
+
promptInstanceHash: hashHarnessTemplateValue({
|
|
18493
|
+
templateHash,
|
|
18494
|
+
input,
|
|
18495
|
+
prompt
|
|
18496
|
+
}),
|
|
18497
|
+
prompt
|
|
18498
|
+
};
|
|
18499
|
+
}
|
|
18500
|
+
function renderStableHarnessContinuation(resultPreview) {
|
|
18501
|
+
const instruction = buildContinuationInstruction(resultPreview);
|
|
18502
|
+
const templateHash = hashHarnessTemplateValue(
|
|
18503
|
+
STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
18504
|
+
);
|
|
18505
|
+
return {
|
|
18506
|
+
templateId: STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
18507
|
+
templateVersion: STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
18508
|
+
templateHash,
|
|
18509
|
+
instruction
|
|
18510
|
+
};
|
|
18511
|
+
}
|
|
18512
|
+
var STABLE_AGENT_HARNESS_TEMPLATE = {
|
|
18513
|
+
manifest: STABLE_AGENT_HARNESS_TEMPLATE_MANIFEST,
|
|
18514
|
+
renderPrompt: renderStableHarnessPrompt,
|
|
18515
|
+
renderContinuation: renderStableHarnessContinuation
|
|
18516
|
+
};
|
|
18517
|
+
var EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST = defineHarnessTemplateManifest(
|
|
18518
|
+
manifest_default2,
|
|
18519
|
+
"experimental-compact@0.1.0 manifest"
|
|
18520
|
+
);
|
|
18521
|
+
function renderExperimentalCompactHarnessPrompt(input) {
|
|
18522
|
+
const prompt = `${buildGranularAgentSystemPrompt(input)}
|
|
18523
|
+
|
|
18524
|
+
[Candidate Harness Delta: Compact Decision Discipline]
|
|
18525
|
+
- Prefer the smallest action that satisfies the current request.
|
|
18526
|
+
- When several records could match, ask one structured choice question before mutating.
|
|
18527
|
+
- Before any irreversible or outbound mutation, obtain explicit confirmation unless the policy surface already requires it.
|
|
18528
|
+
- Do not compensate for missing tools with raw network calls, synthetic records, or hidden side channels.
|
|
18529
|
+
- Keep the final user-facing reply focused on what was done, what was not done, and any remaining blocker.`;
|
|
18530
|
+
const templateHash = hashHarnessTemplateValue(
|
|
18531
|
+
EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
18532
|
+
);
|
|
18533
|
+
return {
|
|
18534
|
+
templateId: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
18535
|
+
templateVersion: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
18536
|
+
templateHash,
|
|
18537
|
+
promptInstanceHash: hashHarnessTemplateValue({
|
|
18538
|
+
templateHash,
|
|
18539
|
+
input,
|
|
18540
|
+
prompt
|
|
18541
|
+
}),
|
|
18542
|
+
prompt
|
|
18543
|
+
};
|
|
18544
|
+
}
|
|
18545
|
+
function renderExperimentalCompactHarnessContinuation(resultPreview) {
|
|
18546
|
+
const instruction = `${buildContinuationInstruction(resultPreview)}
|
|
18547
|
+
|
|
18548
|
+
Keep the continuation compact: either finish, ask the one blocking question, or run the next smallest safe action.`;
|
|
18549
|
+
const templateHash = hashHarnessTemplateValue(
|
|
18550
|
+
EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
18551
|
+
);
|
|
18552
|
+
return {
|
|
18553
|
+
templateId: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
18554
|
+
templateVersion: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
18555
|
+
templateHash,
|
|
18556
|
+
instruction
|
|
18557
|
+
};
|
|
18558
|
+
}
|
|
18559
|
+
var EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE = {
|
|
18560
|
+
manifest: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE_MANIFEST,
|
|
18561
|
+
renderPrompt: renderExperimentalCompactHarnessPrompt,
|
|
18562
|
+
renderContinuation: renderExperimentalCompactHarnessContinuation
|
|
18563
|
+
};
|
|
18564
|
+
var ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST = defineHarnessTemplateManifest(
|
|
18565
|
+
manifest_default,
|
|
18566
|
+
"action-presentation@0.1.0 manifest"
|
|
18567
|
+
);
|
|
18568
|
+
function renderActionPresentationHarnessPrompt(input) {
|
|
18569
|
+
const prompt = `${buildGranularAgentSystemPrompt(input)}
|
|
18570
|
+
|
|
18571
|
+
[Candidate Harness Delta: Action Request And Result Presentation]
|
|
18572
|
+
- 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.
|
|
18573
|
+
- 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.
|
|
18574
|
+
- 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.
|
|
18575
|
+
- After a mutation/effect call, base the reply on the returned action result and include a visible target label or identifier when one exists.
|
|
18576
|
+
- If no target can be grounded, say what was searched and what exact identifier or choice is needed; do not pretend the action completed.`;
|
|
18577
|
+
const templateHash = hashHarnessTemplateValue(
|
|
18578
|
+
ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
18579
|
+
);
|
|
18580
|
+
return {
|
|
18581
|
+
templateId: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
18582
|
+
templateVersion: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
18583
|
+
templateHash,
|
|
18584
|
+
promptInstanceHash: hashHarnessTemplateValue({
|
|
18585
|
+
templateHash,
|
|
18586
|
+
input,
|
|
18587
|
+
prompt
|
|
18588
|
+
}),
|
|
18589
|
+
prompt
|
|
18590
|
+
};
|
|
18591
|
+
}
|
|
18592
|
+
function renderActionPresentationHarnessContinuation(resultPreview) {
|
|
18593
|
+
const instruction = `${buildContinuationInstruction(resultPreview)}
|
|
18594
|
+
|
|
18595
|
+
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.`;
|
|
18596
|
+
const templateHash = hashHarnessTemplateValue(
|
|
18597
|
+
ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST
|
|
18598
|
+
);
|
|
18599
|
+
return {
|
|
18600
|
+
templateId: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST.id,
|
|
18601
|
+
templateVersion: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST.version,
|
|
18602
|
+
templateHash,
|
|
18603
|
+
instruction
|
|
18604
|
+
};
|
|
18605
|
+
}
|
|
18606
|
+
var ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE = {
|
|
18607
|
+
manifest: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE_MANIFEST,
|
|
18608
|
+
renderPrompt: renderActionPresentationHarnessPrompt,
|
|
18609
|
+
renderContinuation: renderActionPresentationHarnessContinuation
|
|
18610
|
+
};
|
|
18611
|
+
var AGENT_HARNESS_TEMPLATES = {
|
|
18612
|
+
[STABLE_AGENT_HARNESS_TEMPLATE.manifest.id]: STABLE_AGENT_HARNESS_TEMPLATE,
|
|
18613
|
+
[EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE.manifest.id]: EXPERIMENTAL_COMPACT_AGENT_HARNESS_TEMPLATE,
|
|
18614
|
+
[ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE.manifest.id]: ACTION_PRESENTATION_AGENT_HARNESS_TEMPLATE
|
|
18615
|
+
};
|
|
18616
|
+
function listHarnessTemplates() {
|
|
18617
|
+
return Object.values(AGENT_HARNESS_TEMPLATES).map((template) => ({
|
|
18618
|
+
...template.manifest,
|
|
18619
|
+
compatibility: { ...template.manifest.compatibility },
|
|
18620
|
+
evalGates: {
|
|
18621
|
+
...template.manifest.evalGates,
|
|
18622
|
+
minPassK: { ...template.manifest.evalGates.minPassK }
|
|
18623
|
+
}
|
|
18624
|
+
}));
|
|
18625
|
+
}
|
|
18626
|
+
function resolveHarnessTemplate(templateId = "stable", options) {
|
|
18627
|
+
const resolved = AGENT_HARNESS_TEMPLATES[templateId];
|
|
18628
|
+
if (resolved) return resolved;
|
|
18629
|
+
if (options?.strict) {
|
|
18630
|
+
const known = Object.keys(AGENT_HARNESS_TEMPLATES).join(", ");
|
|
18631
|
+
throw new Error(
|
|
18632
|
+
`Unknown harness template "${templateId}". Known templates: ${known}`
|
|
18633
|
+
);
|
|
18634
|
+
}
|
|
18635
|
+
return STABLE_AGENT_HARNESS_TEMPLATE;
|
|
18636
|
+
}
|
|
18637
|
+
function getDefaultHarnessTemplateId() {
|
|
18638
|
+
if (typeof process !== "undefined") {
|
|
18639
|
+
const configured = process.env.GRANULAR_AGENT_HARNESS_TEMPLATE || process.env.NEXT_PUBLIC_GRANULAR_AGENT_HARNESS_TEMPLATE;
|
|
18640
|
+
if (configured?.trim()) return configured.trim();
|
|
18641
|
+
}
|
|
18642
|
+
return "stable";
|
|
18643
|
+
}
|
|
18644
|
+
function renderGranularAgentSystemPromptFromTemplate(input, options) {
|
|
18645
|
+
const template = resolveHarnessTemplate(
|
|
18646
|
+
options?.templateId || getDefaultHarnessTemplateId(),
|
|
18647
|
+
{ strict: options?.strict ?? true }
|
|
18648
|
+
);
|
|
18649
|
+
return template.renderPrompt(input);
|
|
18650
|
+
}
|
|
18651
|
+
function buildGranularAgentSystemPromptFromTemplate(input, options) {
|
|
18652
|
+
return renderGranularAgentSystemPromptFromTemplate(input, options).prompt;
|
|
18653
|
+
}
|
|
18654
|
+
function renderContinuationInstructionFromTemplate(resultPreview, options) {
|
|
18655
|
+
const template = resolveHarnessTemplate(
|
|
18656
|
+
options?.templateId || getDefaultHarnessTemplateId(),
|
|
18657
|
+
{ strict: options?.strict ?? true }
|
|
18658
|
+
);
|
|
18659
|
+
return template.renderContinuation(resultPreview);
|
|
18660
|
+
}
|
|
18661
|
+
function buildContinuationInstructionFromTemplate(resultPreview, options) {
|
|
18662
|
+
return renderContinuationInstructionFromTemplate(resultPreview, options).instruction;
|
|
18663
|
+
}
|
|
18129
18664
|
|
|
18130
18665
|
// src/openai-usage.ts
|
|
18131
18666
|
var OPENAI_PRICING_SOURCE_URL = "https://developers.openai.com/api/docs/models/gpt-5.4/";
|
|
@@ -18230,6 +18765,7 @@ exports.OntologyHandle = OntologyHandle;
|
|
|
18230
18765
|
exports.Session = Session;
|
|
18231
18766
|
exports.WSClient = WSClient;
|
|
18232
18767
|
exports.buildContinuationInstruction = buildContinuationInstruction;
|
|
18768
|
+
exports.buildContinuationInstructionFromTemplate = buildContinuationInstructionFromTemplate;
|
|
18233
18769
|
exports.buildGranularAgentCheckpointBlock = buildGranularAgentCheckpointBlock;
|
|
18234
18770
|
exports.buildGranularAgentDomainBlock = buildGranularAgentDomainBlock;
|
|
18235
18771
|
exports.buildGranularAgentFileBlock = buildGranularAgentFileBlock;
|
|
@@ -18239,6 +18775,7 @@ exports.buildGranularAgentReferentBlock = buildGranularAgentReferentBlock;
|
|
|
18239
18775
|
exports.buildGranularAgentRuntimeImportsBlock = buildGranularAgentRuntimeImportsBlock;
|
|
18240
18776
|
exports.buildGranularAgentSessionBlock = buildGranularAgentSessionBlock;
|
|
18241
18777
|
exports.buildGranularAgentSystemPrompt = buildGranularAgentSystemPrompt;
|
|
18778
|
+
exports.buildGranularAgentSystemPromptFromTemplate = buildGranularAgentSystemPromptFromTemplate;
|
|
18242
18779
|
exports.buildGranularAgentToolBlock = buildGranularAgentToolBlock;
|
|
18243
18780
|
exports.buildGranularAgentWorkflowBlock = buildGranularAgentWorkflowBlock;
|
|
18244
18781
|
exports.buildOpenAISpendEventId = buildOpenAISpendEventId;
|
|
@@ -18250,11 +18787,14 @@ exports.createHarnessVerifierSnapshot = createHarnessVerifierSnapshot;
|
|
|
18250
18787
|
exports.evaluateContinuation = evaluateContinuation;
|
|
18251
18788
|
exports.extractPromptTokens = extractPromptTokens;
|
|
18252
18789
|
exports.getCurrentClosureId = getCurrentClosureId;
|
|
18790
|
+
exports.getDefaultHarnessTemplateId = getDefaultHarnessTemplateId;
|
|
18253
18791
|
exports.getExclusivePromptTarget = getExclusivePromptTarget;
|
|
18254
18792
|
exports.getOpenAIModelPricing = getOpenAIModelPricing;
|
|
18255
18793
|
exports.hasOpenPrompt = hasOpenPrompt;
|
|
18794
|
+
exports.hashHarnessTemplateValue = hashHarnessTemplateValue;
|
|
18256
18795
|
exports.invokeRegisteredEffect = invokeRegisteredEffect;
|
|
18257
18796
|
exports.isLocalApiUrl = isLocalApiUrl;
|
|
18797
|
+
exports.listHarnessTemplates = listHarnessTemplates;
|
|
18258
18798
|
exports.normalizeEffectBehaviors = normalizeEffectBehaviors;
|
|
18259
18799
|
exports.normalizeOpenAIUsage = normalizeOpenAIUsage;
|
|
18260
18800
|
exports.normalizePrompt = normalizePrompt;
|
|
@@ -18269,13 +18809,17 @@ exports.projectSessionFileSummary = projectSessionFileSummary;
|
|
|
18269
18809
|
exports.projectWorkflowFocus = projectWorkflowFocus;
|
|
18270
18810
|
exports.projectWorkflowSummary = projectWorkflowSummary;
|
|
18271
18811
|
exports.recordOpenAIUsageSpend = recordOpenAIUsageSpend;
|
|
18812
|
+
exports.renderContinuationInstructionFromTemplate = renderContinuationInstructionFromTemplate;
|
|
18813
|
+
exports.renderGranularAgentSystemPromptFromTemplate = renderGranularAgentSystemPromptFromTemplate;
|
|
18272
18814
|
exports.resolveApiUrl = resolveApiUrl;
|
|
18273
18815
|
exports.resolveAuthTokenForApiUrl = resolveAuthTokenForApiUrl;
|
|
18816
|
+
exports.resolveHarnessTemplate = resolveHarnessTemplate;
|
|
18274
18817
|
exports.resolveJobPresentation = resolveJobPresentation;
|
|
18275
18818
|
exports.resolvePromptAnswer = resolvePromptAnswer;
|
|
18276
18819
|
exports.reviewGeneratedJobCode = reviewGeneratedJobCode;
|
|
18277
18820
|
exports.scorePromptChoiceMatch = scorePromptChoiceMatch;
|
|
18278
18821
|
exports.stripGranularReasoningTrace = stripGranularReasoningTrace;
|
|
18279
18822
|
exports.toGranularHttpBase = toGranularHttpBase;
|
|
18823
|
+
exports.validateHarnessTemplateManifest = validateHarnessTemplateManifest;
|
|
18280
18824
|
//# sourceMappingURL=index.js.map
|
|
18281
18825
|
//# sourceMappingURL=index.js.map
|