@aiti-ai/aiti-codex-agent 0.1.10 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,38 +1,30 @@
1
1
  # @aiti-ai/aiti-codex-agent
2
2
 
3
- > OpenAI Codex CLI driver —— exec --json + resume 接入 All Sessions;认证双轨(auth.json OAuth / openrouter env),直播与冷回放同形原生工具卡
3
+ > OpenAI Codex CLI driver — exec --json + resume integrated into All Sessions; dual-track auth (auth.json OAuth / openrouter env), live streaming and cold replay render identically-shaped native tool cards
4
4
 
5
- ## 来源 · Origin
5
+ English · [简体中文](./README.zh-CN.md)
6
6
 
7
- 本包是 **aiti** 生态的组成部分——以 [pi](https://pi.dev) 为引擎的个人 AI 开发工作台与本地调试注入生态:**aiti-agent**(自托管 Web 工作台,基于开源项目 [pi-web](https://github.com/aiti-ai/pi-web) 构建,浏览器为主操作面)+ 各开发工具内的调试注入(aiti-devtools)+ 丰富的扩展体系。
7
+ ## About aiti
8
8
 
9
9
  This package is part of the **aiti** ecosystem — a personal AI development workbench powered by [pi](https://pi.dev): **aiti-agent** (a self-hosted web workbench built on the open-source [pi-web](https://github.com/aiti-ai/pi-web)) plus debug injection into mainstream dev tools (aiti-devtools) and a rich extension system.
10
10
 
11
- - 工作台 / workbench: <https://github.com/aiti-ai/pi-web>
12
- - 生态仓库 / monorepo: <https://github.com/aiti-ai/aiti-ai>
13
- - 官网 / site: <https://aiti.pw>
11
+ - Workbench (aiti-agent, built on pi-web): <https://github.com/aiti-ai/pi-web>
12
+ - Ecosystem monorepo: <https://github.com/aiti-ai/aiti-ai>
13
+ - Site: <https://aiti.pw>
14
14
 
15
- ## 功能定位(中文)
15
+ Category: Multi-agent backends · Tags: `codex` · `openai` · `cli` · `session` · `multi-agent`
16
16
 
17
- OpenAI Codex CLI driver —— exec --json + resume 接入 All Sessions;认证双轨(auth.json OAuth / openrouter env),直播与冷回放同形原生工具卡
17
+ ## Install
18
18
 
19
- 多 agent 后端 · tags: `codex` · `openai` · `cli` · `session` · `multi-agent`
19
+ Bundled with **aiti-agent** (`@aiti-ai/pi-web`) — enable it from the in-app extension manager (ExtMan / App Center).
20
20
 
21
- ## Positioning (English)
21
+ Manual install: place this package at `~/.pi/web/extensions/aiti-codex-agent/` and reload pi-web.
22
22
 
23
- OpenAI Codex CLI driver — exec --json + resume integrated into All Sessions; dual-track auth (auth.json OAuth / openrouter env), live streaming and cold replay render identically-shaped native tool cards
23
+ ## Documentation
24
24
 
25
- ## 安装 / 部署
26
-
27
- ```bash
28
- # 部署到 ~/.pi/web/extensions/aiti-codex-agent/ 后 reload
29
- ```
30
-
31
- ## 文档 · Documentation
32
-
33
- - 中文完整文档(aiti-docs): <https://aiti.pw/extensions/aiti-codex-agent.html>
34
- - English docs: <https://aiti.pw/en/extensions/aiti-codex-agent.html>
35
- - 扩展注册表 / registry: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
25
+ - Documentation (English): <https://aiti.pw/en/extensions/aiti-codex-agent.html>
26
+ - 文档(中文): <https://aiti.pw/extensions/aiti-codex-agent.html>
27
+ - Extension registry: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
36
28
 
37
29
  ## License
38
30
 
@@ -0,0 +1,31 @@
1
+ # @aiti-ai/aiti-codex-agent
2
+
3
+ > OpenAI Codex CLI driver —— exec --json + resume 接入 All Sessions;认证双轨(auth.json OAuth / openrouter env),直播与冷回放同形原生工具卡
4
+
5
+ [English](./README.md) · 简体中文
6
+
7
+ ## 关于 aiti
8
+
9
+ 本包是 **aiti** 生态的组成部分——以 [pi](https://pi.dev) 为引擎的个人 AI 开发工作台与本地调试注入生态:**aiti-agent**(自托管 Web 工作台,基于开源项目 [pi-web](https://github.com/aiti-ai/pi-web) 构建,浏览器为主操作面)+ 各开发工具内的调试注入(aiti-devtools)+ 丰富的扩展体系。
10
+
11
+ - 工作台(aiti-agent,基于 pi-web): <https://github.com/aiti-ai/pi-web>
12
+ - 生态仓库: <https://github.com/aiti-ai/aiti-ai>
13
+ - 官网: <https://aiti.pw>
14
+
15
+ 分类: 多 agent 后端 · tags: `codex` · `openai` · `cli` · `session` · `multi-agent`
16
+
17
+ ## 安装
18
+
19
+ 随 **aiti-agent**(`@aiti-ai/pi-web`)捆绑发行——在工作台内的扩展管理器(ExtMan / 应用中心)启用即可。
20
+
21
+ 手动安装:把本包放到 `~/.pi/web/extensions/aiti-codex-agent/` 后 reload。
22
+
23
+ ## 文档
24
+
25
+ - 中文文档: <https://aiti.pw/extensions/aiti-codex-agent.html>
26
+ - Documentation (English): <https://aiti.pw/en/extensions/aiti-codex-agent.html>
27
+ - 扩展注册表: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
28
+
29
+ ## 许可证
30
+
31
+ MIT
package/dev-pack.mjs CHANGED
@@ -77,7 +77,7 @@ export function agentsMdTemplate(extId) {
77
77
 
78
78
  /** 默认 tools/build.mjs(esbuild 单包零配置;扩展自带 tools/build.mjs 则不走到这里)。 */
79
79
  function buildMjsTemplate(extId, extRoot, clientOut, entryRel) {
80
- const repoHint = "/home/pi/workspace/aiti-ai"; // 现场构建探测源码仓 node_modules 用(三机各不同,缺失时走 npm exec)
80
+ // No hardcoded checkout path: candidates are resolved at run time (see repoCandidates below).
81
81
  return `/**
82
82
  * ${extId} · 现场构建入口(dev-pack 默认模板,esbuild 单包零配置)
83
83
  * 用法:node tools/build.mjs
@@ -96,12 +96,25 @@ const entryRel = ${JSON.stringify(entryRel || "")};
96
96
 
97
97
  // esbuild 解析:部署目录 node_modules → 源码仓 node_modules(本机开发场景)→ PATH 上的 esbuild → npm exec 现拉。
98
98
  // 注意:node_modules/esbuild/bin/esbuild 是原生二进制(ELF/Mach-O),必须直接执行(不能当 JS 跑)。
99
+ // Checkout roots are discovered by walking up from the extension dir (a root has node_modules/),
100
+ // plus AITI_REPO_ROOT when set — no machine-specific absolute paths baked into generated files.
101
+ function repoCandidates() {
102
+ const out = [];
103
+ if (process.env.AITI_REPO_ROOT) out.push(process.env.AITI_REPO_ROOT.split(pathSep).join("/") + "/node_modules/esbuild/bin/esbuild");
104
+ let d = extRoot;
105
+ for (let i = 0; i < 8; i++) {
106
+ out.push(d.split(pathSep).join("/") + "/node_modules/esbuild/bin/esbuild");
107
+ const up = dirname(d);
108
+ if (up === d) break;
109
+ d = up;
110
+ }
111
+ return out;
112
+ }
99
113
  function findEsbuild() {
100
114
  const home = (process.env.HOME || process.env.USERPROFILE || "").split(pathSep).join("/");
101
115
  const candidates = [
102
116
  extRoot + "/node_modules/esbuild/bin/esbuild",
103
- home + "/workspace/aiti-ai/node_modules/esbuild/bin/esbuild",
104
- "C:/workspace/aiti-ai/node_modules/esbuild/bin/esbuild", // windows dev box(源码在 D 盘)
117
+ ...repoCandidates(),
105
118
  ];
106
119
  for (const c of candidates) {
107
120
  if (!existsSync(c)) continue;
package/index.ts CHANGED
@@ -48,7 +48,7 @@ function resolveCodexBin(): string {
48
48
  }
49
49
  import { homedir, tmpdir } from "node:os";
50
50
  import { governanceEnv } from "./external-governance.ts";
51
- import { agentSpawnEnv, spawnEnvFeature, spawnCommandFeature, spawnArgsPrefixFeature, spawnEnvList, spawnCommand, spawnArgsPrefix, parseArgsLines, resolveCliLaunch, captureSpawnEnvFeatures } from "@aiti-ai/ext-shared/agent-spawn-env";
51
+ import { agentSpawnEnv, spawnEnvFeature, spawnDisplayEnvFeature, spawnCommandFeature, spawnArgsPrefixFeature, spawnEnvList, spawnCommand, spawnArgsPrefix, parseArgsLines, resolveCliLaunch, captureSpawnEnvFeatures } from "@aiti-ai/ext-shared/agent-spawn-env";
52
52
  import type { LaunchOverride } from "@aiti-ai/ext-shared/agent-spawn-env";
53
53
  // 队列共享实现层(权威源 pi-web-ext/_shared/backend-queue.ts,副本随扩展部署——改动须双向同步)
54
54
  import { createBackendQueueSupport, createQueueFilePersistence, migrateQueueSidecar } from "@aiti-ai/ext-shared/backend-queue";
@@ -732,6 +732,10 @@ class CodexHandle {
732
732
  // ============================================================================
733
733
 
734
734
  let lastKey: string | null = null;
735
+ /** Provider object captured at startup — rescanBackends flips the availability
736
+ * snapshot in place (same identity keeps the createSession/listModels closures)
737
+ * and re-registers it (same registry key overwrites in the host map). */
738
+ let codexProviderRef: Record<string, unknown> | null = null;
735
739
  let counter = 0;
736
740
 
737
741
  // ============================================================================
@@ -823,14 +827,13 @@ function quotaRoute(req: Request, ctx: { path: string[]; method: string; searchP
823
827
  export default {
824
828
  id: "aiti-codex-agent",
825
829
  name: "Codex CLI",
826
- version: "0.1.0",
827
830
  icon: "🌀",
828
831
  // 受控登录统一弹窗(零构建原生 h() client;client/ 下两文件随 deploy 拷贝)
829
832
  // 静态插入点声明(与 client registerItems 的 id 一一对应)
830
833
  // 登录 UI 已统一到 aiti-agent-manager(受控登录弹窗退役,2026-09-13):不再声明
831
834
  // client/ui —— 服务端 /login/* 与 .agent 描述符保留(manager 代理消费)。
832
835
 
833
- features: [spawnEnvFeature("Codex"), spawnCommandFeature("Codex"), spawnArgsPrefixFeature("Codex")],
836
+ features: [spawnEnvFeature("Codex"), spawnDisplayEnvFeature("Codex"), spawnCommandFeature("Codex"), spawnArgsPrefixFeature("Codex")],
834
837
 
835
838
  server: {
836
839
  startup(ctx: {
@@ -880,12 +883,19 @@ export default {
880
883
  });
881
884
  loginApi = mountControlledLoginApi(login);
882
885
  loginCtl = login;
883
- lastKey = ctx.sessionProviders.register({
886
+ // Availability probe (dropdown grey-out): bare name requires a PATH hit —
887
+ // spawn has no npx fallback. Snapshot flips on rescanBackends.
888
+ const codexBin = resolveCodexBin();
889
+ const codexReady = codexBin.includes("/") || Boolean(whichBin(codexBin));
890
+ // provider 对象存模块级 ref:rescanBackends 原地翻转 available 快照后重新 register
891
+ //(同对象身份 → createSession/listModels 闭包保持,宿主 Map 同 key 覆盖)
892
+ const codexProvider = {
884
893
  type: "codex",
885
894
  label: "OpenAI Codex CLI",
886
895
  agentKey: "codex",
887
896
  maxCapabilities: CODEX_CAPABILITIES,
888
- // 静态目录(新建页选后端时给选择器供数据;无会话即可取)
897
+ // Availability snapshot: false = CLI missing → dropdown entry greyed out
898
+ ...(codexReady ? {} : { available: false as const, installHint: "codex CLI (npm i -g @openai/codex)" }),
889
899
  // 静态目录(新建页选后端时给选择器供数据;无会话即可取)——上次使用的模型置顶
890
900
  listModels: async () => withLastUsedFirst(await codexCatalog(), (await readAgentLastUsedModel("codex"))?.id),
891
901
  createSession: async (options) => {
@@ -931,7 +941,9 @@ export default {
931
941
  handle.persistModelState();
932
942
  return handle;
933
943
  },
934
- });
944
+ };
945
+ codexProviderRef = codexProvider;
946
+ lastKey = ctx.sessionProviders.register(codexProvider);
935
947
  // agent 描述符:agent 管理面(aiti-agent-manager)动态发现用——manager 不写死各家
936
948
  ctx.services?.provide?.("aiti-codex-agent.agent", {
937
949
  agent: "codex",
@@ -968,7 +980,29 @@ export default {
968
980
  return handle;
969
981
  },
970
982
  });
971
- console.log(`[aiti-codex-agent] registered: ${lastKey} + launch service`);
983
+ console.log(`[aiti-codex-agent] registered: ${lastKey} + launch service${codexReady ? "" : " (CLI missing — entry greyed out)"}`);
984
+ },
985
+
986
+ /** Backend rescan (POST /api/session-backends/rescan): re-run the availability
987
+ * probe — a CLI installed after host boot lights up without a restart; missing
988
+ * stays greyed out with the install hint. Flips the snapshot on the startup
989
+ * provider object (same closures) and re-registers it. */
990
+ rescanBackends(ctx: { sessionProviders: { register(provider: unknown): string } }) {
991
+ if (!codexProviderRef) return;
992
+ const bin = resolveCodexBin();
993
+ const ready = bin.includes("/") || Boolean(whichBin(bin));
994
+ const p = codexProviderRef as { available?: boolean; installHint?: string };
995
+ if (ready) {
996
+ delete p.available;
997
+ delete p.installHint;
998
+ } else {
999
+ p.available = false;
1000
+ p.installHint = "codex CLI (npm i -g @openai/codex)";
1001
+ }
1002
+ const key = (ctx.sessionProviders as { register(provider: unknown): string }).register(codexProviderRef);
1003
+ const keyStr = typeof lastKey === "string" ? lastKey : key;
1004
+ console.log(`[aiti-codex-agent] rescan: ${ready ? "available" : "not installed"} (${keyStr})`);
1005
+ return ready ? { registered: [keyStr] } : { unavailable: [keyStr] };
972
1006
  },
973
1007
 
974
1008
  /** 受控登录 API:POST /login/start · GET /login/status · POST /login/cancel · POST /login/submit。 */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aiti-ai/aiti-codex-agent",
3
- "version": "0.1.10",
4
- "description": "OpenAI Codex CLI driver (exec --json + resume)",
3
+ "version": "0.1.11",
4
+ "description": "OpenAI Codex CLI driver — exec --json + resume integrated into All Sessions; dual-track auth (auth.json OAuth / openrouter env), live streaming and cold replay render identically-shaped native tool cards",
5
5
  "soul": "Codex 在哪儿跑,面板就在哪儿看。",
6
6
  "scripts": {
7
7
  "build:client": "node -e \"const fs=require('fs');fs.mkdirSync('dist',{recursive:true});for(const f of fs.readdirSync('client/src'))if(f.endsWith('.mjs'))fs.copyFileSync('client/src/'+f,'dist/'+f)\""
@@ -14,10 +14,10 @@
14
14
  },
15
15
  "aitiExtProtocol": "1.0",
16
16
  "dependencies": {
17
- "@aiti-ai/ext-shared": "^0.1.7"
17
+ "@aiti-ai/ext-shared": "^0.1.12"
18
18
  },
19
19
  "license": "MIT",
20
- "contentHash": "a4c701424f5c014f",
20
+ "contentHash": "39122ea131ec1314",
21
21
  "repository": {
22
22
  "type": "git",
23
23
  "url": "git+https://github.com/aiti-ai/aiti-ai.git",