@harness-engineering/orchestrator 0.4.2 → 0.4.4
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.mts +141 -5
- package/dist/index.d.ts +141 -5
- package/dist/index.js +1715 -144
- package/dist/index.mjs +1697 -123
- package/package.json +12 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Issue, AgentEvent, WorkflowConfig, TokenUsage, ConcernSignal, ScopeTier, EscalationConfig, RoutingDecision, Result, WorkflowDefinition, WorkspaceConfig, HooksConfig, AgentBackend, SessionStartParams, AgentSession, AgentError, TurnParams, TurnResult, BackendDef, RoutingConfig, RoutingUseCase, ContainerConfig, SecretConfig, AgentConfig } from '@harness-engineering/types';
|
|
2
|
-
import { IssueTrackerClient, Issue as Issue$1, TrackerConfig } from '@harness-engineering/core';
|
|
1
|
+
import { Issue, AgentEvent, WorkflowConfig, TokenUsage, ConcernSignal, ScopeTier, EscalationConfig, RoutingDecision, Result, WorkflowDefinition, WorkspaceConfig, HooksConfig, AgentBackend, SessionStartParams, AgentSession, AgentError, TurnParams, TurnResult, BackendDef, RoutingConfig, RoutingUseCase, ContainerConfig, SecretConfig, AgentConfig, TokenScope, AuthToken, AuthTokenPublic } from '@harness-engineering/types';
|
|
2
|
+
import { IssueTrackerClient, Issue as Issue$1, TrackerConfig, CacheMetricsRecorder } from '@harness-engineering/core';
|
|
3
3
|
import { EnrichedSpec, ComplexityScore, SimulationResult, IntelligencePipeline, WeightedRecommendation } from '@harness-engineering/intelligence';
|
|
4
4
|
import { GraphStore } from '@harness-engineering/graph';
|
|
5
5
|
import { execFile } from 'node:child_process';
|
|
@@ -682,10 +682,16 @@ interface PendingInteraction {
|
|
|
682
682
|
declare class InteractionQueue {
|
|
683
683
|
private dir;
|
|
684
684
|
private pushListeners;
|
|
685
|
+
private emitter;
|
|
685
686
|
/**
|
|
686
687
|
* @param dir - Directory path for storing interaction JSON files
|
|
688
|
+
* @param emitter - Optional event bus that receives `interaction.created`
|
|
689
|
+
* and `interaction.resolved` events. When omitted, the queue behaves as
|
|
690
|
+
* it did pre-Phase-2 (no emission). Phase 2 Task 8 wires the
|
|
691
|
+
* orchestrator (itself an EventEmitter) in as the bus so the SSE
|
|
692
|
+
* handler (`GET /api/v1/events`) can fan these out to clients.
|
|
687
693
|
*/
|
|
688
|
-
constructor(dir: string);
|
|
694
|
+
constructor(dir: string, emitter?: EventEmitter);
|
|
689
695
|
/**
|
|
690
696
|
* Register a listener that fires after each push.
|
|
691
697
|
*/
|
|
@@ -1214,6 +1220,12 @@ declare class Orchestrator extends EventEmitter {
|
|
|
1214
1220
|
private prDetector;
|
|
1215
1221
|
private maintenanceScheduler;
|
|
1216
1222
|
private maintenanceReporter;
|
|
1223
|
+
private webhookFanoutOff?;
|
|
1224
|
+
private webhookQueue?;
|
|
1225
|
+
private webhookDeliveryWorker?;
|
|
1226
|
+
private cacheMetrics?;
|
|
1227
|
+
private otlpExporter?;
|
|
1228
|
+
private telemetryFanoutOff?;
|
|
1217
1229
|
private orchestratorIdPromise;
|
|
1218
1230
|
private recorder;
|
|
1219
1231
|
private intelligenceRunner;
|
|
@@ -1447,6 +1459,12 @@ interface OrchestratorBackendFactoryOptions {
|
|
|
1447
1459
|
* route through the resolver Map.
|
|
1448
1460
|
*/
|
|
1449
1461
|
getResolverModelFor?: (backendName: string) => (() => string | null) | undefined;
|
|
1462
|
+
/**
|
|
1463
|
+
* Phase 5: prompt-cache recorder forwarded to Anthropic-capable backends.
|
|
1464
|
+
* Other backends accept-but-ignore. Shared across dispatches so the
|
|
1465
|
+
* `/api/v1/telemetry/cache/stats` endpoint sees the full rolling window.
|
|
1466
|
+
*/
|
|
1467
|
+
cacheMetrics?: CacheMetricsRecorder;
|
|
1450
1468
|
}
|
|
1451
1469
|
/**
|
|
1452
1470
|
* High-level factory wrapping `BackendRouter` + `createBackend` plus
|
|
@@ -1513,12 +1531,27 @@ interface MigrationResult {
|
|
|
1513
1531
|
}
|
|
1514
1532
|
declare function migrateAgentConfig(agent: AgentConfig): MigrationResult;
|
|
1515
1533
|
|
|
1534
|
+
/**
|
|
1535
|
+
* Orchestrator-owned dependencies threaded into backend constructors. Today
|
|
1536
|
+
* only the prompt-cache recorder is plumbed (consumed by ClaudeBackend); other
|
|
1537
|
+
* backends accept the option without using it so a single recorder instance
|
|
1538
|
+
* can be shared across the dispatch tree. The recorder itself is instantiated
|
|
1539
|
+
* by the orchestrator at startup — Phase 5 Task 16.
|
|
1540
|
+
*/
|
|
1541
|
+
interface CreateBackendOptions {
|
|
1542
|
+
/** Optional prompt-cache recorder shared across Anthropic-capable backends. */
|
|
1543
|
+
cacheMetrics?: CacheMetricsRecorder;
|
|
1544
|
+
}
|
|
1516
1545
|
/**
|
|
1517
1546
|
* Pure constructor: BackendDef -> concrete AgentBackend instance.
|
|
1518
1547
|
* No side effects beyond the underlying class constructors.
|
|
1519
1548
|
* Container wrapping (sandbox policy) is the orchestrator's job, not the factory's.
|
|
1549
|
+
*
|
|
1550
|
+
* `options.cacheMetrics`, when provided, is forwarded to backends that
|
|
1551
|
+
* record prompt-cache hits (currently `ClaudeBackend`). Other backends
|
|
1552
|
+
* accept-but-ignore the recorder.
|
|
1520
1553
|
*/
|
|
1521
|
-
declare function createBackend(def: BackendDef): AgentBackend;
|
|
1554
|
+
declare function createBackend(def: BackendDef, options?: CreateBackendOptions): AgentBackend;
|
|
1522
1555
|
|
|
1523
1556
|
/**
|
|
1524
1557
|
* Function signature compatible with Node's `child_process.execFile`.
|
|
@@ -1561,4 +1594,107 @@ interface SyncMainOptions {
|
|
|
1561
1594
|
*/
|
|
1562
1595
|
declare function syncMain(repoRoot: string, opts?: SyncMainOptions): Promise<SyncMainResult>;
|
|
1563
1596
|
|
|
1564
|
-
|
|
1597
|
+
interface CreateTokenInput {
|
|
1598
|
+
name: string;
|
|
1599
|
+
scopes: TokenScope[];
|
|
1600
|
+
bridgeKind?: AuthToken['bridgeKind'];
|
|
1601
|
+
tenantId?: string;
|
|
1602
|
+
expiresAt?: string;
|
|
1603
|
+
}
|
|
1604
|
+
interface CreateTokenResult {
|
|
1605
|
+
id: string;
|
|
1606
|
+
token: string;
|
|
1607
|
+
record: AuthToken;
|
|
1608
|
+
}
|
|
1609
|
+
declare class TokenStore {
|
|
1610
|
+
private readonly path;
|
|
1611
|
+
private cache;
|
|
1612
|
+
constructor(path: string);
|
|
1613
|
+
private load;
|
|
1614
|
+
private persist;
|
|
1615
|
+
create(input: CreateTokenInput): Promise<CreateTokenResult>;
|
|
1616
|
+
verify(raw: string): Promise<AuthToken | null>;
|
|
1617
|
+
private touchLastUsed;
|
|
1618
|
+
list(): Promise<AuthTokenPublic[]>;
|
|
1619
|
+
revoke(id: string): Promise<boolean>;
|
|
1620
|
+
/**
|
|
1621
|
+
* Synthetic admin record for the legacy HARNESS_API_TOKEN escape hatch.
|
|
1622
|
+
* Returned only when `presented` matches `envValue` byte-for-byte (constant-time).
|
|
1623
|
+
*/
|
|
1624
|
+
legacyEnvToken(presented: string, envValue: string | undefined): AuthToken | null;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
declare const RETRY_DELAYS_MS: readonly [1000, 4000, 16000, 64000, 256000];
|
|
1628
|
+
declare const MAX_ATTEMPTS = 5;
|
|
1629
|
+
interface QueueInsertInput {
|
|
1630
|
+
id: string;
|
|
1631
|
+
subscriptionId: string;
|
|
1632
|
+
eventType: string;
|
|
1633
|
+
payload: string;
|
|
1634
|
+
}
|
|
1635
|
+
interface QueueRow {
|
|
1636
|
+
id: string;
|
|
1637
|
+
subscriptionId: string;
|
|
1638
|
+
eventType: string;
|
|
1639
|
+
payload: string;
|
|
1640
|
+
attempt: number;
|
|
1641
|
+
status: 'pending' | 'in_flight' | 'failed' | 'delivered' | 'dead';
|
|
1642
|
+
nextAttemptAt: number | null;
|
|
1643
|
+
lastError: string | null;
|
|
1644
|
+
deliveredAt: number | null;
|
|
1645
|
+
}
|
|
1646
|
+
interface QueueStats {
|
|
1647
|
+
pending: number;
|
|
1648
|
+
inFlight: number;
|
|
1649
|
+
failed: number;
|
|
1650
|
+
dead: number;
|
|
1651
|
+
delivered: number;
|
|
1652
|
+
}
|
|
1653
|
+
declare class WebhookQueue {
|
|
1654
|
+
private readonly db;
|
|
1655
|
+
constructor(dbPath: string);
|
|
1656
|
+
insert(row: QueueInsertInput): void;
|
|
1657
|
+
/**
|
|
1658
|
+
* Atomically lease a batch of deliverable rows: select pending|failed rows
|
|
1659
|
+
* whose nextAttemptAt has elapsed, mark them in_flight in the same
|
|
1660
|
+
* transaction, and return the leased rows. Subsequent calls cannot re-claim
|
|
1661
|
+
* the same rows because they are no longer in pending|failed.
|
|
1662
|
+
*
|
|
1663
|
+
* Without this, two overlapping ticks (tick interval 500ms, HTTP timeout
|
|
1664
|
+
* 5s) would both select the same row and double-fire the webhook.
|
|
1665
|
+
*/
|
|
1666
|
+
claim(now: number, limit?: number): QueueRow[];
|
|
1667
|
+
/**
|
|
1668
|
+
* Reset any rows stuck in in_flight (e.g. from a crashed or abruptly
|
|
1669
|
+
* stopped worker) back to failed so they can be re-claimed by the next
|
|
1670
|
+
* tick. At-most-once semantics within a single process; at-least-once
|
|
1671
|
+
* across restarts (a row whose HTTP POST completed but whose DB update was
|
|
1672
|
+
* lost will be re-delivered — bridges must be idempotent on delivery-id).
|
|
1673
|
+
*/
|
|
1674
|
+
recoverInFlight(): number;
|
|
1675
|
+
markDelivered(id: string, deliveredAt: number): void;
|
|
1676
|
+
markFailed(id: string, attempt: number, nextAttemptAt: number, lastError: string): void;
|
|
1677
|
+
retryDead(id: string): boolean;
|
|
1678
|
+
list(filter?: {
|
|
1679
|
+
status?: string;
|
|
1680
|
+
subscriptionId?: string;
|
|
1681
|
+
}): QueueRow[];
|
|
1682
|
+
purge(opts?: {
|
|
1683
|
+
deadOnly?: boolean;
|
|
1684
|
+
olderThanMs?: number;
|
|
1685
|
+
all?: boolean;
|
|
1686
|
+
}): number;
|
|
1687
|
+
/**
|
|
1688
|
+
* Count the rows a purge() call with these same options would delete.
|
|
1689
|
+
* Used by the CLI to show a confirmation preview before destructive deletes.
|
|
1690
|
+
*/
|
|
1691
|
+
previewPurge(opts?: {
|
|
1692
|
+
deadOnly?: boolean;
|
|
1693
|
+
olderThanMs?: number;
|
|
1694
|
+
all?: boolean;
|
|
1695
|
+
}): number;
|
|
1696
|
+
stats(): QueueStats;
|
|
1697
|
+
close(): void;
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
export { type AgentUpdateEvent, AnalysisArchive, type AnalysisRecord, type ApplyEventResult, type ArtifactPresence, type AttemptStats, BackendRouter, type BackendRouterOptions, type BaseRefFallbackEvent, ClaimManager, type ClaimManagerConfig, type CleanWorkspaceEffect, type CreateTokenInput, type CreateTokenResult, type DispatchEffect, type EmitLogEffect, type EscalateEffect, type ExecFileFn$1 as ExecFileFn, type Highlight, type HighlightsInfo, InteractionQueue, type LinearGraphQLExtension, LinearGraphQLStub, type LiveSession, MAX_ATTEMPTS, type MigrationResult, MockBackend, ORCHESTRATOR_IDENTITY_FILE, Orchestrator, OrchestratorBackendFactory, type OrchestratorBackendFactoryOptions, type OrchestratorContext, type OrchestratorEvent, type OrchestratorState, PRDetector, type PRDetectorLogger, type PendingInteraction, PromptRenderer, type PublishedIndex, type QueueInsertInput, type QueueRow, type QueueStats, RETRY_DELAYS_MS, type RateLimitSnapshot as RateLimitComputeSnapshot, type RateLimitConfig, type RateLimitSnapshot$1 as RateLimitSnapshot, type ReleaseClaimEffect, type RetryEntry, type RetryFiredEvent, RoadmapTrackerAdapter, type RunAttemptPhase, type RunningEntry, type ScheduleRetryEffect, type SideEffect, type StallDetectedEvent, type StopEffect, type StreamManifest, StreamRecorder, type SyncMainOptions, type SyncMainResult, type SyncSkipReason, type TickEvent, TokenStore, type TokenTotals, type TriageConfig, type TriageDecision, type TriageSignals, type TriageSkill, type UpdateTokensEffect, WebhookQueue, type WorkerExitEvent, WorkflowLoader, WorkspaceHooks, WorkspaceManager, type WorkspaceManagerOptions, applyEvent, artifactPresenceFromIssue, calculateRetryDelay, canDispatch, computeRateLimitDelay, createBackend, createEmptyState, detectScopeTier, extractHighlights, extractTitlePrefix, getAvailableSlots, getDefaultConfig, getPerStateCount, isEligible, launchTUI, loadPublishedIndex, migrateAgentConfig, reconcile, renderAnalysisComment, renderPRComment, resolveEscalationConfig, resolveOrchestratorId, routeIssue, savePublishedIndex, selectCandidates, sortCandidates, syncMain, triageIssue, validateWorkflowConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Issue, AgentEvent, WorkflowConfig, TokenUsage, ConcernSignal, ScopeTier, EscalationConfig, RoutingDecision, Result, WorkflowDefinition, WorkspaceConfig, HooksConfig, AgentBackend, SessionStartParams, AgentSession, AgentError, TurnParams, TurnResult, BackendDef, RoutingConfig, RoutingUseCase, ContainerConfig, SecretConfig, AgentConfig } from '@harness-engineering/types';
|
|
2
|
-
import { IssueTrackerClient, Issue as Issue$1, TrackerConfig } from '@harness-engineering/core';
|
|
1
|
+
import { Issue, AgentEvent, WorkflowConfig, TokenUsage, ConcernSignal, ScopeTier, EscalationConfig, RoutingDecision, Result, WorkflowDefinition, WorkspaceConfig, HooksConfig, AgentBackend, SessionStartParams, AgentSession, AgentError, TurnParams, TurnResult, BackendDef, RoutingConfig, RoutingUseCase, ContainerConfig, SecretConfig, AgentConfig, TokenScope, AuthToken, AuthTokenPublic } from '@harness-engineering/types';
|
|
2
|
+
import { IssueTrackerClient, Issue as Issue$1, TrackerConfig, CacheMetricsRecorder } from '@harness-engineering/core';
|
|
3
3
|
import { EnrichedSpec, ComplexityScore, SimulationResult, IntelligencePipeline, WeightedRecommendation } from '@harness-engineering/intelligence';
|
|
4
4
|
import { GraphStore } from '@harness-engineering/graph';
|
|
5
5
|
import { execFile } from 'node:child_process';
|
|
@@ -682,10 +682,16 @@ interface PendingInteraction {
|
|
|
682
682
|
declare class InteractionQueue {
|
|
683
683
|
private dir;
|
|
684
684
|
private pushListeners;
|
|
685
|
+
private emitter;
|
|
685
686
|
/**
|
|
686
687
|
* @param dir - Directory path for storing interaction JSON files
|
|
688
|
+
* @param emitter - Optional event bus that receives `interaction.created`
|
|
689
|
+
* and `interaction.resolved` events. When omitted, the queue behaves as
|
|
690
|
+
* it did pre-Phase-2 (no emission). Phase 2 Task 8 wires the
|
|
691
|
+
* orchestrator (itself an EventEmitter) in as the bus so the SSE
|
|
692
|
+
* handler (`GET /api/v1/events`) can fan these out to clients.
|
|
687
693
|
*/
|
|
688
|
-
constructor(dir: string);
|
|
694
|
+
constructor(dir: string, emitter?: EventEmitter);
|
|
689
695
|
/**
|
|
690
696
|
* Register a listener that fires after each push.
|
|
691
697
|
*/
|
|
@@ -1214,6 +1220,12 @@ declare class Orchestrator extends EventEmitter {
|
|
|
1214
1220
|
private prDetector;
|
|
1215
1221
|
private maintenanceScheduler;
|
|
1216
1222
|
private maintenanceReporter;
|
|
1223
|
+
private webhookFanoutOff?;
|
|
1224
|
+
private webhookQueue?;
|
|
1225
|
+
private webhookDeliveryWorker?;
|
|
1226
|
+
private cacheMetrics?;
|
|
1227
|
+
private otlpExporter?;
|
|
1228
|
+
private telemetryFanoutOff?;
|
|
1217
1229
|
private orchestratorIdPromise;
|
|
1218
1230
|
private recorder;
|
|
1219
1231
|
private intelligenceRunner;
|
|
@@ -1447,6 +1459,12 @@ interface OrchestratorBackendFactoryOptions {
|
|
|
1447
1459
|
* route through the resolver Map.
|
|
1448
1460
|
*/
|
|
1449
1461
|
getResolverModelFor?: (backendName: string) => (() => string | null) | undefined;
|
|
1462
|
+
/**
|
|
1463
|
+
* Phase 5: prompt-cache recorder forwarded to Anthropic-capable backends.
|
|
1464
|
+
* Other backends accept-but-ignore. Shared across dispatches so the
|
|
1465
|
+
* `/api/v1/telemetry/cache/stats` endpoint sees the full rolling window.
|
|
1466
|
+
*/
|
|
1467
|
+
cacheMetrics?: CacheMetricsRecorder;
|
|
1450
1468
|
}
|
|
1451
1469
|
/**
|
|
1452
1470
|
* High-level factory wrapping `BackendRouter` + `createBackend` plus
|
|
@@ -1513,12 +1531,27 @@ interface MigrationResult {
|
|
|
1513
1531
|
}
|
|
1514
1532
|
declare function migrateAgentConfig(agent: AgentConfig): MigrationResult;
|
|
1515
1533
|
|
|
1534
|
+
/**
|
|
1535
|
+
* Orchestrator-owned dependencies threaded into backend constructors. Today
|
|
1536
|
+
* only the prompt-cache recorder is plumbed (consumed by ClaudeBackend); other
|
|
1537
|
+
* backends accept the option without using it so a single recorder instance
|
|
1538
|
+
* can be shared across the dispatch tree. The recorder itself is instantiated
|
|
1539
|
+
* by the orchestrator at startup — Phase 5 Task 16.
|
|
1540
|
+
*/
|
|
1541
|
+
interface CreateBackendOptions {
|
|
1542
|
+
/** Optional prompt-cache recorder shared across Anthropic-capable backends. */
|
|
1543
|
+
cacheMetrics?: CacheMetricsRecorder;
|
|
1544
|
+
}
|
|
1516
1545
|
/**
|
|
1517
1546
|
* Pure constructor: BackendDef -> concrete AgentBackend instance.
|
|
1518
1547
|
* No side effects beyond the underlying class constructors.
|
|
1519
1548
|
* Container wrapping (sandbox policy) is the orchestrator's job, not the factory's.
|
|
1549
|
+
*
|
|
1550
|
+
* `options.cacheMetrics`, when provided, is forwarded to backends that
|
|
1551
|
+
* record prompt-cache hits (currently `ClaudeBackend`). Other backends
|
|
1552
|
+
* accept-but-ignore the recorder.
|
|
1520
1553
|
*/
|
|
1521
|
-
declare function createBackend(def: BackendDef): AgentBackend;
|
|
1554
|
+
declare function createBackend(def: BackendDef, options?: CreateBackendOptions): AgentBackend;
|
|
1522
1555
|
|
|
1523
1556
|
/**
|
|
1524
1557
|
* Function signature compatible with Node's `child_process.execFile`.
|
|
@@ -1561,4 +1594,107 @@ interface SyncMainOptions {
|
|
|
1561
1594
|
*/
|
|
1562
1595
|
declare function syncMain(repoRoot: string, opts?: SyncMainOptions): Promise<SyncMainResult>;
|
|
1563
1596
|
|
|
1564
|
-
|
|
1597
|
+
interface CreateTokenInput {
|
|
1598
|
+
name: string;
|
|
1599
|
+
scopes: TokenScope[];
|
|
1600
|
+
bridgeKind?: AuthToken['bridgeKind'];
|
|
1601
|
+
tenantId?: string;
|
|
1602
|
+
expiresAt?: string;
|
|
1603
|
+
}
|
|
1604
|
+
interface CreateTokenResult {
|
|
1605
|
+
id: string;
|
|
1606
|
+
token: string;
|
|
1607
|
+
record: AuthToken;
|
|
1608
|
+
}
|
|
1609
|
+
declare class TokenStore {
|
|
1610
|
+
private readonly path;
|
|
1611
|
+
private cache;
|
|
1612
|
+
constructor(path: string);
|
|
1613
|
+
private load;
|
|
1614
|
+
private persist;
|
|
1615
|
+
create(input: CreateTokenInput): Promise<CreateTokenResult>;
|
|
1616
|
+
verify(raw: string): Promise<AuthToken | null>;
|
|
1617
|
+
private touchLastUsed;
|
|
1618
|
+
list(): Promise<AuthTokenPublic[]>;
|
|
1619
|
+
revoke(id: string): Promise<boolean>;
|
|
1620
|
+
/**
|
|
1621
|
+
* Synthetic admin record for the legacy HARNESS_API_TOKEN escape hatch.
|
|
1622
|
+
* Returned only when `presented` matches `envValue` byte-for-byte (constant-time).
|
|
1623
|
+
*/
|
|
1624
|
+
legacyEnvToken(presented: string, envValue: string | undefined): AuthToken | null;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
declare const RETRY_DELAYS_MS: readonly [1000, 4000, 16000, 64000, 256000];
|
|
1628
|
+
declare const MAX_ATTEMPTS = 5;
|
|
1629
|
+
interface QueueInsertInput {
|
|
1630
|
+
id: string;
|
|
1631
|
+
subscriptionId: string;
|
|
1632
|
+
eventType: string;
|
|
1633
|
+
payload: string;
|
|
1634
|
+
}
|
|
1635
|
+
interface QueueRow {
|
|
1636
|
+
id: string;
|
|
1637
|
+
subscriptionId: string;
|
|
1638
|
+
eventType: string;
|
|
1639
|
+
payload: string;
|
|
1640
|
+
attempt: number;
|
|
1641
|
+
status: 'pending' | 'in_flight' | 'failed' | 'delivered' | 'dead';
|
|
1642
|
+
nextAttemptAt: number | null;
|
|
1643
|
+
lastError: string | null;
|
|
1644
|
+
deliveredAt: number | null;
|
|
1645
|
+
}
|
|
1646
|
+
interface QueueStats {
|
|
1647
|
+
pending: number;
|
|
1648
|
+
inFlight: number;
|
|
1649
|
+
failed: number;
|
|
1650
|
+
dead: number;
|
|
1651
|
+
delivered: number;
|
|
1652
|
+
}
|
|
1653
|
+
declare class WebhookQueue {
|
|
1654
|
+
private readonly db;
|
|
1655
|
+
constructor(dbPath: string);
|
|
1656
|
+
insert(row: QueueInsertInput): void;
|
|
1657
|
+
/**
|
|
1658
|
+
* Atomically lease a batch of deliverable rows: select pending|failed rows
|
|
1659
|
+
* whose nextAttemptAt has elapsed, mark them in_flight in the same
|
|
1660
|
+
* transaction, and return the leased rows. Subsequent calls cannot re-claim
|
|
1661
|
+
* the same rows because they are no longer in pending|failed.
|
|
1662
|
+
*
|
|
1663
|
+
* Without this, two overlapping ticks (tick interval 500ms, HTTP timeout
|
|
1664
|
+
* 5s) would both select the same row and double-fire the webhook.
|
|
1665
|
+
*/
|
|
1666
|
+
claim(now: number, limit?: number): QueueRow[];
|
|
1667
|
+
/**
|
|
1668
|
+
* Reset any rows stuck in in_flight (e.g. from a crashed or abruptly
|
|
1669
|
+
* stopped worker) back to failed so they can be re-claimed by the next
|
|
1670
|
+
* tick. At-most-once semantics within a single process; at-least-once
|
|
1671
|
+
* across restarts (a row whose HTTP POST completed but whose DB update was
|
|
1672
|
+
* lost will be re-delivered — bridges must be idempotent on delivery-id).
|
|
1673
|
+
*/
|
|
1674
|
+
recoverInFlight(): number;
|
|
1675
|
+
markDelivered(id: string, deliveredAt: number): void;
|
|
1676
|
+
markFailed(id: string, attempt: number, nextAttemptAt: number, lastError: string): void;
|
|
1677
|
+
retryDead(id: string): boolean;
|
|
1678
|
+
list(filter?: {
|
|
1679
|
+
status?: string;
|
|
1680
|
+
subscriptionId?: string;
|
|
1681
|
+
}): QueueRow[];
|
|
1682
|
+
purge(opts?: {
|
|
1683
|
+
deadOnly?: boolean;
|
|
1684
|
+
olderThanMs?: number;
|
|
1685
|
+
all?: boolean;
|
|
1686
|
+
}): number;
|
|
1687
|
+
/**
|
|
1688
|
+
* Count the rows a purge() call with these same options would delete.
|
|
1689
|
+
* Used by the CLI to show a confirmation preview before destructive deletes.
|
|
1690
|
+
*/
|
|
1691
|
+
previewPurge(opts?: {
|
|
1692
|
+
deadOnly?: boolean;
|
|
1693
|
+
olderThanMs?: number;
|
|
1694
|
+
all?: boolean;
|
|
1695
|
+
}): number;
|
|
1696
|
+
stats(): QueueStats;
|
|
1697
|
+
close(): void;
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
export { type AgentUpdateEvent, AnalysisArchive, type AnalysisRecord, type ApplyEventResult, type ArtifactPresence, type AttemptStats, BackendRouter, type BackendRouterOptions, type BaseRefFallbackEvent, ClaimManager, type ClaimManagerConfig, type CleanWorkspaceEffect, type CreateTokenInput, type CreateTokenResult, type DispatchEffect, type EmitLogEffect, type EscalateEffect, type ExecFileFn$1 as ExecFileFn, type Highlight, type HighlightsInfo, InteractionQueue, type LinearGraphQLExtension, LinearGraphQLStub, type LiveSession, MAX_ATTEMPTS, type MigrationResult, MockBackend, ORCHESTRATOR_IDENTITY_FILE, Orchestrator, OrchestratorBackendFactory, type OrchestratorBackendFactoryOptions, type OrchestratorContext, type OrchestratorEvent, type OrchestratorState, PRDetector, type PRDetectorLogger, type PendingInteraction, PromptRenderer, type PublishedIndex, type QueueInsertInput, type QueueRow, type QueueStats, RETRY_DELAYS_MS, type RateLimitSnapshot as RateLimitComputeSnapshot, type RateLimitConfig, type RateLimitSnapshot$1 as RateLimitSnapshot, type ReleaseClaimEffect, type RetryEntry, type RetryFiredEvent, RoadmapTrackerAdapter, type RunAttemptPhase, type RunningEntry, type ScheduleRetryEffect, type SideEffect, type StallDetectedEvent, type StopEffect, type StreamManifest, StreamRecorder, type SyncMainOptions, type SyncMainResult, type SyncSkipReason, type TickEvent, TokenStore, type TokenTotals, type TriageConfig, type TriageDecision, type TriageSignals, type TriageSkill, type UpdateTokensEffect, WebhookQueue, type WorkerExitEvent, WorkflowLoader, WorkspaceHooks, WorkspaceManager, type WorkspaceManagerOptions, applyEvent, artifactPresenceFromIssue, calculateRetryDelay, canDispatch, computeRateLimitDelay, createBackend, createEmptyState, detectScopeTier, extractHighlights, extractTitlePrefix, getAvailableSlots, getDefaultConfig, getPerStateCount, isEligible, launchTUI, loadPublishedIndex, migrateAgentConfig, reconcile, renderAnalysisComment, renderPRComment, resolveEscalationConfig, resolveOrchestratorId, routeIssue, savePublishedIndex, selectCandidates, sortCandidates, syncMain, triageIssue, validateWorkflowConfig };
|