harnery 0.34.0 → 0.34.1
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/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +17 -2
- package/dist/core/agents/session-name-display.d.ts +1 -1
- package/dist/core/agents/session-name-display.js +2 -2
- package/dist/core/hooks/cli.js +3 -2
- package/dist/core/hooks/resolve/transcript.d.ts.map +1 -1
- package/dist/core/hooks/resolve/transcript.js +13 -7
- package/package.json +1 -1
- package/src/commands/agents.ts +19 -2
- package/src/core/agents/session-name-display.ts +2 -2
- package/src/core/hooks/cli.ts +3 -2
- package/src/core/hooks/resolve/transcript.ts +12 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/commands/agents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAeH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAkB1E,OAAO,EAKL,KAAK,4BAA4B,EAClC,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAGL,KAAK,SAAS,EAEf,MAAM,0CAA0C,CAAC;AAelD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAmFjE;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAA;CAAE,CAErF;AA+ED,sGAAsG;AACtG,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,IAAI,CAAC,SAAS,EAAE,mBAAmB,GAAG,YAAY,CAAC,GAAG,IAAI,GAAG,SAAS,EAC3E,QAAQ,EAAE,MAAM,GACf,MAAM,CAQR;AASD,wBAAgB,qBAAqB,CACnC,OAAO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AM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,KAAK,EAAE,MAAM,CAAC;CACf;AAUD;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,KAAK,SAAa,GACjB,wBAAwB,CA0C1B"}
|
package/dist/commands/agents.js
CHANGED
|
@@ -1378,16 +1378,31 @@ function runSetTask(task, opts) {
|
|
|
1378
1378
|
// the first time. `first_of_session: true` means exactly "this call produced
|
|
1379
1379
|
// the session name" — it is never true with a null name (an empty first
|
|
1380
1380
|
// declaration or a `--session-id` relay both keep the window open instead).
|
|
1381
|
-
const
|
|
1381
|
+
const firstSuggestedName = !priorHb?.suggested_session_name && hb?.suggested_session_name
|
|
1382
1382
|
? hb.suggested_session_name
|
|
1383
1383
|
: null;
|
|
1384
|
-
|
|
1384
|
+
// A readable but misclassified first display would otherwise leave the
|
|
1385
|
+
// session permanently latched: set-task is allowed through the gate, but a
|
|
1386
|
+
// normal repeat used to return no name and therefore could not establish a
|
|
1387
|
+
// fresh ordered transcript boundary. Re-emit the unchanged pending name as
|
|
1388
|
+
// an explicit retry. This does not rename the session or claim that the
|
|
1389
|
+
// display was seen; it only gives the next exact block new mint evidence.
|
|
1390
|
+
const retriedSuggestedName = !firstSuggestedName &&
|
|
1391
|
+
priorHb?.suggested_session_name &&
|
|
1392
|
+
priorHb.session_name_seen_for !== priorHb.suggested_session_name &&
|
|
1393
|
+
hb?.suggested_session_name === priorHb.suggested_session_name
|
|
1394
|
+
? hb.suggested_session_name
|
|
1395
|
+
: null;
|
|
1396
|
+
const suggestedName = firstSuggestedName ?? retriedSuggestedName;
|
|
1397
|
+
const firstOfSession = firstSuggestedName !== null;
|
|
1398
|
+
const sessionNameRetry = retriedSuggestedName !== null;
|
|
1385
1399
|
emit.data({
|
|
1386
1400
|
instance_id: myOwner,
|
|
1387
1401
|
name: hb?.name ?? null,
|
|
1388
1402
|
task: hb?.task ?? null,
|
|
1389
1403
|
cleared: !task || task.length === 0,
|
|
1390
1404
|
first_of_session: firstOfSession,
|
|
1405
|
+
session_name_retry: sessionNameRetry,
|
|
1391
1406
|
suggested_session_name: suggestedName,
|
|
1392
1407
|
...(lifecycleWarning ? { warning: lifecycleWarning } : {}),
|
|
1393
1408
|
// Right-time instruction: the UserPromptSubmit nudge fires before the name
|
|
@@ -14,7 +14,7 @@ export declare function sessionNameDisplayBlock(name: string): string;
|
|
|
14
14
|
export declare function sessionNameDisplayInstruction(name: string): string;
|
|
15
15
|
/**
|
|
16
16
|
* A PostToolUse result should announce the display protocol only when that
|
|
17
|
-
* exact tool call minted the current suggestion. The coordination row keeps
|
|
17
|
+
* exact tool call minted or retried the current suggestion. The coordination row keeps
|
|
18
18
|
* the suggestion pending until transcript evidence catches up, so checking
|
|
19
19
|
* the row alone would re-announce the same name after every later tool.
|
|
20
20
|
*
|
|
@@ -26,7 +26,7 @@ export function sessionNameDisplayInstruction(name) {
|
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* A PostToolUse result should announce the display protocol only when that
|
|
29
|
-
* exact tool call minted the current suggestion. The coordination row keeps
|
|
29
|
+
* exact tool call minted or retried the current suggestion. The coordination row keeps
|
|
30
30
|
* the suggestion pending until transcript evidence catches up, so checking
|
|
31
31
|
* the row alone would re-announce the same name after every later tool.
|
|
32
32
|
*
|
|
@@ -70,7 +70,7 @@ function responseContainsSessionNameMint(value, name, seen, depth) {
|
|
|
70
70
|
}
|
|
71
71
|
const row = value;
|
|
72
72
|
if (row.suggested_session_name === name &&
|
|
73
|
-
(row.first_of_session === true || row.name_reminted === true)) {
|
|
73
|
+
(row.first_of_session === true || row.name_reminted === true || row.session_name_retry === true)) {
|
|
74
74
|
return true;
|
|
75
75
|
}
|
|
76
76
|
return Object.values(row).some((item) => responseContainsSessionNameMint(item, name, seen, depth + 1));
|
package/dist/core/hooks/cli.js
CHANGED
|
@@ -944,8 +944,9 @@ async function main() {
|
|
|
944
944
|
return 0;
|
|
945
945
|
}
|
|
946
946
|
if (norm.event_type === "tool.completed" && eventName === "post-tool-use") {
|
|
947
|
-
// Inject only at the successful tool boundary that actually minted
|
|
948
|
-
// the first non-empty set-task
|
|
947
|
+
// Inject only at the successful tool boundary that actually minted or
|
|
948
|
+
// retried a name: the first non-empty set-task, a pending-name set-task
|
|
949
|
+
// retry, or the transition to lifecycle done. The
|
|
949
950
|
// coordination row intentionally remains pending until transcript evidence
|
|
950
951
|
// catches up; reading that latch alone here would re-inject after every
|
|
951
952
|
// later tool and make the agent print the same block repeatedly.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/resolve/transcript.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/resolve/transcript.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAQhF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,MAAM,EAAE,MAAM,GACb,OAAO,CAiCT;AAED,kFAAkF;AAClF,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAgB9F;AAED;;;;;GAKG;AACH,wBAAgB,mCAAmC,CACjD,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,IAAI,EAAE,MAAM,EACZ,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,OAAO,GAC/D,OAAO,CAIT;AAED,MAAM,MAAM,4BAA4B,GACpC;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,GACpB;IAAE,KAAK,EAAE,QAAQ,CAAA;CAAE,GACnB;IAAE,KAAK,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,oBAAoB,GAAG,sBAAsB,CAAA;CAAE,CAAC;AAEpF;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,IAAI,EAAE,MAAM,EACZ,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,OAAO,GAC/D,4BAA4B,CA0B9B;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,CAUrF;AAwDD;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAuB1F;AAQD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB,CAC9B,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,SAAS,CAkDpB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
2
2
|
import { basename, dirname, join } from "node:path";
|
|
3
|
+
import { toolResponseMintedSessionName } from "../../agents/session-name-display.js";
|
|
3
4
|
/**
|
|
4
5
|
* Scan a CC-style JSONL transcript for the `┌─ agent-` status-box prefix in
|
|
5
6
|
* the most-recent assistant turn. Used by `turn.completed` events to populate
|
|
@@ -123,21 +124,26 @@ export function inspectSessionNameDisplayImmediately(transcriptPath, name, start
|
|
|
123
124
|
if (!text)
|
|
124
125
|
return { state: "unavailable", reason: "transcript_not_ready" };
|
|
125
126
|
let sawMintResult = false;
|
|
127
|
+
let awaitingReply = false;
|
|
126
128
|
for (const line of text.split("\n")) {
|
|
127
|
-
if (!sawMintResult) {
|
|
128
|
-
if (line.includes(name) && line.includes("suggested_session_name"))
|
|
129
|
-
sawMintResult = true;
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
129
|
const row = parseTranscriptRow(line);
|
|
133
130
|
if (!row)
|
|
134
131
|
continue;
|
|
132
|
+
if (toolResponseMintedSessionName(row, name)) {
|
|
133
|
+
sawMintResult = true;
|
|
134
|
+
awaitingReply = true;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (!awaitingReply)
|
|
138
|
+
continue;
|
|
135
139
|
const assistantText = assistantTextFromRow(row);
|
|
136
140
|
if (assistantText !== null) {
|
|
137
|
-
|
|
141
|
+
if (startsWithBlock(assistantText, name))
|
|
142
|
+
return { state: "present" };
|
|
143
|
+
awaitingReply = false;
|
|
138
144
|
}
|
|
139
145
|
}
|
|
140
|
-
return sawMintResult
|
|
146
|
+
return sawMintResult && awaitingReply
|
|
141
147
|
? { state: "unavailable", reason: "transcript_not_ready" }
|
|
142
148
|
: { state: "absent" };
|
|
143
149
|
}
|
package/package.json
CHANGED
package/src/commands/agents.ts
CHANGED
|
@@ -1854,11 +1854,27 @@ function runSetTask(task: string, opts?: { sessionId?: string }): void {
|
|
|
1854
1854
|
// the first time. `first_of_session: true` means exactly "this call produced
|
|
1855
1855
|
// the session name" — it is never true with a null name (an empty first
|
|
1856
1856
|
// declaration or a `--session-id` relay both keep the window open instead).
|
|
1857
|
-
const
|
|
1857
|
+
const firstSuggestedName =
|
|
1858
1858
|
!priorHb?.suggested_session_name && hb?.suggested_session_name
|
|
1859
1859
|
? hb.suggested_session_name
|
|
1860
1860
|
: null;
|
|
1861
|
-
|
|
1861
|
+
|
|
1862
|
+
// A readable but misclassified first display would otherwise leave the
|
|
1863
|
+
// session permanently latched: set-task is allowed through the gate, but a
|
|
1864
|
+
// normal repeat used to return no name and therefore could not establish a
|
|
1865
|
+
// fresh ordered transcript boundary. Re-emit the unchanged pending name as
|
|
1866
|
+
// an explicit retry. This does not rename the session or claim that the
|
|
1867
|
+
// display was seen; it only gives the next exact block new mint evidence.
|
|
1868
|
+
const retriedSuggestedName =
|
|
1869
|
+
!firstSuggestedName &&
|
|
1870
|
+
priorHb?.suggested_session_name &&
|
|
1871
|
+
priorHb.session_name_seen_for !== priorHb.suggested_session_name &&
|
|
1872
|
+
hb?.suggested_session_name === priorHb.suggested_session_name
|
|
1873
|
+
? hb.suggested_session_name
|
|
1874
|
+
: null;
|
|
1875
|
+
const suggestedName = firstSuggestedName ?? retriedSuggestedName;
|
|
1876
|
+
const firstOfSession = firstSuggestedName !== null;
|
|
1877
|
+
const sessionNameRetry = retriedSuggestedName !== null;
|
|
1862
1878
|
|
|
1863
1879
|
emit.data({
|
|
1864
1880
|
instance_id: myOwner,
|
|
@@ -1866,6 +1882,7 @@ function runSetTask(task: string, opts?: { sessionId?: string }): void {
|
|
|
1866
1882
|
task: hb?.task ?? null,
|
|
1867
1883
|
cleared: !task || task.length === 0,
|
|
1868
1884
|
first_of_session: firstOfSession,
|
|
1885
|
+
session_name_retry: sessionNameRetry,
|
|
1869
1886
|
suggested_session_name: suggestedName,
|
|
1870
1887
|
...(lifecycleWarning ? { warning: lifecycleWarning } : {}),
|
|
1871
1888
|
// Right-time instruction: the UserPromptSubmit nudge fires before the name
|
|
@@ -38,7 +38,7 @@ export function sessionNameDisplayInstruction(name: string): string {
|
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* A PostToolUse result should announce the display protocol only when that
|
|
41
|
-
* exact tool call minted the current suggestion. The coordination row keeps
|
|
41
|
+
* exact tool call minted or retried the current suggestion. The coordination row keeps
|
|
42
42
|
* the suggestion pending until transcript evidence catches up, so checking
|
|
43
43
|
* the row alone would re-announce the same name after every later tool.
|
|
44
44
|
*
|
|
@@ -89,7 +89,7 @@ function responseContainsSessionNameMint(
|
|
|
89
89
|
const row = value as Record<string, unknown>;
|
|
90
90
|
if (
|
|
91
91
|
row.suggested_session_name === name &&
|
|
92
|
-
(row.first_of_session === true || row.name_reminted === true)
|
|
92
|
+
(row.first_of_session === true || row.name_reminted === true || row.session_name_retry === true)
|
|
93
93
|
) {
|
|
94
94
|
return true;
|
|
95
95
|
}
|
package/src/core/hooks/cli.ts
CHANGED
|
@@ -1117,8 +1117,9 @@ async function main(): Promise<number> {
|
|
|
1117
1117
|
}
|
|
1118
1118
|
|
|
1119
1119
|
if (norm.event_type === "tool.completed" && eventName === "post-tool-use") {
|
|
1120
|
-
// Inject only at the successful tool boundary that actually minted
|
|
1121
|
-
// the first non-empty set-task
|
|
1120
|
+
// Inject only at the successful tool boundary that actually minted or
|
|
1121
|
+
// retried a name: the first non-empty set-task, a pending-name set-task
|
|
1122
|
+
// retry, or the transition to lifecycle done. The
|
|
1122
1123
|
// coordination row intentionally remains pending until transcript evidence
|
|
1123
1124
|
// catches up; reading that latch alone here would re-inject after every
|
|
1124
1125
|
// later tool and make the agent print the same block repeatedly.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
2
2
|
import { basename, dirname, join } from "node:path";
|
|
3
3
|
|
|
4
|
+
import { toolResponseMintedSessionName } from "../../agents/session-name-display.ts";
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* Scan a CC-style JSONL transcript for the `┌─ agent-` status-box prefix in
|
|
6
8
|
* the most-recent assistant turn. Used by `turn.completed` events to populate
|
|
@@ -131,19 +133,23 @@ export function inspectSessionNameDisplayImmediately(
|
|
|
131
133
|
const text = tailText(readablePath);
|
|
132
134
|
if (!text) return { state: "unavailable", reason: "transcript_not_ready" };
|
|
133
135
|
let sawMintResult = false;
|
|
136
|
+
let awaitingReply = false;
|
|
134
137
|
for (const line of text.split("\n")) {
|
|
135
|
-
if (!sawMintResult) {
|
|
136
|
-
if (line.includes(name) && line.includes("suggested_session_name")) sawMintResult = true;
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
138
|
const row = parseTranscriptRow(line);
|
|
140
139
|
if (!row) continue;
|
|
140
|
+
if (toolResponseMintedSessionName(row, name)) {
|
|
141
|
+
sawMintResult = true;
|
|
142
|
+
awaitingReply = true;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (!awaitingReply) continue;
|
|
141
146
|
const assistantText = assistantTextFromRow(row);
|
|
142
147
|
if (assistantText !== null) {
|
|
143
|
-
|
|
148
|
+
if (startsWithBlock(assistantText, name)) return { state: "present" };
|
|
149
|
+
awaitingReply = false;
|
|
144
150
|
}
|
|
145
151
|
}
|
|
146
|
-
return sawMintResult
|
|
152
|
+
return sawMintResult && awaitingReply
|
|
147
153
|
? { state: "unavailable", reason: "transcript_not_ready" }
|
|
148
154
|
: { state: "absent" };
|
|
149
155
|
}
|