@xdxer/dingtalk-agent 0.1.5-beta.2 → 0.1.5-beta.4

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.
Files changed (72) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.en.md +92 -63
  3. package/README.md +92 -63
  4. package/dist/bin/dingtalk-agent.js +142 -15
  5. package/dist/bin/dingtalk-agent.js.map +1 -1
  6. package/dist/src/agent-audit.js +69 -55
  7. package/dist/src/agent-audit.js.map +1 -1
  8. package/dist/src/agent-enhance.js +49 -30
  9. package/dist/src/agent-enhance.js.map +1 -1
  10. package/dist/src/agent-platform.js +1 -0
  11. package/dist/src/agent-platform.js.map +1 -1
  12. package/dist/src/bootstrap.js +6 -2
  13. package/dist/src/bootstrap.js.map +1 -1
  14. package/dist/src/development-workspace.js +108 -18
  15. package/dist/src/development-workspace.js.map +1 -1
  16. package/dist/src/multica-deploy.js +128 -18
  17. package/dist/src/multica-deploy.js.map +1 -1
  18. package/dist/src/multica-provider.js +157 -2
  19. package/dist/src/multica-provider.js.map +1 -1
  20. package/dist/src/opencode-provider.js +17 -5
  21. package/dist/src/opencode-provider.js.map +1 -1
  22. package/dist/src/schedule-plan.js +105 -0
  23. package/dist/src/schedule-plan.js.map +1 -0
  24. package/dist/src/skills.js +2 -0
  25. package/dist/src/skills.js.map +1 -1
  26. package/dist/src/workspace.js +11 -6
  27. package/dist/src/workspace.js.map +1 -1
  28. package/docs/ARCHITECTURE.md +142 -24
  29. package/docs/INSTALLATION.md +1 -1
  30. package/docs/PRIOR-ART.md +4 -0
  31. package/docs/SELF-TEST.md +1 -1
  32. package/docs/architecture/agent-platform-connection-layer.svg +120 -0
  33. package/docs/architecture/digital-employee-composition.svg +92 -0
  34. package/docs/architecture/dingtalk-agent-architecture.svg +125 -0
  35. package/docs/assets/digital-employee-at-work.svg +77 -0
  36. package/docs/schemas/multica-workspace-run.schema.json +150 -33
  37. package/docs/schemas/project.schema.json +27 -0
  38. package/docs/schemas/workspace-scaffold.schema.json +37 -0
  39. package/examples/agents/README.md +9 -7
  40. package/examples/agents/fde-coach/AGENTS.md +2 -34
  41. package/examples/agents/fde-coach/agent/AGENTS.md +35 -0
  42. package/examples/agents/fde-coach/agent.bindings.json +10 -0
  43. package/examples/agents/release-manager/AGENTS.md +2 -34
  44. package/examples/agents/release-manager/agent/AGENTS.md +35 -0
  45. package/examples/agents/release-manager/agent.bindings.json +10 -0
  46. package/lab/project-workspace/fake-multica-provider.mjs +43 -8
  47. package/lab/project-workspace/opencode-provider-suite.json +1 -1
  48. package/lab/robot-eval/suite.json +1 -1
  49. package/package.json +2 -2
  50. package/skills/core/dingtalk-agent-compose/SKILL.md +25 -18
  51. package/skills/core/dingtalk-agent-compose/assets/AGENTS.template.md +1 -1
  52. package/skills/core/dingtalk-agent-compose/assets/REPOSITORY.template.md +10 -0
  53. package/skills/core/dingtalk-agent-compose/assets/agent.bindings.dingtalk-doc.template.json +2 -2
  54. package/skills/core/dingtalk-agent-compose/assets/agent.bindings.local.template.json +2 -2
  55. package/skills/core/dingtalk-agent-compose/assets/hosts/opencode/opencode.template.json +2 -1
  56. package/skills/core/dingtalk-agent-compose/evals/evals.json +1 -1
  57. package/skills/core/dingtalk-agent-compose/references/agent-definition-contract.md +6 -6
  58. package/skills/core/dingtalk-agent-compose/references/drive-and-schedules.md +124 -0
  59. package/skills/core/dingtalk-agent-compose/references/host-loading-contract.md +10 -12
  60. package/skills/core/dingtalk-agent-compose/references/hosts/claude-code.md +13 -12
  61. package/skills/core/dingtalk-agent-compose/references/hosts/opencode.md +13 -12
  62. package/skills/core/dingtalk-basic-behavior/SKILL.md +11 -7
  63. package/skills/core/dingtalk-basic-behavior/references/event-to-behavior.md +15 -1
  64. package/skills/core/dingtalk-basic-behavior/references/perception-and-gates.md +5 -0
  65. package/skills/core/dingtalk-basic-behavior/references/risk-authority-and-privacy.md +12 -0
  66. package/skills/platforms/deap/PLATFORM.md +30 -1
  67. package/skills/platforms/multica-dingtalk/PLATFORM.md +25 -0
  68. package/skills/platforms/multica-dingtalk/dingtalk-agent-deploy-multica/SKILL.md +3 -2
  69. package/skills/platforms/multica-dingtalk/multica-external/SKILL.md +15 -0
  70. package/docs/assets/agent-delivery-lifecycle.svg +0 -103
  71. /package/examples/agents/fde-coach/{skills → agent/skills}/fde-coach/SKILL.md +0 -0
  72. /package/examples/agents/release-manager/{skills → agent/skills}/release-manager/SKILL.md +0 -0
