@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
|
@@ -17,12 +17,13 @@ import { type BlobPutResult, BlobStore } from "./blob-store";
|
|
|
17
17
|
import { type GraphSuccessorRefusal } from "./internal/graph-successor-proof";
|
|
18
18
|
import { type ManagedMigrationPolicy } from "./internal/managed-session-scope";
|
|
19
19
|
import { ManagedAppendIdentityMismatchError, type ManagedAppendReceipt, type ManagedBoundedAppendExpectation, type ManagedDirectoryRoot, ManagedSessionDescendantStore } from "./internal/managed-session-storage";
|
|
20
|
-
import { SessionClaimSet, sessionClaimSetCapability } from "./internal/session-claim-set";
|
|
20
|
+
import { type ResolvedSessionOwnership, SessionClaimSet, type SessionOwnershipDecision, sessionClaimSetCapability } from "./internal/session-claim-set";
|
|
21
21
|
import { type BaseAnchor, BoundedLabelsPinsStore, type CommittedTail, type DescriptorSnapshot, type DictionaryPartitionCommit, FixedCacheAccount, type MetadataDeltaValue, type ParentBucketCommit, type ReducerState, type ReopenClassification, SessionMemoryAccountant } from "./internal/session-memory-sidecar";
|
|
22
22
|
import { type MemoryGuardCreateCheckpointInput, type MemoryGuardParticipantIngressLease, type MemoryGuardRestoreInput, type MemoryGuardRestoreResult, type MemoryGuardSessionManagerCheckpointV1 } from "./memory-guard-checkpoint-participant";
|
|
23
23
|
import { type BashExecutionMessage, type CustomMessage, type FileMentionMessage, type HookMessage, type PythonExecutionMessage } from "./messages";
|
|
24
24
|
import { type SessionRecapAppendResult, type SessionRecapInput } from "./recap";
|
|
25
25
|
import { type SessionManagerReadAccess, sessionManagerReadCapability } from "./session-manager-internal";
|
|
26
|
+
import { SessionHeldError, type SessionOwnerClaim } from "./session-ownership";
|
|
26
27
|
import type { ManagedSessionSecurityContext, SessionStorage, VerifiedSessionDeleteResult, VerifiedSessionDeleteTarget } from "./session-storage";
|
|
27
28
|
export interface SessionHeader extends MutableSessionHeaderFields {
|
|
28
29
|
type: "session";
|
|
@@ -1481,7 +1482,10 @@ export declare class SessionManager {
|
|
|
1481
1482
|
restoreRollbackState(snapshot: SessionManagerStateSnapshot): Promise<void>;
|
|
1482
1483
|
captureState(): SessionManagerStateSnapshot;
|
|
1483
1484
|
restoreState(snapshot: SessionManagerStateSnapshot): void;
|
|
1484
|
-
/**
|
|
1485
|
+
/**
|
|
1486
|
+
* Switch to a different session file (used for resume and branching). Under enforce, a target
|
|
1487
|
+
* another process holds is refused with {@link SessionHeldError} before anything changes.
|
|
1488
|
+
*/
|
|
1485
1489
|
setSessionFile(sessionFile: string, options?: {
|
|
1486
1490
|
deferEphemeralArtifactRetirement?: boolean;
|
|
1487
1491
|
}): Promise<void>;
|
|
@@ -1703,6 +1707,14 @@ export declare class SessionManager {
|
|
|
1703
1707
|
* @internal
|
|
1704
1708
|
*/
|
|
1705
1709
|
flushBeforeLeaving(): Promise<void>;
|
|
1710
|
+
/**
|
|
1711
|
+
* Take over a manager its holder dropped after `close()` failed (a bounded fork's swap or rollback):
|
|
1712
|
+
* retry only the writer close while it is retryable, then release its resources and claims, so a
|
|
1713
|
+
* claim lives exactly as long as the writer. Never a full `close()`: that could rewrite a
|
|
1714
|
+
* transcript the holder has already discarded.
|
|
1715
|
+
* @internal
|
|
1716
|
+
*/
|
|
1717
|
+
retryCloseInBackground(): void;
|
|
1706
1718
|
/** Close the persistent writer after flushing all pending data. */
|
|
1707
1719
|
close(): Promise<void>;
|
|
1708
1720
|
/** Flush while open, then strictly close; retryable close skips the invalid second flush. */
|
|
@@ -1828,7 +1840,7 @@ export declare class SessionManager {
|
|
|
1828
1840
|
setSessionStarred(starred: boolean): Promise<boolean>;
|
|
1829
1841
|
setSessionStarredForPicker(session: SessionInfo, starred: boolean): Promise<void>;
|
|
1830
1842
|
/** Update only a picker candidate's metadata, without opening a runtime or publishing a resume breadcrumb. */
|
|
1831
|
-
static setSessionStarredForPicker(session: SessionInfo, starred: boolean, explicitSessionDir?: string): Promise<void>;
|
|
1843
|
+
static setSessionStarredForPicker(session: SessionInfo, starred: boolean, explicitSessionDir?: string, ownership?: SessionOwnershipDecision): Promise<void>;
|
|
1832
1844
|
setSessionName(name: string, source?: "auto" | "user", options?: {
|
|
1833
1845
|
isCurrent?: () => boolean;
|
|
1834
1846
|
onlyIfUnnamed?: boolean;
|
|
@@ -1900,6 +1912,12 @@ export declare class SessionManager {
|
|
|
1900
1912
|
withSharedThinkingControl<T>(body: () => Promise<T>): Promise<T>;
|
|
1901
1913
|
/** Whether this logical session must keep using shared mutation admission. */
|
|
1902
1914
|
requiresSharedMutationAdmission(): boolean;
|
|
1915
|
+
/**
|
|
1916
|
+
* Refuse, with {@link ManagedAppendIdentityMismatchError}, a destructive control (`/drop`) on a
|
|
1917
|
+
* managed transcript that is no longer the one this manager last wrote or bound: a writer it
|
|
1918
|
+
* cannot see (ownership off, an older binary) changed it, and its entries would go with it.
|
|
1919
|
+
*/
|
|
1920
|
+
assertTranscriptUnchanged(): void;
|
|
1903
1921
|
/** Refuse before caller-side agent, UI, settings, or external effects. */
|
|
1904
1922
|
assertLegacyMutationAllowed(operation: string): void;
|
|
1905
1923
|
/** Additive legacy appends are safe once a control publication's transaction has settled. */
|
|
@@ -2250,18 +2268,31 @@ export declare class SessionManager {
|
|
|
2250
2268
|
static nestedManagedDestination(authority: ManagedDirectoryRoot | ManagedSessionDescendantStore, directory: string): SessionDestination;
|
|
2251
2269
|
static managedDestination(cwd: string, agentDir?: string, storage?: SessionStorage): SessionDestination;
|
|
2252
2270
|
static explicitDestination(directory: string): SessionDestination;
|
|
2253
|
-
static create(cwd: string, destinationInput?: SessionDestinationInput, storage?: SessionStorage): SessionManager;
|
|
2271
|
+
static create(cwd: string, destinationInput?: SessionDestinationInput, storage?: SessionStorage, ownership?: SessionOwnershipDecision): SessionManager;
|
|
2254
2272
|
/** Prepare a selected candidate using this manager's captured managed destination authority. */
|
|
2255
2273
|
prepareManagedCandidateForWrite(filePath: string, migrationPolicy: SessionDirectoryMigrationPolicy, expectedIdentity?: ResumeSessionIdentity): Promise<string>;
|
|
2256
2274
|
/** Prepare a managed candidate and retain its exact post-preparation identity for the next adoption. */
|
|
2257
2275
|
prepareManagedCandidateForStrictAdoption(filePath: string, migrationPolicy: SessionDirectoryMigrationPolicy, expectedIdentity: ResumeSessionIdentity): Promise<string>;
|
|
2258
|
-
/**
|
|
2259
|
-
|
|
2276
|
+
/**
|
|
2277
|
+
* Resolve a default-managed candidate through binding validation and copy-retain migration before mutation.
|
|
2278
|
+
* The migration runs under a scoped claim of the candidate's id. With `readInPlaceWhenHeld` (a fork's
|
|
2279
|
+
* source) a candidate another process holds is not migrated: the caller reads it where it is.
|
|
2280
|
+
*/
|
|
2281
|
+
static prepareManagedCandidateForWrite(filePath: string, migrationPolicy: SessionDirectoryMigrationPolicy, destination: SessionDestination, expectedIdentity?: ResumeSessionIdentity, options?: {
|
|
2282
|
+
readonly ownership?: SessionOwnershipDecision;
|
|
2283
|
+
readonly readInPlaceWhenHeld?: boolean;
|
|
2284
|
+
}): Promise<string>;
|
|
2260
2285
|
/**
|
|
2261
2286
|
* Fork a session into the current project directory.
|
|
2262
2287
|
* Copies history from another session file while creating a new session file in the current sessionDir.
|
|
2263
2288
|
*/
|
|
2264
|
-
static forkFrom(sourcePath: string, cwd: string, destinationInput?: SessionDestinationInput, storage?: SessionStorage, migrationPolicy?: SessionDirectoryMigrationPolicy, sessionMemoryMode?: SessionMemoryMode
|
|
2289
|
+
static forkFrom(sourcePath: string, cwd: string, destinationInput?: SessionDestinationInput, storage?: SessionStorage, migrationPolicy?: SessionDirectoryMigrationPolicy, sessionMemoryMode?: SessionMemoryMode, ownership?: SessionOwnershipDecision, options?: {
|
|
2290
|
+
/**
|
|
2291
|
+
* `false` when the caller switches to the fork next: the switch moves the terminal
|
|
2292
|
+
* breadcrumb once it lands, so an abandoned fork never becomes `--continue`'s target.
|
|
2293
|
+
*/
|
|
2294
|
+
readonly writeBreadcrumb?: boolean;
|
|
2295
|
+
}): Promise<SessionManager>;
|
|
2265
2296
|
/**
|
|
2266
2297
|
* Open a specific session file.
|
|
2267
2298
|
* @param path Path to session file
|
|
@@ -2286,7 +2317,30 @@ export declare class SessionManager {
|
|
|
2286
2317
|
discardStaged(): Promise<void>;
|
|
2287
2318
|
commitStagedNestedManaged(): Promise<void>;
|
|
2288
2319
|
discardStagedNestedManaged(): Promise<void>;
|
|
2289
|
-
static open(filePath: string, destinationInput?: SessionDestinationInput, storage?: SessionStorage, migrationPolicy?: SessionDirectoryMigrationPolicy, sessionMemoryMode?: SessionMemoryMode): Promise<SessionManager>;
|
|
2320
|
+
static open(filePath: string, destinationInput?: SessionDestinationInput, storage?: SessionStorage, migrationPolicy?: SessionDirectoryMigrationPolicy, sessionMemoryMode?: SessionMemoryMode, ownership?: SessionOwnershipDecision): Promise<SessionManager>;
|
|
2321
|
+
/** The surface and mode this manager claims with, for a claim taken on its behalf (Continue here). */
|
|
2322
|
+
get ownershipDecision(): ResolvedSessionOwnership;
|
|
2323
|
+
/**
|
|
2324
|
+
* Enforce's admission of a switch target (design §1 rows 3 and 9): `open`'s pre-claim of the
|
|
2325
|
+
* target's header id, taken before the switch emits any event or begins its transition. It throws
|
|
2326
|
+
* {@link SessionHeldError} for a session another process holds. The returned claim is an
|
|
2327
|
+
* admission: the rotation's own claim of the target releases it when it lands, so the switched-to
|
|
2328
|
+
* session never has it as a second holder; the caller still releases it on every path (a no-op
|
|
2329
|
+
* by then), which covers a switch that ends before it claims. `undefined`, with nothing awaited,
|
|
2330
|
+
* outside enforce, so other modes keep their ordering.
|
|
2331
|
+
*/
|
|
2332
|
+
switchTargetAdmission(sessionFile: string): Promise<SessionOwnerClaim | undefined> | undefined;
|
|
2333
|
+
/**
|
|
2334
|
+
* Run `run` under {@link switchTargetAdmission}'s claim of `sessionFile`, released once `run`
|
|
2335
|
+
* settles. Outside enforce `run` is called at once, with nothing awaited before it.
|
|
2336
|
+
*/
|
|
2337
|
+
withSwitchTargetAdmission<T>(sessionFile: string, run: () => Promise<T>): Promise<T>;
|
|
2338
|
+
/**
|
|
2339
|
+
* Enforce's refusal for the session in an existing transcript that another process holds, from a
|
|
2340
|
+
* probe of its header id: what an interactive launch warns about before it opens or forks
|
|
2341
|
+
* (design §3.1). `undefined`, with nothing awaited, outside enforce.
|
|
2342
|
+
*/
|
|
2343
|
+
static probeHeldTranscript(filePath: string, ownership?: SessionOwnershipDecision): Promise<SessionHeldError | undefined> | undefined;
|
|
2290
2344
|
static openNestedManaged(filePath: string, destination: SessionDestination, store: ManagedSessionDescendantStore, storage?: SessionStorage, cwdOverride?: string, sessionMemoryMode?: SessionMemoryMode): Promise<SessionManager>;
|
|
2291
2345
|
/**
|
|
2292
2346
|
* List default-managed sessions for the resume picker without recovery or other
|
|
@@ -2302,8 +2356,13 @@ export declare class SessionManager {
|
|
|
2302
2356
|
static listForResumePickerReadOnly(cwd: string, sessionDir?: string, storage?: SessionStorage): Promise<SessionInfo[]>;
|
|
2303
2357
|
/** Read a recap only from the exact, unchanged transcript authorized by an SDK lookup. */
|
|
2304
2358
|
static readSessionRecapReadOnly(file: string, identity: SessionRecapFileIdentity): Promise<SessionRecapRecord | undefined>;
|
|
2305
|
-
/** Delete an authorized managed or project-local picker candidate. */
|
|
2306
|
-
static deleteManagedCandidate(sessionPath: string): Promise<void>;
|
|
2359
|
+
/** Delete an authorized managed or project-local picker candidate, under a scoped claim of its id (design §1 row 17). */
|
|
2360
|
+
static deleteManagedCandidate(sessionPath: string, ownership?: SessionOwnershipDecision): Promise<void>;
|
|
2361
|
+
/**
|
|
2362
|
+
* Delete a picker candidate of an explicit `--session-dir` (transcript and artifacts), under a
|
|
2363
|
+
* scoped claim of the id its header names (design §1 row 17).
|
|
2364
|
+
*/
|
|
2365
|
+
static deleteExplicitCandidate(sessionPath: string, ownership?: SessionOwnershipDecision): Promise<void>;
|
|
2307
2366
|
/** Capture exact source content for a strict fork without granting write ownership. */
|
|
2308
2367
|
static captureTranscriptStrict(filePath: string, storage?: SessionStorage): StrictSessionCaptureResult;
|
|
2309
2368
|
/**
|
|
@@ -2313,7 +2372,7 @@ export declare class SessionManager {
|
|
|
2313
2372
|
* sourceEntryId selects an inclusive root-to-entry path; null selects no history.
|
|
2314
2373
|
* Undefined preserves the complete transcript, including inactive branches.
|
|
2315
2374
|
*/
|
|
2316
|
-
static forkFromCaptured(snapshot: CapturedSessionTranscriptSnapshot, cwd: string, destinationInput?: SessionDestinationInput, _migrationPolicy?: SessionDirectoryMigrationPolicy, sessionMemoryMode?: SessionMemoryMode, sourceEntryId?: string | null): Promise<StrictSessionForkResult>;
|
|
2375
|
+
static forkFromCaptured(snapshot: CapturedSessionTranscriptSnapshot, cwd: string, destinationInput?: SessionDestinationInput, _migrationPolicy?: SessionDirectoryMigrationPolicy, sessionMemoryMode?: SessionMemoryMode, sourceEntryId?: string | null, ownership?: SessionOwnershipDecision): Promise<StrictSessionForkResult>;
|
|
2317
2376
|
static restoreMemoryGuardCheckpoint(input: MemoryGuardRestoreInput): Promise<MemoryGuardRestoreResult>;
|
|
2318
2377
|
/** Inspect a selected session without acquiring write-capable ownership. */
|
|
2319
2378
|
static inspectSessionTailReadOnly(filePath: string, storage?: SessionStorage): Promise<ResumeTailInspection>;
|
|
@@ -2364,7 +2423,7 @@ export declare class SessionManager {
|
|
|
2364
2423
|
* the explicit promotion seam only after its ownership-ready fence and writer
|
|
2365
2424
|
* lease are durable.
|
|
2366
2425
|
*/
|
|
2367
|
-
static openExistingForRecoveryHydrationStrict(identity: ResumeSessionIdentity, destinationInput?: SessionDestinationInput, storage?: SessionStorage): Promise<RecoveryHydrationOpenResult>;
|
|
2426
|
+
static openExistingForRecoveryHydrationStrict(identity: ResumeSessionIdentity, destinationInput?: SessionDestinationInput, storage?: SessionStorage, ownership?: SessionOwnershipDecision): Promise<RecoveryHydrationOpenResult>;
|
|
2368
2427
|
/**
|
|
2369
2428
|
* Allows the normal post-open metadata sanitation only after the caller has
|
|
2370
2429
|
* fsynced its external ownership-ready fence and acquired the writer lease.
|
|
@@ -2375,13 +2434,14 @@ export declare class SessionManager {
|
|
|
2375
2434
|
* the returned discriminant; an error result never creates, rewrites, or adopts
|
|
2376
2435
|
* the selected path. Breadcrumb ownership begins only after `kind: "opened"`.
|
|
2377
2436
|
*/
|
|
2378
|
-
static openExistingStrict(identity: ResumeSessionIdentity, destinationInput?: SessionDestinationInput, storage?: SessionStorage, migrationPolicy?: SessionDirectoryMigrationPolicy, sessionMemoryMode?: SessionMemoryMode): Promise<StrictSessionOpenResult>;
|
|
2437
|
+
static openExistingStrict(identity: ResumeSessionIdentity, destinationInput?: SessionDestinationInput, storage?: SessionStorage, migrationPolicy?: SessionDirectoryMigrationPolicy, sessionMemoryMode?: SessionMemoryMode, ownership?: SessionOwnershipDecision): Promise<StrictSessionOpenResult>;
|
|
2379
2438
|
/**
|
|
2380
|
-
* Continue the most recent session, or create new if none.
|
|
2439
|
+
* Continue the most recent session, or create new if none. In enforce, throws `SessionHeldError`
|
|
2440
|
+
* when the session it would continue is open for writing in another process.
|
|
2381
2441
|
* @param cwd Working directory
|
|
2382
2442
|
* @param sessionDir Optional session directory. If omitted, uses default (~/.gjc/agent/sessions/<encoded-cwd>/).
|
|
2383
2443
|
*/
|
|
2384
|
-
static continueRecent(cwd: string, destinationInput?: SessionDestinationInput, storage?: SessionStorage, migrationPolicy?: SessionDirectoryMigrationPolicy, sessionMemoryMode?: SessionMemoryMode): Promise<SessionManager>;
|
|
2444
|
+
static continueRecent(cwd: string, destinationInput?: SessionDestinationInput, storage?: SessionStorage, migrationPolicy?: SessionDirectoryMigrationPolicy, sessionMemoryMode?: SessionMemoryMode, ownership?: SessionOwnershipDecision): Promise<SessionManager>;
|
|
2385
2445
|
/** Create an in-memory session (no file persistence) */
|
|
2386
2446
|
static inMemory(cwd?: string, storage?: SessionStorage): SessionManager;
|
|
2387
2447
|
/**
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who holds a session, and how that is said: holder types, the held-session error and its text.
|
|
3
|
+
*
|
|
4
|
+
* Import-free on purpose. Machine entrypoints (ACP, MCP, the `gjc sdk session` CLI) and the broker's
|
|
5
|
+
* lifecycle service name a holder in their errors, and must not reach the claim and lock machinery in
|
|
6
|
+
* `session-ownership.ts` to do it (`scripts/verify-gjc-sdk-canonicalization.ts`).
|
|
7
|
+
*/
|
|
8
|
+
/** A session id that may be quoted in text; any other id may hold any text. */
|
|
9
|
+
export declare const SAFE_SESSION_ID: RegExp;
|
|
10
|
+
/** A host name that may be shown; any other host reads as "another gjc process". */
|
|
11
|
+
export declare const SAFE_SESSION_HOST: RegExp;
|
|
12
|
+
export declare const SESSION_OWNER_SURFACES: readonly ["app", "terminal", "print", "sdk-host", "acp-host", "sdk"];
|
|
13
|
+
export type SessionOwnerBaseSurface = (typeof SESSION_OWNER_SURFACES)[number];
|
|
14
|
+
/** Where the holder runs; a subagent child carries its parent's surface plus ` (subagent)`. */
|
|
15
|
+
export type SessionOwnerSurface = SessionOwnerBaseSurface | `${SessionOwnerBaseSurface} (subagent)`;
|
|
16
|
+
/** A verified holder: its lock is held, and (on this host) its pid and incarnation match its record. */
|
|
17
|
+
export interface SessionOwnerHolder {
|
|
18
|
+
readonly surface: SessionOwnerSurface;
|
|
19
|
+
readonly pid: number;
|
|
20
|
+
/** Present only when the holder runs on another host, whose pid cannot be checked here. */
|
|
21
|
+
readonly host?: string;
|
|
22
|
+
readonly gjcVersion?: string;
|
|
23
|
+
readonly claimedAt?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function isSessionOwnerSurface(value: unknown): value is SessionOwnerSurface;
|
|
26
|
+
/** The holder as a remote client is told it, in a broker lifecycle error: surface and pid only. */
|
|
27
|
+
export interface SessionOwnerHolderSummary {
|
|
28
|
+
readonly surface: SessionOwnerSurface;
|
|
29
|
+
readonly pid: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* {@link SessionOwnerHolderSummary} of `holder`, checked field by field because it may come from
|
|
33
|
+
* a file another process wrote; `undefined` when it does not name a surface and a positive pid.
|
|
34
|
+
* A holder on another host keeps its surface and pid; its host name stays out.
|
|
35
|
+
*/
|
|
36
|
+
export declare function sessionOwnerHolderSummary(holder: unknown): SessionOwnerHolderSummary | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* How a holder is named to a person (design §3.4). The holder is checked again here, because a
|
|
39
|
+
* caller may build one: anything malformed reads as "another gjc process", never as raw text.
|
|
40
|
+
*/
|
|
41
|
+
export declare function sessionOwnerHolderPhrase(holder: SessionOwnerHolder | undefined): string;
|
|
42
|
+
/**
|
|
43
|
+
* The CLI command that continues a held session in a copy (design §3.3), for the CLI's refusals
|
|
44
|
+
* only: the SDK's `operatorMessage` names no command. `undefined` for an id that is not a safe file
|
|
45
|
+
* name, since any other id may hold any text.
|
|
46
|
+
*/
|
|
47
|
+
export declare function sessionHeldForkCommand(sessionId: string, options?: {
|
|
48
|
+
readonly print?: boolean;
|
|
49
|
+
/** The transcript path the session was named by, repeated so the command reads the same file. */
|
|
50
|
+
readonly source?: string;
|
|
51
|
+
/** The `--session-dir` the session was found in; an id resolves only there. */
|
|
52
|
+
readonly sessionDir?: string;
|
|
53
|
+
}): string | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* The terminal warning for a session another process holds (design §3.1; Fork and Cancel only, the
|
|
56
|
+
* read-only view and Take over are deferred). Fixed vocabulary, the holder's §3.4 phrase and a safe
|
|
57
|
+
* short id only: nothing a session or another process wrote reaches the screen.
|
|
58
|
+
*/
|
|
59
|
+
export declare function sessionHeldWarning(error: SessionHeldError): {
|
|
60
|
+
readonly heading: string;
|
|
61
|
+
readonly lines: string[];
|
|
62
|
+
};
|
|
63
|
+
/** What a launch or the TUI says after Fork (design §3.1). */
|
|
64
|
+
export declare function sessionHeldForkedNotice(error: SessionHeldError): string;
|
|
65
|
+
/** The short marker a session list shows on a row another process holds (design §1 row 2): `in terminal`. */
|
|
66
|
+
export declare function sessionOwnerHolderMarker(holder: SessionOwnerHolder | undefined): string;
|
|
67
|
+
/**
|
|
68
|
+
* A session another live process holds for writing. `message` is the stable machine code; the
|
|
69
|
+
* fixed, path-free `operatorMessage` is what a person sees.
|
|
70
|
+
*/
|
|
71
|
+
export declare class SessionHeldError extends Error {
|
|
72
|
+
readonly code = "session_held";
|
|
73
|
+
readonly sessionId: string;
|
|
74
|
+
readonly holder: SessionOwnerHolder | undefined;
|
|
75
|
+
readonly operatorMessage: string;
|
|
76
|
+
constructor(sessionId: string, holder?: SessionOwnerHolder);
|
|
77
|
+
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { type ProjectEnvSnapshot } from "@gajae-code/utils/env-file";
|
|
2
2
|
export declare const SESSION_OWNERSHIP_MODES: readonly ["off", "observe", "enforce"];
|
|
3
3
|
export type SessionOwnershipMode = (typeof SESSION_OWNERSHIP_MODES)[number];
|
|
4
|
+
/**
|
|
5
|
+
* The mode when the operator set none. It is the effective default: `Settings.getGlobal` returns no
|
|
6
|
+
* value for an unset key, so the resolver falls back to this, and the schema default only mirrors it
|
|
7
|
+
* for display (a test keeps the two equal).
|
|
8
|
+
*/
|
|
4
9
|
export declare const DEFAULT_SESSION_OWNERSHIP_MODE: SessionOwnershipMode;
|
|
5
10
|
export declare const SESSION_OWNERSHIP_ENV = "GJC_SESSION_OWNERSHIP";
|
|
6
11
|
/** Test-only seams shared by the ownership modules. Code, not environment, so a project `.env` cannot reach them. */
|
|
@@ -32,14 +37,52 @@ export declare function resolveSessionOwnershipMode(setting: unknown, override:
|
|
|
32
37
|
* snapshot could not be read in full.
|
|
33
38
|
*/
|
|
34
39
|
export declare function trustedSessionOwnershipOverride(env: NodeJS.ProcessEnv, snapshot: ProjectEnvSnapshot): string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Remove a project-supplied `GJC_SESSION_OWNERSHIP` from `env` before it reaches a child. A child in
|
|
42
|
+
* another directory (a `--tmux --worktree` launch runs `--no-env-file` there) checks provenance against
|
|
43
|
+
* that directory's `.env`, so it would trust this project's value. Called beside the `HERDR_BIN_PATH`
|
|
44
|
+
* drop, with the same startup snapshot.
|
|
45
|
+
*/
|
|
46
|
+
export declare function dropProjectSuppliedSessionOwnershipOverride(env: NodeJS.ProcessEnv, snapshot: ProjectEnvSnapshot): void;
|
|
35
47
|
/** Test-only: forget the cached override, so a test can change the environment. */
|
|
36
48
|
export declare function resetSessionOwnershipModeForTests(): void;
|
|
37
49
|
/** Test-only: whether this process has read `GJC_SESSION_OWNERSHIP` since the last reset. */
|
|
38
50
|
export declare function sessionOwnershipOverrideWasRead(): boolean;
|
|
39
|
-
/**
|
|
40
|
-
export
|
|
51
|
+
/** `fresh` asks for the value on disk now, past any cache, where the source has one. */
|
|
52
|
+
export type SessionOwnershipSettingSource = (options?: {
|
|
53
|
+
readonly fresh?: boolean;
|
|
54
|
+
}) => unknown;
|
|
55
|
+
/**
|
|
56
|
+
* Settings supplies the operator's global `session.ownership.mode` value: the process settings, or,
|
|
57
|
+
* before `Settings.init`, the agent directory's config file. Without a source the default applies.
|
|
58
|
+
*/
|
|
59
|
+
export declare function setSessionOwnershipSettingSource(source: SessionOwnershipSettingSource | undefined): void;
|
|
60
|
+
/**
|
|
61
|
+
* The mode as the operator has it now, for a refusal decision (5a). A refusal needs `enforce` both
|
|
62
|
+
* here and in the mode its factory read, so this can only lower a decision: `gjc config set
|
|
63
|
+
* session.ownership.mode off` reaches a running process's next refusal. It rereads the operator's
|
|
64
|
+
* config file. Only an explicit lower value lowers it: a file that names no mode, or cannot be read
|
|
65
|
+
* (the source then reports no value), leaves the factory's decision as it was, and so does the
|
|
66
|
+
* environment override unless it lowers.
|
|
67
|
+
*/
|
|
68
|
+
export declare function liveSessionOwnershipMode(): SessionOwnershipMode;
|
|
69
|
+
/**
|
|
70
|
+
* The mode for a decision a running process makes now: `processMode` (the mode its process or
|
|
71
|
+
* factory read), lowered by {@link liveSessionOwnershipMode}. Only an explicit lower value in the
|
|
72
|
+
* operator's config file (or a lowering environment override) lowers it, and nothing raises it, so
|
|
73
|
+
* `gjc config set session.ownership.mode off` reaches a running process's next decision.
|
|
74
|
+
*/
|
|
75
|
+
export declare function liveSessionOwnershipModeFor(processMode?: SessionOwnershipMode): SessionOwnershipMode;
|
|
41
76
|
/**
|
|
42
77
|
* The mode for this process now. With the setting `off` it returns before reading the environment,
|
|
43
78
|
* so `off` does no work beyond reading the setting.
|
|
44
79
|
*/
|
|
45
80
|
export declare function sessionOwnershipMode(): SessionOwnershipMode;
|
|
81
|
+
/**
|
|
82
|
+
* The mode for a `session.ownership.mode` value read from settings other than the global instance
|
|
83
|
+
* (a launch that opens its session before `Settings.init`, or a scoped load), with the same override.
|
|
84
|
+
* A missing or invalid value, as from settings that never loaded the operator's config file (an
|
|
85
|
+
* embedding's `Settings.isolated()`), falls back to the setting source, so the operator's `off` still
|
|
86
|
+
* applies. A valid explicit value wins.
|
|
87
|
+
*/
|
|
88
|
+
export declare function sessionOwnershipModeFor(setting: unknown): SessionOwnershipMode;
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
import { type FileLockAcquireResult, type FileLockProbeResult } from "@gajae-code/natives";
|
|
2
|
+
import { type SessionOwnerBaseSurface, type SessionOwnerHolder, type SessionOwnerSurface } from "./session-owner-holder";
|
|
2
3
|
import { type SessionOwnershipTestHookSlot } from "./session-ownership-mode";
|
|
3
|
-
export
|
|
4
|
-
export type SessionOwnerBaseSurface = (typeof SESSION_OWNER_SURFACES)[number];
|
|
5
|
-
/** Where the holder runs; a subagent child carries its parent's surface plus ` (subagent)`. */
|
|
6
|
-
export type SessionOwnerSurface = SessionOwnerBaseSurface | `${SessionOwnerBaseSurface} (subagent)`;
|
|
7
|
-
/** A verified holder: its lock is held, and (on this host) its pid and incarnation match its record. */
|
|
8
|
-
export interface SessionOwnerHolder {
|
|
9
|
-
readonly surface: SessionOwnerSurface;
|
|
10
|
-
readonly pid: number;
|
|
11
|
-
/** Present only when the holder runs on another host, whose pid cannot be checked here. */
|
|
12
|
-
readonly host?: string;
|
|
13
|
-
readonly gjcVersion?: string;
|
|
14
|
-
readonly claimedAt?: string;
|
|
15
|
-
}
|
|
4
|
+
export { SESSION_OWNER_SURFACES, SessionHeldError, type SessionOwnerBaseSurface, type SessionOwnerHolder, type SessionOwnerHolderSummary, type SessionOwnerSurface, sessionHeldForkCommand, sessionHeldForkedNotice, sessionHeldWarning, sessionOwnerHolderMarker, sessionOwnerHolderPhrase, sessionOwnerHolderSummary, } from "./session-owner-holder";
|
|
16
5
|
export type SessionOwnerUnknownReason = "unavailable" | "timed_out" | "failed";
|
|
17
6
|
export type SessionOwnerProbe = {
|
|
18
7
|
readonly state: "free";
|
|
@@ -76,6 +65,12 @@ export declare class SessionOwnershipError extends Error {
|
|
|
76
65
|
errno?: string;
|
|
77
66
|
});
|
|
78
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* The surface this process claims sessions as when a factory is not told one (design §1): the CLI
|
|
70
|
+
* sets it once at startup (`terminal`, `print`, `sdk-host`); an embedding keeps `sdk`.
|
|
71
|
+
*/
|
|
72
|
+
export declare function setSessionOwnerSurface(surface: SessionOwnerBaseSurface): void;
|
|
73
|
+
export declare function sessionOwnerSurface(): SessionOwnerBaseSurface;
|
|
79
74
|
/**
|
|
80
75
|
* The sidecar key for a session id: the id itself when it is a lower-case safe file name,
|
|
81
76
|
* otherwise `h-<hash>`. Ids with upper case are hashed so two ids differing only in case never
|
|
@@ -99,6 +94,8 @@ export declare const SESSION_OWNERSHIP_COUNTERS: readonly ["claim_taken", "claim
|
|
|
99
94
|
"claim_conflict",
|
|
100
95
|
/** A claim skipped by the narrow fail-open policy (design §2.7). */
|
|
101
96
|
"fail_open",
|
|
97
|
+
/** A claim that would refuse the session in enforce (an owners-directory failure), only logged before then. */
|
|
98
|
+
"claim_failed",
|
|
102
99
|
/** Locks this process still held when it exited: a missed release. */
|
|
103
100
|
"held_at_exit", "release_after_deferred_timeout", "session_write_without_claim",
|
|
104
101
|
/** Claims still in the claim set of a manager that was garbage-collected: a missed release. */
|
|
@@ -124,13 +121,28 @@ export declare function sessionOwnershipCounters(): Readonly<Record<SessionOwner
|
|
|
124
121
|
export declare function persistSessionOwnershipCounters(options?: {
|
|
125
122
|
readonly atExit?: boolean;
|
|
126
123
|
}): void;
|
|
124
|
+
/**
|
|
125
|
+
* `claim`, an opener's own claim of its session, has landed: release the admission claims that
|
|
126
|
+
* covered the open. `claim` is held, so the lock never lapses between them (design §2.5).
|
|
127
|
+
*/
|
|
128
|
+
export declare function releaseSessionAdmissions(claim: SessionOwnerClaim): void;
|
|
127
129
|
/**
|
|
128
130
|
* Claim `sessionId` for this process. A session this process already holds is shared (design D10).
|
|
129
131
|
* Throws `SessionOwnershipError` when the owners directory or the lock fails in a way that must
|
|
130
132
|
* refuse the session; only `unavailable` and `timed_out` fail open (design §2.7).
|
|
133
|
+
*
|
|
134
|
+
* `repeat` names the outcome the caller's previous attempt of this id had (a turn-start
|
|
135
|
+
* re-attempt): the same outcome again is neither counted nor logged again, so the counters count
|
|
136
|
+
* episodes, not turns.
|
|
137
|
+
*
|
|
138
|
+
* `admission` marks a cover an open or a switch takes before it reads the session: the opener's own
|
|
139
|
+
* claim releases it when it lands ({@link releaseSessionAdmissions}), so it is never a second holder
|
|
140
|
+
* once the session is open.
|
|
131
141
|
*/
|
|
132
142
|
export declare function claimSessionOwner(sessionId: string, request: {
|
|
133
143
|
readonly surface: SessionOwnerSurface;
|
|
144
|
+
readonly repeat?: "held" | "timed_out";
|
|
145
|
+
readonly admission?: boolean;
|
|
134
146
|
}): Promise<SessionOwnerClaimResult>;
|
|
135
147
|
/**
|
|
136
148
|
* Report, for each id, whether a live process holds it, without taking anything. Three-valued:
|
|
@@ -177,19 +189,3 @@ export interface SessionOwnersInventory {
|
|
|
177
189
|
export declare function inspectSessionOwners(options?: {
|
|
178
190
|
readonly keys?: readonly string[];
|
|
179
191
|
}): Promise<SessionOwnersInventory>;
|
|
180
|
-
/**
|
|
181
|
-
* How a holder is named to a person (design §3.4). The holder is checked again here, because a
|
|
182
|
-
* caller may build one: anything malformed reads as "another gjc process", never as raw text.
|
|
183
|
-
*/
|
|
184
|
-
export declare function sessionOwnerHolderPhrase(holder: SessionOwnerHolder | undefined): string;
|
|
185
|
-
/**
|
|
186
|
-
* A session another live process holds for writing. `message` is the stable machine code; the
|
|
187
|
-
* fixed, path-free `operatorMessage` is what a person sees.
|
|
188
|
-
*/
|
|
189
|
-
export declare class SessionHeldError extends Error {
|
|
190
|
-
readonly code = "session_held";
|
|
191
|
-
readonly sessionId: string;
|
|
192
|
-
readonly holder: SessionOwnerHolder | undefined;
|
|
193
|
-
readonly operatorMessage: string;
|
|
194
|
-
constructor(sessionId: string, holder?: SessionOwnerHolder);
|
|
195
|
-
}
|
|
@@ -9,6 +9,12 @@ export interface YieldDispatcher<P> {
|
|
|
9
9
|
* another origin (review thread P2).
|
|
10
10
|
*/
|
|
11
11
|
groupKey?(entry: P): string;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the entry may be delivered at a step boundary of a running turn
|
|
14
|
+
* (see {@link YieldQueue.drainStepBoundary}). Entries without this predicate,
|
|
15
|
+
* or for which it returns false, keep the before-yield and idle paths.
|
|
16
|
+
*/
|
|
17
|
+
deliverAtStepBoundary?(entry: P): boolean;
|
|
12
18
|
/** Produce one batched AgentMessage from non-stale entries. Return null to skip. */
|
|
13
19
|
build(survivors: P[]): AgentMessage | null;
|
|
14
20
|
}
|
|
@@ -43,6 +49,13 @@ export declare class YieldQueue {
|
|
|
43
49
|
enqueue<P>(kind: string, entry: P): void;
|
|
44
50
|
has(kind?: string): boolean;
|
|
45
51
|
flush(mode: YieldFlushMode, signal?: AbortSignal): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Drain and build every entry whose dispatcher allows step-boundary delivery,
|
|
54
|
+
* returning the messages for the running turn to consume directly. Ineligible
|
|
55
|
+
* entries stay queued in order for the before-yield or idle flush, so each
|
|
56
|
+
* entry is delivered by exactly one path.
|
|
57
|
+
*/
|
|
58
|
+
drainStepBoundary(): AgentMessage[];
|
|
46
59
|
clear(onDrop?: (kind: string, entries: readonly unknown[]) => void): void;
|
|
47
60
|
/** Drop only the queued entries of a single kind, leaving other kinds intact. */
|
|
48
61
|
clearKind(kind: string): void;
|
|
@@ -145,6 +145,13 @@ export declare class BashTool implements AgentTool<BashToolSchema, BashToolDetai
|
|
|
145
145
|
onRawLine?: (line: string, jobId: string) => void;
|
|
146
146
|
shouldAcceptRawLine?: (jobId: string) => boolean;
|
|
147
147
|
lifecycle?: import("../async").AsyncJobLifecycleCleanup;
|
|
148
|
+
/**
|
|
149
|
+
* Asked once when the command exits successfully. Returning true
|
|
150
|
+
* acknowledges the job's own completion delivery before the manager
|
|
151
|
+
* settles it, so no async-result is enqueued: the caller's stdout
|
|
152
|
+
* notifications already reported the run (#7993).
|
|
153
|
+
*/
|
|
154
|
+
shouldAcknowledgeCompletion?: () => boolean;
|
|
148
155
|
}): Promise<{
|
|
149
156
|
jobId: string;
|
|
150
157
|
label: string;
|
|
@@ -77,7 +77,30 @@ export interface LaunchHeadlessOptions {
|
|
|
77
77
|
locale?: string;
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
-
export
|
|
80
|
+
export interface LaunchHeadlessResult {
|
|
81
|
+
browser: Browser;
|
|
82
|
+
/**
|
|
83
|
+
* The userDataDir gjc created when profileWarmupDir was not provided.
|
|
84
|
+
* undefined if profileWarmupDir was used (caller-supplied dir).
|
|
85
|
+
* When set, gjc owns this dir and must remove it after Chrome exits.
|
|
86
|
+
*/
|
|
87
|
+
createdUserDataDir?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Attempt to remove a profile directory with bounded retry on transient EBUSY errors.
|
|
91
|
+
* Chrome may still hold files when launch fails or during disconnection, so retry
|
|
92
|
+
* with brief delays before giving up. Returns explicit result indicating success or failure.
|
|
93
|
+
*
|
|
94
|
+
* On EBUSY after exhausting retries, throws to signal to caller that deferral may be needed.
|
|
95
|
+
* On other errors after first attempt, logs but returns {removed: false, error}.
|
|
96
|
+
*/
|
|
97
|
+
export declare function cleanupProfileDirWithRetry(dir: string, maxRetries?: number, delay?: number): Promise<{
|
|
98
|
+
removed: true;
|
|
99
|
+
} | {
|
|
100
|
+
removed: false;
|
|
101
|
+
error: Error;
|
|
102
|
+
}>;
|
|
103
|
+
export declare function launchHeadlessBrowser(opts: LaunchHeadlessOptions): Promise<LaunchHeadlessResult>;
|
|
81
104
|
export declare function applyViewport(page: Page, viewport?: {
|
|
82
105
|
width: number;
|
|
83
106
|
height: number;
|
|
@@ -229,6 +229,8 @@ export interface ToolSession {
|
|
|
229
229
|
waitForFollowUpQueued?: (signal: AbortSignal) => Promise<void>;
|
|
230
230
|
/** Get session ID */
|
|
231
231
|
getSessionId?: () => string | null;
|
|
232
|
+
/** Changes only when a different session identity or transcript is adopted; a cwd move keeps it. */
|
|
233
|
+
getSessionIdentityGeneration?: () => number;
|
|
232
234
|
/**
|
|
233
235
|
* Opaque async-job ownership/lookup endpoint key. This is not a workflow or
|
|
234
236
|
* path identity: workflow/session consumers must use getSessionId(). Only
|
|
@@ -358,6 +360,8 @@ export interface ToolSession {
|
|
|
358
360
|
getSdkPermissionProvider?: () => ClientBridge["requestPermission"];
|
|
359
361
|
/** Bridge to the connected client (e.g. ACP editor host). Tools should route fs/terminal/permission requests through this when available. */
|
|
360
362
|
getClientBridge?: () => ClientBridge | undefined;
|
|
363
|
+
/** True once the owning session is disposed; background retries stop then. */
|
|
364
|
+
isSessionDisposed?: () => boolean;
|
|
361
365
|
/** Get compact conversation context for subagents (excludes tool results, system prompts) */
|
|
362
366
|
getCompactContext?: () => string;
|
|
363
367
|
/** Get cached todo phases for this session. */
|
|
@@ -413,6 +417,8 @@ export interface ToolSession {
|
|
|
413
417
|
sendCustomMessage?(message: Pick<CustomMessage, "customType" | "content" | "display" | "details" | "attribution">, options?: {
|
|
414
418
|
triggerTurn?: boolean;
|
|
415
419
|
deliverAs?: "steer" | "followUp" | "nextTurn";
|
|
420
|
+
/** Hidden next-turn provenance: "external" (background producer) survives a terminal abort. */
|
|
421
|
+
origin?: "turn" | "external";
|
|
416
422
|
}): Promise<void>;
|
|
417
423
|
/** Get the active OpenTelemetry config so subagent dispatch can forward
|
|
418
424
|
* the parent's tracer/hooks with the subagent's own identity stamped. */
|
|
@@ -118,6 +118,13 @@ export interface OutputMeta {
|
|
|
118
118
|
diagnostics?: DiagnosticMeta;
|
|
119
119
|
limits?: LimitsMeta;
|
|
120
120
|
eviction?: EvictedToolOutputHandle;
|
|
121
|
+
/**
|
|
122
|
+
* Which settings budget this output's inline excerpt when the result wrapper
|
|
123
|
+
* spills or caps it. Bash stamps `"bash"` on every result it builds, so tools
|
|
124
|
+
* that return a Bash result under their own name (`recipe`) inherit the Bash
|
|
125
|
+
* budgets; absent means the shared `tools.artifact*Bytes` budgets.
|
|
126
|
+
*/
|
|
127
|
+
retention?: "bash";
|
|
121
128
|
}
|
|
122
129
|
export interface TruncationOptions {
|
|
123
130
|
direction: "head" | "tail" | "middle";
|
|
@@ -191,6 +198,8 @@ export declare class OutputMetaBuilder {
|
|
|
191
198
|
sourceInternal(value: string): this;
|
|
192
199
|
/** Add LSP diagnostics. No-op if no messages. */
|
|
193
200
|
diagnostics(summary: string, messages: string[]): this;
|
|
201
|
+
/** Declare which settings budget this output's inline excerpt. */
|
|
202
|
+
retention(policy: "bash"): this;
|
|
194
203
|
/** Get the built OutputMeta, or undefined if empty. */
|
|
195
204
|
get(): OutputMeta | undefined;
|
|
196
205
|
}
|
|
@@ -234,19 +243,16 @@ export declare function stripOutputNotice(text: string, meta: OutputMeta | undef
|
|
|
234
243
|
* middle elision with the same per-user configuration.
|
|
235
244
|
*/
|
|
236
245
|
export declare function resolveOutputSinkHeadBytes(s: Settings | undefined): number;
|
|
237
|
-
export declare const BASH_DEFAULT_OUTPUT_TAIL_BYTES = 1024;
|
|
238
246
|
/**
|
|
239
|
-
* Bash
|
|
240
|
-
*
|
|
241
|
-
*
|
|
247
|
+
* Bash has its own retention budgets (`tools.bashOutputTailBytes`,
|
|
248
|
+
* `tools.bashOutputHeadBytes`) instead of the shared artifact spill keys: its
|
|
249
|
+
* default tail is deliberately small (1 KiB, no head) to nudge callers toward
|
|
250
|
+
* focused commands and dedicated search tools, while other tools keep the
|
|
251
|
+
* larger shared defaults. Keeping the keys separate means the value a user
|
|
252
|
+
* sees in settings is the value Bash applies.
|
|
242
253
|
*/
|
|
243
|
-
export declare function resolveBashOutputSinkTailBytes(s: Settings): number;
|
|
244
|
-
|
|
245
|
-
* Bash keeps only the tail unless the user explicitly opts into the shared
|
|
246
|
-
* head-retention setting. Schema defaults still apply to other streaming
|
|
247
|
-
* tools without silently turning Bash back into middle-elision mode.
|
|
248
|
-
*/
|
|
249
|
-
export declare function resolveBashOutputSinkHeadBytes(s: Settings): number;
|
|
254
|
+
export declare function resolveBashOutputSinkTailBytes(s: Settings | undefined): number;
|
|
255
|
+
export declare function resolveBashOutputSinkHeadBytes(s: Settings | undefined): number;
|
|
250
256
|
/**
|
|
251
257
|
* Resolve the per-line column cap from session settings. Shared by streaming
|
|
252
258
|
* executors (bash/python/ssh/eval via OutputSink) and the `read` tool's
|
|
@@ -30,6 +30,7 @@ export declare class ToolResultBuilder<TDetails extends DetailsWithMeta> {
|
|
|
30
30
|
sourcePath(value: string): this;
|
|
31
31
|
sourceInternal(value: string): this;
|
|
32
32
|
diagnostics(summary: string, messages: string[]): this;
|
|
33
|
+
retention(policy: "bash"): this;
|
|
33
34
|
done(): AgentToolResult<TDetails>;
|
|
34
35
|
}
|
|
35
36
|
export declare function toolResult<TDetails extends DetailsWithMeta>(details?: TDetails): ToolResultBuilder<TDetails>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@gajae-code/coding-agent",
|
|
4
|
-
"version": "0.22.
|
|
4
|
+
"version": "0.22.3",
|
|
5
5
|
"description": "Gajae Code CLI with read, bash, edit, write tools and session management",
|
|
6
6
|
"homepage": "https://gajae-code.com",
|
|
7
7
|
"author": "Yeachan-Heo and Gajae Code Contributors",
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
"@agentclientprotocol/sdk": "1.3.0",
|
|
58
58
|
"@babel/parser": "^7.29.3",
|
|
59
59
|
"@mozilla/readability": "^0.6.0",
|
|
60
|
-
"@gajae-code/stats": "0.22.
|
|
61
|
-
"@gajae-code/agent-core": "0.22.
|
|
62
|
-
"@gajae-code/ai": "0.22.
|
|
63
|
-
"@gajae-code/natives": "0.22.
|
|
64
|
-
"@gajae-code/tui": "0.22.
|
|
65
|
-
"@gajae-code/utils": "0.22.
|
|
60
|
+
"@gajae-code/stats": "0.22.3",
|
|
61
|
+
"@gajae-code/agent-core": "0.22.3",
|
|
62
|
+
"@gajae-code/ai": "0.22.3",
|
|
63
|
+
"@gajae-code/natives": "0.22.3",
|
|
64
|
+
"@gajae-code/tui": "0.22.3",
|
|
65
|
+
"@gajae-code/utils": "0.22.3",
|
|
66
66
|
"@puppeteer/browsers": "^2.13.0",
|
|
67
67
|
"@types/turndown": "5.0.6",
|
|
68
68
|
"@xterm/headless": "^6.0.0",
|
|
@@ -142,6 +142,8 @@
|
|
|
142
142
|
"./session/sdk-run-capability.js": null,
|
|
143
143
|
"./session/session-ownership": null,
|
|
144
144
|
"./session/session-ownership.js": null,
|
|
145
|
+
"./session/session-owner-holder": null,
|
|
146
|
+
"./session/session-owner-holder.js": null,
|
|
145
147
|
"./session/session-ownership-mode": null,
|
|
146
148
|
"./session/session-ownership-mode.js": null,
|
|
147
149
|
"./extensibility/extensions/function-hooks-internal": null,
|