@cadraos/sdk 0.3.14-p46.3 → 0.3.14
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 +104 -53
- package/dist/ai-functions/react/index.cjs +176 -0
- package/dist/ai-functions/react/index.cjs.map +1 -0
- package/dist/ai-functions/react/index.d.cts +129 -0
- package/dist/ai-functions/react/index.d.ts +129 -0
- package/dist/ai-functions/react/index.js +153 -0
- package/dist/ai-functions/react/index.js.map +1 -0
- package/dist/ai-functions/server/index.cjs +296 -0
- package/dist/ai-functions/server/index.cjs.map +1 -0
- package/dist/ai-functions/server/index.d.cts +334 -0
- package/dist/ai-functions/server/index.d.ts +334 -0
- package/dist/ai-functions/server/index.js +284 -0
- package/dist/ai-functions/server/index.js.map +1 -0
- package/dist/board-host/index.cjs +217 -129
- package/dist/board-host/index.cjs.map +1 -1
- package/dist/board-host/index.d.cts +96 -1
- package/dist/board-host/index.d.ts +96 -1
- package/dist/board-host/index.js +218 -131
- package/dist/board-host/index.js.map +1 -1
- package/dist/board-host/server/index.d.cts +44 -0
- package/dist/board-host/server/index.d.ts +44 -0
- package/dist/chat/index.cjs +299 -17
- package/dist/chat/index.cjs.map +1 -1
- package/dist/chat/index.d.cts +225 -0
- package/dist/chat/index.d.ts +225 -0
- package/dist/chat/index.js +299 -17
- package/dist/chat/index.js.map +1 -1
- package/dist/index.cjs +221 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +286 -1
- package/dist/index.d.ts +286 -1
- package/dist/index.js +215 -4
- package/dist/index.js.map +1 -1
- package/dist/kanban/engine/index.cjs +774 -683
- package/dist/kanban/engine/index.cjs.map +1 -1
- package/dist/kanban/engine/index.d.cts +90 -1
- package/dist/kanban/engine/index.d.ts +90 -1
- package/dist/kanban/engine/index.js +774 -684
- package/dist/kanban/engine/index.js.map +1 -1
- package/dist/kanban/index.cjs +214 -3
- package/dist/kanban/index.cjs.map +1 -1
- package/dist/kanban/index.d.cts +252 -0
- package/dist/kanban/index.d.ts +252 -0
- package/dist/kanban/index.js +214 -3
- package/dist/kanban/index.js.map +1 -1
- package/dist/teams/index.cjs +214 -3
- package/dist/teams/index.cjs.map +1 -1
- package/dist/teams/index.d.cts +225 -0
- package/dist/teams/index.d.ts +225 -0
- package/dist/teams/index.js +214 -3
- package/dist/teams/index.js.map +1 -1
- package/package.json +21 -1
|
@@ -316,6 +316,11 @@ interface KanbanCard {
|
|
|
316
316
|
configVersion?: number;
|
|
317
317
|
/** Arbitrary shared context carried across transitions. */
|
|
318
318
|
sharedContext?: Record<string, unknown>;
|
|
319
|
+
/**
|
|
320
|
+
* p46 (P46-002): the card's id in an external host (a Jira issue key).
|
|
321
|
+
* Absent on native / crm / yobo cards.
|
|
322
|
+
*/
|
|
323
|
+
externalRef?: string;
|
|
319
324
|
/**
|
|
320
325
|
* Execution UUID of the card's current/last run, if any.
|
|
321
326
|
*
|
|
@@ -378,6 +383,18 @@ interface CreateCardInput {
|
|
|
378
383
|
* in the lifecycle's initial lane.
|
|
379
384
|
*/
|
|
380
385
|
lane?: string;
|
|
386
|
+
/**
|
|
387
|
+
* p46 (P46-002): the card's id in an EXTERNAL host (a Jira issue key, e.g.
|
|
388
|
+
* `CAD-231`). Optional. When set, a card is created at most ONCE per
|
|
389
|
+
* `(boardConfigUuid, externalRef)`: a repeat create returns the existing card
|
|
390
|
+
* and dispatches nothing. Hosts that don't store it simply ignore it.
|
|
391
|
+
*/
|
|
392
|
+
externalRef?: string;
|
|
393
|
+
/**
|
|
394
|
+
* p46 (P46-002): opaque host facts stored with the card (Jira `statusId`,
|
|
395
|
+
* `mover`, `detached`, …). Passed through to `adapter.createCard` untouched.
|
|
396
|
+
*/
|
|
397
|
+
externalMeta?: Record<string, unknown>;
|
|
381
398
|
}
|
|
382
399
|
/**
|
|
383
400
|
* Who performed a transition / stage-run (server-engine side).
|
|
@@ -495,6 +512,23 @@ interface ApplyTransitionInput {
|
|
|
495
512
|
contextPatch?: Record<string, unknown>;
|
|
496
513
|
/** Execution UUID to stamp on the card (handler advances). */
|
|
497
514
|
executionUuid?: string;
|
|
515
|
+
/**
|
|
516
|
+
* p46 (P46-002, F8): set ONLY by `engine.hostMove` (a move the external host
|
|
517
|
+
* made — e.g. a Jira drag mirrored by the sync). A host-aware adapter, inside
|
|
518
|
+
* the same card lock as the `fromLane` CAS, (1) refuses the move with a
|
|
519
|
+
* `HostFenceError` while the card has any `host.*` op `pending` (D19 — never
|
|
520
|
+
* mistake our own half-done move for a human one), (2) writes `externalMeta`,
|
|
521
|
+
* then (3) moves. Adapters that don't know it ignore it (optional, additive).
|
|
522
|
+
*/
|
|
523
|
+
hostObservation?: {
|
|
524
|
+
externalMeta?: Record<string, unknown>;
|
|
525
|
+
/**
|
|
526
|
+
* ISO time the host state was READ. The fence also refuses the move when a
|
|
527
|
+
* `host.*` op for the card settled (done/failed) after this instant — the
|
|
528
|
+
* read may predate our own write landing in the host.
|
|
529
|
+
*/
|
|
530
|
+
observedAt?: string;
|
|
531
|
+
};
|
|
498
532
|
}
|
|
499
533
|
|
|
500
534
|
/**
|
|
@@ -866,6 +900,16 @@ interface KanbanStorageAdapter {
|
|
|
866
900
|
* config and passes it as `initialLane`.
|
|
867
901
|
*/
|
|
868
902
|
createCard(input: CreateCardServerInput): Promise<KanbanCard>;
|
|
903
|
+
/**
|
|
904
|
+
* p46 (P46-002) OPTIONAL: the card with this `externalRef` on this board, or
|
|
905
|
+
* null. When present, `engine.createCard({externalRef})` looks it up first and
|
|
906
|
+
* returns an existing card WITHOUT dispatching (exactly-once create per issue
|
|
907
|
+
* key). A host that stores `externalRef` SHOULD also make `createCard` itself
|
|
908
|
+
* idempotent on `(boardConfigUuid, externalRef)` (unique index + `ON CONFLICT
|
|
909
|
+
* DO NOTHING` → return the existing row) for the lookup/insert race. Hosts
|
|
910
|
+
* without external refs (crm/yobo) omit it.
|
|
911
|
+
*/
|
|
912
|
+
getCardByExternalRef?(boardConfigUuid: string, externalRef: string): Promise<KanbanCard | null>;
|
|
869
913
|
/**
|
|
870
914
|
* Patch a card's mutable fields.
|
|
871
915
|
*/
|
|
@@ -1632,6 +1676,16 @@ declare class TransitionConflictError extends Error {
|
|
|
1632
1676
|
readonly code = "transition_conflict";
|
|
1633
1677
|
constructor(message?: string);
|
|
1634
1678
|
}
|
|
1679
|
+
/**
|
|
1680
|
+
* p46 (P46-002, D19/F8): thrown by a host-aware adapter's `applyTransition`
|
|
1681
|
+
* when a HOST move (`move.hostObservation` set) targets a card that still has
|
|
1682
|
+
* a `host.*` outbox op `pending` — Cadra's own half-done write to the host must
|
|
1683
|
+
* never be mistaken for a human move. The sync skips the card this pass.
|
|
1684
|
+
*/
|
|
1685
|
+
declare class HostFenceError extends Error {
|
|
1686
|
+
readonly code = "host_fence";
|
|
1687
|
+
constructor(message?: string);
|
|
1688
|
+
}
|
|
1635
1689
|
/**
|
|
1636
1690
|
* Thrown by `listDueCards` when a `DueRule.kind` is not in the closed
|
|
1637
1691
|
* vocabulary (design §6 — fail closed; never silently return everything).
|
|
@@ -1650,11 +1704,15 @@ interface InMemoryOp {
|
|
|
1650
1704
|
status: "pending" | "done" | "failed";
|
|
1651
1705
|
attempts: number;
|
|
1652
1706
|
lastError?: string;
|
|
1707
|
+
/** ISO time the op reached `done`/`failed` (p46 P46-002 host fence). */
|
|
1708
|
+
settledAt?: string;
|
|
1653
1709
|
}
|
|
1654
1710
|
declare class InMemoryStorageAdapter implements KanbanStorageAdapter {
|
|
1655
1711
|
private cards;
|
|
1656
1712
|
private logs;
|
|
1657
1713
|
private runs;
|
|
1714
|
+
/** Lane KEY the card was in when each run was (re)claimed (idemKey → lane). */
|
|
1715
|
+
private runLanes;
|
|
1658
1716
|
private handoffs;
|
|
1659
1717
|
private ops;
|
|
1660
1718
|
private handoffSeq;
|
|
@@ -1681,6 +1739,7 @@ declare class InMemoryStorageAdapter implements KanbanStorageAdapter {
|
|
|
1681
1739
|
});
|
|
1682
1740
|
listCards(boardConfigUuid: string): Promise<KanbanCard[]>;
|
|
1683
1741
|
getCard(cardId: string): Promise<KanbanCard | null>;
|
|
1742
|
+
getCardByExternalRef(boardConfigUuid: string, externalRef: string): Promise<KanbanCard | null>;
|
|
1684
1743
|
createCard(input: CreateCardServerInput): Promise<KanbanCard>;
|
|
1685
1744
|
updateCard(cardId: string, patch: {
|
|
1686
1745
|
title?: string;
|
|
@@ -1702,6 +1761,7 @@ declare class InMemoryStorageAdapter implements KanbanStorageAdapter {
|
|
|
1702
1761
|
created: boolean;
|
|
1703
1762
|
run: StageRun;
|
|
1704
1763
|
}>;
|
|
1764
|
+
private recordRunLane;
|
|
1705
1765
|
/**
|
|
1706
1766
|
* A stranded stage-run the next `beginStageRun` may re-claim (design §10): a
|
|
1707
1767
|
* `failed` run (dispatch threw), or a `queued` run older than `staleQueuedMs`
|
|
@@ -2384,9 +2444,38 @@ interface BatchCompleteResult {
|
|
|
2384
2444
|
*/
|
|
2385
2445
|
noop: number;
|
|
2386
2446
|
}
|
|
2447
|
+
/** Options for {@link KanbanEngine.hostMove} (p46 P46-002, D22 + F8). */
|
|
2448
|
+
interface HostMoveOptions {
|
|
2449
|
+
/**
|
|
2450
|
+
* The lane the HOST SYNC observed the card in at the start of its pass. The
|
|
2451
|
+
* move is a CAS on it — never a re-read: a Cadra move committed between the
|
|
2452
|
+
* sync's read and this apply makes the move fail (`TransitionConflictError`)
|
|
2453
|
+
* instead of silently moving the card back.
|
|
2454
|
+
*/
|
|
2455
|
+
expectedFromLane: string;
|
|
2456
|
+
/** Host facts written with the move inside the adapter's card lock. */
|
|
2457
|
+
externalMeta?: Record<string, unknown>;
|
|
2458
|
+
/**
|
|
2459
|
+
* ISO time the sync READ the host state. The adapter fence then also refuses
|
|
2460
|
+
* the move if a `host.*` op for this card settled after it (our own write may
|
|
2461
|
+
* have landed after the read). Strongly recommended for a polling sync.
|
|
2462
|
+
*/
|
|
2463
|
+
observedAt?: string;
|
|
2464
|
+
}
|
|
2387
2465
|
interface KanbanEngine {
|
|
2388
2466
|
createCard(boardConfigUuid: string, input: CreateCardInput): Promise<KanbanCard>;
|
|
2389
2467
|
transition(cardId: string, toLane?: string, actor?: Actor): Promise<KanbanCard>;
|
|
2468
|
+
/**
|
|
2469
|
+
* p46 (P46-002, D22 + F8): mirror a move the EXTERNAL host made (a Jira drag)
|
|
2470
|
+
* — the host owns the column, so NO manual edge is required. Keeps the CAS on
|
|
2471
|
+
* `expectedFromLane`, logs `transitionId` = the matching edge id (any
|
|
2472
|
+
* trigger) else `host:<from>-><to>`, passes `hostObservation` (the adapter's
|
|
2473
|
+
* D19 fence + `externalMeta` write), writes `human_to_ai` on a
|
|
2474
|
+
* non-automated → automated move (D5), and dispatches on entry.
|
|
2475
|
+
* `toLane === card.lane` → no-op returning the card. Unknown lane → throws.
|
|
2476
|
+
* Actor for Jira: `{ type: "system", id: "host:jira" }`.
|
|
2477
|
+
*/
|
|
2478
|
+
hostMove(cardId: string, toLane: string, actor: Actor, opts: HostMoveOptions): Promise<KanbanCard>;
|
|
2390
2479
|
runStage(cardId: string, stageId: string): Promise<{
|
|
2391
2480
|
dispatched: boolean;
|
|
2392
2481
|
executionUuid?: string;
|
|
@@ -2463,4 +2552,4 @@ interface KanbanLedgerEngine extends KanbanEngine {
|
|
|
2463
2552
|
}
|
|
2464
2553
|
declare function createEngine(options: CreateEngineOptions): KanbanLedgerEngine;
|
|
2465
2554
|
|
|
2466
|
-
export { ANSWERABLE_HANDOFF_KINDS, type Actor, type AdapterCapabilities, type AdapterFactory, type ApplyTransitionInput, type BatchCardCompletion, type BatchCardContext, type BatchCompleteResult, type BatchDispatchMeta, BoardConfigClient, type BoardConfigClientOptions, type BoardConfigHttp, CadraLifecycleSource, type CadraRunClient, CapabilitiesNotLoadedError, ConductorUnsupportedError, type ConformanceExpect, type ConformanceRunner, type CreateCardServerInput, type CreateEngineOptions, DEFAULT_BOARD_CEILING, type DueRule, type ExampleHostOptions, type FetchLike, HANDOFF_ANSWER_MAX_TEXT, HANDOFF_OUTPUT_MAX_BYTES, HANDOFF_PROMPT_PREAMBLE, HANDOFF_VERDICT_JSON_SCHEMA, HANDOFF_VERDICT_TASK_SUFFIX, type HandlerContext, type HandlerDispatchResult, type HandoffAnswer, HandoffAnswerError, type HandoffAnswerErrorCode, type HandoffDecision, type HandoffKind, type HandoffLedgerAdapter, type HandoffOption, type HandoffRecord, type HandoffState, type HandoffStatus, type HandoffV1, type HandoffVerdict, type HandoffVerdictKind, type HostRequest, type HostResponse, HttpAdapterError, HttpStorageAdapter, type HttpStorageAdapterConfig, type InMemoryOp, InMemoryStorageAdapter, type KanbanEngine, type KanbanLaneDispatch, type KanbanLaneHandoffMode, type KanbanLaneTrigger, type KanbanLedgerEngine, type KanbanStorageAdapter, type LaneHealth, type LaneHealthCheck, type LaneHealthReason, type LaneHealthState, type LifecycleRef, type LifecycleSource, type LifecycleSourceKind, NotScheduledLaneError, type ParseHandoffVerdictResult, type ResolveLifecycleRef, type ResolvedBoardConfig, type ResolvedLifecycle, type RunAgentInput, type RunDueStagesSummary, type RunRemoteAgentInput, type RunResult, type RunTeamInput, type Stage, type StageRun, type StageRunLedgerWrite, type StageRunStatus, type Transition, TransitionConflictError, type TransitionLogEntry, UnknownDueRuleError, WebhookDeliveryError, type WebhookDeliveryOptions, type WebhookSecret, createEngine, deliverWebhook, dispatchStageHandler, exampleHostHandler, hasHandoffLedger, hmacSign, isSafeHandoffUrl, mapDefinitionToBoard, parseHandoffVerdict, renderHandoffForPrompt, resolveAutoEdge, resolveManualEdge, runAdapterConformance, startExampleHost, toResolvedLifecycle };
|
|
2555
|
+
export { ANSWERABLE_HANDOFF_KINDS, type Actor, type AdapterCapabilities, type AdapterFactory, type ApplyTransitionInput, type BatchCardCompletion, type BatchCardContext, type BatchCompleteResult, type BatchDispatchMeta, BoardConfigClient, type BoardConfigClientOptions, type BoardConfigHttp, CadraLifecycleSource, type CadraRunClient, CapabilitiesNotLoadedError, ConductorUnsupportedError, type ConformanceExpect, type ConformanceRunner, type CreateCardServerInput, type CreateEngineOptions, DEFAULT_BOARD_CEILING, type DueRule, type ExampleHostOptions, type FetchLike, HANDOFF_ANSWER_MAX_TEXT, HANDOFF_OUTPUT_MAX_BYTES, HANDOFF_PROMPT_PREAMBLE, HANDOFF_VERDICT_JSON_SCHEMA, HANDOFF_VERDICT_TASK_SUFFIX, type HandlerContext, type HandlerDispatchResult, type HandoffAnswer, HandoffAnswerError, type HandoffAnswerErrorCode, type HandoffDecision, type HandoffKind, type HandoffLedgerAdapter, type HandoffOption, type HandoffRecord, type HandoffState, type HandoffStatus, type HandoffV1, type HandoffVerdict, type HandoffVerdictKind, HostFenceError, type HostMoveOptions, type HostRequest, type HostResponse, HttpAdapterError, HttpStorageAdapter, type HttpStorageAdapterConfig, type InMemoryOp, InMemoryStorageAdapter, type KanbanEngine, type KanbanLaneDispatch, type KanbanLaneHandoffMode, type KanbanLaneTrigger, type KanbanLedgerEngine, type KanbanStorageAdapter, type LaneHealth, type LaneHealthCheck, type LaneHealthReason, type LaneHealthState, type LifecycleRef, type LifecycleSource, type LifecycleSourceKind, NotScheduledLaneError, type ParseHandoffVerdictResult, type ResolveLifecycleRef, type ResolvedBoardConfig, type ResolvedLifecycle, type RunAgentInput, type RunDueStagesSummary, type RunRemoteAgentInput, type RunResult, type RunTeamInput, type Stage, type StageRun, type StageRunLedgerWrite, type StageRunStatus, type Transition, TransitionConflictError, type TransitionLogEntry, UnknownDueRuleError, WebhookDeliveryError, type WebhookDeliveryOptions, type WebhookSecret, createEngine, deliverWebhook, dispatchStageHandler, exampleHostHandler, hasHandoffLedger, hmacSign, isSafeHandoffUrl, mapDefinitionToBoard, parseHandoffVerdict, renderHandoffForPrompt, resolveAutoEdge, resolveManualEdge, runAdapterConformance, startExampleHost, toResolvedLifecycle };
|
|
@@ -316,6 +316,11 @@ interface KanbanCard {
|
|
|
316
316
|
configVersion?: number;
|
|
317
317
|
/** Arbitrary shared context carried across transitions. */
|
|
318
318
|
sharedContext?: Record<string, unknown>;
|
|
319
|
+
/**
|
|
320
|
+
* p46 (P46-002): the card's id in an external host (a Jira issue key).
|
|
321
|
+
* Absent on native / crm / yobo cards.
|
|
322
|
+
*/
|
|
323
|
+
externalRef?: string;
|
|
319
324
|
/**
|
|
320
325
|
* Execution UUID of the card's current/last run, if any.
|
|
321
326
|
*
|
|
@@ -378,6 +383,18 @@ interface CreateCardInput {
|
|
|
378
383
|
* in the lifecycle's initial lane.
|
|
379
384
|
*/
|
|
380
385
|
lane?: string;
|
|
386
|
+
/**
|
|
387
|
+
* p46 (P46-002): the card's id in an EXTERNAL host (a Jira issue key, e.g.
|
|
388
|
+
* `CAD-231`). Optional. When set, a card is created at most ONCE per
|
|
389
|
+
* `(boardConfigUuid, externalRef)`: a repeat create returns the existing card
|
|
390
|
+
* and dispatches nothing. Hosts that don't store it simply ignore it.
|
|
391
|
+
*/
|
|
392
|
+
externalRef?: string;
|
|
393
|
+
/**
|
|
394
|
+
* p46 (P46-002): opaque host facts stored with the card (Jira `statusId`,
|
|
395
|
+
* `mover`, `detached`, …). Passed through to `adapter.createCard` untouched.
|
|
396
|
+
*/
|
|
397
|
+
externalMeta?: Record<string, unknown>;
|
|
381
398
|
}
|
|
382
399
|
/**
|
|
383
400
|
* Who performed a transition / stage-run (server-engine side).
|
|
@@ -495,6 +512,23 @@ interface ApplyTransitionInput {
|
|
|
495
512
|
contextPatch?: Record<string, unknown>;
|
|
496
513
|
/** Execution UUID to stamp on the card (handler advances). */
|
|
497
514
|
executionUuid?: string;
|
|
515
|
+
/**
|
|
516
|
+
* p46 (P46-002, F8): set ONLY by `engine.hostMove` (a move the external host
|
|
517
|
+
* made — e.g. a Jira drag mirrored by the sync). A host-aware adapter, inside
|
|
518
|
+
* the same card lock as the `fromLane` CAS, (1) refuses the move with a
|
|
519
|
+
* `HostFenceError` while the card has any `host.*` op `pending` (D19 — never
|
|
520
|
+
* mistake our own half-done move for a human one), (2) writes `externalMeta`,
|
|
521
|
+
* then (3) moves. Adapters that don't know it ignore it (optional, additive).
|
|
522
|
+
*/
|
|
523
|
+
hostObservation?: {
|
|
524
|
+
externalMeta?: Record<string, unknown>;
|
|
525
|
+
/**
|
|
526
|
+
* ISO time the host state was READ. The fence also refuses the move when a
|
|
527
|
+
* `host.*` op for the card settled (done/failed) after this instant — the
|
|
528
|
+
* read may predate our own write landing in the host.
|
|
529
|
+
*/
|
|
530
|
+
observedAt?: string;
|
|
531
|
+
};
|
|
498
532
|
}
|
|
499
533
|
|
|
500
534
|
/**
|
|
@@ -866,6 +900,16 @@ interface KanbanStorageAdapter {
|
|
|
866
900
|
* config and passes it as `initialLane`.
|
|
867
901
|
*/
|
|
868
902
|
createCard(input: CreateCardServerInput): Promise<KanbanCard>;
|
|
903
|
+
/**
|
|
904
|
+
* p46 (P46-002) OPTIONAL: the card with this `externalRef` on this board, or
|
|
905
|
+
* null. When present, `engine.createCard({externalRef})` looks it up first and
|
|
906
|
+
* returns an existing card WITHOUT dispatching (exactly-once create per issue
|
|
907
|
+
* key). A host that stores `externalRef` SHOULD also make `createCard` itself
|
|
908
|
+
* idempotent on `(boardConfigUuid, externalRef)` (unique index + `ON CONFLICT
|
|
909
|
+
* DO NOTHING` → return the existing row) for the lookup/insert race. Hosts
|
|
910
|
+
* without external refs (crm/yobo) omit it.
|
|
911
|
+
*/
|
|
912
|
+
getCardByExternalRef?(boardConfigUuid: string, externalRef: string): Promise<KanbanCard | null>;
|
|
869
913
|
/**
|
|
870
914
|
* Patch a card's mutable fields.
|
|
871
915
|
*/
|
|
@@ -1632,6 +1676,16 @@ declare class TransitionConflictError extends Error {
|
|
|
1632
1676
|
readonly code = "transition_conflict";
|
|
1633
1677
|
constructor(message?: string);
|
|
1634
1678
|
}
|
|
1679
|
+
/**
|
|
1680
|
+
* p46 (P46-002, D19/F8): thrown by a host-aware adapter's `applyTransition`
|
|
1681
|
+
* when a HOST move (`move.hostObservation` set) targets a card that still has
|
|
1682
|
+
* a `host.*` outbox op `pending` — Cadra's own half-done write to the host must
|
|
1683
|
+
* never be mistaken for a human move. The sync skips the card this pass.
|
|
1684
|
+
*/
|
|
1685
|
+
declare class HostFenceError extends Error {
|
|
1686
|
+
readonly code = "host_fence";
|
|
1687
|
+
constructor(message?: string);
|
|
1688
|
+
}
|
|
1635
1689
|
/**
|
|
1636
1690
|
* Thrown by `listDueCards` when a `DueRule.kind` is not in the closed
|
|
1637
1691
|
* vocabulary (design §6 — fail closed; never silently return everything).
|
|
@@ -1650,11 +1704,15 @@ interface InMemoryOp {
|
|
|
1650
1704
|
status: "pending" | "done" | "failed";
|
|
1651
1705
|
attempts: number;
|
|
1652
1706
|
lastError?: string;
|
|
1707
|
+
/** ISO time the op reached `done`/`failed` (p46 P46-002 host fence). */
|
|
1708
|
+
settledAt?: string;
|
|
1653
1709
|
}
|
|
1654
1710
|
declare class InMemoryStorageAdapter implements KanbanStorageAdapter {
|
|
1655
1711
|
private cards;
|
|
1656
1712
|
private logs;
|
|
1657
1713
|
private runs;
|
|
1714
|
+
/** Lane KEY the card was in when each run was (re)claimed (idemKey → lane). */
|
|
1715
|
+
private runLanes;
|
|
1658
1716
|
private handoffs;
|
|
1659
1717
|
private ops;
|
|
1660
1718
|
private handoffSeq;
|
|
@@ -1681,6 +1739,7 @@ declare class InMemoryStorageAdapter implements KanbanStorageAdapter {
|
|
|
1681
1739
|
});
|
|
1682
1740
|
listCards(boardConfigUuid: string): Promise<KanbanCard[]>;
|
|
1683
1741
|
getCard(cardId: string): Promise<KanbanCard | null>;
|
|
1742
|
+
getCardByExternalRef(boardConfigUuid: string, externalRef: string): Promise<KanbanCard | null>;
|
|
1684
1743
|
createCard(input: CreateCardServerInput): Promise<KanbanCard>;
|
|
1685
1744
|
updateCard(cardId: string, patch: {
|
|
1686
1745
|
title?: string;
|
|
@@ -1702,6 +1761,7 @@ declare class InMemoryStorageAdapter implements KanbanStorageAdapter {
|
|
|
1702
1761
|
created: boolean;
|
|
1703
1762
|
run: StageRun;
|
|
1704
1763
|
}>;
|
|
1764
|
+
private recordRunLane;
|
|
1705
1765
|
/**
|
|
1706
1766
|
* A stranded stage-run the next `beginStageRun` may re-claim (design §10): a
|
|
1707
1767
|
* `failed` run (dispatch threw), or a `queued` run older than `staleQueuedMs`
|
|
@@ -2384,9 +2444,38 @@ interface BatchCompleteResult {
|
|
|
2384
2444
|
*/
|
|
2385
2445
|
noop: number;
|
|
2386
2446
|
}
|
|
2447
|
+
/** Options for {@link KanbanEngine.hostMove} (p46 P46-002, D22 + F8). */
|
|
2448
|
+
interface HostMoveOptions {
|
|
2449
|
+
/**
|
|
2450
|
+
* The lane the HOST SYNC observed the card in at the start of its pass. The
|
|
2451
|
+
* move is a CAS on it — never a re-read: a Cadra move committed between the
|
|
2452
|
+
* sync's read and this apply makes the move fail (`TransitionConflictError`)
|
|
2453
|
+
* instead of silently moving the card back.
|
|
2454
|
+
*/
|
|
2455
|
+
expectedFromLane: string;
|
|
2456
|
+
/** Host facts written with the move inside the adapter's card lock. */
|
|
2457
|
+
externalMeta?: Record<string, unknown>;
|
|
2458
|
+
/**
|
|
2459
|
+
* ISO time the sync READ the host state. The adapter fence then also refuses
|
|
2460
|
+
* the move if a `host.*` op for this card settled after it (our own write may
|
|
2461
|
+
* have landed after the read). Strongly recommended for a polling sync.
|
|
2462
|
+
*/
|
|
2463
|
+
observedAt?: string;
|
|
2464
|
+
}
|
|
2387
2465
|
interface KanbanEngine {
|
|
2388
2466
|
createCard(boardConfigUuid: string, input: CreateCardInput): Promise<KanbanCard>;
|
|
2389
2467
|
transition(cardId: string, toLane?: string, actor?: Actor): Promise<KanbanCard>;
|
|
2468
|
+
/**
|
|
2469
|
+
* p46 (P46-002, D22 + F8): mirror a move the EXTERNAL host made (a Jira drag)
|
|
2470
|
+
* — the host owns the column, so NO manual edge is required. Keeps the CAS on
|
|
2471
|
+
* `expectedFromLane`, logs `transitionId` = the matching edge id (any
|
|
2472
|
+
* trigger) else `host:<from>-><to>`, passes `hostObservation` (the adapter's
|
|
2473
|
+
* D19 fence + `externalMeta` write), writes `human_to_ai` on a
|
|
2474
|
+
* non-automated → automated move (D5), and dispatches on entry.
|
|
2475
|
+
* `toLane === card.lane` → no-op returning the card. Unknown lane → throws.
|
|
2476
|
+
* Actor for Jira: `{ type: "system", id: "host:jira" }`.
|
|
2477
|
+
*/
|
|
2478
|
+
hostMove(cardId: string, toLane: string, actor: Actor, opts: HostMoveOptions): Promise<KanbanCard>;
|
|
2390
2479
|
runStage(cardId: string, stageId: string): Promise<{
|
|
2391
2480
|
dispatched: boolean;
|
|
2392
2481
|
executionUuid?: string;
|
|
@@ -2463,4 +2552,4 @@ interface KanbanLedgerEngine extends KanbanEngine {
|
|
|
2463
2552
|
}
|
|
2464
2553
|
declare function createEngine(options: CreateEngineOptions): KanbanLedgerEngine;
|
|
2465
2554
|
|
|
2466
|
-
export { ANSWERABLE_HANDOFF_KINDS, type Actor, type AdapterCapabilities, type AdapterFactory, type ApplyTransitionInput, type BatchCardCompletion, type BatchCardContext, type BatchCompleteResult, type BatchDispatchMeta, BoardConfigClient, type BoardConfigClientOptions, type BoardConfigHttp, CadraLifecycleSource, type CadraRunClient, CapabilitiesNotLoadedError, ConductorUnsupportedError, type ConformanceExpect, type ConformanceRunner, type CreateCardServerInput, type CreateEngineOptions, DEFAULT_BOARD_CEILING, type DueRule, type ExampleHostOptions, type FetchLike, HANDOFF_ANSWER_MAX_TEXT, HANDOFF_OUTPUT_MAX_BYTES, HANDOFF_PROMPT_PREAMBLE, HANDOFF_VERDICT_JSON_SCHEMA, HANDOFF_VERDICT_TASK_SUFFIX, type HandlerContext, type HandlerDispatchResult, type HandoffAnswer, HandoffAnswerError, type HandoffAnswerErrorCode, type HandoffDecision, type HandoffKind, type HandoffLedgerAdapter, type HandoffOption, type HandoffRecord, type HandoffState, type HandoffStatus, type HandoffV1, type HandoffVerdict, type HandoffVerdictKind, type HostRequest, type HostResponse, HttpAdapterError, HttpStorageAdapter, type HttpStorageAdapterConfig, type InMemoryOp, InMemoryStorageAdapter, type KanbanEngine, type KanbanLaneDispatch, type KanbanLaneHandoffMode, type KanbanLaneTrigger, type KanbanLedgerEngine, type KanbanStorageAdapter, type LaneHealth, type LaneHealthCheck, type LaneHealthReason, type LaneHealthState, type LifecycleRef, type LifecycleSource, type LifecycleSourceKind, NotScheduledLaneError, type ParseHandoffVerdictResult, type ResolveLifecycleRef, type ResolvedBoardConfig, type ResolvedLifecycle, type RunAgentInput, type RunDueStagesSummary, type RunRemoteAgentInput, type RunResult, type RunTeamInput, type Stage, type StageRun, type StageRunLedgerWrite, type StageRunStatus, type Transition, TransitionConflictError, type TransitionLogEntry, UnknownDueRuleError, WebhookDeliveryError, type WebhookDeliveryOptions, type WebhookSecret, createEngine, deliverWebhook, dispatchStageHandler, exampleHostHandler, hasHandoffLedger, hmacSign, isSafeHandoffUrl, mapDefinitionToBoard, parseHandoffVerdict, renderHandoffForPrompt, resolveAutoEdge, resolveManualEdge, runAdapterConformance, startExampleHost, toResolvedLifecycle };
|
|
2555
|
+
export { ANSWERABLE_HANDOFF_KINDS, type Actor, type AdapterCapabilities, type AdapterFactory, type ApplyTransitionInput, type BatchCardCompletion, type BatchCardContext, type BatchCompleteResult, type BatchDispatchMeta, BoardConfigClient, type BoardConfigClientOptions, type BoardConfigHttp, CadraLifecycleSource, type CadraRunClient, CapabilitiesNotLoadedError, ConductorUnsupportedError, type ConformanceExpect, type ConformanceRunner, type CreateCardServerInput, type CreateEngineOptions, DEFAULT_BOARD_CEILING, type DueRule, type ExampleHostOptions, type FetchLike, HANDOFF_ANSWER_MAX_TEXT, HANDOFF_OUTPUT_MAX_BYTES, HANDOFF_PROMPT_PREAMBLE, HANDOFF_VERDICT_JSON_SCHEMA, HANDOFF_VERDICT_TASK_SUFFIX, type HandlerContext, type HandlerDispatchResult, type HandoffAnswer, HandoffAnswerError, type HandoffAnswerErrorCode, type HandoffDecision, type HandoffKind, type HandoffLedgerAdapter, type HandoffOption, type HandoffRecord, type HandoffState, type HandoffStatus, type HandoffV1, type HandoffVerdict, type HandoffVerdictKind, HostFenceError, type HostMoveOptions, type HostRequest, type HostResponse, HttpAdapterError, HttpStorageAdapter, type HttpStorageAdapterConfig, type InMemoryOp, InMemoryStorageAdapter, type KanbanEngine, type KanbanLaneDispatch, type KanbanLaneHandoffMode, type KanbanLaneTrigger, type KanbanLedgerEngine, type KanbanStorageAdapter, type LaneHealth, type LaneHealthCheck, type LaneHealthReason, type LaneHealthState, type LifecycleRef, type LifecycleSource, type LifecycleSourceKind, NotScheduledLaneError, type ParseHandoffVerdictResult, type ResolveLifecycleRef, type ResolvedBoardConfig, type ResolvedLifecycle, type RunAgentInput, type RunDueStagesSummary, type RunRemoteAgentInput, type RunResult, type RunTeamInput, type Stage, type StageRun, type StageRunLedgerWrite, type StageRunStatus, type Transition, TransitionConflictError, type TransitionLogEntry, UnknownDueRuleError, WebhookDeliveryError, type WebhookDeliveryOptions, type WebhookSecret, createEngine, deliverWebhook, dispatchStageHandler, exampleHostHandler, hasHandoffLedger, hmacSign, isSafeHandoffUrl, mapDefinitionToBoard, parseHandoffVerdict, renderHandoffForPrompt, resolveAutoEdge, resolveManualEdge, runAdapterConformance, startExampleHost, toResolvedLifecycle };
|