@ycodium-ai/agent-dsh 0.2.5407 → 0.2.5503
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/README.md +4 -1
- package/dist/index.js +608 -224
- package/package.json +6 -5
package/dist/index.js
CHANGED
|
@@ -2320,7 +2320,7 @@ var require_string = __commonJS({
|
|
|
2320
2320
|
"../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/schema/common/string.js"(exports) {
|
|
2321
2321
|
"use strict";
|
|
2322
2322
|
var stringifyString = require_stringifyString();
|
|
2323
|
-
var
|
|
2323
|
+
var string5 = {
|
|
2324
2324
|
identify: (value) => typeof value === "string",
|
|
2325
2325
|
default: true,
|
|
2326
2326
|
tag: "tag:yaml.org,2002:str",
|
|
@@ -2330,7 +2330,7 @@ var require_string = __commonJS({
|
|
|
2330
2330
|
return stringifyString.stringifyString(item, ctx, onComment, onChompKeep);
|
|
2331
2331
|
}
|
|
2332
2332
|
};
|
|
2333
|
-
exports.string =
|
|
2333
|
+
exports.string = string5;
|
|
2334
2334
|
}
|
|
2335
2335
|
});
|
|
2336
2336
|
|
|
@@ -2501,14 +2501,14 @@ var require_schema = __commonJS({
|
|
|
2501
2501
|
var map2 = require_map();
|
|
2502
2502
|
var _null4 = require_null();
|
|
2503
2503
|
var seq = require_seq();
|
|
2504
|
-
var
|
|
2504
|
+
var string5 = require_string();
|
|
2505
2505
|
var bool = require_bool();
|
|
2506
2506
|
var float = require_float();
|
|
2507
2507
|
var int2 = require_int();
|
|
2508
2508
|
var schema = [
|
|
2509
2509
|
map2.map,
|
|
2510
2510
|
seq.seq,
|
|
2511
|
-
|
|
2511
|
+
string5.string,
|
|
2512
2512
|
_null4.nullTag,
|
|
2513
2513
|
bool.boolTag,
|
|
2514
2514
|
int2.intOct,
|
|
@@ -3155,7 +3155,7 @@ var require_schema3 = __commonJS({
|
|
|
3155
3155
|
var map2 = require_map();
|
|
3156
3156
|
var _null4 = require_null();
|
|
3157
3157
|
var seq = require_seq();
|
|
3158
|
-
var
|
|
3158
|
+
var string5 = require_string();
|
|
3159
3159
|
var binary = require_binary();
|
|
3160
3160
|
var bool = require_bool2();
|
|
3161
3161
|
var float = require_float2();
|
|
@@ -3168,7 +3168,7 @@ var require_schema3 = __commonJS({
|
|
|
3168
3168
|
var schema = [
|
|
3169
3169
|
map2.map,
|
|
3170
3170
|
seq.seq,
|
|
3171
|
-
|
|
3171
|
+
string5.string,
|
|
3172
3172
|
_null4.nullTag,
|
|
3173
3173
|
bool.trueTag,
|
|
3174
3174
|
bool.falseTag,
|
|
@@ -3199,7 +3199,7 @@ var require_tags = __commonJS({
|
|
|
3199
3199
|
var map2 = require_map();
|
|
3200
3200
|
var _null4 = require_null();
|
|
3201
3201
|
var seq = require_seq();
|
|
3202
|
-
var
|
|
3202
|
+
var string5 = require_string();
|
|
3203
3203
|
var bool = require_bool();
|
|
3204
3204
|
var float = require_float();
|
|
3205
3205
|
var int2 = require_int();
|
|
@@ -3214,7 +3214,7 @@ var require_tags = __commonJS({
|
|
|
3214
3214
|
var timestamp = require_timestamp();
|
|
3215
3215
|
var schemas = /* @__PURE__ */ new Map([
|
|
3216
3216
|
["core", schema.schema],
|
|
3217
|
-
["failsafe", [map2.map, seq.seq,
|
|
3217
|
+
["failsafe", [map2.map, seq.seq, string5.string]],
|
|
3218
3218
|
["json", schema$1.schema],
|
|
3219
3219
|
["yaml11", schema$2.schema],
|
|
3220
3220
|
["yaml-1.1", schema$2.schema]
|
|
@@ -3293,7 +3293,7 @@ var require_Schema = __commonJS({
|
|
|
3293
3293
|
var identity = require_identity();
|
|
3294
3294
|
var map2 = require_map();
|
|
3295
3295
|
var seq = require_seq();
|
|
3296
|
-
var
|
|
3296
|
+
var string5 = require_string();
|
|
3297
3297
|
var tags = require_tags();
|
|
3298
3298
|
var sortMapEntriesByKey = (a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
|
|
3299
3299
|
var Schema = class _Schema {
|
|
@@ -3304,7 +3304,7 @@ var require_Schema = __commonJS({
|
|
|
3304
3304
|
this.tags = tags.getTags(customTags, this.name, merge2);
|
|
3305
3305
|
this.toStringOptions = toStringDefaults ?? null;
|
|
3306
3306
|
Object.defineProperty(this, identity.MAP, { value: map2.map });
|
|
3307
|
-
Object.defineProperty(this, identity.SCALAR, { value:
|
|
3307
|
+
Object.defineProperty(this, identity.SCALAR, { value: string5.string });
|
|
3308
3308
|
Object.defineProperty(this, identity.SEQ, { value: seq.seq });
|
|
3309
3309
|
this.sortMapEntries = typeof sortMapEntries === "function" ? sortMapEntries : sortMapEntries === true ? sortMapEntriesByKey : null;
|
|
3310
3310
|
}
|
|
@@ -4001,10 +4001,10 @@ var require_resolve_block_map = __commonJS({
|
|
|
4001
4001
|
let offset = bm.offset;
|
|
4002
4002
|
let commentEnd = null;
|
|
4003
4003
|
for (const collItem of bm.items) {
|
|
4004
|
-
const { start, key, sep, value } = collItem;
|
|
4004
|
+
const { start, key, sep: sep2, value } = collItem;
|
|
4005
4005
|
const keyProps = resolveProps.resolveProps(start, {
|
|
4006
4006
|
indicator: "explicit-key-ind",
|
|
4007
|
-
next: key ??
|
|
4007
|
+
next: key ?? sep2?.[0],
|
|
4008
4008
|
offset,
|
|
4009
4009
|
onError,
|
|
4010
4010
|
parentIndent: bm.indent,
|
|
@@ -4018,7 +4018,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
4018
4018
|
else if ("indent" in key && key.indent !== bm.indent)
|
|
4019
4019
|
onError(offset, "BAD_INDENT", startColMsg);
|
|
4020
4020
|
}
|
|
4021
|
-
if (!keyProps.anchor && !keyProps.tag && !
|
|
4021
|
+
if (!keyProps.anchor && !keyProps.tag && !sep2) {
|
|
4022
4022
|
commentEnd = keyProps.end;
|
|
4023
4023
|
if (keyProps.comment) {
|
|
4024
4024
|
if (map2.comment)
|
|
@@ -4042,7 +4042,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
4042
4042
|
ctx.atKey = false;
|
|
4043
4043
|
if (utilMapIncludes.mapIncludes(ctx, map2.items, keyNode))
|
|
4044
4044
|
onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
|
|
4045
|
-
const valueProps = resolveProps.resolveProps(
|
|
4045
|
+
const valueProps = resolveProps.resolveProps(sep2 ?? [], {
|
|
4046
4046
|
indicator: "map-value-ind",
|
|
4047
4047
|
next: value,
|
|
4048
4048
|
offset: keyNode.range[2],
|
|
@@ -4058,7 +4058,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
4058
4058
|
if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
|
|
4059
4059
|
onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
|
|
4060
4060
|
}
|
|
4061
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset,
|
|
4061
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep2, null, valueProps, onError);
|
|
4062
4062
|
if (ctx.schema.compat)
|
|
4063
4063
|
utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
|
|
4064
4064
|
offset = valueNode.range[2];
|
|
@@ -4149,7 +4149,7 @@ var require_resolve_end = __commonJS({
|
|
|
4149
4149
|
let comment = "";
|
|
4150
4150
|
if (end) {
|
|
4151
4151
|
let hasSpace = false;
|
|
4152
|
-
let
|
|
4152
|
+
let sep2 = "";
|
|
4153
4153
|
for (const token of end) {
|
|
4154
4154
|
const { source, type } = token;
|
|
4155
4155
|
switch (type) {
|
|
@@ -4163,13 +4163,13 @@ var require_resolve_end = __commonJS({
|
|
|
4163
4163
|
if (!comment)
|
|
4164
4164
|
comment = cb;
|
|
4165
4165
|
else
|
|
4166
|
-
comment +=
|
|
4167
|
-
|
|
4166
|
+
comment += sep2 + cb;
|
|
4167
|
+
sep2 = "";
|
|
4168
4168
|
break;
|
|
4169
4169
|
}
|
|
4170
4170
|
case "newline":
|
|
4171
4171
|
if (comment)
|
|
4172
|
-
|
|
4172
|
+
sep2 += source;
|
|
4173
4173
|
hasSpace = true;
|
|
4174
4174
|
break;
|
|
4175
4175
|
default:
|
|
@@ -4212,18 +4212,18 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4212
4212
|
let offset = fc.offset + fc.start.source.length;
|
|
4213
4213
|
for (let i = 0; i < fc.items.length; ++i) {
|
|
4214
4214
|
const collItem = fc.items[i];
|
|
4215
|
-
const { start, key, sep, value } = collItem;
|
|
4215
|
+
const { start, key, sep: sep2, value } = collItem;
|
|
4216
4216
|
const props = resolveProps.resolveProps(start, {
|
|
4217
4217
|
flow: fcName,
|
|
4218
4218
|
indicator: "explicit-key-ind",
|
|
4219
|
-
next: key ??
|
|
4219
|
+
next: key ?? sep2?.[0],
|
|
4220
4220
|
offset,
|
|
4221
4221
|
onError,
|
|
4222
4222
|
parentIndent: fc.indent,
|
|
4223
4223
|
startOnNewline: false
|
|
4224
4224
|
});
|
|
4225
4225
|
if (!props.found) {
|
|
4226
|
-
if (!props.anchor && !props.tag && !
|
|
4226
|
+
if (!props.anchor && !props.tag && !sep2 && !value) {
|
|
4227
4227
|
if (i === 0 && props.comma)
|
|
4228
4228
|
onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
|
|
4229
4229
|
else if (i < fc.items.length - 1)
|
|
@@ -4277,8 +4277,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4277
4277
|
}
|
|
4278
4278
|
}
|
|
4279
4279
|
}
|
|
4280
|
-
if (!isMap && !
|
|
4281
|
-
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end,
|
|
4280
|
+
if (!isMap && !sep2 && !props.found) {
|
|
4281
|
+
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep2, null, props, onError);
|
|
4282
4282
|
coll.items.push(valueNode);
|
|
4283
4283
|
offset = valueNode.range[2];
|
|
4284
4284
|
if (isBlock(value))
|
|
@@ -4290,7 +4290,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4290
4290
|
if (isBlock(key))
|
|
4291
4291
|
onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
4292
4292
|
ctx.atKey = false;
|
|
4293
|
-
const valueProps = resolveProps.resolveProps(
|
|
4293
|
+
const valueProps = resolveProps.resolveProps(sep2 ?? [], {
|
|
4294
4294
|
flow: fcName,
|
|
4295
4295
|
indicator: "map-value-ind",
|
|
4296
4296
|
next: value,
|
|
@@ -4301,8 +4301,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4301
4301
|
});
|
|
4302
4302
|
if (valueProps.found) {
|
|
4303
4303
|
if (!isMap && !props.found && ctx.options.strict) {
|
|
4304
|
-
if (
|
|
4305
|
-
for (const st of
|
|
4304
|
+
if (sep2)
|
|
4305
|
+
for (const st of sep2) {
|
|
4306
4306
|
if (st === valueProps.found)
|
|
4307
4307
|
break;
|
|
4308
4308
|
if (st.type === "newline") {
|
|
@@ -4319,7 +4319,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4319
4319
|
else
|
|
4320
4320
|
onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
|
|
4321
4321
|
}
|
|
4322
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end,
|
|
4322
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep2, null, valueProps, onError) : null;
|
|
4323
4323
|
if (valueNode) {
|
|
4324
4324
|
if (isBlock(value))
|
|
4325
4325
|
onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
@@ -4499,7 +4499,7 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
4499
4499
|
chompStart = i + 1;
|
|
4500
4500
|
}
|
|
4501
4501
|
let value = "";
|
|
4502
|
-
let
|
|
4502
|
+
let sep2 = "";
|
|
4503
4503
|
let prevMoreIndented = false;
|
|
4504
4504
|
for (let i = 0; i < contentStart; ++i)
|
|
4505
4505
|
value += lines[i][0].slice(trimIndent) + "\n";
|
|
@@ -4516,24 +4516,24 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
4516
4516
|
indent = "";
|
|
4517
4517
|
}
|
|
4518
4518
|
if (type === Scalar.Scalar.BLOCK_LITERAL) {
|
|
4519
|
-
value +=
|
|
4520
|
-
|
|
4519
|
+
value += sep2 + indent.slice(trimIndent) + content;
|
|
4520
|
+
sep2 = "\n";
|
|
4521
4521
|
} else if (indent.length > trimIndent || content[0] === " ") {
|
|
4522
|
-
if (
|
|
4523
|
-
|
|
4524
|
-
else if (!prevMoreIndented &&
|
|
4525
|
-
|
|
4526
|
-
value +=
|
|
4527
|
-
|
|
4522
|
+
if (sep2 === " ")
|
|
4523
|
+
sep2 = "\n";
|
|
4524
|
+
else if (!prevMoreIndented && sep2 === "\n")
|
|
4525
|
+
sep2 = "\n\n";
|
|
4526
|
+
value += sep2 + indent.slice(trimIndent) + content;
|
|
4527
|
+
sep2 = "\n";
|
|
4528
4528
|
prevMoreIndented = true;
|
|
4529
4529
|
} else if (content === "") {
|
|
4530
|
-
if (
|
|
4530
|
+
if (sep2 === "\n")
|
|
4531
4531
|
value += "\n";
|
|
4532
4532
|
else
|
|
4533
|
-
|
|
4533
|
+
sep2 = "\n";
|
|
4534
4534
|
} else {
|
|
4535
|
-
value +=
|
|
4536
|
-
|
|
4535
|
+
value += sep2 + content;
|
|
4536
|
+
sep2 = " ";
|
|
4537
4537
|
prevMoreIndented = false;
|
|
4538
4538
|
}
|
|
4539
4539
|
}
|
|
@@ -4715,25 +4715,25 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
4715
4715
|
if (!match)
|
|
4716
4716
|
return source;
|
|
4717
4717
|
let res = match[1];
|
|
4718
|
-
let
|
|
4718
|
+
let sep2 = " ";
|
|
4719
4719
|
let pos = first.lastIndex;
|
|
4720
4720
|
line.lastIndex = pos;
|
|
4721
4721
|
while (match = line.exec(source)) {
|
|
4722
4722
|
if (match[1] === "") {
|
|
4723
|
-
if (
|
|
4724
|
-
res +=
|
|
4723
|
+
if (sep2 === "\n")
|
|
4724
|
+
res += sep2;
|
|
4725
4725
|
else
|
|
4726
|
-
|
|
4726
|
+
sep2 = "\n";
|
|
4727
4727
|
} else {
|
|
4728
|
-
res +=
|
|
4729
|
-
|
|
4728
|
+
res += sep2 + match[1];
|
|
4729
|
+
sep2 = " ";
|
|
4730
4730
|
}
|
|
4731
4731
|
pos = line.lastIndex;
|
|
4732
4732
|
}
|
|
4733
4733
|
const last = /[ \t]*(.*)/sy;
|
|
4734
4734
|
last.lastIndex = pos;
|
|
4735
4735
|
match = last.exec(source);
|
|
4736
|
-
return res +
|
|
4736
|
+
return res + sep2 + (match?.[1] ?? "");
|
|
4737
4737
|
}
|
|
4738
4738
|
function doubleQuotedValue(source, onError) {
|
|
4739
4739
|
let res = "";
|
|
@@ -5543,14 +5543,14 @@ var require_cst_stringify = __commonJS({
|
|
|
5543
5543
|
}
|
|
5544
5544
|
}
|
|
5545
5545
|
}
|
|
5546
|
-
function stringifyItem({ start, key, sep, value }) {
|
|
5546
|
+
function stringifyItem({ start, key, sep: sep2, value }) {
|
|
5547
5547
|
let res = "";
|
|
5548
5548
|
for (const st of start)
|
|
5549
5549
|
res += st.source;
|
|
5550
5550
|
if (key)
|
|
5551
5551
|
res += stringifyToken(key);
|
|
5552
|
-
if (
|
|
5553
|
-
for (const st of
|
|
5552
|
+
if (sep2)
|
|
5553
|
+
for (const st of sep2)
|
|
5554
5554
|
res += st.source;
|
|
5555
5555
|
if (value)
|
|
5556
5556
|
res += stringifyToken(value);
|
|
@@ -6717,18 +6717,18 @@ var require_parser = __commonJS({
|
|
|
6717
6717
|
if (this.type === "map-value-ind") {
|
|
6718
6718
|
const prev = getPrevProps(this.peek(2));
|
|
6719
6719
|
const start = getFirstKeyStartProps(prev);
|
|
6720
|
-
let
|
|
6720
|
+
let sep2;
|
|
6721
6721
|
if (scalar.end) {
|
|
6722
|
-
|
|
6723
|
-
|
|
6722
|
+
sep2 = scalar.end;
|
|
6723
|
+
sep2.push(this.sourceToken);
|
|
6724
6724
|
delete scalar.end;
|
|
6725
6725
|
} else
|
|
6726
|
-
|
|
6726
|
+
sep2 = [this.sourceToken];
|
|
6727
6727
|
const map2 = {
|
|
6728
6728
|
type: "block-map",
|
|
6729
6729
|
offset: scalar.offset,
|
|
6730
6730
|
indent: scalar.indent,
|
|
6731
|
-
items: [{ start, key: scalar, sep }]
|
|
6731
|
+
items: [{ start, key: scalar, sep: sep2 }]
|
|
6732
6732
|
};
|
|
6733
6733
|
this.onKeyLine = true;
|
|
6734
6734
|
this.stack[this.stack.length - 1] = map2;
|
|
@@ -6881,15 +6881,15 @@ var require_parser = __commonJS({
|
|
|
6881
6881
|
} else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
|
|
6882
6882
|
const start2 = getFirstKeyStartProps(it.start);
|
|
6883
6883
|
const key = it.key;
|
|
6884
|
-
const
|
|
6885
|
-
|
|
6884
|
+
const sep2 = it.sep;
|
|
6885
|
+
sep2.push(this.sourceToken);
|
|
6886
6886
|
delete it.key;
|
|
6887
6887
|
delete it.sep;
|
|
6888
6888
|
this.stack.push({
|
|
6889
6889
|
type: "block-map",
|
|
6890
6890
|
offset: this.offset,
|
|
6891
6891
|
indent: this.indent,
|
|
6892
|
-
items: [{ start: start2, key, sep }]
|
|
6892
|
+
items: [{ start: start2, key, sep: sep2 }]
|
|
6893
6893
|
});
|
|
6894
6894
|
} else if (start.length > 0) {
|
|
6895
6895
|
it.sep = it.sep.concat(start, this.sourceToken);
|
|
@@ -7083,13 +7083,13 @@ var require_parser = __commonJS({
|
|
|
7083
7083
|
const prev = getPrevProps(parent);
|
|
7084
7084
|
const start = getFirstKeyStartProps(prev);
|
|
7085
7085
|
fixFlowSeqItems(fc);
|
|
7086
|
-
const
|
|
7087
|
-
|
|
7086
|
+
const sep2 = fc.end.splice(1, fc.end.length);
|
|
7087
|
+
sep2.push(this.sourceToken);
|
|
7088
7088
|
const map2 = {
|
|
7089
7089
|
type: "block-map",
|
|
7090
7090
|
offset: fc.offset,
|
|
7091
7091
|
indent: fc.indent,
|
|
7092
|
-
items: [{ start, key: fc, sep }]
|
|
7092
|
+
items: [{ start, key: fc, sep: sep2 }]
|
|
7093
7093
|
};
|
|
7094
7094
|
this.onKeyLine = true;
|
|
7095
7095
|
this.stack[this.stack.length - 1] = map2;
|
|
@@ -7371,11 +7371,11 @@ var require_dist = __commonJS({
|
|
|
7371
7371
|
import { definePlugin } from "@ycodium-ai/plugin-api";
|
|
7372
7372
|
|
|
7373
7373
|
// ../../packages/plugin-api/src/version.ts
|
|
7374
|
-
var PLUGIN_API_VERSION =
|
|
7374
|
+
var PLUGIN_API_VERSION = 173;
|
|
7375
7375
|
|
|
7376
7376
|
// src/index.ts
|
|
7377
|
-
import * as
|
|
7378
|
-
import * as
|
|
7377
|
+
import * as NodeOS9 from "node:os";
|
|
7378
|
+
import * as NodePath9 from "node:path";
|
|
7379
7379
|
import {
|
|
7380
7380
|
EXECUTOR_EFFECTIVE_PAYLOAD_SCHEMA,
|
|
7381
7381
|
executorHomeEffectiveValue,
|
|
@@ -7556,9 +7556,9 @@ function createApprovalGate(input2) {
|
|
|
7556
7556
|
return true;
|
|
7557
7557
|
};
|
|
7558
7558
|
const settleAll = (outcome) => {
|
|
7559
|
-
const
|
|
7559
|
+
const entries2 = list();
|
|
7560
7560
|
const settled = [];
|
|
7561
|
-
for (const entry of
|
|
7561
|
+
for (const entry of entries2) {
|
|
7562
7562
|
if (settle2(entry, outcome)) {
|
|
7563
7563
|
settled.push(entry);
|
|
7564
7564
|
}
|
|
@@ -8224,15 +8224,15 @@ function boundToolCallRawOutput(rawOutput) {
|
|
|
8224
8224
|
return rawOutput;
|
|
8225
8225
|
}
|
|
8226
8226
|
let changed = false;
|
|
8227
|
-
const
|
|
8227
|
+
const bounded2 = { ...rawOutput };
|
|
8228
8228
|
for (const field2 of RAW_OUTPUT_TEXT_FIELDS) {
|
|
8229
8229
|
const value = rawOutput[field2];
|
|
8230
8230
|
if (typeof value === "string" && value.length > TOOL_CALL_CONTENT_MAX_CHARS) {
|
|
8231
|
-
|
|
8231
|
+
bounded2[field2] = boundToolCallOutputText(value);
|
|
8232
8232
|
changed = true;
|
|
8233
8233
|
}
|
|
8234
8234
|
}
|
|
8235
|
-
return changed ?
|
|
8235
|
+
return changed ? bounded2 : rawOutput;
|
|
8236
8236
|
}
|
|
8237
8237
|
function toolCallContentText(entry) {
|
|
8238
8238
|
if (entry.type !== "content" || entry.content?.type !== "text") {
|
|
@@ -8259,7 +8259,7 @@ function extractTextContentFromToolCallContent(content) {
|
|
|
8259
8259
|
if (joined.length <= TOOL_CALL_CONTENT_MAX_CHARS) {
|
|
8260
8260
|
return { text: joined, content: typed };
|
|
8261
8261
|
}
|
|
8262
|
-
const
|
|
8262
|
+
const bounded2 = boundToolCallOutputText(joined);
|
|
8263
8263
|
const lastContributingTextIndex = typed.reduce(
|
|
8264
8264
|
(lastIndex, entry, index) => toolCallContentText(entry)?.trim() ? index : lastIndex,
|
|
8265
8265
|
-1
|
|
@@ -8271,9 +8271,9 @@ function extractTextContentFromToolCallContent(content) {
|
|
|
8271
8271
|
if (index !== lastContributingTextIndex) {
|
|
8272
8272
|
return [];
|
|
8273
8273
|
}
|
|
8274
|
-
return [{ type: "content", content: { type: "text", text:
|
|
8274
|
+
return [{ type: "content", content: { type: "text", text: bounded2 } }];
|
|
8275
8275
|
});
|
|
8276
|
-
return { text:
|
|
8276
|
+
return { text: bounded2, content: boundedContent };
|
|
8277
8277
|
}
|
|
8278
8278
|
function normalizeToolKind(kind) {
|
|
8279
8279
|
return typeof kind === "string" && kind.trim().length > 0 ? kind.trim() : void 0;
|
|
@@ -8580,8 +8580,8 @@ function parseSessionUpdateEvent(params) {
|
|
|
8580
8580
|
break;
|
|
8581
8581
|
}
|
|
8582
8582
|
case "plan": {
|
|
8583
|
-
const
|
|
8584
|
-
const plan =
|
|
8583
|
+
const entries2 = Array.isArray(upd["entries"]) ? upd["entries"] : [];
|
|
8584
|
+
const plan = entries2.map((entry, index) => ({
|
|
8585
8585
|
step: readAcpText(entry, "content") ?? `Step ${index + 1}`,
|
|
8586
8586
|
status: normalizePlanStepStatus(isRecord2(entry) ? entry["status"] : void 0)
|
|
8587
8587
|
}));
|
|
@@ -8904,10 +8904,10 @@ function createChildSessionRegistry(limit = CHILD_LIMIT) {
|
|
|
8904
8904
|
const records = /* @__PURE__ */ new Map();
|
|
8905
8905
|
const evictOne = (keep) => {
|
|
8906
8906
|
const protectedIds = /* @__PURE__ */ new Set();
|
|
8907
|
-
for (const [id,
|
|
8908
|
-
if (!active(
|
|
8907
|
+
for (const [id, record3] of records) {
|
|
8908
|
+
if (!active(record3.observed)) continue;
|
|
8909
8909
|
protectedIds.add(id);
|
|
8910
|
-
let parent =
|
|
8910
|
+
let parent = record3.parentAgentId;
|
|
8911
8911
|
while (parent !== void 0 && !protectedIds.has(parent)) {
|
|
8912
8912
|
protectedIds.add(parent);
|
|
8913
8913
|
parent = records.get(parent)?.parentAgentId;
|
|
@@ -8919,8 +8919,8 @@ function createChildSessionRegistry(limit = CHILD_LIMIT) {
|
|
|
8919
8919
|
return;
|
|
8920
8920
|
}
|
|
8921
8921
|
};
|
|
8922
|
-
const add = (sessionId,
|
|
8923
|
-
records.set(sessionId,
|
|
8922
|
+
const add = (sessionId, record3) => {
|
|
8923
|
+
records.set(sessionId, record3);
|
|
8924
8924
|
if (records.size > limit) evictOne(sessionId);
|
|
8925
8925
|
};
|
|
8926
8926
|
return {
|
|
@@ -9672,9 +9672,9 @@ function assertNever(_x) {
|
|
|
9672
9672
|
}
|
|
9673
9673
|
function assert(_) {
|
|
9674
9674
|
}
|
|
9675
|
-
function getEnumValues(
|
|
9676
|
-
const numericValues = Object.values(
|
|
9677
|
-
const values = Object.entries(
|
|
9675
|
+
function getEnumValues(entries2) {
|
|
9676
|
+
const numericValues = Object.values(entries2).filter((v) => typeof v === "number");
|
|
9677
|
+
const values = Object.entries(entries2).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
9678
9678
|
return values;
|
|
9679
9679
|
}
|
|
9680
9680
|
function joinValues(array2, separator = "|") {
|
|
@@ -11497,16 +11497,16 @@ var $ZodCheckProperties = /* @__PURE__ */ $constructor("$ZodCheckProperties", (i
|
|
|
11497
11497
|
hide(inst, Symbol.iterator, function* () {
|
|
11498
11498
|
yield inst;
|
|
11499
11499
|
});
|
|
11500
|
-
let
|
|
11500
|
+
let entries2;
|
|
11501
11501
|
inst._zod.check = (payload) => {
|
|
11502
11502
|
if (payload.value == null) {
|
|
11503
11503
|
payload.issues.push({ expected: "object", code: "invalid_type", input: payload.value, inst });
|
|
11504
11504
|
return void 0;
|
|
11505
11505
|
}
|
|
11506
|
-
|
|
11506
|
+
entries2 ?? (entries2 = Reflect.ownKeys(def.shape).map((key) => [key, def.shape[key]]));
|
|
11507
11507
|
const input2 = payload.value;
|
|
11508
11508
|
let proms;
|
|
11509
|
-
for (const [key, schema] of
|
|
11509
|
+
for (const [key, schema] of entries2) {
|
|
11510
11510
|
const result = schema._zod.run({ value: input2[key], issues: [] }, {});
|
|
11511
11511
|
if (result instanceof Promise) {
|
|
11512
11512
|
proms ?? (proms = []);
|
|
@@ -24288,18 +24288,18 @@ function _set(Class2, valueType, params) {
|
|
|
24288
24288
|
}
|
|
24289
24289
|
// @__NO_SIDE_EFFECTS__
|
|
24290
24290
|
function _enum(Class2, values, params) {
|
|
24291
|
-
const
|
|
24291
|
+
const entries2 = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
24292
24292
|
return new Class2({
|
|
24293
24293
|
type: "enum",
|
|
24294
|
-
entries,
|
|
24294
|
+
entries: entries2,
|
|
24295
24295
|
...normalizeParams(params)
|
|
24296
24296
|
});
|
|
24297
24297
|
}
|
|
24298
24298
|
// @__NO_SIDE_EFFECTS__
|
|
24299
|
-
function _nativeEnum(Class2,
|
|
24299
|
+
function _nativeEnum(Class2, entries2, params) {
|
|
24300
24300
|
return new Class2({
|
|
24301
24301
|
type: "enum",
|
|
24302
|
-
entries,
|
|
24302
|
+
entries: entries2,
|
|
24303
24303
|
...normalizeParams(params)
|
|
24304
24304
|
});
|
|
24305
24305
|
}
|
|
@@ -25601,8 +25601,8 @@ function rewriteKeyNames(ctx) {
|
|
|
25601
25601
|
bySchema.set(entry.schema, entry);
|
|
25602
25602
|
}
|
|
25603
25603
|
const rewrites = /* @__PURE__ */ new Map();
|
|
25604
|
-
for (const
|
|
25605
|
-
const seen = ctx.seen.get(
|
|
25604
|
+
for (const record3 of pendingRecords.get(ctx) ?? []) {
|
|
25605
|
+
const seen = ctx.seen.get(record3);
|
|
25606
25606
|
const names = (seen?.def ?? seen?.schema)?.propertyNames;
|
|
25607
25607
|
if (!names || names === true || rewrites.has(names))
|
|
25608
25608
|
continue;
|
|
@@ -27282,17 +27282,17 @@ var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
|
27282
27282
|
};
|
|
27283
27283
|
});
|
|
27284
27284
|
function _enum2(values, params) {
|
|
27285
|
-
const
|
|
27285
|
+
const entries2 = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
27286
27286
|
return new ZodEnum({
|
|
27287
27287
|
type: "enum",
|
|
27288
|
-
entries,
|
|
27288
|
+
entries: entries2,
|
|
27289
27289
|
...util_exports.normalizeParams(params)
|
|
27290
27290
|
});
|
|
27291
27291
|
}
|
|
27292
|
-
function nativeEnum(
|
|
27292
|
+
function nativeEnum(entries2, params) {
|
|
27293
27293
|
return new ZodEnum({
|
|
27294
27294
|
type: "enum",
|
|
27295
|
-
entries,
|
|
27295
|
+
entries: entries2,
|
|
27296
27296
|
...util_exports.normalizeParams(params)
|
|
27297
27297
|
});
|
|
27298
27298
|
}
|
|
@@ -30564,8 +30564,8 @@ var ConnectionContext = class {
|
|
|
30564
30564
|
/**
|
|
30565
30565
|
* Sends a non-empty JSON-RPC batch in one transport message.
|
|
30566
30566
|
*/
|
|
30567
|
-
sendBatch(
|
|
30568
|
-
return this.connection.sendBatch(
|
|
30567
|
+
sendBatch(entries2) {
|
|
30568
|
+
return this.connection.sendBatch(entries2);
|
|
30569
30569
|
}
|
|
30570
30570
|
/**
|
|
30571
30571
|
* Sends a protocol-level request cancellation notification.
|
|
@@ -30710,20 +30710,20 @@ var Connection = class {
|
|
|
30710
30710
|
* returned tuple preserves the input order: request entries resolve to their
|
|
30711
30711
|
* mapped response, while notification entries resolve to `undefined`.
|
|
30712
30712
|
*/
|
|
30713
|
-
sendBatch(
|
|
30713
|
+
sendBatch(entries2) {
|
|
30714
30714
|
if (this.abortController.signal.aborted) {
|
|
30715
30715
|
return rejectedPromise(this.closedReason());
|
|
30716
30716
|
}
|
|
30717
30717
|
if (!this.allowBatches) {
|
|
30718
30718
|
return rejectedPromise(new TypeError("JSON-RPC batches are not supported on this connection"));
|
|
30719
30719
|
}
|
|
30720
|
-
if (
|
|
30720
|
+
if (entries2.length === 0) {
|
|
30721
30721
|
return rejectedPromise(new TypeError("JSON-RPC batch must contain at least one entry"));
|
|
30722
30722
|
}
|
|
30723
30723
|
const messages = [];
|
|
30724
30724
|
const cancellations = [];
|
|
30725
30725
|
const outputs = [];
|
|
30726
|
-
for (const entry of
|
|
30726
|
+
for (const entry of entries2) {
|
|
30727
30727
|
if (entry.kind === "notification") {
|
|
30728
30728
|
messages.push({
|
|
30729
30729
|
jsonrpc: "2.0",
|
|
@@ -32503,9 +32503,9 @@ function createAcpConnection(options) {
|
|
|
32503
32503
|
let inboundTail = Promise.resolve();
|
|
32504
32504
|
const { resolve: resolveClosed, promise: closed } = Promise.withResolvers();
|
|
32505
32505
|
const rejectPending = (error62) => {
|
|
32506
|
-
const
|
|
32506
|
+
const entries2 = [...pending.values()];
|
|
32507
32507
|
pending.clear();
|
|
32508
|
-
for (const entry of
|
|
32508
|
+
for (const entry of entries2) {
|
|
32509
32509
|
entry.reject(error62);
|
|
32510
32510
|
}
|
|
32511
32511
|
};
|
|
@@ -32979,9 +32979,9 @@ function createExecutorLifecycle({
|
|
|
32979
32979
|
if (targetTurnId !== void 0) {
|
|
32980
32980
|
interruptedTurnIds.add(targetTurnId);
|
|
32981
32981
|
}
|
|
32982
|
-
const
|
|
32983
|
-
if (
|
|
32984
|
-
|
|
32982
|
+
const waiting = shared.localPromptWait;
|
|
32983
|
+
if (waiting !== void 0 && (targetTurnId === void 0 || waiting.turnId === targetTurnId)) {
|
|
32984
|
+
waiting.stop();
|
|
32985
32985
|
}
|
|
32986
32986
|
settleAllApprovals("cancel");
|
|
32987
32987
|
settleAllUserInputs();
|
|
@@ -33038,7 +33038,7 @@ function createExecutorLifecycle({
|
|
|
33038
33038
|
"Cannot compact while a turn or another compaction is running"
|
|
33039
33039
|
);
|
|
33040
33040
|
}
|
|
33041
|
-
const
|
|
33041
|
+
const record3 = {
|
|
33042
33042
|
snapshotId: randomId(),
|
|
33043
33043
|
trigger: "manual",
|
|
33044
33044
|
startedAtMs: nowMs(),
|
|
@@ -33048,7 +33048,7 @@ function createExecutorLifecycle({
|
|
|
33048
33048
|
adopted: false
|
|
33049
33049
|
};
|
|
33050
33050
|
await promptMutex.acquire();
|
|
33051
|
-
shared.manualCompaction =
|
|
33051
|
+
shared.manualCompaction = record3;
|
|
33052
33052
|
const emitSessionState = (state) => {
|
|
33053
33053
|
emit({
|
|
33054
33054
|
type: "session.state.changed",
|
|
@@ -33061,7 +33061,7 @@ function createExecutorLifecycle({
|
|
|
33061
33061
|
try {
|
|
33062
33062
|
failIfDisposed();
|
|
33063
33063
|
emitSessionState("compacting");
|
|
33064
|
-
emitCompactionState(
|
|
33064
|
+
emitCompactionState(record3, "compacting");
|
|
33065
33065
|
let response;
|
|
33066
33066
|
try {
|
|
33067
33067
|
response = await sendPromptRpc(started.sessionId, [
|
|
@@ -33075,13 +33075,13 @@ function createExecutorLifecycle({
|
|
|
33075
33075
|
if (response.stopReason === "cancelled") {
|
|
33076
33076
|
return;
|
|
33077
33077
|
}
|
|
33078
|
-
if (!
|
|
33079
|
-
|
|
33080
|
-
emitCompactionState(
|
|
33078
|
+
if (!record3.finished) {
|
|
33079
|
+
record3.finished = true;
|
|
33080
|
+
emitCompactionState(record3, "compacted");
|
|
33081
33081
|
}
|
|
33082
33082
|
} finally {
|
|
33083
33083
|
for (const [agentId, tracked] of compactions) {
|
|
33084
|
-
if (tracked ===
|
|
33084
|
+
if (tracked === record3) compactions.delete(agentId);
|
|
33085
33085
|
}
|
|
33086
33086
|
shared.manualCompaction = void 0;
|
|
33087
33087
|
promptMutex.release();
|
|
@@ -33094,6 +33094,7 @@ function createExecutorLifecycle({
|
|
|
33094
33094
|
if (disposing) return disposing;
|
|
33095
33095
|
shared.disposing = true;
|
|
33096
33096
|
disposing = (async () => {
|
|
33097
|
+
shared.localPromptWait?.stop();
|
|
33097
33098
|
if (exitCode !== void 0) {
|
|
33098
33099
|
let timer;
|
|
33099
33100
|
await Promise.race([
|
|
@@ -33169,10 +33170,10 @@ function selectAutoApprovedAcpPermissionOption(request) {
|
|
|
33169
33170
|
}
|
|
33170
33171
|
function parseAcpResumeCursor(raw, schemaVersion) {
|
|
33171
33172
|
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return void 0;
|
|
33172
|
-
const
|
|
33173
|
-
if (
|
|
33174
|
-
if (typeof
|
|
33175
|
-
return { sessionId:
|
|
33173
|
+
const record3 = raw;
|
|
33174
|
+
if (record3["schemaVersion"] !== schemaVersion) return void 0;
|
|
33175
|
+
if (typeof record3["sessionId"] !== "string" || !record3["sessionId"].trim()) return void 0;
|
|
33176
|
+
return { sessionId: record3["sessionId"].trim() };
|
|
33176
33177
|
}
|
|
33177
33178
|
function acpPromptSettlementBelongsToContext(input2) {
|
|
33178
33179
|
return input2.liveAcpSessionId === input2.expectedAcpSessionId && (input2.liveActiveTurnId === input2.turnId || input2.liveSessionActiveTurnId === input2.turnId);
|
|
@@ -33181,18 +33182,18 @@ function isAcpRequestPermissionParams(value) {
|
|
|
33181
33182
|
if (typeof value !== "object" || value === null) {
|
|
33182
33183
|
return false;
|
|
33183
33184
|
}
|
|
33184
|
-
const
|
|
33185
|
-
if (typeof
|
|
33185
|
+
const record3 = value;
|
|
33186
|
+
if (typeof record3["sessionId"] !== "string") {
|
|
33186
33187
|
return false;
|
|
33187
33188
|
}
|
|
33188
|
-
const toolCall =
|
|
33189
|
+
const toolCall = record3["toolCall"];
|
|
33189
33190
|
if (typeof toolCall !== "object" || toolCall === null) {
|
|
33190
33191
|
return false;
|
|
33191
33192
|
}
|
|
33192
33193
|
if (typeof toolCall["toolCallId"] !== "string") {
|
|
33193
33194
|
return false;
|
|
33194
33195
|
}
|
|
33195
|
-
return Array.isArray(
|
|
33196
|
+
return Array.isArray(record3["options"]);
|
|
33196
33197
|
}
|
|
33197
33198
|
|
|
33198
33199
|
// ../../packages/ycodium-acp-executor/src/apply-effort.ts
|
|
@@ -33633,7 +33634,7 @@ function createExecutorPrompt({
|
|
|
33633
33634
|
promptResults.forget(input2.turnId);
|
|
33634
33635
|
return true;
|
|
33635
33636
|
};
|
|
33636
|
-
const sendPromptRpc = async (sessionId, promptParts, onWritten,
|
|
33637
|
+
const sendPromptRpc = async (sessionId, promptParts, onWritten, record3) => {
|
|
33637
33638
|
const settlementHooks = hooks.promptSettlement;
|
|
33638
33639
|
const promptKey = settlementHooks === void 0 ? void 0 : randomId();
|
|
33639
33640
|
const pending = connection.begin(
|
|
@@ -33643,7 +33644,7 @@ function createExecutorPrompt({
|
|
|
33643
33644
|
prompt: promptParts,
|
|
33644
33645
|
...settlementHooks !== void 0 && promptKey !== void 0 ? settlementHooks.requestFields(promptKey) : {}
|
|
33645
33646
|
},
|
|
33646
|
-
|
|
33647
|
+
record3?.promptId
|
|
33647
33648
|
);
|
|
33648
33649
|
void pending.written.then(onWritten, () => void 0);
|
|
33649
33650
|
const promptRpc = pending.response;
|
|
@@ -33655,10 +33656,10 @@ function createExecutorPrompt({
|
|
|
33655
33656
|
promptKey,
|
|
33656
33657
|
sessionId,
|
|
33657
33658
|
settle: settleEarly,
|
|
33658
|
-
...
|
|
33659
|
-
onResponse: (response) => promptResults.receive(
|
|
33660
|
-
onError: () => promptResults.reject(
|
|
33661
|
-
hasResult: () =>
|
|
33659
|
+
...record3 === void 0 ? {} : {
|
|
33660
|
+
onResponse: (response) => promptResults.receive(record3.promptId, response),
|
|
33661
|
+
onError: () => promptResults.reject(record3.promptId),
|
|
33662
|
+
hasResult: () => record3.response !== void 0
|
|
33662
33663
|
}
|
|
33663
33664
|
});
|
|
33664
33665
|
try {
|
|
@@ -33752,11 +33753,11 @@ function createExecutorPrompt({
|
|
|
33752
33753
|
failIfPromptUnavailable();
|
|
33753
33754
|
const started = requireStarted();
|
|
33754
33755
|
const sessionId = started.sessionId;
|
|
33755
|
-
let
|
|
33756
|
+
let record3;
|
|
33756
33757
|
const settle2 = (rest) => settleTurn({
|
|
33757
33758
|
expectedGeneration: started.generation,
|
|
33758
33759
|
expectedSessionId: sessionId,
|
|
33759
|
-
record:
|
|
33760
|
+
record: record3,
|
|
33760
33761
|
...rest
|
|
33761
33762
|
});
|
|
33762
33763
|
let turnId;
|
|
@@ -33769,7 +33770,7 @@ function createExecutorPrompt({
|
|
|
33769
33770
|
randomId
|
|
33770
33771
|
);
|
|
33771
33772
|
shared.promptsInFlight += 1;
|
|
33772
|
-
|
|
33773
|
+
record3 = promptResults.add(
|
|
33773
33774
|
{
|
|
33774
33775
|
promptId: randomId(),
|
|
33775
33776
|
sessionId: started.sessionId,
|
|
@@ -33798,9 +33799,9 @@ function createExecutorPrompt({
|
|
|
33798
33799
|
const promptParts = input2.prompt ?? (input2.text !== void 0 ? [{ type: "text", text: input2.text }] : [{ type: "text", text: "" }]);
|
|
33799
33800
|
let contextWindow;
|
|
33800
33801
|
const finishPrompt = () => {
|
|
33801
|
-
if (!isLive(started.generation) ||
|
|
33802
|
-
const response2 =
|
|
33803
|
-
if (
|
|
33802
|
+
if (!isLive(started.generation) || record3.finished) throw new AcpExecutorDisposedError();
|
|
33803
|
+
const response2 = record3.response;
|
|
33804
|
+
if (record3.interrupted || response2 === void 0) {
|
|
33804
33805
|
settle2({ turnId, stopReason: "cancelled", state: "cancelled" });
|
|
33805
33806
|
return { threadId: options.threadId, turnId, stopReason: "cancelled" };
|
|
33806
33807
|
}
|
|
@@ -33843,7 +33844,7 @@ function createExecutorPrompt({
|
|
|
33843
33844
|
const isStale = () => interruptedTurnIds.has(queuedTurnId) || input2.expectedActiveTurnId !== void 0 && shared.activeTurnId !== queuedTurnId;
|
|
33844
33845
|
if (!isStale() && input2.expectedActiveTurnId === void 0) {
|
|
33845
33846
|
const optionWrites = new AbortController();
|
|
33846
|
-
shared.
|
|
33847
|
+
shared.localPromptWait = { turnId, stop: () => optionWrites.abort() };
|
|
33847
33848
|
try {
|
|
33848
33849
|
await alignTurnOptions(
|
|
33849
33850
|
input2,
|
|
@@ -33868,7 +33869,7 @@ function createExecutorPrompt({
|
|
|
33868
33869
|
});
|
|
33869
33870
|
throw error62 instanceof Error ? withFailureCategory(error62, failureCategory) : error62;
|
|
33870
33871
|
} finally {
|
|
33871
|
-
shared.
|
|
33872
|
+
shared.localPromptWait = void 0;
|
|
33872
33873
|
}
|
|
33873
33874
|
}
|
|
33874
33875
|
failIfDisposed();
|
|
@@ -33879,6 +33880,7 @@ function createExecutorPrompt({
|
|
|
33879
33880
|
closeActiveAssistantSegment(turnId);
|
|
33880
33881
|
let written = false;
|
|
33881
33882
|
try {
|
|
33883
|
+
const readFailure = hooks.observePromptFailure?.(sessionId);
|
|
33882
33884
|
response = await sendPromptRpc(
|
|
33883
33885
|
sessionId,
|
|
33884
33886
|
promptParts,
|
|
@@ -33886,8 +33888,18 @@ function createExecutorPrompt({
|
|
|
33886
33888
|
written = true;
|
|
33887
33889
|
input2.onDispatched?.(turnId);
|
|
33888
33890
|
},
|
|
33889
|
-
|
|
33891
|
+
record3
|
|
33890
33892
|
);
|
|
33893
|
+
if (readFailure && response.stopReason === "end_turn" && isLive(started.generation) && !isStale()) {
|
|
33894
|
+
const controller = new AbortController();
|
|
33895
|
+
shared.localPromptWait = { turnId, stop: () => controller.abort() };
|
|
33896
|
+
try {
|
|
33897
|
+
const failure2 = await readFailure(controller.signal);
|
|
33898
|
+
if (failure2 && !isStale() && !controller.signal.aborted) throw failure2;
|
|
33899
|
+
} finally {
|
|
33900
|
+
shared.localPromptWait = void 0;
|
|
33901
|
+
}
|
|
33902
|
+
}
|
|
33891
33903
|
} catch (caught) {
|
|
33892
33904
|
if (shared.disposed) {
|
|
33893
33905
|
throw new AcpExecutorDisposedError();
|
|
@@ -33931,7 +33943,7 @@ function createExecutorPrompt({
|
|
|
33931
33943
|
if (turnId === void 0) {
|
|
33932
33944
|
throw new AcpExecutorError("internal", "ACP prompt settled without a turn id");
|
|
33933
33945
|
}
|
|
33934
|
-
if (
|
|
33946
|
+
if (record3.finished) throw new AcpExecutorDisposedError();
|
|
33935
33947
|
if (hooks.readContextWindow !== void 0) {
|
|
33936
33948
|
try {
|
|
33937
33949
|
contextWindow = await hooks.readContextWindow({
|
|
@@ -33967,7 +33979,7 @@ function createPromptResults({
|
|
|
33967
33979
|
const prompts = /* @__PURE__ */ new Map();
|
|
33968
33980
|
const add = (identity, finish) => {
|
|
33969
33981
|
const { promise: done, resolve: resolve5 } = Promise.withResolvers();
|
|
33970
|
-
const
|
|
33982
|
+
const record3 = {
|
|
33971
33983
|
...identity,
|
|
33972
33984
|
finish,
|
|
33973
33985
|
done,
|
|
@@ -33976,49 +33988,49 @@ function createPromptResults({
|
|
|
33976
33988
|
interrupted: false,
|
|
33977
33989
|
finished: false
|
|
33978
33990
|
};
|
|
33979
|
-
prompts.set(
|
|
33980
|
-
return
|
|
33991
|
+
prompts.set(record3.promptId, record3);
|
|
33992
|
+
return record3;
|
|
33981
33993
|
};
|
|
33982
33994
|
const receive = (promptId, response) => {
|
|
33983
|
-
const
|
|
33984
|
-
if (!
|
|
33985
|
-
if (shared.disposed || shared.generation !==
|
|
33995
|
+
const record3 = prompts.get(promptId);
|
|
33996
|
+
if (!record3 || record3.finished || record3.rejected || record3.response !== void 0) return;
|
|
33997
|
+
if (shared.disposed || shared.generation !== record3.generation || shared.sessionId !== record3.sessionId)
|
|
33986
33998
|
return;
|
|
33987
|
-
|
|
33999
|
+
record3.response = response;
|
|
33988
34000
|
};
|
|
33989
34001
|
const reject = (promptId) => {
|
|
33990
|
-
const
|
|
33991
|
-
if (
|
|
34002
|
+
const record3 = prompts.get(promptId);
|
|
34003
|
+
if (record3 && record3.response === void 0) record3.rejected = true;
|
|
33992
34004
|
};
|
|
33993
34005
|
const stop = (turnId) => {
|
|
33994
|
-
for (const
|
|
33995
|
-
if (!
|
|
33996
|
-
|
|
34006
|
+
for (const record3 of prompts.values()) {
|
|
34007
|
+
if (!record3.finished && (turnId === void 0 || record3.turnId === turnId) && record3.response === void 0) {
|
|
34008
|
+
record3.interrupted = true;
|
|
33997
34009
|
}
|
|
33998
34010
|
}
|
|
33999
34011
|
};
|
|
34000
|
-
const complete = (
|
|
34001
|
-
|
|
34002
|
-
|
|
34012
|
+
const complete = (record3) => {
|
|
34013
|
+
record3.finished = true;
|
|
34014
|
+
record3.resolve();
|
|
34003
34015
|
};
|
|
34004
|
-
const hasInterrupted = (turnId) => [...prompts.values()].some((
|
|
34016
|
+
const hasInterrupted = (turnId) => [...prompts.values()].some((record3) => record3.turnId === turnId && record3.interrupted);
|
|
34005
34017
|
const forget = (turnId) => {
|
|
34006
|
-
for (const [id,
|
|
34007
|
-
if (
|
|
34008
|
-
complete(
|
|
34018
|
+
for (const [id, record3] of prompts) {
|
|
34019
|
+
if (record3.turnId === turnId) {
|
|
34020
|
+
complete(record3);
|
|
34009
34021
|
prompts.delete(id);
|
|
34010
34022
|
}
|
|
34011
34023
|
}
|
|
34012
34024
|
};
|
|
34013
34025
|
const wait = async (turnId, includeUnreceived = false) => {
|
|
34014
34026
|
const claimed = [...prompts.values()].filter(
|
|
34015
|
-
(
|
|
34027
|
+
(record3) => !record3.finished && (includeUnreceived || record3.response !== void 0) && (turnId === void 0 || record3.turnId === turnId)
|
|
34016
34028
|
);
|
|
34017
34029
|
if (claimed.length === 0) return;
|
|
34018
34030
|
let timer;
|
|
34019
34031
|
try {
|
|
34020
34032
|
const drained = await Promise.race([
|
|
34021
|
-
Promise.all(claimed.map((
|
|
34033
|
+
Promise.all(claimed.map((record3) => record3.done)).then(() => true),
|
|
34022
34034
|
new Promise((resolve5) => {
|
|
34023
34035
|
timer = setTimeout(
|
|
34024
34036
|
() => resolve5(false),
|
|
@@ -34028,19 +34040,19 @@ function createPromptResults({
|
|
|
34028
34040
|
]);
|
|
34029
34041
|
if (drained) return;
|
|
34030
34042
|
options.log?.warn?.("ACP result settlement timed out", { threadId: options.threadId });
|
|
34031
|
-
for (const
|
|
34043
|
+
for (const record3 of claimed) if (!record3.finished) record3.finish();
|
|
34032
34044
|
} finally {
|
|
34033
34045
|
clearTimeout(timer);
|
|
34034
34046
|
}
|
|
34035
34047
|
};
|
|
34036
34048
|
const finishUnreceived = () => {
|
|
34037
34049
|
const claimedTurns = new Set(
|
|
34038
|
-
[...prompts.values()].filter((
|
|
34050
|
+
[...prompts.values()].filter((record3) => !record3.finished && record3.response !== void 0).map((record3) => record3.turnId)
|
|
34039
34051
|
);
|
|
34040
|
-
for (const
|
|
34041
|
-
if (!
|
|
34042
|
-
if (claimedTurns.has(
|
|
34043
|
-
else complete(
|
|
34052
|
+
for (const record3 of prompts.values()) {
|
|
34053
|
+
if (!record3.finished && record3.response === void 0) {
|
|
34054
|
+
if (claimedTurns.has(record3.turnId)) record3.finish();
|
|
34055
|
+
else complete(record3);
|
|
34044
34056
|
}
|
|
34045
34057
|
}
|
|
34046
34058
|
};
|
|
@@ -35063,13 +35075,13 @@ function parseState(raw) {
|
|
|
35063
35075
|
if (stopReason === "cancelled") return { status: "cancelled", error: void 0 };
|
|
35064
35076
|
return { status: "idle", error: void 0 };
|
|
35065
35077
|
}
|
|
35066
|
-
function childLinkage(childId,
|
|
35078
|
+
function childLinkage(childId, record3) {
|
|
35067
35079
|
return {
|
|
35068
35080
|
taskType: "subagent",
|
|
35069
35081
|
rosterKind: "subagent",
|
|
35070
35082
|
nativeSessionId: childId,
|
|
35071
35083
|
timelineBypass: true,
|
|
35072
|
-
...
|
|
35084
|
+
...record3.title === void 0 ? {} : { title: record3.title }
|
|
35073
35085
|
};
|
|
35074
35086
|
}
|
|
35075
35087
|
function createSubagentSessionTracker(registry2) {
|
|
@@ -35085,9 +35097,9 @@ function createSubagentSessionTracker(registry2) {
|
|
|
35085
35097
|
const title = asTrimmedString(update["title"]);
|
|
35086
35098
|
const description = asTrimmedString(update["description"]);
|
|
35087
35099
|
const state = parseState(update["state"]);
|
|
35088
|
-
let
|
|
35089
|
-
if (
|
|
35090
|
-
|
|
35100
|
+
let record3 = registry2.get(childId);
|
|
35101
|
+
if (record3 === void 0) {
|
|
35102
|
+
record3 = {
|
|
35091
35103
|
turnId: ctx.turnId,
|
|
35092
35104
|
title,
|
|
35093
35105
|
description,
|
|
@@ -35099,40 +35111,40 @@ function createSubagentSessionTracker(registry2) {
|
|
|
35099
35111
|
announced: ctx.silent,
|
|
35100
35112
|
pendingMetadata: false
|
|
35101
35113
|
};
|
|
35102
|
-
registry2.add(childId,
|
|
35114
|
+
registry2.add(childId, record3);
|
|
35103
35115
|
}
|
|
35104
|
-
|
|
35116
|
+
record3.turnId ??= ctx.turnId;
|
|
35105
35117
|
if (!ctx.silent) {
|
|
35106
|
-
if (title !== void 0 && title !==
|
|
35107
|
-
|
|
35118
|
+
if (title !== void 0 && title !== record3.title || description !== void 0 && description !== record3.description) {
|
|
35119
|
+
record3.pendingMetadata = true;
|
|
35108
35120
|
}
|
|
35109
35121
|
}
|
|
35110
|
-
if (title !== void 0)
|
|
35111
|
-
if (description !== void 0)
|
|
35112
|
-
if (state.status !== void 0)
|
|
35122
|
+
if (title !== void 0) record3.title = title;
|
|
35123
|
+
if (description !== void 0) record3.description = description;
|
|
35124
|
+
if (state.status !== void 0) record3.observed = state.status;
|
|
35113
35125
|
if (ctx.silent) return [];
|
|
35114
|
-
const linkage2 = childLinkage(childId,
|
|
35115
|
-
const turn =
|
|
35126
|
+
const linkage2 = childLinkage(childId, record3);
|
|
35127
|
+
const turn = record3.turnId === void 0 ? {} : { turnId: record3.turnId };
|
|
35116
35128
|
const events = [];
|
|
35117
|
-
if (!
|
|
35118
|
-
if (!
|
|
35119
|
-
|
|
35120
|
-
|
|
35129
|
+
if (!record3.announced && state.status === void 0) return events;
|
|
35130
|
+
if (!record3.announced) {
|
|
35131
|
+
record3.announced = true;
|
|
35132
|
+
record3.pendingMetadata = false;
|
|
35121
35133
|
events.push({
|
|
35122
35134
|
type: "task.started",
|
|
35123
35135
|
...turn,
|
|
35124
35136
|
payload: {
|
|
35125
35137
|
taskId: childId,
|
|
35126
35138
|
...linkage2,
|
|
35127
|
-
...
|
|
35139
|
+
...record3.description === void 0 ? {} : { description: record3.description }
|
|
35128
35140
|
}
|
|
35129
35141
|
});
|
|
35130
35142
|
}
|
|
35131
|
-
const statusChanged = state.status !== void 0 && (state.status !==
|
|
35143
|
+
const statusChanged = state.status !== void 0 && (state.status !== record3.reported || record3.pendingMetadata || state.error !== void 0 && state.error !== record3.reportedError);
|
|
35132
35144
|
if (statusChanged) {
|
|
35133
|
-
|
|
35134
|
-
|
|
35135
|
-
|
|
35145
|
+
record3.pendingMetadata = false;
|
|
35146
|
+
record3.reported = state.status;
|
|
35147
|
+
record3.reportedError = state.status === "failed" ? state.error ?? record3.reportedError : void 0;
|
|
35136
35148
|
events.push({
|
|
35137
35149
|
type: "task.updated",
|
|
35138
35150
|
...turn,
|
|
@@ -35140,7 +35152,7 @@ function createSubagentSessionTracker(registry2) {
|
|
|
35140
35152
|
taskId: childId,
|
|
35141
35153
|
status: state.status,
|
|
35142
35154
|
...state.error === void 0 ? {} : { error: state.error },
|
|
35143
|
-
...
|
|
35155
|
+
...record3.description === void 0 ? {} : { description: record3.description },
|
|
35144
35156
|
...linkage2
|
|
35145
35157
|
}
|
|
35146
35158
|
});
|
|
@@ -35149,20 +35161,20 @@ function createSubagentSessionTracker(registry2) {
|
|
|
35149
35161
|
};
|
|
35150
35162
|
const settleSessionEnded = () => {
|
|
35151
35163
|
const events = [];
|
|
35152
|
-
for (const [childId,
|
|
35153
|
-
const last =
|
|
35154
|
-
if (!
|
|
35155
|
-
|
|
35156
|
-
|
|
35164
|
+
for (const [childId, record3] of registry2.entries()) {
|
|
35165
|
+
const last = record3.reported ?? record3.observed;
|
|
35166
|
+
if (!record3.announced || last !== "running" && last !== "waiting") continue;
|
|
35167
|
+
record3.reported = "idle";
|
|
35168
|
+
record3.observed = "idle";
|
|
35157
35169
|
events.push({
|
|
35158
35170
|
type: "task.updated",
|
|
35159
|
-
...
|
|
35171
|
+
...record3.turnId === void 0 ? {} : { turnId: record3.turnId },
|
|
35160
35172
|
payload: {
|
|
35161
35173
|
taskId: childId,
|
|
35162
35174
|
status: "idle",
|
|
35163
35175
|
outcomeUnknown: true,
|
|
35164
|
-
...
|
|
35165
|
-
...childLinkage(childId,
|
|
35176
|
+
...record3.description === void 0 ? {} : { description: record3.description },
|
|
35177
|
+
...childLinkage(childId, record3)
|
|
35166
35178
|
}
|
|
35167
35179
|
});
|
|
35168
35180
|
}
|
|
@@ -35191,8 +35203,8 @@ function createExecutorUpdates({
|
|
|
35191
35203
|
const shownToolCallIds = /* @__PURE__ */ new Set();
|
|
35192
35204
|
const markChildSession = shared.childSessions.mark;
|
|
35193
35205
|
const subagentSessions = options.subagentSessions === true ? createSubagentSessionTracker(shared.childSessions) : void 0;
|
|
35194
|
-
const emitCompactionState = (
|
|
35195
|
-
const summary =
|
|
35206
|
+
const emitCompactionState = (record3, state) => {
|
|
35207
|
+
const summary = record3.summary?.trim() ?? "";
|
|
35196
35208
|
const truncated = summary.length > COMPACTION_SUMMARY_MAX_CHARS;
|
|
35197
35209
|
emit({
|
|
35198
35210
|
type: "thread.state.changed",
|
|
@@ -35203,9 +35215,9 @@ function createExecutorUpdates({
|
|
|
35203
35215
|
payload: {
|
|
35204
35216
|
state,
|
|
35205
35217
|
compaction: {
|
|
35206
|
-
compactionId:
|
|
35207
|
-
trigger:
|
|
35208
|
-
...state === "compacted" ? { durationMs: Math.max(0, nowMs() -
|
|
35218
|
+
compactionId: record3.snapshotId,
|
|
35219
|
+
trigger: record3.trigger,
|
|
35220
|
+
...state === "compacted" ? { durationMs: Math.max(0, nowMs() - record3.startedAtMs) } : {},
|
|
35209
35221
|
...summary.length > 0 ? {
|
|
35210
35222
|
summary: truncated ? summary.slice(0, COMPACTION_SUMMARY_MAX_CHARS) : summary,
|
|
35211
35223
|
...truncated ? { summaryTruncated: true } : {}
|
|
@@ -35215,13 +35227,13 @@ function createExecutorUpdates({
|
|
|
35215
35227
|
});
|
|
35216
35228
|
};
|
|
35217
35229
|
const applyCompactionUpdate = (event) => {
|
|
35218
|
-
let
|
|
35219
|
-
if (
|
|
35230
|
+
let record3 = compactions.get(event.compactionId);
|
|
35231
|
+
if (record3 === void 0) {
|
|
35220
35232
|
if (shared.manualCompaction !== void 0 && !shared.manualCompaction.adopted) {
|
|
35221
35233
|
shared.manualCompaction.adopted = true;
|
|
35222
|
-
|
|
35234
|
+
record3 = shared.manualCompaction;
|
|
35223
35235
|
} else {
|
|
35224
|
-
|
|
35236
|
+
record3 = {
|
|
35225
35237
|
snapshotId: randomId(),
|
|
35226
35238
|
trigger: "automatic",
|
|
35227
35239
|
startedAtMs: nowMs(),
|
|
@@ -35231,25 +35243,25 @@ function createExecutorUpdates({
|
|
|
35231
35243
|
adopted: false
|
|
35232
35244
|
};
|
|
35233
35245
|
}
|
|
35234
|
-
compactions.set(event.compactionId,
|
|
35246
|
+
compactions.set(event.compactionId, record3);
|
|
35235
35247
|
}
|
|
35236
|
-
if (event.summary !== void 0)
|
|
35248
|
+
if (event.summary !== void 0) record3.summary = event.summary ?? void 0;
|
|
35237
35249
|
switch (event.status) {
|
|
35238
35250
|
case "in_progress":
|
|
35239
|
-
if (!
|
|
35240
|
-
|
|
35241
|
-
emitCompactionState(
|
|
35251
|
+
if (!record3.announced) {
|
|
35252
|
+
record3.announced = true;
|
|
35253
|
+
emitCompactionState(record3, "compacting");
|
|
35242
35254
|
}
|
|
35243
35255
|
return;
|
|
35244
35256
|
case "completed":
|
|
35245
|
-
|
|
35246
|
-
|
|
35257
|
+
record3.announced = true;
|
|
35258
|
+
record3.finished = true;
|
|
35247
35259
|
compactions.delete(event.compactionId);
|
|
35248
|
-
emitCompactionState(
|
|
35260
|
+
emitCompactionState(record3, "compacted");
|
|
35249
35261
|
return;
|
|
35250
35262
|
case "failed":
|
|
35251
35263
|
case "cancelled":
|
|
35252
|
-
|
|
35264
|
+
record3.finished = true;
|
|
35253
35265
|
compactions.delete(event.compactionId);
|
|
35254
35266
|
emit({
|
|
35255
35267
|
type: "runtime.warning",
|
|
@@ -35405,9 +35417,9 @@ function createExecutorUpdates({
|
|
|
35405
35417
|
continue;
|
|
35406
35418
|
}
|
|
35407
35419
|
if (event._tag === "CompactionSummaryChunk") {
|
|
35408
|
-
const
|
|
35409
|
-
if (
|
|
35410
|
-
|
|
35420
|
+
const record3 = compactions.get(event.compactionId);
|
|
35421
|
+
if (record3 !== void 0 && !record3.finished) {
|
|
35422
|
+
record3.summary = (record3.summary ?? "") + event.text;
|
|
35411
35423
|
}
|
|
35412
35424
|
continue;
|
|
35413
35425
|
}
|
|
@@ -35649,7 +35661,7 @@ function createAcpExecutor(options) {
|
|
|
35649
35661
|
childSessions: createChildSessionRegistry(),
|
|
35650
35662
|
sessionOpensInFlight: 0,
|
|
35651
35663
|
configOptionUpdates: /* @__PURE__ */ new Map(),
|
|
35652
|
-
|
|
35664
|
+
localPromptWait: void 0,
|
|
35653
35665
|
configUpdateSeq: 0
|
|
35654
35666
|
};
|
|
35655
35667
|
const interruptedTurnIds = /* @__PURE__ */ new Set();
|
|
@@ -36236,8 +36248,8 @@ function nodeStreamsFromHandle(handle, errors = ownErrors) {
|
|
|
36236
36248
|
}
|
|
36237
36249
|
|
|
36238
36250
|
// ../../packages/ycodium-acp-executor/src/mcp-servers.ts
|
|
36239
|
-
function toAcpMcpServers(
|
|
36240
|
-
return (
|
|
36251
|
+
function toAcpMcpServers(entries2) {
|
|
36252
|
+
return (entries2 ?? []).map(
|
|
36241
36253
|
(entry) => entry.transport.type === "stdio" ? {
|
|
36242
36254
|
name: entry.name,
|
|
36243
36255
|
command: entry.transport.command,
|
|
@@ -36610,6 +36622,49 @@ async function withAcpProbeProcess(input2) {
|
|
|
36610
36622
|
}
|
|
36611
36623
|
}
|
|
36612
36624
|
|
|
36625
|
+
// ../../packages/ycodium-jsonl-stream/src/sessionTranscript.ts
|
|
36626
|
+
var SESSION_IMPORT_ACTIVITY_TEXT_LIMIT = 32e3;
|
|
36627
|
+
function isoTranscriptTimestamp(value) {
|
|
36628
|
+
return typeof value === "number" && Math.abs(value) <= 864e13 ? new Date(value).toISOString() : void 0;
|
|
36629
|
+
}
|
|
36630
|
+
function bounded(value, tail = false) {
|
|
36631
|
+
if (value.length <= SESSION_IMPORT_ACTIVITY_TEXT_LIMIT) return { text: value, truncated: false };
|
|
36632
|
+
const offset = tail ? value.length - SESSION_IMPORT_ACTIVITY_TEXT_LIMIT : SESSION_IMPORT_ACTIVITY_TEXT_LIMIT;
|
|
36633
|
+
const character = value.charCodeAt(offset);
|
|
36634
|
+
const previous = value.charCodeAt(offset - 1);
|
|
36635
|
+
const splitPair = character >= 56320 && character <= 57343 && previous >= 55296 && previous <= 56319;
|
|
36636
|
+
return {
|
|
36637
|
+
text: tail ? value.slice(offset + (splitPair ? 1 : 0)) : value.slice(0, offset - (splitPair ? 1 : 0)),
|
|
36638
|
+
truncated: true
|
|
36639
|
+
};
|
|
36640
|
+
}
|
|
36641
|
+
function inputPayload(input2) {
|
|
36642
|
+
if (input2 === void 0) return {};
|
|
36643
|
+
const result = bounded(input2);
|
|
36644
|
+
return { input: result.text, ...result.truncated ? { inputTruncated: true } : {} };
|
|
36645
|
+
}
|
|
36646
|
+
function outputPayload(output2) {
|
|
36647
|
+
if (output2 === void 0) return {};
|
|
36648
|
+
const result = bounded(output2, true);
|
|
36649
|
+
return { output: result.text, ...result.truncated ? { outputTruncated: true } : {} };
|
|
36650
|
+
}
|
|
36651
|
+
function reasoning(identity, text, streamKind) {
|
|
36652
|
+
const result = bounded(text);
|
|
36653
|
+
return {
|
|
36654
|
+
...identity,
|
|
36655
|
+
kind: "reasoning",
|
|
36656
|
+
tone: "info",
|
|
36657
|
+
summary: "Reasoning",
|
|
36658
|
+
payload: {
|
|
36659
|
+
text: result.text,
|
|
36660
|
+
streamKind,
|
|
36661
|
+
chars: result.text.length,
|
|
36662
|
+
streaming: false,
|
|
36663
|
+
...result.truncated ? { truncated: true } : {}
|
|
36664
|
+
}
|
|
36665
|
+
};
|
|
36666
|
+
}
|
|
36667
|
+
|
|
36613
36668
|
// ../../packages/ycodium-instance-config/src/launchArgs.ts
|
|
36614
36669
|
function tokenizeShellWords(value) {
|
|
36615
36670
|
const input2 = value.trim();
|
|
@@ -37007,13 +37062,13 @@ function dumpConfigHasPermissionSync(dump) {
|
|
|
37007
37062
|
);
|
|
37008
37063
|
}
|
|
37009
37064
|
function dumpConfigEntries(dump) {
|
|
37010
|
-
let
|
|
37065
|
+
let entries2;
|
|
37011
37066
|
try {
|
|
37012
|
-
|
|
37067
|
+
entries2 = (0, import_yaml.parse)(dump);
|
|
37013
37068
|
} catch {
|
|
37014
37069
|
return [];
|
|
37015
37070
|
}
|
|
37016
|
-
return Array.isArray(
|
|
37071
|
+
return Array.isArray(entries2) ? entries2 : [];
|
|
37017
37072
|
}
|
|
37018
37073
|
async function dshOverlayPatchArgs(input2) {
|
|
37019
37074
|
const { skills, host, launch } = input2;
|
|
@@ -37253,6 +37308,334 @@ async function probeDshVersion(input2) {
|
|
|
37253
37308
|
});
|
|
37254
37309
|
}
|
|
37255
37310
|
|
|
37311
|
+
// src/nativeSessions.ts
|
|
37312
|
+
import * as NodeFS4 from "node:fs";
|
|
37313
|
+
import * as NodeFSP2 from "node:fs/promises";
|
|
37314
|
+
import * as NodeOS8 from "node:os";
|
|
37315
|
+
import * as NodePath8 from "node:path";
|
|
37316
|
+
import * as NodeReadline from "node:readline";
|
|
37317
|
+
import * as NodeStreamPromises from "node:stream/promises";
|
|
37318
|
+
import * as NodeZlib from "node:zlib";
|
|
37319
|
+
var DshTranscriptChangedError = class extends Error {
|
|
37320
|
+
};
|
|
37321
|
+
var SESSION_LOG = /^session(?:\.v([1-9][0-9]*))?\.jsonl(\.zstd)?$/;
|
|
37322
|
+
var SESSION_ID = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
|
|
37323
|
+
var record2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
37324
|
+
var string4 = (value) => typeof value === "string" ? value : "";
|
|
37325
|
+
function modelSlug(value) {
|
|
37326
|
+
const route = record2(value);
|
|
37327
|
+
const model = string4(route.model);
|
|
37328
|
+
const provider = string4(route.provider);
|
|
37329
|
+
return model && provider ? JSON.stringify([provider, model]) : "";
|
|
37330
|
+
}
|
|
37331
|
+
async function entries(directory) {
|
|
37332
|
+
return NodeFSP2.readdir(directory, { withFileTypes: true }).catch(
|
|
37333
|
+
(error62) => {
|
|
37334
|
+
if (error62.code === "ENOENT") return [];
|
|
37335
|
+
throw error62;
|
|
37336
|
+
}
|
|
37337
|
+
);
|
|
37338
|
+
}
|
|
37339
|
+
async function* sessionLogs(directory, id, signal) {
|
|
37340
|
+
signal?.throwIfAborted();
|
|
37341
|
+
for (const project of await entries(directory)) {
|
|
37342
|
+
signal?.throwIfAborted();
|
|
37343
|
+
if (!project.isDirectory()) continue;
|
|
37344
|
+
const projectDir = NodePath8.join(directory, project.name);
|
|
37345
|
+
for (const session of await entries(projectDir)) {
|
|
37346
|
+
signal?.throwIfAborted();
|
|
37347
|
+
if (!session.isDirectory() || !SESSION_ID.test(session.name) || id !== void 0 && id !== session.name)
|
|
37348
|
+
continue;
|
|
37349
|
+
const sessionDir = NodePath8.join(projectDir, session.name);
|
|
37350
|
+
let selected;
|
|
37351
|
+
let compression;
|
|
37352
|
+
for (const log of await entries(sessionDir)) {
|
|
37353
|
+
if (!log.isFile()) continue;
|
|
37354
|
+
const match = SESSION_LOG.exec(log.name);
|
|
37355
|
+
if (!match) continue;
|
|
37356
|
+
const generation = Number(match[1] ?? 0);
|
|
37357
|
+
if (!Number.isSafeInteger(generation)) continue;
|
|
37358
|
+
const compressed = match[2] !== void 0;
|
|
37359
|
+
if (compression !== void 0 && compression !== compressed) {
|
|
37360
|
+
selected = void 0;
|
|
37361
|
+
break;
|
|
37362
|
+
}
|
|
37363
|
+
compression = compressed;
|
|
37364
|
+
if (!selected || generation > selected.generation) {
|
|
37365
|
+
selected = { file: NodePath8.join(sessionDir, log.name), id: session.name, generation };
|
|
37366
|
+
}
|
|
37367
|
+
}
|
|
37368
|
+
if (selected) yield selected;
|
|
37369
|
+
}
|
|
37370
|
+
}
|
|
37371
|
+
}
|
|
37372
|
+
function textBlocks(content) {
|
|
37373
|
+
if (typeof content === "string") return content;
|
|
37374
|
+
return Array.isArray(content) ? content.map(record2).filter((block) => block.type === "text").map((block) => string4(block.text)).join("\n") : "";
|
|
37375
|
+
}
|
|
37376
|
+
async function readDshLog(log, select, resumeSchemaVersion, scanOnly, signal) {
|
|
37377
|
+
const before = await NodeFSP2.lstat(log.file, { bigint: true }).catch(
|
|
37378
|
+
(error62) => {
|
|
37379
|
+
if (error62.code === "ENOENT") return void 0;
|
|
37380
|
+
throw error62;
|
|
37381
|
+
}
|
|
37382
|
+
);
|
|
37383
|
+
if (!before?.isFile()) return;
|
|
37384
|
+
const stream = NodeFS4.createReadStream(log.file, { signal });
|
|
37385
|
+
const decompressor = log.file.endsWith(".zstd") ? NodeZlib.createZstdDecompress() : void 0;
|
|
37386
|
+
const pump = decompressor ? NodeStreamPromises.pipeline(stream, decompressor, { signal }) : void 0;
|
|
37387
|
+
void pump?.catch(() => {
|
|
37388
|
+
});
|
|
37389
|
+
const closed = new Promise((resolve5) => stream.once("close", resolve5));
|
|
37390
|
+
const lines = NodeReadline.createInterface({
|
|
37391
|
+
input: decompressor ?? stream,
|
|
37392
|
+
crlfDelay: Infinity
|
|
37393
|
+
});
|
|
37394
|
+
const messages = [];
|
|
37395
|
+
const activities = [];
|
|
37396
|
+
let cwd = "";
|
|
37397
|
+
let title = null;
|
|
37398
|
+
let model = null;
|
|
37399
|
+
let turn = "";
|
|
37400
|
+
let firstUser = "";
|
|
37401
|
+
let turnCount = 0;
|
|
37402
|
+
let matches = false;
|
|
37403
|
+
try {
|
|
37404
|
+
for await (const line of lines) {
|
|
37405
|
+
signal?.throwIfAborted();
|
|
37406
|
+
if (!line.trim()) continue;
|
|
37407
|
+
let row;
|
|
37408
|
+
try {
|
|
37409
|
+
row = record2(JSON.parse(line));
|
|
37410
|
+
} catch {
|
|
37411
|
+
if (!cwd) return;
|
|
37412
|
+
continue;
|
|
37413
|
+
}
|
|
37414
|
+
if (!cwd) {
|
|
37415
|
+
cwd = string4(row.cwd);
|
|
37416
|
+
if (row.type !== "session" || row.id !== log.id || row.version !== log.generation || row.origin === "subagent" || !NodePath8.isAbsolute(cwd) || !select(cwd))
|
|
37417
|
+
return;
|
|
37418
|
+
matches = true;
|
|
37419
|
+
continue;
|
|
37420
|
+
}
|
|
37421
|
+
const createdAt = isoTranscriptTimestamp(row.time);
|
|
37422
|
+
if (typeof row.seq !== "number" || !Number.isSafeInteger(row.seq) || row.seq < 0 || !createdAt)
|
|
37423
|
+
continue;
|
|
37424
|
+
const data = record2(row.data);
|
|
37425
|
+
const message = row.type === "user/message" ? data : record2(data.message);
|
|
37426
|
+
if (row.type === "session/title") title = string4(data.title).trim() || null;
|
|
37427
|
+
if (row.type === "request/header") model = modelSlug(record2(data.header).config) || model;
|
|
37428
|
+
if (row.type === "turn/start") turn = typeof data.turn === "number" ? String(data.turn) : "";
|
|
37429
|
+
if (row.type === "assistant/message") model = modelSlug(message.source) || model;
|
|
37430
|
+
const sourceKind = record2(message.source).kind;
|
|
37431
|
+
const isUserMessage = row.type === "user/message" && (sourceKind === "user" || sourceKind === void 0);
|
|
37432
|
+
const text = !scanOnly || isUserMessage ? textBlocks(message.content) : "";
|
|
37433
|
+
if (isUserMessage && text.trim()) {
|
|
37434
|
+
firstUser ||= text.trim().slice(0, 300);
|
|
37435
|
+
turnCount++;
|
|
37436
|
+
}
|
|
37437
|
+
if (scanOnly) continue;
|
|
37438
|
+
const sourceId = String(row.seq);
|
|
37439
|
+
const identity = {
|
|
37440
|
+
createdAt,
|
|
37441
|
+
...turn ? { nativeTurnId: turn } : {},
|
|
37442
|
+
...model ? { model } : {}
|
|
37443
|
+
};
|
|
37444
|
+
if (isUserMessage && text.trim()) {
|
|
37445
|
+
messages.push({
|
|
37446
|
+
...identity,
|
|
37447
|
+
sourceId,
|
|
37448
|
+
sourceOrder: messages.length + activities.length,
|
|
37449
|
+
role: "user",
|
|
37450
|
+
text
|
|
37451
|
+
});
|
|
37452
|
+
}
|
|
37453
|
+
if (row.type === "assistant/message") {
|
|
37454
|
+
if (text.trim()) {
|
|
37455
|
+
messages.push({
|
|
37456
|
+
...identity,
|
|
37457
|
+
sourceId,
|
|
37458
|
+
sourceOrder: messages.length + activities.length,
|
|
37459
|
+
role: "assistant",
|
|
37460
|
+
text
|
|
37461
|
+
});
|
|
37462
|
+
}
|
|
37463
|
+
if (Array.isArray(message.content)) {
|
|
37464
|
+
for (const [index, item] of message.content.entries()) {
|
|
37465
|
+
const block = record2(item);
|
|
37466
|
+
const text2 = string4(block.text);
|
|
37467
|
+
if (block.type !== "reasoning" || !text2.trim()) continue;
|
|
37468
|
+
const activity = reasoning(
|
|
37469
|
+
{
|
|
37470
|
+
...identity,
|
|
37471
|
+
sourceId: `${sourceId}:${index}`,
|
|
37472
|
+
sourceOrder: messages.length + activities.length
|
|
37473
|
+
},
|
|
37474
|
+
text2,
|
|
37475
|
+
"reasoning_text"
|
|
37476
|
+
);
|
|
37477
|
+
activities.push({ ...activity, payload: { ...activity.payload, chars: text2.length } });
|
|
37478
|
+
}
|
|
37479
|
+
}
|
|
37480
|
+
}
|
|
37481
|
+
if (row.type === "tool/call") {
|
|
37482
|
+
activities.push({
|
|
37483
|
+
...identity,
|
|
37484
|
+
sourceId,
|
|
37485
|
+
sourceOrder: messages.length + activities.length,
|
|
37486
|
+
kind: "tool.started",
|
|
37487
|
+
tone: "tool",
|
|
37488
|
+
summary: string4(data.name) || "Tool call",
|
|
37489
|
+
payload: {
|
|
37490
|
+
toolCallId: string4(data.callId),
|
|
37491
|
+
itemType: "dynamic_tool_call",
|
|
37492
|
+
startedAt: identity.createdAt,
|
|
37493
|
+
toolName: string4(data.name),
|
|
37494
|
+
...inputPayload(string4(data.arguments))
|
|
37495
|
+
}
|
|
37496
|
+
});
|
|
37497
|
+
}
|
|
37498
|
+
if (row.type === "tool/result") {
|
|
37499
|
+
activities.push({
|
|
37500
|
+
...identity,
|
|
37501
|
+
sourceId,
|
|
37502
|
+
sourceOrder: messages.length + activities.length,
|
|
37503
|
+
kind: "tool.completed",
|
|
37504
|
+
tone: message.isError === true ? "error" : "tool",
|
|
37505
|
+
summary: string4(message.toolName) || "Tool result",
|
|
37506
|
+
payload: {
|
|
37507
|
+
toolCallId: string4(message.toolCallId),
|
|
37508
|
+
itemType: "dynamic_tool_call",
|
|
37509
|
+
status: message.isError === true ? "failed" : "completed",
|
|
37510
|
+
toolName: string4(message.toolName),
|
|
37511
|
+
...outputPayload(text)
|
|
37512
|
+
}
|
|
37513
|
+
});
|
|
37514
|
+
}
|
|
37515
|
+
}
|
|
37516
|
+
await pump;
|
|
37517
|
+
} finally {
|
|
37518
|
+
lines.close();
|
|
37519
|
+
stream.destroy();
|
|
37520
|
+
decompressor?.destroy();
|
|
37521
|
+
await pump?.catch(() => {
|
|
37522
|
+
});
|
|
37523
|
+
await closed;
|
|
37524
|
+
signal?.throwIfAborted();
|
|
37525
|
+
if (matches) {
|
|
37526
|
+
const after = await NodeFSP2.lstat(log.file, { bigint: true });
|
|
37527
|
+
signal?.throwIfAborted();
|
|
37528
|
+
if (before.ino !== after.ino || before.dev !== after.dev || before.size !== after.size || before.mtimeNs !== after.mtimeNs || before.ctimeNs !== after.ctimeNs) {
|
|
37529
|
+
throw new DshTranscriptChangedError(
|
|
37530
|
+
"The native DSH transcript changed while it was being read."
|
|
37531
|
+
);
|
|
37532
|
+
}
|
|
37533
|
+
}
|
|
37534
|
+
}
|
|
37535
|
+
if (!matches) return;
|
|
37536
|
+
title ??= firstUser.slice(0, 100) || null;
|
|
37537
|
+
return {
|
|
37538
|
+
candidate: {
|
|
37539
|
+
nativeSessionId: log.id,
|
|
37540
|
+
cwd,
|
|
37541
|
+
title,
|
|
37542
|
+
preview: firstUser.slice(0, 300) || null,
|
|
37543
|
+
model,
|
|
37544
|
+
turnCount,
|
|
37545
|
+
updatedAt: Number(before.mtimeNs / 1000000n),
|
|
37546
|
+
availability: "importable",
|
|
37547
|
+
openElsewhere: false
|
|
37548
|
+
},
|
|
37549
|
+
transcript: {
|
|
37550
|
+
resumeCursor: { schemaVersion: resumeSchemaVersion, sessionId: log.id },
|
|
37551
|
+
title,
|
|
37552
|
+
model,
|
|
37553
|
+
messages,
|
|
37554
|
+
activities,
|
|
37555
|
+
availableMessages: messages.length,
|
|
37556
|
+
availableActivities: activities.length
|
|
37557
|
+
}
|
|
37558
|
+
};
|
|
37559
|
+
}
|
|
37560
|
+
function dshNativeSessions(recipe, resumeSchemaVersion) {
|
|
37561
|
+
const env = buildSpawnEnv(recipe, resolveHomePath(recipe.homePath));
|
|
37562
|
+
const configuredHome = env.DSH_HOME ?? process.env.DSH_HOME;
|
|
37563
|
+
const home = configuredHome?.trim() ? expandHomePath(configuredHome) : NodePath8.join(NodeOS8.homedir(), ".dsh");
|
|
37564
|
+
const root = NodePath8.join(home, "sessions");
|
|
37565
|
+
const configError = "Set an absolute DSH_HOME to import DSH terminal sessions.";
|
|
37566
|
+
const readImport = async ({ nativeSessionId, cwd, signal }) => {
|
|
37567
|
+
signal?.throwIfAborted();
|
|
37568
|
+
if (!NodePath8.isAbsolute(root)) throw new Error(configError);
|
|
37569
|
+
if (!SESSION_ID.test(nativeSessionId) || !cwd || !NodePath8.isAbsolute(cwd)) {
|
|
37570
|
+
throw new Error("Invalid DSH session identity or working directory.");
|
|
37571
|
+
}
|
|
37572
|
+
let log;
|
|
37573
|
+
for await (const candidate of sessionLogs(root, nativeSessionId, signal)) {
|
|
37574
|
+
if (log) throw new Error(`Multiple transcripts for DSH session ${nativeSessionId}.`);
|
|
37575
|
+
log = candidate;
|
|
37576
|
+
}
|
|
37577
|
+
const result = log && await readDshLog(
|
|
37578
|
+
log,
|
|
37579
|
+
(recorded) => NodePath8.relative(cwd, recorded) === "",
|
|
37580
|
+
resumeSchemaVersion,
|
|
37581
|
+
false,
|
|
37582
|
+
signal
|
|
37583
|
+
);
|
|
37584
|
+
if (!result)
|
|
37585
|
+
throw new Error(
|
|
37586
|
+
`No transcript for DSH session ${nativeSessionId} in the requested directory.`
|
|
37587
|
+
);
|
|
37588
|
+
return result.transcript;
|
|
37589
|
+
};
|
|
37590
|
+
return {
|
|
37591
|
+
...NodePath8.isAbsolute(root) ? { storageKey: `dsh:sessions:${NodePath8.sep === "\\" ? root.toLowerCase() : root}` } : {},
|
|
37592
|
+
scan: async ({ directory, signal }) => {
|
|
37593
|
+
signal?.throwIfAborted();
|
|
37594
|
+
if (!NodePath8.isAbsolute(root)) throw new Error(configError);
|
|
37595
|
+
if (!directory || !NodePath8.isAbsolute(directory)) return { candidates: [] };
|
|
37596
|
+
const candidates = /* @__PURE__ */ new Map();
|
|
37597
|
+
for await (const log of sessionLogs(root, void 0, signal)) {
|
|
37598
|
+
if (candidates.has(log.id)) {
|
|
37599
|
+
candidates.set(log.id, void 0);
|
|
37600
|
+
continue;
|
|
37601
|
+
}
|
|
37602
|
+
const result = await readDshLog(
|
|
37603
|
+
log,
|
|
37604
|
+
(cwd) => {
|
|
37605
|
+
const relative2 = NodePath8.relative(directory, cwd);
|
|
37606
|
+
return relative2 !== ".." && !relative2.startsWith(`..${NodePath8.sep}`) && !NodePath8.isAbsolute(relative2);
|
|
37607
|
+
},
|
|
37608
|
+
resumeSchemaVersion,
|
|
37609
|
+
true,
|
|
37610
|
+
signal
|
|
37611
|
+
).catch((error62) => {
|
|
37612
|
+
signal?.throwIfAborted();
|
|
37613
|
+
if (error62 instanceof DshTranscriptChangedError || record2(error62).code === "ENOENT") return;
|
|
37614
|
+
throw error62;
|
|
37615
|
+
});
|
|
37616
|
+
candidates.set(log.id, result?.candidate);
|
|
37617
|
+
}
|
|
37618
|
+
return {
|
|
37619
|
+
candidates: [...candidates.values()].filter((candidate) => candidate !== void 0).sort((a, b) => b.updatedAt - a.updatedAt)
|
|
37620
|
+
};
|
|
37621
|
+
},
|
|
37622
|
+
readImport,
|
|
37623
|
+
read: async (input2) => {
|
|
37624
|
+
const { messages, model, resumeCursor } = await readImport(input2);
|
|
37625
|
+
return {
|
|
37626
|
+
nativeSessionId: input2.nativeSessionId,
|
|
37627
|
+
messages: messages.map(({ role, text, createdAt }) => ({
|
|
37628
|
+
role,
|
|
37629
|
+
text,
|
|
37630
|
+
createdAt: Date.parse(createdAt)
|
|
37631
|
+
})),
|
|
37632
|
+
model,
|
|
37633
|
+
resumeCursor
|
|
37634
|
+
};
|
|
37635
|
+
}
|
|
37636
|
+
};
|
|
37637
|
+
}
|
|
37638
|
+
|
|
37256
37639
|
// src/openCommands.ts
|
|
37257
37640
|
import {
|
|
37258
37641
|
isPowerShellExecutableName,
|
|
@@ -37561,6 +37944,7 @@ var createDshInstance = (config2, host) => {
|
|
|
37561
37944
|
beforeSendTurn: (booked) => booked.permissionSync.beforeSendTurn()
|
|
37562
37945
|
});
|
|
37563
37946
|
const instance = {
|
|
37947
|
+
sessions: dshNativeSessions(recipe, RESUME_SCHEMA_VERSION),
|
|
37564
37948
|
probe: async (signal) => {
|
|
37565
37949
|
if (recipe.binaryPath.length === 0) {
|
|
37566
37950
|
return {
|
|
@@ -37786,7 +38170,7 @@ var index_default = definePlugin({
|
|
|
37786
38170
|
"DSH_HOME",
|
|
37787
38171
|
request,
|
|
37788
38172
|
process.env,
|
|
37789
|
-
(value) => value === void 0 ?
|
|
38173
|
+
(value) => value === void 0 ? NodePath9.join(NodeOS9.homedir(), ".dsh") : NodePath9.resolve(expandHomePath(value))
|
|
37790
38174
|
)
|
|
37791
38175
|
};
|
|
37792
38176
|
}
|