@peer-agent/protocol 0.1.0-rc.44 → 0.1.0-rc.46
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/delegation.d.ts +5 -0
- package/dist/delegation.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/project-input-recovery.d.ts +10 -0
- package/dist/project-input-recovery.js +20 -0
- package/dist/project.d.ts +2 -0
- package/dist/quiet-reply.d.ts +9 -0
- package/dist/quiet-reply.js +43 -0
- package/dist/resource-feedback-transport.d.ts +1 -0
- package/dist/resource-feedback-transport.js +2 -1
- package/dist/skill-marketplace.d.ts +39 -4
- package/dist/working-plan.d.ts +18 -0
- package/dist/working-plan.js +1 -0
- package/package.json +1 -1
package/dist/delegation.d.ts
CHANGED
|
@@ -89,6 +89,8 @@ export interface WorkSessionConversationMeta extends SessionQueueFacts {
|
|
|
89
89
|
readonly conversationId?: string;
|
|
90
90
|
readonly workspaceId: string;
|
|
91
91
|
readonly spawnedAt?: string;
|
|
92
|
+
readonly startedAt?: string;
|
|
93
|
+
readonly endedAt?: string;
|
|
92
94
|
readonly origin: DelegationOrigin;
|
|
93
95
|
readonly supersededBy?: string;
|
|
94
96
|
readonly acceptance?: 'auto' | 'confirm';
|
|
@@ -102,6 +104,7 @@ export interface WorkSessionConversationMeta extends SessionQueueFacts {
|
|
|
102
104
|
readonly obligationDisposition?: 'indexed' | 'suspended' | 'current';
|
|
103
105
|
}
|
|
104
106
|
export interface WorkSession extends SessionQueueFacts {
|
|
107
|
+
readonly followUpEpoch?: number;
|
|
105
108
|
readonly executionOwnership?: ExecutionOwnership;
|
|
106
109
|
readonly followUp?: import('./task-overview.ts').FollowUpProjection;
|
|
107
110
|
readonly verificationProgress?: VerificationProgress;
|
|
@@ -120,6 +123,8 @@ export interface WorkSession extends SessionQueueFacts {
|
|
|
120
123
|
readonly cancelable?: boolean;
|
|
121
124
|
readonly needsYouReason?: TaskOverviewItem['needsYouReason'];
|
|
122
125
|
readonly spawnedAt: string;
|
|
126
|
+
readonly startedAt?: string;
|
|
127
|
+
readonly endedAt?: string;
|
|
123
128
|
readonly conversationId?: string;
|
|
124
129
|
readonly origin: DelegationOrigin;
|
|
125
130
|
readonly supersededBy?: string;
|
package/dist/delegation.js
CHANGED
|
@@ -95,6 +95,8 @@ export function projectWorkSession(plan, conversationMeta) {
|
|
|
95
95
|
...(projected.needsYouReason ? { needsYouReason: projected.needsYouReason } : {}),
|
|
96
96
|
...(conversationMeta.coordination ? { coordination: conversationMeta.coordination } : {}),
|
|
97
97
|
spawnedAt: conversationMeta.spawnedAt ?? plan.updatedAt ?? '',
|
|
98
|
+
...(conversationMeta.startedAt ? { startedAt: conversationMeta.startedAt } : {}),
|
|
99
|
+
...(conversationMeta.endedAt ? { endedAt: conversationMeta.endedAt } : {}),
|
|
98
100
|
...(conversationMeta.conversationId ? { conversationId: conversationMeta.conversationId } : {}),
|
|
99
101
|
origin: conversationMeta.origin,
|
|
100
102
|
...(conversationMeta.resourceBlocker ? { resourceBlocker: conversationMeta.resourceBlocker } : {}),
|
package/dist/index.d.ts
CHANGED
|
@@ -935,3 +935,5 @@ export * from './interactive-result.ts';
|
|
|
935
935
|
export * from './interactive-verification.ts';
|
|
936
936
|
export { normalizeConversationExecution, conversationExecutionPermitsNewRun } from './conversation-execution.ts';
|
|
937
937
|
export type { ConversationExecutionIdentity, ConversationExecution } from './conversation-execution.ts';
|
|
938
|
+
export * from './quiet-reply.js';
|
|
939
|
+
export type { WorkingPlanStepStatus, WorkingPlanStepView, WorkingPlanView } from './working-plan.ts';
|
package/dist/index.js
CHANGED
|
@@ -66,3 +66,4 @@ export * from "./input-prediction.js";
|
|
|
66
66
|
export * from "./interactive-result.js";
|
|
67
67
|
export * from "./interactive-verification.js";
|
|
68
68
|
export { normalizeConversationExecution, conversationExecutionPermitsNewRun } from "./conversation-execution.js";
|
|
69
|
+
export * from './quiet-reply.js';
|
|
@@ -68,6 +68,16 @@ export interface ProjectInputRecoveryPort {
|
|
|
68
68
|
write(request: ProjectInputDraftWriteRequest): Promise<ProjectInputDraftWriteResult>;
|
|
69
69
|
submit(request: UnconfirmedProjectInput & ProjectInputDraftReadRequest): Promise<ProjectAgentSubmitInputResult>;
|
|
70
70
|
}
|
|
71
|
+
export type ProjectInputMutationResult = {
|
|
72
|
+
readonly ok: true;
|
|
73
|
+
} | {
|
|
74
|
+
readonly ok: false;
|
|
75
|
+
readonly code: string;
|
|
76
|
+
};
|
|
77
|
+
export declare const DEFINITE_PROJECT_INPUT_REJECTION_CODES: ReadonlySet<string>;
|
|
71
78
|
export declare function emptyInputDraft(): InputDraftValue;
|
|
72
79
|
/** A handoff failure may follow a durable receipt. Generic ok alone proves nothing. */
|
|
73
80
|
export declare function projectInputWasReceived(result: ProjectAgentSubmitInputResult | null | undefined, workspaceId: string, inputId: string): boolean;
|
|
81
|
+
export declare function isDefiniteProjectInputRejectionCode(code: string | null | undefined): boolean;
|
|
82
|
+
/** True only when the host rejected the input before enqueuing it (no durable receipt). */
|
|
83
|
+
export declare function isDefiniteProjectInputRejection(result: ProjectAgentSubmitInputResult | null | undefined, workspaceId: string, inputId: string): boolean;
|
|
@@ -1,5 +1,25 @@
|
|
|
1
|
+
export const DEFINITE_PROJECT_INPUT_REJECTION_CODES = new Set([
|
|
2
|
+
'QUESTION_CLOSED',
|
|
3
|
+
'INVALID_INPUT',
|
|
4
|
+
'INVALID_INPUT_ID',
|
|
5
|
+
'INVALID_RESOURCE_FEEDBACK',
|
|
6
|
+
'RESOURCE_FEEDBACK_RECIPIENT_CHANGED',
|
|
7
|
+
'RESOURCE_FEEDBACK_ATTACHMENT_LIMIT',
|
|
8
|
+
'INTERACTIVE_FEEDBACK_UNAVAILABLE',
|
|
9
|
+
'NOT_FOUND',
|
|
10
|
+
'WORKSPACE_NOT_FOUND',
|
|
11
|
+
]);
|
|
1
12
|
export function emptyInputDraft() { return { text: '', quote: null, attachments: [] }; }
|
|
2
13
|
/** A handoff failure may follow a durable receipt. Generic ok alone proves nothing. */
|
|
3
14
|
export function projectInputWasReceived(result, workspaceId, inputId) {
|
|
4
15
|
return result?.input?.workspaceId === workspaceId && result.input.inputId === inputId;
|
|
5
16
|
}
|
|
17
|
+
export function isDefiniteProjectInputRejectionCode(code) {
|
|
18
|
+
return typeof code === 'string' && DEFINITE_PROJECT_INPUT_REJECTION_CODES.has(code);
|
|
19
|
+
}
|
|
20
|
+
/** True only when the host rejected the input before enqueuing it (no durable receipt). */
|
|
21
|
+
export function isDefiniteProjectInputRejection(result, workspaceId, inputId) {
|
|
22
|
+
if (!result || result.ok || projectInputWasReceived(result, workspaceId, inputId))
|
|
23
|
+
return false;
|
|
24
|
+
return isDefiniteProjectInputRejectionCode(result.code);
|
|
25
|
+
}
|
package/dist/project.d.ts
CHANGED
|
@@ -302,6 +302,8 @@ export type ProjectAgentStopResponseResult = {
|
|
|
302
302
|
readonly code: 'PROJECT_AGENT_DISABLED' | 'NOT_FOUND' | 'HOST_OFFLINE' | 'STALE_TURN' | 'INVALID_INPUT';
|
|
303
303
|
};
|
|
304
304
|
export interface BotListSession {
|
|
305
|
+
readonly startedAt?: string;
|
|
306
|
+
readonly endedAt?: string;
|
|
305
307
|
readonly sessionId?: string;
|
|
306
308
|
readonly title?: string;
|
|
307
309
|
readonly status: WorkSessionStatus;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const QUIET_REPLY_MARKER: "NO_REPLY";
|
|
2
|
+
export interface QuietReplyParse {
|
|
3
|
+
readonly isQuiet: boolean;
|
|
4
|
+
readonly leadingText: string;
|
|
5
|
+
readonly isPureQuiet: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function parseQuietReply(raw: string): QuietReplyParse;
|
|
8
|
+
export declare function isQuietReply(raw: string): boolean;
|
|
9
|
+
export declare function withoutGrowingQuietMarker(raw: string): string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export const QUIET_REPLY_MARKER = 'NO_REPLY';
|
|
2
|
+
// Match Rust char::is_whitespace and char::is_alphanumeric, including non-ASCII letters.
|
|
3
|
+
const alphanumeric = /[\p{Alphabetic}\p{Number}]/u;
|
|
4
|
+
const markup = /^[`*_]*/u;
|
|
5
|
+
const validSuffix = /^[`*_.!]*$/u;
|
|
6
|
+
const trimEnd = (text) => text.replace(/\p{White_Space}+$/u, '');
|
|
7
|
+
function inlineReference(before, decorations) {
|
|
8
|
+
return decorations.includes('`') && alphanumeric.test(before.slice(before.lastIndexOf('\n') + 1));
|
|
9
|
+
}
|
|
10
|
+
function wordParts(text, separator) {
|
|
11
|
+
let start = text.length;
|
|
12
|
+
while (start > 0 && !separator.test(text[start - 1] ?? ''))
|
|
13
|
+
start--;
|
|
14
|
+
const word = text.slice(start);
|
|
15
|
+
const before = text.slice(0, start);
|
|
16
|
+
const decorations = markup.exec(word)?.[0] ?? '';
|
|
17
|
+
return { before, decorations, bare: word.slice(decorations.length) };
|
|
18
|
+
}
|
|
19
|
+
function exactMarker(bare) {
|
|
20
|
+
return bare.startsWith(QUIET_REPLY_MARKER) && validSuffix.test(bare.slice(QUIET_REPLY_MARKER.length));
|
|
21
|
+
}
|
|
22
|
+
export function parseQuietReply(raw) {
|
|
23
|
+
let remaining = trimEnd(raw);
|
|
24
|
+
let isQuiet = false;
|
|
25
|
+
while (true) {
|
|
26
|
+
const { before, decorations, bare } = wordParts(remaining, /\p{White_Space}/u);
|
|
27
|
+
if (!exactMarker(bare) || inlineReference(before, decorations))
|
|
28
|
+
break;
|
|
29
|
+
isQuiet = true;
|
|
30
|
+
remaining = trimEnd(before);
|
|
31
|
+
}
|
|
32
|
+
const isPureQuiet = isQuiet && !alphanumeric.test(remaining);
|
|
33
|
+
return { isQuiet, isPureQuiet, leadingText: isPureQuiet ? '' : isQuiet ? remaining : raw };
|
|
34
|
+
}
|
|
35
|
+
export function isQuietReply(raw) {
|
|
36
|
+
return parseQuietReply(raw).isQuiet;
|
|
37
|
+
}
|
|
38
|
+
export function withoutGrowingQuietMarker(raw) {
|
|
39
|
+
const { before, decorations, bare } = wordParts(trimEnd(raw), /[ \n\t]/u);
|
|
40
|
+
return bare && (QUIET_REPLY_MARKER.startsWith(bare) || exactMarker(bare)) && !inlineReference(before, decorations)
|
|
41
|
+
? trimEnd(before)
|
|
42
|
+
: raw;
|
|
43
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ProjectInputAttachment } from './delegation.ts';
|
|
2
2
|
import { type ResourceFeedback } from './resource-feedback.ts';
|
|
3
3
|
export declare const INTERACTIVE_FEEDBACK_TRANSPORT = "peer-interactive-selection-1";
|
|
4
|
+
export declare const INPUT_ATTACHMENT_LIMIT = 100;
|
|
4
5
|
export declare function isInteractiveFeedbackAttachment(raw: unknown): boolean;
|
|
5
6
|
export declare function interactiveFeedbackAttachment(raw: unknown): ProjectInputAttachment;
|
|
6
7
|
export declare function readInteractiveFeedbackAttachment(raw: unknown): ResourceFeedback | undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { normalizeResourceFeedback, normalizeResourceFeedbackList } from "./resource-feedback.js";
|
|
2
2
|
export const INTERACTIVE_FEEDBACK_TRANSPORT = 'peer-interactive-selection-1';
|
|
3
|
+
export const INPUT_ATTACHMENT_LIMIT = 100;
|
|
3
4
|
const fail = (code) => { throw Object.assign(new TypeError(code), { code }); };
|
|
4
5
|
const bytes = (value) => new TextEncoder().encode(value).byteLength;
|
|
5
6
|
const equal = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
@@ -74,7 +75,7 @@ export function encodeResourceFeedbackTransport(rawRows, rawAttachments = []) {
|
|
|
74
75
|
if (!previous)
|
|
75
76
|
attachments.push(attachment);
|
|
76
77
|
}
|
|
77
|
-
if (attachments.length >
|
|
78
|
+
if (attachments.length > INPUT_ATTACHMENT_LIMIT)
|
|
78
79
|
return fail('RESOURCE_FEEDBACK_ATTACHMENT_LIMIT');
|
|
79
80
|
return { ...(legacy.length ? { resourceFeedback: legacy } : {}), ...(attachments.length ? { attachments } : {}) };
|
|
80
81
|
}
|
|
@@ -40,6 +40,39 @@ export interface SkillMarketplaceInstallResult {
|
|
|
40
40
|
readonly skillId?: string;
|
|
41
41
|
readonly error?: string;
|
|
42
42
|
}
|
|
43
|
+
export interface SkillInstallTarget {
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly workspaceId: string;
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly path: string;
|
|
48
|
+
readonly kind: 'bot' | 'workspace';
|
|
49
|
+
readonly available: boolean;
|
|
50
|
+
readonly unavailableReason?: string;
|
|
51
|
+
readonly isActive: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface SkillInstallTargetRequest {
|
|
54
|
+
readonly workspaceId?: string;
|
|
55
|
+
readonly workspacePath?: string;
|
|
56
|
+
}
|
|
57
|
+
export type SkillInstallTargetResult = {
|
|
58
|
+
readonly workspaceId: string | null;
|
|
59
|
+
readonly name: string;
|
|
60
|
+
readonly path: string | null;
|
|
61
|
+
} & ({
|
|
62
|
+
readonly ok: true;
|
|
63
|
+
readonly skillId: string;
|
|
64
|
+
} | {
|
|
65
|
+
readonly ok: false;
|
|
66
|
+
readonly error: string;
|
|
67
|
+
readonly code?: string;
|
|
68
|
+
});
|
|
69
|
+
export interface SkillInstallBatchReceipt {
|
|
70
|
+
readonly partial: boolean;
|
|
71
|
+
readonly succeededCount: number;
|
|
72
|
+
readonly failedCount: number;
|
|
73
|
+
readonly results: readonly SkillInstallTargetResult[];
|
|
74
|
+
}
|
|
75
|
+
export type SkillHubInstallResult = SkillMarketplaceInstallResult & Partial<SkillInstallBatchReceipt>;
|
|
43
76
|
/**
|
|
44
77
|
* SkillHub 官方列表排序(GET /api/skills?sortBy=):
|
|
45
78
|
* - score: 全部 / 综合评分
|
|
@@ -106,9 +139,10 @@ export interface SkillHubInstallRequest {
|
|
|
106
139
|
readonly namespace: string;
|
|
107
140
|
readonly slug: string;
|
|
108
141
|
readonly version: string;
|
|
109
|
-
/** 默认 global
|
|
142
|
+
/** 默认 global。工作区安装使用 targets,旧调用方可传 workspacePath。 */
|
|
110
143
|
readonly scope?: SkillHubInstallScope;
|
|
111
144
|
readonly workspacePath?: string;
|
|
145
|
+
readonly targets?: readonly SkillInstallTargetRequest[];
|
|
112
146
|
/** 市场图标 URL;安装时写入本地 _meta.json,供已安装列表展示。 */
|
|
113
147
|
readonly iconUrl?: string | null;
|
|
114
148
|
}
|
|
@@ -206,12 +240,13 @@ export interface QoderInstallIdentity {
|
|
|
206
240
|
readonly skillId: string;
|
|
207
241
|
readonly scope?: QoderInstallScope;
|
|
208
242
|
readonly workspacePath?: string;
|
|
243
|
+
readonly targets?: readonly SkillInstallTargetRequest[];
|
|
209
244
|
readonly iconUrl?: string | null;
|
|
210
245
|
}
|
|
211
|
-
export interface QoderInstallResult {
|
|
246
|
+
export interface QoderInstallResult extends Partial<SkillInstallBatchReceipt> {
|
|
212
247
|
readonly ok: boolean;
|
|
213
248
|
readonly skillId: string;
|
|
214
|
-
readonly installedSkillId
|
|
215
|
-
readonly version
|
|
249
|
+
readonly installedSkillId?: string;
|
|
250
|
+
readonly version?: string;
|
|
216
251
|
readonly scope: QoderInstallScope;
|
|
217
252
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type WorkingPlanStepStatus = 'pending' | 'in_progress' | 'completed' | 'blocked';
|
|
2
|
+
export interface WorkingPlanStepView {
|
|
3
|
+
readonly title: string;
|
|
4
|
+
readonly status: WorkingPlanStepStatus;
|
|
5
|
+
readonly check?: string;
|
|
6
|
+
readonly note?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface WorkingPlanView {
|
|
9
|
+
readonly epoch: number;
|
|
10
|
+
readonly revision: number;
|
|
11
|
+
readonly updatedAt: string;
|
|
12
|
+
readonly summary?: string;
|
|
13
|
+
readonly invariants?: readonly string[];
|
|
14
|
+
readonly completed: number;
|
|
15
|
+
readonly total: number;
|
|
16
|
+
readonly blocked: number;
|
|
17
|
+
readonly steps: readonly WorkingPlanStepView[];
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|