@elench/testkit 0.1.81 → 0.1.83

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 (55) hide show
  1. package/README.md +64 -27
  2. package/lib/cli/agents/index.mjs +64 -0
  3. package/lib/cli/agents/investigate.mjs +75 -0
  4. package/lib/cli/agents/investigation-context.mjs +102 -0
  5. package/lib/cli/agents/investigation-context.test.mjs +144 -0
  6. package/lib/cli/agents/prompt-builder.mjs +25 -0
  7. package/lib/cli/agents/providers/claude.mjs +74 -0
  8. package/lib/cli/agents/providers/claude.test.mjs +95 -0
  9. package/lib/cli/agents/providers/codex.mjs +83 -0
  10. package/lib/cli/agents/providers/codex.test.mjs +93 -0
  11. package/lib/cli/agents/providers/shared.mjs +134 -0
  12. package/lib/cli/command-helpers.mjs +53 -25
  13. package/lib/cli/command-helpers.test.mjs +122 -0
  14. package/lib/cli/commands/investigate.mjs +87 -0
  15. package/lib/cli/commands/investigate.test.mjs +83 -0
  16. package/lib/cli/entrypoint.mjs +3 -0
  17. package/lib/cli/presentation/colors.mjs +12 -0
  18. package/lib/cli/presentation/events-reporter.mjs +135 -0
  19. package/lib/cli/presentation/events-reporter.test.mjs +73 -0
  20. package/lib/cli/presentation/summary-box.mjs +11 -11
  21. package/lib/cli/presentation/summary-box.test.mjs +17 -0
  22. package/lib/cli/presentation/tree-reporter.mjs +159 -0
  23. package/lib/cli/presentation/tree-reporter.test.mjs +166 -0
  24. package/lib/cli/tui/run-app.mjs +1 -0
  25. package/lib/cli/tui/run-session-app.mjs +370 -0
  26. package/lib/cli/tui/run-session-app.test.mjs +50 -0
  27. package/lib/cli/tui/run-session-state.mjs +481 -0
  28. package/lib/cli/tui/run-tree-state.mjs +1 -0
  29. package/lib/cli/tui/run-tree-state.test.mjs +324 -0
  30. package/lib/config-api/auth-fixtures.mjs +767 -0
  31. package/lib/config-api/index.d.ts +92 -108
  32. package/lib/config-api/index.mjs +22 -12
  33. package/lib/config-api/index.test.mjs +103 -210
  34. package/lib/discovery/index.mjs +1 -1
  35. package/lib/index.d.ts +34 -10
  36. package/lib/runner/orchestrator.mjs +1 -0
  37. package/lib/runtime/index.d.ts +177 -27
  38. package/lib/runtime/index.mjs +68 -3
  39. package/lib/runtime-src/k6/http-assertions.js +31 -1
  40. package/lib/runtime-src/k6/http-checks.js +120 -0
  41. package/lib/runtime-src/k6/http-checks.test.mjs +120 -0
  42. package/lib/runtime-src/k6/http-suite-runtime.js +151 -0
  43. package/lib/runtime-src/k6/http.js +285 -56
  44. package/lib/runtime-src/k6/http.test.mjs +205 -0
  45. package/lib/runtime-src/k6/scenario-suite.js +13 -110
  46. package/lib/runtime-src/k6/suite.js +13 -107
  47. package/lib/runtime-src/shared/error-body.mjs +42 -0
  48. package/lib/runtime-src/shared/http-parsing.mjs +68 -0
  49. package/lib/runtime-src/shared/http-parsing.test.mjs +69 -0
  50. package/node_modules/@elench/next-analysis/package.json +1 -1
  51. package/node_modules/@elench/testkit-bridge/package.json +2 -2
  52. package/node_modules/@elench/testkit-protocol/package.json +1 -1
  53. package/node_modules/@elench/ts-analysis/package.json +1 -1
  54. package/package.json +5 -5
  55. package/lib/config-api/profiles.mjs +0 -640
@@ -192,22 +192,22 @@ export interface TestkitFileMetadata {
192
192
  skip?: string | { reason: string };
193
193
  }
194
194
 
