@gajae-code/coding-agent 0.18.5 → 0.18.7
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 +140 -0
- package/dist/types/capability/types.d.ts +4 -0
- package/dist/types/cli-commands.d.ts +10 -0
- package/dist/types/cli-ordinary.d.ts +13 -0
- package/dist/types/cli.d.ts +12 -3
- package/dist/types/commands/contribution-prep.d.ts +0 -3
- package/dist/types/commands/sdk.d.ts +3 -0
- package/dist/types/commands/update.d.ts +1 -0
- package/dist/types/config/model-profile-activation.d.ts +19 -0
- package/dist/types/config/settings.d.ts +4 -0
- package/dist/types/coordinator-mcp/session-reaper.d.ts +5 -0
- package/dist/types/discovery/helpers.d.ts +2 -2
- package/dist/types/edit/modes/replace.d.ts +3 -3
- package/dist/types/edit/streaming.d.ts +2 -2
- package/dist/types/exec/bash-shell-supervisor.d.ts +12 -0
- package/dist/types/runtime-mcp/elicitation.d.ts +12 -0
- package/dist/types/sdk/broker/discovery.d.ts +8 -0
- package/dist/types/sdk/broker/ensure.d.ts +1 -0
- package/dist/types/sdk/broker/lifecycle-ledger.d.ts +4 -0
- package/dist/types/sdk/broker/lifecycle.d.ts +9 -0
- package/dist/types/sdk/broker/runtime.d.ts +1 -1
- package/dist/types/sdk/broker/task-artifact-owner-validation.d.ts +55 -0
- package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +1 -1
- package/dist/types/sdk/bus/telegram-daemon.d.ts +4 -2
- package/dist/types/sdk/cli/diagnostics-cli.d.ts +18 -0
- package/dist/types/sdk/diagnostics/observe-broker.d.ts +185 -0
- package/dist/types/sdk/host/control/operations.d.ts +1 -1
- package/dist/types/sdk/host/host.d.ts +6 -0
- package/dist/types/sdk/index.d.ts +1 -0
- package/dist/types/sdk/router/session-router.d.ts +9 -0
- package/dist/types/sdk/session.d.ts +13 -0
- package/dist/types/session/agent-session.d.ts +5 -1
- package/dist/types/session/internal/managed-session-storage.d.ts +11 -1
- package/dist/types/session/internal/task-artifact-owner-access.d.ts +17 -0
- package/dist/types/session/internal/task-artifact-owner-transcript.d.ts +3 -0
- package/dist/types/session/session-retirement.d.ts +47 -0
- package/dist/types/session/session-storage.d.ts +0 -46
- package/dist/types/session/session-transcript-header.d.ts +2 -0
- package/dist/types/session/task-artifact-owner-codec.d.ts +107 -0
- package/dist/types/session/task-artifact-owner-retirement.d.ts +7 -0
- package/dist/types/session/task-artifact-owner.d.ts +10 -0
- package/dist/types/tools/ask-contract.d.ts +75 -254
- package/dist/types/tools/bash.d.ts +1 -1
- package/package.json +7 -7
- package/scripts/build-sdk-package-smoke.ts +5 -0
- package/scripts/resident-memory-bench.ts +174 -20
- package/src/capability/index.ts +1 -0
- package/src/capability/types.ts +4 -0
- package/src/cli/config-cli.ts +8 -18
- package/src/cli/public-command-entry.ts +5 -0
- package/src/cli/ssh-cli.ts +6 -3
- package/src/cli/web-search-cli.ts +9 -3
- package/src/cli-commands.ts +14 -0
- package/src/cli-main.ts +7 -8
- package/src/cli-ordinary.ts +197 -0
- package/src/cli.ts +25 -182
- package/src/commands/contribution-prep.ts +1 -3
- package/src/commands/sdk.ts +171 -21
- package/src/commands/update.ts +15 -1
- package/src/config/file-lock.ts +91 -2
- package/src/config/model-profile-activation.ts +70 -4
- package/src/config/model-profile-contract.ts +4 -1
- package/src/config/model-profiles.ts +23 -31
- package/src/config/model-resolver.ts +9 -1
- package/src/config/settings.ts +44 -4
- package/src/coordinator-mcp/event-webhook.ts +19 -14
- package/src/coordinator-mcp/policy.ts +14 -4
- package/src/coordinator-mcp/server.ts +142 -7
- package/src/coordinator-mcp/session-reaper.ts +9 -1
- package/src/defaults/gjc/skills/deep-interview/SKILL.md +1 -1
- package/src/discovery/helpers.ts +9 -3
- package/src/discovery/ssh.ts +8 -3
- package/src/edit/modes/replace.ts +6 -6
- package/src/edit/streaming.ts +15 -15
- package/src/exec/bash-shell-supervisor.ts +60 -3
- package/src/gjc-runtime/gc-runtime.ts +2 -1
- package/src/hindsight/config.ts +9 -3
- package/src/internal-urls/docs-index.generated.ts +11 -10
- package/src/memories/index.ts +8 -2
- package/src/modes/acp/acp-agent.ts +724 -370
- package/src/modes/components/tool-execution.ts +1 -1
- package/src/prompts/tools/ask.md +2 -0
- package/src/runtime-mcp/client.ts +13 -4
- package/src/runtime-mcp/elicitation.ts +142 -0
- package/src/sdk/broker/broker.ts +54 -1
- package/src/sdk/broker/daemon-entry.ts +67 -6
- package/src/sdk/broker/discovery.ts +8 -0
- package/src/sdk/broker/ensure.ts +156 -20
- package/src/sdk/broker/lifecycle-ledger.ts +110 -12
- package/src/sdk/broker/lifecycle.ts +334 -348
- package/src/sdk/broker/runtime.ts +5 -1
- package/src/sdk/broker/task-artifact-owner-validation.ts +259 -0
- package/src/sdk/broker/transport.ts +5 -1
- package/src/sdk/bus/chat-daemon-control.ts +2 -2
- package/src/sdk/bus/chat-daemon-runtime.ts +3 -0
- package/src/sdk/bus/index.ts +3 -3
- package/src/sdk/bus/telegram-daemon-contract.ts +1 -1
- package/src/sdk/bus/telegram-daemon-control.ts +15 -12
- package/src/sdk/bus/telegram-daemon.ts +38 -3
- package/src/sdk/cli/diagnostics-cli.ts +247 -0
- package/src/sdk/diagnostics/observe-broker.ts +654 -0
- package/src/sdk/host/control/dispatch.ts +52 -4
- package/src/sdk/host/control/operations.ts +1 -1
- package/src/sdk/host/host.ts +6 -0
- package/src/sdk/host/session-runtime.test.ts +83 -4
- package/src/sdk/host/session-runtime.ts +15 -7
- package/src/sdk/index.ts +1 -0
- package/src/sdk/lifecycle-session.ts +1 -0
- package/src/sdk/mcp/server.ts +15 -3
- package/src/sdk/protocol/operation-registry.ts +1 -1
- package/src/sdk/router/session-router.ts +26 -3
- package/src/sdk/session.ts +51 -8
- package/src/session/agent-session.ts +169 -43
- package/src/session/blob-store.ts +78 -33
- package/src/session/internal/managed-session-storage.ts +203 -4
- package/src/session/internal/task-artifact-owner-access.ts +229 -0
- package/src/session/internal/task-artifact-owner-transcript.ts +68 -0
- package/src/session/session-retirement.ts +155 -0
- package/src/session/session-storage.ts +1 -160
- package/src/session/session-transcript-header.ts +17 -0
- package/src/session/task-artifact-owner-codec.ts +578 -0
- package/src/session/task-artifact-owner-retirement.ts +475 -0
- package/src/session/task-artifact-owner.ts +289 -0
- package/src/setup/hermes/templates/operator-instructions.v1.md +19 -1
- package/src/setup/hermes-setup.ts +4 -1
- package/src/slash-commands/builtin-registry.ts +8 -5
- package/src/tools/ask-contract.test.ts +76 -1
- package/src/tools/ask-contract.ts +57 -6
- package/src/tools/ask.ts +16 -7
- package/src/tools/bash.ts +38 -29
- package/src/tools/descriptors.test.ts +29 -0
- package/src/tools/tool-catalog.generated.ts +7 -4
- package/src/web/search/index.ts +2 -2
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/** Isolated `gjc sdk diagnostics` parser and renderer.
|
|
2
|
+
*
|
|
3
|
+
* Reached from the inert entry before any effectful branch, so this module must
|
|
4
|
+
* stay a pure leaf: no command registry, session CLI, runtime globals, managed
|
|
5
|
+
* owner admission, malloc guard, evidence publisher, broker client, directory
|
|
6
|
+
* resolver or logger import. Help and usage never resolve a root or open a file,
|
|
7
|
+
* and every outcome is a fixed bounded string with a fixed exit code.
|
|
8
|
+
*
|
|
9
|
+
* Observation itself must never start, ensure, retire, restart or recover a
|
|
10
|
+
* broker. The read-only observation facade (DESIGN §B3) is wired: `observe()`
|
|
11
|
+
* below routes to it and to nothing else, so this command can report only what a
|
|
12
|
+
* supporting broker publishes to the read-only reader. An unsupported runtime
|
|
13
|
+
* tuple, a missing or mismatched native artifact and an old broker without a
|
|
14
|
+
* published generation all still fail closed with the fixed `unsupported`
|
|
15
|
+
* outcome.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const USAGE_FAMILY = `usage: gjc sdk diagnostics <command>
|
|
19
|
+
|
|
20
|
+
Read-only broker observation. Never starts, ensures, retires, restarts or
|
|
21
|
+
recovers a broker, and never spawns a host.
|
|
22
|
+
|
|
23
|
+
commands:
|
|
24
|
+
broker Observe an already running broker publication.
|
|
25
|
+
|
|
26
|
+
flags:
|
|
27
|
+
-h, --help Show this help.
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
const USAGE_BROKER = `usage: gjc sdk diagnostics broker [--agent-dir <dir>] [--expected-generation <id>] [--timeout-ms <ms>] [--json]
|
|
31
|
+
|
|
32
|
+
Observe an already running broker publication without starting, ensuring,
|
|
33
|
+
retiring, restarting or recovering it.
|
|
34
|
+
|
|
35
|
+
flags:
|
|
36
|
+
--agent-dir <dir> Absolute agent directory holding the broker publication.
|
|
37
|
+
--expected-generation <id> Require this exact publication generation (32 hex characters).
|
|
38
|
+
--timeout-ms <ms> Overall observation deadline, 1-10000 (default 2000).
|
|
39
|
+
--json Emit the observation document as JSON.
|
|
40
|
+
-h, --help Show this help.
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
/** Fixed messages keyed by reason; never exception text, never a path. */
|
|
44
|
+
const UNAVAILABLE_MESSAGES = {
|
|
45
|
+
absent: "No broker publication was found for the selected agent directory.",
|
|
46
|
+
stale: "The broker publication is stale.",
|
|
47
|
+
incompatible: "The broker uses an unsupported diagnostic protocol.",
|
|
48
|
+
authentication_failed: "The broker refused the diagnostic authentication.",
|
|
49
|
+
unsupported: "Read-only broker observation is not supported by this runtime or build.",
|
|
50
|
+
generation_mismatch: "The observed broker publication is a different incarnation.",
|
|
51
|
+
transport_unavailable: "The broker diagnostic transport is unavailable.",
|
|
52
|
+
timeout: "The broker observation deadline expired.",
|
|
53
|
+
invalid_response: "The broker returned an invalid diagnostic response.",
|
|
54
|
+
unsafe_discovery: "The broker publication path failed read-only safety validation.",
|
|
55
|
+
} as const;
|
|
56
|
+
|
|
57
|
+
type UnavailableReason = keyof typeof UNAVAILABLE_MESSAGES;
|
|
58
|
+
|
|
59
|
+
type BrokerObservation =
|
|
60
|
+
| {
|
|
61
|
+
schema: "gjc.broker-observation";
|
|
62
|
+
version: 1;
|
|
63
|
+
ok: false;
|
|
64
|
+
observedAt: string;
|
|
65
|
+
unavailable: { reason: UnavailableReason; message: string };
|
|
66
|
+
}
|
|
67
|
+
| {
|
|
68
|
+
schema: "gjc.broker-observation";
|
|
69
|
+
version: 1;
|
|
70
|
+
ok: true;
|
|
71
|
+
observedAt: string;
|
|
72
|
+
broker: {
|
|
73
|
+
generation: string;
|
|
74
|
+
build: { packageVersion: string; buildId: string | null };
|
|
75
|
+
diagnosticProtocol: 1;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const MAX_ARGV_BYTES = 8192;
|
|
80
|
+
const MAX_PATH_BYTES = 4096;
|
|
81
|
+
const MAX_PATH_COMPONENTS = 128;
|
|
82
|
+
const DEFAULT_TIMEOUT_MS = 2000;
|
|
83
|
+
const MIN_TIMEOUT_MS = 1;
|
|
84
|
+
const MAX_TIMEOUT_MS = 10000;
|
|
85
|
+
|
|
86
|
+
type Parsed =
|
|
87
|
+
| { kind: "help"; text: string }
|
|
88
|
+
| { kind: "usage" }
|
|
89
|
+
| {
|
|
90
|
+
kind: "observe";
|
|
91
|
+
agentDir: string | undefined;
|
|
92
|
+
expectedGeneration: string | undefined;
|
|
93
|
+
timeoutMs: number;
|
|
94
|
+
json: boolean;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
function isHelpToken(token: string): boolean {
|
|
98
|
+
return token === "--help" || token === "-h";
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function validAgentDir(value: string): boolean {
|
|
102
|
+
if (value.length === 0 || value.includes("\0")) return false;
|
|
103
|
+
if (!value.startsWith("/")) return false;
|
|
104
|
+
if (Buffer.byteLength(value, "utf8") > MAX_PATH_BYTES) return false;
|
|
105
|
+
return value.split("/").length <= MAX_PATH_COMPONENTS;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function validGeneration(value: string): boolean {
|
|
109
|
+
return /^[0-9a-f]{32}$/.test(value);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function parseTimeout(value: string): number | undefined {
|
|
113
|
+
if (!/^[0-9]{1,5}$/.test(value)) return undefined;
|
|
114
|
+
const parsed = Number.parseInt(value, 10);
|
|
115
|
+
if (parsed < MIN_TIMEOUT_MS || parsed > MAX_TIMEOUT_MS) return undefined;
|
|
116
|
+
return parsed;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function parse(argv: readonly string[]): Parsed {
|
|
120
|
+
let argvBytes = 0;
|
|
121
|
+
for (const token of argv) argvBytes += Buffer.byteLength(token, "utf8") + 1;
|
|
122
|
+
if (argvBytes > MAX_ARGV_BYTES) return { kind: "usage" };
|
|
123
|
+
if (argv.length === 0) return { kind: "usage" };
|
|
124
|
+
if (isHelpToken(argv[0]!)) {
|
|
125
|
+
// Family help is the whole invocation or nothing: a trailing operand, a second
|
|
126
|
+
// help token or a subcommand after it is a usage error, never a rendered help.
|
|
127
|
+
return argv.length === 1 ? { kind: "help", text: USAGE_FAMILY } : { kind: "usage" };
|
|
128
|
+
}
|
|
129
|
+
if (argv[0] !== "broker") return { kind: "usage" };
|
|
130
|
+
|
|
131
|
+
let agentDir: string | undefined;
|
|
132
|
+
let expectedGeneration: string | undefined;
|
|
133
|
+
let timeoutMs: number | undefined;
|
|
134
|
+
let json = false;
|
|
135
|
+
// A help request never short-circuits validation: the remaining argv is checked
|
|
136
|
+
// first, so an unknown flag, a private marker, a trailing operand or a duplicate
|
|
137
|
+
// selector next to `--help` still terminates with the fixed usage error.
|
|
138
|
+
let helpRequested = false;
|
|
139
|
+
for (let index = 1; index < argv.length; index += 1) {
|
|
140
|
+
const token = argv[index]!;
|
|
141
|
+
if (isHelpToken(token)) {
|
|
142
|
+
if (helpRequested) return { kind: "usage" };
|
|
143
|
+
helpRequested = true;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (token === "--json") {
|
|
147
|
+
if (json) return { kind: "usage" };
|
|
148
|
+
json = true;
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (token === "--agent-dir" || token === "--expected-generation" || token === "--timeout-ms") {
|
|
152
|
+
const value = argv[index + 1];
|
|
153
|
+
if (value === undefined) return { kind: "usage" };
|
|
154
|
+
index += 1;
|
|
155
|
+
if (token === "--agent-dir") {
|
|
156
|
+
if (agentDir !== undefined || !validAgentDir(value)) return { kind: "usage" };
|
|
157
|
+
agentDir = value;
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
if (token === "--expected-generation") {
|
|
161
|
+
if (expectedGeneration !== undefined || !validGeneration(value)) return { kind: "usage" };
|
|
162
|
+
expectedGeneration = value;
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
if (timeoutMs !== undefined) return { kind: "usage" };
|
|
166
|
+
const parsed = parseTimeout(value);
|
|
167
|
+
if (parsed === undefined) return { kind: "usage" };
|
|
168
|
+
timeoutMs = parsed;
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
return { kind: "usage" };
|
|
172
|
+
}
|
|
173
|
+
if (helpRequested) return { kind: "help", text: USAGE_BROKER };
|
|
174
|
+
return { kind: "observe", agentDir, expectedGeneration, timeoutMs: timeoutMs ?? DEFAULT_TIMEOUT_MS, json };
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function unavailable(reason: UnavailableReason): BrokerObservation {
|
|
178
|
+
return {
|
|
179
|
+
schema: "gjc.broker-observation",
|
|
180
|
+
version: 1,
|
|
181
|
+
ok: false,
|
|
182
|
+
observedAt: new Date().toISOString(),
|
|
183
|
+
unavailable: { reason, message: UNAVAILABLE_MESSAGES[reason] },
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function renderText(observation: BrokerObservation): string {
|
|
188
|
+
if (observation.ok) {
|
|
189
|
+
return [
|
|
190
|
+
"broker observation: ok",
|
|
191
|
+
`generation: ${observation.broker.generation}`,
|
|
192
|
+
`package version: ${observation.broker.build.packageVersion}`,
|
|
193
|
+
`build id: ${observation.broker.build.buildId ?? "unknown"}`,
|
|
194
|
+
`diagnostic protocol: ${observation.broker.diagnosticProtocol}`,
|
|
195
|
+
"",
|
|
196
|
+
].join("\n");
|
|
197
|
+
}
|
|
198
|
+
return `broker observation: unavailable (${observation.unavailable.reason})\n${observation.unavailable.message}\n`;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Observe an already running broker.
|
|
203
|
+
*
|
|
204
|
+
* The read-only observation reader (narrow native snapshot adapter + read-only
|
|
205
|
+
* loader) is part of this build, so a valid explicit agent directory reaches the
|
|
206
|
+
* facade. A missing `--agent-dir` still returns the fixed `absent` outcome
|
|
207
|
+
* without opening a path, creating a socket or writing any state: exact
|
|
208
|
+
* selection never authorizes an alternative-root scan.
|
|
209
|
+
*/
|
|
210
|
+
async function observe(options: {
|
|
211
|
+
agentDir: string | undefined;
|
|
212
|
+
expectedGeneration: string | undefined;
|
|
213
|
+
timeoutMs: number;
|
|
214
|
+
}): Promise<BrokerObservation> {
|
|
215
|
+
if (options.agentDir === undefined) return unavailable("absent");
|
|
216
|
+
// Exactly one route: the observation facade. No other broker operation is reachable
|
|
217
|
+
// from here, and nothing on this path ensures, starts, recovers or retires a broker.
|
|
218
|
+
const { observeExistingBroker } = await import("../diagnostics/observe-broker");
|
|
219
|
+
return (await observeExistingBroker({
|
|
220
|
+
agentDir: options.agentDir,
|
|
221
|
+
expectedGeneration: options.expectedGeneration,
|
|
222
|
+
timeoutMs: options.timeoutMs,
|
|
223
|
+
})) as BrokerObservation;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** Run `gjc sdk diagnostics <argv…>`; argv excludes the `sdk diagnostics` prefix. */
|
|
227
|
+
export async function runDiagnosticsCli(argv: readonly string[]): Promise<void> {
|
|
228
|
+
let parsed: Parsed;
|
|
229
|
+
try {
|
|
230
|
+
parsed = parse(argv);
|
|
231
|
+
} catch {
|
|
232
|
+
parsed = { kind: "usage" };
|
|
233
|
+
}
|
|
234
|
+
if (parsed.kind === "help") {
|
|
235
|
+
process.stdout.write(parsed.text);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
if (parsed.kind === "usage") {
|
|
239
|
+
process.stderr.write(USAGE_FAMILY);
|
|
240
|
+
process.exitCode = 2;
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
const observation = await observe(parsed);
|
|
244
|
+
process.stdout.write(parsed.json ? `${JSON.stringify(observation)}\n` : renderText(observation));
|
|
245
|
+
// An observed result exits 0; a typed unavailability exits 1.
|
|
246
|
+
process.exitCode = observation.ok ? 0 : 1;
|
|
247
|
+
}
|