@yiaany/ghostapi 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (323) hide show
  1. package/CHANGELOG.md +48 -2
  2. package/CONTRIBUTING.md +119 -117
  3. package/LICENSE +21 -21
  4. package/README.md +208 -185
  5. package/SECURITY.md +53 -37
  6. package/dist/actions/gateway.d.ts +179 -0
  7. package/dist/actions/gateway.js +514 -0
  8. package/dist/actions/gateway.js.map +1 -0
  9. package/dist/actions/index.d.ts +2 -0
  10. package/dist/actions/index.js +2 -0
  11. package/dist/actions/index.js.map +1 -0
  12. package/dist/ai/aiClient.js +4 -4
  13. package/dist/ai/aiClient.js.map +1 -1
  14. package/dist/ai/aiGenerator.d.ts +2 -2
  15. package/dist/ai/aiGenerator.js +21 -72
  16. package/dist/ai/aiGenerator.js.map +1 -1
  17. package/dist/ai/prompts.js +51 -51
  18. package/dist/ai/prompts.js.map +1 -1
  19. package/dist/approvals/approvalInbox.d.ts +150 -0
  20. package/dist/approvals/approvalInbox.js +412 -0
  21. package/dist/approvals/approvalInbox.js.map +1 -0
  22. package/dist/approvals/index.d.ts +2 -0
  23. package/dist/approvals/index.js +2 -0
  24. package/dist/approvals/index.js.map +1 -0
  25. package/dist/behavior/behaviorStore.d.ts +2 -0
  26. package/dist/behavior/behaviorStore.js +50 -46
  27. package/dist/behavior/behaviorStore.js.map +1 -1
  28. package/dist/cache/index.d.ts +2 -0
  29. package/dist/cache/index.js +58 -14
  30. package/dist/cache/index.js.map +1 -1
  31. package/dist/cli/index.js +438 -58
  32. package/dist/cli/index.js.map +1 -1
  33. package/dist/cli/openUrl.d.ts +10 -0
  34. package/dist/cli/openUrl.js +31 -0
  35. package/dist/cli/openUrl.js.map +1 -0
  36. package/dist/cli/parser.d.ts +155 -0
  37. package/dist/cli/parser.js +504 -2
  38. package/dist/cli/parser.js.map +1 -1
  39. package/dist/config/dataPaths.d.ts +31 -0
  40. package/dist/config/dataPaths.js +45 -0
  41. package/dist/config/dataPaths.js.map +1 -0
  42. package/dist/config/localConfig.d.ts +1 -2
  43. package/dist/config/localConfig.js +27 -21
  44. package/dist/config/localConfig.js.map +1 -1
  45. package/dist/config/serverConfig.d.ts +2 -0
  46. package/dist/config/serverConfig.js +8 -1
  47. package/dist/config/serverConfig.js.map +1 -1
  48. package/dist/contracts/contract.d.ts +76 -0
  49. package/dist/contracts/contract.js +603 -0
  50. package/dist/contracts/contract.js.map +1 -0
  51. package/dist/contracts/index.d.ts +2 -0
  52. package/dist/contracts/index.js +2 -0
  53. package/dist/contracts/index.js.map +1 -0
  54. package/dist/credentials/credentialBroker.d.ts +207 -0
  55. package/dist/credentials/credentialBroker.js +588 -0
  56. package/dist/credentials/credentialBroker.js.map +1 -0
  57. package/dist/credentials/index.d.ts +2 -0
  58. package/dist/credentials/index.js +2 -0
  59. package/dist/credentials/index.js.map +1 -0
  60. package/dist/dashboard/app.js +685 -615
  61. package/dist/dashboard/index.html +13 -7
  62. package/dist/dashboard/styles.css +349 -349
  63. package/dist/egress/capabilities.d.ts +32 -0
  64. package/dist/egress/capabilities.js +165 -0
  65. package/dist/egress/capabilities.js.map +1 -0
  66. package/dist/egress/linuxBootstrap.d.ts +1 -0
  67. package/dist/egress/linuxBootstrap.js +121 -0
  68. package/dist/egress/linuxBootstrap.js.map +1 -0
  69. package/dist/egress/run.d.ts +18 -0
  70. package/dist/egress/run.js +305 -0
  71. package/dist/egress/run.js.map +1 -0
  72. package/dist/errors/errorEngine.d.ts +2 -2
  73. package/dist/errors/errorEngine.js +3 -40
  74. package/dist/errors/errorEngine.js.map +1 -1
  75. package/dist/evals/evals.d.ts +126 -0
  76. package/dist/evals/evals.js +466 -0
  77. package/dist/evals/evals.js.map +1 -0
  78. package/dist/evals/index.d.ts +2 -0
  79. package/dist/evals/index.js +2 -0
  80. package/dist/evals/index.js.map +1 -0
  81. package/dist/evidence/index.d.ts +2 -0
  82. package/dist/evidence/index.js +2 -0
  83. package/dist/evidence/index.js.map +1 -0
  84. package/dist/evidence/report.d.ts +143 -0
  85. package/dist/evidence/report.js +556 -0
  86. package/dist/evidence/report.js.map +1 -0
  87. package/dist/fault/faultLab.d.ts +5 -4
  88. package/dist/fault/faultLab.js +66 -24
  89. package/dist/fault/faultLab.js.map +1 -1
  90. package/dist/index.d.ts +46 -0
  91. package/dist/index.js +23 -0
  92. package/dist/index.js.map +1 -1
  93. package/dist/inventory/analysis.d.ts +12 -0
  94. package/dist/inventory/analysis.js +457 -0
  95. package/dist/inventory/analysis.js.map +1 -0
  96. package/dist/inventory/index.d.ts +5 -0
  97. package/dist/inventory/index.js +4 -0
  98. package/dist/inventory/index.js.map +1 -0
  99. package/dist/inventory/inventoryController.d.ts +53 -0
  100. package/dist/inventory/inventoryController.js +1044 -0
  101. package/dist/inventory/inventoryController.js.map +1 -0
  102. package/dist/inventory/types.d.ts +579 -0
  103. package/dist/inventory/types.js +787 -0
  104. package/dist/inventory/types.js.map +1 -0
  105. package/dist/landing/assets/index-CxWsopzP.css +1 -0
  106. package/dist/landing/assets/index-DZlpyhqd.js +55 -0
  107. package/dist/landing/assets/index-Dk-Xezs3.js +55 -0
  108. package/dist/landing/index.html +15 -15
  109. package/dist/ledger/actionLedger.d.ts +125 -0
  110. package/dist/ledger/actionLedger.js +594 -0
  111. package/dist/ledger/actionLedger.js.map +1 -0
  112. package/dist/ledger/index.d.ts +2 -0
  113. package/dist/ledger/index.js +2 -0
  114. package/dist/ledger/index.js.map +1 -0
  115. package/dist/mcp/server.js +4 -3
  116. package/dist/mcp/server.js.map +1 -1
  117. package/dist/policy/index.d.ts +3 -0
  118. package/dist/policy/index.js +2 -0
  119. package/dist/policy/index.js.map +1 -0
  120. package/dist/policy/policy.d.ts +14 -0
  121. package/dist/policy/policy.js +282 -0
  122. package/dist/policy/policy.js.map +1 -0
  123. package/dist/policy/types.d.ts +52 -0
  124. package/dist/policy/types.js +2 -0
  125. package/dist/policy/types.js.map +1 -0
  126. package/dist/productTelemetry/index.d.ts +16 -0
  127. package/dist/productTelemetry/index.js +142 -0
  128. package/dist/productTelemetry/index.js.map +1 -0
  129. package/dist/providers/conformance.d.ts +7 -0
  130. package/dist/providers/conformance.js +48 -0
  131. package/dist/providers/conformance.js.map +1 -0
  132. package/dist/providers/index.d.ts +4 -2
  133. package/dist/providers/index.js +3 -1
  134. package/dist/providers/index.js.map +1 -1
  135. package/dist/providers/packs/resendPack.d.ts +2 -0
  136. package/dist/providers/packs/resendPack.js +147 -0
  137. package/dist/providers/packs/resendPack.js.map +1 -0
  138. package/dist/providers/packs/stripePack.d.ts +2 -0
  139. package/dist/providers/packs/stripePack.js +852 -0
  140. package/dist/providers/packs/stripePack.js.map +1 -0
  141. package/dist/providers/registry.d.ts +7 -3
  142. package/dist/providers/registry.js +55 -4
  143. package/dist/providers/registry.js.map +1 -1
  144. package/dist/providers/resend.js +2 -11
  145. package/dist/providers/resend.js.map +1 -1
  146. package/dist/providers/runtime.d.ts +8 -0
  147. package/dist/providers/runtime.js +48 -0
  148. package/dist/providers/runtime.js.map +1 -0
  149. package/dist/providers/stripeWebhook.d.ts +13 -0
  150. package/dist/providers/stripeWebhook.js +50 -0
  151. package/dist/providers/stripeWebhook.js.map +1 -0
  152. package/dist/providers/types.d.ts +153 -0
  153. package/dist/proxy/cacheKey.js +3 -3
  154. package/dist/proxy/cacheKey.js.map +1 -1
  155. package/dist/proxy/providerDetector.d.ts +2 -7
  156. package/dist/proxy/providerDetector.js +4 -4
  157. package/dist/proxy/providerDetector.js.map +1 -1
  158. package/dist/proxy/proxyHandler.js +116 -12
  159. package/dist/proxy/proxyHandler.js.map +1 -1
  160. package/dist/proxy/requestNormalizer.d.ts +0 -1
  161. package/dist/proxy/requestNormalizer.js +2 -5
  162. package/dist/proxy/requestNormalizer.js.map +1 -1
  163. package/dist/reliability/costGovernance.d.ts +175 -0
  164. package/dist/reliability/costGovernance.js +515 -0
  165. package/dist/reliability/costGovernance.js.map +1 -0
  166. package/dist/reliability/index.d.ts +8 -0
  167. package/dist/reliability/index.js +5 -0
  168. package/dist/reliability/index.js.map +1 -0
  169. package/dist/reliability/reconciliation.d.ts +157 -0
  170. package/dist/reliability/reconciliation.js +522 -0
  171. package/dist/reliability/reconciliation.js.map +1 -0
  172. package/dist/reliability/runtimeHealth.d.ts +60 -0
  173. package/dist/reliability/runtimeHealth.js +356 -0
  174. package/dist/reliability/runtimeHealth.js.map +1 -0
  175. package/dist/reliability/slo.d.ts +131 -0
  176. package/dist/reliability/slo.js +375 -0
  177. package/dist/reliability/slo.js.map +1 -0
  178. package/dist/report/safetyReport.js +7 -3
  179. package/dist/report/safetyReport.js.map +1 -1
  180. package/dist/safety/index.d.ts +2 -0
  181. package/dist/safety/index.js +2 -0
  182. package/dist/safety/index.js.map +1 -0
  183. package/dist/safety/safetyController.d.ts +187 -0
  184. package/dist/safety/safetyController.js +477 -0
  185. package/dist/safety/safetyController.js.map +1 -0
  186. package/dist/scenarios/scenarioBundle.d.ts +75 -0
  187. package/dist/scenarios/scenarioBundle.js +750 -0
  188. package/dist/scenarios/scenarioBundle.js.map +1 -0
  189. package/dist/scenarios/scenarioStore.d.ts +1 -0
  190. package/dist/scenarios/scenarioStore.js +47 -32
  191. package/dist/scenarios/scenarioStore.js.map +1 -1
  192. package/dist/security/headerSanitizer.d.ts +2 -0
  193. package/dist/security/headerSanitizer.js +36 -1
  194. package/dist/security/headerSanitizer.js.map +1 -1
  195. package/dist/security/secrets.js +24 -4
  196. package/dist/security/secrets.js.map +1 -1
  197. package/dist/server/accessControl.d.ts +5 -0
  198. package/dist/server/accessControl.js +100 -0
  199. package/dist/server/accessControl.js.map +1 -0
  200. package/dist/server/createServer.d.ts +0 -5
  201. package/dist/server/createServer.js +9 -29
  202. package/dist/server/createServer.js.map +1 -1
  203. package/dist/server/eventsStore.d.ts +6 -1
  204. package/dist/server/eventsStore.js +83 -15
  205. package/dist/server/eventsStore.js.map +1 -1
  206. package/dist/server/routes.js +36 -10
  207. package/dist/server/routes.js.map +1 -1
  208. package/dist/server/sse.d.ts +2 -1
  209. package/dist/server/sse.js +15 -3
  210. package/dist/server/sse.js.map +1 -1
  211. package/dist/setup/setupGenerator.js +53 -6
  212. package/dist/setup/setupGenerator.js.map +1 -1
  213. package/dist/state/stateStore.d.ts +5 -0
  214. package/dist/state/stateStore.js +48 -62
  215. package/dist/state/stateStore.js.map +1 -1
  216. package/dist/storage/fileStore.d.ts +10 -0
  217. package/dist/storage/fileStore.js +131 -0
  218. package/dist/storage/fileStore.js.map +1 -0
  219. package/dist/teamControl/controlPlane.d.ts +255 -0
  220. package/dist/teamControl/controlPlane.js +918 -0
  221. package/dist/teamControl/controlPlane.js.map +1 -0
  222. package/dist/teamControl/deployment.d.ts +33 -0
  223. package/dist/teamControl/deployment.js +67 -0
  224. package/dist/teamControl/deployment.js.map +1 -0
  225. package/dist/teamControl/index.d.ts +4 -0
  226. package/dist/teamControl/index.js +3 -0
  227. package/dist/teamControl/index.js.map +1 -0
  228. package/dist/tests/testGenerator.js +4 -1
  229. package/dist/tests/testGenerator.js.map +1 -1
  230. package/dist/trust/index.d.ts +2 -0
  231. package/dist/trust/index.js +2 -0
  232. package/dist/trust/index.js.map +1 -0
  233. package/dist/trust/trustLadder.d.ts +182 -0
  234. package/dist/trust/trustLadder.js +560 -0
  235. package/dist/trust/trustLadder.js.map +1 -0
  236. package/dist/worlds/index.d.ts +2 -0
  237. package/dist/worlds/index.js +2 -0
  238. package/dist/worlds/index.js.map +1 -0
  239. package/dist/worlds/worlds.d.ts +160 -0
  240. package/dist/worlds/worlds.js +491 -0
  241. package/dist/worlds/worlds.js.map +1 -0
  242. package/docs/assets/dashboard.png +0 -0
  243. package/docs/ci.md +49 -0
  244. package/docs/commercial/README.md +29 -0
  245. package/docs/commercial/data-inventory.md +36 -0
  246. package/docs/commercial/manual-invoicing.md +44 -0
  247. package/docs/commercial/metrics.md +51 -0
  248. package/docs/commercial/pricing.md +103 -0
  249. package/docs/commercial/privacy-policy-draft.md +41 -0
  250. package/docs/commercial/terms-topics-for-counsel.md +51 -0
  251. package/docs/design-partners/README.md +52 -0
  252. package/docs/design-partners/demo-narratives.md +33 -0
  253. package/docs/design-partners/design-partner-offer.md +39 -0
  254. package/docs/design-partners/discovery-questions.md +28 -0
  255. package/docs/design-partners/feedback-capture-template.md +48 -0
  256. package/docs/design-partners/icp-one-pager.md +43 -0
  257. package/docs/design-partners/onboarding-checklist.md +33 -0
  258. package/docs/design-partners/pilot-success-criteria.md +27 -0
  259. package/docs/design-partners/pricing-interview-script.md +18 -0
  260. package/docs/design-partners/telemetry-plan.md +48 -0
  261. package/docs/development/baseline.md +114 -0
  262. package/docs/development/onboarding-smoke.md +37 -0
  263. package/docs/development/verification-0.1.8.md +25 -0
  264. package/docs/enterprise-product-roadmap-ru.md +1879 -0
  265. package/docs/fundraising/README.md +87 -0
  266. package/docs/fundraising/data-room-checklist.md +72 -0
  267. package/docs/fundraising/demo-script.md +52 -0
  268. package/docs/fundraising/design-partners-50.md +74 -0
  269. package/docs/fundraising/launch-posts.md +37 -0
  270. package/docs/fundraising/metrics-and-evidence.md +30 -0
  271. package/docs/fundraising/roadmap-12-month.md +25 -0
  272. package/docs/fundraising/technical-due-diligence-index.md +37 -0
  273. package/docs/fundraising/yc-application.md +25 -0
  274. package/docs/github-actions.md +84 -0
  275. package/docs/hosted-pilot.md +111 -0
  276. package/docs/mcp.md +52 -50
  277. package/docs/operations/disaster-recovery-runbook.md +81 -0
  278. package/docs/operations/kill-switch-runbook.md +32 -0
  279. package/docs/policy.md +61 -0
  280. package/docs/providers/authoring-packs.md +175 -0
  281. package/docs/providers/stripe-core-pack.md +82 -0
  282. package/docs/release-checklist.md +83 -71
  283. package/docs/release-migration-and-rollback.md +63 -0
  284. package/docs/release-readiness.md +39 -0
  285. package/docs/security/action-gateway-threat-model.md +34 -0
  286. package/docs/security/action-ledger-incident-replay-threat-model.md +42 -0
  287. package/docs/security/approval-inbox-threat-model.md +35 -0
  288. package/docs/security/credential-broker-threat-model.md +52 -0
  289. package/docs/security/egress-threat-model.md +126 -0
  290. package/docs/security/inventory-threat-model.md +104 -0
  291. package/docs/security/kill-switch-budgets-threat-model.md +37 -0
  292. package/docs/security/reliability-threat-model.md +111 -0
  293. package/docs/security/trust-ladder-threat-model.md +33 -0
  294. package/docs/team-control-plane.md +72 -0
  295. package/docs/usage.md +571 -57
  296. package/examples/README.md +10 -0
  297. package/examples/agent-instructions/README.md +39 -39
  298. package/examples/ci-smoke/README.md +21 -0
  299. package/examples/ci-smoke/ghostapi.policy.yaml +22 -0
  300. package/examples/ci-smoke/package.json +9 -0
  301. package/examples/ci-smoke/production-egress.mjs +2 -0
  302. package/examples/ci-smoke/safe.mjs +17 -0
  303. package/examples/evals/README.md +24 -0
  304. package/examples/evals/retry-after.eval.json +52 -0
  305. package/examples/generic-rest/README.md +27 -27
  306. package/examples/github-fetch/README.md +35 -35
  307. package/examples/openai-streaming/README.md +16 -0
  308. package/examples/openai-streaming/streaming-tool-call.mjs +31 -0
  309. package/examples/policy/ghostapi.policy.yaml +27 -0
  310. package/examples/record-replay/README.md +19 -0
  311. package/examples/record-replay/replay-requests.json +22 -0
  312. package/examples/record-replay/stripe-checkout.har.json +30 -0
  313. package/examples/resend-node/README.md +22 -22
  314. package/examples/stripe-node/README.md +35 -29
  315. package/examples/stripe-node/checkout-flow.mjs +61 -0
  316. package/examples/twilio-node/README.md +21 -21
  317. package/examples/worlds/README.md +19 -0
  318. package/examples/worlds/subscription-recovery.mjs +12 -0
  319. package/package.json +26 -11
  320. package/dist/providers/stripe.d.ts +0 -2
  321. package/dist/providers/stripe.js +0 -15
  322. package/dist/providers/stripe.js.map +0 -1
  323. package/docs/assets/ghostapi-avatar.png +0 -0
