@cydm/pie 2.7.1 → 2.7.2
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/builtin/extensions/ask-user/index.js +3 -3
- package/dist/builtin/extensions/plan-mode/index.js +3 -3
- package/dist/builtin/extensions/subagent/index.js +4 -4
- package/dist/builtin/extensions/todo/index.js +3 -3
- package/dist/builtin/skills/computer-use-axi/SKILL.md +18 -2
- package/dist/builtin/skills/computer-use-axi/computer-use-axi-broker.js +911 -753
- package/dist/builtin/skills/computer-use-axi/computer-use-axi-runtime.js +11 -2
- package/dist/chunks/{chunk-M44CWVDZ.js → chunk-65B6P5J5.js} +198 -35
- package/dist/chunks/{chunk-XUROMYTT.js → chunk-BRFP5WZ6.js} +53 -12
- package/dist/chunks/{chunk-W74NRSRV.js → chunk-GECAIKZL.js} +3 -2
- package/dist/chunks/{chunk-NJFPBU36.js → chunk-GZDAIW6F.js} +1 -1
- package/dist/chunks/{src-C4KA4G75.js → src-PRKTGADX.js} +2 -2
- package/dist/chunks/{test-stream-A5ZELKNG.js → test-stream-BGAEVPRX.js} +1 -1
- package/dist/cli.js +92 -34
- package/models.schema.json +23 -2
- package/package.json +1 -1
|
@@ -84,7 +84,7 @@ function computerUseOwnerFromEnv(env = process.env) {
|
|
|
84
84
|
|
|
85
85
|
// vendor/computer-use-axi/src/broker-protocol.ts
|
|
86
86
|
var BROKER_PROTOCOL_VERSION = 1;
|
|
87
|
-
var BROKER_ENGINE_VERSION =
|
|
87
|
+
var BROKER_ENGINE_VERSION = 2;
|
|
88
88
|
var BROKER_PACKAGE_VERSION = "0.5.1-pie.1";
|
|
89
89
|
var BROKER_MAX_FRAME_BYTES = 4 * 1024 * 1024;
|
|
90
90
|
var BROKER_MAX_RESPONSE_BYTES = 8 * 1024 * 1024;
|
|
@@ -352,6 +352,7 @@ async function callBroker(options) {
|
|
|
352
352
|
type: "request",
|
|
353
353
|
protocolVersion: brokerProtocol,
|
|
354
354
|
requestId: options.requestId,
|
|
355
|
+
generation: options.generation,
|
|
355
356
|
ownerId: options.ownerId,
|
|
356
357
|
executionId: options.executionId,
|
|
357
358
|
command: options.command,
|
|
@@ -417,12 +418,14 @@ Commands:
|
|
|
417
418
|
browser launch [--url U]
|
|
418
419
|
browser navigate --state S --url U
|
|
419
420
|
browser eval --state S --expr '<JavaScript>'
|
|
421
|
+
permissions setup|recheck macOS: register/open Settings, or restart helper and check
|
|
420
422
|
status Show the local broker status (never starts one)
|
|
421
423
|
stop Stop the local broker and release processes it owns
|
|
422
424
|
|
|
423
425
|
Options:
|
|
424
426
|
--json Print { content, details, isError } as JSON
|
|
425
|
-
--request-id ID
|
|
427
|
+
--request-id ID Retrieve the same result within its original broker generation
|
|
428
|
+
--generation G Pin request/result retrieval to a broker generation (use with reused IDs)
|
|
426
429
|
--owner ID Opaque session identity (defaults to the standalone namespace)
|
|
427
430
|
--help, -h Show this help
|
|
428
431
|
|
|
@@ -526,6 +529,11 @@ function buildCommand(args) {
|
|
|
526
529
|
usageError(`unknown browser subcommand '${sub}' (expected launch | navigate | eval)`);
|
|
527
530
|
}
|
|
528
531
|
switch (args.command) {
|
|
532
|
+
case "permissions": {
|
|
533
|
+
const mode = args.rest[0];
|
|
534
|
+
if (mode !== "setup" && mode !== "recheck") usageError("permissions requires setup | recheck");
|
|
535
|
+
return { command: "permissions", params: { mode } };
|
|
536
|
+
}
|
|
529
537
|
case "status":
|
|
530
538
|
return { command: "status", params: {} };
|
|
531
539
|
case "stop":
|
|
@@ -655,6 +663,7 @@ async function main() {
|
|
|
655
663
|
ownerId: ownerId === COMPUTER_USE_STANDALONE_OWNER ? ownerId : ownerId,
|
|
656
664
|
executionId,
|
|
657
665
|
requestId,
|
|
666
|
+
generation: optionalFlag(args, "--generation"),
|
|
658
667
|
cwd: process.cwd(),
|
|
659
668
|
budgetMs,
|
|
660
669
|
spawnIfMissing: !control
|
|
@@ -2,7 +2,7 @@ import { createRequire as __createRequire } from "node:module"; const require =
|
|
|
2
2
|
import {
|
|
3
3
|
Agent,
|
|
4
4
|
getToolCallerIdentity
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-GZDAIW6F.js";
|
|
6
6
|
import {
|
|
7
7
|
AssistantMessageEventStream,
|
|
8
8
|
FileSystemGateway,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
getPlatformConfig,
|
|
13
13
|
hashText,
|
|
14
14
|
streamSimple
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-BRFP5WZ6.js";
|
|
16
16
|
import {
|
|
17
17
|
Type
|
|
18
18
|
} from "./chunk-XXGYUYXI.js";
|
|
@@ -978,6 +978,39 @@ var SIMPLE_READ_COMMANDS = /* @__PURE__ */ new Set(["pwd", "ls", "cat", "head",
|
|
|
978
978
|
var GIT_READ_SUBCOMMANDS = /* @__PURE__ */ new Set(["status", "log", "diff", "show", "rev-parse", "ls-files", "ls-tree", "blame", "describe", "shortlog", "merge-base"]);
|
|
979
979
|
var UNSAFE_GIT_FLAGS = /^(?:-c|--config-env|--exec|--output|--ext-diff|--textconv)(?:=|$)/;
|
|
980
980
|
var UNSAFE_RG_FLAGS = /^(?:--pre|--pre-glob)(?:=|$)/;
|
|
981
|
+
function longOptionUnsafe(arg, dangerous, benign) {
|
|
982
|
+
const name = arg.slice(2).split("=", 1)[0];
|
|
983
|
+
if (!name) return true;
|
|
984
|
+
if (dangerous.some((option) => option.startsWith(name))) return true;
|
|
985
|
+
return !benign.some((option) => option.startsWith(name));
|
|
986
|
+
}
|
|
987
|
+
function isReadOnlyUniq(args) {
|
|
988
|
+
let operands = 0;
|
|
989
|
+
let endOptions = false;
|
|
990
|
+
for (let i = 0; i < args.length; i++) {
|
|
991
|
+
const arg = args[i];
|
|
992
|
+
if (!endOptions && arg === "--") {
|
|
993
|
+
endOptions = true;
|
|
994
|
+
continue;
|
|
995
|
+
}
|
|
996
|
+
if (!endOptions && arg.startsWith("--")) {
|
|
997
|
+
if (/^--(?:skip-fields|skip-chars|check-chars)(?:=\d+)?$/.test(arg)) {
|
|
998
|
+
if (!arg.includes("=") && !/^\d+$/.test(args[++i] ?? "")) return false;
|
|
999
|
+
} else if (longOptionUnsafe(arg, [], ["count", "repeated", "unique", "all-repeated", "group", "ignore-case", "zero-terminated", "help", "version"])) {
|
|
1000
|
+
return false;
|
|
1001
|
+
}
|
|
1002
|
+
continue;
|
|
1003
|
+
}
|
|
1004
|
+
if (!endOptions && arg.startsWith("-") && arg !== "-") {
|
|
1005
|
+
const match2 = /^-[cdDuiz]*(?:([fsw])(\d*))?$/.exec(arg);
|
|
1006
|
+
if (!match2) return false;
|
|
1007
|
+
if (match2[1] && !match2[2] && !/^\d+$/.test(args[++i] ?? "")) return false;
|
|
1008
|
+
continue;
|
|
1009
|
+
}
|
|
1010
|
+
if (++operands > 1) return false;
|
|
1011
|
+
}
|
|
1012
|
+
return true;
|
|
1013
|
+
}
|
|
981
1014
|
function isReadOnlySegment(words) {
|
|
982
1015
|
if (words.length === 0) return false;
|
|
983
1016
|
const [program, ...args] = words;
|
|
@@ -991,11 +1024,72 @@ function isReadOnlySegment(words) {
|
|
|
991
1024
|
return !args.some((arg) => /^-(?:exec|execdir|ok|okdir|delete|fprint|fls|fprintf)/.test(arg));
|
|
992
1025
|
}
|
|
993
1026
|
if (program === "tree") {
|
|
994
|
-
return !args.some((arg) => /^-o
|
|
1027
|
+
return !args.some((arg) => /^-[^-]*o/.test(arg) || arg.startsWith("--") && arg !== "--" && longOptionUnsafe(arg, ["output"], [
|
|
1028
|
+
"ascii",
|
|
1029
|
+
"charset",
|
|
1030
|
+
"color",
|
|
1031
|
+
"dirsfirst",
|
|
1032
|
+
"du",
|
|
1033
|
+
"filelimit",
|
|
1034
|
+
"hardlinks",
|
|
1035
|
+
"help",
|
|
1036
|
+
"ignore-case",
|
|
1037
|
+
"inode",
|
|
1038
|
+
"links",
|
|
1039
|
+
"metafirst",
|
|
1040
|
+
"noreport",
|
|
1041
|
+
"nolinks",
|
|
1042
|
+
"outdent",
|
|
1043
|
+
"quote",
|
|
1044
|
+
"sort",
|
|
1045
|
+
"timefmt",
|
|
1046
|
+
"version",
|
|
1047
|
+
"pattern",
|
|
1048
|
+
"matchdirs",
|
|
1049
|
+
"prune"
|
|
1050
|
+
]));
|
|
995
1051
|
}
|
|
996
1052
|
if (program === "sort") {
|
|
997
|
-
return !args.some((arg) =>
|
|
1053
|
+
return !args.some((arg) => {
|
|
1054
|
+
if (arg === "--") return false;
|
|
1055
|
+
if (arg.startsWith("--")) {
|
|
1056
|
+
return longOptionUnsafe(arg, ["output", "compress-program"], [
|
|
1057
|
+
"numeric-sort",
|
|
1058
|
+
"general-numeric-sort",
|
|
1059
|
+
"human-numeric-sort",
|
|
1060
|
+
"month-sort",
|
|
1061
|
+
"version-sort",
|
|
1062
|
+
"random-sort",
|
|
1063
|
+
"random-source",
|
|
1064
|
+
"reverse",
|
|
1065
|
+
"unique",
|
|
1066
|
+
"check",
|
|
1067
|
+
"check-silent",
|
|
1068
|
+
"ignore-case",
|
|
1069
|
+
"ignore-leading-blanks",
|
|
1070
|
+
"ignore-nonprinting",
|
|
1071
|
+
"ignore-blanks",
|
|
1072
|
+
"dictionary-order",
|
|
1073
|
+
"merge",
|
|
1074
|
+
"stable",
|
|
1075
|
+
"batch-size",
|
|
1076
|
+
"buffer-size",
|
|
1077
|
+
"pipe-size",
|
|
1078
|
+
"parallel",
|
|
1079
|
+
"temporary-directory",
|
|
1080
|
+
"field-separator",
|
|
1081
|
+
"zero-terminated",
|
|
1082
|
+
"help",
|
|
1083
|
+
"version",
|
|
1084
|
+
"debug",
|
|
1085
|
+
"sort"
|
|
1086
|
+
]);
|
|
1087
|
+
}
|
|
1088
|
+
if (arg.startsWith("-") && arg !== "-") return arg.slice(1).includes("o");
|
|
1089
|
+
return false;
|
|
1090
|
+
});
|
|
998
1091
|
}
|
|
1092
|
+
if (program === "uniq") return isReadOnlyUniq(args);
|
|
999
1093
|
if (program === "date") {
|
|
1000
1094
|
return args.every((arg) => arg.startsWith("-") || arg.startsWith("+"));
|
|
1001
1095
|
}
|
|
@@ -1059,6 +1153,7 @@ ${inlineMatch[1]}`;
|
|
|
1059
1153
|
function isPlanModeSafeCommand(command) {
|
|
1060
1154
|
const trimmed = command.trim();
|
|
1061
1155
|
if (!trimmed || /[$`\n\r\0]/.test(trimmed)) return false;
|
|
1156
|
+
if (/\{[^{}]*\}/.test(trimmed) || /\{\s*,/.test(trimmed)) return false;
|
|
1062
1157
|
let tokens;
|
|
1063
1158
|
try {
|
|
1064
1159
|
tokens = (0, import_shell_quote.parse)(trimmed);
|
|
@@ -3193,6 +3288,9 @@ function isTransientCompactionFailure(error) {
|
|
|
3193
3288
|
if (status !== void 0) return status === 429 || status >= 500 && status <= 599;
|
|
3194
3289
|
return /\b(?:429|5\d\d|ECONNRESET|ETIMEDOUT|EAI_AGAIN|ENOTFOUND|ECONNREFUSED|EPIPE)\b|fetch failed|network error|request timeout|socket hang up|connection error|sse stream (?:aborted|closed before end|ended before response completed)|rate.?limit|too many requests|overloaded|service unavailable/i.test(text);
|
|
3195
3290
|
}
|
|
3291
|
+
function explicitlyNonRetryable(error) {
|
|
3292
|
+
return Boolean(error && typeof error === "object" && error.retryable === false);
|
|
3293
|
+
}
|
|
3196
3294
|
function waitForCompactionRetry(delayMs, signal) {
|
|
3197
3295
|
return new Promise((resolve2, reject) => {
|
|
3198
3296
|
const abort = () => {
|
|
@@ -3245,11 +3343,14 @@ Return a text-only successor handoff. Do not call any tools.` }],
|
|
|
3245
3343
|
).result();
|
|
3246
3344
|
throwIfAborted();
|
|
3247
3345
|
if (response.stopReason === "error" && !response.content.some((block) => block.type === "toolCall")) {
|
|
3248
|
-
|
|
3346
|
+
const providerError = new Error(response.errorMessage || "Compaction provider error");
|
|
3347
|
+
const explicitRetryable = response.retryable;
|
|
3348
|
+
if (typeof explicitRetryable === "boolean") providerError.retryable = explicitRetryable;
|
|
3349
|
+
throw providerError;
|
|
3249
3350
|
}
|
|
3250
3351
|
} catch (error) {
|
|
3251
3352
|
throwIfAborted();
|
|
3252
|
-
if (attempt >= 2 || !isTransientCompactionFailure(error)) throw error;
|
|
3353
|
+
if (attempt >= 2 || explicitlyNonRetryable(error) || !isTransientCompactionFailure(error)) throw error;
|
|
3253
3354
|
await waitForCompactionRetry(250 * 2 ** attempt, signal);
|
|
3254
3355
|
continue;
|
|
3255
3356
|
}
|
|
@@ -3680,6 +3781,10 @@ var LruCache = class {
|
|
|
3680
3781
|
weigh;
|
|
3681
3782
|
maxWeight;
|
|
3682
3783
|
map = /* @__PURE__ */ new Map();
|
|
3784
|
+
total = 0;
|
|
3785
|
+
weightOf(value) {
|
|
3786
|
+
return this.weigh ? this.weigh(value) : 1;
|
|
3787
|
+
}
|
|
3683
3788
|
get(key) {
|
|
3684
3789
|
const value = this.map.get(key);
|
|
3685
3790
|
if (value !== void 0) {
|
|
@@ -3690,34 +3795,36 @@ var LruCache = class {
|
|
|
3690
3795
|
}
|
|
3691
3796
|
/** Insert a value, evicting until the entry and total weight fit. */
|
|
3692
3797
|
set(key, value) {
|
|
3693
|
-
this.map.
|
|
3694
|
-
|
|
3798
|
+
const existing = this.map.get(key);
|
|
3799
|
+
if (existing !== void 0) {
|
|
3800
|
+
this.total -= this.weightOf(existing);
|
|
3801
|
+
this.map.delete(key);
|
|
3802
|
+
}
|
|
3803
|
+
const weight = this.weightOf(value);
|
|
3695
3804
|
if (weight > this.maxWeight) {
|
|
3696
3805
|
return;
|
|
3697
3806
|
}
|
|
3698
|
-
|
|
3699
|
-
while ((this.map.size >= this.limit || total > this.maxWeight) && this.map.size > 0) {
|
|
3807
|
+
this.total += weight;
|
|
3808
|
+
while ((this.map.size >= this.limit || this.total > this.maxWeight) && this.map.size > 0) {
|
|
3700
3809
|
const oldest = this.map.keys().next().value;
|
|
3701
|
-
|
|
3702
|
-
total -= this.weigh ? this.weigh(evicted) : 1;
|
|
3810
|
+
this.total -= this.weightOf(this.map.get(oldest));
|
|
3703
3811
|
this.map.delete(oldest);
|
|
3704
3812
|
}
|
|
3705
3813
|
this.map.set(key, value);
|
|
3706
3814
|
}
|
|
3707
3815
|
delete(key) {
|
|
3708
|
-
this.map.
|
|
3816
|
+
const existing = this.map.get(key);
|
|
3817
|
+
if (existing !== void 0) {
|
|
3818
|
+
this.total -= this.weightOf(existing);
|
|
3819
|
+
this.map.delete(key);
|
|
3820
|
+
}
|
|
3709
3821
|
}
|
|
3710
3822
|
clear() {
|
|
3711
3823
|
this.map.clear();
|
|
3824
|
+
this.total = 0;
|
|
3712
3825
|
}
|
|
3713
3826
|
get weight() {
|
|
3714
|
-
return this.
|
|
3715
|
-
}
|
|
3716
|
-
totalWeight() {
|
|
3717
|
-
if (!this.weigh) return this.map.size;
|
|
3718
|
-
let total = 0;
|
|
3719
|
-
for (const value of this.map.values()) total += this.weigh(value);
|
|
3720
|
-
return total;
|
|
3827
|
+
return this.total;
|
|
3721
3828
|
}
|
|
3722
3829
|
};
|
|
3723
3830
|
function isRecord(value) {
|
|
@@ -6855,6 +6962,17 @@ function isAssistantTerminalCompletion(message) {
|
|
|
6855
6962
|
}
|
|
6856
6963
|
function createFailureClassification(context, retry, classifyFailure) {
|
|
6857
6964
|
if (context.message?.role === "assistant" && context.message.retryable === false) {
|
|
6965
|
+
if (context.message.replayEligible === true) {
|
|
6966
|
+
return {
|
|
6967
|
+
kind: "provider_transient",
|
|
6968
|
+
retryable: true,
|
|
6969
|
+
compactable: false,
|
|
6970
|
+
userAbort: context.message.stopReason === "aborted",
|
|
6971
|
+
terminal: false,
|
|
6972
|
+
message: context.errorMessage,
|
|
6973
|
+
replayExempt: true
|
|
6974
|
+
};
|
|
6975
|
+
}
|
|
6858
6976
|
return { kind: "unknown", retryable: false, compactable: false, userAbort: context.message.stopReason === "aborted", terminal: true, message: context.errorMessage };
|
|
6859
6977
|
}
|
|
6860
6978
|
const hostClassification = classifyFailure?.(context);
|
|
@@ -6873,13 +6991,7 @@ function createFailureClassification(context, retry, classifyFailure) {
|
|
|
6873
6991
|
};
|
|
6874
6992
|
}
|
|
6875
6993
|
function asTerminalFailure(failure, message = failure.message) {
|
|
6876
|
-
return {
|
|
6877
|
-
...failure,
|
|
6878
|
-
retryable: false,
|
|
6879
|
-
compactable: false,
|
|
6880
|
-
terminal: true,
|
|
6881
|
-
message
|
|
6882
|
-
};
|
|
6994
|
+
return { ...failure, retryable: false, compactable: false, terminal: true, message };
|
|
6883
6995
|
}
|
|
6884
6996
|
function emitTurnEndPolicyFailure(emit, error) {
|
|
6885
6997
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -6907,6 +7019,36 @@ function handleTurnEndPolicyThrow(emit, error, context) {
|
|
|
6907
7019
|
emit({ type: "turn_policy_error", message: `Turn-end policy failed after settle: ${message}` });
|
|
6908
7020
|
}
|
|
6909
7021
|
|
|
7022
|
+
// ../../packages/agent-framework/src/session/controller/replay-stall-circuit.ts
|
|
7023
|
+
var ReplayStallCircuit = class {
|
|
7024
|
+
constructor(limit) {
|
|
7025
|
+
this.limit = limit;
|
|
7026
|
+
}
|
|
7027
|
+
limit;
|
|
7028
|
+
consecutiveStalls = 0;
|
|
7029
|
+
open = false;
|
|
7030
|
+
get isOpen() {
|
|
7031
|
+
return this.open;
|
|
7032
|
+
}
|
|
7033
|
+
get consecutiveTurnStalls() {
|
|
7034
|
+
return this.consecutiveStalls;
|
|
7035
|
+
}
|
|
7036
|
+
/** A replay-exempt retry budget was exhausted for this turn. */
|
|
7037
|
+
recordReplayExhaustion() {
|
|
7038
|
+
this.consecutiveStalls += 1;
|
|
7039
|
+
if (this.limit !== void 0 && this.consecutiveStalls >= this.limit && !this.open) {
|
|
7040
|
+
this.open = true;
|
|
7041
|
+
return { opened: true, consecutive: this.consecutiveStalls };
|
|
7042
|
+
}
|
|
7043
|
+
return { opened: false, consecutive: this.consecutiveStalls };
|
|
7044
|
+
}
|
|
7045
|
+
/** A turn succeeded, or failed in a way the endpoint actively answered. */
|
|
7046
|
+
recordHealthyTurn() {
|
|
7047
|
+
this.consecutiveStalls = 0;
|
|
7048
|
+
this.open = false;
|
|
7049
|
+
}
|
|
7050
|
+
};
|
|
7051
|
+
|
|
6910
7052
|
// ../../packages/agent-framework/src/session/controller/retry-policy.ts
|
|
6911
7053
|
function defaultSetTimeout4(callback, delay) {
|
|
6912
7054
|
return setTimeout(callback, delay);
|
|
@@ -6921,6 +7063,7 @@ var AgentSessionRetryController = class {
|
|
|
6921
7063
|
this.removeTrailingAssistantError = removeTrailingAssistantError2;
|
|
6922
7064
|
this.continueTurn = continueTurn;
|
|
6923
7065
|
this.setRecoveryState = setRecoveryState;
|
|
7066
|
+
this.replayCircuit = new ReplayStallCircuit(retry?.systemicReplayStallLimit);
|
|
6924
7067
|
}
|
|
6925
7068
|
retry;
|
|
6926
7069
|
emit;
|
|
@@ -6933,6 +7076,8 @@ var AgentSessionRetryController = class {
|
|
|
6933
7076
|
retryAttempts = /* @__PURE__ */ new Map();
|
|
6934
7077
|
/** Total attempts across kinds in this recovery episode, for reporting. */
|
|
6935
7078
|
totalRetryAttempts = 0;
|
|
7079
|
+
/** L2 systemic-stall circuit (see replay-stall-circuit.ts). */
|
|
7080
|
+
replayCircuit;
|
|
6936
7081
|
retryTimer;
|
|
6937
7082
|
retryEpoch = 0;
|
|
6938
7083
|
pendingRetry;
|
|
@@ -6946,12 +7091,17 @@ var AgentSessionRetryController = class {
|
|
|
6946
7091
|
waitForRetry() {
|
|
6947
7092
|
return this.pendingRetry ?? Promise.resolve();
|
|
6948
7093
|
}
|
|
7094
|
+
/** L2 circuit: healthy turn (success or an actively-answered failure). */
|
|
7095
|
+
noteEndpointHealthy() {
|
|
7096
|
+
this.replayCircuit.recordHealthyTurn();
|
|
7097
|
+
}
|
|
6949
7098
|
async handleTurnEnd(message, failure) {
|
|
6950
7099
|
if (!this.retry || !message || message.role !== "assistant") {
|
|
6951
7100
|
this.settleStrandedRetry(failure);
|
|
6952
7101
|
return;
|
|
6953
7102
|
}
|
|
6954
7103
|
if (!failure) {
|
|
7104
|
+
this.noteEndpointHealthy();
|
|
6955
7105
|
if (this.totalRetryAttempts > 0) {
|
|
6956
7106
|
this.emit({ type: "retry_succeeded", attempts: this.totalRetryAttempts });
|
|
6957
7107
|
this.emit({ type: "turn_retry_succeeded", attempts: this.totalRetryAttempts });
|
|
@@ -6962,6 +7112,9 @@ var AgentSessionRetryController = class {
|
|
|
6962
7112
|
return;
|
|
6963
7113
|
}
|
|
6964
7114
|
if (!failure.retryable) {
|
|
7115
|
+
if (failure.kind !== "unknown" && failure.kind !== "internal_error") {
|
|
7116
|
+
this.noteEndpointHealthy();
|
|
7117
|
+
}
|
|
6965
7118
|
if (this.totalRetryAttempts > 0) {
|
|
6966
7119
|
this.resetAttempts();
|
|
6967
7120
|
this.setRecoveryState("none");
|
|
@@ -6969,6 +7122,16 @@ var AgentSessionRetryController = class {
|
|
|
6969
7122
|
}
|
|
6970
7123
|
return;
|
|
6971
7124
|
}
|
|
7125
|
+
if (failure.replayExempt === true && this.replayCircuit.isOpen) {
|
|
7126
|
+
const openFailure = asTerminalFailure(failure, `${failure.message} (replay circuit open: ${this.replayCircuit.consecutiveTurnStalls} consecutive turns ended by timeout-replay exhaustion)`);
|
|
7127
|
+
this.emit({ type: "retry_exhausted", errorMessage: openFailure.message, maxRetries: 0 });
|
|
7128
|
+
this.emit({ type: "turn_failed_terminal", failure: openFailure, message });
|
|
7129
|
+
this.emit({ type: "turn_settled" });
|
|
7130
|
+
this.resetAttempts();
|
|
7131
|
+
this.setRecoveryState("terminal");
|
|
7132
|
+
this.resolvePending();
|
|
7133
|
+
return;
|
|
7134
|
+
}
|
|
6972
7135
|
const maxRetries = this.retry.maxRetriesForFailure?.(failure) ?? this.retry.maxRetries ?? 3;
|
|
6973
7136
|
const kindAttempts = (this.retryAttempts.get(failure.kind) ?? 0) + 1;
|
|
6974
7137
|
this.retryAttempts.set(failure.kind, kindAttempts);
|
|
@@ -6978,6 +7141,12 @@ var AgentSessionRetryController = class {
|
|
|
6978
7141
|
const totalExhausted = totalBudget !== void 0 && this.totalRetryAttempts > totalBudget;
|
|
6979
7142
|
if (kindExhausted || totalExhausted) {
|
|
6980
7143
|
const terminalFailure = asTerminalFailure(failure);
|
|
7144
|
+
if (failure.replayExempt === true) {
|
|
7145
|
+
const outcome = this.replayCircuit.recordReplayExhaustion();
|
|
7146
|
+
if (outcome.opened) {
|
|
7147
|
+
this.emit({ type: "retry_exhausted", errorMessage: `systemic timeout-stall: ${outcome.consecutive} consecutive turns ended by timeout-replay exhaustion`, maxRetries: totalExhausted ? totalBudget : maxRetries });
|
|
7148
|
+
}
|
|
7149
|
+
}
|
|
6981
7150
|
this.emit({ type: "retry_exhausted", errorMessage: failure.message, maxRetries: totalExhausted ? totalBudget : maxRetries });
|
|
6982
7151
|
this.emit({ type: "turn_failed_terminal", failure: terminalFailure, message });
|
|
6983
7152
|
this.emit({ type: "turn_settled" });
|
|
@@ -7012,11 +7181,7 @@ var AgentSessionRetryController = class {
|
|
|
7012
7181
|
if (epoch !== this.retryEpoch || pending !== this.pendingRetry) return;
|
|
7013
7182
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
7014
7183
|
const terminalFailure = asTerminalFailure(failure, errorMessage);
|
|
7015
|
-
this.emit({
|
|
7016
|
-
type: "retry_exhausted",
|
|
7017
|
-
errorMessage,
|
|
7018
|
-
maxRetries
|
|
7019
|
-
});
|
|
7184
|
+
this.emit({ type: "retry_exhausted", errorMessage, maxRetries });
|
|
7020
7185
|
this.emit({ type: "turn_failed_terminal", failure: terminalFailure, message });
|
|
7021
7186
|
this.emit({ type: "turn_settled" });
|
|
7022
7187
|
this.resetAttempts();
|
|
@@ -7071,9 +7236,7 @@ var AgentSessionRetryController = class {
|
|
|
7071
7236
|
this.retryTimer = void 0;
|
|
7072
7237
|
}
|
|
7073
7238
|
ensurePending() {
|
|
7074
|
-
if (this.pendingRetry)
|
|
7075
|
-
return;
|
|
7076
|
-
}
|
|
7239
|
+
if (this.pendingRetry) return;
|
|
7077
7240
|
this.pendingRetry = new Promise((resolve2) => {
|
|
7078
7241
|
this.resolvePendingRetry = resolve2;
|
|
7079
7242
|
});
|
|
@@ -1890,6 +1890,10 @@ var NodeHttpClient = class {
|
|
|
1890
1890
|
let tieredBodyByteSeen = false;
|
|
1891
1891
|
let tierMarkBodyByte = null;
|
|
1892
1892
|
let requestTimeoutError;
|
|
1893
|
+
const setTimeoutKind = (error, kind) => {
|
|
1894
|
+
if (!error) return;
|
|
1895
|
+
error.timeoutKind = kind;
|
|
1896
|
+
};
|
|
1893
1897
|
const clearTieredFirstByteTimer = () => {
|
|
1894
1898
|
if (tieredFirstByteTimer !== void 0) {
|
|
1895
1899
|
clearTimeout(tieredFirstByteTimer);
|
|
@@ -1933,6 +1937,7 @@ var NodeHttpClient = class {
|
|
|
1933
1937
|
res.on("timeout", () => {
|
|
1934
1938
|
if (res.readableEnded || res.complete) return;
|
|
1935
1939
|
requestTimeoutError = new Error(`Request timeout (stream idle) after ${tieredStreamIdleTimeoutMs}ms`);
|
|
1940
|
+
setTimeoutKind(requestTimeoutError, "stream_idle");
|
|
1936
1941
|
logHttp("WARN", `Request [${reqTag}] stream idle timeout`, { idleTimeoutMs: tieredStreamIdleTimeoutMs });
|
|
1937
1942
|
req.destroy(requestTimeoutError);
|
|
1938
1943
|
});
|
|
@@ -2178,6 +2183,7 @@ var NodeHttpClient = class {
|
|
|
2178
2183
|
if (!tieredStreamTimeout) {
|
|
2179
2184
|
req.on("timeout", () => {
|
|
2180
2185
|
requestTimeoutError = new Error("Request timeout");
|
|
2186
|
+
setTimeoutKind(requestTimeoutError, "total");
|
|
2181
2187
|
logHttp("ERROR", `Request [${reqTag}] timeout`);
|
|
2182
2188
|
req.destroy(requestTimeoutError);
|
|
2183
2189
|
});
|
|
@@ -2186,6 +2192,7 @@ var NodeHttpClient = class {
|
|
|
2186
2192
|
tieredFirstByteTimer = setTimeout(() => {
|
|
2187
2193
|
tieredFirstByteTimer = void 0;
|
|
2188
2194
|
requestTimeoutError = new Error(`Request timeout (first byte) after ${tieredFirstByteTimeoutMs}ms`);
|
|
2195
|
+
setTimeoutKind(requestTimeoutError, "first_byte");
|
|
2189
2196
|
logHttp("WARN", `Request [${reqTag}] first byte timeout`, { firstByteTimeoutMs: tieredFirstByteTimeoutMs });
|
|
2190
2197
|
req.destroy(requestTimeoutError);
|
|
2191
2198
|
}, tieredFirstByteTimeoutMs);
|
|
@@ -3368,6 +3375,10 @@ function buildBaseOptions(model, options, apiKey) {
|
|
|
3368
3375
|
sessionId: options?.sessionId,
|
|
3369
3376
|
headers: options?.headers,
|
|
3370
3377
|
timeoutMs: options?.timeoutMs,
|
|
3378
|
+
firstResponseTimeoutMs: options?.firstResponseTimeoutMs,
|
|
3379
|
+
streamIdleTimeoutMs: options?.streamIdleTimeoutMs,
|
|
3380
|
+
requestTimeoutMs: options?.requestTimeoutMs,
|
|
3381
|
+
connectionIdleTimeoutMs: options?.connectionIdleTimeoutMs,
|
|
3371
3382
|
onPayload: options?.onPayload,
|
|
3372
3383
|
onTransportDiagnostic: options?.onTransportDiagnostic,
|
|
3373
3384
|
onTransportLifecycle: options?.onTransportLifecycle,
|
|
@@ -4887,7 +4898,10 @@ function getResponsesCompat(model) {
|
|
|
4887
4898
|
supportsStore: compat.supportsStore ?? true,
|
|
4888
4899
|
supportsReasoningEffort: compat.supportsReasoningEffort ?? true,
|
|
4889
4900
|
supportsEncryptedReasoning: compat.supportsEncryptedReasoning ?? true,
|
|
4890
|
-
responsesContinuation: compat.responsesContinuation ?? false
|
|
4901
|
+
responsesContinuation: compat.responsesContinuation ?? false,
|
|
4902
|
+
supportsReasoningSummary: compat.supportsReasoningSummary ?? false,
|
|
4903
|
+
reasoningSummary: compat.reasoningSummary ?? "auto",
|
|
4904
|
+
timeoutReplay: compat.timeoutReplay ?? false
|
|
4891
4905
|
};
|
|
4892
4906
|
}
|
|
4893
4907
|
|
|
@@ -5074,6 +5088,10 @@ function buildResponsesRequest(model, context, options, compat = getResponsesCom
|
|
|
5074
5088
|
if (options?.reasoningEffort && model.reasoning && compat.supportsReasoningEffort) {
|
|
5075
5089
|
params.reasoning = { effort: options.reasoningEffort };
|
|
5076
5090
|
}
|
|
5091
|
+
if (model.reasoning && compat.supportsReasoningSummary && compat.reasoningSummary !== "none") {
|
|
5092
|
+
params.reasoning = params.reasoning ?? {};
|
|
5093
|
+
params.reasoning.summary = compat.reasoningSummary;
|
|
5094
|
+
}
|
|
5077
5095
|
if (compat.supportsEncryptedReasoning && model.reasoning) {
|
|
5078
5096
|
params.include = ["reasoning.encrypted_content"];
|
|
5079
5097
|
}
|
|
@@ -5606,6 +5624,8 @@ function monotonicNow() {
|
|
|
5606
5624
|
// ../../packages/ai/src/providers/responses/responses-sse.ts
|
|
5607
5625
|
var DEFAULT_RESPONSES_STREAM_IDLE_TIMEOUT_MS = 2 * 60 * 1e3;
|
|
5608
5626
|
var DEFAULT_RESPONSES_FIRST_BYTE_TIMEOUT_MS = 3 * 60 * 1e3;
|
|
5627
|
+
var REASONING_STREAM_IDLE_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
5628
|
+
var REASONING_FIRST_BYTE_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
5609
5629
|
function parseSSEDataLine2(line) {
|
|
5610
5630
|
const trimmed = line.trim();
|
|
5611
5631
|
if (!trimmed || trimmed.startsWith(":")) return null;
|
|
@@ -5635,16 +5655,19 @@ function explicitBudget(value, field) {
|
|
|
5635
5655
|
}
|
|
5636
5656
|
return value;
|
|
5637
5657
|
}
|
|
5638
|
-
function resolveSSEBudgets(options) {
|
|
5658
|
+
function resolveSSEBudgets(options, model) {
|
|
5639
5659
|
const firstResponse = explicitBudget(options?.firstResponseTimeoutMs, "firstResponseTimeoutMs");
|
|
5640
5660
|
const streamIdle = explicitBudget(options?.streamIdleTimeoutMs, "streamIdleTimeoutMs");
|
|
5641
5661
|
const requestTimeoutMs = explicitBudget(options?.requestTimeoutMs, "requestTimeoutMs");
|
|
5642
5662
|
explicitBudget(options?.connectionIdleTimeoutMs, "connectionIdleTimeoutMs");
|
|
5663
|
+
const reasoning = model.reasoning === true;
|
|
5664
|
+
const defaultFirstByte = reasoning ? REASONING_FIRST_BYTE_TIMEOUT_MS : DEFAULT_RESPONSES_FIRST_BYTE_TIMEOUT_MS;
|
|
5665
|
+
const defaultIdle = reasoning ? REASONING_STREAM_IDLE_TIMEOUT_MS : DEFAULT_RESPONSES_STREAM_IDLE_TIMEOUT_MS;
|
|
5643
5666
|
if (firstResponse !== void 0 || streamIdle !== void 0) {
|
|
5644
5667
|
return {
|
|
5645
5668
|
http: {
|
|
5646
|
-
firstByteTimeoutMs: firstResponse ??
|
|
5647
|
-
streamIdleTimeoutMs: streamIdle ??
|
|
5669
|
+
firstByteTimeoutMs: firstResponse ?? defaultFirstByte,
|
|
5670
|
+
streamIdleTimeoutMs: streamIdle ?? defaultIdle
|
|
5648
5671
|
},
|
|
5649
5672
|
requestTimeoutMs
|
|
5650
5673
|
};
|
|
@@ -5652,8 +5675,8 @@ function resolveSSEBudgets(options) {
|
|
|
5652
5675
|
if (options?.timeoutMs !== void 0) return { http: { timeoutMs: options.timeoutMs }, requestTimeoutMs };
|
|
5653
5676
|
return {
|
|
5654
5677
|
http: {
|
|
5655
|
-
firstByteTimeoutMs:
|
|
5656
|
-
streamIdleTimeoutMs:
|
|
5678
|
+
firstByteTimeoutMs: defaultFirstByte,
|
|
5679
|
+
streamIdleTimeoutMs: defaultIdle
|
|
5657
5680
|
},
|
|
5658
5681
|
requestTimeoutMs
|
|
5659
5682
|
};
|
|
@@ -5701,7 +5724,7 @@ function streamResponsesSSE(model, context, options) {
|
|
|
5701
5724
|
try {
|
|
5702
5725
|
let resolved;
|
|
5703
5726
|
try {
|
|
5704
|
-
resolved = resolveSSEBudgets(options);
|
|
5727
|
+
resolved = resolveSSEBudgets(options, model);
|
|
5705
5728
|
} catch (error) {
|
|
5706
5729
|
localFailure = true;
|
|
5707
5730
|
throw error;
|
|
@@ -5824,7 +5847,15 @@ function streamResponsesSSE(model, context, options) {
|
|
|
5824
5847
|
const message = reducer.message;
|
|
5825
5848
|
const userAborted = options?.signal?.aborted === true;
|
|
5826
5849
|
message.stopReason = userAborted ? "aborted" : "error";
|
|
5850
|
+
const adapterTimeoutKind = error instanceof Error ? error.timeoutKind : void 0;
|
|
5851
|
+
if (!internalTimeout && (adapterTimeoutKind === "first_byte" || adapterTimeoutKind === "stream_idle")) {
|
|
5852
|
+
internalTimeout = adapterTimeoutKind === "first_byte" ? "first_response" : "stream_idle";
|
|
5853
|
+
}
|
|
5827
5854
|
message.errorMessage = internalTimeout ? `Responses request timeout (${internalTimeout}) after ${Math.round(monotonicNow() - startedAt)}ms` : error instanceof Error ? error.message : JSON.stringify(error);
|
|
5855
|
+
if (internalTimeout && getResponsesCompat(model).timeoutReplay) {
|
|
5856
|
+
message.replayEligible = true;
|
|
5857
|
+
message.replayClass = internalTimeout;
|
|
5858
|
+
}
|
|
5828
5859
|
if (submitted || localFailure) message.retryable = false;
|
|
5829
5860
|
phase = "cleanup";
|
|
5830
5861
|
lifecycle({
|
|
@@ -5851,6 +5882,8 @@ var DEFAULT_CONNECT_TIMEOUT_MS = 3e4;
|
|
|
5851
5882
|
var DEFAULT_FIRST_RESPONSE_TIMEOUT_MS = 2 * 60 * 1e3;
|
|
5852
5883
|
var DEFAULT_STREAM_IDLE_TIMEOUT_MS = 2 * 60 * 1e3;
|
|
5853
5884
|
var DEFAULT_CONNECTION_IDLE_TIMEOUT_MS = 2 * 60 * 1e3;
|
|
5885
|
+
var REASONING_FIRST_RESPONSE_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
5886
|
+
var REASONING_STREAM_IDLE_TIMEOUT_MS2 = 5 * 60 * 1e3;
|
|
5854
5887
|
var ITERATOR_CLEANUP_TIMEOUT_MS = 1e3;
|
|
5855
5888
|
function explicitBudget2(value, field) {
|
|
5856
5889
|
if (value === void 0) return void 0;
|
|
@@ -5859,16 +5892,17 @@ function explicitBudget2(value, field) {
|
|
|
5859
5892
|
}
|
|
5860
5893
|
return value;
|
|
5861
5894
|
}
|
|
5862
|
-
function resolveBudgets(options) {
|
|
5895
|
+
function resolveBudgets(options, model) {
|
|
5863
5896
|
const firstResponse = explicitBudget2(options?.firstResponseTimeoutMs, "firstResponseTimeoutMs");
|
|
5864
5897
|
const streamIdle = explicitBudget2(options?.streamIdleTimeoutMs, "streamIdleTimeoutMs");
|
|
5865
5898
|
const requestTimeout = explicitBudget2(options?.requestTimeoutMs, "requestTimeoutMs");
|
|
5866
5899
|
const connectionIdle = explicitBudget2(options?.connectionIdleTimeoutMs, "connectionIdleTimeoutMs");
|
|
5867
5900
|
const legacy = options?.timeoutMs !== void 0 && Number.isFinite(options.timeoutMs) && options.timeoutMs > 0 ? options.timeoutMs : void 0;
|
|
5901
|
+
const reasoning = model.reasoning === true;
|
|
5868
5902
|
return {
|
|
5869
5903
|
connectTimeoutMs: legacy ?? DEFAULT_CONNECT_TIMEOUT_MS,
|
|
5870
|
-
firstResponseTimeoutMs: firstResponse ?? legacy ?? DEFAULT_FIRST_RESPONSE_TIMEOUT_MS,
|
|
5871
|
-
streamIdleTimeoutMs: streamIdle ?? legacy ?? DEFAULT_STREAM_IDLE_TIMEOUT_MS,
|
|
5904
|
+
firstResponseTimeoutMs: firstResponse ?? legacy ?? (reasoning ? REASONING_FIRST_RESPONSE_TIMEOUT_MS : DEFAULT_FIRST_RESPONSE_TIMEOUT_MS),
|
|
5905
|
+
streamIdleTimeoutMs: streamIdle ?? legacy ?? (reasoning ? REASONING_STREAM_IDLE_TIMEOUT_MS2 : DEFAULT_STREAM_IDLE_TIMEOUT_MS),
|
|
5872
5906
|
requestTimeoutMs: requestTimeout,
|
|
5873
5907
|
connectionIdleTimeoutMs: connectionIdle ?? DEFAULT_CONNECTION_IDLE_TIMEOUT_MS
|
|
5874
5908
|
};
|
|
@@ -5937,7 +5971,7 @@ function streamResponsesWS(model, context, options) {
|
|
|
5937
5971
|
}
|
|
5938
5972
|
let budgets;
|
|
5939
5973
|
try {
|
|
5940
|
-
budgets = resolveBudgets(options);
|
|
5974
|
+
budgets = resolveBudgets(options, model);
|
|
5941
5975
|
} catch (error) {
|
|
5942
5976
|
reducer.message.stopReason = "error";
|
|
5943
5977
|
reducer.message.errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -5966,6 +6000,7 @@ function streamResponsesWS(model, context, options) {
|
|
|
5966
6000
|
let requestTimer;
|
|
5967
6001
|
let totalTimer;
|
|
5968
6002
|
let receiveCleanupFailed = false;
|
|
6003
|
+
const compat = getResponsesCompat(model);
|
|
5969
6004
|
let cleanupCancelSource;
|
|
5970
6005
|
const requestAbort = new AbortController();
|
|
5971
6006
|
const publish = (event) => {
|
|
@@ -6081,7 +6116,9 @@ function streamResponsesWS(model, context, options) {
|
|
|
6081
6116
|
cancelSource: "internal_timeout",
|
|
6082
6117
|
retryAllowed: !sent,
|
|
6083
6118
|
retryDecision,
|
|
6084
|
-
submissionAttempted: sent
|
|
6119
|
+
submissionAttempted: sent,
|
|
6120
|
+
// L2 diagnostic surface: this timeout qualifies for bounded replay.
|
|
6121
|
+
...compat.timeoutReplay && sent ? { replayExempt: true } : {}
|
|
6085
6122
|
});
|
|
6086
6123
|
requestAbort.abort();
|
|
6087
6124
|
}, timeoutMs);
|
|
@@ -6273,6 +6310,10 @@ function streamResponsesWS(model, context, options) {
|
|
|
6273
6310
|
message.stopReason = userAborted || ownerDisposed ? "aborted" : "error";
|
|
6274
6311
|
const cause = timedOut ? `Responses request timeout (${timedOut}) after ${ageMs()}ms` : error instanceof Error ? error.message : String(error);
|
|
6275
6312
|
message.errorMessage = cause;
|
|
6313
|
+
if (timedOut && compat.timeoutReplay) {
|
|
6314
|
+
message.replayEligible = true;
|
|
6315
|
+
message.replayClass = timedOut;
|
|
6316
|
+
}
|
|
6276
6317
|
if (sent) {
|
|
6277
6318
|
message.retryable = false;
|
|
6278
6319
|
retryDecision = "not_retryable_after_submission";
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
createSharedWebSearchTool,
|
|
7
7
|
interpretShellExit,
|
|
8
8
|
requestInteraction
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-65B6P5J5.js";
|
|
10
10
|
import {
|
|
11
11
|
getLogger
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-BRFP5WZ6.js";
|
|
13
13
|
import {
|
|
14
14
|
Type
|
|
15
15
|
} from "./chunk-XXGYUYXI.js";
|
|
@@ -153,6 +153,7 @@ function formatTransportLifecycle(event) {
|
|
|
153
153
|
if (event.terminalAccepted !== void 0) parts.push(`terminal=${event.terminalAccepted ? "yes" : "no"}`);
|
|
154
154
|
if (event.retryAllowed !== void 0) parts.push(`retryAllowed=${event.retryAllowed ? "yes" : "no"}`);
|
|
155
155
|
if (event.retryDecision) parts.push(`retryDecision=${event.retryDecision}`);
|
|
156
|
+
if (event.replayExempt === true) parts.push("replayExempt=yes");
|
|
156
157
|
if (event.cancelSource) parts.push(`cancelSource=${event.cancelSource}`);
|
|
157
158
|
if (event.cleanupOutcome) parts.push(`cleanup=${event.cleanupOutcome}`);
|
|
158
159
|
if (event.singleAttempt) parts.push(`singleAttempt=${event.singleAttempt}`);
|