@muse-code/sdk 0.1.1 → 1.3.0
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 +56 -253
- package/dist/src/facade/approval.d.ts +21 -1
- package/dist/src/facade/approval.js +97 -1
- package/dist/src/facade/client.d.ts +3 -4
- package/dist/src/facade/client.js +7 -3
- package/dist/src/facade/session.js +26 -12
- package/dist/src/fingerprint.d.ts +1 -1
- package/dist/src/fingerprint.js +1 -1
- package/dist/src/fold/session-fold.d.ts +74 -12
- package/dist/src/fold/session-fold.js +6 -2
- package/dist/src/index.d.ts +8 -1
- package/dist/src/msp.d.ts +477 -13
- package/package.json +9 -1
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
* unrecognized `TurnTerminal` is kept verbatim, and a second resolution never
|
|
27
27
|
* displaces the first durable one.
|
|
28
28
|
*/
|
|
29
|
-
import type { ApprovalRequestParams, ApprovalResolvedParams, ApprovalUpdatedParams, Item, ItemCompletedParams, ItemDeltaParams, ItemStartedParams, ItemUpdatedParams, MspNotification, SessionApprovalModeChangedParams, SessionBranchChangedParams, SessionContextUsageParams, SessionGoalChangedParams, SessionModelChangedParams, SessionTodoListChangedParams, SessionTokenUsageParams, TurnCompletedParams, TurnError, TurnRetractedParams, TurnRetryScheduledParams, TurnStartedParams, TurnTerminal, TurnUnqueuedParams, UserInputRequestParams, UserInputSettledParams, ViewGapParams } from "../msp.js";
|
|
29
|
+
import type { ApprovalRequestParams, ApprovalResolvedParams, ApprovalUpdatedParams, Item, ItemCompletedParams, ItemDeltaParams, ItemStartedParams, ItemUpdatedParams, MspNotification, SessionApprovalModeChangedParams, SessionBranchChangedParams, SessionContextUsageParams, SessionGoalChangedParams, SessionModelChangedParams, SessionModelRouteUnservedParams, SessionNameChangedParams, SessionReasoningEffortChangedParams, SessionTodoListChangedParams, SessionTokenUsageParams, TurnCompletedParams, TurnError, TurnRetractedParams, TurnRetryScheduledParams, TurnStartedParams, TurnTerminal, TurnUnqueuedParams, UserInputRequestParams, UserInputSettledParams, ViewGapParams } from "../msp.js";
|
|
30
30
|
import type { DeltaApplyOutcome, ItemApplyOutcome, TerminalUnknownItemAnnotation } from "./item-store.js";
|
|
31
31
|
import type { StateApplyOutcome, StateValue } from "./state-store.js";
|
|
32
32
|
/** The session-state families, each keyed in the store by its method name. */
|
|
33
|
-
export type SessionStateParams = SessionApprovalModeChangedParams | SessionBranchChangedParams | SessionContextUsageParams | SessionGoalChangedParams | SessionModelChangedParams | SessionTodoListChangedParams | SessionTokenUsageParams;
|
|
33
|
+
export type SessionStateParams = SessionApprovalModeChangedParams | SessionBranchChangedParams | SessionContextUsageParams | SessionGoalChangedParams | SessionModelChangedParams | SessionNameChangedParams | SessionReasoningEffortChangedParams | SessionTodoListChangedParams | SessionTokenUsageParams;
|
|
34
34
|
/** A view notification, paired with the generated params object it carries. */
|
|
35
35
|
export type ViewEvent = {
|
|
36
36
|
readonly method: "item/started";
|
|
@@ -77,6 +77,9 @@ export type ViewEvent = {
|
|
|
77
77
|
} | {
|
|
78
78
|
readonly method: "session/modelChanged";
|
|
79
79
|
readonly params: SessionModelChangedParams;
|
|
80
|
+
} | {
|
|
81
|
+
readonly method: "session/reasoningEffortChanged";
|
|
82
|
+
readonly params: SessionReasoningEffortChangedParams;
|
|
80
83
|
} | {
|
|
81
84
|
readonly method: "session/goalChanged";
|
|
82
85
|
readonly params: SessionGoalChangedParams;
|
|
@@ -95,6 +98,17 @@ export type ViewEvent = {
|
|
|
95
98
|
} | {
|
|
96
99
|
readonly method: "session/approvalModeChanged";
|
|
97
100
|
readonly params: SessionApprovalModeChangedParams;
|
|
101
|
+
} | {
|
|
102
|
+
readonly method: "session/nameChanged";
|
|
103
|
+
readonly params: SessionNameChangedParams;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The one-shot login-swap route disclosure (#25603, tdd SS4.6.8): routed to
|
|
107
|
+
* its own non-storing outcome — a notice, never sticky session state.
|
|
108
|
+
*/
|
|
109
|
+
| {
|
|
110
|
+
readonly method: "session/modelRouteUnserved";
|
|
111
|
+
readonly params: SessionModelRouteUnservedParams;
|
|
98
112
|
}
|
|
99
113
|
/**
|
|
100
114
|
* The delivery-plane marker (tdd SS4.8). A `ViewEvent` since spec 14990
|
|
@@ -119,16 +133,34 @@ export type ViewEvent = {
|
|
|
119
133
|
};
|
|
120
134
|
/**
|
|
121
135
|
* Compile-time coverage: every `MspNotification` except the handshake's
|
|
122
|
-
* `initialized` is a fold input. A #206
|
|
123
|
-
* notification fails HERE rather than being
|
|
136
|
+
* `initialized` and the live host-state projections is a fold input. A #206
|
|
137
|
+
* enrollment that adds a view notification fails HERE rather than being
|
|
138
|
+
* silently ignored at runtime.
|
|
124
139
|
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
* removed by spec 14990 T032 when the marker became the `ViewEvent`
|
|
140
|
+
* The exclusions, each excluded because it is NOT a view event:
|
|
141
|
+
* - `initialized` is a HANDSHAKE notification, answered by `MspHandshake`
|
|
142
|
+
* before this fold exists. (The `view/gap` exclusion D-24021-1 recorded
|
|
143
|
+
* was removed by spec 14990 T032 when the marker became the `ViewEvent`
|
|
144
|
+
* arm above.)
|
|
145
|
+
* - `session/viewHealthChanged` (#32557, ADR 32557) is a COMMAND-PLANE
|
|
146
|
+
* health push, not a view-fold event: it reports that the live view
|
|
147
|
+
* stream stopped, so it carries no cursor and folds into no transcript
|
|
148
|
+
* state. A consumer handles it out of band (mark the session view
|
|
149
|
+
* unhealthy), never through this fold.
|
|
150
|
+
* - `usage/changed` (ADR 32563 D3, tdd SS3.23) is a live HOST-STATE push
|
|
151
|
+
* outside the view altitude: no `viewCursor`, no `sourceRange`, nothing
|
|
152
|
+
* seeded into either store; it reaches consumers through the ordinary
|
|
153
|
+
* notification hook, not this fold.
|
|
154
|
+
* - `skill/changed` (ADR 32471 D3, tdd SS3.22.2) is a live host-state
|
|
155
|
+
* projection carrying `sessionId` only — no `viewCursor`, no
|
|
156
|
+
* `sourceRange`, nothing durable to fold. The SDK consumer's reaction is
|
|
157
|
+
* an ACTION (re-issue `skill/list`), not fold state, so it rides the
|
|
158
|
+
* client's notification callback rather than this fold.
|
|
129
159
|
*/
|
|
130
160
|
type AssertNever<T extends never> = T;
|
|
131
|
-
type
|
|
161
|
+
type LiveHostStateProjection = "skill/changed" | "usage/changed" | "session/statusChanged" | "session/listChanged";
|
|
162
|
+
type NonFoldNotification = "initialized" | "session/viewHealthChanged" | LiveHostStateProjection;
|
|
163
|
+
type UnfoldedViewNotification = Exclude<MspNotification, NonFoldNotification | ViewEvent["method"]>;
|
|
132
164
|
export type EveryViewNotificationIsFolded = AssertNever<UnfoldedViewNotification>;
|
|
133
165
|
/**
|
|
134
166
|
* The reverse direction: every `ViewEvent` arm names a REAL generated
|
|
@@ -145,7 +177,7 @@ export type NoStaleViewArm = AssertNever<StaleViewArm>;
|
|
|
145
177
|
* vocabulary (the PR #23087 rule, applied to this file's only other
|
|
146
178
|
* hand-typed method set).
|
|
147
179
|
*/
|
|
148
|
-
type StaleExclusion = Exclude<
|
|
180
|
+
type StaleExclusion = Exclude<NonFoldNotification, MspNotification>;
|
|
149
181
|
export type NoStaleExclusion = AssertNever<StaleExclusion>;
|
|
150
182
|
/**
|
|
151
183
|
* A recursively read-only view of a value.
|
|
@@ -215,12 +247,32 @@ export type FoldOutcome = {
|
|
|
215
247
|
readonly kind: "turn";
|
|
216
248
|
readonly turnId: string;
|
|
217
249
|
readonly state: TurnState;
|
|
218
|
-
}
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* `outcome` is sealed for the same reason every getter is (D-14): the
|
|
253
|
+
* store hands back the very object it just stored, so an unsealed
|
|
254
|
+
* `current` is a live handle into fold state — `out.outcome.current
|
|
255
|
+
* .modelId = "..."` would mutate the fold with no cast and break INV-002
|
|
256
|
+
* replay equality. This and `approvalPending.requested` (#36949) are the
|
|
257
|
+
* two `FoldOutcome` arms that carry a params object; every other arm
|
|
258
|
+
* carries only ids, numbers, and booleans, which is why D-14 originally
|
|
259
|
+
* missed this one (#23556 item 2). Both seals are pinned by
|
|
260
|
+
* `@ts-expect-error` write probes in `session-fold.test.ts`.
|
|
261
|
+
*/
|
|
262
|
+
| {
|
|
219
263
|
readonly kind: "sessionState";
|
|
220
|
-
readonly outcome: StateApplyOutcome<SessionStateParams
|
|
264
|
+
readonly outcome: DeepReadonly<StateApplyOutcome<SessionStateParams>>;
|
|
221
265
|
} | {
|
|
222
266
|
readonly kind: "approvalPending";
|
|
223
267
|
readonly approvalId: string;
|
|
268
|
+
/**
|
|
269
|
+
* The pending entry's retained request (#36949): the facade's
|
|
270
|
+
* `approval/updated` re-route needs the request-shape members, and
|
|
271
|
+
* carrying them on the verdict itself makes "the fold vouched for this
|
|
272
|
+
* entry" and "here is that entry" one fact instead of a re-lookup a
|
|
273
|
+
* contract drift could silently miss.
|
|
274
|
+
*/
|
|
275
|
+
readonly requested: DeepReadonly<ApprovalRequestParams>;
|
|
224
276
|
} | {
|
|
225
277
|
readonly kind: "approvalResolved";
|
|
226
278
|
readonly approvalId: string;
|
|
@@ -248,6 +300,16 @@ export type FoldOutcome = {
|
|
|
248
300
|
readonly kind: "deliveryGap";
|
|
249
301
|
readonly after: string;
|
|
250
302
|
readonly next: string;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* The one-shot login-swap route disclosure (#25603, tdd SS4.6.8): a NOTICE,
|
|
306
|
+
* not a state family — it seeds no store (a repair via `session/setModel`
|
|
307
|
+
* would never clear a stored copy, and a snapshot reseed would wipe it), so
|
|
308
|
+
* the params ride the outcome verbatim for the consumer to render once.
|
|
309
|
+
*/
|
|
310
|
+
| {
|
|
311
|
+
readonly kind: "modelRouteUnserved";
|
|
312
|
+
readonly params: SessionModelRouteUnservedParams;
|
|
251
313
|
} | {
|
|
252
314
|
readonly kind: "ignoredUnrecognizedMethod";
|
|
253
315
|
readonly method: string;
|
|
@@ -174,13 +174,17 @@ export class SessionFold {
|
|
|
174
174
|
return this.#userInputSettled(typed.params);
|
|
175
175
|
case "view/gap":
|
|
176
176
|
return this.#deliveryGap(typed.params);
|
|
177
|
+
case "session/modelRouteUnserved":
|
|
178
|
+
return { kind: "modelRouteUnserved", params: typed.params };
|
|
177
179
|
case "session/modelChanged":
|
|
180
|
+
case "session/reasoningEffortChanged":
|
|
178
181
|
case "session/goalChanged":
|
|
179
182
|
case "session/todoListChanged":
|
|
180
183
|
case "session/branchChanged":
|
|
181
184
|
case "session/tokenUsage":
|
|
182
185
|
case "session/contextUsage":
|
|
183
186
|
case "session/approvalModeChanged":
|
|
187
|
+
case "session/nameChanged":
|
|
184
188
|
return {
|
|
185
189
|
kind: "sessionState",
|
|
186
190
|
outcome: this.#sessionStateStore.apply(typed.method, typed.params, typed.params.viewCursor),
|
|
@@ -352,7 +356,7 @@ export class SessionFold {
|
|
|
352
356
|
// the new request with the OLD update would show stale stage/choices and
|
|
353
357
|
// a decide against them bounces -32053.
|
|
354
358
|
this.#pendingApprovals.set(params.approvalId, { requested: params });
|
|
355
|
-
return { kind: "approvalPending", approvalId: params.approvalId };
|
|
359
|
+
return { kind: "approvalPending", approvalId: params.approvalId, requested: params };
|
|
356
360
|
}
|
|
357
361
|
#approvalUpdated(params) {
|
|
358
362
|
// An update REFRESHES a pending view; it never opens one. An update for an
|
|
@@ -370,7 +374,7 @@ export class SessionFold {
|
|
|
370
374
|
return { kind: "ignoredStaleFrame", method: "approval/updated", id: params.approvalId };
|
|
371
375
|
}
|
|
372
376
|
held.latestUpdate = params;
|
|
373
|
-
return { kind: "approvalPending", approvalId: params.approvalId };
|
|
377
|
+
return { kind: "approvalPending", approvalId: params.approvalId, requested: held.requested };
|
|
374
378
|
}
|
|
375
379
|
#approvalResolved(params) {
|
|
376
380
|
this.#pendingApprovals.delete(params.approvalId);
|
package/dist/src/index.d.ts
CHANGED
|
@@ -33,7 +33,14 @@ export type { DeltaApplyOutcome, ItemApplyOutcome, RevisionedItem, TerminalUnkno
|
|
|
33
33
|
export { SessionStateStore } from "./fold/state-store.js";
|
|
34
34
|
export type { StateApplyOutcome, StateValue } from "./fold/state-store.js";
|
|
35
35
|
export { SessionFold } from "./fold/session-fold.js";
|
|
36
|
-
export type {
|
|
36
|
+
export type {
|
|
37
|
+
/**
|
|
38
|
+
* Exported because it is CONSUMER SURFACE, not an internal pin: every
|
|
39
|
+
* getter on `SessionFold` returns `DeepReadonly<…>`, so a consumer naming
|
|
40
|
+
* one of those values needs the type. Without it they are stuck with
|
|
41
|
+
* `ReturnType<>` gymnastics or a deep `dist/` import (#23556 item 4).
|
|
42
|
+
*/
|
|
43
|
+
DeepReadonly, FoldItems, FoldOutcome, FoldSessionState, PendingApproval, SessionStateMethod, SessionStateParams, StaleDroppableMethod, TurnEntry, TurnState, ViewEvent, } from "./fold/session-fold.js";
|
|
37
44
|
export { COMMAND_REJECTED_CODE, COMMAND_REJECTED_KIND, PendingCommandSet, } from "./pending/pending-command-set.js";
|
|
38
45
|
export type { CommandErrorResponse, PendingCommandAck, PendingCommandEntry, PendingCommandSetOptions, PendingDisposition, PendingJoinPlan, PendingRetirement, ReplayAnswer, SnapshotJoinFacts, } from "./pending/pending-command-set.js";
|
|
39
46
|
export { Connection, createUuidV7Mint, MspError, ProtocolError, } from "./connection/connection.js";
|