@xdxer/dingtalk-agent 0.1.4-beta.13 → 0.1.4-beta.15

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.
@@ -18,11 +18,13 @@ export const MANAGED_AGENT_PLATFORMS = [
18
18
  status: 'supported',
19
19
  description: '钉钉 Multica 托管平台:供给、部署、钉钉机器人绑定、观测与调度。',
20
20
  skills: [
21
- { role: 'deploy', name: 'dingtalk-agent-deploy-multica' },
22
- { role: 'boot', name: 'dingtalk-agent-boot-multica' },
23
- { role: 'ops', name: 'multica-external' },
21
+ { role: 'deploy', name: 'dingtalk-agent-deploy-multica', purpose: '经 dta 稳定 CLI 受控部署/晋级/观测到 Multica' },
22
+ { role: 'boot', name: 'dingtalk-agent-boot-multica', purpose: '部署产物在 Multica Host 内每次任务的启动协议' },
23
+ { role: 'ops', name: 'multica-external', purpose: '平台运维执行体:供给/绑定机器人/观测/调度(纯 HTTPS)' },
24
24
  ],
25
25
  commands: ['deploy', 'promote', 'observe'],
26
+ suggestedEndpoint: 'https://pre-fde-workbench.dingtalk.com',
27
+ endpointEnv: 'MULTICA_SERVER_URL',
26
28
  },
