@copilotz/admin 0.9.37 → 0.9.38

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.cts CHANGED
@@ -127,6 +127,16 @@ interface AdminUsageFilters {
127
127
  operation?: string;
128
128
  status?: string;
129
129
  }
130
+ interface AdminEventFilters {
131
+ namespace?: string;
132
+ threadId?: string;
133
+ status?: string;
134
+ eventType?: string;
135
+ traceId?: string;
136
+ search?: string;
137
+ limit?: number;
138
+ offset?: number;
139
+ }
130
140
  interface AdminThreadDetail {
131
141
  id: string;
132
142
  name: string;
@@ -236,6 +246,7 @@ interface CopilotzAdminClient {
236
246
  limit?: number;
237
247
  before?: string;
238
248
  }): Promise<AdminMessagePage>;
249
+ listEvents(options?: AdminEventFilters): Promise<AdminQueueEvent[]>;
239
250
  getThreadEvent(threadId: string): Promise<AdminQueueEvent | undefined>;
240
251
  listCollections(): Promise<string[]>;
241
252
  listCollectionItems(collection: string, options?: AdminListOptions): Promise<AdminCollectionItem[]>;
@@ -533,4 +544,4 @@ declare function StatusBadge({ status }: {
533
544
  status?: string | null;
534
545
  }): react_jsx_runtime.JSX.Element;
535
546
 
536
- export { ADMIN_GROUP_LABELS, ADMIN_GROUP_ORDER, type AdminActivityInterval, type AdminActivityPoint, type AdminAgentSummary, type AdminBranding, type AdminClientConfig, type AdminClientOptions, type AdminClientPaths, type AdminCollectionItem, type AdminCollectionPage, type AdminDatePreset, type AdminDetailPanel, type AdminMessage, type AdminMessagePage, type AdminMessagePageInfo, type AdminModule, type AdminModuleGroup, type AdminNavItem, type AdminOverview, type AdminParticipantDetail, type AdminParticipantSummary, type AdminPermissions, type AdminQueueEvent, type AdminRouteDefinition, type AdminRouteState, type AdminRuntimeContext, type AdminScope, type AdminThreadDetail, type AdminThreadSummary, type AdminUsageAttribution, type AdminUsageBreakdown, type AdminUsageDimension, type AdminUsageFilters, type AdminUsageGroupBy, type AdminUsageInterval, type AdminUsageKind, type AdminUsageMetricKind, type AdminUsagePoint, type AdminUsageResponse, type AdminUsageTotals, type AggregatedUsageRow, type CollectionEditor, type CollectionEditorProps, CopilotzAdmin, type CopilotzAdminClient, type CopilotzAdminProps, EMPTY_USAGE_TOTALS, EmptyState, FilterBar, InspectorPanel, JsonPanel, type LegacyAdminConfig, MetricStrip, type MetricStripItem, PageHeader, type RequestHeadersProvider, ResourceTable, type ResourceTableColumn, StatusBadge, type UsageCalculationOptions, type UsageChartSeries, type UsageChartState, type UseCopilotzAdminOptions, type UseCopilotzAdminResult, addUsageTotals, agentsModule, aggregateUsageRows, buildUsageChartState, canAccessAdminPermission, collectAdminNavItems, collectAdminRoutes, collectCollectionEditors, collectionsModule, createAdminClient, defaultAdminConfig, defaultCopilotzModules, eventsModule, firstAccessibleRoute, formatCompactMetric, formatMetricValue, formatNumber, formatPercent, formatUsageBucket, getUsageDimensionLabel, getUsageGroupLabel, getUsageMetricLabel, getUsageRange, getUsageTotalValue, mergeAdminConfig, overviewModule, participantsModule, threadsModule, usageModule, useAdmin, useCopilotzAdmin };
547
+ export { ADMIN_GROUP_LABELS, ADMIN_GROUP_ORDER, type AdminActivityInterval, type AdminActivityPoint, type AdminAgentSummary, type AdminBranding, type AdminClientConfig, type AdminClientOptions, type AdminClientPaths, type AdminCollectionItem, type AdminCollectionPage, type AdminDatePreset, type AdminDetailPanel, type AdminEventFilters, type AdminMessage, type AdminMessagePage, type AdminMessagePageInfo, type AdminModule, type AdminModuleGroup, type AdminNavItem, type AdminOverview, type AdminParticipantDetail, type AdminParticipantSummary, type AdminPermissions, type AdminQueueEvent, type AdminRouteDefinition, type AdminRouteState, type AdminRuntimeContext, type AdminScope, type AdminThreadDetail, type AdminThreadSummary, type AdminUsageAttribution, type AdminUsageBreakdown, type AdminUsageDimension, type AdminUsageFilters, type AdminUsageGroupBy, type AdminUsageInterval, type AdminUsageKind, type AdminUsageMetricKind, type AdminUsagePoint, type AdminUsageResponse, type AdminUsageTotals, type AggregatedUsageRow, type CollectionEditor, type CollectionEditorProps, CopilotzAdmin, type CopilotzAdminClient, type CopilotzAdminProps, EMPTY_USAGE_TOTALS, EmptyState, FilterBar, InspectorPanel, JsonPanel, type LegacyAdminConfig, MetricStrip, type MetricStripItem, PageHeader, type RequestHeadersProvider, ResourceTable, type ResourceTableColumn, StatusBadge, type UsageCalculationOptions, type UsageChartSeries, type UsageChartState, type UseCopilotzAdminOptions, type UseCopilotzAdminResult, addUsageTotals, agentsModule, aggregateUsageRows, buildUsageChartState, canAccessAdminPermission, collectAdminNavItems, collectAdminRoutes, collectCollectionEditors, collectionsModule, createAdminClient, defaultAdminConfig, defaultCopilotzModules, eventsModule, firstAccessibleRoute, formatCompactMetric, formatMetricValue, formatNumber, formatPercent, formatUsageBucket, getUsageDimensionLabel, getUsageGroupLabel, getUsageMetricLabel, getUsageRange, getUsageTotalValue, mergeAdminConfig, overviewModule, participantsModule, threadsModule, usageModule, useAdmin, useCopilotzAdmin };
package/dist/index.d.ts CHANGED
@@ -127,6 +127,16 @@ interface AdminUsageFilters {
127
127
  operation?: string;
128
128
  status?: string;
129
129
  }