195
- export interface ProfileRequestContext {
195
+ export interface AuthRequestContext {
196
196
  actor: string;
197
197
  actorIndex: number;
198
198
  env: RuntimeEnv;
199
199
  phase: string;
200
200
  }
201
201
 
202
- export type ProfileValueFactory<TValue> =
202
+ export type AuthValueFactory<TValue> =
203
203
  | TValue
204
- | ((context: ProfileRequestContext) => TValue);
204
+ | ((context: AuthRequestContext) => TValue);
205
205
 
206
- export interface ProfileRequestConfig {
207
- body?: ProfileValueFactory<unknown>;
206
+ export interface AuthRequestConfig {
207
+ body?: AuthValueFactory<unknown>;
208
208
  contentTypeJson?: boolean;
209
209
  expect?: number | number[];
210
- headers?: ProfileValueFactory<Record<string, string>>;
210
+ headers?: AuthValueFactory<Record<string, string>>;
211
211
  method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
212
212
  path: string;
213
213
  }
@@ -222,25 +222,13 @@ export interface SessionAuthHeaderConfig {
222
222
  source: SessionAuthSourceConfig;
223
223
  }
224
224
 
225
- export interface SessionCaptureConfig {
226
- auth?: SessionAuthHeaderConfig;
227
- cookies?: Record<string, string>;
228
- fields?: Record<string, string>;
229
- }
230
-
231
- export interface SessionActorConfig {
232
- bootstrap?: ProfileRequestConfig | ProfileRequestConfig[];
233
- login: ProfileRequestConfig;
234
- session: SessionCaptureConfig;
235
- }
236
-
237
- export interface ProfileHeaderContext<TSession = unknown> {
225
+ export interface AuthProfileHeaderContext<TSession = unknown> {
238
226
  actor: string | null;
239
227
  env: RuntimeEnv;
240
228
  session: TSession | null;
241
229
  }
242
230
 
243
- export interface ProfileSessionHeaderConfig {
231
+ export interface AuthProfileSessionHeaderConfig {
244
232
  actor?: string;
245
233
  field: string;
246
234
  header: string;
@@ -252,125 +240,113 @@ export interface DeterministicForwardedForConfig {
252
240
  seed?: string;
253
241
  }
254
242
 
255
- export interface ProfileHeaderConfig<TSession = unknown> {
243
+ export interface AuthProfileHeaderOptions<TSession = unknown> {
256
244
  contentTypeJson?: boolean;
257
245
  forwardedFor?: "deterministic" | DeterministicForwardedForConfig;
258
- fromSession?: ProfileSessionHeaderConfig[];
259
- values?: Record<string, string> | ((context: ProfileHeaderContext<TSession>) => Record<string, string>);
260
- }
261
-
262
- export interface RawHttpProfileOptions {
263
- env?: RuntimeEnv;
264
- headers?: ProfileHeaderConfig;
265
- options?: RuntimeOptions;
266
- }
267
-
268
- export interface SessionHttpProfileOptions {
269
- actor: SessionActorConfig;
270
- env?: RuntimeEnv;
271
- headers?: ProfileHeaderConfig<Record<string, unknown>>;
272
- options?: RuntimeOptions;
246
+ fromSession?: AuthProfileSessionHeaderConfig[];
247
+ values?: Record<string, string> | ((context: AuthProfileHeaderContext<TSession>) => Record<string, string>);
273
248
  }
274
249
 
275
- export interface MultiActorHttpProfileOptions {
276
- actors: Record<string, SessionActorConfig>;
277
- env?: RuntimeEnv;
278
- headers?: ProfileHeaderConfig<Record<string, Record<string, unknown>>>;
279
- options?: RuntimeOptions;
280
- primaryActor?: string;
281
- }
282
-
283
- export interface LocalJsonIdentityContext {
284
- actor: string;
285
- }
286
-
287
- export type LocalJsonIdentityValue = string | ((context: LocalJsonIdentityContext) => string);
288
-
289
- export interface LocalJsonActorIdentityConfig {
290
- email?: LocalJsonIdentityValue;
250
+ export interface AuthTopologyActorConfig {
251
+ email?: string;
291
252
  loginBody?: Record<string, unknown>;
292
- name?: LocalJsonIdentityValue;
293
- organizationName?: LocalJsonIdentityValue;
294
- password?: LocalJsonIdentityValue;
253
+ name?: string;
254
+ org?: string;
255
+ organizationName?: string;
256
+ password?: string;
295
257
  signupBody?: Record<string, unknown>;
296
258
  }
297
259
 
298
- export interface LocalJsonSessionAuthOptions {
299
- header?: string;
300
- prefix?: string;
301
- sourceKey?: string;
260
+ export interface AuthTopologyOrgConfig {
261
+ name?: string;
302
262
  }
303
263
 
304
- export interface LocalJsonSessionOptions {
305
- auth?: LocalJsonSessionAuthOptions;
264
+ export interface JsonSessionContractOptions {
306
265
  authCookie?: string;
307
- cookies?: Record<string, string>;
308
- fields?: Record<string, string>;
266
+ authHeader?: string;
267
+ authPrefix?: string;
268
+ authSourceKey?: string;
269
+ contentTypeJson?: boolean;
270
+ forwardedFor?: "deterministic" | DeterministicForwardedForConfig;
271
+ loginExpect?: number | number[];
272
+ loginPath?: string;
273
+ organizationHeader?: false | string;
309
274
  organizationIdPath?: string;
310
275
  refreshCookie?: string;
276
+ sessionCookies?: Record<string, string>;
277
+ sessionFields?: Record<string, string>;
278
+ signup?: false;
279
+ signupExpect?: number | number[];
280
+ signupPath?: string;
311
281
  }
312
282
 
313
- export interface LocalJsonOrganizationHeaderConfig {
314
- actor?: string;
315
- field?: string;
316
- header?: string;
283
+ export interface JsonSessionContract {
284
+ kind: "json-session";
317
285
  }
318
286
 
319
- export interface LocalJsonHeaderOptions {
320
- contentTypeJson?: boolean;
321
- forwardedFor?: "deterministic" | DeterministicForwardedForConfig;
322
- organization?: false | string | LocalJsonOrganizationHeaderConfig;
323
- values?: Record<string, string> | ((context: ProfileHeaderContext<unknown>) => Record<string, string>);
287
+ export interface SingleOrgTopologyOptions {
288
+ actors?: string[] | Record<string, string | AuthTopologyActorConfig>;
289
+ namespace: string;
290
+ org?: string;
291
+ orgs?: Record<string, AuthTopologyOrgConfig>;
292
+ password?: string;
324
293
  }
325
294
 
326
- export interface LocalJsonSignupOptions {
327
- enabled?: boolean;
328
- expect?: number | number[];
329
- path?: string;
295
+ export interface CrossOrgTopologyOptions {
296
+ actors: string[] | Record<string, string | AuthTopologyActorConfig>;
297
+ namespace: string;
298
+ orgs?: Record<string, AuthTopologyOrgConfig>;
299
+ password?: string;
330
300
  }
331
301
 
332
- export interface LocalJsonLoginOptions {
333
- expect?: number | number[];
334
- path?: string;
302
+ export interface AuthTopology {
303
+ kind: "auth-topology";
335
304
  }
336
305
 
337
- export interface LocalJsonProfileOptions {
306
+ export interface AuthActorProfileOptions {
338
307
  env?: RuntimeEnv;
339
- headers?: LocalJsonHeaderOptions;
340
- identities?: Record<string, LocalJsonActorIdentityConfig>;
341
- login?: LocalJsonLoginOptions;
308
+ headers?: AuthProfileHeaderOptions<Record<string, unknown>>;
342
309
  options?: RuntimeOptions;
343
- password?: LocalJsonIdentityValue;
344
- session?: LocalJsonSessionOptions;
345
- signup?: false | LocalJsonSignupOptions;
346
310
  }
347
311
 
348
- export interface LocalJsonSessionProfileOptions {
349
- actor?: string;
312
+ export interface AuthActorsProfileOptions {
313
+ actors: string[];
350
314
  env?: RuntimeEnv;
351
- headers?: LocalJsonHeaderOptions;
352
- identity?: LocalJsonActorIdentityConfig;
315
+ headers?: AuthProfileHeaderOptions<Record<string, unknown>>;
353
316
  options?: RuntimeOptions;
317
+ primaryActor?: string;
354
318
  }
355
319
 
356
- export interface LocalJsonMultiActorProfileOptions {
357
- actors?: string[] | Record<string, LocalJsonActorIdentityConfig>;
320
+ export interface AuthRawProfileOptions {
358
321
  env?: RuntimeEnv;
359
- headers?: LocalJsonHeaderOptions;
322
+ headers?: AuthProfileHeaderOptions;
360
323
  options?: RuntimeOptions;
361
- primaryActor?: string;
362
324
  }
363
325
 
364
- export interface LocalJsonRawProfileOptions {
365
- env?: RuntimeEnv;
366
- headers?: LocalJsonHeaderOptions;
367
- options?: RuntimeOptions;
326
+ export interface AuthActorProfileDescriptor {
327
+ kind: "actor";
328
+ actor: string;
329
+ }
330
+
331
+ export interface AuthActorsProfileDescriptor {
332
+ kind: "actors";
333
+ actors: string[];
334
+ primaryActor: string;
368
335
  }
369
336
 
370
- export interface LocalJsonProfileBuilder {
371
- multiActor(options?: LocalJsonMultiActorProfileOptions): HttpSuiteConfig<Record<string, Record<string, unknown>>>;
372
- raw(options?: LocalJsonRawProfileOptions): HttpSuiteConfig<any>;
373
- session(options?: LocalJsonSessionProfileOptions): HttpSuiteConfig<Record<string, unknown>>;
337
+ export interface AuthRawProfileDescriptor {
338
+ kind: "raw";
339
+ }
340
+
341
+ export type AuthProfileDescriptor =
342
+ | AuthActorProfileDescriptor
343
+ | AuthActorsProfileDescriptor
344
+ | AuthRawProfileDescriptor;
345
+
346
+ export interface AuthFixture {
347
+ contract: JsonSessionContract;
348
+ topology: AuthTopology;
349
+ profiles(definitions: Record<string, AuthProfileDescriptor>): Record<string, HttpSuiteConfig<any>>;
374
350
  }
375
351
 
376
352
  export interface NodeAppOptions extends Omit<ServiceConfig, "local" | "runtime" | "env"> {
@@ -449,12 +425,20 @@ export declare const database: {
449
425
  export declare const toolchain: {
450
426
  node(options?: NodeToolchainConfig): NodeToolchainConfig;
451
427
  };
452
- export declare const profiles: {
453
- custom<T extends HttpSuiteConfig>(profile: T): T;
454
- localJson(options?: LocalJsonProfileOptions): LocalJsonProfileBuilder;
455
- multiActor(options: MultiActorHttpProfileOptions): HttpSuiteConfig<Record<string, Record<string, unknown>>>;
456
- raw(options?: RawHttpProfileOptions): HttpSuiteConfig<any>;
457
- session(options: SessionHttpProfileOptions): HttpSuiteConfig<Record<string, unknown>>;
428
+ export declare const auth: {
429
+ fixture(options: { contract: JsonSessionContract; topology: AuthTopology }): AuthFixture;
430
+ contracts: {
431
+ jsonSession(options?: JsonSessionContractOptions): JsonSessionContract;
432
+ };
433
+ topologies: {
434
+ crossOrg(options: CrossOrgTopologyOptions): AuthTopology;
435
+ singleOrg(options: SingleOrgTopologyOptions): AuthTopology;
436
+ };
437
+ profile: {
438
+ actor(actorName: string, options?: AuthActorProfileOptions): AuthActorProfileDescriptor;
439
+ actors(options: AuthActorsProfileOptions): AuthActorsProfileDescriptor;
440
+ raw(options?: AuthRawProfileOptions): AuthRawProfileDescriptor;
441
+ };
458
442
  };
459
443
 
460
444
  export declare function registerRepoConfig(config: unknown): void;
@@ -9,12 +9,14 @@ import {
9
9
  runtimeJson,
10
10
  } from "./runtime.mjs";
11
11
  import {
12
- customProfile,
13
- localJsonProfile,
14
- multiActorProfile,
15
- rawProfile,
16
- sessionProfile,
17
- } from "./profiles.mjs";
12
+ actorProfile as createActorProfile,
13
+ actorsProfile as createActorsProfile,
14
+ authFixture as createAuthFixture,
15
+ crossOrgTopology as createCrossOrgTopology,
16
+ jsonSessionContract as createJsonSessionContract,
17
+ rawAuthProfile as createRawAuthProfile,
18
+ singleOrgTopology as createSingleOrgTopology,
19
+ } from "./auth-fixtures.mjs";
18
20
 
19
21
  export function defineConfig(config) {
20
22
  return config || {};
@@ -264,12 +266,20 @@ export const toolchain = {
264
266
  node: nodeToolchain,
265
267
  };
266
268
 
267
- export const profiles = {
268
- custom: customProfile,
269
- localJson: localJsonProfile,
270
- multiActor: multiActorProfile,
271
- raw: rawProfile,
272
- session: sessionProfile,
269
+ export const auth = {
270
+ fixture: createAuthFixture,
271
+ contracts: {
272
+ jsonSession: createJsonSessionContract,
273
+ },
274
+ topologies: {
275
+ crossOrg: createCrossOrgTopology,
276
+ singleOrg: createSingleOrgTopology,
277
+ },
278
+ profile: {
279
+ actor: createActorProfile,
280
+ actors: createActorsProfile,
281
+ raw: createRawAuthProfile,
282
+ },
273
283
  };
274
284
 
275
285
  export {