@peer-agent/protocol 0.1.0-rc.5 → 0.1.0-rc.6
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 +17 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/model-reasoning.d.ts +13 -0
- package/dist/model-reasoning.js +18 -0
- package/dist/model-routing.d.ts +18 -1
- package/dist/model-routing.js +10 -5
- package/dist/project.d.ts +32 -0
- package/package.json +1 -1
package/dist/delegation.d.ts
CHANGED
|
@@ -200,6 +200,22 @@ export interface SurfacingEvent {
|
|
|
200
200
|
readonly severity: 'info' | 'notable' | 'urgent';
|
|
201
201
|
readonly deadlineImminent?: boolean;
|
|
202
202
|
}
|
|
203
|
+
/** Explicit user uploads are factual user context, never execution authority. */
|
|
204
|
+
export type ProjectInputAttachment = {
|
|
205
|
+
readonly id: string;
|
|
206
|
+
readonly name: string;
|
|
207
|
+
readonly mimeType: string;
|
|
208
|
+
readonly size: number;
|
|
209
|
+
readonly sourceKind: 'user_upload';
|
|
210
|
+
} & ({
|
|
211
|
+
readonly kind: 'image';
|
|
212
|
+
readonly dataUrl: string;
|
|
213
|
+
} | {
|
|
214
|
+
readonly kind: 'text';
|
|
215
|
+
readonly text: string;
|
|
216
|
+
} | {
|
|
217
|
+
readonly kind: 'unsupported';
|
|
218
|
+
});
|
|
203
219
|
export interface ProjectInput {
|
|
204
220
|
readonly inputId: string;
|
|
205
221
|
readonly workspaceId: string;
|
|
@@ -208,6 +224,7 @@ export interface ProjectInput {
|
|
|
208
224
|
readonly anchorRefs: readonly string[];
|
|
209
225
|
readonly quoteRefs: readonly string[];
|
|
210
226
|
readonly attachmentRefs: readonly string[];
|
|
227
|
+
readonly attachments?: readonly ProjectInputAttachment[];
|
|
211
228
|
readonly createdAt: string;
|
|
212
229
|
}
|
|
213
230
|
export type PendingApprovalState = 'open' | 'approved' | 'denied' | 'expired' | 'stale';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { isModelReasoningEffort, modelReasoningLevels, modelDefaultReasoningEffort, type ModelReasoningEffort } from './model-reasoning.ts';
|
|
1
2
|
export type { SelectionRange, SelectionReference, SelectionDraft, SelectionOrigin, SelectionChildSession, SelectionChildSummary, SelectionChildrenPage, SelectionChildRead } from './selection-reference.ts';
|
|
2
3
|
export { buildModelMenuGroups, modelMenuChannelName, type ModelMenuRow } from './model-menu.ts';
|
|
3
4
|
export { evaluateUiDelivery } from './ui-delivery-verification.ts';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { isModelReasoningEffort, modelReasoningLevels, modelDefaultReasoningEffort } from "./model-reasoning.js";
|
|
1
2
|
export { buildModelMenuGroups, modelMenuChannelName } from "./model-menu.js";
|
|
2
3
|
export { evaluateUiDelivery } from "./ui-delivery-verification.js";
|
|
3
4
|
export { DESKTOP_PREVIEW_PROTOCOL, DESKTOP_PREVIEW_CAPABILITY, DESKTOP_PREVIEW_TOOL } from "./desktop-preview.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Provider-declared effort values. Unknown capabilities do not create UI choices. */
|
|
2
|
+
export type ModelReasoningEffort = 'off' | 'low' | 'medium' | 'default' | 'high' | 'xhigh' | 'max';
|
|
3
|
+
export declare function isModelReasoningEffort(value: unknown): value is ModelReasoningEffort;
|
|
4
|
+
export declare function modelReasoningLevels(provider: {
|
|
5
|
+
readonly supportsReasoning?: unknown;
|
|
6
|
+
readonly reasoningEffortLevels?: unknown;
|
|
7
|
+
}): readonly ModelReasoningEffort[];
|
|
8
|
+
export declare function modelDefaultReasoningEffort(provider: {
|
|
9
|
+
readonly supportsReasoning?: unknown;
|
|
10
|
+
readonly reasoningEffortLevels?: unknown;
|
|
11
|
+
readonly reasoningEffort?: unknown;
|
|
12
|
+
readonly defaultEffort?: unknown;
|
|
13
|
+
}): ModelReasoningEffort | undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const ORDER = ['off', 'low', 'medium', 'default', 'high', 'xhigh', 'max'];
|
|
2
|
+
export function isModelReasoningEffort(value) {
|
|
3
|
+
return ORDER.includes(value);
|
|
4
|
+
}
|
|
5
|
+
export function modelReasoningLevels(provider) {
|
|
6
|
+
if (provider.supportsReasoning === false || !Array.isArray(provider.reasoningEffortLevels))
|
|
7
|
+
return [];
|
|
8
|
+
const declared = provider.reasoningEffortLevels;
|
|
9
|
+
return ORDER.filter(value => declared.includes(value));
|
|
10
|
+
}
|
|
11
|
+
export function modelDefaultReasoningEffort(provider) {
|
|
12
|
+
const levels = modelReasoningLevels(provider);
|
|
13
|
+
for (const value of [provider.reasoningEffort, provider.defaultEffort, 'default', 'medium', 'high', 'low', ...levels]) {
|
|
14
|
+
if (isModelReasoningEffort(value) && levels.includes(value))
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
package/dist/model-routing.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ModelReasoningEffort } from './model-reasoning.ts';
|
|
1
2
|
/**
|
|
2
3
|
* Role and tier model routing. Resolution is pure; hosts apply the result.
|
|
3
4
|
* Order and filters follow ADR 83. An empty candidate set is an error, not a silent downgrade.
|
|
@@ -10,6 +11,7 @@ export type RoleSetting = {
|
|
|
10
11
|
} | {
|
|
11
12
|
readonly mode: 'fixed';
|
|
12
13
|
readonly modelProviderId: string;
|
|
14
|
+
readonly reasoningEffort?: ModelReasoningEffort;
|
|
13
15
|
} | {
|
|
14
16
|
readonly mode: 'auto';
|
|
15
17
|
readonly pool: readonly string[];
|
|
@@ -65,7 +67,15 @@ export interface ModelRoutingMenuOption {
|
|
|
65
67
|
readonly supportsTools: boolean;
|
|
66
68
|
readonly supportsStructured: boolean;
|
|
67
69
|
readonly contextTokens: number;
|
|
70
|
+
readonly available?: boolean;
|
|
71
|
+
readonly reasoningEffortLevels?: readonly ModelReasoningEffort[];
|
|
72
|
+
readonly defaultReasoningEffort?: ModelReasoningEffort;
|
|
68
73
|
}
|
|
74
|
+
export interface BotRoleModelView {
|
|
75
|
+
readonly resolution: ModelResolution;
|
|
76
|
+
readonly eligibleModelIds: readonly string[];
|
|
77
|
+
}
|
|
78
|
+
export type BotModelViews = Partial<Record<ModelRole, BotRoleModelView>>;
|
|
69
79
|
/** Project one configured provider into the routing menu contract. */
|
|
70
80
|
export declare function projectModelRoutingMenuOption(provider: {
|
|
71
81
|
readonly id?: unknown;
|
|
@@ -81,6 +91,12 @@ export declare function projectModelRoutingMenuOption(provider: {
|
|
|
81
91
|
readonly toolUse?: unknown;
|
|
82
92
|
} | null;
|
|
83
93
|
readonly contextWindow?: unknown;
|
|
94
|
+
readonly apiKeyConfigured?: unknown;
|
|
95
|
+
readonly enabled?: unknown;
|
|
96
|
+
readonly supportsReasoning?: unknown;
|
|
97
|
+
readonly reasoningEffortLevels?: unknown;
|
|
98
|
+
readonly reasoningEffort?: unknown;
|
|
99
|
+
readonly defaultEffort?: unknown;
|
|
84
100
|
} | null | undefined): ModelRoutingMenuOption | null;
|
|
85
101
|
export interface CatalogModel {
|
|
86
102
|
readonly modelProviderId: string;
|
|
@@ -93,6 +109,7 @@ export interface CatalogModel {
|
|
|
93
109
|
readonly contextTokens?: number;
|
|
94
110
|
readonly local?: boolean;
|
|
95
111
|
readonly reasoningEffort?: string;
|
|
112
|
+
readonly reasoningEffortLevels?: readonly ModelReasoningEffort[];
|
|
96
113
|
}
|
|
97
114
|
export type ModelResolution = {
|
|
98
115
|
readonly ok: true;
|
|
@@ -101,7 +118,7 @@ export type ModelResolution = {
|
|
|
101
118
|
readonly sameFamilyAsWorker?: boolean;
|
|
102
119
|
} | {
|
|
103
120
|
readonly ok: false;
|
|
104
|
-
readonly reason: 'capability' | 'scope' | 'auto_pool' | 'empty';
|
|
121
|
+
readonly reason: 'capability' | 'scope' | 'auto_pool' | 'empty' | 'reasoning';
|
|
105
122
|
readonly missing: string;
|
|
106
123
|
};
|
|
107
124
|
export interface RoleModelRequest {
|
package/dist/model-routing.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Role and tier model routing. Resolution is pure; hosts apply the result.
|
|
3
|
-
* Order and filters follow ADR 83. An empty candidate set is an error, not a silent downgrade.
|
|
4
|
-
*/
|
|
1
|
+
import { modelDefaultReasoningEffort, modelReasoningLevels } from "./model-reasoning.js";
|
|
5
2
|
/** Project one configured provider into the routing menu contract. */
|
|
6
3
|
export function projectModelRoutingMenuOption(provider) {
|
|
7
4
|
if (!provider || typeof provider.id !== 'string' || !provider.id.trim())
|
|
@@ -24,6 +21,9 @@ export function projectModelRoutingMenuOption(provider) {
|
|
|
24
21
|
supportsTools: provider.supportsTools !== false && provider.capabilities?.toolUse !== false,
|
|
25
22
|
supportsStructured: provider.supportsStructured !== false,
|
|
26
23
|
contextTokens: Number.isFinite(context) && context > 0 ? context : 128_000,
|
|
24
|
+
available: provider.enabled !== false && provider.apiKeyConfigured === true,
|
|
25
|
+
reasoningEffortLevels: modelReasoningLevels(provider),
|
|
26
|
+
defaultReasoningEffort: modelDefaultReasoningEffort(provider),
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
const EXPLORER_MIN_CONTEXT = 8_000;
|
|
@@ -75,6 +75,8 @@ function inScope(model, policy) {
|
|
|
75
75
|
return true;
|
|
76
76
|
}
|
|
77
77
|
function missingText(input, reason) {
|
|
78
|
+
if (reason === 'reasoning')
|
|
79
|
+
return '所选模型不支持该推理强度';
|
|
78
80
|
if (reason === 'auto_pool')
|
|
79
81
|
return '所选模型不在自动池内';
|
|
80
82
|
const localOnly = input.projectPolicy?.scope?.localOnly === true;
|
|
@@ -226,10 +228,13 @@ export function resolveRoleModel(input) {
|
|
|
226
228
|
const chosen = ordered[0];
|
|
227
229
|
if (!chosen)
|
|
228
230
|
return fail(input, 'empty');
|
|
231
|
+
const requestedEffort = layer.setting.mode === 'fixed' ? layer.setting.reasoningEffort : undefined;
|
|
232
|
+
if (requestedEffort !== undefined && !chosen.reasoningEffortLevels?.includes(requestedEffort))
|
|
233
|
+
return fail(input, 'reasoning');
|
|
229
234
|
const source = layer.setting.mode === 'auto' ? 'auto' : layer.source;
|
|
230
235
|
return {
|
|
231
236
|
ok: true,
|
|
232
|
-
selection: toSelection(chosen),
|
|
237
|
+
selection: { ...toSelection(chosen), ...(requestedEffort !== undefined ? { reasoningEffort: requestedEffort } : {}) },
|
|
233
238
|
source,
|
|
234
239
|
...(input.role === 'verifier'
|
|
235
240
|
? { sameFamilyAsWorker: sameFamily(chosen, input.workerModel) }
|
package/dist/project.d.ts
CHANGED
|
@@ -189,6 +189,38 @@ export interface BotListFilter {
|
|
|
189
189
|
readonly query?: string;
|
|
190
190
|
readonly needsYouOnly?: boolean;
|
|
191
191
|
}
|
|
192
|
+
/** Ephemeral user-turn presentation. No tool arguments, reasoning or Evidence. */
|
|
193
|
+
export interface ProjectAgentActivity {
|
|
194
|
+
readonly workspaceId: string;
|
|
195
|
+
readonly conversationId: string;
|
|
196
|
+
readonly turnId: string;
|
|
197
|
+
readonly revision: number;
|
|
198
|
+
readonly startedAt: string;
|
|
199
|
+
readonly modelSelection?: Pick<import('./model-routing.ts').RuntimeModelSelection, 'modelProviderId' | 'reasoningEffort'>;
|
|
200
|
+
readonly replyTo: readonly string[];
|
|
201
|
+
readonly phase: 'waiting' | 'thinking' | 'responding' | 'tool' | 'settling' | 'done' | 'error' | 'stopped' | 'disposed';
|
|
202
|
+
readonly replyText: string;
|
|
203
|
+
readonly segments: readonly ({
|
|
204
|
+
readonly kind: 'text';
|
|
205
|
+
readonly id: string;
|
|
206
|
+
readonly text: string;
|
|
207
|
+
} | {
|
|
208
|
+
readonly kind: 'tool';
|
|
209
|
+
readonly id: string;
|
|
210
|
+
readonly name: string;
|
|
211
|
+
readonly status: 'running' | 'done' | 'error';
|
|
212
|
+
})[];
|
|
213
|
+
}
|
|
214
|
+
export interface ProjectAgentStopResponseRequest {
|
|
215
|
+
readonly workspaceId: string;
|
|
216
|
+
readonly turnId: string;
|
|
217
|
+
}
|
|
218
|
+
export type ProjectAgentStopResponseResult = {
|
|
219
|
+
readonly ok: true;
|
|
220
|
+
} | {
|
|
221
|
+
readonly ok: false;
|
|
222
|
+
readonly code: 'PROJECT_AGENT_DISABLED' | 'NOT_FOUND' | 'HOST_OFFLINE' | 'STALE_TURN' | 'INVALID_INPUT';
|
|
223
|
+
};
|
|
192
224
|
export interface BotListSession {
|
|
193
225
|
readonly status: WorkSessionStatus;
|
|
194
226
|
readonly updatedAt?: string;
|