@ordewell/core 0.10.9 → 0.10.10
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/{IFileSystem-C9W5mRYA.d.mts → IFileSystem-1PqRCjhu.d.mts} +21 -3
- package/dist/{IFileSystem-B8qRNC_6.d.ts → IFileSystem-lTRL_G9Z.d.ts} +21 -3
- package/dist/{ModeResolver-C1PN5FYG.d.mts → ModeResolver-6TQXVsde.d.mts} +1 -1
- package/dist/{ModeResolver-CaPnoU8N.d.ts → ModeResolver-CoJAJD-f.d.ts} +1 -1
- package/dist/{Task-hFfRS9rN.d.mts → Task-CfBM0wkV.d.mts} +94 -21
- package/dist/{Task-hFfRS9rN.d.ts → Task-CfBM0wkV.d.ts} +94 -21
- package/dist/{chunk-H7QX32BH.mjs → chunk-24EL4Z2W.mjs} +2 -2
- package/dist/{chunk-O6LQU3W6.mjs → chunk-ESKK5I4F.mjs} +138 -21
- package/dist/chunk-ESKK5I4F.mjs.map +1 -0
- package/dist/{chunk-LTHKFBKM.mjs → chunk-KWS3VEER.mjs} +3 -3
- package/dist/{chunk-EEE2GBLG.mjs → chunk-PFH7WFIB.mjs} +1 -1
- package/dist/chunk-PFH7WFIB.mjs.map +1 -0
- package/dist/index.d.mts +119 -17
- package/dist/index.d.ts +119 -17
- package/dist/index.js +521 -88
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +397 -72
- package/dist/index.mjs.map +1 -1
- package/dist/parsing.d.mts +2 -2
- package/dist/parsing.d.ts +2 -2
- package/dist/parsing.js.map +1 -1
- package/dist/parsing.mjs +3 -3
- package/dist/plan-utils.d.mts +4 -4
- package/dist/plan-utils.d.ts +4 -4
- package/dist/plan-utils.js +144 -18
- package/dist/plan-utils.js.map +1 -1
- package/dist/plan-utils.mjs +22 -4
- package/dist/{runSettingsText-rLoYQlUH.d.mts → runSettingsText-C1i9wBG1.d.mts} +26 -15
- package/dist/{runSettingsText-CGKX3aeV.d.ts → runSettingsText-CWNrmF5U.d.ts} +26 -15
- package/dist/testing.d.mts +7 -2
- package/dist/testing.d.ts +7 -2
- package/dist/testing.js +11 -0
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +12 -1
- package/dist/testing.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-EEE2GBLG.mjs.map +0 -1
- package/dist/chunk-O6LQU3W6.mjs.map +0 -1
- /package/dist/{chunk-H7QX32BH.mjs.map → chunk-24EL4Z2W.mjs.map} +0 -0
- /package/dist/{chunk-LTHKFBKM.mjs.map → chunk-KWS3VEER.mjs.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChildProcess } from 'child_process';
|
|
2
|
-
import {
|
|
2
|
+
import { a7 as RunnerId, az as UsageRecord, ak as SubagentOutcome, a8 as RunnerSessionCost, f as DiscoveredModel, at as TaskSkillSnapshot } from './Task-CfBM0wkV.mjs';
|
|
3
3
|
import { z } from 'zod/v4';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1153,7 +1153,7 @@ type AgentEvent =
|
|
|
1153
1153
|
success: boolean;
|
|
1154
1154
|
subagentId?: string;
|
|
1155
1155
|
}
|
|
1156
|
-
/**
|
|
1156
|
+
/** Usage and session billing facts as the agent reported them — never priced by Ordewell. */
|
|
1157
1157
|
| {
|
|
1158
1158
|
type: 'usage';
|
|
1159
1159
|
record: UsageRecord;
|
|
@@ -1466,6 +1466,12 @@ interface TaskModeAgentAdapter extends AgentAdapter {
|
|
|
1466
1466
|
* within `timeoutMs`, and the caller must fall back to killing it.
|
|
1467
1467
|
*/
|
|
1468
1468
|
interrupt(timeoutMs: number): Promise<boolean>;
|
|
1469
|
+
/**
|
|
1470
|
+
* Tell the process nothing more is coming, once its turn has closed, so it
|
|
1471
|
+
* ends by itself and keeps what it saves on the way out. The process exit
|
|
1472
|
+
* reports its end. Absent on a runner whose process is only ever killed.
|
|
1473
|
+
*/
|
|
1474
|
+
endInput?(): void;
|
|
1469
1475
|
/**
|
|
1470
1476
|
* Registers the listener for what the agent does after a turn has ended and
|
|
1471
1477
|
* before the next message — a turn it opens itself when background work
|
|
@@ -1785,7 +1791,17 @@ interface IRunnerSession {
|
|
|
1785
1791
|
taskId: string;
|
|
1786
1792
|
onOutput(callback: (text: string) => void): void;
|
|
1787
1793
|
onExit(callback: (code: number) => void): void;
|
|
1794
|
+
/** End the process at once. {@link stop} is how an attempt that is over lets it go. */
|
|
1788
1795
|
kill(): void;
|
|
1796
|
+
/**
|
|
1797
|
+
* End the session the way its runner ends a turn (ADR-0018, L1): nothing
|
|
1798
|
+
* more is sent, a turn still open is interrupted and given the interrupt
|
|
1799
|
+
* grace to close — so what the runner reports as it closes, its cost and a
|
|
1800
|
+
* last call's usage, still reaches {@link onEvent} — then the process ends,
|
|
1801
|
+
* by itself where its runner can, killed once the grace runs out. Resolves
|
|
1802
|
+
* once it is gone, after {@link onExit}; at once when it already is.
|
|
1803
|
+
*/
|
|
1804
|
+
stop(): Promise<void>;
|
|
1789
1805
|
getOutput(): string;
|
|
1790
1806
|
write(text: string): void;
|
|
1791
1807
|
/** `working` while a turn runs; `idle` between turns, waiting for a message. */
|
|
@@ -1910,7 +1926,9 @@ interface IRunner {
|
|
|
1910
1926
|
/** Something the user should know about how the spawn went that did not stop it — a respawn, most often. */
|
|
1911
1927
|
onNotice?: (message: string) => void;
|
|
1912
1928
|
}): Promise<IRunnerSession>;
|
|
1913
|
-
|
|
1929
|
+
/** Wind one session down ({@link IRunnerSession.stop}); resolves once its process is gone. */
|
|
1930
|
+
stop(sessionId: string): Promise<void>;
|
|
1931
|
+
/** Wind every session down at once, as {@link stop} does one. */
|
|
1914
1932
|
stopAll(): void;
|
|
1915
1933
|
activeCount: number;
|
|
1916
1934
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChildProcess } from 'child_process';
|
|
2
|
-
import {
|
|
2
|
+
import { a7 as RunnerId, az as UsageRecord, ak as SubagentOutcome, a8 as RunnerSessionCost, f as DiscoveredModel, at as TaskSkillSnapshot } from './Task-CfBM0wkV.js';
|
|
3
3
|
import { z } from 'zod/v4';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1153,7 +1153,7 @@ type AgentEvent =
|
|
|
1153
1153
|
success: boolean;
|
|
1154
1154
|
subagentId?: string;
|
|
1155
1155
|
}
|
|
1156
|
-
/**
|
|
1156
|
+
/** Usage and session billing facts as the agent reported them — never priced by Ordewell. */
|
|
1157
1157
|
| {
|
|
1158
1158
|
type: 'usage';
|
|
1159
1159
|
record: UsageRecord;
|
|
@@ -1466,6 +1466,12 @@ interface TaskModeAgentAdapter extends AgentAdapter {
|
|
|
1466
1466
|
* within `timeoutMs`, and the caller must fall back to killing it.
|
|
1467
1467
|
*/
|
|
1468
1468
|
interrupt(timeoutMs: number): Promise<boolean>;
|
|
1469
|
+
/**
|
|
1470
|
+
* Tell the process nothing more is coming, once its turn has closed, so it
|
|
1471
|
+
* ends by itself and keeps what it saves on the way out. The process exit
|
|
1472
|
+
* reports its end. Absent on a runner whose process is only ever killed.
|
|
1473
|
+
*/
|
|
1474
|
+
endInput?(): void;
|
|
1469
1475
|
/**
|
|
1470
1476
|
* Registers the listener for what the agent does after a turn has ended and
|
|
1471
1477
|
* before the next message — a turn it opens itself when background work
|
|
@@ -1785,7 +1791,17 @@ interface IRunnerSession {
|
|
|
1785
1791
|
taskId: string;
|
|
1786
1792
|
onOutput(callback: (text: string) => void): void;
|
|
1787
1793
|
onExit(callback: (code: number) => void): void;
|
|
1794
|
+
/** End the process at once. {@link stop} is how an attempt that is over lets it go. */
|
|
1788
1795
|
kill(): void;
|
|
1796
|
+
/**
|
|
1797
|
+
* End the session the way its runner ends a turn (ADR-0018, L1): nothing
|
|
1798
|
+
* more is sent, a turn still open is interrupted and given the interrupt
|
|
1799
|
+
* grace to close — so what the runner reports as it closes, its cost and a
|
|
1800
|
+
* last call's usage, still reaches {@link onEvent} — then the process ends,
|
|
1801
|
+
* by itself where its runner can, killed once the grace runs out. Resolves
|
|
1802
|
+
* once it is gone, after {@link onExit}; at once when it already is.
|
|
1803
|
+
*/
|
|
1804
|
+
stop(): Promise<void>;
|
|
1789
1805
|
getOutput(): string;
|
|
1790
1806
|
write(text: string): void;
|
|
1791
1807
|
/** `working` while a turn runs; `idle` between turns, waiting for a message. */
|
|
@@ -1910,7 +1926,9 @@ interface IRunner {
|
|
|
1910
1926
|
/** Something the user should know about how the spawn went that did not stop it — a respawn, most often. */
|
|
1911
1927
|
onNotice?: (message: string) => void;
|
|
1912
1928
|
}): Promise<IRunnerSession>;
|
|
1913
|
-
|
|
1929
|
+
/** Wind one session down ({@link IRunnerSession.stop}); resolves once its process is gone. */
|
|
1930
|
+
stop(sessionId: string): Promise<void>;
|
|
1931
|
+
/** Wind every session down at once, as {@link stop} does one. */
|
|
1914
1932
|
stopAll(): void;
|
|
1915
1933
|
activeCount: number;
|
|
1916
1934
|
}
|
|
@@ -551,6 +551,16 @@ interface IWorktreeIsolation {
|
|
|
551
551
|
sweep(run: IsolationRun): Promise<void>;
|
|
552
552
|
}
|
|
553
553
|
|
|
554
|
+
/** How the runner says this session is paid for; absent means it has not said. */
|
|
555
|
+
interface SessionBilling {
|
|
556
|
+
type: 'subscription' | 'api-key';
|
|
557
|
+
plan?: string;
|
|
558
|
+
}
|
|
559
|
+
interface CostProvenance {
|
|
560
|
+
kind: 'estimate' | 'billed' | 'unknown';
|
|
561
|
+
billing: SessionBilling['type'] | 'unknown' | 'mixed';
|
|
562
|
+
basis?: 'list' | 'managed';
|
|
563
|
+
}
|
|
554
564
|
/**
|
|
555
565
|
* What one model call consumed, as its provider or runner reported it. Shared
|
|
556
566
|
* by the planner's usage line (#49) and per-attempt task usage (#26): a record
|
|
@@ -572,22 +582,47 @@ interface UsageRecord {
|
|
|
572
582
|
cachedInputTokens?: number;
|
|
573
583
|
/**
|
|
574
584
|
* Filled only from a provider's or runner's own report, never from a price
|
|
575
|
-
* table
|
|
585
|
+
* table kept in Ordewell: prices go stale, and a subscription runner has no
|
|
576
586
|
* per-token price at all. No report means no cost, not a guessed one.
|
|
577
587
|
*/
|
|
578
588
|
reportedCost?: {
|
|
579
589
|
amount: number;
|
|
580
590
|
currency: string;
|
|
591
|
+
kind?: 'estimate' | 'billed';
|
|
592
|
+
basis?: 'list' | 'managed';
|
|
581
593
|
};
|
|
594
|
+
sessionBilling?: SessionBilling;
|
|
582
595
|
/**
|
|
583
596
|
* The model's context window: as the runner or provider reported it, or,
|
|
584
597
|
* when it reported none, from that runner's or provider's own model listing
|
|
585
598
|
* (`ContextWindowFill`). Never from a table kept in Ordewell.
|
|
586
599
|
*/
|
|
587
600
|
contextWindow?: number;
|
|
601
|
+
/**
|
|
602
|
+
* What the main model's context holds once this call is done, counted the
|
|
603
|
+
* way its runner's own UI counts it, so the meter reads what the user would
|
|
604
|
+
* see there. Runners differ, and no sum of the measures above can tell.
|
|
605
|
+
* A measure of the meter only: no total adds it. Absent, the meter reads the
|
|
606
|
+
* prompt.
|
|
607
|
+
*/
|
|
608
|
+
contextTokens?: number;
|
|
609
|
+
/**
|
|
610
|
+
* The runner reset the main model's context outside a call — a compaction,
|
|
611
|
+
* or a `/clear`: no call, so the record measures nothing but `contextTokens`,
|
|
612
|
+
* the size it reported the context left at, if it did. It may name the model
|
|
613
|
+
* the new context belongs to; a record that names none is about whichever
|
|
614
|
+
* runs now.
|
|
615
|
+
*/
|
|
616
|
+
compacted?: true;
|
|
588
617
|
/** Set when a subagent made the call; its usage still counts toward the total. */
|
|
589
618
|
subagentId?: string;
|
|
590
619
|
}
|
|
620
|
+
/** A model's window as its reporter stated it: what a plan saves of its session's windows (`SessionWindows`). */
|
|
621
|
+
interface ReportedWindow {
|
|
622
|
+
source: string;
|
|
623
|
+
model: string;
|
|
624
|
+
contextWindow: number;
|
|
625
|
+
}
|
|
591
626
|
/**
|
|
592
627
|
* A running sum of {@link UsageRecord}s. A measure stays absent until some
|
|
593
628
|
* record reports it. Cost is kept per currency: two runners may bill in
|
|
@@ -598,6 +633,7 @@ interface UsageTotals {
|
|
|
598
633
|
outputTokens?: number;
|
|
599
634
|
cachedInputTokens?: number;
|
|
600
635
|
reportedCost?: Record<string, number>;
|
|
636
|
+
costProvenance?: Record<string, CostProvenance>;
|
|
601
637
|
}
|
|
602
638
|
/**
|
|
603
639
|
* The input side of a call whose provider reports its prompt in parts — the
|
|
@@ -617,9 +653,12 @@ declare function addUsage(totals: UsageTotals, record: UsageRecord): UsageTotals
|
|
|
617
653
|
* What the planner has consumed over a session (#49). `totals` includes every
|
|
618
654
|
* `bySubagent` entry. `lastPromptTokens` and `contextWindow` track the
|
|
619
655
|
* planner's own calls only — a subagent runs its own model, whose window says
|
|
620
|
-
* nothing about the planner's.
|
|
656
|
+
* nothing about the planner's. `lastPromptTokens` is the context the last call
|
|
657
|
+
* left (its `contextTokens`, else its prompt), under the name saved sessions
|
|
658
|
+
* already hold it by.
|
|
621
659
|
*/
|
|
622
660
|
interface PlannerUsage {
|
|
661
|
+
sessionBilling?: SessionBilling;
|
|
623
662
|
totals: UsageTotals;
|
|
624
663
|
bySubagent?: Record<string, UsageTotals>;
|
|
625
664
|
byModel?: ModelUsage[];
|
|
@@ -629,31 +668,35 @@ interface PlannerUsage {
|
|
|
629
668
|
contextWindow?: number;
|
|
630
669
|
}
|
|
631
670
|
declare function addPlannerUsage(usage: PlannerUsage, record: UsageRecord): PlannerUsage;
|
|
632
|
-
/** Whether any measure was reported: a
|
|
671
|
+
/** Whether any measure was reported: a usage line of nothing but blanks says nothing. */
|
|
633
672
|
declare function isMeasured(totals: UsageTotals): boolean;
|
|
634
|
-
/**
|
|
673
|
+
/**
|
|
674
|
+
* The main model's context: what its last call left in it, against its window
|
|
675
|
+
* when that is known. A window of 0 is not known.
|
|
676
|
+
*/
|
|
677
|
+
interface ContextFill {
|
|
678
|
+
usedTokens: number;
|
|
679
|
+
windowTokens?: number;
|
|
680
|
+
}
|
|
681
|
+
/** What the usage line draws of a ledger — live from its broadcast, or reloaded from the saved one. */
|
|
635
682
|
interface UsageLine {
|
|
683
|
+
sessionBilling?: SessionBilling;
|
|
636
684
|
byModel?: ModelUsage[];
|
|
637
685
|
model?: string;
|
|
638
686
|
totals: UsageTotals;
|
|
639
687
|
bySubagent?: Record<string, UsageTotals>;
|
|
640
|
-
contextFill?:
|
|
641
|
-
usedTokens: number;
|
|
642
|
-
windowTokens: number;
|
|
643
|
-
};
|
|
688
|
+
contextFill?: ContextFill;
|
|
644
689
|
}
|
|
645
690
|
declare function usageLine(usage: PlannerUsage): UsageLine;
|
|
646
691
|
/**
|
|
647
|
-
* The
|
|
648
|
-
*
|
|
692
|
+
* The main model's context as its last call left it, or undefined before one
|
|
693
|
+
* was measured and after a compaction that reported no size. `usedTokens` is
|
|
694
|
+
* what that call stated as its context, else its prompt total, cached tokens
|
|
649
695
|
* included: a cached token still occupies the window, so subtracting the
|
|
650
|
-
* cached share would understate how full the context is.
|
|
651
|
-
* treated as unknown — never guessed.
|
|
696
|
+
* cached share would understate how full the context is. The window rides
|
|
697
|
+
* along only when known; a window of 0 is treated as unknown — never guessed.
|
|
652
698
|
*/
|
|
653
|
-
declare function plannerContextFill(usage: PlannerUsage):
|
|
654
|
-
usedTokens: number;
|
|
655
|
-
windowTokens: number;
|
|
656
|
-
} | undefined;
|
|
699
|
+
declare function plannerContextFill(usage: PlannerUsage): ContextFill | undefined;
|
|
657
700
|
interface ModelUsage {
|
|
658
701
|
source: string;
|
|
659
702
|
model?: string;
|
|
@@ -683,7 +726,9 @@ interface AttemptUsage extends PlannerUsage {
|
|
|
683
726
|
runnerSessionCost?: RunnerSessionCost;
|
|
684
727
|
}
|
|
685
728
|
declare function startAttemptUsage(attempt: number, runner: string, startedAt: string): AttemptUsage;
|
|
729
|
+
/** What its runner reports as it winds down after the attempt ended is added without moving its end. */
|
|
686
730
|
declare function addAttemptUsage(usage: AttemptUsage, record: UsageRecord, now: string): AttemptUsage;
|
|
731
|
+
/** An attempt ends once; ended again once its runner wound down, it only takes the count that runner ended on. */
|
|
687
732
|
declare function endAttemptUsage(usage: AttemptUsage, now: string, runnerSessionCost?: RunnerSessionCost, sessionId?: string): AttemptUsage;
|
|
688
733
|
/** The count a continue of `sessionId` starts from: the one its latest attempt in that session ended with. */
|
|
689
734
|
declare function countedSessionCost(attempts: readonly AttemptUsage[] | undefined, sessionId: string): RunnerSessionCost | undefined;
|
|
@@ -716,12 +761,38 @@ declare function planUsage(tasks: readonly UsageTask[]): PlanUsage;
|
|
|
716
761
|
interface TaskUsageSummary {
|
|
717
762
|
totals: UsageTotals;
|
|
718
763
|
attempts: number;
|
|
719
|
-
contextFill?:
|
|
720
|
-
usedTokens: number;
|
|
721
|
-
windowTokens: number;
|
|
722
|
-
};
|
|
764
|
+
contextFill?: ContextFill;
|
|
723
765
|
}
|
|
724
766
|
declare function taskUsageSummary(task: Pick<UsageTask, 'attemptUsage'>): TaskUsageSummary;
|
|
767
|
+
/** `950`, `1.5k`, `61k`, `261k`, `1.2M`. */
|
|
768
|
+
declare function formatTokenCount(n: number): string;
|
|
769
|
+
/** Two decimals from 1 up and up to four below it: a call can cost a fraction of a cent, a session several dollars. */
|
|
770
|
+
declare function formatCost(currency: string, amount: number): string;
|
|
771
|
+
/** `ctx 61k (6%)`, `ctx 61k` while the window is unknown, nothing before a call was measured. */
|
|
772
|
+
declare function contextMeterText(fill: ContextFill | undefined): string | null;
|
|
773
|
+
/** Exact counts for the meter's hover. */
|
|
774
|
+
declare function contextMeterTitle(fill: ContextFill): string;
|
|
775
|
+
/** The cost per currency as reported, joined by ` · `; null when none was reported. */
|
|
776
|
+
declare function costText(totals: UsageTotals): string | null;
|
|
777
|
+
/** The meter, then the cost, joined by ` · `; null when neither is known. */
|
|
778
|
+
declare function usageText(usage: {
|
|
779
|
+
totals: UsageTotals;
|
|
780
|
+
contextFill?: ContextFill;
|
|
781
|
+
}): string | null;
|
|
782
|
+
/** Each runner/model's reported cost for the cost's hover, leaving out models with none. */
|
|
783
|
+
declare function modelCostTitle(byModel: readonly ModelUsage[]): string | undefined;
|
|
784
|
+
/** Each subagent's reported cost for the subagent count's hover, or that it reported none. */
|
|
785
|
+
declare function subagentCostTitle(bySubagent: Readonly<Record<string, UsageTotals>>): string;
|
|
786
|
+
/**
|
|
787
|
+
* `Tasks total: $3.20 · codex reports no cost`: the cost over every attempt,
|
|
788
|
+
* then the runners none of whose attempts reported one — codex reports no
|
|
789
|
+
* price, and a price table is not Ordewell's to keep (ADR-0017 U1). A runner is
|
|
790
|
+
* named only once an attempt of it has ended having reported usage: Claude
|
|
791
|
+
* Code states a cost only on a turn's last line, so a first attempt still in
|
|
792
|
+
* its turn has not said yet, and one that never ran said nothing. A total has
|
|
793
|
+
* no meter: each task's own model holds its own window.
|
|
794
|
+
*/
|
|
795
|
+
declare function tasksTotalText(tasks: readonly UsageTask[]): string | null;
|
|
725
796
|
|
|
726
797
|
/**
|
|
727
798
|
* How far a plan's supervisor may act in its wake-up turns (ADR-0029): a plan
|
|
@@ -1397,6 +1468,8 @@ interface LegacyPlanState {
|
|
|
1397
1468
|
isolation?: PlanIsolation;
|
|
1398
1469
|
/** Kept so a reopened session shows the same token line (#49). */
|
|
1399
1470
|
plannerUsage?: PlannerUsage;
|
|
1471
|
+
/** The windows reported over the session, so a reopened one knows each model's from its first call. */
|
|
1472
|
+
contextWindows?: ReportedWindow[];
|
|
1400
1473
|
/** The planner hit its usage limit and the inputs its turn took wait to be sent again; absent otherwise. */
|
|
1401
1474
|
plannerResend?: PlannerResendState;
|
|
1402
1475
|
/**
|
|
@@ -1489,4 +1562,4 @@ type ApprovalRecord = Pick<LegacyPlanState, 'approved' | 'approvedTasks'>;
|
|
|
1489
1562
|
*/
|
|
1490
1563
|
declare function waitsForApproval(task: Pick<Task, 'id' | 'type' | 'status'>, record: ApprovalRecord): boolean;
|
|
1491
1564
|
|
|
1492
|
-
export { type
|
|
1565
|
+
export { type RepoGroupLayout as $, type ApprovalRecord as A, BUILTIN_SKILL_NAMES as B, type ContextFill as C, DEFAULT_RUNNERS as D, type ExecutionActor as E, type IsolationTaskRef as F, type GuardTarget as G, type IsolationTaskRepo as H, type IWorktreeIsolation as I, type IsolationTaskStatus as J, type IsolationView as K, type LegacyPlanState as L, type ModelUsage as M, type PlanIsolation as N, type PlanState as O, type PendingPlanTurn as P, type PlanStatus as Q, type PlanUsage as R, type PlannerResendState as S, type PlannerUsage as T, type PrepareIntent as U, type PreparedTask as V, type PreservedWork as W, type PreviousWork as X, type RefusedRemoval as Y, type RepairEvidence as Z, type ReplyRun as _, type AttemptUsage as a, pausedOnLimit as a$, type ReportedWindow as a0, type ResearchLogEntry as a1, type ResearchProgress as a2, type ResearchStep as a3, type ResearchStepOutcome as a4, type ResearchToolType as a5, type RunSettings as a6, type RunnerId as a7, type RunnerSessionCost as a8, type SessionBilling as a9, type UsageTotals as aA, type Verdict as aB, type VerificationCheck as aC, addAttemptUsage as aD, addModelUsage as aE, addPlannerUsage as aF, addUsage as aG, addUsageTotals as aH, contextMeterText as aI, contextMeterTitle as aJ, costText as aK, countedSessionCost as aL, createEmptyPlan as aM, createSkillsService as aN, createTask as aO, endAttemptUsage as aP, flattenTasks as aQ, flattenTasksWithParents as aR, formatCost as aS, formatTokenCount as aT, isAwaitingReason as aU, isMeasured as aV, isSupervisorLevel as aW, isUserMessage as aX, migratePlanState as aY, modelCostTitle as aZ, partedPromptUsage as a_, type SetupFailure as aa, type ShadowedSkill as ab, type SkillAppliesTo as ac, type SkillCatalog as ad, type SkillInfo as ae, type SkillLoad as af, type SkillLoadNotice as ag, type SkillMetadata as ah, type SkillSource as ai, SkillsService as aj, type SubagentOutcome as ak, type SupervisorLevel as al, type Task as am, type TaskDiffRead as an, type TaskDiffResult as ao, type TaskIsolation as ap, type TaskIsolationState as aq, type TaskModelAssignment as ar, type TaskSkillNotice as as, type TaskSkillSnapshot as at, type TaskSnapshot as au, type TaskStatus as av, type TaskUsageSummary as aw, type TreeSnapshot as ax, type UsageLine as ay, type UsageRecord as az, type AwaitingReason as b, planUsage as b0, plannerContextFill as b1, rejoinPlanTree as b2, resumedSessionWindow as b3, startAttemptUsage as b4, subagentCostTitle as b5, taskUsageSummary as b6, tasksTotalText as b7, usageLine as b8, usageText as b9, waitsForApproval as ba, type ConversationMessage as c, type CostProvenance as d, DEFAULT_SUPERVISOR_RETRY_LIMIT as e, type DiscoveredModel as f, type ExecutionCommandName as g, type ExecutionRecord as h, type GuardTrip as i, type IntegrationDisposal as j, type InvalidSkill as k, type IsolationAvailability as l, type IsolationHandoff as m, type IsolationHandoffRepo as n, type IsolationInactiveReason as o, type IsolationLandedTask as p, type IsolationLanding as q, type IsolationMergeBlock as r, type IsolationMergeBlockReason as s, type IsolationMergeResult as t, type IsolationOutcome as u, type IsolationPruneResult as v, type IsolationRemoval as w, type IsolationRepo as x, type IsolationRun as y, type IsolationTaskRecord as z };
|
|
@@ -551,6 +551,16 @@ interface IWorktreeIsolation {
|
|
|
551
551
|
sweep(run: IsolationRun): Promise<void>;
|
|
552
552
|
}
|
|
553
553
|
|
|
554
|
+
/** How the runner says this session is paid for; absent means it has not said. */
|
|
555
|
+
interface SessionBilling {
|
|
556
|
+
type: 'subscription' | 'api-key';
|
|
557
|
+
plan?: string;
|
|
558
|
+
}
|
|
559
|
+
interface CostProvenance {
|
|
560
|
+
kind: 'estimate' | 'billed' | 'unknown';
|
|
561
|
+
billing: SessionBilling['type'] | 'unknown' | 'mixed';
|
|
562
|
+
basis?: 'list' | 'managed';
|
|
563
|
+
}
|
|
554
564
|
/**
|
|
555
565
|
* What one model call consumed, as its provider or runner reported it. Shared
|
|
556
566
|
* by the planner's usage line (#49) and per-attempt task usage (#26): a record
|
|
@@ -572,22 +582,47 @@ interface UsageRecord {
|
|
|
572
582
|
cachedInputTokens?: number;
|
|
573
583
|
/**
|
|
574
584
|
* Filled only from a provider's or runner's own report, never from a price
|
|
575
|
-
* table
|
|
585
|
+
* table kept in Ordewell: prices go stale, and a subscription runner has no
|
|
576
586
|
* per-token price at all. No report means no cost, not a guessed one.
|
|
577
587
|
*/
|
|
578
588
|
reportedCost?: {
|
|
579
589
|
amount: number;
|
|
580
590
|
currency: string;
|
|
591
|
+
kind?: 'estimate' | 'billed';
|
|
592
|
+
basis?: 'list' | 'managed';
|
|
581
593
|
};
|
|
594
|
+
sessionBilling?: SessionBilling;
|
|
582
595
|
/**
|
|
583
596
|
* The model's context window: as the runner or provider reported it, or,
|
|
584
597
|
* when it reported none, from that runner's or provider's own model listing
|
|
585
598
|
* (`ContextWindowFill`). Never from a table kept in Ordewell.
|
|
586
599
|
*/
|
|
587
600
|
contextWindow?: number;
|
|
601
|
+
/**
|
|
602
|
+
* What the main model's context holds once this call is done, counted the
|
|
603
|
+
* way its runner's own UI counts it, so the meter reads what the user would
|
|
604
|
+
* see there. Runners differ, and no sum of the measures above can tell.
|
|
605
|
+
* A measure of the meter only: no total adds it. Absent, the meter reads the
|
|
606
|
+
* prompt.
|
|
607
|
+
*/
|
|
608
|
+
contextTokens?: number;
|
|
609
|
+
/**
|
|
610
|
+
* The runner reset the main model's context outside a call — a compaction,
|
|
611
|
+
* or a `/clear`: no call, so the record measures nothing but `contextTokens`,
|
|
612
|
+
* the size it reported the context left at, if it did. It may name the model
|
|
613
|
+
* the new context belongs to; a record that names none is about whichever
|
|
614
|
+
* runs now.
|
|
615
|
+
*/
|
|
616
|
+
compacted?: true;
|
|
588
617
|
/** Set when a subagent made the call; its usage still counts toward the total. */
|
|
589
618
|
subagentId?: string;
|
|
590
619
|
}
|
|
620
|
+
/** A model's window as its reporter stated it: what a plan saves of its session's windows (`SessionWindows`). */
|
|
621
|
+
interface ReportedWindow {
|
|
622
|
+
source: string;
|
|
623
|
+
model: string;
|
|
624
|
+
contextWindow: number;
|
|
625
|
+
}
|
|
591
626
|
/**
|
|
592
627
|
* A running sum of {@link UsageRecord}s. A measure stays absent until some
|
|
593
628
|
* record reports it. Cost is kept per currency: two runners may bill in
|
|
@@ -598,6 +633,7 @@ interface UsageTotals {
|
|
|
598
633
|
outputTokens?: number;
|
|
599
634
|
cachedInputTokens?: number;
|
|
600
635
|
reportedCost?: Record<string, number>;
|
|
636
|
+
costProvenance?: Record<string, CostProvenance>;
|
|
601
637
|
}
|
|
602
638
|
/**
|
|
603
639
|
* The input side of a call whose provider reports its prompt in parts — the
|
|
@@ -617,9 +653,12 @@ declare function addUsage(totals: UsageTotals, record: UsageRecord): UsageTotals
|
|
|
617
653
|
* What the planner has consumed over a session (#49). `totals` includes every
|
|
618
654
|
* `bySubagent` entry. `lastPromptTokens` and `contextWindow` track the
|
|
619
655
|
* planner's own calls only — a subagent runs its own model, whose window says
|
|
620
|
-
* nothing about the planner's.
|
|
656
|
+
* nothing about the planner's. `lastPromptTokens` is the context the last call
|
|
657
|
+
* left (its `contextTokens`, else its prompt), under the name saved sessions
|
|
658
|
+
* already hold it by.
|
|
621
659
|
*/
|
|
622
660
|
interface PlannerUsage {
|
|
661
|
+
sessionBilling?: SessionBilling;
|
|
623
662
|
totals: UsageTotals;
|
|
624
663
|
bySubagent?: Record<string, UsageTotals>;
|
|
625
664
|
byModel?: ModelUsage[];
|
|
@@ -629,31 +668,35 @@ interface PlannerUsage {
|
|
|
629
668
|
contextWindow?: number;
|
|
630
669
|
}
|
|
631
670
|
declare function addPlannerUsage(usage: PlannerUsage, record: UsageRecord): PlannerUsage;
|
|
632
|
-
/** Whether any measure was reported: a
|
|
671
|
+
/** Whether any measure was reported: a usage line of nothing but blanks says nothing. */
|
|
633
672
|
declare function isMeasured(totals: UsageTotals): boolean;
|
|
634
|
-
/**
|
|
673
|
+
/**
|
|
674
|
+
* The main model's context: what its last call left in it, against its window
|
|
675
|
+
* when that is known. A window of 0 is not known.
|
|
676
|
+
*/
|
|
677
|
+
interface ContextFill {
|
|
678
|
+
usedTokens: number;
|
|
679
|
+
windowTokens?: number;
|
|
680
|
+
}
|
|
681
|
+
/** What the usage line draws of a ledger — live from its broadcast, or reloaded from the saved one. */
|
|
635
682
|
interface UsageLine {
|
|
683
|
+
sessionBilling?: SessionBilling;
|
|
636
684
|
byModel?: ModelUsage[];
|
|
637
685
|
model?: string;
|
|
638
686
|
totals: UsageTotals;
|
|
639
687
|
bySubagent?: Record<string, UsageTotals>;
|
|
640
|
-
contextFill?:
|
|
641
|
-
usedTokens: number;
|
|
642
|
-
windowTokens: number;
|
|
643
|
-
};
|
|
688
|
+
contextFill?: ContextFill;
|
|
644
689
|
}
|
|
645
690
|
declare function usageLine(usage: PlannerUsage): UsageLine;
|
|
646
691
|
/**
|
|
647
|
-
* The
|
|
648
|
-
*
|
|
692
|
+
* The main model's context as its last call left it, or undefined before one
|
|
693
|
+
* was measured and after a compaction that reported no size. `usedTokens` is
|
|
694
|
+
* what that call stated as its context, else its prompt total, cached tokens
|
|
649
695
|
* included: a cached token still occupies the window, so subtracting the
|
|
650
|
-
* cached share would understate how full the context is.
|
|
651
|
-
* treated as unknown — never guessed.
|
|
696
|
+
* cached share would understate how full the context is. The window rides
|
|
697
|
+
* along only when known; a window of 0 is treated as unknown — never guessed.
|
|
652
698
|
*/
|
|
653
|
-
declare function plannerContextFill(usage: PlannerUsage):
|
|
654
|
-
usedTokens: number;
|
|
655
|
-
windowTokens: number;
|
|
656
|
-
} | undefined;
|
|
699
|
+
declare function plannerContextFill(usage: PlannerUsage): ContextFill | undefined;
|
|
657
700
|
interface ModelUsage {
|
|
658
701
|
source: string;
|
|
659
702
|
model?: string;
|
|
@@ -683,7 +726,9 @@ interface AttemptUsage extends PlannerUsage {
|
|
|
683
726
|
runnerSessionCost?: RunnerSessionCost;
|
|
684
727
|
}
|
|
685
728
|
declare function startAttemptUsage(attempt: number, runner: string, startedAt: string): AttemptUsage;
|
|
729
|
+
/** What its runner reports as it winds down after the attempt ended is added without moving its end. */
|
|
686
730
|
declare function addAttemptUsage(usage: AttemptUsage, record: UsageRecord, now: string): AttemptUsage;
|
|
731
|
+
/** An attempt ends once; ended again once its runner wound down, it only takes the count that runner ended on. */
|
|
687
732
|
declare function endAttemptUsage(usage: AttemptUsage, now: string, runnerSessionCost?: RunnerSessionCost, sessionId?: string): AttemptUsage;
|
|
688
733
|
/** The count a continue of `sessionId` starts from: the one its latest attempt in that session ended with. */
|
|
689
734
|
declare function countedSessionCost(attempts: readonly AttemptUsage[] | undefined, sessionId: string): RunnerSessionCost | undefined;
|
|
@@ -716,12 +761,38 @@ declare function planUsage(tasks: readonly UsageTask[]): PlanUsage;
|
|
|
716
761
|
interface TaskUsageSummary {
|
|
717
762
|
totals: UsageTotals;
|
|
718
763
|
attempts: number;
|
|
719
|
-
contextFill?:
|
|
720
|
-
usedTokens: number;
|
|
721
|
-
windowTokens: number;
|
|
722
|
-
};
|
|
764
|
+
contextFill?: ContextFill;
|
|
723
765
|
}
|
|
724
766
|
declare function taskUsageSummary(task: Pick<UsageTask, 'attemptUsage'>): TaskUsageSummary;
|
|
767
|
+
/** `950`, `1.5k`, `61k`, `261k`, `1.2M`. */
|
|
768
|
+
declare function formatTokenCount(n: number): string;
|
|
769
|
+
/** Two decimals from 1 up and up to four below it: a call can cost a fraction of a cent, a session several dollars. */
|
|
770
|
+
declare function formatCost(currency: string, amount: number): string;
|
|
771
|
+
/** `ctx 61k (6%)`, `ctx 61k` while the window is unknown, nothing before a call was measured. */
|
|
772
|
+
declare function contextMeterText(fill: ContextFill | undefined): string | null;
|
|
773
|
+
/** Exact counts for the meter's hover. */
|
|
774
|
+
declare function contextMeterTitle(fill: ContextFill): string;
|
|
775
|
+
/** The cost per currency as reported, joined by ` · `; null when none was reported. */
|
|
776
|
+
declare function costText(totals: UsageTotals): string | null;
|
|
777
|
+
/** The meter, then the cost, joined by ` · `; null when neither is known. */
|
|
778
|
+
declare function usageText(usage: {
|
|
779
|
+
totals: UsageTotals;
|
|
780
|
+
contextFill?: ContextFill;
|
|
781
|
+
}): string | null;
|
|
782
|
+
/** Each runner/model's reported cost for the cost's hover, leaving out models with none. */
|
|
783
|
+
declare function modelCostTitle(byModel: readonly ModelUsage[]): string | undefined;
|
|
784
|
+
/** Each subagent's reported cost for the subagent count's hover, or that it reported none. */
|
|
785
|
+
declare function subagentCostTitle(bySubagent: Readonly<Record<string, UsageTotals>>): string;
|
|
786
|
+
/**
|
|
787
|
+
* `Tasks total: $3.20 · codex reports no cost`: the cost over every attempt,
|
|
788
|
+
* then the runners none of whose attempts reported one — codex reports no
|
|
789
|
+
* price, and a price table is not Ordewell's to keep (ADR-0017 U1). A runner is
|
|
790
|
+
* named only once an attempt of it has ended having reported usage: Claude
|
|
791
|
+
* Code states a cost only on a turn's last line, so a first attempt still in
|
|
792
|
+
* its turn has not said yet, and one that never ran said nothing. A total has
|
|
793
|
+
* no meter: each task's own model holds its own window.
|
|
794
|
+
*/
|
|
795
|
+
declare function tasksTotalText(tasks: readonly UsageTask[]): string | null;
|
|
725
796
|
|
|
726
797
|
/**
|
|
727
798
|
* How far a plan's supervisor may act in its wake-up turns (ADR-0029): a plan
|
|
@@ -1397,6 +1468,8 @@ interface LegacyPlanState {
|
|
|
1397
1468
|
isolation?: PlanIsolation;
|
|
1398
1469
|
/** Kept so a reopened session shows the same token line (#49). */
|
|
1399
1470
|
plannerUsage?: PlannerUsage;
|
|
1471
|
+
/** The windows reported over the session, so a reopened one knows each model's from its first call. */
|
|
1472
|
+
contextWindows?: ReportedWindow[];
|
|
1400
1473
|
/** The planner hit its usage limit and the inputs its turn took wait to be sent again; absent otherwise. */
|
|
1401
1474
|
plannerResend?: PlannerResendState;
|
|
1402
1475
|
/**
|
|
@@ -1489,4 +1562,4 @@ type ApprovalRecord = Pick<LegacyPlanState, 'approved' | 'approvedTasks'>;
|
|
|
1489
1562
|
*/
|
|
1490
1563
|
declare function waitsForApproval(task: Pick<Task, 'id' | 'type' | 'status'>, record: ApprovalRecord): boolean;
|
|
1491
1564
|
|
|
1492
|
-
export { type
|
|
1565
|
+
export { type RepoGroupLayout as $, type ApprovalRecord as A, BUILTIN_SKILL_NAMES as B, type ContextFill as C, DEFAULT_RUNNERS as D, type ExecutionActor as E, type IsolationTaskRef as F, type GuardTarget as G, type IsolationTaskRepo as H, type IWorktreeIsolation as I, type IsolationTaskStatus as J, type IsolationView as K, type LegacyPlanState as L, type ModelUsage as M, type PlanIsolation as N, type PlanState as O, type PendingPlanTurn as P, type PlanStatus as Q, type PlanUsage as R, type PlannerResendState as S, type PlannerUsage as T, type PrepareIntent as U, type PreparedTask as V, type PreservedWork as W, type PreviousWork as X, type RefusedRemoval as Y, type RepairEvidence as Z, type ReplyRun as _, type AttemptUsage as a, pausedOnLimit as a$, type ReportedWindow as a0, type ResearchLogEntry as a1, type ResearchProgress as a2, type ResearchStep as a3, type ResearchStepOutcome as a4, type ResearchToolType as a5, type RunSettings as a6, type RunnerId as a7, type RunnerSessionCost as a8, type SessionBilling as a9, type UsageTotals as aA, type Verdict as aB, type VerificationCheck as aC, addAttemptUsage as aD, addModelUsage as aE, addPlannerUsage as aF, addUsage as aG, addUsageTotals as aH, contextMeterText as aI, contextMeterTitle as aJ, costText as aK, countedSessionCost as aL, createEmptyPlan as aM, createSkillsService as aN, createTask as aO, endAttemptUsage as aP, flattenTasks as aQ, flattenTasksWithParents as aR, formatCost as aS, formatTokenCount as aT, isAwaitingReason as aU, isMeasured as aV, isSupervisorLevel as aW, isUserMessage as aX, migratePlanState as aY, modelCostTitle as aZ, partedPromptUsage as a_, type SetupFailure as aa, type ShadowedSkill as ab, type SkillAppliesTo as ac, type SkillCatalog as ad, type SkillInfo as ae, type SkillLoad as af, type SkillLoadNotice as ag, type SkillMetadata as ah, type SkillSource as ai, SkillsService as aj, type SubagentOutcome as ak, type SupervisorLevel as al, type Task as am, type TaskDiffRead as an, type TaskDiffResult as ao, type TaskIsolation as ap, type TaskIsolationState as aq, type TaskModelAssignment as ar, type TaskSkillNotice as as, type TaskSkillSnapshot as at, type TaskSnapshot as au, type TaskStatus as av, type TaskUsageSummary as aw, type TreeSnapshot as ax, type UsageLine as ay, type UsageRecord as az, type AwaitingReason as b, planUsage as b0, plannerContextFill as b1, rejoinPlanTree as b2, resumedSessionWindow as b3, startAttemptUsage as b4, subagentCostTitle as b5, taskUsageSummary as b6, tasksTotalText as b7, usageLine as b8, usageText as b9, waitsForApproval as ba, type ConversationMessage as c, type CostProvenance as d, DEFAULT_SUPERVISOR_RETRY_LIMIT as e, type DiscoveredModel as f, type ExecutionCommandName as g, type ExecutionRecord as h, type GuardTrip as i, type IntegrationDisposal as j, type InvalidSkill as k, type IsolationAvailability as l, type IsolationHandoff as m, type IsolationHandoffRepo as n, type IsolationInactiveReason as o, type IsolationLandedTask as p, type IsolationLanding as q, type IsolationMergeBlock as r, type IsolationMergeBlockReason as s, type IsolationMergeResult as t, type IsolationOutcome as u, type IsolationPruneResult as v, type IsolationRemoval as w, type IsolationRepo as x, type IsolationRun as y, type IsolationTaskRecord as z };
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
flattenTasksWithParents,
|
|
8
8
|
inheritedSkills,
|
|
9
9
|
skillNames
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-PFH7WFIB.mjs";
|
|
11
11
|
|
|
12
12
|
// src/services/JsonExtractor.ts
|
|
13
13
|
var PLAN_ENVELOPE_KEY = "tasks";
|
|
@@ -644,4 +644,4 @@ export {
|
|
|
644
644
|
checkPlanInvariants,
|
|
645
645
|
detectCycle
|
|
646
646
|
};
|
|
647
|
-
//# sourceMappingURL=chunk-
|
|
647
|
+
//# sourceMappingURL=chunk-24EL4Z2W.mjs.map
|