@yitom/acp-client 0.1.3 → 0.1.5

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.
@@ -1,4 +1,5 @@
1
1
  import { type AcpAvailableCommand } from '../session/available-commands';
2
+ import type { AcpAgentQuota } from '../contracts';
2
3
  import { type InitializeResponse } from '@agentclientprotocol/sdk';
3
4
  import type { AcpConnectionStatus, AcpPermissionOutcome, AcpProxySettings, AcpRuntimeInfo, AcpSessionRestoreMethod, AppError, InkdownVirtualResource } from "../contracts";
4
5
  import { type Result } from "../contracts";
@@ -58,6 +59,10 @@ export declare class AcpSessionHandle {
58
59
  }>;
59
60
  }): Promise<Result<unknown, AppError>>;
60
61
  /** Agent 通过 available_commands_update 提供的斜杠命令(调用 = prompt 发送 `/name args` 文本) */
62
+ /** 当前会话最近获取或解析到的配额(5h / 周额度 / 余额) */
63
+ get quota(): AcpAgentQuota | undefined;
64
+ /** 主动获取/刷新配额(优先缓存,过期或无缓存时触发适配器探针) */
65
+ getQuota(): Promise<AcpAgentQuota | null>;
61
66
  get availableCommands(): AcpAvailableCommand[] | undefined;
62
67
  /** 修改会话配置项(如模型 ID、模式等) */
63
68
  setConfigOption(configId: string, value: string | boolean): Promise<Result<unknown, AppError>>;
@@ -72,6 +77,7 @@ export declare class AcpSessionHandle {
72
77
  export declare class AcpClient {
73
78
  private status;
74
79
  private readonly commandsCache;
80
+ private readonly quotaCache;
75
81
  private runtimeInfo;
76
82
  private adapter;
77
83
  private readonly workspaceRoot;
@@ -104,6 +110,8 @@ export declare class AcpClient {
104
110
  init: InitializeResponse;
105
111
  }, AppError>>;
106
112
  /** 最近一次 available_commands_update 的命令列表(未收到过则为 undefined) */
113
+ getCachedQuota(sessionId?: string): AcpAgentQuota | undefined;
114
+ getQuota(sessionId?: string): Promise<AcpAgentQuota | null>;
107
115
  getAvailableCommands(sessionId: string): AcpAvailableCommand[] | undefined;
108
116
  /** 等待某会话的命令列表(已缓存则立即返回;超时返回 undefined) */
109
117
  waitForAvailableCommands(sessionId: string, timeoutMs?: number): Promise<AcpAvailableCommand[] | undefined>;
@@ -271,7 +271,9 @@ export declare const CODEX_ACP_NPM_PACKAGE: '@agentclientprotocol/codex-acp';
271
271
  export declare const CLAUDE_ACP_NPM_PACKAGE: '@agentclientprotocol/claude-agent-acp';
272
272
  export declare const DEEPSEEK_DSH_NPM_PACKAGE: '@deepseek-ai/dsh';
273
273
  export declare const AGY_ACP_NPM_PACKAGE: '@yitom/agy-acp-map';
274
+ export declare const OPENCODE_CLI_NPM_PACKAGE: '@opencode/cli';
274
275
  export declare const LEGACY_ZED_CODEX_ACP_NPM_PACKAGE: '@zed-industries/codex-acp';
275
276
  export declare const DEFAULT_ACP_RUNTIME_ID = "codex-acp";
276
277
  export declare const BUILTIN_ACP_RUNTIMES: readonly AcpRuntimeInfo[];
277
278
  export declare function findBuiltinAcpRuntime(id: string): AcpRuntimeInfo | undefined;
279
+ export * from './quota';
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Agent 额度与速率限制契约 (Agent Quota & Rate Limits Contract)
3
+ *
4
+ * 跨 Agent 通用抽象:
5
+ * - primaryWindow: 核心短期限制(如 Codex / Claude / OpenCode 5小时限额)
6
+ * - secondaryWindow: 周期限制(如 每周限额 / 每月限额)
7
+ * - credits: 账户余额 / 积分
8
+ * - extraWindows: 额外限制(如 单个请求上限 / 日调用上限 / 模型专属上限)
9
+ */
10
+ export interface AcpQuotaLimitWindow {
11
+ /** 限制窗口标识或名称,如 '5h limit', 'Weekly limit', 'Monthly limit' */
12
+ label: string;
13
+ /** 剩余百分比 (0 - 100) */
14
+ percentLeft: number;
15
+ /** 已用百分比 (0 - 100) */
16
+ usedPercent?: number;
17
+ /** 已用绝对量 (例如已用 token、金额或请求次数) */
18
+ used?: number | string;
19
+ /** 总额度 (例如总 token、限值) */
20
+ total?: number | string;
21
+ /** 窗口时长(分钟),例如 5h = 300, 7d = 10080 */
22
+ windowDurationMins?: number;
23
+ /** 重置时间提示,如 '18:05', '10月20日 13:05' 或 ISO 时间串 */
24
+ resetsAt?: string | number;
25
+ }
26
+ export interface AcpQuotaCredits {
27
+ /** 余额数值或字符串,例如 126.19 或 'unlimited' */
28
+ balance?: number | string;
29
+ /** 货币单位,如 USD, CNY, CREDITS */
30
+ currency?: string;
31
+ /** 是否无限制 */
32
+ unlimited?: boolean;
33
+ }
34
+ export interface AcpAccountInfo {
35
+ name?: string;
36
+ email?: string;
37
+ plan?: string;
38
+ type?: string;
39
+ }
40
+ export type AcpQuotaStatus = 'ok' | 'warning' | 'exhausted' | 'banned' | 'unauthorized' | 'unknown';
41
+ export interface AcpAgentQuota {
42
+ runtimeId: string;
43
+ provider?: string;
44
+ account?: AcpAccountInfo;
45
+ /** 核心短期窗口,如 5 小时限额 */
46
+ primaryWindow?: AcpQuotaLimitWindow;
47
+ /** 周期窗口,如 每周限额 / 每月限额 */
48
+ secondaryWindow?: AcpQuotaLimitWindow;
49
+ /** 账户积分 / 余额 */
50
+ credits?: AcpQuotaCredits;
51
+ /** 其他窗口(如模型专属调用上限) */
52
+ extraWindows?: AcpQuotaLimitWindow[];
53
+ /** 账户/额度整体状态 */
54
+ status?: AcpQuotaStatus;
55
+ /** 人类可读说明或异常警告(例如 'Account banned', '429 Too Many Requests') */
56
+ message?: string;
57
+ /** 原始文本(若由 /status 或 CLI 文本解析而来) */
58
+ rawText?: string;
59
+ /** 更新时间戳 (ms) */
60
+ updatedAt: number;
61
+ }