@openbkn/bkn-sdk 0.1.1-alpha.8 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -0
- package/NOTICE +21 -0
- package/README.md +31 -25
- package/README.zh.md +10 -12
- package/dist/{chunk-DTU5DGJW.js → chunk-NC6DZ2AU.js} +648 -194
- package/dist/cli.js +504 -179
- package/dist/index.d.ts +383 -64
- package/dist/index.js +1 -1
- package/package.json +5 -4
- package/dist/chunk-DTU5DGJW.js.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -59,12 +59,64 @@ interface RawCallResult {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
62
|
+
* bkn-safe admin API (`/api/safe/v1/admin/*`, token-gated; the gateway-exposed
|
|
63
|
+
* replacement for the retired ISF UserManagement / Authorization / EACP). The
|
|
64
|
+
* logged-in user must be an admin: 401 = no/invalid token, 403 = not an admin.
|
|
65
|
+
* Only `audit list` has no endpoint (login-log retired by design). Response
|
|
66
|
+
* shapes: `{users|roles|departments, total}`; department `parent_id` (not the
|
|
67
|
+
* ISF `parent_deps[]`). See docs/exec-plans/admin-bkn-safe-migration.md.
|
|
68
|
+
* Also carries the cluster license hub (`/admin/license/*`, issue #224).
|
|
66
69
|
*/
|
|
67
70
|
|
|
71
|
+
/** licverify judgement states. `invalid` also covers "no license installed". */
|
|
72
|
+
type LicenseState = "valid" | "grace" | "fallback_community" | "invalid";
|
|
73
|
+
/** GET /admin/license response (admin detail view). */
|
|
74
|
+
interface LicenseDetail {
|
|
75
|
+
state: LicenseState;
|
|
76
|
+
/** Whether the installed license is fingerprint-bound to this instance. */
|
|
77
|
+
activated: boolean;
|
|
78
|
+
/** This cluster's machine code (present even with no license installed). */
|
|
79
|
+
instance_fp: string;
|
|
80
|
+
error?: string;
|
|
81
|
+
/** Background auto-renew failure — license itself may still be valid. */
|
|
82
|
+
renew_error?: string;
|
|
83
|
+
edition?: string;
|
|
84
|
+
lic_id?: string;
|
|
85
|
+
customer?: {
|
|
86
|
+
name?: string;
|
|
87
|
+
[k: string]: unknown;
|
|
88
|
+
};
|
|
89
|
+
/** Unix seconds; expires_at 0 = never expires (community). */
|
|
90
|
+
issued_at?: number;
|
|
91
|
+
expires_at?: number;
|
|
92
|
+
contract_expires_at?: number;
|
|
93
|
+
/** Only present in `grace` state. */
|
|
94
|
+
grace_remaining_days?: number;
|
|
95
|
+
features?: string[];
|
|
96
|
+
limits?: Record<string, number>;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Import outcome. Plain success = the stored license's detail. `stored: true`
|
|
100
|
+
* = the .lic was verified and stored, but issuer activation failed (HTTP
|
|
101
|
+
* 409/502) — both facts matter, the import is not lost.
|
|
102
|
+
*/
|
|
103
|
+
type LicenseImportResult = LicenseDetail | {
|
|
104
|
+
stored: true;
|
|
105
|
+
error: string;
|
|
106
|
+
license: LicenseDetail;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Admin (operator) input shapes — the CLI-facing contract for the `admin`
|
|
111
|
+
* command group. `src/resources/admin.ts` maps each of these onto the bkn-safe
|
|
112
|
+
* client in `./safe.ts`, which is where the requests live.
|
|
113
|
+
*
|
|
114
|
+
* The ISF clients that used to back these types (`/api/user-management/v1`,
|
|
115
|
+
* `/api/authorization/v1`, `/isfweb/api/ShareMgnt`, `/api/eacp/v1`) were removed
|
|
116
|
+
* once ISF was retired — see docs/exec-plans/admin-bkn-safe-migration.md. Some
|
|
117
|
+
* fields here are wider than bkn-safe accepts and are dropped in the mapping;
|
|
118
|
+
* that lossiness is documented in the migration plan.
|
|
119
|
+
*/
|
|
68
120
|
interface AdminListOptions {
|
|
69
121
|
role?: string;
|
|
70
122
|
offset?: number;
|
|
@@ -184,6 +236,17 @@ declare function admin(ctx: RequestContext): {
|
|
|
184
236
|
ok: true;
|
|
185
237
|
}>;
|
|
186
238
|
auditList: (_opts?: AuditListOptions) => never;
|
|
239
|
+
licenseGet: () => Promise<LicenseDetail>;
|
|
240
|
+
licenseImport: (licenseText: string, opts?: {
|
|
241
|
+
receipt?: boolean;
|
|
242
|
+
}) => Promise<LicenseImportResult>;
|
|
243
|
+
licenseActivate: () => Promise<LicenseDetail>;
|
|
244
|
+
licenseRemove: () => Promise<{
|
|
245
|
+
ok: true;
|
|
246
|
+
}>;
|
|
247
|
+
licenseFingerprint: () => Promise<{
|
|
248
|
+
instance_fp: string;
|
|
249
|
+
}>;
|
|
187
250
|
};
|
|
188
251
|
|
|
189
252
|
interface ChatResult {
|
|
@@ -197,8 +260,10 @@ interface SendChatOptions {
|
|
|
197
260
|
}
|
|
198
261
|
|
|
199
262
|
/**
|
|
200
|
-
* Agent client (agent-factory v3). Read side + published listing
|
|
201
|
-
*
|
|
263
|
+
* Agent client (agent-factory v3). Read side + published listing.
|
|
264
|
+
* Responses passed through as parsed JSON.
|
|
265
|
+
* @deprecated The Decision Agent (agent-factory) surface is being phased out and
|
|
266
|
+
* may be removed in a future release. Avoid building new integrations on it.
|
|
202
267
|
*/
|
|
203
268
|
|
|
204
269
|
interface ListAgentsOptions {
|
|
@@ -215,6 +280,11 @@ interface PagingOptions {
|
|
|
215
280
|
name?: string;
|
|
216
281
|
}
|
|
217
282
|
|
|
283
|
+
/**
|
|
284
|
+
* Decision Agent resource surface.
|
|
285
|
+
* @deprecated The Decision Agent (agent-factory) surface is being phased out and
|
|
286
|
+
* may be removed in a future release. Avoid building new integrations on it.
|
|
287
|
+
*/
|
|
218
288
|
declare function agents(ctx: RequestContext): {
|
|
219
289
|
list: (opts?: ListAgentsOptions) => Promise<unknown>;
|
|
220
290
|
get: (agentId: string) => Promise<unknown>;
|
|
@@ -245,9 +315,66 @@ declare function agents(ctx: RequestContext): {
|
|
|
245
315
|
}) => Promise<ChatResult>;
|
|
246
316
|
};
|
|
247
317
|
|
|
318
|
+
/**
|
|
319
|
+
* AppKey API (`/api/safe/v1/{me,admin}/api-keys`, OAuth-token-gated). AppKeys
|
|
320
|
+
* are user-issued long-lived credentials (prefix `bak_`) that authenticate AS
|
|
321
|
+
* their owner — downstream authorization is identical to that owner's OAuth
|
|
322
|
+
* token. Issuing/managing them needs a real OAuth session (an AppKey itself
|
|
323
|
+
* cannot mint AppKeys). The plaintext `key` is returned ONCE, on create.
|
|
324
|
+
* Usage of an AppKey is drop-in: pass it as the bearer `--token` against the
|
|
325
|
+
* Context Loader (agent-retrieval) MCP/REST surface. See issue #75.
|
|
326
|
+
*/
|
|
327
|
+
|
|
328
|
+
/** A key's public metadata — never carries the secret. */
|
|
329
|
+
interface ApiKey {
|
|
330
|
+
id: string;
|
|
331
|
+
key_id: string;
|
|
332
|
+
name: string;
|
|
333
|
+
/** Masked preview for display, e.g. `bak_b3ff****b234` — safe to show in lists. */
|
|
334
|
+
masked: string;
|
|
335
|
+
enabled: boolean;
|
|
336
|
+
/** `null` = never expires. */
|
|
337
|
+
expires_at: string | null;
|
|
338
|
+
/** `null` = never used (zombie-key signal). */
|
|
339
|
+
last_used_at: string | null;
|
|
340
|
+
created_at: string;
|
|
341
|
+
/** Present only on the admin list. */
|
|
342
|
+
owner_user_id?: string;
|
|
343
|
+
}
|
|
344
|
+
/** Create response — `key` is the full plaintext, shown only this once. */
|
|
345
|
+
interface CreatedApiKey extends ApiKey {
|
|
346
|
+
key: string;
|
|
347
|
+
}
|
|
348
|
+
interface CreateApiKeyInput {
|
|
349
|
+
name: string;
|
|
350
|
+
/** RFC3339; omit = backend default (1 year). Must be in the future. */
|
|
351
|
+
expiresAt?: string;
|
|
352
|
+
/** `true` = never expire (wins over `expiresAt`). */
|
|
353
|
+
neverExpire?: boolean;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
declare function appKeys(ctx: RequestContext): {
|
|
357
|
+
/** List the caller's own keys (no secrets). */
|
|
358
|
+
list: () => Promise<{
|
|
359
|
+
keys: ApiKey[];
|
|
360
|
+
}>;
|
|
361
|
+
/** Issue a key — the result's `key` is the plaintext, shown only once. */
|
|
362
|
+
create: (input: CreateApiKeyInput) => Promise<CreatedApiKey>;
|
|
363
|
+
/** Revoke one of the caller's keys (immediate). */
|
|
364
|
+
revoke: (id: string) => Promise<void>;
|
|
365
|
+
/** Rotate a key in place — new plaintext (shown once); old secret dies now. */
|
|
366
|
+
regenerate: (id: string) => Promise<CreatedApiKey>;
|
|
367
|
+
/** Admin: list all keys, or one owner's (adds `owner_user_id`). */
|
|
368
|
+
adminList: (ownerId?: string) => Promise<{
|
|
369
|
+
keys: ApiKey[];
|
|
370
|
+
}>;
|
|
371
|
+
/** Admin: revoke any key. */
|
|
372
|
+
adminRevoke: (id: string) => Promise<void>;
|
|
373
|
+
};
|
|
374
|
+
|
|
248
375
|
/**
|
|
249
376
|
* Context-loader client over the agent-retrieval MCP endpoint (JSON-RPC).
|
|
250
|
-
*
|
|
377
|
+
* Slim implementation: initialize → session id →
|
|
251
378
|
* notifications/initialized, then tools/call. Handles plain-JSON and
|
|
252
379
|
* SSE (`data:`) response bodies. Per-process session cache (5 min TTL).
|
|
253
380
|
*/
|
|
@@ -256,6 +383,8 @@ interface SearchSchemaOptions {
|
|
|
256
383
|
searchScope?: string[];
|
|
257
384
|
maxConcepts?: number;
|
|
258
385
|
}
|
|
386
|
+
/** Progressive KN-detail disclosure level: `summary` (skeleton + property names) | `full`. */
|
|
387
|
+
type DetailLevel = "summary" | "full";
|
|
259
388
|
|
|
260
389
|
/** Context-loader resource surface (MCP over agent-retrieval). */
|
|
261
390
|
|
|
@@ -263,8 +392,13 @@ declare function context(ctx: RequestContext): {
|
|
|
263
392
|
searchSchema: (knId: string, query: string, opts?: SearchSchemaOptions) => Promise<unknown>;
|
|
264
393
|
queryObjectInstance: (knId: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
265
394
|
findSkills: (knId: string, objectTypeId: string, topK?: number) => Promise<unknown>;
|
|
395
|
+
knDetail: (knId: string, detailLevel?: DetailLevel) => Promise<unknown>;
|
|
396
|
+
objectTypes: (knId: string, ids: string[]) => Promise<unknown>;
|
|
397
|
+
relationTypes: (knId: string, ids: string[]) => Promise<unknown>;
|
|
398
|
+
info: () => Promise<unknown>;
|
|
266
399
|
tools: (knId: string) => Promise<unknown>;
|
|
267
400
|
toolCall: (knId: string, name: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
401
|
+
callMethod: (knId: string, method: string, params?: Record<string, unknown>) => Promise<unknown>;
|
|
268
402
|
queryInstanceSubgraph: (knId: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
269
403
|
logicProperties: (knId: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
270
404
|
actionInfo: (knId: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
@@ -286,7 +420,7 @@ interface TemplateArg {
|
|
|
286
420
|
|
|
287
421
|
/**
|
|
288
422
|
* Dataflow backend client (automation v2). Read endpoints (list/runs/logs) are
|
|
289
|
-
* implemented
|
|
423
|
+
* implemented; trigger/create bodies are deferred until the
|
|
290
424
|
* contract is verified on a live env. Responses passed through as parsed JSON.
|
|
291
425
|
*/
|
|
292
426
|
|
|
@@ -318,7 +452,7 @@ declare function dataflows(ctx: RequestContext): {
|
|
|
318
452
|
|
|
319
453
|
/**
|
|
320
454
|
* Knowledge-network backend client (ontology-manager + agent-retrieval).
|
|
321
|
-
*
|
|
455
|
+
* Responses are passed through as parsed JSON
|
|
322
456
|
* (shapes vary by backend version — validate at higher layers as needed).
|
|
323
457
|
*/
|
|
324
458
|
|
|
@@ -365,7 +499,7 @@ interface CreateFromCatalogOptions {
|
|
|
365
499
|
tables?: string[];
|
|
366
500
|
pkMap?: Record<string, string>;
|
|
367
501
|
build?: boolean;
|
|
368
|
-
/** Per-table resource columns to vectorize (sets
|
|
502
|
+
/** Per-table resource columns to vectorize (sets resource schema index features). */
|
|
369
503
|
embeddingFields?: Record<string, string[]>;
|
|
370
504
|
embeddingModel?: string;
|
|
371
505
|
noRollback?: boolean;
|
|
@@ -492,6 +626,8 @@ declare function models(ctx: RequestContext): {
|
|
|
492
626
|
edit: (body: unknown) => Promise<unknown>;
|
|
493
627
|
delete: (modelIds: string[]) => Promise<unknown>;
|
|
494
628
|
test: (body: unknown) => Promise<unknown>;
|
|
629
|
+
/** Set (or clear) the system default LLM. */
|
|
630
|
+
setDefault: (modelId: string, isDefault?: boolean) => Promise<unknown>;
|
|
495
631
|
};
|
|
496
632
|
small: {
|
|
497
633
|
list: (opts?: ListModelsOptions) => Promise<unknown>;
|
|
@@ -502,21 +638,86 @@ declare function models(ctx: RequestContext): {
|
|
|
502
638
|
edit: (body: unknown) => Promise<unknown>;
|
|
503
639
|
delete: (modelIds: string[]) => Promise<unknown>;
|
|
504
640
|
test: (body: unknown) => Promise<unknown>;
|
|
641
|
+
/** Set (or clear) the system default small model (type inferred from the model). */
|
|
642
|
+
setDefault: (modelId: string, isDefault?: boolean) => Promise<unknown>;
|
|
643
|
+
/** Get the system default small model for a type (default "embedding"). */
|
|
644
|
+
getDefault: (modelType?: string) => Promise<unknown>;
|
|
505
645
|
};
|
|
506
646
|
};
|
|
507
647
|
|
|
508
648
|
/**
|
|
509
|
-
* Vega-backend resource client (list/find/get/query/delete).
|
|
510
|
-
*
|
|
649
|
+
* Vega-backend resource client (list/find/get/query/delete).
|
|
650
|
+
* Responses passed through as parsed JSON.
|
|
511
651
|
*/
|
|
512
652
|
|
|
653
|
+
interface PropertyFeature {
|
|
654
|
+
name?: string;
|
|
655
|
+
display_name?: string;
|
|
656
|
+
feature_type: "keyword" | "fulltext" | "vector" | string;
|
|
657
|
+
description?: string;
|
|
658
|
+
ref_property?: string;
|
|
659
|
+
is_default?: boolean;
|
|
660
|
+
is_native?: boolean;
|
|
661
|
+
config?: Record<string, unknown>;
|
|
662
|
+
}
|
|
663
|
+
interface ResourceProperty {
|
|
664
|
+
name: string;
|
|
665
|
+
display_name?: string;
|
|
666
|
+
type?: string;
|
|
667
|
+
description?: string;
|
|
668
|
+
original_name?: string;
|
|
669
|
+
original_type?: string;
|
|
670
|
+
original_description?: string;
|
|
671
|
+
features?: PropertyFeature[];
|
|
672
|
+
attributes?: Record<string, unknown>;
|
|
673
|
+
extensions?: Record<string, string>;
|
|
674
|
+
}
|
|
675
|
+
interface ResourceIndexConfig {
|
|
676
|
+
build_key_fields?: string[];
|
|
677
|
+
default_fulltext_analyzer?: string;
|
|
678
|
+
default_embedding_model?: string;
|
|
679
|
+
}
|
|
513
680
|
interface ListResourcesOptions {
|
|
514
681
|
datasourceId?: string;
|
|
515
682
|
name?: string;
|
|
516
683
|
/** Resource category, e.g. table | logicview. */
|
|
517
684
|
category?: string;
|
|
685
|
+
status?: string;
|
|
686
|
+
database?: string;
|
|
518
687
|
limit?: number;
|
|
688
|
+
offset?: number;
|
|
689
|
+
sort?: "name" | "create_time" | "update_time" | string;
|
|
690
|
+
direction?: "asc" | "desc";
|
|
691
|
+
includeExtensions?: boolean;
|
|
692
|
+
includeExtensionKeys?: string;
|
|
693
|
+
extensionPairs?: Array<{
|
|
694
|
+
key: string;
|
|
695
|
+
value: string;
|
|
696
|
+
}>;
|
|
519
697
|
}
|
|
698
|
+
interface UpdateResourceOptions {
|
|
699
|
+
name?: string;
|
|
700
|
+
catalogId?: string;
|
|
701
|
+
tags?: string[];
|
|
702
|
+
description?: string;
|
|
703
|
+
category?: string;
|
|
704
|
+
status?: string;
|
|
705
|
+
database?: string;
|
|
706
|
+
sourceIdentifier?: string;
|
|
707
|
+
sourceMetadata?: Record<string, unknown>;
|
|
708
|
+
schemaDefinition?: ResourceProperty[];
|
|
709
|
+
indexConfig?: ResourceIndexConfig | null;
|
|
710
|
+
logicDefinition?: unknown;
|
|
711
|
+
extensions?: Record<string, string>;
|
|
712
|
+
}
|
|
713
|
+
interface ConfigureResourceIndexOptions {
|
|
714
|
+
buildKeyFields?: string[];
|
|
715
|
+
embeddingFields?: string[];
|
|
716
|
+
embeddingModel?: string;
|
|
717
|
+
fulltextFields?: string[];
|
|
718
|
+
fulltextAnalyzer?: string;
|
|
719
|
+
}
|
|
720
|
+
declare function configureResourceIndex(ctx: RequestContext, id: string, opts: ConfigureResourceIndexOptions): Promise<unknown>;
|
|
520
721
|
interface FindResourceOptions {
|
|
521
722
|
datasourceId?: string;
|
|
522
723
|
/** Exact name match instead of fuzzy. */
|
|
@@ -534,6 +735,8 @@ declare function resources(ctx: RequestContext): {
|
|
|
534
735
|
list: (opts?: ListResourcesOptions) => Promise<unknown>;
|
|
535
736
|
get: (id: string) => Promise<unknown>;
|
|
536
737
|
delete: (id: string) => Promise<unknown>;
|
|
738
|
+
update: (id: string, patch: UpdateResourceOptions) => Promise<unknown>;
|
|
739
|
+
configureIndex: (id: string, opts: Parameters<typeof configureResourceIndex>[2]) => Promise<unknown>;
|
|
537
740
|
find: (name: string, opts?: FindResourceOptions) => Promise<unknown>;
|
|
538
741
|
query: (id: string, opts?: QueryResourceOptions) => Promise<unknown>;
|
|
539
742
|
};
|
|
@@ -667,8 +870,8 @@ interface DiagnoseReport {
|
|
|
667
870
|
* agent, fetches the resulting trace, and checks each assertion. Deterministic
|
|
668
871
|
* assertion kinds (contains, regex, tool-call count/order, latency) need no LLM;
|
|
669
872
|
* `semantic_match` reuses the local-claude judge. Builder lifts cases from a
|
|
670
|
-
* queries file (JSON). The diagnosis-report lift + YAML shards + redaction
|
|
671
|
-
*
|
|
873
|
+
* queries file (JSON). The diagnosis-report lift + YAML shards + redaction
|
|
874
|
+
* are deferred — see tech-debt.
|
|
672
875
|
*/
|
|
673
876
|
|
|
674
877
|
type AssertionType = "contains" | "not_contains" | "regex" | "tool_call_count" | "tool_call_order" | "latency_ms" | "semantic_match";
|
|
@@ -756,7 +959,8 @@ declare function trace(ctx: RequestContext): {
|
|
|
756
959
|
|
|
757
960
|
/**
|
|
758
961
|
* Vega backend client — catalog/resource reads + BuildTask (index build).
|
|
759
|
-
* Build config
|
|
962
|
+
* Build config is snapshotted from the Resource's schema_definition/features and
|
|
963
|
+
* index_config when the BuildTask is created.
|
|
760
964
|
*/
|
|
761
965
|
|
|
762
966
|
declare const BuildMode: z.ZodEnum<["batch", "streaming"]>;
|
|
@@ -765,24 +969,15 @@ type BuildMode = z.infer<typeof BuildMode>;
|
|
|
765
969
|
declare const CreateBuildTaskRequest: z.ZodObject<{
|
|
766
970
|
resource_id: z.ZodString;
|
|
767
971
|
mode: z.ZodEnum<["batch", "streaming"]>;
|
|
768
|
-
|
|
769
|
-
build_key_fields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
770
|
-
embedding_model: z.ZodOptional<z.ZodString>;
|
|
771
|
-
model_dimensions: z.ZodOptional<z.ZodNumber>;
|
|
972
|
+
execute_type: z.ZodOptional<z.ZodEnum<["incremental", "full"]>>;
|
|
772
973
|
}, "strip", z.ZodTypeAny, {
|
|
773
974
|
mode: "batch" | "streaming";
|
|
774
975
|
resource_id: string;
|
|
775
|
-
|
|
776
|
-
build_key_fields?: string[] | undefined;
|
|
777
|
-
embedding_model?: string | undefined;
|
|
778
|
-
model_dimensions?: number | undefined;
|
|
976
|
+
execute_type?: "full" | "incremental" | undefined;
|
|
779
977
|
}, {
|
|
780
978
|
mode: "batch" | "streaming";
|
|
781
979
|
resource_id: string;
|
|
782
|
-
|
|
783
|
-
build_key_fields?: string[] | undefined;
|
|
784
|
-
embedding_model?: string | undefined;
|
|
785
|
-
model_dimensions?: number | undefined;
|
|
980
|
+
execute_type?: "full" | "incremental" | undefined;
|
|
786
981
|
}>;
|
|
787
982
|
type CreateBuildTaskRequest = z.infer<typeof CreateBuildTaskRequest>;
|
|
788
983
|
declare const BuildTask: z.ZodObject<{
|
|
@@ -794,10 +989,21 @@ declare const BuildTask: z.ZodObject<{
|
|
|
794
989
|
total_count: z.ZodOptional<z.ZodNumber>;
|
|
795
990
|
synced_count: z.ZodOptional<z.ZodNumber>;
|
|
796
991
|
vectorized_count: z.ZodOptional<z.ZodNumber>;
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
992
|
+
index_config: z.ZodOptional<z.ZodUnknown>;
|
|
993
|
+
catalog_id: z.ZodOptional<z.ZodString>;
|
|
994
|
+
index_health: z.ZodOptional<z.ZodObject<{
|
|
995
|
+
embedding: z.ZodString;
|
|
996
|
+
fulltext: z.ZodString;
|
|
997
|
+
usable: z.ZodBoolean;
|
|
998
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
999
|
+
embedding: z.ZodString;
|
|
1000
|
+
fulltext: z.ZodString;
|
|
1001
|
+
usable: z.ZodBoolean;
|
|
1002
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
1003
|
+
embedding: z.ZodString;
|
|
1004
|
+
fulltext: z.ZodString;
|
|
1005
|
+
usable: z.ZodBoolean;
|
|
1006
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
801
1007
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
802
1008
|
id: z.ZodString;
|
|
803
1009
|
resource_id: z.ZodOptional<z.ZodString>;
|
|
@@ -807,10 +1013,21 @@ declare const BuildTask: z.ZodObject<{
|
|
|
807
1013
|
total_count: z.ZodOptional<z.ZodNumber>;
|
|
808
1014
|
synced_count: z.ZodOptional<z.ZodNumber>;
|
|
809
1015
|
vectorized_count: z.ZodOptional<z.ZodNumber>;
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
1016
|
+
index_config: z.ZodOptional<z.ZodUnknown>;
|
|
1017
|
+
catalog_id: z.ZodOptional<z.ZodString>;
|
|
1018
|
+
index_health: z.ZodOptional<z.ZodObject<{
|
|
1019
|
+
embedding: z.ZodString;
|
|
1020
|
+
fulltext: z.ZodString;
|
|
1021
|
+
usable: z.ZodBoolean;
|
|
1022
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
1023
|
+
embedding: z.ZodString;
|
|
1024
|
+
fulltext: z.ZodString;
|
|
1025
|
+
usable: z.ZodBoolean;
|
|
1026
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
1027
|
+
embedding: z.ZodString;
|
|
1028
|
+
fulltext: z.ZodString;
|
|
1029
|
+
usable: z.ZodBoolean;
|
|
1030
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
814
1031
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
815
1032
|
id: z.ZodString;
|
|
816
1033
|
resource_id: z.ZodOptional<z.ZodString>;
|
|
@@ -820,15 +1037,71 @@ declare const BuildTask: z.ZodObject<{
|
|
|
820
1037
|
total_count: z.ZodOptional<z.ZodNumber>;
|
|
821
1038
|
synced_count: z.ZodOptional<z.ZodNumber>;
|
|
822
1039
|
vectorized_count: z.ZodOptional<z.ZodNumber>;
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
1040
|
+
index_config: z.ZodOptional<z.ZodUnknown>;
|
|
1041
|
+
catalog_id: z.ZodOptional<z.ZodString>;
|
|
1042
|
+
index_health: z.ZodOptional<z.ZodObject<{
|
|
1043
|
+
embedding: z.ZodString;
|
|
1044
|
+
fulltext: z.ZodString;
|
|
1045
|
+
usable: z.ZodBoolean;
|
|
1046
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
1047
|
+
embedding: z.ZodString;
|
|
1048
|
+
fulltext: z.ZodString;
|
|
1049
|
+
usable: z.ZodBoolean;
|
|
1050
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
1051
|
+
embedding: z.ZodString;
|
|
1052
|
+
fulltext: z.ZodString;
|
|
1053
|
+
usable: z.ZodBoolean;
|
|
1054
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
827
1055
|
}, z.ZodTypeAny, "passthrough">>;
|
|
828
1056
|
type BuildTask = z.infer<typeof BuildTask>;
|
|
1057
|
+
interface ListBuildTasksOptions {
|
|
1058
|
+
limit?: number;
|
|
1059
|
+
offset?: number;
|
|
1060
|
+
resourceId?: string;
|
|
1061
|
+
catalogId?: string;
|
|
1062
|
+
status?: string | string[];
|
|
1063
|
+
active?: boolean;
|
|
1064
|
+
mode?: BuildMode;
|
|
1065
|
+
orderBy?: "default" | "created_at" | "updated_at" | "status" | "mode";
|
|
1066
|
+
order?: "asc" | "desc";
|
|
1067
|
+
}
|
|
1068
|
+
interface DeleteBuildTasksOptions {
|
|
1069
|
+
ignoreMissing?: boolean;
|
|
1070
|
+
deleteActiveIndex?: boolean;
|
|
1071
|
+
}
|
|
1072
|
+
interface SqlQueryRequest {
|
|
1073
|
+
/** SQL string (MySQL/MariaDB/PostgreSQL) or an OpenSearch DSL object. */
|
|
1074
|
+
query: string | Record<string, unknown>;
|
|
1075
|
+
/** Query mode. `stream` uses cursor-style paging through `query_id`. */
|
|
1076
|
+
query_type?: "standard" | "stream";
|
|
1077
|
+
/**
|
|
1078
|
+
* Source type (mysql | mariadb | postgresql | opensearch …). Required by the
|
|
1079
|
+
* current vega-backend raw query handler.
|
|
1080
|
+
*/
|
|
1081
|
+
resource_type: string;
|
|
1082
|
+
/** Streaming batch size (100–10000, default server-side). */
|
|
1083
|
+
stream_size?: number;
|
|
1084
|
+
/** Query timeout in seconds (1–3600). */
|
|
1085
|
+
query_timeout?: number;
|
|
1086
|
+
/** Cursor session id for paged streaming. */
|
|
1087
|
+
query_id?: string;
|
|
1088
|
+
}
|
|
829
1089
|
interface ListCatalogsOptions {
|
|
830
1090
|
limit?: number;
|
|
831
1091
|
offset?: number;
|
|
1092
|
+
name?: string;
|
|
1093
|
+
tag?: string;
|
|
1094
|
+
type?: "physical" | "logical" | string;
|
|
1095
|
+
enabled?: boolean;
|
|
1096
|
+
healthCheckStatus?: string;
|
|
1097
|
+
includeExtensions?: boolean;
|
|
1098
|
+
includeExtensionKeys?: string;
|
|
1099
|
+
extensionPairs?: Array<{
|
|
1100
|
+
key: string;
|
|
1101
|
+
value: string;
|
|
1102
|
+
}>;
|
|
1103
|
+
sort?: "name" | "create_time" | "update_time" | string;
|
|
1104
|
+
direction?: "asc" | "desc";
|
|
832
1105
|
}
|
|
833
1106
|
/** POST /catalogs body. `connector_config` shape varies by connector (raw passthrough). */
|
|
834
1107
|
interface CreateCatalogRequest {
|
|
@@ -838,18 +1111,27 @@ interface CreateCatalogRequest {
|
|
|
838
1111
|
tags?: string[];
|
|
839
1112
|
description?: string;
|
|
840
1113
|
enabled?: boolean;
|
|
1114
|
+
id?: string;
|
|
1115
|
+
internal?: boolean;
|
|
1116
|
+
extensions?: Record<string, string>;
|
|
841
1117
|
}
|
|
842
1118
|
|
|
843
1119
|
declare function vega(ctx: RequestContext): {
|
|
844
1120
|
catalogs: (opts?: ListCatalogsOptions) => Promise<unknown>;
|
|
845
1121
|
getCatalog: (id: string) => Promise<unknown>;
|
|
846
1122
|
createCatalog: (req: CreateCatalogRequest) => Promise<unknown>;
|
|
1123
|
+
updateCatalog: (id: string, req: Partial<CreateCatalogRequest>) => Promise<unknown>;
|
|
847
1124
|
enableCatalog: (id: string) => Promise<unknown>;
|
|
1125
|
+
disableCatalog: (id: string) => Promise<unknown>;
|
|
1126
|
+
deleteCatalog: (id: string) => Promise<unknown>;
|
|
1127
|
+
testCatalogConnection: (id: string) => Promise<unknown>;
|
|
848
1128
|
discoverCatalog: (id: string, wait?: boolean) => Promise<unknown>;
|
|
849
1129
|
catalogResources: (id: string, category?: string) => Promise<unknown>;
|
|
850
1130
|
catalogHealth: (ids: string[]) => Promise<unknown>;
|
|
851
1131
|
connectorTypes: () => Promise<unknown>;
|
|
852
1132
|
connectorType: (type: string) => Promise<unknown>;
|
|
1133
|
+
/** Run SQL / OpenSearch DSL directly against a data source. */
|
|
1134
|
+
sql: (body: SqlQueryRequest) => Promise<unknown>;
|
|
853
1135
|
/** Build a resource's index. With `wait`, polls until terminal. */
|
|
854
1136
|
build: (req: CreateBuildTaskRequest, opts?: {
|
|
855
1137
|
wait?: boolean;
|
|
@@ -865,11 +1147,28 @@ declare function vega(ctx: RequestContext): {
|
|
|
865
1147
|
total_count: zod.ZodOptional<zod.ZodNumber>;
|
|
866
1148
|
synced_count: zod.ZodOptional<zod.ZodNumber>;
|
|
867
1149
|
vectorized_count: zod.ZodOptional<zod.ZodNumber>;
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
1150
|
+
index_config: zod.ZodOptional<zod.ZodUnknown>;
|
|
1151
|
+
catalog_id: zod.ZodOptional<zod.ZodString>;
|
|
1152
|
+
index_health: zod.ZodOptional<zod.ZodObject<{
|
|
1153
|
+
embedding: zod.ZodString;
|
|
1154
|
+
fulltext: zod.ZodString;
|
|
1155
|
+
usable: zod.ZodBoolean;
|
|
1156
|
+
}, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{
|
|
1157
|
+
embedding: zod.ZodString;
|
|
1158
|
+
fulltext: zod.ZodString;
|
|
1159
|
+
usable: zod.ZodBoolean;
|
|
1160
|
+
}, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{
|
|
1161
|
+
embedding: zod.ZodString;
|
|
1162
|
+
fulltext: zod.ZodString;
|
|
1163
|
+
usable: zod.ZodBoolean;
|
|
1164
|
+
}, zod.ZodTypeAny, "passthrough">>>;
|
|
872
1165
|
}, zod.ZodTypeAny, "passthrough">>;
|
|
1166
|
+
buildTasks: (opts?: ListBuildTasksOptions) => Promise<unknown>;
|
|
1167
|
+
deleteBuildTasks: (ids: string[], opts?: DeleteBuildTasksOptions) => Promise<unknown>;
|
|
1168
|
+
startBuildTask: (taskId: string, opts?: {
|
|
1169
|
+
reset?: boolean;
|
|
1170
|
+
}) => Promise<unknown>;
|
|
1171
|
+
stopBuildTask: (taskId: string) => Promise<unknown>;
|
|
873
1172
|
};
|
|
874
1173
|
|
|
875
1174
|
interface BknClient {
|
|
@@ -877,6 +1176,10 @@ interface BknClient {
|
|
|
877
1176
|
readonly kn: ReturnType<typeof kn>;
|
|
878
1177
|
readonly resource: ReturnType<typeof resources>;
|
|
879
1178
|
readonly dataflows: ReturnType<typeof dataflows>;
|
|
1179
|
+
/**
|
|
1180
|
+
* @deprecated Decision Agent (agent-factory) is being phased out and may be
|
|
1181
|
+
* removed in a future release. Avoid building new integrations on it.
|
|
1182
|
+
*/
|
|
880
1183
|
readonly agents: ReturnType<typeof agents>;
|
|
881
1184
|
readonly context: ReturnType<typeof context>;
|
|
882
1185
|
readonly models: ReturnType<typeof models>;
|
|
@@ -884,6 +1187,7 @@ interface BknClient {
|
|
|
884
1187
|
readonly toolboxes: ReturnType<typeof toolboxes>;
|
|
885
1188
|
readonly trace: ReturnType<typeof trace>;
|
|
886
1189
|
readonly admin: ReturnType<typeof admin>;
|
|
1190
|
+
readonly appKeys: ReturnType<typeof appKeys>;
|
|
887
1191
|
readonly vega: ReturnType<typeof vega>;
|
|
888
1192
|
/** Raw API passthrough (the `call` escape hatch). */
|
|
889
1193
|
call(path: string, opts?: RawCallOptions): Promise<RawCallResult>;
|
|
@@ -896,7 +1200,9 @@ declare class HttpError extends Error {
|
|
|
896
1200
|
readonly status: number;
|
|
897
1201
|
readonly statusText: string;
|
|
898
1202
|
readonly body: string;
|
|
899
|
-
|
|
1203
|
+
/** Optional next-step guidance, overriding the status default (e.g. AppKey re-issue). */
|
|
1204
|
+
readonly hint?: string;
|
|
1205
|
+
constructor(status: number, statusText: string, body: string, hint?: string);
|
|
900
1206
|
}
|
|
901
1207
|
/** Raised for bad CLI/SDK input before any request is made. */
|
|
902
1208
|
declare class InputError extends Error {
|
|
@@ -923,16 +1229,28 @@ interface TokenConfig {
|
|
|
923
1229
|
refreshToken?: string;
|
|
924
1230
|
idToken?: string;
|
|
925
1231
|
expiresAt?: string;
|
|
926
|
-
/** Skip TLS verification for this platform (saved by `auth login -k`). */
|
|
927
|
-
tlsInsecure?: boolean;
|
|
928
|
-
/** Platform has no auth stack (no bkn-safe) — requests carry no token. */
|
|
929
|
-
noAuth?: boolean;
|
|
930
1232
|
/** Login name persisted at login time (fallback when JWT lacks claims). */
|
|
931
1233
|
username?: string;
|
|
932
1234
|
/** Human-readable name from userinfo. */
|
|
933
1235
|
displayName?: string;
|
|
1236
|
+
/**
|
|
1237
|
+
* Skip TLS verification for this platform (saved by `auth login -k`), so a
|
|
1238
|
+
* self-signed platform needn't repeat `-k` on every command. The opt-out is
|
|
1239
|
+
* applied per request via an undici dispatcher (see api/tls.ts) and is scoped
|
|
1240
|
+
* to this platform's requests — it never touches the global TLS setting or a
|
|
1241
|
+
* library consumer's unrelated traffic.
|
|
1242
|
+
*/
|
|
1243
|
+
tlsInsecure?: boolean;
|
|
934
1244
|
}
|
|
935
|
-
/**
|
|
1245
|
+
/**
|
|
1246
|
+
* userId from the token's JWT `sub` (id_token first), else "default".
|
|
1247
|
+
*
|
|
1248
|
+
* The `sub` is attacker-supplied — the JWT is never signature-checked — and it
|
|
1249
|
+
* becomes a path segment under `userDir`. An unconstrained one escapes the
|
|
1250
|
+
* store: `sub: "../../<other-platform>/users/default"` overwrites another
|
|
1251
|
+
* platform's saved token, so the victim's later commands there authenticate as
|
|
1252
|
+
* whoever issued this token. Constrain it the way BKN_PROFILE is constrained.
|
|
1253
|
+
*/
|
|
936
1254
|
declare function userIdFromToken(token: TokenConfig): string;
|
|
937
1255
|
interface PlatformUser {
|
|
938
1256
|
userId: string;
|
|
@@ -951,20 +1269,13 @@ declare function hostOf(baseUrl: string): string;
|
|
|
951
1269
|
declare function attachToken(baseUrl: string, accessToken: string, opts?: {
|
|
952
1270
|
refreshToken?: string;
|
|
953
1271
|
idToken?: string;
|
|
954
|
-
insecure?: boolean;
|
|
955
1272
|
username?: string;
|
|
1273
|
+
insecure?: boolean;
|
|
956
1274
|
}): {
|
|
957
1275
|
baseUrl: string;
|
|
958
1276
|
userId: string;
|
|
959
1277
|
username?: string;
|
|
960
1278
|
};
|
|
961
|
-
/** Register a no-auth platform session (no token; the platform has no bkn-safe). */
|
|
962
|
-
declare function attachNoAuth(baseUrl: string, opts?: {
|
|
963
|
-
insecure?: boolean;
|
|
964
|
-
}): {
|
|
965
|
-
baseUrl: string;
|
|
966
|
-
noAuth: true;
|
|
967
|
-
};
|
|
968
1279
|
interface AuthStatus {
|
|
969
1280
|
baseUrl?: string;
|
|
970
1281
|
userId?: string;
|
|
@@ -972,15 +1283,22 @@ interface AuthStatus {
|
|
|
972
1283
|
username?: string;
|
|
973
1284
|
expired?: boolean;
|
|
974
1285
|
}
|
|
975
|
-
declare function status(
|
|
976
|
-
|
|
1286
|
+
declare function status(opts?: {
|
|
1287
|
+
user?: string;
|
|
1288
|
+
}): AuthStatus;
|
|
1289
|
+
declare function currentToken(opts?: {
|
|
1290
|
+
user?: string;
|
|
1291
|
+
}): string;
|
|
977
1292
|
/**
|
|
978
1293
|
* Like {@link currentToken} but proactively refreshes an expired access token
|
|
979
1294
|
* when a refresh token is stored, persisting the result. API requests already
|
|
980
1295
|
* refresh on a 401 (see api/http.ts); this covers the `auth token` getter,
|
|
981
1296
|
* whose output is copied out and used elsewhere where no 401 retry can help.
|
|
982
1297
|
*/
|
|
983
|
-
declare function currentTokenFresh(
|
|
1298
|
+
declare function currentTokenFresh(opts?: {
|
|
1299
|
+
insecure?: boolean;
|
|
1300
|
+
user?: string;
|
|
1301
|
+
}): Promise<string>;
|
|
984
1302
|
interface WhoamiResult extends JwtClaims {
|
|
985
1303
|
/** Platform the active session belongs to. */
|
|
986
1304
|
baseUrl?: string;
|
|
@@ -989,7 +1307,9 @@ interface WhoamiResult extends JwtClaims {
|
|
|
989
1307
|
/** Resolved account/login name — what `auth login` looked up and stored. */
|
|
990
1308
|
username?: string;
|
|
991
1309
|
}
|
|
992
|
-
declare function whoami(
|
|
1310
|
+
declare function whoami(opts?: {
|
|
1311
|
+
user?: string;
|
|
1312
|
+
}): WhoamiResult;
|
|
993
1313
|
interface PlatformListItem {
|
|
994
1314
|
baseUrl: string;
|
|
995
1315
|
userId: string;
|
|
@@ -1024,7 +1344,6 @@ declare function exportCreds(): {
|
|
|
1024
1344
|
type auth_AuthStatus = AuthStatus;
|
|
1025
1345
|
type auth_PlatformListItem = PlatformListItem;
|
|
1026
1346
|
type auth_WhoamiResult = WhoamiResult;
|
|
1027
|
-
declare const auth_attachNoAuth: typeof attachNoAuth;
|
|
1028
1347
|
declare const auth_attachToken: typeof attachToken;
|
|
1029
1348
|
declare const auth_currentToken: typeof currentToken;
|
|
1030
1349
|
declare const auth_currentTokenFresh: typeof currentTokenFresh;
|
|
@@ -1040,7 +1359,7 @@ declare const auth_userIdFromToken: typeof userIdFromToken;
|
|
|
1040
1359
|
declare const auth_usersOf: typeof usersOf;
|
|
1041
1360
|
declare const auth_whoami: typeof whoami;
|
|
1042
1361
|
declare namespace auth {
|
|
1043
|
-
export { type auth_AuthStatus as AuthStatus, type auth_PlatformListItem as PlatformListItem, type auth_WhoamiResult as WhoamiResult,
|
|
1362
|
+
export { type auth_AuthStatus as AuthStatus, type auth_PlatformListItem as PlatformListItem, type auth_WhoamiResult as WhoamiResult, auth_attachToken as attachToken, auth_currentToken as currentToken, auth_currentTokenFresh as currentTokenFresh, auth_deletePlatform as deletePlatform, auth_exportCreds as exportCreds, auth_hostOf as hostOf, auth_listPlatforms as listPlatforms, auth_logout as logout, auth_status as status, auth_switchUser as switchUser, auth_use as use, auth_userIdFromToken as userIdFromToken, auth_usersOf as usersOf, auth_whoami as whoami };
|
|
1044
1363
|
}
|
|
1045
1364
|
|
|
1046
1365
|
interface RequestInitEx {
|
|
@@ -1048,7 +1367,7 @@ interface RequestInitEx {
|
|
|
1048
1367
|
/** JSON body — serialized and Content-Type set automatically. */
|
|
1049
1368
|
body?: unknown;
|
|
1050
1369
|
/** Query params appended to the path. */
|
|
1051
|
-
query?: Record<string, string | number | boolean | undefined>;
|
|
1370
|
+
query?: Record<string, string | number | boolean | Array<string | number | boolean> | undefined>;
|
|
1052
1371
|
headers?: Record<string, string>;
|
|
1053
1372
|
/** Per-request timeout; defaults to 30s. */
|
|
1054
1373
|
timeoutMs?: number;
|