@agentguard-run/spend 0.4.0 → 0.4.2
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/CHANGELOG.md +8 -2
- package/README.es-419.md +21 -4
- package/README.md +24 -5
- package/README.pt-BR.md +21 -4
- package/dist/{coach → advisor}/anomaly.d.ts +5 -5
- package/dist/advisor/anomaly.d.ts.map +1 -0
- package/dist/{coach → advisor}/anomaly.js +1 -1
- package/dist/advisor/anomaly.js.map +1 -0
- package/dist/{coach → advisor}/conversation.d.ts +23 -17
- package/dist/advisor/conversation.d.ts.map +1 -0
- package/dist/{coach → advisor}/conversation.js +63 -27
- package/dist/advisor/conversation.js.map +1 -0
- package/dist/{coach → advisor}/forecast.d.ts +4 -4
- package/dist/advisor/forecast.d.ts.map +1 -0
- package/dist/{coach → advisor}/forecast.js +1 -1
- package/dist/advisor/forecast.js.map +1 -0
- package/dist/{coach → advisor}/llm-client.d.ts +10 -10
- package/dist/advisor/llm-client.d.ts.map +1 -0
- package/dist/{coach → advisor}/llm-client.js +12 -12
- package/dist/advisor/llm-client.js.map +1 -0
- package/dist/{coach → advisor}/output.d.ts +12 -12
- package/dist/advisor/output.d.ts.map +1 -0
- package/dist/{coach → advisor}/output.js +42 -13
- package/dist/advisor/output.js.map +1 -0
- package/dist/advisor/posture.d.ts +26 -0
- package/dist/advisor/posture.d.ts.map +1 -0
- package/dist/advisor/posture.js +100 -0
- package/dist/advisor/posture.js.map +1 -0
- package/dist/{coach → advisor}/system-prompt.d.ts +5 -5
- package/dist/advisor/system-prompt.d.ts.map +1 -0
- package/dist/{coach → advisor}/system-prompt.js +21 -8
- package/dist/advisor/system-prompt.js.map +1 -0
- package/dist/cli/advisor.d.ts +5 -0
- package/dist/cli/advisor.d.ts.map +1 -0
- package/dist/cli/{coach.js → advisor.js} +63 -47
- package/dist/cli/advisor.js.map +1 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +7 -6
- package/dist/cli/main.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/telemetry.js +1 -1
- package/package.json +7 -7
- package/src/{coach → advisor}/anomaly.ts +9 -9
- package/src/{coach → advisor}/conversation.ts +80 -39
- package/src/{coach → advisor}/forecast.ts +5 -5
- package/src/{coach → advisor}/llm-client.ts +21 -21
- package/src/{coach → advisor}/output.ts +49 -20
- package/src/advisor/posture.ts +112 -0
- package/src/{coach → advisor}/system-prompt.ts +22 -8
- package/src/cli/{coach.ts → advisor.ts} +74 -58
- package/dist/cli/coach.d.ts +0 -5
- package/dist/cli/coach.d.ts.map +0 -1
- package/dist/cli/coach.js.map +0 -1
- package/dist/coach/anomaly.d.ts.map +0 -1
- package/dist/coach/anomaly.js.map +0 -1
- package/dist/coach/conversation.d.ts.map +0 -1
- package/dist/coach/conversation.js.map +0 -1
- package/dist/coach/forecast.d.ts.map +0 -1
- package/dist/coach/forecast.js.map +0 -1
- package/dist/coach/llm-client.d.ts.map +0 -1
- package/dist/coach/llm-client.js.map +0 -1
- package/dist/coach/output.d.ts.map +0 -1
- package/dist/coach/output.js.map +0 -1
- package/dist/coach/system-prompt.d.ts.map +0 -1
- package/dist/coach/system-prompt.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* AgentGuard(TM) Spend: local
|
|
3
|
+
* AgentGuard(TM) Spend: local Advisor LLM client.
|
|
4
4
|
*
|
|
5
5
|
* All provider calls go from the customer terminal to the configured provider.
|
|
6
6
|
* No AgentGuard service is contacted for prompts or completions.
|
|
@@ -43,8 +43,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
43
43
|
};
|
|
44
44
|
})();
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
-
exports.
|
|
47
|
-
exports.
|
|
46
|
+
exports.resolveAdvisorApiKey = resolveAdvisorApiKey;
|
|
47
|
+
exports.createAdvisorClient = createAdvisorClient;
|
|
48
48
|
exports.parseSseResponse = parseSseResponse;
|
|
49
49
|
const fs = __importStar(require("fs"));
|
|
50
50
|
const os = __importStar(require("os"));
|
|
@@ -53,7 +53,7 @@ const DEFAULT_OPENROUTER_BASE_URL = 'https://openrouter.ai/api/v1';
|
|
|
53
53
|
const DEFAULT_OPENAI_BASE_URL = 'https://api.openai.com/v1';
|
|
54
54
|
const DEFAULT_ANTHROPIC_BASE_URL = 'https://api.anthropic.com/v1';
|
|
55
55
|
const DEFAULT_MODEL = 'openai/gpt-4o-mini';
|
|
56
|
-
function
|
|
56
|
+
function resolveAdvisorApiKey(provider = 'openrouter', explicit) {
|
|
57
57
|
if (explicit?.trim())
|
|
58
58
|
return explicit.trim();
|
|
59
59
|
if (provider === 'openai' && process.env.OPENAI_API_KEY)
|
|
@@ -62,8 +62,8 @@ function resolveCoachApiKey(provider = 'openrouter', explicit) {
|
|
|
62
62
|
return process.env.ANTHROPIC_API_KEY;
|
|
63
63
|
if ((provider === 'openrouter' || provider === 'compatible') && process.env.OPENROUTER_API_KEY)
|
|
64
64
|
return process.env.OPENROUTER_API_KEY;
|
|
65
|
-
if (process.env.
|
|
66
|
-
return process.env.
|
|
65
|
+
if (process.env.AGENTGUARD_ADVISOR_API_KEY)
|
|
66
|
+
return process.env.AGENTGUARD_ADVISOR_API_KEY;
|
|
67
67
|
try {
|
|
68
68
|
const key = fs.readFileSync(path.join(agentguardHome(), 'openrouter-key'), 'utf8').trim();
|
|
69
69
|
return key.length > 0 ? key : null;
|
|
@@ -72,23 +72,23 @@ function resolveCoachApiKey(provider = 'openrouter', explicit) {
|
|
|
72
72
|
return null;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function createAdvisorClient(options = {}) {
|
|
76
76
|
const provider = options.provider ?? providerFromBaseUrl(options.baseUrl) ?? 'openrouter';
|
|
77
77
|
const model = options.model ?? (provider === 'anthropic' ? 'claude-sonnet-4-6' : DEFAULT_MODEL);
|
|
78
78
|
const baseUrl = normalizeBaseUrl(options.baseUrl ?? defaultBaseUrl(provider));
|
|
79
79
|
const fetchImpl = options.fetchImpl ?? globalFetch;
|
|
80
|
-
const apiKey =
|
|
80
|
+
const apiKey = resolveAdvisorApiKey(provider, options.apiKey);
|
|
81
81
|
return {
|
|
82
82
|
provider,
|
|
83
83
|
model,
|
|
84
84
|
baseUrl,
|
|
85
85
|
async *streamChat(messages, signal) {
|
|
86
86
|
if (provider === 'mock') {
|
|
87
|
-
yield 'Mock
|
|
87
|
+
yield 'Mock advisor response.';
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
90
|
if (!apiKey)
|
|
91
|
-
throw new Error('No
|
|
91
|
+
throw new Error('No Advisor API key configured');
|
|
92
92
|
if (provider === 'anthropic') {
|
|
93
93
|
yield* streamAnthropic({ fetchImpl, baseUrl, model, apiKey, messages, signal, timeoutMs: options.timeoutMs });
|
|
94
94
|
}
|
|
@@ -114,7 +114,7 @@ async function* streamOpenAICompatible(args) {
|
|
|
114
114
|
signal,
|
|
115
115
|
});
|
|
116
116
|
if (!response.ok)
|
|
117
|
-
throw new Error(`
|
|
117
|
+
throw new Error(`Advisor provider HTTP ${response.status}`);
|
|
118
118
|
yield* parseSseResponse(response, (json) => json?.choices?.[0]?.delta?.content ?? json?.choices?.[0]?.message?.content ?? '');
|
|
119
119
|
}
|
|
120
120
|
finally {
|
|
@@ -140,7 +140,7 @@ async function* streamAnthropic(args) {
|
|
|
140
140
|
signal,
|
|
141
141
|
});
|
|
142
142
|
if (!response.ok)
|
|
143
|
-
throw new Error(`
|
|
143
|
+
throw new Error(`Advisor provider HTTP ${response.status}`);
|
|
144
144
|
yield* parseSseResponse(response, (json) => json?.delta?.text ?? json?.content_block?.text ?? '');
|
|
145
145
|
}
|
|
146
146
|
finally {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-client.js","sourceRoot":"","sources":["../../src/adv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,MAAM,GAAoB,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC;IACtF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AAC7D,CAAC;AAED,SAAS,WAAW,CAAC,CAA8B,EAAE,CAAkB;IACrE,IAAI,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACjB,IAAI,CAAC,CAAC,OAAO;QAAE,OAAO,CAAC,CAAC;IACxB,MAAM,UAAU,GAAG,qBAAqB,EAAE,CAAC;IAC3C,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IACvC,CAAC,CAAC,gBAAgB,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,CAAC,CAAC,gBAAgB,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,OAAO,UAAU,CAAC,MAAM,CAAC;AAC3B,CAAC"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* AgentGuard(TM) Spend:
|
|
2
|
+
* AgentGuard(TM) Spend: Advisor output writers.
|
|
3
3
|
*
|
|
4
4
|
* Files are written locally under ~/.agentguard by default. Conversation logs
|
|
5
|
-
* stay in ~/.agentguard/
|
|
5
|
+
* stay in ~/.agentguard/advisor-sessions and are never uploaded by this SDK.
|
|
6
6
|
*
|
|
7
7
|
* Patent notice: Protected by U.S. patent-pending technology
|
|
8
8
|
* (App. Nos. 63/983,615; 63/983,621; 63/983,843; 63/984,626;
|
|
9
9
|
* 64/071,781; 64/071,789).
|
|
10
10
|
*/
|
|
11
11
|
import type { SpendPolicy } from '../types';
|
|
12
|
-
import { type
|
|
13
|
-
export interface
|
|
12
|
+
import { type AdvisorBusinessProfile, type ProjectedSavings } from './conversation';
|
|
13
|
+
export interface AdvisorOutputOptions {
|
|
14
14
|
home?: string;
|
|
15
15
|
now?: Date;
|
|
16
16
|
language?: 'ts' | 'py';
|
|
17
17
|
overwrite?: boolean;
|
|
18
18
|
}
|
|
19
|
-
export interface
|
|
19
|
+
export interface AdvisorOutputs {
|
|
20
20
|
policy: SpendPolicy;
|
|
21
21
|
policyPath: string;
|
|
22
22
|
quickstartPath: string;
|
|
@@ -26,16 +26,16 @@ export interface CoachOutputs {
|
|
|
26
26
|
quickstartCode: string;
|
|
27
27
|
savingsTable: string;
|
|
28
28
|
}
|
|
29
|
-
export interface
|
|
29
|
+
export interface AdvisorSessionLogger {
|
|
30
30
|
path: string;
|
|
31
31
|
append: (event: string, payload?: Record<string, unknown>) => void;
|
|
32
32
|
}
|
|
33
33
|
export declare function agentguardHome(): string;
|
|
34
|
-
export declare function
|
|
35
|
-
export declare function
|
|
36
|
-
export declare function
|
|
37
|
-
export declare function renderPolicyYaml(policy: SpendPolicy, profile:
|
|
38
|
-
export declare function renderQuickstartTs(policy: SpendPolicy, profile:
|
|
39
|
-
export declare function renderQuickstartPy(policy: SpendPolicy, profile:
|
|
34
|
+
export declare function advisorSessionDir(home?: string): string;
|
|
35
|
+
export declare function createAdvisorSessionLogger(home?: string, now?: Date): AdvisorSessionLogger;
|
|
36
|
+
export declare function writeAdvisorOutputs(profile: AdvisorBusinessProfile, options?: AdvisorOutputOptions): AdvisorOutputs;
|
|
37
|
+
export declare function renderPolicyYaml(policy: SpendPolicy, profile: AdvisorBusinessProfile, now?: Date): string;
|
|
38
|
+
export declare function renderQuickstartTs(policy: SpendPolicy, profile: AdvisorBusinessProfile): string;
|
|
39
|
+
export declare function renderQuickstartPy(policy: SpendPolicy, profile: AdvisorBusinessProfile): string;
|
|
40
40
|
export declare function renderSavingsTable(savings: ProjectedSavings): string;
|
|
41
41
|
//# sourceMappingURL=output.d.ts.map
|
|
@@ -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BAAsB,EAAE,GAAG,OAAa,GAAG,MAAM,CAyC/G;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,sBAAsB,GAAG,MAAM,CAE/F;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,sBAAsB,GAAG,MAAM,CAO/F;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAQpE"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* AgentGuard(TM) Spend:
|
|
3
|
+
* AgentGuard(TM) Spend: Advisor output writers.
|
|
4
4
|
*
|
|
5
5
|
* Files are written locally under ~/.agentguard by default. Conversation logs
|
|
6
|
-
* stay in ~/.agentguard/
|
|
6
|
+
* stay in ~/.agentguard/advisor-sessions and are never uploaded by this SDK.
|
|
7
7
|
*
|
|
8
8
|
* Patent notice: Protected by U.S. patent-pending technology
|
|
9
9
|
* (App. Nos. 63/983,615; 63/983,621; 63/983,843; 63/984,626;
|
|
@@ -44,9 +44,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
44
44
|
})();
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
46
|
exports.agentguardHome = agentguardHome;
|
|
47
|
-
exports.
|
|
48
|
-
exports.
|
|
49
|
-
exports.
|
|
47
|
+
exports.advisorSessionDir = advisorSessionDir;
|
|
48
|
+
exports.createAdvisorSessionLogger = createAdvisorSessionLogger;
|
|
49
|
+
exports.writeAdvisorOutputs = writeAdvisorOutputs;
|
|
50
50
|
exports.renderPolicyYaml = renderPolicyYaml;
|
|
51
51
|
exports.renderQuickstartTs = renderQuickstartTs;
|
|
52
52
|
exports.renderQuickstartPy = renderQuickstartPy;
|
|
@@ -55,14 +55,15 @@ const fs = __importStar(require("fs"));
|
|
|
55
55
|
const os = __importStar(require("os"));
|
|
56
56
|
const path = __importStar(require("path"));
|
|
57
57
|
const conversation_1 = require("./conversation");
|
|
58
|
+
const posture_1 = require("./posture");
|
|
58
59
|
function agentguardHome() {
|
|
59
60
|
return process.env.AGENTGUARD_HOME || path.join(os.homedir(), '.agentguard');
|
|
60
61
|
}
|
|
61
|
-
function
|
|
62
|
-
return path.join(home, '
|
|
62
|
+
function advisorSessionDir(home = agentguardHome()) {
|
|
63
|
+
return path.join(home, 'advisor-sessions');
|
|
63
64
|
}
|
|
64
|
-
function
|
|
65
|
-
const dir =
|
|
65
|
+
function createAdvisorSessionLogger(home = agentguardHome(), now = new Date()) {
|
|
66
|
+
const dir = advisorSessionDir(home);
|
|
66
67
|
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
67
68
|
const stamp = now.toISOString().replace(/[:.]/g, '-');
|
|
68
69
|
const file = path.join(dir, `${stamp}.jsonl`);
|
|
@@ -75,10 +76,10 @@ function createCoachSessionLogger(home = agentguardHome(), now = new Date()) {
|
|
|
75
76
|
},
|
|
76
77
|
};
|
|
77
78
|
}
|
|
78
|
-
function
|
|
79
|
+
function writeAdvisorOutputs(profile, options = {}) {
|
|
79
80
|
const home = options.home ?? agentguardHome();
|
|
80
81
|
const language = options.language ?? profile.language;
|
|
81
|
-
const sessionDir =
|
|
82
|
+
const sessionDir = advisorSessionDir(home);
|
|
82
83
|
fs.mkdirSync(home, { recursive: true, mode: 0o700 });
|
|
83
84
|
fs.mkdirSync(sessionDir, { recursive: true, mode: 0o700 });
|
|
84
85
|
const policy = (0, conversation_1.buildPolicyFromProfile)(profile);
|
|
@@ -111,7 +112,34 @@ function renderPolicyYaml(policy, profile, now = new Date()) {
|
|
|
111
112
|
return lines.join('\n');
|
|
112
113
|
}).join('\n');
|
|
113
114
|
const tasks = profile.tasks.map((task) => ` - ${quoteYaml(task)}`).join('\n');
|
|
114
|
-
|
|
115
|
+
const posture = (0, posture_1.postureProfile)(profile.posture);
|
|
116
|
+
const canary = posture.canaryPercent === undefined ? '' : ` canaryPercent: ${posture.canaryPercent}\n`;
|
|
117
|
+
return `# AgentGuard Spend policy generated by agentguard advisor
|
|
118
|
+
# Generated at: ${now.toISOString()}
|
|
119
|
+
# Scope key: ${profile.scopeLabel}
|
|
120
|
+
id: ${policy.id}
|
|
121
|
+
name: ${quoteYaml(policy.name)}
|
|
122
|
+
version: ${policy.version}
|
|
123
|
+
effectiveFrom: ${quoteYaml(policy.effectiveFrom)}
|
|
124
|
+
mode: ${policy.mode}
|
|
125
|
+
requiredCapability: ${policy.requiredCapability ?? 'read_only'}
|
|
126
|
+
scope:
|
|
127
|
+
tenantId: ${quoteYaml(policy.scope.tenantId)}
|
|
128
|
+
models:
|
|
129
|
+
primary: ${profile.primaryModel}
|
|
130
|
+
fallback: ${profile.fallbackModel}
|
|
131
|
+
governancePosture:
|
|
132
|
+
posture: ${profile.posture}
|
|
133
|
+
auditRetentionDays: ${posture.auditRetentionDays}
|
|
134
|
+
approvalGates: ${posture.approvalGates}
|
|
135
|
+
downgradeStyle: ${posture.downgradeStyle}
|
|
136
|
+
${canary}tasks:
|
|
137
|
+
${tasks}
|
|
138
|
+
caps:
|
|
139
|
+
${caps}
|
|
140
|
+
systemInstructions: |
|
|
141
|
+
${indent(systemInstructions(profile), 2)}
|
|
142
|
+
`;
|
|
115
143
|
}
|
|
116
144
|
function renderQuickstartTs(policy, profile) {
|
|
117
145
|
return `import OpenAI from 'openai';\nimport { withSpendGuard, type SpendPolicy } from '@agentguard-run/spend';\n\nconst policy: SpendPolicy = ${JSON.stringify(policy, null, 2)};\n\nconst openrouter = new OpenAI({\n baseURL: 'https://openrouter.ai/api/v1',\n apiKey: process.env.OPENROUTER_API_KEY,\n});\n\nexport const guardedClient = withSpendGuard(openrouter, {\n policy,\n scope: { tenantId: '${escapeTs(profile.tenantId)}', agentId: '${escapeTs(profile.vertical)}' },\n capabilityClaim: '${policy.requiredCapability ?? 'read_only'}',\n});\n\nexport async function runGuardedTask(prompt: string) {\n return guardedClient.chat.completions.create({\n model: '${escapeTs(profile.primaryModel)}',\n messages: [{ role: 'user', content: prompt }],\n });\n}\n`;
|
|
@@ -155,7 +183,8 @@ function whyForWindow(window) {
|
|
|
155
183
|
return 'Limits spend inside the selected time window.';
|
|
156
184
|
}
|
|
157
185
|
function systemInstructions(profile) {
|
|
158
|
-
|
|
186
|
+
const posture = (0, posture_1.postureProfile)(profile.posture);
|
|
187
|
+
return `Run ${profile.vertical} tasks with ${profile.requiredCapability} capability under ${posture.label} governance posture. Prefer ${profile.primaryModel} for high-value work and ${profile.fallbackModel} for routine work. Keep evidence pointers in outputs and escalate anything outside the configured capability tier.`;
|
|
159
188
|
}
|
|
160
189
|
function quoteYaml(value) {
|
|
161
190
|
return JSON.stringify(value);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/advisor/output.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCH,wCAEC;AAED,8CAEC;AAED,gEAaC;AAED,kDAuBC;AAED,4CAyCC;AAED,gDAEC;AAED,gDAOC;AAED,gDAQC;AApJD,uCAAyB;AACzB,uCAAyB;AACzB,2CAA6B;AAE7B,iDAMwB;AACxB,uCAA2C;AAyB3C,SAAgB,cAAc;IAC5B,OAAO,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,aAAa,CAAC,CAAC;AAC/E,CAAC;AAED,SAAgB,iBAAiB,CAAC,IAAI,GAAG,cAAc,EAAE;IACvD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;AAC7C,CAAC;AAED,SAAgB,0BAA0B,CAAC,IAAI,GAAG,cAAc,EAAE,EAAE,GAAG,GAAG,IAAI,IAAI,EAAE;IAClF,MAAM,GAAG,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACpC,EAAE,CAAC,SAAS,CAA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O,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentGuard(TM) Spend: Advisor governance posture profiles.
|
|
3
|
+
*
|
|
4
|
+
* Patent notice: Protected by U.S. patent-pending technology
|
|
5
|
+
* (App. Nos. 63/983,615; 63/983,621; 63/983,843; 63/984,626;
|
|
6
|
+
* 64/071,781; 64/071,789).
|
|
7
|
+
*/
|
|
8
|
+
import type { CapabilityTier, EnforcementMode } from '../types';
|
|
9
|
+
export type GovernancePosture = 'velocity' | 'standard' | 'compliance';
|
|
10
|
+
export interface GovernancePostureProfile {
|
|
11
|
+
posture: GovernancePosture;
|
|
12
|
+
label: string;
|
|
13
|
+
defaultMode: EnforcementMode;
|
|
14
|
+
capabilityStyle: 'permissive' | 'balanced' | 'strict';
|
|
15
|
+
downgradeStyle: 'aggressive' | 'moderate' | 'conservative';
|
|
16
|
+
auditRetentionDays: number;
|
|
17
|
+
approvalGates: boolean;
|
|
18
|
+
canaryPercent?: number;
|
|
19
|
+
}
|
|
20
|
+
export declare const GOVERNANCE_POSTURES: Record<GovernancePosture, GovernancePostureProfile>;
|
|
21
|
+
export declare function normalizePosture(value?: string | null): GovernancePosture | null;
|
|
22
|
+
export declare function postureProfile(posture: GovernancePosture): GovernancePostureProfile;
|
|
23
|
+
export declare function suggestPostureForVertical(vertical: string): GovernancePosture;
|
|
24
|
+
export declare function applyPostureCapability(posture: GovernancePosture, text: string, fallback: CapabilityTier): CapabilityTier;
|
|
25
|
+
export declare function postureDescription(posture: GovernancePosture): string;
|
|
26
|
+
//# sourceMappingURL=posture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"posture.d.ts","sourceRoot":"","sources":["../../src/advisor/posture.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhE,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,UAAU,GAAG,YAAY,CAAC;AAEvE,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,eAAe,CAAC;IAC7B,eAAe,EAAE,YAAY,GAAG,UAAU,GAAG,QAAQ,CAAC;IACtD,cAAc,EAAE,YAAY,GAAG,UAAU,GAAG,cAAc,CAAC;IAC3D,kBAAkB,EAAE,MAAM,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,iBAAiB,EAAE,wBAAwB,CA6BnF,CAAC;AAmBF,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,iBAAiB,GAAG,IAAI,CAIhF;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,wBAAwB,CAEnF;AAED,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAE7E;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,iBAAiB,EAC1B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,cAAc,GACvB,cAAc,CAiBhB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAGrE"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AgentGuard(TM) Spend: Advisor governance posture profiles.
|
|
4
|
+
*
|
|
5
|
+
* Patent notice: Protected by U.S. patent-pending technology
|
|
6
|
+
* (App. Nos. 63/983,615; 63/983,621; 63/983,843; 63/984,626;
|
|
7
|
+
* 64/071,781; 64/071,789).
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.GOVERNANCE_POSTURES = void 0;
|
|
11
|
+
exports.normalizePosture = normalizePosture;
|
|
12
|
+
exports.postureProfile = postureProfile;
|
|
13
|
+
exports.suggestPostureForVertical = suggestPostureForVertical;
|
|
14
|
+
exports.applyPostureCapability = applyPostureCapability;
|
|
15
|
+
exports.postureDescription = postureDescription;
|
|
16
|
+
exports.GOVERNANCE_POSTURES = {
|
|
17
|
+
velocity: {
|
|
18
|
+
posture: 'velocity',
|
|
19
|
+
label: 'Velocity',
|
|
20
|
+
defaultMode: 'shadow',
|
|
21
|
+
capabilityStyle: 'permissive',
|
|
22
|
+
downgradeStyle: 'aggressive',
|
|
23
|
+
auditRetentionDays: 30,
|
|
24
|
+
approvalGates: false,
|
|
25
|
+
},
|
|
26
|
+
standard: {
|
|
27
|
+
posture: 'standard',
|
|
28
|
+
label: 'Standard',
|
|
29
|
+
defaultMode: 'enforce',
|
|
30
|
+
capabilityStyle: 'balanced',
|
|
31
|
+
downgradeStyle: 'moderate',
|
|
32
|
+
auditRetentionDays: 90,
|
|
33
|
+
approvalGates: false,
|
|
34
|
+
},
|
|
35
|
+
compliance: {
|
|
36
|
+
posture: 'compliance',
|
|
37
|
+
label: 'Compliance',
|
|
38
|
+
defaultMode: 'canary',
|
|
39
|
+
capabilityStyle: 'strict',
|
|
40
|
+
downgradeStyle: 'conservative',
|
|
41
|
+
auditRetentionDays: 2555,
|
|
42
|
+
approvalGates: true,
|
|
43
|
+
canaryPercent: 5,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
const VERTICAL_POSTURES = {
|
|
47
|
+
'law-firm': 'compliance',
|
|
48
|
+
healthcare: 'compliance',
|
|
49
|
+
accounting: 'compliance',
|
|
50
|
+
fintech: 'compliance',
|
|
51
|
+
insurance: 'compliance',
|
|
52
|
+
'real-estate': 'standard',
|
|
53
|
+
marketing: 'standard',
|
|
54
|
+
ecommerce: 'standard',
|
|
55
|
+
'local-services': 'standard',
|
|
56
|
+
dental: 'compliance',
|
|
57
|
+
software: 'velocity',
|
|
58
|
+
startup: 'standard',
|
|
59
|
+
'ai-lab': 'velocity',
|
|
60
|
+
'ai-team': 'velocity',
|
|
61
|
+
};
|
|
62
|
+
function normalizePosture(value) {
|
|
63
|
+
const normalized = (value ?? '').trim().toLowerCase();
|
|
64
|
+
if (normalized === 'velocity' || normalized === 'standard' || normalized === 'compliance')
|
|
65
|
+
return normalized;
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
function postureProfile(posture) {
|
|
69
|
+
return exports.GOVERNANCE_POSTURES[posture];
|
|
70
|
+
}
|
|
71
|
+
function suggestPostureForVertical(vertical) {
|
|
72
|
+
return VERTICAL_POSTURES[vertical] ?? 'standard';
|
|
73
|
+
}
|
|
74
|
+
function applyPostureCapability(posture, text, fallback) {
|
|
75
|
+
const lowered = text.toLowerCase();
|
|
76
|
+
if (posture === 'velocity') {
|
|
77
|
+
if (/execute|wire|ach|payout|capture funds/.test(lowered))
|
|
78
|
+
return 'payment_execute';
|
|
79
|
+
if (/refund|payment|charge|dispute|money|invoice/.test(lowered))
|
|
80
|
+
return 'payment_initiate';
|
|
81
|
+
return 'read_only';
|
|
82
|
+
}
|
|
83
|
+
if (posture === 'compliance') {
|
|
84
|
+
if (/refund|payment|charge|dispute|money|invoice|ledger|sox|fintech|bank/.test(lowered))
|
|
85
|
+
return 'payment_execute';
|
|
86
|
+
if (/write|update|chart|patient|health|phi|pii|legal|contract|tax|student|employment/.test(lowered))
|
|
87
|
+
return 'data_write';
|
|
88
|
+
return fallback === 'read_only' ? 'data_write' : fallback;
|
|
89
|
+
}
|
|
90
|
+
if (/refund|payment|charge|dispute|money|invoice/.test(lowered))
|
|
91
|
+
return 'payment_initiate';
|
|
92
|
+
if (/write|update|ledger|chart|patient|health|phi|pii|sox|legal|contract|tax|student|employment/.test(lowered))
|
|
93
|
+
return 'data_write';
|
|
94
|
+
return fallback;
|
|
95
|
+
}
|
|
96
|
+
function postureDescription(posture) {
|
|
97
|
+
const profile = postureProfile(posture);
|
|
98
|
+
return `${profile.label}: mode ${profile.defaultMode}, ${profile.capabilityStyle} capabilities, ${profile.downgradeStyle} downgrade chains, ${profile.auditRetentionDays} day audit retention`;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=posture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"posture.js","sourceRoot":"","sources":["../../src/advisor/posture.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAiEH,4CAIC;AAED,wCAEC;AAED,8DAEC;AAED,wDAqBC;AAED,gDAGC;AAxFY,QAAA,mBAAmB,GAAwD;IACtF,QAAQ,EAAE;QACR,OAAO,EAAE,UAAU;QACnB,KAAK,EAAE,UAAU;QACjB,WAAW,EAAE,QAAQ;QACrB,eAAe,EAAE,YAAY;QAC7B,cAAc,EAAE,YAAY;QAC5B,kBAAkB,EAAE,EAAE;QACtB,aAAa,EAAE,KAAK;KACrB;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,UAAU;QACnB,KAAK,EAAE,UAAU;QACjB,WAAW,EAAE,SAAS;QACtB,eAAe,EAAE,UAAU;QAC3B,cAAc,EAAE,UAAU;QAC1B,kBAAkB,EAAE,EAAE;QACtB,aAAa,EAAE,KAAK;KACrB;IACD,UAAU,EAAE;QACV,OAAO,EAAE,YAAY;QACrB,KAAK,EAAE,YAAY;QACnB,WAAW,EAAE,QAAQ;QACrB,eAAe,EAAE,QAAQ;QACzB,cAAc,EAAE,cAAc;QAC9B,kBAAkB,EAAE,IAAI;QACxB,aAAa,EAAE,IAAI;QACnB,aAAa,EAAE,CAAC;KACjB;CACF,CAAC;AAEF,MAAM,iBAAiB,GAAsC;IAC3D,UAAU,EAAE,YAAY;IACxB,UAAU,EAAE,YAAY;IACxB,UAAU,EAAE,YAAY;IACxB,OAAO,EAAE,YAAY;IACrB,SAAS,EAAE,YAAY;IACvB,aAAa,EAAE,UAAU;IACzB,SAAS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W,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC5D,CAAC;IAED,IAAI,6CAA6C,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,OAAO,kBAAkB,CAAC;IAC3F,IAAI,4FAA4F,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,OAAO,YAAY,CAAC;IACpI,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAgB,kBAAkB,CAAC,OAA0B;IAC3D,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IACxC,OAAO,GAAG,OAAO,CAAC,KAAK,UAAU,OAAO,CAAC,WAAW,KAAK,OAAO,CAAC,eAAe,kBAAkB,OAAO,CAAC,cAAc,sBAAsB,OAAO,CAAC,kBAAkB,sBAAsB,CAAC;AACjM,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* AgentGuard(TM) Spend:
|
|
2
|
+
* AgentGuard(TM) Spend: Advisor system prompt.
|
|
3
3
|
*
|
|
4
|
-
* AgentGuard
|
|
4
|
+
* AgentGuard Advisor runs locally in the customer terminal. It may call the
|
|
5
5
|
* customer's chosen OpenAI-compatible provider, but it never calls AgentGuard
|
|
6
6
|
* infrastructure for prompts, completions, provider keys, signing keys, or
|
|
7
7
|
* policy details.
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
* (App. Nos. 63/983,615; 63/983,621; 63/983,843; 63/984,626;
|
|
11
11
|
* 64/071,781; 64/071,789).
|
|
12
12
|
*/
|
|
13
|
-
export interface
|
|
13
|
+
export interface AdvisorPromptSection {
|
|
14
14
|
id: string;
|
|
15
15
|
title: string;
|
|
16
16
|
content: string;
|
|
17
17
|
}
|
|
18
|
-
export declare const
|
|
19
|
-
export declare const
|
|
18
|
+
export declare const ADVISOR_SYSTEM_PROMPT_SECTIONS: AdvisorPromptSection[];
|
|
19
|
+
export declare const ADVISOR_SYSTEM_PROMPT: string;
|
|
20
20
|
//# sourceMappingURL=system-prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/advisor/system-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,8BAA8B,EAAE,oBAAoB,EA2KhE,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAEnB,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* AgentGuard(TM) Spend:
|
|
3
|
+
* AgentGuard(TM) Spend: Advisor system prompt.
|
|
4
4
|
*
|
|
5
|
-
* AgentGuard
|
|
5
|
+
* AgentGuard Advisor runs locally in the customer terminal. It may call the
|
|
6
6
|
* customer's chosen OpenAI-compatible provider, but it never calls AgentGuard
|
|
7
7
|
* infrastructure for prompts, completions, provider keys, signing keys, or
|
|
8
8
|
* policy details.
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
* 64/071,781; 64/071,789).
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
16
|
-
exports.
|
|
15
|
+
exports.ADVISOR_SYSTEM_PROMPT = exports.ADVISOR_SYSTEM_PROMPT_SECTIONS = void 0;
|
|
16
|
+
exports.ADVISOR_SYSTEM_PROMPT_SECTIONS = [
|
|
17
17
|
{
|
|
18
18
|
id: 'role',
|
|
19
19
|
title: 'Role',
|
|
20
|
-
content: `You are AgentGuard
|
|
20
|
+
content: `You are AgentGuard Advisor, helping a business owner configure AgentGuard Spend for their specific company. You produce a complete policy.yaml plus quickstart code customized to their vertical. You never make up cap values without explaining the math. You ask one question at a time, keep the tone direct, and optimize for a working local setup in under 90 seconds.`,
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
id: 'sdk-knowledge',
|
|
@@ -53,6 +53,19 @@ Provider wrappers:
|
|
|
53
53
|
|
|
54
54
|
Streaming true-up:
|
|
55
55
|
The SDK reserves against projected tokens before a stream starts. On stream completion or cancellation, it signs a settlement entry with actual usage when the provider supplies usage, and falls back to the local token estimator when needed.`,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: 'governance-posture',
|
|
59
|
+
title: 'Governance Posture',
|
|
60
|
+
content: `Governance Posture shapes the generated policy from the team's operating style.
|
|
61
|
+
|
|
62
|
+
Velocity: for high-ship software and AI teams. Default mode is shadow. Capabilities are permissive, with read_only sufficient for most work. Downgrade chains are aggressive and move to cheap models fast. Audit retention is 30 days. Per-action approval gates are off.
|
|
63
|
+
|
|
64
|
+
Standard: default for most SaaS, e-commerce, real estate, agencies, local services, and startups. Default mode is enforce. Capabilities are balanced, with data_write for mutations. Downgrade chains are moderate. Audit retention is 90 days. Per-action approval gates are off.
|
|
65
|
+
|
|
66
|
+
Compliance: for law, healthcare, dental, accounting, SOX, fintech, and regulated workflows. Default mode is canary, meaning enforce with a 5 percent sticky shadow sample. Capabilities are strict, with payment_execute for financial workflows and data_write minimum for PHI or PII workflows. Downgrade chains are conservative, and regulated capabilities block instead of downgrade. Audit retention is 7 years. Per-action approval gates are on for payment_execute.
|
|
67
|
+
|
|
68
|
+
Custom: a Solo tier posture for future Outcome Builder workflows. In this release, tell the user Solo tier is required and choose Velocity, Standard, or Compliance instead.`,
|
|
56
69
|
},
|
|
57
70
|
{
|
|
58
71
|
id: 'vertical-encyclopedia-core',
|
|
@@ -163,15 +176,15 @@ caps:
|
|
|
163
176
|
{
|
|
164
177
|
id: 'conversation-flow',
|
|
165
178
|
title: 'Conversation Flow Instructions',
|
|
166
|
-
content: `Ask one question at a time. The required flow is: Q1 what are you building, Q2 team size and monthly volume, Q3 top three AI tasks, Q4 monthly budget or per-task budget, Q5 confirm and offer refinements. After Q5, show projected savings math before finalizing. Always explain cap values with arithmetic. Always offer to write the local file. If the vertical is unknown, ask for customer type, task list, and whether any task touches payments, health data, financial records, legal privilege, student records, or regulated employment decisions. Suggest agentguard demo at the end.`,
|
|
179
|
+
content: `Ask one question at a time. The required flow is: Q1 what are you building, confirm or override the suggested governance posture, Q2 team size and monthly volume, Q3 top three AI tasks, Q4 monthly budget or per-task budget, Q5 confirm and offer refinements. After Q5, show projected savings math before finalizing. Always explain cap values with arithmetic. Always offer to write the local file. If the vertical is unknown, ask for customer type, task list, and whether any task touches payments, health data, financial records, legal privilege, student records, or regulated employment decisions. Suggest agentguard demo at the end.`,
|
|
167
180
|
},
|
|
168
181
|
{
|
|
169
182
|
id: 'hard-rules',
|
|
170
183
|
title: 'Hard Rules',
|
|
171
|
-
content: `Never propose a proxy architecture. Never suggest managed-key services. Never invent model names or prices outside the cost table. For HIPAA, SOX, privilege, student records, financial records, or employment workflows, require capability gating with data_write minimum when data can be written. For payment-touching workflows, require payment_initiate. For money movement, require payment_execute plus verified attestation. Keep conversation logs local in ~/.agentguard/
|
|
184
|
+
content: `Never propose a proxy architecture. Never suggest managed-key services. Never invent model names or prices outside the cost table. For HIPAA, SOX, privilege, student records, financial records, or employment workflows, require capability gating with data_write minimum when data can be written. For payment-touching workflows, require payment_initiate. For money movement, require payment_execute plus verified attestation. Keep conversation logs local in ~/.agentguard/advisor-sessions.`,
|
|
172
185
|
},
|
|
173
186
|
];
|
|
174
|
-
exports.
|
|
187
|
+
exports.ADVISOR_SYSTEM_PROMPT = exports.ADVISOR_SYSTEM_PROMPT_SECTIONS
|
|
175
188
|
.map((section) => `## ${section.title}\n${section.content}`)
|
|
176
189
|
.join('\n\n');
|
|
177
190
|
//# sourceMappingURL=system-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/advisor/system-prompt.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAQU,QAAA,8BA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