@@ -1 +1 @@
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,oDAAoD;AACpD,wEAAwE;AAExE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACpG,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAA0B,MAAM,oBAAoB,CAAA;AAwB/E,MAAM,CAAC,MAAM,uBAAuB,GAA8B;IAChE;QACE,IAAI,EAAE,kBAAkB;QACxB,KAAK,EAAE,oBAAoB;QAC3B,MAAM,EAAE,WAAW;QACnB,WAAW,EAAE,sCAAsC;QACnD,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,+BAA+B,EAAE,OAAO,EAAE,kCAAkC,EAAE;YACtG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,iCAAiC,EAAE;SACtF;QACD,QAAQ,E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AA;IAC5E,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,UAAU,CACjB,IAAmB,EAAE,MAA2B,EAAE,IAAY;IAE9D,OAAO;QACL,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 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 // 已指向线上正式域名——正因为是生产环境,resolveEndpoint 仍返回 confirmed: false,用前必须显式确认。\n // 可被 MULTICA_SERVER_URL 环境变量 / 项目 config / 已登录 profile 覆盖。\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: 'ops', name: 'multica-external', purpose: '平台运维执行体:供给/绑定机器人/观测/调度(纯 HTTPS)' },\n ],\n commands: ['deploy', 'promote', 'observe'],\n suggestedEndpoint: 'https://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"]}
1
+ {"version":3,"file":"agent-platform.js","sourceRoot":"","sources":["../../src/agent-platform.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,oCAAoC;AACpC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,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 // Provider kind a `workspace create` on this platform scaffolds (project.schema provider.kind).\n // Absent while a platform has no runnable provider yet (e.g. deap): scaffolding refuses.\n provider?: 'multica' | 'opencode'\n // 建议 endpoint(不是静默默认直连:真实执行仍 fail-closed,见 resolveEndpoint)。\n // 已指向线上正式域名——正因为是生产环境,resolveEndpoint 仍返回 confirmed: false,用前必须显式确认。\n // 可被 MULTICA_SERVER_URL 环境变量 / 项目 config / 已登录 profile 覆盖。\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: 'ops', name: 'multica-external', purpose: '平台运维执行体:供给/绑定机器人/观测/调度(纯 HTTPS)' },\n ],\n commands: ['deploy', 'promote', 'observe'],\n provider: 'multica',\n suggestedEndpoint: 'https://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"]}
@@ -18,10 +18,14 @@ export function bootstrap(root, options = {}) {
18
18
  const cwd = realpathSync(resolve(root));
19
19
  const hasWorkspace = existsSync(workspacePath(cwd));
20
20
  const workspace = hasWorkspace ? loadWorkspace(cwd) : null;
21
- const agent = select(options.agent || options.storage, options.context?.agent, process.env.DTA_AGENT_SOURCE, workspace ? 'workspace-manifest' : '', `local-dir:${cwd}`);
21
+ const packagedAgentRoot = existsSync(join(cwd, 'agent', 'AGENTS.md'))
22
+ ? join(cwd, 'agent') : cwd;
23
+ const packagedSkillsRef = existsSync(join(cwd, 'agent', 'skills'))
24
+ ? 'agent/skills' : existsSync(join(cwd, 'skills')) ? 'skills' : '';
25
+ const agent = select(options.agent || options.storage, options.context?.agent, process.env.DTA_AGENT_SOURCE, workspace ? 'workspace-manifest' : '', `local-dir:${packagedAgentRoot}`);
22
26
  const memory = select(options.memory, options.context?.memory, process.env.DTA_MEMORY_STORAGE, workspace?.mounts.memory || '', existsSync(join(cwd, 'MEMORY.md')) ? 'local-md:MEMORY.md' : '');
23
27
  const knowledge = select(options.knowledge, options.context?.knowledge, process.env.DTA_KNOWLEDGE_STORAGE, workspace?.mounts.knowledge || '', existsSync(join(cwd, 'knowledge', 'INDEX.md')) ? 'local-md:knowledge/INDEX.md' : '');
24
- const skills = select(options.skills, options.context?.skills, process.env.DTA_SKILLS_SOURCE, workspace?.mounts.skills || '', existsSync(join(cwd, 'skills')) ? 'local-dir:skills' : '');
28
+ const skills = select(options.skills, options.context?.skills, process.env.DTA_SKILLS_SOURCE, workspace?.mounts.skills || '', packagedSkillsRef ? `local-dir:${packagedSkillsRef}` : '');
25
29
  const state = select(options.stateDir, options.context?.stateDir, process.env.DTA_STATE_DIR, '', '.dingtalk-agent');
26
30
  const artifacts = select(options.artifacts, options.context?.artifacts, process.env.DTA_ARTIFACTS_STORAGE, '', `local-dir:${resolve(cwd, state.value, 'artifacts')}`);
27
31
  const dwsProfile = select(options.profile, options.context?.profile, process.env.DTA_DWS_PROFILE, workspace?.dws.profile || '', '');
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/bootstrap.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,EAAE;AACF,sBAAsB;AACtB,mCAAmC;AACnC,mCAAmC;AACnC,kCAAkC;AAElC,OAAO,EACL,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EACrF,aAAa,GACd,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAA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C,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC7C,MAAM,IAAI,GAAG,GAAG,IAAI,IAAI,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,MAAM,CAAA;IACvD,aAAa,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1C,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;AACxB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC7B,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,mBAAmB,EAAE,GAAG,CAAC,IAAI,WAAW,CAAA;AACzE,CAAC","sourcesContent":["// Agent Session 的轻量水合入口。\n//\n// 它不要求 init,也不创建项目模板:\n// - local-dir 直接返回可读的 Markdown 挂载;\n// - dingtalk-doc 通过 DWS 拉成隐藏的只读快照;\n// - 已有 workspace@1 时复用其中的 mounts。\n\nimport {\n existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync,\n writeFileSync,\n} from 'node:fs'\nimport { basename, dirname, join, relative, resolve } from 'node:path'\nimport { digest } from './events.js'\nimport * as dws from './dws.js'\nimport { buildBootstrapDefinition } from './agent-definition.js'\nimport { directInvocation } from './invocation.js'\nimport type { AgentDefinition, InvocationContext } from './types.js'\nimport { loadWorkspace, workspacePath, type WorkspaceSpec } from './workspace.js'\n\ntype Provider = 'local-dir' | 'local-md' | 'dingtalk-doc'\n\nexport interface BootstrapOptions {\n agent?: string\n storage?: string\n memory?: string\n knowledge?: string\n skills?: string\n artifacts?: string\n stateDir?: string\n profile?: string\n expectedUserId?: string\n /** Inspect bindings without reading a remote provider. Used by the local agent audit. */\n deferRemote?: boolean\n context?: Partial<{\n agent: string\n memory: string\n knowledge: string\n skills: string\n artifacts: string\n stateDir: string\n profile: string\n expectedUserId: string\n }>\n}\n\nexport interface BootstrapMount {\n slot: string\n provider: Provider\n source: string\n path: string\n hash: string\n}\n\nexport interface BootstrapResult {\n $schema: 'dingtalk-agent/bootstrap@1'\n mode: 'direct' | 'workspace'\n initialized: boolean\n scopeId: string\n contextId: string\n storage: string\n stateDir: string\n mounts: BootstrapMount[]\n definition: AgentDefinition\n invocation: InvocationContext\n note: string\n}\n\nexport function bootstrap(root: string, options: BootstrapOptions = {}): BootstrapResult {\n // Canonicalize aliases such as macOS /var -> /private/var so bootstrap,\n // agent audit, evidence fingerprints, and later Session snapshots hash the\n // same Agent root.\n const cwd = realpathSync(resolve(root))\n const hasWorkspace = existsSync(workspacePath(cwd))\n const workspace = hasWorkspace ? loadWorkspace(cwd) : null\n const agent = select(\n options.agent || options.storage, options.context?.agent, process.env.DTA_AGENT_SOURCE,\n workspace ? 'workspace-manifest' : '', `local-dir:${cwd}`,\n )\n const memory = select(\n options.memory, options.context?.memory, process.env.DTA_MEMORY_STORAGE,\n workspace?.mounts.memory || '', existsSync(join(cwd, 'MEMORY.md')) ? 'local-md:MEMORY.md' : '',\n )\n const knowledge = select(\n options.knowledge, options.context?.knowledge, process.env.DTA_KNOWLEDGE_STORAGE,\n workspace?.mounts.knowledge || '',\n existsSync(join(cwd, 'knowledge', 'INDEX.md')) ? 'local-md:knowledge/INDEX.md' : '',\n )\n const skills = select(\n options.skills, options.context?.skills, process.env.DTA_SKILLS_SOURCE,\n workspace?.mounts.skills || '', existsSync(join(cwd, 'skills')) ? 'local-dir:skills' : '',\n )\n const state = select(\n options.stateDir, options.context?.stateDir, process.env.DTA_STATE_DIR,\n '', '.dingtalk-agent',\n )\n const artifacts = select(\n options.artifacts, options.context?.artifacts, process.env.DTA_ARTIFACTS_STORAGE,\n '', `local-dir:${resolve(cwd, state.value, 'artifacts')}`,\n )\n const dwsProfile = select(\n options.profile, options.context?.profile, process.env.DTA_DWS_PROFILE,\n workspace?.dws.profile || '', '',\n )\n const expectedUserId = select(\n options.expectedUserId, options.context?.expectedUserId, process.env.DTA_EXPECTED_USER_ID,\n workspace?.dws.expectedUserId || '', '',\n )\n const storage = agent.value\n const stateDir = resolve(cwd, state.value)\n let mounts = workspace && agent.value === 'workspace-manifest'\n ? hydrateWorkspace(cwd, workspace, stateDir, dwsProfile.value, options.deferRemote)\n : hydrateStorage(cwd, agent.value, stateDir, dwsProfile.value, 'body', options.deferRemote)\n mounts = mergeMounts(mounts, hydrateOptional(\n cwd, memory.value, stateDir, dwsProfile.value, 'memory', options.deferRemote))\n mounts = mergeMounts(mounts, hydrateOptional(\n cwd, knowledge.value, stateDir, dwsProfile.value, 'knowledge', options.deferRemote))\n mounts = mergeMounts(mounts, hydrateOptional(\n cwd, skills.value, stateDir, dwsProfile.value, 'skills', options.deferRemote))\n const contextId = workspace?.contextId || ''\n const scopeSeed = agent.value === 'workspace-manifest' && contextId\n ? contextId : canonicalStorageSeed(storage, cwd)\n const sourcePath = storage.startsWith('local-dir:')\n ? safeLocalPath(cwd, parseStorage(storage).ref, true) : ''\n const origins = {\n agent: agent.origin, memory: memory.origin, knowledge: knowledge.origin,\n skills: skills.origin, artifacts: artifacts.origin, state: state.origin,\n dwsProfile: dwsProfile.origin, expectedUserId: expectedUserId.origin,\n }\n const definition = buildBootstrapDefinition(mounts, {\n source: storage,\n sourcePath,\n memory: memory.value,\n knowledge: knowledge.value,\n artifacts: artifacts.value,\n state: stateDir,\n dwsProfile: dwsProfile.value,\n expectedUserId: expectedUserId.value,\n origins,\n }, agent.value === 'workspace-manifest' ? workspace : null)\n return {\n $schema: 'dingtalk-agent/bootstrap@1',\n mode: workspace ? 'workspace' : 'direct',\n initialized: hasWorkspace,\n scopeId: `scope_${digest(scopeSeed).slice(0, 20)}`,\n contextId,\n storage,\n stateDir: mounts.some((item) => item.provider === 'dingtalk-doc') ? stateDir : '',\n mounts,\n definition,\n invocation: directInvocation(),\n note: hasWorkspace\n ? '已读取现有 Workspace;init 不是每次 Session 的前置动作。'\n : '未初始化 Workspace;已按直接会话模式工作,不会自动修改当前目录。',\n }\n}\n\nfunction hydrateWorkspace(\n root: string,\n workspace: WorkspaceSpec,\n stateDir: string,\n profile = '',\n deferRemote = false,\n): BootstrapMount[] {\n const out: BootstrapMount[] = []\n for (const slot of ['profile', 'memory', 'knowledge'] as const) {\n out.push(...hydrateStorage(\n root,\n workspace.mounts[slot],\n stateDir,\n profile || workspace.dws.profile,\n slot,\n deferRemote,\n ))\n }\n return out\n}\n\nfunction hydrateStorage(\n root: string,\n uri: string,\n stateDir: string,\n profile = '',\n slot = 'workspace',\n deferRemote = false,\n): BootstrapMount[] {\n const mount = parseStorage(uri)\n if (mount.provider === 'local-dir') {\n if (slot === 'skills') {\n return discoverSkillDirectory(root, mount.ref)\n }\n const discovered = discoverLocalDirectory(root, mount.ref)\n return slot === 'body' || slot === 'workspace'\n ? discovered\n : discovered.filter((item) => item.slot === slot)\n }\n if (mount.provider === 'local-md') {\n const path = safeLocalPath(root, mount.ref, false)\n if (!path) return []\n const markdown = readFileSync(path, 'utf8')\n const effectiveSlot = slot === 'skills'\n ? `skill:${readSkillName(markdown) || safeName(path)}` : slot\n return [{ slot: effectiveSlot, provider: mount.provider, source: uri, path, hash: digest(markdown) }]\n }\n\n if (deferRemote) return []\n\n // /i/nodes URL 是多产品统一入口;先 probe,只有在线文档 adoc 才能作为 Markdown Storage。\n const info = dws.docInfo(mount.ref, profile)\n const contentType = String(info?.contentType || '').toUpperCase()\n const extension = String(info?.extension || '').toLowerCase()\n if (contentType !== 'ALIDOC' || extension !== 'adoc') {\n throw new Error(\n `dingtalk-doc 只接受在线文档 adoc;实际 contentType=${contentType || '?'} extension=${extension || '?'}`,\n )\n }\n const markdown = String(dws.readDoc(mount.ref, profile))\n const scope = digest(uri).slice(0, 20)\n const effectiveSlot = slot === 'skills'\n ? `skill:${readSkillName(markdown) || safeName(mount.ref)}` : slot\n // A single remote document may intentionally back more than one semantic slot.\n // Give each slot its own directory so its manifest cannot overwrite another slot.\n const path = join(\n stateDir, 'cache', 'bootstrap', scope, safeName(effectiveSlot), 'snapshot.md')\n // Cache bytes must be identical to the independently read remote bytes. Adding\n // formatting here would make the manifest hash describe data that is not on disk.\n writeAtomic(path, markdown)\n const manifest = join(dirname(path), 'manifest.json')\n writeAtomic(manifest, JSON.stringify({\n $schema: 'dingtalk-agent/bootstrap-cache@1',\n source: uri,\n profile,\n pulledAt: new Date().toISOString(),\n hash: digest(markdown),\n path,\n }, null, 2) + '\\n')\n return [{ slot: effectiveSlot, provider: mount.provider, source: uri, path, hash: digest(markdown) }]\n}\n\nfunction discoverLocalDirectory(root: string, ref: string): BootstrapMount[] {\n const directory = safeLocalPath(root, ref, true)\n if (!directory || !lstatSync(directory).isDirectory()) {\n throw new Error(`local-dir 不是目录: ${ref}`)\n }\n const candidates: Array<[string, string]> = [\n ['body', 'AGENTS.md'],\n ['profile', 'WORKSPACE.md'],\n ['memory', 'MEMORY.md'],\n ['knowledge', join('knowledge', 'INDEX.md')],\n ]\n const out: BootstrapMount[] = []\n for (const [slot, rel] of candidates) {\n const path = resolve(directory, rel)\n if (!existsSync(path) || !lstatSync(path).isFile()) continue\n const markdown = readFileSync(path, 'utf8')\n out.push({\n slot,\n provider: 'local-dir',\n source: `local-dir:${directory}`,\n path,\n hash: digest(markdown),\n })\n }\n out.push(...discoverSkillDirectory(root, join(directory, 'skills'), true))\n return out\n}\n\nfunction discoverSkillDirectory(root: string, ref: string, optional = false): BootstrapMount[] {\n const candidate = resolve(root, ref)\n if (!existsSync(candidate)) {\n if (optional) return []\n throw new Error(`Skill Storage 不存在: ${ref}`)\n }\n const directory = realpathSync(candidate)\n if (!lstatSync(directory).isDirectory()) throw new Error(`Skill Storage 不是目录: ${ref}`)\n const roots = existsSync(join(directory, 'SKILL.md'))\n ? [directory]\n : readdirSync(directory).sort().map((name) => join(directory, name))\n .filter((path) => existsSync(join(path, 'SKILL.md')) && lstatSync(path).isDirectory())\n return roots.map((path) => {\n const markdown = readFileSync(join(path, 'SKILL.md'), 'utf8')\n const name = readSkillName(markdown) || basename(path)\n return {\n slot: `skill:${name}`, provider: 'local-dir' as const,\n source: `local-dir:${directory}`, path: join(path, 'SKILL.md'), hash: digest(markdown),\n }\n })\n}\n\nfunction hydrateOptional(\n root: string, uri: string, stateDir: string, profile: string, slot: string,\n deferRemote = false,\n): BootstrapMount[] {\n return uri ? hydrateStorage(root, uri, stateDir, profile, slot, deferRemote) : []\n}\n\nfunction mergeMounts(current: BootstrapMount[], additions: BootstrapMount[]): BootstrapMount[] {\n const out = [...current]\n for (const addition of additions) {\n const index = out.findIndex((item) => item.slot === addition.slot)\n if (index >= 0) out[index] = addition\n else out.push(addition)\n }\n return out\n}\n\nfunction readSkillName(markdown: string): string {\n const frontmatter = markdown.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---/)\n return frontmatter?.[1].match(/^name:\\s*['\"]?([^'\"\\r\\n]+)['\"]?\\s*$/m)?.[1]?.trim() || ''\n}\n\ntype ConfigOrigin = AgentDefinition['configuration'][string]\n\nfunction select(\n explicit: unknown, context: unknown, environment: unknown,\n workspace: unknown, convention: string,\n): { value: string; origin: ConfigOrigin } {\n const choices: Array<[unknown, ConfigOrigin]> = [\n [explicit, 'explicit'], [context, 'context'], [environment, 'environment'],\n [workspace, 'workspace'], [convention, 'convention'],\n ]\n for (const [value, origin] of choices) {\n if (typeof value === 'string' && value.trim()) return { value: value.trim(), origin }\n }\n return { value: '', origin: 'convention' }\n}\n\nfunction parseStorage(uri: string): { provider: Provider; ref: string } {\n const separator = uri.indexOf(':')\n const provider = separator < 0 ? '' : uri.slice(0, separator)\n const ref = separator < 0 ? '' : uri.slice(separator + 1).trim()\n if (!['local-dir', 'local-md', 'dingtalk-doc'].includes(provider) || !ref) {\n throw new Error(\n `Storage URI 不合法: ${uri};使用 local-dir:<path> / local-md:<path> / dingtalk-doc:<node-or-url>`,\n )\n }\n return { provider: provider as Provider, ref }\n}\n\nfunction safeLocalPath(root: string, ref: string, allowAbsolute: boolean): string {\n const rootReal = realpathSync(resolve(root))\n const candidate = resolve(rootReal, ref)\n if (!existsSync(candidate)) {\n if (!allowAbsolute) return ''\n throw new Error(`Storage 不存在: ${ref}`)\n }\n const actual = realpathSync(candidate)\n if (!allowAbsolute) {\n const rel = relative(rootReal, actual)\n if (rel === '..' || rel.startsWith(`..${process.platform === 'win32' ? '\\\\' : '/'}`)) {\n throw new Error(`local-md 必须位于当前 Workspace 内: ${ref}`)\n }\n }\n return actual\n}\n\nfunction canonicalStorageSeed(storage: string, root: string): string {\n const mount = parseStorage(storage)\n return mount.provider === 'local-dir'\n ? `local-dir:${realpathSync(resolve(root, mount.ref))}`\n : storage\n}\n\nfunction writeAtomic(path: string, value: string): void {\n mkdirSync(dirname(path), { recursive: true })\n const temp = `${path}.${process.pid}.${Date.now()}.tmp`\n writeFileSync(temp, value, { flag: 'wx' })\n renameSync(temp, path)\n}\n\nfunction safeName(value: string): string {\n return basename(value).replace(/[^a-zA-Z0-9._-]+/g, '-') || 'workspace'\n}\n"]}
1
+ {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/bootstrap.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,EAAE;AACF,sBAAsB;AACtB,mCAAmC;AACnC,mCAAmC;AACnC,kCAAkC;AAElC,OAAO,EACL,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EACrF,aAAa,GACd,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAsB,MAAM,gBAAgB,CAAA;AAkDjF,MAAM,UA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CAAA;AACb,CAAC;AAED,SAAS,WAAW,CAAC,IAAY,EAAE,KAAa;IAC9C,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC7C,MAAM,IAAI,GAAG,GAAG,IAAI,IAAI,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,MAAM,CAAA;IACvD,aAAa,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1C,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;AACxB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC7B,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,mBAAmB,EAAE,GAAG,CAAC,IAAI,WAAW,CAAA;AACzE,CAAC","sourcesContent":["// Agent Session 的轻量水合入口。\n//\n// 它不要求 init,也不创建项目模板:\n// - local-dir 直接返回可读的 Markdown 挂载;\n// - dingtalk-doc 通过 DWS 拉成隐藏的只读快照;\n// - 已有 workspace@1 时复用其中的 mounts。\n\nimport {\n existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync,\n writeFileSync,\n} from 'node:fs'\nimport { basename, dirname, join, relative, resolve } from 'node:path'\nimport { digest } from './events.js'\nimport * as dws from './dws.js'\nimport { buildBootstrapDefinition } from './agent-definition.js'\nimport { directInvocation } from './invocation.js'\nimport type { AgentDefinition, InvocationContext } from './types.js'\nimport { loadWorkspace, workspacePath, type WorkspaceSpec } from './workspace.js'\n\ntype Provider = 'local-dir' | 'local-md' | 'dingtalk-doc'\n\nexport interface BootstrapOptions {\n agent?: string\n storage?: string\n memory?: string\n knowledge?: string\n skills?: string\n artifacts?: string\n stateDir?: string\n profile?: string\n expectedUserId?: string\n /** Inspect bindings without reading a remote provider. Used by the local agent audit. */\n deferRemote?: boolean\n context?: Partial<{\n agent: string\n memory: string\n knowledge: string\n skills: string\n artifacts: string\n stateDir: string\n profile: string\n expectedUserId: string\n }>\n}\n\nexport interface BootstrapMount {\n slot: string\n provider: Provider\n source: string\n path: string\n hash: string\n}\n\nexport interface BootstrapResult {\n $schema: 'dingtalk-agent/bootstrap@1'\n mode: 'direct' | 'workspace'\n initialized: boolean\n scopeId: string\n contextId: string\n storage: string\n stateDir: string\n mounts: BootstrapMount[]\n definition: AgentDefinition\n invocation: InvocationContext\n note: string\n}\n\nexport function bootstrap(root: string, options: BootstrapOptions = {}): BootstrapResult {\n // Canonicalize aliases such as macOS /var -> /private/var so bootstrap,\n // agent audit, evidence fingerprints, and later Session snapshots hash the\n // same Agent root.\n const cwd = realpathSync(resolve(root))\n const hasWorkspace = existsSync(workspacePath(cwd))\n const workspace = hasWorkspace ? loadWorkspace(cwd) : null\n const packagedAgentRoot = existsSync(join(cwd, 'agent', 'AGENTS.md'))\n ? join(cwd, 'agent') : cwd\n const packagedSkillsRef = existsSync(join(cwd, 'agent', 'skills'))\n ? 'agent/skills' : existsSync(join(cwd, 'skills')) ? 'skills' : ''\n const agent = select(\n options.agent || options.storage, options.context?.agent, process.env.DTA_AGENT_SOURCE,\n workspace ? 'workspace-manifest' : '', `local-dir:${packagedAgentRoot}`,\n )\n const memory = select(\n options.memory, options.context?.memory, process.env.DTA_MEMORY_STORAGE,\n workspace?.mounts.memory || '', existsSync(join(cwd, 'MEMORY.md')) ? 'local-md:MEMORY.md' : '',\n )\n const knowledge = select(\n options.knowledge, options.context?.knowledge, process.env.DTA_KNOWLEDGE_STORAGE,\n workspace?.mounts.knowledge || '',\n existsSync(join(cwd, 'knowledge', 'INDEX.md')) ? 'local-md:knowledge/INDEX.md' : '',\n )\n const skills = select(\n options.skills, options.context?.skills, process.env.DTA_SKILLS_SOURCE,\n workspace?.mounts.skills || '', packagedSkillsRef ? `local-dir:${packagedSkillsRef}` : '',\n )\n const state = select(\n options.stateDir, options.context?.stateDir, process.env.DTA_STATE_DIR,\n '', '.dingtalk-agent',\n )\n const artifacts = select(\n options.artifacts, options.context?.artifacts, process.env.DTA_ARTIFACTS_STORAGE,\n '', `local-dir:${resolve(cwd, state.value, 'artifacts')}`,\n )\n const dwsProfile = select(\n options.profile, options.context?.profile, process.env.DTA_DWS_PROFILE,\n workspace?.dws.profile || '', '',\n )\n const expectedUserId = select(\n options.expectedUserId, options.context?.expectedUserId, process.env.DTA_EXPECTED_USER_ID,\n workspace?.dws.expectedUserId || '', '',\n )\n const storage = agent.value\n const stateDir = resolve(cwd, state.value)\n let mounts = workspace && agent.value === 'workspace-manifest'\n ? hydrateWorkspace(cwd, workspace, stateDir, dwsProfile.value, options.deferRemote)\n : hydrateStorage(cwd, agent.value, stateDir, dwsProfile.value, 'body', options.deferRemote)\n mounts = mergeMounts(mounts, hydrateOptional(\n cwd, memory.value, stateDir, dwsProfile.value, 'memory', options.deferRemote))\n mounts = mergeMounts(mounts, hydrateOptional(\n cwd, knowledge.value, stateDir, dwsProfile.value, 'knowledge', options.deferRemote))\n mounts = mergeMounts(mounts, hydrateOptional(\n cwd, skills.value, stateDir, dwsProfile.value, 'skills', options.deferRemote))\n const contextId = workspace?.contextId || ''\n const scopeSeed = agent.value === 'workspace-manifest' && contextId\n ? contextId : canonicalStorageSeed(storage, cwd)\n const sourcePath = storage.startsWith('local-dir:')\n ? safeLocalPath(cwd, parseStorage(storage).ref, true) : ''\n const origins = {\n agent: agent.origin, memory: memory.origin, knowledge: knowledge.origin,\n skills: skills.origin, artifacts: artifacts.origin, state: state.origin,\n dwsProfile: dwsProfile.origin, expectedUserId: expectedUserId.origin,\n }\n const definition = buildBootstrapDefinition(mounts, {\n source: storage,\n sourcePath,\n memory: memory.value,\n knowledge: knowledge.value,\n artifacts: artifacts.value,\n state: stateDir,\n dwsProfile: dwsProfile.value,\n expectedUserId: expectedUserId.value,\n origins,\n }, agent.value === 'workspace-manifest' ? workspace : null)\n return {\n $schema: 'dingtalk-agent/bootstrap@1',\n mode: workspace ? 'workspace' : 'direct',\n initialized: hasWorkspace,\n scopeId: `scope_${digest(scopeSeed).slice(0, 20)}`,\n contextId,\n storage,\n stateDir: mounts.some((item) => item.provider === 'dingtalk-doc') ? stateDir : '',\n mounts,\n definition,\n invocation: directInvocation(),\n note: hasWorkspace\n ? '已读取现有 Workspace;init 不是每次 Session 的前置动作。'\n : '未初始化 Workspace;已按直接会话模式工作,不会自动修改当前目录。',\n }\n}\n\nfunction hydrateWorkspace(\n root: string,\n workspace: WorkspaceSpec,\n stateDir: string,\n profile = '',\n deferRemote = false,\n): BootstrapMount[] {\n const out: BootstrapMount[] = []\n for (const slot of ['profile', 'memory', 'knowledge'] as const) {\n out.push(...hydrateStorage(\n root,\n workspace.mounts[slot],\n stateDir,\n profile || workspace.dws.profile,\n slot,\n deferRemote,\n ))\n }\n return out\n}\n\nfunction hydrateStorage(\n root: string,\n uri: string,\n stateDir: string,\n profile = '',\n slot = 'workspace',\n deferRemote = false,\n): BootstrapMount[] {\n const mount = parseStorage(uri)\n if (mount.provider === 'local-dir') {\n if (slot === 'skills') {\n return discoverSkillDirectory(root, mount.ref)\n }\n const discovered = discoverLocalDirectory(root, mount.ref)\n return slot === 'body' || slot === 'workspace'\n ? discovered\n : discovered.filter((item) => item.slot === slot)\n }\n if (mount.provider === 'local-md') {\n const path = safeLocalPath(root, mount.ref, false)\n if (!path) return []\n const markdown = readFileSync(path, 'utf8')\n const effectiveSlot = slot === 'skills'\n ? `skill:${readSkillName(markdown) || safeName(path)}` : slot\n return [{ slot: effectiveSlot, provider: mount.provider, source: uri, path, hash: digest(markdown) }]\n }\n\n if (deferRemote) return []\n\n // /i/nodes URL 是多产品统一入口;先 probe,只有在线文档 adoc 才能作为 Markdown Storage。\n const info = dws.docInfo(mount.ref, profile)\n const contentType = String(info?.contentType || '').toUpperCase()\n const extension = String(info?.extension || '').toLowerCase()\n if (contentType !== 'ALIDOC' || extension !== 'adoc') {\n throw new Error(\n `dingtalk-doc 只接受在线文档 adoc;实际 contentType=${contentType || '?'} extension=${extension || '?'}`,\n )\n }\n const markdown = String(dws.readDoc(mount.ref, profile))\n const scope = digest(uri).slice(0, 20)\n const effectiveSlot = slot === 'skills'\n ? `skill:${readSkillName(markdown) || safeName(mount.ref)}` : slot\n // A single remote document may intentionally back more than one semantic slot.\n // Give each slot its own directory so its manifest cannot overwrite another slot.\n const path = join(\n stateDir, 'cache', 'bootstrap', scope, safeName(effectiveSlot), 'snapshot.md')\n // Cache bytes must be identical to the independently read remote bytes. Adding\n // formatting here would make the manifest hash describe data that is not on disk.\n writeAtomic(path, markdown)\n const manifest = join(dirname(path), 'manifest.json')\n writeAtomic(manifest, JSON.stringify({\n $schema: 'dingtalk-agent/bootstrap-cache@1',\n source: uri,\n profile,\n pulledAt: new Date().toISOString(),\n hash: digest(markdown),\n path,\n }, null, 2) + '\\n')\n return [{ slot: effectiveSlot, provider: mount.provider, source: uri, path, hash: digest(markdown) }]\n}\n\nfunction discoverLocalDirectory(root: string, ref: string): BootstrapMount[] {\n const directory = safeLocalPath(root, ref, true)\n if (!directory || !lstatSync(directory).isDirectory()) {\n throw new Error(`local-dir 不是目录: ${ref}`)\n }\n const candidates: Array<[string, string]> = [\n ['body', 'AGENTS.md'],\n ['profile', 'WORKSPACE.md'],\n ['memory', 'MEMORY.md'],\n ['knowledge', join('knowledge', 'INDEX.md')],\n ]\n const out: BootstrapMount[] = []\n for (const [slot, rel] of candidates) {\n const path = resolve(directory, rel)\n if (!existsSync(path) || !lstatSync(path).isFile()) continue\n const markdown = readFileSync(path, 'utf8')\n out.push({\n slot,\n provider: 'local-dir',\n source: `local-dir:${directory}`,\n path,\n hash: digest(markdown),\n })\n }\n out.push(...discoverSkillDirectory(root, join(directory, 'skills'), true))\n return out\n}\n\nfunction discoverSkillDirectory(root: string, ref: string, optional = false): BootstrapMount[] {\n const candidate = resolve(root, ref)\n if (!existsSync(candidate)) {\n if (optional) return []\n throw new Error(`Skill Storage 不存在: ${ref}`)\n }\n const directory = realpathSync(candidate)\n if (!lstatSync(directory).isDirectory()) throw new Error(`Skill Storage 不是目录: ${ref}`)\n const roots = existsSync(join(directory, 'SKILL.md'))\n ? [directory]\n : readdirSync(directory).sort().map((name) => join(directory, name))\n .filter((path) => existsSync(join(path, 'SKILL.md')) && lstatSync(path).isDirectory())\n return roots.map((path) => {\n const markdown = readFileSync(join(path, 'SKILL.md'), 'utf8')\n const name = readSkillName(markdown) || basename(path)\n return {\n slot: `skill:${name}`, provider: 'local-dir' as const,\n source: `local-dir:${directory}`, path: join(path, 'SKILL.md'), hash: digest(markdown),\n }\n })\n}\n\nfunction hydrateOptional(\n root: string, uri: string, stateDir: string, profile: string, slot: string,\n deferRemote = false,\n): BootstrapMount[] {\n return uri ? hydrateStorage(root, uri, stateDir, profile, slot, deferRemote) : []\n}\n\nfunction mergeMounts(current: BootstrapMount[], additions: BootstrapMount[]): BootstrapMount[] {\n const out = [...current]\n for (const addition of additions) {\n const index = out.findIndex((item) => item.slot === addition.slot)\n if (index >= 0) out[index] = addition\n else out.push(addition)\n }\n return out\n}\n\nfunction readSkillName(markdown: string): string {\n const frontmatter = markdown.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---/)\n return frontmatter?.[1].match(/^name:\\s*['\"]?([^'\"\\r\\n]+)['\"]?\\s*$/m)?.[1]?.trim() || ''\n}\n\ntype ConfigOrigin = AgentDefinition['configuration'][string]\n\nfunction select(\n explicit: unknown, context: unknown, environment: unknown,\n workspace: unknown, convention: string,\n): { value: string; origin: ConfigOrigin } {\n const choices: Array<[unknown, ConfigOrigin]> = [\n [explicit, 'explicit'], [context, 'context'], [environment, 'environment'],\n [workspace, 'workspace'], [convention, 'convention'],\n ]\n for (const [value, origin] of choices) {\n if (typeof value === 'string' && value.trim()) return { value: value.trim(), origin }\n }\n return { value: '', origin: 'convention' }\n}\n\nfunction parseStorage(uri: string): { provider: Provider; ref: string } {\n const separator = uri.indexOf(':')\n const provider = separator < 0 ? '' : uri.slice(0, separator)\n const ref = separator < 0 ? '' : uri.slice(separator + 1).trim()\n if (!['local-dir', 'local-md', 'dingtalk-doc'].includes(provider) || !ref) {\n throw new Error(\n `Storage URI 不合法: ${uri};使用 local-dir:<path> / local-md:<path> / dingtalk-doc:<node-or-url>`,\n )\n }\n return { provider: provider as Provider, ref }\n}\n\nfunction safeLocalPath(root: string, ref: string, allowAbsolute: boolean): string {\n const rootReal = realpathSync(resolve(root))\n const candidate = resolve(rootReal, ref)\n if (!existsSync(candidate)) {\n if (!allowAbsolute) return ''\n throw new Error(`Storage 不存在: ${ref}`)\n }\n const actual = realpathSync(candidate)\n if (!allowAbsolute) {\n const rel = relative(rootReal, actual)\n if (rel === '..' || rel.startsWith(`..${process.platform === 'win32' ? '\\\\' : '/'}`)) {\n throw new Error(`local-md 必须位于当前 Workspace 内: ${ref}`)\n }\n }\n return actual\n}\n\nfunction canonicalStorageSeed(storage: string, root: string): string {\n const mount = parseStorage(storage)\n return mount.provider === 'local-dir'\n ? `local-dir:${realpathSync(resolve(root, mount.ref))}`\n : storage\n}\n\nfunction writeAtomic(path: string, value: string): void {\n mkdirSync(dirname(path), { recursive: true })\n const temp = `${path}.${process.pid}.${Date.now()}.tmp`\n writeFileSync(temp, value, { flag: 'wx' })\n renameSync(temp, path)\n}\n\nfunction safeName(value: string): string {\n return basename(value).replace(/[^a-zA-Z0-9._-]+/g, '-') || 'workspace'\n}\n"]}
@@ -11,9 +11,13 @@ 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', 'multicaEndpoint']);
15
- const AGENT_KEYS = new Set(['definition', 'displayName', 'skills']);
14
+ const PROJECT_OPTIONAL_KEYS = new Set([...PROJECT_KEYS, 'agentPlatform', 'multicaEndpoint', 'schedules']);
15
+ const AGENT_KEYS = new Set(['definition', 'skillsRoot', 'displayName', 'skills']);
16
16
  const AGENT_REQUIRED_KEYS = new Set(['definition', 'skills']);
17
+ const SCHEDULE_KEYS = new Set(['name', 'cron', 'timezone', 'mode', 'wake', 'purpose',
18
+ 'completion', 'unit', 'evidence', 'supervision']);
19
+ const SCHEDULE_REQUIRED_KEYS = new Set(['name', 'cron', 'timezone', 'mode']);
20
+ const SCHEDULE_MODES = new Set(['ephemeral', 'work-item']);
17
21
  const WORKSPACE_KEYS = new Set(['stage', 'provider', 'storage', 'authority']);
18
22
  const OPENCODE_KEYS = new Set(['kind', 'model']);
19
23
  const MULTICA_KEYS = new Set([
@@ -21,6 +25,10 @@ const MULTICA_KEYS = new Set([
21
25
  ]);
22
26
  const STORAGE_KEYS = new Set(['memory', 'knowledge', 'artifacts']);
23
27
  const AUTHORITY_KEYS = new Set(['dwsProfileFrom', 'expectedUserIdFrom']);
28
+ export const PROVIDER_CONTRACTS = {
29
+ opencode: { kind: 'opencode', requiresAuthority: false },
30
+ multica: { kind: 'multica', requiresAuthority: true },
31
+ };
24
32
  const STATE_KEYS = new Set([
25
33
  '$schema', 'workspace', 'provider', 'status', 'binding', 'desiredHash', 'observedHash',
26
34
  'lastPlanId', 'lastReceiptId', 'lastEvalId',
@@ -70,7 +78,9 @@ export function inspectAgentProject(start = process.cwd(), cliVersion = '') {
70
78
  dtaVersion: loaded.manifest.dtaVersion,
71
79
  compatibleWithCli: !cliVersion || versionSatisfies(cliVersion, loaded.manifest.dtaVersion),
72
80
  definition: loaded.manifest.agent.definition,
81
+ skillsRoot: loaded.manifest.agent.skillsRoot || '',
73
82
  skills: [...loaded.manifest.agent.skills],
83
+ schedules: loaded.manifest.schedules ? [...loaded.manifest.schedules] : [],
74
84
  },
75
85
  currentWorkspace,
76
86
  workspaces: declared,
@@ -189,6 +199,51 @@ function loadAgentProject(start) {
189
199
  manifestHash: digest(stableStringify(manifest)), legacy,
190
200
  };
191
201
  }
202
+ function validateCron(expr, label) {
203
+ const value = requiredString(expr, label);
204
+ if (value.startsWith('@')) {
205
+ throw new Error(`${label} 不支持 @macro(如 @daily);用标准 5 段 cron`);
206
+ }
207
+ const fields = value.trim().split(/\s+/);
208
+ if (fields.length !== 5) {
209
+ throw new Error(`${label} 必须是标准 5 段 cron(分 时 日 月 周);得到 ${fields.length} 段: "${value}"`);
210
+ }
211
+ return value;
212
+ }
213
+ function validateSchedules(value) {
214
+ if (value === undefined)
215
+ return [];
216
+ if (!Array.isArray(value))
217
+ throw new Error('schedules 必须是数组');
218
+ const seen = new Set();
219
+ return value.map((raw, index) => {
220
+ const input = objectValue(raw, `schedules[${index}]`);
221
+ assertAllowedKeys(input, SCHEDULE_KEYS, `schedules[${index}]`);
222
+ const missing = [...SCHEDULE_REQUIRED_KEYS].filter((key) => !(key in input));
223
+ if (missing.length)
224
+ throw new Error(`schedules[${index}] 缺少字段: ${missing.join(', ')}`);
225
+ const name = agentDisplayName(input.name, `schedules[${index}].name`);
226
+ if (seen.has(name))
227
+ throw new Error(`schedules 里的 name 不能重复: ${name}`);
228
+ seen.add(name);
229
+ const cron = validateCron(input.cron, `schedules[${index}].cron`);
230
+ const timezone = requiredString(input.timezone, `schedules[${index}].timezone`);
231
+ const mode = requiredString(input.mode, `schedules[${index}].mode`);
232
+ if (!SCHEDULE_MODES.has(mode)) {
233
+ throw new Error(`schedules[${index}].mode 只能是 ${[...SCHEDULE_MODES].join(' | ')};得到 "${mode}"`);
234
+ }
235
+ const opt = (key) => input[key] === undefined ? undefined : requiredString(input[key], `schedules[${index}].${key}`);
236
+ return {
237
+ name, cron, timezone, mode: mode,
238
+ ...(opt('wake') === undefined ? {} : { wake: opt('wake') }),
239
+ ...(opt('purpose') === undefined ? {} : { purpose: opt('purpose') }),
240
+ ...(opt('completion') === undefined ? {} : { completion: opt('completion') }),
241
+ ...(opt('unit') === undefined ? {} : { unit: opt('unit') }),
242
+ ...(opt('evidence') === undefined ? {} : { evidence: opt('evidence') }),
243
+ ...(opt('supervision') === undefined ? {} : { supervision: opt('supervision') }),
244
+ };
245
+ });
246
+ }
192
247
  function validateProjectManifest(value, root) {
193
248
  const input = objectValue(value, 'Project manifest');
194
249
  assertAllowedKeys(input, PROJECT_OPTIONAL_KEYS, 'Project manifest');
@@ -210,6 +265,9 @@ function validateProjectManifest(value, root) {
210
265
  if (missingAgent.length)
211
266
  throw new Error(`Project agent 缺少字段: ${missingAgent.join(', ')}`);
212
267
  const definition = safeRelativePath(root, requiredString(agentInput.definition, 'agent.definition'), 'agent.definition', false);
268
+ const skillsRoot = agentInput.skillsRoot === undefined
269
+ ? undefined
270
+ : safeRelativePath(root, requiredString(agentInput.skillsRoot, 'agent.skillsRoot'), 'agent.skillsRoot', false);
213
271
  const displayName = agentInput.displayName === undefined
214
272
  ? undefined : agentDisplayName(agentInput.displayName, 'agent.displayName');
215
273
  if (!Array.isArray(agentInput.skills) || agentInput.skills.length === 0) {
@@ -230,13 +288,43 @@ function validateProjectManifest(value, root) {
230
288
  }
231
289
  workspaces[workspaceName] = validateDeclaredWorkspace(rawWorkspace, root, workspaceName);
232
290
  }
291
+ const schedules = validateSchedules(input.schedules);
233
292
  return {
234
293
  $schema: 'dingtalk-agent/project@1', name, dtaVersion,
235
294
  ...(agentPlatform === undefined ? {} : { agentPlatform }),
236
295
  ...(multicaEndpoint === undefined ? {} : { multicaEndpoint }),
237
- agent: { definition, ...(displayName === undefined ? {} : { displayName }), skills }, workspaces,
296
+ agent: {
297
+ definition,
298
+ ...(skillsRoot === undefined ? {} : { skillsRoot }),
299
+ ...(displayName === undefined ? {} : { displayName }),
300
+ skills,
301
+ },
302
+ ...(schedules.length ? { schedules } : {}),
303
+ workspaces,
238
304
  };
239
305
  }
306
+ /**
307
+ * Resolve the versioned source of a declared Skill.
308
+ *
309
+ * New projects declare one package root (normally agent/skills). Manifests
310
+ * created before skillsRoot keep their historical split layout so an existing
311
+ * code repository can migrate deliberately instead of being rewritten merely
312
+ * because dta was upgraded.
313
+ */
314
+ export function projectSkillRef(project, name) {
315
+ if (project.skillsRoot)
316
+ return `${project.skillsRoot}/${name}`;
317
+ return name === 'dingtalk-basic-behavior'
318
+ ? `.agents/skills/${name}`
319
+ : `skills/${name}`;
320
+ }
321
+ function manifestSkillRef(manifest, name) {
322
+ if (manifest.agent.skillsRoot)
323
+ return `${manifest.agent.skillsRoot}/${name}`;
324
+ return name === 'dingtalk-basic-behavior'
325
+ ? `.agents/skills/${name}`
326
+ : `skills/${name}`;
327
+ }
240
328
  function validateDeclaredWorkspace(value, root, name) {
241
329
  const input = objectValue(value, `Workspace ${name}`);
242
330
  assertAllowedKeys(input, WORKSPACE_KEYS, `Workspace ${name}`);
@@ -300,8 +388,15 @@ function validateDeclaredWorkspace(value, root, name) {
300
388
  expectedUserIdFrom: envReference(authorityInput.expectedUserIdFrom, `${name}.expectedUserIdFrom`),
301
389
  };
302
390
  }
303
- if (provider.kind === 'multica' && !authority) {
304
- throw new Error(`Workspace ${name} 的 multica Provider 必须声明 authority env 来源`);
391
+ if (PROVIDER_CONTRACTS[provider.kind]?.requiresAuthority && !authority) {
392
+ throw new Error(`Workspace ${name} 的 ${provider.kind} Provider 必须声明 authority.dwsProfileFrom ` +
393
+ `authority.expectedUserIdFrom(都用 env: 引用,不接受字面量)。\n` +
394
+ `在该 Workspace 下补上,例如:\n` +
395
+ ` "authority": {\n` +
396
+ ` "dwsProfileFrom": "env:DTA_DWS_PROFILE",\n` +
397
+ ` "expectedUserIdFrom": "env:DTA_EXPECTED_USER_ID"\n` +
398
+ ` }\n` +
399
+ `或直接用 dta workspace create ${name} --provider ${provider.kind} 生成完整条目。`);
305
400
  }
306
401
  return { stage, provider, storage: {
307
402
  ...(memory ? { memory } : {}),
@@ -389,11 +484,8 @@ function projectSourceHash(root, manifest) {
389
484
  opencode: localContentHash(root, 'opencode.json'),
390
485
  };
391
486
  for (const name of manifest.agent.skills) {
392
- const ref = name === 'dingtalk-basic-behavior'
393
- ? `.agents/skills/${name}` : `skills/${name}`;
487
+ const ref = manifestSkillRef(manifest, name);
394
488
  sources[`skill:${name}`] = localContentHash(root, ref);
395
- const exposure = `.agents/skills/${name}`;
396
- sources[`exposure:${name}`] = localContentHash(root, exposure);
397
489
  }
398
490
  return digest(stableStringify(sources));
399
491
  }
@@ -480,13 +572,13 @@ function inspectOpenCodeWorkspace(info, workspace, env, add) {
480
572
  const executable = findExecutable('opencode', env);
481
573
  add('provider.opencode-cli', 'provider', executable ? 'pass' : 'fail', true, executable ? 'OpenCode CLI 可执行' : 'PATH 找不到 opencode', { executable: executable || '' }, '安装 OpenCode,并确认 opencode --version 可执行');
482
574
  add('provider.opencode-model', 'provider', workspace.provider.model ? 'pass' : 'fail', true, workspace.provider.model ? 'OpenCode model 已显式声明' : 'OpenCode model 缺失', { model: workspace.provider.model || '' });
483
- const basicPath = '.agents/skills/dingtalk-basic-behavior/SKILL.md';
575
+ const basicPath = `${projectSkillRef(info.project, 'dingtalk-basic-behavior')}/SKILL.md`;
484
576
  const basic = inspectLocalFile(info.root, basicPath);
485
577
  const canonicalPackageRoot = resolvePackageRoot(import.meta.url);
486
578
  const canonicalBasic = inspectLocalFile(canonicalPackageRoot, relative(canonicalPackageRoot, join(bundledSkillPath(canonicalPackageRoot, 'dingtalk-basic-behavior'), 'SKILL.md')));
487
579
  const basicMatched = basic.valid && canonicalBasic.valid && basic.hash === canonicalBasic.hash;
488
- add('skills.basic-exposure', 'skills', basicMatched ? 'pass' : 'fail', true, basicMatched ? 'Basic Skill exposure 与当前 canonical source 一致'
489
- : 'Basic Skill exposure 缺失、越界或 hash 漂移', { exposure: basic, canonicalHash: canonicalBasic.hash || '' }, `重新物化 ${basicPath}`);
580
+ add('skills.basic-exposure', 'skills', basicMatched ? 'pass' : 'fail', true, basicMatched ? 'Agent package 中的 Basic Skill 与当前 canonical source 一致'
581
+ : 'Agent package 的 Basic Skill 缺失、越界或 hash 漂移', { source: basic, canonicalHash: canonicalBasic.hash || '' }, `重新装配 ${basicPath}`);
490
582
  const configPath = join(info.root, 'opencode.json');
491
583
  const configFile = inspectLocalFile(info.root, 'opencode.json');
492
584
  let configError = '';
@@ -514,12 +606,10 @@ function inspectOpenCodeWorkspace(info, workspace, env, add) {
514
606
  const configValid = !configError && instructionCount === 1 && permission === 'allow';
515
607
  add('skills.basic-instruction', 'skills', configValid ? 'pass' : 'fail', true, configValid ? 'OpenCode config 强制加载且允许 Basic Skill' : 'OpenCode Basic instruction/permission 合同不完整', { path: 'opencode.json', error: configError, instructionCount, permission }, '运行 compose/bind 流程生成唯一 Basic instruction 与 allow permission');
516
608
  for (const name of info.project.skills.filter((item) => item !== 'dingtalk-basic-behavior')) {
517
- const source = inspectLocalFile(info.root, `skills/${name}/SKILL.md`);
518
- const exposure = inspectLocalFile(info.root, `.agents/skills/${name}/SKILL.md`);
519
- const matched = source.valid && exposure.valid && source.hash === exposure.hash &&
520
- permissions[name] === 'allow';
521
- add(`skills.role.${name}`, 'skills', matched ? 'pass' : 'fail', true, matched ? `Role Skill ${name} source/exposure hash 与 permission 一致`
522
- : `Role Skill ${name} source、exposure hash 或 permission 不一致`, { source, exposure, permission: permissions[name] || '' }, `运行 compose/bind 流程物化 ${name}`);
609
+ const source = inspectLocalFile(info.root, `${projectSkillRef(info.project, name)}/SKILL.md`);
610
+ const matched = source.valid && permissions[name] === 'allow';
611
+ add(`skills.role.${name}`, 'skills', matched ? 'pass' : 'fail', true, matched ? `Role Skill ${name} 单一发布源与 permission 一致`
612
+ : `Role Skill ${name} 发布源缺失或 permission 不一致`, { source, permission: permissions[name] || '' }, `运行 compose/bind 流程装配 ${name}`);
523
613
  }
524
614
  const managedRef = workspace.state?.binding.managedPath || '';
525
615
  if (managedRef) {