130
+ interface AdminEventFilters {
131
+ namespace?: string;
132
+ threadId?: string;
133
+ status?: string;
134
+ eventType?: string;
135
+ traceId?: string;
136
+ search?: string;
137
+ limit?: number;
138
+ offset?: number;
139
+ }
130
140
  interface AdminThreadDetail {
131
141
  id: string;
132
142
  name: string;
@@ -236,6 +246,7 @@ interface CopilotzAdminClient {
236
246
  limit?: number;
237
247
  before?: string;
238
248
  }): Promise<AdminMessagePage>;
249
+ listEvents(options?: AdminEventFilters): Promise<AdminQueueEvent[]>;
239
250
  getThreadEvent(threadId: string): Promise<AdminQueueEvent | undefined>;
240
251
  listCollections(): Promise<string[]>;
241
252
  listCollectionItems(collection: string, options?: AdminListOptions): Promise<AdminCollectionItem[]>;
@@ -533,4 +544,4 @@ declare function StatusBadge({ status }: {
533
544
  status?: string | null;
534
545
  }): react_jsx_runtime.JSX.Element;
535
546
 
536
- export { ADMIN_GROUP_LABELS, ADMIN_GROUP_ORDER, type AdminActivityInterval, type AdminActivityPoint, type AdminAgentSummary, type AdminBranding, type AdminClientConfig, type AdminClientOptions, type AdminClientPaths, type AdminCollectionItem, type AdminCollectionPage, type AdminDatePreset, type AdminDetailPanel, type AdminMessage, type AdminMessagePage, type AdminMessagePageInfo, type AdminModule, type AdminModuleGroup, type AdminNavItem, type AdminOverview, type AdminParticipantDetail, type AdminParticipantSummary, type AdminPermissions, type AdminQueueEvent, type AdminRouteDefinition, type AdminRouteState, type AdminRuntimeContext, type AdminScope, type AdminThreadDetail, type AdminThreadSummary, type AdminUsageAttribution, type AdminUsageBreakdown, type AdminUsageDimension, type AdminUsageFilters, type AdminUsageGroupBy, type AdminUsageInterval, type AdminUsageKind, type AdminUsageMetricKind, type AdminUsagePoint, type AdminUsageResponse, type AdminUsageTotals, type AggregatedUsageRow, type CollectionEditor, type CollectionEditorProps, CopilotzAdmin, type CopilotzAdminClient, type CopilotzAdminProps, EMPTY_USAGE_TOTALS, EmptyState, FilterBar, InspectorPanel, JsonPanel, type LegacyAdminConfig, MetricStrip, type MetricStripItem, PageHeader, type RequestHeadersProvider, ResourceTable, type ResourceTableColumn, StatusBadge, type UsageCalculationOptions, type UsageChartSeries, type UsageChartState, type UseCopilotzAdminOptions, type UseCopilotzAdminResult, addUsageTotals, agentsModule, aggregateUsageRows, buildUsageChartState, canAccessAdminPermission, collectAdminNavItems, collectAdminRoutes, collectCollectionEditors, collectionsModule, createAdminClient, defaultAdminConfig, defaultCopilotzModules, eventsModule, firstAccessibleRoute, formatCompactMetric, formatMetricValue, formatNumber, formatPercent, formatUsageBucket, getUsageDimensionLabel, getUsageGroupLabel, getUsageMetricLabel, getUsageRange, getUsageTotalValue, mergeAdminConfig, overviewModule, participantsModule, threadsModule, usageModule, useAdmin, useCopilotzAdmin };
547
+ export { ADMIN_GROUP_LABELS, ADMIN_GROUP_ORDER, type AdminActivityInterval, type AdminActivityPoint, type AdminAgentSummary, type AdminBranding, type AdminClientConfig, type AdminClientOptions, type AdminClientPaths, type AdminCollectionItem, type AdminCollectionPage, type AdminDatePreset, type AdminDetailPanel, type AdminEventFilters, type AdminMessage, type AdminMessagePage, type AdminMessagePageInfo, type AdminModule, type AdminModuleGroup, type AdminNavItem, type AdminOverview, type AdminParticipantDetail, type AdminParticipantSummary, type AdminPermissions, type AdminQueueEvent, type AdminRouteDefinition, type AdminRouteState, type AdminRuntimeContext, type AdminScope, type AdminThreadDetail, type AdminThreadSummary, type AdminUsageAttribution, type AdminUsageBreakdown, type AdminUsageDimension, type AdminUsageFilters, type AdminUsageGroupBy, type AdminUsageInterval, type AdminUsageKind, type AdminUsageMetricKind, type AdminUsagePoint, type AdminUsageResponse, type AdminUsageTotals, type AggregatedUsageRow, type CollectionEditor, type CollectionEditorProps, CopilotzAdmin, type CopilotzAdminClient, type CopilotzAdminProps, EMPTY_USAGE_TOTALS, EmptyState, FilterBar, InspectorPanel, JsonPanel, type LegacyAdminConfig, MetricStrip, type MetricStripItem, PageHeader, type RequestHeadersProvider, ResourceTable, type ResourceTableColumn, StatusBadge, type UsageCalculationOptions, type UsageChartSeries, type UsageChartState, type UseCopilotzAdminOptions, type UseCopilotzAdminResult, addUsageTotals, agentsModule, aggregateUsageRows, buildUsageChartState, canAccessAdminPermission, collectAdminNavItems, collectAdminRoutes, collectCollectionEditors, collectionsModule, createAdminClient, defaultAdminConfig, defaultCopilotzModules, eventsModule, firstAccessibleRoute, formatCompactMetric, formatMetricValue, formatNumber, formatPercent, formatUsageBucket, getUsageDimensionLabel, getUsageGroupLabel, getUsageMetricLabel, getUsageRange, getUsageTotalValue, mergeAdminConfig, overviewModule, participantsModule, threadsModule, usageModule, useAdmin, useCopilotzAdmin };
package/dist/index.js CHANGED
@@ -81,6 +81,21 @@ function normalizeMessagePage(payload) {
81
81
  const pageInfo = isRecord(candidate) ? normalizeMessagePageInfo(candidate.pageInfo, data) : normalizeMessagePageInfo(void 0, data);
82
82
  return { data, pageInfo };
83
83
  }
