@jingyi0605/codingns 0.3.6 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/bin/codingns.mjs +489 -1
- package/dist/public/assets/{TerminalPage-D00S4KM6.js → TerminalPage-6jHZV9Mh.js} +17 -17
- package/dist/public/assets/index-CSVhg7I8.js +123 -0
- package/dist/public/assets/index-Ce1VX19m.css +1 -0
- package/dist/public/index.html +2 -2
- package/dist/server/modules/assistant-capability/assistant-capability-controller.d.ts +173 -0
- package/dist/server/modules/assistant-capability/assistant-capability-controller.js +307 -0
- package/dist/server/modules/assistant-capability/assistant-capability-controller.js.map +1 -1
- package/dist/server/modules/assistant-capability/assistant-capability-service.d.ts +199 -2
- package/dist/server/modules/assistant-capability/assistant-capability-service.js +565 -3
- package/dist/server/modules/assistant-capability/assistant-capability-service.js.map +1 -1
- package/dist/server/modules/butler/assistant-automation-service.d.ts +110 -0
- package/dist/server/modules/butler/assistant-automation-service.js +786 -0
- package/dist/server/modules/butler/assistant-automation-service.js.map +1 -0
- package/dist/server/modules/butler/assistant-automation-trigger.d.ts +94 -0
- package/dist/server/modules/butler/assistant-automation-trigger.js +400 -0
- package/dist/server/modules/butler/assistant-automation-trigger.js.map +1 -0
- package/dist/server/modules/butler/assistant-sandbox-service.d.ts +55 -0
- package/dist/server/modules/butler/assistant-sandbox-service.js +266 -0
- package/dist/server/modules/butler/assistant-sandbox-service.js.map +1 -0
- package/dist/server/modules/butler/butler-action-context-service.d.ts +4 -1
- package/dist/server/modules/butler/butler-action-context-service.js +8 -2
- package/dist/server/modules/butler/butler-action-context-service.js.map +1 -1
- package/dist/server/modules/butler/butler-control-session-service.d.ts +8 -1
- package/dist/server/modules/butler/butler-control-session-service.js +154 -40
- package/dist/server/modules/butler/butler-control-session-service.js.map +1 -1
- package/dist/server/modules/butler/butler-control-timer-scheduler.d.ts +32 -0
- package/dist/server/modules/butler/butler-control-timer-scheduler.js +93 -0
- package/dist/server/modules/butler/butler-control-timer-scheduler.js.map +1 -0
- package/dist/server/modules/butler/butler-control-timer-service.d.ts +42 -0
- package/dist/server/modules/butler/butler-control-timer-service.js +132 -0
- package/dist/server/modules/butler/butler-control-timer-service.js.map +1 -0
- package/dist/server/modules/butler/butler-controller.d.ts +42 -2
- package/dist/server/modules/butler/butler-controller.js +79 -12
- package/dist/server/modules/butler/butler-controller.js.map +1 -1
- package/dist/server/modules/butler/butler-follow-up-service.d.ts +9 -1
- package/dist/server/modules/butler/butler-follow-up-service.js +273 -181
- package/dist/server/modules/butler/butler-follow-up-service.js.map +1 -1
- package/dist/server/modules/butler/butler-inbox-analysis-service.d.ts +4 -1
- package/dist/server/modules/butler/butler-inbox-analysis-service.js +18 -4
- package/dist/server/modules/butler/butler-inbox-analysis-service.js.map +1 -1
- package/dist/server/modules/butler/butler-profile-service.js +2 -5
- package/dist/server/modules/butler/butler-profile-service.js.map +1 -1
- package/dist/server/modules/butler/butler-project-service.d.ts +3 -1
- package/dist/server/modules/butler/butler-project-service.js +7 -1
- package/dist/server/modules/butler/butler-project-service.js.map +1 -1
- package/dist/server/modules/butler/butler-session-service.d.ts +3 -1
- package/dist/server/modules/butler/butler-session-service.js +12 -1
- package/dist/server/modules/butler/butler-session-service.js.map +1 -1
- package/dist/server/modules/butler/butler-session-summary-service.js +2 -1
- package/dist/server/modules/butler/butler-session-summary-service.js.map +1 -1
- package/dist/server/modules/butler/butler-workspace-context.d.ts +3 -0
- package/dist/server/modules/butler/butler-workspace-context.js +164 -44
- package/dist/server/modules/butler/butler-workspace-context.js.map +1 -1
- package/dist/server/modules/butler/patrol-execution-service.js +2 -1
- package/dist/server/modules/butler/patrol-execution-service.js.map +1 -1
- package/dist/server/modules/butler/provider-adapter-registry.d.ts +3 -0
- package/dist/server/modules/butler/provider-adapter-registry.js +18 -1
- package/dist/server/modules/butler/provider-adapter-registry.js.map +1 -1
- package/dist/server/modules/butler/verification-run-service.d.ts +9 -2
- package/dist/server/modules/butler/verification-run-service.js +188 -34
- package/dist/server/modules/butler/verification-run-service.js.map +1 -1
- package/dist/server/modules/debug-target/debug-target-controller.js +1 -1
- package/dist/server/modules/debug-target/debug-target-controller.js.map +1 -1
- package/dist/server/modules/debug-target/debug-target-service.d.ts +7 -2
- package/dist/server/modules/debug-target/debug-target-service.js +563 -100
- package/dist/server/modules/debug-target/debug-target-service.js.map +1 -1
- package/dist/server/modules/git/git-command-helper-client.d.ts +1 -0
- package/dist/server/modules/git/git-command-helper-client.js +19 -26
- package/dist/server/modules/git/git-command-helper-client.js.map +1 -1
- package/dist/server/modules/git/git-command-runner.js +19 -1
- package/dist/server/modules/git/git-command-runner.js.map +1 -1
- package/dist/server/modules/preferences/profile-service.d.ts +3 -1
- package/dist/server/modules/preferences/profile-service.js +74 -3
- package/dist/server/modules/preferences/profile-service.js.map +1 -1
- package/dist/server/modules/provider/provider-discovery-helper-client.d.ts +5 -3
- package/dist/server/modules/provider/provider-discovery-helper-client.js +129 -43
- package/dist/server/modules/provider/provider-discovery-helper-client.js.map +1 -1
- package/dist/server/modules/provider/provider-discovery-helper-process.js +44 -0
- package/dist/server/modules/provider/provider-discovery-helper-process.js.map +1 -1
- package/dist/server/modules/provider/provider-discovery-runtime.js +83 -3
- package/dist/server/modules/provider/provider-discovery-runtime.js.map +1 -1
- package/dist/server/modules/sessions/claude-runtime-helper-client.js +23 -1
- package/dist/server/modules/sessions/claude-runtime-helper-client.js.map +1 -1
- package/dist/server/modules/sessions/session-history-service.d.ts +7 -1
- package/dist/server/modules/sessions/session-history-service.js +251 -41
- package/dist/server/modules/sessions/session-history-service.js.map +1 -1
- package/dist/server/modules/sessions/session-live-runtime-service.d.ts +6 -0
- package/dist/server/modules/sessions/session-live-runtime-service.js +97 -11
- package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
- package/dist/server/modules/sessions/session-message-origin-utils.d.ts +12 -0
- package/dist/server/modules/sessions/session-message-origin-utils.js +45 -0
- package/dist/server/modules/sessions/session-message-origin-utils.js.map +1 -0
- package/dist/server/modules/sessions/session-permission-request-service.js +167 -0
- package/dist/server/modules/sessions/session-permission-request-service.js.map +1 -1
- package/dist/server/modules/skills/builtin-skill-service.js +1 -1
- package/dist/server/modules/skills/builtin-skill-service.js.map +1 -1
- package/dist/server/modules/skills/builtin-skills/codingns-assistant/SKILL.md +19 -12
- package/dist/server/modules/skills/builtin-skills/codingns-assistant/references/cli-workflow.md +9 -3
- package/dist/server/modules/tasks/task-helper-client.d.ts +5 -2
- package/dist/server/modules/tasks/task-helper-client.js +118 -38
- package/dist/server/modules/tasks/task-helper-client.js.map +1 -1
- package/dist/server/modules/tasks/task-helper-process.js +94 -3
- package/dist/server/modules/tasks/task-helper-process.js.map +1 -1
- package/dist/server/modules/tasks/task-types.d.ts +3 -0
- package/dist/server/modules/tasks/task-types.js +4 -1
- package/dist/server/modules/tasks/task-types.js.map +1 -1
- package/dist/server/modules/terminal/command-template-service.d.ts +9 -0
- package/dist/server/modules/terminal/command-template-service.js +87 -5
- package/dist/server/modules/terminal/command-template-service.js.map +1 -1
- package/dist/server/modules/terminal/terminal-controller.d.ts +3 -0
- package/dist/server/modules/terminal/terminal-controller.js +41 -0
- package/dist/server/modules/terminal/terminal-controller.js.map +1 -1
- package/dist/server/modules/workbench/workbench-service.d.ts +3 -0
- package/dist/server/modules/workbench/workbench-service.js +4 -3
- package/dist/server/modules/workbench/workbench-service.js.map +1 -1
- package/dist/server/modules/workbench/workspace-file-watcher.d.ts +14 -6
- package/dist/server/modules/workbench/workspace-file-watcher.js +267 -57
- package/dist/server/modules/workbench/workspace-file-watcher.js.map +1 -1
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.d.ts +2 -0
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.js +32 -3
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.js.map +1 -1
- package/dist/server/modules/worktree/worktree-manager.d.ts +9 -1
- package/dist/server/modules/worktree/worktree-manager.js +9 -1
- package/dist/server/modules/worktree/worktree-manager.js.map +1 -1
- package/dist/server/routes/assistant.js +19 -0
- package/dist/server/routes/assistant.js.map +1 -1
- package/dist/server/routes/butler.js +5 -0
- package/dist/server/routes/butler.js.map +1 -1
- package/dist/server/server/create-server.d.ts +8 -0
- package/dist/server/server/create-server.js +36 -13
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/storage/repositories/assistant-automation-run-repository.d.ts +12 -0
- package/dist/server/storage/repositories/assistant-automation-run-repository.js +139 -0
- package/dist/server/storage/repositories/assistant-automation-run-repository.js.map +1 -0
- package/dist/server/storage/repositories/assistant-automation-task-repository.d.ts +15 -0
- package/dist/server/storage/repositories/assistant-automation-task-repository.js +173 -0
- package/dist/server/storage/repositories/assistant-automation-task-repository.js.map +1 -0
- package/dist/server/storage/repositories/assistant-sandbox-workspace-repository.d.ts +17 -0
- package/dist/server/storage/repositories/assistant-sandbox-workspace-repository.js +164 -0
- package/dist/server/storage/repositories/assistant-sandbox-workspace-repository.js.map +1 -0
- package/dist/server/storage/repositories/butler-control-session-repository.js +27 -3
- package/dist/server/storage/repositories/butler-control-session-repository.js.map +1 -1
- package/dist/server/storage/repositories/butler-control-timer-repository.d.ts +15 -0
- package/dist/server/storage/repositories/butler-control-timer-repository.js +157 -0
- package/dist/server/storage/repositories/butler-control-timer-repository.js.map +1 -0
- package/dist/server/storage/repositories/user-preference-profile-repository.js +6 -3
- package/dist/server/storage/repositories/user-preference-profile-repository.js.map +1 -1
- package/dist/server/storage/sqlite/client.js +239 -2
- package/dist/server/storage/sqlite/client.js.map +1 -1
- package/dist/server/storage/sqlite/schema.sql +107 -1
- package/dist/server/types/domain.d.ts +89 -2
- package/dist/server/ws/workbench-ws-hub.d.ts +14 -8
- package/dist/server/ws/workbench-ws-hub.js +299 -163
- package/dist/server/ws/workbench-ws-hub.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.d.ts +4 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js +111 -3
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.d.ts +6 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +306 -31
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/gemini.d.ts +5 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/gemini.js +187 -26
- package/node_modules/@codingns/session-sync-core/dist/providers/gemini.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/kimi.d.ts +4 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/kimi.js +98 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/kimi.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.d.ts +2 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js +71 -8
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/utils.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/utils.js +4 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/utils.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js +44 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +9 -3
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/types.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/services.js +17 -8
- package/node_modules/@codingns/session-sync-core/dist/services.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/types.d.ts +4 -0
- package/package.json +1 -1
- package/dist/public/assets/index-BlOinYqR.js +0 -122
- package/dist/public/assets/index-Dg_7g6lA.css +0 -1
|
@@ -2,6 +2,7 @@ import { AppError } from "../../shared/errors/app-error.js";
|
|
|
2
2
|
import { createId } from "../../shared/utils/id.js";
|
|
3
3
|
import { nowIso } from "../../shared/utils/time.js";
|
|
4
4
|
import { syncButlerWorkspaceContext } from "./butler-workspace-context.js";
|
|
5
|
+
import { recordButlerProxyMessageOrigin } from "../sessions/session-message-origin-utils.js";
|
|
5
6
|
export class ButlerControlSessionService {
|
|
6
7
|
butlerProfileService;
|
|
7
8
|
butlerControlSessionRepository;
|
|
@@ -13,7 +14,11 @@ export class ButlerControlSessionService {
|
|
|
13
14
|
skillManagerService;
|
|
14
15
|
codexHomeDir;
|
|
15
16
|
sourceCodexHomeDir;
|
|
16
|
-
|
|
17
|
+
claudeCodeHomeDir;
|
|
18
|
+
sourceClaudeCodeHomeDir;
|
|
19
|
+
sessionMessageOriginRepository;
|
|
20
|
+
assistantSandboxService;
|
|
21
|
+
constructor(butlerProfileService, butlerControlSessionRepository, workspaceService, sessionHistoryService, sessionLiveRuntimeService, butlerContextAggregator, butlerAuthService, skillManagerService, codexHomeDir = null, sourceCodexHomeDir = null, claudeCodeHomeDir = null, sourceClaudeCodeHomeDir = null, sessionMessageOriginRepository = null, assistantSandboxService = null) {
|
|
17
22
|
this.butlerProfileService = butlerProfileService;
|
|
18
23
|
this.butlerControlSessionRepository = butlerControlSessionRepository;
|
|
19
24
|
this.workspaceService = workspaceService;
|
|
@@ -24,6 +29,10 @@ export class ButlerControlSessionService {
|
|
|
24
29
|
this.skillManagerService = skillManagerService;
|
|
25
30
|
this.codexHomeDir = codexHomeDir;
|
|
26
31
|
this.sourceCodexHomeDir = sourceCodexHomeDir;
|
|
32
|
+
this.claudeCodeHomeDir = claudeCodeHomeDir;
|
|
33
|
+
this.sourceClaudeCodeHomeDir = sourceClaudeCodeHomeDir;
|
|
34
|
+
this.sessionMessageOriginRepository = sessionMessageOriginRepository;
|
|
35
|
+
this.assistantSandboxService = assistantSandboxService;
|
|
27
36
|
}
|
|
28
37
|
getCurrentSession(userId) {
|
|
29
38
|
const profile = this.butlerProfileService.ensureInitialized();
|
|
@@ -61,8 +70,16 @@ export class ButlerControlSessionService {
|
|
|
61
70
|
async startSession(userId, input = {}) {
|
|
62
71
|
const profile = this.butlerProfileService.ensureInitialized();
|
|
63
72
|
const content = normalizeControlContent(input.content, "");
|
|
73
|
+
const model = normalizeNullableText(input.model);
|
|
74
|
+
const reasoningLevel = normalizeNullableText(input.reasoningLevel);
|
|
75
|
+
const permissionMode = normalizeNullableText(input.permissionMode);
|
|
76
|
+
const clientRequestId = normalizeNullableText(input.clientRequestId)
|
|
77
|
+
?? `assistant-origin:butler-control-start:${createId()}`;
|
|
64
78
|
const promptContext = await this.butlerContextAggregator.resolvePromptContext(userId, input.content ?? null);
|
|
65
|
-
const
|
|
79
|
+
const preparedWorkspace = await this.prepareWorkspace(profile, promptContext, userId, {
|
|
80
|
+
title: normalizeNullableText(input.title),
|
|
81
|
+
content
|
|
82
|
+
});
|
|
66
83
|
const current = this.butlerControlSessionRepository.findLatestOpenByProvider(profile.providerId);
|
|
67
84
|
if (current && current.status !== "closed") {
|
|
68
85
|
this.butlerControlSessionRepository.update({
|
|
@@ -71,40 +88,67 @@ export class ButlerControlSessionService {
|
|
|
71
88
|
updatedAt: nowIso()
|
|
72
89
|
});
|
|
73
90
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
91
|
+
try {
|
|
92
|
+
const started = await this.sessionLiveRuntimeService.startLiveSession({
|
|
93
|
+
workspaceId: preparedWorkspace.workspaceId,
|
|
94
|
+
userId,
|
|
95
|
+
provider: profile.providerId,
|
|
96
|
+
content,
|
|
97
|
+
clientRequestId,
|
|
98
|
+
runtimeOptions: {
|
|
99
|
+
model,
|
|
100
|
+
reasoningLevel,
|
|
101
|
+
permissionMode,
|
|
102
|
+
attachments: []
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
recordButlerProxyMessageOrigin(this.sessionMessageOriginRepository, {
|
|
106
|
+
sessionId: started.sessionId,
|
|
107
|
+
clientRequestId,
|
|
108
|
+
messageId: started.message?.messageId ?? null,
|
|
109
|
+
content,
|
|
110
|
+
createdAt: started.acceptedAt,
|
|
111
|
+
fallbackKey: `butler-control-start:${started.sessionId}:${started.acceptedAt}`
|
|
112
|
+
});
|
|
113
|
+
const timestamp = started.acceptedAt;
|
|
114
|
+
const created = this.butlerControlSessionRepository.create({
|
|
115
|
+
id: createId(),
|
|
116
|
+
providerId: profile.providerId,
|
|
117
|
+
sessionId: started.sessionId,
|
|
118
|
+
purpose: input.purpose ?? "chat",
|
|
119
|
+
title: normalizeNullableText(input.title),
|
|
120
|
+
sourceItemId: normalizeNullableText(input.sourceItemId),
|
|
121
|
+
model,
|
|
122
|
+
reasoningLevel,
|
|
123
|
+
permissionMode,
|
|
124
|
+
status: "running",
|
|
125
|
+
lastContextVersion: promptContext.version,
|
|
126
|
+
lastSummary: normalizeNullableText(input.title) ?? summarizeMessage(content),
|
|
127
|
+
createdAt: timestamp,
|
|
128
|
+
updatedAt: timestamp
|
|
129
|
+
});
|
|
130
|
+
if (preparedWorkspace.sandboxId && this.assistantSandboxService) {
|
|
131
|
+
this.assistantSandboxService.markSandboxUsedByControlSession(preparedWorkspace.sandboxId, userId, created.id);
|
|
85
132
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
updatedAt: timestamp
|
|
100
|
-
});
|
|
101
|
-
return this.toView(created, userId);
|
|
133
|
+
return this.toView(created, userId);
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
if (preparedWorkspace.sandboxId && this.assistantSandboxService) {
|
|
137
|
+
try {
|
|
138
|
+
this.assistantSandboxService.removeSandbox(preparedWorkspace.sandboxId, userId);
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
// 控制会话没真正启动成功时,尽量把新建的空白沙箱收口,避免残留无主目录。
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
102
146
|
}
|
|
103
147
|
async resumeCurrentSession(userId) {
|
|
104
148
|
const profile = this.butlerProfileService.ensureInitialized();
|
|
105
149
|
const current = this.requireCurrentSession(profile.providerId);
|
|
106
150
|
const promptContext = await this.butlerContextAggregator.resolvePromptContext(userId, null);
|
|
107
|
-
this.syncWorkspaceContext(profile, promptContext, userId);
|
|
151
|
+
this.syncWorkspaceContext(profile, promptContext, userId, this.resolveControlSessionWorkspacePath(profile, current.id, userId));
|
|
108
152
|
try {
|
|
109
153
|
const resumed = await this.sessionHistoryService.resumeSession(current.sessionId);
|
|
110
154
|
const updated = this.butlerControlSessionRepository.update({
|
|
@@ -131,23 +175,45 @@ export class ButlerControlSessionService {
|
|
|
131
175
|
? this.requireSessionById(input.controlSessionId, profile.providerId)
|
|
132
176
|
: this.requireCurrentSession(profile.providerId);
|
|
133
177
|
const content = normalizeControlContent(input.content, "");
|
|
178
|
+
const requestedAt = nowIso();
|
|
179
|
+
const clientRequestId = recordButlerProxyMessageOrigin(this.sessionMessageOriginRepository, {
|
|
180
|
+
sessionId: current.sessionId,
|
|
181
|
+
clientRequestId: normalizeNullableText(input.clientRequestId),
|
|
182
|
+
content,
|
|
183
|
+
createdAt: requestedAt,
|
|
184
|
+
fallbackKey: `butler-control-send:${current.id}:${requestedAt}`
|
|
185
|
+
});
|
|
186
|
+
const model = normalizeNullableText(input.model) ?? current.model;
|
|
187
|
+
const reasoningLevel = normalizeNullableText(input.reasoningLevel) ?? current.reasoningLevel;
|
|
188
|
+
const permissionMode = normalizeNullableText(input.permissionMode) ?? current.permissionMode;
|
|
134
189
|
const promptContext = await this.butlerContextAggregator.resolvePromptContext(userId, content);
|
|
135
|
-
this.syncWorkspaceContext(profile, promptContext, userId);
|
|
190
|
+
this.syncWorkspaceContext(profile, promptContext, userId, this.resolveControlSessionWorkspacePath(profile, current.id, userId));
|
|
136
191
|
try {
|
|
137
192
|
const result = await this.sessionLiveRuntimeService.sendLiveMessage({
|
|
138
193
|
sessionId: current.sessionId,
|
|
139
194
|
userId,
|
|
140
195
|
content,
|
|
141
|
-
clientRequestId
|
|
196
|
+
clientRequestId,
|
|
142
197
|
runtimeOptions: {
|
|
143
|
-
model
|
|
144
|
-
reasoningLevel
|
|
145
|
-
permissionMode
|
|
198
|
+
model,
|
|
199
|
+
reasoningLevel,
|
|
200
|
+
permissionMode,
|
|
146
201
|
attachments: []
|
|
147
202
|
}
|
|
148
203
|
});
|
|
204
|
+
recordButlerProxyMessageOrigin(this.sessionMessageOriginRepository, {
|
|
205
|
+
sessionId: current.sessionId,
|
|
206
|
+
clientRequestId,
|
|
207
|
+
messageId: result.message?.messageId ?? null,
|
|
208
|
+
content,
|
|
209
|
+
createdAt: result.acceptedAt,
|
|
210
|
+
fallbackKey: `butler-control-send:${current.id}:${result.acceptedAt}`
|
|
211
|
+
});
|
|
149
212
|
const updated = this.butlerControlSessionRepository.update({
|
|
150
213
|
...current,
|
|
214
|
+
model,
|
|
215
|
+
reasoningLevel,
|
|
216
|
+
permissionMode,
|
|
151
217
|
status: "running",
|
|
152
218
|
lastContextVersion: promptContext.version,
|
|
153
219
|
lastSummary: summarizeMessage(content),
|
|
@@ -196,21 +262,66 @@ export class ButlerControlSessionService {
|
|
|
196
262
|
session: this.sessionHistoryService.getSession(record.sessionId, userId)
|
|
197
263
|
};
|
|
198
264
|
}
|
|
199
|
-
prepareWorkspace(profile, promptContext, userId) {
|
|
200
|
-
this.
|
|
201
|
-
|
|
265
|
+
async prepareWorkspace(profile, promptContext, userId, input) {
|
|
266
|
+
if (!this.assistantSandboxService) {
|
|
267
|
+
this.syncWorkspaceContext(profile, promptContext, userId, profile.workspacePath);
|
|
268
|
+
const workspace = this.workspaceService.importWorkspace(profile.workspacePath, "代码助手");
|
|
269
|
+
return {
|
|
270
|
+
workspaceId: workspace.id,
|
|
271
|
+
sandboxId: null
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
const sandbox = await this.assistantSandboxService.createSandbox({
|
|
275
|
+
userId,
|
|
276
|
+
title: inferControlSessionSandboxTitle(input.title, input.content),
|
|
277
|
+
description: "当前助手会话独占的临时工作区",
|
|
278
|
+
purpose: "butler_control_session",
|
|
279
|
+
source: {
|
|
280
|
+
kind: "blank",
|
|
281
|
+
directoryName: `control-session-${createId().slice(0, 8)}`
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
const workspacePath = sandbox.workspace?.path?.trim();
|
|
285
|
+
if (!workspacePath) {
|
|
286
|
+
throw new AppError({
|
|
287
|
+
statusCode: 500,
|
|
288
|
+
errorCode: "BUTLER_CONTROL_SANDBOX_UNAVAILABLE",
|
|
289
|
+
detail: "已创建助手沙箱,但未能解析对应工作区路径"
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
this.syncWorkspaceContext(profile, promptContext, userId, workspacePath);
|
|
293
|
+
return {
|
|
294
|
+
workspaceId: sandbox.workspaceId,
|
|
295
|
+
sandboxId: sandbox.id
|
|
296
|
+
};
|
|
202
297
|
}
|
|
203
|
-
syncWorkspaceContext(profile, promptContext, userId) {
|
|
298
|
+
syncWorkspaceContext(profile, promptContext, userId, workspacePath) {
|
|
204
299
|
syncButlerWorkspaceContext({
|
|
205
300
|
profile,
|
|
206
301
|
promptContext,
|
|
207
302
|
userId,
|
|
303
|
+
workspacePath,
|
|
208
304
|
butlerAuthService: this.butlerAuthService,
|
|
209
305
|
skillManagerService: this.skillManagerService,
|
|
210
306
|
codexHomeDir: this.codexHomeDir,
|
|
211
|
-
sourceCodexHomeDir: this.sourceCodexHomeDir
|
|
307
|
+
sourceCodexHomeDir: this.sourceCodexHomeDir,
|
|
308
|
+
claudeCodeHomeDir: this.claudeCodeHomeDir,
|
|
309
|
+
sourceClaudeCodeHomeDir: this.sourceClaudeCodeHomeDir
|
|
212
310
|
});
|
|
213
311
|
}
|
|
312
|
+
resolveControlSessionWorkspacePath(profile, controlSessionId, userId) {
|
|
313
|
+
const sandboxWorkspacePath = this.assistantSandboxService
|
|
314
|
+
?.listSandboxes({
|
|
315
|
+
userId,
|
|
316
|
+
controlSessionId,
|
|
317
|
+
statuses: ["active", "archived"],
|
|
318
|
+
limit: 1
|
|
319
|
+
})[0]
|
|
320
|
+
?.workspace
|
|
321
|
+
?.path
|
|
322
|
+
?.trim();
|
|
323
|
+
return sandboxWorkspacePath || profile.workspacePath;
|
|
324
|
+
}
|
|
214
325
|
markFailed(record, fallbackSummary) {
|
|
215
326
|
this.butlerControlSessionRepository.update({
|
|
216
327
|
...record,
|
|
@@ -251,4 +362,7 @@ function normalizeNullableText(value) {
|
|
|
251
362
|
function summarizeMessage(content) {
|
|
252
363
|
return content.length > 120 ? `${content.slice(0, 117)}...` : content;
|
|
253
364
|
}
|
|
365
|
+
function inferControlSessionSandboxTitle(title, content) {
|
|
366
|
+
return title ?? summarizeMessage(content) ?? "助手临时工作区";
|
|
367
|
+
}
|
|
254
368
|
//# sourceMappingURL=butler-control-session-service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"butler-control-session-service.js","sourceRoot":"","sources":["../../../../src/modules/butler/butler-control-session-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAiBpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAsB3E,MAAM,OAAO,2BAA2B;IAEnB;IACA;IACA;IACA;IAIA;IAIA;IACA;IACA;IACA;IACA;IAhBnB,YACmB,oBAA0C,EAC1C,8BAA8D,EAC9D,gBAA2D,EAC3D,qBAGhB,EACgB,yBAGhB,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CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,WAAW;YAC5E,SAAS,EAAE,MAAM,EAAE;SACpB,CAAC,CAAC;IACL,CAAC;CACF;AAED,SAAS,uBAAuB,CAAC,KAAyB,EAAE,QAAgB;IAC1E,MAAM,UAAU,GAAG,KAAK,EAAE,IAAI,EAAE,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;IAEpD,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,QAAQ,CAAC;YACjB,UAAU,EAAE,GAAG;YACf,SAAS,EAAE,eAAe;YAC1B,MAAM,EAAE,sBAAsB;YAC9B,KAAK,EAAE,SAAS;SACjB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAgC;IAC7D,MAAM,UAAU,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC;IACjC,OAAO,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;AACxC,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAe;IACvC,OAAO,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;AACxE,CAAC"}
|
|
1
|
+
{"version":3,"file":"butler-control-session-service.js","sourceRoot":"","sources":["../../../../src/modules/butler/butler-control-session-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAkBpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AA4B7F,MAAM,OAAO,2BAA2B;IA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duler-metrics.js";
|
|
2
|
+
import type { ButlerControlTimerService } from "./butler-control-timer-service.js";
|
|
3
|
+
interface ButlerControlTimerSchedulerLogger {
|
|
4
|
+
error(message: string, detail?: unknown): void;
|
|
5
|
+
}
|
|
6
|
+
interface ButlerControlTimerSchedulerOptions {
|
|
7
|
+
intervalMs?: number;
|
|
8
|
+
maxIntervalMs?: number;
|
|
9
|
+
now?: () => string;
|
|
10
|
+
logger?: ButlerControlTimerSchedulerLogger;
|
|
11
|
+
schedulerMetrics?: SchedulerMetrics;
|
|
12
|
+
}
|
|
13
|
+
export declare class ButlerControlTimerScheduler {
|
|
14
|
+
private readonly butlerControlTimerService;
|
|
15
|
+
private readonly intervalMs;
|
|
16
|
+
private readonly maxIntervalMs;
|
|
17
|
+
private readonly now;
|
|
18
|
+
private readonly logger;
|
|
19
|
+
private readonly schedulerMetrics;
|
|
20
|
+
private timer;
|
|
21
|
+
private ticking;
|
|
22
|
+
private started;
|
|
23
|
+
private disposed;
|
|
24
|
+
private idleStreak;
|
|
25
|
+
constructor(butlerControlTimerService: Pick<ButlerControlTimerService, "runDueTimers">, options?: ButlerControlTimerSchedulerOptions);
|
|
26
|
+
start(): void;
|
|
27
|
+
dispose(): Promise<void>;
|
|
28
|
+
runOnce(): Promise<void>;
|
|
29
|
+
private scheduleNext;
|
|
30
|
+
private tick;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { nowIso } from "../../shared/utils/time.js";
|
|
2
|
+
import { resolveAdaptiveSchedulerDelayMs } from "../tasks/scheduler-metrics.js";
|
|
3
|
+
const DEFAULT_INTERVAL_MS = 10_000;
|
|
4
|
+
export class ButlerControlTimerScheduler {
|
|
5
|
+
butlerControlTimerService;
|
|
6
|
+
intervalMs;
|
|
7
|
+
maxIntervalMs;
|
|
8
|
+
now;
|
|
9
|
+
logger;
|
|
10
|
+
schedulerMetrics;
|
|
11
|
+
timer = null;
|
|
12
|
+
ticking = false;
|
|
13
|
+
started = false;
|
|
14
|
+
disposed = false;
|
|
15
|
+
idleStreak = 0;
|
|
16
|
+
constructor(butlerControlTimerService, options = {}) {
|
|
17
|
+
this.butlerControlTimerService = butlerControlTimerService;
|
|
18
|
+
this.intervalMs = Math.max(5_000, options.intervalMs ?? DEFAULT_INTERVAL_MS);
|
|
19
|
+
this.maxIntervalMs = Math.max(this.intervalMs, options.maxIntervalMs ?? this.intervalMs * 8);
|
|
20
|
+
this.now = options.now ?? nowIso;
|
|
21
|
+
this.logger = options.logger ?? console;
|
|
22
|
+
this.schedulerMetrics = options.schedulerMetrics ?? null;
|
|
23
|
+
}
|
|
24
|
+
start() {
|
|
25
|
+
if (this.timer || this.disposed) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
this.started = true;
|
|
29
|
+
this.scheduleNext(0);
|
|
30
|
+
}
|
|
31
|
+
async dispose() {
|
|
32
|
+
this.started = false;
|
|
33
|
+
this.disposed = true;
|
|
34
|
+
if (this.timer) {
|
|
35
|
+
clearTimeout(this.timer);
|
|
36
|
+
this.timer = null;
|
|
37
|
+
}
|
|
38
|
+
while (this.ticking) {
|
|
39
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async runOnce() {
|
|
43
|
+
await this.tick(false);
|
|
44
|
+
}
|
|
45
|
+
scheduleNext(delayMs) {
|
|
46
|
+
this.timer = setTimeout(() => {
|
|
47
|
+
this.timer = null;
|
|
48
|
+
void this.tick();
|
|
49
|
+
}, delayMs);
|
|
50
|
+
this.timer.unref?.();
|
|
51
|
+
}
|
|
52
|
+
async tick(shouldScheduleNext = true) {
|
|
53
|
+
if (this.ticking) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
this.ticking = true;
|
|
57
|
+
const tickStartedAt = Date.now();
|
|
58
|
+
const referenceAt = this.now();
|
|
59
|
+
let result = null;
|
|
60
|
+
let errorCount = 0;
|
|
61
|
+
try {
|
|
62
|
+
result = await this.butlerControlTimerService.runDueTimers(referenceAt);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
errorCount = 1;
|
|
66
|
+
this.logger.error("[butler-control-timer-scheduler] tick failed", {
|
|
67
|
+
error: error instanceof Error ? error.message : String(error),
|
|
68
|
+
referenceAt
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
this.ticking = false;
|
|
73
|
+
const idle = result?.idle ?? true;
|
|
74
|
+
const taskCount = result?.dueTimerCount ?? 0;
|
|
75
|
+
this.idleStreak = idle ? this.idleStreak + 1 : 0;
|
|
76
|
+
const nextDelayMs = resolveAdaptiveSchedulerDelayMs(this.intervalMs, this.maxIntervalMs, this.idleStreak);
|
|
77
|
+
this.schedulerMetrics?.recordTick({
|
|
78
|
+
schedulerName: "butler_control_timer",
|
|
79
|
+
referenceAt,
|
|
80
|
+
durationMs: Date.now() - tickStartedAt,
|
|
81
|
+
taskCount,
|
|
82
|
+
idle,
|
|
83
|
+
errorCount,
|
|
84
|
+
nextDelayMs,
|
|
85
|
+
idleStreak: this.idleStreak
|
|
86
|
+
});
|
|
87
|
+
if (shouldScheduleNext && this.started && !this.disposed && this.timer === null) {
|
|
88
|
+
this.scheduleNext(nextDelayMs);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=butler-control-timer-scheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"butler-control-timer-scheduler.js","sourceRoot":"","sources":["../../../../src/modules/butler/butler-control-timer-scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EACL,+BAA+B,EAEhC,MAAM,+BAA+B,CAAC;AAGvC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAcnC,MAAM,OAAO,2BAA2B;IAanB;IAZF,UAAU,CAAS;IACnB,aAAa,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AAC;QACL,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;YAErB,MAAM,IAAI,GAAG,MAAM,EAAE,IAAI,IAAI,IAAI,CAAC;YAClC,MAAM,SAAS,GAAG,MAAM,EAAE,aAAa,IAAI,CAAC,CAAC;YAC7C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACjD,MAAM,WAAW,GAAG,+BAA+B,CACjD,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,UAAU,CAChB,CAAC;YACF,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC;gBAChC,aAAa,EAAE,sBAAsB;gBACrC,WAAW;gBACX,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,aAAa;gBACtC,SAAS;gBACT,IAAI;gBACJ,UAAU;gBACV,WAAW;gBACX,UAAU,EAAE,IAAI,CAAC,UAAU;aAC5B,CAAC,CAAC;YAEH,IAAI,kBAAkB,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;gBAChF,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ButlerControlTimer, ButlerControlTimerStatus } from "../../types/domain.js";
|
|
2
|
+
import type { ButlerProfileService } from "./butler-profile-service.js";
|
|
3
|
+
import type { ButlerControlSessionService, ButlerControlSessionView } from "./butler-control-session-service.js";
|
|
4
|
+
import type { ButlerControlTimerRepository } from "../../storage/repositories/butler-control-timer-repository.js";
|
|
5
|
+
import type { AssistantAutomationService } from "./assistant-automation-service.js";
|
|
6
|
+
export interface ButlerControlTimerView extends ButlerControlTimer {
|
|
7
|
+
controlSession: ButlerControlSessionView | null;
|
|
8
|
+
}
|
|
9
|
+
export interface CreateButlerControlTimerInput {
|
|
10
|
+
userId: string;
|
|
11
|
+
controlSessionId?: string | null;
|
|
12
|
+
projectId?: string | null;
|
|
13
|
+
targetSessionId?: string | null;
|
|
14
|
+
title?: string | null;
|
|
15
|
+
content: string;
|
|
16
|
+
dueAt?: string | null;
|
|
17
|
+
afterSeconds?: number | null;
|
|
18
|
+
}
|
|
19
|
+
export interface ButlerControlTimerRunDueTimersResult {
|
|
20
|
+
activeTimerCount: number;
|
|
21
|
+
dueTimerCount: number;
|
|
22
|
+
processedTimerCount: number;
|
|
23
|
+
idle: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare class ButlerControlTimerService {
|
|
26
|
+
private readonly butlerProfileService;
|
|
27
|
+
private readonly butlerControlSessionService;
|
|
28
|
+
private readonly butlerControlTimerRepository;
|
|
29
|
+
private readonly assistantAutomationService;
|
|
30
|
+
constructor(butlerProfileService: Pick<ButlerProfileService, "ensureInitialized">, butlerControlSessionService: Pick<ButlerControlSessionService, "getCurrentSession" | "getSession" | "sendMessage">, butlerControlTimerRepository: ButlerControlTimerRepository, assistantAutomationService: Pick<AssistantAutomationService, "listTasks" | "getTask" | "createTask" | "cancelTask" | "runDueTasks">);
|
|
31
|
+
listTimers(filters: {
|
|
32
|
+
userId: string;
|
|
33
|
+
statuses?: ButlerControlTimerStatus[];
|
|
34
|
+
controlSessionId?: string | null;
|
|
35
|
+
limit?: number;
|
|
36
|
+
}): ButlerControlTimerView[];
|
|
37
|
+
getTimer(timerId: string, userId: string): ButlerControlTimerView;
|
|
38
|
+
createTimer(input: CreateButlerControlTimerInput): ButlerControlTimerView;
|
|
39
|
+
cancelTimer(timerId: string, userId: string): ButlerControlTimerView;
|
|
40
|
+
runDueTimers(referenceAt: string): Promise<ButlerControlTimerRunDueTimersResult>;
|
|
41
|
+
private mapTaskToTimerView;
|
|
42
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { AppError } from "../../shared/errors/app-error.js";
|
|
2
|
+
export class ButlerControlTimerService {
|
|
3
|
+
butlerProfileService;
|
|
4
|
+
butlerControlSessionService;
|
|
5
|
+
butlerControlTimerRepository;
|
|
6
|
+
assistantAutomationService;
|
|
7
|
+
constructor(butlerProfileService, butlerControlSessionService, butlerControlTimerRepository, assistantAutomationService) {
|
|
8
|
+
this.butlerProfileService = butlerProfileService;
|
|
9
|
+
this.butlerControlSessionService = butlerControlSessionService;
|
|
10
|
+
this.butlerControlTimerRepository = butlerControlTimerRepository;
|
|
11
|
+
this.assistantAutomationService = assistantAutomationService;
|
|
12
|
+
}
|
|
13
|
+
listTimers(filters) {
|
|
14
|
+
this.butlerProfileService.ensureInitialized();
|
|
15
|
+
return this.assistantAutomationService
|
|
16
|
+
.listTasks({
|
|
17
|
+
userId: filters.userId,
|
|
18
|
+
statuses: mapTimerStatusesToAutomationStatuses(filters.statuses),
|
|
19
|
+
controlSessionId: filters.controlSessionId?.trim() || null,
|
|
20
|
+
limit: filters.limit
|
|
21
|
+
})
|
|
22
|
+
.filter((task) => task.triggerType === "once")
|
|
23
|
+
.map((task) => this.mapTaskToTimerView(task));
|
|
24
|
+
}
|
|
25
|
+
getTimer(timerId, userId) {
|
|
26
|
+
this.butlerProfileService.ensureInitialized();
|
|
27
|
+
return this.mapTaskToTimerView(this.assistantAutomationService.getTask(timerId.trim(), userId));
|
|
28
|
+
}
|
|
29
|
+
createTimer(input) {
|
|
30
|
+
this.butlerProfileService.ensureInitialized();
|
|
31
|
+
const created = this.assistantAutomationService.createTask({
|
|
32
|
+
userId: input.userId,
|
|
33
|
+
controlSessionId: input.controlSessionId,
|
|
34
|
+
projectId: input.projectId,
|
|
35
|
+
title: input.title,
|
|
36
|
+
trigger: {
|
|
37
|
+
type: "once",
|
|
38
|
+
dueAt: input.dueAt,
|
|
39
|
+
afterSeconds: input.afterSeconds ?? null
|
|
40
|
+
},
|
|
41
|
+
action: {
|
|
42
|
+
type: "send_control_message",
|
|
43
|
+
content: input.content,
|
|
44
|
+
includeTriggerContext: false,
|
|
45
|
+
targetSessionId: input.targetSessionId
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return this.mapTaskToTimerView(created);
|
|
49
|
+
}
|
|
50
|
+
cancelTimer(timerId, userId) {
|
|
51
|
+
this.butlerProfileService.ensureInitialized();
|
|
52
|
+
return this.mapTaskToTimerView(this.assistantAutomationService.cancelTask(timerId.trim(), userId));
|
|
53
|
+
}
|
|
54
|
+
async runDueTimers(referenceAt) {
|
|
55
|
+
this.butlerProfileService.ensureInitialized();
|
|
56
|
+
const result = await this.assistantAutomationService.runDueTasks(referenceAt);
|
|
57
|
+
return {
|
|
58
|
+
activeTimerCount: result.activeTaskCount,
|
|
59
|
+
dueTimerCount: result.dueTaskCount,
|
|
60
|
+
processedTimerCount: result.processedTaskCount,
|
|
61
|
+
idle: result.idle
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
mapTaskToTimerView(task) {
|
|
65
|
+
if (task.triggerType !== "once") {
|
|
66
|
+
throw new AppError({
|
|
67
|
+
statusCode: 409,
|
|
68
|
+
errorCode: "BUTLER_CONTROL_TIMER_COMPATIBILITY_ERROR",
|
|
69
|
+
detail: "当前计时器兼容视图只支持 once 类型自动化"
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const triggerConfig = parseOnceTriggerConfig(task.triggerConfigJson);
|
|
73
|
+
const actionConfig = parseSendControlMessageActionConfig(task.actionConfigJson);
|
|
74
|
+
return {
|
|
75
|
+
id: task.id,
|
|
76
|
+
controlSessionId: task.controlSessionId,
|
|
77
|
+
sessionId: task.controlSession?.sessionId ?? "",
|
|
78
|
+
userId: task.userId,
|
|
79
|
+
projectId: task.projectId,
|
|
80
|
+
targetSessionId: actionConfig.targetSessionId,
|
|
81
|
+
title: task.title,
|
|
82
|
+
content: actionConfig.content,
|
|
83
|
+
dueAt: triggerConfig.dueAt,
|
|
84
|
+
status: mapAutomationStatusToTimerStatus(task.status),
|
|
85
|
+
triggeredAt: task.lastRunAt,
|
|
86
|
+
lastError: task.lastError,
|
|
87
|
+
createdAt: task.createdAt,
|
|
88
|
+
updatedAt: task.updatedAt,
|
|
89
|
+
cancelledAt: task.cancelledAt,
|
|
90
|
+
controlSession: task.controlSession
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function mapTimerStatusesToAutomationStatuses(statuses) {
|
|
95
|
+
return statuses?.map((status) => (status === "active" ? "active" : status));
|
|
96
|
+
}
|
|
97
|
+
function mapAutomationStatusToTimerStatus(status) {
|
|
98
|
+
if (status === "paused") {
|
|
99
|
+
return "active";
|
|
100
|
+
}
|
|
101
|
+
return status;
|
|
102
|
+
}
|
|
103
|
+
function parseOnceTriggerConfig(value) {
|
|
104
|
+
const parsed = JSON.parse(value);
|
|
105
|
+
const dueAt = parsed.dueAt?.trim();
|
|
106
|
+
if (!dueAt) {
|
|
107
|
+
throw new AppError({
|
|
108
|
+
statusCode: 500,
|
|
109
|
+
errorCode: "BUTLER_CONTROL_TIMER_COMPATIBILITY_ERROR",
|
|
110
|
+
detail: "自动化缺少 once 触发时间,无法映射为计时器"
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
dueAt
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function parseSendControlMessageActionConfig(value) {
|
|
118
|
+
const parsed = JSON.parse(value);
|
|
119
|
+
const content = parsed.content?.trim();
|
|
120
|
+
if (!content) {
|
|
121
|
+
throw new AppError({
|
|
122
|
+
statusCode: 500,
|
|
123
|
+
errorCode: "BUTLER_CONTROL_TIMER_COMPATIBILITY_ERROR",
|
|
124
|
+
detail: "自动化缺少控制会话消息内容,无法映射为计时器"
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
content,
|
|
129
|
+
targetSessionId: parsed.targetSessionId?.trim() || null
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=butler-control-timer-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"butler-control-timer-service.js","sourceRoot":"","sources":["../../../../src/modules/butler/butler-control-timer-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAsC5D,MAAM,OAAO,yBAAyB;IAEjB;IACA;IAIA;IACA;IAPnB,YACmB,oBAAqE,EACrE,2BAGhB,EACgB,4BAA0D,EAC1D,0BAGhB;QATgB,yBAAoB,GAApB,oBAAoB,CAAiD;QACrE,gCAA2B,GAA3B,2BAA2B,CAG3C;QACgB,iCAA4B,GAA5B,4BAA4B,CAA8B;QAC1D,+BAA0B,GAA1B,0BAA0B,CAG1C;IACA,CAAC;IAEJ,UAAU,CAAC,OAKV;QACC,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC,0BAA0B;aACnC,SAAS,CAAC;YACT,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,QAAQ,EAAE,oCAAoC,CAAC,OAAO,CAAC,QAAQ,CAAC;YAChE,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,EAAE,IAAI,EAAE,IAAI,IAAI;YAC1D,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAC;aACD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,KAAK,MAAM,CAAC;aAC7C,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,QAAQ,CAAC,OAAe,EAAE,MAAc;QACtC,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,0BAA0B,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC,CAA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