@agentguard-run/spend 0.1.3 → 0.1.4
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/README.es-419.md +128 -0
- package/README.md +2 -0
- package/README.pt-BR.md +128 -0
- package/dist/i18n.d.ts +41 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/i18n.js +210 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/spend-guard.d.ts +7 -1
- package/dist/spend-guard.d.ts.map +1 -1
- package/dist/spend-guard.js +23 -4
- package/dist/spend-guard.js.map +1 -1
- package/package.json +1 -1
package/README.es-419.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# @agentguard-run/spend
|
|
2
|
+
|
|
3
|
+
> Límites de gasto de tiempo de ejecución local y enrutamiento de modelos con capacidades para agentes de IA.
|
|
4
|
+
|
|
5
|
+
Cada decisión de política se ejecuta dentro de su proceso. Los prompts, claves API del proveedor y claves de firma nunca salen de su entorno de ejecución. Cada decisión de aplicación produce un recibo firmado con Ed25519, encadenado por hash, apto para auditoría y revisión de cumplimiento.
|
|
6
|
+
|
|
7
|
+
> Disponible también en: [English](README.md) · [Português (BR)](README.pt-BR.md)
|
|
8
|
+
|
|
9
|
+
## Por qué sin proxy
|
|
10
|
+
|
|
11
|
+
Cada competidor financiado en gobernanza del gasto en IA (Portkey, Helicone, LiteLLM, Cloudflare AI Gateway, Vercel AI Gateway) usa proxy sobre su tráfico. Eso significa que sus prompts y claves de proveedor pasan por la infraestructura de ellos. `@agentguard-run/spend` nunca ve nada de eso. La política corre en su proceso. El registro firmado vive en su almacenamiento.
|
|
12
|
+
|
|
13
|
+
## Instalación
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @agentguard-run/spend
|
|
17
|
+
# o
|
|
18
|
+
pnpm add @agentguard-run/spend
|
|
19
|
+
# o
|
|
20
|
+
yarn add @agentguard-run/spend
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Inicio rápido
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import OpenAI from 'openai';
|
|
27
|
+
import {
|
|
28
|
+
withSpendGuard,
|
|
29
|
+
AgentGuardBlockedError,
|
|
30
|
+
type SpendPolicy,
|
|
31
|
+
} from '@agentguard-run/spend';
|
|
32
|
+
import { randomBytes } from 'crypto';
|
|
33
|
+
|
|
34
|
+
const policy: SpendPolicy = {
|
|
35
|
+
id: 'finance-ops-v1',
|
|
36
|
+
name: 'Límites diarios de operaciones financieras',
|
|
37
|
+
scope: { tenantId: 'acme-corp' },
|
|
38
|
+
caps: [
|
|
39
|
+
{
|
|
40
|
+
amountCents: 500,
|
|
41
|
+
window: 'per_day',
|
|
42
|
+
action: 'downgrade',
|
|
43
|
+
downgradeTo: 'gpt-4o-mini',
|
|
44
|
+
reason: 'Límite blando diario alcanzado, enrutando al modelo más económico',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
amountCents: 2000,
|
|
48
|
+
window: 'per_day',
|
|
49
|
+
action: 'block',
|
|
50
|
+
reason: 'Tope diario duro',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
mode: 'enforce',
|
|
54
|
+
version: 1,
|
|
55
|
+
effectiveFrom: '2026-05-24T00:00:00Z',
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const privateKey = new Uint8Array(randomBytes(32));
|
|
59
|
+
|
|
60
|
+
const client = withSpendGuard(new OpenAI(), {
|
|
61
|
+
policy,
|
|
62
|
+
scope: { tenantId: 'acme-corp', agentId: 'finance-bot' },
|
|
63
|
+
config: {
|
|
64
|
+
policy,
|
|
65
|
+
signingKeys: {
|
|
66
|
+
privateKey,
|
|
67
|
+
publicKey: new Uint8Array(32), // derivar de privateKey en producción
|
|
68
|
+
},
|
|
69
|
+
locale: 'es-419', // opcional - también detecta automáticamente
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
const completion = await client.chat.completions.create({
|
|
75
|
+
model: 'gpt-4o',
|
|
76
|
+
messages: [{ role: 'user', content: 'Hola' }],
|
|
77
|
+
});
|
|
78
|
+
} catch (err) {
|
|
79
|
+
if (err instanceof AgentGuardBlockedError) {
|
|
80
|
+
// El mensaje será mostrado en español por el detector de locale
|
|
81
|
+
console.error(err.message);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Cuando se dispara la política:
|
|
87
|
+
|
|
88
|
+
| Acción | Resultado |
|
|
89
|
+
|-------------|------------------------------------------------------------------------------------|
|
|
90
|
+
| `allow` | La llamada pasa sin modificaciones |
|
|
91
|
+
| `downgrade` | El parámetro `model` se reescribe a `downgradeTo`, luego la llamada continúa |
|
|
92
|
+
| `block` | Se lanza `AgentGuardBlockedError` antes de contactar al proveedor |
|
|
93
|
+
| `shadow` | La llamada pasa; la decisión se registra solo para análisis |
|
|
94
|
+
|
|
95
|
+
## Localización (v0.1.4+)
|
|
96
|
+
|
|
97
|
+
Los mensajes de bloqueo legibles están localizados en **inglés (en-US)**, **español de América Latina (es-419)** y **portugués brasileño (pt-BR)**. La resolución del locale sigue la cadena de prioridad estándar:
|
|
98
|
+
|
|
99
|
+
1. Configuración explícita: `config: { locale: 'es-419', ... }`
|
|
100
|
+
2. Variable de entorno: `export AGENTGUARD_LOCALE=es-419`
|
|
101
|
+
3. Variables de entorno del sistema: `LC_ALL`, `LC_MESSAGES`, `LANG`
|
|
102
|
+
4. `Intl.DateTimeFormat().resolvedOptions().locale` (navegador / Deno / Bun)
|
|
103
|
+
5. Respaldo: `en-US`
|
|
104
|
+
|
|
105
|
+
## Estado
|
|
106
|
+
|
|
107
|
+
Vista previa privada. Diseñado para integración empresarial, OEM y de plataforma.
|
|
108
|
+
|
|
109
|
+
Para acceso a evaluación, licencias OEM o consultas de asociación estratégica: `invest@agentguard.run`
|
|
110
|
+
|
|
111
|
+
## Licencia y umbrales de uso
|
|
112
|
+
|
|
113
|
+
El SDK es **gratuito** para:
|
|
114
|
+
|
|
115
|
+
- Evaluación, prototipado y desarrollo no comercial a cualquier volumen
|
|
116
|
+
- Despliegues de producción que procesan **hasta 10 000 llamadas de aplicación por mes calendario**
|
|
117
|
+
|
|
118
|
+
Se requiere una licencia comercial separada para volúmenes mayores o redistribución. Consultas: `invest@agentguard.run`
|
|
119
|
+
|
|
120
|
+
## Aviso de patentes
|
|
121
|
+
|
|
122
|
+
Protegido por solicitudes de patente pendientes en EE. UU. (App. Nos. 63/983,615; 63/983,621; 63/983,843; 63/984,626; 64/071,781; 64/071,789).
|
|
123
|
+
|
|
124
|
+
## Enlaces
|
|
125
|
+
|
|
126
|
+
- agentguard.run
|
|
127
|
+
- Contacto: `invest@agentguard.run`
|
|
128
|
+
- SDK Python: [`agentguard-spend`](https://pypi.org/project/agentguard-spend/)
|
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
> Local-runtime spend caps and capability-gated model routing for AI agents.
|
|
4
4
|
|
|
5
|
+
> Also available in: [Español (LATAM)](README.es-419.md) · [Português (BR)](README.pt-BR.md)
|
|
6
|
+
|
|
5
7
|
Every policy decision runs inside your process. Prompts, provider API keys, and signing keys never leave your runtime. Each enforcement decision produces an Ed25519-signed, hash-chained receipt suitable for audit and compliance review.
|
|
6
8
|
|
|
7
9
|
## Why no proxy
|
package/README.pt-BR.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# @agentguard-run/spend
|
|
2
|
+
|
|
3
|
+
> Limites de gasto em tempo de execução local e roteamento de modelos com capacidades para agentes de IA.
|
|
4
|
+
|
|
5
|
+
Toda decisão de política é executada dentro do seu processo. Prompts, chaves de API do provedor e chaves de assinatura nunca saem do seu runtime. Cada decisão de aplicação produz um recibo assinado com Ed25519, encadeado por hash, adequado para auditoria e revisão de compliance.
|
|
6
|
+
|
|
7
|
+
> Disponível também em: [English](README.md) · [Español (LATAM)](README.es-419.md)
|
|
8
|
+
|
|
9
|
+
## Por que sem proxy
|
|
10
|
+
|
|
11
|
+
Todo concorrente financiado em governança de gasto em IA (Portkey, Helicone, LiteLLM, Cloudflare AI Gateway, Vercel AI Gateway) faz proxy do seu tráfego. Isso significa que seus prompts e chaves de provedor passam pela infraestrutura deles. `@agentguard-run/spend` nunca vê nada disso. A política roda no seu processo. O log assinado vive no seu armazenamento.
|
|
12
|
+
|
|
13
|
+
## Instalação
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @agentguard-run/spend
|
|
17
|
+
# ou
|
|
18
|
+
pnpm add @agentguard-run/spend
|
|
19
|
+
# ou
|
|
20
|
+
yarn add @agentguard-run/spend
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quickstart
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import OpenAI from 'openai';
|
|
27
|
+
import {
|
|
28
|
+
withSpendGuard,
|
|
29
|
+
AgentGuardBlockedError,
|
|
30
|
+
type SpendPolicy,
|
|
31
|
+
} from '@agentguard-run/spend';
|
|
32
|
+
import { randomBytes } from 'crypto';
|
|
33
|
+
|
|
34
|
+
const policy: SpendPolicy = {
|
|
35
|
+
id: 'finance-ops-v1',
|
|
36
|
+
name: 'Limites diários de operações financeiras',
|
|
37
|
+
scope: { tenantId: 'acme-corp' },
|
|
38
|
+
caps: [
|
|
39
|
+
{
|
|
40
|
+
amountCents: 500,
|
|
41
|
+
window: 'per_day',
|
|
42
|
+
action: 'downgrade',
|
|
43
|
+
downgradeTo: 'gpt-4o-mini',
|
|
44
|
+
reason: 'Limite leve diário atingido, redirecionando para modelo mais barato',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
amountCents: 2000,
|
|
48
|
+
window: 'per_day',
|
|
49
|
+
action: 'block',
|
|
50
|
+
reason: 'Teto diário rígido',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
mode: 'enforce',
|
|
54
|
+
version: 1,
|
|
55
|
+
effectiveFrom: '2026-05-24T00:00:00Z',
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const privateKey = new Uint8Array(randomBytes(32));
|
|
59
|
+
|
|
60
|
+
const client = withSpendGuard(new OpenAI(), {
|
|
61
|
+
policy,
|
|
62
|
+
scope: { tenantId: 'acme-corp', agentId: 'finance-bot' },
|
|
63
|
+
config: {
|
|
64
|
+
policy,
|
|
65
|
+
signingKeys: {
|
|
66
|
+
privateKey,
|
|
67
|
+
publicKey: new Uint8Array(32), // derivar de privateKey em produção
|
|
68
|
+
},
|
|
69
|
+
locale: 'pt-BR', // opcional - também detecta automaticamente
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
const completion = await client.chat.completions.create({
|
|
75
|
+
model: 'gpt-4o',
|
|
76
|
+
messages: [{ role: 'user', content: 'Olá' }],
|
|
77
|
+
});
|
|
78
|
+
} catch (err) {
|
|
79
|
+
if (err instanceof AgentGuardBlockedError) {
|
|
80
|
+
// A mensagem será exibida em português pelo detector de locale
|
|
81
|
+
console.error(err.message);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Quando a política dispara:
|
|
87
|
+
|
|
88
|
+
| Ação | Resultado |
|
|
89
|
+
|-------------|------------------------------------------------------------------------------------------|
|
|
90
|
+
| `allow` | A chamada passa sem alterações |
|
|
91
|
+
| `downgrade` | O parâmetro `model` é reescrito para `downgradeTo`, então a chamada prossegue |
|
|
92
|
+
| `block` | `AgentGuardBlockedError` é lançado antes de contatar o provedor |
|
|
93
|
+
| `shadow` | A chamada passa; a decisão é registrada apenas para análise |
|
|
94
|
+
|
|
95
|
+
## Localização (v0.1.4+)
|
|
96
|
+
|
|
97
|
+
Mensagens de bloqueio legíveis estão localizadas em **inglês (en-US)**, **espanhol latino-americano (es-419)** e **português brasileiro (pt-BR)**. A resolução do locale segue a cadeia de prioridade padrão:
|
|
98
|
+
|
|
99
|
+
1. Configuração explícita: `config: { locale: 'pt-BR', ... }`
|
|
100
|
+
2. Variável de ambiente: `export AGENTGUARD_LOCALE=pt-BR`
|
|
101
|
+
3. Variáveis de ambiente do sistema: `LC_ALL`, `LC_MESSAGES`, `LANG`
|
|
102
|
+
4. `Intl.DateTimeFormat().resolvedOptions().locale` (browser / Deno / Bun)
|
|
103
|
+
5. Fallback: `en-US`
|
|
104
|
+
|
|
105
|
+
## Status
|
|
106
|
+
|
|
107
|
+
Preview privado. Projetado para integração corporativa, OEM e de plataforma.
|
|
108
|
+
|
|
109
|
+
Para acesso de avaliação, licenciamento OEM ou consultas de parceria estratégica: `invest@agentguard.run`
|
|
110
|
+
|
|
111
|
+
## Licença e limiares de uso
|
|
112
|
+
|
|
113
|
+
O SDK é **gratuito** para:
|
|
114
|
+
|
|
115
|
+
- Avaliação, prototipagem e desenvolvimento não comercial em qualquer volume
|
|
116
|
+
- Implantações de produção processando **até 10.000 chamadas de aplicação por mês calendário**
|
|
117
|
+
|
|
118
|
+
Uma licença comercial separada é necessária para volumes maiores ou redistribuição. Consultas: `invest@agentguard.run`
|
|
119
|
+
|
|
120
|
+
## Aviso de patentes
|
|
121
|
+
|
|
122
|
+
Protegido por aplicações de patente pendentes nos EUA (App. Nos. 63/983,615; 63/983,621; 63/983,843; 63/984,626; 64/071,781; 64/071,789).
|
|
123
|
+
|
|
124
|
+
## Links
|
|
125
|
+
|
|
126
|
+
- agentguard.run
|
|
127
|
+
- Contato: `invest@agentguard.run`
|
|
128
|
+
- SDK Python: [`agentguard-spend`](https://pypi.org/project/agentguard-spend/)
|
package/dist/i18n.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentGuard Spend i18n module (TypeScript).
|
|
3
|
+
*
|
|
4
|
+
* Resolves locale at runtime via the standard priority chain:
|
|
5
|
+
*
|
|
6
|
+
* 1. explicit config (passed to SpendGuardConfig or to a binding)
|
|
7
|
+
* 2. AGENTGUARD_LOCALE environment variable
|
|
8
|
+
* 3. operating-system / runtime locale (Intl.DateTimeFormat or process.env.LANG)
|
|
9
|
+
* 4. en-US fallback
|
|
10
|
+
*
|
|
11
|
+
* Supports en-US (default), es-419 (Latin American Spanish), and pt-BR
|
|
12
|
+
* (Brazilian Portuguese) in v0.1.4.
|
|
13
|
+
*/
|
|
14
|
+
export declare const SUPPORTED_LOCALES: readonly ["en-US", "es-419", "pt-BR"];
|
|
15
|
+
export type SupportedLocale = (typeof SUPPORTED_LOCALES)[number];
|
|
16
|
+
export declare const DEFAULT_LOCALE: SupportedLocale;
|
|
17
|
+
export declare function resolveLocale(explicit?: string): SupportedLocale;
|
|
18
|
+
type TranslationKey = 'blocked_header' | 'field_agent' | 'field_provider' | 'field_amount' | 'field_cap' | 'field_status' | 'status_blocked' | 'field_saved' | 'check_cap_enforced' | 'check_receipt' | 'check_provider_never_charged' | 'field_policy' | 'field_reasons' | 'reasons_none' | 'window_per_call' | 'window_per_minute' | 'window_per_hour' | 'window_per_day' | 'window_per_month' | 'short_message' | 'default_soft_cap_reason' | 'default_hard_cap_reason' | 'default_minute_burst_reason' | 'default_monthly_ceiling_reason' | 'cap_exceeded_format';
|
|
19
|
+
export declare const TRANSLATIONS: Record<SupportedLocale, Record<TranslationKey, string>>;
|
|
20
|
+
export declare function t(key: TranslationKey, locale?: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Format a multi-line blocked-call trace matching the Python SDK and the
|
|
23
|
+
* agentguard.run/the-block/ marketing screenshot. Localized per the active
|
|
24
|
+
* locale (auto-detected unless `locale` is explicitly passed).
|
|
25
|
+
*/
|
|
26
|
+
export interface BlockedTraceArgs {
|
|
27
|
+
policyId: string;
|
|
28
|
+
provider: string;
|
|
29
|
+
projectedCents: number;
|
|
30
|
+
windowSpendBefore: number;
|
|
31
|
+
reasons: string[];
|
|
32
|
+
triggeredCap?: {
|
|
33
|
+
amountCents: number;
|
|
34
|
+
window: string;
|
|
35
|
+
};
|
|
36
|
+
agentId?: string;
|
|
37
|
+
locale?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare function formatBlockedTrace(args: BlockedTraceArgs): string;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,iBAAiB,uCAAwC,CAAC;AACvE,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AACjE,eAAO,MAAM,cAAc,EAAE,eAAyB,CAAC;AAgCvD,wBAAgB,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,eAAe,CAGhE;AAED,KAAK,cAAc,GACf,gBAAgB,GAChB,aAAa,GACb,gBAAgB,GAChB,cAAc,GACd,WAAW,GACX,cAAc,GACd,gBAAgB,GAChB,aAAa,GACb,oBAAoB,GACpB,eAAe,GACf,8BAA8B,GAC9B,cAAc,GACd,eAAe,GACf,cAAc,GACd,iBAAiB,GACjB,mBAAmB,GACnB,iBAAiB,GACjB,gBAAgB,GAChB,kBAAkB,GAClB,eAAe,GACf,yBAAyB,GACzB,yBAAyB,GACzB,6BAA6B,GAC7B,gCAAgC,GAChC,qBAAqB,CAAC;AAE1B,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAqFhF,CAAC;AAEF,wBAAgB,CAAC,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAO9D;AAyBD;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,CAAC,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CA+DjE"}
|
package/dist/i18n.js
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AgentGuard Spend i18n module (TypeScript).
|
|
4
|
+
*
|
|
5
|
+
* Resolves locale at runtime via the standard priority chain:
|
|
6
|
+
*
|
|
7
|
+
* 1. explicit config (passed to SpendGuardConfig or to a binding)
|
|
8
|
+
* 2. AGENTGUARD_LOCALE environment variable
|
|
9
|
+
* 3. operating-system / runtime locale (Intl.DateTimeFormat or process.env.LANG)
|
|
10
|
+
* 4. en-US fallback
|
|
11
|
+
*
|
|
12
|
+
* Supports en-US (default), es-419 (Latin American Spanish), and pt-BR
|
|
13
|
+
* (Brazilian Portuguese) in v0.1.4.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.TRANSLATIONS = exports.DEFAULT_LOCALE = exports.SUPPORTED_LOCALES = void 0;
|
|
17
|
+
exports.resolveLocale = resolveLocale;
|
|
18
|
+
exports.t = t;
|
|
19
|
+
exports.formatBlockedTrace = formatBlockedTrace;
|
|
20
|
+
exports.SUPPORTED_LOCALES = ['en-US', 'es-419', 'pt-BR'];
|
|
21
|
+
exports.DEFAULT_LOCALE = 'en-US';
|
|
22
|
+
function normalizeLocale(raw) {
|
|
23
|
+
if (!raw)
|
|
24
|
+
return exports.DEFAULT_LOCALE;
|
|
25
|
+
const s = raw.toLowerCase().replace(/_/g, '-');
|
|
26
|
+
if (s.startsWith('es'))
|
|
27
|
+
return 'es-419';
|
|
28
|
+
if (s.startsWith('pt'))
|
|
29
|
+
return 'pt-BR';
|
|
30
|
+
return exports.DEFAULT_LOCALE;
|
|
31
|
+
}
|
|
32
|
+
function detectSystemLocale() {
|
|
33
|
+
// Node first (Intl in Node returns en-US regardless of system on some platforms)
|
|
34
|
+
if (typeof process !== 'undefined' && process.env) {
|
|
35
|
+
const env = process.env.AGENTGUARD_LOCALE ||
|
|
36
|
+
process.env.LC_ALL ||
|
|
37
|
+
process.env.LC_MESSAGES ||
|
|
38
|
+
process.env.LANG;
|
|
39
|
+
if (env)
|
|
40
|
+
return env;
|
|
41
|
+
}
|
|
42
|
+
// Browser / Deno / Bun fallback via Intl
|
|
43
|
+
try {
|
|
44
|
+
if (typeof Intl !== 'undefined' && Intl.DateTimeFormat) {
|
|
45
|
+
const resolved = Intl.DateTimeFormat().resolvedOptions().locale;
|
|
46
|
+
if (resolved)
|
|
47
|
+
return resolved;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// ignore
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
function resolveLocale(explicit) {
|
|
56
|
+
if (explicit)
|
|
57
|
+
return normalizeLocale(explicit);
|
|
58
|
+
return normalizeLocale(detectSystemLocale());
|
|
59
|
+
}
|
|
60
|
+
exports.TRANSLATIONS = {
|
|
61
|
+
// ---------------- English (source of truth) ----------------
|
|
62
|
+
'en-US': {
|
|
63
|
+
blocked_header: 'AgentGuard Spend — call blocked',
|
|
64
|
+
field_agent: 'agent',
|
|
65
|
+
field_provider: 'provider',
|
|
66
|
+
field_amount: 'amount',
|
|
67
|
+
field_cap: 'cap',
|
|
68
|
+
field_status: 'status',
|
|
69
|
+
status_blocked: 'BLOCKED',
|
|
70
|
+
field_saved: 'saved',
|
|
71
|
+
check_cap_enforced: 'spend cap enforced',
|
|
72
|
+
check_receipt: 'receipt tamper-evident',
|
|
73
|
+
check_provider_never_charged: 'provider never charged',
|
|
74
|
+
field_policy: 'policy',
|
|
75
|
+
field_reasons: 'reasons',
|
|
76
|
+
reasons_none: '(none)',
|
|
77
|
+
window_per_call: 'call',
|
|
78
|
+
window_per_minute: 'minute',
|
|
79
|
+
window_per_hour: 'hour',
|
|
80
|
+
window_per_day: 'day',
|
|
81
|
+
window_per_month: 'month',
|
|
82
|
+
short_message: 'AgentGuard Spend blocked call',
|
|
83
|
+
default_soft_cap_reason: 'Soft daily cap reached, routing to fallback model',
|
|
84
|
+
default_hard_cap_reason: 'Hard daily ceiling exceeded',
|
|
85
|
+
default_minute_burst_reason: 'Per-minute burst guard',
|
|
86
|
+
default_monthly_ceiling_reason: 'Monthly hard ceiling',
|
|
87
|
+
cap_exceeded_format: "Cap '{window}={amount_cents}c' exceeded",
|
|
88
|
+
},
|
|
89
|
+
// ---------------- Latin American Spanish (es-419) ----------------
|
|
90
|
+
'es-419': {
|
|
91
|
+
blocked_header: 'AgentGuard Spend — llamada bloqueada',
|
|
92
|
+
field_agent: 'agente',
|
|
93
|
+
field_provider: 'proveedor',
|
|
94
|
+
field_amount: 'monto',
|
|
95
|
+
field_cap: 'límite',
|
|
96
|
+
field_status: 'estado',
|
|
97
|
+
status_blocked: 'BLOQUEADO',
|
|
98
|
+
field_saved: 'ahorrado',
|
|
99
|
+
check_cap_enforced: 'límite de gasto aplicado',
|
|
100
|
+
check_receipt: 'recibo a prueba de manipulación',
|
|
101
|
+
check_provider_never_charged: 'proveedor nunca cobrado',
|
|
102
|
+
field_policy: 'política',
|
|
103
|
+
field_reasons: 'razones',
|
|
104
|
+
reasons_none: '(ninguna)',
|
|
105
|
+
window_per_call: 'llamada',
|
|
106
|
+
window_per_minute: 'minuto',
|
|
107
|
+
window_per_hour: 'hora',
|
|
108
|
+
window_per_day: 'día',
|
|
109
|
+
window_per_month: 'mes',
|
|
110
|
+
short_message: 'AgentGuard Spend bloqueó la llamada',
|
|
111
|
+
default_soft_cap_reason: 'Límite diario blando alcanzado, enrutando al modelo de respaldo',
|
|
112
|
+
default_hard_cap_reason: 'Tope diario duro excedido',
|
|
113
|
+
default_minute_burst_reason: 'Protección de ráfaga por minuto',
|
|
114
|
+
default_monthly_ceiling_reason: 'Tope mensual duro',
|
|
115
|
+
cap_exceeded_format: "Límite '{window}={amount_cents}c' excedido",
|
|
116
|
+
},
|
|
117
|
+
// ---------------- Brazilian Portuguese (pt-BR) ----------------
|
|
118
|
+
'pt-BR': {
|
|
119
|
+
blocked_header: 'AgentGuard Spend — chamada bloqueada',
|
|
120
|
+
field_agent: 'agente',
|
|
121
|
+
field_provider: 'provedor',
|
|
122
|
+
field_amount: 'valor',
|
|
123
|
+
field_cap: 'limite',
|
|
124
|
+
field_status: 'status',
|
|
125
|
+
status_blocked: 'BLOQUEADO',
|
|
126
|
+
field_saved: 'economizado',
|
|
127
|
+
check_cap_enforced: 'limite de gasto aplicado',
|
|
128
|
+
check_receipt: 'recibo à prova de adulteração',
|
|
129
|
+
check_provider_never_charged: 'provedor nunca cobrado',
|
|
130
|
+
field_policy: 'política',
|
|
131
|
+
field_reasons: 'motivos',
|
|
132
|
+
reasons_none: '(nenhum)',
|
|
133
|
+
window_per_call: 'chamada',
|
|
134
|
+
window_per_minute: 'minuto',
|
|
135
|
+
window_per_hour: 'hora',
|
|
136
|
+
window_per_day: 'dia',
|
|
137
|
+
window_per_month: 'mês',
|
|
138
|
+
short_message: 'AgentGuard Spend bloqueou a chamada',
|
|
139
|
+
default_soft_cap_reason: 'Limite diário leve atingido, redirecionando para modelo alternativo',
|
|
140
|
+
default_hard_cap_reason: 'Teto diário rígido excedido',
|
|
141
|
+
default_minute_burst_reason: 'Proteção de pico por minuto',
|
|
142
|
+
default_monthly_ceiling_reason: 'Teto mensal rígido',
|
|
143
|
+
cap_exceeded_format: "Limite '{window}={amount_cents}c' excedido",
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
function t(key, locale) {
|
|
147
|
+
const resolved = resolveLocale(locale);
|
|
148
|
+
return (exports.TRANSLATIONS[resolved][key] ??
|
|
149
|
+
exports.TRANSLATIONS[exports.DEFAULT_LOCALE][key] ??
|
|
150
|
+
key);
|
|
151
|
+
}
|
|
152
|
+
function formatCents(cents) {
|
|
153
|
+
const sign = cents < 0 ? '-' : '';
|
|
154
|
+
const abs = Math.abs(Math.round(cents));
|
|
155
|
+
const dollars = Math.floor(abs / 100);
|
|
156
|
+
const remainder = abs % 100;
|
|
157
|
+
const dollarsStr = dollars.toLocaleString('en-US');
|
|
158
|
+
const remainderStr = remainder.toString().padStart(2, '0');
|
|
159
|
+
return `${sign}$${dollarsStr}.${remainderStr}`;
|
|
160
|
+
}
|
|
161
|
+
function windowLabel(window, locale) {
|
|
162
|
+
const key = {
|
|
163
|
+
per_call: 'window_per_call',
|
|
164
|
+
per_minute: 'window_per_minute',
|
|
165
|
+
per_hour: 'window_per_hour',
|
|
166
|
+
per_day: 'window_per_day',
|
|
167
|
+
per_month: 'window_per_month',
|
|
168
|
+
}[window];
|
|
169
|
+
return key ? t(key, locale) : window;
|
|
170
|
+
}
|
|
171
|
+
function formatBlockedTrace(args) {
|
|
172
|
+
const { policyId, provider, projectedCents, windowSpendBefore, reasons, triggeredCap, agentId, locale, } = args;
|
|
173
|
+
const agent = agentId || 'unknown';
|
|
174
|
+
let capStr = 'n/a';
|
|
175
|
+
let savedCents = 0;
|
|
176
|
+
if (triggeredCap) {
|
|
177
|
+
capStr = `${formatCents(triggeredCap.amountCents)} / ${windowLabel(triggeredCap.window, locale)}`;
|
|
178
|
+
savedCents = Math.max(0, projectedCents - Math.max(0, triggeredCap.amountCents - windowSpendBefore));
|
|
179
|
+
}
|
|
180
|
+
const amountStr = formatCents(projectedCents);
|
|
181
|
+
const reasonsStr = reasons.length > 0 ? reasons.join('; ') : t('reasons_none', locale);
|
|
182
|
+
const fieldAgent = t('field_agent', locale);
|
|
183
|
+
const fieldProvider = t('field_provider', locale);
|
|
184
|
+
const fieldAmount = t('field_amount', locale);
|
|
185
|
+
const fieldCap = t('field_cap', locale);
|
|
186
|
+
const fieldStatus = t('field_status', locale);
|
|
187
|
+
const fieldSaved = t('field_saved', locale);
|
|
188
|
+
const labelWidth = Math.max(fieldAgent.length, fieldProvider.length, fieldAmount.length, fieldCap.length, fieldStatus.length, fieldSaved.length) + 2;
|
|
189
|
+
const pad = (s) => s + ' '.repeat(Math.max(0, labelWidth - s.length));
|
|
190
|
+
const lines = [
|
|
191
|
+
t('blocked_header', locale),
|
|
192
|
+
'',
|
|
193
|
+
` ${pad(fieldAgent)}${agent}`,
|
|
194
|
+
` ${pad(fieldProvider)}${provider}`,
|
|
195
|
+
` ${pad(fieldAmount)}${amountStr}`,
|
|
196
|
+
` ${pad(fieldCap)}${capStr}`,
|
|
197
|
+
` ${pad(fieldStatus)}${t('status_blocked', locale)}`,
|
|
198
|
+
'',
|
|
199
|
+
` ${pad(fieldSaved)}+${formatCents(savedCents)}`,
|
|
200
|
+
'',
|
|
201
|
+
` ✓ ${t('check_cap_enforced', locale)}`,
|
|
202
|
+
` ✓ ${t('check_receipt', locale)}`,
|
|
203
|
+
` ✓ ${t('check_provider_never_charged', locale)}`,
|
|
204
|
+
'',
|
|
205
|
+
`${t('field_policy', locale)}: ${policyId}`,
|
|
206
|
+
`${t('field_reasons', locale)}: ${reasonsStr}`,
|
|
207
|
+
];
|
|
208
|
+
return lines.join('\n');
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=i18n.js.map
|
package/dist/i18n.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAoCH,sCAGC;AAoHD,cAOC;AAyCD,gDA+DC;AAxQY,QAAA,iBAAiB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAU,CAAC;AAE1D,QAAA,cAAc,GAAoB,OAAO,CAAC;AAEvD,SAAS,eAAe,CAAC,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AC3B,EAAE;QACF,KAAK,GAAG,CAAC,UAAU,CAAC,GAAG,KAAK,EAAE;QAC9B,KAAK,GAAG,CAAC,aAAa,CAAC,GAAG,QAAQ,EAAE;QACpC,KAAK,GAAG,CAAC,WAAW,CAAC,GAAG,SAAS,EAAE;QACnC,KAAK,GAAG,CAAC,QAAQ,CAAC,GAAG,MAAM,EAAE;QAC7B,KAAK,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,MAAM,CAAC,EAAE;QACrD,EAAE;QACF,KAAK,GAAG,CAAC,UAAU,CAAC,IAAI,WAAW,CAAC,UAAU,CAAC,EAAE;QACjD,EAAE;QACF,OAAO,CAAC,CAAC,oBAAoB,EAAE,MAAM,CAAC,EAAE;QACxC,OAAO,CAAC,CAAC,eAAe,EAAE,MAAM,CAAC,EAAE;QACnC,OAAO,CAAC,CAAC,8BAA8B,EAAE,MAAM,CAAC,EAAE;QAClD,EAAE;QACF,GAAG,CAAC,CAAC,cAAc,EAAE,MAAM,CAAC,KAAK,QAAQ,EAAE;QAC3C,GAAG,CAAC,CAAC,eAAe,EAAE,MAAM,CAAC,KAAK,UAAU,EAAE;KAC/C,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,8 @@ export { evaluatePolicy, buildScopeKey } from './policy';
|
|
|
11
11
|
export { canonicalJson, sha256Hex, computeEntryHash, computeSignerFingerprint, signDecision, verifyEntry, verifyChain, GENESIS_PREVIOUS_HASH, InMemoryDecisionLogStore, } from './decision-log';
|
|
12
12
|
export { InMemorySpendStore } from './store-memory';
|
|
13
13
|
export { SpendGuard, withSpendGuard, AgentGuardBlockedError, type SpendGuardConfig, type OpenAIBindingOptions, } from './spend-guard';
|
|
14
|
-
export
|
|
14
|
+
export { DEFAULT_LOCALE, SUPPORTED_LOCALES, TRANSLATIONS, type SupportedLocale, resolveLocale, t, formatBlockedTrace, type BlockedTraceArgs, } from './i18n';
|
|
15
|
+
export declare const AGENTGUARD_SPEND_VERSION = "0.1.4";
|
|
15
16
|
/** Patent marking. 35 U.S.C. § 287 constructive notice. */
|
|
16
17
|
export declare const PATENT_NOTICE: string;
|
|
17
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EACV,WAAW,EACX,WAAW,EACX,QAAQ,EACR,eAAe,EACf,cAAc,EACd,QAAQ,EACR,UAAU,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACb,sBAAsB,EACtB,UAAU,EACV,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,KAAK,SAAS,GACf,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzD,OAAO,EACL,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,wBAAwB,EACxB,YAAY,EACZ,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,OAAO,EACL,UAAU,EACV,cAAc,EACd,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,GAC1B,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EACV,WAAW,EACX,WAAW,EACX,QAAQ,EACR,eAAe,EACf,cAAc,EACd,QAAQ,EACR,UAAU,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACb,sBAAsB,EACtB,UAAU,EACV,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,KAAK,SAAS,GACf,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzD,OAAO,EACL,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,wBAAwB,EACxB,YAAY,EACZ,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,OAAO,EACL,UAAU,EACV,cAAc,EACd,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,GAC1B,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,KAAK,eAAe,EACpB,aAAa,EACb,CAAC,EACD,kBAAkB,EAClB,KAAK,gBAAgB,GACtB,MAAM,QAAQ,CAAC;AAEhB,eAAO,MAAM,wBAAwB,UAAU,CAAC;AAEhD,2DAA2D;AAC3D,eAAO,MAAM,aAAa,QAIK,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* and an additional application filed May 2026).
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.PATENT_NOTICE = exports.AGENTGUARD_SPEND_VERSION = exports.AgentGuardBlockedError = exports.withSpendGuard = exports.SpendGuard = exports.InMemorySpendStore = exports.InMemoryDecisionLogStore = exports.GENESIS_PREVIOUS_HASH = exports.verifyChain = exports.verifyEntry = exports.signDecision = exports.computeSignerFingerprint = exports.computeEntryHash = exports.sha256Hex = exports.canonicalJson = exports.buildScopeKey = exports.evaluatePolicy = exports.inferProvider = exports.computeCallCents = exports.clearCostOverrides = exports.setCostOverride = exports.getModelCost = void 0;
|
|
10
|
+
exports.PATENT_NOTICE = exports.AGENTGUARD_SPEND_VERSION = exports.formatBlockedTrace = exports.t = exports.resolveLocale = exports.TRANSLATIONS = exports.SUPPORTED_LOCALES = exports.DEFAULT_LOCALE = exports.AgentGuardBlockedError = exports.withSpendGuard = exports.SpendGuard = exports.InMemorySpendStore = exports.InMemoryDecisionLogStore = exports.GENESIS_PREVIOUS_HASH = exports.verifyChain = exports.verifyEntry = exports.signDecision = exports.computeSignerFingerprint = exports.computeEntryHash = exports.sha256Hex = exports.canonicalJson = exports.buildScopeKey = exports.evaluatePolicy = exports.inferProvider = exports.computeCallCents = exports.clearCostOverrides = exports.setCostOverride = exports.getModelCost = void 0;
|
|
11
11
|
// Cost table
|
|
12
12
|
var cost_table_1 = require("./cost-table");
|
|
13
13
|
Object.defineProperty(exports, "getModelCost", { enumerable: true, get: function () { return cost_table_1.getModelCost; } });
|
|
@@ -38,7 +38,15 @@ var spend_guard_1 = require("./spend-guard");
|
|
|
38
38
|
Object.defineProperty(exports, "SpendGuard", { enumerable: true, get: function () { return spend_guard_1.SpendGuard; } });
|
|
39
39
|
Object.defineProperty(exports, "withSpendGuard", { enumerable: true, get: function () { return spend_guard_1.withSpendGuard; } });
|
|
40
40
|
Object.defineProperty(exports, "AgentGuardBlockedError", { enumerable: true, get: function () { return spend_guard_1.AgentGuardBlockedError; } });
|
|
41
|
-
|
|
41
|
+
// Localization (en-US, es-419, pt-BR)
|
|
42
|
+
var i18n_1 = require("./i18n");
|
|
43
|
+
Object.defineProperty(exports, "DEFAULT_LOCALE", { enumerable: true, get: function () { return i18n_1.DEFAULT_LOCALE; } });
|
|
44
|
+
Object.defineProperty(exports, "SUPPORTED_LOCALES", { enumerable: true, get: function () { return i18n_1.SUPPORTED_LOCALES; } });
|
|
45
|
+
Object.defineProperty(exports, "TRANSLATIONS", { enumerable: true, get: function () { return i18n_1.TRANSLATIONS; } });
|
|
46
|
+
Object.defineProperty(exports, "resolveLocale", { enumerable: true, get: function () { return i18n_1.resolveLocale; } });
|
|
47
|
+
Object.defineProperty(exports, "t", { enumerable: true, get: function () { return i18n_1.t; } });
|
|
48
|
+
Object.defineProperty(exports, "formatBlockedTrace", { enumerable: true, get: function () { return i18n_1.formatBlockedTrace; } });
|
|
49
|
+
exports.AGENTGUARD_SPEND_VERSION = '0.1.4';
|
|
42
50
|
/** Patent marking. 35 U.S.C. § 287 constructive notice. */
|
|
43
51
|
exports.PATENT_NOTICE = 'Protected by U.S. patent-pending technology ' +
|
|
44
52
|
'(App. Nos. 63/983,615; 63/983,621; 63/983,843; 63/984,626; ' +
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAmBH,aAAa;AACb,2CAOsB;AANpB,0GAAA,YAAY,OAAA;AACZ,6GAAA,eAAe,OAAA;AACf,gHAAA,kBAAkB,OAAA;AAClB,8GAAA,gBAAgB,OAAA;AAChB,2GAAA,aAAa,OAAA;AAIf,gBAAgB;AAChB,mCAAyD;AAAhD,wGAAA,cAAc,OAAA;AAAE,uGAAA,aAAa,OAAA;AAEtC,eAAe;AACf,+CAUwB;AATtB,6GAAA,aAAa,OAAA;AACb,yGAAA,SAAS,OAAA;AACT,gHAAA,gBAAgB,OAAA;AAChB,wHAAA,wBAAwB,OAAA;AACxB,4GAAA,YAAY,OAAA;AACZ,2GAAA,WAAW,OAAA;AACX,2GAAA,WAAW,OAAA;AACX,qHAAA,qBAAqB,OAAA;AACrB,wHAAA,wBAAwB,OAAA;AAG1B,wBAAwB;AACxB,+CAAoD;AAA3C,kHAAA,kBAAkB,OAAA;AAE3B,eAAe;AACf,6CAMuB;AALrB,yGAAA,UAAU,OAAA;AACV,6GAAA,cAAc,OAAA;AACd,qHAAA,sBAAsB,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAmBH,aAAa;AACb,2CAOsB;AANpB,0GAAA,YAAY,OAAA;AACZ,6GAAA,eAAe,OAAA;AACf,gHAAA,kBAAkB,OAAA;AAClB,8GAAA,gBAAgB,OAAA;AAChB,2GAAA,aAAa,OAAA;AAIf,gBAAgB;AAChB,mCAAyD;AAAhD,wGAAA,cAAc,OAAA;AAAE,uGAAA,aAAa,OAAA;AAEtC,eAAe;AACf,+CAUwB;AATtB,6GAAA,aAAa,OAAA;AACb,yGAAA,SAAS,OAAA;AACT,gHAAA,gBAAgB,OAAA;AAChB,wHAAA,wBAAwB,OAAA;AACxB,4GAAA,YAAY,OAAA;AACZ,2GAAA,WAAW,OAAA;AACX,2GAAA,WAAW,OAAA;AACX,qHAAA,qBAAqB,OAAA;AACrB,wHAAA,wBAAwB,OAAA;AAG1B,wBAAwB;AACxB,+CAAoD;AAA3C,kHAAA,kBAAkB,OAAA;AAE3B,eAAe;AACf,6CAMuB;AALrB,yGAAA,UAAU,OAAA;AACV,6GAAA,cAAc,OAAA;AACd,qHAAA,sBAAsB,OAAA;AAKxB,sCAAsC;AACtC,+BASgB;AARd,sGAAA,cAAc,OAAA;AACd,yGAAA,iBAAiB,OAAA;AACjB,oGAAA,YAAY,OAAA;AAEZ,qGAAA,aAAa,OAAA;AACb,yFAAA,CAAC,OAAA;AACD,0GAAA,kBAAkB,OAAA;AAIP,QAAA,wBAAwB,GAAG,OAAO,CAAC;AAEhD,2DAA2D;AAC9C,QAAA,aAAa,GACxB,8CAA8C;IAC9C,6DAA6D;IAC7D,iDAAiD;IACjD,6BAA6B,CAAC"}
|
package/dist/spend-guard.d.ts
CHANGED
|
@@ -36,6 +36,10 @@ export interface SpendGuardConfig {
|
|
|
36
36
|
onDecision?: (decision: SpendDecision, signed: SignedDecisionLogEntry | null) => void | Promise<void>;
|
|
37
37
|
/** Optional token-count estimator. Defaults to `chars / 4` heuristic. */
|
|
38
38
|
tokenEstimator?: (text: string) => number;
|
|
39
|
+
/** Optional locale for localized block traces. Defaults to auto-detection
|
|
40
|
+
* via AGENTGUARD_LOCALE env var or system locale, falling back to en-US.
|
|
41
|
+
* Supported in v0.1.4: 'en-US', 'es-419', 'pt-BR'. */
|
|
42
|
+
locale?: string;
|
|
39
43
|
}
|
|
40
44
|
export declare class SpendGuard {
|
|
41
45
|
private config;
|
|
@@ -97,7 +101,9 @@ export interface OpenAIBindingOptions {
|
|
|
97
101
|
}
|
|
98
102
|
export declare class AgentGuardBlockedError extends Error {
|
|
99
103
|
decision: SpendDecision;
|
|
100
|
-
|
|
104
|
+
scope?: SpendScope;
|
|
105
|
+
locale?: string;
|
|
106
|
+
constructor(decision: SpendDecision, scope?: SpendScope, locale?: string);
|
|
101
107
|
}
|
|
102
108
|
/**
|
|
103
109
|
* Wrap an OpenAI client. Returns a proxy whose chat.completions.create
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spend-guard.d.ts","sourceRoot":"","sources":["../src/spend-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,sBAAsB,EAEtB,cAAc,EACd,UAAU,EACX,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"spend-guard.d.ts","sourceRoot":"","sources":["../src/spend-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,sBAAsB,EAEtB,cAAc,EACd,UAAU,EACX,MAAM,SAAS,CAAC;AAWjB;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,gDAAgD;IAChD,MAAM,EAAE,WAAW,CAAC;IACpB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,8CAA8C;IAC9C,Q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AAC;IACjC,MAAM,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;CAC3C;AAED,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,QAAQ,EAAE,aAAa,CAAC;IACxB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;gBACJ,QAAQ,EAAE,aAAa,EAAE,KAAK,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM;CAwBzE;AAED;;;;GAIG;AAEH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,GAAG,EACX,IAAI,EAAE,oBAAoB,GAEzB,GAAG,CA8CL"}
|
package/dist/spend-guard.js
CHANGED
|
@@ -23,6 +23,7 @@ const decision_log_1 = require("./decision-log");
|
|
|
23
23
|
const store_memory_1 = require("./store-memory");
|
|
24
24
|
const decision_log_2 = require("./decision-log");
|
|
25
25
|
const cost_table_1 = require("./cost-table");
|
|
26
|
+
const i18n_1 = require("./i18n");
|
|
26
27
|
class SpendGuard {
|
|
27
28
|
config;
|
|
28
29
|
spendStore;
|
|
@@ -91,11 +92,29 @@ class SpendGuard {
|
|
|
91
92
|
exports.SpendGuard = SpendGuard;
|
|
92
93
|
class AgentGuardBlockedError extends Error {
|
|
93
94
|
decision;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
scope;
|
|
96
|
+
locale;
|
|
97
|
+
constructor(decision, scope, locale) {
|
|
98
|
+
const agentId = scope?.agentId || scope?.userId || scope?.tenantId;
|
|
99
|
+
super((0, i18n_1.formatBlockedTrace)({
|
|
100
|
+
policyId: decision.policyId,
|
|
101
|
+
provider: decision.provider,
|
|
102
|
+
projectedCents: decision.projectedCents,
|
|
103
|
+
windowSpendBefore: decision.windowSpendBefore,
|
|
104
|
+
reasons: decision.reasons,
|
|
105
|
+
triggeredCap: decision.triggeredCap
|
|
106
|
+
? {
|
|
107
|
+
amountCents: decision.triggeredCap.amountCents,
|
|
108
|
+
window: decision.triggeredCap.window,
|
|
109
|
+
}
|
|
110
|
+
: undefined,
|
|
111
|
+
agentId,
|
|
112
|
+
locale,
|
|
113
|
+
}));
|
|
97
114
|
this.name = 'AgentGuardBlockedError';
|
|
98
115
|
this.decision = decision;
|
|
116
|
+
this.scope = scope;
|
|
117
|
+
this.locale = locale;
|
|
99
118
|
}
|
|
100
119
|
}
|
|
101
120
|
exports.AgentGuardBlockedError = AgentGuardBlockedError;
|
|
@@ -129,7 +148,7 @@ function withSpendGuard(client, opts) {
|
|
|
129
148
|
};
|
|
130
149
|
const { decision } = await guard.decide(call);
|
|
131
150
|
if (decision.action === 'block') {
|
|
132
|
-
throw new AgentGuardBlockedError(decision);
|
|
151
|
+
throw new AgentGuardBlockedError(decision, opts.scope, opts.config?.locale);
|
|
133
152
|
}
|
|
134
153
|
if (decision.action === 'downgrade' && decision.modelResolved !== decision.modelRequested) {
|
|
135
154
|
params = { ...params, model: decision.modelResolved };
|
package/dist/spend-guard.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spend-guard.js","sourceRoot":"","sources":["../src/spend-guard.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;
|
|
1
|
+
{"version":3,"file":"spend-guard.js","sourceRoot":"","sources":["../src/spend-guard.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAkMH,wCAkDC;AAvOD,qCAA0C;AAC1C,iDAGwB;AACxB,iDAAoD;AACpD,iDAA0D;AAC1D,6CAA6C;AAC7C,iCAA4C;AA6B5C,MAAa,UAAU;IACb,MAAM,CAAmB;IACzB,UAAU,CAAa;IACvB,QAAQ,CAAmB;IAC3B,YAAY,GAAG,CAAC,CAAC;IACjB,YAAY,GAAG,oCAAqB,CAAC;IAE7C,YAAY,MAAwB;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,IAA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AAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentguard-run/spend",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Local-runtime spend caps and capability-gated model routing for AI agents. Prompts, API keys, and signing keys stay inside the customer runtime. Zero data plane involvement.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|