@ccmsg/cli 0.9.0 → 0.10.1

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.
@@ -0,0 +1,111 @@
1
+ /** 設定ファイル (`config_v2.ts` / `instances/instance-<id>.ts`) が書ける値の型。
2
+ *
3
+ * ccmsg がこのファイルを config home に `ccmsg-config_v2.d.ts` として写すので、
4
+ * 設定ファイルからは `import type { Instance } from "../ccmsg-config_v2"` の形で
5
+ * 参照できる。型だけを持ち、他の何も import しないので、tsconfig の無い場所でも解決する。 */
6
+
7
+ /** ある config home が動かすもの。 */
8
+ export type Harness = "claude" | "codex";
9
+
10
+ /** どこで待ち受け、誰からを受けるか。 */
11
+ export interface Entry {
12
+ host: string;
13
+ /** 0 はカーネルに空きポートを選ばせる。 */
14
+ port: number;
15
+ source_ips: string[];
16
+ /** `X-Forwarded-For` を信じる送り元 (CIDR)。 */
17
+ trusted_proxies: string[];
18
+ }
19
+
20
+ /** 起動レシピが読む値 1 つ。 */
21
+ export interface LauncherParam {
22
+ name: string;
23
+ default: string;
24
+ }
25
+
26
+ export interface LauncherTemplate {
27
+ name: string;
28
+ command: string;
29
+ params?: LauncherParam[];
30
+ shell?: "bash" | "zsh";
31
+ }
32
+
33
+ export interface Launcher {
34
+ root_dirs: string[];
35
+ /** 並び順のまま答える。先頭が既定のレシピ。 */
36
+ templates: LauncherTemplate[];
37
+ depth?: number;
38
+ timeout_secs?: number;
39
+ clean_env?: string[];
40
+ keep_env?: string[];
41
+ }
42
+
43
+ export interface Upstream {
44
+ gateway_url?: string;
45
+ gateway_webhook_source?: string;
46
+ gateway_webhook_token_file?: string;
47
+ /** 末尾に `/` を付けない base URL。 */
48
+ terminal_gateway?: string;
49
+ launcher?: Launcher;
50
+ /** batch を訳すプログラム。絶対パス。 */
51
+ translate_helper?: string;
52
+ sandbox_origin?: string;
53
+ }
54
+
55
+ /** 名前の付いた dump の選択。`types` は型名・その prefix・`-` 付きの除外・
56
+ * 他の preset を差し込む `@name`。 */
57
+ export interface DumpPreset {
58
+ name: string;
59
+ description?: string;
60
+ opts: { types: string[] };
61
+ }
62
+
63
+ export interface Dump {
64
+ presets: DumpPreset[];
65
+ }
66
+
67
+ /** 1 instance 分の設定。`config_v2.ts` が返すのも、`instances/instance-<id>.ts` が
68
+ * `dir` を足して返すのも、これ。
69
+ *
70
+ * mesh の相手はここに書かない。この host の instance は `instances/*.ts` の
71
+ * port から、別 host の endpoint は `peers.json` (`ccmsg mesh add`) から入る。 */
72
+ export interface Config {
73
+ harness: Harness;
74
+ /** 無ければ unix socket だけで serve する。 */
75
+ entry?: Entry;
76
+ upstream: Upstream;
77
+ direct_delivery: boolean;
78
+ fork_origin: boolean;
79
+ dump: Dump;
80
+ }
81
+
82
+ /** instance の設定。`dir` (= config home の絶対パス) が instance を決める。 */
83
+ export interface InstanceConfig extends Config {
84
+ dir: string;
85
+ /** 人向けのラベル。書かなければ id。ファイル名は id なので、変えても何も動かない。 */
86
+ name?: string;
87
+ /** peer と人がこの instance に届く URL (末尾 `/`)。reverse proxy の後ろに
88
+ * 居る instance は、待ち受ける address と届く URL が別で、互いに導けない。
89
+ * mesh の一覧にはこの値が載る (= probe が確定する self、handshake の
90
+ * `iss` / `aud`、人に見せる URL)。書かなければ待ち受ける address になる。 */
91
+ endpoint?: string;
92
+ }
93
+
94
+ /** `config_v2.ts` が default export する関数。
95
+ *
96
+ * `builtin` は組み込みの既定値で、凍らせてあるので書き換えられない。
97
+ * `config` はそのコピーなので、好きに書き換えて返す。 */
98
+ export type Defaults = (ctx: {
99
+ readonly builtin: Readonly<Config>;
100
+ config: Config;
101
+ }) => Config | Promise<Config>;
102
+
103
+ /** `instances/instance-<id>.ts` が default export する関数。
104
+ *
105
+ * `default` は `config_v2.ts` が返した値 (凍結済み)、`config` はそのコピーに
106
+ * `dir` の場所を空で足した物。 */
107
+ export type Instance = (ctx: {
108
+ readonly builtin: Readonly<Config>;
109
+ readonly default: Readonly<Config>;
110
+ config: InstanceConfig;
111
+ }) => InstanceConfig | Promise<InstanceConfig>;