84
+ function isQueueEvent(value) {
85
+ return isRecord(value) && typeof value.id === "string" && typeof value.threadId === "string" && typeof value.eventType === "string";
86
+ }
87
+ function normalizeQueueEvent(value) {
88
+ if (isQueueEvent(value)) return value;
89
+ if (isRecord(value) && isQueueEvent(value.data)) return value.data;
90
+ return void 0;
91
+ }
92
+ function normalizeQueueEvents(value) {
93
+ if (Array.isArray(value)) return value.filter(isQueueEvent);
94
+ if (isRecord(value) && Array.isArray(value.data)) {
95
+ return value.data.filter(isQueueEvent);
96
+ }
97
+ return [];
98
+ }
84
99
  function createAdminClient(options = {}) {
85
100
  const baseUrl = resolveBaseUrl(options.baseUrl);
86
101
  const paths = { ...DEFAULT_PATHS, ...options.paths };
@@ -187,9 +202,25 @@ function createAdminClient(options = {}) {
187
202
  );
188
203
  return normalizeMessagePage(payload);
189
204
  },
190
- getThreadEvent: async (threadId) => await requestJson(
191
- `${paths.threadsBase}/${encodeURIComponent(threadId)}/events`
192
- ),
205
+ listEvents: async (eventOptions = {}) => {
206
+ const payload = await requestJson(`${paths.adminBase}/events`, {
207
+ namespace: eventOptions.namespace,
208
+ threadId: eventOptions.threadId,
209
+ status: eventOptions.status,
210
+ eventType: eventOptions.eventType,
211
+ traceId: eventOptions.traceId,
212
+ search: eventOptions.search,
213
+ limit: String(eventOptions.limit ?? 50),
214
+ offset: eventOptions.offset ? String(eventOptions.offset) : void 0
215
+ });
216
+ return normalizeQueueEvents(payload);
217
+ },
218
+ getThreadEvent: async (threadId) => {
219
+ const payload = await requestJson(
220
+ `${paths.threadsBase}/${encodeURIComponent(threadId)}/events`
221
+ );
222
+ return normalizeQueueEvent(payload);
223
+ },
193
224
  listCollections: async () => await requestJson(paths.collectionsBase),
