@sponsio/sdk 0.1.0 → 0.2.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/contracts/benchmark/agentdojo.yaml +551 -0
  2. package/contracts/benchmark/odcv_bench.yaml +393 -0
  3. package/contracts/benchmark/redcode_exec.yaml +488 -0
  4. package/contracts/benchmark/swebench.yaml +176 -0
  5. package/contracts/benchmark/tau2_bench.yaml +984 -0
  6. package/contracts/capability/destructive.yaml +213 -0
  7. package/contracts/capability/factual-claims.yaml +79 -0
  8. package/contracts/capability/host-config-integrity.yaml +42 -9
  9. package/contracts/capability/self-modify.yaml +58 -12
  10. package/contracts/capability/shell.yaml +19 -10
  11. package/contracts/incident/claude-code-secret-bypass.yaml +48 -16
  12. package/contracts/incident/cursor-railway-wipe.yaml +60 -4
  13. package/contracts/incident/openclaw.yaml +9 -62
  14. package/contracts/premium/.gitkeep +5 -6
  15. package/dist/cli/cli.js +32 -0
  16. package/dist/cli/cli.js.map +1 -1
  17. package/dist/cli/packs.d.ts.map +1 -1
  18. package/dist/cli/packs.js +14 -8
  19. package/dist/cli/packs.js.map +1 -1
  20. package/dist/cli/patterns.d.ts +5 -4
  21. package/dist/cli/patterns.d.ts.map +1 -1
  22. package/dist/cli/patterns.js +11 -10
  23. package/dist/cli/patterns.js.map +1 -1
  24. package/dist/cli/prompt.js +5 -5
  25. package/dist/cli/prompt.js.map +1 -1
  26. package/dist/cli/scan.js +2 -2
  27. package/dist/cli/skill.d.ts +1 -1
  28. package/dist/cli/skill.js +1 -1
  29. package/dist/cli/validate.js +5 -5
  30. package/dist/cli/validate.js.map +1 -1
  31. package/dist/cloud/client.d.ts +76 -0
  32. package/dist/cloud/client.d.ts.map +1 -0
  33. package/dist/cloud/client.js +204 -0
  34. package/dist/cloud/client.js.map +1 -0
  35. package/dist/cloud/evidence.d.ts +108 -0
  36. package/dist/cloud/evidence.d.ts.map +1 -0
  37. package/dist/cloud/evidence.js +184 -0
  38. package/dist/cloud/evidence.js.map +1 -0
  39. package/dist/cloud/privacy.d.ts +67 -0
  40. package/dist/cloud/privacy.d.ts.map +1 -0
  41. package/dist/cloud/privacy.js +170 -0
  42. package/dist/cloud/privacy.js.map +1 -0
  43. package/dist/cloud/view-model.d.ts +49 -0
  44. package/dist/cloud/view-model.d.ts.map +1 -0
  45. package/dist/cloud/view-model.js +172 -0
  46. package/dist/cloud/view-model.js.map +1 -0
  47. package/dist/core/config-loader.d.ts.map +1 -1
  48. package/dist/core/config-loader.js +81 -9
  49. package/dist/core/config-loader.js.map +1 -1
  50. package/dist/core/evaluator.d.ts +11 -1
  51. package/dist/core/evaluator.d.ts.map +1 -1
  52. package/dist/core/evaluator.js +275 -13
  53. package/dist/core/evaluator.js.map +1 -1
  54. package/dist/core/formula.d.ts +76 -17
  55. package/dist/core/formula.d.ts.map +1 -1
  56. package/dist/core/formula.js +95 -1
  57. package/dist/core/formula.js.map +1 -1
  58. package/dist/core/grounding.d.ts +44 -8
  59. package/dist/core/grounding.d.ts.map +1 -1
  60. package/dist/core/grounding.js +208 -26
  61. package/dist/core/grounding.js.map +1 -1
  62. package/dist/core/nl-parser.d.ts +2 -2
  63. package/dist/core/nl-parser.d.ts.map +1 -1
  64. package/dist/core/nl-parser.js +617 -41
  65. package/dist/core/nl-parser.js.map +1 -1
  66. package/dist/core/pack-loader.d.ts.map +1 -1
  67. package/dist/core/pack-loader.js +14 -2
  68. package/dist/core/pack-loader.js.map +1 -1
  69. package/dist/core/parser.d.ts.map +1 -1
  70. package/dist/core/parser.js +30 -1
  71. package/dist/core/parser.js.map +1 -1
  72. package/dist/core/pattern-factory.d.ts.map +1 -1
  73. package/dist/core/pattern-factory.js +14 -1
  74. package/dist/core/pattern-factory.js.map +1 -1
  75. package/dist/core/patterns.d.ts +118 -1
  76. package/dist/core/patterns.d.ts.map +1 -1
  77. package/dist/core/patterns.js +189 -10
  78. package/dist/core/patterns.js.map +1 -1
  79. package/dist/core/session-log.d.ts.map +1 -1
  80. package/dist/core/session-log.js +20 -1
  81. package/dist/core/session-log.js.map +1 -1
  82. package/dist/core/sto.d.ts +21 -27
  83. package/dist/core/sto.d.ts.map +1 -1
  84. package/dist/core/sto.js +30 -33
  85. package/dist/core/sto.js.map +1 -1
  86. package/dist/core/tool-names.d.ts +59 -0
  87. package/dist/core/tool-names.d.ts.map +1 -0
  88. package/dist/core/tool-names.js +128 -0
  89. package/dist/core/tool-names.js.map +1 -0
  90. package/dist/index.d.ts +181 -32
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +415 -67
  93. package/dist/index.js.map +1 -1
  94. package/dist/integrations/claude-agent.d.ts +5 -0
  95. package/dist/integrations/claude-agent.d.ts.map +1 -1
  96. package/dist/integrations/claude-agent.js +42 -13
  97. package/dist/integrations/claude-agent.js.map +1 -1
  98. package/dist/integrations/google-adk.d.ts +5 -3
  99. package/dist/integrations/google-adk.d.ts.map +1 -1
  100. package/dist/integrations/google-adk.js +9 -5
  101. package/dist/integrations/google-adk.js.map +1 -1
  102. package/dist/integrations/langchain.d.ts +7 -0
  103. package/dist/integrations/langchain.d.ts.map +1 -1
  104. package/dist/integrations/langchain.js +21 -3
  105. package/dist/integrations/langchain.js.map +1 -1
  106. package/dist/integrations/openai-agents.d.ts +22 -10
  107. package/dist/integrations/openai-agents.d.ts.map +1 -1
  108. package/dist/integrations/openai-agents.js +55 -15
  109. package/dist/integrations/openai-agents.js.map +1 -1
  110. package/dist/integrations/openai.d.ts +11 -0
  111. package/dist/integrations/openai.d.ts.map +1 -1
  112. package/dist/integrations/openai.js +130 -48
  113. package/dist/integrations/openai.js.map +1 -1
  114. package/dist/integrations/vercel-ai.d.ts +20 -9
  115. package/dist/integrations/vercel-ai.d.ts.map +1 -1
  116. package/dist/integrations/vercel-ai.js +131 -32
  117. package/dist/integrations/vercel-ai.js.map +1 -1
  118. package/package.json +17 -9
  119. package/prompts/onboard.md +26 -17
  120. package/prompts/scan.md +3 -5
  121. package/skills/SKILL.md +13 -83
  122. package/contracts/core/llm_safety.yaml +0 -140
  123. package/prompts/refresh.md +0 -118
