@gajae-code/coding-agent 0.22.1 → 0.22.2
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 +60 -0
- package/dist/types/cli/doctor/probe-types.d.ts +1 -1
- package/dist/types/cli/doctor/session-owners-probe.d.ts +7 -0
- package/dist/types/cli/doctor/session-owners.d.ts +16 -0
- package/dist/types/cli/github-release.d.ts +16 -0
- package/dist/types/cli/session-owners-cli.d.ts +13 -0
- package/dist/types/cli/update-cli.d.ts +2 -0
- package/dist/types/commands/sdk.d.ts +23 -14
- package/dist/types/config/settings-schema.d.ts +6 -0
- package/dist/types/exec/bash-shell-guardian.d.ts +61 -0
- package/dist/types/export/html/html-export-destination.d.ts +16 -0
- package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +1 -1
- package/dist/types/sdk/host/control/runtime-gate.d.ts +7 -0
- package/dist/types/session/internal/graph-successor-proof.d.ts +33 -0
- package/dist/types/session/internal/managed-session-storage.d.ts +6 -1
- package/dist/types/session/internal/session-claim-set.d.ts +69 -0
- package/dist/types/session/operator-error-message.d.ts +29 -0
- package/dist/types/session/session-manager.d.ts +57 -3
- package/dist/types/session/session-owners-layout.d.ts +24 -0
- package/dist/types/session/session-ownership-mode.d.ts +45 -0
- package/dist/types/session/session-ownership.d.ts +195 -0
- package/dist/types/session/session-storage.d.ts +36 -0
- package/dist/types/slash-commands/helpers/parse.d.ts +1 -0
- package/package.json +12 -8
- package/scripts/verify-gjc-sdk-canonicalization.ts +2 -0
- package/src/cli/doctor/probe-types.ts +1 -1
- package/src/cli/doctor/probe.ts +9 -5
- package/src/cli/doctor/runner.ts +6 -1
- package/src/cli/doctor/session-owners-probe.ts +69 -0
- package/src/cli/doctor/session-owners.ts +106 -0
- package/src/cli/github-release.ts +100 -0
- package/src/cli/session-owners-cli.ts +118 -0
- package/src/cli/stats-cli.ts +19 -1
- package/src/cli/update-cli.ts +50 -3
- package/src/cli-ordinary.ts +1 -1
- package/src/commands/sdk.ts +36 -33
- package/src/commands/session.ts +10 -2
- package/src/config/settings-schema.ts +18 -0
- package/src/config/settings.ts +127 -13
- package/src/exec/bash-shell-guardian.ts +181 -12
- package/src/exec/isolated-shell.ts +13 -3
- package/src/export/html/html-export-destination.ts +47 -2
- package/src/export/html/index.ts +161 -13
- package/src/internal-urls/docs-index.generated.ts +4 -4
- package/src/main.ts +20 -14
- package/src/modes/acp/acp-agent.ts +6 -0
- package/src/modes/action-registry.ts +4 -1
- package/src/modes/controllers/command-controller.ts +12 -5
- package/src/modes/controllers/extension-ui-controller.ts +6 -22
- package/src/modes/controllers/input-controller.ts +3 -2
- package/src/modes/controllers/selector-controller.ts +14 -1
- package/src/modes/interactive-mode.ts +6 -3
- package/src/modes/print-mode.ts +2 -1
- package/src/modes/runtime-init.ts +2 -17
- package/src/modes/utils/ui-helpers.ts +5 -3
- package/src/sdk/bus/index.ts +22 -0
- package/src/sdk/bus/telegram-daemon-contract.ts +1 -1
- package/src/sdk/host/control/dispatch.ts +5 -1
- package/src/sdk/host/control/runtime-gate.ts +22 -0
- package/src/sdk/host/host.ts +4 -1
- package/src/sdk/session-readonly/metadata.ts +24 -18
- package/src/sdk/session.ts +2 -0
- package/src/session/agent-session.ts +101 -22
- package/src/session/internal/graph-successor-proof.ts +108 -0
- package/src/session/internal/managed-session-storage.ts +8 -1
- package/src/session/internal/session-claim-set.ts +242 -0
- package/src/session/operator-error-message.ts +79 -0
- package/src/session/session-manager.ts +524 -108
- package/src/session/session-owners-layout.ts +52 -0
- package/src/session/session-ownership-mode.ts +176 -0
- package/src/session/session-ownership.ts +851 -0
- package/src/session/session-storage.ts +60 -16
- package/src/setup/credential-import.ts +2 -1
- package/src/slash-commands/builtin-registry.ts +2 -0
- package/src/slash-commands/helpers/parse.ts +3 -1
|
@@ -63,7 +63,7 @@ import {
|
|
|
63
63
|
} from "./task-artifact-owner-retirement";
|
|
64
64
|
|
|
65
65
|
const newlineBuffer = Buffer.from("\n", "utf8");
|
|
66
|
-
function canonicalPathSync(value: string): string {
|
|
66
|
+
export function canonicalPathSync(value: string): string {
|
|
67
67
|
try {
|
|
68
68
|
return fs.realpathSync.native(value);
|
|
69
69
|
} catch {
|
|
@@ -93,7 +93,7 @@ function transcriptLockIdentity(transcriptPath: string): string {
|
|
|
93
93
|
* writable without the sticky bit, or group-writable through a group other than the user's
|
|
94
94
|
* primary group. (Windows profile DACLs grant only the user, SYSTEM, and Administrators.)
|
|
95
95
|
*/
|
|
96
|
-
function assertAppendLockHomeNotSharedWritable(home: string): void {
|
|
96
|
+
export function assertAppendLockHomeNotSharedWritable(home: string): void {
|
|
97
97
|
if (process.platform === "win32") return;
|
|
98
98
|
const stat = fs.statSync(home);
|
|
99
99
|
const uid = process.getuid?.();
|
|
@@ -106,21 +106,37 @@ function assertAppendLockHomeNotSharedWritable(home: string): void {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
interface DirectoryIdentity {
|
|
109
|
+
export interface DirectoryIdentity {
|
|
110
110
|
readonly path: string;
|
|
111
111
|
readonly dev: bigint;
|
|
112
112
|
readonly ino: bigint;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
/** A prepared `<home>/.gjc/runtime/<name>` lock directory plus the identities of `.gjc`, `runtime` and itself. */
|
|
116
|
+
export interface RuntimeLockDirectory {
|
|
117
|
+
readonly path: string;
|
|
118
|
+
readonly directories: readonly DirectoryIdentity[];
|
|
119
|
+
/** The noun error text uses for this namespace's directories, e.g. `append-lock`. */
|
|
120
|
+
readonly label: string;
|
|
121
|
+
}
|
|
122
|
+
|
|
115
123
|
/** A prepared append-lock path plus the identities of `.gjc`, `runtime`, and `append-locks`. */
|
|
116
124
|
interface AppendLockTarget {
|
|
117
125
|
readonly lockPath: string;
|
|
118
126
|
readonly directories: readonly DirectoryIdentity[];
|
|
119
127
|
}
|
|
120
128
|
|
|
121
|
-
|
|
129
|
+
/** A lock namespace name: one lower-case path segment, so it can never leave `runtime`. */
|
|
130
|
+
const RUNTIME_LOCK_DIRECTORY_NAME = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
131
|
+
|
|
132
|
+
/** `append-locks` → `append-lock`: the noun error text uses for a namespace's directories. */
|
|
133
|
+
function runtimeLockDirectoryLabel(name: string): string {
|
|
134
|
+
return name.endsWith("s") ? name.slice(0, -1) : name;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function realDirectoryIdentity(pathname: string, label = "append-lock"): DirectoryIdentity {
|
|
122
138
|
const stat = fs.lstatSync(pathname, { bigint: true });
|
|
123
|
-
if (!stat.isDirectory() || stat.isSymbolicLink()) throw new Error(`Unsafe
|
|
139
|
+
if (!stat.isDirectory() || stat.isSymbolicLink()) throw new Error(`Unsafe ${label} directory: ${pathname}`);
|
|
124
140
|
return { path: pathname, dev: stat.dev, ino: stat.ino };
|
|
125
141
|
}
|
|
126
142
|
|
|
@@ -129,26 +145,44 @@ function realDirectoryIdentity(pathname: string): DirectoryIdentity {
|
|
|
129
145
|
* so a principal able to rename entries in `.gjc` cannot redirect a writer to a fresh,
|
|
130
146
|
* empty lock directory and enter the critical section beside another writer.
|
|
131
147
|
*/
|
|
132
|
-
function
|
|
133
|
-
|
|
148
|
+
export function assertRuntimeLockDirectoryUnchanged(
|
|
149
|
+
directories: readonly DirectoryIdentity[],
|
|
150
|
+
code = "append_lock_root_changed",
|
|
151
|
+
label = "append-lock",
|
|
152
|
+
): void {
|
|
153
|
+
for (const expected of directories) {
|
|
134
154
|
let current: DirectoryIdentity;
|
|
135
155
|
try {
|
|
136
|
-
current = realDirectoryIdentity(expected.path);
|
|
156
|
+
current = realDirectoryIdentity(expected.path, label);
|
|
137
157
|
} catch (error) {
|
|
138
|
-
throw new Error(
|
|
158
|
+
throw new Error(`${code}: ${expected.path}`, { cause: error });
|
|
139
159
|
}
|
|
140
160
|
if (current.dev !== expected.dev || current.ino !== expected.ino) {
|
|
141
|
-
throw new Error(
|
|
161
|
+
throw new Error(`${code}: ${expected.path}`);
|
|
142
162
|
}
|
|
143
163
|
}
|
|
144
164
|
}
|
|
145
165
|
|
|
146
|
-
function
|
|
147
|
-
|
|
166
|
+
function assertAppendLockTargetUnchanged(target: AppendLockTarget): void {
|
|
167
|
+
assertRuntimeLockDirectoryUnchanged(target.directories);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Create `<trusted home>/.gjc/runtime/<name>` for kernel or exclusive-file locks, with the
|
|
172
|
+
* checks every lock namespace shares, and capture its directories' identities for
|
|
173
|
+
* {@link assertRuntimeLockDirectoryUnchanged}. Throws (fails closed) on a home other users can
|
|
174
|
+
* write, a reparse component, or a directory whose owner-only mode or ACL does not verify.
|
|
175
|
+
*/
|
|
176
|
+
export function prepareRuntimeLockDirectory(
|
|
177
|
+
name: string,
|
|
178
|
+
trustedHome: string = getTrustedHomeDir(),
|
|
179
|
+
): RuntimeLockDirectory {
|
|
180
|
+
if (!RUNTIME_LOCK_DIRECTORY_NAME.test(name)) throw new TypeError(`Invalid runtime lock directory name: ${name}`);
|
|
181
|
+
const home = canonicalPathSync(trustedHome);
|
|
148
182
|
assertAppendLockHomeNotSharedWritable(home);
|
|
149
183
|
const gjcRoot = path.join(home, ".gjc");
|
|
150
184
|
const appendLockRuntimeRoot = path.join(gjcRoot, "runtime");
|
|
151
|
-
const lockRoot = path.join(appendLockRuntimeRoot,
|
|
185
|
+
const lockRoot = path.join(appendLockRuntimeRoot, name);
|
|
152
186
|
// No component below the trusted home may be a reparse point, including `.gjc`,
|
|
153
187
|
// which ensureManagedDirectory would otherwise create through recursively.
|
|
154
188
|
assertNoReparsePath(lockRoot);
|
|
@@ -160,12 +194,22 @@ function prepareAppendLockTarget(transcriptPath: string): AppendLockTarget {
|
|
|
160
194
|
ensureManagedDirectory(gjcRoot, undefined, policy);
|
|
161
195
|
ensureManagedDirectory(appendLockRuntimeRoot, undefined, policy);
|
|
162
196
|
ensureManagedDirectory(lockRoot, undefined, policy);
|
|
197
|
+
const label = runtimeLockDirectoryLabel(name);
|
|
198
|
+
return {
|
|
199
|
+
path: lockRoot,
|
|
200
|
+
directories: [gjcRoot, appendLockRuntimeRoot, lockRoot].map(directory => realDirectoryIdentity(directory, label)),
|
|
201
|
+
label,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function prepareAppendLockTarget(transcriptPath: string): AppendLockTarget {
|
|
206
|
+
const directory = prepareRuntimeLockDirectory("append-locks");
|
|
163
207
|
return {
|
|
164
208
|
lockPath: path.join(
|
|
165
|
-
|
|
209
|
+
directory.path,
|
|
166
210
|
`gjc-${createHash("sha256").update(transcriptLockIdentity(transcriptPath)).digest("hex")}.append-lock`,
|
|
167
211
|
),
|
|
168
|
-
directories:
|
|
212
|
+
directories: directory.directories,
|
|
169
213
|
};
|
|
170
214
|
}
|
|
171
215
|
|
|
@@ -894,7 +938,7 @@ export function writeExplicitOwnerOnlyTextSync(pathname: string, content: string
|
|
|
894
938
|
}
|
|
895
939
|
|
|
896
940
|
/** Reject a symlink/junction/reparse component before a storage path is created or opened. */
|
|
897
|
-
function assertNoReparsePath(pathname: string): void {
|
|
941
|
+
export function assertNoReparsePath(pathname: string): void {
|
|
898
942
|
const resolved = path.resolve(pathname);
|
|
899
943
|
const parsed = path.parse(resolved);
|
|
900
944
|
let current = parsed.root;
|
|
@@ -320,7 +320,8 @@ function parseCodexAuth(raw: string, source: string): ImportableCredential | Ski
|
|
|
320
320
|
access,
|
|
321
321
|
refresh,
|
|
322
322
|
expires: expiresAt ?? Date.now(),
|
|
323
|
-
|
|
323
|
+
// The ChatGPT workspace id is also the credential's organization: one login holds a row per workspace.
|
|
324
|
+
...(accountId ? { accountId, organizationId: accountId } : {}),
|
|
324
325
|
...(email ? { email } : {}),
|
|
325
326
|
};
|
|
326
327
|
const identity =
|
|
@@ -2633,6 +2633,8 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<SlashCommandSpec> = [
|
|
|
2633
2633
|
}
|
|
2634
2634
|
if (!isDirectory) return usage(`Directory does not exist or is not a directory: ${resolvedPath}`, runtime);
|
|
2635
2635
|
try {
|
|
2636
|
+
// Refuse before flushing, not from inside moveTo.
|
|
2637
|
+
runtime.sessionManager.assertLegacyMutationAllowed("move session");
|
|
2636
2638
|
await runtime.sessionManager.flush();
|
|
2637
2639
|
await runtime.sessionManager.moveTo(resolvedPath);
|
|
2638
2640
|
} catch (err) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { operatorErrorMessage } from "../../session/operator-error-message";
|
|
1
2
|
import { parseCommandArgs } from "../../utils/command-args";
|
|
2
3
|
import type { ParsedSlashCommand, SlashCommandResult, SlashCommandRuntime } from "../types";
|
|
3
4
|
|
|
@@ -56,8 +57,9 @@ export function parseSubcommand(input: string): ParsedSubcommand {
|
|
|
56
57
|
return { verb: trimmed.slice(0, spaceIdx).toLowerCase(), rest: trimmed.slice(spaceIdx + 1).trim() };
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
/** Human text for a failed slash command; session refusals render their operator message. */
|
|
59
61
|
export function errorMessage(error: unknown): string {
|
|
60
|
-
return error
|
|
62
|
+
return operatorErrorMessage(error, String(error));
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
/**
|