@duckcodeailabs/dql-cli 1.0.4 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/args.d.ts +1 -0
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +4 -0
- package/dist/args.js.map +1 -1
- package/dist/assets/dql-notebook/assets/index-Cscl1A2H.js +628 -0
- package/dist/assets/dql-notebook/index.html +1 -1
- package/dist/commands/app.d.ts +3 -0
- package/dist/commands/app.d.ts.map +1 -0
- package/dist/commands/app.js +191 -0
- package/dist/commands/app.js.map +1 -0
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +30 -2
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/fmt.d.ts.map +1 -1
- package/dist/commands/fmt.js +26 -9
- package/dist/commands/fmt.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +1 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/mcp.d.ts +7 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +16 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/schedule.d.ts +3 -0
- package/dist/commands/schedule.d.ts.map +1 -0
- package/dist/commands/schedule.js +132 -0
- package/dist/commands/schedule.js.map +1 -0
- package/dist/digest.d.ts +10 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +83 -0
- package/dist/digest.js.map +1 -0
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -1
- package/dist/llm/claude-agent-sdk.d.ts +3 -0
- package/dist/llm/claude-agent-sdk.d.ts.map +1 -0
- package/dist/llm/claude-agent-sdk.js +174 -0
- package/dist/llm/claude-agent-sdk.js.map +1 -0
- package/dist/llm/claude-code.d.ts +8 -0
- package/dist/llm/claude-code.d.ts.map +1 -0
- package/dist/llm/claude-code.js +171 -0
- package/dist/llm/claude-code.js.map +1 -0
- package/dist/llm/index.d.ts +4 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +10 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/tools.d.ts +9 -0
- package/dist/llm/tools.d.ts.map +1 -0
- package/dist/llm/tools.js +112 -0
- package/dist/llm/tools.js.map +1 -0
- package/dist/llm/types.d.ts +64 -0
- package/dist/llm/types.d.ts.map +1 -0
- package/dist/llm/types.js +2 -0
- package/dist/llm/types.js.map +1 -0
- package/dist/local-runtime.d.ts +6 -0
- package/dist/local-runtime.d.ts.map +1 -1
- package/dist/local-runtime.js +69 -1
- package/dist/local-runtime.js.map +1 -1
- package/dist/schedule/alerts.d.ts +5 -0
- package/dist/schedule/alerts.d.ts.map +1 -0
- package/dist/schedule/alerts.js +54 -0
- package/dist/schedule/alerts.js.map +1 -0
- package/dist/schedule/discovery.d.ts +4 -0
- package/dist/schedule/discovery.d.ts.map +1 -0
- package/dist/schedule/discovery.js +36 -0
- package/dist/schedule/discovery.js.map +1 -0
- package/dist/schedule/notifiers/email.d.ts +3 -0
- package/dist/schedule/notifiers/email.d.ts.map +1 -0
- package/dist/schedule/notifiers/email.js +76 -0
- package/dist/schedule/notifiers/email.js.map +1 -0
- package/dist/schedule/notifiers/file.d.ts +3 -0
- package/dist/schedule/notifiers/file.d.ts.map +1 -0
- package/dist/schedule/notifiers/file.js +50 -0
- package/dist/schedule/notifiers/file.js.map +1 -0
- package/dist/schedule/notifiers/index.d.ts +10 -0
- package/dist/schedule/notifiers/index.d.ts.map +1 -0
- package/dist/schedule/notifiers/index.js +33 -0
- package/dist/schedule/notifiers/index.js.map +1 -0
- package/dist/schedule/notifiers/slack.d.ts +3 -0
- package/dist/schedule/notifiers/slack.d.ts.map +1 -0
- package/dist/schedule/notifiers/slack.js +58 -0
- package/dist/schedule/notifiers/slack.js.map +1 -0
- package/dist/schedule/runner.d.ts +11 -0
- package/dist/schedule/runner.d.ts.map +1 -0
- package/dist/schedule/runner.js +109 -0
- package/dist/schedule/runner.js.map +1 -0
- package/dist/schedule/runs.d.ts +5 -0
- package/dist/schedule/runs.d.ts.map +1 -0
- package/dist/schedule/runs.js +40 -0
- package/dist/schedule/runs.js.map +1 -0
- package/dist/schedule/service.d.ts +12 -0
- package/dist/schedule/service.d.ts.map +1 -0
- package/dist/schedule/service.js +49 -0
- package/dist/schedule/service.js.map +1 -0
- package/dist/schedule/types.d.ts +64 -0
- package/dist/schedule/types.d.ts.map +1 -0
- package/dist/schedule/types.js +2 -0
- package/dist/schedule/types.js.map +1 -0
- package/package.json +16 -10
- package/dist/assets/dql-notebook/assets/index-dZVjj9xj.js +0 -623
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { searchBlocks, getBlock, listMetrics, listDimensions, lineageImpact, certify, suggestBlock, } from '@duckcodeailabs/dql-mcp';
|
|
2
|
+
const SEARCH_BLOCKS_SCHEMA = {
|
|
3
|
+
type: 'object',
|
|
4
|
+
additionalProperties: false,
|
|
5
|
+
properties: {
|
|
6
|
+
query: { type: 'string', description: 'Substring matched against name, description, or tags.' },
|
|
7
|
+
domain: { type: 'string', description: 'Filter to a single business domain.' },
|
|
8
|
+
status: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
enum: ['draft', 'review', 'certified', 'deprecated', 'pending_recertification'],
|
|
11
|
+
description: 'Filter by certification status.',
|
|
12
|
+
},
|
|
13
|
+
limit: { type: 'number', description: 'Max results (default 50).' },
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
const GET_BLOCK_SCHEMA = {
|
|
17
|
+
type: 'object',
|
|
18
|
+
additionalProperties: false,
|
|
19
|
+
required: ['name'],
|
|
20
|
+
properties: {
|
|
21
|
+
name: { type: 'string', description: 'Block name (as shown in search_blocks).' },
|
|
22
|
+
includeSource: { type: 'boolean', description: 'Include full .dql source text. Default true.' },
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
const DOMAIN_FILTER_SCHEMA = {
|
|
26
|
+
type: 'object',
|
|
27
|
+
additionalProperties: false,
|
|
28
|
+
properties: {
|
|
29
|
+
domain: { type: 'string', description: 'Filter to a single domain.' },
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
const LINEAGE_IMPACT_SCHEMA = {
|
|
33
|
+
type: 'object',
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
required: ['focus'],
|
|
36
|
+
properties: {
|
|
37
|
+
focus: { type: 'string', description: 'Node id ("block:revenue") or bare name.' },
|
|
38
|
+
upstreamDepth: { type: 'number' },
|
|
39
|
+
downstreamDepth: { type: 'number' },
|
|
40
|
+
paths: { type: 'boolean', description: 'Include full source→leaf paths (slower on large graphs).' },
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
const CERTIFY_SCHEMA = {
|
|
44
|
+
type: 'object',
|
|
45
|
+
additionalProperties: false,
|
|
46
|
+
required: ['name'],
|
|
47
|
+
properties: {
|
|
48
|
+
name: { type: 'string', description: 'Block name to certify.' },
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
const SUGGEST_BLOCK_SCHEMA = {
|
|
52
|
+
type: 'object',
|
|
53
|
+
additionalProperties: false,
|
|
54
|
+
required: ['name', 'domain', 'owner', 'description', 'sql'],
|
|
55
|
+
properties: {
|
|
56
|
+
name: { type: 'string', description: 'Proposed block name (kebab_case).' },
|
|
57
|
+
domain: { type: 'string', description: 'Business domain (finance, product, …).' },
|
|
58
|
+
owner: { type: 'string', description: 'Block owner identity (email or team handle).' },
|
|
59
|
+
description: { type: 'string', description: 'One-line description.' },
|
|
60
|
+
sql: { type: 'string', description: 'The block body SQL.' },
|
|
61
|
+
tags: { type: 'array', items: { type: 'string' } },
|
|
62
|
+
chartType: { type: 'string', description: 'Optional visualization type.' },
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
export function buildAgentTools(ctx) {
|
|
66
|
+
return [
|
|
67
|
+
{
|
|
68
|
+
name: 'search_blocks',
|
|
69
|
+
description: 'Find certified DQL blocks by keyword, domain, or status.',
|
|
70
|
+
inputSchema: SEARCH_BLOCKS_SCHEMA,
|
|
71
|
+
run: async (args) => searchBlocks(ctx, args),
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'get_block',
|
|
75
|
+
description: 'Return full metadata, dependencies, and SQL for a block.',
|
|
76
|
+
inputSchema: GET_BLOCK_SCHEMA,
|
|
77
|
+
run: async (args) => getBlock(ctx, args),
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'list_metrics',
|
|
81
|
+
description: 'List semantic-layer metrics, optionally filtered by domain.',
|
|
82
|
+
inputSchema: DOMAIN_FILTER_SCHEMA,
|
|
83
|
+
run: async (args) => listMetrics(ctx, args),
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: 'list_dimensions',
|
|
87
|
+
description: 'List semantic-layer dimensions, optionally filtered by domain.',
|
|
88
|
+
inputSchema: DOMAIN_FILTER_SCHEMA,
|
|
89
|
+
run: async (args) => listDimensions(ctx, args),
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'lineage_impact',
|
|
93
|
+
description: 'Return upstream/downstream lineage for a block, metric, or model.',
|
|
94
|
+
inputSchema: LINEAGE_IMPACT_SCHEMA,
|
|
95
|
+
run: async (args) => lineageImpact(ctx, args),
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'certify',
|
|
99
|
+
description: 'Run governance rules against a block and report pass/fail.',
|
|
100
|
+
inputSchema: CERTIFY_SCHEMA,
|
|
101
|
+
run: async (args) => certify(ctx, args),
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: 'suggest_block',
|
|
105
|
+
description: 'Write a proposed block to blocks/_drafts/ and return governance results. ' +
|
|
106
|
+
'Use this at the end of a conversation to hand the user a reviewable draft.',
|
|
107
|
+
inputSchema: SUGGEST_BLOCK_SCHEMA,
|
|
108
|
+
run: async (args) => suggestBlock(ctx, args),
|
|
109
|
+
},
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 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ACzE;QACD;YACE,IAAI,EAAE,eAAe;YACrB,WAAW,EACT,2EAA2E;gBAC3E,4EAA4E;YAC9E,WAAW,EAAE,oBAAoB;YACjC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,EAAE,IAA0C,CAAC;SACnF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export type ProviderId = 'claude-agent-sdk' | 'claude-code';
|
|
2
|
+
export interface ChatTurn {
|
|
3
|
+
role: 'user' | 'assistant';
|
|
4
|
+
content: string;
|
|
5
|
+
}
|
|
6
|
+
export interface BlockProposal {
|
|
7
|
+
name: string;
|
|
8
|
+
domain: string;
|
|
9
|
+
owner: string;
|
|
10
|
+
description: string;
|
|
11
|
+
sql: string;
|
|
12
|
+
tags?: string[];
|
|
13
|
+
chartType?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Normalized event a provider streams back for each step of an agent run.
|
|
17
|
+
* The UI renders these in order; the final `proposal` (if any) routes through
|
|
18
|
+
* the governance gate before `/api/blocks/save-from-cell`.
|
|
19
|
+
*/
|
|
20
|
+
export type AgentTurn = {
|
|
21
|
+
kind: 'thinking';
|
|
22
|
+
text: string;
|
|
23
|
+
} | {
|
|
24
|
+
kind: 'text';
|
|
25
|
+
text: string;
|
|
26
|
+
} | {
|
|
27
|
+
kind: 'tool_call';
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
input: unknown;
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'tool_result';
|
|
33
|
+
id: string;
|
|
34
|
+
output: unknown;
|
|
35
|
+
isError?: boolean;
|
|
36
|
+
} | {
|
|
37
|
+
kind: 'proposal';
|
|
38
|
+
proposal: BlockProposal;
|
|
39
|
+
governance: {
|
|
40
|
+
certified: boolean;
|
|
41
|
+
errors: string[];
|
|
42
|
+
warnings: string[];
|
|
43
|
+
};
|
|
44
|
+
} | {
|
|
45
|
+
kind: 'error';
|
|
46
|
+
message: string;
|
|
47
|
+
} | {
|
|
48
|
+
kind: 'done';
|
|
49
|
+
stopReason?: string;
|
|
50
|
+
};
|
|
51
|
+
export interface AgentRunRequest {
|
|
52
|
+
provider: ProviderId;
|
|
53
|
+
messages: ChatTurn[];
|
|
54
|
+
upstream?: {
|
|
55
|
+
cellId?: string;
|
|
56
|
+
sql?: string;
|
|
57
|
+
preview?: unknown;
|
|
58
|
+
};
|
|
59
|
+
projectRoot: string;
|
|
60
|
+
}
|
|
61
|
+
export interface AgentRunner {
|
|
62
|
+
run(req: AgentRunRequest, emit: (turn: AgentTurn) => void, signal: AbortSignal): Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/llm/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,kBAAkB,GAAG,aAAa,CAAC;AAE5D,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,MAAM,SAAS,GACjB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC/D;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GACvE;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,aAAa,CAAC;IAAC,UAAU,EAAE;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;CAAE,GACvH;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,UAAU,CAAC;IACrB,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAChE,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/llm/types.ts"],"names":[],"mappings":""}
|
package/dist/local-runtime.d.ts
CHANGED
|
@@ -81,6 +81,12 @@ export declare function createBlockArtifacts(projectRoot: string, options: {
|
|
|
81
81
|
tags?: string[];
|
|
82
82
|
metricRefs?: string[];
|
|
83
83
|
template?: string;
|
|
84
|
+
llmContext?: string;
|
|
85
|
+
examples?: Array<{
|
|
86
|
+
question: string;
|
|
87
|
+
sql?: string;
|
|
88
|
+
}>;
|
|
89
|
+
invariants?: string[];
|
|
84
90
|
gitMetadata?: BlockGitMetadata | null;
|
|
85
91
|
}): {
|
|
86
92
|
path: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-runtime.d.ts","sourceRoot":"","sources":["../src/local-runtime.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAUtF,OAAO,EAcL,KAAK,aAAa,EAClB,KAAK,2BAA2B,EAUjC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"local-runtime.d.ts","sourceRoot":"","sources":["../src/local-runtime.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAUtF,OAAO,EAcL,KAAK,aAAa,EAClB,KAAK,2BAA2B,EAUjC,MAAM,0BAA0B,CAAC;AAalC,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,gBAAgB,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,2BAA2B,CAAC;IAC5C,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,OAAO,CAAC;KAChB,CAAC;CACH;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,aAAa,CAAC;IACxB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,aAAa,EAAE,M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AAM,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA6CD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
package/dist/local-runtime.js
CHANGED
|
@@ -5,6 +5,7 @@ import { dirname, extname, join, normalize, relative, resolve } from 'node:path'
|
|
|
5
5
|
import { buildExecutionPlan, createWelcomeNotebook, deserializeNotebook, getConnectorFormSchemas, hasSemanticRefs, resolveSemanticRefs, } from '@duckcodeailabs/dql-notebook';
|
|
6
6
|
import { loadSemanticLayerFromDir, resolveSemanticLayerAsync, Parser, buildLineageGraph, buildManifest, analyzeImpact, buildTrustChain, detectDomainFlows, getDomainTrustOverview, queryLineage, queryCompleteLineagePaths, LineageGraph, canonicalize, canonicalizeNotebook, diffDQL, diffNotebook, } from '@duckcodeailabs/dql-core';
|
|
7
7
|
import { listBlockTemplates } from './block-templates.js';
|
|
8
|
+
import { getRunner as getLLMRunner } from './llm/index.js';
|
|
8
9
|
import { buildSemanticObjectDetail, buildSemanticTree, computeSyncDiff, loadSemanticImportManifest, performSemanticImport, previewSemanticImport, syncSemanticImport, } from './semantic-import.js';
|
|
9
10
|
export async function startLocalServer(opts) {
|
|
10
11
|
const { rootDir, executor, connection: rawConnection, preferredPort, projectRoot = process.cwd() } = opts;
|
|
@@ -344,7 +345,7 @@ export async function startLocalServer(opts) {
|
|
|
344
345
|
if (req.method === 'POST' && path === '/api/blocks/save-from-cell') {
|
|
345
346
|
try {
|
|
346
347
|
const body = await readJSON(req);
|
|
347
|
-
const { name, domain, owner, content, description, tags, metricRefs, template, } = body;
|
|
348
|
+
const { name, domain, owner, content, description, tags, metricRefs, template, llmContext, examples, invariants, } = body;
|
|
348
349
|
if (!name || typeof name !== 'string' || !content || typeof content !== 'string') {
|
|
349
350
|
res.writeHead(400, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
350
351
|
res.end(serializeJSON({ error: 'name and content are required' }));
|
|
@@ -374,6 +375,9 @@ export async function startLocalServer(opts) {
|
|
|
374
375
|
tags,
|
|
375
376
|
metricRefs,
|
|
376
377
|
template,
|
|
378
|
+
llmContext,
|
|
379
|
+
examples,
|
|
380
|
+
invariants,
|
|
377
381
|
gitMetadata: readGitMetadata(projectRoot),
|
|
378
382
|
});
|
|
379
383
|
res.writeHead(201, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
@@ -1293,6 +1297,42 @@ export async function startLocalServer(opts) {
|
|
|
1293
1297
|
}
|
|
1294
1298
|
return;
|
|
1295
1299
|
}
|
|
1300
|
+
if (req.method === 'POST' && path === '/api/llm/run') {
|
|
1301
|
+
const body = await readJSON(req).catch(() => null);
|
|
1302
|
+
if (!body || typeof body !== 'object') {
|
|
1303
|
+
res.writeHead(400, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
1304
|
+
res.end(serializeJSON({ error: 'Invalid JSON body' }));
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
const { provider, messages, upstream } = body;
|
|
1308
|
+
const runner = provider === 'claude-agent-sdk' || provider === 'claude-code' ? getLLMRunner(provider) : null;
|
|
1309
|
+
if (!runner) {
|
|
1310
|
+
res.writeHead(400, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
1311
|
+
res.end(serializeJSON({ error: `Unknown provider: ${provider}` }));
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
if (!Array.isArray(messages) || messages.length === 0) {
|
|
1315
|
+
res.writeHead(400, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
1316
|
+
res.end(serializeJSON({ error: 'messages[] required' }));
|
|
1317
|
+
return;
|
|
1318
|
+
}
|
|
1319
|
+
res.writeHead(200, {
|
|
1320
|
+
'Content-Type': 'text/event-stream',
|
|
1321
|
+
'Cache-Control': 'no-cache, no-transform',
|
|
1322
|
+
Connection: 'keep-alive',
|
|
1323
|
+
});
|
|
1324
|
+
const controller = new AbortController();
|
|
1325
|
+
req.on('close', () => controller.abort());
|
|
1326
|
+
const emit = (turn) => { res.write(`data: ${JSON.stringify(turn)}\n\n`); };
|
|
1327
|
+
try {
|
|
1328
|
+
await runner.run({ provider: provider, messages, upstream, projectRoot }, emit, controller.signal);
|
|
1329
|
+
}
|
|
1330
|
+
catch (err) {
|
|
1331
|
+
emit({ kind: 'error', message: err instanceof Error ? err.message : String(err) });
|
|
1332
|
+
}
|
|
1333
|
+
res.end();
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1296
1336
|
if (req.method === 'POST' && path === '/api/query') {
|
|
1297
1337
|
try {
|
|
1298
1338
|
const body = await readJSON(req);
|
|
@@ -2826,6 +2866,9 @@ export function createBlockArtifacts(projectRoot, options) {
|
|
|
2826
2866
|
owner: options.owner,
|
|
2827
2867
|
description: options.description,
|
|
2828
2868
|
tags: options.tags,
|
|
2869
|
+
llmContext: options.llmContext,
|
|
2870
|
+
examples: options.examples,
|
|
2871
|
+
invariants: options.invariants,
|
|
2829
2872
|
content: options.content?.trim() || templateContent,
|
|
2830
2873
|
}));
|
|
2831
2874
|
writeFileSync(blockPath, fileContent, 'utf-8');
|
|
@@ -3069,6 +3112,9 @@ function normalizeBlockStudioContent(options) {
|
|
|
3069
3112
|
owner: options.owner,
|
|
3070
3113
|
description: options.description,
|
|
3071
3114
|
tags: options.tags,
|
|
3115
|
+
llmContext: options.llmContext,
|
|
3116
|
+
examples: options.examples,
|
|
3117
|
+
invariants: options.invariants,
|
|
3072
3118
|
sql: content || 'SELECT 1 AS value',
|
|
3073
3119
|
});
|
|
3074
3120
|
}
|
|
@@ -3081,6 +3127,28 @@ function buildBlankBlockContent(options) {
|
|
|
3081
3127
|
` owner = "${escapeDqlString(options.owner?.trim() ?? '')}"`,
|
|
3082
3128
|
];
|
|
3083
3129
|
lines.push(` tags = [${(options.tags ?? []).map((tag) => `"${escapeDqlString(tag)}"`).join(', ')}]`);
|
|
3130
|
+
if (options.llmContext && options.llmContext.trim()) {
|
|
3131
|
+
lines.push(` llmContext = "${escapeDqlString(options.llmContext.trim())}"`);
|
|
3132
|
+
}
|
|
3133
|
+
if (options.invariants && options.invariants.length > 0) {
|
|
3134
|
+
lines.push(` invariants = [${options.invariants
|
|
3135
|
+
.filter((inv) => inv && inv.trim())
|
|
3136
|
+
.map((inv) => `"${escapeDqlString(inv.trim())}"`)
|
|
3137
|
+
.join(', ')}]`);
|
|
3138
|
+
}
|
|
3139
|
+
if (options.examples && options.examples.length > 0) {
|
|
3140
|
+
const items = options.examples.filter((ex) => ex.question && ex.question.trim());
|
|
3141
|
+
if (items.length > 0) {
|
|
3142
|
+
lines.push(' examples = [');
|
|
3143
|
+
for (const ex of items) {
|
|
3144
|
+
const parts = [`question = "${escapeDqlString(ex.question.trim())}"`];
|
|
3145
|
+
if (ex.sql && ex.sql.trim())
|
|
3146
|
+
parts.push(`sql = "${escapeDqlString(ex.sql.trim())}"`);
|
|
3147
|
+
lines.push(` { ${parts.join(', ')} },`);
|
|
3148
|
+
}
|
|
3149
|
+
lines.push(' ]');
|
|
3150
|
+
}
|
|
3151
|
+
}
|
|
3084
3152
|
lines.push('');
|
|
3085
3153
|
lines.push(' query = """');
|
|
3086
3154
|
lines.push(...indentBlock(options.sql.trim(), 8).split('\n'));
|