@@ -52,7 +52,26 @@ const SAFE_AGENT_ID_RE = /[^A-Za-z0-9._:\-]/g;
52
52
  function sanitizeAgentId(agentId) {
53
53
  if (!agentId)
54
54
  return "_unknown";
55
- const cleaned = agentId.replace(SAFE_AGENT_ID_RE, "_").replace(/^[._]+|[._]+$/g, "");
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,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AAI,EAAE,OAAO,CAAC,CAAC;QAClD,CAAC;QAAC,MAAM,CAAC;YACP,0CAA0C;QAC5C,CAAC;IACH,CAAC;CACF"}
@@ -1,45 +1,39 @@
1
1
  /**
2
- * OSS↔Cloud schema surface for the sto (stochastic / LLM-judge) pipeline.
2
+ * Schema surface for the sto (stochastic / LLM-judge) pipeline extension point.
3
3
  *
4
- * The TS SDK is **det-only**, mirroring Sponsio Python's OSS engine.
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`` …), the OpenAI-compatible judge client, and the
7
- * per-evaluator scoring code are Sponsio Cloud features. They live in
8
- * the proprietary ``sponsio_cloud.sto.*`` Python package; a Cloud-TS
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 in OSS:
10
+ * What this file ships:
12
11
  *
13
- * - **Type contracts** — ``StoEvaluator`` / ``StoResult`` / ``StoInput`` /
12
+ * - **Type contracts**, ``StoEvaluator`` / ``StoResult`` / ``StoInput`` /
14
13
  * ``StoContract`` / ``JudgeClient`` / ``JudgeConfig`` /
15
- * ``StoContextSnapshot``. Cloud subclasses / OSS callers consuming the
16
- * schema (session loggers, dashboards) reference these.
17
- * - ``CloudFeatureError`` — the exception any Cloud-only code path
18
- * raises when reached on the OSS engine.
19
- * - ``parseScore`` — a pure utility that converts a 0-1 score from a
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 in OSS (deleted alongside the Python
23
- * mirrors — ``RetryWithConstraint`` / ``RedirectToSafe`` /
24
- * ``FeedbackGenerator`` / the per-atom evaluator stubs):
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`` — judge construction
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 OSS callers never reach a
34
- * code path that would have built one of these. Cloud installs will
35
- * supply real implementations of the same Protocol surface.
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;
@@ -1 +1 @@
1
- {"version":3,"file":"sto.d.ts","sourceRoot":"","sources":["../../src/core/sto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;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;I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↔Cloud schema surface for the sto (stochastic / LLM-judge) pipeline.
2
+ * Schema surface for the sto (stochastic / LLM-judge) pipeline extension point.
3
3
  *
4
- * The TS SDK is **det-only**, mirroring Sponsio Python's OSS engine.
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`` …), the OpenAI-compatible judge client, and the
7
- * per-evaluator scoring code are Sponsio Cloud features. They live in
8
- * the proprietary ``sponsio_cloud.sto.*`` Python package; a Cloud-TS
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 in OSS:
10
+ * What this file ships:
12
11
  *
13
- * - **Type contracts** — ``StoEvaluator`` / ``StoResult`` / ``StoInput`` /
12
+ * - **Type contracts**, ``StoEvaluator`` / ``StoResult`` / ``StoInput`` /
14
13
  * ``StoContract`` / ``JudgeClient`` / ``JudgeConfig`` /
15
- * ``StoContextSnapshot``. Cloud subclasses / OSS callers consuming the
16
- * schema (session loggers, dashboards) reference these.
17
- * - ``CloudFeatureError`` — the exception any Cloud-only code path
18
- * raises when reached on the OSS engine.
19
- * - ``parseScore`` — a pure utility that converts a 0-1 score from a
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 in OSS (deleted alongside the Python
23
- * mirrors — ``RetryWithConstraint`` / ``RedirectToSafe`` /
24
- * ``FeedbackGenerator`` / the per-atom evaluator stubs):
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`` — judge construction
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 OSS callers never reach a
34
- * code path that would have built one of these. Cloud installs will
35
- * supply real implementations of the same Protocol surface.
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 a Cloud feature, not bundled " +
46
- "with the OSS engine. Install `sponsio[cloud]` (Python) or contact " +
47
- "your Sponsio account team for managed sto access. See " +
48
- "https://github.com/SponsioLabs/Sponsio/blob/main/docs/oss_scope.md.";
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 available in OSS. ${CLOUD_HINT}`);
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
- const m = trimmed.match(/([01](?:\.\d+)?|0?\.\d+)/);
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
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sto.js","sourceRoot":"","sources":["../../src/core/sto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAgDH,wEAAwE;AAExE,MAAM,UAAU,GACd,qEAAqE;IACrE,oEAAoE;IACpE,wDAAwD;IACxD,qEAAqE,CAAC;AAExE,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,WAAmB;QAC7B,KAAK,CAAC,aAAa,WAAW,6BAA6B,UAAU,EAAE,CAAC,CAAC;QACzE,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,wEAAwE;AAExE;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC3B,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAwB,CAAC;YACvD,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ;gBAAE,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC/D,CAAC;QAAC,MAAM,CAAC;YACP,kBAAkB;QACpB,CAAC;IACH,CAAC;IACD,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK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QAC5B,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAwB,CAAC;YACvD,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ;gBAAE,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC/D,CAAC;QAAC,MAAM,CAAC;YACP,kBAAkB;QACpB,CAAC;IACH,CAAC;IACD,mEAAmE;IACnE,oEAAoE;IACpE,mDAAmD;IACnD,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,IAAI,CAAC,CAAC,EAAE,CAAC;QACP,MAAM,IAAI,KAAK,CACb,sBAAsB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAC7D,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACtE,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AAED,SAAS,OAAO,CAAC,CAAS;IACxB,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IACpB,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IACpB,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * One canonical spelling for a tool name, shared by contracts and grounding.
3
+ *
4
+ * Port of sponsio/formulas/tool_names.py.
5
+ *
6
+ * Predicate keys are map keys: ``called(issue_refund)`` and
7
+ * ``called(Issue_Refund)`` are different entries, and a contract looks up
8
+ * the spelling its author typed. So a rule written against ``issue_refund``
9
+ * was silently inert against an event whose tool arrived as
10
+ * ``Issue_Refund``, as ``"issue_refund "`` with a stray space, or as
11
+ * ``mcp__finance__issue_refund`` (our own documented MCP wire format).
12
+ * ``mustPrecede`` compiles to ``Or(order-holds, never-called)``, so a name
13
+ * that never matches makes the second disjunct true and the contract
14
+ * reports satisfied while the guarded action runs unchecked.
15
+ *
16
+ * Two functions, used on opposite sides of the same join:
17
+ *
18
+ * - {@link canonicalTool}: what a *contract* keys on. Contracts are
19
+ * authored once, so they collapse to a single canonical spelling.
20
+ * - {@link toolAliases}: what an *event* answers to. A tool call is a fact
21
+ * and cannot be rewritten, so it is grounded under every spelling a
22
+ * contract might reasonably have used, canonical form included.
23
+ *
24
+ * Widening only ever makes more contracts apply to a given call, never
25
+ * fewer.
26
+ */
27
+ /**
28
+ * Claude Code / MCP wire format: ``mcp__<server>__<tool>``, prefix in any
29
+ * case (``MCP__finance__x`` is the same call). The server segment has no
30
+ * ``__`` of its own; the tool segment may, so the split is on the FIRST
31
+ * ``__`` after the prefix. ``[^\n]`` rather than ``.`` because
32
+ * Python's ``.`` excludes only ``\n`` while JavaScript's also excludes
33
+ * ``\r`` and U+2028/2029.
34
+ */
35
+ export declare const MCP_TOOL_RE: RegExp;
36
+ /**
37
+ * OpenClaw's MCP wire format: ``<server>__<tool>`` with no ``mcp__``
38
+ * prefix. Same split; consulted only when {@link MCP_TOOL_RE} did not
39
+ * match, so the ``mcp`` of a prefixed name is never read as a server.
40
+ */
41
+ export declare const SERVER_TOOL_RE: RegExp;
42
+ /**
43
+ * The single spelling a contract keys on.
44
+ *
45
+ * Strips surrounding whitespace and case-folds. The MCP prefix is *not*
46
+ * stripped here: a contract that deliberately names
47
+ * ``mcp__finance__issue_refund`` means that server's tool and should not
48
+ * widen to every tool of that name. Grounding supplies the bare-name
49
+ * alias so the reverse direction still joins.
50
+ */
51
+ export declare function canonicalTool(tool: string): string;
52
+ /**
53
+ * Every spelling an event's tool call should answer to.
54
+ *
55
+ * Ordered, duplicate-free, and always contains the raw name first so
56
+ * existing traces and predicate keys keep working unchanged.
57
+ */
58
+ export declare function toolAliases(tool: string): string[];
59
+ //# sourceMappingURL=tool-names.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-names.d.ts","sourceRoot":"","sources":["../../src/core/tool-names.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,QAAyC,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAmC,CAAC;AA4D/D;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAQlD"}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * One canonical spelling for a tool name, shared by contracts and grounding.
3
+ *
4
+ * Port of sponsio/formulas/tool_names.py.
5
+ *
6
+ * Predicate keys are map keys: ``called(issue_refund)`` and
7
+ * ``called(Issue_Refund)`` are different entries, and a contract looks up
8
+ * the spelling its author typed. So a rule written against ``issue_refund``
9
+ * was silently inert against an event whose tool arrived as
10
+ * ``Issue_Refund``, as ``"issue_refund "`` with a stray space, or as
11
+ * ``mcp__finance__issue_refund`` (our own documented MCP wire format).
12
+ * ``mustPrecede`` compiles to ``Or(order-holds, never-called)``, so a name
13
+ * that never matches makes the second disjunct true and the contract
14
+ * reports satisfied while the guarded action runs unchecked.
15
+ *
16
+ * Two functions, used on opposite sides of the same join:
17
+ *
18
+ * - {@link canonicalTool}: what a *contract* keys on. Contracts are
19
+ * authored once, so they collapse to a single canonical spelling.
20
+ * - {@link toolAliases}: what an *event* answers to. A tool call is a fact
21
+ * and cannot be rewritten, so it is grounded under every spelling a
22
+ * contract might reasonably have used, canonical form included.
23
+ *
24
+ * Widening only ever makes more contracts apply to a given call, never
25
+ * fewer.
26
+ */
27
+ /**
28
+ * Claude Code / MCP wire format: ``mcp__<server>__<tool>``, prefix in any
29
+ * case (``MCP__finance__x`` is the same call). The server segment has no
30
+ * ``__`` of its own; the tool segment may, so the split is on the FIRST
31
+ * ``__`` after the prefix. ``[^\n]`` rather than ``.`` because
32
+ * Python's ``.`` excludes only ``\n`` while JavaScript's also excludes
33
+ * ``\r`` and U+2028/2029.
34
+ */
35
+ export const MCP_TOOL_RE = /^mcp__([^_]+(?:_[^_]+)*)__([^\n]+)$/i;
36
+ /**
37
+ * OpenClaw's MCP wire format: ``<server>__<tool>`` with no ``mcp__``
38
+ * prefix. Same split; consulted only when {@link MCP_TOOL_RE} did not
39
+ * match, so the ``mcp`` of a prefixed name is never read as a server.
40
+ */
41
+ export const SERVER_TOOL_RE = /^([^_]+(?:_[^_]+)*)__([^\n]+)$/;
42
+ /**
43
+ * Python ``str.strip()`` whitespace (``str.isspace``). Differs from
44
+ * ``String.prototype.trim`` on U+001C-001F and U+0085 (Python strips,
45
+ * JavaScript keeps) and U+FEFF (JavaScript strips, Python keeps).
46
+ */
47
+ const PY_WS = "\\t\\n\\v\\f\\r\\x1c-\\x20\\x85\\xa0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000";
48
+ const PY_STRIP_RE = new RegExp(`^[${PY_WS}]+|[${PY_WS}]+$`, "g");
49
+ function pyStrip(s) {
50
+ return s.replace(PY_STRIP_RE, "");
51
+ }
52
+ /**
53
+ * Python ``str.casefold()``, per code point.
54
+ *
55
+ * Lower-casing alone misses the full case folds (``ß`` -> ``ss``,
56
+ * ``ſ`` -> ``s``, final sigma -> ``σ``, ``µ`` -> ``μ``); folding through
57
+ * the upper case catches those. Two families need explicit handling:
58
+ * dotless ``ı`` has no fold in Python but upper-cases to ``I``, and
59
+ * Unicode folds lower-case Cherokee *to* the upper-case letters. Code
60
+ * points added in a Unicode version one runtime knows and the other does
61
+ * not can still differ; tool names are ASCII in practice.
62
+ */
63
+ function pyCasefold(s) {
64
+ let out = "";
65
+ for (const ch of s) {
66
+ const cp = ch.codePointAt(0);
67
+ if (cp < 0x80) {
68
+ out += ch.toLowerCase();
69
+ }
70
+ else if (cp === 0x131) {
71
+ out += ch;
72
+ }
73
+ else if (cp >= 0xab70 && cp <= 0xabbf) {
74
+ out += String.fromCodePoint(cp - 0xab70 + 0x13a0);
75
+ }
76
+ else if (cp >= 0x13f8 && cp <= 0x13fd) {
77
+ out += String.fromCodePoint(cp - 8);
78
+ }
79
+ else if (cp >= 0x13a0 && cp <= 0x13f5) {
80
+ out += ch;
81
+ }
82
+ else {
83
+ const lower = ch.toLowerCase();
84
+ const upper = lower.toUpperCase();
85
+ out += upper !== lower ? upper.toLowerCase() : lower;
86
+ }
87
+ }
88
+ return out;
89
+ }
90
+ /** ``mcp__finance__issue_refund`` -> ``issue_refund``; else ``null``. */
91
+ function stripMcp(name) {
92
+ const m = MCP_TOOL_RE.exec(name);
93
+ return m ? m[2] : null;
94
+ }
95
+ /** ``finance__issue_refund`` -> ``issue_refund``; else ``null``. */
96
+ function stripServer(name) {
97
+ const m = SERVER_TOOL_RE.exec(name);
98
+ return m ? m[2] : null;
99
+ }
100
+ /**
101
+ * The single spelling a contract keys on.
102
+ *
103
+ * Strips surrounding whitespace and case-folds. The MCP prefix is *not*
104
+ * stripped here: a contract that deliberately names
105
+ * ``mcp__finance__issue_refund`` means that server's tool and should not
106
+ * widen to every tool of that name. Grounding supplies the bare-name
107
+ * alias so the reverse direction still joins.
108
+ */
109
+ export function canonicalTool(tool) {
110
+ return pyCasefold(pyStrip(String(tool)));
111
+ }
112
+ /**
113
+ * Every spelling an event's tool call should answer to.
114
+ *
115
+ * Ordered, duplicate-free, and always contains the raw name first so
116
+ * existing traces and predicate keys keep working unchanged.
117
+ */
118
+ export function toolAliases(tool) {
119
+ const raw = String(tool);
120
+ const out = [raw];
121
+ const stripped = pyStrip(raw);
122
+ out.push(stripped, pyCasefold(stripped));
123
+ const bare = stripMcp(stripped) ?? stripServer(stripped);
124
+ if (bare)
125
+ out.push(bare, pyCasefold(bare));
126
+ return [...new Set(out)].filter((k) => k);
127
+ }
128
+ //# sourceMappingURL=tool-names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-names.js","sourceRoot":"","sources":["../../src/core/tool-names.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,sCAAsC,CAAC;AAElE;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,gCAAgC,CAAC;AAE/D;;;;GAIG;AACH,MAAM,KAAK,GAAG,+FAA+F,CAAC;AAC9G,MAAM,WAAW,GAAG,IAAI,MAAM,CAAC,KAAK,KAAK,OAAO,KAAK,KAAK,EAAE,GAAG,CAAC,CAAC;AAEjE,SAAS,OAAO,CAAC,CAAS;IACxB,OAAO,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AACpC,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,UAAU,CAAC,CAAS;IAC3B,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;QACnB,MAAM,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,CAAW,CAAC;QACvC,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;YACd,GAAG,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC1B,CAAC;aAAM,IAAI,EAAE,KAAK,KAAK,EAAE,CAAC;YACxB,GAAG,IAAI,EAAE,CAAC;QACZ,CAAC;aAAM,IAAI,EAAE,IAAI,MAAM,IAAI,EAAE,IAAI,MAAM,EAAE,CAAC;YACxC,GAAG,IAAI,MAAM,CAAC,aAAa,CAAC,EAAE,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC;QACpD,CAAC;aAAM,IAAI,EAAE,IAAI,MAAM,IAAI,EAAE,IAAI,MAAM,EAAE,CAAC;YACxC,GAAG,IA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