agent-afk 5.290.4 → 5.291.0
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/agent/awareness/types.d.ts +4 -0
- package/dist/agent/daemon/budget-gate.d.ts +31 -0
- package/dist/agent/daemon/gates.d.ts +1 -1
- package/dist/agent/daemon/scheduler.d.ts +2 -0
- package/dist/agent/daemon/scheduler.overlap-guard.d.ts +2 -0
- package/dist/agent/daemon/tool-health-task.d.ts +17 -0
- package/dist/agent/daemon/triggers.d.ts +1 -1
- package/dist/agent/facets/schema.d.ts +10 -2
- package/dist/agent/outcomes/schema.d.ts +1 -1
- package/dist/agent/peer/admission-queue.d.ts +39 -0
- package/dist/agent/peer/inbox-store.d.ts +2 -0
- package/dist/agent/provider.d.ts +1 -0
- package/dist/agent/providers/anthropic-direct/auth.d.ts +2 -1
- package/dist/agent/providers/anthropic-direct/beta-headers.d.ts +2 -0
- package/dist/agent/providers/anthropic-direct/input-transformations.d.ts +3 -0
- package/dist/agent/providers/anthropic-direct/loop/round-request.d.ts +1 -1
- package/dist/agent/providers/anthropic-direct/query/turn-request.d.ts +1 -0
- package/dist/agent/providers/anthropic-direct/query-options.d.ts +2 -0
- package/dist/agent/providers/anthropic-direct/query-runtime.d.ts +3 -0
- package/dist/agent/providers/anthropic-direct/query-turn-driver.d.ts +1 -0
- package/dist/agent/providers/anthropic-direct/request-types.d.ts +8 -1
- package/dist/agent/providers/anthropic-direct/resolve-params.d.ts +4 -1
- package/dist/agent/providers/openai-compatible/complete-wire.d.ts +11 -0
- package/dist/agent/providers/openai-compatible/oneshot.d.ts +1 -0
- package/dist/agent/providers/openai-compatible/query/client.d.ts +1 -0
- package/dist/agent/providers/openai-compatible/query/overload-pause-tier.d.ts +1 -0
- package/dist/agent/providers/router/provider-router.d.ts +2 -0
- package/dist/agent/providers/router/provider-router.switch.d.ts +4 -0
- package/dist/agent/providers/shared/compaction.d.ts +4 -0
- package/dist/agent/providers/shared/rate-limit-bucket.d.ts +18 -0
- package/dist/agent/providers/shared/rate-limit-bucket.registry.d.ts +3 -0
- package/dist/agent/providers/shared/transient-retry.d.ts +18 -0
- package/dist/agent/providers/shared/transient-retry.trace.d.ts +3 -0
- package/dist/agent/session/model-slots.d.ts +1 -0
- package/dist/agent/state/state-store.d.ts +1 -0
- package/dist/agent/subagent/usage-limit-park-policy.d.ts +3 -0
- package/dist/agent/tools/dispatcher.batch-process.d.ts +4 -0
- package/dist/agent/tools/dispatcher.d.ts +1 -0
- package/dist/agent/tools/dispatcher.execute-batch.d.ts +2 -0
- package/dist/agent/tools/handlers/worktree-managed.d.ts +1 -0
- package/dist/agent/tools/tool-health-monitor.d.ts +26 -0
- package/dist/agent/tools/usage-notice.d.ts +8 -0
- package/dist/agent/trace/events.d.ts +13 -0
- package/dist/agent/trace/events.session-phase.d.ts +4 -0
- package/dist/agent/trace/types.d.ts +3 -13
- package/dist/agent/trace/types.session-phase.d.ts +12 -0
- package/dist/agent/types/session-types.d.ts +1 -0
- package/dist/agent/usage/codex-usage.d.ts +12 -0
- package/dist/agent/usage/usage-budget.d.ts +24 -0
- package/dist/agent/usage/usage-formatter.d.ts +52 -0
- package/dist/agent/usage/usage-http.d.ts +11 -0
- package/dist/agent/usage/usage-ledger.d.ts +13 -0
- package/dist/agent/usage/usage-record.d.ts +37 -0
- package/dist/agent/usage/usage-snapshot.d.ts +21 -0
- package/dist/cli/commands/daemon-builtin-tasks.d.ts +15 -0
- package/dist/cli/commands/interactive/interactive.cleanup.d.ts +6 -1
- package/dist/cli/commands/interactive/loop-iteration.boundary.d.ts +36 -0
- package/dist/cli/commands/interactive/peer-inbox-notifier.d.ts +11 -1
- package/dist/cli/commands/interactive/shared.d.ts +4 -1
- package/dist/cli/commands/interactive/surface-setup.suggest-config.d.ts +0 -1
- package/dist/cli/commands/usage.d.ts +9 -0
- package/dist/cli/config/json-tier-parse.daemon.d.ts +2 -0
- package/dist/cli/config/types.d.ts +8 -0
- package/dist/cli/constants.d.ts +0 -2
- package/dist/cli/input/suggest-credential.d.ts +10 -0
- package/dist/cli/input/suggest-types.d.ts +2 -1
- package/dist/cli/session-store.d.ts +6 -1
- package/dist/cli/tool-category.d.ts +1 -0
- package/dist/cli.mjs +491 -474
- package/dist/config/env.d.ts +38 -0
- package/dist/config/env.daemon.d.ts +22 -0
- package/dist/config/env.misc.d.ts +8 -0
- package/dist/config/env.model-tiers.d.ts +8 -0
- package/dist/index.mjs +216 -208
- package/dist/paths.daemon.d.ts +1 -0
- package/dist/telegram.mjs +189 -180
- package/dist/web-ui-assets/assets/{index-MIgeDul2.js → index-BtgJsRFJ.js} +1 -1
- package/dist/web-ui-assets/assets/index-gg5vv6YH.js +380 -0
- package/dist/web-ui-assets/index.html +1 -1
- package/package.json +2 -3
- package/dist/web-ui-assets/assets/index-CpbGrtNj.js +0 -380
|
@@ -381,9 +381,12 @@ export declare const PeerMessagePayloadSchema: z.ZodObject<{
|
|
|
381
381
|
action: z.ZodEnum<{
|
|
382
382
|
delivered: "delivered";
|
|
383
383
|
sent: "sent";
|
|
384
|
+
claimed: "claimed";
|
|
385
|
+
injected: "injected";
|
|
384
386
|
held: "held";
|
|
385
387
|
refused: "refused";
|
|
386
388
|
dropped: "dropped";
|
|
389
|
+
reclaimed: "reclaimed";
|
|
387
390
|
}>;
|
|
388
391
|
messageId: z.ZodOptional<z.ZodString>;
|
|
389
392
|
peer: z.ZodString;
|
|
@@ -714,9 +717,12 @@ export declare const TraceEventInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
714
717
|
action: z.ZodEnum<{
|
|
715
718
|
delivered: "delivered";
|
|
716
719
|
sent: "sent";
|
|
720
|
+
claimed: "claimed";
|
|
721
|
+
injected: "injected";
|
|
717
722
|
held: "held";
|
|
718
723
|
refused: "refused";
|
|
719
724
|
dropped: "dropped";
|
|
725
|
+
reclaimed: "reclaimed";
|
|
720
726
|
}>;
|
|
721
727
|
messageId: z.ZodOptional<z.ZodString>;
|
|
722
728
|
peer: z.ZodString;
|
|
@@ -757,6 +763,8 @@ export declare const TraceEventInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
757
763
|
many_image_degraded: "many_image_degraded";
|
|
758
764
|
stream_accepted_after_drop: "stream_accepted_after_drop";
|
|
759
765
|
connection_retry: "connection_retry";
|
|
766
|
+
usage_notice: "usage_notice";
|
|
767
|
+
tool_degraded: "tool_degraded";
|
|
760
768
|
}>;
|
|
761
769
|
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
762
770
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
@@ -1110,9 +1118,12 @@ export declare const TraceEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1110
1118
|
action: z.ZodEnum<{
|
|
1111
1119
|
delivered: "delivered";
|
|
1112
1120
|
sent: "sent";
|
|
1121
|
+
claimed: "claimed";
|
|
1122
|
+
injected: "injected";
|
|
1113
1123
|
held: "held";
|
|
1114
1124
|
refused: "refused";
|
|
1115
1125
|
dropped: "dropped";
|
|
1126
|
+
reclaimed: "reclaimed";
|
|
1116
1127
|
}>;
|
|
1117
1128
|
messageId: z.ZodOptional<z.ZodString>;
|
|
1118
1129
|
peer: z.ZodString;
|
|
@@ -1155,6 +1166,8 @@ export declare const TraceEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1155
1166
|
many_image_degraded: "many_image_degraded";
|
|
1156
1167
|
stream_accepted_after_drop: "stream_accepted_after_drop";
|
|
1157
1168
|
connection_retry: "connection_retry";
|
|
1169
|
+
usage_notice: "usage_notice";
|
|
1170
|
+
tool_degraded: "tool_degraded";
|
|
1158
1171
|
}>;
|
|
1159
1172
|
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
1160
1173
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
@@ -30,6 +30,8 @@ export declare const SessionPhaseNameSchema: z.ZodEnum<{
|
|
|
30
30
|
many_image_degraded: "many_image_degraded";
|
|
31
31
|
stream_accepted_after_drop: "stream_accepted_after_drop";
|
|
32
32
|
connection_retry: "connection_retry";
|
|
33
|
+
usage_notice: "usage_notice";
|
|
34
|
+
tool_degraded: "tool_degraded";
|
|
33
35
|
}>;
|
|
34
36
|
export declare const SessionPhasePayloadSchema: z.ZodObject<{
|
|
35
37
|
phase: z.ZodEnum<{
|
|
@@ -63,6 +65,8 @@ export declare const SessionPhasePayloadSchema: z.ZodObject<{
|
|
|
63
65
|
many_image_degraded: "many_image_degraded";
|
|
64
66
|
stream_accepted_after_drop: "stream_accepted_after_drop";
|
|
65
67
|
connection_retry: "connection_retry";
|
|
68
|
+
usage_notice: "usage_notice";
|
|
69
|
+
tool_degraded: "tool_degraded";
|
|
66
70
|
}>;
|
|
67
71
|
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
68
72
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
@@ -162,7 +162,7 @@ export interface QueuedUserMessagePayload {
|
|
|
162
162
|
byteLength: number;
|
|
163
163
|
}
|
|
164
164
|
export interface PeerMessagePayload {
|
|
165
|
-
action: 'sent' | 'delivered' | 'held' | 'refused' | 'dropped';
|
|
165
|
+
action: 'sent' | 'claimed' | 'injected' | 'delivered' | 'held' | 'refused' | 'dropped' | 'reclaimed';
|
|
166
166
|
messageId?: string;
|
|
167
167
|
peer: string;
|
|
168
168
|
bytes: number;
|
|
@@ -186,18 +186,8 @@ export interface BrowserEventPayload {
|
|
|
186
186
|
};
|
|
187
187
|
durationMs: number;
|
|
188
188
|
}
|
|
189
|
-
export type SessionPhaseName
|
|
190
|
-
|
|
191
|
-
phase: SessionPhaseName;
|
|
192
|
-
durationMs?: number;
|
|
193
|
-
metadata?: Record<string, string | number | boolean>;
|
|
194
|
-
model?: string;
|
|
195
|
-
resolvedModel?: string;
|
|
196
|
-
origin?: 'cli' | 'telegram' | 'daemon' | 'web' | 'unknown';
|
|
197
|
-
actor?: 'main' | 'subagent';
|
|
198
|
-
sessionId?: string;
|
|
199
|
-
priorSessionId?: string;
|
|
200
|
-
}
|
|
189
|
+
export type { SessionPhaseName, SessionPhasePayload } from './types.session-phase.js';
|
|
190
|
+
import type { SessionPhasePayload } from './types.session-phase.js';
|
|
201
191
|
export interface SessionSealedPayload {
|
|
202
192
|
status: 'succeeded' | 'failed' | 'cancelled';
|
|
203
193
|
finalCostUsd: number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type SessionPhaseName = 'bootstrap_start' | 'bootstrap_done' | 'session_init_start' | 'session_init_done' | 'mcp_connect_start' | 'mcp_connect_done' | 'mcp_server_start' | 'mcp_server_done' | 'loop_start' | 'loop_end' | 'model_ttfb' | 'interrupt_halt' | 'rate_limit' | 'ttfb_timeout' | 'usage_limit_pause' | 'usage_limit_resume' | 'overload_pause' | 'overload_resume' | 'idle_watchdog_fired' | 'pause_extension_granted' | 'suspected_loop' | 'compaction_disabled' | 'boot_warning' | 'workspace_subscribed' | 'workspace_delivery' | 'gate_shape' | 'session_id_assigned' | 'many_image_degraded' | 'stream_accepted_after_drop' | 'connection_retry' | 'usage_notice' | 'tool_degraded';
|
|
2
|
+
export interface SessionPhasePayload {
|
|
3
|
+
phase: SessionPhaseName;
|
|
4
|
+
durationMs?: number;
|
|
5
|
+
metadata?: Record<string, string | number | boolean>;
|
|
6
|
+
model?: string;
|
|
7
|
+
resolvedModel?: string;
|
|
8
|
+
origin?: 'cli' | 'telegram' | 'daemon' | 'web' | 'unknown';
|
|
9
|
+
actor?: 'main' | 'subagent';
|
|
10
|
+
sessionId?: string;
|
|
11
|
+
priorSessionId?: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UsageResult } from '../subscription-usage.js';
|
|
2
|
+
import { type OpenAIAuthResolution } from '../providers/openai-compatible/auth.js';
|
|
3
|
+
import { type UsageHttpOptions } from './usage-http.js';
|
|
4
|
+
export declare const CODEX_SUBSCRIPTION: {
|
|
5
|
+
readonly provider: "codex";
|
|
6
|
+
readonly account: "chatgpt-subscription";
|
|
7
|
+
};
|
|
8
|
+
export interface FetchCodexUsageOptions extends UsageHttpOptions {
|
|
9
|
+
readonly auth?: () => Pick<OpenAIAuthResolution, 'apiKey' | 'source' | 'accountId'>;
|
|
10
|
+
}
|
|
11
|
+
export declare function fetchCodexUsage(options?: FetchCodexUsageOptions): Promise<UsageResult>;
|
|
12
|
+
export declare function parseCodexUsagePayload(body: Record<string, unknown>): UsageResult;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type UsageRecord, type WindowKey, type WindowsObservation } from './usage-record.js';
|
|
2
|
+
export type UsageLevel = 'ok' | 'warn' | 'over' | 'unknown';
|
|
3
|
+
export interface UsageThresholds {
|
|
4
|
+
readonly warnPct: number;
|
|
5
|
+
readonly overPct: number;
|
|
6
|
+
}
|
|
7
|
+
export declare const DEFAULT_USAGE_THRESHOLDS: UsageThresholds;
|
|
8
|
+
export interface BindingWindow {
|
|
9
|
+
readonly key: WindowKey;
|
|
10
|
+
readonly label: string;
|
|
11
|
+
readonly utilization: number;
|
|
12
|
+
readonly pct: number;
|
|
13
|
+
readonly resetsAt?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface UsageEvaluation {
|
|
16
|
+
readonly level: UsageLevel;
|
|
17
|
+
readonly stale: boolean;
|
|
18
|
+
readonly binding?: BindingWindow;
|
|
19
|
+
readonly frozenUntil?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare function levelFor(utilization: number, t?: UsageThresholds): Exclude<UsageLevel, 'unknown'>;
|
|
22
|
+
export declare function bindingWindow(w: WindowsObservation | undefined): BindingWindow | undefined;
|
|
23
|
+
export declare function isStale(observedAt: number, now: number): boolean;
|
|
24
|
+
export declare function evaluateUsage(rec: UsageRecord | undefined, now?: number, thresholds?: UsageThresholds): UsageEvaluation;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type UsageRecord } from './usage-record.js';
|
|
2
|
+
import { type BindingWindow } from './usage-budget.js';
|
|
3
|
+
export interface UsageWindowSummary {
|
|
4
|
+
readonly utilization: number;
|
|
5
|
+
readonly utilizationPct: number;
|
|
6
|
+
readonly resetsAtMs?: number;
|
|
7
|
+
readonly resetsIn?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface PerMinuteSummary {
|
|
10
|
+
readonly requestsRemaining?: number;
|
|
11
|
+
readonly requestsLimit?: number;
|
|
12
|
+
readonly tokensRemaining?: number;
|
|
13
|
+
readonly tokensLimit?: number;
|
|
14
|
+
readonly frozenUntilMs?: number;
|
|
15
|
+
readonly frozenFor?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ProviderUsageSummary {
|
|
18
|
+
readonly provider: string;
|
|
19
|
+
readonly account: string;
|
|
20
|
+
readonly status: 'ok' | 'stale' | 'unknown' | 'error';
|
|
21
|
+
readonly errorDetail?: string;
|
|
22
|
+
readonly ageMs?: number;
|
|
23
|
+
readonly perMinute?: PerMinuteSummary;
|
|
24
|
+
readonly fiveHour?: UsageWindowSummary;
|
|
25
|
+
readonly sevenDay?: UsageWindowSummary;
|
|
26
|
+
readonly sevenDaySonnet?: UsageWindowSummary;
|
|
27
|
+
readonly sevenDayOpus?: UsageWindowSummary;
|
|
28
|
+
}
|
|
29
|
+
export interface UsageSummary {
|
|
30
|
+
readonly asOfMs: number;
|
|
31
|
+
readonly providers: readonly ProviderUsageSummary[];
|
|
32
|
+
}
|
|
33
|
+
export interface CompactUsageEntry {
|
|
34
|
+
provider: string;
|
|
35
|
+
account: string;
|
|
36
|
+
status: ProviderUsageSummary['status'];
|
|
37
|
+
fiveHourPct?: number;
|
|
38
|
+
sevenDayPct?: number;
|
|
39
|
+
frozenUntilMs?: number;
|
|
40
|
+
}
|
|
41
|
+
export declare function summarizeUsageRecord(rec: UsageRecord, now?: number): ProviderUsageSummary;
|
|
42
|
+
export declare function unknownProviderSummary(provider: string, account: string): ProviderUsageSummary;
|
|
43
|
+
export declare function errorProviderSummary(provider: string, account: string, detail: string): ProviderUsageSummary;
|
|
44
|
+
export declare function compactUsageEntries(records: readonly UsageRecord[], now?: number): CompactUsageEntry[];
|
|
45
|
+
export declare function describeBindingWindow(provider: string, binding: BindingWindow, now?: number): string;
|
|
46
|
+
export interface UsageRow {
|
|
47
|
+
readonly label: string;
|
|
48
|
+
readonly value: string;
|
|
49
|
+
readonly level?: 'ok' | 'warn' | 'over' | 'info';
|
|
50
|
+
}
|
|
51
|
+
export declare function usageRows(p: ProviderUsageSummary): UsageRow[];
|
|
52
|
+
export declare function formatUsageSummaryText(summary: UsageSummary): string[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { UsageUnavailable } from '../subscription-usage.js';
|
|
2
|
+
export declare const DEFAULT_USAGE_TIMEOUT_MS = 10000;
|
|
3
|
+
export interface UsageHttpOptions {
|
|
4
|
+
readonly fetchImpl?: typeof fetch;
|
|
5
|
+
readonly timeoutMs?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface UsageJson {
|
|
8
|
+
readonly kind: 'json';
|
|
9
|
+
readonly body: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
export declare function fetchUsageJson(url: string, headers: Record<string, string>, options?: UsageHttpOptions): Promise<UsageJson | UsageUnavailable>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type PerMinuteObservation, type UsageRecord, type WindowsObservation } from './usage-record.js';
|
|
2
|
+
import type { QuotaSnapshot } from '../quota-cache.js';
|
|
3
|
+
import type { RateLimitSnapshot } from '../providers/shared/rate-limit-bucket.js';
|
|
4
|
+
import type { RateLimitGate } from '../providers/shared/tracing-fetch-utils.js';
|
|
5
|
+
import type { UsageResult } from '../subscription-usage.js';
|
|
6
|
+
export declare function resetUsageLedgerForTests(): void;
|
|
7
|
+
export declare function publishUsage(rec: UsageRecord, now?: number): void;
|
|
8
|
+
export declare function readLedgerRecords(): UsageRecord[];
|
|
9
|
+
export declare function readLedgerRecord(provider: string, account: string): UsageRecord | undefined;
|
|
10
|
+
export declare function windowsFromQuotaSnapshot(s: QuotaSnapshot): WindowsObservation;
|
|
11
|
+
export declare function windowsFromUsageResult(r: UsageResult, now: number): WindowsObservation | undefined;
|
|
12
|
+
export declare function perMinuteFromRateLimit(s: RateLimitSnapshot, now: number): PerMinuteObservation;
|
|
13
|
+
export declare function publishingGate(gate: RateLimitGate, provider: string, account: string): RateLimitGate;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface PerMinuteObservation {
|
|
2
|
+
requestsRemaining?: number;
|
|
3
|
+
requestsLimit?: number;
|
|
4
|
+
requestsResetAt?: number;
|
|
5
|
+
tokensRemaining?: number;
|
|
6
|
+
tokensLimit?: number;
|
|
7
|
+
tokensResetAt?: number;
|
|
8
|
+
frozenUntil?: number;
|
|
9
|
+
observedAt: number;
|
|
10
|
+
}
|
|
11
|
+
export interface WindowObservation {
|
|
12
|
+
utilization: number;
|
|
13
|
+
resetsAt?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface WindowsObservation {
|
|
16
|
+
fiveHour?: WindowObservation;
|
|
17
|
+
sevenDay?: WindowObservation;
|
|
18
|
+
sevenDaySonnet?: WindowObservation;
|
|
19
|
+
sevenDayOpus?: WindowObservation;
|
|
20
|
+
observedAt: number;
|
|
21
|
+
}
|
|
22
|
+
export declare const WINDOW_KEYS: readonly ["fiveHour", "sevenDay", "sevenDaySonnet", "sevenDayOpus"];
|
|
23
|
+
export type WindowKey = (typeof WINDOW_KEYS)[number];
|
|
24
|
+
export declare const WINDOW_LABELS: Readonly<Record<WindowKey, string>>;
|
|
25
|
+
export declare const USAGE_STALE_AFTER_MS: number;
|
|
26
|
+
export declare function usageKey(provider: string, account: string): string;
|
|
27
|
+
export interface UsageRecord {
|
|
28
|
+
v: 1;
|
|
29
|
+
provider: string;
|
|
30
|
+
account: string;
|
|
31
|
+
perMinute?: PerMinuteObservation;
|
|
32
|
+
windows?: WindowsObservation;
|
|
33
|
+
}
|
|
34
|
+
export declare function mergePerMinute(a: PerMinuteObservation | undefined, b: PerMinuteObservation | undefined): PerMinuteObservation | undefined;
|
|
35
|
+
export declare function mergeWindows(a: WindowsObservation | undefined, b: WindowsObservation | undefined): WindowsObservation | undefined;
|
|
36
|
+
export declare function mergeUsageRecords(existing: UsageRecord | undefined, incoming: UsageRecord): UsageRecord;
|
|
37
|
+
export declare function parseUsageRecord(raw: unknown): UsageRecord | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type FetchSubscriptionUsageOptions, type UsageResult } from '../subscription-usage.js';
|
|
2
|
+
import { type UsageRecord } from './usage-record.js';
|
|
3
|
+
export declare const ANTHROPIC_OAUTH: {
|
|
4
|
+
readonly provider: "anthropic";
|
|
5
|
+
readonly account: "oauth";
|
|
6
|
+
};
|
|
7
|
+
export declare function readUsageRecords(extra?: readonly UsageRecord[]): UsageRecord[];
|
|
8
|
+
export declare function readUsageRecord(provider: string, account: string): UsageRecord | undefined;
|
|
9
|
+
export interface CollectUsageOptions {
|
|
10
|
+
readonly fetchUsage?: (opts?: FetchSubscriptionUsageOptions) => Promise<UsageResult>;
|
|
11
|
+
readonly includeClaude?: boolean;
|
|
12
|
+
readonly includeCodex?: boolean;
|
|
13
|
+
readonly fetchCodex?: () => Promise<UsageResult>;
|
|
14
|
+
readonly now?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface CollectedUsage {
|
|
17
|
+
readonly records: UsageRecord[];
|
|
18
|
+
readonly anthropic?: UsageResult;
|
|
19
|
+
readonly codex?: UsageResult;
|
|
20
|
+
}
|
|
21
|
+
export declare function collectUsage(opts?: CollectUsageOptions): Promise<CollectedUsage>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ScheduledTask } from '../../agent/daemon/triggers.js';
|
|
2
|
+
import type { CliConfig } from '../config/types.js';
|
|
3
|
+
export declare function buildWorktreePruneTask(cron: string): ScheduledTask;
|
|
4
|
+
export declare function buildToolHealthTask(cron: string): ScheduledTask;
|
|
5
|
+
export declare function appendBuiltinTasks(tasks: ScheduledTask[], config: {
|
|
6
|
+
daemon?: CliConfig['daemon'];
|
|
7
|
+
}, env: {
|
|
8
|
+
AFK_WORKTREE_PRUNE_DISABLE?: string;
|
|
9
|
+
AFK_TOOL_HEALTH_DISABLE?: string;
|
|
10
|
+
}): {
|
|
11
|
+
worktreePruneCron: string;
|
|
12
|
+
toolHealthCron: string;
|
|
13
|
+
worktreePruneEnabled: boolean;
|
|
14
|
+
toolHealthEnabled: boolean;
|
|
15
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type StoredSession } from '../../session-store.js';
|
|
1
2
|
import type { InteractiveCtx } from './shared.js';
|
|
2
3
|
import type { TurnState } from './repl-loop.js';
|
|
3
4
|
import type { WorktreeHandle } from './worktree.js';
|
|
@@ -5,6 +6,7 @@ export interface SignalHandlerDeps {
|
|
|
5
6
|
ctx: InteractiveCtx;
|
|
6
7
|
turnState: TurnState;
|
|
7
8
|
pickerAbort: AbortController;
|
|
9
|
+
exitReasonRef: ExitReasonRef;
|
|
8
10
|
}
|
|
9
11
|
export interface SignalHandlerDisposers {
|
|
10
12
|
removeListeners: () => void;
|
|
@@ -15,7 +17,10 @@ export declare function installSignalHandlers(deps: SignalHandlerDeps): {
|
|
|
15
17
|
};
|
|
16
18
|
export declare function printExitSummary(ctx: InteractiveCtx, worktreeHandle: WorktreeHandle | undefined, saveCurrentSession: () => string | undefined): void;
|
|
17
19
|
export declare function snapshotGitStateForCancelAll(cwd: string): Promise<void>;
|
|
18
|
-
export
|
|
20
|
+
export type ExitReasonRef = {
|
|
21
|
+
current: StoredSession['exitReason'];
|
|
22
|
+
};
|
|
23
|
+
export declare function makeSessionSaver(ctx: InteractiveCtx, exitReasonRef?: ExitReasonRef): {
|
|
19
24
|
saveCurrentSession: () => string | undefined;
|
|
20
25
|
isSaved: () => boolean;
|
|
21
26
|
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { PeerInboxNotifier } from './peer-inbox-notifier.js';
|
|
2
|
+
import { AdmissionQueue } from '../../../agent/peer/admission-queue.js';
|
|
3
|
+
import type { InteractiveCtx } from './shared.js';
|
|
4
|
+
import type { InputSurface } from '../../input/input-surface.js';
|
|
5
|
+
export interface BoundaryCompositor {
|
|
6
|
+
hasPendingSubmission(): boolean;
|
|
7
|
+
peekQueuedText(): {
|
|
8
|
+
text: string;
|
|
9
|
+
payloads: readonly unknown[];
|
|
10
|
+
} | undefined;
|
|
11
|
+
reserveQueued(snapshot: {
|
|
12
|
+
payloads: readonly unknown[];
|
|
13
|
+
}): void;
|
|
14
|
+
releaseQueued(snapshot: {
|
|
15
|
+
payloads: readonly unknown[];
|
|
16
|
+
}): void;
|
|
17
|
+
dropQueued(snapshot: {
|
|
18
|
+
payloads: readonly unknown[];
|
|
19
|
+
}): number;
|
|
20
|
+
}
|
|
21
|
+
export interface BoundarySession {
|
|
22
|
+
setBeforeNextRound?: (cb: (() => string | undefined) | undefined) => void;
|
|
23
|
+
}
|
|
24
|
+
export interface PeerBoundaryOpts {
|
|
25
|
+
getSession: () => BoundarySession | undefined;
|
|
26
|
+
getCompositor: () => BoundaryCompositor | null;
|
|
27
|
+
peerNotifier: PeerInboxNotifier;
|
|
28
|
+
admissionQueue: AdmissionQueue;
|
|
29
|
+
}
|
|
30
|
+
export declare function installPeerBoundary(opts: PeerBoundaryOpts): () => void;
|
|
31
|
+
export declare function reinstallPeerBoundary(opts: PeerBoundaryOpts, prevDispose: (() => void) | undefined): () => void;
|
|
32
|
+
export declare function drainAdmissionQueueFallback(text: string, q: AdmissionQueue): string;
|
|
33
|
+
export declare function setupPeerBoundary(ctx: InteractiveCtx, surface: InputSurface, peerNotifier: PeerInboxNotifier): {
|
|
34
|
+
admissionQueue: AdmissionQueue;
|
|
35
|
+
reinstall: () => void;
|
|
36
|
+
};
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { type PeerInboundMode } from '../../../agent/peer/inbound-mode.js';
|
|
2
|
+
import { type PeerEnvelope } from '../../../agent/peer/envelope.js';
|
|
2
3
|
import type { TraceSink } from '../../../agent/trace/index.js';
|
|
3
4
|
import type { InteractiveCtx } from './shared.js';
|
|
4
5
|
export interface PeerInboxNotifierOpts {
|
|
5
6
|
getSessionId: () => string | undefined;
|
|
6
7
|
writeLine: (text: string) => void;
|
|
7
8
|
mode?: () => PeerInboundMode;
|
|
8
|
-
traceWriter?: TraceSink;
|
|
9
9
|
getTraceWriter?: () => TraceSink | undefined;
|
|
10
|
+
traceWriter?: TraceSink;
|
|
10
11
|
now?: () => number;
|
|
11
12
|
pollMs?: number;
|
|
12
13
|
}
|
|
14
|
+
interface BufferedClaim {
|
|
15
|
+
envelope: PeerEnvelope;
|
|
16
|
+
sessionId: string;
|
|
17
|
+
}
|
|
13
18
|
export declare class PeerInboxNotifier {
|
|
14
19
|
private readonly opts;
|
|
15
20
|
onInjectable: (() => void) | null;
|
|
@@ -17,6 +22,7 @@ export declare class PeerInboxNotifier {
|
|
|
17
22
|
private wakeBudget;
|
|
18
23
|
private readonly pollMs;
|
|
19
24
|
private readonly getMode;
|
|
25
|
+
private readonly resolveTraceWriter;
|
|
20
26
|
private scanning;
|
|
21
27
|
private rescan;
|
|
22
28
|
private watchedId;
|
|
@@ -29,7 +35,10 @@ export declare class PeerInboxNotifier {
|
|
|
29
35
|
constructor(opts: PeerInboxNotifierOpts);
|
|
30
36
|
resetForNewSession(): void;
|
|
31
37
|
hasPendingInjections(): boolean;
|
|
38
|
+
peekEnvelopes(): readonly BufferedClaim[];
|
|
39
|
+
consumeEnvelopes(count: number): string;
|
|
32
40
|
drainInjections(): string;
|
|
41
|
+
reclaim(): Promise<number>;
|
|
33
42
|
start(): void;
|
|
34
43
|
dispose(): void;
|
|
35
44
|
forceAccept(messageIds: ReadonlySet<string> | 'all'): Promise<number>;
|
|
@@ -47,3 +56,4 @@ export declare class PeerInboxNotifier {
|
|
|
47
56
|
}
|
|
48
57
|
export declare function createPeerInboxNotifier(opts: PeerInboxNotifierOpts): PeerInboxNotifier;
|
|
49
58
|
export declare function createReplPeerNotifier(ctx: InteractiveCtx): PeerInboxNotifier;
|
|
59
|
+
export {};
|
|
@@ -77,17 +77,20 @@ export interface InteractiveCtx {
|
|
|
77
77
|
worktreeDisposition?: import('./worktree-disposition.js').WorktreeDisposition;
|
|
78
78
|
resolveWorktreeDisposition?: (canPrompt: boolean) => Promise<void>;
|
|
79
79
|
getInFlight?: () => boolean;
|
|
80
|
+
exitReasonRef?: {
|
|
81
|
+
current: StoredSession['exitReason'];
|
|
82
|
+
};
|
|
80
83
|
requestResume?: (target: ResolvedResumeTarget) => Promise<ResumeSwapResult>;
|
|
81
84
|
clearVerdictLedger?: () => void;
|
|
82
85
|
clearBgResultBuffer?: () => void;
|
|
83
86
|
resetPeerNotifier?: () => void;
|
|
84
87
|
traceWriter?: TraceSink;
|
|
85
88
|
clearPendingStopInjection?: () => void;
|
|
89
|
+
reinstallPeerBoundary?: () => void;
|
|
86
90
|
preArmAnchorRow?: number;
|
|
87
91
|
inputSurfaceRef?: {
|
|
88
92
|
current: import('../../input/input-surface.js').InputSurface | null;
|
|
89
93
|
};
|
|
90
|
-
suggestApiKey?: string;
|
|
91
94
|
suggestBaseUrl?: string;
|
|
92
95
|
suggestGhostConfig?: boolean;
|
|
93
96
|
viewingTaskId?: string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
import { type UsageSummary } from '../../agent/usage/usage-formatter.js';
|
|
3
|
+
import { type OpenAIAuthResolution } from '../../agent/providers/openai-compatible/auth.js';
|
|
4
|
+
export interface UsageCredentialProbes {
|
|
5
|
+
readonly chatgpt: () => Pick<OpenAIAuthResolution, 'source'>;
|
|
6
|
+
readonly openaiApiKey: () => string | undefined;
|
|
7
|
+
}
|
|
8
|
+
export declare function collectUsageSummary(now?: number, probes?: UsageCredentialProbes): Promise<UsageSummary>;
|
|
9
|
+
export declare function registerUsageCommand(program: Command): void;
|
|
@@ -31,6 +31,10 @@ export interface CliConfig {
|
|
|
31
31
|
maxAgeDaysDirty: number;
|
|
32
32
|
scope: string;
|
|
33
33
|
};
|
|
34
|
+
toolHealth?: {
|
|
35
|
+
enabled: boolean;
|
|
36
|
+
cron: string;
|
|
37
|
+
};
|
|
34
38
|
verifyDone?: boolean;
|
|
35
39
|
};
|
|
36
40
|
telegram?: {
|
|
@@ -98,6 +102,10 @@ export interface ConfigFileSchema {
|
|
|
98
102
|
maxAgeDaysDirty?: number;
|
|
99
103
|
scope?: string;
|
|
100
104
|
};
|
|
105
|
+
toolHealth?: {
|
|
106
|
+
enabled?: boolean;
|
|
107
|
+
cron?: string;
|
|
108
|
+
};
|
|
101
109
|
verifyDone?: boolean;
|
|
102
110
|
};
|
|
103
111
|
telegram?: {
|
package/dist/cli/constants.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export declare const SPINNER_VERBS: string[];
|
|
2
2
|
export declare const GOBLIN_SPINNER_VERBS: string[];
|
|
3
|
-
export declare const COMPLETION_VERBS: Record<string, string>;
|
|
4
3
|
export declare function pickRandomVerb(): string;
|
|
5
4
|
export declare function pickRandomGoblinVerb(): string;
|
|
6
|
-
export declare function getCompletionVerb(verb: string): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ProviderRouteHints } from '../../agent/providers/index.js';
|
|
2
|
+
export interface SuggestCredential {
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
forceChatgptOAuth?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export type ResolveCredentialFn = (model: string | undefined, hints: ProviderRouteHints | undefined) => string | undefined;
|
|
7
|
+
export interface SuggestCredentialResolver {
|
|
8
|
+
resolve(model: string, hints: ProviderRouteHints | undefined): SuggestCredential | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare function createSuggestCredentialResolver(resolveFn?: ResolveCredentialFn): SuggestCredentialResolver;
|
|
@@ -2,7 +2,6 @@ import type { ModelProvider } from '../../agent/provider.js';
|
|
|
2
2
|
import type { ProviderRouteHints } from '../../agent/providers/index.js';
|
|
3
3
|
export interface SuggestContext {
|
|
4
4
|
model: string;
|
|
5
|
-
apiKey?: string;
|
|
6
5
|
baseUrl?: string;
|
|
7
6
|
cwd: string;
|
|
8
7
|
getHistory(): string[];
|
|
@@ -22,12 +21,14 @@ export interface CompleteRequest {
|
|
|
22
21
|
maxTokens: number;
|
|
23
22
|
signal: AbortSignal;
|
|
24
23
|
apiKey?: string;
|
|
24
|
+
forceChatgptOAuth?: boolean;
|
|
25
25
|
baseUrl?: string;
|
|
26
26
|
}
|
|
27
27
|
export type CompleteFn = (req: CompleteRequest) => Promise<string>;
|
|
28
28
|
export interface SuggestEngineOptions {
|
|
29
29
|
completeFn?: CompleteFn;
|
|
30
30
|
resolveProviderFn?: (model: string | undefined, hints: ProviderRouteHints | undefined) => ModelProvider;
|
|
31
|
+
resolveCredentialFn?: (model: string | undefined, hints: ProviderRouteHints | undefined) => string | undefined;
|
|
31
32
|
debounceMs?: number;
|
|
32
33
|
timeoutMs?: number;
|
|
33
34
|
onError?: (err: unknown) => void;
|
|
@@ -10,6 +10,8 @@ export interface StoredSession {
|
|
|
10
10
|
model: AgentModelInput;
|
|
11
11
|
startedAt: number;
|
|
12
12
|
savedAt: number;
|
|
13
|
+
endedAt?: number;
|
|
14
|
+
exitReason?: 'sigint' | 'sigterm' | 'sighup' | 'exit-command' | 'eof';
|
|
13
15
|
totalTurns: number;
|
|
14
16
|
totalCostUsd: number;
|
|
15
17
|
unpricedTurns?: number;
|
|
@@ -43,7 +45,10 @@ export interface FoundSession {
|
|
|
43
45
|
id: string;
|
|
44
46
|
data: StoredSession;
|
|
45
47
|
}
|
|
46
|
-
export declare function saveSession(stats: SessionStats, overrideId?: string
|
|
48
|
+
export declare function saveSession(stats: SessionStats, overrideId?: string, opts?: {
|
|
49
|
+
closeTime?: boolean;
|
|
50
|
+
exitReason?: StoredSession['exitReason'];
|
|
51
|
+
}): string;
|
|
47
52
|
export declare function forkStoredSession(stats: SessionStats, opts?: {
|
|
48
53
|
newId?: string;
|
|
49
54
|
}): {
|
|
@@ -2,6 +2,7 @@ import { type ChalkInstance } from 'chalk';
|
|
|
2
2
|
import { categorizeTool, dispatchTagForCategory, SUBAGENT_TOOLS, SKILL_TOOLS, DAG_TOOLS, NESTING_TOOLS, type ToolCategory } from '../agent/tool-category.js';
|
|
3
3
|
export { categorizeTool, dispatchTagForCategory, SUBAGENT_TOOLS, SKILL_TOOLS, DAG_TOOLS, NESTING_TOOLS, type ToolCategory, };
|
|
4
4
|
export declare const CATEGORY_HUMAN_VERB: Record<ToolCategory, string>;
|
|
5
|
+
export declare const TOOL_VERB_OVERRIDES: Partial<Record<string, string>>;
|
|
5
6
|
export declare function humanVerbForTool(toolName: string): string;
|
|
6
7
|
export interface CategoryStyle {
|
|
7
8
|
color: ChalkInstance;
|