@sublang/playbook 0.9.0 → 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.
Files changed (51) hide show
  1. package/README.md +190 -151
  2. package/package.json +50 -6
  3. package/reference/sdlc/captain.md +102 -0
  4. package/reference/sdlc/captain.playbook/captain.fsm.d.ts +227 -0
  5. package/reference/sdlc/captain.playbook/captain.fsm.js +628 -0
  6. package/reference/sdlc/captain.playbook/captain.fsm.ts +851 -0
  7. package/reference/sdlc/captain.playbook/captain.gears.md +60 -0
  8. package/reference/sdlc/captain.playbook/captain.playbook.d.ts +23 -0
  9. package/reference/sdlc/captain.playbook/captain.playbook.js +1053 -0
  10. package/reference/sdlc/captain.playbook/captain.playbook.ts +1144 -0
  11. package/reference/sdlc/code.playbook/bin/playbook.js +158 -12
  12. package/reference/sdlc/code.playbook/bin/run.js +999 -0
  13. package/reference/sdlc/code.playbook/code.fsm.d.ts +11 -4
  14. package/reference/sdlc/code.playbook/code.fsm.introspect.d.ts +2 -2
  15. package/reference/sdlc/code.playbook/code.fsm.introspect.js +1 -1
  16. package/reference/sdlc/code.playbook/code.fsm.introspect.ts +6 -6
  17. package/reference/sdlc/code.playbook/code.fsm.js +334 -102
  18. package/reference/sdlc/code.playbook/code.fsm.ts +467 -180
  19. package/reference/sdlc/code.playbook/code.gears.md +11 -10
  20. package/reference/sdlc/code.playbook/code.playbook.d.ts +16 -19
  21. package/reference/sdlc/code.playbook/code.playbook.js +199 -488
  22. package/reference/sdlc/code.playbook/code.playbook.ts +327 -566
  23. package/reference/sdlc/code.playbook/code.registry.d.ts +0 -3
  24. package/reference/sdlc/code.playbook/code.registry.js +0 -3
  25. package/reference/sdlc/code.playbook/code.registry.ts +0 -6
  26. package/reference/sdlc/code.playbook/playbook-captain.d.ts +9 -4
  27. package/reference/sdlc/code.playbook/playbook-captain.js +889 -210
  28. package/reference/sdlc/code.playbook/playbook-captain.ts +1136 -257
  29. package/reference/sdlc/code.playbook/playbook.config.template.yaml +21 -0
  30. package/reference/sdlc/discuss.playbook/discuss.fsm.d.ts +396 -0
  31. package/reference/sdlc/discuss.playbook/discuss.fsm.js +2066 -0
  32. package/reference/sdlc/discuss.playbook/discuss.fsm.ts +2464 -0
  33. package/reference/sdlc/discuss.playbook/discuss.gears.md +251 -0
  34. package/reference/sdlc/discuss.playbook/discuss.playbook.d.ts +113 -0
  35. package/reference/sdlc/discuss.playbook/discuss.playbook.js +1514 -0
  36. package/reference/sdlc/discuss.playbook/discuss.playbook.ts +1926 -0
  37. package/reference/sdlc/discuss.playbook/discuss.registry.d.ts +58 -0
  38. package/reference/sdlc/discuss.playbook/discuss.registry.js +97 -0
  39. package/reference/sdlc/discuss.playbook/discuss.registry.ts +153 -0
  40. package/slc/gears2fsm.md +557 -57
  41. package/slc/link.md +1165 -89
  42. package/slc/optimize.md +92 -0
  43. package/slc/text2gears.md +255 -7
  44. package/src/runtime.d.ts +146 -3
  45. package/src/runtime.ts +201 -2
  46. package/src/xstate-playbook-runtime.d.ts +201 -0
  47. package/src/xstate-playbook-runtime.js +2058 -0
  48. package/src/xstate-playbook-runtime.ts +2792 -0
  49. package/src/xstate-runtime.d.ts +95 -0
  50. package/src/xstate-runtime.js +1258 -0
  51. package/src/xstate-runtime.ts +1816 -0
