golem-kit 0.2.2 → 0.2.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.
- package/CHANGELOG.md +5 -0
- package/docs/agents.md +2 -0
- package/package.json +1 -1
- package/src/config.ts +11 -3
- package/src/dev-server.ts +15 -4
- package/src/runtime/session.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.3
|
|
4
|
+
|
|
5
|
+
- A model pin follows its agent: change `chat.agent` (or `agents.builder`) and the conversation saved on the old agent is retired on the next start instead of resumed with the new agent's pin. It stays readable in `.golem/conversations.json`, marked, and the next message opens a fresh conversation on the configured agent.
|
|
6
|
+
- `chat: { provider: 'tmux', sandbox: 'none' }` launches the chat agent on the builder's bypass profile, for boxes where the CLI's own sandbox cannot start.
|
|
7
|
+
|
|
3
8
|
## 0.2.2
|
|
4
9
|
|
|
5
10
|
- An app pins the model its terminal agents run on: `chat: { provider: 'tmux', agent, model }` for normal-mode chat and `agents.builderModel` for the builder. The pin rides the launch args (`-m` for Codex, `--model` for Claude Code) and is replayed on resume.
|
package/docs/agents.md
CHANGED
|
@@ -31,6 +31,8 @@ export default {
|
|
|
31
31
|
|
|
32
32
|
- `builder` is the default choice in build mode. A person's own pick in the browser still wins and is remembered.
|
|
33
33
|
- `builderModel` pins the builder CLI's model, in that CLI's own spelling (`--model` for Claude Code, `-m` for Codex). A terminal chat pins its own the same way: `chat: { provider: 'tmux', agent: 'codex', model: 'gpt-6-luna' }`. Both survive a resume. Left out, each CLI picks its default.
|
|
34
|
+
- Change `chat.agent` (or `agents.builder`) and the conversation saved on the old agent is retired on the next server start, so its pin never follows it: it stays readable in `.golem/conversations.json`, marked `retired`, and the next message opens a fresh conversation on the configured agent.
|
|
35
|
+
- `chat.sandbox` picks the terminal chat's launch profile: `'read-only'` (the default) is the CLI's own read-only sandbox, `'none'` is the builder's bypass profile. Use `'none'` where the sandbox cannot start, e.g. codex's `bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted` under `kernel.apparmor_restrict_unprivileged_userns=1`.
|
|
34
36
|
- `ordinary` turns on the **Start a chat** button. Leave it out and there is no ordinary chat.
|
|
35
37
|
- `ordinary.model` defaults to `claude-opus-5`.
|
|
36
38
|
- `golem.config.ts` is bundled into the browser. Keep the API key in `.env.local` or the server environment, never in this file.
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -12,7 +12,14 @@ export type ModelConfig = { runtime: 'claude' | 'codex'; name?: string }
|
|
|
12
12
|
* terminal agent in the `chat` window of the app's tmux session, briefed from `docs/chat.md`.
|
|
13
13
|
* `roles` restricts chat to those account roles; absent, anyone signed in may chat.
|
|
14
14
|
*/
|
|
15
|
-
export type ChatConfig = ({ provider: 'anthropic' } | { provider: 'tmux'; agent?: 'codex' | 'claude'; model?: string }) & { roles?: string[] }
|
|
15
|
+
export type ChatConfig = ({ provider: 'anthropic' } | { provider: 'tmux'; agent?: 'codex' | 'claude'; model?: string; sandbox?: 'read-only' | 'none' }) & { roles?: string[] }
|
|
16
|
+
/**
|
|
17
|
+
* The terminal chat's launch profile: the CLI's own read-only sandbox, or — where that sandbox cannot start
|
|
18
|
+
* (codex's bwrap under `kernel.apparmor_restrict_unprivileged_userns=1`) — the builder's bypass profile.
|
|
19
|
+
*/
|
|
20
|
+
export const chatPermissions = (chat: ChatConfig | undefined): 'bypass' | 'readonly' =>
|
|
21
|
+
chat?.provider === 'tmux' && chat.sandbox === 'none' ? 'bypass' : 'readonly'
|
|
22
|
+
|
|
16
23
|
/** `brain: true` serves the app's `brain/` folder read-only and mounts the Brain reader beside the app. */
|
|
17
24
|
|
|
18
25
|
/**
|
|
@@ -70,11 +77,12 @@ export async function loadAppConfig(root = process.cwd()): Promise<AppConfig> {
|
|
|
70
77
|
config.agents = { ...config.agents, ordinary: ordinaryAgent({ backend: 'anthropic', ...rest }) }
|
|
71
78
|
config.chat = { provider, ...chatRoles }
|
|
72
79
|
} else if (provider === 'tmux') {
|
|
73
|
-
const { agent, model, ...unknown } = rest
|
|
80
|
+
const { agent, model, sandbox, ...unknown } = rest
|
|
74
81
|
if (Object.keys(unknown).length) throw new Error(`golem.config.ts chat has unknown fields: ${Object.keys(unknown).join(', ')}`)
|
|
75
82
|
if (agent !== undefined && agent !== 'codex' && agent !== 'claude') throw new Error("golem.config.ts chat.agent must be 'codex' or 'claude'")
|
|
76
83
|
if (model !== undefined && (typeof model !== 'string' || !model)) throw new Error('golem.config.ts chat.model must be a nonempty string')
|
|
77
|
-
|
|
84
|
+
if (sandbox !== undefined && sandbox !== 'read-only' && sandbox !== 'none') throw new Error("golem.config.ts chat.sandbox must be 'read-only' or 'none'")
|
|
85
|
+
config.chat = { provider, ...(agent ? { agent } : {}), ...(model ? { model: model as string } : {}), ...(sandbox ? { sandbox: sandbox as 'read-only' | 'none' } : {}), ...chatRoles }
|
|
78
86
|
} else throw new Error("golem.config.ts chat.provider must be 'anthropic' or 'tmux'")
|
|
79
87
|
} else if (config.agents?.ordinary) config.chat = { provider: 'anthropic' }
|
|
80
88
|
return config
|
package/src/dev-server.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { buildBrowser, rebuild } from './browser-build.ts';
|
|
|
7
7
|
import { createAppBackend, type AppBackend } from './backend/http.ts';
|
|
8
8
|
import { ordinaryChat, type OrdinaryChat } from './chat.ts';
|
|
9
9
|
import { openBrain } from './brain.ts';
|
|
10
|
-
import { serverUrl } from './config.ts';
|
|
10
|
+
import { chatPermissions, serverUrl } from './config.ts';
|
|
11
11
|
import { discoverAgents, runtimeState, type AgentName } from './runtime/discovery.ts';
|
|
12
12
|
import { SessionManager, type Session, type SessionBackend, type SessionSnapshot } from './runtime/session.ts';
|
|
13
13
|
import { TmuxBackend, chatInstructions, type HarnessRef } from './runtime/tmux.ts';
|
|
@@ -46,11 +46,13 @@ export async function startDevServer(
|
|
|
46
46
|
createBackend ??= async (backend, ref, buildMode = true) => {
|
|
47
47
|
if (!ref && !(await discoverAgents()).some((found) => found.agent === backend && found.runnable)) throw new Error(`${backend} is not runnable here`);
|
|
48
48
|
const model = buildMode ? app.config.agents?.builderModel : app.config.chat?.provider === 'tmux' ? app.config.chat.model : undefined;
|
|
49
|
-
return new TmuxBackend(appRoot, backend, ref, { stateDir: join(stateDirectory, 'harness'), api: serverUrl(host, port), window: buildMode ? 'builder' : 'chat', ...(model ? { model } : {}), ...(buildMode ? {} : { instructions: chatInstructions(appRoot), permissions:
|
|
49
|
+
return new TmuxBackend(appRoot, backend, ref, { stateDir: join(stateDirectory, 'harness'), api: serverUrl(host, port), window: buildMode ? 'builder' : 'chat', ...(model ? { model } : {}), ...(buildMode ? {} : { instructions: chatInstructions(appRoot), permissions: chatPermissions(app.config.chat) }) });
|
|
50
50
|
};
|
|
51
51
|
const builder = await builderFlag(stateDirectory);
|
|
52
52
|
const state = new ConversationState(stateDirectory);
|
|
53
|
-
|
|
53
|
+
// Retired conversations are no longer live, but they stay in the file: `save` writes them back beside the rest.
|
|
54
|
+
let retired: SessionSnapshot[] = [];
|
|
55
|
+
const sessions = new SessionManager((snapshots) => state.save([...retired, ...snapshots]));
|
|
54
56
|
const app = await createAppBackend(appRoot, join(stateDirectory, 'data'));
|
|
55
57
|
const chat = ordinaryChat(app);
|
|
56
58
|
const brain = app.config.brain ? openBrain(join(appRoot, 'brain')) : undefined;
|
|
@@ -60,7 +62,16 @@ export async function startDevServer(
|
|
|
60
62
|
owns: (conversation, owner) => { const session = sessions.get(conversation); return session?.backend === 'anthropic' && session.owner === owner; },
|
|
61
63
|
});
|
|
62
64
|
// Restored conversations wait for their next message; nothing is re-run.
|
|
63
|
-
const
|
|
65
|
+
const saved = await state.load();
|
|
66
|
+
// A pin follows its agent: when the app changes `chat.agent` (or `agents.builder`), the conversation saved
|
|
67
|
+
// on the old agent is retired rather than resumed, so the new agent's model never reaches the old CLI. It
|
|
68
|
+
// stays readable in the file, marked; the browser finds no conversation and starts one on the new agent.
|
|
69
|
+
const agentOf = (buildMode: boolean) => buildMode ? app.config.agents?.builder : app.config.chat?.provider === 'tmux' ? app.config.chat.agent : undefined;
|
|
70
|
+
const stale = saved.filter((snapshot) => !snapshot.retired && snapshot.backend !== 'anthropic'
|
|
71
|
+
&& agentOf(snapshot.buildMode) !== undefined && agentOf(snapshot.buildMode) !== snapshot.backend);
|
|
72
|
+
for (const snapshot of stale) console.log(`Retired the ${snapshot.buildMode ? 'builder' : 'chat'} conversation on ${snapshot.backend}: this app now runs ${agentOf(snapshot.buildMode)}.`);
|
|
73
|
+
retired = saved.filter((snapshot) => snapshot.retired || stale.includes(snapshot)).map((snapshot) => ({ ...snapshot, retired: true }));
|
|
74
|
+
const restored = saved.filter((snapshot) => !snapshot.retired && !stale.includes(snapshot));
|
|
64
75
|
const workers = await Promise.all(restored.map((snapshot) => snapshot.backend === 'anthropic'
|
|
65
76
|
? chat.backend(snapshot.transcript)
|
|
66
77
|
: createBackend(snapshot.backend, snapshot.harness as HarnessRef | undefined, snapshot.buildMode)));
|
package/src/runtime/session.ts
CHANGED
|
@@ -392,6 +392,8 @@ export type SessionSnapshot = {
|
|
|
392
392
|
harness?: unknown
|
|
393
393
|
transcript?: unknown
|
|
394
394
|
updatedAt?: string
|
|
395
|
+
/** Set when the app's configured agent no longer matches `backend`: kept in the file, never restored. */
|
|
396
|
+
retired?: boolean
|
|
395
397
|
}
|
|
396
398
|
|
|
397
399
|
export class SessionManager {
|