@hilbras/omninode 2.0.0-alpha.6 → 2.0.0-alpha.7

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/dist/index.d.ts CHANGED
@@ -296,6 +296,14 @@ interface ChatResponse {
296
296
  * layer so adapters (e.g. planner) never depend on engine modules.
297
297
  */
298
298
  type ChatFn = (model: string, messages: ChatMessage[]) => Promise<string>;
299
+ /** One streamed chunk (SSE deltas from OpenAI-compatible gateways). */
300
+ interface ChatStreamChunk {
301
+ /** Text delta (empty for role-only or final chunks). */
302
+ delta: string;
303
+ /** Provider-reported finish reason, on the final chunk. */
304
+ finishReason?: string;
305
+ raw?: unknown;
306
+ }
299
307
 
300
308
  /**
301
309
  * Memory abstraction. Remembera is the preferred Hilbras integration, but the
@@ -685,6 +693,8 @@ interface ProviderConfig {
685
693
  */
686
694
  apiKeyEnvVar?: string;
687
695
  headers?: Record<string, string>;
696
+ /** Provider-level request timeout in ms (distinct from agent/pipeline budgets). */
697
+ timeoutMs?: number;
688
698
  /** Capabilities declared for this provider (discovered ones are merged in). */
689
699
  capabilities?: ProviderCapability[];
690
700
  enabled?: boolean;
@@ -722,6 +732,11 @@ interface IProvider {
722
732
  /** Contract for providers that can run chat completions (foundation for planning). */
723
733
  interface IChatProvider extends IProvider {
724
734
  chat(request: ChatRequest): Promise<ChatResponse>;
735
+ /**
736
+ * Stream a completion where the provider supports it (§11). Chunks are
737
+ * delivered in order; the resolved ChatResponse carries the assembled text.
738
+ */
739
+ stream?(request: ChatRequest, onChunk: (chunk: ChatStreamChunk) => void): Promise<ChatResponse>;
725
740
  }
726
741
 
727
742
  /** Typed error hierarchy shared across the whole codebase (§4.1 — error model). */
@@ -806,6 +821,7 @@ declare const providerConfigSchema: z.ZodObject<{
806
821
  type: z.ZodEnum<["openai-compatible", "omnihilbras", "openrouter", "local", "custom"]>;
807
822
  base_url: z.ZodString;
808
823
  api_key_env_var: z.ZodOptional<z.ZodString>;
824
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
809
825
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
810
826
  enabled: z.ZodOptional<z.ZodBoolean>;
811
827
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -815,6 +831,7 @@ declare const providerConfigSchema: z.ZodObject<{
815
831
  base_url: string;
816
832
  metadata?: Record<string, unknown> | undefined;
817
833
  api_key_env_var?: string | undefined;
834
+ timeout_ms?: number | undefined;
818
835
  headers?: Record<string, string> | undefined;
819
836
  enabled?: boolean | undefined;
820
837
  }, {
@@ -823,6 +840,7 @@ declare const providerConfigSchema: z.ZodObject<{
823
840
  base_url: string;
824
841
  metadata?: Record<string, unknown> | undefined;
825
842
  api_key_env_var?: string | undefined;
843
+ timeout_ms?: number | undefined;
826
844
  headers?: Record<string, string> | undefined;
827
845
  enabled?: boolean | undefined;
828
846
  }>;
@@ -848,11 +866,11 @@ declare const agentConfigSchema: z.ZodObject<{
848
866
  type: "native" | "process" | "cli";
849
867
  input_mode: "protocol" | "stdin" | "arg";
850
868
  metadata?: Record<string, unknown> | undefined;
869
+ timeout_ms?: number | undefined;
851
870
  command?: string | undefined;
852
871
  args?: string[] | undefined;
853
872
  cwd?: string | undefined;
854
873
  env?: Record<string, string> | undefined;
855
- timeout_ms?: number | undefined;
856
874
  inherit_env?: boolean | undefined;
857
875
  env_policy?: "inherit" | "allowlist" | "denylist" | "explicit" | undefined;
858
876
  env_allowlist?: string[] | undefined;
@@ -863,12 +881,12 @@ declare const agentConfigSchema: z.ZodObject<{
863
881
  name: string;
864
882
  metadata?: Record<string, unknown> | undefined;
865
883
  type?: "native" | "process" | "cli" | undefined;
884
+ timeout_ms?: number | undefined;
866
885
  command?: string | undefined;
867
886
  args?: string[] | undefined;
868
887
  cwd?: string | undefined;
869
888
  env?: Record<string, string> | undefined;
870
889
  input_mode?: "protocol" | "stdin" | "arg" | undefined;
871
- timeout_ms?: number | undefined;
872
890
  inherit_env?: boolean | undefined;
873
891
  env_policy?: "inherit" | "allowlist" | "denylist" | "explicit" | undefined;
874
892
  env_allowlist?: string[] | undefined;
@@ -1016,6 +1034,7 @@ declare const projectConfigSchema: z.ZodObject<{
1016
1034
  type: z.ZodEnum<["openai-compatible", "omnihilbras", "openrouter", "local", "custom"]>;
1017
1035
  base_url: z.ZodString;
1018
1036
  api_key_env_var: z.ZodOptional<z.ZodString>;
1037
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
1019
1038
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1020
1039
  enabled: z.ZodOptional<z.ZodBoolean>;
1021
1040
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -1025,6 +1044,7 @@ declare const projectConfigSchema: z.ZodObject<{
1025
1044
  base_url: string;
1026
1045
  metadata?: Record<string, unknown> | undefined;
1027
1046
  api_key_env_var?: string | undefined;
1047
+ timeout_ms?: number | undefined;
1028
1048
  headers?: Record<string, string> | undefined;
1029
1049
  enabled?: boolean | undefined;
1030
1050
  }, {
@@ -1033,6 +1053,7 @@ declare const projectConfigSchema: z.ZodObject<{
1033
1053
  base_url: string;
1034
1054
  metadata?: Record<string, unknown> | undefined;
1035
1055
  api_key_env_var?: string | undefined;
1056
+ timeout_ms?: number | undefined;
1036
1057
  headers?: Record<string, string> | undefined;
1037
1058
  enabled?: boolean | undefined;
1038
1059
  }>, "many">>;
@@ -1058,11 +1079,11 @@ declare const projectConfigSchema: z.ZodObject<{
1058
1079
  type: "native" | "process" | "cli";
1059
1080
  input_mode: "protocol" | "stdin" | "arg";
1060
1081
  metadata?: Record<string, unknown> | undefined;
1082
+ timeout_ms?: number | undefined;
1061
1083
  command?: string | undefined;
1062
1084
  args?: string[] | undefined;
1063
1085
  cwd?: string | undefined;
1064
1086
  env?: Record<string, string> | undefined;
1065
- timeout_ms?: number | undefined;
1066
1087
  inherit_env?: boolean | undefined;
1067
1088
  env_policy?: "inherit" | "allowlist" | "denylist" | "explicit" | undefined;
1068
1089
  env_allowlist?: string[] | undefined;
@@ -1073,12 +1094,12 @@ declare const projectConfigSchema: z.ZodObject<{
1073
1094
  name: string;
1074
1095
  metadata?: Record<string, unknown> | undefined;
1075
1096
  type?: "native" | "process" | "cli" | undefined;
1097
+ timeout_ms?: number | undefined;
1076
1098
  command?: string | undefined;
1077
1099
  args?: string[] | undefined;
1078
1100
  cwd?: string | undefined;
1079
1101
  env?: Record<string, string> | undefined;
1080
1102
  input_mode?: "protocol" | "stdin" | "arg" | undefined;
1081
- timeout_ms?: number | undefined;
1082
1103
  inherit_env?: boolean | undefined;
1083
1104
  env_policy?: "inherit" | "allowlist" | "denylist" | "explicit" | undefined;
1084
1105
  env_allowlist?: string[] | undefined;
@@ -1195,13 +1216,16 @@ declare const projectConfigSchema: z.ZodObject<{
1195
1216
  provider: z.ZodDefault<z.ZodString>;
1196
1217
  base_url: z.ZodOptional<z.ZodString>;
1197
1218
  api_key_env_var: z.ZodOptional<z.ZodString>;
1219
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
1198
1220
  }, "strict", z.ZodTypeAny, {
1199
1221
  provider: string;
1200
1222
  base_url?: string | undefined;
1201
1223
  api_key_env_var?: string | undefined;
1224
+ timeout_ms?: number | undefined;
1202
1225
  }, {
1203
1226
  base_url?: string | undefined;
1204
1227
  api_key_env_var?: string | undefined;
1228
+ timeout_ms?: number | undefined;
1205
1229
  provider?: string | undefined;
1206
1230
  }>>;
1207
1231
  }, "strict", z.ZodTypeAny, {
@@ -1211,11 +1235,11 @@ declare const projectConfigSchema: z.ZodObject<{
1211
1235
  type: "native" | "process" | "cli";
1212
1236
  input_mode: "protocol" | "stdin" | "arg";
1213
1237
  metadata?: Record<string, unknown> | undefined;
1238
+ timeout_ms?: number | undefined;
1214
1239
  command?: string | undefined;
1215
1240
  args?: string[] | undefined;
1216
1241
  cwd?: string | undefined;
1217
1242
  env?: Record<string, string> | undefined;
1218
- timeout_ms?: number | undefined;
1219
1243
  inherit_env?: boolean | undefined;
1220
1244
  env_policy?: "inherit" | "allowlist" | "denylist" | "explicit" | undefined;
1221
1245
  env_allowlist?: string[] | undefined;
@@ -1229,6 +1253,7 @@ declare const projectConfigSchema: z.ZodObject<{
1229
1253
  base_url: string;
1230
1254
  metadata?: Record<string, unknown> | undefined;
1231
1255
  api_key_env_var?: string | undefined;
1256
+ timeout_ms?: number | undefined;
1232
1257
  headers?: Record<string, string> | undefined;
1233
1258
  enabled?: boolean | undefined;
1234
1259
  }[];
@@ -1267,6 +1292,7 @@ declare const projectConfigSchema: z.ZodObject<{
1267
1292
  provider: string;
1268
1293
  base_url?: string | undefined;
1269
1294
  api_key_env_var?: string | undefined;
1295
+ timeout_ms?: number | undefined;
1270
1296
  } | undefined;
1271
1297
  }, {
1272
1298
  name: string;
@@ -1274,12 +1300,12 @@ declare const projectConfigSchema: z.ZodObject<{
1274
1300
  name: string;
1275
1301
  metadata?: Record<string, unknown> | undefined;
1276
1302
  type?: "native" | "process" | "cli" | undefined;
1303
+ timeout_ms?: number | undefined;
1277
1304
  command?: string | undefined;
1278
1305
  args?: string[] | undefined;
1279
1306
  cwd?: string | undefined;
1280
1307
  env?: Record<string, string> | undefined;
1281
1308
  input_mode?: "protocol" | "stdin" | "arg" | undefined;
1282
- timeout_ms?: number | undefined;
1283
1309
  inherit_env?: boolean | undefined;
1284
1310
  env_policy?: "inherit" | "allowlist" | "denylist" | "explicit" | undefined;
1285
1311
  env_allowlist?: string[] | undefined;
@@ -1293,6 +1319,7 @@ declare const projectConfigSchema: z.ZodObject<{
1293
1319
  base_url: string;
1294
1320
  metadata?: Record<string, unknown> | undefined;
1295
1321
  api_key_env_var?: string | undefined;
1322
+ timeout_ms?: number | undefined;
1296
1323
  headers?: Record<string, string> | undefined;
1297
1324
  enabled?: boolean | undefined;
1298
1325
  }[] | undefined;
@@ -1330,6 +1357,7 @@ declare const projectConfigSchema: z.ZodObject<{
1330
1357
  memory?: {
1331
1358
  base_url?: string | undefined;
1332
1359
  api_key_env_var?: string | undefined;
1360
+ timeout_ms?: number | undefined;
1333
1361
  provider?: string | undefined;
1334
1362
  } | undefined;
1335
1363
  }>;
@@ -1341,6 +1369,7 @@ declare const appConfigSchema: z.ZodObject<{
1341
1369
  type: z.ZodEnum<["openai-compatible", "omnihilbras", "openrouter", "local", "custom"]>;
1342
1370
  base_url: z.ZodString;
1343
1371
  api_key_env_var: z.ZodOptional<z.ZodString>;
1372
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
1344
1373
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1345
1374
  enabled: z.ZodOptional<z.ZodBoolean>;
1346
1375
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -1350,6 +1379,7 @@ declare const appConfigSchema: z.ZodObject<{
1350
1379
  base_url: string;
1351
1380
  metadata?: Record<string, unknown> | undefined;
1352
1381
  api_key_env_var?: string | undefined;
1382
+ timeout_ms?: number | undefined;
1353
1383
  headers?: Record<string, string> | undefined;
1354
1384
  enabled?: boolean | undefined;
1355
1385
  }, {
@@ -1358,6 +1388,7 @@ declare const appConfigSchema: z.ZodObject<{
1358
1388
  base_url: string;
1359
1389
  metadata?: Record<string, unknown> | undefined;
1360
1390
  api_key_env_var?: string | undefined;
1391
+ timeout_ms?: number | undefined;
1361
1392
  headers?: Record<string, string> | undefined;
1362
1393
  enabled?: boolean | undefined;
1363
1394
  }>, "many">>;
@@ -1383,11 +1414,11 @@ declare const appConfigSchema: z.ZodObject<{
1383
1414
  type: "native" | "process" | "cli";
1384
1415
  input_mode: "protocol" | "stdin" | "arg";
1385
1416
  metadata?: Record<string, unknown> | undefined;
1417
+ timeout_ms?: number | undefined;
1386
1418
  command?: string | undefined;
1387
1419
  args?: string[] | undefined;
1388
1420
  cwd?: string | undefined;
1389
1421
  env?: Record<string, string> | undefined;
1390
- timeout_ms?: number | undefined;
1391
1422
  inherit_env?: boolean | undefined;
1392
1423
  env_policy?: "inherit" | "allowlist" | "denylist" | "explicit" | undefined;
1393
1424
  env_allowlist?: string[] | undefined;
@@ -1398,12 +1429,12 @@ declare const appConfigSchema: z.ZodObject<{
1398
1429
  name: string;
1399
1430
  metadata?: Record<string, unknown> | undefined;
1400
1431
  type?: "native" | "process" | "cli" | undefined;
1432
+ timeout_ms?: number | undefined;
1401
1433
  command?: string | undefined;
1402
1434
  args?: string[] | undefined;
1403
1435
  cwd?: string | undefined;
1404
1436
  env?: Record<string, string> | undefined;
1405
1437
  input_mode?: "protocol" | "stdin" | "arg" | undefined;
1406
- timeout_ms?: number | undefined;
1407
1438
  inherit_env?: boolean | undefined;
1408
1439
  env_policy?: "inherit" | "allowlist" | "denylist" | "explicit" | undefined;
1409
1440
  env_allowlist?: string[] | undefined;
@@ -1520,13 +1551,16 @@ declare const appConfigSchema: z.ZodObject<{
1520
1551
  provider: z.ZodDefault<z.ZodString>;
1521
1552
  base_url: z.ZodOptional<z.ZodString>;
1522
1553
  api_key_env_var: z.ZodOptional<z.ZodString>;
1554
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
1523
1555
  }, "strict", z.ZodTypeAny, {
1524
1556
  provider: string;
1525
1557
  base_url?: string | undefined;
1526
1558
  api_key_env_var?: string | undefined;
1559
+ timeout_ms?: number | undefined;
1527
1560
  }, {
1528
1561
  base_url?: string | undefined;
1529
1562
  api_key_env_var?: string | undefined;
1563
+ timeout_ms?: number | undefined;
1530
1564
  provider?: string | undefined;
1531
1565
  }>>;
1532
1566
  }, "strict", z.ZodTypeAny, {
@@ -1536,11 +1570,11 @@ declare const appConfigSchema: z.ZodObject<{
1536
1570
  type: "native" | "process" | "cli";
1537
1571
  input_mode: "protocol" | "stdin" | "arg";
1538
1572
  metadata?: Record<string, unknown> | undefined;
1573
+ timeout_ms?: number | undefined;
1539
1574
  command?: string | undefined;
1540
1575
  args?: string[] | undefined;
1541
1576
  cwd?: string | undefined;
1542
1577
  env?: Record<string, string> | undefined;
1543
- timeout_ms?: number | undefined;
1544
1578
  inherit_env?: boolean | undefined;
1545
1579
  env_policy?: "inherit" | "allowlist" | "denylist" | "explicit" | undefined;
1546
1580
  env_allowlist?: string[] | undefined;
@@ -1554,6 +1588,7 @@ declare const appConfigSchema: z.ZodObject<{
1554
1588
  base_url: string;
1555
1589
  metadata?: Record<string, unknown> | undefined;
1556
1590
  api_key_env_var?: string | undefined;
1591
+ timeout_ms?: number | undefined;
1557
1592
  headers?: Record<string, string> | undefined;
1558
1593
  enabled?: boolean | undefined;
1559
1594
  }[];
@@ -1592,6 +1627,7 @@ declare const appConfigSchema: z.ZodObject<{
1592
1627
  provider: string;
1593
1628
  base_url?: string | undefined;
1594
1629
  api_key_env_var?: string | undefined;
1630
+ timeout_ms?: number | undefined;
1595
1631
  } | undefined;
1596
1632
  }, {
1597
1633
  name: string;
@@ -1599,12 +1635,12 @@ declare const appConfigSchema: z.ZodObject<{
1599
1635
  name: string;
1600
1636
  metadata?: Record<string, unknown> | undefined;
1601
1637
  type?: "native" | "process" | "cli" | undefined;
1638
+ timeout_ms?: number | undefined;
1602
1639
  command?: string | undefined;
1603
1640
  args?: string[] | undefined;
1604
1641
  cwd?: string | undefined;
1605
1642
  env?: Record<string, string> | undefined;
1606
1643
  input_mode?: "protocol" | "stdin" | "arg" | undefined;
1607
- timeout_ms?: number | undefined;
1608
1644
  inherit_env?: boolean | undefined;
1609
1645
  env_policy?: "inherit" | "allowlist" | "denylist" | "explicit" | undefined;
1610
1646
  env_allowlist?: string[] | undefined;
@@ -1618,6 +1654,7 @@ declare const appConfigSchema: z.ZodObject<{
1618
1654
  base_url: string;
1619
1655
  metadata?: Record<string, unknown> | undefined;
1620
1656
  api_key_env_var?: string | undefined;
1657
+ timeout_ms?: number | undefined;
1621
1658
  headers?: Record<string, string> | undefined;
1622
1659
  enabled?: boolean | undefined;
1623
1660
  }[] | undefined;
@@ -1655,6 +1692,7 @@ declare const appConfigSchema: z.ZodObject<{
1655
1692
  memory?: {
1656
1693
  base_url?: string | undefined;
1657
1694
  api_key_env_var?: string | undefined;
1695
+ timeout_ms?: number | undefined;
1658
1696
  provider?: string | undefined;
1659
1697
  } | undefined;
1660
1698
  }>;
@@ -1673,11 +1711,11 @@ declare const appConfigSchema: z.ZodObject<{
1673
1711
  type: "native" | "process" | "cli";
1674
1712
  input_mode: "protocol" | "stdin" | "arg";
1675
1713
  metadata?: Record<string, unknown> | undefined;
1714
+ timeout_ms?: number | undefined;
1676
1715
  command?: string | undefined;
1677
1716
  args?: string[] | undefined;
1678
1717
  cwd?: string | undefined;
1679
1718
  env?: Record<string, string> | undefined;
1680
- timeout_ms?: number | undefined;
1681
1719
  inherit_env?: boolean | undefined;
1682
1720
  env_policy?: "inherit" | "allowlist" | "denylist" | "explicit" | undefined;
1683
1721
  env_allowlist?: string[] | undefined;
@@ -1691,6 +1729,7 @@ declare const appConfigSchema: z.ZodObject<{
1691
1729
  base_url: string;
1692
1730
  metadata?: Record<string, unknown> | undefined;
1693
1731
  api_key_env_var?: string | undefined;
1732
+ timeout_ms?: number | undefined;
1694
1733
  headers?: Record<string, string> | undefined;
1695
1734
  enabled?: boolean | undefined;
1696
1735
  }[];
@@ -1729,6 +1768,7 @@ declare const appConfigSchema: z.ZodObject<{
1729
1768
  provider: string;
1730
1769
  base_url?: string | undefined;
1731
1770
  api_key_env_var?: string | undefined;
1771
+ timeout_ms?: number | undefined;
1732
1772
  } | undefined;
1733
1773
  };
1734
1774
  logging?: {
@@ -1741,12 +1781,12 @@ declare const appConfigSchema: z.ZodObject<{
1741
1781
  name: string;
1742
1782
  metadata?: Record<string, unknown> | undefined;
1743
1783
  type?: "native" | "process" | "cli" | undefined;
1784
+ timeout_ms?: number | undefined;
1744
1785
  command?: string | undefined;
1745
1786
  args?: string[] | undefined;
1746
1787
  cwd?: string | undefined;
1747
1788
  env?: Record<string, string> | undefined;
1748
1789
  input_mode?: "protocol" | "stdin" | "arg" | undefined;
1749
- timeout_ms?: number | undefined;
1750
1790
  inherit_env?: boolean | undefined;
1751
1791
  env_policy?: "inherit" | "allowlist" | "denylist" | "explicit" | undefined;
1752
1792
  env_allowlist?: string[] | undefined;
@@ -1760,6 +1800,7 @@ declare const appConfigSchema: z.ZodObject<{
1760
1800
  base_url: string;
1761
1801
  metadata?: Record<string, unknown> | undefined;
1762
1802
  api_key_env_var?: string | undefined;
1803
+ timeout_ms?: number | undefined;
1763
1804
  headers?: Record<string, string> | undefined;
1764
1805
  enabled?: boolean | undefined;
1765
1806
  }[] | undefined;
@@ -1797,6 +1838,7 @@ declare const appConfigSchema: z.ZodObject<{
1797
1838
  memory?: {
1798
1839
  base_url?: string | undefined;
1799
1840
  api_key_env_var?: string | undefined;
1841
+ timeout_ms?: number | undefined;
1800
1842
  provider?: string | undefined;
1801
1843
  } | undefined;
1802
1844
  };
@@ -1923,12 +1965,19 @@ declare class OpenAICompatibleProvider implements IChatProvider {
1923
1965
  private discovered?;
1924
1966
  private readonly env;
1925
1967
  constructor(config: ProviderConfig, log?: Logger, env?: Record<string, string | undefined>);
1968
+ /** Provider-level request timeout (roadmap §6.6/§11) with the shared default. */
1969
+ private get requestTimeoutMs();
1926
1970
  /** Authenticate + discover (roadmap §10, Model Discovery). */
1927
1971
  connect(): Promise<ModelInfo[]>;
1928
1972
  getModel(modelId: string): Promise<ModelInfo | undefined>;
1973
+ /** Raw /models body (protected so adapters can capture gateway-level metadata). */
1974
+ protected rawModelsResponse(): Promise<unknown>;
1975
+ private modelsRequest;
1929
1976
  listModels(): Promise<ModelInfo[]>;
1930
1977
  /** Maps a raw model entry onto the normalized metadata shape (§10). */
1931
1978
  private toModelInfo;
1979
+ /** Streaming where the gateway supports it (§11). */
1980
+ stream(request: ChatRequest, onChunk: (chunk: ChatStreamChunk) => void): Promise<ChatResponse>;
1932
1981
  healthCheck(): Promise<ProviderStatus>;
1933
1982
  chat(request: ChatRequest): Promise<ChatResponse>;
1934
1983
  }
@@ -1971,10 +2020,18 @@ interface OmniHilbrasConnectionResult {
1971
2020
  registered: number;
1972
2021
  }
1973
2022
  declare class OmniHilbrasProvider extends OpenAICompatibleProvider {
2023
+ private gateway?;
2024
+ listModels(): Promise<ModelInfo[]>;
1974
2025
  /**
1975
2026
  * Run the full connect flow. Throws on authentication or transport failure
1976
2027
  * (use healthCheck() for a non-throwing probe).
1977
2028
  */
2029
+ /**
2030
+ * Gateway metadata reported alongside the model list (gateway version, tier,
2031
+ * region…), kept separate from per-model metadata (§11 — provider metadata).
2032
+ */
2033
+ gatewayMetadata(): Record<string, unknown> | undefined;
2034
+ protected extractGatewayMetadata(body: unknown): Promise<void>;
1978
2035
  connectAndRegister(registry?: ModelRegistry): Promise<OmniHilbrasConnectionResult>;
1979
2036
  }
1980
2037
 
@@ -2645,6 +2702,6 @@ declare class ProjectStores {
2645
2702
  constructor(directory?: string);
2646
2703
  }
2647
2704
 
2648
- declare const OMNINODE_VERSION = "2.0.0-alpha.6";
2705
+ declare const OMNINODE_VERSION = "2.0.0-alpha.7";
2649
2706
 
2650
- export { AgentAdapterRegistry, type AgentConfig, type AgentConfigYaml, type AgentDescriptor, AgentError, type AgentInfo, type AgentInputMode, type AgentIntegrationType, AgentRegistry, type AgentStatus, type AgentTaskInput, type AgentTaskOutput, type AgentToNodeMessage, type AggregateOptions, type AggregatedFinding, type AggregatedRecommendation, type AppConfig, type AppConfigYaml, type ArtifactKind, type ArtifactPayload, type AskedQuestion, type AuditAction, type AuditEvent, type AuditSink, type ChatFn, type ChatMessage, type ChatRequest, type ChatResponse, type ChatRole, type ChatUsage, type CombinedMeta, type CombinedReport, type CombinedReportFilter, type Confidence, ConfigError, ConsoleLogSink, type CreateTaskInput, type CwdValidation, DEFAULT_MAX_OUTPUT_BYTES, type DecodeResult, type DiscoveryResult, type EnvPolicy, type EnvelopeMeta, type ExecutionRecord, type ExtractionMeta, FileAuditLog, FilePipelineRunStore, FilePlanStore, FileReportStore, FileTaskStore, type Finding, type FindingSeverity, type FindingSource, type HelloResult, HeuristicPlanner, type HttpRequestOptions, type HttpResponse, type IAgent, type IAgentAdapter, type IChatProvider, type IMemoryProvider, type IPipelineExecutor, type IPlanner, type IProvider, type JsonDocument, JsonFileStore, type JsonFileStoreOptions, type LoadConfigOptions, LocalMemoryProvider, type LogLevel, type LogSink, Logger, type LoggerOptions, MAX_MESSAGE_BYTES, type MemoryContextQuery, type MemoryEntry, MemoryError, type MemoryProviderConfig, type MemoryQuery, type MemoryScope, MemoryService, type MessageEnvelope, type Modality, type ModelCapabilities, type ModelFilter, type ModelInfo, ModelPlanner, ModelRegistry, type ModelStatus, type NodeToAgentMessage, OMNINODE_VERSION, OPENAI_COMPATIBLE_TYPES, type OmniHilbrasConnectionResult, OmniHilbrasProvider, OmniNodeError, type OmniNodeErrorCode, type OmniNodeErrorOptions, OpenAICompatibleProvider, PROTOCOL_V2, type PipelineConfigYaml, type PipelineDefinition, PipelineEngine, type PipelineEngineOptions, PipelineError, type PipelineRun, type PipelineRunAttempt, type PipelineRunFilter, type PipelineRunOptions, type PipelineRunStatus, type PipelineRunStore, type PipelineStep, type PipelineStepCondition, type PipelineStepConfigYaml, type PipelineStepKind, type PipelineStepRun, type Plan, type PlanFilter, type PlanRequest, type PlanStep, type PlanStore, type PlannerConfigYaml, PlannerError, ProcessAgent, ProcessAgentAdapter, type Project, type ProjectConfigYaml, ProjectStores, type ProtocolAgentToNodeType, ProtocolDecoder, type ProtocolEnvelope, ProtocolError, type ProtocolMessageType, type ProtocolNodeToAgentType, ProtocolSession, type ProtocolViolation, type ProtocolViolationCode, type ProviderAuthentication, type ProviderCapability, type ProviderConfig, type ProviderConfigYaml, ProviderError, type ProviderErrorKind, type ProviderHealth, type ProviderStatus, type ProviderType, type QuestionPayload, type QuestionResponder, type RememberaConfig, RememberaMemoryProvider, type Report, type ReportFilter, type ReportPayload, ReportService, type ReportStore, type RoleConfigYaml, type RoleDefinition, RoleRegistry, type RunPipelineOptions, SUPPORTED_PROTOCOL_VERSIONS, type SessionIds, TERMINAL_TASK_STATUSES, type Task, type TaskContext, TaskEngine, type TaskEngineOptions, TaskError, type TaskPayload, type TaskResult, type TaskStatus, type TaskStore, type TaskStoreFilter, type WritableLike, agentConfigSchema, aggregateReports, appConfigSchema, authHeaders, buildAgentRegistry, buildChildEnv, buildHello, buildHelloAck, buildPipelineEngine, buildPlanner, buildPlannerContext, buildRoleRegistry, composeTaskText, createAgent, createDefaultChatFn, createMemoryProvider, createProvider, createTaskEngine, decodeMessage, decodeStream, defaultProjectConfigYaml, describeExit, encodeMessage, envelope, expandEnvRefs, extractMessage, extractReportFromText, findConfigFile, isNetworkError, isOmniNodeError, isRetryable, isSupportedProtocol, isTimeoutError, keywords, killTree, kindFromStatus, loadConfig, logger, newMessageId, parseHello, parsePlanJson, parseRetryAfter, pipelineConfigSchema, pipelineStepConfigSchema, plannerConfigSchema, projectConfigSchema, providerConfigSchema, providerHttpError, providerTransportError, registryKey, requestJson, requireCompletion, resolveApiKey, resolveEnvPolicy, roleConfigSchema, sanitizeChunk, similar, validateEnvelope, validateWorkingDirectory };
2707
+ export { AgentAdapterRegistry, type AgentConfig, type AgentConfigYaml, type AgentDescriptor, AgentError, type AgentInfo, type AgentInputMode, type AgentIntegrationType, AgentRegistry, type AgentStatus, type AgentTaskInput, type AgentTaskOutput, type AgentToNodeMessage, type AggregateOptions, type AggregatedFinding, type AggregatedRecommendation, type AppConfig, type AppConfigYaml, type ArtifactKind, type ArtifactPayload, type AskedQuestion, type AuditAction, type AuditEvent, type AuditSink, type ChatFn, type ChatMessage, type ChatRequest, type ChatResponse, type ChatRole, type ChatStreamChunk, type ChatUsage, type CombinedMeta, type CombinedReport, type CombinedReportFilter, type Confidence, ConfigError, ConsoleLogSink, type CreateTaskInput, type CwdValidation, DEFAULT_MAX_OUTPUT_BYTES, type DecodeResult, type DiscoveryResult, type EnvPolicy, type EnvelopeMeta, type ExecutionRecord, type ExtractionMeta, FileAuditLog, FilePipelineRunStore, FilePlanStore, FileReportStore, FileTaskStore, type Finding, type FindingSeverity, type FindingSource, type HelloResult, HeuristicPlanner, type HttpRequestOptions, type HttpResponse, type IAgent, type IAgentAdapter, type IChatProvider, type IMemoryProvider, type IPipelineExecutor, type IPlanner, type IProvider, type JsonDocument, JsonFileStore, type JsonFileStoreOptions, type LoadConfigOptions, LocalMemoryProvider, type LogLevel, type LogSink, Logger, type LoggerOptions, MAX_MESSAGE_BYTES, type MemoryContextQuery, type MemoryEntry, MemoryError, type MemoryProviderConfig, type MemoryQuery, type MemoryScope, MemoryService, type MessageEnvelope, type Modality, type ModelCapabilities, type ModelFilter, type ModelInfo, ModelPlanner, ModelRegistry, type ModelStatus, type NodeToAgentMessage, OMNINODE_VERSION, OPENAI_COMPATIBLE_TYPES, type OmniHilbrasConnectionResult, OmniHilbrasProvider, OmniNodeError, type OmniNodeErrorCode, type OmniNodeErrorOptions, OpenAICompatibleProvider, PROTOCOL_V2, type PipelineConfigYaml, type PipelineDefinition, PipelineEngine, type PipelineEngineOptions, PipelineError, type PipelineRun, type PipelineRunAttempt, type PipelineRunFilter, type PipelineRunOptions, type PipelineRunStatus, type PipelineRunStore, type PipelineStep, type PipelineStepCondition, type PipelineStepConfigYaml, type PipelineStepKind, type PipelineStepRun, type Plan, type PlanFilter, type PlanRequest, type PlanStep, type PlanStore, type PlannerConfigYaml, PlannerError, ProcessAgent, ProcessAgentAdapter, type Project, type ProjectConfigYaml, ProjectStores, type ProtocolAgentToNodeType, ProtocolDecoder, type ProtocolEnvelope, ProtocolError, type ProtocolMessageType, type ProtocolNodeToAgentType, ProtocolSession, type ProtocolViolation, type ProtocolViolationCode, type ProviderAuthentication, type ProviderCapability, type ProviderConfig, type ProviderConfigYaml, ProviderError, type ProviderErrorKind, type ProviderHealth, type ProviderStatus, type ProviderType, type QuestionPayload, type QuestionResponder, type RememberaConfig, RememberaMemoryProvider, type Report, type ReportFilter, type ReportPayload, ReportService, type ReportStore, type RoleConfigYaml, type RoleDefinition, RoleRegistry, type RunPipelineOptions, SUPPORTED_PROTOCOL_VERSIONS, type SessionIds, TERMINAL_TASK_STATUSES, type Task, type TaskContext, TaskEngine, type TaskEngineOptions, TaskError, type TaskPayload, type TaskResult, type TaskStatus, type TaskStore, type TaskStoreFilter, type WritableLike, agentConfigSchema, aggregateReports, appConfigSchema, authHeaders, buildAgentRegistry, buildChildEnv, buildHello, buildHelloAck, buildPipelineEngine, buildPlanner, buildPlannerContext, buildRoleRegistry, composeTaskText, createAgent, createDefaultChatFn, createMemoryProvider, createProvider, createTaskEngine, decodeMessage, decodeStream, defaultProjectConfigYaml, describeExit, encodeMessage, envelope, expandEnvRefs, extractMessage, extractReportFromText, findConfigFile, isNetworkError, isOmniNodeError, isRetryable, isSupportedProtocol, isTimeoutError, keywords, killTree, kindFromStatus, loadConfig, logger, newMessageId, parseHello, parsePlanJson, parseRetryAfter, pipelineConfigSchema, pipelineStepConfigSchema, plannerConfigSchema, projectConfigSchema, providerConfigSchema, providerHttpError, providerTransportError, registryKey, requestJson, requireCompletion, resolveApiKey, resolveEnvPolicy, roleConfigSchema, sanitizeChunk, similar, validateEnvelope, validateWorkingDirectory };
package/dist/index.js CHANGED
@@ -125,6 +125,7 @@ var providerConfigSchema = z.object({
125
125
  type: z.enum(["openai-compatible", "omnihilbras", "openrouter", "local", "custom"]),
126
126
  base_url: z.string().url(),
127
127
  api_key_env_var: z.string().min(1).optional(),
128
+ timeout_ms: z.number().int().positive().optional(),
128
129
  headers: z.record(z.string()).optional(),
129
130
  enabled: z.boolean().optional(),
130
131
  metadata: z.record(z.unknown()).optional()
@@ -189,7 +190,8 @@ var projectConfigSchema = z.object({
189
190
  memory: z.object({
190
191
  provider: z.string().min(1).default("local"),
191
192
  base_url: z.string().url().optional(),
192
- api_key_env_var: z.string().min(1).optional()
193
+ api_key_env_var: z.string().min(1).optional(),
194
+ timeout_ms: z.number().int().positive().optional()
193
195
  }).strict().optional()
194
196
  }).strict();
195
197
  var appConfigSchema = z.object({
@@ -302,6 +304,7 @@ function toProviderConfig(raw) {
302
304
  type: raw.type,
303
305
  baseUrl: raw.base_url,
304
306
  apiKeyEnvVar: raw.api_key_env_var,
307
+ timeoutMs: raw.timeout_ms,
305
308
  headers: raw.headers,
306
309
  enabled: raw.enabled,
307
310
  metadata: raw.metadata
@@ -524,6 +527,7 @@ function providerTransportError(context) {
524
527
  }
525
528
 
526
529
  // src/providers/openai-compatible/index.ts
530
+ var DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
527
531
  var OpenAICompatibleProvider = class {
528
532
  config;
529
533
  providerId;
@@ -543,6 +547,10 @@ var OpenAICompatibleProvider = class {
543
547
  };
544
548
  this.log = log.child({ provider: config.name });
545
549
  }
550
+ /** Provider-level request timeout (roadmap §6.6/§11) with the shared default. */
551
+ get requestTimeoutMs() {
552
+ return this.config.timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
553
+ }
546
554
  /** Authenticate + discover (roadmap §10, Model Discovery). */
547
555
  async connect() {
548
556
  authHeaders(this.config, this.env);
@@ -554,11 +562,17 @@ var OpenAICompatibleProvider = class {
554
562
  const models = this.discovered ?? await this.connect();
555
563
  return models.find((m) => m.id === modelId);
556
564
  }
557
- async listModels() {
565
+ /** Raw /models body (protected so adapters can capture gateway-level metadata). */
566
+ async rawModelsResponse() {
567
+ const response = await this.modelsRequest();
568
+ return response.body;
569
+ }
570
+ async modelsRequest() {
558
571
  let response;
559
572
  try {
560
573
  response = await requestJson(`${this.config.baseUrl}/models`, {
561
- headers: authHeaders(this.config, this.env)
574
+ headers: authHeaders(this.config, this.env),
575
+ timeoutMs: this.requestTimeoutMs
562
576
  });
563
577
  } catch (error) {
564
578
  if (error instanceof ProviderError) throw error;
@@ -573,6 +587,10 @@ var OpenAICompatibleProvider = class {
573
587
  body
574
588
  });
575
589
  }
590
+ return response;
591
+ }
592
+ async listModels() {
593
+ const body = await this.rawModelsResponse();
576
594
  const entries = extractModelEntries(body, this.config);
577
595
  const models = [];
578
596
  let skipped = 0;
@@ -615,6 +633,10 @@ var OpenAICompatibleProvider = class {
615
633
  }
616
634
  };
617
635
  }
636
+ /** Streaming where the gateway supports it (§11). */
637
+ stream(request, onChunk) {
638
+ return streamChatCompletion(this.config, request, onChunk, this.env);
639
+ }
618
640
  async healthCheck() {
619
641
  const lastCheckedAt = (/* @__PURE__ */ new Date()).toISOString();
620
642
  try {
@@ -649,6 +671,7 @@ var OpenAICompatibleProvider = class {
649
671
  response = await requestJson(`${this.config.baseUrl}/chat/completions`, {
650
672
  method: "POST",
651
673
  headers: authHeaders(this.config, this.env),
674
+ timeoutMs: this.requestTimeoutMs,
652
675
  body: {
653
676
  model: request.model,
654
677
  messages: request.messages,
@@ -693,6 +716,74 @@ var OpenAICompatibleProvider = class {
693
716
  };
694
717
  }
695
718
  };
719
+ async function streamChatCompletion(config, request, onChunk, env = process.env) {
720
+ const baseUrl = normalizeBaseUrl(config.baseUrl);
721
+ const timeoutMs = config.timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
722
+ let response;
723
+ try {
724
+ response = await fetch(`${baseUrl}/chat/completions`, {
725
+ method: "POST",
726
+ headers: {
727
+ accept: "text/event-stream",
728
+ "content-type": "application/json",
729
+ ...authHeaders(config, env)
730
+ },
731
+ body: JSON.stringify({
732
+ model: request.model,
733
+ messages: request.messages,
734
+ stream: true,
735
+ ...request.temperature !== void 0 ? { temperature: request.temperature } : {},
736
+ ...request.maxTokens !== void 0 ? { max_tokens: request.maxTokens } : {}
737
+ }),
738
+ signal: AbortSignal.timeout(timeoutMs)
739
+ });
740
+ } catch (error) {
741
+ throw providerTransportError({ provider: config.name, operation: "stream", cause: error });
742
+ }
743
+ if (!response.ok) {
744
+ const body = await response.json().catch(() => void 0);
745
+ throw providerHttpError({ provider: config.name, operation: "stream", status: response.status, body });
746
+ }
747
+ if (!response.body) {
748
+ throw providerHttpError({
749
+ provider: config.name,
750
+ operation: "stream",
751
+ status: 500,
752
+ body: { error: { message: "streaming is not supported by this endpoint" } }
753
+ });
754
+ }
755
+ let content = "";
756
+ let model = request.model;
757
+ let finishReason;
758
+ const decoder = new TextDecoder();
759
+ let buffer = "";
760
+ for await (const piece of response.body) {
761
+ buffer += decoder.decode(piece, { stream: true });
762
+ let newline = buffer.indexOf("\n");
763
+ while (newline >= 0) {
764
+ const line = buffer.slice(0, newline).trim();
765
+ buffer = buffer.slice(newline + 1);
766
+ newline = buffer.indexOf("\n");
767
+ if (line.length === 0 || line.startsWith(":")) continue;
768
+ const data = line.startsWith("data:") ? line.slice(5).trim() : line;
769
+ if (data === "[DONE]") continue;
770
+ let event;
771
+ try {
772
+ event = JSON.parse(data);
773
+ } catch {
774
+ continue;
775
+ }
776
+ if (typeof event.model === "string") model = event.model;
777
+ const choices = Array.isArray(event.choices) ? event.choices : [];
778
+ const first = choices[0];
779
+ const delta = typeof first?.delta?.content === "string" ? first.delta.content : "";
780
+ if (delta.length > 0) content += delta;
781
+ if (typeof first?.finish_reason === "string") finishReason = first.finish_reason;
782
+ onChunk({ delta, ...finishReason !== void 0 ? { finishReason } : {}, raw: event });
783
+ }
784
+ }
785
+ return { model, content, ...finishReason !== void 0 ? { finishReason } : {} };
786
+ }
696
787
  function normalizeModalities(value) {
697
788
  const list = Array.isArray(value) ? value : typeof value === "string" ? [value] : void 0;
698
789
  if (!list) return void 0;
@@ -726,10 +817,32 @@ function inferHealth(error) {
726
817
 
727
818
  // src/providers/omnihilbras/index.ts
728
819
  var OmniHilbrasProvider = class extends OpenAICompatibleProvider {
820
+ gateway;
821
+ async listModels() {
822
+ const raw = await this.rawModelsResponse();
823
+ await this.extractGatewayMetadata(raw);
824
+ const models = await super.listModels();
825
+ return this.gateway ? models.map((model) => ({ ...model, metadata: { ...model.metadata, gateway: this.gateway } })) : models;
826
+ }
729
827
  /**
730
828
  * Run the full connect flow. Throws on authentication or transport failure
731
829
  * (use healthCheck() for a non-throwing probe).
732
830
  */
831
+ /**
832
+ * Gateway metadata reported alongside the model list (gateway version, tier,
833
+ * region…), kept separate from per-model metadata (§11 — provider metadata).
834
+ */
835
+ gatewayMetadata() {
836
+ return this.gateway;
837
+ }
838
+ async extractGatewayMetadata(body) {
839
+ if (body !== null && typeof body === "object") {
840
+ const gateway = body.gateway;
841
+ if (gateway !== null && typeof gateway === "object") {
842
+ this.gateway = gateway;
843
+ }
844
+ }
845
+ }
733
846
  async connectAndRegister(registry) {
734
847
  const apiKey = resolveApiKey(this.config);
735
848
  const discovered = await this.listModels();
@@ -3477,7 +3590,7 @@ var ProjectStores = class {
3477
3590
  };
3478
3591
 
3479
3592
  // src/version.ts
3480
- var OMNINODE_VERSION = "2.0.0-alpha.6";
3593
+ var OMNINODE_VERSION = "2.0.0-alpha.7";
3481
3594
  export {
3482
3595
  AgentAdapterRegistry,
3483
3596
  AgentError,