cngkit 1.1.17 → 1.1.19

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 (76) hide show
  1. package/README.md +100 -7
  2. package/dist/chunk-3A6GRNEV.js +1590 -0
  3. package/dist/chunk-3A6GRNEV.js.map +1 -0
  4. package/dist/{chunk-HRFI2IEP.js → chunk-7SO75QXJ.js} +886 -68
  5. package/dist/chunk-7SO75QXJ.js.map +1 -0
  6. package/dist/chunk-DBA3BZXP.js +231 -0
  7. package/dist/chunk-DBA3BZXP.js.map +1 -0
  8. package/dist/{chunk-5ZNV3FDG.js → chunk-GBONV6XP.js} +16 -4
  9. package/dist/chunk-GBONV6XP.js.map +1 -0
  10. package/dist/chunk-L6ZVQRSY.js +569 -0
  11. package/dist/chunk-L6ZVQRSY.js.map +1 -0
  12. package/dist/{chunk-VCWNKNUE.js → chunk-NGEWD4BW.js} +10 -1
  13. package/dist/chunk-NGEWD4BW.js.map +1 -0
  14. package/dist/chunk-TYDIBWZV.js +35 -0
  15. package/dist/chunk-TYDIBWZV.js.map +1 -0
  16. package/dist/{chunk-GT2MTS6E.js → chunk-X4E7NAN4.js} +2 -2
  17. package/dist/cli.js +82 -16
  18. package/dist/cli.js.map +1 -1
  19. package/dist/commands/coderoom/index.js +6 -6
  20. package/dist/commands/coderoom/index.js.map +1 -1
  21. package/dist/commands/coderoom/join.js +5 -5
  22. package/dist/commands/coderoom/share.js +5 -5
  23. package/dist/commands/hookify/index.js +25 -0
  24. package/dist/commands/hookify/index.js.map +1 -0
  25. package/dist/commands/hookify/ingest.js +127 -0
  26. package/dist/commands/hookify/ingest.js.map +1 -0
  27. package/dist/commands/hooks/index.js +25 -0
  28. package/dist/commands/hooks/index.js.map +1 -0
  29. package/dist/commands/hooks/install.js +40 -0
  30. package/dist/commands/hooks/install.js.map +1 -0
  31. package/dist/commands/hooks/uninstall.js +40 -0
  32. package/dist/commands/hooks/uninstall.js.map +1 -0
  33. package/dist/commands/index.js +5 -5
  34. package/dist/commands/index.js.map +1 -1
  35. package/dist/commands/knowledges/audiences.js +6 -6
  36. package/dist/commands/knowledges/cat.js +31 -0
  37. package/dist/commands/knowledges/cat.js.map +1 -0
  38. package/dist/commands/knowledges/files.js +6 -6
  39. package/dist/commands/knowledges/find.js +66 -0
  40. package/dist/commands/knowledges/find.js.map +1 -0
  41. package/dist/commands/knowledges/glob.js +6 -6
  42. package/dist/commands/knowledges/grep.js +6 -6
  43. package/dist/commands/knowledges/head.js +41 -0
  44. package/dist/commands/knowledges/head.js.map +1 -0
  45. package/dist/commands/knowledges/index.js +6 -6
  46. package/dist/commands/knowledges/index.js.map +1 -1
  47. package/dist/commands/knowledges/list.js +7 -7
  48. package/dist/commands/knowledges/list.js.map +1 -1
  49. package/dist/commands/knowledges/ls.js +40 -0
  50. package/dist/commands/knowledges/ls.js.map +1 -0
  51. package/dist/commands/knowledges/read.js +6 -6
  52. package/dist/commands/knowledges/realpath.js +31 -0
  53. package/dist/commands/knowledges/realpath.js.map +1 -0
  54. package/dist/commands/knowledges/search.js +6 -6
  55. package/dist/commands/knowledges/stat.js +31 -0
  56. package/dist/commands/knowledges/stat.js.map +1 -0
  57. package/dist/commands/knowledges/status.js +6 -6
  58. package/dist/commands/knowledges/tail.js +41 -0
  59. package/dist/commands/knowledges/tail.js.map +1 -0
  60. package/dist/commands/knowledges/tree.js +46 -0
  61. package/dist/commands/knowledges/tree.js.map +1 -0
  62. package/dist/commands/login.js +3 -3
  63. package/dist/commands/scrub.js +3 -3
  64. package/dist/commands/transcripts.js +6 -6
  65. package/dist/commands/transcripts.js.map +1 -1
  66. package/package.json +2 -2
  67. package/dist/chunk-5ZNV3FDG.js.map +0 -1
  68. package/dist/chunk-BL3XMLIH.js +0 -573
  69. package/dist/chunk-BL3XMLIH.js.map +0 -1
  70. package/dist/chunk-HRFI2IEP.js.map +0 -1
  71. package/dist/chunk-K36DKQWH.js +0 -327
  72. package/dist/chunk-K36DKQWH.js.map +0 -1
  73. package/dist/chunk-VCWNKNUE.js.map +0 -1
  74. package/dist/chunk-WYJTGGMN.js +0 -222
  75. package/dist/chunk-WYJTGGMN.js.map +0 -1
  76. /package/dist/{chunk-GT2MTS6E.js.map → chunk-X4E7NAN4.js.map} +0 -0
@@ -1,10 +1,44 @@
1
- import {
2
- resolveApiBaseUrl
3
- } from "./chunk-WYJTGGMN.js";
4
1
  import {
5
2
  __export
6
3
  } from "./chunk-PZ5AY32C.js";
7
4
 
5
+ // src/shared/config.ts
6
+ import { randomBytes, randomUUID } from "crypto";
7
+ import process2 from "process";
8
+ var packageVersion = "1.1.19";
9
+ var defaultApiBaseUrl = "https://curly.ng";
10
+ function resolveApiBaseUrl(options) {
11
+ void options;
12
+ return defaultApiBaseUrl;
13
+ }
14
+ function resolveOutputFormat() {
15
+ const value = process2.env.CNGKIT_FORMAT?.toLowerCase();
16
+ if (value === "json" || value === "markdown") {
17
+ return value;
18
+ }
19
+ return "text";
20
+ }
21
+ function parseOutputFormat(value) {
22
+ const normalizedValue = value.toLowerCase();
23
+ if (normalizedValue === "text" || normalizedValue === "json" || normalizedValue === "markdown") {
24
+ return normalizedValue;
25
+ }
26
+ throw new Error("Unknown --format value. Use one of: text, json, markdown.");
27
+ }
28
+ function createRoomCode() {
29
+ return randomBytes(4).toString("hex").toUpperCase();
30
+ }
31
+ function createPeerId() {
32
+ return randomUUID();
33
+ }
34
+
35
+ // src/shared/output.ts
36
+ import process3 from "process";
37
+ import { createElement } from "react";
38
+ import { renderToString, Text } from "ink";
39
+ import Markdown from "@inkkit/ink-markdown";
40
+ import stripAnsi from "strip-ansi";
41
+
8
42
  // ../../packages/client/src/generated/core/json.ts
