@peer-agent/protocol 0.1.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.
@@ -0,0 +1,104 @@
1
+ export interface WorkingMemorySection {
2
+ readonly key: string;
3
+ readonly title: string;
4
+ readonly content: string;
5
+ readonly priority?: number;
6
+ readonly source?: 'conversation' | 'agent' | 'local_preview';
7
+ }
8
+ export interface WorkingMemorySnapshotEntry {
9
+ readonly id?: number;
10
+ readonly itemType?: string;
11
+ readonly title?: string | null;
12
+ readonly content: string;
13
+ readonly sourceMessageId?: number | null;
14
+ readonly sourceRefId?: string | null;
15
+ readonly gmtModified?: string | null;
16
+ }
17
+ export interface WorkingMemorySnapshotJson {
18
+ readonly currentGoal?: WorkingMemorySnapshotEntry | null;
19
+ readonly constraints?: readonly WorkingMemorySnapshotEntry[];
20
+ readonly decisions?: readonly WorkingMemorySnapshotEntry[];
21
+ readonly facts?: readonly WorkingMemorySnapshotEntry[];
22
+ readonly currentState?: WorkingMemorySnapshotEntry | null;
23
+ readonly nextStep?: WorkingMemorySnapshotEntry | null;
24
+ readonly abandonedPaths?: readonly WorkingMemorySnapshotEntry[];
25
+ readonly keyObjects?: readonly WorkingMemorySnapshotEntry[];
26
+ }
27
+ export interface WorkingMemoryPromptSection {
28
+ readonly scope: 'conversation' | 'agent';
29
+ readonly agentId: number;
30
+ readonly version: number;
31
+ readonly snapshotUuid: string;
32
+ readonly renderText: string;
33
+ readonly tokenEstimate: number;
34
+ readonly snapshotJson?: WorkingMemorySnapshotJson | null;
35
+ readonly gmtCreate?: string;
36
+ }
37
+ export type WorkingMemoryData = readonly WorkingMemoryPromptSection[] | readonly WorkingMemorySection[] | {
38
+ readonly conversationId: number;
39
+ readonly agentId?: number;
40
+ readonly sections: readonly WorkingMemorySection[];
41
+ readonly updatedAt?: string;
42
+ };
43
+ export type MemoryWikiCompileStatus = 'empty' | 'running' | 'completed' | 'failed';
44
+ export type MemoryWikiCompileMode = 'full' | 'delta';
45
+ export interface InitializeConversationMemoryWikiResult {
46
+ readonly conversationId: number;
47
+ readonly agentId?: number;
48
+ readonly status: MemoryWikiCompileStatus;
49
+ readonly mode?: MemoryWikiCompileMode | null;
50
+ readonly initialized?: boolean;
51
+ readonly enqueuedJobs?: number;
52
+ readonly consumedMessageCount?: number;
53
+ readonly pageCount?: number;
54
+ readonly error?: string;
55
+ }
56
+ export interface ConversationMemoryWikiStatus {
57
+ readonly conversationId?: number;
58
+ readonly agentId?: number;
59
+ readonly status: 'not_initialized' | 'initializing' | 'ready' | 'failed' | MemoryWikiCompileStatus;
60
+ readonly mode?: MemoryWikiCompileMode | null;
61
+ readonly pageCount?: number;
62
+ readonly totalJobs?: number;
63
+ readonly pendingJobs?: number;
64
+ readonly runningJobs?: number;
65
+ readonly completedJobs?: number;
66
+ readonly failedJobs?: number;
67
+ readonly skippedJobs?: number;
68
+ readonly progressPercent?: number;
69
+ readonly canInitialize?: boolean;
70
+ readonly updatedAt?: string;
71
+ }
72
+ export interface ConversationMemoryWikiPage {
73
+ readonly pageUuid: string;
74
+ readonly pageKey: string;
75
+ readonly title: string;
76
+ readonly pageType?: string;
77
+ readonly scopeType?: string;
78
+ readonly summary?: string;
79
+ readonly tags?: readonly string[];
80
+ readonly importance?: number;
81
+ readonly confidence?: number;
82
+ readonly version?: number;
83
+ readonly markdown?: string;
84
+ readonly bodyMd?: string;
85
+ readonly structuredJson?: Record<string, unknown> | null;
86
+ readonly entities?: readonly unknown[];
87
+ readonly evidenceRefs?: readonly unknown[];
88
+ readonly updatedAt?: string;
89
+ readonly gmtModified?: string | null;
90
+ }
91
+ export interface ConversationMemoryWikiPageListData {
92
+ readonly list?: readonly ConversationMemoryWikiPage[];
93
+ readonly pages?: readonly ConversationMemoryWikiPage[];
94
+ readonly total?: number;
95
+ readonly limit?: number;
96
+ readonly offset?: number;
97
+ }
98
+ export interface ConversationMemoryCompileStatus {
99
+ readonly conversationId: number;
100
+ readonly agentId?: number;
101
+ readonly status: 'idle' | 'running' | 'completed' | 'failed';
102
+ readonly consumedMessageCount?: number;
103
+ readonly error?: string;
104
+ }
package/dist/memory.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,180 @@
1
+ export type AttachmentContextKind = 'image' | 'text' | 'unsupported';
2
+ export type AttachmentContextTransport = 'provider_image_part' | 'user_text_part' | 'metadata_only' | string;
3
+ export interface AttachmentContextItem {
4
+ readonly id?: string;
5
+ readonly name: string;
6
+ readonly mimeType: string;
7
+ readonly size: number;
8
+ readonly kind: AttachmentContextKind;
9
+ readonly contentIncluded: boolean;
10
+ readonly transport: AttachmentContextTransport;
11
+ }
12
+ export type ContextAttachmentSourceKind = 'user_upload' | 'clipboard' | 'skill' | 'memory' | 'hook' | 'mcp' | 'runtime' | string;
13
+ export type ContextAttachmentScope = 'turn' | 'conversation' | 'workspace' | 'session' | string;
14
+ export type ContextAttachmentLifecycle = 'ephemeral' | 'durable_ref' | 'evidence_ref' | string;
15
+ export interface ContextAttachmentItem extends AttachmentContextItem {
16
+ readonly sourceKind?: ContextAttachmentSourceKind;
17
+ readonly scope?: ContextAttachmentScope;
18
+ readonly lifecycle?: ContextAttachmentLifecycle;
19
+ readonly contentRef?: string;
20
+ }
21
+ export type RuntimeReminderKind = 'mode' | 'provider' | 'permission' | 'continuity' | 'attachment' | 'runtime' | string;
22
+ export type RuntimeReminderScope = 'turn' | 'conversation' | 'workspace' | 'session' | string;
23
+ export interface RuntimeReminderItem {
24
+ readonly id: string;
25
+ readonly title?: string;
26
+ readonly content: string;
27
+ readonly kind?: RuntimeReminderKind;
28
+ readonly scope?: RuntimeReminderScope;
29
+ readonly layer?: 'L2_RUNTIME' | 'L5_TOOL_RULES' | 'L6_MODE_REMINDER' | 'L7_CONTINUITY' | string;
30
+ readonly priority?: number;
31
+ readonly sourceKind?: 'runtime' | 'system' | 'plugin' | 'skill' | 'mcp' | string;
32
+ readonly trust?: 'builtin' | 'runtime' | 'workspace' | 'user' | 'extension' | string;
33
+ }
34
+ export interface ContinuityContextItem {
35
+ readonly id?: string;
36
+ readonly method: string;
37
+ readonly originalMessageCount: number;
38
+ readonly beforeTokens: number;
39
+ readonly afterTokens: number;
40
+ readonly summary: string;
41
+ readonly content?: string;
42
+ }
43
+ export interface ConfigInstructionContextItem {
44
+ readonly id?: string;
45
+ readonly title?: string;
46
+ readonly content: string;
47
+ readonly priority?: number;
48
+ readonly source?: string;
49
+ }
50
+ export interface ContextExtensionItem {
51
+ readonly id: string;
52
+ readonly title?: string;
53
+ readonly content: string;
54
+ readonly layer?: 'L3_INSTRUCTIONS' | 'L4_CAPABILITIES' | 'L5_TOOL_RULES' | string;
55
+ readonly priority?: number;
56
+ readonly sourceKind?: 'plugin' | 'skill' | 'mcp' | 'runtime' | string;
57
+ readonly trust?: 'builtin' | 'runtime' | 'workspace' | 'user' | 'extension' | string;
58
+ }
59
+ export interface ChatProviderMessage {
60
+ readonly role: string;
61
+ readonly content: unknown;
62
+ }
63
+ export interface ChatSendRequest {
64
+ readonly messages: readonly ChatProviderMessage[];
65
+ readonly streamId: string;
66
+ /**
67
+ * 助手消息的持久化主键(renderer 在发送前已 append 的空 assistant 占位消息 id)。
68
+ * 主进程据此把累积的正文/segments 落盘到 conversationStore,无需依赖 renderer
69
+ * 在终态事件时回写——这是「正文持久化真值下沉主进程」的链路锚点。
70
+ */
71
+ readonly assistantMessageId?: string;
72
+ readonly effort?: string;
73
+ readonly mode?: string;
74
+ readonly conversationId?: string;
75
+ /**
76
+ * 会话级绑定的模型 provider 复合 id(groupId::modelId)。渲染端从会话 meta 透传,
77
+ * 主进程据此把该 provider 排为本轮首选;若已失效则回退全局默认(强绑定回退)。
78
+ * 缺省时主进程会按 conversationId 从 conversation-store 兜底解析。
79
+ */
80
+ readonly modelProviderId?: string | null;
81
+ /**
82
+ * 渲染端当前活跃工作区路径(B2 兜底通道)。仅在主进程无法按 conversationId 从
83
+ * conversation-store 解析到会话绑定的 workspacePath 时,作为兜底/校验来源使用,
84
+ * 不作为运行根目录的主真值。详见 llm-chat-service.resolveRunWorkspacePath。
85
+ */
86
+ readonly workspacePath?: string | null;
87
+ readonly contextAttachments?: readonly ContextAttachmentItem[];
88
+ readonly runtimeReminders?: readonly RuntimeReminderItem[];
89
+ readonly attachmentContext?: readonly AttachmentContextItem[];
90
+ readonly continuityContext?: readonly ContinuityContextItem[];
91
+ readonly configInstructions?: readonly ConfigInstructionContextItem[];
92
+ readonly contextExtensions?: readonly ContextExtensionItem[];
93
+ }
94
+ export interface PromptSnapshotSectionRef {
95
+ readonly id: string;
96
+ readonly layer: string;
97
+ readonly checksum: string;
98
+ readonly source?: Record<string, unknown>;
99
+ }
100
+ export interface PromptSnapshotIndexEntry {
101
+ readonly id: string;
102
+ readonly contextSnapshotId: string;
103
+ readonly createdAt: string;
104
+ readonly streamId: string | null;
105
+ readonly conversationId: string | null;
106
+ readonly workspacePath: string | null;
107
+ readonly provider: string | null;
108
+ readonly providerId: string | null;
109
+ readonly model: string | null;
110
+ readonly mode: string | null;
111
+ readonly effort: string | null;
112
+ readonly renderedHash: string;
113
+ readonly sectionRefs: readonly PromptSnapshotSectionRef[];
114
+ readonly baselineId?: string;
115
+ readonly baselineReason?: string;
116
+ readonly contextEpochId?: string;
117
+ }
118
+ export interface PromptSnapshotRecord extends PromptSnapshotIndexEntry {
119
+ readonly context: {
120
+ readonly version: number;
121
+ readonly rendered: string;
122
+ readonly sections: readonly Record<string, unknown>[];
123
+ readonly snapshot: Record<string, unknown>;
124
+ };
125
+ }
126
+ export interface PromptBaselineRecord {
127
+ readonly baselineId: string;
128
+ readonly contextEpochId: string;
129
+ readonly reason: string;
130
+ readonly promptRecordId: string;
131
+ readonly contextSnapshotId: string;
132
+ readonly createdAt: string;
133
+ readonly conversationId: string | null;
134
+ readonly workspacePath: string | null;
135
+ readonly provider: string | null;
136
+ readonly providerId: string | null;
137
+ readonly model: string | null;
138
+ readonly mode: string | null;
139
+ readonly effort: string | null;
140
+ readonly renderedHash: string;
141
+ readonly sectionRefs: readonly PromptSnapshotSectionRef[];
142
+ }
143
+ export interface PromptContextEpochRecord {
144
+ readonly contextEpochId: string;
145
+ readonly reason: string;
146
+ readonly baselineId: string;
147
+ readonly promptRecordId: string;
148
+ readonly contextSnapshotId: string;
149
+ readonly createdAt: string;
150
+ readonly replacesContextEpochId: string | null;
151
+ readonly conversationId: string | null;
152
+ readonly workspacePath: string | null;
153
+ readonly provider: string | null;
154
+ readonly providerId: string | null;
155
+ readonly model: string | null;
156
+ readonly mode: string | null;
157
+ readonly effort: string | null;
158
+ readonly renderedHash: string;
159
+ readonly sectionRefs: readonly PromptSnapshotSectionRef[];
160
+ }
161
+ export type PromptContextEpochEventType = 'epoch_created' | 'epoch_replaced' | 'snapshot_anchored';
162
+ export interface PromptContextEpochEventRecord {
163
+ readonly eventId: string;
164
+ readonly eventType: PromptContextEpochEventType;
165
+ readonly occurredAt: string;
166
+ readonly contextEpochId: string;
167
+ readonly previousContextEpochId: string | null;
168
+ readonly reason: string | null;
169
+ readonly baselineId: string | null;
170
+ readonly promptRecordId: string;
171
+ readonly contextSnapshotId: string;
172
+ readonly conversationId: string | null;
173
+ readonly workspacePath: string | null;
174
+ readonly provider: string | null;
175
+ readonly providerId: string | null;
176
+ readonly model: string | null;
177
+ readonly mode: string | null;
178
+ readonly effort: string | null;
179
+ readonly renderedHash: string;
180
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,72 @@
1
+ /**
2
+ * 更新通道(Update Channel)契约。
3
+ *
4
+ * 这是「版本号显示 + 检查更新 + 可选更新通道」能力的跨层边界类型:
5
+ * - 桌面更新适配器依据通道决定使用 latest*.yml / beta*.yml 哪条清单。
6
+ * - 渲染层(表达)仅消费这些类型展示版本徽标、更新摘要弹窗与设置项。
7
+ * - settings 存储是通道选择的权限真相(updateChannel 字段)。
8
+ */
9
+ export type UpdateChannel = 'beta' | 'stable';
10
+ /**
11
+ * 用户对更新通道的偏好。
12
+ * - 'auto':未手动选择,回退到「按当前应用版本号语义」推断(含 -beta/-alpha/-rc → beta,否则 stable)。
13
+ * - 'beta' / 'stable':用户手动选择,优先于版本号推断。
14
+ */
15
+ export type UpdateChannelPreference = 'auto' | UpdateChannel;
16
+ /** 更新流程阶段。渲染层据此切换徽标红点 / 摘要弹窗 / 下载进度 / 安装态的表达。 */
17
+ export type UpdaterPhase = 'idle' | 'checking' | 'available' | 'not-available' | 'downloading' | 'downloaded'
18
+ /**
19
+ * mac 专用完成态:应用为 ad-hoc 签名,无法走 Squirrel 的「下载→签名校验→原子替换」
20
+ * 自动安装链路,因此主进程自管下载 dmg 后停在此态,由用户在弹窗点击「打开安装包」,
21
+ * 主进程 shell.openPath(dmg) 打开挂载,用户手动拖入「应用程序」覆盖安装。
22
+ * 与 'downloaded'(Windows 重启安装)语义互斥。
23
+ */
24
+ | 'ready-to-open' | 'error';
25
+ /** 主进程向渲染层广播的更新事件(与 auto-updater 的 onEvent 一一对应)。 */
26
+ export interface UpdaterEvent {
27
+ readonly type: 'checking-for-update' | 'update-available' | 'update-not-available' | 'download-progress' | 'update-downloaded' | 'error';
28
+ /** 目标/可用版本号(available / downloaded / not-available 时携带)。 */
29
+ readonly version?: string;
30
+ /** 下载进度百分比(download-progress 时携带,0–100 整数)。 */
31
+ readonly percent?: number;
32
+ /** 错误信息(error 时携带)。 */
33
+ readonly message?: string;
34
+ /** 更新说明 / release notes(available / downloaded 时可能携带)。 */
35
+ readonly releaseNotes?: string;
36
+ }
37
+ /** 渲染层订阅 / 主动查询时获得的更新状态快照。 */
38
+ export interface UpdaterStatus {
39
+ /** 当前应用版本号(来自 app.getVersion)。 */
40
+ readonly currentVersion: string;
41
+ /** 实际生效的更新通道(preference=auto 时为版本号推断结果)。 */
42
+ readonly channel: UpdateChannel;
43
+ /** 用户偏好(settings 真相)。 */
44
+ readonly preference: UpdateChannelPreference;
45
+ /** 更新能力是否启用(开发态默认禁用)。 */
46
+ readonly enabled: boolean;
47
+ /** 当前流程阶段。 */
48
+ readonly phase: UpdaterPhase;
49
+ /** 可用 / 已下载的新版本号。 */
50
+ readonly availableVersion?: string;
51
+ /** 下载进度百分比(0–100)。 */
52
+ readonly percent?: number;
53
+ /** 最近一次错误信息。 */
54
+ readonly error?: string;
55
+ /** 更新说明 / release notes。 */
56
+ readonly releaseNotes?: string;
57
+ /**
58
+ * mac 自管下载完成的安装包(dmg)本地绝对路径,仅 phase='ready-to-open' 时存在。
59
+ * 渲染层据此启用「打开安装包」按钮(实际打开动作仍在主进程 shell.openPath 执行)。
60
+ */
61
+ readonly installerPath?: string;
62
+ /**
63
+ * 兜底用的 GitHub Release 页面 URL。当 mac 自管下载因资产缺失/命名漂移失败时,
64
+ * 主进程置 phase='error' 并提供此链接,渲染层展示「打开 Release 页面」按钮。
65
+ */
66
+ readonly releaseUrl?: string;
67
+ }
68
+ /** settings:update / settings:get 中与更新相关的字段。 */
69
+ export interface UpdaterSettings {
70
+ /** 更新通道偏好,缺省 'auto'。 */
71
+ readonly updateChannel?: UpdateChannelPreference;
72
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@peer-agent/protocol",
3
+ "version": "0.1.0",
4
+ "description": "Shared host-neutral protocol contracts for Peer Agent runtimes and clients.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "sideEffects": false,
8
+ "engines": {
9
+ "node": ">=20"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/yinLiangDream/Peer-Agent.git",
14
+ "directory": "packages/protocol"
15
+ },
16
+ "homepage": "https://github.com/yinLiangDream/Peer-Agent#readme",
17
+ "bugs": {
18
+ "url": "https://github.com/yinLiangDream/Peer-Agent/issues"
19
+ },
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "main": "./dist/index.js",
24
+ "types": "./dist/index.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "default": "./dist/index.js"
29
+ }
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "README.md"
34
+ ],
35
+ "devDependencies": {
36
+ "typescript": "^5.9.3"
37
+ },
38
+ "scripts": {
39
+ "build": "tsc -p tsconfig.build.json",
40
+ "typecheck": "tsc -p tsconfig.json"
41
+ }
42
+ }