@tonyclaw/agent-inspector 3.0.30 → 3.0.32
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/.output/nitro.json +1 -1
- package/.output/public/assets/{CompareDrawer-B6cXJohL.js → CompareDrawer-CONqySRK.js} +1 -1
- package/.output/public/assets/{InspectorPet-mAzeGmEE.js → InspectorPet-B6oMiG2V.js} +1 -1
- package/.output/public/assets/ProxyViewerContainer-Ce_WtVu2.js +126 -0
- package/.output/public/assets/{ReplayDialog-DodiTL6E.js → ReplayDialog-BauSX4Hj.js} +1 -1
- package/.output/public/assets/{RequestAnatomy-B3IauToI.js → RequestAnatomy-gyMOB2oK.js} +1 -1
- package/.output/public/assets/ResponseView-CUQvY1eb.js +2 -0
- package/.output/public/assets/{StreamingChunkSequence-vLDOVQM_.js → StreamingChunkSequence-CE6R5CKU.js} +1 -1
- package/.output/public/assets/{_sessionId-BFH4TOaI.js → _sessionId-BW1YYf5W.js} +1 -1
- package/.output/public/assets/{_sessionId-Cj_HIFZx.js → _sessionId-DRRig28i.js} +1 -1
- package/.output/public/assets/{index-DkDdKvLl.js → index-BTor51ZC.js} +3 -3
- package/.output/public/assets/{index-Ch7uqnCT.js → index-BzL-q9eN.js} +1 -1
- package/.output/public/assets/{index-Bmj2lcWE.js → index-CbFGlzA-.js} +1 -1
- package/.output/public/assets/index-D17dU-mX.css +1 -0
- package/.output/public/assets/{index-ZlhqCrSg.js → index-iN9QtGKF.js} +1 -1
- package/.output/public/assets/{json-viewer-BdrnVQu-.js → json-viewer-cR8mD7Tl.js} +1 -1
- package/.output/public/assets/{jszip.min-CS_nt_o1.js → jszip.min-aHTREmPV.js} +1 -1
- package/.output/server/_libs/lucide-react.mjs +55 -55
- package/.output/server/{_sessionId-C5S3pGZd.mjs → _sessionId-CuTfM9Wy.mjs} +2 -2
- package/.output/server/{_sessionId-g6D69lKq.mjs → _sessionId-RGCARWul.mjs} +1 -1
- package/.output/server/_ssr/{CompareDrawer-CqUmGHal.mjs → CompareDrawer-mUnxKFwp.mjs} +3 -3
- package/.output/server/_ssr/{InspectorPet-DI0UJd01.mjs → InspectorPet-J0mv5NOp.mjs} +1 -1
- package/.output/server/_ssr/{ProxyViewerContainer-CvsUmbJ3.mjs → ProxyViewerContainer-C7Wx7SjJ.mjs} +457 -47
- package/.output/server/_ssr/{ReplayDialog-DS48dpFG.mjs → ReplayDialog-C_zNrriu.mjs} +4 -4
- package/.output/server/_ssr/{RequestAnatomy-DxYVQU1C.mjs → RequestAnatomy-lvR2Uz9j.mjs} +3 -3
- package/.output/server/_ssr/{ResponseView-BLXW73eq.mjs → ResponseView-CRcqekgn.mjs} +3 -14
- package/.output/server/_ssr/{StreamingChunkSequence-DD0iFuy0.mjs → StreamingChunkSequence-CJLR-ZYV.mjs} +3 -3
- package/.output/server/_ssr/{index-RHVJnU2p.mjs → index-BhL5Yn1J.mjs} +1 -1
- package/.output/server/_ssr/{index-B10LIaK0.mjs → index-urTy0DU2.mjs} +2 -2
- package/.output/server/_ssr/index.mjs +2 -2
- package/.output/server/_ssr/{json-viewer-LDu2XBaK.mjs → json-viewer-BcooIEu5.mjs} +3 -3
- package/.output/server/_ssr/{router-GKvrwifJ.mjs → router-D-PJYphE.mjs} +5382 -4524
- package/.output/server/{_tanstack-start-manifest_v-Df2n4mbT.mjs → _tanstack-start-manifest_v-DhxDbp_1.mjs} +1 -1
- package/.output/server/index.mjs +92 -92
- package/package.json +1 -1
- package/src/components/pi-agent/PiAgentPanel.tsx +229 -34
- package/src/components/pi-agent/piAgentChatLogic.ts +287 -0
- package/src/components/ui/transient-toast.tsx +6 -5
- package/src/lib/piAgentContract.ts +80 -0
- package/src/services/piAgent.ts +131 -102
- package/src/services/piAgentRetrieval.ts +1180 -0
- package/.output/public/assets/ProxyViewerContainer-CkFWv_Nm.js +0 -126
- package/.output/public/assets/ResponseView-Hn-5ordK.js +0 -3
- package/.output/public/assets/index-CgJj-HBC.css +0 -1
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { safeGetOwnProperty } from "../../lib/objectUtils";
|
|
2
|
+
|
|
3
|
+
export type PiAgentChatRole = "user" | "assistant";
|
|
4
|
+
|
|
5
|
+
export type PiAgentHistoryMessage = {
|
|
6
|
+
role: PiAgentChatRole;
|
|
7
|
+
content: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type PiAgentEvidenceView = {
|
|
11
|
+
source: string;
|
|
12
|
+
id: string;
|
|
13
|
+
logId: number | null;
|
|
14
|
+
sessionId: string | null;
|
|
15
|
+
timestamp: string | null;
|
|
16
|
+
model: string | null;
|
|
17
|
+
providerName: string | null;
|
|
18
|
+
path: string | null;
|
|
19
|
+
status: string | number | null;
|
|
20
|
+
elapsedMs: number | null;
|
|
21
|
+
inputTokens: number | null;
|
|
22
|
+
outputTokens: number | null;
|
|
23
|
+
totalTokens: number | null;
|
|
24
|
+
score: number | null;
|
|
25
|
+
matchedFields: string[];
|
|
26
|
+
excerpt: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type PiAgentMetricView = {
|
|
30
|
+
key: string;
|
|
31
|
+
label: string;
|
|
32
|
+
value: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type PiAgentResponseView = {
|
|
36
|
+
answer: string;
|
|
37
|
+
providerId: string;
|
|
38
|
+
providerName: string;
|
|
39
|
+
model: string;
|
|
40
|
+
protocol: string;
|
|
41
|
+
logCount: number;
|
|
42
|
+
evidence: PiAgentEvidenceView[];
|
|
43
|
+
summaryMetrics: PiAgentMetricView[];
|
|
44
|
+
queryMetrics: PiAgentMetricView[];
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type PiAgentConversationMessage = PiAgentHistoryMessage & {
|
|
48
|
+
id: string;
|
|
49
|
+
response: PiAgentResponseView | null;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type PiAgentConversationState = {
|
|
53
|
+
messages: PiAgentConversationMessage[];
|
|
54
|
+
question: string;
|
|
55
|
+
error: string | null;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type PiAgentStarter = {
|
|
59
|
+
id: "reliability" | "performance" | "tokens" | "providers" | "tools";
|
|
60
|
+
label: string;
|
|
61
|
+
question: string;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type PiAgentScopePill = {
|
|
65
|
+
id: "saved-data" | "root-cause" | "evidence";
|
|
66
|
+
label: string;
|
|
67
|
+
description: string;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const PI_AGENT_SCOPE_PILLS: readonly PiAgentScopePill[] = [
|
|
71
|
+
{
|
|
72
|
+
id: "saved-data",
|
|
73
|
+
label: "Saved Inspector data",
|
|
74
|
+
description: "requests, responses, sessions, tools, alerts, runs, groups, and knowledge",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: "root-cause",
|
|
78
|
+
label: "Root-cause hints",
|
|
79
|
+
description: "failures, hangs, slow paths, token spikes, and provider drift",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
id: "evidence",
|
|
83
|
+
label: "Evidence links",
|
|
84
|
+
description: "matched logs and metrics you can jump back into",
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
export const PI_AGENT_STARTERS: readonly PiAgentStarter[] = [
|
|
89
|
+
{
|
|
90
|
+
id: "reliability",
|
|
91
|
+
label: "Reliability",
|
|
92
|
+
question: "Which requests failed, stalled, or look most likely to hang, and why?",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: "performance",
|
|
96
|
+
label: "Performance",
|
|
97
|
+
question: "Summarize latency and identify the slowest requests with supporting evidence.",
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: "tokens",
|
|
101
|
+
label: "Token usage",
|
|
102
|
+
question: "Where are tokens being spent, and which requests have unusually high usage?",
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: "providers",
|
|
106
|
+
label: "Providers",
|
|
107
|
+
question: "Compare Provider and model reliability, latency, and token usage in this scope.",
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: "tools",
|
|
111
|
+
label: "Tool activity",
|
|
112
|
+
question: "Which tools were used most, and where did tool calls fail or produce warnings?",
|
|
113
|
+
},
|
|
114
|
+
];
|
|
115
|
+
|
|
116
|
+
const MAX_HISTORY_MESSAGES = 10;
|
|
117
|
+
const MAX_HISTORY_CONTENT_CHARS = 4_000;
|
|
118
|
+
const MAX_METRICS = 12;
|
|
119
|
+
|
|
120
|
+
export function createEmptyPiAgentConversation(): PiAgentConversationState {
|
|
121
|
+
return { messages: [], question: "", error: null };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function buildPiAgentHistory(
|
|
125
|
+
messages: readonly PiAgentConversationMessage[],
|
|
126
|
+
): PiAgentHistoryMessage[] {
|
|
127
|
+
return messages
|
|
128
|
+
.filter((message) => message.content.trim().length > 0)
|
|
129
|
+
.slice(-MAX_HISTORY_MESSAGES)
|
|
130
|
+
.map((message) => ({
|
|
131
|
+
role: message.role,
|
|
132
|
+
content: message.content.trim().slice(0, MAX_HISTORY_CONTENT_CHARS),
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function readString(value: unknown, ...keys: string[]): string | null {
|
|
137
|
+
for (const key of keys) {
|
|
138
|
+
const candidate = safeGetOwnProperty(value, key);
|
|
139
|
+
if (typeof candidate === "string" && candidate.trim().length > 0) return candidate;
|
|
140
|
+
}
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function readNumber(value: unknown, ...keys: string[]): number | null {
|
|
145
|
+
for (const key of keys) {
|
|
146
|
+
const candidate = safeGetOwnProperty(value, key);
|
|
147
|
+
if (typeof candidate === "number" && Number.isFinite(candidate)) return candidate;
|
|
148
|
+
}
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function readStringArray(value: unknown, key: string): string[] {
|
|
153
|
+
const candidate = safeGetOwnProperty(value, key);
|
|
154
|
+
if (!Array.isArray(candidate)) return [];
|
|
155
|
+
return candidate.filter((item): item is string => typeof item === "string").slice(0, 8);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function evidenceView(value: unknown): PiAgentEvidenceView | null {
|
|
159
|
+
const source = readString(value, "source") ?? "log";
|
|
160
|
+
const id = readString(value, "id") ?? "";
|
|
161
|
+
const logId = readNumber(value, "logId", "id");
|
|
162
|
+
if (id === "" && logId === null) return null;
|
|
163
|
+
if (logId !== null && (!Number.isInteger(logId) || logId < 0)) return null;
|
|
164
|
+
const inputTokens = readNumber(value, "inputTokens");
|
|
165
|
+
const outputTokens = readNumber(value, "outputTokens");
|
|
166
|
+
const explicitTotal = readNumber(value, "totalTokens", "tokenCount");
|
|
167
|
+
const statusNumber = readNumber(value, "responseStatus", "status");
|
|
168
|
+
const statusString = readString(value, "responseStatus", "status");
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
source,
|
|
172
|
+
id: id !== "" ? id : String(logId),
|
|
173
|
+
logId,
|
|
174
|
+
sessionId: readString(value, "sessionId"),
|
|
175
|
+
timestamp: readString(value, "timestamp"),
|
|
176
|
+
model: readString(value, "model"),
|
|
177
|
+
providerName: readString(value, "providerName", "provider"),
|
|
178
|
+
path: readString(value, "path"),
|
|
179
|
+
status: statusNumber ?? statusString,
|
|
180
|
+
elapsedMs: readNumber(value, "elapsedMs", "latencyMs"),
|
|
181
|
+
inputTokens,
|
|
182
|
+
outputTokens,
|
|
183
|
+
totalTokens:
|
|
184
|
+
explicitTotal ??
|
|
185
|
+
(inputTokens === null && outputTokens === null
|
|
186
|
+
? null
|
|
187
|
+
: (inputTokens ?? 0) + (outputTokens ?? 0)),
|
|
188
|
+
score: readNumber(value, "score", "relevanceScore"),
|
|
189
|
+
matchedFields: readStringArray(value, "matchedFields"),
|
|
190
|
+
excerpt: readString(value, "excerpt", "snippet") ?? "No excerpt available.",
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function humanizeMetricKey(key: string): string {
|
|
195
|
+
const spaced = key
|
|
196
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
197
|
+
.replace(/[_-]+/g, " ")
|
|
198
|
+
.trim();
|
|
199
|
+
return spaced.length === 0 ? "Metric" : `${spaced[0]?.toUpperCase() ?? ""}${spaced.slice(1)}`;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function metricValue(value: unknown): string | null {
|
|
203
|
+
if (typeof value === "number" && Number.isFinite(value)) return value.toLocaleString();
|
|
204
|
+
if (typeof value === "string" && value.trim().length > 0) return value;
|
|
205
|
+
if (typeof value === "boolean") return value ? "Yes" : "No";
|
|
206
|
+
if (Array.isArray(value)) {
|
|
207
|
+
const items = value
|
|
208
|
+
.filter(
|
|
209
|
+
(item): item is string | number =>
|
|
210
|
+
typeof item === "string" || (typeof item === "number" && Number.isFinite(item)),
|
|
211
|
+
)
|
|
212
|
+
.slice(0, 6);
|
|
213
|
+
return items.length > 0 ? items.join(", ") : null;
|
|
214
|
+
}
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function objectMetricEntries(value: object): [string, unknown][] {
|
|
219
|
+
return Object.getOwnPropertyNames(value).map((key) => [key, safeGetOwnProperty(value, key)]);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export function metricViews(value: unknown): PiAgentMetricView[] {
|
|
223
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return [];
|
|
224
|
+
const entries: PiAgentMetricView[] = [];
|
|
225
|
+
|
|
226
|
+
for (const [key, rawValue] of objectMetricEntries(value)) {
|
|
227
|
+
const directValue = metricValue(rawValue);
|
|
228
|
+
if (directValue !== null) {
|
|
229
|
+
entries.push({ key, label: humanizeMetricKey(key), value: directValue });
|
|
230
|
+
if (entries.length >= MAX_METRICS) break;
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
if (rawValue === null || typeof rawValue !== "object" || Array.isArray(rawValue)) continue;
|
|
234
|
+
for (const [nestedKey, nestedValue] of objectMetricEntries(rawValue)) {
|
|
235
|
+
const formatted = metricValue(nestedValue);
|
|
236
|
+
if (formatted === null) continue;
|
|
237
|
+
const metricKey = `${key}.${nestedKey}`;
|
|
238
|
+
entries.push({
|
|
239
|
+
key: metricKey,
|
|
240
|
+
label: `${humanizeMetricKey(key)} ${humanizeMetricKey(nestedKey).toLowerCase()}`,
|
|
241
|
+
value: formatted,
|
|
242
|
+
});
|
|
243
|
+
if (entries.length >= MAX_METRICS) break;
|
|
244
|
+
}
|
|
245
|
+
if (entries.length >= MAX_METRICS) break;
|
|
246
|
+
}
|
|
247
|
+
return entries;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export function normalizePiAgentResponse(value: unknown): PiAgentResponseView | null {
|
|
251
|
+
const answer = readString(value, "answer");
|
|
252
|
+
const providerId = readString(value, "providerId");
|
|
253
|
+
const providerName = readString(value, "providerName");
|
|
254
|
+
const model = readString(value, "model");
|
|
255
|
+
const protocol = readString(value, "protocol");
|
|
256
|
+
const logCount = readNumber(value, "logCount");
|
|
257
|
+
if (
|
|
258
|
+
answer === null ||
|
|
259
|
+
providerId === null ||
|
|
260
|
+
providerName === null ||
|
|
261
|
+
model === null ||
|
|
262
|
+
protocol === null ||
|
|
263
|
+
logCount === null
|
|
264
|
+
) {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const rawEvidence = safeGetOwnProperty(value, "evidence");
|
|
269
|
+
const evidence = Array.isArray(rawEvidence)
|
|
270
|
+
? rawEvidence
|
|
271
|
+
.map(evidenceView)
|
|
272
|
+
.filter((item): item is PiAgentEvidenceView => item !== null)
|
|
273
|
+
.slice(0, 12)
|
|
274
|
+
: [];
|
|
275
|
+
|
|
276
|
+
return {
|
|
277
|
+
answer,
|
|
278
|
+
providerId,
|
|
279
|
+
providerName,
|
|
280
|
+
model,
|
|
281
|
+
protocol,
|
|
282
|
+
logCount,
|
|
283
|
+
evidence,
|
|
284
|
+
summaryMetrics: metricViews(safeGetOwnProperty(value, "summary")),
|
|
285
|
+
queryMetrics: metricViews(safeGetOwnProperty(value, "queryStats")),
|
|
286
|
+
};
|
|
287
|
+
}
|
|
@@ -80,14 +80,15 @@ export function TransientToast({
|
|
|
80
80
|
<div
|
|
81
81
|
key={notice.id}
|
|
82
82
|
className={cn(
|
|
83
|
-
"pointer-events-auto flex items-start gap-2 rounded-md border px-3 py-2 text-sm shadow-[
|
|
84
|
-
isError
|
|
85
|
-
? "border-red-400/30 bg-[#16090b]/95 text-red-100"
|
|
86
|
-
: "border-cyan-300/25 bg-[#071318]/95 text-cyan-100",
|
|
83
|
+
"pointer-events-auto flex items-start gap-2 rounded-md border bg-popover/95 px-3 py-2 text-sm text-popover-foreground shadow-[0_18px_50px_color-mix(in_oklch,var(--foreground)_16%,transparent)] backdrop-blur",
|
|
84
|
+
isError ? "border-status-danger/35" : "border-status-success/35",
|
|
87
85
|
)}
|
|
88
86
|
>
|
|
89
87
|
<Icon
|
|
90
|
-
className={cn(
|
|
88
|
+
className={cn(
|
|
89
|
+
"mt-0.5 size-4 shrink-0",
|
|
90
|
+
isError ? "text-status-danger" : "text-status-success",
|
|
91
|
+
)}
|
|
91
92
|
/>
|
|
92
93
|
<div className="min-w-0 flex-1 break-words leading-5">{notice.message}</div>
|
|
93
94
|
<button
|
|
@@ -1,11 +1,88 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
+
export const PiAgentHistoryMessageSchema = z.object({
|
|
4
|
+
role: z.enum(["user", "assistant"]),
|
|
5
|
+
content: z.string().trim().min(1).max(4_000),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export const PiAgentEvidenceSourceSchema = z.enum([
|
|
9
|
+
"log",
|
|
10
|
+
"knowledge",
|
|
11
|
+
"alert",
|
|
12
|
+
"run",
|
|
13
|
+
"group",
|
|
14
|
+
"provider",
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
export const PiAgentCountEntrySchema = z.object({
|
|
18
|
+
value: z.string(),
|
|
19
|
+
count: z.number().int().nonnegative(),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const PiAgentSummarySchema = z.object({
|
|
23
|
+
matchedLogs: z.number().int().nonnegative(),
|
|
24
|
+
knowledgeMatched: z.number().int().nonnegative(),
|
|
25
|
+
failures: z.number().int().nonnegative(),
|
|
26
|
+
pending: z.number().int().nonnegative(),
|
|
27
|
+
sessions: z.number().int().nonnegative(),
|
|
28
|
+
models: z.array(PiAgentCountEntrySchema),
|
|
29
|
+
providers: z.array(PiAgentCountEntrySchema),
|
|
30
|
+
latency: z.object({
|
|
31
|
+
count: z.number().int().nonnegative(),
|
|
32
|
+
minMs: z.number().nullable(),
|
|
33
|
+
maxMs: z.number().nullable(),
|
|
34
|
+
averageMs: z.number().nullable(),
|
|
35
|
+
}),
|
|
36
|
+
tokens: z.object({
|
|
37
|
+
input: z.number().int().nonnegative(),
|
|
38
|
+
output: z.number().int().nonnegative(),
|
|
39
|
+
total: z.number().int().nonnegative(),
|
|
40
|
+
}),
|
|
41
|
+
sourceCounts: z.record(PiAgentEvidenceSourceSchema, z.number().int().nonnegative()),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export const PiAgentQueryStatsSchema = z.object({
|
|
45
|
+
scannedLogs: z.number().int().nonnegative(),
|
|
46
|
+
hydratedLogs: z.number().int().nonnegative(),
|
|
47
|
+
matchedLogs: z.number().int().nonnegative(),
|
|
48
|
+
scannedKnowledge: z.number().int().nonnegative(),
|
|
49
|
+
matchedKnowledge: z.number().int().nonnegative(),
|
|
50
|
+
returnedEvidence: z.number().int().nonnegative(),
|
|
51
|
+
truncated: z.boolean(),
|
|
52
|
+
durationMs: z.number().nonnegative(),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export const PiAgentEvidenceSchema = z.object({
|
|
56
|
+
source: PiAgentEvidenceSourceSchema,
|
|
57
|
+
id: z.string(),
|
|
58
|
+
logId: z.number().int().positive().optional(),
|
|
59
|
+
knowledgeId: z.string().optional(),
|
|
60
|
+
logIds: z.array(z.number().int().positive()).optional(),
|
|
61
|
+
timestamp: z.string().optional(),
|
|
62
|
+
sessionId: z.string().optional(),
|
|
63
|
+
model: z.string().optional(),
|
|
64
|
+
providerName: z.string().optional(),
|
|
65
|
+
path: z.string().optional(),
|
|
66
|
+
status: z.union([z.number(), z.string()]).nullable().optional(),
|
|
67
|
+
elapsedMs: z.number().optional(),
|
|
68
|
+
inputTokens: z.number().int().nonnegative().optional(),
|
|
69
|
+
outputTokens: z.number().int().nonnegative().optional(),
|
|
70
|
+
score: z.number(),
|
|
71
|
+
matchedFields: z.array(z.string()),
|
|
72
|
+
excerpt: z.string(),
|
|
73
|
+
entityType: z.string().optional(),
|
|
74
|
+
title: z.string().optional(),
|
|
75
|
+
knowledgeType: z.string().optional(),
|
|
76
|
+
tags: z.array(z.string()).optional(),
|
|
77
|
+
});
|
|
78
|
+
|
|
3
79
|
export const PiAgentRequestSchema = z.object({
|
|
4
80
|
question: z.string().trim().min(1).max(4_000),
|
|
5
81
|
sessionId: z.string().trim().min(1).optional(),
|
|
6
82
|
providerId: z.string().trim().min(1).optional(),
|
|
7
83
|
model: z.string().trim().min(1).optional(),
|
|
8
84
|
logLimit: z.number().int().min(1).max(80).optional(),
|
|
85
|
+
history: z.array(PiAgentHistoryMessageSchema).max(12).optional(),
|
|
9
86
|
});
|
|
10
87
|
|
|
11
88
|
export const PiAgentResponseSchema = z.object({
|
|
@@ -15,6 +92,9 @@ export const PiAgentResponseSchema = z.object({
|
|
|
15
92
|
model: z.string(),
|
|
16
93
|
protocol: z.enum(["openaiResponses", "openaiChat", "anthropic"]),
|
|
17
94
|
logCount: z.number().int().nonnegative(),
|
|
95
|
+
evidence: z.array(PiAgentEvidenceSchema).optional(),
|
|
96
|
+
summary: PiAgentSummarySchema.optional(),
|
|
97
|
+
queryStats: PiAgentQueryStatsSchema.optional(),
|
|
18
98
|
});
|
|
19
99
|
|
|
20
100
|
export type PiAgentRequest = z.infer<typeof PiAgentRequestSchema>;
|