27
29
  {
28
30
  name: 'deap',
@@ -133,14 +135,71 @@ export function platformSkillForRole(platformName, role) {
133
135
  const definition = agentPlatformDefinition(platformName);
134
136
  return definition?.skills.find((item) => item.role === role)?.name || null;
135
137
  }
138
+ const PLATFORM_DIRS = {
139
+ 'multica-dingtalk': 'skills/platforms/multica-dingtalk',
140
+ deap: 'skills/platforms/deap',
141
+ };
142
+ /** 平台说明文档(PLATFORM.md)在包内的路径;切换到该平台时应加载让维护者/Agent 知道各技能用途。 */
143
+ export function platformDocPath(packageRoot, platformName) {
144
+ const dir = PLATFORM_DIRS[platformName];
145
+ if (!dir)
146
+ return null;
147
+ const path = join(packageRoot, dir, 'PLATFORM.md');
148
+ return existsSync(path) ? path : null;
149
+ }
150
+ export function readPlatformDoc(packageRoot, platformName) {
151
+ const path = platformDocPath(packageRoot, platformName);
152
+ return path ? readFileSync(path, 'utf8') : '';
153
+ }
136
154
  export function statusLabel(status) {
137
155
  return status === 'supported' ? '已支持' : '敬请期待';
138
156
  }
157
+ /**
158
+ * 解析平台 endpoint,与真实执行体(multica_ext.py 读 MULTICA_SERVER_URL/--profile)同源,
159
+ * 不新造命名空间、不静默默认连预发。顺序:
160
+ * MULTICA_SERVER_URL 环境变量 > 项目 config(dingtalk-agent.json#multicaEndpoint /
161
+ * .dingtalk-agent/agent-platform.json.endpoint)> 恰好一个已登录 profile 的 server_url
162
+ * (多个则 ambiguous,不自动挑)> suggestedEndpoint(仅建议,未确认)。
163
+ */
164
+ export function resolveEndpoint(platformName, start = process.cwd(), env = process.env, home = homedir()) {
165
+ const definition = agentPlatformDefinition(platformName);
166
+ const envVar = definition?.endpointEnv || 'MULTICA_SERVER_URL';
167
+ const base = { envVar, candidates: [] };
168
+ const fromEnv = String(env[envVar] || '').trim();
169
+ if (fromEnv)
170
+ return { endpoint: fromEnv, source: 'env', confirmed: true, ...base };
171
+ const fromConfig = projectEndpoint(start);
172
+ if (fromConfig)
173
+ return { endpoint: fromConfig, source: 'project-config', confirmed: true, ...base };
174
+ const serverUrls = [...new Set(multicaTargets(home)
175
+ .map((target) => target.serverUrl.trim()).filter(Boolean))];
176
+ if (serverUrls.length === 1) {
177
+ return { endpoint: serverUrls[0], source: 'profile', confirmed: true, ...base };
178
+ }
179
+ if (serverUrls.length > 1) {
180
+ return { endpoint: '', source: 'ambiguous', confirmed: false, ...base, candidates: serverUrls };
181
+ }
182
+ if (definition?.suggestedEndpoint) {
183
+ return { endpoint: definition.suggestedEndpoint, source: 'suggested', confirmed: false, ...base };
184
+ }
185
+ return { endpoint: '', source: 'none', confirmed: false, ...base };
186
+ }
187
+ function projectEndpoint(start) {
188
+ const projectRoot = findAgentProjectRoot(start);
189
+ if (!projectRoot)
190
+ return '';
191
+ const manifest = readJsonOrNull(join(projectRoot, PROJECT_FILE));
192
+ const fromManifest = typeof manifest?.multicaEndpoint === 'string' ? manifest.multicaEndpoint.trim() : '';
193
+ if (fromManifest)
194
+ return fromManifest;
195
+ const platform = readJsonOrNull(join(projectRoot, AGENT_PLATFORM_FILE));
196
+ return typeof platform?.endpoint === 'string' ? platform.endpoint.trim() : '';
197
+ }
139
198
  /**
140
199
  * 平台工具链就绪检查(只读,不阻断):选择/查看平台归属时提示用户缺什么、怎么补。
141
200
  * 强制门禁仍由 requireSupportedAgentPlatform 与各平台命令自身承担。
142
201
  */
143
- export function agentPlatformReadiness(name, env = process.env, home = homedir()) {
202
+ export function agentPlatformReadiness(name, env = process.env, home = homedir(), start = process.cwd()) {
144
203
  if (name !== 'multica-dingtalk')
145
204
  return [];
146
205
  const checks = [];
@@ -151,11 +210,15 @@ export function agentPlatformReadiness(name, env = process.env, home = homedir()
151
210
  id: 'multica-cli', ok: false, summary: '未找到 multica CLI',
152
211
  hint: '安装:curl -fsSL https://raw.githubusercontent.com/multica-ai/multica/main/scripts/install.sh | bash',
153
212
  });
213
+ const ep = resolveEndpoint(name, start, env, home);
214
+ const loginTarget = ep.endpoint || '<endpoint>';
215
+ const suffix = ep.confirmed ? '' : '(未确认,请核对是预发还是生产)';
154
216
  checks.push(hasMulticaToken(home)
155
217
  ? { id: 'multica-login', ok: true, summary: 'Multica 已登录(本地存在 token)' }
156
218
  : {
157
219
  id: 'multica-login', ok: false, summary: 'Multica 尚未登录',
158
- hint: '登录:multica login --server-url <endpoint>(预发环境为 https://pre-fde-workbench.dingtalk.com)',
220
+ hint: `登录:multica login --server-url ${loginTarget} --token <你的 mul_ PAT>` +
221
+ `(endpoint 来源 ${ep.source}${suffix};用 MULTICA_SERVER_URL 或登录别的 profile 可切换)`,
159
222
  });
160
223
  if (['HTTPS_PROXY', 'https_proxy', 'ALL_PROXY', 'all_proxy'].some((key) => env[key])) {
161
224
  checks.push({
@@ -1 +1 @@
1
- {"version":3,"file":"agent-platform.js","sourceRoot":"","sources":["../../src/agent-platform.ts"],"names":[],"mappings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OAAO,EAAE,4CAA4C;QACrD,QAAQ,EAAE,IAAI;QACd,MAAM;QACN,IAAI;QACJ,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;QACvD,SAAS,EAAE,uBAAuB;KACnC,CAAA;AACH,CAAC;AAED,SAAS,cAAc,CAAC,IAAY;IAClC,IAAI,CAAC;QAAC,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAA;IAAC,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,IAAI,CAAA;IAAC,CAAC;AAC7E,CAAC;AAED,SAAS,MAAM,CAAC,KAAa,EAAE,YAAoB;IACjD,IAAI,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;IACxB,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAA;QACzC,IAAI,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,cAAc,EAAE;YAAE,OAAO,SAAS,CAAA;QACrF,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;QAC3B,IAAI,MAAM,KAAK,GAAG,IAAI,GAAG,KAAK,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI;YAAE,OAAO,IAAI,CAAA;QAC1D,GAAG,GAAG,MAAM,CAAA;IACd,CAAC;AACH,CAAC","sourcesContent":["// Managed Agent Platform 注册表与工作区归属解析。\n//\n// 一个 Agent 工作区归属于至多一个托管平台;归属解析顺序固定:\n// DTA_AGENT_PLATFORM 环境变量 > dingtalk-agent.json#agentPlatform\n// > .dingtalk-agent/agent-platform.json > 按 Provider 声明推断。\n// 平台相关的方法学不写进 CLI——它们随对应平台的 Skill 包分发,只在用户选择该平台时安装。\n// 平台命令(如 deploy/promote/observe)必须先通过归属门禁;coming-soon 平台一律 fail-closed。\n\nimport { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs'\nimport { homedir } from 'node:os'\nimport { dirname, join, parse, resolve } from 'node:path'\n\nimport { findAgentProjectRoot } from './development-workspace.js'\nimport { findExecutable } from './doctor.js'\nimport { installGlobalSkill, type GlobalSkillStatus } from './skill-manager.js'\n\nexport type AgentPlatformStatus = 'supported' | 'coming-soon'\n\nexport interface AgentPlatformSkillBinding {\n role: string\n name: string\n}\n\nexport interface AgentPlatformDefinition {\n name: string\n label: string\n status: AgentPlatformStatus\n description: string\n skills: AgentPlatformSkillBinding[]\n commands: string[]\n}\n\nexport const MANAGED_AGENT_PLATFORMS: AgentPlatformDefinition[] = [\n {\n name: 'multica-dingtalk',\n label: 'Multica (DingTalk)',\n status: 'supported',\n description: '钉钉 Multica 托管平台:供给、部署、钉钉机器人绑定、观测与调度。',\n skills: [\n { role: 'deploy', name: 'dingtalk-agent-deploy-multica' },\n { role: 'boot', name: 'dingtalk-agent-boot-multica' },\n { role: 'ops', name: 'multica-external' },\n ],\n commands: ['deploy', 'promote', 'observe'],\n },\n {\n name: 'deap',\n label: 'DEAP',\n status: 'coming-soon',\n description: '敬请期待。',\n skills: [],\n commands: [],\n },\n]\n\nexport const AGENT_PLATFORM_FILE = '.dingtalk-agent/agent-platform.json'\nconst PROJECT_FILE = 'dingtalk-agent.json'\n\nexport type AgentPlatformSource = 'env' | 'project-manifest' | 'platform-file' | 'inferred' | 'none'\n\nexport interface AgentPlatformResolution {\n $schema: 'dingtalk-agent/agent-platform-resolution@1'\n platform: string | null\n source: AgentPlatformSource\n file: string\n definition: AgentPlatformDefinition | null\n platforms: AgentPlatformDefinition[]\n}\n\nexport interface AgentPlatformUseResult extends AgentPlatformResolution {\n written: string\n skillInstalls: GlobalSkillStatus[]\n}\n\nexport function agentPlatformDefinition(name: string): AgentPlatformDefinition | null {\n return MANAGED_AGENT_PLATFORMS.find((item) => item.name === name) || null\n}\n\nexport function resolveAgentPlatform(\n start = process.cwd(), env: NodeJS.ProcessEnv = process.env,\n): AgentPlatformResolution {\n const fromEnv = String(env.DTA_AGENT_PLATFORM || '').trim()\n if (fromEnv) return resolution(fromEnv, 'env', '')\n\n const projectRoot = findAgentProjectRoot(start)\n if (projectRoot) {\n const manifestPath = join(projectRoot, PROJECT_FILE)\n if (existsSync(manifestPath) && !lstatSync(manifestPath).isSymbolicLink()) {\n const manifest = readJsonOrNull(manifestPath)\n const declared = typeof manifest?.agentPlatform === 'string' ? manifest.agentPlatform.trim() : ''\n if (declared) return resolution(declared, 'project-manifest', manifestPath)\n }\n }\n\n const platformPath = findUp(start, AGENT_PLATFORM_FILE)\n if (platformPath) {\n const stored = readJsonOrNull(platformPath)\n const declared = typeof stored?.agentPlatform === 'string' ? stored.agentPlatform.trim() : ''\n if (declared) return resolution(declared, 'platform-file', platformPath)\n }\n\n if (projectRoot) {\n const manifest = readJsonOrNull(join(projectRoot, PROJECT_FILE))\n const providers = Object.values(manifest?.workspaces || {})\n .map((workspace: any) => workspace?.provider?.kind)\n if (providers.includes('multica')) {\n return resolution('multica-dingtalk', 'inferred', join(projectRoot, PROJECT_FILE))\n }\n }\n\n return resolution(null, 'none', '')\n}\n\nexport interface AgentPlatformUseOptions {\n packageRoot: string\n home?: string\n env?: NodeJS.ProcessEnv\n installSkills?: boolean\n}\n\nexport function useAgentPlatform(\n start: string, name: string, options: AgentPlatformUseOptions,\n): AgentPlatformUseResult {\n const definition = agentPlatformDefinition(name)\n if (!definition) {\n throw new Error(\n `未知 managed agent platform: ${name}\\n` +\n `可用: ${MANAGED_AGENT_PLATFORMS.map((item) => `${item.name}(${statusLabel(item.status)})`).join('、')}`,\n )\n }\n if (definition.status !== 'supported') {\n throw new Error(`${definition.label} 敬请期待——当前版本尚未开放该平台。`)\n }\n\n const projectRoot = findAgentProjectRoot(start)\n let written: string\n if (projectRoot && existsSync(join(projectRoot, PROJECT_FILE))) {\n const manifestPath = join(projectRoot, PROJECT_FILE)\n if (lstatSync(manifestPath).isSymbolicLink()) {\n throw new Error(`${PROJECT_FILE} 不能是符号链接`)\n }\n const manifest = readJsonOrNull(manifestPath)\n if (!manifest || typeof manifest !== 'object') {\n throw new Error(`${PROJECT_FILE} 不是合法 JSON,无法写入 agentPlatform 归属`)\n }\n manifest.agentPlatform = definition.name\n writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + '\\n')\n written = manifestPath\n } else {\n const target = join(resolve(start), AGENT_PLATFORM_FILE)\n mkdirSync(dirname(target), { recursive: true })\n writeFileSync(target, JSON.stringify(\n { $schema: 'dingtalk-agent/agent-platform@1', agentPlatform: definition.name }, null, 2,\n ) + '\\n')\n written = target\n }\n\n const skillInstalls: GlobalSkillStatus[] = []\n if (options.installSkills !== false) {\n for (const skill of definition.skills) {\n skillInstalls.push(installGlobalSkill(options.packageRoot, {\n name: skill.name, home: options.home, env: options.env,\n }))\n }\n }\n\n return { ...resolveAgentPlatform(start, options.env || process.env), written, skillInstalls }\n}\n\n/** deploy/promote/observe 等平台命令的归属门禁:未归属、未知或 coming-soon 一律 fail-closed。 */\nexport function requireSupportedAgentPlatform(\n command: string, start = process.cwd(), env: NodeJS.ProcessEnv = process.env,\n): AgentPlatformResolution {\n const resolved = resolveAgentPlatform(start, env)\n if (!resolved.platform) {\n throw new Error(\n `当前工作区未声明 managed agent platform,无法执行 \\`${command}\\`。\\n` +\n '先运行 `dta agent-platform use multica-dingtalk`,或设置 DTA_AGENT_PLATFORM 环境变量。',\n )\n }\n if (!resolved.definition) {\n throw new Error(\n `工作区声明了未知 platform: ${resolved.platform}(来源 ${resolved.source})。\\n` +\n `可用: ${MANAGED_AGENT_PLATFORMS.map((item) => item.name).join('、')}`,\n )\n }\n if (resolved.definition.status !== 'supported') {\n throw new Error(`${resolved.definition.label} 敬请期待——\\`${command}\\` 尚未在该平台开放。`)\n }\n if (!resolved.definition.commands.includes(command)) {\n throw new Error(`${resolved.definition.label} 不承接命令 \\`${command}\\`。`)\n }\n return resolved\n}\n\n/** dta 层的平台命令/角色(deploy、boot、ops…)关联到该平台内确切的 Skill 名。 */\nexport function platformSkillForRole(platformName: string, role: string): string | null {\n const definition = agentPlatformDefinition(platformName)\n return definition?.skills.find((item) => item.role === role)?.name || null\n}\n\nexport function statusLabel(status: AgentPlatformStatus): string {\n return status === 'supported' ? '已支持' : '敬请期待'\n}\n\nexport interface AgentPlatformReadinessCheck {\n id: string\n ok: boolean\n summary: string\n hint?: string\n}\n\n/**\n * 平台工具链就绪检查(只读,不阻断):选择/查看平台归属时提示用户缺什么、怎么补。\n * 强制门禁仍由 requireSupportedAgentPlatform 与各平台命令自身承担。\n */\nexport function agentPlatformReadiness(\n name: string, env: NodeJS.ProcessEnv = process.env, home = homedir(),\n): AgentPlatformReadinessCheck[] {\n if (name !== 'multica-dingtalk') return []\n const checks: AgentPlatformReadinessCheck[] = []\n const cli = findExecutable('multica', env)\n checks.push(cli\n ? { id: 'multica-cli', ok: true, summary: `multica CLI 已安装(${cli})` }\n : {\n id: 'multica-cli', ok: false, summary: '未找到 multica CLI',\n hint: '安装:curl -fsSL https://raw.githubusercontent.com/multica-ai/multica/main/scripts/install.sh | bash',\n })\n checks.push(hasMulticaToken(home)\n ? { id: 'multica-login', ok: true, summary: 'Multica 已登录(本地存在 token)' }\n : {\n id: 'multica-login', ok: false, summary: 'Multica 尚未登录',\n hint: '登录:multica login --server-url <endpoint>(预发环境为 https://pre-fde-workbench.dingtalk.com)',\n })\n if (['HTTPS_PROXY', 'https_proxy', 'ALL_PROXY', 'all_proxy'].some((key) => env[key])) {\n checks.push({\n id: 'proxy-env', ok: false, summary: '检测到代理环境变量,可能阻断 Multica 直连',\n hint: '连接失败时用 env -u HTTPS_PROXY -u https_proxy -u ALL_PROXY -u all_proxy 运行 multica 与平台脚本',\n })\n }\n return checks\n}\n\nexport interface MulticaTarget {\n profile: string\n serverUrl: string\n workspaceId: string\n}\n\n/**\n * 本机已登录的 Multica 目标清单(default 配置 + 各 profile)。只暴露 endpoint 与\n * workspace 标识,不读取 token 内容。发布前必须把候选交给用户选择,绝不默默用默认配置。\n */\nexport function multicaTargets(home = homedir()): MulticaTarget[] {\n const targets: MulticaTarget[] = []\n const push = (profile: string, path: string) => {\n const config = readJsonOrNull(path)\n if (typeof config?.token === 'string' && config.token.trim()) {\n targets.push({\n profile,\n serverUrl: String(config.server_url || ''),\n workspaceId: String(config.workspace_id || ''),\n })\n }\n }\n push('default', join(home, '.multica', 'config.json'))\n try {\n for (const entry of readdirSync(join(home, '.multica', 'profiles'))) {\n push(entry, join(home, '.multica', 'profiles', entry, 'config.json'))\n }\n } catch { /* profiles 目录不存在 */ }\n return targets\n}\n\nfunction hasMulticaToken(home: string): boolean {\n const candidates = [join(home, '.multica', 'config.json')]\n try {\n for (const entry of readdirSync(join(home, '.multica', 'profiles'))) {\n candidates.push(join(home, '.multica', 'profiles', entry, 'config.json'))\n }\n } catch { /* profiles 目录不存在 */ }\n return candidates.some((path) => {\n const config = readJsonOrNull(path)\n return typeof config?.token === 'string' && config.token.trim().length > 0\n })\n}\n\nfunction resolution(\n name: string | null, source: AgentPlatformSource, file: string,\n): AgentPlatformResolution {\n return {\n $schema: 'dingtalk-agent/agent-platform-resolution@1',\n platform: name,\n source,\n file,\n definition: name ? agentPlatformDefinition(name) : null,\n platforms: MANAGED_AGENT_PLATFORMS,\n }\n}\n\nfunction readJsonOrNull(path: string): any {\n try { return JSON.parse(readFileSync(path, 'utf8')) } catch { return null }\n}\n\nfunction findUp(start: string, relativePath: string): string | null {\n let dir = resolve(start)\n while (true) {\n const candidate = join(dir, relativePath)\n if (existsSync(candidate) && !lstatSync(candidate).isSymbolicLink()) return candidate\n const parent = dirname(dir)\n if (parent === dir || dir === parse(dir).root) return null\n dir = parent\n }\n}\n"]}
1
+ {"version":3,"file":"agent-platform.js","sourceRoot":"","sources":["../../src/agent-platform.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,oCAAoC;AACpC,gEAAgE;AAChE,6DAA6D;AAC7D,o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AClC,IAAI,CAAC;QAAC,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAA;IAAC,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,IAAI,CAAA;IAAC,CAAC;AAC7E,CAAC;AAED,SAAS,MAAM,CAAC,KAAa,EAAE,YAAoB;IACjD,IAAI,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;IACxB,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAA;QACzC,IAAI,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,cAAc,EAAE;YAAE,OAAO,SAAS,CAAA;QACrF,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;QAC3B,IAAI,MAAM,KAAK,GAAG,IAAI,GAAG,KAAK,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI;YAAE,OAAO,IAAI,CAAA;QAC1D,GAAG,GAAG,MAAM,CAAA;IACd,CAAC;AACH,CAAC","sourcesContent":["// Managed Agent Platform 注册表与工作区归属解析。\n//\n// 一个 Agent 工作区归属于至多一个托管平台;归属解析顺序固定:\n// DTA_AGENT_PLATFORM 环境变量 > dingtalk-agent.json#agentPlatform\n// > .dingtalk-agent/agent-platform.json > 按 Provider 声明推断。\n// 平台相关的方法学不写进 CLI——它们随对应平台的 Skill 包分发,只在用户选择该平台时安装。\n// 平台命令(如 deploy/promote/observe)必须先通过归属门禁;coming-soon 平台一律 fail-closed。\n\nimport { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs'\nimport { homedir } from 'node:os'\nimport { dirname, join, parse, resolve } from 'node:path'\n\nimport { findAgentProjectRoot } from './development-workspace.js'\nimport { findExecutable } from './doctor.js'\nimport { installGlobalSkill, type GlobalSkillStatus } from './skill-manager.js'\n\nexport type AgentPlatformStatus = 'supported' | 'coming-soon'\n\nexport interface AgentPlatformSkillBinding {\n role: string\n name: string\n purpose: string\n}\n\nexport interface AgentPlatformDefinition {\n name: string\n label: string\n status: AgentPlatformStatus\n description: string\n skills: AgentPlatformSkillBinding[]\n commands: string[]\n // 现阶段建议的测试 endpoint(不是静默默认直连:真实执行仍 fail-closed,见 resolveEndpoint)。\n // 可被 MULTICA_SERVER_URL 环境变量 / 项目 config / 已登录 profile 覆盖;GA 时改此处或用覆盖切换。\n suggestedEndpoint?: string\n endpointEnv?: string\n}\n\nexport const MANAGED_AGENT_PLATFORMS: AgentPlatformDefinition[] = [\n {\n name: 'multica-dingtalk',\n label: 'Multica (DingTalk)',\n status: 'supported',\n description: '钉钉 Multica 托管平台:供给、部署、钉钉机器人绑定、观测与调度。',\n skills: [\n { role: 'deploy', name: 'dingtalk-agent-deploy-multica', purpose: '经 dta 稳定 CLI 受控部署/晋级/观测到 Multica' },\n { role: 'boot', name: 'dingtalk-agent-boot-multica', purpose: '部署产物在 Multica Host 内每次任务的启动协议' },\n { role: 'ops', name: 'multica-external', purpose: '平台运维执行体:供给/绑定机器人/观测/调度(纯 HTTPS)' },\n ],\n commands: ['deploy', 'promote', 'observe'],\n suggestedEndpoint: 'https://pre-fde-workbench.dingtalk.com',\n endpointEnv: 'MULTICA_SERVER_URL',\n },\n {\n name: 'deap',\n label: 'DEAP',\n status: 'coming-soon',\n description: '敬请期待。',\n skills: [],\n commands: [],\n },\n]\n\nexport const AGENT_PLATFORM_FILE = '.dingtalk-agent/agent-platform.json'\nconst PROJECT_FILE = 'dingtalk-agent.json'\n\nexport type AgentPlatformSource = 'env' | 'project-manifest' | 'platform-file' | 'inferred' | 'none'\n\nexport interface AgentPlatformResolution {\n $schema: 'dingtalk-agent/agent-platform-resolution@1'\n platform: string | null\n source: AgentPlatformSource\n file: string\n definition: AgentPlatformDefinition | null\n platforms: AgentPlatformDefinition[]\n}\n\nexport interface AgentPlatformUseResult extends AgentPlatformResolution {\n written: string\n skillInstalls: GlobalSkillStatus[]\n}\n\nexport function agentPlatformDefinition(name: string): AgentPlatformDefinition | null {\n return MANAGED_AGENT_PLATFORMS.find((item) => item.name === name) || null\n}\n\nexport function resolveAgentPlatform(\n start = process.cwd(), env: NodeJS.ProcessEnv = process.env,\n): AgentPlatformResolution {\n const fromEnv = String(env.DTA_AGENT_PLATFORM || '').trim()\n if (fromEnv) return resolution(fromEnv, 'env', '')\n\n const projectRoot = findAgentProjectRoot(start)\n if (projectRoot) {\n const manifestPath = join(projectRoot, PROJECT_FILE)\n if (existsSync(manifestPath) && !lstatSync(manifestPath).isSymbolicLink()) {\n const manifest = readJsonOrNull(manifestPath)\n const declared = typeof manifest?.agentPlatform === 'string' ? manifest.agentPlatform.trim() : ''\n if (declared) return resolution(declared, 'project-manifest', manifestPath)\n }\n }\n\n const platformPath = findUp(start, AGENT_PLATFORM_FILE)\n if (platformPath) {\n const stored = readJsonOrNull(platformPath)\n const declared = typeof stored?.agentPlatform === 'string' ? stored.agentPlatform.trim() : ''\n if (declared) return resolution(declared, 'platform-file', platformPath)\n }\n\n if (projectRoot) {\n const manifest = readJsonOrNull(join(projectRoot, PROJECT_FILE))\n const providers = Object.values(manifest?.workspaces || {})\n .map((workspace: any) => workspace?.provider?.kind)\n if (providers.includes('multica')) {\n return resolution('multica-dingtalk', 'inferred', join(projectRoot, PROJECT_FILE))\n }\n }\n\n return resolution(null, 'none', '')\n}\n\nexport interface AgentPlatformUseOptions {\n packageRoot: string\n home?: string\n env?: NodeJS.ProcessEnv\n installSkills?: boolean\n}\n\nexport function useAgentPlatform(\n start: string, name: string, options: AgentPlatformUseOptions,\n): AgentPlatformUseResult {\n const definition = agentPlatformDefinition(name)\n if (!definition) {\n throw new Error(\n `未知 managed agent platform: ${name}\\n` +\n `可用: ${MANAGED_AGENT_PLATFORMS.map((item) => `${item.name}(${statusLabel(item.status)})`).join('、')}`,\n )\n }\n if (definition.status !== 'supported') {\n throw new Error(`${definition.label} 敬请期待——当前版本尚未开放该平台。`)\n }\n\n const projectRoot = findAgentProjectRoot(start)\n let written: string\n if (projectRoot && existsSync(join(projectRoot, PROJECT_FILE))) {\n const manifestPath = join(projectRoot, PROJECT_FILE)\n if (lstatSync(manifestPath).isSymbolicLink()) {\n throw new Error(`${PROJECT_FILE} 不能是符号链接`)\n }\n const manifest = readJsonOrNull(manifestPath)\n if (!manifest || typeof manifest !== 'object') {\n throw new Error(`${PROJECT_FILE} 不是合法 JSON,无法写入 agentPlatform 归属`)\n }\n manifest.agentPlatform = definition.name\n writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + '\\n')\n written = manifestPath\n } else {\n const target = join(resolve(start), AGENT_PLATFORM_FILE)\n mkdirSync(dirname(target), { recursive: true })\n writeFileSync(target, JSON.stringify(\n { $schema: 'dingtalk-agent/agent-platform@1', agentPlatform: definition.name }, null, 2,\n ) + '\\n')\n written = target\n }\n\n const skillInstalls: GlobalSkillStatus[] = []\n if (options.installSkills !== false) {\n for (const skill of definition.skills) {\n skillInstalls.push(installGlobalSkill(options.packageRoot, {\n name: skill.name, home: options.home, env: options.env,\n }))\n }\n }\n\n return { ...resolveAgentPlatform(start, options.env || process.env), written, skillInstalls }\n}\n\n/** deploy/promote/observe 等平台命令的归属门禁:未归属、未知或 coming-soon 一律 fail-closed。 */\nexport function requireSupportedAgentPlatform(\n command: string, start = process.cwd(), env: NodeJS.ProcessEnv = process.env,\n): AgentPlatformResolution {\n const resolved = resolveAgentPlatform(start, env)\n if (!resolved.platform) {\n throw new Error(\n `当前工作区未声明 managed agent platform,无法执行 \\`${command}\\`。\\n` +\n '先运行 `dta agent-platform use multica-dingtalk`,或设置 DTA_AGENT_PLATFORM 环境变量。',\n )\n }\n if (!resolved.definition) {\n throw new Error(\n `工作区声明了未知 platform: ${resolved.platform}(来源 ${resolved.source})。\\n` +\n `可用: ${MANAGED_AGENT_PLATFORMS.map((item) => item.name).join('、')}`,\n )\n }\n if (resolved.definition.status !== 'supported') {\n throw new Error(`${resolved.definition.label} 敬请期待——\\`${command}\\` 尚未在该平台开放。`)\n }\n if (!resolved.definition.commands.includes(command)) {\n throw new Error(`${resolved.definition.label} 不承接命令 \\`${command}\\`。`)\n }\n return resolved\n}\n\n/** dta 层的平台命令/角色(deploy、boot、ops…)关联到该平台内确切的 Skill 名。 */\nexport function platformSkillForRole(platformName: string, role: string): string | null {\n const definition = agentPlatformDefinition(platformName)\n return definition?.skills.find((item) => item.role === role)?.name || null\n}\n\nconst PLATFORM_DIRS: Record<string, string> = {\n 'multica-dingtalk': 'skills/platforms/multica-dingtalk',\n deap: 'skills/platforms/deap',\n}\n\n/** 平台说明文档(PLATFORM.md)在包内的路径;切换到该平台时应加载让维护者/Agent 知道各技能用途。 */\nexport function platformDocPath(packageRoot: string, platformName: string): string | null {\n const dir = PLATFORM_DIRS[platformName]\n if (!dir) return null\n const path = join(packageRoot, dir, 'PLATFORM.md')\n return existsSync(path) ? path : null\n}\n\nexport function readPlatformDoc(packageRoot: string, platformName: string): string {\n const path = platformDocPath(packageRoot, platformName)\n return path ? readFileSync(path, 'utf8') : ''\n}\n\nexport function statusLabel(status: AgentPlatformStatus): string {\n return status === 'supported' ? '已支持' : '敬请期待'\n}\n\nexport type EndpointSource = 'env' | 'project-config' | 'profile' | 'suggested' | 'ambiguous' | 'none'\n\nexport interface EndpointResolution {\n endpoint: string\n source: EndpointSource\n // confirmed=true 仅当来自真实来源(env / 项目 config / 恰好一个已登录 profile);\n // suggested(预发建议)与 ambiguous(多目标未选)均为 false —— 发布前仍需用户显式确认,不得据此直连。\n confirmed: boolean\n envVar: string\n candidates: string[]\n}\n\n/**\n * 解析平台 endpoint,与真实执行体(multica_ext.py 读 MULTICA_SERVER_URL/--profile)同源,\n * 不新造命名空间、不静默默认连预发。顺序:\n * MULTICA_SERVER_URL 环境变量 > 项目 config(dingtalk-agent.json#multicaEndpoint /\n * .dingtalk-agent/agent-platform.json.endpoint)> 恰好一个已登录 profile 的 server_url\n * (多个则 ambiguous,不自动挑)> suggestedEndpoint(仅建议,未确认)。\n */\nexport function resolveEndpoint(\n platformName: string, start = process.cwd(),\n env: NodeJS.ProcessEnv = process.env, home = homedir(),\n): EndpointResolution {\n const definition = agentPlatformDefinition(platformName)\n const envVar = definition?.endpointEnv || 'MULTICA_SERVER_URL'\n const base: Omit<EndpointResolution, 'endpoint' | 'source' | 'confirmed'> = { envVar, candidates: [] }\n\n const fromEnv = String(env[envVar] || '').trim()\n if (fromEnv) return { endpoint: fromEnv, source: 'env', confirmed: true, ...base }\n\n const fromConfig = projectEndpoint(start)\n if (fromConfig) return { endpoint: fromConfig, source: 'project-config', confirmed: true, ...base }\n\n const serverUrls = [...new Set(multicaTargets(home)\n .map((target) => target.serverUrl.trim()).filter(Boolean))]\n if (serverUrls.length === 1) {\n return { endpoint: serverUrls[0], source: 'profile', confirmed: true, ...base }\n }\n if (serverUrls.length > 1) {\n return { endpoint: '', source: 'ambiguous', confirmed: false, ...base, candidates: serverUrls }\n }\n\n if (definition?.suggestedEndpoint) {\n return { endpoint: definition.suggestedEndpoint, source: 'suggested', confirmed: false, ...base }\n }\n return { endpoint: '', source: 'none', confirmed: false, ...base }\n}\n\nfunction projectEndpoint(start: string): string {\n const projectRoot = findAgentProjectRoot(start)\n if (!projectRoot) return ''\n const manifest = readJsonOrNull(join(projectRoot, PROJECT_FILE))\n const fromManifest = typeof manifest?.multicaEndpoint === 'string' ? manifest.multicaEndpoint.trim() : ''\n if (fromManifest) return fromManifest\n const platform = readJsonOrNull(join(projectRoot, AGENT_PLATFORM_FILE))\n return typeof platform?.endpoint === 'string' ? platform.endpoint.trim() : ''\n}\n\nexport interface AgentPlatformReadinessCheck {\n id: string\n ok: boolean\n summary: string\n hint?: string\n}\n\n/**\n * 平台工具链就绪检查(只读,不阻断):选择/查看平台归属时提示用户缺什么、怎么补。\n * 强制门禁仍由 requireSupportedAgentPlatform 与各平台命令自身承担。\n */\nexport function agentPlatformReadiness(\n name: string, env: NodeJS.ProcessEnv = process.env, home = homedir(),\n start: string = process.cwd(),\n): AgentPlatformReadinessCheck[] {\n if (name !== 'multica-dingtalk') return []\n const checks: AgentPlatformReadinessCheck[] = []\n const cli = findExecutable('multica', env)\n checks.push(cli\n ? { id: 'multica-cli', ok: true, summary: `multica CLI 已安装(${cli})` }\n : {\n id: 'multica-cli', ok: false, summary: '未找到 multica CLI',\n hint: '安装:curl -fsSL https://raw.githubusercontent.com/multica-ai/multica/main/scripts/install.sh | bash',\n })\n const ep = resolveEndpoint(name, start, env, home)\n const loginTarget = ep.endpoint || '<endpoint>'\n const suffix = ep.confirmed ? '' : '(未确认,请核对是预发还是生产)'\n checks.push(hasMulticaToken(home)\n ? { id: 'multica-login', ok: true, summary: 'Multica 已登录(本地存在 token)' }\n : {\n id: 'multica-login', ok: false, summary: 'Multica 尚未登录',\n hint: `登录:multica login --server-url ${loginTarget} --token <你的 mul_ PAT>` +\n `(endpoint 来源 ${ep.source}${suffix};用 MULTICA_SERVER_URL 或登录别的 profile 可切换)`,\n })\n if (['HTTPS_PROXY', 'https_proxy', 'ALL_PROXY', 'all_proxy'].some((key) => env[key])) {\n checks.push({\n id: 'proxy-env', ok: false, summary: '检测到代理环境变量,可能阻断 Multica 直连',\n hint: '连接失败时用 env -u HTTPS_PROXY -u https_proxy -u ALL_PROXY -u all_proxy 运行 multica 与平台脚本',\n })\n }\n return checks\n}\n\nexport interface MulticaTarget {\n profile: string\n serverUrl: string\n workspaceId: string\n}\n\n/**\n * 本机已登录的 Multica 目标清单(default 配置 + 各 profile)。只暴露 endpoint 与\n * workspace 标识,不读取 token 内容。发布前必须把候选交给用户选择,绝不默默用默认配置。\n */\nexport function multicaTargets(home = homedir()): MulticaTarget[] {\n const targets: MulticaTarget[] = []\n const push = (profile: string, path: string) => {\n const config = readJsonOrNull(path)\n if (typeof config?.token === 'string' && config.token.trim()) {\n targets.push({\n profile,\n serverUrl: String(config.server_url || ''),\n workspaceId: String(config.workspace_id || ''),\n })\n }\n }\n push('default', join(home, '.multica', 'config.json'))\n try {\n for (const entry of readdirSync(join(home, '.multica', 'profiles'))) {\n push(entry, join(home, '.multica', 'profiles', entry, 'config.json'))\n }\n } catch { /* profiles 目录不存在 */ }\n return targets\n}\n\nfunction hasMulticaToken(home: string): boolean {\n const candidates = [join(home, '.multica', 'config.json')]\n try {\n for (const entry of readdirSync(join(home, '.multica', 'profiles'))) {\n candidates.push(join(home, '.multica', 'profiles', entry, 'config.json'))\n }\n } catch { /* profiles 目录不存在 */ }\n return candidates.some((path) => {\n const config = readJsonOrNull(path)\n return typeof config?.token === 'string' && config.token.trim().length > 0\n })\n}\n\nfunction resolution(\n name: string | null, source: AgentPlatformSource, file: string,\n): AgentPlatformResolution {\n return {\n $schema: 'dingtalk-agent/agent-platform-resolution@1',\n platform: name,\n source,\n file,\n definition: name ? agentPlatformDefinition(name) : null,\n platforms: MANAGED_AGENT_PLATFORMS,\n }\n}\n\nfunction readJsonOrNull(path: string): any {\n try { return JSON.parse(readFileSync(path, 'utf8')) } catch { return null }\n}\n\nfunction findUp(start: string, relativePath: string): string | null {\n let dir = resolve(start)\n while (true) {\n const candidate = join(dir, relativePath)\n if (existsSync(candidate) && !lstatSync(candidate).isSymbolicLink()) return candidate\n const parent = dirname(dir)\n if (parent === dir || dir === parse(dir).root) return null\n dir = parent\n }\n}\n"]}
@@ -11,7 +11,7 @@ export const CURRENT_WORKSPACE_FILE = '.dingtalk-agent/current-workspace';
11
11
  export const WORKSPACE_STATE_ROOT = '.dingtalk-agent/state/workspaces';
12
12
  export const LEGACY_WORKSPACE_NAME = 'legacy-prepared';
13
13
  const PROJECT_KEYS = new Set(['$schema', 'name', 'dtaVersion', 'agent', 'workspaces']);
14
- const PROJECT_OPTIONAL_KEYS = new Set([...PROJECT_KEYS, 'agentPlatform']);
14
+ const PROJECT_OPTIONAL_KEYS = new Set([...PROJECT_KEYS, 'agentPlatform', 'multicaEndpoint']);
15
15
  const AGENT_KEYS = new Set(['definition', 'skills']);
16
16
  const WORKSPACE_KEYS = new Set(['stage', 'provider', 'storage', 'authority']);
17
17
  const OPENCODE_KEYS = new Set(['kind', 'model']);
@@ -200,6 +200,8 @@ function validateProjectManifest(value, root) {
200
200
  const dtaVersion = requiredString(input.dtaVersion, 'dtaVersion');
201
201
  const agentPlatform = input.agentPlatform === undefined
202
202
  ? undefined : requiredString(input.agentPlatform, 'agentPlatform');
203
+ const multicaEndpoint = input.multicaEndpoint === undefined
204
+ ? undefined : requiredString(input.multicaEndpoint, 'multicaEndpoint');
203
205
  const agentInput = objectValue(input.agent, 'Project agent');
204
206
  assertExactKeys(agentInput, AGENT_KEYS, 'Project agent');
205
207
  const definition = safeRelativePath(root, requiredString(agentInput.definition, 'agent.definition'), 'agent.definition', false);
@@ -224,6 +226,7 @@ function validateProjectManifest(value, root) {
224
226
  return {
225
227
  $schema: 'dingtalk-agent/project@1', name, dtaVersion,
226
228
  ...(agentPlatform === undefined ? {} : { agentPlatform }),
229
+ ...(multicaEndpoint === undefined ? {} : { multicaEndpoint }),
227
230
  agent: { definition, skills }, workspaces,
228
231
  };
229
232
  }