personal-bot 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTEXT.md +9 -7
- package/README.md +15 -8
- package/README.zh-CN.md +15 -8
- package/docs/README.md +3 -1
- package/docs/agent-collaboration.md +27 -13
- package/docs/architecture-guidelines.md +2 -2
- package/docs/capability-design.md +6 -4
- package/docs/dsh-implementation-plan.md +158 -0
- package/docs/dsh-support-proposal.md +314 -0
- package/docs/dsh.md +103 -0
- package/docs/file-storage.md +14 -9
- package/docs/history.md +29 -18
- package/docs/installation-design.md +3 -1
- package/docs/interaction-design.md +13 -0
- package/docs/release.md +3 -3
- package/docs/subagent-upgrade-proposal.md +3 -3
- package/docs/technical-design.md +29 -15
- package/docs/validation.md +49 -3
- package/lib/client.js +1071 -0
- package/lib/common/files.d.ts +2 -0
- package/lib/common/files.js +44 -0
- package/lib/common/json.d.ts +6 -0
- package/lib/common/json.js +16 -0
- package/lib/common/markdown.d.ts +5 -0
- package/lib/common/markdown.js +26 -0
- package/lib/common/paths.d.ts +1 -0
- package/lib/common/paths.js +2 -0
- package/lib/common/validation.d.ts +3 -0
- package/lib/common/validation.js +14 -0
- package/lib/common/version.d.ts +3 -0
- package/lib/common/version.js +13 -0
- package/lib/dsh.d.ts +4 -0
- package/lib/dsh.js +22 -0
- package/lib/extension/dsh/agent-events.d.ts +24 -0
- package/lib/extension/dsh/agent-events.js +242 -0
- package/lib/extension/dsh/agent-runtime.d.ts +49 -0
- package/lib/extension/dsh/agent-runtime.js +348 -0
- package/lib/extension/dsh/command.d.ts +4 -0
- package/lib/extension/dsh/command.js +83 -0
- package/lib/extension/dsh/files.d.ts +5 -0
- package/lib/extension/dsh/files.js +67 -0
- package/lib/extension/dsh/history.d.ts +15 -0
- package/lib/extension/dsh/history.js +88 -0
- package/lib/extension/dsh/management.d.ts +21 -0
- package/lib/extension/dsh/management.js +217 -0
- package/lib/extension/dsh/workspace.d.ts +48 -0
- package/lib/extension/dsh/workspace.js +290 -0
- package/lib/integrations/agent-resources.d.ts +1 -0
- package/lib/integrations/agent-resources.js +18 -0
- package/lib/integrations/dsh/dsh-agents.d.ts +30 -0
- package/lib/integrations/dsh/dsh-agents.js +104 -0
- package/lib/integrations/dsh/history-summary.d.ts +11 -0
- package/lib/integrations/dsh/history-summary.js +40 -0
- package/lib/integrations/dsh/history.d.ts +16 -0
- package/lib/integrations/dsh/history.js +156 -0
- package/lib/integrations/dsh/input.d.ts +21 -0
- package/lib/integrations/dsh/input.js +62 -0
- package/lib/integrations/dsh/messages.d.ts +36 -0
- package/lib/integrations/dsh/messages.js +11 -0
- package/lib/integrations/dsh/notifications.d.ts +8 -0
- package/lib/integrations/dsh/notifications.js +55 -0
- package/lib/integrations/dsh/resources.d.ts +10 -0
- package/lib/integrations/dsh/resources.js +41 -0
- package/lib/integrations/dsh/schema.d.ts +7 -0
- package/lib/integrations/dsh/schema.js +28 -0
- package/lib/integrations/dsh/session.d.ts +14 -0
- package/lib/integrations/dsh/session.js +59 -0
- package/lib/integrations/history-summary.d.ts +2 -0
- package/lib/integrations/history-summary.js +21 -0
- package/lib/integrations/process.d.ts +14 -0
- package/lib/integrations/process.js +48 -0
- package/lib/integrations/python-activation.d.ts +2 -0
- package/lib/integrations/python-activation.js +29 -0
- package/lib/integrations/team-context.d.ts +18 -0
- package/lib/integrations/team-context.js +57 -0
- package/lib/model/agent.d.ts +92 -0
- package/lib/model/agent.js +1 -0
- package/lib/model/history.d.ts +43 -0
- package/lib/model/history.js +1 -0
- package/lib/model/team.d.ts +85 -0
- package/lib/model/team.js +1 -0
- package/lib/services/agents/agent-notices.d.ts +13 -0
- package/lib/services/agents/agent-notices.js +25 -0
- package/lib/services/agents/agent-run.d.ts +39 -0
- package/lib/services/agents/agent-run.js +138 -0
- package/lib/services/agents/agent-service.d.ts +166 -0
- package/lib/services/agents/agent-service.js +325 -0
- package/lib/services/agents/team-service.d.ts +168 -0
- package/lib/services/agents/team-service.js +343 -0
- package/lib/services/history/history-service.d.ts +103 -0
- package/lib/services/history/history-service.js +269 -0
- package/lib/services/workspace/python-environment-service.d.ts +15 -0
- package/lib/services/workspace/python-environment-service.js +50 -0
- package/lib/services/workspace/workspace-files.d.ts +2 -0
- package/lib/services/workspace/workspace-files.js +17 -0
- package/lib/services/workspace/workspace-preparation.d.ts +2 -0
- package/lib/services/workspace/workspace-preparation.js +18 -0
- package/lib/storage/agent-files.d.ts +30 -0
- package/lib/storage/agent-files.js +166 -0
- package/lib/storage/atomic-json.d.ts +11 -0
- package/lib/storage/atomic-json.js +101 -0
- package/lib/storage/file-access.d.ts +2 -0
- package/lib/storage/file-access.js +26 -0
- package/lib/storage/history-files.d.ts +10 -0
- package/lib/storage/history-files.js +63 -0
- package/lib/storage/team-files.d.ts +16 -0
- package/lib/storage/team-files.js +111 -0
- package/lib/tools/agents/actions.d.ts +52 -0
- package/lib/tools/agents/actions.js +49 -0
- package/lib/tools/agents/contract.d.ts +163 -0
- package/lib/tools/agents/contract.js +56 -0
- package/lib/tools/agents/dsh-contract.d.ts +52 -0
- package/lib/tools/agents/dsh-contract.js +15 -0
- package/lib/tools/agents/dsh-tool.d.ts +5 -0
- package/lib/tools/agents/dsh-tool.js +38 -0
- package/lib/tools/history/actions.d.ts +70 -0
- package/lib/tools/history/actions.js +7 -0
- package/lib/tools/history/contract.d.ts +81 -0
- package/lib/tools/history/contract.js +32 -0
- package/lib/tools/history/dsh-tool.d.ts +4 -0
- package/lib/tools/history/dsh-tool.js +22 -0
- package/lib/tools/result.d.ts +18 -0
- package/lib/tools/result.js +10 -0
- package/lib/tools/teams/actions.d.ts +24 -0
- package/lib/tools/teams/actions.js +38 -0
- package/lib/tools/teams/contract.d.ts +232 -0
- package/lib/tools/teams/contract.js +67 -0
- package/lib/tools/teams/dsh-tool.d.ts +8 -0
- package/lib/tools/teams/dsh-tool.js +49 -0
- package/lib/ui/dsh/attachments.d.ts +5 -0
- package/lib/ui/dsh/attachments.js +39 -0
- package/lib/ui/dsh/elements.d.ts +17 -0
- package/lib/ui/dsh/elements.js +79 -0
- package/lib/ui/dsh/index.d.ts +4 -0
- package/lib/ui/dsh/index.js +13 -0
- package/lib/ui/dsh/management.d.ts +4 -0
- package/lib/ui/dsh/management.js +711 -0
- package/lib/ui/dsh/remote.d.ts +15 -0
- package/lib/ui/dsh/remote.js +11 -0
- package/lib/ui/dsh/styles.d.ts +1 -0
- package/lib/ui/dsh/styles.js +132 -0
- package/lib/ui/presentation.d.ts +3 -0
- package/lib/ui/presentation.js +12 -0
- package/npm-shrinkwrap.json +11123 -793
- package/package.json +94 -11
- package/python/README.md +6 -6
- package/resources/agents/coordinator.md +1 -1
- package/resources/dsh/cordis.patch.yml +3 -0
- package/resources/prompts/workspace.md +1 -1
- package/resources/references/compute.md +1 -1
- package/resources/references/task-conductor.md +6 -4
- package/resources/skills/provider-connections/SKILL.md +10 -0
- package/scripts/README.md +9 -1
- package/src/dsh.ts +22 -0
- package/src/extension/agent-events.ts +51 -46
- package/src/extension/agents-command.ts +48 -34
- package/src/extension/command.ts +42 -23
- package/src/extension/dsh/agent-events.ts +148 -0
- package/src/extension/dsh/agent-runtime.ts +251 -0
- package/src/extension/dsh/command.ts +78 -0
- package/src/extension/dsh/files.ts +61 -0
- package/src/extension/dsh/history.ts +69 -0
- package/src/extension/dsh/management.ts +108 -0
- package/src/extension/dsh/workspace.ts +206 -0
- package/src/extension/events.ts +6 -4
- package/src/extension/history.ts +15 -12
- package/src/extension/subagent-entry.ts +34 -63
- package/src/extension/teams-command.ts +53 -46
- package/src/integrations/{pi/agent-resources.ts → agent-resources.ts} +2 -2
- package/src/integrations/dsh/dsh-agents.ts +97 -0
- package/src/integrations/dsh/history-summary.ts +43 -0
- package/src/integrations/dsh/history.ts +76 -0
- package/src/integrations/dsh/input.ts +66 -0
- package/src/integrations/dsh/messages.ts +22 -0
- package/src/integrations/dsh/notifications.ts +46 -0
- package/src/integrations/dsh/resources.ts +44 -0
- package/src/integrations/dsh/schema.ts +26 -0
- package/src/integrations/dsh/session.ts +67 -0
- package/src/integrations/history-summary.ts +20 -0
- package/src/integrations/pi/history.ts +4 -14
- package/src/integrations/pi/pi-agents.ts +17 -6
- package/src/integrations/pi/team-context.ts +6 -58
- package/src/integrations/team-context.ts +60 -0
- package/src/model/agent.ts +2 -0
- package/src/model/history.ts +3 -1
- package/src/pbot.ts +1 -1
- package/src/services/agents/agent-notices.ts +28 -0
- package/src/services/agents/agent-run.ts +114 -0
- package/src/services/agents/agent-service.ts +127 -64
- package/src/services/history/history-service.ts +120 -59
- package/src/storage/agent-files.ts +17 -4
- package/src/storage/history-files.ts +30 -5
- package/src/tools/agents/actions.ts +47 -0
- package/src/tools/agents/contract.ts +8 -5
- package/src/tools/agents/dsh-contract.ts +16 -0
- package/src/tools/agents/dsh-tool.ts +41 -0
- package/src/tools/agents/tool.ts +7 -43
- package/src/tools/history/actions.ts +9 -0
- package/src/tools/history/contract.ts +34 -0
- package/src/tools/history/dsh-tool.ts +22 -0
- package/src/tools/history/tool.ts +7 -30
- package/src/tools/teams/actions.ts +38 -0
- package/src/tools/teams/contract.ts +7 -3
- package/src/tools/teams/dsh-tool.ts +55 -0
- package/src/tools/teams/tool.ts +6 -31
- package/src/ui/agent-display.ts +7 -4
- package/src/ui/dsh/attachments.ts +42 -0
- package/src/ui/dsh/elements.ts +50 -0
- package/src/ui/dsh/index.ts +18 -0
- package/src/ui/dsh/management.ts +412 -0
- package/src/ui/dsh/remote.ts +20 -0
- package/src/ui/dsh/styles.ts +132 -0
- package/src/ui/pi/menu.ts +37 -0
- package/src/ui/pi/reader.ts +46 -0
- package/src/ui/presentation.ts +12 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
+
var useValue = arguments.length > 2;
|
|
3
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
+
}
|
|
6
|
+
return useValue ? value : void 0;
|
|
7
|
+
};
|
|
8
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
+
var _, done = false;
|
|
14
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
+
var context = {};
|
|
16
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
+
if (kind === "accessor") {
|
|
21
|
+
if (result === void 0) continue;
|
|
22
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
+
}
|
|
27
|
+
else if (_ = accept(result)) {
|
|
28
|
+
if (kind === "field") initializers.unshift(_);
|
|
29
|
+
else descriptor[key] = _;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
+
done = true;
|
|
34
|
+
};
|
|
35
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
36
|
+
if (value !== null && value !== void 0) {
|
|
37
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
38
|
+
var dispose, inner;
|
|
39
|
+
if (async) {
|
|
40
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
41
|
+
dispose = value[Symbol.asyncDispose];
|
|
42
|
+
}
|
|
43
|
+
if (dispose === void 0) {
|
|
44
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
45
|
+
dispose = value[Symbol.dispose];
|
|
46
|
+
if (async) inner = dispose;
|
|
47
|
+
}
|
|
48
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
49
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
50
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
51
|
+
}
|
|
52
|
+
else if (async) {
|
|
53
|
+
env.stack.push({ async: true });
|
|
54
|
+
}
|
|
55
|
+
return value;
|
|
56
|
+
};
|
|
57
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
58
|
+
return function (env) {
|
|
59
|
+
function fail(e) {
|
|
60
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
61
|
+
env.hasError = true;
|
|
62
|
+
}
|
|
63
|
+
var r, s = 0;
|
|
64
|
+
function next() {
|
|
65
|
+
while (r = env.stack.pop()) {
|
|
66
|
+
try {
|
|
67
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
68
|
+
if (r.dispose) {
|
|
69
|
+
var result = r.dispose.call(r.value);
|
|
70
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
71
|
+
}
|
|
72
|
+
else s |= 1;
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
fail(e);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
79
|
+
if (env.hasError) throw env.error;
|
|
80
|
+
}
|
|
81
|
+
return next();
|
|
82
|
+
};
|
|
83
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
84
|
+
var e = new Error(message);
|
|
85
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
86
|
+
});
|
|
87
|
+
import { Remote, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
88
|
+
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
89
|
+
import { extractSessionEventText } from "@deepseek-ai/dsh-session-query";
|
|
90
|
+
import { Type } from "typebox";
|
|
91
|
+
import { json } from "../../common/json.js";
|
|
92
|
+
import { requireThat, schema } from "../../common/validation.js";
|
|
93
|
+
import { packageVersion } from "../../common/version.js";
|
|
94
|
+
import { historyInput } from "../../tools/history/contract.js";
|
|
95
|
+
import { executeHistory } from "../../tools/history/actions.js";
|
|
96
|
+
import { pbotReadRemote } from "../../ui/dsh/remote.js";
|
|
97
|
+
const requestSchema = Type.Object({ parentSessionId: Type.String({ minLength: 1 }), input: Type.Optional(Type.Unknown()) }, { additionalProperties: false });
|
|
98
|
+
const expertSchema = Type.Object({ agentId: Type.String({ minLength: 1 }), offset: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
99
|
+
limit: Type.Optional(Type.Integer({ minimum: 1, maximum: 100 })), seq: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
100
|
+
textOffset: Type.Optional(Type.Integer({ minimum: 0 })), textLimit: Type.Optional(Type.Integer({ minimum: 2, maximum: 24000 })),
|
|
101
|
+
format: Type.Optional(Type.Union([Type.Literal("text"), Type.Literal("json")])) }, { additionalProperties: false });
|
|
102
|
+
const teamSchema = Type.Object({ teamId: Type.String({ minLength: 1 }), afterSeq: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
103
|
+
seq: Type.Optional(Type.Integer({ minimum: 1 })), offset: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
104
|
+
limit: Type.Optional(Type.Integer({ minimum: 1, maximum: 16000 })) }, { additionalProperties: false });
|
|
105
|
+
const validRequest = schema(requestSchema), validExpert = schema(expertSchema), validTeam = schema(teamSchema);
|
|
106
|
+
export function dshStatus(workspaces, workspace) {
|
|
107
|
+
workspace.check();
|
|
108
|
+
const agents = workspace.agents.list(workspace.owner);
|
|
109
|
+
return json({ host: "dsh", release: packageVersion, workspaceRoot: workspace.root, sessionId: workspace.agent.id,
|
|
110
|
+
model: workspace.agent.model.current() ?? null, python: workspaces.python.status,
|
|
111
|
+
controlError: workspace.controlError ?? null, history: workspace.history.status,
|
|
112
|
+
agents, teams: workspace.teams.list(workspace.owner, agents) });
|
|
113
|
+
}
|
|
114
|
+
/** Native Remote owns transport and access checks. These workspace reads do not admit or cancel execution. */
|
|
115
|
+
let PbotManagement = (() => {
|
|
116
|
+
let _classSuper = TypertRemoteService;
|
|
117
|
+
let _instanceExtraInitializers = [];
|
|
118
|
+
let _snapshot_decorators;
|
|
119
|
+
let _expert_decorators;
|
|
120
|
+
let _team_decorators;
|
|
121
|
+
let _history_decorators;
|
|
122
|
+
return class PbotManagement extends _classSuper {
|
|
123
|
+
static {
|
|
124
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
125
|
+
_snapshot_decorators = [Remote];
|
|
126
|
+
_expert_decorators = [Remote];
|
|
127
|
+
_team_decorators = [Remote];
|
|
128
|
+
_history_decorators = [Remote];
|
|
129
|
+
__esDecorate(this, null, _snapshot_decorators, { kind: "method", name: "snapshot", static: false, private: false, access: { has: obj => "snapshot" in obj, get: obj => obj.snapshot }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
130
|
+
__esDecorate(this, null, _expert_decorators, { kind: "method", name: "expert", static: false, private: false, access: { has: obj => "expert" in obj, get: obj => obj.expert }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
131
|
+
__esDecorate(this, null, _team_decorators, { kind: "method", name: "team", static: false, private: false, access: { has: obj => "team" in obj, get: obj => obj.team }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
132
|
+
__esDecorate(this, null, _history_decorators, { kind: "method", name: "history", static: false, private: false, access: { has: obj => "history" in obj, get: obj => obj.history }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
133
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
134
|
+
}
|
|
135
|
+
workspaces = __runInitializers(this, _instanceExtraInitializers);
|
|
136
|
+
constructor(ctx, workspaces) {
|
|
137
|
+
super(ctx, "pbotManagement", { namespace: "pbot" });
|
|
138
|
+
this.workspaces = workspaces;
|
|
139
|
+
}
|
|
140
|
+
async workspace(request, signal) {
|
|
141
|
+
signal.throwIfAborted();
|
|
142
|
+
requireThat(validRequest(request), "管理查询参数无效。");
|
|
143
|
+
const args = request;
|
|
144
|
+
const agent = this.ctx.agents.get(SessionId(args.parentSessionId));
|
|
145
|
+
requireThat(agent, "父会话未加载或已关闭,请在原生会话页面重新打开。");
|
|
146
|
+
const workspace = await this.workspaces.get(agent);
|
|
147
|
+
signal.throwIfAborted();
|
|
148
|
+
workspace.check();
|
|
149
|
+
return { workspace, input: args.input, signal: AbortSignal.any([signal, workspace.lifetime.signal]) };
|
|
150
|
+
}
|
|
151
|
+
async snapshot(request, signal) {
|
|
152
|
+
const { workspace, input } = await this.workspace(request, signal);
|
|
153
|
+
requireThat(input === undefined, "工作区状态查询不接受额外参数。");
|
|
154
|
+
return dshStatus(this.workspaces, workspace);
|
|
155
|
+
}
|
|
156
|
+
async expert(request, signal) {
|
|
157
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
158
|
+
try {
|
|
159
|
+
const current = await this.workspace(request, signal), { workspace, input } = current;
|
|
160
|
+
requireThat(validExpert(input), "专家记录查询参数无效。");
|
|
161
|
+
const args = input;
|
|
162
|
+
const view = workspace.agents.status(args.agentId, workspace.owner);
|
|
163
|
+
const observation = __addDisposableResource(env_1, await this.ctx.sessionQuery.observeSession(SessionId(view.agentId), { projectionMode: "none", signal: current.signal }), false);
|
|
164
|
+
workspace.check();
|
|
165
|
+
current.signal.throwIfAborted();
|
|
166
|
+
const header = observation.header;
|
|
167
|
+
requireThat(header.id === view.agentId && header.cwd === view.cwd && header.parentSession === workspace.agent.id &&
|
|
168
|
+
header.origin === "subagent" && !header.isSeeded, "原生专家记录的身份或归属不匹配。");
|
|
169
|
+
const events = observation.events;
|
|
170
|
+
if (args.seq !== undefined) {
|
|
171
|
+
const event = events.find(value => value.seq === args.seq);
|
|
172
|
+
requireThat(event, "原生记录位置不存在。");
|
|
173
|
+
const text = (args.format === "text" ? extractSessionEventText(event) : "") || JSON.stringify(event, null, 2), offset = args.textOffset ?? 0;
|
|
174
|
+
requireThat(offset <= text.length, "原生记录分页位置超出范围。");
|
|
175
|
+
let end = Math.min(text.length, offset + (args.textLimit ?? 12000));
|
|
176
|
+
if (end < text.length && /[\uD800-\uDBFF]/.test(text[end - 1]))
|
|
177
|
+
end--;
|
|
178
|
+
return json({ agent: view, cursor: observation.cursor, seq: event.seq, offset, text: text.slice(offset, end),
|
|
179
|
+
totalLength: text.length, nextOffset: end < text.length ? end : null });
|
|
180
|
+
}
|
|
181
|
+
const limit = args.limit ?? 30, offset = args.offset ?? Math.max(0, events.length - limit);
|
|
182
|
+
requireThat(offset <= events.length, "原生记录分页位置超出范围。");
|
|
183
|
+
return json({ agent: view, header, cursor: observation.cursor, total: events.length, offset,
|
|
184
|
+
nextOffset: offset + limit < events.length ? offset + limit : null,
|
|
185
|
+
events: events.slice(offset, offset + limit).map(event => ({ seq: event.seq, type: event.type, time: event.time,
|
|
186
|
+
...(event.type === "user/message" ? { source: event.data.source.kind } : {}), preview: extractSessionEventText(event).slice(0, 800) })) });
|
|
187
|
+
}
|
|
188
|
+
catch (e_1) {
|
|
189
|
+
env_1.error = e_1;
|
|
190
|
+
env_1.hasError = true;
|
|
191
|
+
}
|
|
192
|
+
finally {
|
|
193
|
+
__disposeResources(env_1);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
async team(request, signal) {
|
|
197
|
+
const { workspace, input } = await this.workspace(request, signal);
|
|
198
|
+
requireThat(validTeam(input), "团队记录查询参数无效。");
|
|
199
|
+
const args = input;
|
|
200
|
+
return json({ team: workspace.teams.status(args.teamId, workspace.owner, workspace.agents.list(workspace.owner)),
|
|
201
|
+
page: workspace.teams.read(args.teamId, { kind: "user", owner: workspace.owner }, args) });
|
|
202
|
+
}
|
|
203
|
+
async history(request, signal) {
|
|
204
|
+
const current = await this.workspace(request, signal), { workspace, input } = current;
|
|
205
|
+
const result = await executeHistory(workspace.history, historyInput(input), { host: "dsh", sessionId: workspace.agent.id }, current.signal);
|
|
206
|
+
workspace.check();
|
|
207
|
+
current.signal.throwIfAborted();
|
|
208
|
+
return json(result);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
})();
|
|
212
|
+
export { PbotManagement };
|
|
213
|
+
export function registerDshManagement(ctx, workspaces) {
|
|
214
|
+
ctx.typert.register({ package: pbotReadRemote.package, face: "host", schemas: [],
|
|
215
|
+
model: { services: [], events: [], objects: [] }, invocations: pbotReadRemote.descriptors });
|
|
216
|
+
return new PbotManagement(ctx, workspaces);
|
|
217
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
2
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
3
|
+
import type { AgentOwner } from "../../model/agent.js";
|
|
4
|
+
import { DshAgents } from "../../integrations/dsh/dsh-agents.js";
|
|
5
|
+
import { AgentService } from "../../services/agents/agent-service.js";
|
|
6
|
+
import { TeamService } from "../../services/agents/team-service.js";
|
|
7
|
+
import { DshAgentRuntime } from "./agent-runtime.js";
|
|
8
|
+
import { DshHistoryWork } from "./history.js";
|
|
9
|
+
import type { HistoryService } from "../../services/history/history-service.js";
|
|
10
|
+
import { PythonEnvironmentService } from "../../services/workspace/python-environment-service.js";
|
|
11
|
+
export declare const dshDependencies: string[];
|
|
12
|
+
export declare class DshWorkspace {
|
|
13
|
+
#private;
|
|
14
|
+
readonly ctx: Context;
|
|
15
|
+
readonly root: string;
|
|
16
|
+
readonly agent: Agent;
|
|
17
|
+
readonly python: PythonEnvironmentService;
|
|
18
|
+
readonly component: AbortSignal;
|
|
19
|
+
private readonly historyWork;
|
|
20
|
+
private readonly releaseHistory;
|
|
21
|
+
readonly lifetime: AbortController;
|
|
22
|
+
readonly host: DshAgents;
|
|
23
|
+
readonly agents: AgentService;
|
|
24
|
+
readonly teams: TeamService;
|
|
25
|
+
readonly history: HistoryService;
|
|
26
|
+
readonly owner: AgentOwner;
|
|
27
|
+
constructor(ctx: Context, root: string, agent: Agent, python: PythonEnvironmentService, component: AbortSignal, historyWork: DshHistoryWork, releaseHistory: () => Promise<void>);
|
|
28
|
+
check: () => void;
|
|
29
|
+
get controlError(): string | undefined;
|
|
30
|
+
open(): Promise<void>;
|
|
31
|
+
expert(id: string): DshAgentRuntime;
|
|
32
|
+
close(): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
/** The execution component owns Python; closing one Session must not undo its activation. */
|
|
35
|
+
export declare class DshWorkspaces {
|
|
36
|
+
#private;
|
|
37
|
+
readonly ctx: Context;
|
|
38
|
+
readonly python: PythonEnvironmentService;
|
|
39
|
+
constructor(ctx: Context);
|
|
40
|
+
private history;
|
|
41
|
+
open(agent: Agent): Promise<DshWorkspace>;
|
|
42
|
+
get(agent: Agent): Promise<DshWorkspace>;
|
|
43
|
+
preparePython(): Promise<{
|
|
44
|
+
directory: string;
|
|
45
|
+
python: string;
|
|
46
|
+
}>;
|
|
47
|
+
close(): Promise<void>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { realpath } from "node:fs/promises";
|
|
2
|
+
import { dshHomePath } from "@deepseek-ai/dsh-home-paths";
|
|
3
|
+
import { DshAgents } from "../../integrations/dsh/dsh-agents.js";
|
|
4
|
+
import { dshResources, dshExpertTools } from "../../integrations/dsh/resources.js";
|
|
5
|
+
import { AgentService } from "../../services/agents/agent-service.js";
|
|
6
|
+
import { TeamService } from "../../services/agents/team-service.js";
|
|
7
|
+
import { registerDshAgentTool } from "../../tools/agents/dsh-tool.js";
|
|
8
|
+
import { registerDshTeamTool, registerDshTeamMessageTool } from "../../tools/teams/dsh-tool.js";
|
|
9
|
+
import { DshAgentRuntime } from "./agent-runtime.js";
|
|
10
|
+
import { DshAgentEvents } from "./agent-events.js";
|
|
11
|
+
import { registerDshFileEvents } from "./files.js";
|
|
12
|
+
import { DshHistoryWork, registerDshHistoryEvents } from "./history.js";
|
|
13
|
+
import { registerDshHistoryTool } from "../../tools/history/dsh-tool.js";
|
|
14
|
+
import { activatePython } from "../../integrations/python-activation.js";
|
|
15
|
+
import { PythonEnvironmentService } from "../../services/workspace/python-environment-service.js";
|
|
16
|
+
import { requireThat } from "../../common/validation.js";
|
|
17
|
+
export const dshDependencies = ["agents", "sessions", "sessionPersistence", "sessionQuery", "llm", "tools", "systemPrompt", "skills", "fs", "attachments", "workingDirectory", "approval"];
|
|
18
|
+
export class DshWorkspace {
|
|
19
|
+
ctx;
|
|
20
|
+
root;
|
|
21
|
+
agent;
|
|
22
|
+
python;
|
|
23
|
+
component;
|
|
24
|
+
historyWork;
|
|
25
|
+
releaseHistory;
|
|
26
|
+
lifetime = new AbortController();
|
|
27
|
+
host;
|
|
28
|
+
agents;
|
|
29
|
+
teams;
|
|
30
|
+
history;
|
|
31
|
+
owner;
|
|
32
|
+
#experts = new Map();
|
|
33
|
+
#scope;
|
|
34
|
+
#events;
|
|
35
|
+
#closing;
|
|
36
|
+
constructor(ctx, root, agent, python, component, historyWork, releaseHistory) {
|
|
37
|
+
this.ctx = ctx;
|
|
38
|
+
this.root = root;
|
|
39
|
+
this.agent = agent;
|
|
40
|
+
this.python = python;
|
|
41
|
+
this.component = component;
|
|
42
|
+
this.historyWork = historyWork;
|
|
43
|
+
this.releaseHistory = releaseHistory;
|
|
44
|
+
this.history = historyWork.service;
|
|
45
|
+
this.owner = { sessionId: agent.id, leaf: null, branch: [] };
|
|
46
|
+
this.host = new DshAgents(ctx, agent, {
|
|
47
|
+
setup: (d, _directory, generation) => async (agentCtx, child) => {
|
|
48
|
+
for (const key of ["noExtensions", "noPromptTemplates", "noContextFiles"])
|
|
49
|
+
requireThat(d.options[key] === undefined, "dsh 不支持宿主选项:" + key);
|
|
50
|
+
await agentCtx.plugin({ name: "pbot-expert", inject: dshDependencies, apply: async (scope) => {
|
|
51
|
+
const runtime = new DshAgentRuntime(scope, child, d, generation, this.agents.files, this.teams, { check: this.check, release: () => this.host.release(d.agentId, generation) });
|
|
52
|
+
this.#experts.set(d.agentId, runtime);
|
|
53
|
+
scope.effect(() => () => { if (this.#experts.get(d.agentId) === runtime)
|
|
54
|
+
this.#experts.delete(d.agentId); });
|
|
55
|
+
await dshResources(scope, child, root, "general-purpose", () => python.status, runtime.check);
|
|
56
|
+
const teamTool = dshExpertTools(scope, child, d.options);
|
|
57
|
+
if (teamTool)
|
|
58
|
+
registerDshTeamMessageTool(scope, child, this.teams, runtime.actor, runtime.check);
|
|
59
|
+
registerDshFileEvents(scope, child, root, true, runtime.check);
|
|
60
|
+
runtime.initialize(teamTool);
|
|
61
|
+
} });
|
|
62
|
+
return { commit: this.check };
|
|
63
|
+
},
|
|
64
|
+
ready: (child, generation) => {
|
|
65
|
+
const runtime = this.#experts.get(child.id);
|
|
66
|
+
requireThat(runtime?.generation === generation, "专家执行组件未就绪。");
|
|
67
|
+
runtime.start();
|
|
68
|
+
},
|
|
69
|
+
stopping: async (child, generation) => { const runtime = this.#experts.get(child.id); if (runtime?.generation === generation)
|
|
70
|
+
await runtime.stop(); },
|
|
71
|
+
}, this.lifetime.signal);
|
|
72
|
+
this.agents = new AgentService(root, dshHomePath("pbot", "subagents"), this.host);
|
|
73
|
+
this.teams = new TeamService(root, this.agents.files, this.agents.teamFiles);
|
|
74
|
+
}
|
|
75
|
+
check = () => { this.component.throwIfAborted(); this.lifetime.signal.throwIfAborted(); };
|
|
76
|
+
get controlError() { return this.#events?.error; }
|
|
77
|
+
async open() {
|
|
78
|
+
this.check();
|
|
79
|
+
this.#scope = await this.agent.ctx.plugin({ name: "pbot-coordinator", inject: dshDependencies, apply: async (ctx) => {
|
|
80
|
+
await dshResources(ctx, this.agent, this.root, "coordinator", () => this.python.status, this.check);
|
|
81
|
+
registerDshFileEvents(ctx, this.agent, this.root, false, this.check);
|
|
82
|
+
registerDshAgentTool(ctx, this.agent, this.agents, this.owner, this.check);
|
|
83
|
+
registerDshTeamTool(ctx, this.agent, this.teams, this.agents, this.owner, this.check);
|
|
84
|
+
registerDshTeamMessageTool(ctx, this.agent, this.teams, () => ({ kind: "coordinator", owner: this.owner }), this.check);
|
|
85
|
+
registerDshHistoryTool(ctx, this.agent, this.history, this.lifetime.signal, this.check);
|
|
86
|
+
registerDshHistoryEvents(ctx, this.agent, this.historyWork, this.check);
|
|
87
|
+
this.#events = new DshAgentEvents(ctx, this.agent, this.agents, this.teams, this.owner, this.check);
|
|
88
|
+
this.#events.start();
|
|
89
|
+
} });
|
|
90
|
+
this.check();
|
|
91
|
+
}
|
|
92
|
+
expert(id) {
|
|
93
|
+
this.check();
|
|
94
|
+
const view = this.agents.status(id, this.owner), runtime = this.#experts.get(id);
|
|
95
|
+
requireThat(view.owned, "专家不属于当前父会话。");
|
|
96
|
+
requireThat(view.alive, "专家已停止;需要明确恢复后才能对话。");
|
|
97
|
+
requireThat(view.state !== "starting", "专家尚未就绪,请等待启动或恢复完成。");
|
|
98
|
+
requireThat(runtime?.generation === view.generation, "原生专家由其他执行实例持有;当前组件不能接管对话。");
|
|
99
|
+
return runtime;
|
|
100
|
+
}
|
|
101
|
+
close() {
|
|
102
|
+
if (this.#closing)
|
|
103
|
+
return this.#closing;
|
|
104
|
+
this.lifetime.abort();
|
|
105
|
+
this.#closing = (async () => {
|
|
106
|
+
const errors = [];
|
|
107
|
+
try {
|
|
108
|
+
await this.#events?.close();
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
errors.push(error);
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
this.teams.pauseAll(this.owner, "父会话或执行组件关闭");
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
errors.push(error);
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
await this.agents.close(this.owner);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
errors.push(error);
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
await this.host.close();
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
errors.push(error);
|
|
130
|
+
}
|
|
131
|
+
this.teams.dispose();
|
|
132
|
+
try {
|
|
133
|
+
await this.#scope?.dispose();
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
errors.push(error);
|
|
137
|
+
}
|
|
138
|
+
try {
|
|
139
|
+
await this.releaseHistory();
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
errors.push(error);
|
|
143
|
+
}
|
|
144
|
+
if (errors.length)
|
|
145
|
+
throw new AggregateError(errors, "dsh 工作区关闭失败;请核对执行资源和控制记录。");
|
|
146
|
+
})();
|
|
147
|
+
return this.#closing;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/** The execution component owns Python; closing one Session must not undo its activation. */
|
|
151
|
+
export class DshWorkspaces {
|
|
152
|
+
ctx;
|
|
153
|
+
python = new PythonEnvironmentService(process.cwd());
|
|
154
|
+
#parents = new Map();
|
|
155
|
+
#parentEffects = new Map();
|
|
156
|
+
#histories = new Map();
|
|
157
|
+
#lifetime = new AbortController();
|
|
158
|
+
#restorePython;
|
|
159
|
+
#preparing;
|
|
160
|
+
#closing;
|
|
161
|
+
constructor(ctx) {
|
|
162
|
+
this.ctx = ctx;
|
|
163
|
+
}
|
|
164
|
+
async history(root) {
|
|
165
|
+
this.#lifetime.signal.throwIfAborted();
|
|
166
|
+
let entry = this.#histories.get(root);
|
|
167
|
+
if (entry && entry.users === 0) {
|
|
168
|
+
await entry.work.close();
|
|
169
|
+
this.#lifetime.signal.throwIfAborted();
|
|
170
|
+
if (this.#histories.get(root) === entry)
|
|
171
|
+
this.#histories.delete(root);
|
|
172
|
+
return this.history(root);
|
|
173
|
+
}
|
|
174
|
+
if (!entry) {
|
|
175
|
+
entry = { work: new DshHistoryWork(this.ctx, root), users: 0 };
|
|
176
|
+
this.#histories.set(root, entry);
|
|
177
|
+
}
|
|
178
|
+
const owned = entry;
|
|
179
|
+
owned.users++;
|
|
180
|
+
let released = false;
|
|
181
|
+
return { work: owned.work, release: async () => {
|
|
182
|
+
if (released)
|
|
183
|
+
return;
|
|
184
|
+
released = true;
|
|
185
|
+
if (--owned.users === 0) {
|
|
186
|
+
try {
|
|
187
|
+
await owned.work.close();
|
|
188
|
+
}
|
|
189
|
+
finally {
|
|
190
|
+
if (this.#histories.get(root) === owned)
|
|
191
|
+
this.#histories.delete(root);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
} };
|
|
195
|
+
}
|
|
196
|
+
async open(agent) {
|
|
197
|
+
this.#lifetime.signal.throwIfAborted();
|
|
198
|
+
requireThat(this.ctx.agents.roots().includes(agent) && agent.session.header.origin !== "subagent", "专家不拥有协调者管理入口。");
|
|
199
|
+
const current = this.#parents.get(agent);
|
|
200
|
+
if (current)
|
|
201
|
+
return current;
|
|
202
|
+
const opening = (async () => {
|
|
203
|
+
const root = await realpath(agent.session.header.cwd ?? process.cwd());
|
|
204
|
+
this.#lifetime.signal.throwIfAborted();
|
|
205
|
+
const history = await this.history(root);
|
|
206
|
+
let workspace;
|
|
207
|
+
try {
|
|
208
|
+
workspace = new DshWorkspace(this.ctx, root, agent, this.python, this.#lifetime.signal, history.work, history.release);
|
|
209
|
+
const owned = workspace;
|
|
210
|
+
const dispose = agent.ctx.effect(() => async () => {
|
|
211
|
+
this.#parents.delete(agent);
|
|
212
|
+
this.#parentEffects.delete(agent);
|
|
213
|
+
await owned.close();
|
|
214
|
+
});
|
|
215
|
+
this.#parentEffects.set(agent, dispose);
|
|
216
|
+
await workspace.open();
|
|
217
|
+
this.#lifetime.signal.throwIfAborted();
|
|
218
|
+
return workspace;
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
try {
|
|
222
|
+
const dispose = this.#parentEffects.get(agent);
|
|
223
|
+
if (dispose)
|
|
224
|
+
await dispose();
|
|
225
|
+
else if (workspace)
|
|
226
|
+
await workspace.close();
|
|
227
|
+
else
|
|
228
|
+
await history.release();
|
|
229
|
+
}
|
|
230
|
+
catch (cleanup) {
|
|
231
|
+
throw new AggregateError([error, cleanup], "dsh 工作区装配与清理均未完成。");
|
|
232
|
+
}
|
|
233
|
+
throw error;
|
|
234
|
+
}
|
|
235
|
+
})();
|
|
236
|
+
this.#parents.set(agent, opening);
|
|
237
|
+
try {
|
|
238
|
+
return await opening;
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
this.#parents.delete(agent);
|
|
242
|
+
throw error;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
async get(agent) {
|
|
246
|
+
this.#lifetime.signal.throwIfAborted();
|
|
247
|
+
requireThat(this.ctx.agents.get(agent.id) === agent, "父会话已关闭。");
|
|
248
|
+
const workspace = await this.open(agent);
|
|
249
|
+
workspace.check();
|
|
250
|
+
return workspace;
|
|
251
|
+
}
|
|
252
|
+
preparePython() {
|
|
253
|
+
this.#lifetime.signal.throwIfAborted();
|
|
254
|
+
if (this.#preparing)
|
|
255
|
+
return this.#preparing;
|
|
256
|
+
this.#preparing = (async () => {
|
|
257
|
+
const result = await this.python.setup(this.#lifetime.signal);
|
|
258
|
+
this.#lifetime.signal.throwIfAborted();
|
|
259
|
+
if (!this.#restorePython)
|
|
260
|
+
this.#restorePython = activatePython(result.directory);
|
|
261
|
+
return result;
|
|
262
|
+
})().finally(() => { this.#preparing = undefined; });
|
|
263
|
+
return this.#preparing;
|
|
264
|
+
}
|
|
265
|
+
close() {
|
|
266
|
+
if (this.#closing)
|
|
267
|
+
return this.#closing;
|
|
268
|
+
this.#lifetime.abort();
|
|
269
|
+
this.#closing = (async () => {
|
|
270
|
+
try {
|
|
271
|
+
const opened = await Promise.allSettled(this.#parents.values());
|
|
272
|
+
const closed = await Promise.allSettled(opened.filter(v => v.status === "fulfilled").map(v => v.value.close()));
|
|
273
|
+
const effects = await Promise.allSettled([...this.#parentEffects.values()].map(dispose => dispose()));
|
|
274
|
+
const histories = await Promise.allSettled([...this.#histories.values()].map(value => value.work.close()));
|
|
275
|
+
await this.python.close();
|
|
276
|
+
const errors = [...new Set([...closed, ...effects, ...histories].flatMap(value => value.status === "rejected" ? [value.reason] : []))];
|
|
277
|
+
if (errors.length)
|
|
278
|
+
throw new AggregateError(errors, "部分 dsh 工作区未能完成关闭。");
|
|
279
|
+
}
|
|
280
|
+
finally {
|
|
281
|
+
this.#parents.clear();
|
|
282
|
+
this.#parentEffects.clear();
|
|
283
|
+
this.#histories.clear();
|
|
284
|
+
this.#restorePython?.();
|
|
285
|
+
this.#restorePython = undefined;
|
|
286
|
+
}
|
|
287
|
+
})();
|
|
288
|
+
return this.#closing;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function agentText(agent: "coordinator" | "general-purpose", root: string): Promise<string>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { resourceRoot } from "../common/paths.js";
|
|
4
|
+
import { requireThat } from "../common/validation.js";
|
|
5
|
+
export async function agentText(agent, root) {
|
|
6
|
+
requireThat(agent === "coordinator" || agent === "general-purpose", "未知职责。");
|
|
7
|
+
let text = await readFile(join(resourceRoot, "agents", agent + ".md"), "utf8");
|
|
8
|
+
try {
|
|
9
|
+
const local = await readFile(join(root, "agents", agent + ".md"), "utf8");
|
|
10
|
+
text += "\n\n工作区职责补充:\n" + local;
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
if (error.code !== "ENOENT")
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
requireThat(text.trim(), "专家职责为空。");
|
|
17
|
+
return text;
|
|
18
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import type { Agent, AgentSetup } from "@deepseek-ai/dsh-agent";
|
|
3
|
+
import type { AgentDescriptor, AgentSessionReference } from "../../model/agent.js";
|
|
4
|
+
import type { AgentHost } from "../../services/agents/agent-service.js";
|
|
5
|
+
/** Native handles belong to the execution component, independently of browser observers. */
|
|
6
|
+
export declare class DshAgents implements AgentHost {
|
|
7
|
+
#private;
|
|
8
|
+
readonly ctx: Context;
|
|
9
|
+
readonly parent: Agent;
|
|
10
|
+
readonly composition: {
|
|
11
|
+
setup(d: AgentDescriptor, directory: string, generation: string): AgentSetup;
|
|
12
|
+
ready(agent: Agent, generation: string): void;
|
|
13
|
+
stopping(agent: Agent, generation: string): Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
readonly lifetime: AbortSignal;
|
|
16
|
+
readonly kind = "dsh";
|
|
17
|
+
constructor(ctx: Context, parent: Agent, composition: {
|
|
18
|
+
setup(d: AgentDescriptor, directory: string, generation: string): AgentSetup;
|
|
19
|
+
ready(agent: Agent, generation: string): void;
|
|
20
|
+
stopping(agent: Agent, generation: string): Promise<void>;
|
|
21
|
+
}, lifetime: AbortSignal);
|
|
22
|
+
available(): void;
|
|
23
|
+
alive(id: string): boolean;
|
|
24
|
+
private reference;
|
|
25
|
+
validateSession(d: AgentDescriptor, reference: AgentSessionReference): Promise<void>;
|
|
26
|
+
launch(d: AgentDescriptor, directory: string, generation: string, reference: AgentSessionReference, resume: boolean, signal: AbortSignal): Promise<void>;
|
|
27
|
+
release(id: string, generation: string): Promise<void>;
|
|
28
|
+
report(d: AgentDescriptor, reference: AgentSessionReference, position: string): Promise<string>;
|
|
29
|
+
close(): Promise<void>;
|
|
30
|
+
}
|