@muse-code/sdk 1.4.10 → 1.4.12
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/README.md +39 -1
- package/dist/src/facade/approval.d.ts +36 -16
- package/dist/src/facade/approval.js +45 -14
- package/dist/src/facade/client.d.ts +17 -1
- package/dist/src/facade/client.js +40 -5
- package/dist/src/facade/gap-fill.js +7 -2
- package/dist/src/facade/session.d.ts +12 -2
- package/dist/src/facade/session.js +86 -4
- package/dist/src/fingerprint.d.ts +1 -1
- package/dist/src/fingerprint.js +1 -1
- package/dist/src/fold/session-fold.d.ts +37 -4
- package/dist/src/fold/session-fold.js +18 -0
- package/dist/src/msp.d.ts +454 -52
- package/package.json +1 -1
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* unrecognized `TurnTerminal` is kept verbatim, and a second resolution never
|
|
28
28
|
* displaces the first durable one.
|
|
29
29
|
*/
|
|
30
|
-
import type { ApprovalRequestParams, ApprovalResolvedParams, ApprovalUpdatedParams, Item, ItemCompletedParams, ItemDeltaParams, ItemStartedParams, ItemUpdatedParams, MspNotification, SessionApprovalModeChangedParams, SessionBranchChangedParams, SessionContextUsageParams, SessionGoalChangedParams, SessionModelChangedParams, SessionModelRouteUnservedParams, SessionNameChangedParams, SessionReasoningEffortChangedParams, SessionTodoListChangedParams, SessionTokenUsageParams, TurnCompletedParams, TurnError, TurnForegroundCompletedParams, TurnModelRetryScheduledParams, TurnRetractedParams, TurnRetryScheduledParams, TurnStartedParams, TurnTerminal, TurnUnqueuedParams, UserInputRequestParams, UserInputSettledParams, ViewGapParams } from "../msp.js";
|
|
30
|
+
import type { ApprovalRequestParams, ApprovalResolvedParams, ApprovalUpdatedParams, Item, ItemCompletedParams, ItemDeltaParams, ItemStartedParams, ItemUpdatedParams, MonitorInboxItemAdmittedParams, MonitorInboxItemDrainedParams, MonitorInboxItemVoidedParams, MspNotification, SessionApprovalModeChangedParams, SessionBranchChangedParams, SessionContextUsageParams, SessionGoalChangedParams, SessionModelChangedParams, SessionModelRouteUnservedParams, SessionNameChangedParams, SessionReasoningEffortChangedParams, SessionTodoListChangedParams, SessionTokenUsageParams, TurnCompletedParams, TurnError, TurnForegroundCompletedParams, TurnModelRetryScheduledParams, TurnRetractedParams, TurnRetryScheduledParams, TurnStartedParams, TurnTerminal, TurnUnqueuedParams, UserInputRequestParams, UserInputSettledParams, ViewGapParams } from "../msp.js";
|
|
31
31
|
import type { DeltaApplyOutcome, ItemApplyOutcome, TerminalUnknownItemAnnotation } from "./item-store.js";
|
|
32
32
|
import type { StateApplyOutcome, StateValue } from "./state-store.js";
|
|
33
33
|
/** The session-state families, each keyed in the store by its method name. */
|
|
@@ -140,6 +140,23 @@ export type ViewEvent = {
|
|
|
140
140
|
| {
|
|
141
141
|
readonly method: "view/gap";
|
|
142
142
|
readonly params: ViewGapParams;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The monitor-inbox trio: per-monitor inbox admissions, drains, and
|
|
146
|
+
* wake-missed voids. A NOTICE, never sticky state — the SDK holds no
|
|
147
|
+
* inbox store, so the per-task projection (tails, badges, counts,
|
|
148
|
+
* retirement) is consumer-folded from the facts on the outcome. The
|
|
149
|
+
* params ride the outcome verbatim for the consumer to fold once.
|
|
150
|
+
*/
|
|
151
|
+
| {
|
|
152
|
+
readonly method: "monitor/inboxItemAdmitted";
|
|
153
|
+
readonly params: MonitorInboxItemAdmittedParams;
|
|
154
|
+
} | {
|
|
155
|
+
readonly method: "monitor/inboxItemDrained";
|
|
156
|
+
readonly params: MonitorInboxItemDrainedParams;
|
|
157
|
+
} | {
|
|
158
|
+
readonly method: "monitor/inboxItemVoided";
|
|
159
|
+
readonly params: MonitorInboxItemVoidedParams;
|
|
143
160
|
};
|
|
144
161
|
/**
|
|
145
162
|
* Compile-time coverage: every `MspNotification` except the handshake's
|
|
@@ -178,7 +195,7 @@ export type ViewEvent = {
|
|
|
178
195
|
type AssertNever<T extends never> = T;
|
|
179
196
|
type LiveHostStateProjection = "skill/changed" | "usage/changed" | "session/statusChanged" | "session/listChanged" | "plugin/changed" | "plugin/marketplaceChanged" | "computerUseSetup/changed";
|
|
180
197
|
type SessionLifecycleBroadcast = "session/started" | "session/closed";
|
|
181
|
-
type NonFoldNotification = "initialized" | "userInput/engaged" | "session/viewHealthChanged" | "recap/completed" | SessionLifecycleBroadcast | LiveHostStateProjection;
|
|
198
|
+
type NonFoldNotification = "initialized" | "userInput/engaged" | "session/viewHealthChanged" | "session/leaveCompleted" | "recap/completed" | SessionLifecycleBroadcast | LiveHostStateProjection;
|
|
182
199
|
type UnfoldedViewNotification = Exclude<MspNotification, NonFoldNotification | ViewEvent["method"]>;
|
|
183
200
|
export type EveryViewNotificationIsFolded = AssertNever<UnfoldedViewNotification>;
|
|
184
201
|
/**
|
|
@@ -224,7 +241,7 @@ export type SessionStateMethod = ViewEvent["method"] & `session/${string}`;
|
|
|
224
241
|
* and could never match exhaustively. A future arm that starts dropping
|
|
225
242
|
* widens this deliberately (PR #23087 review round).
|
|
226
243
|
*/
|
|
227
|
-
export type StaleDroppableMethod = "turn/started" | "turn/completed" | "turn/retracted" | "turn/foregroundCompleted" | "turn/retryScheduled" | "turn/modelRetryScheduled" | "approval/requested" | "approval/updated" | "userInput/requested";
|
|
244
|
+
export type StaleDroppableMethod = "turn/started" | "turn/completed" | "turn/retracted" | "turn/foregroundCompleted" | "turn/retryScheduled" | "turn/modelRetryScheduled" | "approval/requested" | "approval/updated" | "userInput/requested" | "view/gap";
|
|
228
245
|
/**
|
|
229
246
|
* The `NoStaleViewArm` sibling for the union above: these are hand-typed
|
|
230
247
|
* literals, so without this pin a typo'd or later-retired member compiles
|
|
@@ -353,6 +370,17 @@ export type FoldOutcome = {
|
|
|
353
370
|
| {
|
|
354
371
|
readonly kind: "modelRouteUnserved";
|
|
355
372
|
readonly params: SessionModelRouteUnservedParams;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* One monitor-inbox trio fact, surfaced verbatim (see the `ViewEvent`
|
|
376
|
+
* arms above): the method names which of the three arrived, and the
|
|
377
|
+
* params carry that event's fact members for the consumer's own fold.
|
|
378
|
+
* Fresh wire objects, never store handles, so no D-14 seal applies.
|
|
379
|
+
*/
|
|
380
|
+
| {
|
|
381
|
+
readonly kind: "monitorInbox";
|
|
382
|
+
readonly method: "monitor/inboxItemAdmitted" | "monitor/inboxItemDrained" | "monitor/inboxItemVoided";
|
|
383
|
+
readonly params: MonitorInboxItemAdmittedParams | MonitorInboxItemDrainedParams | MonitorInboxItemVoidedParams;
|
|
356
384
|
} | {
|
|
357
385
|
readonly kind: "ignoredUnrecognizedMethod";
|
|
358
386
|
readonly method: string;
|
|
@@ -379,7 +407,9 @@ export type FoldOutcome = {
|
|
|
379
407
|
* not seen; an `approval/updated` for an approval it never saw
|
|
380
408
|
* requested (or whose entry a resolution already deleted); or a
|
|
381
409
|
* redelivered `approval/requested` / `userInput/requested` for an
|
|
382
|
-
* approval/prompt that already has its durable terminal
|
|
410
|
+
* approval/prompt that already has its durable terminal; or a
|
|
411
|
+
* `view/gap` whose `next` an earlier frame already named while the
|
|
412
|
+
* hole is open (`id` is that `next`, #62032). Truthful by
|
|
383
413
|
* contract: a "pending" kind here would make a renderer show an entry
|
|
384
414
|
* the fold does not hold (PR #23087 review round).
|
|
385
415
|
*
|
|
@@ -494,6 +524,9 @@ export declare class SessionFold {
|
|
|
494
524
|
* own D-16487-1 bracket rule. A recovery walks `(after, next)` and calls
|
|
495
525
|
* `gapFilled(next)` with the target it actually reached, so a hole that grew
|
|
496
526
|
* while the walk was in flight cannot be reported filled.
|
|
527
|
+
*
|
|
528
|
+
* A later frame moves `next` to its own, but one repeating a `next` already
|
|
529
|
+
* named while the hole is open is stale and changes nothing (#62032).
|
|
497
530
|
*/
|
|
498
531
|
get pendingGap(): DeepReadonly<ViewGapParams> | undefined;
|
|
499
532
|
/**
|
|
@@ -78,6 +78,8 @@ export class SessionFold {
|
|
|
78
78
|
#settledUserInputs = new Map();
|
|
79
79
|
#activeTurnId;
|
|
80
80
|
#pendingGap;
|
|
81
|
+
/** Every `next` a `view/gap` named while `#pendingGap` is open; `gapFilled` empties it. */
|
|
82
|
+
#gapTargets = new Set();
|
|
81
83
|
/** The turn currently running, if one is. */
|
|
82
84
|
get activeTurnId() {
|
|
83
85
|
return this.#activeTurnId;
|
|
@@ -91,6 +93,9 @@ export class SessionFold {
|
|
|
91
93
|
* own D-16487-1 bracket rule. A recovery walks `(after, next)` and calls
|
|
92
94
|
* `gapFilled(next)` with the target it actually reached, so a hole that grew
|
|
93
95
|
* while the walk was in flight cannot be reported filled.
|
|
96
|
+
*
|
|
97
|
+
* A later frame moves `next` to its own, but one repeating a `next` already
|
|
98
|
+
* named while the hole is open is stale and changes nothing (#62032).
|
|
94
99
|
*/
|
|
95
100
|
get pendingGap() {
|
|
96
101
|
return this.#pendingGap;
|
|
@@ -123,6 +128,7 @@ export class SessionFold {
|
|
|
123
128
|
if (this.#pendingGap?.next !== next)
|
|
124
129
|
return false;
|
|
125
130
|
this.#pendingGap = undefined;
|
|
131
|
+
this.#gapTargets.clear();
|
|
126
132
|
return true;
|
|
127
133
|
}
|
|
128
134
|
apply(event) {
|
|
@@ -181,6 +187,10 @@ export class SessionFold {
|
|
|
181
187
|
return this.#userInputSettled(typed.params);
|
|
182
188
|
case "view/gap":
|
|
183
189
|
return this.#deliveryGap(typed.params);
|
|
190
|
+
case "monitor/inboxItemAdmitted":
|
|
191
|
+
case "monitor/inboxItemDrained":
|
|
192
|
+
case "monitor/inboxItemVoided":
|
|
193
|
+
return { kind: "monitorInbox", method: typed.method, params: typed.params };
|
|
184
194
|
case "session/modelRouteUnserved":
|
|
185
195
|
return { kind: "modelRouteUnserved", params: typed.params };
|
|
186
196
|
case "session/modelChanged":
|
|
@@ -387,6 +397,14 @@ export class SessionFold {
|
|
|
387
397
|
}
|
|
388
398
|
// ---- the delivery-plane marker ------------------------------------------
|
|
389
399
|
#deliveryGap(params) {
|
|
400
|
+
// A `next` already named while this hole is open is a stale repeat of an
|
|
401
|
+
// earlier frame: taking it would move the target back, so a walk would
|
|
402
|
+
// stop short and the fold report current over an unfilled hole. It
|
|
403
|
+
// changes nothing, as in the Rust SDK's gap walk (ADR 42116 D1, #62032).
|
|
404
|
+
if (this.#gapTargets.has(params.next)) {
|
|
405
|
+
return { id: params.next, kind: "ignoredStaleFrame", method: "view/gap" };
|
|
406
|
+
}
|
|
407
|
+
this.#gapTargets.add(params.next);
|
|
390
408
|
// Coalesced on the FIRST `after`: a second overflow while the first hole
|
|
391
409
|
// is still open extends the range rather than replacing it. Replacing it
|
|
392
410
|
// would move the lower bound past events that were never delivered, so a
|