@synctek/forgeos 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 (143) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +386 -0
  3. package/dist/cli/commands/analyze.d.ts +14 -0
  4. package/dist/cli/commands/analyze.d.ts.map +1 -0
  5. package/dist/cli/commands/analyze.js +94 -0
  6. package/dist/cli/commands/analyze.js.map +1 -0
  7. package/dist/cli/commands/build.d.ts +11 -0
  8. package/dist/cli/commands/build.d.ts.map +1 -0
  9. package/dist/cli/commands/build.js +86 -0
  10. package/dist/cli/commands/build.js.map +1 -0
  11. package/dist/cli/commands/changeset.d.ts +13 -0
  12. package/dist/cli/commands/changeset.d.ts.map +1 -0
  13. package/dist/cli/commands/changeset.js +174 -0
  14. package/dist/cli/commands/changeset.js.map +1 -0
  15. package/dist/cli/commands/evidence.d.ts +12 -0
  16. package/dist/cli/commands/evidence.d.ts.map +1 -0
  17. package/dist/cli/commands/evidence.js +94 -0
  18. package/dist/cli/commands/evidence.js.map +1 -0
  19. package/dist/cli/commands/federation.d.ts +13 -0
  20. package/dist/cli/commands/federation.d.ts.map +1 -0
  21. package/dist/cli/commands/federation.js +127 -0
  22. package/dist/cli/commands/federation.js.map +1 -0
  23. package/dist/cli/commands/gate.d.ts +15 -0
  24. package/dist/cli/commands/gate.d.ts.map +1 -0
  25. package/dist/cli/commands/gate.js +178 -0
  26. package/dist/cli/commands/gate.js.map +1 -0
  27. package/dist/cli/commands/initiative.d.ts +13 -0
  28. package/dist/cli/commands/initiative.d.ts.map +1 -0
  29. package/dist/cli/commands/initiative.js +130 -0
  30. package/dist/cli/commands/initiative.js.map +1 -0
  31. package/dist/cli/commands/mind.d.ts +16 -0
  32. package/dist/cli/commands/mind.d.ts.map +1 -0
  33. package/dist/cli/commands/mind.js +139 -0
  34. package/dist/cli/commands/mind.js.map +1 -0
  35. package/dist/cli/commands/outcome.d.ts +12 -0
  36. package/dist/cli/commands/outcome.d.ts.map +1 -0
  37. package/dist/cli/commands/outcome.js +85 -0
  38. package/dist/cli/commands/outcome.js.map +1 -0
  39. package/dist/cli/commands/project.d.ts +13 -0
  40. package/dist/cli/commands/project.d.ts.map +1 -0
  41. package/dist/cli/commands/project.js +128 -0
  42. package/dist/cli/commands/project.js.map +1 -0
  43. package/dist/cli/commands/review.d.ts +15 -0
  44. package/dist/cli/commands/review.d.ts.map +1 -0
  45. package/dist/cli/commands/review.js +167 -0
  46. package/dist/cli/commands/review.js.map +1 -0
  47. package/dist/cli/commands/score.d.ts +17 -0
  48. package/dist/cli/commands/score.d.ts.map +1 -0
  49. package/dist/cli/commands/score.js +168 -0
  50. package/dist/cli/commands/score.js.map +1 -0
  51. package/dist/cli/commands/session.d.ts +13 -0
  52. package/dist/cli/commands/session.d.ts.map +1 -0
  53. package/dist/cli/commands/session.js +133 -0
  54. package/dist/cli/commands/session.js.map +1 -0
  55. package/dist/cli/commands/trust.d.ts +16 -0
  56. package/dist/cli/commands/trust.d.ts.map +1 -0
  57. package/dist/cli/commands/trust.js +261 -0
  58. package/dist/cli/commands/trust.js.map +1 -0
  59. package/dist/cli/index.d.ts +19 -0
  60. package/dist/cli/index.d.ts.map +1 -0
  61. package/dist/cli/index.js +99 -0
  62. package/dist/cli/index.js.map +1 -0
  63. package/dist/cli/output.d.ts +48 -0
  64. package/dist/cli/output.d.ts.map +1 -0
  65. package/dist/cli/output.js +139 -0
  66. package/dist/cli/output.js.map +1 -0
  67. package/dist/client.d.ts +46 -0
  68. package/dist/client.d.ts.map +1 -0
  69. package/dist/client.js +146 -0
  70. package/dist/client.js.map +1 -0
  71. package/dist/handlers.d.ts +11 -0
  72. package/dist/handlers.d.ts.map +1 -0
  73. package/dist/handlers.js +424 -0
  74. package/dist/handlers.js.map +1 -0
  75. package/dist/http-server.d.ts +25 -0
  76. package/dist/http-server.d.ts.map +1 -0
  77. package/dist/http-server.js +246 -0
  78. package/dist/http-server.js.map +1 -0
  79. package/dist/index.d.ts +3 -0
  80. package/dist/index.d.ts.map +1 -0
  81. package/dist/index.js +40 -0
  82. package/dist/index.js.map +1 -0
  83. package/dist/mcp/handlers.d.ts +11 -0
  84. package/dist/mcp/handlers.d.ts.map +1 -0
  85. package/dist/mcp/handlers.js +553 -0
  86. package/dist/mcp/handlers.js.map +1 -0
  87. package/dist/mcp/http-server.d.ts +25 -0
  88. package/dist/mcp/http-server.d.ts.map +1 -0
  89. package/dist/mcp/http-server.js +246 -0
  90. package/dist/mcp/http-server.js.map +1 -0
  91. package/dist/mcp/index.d.ts +3 -0
  92. package/dist/mcp/index.d.ts.map +1 -0
  93. package/dist/mcp/index.js +40 -0
  94. package/dist/mcp/index.js.map +1 -0
  95. package/dist/mcp/tools.d.ts +944 -0
  96. package/dist/mcp/tools.d.ts.map +1 -0
  97. package/dist/mcp/tools.js +531 -0
  98. package/dist/mcp/tools.js.map +1 -0
  99. package/dist/shared/client.d.ts +59 -0
  100. package/dist/shared/client.d.ts.map +1 -0
  101. package/dist/shared/client.js +171 -0
  102. package/dist/shared/client.js.map +1 -0
  103. package/dist/shared/errors.d.ts +25 -0
  104. package/dist/shared/errors.d.ts.map +1 -0
  105. package/dist/shared/errors.js +44 -0
  106. package/dist/shared/errors.js.map +1 -0
  107. package/dist/shared/types.d.ts +111 -0
  108. package/dist/shared/types.d.ts.map +1 -0
  109. package/dist/shared/types.js +10 -0
  110. package/dist/shared/types.js.map +1 -0
  111. package/dist/tools.d.ts +944 -0
  112. package/dist/tools.d.ts.map +1 -0
  113. package/dist/tools.js +513 -0
  114. package/dist/tools.js.map +1 -0
  115. package/dist/trust/chain.d.ts +86 -0
  116. package/dist/trust/chain.d.ts.map +1 -0
  117. package/dist/trust/chain.js +176 -0
  118. package/dist/trust/chain.js.map +1 -0
  119. package/dist/trust/git-binding.d.ts +61 -0
  120. package/dist/trust/git-binding.d.ts.map +1 -0
  121. package/dist/trust/git-binding.js +133 -0
  122. package/dist/trust/git-binding.js.map +1 -0
  123. package/dist/trust/index.d.ts +20 -0
  124. package/dist/trust/index.d.ts.map +1 -0
  125. package/dist/trust/index.js +17 -0
  126. package/dist/trust/index.js.map +1 -0
  127. package/dist/trust/ledger.d.ts +144 -0
  128. package/dist/trust/ledger.d.ts.map +1 -0
  129. package/dist/trust/ledger.js +351 -0
  130. package/dist/trust/ledger.js.map +1 -0
  131. package/dist/trust/signing.d.ts +134 -0
  132. package/dist/trust/signing.d.ts.map +1 -0
  133. package/dist/trust/signing.js +249 -0
  134. package/dist/trust/signing.js.map +1 -0
  135. package/dist/trust/transmission.d.ts +129 -0
  136. package/dist/trust/transmission.d.ts.map +1 -0
  137. package/dist/trust/transmission.js +390 -0
  138. package/dist/trust/transmission.js.map +1 -0
  139. package/dist/types.d.ts +183 -0
  140. package/dist/types.d.ts.map +1 -0
  141. package/dist/types.js +3 -0
  142. package/dist/types.js.map +1 -0
  143. package/package.json +61 -0
