@peer-agent/protocol 0.0.1 → 0.0.2-beta.1

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,279 @@
1
+ import type { Evidence } from './index.ts';
2
+ /** Stable lifecycle of a reusable automation definition. */
3
+ export type AutomationLifecycleStatus = 'draft' | 'active' | 'paused' | 'completed' | 'disabled' | 'archived';
4
+ export type AutomationScheduleKind = 'once' | 'hourly' | 'daily' | 'weekdays' | 'weekly' | 'monthly' | 'custom_cron';
5
+ export type AutomationMissedRunPolicy = 'run_latest' | 'skip';
6
+ export type AutomationOverlapPolicy = 'skip' | 'queue_latest';
7
+ export type AutomationAccessPreset = 'observe' | 'work_in_workspace';
8
+ export type AutomationTriggerSource = 'scheduled' | 'manual' | 'retry';
9
+ export type AutomationRunStatus = 'scheduled' | 'queued' | 'preparing' | 'running' | 'waiting_permission' | 'waiting_user' | 'succeeded' | 'failed' | 'cancelled' | 'skipped' | 'timed_out' | 'blocked';
10
+ export type AutomationRunBlockedReason = 'workspace_missing' | 'workspace_not_git' | 'git_baseline_invalid' | 'provider_unavailable' | 'auth_expired' | 'capability_missing' | 'grant_invalid' | 'budget_exhausted_before_start' | 'runtime_unavailable';
11
+ export type AutomationRunSkippedReason = 'overlap' | 'missed_policy' | 'automation_paused' | 'global_pause';
12
+ export interface AutomationSchedule {
13
+ readonly kind: AutomationScheduleKind;
14
+ /** IANA timezone such as Asia/Shanghai. */
15
+ readonly timezone: string;
16
+ /** ISO timestamp for a one-time schedule. */
17
+ readonly onceAt?: string;
18
+ /** Positive interval for hourly schedules. */
19
+ readonly everyHours?: number;
20
+ /** Local wall-clock hour in the saved timezone. */
21
+ readonly hour?: number;
22
+ /** Local wall-clock minute in the saved timezone. */
23
+ readonly minute?: number;
24
+ /** ISO weekday values: Monday=1 ... Sunday=7. */
25
+ readonly weekdays?: readonly number[];
26
+ /** Day of month, 1...31. */
27
+ readonly dayOfMonth?: number;
28
+ /** Five-field, minute-level cron expression. */
29
+ readonly cron?: string;
30
+ }
31
+ export interface AutomationGrant {
32
+ readonly preset: AutomationAccessPreset;
33
+ readonly workspacePath: string;
34
+ readonly allowedCapabilityIds: readonly string[];
35
+ readonly askCapabilityIds: readonly string[];
36
+ readonly blockedCapabilityIds: readonly string[];
37
+ readonly confirmedAt: string;
38
+ readonly version: number;
39
+ }
40
+ export interface AutomationNotificationPolicy {
41
+ readonly needsAttention: 'system_and_badge' | 'badge_only';
42
+ readonly failed: boolean;
43
+ readonly succeeded: boolean;
44
+ }
45
+ export interface AutomationBudget {
46
+ readonly timeoutMs: number;
47
+ readonly maxTokens?: number;
48
+ readonly maxCostUsd?: number;
49
+ readonly maxRunsPerDay?: number;
50
+ }
51
+ export interface AutomationDefinition {
52
+ readonly automationId: string;
53
+ readonly version: number;
54
+ readonly name: string;
55
+ readonly prompt: string;
56
+ readonly workspacePath: string;
57
+ readonly modelProviderId?: string | null;
58
+ readonly schedule: AutomationSchedule;
59
+ readonly grant: AutomationGrant;
60
+ readonly notifications: AutomationNotificationPolicy;
61
+ readonly budget: AutomationBudget;
62
+ readonly missedRunPolicy: AutomationMissedRunPolicy;
63
+ readonly overlapPolicy: AutomationOverlapPolicy;
64
+ readonly status: AutomationLifecycleStatus;
65
+ readonly pauseReason?: 'user' | 'global' | 'consecutive_failures' | 'configuration_invalid';
66
+ readonly consecutiveFailures: number;
67
+ readonly lastScheduledAt?: string;
68
+ readonly lastRunAt?: string;
69
+ readonly nextRunAt?: string;
70
+ readonly createdAt: string;
71
+ readonly updatedAt: string;
72
+ }
73
+ /** Immutable definition/runtime facts captured when a run is created. */
74
+ export interface AutomationRunSnapshot {
75
+ readonly definitionVersion: number;
76
+ readonly name: string;
77
+ readonly prompt: string;
78
+ readonly workspacePath: string;
79
+ readonly modelProviderId?: string | null;
80
+ readonly schedule: AutomationSchedule;
81
+ readonly grant: AutomationGrant;
82
+ readonly budget: AutomationBudget;
83
+ readonly gitBaseline?: {
84
+ readonly commit: string;
85
+ readonly branch?: string;
86
+ readonly dirty: boolean;
87
+ };
88
+ }
89
+ export interface AutomationRunVerification {
90
+ readonly command: string;
91
+ readonly status: 'passed' | 'failed';
92
+ readonly exitCode?: number;
93
+ readonly summary?: string;
94
+ readonly evidenceRefs: readonly string[];
95
+ }
96
+ export interface AutomationRunChangeSet {
97
+ readonly worktreePath?: string;
98
+ readonly branch?: string;
99
+ readonly changedFiles: readonly string[];
100
+ readonly additions?: number;
101
+ readonly deletions?: number;
102
+ readonly diffArtifactRefs: readonly string[];
103
+ readonly retained: boolean;
104
+ }
105
+ export interface AutomationRunReceipt {
106
+ readonly summary?: string;
107
+ readonly error?: string;
108
+ readonly evidence: readonly Evidence[];
109
+ readonly evidenceRefs: readonly string[];
110
+ readonly verifications: readonly AutomationRunVerification[];
111
+ readonly changes?: AutomationRunChangeSet;
112
+ readonly inputTokens?: number;
113
+ readonly outputTokens?: number;
114
+ readonly costUsd?: number;
115
+ readonly durationMs?: number;
116
+ readonly completedAt: string;
117
+ }
118
+ export interface AutomationRun {
119
+ readonly runId: string;
120
+ readonly automationId: string;
121
+ readonly sourceRunId?: string;
122
+ readonly idempotencyKey: string;
123
+ readonly triggerSource: AutomationTriggerSource;
124
+ readonly status: AutomationRunStatus;
125
+ readonly scheduledAt: string;
126
+ readonly createdAt: string;
127
+ readonly startedAt?: string;
128
+ readonly finishedAt?: string;
129
+ readonly conversationId?: number;
130
+ readonly missedRecovery?: boolean;
131
+ readonly blockedReason?: AutomationRunBlockedReason;
132
+ readonly skippedReason?: AutomationRunSkippedReason;
133
+ readonly failureReason?: string;
134
+ readonly attentionVersion: number;
135
+ readonly snapshot: AutomationRunSnapshot;
136
+ readonly receipt?: AutomationRunReceipt;
137
+ }
138
+ export interface AutomationRuntimeState {
139
+ readonly globallyPaused: boolean;
140
+ readonly pausedAt?: string;
141
+ readonly activeRunIds: readonly string[];
142
+ readonly updatedAt: string;
143
+ }
144
+ export interface AutomationSummary {
145
+ readonly definition: AutomationDefinition;
146
+ readonly latestRun?: AutomationRun;
147
+ readonly activeRun?: AutomationRun;
148
+ readonly needsAttention: boolean;
149
+ }
150
+ export interface AutomationCreateInput {
151
+ readonly name: string;
152
+ readonly prompt: string;
153
+ readonly workspacePath: string;
154
+ readonly modelProviderId?: string | null;
155
+ readonly schedule: AutomationSchedule;
156
+ readonly grant: AutomationGrant;
157
+ readonly notifications: AutomationNotificationPolicy;
158
+ readonly budget: AutomationBudget;
159
+ readonly missedRunPolicy?: AutomationMissedRunPolicy;
160
+ readonly overlapPolicy?: AutomationOverlapPolicy;
161
+ readonly enable: boolean;
162
+ }
163
+ export interface AutomationUpdateInput {
164
+ readonly automationId: string;
165
+ readonly expectedVersion: number;
166
+ readonly patch: Partial<Omit<AutomationCreateInput, 'enable'>> & {
167
+ readonly status?: AutomationLifecycleStatus;
168
+ };
169
+ }
170
+ export interface AutomationListInput {
171
+ readonly workspacePath?: string;
172
+ readonly statuses?: readonly AutomationLifecycleStatus[];
173
+ readonly query?: string;
174
+ }
175
+ export interface AutomationRunListInput {
176
+ readonly automationId: string;
177
+ readonly statuses?: readonly AutomationRunStatus[];
178
+ readonly limit?: number;
179
+ readonly before?: string;
180
+ }
181
+ export interface AutomationRunNowInput {
182
+ readonly automationId: string;
183
+ }
184
+ export interface AutomationRetryRunInput {
185
+ readonly runId: string;
186
+ }
187
+ export interface AutomationCancelRunInput {
188
+ readonly runId: string;
189
+ }
190
+ export interface AutomationPermissionDecisionInput {
191
+ readonly runId: string;
192
+ readonly toolCallId: string;
193
+ readonly decision: 'allow_once' | 'deny';
194
+ }
195
+ export interface AutomationRuntimeCommandInput {
196
+ readonly paused: boolean;
197
+ }
198
+ export type AutomationEvent = {
199
+ readonly type: 'definition_changed';
200
+ readonly automationId: string;
201
+ } | {
202
+ readonly type: 'run_changed';
203
+ readonly automationId: string;
204
+ readonly runId: string;
205
+ } | {
206
+ readonly type: 'attention_changed';
207
+ readonly automationId: string;
208
+ readonly runId: string;
209
+ readonly attentionVersion: number;
210
+ } | {
211
+ readonly type: 'runtime_changed';
212
+ readonly state: AutomationRuntimeState;
213
+ };
214
+ export interface AutomationBootstrapResult {
215
+ readonly automations: readonly AutomationSummary[];
216
+ readonly runtime: AutomationRuntimeState;
217
+ }
218
+ /** How a conversation entered automation-task creation. */
219
+ export type AutomationCreateContextSource = 'automation_center' | 'chat_intent';
220
+ /** Conversation-scoped state; persisted with conversation metadata across restarts. */
221
+ export type AutomationCreateContextStatus = 'collecting' | 'proposed' | 'creating' | 'created' | 'cancelled' | 'failed';
222
+ export type AutomationProposalStatus = 'proposed' | 'creating' | 'created' | 'cancelled' | 'failed';
223
+ export type AutomationProposalConfidence = 'high' | 'medium';
224
+ /**
225
+ * Structured proposal emitted by the governed local automation capability.
226
+ * `definition` reuses the existing create contract; this is not a second automation definition.
227
+ */
228
+ export interface AutomationChatProposal {
229
+ readonly schemaVersion: 1;
230
+ readonly proposalId: string;
231
+ readonly conversationId: string;
232
+ readonly fingerprint: string;
233
+ readonly source: AutomationCreateContextSource;
234
+ readonly confidence: AutomationProposalConfidence;
235
+ readonly status: AutomationProposalStatus;
236
+ readonly definition: AutomationCreateInput;
237
+ readonly replacesProposalId?: string | null;
238
+ readonly createdAt: string;
239
+ readonly updatedAt: string;
240
+ readonly automationId?: string | null;
241
+ readonly receipt?: AutomationCreationReceipt | null;
242
+ readonly error?: string | null;
243
+ }
244
+ /** Single conversation source of truth while a task is being collected or proposed. */
245
+ export interface AutomationCreateContext {
246
+ readonly schemaVersion: 1;
247
+ readonly kind: 'automation_create';
248
+ readonly source: AutomationCreateContextSource;
249
+ readonly status: AutomationCreateContextStatus;
250
+ readonly activeProposal?: AutomationChatProposal | null;
251
+ readonly rejectedFingerprints: readonly string[];
252
+ readonly createdAt: string;
253
+ readonly updatedAt: string;
254
+ }
255
+ export type AutomationProposalAction = 'confirm' | 'cancel';
256
+ export interface AutomationProposalActionRequest {
257
+ readonly conversationId: string;
258
+ readonly proposalId: string;
259
+ readonly fingerprint: string;
260
+ readonly action: AutomationProposalAction;
261
+ }
262
+ /** Receipt is derived from a real created Automation Definition, never assistant text. */
263
+ export interface AutomationCreationReceipt {
264
+ readonly schemaVersion: 1;
265
+ readonly proposalId: string;
266
+ readonly fingerprint: string;
267
+ readonly conversationId: string;
268
+ readonly automationId: string;
269
+ readonly automationName: string;
270
+ readonly definitionVersion: number;
271
+ readonly lifecycleStatus: AutomationLifecycleStatus;
272
+ readonly createdAt: string;
273
+ readonly nextRunAt?: string | null;
274
+ }
275
+ export interface AutomationProposalActionResult {
276
+ readonly proposal: AutomationChatProposal;
277
+ readonly receipt?: AutomationCreationReceipt | null;
278
+ readonly replayed: boolean;
279
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -789,3 +789,4 @@ export * from './system-context.ts';
789
789
  export * from './goal.ts';
790
790
  export * from './updater.ts';
791
791
  export * from './appshot.ts';
792
+ export * from './automation.ts';
package/dist/index.js CHANGED
@@ -22,3 +22,4 @@ export * from "./system-context.js";
22
22
  export * from "./goal.js";
23
23
  export * from "./updater.js";
24
24
  export * from "./appshot.js";
25
+ export * from "./automation.js";
@@ -1,5 +1,13 @@
1
1
  export type AttachmentContextKind = 'image' | 'text' | 'unsupported';
2
2
  export type AttachmentContextTransport = 'provider_image_part' | 'user_text_part' | 'metadata_only' | string;
3
+ /**
4
+ * 全局「兜底多模态模型」配置。
5
+ * 主模型不支持 vision 时,可先用该模型识别本轮新图,再静默注入文本给主模型。
6
+ * providerId 指向 listProviders() 的复合 id;null/缺省表示未配置。
7
+ */
8
+ export interface FallbackVisionModelSettings {
9
+ readonly providerId?: string | null;
10
+ }
3
11
  export interface AttachmentContextItem {
4
12
  readonly id?: string;
5
13
  readonly name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peer-agent/protocol",
3
- "version": "0.0.1",
3
+ "version": "0.0.2-beta.1",
4
4
  "description": "Shared host-neutral protocol contracts for Peer Agent runtimes and clients.",
5
5
  "type": "module",
6
6
  "license": "MIT",