@botlearn-course/daemon 0.0.2 → 0.0.4

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
@@ -36,6 +36,12 @@ npx @botlearn-course/daemon@latest course logout
36
36
  | `course doctor` | 打印 Auth 状态(不含 token)与 runtime 探测表(安装路径 / 版本 / 登录状态 / 安装提示)。 |
37
37
  | `--help` / `--version` | 帮助与版本。 |
38
38
 
39
+ 包内还包含供 BotLearn 托管 E2B Template 使用的内部命令
40
+ `botlearn-sandbox-supervisor agent-service session`。它不是 BYOA 用户入口:生产环境只允许由
41
+ Agent Service 以固定 argv 启动,通过 stdin 接收一次性 bootstrap,并把 daemon/runtime 分别降权
42
+ 到 `botlearn-control`/`user` UID。`agent-service session --bootstrap-stdin` 同样属于受 supervisor
43
+ 保护的内部协议,不应直接暴露给课程任务或 workspace shell。
44
+
39
45
  ## 支持的 runtime
40
46
 
41
47
  run 的 `runtime.id` 决定用哪个 adapter 执行;未指定时默认 `codex`。runtime 不可用时 run 会
@@ -99,6 +105,9 @@ runtime 凭据。
99
105
  revoke。
100
106
  - 本包 production 依赖为零,发布 tarball 只包含 `dist/`、`README.md`、`package.json`、
101
107
  `LICENSE`(CI 发布前强制校验)。
108
+ - 托管 session 的 control token/reconnect state 位于 runtime UID 不可访问的 `0700` control home;
109
+ runtime workspace 独立可写,Prompt Pack/Skill 则通过 control-owned、group-readable 的只读视图
110
+ 提供。长期模型 provider key 留在 Agent Service,runtime 只拿 generation-scoped proxy grant。
102
111
 
103
112
  ## 发布
104
113
 
@@ -0,0 +1,67 @@
1
+ import { type Logger } from "./log.js";
2
+ import { type PersistentSessionExecution, type PreparedPersistentTurn, type RunReportingClient } from "./run-dispatcher.js";
3
+ import type { CourseRuntime, CourseRuntimeProfile, RunEvent, RunFileCandidate, RunFileRecord, RunStartPayload } from "./types.js";
4
+ export interface AgentServiceSessionOptions {
5
+ wsUrl: string;
6
+ sessionId: string;
7
+ sessionToken: string;
8
+ runtimes: Map<string, CourseRuntime>;
9
+ daemonVersion: string;
10
+ runtimeEnv?: Record<string, string>;
11
+ log?: Logger;
12
+ random?: () => number;
13
+ sleep?: (ms: number) => Promise<void>;
14
+ }
15
+ /** Long-running daemon client for one persistent managed sandbox session. */
16
+ export declare class AgentServiceSessionClient implements RunReportingClient, PersistentSessionExecution {
17
+ private readonly options;
18
+ private readonly log;
19
+ private readonly random;
20
+ private readonly sleep;
21
+ private readonly state;
22
+ private readonly dispatcher;
23
+ private readonly attempts;
24
+ private readonly runtimeProfiles;
25
+ private readonly pendingAcks;
26
+ private readonly pendingFilePrepares;
27
+ private readonly pendingFileCommits;
28
+ private readonly fileGrants;
29
+ private readonly inflightCommands;
30
+ private socket;
31
+ private sessionGeneration;
32
+ private connectionEpoch;
33
+ private inboundSeq;
34
+ private heartbeatMs;
35
+ private staleMs;
36
+ private stopped;
37
+ private permanentFailure;
38
+ constructor(options: AgentServiceSessionOptions);
39
+ prepareTurn(payload: RunStartPayload): PreparedPersistentTurn;
40
+ persistNativeSession(sessionId: string): void;
41
+ run(): Promise<void>;
42
+ stop(): void;
43
+ postEvent(agentRunId: string, event: RunEvent): Promise<void>;
44
+ postFile(agentRunId: string, file: RunFileCandidate): Promise<RunFileRecord>;
45
+ uploadFileContent(agentRunId: string, fileId: string, absPath: string, mimeType?: string): Promise<RunFileRecord>;
46
+ getRunRuntimeProfile(agentRunId: string): Promise<CourseRuntimeProfile>;
47
+ private connectOnce;
48
+ private handleHello;
49
+ private assertServerFrame;
50
+ private handleServerFrame;
51
+ private applyDesiredState;
52
+ private reconcileInterruptedCommand;
53
+ private runtimeActivation;
54
+ private ackEventOrFile;
55
+ private acceptFileGrant;
56
+ private replaySpool;
57
+ private sendHeartbeat;
58
+ private sendCommandAck;
59
+ private sendControlFrame;
60
+ private sendFrame;
61
+ private nextOutboundSeq;
62
+ private spoolBytes;
63
+ private enforceSpoolLimit;
64
+ private rejectPending;
65
+ private rejectPendingFiles;
66
+ private persist;
67
+ }