codiedev 0.9.17 → 0.9.18
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/hook.js +7 -1
- package/dist/limitEvent.d.ts +1 -0
- package/dist/limitEvent.js +13 -0
- package/package.json +1 -1
package/dist/hook.js
CHANGED
|
@@ -112,10 +112,15 @@ async function runStopFailure(hookInput) {
|
|
|
112
112
|
if (!config)
|
|
113
113
|
process.exit(0);
|
|
114
114
|
let event = null;
|
|
115
|
+
let transcriptTail;
|
|
115
116
|
const tp = hookInput.transcript_path;
|
|
116
117
|
if (tp) {
|
|
117
118
|
try {
|
|
118
|
-
|
|
119
|
+
const transcript = fs.readFileSync(tp, "utf8");
|
|
120
|
+
event = (0, limitEvent_1.parseLimitEventFromTranscript)(transcript);
|
|
121
|
+
// Ship the tail with the event so the server can summarize "what they
|
|
122
|
+
// were working on" right now — no waiting for the SessionEnd capture.
|
|
123
|
+
transcriptTail = (0, limitEvent_1.tailForLimitEvent)(transcript) || undefined;
|
|
119
124
|
}
|
|
120
125
|
catch {
|
|
121
126
|
/* unreadable transcript — fall through to minimal event */
|
|
@@ -130,6 +135,7 @@ async function runStopFailure(hookInput) {
|
|
|
130
135
|
at: payload.at,
|
|
131
136
|
resetText: payload.resetText,
|
|
132
137
|
sessionId: hookInput.session_id,
|
|
138
|
+
transcriptTail,
|
|
133
139
|
}, config.token);
|
|
134
140
|
}
|
|
135
141
|
catch {
|
package/dist/limitEvent.d.ts
CHANGED
|
@@ -6,3 +6,4 @@ export interface LimitEvent {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function classifyLimitKind(text: string): LimitKind;
|
|
8
8
|
export declare function parseLimitEventFromTranscript(transcript: string): LimitEvent | null;
|
|
9
|
+
export declare function tailForLimitEvent(transcript: string, maxChars?: number): string;
|
package/dist/limitEvent.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.classifyLimitKind = classifyLimitKind;
|
|
4
4
|
exports.parseLimitEventFromTranscript = parseLimitEventFromTranscript;
|
|
5
|
+
exports.tailForLimitEvent = tailForLimitEvent;
|
|
5
6
|
function classifyLimitKind(text) {
|
|
6
7
|
const t = text.toLowerCase();
|
|
7
8
|
if (t.includes("session limit"))
|
|
@@ -49,3 +50,15 @@ function parseLimitEventFromTranscript(transcript) {
|
|
|
49
50
|
}
|
|
50
51
|
return found;
|
|
51
52
|
}
|
|
53
|
+
// Tail of the raw transcript to ship with the limit event so the server can
|
|
54
|
+
// summarize "what they were working on" immediately — without waiting for the
|
|
55
|
+
// SessionEnd capture (which can lag hours, or drop entirely on Windows).
|
|
56
|
+
// Resumes at a line boundary so every JSONL line in the tail still parses.
|
|
57
|
+
const DEFAULT_TAIL_CHARS = 65536;
|
|
58
|
+
function tailForLimitEvent(transcript, maxChars = DEFAULT_TAIL_CHARS) {
|
|
59
|
+
if (transcript.length <= maxChars)
|
|
60
|
+
return transcript;
|
|
61
|
+
const sliced = transcript.slice(-maxChars);
|
|
62
|
+
const nl = sliced.indexOf("\n");
|
|
63
|
+
return nl === -1 ? sliced : sliced.slice(nl + 1);
|
|
64
|
+
}
|
package/package.json
CHANGED