@adhdev/mesh-shared 1.0.82-rc.2 → 1.0.82-rc.20
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/assistant-protocol.d.ts +9 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +230 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +214 -18
- package/dist/index.mjs.map +1 -1
- package/dist/launch-defaults.d.ts +194 -0
- package/dist/mesh-tool-names.d.ts +2 -2
- package/dist/mesh-vocabulary.d.ts +8 -1
- package/dist/node-facts.d.ts +40 -0
- package/dist/path-ownership.d.ts +1 -1
- package/dist/provider-approval.d.ts +36 -0
- package/dist/provider-question.d.ts +19 -0
- package/dist/quota-freshness.d.ts +65 -0
- package/dist/turn-evidence.d.ts +20 -8
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/assistant-protocol.ts +22 -1
- package/src/index.ts +4 -0
- package/src/keyed-doc-delta.ts +9 -1
- package/src/launch-defaults.ts +168 -0
- package/src/mesh-tool-names.ts +1 -0
- package/src/mesh-vocabulary.ts +8 -0
- package/src/node-facts.ts +35 -0
- package/src/path-ownership.ts +4 -6
- package/src/provider-approval.ts +59 -0
- package/src/provider-question.ts +31 -0
- package/src/quota-freshness.ts +136 -0
- package/src/turn-evidence.ts +20 -17
- package/src/types.ts +1 -0
package/src/turn-evidence.ts
CHANGED
|
@@ -83,9 +83,9 @@ export type SessionReboundReason = typeof SESSION_REBOUND_REASONS[number]
|
|
|
83
83
|
|
|
84
84
|
export const SUSPENSION_MODALS = ['approval', 'choice'] as const
|
|
85
85
|
export type SuspensionModal = typeof SUSPENSION_MODALS[number]
|
|
86
|
-
export const SUSPENSION_RESOLUTIONS = ['approved', 'rejected', 'answered'] as const
|
|
86
|
+
export const SUSPENSION_RESOLUTIONS = ['approved', 'rejected', 'answered', 'dismissed'] as const
|
|
87
87
|
export type SuspensionResolution = typeof SUSPENSION_RESOLUTIONS[number]
|
|
88
|
-
export const SUSPENSION_RESOLUTION_VIAS = ['modal_button', 'auto_approve', 'prompt_answer'] as const
|
|
88
|
+
export const SUSPENSION_RESOLUTION_VIAS = ['modal_button', 'auto_approve', 'prompt_answer', 'modal_disappeared'] as const
|
|
89
89
|
export type SuspensionResolutionVia = typeof SUSPENSION_RESOLUTION_VIAS[number]
|
|
90
90
|
|
|
91
91
|
export const TURN_END_STRENGTHS = ['genuine', 'weak'] as const
|
|
@@ -97,13 +97,13 @@ export const TURN_END_BLOCK_REASONS = [
|
|
|
97
97
|
] as const
|
|
98
98
|
export type TurnEndBlockReason = typeof TURN_END_BLOCK_REASONS[number]
|
|
99
99
|
|
|
100
|
-
export const NATIVE_TURN_OUTCOMES = ['completed', 'aborted'] as const
|
|
100
|
+
export const NATIVE_TURN_OUTCOMES = ['completed', 'aborted', 'failed'] as const
|
|
101
101
|
export type NativeTurnOutcome = typeof NATIVE_TURN_OUTCOMES[number]
|
|
102
102
|
|
|
103
103
|
export const LIVENESS_RESULTS = ['alive', 'unknown', 'read_failed', 'dead'] as const
|
|
104
104
|
export type LivenessResult = typeof LIVENESS_RESULTS[number]
|
|
105
105
|
|
|
106
|
-
export const PROVIDER_FAILURES = ['auth_failed', 'billing_failed'] as const
|
|
106
|
+
export const PROVIDER_FAILURES = ['auth_failed', 'billing_failed', 'usage_limit_exceeded', 'server_overloaded', 'provider_error'] as const
|
|
107
107
|
export type ProviderFailure = typeof PROVIDER_FAILURES[number]
|
|
108
108
|
|
|
109
109
|
/**
|
|
@@ -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',
|
|
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',
|
|
@@ -207,7 +207,7 @@ export interface LiveTurnPending { modal: boolean; adapterPending: boolean; trai
|
|
|
207
207
|
/** Structural copy of daemon-core's `CoordinatorIdentity` (this package cannot import daemon-core). */
|
|
208
208
|
export interface EvidenceCoordinatorIdentity { daemonId: string; coordinatorRunId: string; sessionId?: string }
|
|
209
209
|
|
|
210
|
-
export interface NativeTurnMarkerRef { outcome: NativeTurnOutcome; turnId?: string }
|
|
210
|
+
export interface NativeTurnMarkerRef { outcome: NativeTurnOutcome; turnId?: string; receivedAt?: number; startedAt?: number; errorAt?: number }
|
|
211
211
|
|
|
212
212
|
export interface EvidenceEnvelope {
|
|
213
213
|
/** Stable id of this observation; dedupe key across republish/replication. */
|
|
@@ -250,10 +250,10 @@ export type TurnEvidenceBody =
|
|
|
250
250
|
| { kind: 'session_rebound'; toSessionId: string; reason: SessionReboundReason }
|
|
251
251
|
// ── worker turn lifecycle ──
|
|
252
252
|
| { kind: 'turn_started'; retro: boolean }
|
|
253
|
-
| { kind: 'suspension'; modal: SuspensionModal; modalKey?: string }
|
|
254
|
-
| { kind: 'suspension_resolved'; resolution: SuspensionResolution; via: SuspensionResolutionVia }
|
|
253
|
+
| { kind: 'suspension'; modal: SuspensionModal; modalKey?: string; providerSetup?: boolean; clockUnknown?: boolean }
|
|
254
|
+
| { kind: 'suspension_resolved'; resolution: SuspensionResolution; via: SuspensionResolutionVia; modalKey?: string }
|
|
255
255
|
| { kind: 'turn_end'; strength: TurnEndStrength; afterFinalizationTimeout?: boolean; hollow?: boolean; summary?: SummaryRef
|
|
256
|
-
blockReason?: TurnEndBlockReason; releasedByHardCap?: boolean; nativeOutcome?: NativeTurnOutcome; live?: LiveTurnPending
|
|
256
|
+
blockReason?: TurnEndBlockReason; releasedByHardCap?: boolean; nativeOutcome?: NativeTurnOutcome; nativeMarker?: NativeTurnMarkerRef; live?: LiveTurnPending
|
|
257
257
|
/**
|
|
258
258
|
* Stamped (true only) by the WORKER's daemon when the session holds a live
|
|
259
259
|
* worker-MCP session bind, i.e. the worker can call report_completion. The
|
|
@@ -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 }
|
|
@@ -352,13 +353,13 @@ export const TURN_EVIDENCE_FIELD_SPECS: TurnEvidenceFieldSpecs = {
|
|
|
352
353
|
duplicate_dispatch_refusal: { holderSessionId: id, holderAttemptId: idOpt },
|
|
353
354
|
session_rebound: { toSessionId: id, reason: en(SESSION_REBOUND_REASONS) },
|
|
354
355
|
turn_started: { retro: bool },
|
|
355
|
-
suspension: { modal: en(SUSPENSION_MODALS), modalKey: idOpt },
|
|
356
|
-
suspension_resolved: { resolution: en(SUSPENSION_RESOLUTIONS), via: en(SUSPENSION_RESOLUTION_VIAS) },
|
|
356
|
+
suspension: { modal: en(SUSPENSION_MODALS), modalKey: idOpt, providerSetup: boolOpt, clockUnknown: boolOpt },
|
|
357
|
+
suspension_resolved: { resolution: en(SUSPENSION_RESOLUTIONS), via: en(SUSPENSION_RESOLUTION_VIAS), modalKey: idOpt },
|
|
357
358
|
turn_end: {
|
|
358
359
|
strength: en(TURN_END_STRENGTHS), afterFinalizationTimeout: boolOpt, hollow: boolOpt,
|
|
359
360
|
summary: { t: 'summary_ref', optional: true }, blockReason: enOpt(TURN_END_BLOCK_REASONS),
|
|
360
361
|
releasedByHardCap: boolOpt, nativeOutcome: enOpt(NATIVE_TURN_OUTCOMES), live: { t: 'live', optional: true },
|
|
361
|
-
reportExpected: boolOpt, providerFailure: enOpt(PROVIDER_FAILURES),
|
|
362
|
+
nativeMarker: { t: 'native_marker', optional: true }, reportExpected: boolOpt, providerFailure: enOpt(PROVIDER_FAILURES),
|
|
362
363
|
},
|
|
363
364
|
transcript_final: {
|
|
364
365
|
selfAttributing: bool, nativeRead: bool, nativeMarker: { t: 'native_marker', optional: true },
|
|
@@ -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) },
|
|
@@ -440,11 +442,12 @@ function isLiveTurnPending(value: unknown): value is LiveTurnPending {
|
|
|
440
442
|
&& (value.newestActivityAt === undefined || isFiniteNumber(value.newestActivityAt))
|
|
441
443
|
}
|
|
442
444
|
|
|
443
|
-
function isNativeMarkerRef(value: unknown): value is NativeTurnMarkerRef {
|
|
445
|
+
export function isNativeMarkerRef(value: unknown): value is NativeTurnMarkerRef {
|
|
444
446
|
return isRecord(value)
|
|
445
|
-
&& hasOnlyKeys(value, ['outcome', 'turnId'])
|
|
447
|
+
&& hasOnlyKeys(value, ['outcome', 'turnId', 'receivedAt', 'startedAt', 'errorAt'])
|
|
446
448
|
&& (NATIVE_TURN_OUTCOMES as readonly string[]).includes(value.outcome as string)
|
|
447
449
|
&& (value.turnId === undefined || isEvidenceIdentifier(value.turnId))
|
|
450
|
+
&& ['receivedAt', 'startedAt', 'errorAt'].every((key) => value[key] === undefined || isFiniteNumber(value[key]))
|
|
448
451
|
}
|
|
449
452
|
|
|
450
453
|
function isCoordinatorIdentity(value: unknown): value is EvidenceCoordinatorIdentity {
|
package/src/types.ts
CHANGED