avantgate 1.2.0 → 1.2.1

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.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Declarative DTO Projection Helpers for avantgate/agent.
3
- * Standardizes common tool output projections (booleans, count, field pick)
4
- * to minimize LLM token consumption and prevent PII leakage.
3
+ * Standardizes common tool output projections (booleans, count, field pick, exhaustive projection)
4
+ * to minimize LLM token consumption, prevent PII leakage, and guard against schema drift.
5
5
  */
6
6
  export interface DtoBooleanResult {
7
7
  success: boolean;
@@ -10,6 +10,25 @@ export interface DtoCountResult {
10
10
  success: true;
11
11
  count: number;
12
12
  }
13
+ /**
14
+ * Type Guard ensuring compile-time exhaustiveness for DTO projections.
15
+ * Requires every key of TSource to be explicitly assigned to either 'keep' or 'drop'.
16
+ * Emits descriptive type errors (_unassignedSourceFields or _overlappingFields) upon discrepancy.
17
+ */
18
+ export type ExhaustiveProjectionConfig<TSource, TKeep extends keyof TSource, TDrop extends keyof TSource> = [Exclude<keyof TSource, TKeep | TDrop>] extends [never] ? [Extract<TKeep, TDrop>] extends [never] ? {
19
+ keep: readonly TKeep[];
20
+ drop: readonly TDrop[];
21
+ } : {
22
+ keep: readonly TKeep[];
23
+ drop: readonly TDrop[];
24
+ /** ❌ Compile Error: A field cannot be present in both 'keep' and 'drop' */
25
+ _overlappingFields: Extract<TKeep, TDrop>;
26
+ } : {
27
+ keep: readonly TKeep[];
28
+ drop: readonly TDrop[];
29
+ /** ❌ Compile Error: Unassigned source fields! You must explicitly add these keys to either 'keep' or 'drop' */
30
+ _unassignedSourceFields: Exclude<keyof TSource, TKeep | TDrop>;
31
+ };
13
32
  export declare const dto: {
14
33
  /**
15
34
  * Generates a boolean acknowledgment for mutations ({ success: true | false }).
@@ -25,8 +44,15 @@ export declare const dto: {
25
44
  */
26
45
  count: (arrayKey?: string) => (data: any) => DtoCountResult;
27
46
  /**
28
- * Filters raw output by extracting only a strict whitelist of allowed fields.
47
+ * Filters raw output by extracting only a whitelist of allowed fields.
48
+ * Supports optional TSource generic parameter for auto-completion.
49
+ */
50
+ pick: <TSource = any, K extends keyof TSource = any>(keys: readonly K[] | K[]) => (data: TSource) => Pick<TSource, K>;
51
+ /**
52
+ * Compile-time guarded exhaustive projection.
53
+ * Forces developers to explicitly classify every key of TSource as either 'keep' (sent to LLM)
54
+ * or 'drop' (ignored), preventing silent schema drift when source types evolve.
29
55
  */
30
- pick: <T extends string>(keys: readonly T[] | T[]) => (data: any) => Record<T, unknown>;
56
+ exhaustivePick: <TSource>() => <const TKeep extends keyof TSource, const TDrop extends keyof TSource>(config: ExhaustiveProjectionConfig<TSource, TKeep, TDrop>) => (data: TSource) => Pick<TSource, TKeep>;
31
57
  };
32
58
  //# sourceMappingURL=dto.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dto.d.ts","sourceRoot":"","sources":["../../src/agent/dto.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,IAAI,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,GAAG;IACd;;;OAGG;oBACa,MAAM,GAAG,KAAG,gBAAgB;IAI5C;;OAEG;oBACa,CAAC,SAAS,MAAM,iBAAgB,CAAC,MAC9C,MAAM,GAAG,KAAG,gBAAgB,GAAG,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC;IAMpD;;OAEG;uBAEW,MAAM,MACjB,MAAM,GAAG,KAAG,cAAc;IAQ7B;;OAEG;WAEA,CAAC,SAAS,MAAM,QAAQ,SAAS,CAAC,EAAE,GAAG,CAAC,EAAE,MAC1C,MAAM,GAAG,KAAG,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC;CAYlC,CAAC"}
1
+ {"version":3,"file":"dto.d.ts","sourceRoot":"","sources":["../../src/agent/dto.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AC,SAAS,MAAM,OAAO,cAAc,SAAS,CAAC,EAAE,GAAG,CAAC,EAAE,MACtE,MAAM,OAAO,KAAG,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAGnC;;;;OAIG;qBAEA,OAAO,QACP,KAAK,CAAC,KAAK,SAAS,MAAM,OAAO,EAAE,KAAK,CAAC,KAAK,SAAS,MAAM,OAAO,EACnE,QAAQ,0BAA0B,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,MAE1D,MAAM,OAAO,KAAG,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC;CAExC,CAAC"}
@@ -381,6 +381,18 @@ function createIsolatedTool(config) {
381
381
  }
382
382
 
383
383
  // src/agent/dto.ts
384
+ function extractWhitelistedFields(data, keys) {
385
+ const result = {};
386
+ if (!data || typeof data !== "object") {
387
+ return result;
388
+ }
389
+ for (const key of keys) {
390
+ if (key in data) {
391
+ result[key] = data[key];
392
+ }
393
+ }
394
+ return result;
395
+ }
384
396
  var dto = {
385
397
  /**
386
398
  * Generates a boolean acknowledgment for mutations ({ success: true | false }).
@@ -407,20 +419,16 @@ var dto = {
407
419
  };
408
420
  },
409
421
  /**
410
- * Filters raw output by extracting only a strict whitelist of allowed fields.
422
+ * Filters raw output by extracting only a whitelist of allowed fields.
423
+ * Supports optional TSource generic parameter for auto-completion.
411
424
  */
412
- pick: (keys) => (data) => {
413
- const result = {};
414
- if (!data || typeof data !== "object") {
415
- return result;
416
- }
417
- for (const key of keys) {
418
- if (key in data) {
419
- result[key] = data[key];
420
- }
421
- }
422
- return result;
423
- }
425
+ pick: (keys) => (data) => extractWhitelistedFields(data, keys),
426
+ /**
427
+ * Compile-time guarded exhaustive projection.
428
+ * Forces developers to explicitly classify every key of TSource as either 'keep' (sent to LLM)
429
+ * or 'drop' (ignored), preventing silent schema drift when source types evolve.
430
+ */
431
+ exhaustivePick: () => (config) => (data) => extractWhitelistedFields(data, config.keep)
424
432
  };
425
433
 
426
434
  // src/agent/factory.ts
@@ -278,6 +278,18 @@ function createIsolatedTool(config) {
278
278
  }
279
279
 
280
280
  // src/agent/dto.ts
281
+ function extractWhitelistedFields(data, keys) {
282
+ const result = {};
283
+ if (!data || typeof data !== "object") {
284
+ return result;
285
+ }
286
+ for (const key of keys) {
287
+ if (key in data) {
288
+ result[key] = data[key];
289
+ }
290
+ }
291
+ return result;
292
+ }
281
293
  var dto = {
282
294
  /**
283
295
  * Generates a boolean acknowledgment for mutations ({ success: true | false }).
@@ -304,20 +316,16 @@ var dto = {
304
316
  };
305
317
  },
306
318
  /**
307
- * Filters raw output by extracting only a strict whitelist of allowed fields.
319
+ * Filters raw output by extracting only a whitelist of allowed fields.
320
+ * Supports optional TSource generic parameter for auto-completion.
308
321
  */
309
- pick: (keys) => (data) => {
310
- const result = {};
311
- if (!data || typeof data !== "object") {
312
- return result;
313
- }
314
- for (const key of keys) {
315
- if (key in data) {
316
- result[key] = data[key];
317
- }
318
- }
319
- return result;
320
- }
322
+ pick: (keys) => (data) => extractWhitelistedFields(data, keys),
323
+ /**
324
+ * Compile-time guarded exhaustive projection.
325
+ * Forces developers to explicitly classify every key of TSource as either 'keep' (sent to LLM)
326
+ * or 'drop' (ignored), preventing silent schema drift when source types evolve.
327
+ */
328
+ exhaustivePick: () => (config) => (data) => extractWhitelistedFields(data, config.keep)
321
329
  };
322
330
 
323
331
  // src/agent/factory.ts
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import {
2
- sanitizePII
3
- } from "./chunk-DVCF4CSV.mjs";
4
1
  import {
5
2
  extractAndCleanJSON,
6
3
  validateWithZod
7
4
  } from "./chunk-CO26LNFD.mjs";
5
+ import {
6
+ sanitizePII
7
+ } from "./chunk-DVCF4CSV.mjs";
8
8
 
9
9
  // src/types.ts
10
10
  var ConfigurationError = class extends Error {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "avantgate",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Zero-infrastructure, in-process LLM control plane & SaaS observability bridge: real-time cost control, token budgets, PII redaction, prompt guardrails, multi-model failover, durable agent workflow harness, and HTTP telemetry without hosting heavy servers.",
5
5
  "author": "Antigravity & LexTalk Team",
6
6
  "license": "MIT",