@openbkn/bkn-sdk 0.1.1 → 0.1.2
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 +2 -1
- package/README.zh.md +1 -0
- package/dist/{chunk-NC6DZ2AU.js → chunk-LH3ONZGQ.js} +1785 -77
- package/dist/cli.js +124 -40
- package/dist/index.d.ts +612 -38
- package/dist/index.js +3 -1
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,10 @@ interface ClientOptions {
|
|
|
12
12
|
businessDomain?: string;
|
|
13
13
|
/** Skip TLS verification (dev / self-signed only). */
|
|
14
14
|
insecure?: boolean;
|
|
15
|
+
/** Dedicated producer credential, sent only to BKN Trace evidence write endpoints. */
|
|
16
|
+
evidenceIngestToken?: string;
|
|
17
|
+
/** Optional BKN Trace phase-one context for request correlation. */
|
|
18
|
+
trace?: TraceContextOptions;
|
|
15
19
|
}
|
|
16
20
|
/** Fully resolved request context — every field is known. */
|
|
17
21
|
interface RefreshableTokens {
|
|
@@ -24,6 +28,10 @@ interface RequestContext {
|
|
|
24
28
|
token: string;
|
|
25
29
|
businessDomain: string;
|
|
26
30
|
insecure: boolean;
|
|
31
|
+
/** Dedicated producer credential; never sent to read or non-Trace endpoints. */
|
|
32
|
+
evidenceIngestToken?: string;
|
|
33
|
+
/** Stable per-client BKN Trace context propagated on outbound requests. */
|
|
34
|
+
trace?: TraceContext;
|
|
27
35
|
/**
|
|
28
36
|
* Stored-credential refresh: on a 401, swap the refresh token for a fresh
|
|
29
37
|
* access token, persist it, and retry once. Absent for explicit `--token`/env.
|
|
@@ -34,6 +42,34 @@ interface RequestContext {
|
|
|
34
42
|
persist: (tokens: RefreshableTokens) => void;
|
|
35
43
|
};
|
|
36
44
|
}
|
|
45
|
+
interface TraceContextOptions {
|
|
46
|
+
/** OpenBKN request id. Generated as `req_<uuid>` when omitted or invalid. */
|
|
47
|
+
requestId?: string;
|
|
48
|
+
/** W3C Trace Context header. Generated when omitted or invalid. */
|
|
49
|
+
traceparent?: string;
|
|
50
|
+
/** Caller-owned business conversation id. The SDK never generates one. */
|
|
51
|
+
conversationId?: string;
|
|
52
|
+
/** Caller-owned id for one user question and its operations. The SDK never generates one. */
|
|
53
|
+
interactionId?: string;
|
|
54
|
+
/** Replay-stable operation id. Transports generate one per logical operation when omitted. */
|
|
55
|
+
operationId?: string;
|
|
56
|
+
/** Retry ordinal for the operation. Defaults to 1. */
|
|
57
|
+
attempt?: number;
|
|
58
|
+
/** Producer observation time in RFC3339 format. Generated per logical operation when omitted. */
|
|
59
|
+
observedAt?: string;
|
|
60
|
+
/** Baggage values are allowlisted before propagation. */
|
|
61
|
+
baggage?: Record<string, string>;
|
|
62
|
+
}
|
|
63
|
+
interface TraceContext {
|
|
64
|
+
requestId: string;
|
|
65
|
+
traceparent: string;
|
|
66
|
+
conversationId?: string;
|
|
67
|
+
interactionId?: string;
|
|
68
|
+
operationId?: string;
|
|
69
|
+
attempt?: number;
|
|
70
|
+
observedAt?: string;
|
|
71
|
+
baggage?: Record<string, string>;
|
|
72
|
+
}
|
|
37
73
|
declare const DEFAULT_BUSINESS_DOMAIN = "bd_public";
|
|
38
74
|
/** Default list/query limits — see AGENTS.md conventions. */
|
|
39
75
|
declare const DEFAULT_LIST_LIMIT = 30;
|
|
@@ -372,13 +408,6 @@ declare function appKeys(ctx: RequestContext): {
|
|
|
372
408
|
adminRevoke: (id: string) => Promise<void>;
|
|
373
409
|
};
|
|
374
410
|
|
|
375
|
-
/**
|
|
376
|
-
* Context-loader client over the agent-retrieval MCP endpoint (JSON-RPC).
|
|
377
|
-
* Slim implementation: initialize → session id →
|
|
378
|
-
* notifications/initialized, then tools/call. Handles plain-JSON and
|
|
379
|
-
* SSE (`data:`) response bodies. Per-process session cache (5 min TTL).
|
|
380
|
-
*/
|
|
381
|
-
|
|
382
411
|
interface SearchSchemaOptions {
|
|
383
412
|
searchScope?: string[];
|
|
384
413
|
maxConcepts?: number;
|
|
@@ -426,6 +455,8 @@ interface TemplateArg {
|
|
|
426
455
|
|
|
427
456
|
interface ListRunsOptions {
|
|
428
457
|
since?: string;
|
|
458
|
+
page?: number;
|
|
459
|
+
limit?: number;
|
|
429
460
|
}
|
|
430
461
|
interface LogsOptions {
|
|
431
462
|
page?: number;
|
|
@@ -547,7 +578,6 @@ declare function kn(ctx: RequestContext): {
|
|
|
547
578
|
metricValidate: (knId: string, body: unknown) => Promise<unknown>;
|
|
548
579
|
objectTypes: (knId: string, opts?: ListSchemaOptions) => Promise<unknown>;
|
|
549
580
|
objectTypeQuery: (knId: string, otId: string, body: unknown) => Promise<unknown>;
|
|
550
|
-
objectTypeProperties: (knId: string, otId: string) => Promise<unknown>;
|
|
551
581
|
objectTypeGet: (knId: string, id: string) => Promise<unknown>;
|
|
552
582
|
objectTypeCreate: (knId: string, body: unknown) => Promise<unknown>;
|
|
553
583
|
objectTypeUpdate: (knId: string, id: string, body: unknown) => Promise<unknown>;
|
|
@@ -575,10 +605,6 @@ declare function kn(ctx: RequestContext): {
|
|
|
575
605
|
actionScheduleUpdate: (knId: string, scheduleId: string, body: unknown) => Promise<unknown>;
|
|
576
606
|
actionScheduleSetStatus: (knId: string, scheduleId: string, body: unknown) => Promise<unknown>;
|
|
577
607
|
actionScheduleDelete: (knId: string, ids: string) => Promise<unknown>;
|
|
578
|
-
jobs: (knId: string) => Promise<unknown>;
|
|
579
|
-
job: (knId: string, jobId: string) => Promise<unknown>;
|
|
580
|
-
jobTasks: (knId: string, jobId: string) => Promise<unknown>;
|
|
581
|
-
jobDelete: (knId: string, ids: string) => Promise<unknown>;
|
|
582
608
|
relationTypePaths: (knId: string, body: unknown) => Promise<unknown>;
|
|
583
609
|
bknResources: () => Promise<unknown>;
|
|
584
610
|
createFromCatalog: (opts: CreateFromCatalogOptions) => Promise<unknown>;
|
|
@@ -722,11 +748,17 @@ interface FindResourceOptions {
|
|
|
722
748
|
datasourceId?: string;
|
|
723
749
|
/** Exact name match instead of fuzzy. */
|
|
724
750
|
exact?: boolean;
|
|
751
|
+
/** Rows to fetch before filtering; `-1` = all. Defaults to the list default. */
|
|
752
|
+
limit?: number;
|
|
725
753
|
}
|
|
726
754
|
interface QueryResourceOptions {
|
|
727
755
|
limit?: number;
|
|
728
756
|
offset?: number;
|
|
729
757
|
needTotal?: boolean;
|
|
758
|
+
pagingMode?: "single" | "cursor";
|
|
759
|
+
keepAliveSec?: number;
|
|
760
|
+
/** Opaque cursor returned by the preceding resource data page. */
|
|
761
|
+
cursor?: string;
|
|
730
762
|
}
|
|
731
763
|
|
|
732
764
|
/** Resource surface (the exported SDK API) over vega-backend resources. */
|
|
@@ -791,6 +823,11 @@ interface ListToolboxesOptions {
|
|
|
791
823
|
limit?: number;
|
|
792
824
|
offset?: number;
|
|
793
825
|
}
|
|
826
|
+
interface ListToolsOptions {
|
|
827
|
+
page?: number;
|
|
828
|
+
pageSize?: number;
|
|
829
|
+
all?: boolean;
|
|
830
|
+
}
|
|
794
831
|
interface CreateToolboxOptions {
|
|
795
832
|
name: string;
|
|
796
833
|
serviceUrl: string;
|
|
@@ -807,7 +844,7 @@ interface ToolInvokeEnvelope {
|
|
|
807
844
|
|
|
808
845
|
declare function toolboxes(ctx: RequestContext): {
|
|
809
846
|
list: (opts?: ListToolboxesOptions) => Promise<unknown>;
|
|
810
|
-
tools: (boxId: string) => Promise<unknown>;
|
|
847
|
+
tools: (boxId: string, opts?: ListToolsOptions) => Promise<unknown>;
|
|
811
848
|
create: (opts: CreateToolboxOptions) => Promise<unknown>;
|
|
812
849
|
delete: (boxId: string) => Promise<unknown>;
|
|
813
850
|
publish: (boxId: string) => Promise<unknown>;
|
|
@@ -826,6 +863,275 @@ declare function toolboxes(ctx: RequestContext): {
|
|
|
826
863
|
debug: (boxId: string, toolId: string, e?: ToolInvokeEnvelope) => Promise<unknown>;
|
|
827
864
|
};
|
|
828
865
|
|
|
866
|
+
interface FixtureValidationError {
|
|
867
|
+
code: string;
|
|
868
|
+
path: string;
|
|
869
|
+
message: string;
|
|
870
|
+
}
|
|
871
|
+
interface FixtureValidationResult {
|
|
872
|
+
fixtureId: string;
|
|
873
|
+
result: "pass" | "fail";
|
|
874
|
+
contractVersion: string | null;
|
|
875
|
+
errors: FixtureValidationError[];
|
|
876
|
+
warnings: string[];
|
|
877
|
+
expectedResult: "pass" | "fail" | null;
|
|
878
|
+
expectationMatched: boolean;
|
|
879
|
+
}
|
|
880
|
+
interface FixturePathValidationResult {
|
|
881
|
+
ok: boolean;
|
|
882
|
+
results: FixtureValidationResult[];
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* BKN Trace client (agent-observability). Implements raw trace search and a
|
|
887
|
+
* two-hop "spans by conversation" fetch. The full
|
|
888
|
+
* diagnose/eval-set rule engine (LLM-as-judge) is a separate large feature and
|
|
889
|
+
* is NOT included here — see docs/exec-plans/tech-debt-tracker.md.
|
|
890
|
+
*/
|
|
891
|
+
|
|
892
|
+
interface EvidenceTraceContext {
|
|
893
|
+
trace_id: string;
|
|
894
|
+
traceparent: string;
|
|
895
|
+
"bkn.request.id": string;
|
|
896
|
+
"bkn.conversation.id"?: string;
|
|
897
|
+
"bkn.tenant.id"?: string;
|
|
898
|
+
business_domain?: string;
|
|
899
|
+
"bkn.account.id": string;
|
|
900
|
+
"bkn.account.type": string;
|
|
901
|
+
}
|
|
902
|
+
type BusinessEvidenceEventType = "agent.interaction.started" | "retrieval.completed" | "knowledge.read.observed" | "data.query.observed" | "logic.execution.observed" | "model.call.observed" | "tool.called" | "tool.result.observed" | "claim.created" | "evidence.refs.created" | "business.refs.resolved" | "action.recommended" | "action.approval_requested" | "action.approved" | "action.rejected" | "action.executed" | "action.result_recorded";
|
|
903
|
+
interface EvidenceEvent {
|
|
904
|
+
event_id: string;
|
|
905
|
+
event_type: BusinessEvidenceEventType | (string & {});
|
|
906
|
+
"bkn.trace.schema.version": string;
|
|
907
|
+
observed_at: string;
|
|
908
|
+
emitted_at: string;
|
|
909
|
+
producer_module: string;
|
|
910
|
+
trace_id: string;
|
|
911
|
+
span_id: string;
|
|
912
|
+
"bkn.request.id": string;
|
|
913
|
+
"bkn.operation.name": string;
|
|
914
|
+
interaction_id?: string;
|
|
915
|
+
operation_id?: string;
|
|
916
|
+
causation_event_id?: string;
|
|
917
|
+
claim_id?: string;
|
|
918
|
+
attempt?: number;
|
|
919
|
+
payload: Record<string, unknown>;
|
|
920
|
+
}
|
|
921
|
+
interface EvidenceIngestRequest {
|
|
922
|
+
"bkn.trace.schema.version": "2.0.0" | "2.1.0" | "2.2.0";
|
|
923
|
+
trace: EvidenceTraceContext;
|
|
924
|
+
events: EvidenceEvent[];
|
|
925
|
+
}
|
|
926
|
+
type EvidenceArtifactType = "action_input" | "action_result" | "data_result" | "logic_execution" | "query" | "question" | "result";
|
|
927
|
+
interface EvidenceArtifact {
|
|
928
|
+
artifact_id: string;
|
|
929
|
+
artifact_type: EvidenceArtifactType;
|
|
930
|
+
"bkn.request.id": string;
|
|
931
|
+
trace_id?: string;
|
|
932
|
+
interaction_id?: string;
|
|
933
|
+
operation_id?: string;
|
|
934
|
+
claim_id?: string;
|
|
935
|
+
source_ref?: string;
|
|
936
|
+
business_refs?: string[];
|
|
937
|
+
content_type: string;
|
|
938
|
+
schema_version: "2.2.0";
|
|
939
|
+
observed_at: string;
|
|
940
|
+
as_of?: string;
|
|
941
|
+
source_version?: string;
|
|
942
|
+
content_hash: string;
|
|
943
|
+
content?: unknown;
|
|
944
|
+
snapshot_ref?: string;
|
|
945
|
+
"bkn.tenant.id"?: string;
|
|
946
|
+
business_domain?: string;
|
|
947
|
+
"bkn.account.id": string;
|
|
948
|
+
"bkn.account.type": string;
|
|
949
|
+
initiator?: string;
|
|
950
|
+
agent_or_app?: string;
|
|
951
|
+
}
|
|
952
|
+
interface EvidenceArtifactIngestResponse {
|
|
953
|
+
artifact_id: string;
|
|
954
|
+
artifact_type: EvidenceArtifactType;
|
|
955
|
+
"bkn.request.id": string;
|
|
956
|
+
trace_id?: string;
|
|
957
|
+
content_hash: string;
|
|
958
|
+
created: boolean;
|
|
959
|
+
}
|
|
960
|
+
interface ActionSummary {
|
|
961
|
+
recommended: number;
|
|
962
|
+
approved: number;
|
|
963
|
+
executed: number;
|
|
964
|
+
completed: number;
|
|
965
|
+
last_status?: string;
|
|
966
|
+
}
|
|
967
|
+
interface RequestSummary {
|
|
968
|
+
request_id: string;
|
|
969
|
+
conversation_id?: string;
|
|
970
|
+
interaction_id?: string;
|
|
971
|
+
started_at?: string;
|
|
972
|
+
completed_at?: string;
|
|
973
|
+
initiator?: string;
|
|
974
|
+
agent_or_app?: string;
|
|
975
|
+
business_domain?: string;
|
|
976
|
+
knowledge_networks?: string[];
|
|
977
|
+
question_preview?: string;
|
|
978
|
+
result_preview?: string;
|
|
979
|
+
status: string;
|
|
980
|
+
evidence_completeness: string;
|
|
981
|
+
partial_reasons?: string[];
|
|
982
|
+
business_refs?: string[];
|
|
983
|
+
action_summary: Partial<ActionSummary>;
|
|
984
|
+
trace_count: number;
|
|
985
|
+
duration_ms?: number;
|
|
986
|
+
error_summary?: string;
|
|
987
|
+
}
|
|
988
|
+
interface TraceExecutionSummary {
|
|
989
|
+
trace_id: string;
|
|
990
|
+
request_id: string;
|
|
991
|
+
conversation_id?: string;
|
|
992
|
+
interaction_id?: string;
|
|
993
|
+
started_at?: string;
|
|
994
|
+
completed_at?: string;
|
|
995
|
+
agent_or_app?: string;
|
|
996
|
+
business_domain?: string;
|
|
997
|
+
root_operation?: string;
|
|
998
|
+
status: string;
|
|
999
|
+
span_count: number;
|
|
1000
|
+
duration_ms?: number;
|
|
1001
|
+
error_summary?: string;
|
|
1002
|
+
}
|
|
1003
|
+
interface SummaryPage<T> {
|
|
1004
|
+
entries: T[];
|
|
1005
|
+
total: number;
|
|
1006
|
+
next_cursor?: string | null;
|
|
1007
|
+
truncated: boolean;
|
|
1008
|
+
partial: boolean;
|
|
1009
|
+
partial_reasons?: string[];
|
|
1010
|
+
}
|
|
1011
|
+
interface RequestSummaryQuery {
|
|
1012
|
+
limit?: number;
|
|
1013
|
+
cursor?: string;
|
|
1014
|
+
from?: string;
|
|
1015
|
+
to?: string;
|
|
1016
|
+
status?: string;
|
|
1017
|
+
agentOrApp?: string;
|
|
1018
|
+
businessDomain?: string;
|
|
1019
|
+
conversationId?: string;
|
|
1020
|
+
interactionId?: string;
|
|
1021
|
+
knowledgeNetwork?: string;
|
|
1022
|
+
evidenceCompleteness?: string;
|
|
1023
|
+
keyword?: string;
|
|
1024
|
+
}
|
|
1025
|
+
interface InteractionSummary {
|
|
1026
|
+
interaction_id: string;
|
|
1027
|
+
conversation_id?: string;
|
|
1028
|
+
started_at?: string;
|
|
1029
|
+
completed_at?: string;
|
|
1030
|
+
status: string;
|
|
1031
|
+
duration_ms?: number;
|
|
1032
|
+
requests: RequestSummary[];
|
|
1033
|
+
traces: TraceExecutionSummary[];
|
|
1034
|
+
}
|
|
1035
|
+
interface EvidenceIngestResponse {
|
|
1036
|
+
trace_id: string;
|
|
1037
|
+
"bkn.request.id": string;
|
|
1038
|
+
"bkn.trace.schema.version": string;
|
|
1039
|
+
accepted_event_count: number;
|
|
1040
|
+
claim_count: number;
|
|
1041
|
+
evidence_ref_count: number;
|
|
1042
|
+
business_ref_count: number;
|
|
1043
|
+
}
|
|
1044
|
+
interface VisibilitySummary {
|
|
1045
|
+
authorized_ref_count: number;
|
|
1046
|
+
redacted_ref_count: number;
|
|
1047
|
+
hidden_ref_count: number;
|
|
1048
|
+
omitted_ref_count: number;
|
|
1049
|
+
unresolved_ref_count: number;
|
|
1050
|
+
unauthorized_ref_count?: number;
|
|
1051
|
+
}
|
|
1052
|
+
interface GraphPage {
|
|
1053
|
+
node_count: number;
|
|
1054
|
+
edge_count: number;
|
|
1055
|
+
truncated?: boolean;
|
|
1056
|
+
next_cursor?: string | null;
|
|
1057
|
+
}
|
|
1058
|
+
interface TraceGraphNode {
|
|
1059
|
+
span_id: string;
|
|
1060
|
+
parent_span_id?: string;
|
|
1061
|
+
name: string;
|
|
1062
|
+
kind: string;
|
|
1063
|
+
service_name?: string;
|
|
1064
|
+
status: string;
|
|
1065
|
+
error_message?: string;
|
|
1066
|
+
start_nano: number;
|
|
1067
|
+
end_nano: number;
|
|
1068
|
+
duration_nano: number;
|
|
1069
|
+
}
|
|
1070
|
+
interface TraceGraphEdge {
|
|
1071
|
+
id: string;
|
|
1072
|
+
parent_span_id: string;
|
|
1073
|
+
child_span_id: string;
|
|
1074
|
+
edge_type: string;
|
|
1075
|
+
}
|
|
1076
|
+
interface TraceGraphResponse {
|
|
1077
|
+
trace_id: string;
|
|
1078
|
+
status: string;
|
|
1079
|
+
duration_nano: number;
|
|
1080
|
+
partial: boolean;
|
|
1081
|
+
partial_reason: string[];
|
|
1082
|
+
page: GraphPage;
|
|
1083
|
+
data: {
|
|
1084
|
+
nodes: TraceGraphNode[];
|
|
1085
|
+
edges: TraceGraphEdge[];
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
interface EvidenceChainResponse {
|
|
1089
|
+
trace_id: string;
|
|
1090
|
+
"bkn.request.id": string;
|
|
1091
|
+
partial: boolean;
|
|
1092
|
+
partial_reason: string[];
|
|
1093
|
+
visibility_summary: VisibilitySummary;
|
|
1094
|
+
page: GraphPage;
|
|
1095
|
+
data: {
|
|
1096
|
+
claims: Array<Record<string, unknown>>;
|
|
1097
|
+
evidence_refs: Array<Record<string, unknown>>;
|
|
1098
|
+
business_refs: Array<Record<string, unknown>>;
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
interface BusinessGraphResponse {
|
|
1102
|
+
trace_id: string;
|
|
1103
|
+
"bkn.request.id": string;
|
|
1104
|
+
partial: boolean;
|
|
1105
|
+
partial_reason: string[];
|
|
1106
|
+
visibility_summary: VisibilitySummary;
|
|
1107
|
+
page: GraphPage;
|
|
1108
|
+
data: {
|
|
1109
|
+
nodes: Array<Record<string, unknown>>;
|
|
1110
|
+
edges: Array<Record<string, unknown>>;
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
interface SnapshotPreviewResponse {
|
|
1114
|
+
trace_id: string;
|
|
1115
|
+
"bkn.request.id": string;
|
|
1116
|
+
partial: boolean;
|
|
1117
|
+
partial_reason: string[];
|
|
1118
|
+
visibility_summary: VisibilitySummary;
|
|
1119
|
+
snapshot_ref: {
|
|
1120
|
+
snapshot_id: string;
|
|
1121
|
+
mode: "preview" | string;
|
|
1122
|
+
uri?: string;
|
|
1123
|
+
};
|
|
1124
|
+
manifest: Record<string, unknown>;
|
|
1125
|
+
}
|
|
1126
|
+
type TraceScope = string | {
|
|
1127
|
+
traceId: string;
|
|
1128
|
+
} | {
|
|
1129
|
+
requestId: string;
|
|
1130
|
+
};
|
|
1131
|
+
interface TraceQueryOptions {
|
|
1132
|
+
limit?: number;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
829
1135
|
/**
|
|
830
1136
|
* Trace diagnose engine. Fetches a conversation's spans, shapes them into a
|
|
831
1137
|
* trace tree, runs deterministic symbolic predicates, and (in hybrid mode) adds
|
|
@@ -913,9 +1219,261 @@ interface EvalSetResult {
|
|
|
913
1219
|
cases: CaseResult[];
|
|
914
1220
|
}
|
|
915
1221
|
|
|
1222
|
+
type EvidenceEmitter = (body: EvidenceIngestRequest) => Promise<EvidenceIngestResponse>;
|
|
1223
|
+
type IDFactory = () => string;
|
|
1224
|
+
interface TraceSessionOptions {
|
|
1225
|
+
trace: EvidenceTraceContext;
|
|
1226
|
+
producerModule: string;
|
|
1227
|
+
spanId: string;
|
|
1228
|
+
interactionId?: string;
|
|
1229
|
+
conversationId?: string;
|
|
1230
|
+
contractVersion?: "2.1.0" | "2.2.0";
|
|
1231
|
+
emit: EvidenceEmitter;
|
|
1232
|
+
idFactory?: IDFactory;
|
|
1233
|
+
now?: () => string;
|
|
1234
|
+
}
|
|
1235
|
+
interface InteractionBase {
|
|
1236
|
+
operationName: string;
|
|
1237
|
+
intentHash: string;
|
|
1238
|
+
mode: "chat" | "task" | "background";
|
|
1239
|
+
questionArtifactRef?: string;
|
|
1240
|
+
}
|
|
1241
|
+
type InteractionInput = InteractionBase & ({
|
|
1242
|
+
agentId: string;
|
|
1243
|
+
appRef?: string;
|
|
1244
|
+
} | {
|
|
1245
|
+
agentId?: string;
|
|
1246
|
+
appRef: string;
|
|
1247
|
+
});
|
|
1248
|
+
interface OperationEventPayloadMap {
|
|
1249
|
+
"retrieval.completed": {
|
|
1250
|
+
query_hash: string;
|
|
1251
|
+
candidate_count: number;
|
|
1252
|
+
truncated: boolean;
|
|
1253
|
+
version_status?: string;
|
|
1254
|
+
source_refs?: string[];
|
|
1255
|
+
};
|
|
1256
|
+
"knowledge.read.observed": {
|
|
1257
|
+
kn_id: string;
|
|
1258
|
+
read_kind: string;
|
|
1259
|
+
version_status: string;
|
|
1260
|
+
schema_version?: string;
|
|
1261
|
+
business_refs?: string[];
|
|
1262
|
+
};
|
|
1263
|
+
"data.query.observed": {
|
|
1264
|
+
query_hash: string;
|
|
1265
|
+
query_type: string;
|
|
1266
|
+
row_count: number;
|
|
1267
|
+
truncated?: boolean;
|
|
1268
|
+
as_of?: string;
|
|
1269
|
+
version_status?: string;
|
|
1270
|
+
resource_refs?: string[];
|
|
1271
|
+
field_refs?: string[];
|
|
1272
|
+
query_artifact_ref?: string;
|
|
1273
|
+
result_artifact_ref?: string;
|
|
1274
|
+
};
|
|
1275
|
+
"logic.execution.observed": {
|
|
1276
|
+
logic_ref: string;
|
|
1277
|
+
input_artifact_ref: string;
|
|
1278
|
+
result_artifact_ref: string;
|
|
1279
|
+
status: "ok" | "success" | "error";
|
|
1280
|
+
};
|
|
1281
|
+
"model.call.observed": {
|
|
1282
|
+
model_name: string;
|
|
1283
|
+
model_provider: string;
|
|
1284
|
+
status: "ok" | "error";
|
|
1285
|
+
input_token_count: number;
|
|
1286
|
+
output_token_count: number;
|
|
1287
|
+
prompt_hash: string;
|
|
1288
|
+
output_hash: string;
|
|
1289
|
+
error_category?: string;
|
|
1290
|
+
error_hash?: string;
|
|
1291
|
+
};
|
|
1292
|
+
"tool.called": {
|
|
1293
|
+
tool_id: string;
|
|
1294
|
+
tool_name: string;
|
|
1295
|
+
args_hash: string;
|
|
1296
|
+
visibility: string;
|
|
1297
|
+
version_status: string;
|
|
1298
|
+
};
|
|
1299
|
+
"tool.result.observed": {
|
|
1300
|
+
tool_id: string;
|
|
1301
|
+
tool_name: string;
|
|
1302
|
+
status: "success" | "error";
|
|
1303
|
+
result_hash?: string;
|
|
1304
|
+
error_hash?: string;
|
|
1305
|
+
visibility: string;
|
|
1306
|
+
version_status: string;
|
|
1307
|
+
};
|
|
1308
|
+
}
|
|
1309
|
+
type OperationEventType = keyof OperationEventPayloadMap;
|
|
1310
|
+
interface OperationInput<T extends OperationEventType = OperationEventType> {
|
|
1311
|
+
operationName: string;
|
|
1312
|
+
causationEventId: string;
|
|
1313
|
+
operationId?: string;
|
|
1314
|
+
attempt?: number;
|
|
1315
|
+
claimId?: string;
|
|
1316
|
+
payload: OperationEventPayloadMap[T];
|
|
1317
|
+
}
|
|
1318
|
+
interface ClaimInput {
|
|
1319
|
+
operationName: string;
|
|
1320
|
+
causationEventId: string;
|
|
1321
|
+
claimId: string;
|
|
1322
|
+
claimType: "answer" | "recommendation" | "structured_output" | "finding";
|
|
1323
|
+
claimHash: string;
|
|
1324
|
+
sourceEventIds: string[];
|
|
1325
|
+
operationIds: string[];
|
|
1326
|
+
resultArtifactRef?: string;
|
|
1327
|
+
visibility?: string;
|
|
1328
|
+
versionStatus?: string;
|
|
1329
|
+
}
|
|
1330
|
+
interface EvidenceRefInput {
|
|
1331
|
+
refId: string;
|
|
1332
|
+
refType: string;
|
|
1333
|
+
sourceSystem: string;
|
|
1334
|
+
validity: "observed" | "available" | "unavailable" | "expired" | "partial";
|
|
1335
|
+
versionStatus: "versioned" | "unversioned" | "not_auditable";
|
|
1336
|
+
visibility: "visible" | "redacted" | "hidden" | "omitted" | "unresolved" | "unauthorized";
|
|
1337
|
+
summaryHash?: string;
|
|
1338
|
+
}
|
|
1339
|
+
interface EvidenceRefsInput {
|
|
1340
|
+
operationName: string;
|
|
1341
|
+
claimId: string;
|
|
1342
|
+
causationEventId?: string;
|
|
1343
|
+
refs: EvidenceRefInput[];
|
|
1344
|
+
}
|
|
1345
|
+
interface BusinessRefInput {
|
|
1346
|
+
refId: string;
|
|
1347
|
+
refType: "knowledge_network" | "object" | "property" | "relation" | "metric" | "logic" | "action";
|
|
1348
|
+
sourceSystem: string;
|
|
1349
|
+
validity: "observed" | "available" | "unavailable" | "expired" | "partial";
|
|
1350
|
+
versionStatus: "versioned" | "unversioned" | "not_auditable";
|
|
1351
|
+
visibility: "visible" | "redacted" | "hidden" | "omitted" | "unresolved" | "unauthorized";
|
|
1352
|
+
}
|
|
1353
|
+
interface BusinessRefsInput {
|
|
1354
|
+
operationName: string;
|
|
1355
|
+
claimId: string;
|
|
1356
|
+
causationEventId?: string;
|
|
1357
|
+
resolverStatus: "resolved" | "partial" | "unresolved";
|
|
1358
|
+
refs: BusinessRefInput[];
|
|
1359
|
+
}
|
|
1360
|
+
interface ActionHandle {
|
|
1361
|
+
readonly actionInstanceId: string;
|
|
1362
|
+
readonly claimId: string;
|
|
1363
|
+
readonly operationId: string;
|
|
1364
|
+
readonly lastEventId: string;
|
|
1365
|
+
readonly state: "recommended" | "approval_requested" | "approved" | "rejected" | "executed" | "result_recorded";
|
|
1366
|
+
}
|
|
1367
|
+
interface RecommendActionInput {
|
|
1368
|
+
operationName: string;
|
|
1369
|
+
claimId: string;
|
|
1370
|
+
actionType: string;
|
|
1371
|
+
targetRefs: string[];
|
|
1372
|
+
reasonHash: string;
|
|
1373
|
+
reasonArtifactRef?: string;
|
|
1374
|
+
inputArtifactRef?: string;
|
|
1375
|
+
causationEventId?: string;
|
|
1376
|
+
}
|
|
1377
|
+
type ExecuteActionInput = {
|
|
1378
|
+
status: "ok";
|
|
1379
|
+
invocationRef: string;
|
|
1380
|
+
} | {
|
|
1381
|
+
status: "error";
|
|
1382
|
+
invocationRef: string;
|
|
1383
|
+
errorCategory: string;
|
|
1384
|
+
errorHash: string;
|
|
1385
|
+
};
|
|
1386
|
+
type ActionResultInput = {
|
|
1387
|
+
status: string;
|
|
1388
|
+
resultHash: string;
|
|
1389
|
+
} & ({
|
|
1390
|
+
resultArtifactRef: string;
|
|
1391
|
+
taskRef?: string;
|
|
1392
|
+
artifactRef?: never;
|
|
1393
|
+
} | {
|
|
1394
|
+
taskRef: string;
|
|
1395
|
+
artifactRef?: string;
|
|
1396
|
+
resultArtifactRef?: string;
|
|
1397
|
+
} | {
|
|
1398
|
+
taskRef?: string;
|
|
1399
|
+
artifactRef: string;
|
|
1400
|
+
resultArtifactRef?: string;
|
|
1401
|
+
});
|
|
1402
|
+
declare class TraceSession {
|
|
1403
|
+
readonly interactionId: string;
|
|
1404
|
+
private readonly trace;
|
|
1405
|
+
private readonly producerModule;
|
|
1406
|
+
private readonly spanId;
|
|
1407
|
+
private readonly emit;
|
|
1408
|
+
private readonly contractVersion;
|
|
1409
|
+
private readonly idFactory;
|
|
1410
|
+
private readonly now;
|
|
1411
|
+
private readonly events;
|
|
1412
|
+
private readonly eventIDs;
|
|
1413
|
+
private readonly operationIDs;
|
|
1414
|
+
private readonly claimEventIDs;
|
|
1415
|
+
private readonly actions;
|
|
1416
|
+
private flushTail;
|
|
1417
|
+
constructor(options: TraceSessionOptions);
|
|
1418
|
+
startInteraction(input: InteractionInput): EvidenceEvent;
|
|
1419
|
+
observeOperation<T extends OperationEventType>(eventType: T, input: OperationInput<T>): EvidenceEvent;
|
|
1420
|
+
createClaim(input: ClaimInput): EvidenceEvent;
|
|
1421
|
+
createEvidenceRefs(input: EvidenceRefsInput): EvidenceEvent;
|
|
1422
|
+
resolveBusinessRefs(input: BusinessRefsInput): EvidenceEvent;
|
|
1423
|
+
recommendAction(input: RecommendActionInput): ActionHandle;
|
|
1424
|
+
requestActionApproval(action: ActionHandle, input: {
|
|
1425
|
+
policyRef: string;
|
|
1426
|
+
}): EvidenceEvent;
|
|
1427
|
+
approveAction(action: ActionHandle, input: {
|
|
1428
|
+
actorRef: string;
|
|
1429
|
+
policyDecisionRef: string;
|
|
1430
|
+
}): EvidenceEvent;
|
|
1431
|
+
rejectAction(action: ActionHandle, input: {
|
|
1432
|
+
actorRef: string;
|
|
1433
|
+
policyDecisionRef: string;
|
|
1434
|
+
}): EvidenceEvent;
|
|
1435
|
+
executeAction(action: ActionHandle, input: ExecuteActionInput): EvidenceEvent;
|
|
1436
|
+
recordActionResult(action: ActionHandle, input: ActionResultInput): EvidenceEvent;
|
|
1437
|
+
pendingEvents(): EvidenceEvent[];
|
|
1438
|
+
flush(): Promise<EvidenceIngestResponse | undefined>;
|
|
1439
|
+
private appendAction;
|
|
1440
|
+
private append;
|
|
1441
|
+
private flushEvents;
|
|
1442
|
+
private assertContractPayload;
|
|
1443
|
+
private assertKnownRefs;
|
|
1444
|
+
private requireClaim;
|
|
1445
|
+
private expectActionState;
|
|
1446
|
+
}
|
|
1447
|
+
|
|
916
1448
|
declare function trace(ctx: RequestContext): {
|
|
917
1449
|
/** Raw trace search (OpenSearch-style body). */
|
|
918
1450
|
search: (body: unknown) => Promise<unknown>;
|
|
1451
|
+
/** Submit BKN Trace phase-two claim/evidence/business events. */
|
|
1452
|
+
emitEvidenceEvents: (body: EvidenceIngestRequest) => Promise<EvidenceIngestResponse>;
|
|
1453
|
+
/** Store one authorized BKN Trace 2.2 business-content artifact. */
|
|
1454
|
+
emitArtifact: (body: EvidenceArtifact) => Promise<EvidenceArtifactIngestResponse>;
|
|
1455
|
+
/** Read one authorized BKN Trace 2.2 business-content artifact. */
|
|
1456
|
+
artifact: (artifactId: string) => Promise<EvidenceArtifact>;
|
|
1457
|
+
/** Product-facing business request list and request-to-trace drilldown. */
|
|
1458
|
+
requests: {
|
|
1459
|
+
get: (requestId: string) => Promise<RequestSummary>;
|
|
1460
|
+
list: (query?: RequestSummaryQuery) => Promise<SummaryPage<RequestSummary>>;
|
|
1461
|
+
traces: (requestId: string, query?: Pick<RequestSummaryQuery, "cursor" | "limit">) => Promise<SummaryPage<TraceExecutionSummary>>;
|
|
1462
|
+
};
|
|
1463
|
+
/** Aggregate all OpenBKN requests and traces for one caller-owned interaction. */
|
|
1464
|
+
interactions: {
|
|
1465
|
+
get: (interactionId: string) => Promise<InteractionSummary>;
|
|
1466
|
+
};
|
|
1467
|
+
/** Create a typed BKN Trace 2.1 session for an Agent or AI application. */
|
|
1468
|
+
createSession: (options: Omit<TraceSessionOptions, "emit">) => TraceSession;
|
|
1469
|
+
/** Normalized trace tree/status graph by trace id. */
|
|
1470
|
+
graph: (traceId: string) => Promise<TraceGraphResponse>;
|
|
1471
|
+
/** Claim -> evidence/business refs graph by trace id or BKN request id. */
|
|
1472
|
+
evidenceChain: (scope: TraceScope, opts?: TraceQueryOptions) => Promise<EvidenceChainResponse>;
|
|
1473
|
+
/** Business semantic graph by trace id or BKN request id. */
|
|
1474
|
+
businessGraph: (scope: TraceScope, opts?: TraceQueryOptions) => Promise<BusinessGraphResponse>;
|
|
1475
|
+
/** Metadata-only evidence snapshot preview by trace id or BKN request id. */
|
|
1476
|
+
snapshotPreview: (scope: TraceScope, opts?: TraceQueryOptions) => Promise<SnapshotPreviewResponse>;
|
|
919
1477
|
/** All span source docs for a conversation. */
|
|
920
1478
|
spans: (conversationId: string, opts?: {
|
|
921
1479
|
maxTraceIds?: number;
|
|
@@ -946,6 +1504,8 @@ declare function trace(ctx: RequestContext): {
|
|
|
946
1504
|
}>;
|
|
947
1505
|
/** Build eval cases from a loosely-shaped queries object/array. */
|
|
948
1506
|
evalSetBuild: (raw: unknown) => EvalCase[];
|
|
1507
|
+
/** Validate BKN Trace phase-one fixture files or directories. */
|
|
1508
|
+
validateFixture: (path: string) => FixturePathValidationResult;
|
|
949
1509
|
/**
|
|
950
1510
|
* Run an eval set against an agent: each case's query is sent to the agent,
|
|
951
1511
|
* the resulting trace is fetched, and assertions are checked. `llm` enables
|
|
@@ -1069,23 +1629,41 @@ interface DeleteBuildTasksOptions {
|
|
|
1069
1629
|
ignoreMissing?: boolean;
|
|
1070
1630
|
deleteActiveIndex?: boolean;
|
|
1071
1631
|
}
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
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;
|
|
1632
|
+
type QueryPagingMode = "single" | "cursor";
|
|
1633
|
+
/** Paging options for an initial Vega raw query. */
|
|
1634
|
+
interface RawQueryPaging {
|
|
1635
|
+
mode?: QueryPagingMode;
|
|
1636
|
+
offset?: number;
|
|
1637
|
+
limit?: number;
|
|
1638
|
+
keep_alive_sec?: number;
|
|
1088
1639
|
}
|
|
1640
|
+
/** Opaque cursor continuation. No initial-query fields may accompany it. */
|
|
1641
|
+
interface RawQueryContinuationRequest {
|
|
1642
|
+
paging: {
|
|
1643
|
+
cursor: string;
|
|
1644
|
+
};
|
|
1645
|
+
/** Accepted by the API but cannot override the value frozen on the first page. */
|
|
1646
|
+
need_total?: boolean;
|
|
1647
|
+
}
|
|
1648
|
+
interface RawQueryInitialBase {
|
|
1649
|
+
paging?: RawQueryPaging;
|
|
1650
|
+
/** Per-page timeout in seconds (1–3600); defaults to 60 server-side. */
|
|
1651
|
+
query_timeout_sec?: number;
|
|
1652
|
+
need_total?: boolean;
|
|
1653
|
+
}
|
|
1654
|
+
interface SqlRawQueryRequest extends RawQueryInitialBase {
|
|
1655
|
+
query: string;
|
|
1656
|
+
query_format: "sql";
|
|
1657
|
+
/** SQL input dialect; defaults to postgres server-side. */
|
|
1658
|
+
input_dialect?: "postgres" | "mysql" | "trino" | "duckdb";
|
|
1659
|
+
}
|
|
1660
|
+
interface DslRawQueryRequest extends RawQueryInitialBase {
|
|
1661
|
+
query: Record<string, unknown>;
|
|
1662
|
+
query_format: "dsl";
|
|
1663
|
+
input_dialect: "opensearch";
|
|
1664
|
+
}
|
|
1665
|
+
/** Request contract for POST /resources/query. */
|
|
1666
|
+
type RawQueryRequest = SqlRawQueryRequest | DslRawQueryRequest | RawQueryContinuationRequest;
|
|
1089
1667
|
interface ListCatalogsOptions {
|
|
1090
1668
|
limit?: number;
|
|
1091
1669
|
offset?: number;
|
|
@@ -1126,12 +1704,12 @@ declare function vega(ctx: RequestContext): {
|
|
|
1126
1704
|
deleteCatalog: (id: string) => Promise<unknown>;
|
|
1127
1705
|
testCatalogConnection: (id: string) => Promise<unknown>;
|
|
1128
1706
|
discoverCatalog: (id: string, wait?: boolean) => Promise<unknown>;
|
|
1129
|
-
catalogResources: (id: string, category?: string) => Promise<unknown>;
|
|
1707
|
+
catalogResources: (id: string, category?: string, limit?: number, offset?: number) => Promise<unknown>;
|
|
1130
1708
|
catalogHealth: (ids: string[]) => Promise<unknown>;
|
|
1131
1709
|
connectorTypes: () => Promise<unknown>;
|
|
1132
1710
|
connectorType: (type: string) => Promise<unknown>;
|
|
1133
1711
|
/** Run SQL / OpenSearch DSL directly against a data source. */
|
|
1134
|
-
sql: (body:
|
|
1712
|
+
sql: (body: RawQueryRequest) => Promise<unknown>;
|
|
1135
1713
|
/** Build a resource's index. With `wait`, polls until terminal. */
|
|
1136
1714
|
build: (req: CreateBuildTaskRequest, opts?: {
|
|
1137
1715
|
wait?: boolean;
|
|
@@ -1369,17 +1947,13 @@ interface RequestInitEx {
|
|
|
1369
1947
|
/** Query params appended to the path. */
|
|
1370
1948
|
query?: Record<string, string | number | boolean | Array<string | number | boolean> | undefined>;
|
|
1371
1949
|
headers?: Record<string, string>;
|
|
1950
|
+
/** Redirect policy; credential-bearing writes should use `manual`. */
|
|
1951
|
+
redirect?: "follow" | "error" | "manual";
|
|
1372
1952
|
/** Per-request timeout; defaults to 30s. */
|
|
1373
1953
|
timeoutMs?: number;
|
|
1374
1954
|
}
|
|
1375
1955
|
declare function request<T = unknown>(ctx: RequestContext, path: string, init?: RequestInitEx): Promise<T>;
|
|
1376
1956
|
|
|
1377
|
-
/**
|
|
1378
|
-
* Resolve a full RequestContext from explicit options → env → store.
|
|
1379
|
-
* Order: caller options win, then env vars, then the active platform/user
|
|
1380
|
-
* in `~/.bkn/`.
|
|
1381
|
-
*/
|
|
1382
|
-
|
|
1383
1957
|
declare function resolveContext(opts?: ClientOptions): RequestContext;
|
|
1384
1958
|
|
|
1385
|
-
export { type BknClient, BuildMode, BuildTask, type ClientOptions, CreateBuildTaskRequest, DEFAULT_BUSINESS_DOMAIN, DEFAULT_LIST_LIMIT, DEFAULT_QUERY_LIMIT, HttpError, InputError, type RequestContext, admin, agents, auth, context, createClient, dataflows, kn, models, request, resolveContext, resources, skills, toolboxes, trace, vega };
|
|
1959
|
+
export { type ActionHandle, type ActionResultInput, type ActionSummary, type BknClient, BuildMode, BuildTask, type BusinessEvidenceEventType, type BusinessGraphResponse, type BusinessRefInput, type BusinessRefsInput, type ClaimInput, type ClientOptions, CreateBuildTaskRequest, DEFAULT_BUSINESS_DOMAIN, DEFAULT_LIST_LIMIT, DEFAULT_QUERY_LIMIT, type DslRawQueryRequest, type EvidenceArtifact, type EvidenceArtifactIngestResponse, type EvidenceArtifactType, type EvidenceChainResponse, type EvidenceEvent, type EvidenceIngestRequest, type EvidenceIngestResponse, type EvidenceRefInput, type EvidenceRefsInput, type EvidenceTraceContext, type ExecuteActionInput, type GraphPage, HttpError, InputError, type InteractionInput, type InteractionSummary, type OperationEventPayloadMap, type OperationEventType, type OperationInput, type QueryPagingMode, type RawQueryContinuationRequest, type RawQueryPaging, type RawQueryRequest, type RecommendActionInput, type RequestContext, type RequestSummary, type RequestSummaryQuery, type SnapshotPreviewResponse, type SqlRawQueryRequest, type SummaryPage, type TraceExecutionSummary, type TraceGraphEdge, type TraceGraphNode, type TraceGraphResponse, type TraceQueryOptions, type TraceScope, TraceSession, type TraceSessionOptions, type VisibilitySummary, admin, agents, auth, context, createClient, dataflows, kn, models, request, resolveContext, resources, skills, toolboxes, trace, vega };
|