@duckcodeailabs/dql-cli 1.6.30 → 1.6.31
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/assets/dql-notebook/assets/{index-QJKCrLXe.js → index-BpPs6_rz.js} +176 -176
- package/dist/assets/dql-notebook/index.html +1 -1
- package/dist/llm/providers/claude-agent-sdk.d.ts.map +1 -1
- package/dist/llm/providers/claude-agent-sdk.js +5 -3
- package/dist/llm/providers/claude-agent-sdk.js.map +1 -1
- package/dist/llm/providers/dql-agent-provider.d.ts.map +1 -1
- package/dist/llm/providers/dql-agent-provider.js +20 -6
- package/dist/llm/providers/dql-agent-provider.js.map +1 -1
- package/dist/llm/providers/native-sdk-provider.d.ts.map +1 -1
- package/dist/llm/providers/native-sdk-provider.js +7 -1
- package/dist/llm/providers/native-sdk-provider.js.map +1 -1
- package/dist/llm/types.d.ts +7 -1
- package/dist/llm/types.d.ts.map +1 -1
- package/dist/local-runtime.d.ts.map +1 -1
- package/dist/local-runtime.js +113 -4
- package/dist/local-runtime.js.map +1 -1
- package/dist/package.json +10 -10
- package/dist/providers/oauth/claude-oauth.d.ts +80 -0
- package/dist/providers/oauth/claude-oauth.d.ts.map +1 -0
- package/dist/providers/oauth/claude-oauth.js +352 -0
- package/dist/providers/oauth/claude-oauth.js.map +1 -0
- package/dist/providers/oauth/codex-oauth.d.ts +71 -0
- package/dist/providers/oauth/codex-oauth.d.ts.map +1 -0
- package/dist/providers/oauth/codex-oauth.js +410 -0
- package/dist/providers/oauth/codex-oauth.js.map +1 -0
- package/dist/providers/oauth/oauth-store.d.ts +31 -0
- package/dist/providers/oauth/oauth-store.d.ts.map +1 -0
- package/dist/providers/oauth/oauth-store.js +61 -0
- package/dist/providers/oauth/oauth-store.js.map +1 -0
- package/dist/settings/provider-settings.d.ts +17 -0
- package/dist/settings/provider-settings.d.ts.map +1 -1
- package/dist/settings/provider-settings.js +43 -9
- package/dist/settings/provider-settings.js.map +1 -1
- package/package.json +11 -11
package/dist/local-runtime.js
CHANGED
|
@@ -13,11 +13,13 @@ import { listBlockTemplates } from './block-templates.js';
|
|
|
13
13
|
import { getRunner as getLLMRunner } from './llm/index.js';
|
|
14
14
|
import { createDqlAgentProviderRunner } from './llm/providers/dql-agent-provider.js';
|
|
15
15
|
import { listRemoteMcpSettings, saveRemoteMcpSettings } from './llm/mcp-config.js';
|
|
16
|
-
import { ClaudeProvider, GeminiProvider, MemoryStore, OllamaProvider, OpenAIProvider, buildBlockBusinessFingerprint, buildBlockSqlFingerprints, buildLocalContextPack, defaultMemoryPath, ensureDefaultMemoryFiles, ensureMetadataCatalogFresh, propose, proposePlan, recordCorrectionTrace, reviewHint, AgentRunEngine, FileAgentRunStore, defaultAgentRunGates, createLlmAgentRunPlanner, createHybridRouter, synthesizeAnswer, streamOrGenerate, narrateResult, normalizeAnthropicBaseUrl, buildProposePreview, buildFromPrompt, defaultAgentRunStorePath, resolveLocalOwner, resolveProposeConfig, recordQueryRun, recordRuntimeSchemaSnapshot, loadSkills, writeSkill, deleteSkill, reindexProject, defaultKgPath, planApp, planResearch, loadSemanticMetrics, } from '@duckcodeailabs/dql-agent';
|
|
16
|
+
import { ClaudeProvider, GeminiProvider, MemoryStore, OllamaProvider, OpenAIProvider, buildBlockBusinessFingerprint, buildBlockSqlFingerprints, buildLocalContextPack, defaultMemoryPath, ensureDefaultMemoryFiles, ensureMetadataCatalogFresh, propose, proposePlan, recordCorrectionTrace, reviewHint, AgentRunEngine, FileAgentRunStore, defaultAgentRunGates, createLlmAgentRunPlanner, createHybridRouter, synthesizeAnswer, streamOrGenerate, narrateResult, normalizeAnthropicBaseUrl, buildProposePreview, buildFromPrompt, defaultAgentRunStorePath, resolveLocalOwner, resolveProposeConfig, recordQueryRun, recordRuntimeSchemaSnapshot, loadSkills, writeSkill, deleteSkill, reindexProject, defaultKgPath, planApp, planResearch, loadSemanticMetrics, routeReasoningEffort, clampReasoningEffort, bumpReasoningEffort, } from '@duckcodeailabs/dql-agent';
|
|
17
17
|
import { gatherProposeEnrichment } from './propose-enrich.js';
|
|
18
18
|
import { handleAppsApi, proposeAppAiBuild, recommendVisualization } from './apps-api.js';
|
|
19
19
|
import { getActiveProvider, getEffectiveProviderConfig, listProviderSettings, saveProviderSettings, } from './settings/provider-settings.js';
|
|
20
20
|
import { ClaudeCodeCliProvider, CodexCliProvider } from './providers/subscription-cli.js';
|
|
21
|
+
import { ClaudeOAuthManager, claudeOAuthConnected, CLAUDE_OAUTH_MODELS, CLAUDE_OAUTH_DEFAULT_MODEL, } from './providers/oauth/claude-oauth.js';
|
|
22
|
+
import { CodexOAuthManager, codexOAuthConnected, CODEX_OAUTH_MODELS, CODEX_OAUTH_DEFAULT_MODEL, } from './providers/oauth/codex-oauth.js';
|
|
21
23
|
import { DQLAccessDeniedError, activePersonaAppId, assertAppAccess, loadRuntimeApp, runtimeVariables, } from './governance-runtime.js';
|
|
22
24
|
import { LocalAppStorage, LocalNotebookResearchStorage, defaultLocalAppsDbPath, defaultNotebookResearchDbPath } from '@duckcodeailabs/dql-project';
|
|
23
25
|
import { Certifier, ENTERPRISE_RULES, evaluateInvariants, hasInvariantViolation, } from '@duckcodeailabs/dql-governance';
|
|
@@ -366,7 +368,7 @@ export async function startLocalServer(opts) {
|
|
|
366
368
|
return provider.generate([{ role: 'system', content: system }, { role: 'user', content: user }], { maxTokens: 600, temperature: 0.2, signal });
|
|
367
369
|
},
|
|
368
370
|
});
|
|
369
|
-
async function runGovernedAgentAnswerForRun(request, repair) {
|
|
371
|
+
async function runGovernedAgentAnswerForRun(request, repair, route = 'generated_answer') {
|
|
370
372
|
const governed = resolveGovernedAnswerRunner(projectRoot);
|
|
371
373
|
const resolvedProvider = governed?.provider ?? null;
|
|
372
374
|
const runner = governed?.runner ?? null;
|
|
@@ -376,6 +378,7 @@ export async function startLocalServer(opts) {
|
|
|
376
378
|
let governedAnswer;
|
|
377
379
|
let providerError;
|
|
378
380
|
const isRepair = (repair?.attempt ?? 0) > 0 && Boolean(repair?.repairHint);
|
|
381
|
+
const reasoningEffort = resolveRunReasoningEffort(projectRoot, resolvedProvider, route, isRepair);
|
|
379
382
|
const contextEnvelope = {
|
|
380
383
|
mode: 'agent_run',
|
|
381
384
|
selectedObject: request.selectedObject,
|
|
@@ -399,6 +402,7 @@ export async function startLocalServer(opts) {
|
|
|
399
402
|
cellId: `agent-run:${request.selectedObject?.kind ?? 'workspace'}:${request.selectedObject?.id ?? request.runId ?? 'auto'}`,
|
|
400
403
|
sql: JSON.stringify(contextEnvelope, null, 2),
|
|
401
404
|
},
|
|
405
|
+
reasoningEffort,
|
|
402
406
|
projectRoot,
|
|
403
407
|
executeCertifiedBlock: executeCertifiedBlockForAgent,
|
|
404
408
|
executeGeneratedSql: executeGeneratedSqlForAgent,
|
|
@@ -416,10 +420,10 @@ export async function startLocalServer(opts) {
|
|
|
416
420
|
}
|
|
417
421
|
return governedAnswer;
|
|
418
422
|
}
|
|
419
|
-
const answerRunExecutor = async ({ request, routeDecision, attempt, repairHint, emitAnswerDelta }) => {
|
|
423
|
+
const answerRunExecutor = async ({ request, route, routeDecision, attempt, repairHint, emitAnswerDelta }) => {
|
|
420
424
|
let governedAnswer;
|
|
421
425
|
try {
|
|
422
|
-
governedAnswer = await runGovernedAgentAnswerForRun(request, { attempt, repairHint });
|
|
426
|
+
governedAnswer = await runGovernedAgentAnswerForRun(request, { attempt, repairHint }, route);
|
|
423
427
|
// Surface the approved Hint-Graph corrections that shaped this answer so the
|
|
424
428
|
// UI can show an "applied learnings" chip (memoryContext is already on the answer).
|
|
425
429
|
if (!governedAnswer.appliedHints) {
|
|
@@ -1094,6 +1098,7 @@ export async function startLocalServer(opts) {
|
|
|
1094
1098
|
let governedAnswer;
|
|
1095
1099
|
let providerError;
|
|
1096
1100
|
const memoOnly = input.mode === 'memo_only';
|
|
1101
|
+
const reasoningEffort = resolveRunReasoningEffort(projectRoot, resolvedProvider, 'research', false);
|
|
1097
1102
|
const contextEnvelope = {
|
|
1098
1103
|
mode: 'app_research',
|
|
1099
1104
|
generationMode: input.mode ?? 'sql_and_memo',
|
|
@@ -1141,6 +1146,7 @@ export async function startLocalServer(opts) {
|
|
|
1141
1146
|
cellId: `app-research:${input.appId}:${input.dashboardId ?? 'app'}`,
|
|
1142
1147
|
sql: JSON.stringify(contextEnvelope, null, 2),
|
|
1143
1148
|
},
|
|
1149
|
+
reasoningEffort,
|
|
1144
1150
|
projectRoot,
|
|
1145
1151
|
executeCertifiedBlock: executeCertifiedBlockForAgent,
|
|
1146
1152
|
executeGeneratedSql: executeGeneratedSqlForAgent,
|
|
@@ -1327,6 +1333,7 @@ export async function startLocalServer(opts) {
|
|
|
1327
1333
|
context,
|
|
1328
1334
|
}, null, 2),
|
|
1329
1335
|
},
|
|
1336
|
+
reasoningEffort: resolveRunReasoningEffort(projectRoot, resolvedProvider, 'research', false),
|
|
1330
1337
|
projectRoot,
|
|
1331
1338
|
executeCertifiedBlock: executeCertifiedBlockForAgent,
|
|
1332
1339
|
executeGeneratedSql: executeGeneratedSqlForAgent,
|
|
@@ -2612,6 +2619,7 @@ export async function startLocalServer(opts) {
|
|
|
2612
2619
|
apiKey: typeof body.apiKey === 'string' ? body.apiKey : undefined,
|
|
2613
2620
|
baseUrl: typeof body.baseUrl === 'string' ? body.baseUrl : undefined,
|
|
2614
2621
|
model: typeof body.model === 'string' ? body.model : undefined,
|
|
2622
|
+
reasoningEffort: isReasoningEffortSetting(body.reasoningEffort) ? body.reasoningEffort : undefined,
|
|
2615
2623
|
});
|
|
2616
2624
|
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
2617
2625
|
res.end(serializeJSON({ ok: true, providers }));
|
|
@@ -2622,6 +2630,60 @@ export async function startLocalServer(opts) {
|
|
|
2622
2630
|
}
|
|
2623
2631
|
return;
|
|
2624
2632
|
}
|
|
2633
|
+
// ── Subscription OAuth (Claude Pro/Max, ChatGPT Plus/Pro) ──────────────
|
|
2634
|
+
{
|
|
2635
|
+
const authMatch = path.match(/^\/api\/auth\/(claude|codex)\/(start|status|signout)$/);
|
|
2636
|
+
if (authMatch) {
|
|
2637
|
+
const oauthProvider = authMatch[1];
|
|
2638
|
+
const action = authMatch[2];
|
|
2639
|
+
const info = oauthProvider === 'claude'
|
|
2640
|
+
? { models: CLAUDE_OAUTH_MODELS, defaultModel: CLAUDE_OAUTH_DEFAULT_MODEL }
|
|
2641
|
+
: { models: CODEX_OAUTH_MODELS, defaultModel: CODEX_OAUTH_DEFAULT_MODEL };
|
|
2642
|
+
const manager = getOAuthManager(projectRoot, oauthProvider);
|
|
2643
|
+
const statusPayload = () => {
|
|
2644
|
+
const connected = oauthProvider === 'claude' ? claudeOAuthConnected(projectRoot) : codexOAuthConnected(projectRoot);
|
|
2645
|
+
return {
|
|
2646
|
+
provider: oauthProvider,
|
|
2647
|
+
connected,
|
|
2648
|
+
email: connected ? manager.getEmail() : null,
|
|
2649
|
+
models: info.models,
|
|
2650
|
+
defaultModel: info.defaultModel,
|
|
2651
|
+
pending: manager.isPending(),
|
|
2652
|
+
};
|
|
2653
|
+
};
|
|
2654
|
+
try {
|
|
2655
|
+
if (action === 'status' && req.method === 'GET') {
|
|
2656
|
+
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
2657
|
+
res.end(serializeJSON(statusPayload()));
|
|
2658
|
+
return;
|
|
2659
|
+
}
|
|
2660
|
+
if (action === 'signout' && req.method === 'POST') {
|
|
2661
|
+
manager.signOut();
|
|
2662
|
+
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
2663
|
+
res.end(serializeJSON(statusPayload()));
|
|
2664
|
+
return;
|
|
2665
|
+
}
|
|
2666
|
+
if (action === 'start' && req.method === 'POST') {
|
|
2667
|
+
// Begin a fresh flow: build the authorize URL and start the loopback
|
|
2668
|
+
// callback server. The client opens the URL; the server captures the
|
|
2669
|
+
// redirect and persists tokens. The pending state lives on the manager,
|
|
2670
|
+
// so a superseded flow settles cleanly. Errors surface on the next poll.
|
|
2671
|
+
const url = manager.startAuthorizationFlow();
|
|
2672
|
+
void manager.waitForCallback().catch(() => { });
|
|
2673
|
+
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
2674
|
+
res.end(serializeJSON({ url, ...statusPayload() }));
|
|
2675
|
+
return;
|
|
2676
|
+
}
|
|
2677
|
+
res.writeHead(405, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
2678
|
+
res.end(serializeJSON({ error: 'Method not allowed' }));
|
|
2679
|
+
}
|
|
2680
|
+
catch (error) {
|
|
2681
|
+
res.writeHead(500, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
2682
|
+
res.end(serializeJSON({ error: error instanceof Error ? error.message : String(error) }));
|
|
2683
|
+
}
|
|
2684
|
+
return;
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2625
2687
|
if (req.method === 'POST' && path === '/api/settings/providers/test') {
|
|
2626
2688
|
try {
|
|
2627
2689
|
const body = await readJSON(req);
|
|
@@ -5676,6 +5738,10 @@ export async function startLocalServer(opts) {
|
|
|
5676
5738
|
conversationContext: conversationContext && typeof conversationContext === 'object' && !Array.isArray(conversationContext)
|
|
5677
5739
|
? conversationContext
|
|
5678
5740
|
: undefined,
|
|
5741
|
+
// Intentionally NOT threading a route effort here: this raw block/chat
|
|
5742
|
+
// authoring endpoint keeps each SDK runner's own tuned default (the
|
|
5743
|
+
// claude-agent-sdk runs `xhigh` for deep authoring). Governed answer /
|
|
5744
|
+
// research paths carry task-adaptive effort; this one shouldn't cap it.
|
|
5679
5745
|
projectRoot,
|
|
5680
5746
|
executeCertifiedBlock: executeCertifiedBlockForAgent,
|
|
5681
5747
|
executeGeneratedSql: executeGeneratedSqlForAgent,
|
|
@@ -6674,6 +6740,49 @@ function resolveGovernedAnswerRunner(projectRoot) {
|
|
|
6674
6740
|
const runner = getLLMRunner(resolved);
|
|
6675
6741
|
return runner ? { provider: resolved, runner } : null;
|
|
6676
6742
|
}
|
|
6743
|
+
/** Map a runner provider id to the settings id whose reasoning ceiling applies. */
|
|
6744
|
+
function reasoningSettingsIdFor(provider) {
|
|
6745
|
+
return provider === 'claude-agent-sdk' ? 'anthropic' : provider;
|
|
6746
|
+
}
|
|
6747
|
+
/** Type-guard for the reasoning-effort settings value from an untrusted request body. */
|
|
6748
|
+
function isReasoningEffortSetting(value) {
|
|
6749
|
+
return value === 'auto' || value === 'low' || value === 'medium' || value === 'high';
|
|
6750
|
+
}
|
|
6751
|
+
// Per-project singleton OAuth managers — they hold pending-auth state that must
|
|
6752
|
+
// survive between the `/start` request and the loopback callback. Keyed by
|
|
6753
|
+
// project root. "Pending" is derived from the manager itself (isPending) so a
|
|
6754
|
+
// superseded double-start can't desync a separate flag.
|
|
6755
|
+
const claudeOAuthManagers = new Map();
|
|
6756
|
+
const codexOAuthManagers = new Map();
|
|
6757
|
+
function getOAuthManager(projectRoot, provider) {
|
|
6758
|
+
if (provider === 'claude') {
|
|
6759
|
+
let m = claudeOAuthManagers.get(projectRoot);
|
|
6760
|
+
if (!m) {
|
|
6761
|
+
m = new ClaudeOAuthManager(projectRoot);
|
|
6762
|
+
claudeOAuthManagers.set(projectRoot, m);
|
|
6763
|
+
}
|
|
6764
|
+
return m;
|
|
6765
|
+
}
|
|
6766
|
+
let m = codexOAuthManagers.get(projectRoot);
|
|
6767
|
+
if (!m) {
|
|
6768
|
+
m = new CodexOAuthManager(projectRoot);
|
|
6769
|
+
codexOAuthManagers.set(projectRoot, m);
|
|
6770
|
+
}
|
|
6771
|
+
return m;
|
|
6772
|
+
}
|
|
6773
|
+
/**
|
|
6774
|
+
* Resolve the concrete reasoning effort for a run: the route's task-adaptive
|
|
6775
|
+
* effort (bumped one level on a repair attempt), clamped by the provider's
|
|
6776
|
+
* Settings ceiling (`auto` = no cap). Providers no-op when their model has no
|
|
6777
|
+
* reasoning surface, so returning a concrete level here is always safe.
|
|
6778
|
+
*/
|
|
6779
|
+
function resolveRunReasoningEffort(projectRoot, provider, route, isRepair) {
|
|
6780
|
+
const ceiling = getEffectiveProviderConfig(projectRoot, reasoningSettingsIdFor(provider)).reasoningEffort;
|
|
6781
|
+
let desired = route ? routeReasoningEffort(route) : 'medium';
|
|
6782
|
+
if (isRepair)
|
|
6783
|
+
desired = bumpReasoningEffort(desired);
|
|
6784
|
+
return ceiling ? clampReasoningEffort(desired, ceiling) : desired;
|
|
6785
|
+
}
|
|
6677
6786
|
function loadAppDashboard(projectRoot, appId, dashboardId) {
|
|
6678
6787
|
for (const p of findAppDocuments(projectRoot)) {
|
|
6679
6788
|
const { document: app } = loadAppDocument(p);
|