@cohortapp/agent-sdk 2.18.28 → 2.18.30
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/lib/runtime/adapter.mjs +53 -5
- package/package.json +1 -1
- package/scripts/daemon/assurance.mjs +69 -2
package/lib/runtime/adapter.mjs
CHANGED
|
@@ -250,6 +250,14 @@ export function sessionArgs(i = {}) {
|
|
|
250
250
|
* @param {{model: string}} i - the lane input.
|
|
251
251
|
* @returns {string[]} the claude argv.
|
|
252
252
|
*/
|
|
253
|
+
/**
|
|
254
|
+
* The output style a daemon-spawned seat session runs in. "default" is Claude
|
|
255
|
+
* Code's own plain style — no decorative teaching blocks, and no instruction to
|
|
256
|
+
* hand work back to the reader. Overridable for an operator who genuinely wants
|
|
257
|
+
* a different one on their seat's sessions.
|
|
258
|
+
*/
|
|
259
|
+
const SEAT_OUTPUT_STYLE = process.env.MAESTRO_SEAT_OUTPUT_STYLE || "default";
|
|
260
|
+
|
|
253
261
|
const TEXT_ONLY_ARGV = (i) => ["--print", "--model", i.model, "--strict-mcp-config", "--tools", ""];
|
|
254
262
|
|
|
255
263
|
const LANES = Object.freeze({
|
|
@@ -460,11 +468,51 @@ export function buildSpawn(i = {}, deps = {}) {
|
|
|
460
468
|
if (!envResult.ok) return fail(envResult.error.code, envResult.error.message);
|
|
461
469
|
|
|
462
470
|
const perm = Array.isArray(i.permissions) ? i.permissions : (spec.defaultPermissions || []);
|
|
463
|
-
//
|
|
464
|
-
//
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
471
|
+
// A SEAT SESSION PINS ITS OWN OUTPUT STYLE.
|
|
472
|
+
//
|
|
473
|
+
// A seat writes to colleagues in a room, not to a developer at a terminal, so
|
|
474
|
+
// a teaching output style is wrong for it. `scripts/setup/init-agent.sh` used
|
|
475
|
+
// to enable explanatory-output-style and learning-output-style on every
|
|
476
|
+
// provisioned machine (fixed in 2.18.28), and enabling the plugin is what
|
|
477
|
+
// turns the style ON — so a seat ran in "learning" mode with no `outputStyle`
|
|
478
|
+
// key anywhere. Observed 2026-09-30 20:12:55Z: a seat posted a decorative
|
|
479
|
+
// teaching block, box-drawing rules and all, into a shared engineering
|
|
480
|
+
// channel mid status message. The learning style is worse in kind: it
|
|
481
|
+
// instructs the model to stop and ask the reader to write the code.
|
|
482
|
+
//
|
|
483
|
+
// Pinning it HERE rather than editing the machine is the point. The flags live
|
|
484
|
+
// in the operator's own global settings file, which also governs their
|
|
485
|
+
// interactive terminal; an upgrade has no business rewriting that, and an
|
|
486
|
+
// operator who wants explanatory mode for their own sessions keeps it. This
|
|
487
|
+
// only constrains sessions the daemon spawns.
|
|
488
|
+
//
|
|
489
|
+
// WHY THIS IS SAFE, ESTABLISHED RATHER THAN ASSUMED. `--settings` is documented
|
|
490
|
+
// as loading "additional settings", i.e. it MERGES into the precedence chain
|
|
491
|
+
// rather than replacing it — and the CLI distinguishes the two cases, since
|
|
492
|
+
// `--strict-mcp-config` exists precisely to make MCP config exclusive and
|
|
493
|
+
// `--settings` has no such counterpart. Verified live: a `--print` run carrying
|
|
494
|
+
// `--settings '{"outputStyle":"default"}'` exited 0 AND still fired the
|
|
495
|
+
// SessionEnd hook defined only in the machine's global settings, which proves
|
|
496
|
+
// the global file was still in effect. Had it replaced instead, passing this
|
|
497
|
+
// unconditionally would have stripped every seat's permissions and silenced
|
|
498
|
+
// the fleet, which is why it was not shipped on the documentation alone.
|
|
499
|
+
//
|
|
500
|
+
// Reaches the three lanes whose argv carries `x.settings` — dispatcher, resume
|
|
501
|
+
// and cadence — which are the full work sessions, and the dispatcher lane is
|
|
502
|
+
// the one whose end-of-turn text the silent-success rescue republishes. The
|
|
503
|
+
// short-text lanes (responder, classifier, ack) take no settings argument at
|
|
504
|
+
// all and are still governed by the machine; they run on an explicit
|
|
505
|
+
// `--append-system-prompt` and emit a line rather than a report, so they are a
|
|
506
|
+
// smaller surface, but they are NOT covered here.
|
|
507
|
+
//
|
|
508
|
+
// Path B: a cohort-llm retarget additionally authenticates through the
|
|
509
|
+
// seat-token helper, which Claude Code only reads from settings (child-env
|
|
510
|
+
// COHORT_HELPER_KEY). Merged into the same object, never a second --settings.
|
|
511
|
+
const sessionSettings = { outputStyle: SEAT_OUTPUT_STYLE };
|
|
512
|
+
if (envResult.retargeting && isCohortHelperRetarget(i.retarget)) {
|
|
513
|
+
sessionSettings.apiKeyHelper = i.retarget[COHORT_HELPER_KEY];
|
|
514
|
+
}
|
|
515
|
+
const settings = ["--settings", JSON.stringify(sessionSettings)];
|
|
468
516
|
const x = { perm, mcp: mcpArgs(i.mcp, d), knobs: knobArgs(i.knobs), settings };
|
|
469
517
|
const argv = spec.argv(input, x);
|
|
470
518
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cohortapp/agent-sdk",
|
|
3
|
-
"version": "2.18.
|
|
3
|
+
"version": "2.18.30",
|
|
4
4
|
"description": "Cohort Agent SDK — autonomous AI colleague runtime. Deploy senior AI colleagues on dedicated Mac minis, wired to the Cohort operating surface.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
import { appendFileSync, mkdirSync, readdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "fs";
|
|
55
55
|
import { spawn } from "child_process";
|
|
56
56
|
import { join } from "path";
|
|
57
|
-
import { deliver, deliverWithRetry, replyTargetOf, canDeliverTo, canReactTo, deliverReaction } from "./deliver.mjs";
|
|
57
|
+
import { deliver, deliverWithRetry, replyTargetOf, canDeliverTo, canReactTo, deliverReaction, cohortReplyRoute } from "./deliver.mjs";
|
|
58
58
|
import { spokeFor, spokeSince, noSendFor, NON_ANSWER_KINDS } from "../../lib/comms/receipts.mjs";
|
|
59
59
|
import { resultTextFromStdout } from "./session-outcomes.mjs";
|
|
60
60
|
// The ack generator funnels through `claude --print` like every other daemon
|
|
@@ -1388,6 +1388,56 @@ export function composeRefusedSend(rec, o = {}) {
|
|
|
1388
1388
|
* @param {object} rec the obligation record; its `item.direct_reason` is read
|
|
1389
1389
|
* @returns {boolean}
|
|
1390
1390
|
*/
|
|
1391
|
+
/**
|
|
1392
|
+
* Is this obligation's reply surface a DOCUMENT rather than a conversation?
|
|
1393
|
+
*
|
|
1394
|
+
* A doc or file comment is not a request for work. Nobody asked the seat for
|
|
1395
|
+
* anything by commenting on a document it can see, so there is no one waiting
|
|
1396
|
+
* for a notice about work that did not finish — and posting one is actively
|
|
1397
|
+
* harmful, because a comment fans out as an inbound to every seat the document
|
|
1398
|
+
* is shared with.
|
|
1399
|
+
*
|
|
1400
|
+
* MEASURED, 2026-10-01 on one shared alerting doc: 11 of its 14 comments were
|
|
1401
|
+
* assurance notices, alternating between two seats every ~10 minutes from
|
|
1402
|
+
* 02:53Z to 04:57Z, burying the three substantive comments a colleague had
|
|
1403
|
+
* written. The mechanism is a closed loop: seat A's notice lands as a comment,
|
|
1404
|
+
* the comment arrives as an inbound at seat B, B's session fails on it, B posts
|
|
1405
|
+
* its own notice, which arrives as an inbound at A. A human recipient of the
|
|
1406
|
+
* document saw every one.
|
|
1407
|
+
*
|
|
1408
|
+
* WHY THIS IS A SURFACE TEST AND NOT A REASON TEST. `isAmbientSurface` already
|
|
1409
|
+
* withholds the silent-success narration on a membership-proved surface, and a
|
|
1410
|
+
* shared document is exactly that — but only until the first notice. The
|
|
1411
|
+
* directedness reasons include `commenter` ("I SPOKE there"), which is NOT a
|
|
1412
|
+
* membership reason, so a seat that posts one notice becomes a commenter and the
|
|
1413
|
+
* surface flips to identity-shaped for every notice after it. The notice
|
|
1414
|
+
* manufactures its own audience, which is why the loop sustains for hours
|
|
1415
|
+
* instead of stopping. A test on the SURFACE cannot be flipped by anything the
|
|
1416
|
+
* seat itself does.
|
|
1417
|
+
*
|
|
1418
|
+
* Scoped to documents on purpose. `task_comment` and `decision` are NOT included:
|
|
1419
|
+
* a board comment can carry an assignment and a decision thread can carry a
|
|
1420
|
+
* request, so a person there may genuinely be waiting. Those keep the existing
|
|
1421
|
+
* reason-based treatment.
|
|
1422
|
+
*
|
|
1423
|
+
* @param {object} rec the obligation record
|
|
1424
|
+
* @returns {boolean}
|
|
1425
|
+
*/
|
|
1426
|
+
const DOCUMENT_SURFACES = Object.freeze(["doc_comment", "file_comment"]);
|
|
1427
|
+
function isDocumentSurface(rec) {
|
|
1428
|
+
const item = rec && rec.item;
|
|
1429
|
+
if (!item) return false;
|
|
1430
|
+
try {
|
|
1431
|
+
const route = cohortReplyRoute(item);
|
|
1432
|
+
return DOCUMENT_SURFACES.includes(String(route && route.surface));
|
|
1433
|
+
} catch {
|
|
1434
|
+
// Unresolvable route → fall back to the reason-based treatment rather than
|
|
1435
|
+
// inventing silence. Failing open here costs a notice; failing closed could
|
|
1436
|
+
// swallow one a person is waiting on.
|
|
1437
|
+
return false;
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1391
1441
|
function isAmbientSurface(rec) {
|
|
1392
1442
|
const reason = String((rec && rec.item && rec.item.direct_reason) || "");
|
|
1393
1443
|
if (!reason) return false; // unknown provenance → treat as a DM, narrate
|
|
@@ -2101,7 +2151,10 @@ export async function settleSession(a = {}) {
|
|
|
2101
2151
|
// close silently to avoid. The debt is still discharged (silent is not
|
|
2102
2152
|
// un-closed); only the narration is withheld. `direct_reason` reaches here
|
|
2103
2153
|
// through `itemSnapshot`, and the guard fails open to narrating.
|
|
2104
|
-
|
|
2154
|
+
// `isDocumentSurface` as well as the reason test: a document stops being
|
|
2155
|
+
// membership-proved the moment this seat comments on it (reason `commenter`),
|
|
2156
|
+
// so the reason alone cannot hold the line across more than one notice.
|
|
2157
|
+
if (isAmbientSurface(rec) || isDocumentSurface(rec)) {
|
|
2105
2158
|
closeObligation(a.key, {
|
|
2106
2159
|
outcome: "answered",
|
|
2107
2160
|
now,
|
|
@@ -2167,6 +2220,20 @@ export async function settleSession(a = {}) {
|
|
|
2167
2220
|
rec.lastFailureAt = now;
|
|
2168
2221
|
writeRecord(rec);
|
|
2169
2222
|
|
|
2223
|
+
// A DOCUMENT IS NOT A REQUEST FOR WORK, SO IT GETS NO FAILURE NOTICE.
|
|
2224
|
+
//
|
|
2225
|
+
// The silent-success branch above already withholds narration on an ambient
|
|
2226
|
+
// surface; this branch never asked the same question, and that asymmetry is
|
|
2227
|
+
// what produced the measured loop (see isDocumentSurface). The debt is closed
|
|
2228
|
+
// and escalated exactly as an undeliverable one is, so an operator still has
|
|
2229
|
+
// the trace — what is withheld is only the comment.
|
|
2230
|
+
if (isDocumentSurface(rec)) {
|
|
2231
|
+
escalate(rec, { failure, now, told: false });
|
|
2232
|
+
closeObligation(a.key, { outcome: "failed", now, note: `${failure.label}; document surface, notice withheld` });
|
|
2233
|
+
counters.bump("assurance.failure_notice_withheld_document", { service: rec.service });
|
|
2234
|
+
return { spoke: false, text: null, verdict: `failed:${failure.label}`, willRetry: false };
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2170
2237
|
// GENERATED, not stamped. `generateFailureNotice` always returns text — the
|
|
2171
2238
|
// degraded path is a plainer sentence, never silence — so the guarantee the
|
|
2172
2239
|
// deterministic composer bought is intact while the words are this ask's own.
|