dominds 1.28.0 → 1.29.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/README.md +1 -0
- package/README.zh.md +1 -0
- package/dist/dialog-global-registry.d.ts +2 -0
- package/dist/dialog-global-registry.js +41 -0
- package/dist/dialog.d.ts +1 -0
- package/dist/dialog.js +5 -0
- package/dist/docs/codex-provider-auth-policy.md +59 -0
- package/dist/docs/codex-provider-auth-policy.zh.md +59 -0
- package/dist/docs/llm-provider-isolation.md +1 -1
- package/dist/docs/llm-provider-isolation.zh.md +1 -1
- package/dist/llm/api-quirks.d.ts +1 -0
- package/dist/llm/api-quirks.js +2 -1
- package/dist/llm/client.d.ts +2 -1
- package/dist/llm/defaults.yaml +163 -7
- package/dist/llm/gen/codex.d.ts +3 -2
- package/dist/llm/gen/codex.js +82 -10
- package/dist/llm/gen/google.d.ts +20 -0
- package/dist/llm/gen/google.js +735 -0
- package/dist/llm/gen/mock.js +8 -0
- package/dist/llm/gen/openai-compatible.js +5 -0
- package/dist/llm/gen/openai.js +9 -1
- package/dist/llm/gen/registry.js +4 -2
- package/dist/llm/gen/tool-output-limit.js +1 -0
- package/dist/llm/gen/tool-result-image-ingest.d.ts +1 -0
- package/dist/llm/gen/tool-result-image-ingest.js +2 -1
- package/dist/llm/kernel-driver/drive.js +21 -3
- package/dist/main-dialog-goal-reminder.d.ts +20 -0
- package/dist/main-dialog-goal-reminder.js +344 -0
- package/dist/minds/system-prompt-parts.js +14 -14
- package/dist/runtime/driver-messages.js +16 -16
- package/dist/server/setup-routes.js +3 -1
- package/dist/team.d.ts +12 -3
- package/dist/team.js +36 -4
- package/dist/tools/builtins.js +2 -0
- package/dist/tools/ctrl.d.ts +1 -0
- package/dist/tools/ctrl.js +65 -1
- package/dist/tools/prompts/control/en/index.md +4 -2
- package/dist/tools/prompts/control/en/principles.md +5 -4
- package/dist/tools/prompts/control/en/scenarios.md +9 -4
- package/dist/tools/prompts/control/en/tools.md +53 -9
- package/dist/tools/prompts/control/zh/index.md +4 -2
- package/dist/tools/prompts/control/zh/principles.md +5 -4
- package/dist/tools/prompts/control/zh/scenarios.md +9 -4
- package/dist/tools/prompts/control/zh/tools.md +53 -9
- package/dist/tools/team_mgmt-manual.js +10 -8
- package/dist/tools/team_mgmt.js +3 -0
- package/dist/tools/txt.js +115 -70
- package/package.json +5 -4
- package/webapp/dist/assets/{main-YWP5PWOM.js → main-YWYVZGBW.js} +119 -60
- package/webapp/dist/assets/{main-YWP5PWOM.js.map → main-YWYVZGBW.js.map} +3 -3
- package/webapp/dist/index.html +1 -1
package/dist/llm/gen/codex.js
CHANGED
|
@@ -4,9 +4,11 @@ exports.CodexGen = void 0;
|
|
|
4
4
|
exports.resolveCodexToolChoice = resolveCodexToolChoice;
|
|
5
5
|
exports.resolveCodexServiceTier = resolveCodexServiceTier;
|
|
6
6
|
exports.resolveCodexInstructions = resolveCodexInstructions;
|
|
7
|
+
exports.resolveCodexReasoningEffortForRequest = resolveCodexReasoningEffortForRequest;
|
|
7
8
|
const log_1 = require("../../log");
|
|
8
9
|
const i18n_text_1 = require("../../runtime/i18n-text");
|
|
9
10
|
const work_language_1 = require("../../runtime/work-language");
|
|
11
|
+
const api_quirks_1 = require("../api-quirks");
|
|
10
12
|
const artifacts_1 = require("./artifacts");
|
|
11
13
|
const failure_classifier_1 = require("./failure-classifier");
|
|
12
14
|
const tool_call_context_1 = require("./tool-call-context");
|
|
@@ -14,6 +16,24 @@ const tool_output_limit_1 = require("./tool-output-limit");
|
|
|
14
16
|
const tool_result_image_ingest_1 = require("./tool-result-image-ingest");
|
|
15
17
|
const log = (0, log_1.createLogger)('llm/codex');
|
|
16
18
|
const codexFallbackInstructions = 'You are Codex CLI.';
|
|
19
|
+
// Runtime import of codex-auth is dynamic because Dominds is CommonJS; keep this discriminator
|
|
20
|
+
// identical to the exported codex-auth policy error code.
|
|
21
|
+
const DOMINDS_CODEX_PROVIDER_AUTH_POLICY_ERROR_CODE = 'DOMINDS_CODEX_PROVIDER_AUTH_POLICY';
|
|
22
|
+
const codexAntiEarlyFinalizationInstructionSections = {
|
|
23
|
+
zh: {
|
|
24
|
+
title: '每轮作答前的推理完成检查',
|
|
25
|
+
body: '请在每轮作答前至少花一分钟推理。深入而充分地思考。在给出本轮答案前,证明充分性和必要性。',
|
|
26
|
+
},
|
|
27
|
+
en: {
|
|
28
|
+
title: 'Reasoning Completion Guard',
|
|
29
|
+
body: 'Please spend at least a minute reasoning before each response. Think long and hard. Prove both sufficiency and necessity before giving the answer for this turn.',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
function isDomindsCodexProviderAuthPolicyError(error) {
|
|
33
|
+
return (error instanceof Error &&
|
|
34
|
+
'code' in error &&
|
|
35
|
+
error.code === DOMINDS_CODEX_PROVIDER_AUTH_POLICY_ERROR_CODE);
|
|
36
|
+
}
|
|
17
37
|
function resolveCodexToolChoice(tools, requestContext) {
|
|
18
38
|
const requirement = requestContext.toolUseRequirement ?? 'auto';
|
|
19
39
|
if (tools.length === 0) {
|
|
@@ -105,8 +125,20 @@ function tryExtractApiReturnedModel(value) {
|
|
|
105
125
|
const trimmed = model.trim();
|
|
106
126
|
return trimmed.length > 0 ? trimmed : undefined;
|
|
107
127
|
}
|
|
108
|
-
function
|
|
109
|
-
|
|
128
|
+
function applyCodexInstructionQuirks(instructions, providerConfig) {
|
|
129
|
+
if (!providerConfig)
|
|
130
|
+
return instructions;
|
|
131
|
+
if (providerConfig.apiType !== 'codex')
|
|
132
|
+
return instructions;
|
|
133
|
+
const quirks = (0, api_quirks_1.normalizeProviderApiQuirks)(providerConfig);
|
|
134
|
+
if (!quirks.has(api_quirks_1.CODEX_ANTI_EARLY_FINALIZATION_API_QUIRK))
|
|
135
|
+
return instructions;
|
|
136
|
+
const section = codexAntiEarlyFinalizationInstructionSections[(0, work_language_1.getWorkLanguage)()];
|
|
137
|
+
return `${instructions}\n\n## ${section.title}\n${section.body}`;
|
|
138
|
+
}
|
|
139
|
+
function resolveCodexInstructions(systemPrompt, providerConfig) {
|
|
140
|
+
const instructions = systemPrompt.trim().length > 0 ? systemPrompt : codexFallbackInstructions;
|
|
141
|
+
return applyCodexInstructionQuirks(instructions, providerConfig);
|
|
110
142
|
}
|
|
111
143
|
function funcToolToCodex(funcTool) {
|
|
112
144
|
// MCP schemas are passed through to providers. Codex tool schema types are narrower; runtime
|
|
@@ -162,16 +194,27 @@ function buildCodexTextControls(agent) {
|
|
|
162
194
|
}
|
|
163
195
|
return Object.keys(text).length > 0 ? text : undefined;
|
|
164
196
|
}
|
|
165
|
-
function
|
|
197
|
+
function resolveCodexReasoningEffortForRequest(model, reasoningEffort) {
|
|
198
|
+
if (model.startsWith('gpt-5.6-') &&
|
|
199
|
+
(reasoningEffort === 'none' || reasoningEffort === 'minimal')) {
|
|
200
|
+
throw new Error(`Invalid Codex reasoning_effort=${reasoningEffort} for model '${model}'; GPT-5.6 Codex models support low|medium|high|xhigh|max, plus ultra on Sol and Terra.`);
|
|
201
|
+
}
|
|
202
|
+
if (model.startsWith('gpt-5.6-luna') && reasoningEffort === 'ultra') {
|
|
203
|
+
throw new Error(`Invalid Codex reasoning_effort=ultra for model '${model}'; GPT-5.6 Luna supports up to max.`);
|
|
204
|
+
}
|
|
205
|
+
// `ultra` is a Codex client orchestration preset. codex-rs sends `max` to the inference API
|
|
206
|
+
// and handles the additional delegation behavior locally; never put `ultra` on the wire.
|
|
207
|
+
return reasoningEffort === 'ultra' ? 'max' : reasoningEffort;
|
|
208
|
+
}
|
|
209
|
+
function buildCodexReasoning(agent, model) {
|
|
166
210
|
// Provider isolation rule: do not borrow OpenAI Responses params inside the Codex wrapper.
|
|
167
211
|
const codexParams = agent.model_params?.codex;
|
|
168
212
|
if (codexParams?.reasoning_effort === undefined && codexParams?.reasoning_summary === undefined) {
|
|
169
213
|
return null;
|
|
170
214
|
}
|
|
215
|
+
const reasoningEffort = resolveCodexReasoningEffortForRequest(model, codexParams?.reasoning_effort);
|
|
171
216
|
return {
|
|
172
|
-
...(
|
|
173
|
-
? { effort: codexParams.reasoning_effort }
|
|
174
|
-
: {}),
|
|
217
|
+
...(reasoningEffort !== undefined ? { effort: reasoningEffort } : {}),
|
|
175
218
|
...(codexParams?.reasoning_summary !== undefined
|
|
176
219
|
? { summary: codexParams.reasoning_summary }
|
|
177
220
|
: { summary: 'auto' }),
|
|
@@ -619,7 +662,7 @@ async function buildCodexRequest(providerConfig, agent, instructions, funcTools,
|
|
|
619
662
|
// Provider isolation rule: request construction must only read Codex-native params here.
|
|
620
663
|
const codexParams = agent.model_params?.codex;
|
|
621
664
|
const parallelToolCalls = codexParams?.parallel_tool_calls ?? true;
|
|
622
|
-
const reasoning = buildCodexReasoning(agent);
|
|
665
|
+
const reasoning = buildCodexReasoning(agent, agent.model);
|
|
623
666
|
const include = reasoning !== null ? ['reasoning.encrypted_content'] : [];
|
|
624
667
|
const serviceTier = resolveCodexServiceTier(codexParams?.service_tier);
|
|
625
668
|
const text = buildCodexTextControls(agent);
|
|
@@ -651,6 +694,13 @@ class CodexGen {
|
|
|
651
694
|
return 'codex';
|
|
652
695
|
}
|
|
653
696
|
classifyFailure(error) {
|
|
697
|
+
if (isDomindsCodexProviderAuthPolicyError(error)) {
|
|
698
|
+
return {
|
|
699
|
+
kind: 'fatal',
|
|
700
|
+
message: error.message,
|
|
701
|
+
code: error.code,
|
|
702
|
+
};
|
|
703
|
+
}
|
|
654
704
|
return (0, failure_classifier_1.classifyOpenAiLikeFailure)(error);
|
|
655
705
|
}
|
|
656
706
|
async genToReceiver(providerConfig, agent, systemPrompt, funcTools, requestContext, context, receiver, _genseq, abortSignal) {
|
|
@@ -661,13 +711,18 @@ class CodexGen {
|
|
|
661
711
|
// NOTE: `@longrun-ai/codex-auth` is an ESM package (`"type": "module"`). The Dominds backend is
|
|
662
712
|
// compiled as CommonJS, so Node.js requires a dynamic `import()` for runtime access here.
|
|
663
713
|
const codexAuth = await import('@longrun-ai/codex-auth');
|
|
714
|
+
// PRODUCT POLICY: this provider is intentionally narrower than codex-rs. It accepts only
|
|
715
|
+
// managed, refreshable ChatGPT OAuth file auth. Keep recognizing new codex-rs auth modes so
|
|
716
|
+
// they fail with actionable diagnostics, but do not enable them here during future syncs
|
|
717
|
+
// without an explicit Dominds product decision. Other auth belongs in a custom OpenAI
|
|
718
|
+
// Responses API provider or a separately approved Dominds feature.
|
|
664
719
|
const authPreparation = codexAuth.prepareCodexFileAuth({
|
|
665
720
|
codexHome,
|
|
666
721
|
codexHomeEnvVar: providerConfig.apiKeyEnvVar,
|
|
667
722
|
providerName: `Dominds codex provider '${providerConfig.name}'`,
|
|
668
723
|
});
|
|
669
724
|
if (authPreparation.kind === 'action_required') {
|
|
670
|
-
throw new
|
|
725
|
+
throw new codexAuth.DomindsCodexProviderAuthPolicyError(codexAuth.formatCodexFileAuthActionRequired(authPreparation));
|
|
671
726
|
}
|
|
672
727
|
if (authPreparation.changedConfigToFile) {
|
|
673
728
|
log.info('Codex CLI auth storage switched to file mode for Dominds codex provider', undefined, {
|
|
@@ -676,14 +731,29 @@ class CodexGen {
|
|
|
676
731
|
previousStoreMode: authPreparation.previousStoreMode,
|
|
677
732
|
});
|
|
678
733
|
}
|
|
679
|
-
const manager = new codexAuth.AuthManager({
|
|
734
|
+
const manager = new codexAuth.AuthManager({
|
|
735
|
+
codexHome,
|
|
736
|
+
// Reject ephemeral credentials, incomplete managed auth, or a changed auth.json before
|
|
737
|
+
// AuthManager can normalize or promote another stored mode into a managed-looking in-memory
|
|
738
|
+
// state during refresh/401 recovery.
|
|
739
|
+
validateStoredAuth: codexAuth.assertDomindsCodexProviderManagedChatGptStoredAuth,
|
|
740
|
+
// Validate environment and external precedence candidates before recovery can compare
|
|
741
|
+
// account ids or replace the cached state, so policy failures keep their actionable error.
|
|
742
|
+
validateAuthState: codexAuth.assertDomindsCodexProviderManagedChatGptAuth,
|
|
743
|
+
});
|
|
744
|
+
// Defense in depth against AuthManager precedence changes, environment overrides, or
|
|
745
|
+
// ephemeral credentials appearing after the file-auth preflight and before request creation.
|
|
746
|
+
codexAuth.assertDomindsCodexProviderManagedChatGptAuth(manager.authCached());
|
|
680
747
|
const client = await codexAuth.createChatGptClientFromManager(manager, {
|
|
681
748
|
baseUrl: providerConfig.baseUrl,
|
|
749
|
+
// Re-run the product-policy assertion after every auth-manager reload/refresh, before a
|
|
750
|
+
// recovered request can be sent with credentials that changed during the dialog lifetime.
|
|
751
|
+
validateAuthState: codexAuth.assertDomindsCodexProviderManagedChatGptAuth,
|
|
682
752
|
});
|
|
683
753
|
if (!agent.model) {
|
|
684
754
|
throw new Error(`Internal error: Model is undefined for agent '${agent.id}'`);
|
|
685
755
|
}
|
|
686
|
-
const instructions = resolveCodexInstructions(systemPrompt);
|
|
756
|
+
const instructions = resolveCodexInstructions(systemPrompt, providerConfig);
|
|
687
757
|
const payload = await buildCodexRequest(providerConfig, agent, instructions, funcTools, requestContext, context, receiver.toolResultImageIngest, receiver.userImageIngest);
|
|
688
758
|
let sayingStarted = false;
|
|
689
759
|
let thinkingStarted = false;
|
|
@@ -1006,10 +1076,12 @@ class CodexGen {
|
|
|
1006
1076
|
if (responseUsage &&
|
|
1007
1077
|
typeof responseUsage.input_tokens === 'number' &&
|
|
1008
1078
|
typeof responseUsage.output_tokens === 'number') {
|
|
1079
|
+
const reasoningTokens = responseUsage.output_tokens_details?.reasoning_tokens;
|
|
1009
1080
|
usage = {
|
|
1010
1081
|
kind: 'available',
|
|
1011
1082
|
promptTokens: responseUsage.input_tokens,
|
|
1012
1083
|
completionTokens: responseUsage.output_tokens,
|
|
1084
|
+
...(typeof reasoningTokens === 'number' ? { reasoningTokens } : {}),
|
|
1013
1085
|
totalTokens: typeof responseUsage.total_tokens === 'number'
|
|
1014
1086
|
? responseUsage.total_tokens
|
|
1015
1087
|
: responseUsage.input_tokens + responseUsage.output_tokens,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module: llm/gen/google
|
|
3
|
+
*
|
|
4
|
+
* Google Gemini API integration implementing streaming and batch generation.
|
|
5
|
+
* Rationale:
|
|
6
|
+
* - Direct native integration via the official `@google/genai` SDK.
|
|
7
|
+
* - Supports reasoning/thinking segments via Gemini 2.0+ `thought` parts.
|
|
8
|
+
* - Supports functional tools/declarations and correlated response structures.
|
|
9
|
+
*/
|
|
10
|
+
import type { Team } from '../../team';
|
|
11
|
+
import type { FuncTool } from '../../tool';
|
|
12
|
+
import { ChatMessage, ProviderConfig } from '../client';
|
|
13
|
+
import { type LlmBatchResult, type LlmFailureDisposition, type LlmGenerator, type LlmRequestContext, type LlmStreamReceiver, type LlmStreamResult } from '../gen';
|
|
14
|
+
export declare class GoogleGen implements LlmGenerator {
|
|
15
|
+
readonly apiType: string;
|
|
16
|
+
constructor(apiType?: string);
|
|
17
|
+
classifyFailure(error: unknown): LlmFailureDisposition | undefined;
|
|
18
|
+
genToReceiver(providerConfig: ProviderConfig, agent: Team.Member, systemPrompt: string, funcTools: FuncTool[], requestContext: LlmRequestContext, context: ChatMessage[], receiver: LlmStreamReceiver, genseq: number, abortSignal?: AbortSignal): Promise<LlmStreamResult>;
|
|
19
|
+
genMoreMessages(providerConfig: ProviderConfig, agent: Team.Member, systemPrompt: string, funcTools: FuncTool[], requestContext: LlmRequestContext, context: ChatMessage[], genseq: number, abortSignal?: AbortSignal): Promise<LlmBatchResult>;
|
|
20
|
+
}
|