@inspectr/mcplab 1.25.0 → 1.26.0

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 (56) hide show
  1. package/dist/app/assets/index-WORUf0Lp.js +258 -0
  2. package/dist/app/assets/index-jX47Pkmh.css +1 -0
  3. package/dist/app/index.html +2 -2
  4. package/dist/app-server/copilotkit-telemetry.d.ts +6 -0
  5. package/dist/app-server/copilotkit-telemetry.d.ts.map +1 -0
  6. package/dist/app-server/copilotkit-telemetry.js +8 -0
  7. package/dist/app-server/copilotkit-telemetry.js.map +1 -0
  8. package/dist/app-server/dev-mcp.d.ts +2 -5
  9. package/dist/app-server/global-copilot-domain.d.ts +30 -0
  10. package/dist/app-server/global-copilot-domain.d.ts.map +1 -0
  11. package/dist/app-server/global-copilot-domain.js +106 -0
  12. package/dist/app-server/global-copilot-domain.js.map +1 -0
  13. package/dist/app-server/global-copilot-mastra-route.d.ts +2 -0
  14. package/dist/app-server/global-copilot-mastra-route.d.ts.map +1 -0
  15. package/dist/app-server/global-copilot-mastra-route.js +5 -0
  16. package/dist/app-server/global-copilot-mastra-route.js.map +1 -0
  17. package/dist/app-server/global-copilot-mastra-runtime.d.ts +9 -0
  18. package/dist/app-server/global-copilot-mastra-runtime.d.ts.map +1 -0
  19. package/dist/app-server/global-copilot-mastra-runtime.js +61 -0
  20. package/dist/app-server/global-copilot-mastra-runtime.js.map +1 -0
  21. package/dist/app-server/global-copilot-mastra-storage.d.ts +8 -0
  22. package/dist/app-server/global-copilot-mastra-storage.d.ts.map +1 -0
  23. package/dist/app-server/global-copilot-mastra-storage.js +26 -0
  24. package/dist/app-server/global-copilot-mastra-storage.js.map +1 -0
  25. package/dist/app-server/global-copilot-mastra-threads.d.ts +5 -0
  26. package/dist/app-server/global-copilot-mastra-threads.d.ts.map +1 -0
  27. package/dist/app-server/global-copilot-mastra-threads.js +21 -0
  28. package/dist/app-server/global-copilot-mastra-threads.js.map +1 -0
  29. package/dist/app-server/global-copilot-mastra-tools.d.ts +50 -0
  30. package/dist/app-server/global-copilot-mastra-tools.d.ts.map +1 -0
  31. package/dist/app-server/global-copilot-mastra-tools.js +175 -0
  32. package/dist/app-server/global-copilot-mastra-tools.js.map +1 -0
  33. package/dist/app-server/global-copilot-mastra.d.ts +44 -0
  34. package/dist/app-server/global-copilot-mastra.d.ts.map +1 -0
  35. package/dist/app-server/global-copilot-mastra.js +198 -0
  36. package/dist/app-server/global-copilot-mastra.js.map +1 -0
  37. package/dist/app-server/global-copilot-memory.d.ts +70 -0
  38. package/dist/app-server/global-copilot-memory.d.ts.map +1 -0
  39. package/dist/app-server/global-copilot-memory.js +119 -0
  40. package/dist/app-server/global-copilot-memory.js.map +1 -0
  41. package/dist/app-server/global-copilot-threads.d.ts +14 -0
  42. package/dist/app-server/global-copilot-threads.d.ts.map +1 -0
  43. package/dist/app-server/global-copilot-threads.js +74 -0
  44. package/dist/app-server/global-copilot-threads.js.map +1 -0
  45. package/dist/app-server/oauth-debugger-domain.d.ts +183 -203
  46. package/dist/app-server/oauth-debugger-domain.d.ts.map +1 -1
  47. package/dist/app-server/oauth-debugger-domain.js +38 -21
  48. package/dist/app-server/oauth-debugger-domain.js.map +1 -1
  49. package/dist/app-server/result-assistant-domain.d.ts +65 -81
  50. package/dist/app-server/scenario-assistant-domain.d.ts +127 -153
  51. package/dist/app-server/settings-store.d.ts +4 -4
  52. package/dist/app-server/store-utils.d.ts +1 -1
  53. package/dist/app-server/types.d.ts +25 -25
  54. package/package.json +1 -1
  55. package/dist/app/assets/index-DgUUu84k.js +0 -258
  56. package/dist/app/assets/index-ICO1prXk.css +0 -1
