@koalaauto/agentchannel 3.45.2 → 3.45.3

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 (40) hide show
  1. package/dist/src/adapters/codex.js +4 -0
  2. package/dist/src/args.d.ts +1 -1
  3. package/dist/src/args.js +7 -60
  4. package/dist/src/cli-admin.d.ts +3 -0
  5. package/dist/src/cli-admin.js +307 -0
  6. package/dist/src/cli-memory.d.ts +3 -0
  7. package/dist/src/cli-memory.js +138 -0
  8. package/dist/src/cli-run.d.ts +28 -0
  9. package/dist/src/cli-run.js +429 -0
  10. package/dist/src/cli-shared.d.ts +73 -0
  11. package/dist/src/cli-shared.js +159 -0
  12. package/dist/src/cli.d.ts +9 -38
  13. package/dist/src/cli.js +21 -1181
  14. package/dist/src/client.d.ts +0 -22
  15. package/dist/src/client.js +0 -29
  16. package/dist/src/codexdaemon.d.ts +22 -0
  17. package/dist/src/codexdaemon.js +68 -0
  18. package/dist/src/invite_people.d.ts +31 -0
  19. package/dist/src/invite_people.js +238 -0
  20. package/dist/src/invite_person.d.ts +1 -1
  21. package/dist/src/invite_person.js +1 -1
  22. package/dist/src/mcp.d.ts +1 -1
  23. package/dist/src/mcp.js +7 -47
  24. package/dist/src/prompts.d.ts +2 -2
  25. package/dist/src/prompts.js +6 -17
  26. package/dist/src/runner/home.d.ts +45 -0
  27. package/dist/src/runner/home.js +150 -0
  28. package/dist/src/runner/runner.d.ts +3 -76
  29. package/dist/src/runner/runner.js +24 -326
  30. package/dist/src/runner/structured.d.ts +20 -0
  31. package/dist/src/runner/structured.js +64 -0
  32. package/dist/src/runner/traces.d.ts +29 -0
  33. package/dist/src/runner/traces.js +119 -0
  34. package/dist/src/sandboxcheck.d.ts +3 -0
  35. package/dist/src/sandboxcheck.js +16 -1
  36. package/dist/src/version.d.ts +1 -1
  37. package/dist/src/version.js +1 -1
  38. package/package.json +1 -1
  39. package/dist/src/import.d.ts +0 -244
  40. package/dist/src/import.js +0 -998
@@ -8,6 +8,7 @@ import { fileURLToPath } from 'node:url';
8
8
  import { codexSandboxOverrides } from './adapters/codex.js';
9
9
  import { linkWindowsSandbox, unlinkWindowsSandbox, WINDOWS_ELEVATED_CONFIG } from './codexhome.js';
10
10
  import { toolchainReadRoots } from './adapters/paths.js';
