@intutic/shared-types 2.1.0 → 2.3.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 (188) hide show
  1. package/dist/anomaly.d.ts +6 -10
  2. package/dist/anomaly.d.ts.map +1 -1
  3. package/dist/anomaly.js +0 -2
  4. package/dist/anomaly.js.map +1 -1
  5. package/dist/api-contracts.d.ts +1 -1
  6. package/dist/api-contracts.js +1 -1
  7. package/dist/attenuation.d.ts +1 -1
  8. package/dist/attenuation.js +1 -1
  9. package/dist/auth.d.ts +10 -9
  10. package/dist/auth.d.ts.map +1 -1
  11. package/dist/auth.js +3 -4
  12. package/dist/auth.js.map +1 -1
  13. package/dist/billing.d.ts +1 -1
  14. package/dist/billing.js +1 -1
  15. package/dist/destructiveSql.d.ts +48 -0
  16. package/dist/destructiveSql.d.ts.map +1 -0
  17. package/dist/destructiveSql.js +43 -0
  18. package/dist/destructiveSql.js.map +1 -0
  19. package/dist/devInventory.d.ts +120 -0
  20. package/dist/devInventory.d.ts.map +1 -0
  21. package/dist/devInventory.js +80 -0
  22. package/dist/devInventory.js.map +1 -0
  23. package/dist/enums.d.ts +18 -21
  24. package/dist/enums.d.ts.map +1 -1
  25. package/dist/enums.js +24 -28
  26. package/dist/enums.js.map +1 -1
  27. package/dist/errors.js +3 -3
  28. package/dist/errors.js.map +1 -1
  29. package/dist/finops.d.ts +14 -2
  30. package/dist/finops.d.ts.map +1 -1
  31. package/dist/finops.js +15 -1
  32. package/dist/finops.js.map +1 -1
  33. package/dist/gateDecisions.d.ts +18 -0
  34. package/dist/gateDecisions.d.ts.map +1 -0
  35. package/dist/gateDecisions.js +20 -0
  36. package/dist/gateDecisions.js.map +1 -0
  37. package/dist/gateIdentity.d.ts +23 -0
  38. package/dist/gateIdentity.d.ts.map +1 -0
  39. package/dist/gateIdentity.js +32 -0
  40. package/dist/gateIdentity.js.map +1 -0
  41. package/dist/gateKind.d.ts +172 -0
  42. package/dist/gateKind.d.ts.map +1 -0
  43. package/dist/gateKind.js +160 -0
  44. package/dist/gateKind.js.map +1 -0
  45. package/dist/gateLimits.d.ts +170 -0
  46. package/dist/gateLimits.d.ts.map +1 -0
  47. package/dist/gateLimits.js +96 -0
  48. package/dist/gateLimits.js.map +1 -0
  49. package/dist/gitRemote.d.ts +17 -0
  50. package/dist/gitRemote.d.ts.map +1 -0
  51. package/dist/gitRemote.js +71 -0
  52. package/dist/gitRemote.js.map +1 -0
  53. package/dist/governanceCoverage.d.ts +3 -3
  54. package/dist/governanceCoverage.js +3 -3
  55. package/dist/guardrailIr.d.ts +3 -3
  56. package/dist/guardrailIr.d.ts.map +1 -1
  57. package/dist/guardrailIr.js +3 -3
  58. package/dist/guardrailIr.js.map +1 -1
  59. package/dist/guardrailRender.d.ts +1 -1
  60. package/dist/guardrailRender.js +1 -1
  61. package/dist/harnessRules.d.ts +74 -0
  62. package/dist/harnessRules.d.ts.map +1 -0
  63. package/dist/harnessRules.js +142 -0
  64. package/dist/harnessRules.js.map +1 -0
  65. package/dist/holdMessages.d.ts +25 -0
  66. package/dist/holdMessages.d.ts.map +1 -0
  67. package/dist/holdMessages.js +34 -0
  68. package/dist/holdMessages.js.map +1 -0
  69. package/dist/identity.d.ts +1 -1
  70. package/dist/identity.js +2 -2
  71. package/dist/identity.js.map +1 -1
  72. package/dist/index.d.ts +36 -6
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +141 -10
  75. package/dist/index.js.map +1 -1
  76. package/dist/intelligence.d.ts +1 -2
  77. package/dist/intelligence.d.ts.map +1 -1
  78. package/dist/intelligence.js.map +1 -1
  79. package/dist/mcpBudgets.d.ts +191 -0
  80. package/dist/mcpBudgets.d.ts.map +1 -0
  81. package/dist/mcpBudgets.js +144 -0
  82. package/dist/mcpBudgets.js.map +1 -0
  83. package/dist/mcpRegistryRecord.d.ts +143 -0
  84. package/dist/mcpRegistryRecord.d.ts.map +1 -0
  85. package/dist/mcpRegistryRecord.js +229 -0
  86. package/dist/mcpRegistryRecord.js.map +1 -0
  87. package/dist/mcpToolRisk.d.ts +82 -0
  88. package/dist/mcpToolRisk.d.ts.map +1 -0
  89. package/dist/mcpToolRisk.js +334 -0
  90. package/dist/mcpToolRisk.js.map +1 -0
  91. package/dist/modelCatalog.d.ts +2 -2
  92. package/dist/modelCatalog.generated.js +1 -1
  93. package/dist/modelCatalog.generated.js.map +1 -1
  94. package/dist/modelCatalog.js +2 -2
  95. package/dist/notifications.d.ts +20 -130
  96. package/dist/notifications.d.ts.map +1 -1
  97. package/dist/notifications.js +241 -1
  98. package/dist/notifications.js.map +1 -1
  99. package/dist/phrases.d.ts +87 -0
  100. package/dist/phrases.d.ts.map +1 -0
  101. package/dist/phrases.js +241 -0
  102. package/dist/phrases.js.map +1 -0
  103. package/dist/piiDetectors.d.ts +97 -0
  104. package/dist/piiDetectors.d.ts.map +1 -0
  105. package/dist/piiDetectors.js +96 -0
  106. package/dist/piiDetectors.js.map +1 -0
  107. package/dist/piiDetectors.json +71 -0
  108. package/dist/policy.d.ts +1 -1
  109. package/dist/policy.js +1 -1
  110. package/dist/policyGuardrails.d.ts +127 -10
  111. package/dist/policyGuardrails.d.ts.map +1 -1
  112. package/dist/policyGuardrails.js +59 -6
  113. package/dist/policyGuardrails.js.map +1 -1
  114. package/dist/posturePresets.js +1 -1
  115. package/dist/posturePresets.js.map +1 -1
  116. package/dist/providerVerification.d.ts +2 -2
  117. package/dist/providerVerification.js +2 -2
  118. package/dist/providers.d.ts +4 -4
  119. package/dist/providers.d.ts.map +1 -1
  120. package/dist/providers.js +11 -6
  121. package/dist/providers.js.map +1 -1
  122. package/dist/regoBuiltins.d.ts +42 -0
  123. package/dist/regoBuiltins.d.ts.map +1 -0
  124. package/dist/regoBuiltins.js +732 -0
  125. package/dist/regoBuiltins.js.map +1 -0
  126. package/dist/regoRules.d.ts +105 -0
  127. package/dist/regoRules.d.ts.map +1 -0
  128. package/dist/regoRules.js +407 -0
  129. package/dist/regoRules.js.map +1 -0
  130. package/dist/ruleLoadFailures.d.ts +15 -0
  131. package/dist/ruleLoadFailures.d.ts.map +1 -0
  132. package/dist/ruleLoadFailures.js +26 -0
  133. package/dist/ruleLoadFailures.js.map +1 -0
  134. package/dist/scriptScan.d.ts +5 -5
  135. package/dist/scriptScan.js +3 -3
  136. package/dist/sequence.d.ts +52 -0
  137. package/dist/sequence.d.ts.map +1 -0
  138. package/dist/sequence.js +127 -0
  139. package/dist/sequence.js.map +1 -0
  140. package/dist/session.d.ts +1 -1
  141. package/dist/session.js +1 -1
  142. package/dist/skillScan.d.ts +3 -3
  143. package/dist/skillScan.d.ts.map +1 -1
  144. package/dist/skillScan.js +26 -4
  145. package/dist/skillScan.js.map +1 -1
  146. package/dist/sop.d.ts +24 -11
  147. package/dist/sop.d.ts.map +1 -1
  148. package/dist/sop.js +10 -9
  149. package/dist/sop.js.map +1 -1
  150. package/dist/sourceProviders.d.ts +1 -8
  151. package/dist/sourceProviders.d.ts.map +1 -1
  152. package/dist/sourceProviders.js +2 -9
  153. package/dist/sourceProviders.js.map +1 -1
  154. package/dist/ssoGroupClearance.d.ts +119 -0
  155. package/dist/ssoGroupClearance.d.ts.map +1 -0
  156. package/dist/ssoGroupClearance.js +196 -0
  157. package/dist/ssoGroupClearance.js.map +1 -0
  158. package/dist/sync.d.ts +42 -14
  159. package/dist/sync.d.ts.map +1 -1
  160. package/dist/sync.js +3 -3
  161. package/dist/sync.js.map +1 -1
  162. package/dist/taskManagement.d.ts +0 -2
  163. package/dist/taskManagement.d.ts.map +1 -1
  164. package/dist/taskManagement.js +0 -2
  165. package/dist/taskManagement.js.map +1 -1
  166. package/dist/toolPoison.d.ts +33 -0
  167. package/dist/toolPoison.d.ts.map +1 -0
  168. package/dist/toolPoison.js +85 -0
  169. package/dist/toolPoison.js.map +1 -0
  170. package/dist/usage.d.ts +186 -0
  171. package/dist/usage.d.ts.map +1 -1
  172. package/dist/wasmBinary.d.ts +25 -0
  173. package/dist/wasmBinary.d.ts.map +1 -0
  174. package/dist/wasmBinary.js +111 -0
  175. package/dist/wasmBinary.js.map +1 -0
  176. package/dist/wasmFuel.d.ts +52 -0
  177. package/dist/wasmFuel.d.ts.map +1 -0
  178. package/dist/wasmFuel.js +320 -0
  179. package/dist/wasmFuel.js.map +1 -0
  180. package/dist/wasmMemoryCap.d.ts +21 -0
  181. package/dist/wasmMemoryCap.d.ts.map +1 -0
  182. package/dist/wasmMemoryCap.js +58 -0
  183. package/dist/wasmMemoryCap.js.map +1 -0
  184. package/dist/workspaceSettings.d.ts +126 -17
  185. package/dist/workspaceSettings.d.ts.map +1 -1
  186. package/dist/workspaceSettings.js +21 -2
  187. package/dist/workspaceSettings.js.map +1 -1
  188. package/package.json +2 -2