9
43
  var toJson = (value, replacer, space) => {
10
44
  return JSON.stringify(value, replacer, space);
@@ -298,6 +332,28 @@ var HarnessSemanticSearchResponse;
298
332
  };
299
333
  })(HarnessSemanticSearchResponse || (HarnessSemanticSearchResponse = {}));
300
334
 
335
+ // ../../packages/client/src/generated/api/types/HookifyIngestResponse.ts
336
+ var HookifyIngestResponse;
337
+ ((HookifyIngestResponse2) => {
338
+ HookifyIngestResponse2.Mode = {
339
+ Sync: "sync",
340
+ Async: "async"
341
+ };
342
+ HookifyIngestResponse2.Status = {
343
+ Completed: "completed",
344
+ Pending: "pending"
345
+ };
346
+ })(HookifyIngestResponse || (HookifyIngestResponse = {}));
347
+
348
+ // ../../packages/client/src/generated/api/types/HookifyRequestResponse.ts
349
+ var HookifyRequestResponse;
350
+ ((HookifyRequestResponse2) => {
351
+ HookifyRequestResponse2.Status = {
352
+ Completed: "completed",
353
+ Pending: "pending"
354
+ };
355
+ })(HookifyRequestResponse || (HookifyRequestResponse = {}));
356
+
301
357
  // ../../packages/client/src/generated/core/headers.ts
