@ycodium-ai/plugin-api 0.2.2169 → 0.2.2488

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,158 +0,0 @@
1
- /**
2
- * `@ycodium-ai/plugin-api/source-metrics` —— 来源动态额度的**窄事实类型**。
3
- *
4
- * 本文件只含 `type` / `interface`,没有运行时值。字段是宿主 `SourceMetric` /
5
- * `SourceMetricsSnapshot` / `SourceMetricsCapability` 的结构子集:宿主模型必须
6
- * 可赋值到这里,反向不保证。不含格式化规则、缓存、轮询或查询策略。插件不得
7
- * import contracts / runtime;UI 组件用 `import type`。宿主按本文件构造
8
- * `ConversationComposerProps.sourceMetrics`。
9
- *
10
- * @module @ycodium-ai/plugin-api/source-metrics
11
- */
12
- export type SourceMetricsRefreshOutcome = "fresh" | "partial" | "joined-inflight" | "rate-limited" | "offline" | "unsupported" | "error";
13
- export type SourceMetricKind = "balance" | "credits" | "quota-window" | "spend-cap" | "rate-limit";
14
- export type SourceMetricsCapabilityStatus = "supported" | "unsupported" | "unknown";
15
- export type QuotaPoolScopeKind = "account" | "org" | "project" | "key" | "endpoint" | "model-group" | "model" | "unknown";
16
- export type SourceMetricProvenance = "reported" | "derived" | "estimated";
17
- export type SourceMetricStatus = "available" | "pending" | "unmeterable" | "expired" | "error";
18
- export type SourceMetricFreshness = "fresh" | "stale" | "unknown";
19
- /** 凭据身份:稳定 id + 单调 revision,不能用邮箱或路径代替。 */
20
- export interface SourceMetricsCredentialIdentity {
21
- readonly id: string;
22
- readonly revision: number;
23
- }
24
- export interface QuotaPoolScope {
25
- readonly kind: QuotaPoolScopeKind;
26
- readonly identity: string | null;
27
- readonly quotaPoolId: string | null;
28
- readonly credentialIdentity: SourceMetricsCredentialIdentity;
29
- }
30
- export type SourceMetricUnit = {
31
- readonly kind: "money";
32
- readonly currency: string;
33
- readonly precision: number;
34
- } | {
35
- readonly kind: "credits" | "requests" | "tokens";
36
- readonly nativeUnit: string;
37
- } | {
38
- readonly kind: "percent";
39
- readonly direction: "used" | "remaining";
40
- };
41
- export interface SourceMetricsCapability {
42
- readonly status: SourceMetricsCapabilityStatus;
43
- readonly readerId: string | null;
44
- readonly metrics: ReadonlyArray<{
45
- readonly kind: SourceMetricKind;
46
- readonly scopes: ReadonlyArray<QuotaPoolScopeKind>;
47
- }>;
48
- readonly nativeEvents: boolean;
49
- readonly ttlMs: number;
50
- readonly cooldownMs: number;
51
- }
52
- export interface SourceMetricWindow {
53
- readonly durationMs: number | null;
54
- readonly nativePeriod: string | null;
55
- }
56
- export interface SourceMetric {
57
- readonly metricId: string;
58
- readonly kind: SourceMetricKind;
59
- readonly scope: QuotaPoolScope;
60
- readonly endpointIds: ReadonlyArray<string>;
61
- readonly modelIds: ReadonlyArray<string>;
62
- readonly nativeLabel: string | null;
63
- readonly used: number | null;
64
- readonly remaining: number | null;
65
- readonly limit: number | null;
66
- readonly unit: SourceMetricUnit;
67
- readonly unlimited: boolean | null;
68
- readonly window: SourceMetricWindow | null;
69
- readonly resetsAt: string | null;
70
- readonly provenance: SourceMetricProvenance;
71
- readonly status: SourceMetricStatus;
72
- readonly freshness: SourceMetricFreshness;
73
- readonly providerObservedAt: string | null;
74
- readonly fetchedAt: string | null;
75
- readonly lastAttemptAt: string | null;
76
- readonly expiresAt: string | null;
77
- readonly retryAt: string | null;
78
- readonly errorReason: string | null;
79
- }
80
- export interface SourceMetricsSnapshot {
81
- readonly environmentId: string;
82
- readonly sourceId: string;
83
- readonly sourceConfigRevision: number;
84
- readonly credentialIdentity: SourceMetricsCredentialIdentity;
85
- readonly endpointIds: ReadonlyArray<string>;
86
- readonly modelIds: ReadonlyArray<string>;
87
- readonly quotaPoolIds: ReadonlyArray<string>;
88
- readonly snapshotRevision: number;
89
- readonly refreshing: boolean;
90
- readonly metrics: ReadonlyArray<SourceMetric>;
91
- }
92
- /** 手动刷新完成结果。进行中的合并由宿主返回 `joined-inflight`,插件不假装成功。 */
93
- export interface SourceMetricsRefreshResult {
94
- readonly outcome: SourceMetricsRefreshOutcome;
95
- readonly retryAt: string | null;
96
- }
97
- /**
98
- * 宿主 `ExecutionSelection` 的结构子集:迟到刷新按这份选择归属,不能只看 sourceId。
99
- */
100
- export interface SourceMetricsSelectionRef {
101
- readonly environmentId: string;
102
- readonly runtimeId: string;
103
- readonly sourceId: string;
104
- readonly profileId: string;
105
- readonly endpointId?: string | undefined;
106
- readonly expectedRevisions: {
107
- readonly runtime: number;
108
- readonly source: number;
109
- readonly profile: number;
110
- readonly endpoint?: number | undefined;
111
- };
112
- }
113
- /**
114
- * composer 额度区的宿主注入面。数据全部来自这份 props:插件不另建缓存、
115
- * 不轮询、不调 Usage 插件、不读默认机器账户。`onRefresh` 必须是宿主接上的
116
- * 真实查询;缺席整份 props,不要塞空回调。
117
- *
118
- * 顶层 `credentialIdentity` 在尚未取得凭据或不支持读取时为 null,界面不得
119
- * 发明身份 id。真 snapshot / metric 仍携带真实 identity。
120
- * `queryKey` 由宿主按完整选定范围与当前 source/endpoint revisions 生成,
121
- * 插件只当不透明刷新代次键,不展示、不解析。
122
- */
123
- export interface ConversationComposerSourceMetrics {
124
- readonly environmentId: string;
125
- /**
126
- * 观察范围。按**来源**读时是来源 id 与其配置 revision;按**实例**读(手自己的账号,
127
- * 不需要来源存在)时是合成的 `instance:<instanceId>` 与 revision 0——插件只当不透明
128
- * 的代次键,不解析、不展示。
129
- */
130
- readonly sourceId: string;
131
- readonly sourceConfigRevision: number;
132
- /** 按来源读时带着这次选择;按实例读时缺席(不属于任何来源)。 */
133
- readonly selection?: SourceMetricsSelectionRef | undefined;
134
- readonly queryKey: string;
135
- readonly credentialIdentity: SourceMetricsCredentialIdentity | null;
136
- readonly sourceLabel: string;
137
- readonly capability: SourceMetricsCapability;
138
- readonly snapshot: SourceMetricsSnapshot | null;
139
- readonly loading: boolean;
140
- readonly error: string | null;
141
- readonly isNextMessage: boolean;
142
- readonly onRefresh: () => Promise<SourceMetricsRefreshResult>;
143
- }
144
- /**
145
- * 按**实例**读到的自管登录额度(`ctx.providers.readInstanceMetrics`)。
146
- *
147
- * 与 composer 那份是同一份宿主快照:同一条探针、同一个缓存,插件不自己出网、不自己
148
- * 读凭据。`supported` 为 false 表示宿主认不得这只手的自管登录(或它被停用、已删除),
149
- * 此时不该为它出额度行;`reasonCode` 是宿主给的原因码,原样用于区分「没登录」与
150
- * 「读不到」。`metrics` 的 `nativeLabel` 是**标识**不是文案,界面自己查 catalog。
151
- */
152
- export interface PluginInstanceMetrics {
153
- readonly instanceId: string;
154
- readonly supported: boolean;
155
- readonly reasonCode: string | null;
156
- readonly metrics: ReadonlyArray<SourceMetric>;
157
- }
158
- //# sourceMappingURL=source-metrics.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"source-metrics.d.ts","sourceRoot":"","sources":["../src/source-metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,MAAM,2BAA2B,GACnC,OAAO,GACP,SAAS,GACT,iBAAiB,GACjB,cAAc,GACd,SAAS,GACT,aAAa,GACb,OAAO,CAAC;AAEZ,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,SAAS,GAAG,cAAc,GAAG,WAAW,GAAG,YAAY,CAAC;AAEnG,MAAM,MAAM,6BAA6B,GAAG,WAAW,GAAG,aAAa,GAAG,SAAS,CAAC;AAEpF,MAAM,MAAM,kBAAkB,GAC1B,SAAS,GACT,KAAK,GACL,SAAS,GACT,KAAK,GACL,UAAU,GACV,aAAa,GACb,OAAO,GACP,SAAS,CAAC;AAEd,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG,SAAS,GAAG,WAAW,CAAC;AAE1E,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,SAAS,GAAG,aAAa,GAAG,SAAS,GAAG,OAAO,CAAC;AAE/F,MAAM,MAAM,qBAAqB,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;AAElE,2CAA2C;AAC3C,MAAM,WAAW,+BAA+B;IAC9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AQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KACxC,CAAC;CACH;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,iCAAiC;IAChD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,oCAAoC;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;IAC3D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,kBAAkB,EAAE,+BAA+B,GAAG,IAAI,CAAC;IACpE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,uBAAuB,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAChD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,OAAO,CAAC,0BAA0B,CAAC,CAAC;CAC/D;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;CAC/C"}
@@ -1,13 +0,0 @@
1
- /**
2
- * `@ycodium-ai/plugin-api/source-metrics` —— 来源动态额度的**窄事实类型**。
3
- *
4
- * 本文件只含 `type` / `interface`,没有运行时值。字段是宿主 `SourceMetric` /
5
- * `SourceMetricsSnapshot` / `SourceMetricsCapability` 的结构子集:宿主模型必须
6
- * 可赋值到这里,反向不保证。不含格式化规则、缓存、轮询或查询策略。插件不得
7
- * import contracts / runtime;UI 组件用 `import type`。宿主按本文件构造
8
- * `ConversationComposerProps.sourceMetrics`。
9
- *
10
- * @module @ycodium-ai/plugin-api/source-metrics
11
- */
12
- export {};
13
- //# sourceMappingURL=source-metrics.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"source-metrics.js","sourceRoot":"","sources":["../src/source-metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}