@helixlife-ai/xiantao 0.1.19 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -1
- package/dist/base-command.js +1 -103
- package/dist/commands/auth/login.js +2 -76
- package/dist/commands/auth/logout.js +1 -20
- package/dist/commands/auth/status.js +2 -60
- package/dist/commands/history/delete.js +1 -38
- package/dist/commands/history/download.js +5 -149
- package/dist/commands/history/list.js +3 -72
- package/dist/commands/history/rename.js +1 -45
- package/dist/commands/login.js +1 -3
- package/dist/commands/logout.js +1 -3
- package/dist/commands/plot/download.js +1 -31
- package/dist/commands/plot/fetch-all.js +1 -47
- package/dist/commands/plot/login.js +2 -76
- package/dist/commands/plot/menu.js +1 -37
- package/dist/commands/plot/menus-raw.js +1 -31
- package/dist/commands/plot/menus.js +2 -47
- package/dist/commands/plot/resolve.js +1 -48
- package/dist/commands/plot/run.js +5 -803
- package/dist/commands/status.js +1 -3
- package/dist/commands/tool/cloud.js +1 -0
- package/dist/commands/tool/download.js +1 -3
- package/dist/commands/tool/exec.js +1 -96
- package/dist/commands/tool/fetch-all.js +1 -3
- package/dist/commands/tool/inspect.js +3 -180
- package/dist/commands/tool/login.js +1 -3
- package/dist/commands/tool/menu.js +1 -3
- package/dist/commands/tool/menus-raw.js +1 -3
- package/dist/commands/tool/menus.js +1 -3
- package/dist/commands/tool/prepare.js +1 -110
- package/dist/commands/tool/resolve.js +1 -3
- package/dist/commands/tool/run.js +1 -3
- package/dist/commands/tool/search.js +2 -53
- package/dist/index.js +0 -1
- package/dist/lib/auth.js +1 -90
- package/dist/lib/constants.js +1 -12
- package/dist/lib/download.js +1 -32
- package/dist/lib/envelope.js +1 -70
- package/dist/lib/errors.js +1 -42
- package/dist/lib/flags.js +1 -11
- package/dist/lib/history.js +1 -200
- package/dist/lib/http.js +1 -41
- package/dist/lib/json.js +1 -20
- package/dist/lib/login-flow.js +1 -10
- package/dist/lib/open-url.js +1 -25
- package/dist/lib/plot-interactive.js +39 -631
- package/dist/lib/plot-options.js +1 -84
- package/dist/lib/plot-schema.js +1 -17
- package/dist/lib/plot.js +1 -144
- package/dist/lib/storage.js +2 -150
- package/dist/lib/tool-inputs.js +1 -51
- package/dist/lib/update.js +2 -151
- package/dist/lib/xiantao-auth.js +7 -117
- package/dist/lib/xiantao-cloud.js +1 -0
- package/dist/lib/xiantao-plot.js +1 -184
- package/dist/lib/xiantao.js +1 -184
- package/dist/xtz-help.js +6 -101
- package/package.json +7 -3
- package/bin/dev.js +0 -7
|
@@ -1,45 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { XtzCommand } from '../../base-command.js';
|
|
3
|
-
import { getAuthContext } from '../../lib/auth.js';
|
|
4
|
-
import { findXiantaoHistoryRecordByFuid, renameXiantaoHistoryRecord } from '../../lib/history.js';
|
|
5
|
-
import { globalFlags } from '../../lib/flags.js';
|
|
6
|
-
export default class HistoryRename extends XtzCommand {
|
|
7
|
-
static description = 'Rename a Xiantao history record';
|
|
8
|
-
static args = {
|
|
9
|
-
fuid: Args.string({
|
|
10
|
-
description: 'History record fuid',
|
|
11
|
-
required: true,
|
|
12
|
-
}),
|
|
13
|
-
name: Args.string({
|
|
14
|
-
description: 'New history record name',
|
|
15
|
-
required: true,
|
|
16
|
-
}),
|
|
17
|
-
};
|
|
18
|
-
static flags = {
|
|
19
|
-
...globalFlags,
|
|
20
|
-
token: Flags.string({
|
|
21
|
-
description: 'Bearer token for agent.helixlife.cn xiantao APIs; falls back to the stored agent token',
|
|
22
|
-
}),
|
|
23
|
-
};
|
|
24
|
-
async run() {
|
|
25
|
-
const { args, flags } = await this.parse(HistoryRename);
|
|
26
|
-
const agent = await this.getProfile(flags.profile);
|
|
27
|
-
const auth = await getAuthContext(agent, flags.token);
|
|
28
|
-
const before = await findXiantaoHistoryRecordByFuid(auth, args.fuid);
|
|
29
|
-
await renameXiantaoHistoryRecord(auth, {
|
|
30
|
-
fuid: args.fuid,
|
|
31
|
-
newName: args.name,
|
|
32
|
-
});
|
|
33
|
-
const output = {
|
|
34
|
-
agent,
|
|
35
|
-
fuid: args.fuid,
|
|
36
|
-
module_id: before?.module_id?.trim() ?? '',
|
|
37
|
-
module_name: before?.module_name?.trim() ?? '',
|
|
38
|
-
name: args.name,
|
|
39
|
-
};
|
|
40
|
-
this.print(flags, output, `${args.fuid} -> ${args.name}`, {
|
|
41
|
-
command: 'history rename',
|
|
42
|
-
profile: agent,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
1
|
+
import{Args as n,Flags as d}from"@oclif/core";import{XtzCommand as m}from"../../base-command.js";import{getAuthContext as f}from"../../lib/auth.js";import{findXiantaoHistoryRecordByFuid as u,renameXiantaoHistoryRecord as c}from"../../lib/history.js";import{globalFlags as l}from"../../lib/flags.js";class r extends m{static description="Rename a Xiantao history record";static args={fuid:n.string({description:"History record fuid",required:!0}),name:n.string({description:"New history record name",required:!0})};static flags={...l,token:d.string({description:"Bearer token for agent.helixlife.cn xiantao APIs; falls back to the stored agent token"})};async run(){const{args:t,flags:e}=await this.parse(r),i=await this.getProfile(e.profile),o=await f(i,e.token),a=await u(o,t.fuid);await c(o,{fuid:t.fuid,newName:t.name});const s={agent:i,fuid:t.fuid,module_id:a?.module_id?.trim()??"",module_name:a?.module_name?.trim()??"",name:t.name};this.print(e,s,`${t.fuid} -> ${t.name}`,{command:"history rename",profile:i})}}export{r as default};
|
package/dist/commands/login.js
CHANGED
package/dist/commands/logout.js
CHANGED
|
@@ -1,31 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { XtzCommand } from '../../base-command.js';
|
|
3
|
-
import { downloadToPath } from '../../lib/download.js';
|
|
4
|
-
export default class PlotDownload extends XtzCommand {
|
|
5
|
-
static description = 'Download a generated tool result URL to a local file';
|
|
6
|
-
static args = {
|
|
7
|
-
url: Args.string({
|
|
8
|
-
description: 'Direct file URL returned by a tool command',
|
|
9
|
-
required: true,
|
|
10
|
-
}),
|
|
11
|
-
};
|
|
12
|
-
static flags = {
|
|
13
|
-
json: Flags.boolean({
|
|
14
|
-
default: false,
|
|
15
|
-
description: 'Output JSON',
|
|
16
|
-
}),
|
|
17
|
-
output: Flags.string({
|
|
18
|
-
char: 'o',
|
|
19
|
-
description: 'Destination path; defaults to ~/Downloads/<file name>',
|
|
20
|
-
}),
|
|
21
|
-
};
|
|
22
|
-
async run() {
|
|
23
|
-
this.warnIfLegacyPlotCommand();
|
|
24
|
-
const { args, flags } = await this.parse(PlotDownload);
|
|
25
|
-
const filePath = await downloadToPath(args.url, flags.output);
|
|
26
|
-
this.print(flags, {
|
|
27
|
-
path: filePath,
|
|
28
|
-
url: args.url,
|
|
29
|
-
}, filePath);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
import{Args as e,Flags as s}from"@oclif/core";import{XtzCommand as i}from"../../base-command.js";import{downloadToPath as l}from"../../lib/download.js";class t extends i{static description="Download a generated tool result URL to a local file";static args={url:e.string({description:"Direct file URL returned by a tool command",required:!0})};static flags={json:s.boolean({default:!1,description:"Output JSON"}),output:s.string({char:"o",description:"Destination path; defaults to ~/Downloads/<file name>"})};async run(){this.warnIfLegacyPlotCommand();const{args:a,flags:o}=await this.parse(t),r=await l(a.url,o.output);this.print(o,{path:r,url:a.url},r)}}export{t as default};
|
|
@@ -1,47 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { XtzCommand } from '../../base-command.js';
|
|
3
|
-
import { getAuthContext } from '../../lib/auth.js';
|
|
4
|
-
import { globalFlags } from '../../lib/flags.js';
|
|
5
|
-
import { buildArgsMainFromSchema } from '../../lib/plot-schema.js';
|
|
6
|
-
import { fetchAllPlotArgs } from '../../lib/xiantao.js';
|
|
7
|
-
export default class PlotFetchAll extends XtzCommand {
|
|
8
|
-
static description = 'Fetch raw dynamic args for a Xiantao tool via public.args.fetch-all';
|
|
9
|
-
static args = {
|
|
10
|
-
moduleId: Args.string({
|
|
11
|
-
description: 'Tool id, e.g. violin_flat',
|
|
12
|
-
required: true,
|
|
13
|
-
}),
|
|
14
|
-
};
|
|
15
|
-
static flags = {
|
|
16
|
-
...globalFlags,
|
|
17
|
-
token: Flags.string({
|
|
18
|
-
description: 'Bearer token for agent.helixlife.cn xiantao APIs; falls back to the stored agent token',
|
|
19
|
-
}),
|
|
20
|
-
uuid: Flags.string({
|
|
21
|
-
description: 'Tool UUID used in the public.args.fetch-all payload',
|
|
22
|
-
required: true,
|
|
23
|
-
}),
|
|
24
|
-
};
|
|
25
|
-
async run() {
|
|
26
|
-
this.warnIfLegacyPlotCommand();
|
|
27
|
-
const { args, flags } = await this.parse(PlotFetchAll);
|
|
28
|
-
const agent = await this.getProfile(flags.profile);
|
|
29
|
-
const auth = await getAuthContext(agent, flags.token);
|
|
30
|
-
const result = await fetchAllPlotArgs(auth, {
|
|
31
|
-
moduleId: args.moduleId,
|
|
32
|
-
uuid: flags.uuid,
|
|
33
|
-
});
|
|
34
|
-
const argsMainDefaults = buildArgsMainFromSchema(result.args_main);
|
|
35
|
-
const output = {
|
|
36
|
-
agent,
|
|
37
|
-
args_data: result.args_data ?? [],
|
|
38
|
-
args_main: result.args_main ?? [],
|
|
39
|
-
args_main_defaults: argsMainDefaults,
|
|
40
|
-
duid: result.id?.duid ?? '',
|
|
41
|
-
module_id: args.moduleId,
|
|
42
|
-
notice: result.notice ?? '',
|
|
43
|
-
uuid: flags.uuid,
|
|
44
|
-
};
|
|
45
|
-
this.print(flags, output, JSON.stringify(output, null, 2), { profile: agent });
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
import{Args as d,Flags as o}from"@oclif/core";import{XtzCommand as c}from"../../base-command.js";import{getAuthContext as u}from"../../lib/auth.js";import{globalFlags as g}from"../../lib/flags.js";import{buildArgsMainFromSchema as f,buildArgsSpecificFromSchema as m}from"../../lib/plot-schema.js";import{fetchAllPlotArgs as p}from"../../lib/xiantao.js";class r extends c{static description="Fetch raw dynamic args for a Xiantao tool via public.args.fetch-all";static args={moduleId:d.string({description:"Tool id, e.g. violin_flat",required:!0})};static flags={...g,token:o.string({description:"Bearer token for agent.helixlife.cn xiantao APIs; falls back to the stored agent token"}),uuid:o.string({description:"Tool UUID used in the public.args.fetch-all payload",required:!0})};async run(){this.warnIfLegacyPlotCommand();const{args:s,flags:i}=await this.parse(r),a=await this.getProfile(i.profile),l=await u(a,i.token),t=await p(l,{moduleId:s.moduleId,uuid:i.uuid}),n=f(t.args_main),e={agent:a,args_data:t.args_data??[],args_main:t.args_main??[],args_main_defaults:n,args_specific:t.args_specific??[],args_specific_defaults:m(t.args_specific),duid:t.id?.duid??"",module_id:s.moduleId,notice:t.notice??"",uuid:i.uuid};this.print(i,e,JSON.stringify(e,null,2),{profile:a})}}export{r as default};
|
|
@@ -1,76 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { loginAuth } from '../../lib/auth.js';
|
|
4
|
-
import { globalFlags } from '../../lib/flags.js';
|
|
5
|
-
import { loginAll } from '../../lib/login-flow.js';
|
|
6
|
-
import { getTokenPath } from '../../lib/storage.js';
|
|
7
|
-
export default class PlotLogin extends XtzCommand {
|
|
8
|
-
static description = 'Authorize the current profile token';
|
|
9
|
-
static flags = {
|
|
10
|
-
...globalFlags,
|
|
11
|
-
open: Flags.boolean({
|
|
12
|
-
allowNo: true,
|
|
13
|
-
default: true,
|
|
14
|
-
description: 'Open the authorization link in the browser',
|
|
15
|
-
}),
|
|
16
|
-
wait: Flags.boolean({
|
|
17
|
-
allowNo: true,
|
|
18
|
-
default: true,
|
|
19
|
-
description: 'Wait until the browser authorization is confirmed before exiting',
|
|
20
|
-
}),
|
|
21
|
-
};
|
|
22
|
-
async run() {
|
|
23
|
-
this.warnIfLegacyPlotCommand();
|
|
24
|
-
const { flags } = await this.parse(PlotLogin);
|
|
25
|
-
const agent = await this.getProfile(flags.profile);
|
|
26
|
-
const waitForAuthorization = this.shouldWait(flags);
|
|
27
|
-
const result = waitForAuthorization
|
|
28
|
-
? await loginAll(agent, flags.open, ({ auth, phase }) => {
|
|
29
|
-
if (flags.json) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
if (phase === 'auth_started') {
|
|
33
|
-
this.log(auth.browserOpened ? '浏览器已打开授权链接,等待授权完成...' : `请先在浏览器中打开授权链接: ${auth.linkUrl}`);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
this.log('授权已确认。');
|
|
37
|
-
})
|
|
38
|
-
: { auth: await loginAuth(agent, flags.open) };
|
|
39
|
-
const authorized = waitForAuthorization;
|
|
40
|
-
this.print(flags, {
|
|
41
|
-
agent,
|
|
42
|
-
authorization_pending: !authorized,
|
|
43
|
-
authorized,
|
|
44
|
-
browser_opened: result.auth.browserOpened,
|
|
45
|
-
link_url: result.auth.linkUrl,
|
|
46
|
-
token_path: result.auth.tokenPath,
|
|
47
|
-
wait: waitForAuthorization,
|
|
48
|
-
}, this.formatLoginText({
|
|
49
|
-
agent,
|
|
50
|
-
authorized,
|
|
51
|
-
browserOpened: result.auth.browserOpened,
|
|
52
|
-
linkUrl: result.auth.linkUrl,
|
|
53
|
-
}), { profile: agent });
|
|
54
|
-
}
|
|
55
|
-
shouldWait(flags) {
|
|
56
|
-
if (!this.hasExplicitWaitFlag()) {
|
|
57
|
-
return !flags.json;
|
|
58
|
-
}
|
|
59
|
-
return flags.wait;
|
|
60
|
-
}
|
|
61
|
-
hasExplicitWaitFlag() {
|
|
62
|
-
return this.argv.includes('--wait') || this.argv.includes('--no-wait');
|
|
63
|
-
}
|
|
64
|
-
formatLoginText(input) {
|
|
65
|
-
const lines = [
|
|
66
|
-
`profile: ${input.agent}`,
|
|
67
|
-
`token: ${getTokenPath(input.agent)}`,
|
|
68
|
-
`authorized: ${input.authorized}`,
|
|
69
|
-
];
|
|
70
|
-
if (input.authorized) {
|
|
71
|
-
return lines.join('\n');
|
|
72
|
-
}
|
|
73
|
-
lines.push(input.browserOpened ? '浏览器已打开授权链接,请完成授权后运行 `xt status`。' : `请在浏览器中打开: ${input.linkUrl}`);
|
|
74
|
-
return lines.join('\n');
|
|
75
|
-
}
|
|
76
|
-
}
|
|
1
|
+
import{Flags as s}from"@oclif/core";import{XtzCommand as h}from"../../base-command.js";import{loginAuth as u}from"../../lib/auth.js";import{globalFlags as d}from"../../lib/flags.js";import{loginAll as p}from"../../lib/login-flow.js";import{getTokenPath as f}from"../../lib/storage.js";class a extends h{static description="Authorize the current profile token";static flags={...d,open:s.boolean({allowNo:!0,default:!0,description:"Open the authorization link in the browser"}),wait:s.boolean({allowNo:!0,default:!0,description:"Wait until the browser authorization is confirmed before exiting"})};async run(){this.warnIfLegacyPlotCommand();const{flags:t}=await this.parse(a),o=await this.getProfile(t.profile),i=this.shouldWait(t),e=i?await p(o,t.open,({auth:n,phase:l})=>{if(!t.json){if(l==="auth_started"){this.log(n.browserOpened?"\u6D4F\u89C8\u5668\u5DF2\u6253\u5F00\u6388\u6743\u94FE\u63A5\uFF0C\u7B49\u5F85\u6388\u6743\u5B8C\u6210...":`\u8BF7\u5148\u5728\u6D4F\u89C8\u5668\u4E2D\u6253\u5F00\u6388\u6743\u94FE\u63A5: ${n.linkUrl}`);return}this.log("\u6388\u6743\u5DF2\u786E\u8BA4\u3002")}}):{auth:await u(o,t.open)},r=i;this.print(t,{agent:o,authorization_pending:!r,authorized:r,browser_opened:e.auth.browserOpened,link_url:e.auth.linkUrl,token_path:e.auth.tokenPath,wait:i},this.formatLoginText({agent:o,authorized:r,browserOpened:e.auth.browserOpened,linkUrl:e.auth.linkUrl}),{profile:o})}shouldWait(t){return this.hasExplicitWaitFlag()?t.wait:!t.json}hasExplicitWaitFlag(){return this.argv.includes("--wait")||this.argv.includes("--no-wait")}formatLoginText(t){const o=[`profile: ${t.agent}`,`token: ${f(t.agent)}`,`authorized: ${t.authorized}`];return t.authorized||o.push(t.browserOpened?"\u6D4F\u89C8\u5668\u5DF2\u6253\u5F00\u6388\u6743\u94FE\u63A5\uFF0C\u8BF7\u5B8C\u6210\u6388\u6743\u540E\u8FD0\u884C `xt status`\u3002":`\u8BF7\u5728\u6D4F\u89C8\u5668\u4E2D\u6253\u5F00: ${t.linkUrl}`),o.join(`
|
|
2
|
+
`)}}export{a as default};
|
|
@@ -1,37 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { XtzCommand } from '../../base-command.js';
|
|
3
|
-
import { getAuthContext } from '../../lib/auth.js';
|
|
4
|
-
import { globalFlags } from '../../lib/flags.js';
|
|
5
|
-
import { resolveXiantaoToolProductUuid } from '../../lib/storage.js';
|
|
6
|
-
import { fetchToolMenu } from '../../lib/xiantao.js';
|
|
7
|
-
export default class PlotMenu extends XtzCommand {
|
|
8
|
-
static description = 'Fetch Xiantao menu metadata for a tool menu UUID';
|
|
9
|
-
static args = {
|
|
10
|
-
menuUuid: Args.string({
|
|
11
|
-
description: 'Tool menu UUID from /tool/menus/:uuid',
|
|
12
|
-
required: true,
|
|
13
|
-
}),
|
|
14
|
-
};
|
|
15
|
-
static flags = {
|
|
16
|
-
...globalFlags,
|
|
17
|
-
token: Flags.string({
|
|
18
|
-
description: 'Bearer token for agent.helixlife.cn xiantao APIs; falls back to the stored agent token',
|
|
19
|
-
}),
|
|
20
|
-
toolProductUuid: Flags.string({
|
|
21
|
-
description: 'tool_product_uuid used in the menu filter payload; defaults to the main Xiantao product UUID',
|
|
22
|
-
}),
|
|
23
|
-
};
|
|
24
|
-
async run() {
|
|
25
|
-
this.warnIfLegacyPlotCommand();
|
|
26
|
-
const { args, flags } = await this.parse(PlotMenu);
|
|
27
|
-
const agent = await this.getProfile(flags.profile);
|
|
28
|
-
const auth = await getAuthContext(agent, flags.token);
|
|
29
|
-
const toolProductUuid = await resolveXiantaoToolProductUuid(flags.toolProductUuid);
|
|
30
|
-
const menu = await fetchToolMenu(auth, args.menuUuid, toolProductUuid);
|
|
31
|
-
this.print(flags, {
|
|
32
|
-
agent,
|
|
33
|
-
menu,
|
|
34
|
-
tool_product_uuid: toolProductUuid,
|
|
35
|
-
}, JSON.stringify(menu, null, 2), { profile: agent });
|
|
36
|
-
}
|
|
37
|
-
}
|
|
1
|
+
import{Args as u,Flags as r}from"@oclif/core";import{XtzCommand as l}from"../../base-command.js";import{getAuthContext as d}from"../../lib/auth.js";import{globalFlags as m}from"../../lib/flags.js";import{resolveXiantaoToolProductUuid as c}from"../../lib/storage.js";import{fetchToolMenu as f}from"../../lib/xiantao.js";class i extends l{static description="Fetch Xiantao menu metadata for a tool menu UUID";static args={menuUuid:u.string({description:"Tool menu UUID from /tool/menus/:uuid",required:!0})};static flags={...m,token:r.string({description:"Bearer token for agent.helixlife.cn xiantao APIs; falls back to the stored agent token"}),toolProductUuid:r.string({description:"tool_product_uuid used in the menu filter payload; defaults to the main Xiantao product UUID"})};async run(){this.warnIfLegacyPlotCommand();const{args:n,flags:t}=await this.parse(i),o=await this.getProfile(t.profile),s=await d(o,t.token),a=await c(t.toolProductUuid),e=await f(s,n.menuUuid,a);this.print(t,{agent:o,menu:e,tool_product_uuid:a},JSON.stringify(e,null,2),{profile:o})}}export{i as default};
|
|
@@ -1,31 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { XtzCommand } from '../../base-command.js';
|
|
3
|
-
import { getAuthContext } from '../../lib/auth.js';
|
|
4
|
-
import { globalFlags } from '../../lib/flags.js';
|
|
5
|
-
import { resolveXiantaoToolProductUuid } from '../../lib/storage.js';
|
|
6
|
-
import { fetchToolMenus } from '../../lib/xiantao.js';
|
|
7
|
-
export default class PlotMenusRaw extends XtzCommand {
|
|
8
|
-
static description = 'Fetch all raw Xiantao menu metadata for a tool product';
|
|
9
|
-
static flags = {
|
|
10
|
-
...globalFlags,
|
|
11
|
-
token: Flags.string({
|
|
12
|
-
description: 'Bearer token for agent.helixlife.cn xiantao APIs; falls back to the stored agent token',
|
|
13
|
-
}),
|
|
14
|
-
toolProductUuid: Flags.string({
|
|
15
|
-
description: 'tool_product_uuid used in the menu filter payload; defaults to the main Xiantao product UUID',
|
|
16
|
-
}),
|
|
17
|
-
};
|
|
18
|
-
async run() {
|
|
19
|
-
this.warnIfLegacyPlotCommand();
|
|
20
|
-
const { flags } = await this.parse(PlotMenusRaw);
|
|
21
|
-
const agent = await this.getProfile(flags.profile);
|
|
22
|
-
const auth = await getAuthContext(agent, flags.token);
|
|
23
|
-
const toolProductUuid = await resolveXiantaoToolProductUuid(flags.toolProductUuid);
|
|
24
|
-
const menus = await fetchToolMenus(auth, toolProductUuid);
|
|
25
|
-
this.print(flags, {
|
|
26
|
-
agent,
|
|
27
|
-
menus,
|
|
28
|
-
tool_product_uuid: toolProductUuid,
|
|
29
|
-
}, JSON.stringify(menus, null, 2), { profile: agent });
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
import{Flags as r}from"@oclif/core";import{XtzCommand as s}from"../../base-command.js";import{getAuthContext as l}from"../../lib/auth.js";import{globalFlags as u}from"../../lib/flags.js";import{resolveXiantaoToolProductUuid as d}from"../../lib/storage.js";import{fetchToolMenus as c}from"../../lib/xiantao.js";class a extends s{static description="Fetch all raw Xiantao menu metadata for a tool product";static flags={...u,token:r.string({description:"Bearer token for agent.helixlife.cn xiantao APIs; falls back to the stored agent token"}),toolProductUuid:r.string({description:"tool_product_uuid used in the menu filter payload; defaults to the main Xiantao product UUID"})};async run(){this.warnIfLegacyPlotCommand();const{flags:t}=await this.parse(a),o=await this.getProfile(t.profile),n=await l(o,t.token),i=await d(t.toolProductUuid),e=await c(n,i);this.print(t,{agent:o,menus:e,tool_product_uuid:i},JSON.stringify(e,null,2),{profile:o})}}export{a as default};
|
|
@@ -1,47 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { getAuthContext } from '../../lib/auth.js';
|
|
4
|
-
import { globalFlags } from '../../lib/flags.js';
|
|
5
|
-
import { resolveXiantaoToolProductUuid } from '../../lib/storage.js';
|
|
6
|
-
import { fetchToolMenus, listToolMenuSummaries } from '../../lib/xiantao.js';
|
|
7
|
-
export default class PlotMenus extends XtzCommand {
|
|
8
|
-
static description = 'List Xiantao tools with title, tool id, path, and route for a product';
|
|
9
|
-
static flags = {
|
|
10
|
-
...globalFlags,
|
|
11
|
-
token: Flags.string({
|
|
12
|
-
description: 'Bearer token for agent.helixlife.cn xiantao APIs; falls back to the stored agent token',
|
|
13
|
-
}),
|
|
14
|
-
toolProductUuid: Flags.string({
|
|
15
|
-
description: 'tool_product_uuid used in the menu filter payload; defaults to the main Xiantao product UUID',
|
|
16
|
-
}),
|
|
17
|
-
};
|
|
18
|
-
async run() {
|
|
19
|
-
this.warnIfLegacyPlotCommand();
|
|
20
|
-
const { flags } = await this.parse(PlotMenus);
|
|
21
|
-
const agent = await this.getProfile(flags.profile);
|
|
22
|
-
const auth = await getAuthContext(agent, flags.token);
|
|
23
|
-
const toolProductUuid = await resolveXiantaoToolProductUuid(flags.toolProductUuid);
|
|
24
|
-
const menus = listToolMenuSummaries(await fetchToolMenus(auth, toolProductUuid));
|
|
25
|
-
this.print(flags, {
|
|
26
|
-
agent,
|
|
27
|
-
menus,
|
|
28
|
-
tool_product_uuid: toolProductUuid,
|
|
29
|
-
}, this.formatMenusText(menus), { profile: agent });
|
|
30
|
-
}
|
|
31
|
-
formatMenusText(menus) {
|
|
32
|
-
if (menus.length === 0) {
|
|
33
|
-
return '未找到可用工具';
|
|
34
|
-
}
|
|
35
|
-
const lines = [`共 ${menus.length} 个工具`];
|
|
36
|
-
for (const menu of menus) {
|
|
37
|
-
lines.push('');
|
|
38
|
-
lines.push(`${menu.title}`);
|
|
39
|
-
lines.push(` ${menu.module_id}`);
|
|
40
|
-
if (menu.path) {
|
|
41
|
-
lines.push(` ${menu.path}`);
|
|
42
|
-
}
|
|
43
|
-
lines.push(` ${menu.route}`);
|
|
44
|
-
}
|
|
45
|
-
return lines.join('\n');
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
import{Flags as n}from"@oclif/core";import{XtzCommand as s}from"../../base-command.js";import{getAuthContext as u}from"../../lib/auth.js";import{globalFlags as l}from"../../lib/flags.js";import{resolveXiantaoToolProductUuid as d}from"../../lib/storage.js";import{fetchToolMenus as p,listToolMenuSummaries as c}from"../../lib/xiantao.js";class e extends s{static description="List Xiantao tools with title, tool id, path, and route for a product";static flags={...l,token:n.string({description:"Bearer token for agent.helixlife.cn xiantao APIs; falls back to the stored agent token"}),toolProductUuid:n.string({description:"tool_product_uuid used in the menu filter payload; defaults to the main Xiantao product UUID"})};async run(){this.warnIfLegacyPlotCommand();const{flags:o}=await this.parse(e),t=await this.getProfile(o.profile),i=await u(t,o.token),a=await d(o.toolProductUuid),r=c(await p(i,a));this.print(o,{agent:t,menus:r,tool_product_uuid:a},this.formatMenusText(r),{profile:t})}formatMenusText(o){if(o.length===0)return"\u672A\u627E\u5230\u53EF\u7528\u5DE5\u5177";const t=[`\u5171 ${o.length} \u4E2A\u5DE5\u5177`];for(const i of o)t.push(""),t.push(`${i.title}`),t.push(` ${i.module_id}`),i.path&&t.push(` ${i.path}`),t.push(` ${i.route}`);return t.join(`
|
|
2
|
+
`)}}export{e as default};
|
|
@@ -1,48 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { XtzCommand } from '../../base-command.js';
|
|
3
|
-
import { getAuthContext } from '../../lib/auth.js';
|
|
4
|
-
import { globalFlags } from '../../lib/flags.js';
|
|
5
|
-
import { resolveXiantaoToolProductUuid } from '../../lib/storage.js';
|
|
6
|
-
import { resolveToolMenuByCode } from '../../lib/xiantao.js';
|
|
7
|
-
export default class PlotResolve extends XtzCommand {
|
|
8
|
-
static description = 'Resolve a Xiantao tool id to its UUID and route';
|
|
9
|
-
static args = {
|
|
10
|
-
moduleId: Args.string({
|
|
11
|
-
description: 'Tool id, e.g. violin_flat',
|
|
12
|
-
required: true,
|
|
13
|
-
}),
|
|
14
|
-
};
|
|
15
|
-
static flags = {
|
|
16
|
-
...globalFlags,
|
|
17
|
-
token: Flags.string({
|
|
18
|
-
description: 'Bearer token for agent.helixlife.cn xiantao APIs; falls back to the stored agent token',
|
|
19
|
-
}),
|
|
20
|
-
toolProductUuid: Flags.string({
|
|
21
|
-
description: 'tool_product_uuid from the /products/apply/:uuid URL; defaults to the main Xiantao product UUID',
|
|
22
|
-
}),
|
|
23
|
-
};
|
|
24
|
-
async run() {
|
|
25
|
-
this.warnIfLegacyPlotCommand();
|
|
26
|
-
const { args, flags } = await this.parse(PlotResolve);
|
|
27
|
-
const agent = await this.getProfile(flags.profile);
|
|
28
|
-
const auth = await getAuthContext(agent, flags.token);
|
|
29
|
-
const toolProductUuid = await resolveXiantaoToolProductUuid(flags.toolProductUuid);
|
|
30
|
-
const resolved = await resolveToolMenuByCode(auth, toolProductUuid, args.moduleId);
|
|
31
|
-
this.print(flags, {
|
|
32
|
-
agent,
|
|
33
|
-
module_id: args.moduleId,
|
|
34
|
-
path: resolved.path,
|
|
35
|
-
route: resolved.route,
|
|
36
|
-
title: resolved.title,
|
|
37
|
-
tool_product_uuid: toolProductUuid,
|
|
38
|
-
uuid: resolved.uuid,
|
|
39
|
-
}, JSON.stringify({
|
|
40
|
-
module_id: args.moduleId,
|
|
41
|
-
path: resolved.path,
|
|
42
|
-
route: resolved.route,
|
|
43
|
-
title: resolved.title,
|
|
44
|
-
tool_product_uuid: toolProductUuid,
|
|
45
|
-
uuid: resolved.uuid,
|
|
46
|
-
}, null, 2), { profile: agent });
|
|
47
|
-
}
|
|
48
|
-
}
|
|
1
|
+
import{Args as l,Flags as d}from"@oclif/core";import{XtzCommand as s}from"../../base-command.js";import{getAuthContext as n}from"../../lib/auth.js";import{globalFlags as c}from"../../lib/flags.js";import{resolveXiantaoToolProductUuid as p}from"../../lib/storage.js";import{resolveToolMenuByCode as m}from"../../lib/xiantao.js";class a extends s{static description="Resolve a Xiantao tool id to its UUID and route";static args={moduleId:l.string({description:"Tool id, e.g. violin_flat",required:!0})};static flags={...c,token:d.string({description:"Bearer token for agent.helixlife.cn xiantao APIs; falls back to the stored agent token"}),toolProductUuid:d.string({description:"tool_product_uuid from the /products/apply/:uuid URL; defaults to the main Xiantao product UUID"})};async run(){this.warnIfLegacyPlotCommand();const{args:i,flags:o}=await this.parse(a),e=await this.getProfile(o.profile),u=await n(e,o.token),r=await p(o.toolProductUuid),t=await m(u,r,i.moduleId);this.print(o,{agent:e,module_id:i.moduleId,path:t.path,route:t.route,title:t.title,tool_product_uuid:r,uuid:t.uuid},JSON.stringify({module_id:i.moduleId,path:t.path,route:t.route,title:t.title,tool_product_uuid:r,uuid:t.uuid},null,2),{profile:e})}}export{a as default};
|