@peer-agent/protocol 0.1.0-rc.6 → 0.1.0-rc.7
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/project.d.ts +21 -7
- package/dist/tool-activity-preview.d.ts +4 -0
- package/dist/tool-activity-preview.js +69 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { toolActivityPreview, toolActivitySummary } from './tool-activity-preview.ts';
|
|
1
2
|
export { isModelReasoningEffort, modelReasoningLevels, modelDefaultReasoningEffort, type ModelReasoningEffort } from './model-reasoning.ts';
|
|
2
3
|
export type { SelectionRange, SelectionReference, SelectionDraft, SelectionOrigin, SelectionChildSession, SelectionChildSummary, SelectionChildrenPage, SelectionChildRead } from './selection-reference.ts';
|
|
3
4
|
export { buildModelMenuGroups, modelMenuChannelName, type ModelMenuRow } from './model-menu.ts';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { toolActivityPreview, toolActivitySummary } from "./tool-activity-preview.js";
|
|
1
2
|
export { isModelReasoningEffort, modelReasoningLevels, modelDefaultReasoningEffort } from "./model-reasoning.js";
|
|
2
3
|
export { buildModelMenuGroups, modelMenuChannelName } from "./model-menu.js";
|
|
3
4
|
export { evaluateUiDelivery } from "./ui-delivery-verification.js";
|
package/dist/project.d.ts
CHANGED
|
@@ -189,13 +189,32 @@ export interface BotListFilter {
|
|
|
189
189
|
readonly query?: string;
|
|
190
190
|
readonly needsYouOnly?: boolean;
|
|
191
191
|
}
|
|
192
|
-
/**
|
|
192
|
+
/** Bounded, redacted display preview; never an execution or Evidence object. */
|
|
193
|
+
export interface ProjectAgentToolPreview {
|
|
194
|
+
readonly text: string;
|
|
195
|
+
readonly truncated: boolean;
|
|
196
|
+
readonly redacted: boolean;
|
|
197
|
+
}
|
|
198
|
+
export interface ProjectAgentToolActivity {
|
|
199
|
+
readonly kind: 'tool';
|
|
200
|
+
readonly id: string;
|
|
201
|
+
readonly name: string;
|
|
202
|
+
readonly status: 'preparing' | 'running' | 'done' | 'error' | 'stopped';
|
|
203
|
+
readonly startedAt?: string;
|
|
204
|
+
readonly finishedAt?: string;
|
|
205
|
+
readonly summary?: string;
|
|
206
|
+
readonly input?: ProjectAgentToolPreview;
|
|
207
|
+
readonly result?: ProjectAgentToolPreview;
|
|
208
|
+
readonly receivedChars?: number;
|
|
209
|
+
}
|
|
210
|
+
/** Ephemeral user-turn presentation. No hidden reasoning or Evidence. */
|
|
193
211
|
export interface ProjectAgentActivity {
|
|
194
212
|
readonly workspaceId: string;
|
|
195
213
|
readonly conversationId: string;
|
|
196
214
|
readonly turnId: string;
|
|
197
215
|
readonly revision: number;
|
|
198
216
|
readonly startedAt: string;
|
|
217
|
+
readonly finishedAt?: string;
|
|
199
218
|
readonly modelSelection?: Pick<import('./model-routing.ts').RuntimeModelSelection, 'modelProviderId' | 'reasoningEffort'>;
|
|
200
219
|
readonly replyTo: readonly string[];
|
|
201
220
|
readonly phase: 'waiting' | 'thinking' | 'responding' | 'tool' | 'settling' | 'done' | 'error' | 'stopped' | 'disposed';
|
|
@@ -204,12 +223,7 @@ export interface ProjectAgentActivity {
|
|
|
204
223
|
readonly kind: 'text';
|
|
205
224
|
readonly id: string;
|
|
206
225
|
readonly text: string;
|
|
207
|
-
} |
|
|
208
|
-
readonly kind: 'tool';
|
|
209
|
-
readonly id: string;
|
|
210
|
-
readonly name: string;
|
|
211
|
-
readonly status: 'running' | 'done' | 'error';
|
|
212
|
-
})[];
|
|
226
|
+
} | ProjectAgentToolActivity)[];
|
|
213
227
|
}
|
|
214
228
|
export interface ProjectAgentStopResponseRequest {
|
|
215
229
|
readonly workspaceId: string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ProjectAgentToolPreview } from './project.ts';
|
|
2
|
+
/** One bounded display seam for tool parameters/results in live and historical presentation. It never executes a tool. */
|
|
3
|
+
export declare function toolActivityPreview(value: unknown, limit: number): ProjectAgentToolPreview;
|
|
4
|
+
export declare function toolActivitySummary(input: Readonly<Record<string, unknown>> | null | undefined): string;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const PRIVATE_FIELD = /(?:api.?key|token|secret|password|credential|authorization|cookie|private.?key|reasoning|thinking)/i;
|
|
2
|
+
/** One bounded display seam for tool parameters/results in live and historical presentation. It never executes a tool. */
|
|
3
|
+
export function toolActivityPreview(value, limit) {
|
|
4
|
+
if (typeof value === 'string' && value.length > 64_000)
|
|
5
|
+
return { text: '', truncated: true, redacted: true };
|
|
6
|
+
let redacted = false, truncated = false, nodes = 0;
|
|
7
|
+
const cleanText = (text) => {
|
|
8
|
+
const bounded = text.slice(0, 6000);
|
|
9
|
+
if (bounded.length < text.length)
|
|
10
|
+
truncated = true;
|
|
11
|
+
const clean = bounded
|
|
12
|
+
.replace(/\b(?:sk|pk|rk)-[A-Za-z0-9_-]{8,}/g, '[redacted]')
|
|
13
|
+
.replace(/AKIA[0-9A-Z]{16}/g, '[redacted]')
|
|
14
|
+
.replace(/\bBearer\s+[A-Za-z0-9._~+/-]+=*/gi, 'Bearer [redacted]')
|
|
15
|
+
.replace(/((?:api[_-]?key|token|secret|password|authorization|cookie)\s*["']?\s*[:=]\s*["']?)[^\s,"';}]+/gi, '$1[redacted]')
|
|
16
|
+
.replace(/-----BEGIN [^-]*PRIVATE KEY-----[\s\S]*/g, '[redacted]');
|
|
17
|
+
if (clean !== bounded)
|
|
18
|
+
redacted = true;
|
|
19
|
+
return clean;
|
|
20
|
+
};
|
|
21
|
+
const visit = (item, depth = 0) => {
|
|
22
|
+
if (++nodes > 160 || depth > 6) {
|
|
23
|
+
truncated = true;
|
|
24
|
+
return '[truncated]';
|
|
25
|
+
}
|
|
26
|
+
if (typeof item === 'string')
|
|
27
|
+
return cleanText(item);
|
|
28
|
+
if (item == null || typeof item === 'boolean' || typeof item === 'number')
|
|
29
|
+
return item;
|
|
30
|
+
if (Array.isArray(item)) {
|
|
31
|
+
if (item.length > 40)
|
|
32
|
+
truncated = true;
|
|
33
|
+
return item.slice(0, 40).map(child => visit(child, depth + 1));
|
|
34
|
+
}
|
|
35
|
+
if (typeof item === 'object') {
|
|
36
|
+
const fields = [];
|
|
37
|
+
for (const key in item) {
|
|
38
|
+
if (!Object.hasOwn(item, key))
|
|
39
|
+
continue;
|
|
40
|
+
if (fields.length >= 40) {
|
|
41
|
+
truncated = true;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
if (PRIVATE_FIELD.test(key)) {
|
|
45
|
+
redacted = true;
|
|
46
|
+
fields.push([key, '[redacted]']);
|
|
47
|
+
}
|
|
48
|
+
else
|
|
49
|
+
fields.push([cleanText(key), visit(item[key], depth + 1)]);
|
|
50
|
+
}
|
|
51
|
+
return Object.fromEntries(fields);
|
|
52
|
+
}
|
|
53
|
+
return String(item);
|
|
54
|
+
};
|
|
55
|
+
let parsed = value;
|
|
56
|
+
if (typeof value === 'string') {
|
|
57
|
+
try {
|
|
58
|
+
parsed = JSON.parse(value);
|
|
59
|
+
}
|
|
60
|
+
catch { /* Plain terminal/file output. */ }
|
|
61
|
+
}
|
|
62
|
+
const clean = visit(parsed);
|
|
63
|
+
const text = typeof clean === 'string' ? clean : JSON.stringify(clean ?? null, null, 2);
|
|
64
|
+
return { text: text.slice(0, limit), truncated: truncated || text.length > limit, redacted };
|
|
65
|
+
}
|
|
66
|
+
export function toolActivitySummary(input) {
|
|
67
|
+
const value = input?.path ?? input?.command ?? input?.cmd ?? input?.query ?? input?.title;
|
|
68
|
+
return typeof value === 'string' ? toolActivityPreview(value.replace(/\s+/g, ' ').trim(), 160).text : '';
|
|
69
|
+
}
|