11
+ import { CODEX_DAEMON_PREFIX, ensureCodexDaemonDir } from './codexdaemon.js';
11
12
  /**
12
13
  * A program's output as text: UTF-8, else (Windows programs write in the console code page) GBK, the code page of the Chinese
13
14
  * Windows machines this runs on (echo-duck-pr's check showed cmd's GBK message as U+FFFD), else UTF-8 with replacements.
@@ -199,7 +200,7 @@ export async function probeSandbox(tool, o = {}) {
199
200
  const platform = o.platform ?? process.platform;
200
201
  const host = o.host ?? detectHost(env, platform);
201
202
  const run = o.run ?? defaultRun;
202
- const st = await probe(tool, { env, platform, host, run, home: o.home ?? homedir(), codex: o.codex, hub: o.hub, runEnv: o.runEnv ?? env, codexHome: o.codexHome ?? (env.CODEX_HOME || join(o.home ?? homedir(), '.codex')) });
203
+ const st = await probe(tool, { env, platform, host, run, home: o.home ?? homedir(), codex: o.codex, hub: o.hub, runEnv: o.runEnv ?? env, codexHome: o.codexHome ?? (env.CODEX_HOME || join(o.home ?? homedir(), '.codex')), codexDaemon: o.codexDaemon ?? (o.run ? () => null : ensureCodexDaemonDir) });
203
204
  if (!st.ok)
204
205
  st.fix = sandboxFix(st, host);
205
206
  return st;
@@ -249,6 +250,9 @@ async function probe(tool, o) {
249
250
  codex = o.codex ?? codexCommand(env);
250
251
  if (!codex)
251
252
  return { tool, ok: true, unverified: true, detail: 'Codex was not found' };
253
+ const daemon = platform === 'win32' ? null : o.codexDaemon();
254
+ if (daemon?.problem)
255
+ return { tool, ok: false, problem: 'failed', detail: daemon.problem };
252
256
  const cmd = platform === 'win32' ? [process.execPath, '-e', WIN_PROBE_SCRIPT, join(dir, 'ok'), outside] : sh;
253
257
  if (canary)
254
258
  writeFileSync(canary, 'probe\n', { mode: 0o600 });
@@ -376,6 +380,17 @@ export function sandboxFix(st, host) {
376
380
  commands: [cmd],
377
381
  };
378
382
  }
383
+ // Codex's socket folder (codexdaemon.ts) that the runner could not put right itself
384
+ if (st.tool === 'codex' && st.detail?.includes(CODEX_DAEMON_PREFIX)) {
385
+ const dir = st.detail.split(' ')[0];
386
+ if (/ belongs to uid /.test(st.detail)) {
387
+ const cmd = `sudo rm -rf ${dir}`;
388
+ return { en: `${dir} belongs to another user; Codex's sandbox needs it as this user's own: remove it.`, zh: `${dir} 属于别的用户,Codex 的沙箱要求它归本用户所有:删掉它。`, commands: [cmd] };
389
+ }
390
+ if (/does not keep modes/.test(st.detail)) {
391
+ return { en: `This machine's /tmp does not keep file modes, which Codex's sandbox needs: give the runner a /tmp of its own (tmpfs).`, zh: `这台机器的 /tmp 不保留文件权限,Codex 的沙箱需要它:给 runner 一个独立的 /tmp(tmpfs)。`, commands: [] };
392
+ }
393
+ }
379
394
  switch (st.problem) {
380
395
  case 'not-logged-in': {
381
396
  const cmd = st.tool === 'claude' ? 'claude auth login' : 'codex login';
@@ -1,4 +1,4 @@
1
- export declare const VERSION = "3.45.2";
1
+ export declare const VERSION = "3.45.3";
2
2
  /** The npm package (scripts/release.mjs keeps it and VERSION in step with package.json). */
3
3
  export declare const PKG_NAME = "@koalaauto/agentchannel";
4
4
  /**
@@ -1,4 +1,4 @@
1
- export const VERSION = '3.45.2';
1
+ export const VERSION = '3.45.3';
2
2
  /** The npm package (scripts/release.mjs keeps it and VERSION in step with package.json). */
3
3
  export const PKG_NAME = '@koalaauto/agentchannel';
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koalaauto/agentchannel",
3
- "version": "3.45.2",
3
+ "version": "3.45.3",
4
4
  "description": "Hand work between your team's agents (Claude Code, Codex) and follow it in one panel: the ach CLI, MCP server and runner for AgentChannel v2",
