@tonyclaw/agent-inspector 3.1.19 → 3.1.21

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.
Files changed (61) hide show
  1. package/.output/backend/nitro.json +1 -1
  2. package/.output/cli.js +140 -20
  3. package/.output/server/_ssr/index.mjs +2 -2
  4. package/.output/server/_ssr/{router-0qlvqhVh.mjs → router-Be6BLuut.mjs} +2454 -1135
  5. package/.output/server/_tanstack-start-manifest_v-ClTaMkEj.mjs +4 -0
  6. package/.output/server/index.mjs +1 -1
  7. package/.output/ui/assets/{CompareDrawer-BOk9hd-Z.js → CompareDrawer-CGk2HFI1.js} +1 -1
  8. package/.output/ui/assets/{InspectorPet-DhHDBpk7.js → InspectorPet-CDM7SdOT.js} +1 -1
  9. package/.output/ui/assets/ProxyViewerContainer-CaWD78tw.js +60 -0
  10. package/.output/ui/assets/{ReplayDialog-DJhKtuNB.js → ReplayDialog-DqaeV1He.js} +1 -1
  11. package/.output/ui/assets/{RequestAnatomy-hP0tsqDC.js → RequestAnatomy-BtHl9P0k.js} +1 -1
  12. package/.output/ui/assets/{ResponseView-BSiUkwCb.js → ResponseView-C6t1vpxs.js} +1 -1
  13. package/.output/ui/assets/{StreamingChunkSequence-CzQqwv4X.js → StreamingChunkSequence-R4mgd3GQ.js} +1 -1
  14. package/.output/ui/assets/{_sessionId-BU-i6h0V.js → _sessionId-CL3hdLlQ.js} +1 -1
  15. package/.output/ui/assets/{_sessionId-C2Pq4Jb0.js → _sessionId-HS666S72.js} +1 -1
  16. package/.output/ui/assets/index-B-Qod-aA.css +1 -0
  17. package/.output/ui/assets/{index-D8C-t-2U.js → index-Bd9jPL4n.js} +1 -1
  18. package/.output/ui/assets/{index-zHpVF0jk.js → index-C4NHrclw.js} +1 -1
  19. package/.output/ui/assets/{index-UUnRwbOJ.js → index-UF1PJEcq.js} +1 -1
  20. package/.output/ui/assets/{index-B7NeIBDf.js → index-tX38BNV2.js} +2 -2
  21. package/.output/ui/assets/{json-viewer-DOzS5rUT.js → json-viewer-KSgzN_Ov.js} +1 -1
  22. package/.output/ui/assets/{jszip.min-CCCY7qNk.js → jszip.min-BiMDxghN.js} +1 -1
  23. package/.output/ui/index.html +2 -2
  24. package/.output/workers/logFinalizer.worker.js +261 -0
  25. package/.output/workers/sessionWorkerEntry.js +261 -0
  26. package/package.json +13 -6
  27. package/src/backend/routes/api/logs.$id.replay.ts +6 -1
  28. package/src/backend/routes/api/logs.stream.ts +7 -0
  29. package/src/backend/routes/api/providers.$providerId.model-metadata.ts +15 -4
  30. package/src/backend/routes/api/storage.ts +56 -0
  31. package/src/backend/routes/metrics.ts +14 -0
  32. package/src/cli/doctor.ts +135 -2
  33. package/src/cli.ts +7 -4
  34. package/src/components/ProxyViewerContainer.tsx +41 -24
  35. package/src/components/providers/SettingsDialog.tsx +261 -70
  36. package/src/components/proxy-viewer/LogEntry.tsx +19 -5
  37. package/src/components/proxy-viewer/bodyHydration.ts +67 -0
  38. package/src/components/proxy-viewer/proxyViewerContainerLogic.ts +78 -0
  39. package/src/contracts/index.ts +2 -0
  40. package/src/contracts/log.ts +5 -0
  41. package/src/knowledge/openclawClient.ts +11 -2
  42. package/src/knowledge/openclawGatewayClient.ts +6 -1
  43. package/src/lib/resourceLimits.ts +191 -0
  44. package/src/lib/safeFetch.ts +428 -20
  45. package/src/lib/stopReason.ts +66 -39
  46. package/src/proxy/ecosystemTasks.ts +20 -0
  47. package/src/proxy/handler.ts +17 -4
  48. package/src/proxy/identityProxy.ts +36 -16
  49. package/src/proxy/logIndex.ts +57 -6
  50. package/src/proxy/logger.ts +4 -0
  51. package/src/proxy/rawStreamCapture.ts +16 -1
  52. package/src/proxy/runtimeHealth.ts +4 -2
  53. package/src/proxy/runtimeMetrics.ts +149 -0
  54. package/src/proxy/schemas.ts +2 -0
  55. package/src/proxy/sessionRuntime.ts +38 -0
  56. package/src/proxy/sqliteLogIndex.ts +78 -2
  57. package/src/proxy/storageLifecycle.ts +432 -0
  58. package/src/proxy/store.ts +69 -13
  59. package/.output/server/_tanstack-start-manifest_v-DnbdNeun.mjs +0 -4
  60. package/.output/ui/assets/ProxyViewerContainer-BRYf987G.js +0 -59
  61. package/.output/ui/assets/index-IBEDJoV_.css +0 -1
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { DEFAULT_RUNTIME_BUDGET_POLICY } from "../lib/resourceLimits";
2
3
  import { safeFetch } from "../lib/safeFetch";
