From d2aa837579e7d120f41238fd4d370215dd6d669c Mon Sep 17 00:00:00 2001 From: zh Date: Wed, 23 Sep 2026 19:29:57 +0800 Subject: [PATCH] =?UTF-8?q?feat(workspace):=20pnpm=20monorepo=20=E9=AA=A8?= =?UTF-8?q?=E6=9E=B6=E4=B8=8E=E5=8C=85=E8=BE=B9=E7=95=8C=EF=BC=88A1.1?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 六个包:@aps/contracts、@aps/provider-sdk、@aps/server、@aps/client-app、@aps/desktop、@aps/provider-aps。依赖方向 contracts <- provider-sdk <- server <- client,providers/* 只依赖 provider-sdk。TypeScript 项目引用串起构建,pnpm typecheck 全绿。server 内部按 entry/app/agent/core/workflows 建目录并写明各自不该出现什么。 --- .gitignore | 4 + README.md | 39 ++++- client/app/index.ts | 7 + client/app/package.json | 14 ++ client/app/tsconfig.json | 11 ++ client/desktop/index.ts | 7 + client/desktop/package.json | 11 ++ client/desktop/tsconfig.json | 9 ++ contracts/index.ts | 23 +++ contracts/package.json | 17 ++ contracts/tsconfig.json | 9 ++ package.json | 16 ++ pnpm-lock.yaml | 259 ++++++++++++++++++++++++++++++ pnpm-workspace.yaml | 8 + providers/aps/index.ts | 15 ++ providers/aps/package.json | 15 ++ providers/aps/tsconfig.json | 13 ++ server/README.md | 22 +++ server/agent/.gitkeep | 0 server/app/.gitkeep | 0 server/core/.gitkeep | 0 server/entry/.gitkeep | 0 server/index.ts | 13 ++ server/package.json | 21 +++ server/provider-sdk/index.ts | 18 +++ server/provider-sdk/package.json | 20 +++ server/provider-sdk/tsconfig.json | 10 ++ server/tsconfig.json | 14 ++ server/workflows/.gitkeep | 0 tsconfig.base.json | 21 +++ tsconfig.json | 11 ++ 31 files changed, 621 insertions(+), 6 deletions(-) create mode 100644 client/app/index.ts create mode 100644 client/app/package.json create mode 100644 client/app/tsconfig.json create mode 100644 client/desktop/index.ts create mode 100644 client/desktop/package.json create mode 100644 client/desktop/tsconfig.json create mode 100644 contracts/index.ts create mode 100644 contracts/package.json create mode 100644 contracts/tsconfig.json create mode 100644 package.json create mode 100644 pnpm-lock.yaml create mode 100644 pnpm-workspace.yaml create mode 100644 providers/aps/index.ts create mode 100644 providers/aps/package.json create mode 100644 providers/aps/tsconfig.json create mode 100644 server/README.md create mode 100644 server/agent/.gitkeep create mode 100644 server/app/.gitkeep create mode 100644 server/core/.gitkeep create mode 100644 server/entry/.gitkeep create mode 100644 server/index.ts create mode 100644 server/package.json create mode 100644 server/provider-sdk/index.ts create mode 100644 server/provider-sdk/package.json create mode 100644 server/provider-sdk/tsconfig.json create mode 100644 server/tsconfig.json create mode 100644 server/workflows/.gitkeep create mode 100644 tsconfig.base.json create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore index 12bbc92..2d1e670 100644 --- a/.gitignore +++ b/.gitignore @@ -75,3 +75,7 @@ beihai-shipyard-aps-data/ /Pi-Agent兜底能力详细方案.md /Pi-Agent接入计划.md /Pi-Agent接入详细计划.md + +# ---- 新平台构建产物(TS 项目引用输出)---- +dist/ +*.tsbuildinfo diff --git a/README.md b/README.md index f1506c6..b552896 100644 --- a/README.md +++ b/README.md @@ -24,13 +24,40 @@ 设计文档在飞书评审中,评审通过后随本分支的后续提交入库(任务表 A0.10)。在此之前仓库里没有设计文档是正常的。 -## 目录规划 +## 目录与包 + +一个 pnpm monorepo,四个一级目录(架构设计第 2 节): ``` -client/ 客户端(桌面 Electron 与浏览器共用) -server/ 平台服务(entry / app / agent / core / provider-sdk / workflows) -providers/ Provider 适配器(aps / erp / ems) -contracts/ 客户端与服务端共享的契约 +contracts/ @aps/contracts 共享契约(只有类型,无运行时依赖) +server/ @aps/server 平台服务:entry / app / agent / core / workflows +server/provider-sdk/ @aps/provider-sdk 业务系统接入平台的契约与契约测试 +providers/aps/ @aps/provider-aps APS 适配器(ERP / EMS 同构) +client/app/ @aps/client-app 界面:对话、工作区、审批 +client/desktop/ @aps/desktop Electron 壳:窗口、本地守护、离线升级 +docs/ 架构、ADR、规范与评测集 ``` -骨架随 A1 建立。 +依赖方向(A1.2 接入 CI 检查): + +``` +contracts ← provider-sdk ← server ← client + ↑ + providers/* +``` + +## 快速开始 + +```bash +pnpm install # 需要 Node >= 22.19.0 +pnpm typecheck # 等价于 tsc -b,按项目引用顺序构建全部包 +``` + +## 开发约定 + +| 约定 | 出处 | +| --- | --- | +| 能力命名与描述七要素 | `docs/spec/capability-description.md` | +| 问法评测集与门槛 | `docs/eval/README.md` | +| 数据存储写法(整数毫秒、应用侧主键、JSONB/TEXT) | `docs/adr/0007-storage-and-consistency.md` | +| 架构决策记录 | `docs/adr/`(写完不改,改结论就新写一份) | diff --git a/client/app/index.ts b/client/app/index.ts new file mode 100644 index 0000000..2285521 --- /dev/null +++ b/client/app/index.ts @@ -0,0 +1,7 @@ +/** + * 客户端界面(架构设计第 2 节):对话、工作区、审批。 + * + * 只做界面与本地能力;业务判断、权限判断、持有业务凭据都不在这里。 + * 界面只认平台事件(@aps/contracts 的 PlatformEvent),对引擎无感。 + */ +export const CLIENT_APP_PACKAGE = '@aps/client-app'; \ No newline at end of file diff --git a/client/app/package.json b/client/app/package.json new file mode 100644 index 0000000..256390f --- /dev/null +++ b/client/app/package.json @@ -0,0 +1,14 @@ +{ + "name": "@aps/client-app", + "version": "0.0.0", + "private": true, + "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "scripts": { + "typecheck": "tsc -b" + }, + "dependencies": { + "@aps/contracts": "workspace:*" + } +} \ No newline at end of file diff --git a/client/app/tsconfig.json b/client/app/tsconfig.json new file mode 100644 index 0000000..8b549e5 --- /dev/null +++ b/client/app/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "dist", + "tsBuildInfoFile": "dist/.tsbuildinfo", + "lib": ["ES2022", "DOM"] + }, + "include": ["index.ts"], + "references": [{ "path": "../../contracts" }] +} \ No newline at end of file diff --git a/client/desktop/index.ts b/client/desktop/index.ts new file mode 100644 index 0000000..c51a442 --- /dev/null +++ b/client/desktop/index.ts @@ -0,0 +1,7 @@ +/** + * Electron 壳(ADR-0004):窗口、本地守护、离线升级。 + * + * 本地能力(文件、打印、设备)归属这一层;不装业务逻辑,不绕开服务端调业务系统。 + * 落地见任务 A10.5(壳与本地守护)与 A10.6(离线升级与回滚)。 + */ +export const DESKTOP_PACKAGE = '@aps/desktop'; \ No newline at end of file diff --git a/client/desktop/package.json b/client/desktop/package.json new file mode 100644 index 0000000..122eaf8 --- /dev/null +++ b/client/desktop/package.json @@ -0,0 +1,11 @@ +{ + "name": "@aps/desktop", + "version": "0.0.0", + "private": true, + "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "scripts": { + "typecheck": "tsc -b" + } +} \ No newline at end of file diff --git a/client/desktop/tsconfig.json b/client/desktop/tsconfig.json new file mode 100644 index 0000000..b9689ce --- /dev/null +++ b/client/desktop/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "dist", + "tsBuildInfoFile": "dist/.tsbuildinfo" + }, + "include": ["index.ts"] +} \ No newline at end of file diff --git a/contracts/index.ts b/contracts/index.ts new file mode 100644 index 0000000..335a9e6 --- /dev/null +++ b/contracts/index.ts @@ -0,0 +1,23 @@ +/** + * 客户端与服务端共享的契约(架构设计第 2 节)。 + * + * 只放类型与模式定义,不引入运行时依赖:这一层被所有包依赖,任何依赖都会变成全局耦合。 + * 引擎差异不在这里体现——引擎事件经适配层转成下面的平台事件,界面对引擎无感。 + */ + +/** 能力标识,形如 `aps.schedule.preview`。命名与描述规范见 docs/spec/capability-description.md */ +export type CapabilityId = string; + +/** 执行回执:所有能力调用的统一返回(架构设计 4.2) */ +export interface ExecutionReceipt { + executionId: string; + status: 'accepted' | 'succeeded' | 'failed' | 'pending-confirmation'; + result?: unknown; + errorKind?: string; +} + +/** 平台事件:唯一面向客户端的事件形态(实施设计 1.7 定义事件模型) */ +export type PlatformEvent = + | { type: 'message.delta'; sessionId: string; text: string } + | { type: 'tool.call'; sessionId: string; capabilityId: CapabilityId } + | { type: 'receipt'; sessionId: string; receipt: ExecutionReceipt }; \ No newline at end of file diff --git a/contracts/package.json b/contracts/package.json new file mode 100644 index 0000000..12557f9 --- /dev/null +++ b/contracts/package.json @@ -0,0 +1,17 @@ +{ + "name": "@aps/contracts", + "version": "0.0.0", + "private": true, + "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + } + }, + "scripts": { + "typecheck": "tsc -b" + } +} \ No newline at end of file diff --git a/contracts/tsconfig.json b/contracts/tsconfig.json new file mode 100644 index 0000000..d1e92f8 --- /dev/null +++ b/contracts/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "dist", + "tsBuildInfoFile": "dist/.tsbuildinfo" + }, + "include": ["index.ts"] +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..ed48657 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "aps-agent-platform", + "private": true, + "type": "module", + "engines": { + "node": ">=22.19.0" + }, + "scripts": { + "typecheck": "tsc -b", + "build": "tsc -b", + "clean": "tsc -b --clean" + }, + "devDependencies": { + "typescript": "^7.0.2" + } +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..9328308 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,259 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + devDependencies: + typescript: + specifier: ^7.0.2 + version: 7.0.2 + + client/app: + dependencies: + '@aps/contracts': + specifier: workspace:* + version: link:../../contracts + + client/desktop: {} + + contracts: {} + + providers/aps: + dependencies: + '@aps/contracts': + specifier: workspace:* + version: link:../../contracts + '@aps/provider-sdk': + specifier: workspace:* + version: link:../../server/provider-sdk + + server: + dependencies: + '@aps/contracts': + specifier: workspace:* + version: link:../contracts + '@aps/provider-sdk': + specifier: workspace:* + version: link:provider-sdk + + server/provider-sdk: + dependencies: + '@aps/contracts': + specifier: workspace:* + version: link:../../contracts + +packages: + + '@typescript/typescript-aix-ppc64@7.0.2': + resolution: {integrity: sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==} + engines: {node: '>=16.20.0'} + cpu: [ppc64] + os: [aix] + + '@typescript/typescript-darwin-arm64@7.0.2': + resolution: {integrity: sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [darwin] + + '@typescript/typescript-darwin-x64@7.0.2': + resolution: {integrity: sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [darwin] + + '@typescript/typescript-freebsd-arm64@7.0.2': + resolution: {integrity: sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [freebsd] + + '@typescript/typescript-freebsd-x64@7.0.2': + resolution: {integrity: sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [freebsd] + + '@typescript/typescript-linux-arm64@7.0.2': + resolution: {integrity: sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [linux] + + '@typescript/typescript-linux-arm@7.0.2': + resolution: {integrity: sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ==} + engines: {node: '>=16.20.0'} + cpu: [arm] + os: [linux] + + '@typescript/typescript-linux-loong64@7.0.2': + resolution: {integrity: sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ==} + engines: {node: '>=16.20.0'} + cpu: [loong64] + os: [linux] + + '@typescript/typescript-linux-mips64el@7.0.2': + resolution: {integrity: sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA==} + engines: {node: '>=16.20.0'} + cpu: [mips64el] + os: [linux] + + '@typescript/typescript-linux-ppc64@7.0.2': + resolution: {integrity: sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA==} + engines: {node: '>=16.20.0'} + cpu: [ppc64] + os: [linux] + + '@typescript/typescript-linux-riscv64@7.0.2': + resolution: {integrity: sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ==} + engines: {node: '>=16.20.0'} + cpu: [riscv64] + os: [linux] + + '@typescript/typescript-linux-s390x@7.0.2': + resolution: {integrity: sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw==} + engines: {node: '>=16.20.0'} + cpu: [s390x] + os: [linux] + + '@typescript/typescript-linux-x64@7.0.2': + resolution: {integrity: sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [linux] + + '@typescript/typescript-netbsd-arm64@7.0.2': + resolution: {integrity: sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [netbsd] + + '@typescript/typescript-netbsd-x64@7.0.2': + resolution: {integrity: sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [netbsd] + + '@typescript/typescript-openbsd-arm64@7.0.2': + resolution: {integrity: sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [openbsd] + + '@typescript/typescript-openbsd-x64@7.0.2': + resolution: {integrity: sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [openbsd] + + '@typescript/typescript-sunos-x64@7.0.2': + resolution: {integrity: sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [sunos] + + '@typescript/typescript-win32-arm64@7.0.2': + resolution: {integrity: sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [win32] + + '@typescript/typescript-win32-x64@7.0.2': + resolution: {integrity: sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [win32] + + typescript@7.0.2: + resolution: {integrity: sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==} + engines: {node: '>=16.20.0'} + hasBin: true + +snapshots: + + '@typescript/typescript-aix-ppc64@7.0.2': + optional: true + + '@typescript/typescript-darwin-arm64@7.0.2': + optional: true + + '@typescript/typescript-darwin-x64@7.0.2': + optional: true + + '@typescript/typescript-freebsd-arm64@7.0.2': + optional: true + + '@typescript/typescript-freebsd-x64@7.0.2': + optional: true + + '@typescript/typescript-linux-arm64@7.0.2': + optional: true + + '@typescript/typescript-linux-arm@7.0.2': + optional: true + + '@typescript/typescript-linux-loong64@7.0.2': + optional: true + + '@typescript/typescript-linux-mips64el@7.0.2': + optional: true + + '@typescript/typescript-linux-ppc64@7.0.2': + optional: true + + '@typescript/typescript-linux-riscv64@7.0.2': + optional: true + + '@typescript/typescript-linux-s390x@7.0.2': + optional: true + + '@typescript/typescript-linux-x64@7.0.2': + optional: true + + '@typescript/typescript-netbsd-arm64@7.0.2': + optional: true + + '@typescript/typescript-netbsd-x64@7.0.2': + optional: true + + '@typescript/typescript-openbsd-arm64@7.0.2': + optional: true + + '@typescript/typescript-openbsd-x64@7.0.2': + optional: true + + '@typescript/typescript-sunos-x64@7.0.2': + optional: true + + '@typescript/typescript-win32-arm64@7.0.2': + optional: true + + '@typescript/typescript-win32-x64@7.0.2': + optional: true + + typescript@7.0.2: + optionalDependencies: + '@typescript/typescript-aix-ppc64': 7.0.2 + '@typescript/typescript-darwin-arm64': 7.0.2 + '@typescript/typescript-darwin-x64': 7.0.2 + '@typescript/typescript-freebsd-arm64': 7.0.2 + '@typescript/typescript-freebsd-x64': 7.0.2 + '@typescript/typescript-linux-arm': 7.0.2 + '@typescript/typescript-linux-arm64': 7.0.2 + '@typescript/typescript-linux-loong64': 7.0.2 + '@typescript/typescript-linux-mips64el': 7.0.2 + '@typescript/typescript-linux-ppc64': 7.0.2 + '@typescript/typescript-linux-riscv64': 7.0.2 + '@typescript/typescript-linux-s390x': 7.0.2 + '@typescript/typescript-linux-x64': 7.0.2 + '@typescript/typescript-netbsd-arm64': 7.0.2 + '@typescript/typescript-netbsd-x64': 7.0.2 + '@typescript/typescript-openbsd-arm64': 7.0.2 + '@typescript/typescript-openbsd-x64': 7.0.2 + '@typescript/typescript-sunos-x64': 7.0.2 + '@typescript/typescript-win32-arm64': 7.0.2 + '@typescript/typescript-win32-x64': 7.0.2 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..c9c498f --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,8 @@ +# 工作区定义(任务 A1.1)。包边界与依赖方向见 docs/adr/0001 与架构设计第 2 节。 +packages: + - contracts + - server + - server/provider-sdk + - client/app + - client/desktop + - providers/aps \ No newline at end of file diff --git a/providers/aps/index.ts b/providers/aps/index.ts new file mode 100644 index 0000000..7f7b3a4 --- /dev/null +++ b/providers/aps/index.ts @@ -0,0 +1,15 @@ +/** + * APS Provider(架构设计第 6 节):把 APS 的能力翻译成平台契约。 + * + * 只做适配:参数校验、调用 APS、结果归一化。不判断权限、不碰模型上下文。 + * APS 本身是独立系统(Python),以现有代码搬迁适配——见决策 D8 与任务 B1~B7。 + */ +import type { CapabilityProvider, ProviderManifest } from '@aps/provider-sdk'; + +export const APS_PROVIDER_ID = 'aps'; + +export function manifest(): ProviderManifest { + return { id: APS_PROVIDER_ID, capabilities: [] }; +} + +export const provider: Pick = { manifest }; \ No newline at end of file diff --git a/providers/aps/package.json b/providers/aps/package.json new file mode 100644 index 0000000..9abb988 --- /dev/null +++ b/providers/aps/package.json @@ -0,0 +1,15 @@ +{ + "name": "@aps/provider-aps", + "version": "0.0.0", + "private": true, + "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "scripts": { + "typecheck": "tsc -b" + }, + "dependencies": { + "@aps/contracts": "workspace:*", + "@aps/provider-sdk": "workspace:*" + } +} \ No newline at end of file diff --git a/providers/aps/tsconfig.json b/providers/aps/tsconfig.json new file mode 100644 index 0000000..3c83041 --- /dev/null +++ b/providers/aps/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "dist", + "tsBuildInfoFile": "dist/.tsbuildinfo" + }, + "include": ["index.ts"], + "references": [ + { "path": "../../contracts" }, + { "path": "../../server/provider-sdk" } + ] +} \ No newline at end of file diff --git a/server/README.md b/server/README.md new file mode 100644 index 0000000..34df411 --- /dev/null +++ b/server/README.md @@ -0,0 +1,22 @@ +# @aps/server + +平台服务。目录按架构设计第 2 节建立,各模块的边界与「不该出现什么」以该节为准。 + +| 目录 | 职责 | 不该出现什么 | +| --- | --- | --- | +| `entry/` | HTTP / SSE 入口、会话、鉴权 | 业务规则、直接调业务系统 | +| `app/` | 请求编排、能力查询、审批流转、事件推送 | 引擎内部概念、直接 import Pi | +| `agent/` | 引擎适配:`AgentRuntime` 接口 + Pi / Codex 实现 | 业务规则、碰凭据 | +| `core/` | 能力目录、身份映射、策略、凭据、执行、审计 | 业务数据、直接拼业务系统 URL | +| `workflows/` | 跨系统顺序流程 | 配置化 DAG 引擎 | + +依赖方向(A1.2 会接入 CI 检查): + +``` +contracts ← provider-sdk ← server ← client + ↑ + providers/* +``` + +- `providers/*` 只依赖 `@aps/provider-sdk`(与 `@aps/contracts`),不依赖 `@aps/server` +- 只有 `agent/` 允许 import 引擎包;其它模块必须经这一层 \ No newline at end of file diff --git a/server/agent/.gitkeep b/server/agent/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/server/app/.gitkeep b/server/app/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/server/core/.gitkeep b/server/core/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/server/entry/.gitkeep b/server/entry/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/server/index.ts b/server/index.ts new file mode 100644 index 0000000..33c7605 --- /dev/null +++ b/server/index.ts @@ -0,0 +1,13 @@ +/** + * 平台服务(架构设计第 2 节):引擎中立的服务端。 + * + * 内部模块与边界: + * entry/ HTTP / SSE 入口、会话、鉴权(只做协议,不做业务) + * app/ 应用服务:请求编排、能力查询、审批流转、事件推送 + * agent/ 引擎适配:统一 AgentRuntime 接口 + Pi / Codex 实现(唯一允许 import 引擎的地方) + * core/ 控制面:能力目录、身份、策略、凭据、执行、审计 + * workflows/ 跨系统顺序流程 + * + * 依赖方向:contracts ← provider-sdk ← server ← client。server 不 import client 与 providers/*。 + */ +export const SERVER_PACKAGE = '@aps/server'; \ No newline at end of file diff --git a/server/package.json b/server/package.json new file mode 100644 index 0000000..86be7fc --- /dev/null +++ b/server/package.json @@ -0,0 +1,21 @@ +{ + "name": "@aps/server", + "version": "0.0.0", + "private": true, + "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + } + }, + "scripts": { + "typecheck": "tsc -b" + }, + "dependencies": { + "@aps/contracts": "workspace:*", + "@aps/provider-sdk": "workspace:*" + } +} \ No newline at end of file diff --git a/server/provider-sdk/index.ts b/server/provider-sdk/index.ts new file mode 100644 index 0000000..652533b --- /dev/null +++ b/server/provider-sdk/index.ts @@ -0,0 +1,18 @@ +/** + * Provider 契约(架构设计第 6 节):业务系统接入平台的唯一形状。 + * + * 只有三个方法:查能力、执行、查状态。Provider 是适配器,不是业务系统,也不承载模型上下文。 + * 能力描述怎么写见 docs/spec/capability-description.md;契约测试套件见任务 A2.4。 + */ +import type { CapabilityId, ExecutionReceipt } from '@aps/contracts'; + +export interface ProviderManifest { + id: string; + capabilities: CapabilityId[]; +} + +export interface CapabilityProvider { + manifest(): ProviderManifest; + execute(capabilityId: CapabilityId, params: unknown): Promise; + status(executionId: string): Promise; +} \ No newline at end of file diff --git a/server/provider-sdk/package.json b/server/provider-sdk/package.json new file mode 100644 index 0000000..573f843 --- /dev/null +++ b/server/provider-sdk/package.json @@ -0,0 +1,20 @@ +{ + "name": "@aps/provider-sdk", + "version": "0.0.0", + "private": true, + "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + } + }, + "scripts": { + "typecheck": "tsc -b" + }, + "dependencies": { + "@aps/contracts": "workspace:*" + } +} \ No newline at end of file diff --git a/server/provider-sdk/tsconfig.json b/server/provider-sdk/tsconfig.json new file mode 100644 index 0000000..109ea82 --- /dev/null +++ b/server/provider-sdk/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "dist", + "tsBuildInfoFile": "dist/.tsbuildinfo" + }, + "include": ["index.ts"], + "references": [{ "path": "../../contracts" }] +} \ No newline at end of file diff --git a/server/tsconfig.json b/server/tsconfig.json new file mode 100644 index 0000000..6685bbe --- /dev/null +++ b/server/tsconfig.json @@ -0,0 +1,14 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "dist", + "tsBuildInfoFile": "dist/.tsbuildinfo" + }, + "include": ["index.ts", "entry", "app", "agent", "core", "workflows"], + "exclude": ["provider-sdk"], + "references": [ + { "path": "../contracts" }, + { "path": "provider-sdk" } + ] +} \ No newline at end of file diff --git a/server/workflows/.gitkeep b/server/workflows/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 0000000..02d3de6 --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "ES2022", + "lib": ["ES2022"], + "module": "NodeNext", + "moduleResolution": "NodeNext", + "strict": true, + "noUncheckedIndexedAccess": true, + "exactOptionalPropertyTypes": true, + "verbatimModuleSyntax": true, + "isolatedModules": true, + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "composite": true, + "incremental": true, + "noEmitOnError": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true + } +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..95c66a9 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,11 @@ +{ + "files": [], + "references": [ + { "path": "contracts" }, + { "path": "server/provider-sdk" }, + { "path": "server" }, + { "path": "client/app" }, + { "path": "client/desktop" }, + { "path": "providers/aps" } + ] +} \ No newline at end of file