@kweaver-ai/kweaver-sdk 0.8.3 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/agent-chat.d.ts +10 -2
- package/dist/api/agent-chat.js +19 -5
- package/dist/api/datasources.d.ts +14 -0
- package/dist/api/datasources.js +14 -0
- package/dist/cli.js +2 -14
- package/dist/client.d.ts +7 -1
- package/dist/client.js +7 -1
- package/dist/commands/bkn-ops.d.ts +1 -1
- package/dist/commands/bkn-ops.js +42 -21
- package/dist/commands/bkn.js +6 -3
- package/dist/commands/ds.d.ts +0 -31
- package/dist/commands/ds.js +18 -448
- package/dist/commands/explore-bkn.d.ts +7 -1
- package/dist/commands/explore-bkn.js +32 -3
- package/dist/resources/datasources.d.ts +7 -0
- package/dist/resources/datasources.js +7 -0
- package/dist/templates/explorer/bkn.js +860 -9
- package/dist/templates/explorer/index.html +1 -0
- package/dist/templates/explorer/style.css +225 -0
- package/dist/templates/explorer/vendor/g6.min.js +68 -0
- package/dist/trace-ai/eval-set/schemas.d.ts +1 -0
- package/dist/trace-ai/eval-set/schemas.js +4 -0
- package/dist/trace-ai/eval-set/types.d.ts +2 -0
- package/dist/trace-ai/exp/capture-fingerprint.d.ts +10 -0
- package/dist/trace-ai/exp/capture-fingerprint.js +12 -0
- package/dist/trace-ai/exp/context/context-assembler.d.ts +18 -0
- package/dist/trace-ai/exp/context/context-assembler.js +42 -0
- package/dist/trace-ai/exp/context/failure-analyzer.d.ts +22 -0
- package/dist/trace-ai/exp/context/failure-analyzer.js +59 -0
- package/dist/trace-ai/exp/context/kn-data-prober.d.ts +13 -0
- package/dist/trace-ai/exp/context/kn-data-prober.js +38 -0
- package/dist/trace-ai/exp/context/kn-schema-client.d.ts +14 -0
- package/dist/trace-ai/exp/context/kn-schema-client.js +41 -0
- package/dist/trace-ai/exp/context/retrieval-health.d.ts +32 -0
- package/dist/trace-ai/exp/context/retrieval-health.js +138 -0
- package/dist/trace-ai/exp/context/vega-catalog-client.d.ts +14 -0
- package/dist/trace-ai/exp/context/vega-catalog-client.js +15 -0
- package/dist/trace-ai/exp/coordinator.d.ts +34 -21
- package/dist/trace-ai/exp/coordinator.js +246 -24
- package/dist/trace-ai/exp/eval-runner.js +4 -2
- package/dist/trace-ai/exp/exp-store/events-jsonl.d.ts +1 -0
- package/dist/trace-ai/exp/exp-store/events-jsonl.js +18 -0
- package/dist/trace-ai/exp/exp-store/expected-fingerprint.d.ts +3 -0
- package/dist/trace-ai/exp/exp-store/expected-fingerprint.js +31 -0
- package/dist/trace-ai/exp/exp-store/index.d.ts +63 -2
- package/dist/trace-ai/exp/exp-store/index.js +2 -1
- package/dist/trace-ai/exp/exp-store/rollback-yaml.d.ts +12 -0
- package/dist/trace-ai/exp/exp-store/rollback-yaml.js +29 -0
- package/dist/trace-ai/exp/index.d.ts +2 -0
- package/dist/trace-ai/exp/index.js +68 -3
- package/dist/trace-ai/exp/info.js +1 -1
- package/dist/trace-ai/exp/patch/index.d.ts +13 -2
- package/dist/trace-ai/exp/patch/index.js +65 -10
- package/dist/trace-ai/exp/patch/kn-api-client.d.ts +40 -0
- package/dist/trace-ai/exp/patch/kn-api-client.js +14 -0
- package/dist/trace-ai/exp/patch/kn.d.ts +8 -0
- package/dist/trace-ai/exp/patch/kn.js +36 -0
- package/dist/trace-ai/exp/patch/skill-api-client.d.ts +17 -0
- package/dist/trace-ai/exp/patch/skill-api-client.js +14 -0
- package/dist/trace-ai/exp/patch/skill-content.d.ts +9 -0
- package/dist/trace-ai/exp/patch/skill-content.js +12 -0
- package/dist/trace-ai/exp/preflight.d.ts +77 -0
- package/dist/trace-ai/exp/preflight.js +148 -0
- package/dist/trace-ai/exp/providers/synthesizer-client.d.ts +3 -14
- package/dist/trace-ai/exp/providers/synthesizer-client.js +53 -35
- package/dist/trace-ai/exp/providers/triage-client.d.ts +15 -2
- package/dist/trace-ai/exp/providers/triage-client.js +143 -28
- package/dist/trace-ai/exp/run-preflight.d.ts +19 -0
- package/dist/trace-ai/exp/run-preflight.js +56 -0
- package/dist/trace-ai/exp/schemas.d.ts +402 -44
- package/dist/trace-ai/exp/schemas.js +131 -18
- package/dist/utils/deprecation.d.ts +1 -0
- package/dist/utils/deprecation.js +18 -0
- package/package.json +2 -1
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const NextChangeSchema: z.ZodObject<{
|
|
3
|
-
target: z.ZodString;
|
|
4
|
-
hypothesis: z.ZodString;
|
|
5
|
-
patch: z.ZodString;
|
|
6
|
-
}, z.core.$strip>;
|
|
7
2
|
declare const GuardrailSchema: z.ZodObject<{
|
|
8
3
|
name: z.ZodString;
|
|
9
4
|
kind: z.ZodEnum<{
|
|
@@ -12,38 +7,6 @@ declare const GuardrailSchema: z.ZodObject<{
|
|
|
12
7
|
}>;
|
|
13
8
|
rule: z.ZodString;
|
|
14
9
|
}, z.core.$strip>;
|
|
15
|
-
export declare const MissionSchema: z.ZodObject<{
|
|
16
|
-
schema_version: z.ZodLiteral<"trace-mission/v1">;
|
|
17
|
-
goal: z.ZodString;
|
|
18
|
-
max_rounds: z.ZodOptional<z.ZodNumber>;
|
|
19
|
-
provider: z.ZodOptional<z.ZodString>;
|
|
20
|
-
eval_sets: z.ZodArray<z.ZodObject<{
|
|
21
|
-
path: z.ZodString;
|
|
22
|
-
role: z.ZodEnum<{
|
|
23
|
-
seed: "seed";
|
|
24
|
-
regression: "regression";
|
|
25
|
-
holdout: "holdout";
|
|
26
|
-
}>;
|
|
27
|
-
}, z.core.$strip>>;
|
|
28
|
-
current_candidate: z.ZodObject<{
|
|
29
|
-
path: z.ZodString;
|
|
30
|
-
}, z.core.$strip>;
|
|
31
|
-
next_change: z.ZodOptional<z.ZodObject<{
|
|
32
|
-
target: z.ZodString;
|
|
33
|
-
hypothesis: z.ZodString;
|
|
34
|
-
patch: z.ZodString;
|
|
35
|
-
}, z.core.$strip>>;
|
|
36
|
-
guardrails: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
37
|
-
name: z.ZodString;
|
|
38
|
-
kind: z.ZodEnum<{
|
|
39
|
-
hard: "hard";
|
|
40
|
-
soft: "soft";
|
|
41
|
-
}>;
|
|
42
|
-
rule: z.ZodString;
|
|
43
|
-
}, z.core.$strip>>>;
|
|
44
|
-
}, z.core.$strip>;
|
|
45
|
-
export type Mission = z.infer<typeof MissionSchema>;
|
|
46
|
-
export type NextChange = z.infer<typeof NextChangeSchema>;
|
|
47
10
|
export { GuardrailSchema };
|
|
48
11
|
export type Guardrail = z.infer<typeof GuardrailSchema>;
|
|
49
12
|
export declare const BundleSchema: z.ZodObject<{
|
|
@@ -102,14 +65,14 @@ export type ExpEvent = {
|
|
|
102
65
|
type: "aborted";
|
|
103
66
|
round: number;
|
|
104
67
|
reason: string;
|
|
68
|
+
} | {
|
|
69
|
+
ts: string;
|
|
70
|
+
type: "TriageComplete";
|
|
71
|
+
round: number;
|
|
72
|
+
verdict: string;
|
|
73
|
+
summary: string;
|
|
74
|
+
failure_attribution: FailureAttribution[];
|
|
105
75
|
};
|
|
106
|
-
export interface LineageEntry {
|
|
107
|
-
version: number;
|
|
108
|
-
candidate_path: string;
|
|
109
|
-
next_change: NextChange;
|
|
110
|
-
status: "running" | "scored" | "guardrail_failed";
|
|
111
|
-
appended_at: string;
|
|
112
|
-
}
|
|
113
76
|
export interface ThreeAxisScores {
|
|
114
77
|
outcome: number;
|
|
115
78
|
trajectory: number;
|
|
@@ -130,6 +93,23 @@ export interface QueryResult {
|
|
|
130
93
|
error_codes: string[];
|
|
131
94
|
};
|
|
132
95
|
raw_trace_id?: string;
|
|
96
|
+
conversation_id?: string;
|
|
97
|
+
}
|
|
98
|
+
export interface QueryFailureAnalysis {
|
|
99
|
+
query_id: string;
|
|
100
|
+
verdict: "fail" | "skip";
|
|
101
|
+
/** Assertion failure reason, truncated to 200 chars. */
|
|
102
|
+
assertion_reason: string;
|
|
103
|
+
/** Tool calls extracted from trace, e.g. ["kn_search(激光雷达)→data"]. Max 3 entries. */
|
|
104
|
+
tool_call_summary: string[];
|
|
105
|
+
/**
|
|
106
|
+
* Whether the agent actually retrieved KN data on this query, derived from the
|
|
107
|
+
* trace. "retrieved" = at least one KN tool call returned data; "errored"/
|
|
108
|
+
* "empty" = KN tool calls were made but none returned data; "no_kn_calls" =
|
|
109
|
+
* no KN tool was called; "no_trace" = trace unavailable. Lets triage see a
|
|
110
|
+
* mechanism failure (agent not retrieving data) instead of guessing at prompts.
|
|
111
|
+
*/
|
|
112
|
+
retrieval_health: "retrieved" | "empty" | "errored" | "no_kn_calls" | "no_trace";
|
|
133
113
|
}
|
|
134
114
|
export interface RoundData {
|
|
135
115
|
round: number;
|
|
@@ -145,3 +125,381 @@ export interface RoundData {
|
|
|
145
125
|
cross_round_memory_ref?: string;
|
|
146
126
|
};
|
|
147
127
|
}
|
|
128
|
+
export declare const PatchTargetSchema: z.ZodEnum<{
|
|
129
|
+
"agent.system_prompt": "agent.system_prompt";
|
|
130
|
+
"agent.skills": "agent.skills";
|
|
131
|
+
"kn.object_type": "kn.object_type";
|
|
132
|
+
"kn.relation_type": "kn.relation_type";
|
|
133
|
+
"skill.content": "skill.content";
|
|
134
|
+
}>;
|
|
135
|
+
export type PatchTarget = z.infer<typeof PatchTargetSchema>;
|
|
136
|
+
export declare const FailureAttributionSchema: z.ZodObject<{
|
|
137
|
+
layer: z.ZodEnum<{
|
|
138
|
+
agent: "agent";
|
|
139
|
+
skill: "skill";
|
|
140
|
+
kn: "kn";
|
|
141
|
+
}>;
|
|
142
|
+
evidence: z.ZodString;
|
|
143
|
+
affected_queries: z.ZodArray<z.ZodString>;
|
|
144
|
+
suggested_target: z.ZodEnum<{
|
|
145
|
+
"agent.system_prompt": "agent.system_prompt";
|
|
146
|
+
"agent.skills": "agent.skills";
|
|
147
|
+
"kn.object_type": "kn.object_type";
|
|
148
|
+
"kn.relation_type": "kn.relation_type";
|
|
149
|
+
"skill.content": "skill.content";
|
|
150
|
+
}>;
|
|
151
|
+
}, z.core.$strip>;
|
|
152
|
+
export type FailureAttribution = z.infer<typeof FailureAttributionSchema>;
|
|
153
|
+
export declare const KnDataPropertySchema: z.ZodObject<{
|
|
154
|
+
name: z.ZodString;
|
|
155
|
+
type: z.ZodString;
|
|
156
|
+
}, z.core.$strip>;
|
|
157
|
+
export declare const KnObjectTypeDefSchema: z.ZodObject<{
|
|
158
|
+
concept_name: z.ZodString;
|
|
159
|
+
dataview_id: z.ZodString;
|
|
160
|
+
primary_keys: z.ZodArray<z.ZodString>;
|
|
161
|
+
data_properties: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
162
|
+
name: z.ZodString;
|
|
163
|
+
type: z.ZodString;
|
|
164
|
+
}, z.core.$strip>>>;
|
|
165
|
+
}, z.core.$strip>;
|
|
166
|
+
export type KnObjectTypeDef = z.infer<typeof KnObjectTypeDefSchema>;
|
|
167
|
+
export declare const KnRelationTypeDefSchema: z.ZodObject<{
|
|
168
|
+
concept_name: z.ZodString;
|
|
169
|
+
source_object_type: z.ZodString;
|
|
170
|
+
target_object_type: z.ZodString;
|
|
171
|
+
join_key: z.ZodString;
|
|
172
|
+
}, z.core.$strip>;
|
|
173
|
+
export type KnRelationTypeDef = z.infer<typeof KnRelationTypeDefSchema>;
|
|
174
|
+
export declare const KnPatchSchema: z.ZodObject<{
|
|
175
|
+
kn_id: z.ZodString;
|
|
176
|
+
add_object_types: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
177
|
+
concept_name: z.ZodString;
|
|
178
|
+
dataview_id: z.ZodString;
|
|
179
|
+
primary_keys: z.ZodArray<z.ZodString>;
|
|
180
|
+
data_properties: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
181
|
+
name: z.ZodString;
|
|
182
|
+
type: z.ZodString;
|
|
183
|
+
}, z.core.$strip>>>;
|
|
184
|
+
}, z.core.$strip>>>;
|
|
185
|
+
add_relation_types: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
186
|
+
concept_name: z.ZodString;
|
|
187
|
+
source_object_type: z.ZodString;
|
|
188
|
+
target_object_type: z.ZodString;
|
|
189
|
+
join_key: z.ZodString;
|
|
190
|
+
}, z.core.$strip>>>;
|
|
191
|
+
}, z.core.$strip>;
|
|
192
|
+
export type KnPatch = z.infer<typeof KnPatchSchema>;
|
|
193
|
+
export declare const SkillContentPatchSchema: z.ZodObject<{
|
|
194
|
+
skill_id: z.ZodString;
|
|
195
|
+
append_section: z.ZodString;
|
|
196
|
+
}, z.core.$strip>;
|
|
197
|
+
export type SkillContentPatch = z.infer<typeof SkillContentPatchSchema>;
|
|
198
|
+
export declare const SkillBindingSchema: z.ZodObject<{
|
|
199
|
+
id: z.ZodString;
|
|
200
|
+
version: z.ZodString;
|
|
201
|
+
}, z.core.$strip>;
|
|
202
|
+
export type SkillBinding = z.infer<typeof SkillBindingSchema>;
|
|
203
|
+
export declare const AgentSkillsPatchSchema: z.ZodObject<{
|
|
204
|
+
unbind: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
205
|
+
bind: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
206
|
+
id: z.ZodString;
|
|
207
|
+
version: z.ZodString;
|
|
208
|
+
}, z.core.$strip>>>;
|
|
209
|
+
}, z.core.$strip>;
|
|
210
|
+
export type AgentSkillsPatch = z.infer<typeof AgentSkillsPatchSchema>;
|
|
211
|
+
export declare const NextChangeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
212
|
+
target: z.ZodLiteral<"agent.system_prompt">;
|
|
213
|
+
hypothesis: z.ZodOptional<z.ZodString>;
|
|
214
|
+
patch: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
|
|
215
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
216
|
+
target: z.ZodLiteral<"agent.skills">;
|
|
217
|
+
hypothesis: z.ZodOptional<z.ZodString>;
|
|
218
|
+
patch: z.ZodObject<{
|
|
219
|
+
unbind: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
220
|
+
bind: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
221
|
+
id: z.ZodString;
|
|
222
|
+
version: z.ZodString;
|
|
223
|
+
}, z.core.$strip>>>;
|
|
224
|
+
}, z.core.$strip>;
|
|
225
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
226
|
+
target: z.ZodLiteral<"kn.object_type">;
|
|
227
|
+
hypothesis: z.ZodString;
|
|
228
|
+
patch: z.ZodObject<{
|
|
229
|
+
kn_id: z.ZodString;
|
|
230
|
+
add_object_types: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
231
|
+
concept_name: z.ZodString;
|
|
232
|
+
dataview_id: z.ZodString;
|
|
233
|
+
primary_keys: z.ZodArray<z.ZodString>;
|
|
234
|
+
data_properties: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
235
|
+
name: z.ZodString;
|
|
236
|
+
type: z.ZodString;
|
|
237
|
+
}, z.core.$strip>>>;
|
|
238
|
+
}, z.core.$strip>>>;
|
|
239
|
+
add_relation_types: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
240
|
+
concept_name: z.ZodString;
|
|
241
|
+
source_object_type: z.ZodString;
|
|
242
|
+
target_object_type: z.ZodString;
|
|
243
|
+
join_key: z.ZodString;
|
|
244
|
+
}, z.core.$strip>>>;
|
|
245
|
+
}, z.core.$strip>;
|
|
246
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
247
|
+
target: z.ZodLiteral<"kn.relation_type">;
|
|
248
|
+
hypothesis: z.ZodString;
|
|
249
|
+
patch: z.ZodObject<{
|
|
250
|
+
kn_id: z.ZodString;
|
|
251
|
+
add_object_types: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
252
|
+
concept_name: z.ZodString;
|
|
253
|
+
dataview_id: z.ZodString;
|
|
254
|
+
primary_keys: z.ZodArray<z.ZodString>;
|
|
255
|
+
data_properties: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
256
|
+
name: z.ZodString;
|
|
257
|
+
type: z.ZodString;
|
|
258
|
+
}, z.core.$strip>>>;
|
|
259
|
+
}, z.core.$strip>>>;
|
|
260
|
+
add_relation_types: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
261
|
+
concept_name: z.ZodString;
|
|
262
|
+
source_object_type: z.ZodString;
|
|
263
|
+
target_object_type: z.ZodString;
|
|
264
|
+
join_key: z.ZodString;
|
|
265
|
+
}, z.core.$strip>>>;
|
|
266
|
+
}, z.core.$strip>;
|
|
267
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
268
|
+
target: z.ZodLiteral<"skill.content">;
|
|
269
|
+
hypothesis: z.ZodString;
|
|
270
|
+
patch: z.ZodObject<{
|
|
271
|
+
skill_id: z.ZodString;
|
|
272
|
+
append_section: z.ZodString;
|
|
273
|
+
}, z.core.$strip>;
|
|
274
|
+
}, z.core.$strip>], "target">;
|
|
275
|
+
export type NextChange = z.infer<typeof NextChangeSchema>;
|
|
276
|
+
export declare const MissionSchema: z.ZodObject<{
|
|
277
|
+
schema_version: z.ZodLiteral<"trace-mission/v1">;
|
|
278
|
+
goal: z.ZodString;
|
|
279
|
+
max_rounds: z.ZodOptional<z.ZodNumber>;
|
|
280
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
281
|
+
eval_sets: z.ZodArray<z.ZodObject<{
|
|
282
|
+
path: z.ZodString;
|
|
283
|
+
role: z.ZodEnum<{
|
|
284
|
+
seed: "seed";
|
|
285
|
+
regression: "regression";
|
|
286
|
+
holdout: "holdout";
|
|
287
|
+
}>;
|
|
288
|
+
}, z.core.$strip>>;
|
|
289
|
+
current_candidate: z.ZodObject<{
|
|
290
|
+
path: z.ZodString;
|
|
291
|
+
}, z.core.$strip>;
|
|
292
|
+
next_change: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
293
|
+
target: z.ZodLiteral<"agent.system_prompt">;
|
|
294
|
+
hypothesis: z.ZodOptional<z.ZodString>;
|
|
295
|
+
patch: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
|
|
296
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
297
|
+
target: z.ZodLiteral<"agent.skills">;
|
|
298
|
+
hypothesis: z.ZodOptional<z.ZodString>;
|
|
299
|
+
patch: z.ZodObject<{
|
|
300
|
+
unbind: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
301
|
+
bind: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
302
|
+
id: z.ZodString;
|
|
303
|
+
version: z.ZodString;
|
|
304
|
+
}, z.core.$strip>>>;
|
|
305
|
+
}, z.core.$strip>;
|
|
306
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
307
|
+
target: z.ZodLiteral<"kn.object_type">;
|
|
308
|
+
hypothesis: z.ZodString;
|
|
309
|
+
patch: z.ZodObject<{
|
|
310
|
+
kn_id: z.ZodString;
|
|
311
|
+
add_object_types: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
312
|
+
concept_name: z.ZodString;
|
|
313
|
+
dataview_id: z.ZodString;
|
|
314
|
+
primary_keys: z.ZodArray<z.ZodString>;
|
|
315
|
+
data_properties: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
316
|
+
name: z.ZodString;
|
|
317
|
+
type: z.ZodString;
|
|
318
|
+
}, z.core.$strip>>>;
|
|
319
|
+
}, z.core.$strip>>>;
|
|
320
|
+
add_relation_types: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
321
|
+
concept_name: z.ZodString;
|
|
322
|
+
source_object_type: z.ZodString;
|
|
323
|
+
target_object_type: z.ZodString;
|
|
324
|
+
join_key: z.ZodString;
|
|
325
|
+
}, z.core.$strip>>>;
|
|
326
|
+
}, z.core.$strip>;
|
|
327
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
328
|
+
target: z.ZodLiteral<"kn.relation_type">;
|
|
329
|
+
hypothesis: z.ZodString;
|
|
330
|
+
patch: z.ZodObject<{
|
|
331
|
+
kn_id: z.ZodString;
|
|
332
|
+
add_object_types: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
333
|
+
concept_name: z.ZodString;
|
|
334
|
+
dataview_id: z.ZodString;
|
|
335
|
+
primary_keys: z.ZodArray<z.ZodString>;
|
|
336
|
+
data_properties: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
337
|
+
name: z.ZodString;
|
|
338
|
+
type: z.ZodString;
|
|
339
|
+
}, z.core.$strip>>>;
|
|
340
|
+
}, z.core.$strip>>>;
|
|
341
|
+
add_relation_types: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
342
|
+
concept_name: z.ZodString;
|
|
343
|
+
source_object_type: z.ZodString;
|
|
344
|
+
target_object_type: z.ZodString;
|
|
345
|
+
join_key: z.ZodString;
|
|
346
|
+
}, z.core.$strip>>>;
|
|
347
|
+
}, z.core.$strip>;
|
|
348
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
349
|
+
target: z.ZodLiteral<"skill.content">;
|
|
350
|
+
hypothesis: z.ZodString;
|
|
351
|
+
patch: z.ZodObject<{
|
|
352
|
+
skill_id: z.ZodString;
|
|
353
|
+
append_section: z.ZodString;
|
|
354
|
+
}, z.core.$strip>;
|
|
355
|
+
}, z.core.$strip>], "target">>;
|
|
356
|
+
guardrails: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
357
|
+
name: z.ZodString;
|
|
358
|
+
kind: z.ZodEnum<{
|
|
359
|
+
hard: "hard";
|
|
360
|
+
soft: "soft";
|
|
361
|
+
}>;
|
|
362
|
+
rule: z.ZodString;
|
|
363
|
+
}, z.core.$strip>>>;
|
|
364
|
+
enabled_targets: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
365
|
+
"agent.system_prompt": "agent.system_prompt";
|
|
366
|
+
"agent.skills": "agent.skills";
|
|
367
|
+
"kn.object_type": "kn.object_type";
|
|
368
|
+
"kn.relation_type": "kn.relation_type";
|
|
369
|
+
"skill.content": "skill.content";
|
|
370
|
+
}>>>;
|
|
371
|
+
}, z.core.$strip>;
|
|
372
|
+
export type Mission = z.infer<typeof MissionSchema>;
|
|
373
|
+
export declare const VegaCatalogEntrySchema: z.ZodObject<{
|
|
374
|
+
id: z.ZodString;
|
|
375
|
+
name: z.ZodString;
|
|
376
|
+
columns: z.ZodArray<z.ZodObject<{
|
|
377
|
+
name: z.ZodString;
|
|
378
|
+
type: z.ZodString;
|
|
379
|
+
}, z.core.$strip>>;
|
|
380
|
+
}, z.core.$strip>;
|
|
381
|
+
export type VegaCatalogEntry = z.infer<typeof VegaCatalogEntrySchema>;
|
|
382
|
+
export declare const KnSchemaSnapshotSchema: z.ZodObject<{
|
|
383
|
+
object_types: z.ZodArray<z.ZodObject<{
|
|
384
|
+
concept_name: z.ZodString;
|
|
385
|
+
data_view_id: z.ZodOptional<z.ZodString>;
|
|
386
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
387
|
+
name: z.ZodString;
|
|
388
|
+
type: z.ZodString;
|
|
389
|
+
}, z.core.$strip>>;
|
|
390
|
+
}, z.core.$strip>>;
|
|
391
|
+
relation_types: z.ZodArray<z.ZodObject<{
|
|
392
|
+
concept_name: z.ZodString;
|
|
393
|
+
source: z.ZodString;
|
|
394
|
+
target: z.ZodString;
|
|
395
|
+
join_key: z.ZodString;
|
|
396
|
+
}, z.core.$strip>>;
|
|
397
|
+
}, z.core.$strip>;
|
|
398
|
+
export type KnSchemaSnapshot = z.infer<typeof KnSchemaSnapshotSchema>;
|
|
399
|
+
export declare const KnContextSchema: z.ZodObject<{
|
|
400
|
+
kn_id: z.ZodString;
|
|
401
|
+
existing_schema: z.ZodObject<{
|
|
402
|
+
object_types: z.ZodArray<z.ZodObject<{
|
|
403
|
+
concept_name: z.ZodString;
|
|
404
|
+
data_view_id: z.ZodOptional<z.ZodString>;
|
|
405
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
406
|
+
name: z.ZodString;
|
|
407
|
+
type: z.ZodString;
|
|
408
|
+
}, z.core.$strip>>;
|
|
409
|
+
}, z.core.$strip>>;
|
|
410
|
+
relation_types: z.ZodArray<z.ZodObject<{
|
|
411
|
+
concept_name: z.ZodString;
|
|
412
|
+
source: z.ZodString;
|
|
413
|
+
target: z.ZodString;
|
|
414
|
+
join_key: z.ZodString;
|
|
415
|
+
}, z.core.$strip>>;
|
|
416
|
+
}, z.core.$strip>;
|
|
417
|
+
available_dataviews: z.ZodArray<z.ZodObject<{
|
|
418
|
+
id: z.ZodString;
|
|
419
|
+
name: z.ZodString;
|
|
420
|
+
columns: z.ZodArray<z.ZodObject<{
|
|
421
|
+
name: z.ZodString;
|
|
422
|
+
type: z.ZodString;
|
|
423
|
+
}, z.core.$strip>>;
|
|
424
|
+
}, z.core.$strip>>;
|
|
425
|
+
data_probes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
426
|
+
concept_name: z.ZodString;
|
|
427
|
+
data_view_id: z.ZodString;
|
|
428
|
+
total_records: z.ZodNumber;
|
|
429
|
+
}, z.core.$strip>>>;
|
|
430
|
+
}, z.core.$strip>;
|
|
431
|
+
export type KnContext = z.infer<typeof KnContextSchema>;
|
|
432
|
+
export declare const SkillContextSchema: z.ZodObject<{
|
|
433
|
+
bound_skills: z.ZodArray<z.ZodObject<{
|
|
434
|
+
id: z.ZodString;
|
|
435
|
+
version: z.ZodString;
|
|
436
|
+
content: z.ZodString;
|
|
437
|
+
}, z.core.$strip>>;
|
|
438
|
+
}, z.core.$strip>;
|
|
439
|
+
export type SkillContext = z.infer<typeof SkillContextSchema>;
|
|
440
|
+
export declare const CandidateSchema: z.ZodObject<{
|
|
441
|
+
schema_version: z.ZodLiteral<"trace-candidate/v1">;
|
|
442
|
+
agent: z.ZodObject<{
|
|
443
|
+
description: z.ZodString;
|
|
444
|
+
system_prompt: z.ZodString;
|
|
445
|
+
}, z.core.$strip>;
|
|
446
|
+
kn: z.ZodOptional<z.ZodObject<{
|
|
447
|
+
id: z.ZodString;
|
|
448
|
+
object_types: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
449
|
+
concept_name: z.ZodString;
|
|
450
|
+
dataview_id: z.ZodString;
|
|
451
|
+
primary_keys: z.ZodArray<z.ZodString>;
|
|
452
|
+
data_properties: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
453
|
+
name: z.ZodString;
|
|
454
|
+
type: z.ZodString;
|
|
455
|
+
}, z.core.$strip>>>;
|
|
456
|
+
}, z.core.$strip>>>;
|
|
457
|
+
relation_types: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
458
|
+
concept_name: z.ZodString;
|
|
459
|
+
source_object_type: z.ZodString;
|
|
460
|
+
target_object_type: z.ZodString;
|
|
461
|
+
join_key: z.ZodString;
|
|
462
|
+
}, z.core.$strip>>>;
|
|
463
|
+
}, z.core.$strip>>;
|
|
464
|
+
}, z.core.$strip>;
|
|
465
|
+
export type Candidate = z.infer<typeof CandidateSchema>;
|
|
466
|
+
export interface LineageEntry {
|
|
467
|
+
version: number;
|
|
468
|
+
candidate_path: string;
|
|
469
|
+
next_change: NextChange;
|
|
470
|
+
status: "running" | "scored" | "guardrail_failed";
|
|
471
|
+
appended_at: string;
|
|
472
|
+
}
|
|
473
|
+
export declare const SkillSetEntrySchema: z.ZodObject<{
|
|
474
|
+
id: z.ZodString;
|
|
475
|
+
version: z.ZodString;
|
|
476
|
+
}, z.core.$strip>;
|
|
477
|
+
export type SkillSetEntry = z.infer<typeof SkillSetEntrySchema>;
|
|
478
|
+
export declare const KnPatchLogEntrySchema: z.ZodObject<{
|
|
479
|
+
op: z.ZodEnum<{
|
|
480
|
+
add_object_type: "add_object_type";
|
|
481
|
+
add_relation_type: "add_relation_type";
|
|
482
|
+
}>;
|
|
483
|
+
concept_name: z.ZodString;
|
|
484
|
+
dataview_id: z.ZodOptional<z.ZodString>;
|
|
485
|
+
applied_at: z.ZodString;
|
|
486
|
+
}, z.core.$strip>;
|
|
487
|
+
export type KnPatchLogEntry = z.infer<typeof KnPatchLogEntrySchema>;
|
|
488
|
+
export declare const LineageEntrySchema: z.ZodObject<{
|
|
489
|
+
version: z.ZodNumber;
|
|
490
|
+
agent_id: z.ZodString;
|
|
491
|
+
skill_set: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
492
|
+
id: z.ZodString;
|
|
493
|
+
version: z.ZodString;
|
|
494
|
+
}, z.core.$strip>>>;
|
|
495
|
+
kn_patch_log: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
496
|
+
op: z.ZodEnum<{
|
|
497
|
+
add_object_type: "add_object_type";
|
|
498
|
+
add_relation_type: "add_relation_type";
|
|
499
|
+
}>;
|
|
500
|
+
concept_name: z.ZodString;
|
|
501
|
+
dataview_id: z.ZodOptional<z.ZodString>;
|
|
502
|
+
applied_at: z.ZodString;
|
|
503
|
+
}, z.core.$strip>>>;
|
|
504
|
+
}, z.core.$strip>;
|
|
505
|
+
export type LineageEntryExtended = z.infer<typeof LineageEntrySchema>;
|
|
@@ -1,27 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export const NextChangeSchema = z.object({
|
|
3
|
-
target: z.string().min(1),
|
|
4
|
-
hypothesis: z.string().min(1),
|
|
5
|
-
patch: z.string(),
|
|
6
|
-
});
|
|
7
2
|
const GuardrailSchema = z.object({
|
|
8
3
|
name: z.string(),
|
|
9
4
|
kind: z.enum(["hard", "soft"]),
|
|
10
5
|
rule: z.string(),
|
|
11
6
|
});
|
|
12
|
-
export const MissionSchema = z.object({
|
|
13
|
-
schema_version: z.literal("trace-mission/v1"),
|
|
14
|
-
goal: z.string().min(1),
|
|
15
|
-
max_rounds: z.number().int().positive().optional(),
|
|
16
|
-
provider: z.string().optional(),
|
|
17
|
-
eval_sets: z.array(z.object({
|
|
18
|
-
path: z.string().min(1),
|
|
19
|
-
role: z.enum(["seed", "regression", "holdout"]),
|
|
20
|
-
})).min(1),
|
|
21
|
-
current_candidate: z.object({ path: z.string() }),
|
|
22
|
-
next_change: NextChangeSchema.optional(),
|
|
23
|
-
guardrails: z.array(GuardrailSchema).optional(),
|
|
24
|
-
});
|
|
25
7
|
export { GuardrailSchema };
|
|
26
8
|
export const BundleSchema = z.object({
|
|
27
9
|
schema_version: z.literal("trace-bundle/v1"),
|
|
@@ -48,3 +30,134 @@ export const ManifestSchema = z.object({
|
|
|
48
30
|
risks: z.array(z.object({ query_id: z.string(), reason: z.string() })),
|
|
49
31
|
}),
|
|
50
32
|
});
|
|
33
|
+
// ── Multilayer Patch ──────────────────────────────────────────────────────
|
|
34
|
+
export const PatchTargetSchema = z.enum([
|
|
35
|
+
"agent.system_prompt",
|
|
36
|
+
"agent.skills",
|
|
37
|
+
"kn.object_type",
|
|
38
|
+
"kn.relation_type",
|
|
39
|
+
"skill.content",
|
|
40
|
+
]);
|
|
41
|
+
export const FailureAttributionSchema = z.object({
|
|
42
|
+
layer: z.enum(["kn", "skill", "agent"]),
|
|
43
|
+
evidence: z.string(),
|
|
44
|
+
affected_queries: z.array(z.string()),
|
|
45
|
+
suggested_target: PatchTargetSchema,
|
|
46
|
+
});
|
|
47
|
+
// ── KN Patch types ────────────────────────────────────────────────────────
|
|
48
|
+
export const KnDataPropertySchema = z.object({ name: z.string(), type: z.string() });
|
|
49
|
+
export const KnObjectTypeDefSchema = z.object({
|
|
50
|
+
concept_name: z.string(),
|
|
51
|
+
dataview_id: z.string(),
|
|
52
|
+
primary_keys: z.array(z.string()),
|
|
53
|
+
data_properties: z.array(KnDataPropertySchema).default([]),
|
|
54
|
+
});
|
|
55
|
+
export const KnRelationTypeDefSchema = z.object({
|
|
56
|
+
concept_name: z.string(),
|
|
57
|
+
source_object_type: z.string(),
|
|
58
|
+
target_object_type: z.string(),
|
|
59
|
+
join_key: z.string(),
|
|
60
|
+
});
|
|
61
|
+
export const KnPatchSchema = z.object({
|
|
62
|
+
kn_id: z.string(),
|
|
63
|
+
add_object_types: z.array(KnObjectTypeDefSchema).default([]),
|
|
64
|
+
add_relation_types: z.array(KnRelationTypeDefSchema).default([]),
|
|
65
|
+
});
|
|
66
|
+
// ── Skill Patch types ─────────────────────────────────────────────────────
|
|
67
|
+
export const SkillContentPatchSchema = z.object({
|
|
68
|
+
skill_id: z.string(),
|
|
69
|
+
append_section: z.string(),
|
|
70
|
+
});
|
|
71
|
+
export const SkillBindingSchema = z.object({ id: z.string(), version: z.string() });
|
|
72
|
+
export const AgentSkillsPatchSchema = z.object({
|
|
73
|
+
unbind: z.array(z.string()).default([]),
|
|
74
|
+
bind: z.array(SkillBindingSchema).default([]),
|
|
75
|
+
});
|
|
76
|
+
// ── NextChange discriminated union ────────────────────────────────────────
|
|
77
|
+
export const NextChangeSchema = z.discriminatedUnion("target", [
|
|
78
|
+
z.object({ target: z.literal("agent.system_prompt"), hypothesis: z.string().optional(), patch: z.union([z.string(), z.record(z.string(), z.unknown())]) }),
|
|
79
|
+
z.object({ target: z.literal("agent.skills"), hypothesis: z.string().optional(), patch: AgentSkillsPatchSchema }),
|
|
80
|
+
z.object({ target: z.literal("kn.object_type"), hypothesis: z.string(), patch: KnPatchSchema }),
|
|
81
|
+
z.object({ target: z.literal("kn.relation_type"), hypothesis: z.string(), patch: KnPatchSchema }),
|
|
82
|
+
z.object({ target: z.literal("skill.content"), hypothesis: z.string(), patch: SkillContentPatchSchema }),
|
|
83
|
+
]);
|
|
84
|
+
// ── MissionSchema (depends on NextChangeSchema) ───────────────────────────
|
|
85
|
+
export const MissionSchema = z.object({
|
|
86
|
+
schema_version: z.literal("trace-mission/v1"),
|
|
87
|
+
goal: z.string().min(1),
|
|
88
|
+
max_rounds: z.number().int().positive().optional(),
|
|
89
|
+
provider: z.string().optional(),
|
|
90
|
+
eval_sets: z.array(z.object({
|
|
91
|
+
path: z.string().min(1),
|
|
92
|
+
role: z.enum(["seed", "regression", "holdout"]),
|
|
93
|
+
})).min(1),
|
|
94
|
+
current_candidate: z.object({ path: z.string() }),
|
|
95
|
+
next_change: NextChangeSchema.optional(),
|
|
96
|
+
guardrails: z.array(GuardrailSchema).optional(),
|
|
97
|
+
/**
|
|
98
|
+
* Patch targets this experiment is allowed to iterate on. Limits the planner
|
|
99
|
+
* LLM's choices, gates KN/Skill client construction, and shapes prompt
|
|
100
|
+
* examples. Default = ["agent.system_prompt"] — safest for missions that
|
|
101
|
+
* predate the multilayer rollout. Opt-in to other layers as their backing
|
|
102
|
+
* API clients become production-ready.
|
|
103
|
+
*/
|
|
104
|
+
enabled_targets: z.array(PatchTargetSchema).min(1).default(["agent.system_prompt"]),
|
|
105
|
+
});
|
|
106
|
+
// ── ContextAssembler types ────────────────────────────────────────────────
|
|
107
|
+
export const VegaCatalogEntrySchema = z.object({
|
|
108
|
+
id: z.string(),
|
|
109
|
+
name: z.string(),
|
|
110
|
+
columns: z.array(z.object({ name: z.string(), type: z.string() })),
|
|
111
|
+
});
|
|
112
|
+
export const KnSchemaSnapshotSchema = z.object({
|
|
113
|
+
object_types: z.array(z.object({
|
|
114
|
+
concept_name: z.string(),
|
|
115
|
+
data_view_id: z.string().optional(),
|
|
116
|
+
fields: z.array(z.object({ name: z.string(), type: z.string() })),
|
|
117
|
+
})),
|
|
118
|
+
relation_types: z.array(z.object({
|
|
119
|
+
concept_name: z.string(),
|
|
120
|
+
source: z.string(),
|
|
121
|
+
target: z.string(),
|
|
122
|
+
join_key: z.string(),
|
|
123
|
+
})),
|
|
124
|
+
});
|
|
125
|
+
export const KnContextSchema = z.object({
|
|
126
|
+
kn_id: z.string(),
|
|
127
|
+
existing_schema: KnSchemaSnapshotSchema,
|
|
128
|
+
available_dataviews: z.array(VegaCatalogEntrySchema),
|
|
129
|
+
data_probes: z.array(z.object({
|
|
130
|
+
concept_name: z.string(),
|
|
131
|
+
data_view_id: z.string(),
|
|
132
|
+
total_records: z.number(),
|
|
133
|
+
})).optional(),
|
|
134
|
+
});
|
|
135
|
+
export const SkillContextSchema = z.object({
|
|
136
|
+
bound_skills: z.array(z.object({ id: z.string(), version: z.string(), content: z.string() })),
|
|
137
|
+
});
|
|
138
|
+
// ── CandidateSchema ───────────────────────────────────────────────────────
|
|
139
|
+
export const CandidateSchema = z.object({
|
|
140
|
+
schema_version: z.literal("trace-candidate/v1"),
|
|
141
|
+
agent: z.object({
|
|
142
|
+
description: z.string(),
|
|
143
|
+
system_prompt: z.string(),
|
|
144
|
+
}),
|
|
145
|
+
kn: z.object({
|
|
146
|
+
id: z.string(),
|
|
147
|
+
object_types: z.array(KnObjectTypeDefSchema).default([]),
|
|
148
|
+
relation_types: z.array(KnRelationTypeDefSchema).default([]),
|
|
149
|
+
}).optional(),
|
|
150
|
+
});
|
|
151
|
+
export const SkillSetEntrySchema = z.object({ id: z.string(), version: z.string() });
|
|
152
|
+
export const KnPatchLogEntrySchema = z.object({
|
|
153
|
+
op: z.enum(["add_object_type", "add_relation_type"]),
|
|
154
|
+
concept_name: z.string(),
|
|
155
|
+
dataview_id: z.string().optional(),
|
|
156
|
+
applied_at: z.string(),
|
|
157
|
+
});
|
|
158
|
+
export const LineageEntrySchema = z.object({
|
|
159
|
+
version: z.number(),
|
|
160
|
+
agent_id: z.string(),
|
|
161
|
+
skill_set: z.array(SkillSetEntrySchema).default([]),
|
|
162
|
+
kn_patch_log: z.array(KnPatchLogEntrySchema).default([]),
|
|
163
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function warnDeprecated(commandName: string, note: string): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Print a one-line deprecation notice to stderr. No-op when the
|
|
2
|
+
// KWEAVER_NO_DEPRECATION_WARNINGS env var is set (CI / scripted callers).
|
|
3
|
+
// ANSI yellow only when stderr is a TTY, to keep piped output clean.
|
|
4
|
+
let warned = new Set();
|
|
5
|
+
// `note` is appended after a colon. Pass a "use X instead" hint when a
|
|
6
|
+
// replacement exists, or a free-form explanation (e.g. "rename pending") when
|
|
7
|
+
// the name is deprecated but no replacement is ready yet.
|
|
8
|
+
export function warnDeprecated(commandName, note) {
|
|
9
|
+
if (process.env.KWEAVER_NO_DEPRECATION_WARNINGS)
|
|
10
|
+
return;
|
|
11
|
+
if (warned.has(commandName))
|
|
12
|
+
return;
|
|
13
|
+
warned.add(commandName);
|
|
14
|
+
const useColor = process.stderr.isTTY;
|
|
15
|
+
const yellow = useColor ? "\x1b[33m" : "";
|
|
16
|
+
const reset = useColor ? "\x1b[0m" : "";
|
|
17
|
+
process.stderr.write(`${yellow}warning:${reset} '${commandName}' is deprecated: ${note}\n`);
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kweaver-ai/kweaver-sdk",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"description": "KWeaver TypeScript SDK — CLI tool and programmatic API for knowledge networks and Decision Agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"node": ">=22"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
+
"@antv/g6": "^5.1.1",
|
|
56
57
|
"@types/js-yaml": "^4.0.9",
|
|
57
58
|
"@types/node": "^24.6.0",
|
|
58
59
|
"@types/react": "^19.2.14",
|