avantgate 1.1.1 → 1.2.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 (94) hide show
  1. package/README.md +15 -398
  2. package/dist/agent/adapters/custom-adapter.d.ts +50 -0
  3. package/dist/agent/adapters/custom-adapter.d.ts.map +1 -0
  4. package/dist/agent/adapters/index.d.ts +6 -0
  5. package/dist/agent/adapters/index.d.ts.map +1 -0
  6. package/dist/agent/adapters/memory-adapter.d.ts +34 -0
  7. package/dist/agent/adapters/memory-adapter.d.ts.map +1 -0
  8. package/dist/agent/adapters/platform-adapter.d.ts +32 -0
  9. package/dist/agent/adapters/platform-adapter.d.ts.map +1 -0
  10. package/dist/agent/adapters/prisma-adapter.d.ts +55 -0
  11. package/dist/agent/adapters/prisma-adapter.d.ts.map +1 -0
  12. package/dist/agent/adapters/sqlite-adapter.d.ts +31 -0
  13. package/dist/agent/adapters/sqlite-adapter.d.ts.map +1 -0
  14. package/dist/agent/dto.d.ts +32 -0
  15. package/dist/agent/dto.d.ts.map +1 -0
  16. package/dist/agent/errors.d.ts +50 -0
  17. package/dist/agent/errors.d.ts.map +1 -0
  18. package/dist/agent/factory.d.ts +21 -0
  19. package/dist/agent/factory.d.ts.map +1 -0
  20. package/dist/agent/guardrails.d.ts +14 -0
  21. package/dist/agent/guardrails.d.ts.map +1 -0
  22. package/dist/agent/index.d.ts +17 -703
  23. package/dist/agent/index.d.ts.map +1 -0
  24. package/dist/agent/index.js +294 -30
  25. package/dist/agent/index.mjs +290 -29
  26. package/dist/agent/isolated-tool.d.ts +9 -0
  27. package/dist/agent/isolated-tool.d.ts.map +1 -0
  28. package/dist/agent/registry.d.ts +71 -0
  29. package/dist/agent/registry.d.ts.map +1 -0
  30. package/dist/agent/step-runner.d.ts +12 -0
  31. package/dist/agent/step-runner.d.ts.map +1 -0
  32. package/dist/agent/strategy.d.ts +37 -0
  33. package/dist/agent/strategy.d.ts.map +1 -0
  34. package/dist/agent/telemetry/http-exporter.d.ts +24 -0
  35. package/dist/agent/telemetry/http-exporter.d.ts.map +1 -0
  36. package/dist/agent/telemetry/index.d.ts +3 -0
  37. package/dist/agent/telemetry/index.d.ts.map +1 -0
  38. package/dist/agent/telemetry/types.d.ts +92 -0
  39. package/dist/agent/telemetry/types.d.ts.map +1 -0
  40. package/dist/agent/tool-invoker.d.ts +17 -0
  41. package/dist/agent/tool-invoker.d.ts.map +1 -0
  42. package/dist/agent/tool-state.d.ts +7 -0
  43. package/dist/agent/tool-state.d.ts.map +1 -0
  44. package/dist/agent/types.d.ts +243 -0
  45. package/dist/agent/types.d.ts.map +1 -0
  46. package/dist/control-layer.d.ts +49 -0
  47. package/dist/control-layer.d.ts.map +1 -0
  48. package/dist/finance/factory.d.ts +11 -0
  49. package/dist/finance/factory.d.ts.map +1 -0
  50. package/dist/finance/index.d.ts +9 -76
  51. package/dist/finance/index.d.ts.map +1 -0
  52. package/dist/finance/normalizer.d.ts +19 -0
  53. package/dist/finance/normalizer.d.ts.map +1 -0
  54. package/dist/finance/strategies/french-pcg.strategy.d.ts +10 -0
  55. package/dist/finance/strategies/french-pcg.strategy.d.ts.map +1 -0
  56. package/dist/finance/strategies/international.strategy.d.ts +10 -0
  57. package/dist/finance/strategies/international.strategy.d.ts.map +1 -0
  58. package/dist/finance/strategies/swiss-co.strategy.d.ts +10 -0
  59. package/dist/finance/strategies/swiss-co.strategy.d.ts.map +1 -0
  60. package/dist/finance/strategies/uk-ifrs.strategy.d.ts +10 -0
  61. package/dist/finance/strategies/uk-ifrs.strategy.d.ts.map +1 -0
  62. package/dist/finance/strategies/us-gaap.strategy.d.ts +10 -0
  63. package/dist/finance/strategies/us-gaap.strategy.d.ts.map +1 -0
  64. package/dist/{strategy.interface-CB4_ZAuk.d.ts → finance/strategy.interface.d.ts} +5 -6
  65. package/dist/finance/strategy.interface.d.ts.map +1 -0
  66. package/dist/index.d.ts +9 -390
  67. package/dist/index.d.ts.map +1 -0
  68. package/dist/input-guard.d.ts +13 -0
  69. package/dist/input-guard.d.ts.map +1 -0
  70. package/dist/pricing.d.ts +49 -0
  71. package/dist/pricing.d.ts.map +1 -0
  72. package/dist/prompts/index.d.ts +5 -0
  73. package/dist/prompts/index.d.ts.map +1 -0
  74. package/dist/prompts/prompt-builder.d.ts +31 -0
  75. package/dist/prompts/prompt-builder.d.ts.map +1 -0
  76. package/dist/prompts/prompt-registry.d.ts +13 -0
  77. package/dist/prompts/prompt-registry.d.ts.map +1 -0
  78. package/dist/prompts/prompt-template.d.ts +17 -0
  79. package/dist/prompts/prompt-template.d.ts.map +1 -0
  80. package/dist/prompts/types.d.ts +39 -0
  81. package/dist/prompts/types.d.ts.map +1 -0
  82. package/dist/providers/http-client.d.ts +18 -0
  83. package/dist/providers/http-client.d.ts.map +1 -0
  84. package/dist/response-validator.d.ts +18 -0
  85. package/dist/response-validator.d.ts.map +1 -0
  86. package/dist/sanitizer.d.ts +11 -0
  87. package/dist/sanitizer.d.ts.map +1 -0
  88. package/dist/types.d.ts +146 -0
  89. package/dist/types.d.ts.map +1 -0
  90. package/package.json +3 -3
  91. package/dist/agent/index.d.mts +0 -704
  92. package/dist/finance/index.d.mts +0 -76
  93. package/dist/index.d.mts +0 -390
  94. package/dist/strategy.interface-CB4_ZAuk.d.mts +0 -16
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Supported telemetry event types for the avantGate observability platform.
3
+ */
4
+ export type TelemetryEventType = "STEP_START" | "STEP_COMPLETED" | "STEP_FAILED" | "STEP_APPROVAL_REQUEST" | "TOOL_EXECUTION";
5
+ /**
6
+ * Base properties shared across all telemetry events.
7
+ */
8
+ export interface BaseTelemetryEvent {
9
+ type: TelemetryEventType;
10
+ timestamp: string;
11
+ }
12
+ export interface StepStartEvent extends BaseTelemetryEvent {
13
+ type: "STEP_START";
14
+ stepName: string;
15
+ metadata?: Record<string, unknown>;
16
+ }
17
+ export interface StepCompletedEvent extends BaseTelemetryEvent {
18
+ type: "STEP_COMPLETED";
19
+ stepName: string;
20
+ durationMs?: number;
21
+ piiDetectedCount?: number;
22
+ resultSummary?: unknown;
23
+ metadata?: Record<string, unknown>;
24
+ }
25
+ export interface StepFailedEvent extends BaseTelemetryEvent {
26
+ type: "STEP_FAILED";
27
+ stepName: string;
28
+ durationMs?: number;
29
+ error: string;
30
+ }
31
+ export interface StepApprovalRequestEvent extends BaseTelemetryEvent {
32
+ type: "STEP_APPROVAL_REQUEST";
33
+ stepName: string;
34
+ actionType?: string;
35
+ payloadSummary?: unknown;
36
+ }
37
+ export interface ToolExecutionTelemetryEvent extends BaseTelemetryEvent {
38
+ type: "TOOL_EXECUTION";
39
+ toolId: string;
40
+ toolName: string;
41
+ aliasUsed?: string;
42
+ durationMs: number;
43
+ success: boolean;
44
+ parentToolId?: string;
45
+ depth?: number;
46
+ llmSummary?: unknown;
47
+ piiFilteredCount?: number;
48
+ tokenCount?: number;
49
+ tokens?: {
50
+ promptTokens?: number;
51
+ completionTokens?: number;
52
+ totalTokens?: number;
53
+ };
54
+ costUsd?: number;
55
+ cached?: boolean;
56
+ error?: string;
57
+ }
58
+ export type TelemetryEvent = StepStartEvent | StepCompletedEvent | StepFailedEvent | StepApprovalRequestEvent | ToolExecutionTelemetryEvent;
59
+ /**
60
+ * Consolidates token usage and FinOps metrics for a batch or run.
61
+ */
62
+ export interface TelemetryUsageSummary {
63
+ model?: string;
64
+ promptTokens?: number;
65
+ completionTokens?: number;
66
+ totalTokens?: number;
67
+ costUsd?: number;
68
+ }
69
+ /**
70
+ * Payload schema ingested by POST /api/v1/ingest/events according to DESIGN-005 §5.1.
71
+ */
72
+ export interface TelemetryIngestPayload {
73
+ runId: string;
74
+ agentName?: string;
75
+ timestamp: string;
76
+ events: TelemetryEvent[];
77
+ usage?: TelemetryUsageSummary;
78
+ }
79
+ /**
80
+ * Configuration options for the HTTP Telemetry Exporter.
81
+ */
82
+ export interface HttpTelemetryExporterOptions {
83
+ apiKey: string;
84
+ endpoint?: string;
85
+ agentName?: string;
86
+ batchIntervalMs?: number;
87
+ maxBatchSize?: number;
88
+ maxQueueSize?: number;
89
+ fetchFn?: typeof fetch;
90
+ onError?: (error: Error) => void;
91
+ }
92
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/agent/telemetry/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,YAAY,GACZ,gBAAgB,GAChB,aAAa,GACb,uBAAuB,GACvB,gBAAgB,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,kBAAkB,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAe,SAAQ,kBAAkB;IACxD,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D,IAAI,EAAE,gBAAgB,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,eAAgB,SAAQ,kBAAkB;IACzD,IAAI,EAAE,aAAa,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,wBAAyB,SAAQ,kBAAkB;IAClE,IAAI,EAAE,uBAAuB,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAA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AC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;IACvB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC"}
@@ -0,0 +1,17 @@
1
+ import { ToolRegistry } from "./registry";
2
+ import type { StepStorageAdapter, ToolExecutionContext } from "./types";
3
+ export interface ToolInvokerOptions {
4
+ maxDepth?: number;
5
+ maxTotalSubCalls?: number;
6
+ workflowId?: string;
7
+ stepId?: string;
8
+ }
9
+ export interface ToolInvoker {
10
+ invokeTool<TResult = unknown>(toolId: string, args: unknown, context?: ToolExecutionContext): Promise<TResult>;
11
+ }
12
+ /**
13
+ * Creates an intelligent, concurrency-safe tool invoker with cycle detection,
14
+ * depth guard, result caching, and database execution tracing.
15
+ */
16
+ export declare function createToolInvoker(registry: ToolRegistry, storage?: StepStorageAdapter, options?: ToolInvokerOptions): ToolInvoker;
17
+ //# sourceMappingURL=tool-invoker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-invoker.d.ts","sourceRoot":"","sources":["../../src/agent/tool-invoker.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EAErB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,OAAO,GAAG,OAAO,EAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB;AA0CD;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,YAAY,EACtB,OAAO,CAAC,EAAE,kBAAkB,EAC5B,OAAO,GAAE,kBAAuB,GAC/B,WAAW,CAqHb"}
@@ -0,0 +1,7 @@
1
+ import type { StepStorageAdapter, ToolSharedState } from "./types";
2
+ /**
3
+ * Creates a shared blackboard state instance for inter-tool data sharing.
4
+ * Backed by the persistent storage adapter if available, otherwise runs in-memory.
5
+ */
6
+ export declare function createToolSharedState(storage?: StepStorageAdapter): ToolSharedState;
7
+ //# sourceMappingURL=tool-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-state.d.ts","sourceRoot":"","sources":["../../src/agent/tool-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAOnE;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,CAAC,EAAE,kBAAkB,GAC3B,eAAe,CAgDjB"}
@@ -0,0 +1,243 @@
1
+ import type { z } from "zod";
2
+ /**
3
+ * Lifecycle status for durable agent workflow steps.
4
+ */
5
+ export type StepStatus = "PENDING" | "RUNNING" | "COMPLETED" | "FAILED" | "WAITING_APPROVAL";
6
+ /**
7
+ * Token usage metrics for LLM calls and tool executions.
8
+ */
9
+ export interface TokenUsage {
10
+ promptTokens?: number;
11
+ completionTokens?: number;
12
+ totalTokens?: number;
13
+ }
14
+ /**
15
+ * Record representing a durable step stored in persistence.
16
+ */
17
+ export interface StepRecord<TResult = unknown> {
18
+ workflowId: string;
19
+ stepId: string;
20
+ runId?: string;
21
+ status: StepStatus;
22
+ result?: TResult;
23
+ error?: string;
24
+ piiDetectedCount?: number;
25
+ tokens?: TokenUsage;
26
+ costUsd?: number;
27
+ metadata?: Record<string, unknown>;
28
+ createdAt: string;
29
+ updatedAt: string;
30
+ }
31
+ /**
32
+ * Record representing a durable tool execution stored in persistence for hierarchical tracing.
33
+ */
34
+ export interface ToolExecutionRecord {
35
+ executionId: string;
36
+ workflowId?: string;
37
+ stepId?: string;
38
+ runId?: string;
39
+ toolId: string;
40
+ parentToolId?: string;
41
+ aliasUsed?: string;
42
+ depth: number;
43
+ inputArgs?: unknown;
44
+ outputSummary?: unknown;
45
+ durationMs: number;
46
+ status: "SUCCESS" | "FAILED";
47
+ error?: string;
48
+ cached?: boolean;
49
+ piiFilteredCount?: number;
50
+ tokens?: TokenUsage;
51
+ costUsd?: number;
52
+ createdAt: string;
53
+ }
54
+ /**
55
+ * Shared Blackboard state interface enabling inter-tool data exchange without context pollution.
56
+ */
57
+ export interface ToolSharedState {
58
+ get<T = unknown>(key: string): Promise<T | null>;
59
+ set<T = unknown>(key: string, value: T, ttlSeconds?: number): Promise<void>;
60
+ delete(key: string): Promise<void>;
61
+ clear?(): Promise<void>;
62
+ }
63
+ /**
64
+ * Hexagonal Port Interface: Pure abstract storage contract.
65
+ * Any storage backend (Prisma, Drizzle, Kysely, SQLite, Mongo, Redis, Supabase)
66
+ * can plug into avantgate/agent by implementing this contract.
67
+ */
68
+ export interface StepStorageAdapter {
69
+ getStep<T = unknown>(workflowId: string, stepId: string): Promise<StepRecord<T> | null>;
70
+ saveStep<T = unknown>(step: StepRecord<T>): Promise<void>;
71
+ updateStepStatus<T = unknown>(workflowId: string, stepId: string, status: StepStatus, patch?: Partial<StepRecord<T>>): Promise<void>;
72
+ listSteps(workflowId: string): Promise<StepRecord[]>;
73
+ saveToolExecution?(record: ToolExecutionRecord): Promise<void>;
74
+ listToolExecutions?(workflowId?: string, stepId?: string): Promise<ToolExecutionRecord[]>;
75
+ getCachedToolResult?<T = unknown>(cacheKey: string): Promise<T | null>;
76
+ setCachedToolResult?<T = unknown>(cacheKey: string, result: T, ttlSeconds: number): Promise<void>;
77
+ getStateValue?<T = unknown>(key: string): Promise<T | null>;
78
+ setStateValue?<T = unknown>(key: string, value: T, ttlSeconds?: number): Promise<void>;
79
+ deleteStateValue?(key: string): Promise<void>;
80
+ clearStateValues?(): Promise<void>;
81
+ }
82
+ /**
83
+ * Options for step approval in Human-in-the-Loop workflows.
84
+ */
85
+ export interface StepApprovalOptions<T = unknown> {
86
+ prompt?: string;
87
+ metadata?: Record<string, unknown>;
88
+ defaultResult?: T;
89
+ }
90
+ /**
91
+ * Execution context passed to workflow handlers.
92
+ */
93
+ export interface StepRunnerContext {
94
+ workflowId: string;
95
+ run<T>(stepId: string, executeFn: () => Promise<T>): Promise<T>;
96
+ waitForApproval<T = unknown>(stepId: string, options?: StepApprovalOptions<T>): Promise<T>;
97
+ }
98
+ /**
99
+ * Configuration options for creating a durable step runner.
100
+ */
101
+ export interface StepRunnerConfig {
102
+ workflowId: string;
103
+ runId?: string;
104
+ storage?: StepStorageAdapter;
105
+ }
106
+ /**
107
+ * Context received by tool execution, supporting inter-tool chaining and shared state.
108
+ */
109
+ export interface ToolExecutionContext {
110
+ toolCallId?: string;
111
+ messages?: unknown[];
112
+ abortSignal?: AbortSignal;
113
+ workflowId?: string;
114
+ runId?: string;
115
+ stepId?: string;
116
+ callChain?: readonly string[];
117
+ callTool?: <TResult = unknown>(toolId: string, args: unknown) => Promise<TResult>;
118
+ state?: ToolSharedState;
119
+ storage?: StepStorageAdapter;
120
+ tokens?: TokenUsage;
121
+ costUsd?: number;
122
+ onInvalidationTags?: (tags: string[]) => void | Promise<void>;
123
+ [key: string]: unknown;
124
+ }
125
+ /**
126
+ * User and environment context injected into tools.
127
+ */
128
+ export interface ToolContext {
129
+ userId?: string;
130
+ tenantId?: string;
131
+ role?: string;
132
+ roles?: string[];
133
+ permissions?: string[];
134
+ phase?: string;
135
+ metadata?: Record<string, unknown>;
136
+ [key: string]: unknown;
137
+ }
138
+ /**
139
+ * Projection function converting raw tool result, input arguments and execution context
140
+ * into a safe, minimal LLM DTO.
141
+ */
142
+ export type LLMDtoMapper<TArgs = any, TResult = any, TLLMDto = unknown> = (result: TResult, args: TArgs, context?: ToolExecutionContext) => TLLMDto | Promise<TLLMDto>;
143
+ /**
144
+ * Out-of-band callback streaming raw or rich tool data directly to the client UI.
145
+ */
146
+ export type ClientDtoCallback<TResult = unknown> = (data: TResult) => void | Promise<void>;
147
+ /**
148
+ * Universal resource invalidation tags generator (string[] or function).
149
+ */
150
+ export type InvalidationTagsResolver<TArgs = any, TResult = any> = string[] | ((args: TArgs, result?: TResult) => string[] | Promise<string[]>);
151
+ /**
152
+ * Guardrail hook for data access control (anti-IDOR) executed prior to tool execution.
153
+ */
154
+ export type DataAccessGuard<TArgs = any> = (args: TArgs, context?: ToolExecutionContext) => boolean | Promise<boolean>;
155
+ /**
156
+ * Configuration for creating an isolated tool with PII protection, Dual-Channel DTO,
157
+ * access governance, stable ID, aliasing and caching.
158
+ */
159
+ export interface IsolatedToolConfig<TArgs = any, TResult = any, TLLMDto = unknown, TClientDto = TResult> {
160
+ id?: string;
161
+ name: string;
162
+ alias?: string;
163
+ description: string;
164
+ domain?: string;
165
+ resource?: string;
166
+ roles?: string[];
167
+ permissions?: string[];
168
+ requireApproval?: boolean;
169
+ dataAccessGuard?: DataAccessGuard<TArgs>;
170
+ invalidationTags?: InvalidationTagsResolver<TArgs, TResult>;
171
+ parameters: z.ZodType<TArgs> | unknown;
172
+ cacheTTL?: number;
173
+ execute: (args: TArgs, context?: ToolExecutionContext) => Promise<TResult>;
174
+ llmDto?: LLMDtoMapper<TArgs, TResult, TLLMDto>;
175
+ clientDto?: ClientDtoCallback<TClientDto>;
176
+ llmDtoSchema?: z.ZodType<TLLMDto>;
177
+ sanitizePii?: boolean;
178
+ throwOnPii?: boolean;
179
+ }
180
+ /**
181
+ * Standard tool contract compatible with Vercel AI SDK (ai) tool definition.
182
+ */
183
+ export interface VercelAiCoreTool<TArgs = any, TResult = any> {
184
+ description: string;
185
+ parameters: any;
186
+ execute: (args: TArgs, context?: ToolExecutionContext) => Promise<TResult>;
187
+ /**
188
+ * Internal identifiers and metadata.
189
+ */
190
+ readonly _toolId: string;
191
+ readonly _toolName: string;
192
+ readonly _toolAlias?: string;
193
+ readonly _isIsolated: boolean;
194
+ readonly _cacheTTL?: number;
195
+ readonly _domain?: string;
196
+ readonly _resource?: string;
197
+ readonly _roles?: readonly string[];
198
+ readonly _permissions?: readonly string[];
199
+ readonly _requireApproval?: boolean;
200
+ _lastPiiFilteredCount?: number;
201
+ _lastInvalidationTags?: string[];
202
+ }
203
+ /**
204
+ * Metadata and descriptor for registered tools in the registry.
205
+ */
206
+ export interface RegisteredTool<TArgs = any, TResult = any> {
207
+ id: string;
208
+ name: string;
209
+ alias?: string;
210
+ description: string;
211
+ domain?: string;
212
+ resource?: string;
213
+ roles?: string[];
214
+ permissions?: string[];
215
+ phases?: string[];
216
+ requiredRoles?: string[];
217
+ tags?: string[];
218
+ requireApproval?: boolean;
219
+ tool: VercelAiCoreTool<TArgs, TResult>;
220
+ }
221
+ /**
222
+ * Pure technical descriptor exportable to client applications without UI coupling.
223
+ */
224
+ export interface ToolDescriptor {
225
+ id: string;
226
+ name: string;
227
+ alias?: string;
228
+ description: string;
229
+ domain?: string;
230
+ resource?: string;
231
+ roles?: string[];
232
+ permissions?: string[];
233
+ requireApproval?: boolean;
234
+ cacheTTL?: number;
235
+ tags?: string[];
236
+ }
237
+ /**
238
+ * Strategy interface for dynamically selecting a subset of tools for LLM prompts.
239
+ */
240
+ export interface ToolSelectionStrategy {
241
+ selectTools(tools: RegisteredTool[], context: ToolContext): RegisteredTool[] | Promise<RegisteredTool[]>;
242
+ }
243
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/agent/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,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AAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,WAAW,CACT,KAAK,EAAE,cAAc,EAAE,EACvB,OAAO,EAAE,WAAW,GACnB,cAAc,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;CACjD"}
@@ -0,0 +1,49 @@
1
+ import { z } from "zod";
2
+ import type { ControlLayerConfig, ExecutionResult, StructuredExecutionResult, GenerateStructuredOutputOptions, LLMProviderPort } from "./types";
3
+ export declare class AvantGateControlLayer {
4
+ private config;
5
+ private cachedPricingAdapter?;
6
+ constructor(config: ControlLayerConfig);
7
+ private resolveProviderConfig;
8
+ private findProviderConfig;
9
+ private calculateCost;
10
+ private applySecurityGuards;
11
+ private checkPreflightBudget;
12
+ private checkPostExecutionBudget;
13
+ private buildMessages;
14
+ private resolveTokens;
15
+ private getProviderChain;
16
+ private executeSimulation;
17
+ private executeOverrideProvider;
18
+ private executeProviderPipeline;
19
+ private assembleResult;
20
+ private notifyAuditSink;
21
+ /**
22
+ * Exécute une requête avec garde d'entrée, masquage PII, garde pré-vol et calcul des coûts.
23
+ */
24
+ execute(options: {
25
+ userQuery: string;
26
+ systemPrompt?: string;
27
+ temperature?: number;
28
+ providerOverride?: LLMProviderPort;
29
+ }): Promise<ExecutionResult>;
30
+ /**
31
+ * Exécute une requête et valide/répare le résultat selon un schéma Zod.
32
+ */
33
+ executeStructured<T>(options: {
34
+ userQuery: string;
35
+ systemPrompt?: string;
36
+ schema: z.ZodType<T>;
37
+ temperature?: number;
38
+ providerOverride?: LLMProviderPort;
39
+ }): Promise<StructuredExecutionResult<T>>;
40
+ /**
41
+ * Méthode unifiée de premier niveau pour l'extraction structurée sans code boilerplate.
42
+ * Gère le failover multi-fournisseurs, les retries, la validation Zod et la normalisation financière.
43
+ */
44
+ generateStructuredOutput<T>(options: GenerateStructuredOutputOptions<T>): Promise<StructuredExecutionResult<T>>;
45
+ }
46
+ export declare function createLLMControlLayer(config: ControlLayerConfig): AvantGateControlLayer;
47
+ export declare const createAvantGate: typeof createLLMControlLayer;
48
+ export { AvantGateControlLayer as ZenLLMControlLayer };
49
+ //# sourceMappingURL=control-layer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control-layer.d.ts","sourceRoot":"","sources":["../src/control-layer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EACV,kBAAkB,EAClB,eAAe,EACf,yBAAyB,EACzB,+BAA+B,EAC/B,eAAe,EAIhB,MAAM,SAAS,CAAC;AAgBjB,qBAAa,qBAAqB;IAChC,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,oBAAoB,CAAC,CAAuB;gBAExC,MAAM,EAAE,kBAAkB;IAgBtC,OAAO,CAAC,qBAAqB;IAY7B,OAAO,CAAC,kBAAkB;IAe1B,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,mBAAmB;IAiB3B,OAAO,CAAC,oBAAoB;IAgC5B,OAAO,CAAC,wBAAwB;IAahC,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,iBAAiB;YAmBX,uBAAuB;YAqBvB,uBAAuB;IAiCrC,OAAO,CAAC,cAAc;YAsBR,eAAe;IAe7B;;OAEG;IACG,OAAO,CAAC,OAAO,EAAE;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,gBAAgB,CAAC,EAAE,eAAe,CAAC;KACpC,GAAG,OAAO,CAAC,eAAe,CAAC;IA6B5B;;OAEG;IACG,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE;QAClC,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,gBAAgB,CAAC,EAAE,eAAe,CAAC;KACpC,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC;IA2BzC;;;OAGG;IACG,wBAAwB,CAAC,CAAC,EAC9B,OAAO,EAAE,+BAA+B,CAAC,CAAC,CAAC,GAC1C,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC;CAsHzC;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,kBAAkB,GAAG,qBAAqB,CAEvF;AAED,eAAO,MAAM,eAAe,8BAAwB,CAAC;AACrD,OAAO,EAAE,qBAAqB,IAAI,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { IAccountingStrategy, FinancialJurisdictionCode } from "./strategy.interface";
2
+ export declare class AccountingFactory {
3
+ private static strategies;
4
+ private static detectionOrder;
5
+ private static initDefaults;
6
+ static registerStrategy(strategy: IAccountingStrategy): void;
7
+ static getStrategy(code?: FinancialJurisdictionCode): IAccountingStrategy;
8
+ static detectStrategy(documentText: string): IAccountingStrategy;
9
+ static resetDefaults(): void;
10
+ }
11
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/finance/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,sBAAsB,CAAC;AAO9B,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAC,UAAU,CAAkE;IAC3F,OAAO,CAAC,MAAM,CAAC,cAAc,CAA6B;IAM1D,OAAO,CAAC,MAAM,CAAC,YAAY;WAcb,gBAAgB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI;WASrD,WAAW,CAAC,IAAI,CAAC,EAAE,yBAAyB,GAAG,mBAAmB;WAWlE,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,mBAAmB;WASzD,aAAa,IAAI,IAAI;CAKpC"}
@@ -1,76 +1,9 @@
1
- import { I as IAccountingStrategy, F as FinancialJurisdictionCode, A as AccountingStandard, a as FinancialCurrency } from '../strategy.interface-CB4_ZAuk.js';
2
-
3
- declare class AccountingFactory {
4
- private static strategies;
5
- private static detectionOrder;
6
- private static initDefaults;
7
- static registerStrategy(strategy: IAccountingStrategy): void;
8
- static getStrategy(code?: FinancialJurisdictionCode): IAccountingStrategy;
9
- static detectStrategy(documentText: string): IAccountingStrategy;
10
- static resetDefaults(): void;
11
- }
12
-
13
- interface FinancialNormalizerOptions {
14
- jurisdiction?: FinancialJurisdictionCode;
15
- autoDetect?: boolean;
16
- }
17
- /**
18
- * Assainit et répare une chaîne JSON contenant des données financières :
19
- * - Notation comptable négative entre parenthèses : (150 000) -> -150000
20
- * - Espaces et virgules décimales : "1 850 000,50 €" -> 1850000.50
21
- * - Abréviations de grandeurs : "1 850 k€" -> 1850000, "2.4 M€" -> 2400000
22
- * - Suppression des symboles de devises dans les positions numériques
23
- * - Préservation stricte des chaînes descriptives normales contenant des parenthèses
24
- */
25
- declare function cleanFinancialJSON(rawText: string, options?: FinancialNormalizerOptions): string;
26
- /**
27
- * Crée une fonction de transformation financière réutilisable.
28
- */
29
- declare function withFinancialNormalizer(options?: FinancialNormalizerOptions): (rawText: string) => string;
30
-
31
- declare class FrenchPCGStrategy implements IAccountingStrategy {
32
- readonly jurisdictionCode: FinancialJurisdictionCode;
33
- readonly standard: AccountingStandard;
34
- readonly defaultCurrency: FinancialCurrency;
35
- cleanNumber(value: string | number): number;
36
- cleanJSON(rawText: string): string;
37
- detect(text: string): boolean;
38
- }
39
-
40
- declare class UsGAAPStrategy implements IAccountingStrategy {
41
- readonly jurisdictionCode: FinancialJurisdictionCode;
42
- readonly standard: AccountingStandard;
43
- readonly defaultCurrency: FinancialCurrency;
44
- cleanNumber(value: string | number): number;
45
- cleanJSON(rawText: string): string;
46
- detect(text: string): boolean;
47
- }
48
-
49
- declare class UkIFRSStrategy implements IAccountingStrategy {
50
- readonly jurisdictionCode: FinancialJurisdictionCode;
51
- readonly standard: AccountingStandard;
52
- readonly defaultCurrency: FinancialCurrency;
53
- cleanNumber(value: string | number): number;
54
- cleanJSON(rawText: string): string;
55
- detect(text: string): boolean;
56
- }
57
-
58
- declare class SwissCOStrategy implements IAccountingStrategy {
59
- readonly jurisdictionCode: FinancialJurisdictionCode;
60
- readonly standard: AccountingStandard;
61
- readonly defaultCurrency: FinancialCurrency;
62
- cleanNumber(value: string | number): number;
63
- cleanJSON(rawText: string): string;
64
- detect(text: string): boolean;
65
- }
66
-
67
- declare class InternationalAccountingStrategy implements IAccountingStrategy {
68
- readonly jurisdictionCode: FinancialJurisdictionCode;
69
- readonly standard: AccountingStandard;
70
- readonly defaultCurrency: FinancialCurrency;
71
- cleanNumber(value: string | number): number;
72
- cleanJSON(rawText: string): string;
73
- detect(_text: string): boolean;
74
- }
75
-
76
- export { AccountingFactory, AccountingStandard, FinancialCurrency, FinancialJurisdictionCode, type FinancialNormalizerOptions, FrenchPCGStrategy, IAccountingStrategy, InternationalAccountingStrategy, SwissCOStrategy, UkIFRSStrategy, UsGAAPStrategy, cleanFinancialJSON, withFinancialNormalizer };
1
+ export * from "./strategy.interface";
2
+ export * from "./factory";
3
+ export * from "./normalizer";
4
+ export * from "./strategies/french-pcg.strategy";
5
+ export * from "./strategies/us-gaap.strategy";
6
+ export * from "./strategies/uk-ifrs.strategy";
7
+ export * from "./strategies/swiss-co.strategy";
8
+ export * from "./strategies/international.strategy";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/finance/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qCAAqC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { FinancialJurisdictionCode } from "./strategy.interface";
2
+ export interface FinancialNormalizerOptions {
3
+ jurisdiction?: FinancialJurisdictionCode;
4
+ autoDetect?: boolean;
5
+ }
6
+ /**
7
+ * Assainit et répare une chaîne JSON contenant des données financières :
8
+ * - Notation comptable négative entre parenthèses : (150 000) -> -150000
9
+ * - Espaces et virgules décimales : "1 850 000,50 €" -> 1850000.50
10
+ * - Abréviations de grandeurs : "1 850 k€" -> 1850000, "2.4 M€" -> 2400000
11
+ * - Suppression des symboles de devises dans les positions numériques
12
+ * - Préservation stricte des chaînes descriptives normales contenant des parenthèses
13
+ */
14
+ export declare function cleanFinancialJSON(rawText: string, options?: FinancialNormalizerOptions): string;
15
+ /**
16
+ * Crée une fonction de transformation financière réutilisable.
17
+ */
18
+ export declare function withFinancialNormalizer(options?: FinancialNormalizerOptions): (rawText: string) => string;
19
+ //# sourceMappingURL=normalizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../../src/finance/normalizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAItE,MAAM,WAAW,0BAA0B;IACzC,YAAY,CAAC,EAAE,yBAAyB,CAAC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,0BAA0B,GACnC,MAAM,CAiBR;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,CAAC,EAAE,0BAA0B,GACnC,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAE7B"}
@@ -0,0 +1,10 @@
1
+ import type { IAccountingStrategy, FinancialJurisdictionCode, AccountingStandard, FinancialCurrency } from "../strategy.interface";
2
+ export declare class FrenchPCGStrategy implements IAccountingStrategy {
3
+ readonly jurisdictionCode: FinancialJurisdictionCode;
4
+ readonly standard: AccountingStandard;
5
+ readonly defaultCurrency: FinancialCurrency;
6
+ cleanNumber(value: string | number): number;
7
+ cleanJSON(rawText: string): string;
8
+ detect(text: string): boolean;
9
+ }
10
+ //# sourceMappingURL=french-pcg.strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"french-pcg.strategy.d.ts","sourceRoot":"","sources":["../../../src/finance/strategies/french-pcg.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAE/B,qBAAa,iBAAkB,YAAW,mBAAmB;IAC3D,QAAQ,CAAC,gBAAgB,EAAE,yBAAyB,CAAQ;IAC5D,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAS;IAC9C,QAAQ,CAAC,eAAe,EAAE,iBAAiB,CAAS;IAE7C,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IA8C3C,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAkDlC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAkBrC"}
@@ -0,0 +1,10 @@
1
+ import type { IAccountingStrategy, FinancialJurisdictionCode, AccountingStandard, FinancialCurrency } from "../strategy.interface";
2
+ export declare class InternationalAccountingStrategy implements IAccountingStrategy {
3
+ readonly jurisdictionCode: FinancialJurisdictionCode;
4
+ readonly standard: AccountingStandard;
5
+ readonly defaultCurrency: FinancialCurrency;
6
+ cleanNumber(value: string | number): number;
7
+ cleanJSON(rawText: string): string;
8
+ detect(_text: string): boolean;
9
+ }
10
+ //# sourceMappingURL=international.strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"international.strategy.d.ts","sourceRoot":"","sources":["../../../src/finance/strategies/international.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAE/B,qBAAa,+BAAgC,YAAW,mBAAmB;IACzE,QAAQ,CAAC,gBAAgB,EAAE,yBAAyB,CAAmB;IACvE,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAW;IAChD,QAAQ,CAAC,eAAe,EAAE,iBAAiB,CAAS;IAE7C,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IA4D3C,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAsBlC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGtC"}
@@ -0,0 +1,10 @@
1
+ import type { IAccountingStrategy, FinancialJurisdictionCode, AccountingStandard, FinancialCurrency } from "../strategy.interface";
2
+ export declare class SwissCOStrategy implements IAccountingStrategy {
3
+ readonly jurisdictionCode: FinancialJurisdictionCode;
4
+ readonly standard: AccountingStandard;
5
+ readonly defaultCurrency: FinancialCurrency;
6
+ cleanNumber(value: string | number): number;
7
+ cleanJSON(rawText: string): string;
8
+ detect(text: string): boolean;
9
+ }
10
+ //# sourceMappingURL=swiss-co.strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swiss-co.strategy.d.ts","sourceRoot":"","sources":["../../../src/finance/strategies/swiss-co.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAE/B,qBAAa,eAAgB,YAAW,mBAAmB;IACzD,QAAQ,CAAC,gBAAgB,EAAE,yBAAyB,CAAQ;IAC5D,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAc;IACnD,QAAQ,CAAC,eAAe,EAAE,iBAAiB,CAAS;IAE7C,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IA2C3C,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAiClC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAYrC"}
@@ -0,0 +1,10 @@
1
+ import type { IAccountingStrategy, FinancialJurisdictionCode, AccountingStandard, FinancialCurrency } from "../strategy.interface";
2
+ export declare class UkIFRSStrategy implements IAccountingStrategy {
3
+ readonly jurisdictionCode: FinancialJurisdictionCode;
4
+ readonly standard: AccountingStandard;
5
+ readonly defaultCurrency: FinancialCurrency;
6
+ cleanNumber(value: string | number): number;
7
+ cleanJSON(rawText: string): string;
8
+ detect(text: string): boolean;
9
+ }
10
+ //# sourceMappingURL=uk-ifrs.strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uk-ifrs.strategy.d.ts","sourceRoot":"","sources":["../../../src/finance/strategies/uk-ifrs.strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAE/B,qBAAa,cAAe,YAAW,mBAAmB;IACxD,QAAQ,CAAC,gBAAgB,EAAE,yBAAyB,CAAQ;IAC5D,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAU;IAC/C,QAAQ,CAAC,eAAe,EAAE,iBAAiB,CAAS;IAE7C,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IAwC3C,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAiClC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAYrC"}
@@ -0,0 +1,10 @@
1
+ import type { IAccountingStrategy, FinancialJurisdictionCode, AccountingStandard, FinancialCurrency } from "../strategy.interface";
2
+ export declare class UsGAAPStrategy implements IAccountingStrategy {
3
+ readonly jurisdictionCode: FinancialJurisdictionCode;
4
+ readonly standard: AccountingStandard;
5
+ readonly defaultCurrency: FinancialCurrency;
6
+ cleanNumber(value: string | number): number;
7
+ cleanJSON(rawText: string): string;
8
+ detect(text: string): boolean;
9
+ }
10
+ //# sourceMappingURL=us-gaap.strategy.d.ts.map