@microi.net/cli 5.9.2 → 5.9.4
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/.codebuddy-plugin/marketplace.json +2 -2
- package/.codebuddy-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.mcp.json +1 -1
- package/.workbuddy-plugin/marketplace.json +2 -2
- package/.workbuddy-plugin/plugin.json +1 -1
- package/assets/build-meta.json +6 -6
- package/cordis.patch.yml +1 -1
- package/package.json +1 -1
- package/scripts/codex-marketplace.json +20 -20
- package/scripts/mcp-codex-stdio-adapter.js +189 -189
- package/scripts/mcp-server.js +81 -81
- package/scripts/mcp-trae-windows-launcher.cmd +21 -21
- package/scripts/microi-cli-mcp.js +7 -7
- package/scripts/microi-codex-broker.js +21 -5
- package/scripts/microi-codex-router.js +17 -1
- package/scripts/microi-skills.meta.json +354 -348
- package/skills/.microi-skills-version.json +2 -2
- package/skills/.progressive-disclosure-manifest.json +122 -115
- package/skills/README.md +287 -287
- package/skills/ai-engine/SKILL.md +269 -269
- package/skills/ai-engine/references/ai-employees.md +48 -48
- package/skills/ai-engine/references/self-hosted-digital-human.md +59 -59
- package/skills/ai-platform-governance/SKILL.md +177 -177
- package/skills/ai-platform-governance/references/progressive-01-/345/212/237/350/203/275/345/274/200/345/205/263.md +190 -190
- package/skills/app-store/SKILL.md +525 -525
- package/skills/business-blueprint/SKILL.md +193 -193
- package/skills/datasource-engine/SKILL.md +93 -93
- package/skills/dos-orm/SKILL.md +101 -95
- package/skills/dos-orm/references/api-reference.md +229 -229
- package/skills/email-engine/SKILL.md +81 -81
- package/skills/email-engine/references/v8-email.md +34 -34
- package/skills/job-engine/SKILL.md +176 -176
- package/skills/message-notification/SKILL.md +156 -156
- package/skills/message-notification/references/contracts.md +102 -102
- package/skills/microi/SKILL.md +14 -14
- package/skills/microi-ai-application/SKILL.md +115 -115
- package/skills/microi-ai-application/references/frontend-baseline.md +164 -164
- package/skills/microi-client-frontend/SKILL.md +242 -242
- package/skills/microi-client-frontend/references/progressive-01-3-/345/212/250/346/200/201/346/214/211/351/222/256/347/263/273/347/273/237.md +144 -144
- package/skills/microi-client-frontend/references/progressive-02-8-/350/277/220/350/241/214/346/227/266/351/253/230/351/242/221/345/235/221/345/244/215/347/233/230.md +196 -196
- package/skills/microi-client-frontend/references/progressive-03-vue3-/345/211/215/347/253/257/345/276/256/346/234/215/345/212/241/345/256/277/344/270/273/350/247/204/345/210/231.md +167 -167
- package/skills/microi-codex-installer/SKILL.md +231 -231
- package/skills/microi-datasource-mapping/SKILL.md +122 -122
- package/skills/microi-db-schema/SKILL.md +175 -175
- package/skills/microi-db-schema/references/core-tables.md +695 -695
- package/skills/microi-db-schema/references/form-component-options.md +256 -256
- package/skills/microi-db-schema/references/schema-overview.md +202 -202
- package/skills/microi-db-schema/references/schema.md +646 -646
- package/skills/microi-db-schema/references/table-catalog.md +1599 -1599
- package/skills/microi-deployment/SKILL.md +239 -220
- package/skills/microi-deployment/references/deployment-matrix.md +109 -109
- package/skills/microi-docs-coverage/SKILL.md +133 -133
- package/skills/microi-docs-coverage/references/capability-map.md +90 -90
- package/skills/microi-form-engine/SKILL.md +338 -333
- package/skills/microi-form-engine/references/component-catalog.md +218 -218
- package/skills/microi-form-engine/references/data-source-events.md +124 -124
- package/skills/microi-frontend-sdk/SKILL.md +194 -194
- package/skills/microi-frontend-sdk/references/progressive-01-token-/345/275/223/345/211/215/347/231/273/345/275/225/347/224/250/346/210/267/344/270/216/345/275/223/345/211/215/347/273/210/347/253/257/347/231/273/345/275/225/345/215/217/350/256/256.md +176 -176
- package/skills/microi-left-right-layout/SKILL.md +141 -141
- package/skills/microi-microservice/SKILL.md +332 -328
- package/skills/microi-microservice/references/runtime-delivery.md +282 -278
- package/skills/microi-mobile-app-quality/SKILL.md +203 -203
- package/skills/microi-mobile-app-quality/references/progressive-01-4-/351/207/215/350/246/201/346/214/211/351/222/256/345/277/205/351/241/273/345/270/246/345/233/276/346/240/207.md +227 -227
- package/skills/microi-mobile-app-quality/references/progressive-02-9-/344/270/273/351/242/230/345/210/207/346/215/242/345/277/205/351/241/273/347/234/237/345/256/236/344/270/224/345/205/250/345/261/200/347/224/237/346/225/210.md +129 -129
- package/skills/microi-solution-quotation/SKILL.md +78 -78
- package/skills/microi-sso/SKILL.md +95 -91
- package/skills/microi-sso/references/acceptance.md +51 -49
- package/skills/microi-sso/references/configuration-and-security.md +53 -53
- package/skills/microi-sso/references/inbound.md +53 -53
- package/skills/microi-sso/references/outbound.md +43 -39
- package/skills/microi-ui/SKILL.md +192 -192
- package/skills/microi-ui/references/progressive-01-/347/247/273/345/212/250/347/253/257/345/234/272/346/231/257/350/223/235/345/233/276.md +183 -183
- package/skills/microi-uniapp-frontend/SKILL.md +206 -204
- package/skills/microi-uniapp-frontend/references/progressive-01-/347/247/273/345/212/250/347/253/257/345/210/206/347/261/273-/345/217/214/346/240/217/345/210/227/350/241/250/347/213/254/347/253/213/346/273/232/345/212/250.md +261 -261
- package/skills/microi-uniapp-frontend/references/progressive-02-/345/205/263/351/224/256/344/270/232/345/212/241/350/265/204/344/272/247/344/270/215/345/276/227/351/273/230/350/256/244/351/200/211/344/270/255.md +154 -154
- package/skills/module-engine/SKILL.md +255 -255
- package/skills/module-engine/references/module-config.md +204 -204
- package/skills/ocr-engine/SKILL.md +113 -113
- package/skills/page-engine/SKILL.md +206 -206
- package/skills/page-engine/references/progressive-01-/346/211/200/346/234/211/347/273/204/344/273/266/347/261/273/345/236/213.md +234 -234
- package/skills/page-engine/references/progressive-02-/347/211/210/346/234/254/345/216/206/345/217/262-/345/271/266/345/217/221/344/277/235/345/255/230/344/270/216/345/233/236/346/273/232.md +60 -60
- package/skills/performance-testing/SKILL.md +227 -221
- package/skills/playwright-e2e/SKILL.md +197 -196
- package/skills/playwright-e2e/references/progressive-01-/345/205/250/350/207/252/345/212/250/347/231/273/345/275/225-/345/205/215/351/252/214/350/257/201/347/240/201-/344/275/206/344/270/215/345/205/215/345/257/206/347/240/201-/345/277/205/350/257/273.md +173 -173
- package/skills/playwright-e2e/references/progressive-02-/346/226/207/345/255/227/345/257/271/346/257/224/345/272/246/344/270/216/345/217/257/350/257/273/346/200/247/350/207/252/345/212/250/345/214/226/346/243/200/346/237/245-/345/277/205/345/201/232.md +183 -183
- package/skills/playwright-e2e/references/progressive-03-microi-helper-/346/250/241/346/235/277.md +221 -221
- package/skills/playwright-e2e/references/progressive-04-ci-/345/273/272/350/256/256.md +115 -115
- package/skills/print-engine/SKILL.md +259 -259
- package/skills/production-readonly-audit/SKILL.md +41 -41
- package/skills/report-engine/SKILL.md +71 -71
- package/skills/search-engine/SKILL.md +75 -75
- package/skills/spider-engine/SKILL.md +190 -190
- package/skills/system-observability/SKILL.md +259 -246
- package/skills/system-observability/references/memory-incident-triage.md +77 -77
- package/skills/translate-engine/SKILL.md +140 -140
- package/skills/ui-design/SKILL.md +223 -223
- package/skills/ui-design/assets/templates/MCI-DESIGN.md +206 -206
- package/skills/ui-design/references/design-pattern-library.md +184 -184
- package/skills/ui-design/references/mci-design-contract.md +163 -163
- package/skills/ui-design/references/motion-and-media.md +78 -78
- package/skills/ui-design/references/product-flow-recipes.md +94 -94
- package/skills/ui-design/references/progressive-01-/351/242/234/350/211/262/344/275/223/347/263/273-css-variables-/346/224/257/346/214/201/344/270/273/351/242/230/345/210/207/346/215/242.md +218 -218
- package/skills/ui-design/references/progressive-02-/345/255/227/344/275/223.md +164 -164
- package/skills/ui-design/references/progressive-03-/345/212/250/346/225/210/350/247/204/350/214/203-/344/270/260/345/257/214/344/275/206/344/270/215/345/215/241.md +235 -235
- package/skills/ui-design/references/progressive-04-/347/273/204/344/273/266/351/243/216/346/240/274/351/200/237/346/237/245.md +152 -152
- package/skills/ui-design/references/progressive-05-/347/247/273/345/212/250/347/253/257/344/270/223/347/224/250/350/247/204/350/214/203.md +238 -238
- package/skills/ui-design/references/progressive-06-/344/270/273/351/242/230/345/210/207/346/215/242/345/256/236/347/216/260.md +194 -194
- package/skills/ui-design/references/progressive-07-/351/200/237/346/237/245-/344/273/216/345/244/264/346/220/255/345/273/272/344/270/200/344/270/252/347/247/273/345/212/250/347/253/257/351/241/265/351/235/242.md +207 -207
- package/skills/ui-design/references/progressive-08-/350/241/250/345/215/225/345/210/206/347/273/204/350/247/204/350/214/203-tabs-vs-collapsegroup-/345/274/272/345/210/266.md +142 -142
- package/skills/uniapp-mall-assets/SKILL.md +176 -176
- package/skills/unity-integration/SKILL.md +178 -171
- package/skills/unity-integration/references/ai-app-delivery.md +119 -119
- package/skills/unity-integration/references/sdk-api.md +82 -82
- package/skills/unity-integration/references/toolbox-migration.md +66 -66
- package/skills/unity-integration/references/webgl-hosting.md +57 -57
- package/skills/v8-api-config/SKILL.md +388 -388
- package/skills/v8-cache-pattern/SKILL.md +312 -312
- package/skills/v8-crud-api/SKILL.md +179 -178
- package/skills/v8-crud-api/references/progressive-01-/346/237/245/350/257/242/345/210/227/350/241/250-/345/210/206/351/241/265.md +226 -226
- package/skills/v8-crud-api/references/progressive-02-where-/346/235/241/344/273/266/350/257/255/346/263/225/351/200/237/346/237/245.md +49 -49
- package/skills/v8-debugging/SKILL.md +284 -284
- package/skills/v8-explorer-tree/SKILL.md +228 -228
- package/skills/v8-export-import/SKILL.md +219 -219
- package/skills/v8-export-import/references/progressive-01-excellayout-/351/253/230/347/272/247/350/207/252/347/224/261/345/270/203/345/261/200.md +211 -211
- package/skills/v8-export-import/references/progressive-02-powerpoint-/345/257/274/345/207/272.md +202 -202
- package/skills/v8-export-import/references/progressive-03-/345/256/211/345/205/250-/346/200/247/350/203/275/346/263/250/346/204/217.md +42 -42
- package/skills/v8-file-upload/SKILL.md +255 -284
- package/skills/v8-file-upload/references/cdn-alias-repair.md +13 -0
- package/skills/v8-file-upload/references/progressive-01-/345/205/254/346/234/211/346/241/266-vs-/347/247/201/346/234/211/346/241/266.md +263 -263
- package/skills/v8-file-upload/references/progressive-02-office-/346/226/207/344/273/266/345/234/250/347/272/277/347/274/226/350/276/221/347/211/210/346/234/254/345/217/267/350/247/204/345/210/231.md +161 -161
- package/skills/v8-file-upload/references/progressive-03-/347/251/272/347/233/256/345/275/225/346/240/207/350/256/260/344/270/216/350/277/234/347/250/213/344/270/213/350/275/275.md +36 -0
- package/skills/v8-formengine-http/SKILL.md +238 -238
- package/skills/v8-frontend-events/SKILL.md +180 -180
- package/skills/v8-frontend-events/references/bluetooth-print-api.md +135 -135
- package/skills/v8-frontend-events/references/bluetooth-print.md +258 -258
- package/skills/v8-frontend-events/references/progressive-01-/345/210/227/350/241/250/344/272/213/344/273/266.md +219 -219
- package/skills/v8-http-integration/SKILL.md +182 -182
- package/skills/v8-http-integration/references/progressive-01-get-/350/257/267/346/261/202.md +220 -220
- package/skills/v8-http-integration/references/progressive-02-/351/224/231/350/257/257/345/244/204/347/220/206/346/250/241/345/274/217.md +44 -44
- package/skills/v8-image-processing/SKILL.md +190 -190
- package/skills/v8-image-processing/references/api-reference.md +623 -623
- package/skills/v8-menu-buttons/SKILL.md +186 -186
- package/skills/v8-menu-buttons/references/progressive-01-2-/346/214/211/351/222/256/345/257/271/350/261/241-schema.md +222 -222
- package/skills/v8-menu-buttons/references/progressive-02-8-/346/250/241/345/274/217-f-/345/220/216/345/217/260/344/273/273/345/212/241/346/214/211/351/222/256-/351/225/277/344/273/273/345/212/241.md +228 -228
- package/skills/v8-menu-buttons/references/progressive-03-10-/345/217/215/346/250/241/345/274/217-/351/201/277/345/205/215.md +104 -104
- package/skills/v8-mongodb/SKILL.md +200 -200
- package/skills/v8-mq-mqtt/SKILL.md +178 -176
- package/skills/v8-mq-mqtt/references/mqtt-production.md +352 -342
- package/skills/v8-mq-mqtt/references/progressive-01-v8-mqtt-iot-/347/211/251/350/201/224/347/275/221.md +181 -181
- package/skills/v8-saas-multi-tenant/SKILL.md +305 -305
- package/skills/v8-security/SKILL.md +227 -210
- package/skills/v8-security/references/progressive-01-2-/346/235/203/351/231/220/346/240/241/351/252/214.md +200 -200
- package/skills/v8-security/references/progressive-02-7-/346/227/245/345/277/227/350/256/260/345/275/225.md +160 -160
- package/skills/v8-sql-query/SKILL.md +302 -302
- package/skills/v8-table-event/SKILL.md +176 -176
- package/skills/v8-table-event/references/progressive-01-informv8-js-/350/241/250/345/215/225/346/211/223/345/274/200/344/272/213/344/273/266.md +216 -216
- package/skills/v8-table-event/references/progressive-02-/345/211/215/347/253/257/344/272/213/344/273/266/345/220/215-v8-eventname-/345/217/257/350/203/275/347/232/204/345/200/274.md +46 -46
- package/skills/v8-tcp-integration/SKILL.md +158 -147
- package/skills/v8-template-engine/SKILL.md +167 -167
- package/skills/v8-utilities/SKILL.md +104 -104
- package/skills/v8-utilities/references/client-api-index.md +143 -143
- package/skills/v8-utilities/references/platform-http-routes.md +83 -83
- package/skills/v8-utilities/references/server-api-index.md +188 -188
- package/skills/v8-workflow/SKILL.md +252 -252
- package/skills/v8-workflow/references/progressive-01-/350/212/202/347/202/271/345/274/200/345/247/213-v8-/344/272/213/344/273/266.md +180 -180
- package/skills/v8-workflow/references/workflow-configuration.md +49 -49
- package/skills/vision-engine/SKILL.md +160 -160
- package/skills/vision-engine/references/architecture-and-acceptance.md +194 -194
- package/skills/workspace-conventions/SKILL.md +13 -13
- package/skills/workspace-conventions/references/progressive-03-cli-/344/270/216-ide-/346/217/222/344/273/266/351/224/231/347/211/210/345/205/261/345/255/230/347/272/246/345/256/232.md +2 -2
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
setlocal
|
|
3
|
-
|
|
4
|
-
if "%~1"=="" (
|
|
5
|
-
>&2 echo [microi-trae-mcp] Missing Node or Electron runtime path.
|
|
6
|
-
exit /b 2
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
if "%~2"=="" (
|
|
10
|
-
>&2 echo [microi-trae-mcp] Missing MCP adapter path.
|
|
11
|
-
exit /b 2
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
if "%~3"=="" (
|
|
15
|
-
>&2 echo [microi-trae-mcp] Missing MCP server path.
|
|
16
|
-
exit /b 2
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
call "%~1" "%~2" "%~3"
|
|
20
|
-
set "MICROI_MCP_EXIT_CODE=%ERRORLEVEL%"
|
|
21
|
-
endlocal & exit /b %MICROI_MCP_EXIT_CODE%
|
|
1
|
+
@echo off
|
|
2
|
+
setlocal
|
|
3
|
+
|
|
4
|
+
if "%~1"=="" (
|
|
5
|
+
>&2 echo [microi-trae-mcp] Missing Node or Electron runtime path.
|
|
6
|
+
exit /b 2
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
if "%~2"=="" (
|
|
10
|
+
>&2 echo [microi-trae-mcp] Missing MCP adapter path.
|
|
11
|
+
exit /b 2
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
if "%~3"=="" (
|
|
15
|
+
>&2 echo [microi-trae-mcp] Missing MCP server path.
|
|
16
|
+
exit /b 2
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
call "%~1" "%~2" "%~3"
|
|
20
|
+
set "MICROI_MCP_EXIT_CODE=%ERRORLEVEL%"
|
|
21
|
+
endlocal & exit /b %MICROI_MCP_EXIT_CODE%
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
// Keep the configured entry name stable and independent from mcp-server.js.
|
|
5
|
-
// Historical VS Code extensions scanned arguments containing that basename
|
|
6
|
-
// and rewrote them to their own extension directory during activation.
|
|
7
|
-
require('./mcp-server.js');
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// Keep the configured entry name stable and independent from mcp-server.js.
|
|
5
|
+
// Historical VS Code extensions scanned arguments containing that basename
|
|
6
|
+
// and rewrote them to their own extension directory during activation.
|
|
7
|
+
require('./mcp-server.js');
|
|
@@ -24,8 +24,16 @@ const workspaceRoot = path.resolve(String(process.env.MICROI_WORKSPACE_ROOT || p
|
|
|
24
24
|
const mcpServerPath = path.resolve(String(process.env.MICROI_MCP_SERVER_PATH || path.join(__dirname, 'mcp-server.js')));
|
|
25
25
|
const toolVersion = String(process.env.MICROI_TOOL_VERSION || '0.0.0');
|
|
26
26
|
const idleMilliseconds = Math.max(250, Number(process.env.MICROI_CODEX_BROKER_IDLE_MS || 30000));
|
|
27
|
+
// The launching router may not get scheduled again immediately on a busy host.
|
|
28
|
+
// Do not retire the listening pipe before its first client has had time to join.
|
|
29
|
+
const initialClientGraceMilliseconds = Math.max(10000, idleMilliseconds);
|
|
27
30
|
const heartbeatMilliseconds = Math.max(500, Number(process.env.MICROI_CODEX_BROKER_HEARTBEAT_MS || 5000));
|
|
28
31
|
const staleMilliseconds = Math.max(heartbeatMilliseconds * 3, Number(process.env.MICROI_CODEX_BROKER_STALE_MS || 20000));
|
|
32
|
+
function testDiagnostic(message) {
|
|
33
|
+
if (process.env.MICROI_CODEX_TEST_DIAGNOSTICS !== '1' || !process.env.MICROI_CODEX_TEST_LOG) return;
|
|
34
|
+
try { if (!fs.existsSync(process.env.MICROI_CODEX_TEST_LOG) || fs.statSync(process.env.MICROI_CODEX_TEST_LOG).size < 65536) fs.appendFileSync(process.env.MICROI_CODEX_TEST_LOG, `${new Date().toISOString()} ${String(message).slice(0,8192)}\n`); } catch { /* tests report missing evidence */ }
|
|
35
|
+
}
|
|
36
|
+
testDiagnostic(`broker start ${process.version}`);
|
|
29
37
|
|
|
30
38
|
if (!endpoint || !process.env.MICROI_CODEX_BROKER_LEASE) {
|
|
31
39
|
process.stderr.write('[microi-codex-broker] Missing endpoint or lease path.\n');
|
|
@@ -232,9 +240,11 @@ class ChildMcp {
|
|
|
232
240
|
},
|
|
233
241
|
});
|
|
234
242
|
this.child.stdout.on('data', chunk => this.onData(chunk));
|
|
235
|
-
this.child.
|
|
243
|
+
this.child.stdin.on('error', error => this.rejectAll(error));
|
|
244
|
+
this.child.stderr.on('data', chunk => { testDiagnostic(`MCP stderr ${chunk}`); process.stderr.write(`[${this.profile.name}] ${chunk}`); });
|
|
236
245
|
this.child.on('error', error => this.rejectAll(error));
|
|
237
246
|
this.child.on('exit', code => {
|
|
247
|
+
testDiagnostic(`MCP child exit ${code}`);
|
|
238
248
|
this.rejectAll(new Error(`Microi MCP ${this.profile.name} exited (${code ?? 'unknown'})`));
|
|
239
249
|
if (!this.stopping && children.get(this.profile.identity) === this) children.delete(this.profile.identity);
|
|
240
250
|
});
|
|
@@ -350,13 +360,14 @@ function cancelIdleShutdown() {
|
|
|
350
360
|
idleTimer = null;
|
|
351
361
|
}
|
|
352
362
|
|
|
353
|
-
function scheduleIdleShutdown() {
|
|
363
|
+
function scheduleIdleShutdown(initial = false) {
|
|
354
364
|
cancelIdleShutdown();
|
|
355
365
|
if (clients.size > 0 || shuttingDown) return;
|
|
356
|
-
idleTimer = setTimeout(() => shutdown(0), idleMilliseconds);
|
|
366
|
+
idleTimer = setTimeout(() => shutdown(0), initial ? initialClientGraceMilliseconds : idleMilliseconds);
|
|
357
367
|
}
|
|
358
368
|
|
|
359
369
|
function acceptClient(socket) {
|
|
370
|
+
testDiagnostic('client connected');
|
|
360
371
|
cancelIdleShutdown();
|
|
361
372
|
clients.add(socket);
|
|
362
373
|
socket.setEncoding('utf8');
|
|
@@ -375,6 +386,7 @@ function acceptClient(socket) {
|
|
|
375
386
|
}
|
|
376
387
|
});
|
|
377
388
|
const close = () => {
|
|
389
|
+
testDiagnostic('client disconnected');
|
|
378
390
|
clients.delete(socket);
|
|
379
391
|
scheduleIdleShutdown();
|
|
380
392
|
};
|
|
@@ -388,6 +400,7 @@ function removeUnixSocket() {
|
|
|
388
400
|
}
|
|
389
401
|
|
|
390
402
|
function shutdown(exitCode = 0) {
|
|
403
|
+
testDiagnostic(`shutdown ${exitCode}`);
|
|
391
404
|
if (shuttingDown) return;
|
|
392
405
|
shuttingDown = true;
|
|
393
406
|
cancelIdleShutdown();
|
|
@@ -421,21 +434,24 @@ if (!acquireLease()) process.exit(0);
|
|
|
421
434
|
removeUnixSocket();
|
|
422
435
|
server = net.createServer(acceptClient);
|
|
423
436
|
server.on('error', error => {
|
|
437
|
+
testDiagnostic(`server error ${error.message}`);
|
|
424
438
|
process.stderr.write(`[microi-codex-broker] ${error.message}\n`);
|
|
425
439
|
shutdown(1);
|
|
426
440
|
});
|
|
427
441
|
server.listen(endpoint, () => {
|
|
442
|
+
testDiagnostic(`server listening ${JSON.stringify(endpoint)}`);
|
|
428
443
|
if (process.platform !== 'win32') {
|
|
429
444
|
try { fs.chmodSync(endpoint, 0o600); } catch { /* best effort */ }
|
|
430
445
|
}
|
|
431
446
|
heartbeatTimer = setInterval(() => {
|
|
432
|
-
try { writeLeaseRecord(leaseRecord()); } catch { shutdown(1); }
|
|
447
|
+
try { writeLeaseRecord(leaseRecord()); } catch (error) { testDiagnostic(`heartbeat failed ${error.message}`); shutdown(1); }
|
|
433
448
|
}, heartbeatMilliseconds);
|
|
434
|
-
scheduleIdleShutdown();
|
|
449
|
+
scheduleIdleShutdown(true);
|
|
435
450
|
});
|
|
436
451
|
|
|
437
452
|
for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) process.on(signal, () => shutdown(0));
|
|
438
453
|
process.on('uncaughtException', error => {
|
|
454
|
+
testDiagnostic(`uncaught ${error?.stack || error}`);
|
|
439
455
|
process.stderr.write(`[microi-codex-broker] ${error?.stack || error}\n`);
|
|
440
456
|
shutdown(1);
|
|
441
457
|
});
|
|
@@ -280,11 +280,12 @@ class SharedBrokerClient {
|
|
|
280
280
|
if (!fs.existsSync(brokerScriptPath)) {
|
|
281
281
|
throw new Error(`Codex Plugin 缺少共享 Broker:${brokerScriptPath}`);
|
|
282
282
|
}
|
|
283
|
+
const testDiagnostics = process.env.MICROI_CODEX_TEST_DIAGNOSTICS === '1';
|
|
283
284
|
const child = childProcess.spawn(process.execPath, [brokerScriptPath], {
|
|
284
285
|
cwd: pluginRoot,
|
|
285
286
|
detached: true,
|
|
286
287
|
windowsHide: true,
|
|
287
|
-
stdio: 'ignore',
|
|
288
|
+
stdio: testDiagnostics ? ['ignore', 'ignore', 'pipe'] : 'ignore',
|
|
288
289
|
env: {
|
|
289
290
|
...process.env,
|
|
290
291
|
MICROI_CODEX_BROKER_ENDPOINT: this.coordinates.endpoint,
|
|
@@ -294,19 +295,34 @@ class SharedBrokerClient {
|
|
|
294
295
|
MICROI_TOOL_VERSION: pluginVersion,
|
|
295
296
|
},
|
|
296
297
|
});
|
|
298
|
+
// Keep production brokers detached. Smoke tests may opt into bounded stderr
|
|
299
|
+
// so a child boot failure cannot be reduced to an unexplained write EPIPE.
|
|
300
|
+
if (testDiagnostics && child.stderr) {
|
|
301
|
+
let remaining = 65536;
|
|
302
|
+
child.stderr.on('data', chunk => {
|
|
303
|
+
if (remaining <= 0) return;
|
|
304
|
+
const bytes = chunk.subarray(0, remaining); remaining -= bytes.length;
|
|
305
|
+
process.stderr.write(bytes);
|
|
306
|
+
});
|
|
307
|
+
child.stderr.unref?.();
|
|
308
|
+
}
|
|
297
309
|
child.on('error', () => { /* connect retry reports the actionable failure */ });
|
|
298
310
|
child.unref();
|
|
299
311
|
}
|
|
300
312
|
|
|
301
313
|
openSocket() {
|
|
302
314
|
return new Promise((resolve, reject) => {
|
|
315
|
+
const diagnostic = message => { if (process.env.MICROI_CODEX_TEST_DIAGNOSTICS === '1' && process.env.MICROI_CODEX_TEST_LOG) { try { fs.appendFileSync(process.env.MICROI_CODEX_TEST_LOG, `${new Date().toISOString()} router ${message}\n`); } catch {} } };
|
|
316
|
+
diagnostic(`connect ${JSON.stringify(this.coordinates.endpoint)}`);
|
|
303
317
|
const socket = net.createConnection(this.coordinates.endpoint);
|
|
304
318
|
const fail = error => {
|
|
319
|
+
diagnostic(`connect failed ${error.code}`);
|
|
305
320
|
socket.destroy();
|
|
306
321
|
reject(error);
|
|
307
322
|
};
|
|
308
323
|
socket.once('error', fail);
|
|
309
324
|
socket.once('connect', () => {
|
|
325
|
+
diagnostic('connected');
|
|
310
326
|
socket.off('error', fail);
|
|
311
327
|
this.socket = socket;
|
|
312
328
|
socket.setEncoding('utf8');
|