3
4
  import type { KnowledgeCandidate, KnowledgeSearchResponse, OpenClawMemoryPayload } from "./types";
4
5
  import { KnowledgeSearchResponseSchema, KnowledgeSearchResultSchema } from "./types";
@@ -89,7 +90,11 @@ export async function promoteToOpenClaw(candidate: KnowledgeCandidate): Promise<
89
90
  headers: authHeaders(),
90
91
  body: JSON.stringify(buildOpenClawPayload(candidate)),
91
92
  },
92
- { bypass: true },
93
+ {
94
+ bypass: true,
95
+ deadlineMs: DEFAULT_RUNTIME_BUDGET_POLICY.upstream.metadataDeadlineMs,
96
+ responseBytes: DEFAULT_RUNTIME_BUDGET_POLICY.upstream.metadataResponseBytes,
97
+ },
93
98
  );
94
99
  if (!fetchResult.ok) return { success: false, error: fetchResult.reason };
95
100
  const response = fetchResult.response;
@@ -133,7 +138,11 @@ export async function searchOpenClaw(
133
138
  method: "GET",
134
139
  headers: authHeaders(),
135
140
  },
136
- { bypass: true },
141
+ {
142
+ bypass: true,
143
+ deadlineMs: DEFAULT_RUNTIME_BUDGET_POLICY.upstream.metadataDeadlineMs,
144
+ responseBytes: DEFAULT_RUNTIME_BUDGET_POLICY.upstream.metadataResponseBytes,
145
+ },
137
146
  );
138
147
  if (!fetchResult.ok) return { results: [], warning: fetchResult.reason };
139
148
  const response = fetchResult.response;
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { DEFAULT_RUNTIME_BUDGET_POLICY } from "../lib/resourceLimits";
2
3
  import { safeFetch } from "../lib/safeFetch";
3
4
  import type { KnowledgeSearchResponse, KnowledgeSearchResult } from "./types";
4
5
 
@@ -208,7 +209,11 @@ export async function searchOpenClawGateway(
208
209
  sessionKey: getOpenClawSessionKey(),
209
210
  }),
210
211
  },
211
- { bypass: true },
212
+ {
213
+ bypass: true,
214
+ deadlineMs: DEFAULT_RUNTIME_BUDGET_POLICY.upstream.metadataDeadlineMs,
215
+ responseBytes: DEFAULT_RUNTIME_BUDGET_POLICY.upstream.metadataResponseBytes,
216
+ },
212
217
  );
213
218
  if (!fetchResult.ok) return { results: [], warning: fetchResult.reason };
214
219
  const response = fetchResult.response;
@@ -11,6 +11,197 @@ export const MAX_ACTIVE_PROVIDER_TESTS = 2;
11
11
  export const MAX_PROVIDER_TEST_CONCURRENCY = 4;
12
12
  export const MAX_ACTIVE_PROXY_REQUESTS = 16;
13
13
 
