@gajae-code/coding-agent 0.22.2 → 0.22.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 +115 -0
- package/dist/types/cli/append-system-prompt.d.ts +7 -0
- package/dist/types/cli/doctor/session-owners.d.ts +8 -2
- package/dist/types/cli/public-command-errors.d.ts +1 -0
- package/dist/types/cli/session-picker.d.ts +16 -3
- package/dist/types/cli/update-cli.d.ts +0 -2
- package/dist/types/cli-ordinary.d.ts +1 -1
- package/dist/types/commands/sdk.d.ts +2 -0
- package/dist/types/config/machine-identity.d.ts +11 -0
- package/dist/types/config/model-registry.d.ts +9 -0
- package/dist/types/config/settings-schema.d.ts +84 -4
- package/dist/types/lsp/client.d.ts +9 -0
- package/dist/types/lsp/types.d.ts +2 -0
- package/dist/types/main.d.ts +40 -3
- package/dist/types/modes/components/session-held-warning.d.ts +27 -0
- package/dist/types/modes/components/session-selector.d.ts +32 -1
- package/dist/types/modes/controllers/selector-controller.d.ts +8 -1
- package/dist/types/modes/interactive-mode.d.ts +12 -1
- package/dist/types/sdk/broker/broker.d.ts +3 -0
- package/dist/types/sdk/broker/lifecycle-ledger.d.ts +5 -2
- package/dist/types/sdk/broker/lifecycle.d.ts +2 -0
- package/dist/types/sdk/broker/session-index.d.ts +11 -0
- package/dist/types/sdk/bus/index.d.ts +1 -1
- package/dist/types/sdk/host/control/dispatch.d.ts +3 -0
- package/dist/types/sdk/host/registration-test-hold.d.ts +7 -0
- package/dist/types/sdk/index.d.ts +1 -0
- package/dist/types/sdk/lifecycle/service.d.ts +3 -0
- package/dist/types/sdk/session-api-key.d.ts +11 -4
- package/dist/types/sdk/session-readonly/format.d.ts +7 -0
- package/dist/types/sdk/session.d.ts +11 -0
- package/dist/types/sdk/startup-capability.d.ts +11 -2
- package/dist/types/session/agent-session.d.ts +1 -2
- package/dist/types/session/internal/managed-session-storage.d.ts +1 -1
- package/dist/types/session/internal/session-claim-set.d.ts +168 -13
- package/dist/types/session/session-handover.d.ts +62 -0
- package/dist/types/session/session-manager.d.ts +75 -15
- package/dist/types/session/session-owner-holder.d.ts +77 -0
- package/dist/types/session/session-ownership-mode.d.ts +45 -2
- package/dist/types/session/session-ownership.d.ts +25 -29
- package/dist/types/session/yield-queue.d.ts +13 -0
- package/dist/types/tools/bash.d.ts +7 -0
- package/dist/types/tools/browser/deferred-profile-cleanup.d.ts +3 -0
- package/dist/types/tools/browser/launch.d.ts +24 -1
- package/dist/types/tools/index.d.ts +6 -0
- package/dist/types/tools/output-meta.d.ts +17 -11
- package/dist/types/tools/tool-result.d.ts +1 -0
- package/package.json +9 -7
- package/scripts/compile-args.ts +6 -3
- package/scripts/run-acp-conformance.ts +36 -10
- package/scripts/verify-gjc-sdk-canonicalization.ts +2 -0
- package/src/cli/append-system-prompt.ts +34 -0
- package/src/cli/auth-broker-cli.ts +5 -1
- package/src/cli/doctor/session-owners.ts +8 -2
- package/src/cli/public-command-errors.ts +4 -0
- package/src/cli/session-picker.ts +57 -7
- package/src/cli/update-cli.ts +0 -22
- package/src/cli-ordinary.ts +2 -17
- package/src/commands/sdk.ts +37 -15
- package/src/config/machine-identity.ts +31 -2
- package/src/config/model-registry.ts +40 -6
- package/src/config/settings-schema.ts +50 -6
- package/src/config/settings.ts +65 -3
- package/src/gjc-runtime/launch-tmux.ts +4 -1
- package/src/internal-urls/docs-index.generated.ts +12 -12
- package/src/lsp/client.ts +60 -6
- package/src/lsp/index.ts +2 -6
- package/src/lsp/types.ts +2 -0
- package/src/main.ts +364 -93
- package/src/modes/DESIGN.md +36 -0
- package/src/modes/acp/acp-agent.ts +215 -31
- package/src/modes/components/session-held-warning.ts +62 -0
- package/src/modes/components/session-selector.ts +234 -11
- package/src/modes/controllers/goal-mode-controller.ts +14 -2
- package/src/modes/controllers/selector-controller.ts +192 -3
- package/src/modes/interactive-mode.ts +40 -2
- package/src/prompts/tools/bash.md +1 -1
- package/src/prompts/tools/monitor.md +1 -1
- package/src/runtime-mcp/manager.ts +5 -1
- package/src/sdk/acp/adapter.ts +2 -0
- package/src/sdk/broker/broker.ts +29 -2
- package/src/sdk/broker/lifecycle-ledger.ts +9 -7
- package/src/sdk/broker/lifecycle.ts +280 -39
- package/src/sdk/broker/session-index.ts +24 -0
- package/src/sdk/bus/index.ts +1 -0
- package/src/sdk/bus/lifecycle-commands.ts +4 -0
- package/src/sdk/cli/session-cli.ts +8 -0
- package/src/sdk/host/control/dispatch.ts +18 -0
- package/src/sdk/host/host.ts +5 -0
- package/src/sdk/host/registration-test-hold.ts +51 -0
- package/src/sdk/host/session-runtime.test.ts +42 -0
- package/src/sdk/index.ts +10 -0
- package/src/sdk/lifecycle/service.ts +33 -10
- package/src/sdk/prompt-failure.ts +4 -0
- package/src/sdk/protocol/operation-registry.ts +7 -1
- package/src/sdk/session-api-key.ts +31 -16
- package/src/sdk/session-readonly/format.ts +10 -0
- package/src/sdk/session-readonly/scope.ts +2 -1
- package/src/sdk/session.ts +60 -7
- package/src/sdk/startup-capability.ts +27 -2
- package/src/session/agent-session.ts +411 -58
- package/src/session/internal/managed-session-storage.ts +16 -2
- package/src/session/internal/session-claim-set.ts +527 -49
- package/src/session/session-handover.ts +283 -0
- package/src/session/session-manager.ts +907 -148
- package/src/session/session-owner-holder.ts +177 -0
- package/src/session/session-ownership-mode.ts +84 -12
- package/src/session/session-ownership.ts +115 -89
- package/src/session/yield-queue.ts +43 -0
- package/src/session-import/provider-service.ts +8 -0
- package/src/setup/provider-onboarding.ts +5 -5
- package/src/task/executor.ts +2 -0
- package/src/tools/bash.ts +10 -0
- package/src/tools/browser/deferred-profile-cleanup.ts +20 -0
- package/src/tools/browser/launch.ts +133 -14
- package/src/tools/browser/registry.ts +72 -19
- package/src/tools/index.ts +10 -1
- package/src/tools/monitor.ts +267 -29
- package/src/tools/output-meta.ts +61 -28
- package/src/tools/tool-catalog.generated.ts +2 -2
- package/src/tools/tool-result.ts +5 -0
- package/dist/types/cli/macos-community-app.d.ts +0 -41
- package/src/cli/macos-community-app.ts +0 -1449
|
@@ -481,13 +481,17 @@ export const SETTINGS_SCHEMA = {
|
|
|
481
481
|
},
|
|
482
482
|
// Single-owner session claims. The whole `session.ownership.` namespace is global-only (see
|
|
483
483
|
// settings.ts), and later sub-flags sit beside `mode`, so the mode is a leaf, not the parent.
|
|
484
|
-
// Hidden from the UI
|
|
484
|
+
// Hidden from the settings UI; operators change it with `gjc config set` or the config file.
|
|
485
|
+
// `off` makes no claim and no lock call; `observe` claims and counts and never refuses; `enforce`,
|
|
486
|
+
// the default, also refuses to open a session another process holds.
|
|
485
487
|
"session.ownership.mode": {
|
|
486
488
|
type: "enum",
|
|
487
|
-
// Kept equal to SESSION_OWNERSHIP_MODES (a test checks);
|
|
489
|
+
// Kept equal to SESSION_OWNERSHIP_MODES and DEFAULT_SESSION_OWNERSHIP_MODE (a test checks);
|
|
490
|
+
// listed here so the schema imports nothing new.
|
|
488
491
|
values: ["off", "observe", "enforce"] as const,
|
|
489
|
-
default: "
|
|
490
|
-
description:
|
|
492
|
+
default: "enforce",
|
|
493
|
+
description:
|
|
494
|
+
"Single-owner session claims: off makes none, observe claims and counts conflicts without refusing anything, enforce (the default) refuses to open a session another process holds.",
|
|
491
495
|
},
|
|
492
496
|
"workspaceTree.mode": {
|
|
493
497
|
type: "enum",
|
|
@@ -1140,7 +1144,8 @@ export const SETTINGS_SCHEMA = {
|
|
|
1140
1144
|
ui: {
|
|
1141
1145
|
tab: "tools",
|
|
1142
1146
|
label: "Artifact tail size (KB)",
|
|
1143
|
-
description:
|
|
1147
|
+
description:
|
|
1148
|
+
"Amount of tail content kept inline when a tool result spills to an artifact. The Bash tool uses `tools.bashOutputTailBytes` instead.",
|
|
1144
1149
|
options: [
|
|
1145
1150
|
{ value: "1", label: "1 KB", description: "~250 tokens" },
|
|
1146
1151
|
{ value: "2.5", label: "2.5 KB", description: "~625 tokens" },
|
|
@@ -1160,7 +1165,7 @@ export const SETTINGS_SCHEMA = {
|
|
|
1160
1165
|
tab: "tools",
|
|
1161
1166
|
label: "Artifact head size (KB)",
|
|
1162
1167
|
description:
|
|
1163
|
-
"Amount of head content kept inline alongside the tail when
|
|
1168
|
+
"Amount of head content kept inline alongside the tail when a tool result spills to an artifact (middle elision). 0 disables — keep tail only. The Bash tool uses `tools.bashOutputHeadBytes` instead.",
|
|
1164
1169
|
options: [
|
|
1165
1170
|
{ value: "0", label: "0 KB", description: "Disabled; tail-only truncation" },
|
|
1166
1171
|
{ value: "1", label: "1 KB", description: "~250 tokens" },
|
|
@@ -1174,6 +1179,45 @@ export const SETTINGS_SCHEMA = {
|
|
|
1174
1179
|
],
|
|
1175
1180
|
},
|
|
1176
1181
|
},
|
|
1182
|
+
"tools.bashOutputTailBytes": {
|
|
1183
|
+
type: "number",
|
|
1184
|
+
default: 1,
|
|
1185
|
+
ui: {
|
|
1186
|
+
tab: "tools",
|
|
1187
|
+
label: "Bash output tail size (KB)",
|
|
1188
|
+
description:
|
|
1189
|
+
"Tail window the Bash tool keeps inline from command output; the full stream is saved as an artifact when storage is available. Deliberately small so callers prefer focused commands and the search/find tools.",
|
|
1190
|
+
options: [
|
|
1191
|
+
{ value: "1", label: "1 KB", description: "Default; ~250 tokens" },
|
|
1192
|
+
{ value: "2.5", label: "2.5 KB", description: "~625 tokens" },
|
|
1193
|
+
{ value: "5", label: "5 KB", description: "~1.25K tokens" },
|
|
1194
|
+
{ value: "10", label: "10 KB", description: "~2.5K tokens" },
|
|
1195
|
+
{ value: "20", label: "20 KB", description: "~5K tokens" },
|
|
1196
|
+
{ value: "50", label: "50 KB", description: "~12.5K tokens" },
|
|
1197
|
+
{ value: "100", label: "100 KB", description: "~25K tokens" },
|
|
1198
|
+
{ value: "200", label: "200 KB", description: "~50K tokens" },
|
|
1199
|
+
],
|
|
1200
|
+
},
|
|
1201
|
+
},
|
|
1202
|
+
"tools.bashOutputHeadBytes": {
|
|
1203
|
+
type: "number",
|
|
1204
|
+
default: 0,
|
|
1205
|
+
ui: {
|
|
1206
|
+
tab: "tools",
|
|
1207
|
+
label: "Bash output head size (KB)",
|
|
1208
|
+
description:
|
|
1209
|
+
"Head window the Bash tool keeps inline alongside the tail (middle elision) so the start of long command output stays visible. 0 keeps the tail only.",
|
|
1210
|
+
options: [
|
|
1211
|
+
{ value: "0", label: "0 KB", description: "Default; tail-only truncation" },
|
|
1212
|
+
{ value: "1", label: "1 KB", description: "~250 tokens" },
|
|
1213
|
+
{ value: "2.5", label: "2.5 KB", description: "~625 tokens" },
|
|
1214
|
+
{ value: "5", label: "5 KB", description: "~1.25K tokens" },
|
|
1215
|
+
{ value: "10", label: "10 KB", description: "~2.5K tokens" },
|
|
1216
|
+
{ value: "20", label: "20 KB", description: "~5K tokens" },
|
|
1217
|
+
{ value: "50", label: "50 KB", description: "~12.5K tokens" },
|
|
1218
|
+
],
|
|
1219
|
+
},
|
|
1220
|
+
},
|
|
1177
1221
|
"tools.outputMaxColumns": {
|
|
1178
1222
|
type: "number",
|
|
1179
1223
|
default: 768,
|
package/src/config/settings.ts
CHANGED
|
@@ -7225,11 +7225,70 @@ let globalInstance: Settings | null = null;
|
|
|
7225
7225
|
let globalInstancePromise: Promise<Settings> | null = null;
|
|
7226
7226
|
let globalInitOptions: SettingsOptions | null = null;
|
|
7227
7227
|
|
|
7228
|
-
|
|
7229
|
-
|
|
7228
|
+
/**
|
|
7229
|
+
* The operator's `session.ownership.mode` from the agent directory's config.yml, for a process that
|
|
7230
|
+
* never ran `Settings.init` (an SDK embedding with isolated settings), read once per path. Sync,
|
|
7231
|
+
* because sync session factories resolve the mode. A missing or malformed file reads as unset, as the
|
|
7232
|
+
* loader treats it. Any other read error (EACCES, EMFILE, a directory in the file's place) resolves to
|
|
7233
|
+
* `off`: deliberately more conservative than the loader, so a file that cannot be read never lifts an
|
|
7234
|
+
* `off` the operator may have set in it. That answer is not cached, because the error may be
|
|
7235
|
+
* transient: the next read tries the file again. The warning is logged once per path.
|
|
7236
|
+
*
|
|
7237
|
+
* A `fresh` read (a refusal decision's) bypasses the cache and never writes it, so a refusal never
|
|
7238
|
+
* changes the mode later factories read. It must not drop a refusal it cannot justify, so a read error
|
|
7239
|
+
* there reads as unset (the factory's decision stands), with its own warning, once per path.
|
|
7240
|
+
*/
|
|
7241
|
+
const operatorOwnershipModes = new Map<string, unknown>();
|
|
7242
|
+
const operatorOwnershipUnreadableWarned = new Set<string>();
|
|
7243
|
+
const operatorOwnershipRereadWarned = new Set<string>();
|
|
7244
|
+
function operatorOwnershipMode(configPath: string, fresh = false): unknown {
|
|
7245
|
+
if (!fresh && operatorOwnershipModes.has(configPath)) return operatorOwnershipModes.get(configPath);
|
|
7246
|
+
let mode: unknown;
|
|
7247
|
+
let content: string | undefined;
|
|
7248
|
+
try {
|
|
7249
|
+
content = fs.readFileSync(configPath, "utf8");
|
|
7250
|
+
} catch (error) {
|
|
7251
|
+
if (!isEnoent(error)) {
|
|
7252
|
+
const warned = fresh ? operatorOwnershipRereadWarned : operatorOwnershipUnreadableWarned;
|
|
7253
|
+
if (!warned.has(configPath)) {
|
|
7254
|
+
warned.add(configPath);
|
|
7255
|
+
logger.warn(
|
|
7256
|
+
fresh
|
|
7257
|
+
? "Session ownership kept a refusal: the global config could not be reread"
|
|
7258
|
+
: "Session ownership is off: the global config could not be read",
|
|
7259
|
+
{ configPath, error: error instanceof Error ? error.message : String(error) },
|
|
7260
|
+
);
|
|
7261
|
+
}
|
|
7262
|
+
return fresh ? undefined : "off";
|
|
7263
|
+
}
|
|
7264
|
+
}
|
|
7265
|
+
if (content !== undefined) {
|
|
7266
|
+
try {
|
|
7267
|
+
const parsed: unknown = YAML.parse(content);
|
|
7268
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed))
|
|
7269
|
+
mode = getByPath(parsed as RawSettings, ["session", "ownership", "mode"]);
|
|
7270
|
+
} catch {
|
|
7271
|
+
// Malformed YAML: the default applies, as it does for the loader.
|
|
7272
|
+
}
|
|
7273
|
+
}
|
|
7274
|
+
if (!fresh) operatorOwnershipModes.set(configPath, mode);
|
|
7275
|
+
return mode;
|
|
7276
|
+
}
|
|
7277
|
+
|
|
7278
|
+
// Session ownership reads its global-only mode from the process settings or, before they exist, from
|
|
7279
|
+
// the agent directory's config file, so the operator's `off` holds in an embedding too. Injected,
|
|
7280
|
+
// because the session modules sit below config in the import graph.
|
|
7230
7281
|
// The global layer only: a project or runtime value, including a null or scalar `session` parent
|
|
7231
7282
|
// that would replace the user's whole `session` object in the merge, never reaches the mode.
|
|
7232
|
-
|
|
7283
|
+
// A `fresh` read (a refusal decision) rereads the file even under process settings, which do not
|
|
7284
|
+
// hot-reload on every platform. Only an explicit `off` or `observe` in it lowers the refusal.
|
|
7285
|
+
setSessionOwnershipSettingSource(options => {
|
|
7286
|
+
if (options?.fresh)
|
|
7287
|
+
return operatorOwnershipMode(path.join(globalInstance?.getAgentDir() ?? getAgentDir(), "config.yml"), true);
|
|
7288
|
+
return globalInstance
|
|
7289
|
+
? globalInstance.getGlobal("session.ownership.mode")
|
|
7290
|
+
: operatorOwnershipMode(path.join(getAgentDir(), "config.yml"));
|
|
7291
|
+
});
|
|
7233
7292
|
|
|
7234
7293
|
export function isSettingsInitialized(): boolean {
|
|
7235
7294
|
return globalInstance !== null;
|
|
@@ -7244,6 +7303,9 @@ export function resetSettingsForTest(): void {
|
|
|
7244
7303
|
globalInstance = null;
|
|
7245
7304
|
globalInstancePromise = null;
|
|
7246
7305
|
globalInitOptions = null;
|
|
7306
|
+
operatorOwnershipModes.clear();
|
|
7307
|
+
operatorOwnershipUnreadableWarned.clear();
|
|
7308
|
+
operatorOwnershipRereadWarned.clear();
|
|
7247
7309
|
}
|
|
7248
7310
|
|
|
7249
7311
|
/**
|
|
@@ -2,12 +2,13 @@ import * as crypto from "node:crypto";
|
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { VERSION } from "@gajae-code/utils/dirs";
|
|
5
|
-
import { isCompiledBinary } from "@gajae-code/utils/env";
|
|
5
|
+
import { isCompiledBinary, startupProjectEnvSnapshot } from "@gajae-code/utils/env";
|
|
6
6
|
import { safeStderrWrite } from "@gajae-code/utils/safe-stderr";
|
|
7
7
|
import { projectSafeSpawnEnv } from "@gajae-code/utils/shell-config";
|
|
8
8
|
import type { Args } from "../cli/args";
|
|
9
9
|
import { macOSMallocEnvUnsetArgs } from "../cli/malloc-env-guard";
|
|
10
10
|
import { dropProjectSuppliedHerdrBinPath } from "../main";
|
|
11
|
+
import { dropProjectSuppliedSessionOwnershipOverride } from "../session/session-ownership-mode";
|
|
11
12
|
import { readLinuxProcStartTimeSync } from "./linux-proc";
|
|
12
13
|
import {
|
|
13
14
|
MANAGED_OWNER_PREDECESSOR_GENERATION_ENV,
|
|
@@ -1557,6 +1558,7 @@ function emitOptionalProfileDiagnostics(profile: GjcTmuxProfileResult, diagnosti
|
|
|
1557
1558
|
export function launchDefaultTmuxIfNeeded(context: TmuxLaunchContext): boolean {
|
|
1558
1559
|
// Judge with this process's startup snapshot, including after a worktree chdir.
|
|
1559
1560
|
dropProjectSuppliedHerdrBinPath(context.env ?? process.env);
|
|
1561
|
+
dropProjectSuppliedSessionOwnershipOverride(context.env ?? process.env, startupProjectEnvSnapshot());
|
|
1560
1562
|
const env = context.env ?? process.env;
|
|
1561
1563
|
// Planning performs only applicability checks. It must precede both the ambient
|
|
1562
1564
|
// window rename and provider refusal so inapplicable root launches reach main
|
|
@@ -1666,6 +1668,7 @@ export function launchDefaultTmuxIfNeeded(context: TmuxLaunchContext): boolean {
|
|
|
1666
1668
|
const creationSpawn = plan.authority ? spawnSync : rawSpawnSync;
|
|
1667
1669
|
const spawnEnv = { ...tmuxLaunchIdentityEnv(env, plan.cwd) };
|
|
1668
1670
|
dropProjectSuppliedHerdrBinPath(spawnEnv);
|
|
1671
|
+
dropProjectSuppliedSessionOwnershipOverride(spawnEnv, startupProjectEnvSnapshot());
|
|
1669
1672
|
delete spawnEnv[GJC_COORDINATOR_SIDECAR_SIGNING_KEY_ENV];
|
|
1670
1673
|
const signingEnv = coordinatorSidecarSigningEnv(env);
|
|
1671
1674
|
Object.assign(spawnEnv, signingEnv);
|