@@ -0,0 +1,119 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { mkdir } from 'node:fs/promises';
3
+ import { dirname, join } from 'node:path';
4
+ import { LibSQLStore } from '@mastra/libsql';
5
+ import { Memory } from '@mastra/memory';
6
+ import { z } from 'zod';
7
+ export const globalCopilotWorkingMemorySchema = z
8
+ .object({
9
+ goal: z.string(),
10
+ constraints: z.array(z.string()),
11
+ decisions: z.array(z.string()),
12
+ followUps: z.array(z.string())
13
+ })
14
+ .strict();
15
+ export const GLOBAL_COPILOT_MEMORY_OPTIONS = {
16
+ lastMessages: 20,
17
+ semanticRecall: false,
18
+ workingMemory: {
19
+ enabled: true,
20
+ scope: 'thread',
21
+ schema: globalCopilotWorkingMemorySchema
22
+ }
23
+ };
24
+ export function globalCopilotMemoryDatabasePath(workspaceRoot) {
25
+ return join(workspaceRoot, 'mcplab', '.mastra', 'global-copilot.db');
26
+ }
27
+ export async function createGlobalCopilotMemoryRuntime(params) {
28
+ await mkdir(dirname(params.databasePath), { recursive: true });
29
+ const storage = new LibSQLStore({
30
+ id: `global-copilot-${createHash('sha256').update(params.databasePath).digest('hex').slice(0, 16)}`,
31
+ url: `file:${params.databasePath}`
32
+ });
33
+ await storage.init();
34
+ return {
35
+ storage,
36
+ memory: new Memory({ storage, options: GLOBAL_COPILOT_MEMORY_OPTIONS }),
37
+ close: () => storage.close()
38
+ };
39
+ }
40
+ export class GlobalCopilotThreadService {
41
+ memory;
42
+ resourceId;
43
+ maxThreads;
44
+ constructor(memory, resourceId, maxThreads = 100) {
45
+ this.memory = memory;
46
+ this.resourceId = resourceId;
47
+ this.maxThreads = maxThreads;
48
+ }
49
+ async list() {
50
+ const result = await this.memory.listThreads({
51
+ filter: { resourceId: this.resourceId },
52
+ perPage: false,
53
+ orderBy: { field: 'updatedAt', direction: 'DESC' }
54
+ });
55
+ return result.threads;
56
+ }
57
+ async get(id) {
58
+ const thread = await this.memory.getThreadById({
59
+ threadId: id,
60
+ resourceId: this.resourceId
61
+ });
62
+ if (!thread || thread.resourceId !== this.resourceId) {
63
+ throw new Error(`Global Copilot thread not found: ${id}`);
64
+ }
65
+ return thread;
66
+ }
67
+ async create(params) {
68
+ const now = new Date();
69
+ const thread = await this.memory.saveThread({
70
+ thread: {
71
+ id: params.id,
72
+ title: params.title?.trim() || 'New conversation',
73
+ resourceId: this.resourceId,
74
+ createdAt: now,
75
+ updatedAt: now,
76
+ metadata: {}
77
+ }
78
+ });
79
+ await this.prune(thread.id);
80
+ return thread;
81
+ }
82
+ async rename(id, title) {
83
+ const thread = await this.get(id);
84
+ const normalizedTitle = title.trim();
85
+ if (!normalizedTitle)
86
+ throw new Error('Thread title is required.');
87
+ return this.memory.updateThread({
88
+ id,
89
+ title: normalizedTitle,
90
+ metadata: thread.metadata ?? {}
91
+ });
92
+ }
93
+ async delete(id) {
94
+ await this.get(id);
95
+ await this.memory.deleteThread(id);
96
+ }
97
+ async prune(preserveId) {
98
+ const threads = await this.list();
99
+ if (threads.length <= this.maxThreads)
100
+ return;
101
+ const retained = new Set([
102
+ preserveId,
103
+ ...threads.filter((thread) => thread.id !== preserveId).slice(0, this.maxThreads - 1).map((thread) => thread.id)
104
+ ]);
105
+ await Promise.all(threads.filter((thread) => !retained.has(thread.id)).map((thread) => this.memory.deleteThread(thread.id)));
106
+ }
107
+ }
108
+ const memoryRuntimes = new Map();
109
+ export function getGlobalCopilotMemoryRuntime(workspaceRoot) {
110
+ const databasePath = globalCopilotMemoryDatabasePath(workspaceRoot);
111
+ let runtime = memoryRuntimes.get(databasePath);
112
+ if (!runtime) {
113
+ runtime = createGlobalCopilotMemoryRuntime({ databasePath });
114
+ memoryRuntimes.set(databasePath, runtime);
115
+ runtime.catch(() => memoryRuntimes.delete(databasePath));
116
+ }
117
+ return runtime;
118
+ }
119
+ //# sourceMappingURL=global-copilot-memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-copilot-memory.js","sourceRoot":"","sources":["../../src/app-server/global-copilot-memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CA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AC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;SACjH,CAAC,CAAC;QACH,MAAM,OAAO,CAAC,GAAG,CACf,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAC1G,CAAC;IACJ,CAAC;CACF;AAED,MAAM,cAAc,GAAG,IAAI,GAAG,EAA+C,CAAC;AAE9E,MAAM,UAAU,6BAA6B,CAC3C,aAAqB;IAErB,MAAM,YAAY,GAAG,+BAA+B,CAAC,aAAa,CAAC,CAAC;IACpE,IAAI,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC/C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,gCAAgC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC;QAC7D,cAAc,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAC1C,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ import type { AppSettings } from './types.js';
3
+ type RouteParams = {
4
+ req: IncomingMessage;
5
+ res: ServerResponse;
6
+ pathname: string;
7
+ method: string;
8
+ settings: AppSettings;
9
+ parseBody: (req: IncomingMessage) => Promise<Record<string, any>>;
10
+ asJson: (res: ServerResponse, status: number, body: unknown) => void;
11
+ };
12
+ export declare function handleGlobalCopilotThreadRoutes(params: RouteParams): Promise<boolean>;
13
+ export {};
14
+ //# sourceMappingURL=global-copilot-threads.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-copilot-threads.d.ts","sourceRoot":"","sources":["../../src/app-server/global-copilot-threads.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAO9C,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,eAAe,CAAC;IACrB,GAAG,EAAE,cAAc,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,WAAW,CAAC;IACtB,SAAS,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IAClE,MAAM,EAAE,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACtE,CAAC;AAUF,wBAAsB,+BAA+B,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAiE3F"}
@@ -0,0 +1,74 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { GlobalCopilotThreadService, getGlobalCopilotMemoryRuntime } from './global-copilot-memory.js';
3
+ import { globalCopilotWorkspaceResourceId } from './global-copilot-mastra.js';
4
+ function serializeThread(thread) {
5
+ return {
6
+ ...thread,
7
+ createdAt: thread.createdAt.toISOString(),
8
+ updatedAt: thread.updatedAt.toISOString()
9
+ };
10
+ }
11
+ export async function handleGlobalCopilotThreadRoutes(params) {
12
+ const collectionPath = '/api/global-copilot/threads';
13
+ const match = params.pathname.match(/^\/api\/global-copilot\/threads\/([^/]+)$/);
14
+ if (params.pathname !== collectionPath && !match)
15
+ return false;
16
+ const runtime = await getGlobalCopilotMemoryRuntime(params.settings.workspaceRoot);
17
+ const service = new GlobalCopilotThreadService(runtime.memory, globalCopilotWorkspaceResourceId(params.settings.workspaceRoot));
18
+ try {
19
+ if (params.pathname === collectionPath && params.method === 'GET') {
20
+ params.asJson(params.res, 200, {
21
+ threads: (await service.list()).map(serializeThread)
22
+ });
23
+ return true;
24
+ }
25
+ if (params.pathname === collectionPath && params.method === 'POST') {
26
+ const body = await params.parseBody(params.req);
27
+ const thread = await service.create({
28
+ id: typeof body.id === 'string' && body.id.trim() ? body.id.trim() : randomUUID(),
29
+ title: typeof body.title === 'string' ? body.title : undefined
30
+ });
31
+ params.asJson(params.res, 201, { thread: serializeThread(thread), messages: [] });
32
+ return true;
33
+ }
34
+ if (match) {
35
+ const threadId = decodeURIComponent(match[1]);
36
+ if (params.method === 'GET') {
37
+ const thread = await service.get(threadId);
38
+ const recalled = await runtime.memory.recall({
39
+ threadId,
40
+ resourceId: globalCopilotWorkspaceResourceId(params.settings.workspaceRoot),
41
+ perPage: false
42
+ });
43
+ params.asJson(params.res, 200, {
44
+ thread: serializeThread(thread),
45
+ messages: recalled.messages
46
+ });
47
+ return true;
48
+ }
49
+ if (params.method === 'PATCH') {
50
+ const body = await params.parseBody(params.req);
51
+ const title = typeof body.title === 'string' ? body.title : '';
52
+ params.asJson(params.res, 200, {
53
+ thread: serializeThread(await service.rename(threadId, title))
54
+ });
55
+ return true;
56
+ }
57
+ if (params.method === 'DELETE') {
58
+ await service.delete(threadId);
59
+ params.res.statusCode = 204;
60
+ params.res.end();
61
+ return true;
62
+ }
63
+ }
64
+ params.asJson(params.res, 405, { error: 'Method not allowed' });
65
+ }
66
+ catch (error) {
67
+ const message = error instanceof Error ? error.message : String(error);
68
+ params.asJson(params.res, message.startsWith('Global Copilot thread not found:') ? 404 : 400, {
69
+ error: message
70
+ });
71
+ }
72
+ return true;
73
+ }
74
+ //# sourceMappingURL=global-copilot-threads.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-copilot-threads.js","sourceRoot":"","sources":["../../src/app-server/global-copilot-threads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,EAC9B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AAY9E,SAAS,eAAe,CAAC,MAA8D;IACrF,OAAO;QACL,GAAG,MAAM;QACT,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE;QACzC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE;KAC1C,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,+BAA+B,CAAC,MAAmB;IACvE,MAAM,cAAc,GAAG,6BAA6B,CAAC;IACrD,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;IACjF,IAAI,MAAM,CAAC,QAAQ,KAAK,cAAc,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAE/D,MAAM,OAAO,GAAG,MAAM,6BAA6B,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IACnF,MAAM,OAAO,GAAG,IAAI,0BAA0B,CAC5C,OAAO,CAAC,MAAM,EACd,gCAAgC,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CAChE,CAAC;IAEF,IAAI,CAAC;QACH,IAAI,MAAM,CAAC,QAAQ,KAAK,cAAc,IAAI,MAAM,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;YAClE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE;gBAC7B,OAAO,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC,C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AC,KAAK,CAAC,CAAC;QACvE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE;YAC5F,KAAK,EAAE,OAAO;SACf,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,239 +1,219 @@
1
1
  import type { ServerResponse } from 'node:http';
