@happyvertical/smrt-playbooks 0.51.32 → 0.51.34

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.d.ts CHANGED
@@ -1,632 +1,29 @@
1
- import { CapabilityClassification } from '@happyvertical/smrt-types';
2
- import { CapabilityDeclaration } from '@happyvertical/smrt-types';
3
- import { SmrtClassOptions } from '@happyvertical/smrt-core';
4
- import { SmrtCollection } from '@happyvertical/smrt-core';
5
- import { SmrtObject } from '@happyvertical/smrt-core';
6
- import { SmrtObjectOptions } from '@happyvertical/smrt-core';
7
-
8
- /**
9
- * Static layers a browser-plane step is evaluated against.
10
- *
11
- * Everything here is a build-time or configuration fact. The generated
12
- * `authMiddleware` is deliberately absent: it is request-bound, returns a
13
- * `Response` rather than a boolean, and may consult session stores, rate-limit,
14
- * or audit — so preflight never invokes it, synthetically or otherwise, and
15
- * `appAuthConfigured` is the only thing it is allowed to know about it.
16
- *
17
- * An `authPredicate` seam (option 1 in #2590) can later be added as an optional
18
- * member here, turning the `app-auth` layer's `unknown` into a real verdict
19
- * without changing the report contract.
20
- */
21
- export declare interface BrowserPreflightLayerSource {
22
- /** `isApiActionEnabled` for the referenced model operation. */
23
- isActionExposed(model: string, action: string): boolean;
24
- /** `isRoutePublic` for the HTTP method the action maps to. */
25
- isRoutePublic(model: string, action: string): boolean;
26
- /** Field-level read-permission slugs the step's model declares. */
27
- requiredFieldPermissions(model: string, action: string): readonly string[];
28
- /** Whether an app-level auth middleware is wired. Never invoked. */
29
- appAuthConfigured: boolean;
30
- }
31
-
32
- export declare interface BrowserPreflightOptions {
33
- layers: BrowserPreflightLayerSource;
34
- /**
35
- * The caller's published permission slugs, when the host publishes them.
36
- * `null`/absent makes the field layer report `unknown` rather than guess.
37
- */
38
- permissions?: Iterable<string> | null;
39
- }
40
-
41
- export declare interface BrowserPreflightProviderOptions {
42
- /**
43
- * Resolution options shared by every request — classifier, intent registry,
44
- * and any host-level runtime override. The per-request database handle and
45
- * tenant come from the route.
46
- */
47
- resolve?: Omit<ResolvePlaybookOptions, 'plane' | 'db'>;
48
- /**
49
- * Derives the cache-partitioning principal identity for a request. Opaque and
50
- * never echoed; defaults to the caller's permission slugs, which is the only
51
- * caller-distinguishing input the static layers actually read.
52
- */
53
- principal?: (request: {
54
- permissions?: Iterable<string>;
55
- appAuthConfigured: boolean;
56
- }) => string;
57
- }
58
-
59
- export declare function clearPlaybookCache(): void;
60
-
61
- /** Drops every cached preflight result. Use in tests. */
62
- export declare function clearPlaybookPreflightCache(): void;
63
-
64
- /**
65
- * Builds the provider wired into `APIConfig.playbookPreflight`.
66
- *
67
- * ```typescript
68
- * const api = new APIGenerator(manifest, {
69
- * playbookPreflight: createBrowserPlaybookPreflight(),
70
- * });
71
- * ```
72
- *
73
- * Every unresolvable key — unknown, disabled, browser-invalid, unresolvable
74
- * intent — comes back as the single uniform unavailable report, so the endpoint
75
- * is not an enumeration oracle.
76
- */
77
- export declare function createBrowserPlaybookPreflight(options?: BrowserPreflightProviderOptions): (request: {
78
- key: string;
79
- plane: 'browser';
80
- permissions?: Iterable<string>;
81
- appAuthConfigured: boolean;
82
- db?: unknown;
83
- }) => Promise<PlaybookPreflightReport>;
84
-
85
- /**
86
- * Browser-plane evaluator: the static layers only.
87
- *
88
- * - `action-exposure` — `isApiActionEnabled`. A disabled action is a hard,
89
- * statically knowable deny (the route answers 405).
90
- * - `public-access` — `isRoutePublic`. A non-public route with **no** app auth
91
- * middleware wired is a hard deny (the generator's fail-closed 401); with one
92
- * wired it is `unknown`, because whether that middleware passes is exactly
93
- * what preflight refuses to guess.
94
- * - `field-permissions` — the model's declared field read-permission slugs
95
- * against the caller's published set. Missing slugs redact fields rather than
96
- * fail the step, so the verdict stays `allow` and carries
97
- * `reason: 'fields-redacted'` plus the missing slugs; an unpublished
98
- * permission set reports `unknown`.
99
- * - `app-auth` — `unknown` whenever a middleware is wired. This is the layer an
100
- * `authPredicate` seam would later fill in.
101
- *
102
- * An intent step never crosses the REST boundary at all, so it is reported
103
- * `unknown` against `intent-mount`: whether the surface is mounted and what its
104
- * staged-control review does are runtime facts of the page, not of the build.
105
- */
106
- export declare function createBrowserStepEvaluator(options: BrowserPreflightOptions): PreflightStepEvaluator;
107
-
108
- /**
109
- * A layer source reading the generated REST surface's own static rules.
110
- *
111
- * A model this build does not register resolves to no object name, and every
112
- * layer then fails closed: an unregistered model has no route, so a step naming
113
- * one can only die.
114
- */
115
- export declare function createRestPreflightLayerSource(options: {
116
- appAuthConfigured: boolean;
117
- }): BrowserPreflightLayerSource;
118
-
119
- /**
120
- * Server-plane evaluator: the intersection of the persona tool allow-list and
121
- * the operation-permission predicate, per step, with nothing executed.
122
- *
123
- * An intent step is reported against its **declared** plane validity: an intent
124
- * that does not declare `server` is denied with reason `plane`, and one that
125
- * does is `unknown`, because server validity rides the #2446 command/ack bridge
126
- * whose acknowledgement is not statically knowable. This repeats a check
127
- * resolution already made, deliberately — the same defense-in-depth shape as
128
- * `assertToolAllowed()` gating both the tool offer and its execution.
129
- */
130
- export declare function createServerStepEvaluator(options: ServerPreflightOptions): PreflightStepEvaluator;
131
-
132
- /**
133
- * Registers a code-default playbook. Packages call this at import time so a
134
- * bundled playbook resolves without any application registration.
135
- */
136
- export declare function definePlaybook(input: PlaybookDefinitionInput): PlaybookDefinition;
137
-
138
- /**
139
- * Fail-closed capability classification, per epic #2585 invariant 3. Applied
140
- * whenever the host cannot tell us how a referenced operation is classified.
141
- */
142
- export declare const FAIL_CLOSED_CLASSIFICATION: CapabilityClassification;
143
-
144
- export declare function getPlaybookCacheTtlMs(): number;
145
-
146
- /** TTL applied to every cached preflight result. */
147
- export declare function getPlaybookPreflightCacheTtlMs(): number;
148
-
149
- export declare function normalizeEditableConfig(editable?: Partial<PlaybookEditableConfig>): PlaybookEditableConfig;
150
-
151
- /* Excluded from this release type: PACKAGE_VERSION_INITIALIZED */
152
-
153
- export declare const PLAYBOOK_PLANES: readonly PlaybookPlane[];
154
-
155
- /**
156
- * The one response every unresolvable playbook produces.
157
- *
158
- * Frozen and shared so an unknown key and an unauthorized key are byte-for-byte
159
- * identical: same shape, same values, no key echo, no reason code, no message.
160
- * Preflight answers only for playbooks resolvable through the caller's own
161
- * layer chain, and says nothing about anything else — including whether it
162
- * exists.
163
- */
164
- export declare const PLAYBOOK_PREFLIGHT_UNAVAILABLE: PlaybookPreflightUnavailableReport;
165
-
166
- export declare interface PlaybookAcceptance {
167
- ok: true;
168
- plan: PlaybookPlan;
169
- }
170
-
171
- export declare interface PlaybookCacheValue {
172
- key: string;
173
- title: string;
174
- description: string;
175
- planes: readonly PlaybookPlane[];
176
- onStepFailure: PlaybookFailurePolicy;
177
- enabled: boolean;
178
- metadata: PlaybookMetadata;
179
- }
180
-
181
- /**
182
- * A partial override from any layer above the code default. There is no
183
- * `steps` key, and supplying one is rejected rather than ignored.
184
- */
185
- export declare interface PlaybookConfigOverrideInput {
186
- title?: string | null;
187
- description?: string | null;
188
- planes?: readonly PlaybookPlane[] | null;
189
- onStepFailure?: PlaybookFailurePolicy | null;
190
- enabled?: boolean | null;
191
- metadata?: PlaybookMetadata | null;
192
- [key: string]: unknown;
193
- }
194
-
195
- export declare interface PlaybookDefinition {
196
- key: string;
197
- title: string;
198
- description: string;
199
- steps: readonly PlaybookStep[];
200
- planes: readonly PlaybookPlane[];
201
- onStepFailure: PlaybookFailurePolicy;
202
- enabled: boolean;
203
- metadata: PlaybookMetadata;
204
- editable: PlaybookEditableConfig;
205
- }
206
-
207
- export declare interface PlaybookDefinitionInput {
208
- key: string;
209
- title: string;
210
- description: string;
211
- steps: readonly PlaybookStep[];
212
- /**
213
- * Planes this playbook is valid on. Defaults to both planes when every step
214
- * is a model operation, and to `['browser']` when any step is a view intent
215
- * — server validity for an intent-bearing playbook rides the #2446 browser
216
- * command/ack bridge and must be declared explicitly.
217
- */
218
- planes?: readonly PlaybookPlane[];
219
- onStepFailure?: PlaybookFailurePolicy;
220
- enabled?: boolean;
221
- metadata?: PlaybookMetadata | null;
222
- editable?: Partial<PlaybookEditableConfig>;
223
- }
224
-
225
- /**
226
- * Fields a stored override layer may change when the definition opts in.
227
- *
228
- * `steps` is deliberately absent: it is structurally non-editable, not merely
229
- * defaulted false. No override layer can carry a step list at all.
230
- */
231
- export declare interface PlaybookEditableConfig {
232
- title: boolean;
233
- description: boolean;
234
- planes: boolean;
235
- onStepFailure: boolean;
236
- enabled: boolean;
237
- metadata: boolean;
238
- }
239
-
240
- /**
241
- * What an agent does when a step fails partway through a plan. Playbooks are
242
- * scripts, never atomic units, so there is no compensation: the definition
243
- * says only whether the remainder of the plan is abandoned.
244
- */
245
- export declare type PlaybookFailurePolicy = 'abort' | 'continue';
246
-
247
- /**
248
- * Record returned by an intent registry for a declared view intent.
249
- *
250
- * Seam for #2588: until an intent registry exists, no resolver is supplied and
251
- * an intent step fails resolution closed.
252
- */
253
- export declare interface PlaybookIntentRecord {
254
- id: string;
255
- classification?: CapabilityDeclaration | null;
256
- planes?: readonly PlaybookPlane[] | null;
257
- }
258
-
259
- /** Seam for #2588. */
260
- export declare type PlaybookIntentResolver = (id: string) => PlaybookIntentRecord | null | undefined;
261
-
262
- /**
263
- * A step naming a declared view intent by its identity (#2588). Valid only
264
- * where a surface is mounted.
265
- */
266
- export declare interface PlaybookIntentStep {
267
- kind: 'intent';
268
- /** Declared intent identity from the #2588 intent registry. */
269
- id: string;
270
- label?: string;
271
- description?: string;
272
- optional?: boolean;
273
- }
274
-
275
- /** One normalized override layer. `null` means "clear"; `undefined` means "inherit". */
276
- export declare interface PlaybookLayer {
277
- title?: string | null;
278
- description?: string | null;
279
- planes?: readonly PlaybookPlane[] | null;
280
- onStepFailure?: PlaybookFailurePolicy | null;
281
- enabled?: boolean | null;
282
- metadata?: PlaybookMetadata | null;
283
- }
284
-
285
- export declare type PlaybookMetadata = Record<string, unknown>;
286
-
287
- /**
288
- * Resolves the capability classification of a referenced model operation.
289
- *
290
- * Playbooks never classify a step themselves. A host that knows the emitted
291
- * build-time classification (core's `tool-schema.ts` output, or the runtime
292
- * manifest) supplies it here; anything it does not know resolves fail-closed
293
- * to `{ effect: 'destructive', idempotent: false, openWorld: true }`.
294
- */
295
- export declare type PlaybookOperationClassifier = (step: PlaybookOperationStep) => CapabilityDeclaration | null | undefined;
296
-
297
- /**
298
- * A step naming a model operation by qualified pair — the same qualified
299
- * form STI discriminators and `@crossPackageRef` already use. Never a
300
- * generated tool name: that is derived from model, action, and namespace and
301
- * would silently orphan stored tenant overrides on a namespace change.
302
- *
303
- * The step never classifies itself; classification is inherited from the
304
- * referenced operation (see {@link PlaybookOperationClassifier}).
305
- */
306
- export declare interface PlaybookOperationStep {
307
- kind: 'operation';
308
- /** Qualified model name, e.g. `@happyvertical/smrt-commerce:Order`. */
309
- model: string;
310
- /** Operation name exposed by the model's `@smrt({ api })` surface. */
311
- action: string;
312
- /** Human-facing label for the agent's narration of this step. */
313
- label?: string;
314
- /** Longer human-facing description of the step. */
315
- description?: string;
316
- /** When true, an agent may skip this step without abandoning the plan. */
317
- optional?: boolean;
318
- }
319
-
320
- /**
321
- * Stored app-level (`tenantId = null`) and tenant-level playbook overrides.
322
- *
323
- * There is deliberately **no `steps` column**. `steps` is structurally
324
- * non-editable: an override layer has nowhere to put a step list, and
325
- * assigning one is rejected in `save()` rather than silently dropped. That is
326
- * the description-behavior guarantee from epic #2585 — an agent announcing
327
- * "checking out your cart" must not be following a rewritten script.
328
- */
329
- export declare class PlaybookOverride extends SmrtObject {
330
- key: string;
331
- tenantId: string | null;
332
- title: string | null;
333
- description: string | null;
334
- /** JSON array of plane names; null inherits the lower layer. */
335
- planes: string | null;
336
- onStepFailure: string | null;
337
- /** Tri-state: null inherits, false disables. True can never widen. */
338
- enabled: boolean | null;
339
- /** JSON object; stored as a string with guarded get/set helpers. */
340
- metadata: string | null;
341
- constructor(options?: PlaybookOverrideOptions);
342
- getMetadata(): PlaybookMetadata;
343
- setMetadata(metadata: PlaybookMetadata | null): void;
344
- getPlanes(): readonly PlaybookPlane[] | null;
345
- setPlanes(planes: readonly PlaybookPlane[] | null): void;
346
- toPlaybookLayer(): PlaybookLayer;
347
- save(): Promise<this>;
348
- private saveAfterIdentityChange;
349
- private saveAfterIdentityChangeInTransaction;
350
- private saveAfterIdentityChangeWithDeferredDelete;
351
- delete(): Promise<void>;
352
- private validatePlaybookOverride;
353
- private getLowerPrecedenceLayers;
354
- private normalizeForPersistence;
355
- private getPersistedIdentity;
356
- }
357
-
358
- export declare class PlaybookOverrideCollection extends SmrtCollection<PlaybookOverride> {
359
- static readonly _itemClass: typeof PlaybookOverride;
360
- private excludeOverrideId;
361
- getAppOverride(key: string, options?: {
362
- excludeId?: string;
363
- }): Promise<PlaybookOverride | null>;
364
- getTenantOverride(key: string, tenantId: string, options?: {
365
- excludeId?: string;
366
- }): Promise<PlaybookOverride | null>;
367
- getResolutionLayers(key: string, tenantId?: string | null, options?: {
368
- excludeId?: string;
369
- }): Promise<{
370
- app: PlaybookOverride | null;
371
- tenant: PlaybookOverride | null;
372
- }>;
373
- }
374
-
375
- export declare interface PlaybookOverrideOptions extends SmrtObjectOptions, PlaybookOverrideOptions_2 {
376
- }
377
-
378
- declare interface PlaybookOverrideOptions_2 {
379
- key?: string;
380
- tenantId?: string | null;
381
- title?: string | null;
382
- description?: string | null;
383
- planes?: string | readonly PlaybookPlane[] | null;
384
- onStepFailure?: PlaybookFailurePolicy | null;
385
- enabled?: boolean | null;
386
- metadata?: string | PlaybookMetadata | null;
387
- }
388
-
389
- export declare interface PlaybookPackageConfig {
390
- playbooks?: Record<string, PlaybookConfigOverrideInput>;
391
- [key: string]: unknown;
392
- }
393
-
394
- /**
395
- * The output of resolution: a plan an agent follows step by step. Nothing in
396
- * this package executes a step, and the plan is not an authority boundary —
397
- * every step is authorized independently where it runs.
398
- */
399
- export declare interface PlaybookPlan {
400
- key: string;
401
- title: string;
402
- description: string;
403
- plane: PlaybookPlane;
404
- planes: readonly PlaybookPlane[];
405
- onStepFailure: PlaybookFailurePolicy;
406
- metadata: PlaybookMetadata;
407
- steps: readonly PlaybookPlanStep[];
408
- }
409
-
410
- /**
411
- * Execution planes a playbook can declare validity for.
412
- *
413
- * `browser` covers WebMCP / in-page agents driving mounted surfaces;
414
- * `server` covers Node MCP, CLI, and in-app agents running under
415
- * `executeAsPrincipal`.
416
- */
417
- export declare type PlaybookPlane = 'browser' | 'server';
418
-
419
- /** One step of a resolved plan, with its inherited classification. */
420
- export declare interface PlaybookPlanStep {
421
- index: number;
422
- step: PlaybookStep;
423
- classification: CapabilityClassification;
424
- /** True when the classification is the fail-closed default. */
425
- classificationDeclared: boolean;
426
- }
427
-
428
- export declare interface PlaybookPreflightAvailableReport {
429
- available: true;
430
- /**
431
- * Literal `true` on every report, as a type-level reminder: a report is a
432
- * prediction, never a grant, and every step is authorized again where it
433
- * executes.
434
- */
435
- advisory: true;
436
- key: string;
437
- plane: PlaybookPlane;
438
- title: string;
439
- description: string;
440
- verdict: PreflightVerdict;
441
- steps: readonly PreflightStepReport[];
442
- summary: PreflightSummary;
443
- }
444
-
445
- /** A preflight result. Advisory only — see the two variants above. */
446
- export declare type PlaybookPreflightReport = PlaybookPreflightAvailableReport | PlaybookPreflightUnavailableReport;
447
-
448
- export declare interface PlaybookPreflightRequest {
449
- key: string;
450
- plane: PlaybookPlane;
451
- /**
452
- * Opaque, caller-scoped principal identity used to partition the cache. It is
453
- * never echoed in the report and never consulted for authority. The cache key
454
- * also folds in `resolve.tenantId`, so a principal string need not encode the
455
- * tenant to stay correct.
456
- */
457
- principal: string;
458
- /** Options handed to `resolvePlaybook()` — the caller's own layer chain. */
459
- resolve?: ResolvePlaybookOptions;
460
- /** Evaluates each resolved step. */
461
- evaluate: PreflightStepEvaluator;
462
- }
463
-
464
- /**
465
- * The single, uniform answer for every playbook the caller's own layer chain
466
- * cannot resolve. An unknown key and an unauthorized key produce this exact
467
- * frozen value, so preflight is not an enumeration oracle: it carries no key,
468
- * no plane, and no reason to tell the two apart.
469
- */
470
- export declare interface PlaybookPreflightUnavailableReport {
471
- available: false;
472
- advisory: true;
473
- verdict: 'deny';
474
- steps: readonly [];
475
- summary: PreflightSummary;
476
- }
477
-
478
- /**
479
- * Global process registry of code-default playbooks, keyed by namespaced key.
480
- *
481
- * Held on `globalThis` so it survives HMR, mirroring `PromptRegistry`.
482
- */
483
- export declare const PlaybookRegistry: {
484
- register(input: PlaybookDefinitionInput): PlaybookDefinition;
485
- get(key: string): PlaybookDefinition | undefined;
486
- has(key: string): boolean;
487
- getAll(): PlaybookDefinition[];
488
- clear(): void;
489
- };
490
-
491
- export declare interface PlaybookRejection {
492
- ok: false;
493
- reason: PlaybookRejectionReason;
494
- message: string;
495
- key: string;
496
- /** Index of the offending step, when the rejection is step-scoped. */
497
- stepIndex?: number;
498
- }
499
-
500
- export declare type PlaybookRejectionReason = 'unknown-playbook' | 'disabled' | 'plane-not-declared' | 'intent-registry-unavailable' | 'unknown-intent' | 'intent-plane-not-declared';
501
-
502
- /** Resolution fails closed: every rejection carries a specific reason. */
503
- export declare type PlaybookResolution = PlaybookAcceptance | PlaybookRejection;
504
-
505
- /** A playbook step. Exactly two kinds exist in v1; playbooks cannot nest. */
506
- export declare type PlaybookStep = PlaybookOperationStep | PlaybookIntentStep;
507
-
508
- /**
509
- * The authority layers preflight reports on. The two planes are deliberately
510
- * asymmetric and report different layers:
511
- *
512
- * - server plane — `tool-allowlist`, `operation-permission`, and `plane` for an
513
- * intent step;
514
- * - browser plane — `action-exposure`, `public-access`, `field-permissions`,
515
- * `app-auth`, and `intent-mount` for an intent step.
516
- */
517
- export declare type PreflightLayer = 'tool-allowlist' | 'operation-permission' | 'plane' | 'action-exposure' | 'public-access' | 'field-permissions' | 'app-auth' | 'intent-mount';
518
-
519
- /** One authority layer's verdict for one step. */
520
- export declare interface PreflightLayerReport {
521
- layer: PreflightLayer;
522
- verdict: PreflightVerdict;
523
- reason: PreflightReason;
524
- /**
525
- * Permission slugs this layer found missing, when it knows them. Present only
526
- * on layers that evaluate a slug set.
527
- */
528
- missingPermissions?: readonly string[];
529
- }
530
-
531
- /**
532
- * Decomposes a resolved plan into per-step verdicts using `evaluate`.
533
- *
534
- * Every step is evaluated — evaluation does not short-circuit on the first
535
- * denial, because the point of preflight is to show the caller *which* step of
536
- * five would die, not merely that one would.
537
- */
538
- export declare function preflightPlan(plan: PlaybookPlan, evaluate: PreflightStepEvaluator): Promise<PlaybookPreflightAvailableReport>;
539
-
540
- /**
541
- * Preflights one playbook for one caller on one plane.
542
- *
543
- * Resolves through the **caller's own layer chain** (their tenant, their
544
- * overrides, their plane), decomposes the plan, and evaluates each step with the
545
- * plane's evaluator. Any playbook the chain cannot resolve — unknown, disabled,
546
- * wrong plane, unresolvable intent — returns the single
547
- * {@link PLAYBOOK_PREFLIGHT_UNAVAILABLE} value.
548
- *
549
- * Results are cached per `(principal, key, plane)` under the playbook cache's
550
- * generation counter; see `preflight-cache.ts` for why that is safe.
551
- */
552
- export declare function preflightPlaybook(request: PlaybookPreflightRequest): Promise<PlaybookPreflightReport>;
553
-
554
- /** Why a layer reached its verdict. A stable code, never a free-form message. */
555
- export declare type PreflightReason = 'ok' | 'tool-not-allowed' | 'permission-denied' | 'permission-unknown' | 'plane' | 'action-not-exposed' | 'not-public' | 'auth-required' | 'app-auth-not-evaluated' | 'app-auth-not-configured' | 'fields-redacted' | 'field-permissions-unknown' | 'intent-not-mounted' | 'intent-bridge-not-evaluated' | 'not-evaluated';
556
-
557
- /** What a step evaluator returns; `preflightPlan` supplies `index` and `kind`. */
558
- export declare interface PreflightStepEvaluation {
559
- layers: readonly PreflightLayerReport[];
560
- }
561
-
562
- /** Evaluates one resolved plan step without executing any part of it. */
563
- export declare type PreflightStepEvaluator = (step: PlaybookPlanStep) => PreflightStepEvaluation | Promise<PreflightStepEvaluation>;
564
-
565
- /** A step's aggregate verdict plus the per-layer detail behind it. */
566
- export declare interface PreflightStepReport {
567
- index: number;
568
- kind: PlaybookStep['kind'];
569
- verdict: PreflightVerdict;
570
- /** Reason of the first layer that produced the step's aggregate verdict. */
571
- reason: PreflightReason;
572
- layers: readonly PreflightLayerReport[];
573
- }
574
-
575
- export declare interface PreflightSummary {
576
- allow: number;
577
- deny: number;
578
- unknown: number;
579
- }
580
-
581
- /**
582
- * Verdict for one authority layer, one step, or a whole plan.
583
- *
584
- * `unknown` is a first-class answer, never a rounded-down `allow`: a layer that
585
- * cannot be evaluated without executing something says so.
586
- */
587
- export declare type PreflightVerdict = 'allow' | 'deny' | 'unknown';
588
-
589
- /**
590
- * Resolves a playbook to a plan for a caller on a given plane.
591
- *
592
- * Returns a discriminated result rather than throwing: resolution fails closed
593
- * and every rejection names a specific reason. Nothing here executes a step —
594
- * the plan is followed step by step by the agent, and each step is authorized
595
- * independently at the REST boundary or by `PrincipalRun.assertToolAllowed()`.
596
- */
597
- export declare function resolvePlaybook(key: string, options?: ResolvePlaybookOptions): Promise<PlaybookResolution>;
598
-
599
- export declare interface ResolvePlaybookOptions {
600
- db?: SmrtClassOptions['db'];
601
- tenantId?: string | null;
602
- /** Plane the calling agent runs on. Defaults to `'server'`. */
603
- plane?: PlaybookPlane;
604
- /** Highest-precedence layer, supplied per call. */
605
- override?: PlaybookConfigOverrideInput;
606
- /** Host-supplied classification source for model-operation steps. */
607
- classifier?: PlaybookOperationClassifier;
608
- /** Host-supplied intent registry (#2588). */
609
- intents?: PlaybookIntentResolver;
610
- }
611
-
612
- export declare interface ServerPreflightOptions {
613
- /** `PrincipalRun.isToolAllowed` for the slug that gates this step. */
614
- isToolAllowed(step: PlaybookOperationStep): boolean;
615
- /**
616
- * The operation-permission predicate. Evaluates the catalog gate for the
617
- * step's `(collection, action)` without performing the operation.
618
- */
619
- checkOperationPermission(step: PlaybookOperationStep): PreflightVerdict | Promise<PreflightVerdict>;
620
- /** Declared plane validity of a view intent, from the #2588 registry. */
621
- intentPlanes?(id: string): readonly PlaybookPlane[] | null | undefined;
622
- }
623
-
624
- /** Fail-closed combination: `deny` beats `unknown` beats `allow`. */
625
- export declare function worstVerdict(left: PreflightVerdict, right: PreflightVerdict): PreflightVerdict;
626
-
627
- export { }
628
-
629
-
630
- declare global {
631
- var __smrtPlaybookRegistry: Map<string, PlaybookDefinition> | undefined;
632
- }
1
+ /**
2
+ * @happyvertical/smrt-playbooks
3
+ *
4
+ * Code-first playbooks — named, described, layered step sequences an agent
5
+ * follows — with config, app-level, tenant-level, and runtime overrides.
6
+ *
7
+ * A playbook resolves to a plan the agent executes step by step. Nothing in
8
+ * this package executes a step, so a playbook is never an authority boundary:
9
+ * every step is authorized independently at the REST boundary or, server-side,
10
+ * by `PrincipalRun.assertToolAllowed()`.
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+ import './__smrt-register__.js';
15
+ export { clearPlaybookCache, getPlaybookCacheTtlMs } from './cache.js';
16
+ export { PlaybookOverrideCollection } from './collections/PlaybookOverrideCollection.js';
17
+ export { PlaybookOverride, type PlaybookOverrideOptions, } from './models/PlaybookOverride.js';
18
+ export { definePlaybook, PlaybookRegistry } from './playbook-registry.js';
19
+ export { resolvePlaybook } from './playbook-resolver.js';
20
+ export { createBrowserStepEvaluator, createServerStepEvaluator, PLAYBOOK_PREFLIGHT_UNAVAILABLE, preflightPlan, preflightPlaybook, worstVerdict, } from './preflight.js';
21
+ export { clearPlaybookPreflightCache, getPlaybookPreflightCacheTtlMs, } from './preflight-cache.js';
22
+ export type { BrowserPreflightLayerSource, BrowserPreflightOptions, PlaybookPreflightAvailableReport, PlaybookPreflightReport, PlaybookPreflightRequest, PlaybookPreflightUnavailableReport, PreflightLayer, PreflightLayerReport, PreflightReason, PreflightStepEvaluation, PreflightStepEvaluator, PreflightStepReport, PreflightSummary, PreflightVerdict, ServerPreflightOptions, } from './preflight-types.js';
23
+ export { type BrowserPreflightProviderOptions, createBrowserPlaybookPreflight, createRestPreflightLayerSource, } from './rest-preflight.js';
24
+ export type { PlaybookAcceptance, PlaybookCacheValue, PlaybookConfigOverrideInput, PlaybookDefinition, PlaybookDefinitionInput, PlaybookEditableConfig, PlaybookFailurePolicy, PlaybookIntentRecord, PlaybookIntentResolver, PlaybookIntentStep, PlaybookLayer, PlaybookMetadata, PlaybookOperationClassifier, PlaybookOperationStep, PlaybookPackageConfig, PlaybookPlan, PlaybookPlane, PlaybookPlanStep, PlaybookRejection, PlaybookRejectionReason, PlaybookResolution, PlaybookStep, ResolvePlaybookOptions, } from './types.js';
25
+ export { PLAYBOOK_PLANES } from './types.js';
26
+ export { FAIL_CLOSED_CLASSIFICATION, normalizeEditableConfig, } from './utils.js';
27
+ /** @internal */
28
+ export declare const PACKAGE_VERSION_INITIALIZED = true;
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,GAC7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,8BAA8B,EAC9B,aAAa,EACb,iBAAiB,EACjB,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,GAC/B,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,2BAA2B,EAC3B,uBAAuB,EACvB,gCAAgC,EAChC,uBAAuB,EACvB,wBAAwB,EACxB,kCAAkC,EAClC,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,KAAK,+BAA+B,EACpC,8BAA8B,EAC9B,8BAA8B,GAC/B,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,2BAA2B,EAC3B,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,2BAA2B,EAC3B,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,YAAY,EACZ,sBAAsB,GACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,YAAY,CAAC;AAEpB,gBAAgB;AAChB,eAAO,MAAM,2BAA2B,OAAO,CAAC"}