@adhdev/mesh-shared 1.0.82-rc.12 → 1.0.82-rc.14
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/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -3
- package/dist/index.mjs.map +1 -1
- package/dist/mesh-vocabulary.d.ts +7 -0
- package/dist/node-facts.d.ts +19 -0
- package/dist/turn-evidence.d.ts +8 -4
- package/package.json +1 -1
- package/src/mesh-vocabulary.ts +8 -0
- package/src/node-facts.ts +19 -0
- package/src/quota-freshness.ts +7 -2
- package/src/turn-evidence.ts +6 -4
|
@@ -46,6 +46,13 @@ export type MeshSessionCleanupMode = typeof MESH_SESSION_CLEANUP_MODES[number];
|
|
|
46
46
|
/** Outcome a delegated worker may report through `report_completion`. */
|
|
47
47
|
export declare const WORKER_REPORT_OUTCOMES: readonly ["completed", "blocked", "failed"];
|
|
48
48
|
export type WorkerReportOutcome = typeof WORKER_REPORT_OUTCOMES[number];
|
|
49
|
+
/**
|
|
50
|
+
* Hard cap on a `report_completion` summary (characters, after trim). Over-limit
|
|
51
|
+
* summaries are REJECTED, never truncated. Declared once so the daemon validator
|
|
52
|
+
* and the mcp-server's pre-send check (which keeps an over-limit report out of the
|
|
53
|
+
* durable outbox) cannot drift apart.
|
|
54
|
+
*/
|
|
55
|
+
export declare const WORKER_REPORT_SUMMARY_MAX_CHARS = 8000;
|
|
49
56
|
/** Final branch state a worker reports (see coordinator convergence rules). */
|
|
50
57
|
export declare const WORKER_BRANCH_STATES: readonly ["merged_to_main", "pushed_feature_branch_needs_merge", "blocked_review", "cleanup_candidate", "not_mergeable"];
|
|
51
58
|
export type WorkerBranchState = typeof WORKER_BRANCH_STATES[number];
|
package/dist/node-facts.d.ts
CHANGED
|
@@ -123,6 +123,25 @@ export interface MeshNodeFactsProviderQuota {
|
|
|
123
123
|
* predating the field.
|
|
124
124
|
*/
|
|
125
125
|
fetchedAt?: number;
|
|
126
|
+
/**
|
|
127
|
+
* Provenance of the RETAINED reading when `lastGoodWindows` is true —
|
|
128
|
+
* the source/plan/measurement time of the snapshot that produced the
|
|
129
|
+
* carried numbers, as opposed to the top-level `source`/`planType`,
|
|
130
|
+
* which describe the fresh failed attempt. See daemon-core
|
|
131
|
+
* `QuotaMetadata.lastGood`.
|
|
132
|
+
*/
|
|
133
|
+
lastGood?: {
|
|
134
|
+
measuredAt: number;
|
|
135
|
+
source?: string;
|
|
136
|
+
planType?: string | null;
|
|
137
|
+
collectorScope?: string;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* `'background-collector'` when the snapshot came from a daemon-spawned
|
|
141
|
+
* probe rather than an executing CLI session; a failure with this scope
|
|
142
|
+
* is not evidence about a running session's sign-in.
|
|
143
|
+
*/
|
|
144
|
+
collectorScope?: string;
|
|
126
145
|
[extra: string]: unknown;
|
|
127
146
|
};
|
|
128
147
|
[extra: string]: unknown;
|
package/dist/turn-evidence.d.ts
CHANGED
|
@@ -99,14 +99,14 @@ export type NoProgressObservedStatus = SessionStatus | 'unknown';
|
|
|
99
99
|
* Reasons a turn hold exists. Holds are attempt-scoped only (C2: delivery-side
|
|
100
100
|
* waits are consumer deferral on the `turn.deliver` cursor, not hold rows).
|
|
101
101
|
*/
|
|
102
|
-
export declare const HOLD_REASONS: readonly ["await_delivery", "await_consume", "await_turn", "liveness", "hard_ceiling", "live_pending", "transcript_quiet", "weak_candidate", "suspension_before_consumed", "await_report", "await_end"];
|
|
102
|
+
export declare const HOLD_REASONS: readonly ["await_delivery", "await_consume", "await_turn", "liveness", "hard_ceiling", "live_pending", "transcript_quiet", "weak_candidate", "suspension_before_consumed", "await_report", "await_end", "report_correction"];
|
|
103
103
|
export type HoldReason = typeof HOLD_REASONS[number];
|
|
104
104
|
export declare const TURN_OUTCOMES: readonly ["completed", "failed", "cancelled"];
|
|
105
105
|
export type TurnOutcome = typeof TURN_OUTCOMES[number];
|
|
106
106
|
export declare const COMMIT_STRENGTHS: readonly ["genuine", "weak", "tool_report", "operator"];
|
|
107
107
|
export type CommitStrength = typeof COMMIT_STRENGTHS[number];
|
|
108
108
|
/** Every terminal or reclaim reason the ledger writes. Closed: no free-text reasons. */
|
|
109
|
-
export declare const TURN_REASONS: readonly ["turn_end", "weak_end_confirmed", "transcript_final", "worker_reported", "finalization_timeout_no_response", "session_error", "provider_auth_failed", "provider_billing_failed", "provider_usage_limit_exceeded", "provider_server_overloaded", "provider_error", "operator_cancel", "intentional_cleanup", "task_removed", "mission_abandoned", "superseded", "operator_update", "refine_terminal", "validation_terminal", "hard_ceiling", "reclaim_budget_exhausted", "hollow_max_retries", "migration_orphan", "dispatch_refused_session_exited", "dispatch_refused_no_target", "dispatch_refused_unsupported_input", "dispatch_failed", "session_exit", "session_exit_before_turn", "session_dead", "hollow_completion", "assigned_stranded_dispatch_unconfirmed", "delivered_not_consumed_redrive", "delivered_no_turn_deadline"];
|
|
109
|
+
export declare const TURN_REASONS: readonly ["turn_end", "weak_end_confirmed", "transcript_final", "worker_reported", "finalization_timeout_no_response", "weak_end_liveness_unconfirmed", "weak_end_probe_unobserved", "report_correction_expired", "session_error", "provider_auth_failed", "provider_billing_failed", "provider_usage_limit_exceeded", "provider_server_overloaded", "provider_error", "operator_cancel", "intentional_cleanup", "task_removed", "mission_abandoned", "superseded", "operator_update", "refine_terminal", "validation_terminal", "hard_ceiling", "reclaim_budget_exhausted", "hollow_max_retries", "migration_orphan", "dispatch_refused_session_exited", "dispatch_refused_no_target", "dispatch_refused_unsupported_input", "dispatch_failed", "session_exit", "session_exit_before_turn", "session_dead", "hollow_completion", "assigned_stranded_dispatch_unconfirmed", "delivered_not_consumed_redrive", "delivered_no_turn_deadline"];
|
|
110
110
|
export type TurnReason = typeof TURN_REASONS[number];
|
|
111
111
|
/**
|
|
112
112
|
* What a `turn.notify` entry tells a coordinator.
|
|
@@ -275,6 +275,7 @@ export type TurnEvidenceBody = {
|
|
|
275
275
|
} | {
|
|
276
276
|
kind: 'liveness';
|
|
277
277
|
result: LivenessResult;
|
|
278
|
+
probeStartedAtMs?: number;
|
|
278
279
|
} | {
|
|
279
280
|
kind: 'process_exit';
|
|
280
281
|
exitCode: number | null;
|
|
@@ -295,6 +296,9 @@ export type TurnEvidenceBody = {
|
|
|
295
296
|
hasHandoffNotes: boolean;
|
|
296
297
|
branchState?: WorkerBranchState;
|
|
297
298
|
touchedFileCount?: number;
|
|
299
|
+
} | {
|
|
300
|
+
kind: 'worker_report_correction_requested';
|
|
301
|
+
deliveryId?: string;
|
|
298
302
|
} | {
|
|
299
303
|
kind: 'worker_progress';
|
|
300
304
|
note?: SummaryRef;
|
|
@@ -378,8 +382,8 @@ export declare const TURN_EVIDENCE_FIELD_SPECS: TurnEvidenceFieldSpecs;
|
|
|
378
382
|
export declare const TURN_EVIDENCE_KINDS: readonly TurnEvidenceKind[];
|
|
379
383
|
/** Evidence kinds that, on their own, can end a turn (the ones R18/R19/R27 reason about). */
|
|
380
384
|
export declare const TERMINAL_CLASS_EVIDENCE_KINDS: readonly ["turn_end", "transcript_final", "no_progress", "worker_report", "session_error", "process_exit", "cancel", "operator_status"];
|
|
381
|
-
export declare const isTurnEvidenceKind: (value: unknown) => value is "no_progress" | "delivered" | "liveness" | "turn_end" | "transcript_final" | "session_error" | "dispatch_failed" | "dispatch_accepted" | "delivery_refused" | "duplicate_dispatch_refusal" | "session_rebound" | "turn_started" | "suspension" | "suspension_resolved" | "transcript_activity" | "process_exit" | "worker_report" | "worker_progress" | "git_side_effect" | "cancel" | "operator_status" | "coordinator_ack" | "hold_expired";
|
|
382
|
-
export declare const isTurnReason: (value: unknown) => value is "provider_error" | "intentional_cleanup" | "operator_cancel" | "task_removed" | "mission_abandoned" | "superseded" | "operator_update" | "refine_terminal" | "validation_terminal" | "hard_ceiling" | "turn_end" | "weak_end_confirmed" | "transcript_final" | "worker_reported" | "finalization_timeout_no_response" | "session_error" | "provider_auth_failed" | "provider_billing_failed" | "provider_usage_limit_exceeded" | "provider_server_overloaded" | "reclaim_budget_exhausted" | "hollow_max_retries" | "migration_orphan" | "dispatch_refused_session_exited" | "dispatch_refused_no_target" | "dispatch_refused_unsupported_input" | "dispatch_failed" | "session_exit" | "session_exit_before_turn" | "session_dead" | "hollow_completion" | "assigned_stranded_dispatch_unconfirmed" | "delivered_not_consumed_redrive" | "delivered_no_turn_deadline";
|
|
385
|
+
export declare const isTurnEvidenceKind: (value: unknown) => value is "no_progress" | "delivered" | "liveness" | "turn_end" | "transcript_final" | "session_error" | "dispatch_failed" | "dispatch_accepted" | "delivery_refused" | "duplicate_dispatch_refusal" | "session_rebound" | "turn_started" | "suspension" | "suspension_resolved" | "transcript_activity" | "process_exit" | "worker_report" | "worker_report_correction_requested" | "worker_progress" | "git_side_effect" | "cancel" | "operator_status" | "coordinator_ack" | "hold_expired";
|
|
386
|
+
export declare const isTurnReason: (value: unknown) => value is "provider_error" | "intentional_cleanup" | "operator_cancel" | "task_removed" | "mission_abandoned" | "superseded" | "operator_update" | "refine_terminal" | "validation_terminal" | "hard_ceiling" | "turn_end" | "weak_end_confirmed" | "transcript_final" | "worker_reported" | "finalization_timeout_no_response" | "weak_end_liveness_unconfirmed" | "weak_end_probe_unobserved" | "report_correction_expired" | "session_error" | "provider_auth_failed" | "provider_billing_failed" | "provider_usage_limit_exceeded" | "provider_server_overloaded" | "reclaim_budget_exhausted" | "hollow_max_retries" | "migration_orphan" | "dispatch_refused_session_exited" | "dispatch_refused_no_target" | "dispatch_refused_unsupported_input" | "dispatch_failed" | "session_exit" | "session_exit_before_turn" | "session_dead" | "hollow_completion" | "assigned_stranded_dispatch_unconfirmed" | "delivered_not_consumed_redrive" | "delivered_no_turn_deadline";
|
|
383
387
|
export declare const isNotifyKind: (value: unknown) => value is "stopped" | "failed" | "no_progress" | "completed" | "cancelled" | "approval" | "choice" | "approval_resolved" | "candidate" | "progress" | "late_completion" | "mesh_event";
|
|
384
388
|
export declare const isTurnOutcome: (value: unknown) => value is "failed" | "completed" | "cancelled";
|
|
385
389
|
export declare const isCommitStrength: (value: unknown) => value is "operator" | "genuine" | "weak" | "tool_report";
|
package/package.json
CHANGED
package/src/mesh-vocabulary.ts
CHANGED
|
@@ -56,6 +56,14 @@ export type MeshSessionCleanupMode = typeof MESH_SESSION_CLEANUP_MODES[number]
|
|
|
56
56
|
export const WORKER_REPORT_OUTCOMES = ['completed', 'blocked', 'failed'] as const
|
|
57
57
|
export type WorkerReportOutcome = typeof WORKER_REPORT_OUTCOMES[number]
|
|
58
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Hard cap on a `report_completion` summary (characters, after trim). Over-limit
|
|
61
|
+
* summaries are REJECTED, never truncated. Declared once so the daemon validator
|
|
62
|
+
* and the mcp-server's pre-send check (which keeps an over-limit report out of the
|
|
63
|
+
* durable outbox) cannot drift apart.
|
|
64
|
+
*/
|
|
65
|
+
export const WORKER_REPORT_SUMMARY_MAX_CHARS = 8_000
|
|
66
|
+
|
|
59
67
|
/** Final branch state a worker reports (see coordinator convergence rules). */
|
|
60
68
|
export const WORKER_BRANCH_STATES = [
|
|
61
69
|
'merged_to_main',
|
package/src/node-facts.ts
CHANGED
|
@@ -126,6 +126,25 @@ export interface MeshNodeFactsProviderQuota {
|
|
|
126
126
|
* predating the field.
|
|
127
127
|
*/
|
|
128
128
|
fetchedAt?: number
|
|
129
|
+
/**
|
|
130
|
+
* Provenance of the RETAINED reading when `lastGoodWindows` is true —
|
|
131
|
+
* the source/plan/measurement time of the snapshot that produced the
|
|
132
|
+
* carried numbers, as opposed to the top-level `source`/`planType`,
|
|
133
|
+
* which describe the fresh failed attempt. See daemon-core
|
|
134
|
+
* `QuotaMetadata.lastGood`.
|
|
135
|
+
*/
|
|
136
|
+
lastGood?: {
|
|
137
|
+
measuredAt: number
|
|
138
|
+
source?: string
|
|
139
|
+
planType?: string | null
|
|
140
|
+
collectorScope?: string
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* `'background-collector'` when the snapshot came from a daemon-spawned
|
|
144
|
+
* probe rather than an executing CLI session; a failure with this scope
|
|
145
|
+
* is not evidence about a running session's sign-in.
|
|
146
|
+
*/
|
|
147
|
+
collectorScope?: string
|
|
129
148
|
[extra: string]: unknown
|
|
130
149
|
}
|
|
131
150
|
[extra: string]: unknown
|
package/src/quota-freshness.ts
CHANGED
|
@@ -50,9 +50,14 @@ function hasUsableWindow(window: { usedPercent?: unknown } | null | undefined):
|
|
|
50
50
|
return !!window && typeof window.usedPercent === 'number' && Number.isFinite(window.usedPercent)
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Does the snapshot carry any renderable number — session/weekly/monthly
|
|
55
|
+
* windows OR per-pool buckets? `monthly` counts on its own: cursor-cli reports
|
|
56
|
+
* ONLY that axis, and leaving it out made a retained cursor reading look
|
|
57
|
+
* numberless. A window without a finite `usedPercent` is unknown, not 0%.
|
|
58
|
+
*/
|
|
54
59
|
function hasReading(quota: MeshNodeFactsProviderQuota): boolean {
|
|
55
|
-
if (hasUsableWindow(quota.session) || hasUsableWindow(quota.weekly)) return true
|
|
60
|
+
if (hasUsableWindow(quota.session) || hasUsableWindow(quota.weekly) || hasUsableWindow(quota.monthly)) return true
|
|
56
61
|
return Array.isArray(quota.buckets) && quota.buckets.some((b) => !!b && typeof b.usedPercent === 'number' && Number.isFinite(b.usedPercent))
|
|
57
62
|
}
|
|
58
63
|
|
package/src/turn-evidence.ts
CHANGED
|
@@ -150,7 +150,7 @@ export const HOLD_REASONS = [
|
|
|
150
150
|
// — a turn_end commits the report (R9t), expiry commits it anyway (R13t) so
|
|
151
151
|
// a session whose FSM never shows the idle edge again does not wait for
|
|
152
152
|
// liveness / hard_ceiling.
|
|
153
|
-
'await_end',
|
|
153
|
+
'await_end', 'report_correction',
|
|
154
154
|
] as const
|
|
155
155
|
export type HoldReason = typeof HOLD_REASONS[number]
|
|
156
156
|
|
|
@@ -164,7 +164,7 @@ export type CommitStrength = typeof COMMIT_STRENGTHS[number]
|
|
|
164
164
|
export const TURN_REASONS = [
|
|
165
165
|
// commits
|
|
166
166
|
'turn_end', 'weak_end_confirmed', 'transcript_final', 'worker_reported',
|
|
167
|
-
'finalization_timeout_no_response', 'session_error', 'provider_auth_failed', 'provider_billing_failed', 'provider_usage_limit_exceeded', 'provider_server_overloaded', 'provider_error',
|
|
167
|
+
'finalization_timeout_no_response', 'weak_end_liveness_unconfirmed', 'weak_end_probe_unobserved', 'report_correction_expired', 'session_error', 'provider_auth_failed', 'provider_billing_failed', 'provider_usage_limit_exceeded', 'provider_server_overloaded', 'provider_error',
|
|
168
168
|
'operator_cancel', 'intentional_cleanup', 'task_removed', 'mission_abandoned', 'superseded',
|
|
169
169
|
'operator_update', 'refine_terminal', 'validation_terminal',
|
|
170
170
|
'hard_ceiling', 'reclaim_budget_exhausted', 'hollow_max_retries', 'migration_orphan',
|
|
@@ -273,7 +273,7 @@ export type TurnEvidenceBody =
|
|
|
273
273
|
live: LiveTurnPending; summary?: SummaryRef; messageAt?: number }
|
|
274
274
|
| { kind: 'transcript_activity'; newestActivityAt: number }
|
|
275
275
|
| { kind: 'no_progress'; stalledMs: number; observedStatus: NoProgressObservedStatus; finalAssistantPresent: boolean }
|
|
276
|
-
| { kind: 'liveness'; result: LivenessResult }
|
|
276
|
+
| { kind: 'liveness'; result: LivenessResult; probeStartedAtMs?: number }
|
|
277
277
|
| { kind: 'process_exit'; exitCode: number | null; providerFailure?: ProviderFailure }
|
|
278
278
|
| { kind: 'session_error'; reason: SessionErrorReason }
|
|
279
279
|
// ── worker MCP (F2) ──
|
|
@@ -284,6 +284,7 @@ export type TurnEvidenceBody =
|
|
|
284
284
|
*/
|
|
285
285
|
| { kind: 'worker_report'; outcome: WorkerReportOutcome; summary?: SummaryRef; hasHandoffNotes: boolean
|
|
286
286
|
branchState?: WorkerBranchState; touchedFileCount?: number }
|
|
287
|
+
| { kind: 'worker_report_correction_requested'; deliveryId?: string }
|
|
287
288
|
| { kind: 'worker_progress'; note?: SummaryRef }
|
|
288
289
|
// ── coordinator / operator ──
|
|
289
290
|
| { kind: 'git_side_effect'; dirty: boolean; commitsSinceDispatch: number; attributable: boolean }
|
|
@@ -366,13 +367,14 @@ export const TURN_EVIDENCE_FIELD_SPECS: TurnEvidenceFieldSpecs = {
|
|
|
366
367
|
},
|
|
367
368
|
transcript_activity: { newestActivityAt: ms },
|
|
368
369
|
no_progress: { stalledMs: ms, observedStatus: en(NO_PROGRESS_OBSERVED_STATUSES), finalAssistantPresent: bool },
|
|
369
|
-
liveness: { result: en(LIVENESS_RESULTS) },
|
|
370
|
+
liveness: { result: en(LIVENESS_RESULTS), probeStartedAtMs: msOpt },
|
|
370
371
|
process_exit: { exitCode: { t: 'int', nullable: true }, providerFailure: enOpt(PROVIDER_FAILURES) },
|
|
371
372
|
session_error: { reason: en(SESSION_ERROR_REASONS) },
|
|
372
373
|
worker_report: {
|
|
373
374
|
outcome: en(WORKER_REPORT_OUTCOMES), summary: { t: 'summary_ref', optional: true }, hasHandoffNotes: bool,
|
|
374
375
|
branchState: enOpt(WORKER_BRANCH_STATES), touchedFileCount: intOpt,
|
|
375
376
|
},
|
|
377
|
+
worker_report_correction_requested: { deliveryId: { t: 'id', optional: true } },
|
|
376
378
|
worker_progress: { note: { t: 'summary_ref', optional: true } },
|
|
377
379
|
git_side_effect: { dirty: bool, commitsSinceDispatch: { t: 'int' }, attributable: bool },
|
|
378
380
|
cancel: { reason: en(CANCEL_REASONS) },
|