replicas-engine 0.1.1118 → 0.1.1119
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/src/{asp-host-NAVM3BKA.js → asp-host-N4MQTNQU.js} +5 -5
- package/dist/src/{chunk-Z5TOQDLX.js → chunk-4LTXGBOS.js} +1 -1
- package/dist/src/{chunk-P22VSOED.js → chunk-AG62XLHV.js} +2 -2
- package/dist/src/{chunk-MTP3S2LT.js → chunk-DW4DQJGC.js} +1 -380
- package/dist/src/{chunk-Y47Q737L.js → chunk-E7J3EX2P.js} +2 -2
- package/dist/src/{chunk-FPITB6MD.js → chunk-HYGB363T.js} +2 -2
- package/dist/src/{chunk-HVWDNPHT.js → chunk-LLUMENUN.js} +6 -6
- package/dist/src/{chunk-KYXXP4IF.js → chunk-SEIA4JEW.js} +1 -1
- package/dist/src/{chunk-XL7SGQND.js → chunk-ZBDWFK5J.js} +3 -3
- package/dist/src/command-protection-hook.js +4 -4
- package/dist/src/headless-agent.js +4 -4
- package/dist/src/index.js +155 -287
- package/dist/src/post-tool-pr-hook.js +2 -2
- package/dist/src/subagent-mcp.js +1 -1
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
evaluateCommandProtection,
|
|
28
28
|
extractToolCommand,
|
|
29
29
|
reportCommandProtectionBlock
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-E7J3EX2P.js";
|
|
31
31
|
import {
|
|
32
32
|
ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
|
|
33
33
|
AGENT_MESSAGE_DELTA_METHOD,
|
|
@@ -64,10 +64,10 @@ import {
|
|
|
64
64
|
spawnMuseMsp,
|
|
65
65
|
startMuseSession,
|
|
66
66
|
uuidV7
|
|
67
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-HYGB363T.js";
|
|
68
68
|
import {
|
|
69
69
|
publishedPullRequestUrls
|
|
70
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-4LTXGBOS.js";
|
|
71
71
|
import {
|
|
72
72
|
ACCOUNT_RATE_LIMITS_READ_METHOD,
|
|
73
73
|
AsyncLock,
|
|
@@ -130,7 +130,7 @@ import {
|
|
|
130
130
|
timestampFromSeconds,
|
|
131
131
|
upsertCredentialFileLines,
|
|
132
132
|
writeSecureCredentialFile
|
|
133
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-LLUMENUN.js";
|
|
134
134
|
import {
|
|
135
135
|
ENGINE_ENV,
|
|
136
136
|
monolithRequest,
|
|
@@ -139,15 +139,15 @@ import {
|
|
|
139
139
|
reloadEngineEnv,
|
|
140
140
|
resolveDiffBase,
|
|
141
141
|
setAgentCredentialSnapshot
|
|
142
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-AG62XLHV.js";
|
|
143
143
|
import {
|
|
144
144
|
getCodexModelProvider
|
|
145
|
-
} from "./chunk-
|
|
145
|
+
} from "./chunk-ZBDWFK5J.js";
|
|
146
146
|
import {
|
|
147
147
|
SUBPROCESS_MAX_BUFFER,
|
|
148
148
|
execAsync,
|
|
149
149
|
execFileAsync
|
|
150
|
-
} from "./chunk-
|
|
150
|
+
} from "./chunk-SEIA4JEW.js";
|
|
151
151
|
import {
|
|
152
152
|
isRecord as isRecord2
|
|
153
153
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -268,7 +268,6 @@ import {
|
|
|
268
268
|
createUuidFromHex,
|
|
269
269
|
defaultForkChatTitle,
|
|
270
270
|
describeCredential,
|
|
271
|
-
describeMessageSteps,
|
|
272
271
|
describeQuotaLimit,
|
|
273
272
|
detectAgentQuotaLimit,
|
|
274
273
|
detectEnvironmentAuthMethod,
|
|
@@ -347,7 +346,6 @@ import {
|
|
|
347
346
|
parseMcpToolName,
|
|
348
347
|
parseReplicasConfigString,
|
|
349
348
|
percentage,
|
|
350
|
-
planItemsFromMessage,
|
|
351
349
|
raceWithTimeout,
|
|
352
350
|
readJsonlAppended,
|
|
353
351
|
readJsonlPage,
|
|
@@ -375,7 +373,7 @@ import {
|
|
|
375
373
|
workspaceTokenRequestSchema,
|
|
376
374
|
workspaceTokenResponseSchema,
|
|
377
375
|
wrapInTag
|
|
378
|
-
} from "./chunk-
|
|
376
|
+
} from "./chunk-DW4DQJGC.js";
|
|
379
377
|
import {
|
|
380
378
|
cloneMcpConfig,
|
|
381
379
|
ensureCompatibilityImports,
|
|
@@ -962,9 +960,9 @@ var require_code2 = __commonJS({
|
|
|
962
960
|
};
|
|
963
961
|
exports.Name = Name;
|
|
964
962
|
var _Code = class extends _CodeOrName {
|
|
965
|
-
constructor(
|
|
963
|
+
constructor(code) {
|
|
966
964
|
super();
|
|
967
|
-
this._items = typeof
|
|
965
|
+
this._items = typeof code === "string" ? [code] : code;
|
|
968
966
|
}
|
|
969
967
|
toString() {
|
|
970
968
|
return this.str;
|
|
@@ -991,13 +989,13 @@ var require_code2 = __commonJS({
|
|
|
991
989
|
exports._Code = _Code;
|
|
992
990
|
exports.nil = new _Code("");
|
|
993
991
|
function _(strs, ...args) {
|
|
994
|
-
const
|
|
992
|
+
const code = [strs[0]];
|
|
995
993
|
let i = 0;
|
|
996
994
|
while (i < args.length) {
|
|
997
|
-
addCodeArg(
|
|
998
|
-
|
|
995
|
+
addCodeArg(code, args[i]);
|
|
996
|
+
code.push(strs[++i]);
|
|
999
997
|
}
|
|
1000
|
-
return new _Code(
|
|
998
|
+
return new _Code(code);
|
|
1001
999
|
}
|
|
1002
1000
|
exports._ = _;
|
|
1003
1001
|
var plus = new _Code("+");
|
|
@@ -1013,13 +1011,13 @@ var require_code2 = __commonJS({
|
|
|
1013
1011
|
return new _Code(expr);
|
|
1014
1012
|
}
|
|
1015
1013
|
exports.str = str;
|
|
1016
|
-
function addCodeArg(
|
|
1014
|
+
function addCodeArg(code, arg) {
|
|
1017
1015
|
if (arg instanceof _Code)
|
|
1018
|
-
|
|
1016
|
+
code.push(...arg._items);
|
|
1019
1017
|
else if (arg instanceof Name)
|
|
1020
|
-
|
|
1018
|
+
code.push(arg);
|
|
1021
1019
|
else
|
|
1022
|
-
|
|
1020
|
+
code.push(interpolate(arg));
|
|
1023
1021
|
}
|
|
1024
1022
|
exports.addCodeArg = addCodeArg;
|
|
1025
1023
|
function optimize(expr) {
|
|
@@ -1203,7 +1201,7 @@ var require_scope2 = __commonJS({
|
|
|
1203
1201
|
}, usedValues, getCode);
|
|
1204
1202
|
}
|
|
1205
1203
|
_reduceValues(values, valueCode, usedValues = {}, getCode) {
|
|
1206
|
-
let
|
|
1204
|
+
let code = code_1.nil;
|
|
1207
1205
|
for (const prefix in values) {
|
|
1208
1206
|
const vs = values[prefix];
|
|
1209
1207
|
if (!vs)
|
|
@@ -1216,16 +1214,16 @@ var require_scope2 = __commonJS({
|
|
|
1216
1214
|
let c = valueCode(name);
|
|
1217
1215
|
if (c) {
|
|
1218
1216
|
const def = this.opts.es5 ? exports.varKinds.var : exports.varKinds.const;
|
|
1219
|
-
|
|
1217
|
+
code = (0, code_1._)`${code}${def} ${name} = ${c};${this.opts._n}`;
|
|
1220
1218
|
} else if (c = getCode === null || getCode === void 0 ? void 0 : getCode(name)) {
|
|
1221
|
-
|
|
1219
|
+
code = (0, code_1._)`${code}${c}${this.opts._n}`;
|
|
1222
1220
|
} else {
|
|
1223
1221
|
throw new ValueError(name);
|
|
1224
1222
|
}
|
|
1225
1223
|
nameSet.set(name, UsedValueState.Completed);
|
|
1226
1224
|
});
|
|
1227
1225
|
}
|
|
1228
|
-
return
|
|
1226
|
+
return code;
|
|
1229
1227
|
}
|
|
1230
1228
|
};
|
|
1231
1229
|
exports.ValueScope = ValueScope;
|
|
@@ -1385,9 +1383,9 @@ var require_codegen2 = __commonJS({
|
|
|
1385
1383
|
}
|
|
1386
1384
|
};
|
|
1387
1385
|
var AnyCode = class extends Node {
|
|
1388
|
-
constructor(
|
|
1386
|
+
constructor(code) {
|
|
1389
1387
|
super();
|
|
1390
|
-
this.code =
|
|
1388
|
+
this.code = code;
|
|
1391
1389
|
}
|
|
1392
1390
|
render({ _n }) {
|
|
1393
1391
|
return `${this.code};` + _n;
|
|
@@ -1409,7 +1407,7 @@ var require_codegen2 = __commonJS({
|
|
|
1409
1407
|
this.nodes = nodes;
|
|
1410
1408
|
}
|
|
1411
1409
|
render(opts) {
|
|
1412
|
-
return this.nodes.reduce((
|
|
1410
|
+
return this.nodes.reduce((code, n) => code + n.render(opts), "");
|
|
1413
1411
|
}
|
|
1414
1412
|
optimizeNodes() {
|
|
1415
1413
|
const { nodes } = this;
|
|
@@ -1457,10 +1455,10 @@ var require_codegen2 = __commonJS({
|
|
|
1457
1455
|
this.condition = condition;
|
|
1458
1456
|
}
|
|
1459
1457
|
render(opts) {
|
|
1460
|
-
let
|
|
1458
|
+
let code = `if(${this.condition})` + super.render(opts);
|
|
1461
1459
|
if (this.else)
|
|
1462
|
-
|
|
1463
|
-
return
|
|
1460
|
+
code += "else " + this.else.render(opts);
|
|
1461
|
+
return code;
|
|
1464
1462
|
}
|
|
1465
1463
|
optimizeNodes() {
|
|
1466
1464
|
super.optimizeNodes();
|
|
@@ -1581,12 +1579,12 @@ var require_codegen2 = __commonJS({
|
|
|
1581
1579
|
Return.kind = "return";
|
|
1582
1580
|
var Try = class extends BlockNode {
|
|
1583
1581
|
render(opts) {
|
|
1584
|
-
let
|
|
1582
|
+
let code = "try" + super.render(opts);
|
|
1585
1583
|
if (this.catch)
|
|
1586
|
-
|
|
1584
|
+
code += this.catch.render(opts);
|
|
1587
1585
|
if (this.finally)
|
|
1588
|
-
|
|
1589
|
-
return
|
|
1586
|
+
code += this.finally.render(opts);
|
|
1587
|
+
return code;
|
|
1590
1588
|
}
|
|
1591
1589
|
optimizeNodes() {
|
|
1592
1590
|
var _a, _b;
|
|
@@ -1703,18 +1701,18 @@ var require_codegen2 = __commonJS({
|
|
|
1703
1701
|
}
|
|
1704
1702
|
// returns code for object literal for the passed argument list of key-value pairs
|
|
1705
1703
|
object(...keyValues) {
|
|
1706
|
-
const
|
|
1704
|
+
const code = ["{"];
|
|
1707
1705
|
for (const [key, value] of keyValues) {
|
|
1708
|
-
if (
|
|
1709
|
-
|
|
1710
|
-
|
|
1706
|
+
if (code.length > 1)
|
|
1707
|
+
code.push(",");
|
|
1708
|
+
code.push(key);
|
|
1711
1709
|
if (key !== value || this.opts.es5) {
|
|
1712
|
-
|
|
1713
|
-
(0, code_1.addCodeArg)(
|
|
1710
|
+
code.push(":");
|
|
1711
|
+
(0, code_1.addCodeArg)(code, value);
|
|
1714
1712
|
}
|
|
1715
1713
|
}
|
|
1716
|
-
|
|
1717
|
-
return new code_1._Code(
|
|
1714
|
+
code.push("}");
|
|
1715
|
+
return new code_1._Code(code);
|
|
1718
1716
|
}
|
|
1719
1717
|
// `if` clause (or statement if `thenBody` and, optionally, `elseBody` are passed)
|
|
1720
1718
|
if(condition, thenBody, elseBody) {
|
|
@@ -4014,22 +4012,22 @@ var require_utils2 = __commonJS({
|
|
|
4014
4012
|
var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
|
|
4015
4013
|
function stringArrayToHexStripped(input) {
|
|
4016
4014
|
let acc = "";
|
|
4017
|
-
let
|
|
4015
|
+
let code = 0;
|
|
4018
4016
|
let i = 0;
|
|
4019
4017
|
for (i = 0; i < input.length; i++) {
|
|
4020
|
-
|
|
4021
|
-
if (
|
|
4018
|
+
code = input[i].charCodeAt(0);
|
|
4019
|
+
if (code === 48) {
|
|
4022
4020
|
continue;
|
|
4023
4021
|
}
|
|
4024
|
-
if (!(
|
|
4022
|
+
if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) {
|
|
4025
4023
|
return "";
|
|
4026
4024
|
}
|
|
4027
4025
|
acc += input[i];
|
|
4028
4026
|
break;
|
|
4029
4027
|
}
|
|
4030
4028
|
for (i += 1; i < input.length; i++) {
|
|
4031
|
-
|
|
4032
|
-
if (!(
|
|
4029
|
+
code = input[i].charCodeAt(0);
|
|
4030
|
+
if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) {
|
|
4033
4031
|
return "";
|
|
4034
4032
|
}
|
|
4035
4033
|
acc += input[i];
|
|
@@ -7048,8 +7046,8 @@ var require_format2 = __commonJS({
|
|
|
7048
7046
|
}
|
|
7049
7047
|
}
|
|
7050
7048
|
function getFormat(fmtDef) {
|
|
7051
|
-
const
|
|
7052
|
-
const fmt = gen.scopeValue("formats", { key: schema, ref: fmtDef, code
|
|
7049
|
+
const code = fmtDef instanceof RegExp ? (0, codegen_1.regexpCode)(fmtDef) : opts.code.formats ? (0, codegen_1._)`${opts.code.formats}${(0, codegen_1.getProperty)(schema)}` : void 0;
|
|
7050
|
+
const fmt = gen.scopeValue("formats", { key: schema, ref: fmtDef, code });
|
|
7053
7051
|
if (typeof fmtDef == "object" && !(fmtDef instanceof RegExp)) {
|
|
7054
7052
|
return [fmtDef.type || "string", fmtDef.validate, (0, codegen_1._)`${fmt}.validate`];
|
|
7055
7053
|
}
|
|
@@ -10003,9 +10001,9 @@ var ReplicasConfigService = class {
|
|
|
10003
10001
|
};
|
|
10004
10002
|
proc.stdout.on("data", (data) => handleData(data, "stdout"));
|
|
10005
10003
|
proc.stderr.on("data", (data) => handleData(data, "stderr"));
|
|
10006
|
-
proc.on("close", (
|
|
10004
|
+
proc.on("close", (code) => {
|
|
10007
10005
|
clearTimeout(timer);
|
|
10008
|
-
const exitCode = bufferExceeded ? 1 :
|
|
10006
|
+
const exitCode = bufferExceeded ? 1 : code ?? 1;
|
|
10009
10007
|
if (exitCode !== 0) {
|
|
10010
10008
|
const reason = timedOut ? "timed out" : `exited with code ${exitCode}`;
|
|
10011
10009
|
const message = `[ERROR] ${params.label} failed: ${reason}
|
|
@@ -15249,8 +15247,8 @@ var CURSOR_AUTH_ERROR_CODES = [
|
|
|
15249
15247
|
"bad_user_api_key"
|
|
15250
15248
|
];
|
|
15251
15249
|
var CURSOR_AUTH_ERROR_TEXT_PATTERN = new RegExp(`\\berror_(${CURSOR_AUTH_ERROR_CODES.join("|")})\\b`);
|
|
15252
|
-
function isCursorAuthenticationError(
|
|
15253
|
-
return CURSOR_AUTH_ERROR_CODES.includes(
|
|
15250
|
+
function isCursorAuthenticationError(code, text) {
|
|
15251
|
+
return CURSOR_AUTH_ERROR_CODES.includes(code?.toLowerCase().replace(/^error_/, "") ?? "") || CURSOR_AUTH_ERROR_TEXT_PATTERN.test(text.toLowerCase());
|
|
15254
15252
|
}
|
|
15255
15253
|
function finiteNumber(value) {
|
|
15256
15254
|
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
@@ -15520,14 +15518,14 @@ var CursorManager = class extends CodingAgentManager {
|
|
|
15520
15518
|
} catch (error) {
|
|
15521
15519
|
await this.cancelRun(run);
|
|
15522
15520
|
const text = extractErrorText(error) || "Cursor run failed";
|
|
15523
|
-
const
|
|
15521
|
+
const code = error instanceof CursorSdkError ? error.code : void 0;
|
|
15524
15522
|
failure = {
|
|
15525
15523
|
text,
|
|
15526
|
-
...
|
|
15524
|
+
...code ? { code } : {},
|
|
15527
15525
|
...run ? { runId: run.id } : {},
|
|
15528
15526
|
...run?.requestId ? { requestId: run.requestId } : {},
|
|
15529
15527
|
transport: isCursorTransportError(text),
|
|
15530
|
-
authentication: error instanceof AuthenticationError || isCursorAuthenticationError(
|
|
15528
|
+
authentication: error instanceof AuthenticationError || isCursorAuthenticationError(code, text)
|
|
15531
15529
|
};
|
|
15532
15530
|
}
|
|
15533
15531
|
if (agent && sawCursorActivity) await this.retainThread(agent.agentId);
|
|
@@ -15719,9 +15717,9 @@ var MuseManager = class extends CodingAgentManager {
|
|
|
15719
15717
|
});
|
|
15720
15718
|
child.stderr.on("data", (chunk) => console.error("[muse MSP]", chunk.toString().trimEnd()));
|
|
15721
15719
|
child.on("error", (error) => this.handleProcessExit(child, error));
|
|
15722
|
-
child.on("exit", (
|
|
15720
|
+
child.on("exit", (code, signal) => this.handleProcessExit(
|
|
15723
15721
|
child,
|
|
15724
|
-
new Error(`Muse MSP exited with code ${
|
|
15722
|
+
new Error(`Muse MSP exited with code ${code ?? signal}`)
|
|
15725
15723
|
));
|
|
15726
15724
|
await initializeMuse(client, "replicas", 0);
|
|
15727
15725
|
if (this.sessionId) {
|
|
@@ -16273,12 +16271,12 @@ function opencodeErrorMessage(error) {
|
|
|
16273
16271
|
}
|
|
16274
16272
|
function opencodeErrorPayload(error) {
|
|
16275
16273
|
const message = opencodeErrorMessage(error) ?? String(error);
|
|
16276
|
-
const
|
|
16274
|
+
const code = typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" ? error.code : void 0;
|
|
16277
16275
|
const cause = error instanceof Error && isRecord2(error.cause) ? error.cause : null;
|
|
16278
16276
|
const status = typeof cause?.status === "number" ? cause.status : void 0;
|
|
16279
16277
|
return {
|
|
16280
|
-
message:
|
|
16281
|
-
...
|
|
16278
|
+
message: code === "ENOENT" ? `Failed to start Opencode server binary (${message}).` : message,
|
|
16279
|
+
...code ? { code } : {},
|
|
16282
16280
|
...status !== void 0 ? { status } : {}
|
|
16283
16281
|
};
|
|
16284
16282
|
}
|
|
@@ -22766,9 +22764,9 @@ var OAuthError = class OAuthError2 extends Error {
|
|
|
22766
22764
|
if (typeof this !== "function") throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");
|
|
22767
22765
|
return brandedHasInstance(this, value);
|
|
22768
22766
|
}
|
|
22769
|
-
constructor(
|
|
22767
|
+
constructor(code, message, errorUri) {
|
|
22770
22768
|
super(message);
|
|
22771
|
-
this.code =
|
|
22769
|
+
this.code = code;
|
|
22772
22770
|
this.errorUri = errorUri;
|
|
22773
22771
|
this.name = "OAuthError";
|
|
22774
22772
|
stampErrorBrands(this, new.target);
|
|
@@ -22833,9 +22831,9 @@ var SdkError = class extends Error {
|
|
|
22833
22831
|
if (typeof this !== "function") throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");
|
|
22834
22832
|
return brandedHasInstance(this, value);
|
|
22835
22833
|
}
|
|
22836
|
-
constructor(
|
|
22834
|
+
constructor(code, message, data) {
|
|
22837
22835
|
super(message);
|
|
22838
|
-
this.code =
|
|
22836
|
+
this.code = code;
|
|
22839
22837
|
this.data = data;
|
|
22840
22838
|
this.name = "SdkError";
|
|
22841
22839
|
stampErrorBrands(this, new.target);
|
|
@@ -22845,8 +22843,8 @@ var SdkHttpError = class extends SdkError {
|
|
|
22845
22843
|
static {
|
|
22846
22844
|
Object.defineProperty(this, "mcpBrand", { value: "mcp.SdkHttpError" });
|
|
22847
22845
|
}
|
|
22848
|
-
constructor(
|
|
22849
|
-
super(
|
|
22846
|
+
constructor(code, message, data) {
|
|
22847
|
+
super(code, message, data);
|
|
22850
22848
|
this.name = "SdkHttpError";
|
|
22851
22849
|
}
|
|
22852
22850
|
get status() {
|
|
@@ -24052,7 +24050,7 @@ var rev2025Codec = {
|
|
|
24052
24050
|
} : t)
|
|
24053
24051
|
};
|
|
24054
24052
|
},
|
|
24055
|
-
encodeErrorCode: (
|
|
24053
|
+
encodeErrorCode: (code) => code === -32002 ? -32602 : code,
|
|
24056
24054
|
checkInboundEnvelope: (_material) => void 0
|
|
24057
24055
|
};
|
|
24058
24056
|
function build() {
|
|
@@ -24984,9 +24982,9 @@ var ProtocolError = class ProtocolError2 extends Error {
|
|
|
24984
24982
|
if (typeof this !== "function") throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");
|
|
24985
24983
|
return brandedHasInstance(this, value);
|
|
24986
24984
|
}
|
|
24987
|
-
constructor(
|
|
24985
|
+
constructor(code, message, data) {
|
|
24988
24986
|
super(message);
|
|
24989
|
-
this.code =
|
|
24987
|
+
this.code = code;
|
|
24990
24988
|
this.data = data;
|
|
24991
24989
|
this.name = "ProtocolError";
|
|
24992
24990
|
stampErrorBrands(this, new.target);
|
|
@@ -24994,27 +24992,27 @@ var ProtocolError = class ProtocolError2 extends Error {
|
|
|
24994
24992
|
/**
|
|
24995
24993
|
* Factory method to create the appropriate error type based on the error code and data
|
|
24996
24994
|
*/
|
|
24997
|
-
static fromError(
|
|
24998
|
-
if (
|
|
24995
|
+
static fromError(code, message, data) {
|
|
24996
|
+
if (code === ProtocolErrorCode.UrlElicitationRequired && data) {
|
|
24999
24997
|
const errorData = data;
|
|
25000
24998
|
if (errorData.elicitations) return new UrlElicitationRequiredError(errorData.elicitations, message);
|
|
25001
24999
|
}
|
|
25002
|
-
if (
|
|
25000
|
+
if (code === ProtocolErrorCode.UnsupportedProtocolVersion && data) {
|
|
25003
25001
|
const errorData = data;
|
|
25004
25002
|
if (Array.isArray(errorData.supported) && typeof errorData.requested === "string") return new UnsupportedProtocolVersionError({
|
|
25005
25003
|
supported: errorData.supported,
|
|
25006
25004
|
requested: errorData.requested
|
|
25007
25005
|
}, message);
|
|
25008
25006
|
}
|
|
25009
|
-
if (
|
|
25007
|
+
if (code === ProtocolErrorCode.InvalidParams || code === ProtocolErrorCode.ResourceNotFound) {
|
|
25010
25008
|
const errorData = data;
|
|
25011
|
-
if (typeof errorData?.uri === "string" && (
|
|
25009
|
+
if (typeof errorData?.uri === "string" && (code === ProtocolErrorCode.ResourceNotFound || Object.keys(errorData).length === 1)) return new ResourceNotFoundError(errorData.uri, message);
|
|
25012
25010
|
}
|
|
25013
|
-
if (
|
|
25011
|
+
if (code === ProtocolErrorCode.MissingRequiredClientCapability && data) {
|
|
25014
25012
|
const errorData = data;
|
|
25015
25013
|
if (errorData.requiredCapabilities !== null && typeof errorData.requiredCapabilities === "object" && !Array.isArray(errorData.requiredCapabilities)) return new MissingRequiredClientCapabilityError({ requiredCapabilities: errorData.requiredCapabilities }, message);
|
|
25016
25014
|
}
|
|
25017
|
-
return new ProtocolError2(
|
|
25015
|
+
return new ProtocolError2(code, message, data);
|
|
25018
25016
|
}
|
|
25019
25017
|
};
|
|
25020
25018
|
var ResourceNotFoundError = class extends ProtocolError {
|
|
@@ -25370,7 +25368,7 @@ var rev2026Codec = {
|
|
|
25370
25368
|
encodeResult(method, result, serverInfo) {
|
|
25371
25369
|
return stampServerInfoMeta(fillCacheFields(method, stampResultType(method, enforceDeletedFields(method, result))), serverInfo);
|
|
25372
25370
|
},
|
|
25373
|
-
encodeErrorCode: (
|
|
25371
|
+
encodeErrorCode: (code) => code === -32002 ? -32602 : code,
|
|
25374
25372
|
checkInboundEnvelope(material) {
|
|
25375
25373
|
if (material.envelope === void 0) return "Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)";
|
|
25376
25374
|
const parsed = buildSchemas2026().RequestMetaEnvelopeSchema.safeParse(material.envelope);
|
|
@@ -26685,12 +26683,12 @@ var Protocol = class {
|
|
|
26685
26683
|
return;
|
|
26686
26684
|
}
|
|
26687
26685
|
const capturedTransport = this._transport;
|
|
26688
|
-
const sendErrorResponse = (
|
|
26686
|
+
const sendErrorResponse = (code, message, data) => {
|
|
26689
26687
|
const errorResponse = {
|
|
26690
26688
|
jsonrpc: "2.0",
|
|
26691
26689
|
id: request.id,
|
|
26692
26690
|
error: {
|
|
26693
|
-
code
|
|
26691
|
+
code,
|
|
26694
26692
|
message,
|
|
26695
26693
|
...data !== void 0 && { data }
|
|
26696
26694
|
}
|
|
@@ -27409,9 +27407,9 @@ var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
27409
27407
|
};
|
|
27410
27408
|
exports.Name = Name;
|
|
27411
27409
|
var _Code = class extends _CodeOrName {
|
|
27412
|
-
constructor(
|
|
27410
|
+
constructor(code) {
|
|
27413
27411
|
super();
|
|
27414
|
-
this._items = typeof
|
|
27412
|
+
this._items = typeof code === "string" ? [code] : code;
|
|
27415
27413
|
}
|
|
27416
27414
|
toString() {
|
|
27417
27415
|
return this.str;
|
|
@@ -27436,13 +27434,13 @@ var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
27436
27434
|
exports._Code = _Code;
|
|
27437
27435
|
exports.nil = new _Code("");
|
|
27438
27436
|
function _(strs, ...args) {
|
|
27439
|
-
const
|
|
27437
|
+
const code = [strs[0]];
|
|
27440
27438
|
let i = 0;
|
|
27441
27439
|
while (i < args.length) {
|
|
27442
|
-
addCodeArg(
|
|
27443
|
-
|
|
27440
|
+
addCodeArg(code, args[i]);
|
|
27441
|
+
code.push(strs[++i]);
|
|
27444
27442
|
}
|
|
27445
|
-
return new _Code(
|
|
27443
|
+
return new _Code(code);
|
|
27446
27444
|
}
|
|
27447
27445
|
exports._ = _;
|
|
27448
27446
|
const plus = new _Code("+");
|
|
@@ -27458,10 +27456,10 @@ var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
27458
27456
|
return new _Code(expr);
|
|
27459
27457
|
}
|
|
27460
27458
|
exports.str = str;
|
|
27461
|
-
function addCodeArg(
|
|
27462
|
-
if (arg instanceof _Code)
|
|
27463
|
-
else if (arg instanceof Name)
|
|
27464
|
-
else
|
|
27459
|
+
function addCodeArg(code, arg) {
|
|
27460
|
+
if (arg instanceof _Code) code.push(...arg._items);
|
|
27461
|
+
else if (arg instanceof Name) code.push(arg);
|
|
27462
|
+
else code.push(interpolate(arg));
|
|
27465
27463
|
}
|
|
27466
27464
|
exports.addCodeArg = addCodeArg;
|
|
27467
27465
|
function optimize(expr) {
|
|
@@ -27631,7 +27629,7 @@ var require_scope = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
27631
27629
|
}, usedValues, getCode);
|
|
27632
27630
|
}
|
|
27633
27631
|
_reduceValues(values, valueCode, usedValues = {}, getCode) {
|
|
27634
|
-
let
|
|
27632
|
+
let code = code_1.nil;
|
|
27635
27633
|
for (const prefix in values) {
|
|
27636
27634
|
const vs = values[prefix];
|
|
27637
27635
|
if (!vs) continue;
|
|
@@ -27642,13 +27640,13 @@ var require_scope = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
27642
27640
|
let c = valueCode(name);
|
|
27643
27641
|
if (c) {
|
|
27644
27642
|
const def = this.opts.es5 ? exports.varKinds.var : exports.varKinds.const;
|
|
27645
|
-
|
|
27646
|
-
} else if (c = getCode === null || getCode === void 0 ? void 0 : getCode(name))
|
|
27643
|
+
code = (0, code_1._)`${code}${def} ${name} = ${c};${this.opts._n}`;
|
|
27644
|
+
} else if (c = getCode === null || getCode === void 0 ? void 0 : getCode(name)) code = (0, code_1._)`${code}${c}${this.opts._n}`;
|
|
27647
27645
|
else throw new ValueError(name);
|
|
27648
27646
|
nameSet.set(name, UsedValueState.Completed);
|
|
27649
27647
|
});
|
|
27650
27648
|
}
|
|
27651
|
-
return
|
|
27649
|
+
return code;
|
|
27652
27650
|
}
|
|
27653
27651
|
};
|
|
27654
27652
|
exports.ValueScope = ValueScope;
|
|
@@ -27834,9 +27832,9 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
27834
27832
|
}
|
|
27835
27833
|
};
|
|
27836
27834
|
var AnyCode = class extends Node {
|
|
27837
|
-
constructor(
|
|
27835
|
+
constructor(code) {
|
|
27838
27836
|
super();
|
|
27839
|
-
this.code =
|
|
27837
|
+
this.code = code;
|
|
27840
27838
|
}
|
|
27841
27839
|
render({ _n }) {
|
|
27842
27840
|
return `${this.code};` + _n;
|
|
@@ -27858,7 +27856,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
27858
27856
|
this.nodes = nodes;
|
|
27859
27857
|
}
|
|
27860
27858
|
render(opts) {
|
|
27861
|
-
return this.nodes.reduce((
|
|
27859
|
+
return this.nodes.reduce((code, n) => code + n.render(opts), "");
|
|
27862
27860
|
}
|
|
27863
27861
|
optimizeNodes() {
|
|
27864
27862
|
const { nodes } = this;
|
|
@@ -27902,9 +27900,9 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
27902
27900
|
this.condition = condition;
|
|
27903
27901
|
}
|
|
27904
27902
|
render(opts) {
|
|
27905
|
-
let
|
|
27906
|
-
if (this.else)
|
|
27907
|
-
return
|
|
27903
|
+
let code = `if(${this.condition})` + super.render(opts);
|
|
27904
|
+
if (this.else) code += "else " + this.else.render(opts);
|
|
27905
|
+
return code;
|
|
27908
27906
|
}
|
|
27909
27907
|
optimizeNodes() {
|
|
27910
27908
|
super.optimizeNodes();
|
|
@@ -28015,10 +28013,10 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
28015
28013
|
Return.kind = "return";
|
|
28016
28014
|
var Try = class extends BlockNode {
|
|
28017
28015
|
render(opts) {
|
|
28018
|
-
let
|
|
28019
|
-
if (this.catch)
|
|
28020
|
-
if (this.finally)
|
|
28021
|
-
return
|
|
28016
|
+
let code = "try" + super.render(opts);
|
|
28017
|
+
if (this.catch) code += this.catch.render(opts);
|
|
28018
|
+
if (this.finally) code += this.finally.render(opts);
|
|
28019
|
+
return code;
|
|
28022
28020
|
}
|
|
28023
28021
|
optimizeNodes() {
|
|
28024
28022
|
var _a, _b;
|
|
@@ -28120,17 +28118,17 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
28120
28118
|
return this;
|
|
28121
28119
|
}
|
|
28122
28120
|
object(...keyValues) {
|
|
28123
|
-
const
|
|
28121
|
+
const code = ["{"];
|
|
28124
28122
|
for (const [key, value] of keyValues) {
|
|
28125
|
-
if (
|
|
28126
|
-
|
|
28123
|
+
if (code.length > 1) code.push(",");
|
|
28124
|
+
code.push(key);
|
|
28127
28125
|
if (key !== value || this.opts.es5) {
|
|
28128
|
-
|
|
28129
|
-
(0, code_1.addCodeArg)(
|
|
28126
|
+
code.push(":");
|
|
28127
|
+
(0, code_1.addCodeArg)(code, value);
|
|
28130
28128
|
}
|
|
28131
28129
|
}
|
|
28132
|
-
|
|
28133
|
-
return new code_1._Code(
|
|
28130
|
+
code.push("}");
|
|
28131
|
+
return new code_1._Code(code);
|
|
28134
28132
|
}
|
|
28135
28133
|
if(condition, thenBody, elseBody) {
|
|
28136
28134
|
this._blockNode(new If2(condition));
|
|
@@ -30067,18 +30065,18 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
30067
30065
|
const isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
|
|
30068
30066
|
function stringArrayToHexStripped(input) {
|
|
30069
30067
|
let acc = "";
|
|
30070
|
-
let
|
|
30068
|
+
let code = 0;
|
|
30071
30069
|
let i = 0;
|
|
30072
30070
|
for (i = 0; i < input.length; i++) {
|
|
30073
|
-
|
|
30074
|
-
if (
|
|
30075
|
-
if (!(
|
|
30071
|
+
code = input[i].charCodeAt(0);
|
|
30072
|
+
if (code === 48) continue;
|
|
30073
|
+
if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) return "";
|
|
30076
30074
|
acc += input[i];
|
|
30077
30075
|
break;
|
|
30078
30076
|
}
|
|
30079
30077
|
for (i += 1; i < input.length; i++) {
|
|
30080
|
-
|
|
30081
|
-
if (!(
|
|
30078
|
+
code = input[i].charCodeAt(0);
|
|
30079
|
+
if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) return "";
|
|
30082
30080
|
acc += input[i];
|
|
30083
30081
|
}
|
|
30084
30082
|
return acc;
|
|
@@ -32523,11 +32521,11 @@ var require_format$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
32523
32521
|
}
|
|
32524
32522
|
}
|
|
32525
32523
|
function getFormat(fmtDef) {
|
|
32526
|
-
const
|
|
32524
|
+
const code = fmtDef instanceof RegExp ? (0, codegen_1.regexpCode)(fmtDef) : opts.code.formats ? (0, codegen_1._)`${opts.code.formats}${(0, codegen_1.getProperty)(schema)}` : void 0;
|
|
32527
32525
|
const fmt = gen.scopeValue("formats", {
|
|
32528
32526
|
key: schema,
|
|
32529
32527
|
ref: fmtDef,
|
|
32530
|
-
code
|
|
32528
|
+
code
|
|
32531
32529
|
});
|
|
32532
32530
|
if (typeof fmtDef == "object" && !(fmtDef instanceof RegExp)) return [
|
|
32533
32531
|
fmtDef.type || "string",
|
|
@@ -34872,10 +34870,10 @@ getRequestOptions_fn = function() {
|
|
|
34872
34870
|
* @param code - The HTTP status code, if available
|
|
34873
34871
|
* @internal
|
|
34874
34872
|
*/
|
|
34875
|
-
failConnection_fn = function(message,
|
|
34873
|
+
failConnection_fn = function(message, code) {
|
|
34876
34874
|
var _a;
|
|
34877
34875
|
__privateGet(this, _readyState) !== this.CLOSED && __privateSet(this, _readyState, this.CLOSED);
|
|
34878
|
-
const errorEvent = new ErrorEvent("error", { code
|
|
34876
|
+
const errorEvent = new ErrorEvent("error", { code, message });
|
|
34879
34877
|
(_a = __privateGet(this, _onError)) == null || _a.call(this, errorEvent), this.dispatchEvent(errorEvent);
|
|
34880
34878
|
}, /**
|
|
34881
34879
|
* Schedules a reconnection attempt against the EventSource endpoint.
|
|
@@ -34884,12 +34882,12 @@ failConnection_fn = function(message, code2) {
|
|
|
34884
34882
|
* @param code - The HTTP status code, if available
|
|
34885
34883
|
* @internal
|
|
34886
34884
|
*/
|
|
34887
|
-
scheduleReconnect_fn = function(message,
|
|
34885
|
+
scheduleReconnect_fn = function(message, code) {
|
|
34888
34886
|
var _a;
|
|
34889
34887
|
if (__privateGet(this, _readyState) === this.CLOSED)
|
|
34890
34888
|
return;
|
|
34891
34889
|
__privateSet(this, _readyState, this.CONNECTING);
|
|
34892
|
-
const errorEvent = new ErrorEvent("error", { code
|
|
34890
|
+
const errorEvent = new ErrorEvent("error", { code, message });
|
|
34893
34891
|
(_a = __privateGet(this, _onError)) == null || _a.call(this, errorEvent), this.dispatchEvent(errorEvent), __privateSet(this, _reconnectTimer, setTimeout(__privateGet(this, _reconnect), __privateGet(this, _reconnectInterval)));
|
|
34894
34892
|
}, _reconnect = /* @__PURE__ */ new WeakMap(), /**
|
|
34895
34893
|
* ReadyState representing an EventSource currently trying to connect
|
|
@@ -35127,9 +35125,9 @@ async function resolveAuthorizationCallbackParams(codeOrParams, iss, provider, s
|
|
|
35127
35125
|
iss
|
|
35128
35126
|
};
|
|
35129
35127
|
const issParam = codeOrParams.get("iss") ?? void 0;
|
|
35130
|
-
const
|
|
35131
|
-
if (
|
|
35132
|
-
authorizationCode:
|
|
35128
|
+
const code = codeOrParams.get("code");
|
|
35129
|
+
if (code) return {
|
|
35130
|
+
authorizationCode: code,
|
|
35133
35131
|
iss: issParam
|
|
35134
35132
|
};
|
|
35135
35133
|
let metadata = (await provider.discoveryState?.())?.authorizationServerMetadata;
|
|
@@ -36241,8 +36239,8 @@ function classifyResult(result, context) {
|
|
|
36241
36239
|
};
|
|
36242
36240
|
}
|
|
36243
36241
|
function classifyRpcError(outcome, context) {
|
|
36244
|
-
const { code
|
|
36245
|
-
if (
|
|
36242
|
+
const { code, message, data } = outcome;
|
|
36243
|
+
if (code === UNSUPPORTED_PROTOCOL_VERSION) {
|
|
36246
36244
|
const supported = parseSupportedList(data);
|
|
36247
36245
|
if (supported === void 0) return { kind: "legacy" };
|
|
36248
36246
|
const error = new UnsupportedProtocolVersionError({
|
|
@@ -36265,7 +36263,7 @@ function classifyRpcError(outcome, context) {
|
|
|
36265
36263
|
error
|
|
36266
36264
|
};
|
|
36267
36265
|
}
|
|
36268
|
-
if (NOT_PROBE_RECOGNIZED.has(
|
|
36266
|
+
if (NOT_PROBE_RECOGNIZED.has(code)) return { kind: "legacy" };
|
|
36269
36267
|
return { kind: "legacy" };
|
|
36270
36268
|
}
|
|
36271
36269
|
function classifyHttpError(outcome, context) {
|
|
@@ -36327,10 +36325,10 @@ function parseJsonRpcErrorBody(body) {
|
|
|
36327
36325
|
if (typeof parsed !== "object" || parsed === null) return void 0;
|
|
36328
36326
|
const error = parsed.error;
|
|
36329
36327
|
if (typeof error !== "object" || error === null) return void 0;
|
|
36330
|
-
const { code
|
|
36331
|
-
if (typeof
|
|
36328
|
+
const { code, message, data } = error;
|
|
36329
|
+
if (typeof code !== "number") return void 0;
|
|
36332
36330
|
return {
|
|
36333
|
-
code
|
|
36331
|
+
code,
|
|
36334
36332
|
message: typeof message === "string" ? message : "",
|
|
36335
36333
|
data
|
|
36336
36334
|
};
|
|
@@ -38060,9 +38058,9 @@ var SseError = class extends Error {
|
|
|
38060
38058
|
if (typeof this !== "function") throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");
|
|
38061
38059
|
return brandedHasInstance(this, value);
|
|
38062
38060
|
}
|
|
38063
|
-
constructor(
|
|
38061
|
+
constructor(code, message, event) {
|
|
38064
38062
|
super(`SSE error: ${message}`);
|
|
38065
|
-
this.code =
|
|
38063
|
+
this.code = code;
|
|
38066
38064
|
this.event = event;
|
|
38067
38065
|
stampErrorBrands(this, new.target);
|
|
38068
38066
|
}
|
|
@@ -41643,7 +41641,7 @@ function handleRequest(req, res) {
|
|
|
41643
41641
|
res.end("Not found");
|
|
41644
41642
|
return;
|
|
41645
41643
|
}
|
|
41646
|
-
const
|
|
41644
|
+
const code = url3.searchParams.get("code");
|
|
41647
41645
|
const iss = url3.searchParams.get("iss");
|
|
41648
41646
|
const state = url3.searchParams.get("state");
|
|
41649
41647
|
const error = url3.searchParams.get("error");
|
|
@@ -41680,7 +41678,7 @@ function handleRequest(req, res) {
|
|
|
41680
41678
|
res.end(htmlError(errorMsg));
|
|
41681
41679
|
return;
|
|
41682
41680
|
}
|
|
41683
|
-
if (!
|
|
41681
|
+
if (!code) {
|
|
41684
41682
|
res.writeHead(400, { "Content-Type": "text/html" });
|
|
41685
41683
|
res.end(htmlError("No authorization code provided"));
|
|
41686
41684
|
return;
|
|
@@ -41692,7 +41690,7 @@ function handleRequest(req, res) {
|
|
|
41692
41690
|
}
|
|
41693
41691
|
clearTimeout(pending.timeout);
|
|
41694
41692
|
pendingAuths.delete(state);
|
|
41695
|
-
pending.resolve({ code
|
|
41693
|
+
pending.resolve({ code, ...iss !== null ? { iss } : {} });
|
|
41696
41694
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
41697
41695
|
res.end(htmlSuccess());
|
|
41698
41696
|
}
|
|
@@ -42420,10 +42418,10 @@ function parseAuthorizationRedirectInput(input, expectedState) {
|
|
|
42420
42418
|
if (expectedState && state !== expectedState) {
|
|
42421
42419
|
throw new Error("OAuth state mismatch - potential CSRF attack");
|
|
42422
42420
|
}
|
|
42423
|
-
const
|
|
42424
|
-
if (
|
|
42421
|
+
const code = params.get("code");
|
|
42422
|
+
if (code) {
|
|
42425
42423
|
const iss = params.get("iss");
|
|
42426
|
-
return { code
|
|
42424
|
+
return { code, ...iss !== null ? { iss } : {} };
|
|
42427
42425
|
}
|
|
42428
42426
|
}
|
|
42429
42427
|
if (/^[A-Za-z0-9._~+/=-]+$/.test(trimmed)) {
|
|
@@ -42491,7 +42489,7 @@ async function completeAuthFromInput(serverName, input, options = {}) {
|
|
|
42491
42489
|
async function completeAuth(serverName, authorizationCode, options = {}) {
|
|
42492
42490
|
const runtime = getRuntime(options);
|
|
42493
42491
|
const runtimeState = getRuntimeState(runtime);
|
|
42494
|
-
const { code
|
|
42492
|
+
const { code, iss } = typeof authorizationCode === "string" ? { code: authorizationCode, iss: void 0 } : authorizationCode;
|
|
42495
42493
|
const fallbackAuthStorageOptions = options.authStorageOptions ?? {};
|
|
42496
42494
|
const signal = combineAbortSignals(runtime.signal, options.signal);
|
|
42497
42495
|
throwIfAborted(signal);
|
|
@@ -42521,7 +42519,7 @@ async function completeAuth(serverName, authorizationCode, options = {}) {
|
|
|
42521
42519
|
}
|
|
42522
42520
|
const result = await abortable(auth(pendingAuth.authProvider, {
|
|
42523
42521
|
serverUrl: pendingAuth.serverUrl,
|
|
42524
|
-
authorizationCode:
|
|
42522
|
+
authorizationCode: code,
|
|
42525
42523
|
...iss !== void 0 ? { iss } : {},
|
|
42526
42524
|
...pendingAuth.discovery
|
|
42527
42525
|
}), signal);
|
|
@@ -43801,14 +43799,14 @@ async function invokeRequestHeadersCommand(config, envelope, signal) {
|
|
|
43801
43799
|
failAfterKill("HTTP request headers command output exceeded 64 KiB");
|
|
43802
43800
|
}
|
|
43803
43801
|
});
|
|
43804
|
-
child.on("close", (
|
|
43802
|
+
child.on("close", (code) => {
|
|
43805
43803
|
if (settled) return;
|
|
43806
43804
|
if (trackingError) {
|
|
43807
43805
|
failAfterKill(trackingError.message);
|
|
43808
43806
|
return;
|
|
43809
43807
|
}
|
|
43810
|
-
if (
|
|
43811
|
-
failAfterKill(`HTTP request headers command exited with code ${
|
|
43808
|
+
if (code !== 0) {
|
|
43809
|
+
failAfterKill(`HTTP request headers command exited with code ${code ?? "unknown"}`);
|
|
43812
43810
|
return;
|
|
43813
43811
|
}
|
|
43814
43812
|
let parsed;
|
|
@@ -52289,9 +52287,9 @@ function Clone2(value) {
|
|
|
52289
52287
|
// ../node_modules/.bun/typebox@1.3.7/node_modules/typebox/build/value/clean/from_union.mjs
|
|
52290
52288
|
function FromUnion9(context, type, value) {
|
|
52291
52289
|
for (const schema of type.anyOf) {
|
|
52292
|
-
const
|
|
52293
|
-
if (Check2(context, schema,
|
|
52294
|
-
return
|
|
52290
|
+
const clean = FromType19(context, schema, Clone2(value));
|
|
52291
|
+
if (Check2(context, schema, clean))
|
|
52292
|
+
return clean;
|
|
52295
52293
|
}
|
|
52296
52294
|
return value;
|
|
52297
52295
|
}
|
|
@@ -55763,8 +55761,8 @@ function createMcpToolResultRenderer(renderOptions) {
|
|
|
55763
55761
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/error-signal.ts
|
|
55764
55762
|
function toolErrorOverride(details) {
|
|
55765
55763
|
if (details && typeof details === "object" && "error" in details) {
|
|
55766
|
-
const
|
|
55767
|
-
if (
|
|
55764
|
+
const code = details.error;
|
|
55765
|
+
if (code === "tool_error" || code === "call_failed" || code === INPUT_REQUIRED_NEEDS_UI) {
|
|
55768
55766
|
return { isError: true };
|
|
55769
55767
|
}
|
|
55770
55768
|
}
|
|
@@ -55847,7 +55845,7 @@ function parseWorkerMessage(value) {
|
|
|
55847
55845
|
}
|
|
55848
55846
|
return null;
|
|
55849
55847
|
}
|
|
55850
|
-
async function runMcpScript(state,
|
|
55848
|
+
async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_MS, getPiTools, signal) {
|
|
55851
55849
|
const resolvedTimeoutMs = Number.isFinite(timeoutMs) && timeoutMs > 0 ? Math.floor(timeoutMs) : DEFAULT_MCP_SCRIPT_TIMEOUT_MS;
|
|
55852
55850
|
const output = [];
|
|
55853
55851
|
const externalSignal = combineAbortSignals(state.owner?.signal, signal);
|
|
@@ -55955,7 +55953,7 @@ async function runMcpScript(state, code2, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT
|
|
|
55955
55953
|
throw abortReasonError(externalSignal.reason);
|
|
55956
55954
|
}
|
|
55957
55955
|
worker = new Worker(new URL("./mcp-script-worker.mjs", import.meta.url), {
|
|
55958
|
-
workerData: { code
|
|
55956
|
+
workerData: { code },
|
|
55959
55957
|
env: {},
|
|
55960
55958
|
// The sandbox cannot open files, and the host always terminates this worker.
|
|
55961
55959
|
// Disable Node's unmanaged FD bookkeeping, which emits false warnings when
|
|
@@ -55997,8 +55995,8 @@ async function runMcpScript(state, code2, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT
|
|
|
55997
55995
|
})().catch(reject);
|
|
55998
55996
|
});
|
|
55999
55997
|
activeWorker.once("error", reject);
|
|
56000
|
-
activeWorker.once("exit", (
|
|
56001
|
-
if (!completed &&
|
|
55998
|
+
activeWorker.once("exit", (code2) => {
|
|
55999
|
+
if (!completed && code2 !== 0) reject(new Error(`mcpScript worker exited with code ${code2}`));
|
|
56002
56000
|
});
|
|
56003
56001
|
});
|
|
56004
56002
|
const timeoutError = new McpScriptTimeoutError(resolvedTimeoutMs);
|
|
@@ -59239,122 +59237,6 @@ async function buildForkHandoff(input) {
|
|
|
59239
59237
|
};
|
|
59240
59238
|
}
|
|
59241
59239
|
|
|
59242
|
-
// src/services/chat/slack-activity-stream.ts
|
|
59243
|
-
var FLUSH_INTERVAL_MS = 3e3;
|
|
59244
|
-
var MAX_ACTIVITY_LENGTH = 100;
|
|
59245
|
-
var MAX_THOUGHT_LENGTH = 500;
|
|
59246
|
-
var MAX_CODE_LENGTH = 40;
|
|
59247
|
-
var MAX_DONE_ATTEMPTS = 3;
|
|
59248
|
-
var GENERIC_STEPS = {
|
|
59249
|
-
read: "Reading a file",
|
|
59250
|
-
edit: "Editing a file",
|
|
59251
|
-
command: "Running a command",
|
|
59252
|
-
search: "Searching the code",
|
|
59253
|
-
web: "Browsing the web",
|
|
59254
|
-
tool: "Using a tool"
|
|
59255
|
-
};
|
|
59256
|
-
var sendQueue = Promise.resolve();
|
|
59257
|
-
var clean = (text) => {
|
|
59258
|
-
const line = text.replace(/\s+/g, " ").trim();
|
|
59259
|
-
return line.length > MAX_ACTIVITY_LENGTH ? `${line.slice(0, MAX_ACTIVITY_LENGTH - 1)}\u2026` : line;
|
|
59260
|
-
};
|
|
59261
|
-
var code = (text) => {
|
|
59262
|
-
const line = text?.replace(/\s+/g, " ").trim();
|
|
59263
|
-
return line && line.length <= MAX_CODE_LENGTH ? `\`${line.replace(/`/g, "'")}\`` : void 0;
|
|
59264
|
-
};
|
|
59265
|
-
var basename4 = (path7) => path7.split("/").pop() || path7;
|
|
59266
|
-
function describeActivity(message, idle) {
|
|
59267
|
-
if (planItemsFromMessage(message) || message.type === "tool_call" && message.inputRequest) return null;
|
|
59268
|
-
if (message.type === "agent") {
|
|
59269
|
-
const thought = message.content.replace(/\*\*/g, "").replace(/\s+/g, " ").trim();
|
|
59270
|
-
return thought ? { thought: thought.length > MAX_THOUGHT_LENGTH ? `\u2026${thought.slice(1 - MAX_THOUGHT_LENGTH)}` : thought } : null;
|
|
59271
|
-
}
|
|
59272
|
-
const steps = describeMessageSteps(message);
|
|
59273
|
-
const step = steps.at(-1);
|
|
59274
|
-
if (!step) return null;
|
|
59275
|
-
if (idle && !steps.some((s) => s.running)) return { thought: "Thinking" };
|
|
59276
|
-
if (steps.length > 1) return { step: `${steps.every((s) => s.live === step.live) ? step.live : "Changing"} ${steps.length} files` };
|
|
59277
|
-
if (!step.target) return { step: step.live };
|
|
59278
|
-
const target = step.target.plain ? clean(step.target.text) : code(step.target.path ? basename4(step.target.path) : step.target.text);
|
|
59279
|
-
if (!target) return { step: GENERIC_STEPS[step.category] ?? step.live };
|
|
59280
|
-
const scope = step.scope && code(basename4(step.scope));
|
|
59281
|
-
return { step: [step.live, target, scope && `in ${scope}`].filter(Boolean).join(" ") };
|
|
59282
|
-
}
|
|
59283
|
-
var SlackActivityStream = class {
|
|
59284
|
-
constructor(turnId, provider) {
|
|
59285
|
-
this.turnId = turnId;
|
|
59286
|
-
this.provider = provider;
|
|
59287
|
-
this.timer = setInterval(() => this.enqueue(false), FLUSH_INTERVAL_MS);
|
|
59288
|
-
this.timer.unref?.();
|
|
59289
|
-
}
|
|
59290
|
-
turnId;
|
|
59291
|
-
provider;
|
|
59292
|
-
events = [];
|
|
59293
|
-
timer;
|
|
59294
|
-
sent = null;
|
|
59295
|
-
attempted = false;
|
|
59296
|
-
dirty = false;
|
|
59297
|
-
settled = false;
|
|
59298
|
-
stopped = false;
|
|
59299
|
-
queued = false;
|
|
59300
|
-
noteEvent(event) {
|
|
59301
|
-
const streamId = getEventStreamId(event);
|
|
59302
|
-
const index = streamId ? this.events.findLastIndex((previous) => getEventStreamId(previous) === streamId) : -1;
|
|
59303
|
-
if (index >= 0) this.events[index] = event;
|
|
59304
|
-
else this.events.push(event);
|
|
59305
|
-
this.dirty = true;
|
|
59306
|
-
}
|
|
59307
|
-
finish() {
|
|
59308
|
-
clearInterval(this.timer);
|
|
59309
|
-
this.enqueue(true);
|
|
59310
|
-
}
|
|
59311
|
-
enqueue(done) {
|
|
59312
|
-
if (!done && this.queued) return;
|
|
59313
|
-
this.queued = true;
|
|
59314
|
-
sendQueue = sendQueue.then(async () => {
|
|
59315
|
-
this.queued = false;
|
|
59316
|
-
for (let attempt = 1; !await this.flush(done) && done && attempt < MAX_DONE_ATTEMPTS; attempt++) {
|
|
59317
|
-
await new Promise((resolve7) => setTimeout(resolve7, FLUSH_INTERVAL_MS));
|
|
59318
|
-
}
|
|
59319
|
-
}).catch((error) => console.error("[SlackActivityStream] Flush failed:", error));
|
|
59320
|
-
}
|
|
59321
|
-
async flush(done) {
|
|
59322
|
-
if (this.stopped) return true;
|
|
59323
|
-
if (done && !this.attempted) {
|
|
59324
|
-
this.stopped = true;
|
|
59325
|
-
return true;
|
|
59326
|
-
}
|
|
59327
|
-
let activity = null;
|
|
59328
|
-
if (!done) {
|
|
59329
|
-
const idle = !this.dirty;
|
|
59330
|
-
if (idle && this.settled) return true;
|
|
59331
|
-
this.settled = idle;
|
|
59332
|
-
this.dirty = false;
|
|
59333
|
-
const latestReasoning = this.provider === "codex" ? this.events.findLast((event2) => codexItemFromEvent(event2)?.item.type === "reasoning") : void 0;
|
|
59334
|
-
const events = latestReasoning ? this.events.filter((event2) => event2 === latestReasoning || codexItemFromEvent(event2)?.item.type !== "reasoning") : this.events;
|
|
59335
|
-
activity = parseDisplayMessages(events, this.provider).map((message) => describeActivity(message, idle)).findLast(Boolean) ?? null;
|
|
59336
|
-
if (!activity || JSON.stringify(activity) === this.sent) return true;
|
|
59337
|
-
}
|
|
59338
|
-
this.attempted = true;
|
|
59339
|
-
const event = {
|
|
59340
|
-
type: "slack_activity",
|
|
59341
|
-
payload: { turnId: this.turnId, ...done ? { done } : activity }
|
|
59342
|
-
};
|
|
59343
|
-
const response = await monolithRequest("/v1/engine/webhook", { body: event, signal: AbortSignal.timeout(15e3) }).catch(() => null);
|
|
59344
|
-
if (response?.status === 409) {
|
|
59345
|
-
this.stopped = true;
|
|
59346
|
-
return true;
|
|
59347
|
-
}
|
|
59348
|
-
if (!response?.ok) {
|
|
59349
|
-
this.dirty = true;
|
|
59350
|
-
return false;
|
|
59351
|
-
}
|
|
59352
|
-
this.sent = JSON.stringify(activity);
|
|
59353
|
-
if (done) this.stopped = true;
|
|
59354
|
-
return true;
|
|
59355
|
-
}
|
|
59356
|
-
};
|
|
59357
|
-
|
|
59358
59240
|
// src/services/chat/chat-service.ts
|
|
59359
59241
|
var CHATS_BACKUP_FILE = `${CHATS_FILE}.bak`;
|
|
59360
59242
|
function createTurnMetadata(message, messageId, recordedAt) {
|
|
@@ -59836,9 +59718,6 @@ var ChatService = class {
|
|
|
59836
59718
|
...request.errorNotificationTargets ?? [],
|
|
59837
59719
|
...request.errorNotificationTarget ? [request.errorNotificationTarget] : []
|
|
59838
59720
|
];
|
|
59839
|
-
if (request.streamSlackActivity && chat.persisted.parentChatId === null) {
|
|
59840
|
-
chat.slackActivityMessageIds.add(result.messageId);
|
|
59841
|
-
}
|
|
59842
59721
|
if (notificationTargets.length > 0) {
|
|
59843
59722
|
const existingTargets = chat.errorNotificationTargets.get(result.messageId) ?? [];
|
|
59844
59723
|
chat.errorNotificationTargets.set(result.messageId, [
|
|
@@ -59987,7 +59866,6 @@ var ChatService = class {
|
|
|
59987
59866
|
for (const messageId of removed) {
|
|
59988
59867
|
chat.acceptedUserEvents.delete(messageId);
|
|
59989
59868
|
chat.errorNotificationTargets.delete(messageId);
|
|
59990
|
-
chat.slackActivityMessageIds.delete(messageId);
|
|
59991
59869
|
}
|
|
59992
59870
|
await this.persistAllChats().catch((error) => {
|
|
59993
59871
|
console.error("[ChatService] Failed to persist queued-message removals:", error);
|
|
@@ -60093,9 +59971,6 @@ var ChatService = class {
|
|
|
60093
59971
|
target.pendingMessageIds = [];
|
|
60094
59972
|
target.acceptedUserEvents.clear();
|
|
60095
59973
|
}
|
|
60096
|
-
target.slackActivity?.finish();
|
|
60097
|
-
target.slackActivity = null;
|
|
60098
|
-
target.slackActivityMessageIds.clear();
|
|
60099
59974
|
const started = hasChatStarted(this.toSummary(target));
|
|
60100
59975
|
if (started) {
|
|
60101
59976
|
target.persisted.deletedAt = deletedAt;
|
|
@@ -60539,8 +60414,6 @@ var ChatService = class {
|
|
|
60539
60414
|
release: null,
|
|
60540
60415
|
errorNotificationTargets: /* @__PURE__ */ new Map(),
|
|
60541
60416
|
activeErrorNotificationTargets: [],
|
|
60542
|
-
slackActivityMessageIds: /* @__PURE__ */ new Set(),
|
|
60543
|
-
slackActivity: null,
|
|
60544
60417
|
quotaExhaustion: null,
|
|
60545
60418
|
lastSendRequest: null
|
|
60546
60419
|
};
|
|
@@ -60596,8 +60469,6 @@ var ChatService = class {
|
|
|
60596
60469
|
this.agentTokenUsageTracker.startTurn(context);
|
|
60597
60470
|
chat.activeErrorNotificationTargets = chat.errorNotificationTargets.get(messageId) ?? [];
|
|
60598
60471
|
chat.errorNotificationTargets.delete(messageId);
|
|
60599
|
-
chat.slackActivity?.finish();
|
|
60600
|
-
chat.slackActivity = chat.slackActivityMessageIds.delete(messageId) ? new SlackActivityStream(messageId, chat.persisted.provider) : null;
|
|
60601
60472
|
}
|
|
60602
60473
|
async handleTurnStarted(chatId, message) {
|
|
60603
60474
|
const chat = this.getRuntimeChat(chatId);
|
|
@@ -60647,7 +60518,6 @@ var ChatService = class {
|
|
|
60647
60518
|
});
|
|
60648
60519
|
}
|
|
60649
60520
|
this.agentTokenUsageTracker.noteAgentEvent(chatId, event);
|
|
60650
|
-
chat.slackActivity?.noteEvent(event);
|
|
60651
60521
|
const parentToolUseId = typeof event.payload.parent_tool_use_id === "string" ? event.payload.parent_tool_use_id : null;
|
|
60652
60522
|
const messages = parseDisplayMessages([event], chat.persisted.provider, { filter: false, parentToolUseId });
|
|
60653
60523
|
if (chat.hasActiveTurn) this.agentChatActivityTrackerService.noteSkillMcpCalls(chatId, messages);
|
|
@@ -60764,8 +60634,6 @@ var ChatService = class {
|
|
|
60764
60634
|
}
|
|
60765
60635
|
chat.hasActiveTurn = false;
|
|
60766
60636
|
chat.activeMessageId = null;
|
|
60767
|
-
chat.slackActivity?.finish();
|
|
60768
|
-
chat.slackActivity = null;
|
|
60769
60637
|
this.endTrackedTurn(chat);
|
|
60770
60638
|
const completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
60771
60639
|
const processing = chat.provider.getQueue().length > 0 || (chat.provider.hasActiveBackgroundTasks?.() ?? false);
|
|
@@ -61652,11 +61520,11 @@ async function executeHookScriptStreaming(params) {
|
|
|
61652
61520
|
};
|
|
61653
61521
|
proc.stdout.on("data", handleData);
|
|
61654
61522
|
proc.stderr.on("data", handleData);
|
|
61655
|
-
proc.on("close", (
|
|
61523
|
+
proc.on("close", (code) => {
|
|
61656
61524
|
clearTimeout(timer);
|
|
61657
61525
|
const output = [`$ ${params.label}`, ...outputParts].join("");
|
|
61658
61526
|
resolve7({
|
|
61659
|
-
exitCode: bufferExceeded ? 1 :
|
|
61527
|
+
exitCode: bufferExceeded ? 1 : code ?? 1,
|
|
61660
61528
|
output,
|
|
61661
61529
|
timedOut: killed && !bufferExceeded
|
|
61662
61530
|
});
|