2
2
  import type { EvalConfig } from '@inspectr/mcplab-core';
3
- type SessionStatus =
4
- | 'configuring'
5
- | 'running'
6
- | 'waiting_for_user'
7
- | 'waiting_for_browser_callback'
8
- | 'completed'
9
- | 'error'
10
- | 'stopped';
3
+ type SessionStatus = 'configuring' | 'running' | 'waiting_for_user' | 'waiting_for_browser_callback' | 'completed' | 'error' | 'stopped';
11
4
  type RegistrationMethod = 'pre_registered' | 'dcr' | 'cimd';
12
5
  export interface OAuthDebuggerSessionConfigInput {
13
- profile: 'latest';
14
- target: {
15
- serverName: string;
16
- overrides?: {
17
- authorizationServerMetadataUrl?: string;
18
- authorizationEndpoint?: string;
19
- tokenEndpoint?: string;
20
- registrationEndpoint?: string;
21
- cimdUrl?: string;
22
- resourceBaseUrl?: string;
6
+ profile: 'latest';
7
+ target: {
8
+ serverName: string;
9
+ overrides?: {
10
+ authorizationServerMetadataUrl?: string;
11
+ authorizationEndpoint?: string;
12
+ tokenEndpoint?: string;
13
+ registrationEndpoint?: string;
14
+ cimdUrl?: string;
15
+ resourceBaseUrl?: string;
16
+ };
23
17
  };
24
- };
25
- registrationMethod: RegistrationMethod;
26
- clientConfig: {
27
- preRegistered?: {
28
- clientId: string;
29
- clientSecret?: string;
30
- tokenEndpointAuthMethod?: string;
18
+ registrationMethod: RegistrationMethod;
19
+ clientConfig: {
20
+ preRegistered?: {
21
+ clientId: string;
22
+ clientSecret?: string;
23
+ tokenEndpointAuthMethod?: string;
24
+ };
25
+ dcr?: {
26
+ metadata?: Record<string, unknown>;
27
+ tokenEndpointAuthMethod?: string;
28
+ };
29
+ cimd?: {
30
+ cimdUrl?: string;
31
+ expectedClientId?: string;
32
+ };
31
33
  };
32
- dcr?: {
33
- metadata?: Record<string, unknown>;
34
- tokenEndpointAuthMethod?: string;
34
+ runtime: {
35
+ redirectMode: 'local_callback' | 'manual';
36
+ scopes?: string[];
37
+ resource?: string;
38
+ usePkce?: boolean;
39
+ codeChallengeMethod?: 'S256';
40
+ state?: string;
41
+ nonce?: string;
42
+ extraAuthParams?: Record<string, string>;
35
43
  };
36
- cimd?: {
37
- cimdUrl?: string;
38
- expectedClientId?: string;
44
+ display?: {
45
+ showSensitiveValues?: boolean;
39
46
  };
40
- };
41
- runtime: {
42
- redirectMode: 'local_callback' | 'manual';
43
- scopes?: string[];
44
- resource?: string;
45
- usePkce?: boolean;
46
- codeChallengeMethod?: 'S256';
47
- state?: string;
48
- nonce?: string;
49
- extraAuthParams?: Record<string, string>;
50
- };
51
- display?: {
52
- showSensitiveValues?: boolean;
53
- };
54
47
  }
55
48
  export interface OAuthNetworkExchange {
56
- id: string;
57
- stepId: string;
58
- kind: 'http';
59
- phase: 'request' | 'response';
60
- label: string;
61
- method?: string;
62
- url: string;
63
- headers: Record<string, string>;
64
- bodyText?: string;
65
- status?: number;
66
- durationMs?: number;
67
- timestamp: string;
68
- sensitiveFields?: Array<{
69
- path: string;
70
- type: 'token' | 'secret' | 'authorization_header';
71
- }>;
49
+ id: string;
50
+ stepId: string;
51
+ kind: 'http';
52
+ phase: 'request' | 'response';
53
+ label: string;
54
+ method?: string;
55
+ url: string;
56
+ headers: Record<string, string>;
57
+ bodyText?: string;
58
+ status?: number;
59
+ durationMs?: number;
60
+ timestamp: string;
61
+ sensitiveFields?: Array<{
62
+ path: string;
63
+ type: 'token' | 'secret' | 'authorization_header';
64
+ }>;
72
65
  }
73
66
  export interface OAuthValidationFinding {
74
- id: string;
75
- stepId: string;
76
- severity: 'error' | 'warning' | 'info';
77
- code: string;
78
- title: string;
79
- detail: string;
80
- specReference?: string;
81
- recommendation?: string;
67
+ id: string;
68
+ stepId: string;
69
+ severity: 'error' | 'warning' | 'info';
70
+ code: string;
71
+ title: string;
72
+ detail: string;
73
+ specReference?: string;
74
+ recommendation?: string;
82
75
  }
83
76
  export interface OAuthDebuggerStepState {
84
- id: string;
85
- title: string;
86
- description: string;
87
- status: 'pending' | 'active' | 'completed' | 'failed' | 'skipped';
88
- startedAt?: string;
89
- finishedAt?: string;
90
- outcomeSummary?: string;
91
- teachableMoment?: string;
92
- networkExchangeIds: string[];
93
- validationIds: string[];
77
+ id: string;
78
+ title: string;
79
+ description: string;
80
+ status: 'pending' | 'active' | 'completed' | 'failed' | 'skipped';
81
+ startedAt?: string;
82
+ finishedAt?: string;
83
+ outcomeSummary?: string;
84
+ teachableMoment?: string;
85
+ networkExchangeIds: string[];
86
+ validationIds: string[];
94
87
  }
95
88
  export interface OAuthSequenceEvent {
96
- id: string;
97
- ts: string;
98
- from: 'User' | 'Debugger' | 'Auth Server' | 'Token Endpoint' | 'MCP/Resource';
99
- to: 'User' | 'Debugger' | 'Auth Server' | 'Token Endpoint' | 'MCP/Resource';
100
- label: string;
101
- stepId?: string;
102
- networkExchangeId?: string;
89
+ id: string;
90
+ ts: string;
91
+ from: 'User' | 'Debugger' | 'Auth Server' | 'Token Endpoint' | 'MCP/Resource';
92
+ to: 'User' | 'Debugger' | 'Auth Server' | 'Token Endpoint' | 'MCP/Resource';
93
+ label: string;
94
+ stepId?: string;
95
+ networkExchangeId?: string;
103
96
  }
104
97
  export interface OAuthDebuggerSession {
105
- id: string;
106
- createdAt: number;
107
- updatedAt: number;
108
- status: SessionStatus;
109
- config: {
110
- profile: 'latest';
111
- target: OAuthDebuggerSessionConfigInput['target'];
112
- registrationMethod: RegistrationMethod;
113
- clientConfig: OAuthDebuggerSessionConfigInput['clientConfig'];
114
- runtime: Required<
115
- Pick<
116
- OAuthDebuggerSessionConfigInput['runtime'],
117
- 'redirectMode' | 'usePkce' | 'codeChallengeMethod'
118
- >
119
- > &
120
- Omit<
121
- OAuthDebuggerSessionConfigInput['runtime'],
122
- 'redirectMode' | 'usePkce' | 'codeChallengeMethod'
123
- >;
124
- display: {
125
- showSensitiveValues: boolean;
98
+ id: string;
99
+ createdAt: number;
100
+ updatedAt: number;
101
+ status: SessionStatus;
102
+ config: {
103
+ profile: 'latest';
104
+ target: OAuthDebuggerSessionConfigInput['target'];
105
+ registrationMethod: RegistrationMethod;
106
+ clientConfig: OAuthDebuggerSessionConfigInput['clientConfig'];
107
+ runtime: Required<Pick<OAuthDebuggerSessionConfigInput['runtime'], 'redirectMode' | 'usePkce' | 'codeChallengeMethod'>> & Omit<OAuthDebuggerSessionConfigInput['runtime'], 'redirectMode' | 'usePkce' | 'codeChallengeMethod'>;
108
+ display: {
109
+ showSensitiveValues: boolean;
110
+ };
126
111
  };
127
- };
128
- steps: OAuthDebuggerStepState[];
129
- validations: OAuthValidationFinding[];
130
- network: OAuthNetworkExchange[];
131
- sequence: OAuthSequenceEvent[];
132
- events: Array<{
133
- type: string;
134
- ts: string;
135
- payload: Record<string, unknown>;
136
- }>;
137
- clients: Set<ServerResponse>;
138
- abortController: AbortController;
139
- serverConfig?: EvalConfig['servers'][string];
140
- context: {
141
- resourceMetadata?: any;
142
- authServerMetadata?: any;
143
- registration?: any;
144
- resolvedClient?: {
145
- clientId: string;
146
- clientSecret?: string;
147
- tokenEndpointAuthMethod?: string;
112
+ steps: OAuthDebuggerStepState[];
113
+ validations: OAuthValidationFinding[];
114
+ network: OAuthNetworkExchange[];
115
+ sequence: OAuthSequenceEvent[];
116
+ events: Array<{
117
+ type: string;
118
+ ts: string;
119
+ payload: Record<string, unknown>;
120
+ }>;
121
+ clients: Set<ServerResponse>;
122
+ abortController: AbortController;
123
+ serverConfig?: EvalConfig['servers'][string];
124
+ context: {
125
+ resourceMetadata?: any;
126
+ authServerMetadata?: any;
127
+ registration?: any;
128
+ resolvedClient?: {
129
+ clientId: string;
130
+ clientSecret?: string;
131
+ tokenEndpointAuthMethod?: string;
132
+ };
133
+ pkce?: {
134
+ verifier: string;
135
+ challenge: string;
136
+ method: 'S256';
137
+ };
138
+ authorizationRequestUrl?: string;
139
+ callbackResult?: {
140
+ rawUrl?: string;
141
+ code?: string;
142
+ state?: string;
143
+ error?: string;
144
+ errorDescription?: string;
145
+ issuer?: string;
146
+ };
147
+ tokenResponse?: any;
148
+ tokenReceivedAt?: number;
149
+ probeResponse?: {
150
+ status: number;
151
+ bodyText: string;
152
+ url: string;
153
+ };
154
+ callbackUrl?: string;
148
155
  };
149
- pkce?: {
150
- verifier: string;
151
- challenge: string;
152
- method: 'S256';
156
+ }
157
+ export interface OAuthDebuggerSessionView {
158
+ id: string;
159
+ status: SessionStatus;
160
+ createdAt: string;
161
+ updatedAt: string;
162
+ profile: 'latest';
163
+ registrationMethod: RegistrationMethod;
164
+ stepStates: OAuthDebuggerStepState[];
165
+ validations: OAuthValidationFinding[];
166
+ network: OAuthNetworkExchange[];
167
+ networkSummary: {
168
+ requestCount: number;
169
+ errorCount: number;
153
170
  };
154
- authorizationRequestUrl?: string;
155
- callbackResult?: {
156
- rawUrl?: string;
157
- code?: string;
158
- state?: string;
159
- error?: string;
160
- errorDescription?: string;
161
- issuer?: string;
171
+ sequence: OAuthSequenceEvent[];
172
+ uiHints: {
173
+ nextAction?: 'start' | 'open_authorize_url' | 'paste_callback_url' | 'none';
174
+ authorizationUrl?: string;
175
+ callbackMode?: 'local_callback' | 'manual';
176
+ callbackUrl?: string;
162
177
  };
163
- tokenResponse?: any;
164
- tokenReceivedAt?: number;
165
- probeResponse?: {
166
- status: number;
167
- bodyText: string;
168
- url: string;
178
+ summary?: {
179
+ showSensitiveValues?: boolean;
180
+ issuer?: string;
181
+ clientId?: string;
182
+ redirectUri?: string;
183
+ tokenEndpointStatus?: number;
184
+ tokenType?: string;
185
+ grantedScopes?: string[];
186
+ accessToken?: string;
187
+ accessTokenExpiresInSeconds?: number;
188
+ accessTokenExpiresAt?: string;
189
+ accessTokenValidForSeconds?: number;
190
+ accessTokenExpirySource?: 'expires_in' | 'jwt_exp' | 'none';
191
+ refreshTokenAvailable?: boolean;
169
192
  };
170
- callbackUrl?: string;
171
- };
172
193
  }
173
- export interface OAuthDebuggerSessionView {
174
- id: string;
175
- status: SessionStatus;
176
- createdAt: string;
177
- updatedAt: string;
178
- profile: 'latest';
179
- registrationMethod: RegistrationMethod;
180
- stepStates: OAuthDebuggerStepState[];
181
- validations: OAuthValidationFinding[];
182
- network: OAuthNetworkExchange[];
183
- networkSummary: {
184
- requestCount: number;
185
- errorCount: number;
186
- };
187
- sequence: OAuthSequenceEvent[];
188
- uiHints: {
189
- nextAction?: 'start' | 'open_authorize_url' | 'paste_callback_url' | 'none';
190
- authorizationUrl?: string;
191
- callbackMode?: 'local_callback' | 'manual';
192
- callbackUrl?: string;
193
- };
194
- summary?: {
195
- showSensitiveValues?: boolean;
196
- issuer?: string;
197
- clientId?: string;
198
- redirectUri?: string;
199
- tokenEndpointStatus?: number;
200
- tokenType?: string;
201
- grantedScopes?: string[];
202
- accessToken?: string;
203
- accessTokenExpiresInSeconds?: number;
204
- accessTokenExpiresAt?: string;
205
- accessTokenValidForSeconds?: number;
206
- accessTokenExpirySource?: 'expires_in' | 'jwt_exp' | 'none';
207
- refreshTokenAvailable?: boolean;
208
- };
209
- }
210
- export declare function cleanupOAuthDebuggerSessions(
211
- sessions: Map<string, OAuthDebuggerSession>,
212
- now?: number
213
- ): void;
194
+ export declare function resourceMetadataCandidates(baseUrl: string, preferredUrl?: string): string[];
195
+ export declare function cleanupOAuthDebuggerSessions(sessions: Map<string, OAuthDebuggerSession>, now?: number): void;
214
196
  export declare function createOAuthDebuggerSession(params: {
215
- config: OAuthDebuggerSessionConfigInput;
216
- serverConfig?: EvalConfig['servers'][string];
197
+ config: OAuthDebuggerSessionConfigInput;
198
+ serverConfig?: EvalConfig['servers'][string];
217
199
  }): OAuthDebuggerSession;
218
- export declare function oauthDebuggerSessionView(
219
- session: OAuthDebuggerSession
220
- ): OAuthDebuggerSessionView;
200
+ export declare function oauthDebuggerSessionView(session: OAuthDebuggerSession): OAuthDebuggerSessionView;
221
201
  export declare function startOrResumeOAuthDebuggerSession(params: {
222
- session: OAuthDebuggerSession;
223
- appBaseUrl: string;
202
+ session: OAuthDebuggerSession;
203
+ appBaseUrl: string;
224
204
  }): Promise<void>;
225
205
  export declare function submitManualCallbackToSession(params: {
226
- session: OAuthDebuggerSession;
227
- redirectUrl?: string;
228
- code?: string;
229
- state?: string;
206
+ session: OAuthDebuggerSession;
207
+ redirectUrl?: string;
208
+ code?: string;
209
+ state?: string;
230
210
  }): void;
231
211
  export declare function submitBrowserCallbackToSession(params: {
232
- session: OAuthDebuggerSession;
233
- rawUrl: string;
212
+ session: OAuthDebuggerSession;
213
+ rawUrl: string;
234
214
  }): void;
235
215
  export declare function stopOAuthDebuggerSession(session: OAuthDebuggerSession): void;
236
216
  export declare function oauthDebuggerExportMarkdown(session: OAuthDebuggerSession): string;
237
217
  export declare function oauthDebuggerExportRawTrace(session: OAuthDebuggerSession): string;
238
218
  export {};
239
- //# sourceMappingURL=oauth-debugger-domain.d.ts.map
219
+ //# sourceMappingURL=oauth-debugger-domain.d.ts.map