@hivemagnus/ardent-client 3.3.0 → 3.4.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/README.md +46 -7
- package/dist/client.d.ts +60 -2
- package/dist/client.js +53 -6
- package/dist/generated.d.ts +297 -9
- package/dist/index.d.ts +2 -2
- package/dist/openapi.d.ts +18 -0
- package/dist/openapi.js +19 -0
- package/dist/routes.d.ts +401 -0
- package/dist/routes.js +460 -0
- package/dist/transport.d.ts +1 -1
- package/dist/transport.js +2 -2
- package/dist/types.d.ts +15 -0
- package/package.json +5 -1
package/dist/generated.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export interface paths {
|
|
|
26
26
|
path?: never;
|
|
27
27
|
cookie?: never;
|
|
28
28
|
};
|
|
29
|
+
/** @description HiveCommon readiness body plus problems. The configuration check runs first; the selected backend (codex or llamacpp) is probed only when the configuration is complete. A 503 keeps the status degraded. */
|
|
29
30
|
get: operations["getReadiness"];
|
|
30
31
|
put?: never;
|
|
31
32
|
post?: never;
|
|
@@ -189,6 +190,7 @@ export interface paths {
|
|
|
189
190
|
path?: never;
|
|
190
191
|
cookie?: never;
|
|
191
192
|
};
|
|
193
|
+
/** @description Tasks newest first (by created_ms, then id), one page at a time. Pass next as after for the following page; filters combine with AND. */
|
|
192
194
|
get: operations["listTasks"];
|
|
193
195
|
put?: never;
|
|
194
196
|
post: operations["submitTask"];
|
|
@@ -700,6 +702,7 @@ export interface paths {
|
|
|
700
702
|
path?: never;
|
|
701
703
|
cookie?: never;
|
|
702
704
|
};
|
|
705
|
+
/** @description Configured providers. codex.auth_mode is the Codex account status (or the probe error) for a Codex profile, and not_selected for a llama.cpp profile unless probe=codex is given. The Codex probe is shared with readiness and cached for 30 seconds. */
|
|
703
706
|
get: operations["getProviders"];
|
|
704
707
|
put?: never;
|
|
705
708
|
post?: never;
|
|
@@ -885,6 +888,57 @@ export interface paths {
|
|
|
885
888
|
patch?: never;
|
|
886
889
|
trace?: never;
|
|
887
890
|
};
|
|
891
|
+
"/api/v1/metrics": {
|
|
892
|
+
parameters: {
|
|
893
|
+
query?: never;
|
|
894
|
+
header?: never;
|
|
895
|
+
path?: never;
|
|
896
|
+
cookie?: never;
|
|
897
|
+
};
|
|
898
|
+
/** @description Profile metrics in the OpenMetrics text format: tasks by state, open recovery statuses, job windows, channel and A2A push deliveries by state, A2A rate-limit refusals since the process started (ardent_a2a_rate_limited_total by scope ip, peer or tasks) and Mattermost catch-up boundary and walk ages and gaps per channel. Gauges are read from the journal when scraped. */
|
|
899
|
+
get: operations["getMetrics"];
|
|
900
|
+
put?: never;
|
|
901
|
+
post?: never;
|
|
902
|
+
delete?: never;
|
|
903
|
+
options?: never;
|
|
904
|
+
head?: never;
|
|
905
|
+
patch?: never;
|
|
906
|
+
trace?: never;
|
|
907
|
+
};
|
|
908
|
+
"/api/v1/credentials/management/reload": {
|
|
909
|
+
parameters: {
|
|
910
|
+
query?: never;
|
|
911
|
+
header?: never;
|
|
912
|
+
path?: never;
|
|
913
|
+
cookie?: never;
|
|
914
|
+
};
|
|
915
|
+
get?: never;
|
|
916
|
+
put?: never;
|
|
917
|
+
/** @description Re-read the management token named by api.token_env from the profile environment file the gateway started from and require it for every later request, without a restart. A token the service environment set cannot be rotated this way (409). The replaced token is still accepted for overlap_seconds (default 300, at most 3600; 0 ends it now), so a caller can switch over. Authenticate this request with the token in use. The token is never returned. */
|
|
918
|
+
post: operations["reloadManagementCredential"];
|
|
919
|
+
delete?: never;
|
|
920
|
+
options?: never;
|
|
921
|
+
head?: never;
|
|
922
|
+
patch?: never;
|
|
923
|
+
trace?: never;
|
|
924
|
+
};
|
|
925
|
+
"/api/v1/credentials/peers/reload": {
|
|
926
|
+
parameters: {
|
|
927
|
+
query?: never;
|
|
928
|
+
header?: never;
|
|
929
|
+
path?: never;
|
|
930
|
+
cookie?: never;
|
|
931
|
+
};
|
|
932
|
+
get?: never;
|
|
933
|
+
put?: never;
|
|
934
|
+
/** @description Re-read the inbound and outbound tokens of every configured A2A peer from the profile environment file and use them without a restart (the peer list itself still needs a restart). A replaced inbound token is still accepted for overlap_seconds (default 300, at most 3600). The new set is validated as at startup; when it is not valid nothing changes. Tokens are never returned. */
|
|
935
|
+
post: operations["reloadPeerCredentials"];
|
|
936
|
+
delete?: never;
|
|
937
|
+
options?: never;
|
|
938
|
+
head?: never;
|
|
939
|
+
patch?: never;
|
|
940
|
+
trace?: never;
|
|
941
|
+
};
|
|
888
942
|
"/api/v1/memory/credential/reload": {
|
|
889
943
|
parameters: {
|
|
890
944
|
query?: never;
|
|
@@ -1004,12 +1058,20 @@ export interface operations {
|
|
|
1004
1058
|
};
|
|
1005
1059
|
requestBody?: never;
|
|
1006
1060
|
responses: {
|
|
1007
|
-
/** @description Process is running */
|
|
1061
|
+
/** @description Process is running (HiveCommon liveness body) */
|
|
1008
1062
|
200: {
|
|
1009
1063
|
headers: {
|
|
1010
1064
|
[name: string]: unknown;
|
|
1011
1065
|
};
|
|
1012
|
-
content
|
|
1066
|
+
content: {
|
|
1067
|
+
"application/json": {
|
|
1068
|
+
/** @enum {string} */
|
|
1069
|
+
status: "live";
|
|
1070
|
+
service: string;
|
|
1071
|
+
version: string;
|
|
1072
|
+
time: string;
|
|
1073
|
+
};
|
|
1074
|
+
};
|
|
1013
1075
|
};
|
|
1014
1076
|
};
|
|
1015
1077
|
};
|
|
@@ -1027,14 +1089,58 @@ export interface operations {
|
|
|
1027
1089
|
headers: {
|
|
1028
1090
|
[name: string]: unknown;
|
|
1029
1091
|
};
|
|
1030
|
-
content
|
|
1092
|
+
content: {
|
|
1093
|
+
"application/json": {
|
|
1094
|
+
/** @enum {string} */
|
|
1095
|
+
status: "ready" | "degraded";
|
|
1096
|
+
service: string;
|
|
1097
|
+
version: string;
|
|
1098
|
+
time: string;
|
|
1099
|
+
/** @description configuration, and codex or llamacpp when probed */
|
|
1100
|
+
checks: {
|
|
1101
|
+
[key: string]: {
|
|
1102
|
+
/** @enum {string} */
|
|
1103
|
+
status: "up" | "down";
|
|
1104
|
+
critical: boolean;
|
|
1105
|
+
latencyMs: number;
|
|
1106
|
+
error?: string;
|
|
1107
|
+
details?: {
|
|
1108
|
+
[key: string]: unknown;
|
|
1109
|
+
};
|
|
1110
|
+
};
|
|
1111
|
+
};
|
|
1112
|
+
problems: string[];
|
|
1113
|
+
};
|
|
1114
|
+
};
|
|
1031
1115
|
};
|
|
1032
1116
|
/** @description Runtime dependency unavailable */
|
|
1033
1117
|
503: {
|
|
1034
1118
|
headers: {
|
|
1035
1119
|
[name: string]: unknown;
|
|
1036
1120
|
};
|
|
1037
|
-
content
|
|
1121
|
+
content: {
|
|
1122
|
+
"application/json": {
|
|
1123
|
+
/** @enum {string} */
|
|
1124
|
+
status: "ready" | "degraded";
|
|
1125
|
+
service: string;
|
|
1126
|
+
version: string;
|
|
1127
|
+
time: string;
|
|
1128
|
+
/** @description configuration, and codex or llamacpp when probed */
|
|
1129
|
+
checks: {
|
|
1130
|
+
[key: string]: {
|
|
1131
|
+
/** @enum {string} */
|
|
1132
|
+
status: "up" | "down";
|
|
1133
|
+
critical: boolean;
|
|
1134
|
+
latencyMs: number;
|
|
1135
|
+
error?: string;
|
|
1136
|
+
details?: {
|
|
1137
|
+
[key: string]: unknown;
|
|
1138
|
+
};
|
|
1139
|
+
};
|
|
1140
|
+
};
|
|
1141
|
+
problems: string[];
|
|
1142
|
+
};
|
|
1143
|
+
};
|
|
1038
1144
|
};
|
|
1039
1145
|
};
|
|
1040
1146
|
};
|
|
@@ -1645,8 +1751,19 @@ export interface operations {
|
|
|
1645
1751
|
listTasks: {
|
|
1646
1752
|
parameters: {
|
|
1647
1753
|
query?: {
|
|
1648
|
-
/** @description Maximum number of
|
|
1754
|
+
/** @description Maximum number of tasks in the page */
|
|
1649
1755
|
limit?: number;
|
|
1756
|
+
/** @description Cursor from a previous page (next) */
|
|
1757
|
+
after?: string;
|
|
1758
|
+
/** @description Comma-separated task states */
|
|
1759
|
+
state?: string;
|
|
1760
|
+
context?: "direct" | "peer" | "scheduled" | "mission" | "preview";
|
|
1761
|
+
/** @description Exact caller, for example management or a peer ID */
|
|
1762
|
+
caller?: string;
|
|
1763
|
+
/** @description Tasks created at or after this time: epoch milliseconds or ISO 8601 */
|
|
1764
|
+
since?: string;
|
|
1765
|
+
/** @description Tasks created before this time: epoch milliseconds or ISO 8601 */
|
|
1766
|
+
until?: string;
|
|
1650
1767
|
};
|
|
1651
1768
|
header?: never;
|
|
1652
1769
|
path?: never;
|
|
@@ -1654,7 +1771,7 @@ export interface operations {
|
|
|
1654
1771
|
};
|
|
1655
1772
|
requestBody?: never;
|
|
1656
1773
|
responses: {
|
|
1657
|
-
/** @description
|
|
1774
|
+
/** @description One page of tasks; next is null on the last page */
|
|
1658
1775
|
200: {
|
|
1659
1776
|
headers: {
|
|
1660
1777
|
[name: string]: unknown;
|
|
@@ -1679,7 +1796,8 @@ export interface operations {
|
|
|
1679
1796
|
* "created_ms": 1790431200000,
|
|
1680
1797
|
* "updated_ms": 1790431200000
|
|
1681
1798
|
* }
|
|
1682
|
-
* ]
|
|
1799
|
+
* ],
|
|
1800
|
+
* "next": null
|
|
1683
1801
|
* }
|
|
1684
1802
|
*/
|
|
1685
1803
|
"application/json": {
|
|
@@ -1750,9 +1868,17 @@ export interface operations {
|
|
|
1750
1868
|
};
|
|
1751
1869
|
};
|
|
1752
1870
|
}[];
|
|
1871
|
+
next: string | null;
|
|
1753
1872
|
};
|
|
1754
1873
|
};
|
|
1755
1874
|
};
|
|
1875
|
+
/** @description Invalid filter or cursor */
|
|
1876
|
+
400: {
|
|
1877
|
+
headers: {
|
|
1878
|
+
[name: string]: unknown;
|
|
1879
|
+
};
|
|
1880
|
+
content?: never;
|
|
1881
|
+
};
|
|
1756
1882
|
};
|
|
1757
1883
|
};
|
|
1758
1884
|
submitTask: {
|
|
@@ -2655,7 +2781,7 @@ export interface operations {
|
|
|
2655
2781
|
};
|
|
2656
2782
|
requestBody?: never;
|
|
2657
2783
|
responses: {
|
|
2658
|
-
/** @description SSE task.event carries TaskEvent JSON with the journal sequence as its id; task.done carries Task JSON. While the task runs, task.text carries the visible reply text of the current model step ({step, text}, sent on connect and when a step starts) and task.delta appends to it. Live text has no event id, is not journaled and is not replayed; the completed task result is authoritative. */
|
|
2784
|
+
/** @description SSE task.event carries TaskEvent JSON with the journal sequence as its id; task.done carries Task JSON. An idle stream sends a `: keepalive` comment every 15 seconds. While the task runs, task.text carries the visible reply text of the current model step ({step, text}, sent on connect and when a step starts) and task.delta appends to it. Live text has no event id, is not journaled and is not replayed; the completed task result is authoritative. */
|
|
2659
2785
|
200: {
|
|
2660
2786
|
headers: {
|
|
2661
2787
|
[name: string]: unknown;
|
|
@@ -3626,7 +3752,10 @@ export interface operations {
|
|
|
3626
3752
|
};
|
|
3627
3753
|
getProviders: {
|
|
3628
3754
|
parameters: {
|
|
3629
|
-
query?:
|
|
3755
|
+
query?: {
|
|
3756
|
+
/** @description codex: probe the Codex account although llama.cpp is selected */
|
|
3757
|
+
probe?: "codex";
|
|
3758
|
+
};
|
|
3630
3759
|
header?: never;
|
|
3631
3760
|
path?: never;
|
|
3632
3761
|
cookie?: never;
|
|
@@ -3964,6 +4093,165 @@ export interface operations {
|
|
|
3964
4093
|
};
|
|
3965
4094
|
};
|
|
3966
4095
|
};
|
|
4096
|
+
getMetrics: {
|
|
4097
|
+
parameters: {
|
|
4098
|
+
query?: never;
|
|
4099
|
+
header?: never;
|
|
4100
|
+
path?: never;
|
|
4101
|
+
cookie?: never;
|
|
4102
|
+
};
|
|
4103
|
+
requestBody?: never;
|
|
4104
|
+
responses: {
|
|
4105
|
+
/** @description OpenMetrics text, ending with # EOF */
|
|
4106
|
+
200: {
|
|
4107
|
+
headers: {
|
|
4108
|
+
[name: string]: unknown;
|
|
4109
|
+
};
|
|
4110
|
+
content: {
|
|
4111
|
+
"application/openmetrics-text": string;
|
|
4112
|
+
};
|
|
4113
|
+
};
|
|
4114
|
+
/** @description Unauthorized */
|
|
4115
|
+
401: {
|
|
4116
|
+
headers: {
|
|
4117
|
+
[name: string]: unknown;
|
|
4118
|
+
};
|
|
4119
|
+
content?: never;
|
|
4120
|
+
};
|
|
4121
|
+
};
|
|
4122
|
+
};
|
|
4123
|
+
reloadManagementCredential: {
|
|
4124
|
+
parameters: {
|
|
4125
|
+
query?: never;
|
|
4126
|
+
header?: never;
|
|
4127
|
+
path?: never;
|
|
4128
|
+
cookie?: never;
|
|
4129
|
+
};
|
|
4130
|
+
requestBody?: {
|
|
4131
|
+
content: {
|
|
4132
|
+
"application/json": {
|
|
4133
|
+
overlap_seconds?: number;
|
|
4134
|
+
};
|
|
4135
|
+
};
|
|
4136
|
+
};
|
|
4137
|
+
responses: {
|
|
4138
|
+
/** @description Credential reloaded; changed is false when the file holds the token already in use */
|
|
4139
|
+
200: {
|
|
4140
|
+
headers: {
|
|
4141
|
+
[name: string]: unknown;
|
|
4142
|
+
};
|
|
4143
|
+
content: {
|
|
4144
|
+
"application/json": {
|
|
4145
|
+
/** @enum {boolean} */
|
|
4146
|
+
reloaded: true;
|
|
4147
|
+
token_env: string;
|
|
4148
|
+
changed: boolean;
|
|
4149
|
+
/**
|
|
4150
|
+
* Format: date-time
|
|
4151
|
+
* @description Until when the replaced token is still accepted, or null
|
|
4152
|
+
*/
|
|
4153
|
+
previous_valid_until: string | null;
|
|
4154
|
+
};
|
|
4155
|
+
};
|
|
4156
|
+
};
|
|
4157
|
+
/** @description Invalid request */
|
|
4158
|
+
400: {
|
|
4159
|
+
headers: {
|
|
4160
|
+
[name: string]: unknown;
|
|
4161
|
+
};
|
|
4162
|
+
content?: never;
|
|
4163
|
+
};
|
|
4164
|
+
/** @description Unauthorized */
|
|
4165
|
+
401: {
|
|
4166
|
+
headers: {
|
|
4167
|
+
[name: string]: unknown;
|
|
4168
|
+
};
|
|
4169
|
+
content?: never;
|
|
4170
|
+
};
|
|
4171
|
+
/** @description The service environment sets the token */
|
|
4172
|
+
409: {
|
|
4173
|
+
headers: {
|
|
4174
|
+
[name: string]: unknown;
|
|
4175
|
+
};
|
|
4176
|
+
content?: never;
|
|
4177
|
+
};
|
|
4178
|
+
/** @description Token missing, too short or malformed, or the environment file is unreadable; the token in use stays */
|
|
4179
|
+
422: {
|
|
4180
|
+
headers: {
|
|
4181
|
+
[name: string]: unknown;
|
|
4182
|
+
};
|
|
4183
|
+
content?: never;
|
|
4184
|
+
};
|
|
4185
|
+
};
|
|
4186
|
+
};
|
|
4187
|
+
reloadPeerCredentials: {
|
|
4188
|
+
parameters: {
|
|
4189
|
+
query?: never;
|
|
4190
|
+
header?: never;
|
|
4191
|
+
path?: never;
|
|
4192
|
+
cookie?: never;
|
|
4193
|
+
};
|
|
4194
|
+
requestBody?: {
|
|
4195
|
+
content: {
|
|
4196
|
+
"application/json": {
|
|
4197
|
+
overlap_seconds?: number;
|
|
4198
|
+
};
|
|
4199
|
+
};
|
|
4200
|
+
};
|
|
4201
|
+
responses: {
|
|
4202
|
+
/** @description Peer credentials reloaded */
|
|
4203
|
+
200: {
|
|
4204
|
+
headers: {
|
|
4205
|
+
[name: string]: unknown;
|
|
4206
|
+
};
|
|
4207
|
+
content: {
|
|
4208
|
+
"application/json": {
|
|
4209
|
+
/** @enum {boolean} */
|
|
4210
|
+
reloaded: true;
|
|
4211
|
+
/** @description Enabled peers */
|
|
4212
|
+
peers: number;
|
|
4213
|
+
/** @description Peers whose inbound token changed */
|
|
4214
|
+
changed: string[];
|
|
4215
|
+
/** @description Token variables the service environment sets; they are not read from the file */
|
|
4216
|
+
service_environment: string[];
|
|
4217
|
+
/**
|
|
4218
|
+
* Format: date-time
|
|
4219
|
+
* @description Until when the replaced inbound tokens are still accepted, or null
|
|
4220
|
+
*/
|
|
4221
|
+
previous_valid_until: string | null;
|
|
4222
|
+
};
|
|
4223
|
+
};
|
|
4224
|
+
};
|
|
4225
|
+
/** @description Invalid request */
|
|
4226
|
+
400: {
|
|
4227
|
+
headers: {
|
|
4228
|
+
[name: string]: unknown;
|
|
4229
|
+
};
|
|
4230
|
+
content?: never;
|
|
4231
|
+
};
|
|
4232
|
+
/** @description Unauthorized */
|
|
4233
|
+
401: {
|
|
4234
|
+
headers: {
|
|
4235
|
+
[name: string]: unknown;
|
|
4236
|
+
};
|
|
4237
|
+
content?: never;
|
|
4238
|
+
};
|
|
4239
|
+
/** @description The A2A surface is not running */
|
|
4240
|
+
409: {
|
|
4241
|
+
headers: {
|
|
4242
|
+
[name: string]: unknown;
|
|
4243
|
+
};
|
|
4244
|
+
content?: never;
|
|
4245
|
+
};
|
|
4246
|
+
/** @description A peer credential is missing, too short, reused or not directional, or the environment file is unreadable; the credentials in use stay */
|
|
4247
|
+
422: {
|
|
4248
|
+
headers: {
|
|
4249
|
+
[name: string]: unknown;
|
|
4250
|
+
};
|
|
4251
|
+
content?: never;
|
|
4252
|
+
};
|
|
4253
|
+
};
|
|
4254
|
+
};
|
|
3967
4255
|
reloadMemoryCredential: {
|
|
3968
4256
|
parameters: {
|
|
3969
4257
|
query?: never;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
* and in modern browsers.
|
|
5
5
|
*/
|
|
6
6
|
export { createArdentClient } from './client.js';
|
|
7
|
-
export type { ArdentCapabilities, ArdentClient, ArdentClientOptions, CallOptions, FollowTaskOptions, RecoveryDecision, SubmitInput, } from './client.js';
|
|
7
|
+
export type { ArdentCapabilities, ArdentClient, ArdentClientOptions, CallOptions, FollowTaskOptions, MissionInput, PreviewInput, RecoveryDecision, SubmitInput, TaskFilter, } from './client.js';
|
|
8
8
|
export { direct, viaMagnus } from './transport.js';
|
|
9
9
|
export type { ArdentTransport, DirectTransportOptions, FetchLike, MagnusTransportOptions, ResolvedMagnusTransportOptions, TokenProvider } from './transport.js';
|
|
10
10
|
export type { FollowOptions } from './follow.js';
|
|
11
11
|
export type { ArtifactDownload, DownloadOptions, DownloadProgress, ResumeSource } from './download.js';
|
|
12
12
|
export { ArdentClientError, ConflictError, DigestMismatchError, NotFoundError, TransportError, UnauthorizedError, UnsupportedCapabilityError, } from './errors.js';
|
|
13
13
|
export { Sha256 } from './sha256.js';
|
|
14
|
-
export type { ArtifactImport, ArtifactImportAccepted, ArtifactImportRequest, ArtifactRecord, ArtifactRecordV2, ArtifactRendition, Lineage, OperationalStatus, Recovery, RecoveryAction, RecoveryDecisionBody, Session, SessionContext, SessionMessage, Task, TaskAccepted, TaskAdmission, TaskEvent, TaskState, TaskText, } from './types.js';
|
|
14
|
+
export type { ArtifactImport, ArtifactImportAccepted, ArtifactImportRequest, ArtifactRecord, ArtifactRecordV2, ArtifactRendition, DevelopmentNote, DevelopmentPage, DevelopmentRecord, Lineage, MissionContextItem, MissionSubmitBody, OperationalStatus, PreviewOverrides, PreviewSubmitBody, Recovery, RecoveryAction, RecoveryDecisionBody, Session, SessionContext, SessionMessage, Task, TaskAccepted, TaskAdmission, TaskContext, TaskEvent, TaskPage, TaskState, TaskText, TeamMission, } from './types.js';
|
|
15
15
|
export type { paths, operations, components } from './generated.js';
|
|
16
16
|
export type { ExecutionContext } from '@hivemagnus/hive-common/execution';
|
|
17
17
|
export type { RenditionRequest } from '@hivemagnus/hive-common/artifact';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@hivemagnus/ardent-client/openapi`: the management API's generated OpenAPI types and its
|
|
3
|
+
* route manifest, for code that proxies or allowlists Ardent routes (such as Magnus's node
|
|
4
|
+
* agent) instead of regenerating them. Types and data only: it imports nothing at run time.
|
|
5
|
+
*/
|
|
6
|
+
import { ARDENT_ROUTES } from './routes.js';
|
|
7
|
+
export type { paths, operations, components } from './generated.js';
|
|
8
|
+
export { ARDENT_ROUTES } from './routes.js';
|
|
9
|
+
/** One management API operation. */
|
|
10
|
+
export type ArdentRoute = (typeof ARDENT_ROUTES)[number];
|
|
11
|
+
/** `read` for GET, `action` for every other method. */
|
|
12
|
+
export type ArdentRouteKind = ArdentRoute['kind'];
|
|
13
|
+
export type ArdentOperationId = ArdentRoute['operationId'];
|
|
14
|
+
/**
|
|
15
|
+
* The route a request matches, or undefined. `path` is the request path (no query), such as
|
|
16
|
+
* `/api/v1/tasks/<id>/events`. A literal segment wins over a parameter, as the server routes.
|
|
17
|
+
*/
|
|
18
|
+
export declare function matchArdentRoute(method: string, path: string): ArdentRoute | undefined;
|
package/dist/openapi.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@hivemagnus/ardent-client/openapi`: the management API's generated OpenAPI types and its
|
|
3
|
+
* route manifest, for code that proxies or allowlists Ardent routes (such as Magnus's node
|
|
4
|
+
* agent) instead of regenerating them. Types and data only: it imports nothing at run time.
|
|
5
|
+
*/
|
|
6
|
+
import { ARDENT_ROUTES } from './routes.js';
|
|
7
|
+
export { ARDENT_ROUTES } from './routes.js';
|
|
8
|
+
const patterns = ARDENT_ROUTES.map(route => ({ route,
|
|
9
|
+
pattern: new RegExp(`^${route.path.replace(/[.*+?^$()|[\]\\]/g, '\\$&').replace(/\{[^}/]+\}/g, '[^/]+')}$`) }));
|
|
10
|
+
/**
|
|
11
|
+
* The route a request matches, or undefined. `path` is the request path (no query), such as
|
|
12
|
+
* `/api/v1/tasks/<id>/events`. A literal segment wins over a parameter, as the server routes.
|
|
13
|
+
*/
|
|
14
|
+
export function matchArdentRoute(method, path) {
|
|
15
|
+
const upper = method.toUpperCase();
|
|
16
|
+
const parameters = (route) => route.path.split('{').length - 1;
|
|
17
|
+
return patterns.filter(entry => entry.route.method === upper && entry.pattern.test(path)).map(entry => entry.route)
|
|
18
|
+
.sort((a, b) => parameters(a) - parameters(b))[0];
|
|
19
|
+
}
|