@cortex-agent/server 2026.7.30 → 2026.8.3-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/defaults/CORTEX.md +1 -0
- package/defaults/config/CORTEX.md +2 -1
- package/defaults/config/hooks/13-status-md-guard.json +11 -0
- package/defaults/config/hooks/CORTEX.md +1 -0
- package/defaults/config/mcp-config-empty.json +3 -0
- package/defaults/config/thread-templates/agents/benchmark-coder.json +22 -0
- package/defaults/config/thread-templates/agents/benchmark-reviewer.json +22 -0
- package/defaults/config/thread-templates/agents/coder-reviewer.json +4 -9
- package/defaults/config/thread-templates/agents/coder.json +4 -14
- package/defaults/config/thread-templates/templates/benchmark-coder-review.json +37 -0
- package/defaults/config/thread-templates/templates/coder-review.json +3 -27
- package/defaults/context/projects/CORTEX.md +1 -1
- package/defaults/data/schedules.json +12 -0
- package/defaults/hooks/CORTEX.md +1 -0
- package/defaults/hooks/new-session-hook.mjs +2 -2
- package/defaults/hooks/status-md-guard.mjs +193 -0
- package/defaults/plugins/cortex-coder/.claude-plugin/plugin.json +1 -1
- package/defaults/plugins/cortex-coder/skills/develop/SKILL.md +28 -2
- package/defaults/plugins/cortex-common/.claude-plugin/plugin.json +1 -1
- package/defaults/plugins/cortex-common/skills/compound/SKILL.md +1 -1
- package/defaults/plugins/cortex-common/skills/compound-simple/SKILL.md +4 -2
- package/defaults/plugins/cortex-common/skills/postmortem/SKILL.md +1 -1
- package/defaults/plugins/cortex-stage-gate/.claude-plugin/plugin.json +1 -1
- package/defaults/plugins/cortex-stage-gate/skills/director-method/SKILL.md +1 -1
- package/defaults/plugins/cortex-stage-gate/skills/need-approval/SKILL.md +1 -0
- package/defaults/plugins/cortex-stage-gate/skills/reorient/SKILL.md +2 -2
- package/defaults/plugins/cortex-stage-gate/skills/task/SKILL.md +11 -8
- package/defaults/plugins/cortex-system/skills/feedback/SKILL.md +1 -1
- package/defaults/plugins/cortex-system/skills/project-init/SKILL.md +13 -16
- package/defaults/prompts/directives/coder-reviewer.md +24 -20
- package/defaults/prompts/directives/coder.md +4 -5
- package/defaults/prompts/directives/director.md +4 -10
- package/defaults/prompts/directives/manager.md +9 -10
- package/defaults/prompts/systemPrompts/worker.md +2 -2
- package/defaults/rules/cortex-md.md +31 -0
- package/defaults/rules/experiment-format.md +8 -1
- package/defaults/rules/issues-md.md +10 -9
- package/defaults/rules/meta-conventions.md +5 -4
- package/defaults/rules/mission-md.md +2 -1
- package/defaults/rules/status-md.md +39 -21
- package/dist/agent-adapter/bg-wait.d.ts +10 -12
- package/dist/agent-adapter/bg-wait.js +209 -129
- package/dist/agent-adapter/claude/adapter-tui.d.ts +3 -1
- package/dist/agent-adapter/claude/adapter-tui.js +8 -5
- package/dist/agent-adapter/claude/adapter.d.ts +43 -14
- package/dist/agent-adapter/claude/adapter.js +276 -161
- package/dist/agent-adapter/claude/defaults.d.ts +2 -0
- package/dist/agent-adapter/claude/defaults.js +5 -5
- package/dist/agent-adapter/claude/event-parser.d.ts +3 -8
- package/dist/agent-adapter/claude/event-parser.js +28 -31
- package/dist/agent-adapter/claude/hooks-builder.js +4 -3
- package/dist/agent-adapter/claude/jsonl-tail.js +54 -35
- package/dist/agent-adapter/claude/spawn-args.d.ts +15 -12
- package/dist/agent-adapter/claude/spawn-args.js +44 -38
- package/dist/agent-adapter/claude/tmux-control.d.ts +4 -17
- package/dist/agent-adapter/claude/tmux-control.js +39 -32
- package/dist/agent-adapter/event-tee.d.ts +19 -0
- package/dist/agent-adapter/event-tee.js +145 -0
- package/dist/agent-adapter/index.d.ts +1 -0
- package/dist/agent-adapter/index.js +7 -3
- package/dist/agent-adapter/normalize/event-types.d.ts +17 -9
- package/dist/agent-adapter/normalize/event-types.js +4 -4
- package/dist/agent-adapter/pi/adapter.d.ts +16 -4
- package/dist/agent-adapter/pi/adapter.js +69 -36
- package/dist/agent-adapter/pi/discovery.d.ts +19 -3
- package/dist/agent-adapter/pi/discovery.js +81 -43
- package/dist/agent-adapter/pi/event-parser.js +4 -2
- package/dist/agent-adapter/pi/spawn-args.d.ts +2 -4
- package/dist/agent-adapter/pi/spawn-args.js +6 -5
- package/dist/agent-adapter/types.d.ts +43 -2
- package/dist/agent-adapter/types.js +8 -4
- package/dist/core/atomic-write.d.ts +6 -1
- package/dist/core/atomic-write.js +183 -7
- package/dist/core/cli-utils.d.ts +15 -2
- package/dist/core/cli-utils.js +46 -41
- package/dist/core/config-generator.d.ts +4 -0
- package/dist/core/config-generator.js +34 -21
- package/dist/core/json-repository.d.ts +4 -0
- package/dist/core/json-repository.js +6 -3
- package/dist/core/locales/en.d.ts +94 -0
- package/dist/core/locales/slices/commands.d.ts +76 -0
- package/dist/core/locales/slices/commands.js +155 -1
- package/dist/core/locales/slices/status.d.ts +18 -0
- package/dist/core/locales/slices/status.js +43 -2
- package/dist/core/log.d.ts +5 -0
- package/dist/core/log.js +25 -23
- package/dist/core/pi-session-filename.d.ts +2 -0
- package/dist/core/pi-session-filename.js +18 -0
- package/dist/core/resume-reminder.d.ts +5 -0
- package/dist/core/resume-reminder.js +18 -0
- package/dist/core/runtime-env.d.ts +1 -0
- package/dist/core/runtime-env.js +15 -0
- package/dist/core/settings-migration.d.ts +5 -0
- package/dist/core/settings-migration.js +128 -0
- package/dist/core/settings-spec.d.ts +174 -0
- package/dist/core/settings-spec.js +150 -0
- package/dist/core/settings.d.ts +10 -0
- package/dist/core/settings.js +235 -0
- package/dist/core/task-parser.d.ts +11 -1
- package/dist/core/task-parser.js +34 -3
- package/dist/core/types/agent-types.d.ts +19 -0
- package/dist/core/types/agent-types.js +1 -1
- package/dist/core/types/thread-types.d.ts +48 -3
- package/dist/core/types/thread-types.js +2 -2
- package/dist/core/utils.d.ts +21 -1
- package/dist/core/utils.js +37 -1
- package/dist/domain/agent-run/access-probe-cli.d.ts +7 -0
- package/dist/domain/agent-run/access-probe-cli.js +139 -0
- package/dist/domain/agent-run/access-probe-policy.d.ts +61 -0
- package/dist/domain/agent-run/access-probe-policy.js +614 -0
- package/dist/domain/agent-run/access-probe.d.ts +21 -0
- package/dist/domain/agent-run/access-probe.js +194 -0
- package/dist/domain/agent-run/agent-run-cli.d.ts +19 -0
- package/dist/domain/agent-run/agent-run-cli.js +171 -0
- package/dist/domain/agent-run/atif.d.ts +54 -0
- package/dist/domain/agent-run/atif.js +211 -0
- package/dist/domain/agent-run/benchmark-local-thread-orchestrator.d.ts +32 -0
- package/dist/domain/agent-run/benchmark-local-thread-orchestrator.js +616 -0
- package/dist/domain/agent-run/benchmark-thread-identity.d.ts +34 -0
- package/dist/domain/agent-run/benchmark-thread-identity.js +106 -0
- package/dist/domain/agent-run/identity.d.ts +62 -0
- package/dist/domain/agent-run/identity.js +118 -0
- package/dist/domain/agent-run/journal.d.ts +51 -0
- package/dist/domain/agent-run/journal.js +259 -0
- package/dist/domain/agent-run/manifest-contract.d.ts +44 -0
- package/dist/domain/agent-run/manifest-contract.js +134 -0
- package/dist/domain/agent-run/manifest.d.ts +51 -0
- package/dist/domain/agent-run/manifest.js +801 -0
- package/dist/domain/agent-run/pinned-node-process.d.ts +35 -0
- package/dist/domain/agent-run/pinned-node-process.js +206 -0
- package/dist/domain/agent-run/role-surface.d.ts +4 -0
- package/dist/domain/agent-run/role-surface.js +99 -0
- package/dist/domain/agent-run/run-config.d.ts +22 -0
- package/dist/domain/agent-run/run-config.js +135 -0
- package/dist/domain/agent-run/runner.d.ts +7 -0
- package/dist/domain/agent-run/runner.js +518 -0
- package/dist/domain/agent-run/supervisor.d.ts +78 -0
- package/dist/domain/agent-run/supervisor.js +425 -0
- package/dist/domain/agent-run/trajectory-merge-cli.d.ts +11 -0
- package/dist/domain/agent-run/trajectory-merge-cli.js +111 -0
- package/dist/domain/agent-run/trajectory-merge.d.ts +39 -0
- package/dist/domain/agent-run/trajectory-merge.js +505 -0
- package/dist/domain/agents/config.d.ts +10 -0
- package/dist/domain/agents/config.js +149 -44
- package/dist/domain/agents/facade.d.ts +42 -7
- package/dist/domain/agents/facade.js +174 -170
- package/dist/domain/agents/provider-run-lifecycle.d.ts +18 -0
- package/dist/domain/agents/provider-run-lifecycle.js +60 -0
- package/dist/domain/auth/auth-events.d.ts +18 -0
- package/dist/domain/auth/auth-events.js +38 -0
- package/dist/domain/auth/auth-format.d.ts +2 -0
- package/dist/domain/auth/auth-format.js +58 -0
- package/dist/domain/auth/auth-status.d.ts +61 -0
- package/dist/domain/auth/auth-status.js +304 -0
- package/dist/domain/auth/auth-watch.d.ts +16 -0
- package/dist/domain/auth/auth-watch.js +125 -0
- package/dist/domain/auth/cc-login.d.ts +7 -0
- package/dist/domain/auth/cc-login.js +16 -0
- package/dist/domain/auth/cc-subscription.d.ts +38 -0
- package/dist/domain/auth/cc-subscription.js +204 -0
- package/dist/domain/auth/index.d.ts +12 -0
- package/dist/domain/auth/index.js +16 -0
- package/dist/domain/auth/login-flow.d.ts +120 -0
- package/dist/domain/auth/login-flow.js +253 -0
- package/dist/domain/auth/login-service.d.ts +32 -0
- package/dist/domain/auth/login-service.js +97 -0
- package/dist/domain/auth/logout.d.ts +32 -0
- package/dist/domain/auth/logout.js +123 -0
- package/dist/domain/auth/pi-login.d.ts +36 -0
- package/dist/domain/auth/pi-login.js +72 -0
- package/dist/domain/auth/pi-oauth.d.ts +36 -0
- package/dist/domain/auth/pi-oauth.js +84 -0
- package/dist/domain/auth/pi-runtime.d.ts +72 -0
- package/dist/domain/auth/pi-runtime.js +86 -0
- package/dist/domain/mcp/benchmark-thread-server.d.ts +1 -0
- package/dist/domain/mcp/benchmark-thread-server.js +26 -0
- package/dist/domain/mcp/tools/benchmark-thread-run.d.ts +23 -0
- package/dist/domain/mcp/tools/benchmark-thread-run.js +146 -0
- package/dist/domain/memory/user-context.js +6 -8
- package/dist/domain/monitor/disk-monitor.js +47 -16
- package/dist/domain/projects/project-store.js +23 -6
- package/dist/domain/remote/client-hot-reload.d.ts +9 -1
- package/dist/domain/remote/client-hot-reload.js +60 -12
- package/dist/domain/remote/client-manager.js +12 -6
- package/dist/domain/scheduling/jobs/auth-expiry-scan.d.ts +14 -0
- package/dist/domain/scheduling/jobs/auth-expiry-scan.js +86 -0
- package/dist/domain/scheduling/jobs/task-dispatch.js +36 -40
- package/dist/domain/scheduling/runner.d.ts +2 -0
- package/dist/domain/scheduling/runner.js +7 -4
- package/dist/domain/sessions/session-backup.d.ts +14 -20
- package/dist/domain/sessions/session-backup.js +57 -68
- package/dist/domain/system/doctor.d.ts +4 -0
- package/dist/domain/system/doctor.js +113 -28
- package/dist/domain/system/install-cli.js +8 -3
- package/dist/domain/system/server-update-check.js +7 -5
- package/dist/domain/system/system-notice.d.ts +3 -1
- package/dist/domain/system/system-notice.js +6 -11
- package/dist/domain/tasks/archiver.d.ts +1 -0
- package/dist/domain/tasks/archiver.js +13 -7
- package/dist/domain/tasks/claim-recovery.d.ts +3 -3
- package/dist/domain/tasks/claim-recovery.js +12 -8
- package/dist/domain/tasks/dispatch-utils.d.ts +15 -14
- package/dist/domain/tasks/dispatch-utils.js +22 -18
- package/dist/domain/tasks/dispatcher.d.ts +1 -0
- package/dist/domain/tasks/dispatcher.js +9 -5
- package/dist/domain/tasks/mutator.d.ts +21 -11
- package/dist/domain/tasks/mutator.js +30 -24
- package/dist/domain/tasks/pending-tracker.d.ts +5 -2
- package/dist/domain/tasks/pending-tracker.js +11 -5
- package/dist/domain/tasks/system/cortex-run.d.ts +2 -1
- package/dist/domain/tasks/system/cortex-run.js +24 -4
- package/dist/domain/tasks/system/task-cli.d.ts +1 -0
- package/dist/domain/tasks/system/task-cli.js +72 -22
- package/dist/domain/tasks/system/task-completion.d.ts +19 -2
- package/dist/domain/tasks/system/task-completion.js +31 -17
- package/dist/domain/tasks/system/task-file-input.d.ts +10 -0
- package/dist/domain/tasks/system/task-file-input.js +57 -0
- package/dist/domain/tasks/system/task-id-utils.d.ts +9 -9
- package/dist/domain/tasks/system/task-id-utils.js +13 -4
- package/dist/domain/tasks/system/task-lifecycle-edit.d.ts +6 -2
- package/dist/domain/tasks/system/task-lifecycle-edit.js +200 -6
- package/dist/domain/tasks/system/task-lock.js +19 -5
- package/dist/domain/tasks/system/task-mutations.d.ts +22 -12
- package/dist/domain/tasks/system/task-mutations.js +28 -4
- package/dist/domain/tasks/system/task-process.js +10 -8
- package/dist/domain/tasks/system/task-state.d.ts +65 -11
- package/dist/domain/tasks/system/task-state.js +86 -13
- package/dist/domain/threads/local-runtime-deps.d.ts +32 -0
- package/dist/domain/threads/local-runtime-deps.js +91 -0
- package/dist/domain/threads/local-runtime-scope.d.ts +6 -0
- package/dist/domain/threads/local-runtime-scope.js +12 -0
- package/dist/domain/threads/pending-user-inputs.d.ts +3 -0
- package/dist/domain/threads/pending-user-inputs.js +37 -0
- package/dist/domain/threads/prompt-builder.d.ts +12 -1
- package/dist/domain/threads/prompt-builder.js +73 -26
- package/dist/domain/threads/runner.d.ts +15 -3
- package/dist/domain/threads/runner.js +261 -105
- package/dist/domain/threads/state-machine.d.ts +1 -1
- package/dist/domain/threads/state-machine.js +17 -8
- package/dist/domain/ui-service/app-router.d.ts +86 -6
- package/dist/domain/ui-service/app-router.js +171 -133
- package/dist/domain/ui-service/input-schemas.d.ts +132 -10
- package/dist/domain/ui-service/input-schemas.js +59 -5
- package/dist/domain/ui-service/mutate/approvals.d.ts +2 -1
- package/dist/domain/ui-service/mutate/approvals.js +2 -1
- package/dist/domain/ui-service/mutate/auth.d.ts +6 -0
- package/dist/domain/ui-service/mutate/auth.js +83 -0
- package/dist/domain/ui-service/mutate/config.js +11 -10
- package/dist/domain/ui-service/query/approvals.js +3 -0
- package/dist/domain/ui-service/query/auth.d.ts +6 -0
- package/dist/domain/ui-service/query/auth.js +12 -0
- package/dist/domain/ui-service/query/config.d.ts +5 -5
- package/dist/domain/ui-service/query/config.js +27 -17
- package/dist/domain/ui-service/query/tasks.d.ts +1 -1
- package/dist/domain/ui-service/query/tasks.js +69 -30
- package/dist/domain/ui-service/query/threads.js +3 -3
- package/dist/domain/ui-service/types.d.ts +67 -8
- package/dist/domain/ui-service/types.js +2 -2
- package/dist/domain/ui-service/ui-service.js +16 -2
- package/dist/entry/admin-channel-hot-reload.d.ts +4 -0
- package/dist/entry/admin-channel-hot-reload.js +22 -0
- package/dist/entry/app.js +38 -38
- package/dist/entry/auth-cli.d.ts +10 -0
- package/dist/entry/auth-cli.js +52 -0
- package/dist/entry/cli-help.d.ts +5 -0
- package/dist/entry/cli-help.js +130 -0
- package/dist/entry/cli.d.ts +5 -5
- package/dist/entry/cli.js +174 -248
- package/dist/entry/daemon.d.ts +11 -0
- package/dist/entry/daemon.js +204 -103
- package/dist/entry/draft-attachments.d.ts +8 -0
- package/dist/entry/draft-attachments.js +83 -0
- package/dist/entry/feishu-login.d.ts +2 -6
- package/dist/entry/feishu-login.js +16 -21
- package/dist/entry/init.js +6 -4
- package/dist/entry/start-ui-http.d.ts +2 -8
- package/dist/entry/start-ui-http.js +7 -34
- package/dist/events/event-logger.js +11 -13
- package/dist/events/event-types.d.ts +19 -1
- package/dist/events/event-types.js +3 -3
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +3 -3
- package/dist/hooks/new-session-hook.mjs +2 -2
- package/dist/hooks/status-md-guard.mjs +193 -0
- package/dist/orchestration/agent-file-send.js +44 -14
- package/dist/orchestration/agent-runner.d.ts +7 -3
- package/dist/orchestration/agent-runner.js +65 -41
- package/dist/orchestration/conversation-runner.d.ts +5 -1
- package/dist/orchestration/conversation-runner.js +16 -7
- package/dist/orchestration/lifecycle.d.ts +23 -1
- package/dist/orchestration/lifecycle.js +103 -40
- package/dist/orchestration/mid-turn-inject.d.ts +2 -0
- package/dist/orchestration/mid-turn-inject.js +29 -13
- package/dist/orchestration/resume-dispatcher.d.ts +3 -5
- package/dist/orchestration/resume-dispatcher.js +9 -17
- package/dist/orchestration/routing/commands/index.d.ts +4 -1
- package/dist/orchestration/routing/commands/index.js +83 -61
- package/dist/orchestration/routing/commands/login-notice.d.ts +21 -0
- package/dist/orchestration/routing/commands/login-notice.js +97 -0
- package/dist/orchestration/routing/commands/login.d.ts +12 -0
- package/dist/orchestration/routing/commands/login.js +555 -0
- package/dist/orchestration/routing/commands/status.js +45 -59
- package/dist/orchestration/routing/edit-handler.d.ts +5 -0
- package/dist/orchestration/routing/edit-handler.js +127 -73
- package/dist/orchestration/routing/webhook.js +5 -4
- package/dist/orchestration/session-rewind.d.ts +5 -1
- package/dist/orchestration/session-rewind.js +106 -62
- package/dist/orchestration/session-send.d.ts +2 -0
- package/dist/orchestration/session-send.js +5 -6
- package/dist/orchestration/status-helpers.d.ts +1 -2
- package/dist/orchestration/status-helpers.js +7 -10
- package/dist/orchestration/thread-callback.d.ts +19 -11
- package/dist/orchestration/thread-callback.js +132 -61
- package/dist/orchestration/thread-executor.js +37 -27
- package/dist/orchestration/turn-mutation-lock.d.ts +3 -0
- package/dist/orchestration/turn-mutation-lock.js +36 -0
- package/dist/orchestration/turn-notify.d.ts +2 -5
- package/dist/orchestration/turn-notify.js +9 -21
- package/dist/platform/adapter.d.ts +1 -0
- package/dist/platform/adapter.js +2 -2
- package/dist/platform/adapters/composite-adapter.d.ts +2 -0
- package/dist/platform/adapters/composite-adapter.js +13 -3
- package/dist/platform/adapters/feishu.d.ts +2 -4
- package/dist/platform/adapters/feishu.js +38 -59
- package/dist/platform/adapters/index.d.ts +1 -1
- package/dist/platform/adapters/index.js +13 -12
- package/dist/platform/adapters/slack.d.ts +1 -1
- package/dist/platform/adapters/slack.js +12 -35
- package/dist/platform/index.d.ts +2 -1
- package/dist/platform/index.js +3 -3
- package/dist/platform/testing.d.ts +1 -0
- package/dist/platform/testing.js +13 -4
- package/dist/platform/tool-trace.js +6 -11
- package/dist/platform/ui-http/ui-http-server.d.ts +1 -1
- package/dist/platform/ui-http/ui-http-server.js +6 -18
- package/dist/store/execution-repo.d.ts +17 -1
- package/dist/store/execution-repo.js +55 -4
- package/dist/store/prompt-migration-replacements.d.ts +4 -0
- package/dist/store/prompt-migration-replacements.js +149 -0
- package/dist/store/thread-repo.d.ts +15 -4
- package/dist/store/thread-repo.js +61 -24
- package/dist/store/version-migrations.js +36 -1
- package/native/cortex-supervisor/dist/build-manifest.json +22 -0
- package/native/cortex-supervisor/dist/cortex-supervisor +0 -0
- package/package.json +5 -2
- package/web/dist/assets/index-XqBCYtkw.js +139 -0
- package/web/dist/assets/index-zpf3OSKC.css +1 -0
- package/web/dist/index.html +2 -2
- package/dist/domain/scheduling/jobs/failed-dispatch-reconciliation.d.ts +0 -1
- package/dist/domain/scheduling/jobs/failed-dispatch-reconciliation.js +0 -78
- package/web/dist/assets/index-B19jLgji.js +0 -138
- package/web/dist/assets/index-BuFyPyRW.css +0 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
// input: config root, mounted-hook registry
|
|
2
|
-
// output: redacted
|
|
3
|
-
// pos:
|
|
4
|
-
// >>>
|
|
1
|
+
// input: config root, settings registry, mounted-hook registry
|
|
2
|
+
// output: redacted config plus plaintext settings provenance
|
|
3
|
+
// pos: Config.get snapshot reader
|
|
4
|
+
// >>> 一旦我被更新,务必更新我的开头注释与所属文件夹 CORTEX.md <<<
|
|
5
5
|
import fs from 'node:fs/promises';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { CONFIG_DIR } from '../../../core/paths.js';
|
|
8
|
+
import { getSettingsSnapshot, resolveSettingsSnapshot } from '../../../core/settings.js';
|
|
8
9
|
import { loadMountedHookSummaries } from '../../../store/hook-registry.js';
|
|
9
10
|
const MASK = '••••••••';
|
|
10
11
|
async function readJson(file) {
|
|
@@ -104,15 +105,27 @@ async function readEnv(file) {
|
|
|
104
105
|
return [];
|
|
105
106
|
}
|
|
106
107
|
}
|
|
108
|
+
async function readSettings(configDir) {
|
|
109
|
+
const raw = await readJson(path.join(configDir, 'settings.json'));
|
|
110
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
111
|
+
return resolveSettingsSnapshot({});
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
return resolveSettingsSnapshot(raw);
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return resolveSettingsSnapshot({});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
107
120
|
/**
|
|
108
|
-
* Read a
|
|
109
|
-
*
|
|
110
|
-
*
|
|
121
|
+
* Read a config snapshot from the supplied directory. Files remain hermetically scoped to that
|
|
122
|
+
* directory; settings use the process env fallback unless the caller supplies the live cached
|
|
123
|
+
* snapshot. A missing or malformed source affects only its own field.
|
|
111
124
|
*/
|
|
112
|
-
export async function readConfigSnapshot(configDir) {
|
|
125
|
+
export async function readConfigSnapshot(configDir, liveSettings) {
|
|
113
126
|
const tt = path.join(configDir, 'thread-templates');
|
|
114
127
|
const hooks = loadMountedHookSummaries(path.join(configDir, 'hooks'), path.join(tt, 'templates'));
|
|
115
|
-
const
|
|
128
|
+
const parts = await Promise.all([
|
|
116
129
|
readJson(path.join(configDir, 'budget.json')),
|
|
117
130
|
readJson(path.join(configDir, 'profiles.json')),
|
|
118
131
|
readJson(path.join(configDir, 'machines.json')),
|
|
@@ -121,18 +134,15 @@ export async function readConfigSnapshot(configDir) {
|
|
|
121
134
|
listJsonBasenames(path.join(tt, 'templates')),
|
|
122
135
|
listJsonBasenames(path.join(tt, 'shells')),
|
|
123
136
|
readEnv(path.join(configDir, '.env')),
|
|
137
|
+
liveSettings ?? readSettings(configDir),
|
|
124
138
|
]);
|
|
139
|
+
const [budget, profiles, machines, mcp, agents, templates, shells, env, settings] = parts;
|
|
125
140
|
const threadTemplates = { agents, templates, shells };
|
|
126
141
|
return {
|
|
127
|
-
budget: parseBudget(
|
|
128
|
-
|
|
129
|
-
machines: parseMachines(machinesRaw),
|
|
130
|
-
mcp: parseMcp(mcpRaw),
|
|
131
|
-
threadTemplates,
|
|
132
|
-
hooks,
|
|
133
|
-
env,
|
|
142
|
+
budget: parseBudget(budget), profiles: parseProfiles(profiles), machines: parseMachines(machines),
|
|
143
|
+
mcp: parseMcp(mcp), threadTemplates, hooks, env, settings,
|
|
134
144
|
};
|
|
135
145
|
}
|
|
136
146
|
export async function handleConfigGet(_deps, _params) {
|
|
137
|
-
return readConfigSnapshot(CONFIG_DIR);
|
|
147
|
+
return readConfigSnapshot(CONFIG_DIR, getSettingsSnapshot());
|
|
138
148
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { UiServiceDeps, TaskInfo, TasksListParams } from '../types.js';
|
|
2
|
-
export declare function toTaskInfo(
|
|
2
|
+
export declare function toTaskInfo(task: any): TaskInfo;
|
|
3
3
|
export declare function handleTasksList(deps: UiServiceDeps, params: TasksListParams): Promise<TaskInfo[]>;
|
|
@@ -1,38 +1,77 @@
|
|
|
1
|
-
// input: UiServiceDeps, TasksListParams, task records
|
|
2
|
-
// output: Task DTOs with lifecycle and
|
|
1
|
+
// input: UiServiceDeps, TasksListParams, task and thread records
|
|
2
|
+
// output: Task DTOs with lifecycle, dependencies and claim thread
|
|
3
3
|
// pos: Task DTO mapper and tasks.list query handler
|
|
4
4
|
// >>> If I am updated, update my header comment and CORTEX.md <<<
|
|
5
|
-
|
|
5
|
+
const ACTIVE_THREAD_STATUSES = new Set(['running', 'waiting', 'rate_limited']);
|
|
6
|
+
function taskThreadKey(project, taskId) {
|
|
7
|
+
return `${project}\0${taskId}`;
|
|
8
|
+
}
|
|
9
|
+
function claimThreadMap(deps) {
|
|
10
|
+
const result = new Map();
|
|
11
|
+
for (const thread of deps.threadStore.getAll()) {
|
|
12
|
+
const taskId = thread.metadata?.taskId;
|
|
13
|
+
const project = thread.metadata?.taskProject ?? thread.projectId;
|
|
14
|
+
const key = taskId && project ? taskThreadKey(project, taskId) : null;
|
|
15
|
+
if (!key || !ACTIVE_THREAD_STATUSES.has(thread.status) || result.has(key))
|
|
16
|
+
continue;
|
|
17
|
+
result.set(key, thread.id);
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
function unresolvedDependencies(task, completedIds) {
|
|
22
|
+
return (task.depends_on ?? []).filter((dependency) => !completedIds.has(dependency));
|
|
23
|
+
}
|
|
24
|
+
function isTaskActionable(task, unmetDependencyIds, today) {
|
|
25
|
+
return task.status === 'open'
|
|
26
|
+
&& !task.paused
|
|
27
|
+
&& !task.claimed_by
|
|
28
|
+
&& !task.blocked_by
|
|
29
|
+
&& !(task.approval_needed && !task.approved_at)
|
|
30
|
+
&& unmetDependencyIds.length === 0
|
|
31
|
+
&& !(task.not_before && task.not_before > today);
|
|
32
|
+
}
|
|
33
|
+
function mapTaskInfo(task, claimThreadId, unmetDependencyIds, actionable) {
|
|
6
34
|
return {
|
|
7
|
-
id:
|
|
8
|
-
text:
|
|
9
|
-
project:
|
|
10
|
-
status:
|
|
11
|
-
priority:
|
|
12
|
-
actionable: !!(
|
|
13
|
-
claimedBy:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
35
|
+
id: task.id,
|
|
36
|
+
text: task.text,
|
|
37
|
+
project: task.project,
|
|
38
|
+
status: task.status === 'done' ? 'done' : 'open',
|
|
39
|
+
priority: task.priority || 'medium',
|
|
40
|
+
actionable: actionable ?? !!(task.status === 'open' && !task.claimed_by && !task.blocked_by && !task.paused),
|
|
41
|
+
claimedBy: task.claimed_by ?? null,
|
|
42
|
+
claimThreadId,
|
|
43
|
+
blockedBy: task.blocked_by ?? null,
|
|
44
|
+
approvalNeeded: task.approval_needed === true,
|
|
45
|
+
approvedAt: task.approved_at ?? null,
|
|
46
|
+
dependsOn: task.depends_on || [],
|
|
47
|
+
unmetDependencyIds,
|
|
48
|
+
plan: task.plan ?? null,
|
|
49
|
+
template: task.template || 'coder-review',
|
|
50
|
+
why: task.why || null,
|
|
51
|
+
doneWhen: task.done_when || null,
|
|
52
|
+
completedAt: task.completed_at ?? null,
|
|
22
53
|
};
|
|
23
54
|
}
|
|
55
|
+
export function toTaskInfo(task) {
|
|
56
|
+
return mapTaskInfo(task, null);
|
|
57
|
+
}
|
|
24
58
|
export async function handleTasksList(deps, params) {
|
|
25
|
-
const { projectId, status, actionable } = params;
|
|
26
59
|
deps.taskStore.refresh();
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
60
|
+
const allTasks = deps.taskStore.getAll();
|
|
61
|
+
const completedIds = new Set(allTasks.filter((task) => task.status === 'done' && task.id).map((task) => task.id));
|
|
62
|
+
const today = new Date().toISOString().slice(0, 10);
|
|
63
|
+
const projected = allTasks.map((task) => {
|
|
64
|
+
const unmetDependencyIds = unresolvedDependencies(task, completedIds);
|
|
65
|
+
return { task, unmetDependencyIds, actionable: isTaskActionable(task, unmetDependencyIds, today) };
|
|
66
|
+
});
|
|
67
|
+
const threadByTask = claimThreadMap(deps);
|
|
68
|
+
return projected
|
|
69
|
+
.filter(({ task }) => !params.projectId || task.project === params.projectId)
|
|
70
|
+
.filter(({ task }) => !params.status || task.status === params.status)
|
|
71
|
+
.filter((item) => params.actionable === undefined || item.actionable === params.actionable)
|
|
72
|
+
.map(({ task, unmetDependencyIds, actionable }) => {
|
|
73
|
+
const key = taskThreadKey(task.project, task.id);
|
|
74
|
+
const threadId = task.claimed_by ? threadByTask.get(key) ?? null : null;
|
|
75
|
+
return mapTaskInfo(task, threadId, unmetDependencyIds, actionable);
|
|
76
|
+
});
|
|
38
77
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// input: UiServiceDeps, thread query params, task DTO mapper
|
|
2
|
-
// output:
|
|
2
|
+
// output: normalized thread lists and task-linked detail
|
|
3
3
|
// pos: Thread list/detail query handlers
|
|
4
4
|
// >>> If I am updated, update my header comment and CORTEX.md <<<
|
|
5
5
|
import { readFile } from 'node:fs/promises';
|
|
@@ -23,7 +23,7 @@ export async function handleThreadsList(deps, params) {
|
|
|
23
23
|
}
|
|
24
24
|
if (status && status.length > 0) {
|
|
25
25
|
const statusSet = new Set(status);
|
|
26
|
-
threads = threads.filter((t) => statusSet.has(t.status));
|
|
26
|
+
threads = threads.filter((t) => statusSet.has(mapStatus(t.status)));
|
|
27
27
|
}
|
|
28
28
|
// Session scoping: a thread spawned from a chat runs on that session's channel, so resolve the
|
|
29
29
|
// session → channel and keep only threads on it. An unknown session (or one with no channel)
|
|
@@ -39,7 +39,7 @@ export async function handleThreadsList(deps, params) {
|
|
|
39
39
|
currentStep: t.currentStepIndex != null
|
|
40
40
|
? { index: t.currentStepIndex, name: t.currentStepName || `step-${t.currentStepIndex}` }
|
|
41
41
|
: null,
|
|
42
|
-
status: t.status,
|
|
42
|
+
status: mapStatus(t.status),
|
|
43
43
|
projectId: t.projectId,
|
|
44
44
|
createdAt: t.createdAt,
|
|
45
45
|
updatedAt: t.updatedAt,
|
|
@@ -2,8 +2,9 @@ import type { Project, CreateProjectResult } from '../projects/index.js';
|
|
|
2
2
|
import type { CostSummary } from '../costs/cost-tracker.js';
|
|
3
3
|
import type { EventBus } from '../../events/index.js';
|
|
4
4
|
import type { RunningExecutions } from '../../core/running-executions.js';
|
|
5
|
-
import type {
|
|
6
|
-
|
|
5
|
+
import type { Settings, SettingSnapshotEntry } from '../../core/settings-spec.js';
|
|
6
|
+
import type { AuthNoticeAction, ChatNoticeLevel, SessionContextUsage } from '../../core/types/agent-types.js';
|
|
7
|
+
export type { AuthNoticeAction, ChatNoticeLevel, SessionContextUsage, } from '../../core/types/agent-types.js';
|
|
7
8
|
import type { PlatformAdapter } from '../../platform/adapter.js';
|
|
8
9
|
import type { HookBackend, HookEvent, HookFilterValue, HookPhase, HookResultMode, HookSource } from '../../store/hook-registry.js';
|
|
9
10
|
import type { HookApplyTime, HookMountTarget } from '../hooks/hook-view.js';
|
|
@@ -14,6 +15,8 @@ import type { LogLocation } from '../executions/log-tailer.js';
|
|
|
14
15
|
import type { SessionHistory } from '../../store/conversation-history-repo.js';
|
|
15
16
|
import type { Backend } from '../../agent-adapter/types.js';
|
|
16
17
|
import type { ProjectNote } from '../../store/project-notes-repo.js';
|
|
18
|
+
import type { AuthLoginService, AuthLogoutResult, AuthLogoutSuccess, AuthStatusSnapshot, AuthType, LoginFlowState, LogoutAccountInput } from '../auth/index.js';
|
|
19
|
+
export type { AuthAccountState, AuthAccountStatus, AuthCredentialStatus, AuthStatusSnapshot, AuthType, LoginFlowNotice, LoginFlowState, LoginFlowStep, LoginOutcome, LoginPendingPrompt, LoginPromptOption, } from '../auth/index.js';
|
|
17
20
|
export type Ok<T> = {
|
|
18
21
|
ok: true;
|
|
19
22
|
data: T;
|
|
@@ -24,8 +27,8 @@ export type Err = {
|
|
|
24
27
|
message: string;
|
|
25
28
|
};
|
|
26
29
|
export type Result<T> = Ok<T> | Err;
|
|
27
|
-
export type QueryScope = 'projects.list' | 'sessions.list' | 'sessions.transcript' | 'sessions.pendingInteraction' | 'threads.list' | 'threads.get' | 'tasks.list' | 'tasks.verification' | 'schedules.list' | 'executions.list' | 'executions.get' | 'memory.tree' | 'memory.file' | 'approvals.list' | 'issues.list' | 'notes.list' | 'cost.summary' | 'config.get' | 'hooks.list' | 'machines.list' | 'skills.list' | 'threadTemplates.get' | 'system.daemonStatus' | 'system.rateLimitStatus';
|
|
28
|
-
export type MutateOp = 'projects.create' | 'sessions.create' | 'sessions.send' | 'sessions.cancel' | 'sessions.compact' | 'sessions.setProfile' | 'sessions.createAndSend' | 'sessions.markRead' | 'sessions.answerQuestion' | 'sessions.respondPlan' | 'sessions.rewind' | 'threads.cancel' | 'executions.cancel' | 'schedules.pause' | 'schedules.resume' | 'schedules.remove' | 'schedules.add' | 'tasks.claim' | 'tasks.unclaim' | 'tasks.complete' | 'tasks.block' | 'tasks.unblock' | 'approvals.approve' | 'approvals.reject' | 'approvals.request' | 'issues.handle' | 'issues.delete' | 'notes.add' | 'notes.update' | 'notes.setCompleted' | 'notes.delete' | 'notes.clearCompleted' | 'config.set' | 'hooks.create' | 'hooks.update' | 'hooks.setEnabled' | 'hooks.remove' | 'hooks.test' | 'system.restart';
|
|
30
|
+
export type QueryScope = 'projects.list' | 'sessions.list' | 'sessions.transcript' | 'sessions.pendingInteraction' | 'threads.list' | 'threads.get' | 'tasks.list' | 'tasks.verification' | 'schedules.list' | 'executions.list' | 'executions.get' | 'memory.tree' | 'memory.file' | 'approvals.list' | 'issues.list' | 'notes.list' | 'cost.summary' | 'config.get' | 'auth.status' | 'auth.flowState' | 'hooks.list' | 'machines.list' | 'skills.list' | 'threadTemplates.get' | 'system.daemonStatus' | 'system.rateLimitStatus';
|
|
31
|
+
export type MutateOp = 'projects.create' | 'sessions.create' | 'sessions.send' | 'sessions.cancel' | 'sessions.compact' | 'sessions.setProfile' | 'sessions.createAndSend' | 'sessions.markRead' | 'sessions.answerQuestion' | 'sessions.respondPlan' | 'sessions.rewind' | 'threads.cancel' | 'executions.cancel' | 'schedules.pause' | 'schedules.resume' | 'schedules.remove' | 'schedules.add' | 'tasks.claim' | 'tasks.unclaim' | 'tasks.complete' | 'tasks.block' | 'tasks.unblock' | 'approvals.approve' | 'approvals.reject' | 'approvals.request' | 'issues.handle' | 'issues.delete' | 'notes.add' | 'notes.update' | 'notes.setCompleted' | 'notes.delete' | 'notes.clearCompleted' | 'config.set' | 'auth.startLogin' | 'auth.respondPrompt' | 'auth.cancelFlow' | 'auth.logout' | 'hooks.create' | 'hooks.update' | 'hooks.setEnabled' | 'hooks.remove' | 'hooks.test' | 'system.restart';
|
|
29
32
|
export interface SubscribeFilter {
|
|
30
33
|
events: string[];
|
|
31
34
|
projectId?: string | null;
|
|
@@ -134,6 +137,10 @@ export interface CostSummaryParams {
|
|
|
134
137
|
projectId?: string | null;
|
|
135
138
|
}
|
|
136
139
|
export type ConfigGetParams = Record<string, never>;
|
|
140
|
+
export type AuthStatusParams = Record<string, never>;
|
|
141
|
+
export interface AuthFlowStateParams {
|
|
142
|
+
flowId: string;
|
|
143
|
+
}
|
|
137
144
|
export type MachinesListParams = Record<string, never>;
|
|
138
145
|
export type SkillsListParams = Record<string, never>;
|
|
139
146
|
export type ThreadTemplatesGetParams = Record<string, never>;
|
|
@@ -142,6 +149,21 @@ export type SystemRateLimitStatusParams = Record<string, never>;
|
|
|
142
149
|
export interface ProjectCreateArgs {
|
|
143
150
|
name: string;
|
|
144
151
|
}
|
|
152
|
+
export interface AuthStartLoginArgs {
|
|
153
|
+
backend: 'claude' | 'pi';
|
|
154
|
+
provider: string;
|
|
155
|
+
authType: AuthType;
|
|
156
|
+
noticeId?: string;
|
|
157
|
+
}
|
|
158
|
+
export interface AuthRespondPromptArgs {
|
|
159
|
+
flowId: string;
|
|
160
|
+
value: string;
|
|
161
|
+
}
|
|
162
|
+
export interface AuthCancelFlowArgs {
|
|
163
|
+
flowId: string;
|
|
164
|
+
}
|
|
165
|
+
export type AuthLogoutArgs = LogoutAccountInput;
|
|
166
|
+
export type AuthLogoutReturn = AuthLogoutSuccess;
|
|
145
167
|
export interface SessionsCreateArgs {
|
|
146
168
|
/** Project the new session belongs to. Omitted → the default project (handler fallback). */
|
|
147
169
|
projectId?: string;
|
|
@@ -254,12 +276,16 @@ export interface BudgetValue {
|
|
|
254
276
|
export interface ProfilesValue {
|
|
255
277
|
defaultProfile: string;
|
|
256
278
|
}
|
|
279
|
+
export type SettingsValue = Partial<Settings>;
|
|
257
280
|
export type ConfigSetArgs = {
|
|
258
281
|
section: 'budget';
|
|
259
282
|
value: BudgetValue;
|
|
260
283
|
} | {
|
|
261
284
|
section: 'profiles';
|
|
262
285
|
value: ProfilesValue;
|
|
286
|
+
} | {
|
|
287
|
+
section: 'settings';
|
|
288
|
+
value: SettingsValue;
|
|
263
289
|
};
|
|
264
290
|
export interface ApprovalsApproveArgs {
|
|
265
291
|
id: string;
|
|
@@ -423,6 +449,8 @@ export interface TranscriptMessage {
|
|
|
423
449
|
debug?: TranscriptDebugDetails;
|
|
424
450
|
/** Semantic chat-notice styling for system-authored assistant messages. */
|
|
425
451
|
noticeLevel?: ChatNoticeLevel;
|
|
452
|
+
/** Secret-free one-click target carried only by authentication notices. */
|
|
453
|
+
authAction?: AuthNoticeAction;
|
|
426
454
|
/** interaction subtype: 'ask-user-answered' | 'plan-approved' | 'plan-rejected' (legacy rows)
|
|
427
455
|
* or derived from kind+status for entity rows (display compat). */
|
|
428
456
|
subtype?: string;
|
|
@@ -580,18 +608,24 @@ export interface TaskInfo {
|
|
|
580
608
|
priority: 'high' | 'medium' | 'low';
|
|
581
609
|
actionable: boolean;
|
|
582
610
|
claimedBy: string | null;
|
|
611
|
+
/** Owning task-dispatch thread; optional while app and server versions roll independently. */
|
|
612
|
+
claimThreadId?: string | null;
|
|
583
613
|
blockedBy: string | null;
|
|
584
614
|
/** Approval gate from task-store `approval-needed`; absent only with an older server contract. */
|
|
585
615
|
approvalNeeded?: boolean;
|
|
586
616
|
/** Recorded approval date; absent only with an older server contract. */
|
|
587
617
|
approvedAt?: string | null;
|
|
588
618
|
dependsOn: string[];
|
|
619
|
+
/** Unresolved dependencies across all projects; optional with an older server contract. */
|
|
620
|
+
unmetDependencyIds?: string[];
|
|
589
621
|
plan: string | null;
|
|
590
622
|
template: string;
|
|
591
623
|
/** The task's rationale (task store `why`). Null when absent/empty (null-safe). */
|
|
592
624
|
why: string | null;
|
|
593
625
|
/** The task's completion criteria (task store `done-when`). Null when absent/empty (null-safe). */
|
|
594
626
|
doneWhen: string | null;
|
|
627
|
+
/** Completion timestamp; optional while app and server versions roll independently. */
|
|
628
|
+
completedAt?: string | null;
|
|
595
629
|
}
|
|
596
630
|
/** Done-when achievement evidence drawn from real completion sources (task store + completing execution). */
|
|
597
631
|
export interface TaskDoneWhenEvidence {
|
|
@@ -727,6 +761,7 @@ export interface ConfigEnvEntry {
|
|
|
727
761
|
present: boolean;
|
|
728
762
|
masked: string;
|
|
729
763
|
}
|
|
764
|
+
export type ConfigSettingEntry = SettingSnapshotEntry;
|
|
730
765
|
export interface ConfigHook {
|
|
731
766
|
id: string;
|
|
732
767
|
event: HookEvent;
|
|
@@ -848,6 +883,8 @@ export interface ConfigSnapshot {
|
|
|
848
883
|
threadTemplates: ConfigThreadTemplates;
|
|
849
884
|
hooks: ConfigHook[];
|
|
850
885
|
env: ConfigEnvEntry[];
|
|
886
|
+
/** Always emitted by current servers; optional while clients and servers roll independently. */
|
|
887
|
+
settings?: ConfigSettingEntry[];
|
|
851
888
|
}
|
|
852
889
|
export interface MachineInfo {
|
|
853
890
|
/** Machine name (key from machines.json). */
|
|
@@ -950,6 +987,12 @@ export interface ApprovalInfo {
|
|
|
950
987
|
/** Stable id derived from the heading line (no explicit id exists in the markdown). */
|
|
951
988
|
id: string;
|
|
952
989
|
title: string;
|
|
990
|
+
/**
|
|
991
|
+
* Owning project from the `- **Project**:` bullet (need-approval skill template). `null` (honest
|
|
992
|
+
* placeholder, never fabricated) for legacy entries and system-level operations — the UI renders
|
|
993
|
+
* those as "global".
|
|
994
|
+
*/
|
|
995
|
+
projectId: string | null;
|
|
953
996
|
operation: string | null;
|
|
954
997
|
reason: string | null;
|
|
955
998
|
impact: string | null;
|
|
@@ -964,9 +1007,9 @@ export interface ApprovalInfo {
|
|
|
964
1007
|
feedback: string | null;
|
|
965
1008
|
/**
|
|
966
1009
|
* Verbatim `Provenance` bullet — the only real "who raised this / origin" carrier in the queue
|
|
967
|
-
* (§12 C item 13).
|
|
968
|
-
* origin/from
|
|
969
|
-
* never fabricated) when absent. Backs the approval-center origin/from slots.
|
|
1010
|
+
* (§12 C item 13). Project attribution now has its own structured `Project` bullet (projectId),
|
|
1011
|
+
* but origin/from remains this freeform bullet only a subset of entries add. `null` (honest
|
|
1012
|
+
* placeholder, never fabricated) when absent. Backs the approval-center origin/from slots.
|
|
970
1013
|
*/
|
|
971
1014
|
provenance: string | null;
|
|
972
1015
|
/**
|
|
@@ -1069,7 +1112,7 @@ export interface ExecutionsCancelReturn {
|
|
|
1069
1112
|
}
|
|
1070
1113
|
export interface ConfigSetReturn {
|
|
1071
1114
|
written: true;
|
|
1072
|
-
section: 'budget' | 'profiles';
|
|
1115
|
+
section: 'budget' | 'profiles' | 'settings';
|
|
1073
1116
|
}
|
|
1074
1117
|
export interface ApprovalMutateReturn {
|
|
1075
1118
|
id: string;
|
|
@@ -1114,6 +1157,8 @@ export interface QueryParamMap {
|
|
|
1114
1157
|
'notes.list': NotesListParams;
|
|
1115
1158
|
'cost.summary': CostSummaryParams;
|
|
1116
1159
|
'config.get': ConfigGetParams;
|
|
1160
|
+
'auth.status': AuthStatusParams;
|
|
1161
|
+
'auth.flowState': AuthFlowStateParams;
|
|
1117
1162
|
'hooks.list': HooksListParams;
|
|
1118
1163
|
'machines.list': MachinesListParams;
|
|
1119
1164
|
'skills.list': SkillsListParams;
|
|
@@ -1140,6 +1185,8 @@ export interface QueryReturnMap {
|
|
|
1140
1185
|
'notes.list': NoteInfo[];
|
|
1141
1186
|
'cost.summary': CostSummary;
|
|
1142
1187
|
'config.get': ConfigSnapshot;
|
|
1188
|
+
'auth.status': AuthStatusSnapshot;
|
|
1189
|
+
'auth.flowState': LoginFlowState | null;
|
|
1143
1190
|
'hooks.list': HooksOverview;
|
|
1144
1191
|
'machines.list': MachineInfo[];
|
|
1145
1192
|
'skills.list': SkillGroup[];
|
|
@@ -1181,6 +1228,10 @@ export interface MutateArgsMap {
|
|
|
1181
1228
|
'notes.delete': NoteActionArgs;
|
|
1182
1229
|
'notes.clearCompleted': NotesClearCompletedArgs;
|
|
1183
1230
|
'config.set': ConfigSetArgs;
|
|
1231
|
+
'auth.startLogin': AuthStartLoginArgs;
|
|
1232
|
+
'auth.respondPrompt': AuthRespondPromptArgs;
|
|
1233
|
+
'auth.cancelFlow': AuthCancelFlowArgs;
|
|
1234
|
+
'auth.logout': AuthLogoutArgs;
|
|
1184
1235
|
'hooks.create': HooksCreateArgs;
|
|
1185
1236
|
'hooks.update': HooksUpdateArgs;
|
|
1186
1237
|
'hooks.setEnabled': HooksSetEnabledArgs;
|
|
@@ -1222,6 +1273,10 @@ export interface MutateReturnMap {
|
|
|
1222
1273
|
'notes.delete': NotesDeleteReturn;
|
|
1223
1274
|
'notes.clearCompleted': NotesClearCompletedReturn;
|
|
1224
1275
|
'config.set': ConfigSetReturn;
|
|
1276
|
+
'auth.startLogin': LoginFlowState;
|
|
1277
|
+
'auth.respondPrompt': LoginFlowState;
|
|
1278
|
+
'auth.cancelFlow': LoginFlowState;
|
|
1279
|
+
'auth.logout': AuthLogoutReturn;
|
|
1225
1280
|
'hooks.create': HooksCreateReturn;
|
|
1226
1281
|
'hooks.update': HooksUpdateReturn;
|
|
1227
1282
|
'hooks.setEnabled': HooksSetEnabledReturn;
|
|
@@ -1249,6 +1304,10 @@ export interface UiService {
|
|
|
1249
1304
|
};
|
|
1250
1305
|
}
|
|
1251
1306
|
export interface UiServiceDeps {
|
|
1307
|
+
/** Optional seams for deterministic authentication dispatch tests. */
|
|
1308
|
+
getAuthStatus?: () => Promise<AuthStatusSnapshot>;
|
|
1309
|
+
authLogin?: AuthLoginService;
|
|
1310
|
+
logoutAccount?: (input: LogoutAccountInput) => Promise<AuthLogoutResult>;
|
|
1252
1311
|
projectStore: {
|
|
1253
1312
|
list(): Project[];
|
|
1254
1313
|
get(id: string): Project | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// input: domain types,
|
|
2
|
-
// output: UI DTOs
|
|
1
|
+
// input: domain types, auth flows/logout, runtime settings, stores
|
|
2
|
+
// output: UI DTOs/maps including auth account mutations
|
|
3
3
|
// pos: Canonical transport-neutral UI contract
|
|
4
4
|
// >>> 一旦我被更新,务必更新我的开头注释与所属文件夹 CORTEX.md <<<
|
|
5
5
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// input: UiServiceDeps and query/mutation handlers
|
|
2
|
-
// output: createUiService with
|
|
2
|
+
// output: createUiService with authentication mutation routing
|
|
3
3
|
// pos: Transport-neutral UI-service dispatcher
|
|
4
4
|
// >>> 一旦我被更新,务必更新我的开头注释与所属文件夹 CORTEX.md <<<
|
|
5
5
|
import { handleProjectsList } from './query/projects.js';
|
|
@@ -15,6 +15,7 @@ import { handleIssuesList } from './query/issues.js';
|
|
|
15
15
|
import { handleNotesList } from './query/notes.js';
|
|
16
16
|
import { handleCostSummary } from './query/cost.js';
|
|
17
17
|
import { handleConfigGet } from './query/config.js';
|
|
18
|
+
import { handleAuthFlowState, handleAuthStatus } from './query/auth.js';
|
|
18
19
|
import { handleHooksList } from './query/hooks.js';
|
|
19
20
|
import { handleMachinesList } from './query/machines.js';
|
|
20
21
|
import { handleSkillsList } from './query/skills.js';
|
|
@@ -32,6 +33,7 @@ import { handleApproveApproval, handleRejectApproval, handleRequestApproval } fr
|
|
|
32
33
|
import { handleIssuesDelete, handleIssuesHandle } from './mutate/issues.js';
|
|
33
34
|
import { handleNotesAdd, handleNotesClearCompleted, handleNotesDelete, handleNotesSetCompleted, handleNotesUpdate, } from './mutate/notes.js';
|
|
34
35
|
import { handleSystemRestart } from './mutate/system.js';
|
|
36
|
+
import { handleAuthCancelFlow, handleAuthLogout, handleAuthRespondPrompt, handleAuthStartLogin, } from './mutate/auth.js';
|
|
35
37
|
import { createSubscription } from './subscribe.js';
|
|
36
38
|
import { resolveExecutionLogLocation } from '../executions/log-tailer.js';
|
|
37
39
|
const queryHandlers = {
|
|
@@ -53,6 +55,8 @@ const queryHandlers = {
|
|
|
53
55
|
'notes.list': (deps, params) => handleNotesList(deps, params),
|
|
54
56
|
'cost.summary': (deps, params) => handleCostSummary(deps, params),
|
|
55
57
|
'config.get': (deps, params) => handleConfigGet(deps, params),
|
|
58
|
+
'auth.status': (deps, params) => handleAuthStatus(params, deps.getAuthStatus),
|
|
59
|
+
'auth.flowState': (deps, params) => handleAuthFlowState(params, deps.authLogin?.getState),
|
|
56
60
|
'hooks.list': (deps, params) => handleHooksList(deps, params),
|
|
57
61
|
'machines.list': (deps, params) => handleMachinesList(deps, params),
|
|
58
62
|
'skills.list': (deps, params) => handleSkillsList(deps, params),
|
|
@@ -94,6 +98,10 @@ const mutateHandlers = {
|
|
|
94
98
|
'notes.delete': (deps, args) => handleNotesDelete(deps, args),
|
|
95
99
|
'notes.clearCompleted': (deps, args) => handleNotesClearCompleted(deps, args),
|
|
96
100
|
'config.set': (deps, args) => handleConfigSet(deps, args),
|
|
101
|
+
'auth.startLogin': (deps, args) => handleAuthStartLogin(deps, args),
|
|
102
|
+
'auth.respondPrompt': (deps, args) => handleAuthRespondPrompt(deps, args),
|
|
103
|
+
'auth.cancelFlow': (deps, args) => handleAuthCancelFlow(deps, args),
|
|
104
|
+
'auth.logout': (deps, args) => handleAuthLogout(deps, args),
|
|
97
105
|
'hooks.create': (deps, args) => handleHooksCreate(deps, args),
|
|
98
106
|
'hooks.update': (deps, args) => handleHooksUpdate(deps, args),
|
|
99
107
|
'hooks.setEnabled': (deps, args) => handleHooksSetEnabled(deps, args),
|
|
@@ -102,7 +110,13 @@ const mutateHandlers = {
|
|
|
102
110
|
'system.restart': (_deps, args) => handleSystemRestart(args),
|
|
103
111
|
};
|
|
104
112
|
export function redactMutationAuditArgs(op, args) {
|
|
105
|
-
if (!
|
|
113
|
+
if (!args || typeof args !== 'object')
|
|
114
|
+
return args;
|
|
115
|
+
if (op === 'auth.respondPrompt') {
|
|
116
|
+
const { flowId } = args;
|
|
117
|
+
return { flowId };
|
|
118
|
+
}
|
|
119
|
+
if (!op.startsWith('notes.'))
|
|
106
120
|
return args;
|
|
107
121
|
const { text: _privateText, ...safe } = args;
|
|
108
122
|
return safe;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// input: adapter factory, settings callbacks, platform routing
|
|
2
|
+
// output: runtime adapter with registered admin hot-reload
|
|
3
|
+
// pos: Composition seam for live admin settings
|
|
4
|
+
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
5
|
+
import { getSettings, onSettingsChange } from '../core/settings.js';
|
|
6
|
+
import { createAdapterFromEnv, setPlatformAdminChannel } from '../platform/index.js';
|
|
7
|
+
function registerAdminChannelHotReload(adapter) {
|
|
8
|
+
onSettingsChange((changedKeys) => {
|
|
9
|
+
const settings = getSettings();
|
|
10
|
+
if (changedKeys.includes('adminChannel')) {
|
|
11
|
+
setPlatformAdminChannel(adapter, 'slack', settings.adminChannel);
|
|
12
|
+
}
|
|
13
|
+
if (changedKeys.includes('feishuAdminChannel')) {
|
|
14
|
+
setPlatformAdminChannel(adapter, 'feishu', settings.feishuAdminChannel);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export function createHotReloadingAdapter(factory = createAdapterFromEnv) {
|
|
19
|
+
const adapter = factory();
|
|
20
|
+
registerAdminChannelHotReload(adapter);
|
|
21
|
+
return adapter;
|
|
22
|
+
}
|