@fantasticit/sumi 0.14.5 → 0.14.6
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/agent-hooks.js +15 -2
- package/dist/agent-hooks.js.map +1 -1
- package/dist/agents.js +14 -9
- package/dist/agents.js.map +1 -1
- package/dist/cli.js +20 -3
- package/dist/cli.js.map +1 -1
- package/dist/codex-trust.d.ts +8 -0
- package/dist/codex-trust.js +27 -0
- package/dist/codex-trust.js.map +1 -0
- package/dist/codex-user-hook-entry.d.ts +1 -0
- package/dist/codex-user-hook-entry.js +134 -0
- package/dist/codex-user-hook-entry.js.map +1 -0
- package/dist/codex-user-hook.cjs +137 -0
- package/dist/codex-user-hook.d.ts +2 -0
- package/dist/codex-user-hook.js +85 -0
- package/dist/codex-user-hook.js.map +1 -0
- package/dist/context.d.ts +3 -1
- package/dist/context.js +16 -16
- package/dist/context.js.map +1 -1
- package/dist/doctor-wiring.d.ts +1 -6
- package/dist/doctor-wiring.js +4 -25
- package/dist/doctor-wiring.js.map +1 -1
- package/dist/hub/board.d.ts +85 -0
- package/dist/hub/board.js +261 -0
- package/dist/hub/board.js.map +1 -0
- package/dist/hub/commands.d.ts +13 -0
- package/dist/hub/commands.js +86 -0
- package/dist/hub/commands.js.map +1 -0
- package/dist/hub/pages.d.ts +2 -0
- package/dist/hub/pages.js +136 -0
- package/dist/hub/pages.js.map +1 -0
- package/dist/hub/server.d.ts +23 -0
- package/dist/hub/server.js +128 -0
- package/dist/hub/server.js.map +1 -0
- package/dist/hub/snapshot.d.ts +48 -0
- package/dist/hub/snapshot.js +132 -0
- package/dist/hub/snapshot.js.map +1 -0
- package/dist/hub/start.d.ts +13 -0
- package/dist/hub/start.js +59 -0
- package/dist/hub/start.js.map +1 -0
- package/dist/hub/state.d.ts +49 -0
- package/dist/hub/state.js +144 -0
- package/dist/hub/state.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/instructions.js +1 -1
- package/dist/run-stats.d.ts +20 -0
- package/dist/run-stats.js +58 -6
- package/dist/run-stats.js.map +1 -1
- package/dist/task.js +8 -2
- package/dist/task.js.map +1 -1
- package/node_modules/@sumi/create/package.json +2 -2
- package/node_modules/@sumi/create/template/control/flows/check.flow.yaml +3 -0
- package/node_modules/@sumi/create/template/control/rules/development.md +1 -1
- package/node_modules/@sumi/kernel/dist/brief.d.ts +2 -0
- package/node_modules/@sumi/kernel/dist/brief.js.map +1 -1
- package/node_modules/@sumi/kernel/dist/engine.js +1 -0
- package/node_modules/@sumi/kernel/dist/engine.js.map +1 -1
- package/node_modules/@sumi/kernel/dist/runner.js +1 -1
- package/node_modules/@sumi/kernel/dist/runner.js.map +1 -1
- package/node_modules/@sumi/kernel/package.json +2 -2
- package/node_modules/@sumi/plugin-sdk/dist/context-delivery.d.ts +11 -6
- package/node_modules/@sumi/plugin-sdk/dist/context-delivery.js +35 -3
- package/node_modules/@sumi/plugin-sdk/dist/context-delivery.js.map +1 -1
- package/node_modules/@sumi/plugin-sdk/dist/edit-paths.d.ts +2 -0
- package/node_modules/@sumi/plugin-sdk/dist/edit-paths.js +29 -23
- package/node_modules/@sumi/plugin-sdk/dist/edit-paths.js.map +1 -1
- package/node_modules/@sumi/plugin-sdk/dist/env.d.ts +2 -0
- package/node_modules/@sumi/plugin-sdk/dist/env.js +7 -0
- package/node_modules/@sumi/plugin-sdk/dist/env.js.map +1 -1
- package/node_modules/@sumi/plugin-sdk/dist/git.d.ts +8 -0
- package/node_modules/@sumi/plugin-sdk/dist/git.js +38 -0
- package/node_modules/@sumi/plugin-sdk/dist/git.js.map +1 -1
- package/node_modules/@sumi/plugin-sdk/dist/hub.d.ts +31 -0
- package/node_modules/@sumi/plugin-sdk/dist/hub.js +32 -0
- package/node_modules/@sumi/plugin-sdk/dist/hub.js.map +1 -0
- package/node_modules/@sumi/plugin-sdk/dist/import-graph.d.ts +22 -0
- package/node_modules/@sumi/plugin-sdk/dist/import-graph.js +118 -0
- package/node_modules/@sumi/plugin-sdk/dist/import-graph.js.map +1 -0
- package/node_modules/@sumi/plugin-sdk/dist/index.d.ts +2 -0
- package/node_modules/@sumi/plugin-sdk/dist/index.js +2 -0
- package/node_modules/@sumi/plugin-sdk/dist/index.js.map +1 -1
- package/node_modules/@sumi/plugin-sdk/dist/permissions.d.ts +2 -0
- package/node_modules/@sumi/plugin-sdk/dist/permissions.js +12 -1
- package/node_modules/@sumi/plugin-sdk/dist/permissions.js.map +1 -1
- package/node_modules/@sumi/plugin-sdk/dist/session-context.d.ts +2 -2
- package/node_modules/@sumi/plugin-sdk/dist/session-context.js +10 -7
- package/node_modules/@sumi/plugin-sdk/dist/session-context.js.map +1 -1
- package/node_modules/@sumi/plugin-sdk/dist/session-env.d.ts +2 -0
- package/node_modules/@sumi/plugin-sdk/dist/session-env.js +3 -0
- package/node_modules/@sumi/plugin-sdk/dist/session-env.js.map +1 -0
- package/node_modules/@sumi/plugin-sdk/dist/shell.d.ts +11 -5
- package/node_modules/@sumi/plugin-sdk/dist/shell.js +132 -23
- package/node_modules/@sumi/plugin-sdk/dist/shell.js.map +1 -1
- package/node_modules/@sumi/plugin-sdk/package.json +1 -1
- package/node_modules/@sumi/plugins-core/dist/agent-rules.js +20 -5
- package/node_modules/@sumi/plugins-core/dist/agent-rules.js.map +1 -1
- package/node_modules/@sumi/plugins-core/dist/change-impact.js +1 -13
- package/node_modules/@sumi/plugins-core/dist/change-impact.js.map +1 -1
- package/node_modules/@sumi/plugins-core/dist/commands/agent-rules-subagent-context.d.ts +1 -0
- package/node_modules/@sumi/plugins-core/dist/commands/agent-rules-subagent-context.js +10 -0
- package/node_modules/@sumi/plugins-core/dist/commands/agent-rules-subagent-context.js.map +1 -0
- package/node_modules/@sumi/plugins-core/dist/plugins/test-affected.js +26 -7
- package/node_modules/@sumi/plugins-core/dist/plugins/test-affected.js.map +1 -1
- package/node_modules/@sumi/plugins-core/dist/test-scope.d.ts +3 -1
- package/node_modules/@sumi/plugins-core/dist/test-scope.js +14 -3
- package/node_modules/@sumi/plugins-core/dist/test-scope.js.map +1 -1
- package/node_modules/@sumi/plugins-core/dist/vitest-runner.js +16 -0
- package/node_modules/@sumi/plugins-core/dist/vitest-runner.js.map +1 -1
- package/node_modules/@sumi/plugins-core/instructions/bugfix.md +1 -1
- package/node_modules/@sumi/plugins-core/instructions/feature.md +1 -1
- package/node_modules/@sumi/plugins-core/package.json +2 -2
- package/node_modules/@sumi/plugins-core/sumi-plugins.yaml +6 -0
- package/node_modules/@sumi/plugins-governance/dist/boundary-answer-page.d.ts +3 -0
- package/node_modules/@sumi/plugins-governance/dist/boundary-answer-page.js +76 -0
- package/node_modules/@sumi/plugins-governance/dist/boundary-answer-page.js.map +1 -0
- package/node_modules/@sumi/plugins-governance/dist/boundary-browser.d.ts +6 -0
- package/node_modules/@sumi/plugins-governance/dist/boundary-browser.js +121 -0
- package/node_modules/@sumi/plugins-governance/dist/boundary-browser.js.map +1 -0
- package/node_modules/@sumi/plugins-governance/dist/boundary-mcp.d.ts +1 -0
- package/node_modules/@sumi/plugins-governance/dist/boundary-mcp.js +179 -0
- package/node_modules/@sumi/plugins-governance/dist/boundary-mcp.js.map +1 -0
- package/node_modules/@sumi/plugins-governance/dist/boundary.d.ts +10 -0
- package/node_modules/@sumi/plugins-governance/dist/boundary.js +135 -29
- package/node_modules/@sumi/plugins-governance/dist/boundary.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/branch-scope.d.ts +9 -0
- package/node_modules/@sumi/plugins-governance/dist/branch-scope.js +64 -0
- package/node_modules/@sumi/plugins-governance/dist/branch-scope.js.map +1 -0
- package/node_modules/@sumi/plugins-governance/dist/checkout.d.ts +2 -0
- package/node_modules/@sumi/plugins-governance/dist/checkout.js +13 -3
- package/node_modules/@sumi/plugins-governance/dist/checkout.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/commands/boundary.js +59 -9
- package/node_modules/@sumi/plugins-governance/dist/commands/boundary.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/commands/gate.js +16 -11
- package/node_modules/@sumi/plugins-governance/dist/commands/gate.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/commands/hub-snapshot.d.ts +1 -0
- package/node_modules/@sumi/plugins-governance/dist/commands/hub-snapshot.js +4 -0
- package/node_modules/@sumi/plugins-governance/dist/commands/hub-snapshot.js.map +1 -0
- package/node_modules/@sumi/plugins-governance/dist/commands/pr-report.js +3 -1
- package/node_modules/@sumi/plugins-governance/dist/commands/pr-report.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/gate-cache.d.ts +2 -1
- package/node_modules/@sumi/plugins-governance/dist/gate-cache.js +11 -2
- package/node_modules/@sumi/plugins-governance/dist/gate-cache.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/guard.js +147 -19
- package/node_modules/@sumi/plugins-governance/dist/guard.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/hub-snapshot.d.ts +3 -0
- package/node_modules/@sumi/plugins-governance/dist/hub-snapshot.js +40 -0
- package/node_modules/@sumi/plugins-governance/dist/hub-snapshot.js.map +1 -0
- package/node_modules/@sumi/plugins-governance/dist/index.d.ts +3 -1
- package/node_modules/@sumi/plugins-governance/dist/index.js +3 -1
- package/node_modules/@sumi/plugins-governance/dist/index.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/pr-base.js +21 -1
- package/node_modules/@sumi/plugins-governance/dist/pr-base.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/pr-report-compose.js +4 -2
- package/node_modules/@sumi/plugins-governance/dist/pr-report-compose.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/pr-report-markers.d.ts +2 -0
- package/node_modules/@sumi/plugins-governance/dist/pr-report-markers.js +2 -0
- package/node_modules/@sumi/plugins-governance/dist/pr-report-markers.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/pr-report-sections.js +34 -4
- package/node_modules/@sumi/plugins-governance/dist/pr-report-sections.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/preflight.d.ts +1 -0
- package/node_modules/@sumi/plugins-governance/dist/preflight.js +2 -2
- package/node_modules/@sumi/plugins-governance/dist/preflight.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/instructions/boundary.md +18 -2
- package/node_modules/@sumi/plugins-governance/package.json +4 -4
- package/node_modules/@sumi/plugins-governance/sumi-plugins.yaml +6 -0
- package/node_modules/@sumi/plugins-openspec/dist/commands/hub-snapshot.d.ts +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/commands/hub-snapshot.js +4 -0
- package/node_modules/@sumi/plugins-openspec/dist/commands/hub-snapshot.js.map +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/hub-snapshot.d.ts +4 -0
- package/node_modules/@sumi/plugins-openspec/dist/hub-snapshot.js +34 -0
- package/node_modules/@sumi/plugins-openspec/dist/hub-snapshot.js.map +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/index.d.ts +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/index.js +1 -0
- package/node_modules/@sumi/plugins-openspec/dist/index.js.map +1 -1
- package/node_modules/@sumi/plugins-openspec/dist/plugins/impact-consistency.js +2 -0
- package/node_modules/@sumi/plugins-openspec/dist/plugins/impact-consistency.js.map +1 -1
- package/node_modules/@sumi/plugins-openspec/package.json +6 -6
- package/node_modules/@sumi/plugins-openspec/sumi-plugins.yaml +4 -0
- package/node_modules/@sumi/plugins-precedent/dist/after-edit-context.js +10 -11
- package/node_modules/@sumi/plugins-precedent/dist/after-edit-context.js.map +1 -1
- package/node_modules/@sumi/plugins-precedent/dist/candidates.d.ts +9 -3
- package/node_modules/@sumi/plugins-precedent/dist/candidates.js +12 -6
- package/node_modules/@sumi/plugins-precedent/dist/candidates.js.map +1 -1
- package/node_modules/@sumi/plugins-precedent/dist/commands/promote.js +20 -5
- package/node_modules/@sumi/plugins-precedent/dist/commands/promote.js.map +1 -1
- package/node_modules/@sumi/plugins-precedent/dist/context-output.d.ts +15 -8
- package/node_modules/@sumi/plugins-precedent/dist/context-output.js +93 -34
- package/node_modules/@sumi/plugins-precedent/dist/context-output.js.map +1 -1
- package/node_modules/@sumi/plugins-precedent/dist/context-provider.js +7 -3
- package/node_modules/@sumi/plugins-precedent/dist/context-provider.js.map +1 -1
- package/node_modules/@sumi/plugins-precedent/dist/impact-state.d.ts +2 -1
- package/node_modules/@sumi/plugins-precedent/dist/impact-state.js +5 -4
- package/node_modules/@sumi/plugins-precedent/dist/impact-state.js.map +1 -1
- package/node_modules/@sumi/plugins-precedent/dist/impact.d.ts +7 -6
- package/node_modules/@sumi/plugins-precedent/dist/impact.js +33 -29
- package/node_modules/@sumi/plugins-precedent/dist/impact.js.map +1 -1
- package/node_modules/@sumi/plugins-precedent/dist/matching.d.ts +12 -0
- package/node_modules/@sumi/plugins-precedent/dist/matching.js +90 -0
- package/node_modules/@sumi/plugins-precedent/dist/matching.js.map +1 -0
- package/node_modules/@sumi/plugins-precedent/dist/plugins/harvest.js +44 -13
- package/node_modules/@sumi/plugins-precedent/dist/plugins/harvest.js.map +1 -1
- package/node_modules/@sumi/plugins-precedent/dist/plugins/impact.js +15 -10
- package/node_modules/@sumi/plugins-precedent/dist/plugins/impact.js.map +1 -1
- package/node_modules/@sumi/plugins-precedent/dist/plugins/planner.js +47 -6
- package/node_modules/@sumi/plugins-precedent/dist/plugins/planner.js.map +1 -1
- package/node_modules/@sumi/plugins-precedent/dist/review-candidates.d.ts +3 -0
- package/node_modules/@sumi/plugins-precedent/dist/review-candidates.js +40 -0
- package/node_modules/@sumi/plugins-precedent/dist/review-candidates.js.map +1 -0
- package/node_modules/@sumi/plugins-precedent/package.json +3 -3
- package/node_modules/@sumi/plugins-review/dist/command-input.d.ts +1 -1
- package/node_modules/@sumi/plugins-review/dist/command-input.js +4 -4
- package/node_modules/@sumi/plugins-review/dist/command-input.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/commands/stats.js +3 -3
- package/node_modules/@sumi/plugins-review/dist/commands/stats.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/commands/submit.js +6 -0
- package/node_modules/@sumi/plugins-review/dist/commands/submit.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/convergence.d.ts +7 -2
- package/node_modules/@sumi/plugins-review/dist/convergence.js +43 -5
- package/node_modules/@sumi/plugins-review/dist/convergence.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/dispatch.js +2 -0
- package/node_modules/@sumi/plugins-review/dist/dispatch.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/plugins/independent-recheck.js +1 -1
- package/node_modules/@sumi/plugins-review/dist/plugins/independent-recheck.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/precedent-context.d.ts +7 -0
- package/node_modules/@sumi/plugins-review/dist/precedent-context.js +28 -0
- package/node_modules/@sumi/plugins-review/dist/precedent-context.js.map +1 -0
- package/node_modules/@sumi/plugins-review/dist/preflight.d.ts +1 -0
- package/node_modules/@sumi/plugins-review/dist/preflight.js +15 -5
- package/node_modules/@sumi/plugins-review/dist/preflight.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/report.d.ts +9 -0
- package/node_modules/@sumi/plugins-review/dist/report.js +28 -7
- package/node_modules/@sumi/plugins-review/dist/report.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/resolved-blockers.d.ts +9 -0
- package/node_modules/@sumi/plugins-review/dist/resolved-blockers.js +50 -0
- package/node_modules/@sumi/plugins-review/dist/resolved-blockers.js.map +1 -0
- package/node_modules/@sumi/plugins-review/dist/review-scope.d.ts +1 -3
- package/node_modules/@sumi/plugins-review/dist/review-scope.js +1 -24
- package/node_modules/@sumi/plugins-review/dist/review-scope.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/review-slices.js +1 -0
- package/node_modules/@sumi/plugins-review/dist/review-slices.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/review.d.ts +47 -8
- package/node_modules/@sumi/plugins-review/dist/review.js +215 -34
- package/node_modules/@sumi/plugins-review/dist/review.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/rubric-check.js +71 -32
- package/node_modules/@sumi/plugins-review/dist/rubric-check.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/stats.d.ts +1 -0
- package/node_modules/@sumi/plugins-review/dist/stats.js +11 -15
- package/node_modules/@sumi/plugins-review/dist/stats.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/submission.js +24 -8
- package/node_modules/@sumi/plugins-review/dist/submission.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/submit-files.d.ts +3 -0
- package/node_modules/@sumi/plugins-review/dist/submit-files.js +55 -0
- package/node_modules/@sumi/plugins-review/dist/submit-files.js.map +1 -0
- package/node_modules/@sumi/plugins-review/dist/validation-receipt.js +4 -2
- package/node_modules/@sumi/plugins-review/dist/validation-receipt.js.map +1 -1
- package/node_modules/@sumi/plugins-review/package.json +6 -6
- package/package.json +10 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"board.js","sourceRoot":"","sources":["../../src/hub/board.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAqE,MAAM,eAAe,CAAC;AAKnH,MAAM,UAAU,GAAG,CAAC,QAA+E,EAAE,EAAE,CACrG,CAAC,QAAQ,EAAE,MAAM,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAA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,OAAO;QACL,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE;QACvB,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;QAC3C,KAAK;QACL,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;QACrG,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM;KAC9H,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface HubStatus {
|
|
2
|
+
running: boolean;
|
|
3
|
+
url: string | null;
|
|
4
|
+
pid: number | null;
|
|
5
|
+
startedAt: number | null;
|
|
6
|
+
projects: number;
|
|
7
|
+
stale: number;
|
|
8
|
+
diagnostic: string | null;
|
|
9
|
+
}
|
|
10
|
+
/** hub 的当前状态;状态文件、进程存活与健康检查都通过才算运行。 */
|
|
11
|
+
export declare function hubStatus(timeoutMs?: number): Promise<HubStatus>;
|
|
12
|
+
/** 一行摘要,供 `sumi hub status` 与 `sumi doctor` 共用。 */
|
|
13
|
+
export declare function describeHub(status: HubStatus): string;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
2
|
+
import { KernelError } from '@sumi/kernel';
|
|
3
|
+
import { registerCommand, requireRoot } from '../cli.js';
|
|
4
|
+
import { HubRunningError, startHub } from './server.js';
|
|
5
|
+
import { hubFiles, pidAlive, probeHub, readHubState, readProjects, releaseHubFiles } from './state.js';
|
|
6
|
+
import { buildSnapshot, sessionDetail } from './snapshot.js';
|
|
7
|
+
/** hub 的当前状态;状态文件、进程存活与健康检查都通过才算运行。 */
|
|
8
|
+
export async function hubStatus(timeoutMs = 1000) {
|
|
9
|
+
const running = await probeHub(timeoutMs);
|
|
10
|
+
const projects = readProjects();
|
|
11
|
+
const { diagnostic } = hubFiles();
|
|
12
|
+
return {
|
|
13
|
+
running: running !== null,
|
|
14
|
+
url: running?.url ?? null,
|
|
15
|
+
pid: running?.state.pid ?? null,
|
|
16
|
+
startedAt: running?.state.startedAt ?? null,
|
|
17
|
+
projects: projects.length,
|
|
18
|
+
stale: projects.filter((entry) => !existsSync(entry.path) || !statSync(entry.path).isDirectory()).length,
|
|
19
|
+
diagnostic: existsSync(diagnostic) ? readFileSync(diagnostic, 'utf8').trim() : null,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** 一行摘要,供 `sumi hub status` 与 `sumi doctor` 共用。 */
|
|
23
|
+
export function describeHub(status) {
|
|
24
|
+
const projects = `已登记 ${status.projects} 个项目${status.stale ? `,${status.stale} 个已失效` : ''}`;
|
|
25
|
+
return status.running ? `hub 运行中:${status.url},${projects}` : `hub 未运行(下次会话开始时自动拉起),${projects}`;
|
|
26
|
+
}
|
|
27
|
+
const SESSION_ID = /^[0-9a-f]{32}$/;
|
|
28
|
+
registerCommand('hub', '本机常驻 hub:sumi hub <serve|status|stop|snapshot>(snapshot 为只读:[--session <id> [--after <偏移>] [--confirmations]])', { flags: ['session', 'after', 'confirmations'], booleanFlags: ['confirmations'] }, async (args, io, root) => {
|
|
29
|
+
const action = args.positionals[0];
|
|
30
|
+
if (action === 'snapshot') {
|
|
31
|
+
const session = args.flags.session;
|
|
32
|
+
if (session !== undefined && (typeof session !== 'string' || !SESSION_ID.test(session)))
|
|
33
|
+
throw new KernelError('--session 必须是 32 位十六进制会话标识');
|
|
34
|
+
const after = Number(args.flags.after ?? 0);
|
|
35
|
+
if (!Number.isSafeInteger(after) || after < 0)
|
|
36
|
+
throw new KernelError('--after 必须是非负整数');
|
|
37
|
+
const project = requireRoot(root);
|
|
38
|
+
const value = session
|
|
39
|
+
? sessionDetail(project, session, { confirmations: args.flags.confirmations === true, after })
|
|
40
|
+
: buildSnapshot(project);
|
|
41
|
+
io.out(JSON.stringify(value));
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
if (action === 'serve') {
|
|
45
|
+
const hub = await startHub().catch((error) => {
|
|
46
|
+
if (error instanceof HubRunningError)
|
|
47
|
+
return null;
|
|
48
|
+
throw error;
|
|
49
|
+
});
|
|
50
|
+
if (!hub) {
|
|
51
|
+
io.out(describeHub(await hubStatus()));
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
io.out(`Sumi hub:${hub.url}`);
|
|
55
|
+
const stop = () => void hub.close();
|
|
56
|
+
process.once('SIGINT', stop);
|
|
57
|
+
process.once('SIGTERM', stop);
|
|
58
|
+
await hub.closed;
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
61
|
+
if (action === 'status') {
|
|
62
|
+
const status = await hubStatus();
|
|
63
|
+
io.out([
|
|
64
|
+
describeHub(status),
|
|
65
|
+
...(status.pid ? [`进程号 ${status.pid},启动于 ${new Date(status.startedAt).toLocaleString('zh-CN', { hour12: false })}`] : []),
|
|
66
|
+
...(status.diagnostic ? [`最近一次诊断:${status.diagnostic}`] : []),
|
|
67
|
+
].join('\n'));
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
70
|
+
if (action === 'stop') {
|
|
71
|
+
const state = readHubState();
|
|
72
|
+
if (state && pidAlive(state.pid) && (await probeHub(1000))) {
|
|
73
|
+
process.kill(state.pid, 'SIGTERM');
|
|
74
|
+
for (let waited = 0; waited < 3000 && pidAlive(state.pid); waited += 100)
|
|
75
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
76
|
+
io.out(pidAlive(state.pid) ? `已发送停止信号,进程 ${state.pid} 仍在退出` : 'hub 已停止');
|
|
77
|
+
}
|
|
78
|
+
else
|
|
79
|
+
io.out('hub 没有运行');
|
|
80
|
+
// 进程已结束或进程号被其他程序复用时,兜底清理状态与锁
|
|
81
|
+
releaseHubFiles();
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
84
|
+
throw new KernelError('用法:sumi hub <serve|status|stop|snapshot>');
|
|
85
|
+
});
|
|
86
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/hub/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACvG,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAY7D,uCAAuC;AACvC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,SAAS,GAAG,IAAI;IAC9C,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAG,YAAY,EAAE,CAAC;IAChC,MAAM,EAAE,UAAU,EAAE,GAAG,QAAQ,EAAE,CAAC;IAClC,OAAO;QACL,OAAO,EAAE,OAAO,KAAK,IAAI;QACzB,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,IAAI;QACzB,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,IAAI,IAAI;QAC/B,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,SAAS,IAAI,IAAI;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M,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;YACnI,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAC3E,CAAC;;YAAM,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC1B,6BAA6B;QAC7B,eAAe,EAAE,CAAC;QAClB,OAAO,CAAC,CAAC;IACX,CAAC;IACD,MAAM,IAAI,WAAW,CAAC,0CAA0C,CAAC,CAAC;AACpE,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// hub 的两个自包含只读页面:无外部字体与脚本,数据来自同源的 JSON 接口,动态内容一律用 textContent。
|
|
2
|
+
// 版式与配色来自设计稿;所有按钮只用于导航、筛选与展开,没有提交类控件。
|
|
3
|
+
const STYLE = `:root{--bg:#F6F6F4;--surface:#fff;--soft:#EFEFEC;--line:#E4E4E0;--ink:#1F1F1C;--ink2:#3A3A36;--muted:#6B6B66;--faint:#8A8A84;--blue:#1D4ED8;--blue-soft:#EEF2FF;--blue-ink:#3730A3;--dev-bg:#F2F6FE;--dev-line:#C9D8F8;--orange:#C2410C;--auto-bg:#FFF8F1;--auto-line:#F1D9C2;--red:#B42318;--red-bg:#FDF1F0;--red-line:#F0C4BF;--green:#15803D;--green-soft:#E7F5EC;--green-ink:#166534;color-scheme:light;font-family:Inter,"PingFang SC","Microsoft YaHei","Noto Sans SC",system-ui,sans-serif}
|
|
4
|
+
@media (prefers-color-scheme:dark){:root{--bg:#161614;--surface:#20201D;--soft:#2A2A26;--line:#34342F;--ink:#ECECE8;--ink2:#D2D2CC;--muted:#A2A29A;--faint:#85857D;--blue:#7BA0FF;--blue-soft:#232A45;--blue-ink:#B6C6FF;--dev-bg:#1C2338;--dev-line:#2F3C63;--orange:#F0985F;--auto-bg:#2D241C;--auto-line:#4A3926;--red:#FF8E84;--red-bg:#3A2321;--red-line:#5F3531;--green:#6FCF8D;--green-soft:#1F3427;--green-ink:#8FE0A9;color-scheme:dark}}
|
|
5
|
+
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink);font-size:14px}
|
|
6
|
+
.mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
|
|
7
|
+
a{color:var(--blue)}button,select{font:inherit;color:inherit}
|
|
8
|
+
header.top{display:flex;flex-wrap:wrap;align-items:center;gap:16px;padding:12px 24px;background:var(--surface);border-bottom:1px solid var(--line)}
|
|
9
|
+
.brand{display:flex;align-items:center;gap:10px;flex:1 1 200px}.brand strong{font-size:18px}.brand span{font-size:13px;color:var(--muted)}
|
|
10
|
+
nav.tabs{display:flex;gap:2px;padding:3px;background:var(--soft);border-radius:10px}
|
|
11
|
+
nav.tabs a{padding:7px 18px;border-radius:8px;font-size:14px;font-weight:500;color:var(--muted);text-decoration:none}
|
|
12
|
+
nav.tabs a[aria-current="page"]{background:var(--surface);color:var(--ink);box-shadow:0 1px 2px rgba(0,0,0,.12)}
|
|
13
|
+
nav.tabs a:focus-visible,.card:focus-visible,.pill:focus-visible,.sess:focus-visible,.row:focus-visible{outline:2px solid var(--blue);outline-offset:2px}
|
|
14
|
+
.right{flex:1 1 200px;display:flex;justify-content:flex-end;gap:8px}
|
|
15
|
+
#need{display:inline-flex;gap:6px;align-items:center;padding:6px 12px;border-radius:8px;background:var(--red-bg);color:var(--red);font-weight:600;font-size:13px}#need[hidden]{display:none}
|
|
16
|
+
.filters{display:flex;flex-wrap:wrap;align-items:center;gap:10px;padding:10px 24px;background:var(--surface);border-bottom:1px solid var(--line);font-size:13px}
|
|
17
|
+
.filters label{color:var(--muted)}.filters select{padding:5px 8px;border-radius:8px;border:1px solid var(--line);background:var(--surface)}
|
|
18
|
+
.projects{display:flex;gap:8px;overflow-x:auto;flex:1 1 400px;min-width:0;padding:2px 0}
|
|
19
|
+
.proj{display:flex;gap:8px;align-items:center;padding:5px 10px;border-radius:8px;border:1px solid var(--line);background:var(--bg);white-space:nowrap;font-size:13px}.proj .mono{color:var(--blue);font-weight:500}.proj em{font-style:normal;color:var(--muted)}.proj.warn em{color:var(--orange)}
|
|
20
|
+
.body{display:flex;flex-wrap:wrap;align-items:stretch}
|
|
21
|
+
.board{flex:999 1 760px;min-width:0;display:grid;grid-template-columns:repeat(4,minmax(220px,1fr));gap:16px;padding:18px 24px;overflow-x:auto;align-content:start}
|
|
22
|
+
.col{display:flex;flex-direction:column;gap:10px}
|
|
23
|
+
.col h2{margin:0;font-size:14px;font-weight:600;display:flex;align-items:center;gap:8px}.col h2 i{width:8px;height:8px;border-radius:4px;display:inline-block}.col h2 span{color:var(--faint);font-weight:500}
|
|
24
|
+
.col p.hint{margin:0;font-size:12px;color:var(--muted)}
|
|
25
|
+
.lane{display:flex;flex-direction:column;gap:2px;margin-top:6px}.lane strong{font-size:13px}.lane span{font-size:12px;color:var(--muted)}.lane.urgent strong{color:var(--red)}
|
|
26
|
+
.empty{font-size:12px;color:var(--faint);padding:8px 2px}
|
|
27
|
+
.card{all:unset;box-sizing:border-box;display:flex;flex-direction:column;gap:6px;width:100%;padding:12px 14px;border-radius:10px;background:var(--surface);border:1px solid var(--line);cursor:pointer;text-align:left}
|
|
28
|
+
.card:hover{border-color:var(--faint)}.card[aria-pressed="true"]{box-shadow:0 0 0 2px var(--blue)}
|
|
29
|
+
.card.dev{background:var(--dev-bg);border-color:var(--dev-line)}.card.auto{background:var(--auto-bg);border-color:var(--auto-line)}.card.need{background:var(--red-bg);border-color:var(--red-line)}
|
|
30
|
+
.card .t{display:flex;justify-content:space-between;gap:8px;align-items:flex-start}.card .t strong{font-size:15px;line-height:21px;overflow-wrap:anywhere}
|
|
31
|
+
.chip{display:inline-flex;align-items:center;gap:4px;padding:2px 7px;border-radius:6px;font-size:12px;font-weight:500;line-height:18px;background:var(--soft);color:var(--ink2)}
|
|
32
|
+
.card .m{font-size:12px;color:var(--muted);overflow-wrap:anywhere}.card.need .m{color:var(--red);font-weight:600}
|
|
33
|
+
.bar{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--muted)}.bar .track{flex:1 1 auto;height:4px;border-radius:2px;background:var(--line);overflow:hidden}.bar .track b{display:block;height:4px;background:var(--orange)}
|
|
34
|
+
aside.detail{flex:1 1 400px;max-width:100%;background:var(--surface);border-left:1px solid var(--line);padding:22px 24px;display:flex;flex-direction:column;gap:18px}
|
|
35
|
+
aside.detail h1{margin:0;font-size:22px;line-height:30px;overflow-wrap:anywhere}aside.detail h2{margin:0;font-size:15px}
|
|
36
|
+
.chips{display:flex;flex-wrap:wrap;gap:6px}.status{font-size:13px;font-weight:600}
|
|
37
|
+
.runs{display:flex;flex-direction:column;gap:8px}.run{display:flex;align-items:center;gap:10px;font-size:13px}.run .mono{flex:1 1 auto;overflow-wrap:anywhere}.run span.st{min-width:44px;justify-content:center}
|
|
38
|
+
.st.pass{background:var(--green-soft);color:var(--green-ink)}.st.fail,.st.blocked{background:var(--red-bg);color:var(--red)}.st.pending{background:var(--soft);color:var(--muted)}
|
|
39
|
+
.note{margin:0;color:var(--muted);font-size:12px;line-height:1.7}
|
|
40
|
+
.layout{display:flex;flex-wrap:wrap;align-items:stretch}
|
|
41
|
+
nav.list{flex:1 1 280px;max-width:100%;padding:16px 12px;background:var(--surface);border-right:1px solid var(--line);display:flex;flex-direction:column;gap:4px;max-height:calc(100vh - 56px);overflow:auto}
|
|
42
|
+
.sess{all:unset;box-sizing:border-box;display:flex;flex-direction:column;gap:3px;width:100%;padding:10px 12px;border-radius:8px;cursor:pointer;min-height:44px}.sess:hover{background:var(--soft)}.sess[aria-current="true"]{background:var(--blue-soft)}
|
|
43
|
+
.sess .t{display:flex;justify-content:space-between;gap:8px}.sess strong{font-size:14px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.sess .m{font-size:12px;color:var(--muted)}
|
|
44
|
+
main.sessions{flex:999 1 640px;min-width:0;padding:22px 28px;display:flex;flex-direction:column;gap:18px}
|
|
45
|
+
main.sessions h1{margin:0;font-size:24px;overflow-wrap:anywhere}.meta{font-size:13px;color:var(--muted);overflow-wrap:anywhere}
|
|
46
|
+
.stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px}.stat{padding:14px;border-radius:10px;background:var(--surface);border:1px solid var(--line);display:flex;flex-direction:column;gap:4px}.stat span{font-size:12px;color:var(--muted)}.stat strong{font-size:24px}
|
|
47
|
+
.pills{display:flex;flex-wrap:wrap;gap:8px;align-items:center}.pill{all:unset;box-sizing:border-box;display:inline-flex;gap:6px;align-items:center;padding:6px 12px;border-radius:999px;font-size:13px;cursor:pointer;border:1px solid var(--line);min-height:32px}.pill[aria-pressed="true"]{background:var(--blue);border-color:var(--blue);color:var(--surface)}
|
|
48
|
+
ol.events{margin:0;padding:0;list-style:none;background:var(--surface);border:1px solid var(--line);border-radius:10px;overflow:hidden}
|
|
49
|
+
ol.events li{border-bottom:1px solid var(--line);padding:12px 14px}ol.events li:last-child{border-bottom:0}
|
|
50
|
+
ol.events[data-view="deliveries"] li.hidden-by-view{display:none}
|
|
51
|
+
.row{display:flex;gap:12px;align-items:flex-start;flex-wrap:wrap}.row time{font-size:12px;color:var(--muted);width:56px;flex:none;padding-top:2px}
|
|
52
|
+
.kind{flex:none;background:var(--blue-soft);color:var(--blue-ink)}.kind.read{background:var(--green-soft);color:var(--green-ink)}.kind.prompt{background:#FFF1E3;color:#9A3412}.kind.plain{background:var(--soft);color:var(--ink2)}
|
|
53
|
+
.what{display:flex;flex-direction:column;gap:3px;flex:1 1 200px;min-width:0}.what b{font-weight:500;overflow-wrap:anywhere}.what small{font-size:12px;color:var(--muted)}
|
|
54
|
+
.tag{font-size:11px;font-weight:650;padding:2px 7px;border-radius:5px;background:var(--soft);color:var(--ink2)}.tag.ok{background:var(--green-soft);color:var(--green-ink)}.tag.bad{background:var(--red-bg);color:var(--red)}
|
|
55
|
+
details{margin:8px 0 0 68px}summary{cursor:pointer;font-size:12px;color:var(--blue);font-weight:600}
|
|
56
|
+
pre{white-space:pre-wrap;overflow-wrap:anywhere;font:12px/1.6 ui-monospace,SFMono-Regular,Menlo,monospace;background:var(--bg);border-radius:8px;padding:11px;max-height:480px;overflow:auto;margin:8px 0 0}
|
|
57
|
+
@media(max-width:820px){.board{padding:14px 16px}header.top,.filters{padding:10px 16px}aside.detail{border-left:0;border-top:1px solid var(--line)}nav.list{border-right:0;border-bottom:1px solid var(--line);max-height:300px}details{margin-left:0}}`;
|
|
58
|
+
const shell = (title, active, content, script) => `<!doctype html>
|
|
59
|
+
<html lang="zh-CN">
|
|
60
|
+
<head>
|
|
61
|
+
<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
62
|
+
<title>${title}</title>
|
|
63
|
+
<style>${STYLE}</style>
|
|
64
|
+
</head><body>
|
|
65
|
+
<header class="top">
|
|
66
|
+
<div class="brand"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M4 6h16M4 12h10M4 18h6"/></svg><strong>Sumi</strong><span id="summary">读取中</span></div>
|
|
67
|
+
<nav class="tabs" aria-label="视图"><a href="/"${active === 'board' ? ' aria-current="page"' : ''}>看板</a><a href="/sessions"${active === 'sessions' ? ' aria-current="page"' : ''}>会话</a></nav>
|
|
68
|
+
<div class="right"><span id="need" hidden></span></div>
|
|
69
|
+
</header>
|
|
70
|
+
${content}
|
|
71
|
+
<script>
|
|
72
|
+
const byId=(id)=>document.getElementById(id);
|
|
73
|
+
const make=(tag,className,value)=>{const node=document.createElement(tag);if(className)node.className=className;if(value!==undefined)node.textContent=String(value);return node};
|
|
74
|
+
const clock=(value)=>{const date=new Date(value);return Number.isNaN(date.getTime())?'时间未知':date.toLocaleTimeString('zh-CN',{hour12:false})};
|
|
75
|
+
const stamp=(value)=>{const date=new Date(value);return Number.isNaN(date.getTime())?'':date.toLocaleString('zh-CN',{hour12:false,month:'numeric',day:'numeric',hour:'2-digit',minute:'2-digit'})};
|
|
76
|
+
const getJson=async(url)=>{const response=await fetch(url,{cache:'no-store'});if(!response.ok)throw new Error(String(response.status));return response.json()};
|
|
77
|
+
${script}
|
|
78
|
+
</script></body></html>`;
|
|
79
|
+
const BOARD_SCRIPT = `
|
|
80
|
+
const COLUMNS=[['awaiting','待确认','var(--faint)','代理在等你确认后才继续'],['dev','开发中','var(--blue)','还没有完整的检查,或任务没做完'],['review','检查与评审','var(--orange)',''],['done','可合并与已合并','var(--green)','检查通过且任务完成,或已合并进默认分支']];
|
|
81
|
+
const RUN={pass:'通过',fail:'失败',blocked:'受阻',pending:'进行中'};
|
|
82
|
+
let board=null;let project='';let selected='';
|
|
83
|
+
const visible=()=>board.cards.filter((card)=>!project||card.projectId===project);
|
|
84
|
+
function pct(card){const items=card.progress||[];const total=items.reduce((sum,item)=>sum+item.total,0);return total?Math.round(items.reduce((sum,item)=>sum+item.done,0)/total*100):0}
|
|
85
|
+
function renderCard(card){const button=make('button','card '+(card.lane==='needs-you'?'need':card.lane==='auto'?'auto':card.column==='dev'?'dev':''));button.type='button';button.setAttribute('aria-pressed',String(card.id===selected));const top=make('span','t');top.append(make('strong','',card.title),make('span','chip mono',card.project));button.append(top);if(card.kind==='branch'&&card.progress&&card.progress.length){const bar=make('span','bar');const track=make('span','track');const fill=make('b');fill.style.width=pct(card)+'%';track.append(fill);bar.append(track,document.createTextNode(card.progress.map((item)=>item.label+' '+item.done+'/'+item.total).join('、')));button.append(bar)}button.append(make('span','m',(card.kind==='session'?'会话 · ':'')+card.reason));button.addEventListener('click',()=>{selected=card.id;render()});return button}
|
|
86
|
+
function column(def,cards){const section=make('section','col');const heading=make('h2');const dot=make('i');dot.style.background=def[2];heading.append(dot,document.createTextNode(def[1]+' '),make('span','',cards.length));section.append(heading);if(def[3])section.append(make('p','hint',def[3]));return section}
|
|
87
|
+
function render(){if(!board)return;const cards=visible();const root=byId('board');root.replaceChildren();for(const def of COLUMNS){const mine=cards.filter((card)=>card.column===def[0]);const section=column(def,mine);if(def[0]==='review'){const need=mine.filter((card)=>card.lane==='needs-you');const auto=mine.filter((card)=>card.lane!=='needs-you');const a=make('div','lane urgent');a.append(make('strong','','需要你 '+need.length),make('span','','代理处理不了:检查受阻或连续两次失败'));section.append(a,...need.map(renderCard));const b=make('div','lane');b.append(make('strong','','自动处理中 '+auto.length),make('span','','检查在跑或刚失败一次,先不用看'));section.append(b,...auto.map(renderCard))}else{section.append(...mine.map(renderCard));if(!mine.length)section.append(make('div','empty','暂无'))}root.append(section)}
|
|
88
|
+
const branches=board.cards.filter((card)=>card.kind==='branch').length;byId('summary').textContent='本机 '+board.projects.length+' 个项目 · '+branches+' 个分支';const need=byId('need');need.hidden=!board.needsYou;need.textContent='需要你 '+board.needsYou;
|
|
89
|
+
const picker=byId('project');if(picker.options.length!==board.projects.length+1){picker.replaceChildren(new Option('全部项目',''),...board.projects.map((entry)=>new Option(entry.name,entry.id)));picker.value=project}
|
|
90
|
+
byId('projects').replaceChildren(...board.projects.map((entry)=>{const box=make('div','proj'+(entry.status==='ok'?'':' warn'));box.append(make('span','mono',entry.name),make('em','',entry.status==='ok'?'读取于 '+clock(entry.readAt):(entry.message||'')+(entry.readAt?' · 上次读取 '+clock(entry.readAt):'')));return box}));
|
|
91
|
+
renderDetail(cards.find((card)=>card.id===selected))}
|
|
92
|
+
function renderDetail(card){const box=byId('detail');box.replaceChildren();if(!card){box.append(make('p','note','选择一张卡片查看详情。看板只读:要回答问题或做决定,请回到对应的 AI 会话。'));return}
|
|
93
|
+
const chips=make('div','chips');chips.append(make('span','chip mono',card.branch||card.title),make('span','chip',card.project));if(card.host)chips.append(make('span','chip',card.host));box.append(chips);
|
|
94
|
+
const head=make('div');head.style.cssText='display:flex;flex-direction:column;gap:6px';const status=make('span','status',COLUMNS.find((def)=>def[0]===card.column)[1]+(card.lane==='needs-you'?' · 需要你':card.lane==='auto'?' · 自动处理中':''));status.style.color=card.lane==='needs-you'?'var(--red)':'var(--ink)';head.append(status,make('h1','',card.title),make('p','note',card.reason));box.append(head);
|
|
95
|
+
if(card.progress&&card.progress.length){const section=make('section','runs');section.append(make('h2','','任务进度'));for(const item of card.progress){const bar=make('div','bar');const track=make('span','track');const fill=make('b');fill.style.width=(item.total?Math.round(item.done/item.total*100):0)+'%';track.append(fill);bar.append(track,document.createTextNode(item.label+' '+item.done+'/'+item.total));section.append(bar)}box.append(section)}
|
|
96
|
+
if(card.runs&&card.runs.length){const section=make('section','runs');section.append(make('h2','','最近检查'));for(const run of card.runs){const row=make('div','run');row.append(make('span','chip st '+run.conclusion,RUN[run.conclusion]||run.conclusion),make('span','mono',run.runId+(run.partial?'(部分运行)':'')),make('span','note',stamp(run.finishedAt||run.startedAt)));section.append(row)}box.append(section)}
|
|
97
|
+
if(card.kind==='session'){const link=make('a','','在会话页查看');link.href='/sessions#'+card.id;box.append(link)}}
|
|
98
|
+
byId('project').addEventListener('change',(event)=>{project=event.target.value;render()});
|
|
99
|
+
async function refresh(){try{board=await getJson('/api/board');render()}catch{byId('summary').textContent='无法读取 hub 数据'}}
|
|
100
|
+
refresh();setInterval(refresh,5000);`;
|
|
101
|
+
export const BOARD_PAGE = shell('Sumi 看板', 'board', `<div class="filters"><label for="project">项目</label><select id="project"><option value="">全部项目</option></select><div id="projects" class="projects" aria-label="项目读取状态"></div></div>
|
|
102
|
+
<div class="body"><main id="board" class="board" aria-label="看板"></main><aside id="detail" class="detail" aria-label="详情"></aside></div>`, BOARD_SCRIPT);
|
|
103
|
+
const SESSIONS_SCRIPT = `
|
|
104
|
+
const CHANNELS={prompt:'提示词',startup:'会话开始','session-start':'会话开始',clear:'清空后',compact:'压缩后','subagent-start':'子代理启动','before-edit':'编辑前','after-edit':'编辑后','rules-fallback':'规则兜底','read-gate':'读取门槛','task-select':'任务选择','context-read':'路径查询'};
|
|
105
|
+
const METHODS={'additional-context':['上下文注入',''],denial:['拒绝工具调用','bad'],'tool-output':['AI 主动读取','']};
|
|
106
|
+
const CONFIRM={confirmed:['已进入会话记录','ok'],missing:['未找到','bad'],unknown:['无法核对','']};
|
|
107
|
+
const KINDS={prompt:['你的提示','prompt'],injection:['Sumi 送达',''],'agent-read':['AI 读取','read'],document:['Sumi 读取','plain'],command:['Sumi 命令','plain']};
|
|
108
|
+
const FILTERS=[['deliveries','送达与读取'],['all','全部事件']];
|
|
109
|
+
let sessions=[];let selected=decodeURIComponent(location.hash.slice(1));let events=[];let next=0;let confirmations={};let host='';let project='';let view='deliveries';
|
|
110
|
+
const keyOf=(item)=>item.projectId+':'+item.id;const chars=(value)=>value>=10000?(value/10000).toFixed(1)+' 万':String(value);
|
|
111
|
+
const current=()=>sessions.find((item)=>keyOf(item)===selected);
|
|
112
|
+
function filtered(){return sessions.filter((item)=>(!host||item.host===host)&&(!project||item.projectId===project))}
|
|
113
|
+
function renderList(){const list=byId('list');const items=filtered();list.replaceChildren(...items.map((item)=>{const button=make('button','sess');button.type='button';button.setAttribute('aria-current',String(keyOf(item)===selected));const top=make('span','t');top.append(make('strong','',item.title||item.session||item.id),make('span','mono m',stamp(item.updatedAt)));button.append(top,make('span','m',[item.project,item.host||'宿主未知','送达 '+item.deliveries+' 次',item.awaiting||''].filter(Boolean).join(' · ')));button.addEventListener('click',()=>select(keyOf(item)));return button}));if(!items.length)list.append(make('div','empty','没有会话。接线 hook 后,新的会话会出现在这里。'))}
|
|
114
|
+
function renderFilters(board){const hosts=[...new Set(sessions.map((item)=>item.host).filter(Boolean))];const projectBox=byId('project');if(projectBox.options.length!==board.projects.length+1){projectBox.replaceChildren(new Option('全部项目',''),...board.projects.map((entry)=>new Option(entry.name,entry.id)));projectBox.value=project}const hostBox=byId('host');if(hostBox.options.length!==hosts.length+1){hostBox.replaceChildren(new Option('全部',''),...hosts.map((name)=>new Option(name,name)));hostBox.value=host}}
|
|
115
|
+
function renderHeader(){const item=current();byId('title').textContent=item?item.title||'未记录提示词的会话':'选择一个会话';byId('meta').textContent=item?[item.project,item.host,item.session,item.checkouts.join('、'),item.agents.length?'子代理 '+item.agents.length+' 个':''].filter(Boolean).join(' · '):'';const stats=byId('stats');if(!item){stats.replaceChildren();return}const count=(state)=>Object.values(confirmations).filter((value)=>value===state).length;stats.replaceChildren(...[[chars(item.chars),'送达字符'],[item.deliveries,'送达次数'],[item.prompts,'你的提示'],[count('confirmed'),'已进入会话记录'],[count('missing'),'未找到'],[item.reads,'AI 主动读取'],[item.denials,'拒绝式送达']].map(([value,label])=>{const box=make('div','stat');box.append(make('span','',label),make('strong','',value));return box}))}
|
|
116
|
+
function groups(items){const map=new Map();for(const entry of items){if(entry.key==='catalog:complete')continue;const prefix=entry.key.split(':')[0];map.set(prefix,[...(map.get(prefix)||[]),entry])}return map}
|
|
117
|
+
function title(event){if(event.kind==='injection')return (CHANNELS[event.channel]||event.channel||'上下文')+(event.agent?' · 子代理':'');if(event.kind==='command')return 'sumi '+(event.command||'')+(Array.isArray(event.args)&&event.args.length?' '+event.args.join(' ').slice(0,80):'');if(event.kind==='prompt')return (event.content||'').split('\\n')[0].slice(0,160);return event.source||''}
|
|
118
|
+
function renderEvent(event){const row=make('li',event.kind==='injection'||event.kind==='prompt'||event.kind==='agent-read'?'':'hidden-by-view');row.dataset.at=event.at||'';const head=make('div','row');const time=make('time','',clock(event.at));if(event.at)time.dateTime=event.at;const kind=KINDS[event.kind]||[event.kind,'plain'];const what=make('span','what');what.append(make('b','',title(event)));const notes=[];if(event.kind==='injection'){const method=METHODS[event.method]||[event.method||'方式未知',''];notes.push(method[0]);if(event.checkout)notes.push('检出 '+event.checkout)}if(event.paths&&event.paths.length)notes.push('触发路径 '+event.paths.slice(0,4).join('、')+(event.paths.length>4?' 等 '+event.paths.length+' 个':''));if(event.selected&&event.selected.length)notes.push('选中 '+event.selected.join('、'));if(notes.length)what.append(make('small','',notes.join(' · ')));head.append(time,make('span','chip kind '+kind[1],kind[0]),what);if(event.kind==='injection'){const state=make('span','tag','核对中');state.dataset.confirm=event.id;head.append(state)}const text=event.kind==='command'?event.output||'':event.content||'';if(text)head.append(make('span','mono note',text.length+' 字'));row.append(head);const lines=[];for(const [prefix,group] of groups(event.items||[]))lines.push('送达 '+group.length+' 条:'+group.slice(0,6).map((entry)=>entry.key).join('、')+(group.length>6?' 等':''));const skipped=event.skipped||[];if(skipped.length)lines.push('跳过 '+skipped.length+' 条:'+skipped.slice(0,4).map((entry)=>entry.key+'('+entry.reason+')').join('、'));if(lines.length){const box=make('div','note');box.style.margin='6px 0 0 68px';box.textContent=lines.join(';');row.append(box)}if(text){const details=make('details');details.append(make('summary','','查看全文'),make('pre','',text));row.append(details)}return row}
|
|
119
|
+
function insert(event){const target=byId('timeline');const row=renderEvent(event);let before=null;for(let node=target.lastElementChild;node;node=node.previousElementSibling){if((node.dataset.at||'')<=(event.at||''))break;before=node}target.insertBefore(row,before)}
|
|
120
|
+
function applyConfirmations(){for(const [id,state] of Object.entries(confirmations)){const node=document.querySelector('[data-confirm="'+id+'"]');if(!node)continue;const def=CONFIRM[state];node.textContent=def[0];node.className='tag '+def[1]}}
|
|
121
|
+
async function loadEvents(key){const item=current();if(!item)return;for(let more=true;more&&key===selected;){const page=await getJson('/api/projects/'+item.projectId+'/sessions/'+item.id+'/events?after='+next);if(key!==selected)return;for(const event of page.events){events.push(event);insert(event)}more=page.more&&page.next>next;next=page.next}byId('count').textContent='共 '+events.length+' 条事件'}
|
|
122
|
+
async function loadConfirmations(key){const item=current();if(!item)return;try{const value=await getJson('/api/projects/'+item.projectId+'/sessions/'+item.id+'/confirmations');if(key!==selected)return;confirmations=value;applyConfirmations();renderHeader()}catch{}}
|
|
123
|
+
async function select(key){if(selected===key)return;selected=key;history.replaceState(null,'','#'+encodeURIComponent(key));events=[];next=0;confirmations={};byId('timeline').replaceChildren();renderList();renderHeader();try{await loadEvents(key);await loadConfirmations(key)}catch{byId('count').textContent='无法读取该会话'}}
|
|
124
|
+
async function refresh(){try{const board=await getJson('/api/board');sessions=board.sessions;byId('summary').textContent='本机 '+board.projects.length+' 个项目 · '+sessions.length+' 个会话';const need=byId('need');need.hidden=!board.needsYou;need.textContent='需要你 '+board.needsYou;renderFilters(board);if(!current()&&sessions[0]){selected='';await select(keyOf(sessions[0]));return}renderList();renderHeader();if(current()){history.replaceState(null,'','#'+encodeURIComponent(selected));await loadEvents(selected)}}catch{byId('summary').textContent='无法读取 hub 数据'}}
|
|
125
|
+
byId('project').addEventListener('change',(event)=>{project=event.target.value;renderList()});byId('host').addEventListener('change',(event)=>{host=event.target.value;renderList()});
|
|
126
|
+
byId('pills').replaceChildren(...FILTERS.map(([id,label])=>{const button=make('button','pill',label);button.type='button';button.setAttribute('aria-pressed',String(id===view));button.addEventListener('click',()=>{view=id;byId('timeline').dataset.view=id;for(const option of byId('pills').children)option.setAttribute('aria-pressed',String(option===button))});return button}));
|
|
127
|
+
addEventListener('hashchange',()=>{const key=decodeURIComponent(location.hash.slice(1));selected='';select(key)});
|
|
128
|
+
refresh();setInterval(refresh,3000);setInterval(()=>{if(selected)loadConfirmations(selected)},8000);`;
|
|
129
|
+
export const SESSIONS_PAGE = shell('Sumi 会话', 'sessions', `<div class="filters"><label for="project">项目</label><select id="project"><option value="">全部项目</option></select><label for="host">代理</label><select id="host"><option value="">全部</option></select></div>
|
|
130
|
+
<div class="layout"><nav id="list" class="list" aria-label="会话列表"></nav>
|
|
131
|
+
<main class="sessions"><div><div id="meta" class="meta"></div><h1 id="title">选择一个会话</h1></div>
|
|
132
|
+
<section id="stats" class="stats" aria-label="送达总量"></section>
|
|
133
|
+
<div id="pills" class="pills" role="group" aria-label="筛选事件"></div><span id="count" class="meta"></span>
|
|
134
|
+
<ol id="timeline" class="events" data-view="deliveries" aria-label="事件时间线"></ol>
|
|
135
|
+
<p class="note"><strong>证据范围</strong>:“已进入会话记录”表示这段正文出现在宿主的会话记录文件里,不表示 AI 理解或遵循了它。“无法核对”表示宿主没有提供会话记录。“AI 读取”来自宿主 Read 工具;Shell、MCP 和宿主自动加载的读取不在观测范围内。“Sumi 读取”只表示 Sumi 打开了文档。事件保存在各项目 git 公共目录的 sumi/sessions 下,hub 只读取,可能包含提示词和开发上下文。</p></main></div>`, SESSIONS_SCRIPT);
|
|
136
|
+
//# sourceMappingURL=pages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pages.js","sourceRoot":"","sources":["../../src/hub/pages.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,sCAAsC;AAEtC,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wPAsD0O,CAAC;AAEzP,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,MAA4B,EAAE,OAAe,EAAE,MAAc,EAAE,EAAE,CAAC;;;;SAIvF,KAAK;SACL,KAAK;;;;+CAIiC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE,6BAA6B,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE;;;EAG7K,OAAO;;;;;;;EAOP,MAAM;wBACgB,CAAC;AAEzB,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;qCAqBgB,CAAC;AAEtC,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAC7B,SAAS,EACT,OAAO,EACP;yIACuI,EACvI,YAAY,CACb,CAAC;AAEF,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;qGAyB6E,CAAC;AAEtG,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAChC,SAAS,EACT,UAAU,EACV;;;;;;wPAMsP,EACtP,eAAe,CAChB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { KernelError } from '@sumi/kernel';
|
|
2
|
+
import { type Collector } from './board.js';
|
|
3
|
+
export interface HubOptions {
|
|
4
|
+
/** 首选端口;被占用时顺延。0 表示由系统分配(测试用)。 */
|
|
5
|
+
port?: number;
|
|
6
|
+
idleMs?: number;
|
|
7
|
+
checkEveryMs?: number;
|
|
8
|
+
now?: () => number;
|
|
9
|
+
collector?: Collector;
|
|
10
|
+
}
|
|
11
|
+
/** 同一用户已有 hub 在运行。 */
|
|
12
|
+
export declare class HubRunningError extends KernelError {
|
|
13
|
+
}
|
|
14
|
+
export declare const IDLE_MS: number;
|
|
15
|
+
export interface RunningHub {
|
|
16
|
+
url: string;
|
|
17
|
+
port: number;
|
|
18
|
+
close: () => Promise<void>;
|
|
19
|
+
/** 服务关闭(主动关闭或空闲退出)后完成。 */
|
|
20
|
+
closed: Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
/** 启动 hub:单实例、只绑定回环地址、只读。进程号锁与状态文件由本函数持有并在关闭时清理。 */
|
|
23
|
+
export declare function startHub(options?: HubOptions): Promise<RunningHub>;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { createServer } from 'node:http';
|
|
2
|
+
import { KernelError } from '@sumi/kernel';
|
|
3
|
+
import { buildBoard, createCollector, projectId } from './board.js';
|
|
4
|
+
import { BOARD_PAGE, SESSIONS_PAGE } from './pages.js';
|
|
5
|
+
import { acquireHubLock, HEALTH, HUB_PORT, readProjects, releaseHubFiles, writeHubState } from './state.js';
|
|
6
|
+
/** 同一用户已有 hub 在运行。 */
|
|
7
|
+
export class HubRunningError extends KernelError {
|
|
8
|
+
}
|
|
9
|
+
export const IDLE_MS = 8 * 3600_000;
|
|
10
|
+
const PORT_SPAN = 20;
|
|
11
|
+
function listen(server, first) {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
let port = first;
|
|
14
|
+
const attempt = () => {
|
|
15
|
+
server.once('error', (error) => {
|
|
16
|
+
if (error.code === 'EADDRINUSE' && first !== 0 && port < first + PORT_SPAN) {
|
|
17
|
+
port += 1;
|
|
18
|
+
attempt();
|
|
19
|
+
}
|
|
20
|
+
else
|
|
21
|
+
reject(error);
|
|
22
|
+
});
|
|
23
|
+
server.listen(port, '127.0.0.1', () => {
|
|
24
|
+
server.removeAllListeners('error');
|
|
25
|
+
resolve(server.address().port);
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
attempt();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** 启动 hub:单实例、只绑定回环地址、只读。进程号锁与状态文件由本函数持有并在关闭时清理。 */
|
|
32
|
+
export async function startHub(options = {}) {
|
|
33
|
+
if (!acquireHubLock())
|
|
34
|
+
throw new HubRunningError('已有 hub 在运行(sumi hub status 查看,sumi hub stop 停止)');
|
|
35
|
+
const now = options.now ?? Date.now;
|
|
36
|
+
const collector = options.collector ?? createCollector({});
|
|
37
|
+
const startedAt = now();
|
|
38
|
+
let port = 0;
|
|
39
|
+
const server = createServer((req, res) => {
|
|
40
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
41
|
+
res.setHeader('X-Content-Type-Options', 'nosniff');
|
|
42
|
+
res.setHeader('Content-Security-Policy', "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; connect-src 'self'");
|
|
43
|
+
if (req.headers.host !== `127.0.0.1:${port}`) {
|
|
44
|
+
res.statusCode = 403;
|
|
45
|
+
res.end('Forbidden');
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (req.method !== 'GET') {
|
|
49
|
+
res.statusCode = 405;
|
|
50
|
+
res.end('Method Not Allowed');
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const url = new URL(req.url ?? '/', 'http://localhost');
|
|
54
|
+
const json = (value) => {
|
|
55
|
+
res.setHeader('Content-Type', 'application/json; charset=utf-8');
|
|
56
|
+
if (value === null || value === undefined)
|
|
57
|
+
res.statusCode = 404;
|
|
58
|
+
res.end(JSON.stringify(value ?? null));
|
|
59
|
+
};
|
|
60
|
+
const html = (page) => {
|
|
61
|
+
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
62
|
+
res.end(page);
|
|
63
|
+
};
|
|
64
|
+
const detail = /^\/api\/projects\/([A-Za-z0-9_-]+)\/sessions\/([0-9a-f]{32})\/(events|confirmations)$/.exec(url.pathname);
|
|
65
|
+
const fail = () => {
|
|
66
|
+
res.statusCode = 500;
|
|
67
|
+
res.end('Internal Error');
|
|
68
|
+
};
|
|
69
|
+
if (url.pathname === '/api/health')
|
|
70
|
+
json({ ...HEALTH, pid: process.pid });
|
|
71
|
+
else if (url.pathname === '/api/board')
|
|
72
|
+
buildBoard(readProjects(), collector).then(json, fail);
|
|
73
|
+
else if (detail) {
|
|
74
|
+
const entry = readProjects().find((project) => projectId(project.path) === detail[1]);
|
|
75
|
+
const after = Number(url.searchParams.get('after'));
|
|
76
|
+
const args = [
|
|
77
|
+
'--session',
|
|
78
|
+
detail[2],
|
|
79
|
+
...(detail[3] === 'confirmations'
|
|
80
|
+
? ['--confirmations']
|
|
81
|
+
: ['--after', String(Number.isSafeInteger(after) && after >= 0 ? after : 0)]),
|
|
82
|
+
];
|
|
83
|
+
if (!entry)
|
|
84
|
+
json(null);
|
|
85
|
+
else
|
|
86
|
+
collector.detail(entry.path, args).then((result) => json(result?.[detail[3]] ?? null), () => json(null));
|
|
87
|
+
}
|
|
88
|
+
else if (url.pathname === '/')
|
|
89
|
+
html(BOARD_PAGE);
|
|
90
|
+
else if (url.pathname === '/sessions')
|
|
91
|
+
html(SESSIONS_PAGE);
|
|
92
|
+
else {
|
|
93
|
+
res.statusCode = 404;
|
|
94
|
+
res.end('Not found');
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
let closing = null;
|
|
98
|
+
let finished;
|
|
99
|
+
const closed = new Promise((resolve) => (finished = resolve));
|
|
100
|
+
const close = () => (closing ??= (async () => {
|
|
101
|
+
clearInterval(timer);
|
|
102
|
+
server.closeAllConnections();
|
|
103
|
+
await new Promise((resolve) => server.close(() => resolve()));
|
|
104
|
+
releaseHubFiles(process.pid);
|
|
105
|
+
finished();
|
|
106
|
+
})());
|
|
107
|
+
try {
|
|
108
|
+
port = await listen(server, options.port ?? HUB_PORT);
|
|
109
|
+
writeHubState({ pid: process.pid, port, startedAt, lastActivityAt: startedAt });
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
await new Promise((resolve) => server.close(() => resolve()));
|
|
113
|
+
releaseHubFiles();
|
|
114
|
+
throw error instanceof KernelError ? error : new KernelError(`无法启动 hub:${error.message}`);
|
|
115
|
+
}
|
|
116
|
+
// 最近的会话活动取登记表里最晚的会话开始时间;浏览页面不算
|
|
117
|
+
const idleMs = options.idleMs ?? IDLE_MS;
|
|
118
|
+
const timer = setInterval(() => {
|
|
119
|
+
const lastActivityAt = Math.max(startedAt, ...readProjects().map((project) => project.lastSeenAt));
|
|
120
|
+
if (now() - lastActivityAt > idleMs)
|
|
121
|
+
void close();
|
|
122
|
+
else
|
|
123
|
+
writeHubState({ pid: process.pid, port, startedAt, lastActivityAt });
|
|
124
|
+
}, options.checkEveryMs ?? 60_000);
|
|
125
|
+
timer.unref();
|
|
126
|
+
return { url: `http://127.0.0.1:${port}`, port, close, closed };
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/hub/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAkB,MAAM,YAAY,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAW5G,sBAAsB;AACtB,MAAM,OAAO,eAAgB,SAAQ,WAAW;CAAG;AAEnD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,G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PSHOT_SCHEMA = 1;
|
|
4
|
+
export interface RunSummary {
|
|
5
|
+
runId: string;
|
|
6
|
+
flow: string;
|
|
7
|
+
conclusion: string;
|
|
8
|
+
partial: boolean;
|
|
9
|
+
startedAt: string;
|
|
10
|
+
finishedAt: string | null;
|
|
11
|
+
}
|
|
12
|
+
export interface CheckoutSnapshot {
|
|
13
|
+
path: string;
|
|
14
|
+
branch: string | null;
|
|
15
|
+
isDefault: boolean;
|
|
16
|
+
merged: boolean;
|
|
17
|
+
/** 最近的运行,新的在前。 */
|
|
18
|
+
runs: RunSummary[];
|
|
19
|
+
contribution: HubContribution;
|
|
20
|
+
}
|
|
21
|
+
export type SessionSnapshot = SessionSummary & {
|
|
22
|
+
awaiting?: string;
|
|
23
|
+
};
|
|
24
|
+
export interface ProjectSnapshot {
|
|
25
|
+
schemaVersion: typeof SNAPSHOT_SCHEMA;
|
|
26
|
+
name: string;
|
|
27
|
+
root: string;
|
|
28
|
+
checkouts: CheckoutSnapshot[];
|
|
29
|
+
sessions: SessionSnapshot[];
|
|
30
|
+
diagnostics: string[];
|
|
31
|
+
}
|
|
32
|
+
/** 项目自己的只读快照:检出与分支、最近运行、会话列表及插件贡献。不修改任何项目数据。 */
|
|
33
|
+
export declare function buildSnapshot(root: string, now?: number): ProjectSnapshot;
|
|
34
|
+
/** 会话明细:直接复用单项目页的账本读取。 */
|
|
35
|
+
export declare function sessionDetail(root: string, id: string, view: {
|
|
36
|
+
confirmations: boolean;
|
|
37
|
+
after: number;
|
|
38
|
+
}): {
|
|
39
|
+
confirmations: Record<string, import("../visualize-sessions.js").Confirmation> | null;
|
|
40
|
+
schemaVersion: number;
|
|
41
|
+
} | {
|
|
42
|
+
events: {
|
|
43
|
+
events: import("../visualize-sessions.js").LedgerEvent[];
|
|
44
|
+
next: number;
|
|
45
|
+
more: boolean;
|
|
46
|
+
} | null;
|
|
47
|
+
schemaVersion: number;
|
|
48
|
+
};
|