@xiangyixie/dsh-superagent 0.18.0 → 0.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +16 -10
- package/lib/doctor.js +31 -0
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -233,6 +233,7 @@ window.__ModuleLoader__.load({
|
|
|
233
233
|
.dsa-rail-count{font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary,rgb(129,133,140))}
|
|
234
234
|
.dsa-rowdot{flex:none;width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-label-caption,rgb(129,133,140))}
|
|
235
235
|
.dsa-rowdot[data-status=running]{background:var(--dsw-alias-state-success-primary,#22c55e)}
|
|
236
|
+
.dsa-rowdot[data-status=waiting]{background:var(--dsw-alias-state-warning-primary,#ffc140)}
|
|
236
237
|
.dsa-rowdot[data-status=stopped]{background:var(--dsw-alias-state-warn-primary,#f59e0b)}
|
|
237
238
|
.dsa-rail-head{display:flex;align-items:center;justify-content:space-between;gap:6px;padding:6px 8px;font-size:13px;line-height:20px;color:var(--dsw-alias-label-tertiary,rgb(129,133,140))}
|
|
238
239
|
.dsa-rail-list{display:flex;flex:1;flex-direction:column;gap:2px;min-height:0;overflow-y:auto;margin-bottom:8px}
|
|
@@ -852,16 +853,21 @@ window.__ModuleLoader__.load({
|
|
|
852
853
|
h('div', { className: 'dsa-rail-list' },
|
|
853
854
|
runs.length === 0
|
|
854
855
|
? h('div', { className: 'dsa-hint', style: { padding: '8px' } }, '超级智能体还没有调度新的会话')
|
|
855
|
-
: runs.map(run =>
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
856
|
+
: runs.map(run => {
|
|
857
|
+
// A run with an unanswered attention item is waiting on the user,
|
|
858
|
+
// not running: show that as its own amber state.
|
|
859
|
+
const waiting = Array.isArray(run.attention) && run.attention.length > 0
|
|
860
|
+
return tipped(run.goal ?? '', h('button', {
|
|
861
|
+
key: run.id,
|
|
862
|
+
type: 'button',
|
|
863
|
+
className: 'dsa-rowitem',
|
|
864
|
+
title: '查看任务详情',
|
|
865
|
+
onClick: () => props.onOpen?.(run.id),
|
|
866
|
+
},
|
|
867
|
+
h('span', { className: 'dsa-rowdot', 'data-status': waiting ? 'waiting' : run.status }),
|
|
868
|
+
h('span', { className: 'dsa-rowtitle' }, run.goal ?? '调度中的会话'),
|
|
869
|
+
h('span', { className: 'dsa-rowtime' }, waiting ? '等你决定' : run.status === 'running' ? '运行中' : run.status === 'completed' ? '完成' : '已停')), 'left', run.id)
|
|
870
|
+
})))
|
|
865
871
|
}
|
|
866
872
|
|
|
867
873
|
/** Artifacts are whatever the run report links to, same rule as the console page. */
|
package/lib/doctor.js
CHANGED
|
@@ -132,6 +132,21 @@ export function readRegisteredTools(source) {
|
|
|
132
132
|
return names
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Tools registered straight through `ctx.tools.register(defineTool(...))` carry
|
|
137
|
+
* no gate, so every host session pays for them on every request. Registrations
|
|
138
|
+
* that go through the local `registerTool` wrapper pick up the panel/worker
|
|
139
|
+
* gate; those are not counted as resident.
|
|
140
|
+
*/
|
|
141
|
+
export function readResidentTools(source) {
|
|
142
|
+
const names = []
|
|
143
|
+
for (const chunk of String(source).split(/ctx\.tools\.register\(\s*defineTool\(/).slice(1)) {
|
|
144
|
+
const match = /name:\s*['"]([^'"]+)['"]/.exec(chunk)
|
|
145
|
+
if (match) names.push(match[1])
|
|
146
|
+
}
|
|
147
|
+
return names
|
|
148
|
+
}
|
|
149
|
+
|
|
135
150
|
function parseVersion(value) {
|
|
136
151
|
const match = /^v?(\d+)\.(\d+)\.(\d+)/.exec(String(value ?? '').trim())
|
|
137
152
|
return match ? { major: Number(match[1]), minor: Number(match[2]), patch: Number(match[3]) } : null
|
|
@@ -703,6 +718,21 @@ async function checkTools(packageDir, expected, { profileName, version }) {
|
|
|
703
718
|
].join('\n'))
|
|
704
719
|
}
|
|
705
720
|
|
|
721
|
+
async function checkResidentTools(packageDir) {
|
|
722
|
+
const entry = path.join(packageDir, 'lib', 'index.js')
|
|
723
|
+
let source
|
|
724
|
+
try {
|
|
725
|
+
source = await fsp.readFile(entry, 'utf8')
|
|
726
|
+
} catch {
|
|
727
|
+
return check('resident', 'Resident tools', 'warn', ['cannot read lib/index.js; resident tool count skipped'])
|
|
728
|
+
}
|
|
729
|
+
const resident = readResidentTools(source)
|
|
730
|
+
const detail = [`resident tools: ${resident.length} (threshold 0)`]
|
|
731
|
+
if (resident.length === 0) return check('resident', 'Resident tools', 'pass', detail)
|
|
732
|
+
detail.push(`ungated: ${resident.join(', ')}`)
|
|
733
|
+
return check('resident', 'Resident tools', 'warn', detail, 'register these through registerTool so the panel/worker gate applies')
|
|
734
|
+
}
|
|
735
|
+
|
|
706
736
|
async function checkPatchFile(packageDir, pkg, { profileName }) {
|
|
707
737
|
const patchRel = pkg?.dsh?.bundle?.patch
|
|
708
738
|
if (typeof patchRel !== 'string' || !patchRel.trim()) {
|
|
@@ -853,6 +883,7 @@ export async function runDoctor(options = {}) {
|
|
|
853
883
|
checks.push(check('registry', 'Registry match', registry.status, registry.detail, registry.fix ?? null))
|
|
854
884
|
}
|
|
855
885
|
checks.push(await checkTools(targetDir, options.expectedTools ?? TOOL_NAMES, { profileName, version: targetPkg.version }))
|
|
886
|
+
checks.push(await checkResidentTools(targetDir))
|
|
856
887
|
checks.push(await checkPatchFile(targetDir, targetPkg, { profileName }))
|
|
857
888
|
if (profileDir) {
|
|
858
889
|
checks.push(await checkProfile(profileDir, profileName))
|