@yaklabs-ai/plugin-sdk 0.15.1 → 0.15.3

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.
@@ -505,6 +505,7 @@ declare interface CustomAgentMessages {
505
505
  userInvoked: UserInvokedMessage;
506
506
  availabilityFacts: AvailabilityFactsMessage;
507
507
  midTurnCompactionOutcome: MidTurnCompactionOutcomeMessage;
508
+ runContinuationCarrier: RunContinuationCarrierMessage;
508
509
  subagentResult: SubagentResultMessage;
509
510
  backgroundTaskResult: BackgroundTaskResultMessage;
510
511
  }
@@ -1235,12 +1236,23 @@ declare interface KayAppCorpus {
1235
1236
  */
1236
1237
  readEntries(sessionId: string): AsyncIterable<TranscriptEntry>;
1237
1238
  /**
1238
- * Read one bounded physical JSONL page. The host resolves `sessionId` to its authoritative
1239
- * indexed path and validates the opaque cursor before opening it. When `throughEntryId` is
1240
- * supplied, the cursor stops at that entry's transaction line; a V4 line may carry later
1241
- * entries, which are returned for the caller to filter and are replayed on the next page.
1242
- * A page can hold no entries at all (a run of storage lines) while more follows; a record
1243
- * longer than the page is stepped over and counted in `oversizedRecords`.
1239
+ * Active-branch entries from the latest canonical human turn opener (send companions included)
1240
+ * through the anchor, oldest first. Mid-turn steers and machine wakes remain inside that window;
1241
+ * attachment-only openers and fresh card answers count. Missing sessions/anchors return [];
1242
+ * unsupported hosts may omit it.
1243
+ * Reads never fall back to materializing the full log.
1244
+ */
1245
+ readLatestHumanWindow?(sessionId: string, options?: {
1246
+ readonly throughEntryId?: string;
1247
+ }): Promise<readonly TranscriptEntry[]>;
1248
+ /**
1249
+ * Read one bounded page of a session's stored transcript. The host resolves `sessionId` to its
1250
+ * authoritative indexed path and validates the opaque cursor before reading. When
1251
+ * `throughEntryId` is supplied, the page ends at that entry and the cursor stays at the start of
1252
+ * the commit holding it: the commit's other entries are returned for the caller to filter, and
1253
+ * the next page replays that commit. A page can hold no entries at all (storage records with no
1254
+ * entry) while more follows; a record longer than the page is stepped over and counted in
1255
+ * `oversizedRecords`.
1244
1256
  */
1245
1257
  readEntryBatch?(sessionId: string, options?: {
1246
1258
  readonly cursor?: JsonValue_3;
@@ -1255,7 +1267,7 @@ declare interface KayAppCorpus {
1255
1267
  readSessionSourceMark(sessionId: string): Promise<KayAppCorpusSourceMark | undefined>;
1256
1268
  }
1257
1269
 
1258
- /** One bounded physical page from the host's incremental JSONL reader. */
1270
+ /** One bounded page from the host's stored transcript reader. */
1259
1271
  declare interface KayAppCorpusEntryBatch {
1260
1272
  readonly entries: readonly TranscriptEntry[];
1261
1273
  /** Opaque JSON cursor after the physical page; only the host may interpret it or open its path. */
@@ -1758,13 +1770,7 @@ declare interface MessageEntry extends EntryBase {
1758
1770
  /** TypeBox instantiation metrics */
1759
1771
  declare const Metrics: TMetrics;
1760
1772
 
1761
- /**
1762
- * A hidden kernel statement delivered before resuming a tool-requested compaction stop.
1763
- *
1764
- * Module-local, unlike every sibling above it: this message is never rendered and never matched
1765
- * by name outside this file, so exporting the string would only publish something no surface
1766
- * consumes. It earns an export the day one needs to recognise it.
1767
- */
1773
+ /** A hidden kernel statement delivered before resuming a tool-requested compaction stop. */
1768
1774
  declare const MID_TURN_COMPACTION_OUTCOME_CUSTOM_TYPE = "mid_turn_compaction_outcome";
1769
1775
 
1770
1776
  declare interface MidTurnCompactionOutcomeDetails {
@@ -2424,6 +2430,34 @@ declare function ReturnType_2<Type extends TSchema>(type: Type, options?: TSchem
2424
2430
  /** Creates a deferred ReturnType action. */
2425
2431
  declare function ReturnTypeDeferred<Type extends TSchema>(type: Type, options?: TSchemaOptions): TReturnTypeDeferred<Type>;
2426
2432
 
2433
+ /**
2434
+ * The hidden message a continued run rides as its admission ticket (a mid-turn compaction
2435
+ * resume, a run-recovery re-drive). The engine writes it; this package's placement rows keep it
2436
+ * out of the canonical transcript.
2437
+ */
2438
+ declare const RUN_CONTINUATION_CARRIER_CUSTOM_TYPE = "herd_run_continuation";
2439
+
2440
+ /**
2441
+ * What a {@link RUN_CONTINUATION_CARRIER_CUSTOM_TYPE} carrier records about the failed turns it
2442
+ * continues.
2443
+ */
2444
+ declare interface RunContinuationCarrierDetails {
2445
+ readonly provenance: {
2446
+ readonly source: "core";
2447
+ };
2448
+ /**
2449
+ * Visible text the failed turns since the previous carrier streamed before they died. Absent
2450
+ * when they showed none (thinking, an unexecuted tool call, or a thrown attempt): such a
2451
+ * carrier is plain.
2452
+ */
2453
+ readonly shownText?: string;
2454
+ }
2455
+
2456
+ declare type RunContinuationCarrierMessage = CustomMessage<RunContinuationCarrierDetails> & {
2457
+ readonly customType: typeof RUN_CONTINUATION_CARRIER_CUSTOM_TYPE;
2458
+ readonly display: false;
2459
+ };
2460
+
2427
2461
  /**
2428
2462
  * A durable runtime notice: the daemon telling the HUMAN, in the transcript,
2429
2463
  * that something it was going to do on their behalf did not happen — and why.
package/dist/kay-app.d.ts CHANGED
@@ -755,6 +755,7 @@ declare interface CustomAgentMessages {
755
755
  userInvoked: UserInvokedMessage;
756
756
  availabilityFacts: AvailabilityFactsMessage;
757
757
  midTurnCompactionOutcome: MidTurnCompactionOutcomeMessage;
758
+ runContinuationCarrier: RunContinuationCarrierMessage;
758
759
  subagentResult: SubagentResultMessage;
759
760
  backgroundTaskResult: BackgroundTaskResultMessage;
760
761
  }
@@ -921,6 +922,18 @@ declare interface DeferredHandle {
921
922
  data?: JsonValue_4;
922
923
  }
923
924
 
925
+ /**
926
+ * Register an ordinary workflow that polls connected accounts with independent JSON cursors.
927
+ * First polls initialize silently. Failed or skipped accounts retain their cursor; removed
928
+ * accounts are pruned. Publication finishes before replacement state is returned.
929
+ *
930
+ * Credential resolution and provider reads share a step so credentials are never step outputs.
931
+ * Poll callbacks must keep secrets out of their returned cursor, events, and summary. Resolution
932
+ * errors fail the run with a sanitized message; provider poll errors isolate the account.
933
+ * Key events at their source: a step can repeat before its result commits or after an engine update.
934
+ */
935
+ export declare function definePoller<Cursor extends JsonValue>(app: Pick<KayAppPluginApi, "workflows" | "auth" | "events">, localId: string, options: KayAppPollerOptions<Cursor>): void;
936
+
924
937
  /** Creates a Dependent type */
925
938
  declare function Dependent<If extends TSchema, Then extends TSchema, Else extends TSchema>(if_: If, then_: Then, else_: Else, options?: TSchemaOptions): TDependent<If, Then, Else>;
926
939
 
@@ -1397,6 +1410,14 @@ declare const Factor: (input: string) => [unknown, string] | [];
1397
1410
 
1398
1411
  declare function FactorMapping(input: [unknown, unknown, unknown, unknown, unknown]): unknown;
1399
1412
 
1413
+ /**
1414
+ * The `ErrorOptions` for a workflow that fails BECAUSE this run failed: the run's retained
1415
+ * failure ref as the error's `cause`, so the host reports that failure, with the same identity
1416
+ * the session kept, instead of guessing from whichever run settled last. Empty when the run kept
1417
+ * no failure: the throw is then the workflow's own.
1418
+ */
1419
+ export declare function failedRunCause(outcome: KayAppSessionRunOutcome): ErrorOptions;
1420
+
1400
1421
  declare type ForecastInterval = "step" | "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year";
1401
1422
 
1402
1423
  /** Creates a Function type. */
@@ -2468,11 +2489,25 @@ export declare interface KayAppAutomationBinding {
2468
2489
  readonly nextDueAtMs?: number;
2469
2490
  readonly expiresAtMs?: number;
2470
2491
  readonly maxRuns?: number;
2492
+ readonly concurrency?: KayAppAutomationConcurrency;
2471
2493
  readonly runCount: number;
2472
2494
  /** Why a script binding's last tick failed and paused it, when it did. */
2473
2495
  readonly scriptLastError?: string;
2474
2496
  }
2475
2497
 
2498
+ /**
2499
+ * How many of an automation's runs may be in progress at once. Absent means `sequential`: one at
2500
+ * a time, in order. `parallel` runs up to `limit` at once (1 to 32, default 4), for an automation
2501
+ * whose runs each handle their own event and can safely overlap, such as replying to separate
2502
+ * emails.
2503
+ */
2504
+ export declare type KayAppAutomationConcurrency = {
2505
+ readonly mode: "sequential";
2506
+ } | {
2507
+ readonly mode: "parallel";
2508
+ readonly limit?: number;
2509
+ };
2510
+
2476
2511
  export declare type KayAppAutomationCondition = KayAppAutomationPluginEventCondition | Extract<KayAppAutomationConditionInput, {
2477
2512
  readonly kind: "time";
2478
2513
  }> | KayAppAutomationUriChangeCondition | {
@@ -2533,10 +2568,8 @@ export declare interface KayAppAutomationContext {
2533
2568
 
2534
2569
  export declare type KayAppAutomationEffect = {
2535
2570
  /**
2536
- * STORED only: a binding created before the 2026-09-28 owner ruling (agents and plugins
2537
- * may not create `spawn-session` automations) can still carry this effect, so a read must
2538
- * still parse it. Absent from {@link KayAppAutomationEffectInput}, so no NEW binding can
2539
- * be minted with it.
2571
+ * Starts a new session each time the automation fires. Created only with
2572
+ * `owner: "user"`; the creating session's directory and project are stamped here.
2540
2573
  */
2541
2574
  readonly kind: "spawn-session";
2542
2575
  readonly prompt: string;
@@ -2561,16 +2594,20 @@ export declare type KayAppAutomationEffect = {
2561
2594
  };
2562
2595
 
2563
2596
  /**
2564
- * What a plugin may CREATE an automation with. `spawn-session` is deliberately absent: owner
2565
- * ruling (2026-09-28) forbids a plugin (or an agent) from minting a `spawn-session` binding —
2566
- * durable recurring agent work belongs to a plugin workflow (`app.workflows.define` +
2567
- * `ctx.runAgent`) or a direct `app.sessions.run`. A binding created before that ruling can still
2568
- * carry the effect and still reads and runs; see {@link KayAppAutomationEffect}, the STORED type
2569
- * this input narrows.
2597
+ * What a plugin may CREATE an automation with; {@link KayAppAutomationEffect} is the STORED type
2598
+ * this input narrows. `spawn-session` needs `owner: "user"`: an automation the creating session
2599
+ * owns is a follow-up that brings that session back, so it cannot start a new one.
2600
+ * `deliver-turn` is the reverse, session-owned only. A script the user owns references a skill
2601
+ * file (`ref: {kind: "skill-file"}`), because it has no session scripts folder.
2570
2602
  */
2571
2603
  export declare type KayAppAutomationEffectInput = {
2572
2604
  readonly kind: "deliver-turn";
2573
2605
  readonly prompt: string;
2606
+ } | {
2607
+ readonly kind: "spawn-session";
2608
+ readonly prompt: string;
2609
+ /** Resolve the new session's model by tier instead of the default. */
2610
+ readonly tier?: "small" | "medium" | "large" | "ultra";
2574
2611
  } | {
2575
2612
  readonly kind: "script";
2576
2613
  /** The file this automation runs; every stored binding carries one. */
@@ -2709,7 +2746,7 @@ export declare interface KayAppAutomationRun {
2709
2746
  readonly id: string;
2710
2747
  readonly bindingId: string;
2711
2748
  readonly logicalKey: string;
2712
- readonly status: "claimed" | "queued" | "running" | "succeeded" | "failed" | "skipped" | "abandoned";
2749
+ readonly status: "claimed" | "queued" | "running" | "succeeded" | "failed" | "skipped";
2713
2750
  readonly match: KayAppAutomationMatch;
2714
2751
  readonly generation: string;
2715
2752
  readonly claimedAtMs: number;
@@ -2783,16 +2820,17 @@ export declare type KayAppAutomationRunOutcome = {
2783
2820
  } | {
2784
2821
  readonly status: "failed";
2785
2822
  readonly summary?: KayAppRunSummary | undefined;
2786
- readonly reason: "executor_failed" | "permission_denied" | "surface_unavailable" | "target_gone";
2823
+ /**
2824
+ * Which part of the lane refused or failed. Absent on a run an earlier build recorded with
2825
+ * a reason this build no longer names; nothing is reconstructed.
2826
+ */
2827
+ readonly reason?: "executor_failed" | "permission_denied" | "surface_unavailable" | "owner_missing" | "target_missing" | "declaration_gone" | undefined;
2787
2828
  readonly message?: string | undefined;
2788
2829
  /** How many tries the run's effect took, when more than one. */
2789
2830
  readonly tries?: number | undefined;
2790
2831
  } | {
2791
2832
  readonly status: "skipped";
2792
- readonly reason: "already_running" | "binding_inactive" | "circuit_breaker" | "concurrency_capped" | "guard_not_satisfied" | "missed_window" | "timer_cancelled";
2793
- } | {
2794
- readonly status: "abandoned";
2795
- readonly reason: "daemon_restart";
2833
+ readonly reason: "already_running" | "binding_inactive" | "guard_not_satisfied" | "missed_window" | "timer_cancelled";
2796
2834
  };
2797
2835
 
2798
2836
  export declare interface KayAppAutomations {
@@ -2824,6 +2862,12 @@ export declare interface KayAppAutomations {
2824
2862
  create(input: {
2825
2863
  readonly name: string;
2826
2864
  readonly description?: string;
2865
+ /**
2866
+ * Who owns the new automation. `session` (the default) ties it to the calling session;
2867
+ * `user` makes it the person's own: it outlives that session, any session may switch it
2868
+ * off, run or delete it, and the Automations page lists it. Requires SDK 0.15.3.
2869
+ */
2870
+ readonly owner?: "session" | "user";
2827
2871
  readonly condition: KayAppAutomationConditionInput;
2828
2872
  readonly effect: KayAppAutomationEffectInput;
2829
2873
  readonly enabled?: boolean;
@@ -2831,6 +2875,7 @@ export declare interface KayAppAutomations {
2831
2875
  readonly catchUpGraceMs?: number;
2832
2876
  readonly expiresAtMs?: number;
2833
2877
  readonly maxRuns?: number;
2878
+ readonly concurrency?: KayAppAutomationConcurrency;
2834
2879
  }, ctx: KayAppAutomationContext): Promise<{
2835
2880
  readonly kind: "created";
2836
2881
  readonly binding: KayAppAutomationBinding;
@@ -3115,12 +3160,23 @@ export declare interface KayAppCorpus {
3115
3160
  */
3116
3161
  readEntries(sessionId: string): AsyncIterable<TranscriptEntry>;
3117
3162
  /**
3118
- * Read one bounded physical JSONL page. The host resolves `sessionId` to its authoritative
3119
- * indexed path and validates the opaque cursor before opening it. When `throughEntryId` is
3120
- * supplied, the cursor stops at that entry's transaction line; a V4 line may carry later
3121
- * entries, which are returned for the caller to filter and are replayed on the next page.
3122
- * A page can hold no entries at all (a run of storage lines) while more follows; a record
3123
- * longer than the page is stepped over and counted in `oversizedRecords`.
3163
+ * Active-branch entries from the latest canonical human turn opener (send companions included)
3164
+ * through the anchor, oldest first. Mid-turn steers and machine wakes remain inside that window;
3165
+ * attachment-only openers and fresh card answers count. Missing sessions/anchors return [];
3166
+ * unsupported hosts may omit it.
3167
+ * Reads never fall back to materializing the full log.
3168
+ */
3169
+ readLatestHumanWindow?(sessionId: string, options?: {
3170
+ readonly throughEntryId?: string;
3171
+ }): Promise<readonly TranscriptEntry[]>;
3172
+ /**
3173
+ * Read one bounded page of a session's stored transcript. The host resolves `sessionId` to its
3174
+ * authoritative indexed path and validates the opaque cursor before reading. When
3175
+ * `throughEntryId` is supplied, the page ends at that entry and the cursor stays at the start of
3176
+ * the commit holding it: the commit's other entries are returned for the caller to filter, and
3177
+ * the next page replays that commit. A page can hold no entries at all (storage records with no
3178
+ * entry) while more follows; a record longer than the page is stepped over and counted in
3179
+ * `oversizedRecords`.
3124
3180
  */
3125
3181
  readEntryBatch?(sessionId: string, options?: {
3126
3182
  readonly cursor?: JsonValue;
@@ -3135,7 +3191,7 @@ export declare interface KayAppCorpus {
3135
3191
  readSessionSourceMark(sessionId: string): Promise<KayAppCorpusSourceMark | undefined>;
3136
3192
  }
3137
3193
 
3138
- /** One bounded physical page from the host's incremental JSONL reader. */
3194
+ /** One bounded page from the host's stored transcript reader. */
3139
3195
  export declare interface KayAppCorpusEntryBatch {
3140
3196
  readonly entries: readonly TranscriptEntry[];
3141
3197
  /** Opaque JSON cursor after the physical page; only the host may interpret it or open its path. */
@@ -3785,11 +3841,9 @@ export declare interface KayAppPaths {
3785
3841
  *
3786
3842
  * Unlike `telemetryRoot`, this can be granted yet absent: compositions that spawn no log lane
3787
3843
  * (test and eval hosts) hand the daemon no logs directory, and the field is then omitted rather
3788
- * than guessed. Event content redaction differs by lane and configuration — the daemon lane
3789
- * omits tool content outright; the Desktop lane captures it when `observability.contentCapture`
3790
- * is on (off by default in packaged builds, on by default unpackaged — a packaged user CAN
3791
- * enable it, so never assume rows from a packaged install are content-free). Absent `content`
3792
- * on a row is the normal case.
3844
+ * than guessed. Desktop and daemon logs contain the same diagnostic facts exported to
3845
+ * PostHog; call content is never recorded. Historical files can contain private content
3846
+ * from older builds, and diagnostic errors/stacks can contain file paths.
3793
3847
  */
3794
3848
  readonly logsRoot?: string;
3795
3849
  }
@@ -3926,7 +3980,7 @@ export declare interface KayAppPluginApi {
3926
3980
  */
3927
3981
  readonly sessionEvents: KayAppSessionEvents;
3928
3982
  /**
3929
- * Grant-gated time-triggered workflow registration. Present for a plugin the host has a workflow
3983
+ * Grant-gated workflow registration, started on a time schedule or the plugin's own events. Present for a plugin the host has a workflow
3930
3984
  * namespace for; `undefined` otherwise. The first `define` asks for the `workflows.define` claim
3931
3985
  * in the user's grant ledger — no manifest request and no source-class gate — and it is decided
3932
3986
  * once `activate()` resolves: an ungranted plugin does not start until the user allows it. A
@@ -4039,6 +4093,36 @@ export declare interface KayAppPluginEvents {
4039
4093
  publish(localId: string, input: PluginEventPublishInput): void;
4040
4094
  }
4041
4095
 
4096
+ export declare interface KayAppPollerEvent {
4097
+ readonly localId: string;
4098
+ readonly input: PluginEventPublishInput;
4099
+ }
4100
+
4101
+ export declare interface KayAppPollerOptions<Cursor extends JsonValue> {
4102
+ readonly name: string;
4103
+ readonly description: string;
4104
+ /** Interval in milliseconds; the workflow engine enforces its scheduling floor. */
4105
+ readonly every: number;
4106
+ readonly serviceId: string;
4107
+ readonly schemeId?: string;
4108
+ readonly resolveCredential: (account: KayAppAccountSummary, runId: string) => Promise<KayAppBackgroundCredentialResult>;
4109
+ /** Cursor, events, and summary must contain no credentials or other secrets. */
4110
+ readonly poll: (input: {
4111
+ readonly account: KayAppAccountSummary;
4112
+ readonly cursor: Cursor | undefined;
4113
+ readonly credential: Extract<KayAppBackgroundCredentialResult, {
4114
+ readonly status: "resolved";
4115
+ }>;
4116
+ readonly runId: string;
4117
+ }) => Promise<KayAppPollResult<Cursor>>;
4118
+ }
4119
+
4120
+ export declare interface KayAppPollResult<Cursor extends JsonValue> {
4121
+ readonly cursor: Cursor;
4122
+ readonly events?: readonly KayAppPollerEvent[];
4123
+ readonly summary?: string;
4124
+ }
4125
+
4042
4126
  export declare type KayAppProcessingSpeed = "standard" | "fast";
4043
4127
 
4044
4128
  /**
@@ -4482,6 +4566,17 @@ export declare type KayAppSessionRunCompletion = {
4482
4566
  /** Provider-neutral recorded classification; an unclassified failure omits the field. */
4483
4567
  export declare type KayAppSessionRunFailureReason = Exclude<RunFailureReason, "unknown">;
4484
4568
 
4569
+ /**
4570
+ * The identity of a failed run's retained failure: the same ref the runtime keeps on the
4571
+ * session and the automation run. A workflow that fails BECAUSE this run failed passes it as
4572
+ * its error's `cause` (`{ cause: { failureRef } }`), and the host reports that failure, not a
4573
+ * guess from whichever run settled last.
4574
+ */
4575
+ export declare interface KayAppSessionRunFailureRef {
4576
+ readonly authority: string;
4577
+ readonly id: string;
4578
+ }
4579
+
4485
4580
  /** One host-tool name in a one-shot system run's explicit ceiling. */
4486
4581
  export declare type KayAppSessionRunHostToolName = string;
4487
4582
 
@@ -4568,6 +4663,8 @@ export declare interface KayAppSessionRunInput {
4568
4663
 
4569
4664
  export declare type KayAppSessionRunOutcome = (KayAppSessionRunBase & {
4570
4665
  readonly state: "failed";
4666
+ /** The retained failure's identity, when the runtime kept one for this run. */
4667
+ readonly failureRef?: KayAppSessionRunFailureRef | undefined;
4571
4668
  /** Present when the runtime could classify the failure. */
4572
4669
  readonly failureReason?: KayAppSessionRunFailureReason | undefined;
4573
4670
  /** Bounded provider-suggested delay before retrying this terminal failure. */
@@ -6009,14 +6106,13 @@ export declare interface KayAppWhiteboardTypes {
6009
6106
  * - **Do not hold state in module scope and expect it to survive.** A recovery may happen in a
6010
6107
  * different process. Anything you need later belongs in a step's return value.
6011
6108
  */
6012
- export declare interface KayAppWorkflowContext {
6109
+ export declare interface KayAppWorkflowContext<Trigger extends KayAppWorkflowTrigger = KayAppWorkflowTimeTrigger> {
6013
6110
  /** State from the last successful run; undefined until a run saves it. */
6014
6111
  readonly state: JsonValue | undefined;
6015
6112
  readonly automationId: string;
6016
6113
  readonly runId: string;
6017
- readonly match: Extract<KayAppAutomationMatch, {
6018
- readonly kind: "time" | "manual";
6019
- }>;
6114
+ /** What started this run; see {@link KayAppWorkflowMatch}. */
6115
+ readonly match: KayAppWorkflowMatch<Trigger>;
6020
6116
  /**
6021
6117
  * Record a step's result for replay.
6022
6118
  *
@@ -6074,17 +6170,23 @@ export declare interface KayAppWorkflowContext {
6074
6170
  runAgent(agent: KayAppAgentDefinitionRef, input: Omit<KayAppSessionRunInput, "agent">): Promise<KayAppSessionRunOutcome>;
6075
6171
  }
6076
6172
 
6077
- export declare interface KayAppWorkflowDefinition {
6173
+ export declare interface KayAppWorkflowDefinition<Trigger extends KayAppWorkflowTrigger = KayAppWorkflowTimeTrigger> {
6078
6174
  readonly name: string;
6079
6175
  /** Plain-text purpose, at most 280 characters. */
6080
6176
  readonly description: string;
6081
6177
  readonly instructions?: readonly KayAppWorkflowInstruction[];
6082
6178
  readonly perRunNote?: string;
6083
- readonly trigger: Extract<KayAppAutomationConditionInput, {
6084
- readonly kind: "time";
6085
- }>;
6086
- readonly run: (context: KayAppWorkflowContext) => Promise<{
6087
- /** Replacement JSON state, at most 64 KiB; omission keeps the previous value. */
6179
+ readonly trigger: Trigger;
6180
+ /**
6181
+ * How many runs may be in progress at once. Absent means `sequential`. A `parallel` workflow
6182
+ * suits an event trigger whose runs each handle their own event; it cannot return `state`.
6183
+ */
6184
+ readonly concurrency?: KayAppAutomationConcurrency;
6185
+ readonly run: (context: KayAppWorkflowContext<Trigger>) => Promise<{
6186
+ /**
6187
+ * Replacement JSON state, at most 64 KiB; omission keeps the previous value. Only a
6188
+ * sequential workflow may return it: a `parallel` run that does fails.
6189
+ */
6088
6190
  readonly state?: JsonValue | undefined;
6089
6191
  readonly summary: KayAppRunSummary;
6090
6192
  readonly produced?: KayAppRunProduced;
@@ -6092,6 +6194,16 @@ export declare interface KayAppWorkflowDefinition {
6092
6194
  }>;
6093
6195
  }
6094
6196
 
6197
+ /**
6198
+ * The event that started a run, as the publisher sent it. The publishing session is withheld.
6199
+ * This is the run's private input, so it carries `payload`, `related` and `key`, which the
6200
+ * public run history's event identity leaves out.
6201
+ */
6202
+ export declare type KayAppWorkflowEvent = Readonly<Omit<PluginEventEnvelope, "related" | "source">> & {
6203
+ readonly related?: Readonly<Record<string, string | readonly string[]>> | undefined;
6204
+ readonly source: Readonly<Omit<PluginEventEnvelope["source"], "sessionId">>;
6205
+ };
6206
+
6095
6207
  /** Fail a workflow while retaining its own explanation beside this attempt. */
6096
6208
  export declare class KayAppWorkflowFailure extends Error {
6097
6209
  readonly summary: KayAppRunSummary;
@@ -6123,11 +6235,43 @@ export declare type KayAppWorkflowInstruction = {
6123
6235
  readonly ref: KayAppAutomationScriptRef;
6124
6236
  };
6125
6237
 
6238
+ /**
6239
+ * What started a run, by trigger: a time workflow sees `time`, an event workflow sees
6240
+ * `plugin-event`, and either sees `manual` for Run now and retries. A retry, even of an event run,
6241
+ * arrives as `manual` without the event.
6242
+ */
6243
+ export declare type KayAppWorkflowMatch<Trigger extends KayAppWorkflowTrigger = KayAppWorkflowTimeTrigger> = Extract<KayAppAutomationMatch, {
6244
+ readonly kind: "manual";
6245
+ }> | (Trigger extends {
6246
+ readonly kind: "plugin-event";
6247
+ } ? {
6248
+ readonly kind: "plugin-event";
6249
+ readonly event: KayAppWorkflowEvent;
6250
+ } : Extract<KayAppAutomationMatch, {
6251
+ readonly kind: "time";
6252
+ }>);
6253
+
6126
6254
  export declare interface KayAppWorkflows {
6127
- define(localId: string, definition: KayAppWorkflowDefinition): void;
6255
+ define<Trigger extends KayAppWorkflowTrigger>(localId: string, definition: KayAppWorkflowDefinition<Trigger>): void;
6128
6256
  inspect(localId: string, options?: KayAppWorkflowInspectOptions): Promise<KayAppWorkflowInspection>;
6129
6257
  }
6130
6258
 
6259
+ export declare type KayAppWorkflowTimeTrigger = Extract<KayAppAutomationConditionInput, {
6260
+ readonly kind: "time";
6261
+ }>;
6262
+
6263
+ /**
6264
+ * What starts a workflow: a time schedule, or one or more of this plugin's own declared events.
6265
+ *
6266
+ * An event trigger names full event types (`google.gmail.message.received`) and takes the same
6267
+ * filters as a `plugin-event` automation. Each matching event starts one run. Only events this
6268
+ * plugin declares are accepted; another plugin's events are refused at `define`.
6269
+ *
6270
+ * A run is not started by an event that one of this workflow's own runs published, as long as the
6271
+ * publish names the run: pass `source: { runId: ctx.runId }` (the Poller helper does).
6272
+ */
6273
+ export declare type KayAppWorkflowTrigger = KayAppWorkflowTimeTrigger | KayAppAutomationPluginEventCondition;
6274
+
6131
6275
  /**
6132
6276
  * Read/arrange access to the live desktop workspace (tabs, panes, the shell chrome). Always
6133
6277
  * present. `snapshot` is ungated; `execute` is checked per call against the `workspace.command`
@@ -6534,13 +6678,7 @@ declare interface MessageEntry extends EntryBase {
6534
6678
  /** TypeBox instantiation metrics */
6535
6679
  declare const Metrics: TMetrics;
6536
6680
 
6537
- /**
6538
- * A hidden kernel statement delivered before resuming a tool-requested compaction stop.
6539
- *
6540
- * Module-local, unlike every sibling above it: this message is never rendered and never matched
6541
- * by name outside this file, so exporting the string would only publish something no surface
6542
- * consumes. It earns an export the day one needs to recognise it.
6543
- */
6681
+ /** A hidden kernel statement delivered before resuming a tool-requested compaction stop. */
6544
6682
  declare const MID_TURN_COMPACTION_OUTCOME_CUSTOM_TYPE = "mid_turn_compaction_outcome";
6545
6683
 
6546
6684
  /**
@@ -7705,9 +7843,37 @@ declare function ReturnType_2<Type extends TSchema>(type: Type, options?: TSchem
7705
7843
  /** Creates a deferred ReturnType action. */
7706
7844
  declare function ReturnTypeDeferred<Type extends TSchema>(type: Type, options?: TSchemaOptions): TReturnTypeDeferred<Type>;
7707
7845
 
7846
+ /**
7847
+ * The hidden message a continued run rides as its admission ticket (a mid-turn compaction
7848
+ * resume, a run-recovery re-drive). The engine writes it; this package's placement rows keep it
7849
+ * out of the canonical transcript.
7850
+ */
7851
+ declare const RUN_CONTINUATION_CARRIER_CUSTOM_TYPE = "herd_run_continuation";
7852
+
7708
7853
  /** Observed cause of a failed request or interrupted run. */
7709
7854
  declare const RUN_FAILURE_REASONS: readonly ["auth", "cancelled", "content_blocked", "context_overflow", "invalid_request", "model_disabled", "model_unavailable", "network", "organization_unavailable", "overloaded", "quota_exhausted", "rate_limit", "runtime_interrupted", "safeguard_block", "seat_unpaid", "server_error", "sign_in_required", "stream_interrupted", "timeout", "unknown"];
7710
7855
 
7856
+ /**
7857
+ * What a {@link RUN_CONTINUATION_CARRIER_CUSTOM_TYPE} carrier records about the failed turns it
7858
+ * continues.
7859
+ */
7860
+ declare interface RunContinuationCarrierDetails {
7861
+ readonly provenance: {
7862
+ readonly source: "core";
7863
+ };
7864
+ /**
7865
+ * Visible text the failed turns since the previous carrier streamed before they died. Absent
7866
+ * when they showed none (thinking, an unexecuted tool call, or a thrown attempt): such a
7867
+ * carrier is plain.
7868
+ */
7869
+ readonly shownText?: string;
7870
+ }
7871
+
7872
+ declare type RunContinuationCarrierMessage = CustomMessage<RunContinuationCarrierDetails> & {
7873
+ readonly customType: typeof RUN_CONTINUATION_CARRIER_CUSTOM_TYPE;
7874
+ readonly display: false;
7875
+ };
7876
+
7711
7877
  declare type RunFailureReason = (typeof RUN_FAILURE_REASONS)[number];
7712
7878
 
7713
7879
  /**