302
358
  function mergeHeaders(...headersArray) {
303
359
  const result = {};
@@ -1447,6 +1503,174 @@ async function makePassthroughRequest(input, init, clientOptions, requestOptions
1447
1503
  return response;
1448
1504
  }
1449
1505
 
1506
+ // ../../packages/client/src/generated/core/file/index.ts
1507
+ var file_exports = {};
1508
+ __export(file_exports, {
1509
+ toBinaryUploadRequest: () => toBinaryUploadRequest,
1510
+ toMultipartDataPart: () => toMultipartDataPart
1511
+ });
1512
+
1513
+ // ../../packages/client/src/generated/core/file/file.ts
1514
+ async function toBinaryUploadRequest(file) {
1515
+ const { data, filename, contentLength, contentType } = await getFileWithMetadata(file);
1516
+ const request = {
1517
+ body: data,
1518
+ headers: {}
1519
+ };
1520
+ if (filename) {
1521
+ request.headers["Content-Disposition"] = `attachment; filename="${filename}"`;
1522
+ }
1523
+ if (contentType) {
1524
+ request.headers["Content-Type"] = contentType;
1525
+ }
1526
+ if (contentLength != null) {
1527
+ request.headers["Content-Length"] = contentLength.toString();
1528
+ }
1529
+ return request;
1530
+ }
1531
+ async function toMultipartDataPart(file) {
1532
+ const { data, filename, contentType } = await getFileWithMetadata(file, {
1533
+ noSniffFileSize: true
1534
+ });
1535
+ return {
1536
+ data,
1537
+ filename,
1538
+ contentType
1539
+ };
1540
+ }
1541
+ async function getFileWithMetadata(file, { noSniffFileSize } = {}) {
1542
+ if (isFileLike(file)) {
1543
+ return getFileWithMetadata(
1544
+ {
1545
+ data: file
1546
+ },
1547
+ { noSniffFileSize }
1548
+ );
1549
+ }
1550
+ if ("path" in file) {
1551
+ const fs = await import("fs");
1552
+ if (!fs?.createReadStream) {
1553
+ throw new Error("File path uploads are not supported in this environment.");
1554
+ }
1555
+ const data = fs.createReadStream(file.path);
1556
+ const contentLength = file.contentLength ?? (noSniffFileSize === true ? void 0 : await tryGetFileSizeFromPath(file.path));
1557
+ const filename = file.filename ?? getNameFromPath(file.path);
1558
+ return {
1559
+ data,
1560
+ filename,
1561
+ contentType: file.contentType,
1562
+ contentLength
1563
+ };
1564
+ }
1565
+ if ("data" in file) {
1566
+ const data = file.data;
1567
+ const contentLength = file.contentLength ?? await tryGetContentLengthFromFileLike(data, {
1568
+ noSniffFileSize
1569
+ });
1570
+ const filename = file.filename ?? tryGetNameFromFileLike(data);
1571
+ return {
1572
+ data,
1573
+ filename,
1574
+ contentType: file.contentType ?? tryGetContentTypeFromFileLike(data),
1575
+ contentLength
1576
+ };
1577
+ }
1578
+ throw new Error(`Invalid FileUpload of type ${typeof file}: ${JSON.stringify(file)}`);
1579
+ }
1580
+ function isFileLike(value) {
1581
+ return isBuffer(value) || isArrayBufferView(value) || isArrayBuffer(value) || isUint8Array(value) || isBlob(value) || isFile(value) || isStreamLike(value) || isReadableStream(value);
1582
+ }
1583
+ async function tryGetFileSizeFromPath(path) {
1584
+ try {
1585
+ const fs = await import("fs");
1586
+ if (!fs?.promises?.stat) {
1587
+ return void 0;
1588
+ }
1589
+ const fileStat = await fs.promises.stat(path);
1590
+ return fileStat.size;
1591
+ } catch (_fallbackError) {
1592
+ return void 0;
1593
+ }
1594
+ }
1595
+ function tryGetNameFromFileLike(data) {
1596
+ if (isNamedValue(data)) {
1597
+ return data.name;
1598
+ }
1599
+ if (isPathedValue(data)) {
1600
+ return getNameFromPath(data.path.toString());
1601
+ }
1602
+ return void 0;
1603
+ }
1604
+ async function tryGetContentLengthFromFileLike(data, { noSniffFileSize } = {}) {
1605
+ if (isBuffer(data)) {
1606
+ return data.length;
1607
+ }
1608
+ if (isArrayBufferView(data)) {
1609
+ return data.byteLength;
1610
+ }
1611
+ if (isArrayBuffer(data)) {
1612
+ return data.byteLength;
1613
+ }
1614
+ if (isBlob(data)) {
1615
+ return data.size;
1616
+ }
1617
+ if (isFile(data)) {
1618
+ return data.size;
1619
+ }
1620
+ if (noSniffFileSize === true) {
1621
+ return void 0;
1622
+ }
1623
+ if (isPathedValue(data)) {
1624
+ return await tryGetFileSizeFromPath(data.path.toString());
1625
+ }
1626
+ return void 0;
1627
+ }
1628
+ function tryGetContentTypeFromFileLike(data) {
1629
+ if (isBlob(data)) {
1630
+ return data.type;
1631
+ }
1632
+ if (isFile(data)) {
1633
+ return data.type;
1634
+ }
1635
+ return void 0;
1636
+ }
1637
+ function getNameFromPath(path) {
1638
+ const lastForwardSlash = path.lastIndexOf("/");
1639
+ const lastBackSlash = path.lastIndexOf("\\");
1640
+ const lastSlashIndex = Math.max(lastForwardSlash, lastBackSlash);
1641
+ return lastSlashIndex >= 0 ? path.substring(lastSlashIndex + 1) : path;
1642
+ }
1643
+ function isNamedValue(value) {
1644
+ return typeof value === "object" && value != null && "name" in value;
1645
+ }
1646
+ function isPathedValue(value) {
1647
+ return typeof value === "object" && value != null && "path" in value;
1648
+ }
1649
+ function isStreamLike(value) {
1650
+ return typeof value === "object" && value != null && ("read" in value || "pipe" in value);
1651
+ }
1652
+ function isReadableStream(value) {
1653
+ return typeof value === "object" && value != null && "getReader" in value;
1654
+ }
1655
+ function isBuffer(value) {
1656
+ return typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(value);
1657
+ }
1658
+ function isArrayBufferView(value) {
1659
+ return typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView(value);
1660
+ }
1661
+ function isArrayBuffer(value) {
1662
+ return typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer;
1663
+ }
1664
+ function isUint8Array(value) {
1665
+ return typeof Uint8Array !== "undefined" && value instanceof Uint8Array;
1666
+ }
1667
+ function isBlob(value) {
1668
+ return typeof Blob !== "undefined" && value instanceof Blob;
1669
+ }
1670
+ function isFile(value) {
1671
+ return typeof File !== "undefined" && value instanceof File;
1672
+ }
1673
+
1450
1674
  // ../../packages/client/src/generated/core/logging/index.ts
1451
1675
  var logging_exports = {};
1452
1676
  __export(logging_exports, {
@@ -1964,6 +2188,70 @@ var HarnessFilesystemClient = class {
1964
2188
  }
1965
2189
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/api/harness/filesystem/read");
1966
2190
  }
2191
+ /**
2192
+ * @param {CngApi.GetHarnessFilesystemTailRequest} request
2193
+ * @param {HarnessFilesystemClient.RequestOptions} requestOptions - Request-specific configuration.
2194
+ *
2195
+ * @throws {@link CngApi.BadRequestError}
2196
+ * @throws {@link CngApi.NotFoundError}
2197
+ * @throws {@link CngApi.ContentTooLargeError}
2198
+ *
2199
+ * @example
2200
+ * await client.harnessFilesystem.getHarnessFilesystemTail({
2201
+ * file_path: "file_path"
2202
+ * })
2203
+ */
2204
+ getHarnessFilesystemTail(request, requestOptions) {
2205
+ return HttpResponsePromise.fromPromise(this.__getHarnessFilesystemTail(request, requestOptions));
2206
+ }
2207
+ async __getHarnessFilesystemTail(request, requestOptions) {
2208
+ const { file_path: filePath, lines } = request;
2209
+ const _queryParams = {
2210
+ file_path: filePath,
2211
+ lines
2212
+ };
2213
+ const _headers = mergeHeaders(this._options?.headers, requestOptions?.headers);
2214
+ const _response = await fetcher({
2215
+ url: url_exports.join(
2216
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment) ?? CngApiEnvironment.Default,
2217
+ "api/harness/filesystem/tail"
2218
+ ),
2219
+ method: "GET",
2220
+ headers: _headers,
2221
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
2222
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
2223
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
2224
+ abortSignal: requestOptions?.abortSignal,
2225
+ fetchFn: this._options?.fetch,
2226
+ logging: this._options.logging
2227
+ });
2228
+ if (_response.ok) {
2229
+ return {
2230
+ data: _response.body,
2231
+ rawResponse: _response.rawResponse
2232
+ };
2233
+ }
2234
+ if (_response.error.reason === "status-code") {
2235
+ switch (_response.error.statusCode) {
2236
+ case 400:
2237
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
2238
+ case 404:
2239
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
2240
+ case 413:
2241
+ throw new ContentTooLargeError(
2242
+ _response.error.body,
2243
+ _response.rawResponse
2244
+ );
2245
+ default:
2246
+ throw new CngApiError({
2247
+ statusCode: _response.error.statusCode,
2248
+ body: _response.error.body,
2249
+ rawResponse: _response.rawResponse
2250
+ });
2251
+ }
2252
+ }
2253
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/api/harness/filesystem/tail");
2254
+ }
1967
2255
  /**
1968
2256
  * @param {CngApi.GetHarnessFilesystemGrepRequest} request
1969
2257
  * @param {HarnessFilesystemClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -2072,6 +2360,226 @@ var HarnessFilesystemClient = class {
2072
2360
  }
2073
2361
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/api/harness/filesystem/glob");
2074
2362
  }
2363
+ /**
2364
+ * @param {CngApi.GetHarnessFilesystemLsRequest} request
2365
+ * @param {HarnessFilesystemClient.RequestOptions} requestOptions - Request-specific configuration.
2366
+ *
2367
+ * @throws {@link CngApi.BadRequestError}
2368
+ *
2369
+ * @example
2370
+ * await client.harnessFilesystem.getHarnessFilesystemLs()
2371
+ */
2372
+ getHarnessFilesystemLs(request = {}, requestOptions) {
2373
+ return HttpResponsePromise.fromPromise(this.__getHarnessFilesystemLs(request, requestOptions));
2374
+ }
2375
+ async __getHarnessFilesystemLs(request = {}, requestOptions) {
2376
+ const { path, limit } = request;
2377
+ const _queryParams = {
2378
+ path,
2379
+ limit
2380
+ };
2381
+ const _headers = mergeHeaders(this._options?.headers, requestOptions?.headers);
2382
+ const _response = await fetcher({
2383
+ url: url_exports.join(
2384
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment) ?? CngApiEnvironment.Default,
2385
+ "api/harness/filesystem/ls"
2386
+ ),
2387
+ method: "GET",
2388
+ headers: _headers,
2389
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
2390
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
2391
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
2392
+ abortSignal: requestOptions?.abortSignal,
2393
+ fetchFn: this._options?.fetch,
2394
+ logging: this._options.logging
2395
+ });
2396
+ if (_response.ok) {
2397
+ return {
2398
+ data: _response.body,
2399
+ rawResponse: _response.rawResponse
2400
+ };
2401
+ }
2402
+ if (_response.error.reason === "status-code") {
2403
+ switch (_response.error.statusCode) {
2404
+ case 400:
2405
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
2406
+ default:
2407
+ throw new CngApiError({
2408
+ statusCode: _response.error.statusCode,
2409
+ body: _response.error.body,
2410
+ rawResponse: _response.rawResponse
2411
+ });
2412
+ }
2413
+ }
2414
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/api/harness/filesystem/ls");
2415
+ }
2416
+ /**
2417
+ * @param {CngApi.GetHarnessFilesystemTreeRequest} request
2418
+ * @param {HarnessFilesystemClient.RequestOptions} requestOptions - Request-specific configuration.
2419
+ *
2420
+ * @throws {@link CngApi.BadRequestError}
2421
+ *
2422
+ * @example
2423
+ * await client.harnessFilesystem.getHarnessFilesystemTree()
2424
+ */
2425
+ getHarnessFilesystemTree(request = {}, requestOptions) {
2426
+ return HttpResponsePromise.fromPromise(this.__getHarnessFilesystemTree(request, requestOptions));
2427
+ }
2428
+ async __getHarnessFilesystemTree(request = {}, requestOptions) {
2429
+ const { path, depth, limit } = request;
2430
+ const _queryParams = {
2431
+ path,
2432
+ depth,
2433
+ limit
2434
+ };
2435
+ const _headers = mergeHeaders(this._options?.headers, requestOptions?.headers);
2436
+ const _response = await fetcher({
2437
+ url: url_exports.join(
2438
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment) ?? CngApiEnvironment.Default,
2439
+ "api/harness/filesystem/tree"
2440
+ ),
2441
+ method: "GET",
2442
+ headers: _headers,
2443
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
2444
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
2445
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
2446
+ abortSignal: requestOptions?.abortSignal,
2447
+ fetchFn: this._options?.fetch,
2448
+ logging: this._options.logging
2449
+ });
2450
+ if (_response.ok) {
2451
+ return {
2452
+ data: _response.body,
2453
+ rawResponse: _response.rawResponse
2454
+ };
2455
+ }
2456
+ if (_response.error.reason === "status-code") {
2457
+ switch (_response.error.statusCode) {
2458
+ case 400:
2459
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
2460
+ default:
2461
+ throw new CngApiError({
2462
+ statusCode: _response.error.statusCode,
2463
+ body: _response.error.body,
2464
+ rawResponse: _response.rawResponse
2465
+ });
2466
+ }
2467
+ }
2468
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/api/harness/filesystem/tree");
2469
+ }
2470
+ /**
2471
+ * @param {CngApi.GetHarnessFilesystemStatRequest} request
2472
+ * @param {HarnessFilesystemClient.RequestOptions} requestOptions - Request-specific configuration.
2473
+ *
2474
+ * @throws {@link CngApi.BadRequestError}
2475
+ * @throws {@link CngApi.NotFoundError}
2476
+ *
2477
+ * @example
2478
+ * await client.harnessFilesystem.getHarnessFilesystemStat({
2479
+ * path: "path"
2480
+ * })
2481
+ */
2482
+ getHarnessFilesystemStat(request, requestOptions) {
2483
+ return HttpResponsePromise.fromPromise(this.__getHarnessFilesystemStat(request, requestOptions));
2484
+ }
2485
+ async __getHarnessFilesystemStat(request, requestOptions) {
2486
+ const { path } = request;
2487
+ const _queryParams = {
2488
+ path
2489
+ };
2490
+ const _headers = mergeHeaders(this._options?.headers, requestOptions?.headers);
2491
+ const _response = await fetcher({
2492
+ url: url_exports.join(
2493
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment) ?? CngApiEnvironment.Default,
2494
+ "api/harness/filesystem/stat"
2495
+ ),
2496
+ method: "GET",
2497
+ headers: _headers,
2498
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
2499
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
2500
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
2501
+ abortSignal: requestOptions?.abortSignal,
2502
+ fetchFn: this._options?.fetch,
2503
+ logging: this._options.logging
2504
+ });
2505
+ if (_response.ok) {
2506
+ return {
2507
+ data: _response.body,
2508
+ rawResponse: _response.rawResponse
2509
+ };
2510
+ }
2511
+ if (_response.error.reason === "status-code") {
2512
+ switch (_response.error.statusCode) {
2513
+ case 400:
2514
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
2515
+ case 404:
2516
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
2517
+ default:
2518
+ throw new CngApiError({
2519
+ statusCode: _response.error.statusCode,
2520
+ body: _response.error.body,
2521
+ rawResponse: _response.rawResponse
2522
+ });
2523
+ }
2524
+ }
2525
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/api/harness/filesystem/stat");
2526
+ }
2527
+ /**
2528
+ * @param {CngApi.GetHarnessFilesystemFindRequest} request
2529
+ * @param {HarnessFilesystemClient.RequestOptions} requestOptions - Request-specific configuration.
2530
+ *
2531
+ * @throws {@link CngApi.BadRequestError}
2532
+ *
2533
+ * @example
2534
+ * await client.harnessFilesystem.getHarnessFilesystemFind()
2535
+ */
2536
+ getHarnessFilesystemFind(request = {}, requestOptions) {
2537
+ return HttpResponsePromise.fromPromise(this.__getHarnessFilesystemFind(request, requestOptions));
2538
+ }
2539
+ async __getHarnessFilesystemFind(request = {}, requestOptions) {
2540
+ const { path, name, type: type_, max_depth: maxDepth, limit } = request;
2541
+ const _queryParams = {
2542
+ path,
2543
+ name,
2544
+ type: type_ != null ? type_ : void 0,
2545
+ max_depth: maxDepth,
2546
+ limit
2547
+ };
2548
+ const _headers = mergeHeaders(this._options?.headers, requestOptions?.headers);
2549
+ const _response = await fetcher({
2550
+ url: url_exports.join(
2551
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment) ?? CngApiEnvironment.Default,
2552
+ "api/harness/filesystem/find"
2553
+ ),
2554
+ method: "GET",
2555
+ headers: _headers,
2556
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
2557
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
2558
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
2559
+ abortSignal: requestOptions?.abortSignal,
2560
+ fetchFn: this._options?.fetch,
2561
+ logging: this._options.logging
2562
+ });
2563
+ if (_response.ok) {
2564
+ return {
2565
+ data: _response.body,
2566
+ rawResponse: _response.rawResponse
2567
+ };
2568
+ }
2569
+ if (_response.error.reason === "status-code") {
2570
+ switch (_response.error.statusCode) {
2571
+ case 400:
2572
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
2573
+ default:
2574
+ throw new CngApiError({
2575
+ statusCode: _response.error.statusCode,
2576
+ body: _response.error.body,
2577
+ rawResponse: _response.rawResponse
2578
+ });
2579
+ }
2580
+ }
2581
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/api/harness/filesystem/find");
2582
+ }
2075
2583
  };
