dominds 1.22.1 → 1.23.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/access-control.js +2 -2
- package/dist/docs/dialog-system.md +3 -2
- package/dist/docs/dialog-system.zh.md +3 -2
- package/dist/docs/encapsulated-taskdoc.md +11 -2
- package/dist/docs/encapsulated-taskdoc.zh.md +10 -1
- package/dist/docs/llm-provider-isolation.md +1 -1
- package/dist/docs/llm-provider-isolation.zh.md +1 -1
- package/dist/docs/team_mgmt-toolset.md +1 -0
- package/dist/docs/team_mgmt-toolset.zh.md +1 -0
- package/dist/llm/defaults.yaml +43 -0
- package/dist/llm/gen/openai-compatible.d.ts +3 -0
- package/dist/llm/gen/openai-compatible.js +294 -11
- package/dist/minds/system-prompt-parts.js +8 -8
- package/dist/runtime/driver-messages.js +4 -4
- package/dist/team.d.ts +2 -1
- package/dist/team.js +11 -1
- package/dist/tools/ctrl.js +48 -11
- package/dist/tools/prompts/control/en/principles.md +3 -3
- package/dist/tools/prompts/control/en/scenarios.md +4 -0
- package/dist/tools/prompts/control/en/tools.md +6 -3
- package/dist/tools/prompts/control/zh/principles.md +3 -3
- package/dist/tools/prompts/control/zh/scenarios.md +4 -0
- package/dist/tools/prompts/control/zh/tools.md +6 -3
- package/dist/tools/team_mgmt-manual.js +2 -2
- package/dist/tools/team_mgmt.js +2 -2
- package/dist/utils/task-package.d.ts +16 -0
- package/dist/utils/task-package.js +132 -55
- package/dist/utils/taskdoc.js +21 -16
- package/package.json +2 -2
- package/webapp/dist/assets/{_basePickBy-DUbW5G8a.js → _basePickBy-CGhMqD96.js} +3 -3
- package/webapp/dist/assets/{_basePickBy-DUbW5G8a.js.map → _basePickBy-CGhMqD96.js.map} +1 -1
- package/webapp/dist/assets/{_baseUniq-vou1IeXB.js → _baseUniq-XCMW7z1Y.js} +2 -2
- package/webapp/dist/assets/{_baseUniq-vou1IeXB.js.map → _baseUniq-XCMW7z1Y.js.map} +1 -1
- package/webapp/dist/assets/{arc-D_O9oO0B.js → arc-B6fzk0T5.js} +2 -2
- package/webapp/dist/assets/{arc-D_O9oO0B.js.map → arc-B6fzk0T5.js.map} +1 -1
- package/webapp/dist/assets/{architectureDiagram-2XIMDMQ5-B7k9SWSL.js → architectureDiagram-2XIMDMQ5-DmSI_GUt.js} +7 -7
- package/webapp/dist/assets/{architectureDiagram-2XIMDMQ5-B7k9SWSL.js.map → architectureDiagram-2XIMDMQ5-DmSI_GUt.js.map} +1 -1
- package/webapp/dist/assets/{blockDiagram-WCTKOSBZ-e3xTmffi.js → blockDiagram-WCTKOSBZ-Bp0nb8IZ.js} +7 -7
- package/webapp/dist/assets/{blockDiagram-WCTKOSBZ-e3xTmffi.js.map → blockDiagram-WCTKOSBZ-Bp0nb8IZ.js.map} +1 -1
- package/webapp/dist/assets/{c4Diagram-IC4MRINW-DVvi-N2o.js → c4Diagram-IC4MRINW-gYpylqGb.js} +3 -3
- package/webapp/dist/assets/{c4Diagram-IC4MRINW-DVvi-N2o.js.map → c4Diagram-IC4MRINW-gYpylqGb.js.map} +1 -1
- package/webapp/dist/assets/{channel-CH387UD2.js → channel-BmQ3YyUn.js} +2 -2
- package/webapp/dist/assets/{channel-CH387UD2.js.map → channel-BmQ3YyUn.js.map} +1 -1
- package/webapp/dist/assets/{chunk-4BX2VUAB-BOo0Xj3m.js → chunk-4BX2VUAB-B5pwFRwA.js} +2 -2
- package/webapp/dist/assets/{chunk-4BX2VUAB-BOo0Xj3m.js.map → chunk-4BX2VUAB-B5pwFRwA.js.map} +1 -1
- package/webapp/dist/assets/{chunk-55IACEB6-CI4uRAx_.js → chunk-55IACEB6-CZf6oMWM.js} +2 -2
- package/webapp/dist/assets/{chunk-55IACEB6-CI4uRAx_.js.map → chunk-55IACEB6-CZf6oMWM.js.map} +1 -1
- package/webapp/dist/assets/{chunk-FMBD7UC4-C4N1ovxD.js → chunk-FMBD7UC4-yZWCDzVz.js} +2 -2
- package/webapp/dist/assets/{chunk-FMBD7UC4-C4N1ovxD.js.map → chunk-FMBD7UC4-yZWCDzVz.js.map} +1 -1
- package/webapp/dist/assets/{chunk-JSJVCQXG-5U4Hu7pC.js → chunk-JSJVCQXG-Cg1ST73M.js} +2 -2
- package/webapp/dist/assets/{chunk-JSJVCQXG-5U4Hu7pC.js.map → chunk-JSJVCQXG-Cg1ST73M.js.map} +1 -1
- package/webapp/dist/assets/{chunk-KX2RTZJC-BXPDNuct.js → chunk-KX2RTZJC-ByGtlX9q.js} +2 -2
- package/webapp/dist/assets/{chunk-KX2RTZJC-BXPDNuct.js.map → chunk-KX2RTZJC-ByGtlX9q.js.map} +1 -1
- package/webapp/dist/assets/{chunk-NQ4KR5QH-oVsExnnn.js → chunk-NQ4KR5QH-DoXvfhSY.js} +4 -4
- package/webapp/dist/assets/{chunk-NQ4KR5QH-oVsExnnn.js.map → chunk-NQ4KR5QH-DoXvfhSY.js.map} +1 -1
- package/webapp/dist/assets/{chunk-QZHKN3VN-C6FzEv2C.js → chunk-QZHKN3VN-2gX2qsHB.js} +2 -2
- package/webapp/dist/assets/{chunk-QZHKN3VN-C6FzEv2C.js.map → chunk-QZHKN3VN-2gX2qsHB.js.map} +1 -1
- package/webapp/dist/assets/{chunk-WL4C6EOR-Ir7e_B7t.js → chunk-WL4C6EOR-L-9bPNxS.js} +6 -6
- package/webapp/dist/assets/{chunk-WL4C6EOR-Ir7e_B7t.js.map → chunk-WL4C6EOR-L-9bPNxS.js.map} +1 -1
- package/webapp/dist/assets/{classDiagram-VBA2DB6C-CPYs_LAr.js → classDiagram-VBA2DB6C-B79Oe3Df.js} +7 -7
- package/webapp/dist/assets/{classDiagram-VBA2DB6C-CPYs_LAr.js.map → classDiagram-VBA2DB6C-B79Oe3Df.js.map} +1 -1
- package/webapp/dist/assets/{classDiagram-v2-RAHNMMFH-CPYs_LAr.js → classDiagram-v2-RAHNMMFH-B79Oe3Df.js} +7 -7
- package/webapp/dist/assets/{classDiagram-v2-RAHNMMFH-CPYs_LAr.js.map → classDiagram-v2-RAHNMMFH-B79Oe3Df.js.map} +1 -1
- package/webapp/dist/assets/{clone-CToca8rS.js → clone-DvlY9Sdn.js} +2 -2
- package/webapp/dist/assets/{clone-CToca8rS.js.map → clone-DvlY9Sdn.js.map} +1 -1
- package/webapp/dist/assets/{cose-bilkent-S5V4N54A-DLNtqY7a.js → cose-bilkent-S5V4N54A-CtkGd0W6.js} +2 -2
- package/webapp/dist/assets/{cose-bilkent-S5V4N54A-DLNtqY7a.js.map → cose-bilkent-S5V4N54A-CtkGd0W6.js.map} +1 -1
- package/webapp/dist/assets/{dagre-KLK3FWXG-Bkt-O9uW.js → dagre-KLK3FWXG-B3W6QTXQ.js} +7 -7
- package/webapp/dist/assets/{dagre-KLK3FWXG-Bkt-O9uW.js.map → dagre-KLK3FWXG-B3W6QTXQ.js.map} +1 -1
- package/webapp/dist/assets/{diagram-E7M64L7V-B4JR_u4V.js → diagram-E7M64L7V-B6-J_E5Q.js} +8 -8
- package/webapp/dist/assets/{diagram-E7M64L7V-B4JR_u4V.js.map → diagram-E7M64L7V-B6-J_E5Q.js.map} +1 -1
- package/webapp/dist/assets/{diagram-IFDJBPK2-D9zRh8b7.js → diagram-IFDJBPK2-C-PH_Yx3.js} +7 -7
- package/webapp/dist/assets/{diagram-IFDJBPK2-D9zRh8b7.js.map → diagram-IFDJBPK2-C-PH_Yx3.js.map} +1 -1
- package/webapp/dist/assets/{diagram-P4PSJMXO-CAaXVWnX.js → diagram-P4PSJMXO-CB5xXDup.js} +7 -7
- package/webapp/dist/assets/{diagram-P4PSJMXO-CAaXVWnX.js.map → diagram-P4PSJMXO-CB5xXDup.js.map} +1 -1
- package/webapp/dist/assets/{erDiagram-INFDFZHY-DDeoaSkJ.js → erDiagram-INFDFZHY-CuAhTGVU.js} +5 -5
- package/webapp/dist/assets/{erDiagram-INFDFZHY-DDeoaSkJ.js.map → erDiagram-INFDFZHY-CuAhTGVU.js.map} +1 -1
- package/webapp/dist/assets/{flowDiagram-PKNHOUZH-DEYqzSEJ.js → flowDiagram-PKNHOUZH-D3cIOfGj.js} +7 -7
- package/webapp/dist/assets/{flowDiagram-PKNHOUZH-DEYqzSEJ.js.map → flowDiagram-PKNHOUZH-D3cIOfGj.js.map} +1 -1
- package/webapp/dist/assets/{ganttDiagram-A5KZAMGK-BuLOSh0d.js → ganttDiagram-A5KZAMGK-CSFhVYXV.js} +3 -3
- package/webapp/dist/assets/{ganttDiagram-A5KZAMGK-BuLOSh0d.js.map → ganttDiagram-A5KZAMGK-CSFhVYXV.js.map} +1 -1
- package/webapp/dist/assets/{gitGraphDiagram-K3NZZRJ6-CBrwZvBf.js → gitGraphDiagram-K3NZZRJ6-CiEaxACG.js} +8 -8
- package/webapp/dist/assets/{gitGraphDiagram-K3NZZRJ6-CBrwZvBf.js.map → gitGraphDiagram-K3NZZRJ6-CiEaxACG.js.map} +1 -1
- package/webapp/dist/assets/{graph-fX6cvjwR.js → graph-CYGALRuy.js} +3 -3
- package/webapp/dist/assets/{graph-fX6cvjwR.js.map → graph-CYGALRuy.js.map} +1 -1
- package/webapp/dist/assets/{index-B3WzTLcD.js → index-BTazqQrV.js} +152 -51
- package/webapp/dist/assets/{index-B3WzTLcD.js.map → index-BTazqQrV.js.map} +1 -1
- package/webapp/dist/assets/{infoDiagram-LFFYTUFH-Ci3XYvve.js → infoDiagram-LFFYTUFH-CiWJjQyU.js} +6 -6
- package/webapp/dist/assets/{infoDiagram-LFFYTUFH-Ci3XYvve.js.map → infoDiagram-LFFYTUFH-CiWJjQyU.js.map} +1 -1
- package/webapp/dist/assets/{ishikawaDiagram-PHBUUO56-DOH5ua9R.js → ishikawaDiagram-PHBUUO56-MlIIUO7o.js} +2 -2
- package/webapp/dist/assets/{ishikawaDiagram-PHBUUO56-DOH5ua9R.js.map → ishikawaDiagram-PHBUUO56-MlIIUO7o.js.map} +1 -1
- package/webapp/dist/assets/{journeyDiagram-4ABVD52K-DM_fiZlj.js → journeyDiagram-4ABVD52K-BBqwkA3d.js} +5 -5
- package/webapp/dist/assets/{journeyDiagram-4ABVD52K-DM_fiZlj.js.map → journeyDiagram-4ABVD52K-BBqwkA3d.js.map} +1 -1
- package/webapp/dist/assets/{kanban-definition-K7BYSVSG-CSh2hqc2.js → kanban-definition-K7BYSVSG-BS4GzDbo.js} +3 -3
- package/webapp/dist/assets/{kanban-definition-K7BYSVSG-CSh2hqc2.js.map → kanban-definition-K7BYSVSG-BS4GzDbo.js.map} +1 -1
- package/webapp/dist/assets/{layout-yZEK1LgL.js → layout-DaJO-1DW.js} +5 -5
- package/webapp/dist/assets/{layout-yZEK1LgL.js.map → layout-DaJO-1DW.js.map} +1 -1
- package/webapp/dist/assets/{linear-m76SmdtZ.js → linear-SWy2Cl7G.js} +2 -2
- package/webapp/dist/assets/{linear-m76SmdtZ.js.map → linear-SWy2Cl7G.js.map} +1 -1
- package/webapp/dist/assets/{mindmap-definition-YRQLILUH-NiwP-SLH.js → mindmap-definition-YRQLILUH-B_gNrT3l.js} +4 -4
- package/webapp/dist/assets/{mindmap-definition-YRQLILUH-NiwP-SLH.js.map → mindmap-definition-YRQLILUH-B_gNrT3l.js.map} +1 -1
- package/webapp/dist/assets/{pieDiagram-SKSYHLDU-CSCapDSD.js → pieDiagram-SKSYHLDU-CVh3lLBA.js} +8 -8
- package/webapp/dist/assets/{pieDiagram-SKSYHLDU-CSCapDSD.js.map → pieDiagram-SKSYHLDU-CVh3lLBA.js.map} +1 -1
- package/webapp/dist/assets/{quadrantDiagram-337W2JSQ-CbDGQH91.js → quadrantDiagram-337W2JSQ-D0zAkVD7.js} +3 -3
- package/webapp/dist/assets/{quadrantDiagram-337W2JSQ-CbDGQH91.js.map → quadrantDiagram-337W2JSQ-D0zAkVD7.js.map} +1 -1
- package/webapp/dist/assets/{requirementDiagram-Z7DCOOCP-CeG2yodp.js → requirementDiagram-Z7DCOOCP--CTFD60w.js} +4 -4
- package/webapp/dist/assets/{requirementDiagram-Z7DCOOCP-CeG2yodp.js.map → requirementDiagram-Z7DCOOCP--CTFD60w.js.map} +1 -1
- package/webapp/dist/assets/{sankeyDiagram-WA2Y5GQK-B_l8tKqa.js → sankeyDiagram-WA2Y5GQK-XZnViaAX.js} +2 -2
- package/webapp/dist/assets/{sankeyDiagram-WA2Y5GQK-B_l8tKqa.js.map → sankeyDiagram-WA2Y5GQK-XZnViaAX.js.map} +1 -1
- package/webapp/dist/assets/{sequenceDiagram-2WXFIKYE-Dc5gBIi5.js → sequenceDiagram-2WXFIKYE-BWAMhn_x.js} +4 -4
- package/webapp/dist/assets/{sequenceDiagram-2WXFIKYE-Dc5gBIi5.js.map → sequenceDiagram-2WXFIKYE-BWAMhn_x.js.map} +1 -1
- package/webapp/dist/assets/{stateDiagram-RAJIS63D-DMYeNS1r.js → stateDiagram-RAJIS63D--jsLD0Dg.js} +9 -9
- package/webapp/dist/assets/{stateDiagram-RAJIS63D-DMYeNS1r.js.map → stateDiagram-RAJIS63D--jsLD0Dg.js.map} +1 -1
- package/webapp/dist/assets/{stateDiagram-v2-FVOUBMTO-MfUJuUEe.js → stateDiagram-v2-FVOUBMTO-DUG9vyI5.js} +5 -5
- package/webapp/dist/assets/{stateDiagram-v2-FVOUBMTO-MfUJuUEe.js.map → stateDiagram-v2-FVOUBMTO-DUG9vyI5.js.map} +1 -1
- package/webapp/dist/assets/{timeline-definition-YZTLITO2-Ci2CZEky.js → timeline-definition-YZTLITO2-BROLp1hL.js} +3 -3
- package/webapp/dist/assets/{timeline-definition-YZTLITO2-Ci2CZEky.js.map → timeline-definition-YZTLITO2-BROLp1hL.js.map} +1 -1
- package/webapp/dist/assets/{treemap-KZPCXAKY-CNgzp4sT.js → treemap-KZPCXAKY-BXuIlbYo.js} +5 -5
- package/webapp/dist/assets/{treemap-KZPCXAKY-CNgzp4sT.js.map → treemap-KZPCXAKY-BXuIlbYo.js.map} +1 -1
- package/webapp/dist/assets/{vennDiagram-LZ73GAT5-BYxtNx2s.js → vennDiagram-LZ73GAT5-BXWd8gBB.js} +2 -2
- package/webapp/dist/assets/{vennDiagram-LZ73GAT5-BYxtNx2s.js.map → vennDiagram-LZ73GAT5-BXWd8gBB.js.map} +1 -1
- package/webapp/dist/assets/{xychartDiagram-JWTSCODW-BUS3bn9p.js → xychartDiagram-JWTSCODW-DR5z9o6h.js} +3 -3
- package/webapp/dist/assets/{xychartDiagram-JWTSCODW-BUS3bn9p.js.map → xychartDiagram-JWTSCODW-DR5z9o6h.js.map} +1 -1
- package/webapp/dist/index.html +1 -1
|
@@ -30,6 +30,8 @@ const path_1 = __importDefault(require("path"));
|
|
|
30
30
|
const log_1 = require("../../log");
|
|
31
31
|
const i18n_text_1 = require("../../runtime/i18n-text");
|
|
32
32
|
const work_language_1 = require("../../runtime/work-language");
|
|
33
|
+
const dominds_running_version_1 = require("../../server/dominds-running-version");
|
|
34
|
+
const api_quirks_1 = require("../api-quirks");
|
|
33
35
|
const gen_1 = require("../gen");
|
|
34
36
|
const stop_reason_i18n_1 = require("../stop-reason-i18n");
|
|
35
37
|
const artifacts_1 = require("./artifacts");
|
|
@@ -43,6 +45,47 @@ const OPENAI_COMPAT_CAPTURE_DIR_ENV = 'DOMINDS_OPENAI_COMPAT_CAPTURE_DIR';
|
|
|
43
45
|
const OPENAI_COMPAT_REJECTED_DIR_ENV = 'DOMINDS_OPENAI_COMPAT_REJECTED_DIR';
|
|
44
46
|
const OPENAI_COMPATIBLE_MALFORMED_BATCH_TOOL_CALL_ERROR_CODE = 'OPENAI_COMPATIBLE_MALFORMED_BATCH_TOOL_CALL';
|
|
45
47
|
const OPENAI_COMPATIBLE_REJECTED_REQUEST_ERROR_CODE = 'OPENAI_COMPATIBLE_REJECTED_REQUEST';
|
|
48
|
+
const KIMI_CODE_API_QUIRK = 'kimi-code';
|
|
49
|
+
const KIMI_CODE_REASONING_EFFORTS = new Set(['low', 'medium', 'high']);
|
|
50
|
+
const KIMI_CLI_CLOAK_API_QUIRK = 'kimi-cli-cloak';
|
|
51
|
+
const KIMI_CLI_USER_AGENT = 'KimiCLI/1.41.0';
|
|
52
|
+
const DISABLE_ASSISTANT_TOOL_CALL_REASONING_CONTENT_API_QUIRK = 'disable-assistant-tool-call-reasoning-content';
|
|
53
|
+
const JSON_SCHEMA_COMBINATOR_KEYS = new Set([
|
|
54
|
+
'anyOf',
|
|
55
|
+
'oneOf',
|
|
56
|
+
'allOf',
|
|
57
|
+
'not',
|
|
58
|
+
'if',
|
|
59
|
+
'then',
|
|
60
|
+
'else',
|
|
61
|
+
'$ref',
|
|
62
|
+
]);
|
|
63
|
+
const JSON_SCHEMA_BRANCH_ARRAY_KEYS = ['anyOf', 'oneOf', 'allOf'];
|
|
64
|
+
const JSON_SCHEMA_OBJECT_KEYS = new Set([
|
|
65
|
+
'properties',
|
|
66
|
+
'additionalProperties',
|
|
67
|
+
'patternProperties',
|
|
68
|
+
'propertyNames',
|
|
69
|
+
'required',
|
|
70
|
+
'minProperties',
|
|
71
|
+
'maxProperties',
|
|
72
|
+
]);
|
|
73
|
+
const JSON_SCHEMA_ARRAY_KEYS = new Set([
|
|
74
|
+
'items',
|
|
75
|
+
'prefixItems',
|
|
76
|
+
'minItems',
|
|
77
|
+
'maxItems',
|
|
78
|
+
'uniqueItems',
|
|
79
|
+
'contains',
|
|
80
|
+
]);
|
|
81
|
+
const JSON_SCHEMA_STRING_KEYS = new Set(['minLength', 'maxLength', 'pattern', 'format']);
|
|
82
|
+
const JSON_SCHEMA_NUMERIC_KEYS = new Set([
|
|
83
|
+
'minimum',
|
|
84
|
+
'maximum',
|
|
85
|
+
'multipleOf',
|
|
86
|
+
'exclusiveMinimum',
|
|
87
|
+
'exclusiveMaximum',
|
|
88
|
+
]);
|
|
46
89
|
function resolveOpenAiCompatibleToolChoice(funcTools, requestContext, modelInfo) {
|
|
47
90
|
const requirement = requestContext.toolUseRequirement ?? 'auto';
|
|
48
91
|
if (funcTools.length === 0) {
|
|
@@ -71,6 +114,14 @@ function resolveOpenAiCompatibleRequestModelInfo(providerConfig, agent, requestC
|
|
|
71
114
|
return undefined;
|
|
72
115
|
return providerConfig.models[modelKey];
|
|
73
116
|
}
|
|
117
|
+
function resolveOpenAiCompatibleParallelToolCalls(args) {
|
|
118
|
+
if (args.openAiParams.parallel_tool_calls !== undefined) {
|
|
119
|
+
return args.openAiParams.parallel_tool_calls;
|
|
120
|
+
}
|
|
121
|
+
if (isKimiCodeProvider(args.providerConfig))
|
|
122
|
+
return undefined;
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
74
125
|
function isOpenAiCompatibleSseCaptureEnabled() {
|
|
75
126
|
const configured = process.env[OPENAI_COMPAT_CAPTURE_SSE_ENV]?.trim().toLowerCase();
|
|
76
127
|
return configured === '1' || configured === 'true' || configured === 'yes' || configured === 'on';
|
|
@@ -525,6 +576,16 @@ function createOpenAiCompatibleClient(args) {
|
|
|
525
576
|
apiKey: args.apiKey,
|
|
526
577
|
baseURL: args.providerConfig.baseUrl,
|
|
527
578
|
};
|
|
579
|
+
if (isKimiCliCloakProvider(args.providerConfig)) {
|
|
580
|
+
options.defaultHeaders = {
|
|
581
|
+
'User-Agent': KIMI_CLI_USER_AGENT,
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
else if (isKimiCodeProvider(args.providerConfig)) {
|
|
585
|
+
options.defaultHeaders = {
|
|
586
|
+
'User-Agent': `Dominds/${dominds_running_version_1.DOMINDS_RUNNING_VERSION || 'dev'}`,
|
|
587
|
+
};
|
|
588
|
+
}
|
|
528
589
|
if (args.providerConfig.apiType === 'openai-compatible' &&
|
|
529
590
|
isOpenAiCompatibleSseCaptureEnabled()) {
|
|
530
591
|
options.fetch = buildOpenAiCompatibleCaptureFetch({
|
|
@@ -553,6 +614,129 @@ function limitOpenAiCompatibleToolOutputText(text, msg, limitChars) {
|
|
|
553
614
|
function isRecord(value) {
|
|
554
615
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
555
616
|
}
|
|
617
|
+
function isKimiCodeProvider(providerConfig) {
|
|
618
|
+
return (0, api_quirks_1.normalizeProviderApiQuirks)(providerConfig).has(KIMI_CODE_API_QUIRK);
|
|
619
|
+
}
|
|
620
|
+
function isKimiCliCloakProvider(providerConfig) {
|
|
621
|
+
return (0, api_quirks_1.normalizeProviderApiQuirks)(providerConfig).has(KIMI_CLI_CLOAK_API_QUIRK);
|
|
622
|
+
}
|
|
623
|
+
function isKimiCodeReasoningEffort(value) {
|
|
624
|
+
return typeof value === 'string' && KIMI_CODE_REASONING_EFFORTS.has(value);
|
|
625
|
+
}
|
|
626
|
+
function isKimiCodeThinkingMode(value) {
|
|
627
|
+
return (value === 'auto' || value === 'off' || value === 'low' || value === 'medium' || value === 'high');
|
|
628
|
+
}
|
|
629
|
+
function cloneJsonSchemaValue(value) {
|
|
630
|
+
if (Array.isArray(value))
|
|
631
|
+
return value.map((item) => cloneJsonSchemaValue(item));
|
|
632
|
+
if (isRecord(value)) {
|
|
633
|
+
const out = {};
|
|
634
|
+
for (const [key, child] of Object.entries(value)) {
|
|
635
|
+
out[key] = cloneJsonSchemaValue(child);
|
|
636
|
+
}
|
|
637
|
+
return out;
|
|
638
|
+
}
|
|
639
|
+
return value;
|
|
640
|
+
}
|
|
641
|
+
function hasAnyOwnKey(value, keys) {
|
|
642
|
+
for (const key of keys) {
|
|
643
|
+
if (Object.prototype.hasOwnProperty.call(value, key))
|
|
644
|
+
return true;
|
|
645
|
+
}
|
|
646
|
+
return false;
|
|
647
|
+
}
|
|
648
|
+
function inferJsonSchemaTypeFromValues(values) {
|
|
649
|
+
const inferred = new Set();
|
|
650
|
+
for (const value of values) {
|
|
651
|
+
if (typeof value === 'boolean')
|
|
652
|
+
inferred.add('boolean');
|
|
653
|
+
else if (typeof value === 'number')
|
|
654
|
+
inferred.add(Number.isInteger(value) ? 'integer' : 'number');
|
|
655
|
+
else if (typeof value === 'string')
|
|
656
|
+
inferred.add('string');
|
|
657
|
+
else if (value === null)
|
|
658
|
+
inferred.add('null');
|
|
659
|
+
else if (Array.isArray(value))
|
|
660
|
+
inferred.add('array');
|
|
661
|
+
else if (isRecord(value))
|
|
662
|
+
inferred.add('object');
|
|
663
|
+
else
|
|
664
|
+
return 'string';
|
|
665
|
+
}
|
|
666
|
+
if (inferred.size === 1) {
|
|
667
|
+
const only = [...inferred][0];
|
|
668
|
+
return only ?? 'string';
|
|
669
|
+
}
|
|
670
|
+
if (inferred.size === 2 && inferred.has('integer') && inferred.has('number')) {
|
|
671
|
+
return 'number';
|
|
672
|
+
}
|
|
673
|
+
return 'string';
|
|
674
|
+
}
|
|
675
|
+
function inferJsonSchemaTypeFromStructure(value) {
|
|
676
|
+
if (hasAnyOwnKey(value, JSON_SCHEMA_OBJECT_KEYS))
|
|
677
|
+
return 'object';
|
|
678
|
+
if (hasAnyOwnKey(value, JSON_SCHEMA_ARRAY_KEYS))
|
|
679
|
+
return 'array';
|
|
680
|
+
if (hasAnyOwnKey(value, JSON_SCHEMA_STRING_KEYS))
|
|
681
|
+
return 'string';
|
|
682
|
+
if (hasAnyOwnKey(value, JSON_SCHEMA_NUMERIC_KEYS))
|
|
683
|
+
return 'number';
|
|
684
|
+
return 'string';
|
|
685
|
+
}
|
|
686
|
+
function normalizeOpenAiCompatibleKimiCodeJsonSchemaProperty(value) {
|
|
687
|
+
if (!isRecord(value))
|
|
688
|
+
return;
|
|
689
|
+
if (!Object.prototype.hasOwnProperty.call(value, 'type') &&
|
|
690
|
+
!hasAnyOwnKey(value, JSON_SCHEMA_COMBINATOR_KEYS)) {
|
|
691
|
+
const enumValues = value.enum;
|
|
692
|
+
if (Array.isArray(enumValues) && enumValues.length > 0) {
|
|
693
|
+
value.type = inferJsonSchemaTypeFromValues(enumValues);
|
|
694
|
+
}
|
|
695
|
+
else if (Object.prototype.hasOwnProperty.call(value, 'const')) {
|
|
696
|
+
value.type = inferJsonSchemaTypeFromValues([value.const]);
|
|
697
|
+
}
|
|
698
|
+
else {
|
|
699
|
+
value.type = inferJsonSchemaTypeFromStructure(value);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
normalizeOpenAiCompatibleKimiCodeJsonSchemaContainer(value);
|
|
703
|
+
}
|
|
704
|
+
function normalizeOpenAiCompatibleKimiCodeJsonSchemaContainer(value) {
|
|
705
|
+
if (!isRecord(value))
|
|
706
|
+
return;
|
|
707
|
+
const properties = value.properties;
|
|
708
|
+
if (isRecord(properties)) {
|
|
709
|
+
for (const property of Object.values(properties)) {
|
|
710
|
+
normalizeOpenAiCompatibleKimiCodeJsonSchemaProperty(property);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
const items = value.items;
|
|
714
|
+
if (isRecord(items)) {
|
|
715
|
+
normalizeOpenAiCompatibleKimiCodeJsonSchemaProperty(items);
|
|
716
|
+
}
|
|
717
|
+
else if (Array.isArray(items)) {
|
|
718
|
+
for (const item of items) {
|
|
719
|
+
normalizeOpenAiCompatibleKimiCodeJsonSchemaProperty(item);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
const additionalProperties = value.additionalProperties;
|
|
723
|
+
if (isRecord(additionalProperties)) {
|
|
724
|
+
normalizeOpenAiCompatibleKimiCodeJsonSchemaProperty(additionalProperties);
|
|
725
|
+
}
|
|
726
|
+
for (const key of JSON_SCHEMA_BRANCH_ARRAY_KEYS) {
|
|
727
|
+
const branches = value[key];
|
|
728
|
+
if (!Array.isArray(branches))
|
|
729
|
+
continue;
|
|
730
|
+
for (const branch of branches) {
|
|
731
|
+
normalizeOpenAiCompatibleKimiCodeJsonSchemaProperty(branch);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
function normalizeOpenAiCompatibleKimiCodeJsonSchema(value) {
|
|
736
|
+
const cloned = cloneJsonSchemaValue(value);
|
|
737
|
+
normalizeOpenAiCompatibleKimiCodeJsonSchemaContainer(cloned);
|
|
738
|
+
return cloned;
|
|
739
|
+
}
|
|
556
740
|
function isLlmRequestContext(value) {
|
|
557
741
|
return (isRecord(value) &&
|
|
558
742
|
typeof value.dialogSelfId === 'string' &&
|
|
@@ -618,8 +802,14 @@ function buildReasoningPayloadFromText(text) {
|
|
|
618
802
|
};
|
|
619
803
|
}
|
|
620
804
|
function buildOpenAiCompatibleExtraParams(args) {
|
|
805
|
+
if (args.providerConfig !== undefined && isKimiCodeProvider(args.providerConfig)) {
|
|
806
|
+
return buildKimiCodeOpenAiCompatibleExtraParams(args);
|
|
807
|
+
}
|
|
621
808
|
const model = args.agent.model ?? '';
|
|
622
809
|
const thinking = args.openAiParams.thinking;
|
|
810
|
+
if (typeof thinking === 'string') {
|
|
811
|
+
throw new Error(`Invalid openai-compatible model_params: string thinking mode '${thinking}' requires apiQuirks: ${KIMI_CODE_API_QUIRK} for model '${model}'.`);
|
|
812
|
+
}
|
|
623
813
|
const reasoningEffort = args.openAiParams.reasoning_effort;
|
|
624
814
|
const thinkingDisabled = thinking === false || (isRecord(thinking) && thinking.type === 'disabled');
|
|
625
815
|
if (thinkingDisabled && reasoningEffort !== undefined) {
|
|
@@ -633,6 +823,57 @@ function buildOpenAiCompatibleExtraParams(args) {
|
|
|
633
823
|
...(reasoningEffort !== undefined ? { reasoning_effort: reasoningEffort } : {}),
|
|
634
824
|
};
|
|
635
825
|
}
|
|
826
|
+
function buildKimiCodeOpenAiCompatibleExtraParams(args) {
|
|
827
|
+
const model = args.agent.model ?? '';
|
|
828
|
+
const thinking = args.openAiParams.thinking;
|
|
829
|
+
const reasoningEffort = args.openAiParams.reasoning_effort;
|
|
830
|
+
const promptCacheKey = args.requestContext?.promptCacheKey?.trim();
|
|
831
|
+
if (reasoningEffort !== undefined && !isKimiCodeReasoningEffort(reasoningEffort)) {
|
|
832
|
+
throw new Error(`Invalid Kimi Code openai-compatible model_params: reasoning_effort=${reasoningEffort} is not supported for model '${model}'; expected low|medium|high.`);
|
|
833
|
+
}
|
|
834
|
+
const base = promptCacheKey !== undefined && promptCacheKey.length > 0
|
|
835
|
+
? { prompt_cache_key: promptCacheKey }
|
|
836
|
+
: {};
|
|
837
|
+
if (thinking === undefined) {
|
|
838
|
+
return {
|
|
839
|
+
...base,
|
|
840
|
+
...(reasoningEffort !== undefined
|
|
841
|
+
? { thinking: { type: 'enabled' }, reasoning_effort: reasoningEffort }
|
|
842
|
+
: {}),
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
if (thinking === 'auto' || thinking === 'off') {
|
|
846
|
+
if (reasoningEffort !== undefined) {
|
|
847
|
+
throw new Error(`Invalid Kimi Code openai-compatible model_params: thinking=${thinking} conflicts with reasoning_effort=${reasoningEffort} for model '${model}'.`);
|
|
848
|
+
}
|
|
849
|
+
if (thinking === 'auto')
|
|
850
|
+
return base;
|
|
851
|
+
return {
|
|
852
|
+
...base,
|
|
853
|
+
thinking: { type: 'disabled' },
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
if (isKimiCodeThinkingMode(thinking)) {
|
|
857
|
+
if (reasoningEffort !== undefined && reasoningEffort !== thinking) {
|
|
858
|
+
throw new Error(`Invalid Kimi Code openai-compatible model_params: thinking=${thinking} conflicts with reasoning_effort=${reasoningEffort} for model '${model}'.`);
|
|
859
|
+
}
|
|
860
|
+
return {
|
|
861
|
+
...base,
|
|
862
|
+
thinking: { type: 'enabled' },
|
|
863
|
+
reasoning_effort: thinking,
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
const thinkingDisabled = thinking === false || (isRecord(thinking) && thinking.type === 'disabled');
|
|
867
|
+
if (thinkingDisabled && reasoningEffort !== undefined) {
|
|
868
|
+
throw new Error(`Invalid Kimi Code openai-compatible model_params: thinking disabled conflicts with reasoning_effort=${reasoningEffort} for model '${model}'.`);
|
|
869
|
+
}
|
|
870
|
+
const thinkingPayload = typeof thinking === 'boolean' ? { type: thinking ? 'enabled' : 'disabled' } : thinking;
|
|
871
|
+
return {
|
|
872
|
+
...base,
|
|
873
|
+
...(thinkingPayload !== undefined ? { thinking: thinkingPayload } : {}),
|
|
874
|
+
...(reasoningEffort !== undefined ? { reasoning_effort: reasoningEffort } : {}),
|
|
875
|
+
};
|
|
876
|
+
}
|
|
636
877
|
async function wrapOpenAiCompatibleRejectedRequestError(args) {
|
|
637
878
|
const status = (0, failure_classifier_1.readErrorStatus)(args.error);
|
|
638
879
|
if (status !== 400)
|
|
@@ -719,10 +960,18 @@ function attachReasoningContent(message, reasoningContent) {
|
|
|
719
960
|
reasoning_content: reasoningContent,
|
|
720
961
|
};
|
|
721
962
|
}
|
|
722
|
-
function
|
|
963
|
+
function shouldAttachReasoningContentToAssistantToolCalls(providerConfig) {
|
|
964
|
+
if (providerConfig === undefined)
|
|
965
|
+
return true;
|
|
966
|
+
return !(0, api_quirks_1.normalizeProviderApiQuirks)(providerConfig).has(DISABLE_ASSISTANT_TOOL_CALL_REASONING_CONTENT_API_QUIRK);
|
|
967
|
+
}
|
|
968
|
+
function funcToolToChatCompletionTool(funcTool, providerConfig) {
|
|
723
969
|
// MCP schemas are passed through to providers. Chat Completions expects a narrower JSON schema
|
|
724
970
|
// shape; runtime compatibility is handled by provider validation + the driver stop policy.
|
|
725
|
-
const
|
|
971
|
+
const rawParameters = funcTool.parameters;
|
|
972
|
+
const parameters = (providerConfig !== undefined && isKimiCodeProvider(providerConfig)
|
|
973
|
+
? normalizeOpenAiCompatibleKimiCodeJsonSchema(rawParameters)
|
|
974
|
+
: rawParameters);
|
|
726
975
|
const description = (0, i18n_text_1.getTextForLanguage)({ i18n: funcTool.descriptionI18n, fallback: funcTool.description }, (0, work_language_1.getWorkLanguage)());
|
|
727
976
|
return {
|
|
728
977
|
type: 'function',
|
|
@@ -748,7 +997,6 @@ function chatMessageToChatCompletionMessage(msg) {
|
|
|
748
997
|
case 'func_call_msg':
|
|
749
998
|
return {
|
|
750
999
|
role: 'assistant',
|
|
751
|
-
content: null,
|
|
752
1000
|
tool_calls: [
|
|
753
1001
|
{
|
|
754
1002
|
id: msg.id,
|
|
@@ -1102,7 +1350,9 @@ async function buildChatCompletionMessages(systemPrompt, context, requestContext
|
|
|
1102
1350
|
const input = [];
|
|
1103
1351
|
const toolResultMaxChars = (0, tool_output_limit_1.resolveProviderToolResultMaxChars)(options?.providerConfig);
|
|
1104
1352
|
const allowedImageKeys = (0, tool_result_image_ingest_1.selectLatestImagesWithinBudget)(normalized, tool_result_image_ingest_1.OPENAI_COMPATIBLE_TOOL_RESULT_IMAGE_BUDGET_BYTES);
|
|
1353
|
+
const attachToolCallReasoning = shouldAttachReasoningContentToAssistantToolCalls(options?.providerConfig);
|
|
1105
1354
|
let pendingReasoningContent;
|
|
1355
|
+
let assistantTurnReasoningContent;
|
|
1106
1356
|
const takePendingReasoningContent = () => {
|
|
1107
1357
|
const current = pendingReasoningContent;
|
|
1108
1358
|
pendingReasoningContent = undefined;
|
|
@@ -1116,10 +1366,16 @@ async function buildChatCompletionMessages(systemPrompt, context, requestContext
|
|
|
1116
1366
|
? `${pendingReasoningContent}\n${value}`
|
|
1117
1367
|
: value;
|
|
1118
1368
|
};
|
|
1369
|
+
const noteAssistantTurnReasoningContent = (value) => {
|
|
1370
|
+
if (!value)
|
|
1371
|
+
return;
|
|
1372
|
+
assistantTurnReasoningContent = value;
|
|
1373
|
+
};
|
|
1119
1374
|
const flushPendingReasoningAsAssistantMessage = () => {
|
|
1120
1375
|
const reasoningContent = takePendingReasoningContent();
|
|
1121
1376
|
if (!reasoningContent)
|
|
1122
1377
|
return;
|
|
1378
|
+
noteAssistantTurnReasoningContent(reasoningContent);
|
|
1123
1379
|
input.push(attachReasoningContent({
|
|
1124
1380
|
role: 'assistant',
|
|
1125
1381
|
content: '',
|
|
@@ -1135,7 +1391,12 @@ async function buildChatCompletionMessages(systemPrompt, context, requestContext
|
|
|
1135
1391
|
}
|
|
1136
1392
|
if (msg.type === 'func_call_msg') {
|
|
1137
1393
|
const mapped = chatMessageToChatCompletionMessage(msg);
|
|
1138
|
-
|
|
1394
|
+
const pending = takePendingReasoningContent();
|
|
1395
|
+
noteAssistantTurnReasoningContent(pending);
|
|
1396
|
+
const reasoningContent = attachToolCallReasoning
|
|
1397
|
+
? (pending ?? assistantTurnReasoningContent)
|
|
1398
|
+
: undefined;
|
|
1399
|
+
input.push(attachReasoningContent(mapped, reasoningContent));
|
|
1139
1400
|
continue;
|
|
1140
1401
|
}
|
|
1141
1402
|
if (msg.type === 'func_result_msg') {
|
|
@@ -1143,6 +1404,12 @@ async function buildChatCompletionMessages(systemPrompt, context, requestContext
|
|
|
1143
1404
|
input.push(...(await funcResultToChatCompletionMessages(msg, toolResultMaxChars, requestContext, options?.providerConfig, allowedImageKeys, options?.onToolResultImageIngest)));
|
|
1144
1405
|
continue;
|
|
1145
1406
|
}
|
|
1407
|
+
if (msg.type === 'environment_msg' ||
|
|
1408
|
+
msg.type === 'prompting_msg' ||
|
|
1409
|
+
msg.type === 'tellask_result_msg' ||
|
|
1410
|
+
msg.type === 'tellask_carryover_msg') {
|
|
1411
|
+
assistantTurnReasoningContent = undefined;
|
|
1412
|
+
}
|
|
1146
1413
|
const mapped = (msg.type === 'prompting_msg' ||
|
|
1147
1414
|
msg.type === 'tellask_result_msg' ||
|
|
1148
1415
|
msg.type === 'tellask_carryover_msg') &&
|
|
@@ -1150,7 +1417,9 @@ async function buildChatCompletionMessages(systemPrompt, context, requestContext
|
|
|
1150
1417
|
msg.contentItems.length > 0
|
|
1151
1418
|
? await userLikeMessageToChatCompletionMessageWithImages(msg, requestContext, options?.providerConfig, allowedImageKeys, options?.onUserImageIngest)
|
|
1152
1419
|
: chatMessageToChatCompletionMessage(msg);
|
|
1153
|
-
|
|
1420
|
+
const reasoningContent = takePendingReasoningContent();
|
|
1421
|
+
noteAssistantTurnReasoningContent(reasoningContent);
|
|
1422
|
+
input.push(attachReasoningContent(mapped, reasoningContent));
|
|
1154
1423
|
}
|
|
1155
1424
|
flushPendingReasoningAsAssistantMessage();
|
|
1156
1425
|
return mergeAdjacentMessages(input);
|
|
@@ -1506,14 +1775,19 @@ class OpenAiCompatibleGen {
|
|
|
1506
1775
|
onUserImageIngest: receiver.userImageIngest,
|
|
1507
1776
|
});
|
|
1508
1777
|
const openAiParams = agent.model_params?.['openai-compatible'] || {};
|
|
1509
|
-
const parallelToolCalls =
|
|
1778
|
+
const parallelToolCalls = resolveOpenAiCompatibleParallelToolCalls({
|
|
1779
|
+
providerConfig,
|
|
1780
|
+
openAiParams,
|
|
1781
|
+
});
|
|
1510
1782
|
const responseFormat = buildChatCompletionResponseFormat(openAiParams);
|
|
1511
1783
|
const requestTools = resolveOpenAiCompatibleRequestTools(funcTools, requestContext);
|
|
1512
1784
|
const modelInfo = resolveOpenAiCompatibleRequestModelInfo(providerConfig, agent, requestContext);
|
|
1513
1785
|
const toolChoice = resolveOpenAiCompatibleToolChoice(requestTools, requestContext, modelInfo);
|
|
1514
1786
|
const openAiCompatibleExtraParams = buildOpenAiCompatibleExtraParams({
|
|
1787
|
+
providerConfig,
|
|
1515
1788
|
agent,
|
|
1516
1789
|
openAiParams,
|
|
1790
|
+
requestContext,
|
|
1517
1791
|
});
|
|
1518
1792
|
const payload = {
|
|
1519
1793
|
model: agent.model,
|
|
@@ -1528,9 +1802,11 @@ class OpenAiCompatibleGen {
|
|
|
1528
1802
|
...(openAiParams.top_p !== undefined && { top_p: openAiParams.top_p }),
|
|
1529
1803
|
...openAiCompatibleExtraParams,
|
|
1530
1804
|
...(responseFormat !== undefined && { response_format: responseFormat }),
|
|
1531
|
-
...(requestTools.length > 0
|
|
1805
|
+
...(requestTools.length > 0
|
|
1806
|
+
? { tools: requestTools.map((tool) => funcToolToChatCompletionTool(tool, providerConfig)) }
|
|
1807
|
+
: {}),
|
|
1532
1808
|
...(toolChoice !== undefined && { tool_choice: toolChoice }),
|
|
1533
|
-
parallel_tool_calls: parallelToolCalls,
|
|
1809
|
+
...(parallelToolCalls !== undefined && { parallel_tool_calls: parallelToolCalls }),
|
|
1534
1810
|
};
|
|
1535
1811
|
try {
|
|
1536
1812
|
const stream = await client.chat.completions.create(payload, {
|
|
@@ -1588,14 +1864,19 @@ class OpenAiCompatibleGen {
|
|
|
1588
1864
|
},
|
|
1589
1865
|
});
|
|
1590
1866
|
const openAiParams = agent.model_params?.['openai-compatible'] || {};
|
|
1591
|
-
const parallelToolCalls =
|
|
1867
|
+
const parallelToolCalls = resolveOpenAiCompatibleParallelToolCalls({
|
|
1868
|
+
providerConfig,
|
|
1869
|
+
openAiParams,
|
|
1870
|
+
});
|
|
1592
1871
|
const responseFormat = buildChatCompletionResponseFormat(openAiParams);
|
|
1593
1872
|
const requestTools = resolveOpenAiCompatibleRequestTools(funcTools, requestContext);
|
|
1594
1873
|
const modelInfo = resolveOpenAiCompatibleRequestModelInfo(providerConfig, agent, requestContext);
|
|
1595
1874
|
const toolChoice = resolveOpenAiCompatibleToolChoice(requestTools, requestContext, modelInfo);
|
|
1596
1875
|
const openAiCompatibleExtraParams = buildOpenAiCompatibleExtraParams({
|
|
1876
|
+
providerConfig,
|
|
1597
1877
|
agent,
|
|
1598
1878
|
openAiParams,
|
|
1879
|
+
requestContext,
|
|
1599
1880
|
});
|
|
1600
1881
|
const payload = {
|
|
1601
1882
|
model: agent.model,
|
|
@@ -1608,9 +1889,11 @@ class OpenAiCompatibleGen {
|
|
|
1608
1889
|
...(openAiParams.top_p !== undefined && { top_p: openAiParams.top_p }),
|
|
1609
1890
|
...openAiCompatibleExtraParams,
|
|
1610
1891
|
...(responseFormat !== undefined && { response_format: responseFormat }),
|
|
1611
|
-
...(requestTools.length > 0 && {
|
|
1892
|
+
...(requestTools.length > 0 && {
|
|
1893
|
+
tools: requestTools.map((tool) => funcToolToChatCompletionTool(tool, providerConfig)),
|
|
1894
|
+
}),
|
|
1612
1895
|
...(toolChoice !== undefined && { tool_choice: toolChoice }),
|
|
1613
|
-
parallel_tool_calls: parallelToolCalls,
|
|
1896
|
+
...(parallelToolCalls !== undefined && { parallel_tool_calls: parallelToolCalls }),
|
|
1614
1897
|
};
|
|
1615
1898
|
try {
|
|
1616
1899
|
const response = await client.chat.completions.create(payload, {
|
|
@@ -148,11 +148,11 @@ function getMemoryPromptCopy(ctx) {
|
|
|
148
148
|
const taskdocLogLineZh = ctx.contextHealthPromptMode === 'critical'
|
|
149
149
|
? ctx.isSideDialog
|
|
150
150
|
? '当前是告急处置态:支线对话不要维护差遣牒,也不要整理差遣牒更新提案;把当前对话历史中下一程需要知道的讨论细节、下一步、关键定位、运行/验证信息、临时路径/ID/样例输入和恢复依据写入接续包提醒项。提醒项长度没有技术限制,宁可完整一些;允许多条粗略提醒项求稳,但不要在当前程提前做“新一程清醒复核”。系统真正开启新一程后,第一步再复核整理:删除冗余、纠正偏激/失真思路,再收敛成高质量提醒项。'
|
|
151
|
-
: '不要把长日志/大段 tool output 直接塞进差遣牒;差遣牒只写结论+下一步。当前是告急处置态:先检查当前对话历史里尚未落文档的讨论细节;能作为全队共享状态/决策/约束/目标的,主线优先用 `do_mind`
|
|
151
|
+
: '不要把长日志/大段 tool output 直接塞进差遣牒;差遣牒只写结论+下一步。当前是告急处置态:先检查当前对话历史里尚未落文档的讨论细节;能作为全队共享状态/决策/约束/目标的,主线优先用 `do_mind` 新增章节保存;只有在确实需要改写已有章节、已完成合并且能带上当前 `content_hash` 作为 `previous_content_hash` 时,才用 `change_mind`。接续包提醒项只留差遣牒仍未覆盖、但恢复工作容易丢的细节;本程允许先保留多条粗略提醒项求稳,但不要在当前程提前做“新一程清醒复核”。系统真正开启新一程后,第一步再复核整理:删除冗余、纠正偏激/失真思路,再收敛成高质量提醒项。'
|
|
152
152
|
: ctx.contextHealthPromptMode === 'caution'
|
|
153
153
|
? ctx.isSideDialog
|
|
154
154
|
? '当前是吃紧处置态:支线对话不要维护差遣牒,也不要整理差遣牒更新提案;把当前对话历史中下一程需要知道的讨论细节、下一步、关键定位、运行/验证信息、临时路径/ID/样例输入和恢复依据写入接续包提醒项。提醒项长度没有技术限制,宁可完整一些;若一时来不及,可先保留多条粗略提醒项过桥,但不要在当前程提前做“新一程清醒复核”。系统真正开启新一程后,第一步再复核整理:删除冗余、纠正偏激/失真思路,再收敛成高质量提醒项。'
|
|
155
|
-
: '不要把长日志/大段 tool output 直接塞进差遣牒;差遣牒只写结论+下一步。当前是吃紧处置态:先检查当前对话历史里尚未落文档的讨论细节;能作为全队共享状态/决策/约束/目标的,主线优先用 `do_mind`
|
|
155
|
+
: '不要把长日志/大段 tool output 直接塞进差遣牒;差遣牒只写结论+下一步。当前是吃紧处置态:先检查当前对话历史里尚未落文档的讨论细节;能作为全队共享状态/决策/约束/目标的,主线优先用 `do_mind` 新增章节保存;只有在确实需要改写已有章节、已完成合并且能带上当前 `content_hash` 作为 `previous_content_hash` 时,才用 `change_mind`。接续包提醒项只留差遣牒仍未覆盖、但恢复工作容易丢的细节;若一时来不及,可先保留多条粗略提醒项过桥,但不要在当前程提前做“新一程清醒复核”。系统真正开启新一程后,第一步再复核整理:删除冗余、纠正偏激/失真思路,再收敛成高质量提醒项。'
|
|
156
156
|
: '不要把长日志/大段 tool output 直接塞进差遣牒;差遣牒只写结论+下一步;提醒项也只留可扫读摘录。接续包提醒项默认应保持结构化、便于快速恢复。';
|
|
157
157
|
const contextHealthLineEn = ctx.contextHealthPromptMode === 'critical'
|
|
158
158
|
? ctx.isSideDialog
|
|
@@ -166,11 +166,11 @@ function getMemoryPromptCopy(ctx) {
|
|
|
166
166
|
const taskdocLogLineEn = ctx.contextHealthPromptMode === 'critical'
|
|
167
167
|
? ctx.isSideDialog
|
|
168
168
|
? 'Current mode is critical remediation: in a Side Dialog, do not maintain Taskdoc and do not draft Taskdoc update proposals. Put discussion details from current dialog history that the next course needs to know, next actions, key pointers, run/verify info, volatile paths/IDs/sample inputs, and resume reasoning into continuation-package reminders. Reminder length has no technical limit, so prefer being complete. Rough multi-reminder bridge notes are acceptable in this course, but do not perform the new-course “clear-headed review” early. Once the system actually starts the new course, the first step is to review/rewrite them: remove redundancy, correct biased or distorted bridge notes, then compress them into high-quality reminders.'
|
|
169
|
-
: 'Do not paste long logs/tool outputs into Taskdoc; Taskdoc should record decisions + next steps. Current mode is critical remediation: first review current-dialog discussion details not yet written into documentation. If they belong to team-shared state, decisions, constraints, or goals, prefer creating a new section with `do_mind`; use `change_mind` only when an existing section truly needs rewriting
|
|
169
|
+
: 'Do not paste long logs/tool outputs into Taskdoc; Taskdoc should record decisions + next steps. Current mode is critical remediation: first review current-dialog discussion details not yet written into documentation. If they belong to team-shared state, decisions, constraints, or goals, prefer creating a new section with `do_mind`; use `change_mind` only when an existing section truly needs rewriting, you have merged against the current content, and you can pass the current `content_hash` as `previous_content_hash`. Continuation-package reminders should keep only details still not covered by Taskdoc but easy to lose during resume. Rough multi-reminder bridge notes are acceptable in this course, but do not perform the new-course “clear-headed review” early. Once the system actually starts the new course, the first step is to review/rewrite them: remove redundancy, correct biased or distorted bridge notes, then compress them into high-quality reminders.'
|
|
170
170
|
: ctx.contextHealthPromptMode === 'caution'
|
|
171
171
|
? ctx.isSideDialog
|
|
172
172
|
? 'Current mode is caution remediation: in a Side Dialog, do not maintain Taskdoc and do not draft Taskdoc update proposals. Put discussion details from current dialog history that the next course needs to know, next actions, key pointers, run/verify info, volatile paths/IDs/sample inputs, and resume reasoning into continuation-package reminders. Reminder length has no technical limit, so prefer being complete. If needed, rough multi-reminder bridge notes are acceptable, but do not perform the new-course “clear-headed review” early. Once the system actually starts the new course, the first step is to review/rewrite them: remove redundancy, correct biased or distorted bridge notes, then compress them into high-quality reminders.'
|
|
173
|
-
: 'Do not paste long logs/tool outputs into Taskdoc; Taskdoc should record decisions + next steps. Current mode is caution remediation: first review current-dialog discussion details not yet written into documentation. If they belong to team-shared state, decisions, constraints, or goals, prefer creating a new section with `do_mind`; use `change_mind` only when an existing section truly needs rewriting
|
|
173
|
+
: 'Do not paste long logs/tool outputs into Taskdoc; Taskdoc should record decisions + next steps. Current mode is caution remediation: first review current-dialog discussion details not yet written into documentation. If they belong to team-shared state, decisions, constraints, or goals, prefer creating a new section with `do_mind`; use `change_mind` only when an existing section truly needs rewriting, you have merged against the current content, and you can pass the current `content_hash` as `previous_content_hash`. Continuation-package reminders should keep only details still not covered by Taskdoc but easy to lose during resume. If needed, rough multi-reminder bridge notes are acceptable, but do not perform the new-course “clear-headed review” early. Once the system actually starts the new course, the first step is to review/rewrite them: remove redundancy, correct biased or distorted bridge notes, then compress them into high-quality reminders.'
|
|
174
174
|
: 'Do not paste long logs/tool outputs into Taskdoc; Taskdoc should record decisions + next steps; reminders should also keep only scannable excerpts. Keep continuation-package reminders structured and fast to resume from by default.';
|
|
175
175
|
if (ctx.language === 'zh') {
|
|
176
176
|
return {
|
|
@@ -181,7 +181,7 @@ function getMemoryPromptCopy(ctx) {
|
|
|
181
181
|
taskdocSemanticsLine: '- 章节语义约定:`progress` 是全队共享、准实时、可扫读的任务公告牌,用来记录当前有效状态、关键决策、下一步与仍成立阻塞;不是流水账,也不是个人工作记录。`goals` / `constraints` 是较稳定的任务契约;每次更新都必须保留仍然有效的他人条目。',
|
|
182
182
|
taskdocSectionReplaceLine: ctx.isSideDialog && ctx.contextHealthPromptMode !== 'normal'
|
|
183
183
|
? '- 当前处于支线对话的上下文健康处置态:本程不要维护差遣牒,也不要整理差遣牒更新提案;把下一程需要恢复的细节写入足够详尽的接续包提醒项。'
|
|
184
|
-
: `- 更新差遣牒时:少量新增条目可用 \`mind_more\` 追加(默认 progress);缺失章节用 \`do_mind\` 创建;需要删除陈旧项、重排结构或压缩时,用 \`change_mind\`
|
|
184
|
+
: `- 更新差遣牒时:少量新增条目可用 \`mind_more\` 追加(默认 progress);缺失章节用 \`do_mind\` 创建;需要删除陈旧项、重排结构或压缩时,用 \`change_mind\` 整章替换并先对照“上下文中注入的当前内容”做合并,同时带上当前 \`content_hash\` 作为 \`previous_content_hash\`;需要删除整章文件时用 \`never_mind\`;禁止覆盖/抹掉他人条目;自己负责维护的条目必须标注责任人(例如 \`- [owner:@${ctx.agentId}] ...\` 或用 \`### @${ctx.agentId}\` 分块)。`,
|
|
185
185
|
progressLine: ctx.isSideDialog && ctx.contextHealthPromptMode !== 'normal'
|
|
186
186
|
? '- 当前处于支线对话的上下文健康处置态:本程不更新 `progress`;只把下一程接续所需信息写入提醒项。'
|
|
187
187
|
: '- 更新 `progress` 时:它必须始终是可供全队扫读的完整当前快照,而不是只追加自己这一轮的零散笔记。',
|
|
@@ -202,7 +202,7 @@ function getMemoryPromptCopy(ctx) {
|
|
|
202
202
|
sideDialogWorkflowLine: ctx.contextHealthPromptMode === 'normal'
|
|
203
203
|
? `工作流:先做事 → 再提炼(\`update_reminder\`;必要时整理差遣牒追加条目/更新提案并诉请 \`@${ctx.taskdocMaintainerId}\` 合并写入)→ 然后 \`clear_mind\` 清空噪音。`
|
|
204
204
|
: '工作流:停止扩张上下文 → 维护足够详尽的接续包提醒项(`add_reminder` 或 `update_reminder`,长度没有技术限制)→ 然后 `clear_mind` 开启新一程。',
|
|
205
|
-
mainDialogWorkflowLine: '工作流:先做事
|
|
205
|
+
mainDialogWorkflowLine: '工作流:先做事 -> 再提炼(`update_reminder` + `mind_more(progress)`;需要压缩/删旧时用带 `previous_content_hash` 的 `change_mind`;要删除整章文件时用 `never_mind`)-> 然后 `clear_mind` 清空噪音。',
|
|
206
206
|
contextHealthLine: contextHealthLineZh,
|
|
207
207
|
taskdocLogLine: taskdocLogLineZh,
|
|
208
208
|
};
|
|
@@ -215,7 +215,7 @@ function getMemoryPromptCopy(ctx) {
|
|
|
215
215
|
taskdocSemanticsLine: '- Section semantics: `progress` is the team-shared, quasi-real-time, scannable task bulletin board for current effective state, key decisions, next steps, and still-active blockers; it is not a raw log or personal work record. `goals` / `constraints` are the more stable task contract; every update must preserve still-valid entries from others.',
|
|
216
216
|
taskdocSectionReplaceLine: ctx.isSideDialog && ctx.contextHealthPromptMode !== 'normal'
|
|
217
217
|
? '- Current mode is context-health remediation in a Side Dialog: do not maintain Taskdoc and do not draft Taskdoc update proposals in this course; put resume-critical details into sufficiently detailed continuation-package reminders.'
|
|
218
|
-
: `- When updating Taskdoc: use \`mind_more\` for small append-only additions (defaults to progress); create missing sections with \`do_mind\`; when stale entries must be removed, reordered, or compressed, use \`change_mind\` for a full-section replacement based on the current injected content
|
|
218
|
+
: `- When updating Taskdoc: use \`mind_more\` for small append-only additions (defaults to progress); create missing sections with \`do_mind\`; when stale entries must be removed, reordered, or compressed, use \`change_mind\` for a full-section replacement based on the current injected content and include the current \`content_hash\` as \`previous_content_hash\`; when a whole section file should be removed, use \`never_mind\`; do not overwrite other contributors; add an explicit owner tag for entries you maintain (e.g., \`- [owner:@${ctx.agentId}] ...\` or a \`### @${ctx.agentId}\` block).`,
|
|
219
219
|
progressLine: ctx.isSideDialog && ctx.contextHealthPromptMode !== 'normal'
|
|
220
220
|
? '- Current mode is context-health remediation in a Side Dialog: do not update `progress` in this course; put resume-critical information into reminders only.'
|
|
221
221
|
: '- When updating `progress`, keep it as a complete, team-scannable current snapshot instead of appending only your own latest notes.',
|
|
@@ -236,7 +236,7 @@ function getMemoryPromptCopy(ctx) {
|
|
|
236
236
|
sideDialogWorkflowLine: ctx.contextHealthPromptMode === 'normal'
|
|
237
237
|
? `Workflow: do work → distill (\`update_reminder\`; when Taskdoc needs updates, draft append entries, a merged replacement, or a section deletion and ask \`@${ctx.taskdocMaintainerId}\`) → then \`clear_mind\` to drop noise.`
|
|
238
238
|
: 'Workflow: stop expanding context → maintain sufficiently detailed continuation-package reminders (`add_reminder` or `update_reminder`, with no technical length limit) → then `clear_mind` to start a new course.',
|
|
239
|
-
mainDialogWorkflowLine: 'Workflow: do work
|
|
239
|
+
mainDialogWorkflowLine: 'Workflow: do work -> distill (`update_reminder` + `mind_more(progress)`; use `change_mind` with `previous_content_hash` when compression/deletion is needed; use `never_mind` when removing a whole section file) -> then `clear_mind` to drop noise.',
|
|
240
240
|
contextHealthLine: contextHealthLineEn,
|
|
241
241
|
taskdocLogLine: taskdocLogLineEn,
|
|
242
242
|
};
|
|
@@ -407,7 +407,7 @@ function formatAgentFacingContextHealthV3RemediationGuide(language, args) {
|
|
|
407
407
|
'',
|
|
408
408
|
'操作:',
|
|
409
409
|
'- 优先新增差遣牒章节保存讨论细节:do_mind({ "category": "<category>", "selector": "<selector>", "content": "..." })',
|
|
410
|
-
'-
|
|
410
|
+
'- 只有在确实需要改写已有章节、且已对照当前差遣牒内容完成合并并带上 `previous_content_hash` 时,才更新:change_mind({"selector":"<selector>","content":"...","previous_content_hash":"sha256:..."})',
|
|
411
411
|
'- 优先新增过桥提醒项:add_reminder({ "content": "..." })',
|
|
412
412
|
'- 只有在确实能就地复用现有提醒项、且不会额外增加当前程认知负担时,才更新:update_reminder({ "reminder_id": "<现有 reminder_id>", "content": "..." })',
|
|
413
413
|
].join('\n');
|
|
@@ -443,7 +443,7 @@ function formatAgentFacingContextHealthV3RemediationGuide(language, args) {
|
|
|
443
443
|
'',
|
|
444
444
|
'操作:',
|
|
445
445
|
'- 优先新增差遣牒章节保存讨论细节:do_mind({ "category": "<category>", "selector": "<selector>", "content": "..." })',
|
|
446
|
-
'-
|
|
446
|
+
'- 只有在确实需要改写已有章节、且已对照当前差遣牒内容完成合并并带上 `previous_content_hash` 时,才更新:change_mind({"selector":"<selector>","content":"...","previous_content_hash":"sha256:..."})',
|
|
447
447
|
'- 优先新增过桥提醒项:add_reminder({ "content": "..." })',
|
|
448
448
|
'- 只有在确实能就地复用现有提醒项、且不会额外增加当前程认知负担时,才更新:update_reminder({ "reminder_id": "<现有 reminder_id>", "content": "..." })',
|
|
449
449
|
'- clear_mind({})',
|
|
@@ -484,7 +484,7 @@ function formatAgentFacingContextHealthV3RemediationGuide(language, args) {
|
|
|
484
484
|
'',
|
|
485
485
|
'Operations:',
|
|
486
486
|
'- Prefer creating a new Taskdoc section for discussion details: do_mind({ "category": "<category>", "selector": "<selector>", "content": "..." })',
|
|
487
|
-
'- Only update when an existing section truly needs rewriting and you have merged against the current Taskdoc content
|
|
487
|
+
'- Only update when an existing section truly needs rewriting and you have merged against the current Taskdoc content and can provide `previous_content_hash`: change_mind({"selector":"<selector>","content":"...","previous_content_hash":"sha256:..."})',
|
|
488
488
|
'- Prefer adding a bridge reminder first: add_reminder({ "content": "..." })',
|
|
489
489
|
'- Only if an existing reminder is clearly the right place, and updating it would not add extra cognitive load in the current course: update_reminder({ "reminder_id": "<existing reminder_id>", "content": "..." })',
|
|
490
490
|
].join('\n');
|
|
@@ -520,7 +520,7 @@ function formatAgentFacingContextHealthV3RemediationGuide(language, args) {
|
|
|
520
520
|
'',
|
|
521
521
|
'Operations:',
|
|
522
522
|
'- Prefer creating a new Taskdoc section for discussion details: do_mind({ "category": "<category>", "selector": "<selector>", "content": "..." })',
|
|
523
|
-
'- Only update when an existing section truly needs rewriting and you have merged against the current Taskdoc content
|
|
523
|
+
'- Only update when an existing section truly needs rewriting and you have merged against the current Taskdoc content and can provide `previous_content_hash`: change_mind({"selector":"<selector>","content":"...","previous_content_hash":"sha256:..."})',
|
|
524
524
|
'- Prefer adding a bridge reminder first: add_reminder({ "content": "..." })',
|
|
525
525
|
'- Only if an existing reminder is clearly the right place, and updating it would not add extra cognitive load in the current course: update_reminder({ "reminder_id": "<existing reminder_id>", "content": "..." })',
|
|
526
526
|
'- clear_mind({})',
|
package/dist/team.d.ts
CHANGED
|
@@ -55,6 +55,7 @@ export declare namespace Team {
|
|
|
55
55
|
web_search_allowed_domains?: string[];
|
|
56
56
|
web_search_include_sources?: boolean;
|
|
57
57
|
};
|
|
58
|
+
type OpenAiCompatibleThinkingMode = 'auto' | 'off' | 'low' | 'medium' | 'high';
|
|
58
59
|
type OpenAiCompatibleModelParams = {
|
|
59
60
|
temperature?: number;
|
|
60
61
|
service_tier?: 'auto' | 'default' | 'flex' | 'scale' | 'priority';
|
|
@@ -66,7 +67,7 @@ export declare namespace Team {
|
|
|
66
67
|
text_format_json_schema?: string;
|
|
67
68
|
text_format_json_schema_strict?: boolean;
|
|
68
69
|
reasoning_effort?: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
69
|
-
thinking?: boolean | Record<string, unknown>;
|
|
70
|
+
thinking?: boolean | OpenAiCompatibleThinkingMode | Record<string, unknown>;
|
|
70
71
|
};
|
|
71
72
|
type AnthropicThinkingConfig = {
|
|
72
73
|
type: 'adaptive';
|
package/dist/team.js
CHANGED
|
@@ -2322,7 +2322,17 @@ exports.Team = Team;
|
|
|
2322
2322
|
asOptionalString(params.text_format_json_schema_name, `${at2}.text_format_json_schema_name`);
|
|
2323
2323
|
asOptionalString(params.text_format_json_schema, `${at2}.text_format_json_schema`);
|
|
2324
2324
|
asOptionalBoolean(params.text_format_json_schema_strict, `${at2}.text_format_json_schema_strict`);
|
|
2325
|
-
|
|
2325
|
+
const thinking = params.thinking;
|
|
2326
|
+
if (thinking !== undefined &&
|
|
2327
|
+
typeof thinking !== 'boolean' &&
|
|
2328
|
+
!isRecordValue(thinking) &&
|
|
2329
|
+
thinking !== 'auto' &&
|
|
2330
|
+
thinking !== 'off' &&
|
|
2331
|
+
thinking !== 'low' &&
|
|
2332
|
+
thinking !== 'medium' &&
|
|
2333
|
+
thinking !== 'high') {
|
|
2334
|
+
throw new Error(`Invalid ${at2}.thinking: expected boolean|object|auto|off|low|medium|high (got ${describeValueType(thinking)})`);
|
|
2335
|
+
}
|
|
2326
2336
|
const serviceTier = params.service_tier;
|
|
2327
2337
|
if (serviceTier !== undefined &&
|
|
2328
2338
|
serviceTier !== 'auto' &&
|