@peer-agent/protocol 0.0.1-beta.45 → 0.0.1-beta.47
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/appshot.d.ts +74 -0
- package/dist/appshot.js +13 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/usage-accounting.d.ts +21 -0
- package/package.json +1 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Appshot(前台应用窗口快照)协议类型。
|
|
3
|
+
*
|
|
4
|
+
* 依据:peer-knowledge ADR 59(Appshots 能力边界与 Evidence 链)、
|
|
5
|
+
* design/product/appshots-window-context-capture.md §5.4 产品语义模型、
|
|
6
|
+
* design/product/appshots-engineering-task-breakdown.md §3.1 spike 实测定案。
|
|
7
|
+
*
|
|
8
|
+
* 约束(ADR 59 决策 3):
|
|
9
|
+
* - `visual.artifactRef` 引用本地落盘 PNG;整图禁止以 dataUrl 内联进会话存储。
|
|
10
|
+
* - `visual.thumbnailDataUrl` 仅允许小缩略图(用于卡片即时渲染)。
|
|
11
|
+
* - 失败必须结构化为 AppshotFailureCode 四类;permission_denied 由 preflight 判定。
|
|
12
|
+
*/
|
|
13
|
+
/** 结构化失败码(ADR 59 决策 3)。 */
|
|
14
|
+
export type AppshotFailureCode = 'permission_denied' | 'peer_frontmost' | 'no_window' | 'window_not_capturable';
|
|
15
|
+
/** 捕获来源窗口的元数据(P0a:来自 CGWindowList / osascript)。 */
|
|
16
|
+
export interface AppshotSource {
|
|
17
|
+
appName: string;
|
|
18
|
+
bundleId?: string;
|
|
19
|
+
pid?: number;
|
|
20
|
+
windowId?: number;
|
|
21
|
+
/** 默认不进日志(ADR 59 决策 4),仅进 payload。 */
|
|
22
|
+
windowTitle?: string;
|
|
23
|
+
bounds?: {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
};
|
|
29
|
+
scaleFactor?: number;
|
|
30
|
+
displayId?: string | number;
|
|
31
|
+
}
|
|
32
|
+
/** 视觉通道:本地 artifact 引用 + 可选内联缩略图。 */
|
|
33
|
+
export interface AppshotVisual {
|
|
34
|
+
/** `local-appshot-artifact://<id>` 形式的本地产物引用。 */
|
|
35
|
+
artifactRef: string;
|
|
36
|
+
/** 落盘文件绝对路径(主进程内部使用;不随消息跨端同步语义)。 */
|
|
37
|
+
filePath?: string;
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
mimeType: 'image/png' | 'image/jpeg';
|
|
41
|
+
byteSize: number;
|
|
42
|
+
/** 仅允许小缩略图内联(≤64KB 级),供卡片即时渲染。 */
|
|
43
|
+
thumbnailDataUrl?: string;
|
|
44
|
+
}
|
|
45
|
+
/** 文本通道占位(P0a 固定 mode:'none';P0b 起启用其余模式)。 */
|
|
46
|
+
export interface AppshotText {
|
|
47
|
+
mode: 'none' | 'visible_or_accessible' | 'includes_offscreen';
|
|
48
|
+
contentRef?: string;
|
|
49
|
+
preview?: string;
|
|
50
|
+
truncated?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** 一次成功捕获的完整 payload。 */
|
|
53
|
+
export interface AppshotPayload {
|
|
54
|
+
appshotId: string;
|
|
55
|
+
capturedAt: string;
|
|
56
|
+
source: AppshotSource;
|
|
57
|
+
visual: AppshotVisual;
|
|
58
|
+
text: AppshotText;
|
|
59
|
+
/** 捕获耗时(毫秒),用于性能验收(产品文档 §12.4)。 */
|
|
60
|
+
captureDurationMs?: number;
|
|
61
|
+
}
|
|
62
|
+
/** 结构化失败结果。 */
|
|
63
|
+
export interface AppshotFailure {
|
|
64
|
+
ok: false;
|
|
65
|
+
code: AppshotFailureCode;
|
|
66
|
+
/** 面向日志/调试的简短说明;禁止包含窗口标题或图像数据(ADR 59 决策 4)。 */
|
|
67
|
+
detail?: string;
|
|
68
|
+
}
|
|
69
|
+
/** 成功结果。 */
|
|
70
|
+
export interface AppshotSuccess {
|
|
71
|
+
ok: true;
|
|
72
|
+
payload: AppshotPayload;
|
|
73
|
+
}
|
|
74
|
+
export type AppshotResult = AppshotSuccess | AppshotFailure;
|
package/dist/appshot.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Appshot(前台应用窗口快照)协议类型。
|
|
3
|
+
*
|
|
4
|
+
* 依据:peer-knowledge ADR 59(Appshots 能力边界与 Evidence 链)、
|
|
5
|
+
* design/product/appshots-window-context-capture.md §5.4 产品语义模型、
|
|
6
|
+
* design/product/appshots-engineering-task-breakdown.md §3.1 spike 实测定案。
|
|
7
|
+
*
|
|
8
|
+
* 约束(ADR 59 决策 3):
|
|
9
|
+
* - `visual.artifactRef` 引用本地落盘 PNG;整图禁止以 dataUrl 内联进会话存储。
|
|
10
|
+
* - `visual.thumbnailDataUrl` 仅允许小缩略图(用于卡片即时渲染)。
|
|
11
|
+
* - 失败必须结构化为 AppshotFailureCode 四类;permission_denied 由 preflight 判定。
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -22,8 +22,29 @@ export interface RuntimeTurnUsage extends UsageAmounts {
|
|
|
22
22
|
readonly usageScope: 'runtime_turn';
|
|
23
23
|
readonly providerRequestCount: number;
|
|
24
24
|
}
|
|
25
|
+
/** Durable billable sum for one provider/model key inside a conversation ledger. */
|
|
26
|
+
export interface ConversationLifetimeModelUsage {
|
|
27
|
+
/** Stable provider binding id, e.g. '5198c365-...::ultimate'. */
|
|
28
|
+
readonly modelProviderId: string;
|
|
29
|
+
readonly model?: string;
|
|
30
|
+
readonly providerName?: string;
|
|
31
|
+
readonly inputTokens: number;
|
|
32
|
+
readonly outputTokens: number;
|
|
33
|
+
readonly totalTokens: number;
|
|
34
|
+
readonly cacheReadTokens: number;
|
|
35
|
+
readonly cacheWriteTokens: number;
|
|
36
|
+
readonly estimatedCostUsd: number;
|
|
37
|
+
readonly requestCount: number;
|
|
38
|
+
}
|
|
25
39
|
/** Durable billable sum across completed runtime turns in one conversation. */
|
|
26
40
|
export interface ConversationLifetimeUsage extends UsageAmounts {
|
|
27
41
|
readonly usageScope: 'conversation_lifetime';
|
|
28
42
|
readonly runtimeTurnCount?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Per-model split of the same lifetime totals. Keyed by modelProviderId.
|
|
45
|
+
* Absent for conversations recorded before the byModel ledger existed
|
|
46
|
+
* (statistics then fall back to the request-level snapshot, or to the
|
|
47
|
+
* legacy "lifetime totals × current price" estimate).
|
|
48
|
+
*/
|
|
49
|
+
readonly byModel?: Readonly<Record<string, ConversationLifetimeModelUsage>>;
|
|
29
50
|
}
|