@koalaauto/agentchannel 0.0.0-stage → 3.0.0

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 (71) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +154 -2
  3. package/dist/src/adapters/claude.d.ts +65 -0
  4. package/dist/src/adapters/claude.js +243 -0
  5. package/dist/src/adapters/codex.d.ts +74 -0
  6. package/dist/src/adapters/codex.js +237 -0
  7. package/dist/src/adapters/fake.d.ts +65 -0
  8. package/dist/src/adapters/fake.js +105 -0
  9. package/dist/src/adapters/index.d.ts +11 -0
  10. package/dist/src/adapters/index.js +26 -0
  11. package/dist/src/adapters/paths.d.ts +35 -0
  12. package/dist/src/adapters/paths.js +113 -0
  13. package/dist/src/adapters/procgroup.d.ts +14 -0
  14. package/dist/src/adapters/procgroup.js +49 -0
  15. package/dist/src/adapters/types.d.ts +57 -0
  16. package/dist/src/adapters/types.js +1 -0
  17. package/dist/src/args.d.ts +14 -0
  18. package/dist/src/args.js +257 -0
  19. package/dist/src/attachments.d.ts +63 -0
  20. package/dist/src/attachments.js +227 -0
  21. package/dist/src/attention.d.ts +85 -0
  22. package/dist/src/attention.js +262 -0
  23. package/dist/src/avatars.d.ts +40 -0
  24. package/dist/src/avatars.js +90 -0
  25. package/dist/src/cli.d.ts +45 -0
  26. package/dist/src/cli.js +1822 -0
  27. package/dist/src/client.d.ts +520 -0
  28. package/dist/src/client.js +449 -0
  29. package/dist/src/config.d.ts +62 -0
  30. package/dist/src/config.js +121 -0
  31. package/dist/src/desknotify.d.ts +154 -0
  32. package/dist/src/desknotify.js +426 -0
  33. package/dist/src/doctor.d.ts +75 -0
  34. package/dist/src/doctor.js +375 -0
  35. package/dist/src/env.d.ts +31 -0
  36. package/dist/src/env.js +52 -0
  37. package/dist/src/import.d.ts +245 -0
  38. package/dist/src/import.js +1008 -0
  39. package/dist/src/index.d.ts +13 -0
  40. package/dist/src/index.js +13 -0
  41. package/dist/src/invite.d.ts +103 -0
  42. package/dist/src/invite.js +229 -0
  43. package/dist/src/invite_person.d.ts +16 -0
  44. package/dist/src/invite_person.js +75 -0
  45. package/dist/src/keystore.d.ts +55 -0
  46. package/dist/src/keystore.js +108 -0
  47. package/dist/src/mcp.d.ts +62 -0
  48. package/dist/src/mcp.js +503 -0
  49. package/dist/src/names.d.ts +30 -0
  50. package/dist/src/names.js +108 -0
  51. package/dist/src/netproxy.d.ts +20 -0
  52. package/dist/src/netproxy.js +36 -0
  53. package/dist/src/onboard.d.ts +105 -0
  54. package/dist/src/onboard.js +270 -0
  55. package/dist/src/perm.d.ts +12 -0
  56. package/dist/src/perm.js +20 -0
  57. package/dist/src/prompts.d.ts +166 -0
  58. package/dist/src/prompts.js +409 -0
  59. package/dist/src/runner/runner.d.ts +212 -0
  60. package/dist/src/runner/runner.js +1148 -0
  61. package/dist/src/runner/state.d.ts +68 -0
  62. package/dist/src/runner/state.js +80 -0
  63. package/dist/src/runner/workspace.d.ts +70 -0
  64. package/dist/src/runner/workspace.js +265 -0
  65. package/dist/src/service.d.ts +29 -0
  66. package/dist/src/service.js +101 -0
  67. package/dist/src/version.d.ts +3 -0
  68. package/dist/src/version.js +3 -0
  69. package/dist/src/wiki.d.ts +74 -0
  70. package/dist/src/wiki.js +222 -0
  71. package/package.json +48 -4
