@mininglamp-oss/cc-channel-octo 1.0.1 → 1.0.2-dev.e347a61
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/CHANGELOG.md +45 -1
- package/README.md +2 -2
- package/dist/agent-bridge.d.ts +12 -0
- package/dist/agent-bridge.js +24 -19
- package/dist/agent-bridge.js.map +1 -1
- package/dist/cli.d.ts +109 -0
- package/dist/cli.js +467 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +16 -0
- package/dist/config.js +14 -0
- package/dist/config.js.map +1 -1
- package/dist/configure.d.ts +11 -0
- package/dist/configure.js +106 -0
- package/dist/configure.js.map +1 -0
- package/dist/gateway.d.ts +6 -1
- package/dist/gateway.js +5 -0
- package/dist/gateway.js.map +1 -1
- package/dist/group-context.d.ts +17 -0
- package/dist/group-context.js +70 -0
- package/dist/group-context.js.map +1 -1
- package/dist/index.d.ts +32 -0
- package/dist/index.js +254 -150
- package/dist/index.js.map +1 -1
- package/dist/mention-utils.d.ts +10 -1
- package/dist/mention-utils.js +16 -2
- package/dist/mention-utils.js.map +1 -1
- package/dist/session-router.d.ts +17 -0
- package/dist/session-router.js +59 -1
- package/dist/session-router.js.map +1 -1
- package/dist/stream-relay.d.ts +1 -1
- package/dist/stream-relay.js +2 -2
- package/dist/stream-relay.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,10 +4,53 @@ All notable changes to this project are documented here.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
While the major version is `0`, minor releases may carry breaking changes.
|
|
8
7
|
|
|
9
8
|
## [Unreleased]
|
|
10
9
|
|
|
10
|
+
## [1.0.2] - 2026-06-24
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Process-supervisor CLI** — `cc-channel-octo start|stop|restart|status`
|
|
15
|
+
backgrounds the gateway, tracks a process-wide PID file, and stops it
|
|
16
|
+
gracefully (SIGTERM → SIGKILL on timeout). The `bin` now points at the
|
|
17
|
+
supervisor (`dist/cli.js`). Backward compatible: a bare `cc-channel-octo`
|
|
18
|
+
(or `npx @mininglamp-oss/cc-channel-octo`) still starts the gateway in the
|
|
19
|
+
foreground, same as before.
|
|
20
|
+
- **`version` / `--version` / `-v`** — prints the package version (read at
|
|
21
|
+
runtime from `package.json`), and the `--help` banner now carries the version
|
|
22
|
+
on its first line.
|
|
23
|
+
- **`configure` subcommand** — `cc-channel-octo configure --gateway-url <url>
|
|
24
|
+
[--model <id>] [--api-url <url>]` writes the LLM gateway URL, optional model
|
|
25
|
+
id, and the Octo IM server URL (`apiUrl`) into the global config without
|
|
26
|
+
hand-editing JSON. The API key is read from the `CC_OCTO_CONFIGURE_API_KEY`
|
|
27
|
+
environment variable so it never appears in the process argument list. This is
|
|
28
|
+
what an automated installer invokes after a fresh global install to make the
|
|
29
|
+
gateway bootable.
|
|
30
|
+
- **`upgrade` subcommand** — `cc-channel-octo upgrade <version>` performs an
|
|
31
|
+
in-place global npm reinstall to the target version and restarts the gateway,
|
|
32
|
+
so an installed gateway can self-update without an external script.
|
|
33
|
+
- **Zero-bot idle startup** — the gateway now boots and stays up with no bound
|
|
34
|
+
bot (previously it required at least one bot to start). A bot bound later via
|
|
35
|
+
provisioning is picked up on the next restart, so a freshly installed gateway
|
|
36
|
+
can come online immediately and wait for its first bot.
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
|
|
40
|
+
- **Configurable gateway URL and model** — the LLM gateway endpoint and model id
|
|
41
|
+
are now read from config (settable via `configure`) instead of being fixed, so
|
|
42
|
+
one build can target different gateways/models per deployment.
|
|
43
|
+
|
|
44
|
+
### Fixed
|
|
45
|
+
|
|
46
|
+
- **Per-message dispatch timeout** — a hung session no longer blocks the bot
|
|
47
|
+
indefinitely; each message dispatch is now bounded by a timeout so a stuck turn
|
|
48
|
+
is released instead of wedging the session (#142).
|
|
49
|
+
- **Outbound `@uid` mention validation** — mentions emitted by the agent are now
|
|
50
|
+
validated against the live group's member set, so invalid/hallucinated `@uid`s
|
|
51
|
+
are dropped instead of being sent (#144, reworked in #145 to use the
|
|
52
|
+
authoritative member set).
|
|
53
|
+
|
|
11
54
|
## [1.0.1] - 2026-06-10
|
|
12
55
|
|
|
13
56
|
The first npm-installable release. No runtime behavior change — packaging only.
|
|
@@ -343,6 +386,7 @@ hardening across the SSRF, prompt-injection, and protocol-DoS surfaces.
|
|
|
343
386
|
Initial tagged baseline: text messaging, streaming output, SQLite session
|
|
344
387
|
persistence, rate limiting, and the core security model.
|
|
345
388
|
|
|
389
|
+
[1.0.2]: https://github.com/Mininglamp-OSS/cc-channel-octo/compare/v1.0.1...v1.0.2
|
|
346
390
|
[1.0.1]: https://github.com/Mininglamp-OSS/cc-channel-octo/compare/v1.0.0...v1.0.1
|
|
347
391
|
[1.0.0]: https://github.com/Mininglamp-OSS/cc-channel-octo/compare/v0.2.0...v1.0.0
|
|
348
392
|
[0.2.0]: https://github.com/Mininglamp-OSS/cc-channel-octo/compare/v0.1.0...v0.2.0
|
package/README.md
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
<a href="https://github.com/Mininglamp-OSS/cc-channel-octo/actions"><img src="https://github.com/Mininglamp-OSS/cc-channel-octo/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
9
|
-
<a href="https://www.npmjs.com/package/cc-channel-octo"><img src="https://img.shields.io/npm/v/cc-channel-octo" alt="npm version"></a>
|
|
9
|
+
<a href="https://www.npmjs.com/package/@mininglamp-oss/cc-channel-octo"><img src="https://img.shields.io/npm/v/@mininglamp-oss/cc-channel-octo" alt="npm version"></a>
|
|
10
10
|
<a href="./LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-blue" alt="License"></a>
|
|
11
|
-
<img src="https://img.shields.io/node/v/cc-channel-octo" alt="Node.js version">
|
|
11
|
+
<img src="https://img.shields.io/node/v/@mininglamp-oss/cc-channel-octo" alt="Node.js version">
|
|
12
12
|
</p>
|
|
13
13
|
|
|
14
14
|
---
|
package/dist/agent-bridge.d.ts
CHANGED
|
@@ -11,6 +11,18 @@
|
|
|
11
11
|
import type { McpServerConfig } from '@anthropic-ai/claude-agent-sdk';
|
|
12
12
|
import type { Config } from './config.js';
|
|
13
13
|
import type { SessionCtx } from './cwd-resolver.js';
|
|
14
|
+
/**
|
|
15
|
+
* Build the SDK subprocess env overlay. The SDK's `env` option REPLACES the
|
|
16
|
+
* subprocess environment, so we spread the base env first to keep
|
|
17
|
+
* PATH/HOME/etc., then layer operator-declared vars and gateway routing.
|
|
18
|
+
* Returns undefined when there is nothing to add (subprocess just inherits).
|
|
19
|
+
* Pure (base env injected) so the injection matrix is unit-testable.
|
|
20
|
+
*
|
|
21
|
+
* Param is narrowed to the fields it reads (not the whole Config['sdk']) so
|
|
22
|
+
* tests pass plain literals — repo lint is `--max-warnings 0` with
|
|
23
|
+
* no-explicit-any, so an `as any` cast in the test would fail the build.
|
|
24
|
+
*/
|
|
25
|
+
export declare function buildSdkEnv(sdk: Pick<Config['sdk'], 'apiKey' | 'anthropicBaseUrl' | 'env'>, baseEnv: NodeJS.ProcessEnv): NodeJS.ProcessEnv | undefined;
|
|
14
26
|
/**
|
|
15
27
|
* @deprecated Back-compat re-export. Section-marker escaping now lives in the
|
|
16
28
|
* shared `prompt-safety` module as `escapeSectionMarkers`. Kept so existing
|
package/dist/agent-bridge.js
CHANGED
|
@@ -12,6 +12,29 @@ import { query as sdkQuery } from '@anthropic-ai/claude-agent-sdk';
|
|
|
12
12
|
import { resolveSessionCwd } from './cwd-resolver.js';
|
|
13
13
|
import { linkSkillsIntoSandbox } from './skill-linker.js';
|
|
14
14
|
import { trustedText, escapeSectionMarkers, CURRENT_MESSAGE_ANCHOR } from './prompt-safety.js';
|
|
15
|
+
/**
|
|
16
|
+
* Build the SDK subprocess env overlay. The SDK's `env` option REPLACES the
|
|
17
|
+
* subprocess environment, so we spread the base env first to keep
|
|
18
|
+
* PATH/HOME/etc., then layer operator-declared vars and gateway routing.
|
|
19
|
+
* Returns undefined when there is nothing to add (subprocess just inherits).
|
|
20
|
+
* Pure (base env injected) so the injection matrix is unit-testable.
|
|
21
|
+
*
|
|
22
|
+
* Param is narrowed to the fields it reads (not the whole Config['sdk']) so
|
|
23
|
+
* tests pass plain literals — repo lint is `--max-warnings 0` with
|
|
24
|
+
* no-explicit-any, so an `as any` cast in the test would fail the build.
|
|
25
|
+
*/
|
|
26
|
+
export function buildSdkEnv(sdk, baseEnv) {
|
|
27
|
+
const extraEnv = sdk.env;
|
|
28
|
+
const hasExtraEnv = extraEnv !== undefined && Object.keys(extraEnv).length > 0;
|
|
29
|
+
if (!sdk.anthropicBaseUrl && !sdk.apiKey && !hasExtraEnv)
|
|
30
|
+
return undefined;
|
|
31
|
+
return {
|
|
32
|
+
...baseEnv,
|
|
33
|
+
...(hasExtraEnv ? extraEnv : {}),
|
|
34
|
+
...(sdk.anthropicBaseUrl ? { ANTHROPIC_BASE_URL: sdk.anthropicBaseUrl } : {}),
|
|
35
|
+
...(sdk.apiKey ? { ANTHROPIC_API_KEY: sdk.apiKey } : {}),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
15
38
|
const VALID_PERMISSION_MODES = new Set([
|
|
16
39
|
'default', 'acceptEdits', 'bypassPermissions', 'plan', 'dontAsk', 'auto',
|
|
17
40
|
]);
|
|
@@ -192,25 +215,7 @@ export async function* queryAgent(userMessage, config, sessionCtx, onToolUse, op
|
|
|
192
215
|
if (sources.length > 0)
|
|
193
216
|
linkSkillsIntoSandbox(cwd, sources);
|
|
194
217
|
}
|
|
195
|
-
|
|
196
|
-
// of mutating the gateway's global process.env. The SDK's `env` REPLACES the
|
|
197
|
-
// subprocess environment entirely, so spread process.env first to preserve
|
|
198
|
-
// PATH/HOME/ANTHROPIC_API_KEY. Scoping here means overrides never leak across
|
|
199
|
-
// requests. When nothing needs adding, omit `env` so the subprocess simply
|
|
200
|
-
// inherits process.env.
|
|
201
|
-
// - sdk.env (#107): operator-declared extra vars (e.g. OCTO_BOT_ID so a
|
|
202
|
-
// multi-bot deploy's octo-cli picks the right profile). Generic — cc does
|
|
203
|
-
// not interpret them.
|
|
204
|
-
// - ANTHROPIC_BASE_URL: model-gateway routing (set last so it wins).
|
|
205
|
-
const extraEnv = config.sdk.env;
|
|
206
|
-
const hasExtraEnv = extraEnv !== undefined && Object.keys(extraEnv).length > 0;
|
|
207
|
-
const env = config.sdk.anthropicBaseUrl || hasExtraEnv
|
|
208
|
-
? {
|
|
209
|
-
...process.env,
|
|
210
|
-
...(hasExtraEnv ? extraEnv : {}),
|
|
211
|
-
...(config.sdk.anthropicBaseUrl ? { ANTHROPIC_BASE_URL: config.sdk.anthropicBaseUrl } : {}),
|
|
212
|
-
}
|
|
213
|
-
: undefined;
|
|
218
|
+
const env = buildSdkEnv(config.sdk, process.env);
|
|
214
219
|
// Build + iterate the SDK stream for a given resume id and prompt. Extracted so
|
|
215
220
|
// a stale/expired `resume` (the SDK throws "No conversation found with session
|
|
216
221
|
// ID: …", verified by spike) can be recovered: clear the bad id and retry once
|
package/dist/agent-bridge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-bridge.js","sourceRoot":"","sources":["../src/agent-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAGnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAI/F,MAAM,sBAAsB,GAAgB,IAAI,GAAG,CAAC;IAClD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C,MAAM,WAAW,GAAG,IAAI,CAAC,mBAAmB,IAAI,WAAW,CAAC;YAC5D,MAAM,YAAY,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;YACpC,KAAK,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,YAAY,CAAC,CAAC;YACpE,OAAO;QACT,CAAC;QACD,4EAA4E;QAC5E,6EAA6E;QAC7E,6EAA6E;QAC7E,4EAA4E;QAC5E,4EAA4E;QAC5E,IAAI,IAAI,EAAE,MAAM,IAAI,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;YACvC,IAAI,CAAC;gBACH,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;YAC1B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,oDAAoD,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACrF,CAAC;QACH,CAAC;QACD,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* cc-channel-octo CLI — a process supervisor for the gateway.
|
|
4
|
+
*
|
|
5
|
+
* The gateway itself (`index.ts`) only runs in the foreground. This thin
|
|
6
|
+
* supervisor backgrounds it, tracks a single process-wide PID file, and stops
|
|
7
|
+
* it gracefully (SIGTERM, then SIGKILL on timeout). It does NOT replace the
|
|
8
|
+
* per-bot `gateway.lock` (which prevents two processes serving the same bot) —
|
|
9
|
+
* the PID file lives at the baseDir root, a sibling of every bot subtree.
|
|
10
|
+
*
|
|
11
|
+
* cc-channel-octo start [--foreground]
|
|
12
|
+
* cc-channel-octo stop [--timeout=<seconds>]
|
|
13
|
+
* cc-channel-octo restart
|
|
14
|
+
* cc-channel-octo status
|
|
15
|
+
*
|
|
16
|
+
* POSIX only (macOS/Linux): stop relies on SIGTERM/SIGKILL. On Windows, run the
|
|
17
|
+
* gateway under a service manager instead — Node has no SIGTERM semantics there.
|
|
18
|
+
*/
|
|
19
|
+
export interface SupervisorPaths {
|
|
20
|
+
baseDir: string;
|
|
21
|
+
pidFile: string;
|
|
22
|
+
logFile: string;
|
|
23
|
+
indexEntry: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Resolve the supervisor's fixed paths. baseDir defaults to the directory of
|
|
27
|
+
* the global config (`~/.cc-channel-octo`); tests inject a temp dir. indexEntry
|
|
28
|
+
* is the compiled gateway entrypoint, a sibling of this file.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveSupervisorPaths(baseDir?: string): SupervisorPaths;
|
|
31
|
+
export interface ParsedArgs {
|
|
32
|
+
cmd: string;
|
|
33
|
+
foreground: boolean;
|
|
34
|
+
timeoutMs: number;
|
|
35
|
+
/** Positional version target for `upgrade` (e.g. `upgrade 1.2.3`); undefined → latest. */
|
|
36
|
+
version?: string;
|
|
37
|
+
/** `configure --gateway-url <url>`. */
|
|
38
|
+
gatewayUrl?: string;
|
|
39
|
+
/** `configure --api-key <key>`. */
|
|
40
|
+
apiKey?: string;
|
|
41
|
+
/** `configure --model <model>` — optional global sdk.model. */
|
|
42
|
+
model?: string;
|
|
43
|
+
/** `configure --api-url <url>` — Octo IM server url (cc top-level apiUrl). */
|
|
44
|
+
apiUrl?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Extract a package version from raw package.json text. Returns 'unknown'
|
|
48
|
+
* rather than throwing if the text is malformed or has no non-empty string
|
|
49
|
+
* `version`. Pure (no I/O) so the fallback paths are unit-testable.
|
|
50
|
+
*/
|
|
51
|
+
export declare function parseVersion(raw: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* The package version, read at runtime from package.json — which lives at the
|
|
54
|
+
* package root, one level up from this module in both src/ (src/cli.ts) and the
|
|
55
|
+
* compiled output (dist/cli.js). Returns 'unknown' if the file can't be read.
|
|
56
|
+
*/
|
|
57
|
+
export declare function readVersion(): string;
|
|
58
|
+
export declare function parseArgs(argv: string[]): ParsedArgs;
|
|
59
|
+
/**
|
|
60
|
+
* Liveness probe via signal 0. EPERM means the process exists but is owned by
|
|
61
|
+
* another user — still "alive" for our purposes; ESRCH means it's gone.
|
|
62
|
+
*/
|
|
63
|
+
export declare function isAlive(pid: number): boolean;
|
|
64
|
+
/** The gateway's PID plus the OS identity recorded when we started it. */
|
|
65
|
+
export interface PidRecord {
|
|
66
|
+
pid: number;
|
|
67
|
+
/** Owner identity (process start time); null for a legacy bare-PID file. */
|
|
68
|
+
id: string | null;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Probe for a process's OS identity, used to detect PID reuse. A PID file by
|
|
72
|
+
* itself is not enough: if the gateway crashes uncleanly and the OS later
|
|
73
|
+
* recycles its PID for an unrelated process, signaling that PID would hit the
|
|
74
|
+
* wrong process. The start time is a cheap, POSIX-portable discriminator — a
|
|
75
|
+
* recycled PID belongs to a process that started later, so its start time
|
|
76
|
+
* differs. Injectable so tests can simulate reuse without real processes.
|
|
77
|
+
*
|
|
78
|
+
* Returns null when the identity can't be read (process gone, `ps` absent);
|
|
79
|
+
* callers treat null as "unverifiable" and fall back to liveness only.
|
|
80
|
+
*/
|
|
81
|
+
export type ProcIdentityFn = (pid: number) => string | null;
|
|
82
|
+
export declare function procStartTime(pid: number): string | null;
|
|
83
|
+
/**
|
|
84
|
+
* Read the PID record. Accepts the current JSON form (`{"pid":N,"id":"…"}`) and
|
|
85
|
+
* the legacy bare-integer form (written by pre-ownership-token releases), which
|
|
86
|
+
* yields a null identity so callers fall back to liveness-only handling.
|
|
87
|
+
*/
|
|
88
|
+
export declare function readPidRecord(pidFile: string): PidRecord | null;
|
|
89
|
+
/** The numeric PID from the file (no ownership check), or null. */
|
|
90
|
+
export declare function readPid(pidFile: string): number | null;
|
|
91
|
+
export declare function writePid(pidFile: string, pid: number, id: string | null): void;
|
|
92
|
+
export declare function removePid(pidFile: string): void;
|
|
93
|
+
/**
|
|
94
|
+
* PID of the running gateway we own, or null. A process counts as ours only if
|
|
95
|
+
* it is alive AND its current OS identity matches the one recorded at start —
|
|
96
|
+
* the guard that stops `stop`/`restart`/`upgrade` from signaling a process that
|
|
97
|
+
* merely inherited the PID after an unclean crash + reuse. Identity mismatch
|
|
98
|
+
* means the file is stale (PID recycled), so it is removed. Legacy files (no
|
|
99
|
+
* recorded identity) and unreadable live identities fall back to liveness only,
|
|
100
|
+
* matching the pre-ownership-token behavior rather than refusing to stop.
|
|
101
|
+
*/
|
|
102
|
+
export declare function resolveOwnedPid(paths: SupervisorPaths, procId: ProcIdentityFn): number | null;
|
|
103
|
+
/**
|
|
104
|
+
* Build the `npm install -g <pkg>@<version>` argument vector. A blank/omitted
|
|
105
|
+
* version installs `@latest`. Pure (no I/O) so the injection guard is unit
|
|
106
|
+
* testable. Throws on an unsafe version string.
|
|
107
|
+
*/
|
|
108
|
+
export declare function buildUpgradeArgs(version?: string): string[];
|
|
109
|
+
export declare function run(argv: string[], baseDir?: string, procId?: ProcIdentityFn): Promise<number>;
|