@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.
- package/LICENSE +21 -0
- package/README.md +386 -0
- package/dist/cli/commands/analyze.d.ts +14 -0
- package/dist/cli/commands/analyze.d.ts.map +1 -0
- package/dist/cli/commands/analyze.js +94 -0
- package/dist/cli/commands/analyze.js.map +1 -0
- package/dist/cli/commands/build.d.ts +11 -0
- package/dist/cli/commands/build.d.ts.map +1 -0
- package/dist/cli/commands/build.js +86 -0
- package/dist/cli/commands/build.js.map +1 -0
- package/dist/cli/commands/changeset.d.ts +13 -0
- package/dist/cli/commands/changeset.d.ts.map +1 -0
- package/dist/cli/commands/changeset.js +174 -0
- package/dist/cli/commands/changeset.js.map +1 -0
- package/dist/cli/commands/evidence.d.ts +12 -0
- package/dist/cli/commands/evidence.d.ts.map +1 -0
- package/dist/cli/commands/evidence.js +94 -0
- package/dist/cli/commands/evidence.js.map +1 -0
- package/dist/cli/commands/federation.d.ts +13 -0
- package/dist/cli/commands/federation.d.ts.map +1 -0
- package/dist/cli/commands/federation.js +127 -0
- package/dist/cli/commands/federation.js.map +1 -0
- package/dist/cli/commands/gate.d.ts +15 -0
- package/dist/cli/commands/gate.d.ts.map +1 -0
- package/dist/cli/commands/gate.js +178 -0
- package/dist/cli/commands/gate.js.map +1 -0
- package/dist/cli/commands/initiative.d.ts +13 -0
- package/dist/cli/commands/initiative.d.ts.map +1 -0
- package/dist/cli/commands/initiative.js +130 -0
- package/dist/cli/commands/initiative.js.map +1 -0
- package/dist/cli/commands/mind.d.ts +16 -0
- package/dist/cli/commands/mind.d.ts.map +1 -0
- package/dist/cli/commands/mind.js +139 -0
- package/dist/cli/commands/mind.js.map +1 -0
- package/dist/cli/commands/outcome.d.ts +12 -0
- package/dist/cli/commands/outcome.d.ts.map +1 -0
- package/dist/cli/commands/outcome.js +85 -0
- package/dist/cli/commands/outcome.js.map +1 -0
- package/dist/cli/commands/project.d.ts +13 -0
- package/dist/cli/commands/project.d.ts.map +1 -0
- package/dist/cli/commands/project.js +128 -0
- package/dist/cli/commands/project.js.map +1 -0
- package/dist/cli/commands/review.d.ts +15 -0
- package/dist/cli/commands/review.d.ts.map +1 -0
- package/dist/cli/commands/review.js +167 -0
- package/dist/cli/commands/review.js.map +1 -0
- package/dist/cli/commands/score.d.ts +17 -0
- package/dist/cli/commands/score.d.ts.map +1 -0
- package/dist/cli/commands/score.js +168 -0
- package/dist/cli/commands/score.js.map +1 -0
- package/dist/cli/commands/session.d.ts +13 -0
- package/dist/cli/commands/session.d.ts.map +1 -0
- package/dist/cli/commands/session.js +133 -0
- package/dist/cli/commands/session.js.map +1 -0
- package/dist/cli/commands/trust.d.ts +16 -0
- package/dist/cli/commands/trust.d.ts.map +1 -0
- package/dist/cli/commands/trust.js +261 -0
- package/dist/cli/commands/trust.js.map +1 -0
- package/dist/cli/index.d.ts +19 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +99 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/output.d.ts +48 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +139 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/client.d.ts +46 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +146 -0
- package/dist/client.js.map +1 -0
- package/dist/handlers.d.ts +11 -0
- package/dist/handlers.d.ts.map +1 -0
- package/dist/handlers.js +424 -0
- package/dist/handlers.js.map +1 -0
- package/dist/http-server.d.ts +25 -0
- package/dist/http-server.d.ts.map +1 -0
- package/dist/http-server.js +246 -0
- package/dist/http-server.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/handlers.d.ts +11 -0
- package/dist/mcp/handlers.d.ts.map +1 -0
- package/dist/mcp/handlers.js +553 -0
- package/dist/mcp/handlers.js.map +1 -0
- package/dist/mcp/http-server.d.ts +25 -0
- package/dist/mcp/http-server.d.ts.map +1 -0
- package/dist/mcp/http-server.js +246 -0
- package/dist/mcp/http-server.js.map +1 -0
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +40 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/tools.d.ts +944 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +531 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/shared/client.d.ts +59 -0
- package/dist/shared/client.d.ts.map +1 -0
- package/dist/shared/client.js +171 -0
- package/dist/shared/client.js.map +1 -0
- package/dist/shared/errors.d.ts +25 -0
- package/dist/shared/errors.d.ts.map +1 -0
- package/dist/shared/errors.js +44 -0
- package/dist/shared/errors.js.map +1 -0
- package/dist/shared/types.d.ts +111 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +10 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/tools.d.ts +944 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +513 -0
- package/dist/tools.js.map +1 -0
- package/dist/trust/chain.d.ts +86 -0
- package/dist/trust/chain.d.ts.map +1 -0
- package/dist/trust/chain.js +176 -0
- package/dist/trust/chain.js.map +1 -0
- package/dist/trust/git-binding.d.ts +61 -0
- package/dist/trust/git-binding.d.ts.map +1 -0
- package/dist/trust/git-binding.js +133 -0
- package/dist/trust/git-binding.js.map +1 -0
- package/dist/trust/index.d.ts +20 -0
- package/dist/trust/index.d.ts.map +1 -0
- package/dist/trust/index.js +17 -0
- package/dist/trust/index.js.map +1 -0
- package/dist/trust/ledger.d.ts +144 -0
- package/dist/trust/ledger.d.ts.map +1 -0
- package/dist/trust/ledger.js +351 -0
- package/dist/trust/ledger.js.map +1 -0
- package/dist/trust/signing.d.ts +134 -0
- package/dist/trust/signing.d.ts.map +1 -0
- package/dist/trust/signing.js +249 -0
- package/dist/trust/signing.js.map +1 -0
- package/dist/trust/transmission.d.ts +129 -0
- package/dist/trust/transmission.d.ts.map +1 -0
- package/dist/trust/transmission.js +390 -0
- package/dist/trust/transmission.js.map +1 -0
- package/dist/types.d.ts +183 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `forge trust` — Local trust ledger commands.
|
|
3
|
+
*
|
|
4
|
+
* These commands operate ENTIRELY locally — no engine HTTP calls.
|
|
5
|
+
* They use the src/trust/ modules directly.
|
|
6
|
+
*
|
|
7
|
+
* Subcommands:
|
|
8
|
+
* forge trust init [path] — generate keypair + create ledger dirs
|
|
9
|
+
* forge trust verify [path] — verify chain integrity
|
|
10
|
+
* forge trust stats [path] — show chain statistics
|
|
11
|
+
* forge trust share [path] [--endpoint <url>] — transmit shareable metadata
|
|
12
|
+
* forge trust config [path] — show key configuration
|
|
13
|
+
*/
|
|
14
|
+
import { existsSync, mkdirSync } from "fs";
|
|
15
|
+
import { join, resolve } from "path";
|
|
16
|
+
import { createInterface } from "readline";
|
|
17
|
+
import { KeyManager } from "../../trust/signing.js";
|
|
18
|
+
import { TrustLedger } from "../../trust/ledger.js";
|
|
19
|
+
import { prepareTransmission, generateManifest, generatePlainManifest, sendTransmission, loadAllowedEndpoints, } from "../../trust/transmission.js";
|
|
20
|
+
import { formatTable, formatJSON, formatSuccess, formatWarning, formatError, formatStatus, green, red, } from "../output.js";
|
|
21
|
+
const DEFAULT_TRUST_ENDPOINT = "https://api.forgeos.synctek.io/api/trust/submit";
|
|
22
|
+
/** Resolve the project path: explicit arg → cwd. */
|
|
23
|
+
function resolvePath(pathArg) {
|
|
24
|
+
return resolve(pathArg ?? process.cwd());
|
|
25
|
+
}
|
|
26
|
+
/** Ask a yes/no question on stdin; returns true for "y"/"yes". */
|
|
27
|
+
async function confirmPrompt(question) {
|
|
28
|
+
return new Promise((resolve) => {
|
|
29
|
+
const rl = createInterface({
|
|
30
|
+
input: process.stdin,
|
|
31
|
+
output: process.stdout,
|
|
32
|
+
});
|
|
33
|
+
rl.question(`${question} [y/N] `, (answer) => {
|
|
34
|
+
rl.close();
|
|
35
|
+
resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export function registerTrustCommands(parent, _client // not used — all trust commands are local
|
|
40
|
+
) {
|
|
41
|
+
const trust = parent
|
|
42
|
+
.command("trust")
|
|
43
|
+
.description("Manage the local trust ledger (local only — no engine)");
|
|
44
|
+
// -------------------------------------------------------------------------
|
|
45
|
+
// trust init [path]
|
|
46
|
+
// -------------------------------------------------------------------------
|
|
47
|
+
trust
|
|
48
|
+
.command("init [path]")
|
|
49
|
+
.description("Generate an Ed25519 keypair and initialise the trust ledger")
|
|
50
|
+
.option("--json", "Output raw JSON")
|
|
51
|
+
.action(async (pathArg, opts) => {
|
|
52
|
+
try {
|
|
53
|
+
const projectPath = resolvePath(pathArg);
|
|
54
|
+
const forgeoDir = join(projectPath, ".forgeos");
|
|
55
|
+
// Create .forgeos/ and .forgeos/keys/ directories
|
|
56
|
+
mkdirSync(join(forgeoDir, "keys"), { recursive: true });
|
|
57
|
+
const km = new KeyManager(projectPath);
|
|
58
|
+
const fingerprint = km.generateKeypair();
|
|
59
|
+
if (opts.json) {
|
|
60
|
+
console.log(formatJSON({
|
|
61
|
+
project_path: projectPath,
|
|
62
|
+
fingerprint,
|
|
63
|
+
private_key: km.privateKeyPath,
|
|
64
|
+
public_key: km.publicKeyPath,
|
|
65
|
+
ledger_path: join(forgeoDir, "ledger.jsonl"),
|
|
66
|
+
}));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
console.log(formatSuccess("Trust ledger initialised."));
|
|
70
|
+
console.log(formatTable(["Field", "Value"], [
|
|
71
|
+
["Project Path", projectPath],
|
|
72
|
+
["Fingerprint", fingerprint],
|
|
73
|
+
["Private Key", km.privateKeyPath],
|
|
74
|
+
["Public Key", km.publicKeyPath],
|
|
75
|
+
["Ledger", join(forgeoDir, "ledger.jsonl")],
|
|
76
|
+
]));
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
console.error(formatError(err));
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
// -------------------------------------------------------------------------
|
|
84
|
+
// trust verify [path]
|
|
85
|
+
// -------------------------------------------------------------------------
|
|
86
|
+
trust
|
|
87
|
+
.command("verify [path]")
|
|
88
|
+
.description("Verify chain integrity of the trust ledger")
|
|
89
|
+
.option("--json", "Output raw JSON")
|
|
90
|
+
.action(async (pathArg, opts) => {
|
|
91
|
+
try {
|
|
92
|
+
const projectPath = resolvePath(pathArg);
|
|
93
|
+
const ledger = new TrustLedger(projectPath);
|
|
94
|
+
const result = ledger.verifyChain();
|
|
95
|
+
if (opts.json) {
|
|
96
|
+
console.log(formatJSON(result));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (result.valid) {
|
|
100
|
+
console.log(formatSuccess(result.message));
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
console.log(formatWarning(result.message));
|
|
104
|
+
if (result.first_break_at !== null) {
|
|
105
|
+
console.log(formatStatus("First break at seq", String(result.first_break_at), "red"));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
console.log(formatTable(["Field", "Value"], [
|
|
109
|
+
["Total Entries", String(result.total_entries)],
|
|
110
|
+
["Chain Valid", result.valid ? green("yes") : red("no")],
|
|
111
|
+
["First Break At", result.first_break_at !== null ? String(result.first_break_at) : "—"],
|
|
112
|
+
]));
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
console.error(formatError(err));
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
// -------------------------------------------------------------------------
|
|
120
|
+
// trust stats [path]
|
|
121
|
+
// -------------------------------------------------------------------------
|
|
122
|
+
trust
|
|
123
|
+
.command("stats [path]")
|
|
124
|
+
.description("Show chain statistics for the trust ledger")
|
|
125
|
+
.option("--json", "Output raw JSON")
|
|
126
|
+
.action(async (pathArg, opts) => {
|
|
127
|
+
try {
|
|
128
|
+
const projectPath = resolvePath(pathArg);
|
|
129
|
+
const ledger = new TrustLedger(projectPath);
|
|
130
|
+
const stats = ledger.getChainStats();
|
|
131
|
+
if (opts.json) {
|
|
132
|
+
console.log(formatJSON(stats));
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const byTypeRows = Object.entries(stats.by_type).map(([type, count]) => [
|
|
136
|
+
type,
|
|
137
|
+
String(count),
|
|
138
|
+
]);
|
|
139
|
+
console.log(formatTable(["Field", "Value"], [
|
|
140
|
+
["Entry Count", String(stats.entry_count)],
|
|
141
|
+
["Chain Valid", stats.chain_valid ? green("yes") : red("no")],
|
|
142
|
+
["First Entry", stats.first_timestamp ?? "—"],
|
|
143
|
+
["Last Entry", stats.last_timestamp ?? "—"],
|
|
144
|
+
["Shareable Hash", stats.shareable_chain_hash?.substring(0, 16) ?? "—"],
|
|
145
|
+
]));
|
|
146
|
+
if (byTypeRows.length > 0) {
|
|
147
|
+
console.log("\nEntries by type:");
|
|
148
|
+
console.log(formatTable(["Type", "Count"], byTypeRows));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
console.error(formatError(err));
|
|
153
|
+
process.exit(1);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
// -------------------------------------------------------------------------
|
|
157
|
+
// trust share [path]
|
|
158
|
+
// -------------------------------------------------------------------------
|
|
159
|
+
trust
|
|
160
|
+
.command("share [path]")
|
|
161
|
+
.description("Transmit shareable trust metadata to a ForgeOS hub")
|
|
162
|
+
.option("--endpoint <url>", "Target endpoint URL", DEFAULT_TRUST_ENDPOINT)
|
|
163
|
+
.option("--yes", "Skip confirmation prompt (non-interactive)")
|
|
164
|
+
.option("--json", "Output raw JSON")
|
|
165
|
+
.action(async (pathArg, opts) => {
|
|
166
|
+
try {
|
|
167
|
+
const projectPath = resolvePath(pathArg);
|
|
168
|
+
const ledger = new TrustLedger(projectPath);
|
|
169
|
+
const entries = ledger.readEntries();
|
|
170
|
+
if (entries.length === 0) {
|
|
171
|
+
console.log(formatWarning("No entries in ledger — nothing to transmit."));
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const payload = prepareTransmission(entries);
|
|
175
|
+
const isTTY = process.stdout.isTTY;
|
|
176
|
+
if (!opts.yes) {
|
|
177
|
+
// Show manifest
|
|
178
|
+
if (isTTY) {
|
|
179
|
+
console.log(generateManifest(payload, opts.endpoint));
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
console.log(generatePlainManifest(payload, opts.endpoint));
|
|
183
|
+
}
|
|
184
|
+
const confirmed = await confirmPrompt("Proceed with transmission?");
|
|
185
|
+
if (!confirmed) {
|
|
186
|
+
console.log("Transmission cancelled.");
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const result = await sendTransmission(opts.endpoint, payload, projectPath, opts.yes ?? false);
|
|
191
|
+
if (opts.json) {
|
|
192
|
+
console.log(formatJSON(result));
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (result.status === "sent") {
|
|
196
|
+
console.log(formatSuccess(`Transmitted ${payload.entry_count} entries. HTTP ${result.http_status}.`));
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
console.log(formatWarning(`Transmission status: ${result.status}`));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
catch (err) {
|
|
203
|
+
console.error(formatError(err));
|
|
204
|
+
process.exit(1);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
// -------------------------------------------------------------------------
|
|
208
|
+
// trust config [path]
|
|
209
|
+
// -------------------------------------------------------------------------
|
|
210
|
+
trust
|
|
211
|
+
.command("config [path]")
|
|
212
|
+
.description("Show key configuration and ledger paths")
|
|
213
|
+
.option("--json", "Output raw JSON")
|
|
214
|
+
.action(async (pathArg, opts) => {
|
|
215
|
+
try {
|
|
216
|
+
const projectPath = resolvePath(pathArg);
|
|
217
|
+
const km = new KeyManager(projectPath);
|
|
218
|
+
const forgeoDir = join(projectPath, ".forgeos");
|
|
219
|
+
const ledgerPath = join(forgeoDir, "ledger.jsonl");
|
|
220
|
+
const keysExist = existsSync(km.privateKeyPath) && existsSync(km.publicKeyPath);
|
|
221
|
+
let fingerprint = "—";
|
|
222
|
+
if (keysExist) {
|
|
223
|
+
try {
|
|
224
|
+
fingerprint = km.getFingerprint();
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
fingerprint = "(error reading key)";
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const allowedEndpoints = loadAllowedEndpoints(projectPath);
|
|
231
|
+
if (opts.json) {
|
|
232
|
+
console.log(formatJSON({
|
|
233
|
+
project_path: projectPath,
|
|
234
|
+
keys_exist: keysExist,
|
|
235
|
+
fingerprint,
|
|
236
|
+
private_key: km.privateKeyPath,
|
|
237
|
+
public_key: km.publicKeyPath,
|
|
238
|
+
ledger_path: ledgerPath,
|
|
239
|
+
ledger_exists: existsSync(ledgerPath),
|
|
240
|
+
allowed_endpoints: allowedEndpoints,
|
|
241
|
+
}));
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
console.log(formatTable(["Field", "Value"], [
|
|
245
|
+
["Project Path", projectPath],
|
|
246
|
+
["Keys Exist", keysExist ? green("yes") : red("no — run: forge trust init")],
|
|
247
|
+
["Fingerprint", fingerprint],
|
|
248
|
+
["Private Key", km.privateKeyPath],
|
|
249
|
+
["Public Key", km.publicKeyPath],
|
|
250
|
+
["Ledger", ledgerPath],
|
|
251
|
+
["Ledger Exists", existsSync(ledgerPath) ? green("yes") : "no"],
|
|
252
|
+
["Allowed Endpoints", allowedEndpoints.join(", ") || "—"],
|
|
253
|
+
]));
|
|
254
|
+
}
|
|
255
|
+
catch (err) {
|
|
256
|
+
console.error(formatError(err));
|
|
257
|
+
process.exit(1);
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
//# sourceMappingURL=trust.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trust.js","sourceRoot":"","sources":["../../../src/cli/commands/trust.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,WAAW,EACX,UAAU,EACV,aAAa,EACb,aAAa,EACb,WAAW,EACX,YAAY,EACZ,KAAK,EACL,GAAG,GACJ,MAAM,cAAc,CAAC;AAEtB,MAAM,sBAAsB,GAC1B,iDAAiD,CAAC;AAEpD,oDAAoD;AACpD,SAAS,WAAW,CAAC,OAAgB;IACnC,OAAO,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED,kEAAkE;AAClE,KAAK,UAAU,aAAa,CAAC,QAAgB;IAC3C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,EAAE,GAAG,eAAe,CAAC;YACzB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;QACH,EAAE,CAAC,QAAQ,CAAC,GAAG,QAAQ,SAAS,EAAE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AS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;gBAC5E,CAAC,aAAa,EAAE,WAAW,CAAC;gBAC5B,CAAC,aAAa,EAAE,EAAE,CAAC,cAAc,CAAC;gBAClC,CAAC,YAAY,EAAE,EAAE,CAAC,aAAa,CAAC;gBAChC,CAAC,QAAQ,EAAE,UAAU,CAAC;gBACtB,CAAC,eAAe,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;gBAC/D,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;aAC1D,CACF,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,GAAY,CAAC,CAAC,CAAC;YACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `forge` CLI entry point — ForgeOS v2.0.0
|
|
4
|
+
*
|
|
5
|
+
* Engine URL resolution (first match wins):
|
|
6
|
+
* 1. FORGE_ENGINE_URL environment variable
|
|
7
|
+
* 2. ~/.forgeos/config.json → engine_url field
|
|
8
|
+
* 3. default: http://localhost:8000
|
|
9
|
+
*
|
|
10
|
+
* API key resolution (first match wins):
|
|
11
|
+
* 1. FORGE_API_KEY environment variable
|
|
12
|
+
* 2. ~/.forgeos/config.json → api_key field
|
|
13
|
+
*
|
|
14
|
+
* All command groups delegate to their respective modules in ./commands/.
|
|
15
|
+
* Trust and score commands are local-only; all others call the engine via
|
|
16
|
+
* ForgeOSClient (src/shared/client.ts).
|
|
17
|
+
*/
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;GAeG"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `forge` CLI entry point — ForgeOS v2.0.0
|
|
4
|
+
*
|
|
5
|
+
* Engine URL resolution (first match wins):
|
|
6
|
+
* 1. FORGE_ENGINE_URL environment variable
|
|
7
|
+
* 2. ~/.forgeos/config.json → engine_url field
|
|
8
|
+
* 3. default: http://localhost:8000
|
|
9
|
+
*
|
|
10
|
+
* API key resolution (first match wins):
|
|
11
|
+
* 1. FORGE_API_KEY environment variable
|
|
12
|
+
* 2. ~/.forgeos/config.json → api_key field
|
|
13
|
+
*
|
|
14
|
+
* All command groups delegate to their respective modules in ./commands/.
|
|
15
|
+
* Trust and score commands are local-only; all others call the engine via
|
|
16
|
+
* ForgeOSClient (src/shared/client.ts).
|
|
17
|
+
*/
|
|
18
|
+
import { readFileSync, existsSync } from "fs";
|
|
19
|
+
import { join } from "path";
|
|
20
|
+
import { homedir } from "os";
|
|
21
|
+
import { Command } from "commander";
|
|
22
|
+
import { ForgeOSClient } from "../shared/client.js";
|
|
23
|
+
import { registerProjectCommands } from "./commands/project.js";
|
|
24
|
+
import { registerInitiativeCommands } from "./commands/initiative.js";
|
|
25
|
+
import { registerChangesetCommands } from "./commands/changeset.js";
|
|
26
|
+
import { registerGateCommands } from "./commands/gate.js";
|
|
27
|
+
import { registerEvidenceCommands } from "./commands/evidence.js";
|
|
28
|
+
import { registerReviewCommands } from "./commands/review.js";
|
|
29
|
+
import { registerSessionCommands } from "./commands/session.js";
|
|
30
|
+
import { registerMindCommands } from "./commands/mind.js";
|
|
31
|
+
import { registerTrustCommands } from "./commands/trust.js";
|
|
32
|
+
import { registerFederationCommands } from "./commands/federation.js";
|
|
33
|
+
import { registerAnalyzeCommands } from "./commands/analyze.js";
|
|
34
|
+
import { registerScoreCommands } from "./commands/score.js";
|
|
35
|
+
import { registerBuildCommands } from "./commands/build.js";
|
|
36
|
+
import { registerOutcomeCommands } from "./commands/outcome.js";
|
|
37
|
+
function loadConfig() {
|
|
38
|
+
const configPath = join(homedir(), ".forgeos", "config.json");
|
|
39
|
+
if (!existsSync(configPath))
|
|
40
|
+
return {};
|
|
41
|
+
try {
|
|
42
|
+
const raw = readFileSync(configPath, "utf8");
|
|
43
|
+
return JSON.parse(raw);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// Credential resolution
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
const config = loadConfig();
|
|
53
|
+
const engineUrl = process.env.FORGE_ENGINE_URL ??
|
|
54
|
+
config.engine_url ??
|
|
55
|
+
"http://localhost:8000";
|
|
56
|
+
const apiKey = process.env.FORGE_API_KEY ??
|
|
57
|
+
config.api_key ??
|
|
58
|
+
"";
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
// Build ForgeOSClient shared instance
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
const client = new ForgeOSClient(engineUrl, apiKey);
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
// Root program
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
const program = new Command();
|
|
67
|
+
program
|
|
68
|
+
.name("forge")
|
|
69
|
+
.description("ForgeOS CLI — governance, memory, and trust for AI-powered teams")
|
|
70
|
+
.version("2.0.0")
|
|
71
|
+
.addHelpText("after", `
|
|
72
|
+
Engine: ${engineUrl}
|
|
73
|
+
Auth: ${apiKey ? "API key set" : "no API key (set FORGE_API_KEY or ~/.forgeos/config.json)"}
|
|
74
|
+
`);
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
// Register all command groups
|
|
77
|
+
// ---------------------------------------------------------------------------
|
|
78
|
+
registerProjectCommands(program, client);
|
|
79
|
+
registerInitiativeCommands(program, client);
|
|
80
|
+
registerChangesetCommands(program, client);
|
|
81
|
+
registerGateCommands(program, client);
|
|
82
|
+
registerEvidenceCommands(program, client);
|
|
83
|
+
registerReviewCommands(program, client);
|
|
84
|
+
registerSessionCommands(program, client);
|
|
85
|
+
registerMindCommands(program, client);
|
|
86
|
+
registerTrustCommands(program, client);
|
|
87
|
+
registerFederationCommands(program, client);
|
|
88
|
+
registerAnalyzeCommands(program, client);
|
|
89
|
+
registerScoreCommands(program, client);
|
|
90
|
+
registerBuildCommands(program, client);
|
|
91
|
+
registerOutcomeCommands(program, client);
|
|
92
|
+
// ---------------------------------------------------------------------------
|
|
93
|
+
// Parse
|
|
94
|
+
// ---------------------------------------------------------------------------
|
|
95
|
+
program.parseAsync(process.argv).catch((err) => {
|
|
96
|
+
console.error(err.message);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
});
|
|
99
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,uBAAuB,EAAE,MAAS,uBAAuB,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAO,yBAAyB,C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A8E;AAC9E,QAAQ;AACR,8EAA8E;AAE9E,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAU,EAAE,EAAE;IACpD,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC3B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal output formatting helpers for the `forge` CLI.
|
|
3
|
+
*
|
|
4
|
+
* All formatting is done via ANSI escape codes — no external colour libraries.
|
|
5
|
+
* Respects the NO_COLOR environment variable (https://no-color.org/).
|
|
6
|
+
*/
|
|
7
|
+
import { ForgeAPIError } from "../shared/errors.js";
|
|
8
|
+
export declare const green: (t: string) => string;
|
|
9
|
+
export declare const yellow: (t: string) => string;
|
|
10
|
+
export declare const red: (t: string) => string;
|
|
11
|
+
export declare const cyan: (t: string) => string;
|
|
12
|
+
export declare const bold: (t: string) => string;
|
|
13
|
+
export declare const dim: (t: string) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Render a table with a header row and data rows.
|
|
16
|
+
*
|
|
17
|
+
* Example:
|
|
18
|
+
* formatTable(["ID", "Name"], [["abc", "My project"], ["def", "Other"]])
|
|
19
|
+
*
|
|
20
|
+
* Produces:
|
|
21
|
+
* ┌─────┬────────────┐
|
|
22
|
+
* │ ID │ Name │
|
|
23
|
+
* ├─────┼────────────┤
|
|
24
|
+
* │ abc │ My project │
|
|
25
|
+
* │ def │ Other │
|
|
26
|
+
* └─────┴────────────┘
|
|
27
|
+
*/
|
|
28
|
+
export declare function formatTable(headers: string[], rows: string[][]): string;
|
|
29
|
+
/** Pretty-print any value as indented JSON. */
|
|
30
|
+
export declare function formatJSON(data: unknown): string;
|
|
31
|
+
/**
|
|
32
|
+
* A single labelled status line.
|
|
33
|
+
*
|
|
34
|
+
* Example: formatStatus("Status", "active", "green") → "Status: active" (coloured)
|
|
35
|
+
*/
|
|
36
|
+
export declare function formatStatus(label: string, value: string, color?: string): string;
|
|
37
|
+
/** Green checkmark prefix. */
|
|
38
|
+
export declare function formatSuccess(message: string): string;
|
|
39
|
+
/** Yellow warning prefix. */
|
|
40
|
+
export declare function formatWarning(message: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Structured error display.
|
|
43
|
+
*
|
|
44
|
+
* For ForgeAPIError: shows HTTP status, detail, context, and suggestion.
|
|
45
|
+
* For generic Error: shows message.
|
|
46
|
+
*/
|
|
47
|
+
export declare function formatError(error: ForgeAPIError | Error): string;
|
|
48
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAapD,eAAO,MAAM,KAAK,GAAI,GAAG,MAAM,WAAkB,CAAC;AAClD,eAAO,MAAM,MAAM,GAAI,GAAG,MAAM,WAAkB,CAAC;AACnD,eAAO,MAAM,GAAG,GAAI,GAAG,MAAM,WAAkB,CAAC;AAChD,eAAO,MAAM,IAAI,GAAI,GAAG,MAAM,WAAkB,CAAC;AACjD,eAAO,MAAM,IAAI,GAAI,GAAG,MAAM,WAAiB,CAAC;AAChD,eAAO,MAAM,GAAG,GAAI,GAAG,MAAM,WAAiB,CAAC;AAqB/C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,CAuCvE;AAMD,+CAA+C;AAC/C,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAEhD;AAMD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAEjF;AAMD,8BAA8B;AAC9B,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,6BAA6B;AAC7B,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,KAAK,GAAG,MAAM,CAkBhE"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal output formatting helpers for the `forge` CLI.
|
|
3
|
+
*
|
|
4
|
+
* All formatting is done via ANSI escape codes — no external colour libraries.
|
|
5
|
+
* Respects the NO_COLOR environment variable (https://no-color.org/).
|
|
6
|
+
*/
|
|
7
|
+
import { ForgeAPIError } from "../shared/errors.js";
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// ANSI colour helpers
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
const NO_COLOR = process.env.NO_COLOR !== undefined;
|
|
12
|
+
function ansi(code, text) {
|
|
13
|
+
if (NO_COLOR)
|
|
14
|
+
return text;
|
|
15
|
+
return `\x1b[${code}m${text}\x1b[0m`;
|
|
16
|
+
}
|
|
17
|
+
export const green = (t) => ansi("32", t);
|
|
18
|
+
export const yellow = (t) => ansi("33", t);
|
|
19
|
+
export const red = (t) => ansi("31", t);
|
|
20
|
+
export const cyan = (t) => ansi("36", t);
|
|
21
|
+
export const bold = (t) => ansi("1", t);
|
|
22
|
+
export const dim = (t) => ansi("2", t);
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// Named colour selector (used by formatStatus)
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
function colorize(text, color) {
|
|
27
|
+
switch (color) {
|
|
28
|
+
case "green": return green(text);
|
|
29
|
+
case "yellow": return yellow(text);
|
|
30
|
+
case "red": return red(text);
|
|
31
|
+
case "cyan": return cyan(text);
|
|
32
|
+
case "bold": return bold(text);
|
|
33
|
+
default: return text;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
// Table formatter
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
/**
|
|
40
|
+
* Render a table with a header row and data rows.
|
|
41
|
+
*
|
|
42
|
+
* Example:
|
|
43
|
+
* formatTable(["ID", "Name"], [["abc", "My project"], ["def", "Other"]])
|
|
44
|
+
*
|
|
45
|
+
* Produces:
|
|
46
|
+
* ┌─────┬────────────┐
|
|
47
|
+
* │ ID │ Name │
|
|
48
|
+
* ├─────┼────────────┤
|
|
49
|
+
* │ abc │ My project │
|
|
50
|
+
* │ def │ Other │
|
|
51
|
+
* └─────┴────────────┘
|
|
52
|
+
*/
|
|
53
|
+
export function formatTable(headers, rows) {
|
|
54
|
+
const colCount = headers.length;
|
|
55
|
+
// Compute column widths: max of header width and all row cell widths
|
|
56
|
+
const widths = headers.map((h) => h.length);
|
|
57
|
+
for (const row of rows) {
|
|
58
|
+
for (let i = 0; i < colCount; i++) {
|
|
59
|
+
const cell = row[i] ?? "";
|
|
60
|
+
if (cell.length > widths[i])
|
|
61
|
+
widths[i] = cell.length;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const pad = (s, w) => s.padEnd(w);
|
|
65
|
+
const hLine = (left, mid, right, fill) => left + widths.map((w) => fill.repeat(w + 2)).join(mid) + right;
|
|
66
|
+
const top = hLine("┌", "┬", "┐", "─");
|
|
67
|
+
const divider = hLine("├", "┼", "┤", "─");
|
|
68
|
+
const bottom = hLine("└", "┴", "┘", "─");
|
|
69
|
+
const renderRow = (cells, colorFn) => {
|
|
70
|
+
const line = "│ " +
|
|
71
|
+
cells
|
|
72
|
+
.map((c, i) => pad(c ?? "", widths[i]))
|
|
73
|
+
.join(" │ ") +
|
|
74
|
+
" │";
|
|
75
|
+
return colorFn ? colorFn(line) : line;
|
|
76
|
+
};
|
|
77
|
+
const lines = [
|
|
78
|
+
top,
|
|
79
|
+
renderRow(headers, bold),
|
|
80
|
+
divider,
|
|
81
|
+
...rows.map((r) => renderRow(r)),
|
|
82
|
+
bottom,
|
|
83
|
+
];
|
|
84
|
+
return lines.join("\n");
|
|
85
|
+
}
|
|
86
|
+
// ---------------------------------------------------------------------------
|
|
87
|
+
// JSON formatter
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
/** Pretty-print any value as indented JSON. */
|
|
90
|
+
export function formatJSON(data) {
|
|
91
|
+
return JSON.stringify(data, null, 2);
|
|
92
|
+
}
|
|
93
|
+
// ---------------------------------------------------------------------------
|
|
94
|
+
// Status line
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
/**
|
|
97
|
+
* A single labelled status line.
|
|
98
|
+
*
|
|
99
|
+
* Example: formatStatus("Status", "active", "green") → "Status: active" (coloured)
|
|
100
|
+
*/
|
|
101
|
+
export function formatStatus(label, value, color) {
|
|
102
|
+
return `${bold(label + ":")} ${colorize(value, color)}`;
|
|
103
|
+
}
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
// Success / warning / error banners
|
|
106
|
+
// ---------------------------------------------------------------------------
|
|
107
|
+
/** Green checkmark prefix. */
|
|
108
|
+
export function formatSuccess(message) {
|
|
109
|
+
return `${green("✓")} ${message}`;
|
|
110
|
+
}
|
|
111
|
+
/** Yellow warning prefix. */
|
|
112
|
+
export function formatWarning(message) {
|
|
113
|
+
return `${yellow("⚠")} ${message}`;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Structured error display.
|
|
117
|
+
*
|
|
118
|
+
* For ForgeAPIError: shows HTTP status, detail, context, and suggestion.
|
|
119
|
+
* For generic Error: shows message.
|
|
120
|
+
*/
|
|
121
|
+
export function formatError(error) {
|
|
122
|
+
if (error instanceof ForgeAPIError) {
|
|
123
|
+
const lines = [
|
|
124
|
+
`${red("✗")} ${bold("Error " + error.status + ":")} ${error.detail}`,
|
|
125
|
+
];
|
|
126
|
+
if (error.context && Object.keys(error.context).length > 0) {
|
|
127
|
+
lines.push(dim(" Context: " + JSON.stringify(error.context)));
|
|
128
|
+
}
|
|
129
|
+
if (error.suggestion) {
|
|
130
|
+
lines.push(yellow(" Suggestion: " + error.suggestion));
|
|
131
|
+
}
|
|
132
|
+
if (error.docsUrl) {
|
|
133
|
+
lines.push(cyan(" Docs: " + error.docsUrl));
|
|
134
|
+
}
|
|
135
|
+
return lines.join("\n");
|
|
136
|
+
}
|
|
137
|
+
return `${red("✗")} ${error.message}`;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC;AAEpD,SAAS,IAAI,CAAC,IAAY,EAAE,IAAY;IACtC,IAAI,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC1B,OAAO,QAAQ,IAAI,IAAI,IAAI,SAAS,CAAC;AACvC,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAClD,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AACnD,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAChD,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,E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rE,CAAC;QACF,IAAI,KAAK,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3D,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;YACrB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;QAC1D,CAAC;QACD,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YAClB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;AACxC,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ForgeOS Engine HTTP client.
|
|
3
|
+
* Thin wrapper over fetch() that calls the ForgeOS Engine REST API.
|
|
4
|
+
*
|
|
5
|
+
* Board Conditions (Engineering Director):
|
|
6
|
+
* - 10-second timeout per request (AbortController)
|
|
7
|
+
* - One automatic retry on network errors (fetch failures, not HTTP errors)
|
|
8
|
+
* - X-ForgeOS-API-Key header when apiKey is provided
|
|
9
|
+
*
|
|
10
|
+
* Design note: API key is accepted only as a constructor parameter.
|
|
11
|
+
* The module-level singleton `client` uses env vars for backward-compat
|
|
12
|
+
* with the stdio transport. The HTTP transport creates per-request instances
|
|
13
|
+
* with the key threaded from the Authorization header — no env mutation.
|
|
14
|
+
*/
|
|
15
|
+
export declare class ForgeOSClient {
|
|
16
|
+
private baseUrl;
|
|
17
|
+
private apiKey;
|
|
18
|
+
/**
|
|
19
|
+
* @param baseUrl Engine base URL. Defaults to FORGEOS_ENGINE_URL env var or http://localhost:8400.
|
|
20
|
+
* @param apiKey API key to send as X-ForgeOS-API-Key. Pass explicitly; do NOT read from env here.
|
|
21
|
+
*/
|
|
22
|
+
constructor(baseUrl?: string, apiKey?: string);
|
|
23
|
+
/** Build common headers for every request. */
|
|
24
|
+
private headers;
|
|
25
|
+
/**
|
|
26
|
+
* Core fetch wrapper with timeout and retry.
|
|
27
|
+
* - Aborts after REQUEST_TIMEOUT_MS via AbortController.
|
|
28
|
+
* - Retries once on network errors (TypeError from fetch).
|
|
29
|
+
* - Does NOT retry on HTTP error responses (4xx/5xx) or timeouts.
|
|
30
|
+
*/
|
|
31
|
+
private fetchWithRetry;
|
|
32
|
+
/** Parse a non-ok response into a descriptive error. */
|
|
33
|
+
private throwHttpError;
|
|
34
|
+
get(path: string, params?: Record<string, string>): Promise<unknown>;
|
|
35
|
+
post(path: string, body?: unknown): Promise<unknown>;
|
|
36
|
+
patch(path: string, body?: unknown): Promise<unknown>;
|
|
37
|
+
put(path: string, body?: unknown): Promise<unknown>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Module-level singleton for the stdio transport path.
|
|
41
|
+
* Reads FORGEOS_API_KEY from env at startup — safe because stdio is
|
|
42
|
+
* single-tenant (one process = one user). The HTTP transport MUST NOT
|
|
43
|
+
* use this singleton; it must construct per-request ForgeOSClient instances.
|
|
44
|
+
*/
|
|
45
|
+
export declare const client: ForgeOSClient;
|
|
46
|
+
//# sourceMappingURL=client.d.ts.map
|