@ulm0/gonogo 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +30 -2
- package/bin/gonogo.js +18 -0
- package/dist/client/THIRD-PARTY-NOTICES.md +409 -0
- package/dist/client/apple-touch-icon.png +0 -0
- package/dist/client/assets/doto-latin-900-normal-D1bF_x6I.woff +0 -0
- package/dist/client/assets/geist-latin-400-normal-B40WzpMT.woff2 +0 -0
- package/dist/client/assets/geist-latin-400-normal-akEymXtG.woff +0 -0
- package/dist/client/assets/geist-latin-500-normal-BDXIbFrL.woff +0 -0
- package/dist/client/assets/geist-latin-500-normal-CTWBw9NS.woff2 +0 -0
- package/dist/client/assets/geist-latin-600-normal-CSETrqM2.woff2 +0 -0
- package/dist/client/assets/geist-latin-600-normal-DsPlZH-9.woff +0 -0
- package/dist/client/assets/geist-mono-latin-400-normal-B2yvC1Cq.woff +0 -0
- package/dist/client/assets/geist-mono-latin-400-normal-DTRLJnHl.woff2 +0 -0
- package/dist/client/assets/geist-mono-latin-500-normal-D-GG86Jb.woff +0 -0
- package/dist/client/assets/geist-mono-latin-500-normal-YINYabwD.woff2 +0 -0
- package/dist/client/assets/geist-mono-latin-600-normal-V-KvD_pi.woff2 +0 -0
- package/dist/client/assets/geist-mono-latin-600-normal-bZn07FKM.woff +0 -0
- package/dist/client/assets/index-B6MsSoeo.css +1 -0
- package/dist/client/assets/index-DRtiRh1Y.js +31 -0
- package/dist/client/favicon.ico +0 -0
- package/dist/client/favicon.svg +1 -0
- package/dist/client/index.html +19 -0
- package/dist/server/cleanroom.js +214 -0
- package/dist/server/cli.js +630 -0
- package/dist/server/command.js +44 -0
- package/dist/server/constants.js +427 -0
- package/dist/server/docking.js +541 -0
- package/dist/server/downlink.js +191 -0
- package/dist/server/home.js +497 -0
- package/dist/server/hooks.js +166 -0
- package/dist/server/hub.js +2484 -0
- package/dist/server/launcher.js +542 -0
- package/dist/server/livery.js +210 -0
- package/dist/server/logsearch.js +112 -0
- package/dist/server/mcp.js +196 -0
- package/dist/server/migrate.js +119 -0
- package/dist/server/missionlog.js +209 -0
- package/dist/server/payload.js +168 -0
- package/dist/server/propellant.js +314 -0
- package/dist/server/providers.js +137 -0
- package/dist/server/relay.js +300 -0
- package/dist/server/relaykinds.js +182 -0
- package/dist/server/schedules.js +277 -0
- package/dist/server/tasks.js +272 -0
- package/dist/server/terminal.js +635 -0
- package/dist/server/uplinks.js +356 -0
- package/dist/server/web.js +1466 -0
- package/dist/shared/cron.js +149 -0
- package/dist/shared/fuel.js +18 -0
- package/dist/shared/livery.js +348 -0
- package/dist/shared/positions.js +132 -0
- package/dist/shared/protocol.js +212 -0
- package/package.json +84 -3
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
import { positionById } from '../shared/positions.js';
|
|
2
|
+
export { AGENT_NAME_MAX, AGENT_NAME_PATTERN, ROLE_MAX_CHARS, DIR_MAX_CHARS, SUBJECT_MAX_CHARS, BODY_MAX_CHARS, MAX_AGENTS, ACTIVITY_WIRE_BODY_CHARS, ACTIVITY_CLIENT_MAX, } from '../shared/protocol.js';
|
|
3
|
+
/* ---- startup and readiness ---- */
|
|
4
|
+
/** Design: not ready 5 s after spawn while the pty is producing output means a startup dialog is waiting. */
|
|
5
|
+
export const STARTUP_READY_TIMEOUT_MS = 5_000;
|
|
6
|
+
/** If the pty has produced no output at the 5 s mark, look again this often (claude may just be slow). */
|
|
7
|
+
export const STARTUP_RECHECK_MS = 1_000;
|
|
8
|
+
/** Design: exit code 1 within 3 s of a start means --session-id/--resume was the wrong flag: flip once and retry. */
|
|
9
|
+
export const SESSION_FLIP_WINDOW_MS = 3_000;
|
|
10
|
+
/**
|
|
11
|
+
* The flip happens only when the exit tail holds claude's own message for the flag that was used (any other exit 1 within
|
|
12
|
+
* 3 s, such as a refused flag, root refusing bypassPermissions or a bad cwd, is a different problem and a retry would hide it):
|
|
13
|
+
* `Error: Session ID <uuid> is already in use.` after --session-id, `No conversation found with session ID: <uuid>` after --resume.
|
|
14
|
+
*/
|
|
15
|
+
export const SESSION_IN_USE_TEXT = 'is already in use';
|
|
16
|
+
export const SESSION_MISSING_TEXT = 'No conversation found with session ID';
|
|
17
|
+
/* ---- stopping ---- */
|
|
18
|
+
/** Design: SIGKILL 5 s after SIGTERM. Measured: claude exits about 2.4 s after SIGTERM (plugin hooks and MCP children). */
|
|
19
|
+
export const STOP_KILL_AFTER_MS = 5_000;
|
|
20
|
+
/** After SIGKILL the exit event comes within milliseconds; if it does not, report the process gone after this long. */
|
|
21
|
+
export const STOP_GIVEUP_AFTER_KILL_MS = 3_000;
|
|
22
|
+
/** Whole-server shutdown: SIGTERM, then KILL_AFTER, then GIVEUP, plus slack. */
|
|
23
|
+
export const SHUTDOWN_MAX_MS = 12_000;
|
|
24
|
+
/* ---- delivery ---- */
|
|
25
|
+
/** Design: the pointer must be confirmed by UserPromptSubmit within 2 s (measured 60-120 ms). */
|
|
26
|
+
export const PROMPT_SUBMIT_CONFIRM_MS = 2_000;
|
|
27
|
+
/** Design: a draft latch that nobody releases stops holding mail after 30 minutes (60 s fired while users only paused). */
|
|
28
|
+
export const DRAFT_EXPIRY_MS = 30 * 60_000;
|
|
29
|
+
/** The screen may clear a draft latch (never set one): the box row must have been empty this long after the last browser input (echo grace; prior-art lesson 27). */
|
|
30
|
+
export const DRAFT_SCREEN_CLEAR_MS = 1_000;
|
|
31
|
+
/** Wait after the first queued message so a burst of messages becomes one pointer. */
|
|
32
|
+
export const DELIVERY_COALESCE_MS = 300;
|
|
33
|
+
/** After a Stop hook the TUI needs a moment to redraw the idle box (title flips within 10-30 ms); wait before typing. */
|
|
34
|
+
export const DELIVERY_SETTLE_MS = 300;
|
|
35
|
+
/** Claude Code ignores the 9th consecutive Stop block (cap 8, resets on a tool call), so never send more than 8. */
|
|
36
|
+
export const MAX_STOP_BLOCKS = 8;
|
|
37
|
+
/** Design: hop cap 8, GONOGO_MAX_HOPS to change it. */
|
|
38
|
+
export const DEFAULT_MAX_HOPS = 8;
|
|
39
|
+
/** Upper bound accepted for GONOGO_MAX_HOPS (a typo such as 8000 would disable the guard). */
|
|
40
|
+
export const MAX_HOPS_LIMIT = 100;
|
|
41
|
+
/** Pointer lists at most this many sender names, then "and others". */
|
|
42
|
+
export const POINTER_MAX_SENDERS = 3;
|
|
43
|
+
/** A message becomes `delivered` at most this many times: one pointer, and one more when the agent's turn ended without read_messages. Then the strip says it was not read. */
|
|
44
|
+
export const POINTER_MAX_ATTEMPTS = 2;
|
|
45
|
+
/** Pointer text always starts with this (never "/", "!", "?" or "@", which the TUI treats as triggers). */
|
|
46
|
+
export const POINTER_PREFIX = 'gonogo: ';
|
|
47
|
+
/* ---- state reconciliation (hooks lie by omission: Esc, denied dialogs and ! commands fire no hook) ---- */
|
|
48
|
+
/** Design: title shows the idle glyph while the state is working for more than 2 s (counted from the later of the glyph change and the last state change) => idle. */
|
|
49
|
+
export const TITLE_IDLE_RECONCILE_MS = 2_000;
|
|
50
|
+
/**
|
|
51
|
+
* Working glyph for this long, counted from the later of the glyph change and the last state change, while the state is idle
|
|
52
|
+
* (R3: shell command, slash command, lost hook) or needs_you for a permission or dialog (R4: the user allowed the tool and
|
|
53
|
+
* no hook fires until it ends) => working. Longer than the 60-120 ms hook latency and the 10-30 ms the title lags a Stop.
|
|
54
|
+
*/
|
|
55
|
+
export const TITLE_WORKING_CONFIRM_MS = 1_000;
|
|
56
|
+
/** Prompt box back on screen, no dialog, idle glyph for this long => the permission dialog was answered without a hook. */
|
|
57
|
+
export const NEEDS_YOU_CLEAR_MS = 1_500;
|
|
58
|
+
/** Cadence of the hub sweep: reconciliation, draft expiry, delivery retries. */
|
|
59
|
+
export const RECONCILE_TICK_MS = 500;
|
|
60
|
+
/* ---- hooks and HTTP ---- */
|
|
61
|
+
/** "timeout" (seconds) written into every http hook; claude's default is 600 s and a hung hook would freeze the agent. */
|
|
62
|
+
export const HOOK_TIMEOUT_S = 10;
|
|
63
|
+
/** PostToolUse carries tool output (a Read of a big file); 8 MiB covers it, bigger gets 413 (a non-blocking error for claude). */
|
|
64
|
+
export const MAX_HOOK_BODY_BYTES = 8 * 1024 * 1024;
|
|
65
|
+
/** Errors that a client can cause after the server started (a reset socket, a destroyed stream, an oversized WebSocket frame): logged, never fatal (contract 2.8). */
|
|
66
|
+
export const TRANSIENT_ERROR_CODES = [
|
|
67
|
+
'ECONNRESET',
|
|
68
|
+
'EPIPE',
|
|
69
|
+
'ERR_STREAM_DESTROYED',
|
|
70
|
+
'ERR_STREAM_WRITE_AFTER_END',
|
|
71
|
+
'ERR_STREAM_PREMATURE_CLOSE',
|
|
72
|
+
'ERR_HTTP_HEADERS_SENT',
|
|
73
|
+
];
|
|
74
|
+
/** Error codes that start with one of these are transient too (the `ws` library reports WS_ERR_*). */
|
|
75
|
+
export const TRANSIENT_ERROR_PREFIXES = ['WS_ERR_'];
|
|
76
|
+
/** MCP JSON-RPC bodies are tiny; send_message bodies are capped at 20,000 chars. */
|
|
77
|
+
export const MAX_MCP_BODY_BYTES = 1024 * 1024;
|
|
78
|
+
/** REST bodies: hire form, edit, a user message of up to 20,000 chars. */
|
|
79
|
+
export const MAX_REST_BODY_BYTES = 256 * 1024;
|
|
80
|
+
export const WS_MAX_FRAME_BYTES = 256 * 1024; // the client splits a paste into WS_INPUT_CHUNK_CHARS pieces (protocol.ts), so only a misbehaving client sends more; bigger frames close the socket with 1009
|
|
81
|
+
export const WS_MAX_BUFFERED_BYTES = 4 * 1024 * 1024; // slow reader: close with 1013 and let it reconnect with a fresh snapshot
|
|
82
|
+
export const WS_PING_INTERVAL_MS = 20_000; // detects dead browsers behind NATs; two missed pongs close the socket
|
|
83
|
+
export const WS_CLOSE_BACKPRESSURE = 1013;
|
|
84
|
+
export const WS_CLOSE_GOING_AWAY = 1001;
|
|
85
|
+
/* ---- terminal ---- */
|
|
86
|
+
export const DEFAULT_COLS = 120; // size used in every experiment of docs/facts
|
|
87
|
+
export const DEFAULT_ROWS = 40;
|
|
88
|
+
export const MIN_COLS = 20; // below this claude's box (needs a rule of >= 20 characters) cannot be recognised
|
|
89
|
+
export const MAX_COLS = 500;
|
|
90
|
+
export const MIN_ROWS = 5;
|
|
91
|
+
export const MAX_ROWS = 200;
|
|
92
|
+
/** Mirror scrollback; the classic renderer keeps history in it, the fullscreen renderer does not use it. */
|
|
93
|
+
export const MIRROR_SCROLLBACK_LINES = 2_000;
|
|
94
|
+
/** serialize({ scrollback }) limit: keeps a snapshot at a few KB (measured 1.8-2.8 KB for a screen). */
|
|
95
|
+
export const SNAPSHOT_SCROLLBACK_LINES = 1_000;
|
|
96
|
+
export const EXIT_TAIL_LINES = 20; // exit reason lines kept for the UI ("No conversation found ...")
|
|
97
|
+
export const EXIT_TAIL_CHARS = 2_000;
|
|
98
|
+
/* ---- hub memory ---- */
|
|
99
|
+
export const ACTIVITY_BACKLOG = 100; // messages loaded from messages.jsonl at start
|
|
100
|
+
export const ACTIVITY_HUB_MAX = 200; // items the hub keeps and sends in StateSnapshot
|
|
101
|
+
export const ROSTER_ROLE_CHARS = 300; // role text per agent in list_roster
|
|
102
|
+
export const PERMISSION_SUMMARY_CHARS = 100; // tool input summary in "permission request: ..."
|
|
103
|
+
/* ---- limits on mail: one agent token must not grow server memory or messages.jsonl without bound ---- */
|
|
104
|
+
/** Unread messages (queued, held or delivered) one recipient may hold: five full read_messages calls, more than an agent can act on. */
|
|
105
|
+
export const MAILBOX_MAX_MESSAGES = 100;
|
|
106
|
+
/** Body characters of that unread mail: 256 KiB, about six full read_messages results, which is all an agent can take in. */
|
|
107
|
+
export const MAILBOX_MAX_BODY_CHARS = 256 * 1024;
|
|
108
|
+
/** Messages one agent may send per rolling SEND_RATE_WINDOW_MS (two a second): a boss briefing all 24 agents at once sends 24. The owner is not limited. */
|
|
109
|
+
export const SEND_RATE_MAX = 120;
|
|
110
|
+
export const SEND_RATE_WINDOW_MS = 60_000;
|
|
111
|
+
/** One read_messages result holds at most this many messages ... */
|
|
112
|
+
export const READ_MAX_MESSAGES = 20;
|
|
113
|
+
/** ... or this many characters of their JSON, whichever comes first: 10,000 tokens of English and 20,000 of symbols, under the 25,000 at which Claude Code refuses an MCP result. */
|
|
114
|
+
export const READ_MAX_CHARS = 40_000;
|
|
115
|
+
/* ---- server defaults ---- */
|
|
116
|
+
export const DEFAULT_PORT = 7777;
|
|
117
|
+
export const DEFAULT_HOST = '127.0.0.1';
|
|
118
|
+
export const DEFAULT_HOME_DIRNAME = '.gonogo';
|
|
119
|
+
export const MIN_NODE_MAJOR = 24;
|
|
120
|
+
export const TOKEN_BYTES = 32; // 32 random bytes = 64 hex chars, for the browser token and for every agent token
|
|
121
|
+
/* ---- files under the home directory ---- */
|
|
122
|
+
export const AGENTS_FILE = 'agents.json';
|
|
123
|
+
export const MESSAGES_FILE = 'messages.jsonl';
|
|
124
|
+
/** messages.jsonl is renamed to this when it is larger than MESSAGES_ROTATE_BYTES at start. */
|
|
125
|
+
export const MESSAGES_ROTATED_FILE = 'messages.jsonl.1';
|
|
126
|
+
export const MESSAGES_ROTATE_BYTES = 32 * 1024 * 1024;
|
|
127
|
+
/** Only this many bytes from the end of messages.jsonl are read at start (history and the id counter), so a long-running home starts fast. */
|
|
128
|
+
export const MESSAGES_TAIL_BYTES = 1024 * 1024;
|
|
129
|
+
/** <home>/server.lock holds the pid of the gonogo that uses the home directory. */
|
|
130
|
+
export const LOCK_FILE = 'server.lock';
|
|
131
|
+
export const BROWSER_TOKEN_FILE = 'token';
|
|
132
|
+
export const AGENTS_DIR = 'agents';
|
|
133
|
+
export const SETTINGS_FILE = 'settings.json';
|
|
134
|
+
export const MCP_FILE = 'mcp.json';
|
|
135
|
+
export const MEMORY_FILE = 'memory.md';
|
|
136
|
+
export const AGENT_TOKEN_FILE = 'token';
|
|
137
|
+
export const DIR_MODE = 0o700;
|
|
138
|
+
export const FILE_MODE = 0o600;
|
|
139
|
+
/* ---- launching claude ---- */
|
|
140
|
+
/** Seed mode: after writing the trust key, read the file back this many times (spaced by the delay) before giving up (claude rewrites the file on every start, O11). */
|
|
141
|
+
export const TRUST_VERIFY_ATTEMPTS = 3;
|
|
142
|
+
export const TRUST_VERIFY_DELAY_MS = 200;
|
|
143
|
+
export const CLAUDE_BIN = 'claude';
|
|
144
|
+
export const TERM_VALUE = 'xterm-256color';
|
|
145
|
+
export const COLORTERM_VALUE = 'truecolor';
|
|
146
|
+
export const HOOK_PATH_PREFIX = '/hook/';
|
|
147
|
+
export const MCP_PATH = '/mcp';
|
|
148
|
+
export const API_KEY_HELPER_COMMAND = 'printenv GONOGO_API_KEY';
|
|
149
|
+
export const ALLOWED_TOOLS = [
|
|
150
|
+
'mcp__gonogo__send_message',
|
|
151
|
+
'mcp__gonogo__list_roster',
|
|
152
|
+
'mcp__gonogo__read_messages',
|
|
153
|
+
'mcp__gonogo__go_nogo',
|
|
154
|
+
'mcp__gonogo__task_list',
|
|
155
|
+
'mcp__gonogo__task_create',
|
|
156
|
+
'mcp__gonogo__task_update',
|
|
157
|
+
'mcp__gonogo__log_write',
|
|
158
|
+
'mcp__gonogo__log_search',
|
|
159
|
+
'mcp__gonogo__log_read',
|
|
160
|
+
'mcp__gonogo__livery_submit',
|
|
161
|
+
];
|
|
162
|
+
/** claude's own cross-session messaging tools, denied so agents use gonogo's tools. */
|
|
163
|
+
export const DENIED_TOOLS = ['SendMessage', 'ListAgents'];
|
|
164
|
+
/** Exact names removed from the child environment (the session identity of the claude that started gonogo, if any). */
|
|
165
|
+
export const SCRUB_ENV_EXACT = [
|
|
166
|
+
'CLAUDECODE',
|
|
167
|
+
'CLAUDE_CODE_CHILD_SESSION',
|
|
168
|
+
'CLAUDE_CODE_SESSION_ID',
|
|
169
|
+
'CLAUDE_CODE_MESSAGING_SOCKET',
|
|
170
|
+
'CLAUDE_CODE_MESSAGING_TOKEN',
|
|
171
|
+
'CLAUDE_CODE_ENTRYPOINT',
|
|
172
|
+
'CLAUDE_CODE_EXECPATH',
|
|
173
|
+
'CLAUDE_CODE_SESSION_ATTENDED',
|
|
174
|
+
'CLAUDE_CODE_BRIDGE_SESSION_ID',
|
|
175
|
+
'CLAUDE_PID',
|
|
176
|
+
'CLAUDE_EFFORT',
|
|
177
|
+
'AI_AGENT',
|
|
178
|
+
'GONOGO_TOKEN',
|
|
179
|
+
'GONOGO_API_KEY',
|
|
180
|
+
];
|
|
181
|
+
/** Also removed, so future members of these identity families do not leak. CLAUDE_CODE_OAUTH_TOKEN and CLAUDE_CONFIG_DIR are kept on purpose. */
|
|
182
|
+
export const SCRUB_ENV_PREFIXES = [
|
|
183
|
+
'CLAUDE_CODE_MESSAGING_',
|
|
184
|
+
'CLAUDE_CODE_SESSION_',
|
|
185
|
+
'CLAUDE_CODE_BRIDGE_',
|
|
186
|
+
'CLAUDE_CODE_CHILD_',
|
|
187
|
+
];
|
|
188
|
+
/* ---- what the TUI draws and sends (claude 2.1.325; see docs/facts/claude-code-terminal.md sections 3 to 5) ---- */
|
|
189
|
+
export const PASTE_START = '\x1b[200~';
|
|
190
|
+
export const PASTE_END = '\x1b[201~';
|
|
191
|
+
export const ENTER = '\r'; // the only submit key; a bare LF only inserts a newline
|
|
192
|
+
export const PROMPT_GLYPH = '❯'; // "❯"
|
|
193
|
+
export const NBSP = ' '; // the prompt row is "❯" + NBSP, never a normal space
|
|
194
|
+
export const RULE_CHAR = '─'; // "─"
|
|
195
|
+
export const RULE_MIN_RUN = 20; // a rule row holds a run of at least this many RULE_CHARs
|
|
196
|
+
/** Rows below the prompt row searched for the closing rule (a draft may wrap to a few rows). */
|
|
197
|
+
export const BOX_MAX_ROWS = 10;
|
|
198
|
+
export const TITLE_IDLE_GLYPH = '✳'; // "✳": not running a turn (also while a permission dialog is open!)
|
|
199
|
+
/** "◐" "◑": a model turn or a shell-mode command is running. Add frames here if a real run shows more. */
|
|
200
|
+
export const TITLE_WORKING_GLYPHS = ['◐', '◑'];
|
|
201
|
+
/**
|
|
202
|
+
* Dialog recognition on the mirror rows (JS RegExp source, no flags unless noted). Order = priority.
|
|
203
|
+
* A row matches a pattern when the row text (right-trimmed) satisfies it. Rule for `permission`: a row matching
|
|
204
|
+
* `^\s*Do you want to ` AND a `menu` row must both be on screen. `menu` alone is reported as 'menu'.
|
|
205
|
+
*/
|
|
206
|
+
export const DIALOG_PATTERNS = [
|
|
207
|
+
{ kind: 'theme', source: 'Choose the text style' },
|
|
208
|
+
{ kind: 'login', source: 'Select login method' },
|
|
209
|
+
{ kind: 'trust', source: 'Quick safety check|Is this a project you created or one you trust' },
|
|
210
|
+
{ kind: 'bypass', source: 'WARNING: Claude Code running in Bypass Permissions mode' },
|
|
211
|
+
{ kind: 'api_key', source: 'Detected a custom API key' },
|
|
212
|
+
{ kind: 'resume', source: 'Resume this conversation' },
|
|
213
|
+
{ kind: 'permission', source: '^\\s*Do you want to ' },
|
|
214
|
+
{ kind: 'menu', source: '^\\s*❯\\s+(\\d+\\.\\s|No, |Yes, )' },
|
|
215
|
+
];
|
|
216
|
+
/** The one reason text for startup dialogs (design). */
|
|
217
|
+
export const STARTUP_DIALOG_REASON = 'startup dialog: answer it in the terminal';
|
|
218
|
+
/** needs_you reason when a dialog is on screen but no PermissionRequest hook announced it. */
|
|
219
|
+
export const SCREEN_DIALOG_REASON = 'a dialog is waiting in the terminal: answer it there';
|
|
220
|
+
/* ---- text given to agents ---- */
|
|
221
|
+
/** Appended to every agent's system prompt. Placeholders: {name}, {memory}, {role}. No dates, no roster: keeps the prompt cache warm. */
|
|
222
|
+
export const ROLE_PREAMBLE = [
|
|
223
|
+
'You are "{name}", an agent in a gonogo operations room: a team of Claude Code agents run by one human owner.',
|
|
224
|
+
'You talk to the others only through these tools of the MCP server "gonogo":',
|
|
225
|
+
'- mcp__gonogo__send_message: send a message to another agent by name, to "boss" (the boss agent) or to "user" (the human owner). Fields: to, subject, body, optional in_reply_to.',
|
|
226
|
+
'- mcp__gonogo__list_roster: list the agents with their role and state, and the agents of the stations docked with this room.',
|
|
227
|
+
'- mcp__gonogo__read_messages: read the messages waiting for you. Each message is returned once.',
|
|
228
|
+
'- mcp__gonogo__task_list, task_create and task_update: the Flight Plan, the task board of the team (statuses todo, doing, review, done, blocked). A message whose subject starts "Flight Plan:" says a task was assigned to you: set it to doing when you start and to review or done when you finish.',
|
|
229
|
+
'- mcp__gonogo__log_search, log_read and log_write: the Mission Log, one memory shared by every agent. Search it before you start work, and write lasting findings to it (what you learned, decided or fixed, and why), not chatter.',
|
|
230
|
+
'Messages never arrive in your input as text. Only a one-line pointer does, for example "gonogo: 1 new message from ana. Call read_messages." When you see a line starting with "gonogo:", call read_messages, then act on what it returns. Also call it when you start work. When a message asks for a go/no-go, answer it with go_nogo.',
|
|
231
|
+
'Do not use any other way to message people or other sessions. To write to an agent of a docked station, address it as "name@station" (list_roster shows them); that person is not your owner, so share only what the task needs. Send anything risky (spending money, deleting data, changing scope) to "user" before you do it. Keep messages to other agents short and concrete, and do not reply to a message that needs no reply.',
|
|
232
|
+
'Your memory file is {memory}. Read it when you start. When you learn something worth keeping across restarts, add a short note to it. It is plain markdown; keep it under 200 lines.',
|
|
233
|
+
'Your role:',
|
|
234
|
+
'{role}',
|
|
235
|
+
].join('\n');
|
|
236
|
+
/** Role text of the boss agent created on first run (editable with Edit). */
|
|
237
|
+
const BOSS_POSITION = positionById('flight');
|
|
238
|
+
export const BOSS_ROLE = BOSS_POSITION ? BOSS_POSITION.role : 'You are the flight director of this team.';
|
|
239
|
+
export const BOSS_DEFAULT_NAME = 'flight'; // the call sign of the flight director; names are lowercase
|
|
240
|
+
/** Longest vote reason, a custom command, and the T-minus and Max Q limits. */
|
|
241
|
+
export const POLL_REASON_MAX_CHARS = 300;
|
|
242
|
+
export const COMMAND_MAX_CHARS = 1000;
|
|
243
|
+
/** Payload (docs/payload-spec.md): the shape of a server name and the limits of one agent's payload. */
|
|
244
|
+
export const PAYLOAD_SERVER_NAME_PATTERN = '^[a-z0-9][a-z0-9_-]{0,31}$';
|
|
245
|
+
export const PAYLOAD_MAX_SERVERS = 16;
|
|
246
|
+
export const PAYLOAD_MAX_SKILLS = 16;
|
|
247
|
+
/** Most items in args, env or headers of one server. */
|
|
248
|
+
export const PAYLOAD_MAX_ITEMS = 32;
|
|
249
|
+
/** Longest command, argument, URL, env or header value. */
|
|
250
|
+
export const PAYLOAD_STRING_MAX_CHARS = 2000;
|
|
251
|
+
/** Longest payload as JSON text: every agent frame and snapshot carries it, so 24 agents stay well under WS_MAX_BUFFERED_BYTES. */
|
|
252
|
+
export const PAYLOAD_MAX_CHARS = 32 * 1024;
|
|
253
|
+
/** The folder of an agent's skills plugin, under agents/<name>/, and the plugin's own name. */
|
|
254
|
+
export const PAYLOAD_PLUGIN_DIR = 'payload-plugin';
|
|
255
|
+
export const PAYLOAD_PLUGIN_NAME = 'gonogo-payload';
|
|
256
|
+
/** Clean Room (docs/clean-room-spec.md): the image, the host name a container reaches gonogo by, and what it is given from gonogo's environment. */
|
|
257
|
+
export const CLEAN_ROOM_IMAGE_ENV = 'GONOGO_CLEANROOM_IMAGE';
|
|
258
|
+
export const CLEAN_ROOM_DEFAULT_IMAGE = 'ghcr.io/ulm0/gonogo';
|
|
259
|
+
/** Set when gonogo itself runs in a container: `container:<its name>`, the network a Clean Room joins instead of reaching the host. */
|
|
260
|
+
export const CLEAN_ROOM_NETWORK_ENV = 'GONOGO_CLEANROOM_NETWORK';
|
|
261
|
+
export const CLEAN_ROOM_NETWORK_PATTERN = '^container:[A-Za-z0-9][A-Za-z0-9_.-]{0,199}$';
|
|
262
|
+
/** GONOGO_CLEANROOM_NETWORK value meaning gonogo's own container, found by its host name. */
|
|
263
|
+
export const CLEAN_ROOM_NETWORK_SELF = 'container:self';
|
|
264
|
+
export const DOCKER_BIN = 'docker';
|
|
265
|
+
export const GIT_BIN = 'git';
|
|
266
|
+
/** An image name or id: a leading dash would be read as a docker option. */
|
|
267
|
+
export const CLEAN_ROOM_IMAGE_PATTERN = '^[A-Za-z0-9][A-Za-z0-9._/:@-]{0,199}$';
|
|
268
|
+
export const CLEAN_ROOM_HOST = 'host.docker.internal';
|
|
269
|
+
/** The container's HOME, under agents/<name>/: its Claude config and sessions stay across restarts and never touch the owner's ~/.claude. */
|
|
270
|
+
export const CLEAN_ROOM_HOME_DIR = 'cleanroom-home';
|
|
271
|
+
/** The credentials a container may get from gonogo's environment, by name. GONOGO_API_KEY is how seed mode carries ANTHROPIC_API_KEY. */
|
|
272
|
+
export const CLEAN_ROOM_CREDENTIALS = ['CLAUDE_CODE_OAUTH_TOKEN', 'GONOGO_API_KEY'];
|
|
273
|
+
/** The variables of the child's environment that the container needs as well. */
|
|
274
|
+
export const CLEAN_ROOM_ENV = ['GONOGO_TOKEN', 'TERM', 'COLORTERM', 'IS_DEMO'];
|
|
275
|
+
/** `docker version`, `git worktree add` and the like must answer within this. */
|
|
276
|
+
export const CLEAN_ROOM_COMMAND_MS = 30_000;
|
|
277
|
+
/** Added to the role of a Clean Room agent: git cannot reach the repository from the container. {branch} is its branch. */
|
|
278
|
+
export const CLEAN_ROOM_NOTE = 'You run in a sandbox: a container that holds only a copy of the project (a git worktree on the branch "{branch}") and your own files. git cannot reach the repository from there, so do not try to commit: edit the files, and the owner commits and merges the branch from outside.';
|
|
279
|
+
export const MAX_WORKING_ENV = 'GONOGO_MAX_WORKING';
|
|
280
|
+
/** A custom command counts as working while it printed something in the last CUSTOM_ACTIVE_MS, and as starting until it prints or CUSTOM_START_MS pass. */
|
|
281
|
+
export const CUSTOM_ACTIVE_MS = 2000;
|
|
282
|
+
export const CUSTOM_START_MS = 3000;
|
|
283
|
+
/** Redline: what trips the circuit breaker of one Claude agent (docs/redline-propellant-spec.md). */
|
|
284
|
+
export const REDLINE_ENV = 'GONOGO_REDLINE';
|
|
285
|
+
/** The same tool with the same input this many times in a row is a loop. */
|
|
286
|
+
export const REDLINE_REPEATS = 5;
|
|
287
|
+
/** This many failed tool calls within the window is an error storm. */
|
|
288
|
+
export const REDLINE_TOOL_FAILURES = 8;
|
|
289
|
+
export const REDLINE_TOOL_FAILURE_WINDOW_MS = 120_000;
|
|
290
|
+
/** This many API errors (StopFailure) within the window is an error storm. */
|
|
291
|
+
export const REDLINE_API_ERRORS = 3;
|
|
292
|
+
export const REDLINE_API_ERROR_WINDOW_MS = 600_000;
|
|
293
|
+
/** More than this many messages to the same recipient within the window is a ping-pong. */
|
|
294
|
+
export const REDLINE_SENDS_TO_ONE = 15;
|
|
295
|
+
export const REDLINE_SEND_WINDOW_MS = 600_000;
|
|
296
|
+
/** Propellant reads a transcript at every Stop and, during a long turn, at most this often on a tool hook. */
|
|
297
|
+
export const METER_INTERVAL_MS = 20_000;
|
|
298
|
+
/** Ledger entries older than this are dropped (the longest window is 30 days). */
|
|
299
|
+
export const FUEL_KEEP_MS = 31 * 24 * 3_600_000;
|
|
300
|
+
/** One read of a transcript takes at most this many bytes; the rest waits for the next read. */
|
|
301
|
+
export const METER_READ_MAX_BYTES = 32 * 1024 * 1024;
|
|
302
|
+
/** The largest token limit accepted (10^12). */
|
|
303
|
+
export const FUEL_LIMIT_MAX = 1_000_000_000_000;
|
|
304
|
+
/** Launch Window (docs/launch-window-spec.md): the file in the home directory, how late a fire may still go, and the longest result kept. */
|
|
305
|
+
export const SCHEDULES_FILE = 'schedules.json';
|
|
306
|
+
export const SCHEDULE_GRACE_MS = 60_000;
|
|
307
|
+
export const SCHEDULE_RESULT_MAX_CHARS = 300;
|
|
308
|
+
/** Uplink (docs/uplink-spec.md): the file, the largest delivery, the rate limit of one uplink, and the longest note of a delivery. */
|
|
309
|
+
export const UPLINKS_FILE = 'uplinks.json';
|
|
310
|
+
export const UPLINK_BODY_MAX_BYTES = 256 * 1024;
|
|
311
|
+
export const UPLINK_RATE_MAX = 30;
|
|
312
|
+
export const UPLINK_RATE_WINDOW_MS = 60_000;
|
|
313
|
+
export const UPLINK_NOTE_MAX_CHARS = 300;
|
|
314
|
+
/** Docking (docs/docking-spec.md): the files, the station name variable, the lifetime of a docking code, how far a signed call's clock may be from ours, and the limits of /dock/*. */
|
|
315
|
+
export const DOCKING_FILE = 'docking.json';
|
|
316
|
+
export const STATION_FILE = 'station.json';
|
|
317
|
+
export const STATION_ENV = 'GONOGO_STATION';
|
|
318
|
+
export const DOCK_CODE_TTL_MS = 15 * 60_000;
|
|
319
|
+
export const DOCK_CODES_MAX = 5;
|
|
320
|
+
export const DOCK_SKEW_MS = 5 * 60_000;
|
|
321
|
+
export const DOCK_BODY_MAX_BYTES = 256 * 1024;
|
|
322
|
+
export const DOCK_RATE_MAX = 60;
|
|
323
|
+
export const DOCK_RATE_WINDOW_MS = 60_000;
|
|
324
|
+
/** A call to another station gives up after this; Undock waits less, because the Director is waiting. */
|
|
325
|
+
export const DOCK_TIMEOUT_MS = 10_000;
|
|
326
|
+
export const DOCK_UNDOCK_TIMEOUT_MS = 3000;
|
|
327
|
+
/** How often the roster of each docked station is pulled. */
|
|
328
|
+
export const DOCK_PULL_MS = 30_000;
|
|
329
|
+
/** Flight Plan (docs/flight-plan-spec.md): the file, the history lines one task keeps, and how many done tasks are kept. */
|
|
330
|
+
export const TASKS_FILE = 'tasks.json';
|
|
331
|
+
export const TASK_NOTES_MAX = 20;
|
|
332
|
+
export const TASKS_DONE_KEEP = 100;
|
|
333
|
+
/**
|
|
334
|
+
* Downlink (docs/downlink-spec.md): the file, how many events and messages the inbox keeps, the longest event text, how many ids one
|
|
335
|
+
* call may carry, how many messages of the log are read at start to find the Director's mail, and the bad-signature rule of an uplink
|
|
336
|
+
* (more than UPLINK_BAD_MAX in UPLINK_BAD_WINDOW_MS is one event, at most one per window).
|
|
337
|
+
*/
|
|
338
|
+
export const DOWNLINK_FILE = 'downlink.json';
|
|
339
|
+
export const DOWNLINK_EVENTS_MAX = 1000;
|
|
340
|
+
export const DOWNLINK_MAIL_MAX = 200;
|
|
341
|
+
export const DOWNLINK_TEXT_MAX_CHARS = 300;
|
|
342
|
+
export const DOWNLINK_IDS_MAX = 200;
|
|
343
|
+
export const DOWNLINK_HISTORY = 1000;
|
|
344
|
+
export const UPLINK_BAD_MAX = 3;
|
|
345
|
+
export const UPLINK_BAD_WINDOW_MS = 10 * 60_000;
|
|
346
|
+
/**
|
|
347
|
+
* Relay (docs/relay-spec.md): the file; one outbound call (10 s, 3 tries, 1 s then 2 s between them, a Retry-After no longer than 10 s
|
|
348
|
+
* is honoured); the send queue, which drops its oldest entry past RELAY_QUEUE_MAX; the longest text sent (Telegram stops at 4096,
|
|
349
|
+
* Slack asks for less than 4000); how many forwarded messages and how many handled inbound ids are remembered (oldest forgotten
|
|
350
|
+
* first); how old a Slack signature may be.
|
|
351
|
+
*/
|
|
352
|
+
export const RELAY_FILE = 'relay.json';
|
|
353
|
+
export const RELAY_TIMEOUT_MS = 10_000;
|
|
354
|
+
export const RELAY_TRIES = 3;
|
|
355
|
+
export const RELAY_BACKOFF_MS = 1_000;
|
|
356
|
+
export const RELAY_RETRY_AFTER_MAX_MS = 10_000;
|
|
357
|
+
export const RELAY_QUEUE_MAX = 50;
|
|
358
|
+
export const RELAY_TEXT_MAX_CHARS = 3500;
|
|
359
|
+
export const RELAY_THREADS_MAX = 500;
|
|
360
|
+
export const RELAY_SEEN_MAX = 500;
|
|
361
|
+
export const RELAY_NOTE_MAX_CHARS = 200;
|
|
362
|
+
export const SLACK_SIGNATURE_MAX_AGE_MS = 5 * 60_000;
|
|
363
|
+
/** Livery (docs/livery-spec.md): the custom liveries are `<home>/liveries/<slug>.json`; the chosen one is `<home>/livery.json`. */
|
|
364
|
+
export const LIVERY_DIR = 'liveries';
|
|
365
|
+
export const LIVERY_FILE = 'livery.json';
|
|
366
|
+
/** Propellant (docs/redline-propellant-spec.md): the limits and cursors file; the ledger fuel.jsonl is a log and has no version. */
|
|
367
|
+
export const PROPELLANT_FILE = 'propellant.json';
|
|
368
|
+
/** Mission Log (docs/mission-log-spec.md): the folder under the home, and how long a snippet of a search result is and how much of the text before the match it shows. */
|
|
369
|
+
export const LOG_DIR = 'mission-log';
|
|
370
|
+
export const LOG_SNIPPET_CHARS = 200;
|
|
371
|
+
export const LOG_SNIPPET_LEAD_CHARS = 40;
|
|
372
|
+
export const MCP_DESCRIPTIONS = {
|
|
373
|
+
go_nogo: 'Answer a T-minus poll from the Director: vote "go" when you are ready to proceed, or "no-go" with a one-sentence reason. Call it when a message asks for a go/no-go. The result says whether the vote counted.',
|
|
374
|
+
send_message: 'Send a message to another agent (by name), to the boss ("boss") or to the human owner ("user"). An agent of a docked station is addressed as "name@station". The recipient gets a one-line pointer and reads the text with read_messages. The result tells you at once whether the message was queued or could not be delivered.',
|
|
375
|
+
list_roster: 'List every agent in the operations room with its name, role and current state, and say which one is the boss. Agents of docked stations are listed too, under docked.',
|
|
376
|
+
read_messages: 'Return the messages waiting for you (each message is returned once) and mark them read. Call it when a line starting with "gonogo:" says messages are waiting.',
|
|
377
|
+
task_list: 'List the tasks of the Flight Plan, the team task board, most recently changed first. Optional filters: mine (only the tasks assigned to you) and status (todo, doing, review, done or blocked).',
|
|
378
|
+
task_create: 'Add a task to the Flight Plan. It starts as todo. Give a short title, a detail with what done means, and optionally the name of the agent it is assigned to; that agent gets a message.',
|
|
379
|
+
task_update: 'Change a task of the Flight Plan by its id: its status (todo, doing, review, done, blocked), its assignee (an agent name, or null to unassign) and a short note for the history. Assigning it to another agent sends that agent a message.',
|
|
380
|
+
log_write: 'Write to the Mission Log, the memory shared by every agent: a title, a body in plain markdown and optional tags. Give an id to change an entry you wrote earlier (any of title, body, tags). Keep an entry to one finding.',
|
|
381
|
+
log_search: 'Search the Mission Log. Returns up to limit entries (at most 20), best first, each with its id, title, author, tags and a snippet around the best match. Read the whole entry with log_read.',
|
|
382
|
+
log_read: 'Read one entry of the Mission Log by its id: the title, tags, author, times and the whole body.',
|
|
383
|
+
livery_submit: 'Submit a livery, a colour theme for gonogo, when the Director asked you to design one: a name, a one-line description and tokens, an object that holds every token the message named, each a CSS colour (#rgb, #rrggbb, rgb(), hsl() or oklch()). It is checked for colours and for contrast; if it is refused, the answer says what to fix. The Director chooses whether to apply it.',
|
|
384
|
+
};
|
|
385
|
+
/* ---- the tiny logger ---- */
|
|
386
|
+
const LEVELS = { debug: 10, info: 20, warn: 30, error: 40 };
|
|
387
|
+
function render(value) {
|
|
388
|
+
if (typeof value === 'string')
|
|
389
|
+
return value;
|
|
390
|
+
if (value instanceof Error)
|
|
391
|
+
return value.stack ?? value.message;
|
|
392
|
+
try {
|
|
393
|
+
return JSON.stringify(value);
|
|
394
|
+
}
|
|
395
|
+
catch {
|
|
396
|
+
return String(value);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
/** Never log tokens, API keys, message bodies or hook payloads (event names and ids only). */
|
|
400
|
+
export function createLogger(options = {}) {
|
|
401
|
+
const min = LEVELS[options.level ?? 'info'];
|
|
402
|
+
const sink = options.sink ?? ((line) => void process.stderr.write(line + '\n'));
|
|
403
|
+
const prefix = options.prefix ? `[${options.prefix}] ` : '';
|
|
404
|
+
const emit = (level, message, extra) => {
|
|
405
|
+
if (LEVELS[level] < min)
|
|
406
|
+
return;
|
|
407
|
+
const tail = extra.length ? ' ' + extra.map(render).join(' ') : '';
|
|
408
|
+
sink(`${new Date().toISOString()} ${level.padEnd(5)} ${prefix}${message}${tail}`);
|
|
409
|
+
};
|
|
410
|
+
return {
|
|
411
|
+
debug: (m, ...e) => emit('debug', m, e),
|
|
412
|
+
info: (m, ...e) => emit('info', m, e),
|
|
413
|
+
warn: (m, ...e) => emit('warn', m, e),
|
|
414
|
+
error: (m, ...e) => emit('error', m, e),
|
|
415
|
+
child: (p) => createLogger({ ...options, prefix: options.prefix ? `${options.prefix}/${p}` : p }),
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
/** Prints nothing. The default logger of every module, so tests print nothing. */
|
|
419
|
+
export const nullLogger = {
|
|
420
|
+
debug() { },
|
|
421
|
+
info() { },
|
|
422
|
+
warn() { },
|
|
423
|
+
error() { },
|
|
424
|
+
child() {
|
|
425
|
+
return nullLogger;
|
|
426
|
+
},
|
|
427
|
+
};
|