teamshare-bridge 0.27.1 → 0.27.3
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/cli/commands/build.js +2 -1
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/plan.js +5 -1
- package/dist/cli/commands/plan.js.map +1 -1
- package/dist/cli/commands/research.js +26 -11
- package/dist/cli/commands/research.js.map +1 -1
- package/dist/cli/commands/run.js +17 -2
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/worker.js +2 -1
- package/dist/cli/commands/worker.js.map +1 -1
- package/dist/lib/api.d.ts +13 -0
- package/dist/lib/api.js +9 -0
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/brief.d.ts +10 -0
- package/dist/lib/brief.js +13 -0
- package/dist/lib/brief.js.map +1 -1
- package/dist/lib/git/git-finalize.js +18 -1
- package/dist/lib/git/git-finalize.js.map +1 -1
- package/dist/lib/git/git-prepare.js +7 -0
- package/dist/lib/git/git-prepare.js.map +1 -1
- package/dist/lib/git/index.d.ts +1 -1
- package/dist/lib/git/index.js +2 -1
- package/dist/lib/git/index.js.map +1 -1
- package/dist/lib/git/pr-create.d.ts +28 -2
- package/dist/lib/git/pr-create.js +100 -25
- package/dist/lib/git/pr-create.js.map +1 -1
- package/dist/lib/harness/harness-adapter.d.ts +20 -0
- package/dist/lib/harness/harness-adapter.js.map +1 -1
- package/dist/lib/harness/opencode-control.d.ts +51 -12
- package/dist/lib/harness/opencode-control.js +172 -17
- package/dist/lib/harness/opencode-control.js.map +1 -1
- package/dist/lib/harness/spawn.d.ts +25 -0
- package/dist/lib/harness/spawn.js +171 -34
- package/dist/lib/harness/spawn.js.map +1 -1
- package/dist/lib/log-batch.d.ts +57 -0
- package/dist/lib/log-batch.js +128 -0
- package/dist/lib/log-batch.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToolLogBatcher = void 0;
|
|
4
|
+
class ToolLogBatcher {
|
|
5
|
+
send;
|
|
6
|
+
opts;
|
|
7
|
+
pending = [];
|
|
8
|
+
bufferedChars = 0;
|
|
9
|
+
timer = null;
|
|
10
|
+
inFlight = null;
|
|
11
|
+
closed = false;
|
|
12
|
+
constructor(send, opts = {}) {
|
|
13
|
+
this.send = send;
|
|
14
|
+
this.opts = opts;
|
|
15
|
+
}
|
|
16
|
+
get intervalMs() {
|
|
17
|
+
return Math.max(50, this.opts.intervalMs ?? 1_500);
|
|
18
|
+
}
|
|
19
|
+
get maxLines() {
|
|
20
|
+
return Math.max(1, this.opts.maxLines ?? 100);
|
|
21
|
+
}
|
|
22
|
+
get maxBufferedChars() {
|
|
23
|
+
return Math.max(1_000, this.opts.maxBufferedChars ?? 200_000);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Split one chunk into wire-sized pieces on a line boundary when possible.
|
|
27
|
+
*
|
|
28
|
+
* The server caps a stored line at 2000 chars. Sending a 12 KB chunk as one
|
|
29
|
+
* line would silently truncate it, so the batcher splits first — the download
|
|
30
|
+
* endpoint is only "the full log" if nothing was dropped on the way in.
|
|
31
|
+
*/
|
|
32
|
+
static split(text, max = 1_800) {
|
|
33
|
+
if (text.length <= max)
|
|
34
|
+
return [text];
|
|
35
|
+
const parts = [];
|
|
36
|
+
let rest = text;
|
|
37
|
+
while (rest.length > max) {
|
|
38
|
+
let cut = rest.lastIndexOf('\n', max);
|
|
39
|
+
if (cut < Math.floor(max / 2))
|
|
40
|
+
cut = max;
|
|
41
|
+
parts.push(rest.slice(0, cut));
|
|
42
|
+
rest = rest.slice(cut);
|
|
43
|
+
if (rest.startsWith('\n'))
|
|
44
|
+
rest = rest.slice(1);
|
|
45
|
+
}
|
|
46
|
+
if (rest)
|
|
47
|
+
parts.push(rest);
|
|
48
|
+
return parts;
|
|
49
|
+
}
|
|
50
|
+
/** Buffer one chunk. Never throws; never blocks the caller. */
|
|
51
|
+
push(stream, text) {
|
|
52
|
+
if (this.closed)
|
|
53
|
+
return;
|
|
54
|
+
const clean = typeof text === 'string' ? text : '';
|
|
55
|
+
if (!clean)
|
|
56
|
+
return;
|
|
57
|
+
const normalised = stream === 'stderr' ? 'stderr' : 'stdout';
|
|
58
|
+
for (const part of ToolLogBatcher.split(clean)) {
|
|
59
|
+
this.pending.push({ stream: normalised, text: part });
|
|
60
|
+
this.bufferedChars += part.length;
|
|
61
|
+
}
|
|
62
|
+
// Drop the OLDEST chunks when a dead network lets the buffer balloon. The
|
|
63
|
+
// console cares about the tail; holding an unbounded run in memory is worse
|
|
64
|
+
// than losing the start.
|
|
65
|
+
while (this.bufferedChars > this.maxBufferedChars &&
|
|
66
|
+
this.pending.length > 1) {
|
|
67
|
+
const dropped = this.pending.shift();
|
|
68
|
+
this.bufferedChars -= dropped?.text.length ?? 0;
|
|
69
|
+
}
|
|
70
|
+
if (this.pending.length >= this.maxLines) {
|
|
71
|
+
void this.flush();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this.arm();
|
|
75
|
+
}
|
|
76
|
+
arm() {
|
|
77
|
+
if (this.timer)
|
|
78
|
+
return;
|
|
79
|
+
this.timer = setTimeout(() => {
|
|
80
|
+
this.timer = null;
|
|
81
|
+
void this.flush();
|
|
82
|
+
}, this.intervalMs);
|
|
83
|
+
// Never keep a process alive just to flush a log line.
|
|
84
|
+
this.timer.unref?.();
|
|
85
|
+
}
|
|
86
|
+
/** Send everything buffered. Serialised — never two requests at once. */
|
|
87
|
+
async flush() {
|
|
88
|
+
if (this.timer) {
|
|
89
|
+
clearTimeout(this.timer);
|
|
90
|
+
this.timer = null;
|
|
91
|
+
}
|
|
92
|
+
if (this.inFlight) {
|
|
93
|
+
await this.inFlight;
|
|
94
|
+
if (!this.pending.length)
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (!this.pending.length)
|
|
98
|
+
return;
|
|
99
|
+
const batch = this.pending;
|
|
100
|
+
this.pending = [];
|
|
101
|
+
this.bufferedChars = 0;
|
|
102
|
+
this.inFlight = (async () => {
|
|
103
|
+
try {
|
|
104
|
+
await this.send(batch);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
// Best-effort: a failed log flush must never fail the run. Put the
|
|
108
|
+
// batch back at the FRONT when the buffer has room, so ordering holds.
|
|
109
|
+
if (this.bufferedChars + batch.reduce((n, l) => n + l.text.length, 0) <=
|
|
110
|
+
this.maxBufferedChars) {
|
|
111
|
+
this.pending = [...batch, ...this.pending];
|
|
112
|
+
this.bufferedChars += batch.reduce((n, l) => n + l.text.length, 0);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
this.inFlight = null;
|
|
117
|
+
}
|
|
118
|
+
})();
|
|
119
|
+
await this.inFlight;
|
|
120
|
+
}
|
|
121
|
+
/** Final flush; after this, `push` is a no-op. */
|
|
122
|
+
async close() {
|
|
123
|
+
this.closed = true;
|
|
124
|
+
await this.flush();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.ToolLogBatcher = ToolLogBatcher;
|
|
128
|
+
//# sourceMappingURL=log-batch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-batch.js","sourceRoot":"","sources":["../../src/lib/log-batch.ts"],"names":[],"mappings":";;;AA+BA,MAAa,cAAc;IAQN;IACA;IARX,OAAO,GAAmB,EAAE,CAAC;IAC7B,aAAa,GAAG,CAAC,CAAC;IAClB,KAAK,GAA0B,IAAI,CAAC;IACpC,QAAQ,GAAyB,IAAI,CAAC;IACtC,MAAM,GAAG,KAAK,CAAC;IAEvB,YACmB,IAAiD,EACjD,OAA8B,EAAE;QADhC,SAAI,GAAJ,IAAI,CAA6C;QACjD,SAAI,GAAJ,IAAI,CAA4B;IAChD,CAAC;IAEJ,IAAY,UAAU;QACpB,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,C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