@@ -0,0 +1,33 @@
1
+ /**
2
+ * toolPoison.ts — Tool-description poisoning patterns.
3
+ *
4
+ * Direct TypeScript port of `packages/proxy/src/tool_poison.rs`'s `scan`
5
+ * function and its seven named patterns. This is a SEPARATE pattern set from
6
+ * the MCP proxy's `injection.ts`, on purpose: `tool_poison.rs`'s own module
7
+ * doc records that it tried reusing `injection::scan` for this and measured
8
+ * that its five patterns match ZERO of the tool-poisoning payloads — they are
9
+ * tuned for conversational jailbreak phrasing ("ignore previous
10
+ * instructions"), while a poisoned tool description reads like documentation,
11
+ * not a jailbreak.
12
+ *
13
+ * Two consumers, which is why it lives here: the MCP proxy's
14
+ * `tool_poisoning` detector (`packages/mcp-proxy/src/anomaly/detectors.ts`)
15
+ * and the tool-change risk score (`mcpToolRisk.ts`), which the control plane
16
+ * computes when a server's tool set changes.
17
+ *
18
+ * The Rust source gates each pattern behind a cheap substring pre-check
19
+ * (`GATES`) before running the regex. That optimization is not ported — it is
20
+ * a performance detail proven equivalent to the plain regex loop (the Rust
21
+ * module's own `gating_never_changes_a_verdict` test), and the volume of tool
22
+ * descriptions scanned here is orders of magnitude below the Rust proxy's
23
+ * request path. The pattern SOURCE TEXT below is unchanged from the Rust
24
+ * `PATTERNS` array.
25
+ *
26
+ @module
27
+ */
28
+ /**
29
+ * Pattern names matching this tool description, deduplicated, empty when it
30
+ * looks like ordinary prose (the overwhelmingly common case).
31
+ */
32
+ export declare function scanToolDescription(description: string): string[];
33
+ //# sourceMappingURL=toolPoison.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolPoison.d.ts","sourceRoot":"","sources":["../src/toolPoison.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAkDH;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAOjE"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ /**
3
+ * toolPoison.ts — Tool-description poisoning patterns.
4
+ *
5
+ * Direct TypeScript port of `packages/proxy/src/tool_poison.rs`'s `scan`
6
+ * function and its seven named patterns. This is a SEPARATE pattern set from
7
+ * the MCP proxy's `injection.ts`, on purpose: `tool_poison.rs`'s own module
8
+ * doc records that it tried reusing `injection::scan` for this and measured
9
+ * that its five patterns match ZERO of the tool-poisoning payloads — they are
10
+ * tuned for conversational jailbreak phrasing ("ignore previous
11
+ * instructions"), while a poisoned tool description reads like documentation,
12
+ * not a jailbreak.
13
+ *
14
+ * Two consumers, which is why it lives here: the MCP proxy's
15
+ * `tool_poisoning` detector (`packages/mcp-proxy/src/anomaly/detectors.ts`)
16
+ * and the tool-change risk score (`mcpToolRisk.ts`), which the control plane
17
+ * computes when a server's tool set changes.
18
+ *
19
+ * The Rust source gates each pattern behind a cheap substring pre-check
20
+ * (`GATES`) before running the regex. That optimization is not ported — it is
21
+ * a performance detail proven equivalent to the plain regex loop (the Rust
22
+ * module's own `gating_never_changes_a_verdict` test), and the volume of tool
23
+ * descriptions scanned here is orders of magnitude below the Rust proxy's
24
+ * request path. The pattern SOURCE TEXT below is unchanged from the Rust
25
+ * `PATTERNS` array.
26
+ *
27
+ @module
28
+ */
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.scanToolDescription = scanToolDescription;
31
+ /**
32
+ * Ported verbatim from `tool_poison.rs`'s `PATTERNS` const. All bounded
33
+ * repetitions here are small fixed-width gaps (`{0,40}`, `{0,60}`, `{0,80}`)
34
+ * over a handful of alternations — the same "no wide bounded repetition, no
35
+ * RegexSet performance regression" shape the MCP proxy's `injection.ts` documents, not the
36
+ * `dlp.rs` shape that regressed.
37
+ */
38
+ const PATTERNS = [
39
+ {
40
+ name: 'hidden-instruction-block',
41
+ regex: /<\s*(important|secret|system|hidden|instructions?)\s*>/i,
42
+ },
43
+ {
44
+ name: 'conceal-from-user',
45
+ regex: /\bdo\s+not\s+(mention|tell|inform|reveal|disclose|show)\b[^.!?]{0,40}\buser\b|\bwithout\s+(informing|telling|notifying|alerting)\s+the\s+user\b/i,
46
+ },
47
+ {
48
+ name: 'sidechannel-exfil',
49
+ regex: /\b(pass|send|include|append|forward|provide)\b[^.!?]{0,60}\b(content|value|text)s?\s+of\b[^.!?]{0,40}(~\/|\.env|\.ssh|id_rsa|credential|secret|token|api[_ ]?key)/i,
50
+ },
51
+ {
52
+ name: 'read-sensitive-path',
53
+ // Rust's own comment: no `\b` before the alternation, because a word
54
+ // boundary cannot exist before a literal `.` — `\b\.env` matches
55
+ // nothing. Preserved exactly, including that absence.
56
+ regex: /\b(read|open|cat|load|access)\b[^.!?]{0,30}(~\/\.\w+|\.ssh\/|id_rsa|\.env\b|\.aws\/|mcp\.json|\/etc\/passwd)/i,
57
+ },
58
+ {
59
+ name: 'cross-tool-shadowing',
60
+ regex: /\buse\s+this\s+tool\s+instead\s+of\b|\bdo\s+not\s+use\s+the\s+\w+\s+tool\b|\bthis\s+tool\s+supersedes\b/i,
61
+ },
62
+ {
63
+ name: 'agent-directed-precondition',
64
+ regex: /\bbefore\s+(using|calling|invoking)\s+(this|the)\s+tool\b[^.!?]{0,80}\b(you\s+must|first\s+read|first\s+call)\b/i,
65
+ },
66
+ {
67
+ name: 'tool-scoped-instruction-override',
68
+ regex: /\b(ignore|disregard|override)\b[^.!?]{0,40}\b(other\s+tools?|previous\s+tools?|system\s+prompt)\b/i,
69
+ },
70
+ ];
71
+ /**
72
+ * Pattern names matching this tool description, deduplicated, empty when it
73
+ * looks like ordinary prose (the overwhelmingly common case).
74
+ */
75
+ function scanToolDescription(description) {
76
+ if (!description)
77
+ return [];
78
+ const found = [];
79
+ for (const { name, regex } of PATTERNS) {
80
+ if (regex.test(description))
81
+ found.push(name);
82
+ }
83
+ return found;
84
+ }
85
+ //# sourceMappingURL=toolPoison.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolPoison.js","sourceRoot":"","sources":["../src/toolPoison.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;AAsDH,kDAOC;AAtDD;;;;;;GAMG;AACH,MAAM,QAAQ,GAAiC;IAC7C;QACE,IAAI,EAAE,0BAA0B;QAChC,KAAK,EAAE,yDAAyD;KACjE;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,KAAK,EACH,kJAAkJ;KACrJ;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,KAAK,EACH,oKAAoK;KACvK;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,qEAAqE;QACrE,iEAAiE;QACjE,sDAAsD;QACtD,KAAK,EAAE,+GAA+G;KACvH;IACD;QACE,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,0GAA0G;KAClH;IACD;QACE,IAAI,EAAE,6BAA6B;QACnC,KAAK,EAAE,kHAAkH;KAC1H;IACD;QACE,IAAI,EAAE,kCAAkC;QACxC,KAAK,EAAE,oGAAoG;KAC5G;CACF,CAAA;AAED;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,WAAmB;IACrD,IAAI,CAAC,WAAW;QAAE,OAAO,EAAE,CAAA;IAC3B,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,QAAQ,EAAE,CAAC;QACvC,IAAI,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC/C,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
package/dist/usage.d.ts CHANGED
@@ -54,4 +54,190 @@ export interface VirtualKeyBreakdown {
54
54
  totalOutputTokens: number;
55
55
  traceCount: number;
56
56
  }
57
+ /**
58
+ * One developer's usage for a period (`GET /api/v1/usage/members`).
59
+ *
60
+ * A call is attributed to the workspace member who owns the virtual key that
61
+ * authenticated it. `memberId: null` is the unattributed bucket: calls with no
62
+ * virtual-key auth context, and calls whose key prefix no single member owns.
63
+ */
64
+ export interface MemberUsage {
65
+ memberId: string | null;
66
+ /** Null for the unattributed bucket, and for a member since removed. */
67
+ displayName: string | null;
68
+ email: string | null;
69
+ totalCostUsd: number;
70
+ totalRawCostUsd: number;
71
+ totalInputTokens: number;
72
+ totalOutputTokens: number;
73
+ traceCount: number;
74
+ /** Distinct requested models, sorted. */
75
+ models: string[];
76
+ /** Distinct UTC calendar days with at least one call. */
77
+ activeDays: number;
78
+ }
79
+ /**
80
+ * `GET /api/v1/usage/members`. `scope: 'self'` when the caller may only see
81
+ * their own row (DEVELOPER and VIEWER); `'workspace'` for OWNER, ADMIN and EM.
82
+ */
83
+ export interface MemberUsageResponse {
84
+ scope: 'workspace' | 'self';
85
+ members: MemberUsage[];
86
+ }
87
+ /**
88
+ * One SCIM group's usage for a period (`GET /api/v1/usage/teams`): the sum over
89
+ * every member in the group, directly or through nested groups. A member in
90
+ * several groups counts in each, so team totals can add up to more than the
91
+ * workspace total.
92
+ */
93
+ export interface TeamUsage {
94
+ groupId: string;
95
+ displayName: string;
96
+ /** Members in the group, transitively. */
97
+ memberCount: number;
98
+ /** Members of the group with at least one attributed call in the period. */
99
+ activeMembers: number;
100
+ totalCostUsd: number;
101
+ totalRawCostUsd: number;
102
+ totalInputTokens: number;
103
+ totalOutputTokens: number;
104
+ traceCount: number;
105
+ }
106
+ /**
107
+ * `GET /api/v1/usage/teams`. `scimGroups: false` means the workspace has no
108
+ * SCIM groups, so there are no teams to roll up to; per-member usage is the
109
+ * finest grouping available.
110
+ */
111
+ export interface TeamUsageResponse {
112
+ scimGroups: boolean;
113
+ teams: TeamUsage[];
114
+ }
115
+ /**
116
+ * Usage per repository and branch (`GET /api/v1/usage/branches`), from the git
117
+ * context copied onto each trace when it was recorded. `repo` and `branch` are
118
+ * both null on the row for calls made with no git context.
119
+ */
120
+ export interface BranchUsage {
121
+ /** Normalised `origin` remote, host/path. Null when the directory had no `origin`. */
122
+ repo: string | null;
123
+ branch: string | null;
124
+ /** Distinct HEAD commits the calls were made at. */
125
+ commitCount: number;
126
+ totalCostUsd: number;
127
+ totalRawCostUsd: number;
128
+ totalInputTokens: number;
129
+ totalOutputTokens: number;
130
+ traceCount: number;
131
+ /** Latest call, ISO 8601. */
132
+ lastCallAt: string;
133
+ }
134
+ /**
135
+ * Usage per HEAD commit (`GET /api/v1/usage/commits`): the calls made while
136
+ * that commit was checked out, which is the work that led to the next commit,
137
+ * not the work that produced this one.
138
+ */
139
+ export interface CommitUsage {
140
+ repo: string | null;
141
+ branch: string | null;
142
+ commit: string | null;
143
+ totalCostUsd: number;
144
+ totalRawCostUsd: number;
145
+ totalInputTokens: number;
146
+ totalOutputTokens: number;
147
+ traceCount: number;
148
+ /** First and latest call at this commit, ISO 8601. */
149
+ firstCallAt: string;
150
+ lastCallAt: string;
151
+ }
152
+ /** `scope` as on {@link MemberUsageResponse}: `'self'` counts only the caller's own calls. */
153
+ export interface BranchUsageResponse {
154
+ scope: 'workspace' | 'self';
155
+ branches: BranchUsage[];
156
+ }
157
+ export interface CommitUsageResponse {
158
+ scope: 'workspace' | 'self';
159
+ commits: CommitUsage[];
160
+ }
161
+ export type PullRequestState = 'open' | 'closed' | 'merged';
162
+ /**
163
+ * One pull request's usage for a period (`GET /api/v1/usage/pull-requests`):
164
+ * the calls made on its head branch, in its repository, between the end of
165
+ * the previous pull request from that branch (or the branch's first call) and
166
+ * this one's merge or close. A call belongs to one pull request at most.
167
+ */
168
+ export interface PullRequestUsage {
169
+ /** Normalised host/owner/name, lower-cased. */
170
+ repo: string;
171
+ number: number;
172
+ title: string;
173
+ /** GitHub login of whoever opened it. */
174
+ author: string | null;
175
+ state: PullRequestState;
176
+ headBranch: string;
177
+ baseBranch: string | null;
178
+ /** The pull request on GitHub. */
179
+ url: string;
180
+ /** ISO 8601. */
181
+ openedAt: string;
182
+ mergedAt: string | null;
183
+ closedAt: string | null;
184
+ totalCostUsd: number;
185
+ totalRawCostUsd: number;
186
+ totalInputTokens: number;
187
+ totalOutputTokens: number;
188
+ traceCount: number;
189
+ /** Members with an attributed call on it in the period. */
190
+ memberCount: number;
191
+ /** First and latest call in the period, ISO 8601. */
192
+ firstCallAt: string;
193
+ lastCallAt: string;
194
+ }
195
+ /** Where pull requests come from, and whether that is working, for the empty states. */
196
+ export interface PullRequestSources {
197
+ /** The workspace has a GitHub source connector whose token lists pull requests. */
198
+ connector: boolean;
199
+ /** The pull-request webhook is set up. */
200
+ webhook: boolean;
201
+ /** The GitHub host the connector's token is used against, e.g. `github.com`. */
202
+ apiHost: string;
203
+ /** Repositories whose pull requests the connector's token was refused (missing scope or access). */
204
+ noAccessRepos: string[];
205
+ /** Pull requests mapped in the workspace, any period. */
206
+ mappedPullRequests: number;
207
+ /** Last time a branch was looked up through the connector, ISO 8601. */
208
+ lastCheckedAt: string | null;
209
+ }
210
+ /** `scope` as on {@link MemberUsageResponse}: `'self'` counts only the caller's own calls. */
211
+ export interface PullRequestUsageResponse {
212
+ scope: 'workspace' | 'self';
213
+ github: PullRequestSources;
214
+ pullRequests: PullRequestUsage[];
215
+ }
216
+ /** `POST /api/v1/usage/pull-requests/refresh`. */
217
+ export interface PullRequestRefreshResult {
218
+ /** Branches looked up. */
219
+ checked: number;
220
+ /** Answered 304: the ETag matched and nothing changed. */
221
+ notModified: number;
222
+ /** Pull requests written or updated. */
223
+ pullRequests: number;
224
+ /** Branches the token could not list. */
225
+ noAccess: number;
226
+ /** True when GitHub's rate limit stopped the run early. */
227
+ rateLimited: boolean;
228
+ }
229
+ /** `GET /api/v1/integrations/github/webhook`. The secret is never returned here. */
230
+ export interface GitHubWebhookInfo {
231
+ configured: boolean;
232
+ /** Payload URL to paste into GitHub. Null until a secret has been made. */
233
+ url: string | null;
234
+ createdAt: string | null;
235
+ secretRotatedAt: string | null;
236
+ lastDeliveryAt: string | null;
237
+ }
238
+ /** `POST /api/v1/integrations/github/webhook/secret`: the new secret, shown once. */
239
+ export interface GitHubWebhookSecret {
240
+ url: string;
241
+ secret: string;
242
+ }
57
243
  //# sourceMappingURL=usage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAA;IACtC,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,eAAe,EAAE,MAAM,CAAA;IACvB,gBAAgB,EAAE,MAAM,CAAA;IACxB,iBAAiB,EAAE,MAAM,CAAA;IACzB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,aAAa,EAAE,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAAA;CAC1C;AAED,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,MAAM,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wBAAwB;IACvC,KAAK,EAAE,WAAW,GAAG,MAAM,CAAA;IAC3B,MAAM,EAAE,kBAAkB,CAAA;IAC1B,YAAY,EAAE,gBAAgB,EAAE,CAAA;CACjC;AAED,kDAAkD;AAClD,MAAM,WAAW,wBAAwB;IACvC,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,0DAA0D;IAC1D,WAAW,EAAE,MAAM,CAAA;IACnB,wCAAwC;IACxC,YAAY,EAAE,MAAM,CAAA;IACpB,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAA;IAChB,2DAA2D;IAC3D,WAAW,EAAE,OAAO,CAAA;CACrB;AAED,oFAAoF;AACpF,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,OAAO,CAAA;IACnB,2EAA2E;IAC3E,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAClB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B;AAED,qFAAqF;AACrF,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;CACf"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The few pieces of the WebAssembly binary format the load-time rewrites
3
+ * (`wasmMemoryCap.ts`, `wasmFuel.ts`) share: LEB128 integers, the section list, and
4
+ * reassembly. Not a general decoder; each rewrite parses only what it changes.
5
+ */
6
+ export interface Section {
7
+ id: number;
8
+ payload: Uint8Array<ArrayBuffer>;
9
+ }
10
+ export declare function malformed(what: string): Error;
11
+ export declare function readU32(bytes: Uint8Array, at: number): {
12
+ value: number;
13
+ next: number;
14
+ };
15
+ /** Skip any LEB128 integer, signed or unsigned, up to 64 bits. */
16
+ export declare function skipLeb(bytes: Uint8Array, at: number): number;
17
+ export declare function writeU32(value: number): number[];
18
+ /** Signed LEB128, for `i32.const` immediates. */
19
+ export declare function writeS32(value: number): number[];
20
+ export declare function readSections(bytes: Uint8Array<ArrayBuffer>): Section[];
21
+ /** Replace the section with `id`, or insert it where the spec's order puts it. */
22
+ export declare function putSection(sections: Section[], id: number, payload: Uint8Array<ArrayBuffer>): void;
23
+ export declare function assembleModule(header: Uint8Array, sections: Section[]): Uint8Array<ArrayBuffer>;
24
+ export declare function concat(parts: Uint8Array[]): Uint8Array<ArrayBuffer>;
25
+ //# sourceMappingURL=wasmBinary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasmBinary.d.ts","sourceRoot":"","sources":["../src/wasmBinary.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,CAAA;CACjC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAE7C;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAUtF;AAED,kEAAkE;AAClE,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAK7D;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAShD;AAED,iDAAiD;AACjD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAShD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,EAAE,CAYtE;AAKD,kFAAkF;AAClF,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAYlG;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAM/F;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAQnE"}
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ /**
3
+ * The few pieces of the WebAssembly binary format the load-time rewrites
4
+ * (`wasmMemoryCap.ts`, `wasmFuel.ts`) share: LEB128 integers, the section list, and
5
+ * reassembly. Not a general decoder; each rewrite parses only what it changes.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.malformed = malformed;
9
+ exports.readU32 = readU32;
10
+ exports.skipLeb = skipLeb;
11
+ exports.writeU32 = writeU32;
12
+ exports.writeS32 = writeS32;
13
+ exports.readSections = readSections;
14
+ exports.putSection = putSection;
15
+ exports.assembleModule = assembleModule;
16
+ exports.concat = concat;
17
+ const HEADER_BYTES = 8; // `\0asm` + version
18
+ function malformed(what) {
19
+ return new Error(`malformed WASM module: ${what}`);
20
+ }
21
+ function readU32(bytes, at) {
22
+ let value = 0;
23
+ let shift = 0;
24
+ for (let i = at; i < bytes.length && i < at + 5; i++) {
25
+ const byte = bytes[i];
26
+ value += (byte & 0x7f) * 2 ** shift;
27
+ if ((byte & 0x80) === 0)
28
+ return { value, next: i + 1 };
29
+ shift += 7;
30
+ }
31
+ throw malformed('truncated or oversized LEB128 integer');
32
+ }
33
+ /** Skip any LEB128 integer, signed or unsigned, up to 64 bits. */
34
+ function skipLeb(bytes, at) {
35
+ for (let i = at; i < bytes.length && i < at + 10; i++) {
36
+ if ((bytes[i] & 0x80) === 0)
37
+ return i + 1;
38
+ }
39
+ throw malformed('truncated or oversized LEB128 integer');
40
+ }
41
+ function writeU32(value) {
42
+ const out = [];
43
+ do {
44
+ let byte = value & 0x7f;
45
+ value = Math.floor(value / 128);
46
+ if (value !== 0)
47
+ byte |= 0x80;
48
+ out.push(byte);
49
+ } while (value !== 0);
50
+ return out;
51
+ }
52
+ /** Signed LEB128, for `i32.const` immediates. */
53
+ function writeS32(value) {
54
+ const out = [];
55
+ for (;;) {
56
+ const byte = value & 0x7f;
57
+ value >>= 7;
58
+ const done = (value === 0 && (byte & 0x40) === 0) || (value === -1 && (byte & 0x40) !== 0);
59
+ out.push(done ? byte : byte | 0x80);
60
+ if (done)
61
+ return out;
62
+ }
63
+ }
64
+ function readSections(bytes) {
65
+ const sections = [];
66
+ let at = HEADER_BYTES;
67
+ while (at < bytes.length) {
68
+ const id = bytes[at];
69
+ const size = readU32(bytes, at + 1);
70
+ const end = size.next + size.value;
71
+ if (end > bytes.length)
72
+ throw malformed('section runs past the end');
73
+ sections.push({ id, payload: bytes.subarray(size.next, end) });
74
+ at = end;
75
+ }
76
+ return sections;
77
+ }
78
+ /** Section order the spec requires; custom sections (id 0) may sit anywhere. */
79
+ const SECTION_RANK = { 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 13: 6, 6: 7, 7: 8, 8: 9, 9: 10, 12: 11, 10: 12, 11: 13 };
80
+ /** Replace the section with `id`, or insert it where the spec's order puts it. */
81
+ function putSection(sections, id, payload) {
82
+ const existing = sections.findIndex((s) => s.id === id);
83
+ if (existing >= 0) {
84
+ sections[existing] = { id, payload };
85
+ return;
86
+ }
87
+ const rank = SECTION_RANK[id];
88
+ let insertAt = 0;
89
+ sections.forEach((s, i) => {
90
+ if (s.id !== 0 && SECTION_RANK[s.id] < rank)
91
+ insertAt = i + 1;
92
+ });
93
+ sections.splice(insertAt, 0, { id, payload });
94
+ }
95
+ function assembleModule(header, sections) {
96
+ const parts = [header.subarray(0, HEADER_BYTES)];
97
+ for (const s of sections) {
98
+ parts.push(Uint8Array.from([s.id, ...writeU32(s.payload.length)]), s.payload);
99
+ }
100
+ return concat(parts);
101
+ }
102
+ function concat(parts) {
103
+ const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));
104
+ let at = 0;
105
+ for (const p of parts) {
106
+ out.set(p, at);
107
+ at += p.length;
108
+ }
109
+ return out;
110
+ }
111
+ //# sourceMappingURL=wasmBinary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasmBinary.js","sourceRoot":"","sources":["../src/wasmBinary.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AASH,8BAEC;AAED,0BAUC;AAGD,0BAKC;AAED,4BASC;AAGD,4BASC;AAED,oCAYC;AAMD,gCAYC;AAED,wCAMC;AAED,wBAQC;AAtGD,MAAM,YAAY,GAAG,CAAC,CAAA,CAAC,oBAAoB;AAO3C,SAAgB,SAAS,CAAC,IAAY;IACpC,OAAO,IAAI,KAAK,CAAC,0BAA0B,IAAI,EAAE,CAAC,CAAA;AACpD,CAAC;AAED,SAAgB,OAAO,CAAC,KAAiB,EAAE,EAAU;IACnD,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,KAAK,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACrD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAE,CAAA;QACtB,KAAK,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,CAAA;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;YAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAA;QACtD,KAAK,IAAI,CAAC,CAAA;IACZ,CAAC;IACD,MAAM,SAAS,CAAC,uCAAuC,CAAC,CAAA;AAC1D,CAAC;AAED,kEAAkE;AAClE,SAAgB,OAAO,CAAC,KAAiB,EAAE,EAAU;IACnD,KAAK,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,E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GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QACd,EAAE,IAAI,CAAC,CAAC,MAAM,CAAA;IAChB,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Instruction budget for WASM rules: the stand-in for Wasmtime fuel, which
3
+ * the Rust proxy sets to 1,000,000 per evaluation (`limits.rs`), wherever a
4
+ * rule runs on V8 — the MCP proxy, and `intutic rules test`, `policy test`
5
+ * and `policy install`, so a rule that runs out in a proxy runs out there.
6
+ *
7
+ * V8 has no metering hook, so the rule's own code is rewritten at load to
8
+ * count. A new mutable i32 global starts at the budget, and a charge is
9
+ * inserted at every function entry and every loop header: subtract the number
10
+ * of instructions that can run before the next charge point, and trap
11
+ * (`unreachable`) once the counter goes negative. Code between two charge
12
+ * points is straight-line apart from forward branches, so each charge is an
13
+ * upper bound on what it pays for, and the budget bounds the instructions the
14
+ * rule actually executes. Structural instructions (`block`, `loop`, `end`,
15
+ * `else`, `nop`, `drop`, `return`, `unreachable`) cost nothing, roughly as
16
+ * Wasmtime prices them.
17
+ *
18
+ * The global is exported as `FUEL_EXPORT` so the worker can tell a trap caused
19
+ * by the budget from any other trap. Each evaluation instantiates the module
20
+ * afresh, so the budget is per evaluation, like a Wasmtime `Store`.
21
+ *
22
+ * The decoder knows the MVP instruction set plus the extensions compilers
23
+ * emit by default (sign extension, saturating truncation, bulk memory,
24
+ * reference types, multi-value, tail calls, SIMD). A module using anything
25
+ * else (exceptions, GC, threads) is refused at load rather than run unmetered.
26
+ */
27
+ /** `runner.rs`: `store.set_fuel(1_000_000)`. */
28
+ export declare const DEFAULT_FUEL_BUDGET = 1000000;
29
+ /**
30
+ * A Rego rule's budget: three times the Rust proxy's 100,000,000
31
+ * (`limits::REGO`), because this meter counts differently.
32
+ *
33
+ * It charges each straight-line run in full at its entry, branches skipped or
34
+ * not, and an OPA build is mostly short runs with early exits: on the largest
35
+ * input (a 64 KB command) the destructive-shell and production-deploy examples
36
+ * count 74,000,000 here against 21,000,000 under Wasmtime, and the
37
+ * deny-writes and conformance policies about 8,000,000. The budget is four
38
+ * times the largest, so a heavier policy on the largest input still fits, and
39
+ * a rule that does not fit is stopped deterministically, whatever the load.
40
+ * Using it all up takes at most 350 ms idle and 4.4 s on a loaded machine;
41
+ * the deadline (`REGO_EVALUATE_TIMEOUT_MS`) is set above that.
42
+ */
43
+ export declare const REGO_FUEL_BUDGET = 300000000;
44
+ /** The export the worker reads to tell budget exhaustion from other traps. */
45
+ export declare const FUEL_EXPORT = "__intutic_fuel";
46
+ /**
47
+ * The module with every function metered against `budget` instructions per
48
+ * instantiation, and the counter exported as `FUEL_EXPORT`. Throws for a
49
+ * module the decoder cannot meter.
50
+ */
51
+ export declare function meterFuel(bytes: Uint8Array<ArrayBuffer>, budget: number): Uint8Array<ArrayBuffer>;
52
+ //# sourceMappingURL=wasmFuel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasmFuel.d.ts","sourceRoot":"","sources":["../src/wasmFuel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAeH,gDAAgD;AAChD,eAAO,MAAM,mBAAmB,UAAY,CAAA;AAE5C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,YAAc,CAAA;AAE3C,8EAA8E;AAC9E,eAAO,MAAM,WAAW,mBAAmB,CAAA;AAoM3C;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CA+BjG"}