@@ -0,0 +1,95 @@
1
+ import { type AnyActorRef, type PromiseActorLogic, type SnapshotFrom } from 'xstate';
2
+ import type { CaptainResult, JsonValue, NormalizedError, PlaybookCallRequest, PlaybookCallResult, PlaybookCallStart, PlaybookPendingCall, PlaybookRuntimeSnapshot, PlaybookSession, PlaybookState, PlayerResult } from './runtime.js';
3
+ export * from './xstate-playbook-runtime.js';
4
+ /**
5
+ * Compose invocation-lifetime and imperative-boundary cancellation without
6
+ * installing a second forwarding listener in each generated runtime.
7
+ */
8
+ export declare function combineAbortSignals(...signals: readonly (AbortSignal | undefined)[]): AbortSignal;
9
+ /**
10
+ * Register host cleanup started synchronously by an invocation abort.
11
+ * The nested bridge drains these promises before it publishes the matching
12
+ * call-finish boundary, without widening the public six-port contract.
13
+ */
14
+ export declare function registerPlaybookAbortCleanup(signal: AbortSignal, cleanup: Promise<unknown>): void;
15
+ /** Reject values that would be changed, omitted, or rejected by JSON. */
16
+ export declare function assertJsonSafe(value: unknown, path?: string, ancestors?: ReadonlySet<object>): asserts value is JsonValue;
17
+ /** Validate, detach, and recursively freeze host-owned JSON input. */
18
+ export declare function snapshotJsonValue(value: unknown, path?: string): JsonValue;
19
+ /** Validate session causality and detach its immutable identity from the host. */
20
+ export declare function snapshotPlaybookSession(session: PlaybookSession): PlaybookSession;
21
+ export declare function normalizeError(error: unknown): NormalizedError;
22
+ export interface PlaybookStateMetadata {
23
+ stateId: string;
24
+ description: string;
25
+ }
26
+ /** Read stable state identity without consulting XState's private `_nodes`. */
27
+ export declare function activePlaybookStateMetadata(snapshot: unknown): readonly PlaybookStateMetadata[];
28
+ export interface SnapshotNormalizationOptions {
29
+ pendingCall?: PlaybookPendingCall;
30
+ }
31
+ export declare function normalizePlaybookSnapshot(snapshot: unknown, options?: SnapshotNormalizationOptions): PlaybookState;
32
+ export declare function detachPersistedMachineSnapshot(persisted: unknown): JsonValue;
33
+ export declare function assertPlaybookRuntimeSnapshot(value: unknown, expectedPlaybookId: string): PlaybookRuntimeSnapshot;
34
+ export interface NestedPlaybookInput {
35
+ stateId: string;
36
+ playbookId: string;
37
+ text: string;
38
+ }
39
+ export interface PlaybookCallStarted {
40
+ callId: string;
41
+ stateId: string;
42
+ playbookId: string;
43
+ text: string;
44
+ }
45
+ export interface PlaybookCallFinished extends PlaybookCallStarted {
46
+ result: PlaybookCallResult;
47
+ }
48
+ export interface NestedPlaybookBridgeOptions {
49
+ nextCallId(): string;
50
+ /** Active public runtime boundary whose abort also owns a new child call. */
51
+ getBoundarySignal?(): AbortSignal | undefined;
52
+ callPlaybook(request: PlaybookCallRequest, signal: AbortSignal): Promise<PlaybookCallStart>;
53
+ emitStarted(event: PlaybookCallStarted): Promise<void>;
54
+ emitFinished(event: PlaybookCallFinished): Promise<void>;
55
+ drain(): Promise<void>;
56
+ bindResumeSignal?(signal: AbortSignal): void;
57
+ onControlPlaneError?(error: unknown): void;
58
+ onBackgroundError?(error: unknown): void;
59
+ }
60
+ export declare class NestedPlaybookCallError extends Error {
61
+ readonly result: PlaybookCallResult;
62
+ constructor(result: PlaybookCallResult);
63
+ }
64
+ export interface PendingCallObserver {
65
+ getPendingCall(): PlaybookPendingCall | undefined;
66
+ subscribePendingCall(listener: (pendingCall: PlaybookPendingCall) => void): () => void;
67
+ }
68
+ export interface NestedPlaybookBridge<TInput extends NestedPlaybookInput = NestedPlaybookInput> extends PendingCallObserver {
69
+ actorLogic: PromiseActorLogic<JsonValue | undefined, TInput>;
70
+ resume(input: {
71
+ callId: string;
72
+ result: PlaybookCallResult;
73
+ signal: AbortSignal;
74
+ }): Promise<void>;
75
+ abortPending(error?: unknown): Promise<void>;
76
+ dispose(): Promise<void>;
77
+ }
78
+ /** Validate, detach, and freeze a host direct-Captain result. */
79
+ export declare function validateCaptainResult(value: unknown, path?: string): CaptainResult;
80
+ /** Validate, detach, and freeze a host delegated-player result. */
81
+ export declare function validatePlayerResult(value: unknown, path?: string): PlayerResult;
82
+ export declare function validatePlaybookCallResult(result: unknown, expectedPlaybookId: string, expectedChildSessionId?: string): PlaybookCallResult;
83
+ export declare function validatePlaybookCallStart(start: unknown, expectedPlaybookId: string): PlaybookCallStart;
84
+ export declare function createNestedPlaybookBridge<TInput extends NestedPlaybookInput = NestedPlaybookInput>(options: NestedPlaybookBridgeOptions): NestedPlaybookBridge<TInput>;
85
+ export interface WaitForPlaybookQuiescenceOptions {
86
+ signal?: AbortSignal;
87
+ timeout?: number;
88
+ pendingCalls?: PendingCallObserver;
89
+ }
90
+ /**
91
+ * Wait at the imperative runtime boundary; workflow waiting remains in XState.
92
+ * A pending-call notification covers the case where the suspended state was
93
+ * entered before its host returned the child session id.
94
+ */
95
+ export declare function waitForPlaybookQuiescence<TActorRef extends AnyActorRef>(actor: TActorRef, options?: WaitForPlaybookQuiescenceOptions): Promise<SnapshotFrom<TActorRef>>;