@arcticdata/dsh-datarc-assistant 0.0.0-stage → 26.39.1
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 +46 -2
- package/api-operations.js +404 -0
- package/client.js +475 -0
- package/cordis.patch.yml +4 -0
- package/entry/SKILL.md +34 -0
- package/icon.png +0 -0
- package/index.js +69 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/native-api.mjs +326 -0
- package/native-contracts.js +195 -0
- package/native-execution.js +184 -0
- package/native-runner.mjs +107 -0
- package/native-state.js +67 -0
- package/native-tools.js +241 -0
- package/operations.js +1260 -0
- package/package.json +65 -6
- package/runtime/datarc-access-permissions/SKILL.md +30 -0
- package/runtime/datarc-access-permissions/references/api.md +31 -0
- package/runtime/datarc-access-permissions/references/write-order.md +16 -0
- package/runtime/datarc-analysis-report/SKILL.md +125 -0
- package/runtime/datarc-analysis-report/agents/openai.yaml +6 -0
- package/runtime/datarc-analysis-report/references/analyst-frameworks.md +215 -0
- package/runtime/datarc-analysis-report/references/api-contracts.md +478 -0
- package/runtime/datarc-analysis-report/references/direct-card-fallback-design.md +66 -0
- package/runtime/datarc-analysis-report/references/human-in-the-loop.md +142 -0
- package/runtime/datarc-analysis-report/references/loop-personalization-policy.md +138 -0
- package/runtime/datarc-analysis-report/references/manifest-example.json +779 -0
- package/runtime/datarc-analysis-report/references/narrative-schema.md +160 -0
- package/runtime/datarc-analysis-report/references/question-syntax.md +151 -0
- package/runtime/datarc-analysis-report/scripts/run_analysis_report.py +2225 -0
- package/runtime/datarc-analysis-report/scripts/run_dataseek_cards.py +1914 -0
- package/runtime/datarc-analysis-report/scripts/test_run_analysis_report.py +5295 -0
- package/runtime/datarc-data-search/SKILL.md +243 -0
- package/runtime/datarc-data-search/scripts/calculate.py +116 -0
- package/runtime/datarc-data-search/scripts/data-search.mjs +628 -0
- package/runtime/datarc-data-search/scripts/datarc-client.mjs +464 -0
- package/runtime/datarc-data-search/scripts/search-result.mjs +211 -0
- package/runtime/datarc-dataseek-batch-evaluation/SKILL.md +59 -0
- package/runtime/datarc-dataseek-batch-evaluation/references/artifacts.md +36 -0
- package/runtime/datarc-dataseek-batch-evaluation/references/equivalence.md +30 -0
- package/runtime/datarc-dataseek-batch-evaluation/scripts/datarc-client.mjs +464 -0
- package/runtime/datarc-dataseek-batch-evaluation/scripts/dataseek-batch-evaluation.mjs +1020 -0
- package/runtime/datarc-dataseek-search/SKILL.md +96 -0
- package/runtime/datarc-dataseek-search/scripts/datarc-client.mjs +464 -0
- package/runtime/datarc-dataseek-search/scripts/dataseek-search.mjs +257 -0
- package/runtime/datarc-dataseek-semantic-debugging/SKILL.md +44 -0
- package/runtime/datarc-dataseek-semantic-debugging/agents/openai.yaml +4 -0
- package/runtime/datarc-dataseek-semantic-debugging/evals/evals.json +165 -0
- package/runtime/datarc-dataseek-semantic-debugging/references/dataset.md +77 -0
- package/runtime/datarc-dataseek-semantic-debugging/references/input-and-resolution.md +93 -0
- package/runtime/datarc-dataseek-semantic-debugging/references/interventions.md +64 -0
- package/runtime/datarc-dataseek-semantic-debugging/references/knowledge-and-prompts.md +47 -0
- package/runtime/datarc-dataseek-semantic-debugging/references/rollback.md +11 -0
- package/runtime/datarc-dataseek-semantic-debugging/references/verification-and-rollback.md +95 -0
- package/runtime/datarc-dataseek-semantic-debugging/scripts/semantic-debugging.mjs +29 -0
- package/runtime/datarc-dataseek-testset-generation/SKILL.md +47 -0
- package/runtime/datarc-dataseek-testset-generation/scripts/datarc-client.mjs +464 -0
- package/runtime/datarc-dataseek-testset-generation/scripts/dataseek-testset-generation.mjs +526 -0
- package/runtime/datarc-datasource/SKILL.md +97 -0
- package/runtime/datarc-oauth/SKILL.md +50 -0
- package/runtime/datarc-oauth/scripts/auth.mjs +192 -0
- package/runtime/datarc-oauth/scripts/credentials.mjs +237 -0
- package/runtime/datarc-report-add-card/SKILL.md +90 -0
- package/runtime/datarc-report-add-card/agents/openai.yaml +4 -0
- package/runtime/datarc-report-add-card/scripts/datarc-client.mjs +464 -0
- package/runtime/datarc-report-add-card/scripts/report-card.mjs +439 -0
- package/runtime/datarc-semantic-alias/SKILL.md +20 -0
- package/runtime/datarc-semantic-alias/scripts/alias-plan.mjs +422 -0
- package/runtime/datarc-semantic-alias/scripts/alias.mjs +11 -0
- package/runtime/datarc-semantic-calibration/SKILL.md +20 -0
- package/runtime/datarc-semantic-calibration/scripts/calibration-plan.mjs +683 -0
- package/runtime/datarc-semantic-calibration/scripts/calibration.mjs +11 -0
- package/runtime/datarc-semantic-core/SKILL.md +12 -0
- package/runtime/datarc-semantic-core/scripts/artifact-journal.mjs +853 -0
- package/runtime/datarc-semantic-core/scripts/canonical.mjs +48 -0
- package/runtime/datarc-semantic-core/scripts/case-model.mjs +608 -0
- package/runtime/datarc-semantic-core/scripts/cli.mjs +180 -0
- package/runtime/datarc-semantic-core/scripts/datarc-client.mjs +180 -0
- package/runtime/datarc-semantic-core/scripts/interpretation-pairs.mjs +57 -0
- package/runtime/datarc-semantic-core/scripts/interventions.mjs +693 -0
- package/runtime/datarc-semantic-core/scripts/live-resolution.mjs +305 -0
- package/runtime/datarc-semantic-core/scripts/model-scope.mjs +49 -0
- package/runtime/datarc-semantic-core/scripts/reproduction.mjs +330 -0
- package/runtime/datarc-semantic-core/scripts/semantic-cli.mjs +799 -0
- package/runtime/datarc-semantic-core/scripts/shared.mjs +312 -0
- package/runtime/datarc-semantic-core/scripts/verification.mjs +1111 -0
- package/runtime/datarc-semantic-dataset/SKILL.md +20 -0
- package/runtime/datarc-semantic-dataset/scripts/dataset-plan.mjs +749 -0
- package/runtime/datarc-semantic-dataset/scripts/dataset-preflight.mjs +813 -0
- package/runtime/datarc-semantic-dataset/scripts/dataset.mjs +11 -0
- package/runtime/datarc-semantic-knowledge/SKILL.md +38 -0
- package/runtime/datarc-semantic-knowledge/references/knowledge-drafts.md +61 -0
- package/runtime/datarc-semantic-knowledge/references/knowledge-generation.json +16 -0
- package/runtime/datarc-semantic-knowledge/scripts/knowledge-draft.mjs +347 -0
- package/runtime/datarc-semantic-knowledge/scripts/knowledge-plan.mjs +848 -0
- package/runtime/datarc-semantic-knowledge/scripts/knowledge.mjs +31 -0
- package/runtime/datarc-semantic-prompt/SKILL.md +20 -0
- package/runtime/datarc-semantic-prompt/scripts/prompt-plan.mjs +598 -0
- package/runtime/datarc-semantic-prompt/scripts/prompt.mjs +15 -0
- package/runtime/datarc-semantic-synonym/SKILL.md +20 -0
- package/runtime/datarc-semantic-synonym/scripts/synonym-plan.mjs +688 -0
- package/runtime/datarc-semantic-synonym/scripts/synonym.mjs +11 -0
- package/runtime/datarc-viz-analysis-report/SKILL.md +108 -0
- package/runtime/datarc-viz-analysis-report/assets/LICENSE-echarts.md +8 -0
- package/runtime/datarc-viz-analysis-report/assets/echarts.min.js +45 -0
- package/runtime/datarc-viz-analysis-report/references/api-contracts.md +163 -0
- package/runtime/datarc-viz-analysis-report/references/derivation-log.md +157 -0
- package/runtime/datarc-viz-analysis-report/references/evidence-framework.md +76 -0
- package/runtime/datarc-viz-analysis-report/references/html-template.md +92 -0
- package/runtime/datarc-viz-analysis-report/references/provenance-format.md +56 -0
- package/runtime/datarc-viz-analysis-report/references/question-syntax.md +151 -0
- package/runtime/datarc-viz-analysis-report/scripts/render_viz_report.py +1708 -0
- package/runtime/datarc-viz-analysis-report/scripts/test_render_viz_report.py +964 -0
- package/runtime/datarc-workspace-configuration/SKILL.md +59 -0
- package/runtime/datarc-workspace-configuration/references/artifacts.md +75 -0
- package/runtime/datarc-workspace-configuration/references/verification.md +20 -0
- package/runtime/datarc-workspace-configuration/scripts/configuration.mjs +722 -0
- package/runtime/datarc-workspace-context/SKILL.md +43 -0
- package/runtime/datarc-workspace-context/agents/openai.yaml +4 -0
- package/runtime/datarc-workspace-context/scripts/datarc-client.mjs +31 -0
- package/runtime/datarc-workspace-context/scripts/query-display.mjs +114 -0
- package/runtime/datarc-workspace-context/scripts/workspace-context.mjs +58 -0
- package/runtime/datarc-workspace-custom-tables/SKILL.md +89 -0
- package/runtime/datarc-workspace-custom-tables/scripts/datarc-client.mjs +165 -0
- package/runtime/datarc-workspace-custom-tables/scripts/workspace-custom-tables.mjs +601 -0
- package/runtime/datarc-workspace-keywords/SKILL.md +197 -0
- package/runtime/datarc-workspace-keywords/agents/openai.yaml +4 -0
- package/runtime/datarc-workspace-keywords/references/api-fields.md +79 -0
- package/runtime/datarc-workspace-keywords/references/derived-measures.md +177 -0
- package/runtime/datarc-workspace-keywords/scripts/datarc-client.mjs +145 -0
- package/runtime/datarc-workspace-keywords/scripts/workspace-keywords.mjs +2421 -0
- package/runtime/datarc-workspace-membership/SKILL.md +29 -0
- package/runtime/datarc-workspace-membership/references/api.md +19 -0
- package/runtime/datarc-workspace-modeling/SKILL.md +209 -0
- package/runtime/datarc-workspace-modeling/agents/openai.yaml +4 -0
- package/runtime/datarc-workspace-modeling/references/join-preview.md +38 -0
- package/runtime/datarc-workspace-modeling/references/model-plan.md +300 -0
- package/runtime/datarc-workspace-modeling/references/model-tags.md +95 -0
- package/runtime/datarc-workspace-modeling/references/modeling-contract.json +29 -0
- package/runtime/datarc-workspace-modeling/references/modeling-fixtures.json +2423 -0
- package/runtime/datarc-workspace-modeling/scripts/datarc-client.mjs +137 -0
- package/runtime/datarc-workspace-modeling/scripts/workspace-model-tags.mjs +238 -0
- package/runtime/datarc-workspace-modeling/scripts/workspace-modeling.mjs +1261 -0
- package/skills-provider.js +51 -0
- package/workflow-index.json +434 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { isAbsolute, resolve } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
const runnerPath = fileURLToPath(new URL('./native-runner.mjs', import.meta.url));
|
|
6
|
+
const allowedModes = new Set(['execute']);
|
|
7
|
+
|
|
8
|
+
function executionError(message, code, cause) {
|
|
9
|
+
return Object.assign(new Error(message, cause === undefined ? undefined : { cause }), { code });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function requireExecution(exec) {
|
|
13
|
+
if (!exec?.agent || !exec.signal) {
|
|
14
|
+
throw executionError('数据工具缺少当前会话执行身份。请在北极九章会话中重试。', 'DATARC_EXECUTION_CONTEXT_REQUIRED');
|
|
15
|
+
}
|
|
16
|
+
exec.signal.throwIfAborted();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function forwardBatchContext(exec, batch) {
|
|
20
|
+
for (const context of batch.additionalContexts ?? []) exec.deferContext(context);
|
|
21
|
+
if (batch.concluded) exec.concludeTurn();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Invoke a caller-visible Host tool through its selected executor and policies.
|
|
25
|
+
* No inner model-step log is invented: the outer data tool owns its durable result.
|
|
26
|
+
* The exact owner, cancellation signal and step admission are not optional substitutes.
|
|
27
|
+
*/
|
|
28
|
+
export async function invokeHostTool(ctx, exec, name, args) {
|
|
29
|
+
requireExecution(exec);
|
|
30
|
+
if (!ctx.tools || typeof ctx.tools.execute !== 'function') {
|
|
31
|
+
throw executionError('当前 DSH 未提供工具执行服务。请启用北极九章预设后重试。', 'DATARC_TOOL_SERVICE_UNAVAILABLE');
|
|
32
|
+
}
|
|
33
|
+
let batch;
|
|
34
|
+
try {
|
|
35
|
+
batch = await ctx.tools.execute({
|
|
36
|
+
calls: [
|
|
37
|
+
{
|
|
38
|
+
type: 'tool-call',
|
|
39
|
+
id: randomUUID(),
|
|
40
|
+
name,
|
|
41
|
+
arguments: JSON.stringify(args),
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
agent: exec.agent,
|
|
45
|
+
signal: exec.signal,
|
|
46
|
+
...(exec.toolSet === undefined ? {} : { toolSet: exec.toolSet }),
|
|
47
|
+
});
|
|
48
|
+
} catch (error) {
|
|
49
|
+
// A failed scheduler may already have accepted context. Never restart its work.
|
|
50
|
+
if (error?.partial?.results && Array.isArray(error.partial.additionalContexts)) forwardBatchContext(exec, error.partial);
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
forwardBatchContext(exec, batch);
|
|
54
|
+
exec.signal.throwIfAborted();
|
|
55
|
+
const result = batch.results?.[0]?.result;
|
|
56
|
+
if (!result || batch.results.length !== 1) {
|
|
57
|
+
throw executionError('DSH 未返回完整的工具结果。请检查会话状态,不要重复提交可能已完成的写入。', 'DATARC_HOST_RESULT_INVALID');
|
|
58
|
+
}
|
|
59
|
+
if (result.isError) {
|
|
60
|
+
const code = result.error?.info?.code ?? 'DATARC_HOST_TOOL_FAILED';
|
|
61
|
+
const detail =
|
|
62
|
+
result.error?.message ??
|
|
63
|
+
result.content
|
|
64
|
+
?.filter((item) => item.type === 'text')
|
|
65
|
+
.map((item) => item.text)
|
|
66
|
+
.join('\n') ??
|
|
67
|
+
'工具执行失败';
|
|
68
|
+
const next =
|
|
69
|
+
code === 'UNKNOWN_TOOL'
|
|
70
|
+
? '请使用提供该工具的北极九章专属预设;不要绕过当前模式或工具限制重试。'
|
|
71
|
+
: '请检查 DSH 权限、连接和当前任务状态后重试;不要自动重复提交写入。';
|
|
72
|
+
throw executionError(`${name} 未完成:${detail} ${next}`, code);
|
|
73
|
+
}
|
|
74
|
+
if (!Object.hasOwn(result, 'value')) {
|
|
75
|
+
throw executionError('DSH 工具缺少结构化结果。请检查 DSH 版本与工具配置后重试。', 'DATARC_HOST_RESULT_INVALID');
|
|
76
|
+
}
|
|
77
|
+
return result.value;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Quote exactly one literal argv value in a generated bash or PowerShell command. */
|
|
81
|
+
export function quoteShellArgument(value, dialect) {
|
|
82
|
+
if (typeof value !== 'string' || value.includes('\0')) {
|
|
83
|
+
throw executionError('执行参数含有无效字符。请修正输入后重试。', 'DATARC_COMMAND_ARGUMENT_INVALID');
|
|
84
|
+
}
|
|
85
|
+
if (dialect === 'pwsh') return `'${value.replaceAll("'", "''")}'`;
|
|
86
|
+
if (dialect === 'bash') return `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
87
|
+
throw executionError('不支持当前终端类型。请使用 DSH 支持的 PowerShell 或 bash。', 'DATARC_SHELL_UNSUPPORTED');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function executablePath(value, label) {
|
|
91
|
+
if (typeof value !== 'string' || !isAbsolute(value) || value.includes('\0')) {
|
|
92
|
+
throw executionError(`${label} 路径无效。请检查 DSH 运行时配置后重试。`, 'DATARC_RUNTIME_PATH_INVALID');
|
|
93
|
+
}
|
|
94
|
+
return value;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function findRuntimes(ctx, exec) {
|
|
98
|
+
let dependencies;
|
|
99
|
+
// A missing provider permits local runtime discovery. A denied provider does not.
|
|
100
|
+
if (ctx.tools.get('load_workspace_dependencies', exec.agent, exec.toolSet)) {
|
|
101
|
+
dependencies = await invokeHostTool(ctx, exec, 'load_workspace_dependencies', {});
|
|
102
|
+
}
|
|
103
|
+
exec.signal.throwIfAborted();
|
|
104
|
+
let node;
|
|
105
|
+
if (dependencies?.node !== undefined) node = executablePath(dependencies.node, 'Node.js');
|
|
106
|
+
else if (!process.versions.electron) node = executablePath(process.execPath, 'Node.js');
|
|
107
|
+
else if (ctx.subprocess) node = executablePath(await ctx.subprocess.resolveExecutable('node', undefined, exec.signal), 'Node.js');
|
|
108
|
+
else throw executionError('未找到可用的 Node.js。请安装或配置 DSH 的 Node.js 运行时后重试。', 'DATARC_NODE_UNAVAILABLE');
|
|
109
|
+
|
|
110
|
+
let python = '';
|
|
111
|
+
if (dependencies?.python !== undefined) python = executablePath(dependencies.python, 'Python');
|
|
112
|
+
else if (ctx.subprocess) {
|
|
113
|
+
try {
|
|
114
|
+
python = executablePath(await ctx.subprocess.resolveExecutable('python', undefined, exec.signal), 'Python');
|
|
115
|
+
} catch (error) {
|
|
116
|
+
exec.signal.throwIfAborted();
|
|
117
|
+
if (error?.code !== 'SUBPROCESS_EXECUTABLE_NOT_FOUND') throw error;
|
|
118
|
+
// Only operations requiring Python fail later; Node-only queries stay usable.
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exec.signal.throwIfAborted();
|
|
122
|
+
return { node, python };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Execute only the packaged runner in the caller's current sandbox and directory.
|
|
126
|
+
* Payloads are data, not commands; their schema and operation allowlist belong to
|
|
127
|
+
* the native business tool and runner. Base64 is not encryption: never pass secrets.
|
|
128
|
+
* Background/promoted values are job handles, not final business success.
|
|
129
|
+
*/
|
|
130
|
+
export async function runConfined(
|
|
131
|
+
ctx,
|
|
132
|
+
exec,
|
|
133
|
+
{ script = runnerPath, payload, mode = 'execute', background = false, description = '执行北极九章业务操作', timeoutMs = 10000 } = {},
|
|
134
|
+
) {
|
|
135
|
+
requireExecution(exec);
|
|
136
|
+
if (typeof script !== 'string' || !isAbsolute(script) || script.includes('\0') || resolve(script) !== resolve(runnerPath)) {
|
|
137
|
+
throw executionError('仅允许执行随包业务入口。请检查插件安装资源后重试。', 'DATARC_RUNNER_NOT_ALLOWED');
|
|
138
|
+
}
|
|
139
|
+
if (!allowedModes.has(mode) || typeof background !== 'boolean' || !Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
140
|
+
throw executionError('业务执行方式或等待时间无效。请修正操作参数后重试。', 'DATARC_EXECUTION_ARGUMENT_INVALID');
|
|
141
|
+
}
|
|
142
|
+
if (typeof description !== 'string' || !description.trim()) {
|
|
143
|
+
throw executionError('业务操作缺少说明。请补充操作说明后重试。', 'DATARC_EXECUTION_ARGUMENT_INVALID');
|
|
144
|
+
}
|
|
145
|
+
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
|
|
146
|
+
throw executionError('业务请求必须是结构化对象。请检查操作参数后重试。', 'DATARC_PAYLOAD_INVALID');
|
|
147
|
+
}
|
|
148
|
+
let serialized;
|
|
149
|
+
try {
|
|
150
|
+
serialized = JSON.stringify(payload);
|
|
151
|
+
} catch (error) {
|
|
152
|
+
throw executionError('业务请求不能转换为 JSON。请移除循环引用或不支持的数据类型后重试。', 'DATARC_PAYLOAD_INVALID', error);
|
|
153
|
+
}
|
|
154
|
+
if (typeof serialized !== 'string') {
|
|
155
|
+
throw executionError('业务请求未生成有效 JSON。请检查操作参数后重试。', 'DATARC_PAYLOAD_INVALID');
|
|
156
|
+
}
|
|
157
|
+
const encoded = Buffer.from(serialized, 'utf8').toString('base64url');
|
|
158
|
+
if (!ctx.workingDirectory?.ensure) {
|
|
159
|
+
throw executionError('当前 DSH 缺少会话工作目录服务。请使用完整北极九章预设后重试。', 'DATARC_WORKING_DIRECTORY_UNAVAILABLE');
|
|
160
|
+
}
|
|
161
|
+
const cwd = executablePath(await ctx.workingDirectory.ensure(exec.agent, exec.signal), '会话工作目录');
|
|
162
|
+
const { node, python } = await findRuntimes(ctx, exec);
|
|
163
|
+
const name = process.platform === 'win32' ? 'pwsh' : 'bash';
|
|
164
|
+
const quote = (value) => quoteShellArgument(value, name);
|
|
165
|
+
const argv = [node, runnerPath, mode, encoded].map(quote).join(' ');
|
|
166
|
+
const command =
|
|
167
|
+
name === 'pwsh'
|
|
168
|
+
? `$env:DATARC_WORKSPACE_DIR=${quote(cwd)}; $env:DATARC_NATIVE_PYTHON=${quote(python)}; & ${argv}; exit $LASTEXITCODE`
|
|
169
|
+
: `DATARC_WORKSPACE_DIR=${quote(cwd)} DATARC_NATIVE_PYTHON=${quote(python)} ${argv}`;
|
|
170
|
+
const result = await invokeHostTool(ctx, exec, name, {
|
|
171
|
+
description,
|
|
172
|
+
command,
|
|
173
|
+
workdir: cwd,
|
|
174
|
+
timeoutMs,
|
|
175
|
+
...(background ? { run_in_background: true } : {}),
|
|
176
|
+
});
|
|
177
|
+
if (result?.sandbox?.denied || result?.sandbox?.runnerFailed) {
|
|
178
|
+
throw executionError(
|
|
179
|
+
'当前 DSH 沙箱拒绝了业务脚本或无法运行沙箱。请检查任务所需的文件权限和运行环境后重试;插件不会自动提权。',
|
|
180
|
+
'DATARC_SANDBOX_DENIED',
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
return result;
|
|
184
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Runs through the caller's DSH shell; business operations never run in the Host.
|
|
2
|
+
import { open, realpath } from 'node:fs/promises';
|
|
3
|
+
import { delimiter, dirname, isAbsolute, relative, resolve, sep } from 'node:path';
|
|
4
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
5
|
+
import { spawn } from 'node:child_process';
|
|
6
|
+
import { commandArguments, operationFor, redact } from './native-contracts.js';
|
|
7
|
+
|
|
8
|
+
const root = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const runtimeRoot = resolve(root, 'runtime');
|
|
10
|
+
|
|
11
|
+
export async function executeRequest(payload, options = {}) {
|
|
12
|
+
const { domain, request } = payload;
|
|
13
|
+
const operation = operationFor(domain, request);
|
|
14
|
+
const cwd = options.cwd ?? process.cwd();
|
|
15
|
+
const resources = options.runtimeRoot ?? runtimeRoot;
|
|
16
|
+
const env = {
|
|
17
|
+
...(options.env ?? process.env),
|
|
18
|
+
DATARC_WORKSPACE_DIR: cwd,
|
|
19
|
+
PYTHONUTF8: '1',
|
|
20
|
+
};
|
|
21
|
+
if (operation.builtin) {
|
|
22
|
+
if (operation.builtin !== 'api') throw new Error('操作执行器不存在。请重新读取当前工具目录后重试。');
|
|
23
|
+
const { execute } = await import('./native-api.mjs');
|
|
24
|
+
const cancellation = new AbortController();
|
|
25
|
+
const stop = () => cancellation.abort(new Error('执行已取消,请先核对已执行结果再继续。'));
|
|
26
|
+
process.once('SIGTERM', stop);
|
|
27
|
+
process.once('SIGINT', stop);
|
|
28
|
+
try {
|
|
29
|
+
const result = await execute(domain, request, {
|
|
30
|
+
...options,
|
|
31
|
+
cwd,
|
|
32
|
+
runtimeRoot: resources,
|
|
33
|
+
env,
|
|
34
|
+
signal: options.signal ? AbortSignal.any([options.signal, cancellation.signal]) : cancellation.signal,
|
|
35
|
+
});
|
|
36
|
+
process.stdout.write(JSON.stringify(redact(result)) + '\n');
|
|
37
|
+
if (result?.ok === false) process.exitCode = 1;
|
|
38
|
+
} finally {
|
|
39
|
+
process.removeListener('SIGTERM', stop);
|
|
40
|
+
process.removeListener('SIGINT', stop);
|
|
41
|
+
}
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let file;
|
|
46
|
+
let args;
|
|
47
|
+
if (operation.userPython) {
|
|
48
|
+
file = await realpath(resolve(cwd, request.script_file));
|
|
49
|
+
args = request.args ?? [];
|
|
50
|
+
env.PYTHONPATH = [resolve(resources, 'datarc-data-search/scripts'), env.PYTHONPATH].filter(Boolean).join(delimiter);
|
|
51
|
+
if (request.workspace_id !== undefined) env.DATARC_WORKSPACE_ID = String(request.workspace_id);
|
|
52
|
+
} else {
|
|
53
|
+
file = await realpath(resolve(resources, operation.script));
|
|
54
|
+
const distance = relative(await realpath(resources), file);
|
|
55
|
+
if (distance === '..' || distance.startsWith('..' + sep) || isAbsolute(distance))
|
|
56
|
+
throw new Error('业务脚本不在随包资源内,请重新安装插件后重试。');
|
|
57
|
+
args = commandArguments(operation, request);
|
|
58
|
+
}
|
|
59
|
+
const interpreter = operation.interpreter === 'python' ? env.DATARC_NATIVE_PYTHON : process.execPath;
|
|
60
|
+
if (!interpreter) throw new Error('本次操作需要Python。请配置DSH的Python运行依赖后重试;尚未执行脚本。');
|
|
61
|
+
env.PATH = dirname(process.execPath) + delimiter + (env.PATH ?? '');
|
|
62
|
+
const stdin = operation.stdinParameter ? await open(resolve(cwd, request[operation.stdinParameter]), 'r') : undefined;
|
|
63
|
+
let child;
|
|
64
|
+
const stop = () => child?.kill('SIGTERM');
|
|
65
|
+
const abort = () => stop();
|
|
66
|
+
try {
|
|
67
|
+
options.signal?.throwIfAborted();
|
|
68
|
+
child = spawn(interpreter, [file, ...args], {
|
|
69
|
+
cwd,
|
|
70
|
+
env,
|
|
71
|
+
stdio: stdin ? [stdin.fd, 'inherit', 'inherit'] : 'inherit',
|
|
72
|
+
windowsHide: true,
|
|
73
|
+
});
|
|
74
|
+
process.once('SIGTERM', stop);
|
|
75
|
+
process.once('SIGINT', stop);
|
|
76
|
+
options.signal?.addEventListener('abort', abort, { once: true });
|
|
77
|
+
const code = await new Promise((resolveExit, reject) => {
|
|
78
|
+
child.once('error', reject);
|
|
79
|
+
child.once('exit', (exitCode, signal) => resolveExit(signal ? 1 : (exitCode ?? 1)));
|
|
80
|
+
});
|
|
81
|
+
process.exitCode = code;
|
|
82
|
+
} finally {
|
|
83
|
+
process.removeListener('SIGTERM', stop);
|
|
84
|
+
process.removeListener('SIGINT', stop);
|
|
85
|
+
options.signal?.removeEventListener('abort', abort);
|
|
86
|
+
await stdin?.close();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
91
|
+
try {
|
|
92
|
+
const [mode, encoded] = process.argv.slice(2);
|
|
93
|
+
if (mode !== 'execute' || !encoded || !/^[A-Za-z0-9_-]+$/.test(encoded)) throw new Error('工具执行封包无效,请通过北极九章原生工具重试。');
|
|
94
|
+
await executeRequest(JSON.parse(Buffer.from(encoded, 'base64url').toString('utf8')));
|
|
95
|
+
} catch (error) {
|
|
96
|
+
process.stdout.write(
|
|
97
|
+
JSON.stringify({
|
|
98
|
+
ok: false,
|
|
99
|
+
error: {
|
|
100
|
+
message: redact(String(error.message)),
|
|
101
|
+
nextStep: '检查原流程要求的输入、凭据和权限;结果未知时先回读,不自动重放写入。',
|
|
102
|
+
},
|
|
103
|
+
}) + '\n',
|
|
104
|
+
);
|
|
105
|
+
process.exitCode = 1;
|
|
106
|
+
}
|
|
107
|
+
}
|
package/native-state.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export const initialActivation = () => ({ turn: 0, domain: null, pending: {} });
|
|
2
|
+
|
|
3
|
+
// Visibility is reconstructed from committed calls/results, not mutable Host memory.
|
|
4
|
+
export function foldActivation(state, event, allowedTopics) {
|
|
5
|
+
if (event.type === "turn/start")
|
|
6
|
+
return { turn: event.data.turn, domain: null, pending: {} };
|
|
7
|
+
if (event.type === "turn/end")
|
|
8
|
+
return state.domain === null && !Object.keys(state.pending).length
|
|
9
|
+
? state
|
|
10
|
+
: { ...state, domain: null, pending: {} };
|
|
11
|
+
if (event.type === "tool/call" && event.data.name === "datarc_guide") {
|
|
12
|
+
let request;
|
|
13
|
+
try {
|
|
14
|
+
request = JSON.parse(event.data.arguments);
|
|
15
|
+
} catch {
|
|
16
|
+
return state;
|
|
17
|
+
}
|
|
18
|
+
if (!request || typeof request !== "object" || Array.isArray(request))
|
|
19
|
+
return state;
|
|
20
|
+
if (request.topic !== "overview" && !allowedTopics.includes(request.topic))
|
|
21
|
+
return state;
|
|
22
|
+
const pending = { ...state.pending, [event.data.callId]: request.topic };
|
|
23
|
+
for (const key of Object.keys(pending).slice(0, -32)) delete pending[key];
|
|
24
|
+
return { ...state, pending };
|
|
25
|
+
}
|
|
26
|
+
if (event.type !== "tool/result") return state;
|
|
27
|
+
const message = event.data.message;
|
|
28
|
+
const callId = message?.toolCallId ?? message?.source?.callId;
|
|
29
|
+
if (!Object.hasOwn(state.pending, callId)) return state;
|
|
30
|
+
const pending = { ...state.pending };
|
|
31
|
+
const topic = pending[callId];
|
|
32
|
+
delete pending[callId];
|
|
33
|
+
const next = { ...state, pending };
|
|
34
|
+
if (message.isError || event.data.error || event.data.turn !== state.turn)
|
|
35
|
+
return next;
|
|
36
|
+
try {
|
|
37
|
+
const result = JSON.parse(
|
|
38
|
+
message.content
|
|
39
|
+
.filter((part) => part.type === "text")
|
|
40
|
+
.map((part) => part.text)
|
|
41
|
+
.join(""),
|
|
42
|
+
);
|
|
43
|
+
if (
|
|
44
|
+
result.kind === "datarc-guide" &&
|
|
45
|
+
result.version === 1 &&
|
|
46
|
+
result.topic === topic
|
|
47
|
+
)
|
|
48
|
+
next.domain = topic === "overview" ? null : topic;
|
|
49
|
+
} catch {
|
|
50
|
+
/* Invalid results do not enable capabilities. */
|
|
51
|
+
}
|
|
52
|
+
return next;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function createActivationProjection(z, allowedTopics) {
|
|
56
|
+
return {
|
|
57
|
+
key: "datarcNativeDomain",
|
|
58
|
+
stateVersion: 1,
|
|
59
|
+
stateSchema: z.object({
|
|
60
|
+
turn: z.number().int(),
|
|
61
|
+
domain: z.string().nullable(),
|
|
62
|
+
pending: z.record(z.string(), z.string()),
|
|
63
|
+
}),
|
|
64
|
+
init: initialActivation,
|
|
65
|
+
apply: (state, event) => foldActivation(state, event, allowedTopics),
|
|
66
|
+
};
|
|
67
|
+
}
|
package/native-tools.js
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { readFile, realpath } from 'node:fs/promises';
|
|
2
|
+
import { dirname, isAbsolute, relative, resolve, sep } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { domains, operationFor, redact, requestSchema } from './native-contracts.js';
|
|
5
|
+
import { runConfined } from './native-execution.js';
|
|
6
|
+
import { createActivationProjection } from './native-state.js';
|
|
7
|
+
|
|
8
|
+
export const inject = ['tools', 'sessionProjections', 'workingDirectory'];
|
|
9
|
+
const root = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const output = {
|
|
11
|
+
schema: { type: 'object', additionalProperties: true },
|
|
12
|
+
render: (_args, value) => [{ type: 'text', text: JSON.stringify(value, null, 2) }],
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function checkOwner(exec) {
|
|
16
|
+
if (!exec.agent?.session || !exec.signal) throw new Error('缺少当前会话身份。请在 DSH 原生会话中重新发起操作。');
|
|
17
|
+
exec.signal.throwIfAborted();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function readGuide(args, options = {}) {
|
|
21
|
+
if (
|
|
22
|
+
!args ||
|
|
23
|
+
typeof args !== 'object' ||
|
|
24
|
+
Array.isArray(args) ||
|
|
25
|
+
Object.keys(args).some((key) => !['topic', 'document', 'offset', 'limit'].includes(key))
|
|
26
|
+
)
|
|
27
|
+
throw new Error('流程读取参数无效。请使用公布的业务域、文档和分页参数。');
|
|
28
|
+
const topic = args.topic;
|
|
29
|
+
if (topic !== 'overview' && !Object.hasOwn(domains, topic)) throw new Error('业务域不存在。请先读取 overview,再选择受支持的业务域。');
|
|
30
|
+
const base = { kind: 'datarc-guide', version: 1, topic };
|
|
31
|
+
if (topic === 'overview')
|
|
32
|
+
return {
|
|
33
|
+
...base,
|
|
34
|
+
domains: Object.entries(domains).map(([key, domain]) => ({
|
|
35
|
+
topic: key,
|
|
36
|
+
title: domain.title,
|
|
37
|
+
description: domain.description,
|
|
38
|
+
})),
|
|
39
|
+
nextStep: '仅在目标确为北极九章时选业务域。读取流程不会执行业务请求;操作工具将在成功读取后的下一模型步骤开放。',
|
|
40
|
+
};
|
|
41
|
+
const domain = domains[topic];
|
|
42
|
+
const packageRoot = options.root ?? root;
|
|
43
|
+
const index = JSON.parse(
|
|
44
|
+
await readFile(resolve(packageRoot, 'workflow-index.json'), {
|
|
45
|
+
encoding: 'utf8',
|
|
46
|
+
signal: options.signal,
|
|
47
|
+
}),
|
|
48
|
+
);
|
|
49
|
+
const documents = index.documents.filter((entry) => domain.workflows.includes(entry.workflow));
|
|
50
|
+
const document = args.document ?? documents.find((entry) => entry.workflow === domain.workflows[0] && entry.path.endsWith('/SKILL.md'))?.path;
|
|
51
|
+
if (!documents.some((entry) => entry.path === document))
|
|
52
|
+
throw new Error('文档不属于当前业务域。请从该域返回的 documents 清单选择,不读取任意路径。');
|
|
53
|
+
const path = await realpath(resolve(packageRoot, 'runtime', document));
|
|
54
|
+
const distance = relative(await realpath(resolve(packageRoot, 'runtime')), path);
|
|
55
|
+
if (distance === '..' || distance.startsWith('..' + sep) || isAbsolute(distance) || !path.endsWith('.md'))
|
|
56
|
+
throw new Error('内部文档路径无效。请重新安装插件后重试。');
|
|
57
|
+
const offset = args.offset ?? 1;
|
|
58
|
+
const limit = args.limit ?? 100;
|
|
59
|
+
if (!Number.isInteger(offset) || offset < 1 || !Number.isInteger(limit) || limit < 1 || limit > 160)
|
|
60
|
+
throw new Error('分页范围无效。offset 从 1 开始,limit 为 1–160 行。');
|
|
61
|
+
const lines = (await readFile(path, { encoding: 'utf8', signal: options.signal }))
|
|
62
|
+
.replace(/^---\r?\n[\s\S]*?\r?\n---(?:\r?\n|$)/, '')
|
|
63
|
+
.split(/\r?\n/);
|
|
64
|
+
let instructions = lines
|
|
65
|
+
.slice(offset - 1, offset - 1 + limit)
|
|
66
|
+
.map((line, i) => `${offset + i}: ${line}`)
|
|
67
|
+
.join('\n');
|
|
68
|
+
const truncated = instructions.length > 16000;
|
|
69
|
+
if (truncated) instructions = instructions.slice(0, 16000);
|
|
70
|
+
return {
|
|
71
|
+
...base,
|
|
72
|
+
document,
|
|
73
|
+
offset,
|
|
74
|
+
totalLines: lines.length,
|
|
75
|
+
nextOffset:
|
|
76
|
+
offset - 1 + limit < lines.length || truncated ? offset + (truncated ? Math.max(1, instructions.split('\n').length - 1) : limit) : null,
|
|
77
|
+
adaptation:
|
|
78
|
+
'下文是内部业务规范,不是可调用的 skill。提到子技能时用 datarc_guide 读取对应流程;CLI 示例对应原生工具的同名业务操作,不直接调用终端或拼接 API。保留原始审批、预检、证据、回读和停止规则。按原流程在规定时点取得用户确认;封装不对每个操作重复弹出确认。',
|
|
79
|
+
instructions,
|
|
80
|
+
documents: documents.map((entry) => entry.path),
|
|
81
|
+
...(domain.inputContracts ? { inputContracts: domain.inputContracts } : {}),
|
|
82
|
+
tool: 'datarc_' + topic,
|
|
83
|
+
operations: Object.entries(domain.operations).map(([operation, spec]) => ({
|
|
84
|
+
operation,
|
|
85
|
+
description: spec.description ?? operation,
|
|
86
|
+
changesState: spec.write === true,
|
|
87
|
+
})),
|
|
88
|
+
sharedTools: ['datarc_auth', 'datarc_workspace'],
|
|
89
|
+
nextStep:
|
|
90
|
+
'下一模型步骤可使用本域工具及认证/工作区工具。更换任务域需重新读取对应 guide;每个新 Turn 重新读取所需流程。查询/进程完成不等于报告或配置业务验收通过。',
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function summarizeExecution(execution) {
|
|
95
|
+
if (!execution || typeof execution !== 'object') throw new Error('执行结果无效。请检查 DSH 连接和当前任务,不要重复提交写入。');
|
|
96
|
+
if (['background', 'promoted'].includes(execution.kind))
|
|
97
|
+
return {
|
|
98
|
+
ok: true,
|
|
99
|
+
status: 'running',
|
|
100
|
+
jobId: execution.jobId,
|
|
101
|
+
execution,
|
|
102
|
+
nextStep: '使用 job_output 读取该任务直到终态。jobId 不是业务成功;取消本地进程不等于远端任务已停止。',
|
|
103
|
+
};
|
|
104
|
+
const text = execution.stdout?.text ?? '';
|
|
105
|
+
let parsed;
|
|
106
|
+
try {
|
|
107
|
+
parsed = JSON.parse(text.trim());
|
|
108
|
+
} catch {
|
|
109
|
+
const lines = text.trim().split(/\r?\n/);
|
|
110
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
111
|
+
try {
|
|
112
|
+
const value = JSON.parse(lines[i]);
|
|
113
|
+
if (value && typeof value === 'object') {
|
|
114
|
+
parsed = value;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
} catch {
|
|
118
|
+
/* Mixed progress output is retained below. */
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const businessStatus = parsed?.data?.status ?? parsed?.status;
|
|
123
|
+
const partial = ['STOPPED', 'BLOCKED'].includes(businessStatus);
|
|
124
|
+
const pending = ['WAITING_AUTOMATION', 'CREATED_PENDING_APPROVAL', 'pending', 'collecting', 'generating'].includes(businessStatus);
|
|
125
|
+
const failed =
|
|
126
|
+
execution.exitCode !== 0 ||
|
|
127
|
+
execution.aborted ||
|
|
128
|
+
execution.timedOut ||
|
|
129
|
+
execution.sandbox?.denied ||
|
|
130
|
+
execution.sandbox?.runnerFailed ||
|
|
131
|
+
parsed?.ok === false ||
|
|
132
|
+
businessStatus === 'failed';
|
|
133
|
+
return {
|
|
134
|
+
ok: !failed && !partial,
|
|
135
|
+
status: failed
|
|
136
|
+
? 'failed-or-unknown'
|
|
137
|
+
: partial
|
|
138
|
+
? 'partial-or-blocked'
|
|
139
|
+
: pending
|
|
140
|
+
? 'awaiting-business-verification'
|
|
141
|
+
: execution.stdout?.truncated
|
|
142
|
+
? 'output-truncated'
|
|
143
|
+
: 'completed',
|
|
144
|
+
...(parsed === undefined ? {} : { result: parsed }),
|
|
145
|
+
execution,
|
|
146
|
+
nextStep:
|
|
147
|
+
failed || partial || pending
|
|
148
|
+
? '业务结果尚未完整通过。先只读核对结果、进度和实际状态;不要自动重放写入或继续覆盖式变更。'
|
|
149
|
+
: execution.stdout?.truncated
|
|
150
|
+
? '输出被截断,请读取 spillPath 后再核对完整结果,不能只用预览宣布成功。'
|
|
151
|
+
: '按内部流程核对业务结果和证据;进程退出成功不代表业务验收通过。',
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export async function executeBusinessOperation(ctx, exec, domain, args, run = runConfined) {
|
|
156
|
+
checkOwner(exec);
|
|
157
|
+
if (
|
|
158
|
+
!args ||
|
|
159
|
+
typeof args !== 'object' ||
|
|
160
|
+
Array.isArray(args) ||
|
|
161
|
+
Object.keys(args).some((key) => !['request', 'background'].includes(key)) ||
|
|
162
|
+
(args.background !== undefined && typeof args.background !== 'boolean')
|
|
163
|
+
)
|
|
164
|
+
throw new Error('业务工具参数无效。请使用结构化 request 和可选 background 参数。');
|
|
165
|
+
const operation = operationFor(domain, args.request);
|
|
166
|
+
// Confirmation belongs to the original skill workflow, not every adapter call.
|
|
167
|
+
// The caller still goes through DSH admission, sandbox and cancellation.
|
|
168
|
+
const payload = { domain, request: args.request };
|
|
169
|
+
const execution = await run(ctx, exec, {
|
|
170
|
+
mode: 'execute',
|
|
171
|
+
payload,
|
|
172
|
+
description: `北极九章 ${domain} ${args.request.operation}`,
|
|
173
|
+
background: args.background ?? operation.background ?? (domain === 'auth' && args.request.operation === 'login'),
|
|
174
|
+
});
|
|
175
|
+
return redact({
|
|
176
|
+
...summarizeExecution(execution),
|
|
177
|
+
domain,
|
|
178
|
+
operation: args.request.operation,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export async function apply(ctx) {
|
|
183
|
+
const { z } = await import('zod');
|
|
184
|
+
const topics = Object.keys(domains);
|
|
185
|
+
const activation = await ctx.sessionProjections.register(createActivationProjection(z, topics));
|
|
186
|
+
ctx.tools.register({
|
|
187
|
+
name: 'datarc_guide',
|
|
188
|
+
description:
|
|
189
|
+
'读取北极九章业务流程与操作目录,按需开放当前任务域的原生工具;不登录或执行业务请求。宿主可信上下文确认实际使用 datarc 专属预设时,普通业务问数默认北极九章,不重复确认平台;其他预设下目标不明仍先判别平台。用户明确指定其他平台或本地文件时遵从。',
|
|
190
|
+
parameters: {
|
|
191
|
+
type: 'object',
|
|
192
|
+
additionalProperties: false,
|
|
193
|
+
properties: {
|
|
194
|
+
topic: { type: 'string', enum: ['overview', ...topics] },
|
|
195
|
+
document: {
|
|
196
|
+
type: 'string',
|
|
197
|
+
description: '仅使用本域 documents 返回的路径;省略则读取主流程。',
|
|
198
|
+
},
|
|
199
|
+
offset: { type: 'integer', description: '起始行,从1开始。' },
|
|
200
|
+
limit: { type: 'integer', description: '1–160行;默认100行。' },
|
|
201
|
+
},
|
|
202
|
+
required: ['topic'],
|
|
203
|
+
},
|
|
204
|
+
output,
|
|
205
|
+
async execute(args, exec) {
|
|
206
|
+
checkOwner(exec);
|
|
207
|
+
return readGuide(args, { signal: exec.signal });
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
for (const [domain, spec] of Object.entries(domains)) {
|
|
211
|
+
ctx.tools.register(
|
|
212
|
+
{
|
|
213
|
+
name: 'datarc_' + domain,
|
|
214
|
+
description: spec.description + '。沿用原技能的权限、确认时点和结果核验;工具只适配操作参数,不重复审批。',
|
|
215
|
+
parameters: {
|
|
216
|
+
type: 'object',
|
|
217
|
+
additionalProperties: false,
|
|
218
|
+
properties: {
|
|
219
|
+
request: requestSchema(domain),
|
|
220
|
+
background: {
|
|
221
|
+
type: 'boolean',
|
|
222
|
+
description: '后台执行并返回DSH jobId;必须跟踪到终态,不能把句柄当业务成功。',
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
required: ['request'],
|
|
226
|
+
},
|
|
227
|
+
output,
|
|
228
|
+
async execute(args, exec) {
|
|
229
|
+
return executeBusinessOperation(ctx, exec, domain, args);
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
when: ({ agent, signal }) => {
|
|
234
|
+
signal.throwIfAborted();
|
|
235
|
+
const selected = activation.stateOf(agent.session).domain;
|
|
236
|
+
return selected !== null && (domain === selected || ['auth', 'workspace'].includes(domain));
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
}
|