@sponsio/sdk 0.1.0 → 0.2.0-alpha.8
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/contracts/benchmark/agentdojo.yaml +551 -0
- package/contracts/benchmark/odcv_bench.yaml +393 -0
- package/contracts/benchmark/redcode_exec.yaml +488 -0
- package/contracts/benchmark/swebench.yaml +176 -0
- package/contracts/benchmark/tau2_bench.yaml +984 -0
- package/contracts/capability/destructive.yaml +213 -0
- package/contracts/capability/factual-claims.yaml +79 -0
- package/contracts/capability/host-config-integrity.yaml +42 -9
- package/contracts/capability/self-modify.yaml +32 -1
- package/contracts/capability/shell.yaml +19 -10
- package/contracts/incident/claude-code-secret-bypass.yaml +48 -16
- package/contracts/incident/cursor-railway-wipe.yaml +60 -4
- package/contracts/incident/openclaw.yaml +9 -62
- package/contracts/premium/.gitkeep +5 -6
- package/dist/cli/cli.js +32 -0
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/packs.d.ts.map +1 -1
- package/dist/cli/packs.js +14 -8
- package/dist/cli/packs.js.map +1 -1
- package/dist/cli/patterns.d.ts +5 -4
- package/dist/cli/patterns.d.ts.map +1 -1
- package/dist/cli/patterns.js +11 -10
- package/dist/cli/patterns.js.map +1 -1
- package/dist/cli/prompt.js +5 -5
- package/dist/cli/prompt.js.map +1 -1
- package/dist/cli/scan.js +2 -2
- package/dist/cli/skill.d.ts +1 -1
- package/dist/cli/skill.js +1 -1
- package/dist/cli/validate.js +5 -5
- package/dist/cli/validate.js.map +1 -1
- package/dist/cloud/client.d.ts +76 -0
- package/dist/cloud/client.d.ts.map +1 -0
- package/dist/cloud/client.js +198 -0
- package/dist/cloud/client.js.map +1 -0
- package/dist/cloud/evidence.d.ts +108 -0
- package/dist/cloud/evidence.d.ts.map +1 -0
- package/dist/cloud/evidence.js +184 -0
- package/dist/cloud/evidence.js.map +1 -0
- package/dist/cloud/privacy.d.ts +67 -0
- package/dist/cloud/privacy.d.ts.map +1 -0
- package/dist/cloud/privacy.js +170 -0
- package/dist/cloud/privacy.js.map +1 -0
- package/dist/cloud/view-model.d.ts +49 -0
- package/dist/cloud/view-model.d.ts.map +1 -0
- package/dist/cloud/view-model.js +172 -0
- package/dist/cloud/view-model.js.map +1 -0
- package/dist/core/config-loader.d.ts.map +1 -1
- package/dist/core/config-loader.js +81 -9
- package/dist/core/config-loader.js.map +1 -1
- package/dist/core/evaluator.d.ts +11 -1
- package/dist/core/evaluator.d.ts.map +1 -1
- package/dist/core/evaluator.js +275 -13
- package/dist/core/evaluator.js.map +1 -1
- package/dist/core/formula.d.ts +76 -17
- package/dist/core/formula.d.ts.map +1 -1
- package/dist/core/formula.js +83 -1
- package/dist/core/formula.js.map +1 -1
- package/dist/core/grounding.d.ts +44 -8
- package/dist/core/grounding.d.ts.map +1 -1
- package/dist/core/grounding.js +197 -26
- package/dist/core/grounding.js.map +1 -1
- package/dist/core/nl-parser.d.ts +2 -2
- package/dist/core/nl-parser.d.ts.map +1 -1
- package/dist/core/nl-parser.js +617 -41
- package/dist/core/nl-parser.js.map +1 -1
- package/dist/core/pack-loader.d.ts.map +1 -1
- package/dist/core/pack-loader.js +14 -2
- package/dist/core/pack-loader.js.map +1 -1
- package/dist/core/parser.d.ts.map +1 -1
- package/dist/core/parser.js +30 -1
- package/dist/core/parser.js.map +1 -1
- package/dist/core/pattern-factory.d.ts.map +1 -1
- package/dist/core/pattern-factory.js +14 -1
- package/dist/core/pattern-factory.js.map +1 -1
- package/dist/core/patterns.d.ts +118 -1
- package/dist/core/patterns.d.ts.map +1 -1
- package/dist/core/patterns.js +189 -10
- package/dist/core/patterns.js.map +1 -1
- package/dist/core/session-log.d.ts.map +1 -1
- package/dist/core/session-log.js +20 -1
- package/dist/core/session-log.js.map +1 -1
- package/dist/core/sto.d.ts +21 -27
- package/dist/core/sto.d.ts.map +1 -1
- package/dist/core/sto.js +30 -33
- package/dist/core/sto.js.map +1 -1
- package/dist/core/tool-names.d.ts +59 -0
- package/dist/core/tool-names.d.ts.map +1 -0
- package/dist/core/tool-names.js +128 -0
- package/dist/core/tool-names.js.map +1 -0
- package/dist/index.d.ts +181 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +415 -67
- package/dist/index.js.map +1 -1
- package/dist/integrations/claude-agent.d.ts +5 -0
- package/dist/integrations/claude-agent.d.ts.map +1 -1
- package/dist/integrations/claude-agent.js +42 -13
- package/dist/integrations/claude-agent.js.map +1 -1
- package/dist/integrations/google-adk.d.ts +5 -3
- package/dist/integrations/google-adk.d.ts.map +1 -1
- package/dist/integrations/google-adk.js +9 -5
- package/dist/integrations/google-adk.js.map +1 -1
- package/dist/integrations/langchain.d.ts +7 -0
- package/dist/integrations/langchain.d.ts.map +1 -1
- package/dist/integrations/langchain.js +21 -3
- package/dist/integrations/langchain.js.map +1 -1
- package/dist/integrations/openai-agents.d.ts +22 -10
- package/dist/integrations/openai-agents.d.ts.map +1 -1
- package/dist/integrations/openai-agents.js +55 -15
- package/dist/integrations/openai-agents.js.map +1 -1
- package/dist/integrations/openai.d.ts +11 -0
- package/dist/integrations/openai.d.ts.map +1 -1
- package/dist/integrations/openai.js +130 -48
- package/dist/integrations/openai.js.map +1 -1
- package/dist/integrations/vercel-ai.d.ts +20 -9
- package/dist/integrations/vercel-ai.d.ts.map +1 -1
- package/dist/integrations/vercel-ai.js +131 -32
- package/dist/integrations/vercel-ai.js.map +1 -1
- package/package.json +17 -9
- package/prompts/onboard.md +26 -17
- package/prompts/scan.md +3 -5
- package/skills/SKILL.md +13 -83
- package/contracts/core/llm_safety.yaml +0 -140
- package/prompts/refresh.md +0 -118
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Talking to the cloud.
|
|
3
|
+
*
|
|
4
|
+
* Port of ``sponsio/cloud/client.py`` narrowed to the two calls an agent
|
|
5
|
+
* makes at runtime: pull the book it should enforce, and upload what it
|
|
6
|
+
* did. Everything else in the Python client belongs to the CLI.
|
|
7
|
+
*
|
|
8
|
+
* Until this existed the TypeScript SDK enforced correctly and uploaded
|
|
9
|
+
* nothing, so a customer running a TypeScript agent showed up in the
|
|
10
|
+
* console with no runs at all: rules could not be rolled out to them and
|
|
11
|
+
* nothing they did could be seen.
|
|
12
|
+
*/
|
|
13
|
+
export declare class CloudError extends Error {
|
|
14
|
+
readonly status?: number;
|
|
15
|
+
constructor(message: string, status?: number);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* ``SPONSIO_API_KEY`` first, then ``~/.sponsio/credentials``. The
|
|
19
|
+
* environment wins so CI and one-off runs can override a logged-in
|
|
20
|
+
* machine without touching files.
|
|
21
|
+
*/
|
|
22
|
+
export declare function readApiKey(): string | null;
|
|
23
|
+
/**
|
|
24
|
+
* ``SPONSIO_PROJECT``, or null.
|
|
25
|
+
*
|
|
26
|
+
* Which customer a run belongs to is deployment configuration, not code.
|
|
27
|
+
* A platform running one agent for forty customers ships one image and
|
|
28
|
+
* varies the environment; naming the customer in the call would mean an
|
|
29
|
+
* image per customer.
|
|
30
|
+
*/
|
|
31
|
+
export declare function readProject(): string | null;
|
|
32
|
+
export declare function baseUrl(): string;
|
|
33
|
+
export interface PulledRulebook {
|
|
34
|
+
yamlText: string;
|
|
35
|
+
versions?: string;
|
|
36
|
+
sha?: string;
|
|
37
|
+
agent?: string;
|
|
38
|
+
channel?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface CloudClientOptions {
|
|
41
|
+
apiKey?: string | null;
|
|
42
|
+
baseUrl?: string;
|
|
43
|
+
/** Milliseconds. A run must not wait on telemetry. */
|
|
44
|
+
timeoutMs?: number;
|
|
45
|
+
}
|
|
46
|
+
export declare class CloudClient {
|
|
47
|
+
readonly apiKey: string | null;
|
|
48
|
+
readonly base: string;
|
|
49
|
+
readonly timeoutMs: number;
|
|
50
|
+
constructor(opts?: CloudClientOptions);
|
|
51
|
+
/** Whether there is a credential to speak with at all. */
|
|
52
|
+
get configured(): boolean;
|
|
53
|
+
private request;
|
|
54
|
+
private static detail;
|
|
55
|
+
/**
|
|
56
|
+
* Fetch a project's rulebook.
|
|
57
|
+
*
|
|
58
|
+
* Without ``agent`` this returns every agent merged into one document:
|
|
59
|
+
* a guard binds by agent id and loads only its own section, so one
|
|
60
|
+
* request serves a whole repo.
|
|
61
|
+
*/
|
|
62
|
+
pullRulebook(project?: string | null, opts?: {
|
|
63
|
+
agent?: string;
|
|
64
|
+
version?: number;
|
|
65
|
+
}): Promise<PulledRulebook>;
|
|
66
|
+
/**
|
|
67
|
+
* Send a run to the cloud.
|
|
68
|
+
*
|
|
69
|
+
* Idempotent on the session key server-side, so a retry after a blip
|
|
70
|
+
* cannot double a run. Callers on the hot path must not wait on this:
|
|
71
|
+
* telemetry is outbound-only and best-effort, and losing it must never
|
|
72
|
+
* change what the agent does.
|
|
73
|
+
*/
|
|
74
|
+
ingestSession(project: string | null, payload: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/cloud/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AASH,qBAAa,UAAW,SAAQ,KAAK;IACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBACb,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAK7C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,MAAM,GAAG,IAAI,CAkB1C;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,IAAI,MAAM,GAAG,IAAI,CAE3C;AAcD,wBAAgB,OAAO,IAAI,MAAM,CAGhC;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,WAAW;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAEf,IAAI,GAAE,kBAAuB;IAMzC,0DAA0D;IAC1D,IAAI,UAAU,IAAI,OAAO,CAExB;YAEa,OAAO;IA0BrB,OAAO,CAAC,MAAM,CAAC,MAAM;IAerB;;;;;;OAMG;IACG,YAAY,CAChB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,EACvB,IAAI,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAO,GAC9C,OAAO,CAAC,cAAc,CAAC;IAkC1B;;;;;;;OAOG;IACG,aAAa,CACjB,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAsBpC"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Talking to the cloud.
|
|
3
|
+
*
|
|
4
|
+
* Port of ``sponsio/cloud/client.py`` narrowed to the two calls an agent
|
|
5
|
+
* makes at runtime: pull the book it should enforce, and upload what it
|
|
6
|
+
* did. Everything else in the Python client belongs to the CLI.
|
|
7
|
+
*
|
|
8
|
+
* Until this existed the TypeScript SDK enforced correctly and uploaded
|
|
9
|
+
* nothing, so a customer running a TypeScript agent showed up in the
|
|
10
|
+
* console with no runs at all: rules could not be rolled out to them and
|
|
11
|
+
* nothing they did could be seen.
|
|
12
|
+
*/
|
|
13
|
+
import { homedir } from "node:os";
|
|
14
|
+
import { join } from "node:path";
|
|
15
|
+
import { readFileSync } from "node:fs";
|
|
16
|
+
const DEFAULT_BASE_URL = "https://app.sponsio.dev";
|
|
17
|
+
const CREDENTIALS_PATH = join(homedir(), ".sponsio", "credentials");
|
|
18
|
+
export class CloudError extends Error {
|
|
19
|
+
status;
|
|
20
|
+
constructor(message, status) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.name = "CloudError";
|
|
23
|
+
if (status !== undefined)
|
|
24
|
+
this.status = status;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* ``SPONSIO_API_KEY`` first, then ``~/.sponsio/credentials``. The
|
|
29
|
+
* environment wins so CI and one-off runs can override a logged-in
|
|
30
|
+
* machine without touching files.
|
|
31
|
+
*/
|
|
32
|
+
export function readApiKey() {
|
|
33
|
+
const env = (process.env.SPONSIO_API_KEY ?? "").trim();
|
|
34
|
+
if (env)
|
|
35
|
+
return env;
|
|
36
|
+
try {
|
|
37
|
+
for (const line of readFileSync(CREDENTIALS_PATH, "utf8").split("\n")) {
|
|
38
|
+
const t = line.trim();
|
|
39
|
+
if (!t || t.startsWith("#"))
|
|
40
|
+
continue;
|
|
41
|
+
const eq = t.indexOf("=");
|
|
42
|
+
if (eq < 0)
|
|
43
|
+
continue;
|
|
44
|
+
if (t.slice(0, eq).trim() === "api_key") {
|
|
45
|
+
const v = t.slice(eq + 1).trim();
|
|
46
|
+
if (v)
|
|
47
|
+
return v;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* ``SPONSIO_PROJECT``, or null.
|
|
58
|
+
*
|
|
59
|
+
* Which customer a run belongs to is deployment configuration, not code.
|
|
60
|
+
* A platform running one agent for forty customers ships one image and
|
|
61
|
+
* varies the environment; naming the customer in the call would mean an
|
|
62
|
+
* image per customer.
|
|
63
|
+
*/
|
|
64
|
+
export function readProject() {
|
|
65
|
+
return (process.env.SPONSIO_PROJECT ?? "").trim() || null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Strip trailing slashes without a regex.
|
|
69
|
+
*
|
|
70
|
+
* ``/\/+$/`` is quadratic on a string that is mostly slashes, and the
|
|
71
|
+
* base URL comes from the environment on a machine we do not run.
|
|
72
|
+
*/
|
|
73
|
+
function trimSlashes(url) {
|
|
74
|
+
let end = url.length;
|
|
75
|
+
while (end > 0 && url.charCodeAt(end - 1) === 47)
|
|
76
|
+
end--;
|
|
77
|
+
return url.slice(0, end);
|
|
78
|
+
}
|
|
79
|
+
export function baseUrl() {
|
|
80
|
+
const explicit = (process.env.SPONSIO_API_URL ?? "").trim();
|
|
81
|
+
return trimSlashes(explicit || DEFAULT_BASE_URL);
|
|
82
|
+
}
|
|
83
|
+
export class CloudClient {
|
|
84
|
+
apiKey;
|
|
85
|
+
base;
|
|
86
|
+
timeoutMs;
|
|
87
|
+
constructor(opts = {}) {
|
|
88
|
+
this.apiKey = opts.apiKey === undefined ? readApiKey() : opts.apiKey;
|
|
89
|
+
this.base = trimSlashes(opts.baseUrl ?? baseUrl());
|
|
90
|
+
this.timeoutMs = opts.timeoutMs ?? 10_000;
|
|
91
|
+
}
|
|
92
|
+
/** Whether there is a credential to speak with at all. */
|
|
93
|
+
get configured() {
|
|
94
|
+
return Boolean(this.apiKey);
|
|
95
|
+
}
|
|
96
|
+
async request(method, path, body, contentType) {
|
|
97
|
+
if (!this.apiKey)
|
|
98
|
+
throw new CloudError("no API key configured");
|
|
99
|
+
const controller = new AbortController();
|
|
100
|
+
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
101
|
+
try {
|
|
102
|
+
const headers = {
|
|
103
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
104
|
+
};
|
|
105
|
+
if (contentType)
|
|
106
|
+
headers["Content-Type"] = contentType;
|
|
107
|
+
const res = await fetch(this.base + path, {
|
|
108
|
+
method,
|
|
109
|
+
headers,
|
|
110
|
+
...(body === undefined ? {} : { body }),
|
|
111
|
+
signal: controller.signal,
|
|
112
|
+
});
|
|
113
|
+
return { status: res.status, text: await res.text(), headers: res.headers };
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
clearTimeout(timer);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
static detail(text, fallback) {
|
|
120
|
+
try {
|
|
121
|
+
const parsed = JSON.parse(text);
|
|
122
|
+
const d = parsed.detail;
|
|
123
|
+
if (typeof d === "string")
|
|
124
|
+
return d;
|
|
125
|
+
if (d && typeof d === "object") {
|
|
126
|
+
const o = d;
|
|
127
|
+
return o.message ?? o.error ?? fallback;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
/* not JSON; the fallback says what happened */
|
|
132
|
+
}
|
|
133
|
+
return fallback;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Fetch a project's rulebook.
|
|
137
|
+
*
|
|
138
|
+
* Without ``agent`` this returns every agent merged into one document:
|
|
139
|
+
* a guard binds by agent id and loads only its own section, so one
|
|
140
|
+
* request serves a whole repo.
|
|
141
|
+
*/
|
|
142
|
+
async pullRulebook(project, opts = {}) {
|
|
143
|
+
const q = [];
|
|
144
|
+
if (project)
|
|
145
|
+
q.push(`project=${encodeURIComponent(project)}`);
|
|
146
|
+
if (opts.agent)
|
|
147
|
+
q.push(`agent=${encodeURIComponent(opts.agent)}`);
|
|
148
|
+
if (opts.version !== undefined)
|
|
149
|
+
q.push(`version=${opts.version}`);
|
|
150
|
+
const path = "/v1/rulebook" + (q.length ? "?" + q.join("&") : "");
|
|
151
|
+
const { status, text, headers } = await this.request("GET", path);
|
|
152
|
+
if (status === 404) {
|
|
153
|
+
// "Nothing published yet" rather than a failure: the caller may
|
|
154
|
+
// publish its local yaml instead of giving up.
|
|
155
|
+
throw new CloudError(CloudClient.detail(text, "no rulebook published"), 404);
|
|
156
|
+
}
|
|
157
|
+
if (status !== 200) {
|
|
158
|
+
throw new CloudError(CloudClient.detail(text, `pull failed (${status})`), status);
|
|
159
|
+
}
|
|
160
|
+
const out = { yamlText: text };
|
|
161
|
+
const v = headers.get("x-rulebook-versions") ?? headers.get("x-rulebook-version");
|
|
162
|
+
if (v)
|
|
163
|
+
out.versions = v;
|
|
164
|
+
const sha = headers.get("x-rulebook-sha");
|
|
165
|
+
if (sha)
|
|
166
|
+
out.sha = sha;
|
|
167
|
+
const agent = headers.get("x-rulebook-agent");
|
|
168
|
+
if (agent)
|
|
169
|
+
out.agent = agent;
|
|
170
|
+
const channel = headers.get("x-rulebook-channel");
|
|
171
|
+
if (channel)
|
|
172
|
+
out.channel = channel;
|
|
173
|
+
return out;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Send a run to the cloud.
|
|
177
|
+
*
|
|
178
|
+
* Idempotent on the session key server-side, so a retry after a blip
|
|
179
|
+
* cannot double a run. Callers on the hot path must not wait on this:
|
|
180
|
+
* telemetry is outbound-only and best-effort, and losing it must never
|
|
181
|
+
* change what the agent does.
|
|
182
|
+
*/
|
|
183
|
+
async ingestSession(project, payload) {
|
|
184
|
+
const path = "/v1/sessions/ingest" +
|
|
185
|
+
(project ? `?project=${encodeURIComponent(project)}` : "");
|
|
186
|
+
const { status, text } = await this.request("POST", path, JSON.stringify(payload), "application/json");
|
|
187
|
+
if (status !== 200) {
|
|
188
|
+
throw new CloudError(CloudClient.detail(text, `ingest failed (${status})`), status);
|
|
189
|
+
}
|
|
190
|
+
try {
|
|
191
|
+
return JSON.parse(text);
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
throw new CloudError("ingest returned a non-JSON body", status);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=client.js.map
|
|
@@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AAE,CAAC,CAAC;QAC7D,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CACzC,MAAM,EACN,IAAI,EACJ,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EACvB,kBAAkB,CACnB,CAAC;QACF,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,MAAM,IAAI,UAAU,CAClB,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,kBAAkB,MAAM,GAAG,CAAC,EACrD,MAAM,CACP,CAAC;QACJ,CAAC;QACD,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAA4B,CAAC;QACrD,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,UAAU,CAAC,iCAAiC,EAAE,MAAM,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The evidence lane, from TypeScript.
|
|
3
|
+
*
|
|
4
|
+
* Rules check what an agent *does*; evidence checks what it *says*. A
|
|
5
|
+
* model that reports "the three line items total $100" is making a claim
|
|
6
|
+
* that is either true of the numbers it was given or is not, and no
|
|
7
|
+
* amount of prompting settles it. This sends the claim to
|
|
8
|
+
* `/v1/evidence/verify`, which resolves it against the declared inputs
|
|
9
|
+
* and answers PASS, MISMATCH, or a verdict meaning it could not tell.
|
|
10
|
+
*
|
|
11
|
+
* Parity with `sponsio/cloud/evidence.py`: same endpoint, same wire
|
|
12
|
+
* shape, same verdict vocabulary. One service, one meter — the server
|
|
13
|
+
* records usage per tenant and cannot see which SDK called it.
|
|
14
|
+
*
|
|
15
|
+
* The judgement is entirely server-side. This file normalises inputs,
|
|
16
|
+
* makes one request, and classifies the answer.
|
|
17
|
+
*
|
|
18
|
+
* @module @sponsio/sdk/cloud/evidence
|
|
19
|
+
*/
|
|
20
|
+
/** A verdict the server can return. Anything else is treated as unknown. */
|
|
21
|
+
export type EvidenceVerdict = "PASS" | "MISMATCH" | "NO_EVIDENCE" | "SOURCE_UNAVAILABLE" | "UNDERDETERMINED";
|
|
22
|
+
/** What the server says to do about a verdict. */
|
|
23
|
+
export type EvidenceAction = "release" | "block" | "clarify";
|
|
24
|
+
/**
|
|
25
|
+
* One input, tagged with where its value came from.
|
|
26
|
+
*
|
|
27
|
+
* The tag is not decoration. Each predicate declares which sources it
|
|
28
|
+
* will accept, and the server refuses a value that arrived from anywhere
|
|
29
|
+
* else: a total the model made up must not be checked against itself.
|
|
30
|
+
* `GET /v1/evidence/predicates` lists the allowlist per predicate.
|
|
31
|
+
*/
|
|
32
|
+
export interface TaggedInput {
|
|
33
|
+
value: unknown;
|
|
34
|
+
source: string;
|
|
35
|
+
}
|
|
36
|
+
/** Ergonomic forms accepted per input: a tagged object or a `[value, source]` pair. */
|
|
37
|
+
export type InputSpec = TaggedInput | [unknown, string];
|
|
38
|
+
export interface EvidenceResult {
|
|
39
|
+
predicate: string;
|
|
40
|
+
verdict: EvidenceVerdict | string;
|
|
41
|
+
action: EvidenceAction | string;
|
|
42
|
+
/** The resolved values the verdict was reached from. */
|
|
43
|
+
values: unknown[];
|
|
44
|
+
evidenceTs?: number;
|
|
45
|
+
source?: string;
|
|
46
|
+
tableVersion?: string;
|
|
47
|
+
/** The right value, when the server knows it. Never invented. */
|
|
48
|
+
correction?: unknown;
|
|
49
|
+
/** What to ask about, on a clarify action. */
|
|
50
|
+
clarifyOn: unknown[];
|
|
51
|
+
/** Server-side record of this check, for an audit trail. */
|
|
52
|
+
attestationId?: string;
|
|
53
|
+
}
|
|
54
|
+
/** The check did not reach a verdict. The caller decides open or closed. */
|
|
55
|
+
export declare class EvidenceError extends Error {
|
|
56
|
+
readonly status?: number;
|
|
57
|
+
constructor(message: string, status?: number);
|
|
58
|
+
}
|
|
59
|
+
/** True when this verdict must stop the response. */
|
|
60
|
+
export declare function isBlocking(result: EvidenceResult): boolean;
|
|
61
|
+
/** True when this verdict asks the agent to clarify rather than stop. */
|
|
62
|
+
export declare function needsClarification(result: EvidenceResult): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Ergonomic input forms to the wire's tagged shape.
|
|
65
|
+
*
|
|
66
|
+
* An untagged input is rejected here rather than sent. The server would
|
|
67
|
+
* refuse it anyway under the taint rule, and failing locally names the
|
|
68
|
+
* input that is missing its tag.
|
|
69
|
+
*
|
|
70
|
+
* The pair form needs a string source. Without that check a two-element
|
|
71
|
+
* array of data read as a pair: `{ items: [40, 60] }` became
|
|
72
|
+
* `value: 40, source: "60"`, and the server then refused source `"60"`
|
|
73
|
+
* as untrusted, an error naming nothing the caller had written. A list
|
|
74
|
+
* value takes the explicit form, `[[40, 60], "submitted_output"]`.
|
|
75
|
+
*/
|
|
76
|
+
export declare function normalizeInputs(inputs?: Record<string, InputSpec>): Record<string, TaggedInput>;
|
|
77
|
+
export interface EvidenceClientOptions {
|
|
78
|
+
/** Defaults to `SPONSIO_API_KEY`. */
|
|
79
|
+
apiKey?: string;
|
|
80
|
+
/** Defaults to `SPONSIO_API_URL`, then `https://app.sponsio.dev`. */
|
|
81
|
+
url?: string;
|
|
82
|
+
/** Per-request timeout in milliseconds. */
|
|
83
|
+
timeoutMs?: number;
|
|
84
|
+
}
|
|
85
|
+
export declare class EvidenceClient {
|
|
86
|
+
readonly url: string;
|
|
87
|
+
private readonly apiKey;
|
|
88
|
+
private readonly timeoutMs;
|
|
89
|
+
constructor(opts?: EvidenceClientOptions);
|
|
90
|
+
get configured(): boolean;
|
|
91
|
+
private post;
|
|
92
|
+
/**
|
|
93
|
+
* Verify one claim against fresh evidence, server-side.
|
|
94
|
+
*
|
|
95
|
+
* Throws `EvidenceError` when the check did not run to a verdict.
|
|
96
|
+
* Decide open or closed at the call site; closed means treating the
|
|
97
|
+
* throw as a block.
|
|
98
|
+
*/
|
|
99
|
+
verify(predicate: string, opts?: {
|
|
100
|
+
value?: unknown;
|
|
101
|
+
text?: string;
|
|
102
|
+
inputs?: Record<string, InputSpec>;
|
|
103
|
+
sessionId?: string;
|
|
104
|
+
}): Promise<EvidenceResult>;
|
|
105
|
+
/** The predicate catalog this key can reach. */
|
|
106
|
+
predicates(): Promise<Record<string, unknown>[]>;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=evidence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evidence.d.ts","sourceRoot":"","sources":["../../src/cloud/evidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,4EAA4E;AAC5E,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,UAAU,GACV,aAAa,GACb,oBAAoB,GACpB,iBAAiB,CAAC;AAEtB,kDAAkD;AAClD,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,uFAAuF;AACvF,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAExD,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,eAAe,GAAG,MAAM,CAAC;IAClC,MAAM,EAAE,cAAc,GAAG,MAAM,CAAC;IAChC,wDAAwD;IACxD,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,8CAA8C;IAC9C,SAAS,EAAE,OAAO,EAAE,CAAC;IACrB,4DAA4D;IAC5D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,4EAA4E;AAC5E,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,MAA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
+
/**
|
|
2
|
+
* The evidence lane, from TypeScript.
|
|
3
|
+
*
|
|
4
|
+
* Rules check what an agent *does*; evidence checks what it *says*. A
|
|
5
|
+
* model that reports "the three line items total $100" is making a claim
|
|
6
|
+
* that is either true of the numbers it was given or is not, and no
|
|
7
|
+
* amount of prompting settles it. This sends the claim to
|
|
8
|
+
* `/v1/evidence/verify`, which resolves it against the declared inputs
|
|
9
|
+
* and answers PASS, MISMATCH, or a verdict meaning it could not tell.
|
|
10
|
+
*
|
|
11
|
+
* Parity with `sponsio/cloud/evidence.py`: same endpoint, same wire
|
|
12
|
+
* shape, same verdict vocabulary. One service, one meter — the server
|
|
13
|
+
* records usage per tenant and cannot see which SDK called it.
|
|
14
|
+
*
|
|
15
|
+
* The judgement is entirely server-side. This file normalises inputs,
|
|
16
|
+
* makes one request, and classifies the answer.
|
|
17
|
+
*
|
|
18
|
+
* @module @sponsio/sdk/cloud/evidence
|
|
19
|
+
*/
|
|
20
|
+
/** The check did not reach a verdict. The caller decides open or closed. */
|
|
21
|
+
export class EvidenceError extends Error {
|
|
22
|
+
status;
|
|
23
|
+
constructor(message, status) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.name = "EvidenceError";
|
|
26
|
+
this.status = status;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** True when this verdict must stop the response. */
|
|
30
|
+
export function isBlocking(result) {
|
|
31
|
+
return result.action === "block";
|
|
32
|
+
}
|
|
33
|
+
/** True when this verdict asks the agent to clarify rather than stop. */
|
|
34
|
+
export function needsClarification(result) {
|
|
35
|
+
return result.action === "clarify";
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Ergonomic input forms to the wire's tagged shape.
|
|
39
|
+
*
|
|
40
|
+
* An untagged input is rejected here rather than sent. The server would
|
|
41
|
+
* refuse it anyway under the taint rule, and failing locally names the
|
|
42
|
+
* input that is missing its tag.
|
|
43
|
+
*
|
|
44
|
+
* The pair form needs a string source. Without that check a two-element
|
|
45
|
+
* array of data read as a pair: `{ items: [40, 60] }` became
|
|
46
|
+
* `value: 40, source: "60"`, and the server then refused source `"60"`
|
|
47
|
+
* as untrusted, an error naming nothing the caller had written. A list
|
|
48
|
+
* value takes the explicit form, `[[40, 60], "submitted_output"]`.
|
|
49
|
+
*/
|
|
50
|
+
export function normalizeInputs(inputs) {
|
|
51
|
+
const wire = {};
|
|
52
|
+
for (const [name, spec] of Object.entries(inputs ?? {})) {
|
|
53
|
+
if (Array.isArray(spec) && spec.length === 2 && typeof spec[1] === "string") {
|
|
54
|
+
wire[name] = { value: spec[0], source: spec[1] };
|
|
55
|
+
}
|
|
56
|
+
else if (spec && typeof spec === "object" && "source" in spec) {
|
|
57
|
+
wire[name] = {
|
|
58
|
+
value: spec.value,
|
|
59
|
+
source: String(spec.source),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
throw new Error(`input '${name}' needs a source tag: pass [value, source] or ` +
|
|
64
|
+
`{ value, source } — the server rejects untagged inputs (taint rule)`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return wire;
|
|
68
|
+
}
|
|
69
|
+
function parseResult(payload) {
|
|
70
|
+
const evidence = (payload.evidence ?? {});
|
|
71
|
+
const rawValues = evidence.values;
|
|
72
|
+
const clarify = payload.clarify_on;
|
|
73
|
+
return {
|
|
74
|
+
predicate: String(payload.predicate ?? ""),
|
|
75
|
+
verdict: String(payload.verdict ?? ""),
|
|
76
|
+
action: String(payload.action ?? ""),
|
|
77
|
+
values: Array.isArray(rawValues) ? rawValues : [],
|
|
78
|
+
...(typeof evidence.ts === "number" ? { evidenceTs: evidence.ts } : {}),
|
|
79
|
+
...(typeof evidence.source === "string" ? { source: evidence.source } : {}),
|
|
80
|
+
...(typeof evidence.table_version === "string"
|
|
81
|
+
? { tableVersion: evidence.table_version }
|
|
82
|
+
: {}),
|
|
83
|
+
...(payload.correction !== null && payload.correction !== undefined
|
|
84
|
+
? { correction: payload.correction }
|
|
85
|
+
: {}),
|
|
86
|
+
clarifyOn: Array.isArray(clarify) ? clarify : [],
|
|
87
|
+
...(typeof payload.attestation_id === "string"
|
|
88
|
+
? { attestationId: payload.attestation_id }
|
|
89
|
+
: {}),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export class EvidenceClient {
|
|
93
|
+
url;
|
|
94
|
+
apiKey;
|
|
95
|
+
timeoutMs;
|
|
96
|
+
constructor(opts = {}) {
|
|
97
|
+
this.apiKey = opts.apiKey ?? process.env.SPONSIO_API_KEY ?? undefined;
|
|
98
|
+
// Trailing slashes stripped without a regex. `/\/+$/` backtracks
|
|
99
|
+
// polynomially on a string of many slashes, and the URL comes from
|
|
100
|
+
// an env var, so it is not ours to trust about its own shape.
|
|
101
|
+
let base = opts.url ?? process.env.SPONSIO_API_URL ?? "https://app.sponsio.dev";
|
|
102
|
+
let end = base.length;
|
|
103
|
+
while (end > 0 && base.charCodeAt(end - 1) === 47)
|
|
104
|
+
end -= 1;
|
|
105
|
+
this.url = base.slice(0, end);
|
|
106
|
+
this.timeoutMs = opts.timeoutMs ?? 10_000;
|
|
107
|
+
}
|
|
108
|
+
get configured() {
|
|
109
|
+
return Boolean(this.apiKey);
|
|
110
|
+
}
|
|
111
|
+
async post(path, body) {
|
|
112
|
+
if (!this.apiKey) {
|
|
113
|
+
throw new EvidenceError("no API key: set SPONSIO_API_KEY or pass apiKey to EvidenceClient");
|
|
114
|
+
}
|
|
115
|
+
const controller = new AbortController();
|
|
116
|
+
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
117
|
+
let response;
|
|
118
|
+
try {
|
|
119
|
+
response = await fetch(`${this.url}${path}`, {
|
|
120
|
+
method: "POST",
|
|
121
|
+
headers: {
|
|
122
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
123
|
+
"Content-Type": "application/json",
|
|
124
|
+
"User-Agent": "sponsio-sdk-ts",
|
|
125
|
+
},
|
|
126
|
+
body: JSON.stringify(body),
|
|
127
|
+
signal: controller.signal,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
catch (err) {
|
|
131
|
+
throw new EvidenceError(`cannot reach ${this.url}: ${err instanceof Error ? err.message : err}`);
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
clearTimeout(timer);
|
|
135
|
+
}
|
|
136
|
+
const text = await response.text();
|
|
137
|
+
let payload;
|
|
138
|
+
try {
|
|
139
|
+
payload = text ? JSON.parse(text) : {};
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
throw new EvidenceError(`${this.url} answered ${response.status} with non-JSON`, response.status);
|
|
143
|
+
}
|
|
144
|
+
if (!response.ok) {
|
|
145
|
+
const detail = payload?.detail;
|
|
146
|
+
throw new EvidenceError(typeof detail === "string" ? detail : `verify failed (${response.status})`, response.status);
|
|
147
|
+
}
|
|
148
|
+
return payload;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Verify one claim against fresh evidence, server-side.
|
|
152
|
+
*
|
|
153
|
+
* Throws `EvidenceError` when the check did not run to a verdict.
|
|
154
|
+
* Decide open or closed at the call site; closed means treating the
|
|
155
|
+
* throw as a block.
|
|
156
|
+
*/
|
|
157
|
+
async verify(predicate, opts = {}) {
|
|
158
|
+
const body = {
|
|
159
|
+
predicate,
|
|
160
|
+
claim: { value: opts.value ?? null, text: opts.text ?? null },
|
|
161
|
+
inputs: normalizeInputs(opts.inputs),
|
|
162
|
+
};
|
|
163
|
+
if (opts.sessionId)
|
|
164
|
+
body.session_id = opts.sessionId;
|
|
165
|
+
return parseResult(await this.post("/v1/evidence/verify", body));
|
|
166
|
+
}
|
|
167
|
+
/** The predicate catalog this key can reach. */
|
|
168
|
+
async predicates() {
|
|
169
|
+
if (!this.apiKey) {
|
|
170
|
+
throw new EvidenceError("no API key: set SPONSIO_API_KEY or pass apiKey to EvidenceClient");
|
|
171
|
+
}
|
|
172
|
+
const response = await fetch(`${this.url}/v1/evidence/predicates`, {
|
|
173
|
+
headers: {
|
|
174
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
175
|
+
"User-Agent": "sponsio-sdk-ts",
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
if (!response.ok) {
|
|
179
|
+
throw new EvidenceError(`predicates failed (${response.status})`, response.status);
|
|
180
|
+
}
|
|
181
|
+
return (await response.json());
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=evidence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evidence.js","sourceRoot":"","sources":["../../src/cloud/evidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AA8CH,4EAA4E;AAC5E,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,MAAM,CAAU;IACzB,YAAY,OAAe,EAAE,MAAe;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,qDAAqD;AACrD,MAAM,UAAU,UAAU,CAAC,MAAsB;IAC/C,OAAO,MAAM,CAAC,MAAM,KAAK,OAAO,CAAC;AACnC,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,kBAAkB,CAAC,MAAsB;IACvD,OAAO,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC;AACrC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAkC;IAElC,MAAM,IAAI,GAAgC,EAAE,CAAC;IAC7C,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,CAAC;QACxD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC5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C,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,IAAI,aAAa,CACrB,kEAAkE,CACnE,CAAC;QACJ,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,yBAAyB,EAAE;YACjE,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE;gBACtC,YAAY,EAAE,gBAAgB;aAC/B;SACF,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,aAAa,CACrB,sBAAsB,QAAQ,CAAC,MAAM,GAAG,EACxC,QAAQ,CAAC,MAAM,CAChB,CAAC;QACJ,CAAC;QACD,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA8B,CAAC;IAC9D,CAAC;CACF"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What may leave this machine.
|
|
3
|
+
*
|
|
4
|
+
* Port of ``sponsio/bridge/privacy.py``. Enforcement already happened
|
|
5
|
+
* here — the det checks are pure and local — so nothing in this file can
|
|
6
|
+
* change a verdict. It only narrows what the console is shown, which is
|
|
7
|
+
* what makes it cheap: the run's shape is all the cloud needs to render
|
|
8
|
+
* a dashboard, count a finding, or meter usage.
|
|
9
|
+
*/
|
|
10
|
+
export declare const LEVELS: readonly ["full", "shape", "hashed", "metadata", "tool_calls"];
|
|
11
|
+
export type PrivacyLevel = (typeof LEVELS)[number];
|
|
12
|
+
/**
|
|
13
|
+
* The level in force. The environment beats the argument, deliberately:
|
|
14
|
+
* the person who decides what may leave a machine is the operator of
|
|
15
|
+
* that machine, not the author of the agent running on it.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolve(explicit?: string): PrivacyLevel;
|
|
18
|
+
/**
|
|
19
|
+
* The structure of an argument set, with every value replaced.
|
|
20
|
+
*
|
|
21
|
+
* Lengths survive for strings and lists because "the model passed a
|
|
22
|
+
* 40 000-character path" is a debugging fact and not content, and it is
|
|
23
|
+
* the one an oversize-argument rule fires on.
|
|
24
|
+
*/
|
|
25
|
+
export declare function shape(args: unknown): string;
|
|
26
|
+
/**
|
|
27
|
+
* ``json.dumps`` as Python writes it, which is what the other runtime
|
|
28
|
+
* hashes and displays.
|
|
29
|
+
*
|
|
30
|
+
* ``JSON.stringify`` omits the spaces Python puts after ``,`` and
|
|
31
|
+
* ``:``. That is invisible in a console and decisive in a digest: the
|
|
32
|
+
* same arguments hashed to different values on the two sides, so
|
|
33
|
+
* duplicate and loop detection disagreed about whether two calls were
|
|
34
|
+
* the same call. ``sortKeys`` additionally makes two calls that differ
|
|
35
|
+
* only in key order agree, which is what the digest is for.
|
|
36
|
+
*/
|
|
37
|
+
export declare function pyJson(value: unknown, sortKeys?: boolean): string;
|
|
38
|
+
/**
|
|
39
|
+
* A stable short hash of an argument set. An equality token, not a
|
|
40
|
+
* signature, which is why twelve hex characters is enough: it is what
|
|
41
|
+
* lets duplicate and loop detection keep working with no content.
|
|
42
|
+
*/
|
|
43
|
+
export declare function digest(args: unknown): string;
|
|
44
|
+
/** What ``argsPreview`` carries at this level. */
|
|
45
|
+
export declare function preview(args: unknown, level: PrivacyLevel, fullPreview: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* What a model turn may quote of itself. A response is the most
|
|
48
|
+
* content-bearing field in the payload, so it goes one level earlier
|
|
49
|
+
* than arguments do.
|
|
50
|
+
*/
|
|
51
|
+
export declare function say(text: string, level: PrivacyLevel): string;
|
|
52
|
+
/**
|
|
53
|
+
* Whether a step of this type is recorded at all.
|
|
54
|
+
*
|
|
55
|
+
* Only ``tool_calls`` drops whole steps. Every other level keeps the
|
|
56
|
+
* shape of the run and empties fields; this one keeps the action lane
|
|
57
|
+
* alone, because that is what the customer asked for by name.
|
|
58
|
+
*/
|
|
59
|
+
export declare function keepsStep(stepType: string, level: PrivacyLevel): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* A stamp for the run, so a reader knows what they are not seeing.
|
|
62
|
+
*
|
|
63
|
+
* A dashboard showing empty arguments has to be able to say whether the
|
|
64
|
+
* agent passed none or the deployment declined to send them.
|
|
65
|
+
*/
|
|
66
|
+
export declare function describe(level: PrivacyLevel): Record<string, unknown>;
|
|
67
|
+
//# sourceMappingURL=privacy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privacy.d.ts","sourceRoot":"","sources":["../../src/cloud/privacy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,eAAO,MAAM,MAAM,gEAAiE,CAAC;AACrF,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AASnD;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,YAAY,CAWvD;AA0BD;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAS3C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,UAAQ,GAAG,MAAM,CAmB/D;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAM5C;AAED,kDAAkD;AAClD,wBAAgB,OAAO,CACrB,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,YAAY,EACnB,WAAW,EAAE,MAAM,GAClB,MAAM,CAKR;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,MAAM,CAE7D;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAExE;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASrE"}
|