@rubytech/create-realagent-code 0.1.565 → 0.1.567
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/package.json +1 -1
- package/payload/platform/config/brand-registry.json +1 -1
- package/payload/platform/neo4j/schema.cypher +9 -0
- package/payload/platform/package-lock.json +66 -1
- package/payload/platform/plugins/.claude-plugin/marketplace.json +5 -0
- package/payload/platform/plugins/admin/hooks/lib/maxy-mcp-plugins.txt +1 -0
- package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +48 -1
- package/payload/platform/plugins/admin/skills/public-agent-manager/SKILL.md +5 -1
- package/payload/platform/plugins/admin/skills/whats-new/SKILL.md +10 -0
- package/payload/platform/plugins/docs/references/channel-wake-and-prompt.md +47 -0
- package/payload/platform/plugins/inventory/.claude-plugin/plugin.json +21 -0
- package/payload/platform/plugins/inventory/PLUGIN.md +75 -0
- package/payload/platform/plugins/inventory/lib/mcp-spawn-tee/index.js +204 -0
- package/payload/platform/plugins/inventory/lib/mcp-spawn-tee/package.json +3 -0
- package/payload/platform/plugins/inventory/mcp/dist/index.d.ts +2 -0
- package/payload/platform/plugins/inventory/mcp/dist/index.d.ts.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/index.js +241 -0
- package/payload/platform/plugins/inventory/mcp/dist/index.js.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/forecast.d.ts +20 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/forecast.d.ts.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/forecast.js +29 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/forecast.js.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/neo4j.d.ts +5 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/neo4j.d.ts.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/neo4j.js +40 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/neo4j.js.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/read.d.ts +28 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/read.d.ts.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/read.js +91 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/read.js.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/replenish.d.ts +56 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/replenish.d.ts.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/replenish.js +107 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/replenish.js.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/types.d.ts +98 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/types.d.ts.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/types.js +7 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/types.js.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/write-rejects.d.ts +12 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/write-rejects.d.ts.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/write-rejects.js +49 -0
- package/payload/platform/plugins/inventory/mcp/dist/lib/write-rejects.js.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/demand-record.d.ts +20 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/demand-record.d.ts.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/demand-record.js +53 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/demand-record.js.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/forecast.d.ts +23 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/forecast.d.ts.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/forecast.js +18 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/forecast.js.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/policy-set.d.ts +25 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/policy-set.d.ts.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/policy-set.js +37 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/policy-set.js.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/purchase-order-record.d.ts +25 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/purchase-order-record.d.ts.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/purchase-order-record.js +43 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/purchase-order-record.js.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/replenish-plan.d.ts +29 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/replenish-plan.d.ts.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/replenish-plan.js +95 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/replenish-plan.js.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/stock-record.d.ts +21 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/stock-record.d.ts.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/stock-record.js +46 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/stock-record.js.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/supplier-terms-set.d.ts +24 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/supplier-terms-set.d.ts.map +1 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/supplier-terms-set.js +29 -0
- package/payload/platform/plugins/inventory/mcp/dist/tools/supplier-terms-set.js.map +1 -0
- package/payload/platform/plugins/inventory/mcp/package.json +21 -0
- package/payload/platform/plugins/memory/references/schema-retail.md +20 -0
- package/payload/platform/scripts/vnc.sh +10 -1
- package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js +8 -0
- package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.js +66 -5
- package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/public-spawn-model.d.ts +28 -0
- package/payload/platform/services/claude-session-manager/dist/public-spawn-model.d.ts.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/public-spawn-model.js +58 -0
- package/payload/platform/services/claude-session-manager/dist/public-spawn-model.js.map +1 -0
- package/payload/platform/services/telegram-channel/dist/server.d.ts +5 -0
- package/payload/platform/services/telegram-channel/dist/server.d.ts.map +1 -1
- package/payload/platform/services/telegram-channel/dist/server.js +22 -2
- package/payload/platform/services/telegram-channel/dist/server.js.map +1 -1
- package/payload/platform/services/telegram-channel/dist/turn-follow.d.ts +34 -2
- package/payload/platform/services/telegram-channel/dist/turn-follow.d.ts.map +1 -1
- package/payload/platform/services/telegram-channel/dist/turn-follow.js +150 -14
- package/payload/platform/services/telegram-channel/dist/turn-follow.js.map +1 -1
- package/payload/platform/services/webchat-channel/dist/server.d.ts +5 -0
- package/payload/platform/services/webchat-channel/dist/server.d.ts.map +1 -1
- package/payload/platform/services/webchat-channel/dist/server.js +22 -2
- package/payload/platform/services/webchat-channel/dist/server.js.map +1 -1
- package/payload/platform/services/webchat-channel/dist/turn-follow.d.ts +34 -2
- package/payload/platform/services/webchat-channel/dist/turn-follow.d.ts.map +1 -1
- package/payload/platform/services/webchat-channel/dist/turn-follow.js +150 -14
- package/payload/platform/services/webchat-channel/dist/turn-follow.js.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/server.d.ts +10 -2
- package/payload/platform/services/whatsapp-channel/dist/server.d.ts.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/server.js +45 -6
- package/payload/platform/services/whatsapp-channel/dist/server.js.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/turn-follow.d.ts +34 -2
- package/payload/platform/services/whatsapp-channel/dist/turn-follow.d.ts.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/turn-follow.js +153 -15
- package/payload/platform/services/whatsapp-channel/dist/turn-follow.js.map +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Which declaration the resolved model came from. `settings` means nothing
|
|
2
|
+
* was declared and settings.json governs — a positive verdict, not a
|
|
3
|
+
* failure. */
|
|
4
|
+
export type PublicModelSource = 'agent-config' | 'account-json' | 'settings';
|
|
5
|
+
export interface PublicModelResolution {
|
|
6
|
+
/** The id to push as `--model`. Null means push nothing. */
|
|
7
|
+
model: string | null;
|
|
8
|
+
source: PublicModelSource;
|
|
9
|
+
/** The FIRST declared value that failed SELECTABLE_MODELS validation, with
|
|
10
|
+
* the level that declared it. Null when every level was either absent or
|
|
11
|
+
* valid. A missing/damaged file is not a rejection — nothing was written,
|
|
12
|
+
* so there is nothing for an operator to correct. */
|
|
13
|
+
rejected: {
|
|
14
|
+
value: string;
|
|
15
|
+
from: 'agent-config' | 'account-json';
|
|
16
|
+
} | null;
|
|
17
|
+
}
|
|
18
|
+
/** Resolve the model for a public spawn: the agent's own config.json, then
|
|
19
|
+
* the account's publicModel, then nothing.
|
|
20
|
+
*
|
|
21
|
+
* The agent directory comes from `resolveAgentIdentityDir`, the documented
|
|
22
|
+
* single source of truth for where a public spawn reads its agent from, so
|
|
23
|
+
* the model and the persona can never disagree about which agent they came
|
|
24
|
+
* from. `slug` is null for a public spawn that supplies none (a WhatsApp
|
|
25
|
+
* public inbound with no enabled public agent); that spawn starts at the
|
|
26
|
+
* account level. */
|
|
27
|
+
export declare function resolvePublicSpawnModel(accountDir: string, slug: string | null): PublicModelResolution;
|
|
28
|
+
//# sourceMappingURL=public-spawn-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-spawn-model.d.ts","sourceRoot":"","sources":["../src/public-spawn-model.ts"],"names":[],"mappings":"AAmBA;;eAEe;AACf,MAAM,MAAM,iBAAiB,GAAG,cAAc,GAAG,cAAc,GAAG,UAAU,CAAA;AAE5E,MAAM,WAAW,qBAAqB;IACpC,4DAA4D;IAC5D,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,MAAM,EAAE,iBAAiB,CAAA;IACzB;;;0DAGsD;IACtD,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,cAAc,GAAG,cAAc,CAAA;KAAE,GAAG,IAAI,CAAA;CAC1E;AAeD;;;;;;;;qBAQqB;AACrB,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,qBAAqB,CAiBtG"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// The model a role:'public' /rc-spawn runs under (Task 2452).
|
|
2
|
+
//
|
|
3
|
+
// Commit 725731df9 routed a public Telegram bot from /public-spawn to
|
|
4
|
+
// /rc-spawn for the tool lockdown. /rc-spawn pushes --model only for a
|
|
5
|
+
// WhatsApp admin spawn or a fresh admin pick, so a public spawn carried none
|
|
6
|
+
// and the CLI took settings.json — pinned to claude-opus-5[1m] by the
|
|
7
|
+
// rc-daemon for the ADMIN session. Three declarations of the intended model
|
|
8
|
+
// went unread. Operator decision 2026-08-05: the agent's own config.json is
|
|
9
|
+
// the source of truth.
|
|
10
|
+
//
|
|
11
|
+
// This module reads and decides; it does not log. The handler owns the log
|
|
12
|
+
// lines so the correlation key (sessionId) stays in one place — the same
|
|
13
|
+
// split public-agent-reachability.ts uses.
|
|
14
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
15
|
+
import { join } from 'node:path';
|
|
16
|
+
import { isSelectableModel } from '../../../lib/models/dist/index.js';
|
|
17
|
+
import { resolveAgentIdentityDir } from './agent-identity-locator.js';
|
|
18
|
+
/** The `model`-shaped string a JSON file declares, or null when the file is
|
|
19
|
+
* absent, unreadable, not an object, or carries no string at `key`. */
|
|
20
|
+
function declaredModel(path, key) {
|
|
21
|
+
if (!existsSync(path))
|
|
22
|
+
return null;
|
|
23
|
+
try {
|
|
24
|
+
const parsed = JSON.parse(readFileSync(path, 'utf-8'));
|
|
25
|
+
const value = parsed[key];
|
|
26
|
+
return typeof value === 'string' && value.length > 0 ? value : null;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** Resolve the model for a public spawn: the agent's own config.json, then
|
|
33
|
+
* the account's publicModel, then nothing.
|
|
34
|
+
*
|
|
35
|
+
* The agent directory comes from `resolveAgentIdentityDir`, the documented
|
|
36
|
+
* single source of truth for where a public spawn reads its agent from, so
|
|
37
|
+
* the model and the persona can never disagree about which agent they came
|
|
38
|
+
* from. `slug` is null for a public spawn that supplies none (a WhatsApp
|
|
39
|
+
* public inbound with no enabled public agent); that spawn starts at the
|
|
40
|
+
* account level. */
|
|
41
|
+
export function resolvePublicSpawnModel(accountDir, slug) {
|
|
42
|
+
let rejected = null;
|
|
43
|
+
const agentDir = slug ? resolveAgentIdentityDir(accountDir, 'public', slug) : null;
|
|
44
|
+
const fromAgent = agentDir ? declaredModel(join(agentDir, 'config.json'), 'model') : null;
|
|
45
|
+
if (fromAgent !== null) {
|
|
46
|
+
if (isSelectableModel(fromAgent))
|
|
47
|
+
return { model: fromAgent, source: 'agent-config', rejected: null };
|
|
48
|
+
rejected = { value: fromAgent, from: 'agent-config' };
|
|
49
|
+
}
|
|
50
|
+
const fromAccount = declaredModel(join(accountDir, 'account.json'), 'publicModel');
|
|
51
|
+
if (fromAccount !== null) {
|
|
52
|
+
if (isSelectableModel(fromAccount))
|
|
53
|
+
return { model: fromAccount, source: 'account-json', rejected };
|
|
54
|
+
rejected ??= { value: fromAccount, from: 'account-json' };
|
|
55
|
+
}
|
|
56
|
+
return { model: null, source: 'settings', rejected };
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=public-spawn-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-spawn-model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CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,aAAa,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IACzF,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,IAAI,iBAAiB,CAAC,SAAS,CAAC;YAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;QACrG,QAAQ,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,cAAc,EAAE,CAAA;IACvD,CAAC;IAED,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,EAAE,aAAa,CAAC,CAAA;IAClF,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;QACzB,IAAI,iBAAiB,CAAC,WAAW,CAAC;YAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAA;QACnG,QAAQ,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,EAAE,CAAA;IAC3D,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAA;AACtD,CAAC"}
|
|
@@ -35,6 +35,11 @@ export declare const mcp: Server<{
|
|
|
35
35
|
} | undefined;
|
|
36
36
|
} | undefined;
|
|
37
37
|
}>;
|
|
38
|
+
/** Task 2451 — how often the follower's hold state is reported. A held segment
|
|
39
|
+
* that never resolves emits nothing of its own, so this census is the only
|
|
40
|
+
* surface that shows it. Exported so tests assert the value without waiting it
|
|
41
|
+
* out. */
|
|
42
|
+
export declare const CENSUS_INTERVAL_MS = 60000;
|
|
38
43
|
export declare function subscribeInbound(): Promise<void>;
|
|
39
44
|
export declare function main(): Promise<void>;
|
|
40
45
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAmBA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAiDlE,eAAO,MAAM,YAAY,QAA4B,CAAA;AAErD,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWf,CAAA;AAwDD,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAmBA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAiDlE,eAAO,MAAM,YAAY,QAA4B,CAAA;AAErD,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWf,CAAA;AAwDD;;;WAGW;AACX,eAAO,MAAM,kBAAkB,QAAS,CAAA;AAExC,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAgKtD;AAED,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAO1C"}
|
|
@@ -120,6 +120,11 @@ async function postReady() {
|
|
|
120
120
|
body: JSON.stringify({ key: KEY }),
|
|
121
121
|
}).catch(() => { });
|
|
122
122
|
}
|
|
123
|
+
/** Task 2451 — how often the follower's hold state is reported. A held segment
|
|
124
|
+
* that never resolves emits nothing of its own, so this census is the only
|
|
125
|
+
* surface that shows it. Exported so tests assert the value without waiting it
|
|
126
|
+
* out. */
|
|
127
|
+
export const CENSUS_INTERVAL_MS = 60_000;
|
|
123
128
|
export async function subscribeInbound() {
|
|
124
129
|
const url = `${GATEWAY_URL}/tg-channel/inbound?key=${encodeURIComponent(KEY)}`;
|
|
125
130
|
for (;;) {
|
|
@@ -224,9 +229,23 @@ export async function subscribeInbound() {
|
|
|
224
229
|
followerStarted = true;
|
|
225
230
|
const followPath = jsonlPath;
|
|
226
231
|
const followStart = turnStartOffset;
|
|
232
|
+
// Task 2451 — a held segment that never resolves emits no event of
|
|
233
|
+
// its own. This census is the only surface that shows it, and the
|
|
234
|
+
// only place credit drift is visible between turns.
|
|
235
|
+
const followerState = { held: false, heldMessageId: '', heldSinceMs: -1, lastMessageId: '' };
|
|
236
|
+
const census = setInterval(() => {
|
|
237
|
+
const heldAgeMs = followerState.held && followerState.heldSinceMs >= 0 ? Date.now() - followerState.heldSinceMs : -1;
|
|
238
|
+
console.error(`[telegram-turn-census] op=census sessionId=${SESSION_ID} pending=${pendingTurns} held=${followerState.held ? 1 : 0} heldMessageId=${followerState.heldMessageId} heldAgeMs=${heldAgeMs} lastMessageId=${followerState.lastMessageId}`);
|
|
239
|
+
}, CENSUS_INTERVAL_MS);
|
|
240
|
+
census.unref?.();
|
|
227
241
|
void followTurnEnds(followPath, followStart, (outcome) => {
|
|
228
|
-
|
|
242
|
+
// Task 2451 — an answer discarded here was rendered in the reader
|
|
243
|
+
// and never reached the chat. finalBytes>0 is a parity breach;
|
|
244
|
+
// this line is the only place it is countable.
|
|
245
|
+
if (pendingTurns <= 0) {
|
|
246
|
+
console.error(`[telegram-channel] op=turn-drop sessionId=${SESSION_ID} messageId=${outcome.messageId} finalBytes=${Buffer.byteLength(outcome.finalText.trim(), 'utf8')} reason=no-credit`);
|
|
229
247
|
return;
|
|
248
|
+
}
|
|
230
249
|
pendingTurns--;
|
|
231
250
|
// Task 2078 — the answer ships whatever woke the turn. Tasks 1464
|
|
232
251
|
// and 1539 argued over a fallback that only existed because the
|
|
@@ -242,7 +261,8 @@ export async function subscribeInbound() {
|
|
|
242
261
|
headers: { 'content-type': 'application/json' },
|
|
243
262
|
body: JSON.stringify(buildTurnEndPostBody(KEY, SESSION_ID, outcome.replied, interactive, finalText, outcome.context)),
|
|
244
263
|
}).catch(() => { });
|
|
245
|
-
}).finally(() => {
|
|
264
|
+
}, { state: followerState }).finally(() => {
|
|
265
|
+
clearInterval(census);
|
|
246
266
|
// The follower settles only on a stat failure (file unreadable —
|
|
247
267
|
// the session is ending). Clear any outstanding count so a
|
|
248
268
|
// replacement follower started by a later inbound begins clean.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AACA,gFAAgF;AAChF,0EAA0E;AAC1E,eAAe;AACf,2EAA2E;AAC3E,uDAAuD;AACvD,4EAA4E;AAC5E,kFAAkF;AAClF,iFAAiF;AACjF,iFAAiF;AACjF,EAAE;AACF,oEAAoE;AACpE,gFAAgF;AAChF,8EAA8E;AAC9E,kEAAkE;AAClE,8EAA8E;AAE9E,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAClG,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,aAAa,GAAyB,MAAM,mBAAmB,CAAA;AACtK,OAAO,EAAE,qBAAqB,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AACA,gFAAgF;AAChF,0EAA0E;AAC1E,eAAe;AACf,2EAA2E;AAC3E,uDAAuD;AACvD,4EAA4E;AAC5E,kFAAkF;AAClF,iFAAiF;AACjF,iFAAiF;AACjF,EAAE;AACF,oEAAoE;AACpE,gFAAgF;AAChF,8EAA8E;AAC9E,kEAAkE;AAClE,8EAA8E;AAE9E,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EA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E,IAAI,CAAC,CAAC,CAAA;IAC3D,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI;IACxB,MAAM,GAAG,CAAC,OAAO,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAA;IAC7C,0EAA0E;IAC1E,yEAAyE;IACzE,uEAAuE;IACvE,eAAe;IACf,MAAM,gBAAgB,EAAE,CAAA;AAC1B,CAAC;AAED,+EAA+E;AAC/E,2EAA2E;AAC3E,2EAA2E;AAC3E,wBAAwB;AACxB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7F,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACnB,OAAO,CAAC,KAAK,CAAC,6BAA6B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QAC9F,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -11,6 +11,17 @@ export interface TurnOutcome {
|
|
|
11
11
|
* offsets; `followTurnEnds` overwrites both before calling back. */
|
|
12
12
|
segmentStart: number;
|
|
13
13
|
segmentEnd: number;
|
|
14
|
+
/** Task 2451 — `message.id` of the closing end_turn row; '' when the row
|
|
15
|
+
* carries none. Claude Code 2.1.222 can persist ONE assistant message as
|
|
16
|
+
* several rows, each stamped end_turn, so this is the identity
|
|
17
|
+
* `followTurnEnds` merges a split message on. */
|
|
18
|
+
messageId: string;
|
|
19
|
+
/** Task 2451 — `type:'tool_use'` blocks across EVERY assistant row in the
|
|
20
|
+
* segment. `replied` cannot serve here: it matches only the retired reply
|
|
21
|
+
* tool names, so a turn that called Read or Bash reports replied=false
|
|
22
|
+
* with tool_use present. The hold rule needs "this turn called no tool
|
|
23
|
+
* at all". */
|
|
24
|
+
toolUseBlocks: number;
|
|
14
25
|
/** Task 2364 — the turn's token and thinking counts, for the gateway's
|
|
15
26
|
* op=turn-context line. */
|
|
16
27
|
context: TurnContextCounts;
|
|
@@ -50,13 +61,34 @@ export type OnTurnEnd = (outcome: TurnOutcome) => void;
|
|
|
50
61
|
* claude-session-manager/src/jsonl-path.ts) to avoid a cross-package dep.
|
|
51
62
|
*/
|
|
52
63
|
export declare function findJsonlForSessionId(sessionId: string, env?: NodeJS.ProcessEnv): string | null;
|
|
64
|
+
/**
|
|
65
|
+
* Task 2451 — the follower's live hold state, mutated in place so the owning
|
|
66
|
+
* channel server can log a standing census without the follower importing a
|
|
67
|
+
* logger. A held segment that never resolves emits no event of its own; the
|
|
68
|
+
* census is the only surface that shows it.
|
|
69
|
+
*/
|
|
70
|
+
export interface FollowerState {
|
|
71
|
+
/** True while a thinking-only close is held awaiting the rest of its message. */
|
|
72
|
+
held: boolean;
|
|
73
|
+
/** `message.id` of the held segment; '' when not holding. */
|
|
74
|
+
heldMessageId: string;
|
|
75
|
+
/** Clock value when the hold began; -1 when not holding. */
|
|
76
|
+
heldSinceMs: number;
|
|
77
|
+
/** `message.id` of the last outcome emitted; '' before the first. */
|
|
78
|
+
lastMessageId: string;
|
|
79
|
+
}
|
|
53
80
|
/**
|
|
54
81
|
* Tail `jsonlPath` from `startOffset` for the life of the session, invoking
|
|
55
|
-
* `onTurnEnd` once
|
|
82
|
+
* `onTurnEnd` once per TURN. Task 2451: that is once per assistant end_turn
|
|
83
|
+
* EXCEPT where one message was split across several end_turn rows, which are
|
|
84
|
+
* merged into a single call. It
|
|
56
85
|
* segments the JSONL at each end_turn so a follow-on turn produced from a
|
|
57
86
|
* mid-turn-queued message is reported too. The process dies with the session,
|
|
58
87
|
* so there is no per-turn timeout; the promise resolves only when the file
|
|
59
88
|
* becomes unreadable. Never rejects. (Mirror of the WhatsApp twin.)
|
|
60
89
|
*/
|
|
61
|
-
export declare function followTurnEnds(jsonlPath: string, startOffset: number, onTurnEnd: OnTurnEnd
|
|
90
|
+
export declare function followTurnEnds(jsonlPath: string, startOffset: number, onTurnEnd: OnTurnEnd, opts?: {
|
|
91
|
+
state?: FollowerState;
|
|
92
|
+
now?: () => number;
|
|
93
|
+
}): Promise<void>;
|
|
62
94
|
//# sourceMappingURL=turn-follow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turn-follow.d.ts","sourceRoot":"","sources":["../src/turn-follow.ts"],"names":[],"mappings":"AAwBA,MAAM,WAAW,WAAW;IAC1B,sDAAsD;IACtD,OAAO,EAAE,OAAO,CAAA;IAChB,+EAA+E;IAC/E,SAAS,EAAE,MAAM,CAAA;IACjB,8CAA8C;IAC9C,cAAc,EAAE,OAAO,CAAA;IACvB;;;yEAGqE;IACrE,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB;gCAC4B;IAC5B,OAAO,EAAE,iBAAiB,CAAA;CAC3B;
|
|
1
|
+
{"version":3,"file":"turn-follow.d.ts","sourceRoot":"","sources":["../src/turn-follow.ts"],"names":[],"mappings":"AAwBA,MAAM,WAAW,WAAW;IAC1B,sDAAsD;IACtD,OAAO,EAAE,OAAO,CAAA;IAChB,+EAA+E;IAC/E,SAAS,EAAE,MAAM,CAAA;IACjB,8CAA8C;IAC9C,cAAc,EAAE,OAAO,CAAA;IACvB;;;yEAGqE;IACrE,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB;;;sDAGkD;IAClD,SAAS,EAAE,MAAM,CAAA;IACjB;;;;mBAIe;IACf,aAAa,EAAE,MAAM,CAAA;IACrB;gCAC4B;IAC5B,OAAO,EAAE,iBAAiB,CAAA;CAC3B;AAYD;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC;;yEAEqE;IACrE,eAAe,EAAE,MAAM,CAAA;IACvB,wEAAwE;IACxE,WAAW,EAAE,MAAM,CAAA;IACnB,yEAAyE;IACzE,YAAY,EAAE,MAAM,CAAA;IACpB;;;6DAGyD;IACzD,cAAc,EAAE,MAAM,CAAA;IACtB;;gEAE4D;IAC5D,aAAa,EAAE,MAAM,CAAA;CACtB;AAOD,2EAA2E;AAC3E,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,WAAW,CA8EhE;AAED,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAA;AAkBtD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,GAAG,IAAI,CAmBf;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,iFAAiF;IACjF,IAAI,EAAE,OAAO,CAAA;IACb,6DAA6D;IAC7D,aAAa,EAAE,MAAM,CAAA;IACrB,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAA;IACnB,qEAAqE;IACrE,aAAa,EAAE,MAAM,CAAA;CACtB;AAmCD;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,SAAS,EACpB,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,aAAa,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAO,GACvD,OAAO,CAAC,IAAI,CAAC,CA+Jf"}
|
|
@@ -34,6 +34,8 @@ export function reduceTurnFromLines(lines) {
|
|
|
34
34
|
let outputTokens = -1;
|
|
35
35
|
let thinkingBlocks = 0;
|
|
36
36
|
let thinkingChars = 0;
|
|
37
|
+
let messageId = '';
|
|
38
|
+
let toolUseBlocks = 0;
|
|
37
39
|
for (const line of lines) {
|
|
38
40
|
if (!line)
|
|
39
41
|
continue;
|
|
@@ -52,6 +54,11 @@ export function reduceTurnFromLines(lines) {
|
|
|
52
54
|
// assistant row in the turn contributes, not only the end_turn row.
|
|
53
55
|
if (msg && Array.isArray(msg.content)) {
|
|
54
56
|
for (const block of msg.content) {
|
|
57
|
+
// Task 2451 — counted here, in the same unguarded pass as thinking, so
|
|
58
|
+
// a row whose content is present but whose shape fails the later guard
|
|
59
|
+
// still contributes its tool calls.
|
|
60
|
+
if (block?.type === 'tool_use')
|
|
61
|
+
toolUseBlocks++;
|
|
55
62
|
if (block?.type !== 'thinking')
|
|
56
63
|
continue;
|
|
57
64
|
thinkingBlocks++;
|
|
@@ -59,18 +66,22 @@ export function reduceTurnFromLines(lines) {
|
|
|
59
66
|
thinkingChars += block.thinking.length;
|
|
60
67
|
}
|
|
61
68
|
}
|
|
62
|
-
//
|
|
63
|
-
//
|
|
69
|
+
// Task 2451 — a segment normally holds exactly one end_turn row, but a MERGED
|
|
70
|
+
// segment holds every end_turn row of one split assistant message. Those rows
|
|
71
|
+
// carry identical `id` and `usage` (measured on msg_011Cdk9NsrGoTd4dEsi25uvq),
|
|
72
|
+
// so re-assigning per row is last-wins over equal values.
|
|
64
73
|
if (isEnd) {
|
|
74
|
+
messageId = typeof msg?.id === 'string' ? msg.id : '';
|
|
65
75
|
cacheReadTokens = usageNum(msg?.usage?.cache_read_input_tokens);
|
|
66
76
|
inputTokens = usageNum(msg?.usage?.input_tokens);
|
|
67
77
|
outputTokens = usageNum(msg?.usage?.output_tokens);
|
|
68
78
|
}
|
|
69
79
|
if (!msg || !Array.isArray(msg.content)) {
|
|
70
|
-
|
|
80
|
+
// Task 2451 — `finalText` is NOT cleared here. It is '' unless an earlier
|
|
81
|
+
// end_turn row of the same merged message already contributed text, and
|
|
82
|
+
// erasing that would drop an answer this segment holds.
|
|
83
|
+
if (isEnd)
|
|
71
84
|
reachedEndTurn = true;
|
|
72
|
-
finalText = '';
|
|
73
|
-
}
|
|
74
85
|
continue;
|
|
75
86
|
}
|
|
76
87
|
let endText = '';
|
|
@@ -84,7 +95,10 @@ export function reduceTurnFromLines(lines) {
|
|
|
84
95
|
}
|
|
85
96
|
if (isEnd) {
|
|
86
97
|
reachedEndTurn = true;
|
|
87
|
-
|
|
98
|
+
// Task 2451 — accumulate rather than assign: a split message is ONE answer,
|
|
99
|
+
// so its text is the concatenation of its rows. Identical to assignment on
|
|
100
|
+
// an ordinary segment, which holds a single end_turn row.
|
|
101
|
+
finalText += endText;
|
|
88
102
|
}
|
|
89
103
|
}
|
|
90
104
|
return {
|
|
@@ -93,6 +107,8 @@ export function reduceTurnFromLines(lines) {
|
|
|
93
107
|
reachedEndTurn,
|
|
94
108
|
segmentStart: -1,
|
|
95
109
|
segmentEnd: -1,
|
|
110
|
+
messageId,
|
|
111
|
+
toolUseBlocks,
|
|
96
112
|
context: { cacheReadTokens, inputTokens, outputTokens, thinkingBlocks, thinkingChars },
|
|
97
113
|
};
|
|
98
114
|
}
|
|
@@ -142,15 +158,52 @@ export function findJsonlForSessionId(sessionId, env = process.env) {
|
|
|
142
158
|
}
|
|
143
159
|
return null;
|
|
144
160
|
}
|
|
161
|
+
/** The `message.id` of an assistant row, or '' for any other row shape. */
|
|
162
|
+
function rowMessageId(line) {
|
|
163
|
+
if (!line)
|
|
164
|
+
return '';
|
|
165
|
+
let ev;
|
|
166
|
+
try {
|
|
167
|
+
ev = JSON.parse(line);
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
return '';
|
|
171
|
+
}
|
|
172
|
+
if (ev.type !== 'assistant')
|
|
173
|
+
return '';
|
|
174
|
+
return typeof ev.message?.id === 'string' ? ev.message.id : '';
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Task 2451 — a close reducing to no text, no tool use and at least one thinking
|
|
178
|
+
* block is not a finished turn. Claude Code 2.1.222 persists one assistant
|
|
179
|
+
* message as one row per content block, each stamped end_turn, so the thinking
|
|
180
|
+
* row closes the turn before the text row exists. Measured on account 5bc2c0e2:
|
|
181
|
+
* 89 of 481 end_turn rows are thinking-only and 89 of 89 are followed by a text
|
|
182
|
+
* end_turn row of the same message.
|
|
183
|
+
*/
|
|
184
|
+
function isIncompleteClose(o) {
|
|
185
|
+
// A close with no `message.id` is never held. The hold is released by the
|
|
186
|
+
// first row whose id differs, and `rowMessageId` reports '' for EVERY
|
|
187
|
+
// non-assistant row, so a hold keyed on '' matches the next user row instead
|
|
188
|
+
// of releasing on it: that row joins the held segment, the empty turn takes
|
|
189
|
+
// its inbound, and the real answer arrives with nothing left to consume and is
|
|
190
|
+
// discarded at the server's credit guard. That is precisely the loss this
|
|
191
|
+
// hold exists to prevent, reintroduced by the identity test degenerating.
|
|
192
|
+
if (o.messageId === '')
|
|
193
|
+
return false;
|
|
194
|
+
return o.finalText === '' && o.toolUseBlocks === 0 && o.context.thinkingBlocks >= 1;
|
|
195
|
+
}
|
|
145
196
|
/**
|
|
146
197
|
* Tail `jsonlPath` from `startOffset` for the life of the session, invoking
|
|
147
|
-
* `onTurnEnd` once
|
|
198
|
+
* `onTurnEnd` once per TURN. Task 2451: that is once per assistant end_turn
|
|
199
|
+
* EXCEPT where one message was split across several end_turn rows, which are
|
|
200
|
+
* merged into a single call. It
|
|
148
201
|
* segments the JSONL at each end_turn so a follow-on turn produced from a
|
|
149
202
|
* mid-turn-queued message is reported too. The process dies with the session,
|
|
150
203
|
* so there is no per-turn timeout; the promise resolves only when the file
|
|
151
204
|
* becomes unreadable. Never rejects. (Mirror of the WhatsApp twin.)
|
|
152
205
|
*/
|
|
153
|
-
export async function followTurnEnds(jsonlPath, startOffset, onTurnEnd) {
|
|
206
|
+
export async function followTurnEnds(jsonlPath, startOffset, onTurnEnd, opts = {}) {
|
|
154
207
|
let baseSize;
|
|
155
208
|
try {
|
|
156
209
|
baseSize = statSync(jsonlPath).size;
|
|
@@ -170,6 +223,43 @@ export async function followTurnEnds(jsonlPath, startOffset, onTurnEnd) {
|
|
|
170
223
|
let segStart = Math.min(startOffset, baseSize);
|
|
171
224
|
let segEnd = segStart;
|
|
172
225
|
let segment = [];
|
|
226
|
+
const state = opts.state;
|
|
227
|
+
const now = opts.now ?? (() => Date.now());
|
|
228
|
+
// Task 2451 — the held segment's lines and its byte start. `heldId` is the
|
|
229
|
+
// message identity a later row must match to extend it. Null when not holding.
|
|
230
|
+
let heldSegment = null;
|
|
231
|
+
let heldId = '';
|
|
232
|
+
let heldStart = 0;
|
|
233
|
+
/** Emit an outcome over the given lines and record it on the shared state. */
|
|
234
|
+
const emit = (lines, start, end) => {
|
|
235
|
+
const outcome = reduceTurnFromLines(lines);
|
|
236
|
+
outcome.segmentStart = start;
|
|
237
|
+
outcome.segmentEnd = end;
|
|
238
|
+
if (state)
|
|
239
|
+
state.lastMessageId = outcome.messageId;
|
|
240
|
+
onTurnEnd(outcome);
|
|
241
|
+
};
|
|
242
|
+
/** Release a held segment as its own (empty-answer) turn. */
|
|
243
|
+
const clearHold = () => {
|
|
244
|
+
heldSegment = null;
|
|
245
|
+
heldId = '';
|
|
246
|
+
if (state) {
|
|
247
|
+
state.held = false;
|
|
248
|
+
state.heldMessageId = '';
|
|
249
|
+
state.heldSinceMs = -1;
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
// Declared ahead of `settle`, which calls it: both are const arrow functions
|
|
253
|
+
// in one scope, so the reverse order throws a TDZ ReferenceError on the
|
|
254
|
+
// watcher-error path, which TypeScript does not report.
|
|
255
|
+
const flushHeld = (end) => {
|
|
256
|
+
if (!heldSegment)
|
|
257
|
+
return;
|
|
258
|
+
const lines = heldSegment;
|
|
259
|
+
const start = heldStart;
|
|
260
|
+
clearHold();
|
|
261
|
+
emit(lines, start, end);
|
|
262
|
+
};
|
|
173
263
|
let settled = false;
|
|
174
264
|
const settle = () => {
|
|
175
265
|
if (settled)
|
|
@@ -177,6 +267,10 @@ export async function followTurnEnds(jsonlPath, startOffset, onTurnEnd) {
|
|
|
177
267
|
settled = true;
|
|
178
268
|
watcher.close();
|
|
179
269
|
clearInterval(poll);
|
|
270
|
+
// Task 2451 — a hold outstanding when the session ends is that answer's
|
|
271
|
+
// last chance to be reported. Flush before the promise resolves and the
|
|
272
|
+
// owning server clears its counters.
|
|
273
|
+
flushHeld(segEnd);
|
|
180
274
|
resolve();
|
|
181
275
|
};
|
|
182
276
|
// Poll as well as watch: fs.watch misses appends on some platforms (notably
|
|
@@ -215,16 +309,58 @@ export async function followTurnEnds(jsonlPath, startOffset, onTurnEnd) {
|
|
|
215
309
|
const line = carry.slice(0, nl);
|
|
216
310
|
carry = carry.slice(nl + 1);
|
|
217
311
|
nl = carry.indexOf('\n');
|
|
218
|
-
|
|
312
|
+
// Task 2451 — a row belonging to a different message ends the held one.
|
|
313
|
+
// Releasing here rather than at the next end_turn keeps the hold as short
|
|
314
|
+
// as the transcript allows: a following user or tool row frees it at once.
|
|
315
|
+
// `segEnd` has not yet advanced past this line, so the flushed segment's
|
|
316
|
+
// end offset correctly excludes the releasing row, and `segStart` must
|
|
317
|
+
// move to that same boundary or the next outcome's byte range re-covers
|
|
318
|
+
// the flushed turn (webchat ships those offsets to the gateway).
|
|
319
|
+
if (heldSegment && rowMessageId(line) !== heldId) {
|
|
320
|
+
flushHeld(segEnd);
|
|
321
|
+
segStart = segEnd;
|
|
322
|
+
}
|
|
323
|
+
if (heldSegment) {
|
|
324
|
+
heldSegment.push(line);
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
segment.push(line);
|
|
328
|
+
}
|
|
219
329
|
segEnd += Buffer.byteLength(line, 'utf8') + 1;
|
|
220
|
-
if (isAssistantEndTurn(line))
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
330
|
+
if (!isAssistantEndTurn(line))
|
|
331
|
+
continue;
|
|
332
|
+
if (heldSegment) {
|
|
333
|
+
// Same message.id and it closes again: the rest of the split message
|
|
334
|
+
// has arrived. Emit the merged segment, empty text included — a merge
|
|
335
|
+
// that is still empty is an honest empty-answer turn.
|
|
336
|
+
const lines = heldSegment;
|
|
337
|
+
const start = heldStart;
|
|
338
|
+
clearHold();
|
|
339
|
+
emit(lines, start, segEnd);
|
|
340
|
+
segStart = segEnd;
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
const outcome = reduceTurnFromLines(segment);
|
|
344
|
+
if (isIncompleteClose(outcome)) {
|
|
345
|
+
heldSegment = segment;
|
|
346
|
+
heldId = outcome.messageId;
|
|
347
|
+
heldStart = segStart;
|
|
348
|
+
if (state) {
|
|
349
|
+
state.held = true;
|
|
350
|
+
state.heldMessageId = outcome.messageId;
|
|
351
|
+
state.heldSinceMs = now();
|
|
352
|
+
}
|
|
225
353
|
segment = [];
|
|
226
354
|
segStart = segEnd;
|
|
355
|
+
continue;
|
|
227
356
|
}
|
|
357
|
+
outcome.segmentStart = segStart;
|
|
358
|
+
outcome.segmentEnd = segEnd;
|
|
359
|
+
if (state)
|
|
360
|
+
state.lastMessageId = outcome.messageId;
|
|
361
|
+
onTurnEnd(outcome);
|
|
362
|
+
segment = [];
|
|
363
|
+
segStart = segEnd;
|
|
228
364
|
}
|
|
229
365
|
};
|
|
230
366
|
const watcher = watch(jsonlPath, { persistent: false }, () => drain());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turn-follow.js","sourceRoot":"","sources":["../src/turn-follow.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,iFAAiF;AACjF,gFAAgF;AAChF,gFAAgF;AAChF,8EAA8E;AAC9E,qDAAqD;AACrD,EAAE;AACF,+EAA+E;AAC/E,qEAAqE;AACrE,iFAAiF;AACjF,uEAAuE;AACvE,4EAA4E;AAC5E,iEAAiE;AACjE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AACjG,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,iFAAiF;AAC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,QAAQ,GAAG,MAAM,CAAA;oBACjB,SAAQ;gBACV,CAAC;gBACD,OAAO,CAAC,YAAY,GAAG,QAAQ,CAAA;gBAC/B,OAAO,CAAC,UAAU,GAAG,MAAM,CAAA;gBAC3B,IAAI,KAAK;oBAAE,KAAK,CAAC,aAAa,GAAG,OAAO,CAAC,SAAS,CAAA;gBAClD,SAAS,CAAC,OAAO,CAAC,CAAA;gBAClB,OAAO,GAAG,EAAE,CAAA;gBACZ,QAAQ,GAAG,MAAM,CAAA;YACnB,CAAC;QACH,CAAC,CAAA;QAED,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,CAAA;QACtE,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAA;QACnC,KAAK,EAAE,CAAA,CAAC,0DAA0D;IACpE,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -35,6 +35,11 @@ export declare const mcp: Server<{
|
|
|
35
35
|
} | undefined;
|
|
36
36
|
} | undefined;
|
|
37
37
|
}>;
|
|
38
|
+
/** Task 2451 — how often the follower's hold state is reported. A held segment
|
|
39
|
+
* that never resolves emits nothing of its own, so this census is the only
|
|
40
|
+
* surface that shows it. Exported so tests assert the value without waiting it
|
|
41
|
+
* out. */
|
|
42
|
+
export declare const CENSUS_INTERVAL_MS = 60000;
|
|
38
43
|
export declare function subscribeInbound(): Promise<void>;
|
|
39
44
|
export declare function main(): Promise<void>;
|
|
40
45
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAoBA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAmDlE,eAAO,MAAM,YAAY,QAA4B,CAAA;AAErD,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBf,CAAA;AAgKD,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAoBA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAmDlE,eAAO,MAAM,YAAY,QAA4B,CAAA;AAErD,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBf,CAAA;AAgKD;;;WAGW;AACX,eAAO,MAAM,kBAAkB,QAAS,CAAA;AAExC,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAkLtD;AAED,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAO1C"}
|
|
@@ -230,6 +230,11 @@ async function postReady() {
|
|
|
230
230
|
body: JSON.stringify({ key: KEY }),
|
|
231
231
|
}).catch(() => { });
|
|
232
232
|
}
|
|
233
|
+
/** Task 2451 — how often the follower's hold state is reported. A held segment
|
|
234
|
+
* that never resolves emits nothing of its own, so this census is the only
|
|
235
|
+
* surface that shows it. Exported so tests assert the value without waiting it
|
|
236
|
+
* out. */
|
|
237
|
+
export const CENSUS_INTERVAL_MS = 60_000;
|
|
233
238
|
export async function subscribeInbound() {
|
|
234
239
|
// Task 2077 — declare the role this server runs as, so the gateway can refuse
|
|
235
240
|
// an inbound whose asserted role does not match the live session holding this
|
|
@@ -357,9 +362,23 @@ export async function subscribeInbound() {
|
|
|
357
362
|
followerStarted = true;
|
|
358
363
|
const followPath = jsonlPath;
|
|
359
364
|
const followStart = turnStartOffset;
|
|
365
|
+
// Task 2451 — a held segment that never resolves emits no event of
|
|
366
|
+
// its own. This census is the only surface that shows it, and the
|
|
367
|
+
// only place credit drift is visible between turns.
|
|
368
|
+
const followerState = { held: false, heldMessageId: '', heldSinceMs: -1, lastMessageId: '' };
|
|
369
|
+
const census = setInterval(() => {
|
|
370
|
+
const heldAgeMs = followerState.held && followerState.heldSinceMs >= 0 ? Date.now() - followerState.heldSinceMs : -1;
|
|
371
|
+
console.error(`[webchat-turn-census] op=census sessionId=${SESSION_ID} pending=${pendingTurns} held=${followerState.held ? 1 : 0} heldMessageId=${followerState.heldMessageId} heldAgeMs=${heldAgeMs} lastMessageId=${followerState.lastMessageId}`);
|
|
372
|
+
}, CENSUS_INTERVAL_MS);
|
|
373
|
+
census.unref?.();
|
|
360
374
|
void followTurnEnds(followPath, followStart, (outcome) => {
|
|
361
|
-
|
|
375
|
+
// Task 2451 — an answer discarded here was rendered in the reader
|
|
376
|
+
// and never reached the chat. finalBytes>0 is a parity breach;
|
|
377
|
+
// this line is the only place it is countable.
|
|
378
|
+
if (pendingTurns <= 0) {
|
|
379
|
+
console.error(`[webchat-channel] op=turn-drop sessionId=${SESSION_ID} messageId=${outcome.messageId} finalBytes=${Buffer.byteLength(outcome.finalText.trim(), 'utf8')} reason=no-credit`);
|
|
362
380
|
return;
|
|
381
|
+
}
|
|
363
382
|
pendingTurns--;
|
|
364
383
|
const interactive = pendingInteractive.shift() ?? true;
|
|
365
384
|
const finalBytes = Buffer.byteLength(outcome.finalText.trim(), 'utf8');
|
|
@@ -368,7 +387,8 @@ export async function subscribeInbound() {
|
|
|
368
387
|
headers: { 'content-type': 'application/json' },
|
|
369
388
|
body: JSON.stringify(buildTurnEndPostBody(KEY, SESSION_ID, ROLE, interactive, finalBytes, outcome.segmentStart, outcome.segmentEnd, outcome.context)),
|
|
370
389
|
}).catch(() => { });
|
|
371
|
-
}).finally(() => {
|
|
390
|
+
}, { state: followerState }).finally(() => {
|
|
391
|
+
clearInterval(census);
|
|
372
392
|
// The follower settles only on a stat failure (file unreadable —
|
|
373
393
|
// the session is ending). Clear any outstanding count so a
|
|
374
394
|
// replacement follower started by a later inbound begins clean.
|