mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 01:53:21 +08:00
feat: execute AI Office jobs in Harness
This commit is contained in:
parent
b0606159e0
commit
3fa2cc05b2
14 changed files with 730 additions and 148 deletions
|
|
@ -106,7 +106,9 @@ export function OfficeSettingsTab({ rpcCall, initialStatus }) {
|
|||
h('div', { className: 'dof-metric' }, h('span', null, '最近心跳'), h('strong', null, health.lastHeartbeatAt ?? '尚无')),
|
||||
h('div', { className: 'dof-metric' }, h('span', null, '最近事件'), h('strong', null, health.lastEventType ?? '尚无')),
|
||||
h('div', { className: 'dof-metric' }, h('span', null, '重连次数'), h('strong', null, String(health.reconnects ?? 0))),
|
||||
h('div', { className: 'dof-metric' }, h('span', null, 'Job Offer'), h('strong', null, String(health.jobsOffered ?? 0)))) : null,
|
||||
h('div', { className: 'dof-metric' }, h('span', null, 'Job Offer'), h('strong', null, String(health.jobsOffered ?? 0))),
|
||||
h('div', { className: 'dof-metric' }, h('span', null, '运行 Job'), h('strong', null, String(health.jobs?.running ?? 0))),
|
||||
h('div', { className: 'dof-metric' }, h('span', null, '完成 Job'), h('strong', null, String(health.jobs?.completed ?? 0)))) : null,
|
||||
h('div', { className: 'dof-card' },
|
||||
h('div', { className: 'dof-cardTitle' }, h('h4', null, '设备连接'), h('span', null, 'Token 只写入本机凭据存储')),
|
||||
h('div', { className: 'dof-grid' },
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ const CSS = `
|
|||
.dof-error, .dof-notice { margin: 10px 0 0; padding: 9px 11px; border-radius: 9px; font-size: 12px; line-height: 1.5; }
|
||||
.dof-error { color: var(--dsw-alias-state-error-primary, #d54941); background: var(--dsw-alias-state-error-secondary, #fff0ef); }
|
||||
.dof-notice { color: var(--dsw-alias-label-secondary, #646a73); background: var(--dsw-alias-interactive-bg-hover, #f7f8fa); }
|
||||
.dof-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
|
||||
.dof-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
|
||||
.dof-metric { min-width: 0; padding: 9px; border-radius: 10px; background: var(--dsw-alias-interactive-bg-hover, #f7f8fa); }
|
||||
.dof-metric span { display: block; color: var(--dsw-alias-label-tertiary, #8f959e); font-size: 10px; }
|
||||
.dof-metric strong { display: block; overflow: hidden; margin-top: 4px; color: var(--dsw-alias-label-primary, #1f2329); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ const EN = Object.freeze({
|
|||
'最近心跳': 'Last heartbeat',
|
||||
'最近事件': 'Last event',
|
||||
'重连次数': 'Reconnects',
|
||||
'运行 Job': 'Running Jobs',
|
||||
'完成 Job': 'Completed Jobs',
|
||||
'尚无': 'None yet',
|
||||
'设备连接': 'Device connection',
|
||||
'Token 只写入本机凭据存储': 'Token is written only to the local credential store',
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import { join, resolve } from 'node:path';
|
|||
import { OfficeConfigStore } from '../../../../src/channels/office/config-store.mjs';
|
||||
import { OfficeController } from '../../../../src/channels/office/office-controller.mjs';
|
||||
import { OfficeRuntime } from '../../../../src/channels/office/office-runtime.mjs';
|
||||
import { HarnessClient } from '../../../../src/channels/shared/harness-client.mjs';
|
||||
import { harnessOrigin } from '../shared/production.mjs';
|
||||
|
||||
export function officePaths(config = {}) {
|
||||
const dshHome = resolve(config.dshHome ?? process.env.DSH_HOME ?? join(homedir(), '.dsh'));
|
||||
|
|
@ -15,14 +17,28 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|||
const Store = internals.ConfigStore ?? OfficeConfigStore;
|
||||
const Controller = internals.Controller ?? OfficeController;
|
||||
const Runtime = internals.Runtime ?? OfficeRuntime;
|
||||
const ResolvedHarness = internals.HarnessClient ?? HarnessClient;
|
||||
const paths = officePaths(config);
|
||||
const configStore = await new Store(paths.config).load();
|
||||
const logger = typeof ctx.logger === 'function' ? ctx.logger('dsh-im:office') : (ctx.logger ?? console);
|
||||
const harnessBaseUrl = harnessOrigin(ctx.webServer, config.harnessBaseUrl);
|
||||
const createHarness = internals.createHarness ?? (({ workspace }) => new ResolvedHarness({
|
||||
baseUrl: harnessBaseUrl,
|
||||
workspace,
|
||||
autostart: false,
|
||||
dshBin: config.dshBin ?? 'dsh',
|
||||
rpcIdPrefix: 'office',
|
||||
logPrefix: 'dsh-im:office',
|
||||
}));
|
||||
const controller = new Controller({
|
||||
credentials: ctx.credentials,
|
||||
configStore,
|
||||
logger,
|
||||
createRuntime: (options) => new Runtime({ ...options, ...(internals.transport ? { transport: internals.transport } : {}) }),
|
||||
createRuntime: (options) => new Runtime({
|
||||
...options,
|
||||
createHarness,
|
||||
...(internals.transport ? { transport: internals.transport } : {}),
|
||||
}),
|
||||
});
|
||||
await controller.initialize();
|
||||
return { controller, close: () => controller.close(), paths };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue