@intutic/shared-types 1.10.0 → 2.0.0

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 (122) hide show
  1. package/README.md +1 -1
  2. package/dist/anomaly.d.ts +11 -0
  3. package/dist/anomaly.d.ts.map +1 -1
  4. package/dist/api-contracts.d.ts +97 -9
  5. package/dist/api-contracts.d.ts.map +1 -1
  6. package/dist/api-contracts.js +9 -0
  7. package/dist/api-contracts.js.map +1 -1
  8. package/dist/auth.d.ts +164 -1
  9. package/dist/auth.d.ts.map +1 -1
  10. package/dist/auth.js +39 -1
  11. package/dist/auth.js.map +1 -1
  12. package/dist/billing.d.ts +2 -99
  13. package/dist/billing.d.ts.map +1 -1
  14. package/dist/billing.js +2 -17
  15. package/dist/billing.js.map +1 -1
  16. package/dist/enums.d.ts +341 -4
  17. package/dist/enums.d.ts.map +1 -1
  18. package/dist/enums.js +369 -6
  19. package/dist/enums.js.map +1 -1
  20. package/dist/errors.d.ts +20 -1
  21. package/dist/errors.d.ts.map +1 -1
  22. package/dist/errors.js +20 -1
  23. package/dist/errors.js.map +1 -1
  24. package/dist/finops.d.ts +97 -1
  25. package/dist/finops.d.ts.map +1 -1
  26. package/dist/governanceCoverage.d.ts +82 -0
  27. package/dist/governanceCoverage.d.ts.map +1 -0
  28. package/dist/governanceCoverage.js +72 -0
  29. package/dist/governanceCoverage.js.map +1 -0
  30. package/dist/guardrailIr.d.ts +287 -0
  31. package/dist/guardrailIr.d.ts.map +1 -0
  32. package/dist/guardrailIr.js +301 -0
  33. package/dist/guardrailIr.js.map +1 -0
  34. package/dist/guardrailRender.d.ts +154 -0
  35. package/dist/guardrailRender.d.ts.map +1 -0
  36. package/dist/guardrailRender.js +440 -0
  37. package/dist/guardrailRender.js.map +1 -0
  38. package/dist/identity.d.ts +75 -0
  39. package/dist/identity.d.ts.map +1 -1
  40. package/dist/identity.js +5 -1
  41. package/dist/identity.js.map +1 -1
  42. package/dist/index.d.ts +34 -14
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +124 -2
  45. package/dist/index.js.map +1 -1
  46. package/dist/intelligence.d.ts +37 -11
  47. package/dist/intelligence.d.ts.map +1 -1
  48. package/dist/intelligence.js.map +1 -1
  49. package/dist/modelCatalog.d.ts +89 -0
  50. package/dist/modelCatalog.d.ts.map +1 -0
  51. package/dist/modelCatalog.generated.d.ts +7217 -0
  52. package/dist/modelCatalog.generated.d.ts.map +1 -0
  53. package/dist/modelCatalog.generated.js +577 -0
  54. package/dist/modelCatalog.generated.js.map +1 -0
  55. package/dist/modelCatalog.js +112 -0
  56. package/dist/modelCatalog.js.map +1 -0
  57. package/dist/notifications.d.ts +134 -2
  58. package/dist/notifications.d.ts.map +1 -1
  59. package/dist/observability.d.ts +4 -0
  60. package/dist/observability.d.ts.map +1 -1
  61. package/dist/policyGuardrails.d.ts +433 -0
  62. package/dist/policyGuardrails.d.ts.map +1 -0
  63. package/dist/policyGuardrails.js +91 -0
  64. package/dist/policyGuardrails.js.map +1 -0
  65. package/dist/posturePresets.d.ts +74 -0
  66. package/dist/posturePresets.d.ts.map +1 -0
  67. package/dist/posturePresets.js +139 -0
  68. package/dist/posturePresets.js.map +1 -0
  69. package/dist/providerVerification.d.ts +64 -0
  70. package/dist/providerVerification.d.ts.map +1 -0
  71. package/dist/providerVerification.js +184 -0
  72. package/dist/providerVerification.js.map +1 -0
  73. package/dist/providers.d.ts +93 -0
  74. package/dist/providers.d.ts.map +1 -0
  75. package/dist/providers.js +176 -0
  76. package/dist/providers.js.map +1 -0
  77. package/dist/rulePredicateDsl.d.ts +101 -0
  78. package/dist/rulePredicateDsl.d.ts.map +1 -0
  79. package/dist/rulePredicateDsl.js +263 -0
  80. package/dist/rulePredicateDsl.js.map +1 -0
  81. package/dist/rulePredicateEval.d.ts +38 -0
  82. package/dist/rulePredicateEval.d.ts.map +1 -0
  83. package/dist/rulePredicateEval.js +124 -0
  84. package/dist/rulePredicateEval.js.map +1 -0
  85. package/dist/scriptScan.d.ts +162 -0
  86. package/dist/scriptScan.d.ts.map +1 -0
  87. package/dist/scriptScan.js +362 -0
  88. package/dist/scriptScan.js.map +1 -0
  89. package/dist/secretPatterns.d.ts +43 -0
  90. package/dist/secretPatterns.d.ts.map +1 -0
  91. package/dist/secretPatterns.js +73 -0
  92. package/dist/secretPatterns.js.map +1 -0
  93. package/dist/skillScan.d.ts +166 -0
  94. package/dist/skillScan.d.ts.map +1 -0
  95. package/dist/skillScan.js +398 -0
  96. package/dist/skillScan.js.map +1 -0
  97. package/dist/sop.d.ts +188 -9
  98. package/dist/sop.d.ts.map +1 -1
  99. package/dist/sop.js +54 -2
  100. package/dist/sop.js.map +1 -1
  101. package/dist/sourceProviders.d.ts +41 -0
  102. package/dist/sourceProviders.d.ts.map +1 -0
  103. package/dist/sourceProviders.js +48 -0
  104. package/dist/sourceProviders.js.map +1 -0
  105. package/dist/sync.d.ts +98 -8
  106. package/dist/sync.d.ts.map +1 -1
  107. package/dist/sync.js.map +1 -1
  108. package/dist/toon.d.ts +80 -0
  109. package/dist/toon.d.ts.map +1 -0
  110. package/dist/toon.js +278 -0
  111. package/dist/toon.js.map +1 -0
  112. package/dist/usage.d.ts +23 -0
  113. package/dist/usage.d.ts.map +1 -1
  114. package/dist/wasmHost.d.ts +58 -0
  115. package/dist/wasmHost.d.ts.map +1 -0
  116. package/dist/wasmHost.js +80 -0
  117. package/dist/wasmHost.js.map +1 -0
  118. package/dist/workspaceSettings.d.ts +463 -21
  119. package/dist/workspaceSettings.d.ts.map +1 -1
  120. package/dist/workspaceSettings.js +86 -1
  121. package/dist/workspaceSettings.js.map +1 -1
  122. package/package.json +4 -3
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ /**
3
+ * Multi-provider credential registry (LLD #67, multi-provider key wizard).
4
+ *
5
+ * `services/control-plane/src/routes/providerCredentials.ts` originally
6
+ * hardcoded exactly 3 providers (anthropic/openai/gemini), each a single
7
+ * bearer API key — sufficient for those three, but LiteLLM's real provider
8
+ * surface includes providers needing MULTIPLE credential fields (Azure
9
+ * OpenAI: endpoint + deployment + key; Bedrock: AWS region + access key +
10
+ * secret; Vertex AI: a service-account JSON blob). This registry is a
11
+ * data-driven description of a provider's credential shape, so adding a
12
+ * new provider's *field layout* is a data change here, not new code in
13
+ * every place that touches credentials.
14
+ *
15
+ * Deliberately NOT exhaustive — LiteLLM supports 100+ providers. This is a
16
+ * representative slice spanning the shapes that actually differ (single
17
+ * key, multi-field cloud credential, self-hosted endpoint, structured
18
+ * blob), chosen so the registry's own shape is proven out before claiming
19
+ * to cover the full LiteLLM catalog. Adding another provider that fits one
20
+ * of these shapes is adding one entry, not new plumbing.
21
+ *
22
+ * `routingLive: true` means `packages/proxy` actually forwards requests to
23
+ * this provider today (`fetch_provider_credential` in `proxy.rs` knows its
24
+ * field name). `routingLive: false` means the credential can be
25
+ * pre-provisioned here, but nothing in the proxy calls it yet — routing
26
+ * support is separate, real per-provider engineering (a new `Provider`
27
+ * enum variant, `get_model_provider`, pricing in `pricing.rs`), not a
28
+ * config change. The dashboard wizard must say so, not imply the key is
29
+ * live the moment it's saved.
30
+ *
31
+ * @module
32
+ */
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ exports.PROVIDER_REGISTRY = exports.LIVE_ROUTING_PROVIDER_IDS = void 0;
35
+ exports.getProviderDefinition = getProviderDefinition;
36
+ exports.isKnownProviderId = isKnownProviderId;
37
+ exports.inferProviderForModel = inferProviderForModel;
38
+ /**
39
+ * The 3 providers this system supported before this registry existed —
40
+ * their storage format (`{provider}_api_key`, a flat string field) is
41
+ * unchanged here, matching what `packages/proxy/src/proxy.rs`'s
42
+ * `fetch_provider_credential` has always read for them.
43
+ *
44
+ * NOT the same question as a provider's `routingLive` flag. This constant
45
+ * decides *storage shape* (flat field vs. `{provider}_config` JSON blob);
46
+ * `routingLive` decides whether the proxy currently forwards requests to a
47
+ * provider at all. They agreed for exactly these 3 while this registry only
48
+ * covered its original scope, but multi-provider wizard phase 3 added real
49
+ * proxy routing for Mistral and OpenRouter *without* changing their storage
50
+ * format — `fetch_provider_credential` reads the JSON blob for both, never
51
+ * the flat field, so they stay off this list even though `routingLive` is
52
+ * now `true` for them. Adding a provider here changes what Valkey field
53
+ * `services/control-plane/src/routes/providerCredentials.ts` writes to —
54
+ * only do it alongside the matching proxy-side flat-field read, never for
55
+ * the "is this provider live" reason alone.
56
+ */
57
+ exports.LIVE_ROUTING_PROVIDER_IDS = ['anthropic', 'openai', 'gemini'];
58
+ exports.PROVIDER_REGISTRY = [
59
+ {
60
+ id: 'anthropic',
61
+ displayName: 'Anthropic',
62
+ docsUrl: 'https://console.anthropic.com/settings/keys',
63
+ fields: [{ key: 'apiKey', label: 'API Key', type: 'password', required: true, placeholder: 'sk-ant-...' }],
64
+ routingLive: true,
65
+ },
66
+ {
67
+ id: 'openai',
68
+ displayName: 'OpenAI',
69
+ docsUrl: 'https://platform.openai.com/api-keys',
70
+ fields: [{ key: 'apiKey', label: 'API Key', type: 'password', required: true, placeholder: 'sk-...' }],
71
+ routingLive: true,
72
+ },
73
+ {
74
+ id: 'gemini',
75
+ displayName: 'Google Gemini',
76
+ docsUrl: 'https://aistudio.google.com/app/apikey',
77
+ fields: [{ key: 'apiKey', label: 'API Key', type: 'password', required: true }],
78
+ routingLive: true,
79
+ },
80
+ {
81
+ id: 'azure_openai',
82
+ displayName: 'Azure OpenAI',
83
+ docsUrl: 'https://learn.microsoft.com/azure/ai-services/openai/how-to/create-resource',
84
+ fields: [
85
+ { key: 'apiKey', label: 'API Key', type: 'password', required: true },
86
+ { key: 'endpoint', label: 'Resource Endpoint', type: 'text', required: true, placeholder: 'https://your-resource.openai.azure.com' },
87
+ { key: 'deploymentName', label: 'Deployment Name', type: 'text', required: true },
88
+ ],
89
+ routingLive: false,
90
+ },
91
+ {
92
+ id: 'bedrock',
93
+ displayName: 'AWS Bedrock',
94
+ docsUrl: 'https://docs.aws.amazon.com/bedrock/latest/userguide/getting-started.html',
95
+ fields: [
96
+ { key: 'awsAccessKeyId', label: 'AWS Access Key ID', type: 'password', required: true },
97
+ { key: 'awsSecretAccessKey', label: 'AWS Secret Access Key', type: 'password', required: true },
98
+ { key: 'awsRegion', label: 'AWS Region', type: 'text', required: true, placeholder: 'us-east-1' },
99
+ ],
100
+ routingLive: false,
101
+ },
102
+ {
103
+ id: 'vertex_ai',
104
+ displayName: 'Google Vertex AI',
105
+ docsUrl: 'https://cloud.google.com/vertex-ai/docs/authentication',
106
+ fields: [
107
+ { key: 'projectId', label: 'GCP Project ID', type: 'text', required: true },
108
+ { key: 'serviceAccountJson', label: 'Service Account JSON', type: 'textarea', required: true, helpText: 'The full JSON key file contents for a service account with Vertex AI access.' },
109
+ ],
110
+ routingLive: false,
111
+ },
112
+ {
113
+ id: 'cohere',
114
+ displayName: 'Cohere',
115
+ docsUrl: 'https://dashboard.cohere.com/api-keys',
116
+ fields: [{ key: 'apiKey', label: 'API Key', type: 'password', required: true }],
117
+ routingLive: false,
118
+ },
119
+ {
120
+ id: 'mistral',
121
+ displayName: 'Mistral AI',
122
+ docsUrl: 'https://console.mistral.ai/api-keys',
123
+ fields: [{ key: 'apiKey', label: 'API Key', type: 'password', required: true }],
124
+ routingLive: true,
125
+ },
126
+ {
127
+ id: 'openrouter',
128
+ displayName: 'OpenRouter',
129
+ docsUrl: 'https://openrouter.ai/keys',
130
+ fields: [{ key: 'apiKey', label: 'API Key', type: 'password', required: true }],
131
+ routingLive: true,
132
+ },
133
+ {
134
+ id: 'ollama',
135
+ displayName: 'Ollama (self-hosted)',
136
+ docsUrl: 'https://github.com/ollama/ollama/blob/main/docs/api.md',
137
+ fields: [{ key: 'apiBase', label: 'Server URL', type: 'text', required: true, placeholder: 'http://localhost:11434' }],
138
+ routingLive: false,
139
+ },
140
+ ];
141
+ function getProviderDefinition(id) {
142
+ return exports.PROVIDER_REGISTRY.find((p) => p.id === id);
143
+ }
144
+ function isKnownProviderId(id) {
145
+ return exports.PROVIDER_REGISTRY.some((p) => p.id === id);
146
+ }
147
+ /**
148
+ * Which provider the data-plane proxy would route a model name to.
149
+ *
150
+ * A hand-maintained TS mirror of `get_model_provider` in
151
+ * `packages/proxy/src/proxy.rs` — the proxy's routing decision is the ground
152
+ * truth, and this exists so the control plane / dashboard can predict it
153
+ * (e.g. the BYO judge model "Test" flow fast-failing on an unprovisioned
154
+ * provider before making a real call, LLD #70). A parity unit test pins this
155
+ * against the Rust source; if the heuristic changes there, change it here in
156
+ * the same commit.
157
+ *
158
+ * Order matters and matches the Rust exactly: claude → gemini → '/'
159
+ * (OpenRouter's vendor/model namespacing — checked before the mistral
160
+ * prefixes so "mistralai/..." routes to OpenRouter) → mistral prefixes →
161
+ * OpenAI as the default arm.
162
+ */
163
+ function inferProviderForModel(model) {
164
+ const m = model.toLowerCase();
165
+ if (m.includes('claude'))
166
+ return 'anthropic';
167
+ if (m.includes('gemini'))
168
+ return 'gemini';
169
+ if (m.includes('/'))
170
+ return 'openrouter';
171
+ if (m.startsWith('mistral') || m.startsWith('open-mixtral') || m.startsWith('codestral')) {
172
+ return 'mistral';
173
+ }
174
+ return 'openai';
175
+ }
176
+ //# sourceMappingURL=providers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providers.js","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;;;AAmIH,sDAEC;AAED,8CAEC;AAkBD,sDAWC;AA5ID;;;;;;;;;;;;;;;;;;GAkBG;AACU,QAAA,yBAAyB,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAA;AAEtE,QAAA,iBAAiB,GAAyB;IACrD;QACE,EAAE,EAAE,WAAW;QACf,WAAW,EAAE,WAAW;QACxB,OAAO,EAAE,6CAA6C;QACtD,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EA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UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QACzF,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * The closed-vocabulary predicate language, and its deterministic renderer.
3
+ *
4
+ * A generated rule is described here as JSON and turned into AssemblyScript by
5
+ * `renderRule`. **The generator never emits AssemblyScript.** That boundary is
6
+ * the whole design, and it exists because the starter rule library encodes three
7
+ * inversions an LLM writing source would reintroduce:
8
+ *
9
+ * - `-1` means **unknown**, not zero. A rule written
10
+ * `if (spend > budget)` reads unknown as "under budget"; one written
11
+ * `if (remaining < 10)` reads it as "broke" and blocks every request
12
+ * outside a workflow.
13
+ * - An **empty** allowlist means unrestricted, not "permit nothing". Reading
14
+ * it the other way blocks every request in a workspace that never declared
15
+ * one.
16
+ * - `new_tool_calls` is this turn's delta; `tool_sequence` is the whole
17
+ * session. Matching a hold against history re-fires it forever.
18
+ *
19
+ * Each of those is a one-token difference in source and a *structural*
20
+ * impossibility in the DSL: there is no operator that compares an optional
21
+ * numeric without the unknown check, and `listEmpty` is spelled differently from
22
+ * `notIn`.
23
+ *
24
+ * ## Closed by construction
25
+ *
26
+ * `FIELDS` below is the vocabulary. A field the guest parser does not read
27
+ * cannot be named, so a predicate cannot reference something that will silently
28
+ * be zero at runtime — the shape that produced every inert control in this
29
+ * codebase. `check-rule-dsl-fields.js` asserts the table against the SDK's real
30
+ * parser.
31
+ *
32
+ * @module
33
+ */
34
+ /** Types the DSL can reason about, mapped to what the guest exposes. */
35
+ export type FieldKind = 'string' | 'int' | 'float' | 'optionalFloat' | 'optionalInt' | 'stringList' | 'bool';
36
+ /**
37
+ * Every field a predicate may name, with the guest type it resolves to.
38
+ *
39
+ * Derived by hand from `packages/wasm-sdk/assembly/index.ts` and gated against
40
+ * it. Deliberately excludes the structured lists (`tools`, `tool_calls`,
41
+ * `changes`, `tool_call_counts`, the four SOP rule arrays) — comparing those
42
+ * needs operators this vocabulary does not have, and half-supporting them
43
+ * would let a generator produce a predicate that renders to something that
44
+ * always evaluates false.
45
+ */
46
+ export declare const FIELDS: Record<string, FieldKind>;
47
+ /** Operators, each valid only for certain field kinds. */
48
+ export declare const OPERATORS: {
49
+ readonly equals: readonly ["string"];
50
+ readonly notEquals: readonly ["string"];
51
+ readonly isTrue: readonly ["bool"];
52
+ readonly isFalse: readonly ["bool"];
53
+ /** Membership in this turn's delta or the session history. */
54
+ readonly contains: readonly ["stringList"];
55
+ readonly notContains: readonly ["stringList"];
56
+ /** The empty-list-means-unrestricted case, spelled so it cannot be confused. */
57
+ readonly listEmpty: readonly ["stringList"];
58
+ readonly listNotEmpty: readonly ["stringList"];
59
+ /**
60
+ * `atLeast` / `atMost` on an optional numeric render WITH the unknown guard.
61
+ * There is no operator that compares one without it.
62
+ */
63
+ readonly atLeast: readonly ["int", "float", "optionalFloat", "optionalInt"];
64
+ readonly atMost: readonly ["int", "float", "optionalFloat", "optionalInt"];
65
+ /** Compares two optional numerics; unknown on either side yields false. */
66
+ readonly exceedsField: readonly ["optionalFloat"];
67
+ };
68
+ export type Operator = keyof typeof OPERATORS;
69
+ export interface Condition {
70
+ field: string;
71
+ op: Operator;
72
+ /** Absent for `isTrue`/`isFalse`/`listEmpty`/`listNotEmpty`. */
73
+ value?: string | number;
74
+ }
75
+ export interface Predicate {
76
+ /** Conditions are ANDed. Deliberately no OR: a rule that fires for two
77
+ * unrelated reasons is two rules, and shadow evidence for one of them says
78
+ * nothing about the other. */
79
+ all: Condition[];
80
+ }
81
+ export declare class PredicateError extends Error {
82
+ }
83
+ /** Rejects anything the vocabulary does not permit, with the reason. */
84
+ export declare function validatePredicate(p: unknown): asserts p is Predicate;
85
+ /** Verdict codes the renderer will emit. 2 is deprecated and refused. */
86
+ export declare const RENDERABLE_VERDICTS: readonly [1, 3];
87
+ /**
88
+ * Renders a validated predicate to standalone AssemblyScript.
89
+ *
90
+ * Deterministic: the same predicate always produces byte-identical source, so a
91
+ * candidate's compiled hash is reproducible and a reviewer diffing two versions
92
+ * sees only what actually changed.
93
+ */
94
+ export declare function renderRule(input: {
95
+ predicate: Predicate;
96
+ verdict: number;
97
+ title: string;
98
+ rationale: string;
99
+ candidateId: string;
100
+ }): string;
101
+ //# sourceMappingURL=rulePredicateDsl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rulePredicateDsl.d.ts","sourceRoot":"","sources":["../src/rulePredicateDsl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,wEAAwE;AACxE,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,eAAe,GAAG,aAAa,GAAG,YAAY,GAAG,MAAM,CAAA;AAE5G;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CA2B5C,CAAA;AAED,0DAA0D;AAC1D,eAAO,MAAM,SAAS;;;;;IAKpB,8DAA8D;;;IAG9D,gFAAgF;;;IAGhF;;;OAGG;;;IAGH,2EAA2E;;CAEnE,CAAA;AAEV,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,SAAS,CAAA;AAE7C,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,EAAE,EAAE,QAAQ,CAAA;IACZ,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,SAAS;IACxB;;mCAE+B;IAC/B,GAAG,EAAE,SAAS,EAAE,CAAA;CACjB;AAED,qBAAa,cAAe,SAAQ,KAAK;CAAG;AAE5C,wEAAwE;AACxE,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,IAAI,SAAS,CAgEpE;AAiDD,yEAAyE;AACzE,eAAO,MAAM,mBAAmB,iBAAkB,CAAA;AAElD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE;IAChC,SAAS,EAAE,SAAS,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;CACpB,GAAG,MAAM,CAwDT"}
@@ -0,0 +1,263 @@
1
+ "use strict";
2
+ /**
3
+ * The closed-vocabulary predicate language, and its deterministic renderer.
4
+ *
5
+ * A generated rule is described here as JSON and turned into AssemblyScript by
6
+ * `renderRule`. **The generator never emits AssemblyScript.** That boundary is
7
+ * the whole design, and it exists because the starter rule library encodes three
8
+ * inversions an LLM writing source would reintroduce:
9
+ *
10
+ * - `-1` means **unknown**, not zero. A rule written
11
+ * `if (spend > budget)` reads unknown as "under budget"; one written
12
+ * `if (remaining < 10)` reads it as "broke" and blocks every request
13
+ * outside a workflow.
14
+ * - An **empty** allowlist means unrestricted, not "permit nothing". Reading
15
+ * it the other way blocks every request in a workspace that never declared
16
+ * one.
17
+ * - `new_tool_calls` is this turn's delta; `tool_sequence` is the whole
18
+ * session. Matching a hold against history re-fires it forever.
19
+ *
20
+ * Each of those is a one-token difference in source and a *structural*
21
+ * impossibility in the DSL: there is no operator that compares an optional
22
+ * numeric without the unknown check, and `listEmpty` is spelled differently from
23
+ * `notIn`.
24
+ *
25
+ * ## Closed by construction
26
+ *
27
+ * `FIELDS` below is the vocabulary. A field the guest parser does not read
28
+ * cannot be named, so a predicate cannot reference something that will silently
29
+ * be zero at runtime — the shape that produced every inert control in this
30
+ * codebase. `check-rule-dsl-fields.js` asserts the table against the SDK's real
31
+ * parser.
32
+ *
33
+ * @module
34
+ */
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.RENDERABLE_VERDICTS = exports.PredicateError = exports.OPERATORS = exports.FIELDS = void 0;
37
+ exports.validatePredicate = validatePredicate;
38
+ exports.renderRule = renderRule;
39
+ /**
40
+ * Every field a predicate may name, with the guest type it resolves to.
41
+ *
42
+ * Derived by hand from `packages/wasm-sdk/assembly/index.ts` and gated against
43
+ * it. Deliberately excludes the structured lists (`tools`, `tool_calls`,
44
+ * `changes`, `tool_call_counts`, the four SOP rule arrays) — comparing those
45
+ * needs operators this vocabulary does not have, and half-supporting them
46
+ * would let a generator produce a predicate that renders to something that
47
+ * always evaluates false.
48
+ */
49
+ exports.FIELDS = {
50
+ model: 'string',
51
+ harness: 'string',
52
+ risk_tier: 'string',
53
+ agent_role: 'string',
54
+ estimated_input_tokens: 'int',
55
+ depth: 'int',
56
+ graph_node_count: 'int',
57
+ calls_last_60s: 'int',
58
+ budget_remaining_usd: 'float',
59
+ // Optional numerics arrive as -1 when the host has nothing to send. The
60
+ // `optional` kinds are what force an unknown check into the rendered source.
61
+ graph_spend_usd: 'optionalFloat',
62
+ graph_budget_usd: 'optionalFloat',
63
+ workflow_spend_usd: 'optionalFloat',
64
+ workflow_budget_usd: 'optionalFloat',
65
+ parent_alive: 'optionalInt',
66
+ tool_sequence: 'stringList',
67
+ new_tool_calls: 'stringList',
68
+ injection_findings: 'stringList',
69
+ injection_sources: 'stringList',
70
+ denied_tools: 'stringList',
71
+ allowed_harnesses: 'stringList',
72
+ review_before: 'stringList',
73
+ plan_steps: 'stringList',
74
+ scope_paths: 'stringList',
75
+ tool_contract_changed: 'bool',
76
+ };
77
+ /** Operators, each valid only for certain field kinds. */
78
+ exports.OPERATORS = {
79
+ equals: ['string'],
80
+ notEquals: ['string'],
81
+ isTrue: ['bool'],
82
+ isFalse: ['bool'],
83
+ /** Membership in this turn's delta or the session history. */
84
+ contains: ['stringList'],
85
+ notContains: ['stringList'],
86
+ /** The empty-list-means-unrestricted case, spelled so it cannot be confused. */
87
+ listEmpty: ['stringList'],
88
+ listNotEmpty: ['stringList'],
89
+ /**
90
+ * `atLeast` / `atMost` on an optional numeric render WITH the unknown guard.
91
+ * There is no operator that compares one without it.
92
+ */
93
+ atLeast: ['int', 'float', 'optionalFloat', 'optionalInt'],
94
+ atMost: ['int', 'float', 'optionalFloat', 'optionalInt'],
95
+ /** Compares two optional numerics; unknown on either side yields false. */
96
+ exceedsField: ['optionalFloat'],
97
+ };
98
+ class PredicateError extends Error {
99
+ }
100
+ exports.PredicateError = PredicateError;
101
+ /** Rejects anything the vocabulary does not permit, with the reason. */
102
+ function validatePredicate(p) {
103
+ if (!p || typeof p !== 'object' || !Array.isArray(p.all)) {
104
+ throw new PredicateError('predicate must be { all: Condition[] }');
105
+ }
106
+ const all = p.all;
107
+ if (all.length === 0) {
108
+ throw new PredicateError('predicate has no conditions, so it would fire on every request');
109
+ }
110
+ if (all.length > 8) {
111
+ throw new PredicateError(`predicate has ${all.length} conditions; more than 8 is not a rule anyone can review`);
112
+ }
113
+ for (const c of all) {
114
+ const kind = exports.FIELDS[c.field];
115
+ if (!kind) {
116
+ throw new PredicateError(`"${c.field}" is not a field a rule may read. A predicate naming a field ` +
117
+ 'the guest does not parse renders to a comparison against a default, ' +
118
+ 'which is a rule that silently never fires.');
119
+ }
120
+ const allowed = exports.OPERATORS[c.op];
121
+ if (!allowed)
122
+ throw new PredicateError(`"${c.op}" is not an operator`);
123
+ if (!allowed.includes(kind)) {
124
+ throw new PredicateError(`"${c.op}" cannot apply to ${c.field}, which is ${kind}`);
125
+ }
126
+ const needsValue = !['isTrue', 'isFalse', 'listEmpty', 'listNotEmpty'].includes(c.op);
127
+ if (needsValue && (c.value === undefined || c.value === null)) {
128
+ throw new PredicateError(`"${c.op}" on ${c.field} needs a value`);
129
+ }
130
+ if (!needsValue && c.value !== undefined) {
131
+ throw new PredicateError(`"${c.op}" on ${c.field} takes no value`);
132
+ }
133
+ if (needsValue) {
134
+ // `exceedsField` compares two fields, so its value is a field NAME even
135
+ // though the field it applies to is numeric. Checked before the type rule
136
+ // below, which would otherwise reject every valid use of it.
137
+ if (c.op === 'exceedsField') {
138
+ if (typeof c.value !== 'string' || !exports.FIELDS[c.value]) {
139
+ throw new PredicateError(`exceedsField must name a field; "${String(c.value)}" is not one`);
140
+ }
141
+ if (!String(exports.FIELDS[c.value]).startsWith('optional')) {
142
+ throw new PredicateError(`exceedsField compares two optional numerics; ${String(c.value)} is ${exports.FIELDS[c.value]}`);
143
+ }
144
+ continue;
145
+ }
146
+ const numeric = ['int', 'float', 'optionalFloat', 'optionalInt'].includes(kind);
147
+ if (numeric && typeof c.value !== 'number') {
148
+ throw new PredicateError(`${c.field} is numeric; "${String(c.value)}" is not`);
149
+ }
150
+ if (!numeric && typeof c.value !== 'string') {
151
+ throw new PredicateError(`${c.field} is textual; ${String(c.value)} is not`);
152
+ }
153
+ }
154
+ }
155
+ }
156
+ /** AssemblyScript string literal. Never interpolate a value without this. */
157
+ function lit(v) {
158
+ return JSON.stringify(v);
159
+ }
160
+ /**
161
+ * One condition as an AssemblyScript expression.
162
+ *
163
+ * The optional-numeric arms carry their own `!= -1` guard, which is why the DSL
164
+ * has no bare comparison operator for them: the guard cannot be forgotten
165
+ * because there is no way to express the comparison without it.
166
+ */
167
+ function renderCondition(c) {
168
+ const f = `ctx.${c.field}`;
169
+ switch (c.op) {
170
+ case 'equals':
171
+ return `${f} == ${lit(String(c.value))}`;
172
+ case 'notEquals':
173
+ return `${f} != ${lit(String(c.value))}`;
174
+ case 'isTrue':
175
+ return f;
176
+ case 'isFalse':
177
+ return `!${f}`;
178
+ case 'contains':
179
+ return `listHas(${f}, ${lit(String(c.value))})`;
180
+ case 'notContains':
181
+ return `!listHas(${f}, ${lit(String(c.value))})`;
182
+ case 'listEmpty':
183
+ return `${f}.length == 0`;
184
+ case 'listNotEmpty':
185
+ return `${f}.length > 0`;
186
+ case 'atLeast':
187
+ return exports.FIELDS[c.field].startsWith('optional')
188
+ ? `(${f} != -1 && ${f} >= ${c.value})`
189
+ : `${f} >= ${c.value}`;
190
+ case 'atMost':
191
+ return exports.FIELDS[c.field].startsWith('optional')
192
+ ? `(${f} != -1 && ${f} <= ${c.value})`
193
+ : `${f} <= ${c.value}`;
194
+ case 'exceedsField': {
195
+ const other = `ctx.${String(c.value)}`;
196
+ // Both sides must be known. Unknown on either yields false, never a block.
197
+ return `(${f} != -1 && ${other} != -1 && ${other} != 0 && ${f} >= ${other})`;
198
+ }
199
+ }
200
+ }
201
+ /** Verdict codes the renderer will emit. 2 is deprecated and refused. */
202
+ exports.RENDERABLE_VERDICTS = [1, 3];
203
+ /**
204
+ * Renders a validated predicate to standalone AssemblyScript.
205
+ *
206
+ * Deterministic: the same predicate always produces byte-identical source, so a
207
+ * candidate's compiled hash is reproducible and a reviewer diffing two versions
208
+ * sees only what actually changed.
209
+ */
210
+ function renderRule(input) {
211
+ validatePredicate(input.predicate);
212
+ if (!exports.RENDERABLE_VERDICTS.includes(input.verdict)) {
213
+ throw new PredicateError(`verdict ${input.verdict} is not renderable. 1 blocks, 3 reasks; 0 would be a ` +
214
+ 'rule that does nothing and 2 is deprecated — the proxy maps it to a block.');
215
+ }
216
+ const conditions = input.predicate.all.map(renderCondition);
217
+ // One condition per line, ANDed. Formatted rather than joined into one
218
+ // expression so a reviewer can read the generated source at all.
219
+ const expr = conditions.map((c) => ` ${c}`).join(' &&\n');
220
+ // Comments carry no backticks or ${: this string is assembled here, but the
221
+ // title and rationale come from a generator and must not be able to terminate
222
+ // anything downstream. JSON-encoding them makes that structural.
223
+ //
224
+ // That goes for the candidate id too, which was the one field interpolated
225
+ // raw while the comment above claimed all three were encoded. A `//` comment
226
+ // is terminated by a newline, so an id carrying one moved whatever followed it
227
+ // onto a line of its own — as AssemblyScript, in a file about to be compiled
228
+ // and loaded as a policy rule. Only tests construct ids today, which is what
229
+ // made it latent rather than live.
230
+ return `// Generated by Intutic from reviewed decisions. Do not edit.
231
+ //
232
+ // Candidate: ${JSON.stringify(input.candidateId)}
233
+ // Title: ${JSON.stringify(input.title)}
234
+ // Rationale: ${JSON.stringify(input.rationale)}
235
+ //
236
+ // Rendered deterministically from a closed-vocabulary predicate; the generator
237
+ // does not write AssemblyScript. Verdict ${input.verdict} — 1 blocks, 3 reasks.
238
+ import { RequestContext, readContext } from "../../assembly/index";
239
+
240
+ export { allocate } from "../../assembly/index";
241
+
242
+ function listHas(xs: string[], needle: string): bool {
243
+ for (let i = 0; i < xs.length; i++) {
244
+ if (xs[i] == needle) return true;
245
+ }
246
+ return false;
247
+ }
248
+
249
+ export function rule(ctx: RequestContext): i32 {
250
+ if (
251
+ ${expr}
252
+ ) {
253
+ return ${input.verdict};
254
+ }
255
+ return 0;
256
+ }
257
+
258
+ export function evaluate(offset: i32, len: i32): i32 {
259
+ return rule(readContext(offset, len));
260
+ }
261
+ `;
262
+ }
263
+ //# sourceMappingURL=rulePredicateDsl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rulePredicateDsl.js","sourceRoot":"","sources":["../src/rulePredicateDsl.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;;;AAqFH,8CAgEC;AA2DD,gCA8DC;AAzQD;;;;;;;;;GASG;AACU,QAAA,MAAM,GAA8B;IAC/C,KAAK,EAAE,QAAQ;IACf,OAAO,EAAE,QAAQ;IACjB,SAAS,EAAE,QAAQ;IACnB,UAAU,EAAE,QAAQ;IACpB,sBAAsB,EAAE,KAAK;IAC7B,KAAK,EAAE,KAAK;IACZ,gBAAgB,EAAE,KAAK;IACvB,cAAc,EAAE,KAAK;IACrB,oBAAoB,EAAE,OAAO;IAC7B,wEAAwE;IACxE,6EAA6E;IAC7E,eAAe,EAAE,eAAe;IAChC,gBAAgB,EAAE,eAAe;IACjC,kBAAkB,EAAE,eAAe;IACnC,mBAAmB,EAAE,eAAe;IACpC,YAAY,EAAE,aAAa;IAC3B,aAAa,EAAE,YAAY;IAC3B,cAAc,EAAE,YAAY;IAC5B,kBAAkB,EAAE,YAAY;IAChC,iBAAiB,EAAE,YAAY;IAC/B,YAAY,EAAE,YAAY;IAC1B,iBAAiB,EAAE,YAAY;IAC/B,aAAa,EAAE,YAAY;IAC3B,UAAU,EAAE,YAAY;IACxB,WA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C,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC;;;4CAGH,KAAK,CAAC,OAAO;;;;;;;;;;;;;;EAcvD,IAAI;;aAEO,KAAK,CAAC,OAAO;;;;;;;;CAQzB,CAAA;AACD,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The TypeScript reading of a predicate — the same arithmetic `renderRule`
3
+ * emits, evaluated over a stored context snapshot instead of compiled.
4
+ *
5
+ * Used where a compiled bundle does not exist yet: picking a block mock and
6
+ * a near-miss for a policy-cited candidate (`/mocks` in citation mode) and
7
+ * previewing "N of M captured contexts would have fired" for a `wasm_rule`
8
+ * guardrail before anyone compiles anything. It decides nothing about
9
+ * enforcement: the compiled rule is what the proxy runs, and the bundle
10
+ * gates (`discriminates`, `historical_replay`) still run the real binary.
11
+ *
12
+ * Parity with the binary is pinned in
13
+ * `packages/wasm-sdk/__tests__/generatedRules.test.ts`, which asserts this
14
+ * function and the compiled module agree on every semantic case. That test
15
+ * is the reason this file mirrors the guest's *defaults* as well as its
16
+ * operators: a field the snapshot does not carry reads as `""`, `0`, `-1`
17
+ * (optional numerics), `[]` or `false`, exactly as `readContext` leaves it.
18
+ *
19
+ * @module
20
+ */
21
+ import { type Predicate } from './rulePredicateDsl.js';
22
+ /**
23
+ * Does this predicate fire on this snapshot? `true` means the compiled rule
24
+ * would return its verdict; `false` means it would return 0 (allow).
25
+ *
26
+ * Does not validate: call {@link compilePredicate} to validate once and
27
+ * evaluate many times, or `validatePredicate` yourself first.
28
+ */
29
+ export declare function evaluatePredicate(predicate: Predicate, ctx: Record<string, unknown>): boolean;
30
+ /**
31
+ * Validate once, evaluate many. Throws `PredicateError` on anything outside
32
+ * the vocabulary — the same refusal `renderRule` gives — so a stored
33
+ * predicate that could not compile never reads as "fires on nothing".
34
+ */
35
+ export declare function compilePredicate(predicate: unknown): (ctx: Record<string, unknown>) => boolean;
36
+ /** Every string literal a predicate compares against; what a citation must ground. */
37
+ export declare function predicateStringValues(predicate: Predicate): string[];
38
+ //# sourceMappingURL=rulePredicateEval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rulePredicateEval.d.ts","sourceRoot":"","sources":["../src/rulePredicateEval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAA6C,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAuEjG;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAE7F;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,OAAO,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAG9F;AAED,sFAAsF;AACtF,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,EAAE,CAOpE"}