@sponsio/sdk 0.1.0 → 0.2.0-alpha.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/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/core/llm_safety.yaml +12 -14
- package/contracts/incident/claude-code-secret-bypass.yaml +2 -2
- package/contracts/incident/openclaw.yaml +5 -4
- package/contracts/premium/.gitkeep +5 -6
- package/dist/cli/packs.js +3 -3
- 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/core/config-loader.d.ts.map +1 -1
- package/dist/core/config-loader.js +65 -9
- package/dist/core/config-loader.js.map +1 -1
- package/dist/core/evaluator.d.ts +9 -1
- package/dist/core/evaluator.d.ts.map +1 -1
- package/dist/core/evaluator.js +189 -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 +1 -1
- package/dist/core/grounding.d.ts.map +1 -1
- package/dist/core/grounding.js +17 -1
- package/dist/core/grounding.js.map +1 -1
- package/dist/core/nl-parser.d.ts +1 -1
- package/dist/core/nl-parser.js +2 -2
- 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 +8 -1
- package/dist/core/pattern-factory.js.map +1 -1
- package/dist/core/patterns.d.ts +49 -1
- package/dist/core/patterns.d.ts.map +1 -1
- package/dist/core/patterns.js +56 -0
- 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/index.d.ts +37 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +57 -44
- package/dist/index.js.map +1 -1
- package/dist/integrations/openai-agents.d.ts.map +1 -1
- package/dist/integrations/openai-agents.js +4 -3
- package/dist/integrations/openai-agents.js.map +1 -1
- package/dist/integrations/vercel-ai.d.ts.map +1 -1
- package/dist/integrations/vercel-ai.js +21 -3
- package/dist/integrations/vercel-ai.js.map +1 -1
- package/package.json +11 -7
- package/prompts/onboard.md +9 -13
- package/prompts/scan.md +3 -5
- package/skills/SKILL.md +13 -83
- package/prompts/refresh.md +0 -118
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-log.d.ts","sourceRoot":"","sources":["../../src/core/session-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;
|
|
1
|
+
{"version":3,"file":"session-log.d.ts","sourceRoot":"","sources":["../../src/core/session-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAsFH;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,MAA0B,EACpC,KAAK,GAAE,MAA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_unknown";
|
|
55
|
-
|
|
55
|
+
// Char-loop strip (ReDoS-free): both anchored ``[._]+`` regex forms
|
|
56
|
+
// still get flagged by CodeQL js/polynomial-redos because the engine
|
|
57
|
+
// is conservative about ``+$`` patterns even though they're linear.
|
|
58
|
+
// Equivalent to Python ``str.strip("._")``.
|
|
59
|
+
const replaced = agentId.replace(SAFE_AGENT_ID_RE, "_");
|
|
60
|
+
let start = 0;
|
|
61
|
+
while (start < replaced.length) {
|
|
62
|
+
const c = replaced.charCodeAt(start);
|
|
63
|
+
if (c !== 46 /* . */ && c !== 95 /* _ */)
|
|
64
|
+
break;
|
|
65
|
+
start++;
|
|
66
|
+
}
|
|
67
|
+
let end = replaced.length;
|
|
68
|
+
while (end > start) {
|
|
69
|
+
const c = replaced.charCodeAt(end - 1);
|
|
70
|
+
if (c !== 46 && c !== 95)
|
|
71
|
+
break;
|
|
72
|
+
end--;
|
|
73
|
+
}
|
|
74
|
+
const cleaned = replaced.slice(start, end);
|
|
56
75
|
if (!cleaned || cleaned === "." || cleaned === "..")
|
|
57
76
|
return "_unknown";
|
|
58
77
|
return cleaned.slice(0, 128);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-log.js","sourceRoot":"","sources":["../../src/core/session-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACL,cAAc,EACd,UAAU,EACV,SAAS,EACT,WAAW,EACX,QAAQ,EACR,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;;;;;;;GAWG;AACH,SAAS,UAAU;IACjB,IAAI,CAAC;QACH,MAAM,CAAC,GAAI,UAA8C,CAAC,OAAO,CAAC;QAClE,OAAO,OAAO,CAAC,EAAE,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC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IAAI,IAAY,CAAC;QACjB,IAAI,CAAC;YACH,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAChC,CAAC;QAAC,MAAM,CAAC;YACP,sDAAsD;YACtD,OAAO;QACT,CAAC;QACD,IAAI,CAAC;YACH,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC;QAClD,CAAC;QAAC,MAAM,CAAC;YACP,0CAA0C;QAC5C,CAAC;IACH,CAAC;CACF"}
|
package/dist/core/sto.d.ts
CHANGED
|
@@ -1,45 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Schema surface for the sto (stochastic / LLM-judge) pipeline extension point.
|
|
3
3
|
*
|
|
4
|
-
* The TS SDK is **det-only**, mirroring
|
|
4
|
+
* The TS SDK is **det-only**, mirroring the Python deterministic engine.
|
|
5
5
|
* The managed evaluator catalog (``tone`` / ``relevance`` / ``llm_judge`` /
|
|
6
|
-
* ``hallucination_free``
|
|
7
|
-
* per-evaluator scoring code are
|
|
8
|
-
*
|
|
9
|
-
* package will mirror them later.
|
|
6
|
+
* ``hallucination_free`` ...), an OpenAI-compatible judge client, and the
|
|
7
|
+
* per-evaluator scoring code are not part of this build (the deterministic
|
|
8
|
+
* engine provides no implementation).
|
|
10
9
|
*
|
|
11
|
-
* What this file ships
|
|
10
|
+
* What this file ships:
|
|
12
11
|
*
|
|
13
|
-
* - **Type contracts
|
|
12
|
+
* - **Type contracts**, ``StoEvaluator`` / ``StoResult`` / ``StoInput`` /
|
|
14
13
|
* ``StoContract`` / ``JudgeClient`` / ``JudgeConfig`` /
|
|
15
|
-
* ``StoContextSnapshot``.
|
|
16
|
-
*
|
|
17
|
-
* - ``CloudFeatureError
|
|
18
|
-
*
|
|
19
|
-
*
|
|
14
|
+
* ``StoContextSnapshot``. External callers consuming the schema
|
|
15
|
+
* (session loggers, dashboards) reference these.
|
|
16
|
+
* - ``CloudFeatureError``, the exception any code path raises when an
|
|
17
|
+
* unimplemented sto feature is reached. The class name is kept for
|
|
18
|
+
* ABI stability, the message is neutral.
|
|
19
|
+
* - ``parseScore``, a pure utility that converts a 0-1 score from a
|
|
20
20
|
* judge response. Kept because it never contacts an LLM.
|
|
21
21
|
*
|
|
22
|
-
* What this file does NOT ship
|
|
23
|
-
*
|
|
24
|
-
*
|
|
22
|
+
* What this file does NOT ship (deleted alongside the Python mirrors,
|
|
23
|
+
* ``RetryWithConstraint`` / ``RedirectToSafe`` / ``FeedbackGenerator`` /
|
|
24
|
+
* the per-atom evaluator stubs):
|
|
25
25
|
*
|
|
26
|
-
* - ``createJudge
|
|
26
|
+
* - ``createJudge``, judge construction
|
|
27
27
|
* - ``LlmJudgeEvaluator`` / ``ToneEvaluator`` / ``RelevanceEvaluator``
|
|
28
28
|
* / ``SemanticPiiFreeEvaluator`` / ``HallucinationFreeEvaluator``
|
|
29
29
|
* / ``ScopeRespectEvaluator`` / ``MetricIntegrityEvaluator``
|
|
30
30
|
* / ``InjectionFreeEvaluator``
|
|
31
31
|
*
|
|
32
32
|
* The Sponsio constructor rejects yaml-declared sto contracts and any
|
|
33
|
-
* ``judge:`` option at config-load time, so
|
|
34
|
-
*
|
|
35
|
-
* supply real implementations of the same
|
|
36
|
-
*
|
|
37
|
-
* Operators who want the sto pipeline:
|
|
38
|
-
*
|
|
39
|
-
* pip install sponsio[cloud]
|
|
40
|
-
*
|
|
41
|
-
* or contact your Sponsio account team for managed sto access. See
|
|
42
|
-
* ``docs/oss_scope.md`` for the OSS / Cloud boundary.
|
|
33
|
+
* ``judge:`` option at config-load time, so callers never reach a code
|
|
34
|
+
* path that would have built one of these. This file is an extension
|
|
35
|
+
* point: external builds can supply real implementations of the same
|
|
36
|
+
* Protocol surface.
|
|
43
37
|
*/
|
|
44
38
|
export interface StoInput {
|
|
45
39
|
toolName: string;
|
package/dist/core/sto.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sto.d.ts","sourceRoot":"","sources":["../../src/core/sto.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sto.d.ts","sourceRoot":"","sources":["../../src/core/sto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAIH,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;CAC1C;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,YAAY,CAAC;CACzB;AAUD,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,WAAW,EAAE,MAAM;CAIhC;AAID;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAsB9C"}
|
package/dist/core/sto.js
CHANGED
|
@@ -1,54 +1,48 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Schema surface for the sto (stochastic / LLM-judge) pipeline extension point.
|
|
3
3
|
*
|
|
4
|
-
* The TS SDK is **det-only**, mirroring
|
|
4
|
+
* The TS SDK is **det-only**, mirroring the Python deterministic engine.
|
|
5
5
|
* The managed evaluator catalog (``tone`` / ``relevance`` / ``llm_judge`` /
|
|
6
|
-
* ``hallucination_free``
|
|
7
|
-
* per-evaluator scoring code are
|
|
8
|
-
*
|
|
9
|
-
* package will mirror them later.
|
|
6
|
+
* ``hallucination_free`` ...), an OpenAI-compatible judge client, and the
|
|
7
|
+
* per-evaluator scoring code are not part of this build (the deterministic
|
|
8
|
+
* engine provides no implementation).
|
|
10
9
|
*
|
|
11
|
-
* What this file ships
|
|
10
|
+
* What this file ships:
|
|
12
11
|
*
|
|
13
|
-
* - **Type contracts
|
|
12
|
+
* - **Type contracts**, ``StoEvaluator`` / ``StoResult`` / ``StoInput`` /
|
|
14
13
|
* ``StoContract`` / ``JudgeClient`` / ``JudgeConfig`` /
|
|
15
|
-
* ``StoContextSnapshot``.
|
|
16
|
-
*
|
|
17
|
-
* - ``CloudFeatureError
|
|
18
|
-
*
|
|
19
|
-
*
|
|
14
|
+
* ``StoContextSnapshot``. External callers consuming the schema
|
|
15
|
+
* (session loggers, dashboards) reference these.
|
|
16
|
+
* - ``CloudFeatureError``, the exception any code path raises when an
|
|
17
|
+
* unimplemented sto feature is reached. The class name is kept for
|
|
18
|
+
* ABI stability, the message is neutral.
|
|
19
|
+
* - ``parseScore``, a pure utility that converts a 0-1 score from a
|
|
20
20
|
* judge response. Kept because it never contacts an LLM.
|
|
21
21
|
*
|
|
22
|
-
* What this file does NOT ship
|
|
23
|
-
*
|
|
24
|
-
*
|
|
22
|
+
* What this file does NOT ship (deleted alongside the Python mirrors,
|
|
23
|
+
* ``RetryWithConstraint`` / ``RedirectToSafe`` / ``FeedbackGenerator`` /
|
|
24
|
+
* the per-atom evaluator stubs):
|
|
25
25
|
*
|
|
26
|
-
* - ``createJudge
|
|
26
|
+
* - ``createJudge``, judge construction
|
|
27
27
|
* - ``LlmJudgeEvaluator`` / ``ToneEvaluator`` / ``RelevanceEvaluator``
|
|
28
28
|
* / ``SemanticPiiFreeEvaluator`` / ``HallucinationFreeEvaluator``
|
|
29
29
|
* / ``ScopeRespectEvaluator`` / ``MetricIntegrityEvaluator``
|
|
30
30
|
* / ``InjectionFreeEvaluator``
|
|
31
31
|
*
|
|
32
32
|
* The Sponsio constructor rejects yaml-declared sto contracts and any
|
|
33
|
-
* ``judge:`` option at config-load time, so
|
|
34
|
-
*
|
|
35
|
-
* supply real implementations of the same
|
|
36
|
-
*
|
|
37
|
-
* Operators who want the sto pipeline:
|
|
38
|
-
*
|
|
39
|
-
* pip install sponsio[cloud]
|
|
40
|
-
*
|
|
41
|
-
* or contact your Sponsio account team for managed sto access. See
|
|
42
|
-
* ``docs/oss_scope.md`` for the OSS / Cloud boundary.
|
|
33
|
+
* ``judge:`` option at config-load time, so callers never reach a code
|
|
34
|
+
* path that would have built one of these. This file is an extension
|
|
35
|
+
* point: external builds can supply real implementations of the same
|
|
36
|
+
* Protocol surface.
|
|
43
37
|
*/
|
|
44
38
|
// ----- CloudFeatureError ---------------------------------------------
|
|
45
|
-
const CLOUD_HINT = "Sponsio's sto (LLM-judge) pipeline is
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
39
|
+
const CLOUD_HINT = "Sponsio's sto (LLM-judge) pipeline is not supported in this build " +
|
|
40
|
+
"(the engine is deterministic-only). The schema types remain as an " +
|
|
41
|
+
"extension point so external implementations can supply real " +
|
|
42
|
+
"evaluators behind the same Protocol surface.";
|
|
49
43
|
export class CloudFeatureError extends Error {
|
|
50
44
|
constructor(featureName) {
|
|
51
|
-
super(`[sponsio] ${featureName} is not
|
|
45
|
+
super(`[sponsio] ${featureName} is not supported in this build. ${CLOUD_HINT}`);
|
|
52
46
|
this.name = "CloudFeatureError";
|
|
53
47
|
}
|
|
54
48
|
}
|
|
@@ -70,7 +64,10 @@ export function parseScore(raw) {
|
|
|
70
64
|
/* fall through */
|
|
71
65
|
}
|
|
72
66
|
}
|
|
73
|
-
|
|
67
|
+
// Anchored + non-overlapping alternatives: prevents the polynomial
|
|
68
|
+
// backtracking CodeQL flags when ``[01](?:\.\d+)?`` and ``0?\.\d+``
|
|
69
|
+
// could both match prefixes like ``0`` or ``0.5``.
|
|
70
|
+
const m = trimmed.match(/^([01](?:\.\d+)?|\.\d+)/);
|
|
74
71
|
if (!m) {
|
|
75
72
|
throw new Error(`unparseable score: ${JSON.stringify(trimmed.slice(0, 80))}`);
|
|
76
73
|
}
|
package/dist/core/sto.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sto.js","sourceRoot":"","sources":["../../src/core/sto.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sto.js","sourceRoot":"","sources":["../../src/core/sto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAgDH,wEAAwE;AAExE,MAAM,UAAU,GACd,oEAAoE;IACpE,oEAAoE;IACpE,8DAA8D;IAC9D,8CAA8C,CAAC;AAEjD,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,WAAmB;QAC7B,KAAK,CAAC,aAAa,WAAW,oCAAoC,UAAU,EAAE,CAAC,CAAC;QAChF,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,w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*/
|
|
99
99
|
detViolations: DetViolation[];
|
|
100
100
|
/**
|
|
101
|
-
* Sto-pipeline violations
|
|
102
|
-
* the
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* ``
|
|
106
|
-
*
|
|
101
|
+
* Sto-pipeline violations. Not part of this build (the engine is
|
|
102
|
+
* deterministic-only). Always ``[]`` on the TS SDK (the ctor
|
|
103
|
+
* rejects yaml sto contracts at load time and never builds a
|
|
104
|
+
* judge). External subclasses can populate this with results from
|
|
105
|
+
* stochastic contracts (``tone`` / ``llm_judge`` / ``injection_free``
|
|
106
|
+
* / ...). Kept on the schema so dashboards / session loggers branch
|
|
107
|
+
* consistently across both surfaces.
|
|
107
108
|
*/
|
|
108
109
|
stoViolations: DetViolation[];
|
|
109
110
|
}
|
|
@@ -130,7 +131,11 @@ export interface SponsoOptions {
|
|
|
130
131
|
/**
|
|
131
132
|
* Runtime mode. Precedence (matches the Python SDK):
|
|
132
133
|
*
|
|
133
|
-
* SPONSIO_MODE env > ctor arg > yaml runtime.mode
|
|
134
|
+
* SPONSIO_MODE env > ctor arg > yaml runtime.mode
|
|
135
|
+
* > yaml defaults.mode > yaml top-level mode: > "observe"
|
|
136
|
+
*
|
|
137
|
+
* A contract may also carry its own `mode:` in yaml, which overrides
|
|
138
|
+
* whatever the global resolution lands on — for that contract alone.
|
|
134
139
|
*
|
|
135
140
|
* ``observe`` (the default) logs every would-have-blocked decision
|
|
136
141
|
* to ``~/.sponsio/sessions/<agent_id>/*.jsonl`` without actually
|
|
@@ -148,13 +153,13 @@ export interface SponsoOptions {
|
|
|
148
153
|
/** Override session log base dir (tests / alternative layouts). */
|
|
149
154
|
sessionLogBaseDir?: string;
|
|
150
155
|
/**
|
|
151
|
-
* Judge config for the sto pipeline. **
|
|
152
|
-
* Either a plain config object
|
|
153
|
-
* baseUrl / fallbackMode) or a pre-built
|
|
154
|
-
* TS SDK accepts the option for shared-yaml
|
|
155
|
-
* never constructs a judge
|
|
156
|
-
*
|
|
157
|
-
*
|
|
156
|
+
* Judge config for the sto pipeline. **Not supported in this build**
|
|
157
|
+
* (the engine is deterministic-only). Either a plain config object
|
|
158
|
+
* (provider / model / apiKey / baseUrl / fallbackMode) or a pre-built
|
|
159
|
+
* ``JudgeClient``. The TS SDK accepts the option for shared-yaml
|
|
160
|
+
* compatibility but never constructs a judge: passing this surfaces
|
|
161
|
+
* a warning via the skipped-items path and the field is otherwise
|
|
162
|
+
* ignored.
|
|
158
163
|
*/
|
|
159
164
|
judge?: JudgeConfig | JudgeClient;
|
|
160
165
|
}
|
|
@@ -255,18 +260,18 @@ export declare class Sponsio {
|
|
|
255
260
|
/**
|
|
256
261
|
* Record tool output after execution.
|
|
257
262
|
*
|
|
258
|
-
*
|
|
259
|
-
* (LLM-judged) atoms are
|
|
260
|
-
*
|
|
261
|
-
* are rejected at config
|
|
262
|
-
* ``[]`` and ``allowed: true``.
|
|
263
|
+
* This build ships **no sto pipeline** (the engine is deterministic-only).
|
|
264
|
+
* Stochastic (LLM-judged) atoms are the extension point that would
|
|
265
|
+
* populate ``stoViolations``; with no external implementation and no
|
|
266
|
+
* sto contracts loaded (sto entries in yaml are rejected at config
|
|
267
|
+
* load), ``stoViolations`` is always ``[]`` and ``allowed: true``.
|
|
263
268
|
*
|
|
264
|
-
* The method stays ``async`` for API parity
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
269
|
+
* The method stays ``async`` for API parity: an external subclass
|
|
270
|
+
* or wrapper can run the judge pipeline and surface real
|
|
271
|
+
* ``stoViolations`` without changing the call site. In **enforce
|
|
272
|
+
* mode** such subclasses can flip ``blocked: true`` on the first
|
|
273
|
+
* sto violation; the tool output has already executed, so the
|
|
274
|
+
* caller is responsible for routing the result (retry with
|
|
270
275
|
* feedback, redirect to safe, etc.).
|
|
271
276
|
*/
|
|
272
277
|
guardAfter(_toolName: string, _output?: string): Promise<CheckResult>;
|
|
@@ -279,13 +284,13 @@ export declare class Sponsio {
|
|
|
279
284
|
/**
|
|
280
285
|
* Stash per-turn context for the sto pipeline.
|
|
281
286
|
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
* consumed.
|
|
287
|
+
* Not supported in this build (the engine is deterministic-only).
|
|
288
|
+
* Atoms that need grounding (``relevance`` -> ``query``,
|
|
289
|
+
* ``hallucination_free`` -> ``source``, ``scope_respect`` ->
|
|
290
|
+
* ``scope`` override, ``metric_integrity`` -> ``history``) would
|
|
291
|
+
* read from this snapshot on the next ``guardAfter`` call. This
|
|
292
|
+
* build accepts the call as a no-op so shared agent code can stay
|
|
293
|
+
* framework-neutral; the snapshot is never consumed.
|
|
289
294
|
*
|
|
290
295
|
* Merges with any previously-set context; pass ``{ query: undefined }``
|
|
291
296
|
* to explicitly clear a field. ``reset()`` clears the whole snapshot.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAkBH,OAAO,EACL,aAAa,EAKd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EAEX,kBAAkB,EAEnB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,WAAW,EACX,iBAAiB,EACj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,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,IAAI;IAUR;;;;;;;;;OASG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,WAAW;IAqE9E,OAAO,CAAC,cAAc;IAoBtB,OAAO,CAAC,SAAS;IAYjB;;;;;;;;;;;;;;;;OAgBG;IACG,UAAU,CACd,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,MAAW,GACnB,OAAO,CAAC,WAAW,CAAC;IAOvB;;;;OAIG;IACH,KAAK,IAAI,IAAI;IAUb;;;;;;;;;;;;;OAaG;IACH,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,IAAI;IAIlD;;OAEG;IACH,IAAI,UAAU,IAAI,MAAM,EAAE,CAEzB;IAED;;;OAGG;IACH,OAAO,IAAI,MAAM;IAKjB;;;;;;OAMG;IACH,YAAY,IAAI,IAAI;CAGrB"}
|
package/dist/index.js
CHANGED
|
@@ -58,9 +58,9 @@ export class Sponsio {
|
|
|
58
58
|
agentId;
|
|
59
59
|
mode;
|
|
60
60
|
_contracts;
|
|
61
|
-
// Sto state. Always empty/null in
|
|
62
|
-
// sto contracts and inline `judge:` at config load.
|
|
63
|
-
// schema-stable surface for
|
|
61
|
+
// Sto state. Always empty/null in this build, the constructor
|
|
62
|
+
// rejects yaml sto contracts and inline `judge:` at config load.
|
|
63
|
+
// Kept as schema-stable surface for external composition / wrapping.
|
|
64
64
|
_stoContracts;
|
|
65
65
|
_stoContext;
|
|
66
66
|
_trace;
|
|
@@ -111,29 +111,30 @@ export class Sponsio {
|
|
|
111
111
|
this._contracts.push(c);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
// ── Sto pipeline is
|
|
114
|
+
// ── Sto pipeline is not part of this build ──────────────────────
|
|
115
115
|
// The managed LLM-judge catalog (`tone` / `relevance` / `llm_judge`
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
// and any
|
|
119
|
-
// never
|
|
120
|
-
// `setContext`, `judge` ctor
|
|
121
|
-
//
|
|
116
|
+
// ...) and the judge client are not part of this build (the
|
|
117
|
+
// deterministic engine provides no implementation). The engine
|
|
118
|
+
// logs-and-skips any yaml sto contracts and any inline `judge:`
|
|
119
|
+
// option, never constructs an evaluator, never contacts an LLM.
|
|
120
|
+
// The API surface (`guardAfter`, `setContext`, `judge` ctor
|
|
121
|
+
// option) is preserved so a shared yaml between deterministic
|
|
122
|
+
// builds and external sto implementations doesn't refuse to load.
|
|
122
123
|
for (const spec of yamlStoSpecs) {
|
|
123
124
|
yamlSkipped.push({
|
|
124
125
|
kind: "sto-contract",
|
|
125
|
-
detail: `${spec.desc} (sto pipeline is
|
|
126
|
+
detail: `${spec.desc} (sto pipeline is not supported in this build)`,
|
|
126
127
|
});
|
|
127
128
|
}
|
|
128
129
|
if (options.judge) {
|
|
129
130
|
yamlSkipped.push({
|
|
130
131
|
kind: "sto-contract",
|
|
131
|
-
detail: "`judge:` option ignored (sto pipeline is
|
|
132
|
+
detail: "`judge:` option ignored (sto pipeline is not supported in this build)",
|
|
132
133
|
});
|
|
133
134
|
}
|
|
134
|
-
// Reference yamlJudge so unused-var lints don't fire
|
|
135
|
-
// is parsed by the loader for shared-yaml compatibility but
|
|
136
|
-
//
|
|
135
|
+
// Reference yamlJudge so unused-var lints don't fire: the field
|
|
136
|
+
// is parsed by the loader for shared-yaml compatibility but this
|
|
137
|
+
// build never constructs a judge from it.
|
|
137
138
|
void yamlJudge;
|
|
138
139
|
// ── Warn once about yaml features the TS runtime can't handle ───
|
|
139
140
|
warnOnceAboutSkipped(yamlSkipped);
|
|
@@ -173,6 +174,7 @@ export class Sponsio {
|
|
|
173
174
|
const violations = [];
|
|
174
175
|
const violatedDescs = [];
|
|
175
176
|
const detViolations = [];
|
|
177
|
+
let anyBlocking = false;
|
|
176
178
|
for (const contract of this._contracts) {
|
|
177
179
|
const checkSpan = new ContractCheckSpan(contract.desc, "hard");
|
|
178
180
|
collector.push(checkSpan);
|
|
@@ -198,7 +200,12 @@ export class Sponsio {
|
|
|
198
200
|
const guaranteeSpan = new GuaranteeSpan(contract.desc, result);
|
|
199
201
|
collector.add(guaranteeSpan, result ? "ok" : "violated");
|
|
200
202
|
if (!result) {
|
|
201
|
-
|
|
203
|
+
// Per-contract `mode:` overrides the global mode for this one
|
|
204
|
+
// verdict — same routing as Python's RuntimeMonitor.
|
|
205
|
+
const effMode = contract.mode ?? this.mode;
|
|
206
|
+
if (effMode === "enforce")
|
|
207
|
+
anyBlocking = true;
|
|
208
|
+
const verb = effMode === "observe" ? "WOULD-BLOCK" : "BLOCKED";
|
|
202
209
|
const msg = `${verb}: ${this.agentId}.${toolName} — det constraint violated: ${contract.desc}`;
|
|
203
210
|
violations.push(msg);
|
|
204
211
|
violatedDescs.push(contract.desc);
|
|
@@ -212,14 +219,14 @@ export class Sponsio {
|
|
|
212
219
|
});
|
|
213
220
|
// Nest violation + enforcement spans under the failed
|
|
214
221
|
// guarantee so the renderer can pick up the verdict word.
|
|
215
|
-
const enforce = new EnforcementSpan("DetBlock",
|
|
222
|
+
const enforce = new EnforcementSpan("DetBlock", effMode === "enforce" ? "blocked" : "observed");
|
|
216
223
|
guaranteeSpan.children.push(enforce);
|
|
217
224
|
enforce.finish("violated");
|
|
218
225
|
}
|
|
219
226
|
collector.pop(result ? "ok" : "violated");
|
|
220
227
|
}
|
|
221
228
|
const hasViolations = violations.length > 0;
|
|
222
|
-
const blocked =
|
|
229
|
+
const blocked = anyBlocking;
|
|
223
230
|
this._turnSpans.push(collector.finishRoot(blocked, this._contracts.length, violations.length));
|
|
224
231
|
if (blocked) {
|
|
225
232
|
this._trace.pop();
|
|
@@ -361,10 +368,14 @@ export class Sponsio {
|
|
|
361
368
|
const violations = [];
|
|
362
369
|
const violatedDescs = [];
|
|
363
370
|
const detViolations = [];
|
|
371
|
+
let anyBlocking = false;
|
|
364
372
|
for (const contract of this._contracts) {
|
|
365
373
|
const result = evaluate(contract.formula, this._trace);
|
|
366
374
|
if (!result) {
|
|
367
|
-
const
|
|
375
|
+
const effMode = contract.mode ?? this.mode;
|
|
376
|
+
if (effMode === "enforce")
|
|
377
|
+
anyBlocking = true;
|
|
378
|
+
const verb = effMode === "observe" ? "WOULD-BLOCK" : "BLOCKED";
|
|
368
379
|
const msg = `${verb}: ${this.agentId}.<llm_response> — det constraint violated: ${contract.desc}`;
|
|
369
380
|
violations.push(msg);
|
|
370
381
|
violatedDescs.push(contract.desc);
|
|
@@ -378,7 +389,7 @@ export class Sponsio {
|
|
|
378
389
|
}
|
|
379
390
|
}
|
|
380
391
|
const hasViolations = violations.length > 0;
|
|
381
|
-
const blocked =
|
|
392
|
+
const blocked = anyBlocking;
|
|
382
393
|
if (blocked) {
|
|
383
394
|
this._trace.pop();
|
|
384
395
|
this._state = snapshot;
|
|
@@ -436,23 +447,24 @@ export class Sponsio {
|
|
|
436
447
|
/**
|
|
437
448
|
* Record tool output after execution.
|
|
438
449
|
*
|
|
439
|
-
*
|
|
440
|
-
* (LLM-judged) atoms are
|
|
441
|
-
*
|
|
442
|
-
* are rejected at config
|
|
443
|
-
* ``[]`` and ``allowed: true``.
|
|
450
|
+
* This build ships **no sto pipeline** (the engine is deterministic-only).
|
|
451
|
+
* Stochastic (LLM-judged) atoms are the extension point that would
|
|
452
|
+
* populate ``stoViolations``; with no external implementation and no
|
|
453
|
+
* sto contracts loaded (sto entries in yaml are rejected at config
|
|
454
|
+
* load), ``stoViolations`` is always ``[]`` and ``allowed: true``.
|
|
444
455
|
*
|
|
445
|
-
* The method stays ``async`` for API parity
|
|
446
|
-
*
|
|
447
|
-
*
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
*
|
|
456
|
+
* The method stays ``async`` for API parity: an external subclass
|
|
457
|
+
* or wrapper can run the judge pipeline and surface real
|
|
458
|
+
* ``stoViolations`` without changing the call site. In **enforce
|
|
459
|
+
* mode** such subclasses can flip ``blocked: true`` on the first
|
|
460
|
+
* sto violation; the tool output has already executed, so the
|
|
461
|
+
* caller is responsible for routing the result (retry with
|
|
451
462
|
* feedback, redirect to safe, etc.).
|
|
452
463
|
*/
|
|
453
464
|
async guardAfter(_toolName, _output = "") {
|
|
454
|
-
//
|
|
455
|
-
// return clean-pass;
|
|
465
|
+
// This build is deterministic-only, the sto pipeline is not
|
|
466
|
+
// implemented. Always return clean-pass; external subclasses can
|
|
467
|
+
// override.
|
|
456
468
|
return emptyAllow();
|
|
457
469
|
}
|
|
458
470
|
/**
|
|
@@ -470,13 +482,13 @@ export class Sponsio {
|
|
|
470
482
|
/**
|
|
471
483
|
* Stash per-turn context for the sto pipeline.
|
|
472
484
|
*
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
*
|
|
479
|
-
* consumed.
|
|
485
|
+
* Not supported in this build (the engine is deterministic-only).
|
|
486
|
+
* Atoms that need grounding (``relevance`` -> ``query``,
|
|
487
|
+
* ``hallucination_free`` -> ``source``, ``scope_respect`` ->
|
|
488
|
+
* ``scope`` override, ``metric_integrity`` -> ``history``) would
|
|
489
|
+
* read from this snapshot on the next ``guardAfter`` call. This
|
|
490
|
+
* build accepts the call as a no-op so shared agent code can stay
|
|
491
|
+
* framework-neutral; the snapshot is never consumed.
|
|
480
492
|
*
|
|
481
493
|
* Merges with any previously-set context; pass ``{ query: undefined }``
|
|
482
494
|
* to explicitly clear a field. ``reset()`` clears the whole snapshot.
|
|
@@ -534,9 +546,10 @@ function resolveMode(ctorMode, yamlMode) {
|
|
|
534
546
|
}
|
|
535
547
|
let _skippedWarned = false;
|
|
536
548
|
// Note: ``resolveJudge`` / ``buildStoContract`` / ``isJudgeClient``
|
|
537
|
-
// helpers were removed when the sto pipeline became
|
|
538
|
-
//
|
|
539
|
-
// specs flow through the ``yamlSkipped`` warning path in
|
|
549
|
+
// helpers were removed when the sto pipeline became an external
|
|
550
|
+
// extension point. This build never constructs a judge or evaluator;
|
|
551
|
+
// yaml sto specs flow through the ``yamlSkipped`` warning path in
|
|
552
|
+
// the ctor.
|
|
540
553
|
function emptyAllow() {
|
|
541
554
|
return {
|
|
542
555
|
blocked: false,
|
|
@@ -569,7 +582,7 @@ function warnOnceAboutSkipped(skipped) {
|
|
|
569
582
|
bits.push(`${unknown} unrecognised contract entr${unknown === 1 ? "y" : "ies"}`);
|
|
570
583
|
}
|
|
571
584
|
const stoNote = sto > 0
|
|
572
|
-
? " Sto (LLM-judge) contracts are
|
|
585
|
+
? " Sto (LLM-judge) contracts are not supported in this build (the engine is deterministic-only)."
|
|
573
586
|
: "";
|
|
574
587
|
console.warn("[sponsio] skipped unsupported yaml items: " +
|
|
575
588
|
bits.join("; ") +
|