2076
2584
 
2077
2585
  // ../../packages/client/src/generated/api/resources/harnessInternalKnowledges/client/Client.ts
@@ -2087,12 +2595,12 @@ var HarnessInternalKnowledgesClient = class {
2087
2595
  * @throws {@link CngApi.ServiceUnavailableError}
2088
2596
  *
2089
2597
  * @example
2090
- * await client.harnessInternalKnowledges.createHarnessSubskillAssetsSyncPlan()
2598
+ * await client.harnessInternalKnowledges.createHarnessTopicAssetsSyncPlan()
2091
2599
  */
2092
- createHarnessSubskillAssetsSyncPlan(requestOptions) {
2093
- return HttpResponsePromise.fromPromise(this.__createHarnessSubskillAssetsSyncPlan(requestOptions));
2600
+ createHarnessTopicAssetsSyncPlan(requestOptions) {
2601
+ return HttpResponsePromise.fromPromise(this.__createHarnessTopicAssetsSyncPlan(requestOptions));
2094
2602
  }
2095
- async __createHarnessSubskillAssetsSyncPlan(requestOptions) {
2603
+ async __createHarnessTopicAssetsSyncPlan(requestOptions) {
2096
2604
  const _headers = mergeHeaders(this._options?.headers, requestOptions?.headers);
2097
2605
  const _response = await fetcher({
2098
2606
  url: url_exports.join(
@@ -2134,7 +2642,7 @@ var HarnessInternalKnowledgesClient = class {
2134
2642
  );
2135
2643
  }
2136
2644
  /**
2137
- * @param {CngApi.GetHarnessSubskillAssetRawFileRequest} request
2645
+ * @param {CngApi.GetHarnessTopicAssetRawFileRequest} request
2138
2646
  * @param {HarnessInternalKnowledgesClient.RequestOptions} requestOptions - Request-specific configuration.
2139
2647
  *
2140
2648
  * @throws {@link CngApi.UnauthorizedError}
@@ -2142,15 +2650,15 @@ var HarnessInternalKnowledgesClient = class {
2142
2650
  * @throws {@link CngApi.ServiceUnavailableError}
2143
2651
  *
2144
2652
  * @example
2145
- * await client.harnessInternalKnowledges.getHarnessSubskillAssetRawFile({
2653
+ * await client.harnessInternalKnowledges.getHarnessTopicAssetRawFile({
2146
2654
  * path: "x",
2147
2655
  * sha256: "sha256"
2148
2656
  * })
2149
2657
  */
2150
- getHarnessSubskillAssetRawFile(request, requestOptions) {
2151
- return HttpResponsePromise.fromPromise(this.__getHarnessSubskillAssetRawFile(request, requestOptions));
2658
+ getHarnessTopicAssetRawFile(request, requestOptions) {
2659
+ return HttpResponsePromise.fromPromise(this.__getHarnessTopicAssetRawFile(request, requestOptions));
2152
2660
  }
2153
- async __getHarnessSubskillAssetRawFile(request, requestOptions) {
2661
+ async __getHarnessTopicAssetRawFile(request, requestOptions) {
2154
2662
  const { path, sha256 } = request;
2155
2663
  const _queryParams = {
2156
2664
  path,
@@ -2204,12 +2712,12 @@ var HarnessInternalKnowledgesClient = class {
2204
2712
  * @throws {@link CngApi.UnauthorizedError}
2205
2713
  *
2206
2714
  * @example
2207
- * await client.harnessInternalKnowledges.listHarnessSubskillAssetHashes()
2715
+ * await client.harnessInternalKnowledges.listHarnessTopicAssetHashes()
2208
2716
  */
2209
- listHarnessSubskillAssetHashes(requestOptions) {
2210
- return HttpResponsePromise.fromPromise(this.__listHarnessSubskillAssetHashes(requestOptions));
2717
+ listHarnessTopicAssetHashes(requestOptions) {
2718
+ return HttpResponsePromise.fromPromise(this.__listHarnessTopicAssetHashes(requestOptions));
2211
2719
  }
2212
- async __listHarnessSubskillAssetHashes(requestOptions) {
2720
+ async __listHarnessTopicAssetHashes(requestOptions) {
2213
2721
  const _headers = mergeHeaders(this._options?.headers, requestOptions?.headers);
2214
2722
  const _response = await fetcher({
2215
2723
  url: url_exports.join(
@@ -2258,26 +2766,29 @@ var HarnessInternalKnowledgesClient = class {
2258
2766
  * @throws {@link CngApi.ConflictError}
2259
2767
  *
2260
2768
  * @example
2261
- * await client.harnessInternalKnowledges.replaceHarnessSubskillAssets({
2769
+ * await client.harnessInternalKnowledges.replaceHarnessTopicAssets({
2262
2770
  * uploadedAt: "uploadedAt",
2263
2771
  * files: [{
2264
2772
  * path: "path",
2773
+ * slug: "slug",
2265
2774
  * sha256: "sha256",
2266
2775
  * size: 1,
2267
2776
  * mode: "mode",
2268
2777
  * assetKind: "skill",
2269
- * subskillName: "subskillName",
2778
+ * topicName: "topicName",
2270
2779
  * displayTitle: "displayTitle",
2271
2780
  * displayDescription: "displayDescription",
2272
2781
  * displayRating: 1,
2782
+ * sourceText: "sourceText",
2783
+ * frontmatterText: "frontmatterText",
2273
2784
  * bodyText: "bodyText"
2274
2785
  * }]
2275
2786
  * })
2276
2787
  */
2277
- replaceHarnessSubskillAssets(request, requestOptions) {
2278
- return HttpResponsePromise.fromPromise(this.__replaceHarnessSubskillAssets(request, requestOptions));
2788
+ replaceHarnessTopicAssets(request, requestOptions) {
2789
+ return HttpResponsePromise.fromPromise(this.__replaceHarnessTopicAssets(request, requestOptions));
2279
2790
  }
2280
- async __replaceHarnessSubskillAssets(request, requestOptions) {
2791
+ async __replaceHarnessTopicAssets(request, requestOptions) {
2281
2792
  const _headers = mergeHeaders(this._options?.headers, requestOptions?.headers);
2282
2793
  const _response = await fetcher({
2283
2794
  url: url_exports.join(
@@ -2331,15 +2842,15 @@ var HarnessInternalKnowledgesClient = class {
2331
2842
  * @throws {@link CngApi.ConflictError}
2332
2843
  *
2333
2844
  * @example
2334
- * await client.harnessInternalKnowledges.deleteHarnessSubskillAssets({
2845
+ * await client.harnessInternalKnowledges.deleteHarnessTopicAssets({
2335
2846
  * uploadedAt: "uploadedAt",
2336
2847
  * paths: ["paths"]
2337
2848
  * })
2338
2849
  */
2339
- deleteHarnessSubskillAssets(request, requestOptions) {
2340
- return HttpResponsePromise.fromPromise(this.__deleteHarnessSubskillAssets(request, requestOptions));
2850
+ deleteHarnessTopicAssets(request, requestOptions) {
2851
+ return HttpResponsePromise.fromPromise(this.__deleteHarnessTopicAssets(request, requestOptions));
2341
2852
  }
2342
- async __deleteHarnessSubskillAssets(request, requestOptions) {
2853
+ async __deleteHarnessTopicAssets(request, requestOptions) {
2343
2854
  const _headers = mergeHeaders(this._options?.headers, requestOptions?.headers);
2344
2855
  const _response = await fetcher({
2345
2856
  url: url_exports.join(
@@ -2389,23 +2900,23 @@ var HarnessInternalKnowledgesClient = class {
2389
2900
  );
2390
2901
  }
2391
2902
  /**
2392
- * @param {CngApi.HarnessUploadSubskillAssetsIndexRequest} request
2903
+ * @param {CngApi.HarnessUploadTopicAssetsIndexRequest} request
2393
2904
  * @param {HarnessInternalKnowledgesClient.RequestOptions} requestOptions - Request-specific configuration.
2394
2905
  *
2395
2906
  * @throws {@link CngApi.UnauthorizedError}
2396
2907
  * @throws {@link CngApi.InternalServerError}
2397
2908
  *
2398
2909
  * @example
2399
- * await client.harnessInternalKnowledges.createHarnessSubskillAssetsIndex({
2910
+ * await client.harnessInternalKnowledges.createHarnessTopicAssetsIndex({
2400
2911
  * runId: "runId",
2401
2912
  * offset: 1,
2402
2913
  * limit: 1
2403
2914
  * })
2404
2915
  */
2405
- createHarnessSubskillAssetsIndex(request, requestOptions) {
2406
- return HttpResponsePromise.fromPromise(this.__createHarnessSubskillAssetsIndex(request, requestOptions));
2916
+ createHarnessTopicAssetsIndex(request, requestOptions) {
2917
+ return HttpResponsePromise.fromPromise(this.__createHarnessTopicAssetsIndex(request, requestOptions));
2407
2918
  }
2408
- async __createHarnessSubskillAssetsIndex(request, requestOptions) {
2919
+ async __createHarnessTopicAssetsIndex(request, requestOptions) {
2409
2920
  const _headers = mergeHeaders(this._options?.headers, requestOptions?.headers);
2410
2921
  const _response = await fetcher({
2411
2922
  url: url_exports.join(
@@ -2550,16 +3061,16 @@ var HarnessKnowledgesClient = class {
2550
3061
  );
2551
3062
  }
2552
3063
  /**
2553
- * @param {CngApi.ListHarnessSubskillAssetsRequest} request
3064
+ * @param {CngApi.ListHarnessTopicAssetsRequest} request
2554
3065
  * @param {HarnessKnowledgesClient.RequestOptions} requestOptions - Request-specific configuration.
2555
3066
  *
2556
3067
  * @example
2557
- * await client.harnessKnowledges.listHarnessSubskillAssets()
3068
+ * await client.harnessKnowledges.listHarnessTopicAssets()
2558
3069
  */
2559
- listHarnessSubskillAssets(request = {}, requestOptions) {
2560
- return HttpResponsePromise.fromPromise(this.__listHarnessSubskillAssets(request, requestOptions));
3070
+ listHarnessTopicAssets(request = {}, requestOptions) {
3071
+ return HttpResponsePromise.fromPromise(this.__listHarnessTopicAssets(request, requestOptions));
2561
3072
  }
2562
- async __listHarnessSubskillAssets(request = {}, requestOptions) {
3073
+ async __listHarnessTopicAssets(request = {}, requestOptions) {
2563
3074
  const { q, audience, limit } = request;
2564
3075
  const _queryParams = {
2565
3076
  q,
@@ -2582,10 +3093,7 @@ var HarnessKnowledgesClient = class {
2582
3093
  logging: this._options.logging
2583
3094
  });
2584
3095
  if (_response.ok) {
2585
- return {
2586
- data: _response.body,
2587
- rawResponse: _response.rawResponse
2588
- };
3096
+ return { data: _response.body, rawResponse: _response.rawResponse };
2589
3097
  }
2590
3098
  if (_response.error.reason === "status-code") {
2591
3099
  throw new CngApiError({
@@ -2739,22 +3247,22 @@ var HarnessKnowledgesClient = class {
2739
3247
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/api/harness/knowledges/brain");
2740
3248
  }
2741
3249
  /**
2742
- * Returns the full subskill index for agent discovery. Use search for semantic lookup, or filesystem/read for content.
3250
+ * Returns the full topic index for agent discovery. Use search for semantic lookup, or filesystem/read for content.
2743
3251
  *
2744
3252
  * @param {HarnessKnowledgesClient.RequestOptions} requestOptions - Request-specific configuration.
2745
3253
  *
2746
3254
  * @example
2747
- * await client.harnessKnowledges.listHarnessKnowledgesSubskills()
3255
+ * await client.harnessKnowledges.listHarnessKnowledgesTopics()
2748
3256
  */
2749
- listHarnessKnowledgesSubskills(requestOptions) {
2750
- return HttpResponsePromise.fromPromise(this.__listHarnessKnowledgesSubskills(requestOptions));
3257
+ listHarnessKnowledgesTopics(requestOptions) {
3258
+ return HttpResponsePromise.fromPromise(this.__listHarnessKnowledgesTopics(requestOptions));
2751
3259
  }
2752
- async __listHarnessKnowledgesSubskills(requestOptions) {
3260
+ async __listHarnessKnowledgesTopics(requestOptions) {
2753
3261
  const _headers = mergeHeaders(this._options?.headers, requestOptions?.headers);
2754
3262
  const _response = await fetcher({
2755
3263
  url: url_exports.join(
2756
3264
  await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment) ?? CngApiEnvironment.Default,
2757
- "api/harness/knowledges/subskills"
3265
+ "api/harness/knowledges/topics"
2758
3266
  ),
2759
3267
  method: "GET",
2760
3268
  headers: _headers,
@@ -2779,7 +3287,7 @@ var HarnessKnowledgesClient = class {
2779
3287
  _response.error,
2780
3288
  _response.rawResponse,
2781
3289
  "GET",
2782
- "/api/harness/knowledges/subskills"
3290
+ "/api/harness/knowledges/topics"
2783
3291
  );
2784
3292
  }
2785
3293
  /**
@@ -2870,6 +3378,109 @@ var HarnessKnowledgesClient = class {
2870
3378
  }
2871
3379
  };
2872
3380
 
3381
+ // ../../packages/client/src/generated/api/resources/hookify/client/Client.ts
3382
+ var HookifyClient = class {
3383
+ _options;
3384
+ constructor(options = {}) {
3385
+ this._options = normalizeClientOptions(options);
3386
+ }
3387
+ /**
3388
+ * @param {core.file.Uploadable} uploadable
3389
+ * @param {CngApi.IngestHookifyHookRequest} request
3390
+ * @param {HookifyClient.RequestOptions} requestOptions - Request-specific configuration.
3391
+ */
3392
+ ingestHookifyHook(uploadable, request, requestOptions) {
3393
+ return HttpResponsePromise.fromPromise(this.__ingestHookifyHook(uploadable, request, requestOptions));
3394
+ }
3395
+ async __ingestHookifyHook(uploadable, request, requestOptions) {
3396
+ const _queryParams = {
3397
+ mode: request.mode != null ? request.mode : void 0,
3398
+ event: request.event
3399
+ };
3400
+ const _binaryUploadRequest = await file_exports.toBinaryUploadRequest(uploadable);
3401
+ const _headers = mergeHeaders(
3402
+ this._options?.headers,
3403
+ _binaryUploadRequest.headers,
3404
+ requestOptions?.headers
3405
+ );
3406
+ const _response = await fetcher({
3407
+ url: url_exports.join(
3408
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment) ?? CngApiEnvironment.Default,
3409
+ "api/hookify/ingest"
3410
+ ),
3411
+ method: "POST",
3412
+ headers: _headers,
3413
+ contentType: "application/octet-stream",
3414
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
3415
+ requestType: "bytes",
3416
+ duplex: "half",
3417
+ body: _binaryUploadRequest.body,
3418
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
3419
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
3420
+ abortSignal: requestOptions?.abortSignal,
3421
+ fetchFn: this._options?.fetch,
3422
+ logging: this._options.logging
3423
+ });
3424
+ if (_response.ok) {
3425
+ return { data: _response.body, rawResponse: _response.rawResponse };
3426
+ }
3427
+ if (_response.error.reason === "status-code") {
3428
+ throw new CngApiError({
3429
+ statusCode: _response.error.statusCode,
3430
+ body: _response.error.body,
3431
+ rawResponse: _response.rawResponse
3432
+ });
3433
+ }
3434
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/api/hookify/ingest");
3435
+ }
3436
+ /**
3437
+ * @param {CngApi.GetHookifyRequestRequest} request
3438
+ * @param {HookifyClient.RequestOptions} requestOptions - Request-specific configuration.
3439
+ *
3440
+ * @example
3441
+ * await client.hookify.getHookifyRequest({
3442
+ * requestId: "requestId"
3443
+ * })
3444
+ */
3445
+ getHookifyRequest(request, requestOptions) {
3446
+ return HttpResponsePromise.fromPromise(this.__getHookifyRequest(request, requestOptions));
3447
+ }
3448
+ async __getHookifyRequest(request, requestOptions) {
3449
+ const { requestId } = request;
3450
+ const _headers = mergeHeaders(this._options?.headers, requestOptions?.headers);
3451
+ const _response = await fetcher({
3452
+ url: url_exports.join(
3453
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment) ?? CngApiEnvironment.Default,
3454
+ `api/hookify/requests/${url_exports.encodePathParam(requestId)}`
3455
+ ),
3456
+ method: "GET",
3457
+ headers: _headers,
3458
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
3459
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
3460
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
3461
+ abortSignal: requestOptions?.abortSignal,
3462
+ fetchFn: this._options?.fetch,
3463
+ logging: this._options.logging
3464
+ });
3465
+ if (_response.ok) {
3466
+ return { data: _response.body, rawResponse: _response.rawResponse };
3467
+ }
3468
+ if (_response.error.reason === "status-code") {
3469
+ throw new CngApiError({
3470
+ statusCode: _response.error.statusCode,
3471
+ body: _response.error.body,
3472
+ rawResponse: _response.rawResponse
3473
+ });
3474
+ }
3475
+ return handleNonStatusCodeError(
3476
+ _response.error,
3477
+ _response.rawResponse,
3478
+ "GET",
3479
+ "/api/hookify/requests/{requestId}"
3480
+ );
3481
+ }
3482
+ };
3483
+
2873
3484
  // ../../packages/client/src/generated/api/resources/llm/client/Client.ts
2874
3485
  var LlmClient = class {
2875
3486
  _options;
@@ -3142,6 +3753,7 @@ var CngApiClient = class {
3142
3753
  _polar;
3143
3754
  _telemetry;
3144
3755
  _llm;
3756
+ _hookify;
3145
3757
  constructor(options = {}) {
3146
3758
  this._options = normalizeClientOptions(options);
3147
3759
  }
@@ -3169,6 +3781,9 @@ var CngApiClient = class {
3169
3781
  get llm() {
3170
3782
  return this._llm ??= new LlmClient(this._options);
3171
3783
  }
3784
+ get hookify() {
3785
+ return this._hookify ??= new HookifyClient(this._options);
3786
+ }
3172
3787
  /**
3173
3788
  * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
3174
3789
  * This is useful for making requests to endpoints not yet supported in the SDK.
@@ -3203,32 +3818,235 @@ var logging;
3203
3818
  logging2.ConsoleLogger = ConsoleLogger;
3204
3819
  })(logging || (logging = {}));
3205
3820
 
3206
- // src/shared/api-client.ts
3207
- function createCngApiClient(options) {
3208
- return new CngApiClient({
3209
- baseUrl: resolveApiBaseUrl(options),
3210
- timeoutInSeconds: 15,
3211
- maxRetries: 1
3821
+ // src/shared/theme.ts
3822
+ import { Chalk } from "chalk";
3823
+ var statusStylePropsByOutputStyle = {
3824
+ info: {
3825
+ color: "cyan"
3826
+ },
3827
+ success: {
3828
+ color: "green",
3829
+ bold: true
3830
+ },
3831
+ warning: {
3832
+ color: "yellow",
3833
+ bold: true
3834
+ },
3835
+ muted: {
3836
+ dimColor: true
3837
+ },
3838
+ error: {
3839
+ color: "red",
3840
+ bold: true
3841
+ }
3842
+ };
3843
+ function createMarkdownTheme(useColor) {
3844
+ const chalk = new Chalk({ level: useColor ? 1 : 0 });
3845
+ const identity = (value) => value;
3846
+ return {
3847
+ code: chalk.green,
3848
+ blockquote: chalk.dim.italic,
3849
+ html: chalk.gray,
3850
+ heading: chalk.blueBright.bold,
3851
+ firstHeading: chalk.magentaBright.bold,
3852
+ hr: chalk.gray,
3853
+ listitem: identity,
3854
+ table: identity,
3855
+ paragraph: identity,
3856
+ strong: chalk.bold,
3857
+ em: chalk.italic,
3858
+ codespan: chalk.cyanBright,
3859
+ del: chalk.dim.strikethrough,
3860
+ link: chalk.blueBright,
3861
+ href: chalk.blue.underline,
3862
+ text: identity,
3863
+ showSectionPrefix: false,
3864
+ reflowText: true,
3865
+ unescape: true,
3866
+ emoji: false,
3867
+ tab: 2
3868
+ };
3869
+ }
3870
+
3871
+ // src/shared/output.ts
3872
+ var consoleOutput = createCommandOutput(process3.stdout, process3.stderr);
3873
+ function createCommandOutput(stdout, stderr) {
3874
+ return {
3875
+ info(message) {
3876
+ writeStyledMessage(stdout, "info", message);
3877
+ },
3878
+ success(message) {
3879
+ writeStyledMessage(stdout, "success", message);
3880
+ },
3881
+ warning(message) {
3882
+ writeStyledMessage(stdout, "warning", message);
3883
+ },
3884
+ muted(message) {
3885
+ writeStyledMessage(stdout, "muted", message);
3886
+ },
3887
+ markdown(message) {
3888
+ stdout.write(`${formatMarkdownMessage(stdout, message)}
3889
+ `);
3890
+ },
3891
+ component(element) {
3892
+ stdout.write(`${formatComponentMessage(stdout, element)}
3893
+ `);
3894
+ },
3895
+ raw(message) {
3896
+ stdout.write(`${message}
3897
+ `);
3898
+ },
3899
+ error(message) {
3900
+ writeStyledMessage(stderr, "error", message);
3901
+ }
3902
+ };
3903
+ }
3904
+ function formatError(error) {
3905
+ if (error instanceof CngApiError) {
3906
+ return formatApiError(error);
3907
+ }
3908
+ return error instanceof Error ? error.message : String(error);
3909
+ }
3910
+ function formatApiError(error) {
3911
+ if (resolveOutputFormat() === "json") {
3912
+ return error.message;
3913
+ }
3914
+ const statusCode = error.statusCode ?? 0;
3915
+ if (statusCode >= 500) {
3916
+ return `Backend error (${statusCode}). The service encountered an internal error.`;
3917
+ }
3918
+ if (statusCode >= 400) {
3919
+ const bodyMessage = extractBodyErrorMessage(error.body);
3920
+ if (bodyMessage) {
3921
+ return `Request error (${statusCode}): ${bodyMessage}`;
3922
+ }
3923
+ return `Request error (${statusCode}).`;
3924
+ }
3925
+ return error.message;
3926
+ }
3927
+ function extractBodyErrorMessage(body) {
3928
+ if (body == null || typeof body !== "object") {
3929
+ return void 0;
3930
+ }
3931
+ const record = body;
3932
+ const errorField = record.error;
3933
+ if (errorField != null && typeof errorField === "object") {
3934
+ const message = errorField.message;
3935
+ if (typeof message === "string") {
3936
+ return message;
3937
+ }
3938
+ }
3939
+ if (typeof record.message === "string") {
3940
+ return record.message;
3941
+ }
3942
+ return void 0;
3943
+ }
3944
+ function writeStyledMessage(stream, style, message) {
3945
+ stream.write(`${formatStyledMessage(stream, style, message)}
3946
+ `);
3947
+ }
3948
+ function formatStyledMessage(stream, style, message) {
3949
+ if (!shouldRenderColor(stream)) {
3950
+ return message;
3951
+ }
3952
+ return renderToString(
3953
+ createElement(
3954
+ Text,
3955
+ {
3956
+ ...statusStylePropsByOutputStyle[style],
3957
+ wrap: "wrap"
3958
+ },
3959
+ message
3960
+ ),
3961
+ {
3962
+ columns: 1e4
3963
+ }
3964
+ );
3965
+ }
3966
+ function formatMarkdownMessage(stream, markdown) {
3967
+ if (resolveOutputFormat() === "markdown") {
3968
+ return markdown;
3969
+ }
3970
+ const useColor = shouldRenderColor(stream);
3971
+ const markdownWidth = clampMarkdownWidth(stream.columns);
3972
+ const preparedMarkdown = prepareMarkdownForTerminal(markdown);
3973
+ const renderedMarkdown = renderToString(
3974
+ createElement(Markdown, {
3975
+ ...createMarkdownTheme(useColor),
3976
+ children: preparedMarkdown,
3977
+ width: markdownWidth
3978
+ }),
3979
+ {
3980
+ columns: markdownWidth
3981
+ }
3982
+ );
3983
+ return useColor ? renderedMarkdown.trimEnd() : stripAnsi(renderedMarkdown).trimEnd();
3984
+ }
3985
+ function formatComponentMessage(stream, element) {
3986
+ const useColor = shouldRenderColor(stream);
3987
+ const renderWidth = clampMarkdownWidth(stream.columns);
3988
+ const rendered = renderToString(element, {
3989
+ columns: renderWidth
3212
3990
  });
3991
+ return useColor ? rendered.trimEnd() : stripAnsi(rendered).trimEnd();
3213
3992
  }
3214
- async function readBackendHealth(options) {
3215
- try {
3216
- const client = createCngApiClient(options);
3217
- const health = await client.system.getHealth();
3218
- return {
3219
- ok: true,
3220
- service: health.service
3221
- };
3222
- } catch (error) {
3223
- return {
3224
- ok: false,
3225
- message: error instanceof Error ? error.message : "unknown error"
3226
- };
3993
+ function prepareMarkdownForTerminal(markdown) {
3994
+ if (!markdown.startsWith("---\n")) {
3995
+ return markdown;
3996
+ }
3997
+ const frontmatterEndIndex = markdown.indexOf("\n---", 4);
3998
+ if (frontmatterEndIndex < 0) {
3999
+ return formatFrontmatterForTerminal(markdown.slice(4).trimEnd());
4000
+ }
4001
+ const frontmatter = markdown.slice(4, frontmatterEndIndex).trimEnd();
4002
+ const body = markdown.slice(frontmatterEndIndex + "\n---".length).replace(/^\n+/, "");
4003
+ return `${formatFrontmatterForTerminal(frontmatter)}
4004
+
4005
+ ${body}`;
4006
+ }
4007
+ function formatFrontmatterForTerminal(frontmatter) {
4008
+ return `## Metadata
4009
+
4010
+ \`\`\`yaml
4011
+ ${frontmatter}
4012
+ \`\`\``;
4013
+ }
4014
+ function shouldRenderColor(stream) {
4015
+ if (process3.env.CNGKIT_NO_COLOR === "1") {
4016
+ return false;
4017
+ }
4018
+ const colorMode = process3.env.CNGKIT_COLOR?.toLowerCase();
4019
+ if (colorMode === "never" || colorMode === "0" || colorMode === "false") {
4020
+ return false;
4021
+ }
4022
+ if (colorMode === "always" || colorMode === "1" || colorMode === "true") {
4023
+ return true;
4024
+ }
4025
+ if (process3.env.FORCE_COLOR !== void 0 && process3.env.FORCE_COLOR !== "0") {
4026
+ return true;
4027
+ }
4028
+ if (process3.env.NO_COLOR !== void 0) {
4029
+ return false;
4030
+ }
4031
+ return stream.isTTY === true;
4032
+ }
4033
+ function clampMarkdownWidth(columns) {
4034
+ if (columns === void 0) {
4035
+ return 100;
3227
4036
  }
4037
+ return Math.max(72, Math.min(columns, 120));
3228
4038
  }
3229
4039
 
3230
4040
  export {
3231
- createCngApiClient,
3232
- readBackendHealth
4041
+ CngApiClient,
4042
+ packageVersion,
4043
+ resolveApiBaseUrl,
4044
+ resolveOutputFormat,
4045
+ parseOutputFormat,
4046
+ createRoomCode,
4047
+ createPeerId,
4048
+ consoleOutput,
4049
+ createCommandOutput,
4050
+ formatError
3233
4051
  };
3234
- //# sourceMappingURL=chunk-HRFI2IEP.js.map
4052
+ //# sourceMappingURL=chunk-7SO75QXJ.js.map