@kweaver-ai/kweaver-sdk 0.8.1 → 0.8.3
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 +40 -52
- package/README.zh.md +41 -46
- package/dist/agent-providers/index.d.ts +7 -0
- package/dist/agent-providers/index.js +5 -0
- package/dist/agent-providers/prompt-template.d.ts +62 -0
- package/dist/agent-providers/prompt-template.js +105 -0
- package/dist/agent-providers/prompts/rubric-judge-v1.prompt.md +51 -0
- package/dist/agent-providers/prompts/within-trace-synthesizer-v1.prompt.md +60 -0
- package/dist/agent-providers/providers/claude-code-subprocess.d.ts +74 -0
- package/dist/agent-providers/providers/claude-code-subprocess.js +259 -0
- package/dist/agent-providers/providers/stub.d.ts +47 -0
- package/dist/agent-providers/providers/stub.js +77 -0
- package/dist/agent-providers/registry.d.ts +45 -0
- package/dist/agent-providers/registry.js +77 -0
- package/dist/agent-providers/types.d.ts +91 -0
- package/dist/agent-providers/types.js +25 -0
- package/dist/api/agent-chat.js +8 -6
- package/dist/api/context-loader.d.ts +1 -0
- package/dist/api/resources.d.ts +94 -0
- package/dist/api/resources.js +166 -0
- package/dist/api/semantic-search.d.ts +5 -0
- package/dist/api/semantic-search.js +5 -0
- package/dist/api/skills.d.ts +75 -2
- package/dist/api/skills.js +108 -12
- package/dist/api/trace.d.ts +5 -0
- package/dist/api/trace.js +4 -0
- package/dist/cli.js +109 -15
- package/dist/client.d.ts +3 -3
- package/dist/client.js +5 -5
- package/dist/commands/agent/mode.d.ts +6 -0
- package/dist/commands/agent/mode.js +75 -0
- package/dist/commands/agent-members.js +27 -11
- package/dist/commands/agent.js +469 -286
- package/dist/commands/auth.js +184 -71
- package/dist/commands/bkn-metric.js +37 -16
- package/dist/commands/bkn-ops.js +164 -86
- package/dist/commands/bkn-query.js +99 -31
- package/dist/commands/bkn-schema.d.ts +3 -3
- package/dist/commands/bkn-schema.js +127 -86
- package/dist/commands/bkn.js +153 -114
- package/dist/commands/call.js +23 -13
- package/dist/commands/config.js +22 -12
- package/dist/commands/context-loader.js +625 -49
- package/dist/commands/dataflow.js +14 -6
- package/dist/commands/ds.js +52 -30
- package/dist/commands/explore.js +18 -15
- package/dist/commands/model.js +53 -42
- package/dist/commands/resource.d.ts +1 -0
- package/dist/commands/{dataview.js → resource.js} +62 -84
- package/dist/commands/skill.d.ts +21 -1
- package/dist/commands/skill.js +567 -43
- package/dist/commands/token.js +11 -0
- package/dist/commands/tool.js +46 -29
- package/dist/commands/toolbox.js +31 -15
- package/dist/commands/trace.d.ts +26 -1
- package/dist/commands/trace.js +515 -15
- package/dist/commands/vega.js +466 -250
- package/dist/help/format.d.ts +65 -0
- package/dist/help/format.js +141 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +3 -3
- package/dist/resources/bkn.d.ts +5 -0
- package/dist/resources/bkn.js +5 -0
- package/dist/resources/{dataviews.d.ts → resources.d.ts} +10 -11
- package/dist/resources/{dataviews.js → resources.js} +12 -13
- package/dist/resources/skills.d.ts +17 -1
- package/dist/resources/skills.js +32 -1
- package/dist/trace-ai/diagnose/agent-binding.d.ts +67 -0
- package/dist/trace-ai/diagnose/agent-binding.js +257 -0
- package/dist/trace-ai/diagnose/builtin-rules/tool-retry-intent-mismatch.yaml +68 -0
- package/dist/trace-ai/diagnose/index.d.ts +32 -0
- package/dist/trace-ai/diagnose/index.js +246 -0
- package/dist/trace-ai/diagnose/output-schema-converter.d.ts +24 -0
- package/dist/trace-ai/diagnose/output-schema-converter.js +81 -0
- package/dist/trace-ai/diagnose/query-extractor.d.ts +14 -0
- package/dist/trace-ai/diagnose/query-extractor.js +45 -0
- package/dist/trace-ai/diagnose/report-assembler.d.ts +31 -0
- package/dist/{trace-core → trace-ai}/diagnose/report-assembler.js +19 -9
- package/dist/trace-ai/diagnose/report-markdown.d.ts +18 -0
- package/dist/trace-ai/diagnose/report-markdown.js +192 -0
- package/dist/{trace-core → trace-ai}/diagnose/rule-loader.js +42 -8
- package/dist/{trace-core → trace-ai}/diagnose/schemas.d.ts +77 -2
- package/dist/trace-ai/diagnose/schemas.js +154 -0
- package/dist/trace-ai/diagnose/signal-probe.d.ts +17 -0
- package/dist/trace-ai/diagnose/signal-probe.js +39 -0
- package/dist/trace-ai/diagnose/synthesizer-agent.d.ts +40 -0
- package/dist/trace-ai/diagnose/synthesizer-agent.js +158 -0
- package/dist/{trace-core → trace-ai}/diagnose/trace-shaper.js +1 -0
- package/dist/{trace-core → trace-ai}/diagnose/types.d.ts +55 -6
- package/dist/trace-ai/eval-set/assertion-evaluator.d.ts +29 -0
- package/dist/trace-ai/eval-set/assertion-evaluator.js +100 -0
- package/dist/trace-ai/eval-set/builder.d.ts +36 -0
- package/dist/trace-ai/eval-set/builder.js +126 -0
- package/dist/trace-ai/eval-set/index.d.ts +15 -0
- package/dist/trace-ai/eval-set/index.js +10 -0
- package/dist/trace-ai/eval-set/output-writer.d.ts +27 -0
- package/dist/trace-ai/eval-set/output-writer.js +126 -0
- package/dist/trace-ai/eval-set/query-picker.d.ts +37 -0
- package/dist/trace-ai/eval-set/query-picker.js +147 -0
- package/dist/trace-ai/eval-set/redactor.d.ts +42 -0
- package/dist/trace-ai/eval-set/redactor.js +133 -0
- package/dist/trace-ai/eval-set/rubric-templates/answer-match-reference.prompt.md +19 -0
- package/dist/trace-ai/eval-set/schemas.d.ts +136 -0
- package/dist/trace-ai/eval-set/schemas.js +130 -0
- package/dist/trace-ai/eval-set/semantic-match-provider.d.ts +33 -0
- package/dist/trace-ai/eval-set/semantic-match-provider.js +51 -0
- package/dist/trace-ai/eval-set/test-runner.d.ts +34 -0
- package/dist/trace-ai/eval-set/test-runner.js +153 -0
- package/dist/trace-ai/eval-set/types.d.ts +46 -0
- package/dist/trace-ai/eval-set/types.js +8 -0
- package/dist/trace-ai/exp/bundle-writer.d.ts +10 -0
- package/dist/trace-ai/exp/bundle-writer.js +54 -0
- package/dist/trace-ai/exp/claude-binary.d.ts +5 -0
- package/dist/trace-ai/exp/claude-binary.js +30 -0
- package/dist/trace-ai/exp/coordinator.d.ts +45 -0
- package/dist/trace-ai/exp/coordinator.js +203 -0
- package/dist/trace-ai/exp/eval-runner.d.ts +14 -0
- package/dist/trace-ai/exp/eval-runner.js +47 -0
- package/dist/trace-ai/exp/exp-store/abort-signal.d.ts +3 -0
- package/dist/trace-ai/exp/exp-store/abort-signal.js +27 -0
- package/dist/trace-ai/exp/exp-store/candidate-lineage-yaml.d.ts +4 -0
- package/dist/trace-ai/exp/exp-store/candidate-lineage-yaml.js +37 -0
- package/dist/trace-ai/exp/exp-store/events-jsonl.d.ts +17 -0
- package/dist/trace-ai/exp/exp-store/events-jsonl.js +60 -0
- package/dist/trace-ai/exp/exp-store/exp-registry.d.ts +6 -0
- package/dist/trace-ai/exp/exp-store/exp-registry.js +41 -0
- package/dist/trace-ai/exp/exp-store/index.d.ts +46 -0
- package/dist/trace-ai/exp/exp-store/index.js +59 -0
- package/dist/trace-ai/exp/exp-store/lock.d.ts +3 -0
- package/dist/trace-ai/exp/exp-store/lock.js +73 -0
- package/dist/trace-ai/exp/exp-store/mission-md.d.ts +3 -0
- package/dist/trace-ai/exp/exp-store/mission-md.js +37 -0
- package/dist/trace-ai/exp/exp-store/readme-template.d.ts +5 -0
- package/dist/trace-ai/exp/exp-store/readme-template.js +25 -0
- package/dist/trace-ai/exp/exp-store/round-yaml.d.ts +3 -0
- package/dist/trace-ai/exp/exp-store/round-yaml.js +33 -0
- package/dist/trace-ai/exp/index.d.ts +8 -0
- package/dist/trace-ai/exp/index.js +238 -0
- package/dist/trace-ai/exp/info.d.ts +35 -0
- package/dist/trace-ai/exp/info.js +120 -0
- package/dist/trace-ai/exp/patch/agent-config.d.ts +1 -0
- package/dist/trace-ai/exp/patch/agent-config.js +26 -0
- package/dist/trace-ai/exp/patch/index.d.ts +2 -0
- package/dist/trace-ai/exp/patch/index.js +13 -0
- package/dist/trace-ai/exp/patch/skill.d.ts +1 -0
- package/dist/trace-ai/exp/patch/skill.js +24 -0
- package/dist/trace-ai/exp/providers/synthesizer-client.d.ts +14 -0
- package/dist/trace-ai/exp/providers/synthesizer-client.js +39 -0
- package/dist/trace-ai/exp/providers/triage-client.d.ts +19 -0
- package/dist/trace-ai/exp/providers/triage-client.js +51 -0
- package/dist/trace-ai/exp/schemas.d.ts +147 -0
- package/dist/trace-ai/exp/schemas.js +50 -0
- package/dist/trace-ai/exp/scoring.d.ts +2 -0
- package/dist/trace-ai/exp/scoring.js +46 -0
- package/dist/trace-ai/scan/aggregator.d.ts +20 -0
- package/dist/trace-ai/scan/aggregator.js +26 -0
- package/dist/trace-ai/scan/artifacts/paths.d.ts +12 -0
- package/dist/trace-ai/scan/artifacts/paths.js +18 -0
- package/dist/trace-ai/scan/artifacts/writer.d.ts +67 -0
- package/dist/trace-ai/scan/artifacts/writer.js +96 -0
- package/dist/trace-ai/scan/batched-rubric.d.ts +55 -0
- package/dist/trace-ai/scan/batched-rubric.js +159 -0
- package/dist/trace-ai/scan/cross-trace-synthesizer.d.ts +24 -0
- package/dist/trace-ai/scan/cross-trace-synthesizer.js +93 -0
- package/dist/trace-ai/scan/index.d.ts +31 -0
- package/dist/trace-ai/scan/index.js +390 -0
- package/dist/trace-ai/scan/prompts/builtin/cross-trace-synthesizer-v1.prompt.md +44 -0
- package/dist/trace-ai/scan/prompts/builtin/rubric-judge-batch-v1.prompt.md +44 -0
- package/dist/trace-ai/scan/runner.d.ts +25 -0
- package/dist/trace-ai/scan/runner.js +42 -0
- package/dist/trace-ai/scan/sampler.d.ts +18 -0
- package/dist/trace-ai/scan/sampler.js +81 -0
- package/dist/trace-ai/scan/scan-summary-markdown.d.ts +2 -0
- package/dist/trace-ai/scan/scan-summary-markdown.js +71 -0
- package/dist/trace-ai/scan/scan-summary-schema.d.ts +73 -0
- package/dist/trace-ai/scan/scan-summary-schema.js +61 -0
- package/dist/trace-ai/scan/single-agent-validator.d.ts +23 -0
- package/dist/trace-ai/scan/single-agent-validator.js +42 -0
- package/dist/trace-ai/scan/traces-list-parser.d.ts +15 -0
- package/dist/trace-ai/scan/traces-list-parser.js +46 -0
- package/package.json +2 -2
- package/dist/api/dataviews.d.ts +0 -117
- package/dist/api/dataviews.js +0 -265
- package/dist/commands/dataview.d.ts +0 -8
- package/dist/trace-core/diagnose/index.d.ts +0 -9
- package/dist/trace-core/diagnose/index.js +0 -104
- package/dist/trace-core/diagnose/report-assembler.d.ts +0 -12
- package/dist/trace-core/diagnose/schemas.js +0 -94
- package/dist/trace-core/diagnose/signal-probe.d.ts +0 -5
- package/dist/trace-core/diagnose/signal-probe.js +0 -21
- /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/excessive-tool-calls-per-turn.d.ts +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/excessive-tool-calls-per-turn.js +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/excessive-tool-calls-per-turn.yaml +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/llm-response-truncated-no-continue.d.ts +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/llm-response-truncated-no-continue.js +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/llm-response-truncated-no-continue.yaml +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/register.d.ts +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/register.js +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/retrieval-empty-no-fallback.d.ts +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/retrieval-empty-no-fallback.js +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/retrieval-empty-no-fallback.yaml +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/tool-error-swallowed.d.ts +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/tool-error-swallowed.js +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/tool-error-swallowed.yaml +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/tool-loop-no-state-change.d.ts +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/tool-loop-no-state-change.js +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/tool-loop-no-state-change.yaml +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/predicate-registry.d.ts +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/predicate-registry.js +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/rule-loader.d.ts +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/synthesizer-template.d.ts +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/synthesizer-template.js +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/trace-shaper.d.ts +0 -0
- /package/dist/{trace-core → trace-ai}/diagnose/types.js +0 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export declare const RESOURCE_LIST_DEFAULT_LIMIT = 30;
|
|
2
|
+
/** Field metadata for a resource schema. */
|
|
3
|
+
export interface ViewField {
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
display_name?: string;
|
|
7
|
+
comment?: string;
|
|
8
|
+
}
|
|
9
|
+
/** Normalized vega-backend Resource model. */
|
|
10
|
+
export interface Resource {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
catalog_id: string;
|
|
14
|
+
category: string;
|
|
15
|
+
source_identifier?: string;
|
|
16
|
+
status?: string;
|
|
17
|
+
schema_definition?: ViewField[];
|
|
18
|
+
logic_definition?: unknown;
|
|
19
|
+
}
|
|
20
|
+
export declare function parseResource(raw: Record<string, unknown>): Resource;
|
|
21
|
+
export interface CreateResourceOptions {
|
|
22
|
+
baseUrl: string;
|
|
23
|
+
accessToken: string;
|
|
24
|
+
name: string;
|
|
25
|
+
datasourceId: string;
|
|
26
|
+
table: string;
|
|
27
|
+
fields?: Array<{
|
|
28
|
+
name: string;
|
|
29
|
+
type: string;
|
|
30
|
+
}>;
|
|
31
|
+
businessDomain?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare function createResource(options: CreateResourceOptions): Promise<string>;
|
|
34
|
+
export interface ListResourcesOptions {
|
|
35
|
+
baseUrl: string;
|
|
36
|
+
accessToken: string;
|
|
37
|
+
businessDomain?: string;
|
|
38
|
+
/** Filter by catalog (data source) id. */
|
|
39
|
+
datasourceId?: string;
|
|
40
|
+
/** Server-side name filter. */
|
|
41
|
+
name?: string;
|
|
42
|
+
/** Category filter (e.g. "table", "logicview"). */
|
|
43
|
+
category?: string;
|
|
44
|
+
/** Max items; ignored when <= 0. */
|
|
45
|
+
limit?: number;
|
|
46
|
+
}
|
|
47
|
+
export declare function listResources(options: ListResourcesOptions): Promise<Resource[]>;
|
|
48
|
+
export interface DeleteResourceOptions {
|
|
49
|
+
baseUrl: string;
|
|
50
|
+
accessToken: string;
|
|
51
|
+
id: string;
|
|
52
|
+
businessDomain?: string;
|
|
53
|
+
}
|
|
54
|
+
export declare function deleteResource(options: DeleteResourceOptions): Promise<void>;
|
|
55
|
+
export interface GetResourceOptions {
|
|
56
|
+
baseUrl: string;
|
|
57
|
+
accessToken: string;
|
|
58
|
+
id: string;
|
|
59
|
+
businessDomain?: string;
|
|
60
|
+
}
|
|
61
|
+
export declare function getResource(options: GetResourceOptions): Promise<Resource>;
|
|
62
|
+
export interface FindResourceOptions {
|
|
63
|
+
baseUrl: string;
|
|
64
|
+
accessToken: string;
|
|
65
|
+
businessDomain?: string;
|
|
66
|
+
/** Resource name to search for. */
|
|
67
|
+
name: string;
|
|
68
|
+
/** Filter by catalog (data source) id. */
|
|
69
|
+
datasourceId?: string;
|
|
70
|
+
/** When true, apply client-side exact name match after server filter (default false). */
|
|
71
|
+
exact?: boolean;
|
|
72
|
+
/** When true, poll until a result appears or timeout (default false). */
|
|
73
|
+
wait?: boolean;
|
|
74
|
+
/** Total wait budget in ms (default 30000). Only used when wait is true. */
|
|
75
|
+
timeoutMs?: number;
|
|
76
|
+
}
|
|
77
|
+
export declare function findResource(options: FindResourceOptions): Promise<Resource[]>;
|
|
78
|
+
export interface QueryResourceOptions {
|
|
79
|
+
baseUrl: string;
|
|
80
|
+
accessToken: string;
|
|
81
|
+
id: string;
|
|
82
|
+
offset?: number;
|
|
83
|
+
limit?: number;
|
|
84
|
+
needTotal?: boolean;
|
|
85
|
+
filterCondition?: unknown;
|
|
86
|
+
sort?: string;
|
|
87
|
+
direction?: "asc" | "desc";
|
|
88
|
+
businessDomain?: string;
|
|
89
|
+
}
|
|
90
|
+
export interface ResourceQueryResult {
|
|
91
|
+
entries?: unknown;
|
|
92
|
+
total_count?: number;
|
|
93
|
+
}
|
|
94
|
+
export declare function queryResource(options: QueryResourceOptions): Promise<ResourceQueryResult>;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { HttpError } from "../utils/http.js";
|
|
2
|
+
import { buildHeaders } from "./headers.js";
|
|
3
|
+
export const RESOURCE_LIST_DEFAULT_LIMIT = 30;
|
|
4
|
+
export function parseResource(raw) {
|
|
5
|
+
const res = {
|
|
6
|
+
id: String(raw.id ?? ""),
|
|
7
|
+
name: String(raw.name ?? ""),
|
|
8
|
+
catalog_id: String(raw.catalog_id ?? ""),
|
|
9
|
+
category: String(raw.category ?? ""),
|
|
10
|
+
};
|
|
11
|
+
if (raw.source_identifier != null)
|
|
12
|
+
res.source_identifier = String(raw.source_identifier);
|
|
13
|
+
if (raw.status != null)
|
|
14
|
+
res.status = String(raw.status);
|
|
15
|
+
if (Array.isArray(raw.schema_definition) && raw.schema_definition.length > 0) {
|
|
16
|
+
res.schema_definition = raw.schema_definition.map((f) => ({
|
|
17
|
+
name: String(f.name ?? ""),
|
|
18
|
+
type: String(f.type ?? "varchar"),
|
|
19
|
+
display_name: f.display_name != null ? String(f.display_name) : undefined,
|
|
20
|
+
comment: f.comment != null ? String(f.comment) : undefined,
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
if (raw.logic_definition !== undefined)
|
|
24
|
+
res.logic_definition = raw.logic_definition;
|
|
25
|
+
return res;
|
|
26
|
+
}
|
|
27
|
+
function extractListPayload(data) {
|
|
28
|
+
if (Array.isArray(data))
|
|
29
|
+
return data;
|
|
30
|
+
if (data && typeof data === "object") {
|
|
31
|
+
const obj = data;
|
|
32
|
+
const items = obj.entries ?? obj.data;
|
|
33
|
+
if (Array.isArray(items))
|
|
34
|
+
return items;
|
|
35
|
+
}
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
export async function createResource(options) {
|
|
39
|
+
const { baseUrl, accessToken, name, datasourceId, table, fields = [], businessDomain = "bd_public", } = options;
|
|
40
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
41
|
+
const url = `${base}/api/vega-backend/v1/resources`;
|
|
42
|
+
const body = {
|
|
43
|
+
name,
|
|
44
|
+
catalog_id: datasourceId,
|
|
45
|
+
category: "table",
|
|
46
|
+
source_identifier: table,
|
|
47
|
+
};
|
|
48
|
+
if (fields.length > 0)
|
|
49
|
+
body.schema_definition = fields;
|
|
50
|
+
const response = await fetch(url, {
|
|
51
|
+
method: "POST",
|
|
52
|
+
headers: {
|
|
53
|
+
...buildHeaders(accessToken, businessDomain),
|
|
54
|
+
"content-type": "application/json",
|
|
55
|
+
},
|
|
56
|
+
body: JSON.stringify(body),
|
|
57
|
+
});
|
|
58
|
+
const responseBody = await response.text();
|
|
59
|
+
if (!response.ok) {
|
|
60
|
+
throw new HttpError(response.status, response.statusText, responseBody);
|
|
61
|
+
}
|
|
62
|
+
const data = JSON.parse(responseBody);
|
|
63
|
+
return String(data.id ?? "");
|
|
64
|
+
}
|
|
65
|
+
export async function listResources(options) {
|
|
66
|
+
const { baseUrl, accessToken, businessDomain = "bd_public", datasourceId, name, category, limit = RESOURCE_LIST_DEFAULT_LIMIT, } = options;
|
|
67
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
68
|
+
const url = new URL(`${base}/api/vega-backend/v1/resources`);
|
|
69
|
+
if (datasourceId)
|
|
70
|
+
url.searchParams.set("catalog_id", datasourceId);
|
|
71
|
+
if (name)
|
|
72
|
+
url.searchParams.set("name", name);
|
|
73
|
+
if (category)
|
|
74
|
+
url.searchParams.set("category", category);
|
|
75
|
+
if (limit && limit > 0)
|
|
76
|
+
url.searchParams.set("limit", String(limit));
|
|
77
|
+
const response = await fetch(url.toString(), {
|
|
78
|
+
method: "GET",
|
|
79
|
+
headers: buildHeaders(accessToken, businessDomain),
|
|
80
|
+
});
|
|
81
|
+
const bodyText = await response.text();
|
|
82
|
+
if (!response.ok)
|
|
83
|
+
throw new HttpError(response.status, response.statusText, bodyText);
|
|
84
|
+
const parsed = JSON.parse(bodyText);
|
|
85
|
+
const items = extractListPayload(parsed);
|
|
86
|
+
return items
|
|
87
|
+
.filter((item) => item != null && typeof item === "object")
|
|
88
|
+
.map(parseResource);
|
|
89
|
+
}
|
|
90
|
+
export async function deleteResource(options) {
|
|
91
|
+
const { baseUrl, accessToken, id, businessDomain = "bd_public" } = options;
|
|
92
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
93
|
+
const url = `${base}/api/vega-backend/v1/resources/${encodeURIComponent(id)}`;
|
|
94
|
+
const response = await fetch(url, {
|
|
95
|
+
method: "DELETE",
|
|
96
|
+
headers: buildHeaders(accessToken, businessDomain),
|
|
97
|
+
});
|
|
98
|
+
const bodyText = await response.text();
|
|
99
|
+
if (!response.ok)
|
|
100
|
+
throw new HttpError(response.status, response.statusText, bodyText);
|
|
101
|
+
}
|
|
102
|
+
export async function getResource(options) {
|
|
103
|
+
const { baseUrl, accessToken, id, businessDomain = "bd_public" } = options;
|
|
104
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
105
|
+
const url = `${base}/api/vega-backend/v1/resources/${encodeURIComponent(id)}`;
|
|
106
|
+
const response = await fetch(url, {
|
|
107
|
+
method: "GET",
|
|
108
|
+
headers: buildHeaders(accessToken, businessDomain),
|
|
109
|
+
});
|
|
110
|
+
const body = await response.text();
|
|
111
|
+
if (!response.ok)
|
|
112
|
+
throw new HttpError(response.status, response.statusText, body);
|
|
113
|
+
const parsed = JSON.parse(body);
|
|
114
|
+
// vega-backend GET /:id returns { entries: [...] } (supports comma-separated ids)
|
|
115
|
+
const items = extractListPayload(parsed);
|
|
116
|
+
const raw = items.length > 0 ? items[0] : (parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null);
|
|
117
|
+
if (!raw || typeof raw !== "object")
|
|
118
|
+
throw new HttpError(500, "Invalid response", body);
|
|
119
|
+
return parseResource(raw);
|
|
120
|
+
}
|
|
121
|
+
function sleepMs(ms) {
|
|
122
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
123
|
+
}
|
|
124
|
+
export async function findResource(options) {
|
|
125
|
+
const { baseUrl, accessToken, businessDomain = "bd_public", name, datasourceId, exact = false, wait = false, timeoutMs = 30_000, } = options;
|
|
126
|
+
const deadline = Date.now() + timeoutMs;
|
|
127
|
+
let attempt = 0;
|
|
128
|
+
while (true) {
|
|
129
|
+
const list = await listResources({ baseUrl, accessToken, businessDomain, datasourceId, name });
|
|
130
|
+
const results = exact ? list.filter((v) => v.name === name) : list;
|
|
131
|
+
if (results.length > 0 || !wait || Date.now() >= deadline)
|
|
132
|
+
return results;
|
|
133
|
+
const delayMs = Math.min(5000, 1000 * 2 ** attempt);
|
|
134
|
+
attempt += 1;
|
|
135
|
+
await sleepMs(delayMs);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
export async function queryResource(options) {
|
|
139
|
+
const { baseUrl, accessToken, id, offset = 0, limit = 50, needTotal = false, filterCondition, sort, direction, businessDomain = "bd_public", } = options;
|
|
140
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
141
|
+
const url = `${base}/api/vega-backend/v1/resources/${encodeURIComponent(id)}/data`;
|
|
142
|
+
const body = { offset, limit, need_total: needTotal };
|
|
143
|
+
if (filterCondition !== undefined)
|
|
144
|
+
body.filter_condition = filterCondition;
|
|
145
|
+
if (sort !== undefined)
|
|
146
|
+
body.sort = sort;
|
|
147
|
+
if (direction !== undefined)
|
|
148
|
+
body.direction = direction;
|
|
149
|
+
const response = await fetch(url, {
|
|
150
|
+
method: "POST",
|
|
151
|
+
headers: {
|
|
152
|
+
...buildHeaders(accessToken, businessDomain),
|
|
153
|
+
"content-type": "application/json",
|
|
154
|
+
"x-http-method-override": "GET",
|
|
155
|
+
},
|
|
156
|
+
body: JSON.stringify(body),
|
|
157
|
+
});
|
|
158
|
+
const bodyText = await response.text();
|
|
159
|
+
if (!response.ok)
|
|
160
|
+
throw new HttpError(response.status, response.statusText, bodyText);
|
|
161
|
+
const parsed = JSON.parse(bodyText);
|
|
162
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
163
|
+
return parsed;
|
|
164
|
+
}
|
|
165
|
+
return {};
|
|
166
|
+
}
|
|
@@ -18,4 +18,9 @@ export interface KnSearchHttpOptions {
|
|
|
18
18
|
businessDomain?: string;
|
|
19
19
|
onlySchema?: boolean;
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated Use Context Loader `search_schema` for new schema discovery integrations.
|
|
23
|
+
* The HTTP `kn_search` endpoint is kept only as a compatibility entry point
|
|
24
|
+
* and may not receive new `search_schema` capabilities.
|
|
25
|
+
*/
|
|
21
26
|
export declare function knSearchHttp(options: KnSearchHttpOptions): Promise<string>;
|
|
@@ -22,6 +22,11 @@ export async function semanticSearch(options) {
|
|
|
22
22
|
}
|
|
23
23
|
return body;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated Use Context Loader `search_schema` for new schema discovery integrations.
|
|
27
|
+
* The HTTP `kn_search` endpoint is kept only as a compatibility entry point
|
|
28
|
+
* and may not receive new `search_schema` capabilities.
|
|
29
|
+
*/
|
|
25
30
|
export async function knSearchHttp(options) {
|
|
26
31
|
const { baseUrl, accessToken, knId, query, businessDomain = "bd_public", onlySchema = false, } = options;
|
|
27
32
|
const base = baseUrl.replace(/\/+$/, "");
|
package/dist/api/skills.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export type SkillStatus = "unpublish" | "published" | "offline";
|
|
2
2
|
export type SkillFileType = "zip" | "content";
|
|
3
|
+
export type SkillEditableStatus = SkillStatus | "editing";
|
|
4
|
+
export type SkillCategory = "other_category" | "system";
|
|
3
5
|
export interface SkillSummary {
|
|
4
6
|
id: string;
|
|
5
7
|
name: string;
|
|
6
8
|
description?: string;
|
|
7
9
|
version?: string;
|
|
8
|
-
status?:
|
|
10
|
+
status?: SkillEditableStatus;
|
|
9
11
|
source?: string;
|
|
10
12
|
create_user?: string;
|
|
11
13
|
create_time?: number;
|
|
@@ -29,7 +31,7 @@ export interface SkillContentIndex {
|
|
|
29
31
|
id: string;
|
|
30
32
|
url: string;
|
|
31
33
|
files: SkillFileSummary[];
|
|
32
|
-
status?:
|
|
34
|
+
status?: SkillEditableStatus;
|
|
33
35
|
}
|
|
34
36
|
export interface SkillFileReadResult {
|
|
35
37
|
id: string;
|
|
@@ -54,6 +56,22 @@ export interface UpdateSkillStatusResult {
|
|
|
54
56
|
id: string;
|
|
55
57
|
status: SkillStatus;
|
|
56
58
|
}
|
|
59
|
+
export interface UpdateSkillMetadataResult {
|
|
60
|
+
id: string;
|
|
61
|
+
version?: string;
|
|
62
|
+
status?: SkillEditableStatus;
|
|
63
|
+
}
|
|
64
|
+
export interface UpdateSkillPackageResult {
|
|
65
|
+
id: string;
|
|
66
|
+
version?: string;
|
|
67
|
+
status?: SkillEditableStatus;
|
|
68
|
+
}
|
|
69
|
+
export interface SkillReleaseHistoryInfo extends SkillSummary {
|
|
70
|
+
category?: SkillCategory;
|
|
71
|
+
release_desc?: string;
|
|
72
|
+
release_user?: string;
|
|
73
|
+
release_time?: number;
|
|
74
|
+
}
|
|
57
75
|
export interface SkillListResult {
|
|
58
76
|
total_count?: number;
|
|
59
77
|
total?: number;
|
|
@@ -104,6 +122,23 @@ export interface RegisterSkillZipOptions extends SkillApiBaseOptions {
|
|
|
104
122
|
source?: string;
|
|
105
123
|
extendInfo?: Record<string, unknown>;
|
|
106
124
|
}
|
|
125
|
+
export interface UpdateSkillMetadataOptions extends SkillApiBaseOptions {
|
|
126
|
+
skillId: string;
|
|
127
|
+
name: string;
|
|
128
|
+
description: string;
|
|
129
|
+
category: SkillCategory;
|
|
130
|
+
source?: string;
|
|
131
|
+
extendInfo?: Record<string, unknown>;
|
|
132
|
+
}
|
|
133
|
+
export interface UpdateSkillPackageContentOptions extends SkillApiBaseOptions {
|
|
134
|
+
skillId: string;
|
|
135
|
+
content: string;
|
|
136
|
+
}
|
|
137
|
+
export interface UpdateSkillPackageZipOptions extends SkillApiBaseOptions {
|
|
138
|
+
skillId: string;
|
|
139
|
+
filename: string;
|
|
140
|
+
bytes: Uint8Array;
|
|
141
|
+
}
|
|
107
142
|
export interface UpdateSkillStatusOptions extends SkillApiBaseOptions {
|
|
108
143
|
skillId: string;
|
|
109
144
|
status: SkillStatus;
|
|
@@ -119,23 +154,61 @@ export interface DownloadedSkillArchive {
|
|
|
119
154
|
fileName: string;
|
|
120
155
|
bytes: Uint8Array;
|
|
121
156
|
}
|
|
157
|
+
export interface SkillHistoryVersionOptions extends SkillApiBaseOptions {
|
|
158
|
+
skillId: string;
|
|
159
|
+
version: string;
|
|
160
|
+
}
|
|
122
161
|
export interface InstallSkillArchiveOptions {
|
|
123
162
|
bytes: Uint8Array;
|
|
124
163
|
directory: string;
|
|
125
164
|
force?: boolean;
|
|
126
165
|
}
|
|
166
|
+
export interface SkillManagementContentData {
|
|
167
|
+
skill_id: string;
|
|
168
|
+
name: string;
|
|
169
|
+
description: string;
|
|
170
|
+
version: string;
|
|
171
|
+
status: SkillEditableStatus;
|
|
172
|
+
source: string;
|
|
173
|
+
file_type: "zip" | "content";
|
|
174
|
+
url?: string;
|
|
175
|
+
content?: string;
|
|
176
|
+
files: SkillFileSummary[];
|
|
177
|
+
}
|
|
178
|
+
export interface GetSkillManagementContentOptions extends SkillApiBaseOptions {
|
|
179
|
+
skillId: string;
|
|
180
|
+
responseMode?: "url" | "content";
|
|
181
|
+
}
|
|
182
|
+
export interface ReadSkillManagementFileOptions extends SkillApiBaseOptions {
|
|
183
|
+
skillId: string;
|
|
184
|
+
relPath: string;
|
|
185
|
+
}
|
|
186
|
+
export interface DownloadSkillManagementOptions extends SkillApiBaseOptions {
|
|
187
|
+
skillId: string;
|
|
188
|
+
responseMode?: "url" | "content";
|
|
189
|
+
}
|
|
127
190
|
export declare function listSkills(options: ListSkillsOptions): Promise<SkillListResult>;
|
|
128
191
|
export declare function listSkillMarket(options: ListSkillMarketOptions): Promise<SkillListResult>;
|
|
129
192
|
export declare function getSkill(options: GetSkillOptions): Promise<SkillInfo>;
|
|
193
|
+
export declare function getSkillMarketDetail(options: GetSkillOptions): Promise<SkillInfo>;
|
|
130
194
|
export declare function deleteSkill(options: GetSkillOptions): Promise<DeleteSkillResult>;
|
|
131
195
|
export declare function updateSkillStatus(options: UpdateSkillStatusOptions): Promise<UpdateSkillStatusResult>;
|
|
196
|
+
export declare function updateSkillMetadata(options: UpdateSkillMetadataOptions): Promise<UpdateSkillMetadataResult>;
|
|
132
197
|
export declare function registerSkillContent(options: RegisterSkillContentOptions): Promise<RegisterSkillResult>;
|
|
133
198
|
export declare function registerSkillZip(options: RegisterSkillZipOptions): Promise<RegisterSkillResult>;
|
|
199
|
+
export declare function updateSkillPackageContent(options: UpdateSkillPackageContentOptions): Promise<UpdateSkillPackageResult>;
|
|
200
|
+
export declare function updateSkillPackageZip(options: UpdateSkillPackageZipOptions): Promise<UpdateSkillPackageResult>;
|
|
134
201
|
export declare function getSkillContentIndex(options: GetSkillOptions): Promise<SkillContentIndex>;
|
|
135
202
|
export declare function fetchSkillContent(options: GetSkillOptions): Promise<string>;
|
|
136
203
|
export declare function readSkillFile(options: ReadSkillFileOptions): Promise<SkillFileReadResult>;
|
|
137
204
|
export declare function fetchSkillFile(options: ReadSkillFileOptions): Promise<Uint8Array>;
|
|
138
205
|
export declare function downloadSkill(options: DownloadSkillOptions): Promise<DownloadedSkillArchive>;
|
|
206
|
+
export declare function listSkillHistory(options: GetSkillOptions): Promise<SkillReleaseHistoryInfo[]>;
|
|
207
|
+
export declare function republishSkillHistory(options: SkillHistoryVersionOptions): Promise<UpdateSkillPackageResult>;
|
|
208
|
+
export declare function publishSkillHistory(options: SkillHistoryVersionOptions): Promise<UpdateSkillPackageResult>;
|
|
209
|
+
export declare function getSkillManagementContent(options: GetSkillManagementContentOptions): Promise<SkillManagementContentData>;
|
|
210
|
+
export declare function readSkillManagementFile(options: ReadSkillManagementFileOptions): Promise<SkillFileReadResult>;
|
|
211
|
+
export declare function downloadSkillManagementArchive(options: DownloadSkillManagementOptions): Promise<DownloadedSkillArchive>;
|
|
139
212
|
export declare function installSkillArchive(options: InstallSkillArchiveOptions): {
|
|
140
213
|
directory: string;
|
|
141
214
|
};
|
package/dist/api/skills.js
CHANGED
|
@@ -87,6 +87,11 @@ export async function getSkill(options) {
|
|
|
87
87
|
const { body } = await fetchTextOrThrow(url, { headers: baseHeaders(options) });
|
|
88
88
|
return normalizeSkillId(unwrapEnvelope(body));
|
|
89
89
|
}
|
|
90
|
+
export async function getSkillMarketDetail(options) {
|
|
91
|
+
const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/market/${encodeURIComponent(options.skillId)}`);
|
|
92
|
+
const { body } = await fetchTextOrThrow(url, { headers: baseHeaders(options) });
|
|
93
|
+
return normalizeSkillId(unwrapEnvelope(body));
|
|
94
|
+
}
|
|
90
95
|
export async function deleteSkill(options) {
|
|
91
96
|
const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}`);
|
|
92
97
|
const { body } = await fetchTextOrThrow(url, { method: "DELETE", headers: baseHeaders(options) });
|
|
@@ -101,14 +106,49 @@ export async function updateSkillStatus(options) {
|
|
|
101
106
|
});
|
|
102
107
|
return normalizeSkillId(unwrapEnvelope(body));
|
|
103
108
|
}
|
|
109
|
+
export async function updateSkillMetadata(options) {
|
|
110
|
+
const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}/metadata`);
|
|
111
|
+
const payload = {
|
|
112
|
+
name: options.name,
|
|
113
|
+
description: options.description,
|
|
114
|
+
category: options.category,
|
|
115
|
+
};
|
|
116
|
+
if (options.source)
|
|
117
|
+
payload.source = options.source;
|
|
118
|
+
if (options.extendInfo)
|
|
119
|
+
payload.extend_info = options.extendInfo;
|
|
120
|
+
const { body } = await fetchTextOrThrow(url, {
|
|
121
|
+
method: "PUT",
|
|
122
|
+
headers: { ...baseHeaders(options), "content-type": "application/json" },
|
|
123
|
+
body: JSON.stringify(payload),
|
|
124
|
+
});
|
|
125
|
+
return normalizeSkillId(unwrapEnvelope(body));
|
|
126
|
+
}
|
|
104
127
|
export async function registerSkillContent(options) {
|
|
128
|
+
// Backend's file_type=content path is half-implemented: it stores
|
|
129
|
+
// the markdown body but skips skill_file_index, so the skill is
|
|
130
|
+
// unreadable after publish (GET /skills/:id/content -> 404).
|
|
131
|
+
// Bundle the content into a 1-file SKILL.md zip and route through
|
|
132
|
+
// the zip path, which writes skill_file_index correctly.
|
|
133
|
+
const { default: JSZip } = await import("jszip");
|
|
134
|
+
const zip = new JSZip();
|
|
135
|
+
zip.file("SKILL.md", options.content);
|
|
136
|
+
const bytes = new Uint8Array(await zip.generateAsync({ type: "uint8array", compression: "DEFLATE" }));
|
|
137
|
+
return registerSkillZip({
|
|
138
|
+
baseUrl: options.baseUrl,
|
|
139
|
+
accessToken: options.accessToken,
|
|
140
|
+
businessDomain: options.businessDomain,
|
|
141
|
+
filename: "SKILL.md.zip",
|
|
142
|
+
bytes,
|
|
143
|
+
source: options.source,
|
|
144
|
+
extendInfo: options.extendInfo,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
export async function registerSkillZip(options) {
|
|
105
148
|
const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills`);
|
|
106
149
|
const form = new FormData();
|
|
107
|
-
form.set("file_type", "
|
|
108
|
-
|
|
109
|
-
// (typed json.RawMessage); needs an actual multipart file part with
|
|
110
|
-
// filename. See utils/gin.go GetBindMultipartFormRaw.
|
|
111
|
-
form.set("file", new Blob([options.content], { type: "text/markdown" }), "SKILL.md");
|
|
150
|
+
form.set("file_type", "zip");
|
|
151
|
+
form.set("file", new Blob([Buffer.from(options.bytes)]), options.filename);
|
|
112
152
|
if (options.source)
|
|
113
153
|
form.set("source", options.source);
|
|
114
154
|
if (options.extendInfo)
|
|
@@ -120,17 +160,22 @@ export async function registerSkillContent(options) {
|
|
|
120
160
|
});
|
|
121
161
|
return normalizeSkillId(unwrapEnvelope(body));
|
|
122
162
|
}
|
|
123
|
-
export async function
|
|
124
|
-
const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills`);
|
|
163
|
+
export async function updateSkillPackageContent(options) {
|
|
164
|
+
const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}/package`);
|
|
165
|
+
const { body } = await fetchTextOrThrow(url, {
|
|
166
|
+
method: "PUT",
|
|
167
|
+
headers: { ...baseHeaders(options), "content-type": "application/json" },
|
|
168
|
+
body: JSON.stringify({ file_type: "content", file: options.content }),
|
|
169
|
+
});
|
|
170
|
+
return normalizeSkillId(unwrapEnvelope(body));
|
|
171
|
+
}
|
|
172
|
+
export async function updateSkillPackageZip(options) {
|
|
173
|
+
const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}/package`);
|
|
125
174
|
const form = new FormData();
|
|
126
175
|
form.set("file_type", "zip");
|
|
127
176
|
form.set("file", new Blob([Buffer.from(options.bytes)]), options.filename);
|
|
128
|
-
if (options.source)
|
|
129
|
-
form.set("source", options.source);
|
|
130
|
-
if (options.extendInfo)
|
|
131
|
-
form.set("extend_info", JSON.stringify(options.extendInfo));
|
|
132
177
|
const { body } = await fetchTextOrThrow(url, {
|
|
133
|
-
method: "
|
|
178
|
+
method: "PUT",
|
|
134
179
|
headers: baseHeaders(options),
|
|
135
180
|
body: form,
|
|
136
181
|
});
|
|
@@ -169,6 +214,57 @@ export async function downloadSkill(options) {
|
|
|
169
214
|
bytes: body,
|
|
170
215
|
};
|
|
171
216
|
}
|
|
217
|
+
export async function listSkillHistory(options) {
|
|
218
|
+
const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}/history`);
|
|
219
|
+
const { body } = await fetchTextOrThrow(url, { headers: baseHeaders(options) });
|
|
220
|
+
return normalizeSkillId(unwrapEnvelope(body));
|
|
221
|
+
}
|
|
222
|
+
export async function republishSkillHistory(options) {
|
|
223
|
+
const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}/history/republish`);
|
|
224
|
+
const { body } = await fetchTextOrThrow(url, {
|
|
225
|
+
method: "POST",
|
|
226
|
+
headers: { ...baseHeaders(options), "content-type": "application/json" },
|
|
227
|
+
body: JSON.stringify({ version: options.version }),
|
|
228
|
+
});
|
|
229
|
+
return normalizeSkillId(unwrapEnvelope(body));
|
|
230
|
+
}
|
|
231
|
+
export async function publishSkillHistory(options) {
|
|
232
|
+
const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}/history/publish`);
|
|
233
|
+
const { body } = await fetchTextOrThrow(url, {
|
|
234
|
+
method: "POST",
|
|
235
|
+
headers: { ...baseHeaders(options), "content-type": "application/json" },
|
|
236
|
+
body: JSON.stringify({ version: options.version }),
|
|
237
|
+
});
|
|
238
|
+
return normalizeSkillId(unwrapEnvelope(body));
|
|
239
|
+
}
|
|
240
|
+
// ── Management Content (editing-state) API ───────────────────────────────────
|
|
241
|
+
export async function getSkillManagementContent(options) {
|
|
242
|
+
const url = new URL(buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}/management/content`));
|
|
243
|
+
if (options.responseMode)
|
|
244
|
+
url.searchParams.set("response_mode", options.responseMode);
|
|
245
|
+
const { body } = await fetchTextOrThrow(url, { headers: baseHeaders(options) });
|
|
246
|
+
return unwrapEnvelope(body);
|
|
247
|
+
}
|
|
248
|
+
export async function readSkillManagementFile(options) {
|
|
249
|
+
const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}/management/files/read`);
|
|
250
|
+
const { body } = await fetchTextOrThrow(url, {
|
|
251
|
+
method: "POST",
|
|
252
|
+
headers: { ...baseHeaders(options), "content-type": "application/json" },
|
|
253
|
+
body: JSON.stringify({ rel_path: options.relPath }),
|
|
254
|
+
});
|
|
255
|
+
return normalizeSkillId(unwrapEnvelope(body));
|
|
256
|
+
}
|
|
257
|
+
export async function downloadSkillManagementArchive(options) {
|
|
258
|
+
const url = new URL(buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}/management/download`));
|
|
259
|
+
if (options.responseMode)
|
|
260
|
+
url.searchParams.set("response_mode", options.responseMode);
|
|
261
|
+
const { response, body } = await fetchBytesOrThrow(url, { headers: baseHeaders(options) });
|
|
262
|
+
const serverName = parseContentDisposition(response.headers.get("content-disposition"));
|
|
263
|
+
return {
|
|
264
|
+
fileName: basename(serverName || `${options.skillId}.zip`),
|
|
265
|
+
bytes: body,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
172
268
|
export function installSkillArchive(options) {
|
|
173
269
|
const targetDir = resolve(options.directory);
|
|
174
270
|
const existed = existsSync(targetDir);
|
package/dist/api/trace.d.ts
CHANGED
|
@@ -25,6 +25,11 @@ export interface RawSpan {
|
|
|
25
25
|
code?: string;
|
|
26
26
|
};
|
|
27
27
|
attributes?: Record<string, unknown>;
|
|
28
|
+
events?: Array<{
|
|
29
|
+
name?: string;
|
|
30
|
+
time?: string;
|
|
31
|
+
attributes?: Record<string, unknown>;
|
|
32
|
+
}>;
|
|
28
33
|
/** OTel traceId for the trace this span belongs to (when known). */
|
|
29
34
|
traceId?: string;
|
|
30
35
|
}
|
package/dist/api/trace.js
CHANGED
|
@@ -48,6 +48,9 @@ function normalizeToRawSpan(source) {
|
|
|
48
48
|
endTimeUnixNano = isoToNanos(source.endTime);
|
|
49
49
|
const status = source.status;
|
|
50
50
|
const attributes = source.attributes;
|
|
51
|
+
const events = Array.isArray(source.events)
|
|
52
|
+
? source.events
|
|
53
|
+
: undefined;
|
|
51
54
|
const name = typeof source.name === "string" ? source.name : undefined;
|
|
52
55
|
const traceIdRaw = source.traceId ?? source.trace_id;
|
|
53
56
|
const traceId = typeof traceIdRaw === "string" ? traceIdRaw : undefined;
|
|
@@ -59,6 +62,7 @@ function normalizeToRawSpan(source) {
|
|
|
59
62
|
endTimeUnixNano,
|
|
60
63
|
status,
|
|
61
64
|
attributes,
|
|
65
|
+
events,
|
|
62
66
|
traceId,
|
|
63
67
|
};
|
|
64
68
|
}
|