@@ -0,0 +1,579 @@
1
+ export declare const INVENTORY_SCHEMA_VERSION = 1;
2
+ export declare const INVENTORY_KIND = "ghostapi.inventory";
3
+ export declare const IMPORT_SOURCE_TYPES: readonly ["config", "ci", "gateway", "cloud"];
4
+ export type ImportSourceType = (typeof IMPORT_SOURCE_TYPES)[number];
5
+ export declare const TOOL_KINDS: readonly ["mcp_server", "sdk_client", "http_client"];
6
+ export type ToolKind = (typeof TOOL_KINDS)[number];
7
+ export declare const IDENTITY_ROLES: readonly ["service_account", "user", "workload"];
8
+ export type IdentityRole = (typeof IDENTITY_ROLES)[number];
9
+ export declare const SIDE_EFFECT_KINDS: readonly ["read", "create", "update", "communicate", "money_movement", "delete", "permission_change", "deployment"];
10
+ export type SideEffectKind = (typeof SIDE_EFFECT_KINDS)[number];
11
+ export declare const IMPACT_SEVERITIES: readonly ["low", "medium", "high", "critical"];
12
+ export type ImpactSeverity = (typeof IMPACT_SEVERITIES)[number];
13
+ export declare const EDGE_RELATIONS: readonly ["owns", "uses", "connects", "exposes", "permits", "requires"];
14
+ export type EdgeRelation = (typeof EDGE_RELATIONS)[number];
15
+ export declare const NODE_KINDS: readonly ["agent", "identity", "tool", "provider", "resource", "side_effect", "credential"];
16
+ export type NodeKind = (typeof NODE_KINDS)[number];
17
+ export declare const FINDING_KINDS: readonly ["orphaned_agents", "stale_unused_credentials", "excessive_permissions", "unowned_production_integrations", "agents_outside_gateway", "missing_kill_switch", "missing_evidence", "policy_drift"];
18
+ export type FindingKind = (typeof FINDING_KINDS)[number];
19
+ export declare const FINDING_BASIS: readonly ["evidence", "heuristic"];
20
+ export type FindingBasis = (typeof FINDING_BASIS)[number];
21
+ export declare const FINDING_SEVERITIES: readonly ["critical", "high", "medium", "low"];
22
+ export type FindingSeverity = (typeof FINDING_SEVERITIES)[number];
23
+ export declare const REMEDIATION_KINDS: readonly ["assign_owner", "reduce_scope", "revoke", "onboard_through_gateway", "create_eval"];
24
+ export type RemediationKind = (typeof REMEDIATION_KINDS)[number];
25
+ export declare const REMEDIATION_STATUSES: readonly ["proposed", "applied", "rejected", "expired"];
26
+ export type RemediationStatus = (typeof REMEDIATION_STATUSES)[number];
27
+ export declare const FRESHNESS_DEFAULT_DAYS: {
28
+ readonly edgeStale: 90;
29
+ readonly credentialStale: 90;
30
+ readonly evidenceFresh: 30;
31
+ };
32
+ export type InventoryFreshnessDays = {
33
+ edgeStaleDays?: number;
34
+ credentialStaleDays?: number;
35
+ evidenceFreshDays?: number;
36
+ };
37
+ export declare const INVENTORY_LIMITS: {
38
+ readonly maxStoreBytes: number;
39
+ readonly maxSources: 64;
40
+ readonly maxImports: 256;
41
+ readonly maxAgents: 500;
42
+ readonly maxTools: 500;
43
+ readonly maxIdentities: 500;
44
+ readonly maxProviders: 200;
45
+ readonly maxResources: 1000;
46
+ readonly maxSideEffects: 2000;
47
+ readonly maxCredentials: 500;
48
+ readonly maxPolicies: 100;
49
+ readonly maxEdges: 6000;
50
+ readonly maxFindings: 3000;
51
+ readonly maxRemediations: 1000;
52
+ readonly maxReferencesPerRecord: 64;
53
+ readonly maxScopesPerRecord: 32;
54
+ readonly maxCounters: 3;
55
+ };
56
+ export type InventoryOperatorPermission = "inventory.import" | "inventory.inspect" | "inventory.analyze" | "inventory.remediate" | "inventory.export";
57
+ export type InventoryOperator = {
58
+ id: string;
59
+ principalId: string;
60
+ tenantId: string;
61
+ permissions: readonly InventoryOperatorPermission[];
62
+ };
63
+ export interface InventoryOperatorAuthorizer {
64
+ authenticate(identity: unknown): Promise<InventoryOperator>;
65
+ }
66
+ export type RecordProvenance = {
67
+ sourceId: string;
68
+ sourceType: ImportSourceType;
69
+ sourceName: string;
70
+ importedAt: string;
71
+ importedBy: string;
72
+ };
73
+ export type RecordFreshness = {
74
+ firstSeenAt: string;
75
+ lastSeenAt: string;
76
+ };
77
+ export type FreshnessStatus = "fresh" | "stale" | "missing";
78
+ export type AgentRecord = {
79
+ schemaVersion: 1;
80
+ kind: "ghostapi.inventory-agent";
81
+ tenantId: string;
82
+ agentId: string;
83
+ name: string;
84
+ ownerId: string | null;
85
+ businessPurpose?: string;
86
+ model?: string;
87
+ runtime?: string;
88
+ version?: string;
89
+ identityIds: string[];
90
+ environmentIds: string[];
91
+ gatewayManaged: boolean;
92
+ killSwitchEnabled: boolean;
93
+ lastEvidenceAt: string | null;
94
+ provenance: RecordProvenance;
95
+ freshness: RecordFreshness;
96
+ };
97
+ export type ToolRecord = {
98
+ schemaVersion: 1;
99
+ tenantId: string;
100
+ toolId: string;
101
+ name: string;
102
+ kind: ToolKind;
103
+ providerId: string | null;
104
+ requiredScopes: string[];
105
+ credentialIds: string[];
106
+ provenance: RecordProvenance;
107
+ freshness: RecordFreshness;
108
+ };
109
+ export type IdentityRecord = {
110
+ schemaVersion: 1;
111
+ kind: "ghostapi.inventory-identity";
112
+ tenantId: string;
113
+ identityId: string;
114
+ principalId: string;
115
+ role: IdentityRole;
116
+ agentId: string | null;
117
+ toolIds: string[];
118
+ environmentIds: string[];
119
+ scopes: string[];
120
+ provenance: RecordProvenance;
121
+ freshness: RecordFreshness;
122
+ };
123
+ export type ProviderRecord = {
124
+ schemaVersion: 1;
125
+ kind: "ghostapi.inventory-provider";
126
+ tenantId: string;
127
+ providerId: string;
128
+ name: string;
129
+ providerType: string;
130
+ ownerId: string | null;
131
+ environmentIds: string[];
132
+ resourceIds: string[];
133
+ gatewayBound: boolean;
134
+ killSwitchApplied: boolean;
135
+ provenance: RecordProvenance;
136
+ freshness: RecordFreshness;
137
+ };
138
+ export type ResourceRecord = {
139
+ schemaVersion: 1;
140
+ kind: "ghostapi.inventory-resource";
141
+ tenantId: string;
142
+ resourceId: string;
143
+ providerId: string;
144
+ resourceType: string;
145
+ name: string;
146
+ environmentIds: string[];
147
+ sensitive: boolean;
148
+ ownerId: string | null;
149
+ businessPurpose?: string;
150
+ sideEffectIds: string[];
151
+ provenance: RecordProvenance;
152
+ freshness: RecordFreshness;
153
+ };
154
+ export type SideEffectRecord = {
155
+ schemaVersion: 1;
156
+ tenantId: string;
157
+ sideEffectId: string;
158
+ resourceId: string;
159
+ kind: SideEffectKind;
160
+ severity: ImpactSeverity;
161
+ provenance: RecordProvenance;
162
+ freshness: RecordFreshness;
163
+ };
164
+ export type CredentialRecord = {
165
+ schemaVersion: 1;
166
+ kind: "ghostapi.inventory-credential";
167
+ tenantId: string;
168
+ credentialId: string;
169
+ name: string;
170
+ providerId: string;
171
+ ownerId: string | null;
172
+ environmentIds: string[];
173
+ grantScopes: string[];
174
+ toolIds: string[];
175
+ status: "active" | "revoked";
176
+ issuedAt: string;
177
+ lastUsedAt: string | null;
178
+ rotatedAt?: string;
179
+ gatewayBound: boolean;
180
+ provenance: RecordProvenance;
181
+ freshness: RecordFreshness;
182
+ };
183
+ export type PolicyRecord = {
184
+ schemaVersion: 1;
185
+ kind: "ghostapi.inventory-policy";
186
+ tenantId: string;
187
+ policyId: string;
188
+ name: string;
189
+ version: string;
190
+ hash: string;
191
+ environmentIds: string[];
192
+ provenance: RecordProvenance;
193
+ freshness: RecordFreshness;
194
+ };
195
+ export type GraphEdge = {
196
+ tenantId: string;
197
+ edgeId: string;
198
+ sourceKind: NodeKind;
199
+ sourceId: string;
200
+ targetKind: NodeKind;
201
+ targetId: string;
202
+ relation: EdgeRelation;
203
+ provenance: RecordProvenance;
204
+ firstSeenAt: string;
205
+ lastSeenAt: string;
206
+ };
207
+ export type FindingRecord = {
208
+ schemaVersion: 1;
209
+ tenantId: string;
210
+ findingId: string;
211
+ kind: FindingKind;
212
+ severity: FindingSeverity;
213
+ targetKind: NodeKind | "environment" | "policy";
214
+ targetId: string;
215
+ ruleId: string;
216
+ reason: string;
217
+ basis: FindingBasis;
218
+ discoveredAt: string;
219
+ status: "open" | "resolved";
220
+ resolvedAt?: string;
221
+ remediationId?: string;
222
+ };
223
+ export type RemediationRecord = {
224
+ schemaVersion: 1;
225
+ tenantId: string;
226
+ remediationId: string;
227
+ findingId: string;
228
+ kind: RemediationKind;
229
+ targetKind: NodeKind | "environment" | "policy";
230
+ targetId: string;
231
+ rationale: string;
232
+ proposedBy: string;
233
+ createdAt: string;
234
+ status: RemediationStatus;
235
+ appliedAt?: string;
236
+ result?: {
237
+ description: string;
238
+ reducedScopes?: string[];
239
+ evalScenarioId?: string;
240
+ ownerId?: string;
241
+ };
242
+ };
243
+ export type ImportSourceRecord = {
244
+ tenantId: string;
245
+ sourceId: string;
246
+ sourceType: ImportSourceType;
247
+ sourceName: string;
248
+ sourceVersion?: string;
249
+ firstSeenAt: string;
250
+ lastSeenAt: string;
251
+ lastDigest: string;
252
+ };
253
+ export type ExpectedPolicyHash = {
254
+ environmentId: string;
255
+ policyHash: string;
256
+ };
257
+ export type ImportCounters = {
258
+ preventedEgressAttempts?: number;
259
+ reviewTimeMinutes?: number;
260
+ meanTimeToContainMinutes?: number;
261
+ };
262
+ export type ImportRunRecord = {
263
+ schemaVersion: 1;
264
+ kind: "ghostapi.inventory-import-run";
265
+ tenantId: string;
266
+ runId: string;
267
+ importedAt: string;
268
+ importedBy: string;
269
+ source: {
270
+ sourceId: string;
271
+ sourceType: ImportSourceType;
272
+ sourceName: string;
273
+ sourceVersion?: string;
274
+ };
275
+ digest: string;
276
+ expectedPolicyHashes: ExpectedPolicyHash[];
277
+ counters?: ImportCounters;
278
+ recordCounts: {
279
+ agents: number;
280
+ tools: number;
281
+ identities: number;
282
+ providers: number;
283
+ resources: number;
284
+ sideEffects: number;
285
+ credentials: number;
286
+ policies: number;
287
+ };
288
+ edgesCreated: number;
289
+ edgesRefreshed: number;
290
+ status: "completed";
291
+ };
292
+ export type InventoryStoreState = {
293
+ schemaVersion: 1;
294
+ kind: "ghostapi.inventory";
295
+ sources: ImportSourceRecord[];
296
+ importRuns: ImportRunRecord[];
297
+ agents: AgentRecord[];
298
+ tools: ToolRecord[];
299
+ identities: IdentityRecord[];
300
+ providers: ProviderRecord[];
301
+ resources: ResourceRecord[];
302
+ sideEffects: SideEffectRecord[];
303
+ credentials: CredentialRecord[];
304
+ policies: PolicyRecord[];
305
+ edges: GraphEdge[];
306
+ findings: FindingRecord[];
307
+ remediations: RemediationRecord[];
308
+ };
309
+ export type ImportedAgent = {
310
+ agentId: string;
311
+ name: string;
312
+ ownerId?: string;
313
+ businessPurpose?: string;
314
+ model?: string;
315
+ runtime?: string;
316
+ version?: string;
317
+ identityIds: string[];
318
+ environmentIds: string[];
319
+ gatewayManaged: boolean;
320
+ killSwitchEnabled: boolean;
321
+ lastEvidenceAt?: string;
322
+ };
323
+ export type ImportedTool = {
324
+ toolId: string;
325
+ name: string;
326
+ kind: ToolKind;
327
+ providerId?: string;
328
+ requiredScopes: string[];
329
+ credentialIds: string[];
330
+ };
331
+ export type ImportedIdentity = {
332
+ identityId: string;
333
+ principalId: string;
334
+ role: IdentityRole;
335
+ agentId?: string;
336
+ toolIds: string[];
337
+ environmentIds: string[];
338
+ scopes: string[];
339
+ };
340
+ export type ImportedProvider = {
341
+ providerId: string;
342
+ name: string;
343
+ providerType: string;
344
+ ownerId?: string;
345
+ environmentIds: string[];
346
+ resourceIds: string[];
347
+ gatewayBound: boolean;
348
+ killSwitchApplied: boolean;
349
+ };
350
+ export type ImportedResource = {
351
+ resourceId: string;
352
+ providerId: string;
353
+ resourceType: string;
354
+ name: string;
355
+ environmentIds: string[];
356
+ sensitive: boolean;
357
+ ownerId?: string;
358
+ businessPurpose?: string;
359
+ sideEffectIds: string[];
360
+ };
361
+ export type ImportedSideEffect = {
362
+ sideEffectId: string;
363
+ resourceId: string;
364
+ kind: SideEffectKind;
365
+ severity: ImpactSeverity;
366
+ };
367
+ export type ImportedCredential = {
368
+ credentialId: string;
369
+ name: string;
370
+ providerId: string;
371
+ ownerId?: string;
372
+ environmentIds: string[];
373
+ grantScopes: string[];
374
+ toolIds: string[];
375
+ status: "active" | "revoked";
376
+ issuedAt: string;
377
+ lastUsedAt?: string;
378
+ rotatedAt?: string;
379
+ gatewayBound: boolean;
380
+ };
381
+ export type ImportedPolicy = {
382
+ policyId: string;
383
+ name: string;
384
+ version: string;
385
+ hash: string;
386
+ environmentIds: string[];
387
+ };
388
+ export type InventoryImportPayload = {
389
+ schemaVersion: 1;
390
+ kind: "ghostapi.inventory-import";
391
+ source: {
392
+ sourceId: string;
393
+ sourceType: ImportSourceType;
394
+ sourceName: string;
395
+ sourceVersion?: string;
396
+ };
397
+ expectedPolicyHashes?: ExpectedPolicyHash[];
398
+ counters?: ImportCounters;
399
+ agents?: ImportedAgent[];
400
+ tools?: ImportedTool[];
401
+ identities?: ImportedIdentity[];
402
+ providers?: ImportedProvider[];
403
+ resources?: ImportedResource[];
404
+ sideEffects?: ImportedSideEffect[];
405
+ credentials?: ImportedCredential[];
406
+ policies?: ImportedPolicy[];
407
+ };
408
+ export type GraphEdgeView = GraphEdge & {
409
+ freshnessStatus: FreshnessStatus;
410
+ };
411
+ export type AttackPathStep = {
412
+ kind: NodeKind;
413
+ id: string;
414
+ display: string;
415
+ };
416
+ export type AttackPath = {
417
+ steps: AttackPathStep[];
418
+ complete: boolean;
419
+ edges: GraphEdge[];
420
+ };
421
+ export type AttackPathResult = {
422
+ agentId: string;
423
+ paths: AttackPath[];
424
+ incompletePaths: number;
425
+ };
426
+ export type BlastRadiusRule = {
427
+ ruleId: string;
428
+ explanation: string;
429
+ };
430
+ export type BlastRadiusResource = {
431
+ resourceId: string;
432
+ resourceType: string;
433
+ sensitive: boolean;
434
+ providerId: string;
435
+ sideEffects: {
436
+ sideEffectId: string;
437
+ kind: SideEffectKind;
438
+ severity: ImpactSeverity;
439
+ heuristic: boolean;
440
+ }[];
441
+ pathCount: number;
442
+ rules: string[];
443
+ };
444
+ export type BlastRadiusReport = {
445
+ schemaVersion: 1;
446
+ kind: "ghostapi.inventory-blast-radius";
447
+ tenantId: string;
448
+ agentId: string;
449
+ analyzedAt: string;
450
+ paths: AttackPath[];
451
+ incompletePaths: number;
452
+ resources: BlastRadiusResource[];
453
+ rules: BlastRadiusRule[];
454
+ heuristicNote: string;
455
+ };
456
+ export type CoverageMetrics = {
457
+ activeAgents: number;
458
+ policyCoveredAgents: number;
459
+ evidenceFreshAgents: number;
460
+ gatewayManagedAgents: number;
461
+ productionProviders: number;
462
+ killSwitchProviders: number;
463
+ directCredentials: number;
464
+ outsideGatewayAgents: number;
465
+ unownedProduction: number;
466
+ policyCoverageBps: number;
467
+ evidenceCoverageBps: number;
468
+ gatewayCoverageBps: number;
469
+ killSwitchCoverageBps: number;
470
+ };
471
+ export type RemovalAnalysis = {
472
+ schemaVersion: 1;
473
+ kind: "ghostapi.inventory-removal-analysis";
474
+ tenantId: string;
475
+ generatedAt: string;
476
+ basis: "local_inventory_data";
477
+ coverage: CoverageMetrics;
478
+ lostWithoutGhostApi: string[];
479
+ };
480
+ export type RoiCounterRow = {
481
+ sourceId: string;
482
+ sourceType: ImportSourceType;
483
+ sourceName: string;
484
+ value: number;
485
+ };
486
+ export type RoiReport = {
487
+ schemaVersion: 1;
488
+ kind: "ghostapi.inventory-roi";
489
+ tenantId: string;
490
+ generatedAt: string;
491
+ basis: "local_inventory_data_only";
492
+ activeAgentCount: number;
493
+ productionProviderCount: number;
494
+ incidents: {
495
+ preventedEgressAttempts: number;
496
+ preventedEgressSources: RoiCounterRow[];
497
+ reviewTimeMinutes: number | null;
498
+ reviewTimeSources: RoiCounterRow[];
499
+ meanTimeToContainMinutes: number | null;
500
+ meanTimeToContainSources: RoiCounterRow[];
501
+ };
502
+ remediationOutcomes: {
503
+ unusedGrantsRemoved: number;
504
+ excessiveScopeReductions: number;
505
+ ownedGrants: number;
506
+ onboardedAgents: number;
507
+ evalsCreated: number;
508
+ };
509
+ coverage: Pick<CoverageMetrics, "policyCoverageBps" | "evidenceCoverageBps" | "gatewayCoverageBps" | "killSwitchCoverageBps">;
510
+ notMeasured: string[];
511
+ };
512
+ export type InventorySnapshot = {
513
+ schemaVersion: 1;
514
+ kind: "ghostapi.inventory-snapshot";
515
+ tenantId: string;
516
+ agents: AgentRecord[];
517
+ tools: ToolRecord[];
518
+ identities: IdentityRecord[];
519
+ providers: ProviderRecord[];
520
+ resources: ResourceRecord[];
521
+ sideEffects: SideEffectRecord[];
522
+ credentials: CredentialRecord[];
523
+ policies: PolicyRecord[];
524
+ edges: GraphEdgeView[];
525
+ findings: FindingRecord[];
526
+ remediations: RemediationRecord[];
527
+ sources: ImportSourceRecord[];
528
+ importRuns: ImportRunRecord[];
529
+ };
530
+ export type InventoryExport = {
531
+ schemaVersion: 1;
532
+ kind: "ghostapi.inventory-export";
533
+ tenantId: string;
534
+ exportedAt: string;
535
+ inventory: Omit<InventorySnapshot, "schemaVersion" | "kind" | "edges"> & {
536
+ edges: GraphEdgeView[];
537
+ };
538
+ policyRecords: PolicyRecord[];
539
+ scenarioRefs: {
540
+ evalScenarioId: string;
541
+ forFindingId: string;
542
+ createdBy: string;
543
+ }[];
544
+ evidenceMetadata: {
545
+ agentId: string;
546
+ lastEvidenceAt: string | null;
547
+ status: FreshnessStatus;
548
+ }[];
549
+ removalAnalysis: RemovalAnalysis;
550
+ roi: RoiReport;
551
+ };
552
+ export type ImportSummary = {
553
+ runId: string;
554
+ importedAt: string;
555
+ digest: string;
556
+ recordCounts: ImportRunRecord["recordCounts"];
557
+ edgesCreated: number;
558
+ edgesRefreshed: number;
559
+ };
560
+ export declare class InventoryError extends Error {
561
+ constructor(message: string);
562
+ }
563
+ export declare function emptyInventoryState(): InventoryStoreState;
564
+ export declare function sha256Digest(value: string): string;
565
+ export declare function canonicalPayloadDigest(payload: InventoryImportPayload): string;
566
+ export declare function sortedKeysReplacer(_key: string, value: unknown): unknown;
567
+ export declare function validateImportPayload(value: unknown): InventoryImportPayload;
568
+ export declare function validateState(value: unknown): InventoryStoreState;
569
+ export declare function clone<T>(value: T): T;
570
+ export declare function validateOperator(value: unknown): InventoryOperator;
571
+ export declare function validateFindingsAndRemediations(value: unknown): {
572
+ findings: FindingRecord[];
573
+ remediations: RemediationRecord[];
574
+ };
575
+ export declare function buildRecordProvenance(source: InventoryImportPayload["source"], importedAt: string, importedBy: string): RecordProvenance;
576
+ export declare function buildRecordFreshness(now: string): RecordFreshness;
577
+ export declare function edgeIdFor(sourceKind: NodeKind, sourceId: string, targetKind: NodeKind, targetId: string, relation: EdgeRelation): string;
578
+ export declare function freshnessStatusFor(lastSeenAt: string, now: string, staleDays: number): FreshnessStatus;
579
+ export declare function daysSince(thenIso: string, nowIso: string): number;