194
225
  listCollectionItems: async (collection, listOptions = {}) => await requestJson(
195
226
  `${paths.collectionsBase}/${encodeURIComponent(collection)}`,
@@ -2186,33 +2217,61 @@ function eventsModule() {
2186
2217
  }]
2187
2218
  };
2188
2219
  }
2220
+ var EVENT_STATUSES = [
2221
+ "all",
2222
+ "pending",
2223
+ "processing",
2224
+ "completed",
2225
+ "failed",
2226
+ "expired",
2227
+ "overwritten"
2228
+ ];
2189
2229
  function EventsPage({ context }) {
2190
2230
  const [threadId, setThreadId] = React8.useState("");
2191
- const [status, setStatus] = React8.useState("");
2192
- const [type, setType] = React8.useState("");
2231
+ const [status, setStatus] = React8.useState(
2232
+ "all"
2233
+ );
2234
+ const [eventType, setEventType] = React8.useState("");
2193
2235
  const [traceId, setTraceId] = React8.useState("");
2194
- const [event, setEvent] = React8.useState(null);
2236
+ const [events, setEvents] = React8.useState([]);
2237
+ const [selectedEvent, setSelectedEvent] = React8.useState(null);
2195
2238
  const [error, setError] = React8.useState(null);
2196
- const [hasSearched, setHasSearched] = React8.useState(false);
2239
+ const [loading, setLoading] = React8.useState(false);
2240
+ const [hasLoaded, setHasLoaded] = React8.useState(false);
2197
2241
  const inspect = async () => {
2198
- if (!threadId.trim()) return;
2199
- setHasSearched(true);
2242
+ setHasLoaded(true);
2243
+ setLoading(true);
2200
2244
  setError(null);
2201
2245
  try {
2202
- const next = await context.client.getThreadEvent(threadId.trim());
2203
- setEvent(next ?? null);
2246
+ const next = await context.client.listEvents({
2247
+ namespace: context.scope.namespace || void 0,
2248
+ threadId: threadId.trim() || void 0,
2249
+ status: status === "all" ? void 0 : status,
2250
+ eventType: eventType.trim() || void 0,
2251
+ traceId: traceId.trim() || void 0,
2252
+ limit: 50
2253
+ });
2254
+ setEvents(next);
2255
+ setSelectedEvent(
2256
+ (current) => current && next.some((event) => event.id === current.id) ? current : next[0] ?? null
2257
+ );
2204
2258
  } catch (cause) {
2205
2259
  setError(cause instanceof Error ? cause.message : "Failed to load event");
2206
- setEvent(null);
2260
+ setEvents([]);
2261
+ setSelectedEvent(null);
2262
+ } finally {
2263
+ setLoading(false);
2207
2264
  }
2208
2265
  };
2209
- const rows = event && (!status || event.status.includes(status)) && (!type || event.eventType.includes(type)) && (!traceId || event.traceId?.includes(traceId)) ? [event] : [];
2266
+ React8.useEffect(() => {
2267
+ void inspect();
2268
+ }, [context.client, context.refreshKey, context.scope.namespace]);
2210
2269
  return /* @__PURE__ */ jsxs14("div", { className: "space-y-4", children: [
2211
2270
  /* @__PURE__ */ jsx22(
2212
2271
  PageHeader,
2213
2272
  {
2214
2273
  title: "Events",
2215
- description: "Queue and event inspection. Current backend support is thread-focused; filters are ready for broader event listing."
2274
+ description: "Queue and event inspection across the active namespace."
2216
2275
  }
2217
2276
  ),
2218
2277
  /* @__PURE__ */ jsxs14(
@@ -2221,13 +2280,13 @@ function EventsPage({ context }) {
2221
2280
  actions: /* @__PURE__ */ jsxs14(
2222
2281
  Button,
2223
2282
  {
2224
- disabled: !threadId.trim(),
2283
+ disabled: loading,
2225
2284
  onClick: () => void inspect(),
2226
2285
  size: "sm",
2227
2286
  type: "button",
2228
2287
  children: [
2229
2288
  /* @__PURE__ */ jsx22(Search2, { className: "size-3" }),
2230
- "Inspect"
2289
+ loading ? "Loading" : "Inspect"
2231
2290
  ]
2232
2291
  }
2233
2292
  ),
@@ -2236,37 +2295,45 @@ function EventsPage({ context }) {
2236
2295
  Input,
2237
2296
  {
2238
2297
  className: "h-8 w-[220px]",
2239
- onChange: (event2) => setThreadId(event2.target.value),
2240
- onKeyDown: (event2) => {
2241
- if (event2.key === "Enter") void inspect();
2298
+ onChange: (event) => setThreadId(event.target.value),
2299
+ onKeyDown: (event) => {
2300
+ if (event.key === "Enter") void inspect();
2242
2301
  },
2243
2302
  placeholder: "Thread ID",
2244
2303
  value: threadId
2245
2304
  }
2246
2305
  ),
2247
- /* @__PURE__ */ jsx22(
2248
- Input,
2306
+ /* @__PURE__ */ jsxs14(
2307
+ Select,
2249
2308
  {
2250
- className: "h-8 w-[150px]",
2251
- onChange: (event2) => setStatus(event2.target.value),
2252
- placeholder: "Status",
2253
- value: status
2309
+ value: status,
2310
+ onValueChange: (value) => setStatus(value),
2311
+ children: [
2312
+ /* @__PURE__ */ jsx22(SelectTrigger, { className: "h-8 w-[150px] text-xs", "aria-label": "Status", children: /* @__PURE__ */ jsx22(SelectValue, {}) }),
2313
+ /* @__PURE__ */ jsx22(SelectContent, { children: EVENT_STATUSES.map((option) => /* @__PURE__ */ jsx22(SelectItem, { value: option, children: option === "all" ? "All statuses" : option }, option)) })
2314
+ ]
2254
2315
  }
2255
2316
  ),
2256
2317
  /* @__PURE__ */ jsx22(
2257
2318
  Input,
2258
2319
  {
2259
2320
  className: "h-8 w-[180px]",
2260
- onChange: (event2) => setType(event2.target.value),
2321
+ onChange: (event) => setEventType(event.target.value),
2322
+ onKeyDown: (event) => {
2323
+ if (event.key === "Enter") void inspect();
2324
+ },
2261
2325
  placeholder: "Event type",
2262
- value: type
2326
+ value: eventType
2263
2327
  }
2264
2328
  ),
2265
2329
  /* @__PURE__ */ jsx22(
2266
2330
  Input,
2267
2331
  {
2268
2332
  className: "h-8 w-[180px]",
2269
- onChange: (event2) => setTraceId(event2.target.value),
2333
+ onChange: (event) => setTraceId(event.target.value),
2334
+ onKeyDown: (event) => {
2335
+ if (event.key === "Enter") void inspect();
2336
+ },
2270
2337
  placeholder: "Trace ID",
2271
2338
  value: traceId
2272
2339
  }
@@ -2274,27 +2341,34 @@ function EventsPage({ context }) {
2274
2341
  ]
2275
2342
  }
2276
2343
  ),
2277
- error ? /* @__PURE__ */ jsx22(EmptyState, { title: "Unable to inspect event", description: error }) : !hasSearched ? /* @__PURE__ */ jsx22(
2344
+ error ? /* @__PURE__ */ jsx22(EmptyState, { title: "Unable to inspect event", description: error }) : !hasLoaded && loading ? /* @__PURE__ */ jsx22(
2278
2345
  EmptyState,
2279
2346
  {
2280
2347
  icon: Activity,
2281
- title: "Choose a thread",
2282
- description: "Enter a thread ID to inspect its next pending event."
2348
+ title: "Loading events",
2349
+ description: "Fetching recent queue events for the active namespace."
2283
2350
  }
2284
2351
  ) : /* @__PURE__ */ jsxs14("div", { className: "grid gap-4 xl:grid-cols-[1fr_420px]", children: [
2285
2352
  /* @__PURE__ */ jsx22(
2286
2353
  ResourceTable,
2287
2354
  {
2288
- rows,
2355
+ rows: events,
2289
2356
  getRowKey: (row) => row.id,
2357
+ onRowClick: setSelectedEvent,
2290
2358
  empty: /* @__PURE__ */ jsx22(
2291
2359
  EmptyState,
2292
2360
  {
2293
- title: "No matching event",
2294
- description: "No pending event matched the current filters."
2361
+ title: "No matching events",
2362
+ description: "No event rows matched the current filters."
2295
2363
  }
2296
2364
  ),
2297
2365
  columns: [
2366
+ {
2367
+ id: "thread",
2368
+ header: "Thread",
2369
+ className: "max-w-[180px] truncate font-mono text-xs",
2370
+ render: (row) => row.threadId
2371
+ },
2298
2372
  {
2299
2373
  id: "type",
2300
2374
  header: "Type",
@@ -2318,7 +2392,20 @@ function EventsPage({ context }) {
2318
2392
  ]
2319
2393
  }
2320
2394
  ),
2321
- /* @__PURE__ */ jsx22(JsonPanel, { title: "Event JSON", value: event, minHeight: 420 })
2395
+ selectedEvent ? /* @__PURE__ */ jsx22(
2396
+ JsonPanel,
2397
+ {
2398
+ title: "Event JSON",
2399
+ value: selectedEvent,
2400
+ minHeight: 420
2401
+ }
2402
+ ) : /* @__PURE__ */ jsx22(
2403
+ EmptyState,
2404
+ {
2405
+ title: "No event selected",
2406
+ description: "Select an event row to inspect its payload."
2407
+ }
2408
+ )
2322
2409
  ] })
2323
2410
  ] });
2324
2411
  }