14
+ const positiveInteger = z.number().int().positive();
15
+
16
+ export const RuntimeBudgetPolicySchema = z
17
+ .object({
18
+ proxy: z.object({
19
+ requestBytes: positiveInteger,
20
+ responseBytes: positiveInteger,
21
+ headerBytes: positiveInteger,
22
+ deadlineMs: positiveInteger,
23
+ idleTimeoutMs: positiveInteger,
24
+ activeRequests: positiveInteger,
25
+ }),
26
+ control: z.object({
27
+ requestBytes: positiveInteger,
28
+ responseBytes: positiveInteger,
29
+ headerBytes: positiveInteger,
30
+ deadlineMs: positiveInteger,
31
+ idleTimeoutMs: positiveInteger,
32
+ activeRequests: positiveInteger,
33
+ }),
34
+ upstream: z.object({
35
+ fetchResponseBytes: positiveInteger,
36
+ fetchDeadlineMs: positiveInteger,
37
+ replayResponseBytes: positiveInteger,
38
+ replayDeadlineMs: positiveInteger,
39
+ metadataResponseBytes: positiveInteger,
40
+ metadataDeadlineMs: positiveInteger,
41
+ connectTimeoutMs: positiveInteger,
42
+ idleTimeoutMs: positiveInteger,
43
+ }),
44
+ pagination: z.object({
45
+ restPageSize: positiveInteger,
46
+ searchQueryChars: positiveInteger,
47
+ searchProjectChars: positiveInteger,
48
+ }),
49
+ sse: z.object({
50
+ clients: positiveInteger,
51
+ initLogs: positiveInteger,
52
+ heartbeatMs: positiveInteger,
53
+ }),
54
+ imports: z.object({
55
+ archiveBytes: positiveInteger,
56
+ entries: positiveInteger,
57
+ entryBytes: positiveInteger,
58
+ uncompressedBytes: positiveInteger,
59
+ expansionRatio: positiveInteger,
60
+ }),
61
+ fanOut: z.object({
62
+ providerModels: positiveInteger,
63
+ providerModelMetadata: positiveInteger,
64
+ providerTestConcurrency: positiveInteger,
65
+ activeProviderTests: positiveInteger,
66
+ }),
67
+ queues: z.object({
68
+ proxyRequests: positiveInteger,
69
+ finalizerJobs: positiveInteger,
70
+ rawStreamMessages: positiveInteger,
71
+ rawStreamBytes: positiveInteger,
72
+ backgroundWorkers: positiveInteger,
73
+ }),
74
+ })
75
+ .superRefine((policy, context) => {
76
+ if (policy.control.requestBytes > policy.proxy.requestBytes) {
77
+ context.addIssue({
78
+ code: "custom",
79
+ path: ["control", "requestBytes"],
80
+ message: "control request budget must not exceed proxy request budget",
81
+ });
82
+ }
83
+ if (policy.control.responseBytes > policy.proxy.responseBytes) {
84
+ context.addIssue({
85
+ code: "custom",
86
+ path: ["control", "responseBytes"],
87
+ message: "control response budget must not exceed proxy response budget",
88
+ });
89
+ }
90
+ if (policy.control.activeRequests > policy.proxy.activeRequests) {
91
+ context.addIssue({
92
+ code: "custom",
93
+ path: ["control", "activeRequests"],
94
+ message: "control active request budget must not exceed proxy active request budget",
95
+ });
96
+ }
97
+ if (policy.upstream.fetchResponseBytes > policy.proxy.responseBytes) {
98
+ context.addIssue({
99
+ code: "custom",
100
+ path: ["upstream", "fetchResponseBytes"],
101
+ message: "upstream fetch response budget must not exceed proxy response budget",
102
+ });
103
+ }
104
+ if (policy.upstream.replayResponseBytes > policy.proxy.responseBytes) {
105
+ context.addIssue({
106
+ code: "custom",
107
+ path: ["upstream", "replayResponseBytes"],
108
+ message: "upstream replay response budget must not exceed proxy response budget",
109
+ });
110
+ }
111
+ if (policy.upstream.metadataResponseBytes > policy.control.responseBytes) {
112
+ context.addIssue({
113
+ code: "custom",
114
+ path: ["upstream", "metadataResponseBytes"],
115
+ message: "upstream metadata response budget must not exceed control response budget",
116
+ });
117
+ }
118
+ if (policy.upstream.metadataDeadlineMs > policy.control.deadlineMs) {
119
+ context.addIssue({
120
+ code: "custom",
121
+ path: ["upstream", "metadataDeadlineMs"],
122
+ message: "upstream metadata deadline must not exceed control deadline",
123
+ });
124
+ }
125
+ if (policy.queues.proxyRequests < policy.proxy.activeRequests) {
126
+ context.addIssue({
127
+ code: "custom",
128
+ path: ["queues", "proxyRequests"],
129
+ message: "proxy request queue budget must cover active proxy requests",
130
+ });
131
+ }
132
+ });
133
+
134
+ export type RuntimeBudgetPolicy = z.infer<typeof RuntimeBudgetPolicySchema>;
135
+
136
+ export const DEFAULT_RUNTIME_BUDGET_POLICY = RuntimeBudgetPolicySchema.parse({
137
+ proxy: {
138
+ requestBytes: 64 * 1024 * 1024,
139
+ responseBytes: 256 * 1024 * 1024,
140
+ headerBytes: 64 * 1024,
141
+ deadlineMs: 120_000,
142
+ idleTimeoutMs: 30_000,
143
+ activeRequests: MAX_ACTIVE_PROXY_REQUESTS,
144
+ },
145
+ control: {
146
+ requestBytes: 8 * 1024 * 1024,
147
+ responseBytes: 64 * 1024 * 1024,
148
+ headerBytes: 32 * 1024,
149
+ deadlineMs: 30_000,
150
+ idleTimeoutMs: 10_000,
151
+ activeRequests: 8,
152
+ },
153
+ upstream: {
154
+ fetchResponseBytes: 256 * 1024 * 1024,
155
+ fetchDeadlineMs: 120_000,
156
+ replayResponseBytes: 256 * 1024 * 1024,
157
+ replayDeadlineMs: 120_000,
158
+ metadataResponseBytes: 10 * 1024 * 1024,
159
+ metadataDeadlineMs: 30_000,
160
+ connectTimeoutMs: 10_000,
161
+ idleTimeoutMs: 30_000,
162
+ },
163
+ pagination: {
164
+ restPageSize: MAX_REST_LOG_PAGE_SIZE,
165
+ searchQueryChars: MAX_SEARCH_QUERY_CHARS,
166
+ searchProjectChars: MAX_SEARCH_PROJECT_CHARS,
167
+ },
168
+ sse: {
169
+ clients: MAX_SSE_CLIENTS,
170
+ initLogs: 500,
171
+ heartbeatMs: 15_000,
172
+ },
173
+ imports: {
174
+ archiveBytes: 64 * 1024 * 1024,
175
+ entries: 5_000,
176
+ entryBytes: 32 * 1024 * 1024,
177
+ uncompressedBytes: 256 * 1024 * 1024,
178
+ expansionRatio: 20,
179
+ },
180
+ fanOut: {
181
+ providerModels: MAX_PROVIDER_MODELS,
182
+ providerModelMetadata: MAX_PROVIDER_MODEL_METADATA,
183
+ providerTestConcurrency: MAX_PROVIDER_TEST_CONCURRENCY,
184
+ activeProviderTests: MAX_ACTIVE_PROVIDER_TESTS,
185
+ },
186
+ queues: {
187
+ proxyRequests: MAX_ACTIVE_PROXY_REQUESTS,
188
+ finalizerJobs: 1_000,
189
+ rawStreamMessages: 16_384,
190
+ rawStreamBytes: 64 * 1024 * 1024,
191
+ backgroundWorkers: 4,
192
+ },
193
+ });
194
+
195
+ export function validateRuntimeBudgetPolicy(input: unknown): RuntimeBudgetPolicy {
196
+ return RuntimeBudgetPolicySchema.parse(input);
197
+ }
198
+
199
+ export function runtimeBudgetPolicySnapshot(
200
+ policy: RuntimeBudgetPolicy = DEFAULT_RUNTIME_BUDGET_POLICY,
201
+ ): RuntimeBudgetPolicy {
202
+ return RuntimeBudgetPolicySchema.parse(policy);
203
+ }
204
+
14
205
  export const ResourceLimitErrorCodeSchema = z.enum([
15
206
  "invalid-page-request",
16
207
  "search-limit-exceeded",