@@ -0,0 +1,245 @@
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
+ role?: string;
73
+ note?: string;
74
+ channels?: string[];
75
+ stats?: {
76
+ commits: number;
77
+ issues_opened: number;
78
+ prs_opened: number;
79
+ assigned: number;
80
+ commits_by_repo: Record<string, number>;
81
+ };
82
+ feishu_open_id?: string;
83
+ }
84
+ export interface Plan {
85
+ version: 1;
86
+ source: {
87
+ kind: 'github';
88
+ org: string;
89
+ };
90
+ since: string;
91
+ generated_at: string;
92
+ channels: PlanChannel[];
93
+ people: PlanPerson[];
94
+ bots: string[];
95
+ unlinked_commit_authors: string[];
96
+ counts: {
97
+ repos: number;
98
+ issues: number;
99
+ prs: number;
100
+ commits: number;
101
+ };
102
+ }
103
+ /** "60d", "8w", "3m" (months), or an ISO date -> ISO time. */
104
+ export declare function parseSince(s: string | undefined, now?: number): string;
105
+ /** Bots never become people: [bot] logins, GitHub type Bot, known agent names, *bot. */
106
+ export declare function isBot(login: string, flagged?: boolean): boolean;
107
+ export declare function excerptOf(body: string | undefined, max?: number): string;
108
+ /** Items whose labels or title name one of these are never sent to the hub (case-insensitive substring). */
109
+ export declare const DEFAULT_EXCLUDE: string[];
110
+ /** Closed/merged items newer than this become posts by default; older ones only seed the wiki. */
111
+ export declare const DEFAULT_CLOSED_DAYS = 7;
112
+ /** Closed/merged items used to seed Memory (links only): the last N months by default, or all (--seed-all). */
113
+ export declare const DEFAULT_SEED_MONTHS = 6;
114
+ export interface Selection {
115
+ items: GhItem[];
116
+ archive: GhItem[];
117
+ tooOld: GhItem[];
118
+ excluded: GhItem[];
119
+ closedCutoff: string;
120
+ seedCutoff?: string;
121
+ }
122
+ export declare function isExcluded(i: Pick<GhItem, 'title' | 'labels'>, terms: string[]): boolean;
123
+ /**
124
+ * What gets posted. Sensitive items (labels/title match `exclude`) are dropped
125
+ * entirely. Open items are posted; closed/merged ones only when they closed
126
+ * after `closedCutoff` ('' = all of them); older closed ones go to `archive`.
127
+ */
128
+ export declare function selectItems(all: GhItem[], o: {
129
+ exclude: string[];
130
+ closedCutoff: string;
131
+ seedCutoff?: string;
132
+ }): Selection;
133
+ /** --exclude a,b / --no-exclude -> the exclusion terms. */
134
+ export declare function excludeTerms(values: Record<string, unknown>): string[];
135
+ /** --seed-all / --seed-months N -> the Memory seed cutoff ('' = everything). */
136
+ export declare function seedCutoff(values: Record<string, unknown>, now: number): string;
137
+ /** The two import ranges as the hub stores them (wizard-ready API fields). */
138
+ export declare function importRanges(values: Record<string, unknown>): {
139
+ post_closed_days?: number;
140
+ seed_months?: number;
141
+ seed?: 'all';
142
+ };
143
+ /** --all / --closed-days N (alias --post-closed-days) -> the closed-item cutoff ('' = no cutoff). */
144
+ export declare function closedCutoff(values: Record<string, unknown>, now: number): string;
145
+ /** Issues and PRs of one repo updated since `since`. */
146
+ export declare function fetchItems(exec: Exec, full: string, since: string, log?: (s: string) => void): Promise<{
147
+ issues: GhItem[];
148
+ prs: GhItem[];
149
+ }>;
150
+ export interface GhRelease {
151
+ repo: string;
152
+ tag: string;
153
+ name: string;
154
+ url: string;
155
+ published_at: string;
156
+ }
157
+ /** Releases of one repo published since `since` (read-only; drafts skipped). Missing access -> none. */
158
+ export declare function fetchReleases(exec: Exec, full: string, since: string): Promise<GhRelease[]>;
159
+ /** Read the org from GitHub: active repos, commits, issues, PRs, people. Read-only. */
160
+ export declare function collectGithub(exec: Exec, org: string, since: string, o?: {
161
+ repos?: string[];
162
+ commits?: boolean;
163
+ log?: (s: string) => void;
164
+ }): Promise<Collected>;
165
+ /**
166
+ * Default channel mapping: repos grouped by name prefix (`myshow-room`,
167
+ * `myshow-video` -> #myshow); a repo that dominates a big group, or an active
168
+ * singleton, gets its own channel; quiet singletons go to #general; at most
169
+ * `maxChannels` channels besides #general. The plan is a starting point: edit it.
170
+ */
171
+ export declare function defaultChannels(repos: RepoData[], maxChannels?: number): PlanChannel[];
172
+ /** People from commits, issues and PRs; roles inferred; bots excluded. */
173
+ export declare function inferPeople(c: Collected, channels: PlanChannel[]): {
174
+ people: PlanPerson[];
175
+ bots: string[];
176
+ unlinked: string[];
177
+ };
178
+ export declare function buildPlan(c: Collected, now?: Date): Plan;
179
+ export declare function readPlan(file: string): Plan;
180
+ /** {channel: {login: {commits}}} from the plan's per-person commits by repo (bots excluded). */
181
+ export declare function channelStats(plan: Plan): Record<string, Record<string, {
182
+ commits: number;
183
+ }>>;
184
+ type Counts = Record<string, number>;
185
+ /** Push plan + items to the hub in chunks; the last request records the sync time. */
186
+ export declare function pushToHub(admin: Client, source: string, o: {
187
+ plan?: Plan;
188
+ items: GhItem[];
189
+ archive?: GhItem[];
190
+ stats?: Record<string, unknown>;
191
+ syncAt: string;
192
+ since: string;
193
+ ranges?: Record<string, unknown>;
194
+ releases?: GhRelease[];
195
+ }): Promise<{
196
+ counts: Counts;
197
+ people: any[];
198
+ skipped: string[];
199
+ channels: any[];
200
+ }>;
201
+ /** One set of numbers for the dry-run header and the "Would import" line. */
202
+ export declare function selectionCounts(sel: Selection): {
203
+ read: number;
204
+ issues: number;
205
+ prs: number;
206
+ items: number;
207
+ open: number;
208
+ recently_closed: number;
209
+ archived: number;
210
+ too_old: number;
211
+ excluded: number;
212
+ };
213
+ export declare function selectionLine(sel: Selection, channels: number): string;
214
+ export declare function planSummary(plan: Plan, file?: string, sel?: Selection): string;
215
+ export interface CmdIo {
216
+ env: NodeJS.ProcessEnv;
217
+ cwd: string;
218
+ out: (s: string) => void;
219
+ err: (s: string) => void;
220
+ exec?: Exec;
221
+ fetch?: import('./client.js').FetchLike;
222
+ now?: () => number;
223
+ }
224
+ /** `ach admin import github` */
225
+ export declare function importGithub(values: Record<string, unknown>, positionals: string[], io: CmdIo, admin: () => Client): Promise<number>;
226
+ /** --every 5m / 30s / 1h -> milliseconds (at least 1 minute unless ACH_SYNC_MIN_MS allows less, for tests). */
227
+ export declare function parseEvery(v: string, env?: NodeJS.ProcessEnv): number;
228
+ /**
229
+ * `ach admin sync github [--every 5m [--runs N]]`: one sync, or a loop (a failed
230
+ * run is reported and the loop goes on). The hub dedupes events, so a repeated
231
+ * sync never notifies twice.
232
+ */
233
+ export declare function syncGithub(values: Record<string, unknown>, positionals: string[], io: CmdIo, admin: () => Client): Promise<number>;
234
+ export declare function inviteMessage(name: string, link: string, workspace?: string, assigned?: number): string;
235
+ /** The exact login that grants missing user scopes (lark-cli's own syntax; scopes add up across logins). */
236
+ export declare function larkScopeHint(scopes?: string[]): string;
237
+ /** Missing scopes named in a lark-cli error (JSON `missing_scopes`, or the scope named in the text). */
238
+ export declare function larkMissingScopes(out: string): string[];
239
+ /**
240
+ * `ach admin invite --feishu [--people a,b] [--map login=ou_x ...] [--yes]`
241
+ * `ach admin invite --people a,b --yes` (no Feishu: print the links to copy)
242
+ * Without --yes nothing is minted or sent: the messages are previewed.
243
+ */
244
+ export declare function invitePeople(values: Record<string, unknown>, io: CmdIo, admin: () => Client): Promise<number>;
245
+ export {};