@testchimp/cli 0.1.53 → 0.1.55
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/chimphands/run.js +9 -30
- package/package.json +1 -1
package/dist/chimphands/run.js
CHANGED
|
@@ -140,19 +140,19 @@ class AgentEventPoster {
|
|
|
140
140
|
body.pullRequestUrl = opts.pullRequestUrl;
|
|
141
141
|
const streamRole = isStreamFanoutRole(role);
|
|
142
142
|
this.chain = this.chain.then(async () => {
|
|
143
|
-
|
|
144
|
-
//
|
|
145
|
-
if (
|
|
143
|
+
const live = !!opts?.liveStream && !opts?.durable;
|
|
144
|
+
// Mid-turn tokens never hit PG. Async / detached: drop. Attached: ephemeral only.
|
|
145
|
+
if (live && !this.uiAttached) {
|
|
146
146
|
return;
|
|
147
147
|
}
|
|
148
|
-
if (opts?.throttle || (streamRole &&
|
|
148
|
+
if (opts?.throttle || (streamRole && live)) {
|
|
149
149
|
const now = Date.now();
|
|
150
150
|
const wait = STREAM_POST_MIN_INTERVAL_MS - (now - this.lastStreamPostAt);
|
|
151
151
|
if (wait > 0)
|
|
152
152
|
await sleep(wait);
|
|
153
153
|
this.lastStreamPostAt = Date.now();
|
|
154
154
|
}
|
|
155
|
-
const tryEphemeral = streamRole && this.uiAttached;
|
|
155
|
+
const tryEphemeral = live && streamRole && this.uiAttached;
|
|
156
156
|
if (tryEphemeral) {
|
|
157
157
|
const eph = {
|
|
158
158
|
sessionId: this.sessionId,
|
|
@@ -164,35 +164,14 @@ class AgentEventPoster {
|
|
|
164
164
|
if (opts?.opencodeSessionId)
|
|
165
165
|
eph.opencodeSessionId = opts.opencodeSessionId;
|
|
166
166
|
try {
|
|
167
|
-
|
|
167
|
+
await postJson(this.backend, this.apiKey, "/api/chimphands/post_ephemeral_agent_event", eph);
|
|
168
168
|
this.ephemeralFailCount = 0;
|
|
169
|
-
let delivered = false;
|
|
170
|
-
try {
|
|
171
|
-
const parsed = JSON.parse(text);
|
|
172
|
-
delivered = !!parsed.delivered;
|
|
173
|
-
}
|
|
174
|
-
catch {
|
|
175
|
-
/* ignore */
|
|
176
|
-
}
|
|
177
|
-
if (delivered)
|
|
178
|
-
return;
|
|
179
|
-
// Mid-turn liveStream must not fall through to durable — that would write
|
|
180
|
-
// every token to PG. Turn-end reconcile persists the final transcript.
|
|
181
|
-
if (opts?.liveStream) {
|
|
182
|
-
this.logEphemeralIssue("ephemeral not delivered (replica miss?) — skipping durable for liveStream");
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
// Completed/non-live: durable fallback for cross-replica UI.
|
|
186
|
-
console.error("ChimpHands ephemeral not delivered (replica miss?) — persisting via post_agent_event");
|
|
187
169
|
}
|
|
188
170
|
catch (err) {
|
|
189
171
|
const detail = err instanceof Error ? err.message : String(err);
|
|
190
|
-
|
|
191
|
-
this.logEphemeralIssue(`ephemeral post failed — skipping durable for liveStream: ${detail}`);
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
console.error(`ChimpHands ephemeral post failed — durable fallback: ${detail}`);
|
|
172
|
+
this.logEphemeralIssue(`ephemeral post failed — not persisting liveStream: ${detail}`);
|
|
195
173
|
}
|
|
174
|
+
return;
|
|
196
175
|
}
|
|
197
176
|
await postJson(this.backend, this.apiKey, "/api/chimphands/post_agent_event", body);
|
|
198
177
|
});
|
|
@@ -1569,7 +1548,7 @@ export async function runChimphands(opts) {
|
|
|
1569
1548
|
void poster.enqueue(role, content, {
|
|
1570
1549
|
...opts,
|
|
1571
1550
|
opencodeSessionId,
|
|
1572
|
-
|
|
1551
|
+
durable: true,
|
|
1573
1552
|
});
|
|
1574
1553
|
}, noteWorkingBranch);
|
|
1575
1554
|
await poster.flush();
|
package/package.json
CHANGED