5
5
  "keywords": [
6
6
  "agentchannel",
@@ -1,244 +0,0 @@
1
- import type { Client } from './client.js';
2
- export interface ExecResult {
3
- code: number;
4
- stdout: string;
5
- stderr: string;
6
- }
7
- export type Exec = (cmd: string, args: string[]) => Promise<ExecResult>;
8
- /** Runs `gh` / `lark-cli` (ACH_GH_CLI / ACH_LARK_CLI override the binaries). */
9
- export declare function makeExec(env: NodeJS.ProcessEnv): Exec;
10
- export declare class ImportError extends Error {
11
- }
12
- export interface GhItem {
13
- kind: 'github_issue' | 'github_pr';
14
- repo: string;
15
- number: number;
16
- url: string;
17
- state: string;
18
- title: string;
19
- author: string;
20
- author_bot: boolean;
21
- assignees: string[];
22
- created_at: string;
23
- updated_at: string;
24
- /** when it was closed or merged ('' while open) */
25
- closed_at: string;
26
- labels: string[];
27
- excerpt: string;
28
- }
29
- export interface RepoData {
30
- full: string;
31
- name: string;
32
- description: string;
33
- pushedAt: string;
34
- commits: {
35
- login: string;
36
- name: string;
37
- bot: boolean;
38
- }[];
39
- issues: GhItem[];
40
- prs: GhItem[];
41
- }
42
- export interface Collected {
43
- org: string;
44
- since: string;
45
- self: string;
46
- repos: RepoData[];
47
- users: Record<string, {
48
- name: string;
49
- email: string;
50
- bot: boolean;
51
- }>;
52
- }
53
- export interface PlanChannel {
54
- name: string;
55
- title?: string;
56
- description?: string;
57
- repos: string[];
58
- visibility?: 'team' | 'private';
59
- stats?: {
60
- issues: number;
61
- prs: number;
62
- commits: number;
63
- };
64
- }
65
- export interface PlanPerson {
66
- github_login: string;
67
- name: string;
68
- email?: string;
69
- is_admin?: boolean;
70
- self?: boolean;
71
- invite: boolean;
72
- note?: string;
73
- channels?: string[];
74
- stats?: {
75
- commits: number;
76
- issues_opened: number;
77
- prs_opened: number;
78
- assigned: number;
79
- commits_by_repo: Record<string, number>;
80
- };
81
- feishu_open_id?: string;
82
- }
83
- export interface Plan {
84
- version: 1;
85
- source: {
86
- kind: 'github';
87
- org: string;
88
- };
89
- since: string;
90
- generated_at: string;
91
- channels: PlanChannel[];
92
- people: PlanPerson[];
93
- bots: string[];
94
- unlinked_commit_authors: string[];
95
- counts: {
96
- repos: number;
97
- issues: number;
98
- prs: number;
99
- commits: number;
100
- };
101
- }
102
- /** "60d", "8w", "3m" (months), or an ISO date -> ISO time. */
103
- export declare function parseSince(s: string | undefined, now?: number): string;
104
- /** Bots never become people: [bot] logins, GitHub type Bot, known agent names, *bot. */
105
- export declare function isBot(login: string, flagged?: boolean): boolean;
106
- export declare function excerptOf(body: string | undefined, max?: number): string;
107
- /** Items whose labels or title name one of these are never sent to the hub (case-insensitive substring). */
108
- export declare const DEFAULT_EXCLUDE: string[];
109
- /** Closed/merged items newer than this become posts by default; older ones only seed the wiki. */
110
- export declare const DEFAULT_CLOSED_DAYS = 7;
111
- /** Closed/merged items used to seed Memory (links only): the last N months by default, or all (--seed-all). */
112
- export declare const DEFAULT_SEED_MONTHS = 6;
113
- export interface Selection {
114
- items: GhItem[];
115
- archive: GhItem[];
116
- tooOld: GhItem[];
117
- excluded: GhItem[];
118
- closedCutoff: string;
119
- seedCutoff?: string;
120
- }
121
- export declare function isExcluded(i: Pick<GhItem, 'title' | 'labels'>, terms: string[]): boolean;
122
- /**
123
- * What gets posted. Sensitive items (labels/title match `exclude`) are dropped
124
- * entirely. Open items are posted; closed/merged ones only when they closed
125
- * after `closedCutoff` ('' = all of them); older closed ones go to `archive`.
126
- */
127
- export declare function selectItems(all: GhItem[], o: {
128
- exclude: string[];
129
- closedCutoff: string;
130
- seedCutoff?: string;
131
- }): Selection;
132
- /** --exclude a,b / --no-exclude -> the exclusion terms. */
133
- export declare function excludeTerms(values: Record<string, unknown>): string[];
134
- /** --seed-all / --seed-months N -> the Memory seed cutoff ('' = everything). */
135
- export declare function seedCutoff(values: Record<string, unknown>, now: number): string;
136
- /** The two import ranges as the hub stores them (wizard-ready API fields). */
137
- export declare function importRanges(values: Record<string, unknown>): {
138
- post_closed_days?: number;
139
- seed_months?: number;
140
- seed?: 'all';
141
- };
142
- /** --all / --closed-days N (alias --post-closed-days) -> the closed-item cutoff ('' = no cutoff). */
143
- export declare function closedCutoff(values: Record<string, unknown>, now: number): string;
144
- /** Issues and PRs of one repo updated since `since`. */
145
- export declare function fetchItems(exec: Exec, full: string, since: string, log?: (s: string) => void): Promise<{
146
- issues: GhItem[];
147
- prs: GhItem[];
148
- }>;
149
- export interface GhRelease {
150
- repo: string;
151
- tag: string;
152
- name: string;
153
- url: string;
154
- published_at: string;
155
- }
156
- /** Releases of one repo published since `since` (read-only; drafts skipped). Missing access -> none. */
157
- export declare function fetchReleases(exec: Exec, full: string, since: string): Promise<GhRelease[]>;
158
- /** Read the org from GitHub: active repos, commits, issues, PRs, people. Read-only. */
159
- export declare function collectGithub(exec: Exec, org: string, since: string, o?: {
160
- repos?: string[];
161
- commits?: boolean;
162
- log?: (s: string) => void;
163
- }): Promise<Collected>;
164
- /**
165
- * Default channel mapping: repos grouped by name prefix (`myshow-room`,
166
- * `myshow-video` -> #myshow); a repo that dominates a big group, or an active
167
- * singleton, gets its own channel; quiet singletons go to #general; at most
168
- * `maxChannels` channels besides #general. The plan is a starting point: edit it.
169
- */
170
- export declare function defaultChannels(repos: RepoData[], maxChannels?: number): PlanChannel[];
171
- /** People from commits, issues and PRs; bots excluded. */
172
- export declare function inferPeople(c: Collected, channels: PlanChannel[]): {
173
- people: PlanPerson[];
174
- bots: string[];
175
- unlinked: string[];
176
- };
177
- export declare function buildPlan(c: Collected, now?: Date): Plan;
178
- export declare function readPlan(file: string): Plan;
179
- /** {channel: {login: {commits}}} from the plan's per-person commits by repo (bots excluded). */
180
- export declare function channelStats(plan: Plan): Record<string, Record<string, {
181
- commits: number;
182
- }>>;
183
- type Counts = Record<string, number>;
184
- /** Push plan + items to the hub in chunks; the last request records the sync time. */
185
- export declare function pushToHub(admin: Client, source: string, o: {
186
- plan?: Plan;
187
- items: GhItem[];
188
- archive?: GhItem[];
189
- stats?: Record<string, unknown>;
190
- syncAt: string;
191
- since: string;
192
- ranges?: Record<string, unknown>;
193
- releases?: GhRelease[];
194
- }): Promise<{
195
- counts: Counts;
196
- people: any[];
197
- skipped: string[];
198
- channels: any[];
199
- }>;
200
- /** One set of numbers for the dry-run header and the "Would import" line. */
201
- export declare function selectionCounts(sel: Selection): {
202
- read: number;
203
- issues: number;
204
- prs: number;
205
- items: number;
206
- open: number;
207
- recently_closed: number;
208
- archived: number;
209
- too_old: number;
210
- excluded: number;
211
- };
212
- export declare function selectionLine(sel: Selection, channels: number): string;
213
- export declare function planSummary(plan: Plan, file?: string, sel?: Selection): string;
214
- export interface CmdIo {
215
- env: NodeJS.ProcessEnv;
216
- cwd: string;
217
- out: (s: string) => void;
218
- err: (s: string) => void;
219
- exec?: Exec;
220
- fetch?: import('./client.js').FetchLike;
221
- now?: () => number;
222
- }
223
- /** `ach admin import github` */
224
- export declare function importGithub(values: Record<string, unknown>, positionals: string[], io: CmdIo, admin: () => Client): Promise<number>;
225
- /** --every 5m / 30s / 1h -> milliseconds (at least 1 minute unless ACH_SYNC_MIN_MS allows less, for tests). */
226
- export declare function parseEvery(v: string, env?: NodeJS.ProcessEnv): number;
227
- /**
228
- * `ach admin sync github [--every 5m [--runs N]]`: one sync, or a loop (a failed
229
- * run is reported and the loop goes on). The hub dedupes events, so a repeated
230
- * sync never notifies twice.
231
- */
232
- export declare function syncGithub(values: Record<string, unknown>, positionals: string[], io: CmdIo, admin: () => Client): Promise<number>;
233
- export declare function inviteMessage(name: string, link: string, workspace?: string, assigned?: number): string;
234
- /** The exact login that grants missing user scopes (lark-cli's own syntax; scopes add up across logins). */
235
- export declare function larkScopeHint(scopes?: string[]): string;
236
- /** Missing scopes named in a lark-cli error (JSON `missing_scopes`, or the scope named in the text). */
237
- export declare function larkMissingScopes(out: string): string[];
238
- /**
239
- * `ach admin invite --feishu [--people a,b] [--map login=ou_x ...] [--yes]`
240
- * `ach admin invite --people a,b --yes` (no Feishu: print the links to copy)
241
- * Without --yes nothing is minted or sent: the messages are previewed.
242
- */
243
- export declare function invitePeople(values: Record<string, unknown>, io: CmdIo, admin: () => Client): Promise<number>;
244
- export {};