@morlay/dsh-job 0.0.0-stage → 0.2.0-alpha.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/LICENSE +21 -0
- package/README.md +22 -2
- package/dist/contract-BrzXpuat.mjs +7 -0
- package/dist/decorate-g56z_1VW.mjs +8 -0
- package/dist/endpoint.d.mts +2 -0
- package/dist/endpoint.mjs +1 -0
- package/dist/index-CYdG_9_f.d.mts +37 -0
- package/dist/index-Di4mD5Dj.d.mts +10 -0
- package/dist/index.d.mts +15 -0
- package/dist/index.mjs +22 -0
- package/dist/job-endpoint-BhkXyiaP.d.mts +37 -0
- package/dist/job-endpoint-DeyhPAwX.mjs +42 -0
- package/dist/job-registry.contract-DptVO838.d.mts +22 -0
- package/dist/job-registry.contract-x3Eydu18.mjs +6 -0
- package/dist/server-C4wETLar.mjs +81 -0
- package/dist/server.d.mts +2 -0
- package/dist/server.mjs +1 -0
- package/dist/ui.d.mts +40 -0
- package/dist/ui.mjs +66 -0
- package/package.json +52 -3
- package/src/contract/index.ts +4 -0
- package/src/contract/job-registry.contract.ts +35 -0
- package/src/contract/jobs.contract.ts +22 -0
- package/src/endpoint/index.ts +4 -0
- package/src/endpoint/job-endpoint.ts +91 -0
- package/src/index.ts +16 -0
- package/src/job-controller.service.ts +23 -0
- package/src/job-idle-guard.provide.ts +9 -0
- package/src/job-idle-guard.service.ts +19 -0
- package/src/job-registry.service.ts +12 -0
- package/src/server/index.ts +3 -0
- package/src/server/job-endpoint.service.ts +65 -0
- package/src/server/job.provide.ts +19 -0
- package/src/server/tool-jobs.service.ts +24 -0
- package/src/ui/index.ts +10 -0
- package/src/ui/job-endpoint.client.ts +37 -0
- package/src/ui/job-list.slots.ts +33 -0
- package/src/ui/job.provide.ts +17 -0
- package/src/ui/jobs-client.service.ts +27 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 morlay
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
后台任务注册表:长跑动作在此登记、查询与取消,工具调用之外也有统一出口。
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 用法
|
|
4
|
+
|
|
5
|
+
- 契约(`./contract`):`JobRegistry`(上游服务名 `jobs`,只活在 **Node 树**里)与浏览器侧的 `Jobs`
|
|
6
|
+
(同样叫 `jobs`,但只存在于浏览器树;两者不会出现在同一个 ctx 上)。
|
|
7
|
+
- 宿主半(`./server`):`provideJob()`——注册表行 + `job_list` / `job_output` / `job_kill` 三条工具行 +
|
|
8
|
+
`remote.job` 的宿主面(`JobEndpointDefault` 是 `./endpoint` 那份契约的实现)。
|
|
9
|
+
- 浏览器半(`./ui`):`provideJobUi()`——三行。
|
|
10
|
+
- `JobEndpointClient`:`./endpoint` 契约的客户端形态,自己 `$mount` `job` 那组 remote;
|
|
11
|
+
- `JobsClient`:`ctx.jobs` 数据面(本会话可见的 roster、按 job 的观察流、人工 kill;上游
|
|
12
|
+
`@deepseek-ai/dsh-api-job-controller/client`),注入上一行只为顺序;
|
|
13
|
+
- `JobListSlots`:会话面板里的后台任务一节(`conversation.session.panel.section` 的 `background-jobs`:状态、耗时、
|
|
14
|
+
进度、展开后的实时输出面板、两次点击的 kill;上游 `@deepseek-ai/dsh-client-ui-jobs/client`)。
|
|
15
|
+
|
|
16
|
+
**两半都要装**:只装宿主半时模型照样能起后台任务,界面上却没有入口、也没法 kill(跑着的东西看不见)。
|
|
17
|
+
|
|
18
|
+
- `provideJobIdleGuard()`:job 域忙不忙(开发态换树按它按住;开着的任务会让换树等)。
|
|
19
|
+
|
|
20
|
+
## 设计
|
|
21
|
+
|
|
22
|
+
包内子域怎么分、契约与行各放哪,见[包内子域拆分与注册抽象](../.agents/designs/20261028-包内子域拆分与注册抽象.md);
|
|
23
|
+
上游 client 半的装配口径见[上游基础装配](../.agents/designs/20261113-上游基础装配.md)。
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "./job-registry.contract-x3Eydu18.mjs";
|
|
2
|
+
import { Injectable } from "@morlay/zephyr";
|
|
3
|
+
import { t as __decorate } from "./decorate-g56z_1VW.mjs";
|
|
4
|
+
// src/contract/jobs.contract.ts
|
|
5
|
+
let Jobs = class Jobs {};
|
|
6
|
+
Jobs = __decorate([Injectable({ name: "jobs" })], Jobs);
|
|
7
|
+
export { Jobs as t };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// \0@oxc-project+runtime@0.160.0/helpers/esm/decorate.js
|
|
2
|
+
function __decorate(decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
}
|
|
8
|
+
export { __decorate as t };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as JobFollowFrame, c as JobKillValue, d as JobViewWire, i as JobEndpointStreamCovered, l as JobListFrame, n as JobEndpoint, o as JobFollowRequest, r as JobEndpointCovered, s as JobKillRequest, t as JobChunkWire, u as JobListRequest } from "./job-endpoint-BhkXyiaP.mjs";
|
|
2
|
+
export { type JobChunkWire, JobEndpoint, JobEndpointCovered, JobEndpointStreamCovered, type JobFollowFrame, type JobFollowRequest, type JobKillRequest, type JobKillValue, type JobListFrame, type JobListRequest, type JobViewWire };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as JobEndpoint } from "./job-endpoint-DeyhPAwX.mjs";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Context, OnInit } from "@morlay/zephyr";
|
|
2
|
+
import { a as JobFollowFrame, c as JobKillValue, l as JobListFrame, n as JobEndpoint, o as JobFollowRequest, s as JobKillRequest, u as JobListRequest } from "./job-endpoint-BhkXyiaP.mjs";
|
|
3
|
+
import JobController$1 from "@deepseek-ai/dsh-api-job-controller";
|
|
4
|
+
import * as ToolJobsPlugin from "@deepseek-ai/dsh-tool-jobs";
|
|
5
|
+
import { t as JobRegistry } from "./job-registry.contract-DptVO838.mjs";
|
|
6
|
+
import { SystemPrompt, ToolRegistry } from "@morlay/dsh-agent";
|
|
7
|
+
import { LocalJobRegistry } from "@deepseek-ai/dsh-jobs-local";
|
|
8
|
+
declare const JobRegistryDefault_base: import("@morlay/zephyr/compat").AdaptedClass<typeof JobRegistry, typeof LocalJobRegistry>;
|
|
9
|
+
declare class JobRegistryDefault extends JobRegistryDefault_base {
|
|
10
|
+
onInit(ctx: Context): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
declare const JobControllerRow_base: import("@morlay/zephyr/compat").AdaptedClass<import("@morlay/zephyr").TokenClass<unknown>, typeof JobController$1>;
|
|
13
|
+
/** `job` 命名空间的上游宿主服务(`api/job-controller`)。 */
|
|
14
|
+
declare class JobControllerRow extends JobControllerRow_base {
|
|
15
|
+
private readonly jobs;
|
|
16
|
+
private readonly typert;
|
|
17
|
+
onInit(ctx: Context): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/** `job` 组的宿主实现。 */
|
|
20
|
+
declare class JobEndpointDefault extends JobEndpoint implements OnInit {
|
|
21
|
+
private readonly handlers;
|
|
22
|
+
/** 上游 `JobController` 的适配行:它的发布面就是那个实例(`list` / `follow` / `kill`)。 */
|
|
23
|
+
private readonly controller;
|
|
24
|
+
onInit(): void;
|
|
25
|
+
list(request: JobListRequest, signal: AbortSignal): AsyncIterable<JobListFrame>;
|
|
26
|
+
follow(request: JobFollowRequest, signal: AbortSignal): AsyncIterable<JobFollowFrame>;
|
|
27
|
+
kill(request: JobKillRequest): Promise<JobKillValue>;
|
|
28
|
+
}
|
|
29
|
+
declare const ToolJobs_base: import("@morlay/zephyr/compat").AdaptedClass<import("@morlay/zephyr").TokenClass<unknown>, typeof ToolJobsPlugin>;
|
|
30
|
+
declare class ToolJobs extends ToolJobs_base {
|
|
31
|
+
tools: ToolRegistry & import("@morlay/zephyr").Required<ToolRegistry>;
|
|
32
|
+
jobs: JobRegistry & import("@morlay/zephyr").Required<JobRegistry>;
|
|
33
|
+
systemPrompt: SystemPrompt & import("@morlay/zephyr").Required<SystemPrompt>;
|
|
34
|
+
onInit(ctx: Context): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
declare const provideJob: (...features: import("@morlay/zephyr").ProviderFeature[]) => readonly [typeof JobRegistryDefault, typeof ToolJobs, typeof JobControllerRow, typeof JobEndpointDefault, import("@morlay/zephyr-app").RemoteDescriptorEntry];
|
|
37
|
+
export { JobRegistryDefault as a, JobControllerRow as i, ToolJobs as n, JobEndpointDefault as r, provideJob as t };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "./job-registry.contract-DptVO838.mjs";
|
|
2
|
+
import { IJobs } from "@deepseek-ai/dsh-api-job-controller/client";
|
|
3
|
+
/** `ctx.jobs`:本会话可见的后台任务与它们的观察流。 */
|
|
4
|
+
declare abstract class Jobs implements IJobs {
|
|
5
|
+
abstract readonly state: IJobs["state"];
|
|
6
|
+
abstract readonly watchRows: IJobs["watchRows"];
|
|
7
|
+
abstract readonly observe: IJobs["observe"];
|
|
8
|
+
abstract readonly kill: IJobs["kill"];
|
|
9
|
+
}
|
|
10
|
+
export { Jobs as t };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { t as Jobs } from "./index-Di4mD5Dj.mjs";
|
|
2
|
+
import "./endpoint.mjs";
|
|
3
|
+
import { a as JobFollowFrame, c as JobKillValue, d as JobViewWire, i as JobEndpointStreamCovered, l as JobListFrame, n as JobEndpoint, o as JobFollowRequest, r as JobEndpointCovered, s as JobKillRequest, t as JobChunkWire, u as JobListRequest } from "./job-endpoint-BhkXyiaP.mjs";
|
|
4
|
+
import { a as JobRegistryDefault, i as JobControllerRow, n as ToolJobs, r as JobEndpointDefault, t as provideJob } from "./index-CYdG_9_f.mjs";
|
|
5
|
+
import { IdleGuard } from "@morlay/zephyr-app";
|
|
6
|
+
import { n as JobRegistryCovered, t as JobRegistry } from "./job-registry.contract-DptVO838.mjs";
|
|
7
|
+
export declare class JobIdleGuard extends IdleGuard {
|
|
8
|
+
private readonly jobs;
|
|
9
|
+
/**
|
|
10
|
+
* @returns 所有任务都收了尾就是空闲。
|
|
11
|
+
*/
|
|
12
|
+
isIdle(): boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const provideJobIdleGuard: (...features: import("@morlay/zephyr").ProviderFeature[]) => readonly [typeof JobIdleGuard];
|
|
15
|
+
export { type JobChunkWire, JobControllerRow, JobEndpoint, JobEndpointCovered, JobEndpointDefault, JobEndpointStreamCovered, type JobFollowFrame, type JobFollowRequest, type JobKillRequest, type JobKillValue, type JobListFrame, type JobListRequest, JobRegistry, JobRegistryCovered, JobRegistryDefault, type JobViewWire, Jobs, ToolJobs, provideJob };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { t as Jobs } from "./contract-BrzXpuat.mjs";
|
|
2
|
+
import "./endpoint.mjs";
|
|
3
|
+
import { t as JobEndpoint } from "./job-endpoint-DeyhPAwX.mjs";
|
|
4
|
+
import { a as JobRegistryDefault, i as JobControllerRow, n as ToolJobs, r as JobEndpointDefault, t as provideJob } from "./server-C4wETLar.mjs";
|
|
5
|
+
import { Injectable, inject, provide } from "@morlay/zephyr";
|
|
6
|
+
import { IdleGuard } from "@morlay/zephyr-app";
|
|
7
|
+
import { t as JobRegistry } from "./job-registry.contract-x3Eydu18.mjs";
|
|
8
|
+
import { t as __decorate } from "./decorate-g56z_1VW.mjs";
|
|
9
|
+
// src/job-idle-guard.service.ts
|
|
10
|
+
let JobIdleGuard = class JobIdleGuard extends IdleGuard {
|
|
11
|
+
jobs = inject(JobRegistry);
|
|
12
|
+
/**
|
|
13
|
+
* @returns 所有任务都收了尾就是空闲。
|
|
14
|
+
*/
|
|
15
|
+
isIdle() {
|
|
16
|
+
return this.jobs.list().every((job) => job.finishedAt !== void 0);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
JobIdleGuard = __decorate([Injectable({ multi: true })], JobIdleGuard);
|
|
20
|
+
// src/job-idle-guard.provide.ts
|
|
21
|
+
const provideJobIdleGuard = provide([JobIdleGuard]);
|
|
22
|
+
export { JobControllerRow, JobEndpoint, JobEndpointDefault, JobIdleGuard, JobRegistry, JobRegistryDefault, Jobs, ToolJobs, provideJob, provideJobIdleGuard };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AssertTrue, AssertWireFace } from "@morlay/zephyr-app/client";
|
|
2
|
+
import { AsyncReturn, DropParam } from "@morlay/zephyr-app/typert";
|
|
3
|
+
import { JobController } from "@deepseek-ai/dsh-api-job-controller";
|
|
4
|
+
import { JobChunk as JobChunkWire, JobFollowFrame, JobFollowFrame as JobFollowFrame$1, JobFollowRequest, JobFollowRequest as JobFollowRequest$1, JobKillRequest, JobKillRequest as JobKillRequest$1, JobKillValue, JobKillValue as JobKillValue$1, JobListFrame, JobListFrame as JobListFrame$1, JobListRequest, JobListRequest as JobListRequest$1, JobView as JobViewWire } from "@deepseek-ai/dsh-api-job-controller/types";
|
|
5
|
+
/** `job` 组:花名册流、单任务输出流、人工取消。 */
|
|
6
|
+
declare class JobEndpoint {
|
|
7
|
+
/**
|
|
8
|
+
* 镜像一个会话能看见的任务花名册(流,整份替换)。
|
|
9
|
+
* @param _request - 目标会话。
|
|
10
|
+
* @param _signal - wire 的取消信号(流承载关闭时 abort)。
|
|
11
|
+
* @returns 逐帧的花名册。
|
|
12
|
+
*/
|
|
13
|
+
list(_request: JobListRequest$1, _signal: AbortSignal): AsyncIterable<JobListFrame$1>;
|
|
14
|
+
/**
|
|
15
|
+
* 从某个字节偏移开始观察一条任务的保留输出(流)。
|
|
16
|
+
* @param _request - 任务、会话与可选续读偏移。
|
|
17
|
+
* @param _signal - wire 的取消信号。
|
|
18
|
+
* @returns 逐帧的输出与终态。
|
|
19
|
+
*/
|
|
20
|
+
follow(_request: JobFollowRequest$1, _signal: AbortSignal): AsyncIterable<JobFollowFrame$1>;
|
|
21
|
+
/**
|
|
22
|
+
* 人工取消一条任务。
|
|
23
|
+
* @param _request - 会话与任务。
|
|
24
|
+
* @returns 注册表的受理结果。
|
|
25
|
+
*/
|
|
26
|
+
kill(_request: JobKillRequest$1): Promise<JobKillValue$1>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 覆盖守卫:契约对上**宿主类** `JobController` 的 wire 面(形参与返回**双向**,见 `AssertWireFace`)。
|
|
30
|
+
*
|
|
31
|
+
* 两条判据分开:unary(`kill`)一条;流式(`list` / `follow`)一条,**两侧各摘一次取消信号**
|
|
32
|
+
* (契约方法带 `signal` 是宿主侧取消通道,wire 上没有它)。
|
|
33
|
+
*/
|
|
34
|
+
type JobWire = AsyncReturn<DropParam<JobController, AbortSignal>>;
|
|
35
|
+
type JobEndpointCovered = AssertTrue<AssertWireFace<Pick<JobWire, "kill">, Pick<JobEndpoint, "kill">>>;
|
|
36
|
+
type JobEndpointStreamCovered = AssertTrue<AssertWireFace<Pick<JobWire, "list" | "follow">, Pick<DropParam<JobEndpoint, AbortSignal>, "list" | "follow">>>;
|
|
37
|
+
export { JobFollowFrame as a, JobKillValue as c, JobViewWire as d, JobEndpointStreamCovered as i, JobListFrame as l, JobEndpoint as n, JobFollowRequest as o, JobEndpointCovered as r, JobKillRequest as s, JobChunkWire as t, JobListRequest as u };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { RemoteGroup, RemoteMethod } from "@morlay/zephyr-app/remote";
|
|
2
|
+
import { t as __decorate } from "./decorate-g56z_1VW.mjs";
|
|
3
|
+
// src/endpoint/job-endpoint.ts
|
|
4
|
+
let JobEndpoint = class JobEndpoint {
|
|
5
|
+
/**
|
|
6
|
+
* 镜像一个会话能看见的任务花名册(流,整份替换)。
|
|
7
|
+
* @param _request - 目标会话。
|
|
8
|
+
* @param _signal - wire 的取消信号(流承载关闭时 abort)。
|
|
9
|
+
* @returns 逐帧的花名册。
|
|
10
|
+
*/
|
|
11
|
+
list(_request, _signal) {
|
|
12
|
+
throw new Error("job/list:契约类未实现(宿主侧要在子类里实现它)");
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 从某个字节偏移开始观察一条任务的保留输出(流)。
|
|
16
|
+
* @param _request - 任务、会话与可选续读偏移。
|
|
17
|
+
* @param _signal - wire 的取消信号。
|
|
18
|
+
* @returns 逐帧的输出与终态。
|
|
19
|
+
*/
|
|
20
|
+
follow(_request, _signal) {
|
|
21
|
+
throw new Error("job/follow:契约类未实现(宿主侧要在子类里实现它)");
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 人工取消一条任务。
|
|
25
|
+
* @param _request - 会话与任务。
|
|
26
|
+
* @returns 注册表的受理结果。
|
|
27
|
+
*/
|
|
28
|
+
async kill(_request) {
|
|
29
|
+
throw new Error("job/kill:契约类未实现(宿主侧要在子类里实现它)");
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
__decorate([RemoteMethod({
|
|
33
|
+
mode: "stream",
|
|
34
|
+
parameters: ["request"]
|
|
35
|
+
})], JobEndpoint.prototype, "list", null);
|
|
36
|
+
__decorate([RemoteMethod({
|
|
37
|
+
mode: "stream",
|
|
38
|
+
parameters: ["request"]
|
|
39
|
+
})], JobEndpoint.prototype, "follow", null);
|
|
40
|
+
__decorate([RemoteMethod({ parameters: ["request"] })], JobEndpoint.prototype, "kill", null);
|
|
41
|
+
JobEndpoint = __decorate([RemoteGroup({ name: "job" })], JobEndpoint);
|
|
42
|
+
export { JobEndpoint as t };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import JobRegistryService from "@deepseek-ai/dsh-jobs";
|
|
2
|
+
import { AssertCoveredStrict, AssertTrue } from "@morlay/zephyr-app/client";
|
|
3
|
+
declare abstract class JobRegistry {
|
|
4
|
+
abstract readonly list: JobRegistryService["list"];
|
|
5
|
+
abstract readonly get: JobRegistryService["get"];
|
|
6
|
+
abstract readonly start: JobRegistryService["start"];
|
|
7
|
+
abstract readonly attachController: JobRegistryService["attachController"];
|
|
8
|
+
abstract readonly events: JobRegistryService["events"];
|
|
9
|
+
abstract readonly kill: JobRegistryService["kill"];
|
|
10
|
+
abstract readonly read: JobRegistryService["read"];
|
|
11
|
+
abstract readonly readAt: JobRegistryService["readAt"];
|
|
12
|
+
abstract readonly remove: JobRegistryService["remove"];
|
|
13
|
+
abstract readonly wait: JobRegistryService["wait"];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 覆盖守卫(严格):上游 `JobRegistry` 的每个成员都要有同名、同签名的对应项。
|
|
17
|
+
*
|
|
18
|
+
* 为什么不是 `implements`:上游那份是 cordis `Service` **类**(带私有成员),`implements` 会报
|
|
19
|
+
* TS2720;也不能真 `extends`:它的构造函数会当场注册成 `jobs` 服务,契约是**抽象面**。
|
|
20
|
+
*/
|
|
21
|
+
type JobRegistryCovered = AssertTrue<AssertCoveredStrict<JobRegistryService, JobRegistry>>;
|
|
22
|
+
export { JobRegistryCovered as n, JobRegistry as t };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Injectable } from "@morlay/zephyr";
|
|
2
|
+
import { t as __decorate } from "./decorate-g56z_1VW.mjs";
|
|
3
|
+
// src/contract/job-registry.contract.ts
|
|
4
|
+
let JobRegistry = class JobRegistry {};
|
|
5
|
+
JobRegistry = __decorate([Injectable({ name: "jobs" })], JobRegistry);
|
|
6
|
+
export { JobRegistry as t };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { SessionId } from "@morlay/dsh-session/endpoint";
|
|
2
|
+
import { Injectable, inject, provide } from "@morlay/zephyr";
|
|
3
|
+
import { RemoteHandlers, Typert, remoteDescriptor } from "@morlay/zephyr-app";
|
|
4
|
+
import { RemoteGroup, registerRemoteGroup } from "@morlay/zephyr-app/remote";
|
|
5
|
+
import JobController from "@deepseek-ai/dsh-api-job-controller";
|
|
6
|
+
import { fromCordis } from "@morlay/zephyr/compat";
|
|
7
|
+
import { t as JobRegistry } from "./job-registry.contract-x3Eydu18.mjs";
|
|
8
|
+
import { t as __decorate } from "./decorate-g56z_1VW.mjs";
|
|
9
|
+
import { t as JobEndpoint } from "./job-endpoint-DeyhPAwX.mjs";
|
|
10
|
+
import * as ToolJobsPlugin from "@deepseek-ai/dsh-tool-jobs";
|
|
11
|
+
import { AgentScoped, SystemPrompt, ToolRegistry } from "@morlay/dsh-agent";
|
|
12
|
+
import { LocalJobRegistry } from "@deepseek-ai/dsh-jobs-local";
|
|
13
|
+
// src/job-registry.service.ts
|
|
14
|
+
let JobRegistryDefault = class JobRegistryDefault extends fromCordis(JobRegistry, LocalJobRegistry) {
|
|
15
|
+
async onInit(ctx) {
|
|
16
|
+
await this.mount(ctx);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
JobRegistryDefault = __decorate([Injectable()], JobRegistryDefault);
|
|
20
|
+
// src/job-controller.service.ts
|
|
21
|
+
let JobControllerRow = class JobControllerRow extends fromCordis(JobController) {
|
|
22
|
+
jobs = inject(JobRegistry);
|
|
23
|
+
typert = inject(Typert);
|
|
24
|
+
async onInit(ctx) {
|
|
25
|
+
await this.mount(ctx, void 0, {
|
|
26
|
+
jobs: this.jobs,
|
|
27
|
+
typert: this.typert
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
JobControllerRow = __decorate([Injectable()], JobControllerRow);
|
|
32
|
+
// src/server/job-endpoint.service.ts
|
|
33
|
+
let JobEndpointDefault = class JobEndpointDefault extends JobEndpoint {
|
|
34
|
+
handlers = inject(RemoteHandlers);
|
|
35
|
+
/** 上游 `JobController` 的适配行:它的发布面就是那个实例(`list` / `follow` / `kill`)。 */
|
|
36
|
+
controller = inject(JobControllerRow);
|
|
37
|
+
onInit() {
|
|
38
|
+
registerRemoteGroup(this.handlers, this);
|
|
39
|
+
}
|
|
40
|
+
list(request, signal) {
|
|
41
|
+
return this.controller.list({ sessionId: SessionId(request.sessionId) }, signal);
|
|
42
|
+
}
|
|
43
|
+
follow(request, signal) {
|
|
44
|
+
const upstream = {
|
|
45
|
+
jobId: request.jobId,
|
|
46
|
+
...request.sessionId === void 0 ? {} : { sessionId: SessionId(request.sessionId) },
|
|
47
|
+
...request.from === void 0 ? {} : { from: request.from }
|
|
48
|
+
};
|
|
49
|
+
return this.controller.follow(upstream, signal);
|
|
50
|
+
}
|
|
51
|
+
async kill(request) {
|
|
52
|
+
return this.controller.kill({
|
|
53
|
+
sessionId: SessionId(request.sessionId),
|
|
54
|
+
jobId: request.jobId
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
JobEndpointDefault = __decorate([RemoteGroup(), Injectable()], JobEndpointDefault);
|
|
59
|
+
// src/server/tool-jobs.service.ts
|
|
60
|
+
let ToolJobs = class ToolJobs extends fromCordis(ToolJobsPlugin) {
|
|
61
|
+
tools = inject(ToolRegistry);
|
|
62
|
+
jobs = inject(JobRegistry);
|
|
63
|
+
systemPrompt = inject(SystemPrompt);
|
|
64
|
+
async onInit(ctx) {
|
|
65
|
+
await this.mount(ctx, void 0, {
|
|
66
|
+
tools: this.tools,
|
|
67
|
+
jobs: this.jobs,
|
|
68
|
+
systemPrompt: this.systemPrompt
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
ToolJobs = __decorate([AgentScoped(), Injectable()], ToolJobs);
|
|
73
|
+
// src/server/job.provide.ts
|
|
74
|
+
const provideJob = provide([
|
|
75
|
+
JobRegistryDefault,
|
|
76
|
+
ToolJobs,
|
|
77
|
+
JobControllerRow,
|
|
78
|
+
JobEndpointDefault,
|
|
79
|
+
remoteDescriptor(() => import("@deepseek-ai/dsh-api-job-controller/remote"))
|
|
80
|
+
]);
|
|
81
|
+
export { JobRegistryDefault as a, JobControllerRow as i, ToolJobs as n, JobEndpointDefault as r, provideJob as t };
|
package/dist/server.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { r as JobEndpointDefault, t as provideJob } from "./server-C4wETLar.mjs";
|
package/dist/ui.d.mts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { t as Jobs } from "./index-Di4mD5Dj.mjs";
|
|
2
|
+
import { Context, OnInit, ProviderList } from "@morlay/zephyr";
|
|
3
|
+
import { Remote, RemoteTransport } from "@morlay/zephyr-app/client";
|
|
4
|
+
import { JobEndpoint } from "@morlay/dsh-job/endpoint";
|
|
5
|
+
import * as ClientJobsPlugin from "@deepseek-ai/dsh-api-job-controller/client";
|
|
6
|
+
import * as ClientUiJobs from "@deepseek-ai/dsh-client-ui-jobs/client";
|
|
7
|
+
/** `job` 组的客户端契约实例。 */
|
|
8
|
+
export declare class JobEndpointClient extends JobEndpoint implements OnInit {
|
|
9
|
+
/** `remote.job` 这一面(发布给按名字读的消费方)。 */
|
|
10
|
+
protected readonly remote: Remote & import("@morlay/zephyr").Required<Remote>;
|
|
11
|
+
/** 传输:转发走它。 */
|
|
12
|
+
protected readonly transport: RemoteTransport & import("@morlay/zephyr").Required<RemoteTransport>;
|
|
13
|
+
/**
|
|
14
|
+
* 挂上这一组的 descriptor:`remote.job` 由它发布。
|
|
15
|
+
* @param ctx - 本行 ctx:disposer 挂在它上面,卸载随行 fiber。
|
|
16
|
+
*/
|
|
17
|
+
onInit(ctx: Context): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
declare const JobsClient_base: import("@morlay/zephyr/compat").AdaptedClass<typeof Jobs, typeof ClientJobsPlugin>;
|
|
20
|
+
/** 后台任务的数据面(浏览器半)。 */
|
|
21
|
+
export declare class JobsClient extends JobsClient_base {
|
|
22
|
+
private readonly remote;
|
|
23
|
+
/** `job` 那组 descriptor 由它挂上:这条注入就是「挂载先于消费」的排序边。 */
|
|
24
|
+
private readonly endpoint;
|
|
25
|
+
onInit(ctx: Context): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
declare const JobListSlots_base: import("@morlay/zephyr/compat").AdaptedClass<import("@morlay/zephyr").TokenClass<unknown>, typeof ClientUiJobs>;
|
|
28
|
+
/** 会话头部的后台任务列表(浏览器半)。 */
|
|
29
|
+
export declare class JobListSlots extends JobListSlots_base {
|
|
30
|
+
private readonly slots;
|
|
31
|
+
private readonly locale;
|
|
32
|
+
private readonly jobs;
|
|
33
|
+
onInit(ctx: Context): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 后台任务的浏览器半清单。
|
|
37
|
+
* @returns provider 清单。
|
|
38
|
+
*/
|
|
39
|
+
export declare function provideJobUi(): ProviderList;
|
|
40
|
+
export { Jobs };
|
package/dist/ui.mjs
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { t as Jobs } from "./contract-BrzXpuat.mjs";
|
|
2
|
+
import { Injectable, inject, provide } from "@morlay/zephyr";
|
|
3
|
+
import { Locale, Remote, RemoteTransport, Slots } from "@morlay/zephyr-app/client";
|
|
4
|
+
import { RemoteClient, groupNameOf, remoteDescriptorsOf } from "@morlay/zephyr-app/remote";
|
|
5
|
+
import { JobEndpoint } from "@morlay/dsh-job/endpoint";
|
|
6
|
+
import { t as __decorate } from "./decorate-g56z_1VW.mjs";
|
|
7
|
+
import * as ClientJobsPlugin from "@deepseek-ai/dsh-api-job-controller/client";
|
|
8
|
+
import { fromCordis } from "@morlay/zephyr/compat";
|
|
9
|
+
import * as ClientUiJobs from "@deepseek-ai/dsh-client-ui-jobs/client";
|
|
10
|
+
// src/ui/job-endpoint.client.ts
|
|
11
|
+
let JobEndpointClient = class JobEndpointClient extends JobEndpoint {
|
|
12
|
+
/** `remote.job` 这一面(发布给按名字读的消费方)。 */
|
|
13
|
+
remote = inject(Remote);
|
|
14
|
+
/** 传输:转发走它。 */
|
|
15
|
+
transport = inject(RemoteTransport);
|
|
16
|
+
/**
|
|
17
|
+
* 挂上这一组的 descriptor:`remote.job` 由它发布。
|
|
18
|
+
* @param ctx - 本行 ctx:disposer 挂在它上面,卸载随行 fiber。
|
|
19
|
+
*/
|
|
20
|
+
async onInit(ctx) {
|
|
21
|
+
try {
|
|
22
|
+
const dispose = await this.remote.$mount(remoteDescriptorsOf(JobEndpoint));
|
|
23
|
+
ctx.effect(() => dispose);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
throw new Error(`挂载 remote.${groupNameOf(JobEndpoint)} 失败:${error.message}`, { cause: error });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
JobEndpointClient = __decorate([RemoteClient()], JobEndpointClient);
|
|
30
|
+
// src/ui/jobs-client.service.ts
|
|
31
|
+
let JobsClient = class JobsClient extends fromCordis(Jobs, ClientJobsPlugin) {
|
|
32
|
+
remote = inject(Remote);
|
|
33
|
+
/** `job` 那组 descriptor 由它挂上:这条注入就是「挂载先于消费」的排序边。 */
|
|
34
|
+
endpoint = inject(JobEndpointClient);
|
|
35
|
+
async onInit(ctx) {
|
|
36
|
+
await this.mount(ctx, void 0, { remote: this.remote });
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
JobsClient = __decorate([Injectable()], JobsClient);
|
|
40
|
+
// src/ui/job-list.slots.ts
|
|
41
|
+
let JobListSlots = class JobListSlots extends fromCordis(ClientUiJobs) {
|
|
42
|
+
slots = inject(Slots);
|
|
43
|
+
locale = inject(Locale);
|
|
44
|
+
jobs = inject(Jobs);
|
|
45
|
+
async onInit(ctx) {
|
|
46
|
+
await this.mount(ctx, void 0, {
|
|
47
|
+
slots: this.slots,
|
|
48
|
+
locale: this.locale,
|
|
49
|
+
jobs: this.jobs
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
JobListSlots = __decorate([Injectable()], JobListSlots);
|
|
54
|
+
// src/ui/job.provide.ts
|
|
55
|
+
/**
|
|
56
|
+
* 后台任务的浏览器半清单。
|
|
57
|
+
* @returns provider 清单。
|
|
58
|
+
*/
|
|
59
|
+
function provideJobUi() {
|
|
60
|
+
return provide([
|
|
61
|
+
JobEndpointClient,
|
|
62
|
+
JobsClient,
|
|
63
|
+
JobListSlots
|
|
64
|
+
])();
|
|
65
|
+
}
|
|
66
|
+
export { JobEndpointClient, JobListSlots, Jobs, JobsClient, provideJobUi };
|
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morlay/dsh-job",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"version": "0.2.0-alpha.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "后台任务注册表:长跑动作在此登记、查询与取消,工具调用之外也有统一出口。",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"src",
|
|
9
|
+
"!**/__tests__"
|
|
10
|
+
],
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.mts",
|
|
15
|
+
"default": "./dist/index.mjs"
|
|
16
|
+
},
|
|
17
|
+
"./endpoint": {
|
|
18
|
+
"types": "./dist/endpoint.d.mts",
|
|
19
|
+
"default": "./dist/endpoint.mjs"
|
|
20
|
+
},
|
|
21
|
+
"./server": {
|
|
22
|
+
"types": "./dist/server.d.mts",
|
|
23
|
+
"default": "./dist/server.mjs"
|
|
24
|
+
},
|
|
25
|
+
"./ui": {
|
|
26
|
+
"types": "./dist/ui.d.mts",
|
|
27
|
+
"default": "./dist/ui.mjs"
|
|
28
|
+
},
|
|
29
|
+
"./package.json": "./package.json"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@morlay/dsh-agent": "^0.2.0-alpha.0",
|
|
33
|
+
"@morlay/zephyr": "^0.2.0-alpha.0",
|
|
34
|
+
"@morlay/zephyr-app": "^0.2.0-alpha.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@morlay/dsh-session": "^0.2.0-alpha.0"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@deepseek-ai/dsh-api-job-controller": "^0.2.3-alpha.3",
|
|
41
|
+
"@deepseek-ai/dsh-client-ui-jobs": "^0.2.3-alpha.3",
|
|
42
|
+
"@deepseek-ai/dsh-jobs": "^0.2.3-alpha.3",
|
|
43
|
+
"@deepseek-ai/dsh-jobs-local": "^0.2.3-alpha.3",
|
|
44
|
+
"@deepseek-ai/dsh-tool-jobs": "^0.2.3-alpha.3"
|
|
45
|
+
},
|
|
46
|
+
"engines": {
|
|
47
|
+
"dsh": ">= 0.2.3-alpha.3 < 0.2.4"
|
|
48
|
+
},
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "https://github.com/morlay/zephyr.git",
|
|
52
|
+
"directory": "packages/agent/dsh-job"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {}
|
|
6
55
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// 后台任务契约:令牌按服务语义命名(上游注册名 `jobs`)。
|
|
2
|
+
import type JobRegistryService from "@deepseek-ai/dsh-jobs";
|
|
3
|
+
import { Injectable } from "@morlay/zephyr";
|
|
4
|
+
import type { AssertCoveredStrict, AssertTrue } from "@morlay/zephyr-app/client";
|
|
5
|
+
|
|
6
|
+
@Injectable({ name: "jobs" })
|
|
7
|
+
export abstract class JobRegistry {
|
|
8
|
+
abstract readonly list: JobRegistryService["list"];
|
|
9
|
+
|
|
10
|
+
abstract readonly get: JobRegistryService["get"];
|
|
11
|
+
|
|
12
|
+
abstract readonly start: JobRegistryService["start"];
|
|
13
|
+
|
|
14
|
+
abstract readonly attachController: JobRegistryService["attachController"];
|
|
15
|
+
|
|
16
|
+
abstract readonly events: JobRegistryService["events"];
|
|
17
|
+
|
|
18
|
+
abstract readonly kill: JobRegistryService["kill"];
|
|
19
|
+
|
|
20
|
+
abstract readonly read: JobRegistryService["read"];
|
|
21
|
+
|
|
22
|
+
abstract readonly readAt: JobRegistryService["readAt"];
|
|
23
|
+
|
|
24
|
+
abstract readonly remove: JobRegistryService["remove"];
|
|
25
|
+
|
|
26
|
+
abstract readonly wait: JobRegistryService["wait"];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 覆盖守卫(严格):上游 `JobRegistry` 的每个成员都要有同名、同签名的对应项。
|
|
31
|
+
*
|
|
32
|
+
* 为什么不是 `implements`:上游那份是 cordis `Service` **类**(带私有成员),`implements` 会报
|
|
33
|
+
* TS2720;也不能真 `extends`:它的构造函数会当场注册成 `jobs` 服务,契约是**抽象面**。
|
|
34
|
+
*/
|
|
35
|
+
export type JobRegistryCovered = AssertTrue<AssertCoveredStrict<JobRegistryService, JobRegistry>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// `ctx.jobs` 契约(浏览器侧):会话面板那份后台任务列表的数据面。
|
|
2
|
+
//
|
|
3
|
+
// 成员来自上游 `IJobs`(`dsh-api-job-controller/client` 的 `ClientJobs`):按会话的 roster 快照、
|
|
4
|
+
// 引用计数的 roster 流与单个 job 的观察流、以及人工 kill。实现是 `JobsClient`(`ui/` 里 `fromCordis`
|
|
5
|
+
// 照装上游 client 半,契约面就是它发布的服务)。契约住 `contract/` 而不是 `ui/`:UI 层只放客户端形态与组件。
|
|
6
|
+
//
|
|
7
|
+
// **与宿主侧的 `JobRegistry` 同名不同树**:那条契约的服务名也是 `jobs`,但它住在 Node 树里
|
|
8
|
+
// (注册表 + `job_list` 一族工具行);这条只存在于浏览器树,两者不会出现在同一个 ctx 上。
|
|
9
|
+
import type { IJobs } from "@deepseek-ai/dsh-api-job-controller/client";
|
|
10
|
+
import { Injectable } from "@morlay/zephyr";
|
|
11
|
+
|
|
12
|
+
/** `ctx.jobs`:本会话可见的后台任务与它们的观察流。 */
|
|
13
|
+
@Injectable({ name: "jobs" })
|
|
14
|
+
export abstract class Jobs implements IJobs {
|
|
15
|
+
abstract readonly state: IJobs["state"];
|
|
16
|
+
|
|
17
|
+
abstract readonly watchRows: IJobs["watchRows"];
|
|
18
|
+
|
|
19
|
+
abstract readonly observe: IJobs["observe"];
|
|
20
|
+
|
|
21
|
+
abstract readonly kill: IJobs["kill"];
|
|
22
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// `job` 这一组的**跨端契约**:组名、组内方法名、请求/响应形状,以及 wire 上的端点名。
|
|
2
|
+
//
|
|
3
|
+
// 两端共用同一份声明:宿主侧继承它并实现方法(`server/`);浏览器侧用 `@RemoteClient()` 生成转发(当前没有远端端点消费它)。
|
|
4
|
+
// **只在这里声明形状**:不 import 任何 `@deepseek-ai/*`(那是宿主半的实现依赖,浏览器侧会把宿主拖进打包图)。
|
|
5
|
+
// 形状照上游 `api/job-controller/src/types.ts` 抄(那份 wire 类型本身就是 client-safe 的)。
|
|
6
|
+
//
|
|
7
|
+
// **它不继承 `RemoteClientBase`**:那个基类带 `inject(Remote)` 字段,而 `Remote` 只有浏览器侧有;
|
|
8
|
+
// 契约被两端共用,继承它会让宿主装配去解析一个不存在的服务。
|
|
9
|
+
import { RemoteGroup, RemoteMethod } from "@morlay/zephyr-app/remote";
|
|
10
|
+
import type { AssertTrue, AssertWireFace } from "@morlay/zephyr-app/client";
|
|
11
|
+
import type { AsyncReturn, DropParam } from "@morlay/zephyr-app/typert";
|
|
12
|
+
import type { JobController as JobControllerHost } from "@deepseek-ai/dsh-api-job-controller";
|
|
13
|
+
|
|
14
|
+
/** 组名(上游 descriptor:`namespace: 'job'`)。 */
|
|
15
|
+
|
|
16
|
+
/** wire 上的端点名(上游 descriptor 的 `namespace/method`)。 */
|
|
17
|
+
|
|
18
|
+
import type {
|
|
19
|
+
JobFollowFrame,
|
|
20
|
+
JobFollowRequest,
|
|
21
|
+
JobKillRequest,
|
|
22
|
+
JobKillValue,
|
|
23
|
+
JobListFrame,
|
|
24
|
+
JobListRequest,
|
|
25
|
+
} from "@deepseek-ai/dsh-api-job-controller/types";
|
|
26
|
+
// 类型**全部取上游**(`@deepseek-ai/dsh-api-job-controller/types`,wire 安全的 view 类型由它转出):
|
|
27
|
+
// 手抄过一次(`JobViewWire` / `JobChunkWire` / 四个帧),只会多一份会漂的声明。
|
|
28
|
+
export type {
|
|
29
|
+
JobChunk as JobChunkWire,
|
|
30
|
+
JobFollowFrame,
|
|
31
|
+
JobFollowRequest,
|
|
32
|
+
JobKillRequest,
|
|
33
|
+
JobKillValue,
|
|
34
|
+
JobListFrame,
|
|
35
|
+
JobListRequest,
|
|
36
|
+
JobView as JobViewWire,
|
|
37
|
+
} from "@deepseek-ai/dsh-api-job-controller/types";
|
|
38
|
+
|
|
39
|
+
/** `job` 组:花名册流、单任务输出流、人工取消。 */
|
|
40
|
+
@RemoteGroup({ name: "job" })
|
|
41
|
+
export class JobEndpoint {
|
|
42
|
+
/**
|
|
43
|
+
* 镜像一个会话能看见的任务花名册(流,整份替换)。
|
|
44
|
+
* @param _request - 目标会话。
|
|
45
|
+
* @param _signal - wire 的取消信号(流承载关闭时 abort)。
|
|
46
|
+
* @returns 逐帧的花名册。
|
|
47
|
+
*/
|
|
48
|
+
@RemoteMethod({ mode: "stream", parameters: ["request"] })
|
|
49
|
+
list(_request: JobListRequest, _signal: AbortSignal): AsyncIterable<JobListFrame> {
|
|
50
|
+
throw new Error("job/list:契约类未实现(宿主侧要在子类里实现它)");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 从某个字节偏移开始观察一条任务的保留输出(流)。
|
|
55
|
+
* @param _request - 任务、会话与可选续读偏移。
|
|
56
|
+
* @param _signal - wire 的取消信号。
|
|
57
|
+
* @returns 逐帧的输出与终态。
|
|
58
|
+
*/
|
|
59
|
+
@RemoteMethod({ mode: "stream", parameters: ["request"] })
|
|
60
|
+
follow(_request: JobFollowRequest, _signal: AbortSignal): AsyncIterable<JobFollowFrame> {
|
|
61
|
+
throw new Error("job/follow:契约类未实现(宿主侧要在子类里实现它)");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 人工取消一条任务。
|
|
66
|
+
* @param _request - 会话与任务。
|
|
67
|
+
* @returns 注册表的受理结果。
|
|
68
|
+
*/
|
|
69
|
+
@RemoteMethod({ parameters: ["request"] })
|
|
70
|
+
async kill(_request: JobKillRequest): Promise<JobKillValue> {
|
|
71
|
+
throw new Error("job/kill:契约类未实现(宿主侧要在子类里实现它)");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 覆盖守卫:契约对上**宿主类** `JobController` 的 wire 面(形参与返回**双向**,见 `AssertWireFace`)。
|
|
76
|
+
*
|
|
77
|
+
* 两条判据分开:unary(`kill`)一条;流式(`list` / `follow`)一条,**两侧各摘一次取消信号**
|
|
78
|
+
* (契约方法带 `signal` 是宿主侧取消通道,wire 上没有它)。
|
|
79
|
+
*/
|
|
80
|
+
type JobWire = AsyncReturn<DropParam<JobControllerHost, AbortSignal>>;
|
|
81
|
+
|
|
82
|
+
export type JobEndpointCovered = AssertTrue<
|
|
83
|
+
AssertWireFace<Pick<JobWire, "kill">, Pick<JobEndpoint, "kill">>
|
|
84
|
+
>;
|
|
85
|
+
|
|
86
|
+
export type JobEndpointStreamCovered = AssertTrue<
|
|
87
|
+
AssertWireFace<
|
|
88
|
+
Pick<JobWire, "list" | "follow">,
|
|
89
|
+
Pick<DropParam<JobEndpoint, AbortSignal>, "list" | "follow">
|
|
90
|
+
>
|
|
91
|
+
>;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// job 域的包根:契约 + 后台任务注册表行 + 装配模块(聚合 `./contract`)。
|
|
2
|
+
export * from "./contract/index.ts";
|
|
3
|
+
export * from "./endpoint/index.ts";
|
|
4
|
+
export * from "./job-registry.service.ts";
|
|
5
|
+
export * from "./job-controller.service.ts";
|
|
6
|
+
export * from "./server/index.ts";
|
|
7
|
+
export * from "./server/tool-jobs.service.ts";
|
|
8
|
+
export { provideJobIdleGuard } from "./job-idle-guard.provide.ts";
|
|
9
|
+
export { JobIdleGuard } from "./job-idle-guard.service.ts";
|
|
10
|
+
|
|
11
|
+
// 与本包契约同名的上游符号:显式导出本包的,覆盖上游那份(TS 显式优先,运行时也只出我们的契约)。
|
|
12
|
+
export { JobRegistry } from "./contract/job-registry.contract.ts";
|
|
13
|
+
|
|
14
|
+
// 上游 `@deepseek-ai/dsh-jobs` **一个符号都不透传**:本包的 `JobRegistry` 是自己的契约(`./contract`),
|
|
15
|
+
// 远程面(组契约 / 端点名 / 请求响应形状)在 `./endpoint`。上游独有的 `JobId` 品牌本仓没有消费方——
|
|
16
|
+
// 要用的人直接引上游包,别从门面上透传。
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// 上游 `JobController` 的适配行:只负责把它装起来并把依赖交进去(`static inject = ['jobs','typert']`)。
|
|
2
|
+
//
|
|
3
|
+
// 为什么单独一行、而不是让 `JobEndpointDefault` 直接 `fromCordis`:契约类的组名与方法元数据要走
|
|
4
|
+
// **类的原型链**(`registerRemoteGroup` 沿链收集),所以宿主实现必须 `extends JobEndpoint`;
|
|
5
|
+
// 而 `fromCordis(...)` 也是继承。两者不能同时继承,于是拆成「适配行(提供上游实例)」+
|
|
6
|
+
// 「端点行(继承契约、注入适配行)」,元数据仍然只有契约一个 home。
|
|
7
|
+
import JobController from "@deepseek-ai/dsh-api-job-controller";
|
|
8
|
+
import { inject, Injectable, type Context } from "@morlay/zephyr";
|
|
9
|
+
import { fromCordis } from "@morlay/zephyr/compat";
|
|
10
|
+
import { Typert } from "@morlay/zephyr-app";
|
|
11
|
+
import { JobRegistry } from "./contract/job-registry.contract.ts";
|
|
12
|
+
|
|
13
|
+
/** `job` 命名空间的上游宿主服务(`api/job-controller`)。 */
|
|
14
|
+
@Injectable()
|
|
15
|
+
export class JobControllerRow extends fromCordis(JobController) {
|
|
16
|
+
private readonly jobs = inject(JobRegistry);
|
|
17
|
+
|
|
18
|
+
private readonly typert = inject(Typert);
|
|
19
|
+
|
|
20
|
+
override async onInit(ctx: Context): Promise<void> {
|
|
21
|
+
await this.mount(ctx, undefined, { jobs: this.jobs, typert: this.typert });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// 「job 域忙不忙」的装配条目(开发态换树用:`IdleGuard` 多值令牌)。
|
|
2
|
+
//
|
|
3
|
+
// 为什么不并进 `provideJob()`:那个清单住在 `src/server/` 子入口面里,面纪律不许它跨面相对导入
|
|
4
|
+
// (`../job-idle-guard.service.ts` 会让「面」退化成目录结构)。这条实现只服务开发态换树,
|
|
5
|
+
// 装不装都不影响任务本身,所以单开一个 `provideXxx()`,装配面按需要叠上去。
|
|
6
|
+
import { provide } from "@morlay/zephyr";
|
|
7
|
+
import { JobIdleGuard } from "./job-idle-guard.service.ts";
|
|
8
|
+
|
|
9
|
+
export const provideJobIdleGuard = provide([JobIdleGuard]);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// 「job 域忙不忙」:有任一后台任务还没收尾就是忙。
|
|
2
|
+
//
|
|
3
|
+
// 那些任务的输出管道挂在被换掉的行上:换树之后它们还在写,读的人拿到的却是新树里的另一个注册表。
|
|
4
|
+
// 判据用 `finishedAt`——它缺失就是还活着(上游的列表本身就按这个字段表达生命周期)。
|
|
5
|
+
import { Injectable, inject } from "@morlay/zephyr";
|
|
6
|
+
import { IdleGuard } from "@morlay/zephyr-app";
|
|
7
|
+
import { JobRegistry } from "./contract/job-registry.contract.ts";
|
|
8
|
+
|
|
9
|
+
@Injectable({ multi: true })
|
|
10
|
+
export class JobIdleGuard extends IdleGuard {
|
|
11
|
+
private readonly jobs = inject(JobRegistry);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @returns 所有任务都收了尾就是空闲。
|
|
15
|
+
*/
|
|
16
|
+
isIdle(): boolean {
|
|
17
|
+
return this.jobs.list().every((job) => job.finishedAt !== undefined);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// 后台任务注册表:上游 `LocalJobRegistry` 经 `fromCordis` 接管。
|
|
2
|
+
import { LocalJobRegistry } from "@deepseek-ai/dsh-jobs-local";
|
|
3
|
+
import { Injectable, type Context } from "@morlay/zephyr";
|
|
4
|
+
import { fromCordis } from "@morlay/zephyr/compat";
|
|
5
|
+
import { JobRegistry } from "./contract/job-registry.contract.ts";
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class JobRegistryDefault extends fromCordis(JobRegistry, LocalJobRegistry) {
|
|
9
|
+
override async onInit(ctx: Context): Promise<void> {
|
|
10
|
+
await this.mount(ctx);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// `job` 这一组的**宿主实现**:继承 `endpoint/` 的契约类,转发到上游 `JobController`
|
|
2
|
+
// (`list` / `follow` 是流、`kill` 是 unary)。
|
|
3
|
+
//
|
|
4
|
+
// 组名从契约类继承(`@RemoteGroup()` 不写名字),端点名只有一个 home:`endpoint/job-endpoint.ts`。
|
|
5
|
+
// 上游实例由 `JobControllerRow`(适配行)提供:`fromCordis(...)` 与 `extends JobEndpoint` 都是继承,
|
|
6
|
+
// 只能二选一,所以拆成两行(见那一行的注释)。
|
|
7
|
+
import type {
|
|
8
|
+
JobFollowRequest as UpstreamFollowRequest,
|
|
9
|
+
JobKillRequest as UpstreamKillRequest,
|
|
10
|
+
JobListRequest as UpstreamListRequest,
|
|
11
|
+
} from "@deepseek-ai/dsh-api-job-controller";
|
|
12
|
+
import { SessionId } from "@morlay/dsh-session/endpoint";
|
|
13
|
+
import { inject, Injectable, type OnInit } from "@morlay/zephyr";
|
|
14
|
+
import { RemoteHandlers } from "@morlay/zephyr-app";
|
|
15
|
+
import { RemoteGroup, registerRemoteGroup } from "@morlay/zephyr-app/remote";
|
|
16
|
+
import { JobControllerRow } from "../job-controller.service.ts";
|
|
17
|
+
import {
|
|
18
|
+
JobEndpoint,
|
|
19
|
+
type JobFollowFrame,
|
|
20
|
+
type JobFollowRequest,
|
|
21
|
+
type JobKillRequest,
|
|
22
|
+
type JobKillValue,
|
|
23
|
+
type JobListFrame,
|
|
24
|
+
type JobListRequest,
|
|
25
|
+
} from "../endpoint/job-endpoint.ts";
|
|
26
|
+
|
|
27
|
+
/** `job` 组的宿主实现。 */
|
|
28
|
+
@RemoteGroup()
|
|
29
|
+
@Injectable()
|
|
30
|
+
export class JobEndpointDefault extends JobEndpoint implements OnInit {
|
|
31
|
+
private readonly handlers = inject(RemoteHandlers);
|
|
32
|
+
|
|
33
|
+
/** 上游 `JobController` 的适配行:它的发布面就是那个实例(`list` / `follow` / `kill`)。 */
|
|
34
|
+
private readonly controller = inject(JobControllerRow);
|
|
35
|
+
|
|
36
|
+
onInit(): void {
|
|
37
|
+
registerRemoteGroup(this.handlers, this);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
override list(request: JobListRequest, signal: AbortSignal): AsyncIterable<JobListFrame> {
|
|
41
|
+
// wire 上是裸字符串,上游要品牌会话身份:在边界铸一次。
|
|
42
|
+
return this.controller.list(
|
|
43
|
+
{ sessionId: SessionId(request.sessionId) } as UpstreamListRequest,
|
|
44
|
+
signal,
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
override follow(request: JobFollowRequest, signal: AbortSignal): AsyncIterable<JobFollowFrame> {
|
|
49
|
+
const upstream = {
|
|
50
|
+
jobId: request.jobId,
|
|
51
|
+
...(request.sessionId === undefined ? {} : { sessionId: SessionId(request.sessionId) }),
|
|
52
|
+
...(request.from === undefined ? {} : { from: request.from }),
|
|
53
|
+
} as UpstreamFollowRequest;
|
|
54
|
+
return this.controller.follow(upstream, signal);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 回**裸值**:`RemoteResult` 由桥(`RemoteHandlersRpcBridge`)与客户端面(`faceOf`)各包一层,
|
|
58
|
+
// 宿主再包就是双包(消费方读 `value` 会拿到 `{ok, value}`)。失败是抛异常。
|
|
59
|
+
override async kill(request: JobKillRequest): Promise<JobKillValue> {
|
|
60
|
+
return this.controller.kill({
|
|
61
|
+
sessionId: SessionId(request.sessionId),
|
|
62
|
+
jobId: request.jobId,
|
|
63
|
+
} as UpstreamKillRequest);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { provide } from "@morlay/zephyr";
|
|
2
|
+
import { remoteDescriptor } from "@morlay/zephyr-app";
|
|
3
|
+
import { JobControllerRow } from "../job-controller.service.ts";
|
|
4
|
+
import { JobEndpointDefault } from "./job-endpoint.service.ts";
|
|
5
|
+
import { ToolJobs } from "./tool-jobs.service.ts";
|
|
6
|
+
import { JobRegistryDefault } from "../job-registry.service.ts";
|
|
7
|
+
|
|
8
|
+
// 注册表 + 它的工具行(`job_list` / `job_output` / `job_kill`)+ `remote.job` 的宿主面。
|
|
9
|
+
//
|
|
10
|
+
// 装配位置**这一票不动**(注册表仍在应用根):它内部按 `scopeOf(ctx)` 分层。按 scope 装配要连着
|
|
11
|
+
// 消费方(`ToolJobs` / `JobControllerRow` / `JobIdleGuard`)一起量,见设计记录的「迁移面」。
|
|
12
|
+
export const provideJob = provide([
|
|
13
|
+
JobRegistryDefault,
|
|
14
|
+
ToolJobs,
|
|
15
|
+
// 上游 `JobController` 的适配行 + 继承 `endpoint/` 契约的端点行。
|
|
16
|
+
JobControllerRow,
|
|
17
|
+
JobEndpointDefault,
|
|
18
|
+
remoteDescriptor(() => import("@deepseek-ai/dsh-api-job-controller/remote")),
|
|
19
|
+
]);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// ToolJobs(工具/策略实现行)。
|
|
2
|
+
import { Injectable, inject, type Context } from "@morlay/zephyr";
|
|
3
|
+
import { fromCordis } from "@morlay/zephyr/compat";
|
|
4
|
+
import * as ToolJobsPlugin from "@deepseek-ai/dsh-tool-jobs";
|
|
5
|
+
import { JobRegistry } from "../contract/job-registry.contract.ts";
|
|
6
|
+
import { AgentScoped, ToolRegistry, SystemPrompt as SystemPromptContract } from "@morlay/dsh-agent";
|
|
7
|
+
|
|
8
|
+
@AgentScoped()
|
|
9
|
+
@Injectable()
|
|
10
|
+
export class ToolJobs extends fromCordis(ToolJobsPlugin) {
|
|
11
|
+
tools = inject(ToolRegistry);
|
|
12
|
+
|
|
13
|
+
jobs = inject(JobRegistry);
|
|
14
|
+
|
|
15
|
+
systemPrompt = inject(SystemPromptContract);
|
|
16
|
+
|
|
17
|
+
override async onInit(ctx: Context): Promise<void> {
|
|
18
|
+
await this.mount(ctx, undefined, {
|
|
19
|
+
tools: this.tools,
|
|
20
|
+
jobs: this.jobs,
|
|
21
|
+
systemPrompt: this.systemPrompt,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
package/src/ui/index.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// job 域的**浏览器半**(`@morlay/dsh-job/ui`):后台任务的数据面与会话头部的任务列表。
|
|
2
|
+
//
|
|
3
|
+
// 宿主半(注册表 + `job_list` 一族工具行 + `remote.job` 的宿主面)在 `./server`;这一面只服务浏览器树,
|
|
4
|
+
// 上游对应 `@deepseek-ai/dsh-api-job-controller/client` 与 `@deepseek-ai/dsh-client-ui-jobs/client`。
|
|
5
|
+
// `ctx.jobs` 契约在 `./contract`(`@Injectable` 的服务面,不放 UI 层)。
|
|
6
|
+
export { Jobs } from "../contract/index.ts";
|
|
7
|
+
export { JobEndpointClient } from "./job-endpoint.client.ts";
|
|
8
|
+
export { JobsClient } from "./jobs-client.service.ts";
|
|
9
|
+
export { JobListSlots } from "./job-list.slots.ts";
|
|
10
|
+
export { provideJobUi } from "./job.provide.ts";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// `JobEndpoint` 的**客户端形态**:只消费、不实现。
|
|
2
|
+
//
|
|
3
|
+
// 挂载也归它自己(`onInit` 里 `$mount(remoteDescriptorsOf(JobEndpoint))`):`remote.job` 这个名字要发布出去,
|
|
4
|
+
// 上游 `jobs-client` 行的 `inject` 里就写着它(删掉立刻报「既没交 deps、也不在 store 里的依赖:remote.job」)。
|
|
5
|
+
// 描述符从本包的 `@RemoteGroup` 契约编译(与宿主侧 `registerRemoteGroup` 同一份声明),不 `$mount`
|
|
6
|
+
// 上游的 `TYPERT_REMOTE`(那是上游控制器的声明)。
|
|
7
|
+
//
|
|
8
|
+
// 转发走 `transport`(我们的组不经过上游 `remote` 的注册表;见 `remote-on-host` 判据)。
|
|
9
|
+
import { inject, type Context, type OnInit } from "@morlay/zephyr";
|
|
10
|
+
import { Remote, RemoteTransport } from "@morlay/zephyr-app/client";
|
|
11
|
+
import { RemoteClient, groupNameOf, remoteDescriptorsOf } from "@morlay/zephyr-app/remote";
|
|
12
|
+
import { JobEndpoint } from "@morlay/dsh-job/endpoint";
|
|
13
|
+
|
|
14
|
+
/** `job` 组的客户端契约实例。 */
|
|
15
|
+
@RemoteClient()
|
|
16
|
+
export class JobEndpointClient extends JobEndpoint implements OnInit {
|
|
17
|
+
/** `remote.job` 这一面(发布给按名字读的消费方)。 */
|
|
18
|
+
protected readonly remote = inject(Remote);
|
|
19
|
+
|
|
20
|
+
/** 传输:转发走它。 */
|
|
21
|
+
protected readonly transport = inject(RemoteTransport);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 挂上这一组的 descriptor:`remote.job` 由它发布。
|
|
25
|
+
* @param ctx - 本行 ctx:disposer 挂在它上面,卸载随行 fiber。
|
|
26
|
+
*/
|
|
27
|
+
async onInit(ctx: Context): Promise<void> {
|
|
28
|
+
try {
|
|
29
|
+
const dispose = await this.remote.$mount(remoteDescriptorsOf(JobEndpoint));
|
|
30
|
+
ctx.effect(() => dispose);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
throw new Error(`挂载 remote.${groupNameOf(JobEndpoint)} 失败:${(error as Error).message}`, {
|
|
33
|
+
cause: error,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// 会话面板里的「后台任务」一节:上游 `dsh-client-ui-jobs/client` 的 `apply` 经 `fromCordis` 照装。
|
|
2
|
+
//
|
|
3
|
+
// 它注册三件东西:`job` 那份字典、`conversation.session.panel.section` 下 `id: 'background-jobs'` 的一节
|
|
4
|
+
// (本会话的 job 行:状态、耗时、进度;展开后的实时输出 `job.follow` 流;两次点击的人工 kill),
|
|
5
|
+
// 以及 `conversation.session.panel.indicator` 下 `id: 'background-jobs.running'` 的运行中指示点。
|
|
6
|
+
// (0.2.2 的头部动作位 `conversation.session.header.actions` 在 0.2.3 已不再注册。)
|
|
7
|
+
// **不重写组件**:上游那份照用,它的 `inject` 面(`hooks.jobs` / `watchRows` / `observe` / `killJob`)
|
|
8
|
+
// 由渲染器按声明绑成 `useJobs`。
|
|
9
|
+
//
|
|
10
|
+
// 它按名字读 `jobs` / `slots` / `locale`,所以装配上必须排在 `JobsClient` 之后——`inject(Jobs)` 就是这条边。
|
|
11
|
+
import * as ClientUiJobs from "@deepseek-ai/dsh-client-ui-jobs/client";
|
|
12
|
+
import { inject, Injectable, type Context } from "@morlay/zephyr";
|
|
13
|
+
import { fromCordis } from "@morlay/zephyr/compat";
|
|
14
|
+
import { Locale, Slots } from "@morlay/zephyr-app/client";
|
|
15
|
+
import { Jobs } from "../contract/index.ts";
|
|
16
|
+
|
|
17
|
+
/** 会话头部的后台任务列表(浏览器半)。 */
|
|
18
|
+
@Injectable()
|
|
19
|
+
export class JobListSlots extends fromCordis(ClientUiJobs) {
|
|
20
|
+
private readonly slots = inject(Slots);
|
|
21
|
+
|
|
22
|
+
private readonly locale = inject(Locale);
|
|
23
|
+
|
|
24
|
+
private readonly jobs = inject(Jobs);
|
|
25
|
+
|
|
26
|
+
override async onInit(ctx: Context): Promise<void> {
|
|
27
|
+
await this.mount(ctx, undefined, {
|
|
28
|
+
slots: this.slots,
|
|
29
|
+
locale: this.locale,
|
|
30
|
+
jobs: this.jobs,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// job 域的**浏览器半装配**:`job` 那组 remote 的客户端形态 + 后台任务的数据面(`jobs`)+ 任务列表。
|
|
2
|
+
//
|
|
3
|
+
// 三行都落在会话界面上(面板一节由上游 `ui-session-panel` 声明),装配面把它排在
|
|
4
|
+
// `provideConversationUi()` 之后;彼此之间是 `inject` 声明的边,由拓扑排序保证顺序:
|
|
5
|
+
// `JobEndpointClient`(挂 `job` 那组 descriptor)→ `JobsClient`(消费它)→ `JobListSlots`(读 `jobs`)。
|
|
6
|
+
import { provide, type ProviderList } from "@morlay/zephyr";
|
|
7
|
+
import { JobEndpointClient } from "./job-endpoint.client.ts";
|
|
8
|
+
import { JobsClient } from "./jobs-client.service.ts";
|
|
9
|
+
import { JobListSlots } from "./job-list.slots.ts";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 后台任务的浏览器半清单。
|
|
13
|
+
* @returns provider 清单。
|
|
14
|
+
*/
|
|
15
|
+
export function provideJobUi(): ProviderList {
|
|
16
|
+
return provide([JobEndpointClient, JobsClient, JobListSlots])();
|
|
17
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// `ctx.jobs` 的实现(浏览器侧):上游 `dsh-api-job-controller/client` 的 `apply` 经 `fromCordis` 照装。
|
|
2
|
+
//
|
|
3
|
+
// 上游那一行只做一件事——`new ClientJobs(ctx, { $stream, job }, model)`:把 `job` 那组 remote 的
|
|
4
|
+
// roster / follow / kill 拼成**引用计数**的流(同一会话两个看客共用一条 roster 流,最后一个看客走时收回)。
|
|
5
|
+
// 组件不碰传输,只读 `state`。
|
|
6
|
+
//
|
|
7
|
+
// `job` 那组 remote 的挂载不在这里:那是 `JobEndpointClient` 自己的 `onInit`。本行注入它只为**顺序**
|
|
8
|
+
// (上游 `apply` 里 `const { job } = remote` 是属性读,挂上之前读到的是空)。
|
|
9
|
+
import * as ClientJobsPlugin from "@deepseek-ai/dsh-api-job-controller/client";
|
|
10
|
+
import { inject, Injectable, type Context } from "@morlay/zephyr";
|
|
11
|
+
import { fromCordis } from "@morlay/zephyr/compat";
|
|
12
|
+
import { Remote } from "@morlay/zephyr-app/client";
|
|
13
|
+
import { Jobs } from "../contract/index.ts";
|
|
14
|
+
import { JobEndpointClient } from "./job-endpoint.client.ts";
|
|
15
|
+
|
|
16
|
+
/** 后台任务的数据面(浏览器半)。 */
|
|
17
|
+
@Injectable()
|
|
18
|
+
export class JobsClient extends fromCordis(Jobs, ClientJobsPlugin) {
|
|
19
|
+
private readonly remote = inject(Remote);
|
|
20
|
+
|
|
21
|
+
/** `job` 那组 descriptor 由它挂上:这条注入就是「挂载先于消费」的排序边。 */
|
|
22
|
+
private readonly endpoint = inject(JobEndpointClient);
|
|
23
|
+
|
|
24
|
+
override async onInit(ctx: Context): Promise<void> {
|
|
25
|
+
await this.mount(ctx, undefined, { remote: this.remote });
|
|
26
|
+
}
|
|
27
|
+
}
|