@@ -0,0 +1,171 @@
1
+ /**
2
+ * ForgeOS Engine HTTP client — shared between MCP server and CLI binary.
3
+ *
4
+ * Improvements over the original src/client.ts:
5
+ * - Structured error handling via ForgeAPIError (parses engine error envelope)
6
+ * - delete() method
7
+ * - Auto-generated Idempotency-Key header on POST/PUT/PATCH
8
+ * - Retry on 429 (respects Retry-After header) and 503 (1 retry, 1s delay)
9
+ * - healthCheck() convenience method
10
+ * - Configurable timeout (constructor param)
11
+ * - Retry guard prevents infinite loops (max 1 automatic retry)
12
+ *
13
+ * Design constraints preserved from original:
14
+ * - X-ForgeOS-API-Key header (not Authorization Bearer) for engine auth
15
+ * - Module-level singleton for the stdio transport path (single-tenant)
16
+ * - HTTP transport MUST NOT use the singleton — construct per-request instances
17
+ * - 10-second default timeout per request
18
+ * - One retry on network errors (TypeError from fetch)
19
+ */
20
+ import { ForgeAPIError } from "./errors.js";
21
+ import { randomUUID } from "crypto";
22
+ const ENGINE_URL = process.env.FORGEOS_ENGINE_URL || "http://localhost:8400";
23
+ const DEFAULT_TIMEOUT_MS = 10_000;
24
+ const MAX_NETWORK_RETRIES = 1;
25
+ const MAX_RATE_RETRIES = 1; // separate guard for 429/503 retries
26
+ /** True if the thrown error is a network-level failure (not an HTTP status). */
27
+ function isNetworkError(err) {
28
+ if (err instanceof TypeError)
29
+ return true;
30
+ // AbortError is a timeout — do not retry
31
+ if (err instanceof DOMException && err.name === "AbortError")
32
+ return false;
33
+ return false;
34
+ }
35
+ function delay(ms) {
36
+ return new Promise((resolve) => setTimeout(resolve, ms));
37
+ }
38
+ export class ForgeOSClient {
39
+ baseUrl;
40
+ apiKey;
41
+ timeout;
42
+ /**
43
+ * @param baseUrl Engine base URL. Defaults to FORGEOS_ENGINE_URL or http://localhost:8400.
44
+ * @param apiKey API key sent as X-ForgeOS-API-Key. Pass explicitly; do NOT read from env here.
45
+ * @param timeout Per-request timeout in ms. Default 10 000.
46
+ */
47
+ constructor(baseUrl, apiKey, timeout = DEFAULT_TIMEOUT_MS) {
48
+ this.baseUrl = (baseUrl || ENGINE_URL).replace(/\/+$/, "");
49
+ this.apiKey = apiKey ?? "";
50
+ this.timeout = timeout;
51
+ }
52
+ // ---------------------------------------------------------------------------
53
+ // Public HTTP methods
54
+ // ---------------------------------------------------------------------------
55
+ async get(path, params) {
56
+ let url = `${this.baseUrl}${path}`;
57
+ if (params && Object.keys(params).length > 0) {
58
+ url += `?${new URLSearchParams(params).toString()}`;
59
+ }
60
+ return this.request("GET", url);
61
+ }
62
+ async post(path, body) {
63
+ return this.request("POST", `${this.baseUrl}${path}`, body);
64
+ }
65
+ async patch(path, body) {
66
+ return this.request("PATCH", `${this.baseUrl}${path}`, body);
67
+ }
68
+ async put(path, body) {
69
+ return this.request("PUT", `${this.baseUrl}${path}`, body);
70
+ }
71
+ async delete(path) {
72
+ return this.request("DELETE", `${this.baseUrl}${path}`);
73
+ }
74
+ /**
75
+ * Lightweight liveness check. Returns true if the engine responds 2xx on
76
+ * GET /health, false otherwise. Never throws.
77
+ */
78
+ async healthCheck() {
79
+ try {
80
+ await this.get("/health");
81
+ return true;
82
+ }
83
+ catch {
84
+ return false;
85
+ }
86
+ }
87
+ // ---------------------------------------------------------------------------
88
+ // Core request implementation
89
+ // ---------------------------------------------------------------------------
90
+ /**
91
+ * Execute an HTTP request with:
92
+ * - AbortController timeout
93
+ * - Auto Idempotency-Key on mutating methods
94
+ * - Retry on network errors (up to MAX_NETWORK_RETRIES)
95
+ * - Retry on 429/503 (up to MAX_RATE_RETRIES, respects Retry-After)
96
+ * - ForgeAPIError on non-ok HTTP responses
97
+ */
98
+ async request(method, url, body, _networkRetry = 0, _rateRetry = 0) {
99
+ const headers = {};
100
+ if (this.apiKey) {
101
+ headers["X-ForgeOS-API-Key"] = this.apiKey;
102
+ }
103
+ if (body !== undefined) {
104
+ headers["Content-Type"] = "application/json";
105
+ }
106
+ // Idempotency key for mutating methods — prevents duplicate side-effects
107
+ if (["POST", "PUT", "PATCH"].includes(method)) {
108
+ headers["Idempotency-Key"] = randomUUID();
109
+ }
110
+ const controller = new AbortController();
111
+ const timerId = setTimeout(() => controller.abort(), this.timeout);
112
+ let response;
113
+ try {
114
+ response = await fetch(url, {
115
+ method,
116
+ headers,
117
+ body: body !== undefined ? JSON.stringify(body) : undefined,
118
+ signal: controller.signal,
119
+ });
120
+ clearTimeout(timerId);
121
+ }
122
+ catch (err) {
123
+ clearTimeout(timerId);
124
+ // Timeout
125
+ if (err instanceof DOMException && err.name === "AbortError") {
126
+ throw new Error(`Request timed out after ${this.timeout}ms: ${method} ${url}`);
127
+ }
128
+ // Network error — retry once
129
+ if (isNetworkError(err) && _networkRetry < MAX_NETWORK_RETRIES) {
130
+ await delay(500);
131
+ return this.request(method, url, body, _networkRetry + 1, _rateRetry);
132
+ }
133
+ throw err;
134
+ }
135
+ // --- Rate limit / service unavailable: retry with back-off ---
136
+ if ([429, 503].includes(response.status) && _rateRetry < MAX_RATE_RETRIES) {
137
+ const retryAfterHeader = response.headers.get("Retry-After");
138
+ const backoff = retryAfterHeader
139
+ ? Math.min(parseInt(retryAfterHeader, 10) * 1000, 5000)
140
+ : 1000;
141
+ await delay(backoff);
142
+ return this.request(method, url, body, _networkRetry, _rateRetry + 1);
143
+ }
144
+ // --- Non-ok response: parse engine error envelope ---
145
+ if (!response.ok) {
146
+ let errorBody = {};
147
+ try {
148
+ errorBody = (await response.json());
149
+ }
150
+ catch {
151
+ const text = await response.text().catch(() => "");
152
+ errorBody = { detail: text || response.statusText };
153
+ }
154
+ throw new ForgeAPIError(response.status, errorBody);
155
+ }
156
+ // 204 No Content
157
+ if (response.status === 204)
158
+ return null;
159
+ return response.json();
160
+ }
161
+ }
162
+ /**
163
+ * Module-level singleton for the stdio transport path.
164
+ * Reads credentials from env at startup — safe because stdio is single-tenant
165
+ * (one process = one user).
166
+ *
167
+ * The HTTP transport MUST NOT use this singleton. It constructs per-request
168
+ * ForgeOSClient instances with the key extracted from the Authorization header.
169
+ */
170
+ export const client = new ForgeOSClient(process.env.FORGEOS_ENGINE_URL, process.env.FORGEOS_API_KEY);
171
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/shared/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,UAAU,GACd,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,uBAAuB,CAAC;AAC5D,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B,MAAM,gBAAgB,GAAG,CAAC,CAAC,CAAC,qCAAqC;AAEjE,gFAAgF;AAChF,SAAS,cAAc,CAAC,GAAY;IAClC,IAAI,GAAG,YAAY,SAAS;QAAE,OAAO,IAAI,CAAC;IAC1C,yCAAyC;IACzC,IAAI,GAAG,YAAY,YAAY,IAAI,GAAG,CAAC,IAAI,KAAK,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e,CAC5B,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * ForgeAPIError — structured error for non-ok HTTP responses from the ForgeOS engine.
3
+ *
4
+ * Parses the engine's standard error envelope:
5
+ * { detail, error, context, suggestion, request_id, docs_url }
6
+ *
7
+ * Design: single source of truth for how callers present engine errors to end
8
+ * users. Both the MCP transport and the CLI binary import this class; neither
9
+ * duplicates the formatting logic.
10
+ */
11
+ export declare class ForgeAPIError extends Error {
12
+ status: number;
13
+ detail: string;
14
+ context: Record<string, unknown> | null;
15
+ suggestion: string | null;
16
+ requestId: string | null;
17
+ docsUrl: string | null;
18
+ constructor(status: number, body: Record<string, unknown>);
19
+ /**
20
+ * Return a user-facing message that includes the error detail plus any
21
+ * actionable hints the engine provided.
22
+ */
23
+ toUserMessage(): string;
24
+ }
25
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/shared/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;gBAEX,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAezD;;;OAGG;IACH,aAAa,IAAI,MAAM;CAMxB"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * ForgeAPIError — structured error for non-ok HTTP responses from the ForgeOS engine.
3
+ *
4
+ * Parses the engine's standard error envelope:
5
+ * { detail, error, context, suggestion, request_id, docs_url }
6
+ *
7
+ * Design: single source of truth for how callers present engine errors to end
8
+ * users. Both the MCP transport and the CLI binary import this class; neither
9
+ * duplicates the formatting logic.
10
+ */
11
+ export class ForgeAPIError extends Error {
12
+ status;
13
+ detail;
14
+ context;
15
+ suggestion;
16
+ requestId;
17
+ docsUrl;
18
+ constructor(status, body) {
19
+ const detail = body.detail ||
20
+ body.error ||
21
+ "Unknown error";
22
+ super(`${status}: ${detail}`);
23
+ this.name = "ForgeAPIError";
24
+ this.status = status;
25
+ this.detail = detail;
26
+ this.context = body.context || null;
27
+ this.suggestion = body.suggestion || null;
28
+ this.requestId = body.request_id || null;
29
+ this.docsUrl = body.docs_url || null;
30
+ }
31
+ /**
32
+ * Return a user-facing message that includes the error detail plus any
33
+ * actionable hints the engine provided.
34
+ */
35
+ toUserMessage() {
36
+ const parts = [this.detail];
37
+ if (this.suggestion)
38
+ parts.push(`Suggestion: ${this.suggestion}`);
39
+ if (this.docsUrl)
40
+ parts.push(`Docs: ${this.docsUrl}`);
41
+ return parts.join("\n");
42
+ }
43
+ }
44
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/shared/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,MAAM,CAAS;IACf,MAAM,CAAS;IACf,OAAO,CAAiC;IACxC,UAAU,CAAgB;IAC1B,SAAS,CAAgB;IACzB,OAAO,CAAgB;IAEvB,YAAY,MAAc,EAAE,IAA6B;QACvD,MAAM,MAAM,GACT,IAAI,CAAC,MAAiB;YACtB,IAAI,CAAC,KAAgB;YACtB,eAAe,CAAC;QAClB,KAAK,CAAC,GAAG,MAAM,KAAK,MAAM,EAAE,CAAC,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAI,IAAI,CAAC,OAAmC,IAAI,IAAI,CAAC;QACjE,IAAI,CAAC,UAAU,GAAI,IAAI,CAAC,UAAqB,IAAI,IAAI,CAAC;QACtD,IAAI,CAAC,SAAS,GAAI,IAAI,CAAC,UAAqB,IAAI,IAAI,CAAC;QACrD,IAAI,CAAC,OAAO,GAAI,IAAI,CAAC,QAAmB,IAAI,IAAI,CAAC;IACnD,CAAC;IAED;;;OAGG;IACH,aAAa;QACX,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5B,IAAI,IAAI,CAAC,UAAU;YAAE,KAAK,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QAClE,IAAI,IAAI,CAAC,OAAO;YAAE,KAAK,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QACtD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Shared TypeScript interfaces for ForgeOS engine response types.
3
+ *
4
+ * Used by both the MCP server transport and the CLI binary so type definitions
5
+ * are never duplicated. Interfaces are intentionally minimal — only the fields
6
+ * callers actually inspect. Engine responses may contain additional fields that
7
+ * are preserved as `unknown` pass-throughs.
8
+ */
9
+ export interface Project {
10
+ id: string;
11
+ name: string;
12
+ platform: string;
13
+ shadow_mode?: boolean;
14
+ }
15
+ export interface ProjectList {
16
+ projects: Project[];
17
+ }
18
+ export interface Initiative {
19
+ id: string;
20
+ title: string;
21
+ description?: string;
22
+ priority: string;
23
+ status: string;
24
+ }
25
+ export interface Changeset {
26
+ id: string;
27
+ changeset_id?: string;
28
+ description: string;
29
+ modules_affected: string[];
30
+ files_changed: string[];
31
+ risk_score: number;
32
+ gate_recommendation?: GateRecommendation | null;
33
+ }
34
+ export interface Gate {
35
+ gate_id: string;
36
+ gate_name: string;
37
+ order: number;
38
+ status: string;
39
+ required_evidence: string[];
40
+ required_roles: string[];
41
+ }
42
+ export interface GateRecommendation {
43
+ recommended_gates: Gate[];
44
+ risk_analysis: Record<string, unknown>;
45
+ }
46
+ export interface Evidence {
47
+ id: string;
48
+ type: string;
49
+ summary: string;
50
+ submitted_by: string;
51
+ }
52
+ export interface Review {
53
+ id: string;
54
+ role: string;
55
+ status: string;
56
+ findings?: ReviewFinding[];
57
+ }
58
+ export interface ReviewFinding {
59
+ category: string;
60
+ severity: string;
61
+ observation: string;
62
+ recommendation: string;
63
+ }
64
+ export interface Session {
65
+ id: string;
66
+ project_id: string;
67
+ status: string;
68
+ started_at: string;
69
+ ended_at?: string;
70
+ }
71
+ export interface Observation {
72
+ id: string;
73
+ domain: string;
74
+ observation_type: string;
75
+ content: string;
76
+ confidence: number;
77
+ }
78
+ export interface KnowledgeNode {
79
+ domain: string;
80
+ patterns: string[];
81
+ anti_patterns: string[];
82
+ fix_recipes: string[];
83
+ }
84
+ export interface QualityWarning {
85
+ type: string;
86
+ message: string;
87
+ severity: string;
88
+ source: string;
89
+ }
90
+ export interface FederationStatus {
91
+ enabled: boolean;
92
+ hub_url: string;
93
+ instance_id: string;
94
+ last_push?: string;
95
+ last_pull?: string;
96
+ }
97
+ export interface LedgerEntry {
98
+ seq: number;
99
+ timestamp: string;
100
+ entry_type: string;
101
+ previous_hash: string;
102
+ }
103
+ export interface Scorecard {
104
+ setup_complete: boolean;
105
+ items: ScorecardItem[];
106
+ }
107
+ export interface ScorecardItem {
108
+ name: string;
109
+ status: "complete" | "incomplete";
110
+ }
111
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OA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,KAAK,EAAE,aAAa,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,GAAG,YAAY,CAAC;CACnC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Shared TypeScript interfaces for ForgeOS engine response types.
3
+ *
4
+ * Used by both the MCP server transport and the CLI binary so type definitions
5
+ * are never duplicated. Interfaces are intentionally minimal — only the fields
6
+ * callers actually inspect. Engine responses may contain additional fields that
7
+ * are preserved as `unknown` pass-throughs.
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}