@gajae-code/coding-agent 0.11.3 → 0.11.5
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 +47 -0
- package/dist/types/cli/notify-cli.d.ts +5 -1
- package/dist/types/cli/worktree-cli.d.ts +8 -25
- package/dist/types/commands/gc.d.ts +4 -0
- package/dist/types/commands/worktree.d.ts +7 -32
- package/dist/types/config/settings-schema.d.ts +20 -0
- package/dist/types/export/html/template.generated.d.ts +1 -1
- package/dist/types/gjc-runtime/deep-interview-state.d.ts +28 -0
- package/dist/types/gjc-runtime/gc-runtime.d.ts +9 -0
- package/dist/types/gjc-runtime/launch-tmux.d.ts +3 -0
- package/dist/types/gjc-runtime/managed-owner-admission.d.ts +42 -0
- package/dist/types/gjc-runtime/managed-owner-supervisor.d.ts +41 -0
- package/dist/types/gjc-runtime/state-argv.d.ts +38 -0
- package/dist/types/gjc-runtime/tmux-owner-isolation.d.ts +9 -0
- package/dist/types/gjc-runtime/ultragoal-owner-loss-recovery.d.ts +94 -0
- package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +1 -0
- package/dist/types/harness-control-plane/owner.d.ts +3 -1
- package/dist/types/internal-urls/local-protocol.d.ts +18 -0
- package/dist/types/main.d.ts +2 -2
- package/dist/types/modes/components/ansi-display-validator.d.ts +2 -0
- package/dist/types/modes/components/custom-editor.d.ts +8 -3
- package/dist/types/modes/components/notifications-settings-editor.d.ts +4 -0
- package/dist/types/modes/components/session-observer-overlay.d.ts +3 -1
- package/dist/types/modes/components/settings-selector.d.ts +2 -0
- package/dist/types/modes/components/tool-transcript-format.d.ts +77 -0
- package/dist/types/modes/components/transcript-viewer-overlay.d.ts +3 -0
- package/dist/types/modes/controllers/goal-mode-controller.d.ts +8 -1
- package/dist/types/modes/controllers/input-controller.d.ts +8 -2
- package/dist/types/modes/controllers/selector-controller.d.ts +15 -0
- package/dist/types/modes/shared/agent-wire/workflow-gate-broker.d.ts +3 -0
- package/dist/types/modes/shared/agent-wire/workflow-gate-types.d.ts +16 -0
- package/dist/types/plan-mode/approved-plan.d.ts +1 -0
- package/dist/types/runtime-mcp/manager.d.ts +2 -0
- package/dist/types/runtime-mcp/oauth-discovery.d.ts +12 -1
- package/dist/types/sdk/broker/broker.d.ts +1 -0
- package/dist/types/sdk/broker/discovery.d.ts +10 -0
- package/dist/types/sdk/broker/ensure.d.ts +24 -1
- package/dist/types/sdk/broker/internal.d.ts +3 -0
- package/dist/types/sdk/broker/session-index.d.ts +12 -0
- package/dist/types/sdk/broker/state-version.d.ts +2 -1
- package/dist/types/sdk/bus/chat-daemon-cli.d.ts +3 -1
- package/dist/types/sdk/bus/chat-daemon-control.d.ts +39 -4
- package/dist/types/sdk/bus/config-commands.d.ts +8 -0
- package/dist/types/sdk/bus/config.d.ts +22 -0
- package/dist/types/sdk/bus/index.d.ts +162 -2
- package/dist/types/sdk/bus/notification-service.d.ts +71 -8
- package/dist/types/sdk/bus/session-control.d.ts +11 -8
- package/dist/types/sdk/bus/telegram-daemon-cli.d.ts +5 -0
- package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +6 -3
- package/dist/types/sdk/bus/telegram-daemon-control.d.ts +23 -4
- package/dist/types/sdk/bus/telegram-daemon.d.ts +214 -20
- package/dist/types/sdk/session.d.ts +16 -1
- package/dist/types/secrets/index.d.ts +4 -2
- package/dist/types/secrets/obfuscator.d.ts +1 -1
- package/dist/types/session/agent-session.d.ts +31 -2
- package/dist/types/session/artifacts.d.ts +30 -8
- package/dist/types/session/internal/managed-session-scope.d.ts +7 -0
- package/dist/types/session/internal/managed-session-storage.d.ts +63 -6
- package/dist/types/session/session-manager.d.ts +88 -18
- package/dist/types/session/session-storage.d.ts +27 -0
- package/dist/types/session/streaming-output.d.ts +4 -0
- package/dist/types/task/executor.d.ts +9 -0
- package/dist/types/tool-discovery/tool-index.d.ts +2 -0
- package/dist/types/tools/ask.d.ts +87 -12
- package/dist/types/tools/bash-skill-urls.d.ts +2 -2
- package/dist/types/tools/browser/screenshot-format.d.ts +8 -0
- package/dist/types/tools/browser/tab-protocol.d.ts +11 -0
- package/dist/types/tools/browser/tab-supervisor.d.ts +1 -1
- package/dist/types/tools/browser/tab-worker-path-resolver.d.ts +2 -0
- package/dist/types/tools/browser/tab-worker-smoke.d.ts +16 -0
- package/dist/types/tools/index.d.ts +4 -0
- package/dist/types/tools/path-utils.d.ts +9 -14
- package/dist/types/tools/render-utils.d.ts +1 -8
- package/dist/types/tools/resource-gc.d.ts +14 -0
- package/dist/types/utils/image-loading.d.ts +23 -0
- package/dist/types/utils/image-resize.d.ts +2 -0
- package/dist/types/utils/pasted-image-loading.d.ts +39 -0
- package/dist/types/utils/pasted-image-path.d.ts +21 -19
- package/dist/types/web/scrapers/html-to-markdown.d.ts +5 -0
- package/dist/types/web/scrapers/types.d.ts +1 -5
- package/package.json +25 -9
- package/scripts/generate-sdk-operation-inventory.ts +2 -0
- package/scripts/run-threat-model-check.ts +60 -0
- package/src/cli/notify-cli.ts +40 -18
- package/src/cli/worktree-cli.ts +9 -287
- package/src/cli.ts +10 -9
- package/src/commands/gc.ts +11 -1
- package/src/commands/sdk.ts +10 -4
- package/src/commands/worktree.ts +10 -53
- package/src/config/model-profiles.ts +15 -15
- package/src/config/settings-schema.ts +17 -0
- package/src/daemon/runtime.ts +2 -2
- package/src/defaults/gjc/skills/deep-interview/SKILL.md +70 -49
- package/src/defaults/gjc/skills/ralplan/SKILL.md +0 -6
- package/src/defaults/gjc/skills/team/SKILL.md +7 -9
- package/src/defaults/gjc/skills/ultragoal/SKILL.md +0 -2
- package/src/eval/js/shared/runtime.ts +1 -1
- package/src/eval/py/index.ts +2 -2
- package/src/export/html/template.generated.ts +1 -1
- package/src/extensibility/plugins/marketplace/manager.ts +94 -10
- package/src/gjc-runtime/deep-interview-recorder.ts +7 -0
- package/src/gjc-runtime/deep-interview-runtime.ts +10 -0
- package/src/gjc-runtime/deep-interview-state.ts +127 -3
- package/src/gjc-runtime/gc-render.ts +19 -1
- package/src/gjc-runtime/gc-runtime.ts +68 -3
- package/src/gjc-runtime/launch-tmux.ts +61 -6
- package/src/gjc-runtime/managed-owner-admission.ts +352 -0
- package/src/gjc-runtime/managed-owner-supervisor.ts +162 -0
- package/src/gjc-runtime/state-argv.ts +292 -0
- package/src/gjc-runtime/state-runtime.ts +80 -222
- package/src/gjc-runtime/team-runtime.ts +1 -1
- package/src/gjc-runtime/tmux-owner-isolation.ts +117 -0
- package/src/gjc-runtime/ultragoal-owner-loss-recovery.ts +328 -0
- package/src/gjc-runtime/ultragoal-runtime.ts +14 -0
- package/src/harness-control-plane/owner.ts +59 -3
- package/src/hindsight/client.ts +65 -2
- package/src/internal-urls/agent-protocol.ts +76 -5
- package/src/internal-urls/docs-index.generated.ts +7 -6
- package/src/internal-urls/local-protocol.ts +416 -18
- package/src/lsp/index.ts +4 -88
- package/src/main.ts +37 -13
- package/src/modes/acp/acp-agent.ts +8 -0
- package/src/modes/components/ansi-display-validator.ts +54 -0
- package/src/modes/components/custom-editor.ts +103 -32
- package/src/modes/components/custom-provider-wizard.ts +26 -1
- package/src/modes/components/notifications-settings-editor.ts +26 -2
- package/src/modes/components/session-observer-overlay.ts +40 -37
- package/src/modes/components/settings-selector.ts +3 -1
- package/src/modes/components/tool-transcript-format.ts +393 -0
- package/src/modes/components/transcript-viewer-overlay.ts +63 -1
- package/src/modes/controllers/goal-mode-controller.ts +20 -1
- package/src/modes/controllers/input-controller.ts +98 -37
- package/src/modes/controllers/plan-mode-controller.ts +2 -0
- package/src/modes/controllers/runtime-mcp-command-controller.ts +3 -0
- package/src/modes/controllers/selector-controller.ts +71 -9
- package/src/modes/interactive-mode.ts +14 -2
- package/src/modes/shared/agent-wire/deep-interview-gate.ts +31 -1
- package/src/modes/shared/agent-wire/workflow-gate-broker.ts +17 -1
- package/src/modes/shared/agent-wire/workflow-gate-schema.ts +4 -2
- package/src/modes/shared/agent-wire/workflow-gate-types.ts +120 -3
- package/src/plan-mode/approved-plan.ts +3 -1
- package/src/prompts/agents/architect.md +1 -0
- package/src/prompts/agents/critic.md +1 -0
- package/src/prompts/system/custom-system-prompt.md +1 -1
- package/src/prompts/system/system-prompt.md +2 -1
- package/src/prompts/tools/lsp.md +3 -3
- package/src/runtime-mcp/manager.ts +16 -1
- package/src/runtime-mcp/oauth-discovery.ts +116 -26
- package/src/sdk/broker/broker.ts +139 -32
- package/src/sdk/broker/discovery.ts +125 -0
- package/src/sdk/broker/ensure.ts +103 -19
- package/src/sdk/broker/internal.ts +10 -0
- package/src/sdk/broker/session-index.ts +309 -38
- package/src/sdk/broker/state-version.ts +5 -2
- package/src/sdk/bus/chat-daemon-cli.ts +72 -10
- package/src/sdk/bus/chat-daemon-control.ts +526 -130
- package/src/sdk/bus/chat-daemon-runtime.ts +1 -0
- package/src/sdk/bus/config-commands.ts +22 -0
- package/src/sdk/bus/config.ts +37 -0
- package/src/sdk/bus/index.ts +384 -92
- package/src/sdk/bus/lifecycle-control-runtime.ts +53 -3
- package/src/sdk/bus/notification-service.ts +284 -62
- package/src/sdk/bus/recent-activity.ts +14 -5
- package/src/sdk/bus/session-control.ts +150 -44
- package/src/sdk/bus/telegram-daemon-cli.ts +20 -14
- package/src/sdk/bus/telegram-daemon-contract.ts +6 -3
- package/src/sdk/bus/telegram-daemon-control.ts +294 -76
- package/src/sdk/bus/telegram-daemon.ts +1842 -281
- package/src/sdk/protocol/operation-inventory.generated.json +11 -0
- package/src/sdk/session.ts +155 -27
- package/src/secrets/index.ts +53 -10
- package/src/secrets/obfuscator.ts +21 -18
- package/src/secrets/regex.ts +2 -0
- package/src/session/agent-session.ts +495 -253
- package/src/session/artifacts.ts +188 -23
- package/src/session/context-estimation.ts +7 -2
- package/src/session/internal/managed-session-scope.ts +215 -39
- package/src/session/internal/managed-session-storage.ts +1152 -46
- package/src/session/session-manager.ts +1055 -148
- package/src/session/session-storage.ts +109 -11
- package/src/session/streaming-output.ts +6 -0
- package/src/task/executor.ts +71 -26
- package/src/task/index.ts +63 -20
- package/src/tool-discovery/tool-index.ts +18 -0
- package/src/tools/ask.ts +329 -57
- package/src/tools/bash-allowed-prefixes.ts +79 -29
- package/src/tools/bash-skill-urls.ts +14 -3
- package/src/tools/bash.ts +2 -2
- package/src/tools/browser/launch.ts +3 -1
- package/src/tools/browser/readable.ts +1 -1
- package/src/tools/browser/screenshot-format.ts +34 -0
- package/src/tools/browser/tab-protocol.ts +3 -0
- package/src/tools/browser/tab-supervisor.ts +125 -122
- package/src/tools/browser/tab-worker-entry.ts +33 -14
- package/src/tools/browser/tab-worker-path-resolver.ts +67 -0
- package/src/tools/browser/tab-worker-smoke.ts +87 -0
- package/src/tools/browser/tab-worker.ts +7 -5
- package/src/tools/index.ts +4 -0
- package/src/tools/path-utils.ts +42 -35
- package/src/tools/plan-mode-guard.ts +1 -0
- package/src/tools/read.ts +7 -1
- package/src/tools/render-utils.ts +1 -27
- package/src/tools/resource-gc.ts +123 -34
- package/src/tools/sqlite-reader.ts +3 -2
- package/src/tools/subagent.ts +2 -0
- package/src/utils/image-loading.ts +85 -34
- package/src/utils/image-resize.ts +16 -9
- package/src/utils/pasted-image-loading.ts +514 -0
- package/src/utils/pasted-image-path.ts +223 -98
- package/src/web/scrapers/html-to-markdown.ts +68 -0
- package/src/web/scrapers/readthedocs.ts +1 -1
- package/src/web/scrapers/types.ts +1 -68
- package/src/web/search/providers/openai-compatible.ts +76 -23
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type SecretEntry, SecretObfuscator } from "./obfuscator";
|
|
2
|
+
/** Create an obfuscator using the process-local authenticated-placeholder key. */
|
|
3
|
+
export declare function createSecretObfuscator(entries: SecretEntry[]): SecretObfuscator;
|
|
2
4
|
export { deobfuscateSessionContext, obfuscateMessages, type SecretEntry, SecretObfuscator } from "./obfuscator";
|
|
3
5
|
/**
|
|
4
6
|
* Load secrets from project-local and global secrets.yml files.
|
|
5
|
-
* Project-local entries override global entries with matching content.
|
|
7
|
+
* Project-local plain entries override global entries with matching content.
|
|
6
8
|
*/
|
|
7
9
|
export declare function loadSecrets(cwd: string, agentDir: string): Promise<SecretEntry[]>;
|
|
8
10
|
/** Collect environment variable values that look like secrets. */
|
|
@@ -9,7 +9,7 @@ export interface SecretEntry {
|
|
|
9
9
|
}
|
|
10
10
|
export declare class SecretObfuscator {
|
|
11
11
|
#private;
|
|
12
|
-
constructor(entries: SecretEntry[]);
|
|
12
|
+
constructor(entries: SecretEntry[], key?: Uint8Array);
|
|
13
13
|
hasSecrets(): boolean;
|
|
14
14
|
/** Obfuscate all secrets in text. Bidirectional placeholders for obfuscate mode, one-way for replace. */
|
|
15
15
|
obfuscate(text: string): string;
|
|
@@ -101,7 +101,7 @@ export { DefaultModelSelectionRecoveryError } from "./default-model-selection";
|
|
|
101
101
|
import type { ClientBridge, ClientBridgePermissionOption, ClientBridgePermissionOutcome, ClientBridgePermissionToolCall } from "./client-bridge";
|
|
102
102
|
import { type ContributionPrepOptions, type ContributionPrepResult } from "./contribution-prep";
|
|
103
103
|
import { type CustomMessage } from "./messages";
|
|
104
|
-
import type { BranchSummaryEntry, CompactionEntry, NewSessionOptions, SessionContext, SessionManager, SessionManagerCloseOutcome } from "./session-manager";
|
|
104
|
+
import type { BranchSummaryEntry, CompactionEntry, NewSessionOptions, RecoveryHydrationContext, RecoveryHydrationPromotionFence, SessionContext, SessionManager, SessionManagerCloseOutcome } from "./session-manager";
|
|
105
105
|
import { ToolChoiceQueue } from "./tool-choice-queue";
|
|
106
106
|
import { YieldQueue } from "./yield-queue";
|
|
107
107
|
/** Session-specific events that extend the core AgentEvent */
|
|
@@ -250,12 +250,30 @@ export interface AgentSessionConfig {
|
|
|
250
250
|
discoveryMode?: "off" | "mcp-only" | "all";
|
|
251
251
|
/** MCP tool names to activate for the current session when discovery mode is enabled. */
|
|
252
252
|
initialSelectedMCPToolNames?: string[];
|
|
253
|
-
/**
|
|
253
|
+
/** Built-in discoverable tool names restored for the current all-discovery session. */
|
|
254
|
+
initialSelectedDiscoveredBuiltinToolNames?: string[];
|
|
255
|
+
/** Discoverable built-ins active for configured or explicit reasons independently of persisted discovery selection. */
|
|
256
|
+
initialBaselineDiscoveredBuiltinToolNames?: string[];
|
|
257
|
+
/** Whether an MCP selection was explicitly supplied to the constructor, including an empty selection. */
|
|
258
|
+
initialMCPToolSelectionIsExplicit?: boolean;
|
|
259
|
+
/** Whether a discoverable built-in selection was explicitly supplied to the constructor, including an empty selection. */
|
|
260
|
+
initialDiscoveredBuiltinToolSelectionIsExplicit?: boolean;
|
|
261
|
+
/** Whether constructor-provided MCP selections should be persisted immediately. */
|
|
254
262
|
persistInitialMCPToolSelection?: boolean;
|
|
263
|
+
/** Whether constructor-provided discovered-built-in selections should be persisted immediately. */
|
|
264
|
+
persistInitialDiscoveredBuiltinToolSelection?: boolean;
|
|
265
|
+
/** Explicit MCP authority to write for a new session; distinct from active fallback tools. */
|
|
266
|
+
initialPersistedMCPToolNames?: string[];
|
|
267
|
+
/** Explicit discovered built-in authority to write for a new session; distinct from active fallback tools. */
|
|
268
|
+
initialPersistedDiscoveredBuiltinToolNames?: string[];
|
|
269
|
+
/** Immutable predecessor authority while a recovery host is read-only. */
|
|
270
|
+
recoveryHydrationContext?: RecoveryHydrationContext;
|
|
255
271
|
/** MCP server names whose tools should seed discovery-mode sessions whenever those servers are connected. */
|
|
256
272
|
defaultSelectedMCPServerNames?: string[];
|
|
257
273
|
/** MCP tool names that should seed brand-new sessions created from this AgentSession. */
|
|
258
274
|
defaultSelectedMCPToolNames?: string[];
|
|
275
|
+
/** MCP capabilities that are always active and never part of persisted user selection. */
|
|
276
|
+
mandatoryMCPToolNames?: string[];
|
|
259
277
|
/** TTSR manager for time-traveling stream rules */
|
|
260
278
|
ttsrManager?: TtsrManager;
|
|
261
279
|
/** Secret obfuscator for deobfuscating streaming edit content */
|
|
@@ -472,6 +490,13 @@ export declare class AgentSession {
|
|
|
472
490
|
};
|
|
473
491
|
readonly rawSseDebugBuffer: RawSseDebugBuffer;
|
|
474
492
|
constructor(config: AgentSessionConfig);
|
|
493
|
+
/**
|
|
494
|
+
* Resolves when constructor-time workflow-gate tool restoration (ask
|
|
495
|
+
* registration plus durable active-workflow attachment) has settled. The
|
|
496
|
+
* SDK factory awaits this so a resumed canonical workflow session is
|
|
497
|
+
* returned with `ask` already resident.
|
|
498
|
+
*/
|
|
499
|
+
get workflowGateToolRestoration(): Promise<void>;
|
|
475
500
|
/** Model registry for API key resolution and model discovery */
|
|
476
501
|
get modelRegistry(): ModelRegistry;
|
|
477
502
|
/** Advance the tool-choice queue and return the next directive for the upcoming LLM call. */
|
|
@@ -704,6 +729,10 @@ export declare class AgentSession {
|
|
|
704
729
|
/** All messages including custom types like BashExecutionMessage */
|
|
705
730
|
get messages(): AgentMessage[];
|
|
706
731
|
get transcriptPromptGeneration(): number;
|
|
732
|
+
/** The immutable recovery authority, present only before external ownership promotion. */
|
|
733
|
+
get recoveryHydrationContext(): RecoveryHydrationContext | undefined;
|
|
734
|
+
/** Enables normal session mutations after the owner has published its durable fence and writer lease. */
|
|
735
|
+
promoteRecoveryHydrationAfterOwnershipReadyFence(fence: RecoveryHydrationPromotionFence): Promise<void>;
|
|
707
736
|
/** Main startup calls this exactly once, after a strict open returned `kind: "opened"`. */
|
|
708
737
|
continuePersistedHistory(): Promise<void>;
|
|
709
738
|
buildDisplaySessionContext(): SessionContext;
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session-scoped artifact storage for truncated tool outputs.
|
|
3
|
+
*
|
|
4
|
+
* Artifacts are stored in a directory alongside the session file,
|
|
5
|
+
* accessible via artifact:// URLs.
|
|
6
|
+
*/
|
|
7
|
+
import { type ManagedSessionDescendantStore } from "./internal/managed-session-storage";
|
|
8
|
+
export interface ManagedOutputGeneration {
|
|
9
|
+
outputFilename: string;
|
|
10
|
+
metadataFilename: string;
|
|
11
|
+
outputSizeBytes: number;
|
|
12
|
+
outputSha256: string;
|
|
13
|
+
metadataSizeBytes: number;
|
|
14
|
+
metadataSha256: string;
|
|
15
|
+
}
|
|
1
16
|
export interface ArtifactSaveOptions {
|
|
2
17
|
maxBytes?: number;
|
|
3
18
|
}
|
|
@@ -16,32 +31,39 @@ export declare class ArtifactManager {
|
|
|
16
31
|
/**
|
|
17
32
|
* @param dir Directory that will hold artifact files. Created lazily on first save.
|
|
18
33
|
*/
|
|
19
|
-
constructor(
|
|
34
|
+
constructor(target: string | ManagedSessionDescendantStore);
|
|
20
35
|
/**
|
|
21
36
|
* Artifact directory path.
|
|
22
37
|
* Directory may not exist until first artifact is saved.
|
|
23
38
|
*/
|
|
24
39
|
get dir(): string;
|
|
40
|
+
getManagedRootAuthority(): import("./internal/managed-session-storage").ManagedDirectoryRoot | undefined;
|
|
41
|
+
getManagedSubtreeRootAuthority(): import("./internal/managed-session-storage").ManagedDirectoryRoot | undefined;
|
|
42
|
+
getManagedStore(): ManagedSessionDescendantStore | undefined;
|
|
43
|
+
assertManagedBinding(): void;
|
|
44
|
+
replaceNamed(filename: string, content: string): Promise<void>;
|
|
45
|
+
replaceNamedBytes(filename: string, bytes: Uint8Array): Promise<void>;
|
|
46
|
+
publishManagedOutputGeneration(selectorFilename: string, outputFilenamePrefix: string, outputBytes: Uint8Array, metadataBytes: Uint8Array): Promise<void>;
|
|
47
|
+
publishNamedNoReplace(filename: string, bytes: Uint8Array): Promise<void>;
|
|
25
48
|
/**
|
|
26
49
|
* Atomically allocate next artifact ID.
|
|
27
50
|
* IDs are sequential within the session.
|
|
28
51
|
*/
|
|
29
52
|
allocateId(): number;
|
|
30
53
|
/**
|
|
31
|
-
*
|
|
54
|
+
* Reserve an artifact ID without exposing a writable managed pathname.
|
|
32
55
|
*
|
|
33
|
-
*
|
|
56
|
+
* Streaming callers that only understand bare paths fail closed; use `save`
|
|
57
|
+
* for terminally published artifact content.
|
|
34
58
|
*/
|
|
35
59
|
allocatePath(toolType: string): Promise<{
|
|
36
60
|
id: string;
|
|
37
|
-
path
|
|
61
|
+
path?: string;
|
|
38
62
|
}>;
|
|
39
63
|
/**
|
|
40
64
|
* Save content as an artifact and return the artifact ID.
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* @param toolType Tool name for file extension (e.g., "bash", "read")
|
|
44
|
-
* @returns Artifact ID (numeric string)
|
|
65
|
+
* Content is written to a private temporary inode, synced, and linked into
|
|
66
|
+
* the artifact directory only after the complete terminal payload exists.
|
|
45
67
|
*/
|
|
46
68
|
save(content: string, toolType: string, options?: ArtifactSaveOptions): Promise<string>;
|
|
47
69
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as native from "@gajae-code/natives";
|
|
1
2
|
import type { ResumeSessionIdentity } from "../session-manager";
|
|
2
3
|
export declare const MANAGED_SESSION_LAYOUT_VERSION: 2;
|
|
3
4
|
export declare const MANAGED_SESSION_IDENTITY_VERSION: 1;
|
|
@@ -14,6 +15,12 @@ export interface ManagedScope {
|
|
|
14
15
|
directoryPath: string;
|
|
15
16
|
platform: "posix" | "win32";
|
|
16
17
|
}
|
|
18
|
+
export declare function managedDirectoryAuthorityForScope(scope: ManagedScope): native.RecoveryFsRoot | undefined;
|
|
19
|
+
export declare function managedDirectoryIdentityForScope(scope: ManagedScope): {
|
|
20
|
+
dev: bigint;
|
|
21
|
+
ino: bigint;
|
|
22
|
+
};
|
|
23
|
+
export declare function managedRootForScope(scope: ManagedScope): import("./managed-session-storage").ManagedDirectoryRoot;
|
|
17
24
|
export type ManagedMigrationPolicy = "copy-retain" | "disabled";
|
|
18
25
|
export type ManagedScopeErrorCode = "cwd_missing" | "cwd_not_directory" | "identity_unavailable" | "network_unsupported" | "sessions_root_unavailable" | "binding_conflict" | "binding_invalid";
|
|
19
26
|
export type ManagedScopeResolution = {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type NativeDirectoryTreeSnapshot, type NativeOwnerOnlySecurityResult, type RecoveryFsRoot } from "@gajae-code/natives";
|
|
1
2
|
export declare const MANAGED_ARTIFACT_MAX_DEPTH = 32;
|
|
2
3
|
export declare const MANAGED_ARTIFACT_MAX_FILES = 10000;
|
|
3
4
|
export declare const MANAGED_ARTIFACT_MAX_FILE_BYTES: number;
|
|
@@ -16,23 +17,79 @@ export interface ManagedFileSnapshot {
|
|
|
16
17
|
ino: bigint;
|
|
17
18
|
size: number;
|
|
18
19
|
mtimeNs: bigint;
|
|
20
|
+
ctimeNs: bigint;
|
|
21
|
+
sha256: string;
|
|
19
22
|
};
|
|
20
23
|
}
|
|
24
|
+
export declare function validateNativeSecurityResult(value: unknown, operation: "apply" | "verify", kind: "directory" | "file"): NativeOwnerOnlySecurityResult;
|
|
25
|
+
/** Captured configured-root authority for managed paths only. */
|
|
26
|
+
export interface ManagedDirectoryRoot {
|
|
27
|
+
readonly canonicalPath: string;
|
|
28
|
+
readonly dev: bigint;
|
|
29
|
+
readonly ino: bigint;
|
|
30
|
+
}
|
|
31
|
+
export declare function managedDirectoryRoot(configuredRoot: string): ManagedDirectoryRoot;
|
|
32
|
+
export declare function retainManagedDirectoryAuthority(root: ManagedDirectoryRoot, directory: string, expected?: {
|
|
33
|
+
dev: bigint;
|
|
34
|
+
ino: bigint;
|
|
35
|
+
}): RecoveryFsRoot | undefined;
|
|
36
|
+
export declare function assertManagedDirectoryRoot(root: ManagedDirectoryRoot): void;
|
|
37
|
+
/** Internal retained-root capability for one managed descendant subtree. */
|
|
38
|
+
export declare class ManagedSessionDescendantStore {
|
|
39
|
+
#private;
|
|
40
|
+
constructor(root: ManagedDirectoryRoot, baseDir: string, retained?: {
|
|
41
|
+
authority: RecoveryFsRoot;
|
|
42
|
+
authorityBaseDir: string;
|
|
43
|
+
});
|
|
44
|
+
get dir(): string;
|
|
45
|
+
get rootAuthority(): ManagedDirectoryRoot;
|
|
46
|
+
get subtreeRootAuthority(): ManagedDirectoryRoot;
|
|
47
|
+
deriveSubtree(relativePath: string): ManagedSessionDescendantStore;
|
|
48
|
+
retainAuthority(): RecoveryFsRoot | undefined;
|
|
49
|
+
assertBound(): void;
|
|
50
|
+
verifyRootSecurity(): void;
|
|
51
|
+
ensureDirectory(relativePath?: string): ManagedDirectoryRoot;
|
|
52
|
+
publishNoReplace(relativePath: string, bytes: Uint8Array): Promise<void>;
|
|
53
|
+
publishNoReplaceSync(relativePath: string, bytes: Uint8Array): void;
|
|
54
|
+
replace(relativePath: string, bytes: Uint8Array): Promise<void>;
|
|
55
|
+
replaceSync(relativePath: string, bytes: Uint8Array): void;
|
|
56
|
+
appendSync(relativePath: string, bytes: Uint8Array): void;
|
|
57
|
+
/** Read an exact managed file without exposing its pathname as authority. */
|
|
58
|
+
readExpected(relativePath: string): ManagedFileSnapshot | null;
|
|
59
|
+
/** Remove an exact captured file without reopening its pathname as authority. */
|
|
60
|
+
removeExpected(relativePath: string, expected: ManagedFileSnapshot): void;
|
|
61
|
+
/** Read and remove one managed descendant through retained authority. */
|
|
62
|
+
consume(relativePath: string): Promise<Uint8Array | null>;
|
|
63
|
+
/** Remove one managed descendant through retained authority when it exists. */
|
|
64
|
+
remove(relativePath: string): Promise<void>;
|
|
65
|
+
/** Capture a complete descendant tree through this retained root. */
|
|
66
|
+
captureTree(relativePath: string): NativeDirectoryTreeSnapshot;
|
|
67
|
+
/** Copy an exact captured tree into an absent managed destination. */
|
|
68
|
+
importTree(sourceRelativePath: string, destinationRelativePath: string, snapshot: NativeDirectoryTreeSnapshot): Promise<void>;
|
|
69
|
+
moveTreeNoReplace(sourceRelativePath: string, destinationRelativePath: string, expected: NativeDirectoryTreeSnapshot): void;
|
|
70
|
+
removeTreeExpected(relativePath: string, expected: NativeDirectoryTreeSnapshot): void;
|
|
71
|
+
fsyncTree(): NativeDirectoryTreeSnapshot;
|
|
72
|
+
}
|
|
21
73
|
export declare function shouldFsyncManagedDirectory(platform?: NodeJS.Platform): boolean;
|
|
22
74
|
/** Create a managed directory and fail closed unless its owner-only mode/ACL verifies. */
|
|
23
|
-
export declare function ensureManagedDirectory(pathname: string): void;
|
|
75
|
+
export declare function ensureManagedDirectory(pathname: string, root?: ManagedDirectoryRoot): void;
|
|
76
|
+
/** Captures a bounded prefix from one no-follow descriptor and rechecks the pathname before use. */
|
|
77
|
+
export declare function captureManagedFilePrefixNoFollow(pathname: string, maxBytes: number): ManagedFileSnapshot;
|
|
24
78
|
/** Captures header/hash/copy input from one no-follow descriptor and rechecks the pathname before use. */
|
|
25
79
|
export declare function captureManagedFileNoFollow(pathname: string): ManagedFileSnapshot;
|
|
26
80
|
/** Atomically publishes bytes without replacing an existing destination. */
|
|
27
|
-
export declare function publishManagedFileNoReplace(destination: string, bytes: Uint8Array, assertOwned?: () => void): Promise<void>;
|
|
28
|
-
export declare function publishManagedFileNoReplaceSync(destination: string, bytes: Uint8Array): void;
|
|
81
|
+
export declare function publishManagedFileNoReplace(destination: string, bytes: Uint8Array, assertOwned?: () => void, root?: ManagedDirectoryRoot): Promise<void>;
|
|
82
|
+
export declare function publishManagedFileNoReplaceSync(destination: string, bytes: Uint8Array, root?: ManagedDirectoryRoot): void;
|
|
83
|
+
/** Replace one managed regular file while retaining the secured staging fd through publication. */
|
|
84
|
+
export declare function replaceManagedFileSync(destination: string, bytes: Uint8Array, root: ManagedDirectoryRoot): void;
|
|
85
|
+
export declare function replaceManagedFile(destination: string, bytes: Uint8Array, root: ManagedDirectoryRoot): Promise<void>;
|
|
29
86
|
/** Copy the exact bytes captured from one no-follow source descriptor. */
|
|
30
|
-
export declare function copyManagedFileNoReplace(source: string, destination: string, snapshot?: ManagedFileSnapshot): Promise<void>;
|
|
87
|
+
export declare function copyManagedFileNoReplace(source: string, destination: string, snapshot?: ManagedFileSnapshot, root?: ManagedDirectoryRoot): Promise<void>;
|
|
31
88
|
/** Acquire a lease lock with bounded wait, heartbeats, conservative stale reclaim, and fencing. */
|
|
32
|
-
export declare function acquireManagedLock(locksDirectory: string, name: string): Promise<ManagedStorageLock>;
|
|
89
|
+
export declare function acquireManagedLock(locksDirectory: string, name: string, root?: ManagedDirectoryRoot): Promise<ManagedStorageLock>;
|
|
33
90
|
/** Bounds a no-follow artifact tree before it can be copied or deleted. */
|
|
34
91
|
export declare function validateManagedArtifactTree(root: string): void;
|
|
35
92
|
/** Flush a copied managed artifact tree, including empty directories, before publishing its receipt. */
|
|
36
|
-
export declare function fsyncManagedArtifactTree(root: string):
|
|
93
|
+
export declare function fsyncManagedArtifactTree(root: string): NativeDirectoryTreeSnapshot;
|
|
37
94
|
export declare function publishManagedTombstone(destination: string, record: Record<string, unknown>, assertOwned?: () => void): Promise<void>;
|
|
38
95
|
export declare function unlinkManagedFileVerified(pathname: string, expected: ManagedFileSnapshot["identity"]): Promise<void>;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { type AgentMessage } from "@gajae-code/agent-core";
|
|
2
2
|
import type { ConfiguredModelChainEntry as SharedConfiguredModelChainEntry } from "@gajae-code/agent-core/compaction";
|
|
3
3
|
import type { ImageContent, Message, MessageAttribution, ServiceTier, TextContent } from "@gajae-code/ai";
|
|
4
|
+
import * as native from "@gajae-code/natives";
|
|
4
5
|
import type { TtsrInjectionRecord } from "../export/ttsr";
|
|
6
|
+
import type { ManagedLegacyLocalMigrationSource } from "../internal-urls/local-protocol";
|
|
5
7
|
import { ArtifactManager } from "./artifacts";
|
|
6
8
|
import { type BlobPutResult, BlobStore } from "./blob-store";
|
|
7
9
|
import { type ManagedMigrationPolicy } from "./internal/managed-session-scope";
|
|
10
|
+
import { type ManagedDirectoryRoot, ManagedSessionDescendantStore } from "./internal/managed-session-storage";
|
|
8
11
|
import { type BashExecutionMessage, type CustomMessage, type FileMentionMessage, type HookMessage, type PythonExecutionMessage } from "./messages";
|
|
9
12
|
import { type SessionManagerReadAccess, sessionManagerReadCapability } from "./session-manager-internal";
|
|
10
|
-
import type { SessionStorage, SessionStorageStat, VerifiedSessionDeleteResult, VerifiedSessionDeleteTarget } from "./session-storage";
|
|
11
|
-
export declare const CURRENT_SESSION_VERSION =
|
|
13
|
+
import type { ManagedSessionSecurityContext, SessionStorage, SessionStorageStat, VerifiedSessionDeleteResult, VerifiedSessionDeleteTarget } from "./session-storage";
|
|
14
|
+
export declare const CURRENT_SESSION_VERSION = 5;
|
|
12
15
|
export interface SessionHeader {
|
|
13
16
|
type: "session";
|
|
14
17
|
version?: number;
|
|
@@ -167,6 +170,17 @@ export interface MCPToolSelectionEntry extends SessionEntryBase {
|
|
|
167
170
|
type: "mcp_tool_selection";
|
|
168
171
|
/** MCP tool names selected for visibility in discovery mode. */
|
|
169
172
|
selectedToolNames: string[];
|
|
173
|
+
/** Legacy v4 combined built-in authority, retained for read compatibility. */
|
|
174
|
+
selectedDiscoveredBuiltinToolNames?: string[];
|
|
175
|
+
/** Correlates the ordered MCP and built-in entries emitted by one combined activation. */
|
|
176
|
+
mutationCorrelationId?: string;
|
|
177
|
+
}
|
|
178
|
+
/** Persisted discovered-built-in selection state, independent of MCP authority. */
|
|
179
|
+
export interface DiscoveredBuiltinToolSelectionEntry extends SessionEntryBase {
|
|
180
|
+
type: "discovered_builtin_tool_selection";
|
|
181
|
+
selectedToolNames: string[];
|
|
182
|
+
/** Correlates the ordered MCP and built-in entries emitted by one combined activation. */
|
|
183
|
+
mutationCorrelationId?: string;
|
|
170
184
|
}
|
|
171
185
|
/** Session init entry - captures initial context for subagent sessions (debugging/replay). */
|
|
172
186
|
export interface SessionInitEntry extends SessionEntryBase {
|
|
@@ -214,7 +228,7 @@ export interface CustomMessageEntry<T = unknown> extends SessionEntryBase {
|
|
|
214
228
|
evictedContent?: EvictedContentMarker;
|
|
215
229
|
}
|
|
216
230
|
/** Session entry - has id/parentId for tree structure (returned by "read" methods in SessionManager) */
|
|
217
|
-
export type SessionEntry = SessionMessageEntry | ThinkingLevelChangeEntry | ModelChangeEntry | ServiceTierChangeEntry | CompactionEntry | BranchSummaryEntry | CustomEntry | CustomMessageEntry | LabelEntry | TtsrInjectionEntry | MCPToolSelectionEntry | SessionInitEntry | ModeChangeEntry | ConfiguredModelChainEntry;
|
|
231
|
+
export type SessionEntry = SessionMessageEntry | ThinkingLevelChangeEntry | ModelChangeEntry | ServiceTierChangeEntry | CompactionEntry | BranchSummaryEntry | CustomEntry | CustomMessageEntry | LabelEntry | TtsrInjectionEntry | MCPToolSelectionEntry | DiscoveredBuiltinToolSelectionEntry | SessionInitEntry | ModeChangeEntry | ConfiguredModelChainEntry;
|
|
218
232
|
/** Append-only replacement for mutable fields on the session header. */
|
|
219
233
|
export interface HeaderPatchRecord {
|
|
220
234
|
type: "header_patch";
|
|
@@ -270,8 +284,12 @@ export interface SessionContext {
|
|
|
270
284
|
ttsrMessageCount?: number;
|
|
271
285
|
/** MCP tool names selected through discovery for this session branch. */
|
|
272
286
|
selectedMCPToolNames: string[];
|
|
287
|
+
/** Built-in discoverable tool names activated through discovery, when explicitly persisted. */
|
|
288
|
+
selectedDiscoveredBuiltinToolNames?: string[];
|
|
273
289
|
/** Whether this branch contains an explicit persisted MCP selection entry. */
|
|
274
290
|
hasPersistedMCPToolSelection: boolean;
|
|
291
|
+
/** Whether this branch contains an explicit persisted discovered-built-in selection entry. */
|
|
292
|
+
hasPersistedDiscoveredBuiltinToolSelection?: boolean;
|
|
275
293
|
/** Active mode (e.g. "plan") or "none" if no special mode is active */
|
|
276
294
|
mode: string;
|
|
277
295
|
/** Mode-specific data from the last mode_change entry */
|
|
@@ -316,7 +334,7 @@ export interface StrictSessionOpenSuccess {
|
|
|
316
334
|
}
|
|
317
335
|
export interface StrictSessionOpenFailure {
|
|
318
336
|
kind: "error";
|
|
319
|
-
reason: ResumeTailError["reason"] | "identity-mismatch";
|
|
337
|
+
reason: ResumeTailError["reason"] | "identity-mismatch" | "migration-required";
|
|
320
338
|
}
|
|
321
339
|
/** Exact transcript bytes and authority captured from one descriptor-bound read. */
|
|
322
340
|
export interface CapturedSessionTranscriptSnapshot {
|
|
@@ -335,6 +353,23 @@ export type StrictSessionForkResult = {
|
|
|
335
353
|
} | StrictSessionOpenFailure;
|
|
336
354
|
/** Result of opening an inspected session without create-or-rewrite fallback. */
|
|
337
355
|
export type StrictSessionOpenResult = StrictSessionOpenSuccess | StrictSessionOpenFailure;
|
|
356
|
+
/**
|
|
357
|
+
* Capability returned only by a strict recovery hydration open. It represents
|
|
358
|
+
* immutable transcript authority and is consumed by the promotion seam.
|
|
359
|
+
*/
|
|
360
|
+
export interface RecoveryHydrationContext {
|
|
361
|
+
readonly identity: ResumeSessionIdentity;
|
|
362
|
+
}
|
|
363
|
+
export interface RecoveryHydrationOpenSuccess {
|
|
364
|
+
readonly kind: "hydrated";
|
|
365
|
+
readonly manager: SessionManager;
|
|
366
|
+
readonly context: RecoveryHydrationContext;
|
|
367
|
+
}
|
|
368
|
+
export type RecoveryHydrationOpenResult = RecoveryHydrationOpenSuccess | StrictSessionOpenFailure;
|
|
369
|
+
export interface RecoveryHydrationPromotionFence {
|
|
370
|
+
/** The caller has durably published ownership and acquired its writer lease. */
|
|
371
|
+
readonly ownershipReady: true;
|
|
372
|
+
}
|
|
338
373
|
export interface SessionInfo {
|
|
339
374
|
path: string;
|
|
340
375
|
id: string;
|
|
@@ -434,6 +469,22 @@ export declare function getLatestCompactionEntry(entries: SessionEntry[]): Compa
|
|
|
434
469
|
* Handles compaction and branch summaries along the path.
|
|
435
470
|
*/
|
|
436
471
|
export declare function buildSessionContext(entries: SessionEntry[], leafId?: string | null, byId?: Map<string, SessionEntry>, sessionIdentityNamespace?: string): SessionContext;
|
|
472
|
+
/** A session directory's authority is distinct from its string path. */
|
|
473
|
+
export type SessionDestination = {
|
|
474
|
+
readonly kind: "managed";
|
|
475
|
+
readonly directory: string;
|
|
476
|
+
readonly securityContext: ManagedSessionSecurityContext;
|
|
477
|
+
} | {
|
|
478
|
+
readonly kind: "explicit";
|
|
479
|
+
readonly directory: string;
|
|
480
|
+
};
|
|
481
|
+
export type SessionDestinationInput = string | SessionDestination | undefined;
|
|
482
|
+
interface ForkArtifactPublication {
|
|
483
|
+
readonly snapshot: native.NativeDirectoryTreeSnapshot;
|
|
484
|
+
readonly store: ManagedSessionDescendantStore;
|
|
485
|
+
readonly cleanupStore: ManagedSessionDescendantStore;
|
|
486
|
+
readonly cleanupRelativePath: string;
|
|
487
|
+
}
|
|
437
488
|
/** Exported for testing */
|
|
438
489
|
export declare function loadEntriesFromFile(filePath: string, storage?: SessionStorage): Promise<FileEntry[]>;
|
|
439
490
|
declare class RecentSessionInfo {
|
|
@@ -520,6 +571,7 @@ export declare class SessionManager {
|
|
|
520
571
|
private sessionDir;
|
|
521
572
|
private readonly persist;
|
|
522
573
|
private readonly storage;
|
|
574
|
+
private destination;
|
|
523
575
|
private constructor();
|
|
524
576
|
/**
|
|
525
577
|
* Snapshot of the five cache-invalidation revision domains (plan: Lane 1
|
|
@@ -552,6 +604,7 @@ export declare class SessionManager {
|
|
|
552
604
|
oldSessionFile: string;
|
|
553
605
|
newSessionFile: string;
|
|
554
606
|
} | undefined>;
|
|
607
|
+
copyArtifactsForFork(oldSessionFile: string, newSessionFile: string): Promise<ForkArtifactPublication | undefined>;
|
|
555
608
|
/**
|
|
556
609
|
* Move the session to a new working directory.
|
|
557
610
|
* Moves session files and artifacts on disk, updates all internal references,
|
|
@@ -592,10 +645,13 @@ export declare class SessionManager {
|
|
|
592
645
|
* Returns the session artifacts directory path (session file path without .jsonl).
|
|
593
646
|
* Returns null when the session is not persisted to a file.
|
|
594
647
|
* When this session has adopted an external ArtifactManager (subagent case),
|
|
595
|
-
*
|
|
596
|
-
*
|
|
648
|
+
* never exposes that managed directory as a pathname. Reads and writes use the
|
|
649
|
+
* adopted manager capability directly.
|
|
597
650
|
*/
|
|
598
651
|
getArtifactsDir(): string | null;
|
|
652
|
+
isManagedDestination(): boolean;
|
|
653
|
+
/** Supplies opaque retained authority for mandatory managed legacy local migration. */
|
|
654
|
+
getManagedLegacyLocalMigrationSource(): ManagedLegacyLocalMigrationSource | null;
|
|
599
655
|
/**
|
|
600
656
|
* Adopt an externally-owned ArtifactManager. Used by subagents to share
|
|
601
657
|
* the parent session's artifact directory and ID counter.
|
|
@@ -716,12 +772,10 @@ export declare class SessionManager {
|
|
|
716
772
|
* @returns Entry id
|
|
717
773
|
*/
|
|
718
774
|
appendCustomMessageEntry<T = unknown>(customType: string, content: string | (TextContent | ImageContent)[], display: boolean, details?: T, attribution?: MessageAttribution, observationId?: string): string;
|
|
719
|
-
/**
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
*/
|
|
724
|
-
appendMCPToolSelection(selectedToolNames: string[]): string;
|
|
775
|
+
/** Append MCP discovery selection authority without altering discovered built-in authority. */
|
|
776
|
+
appendMCPToolSelection(selectedToolNames: string[], mutationCorrelationId?: string): string;
|
|
777
|
+
/** Append discovered built-in selection authority without altering MCP authority. */
|
|
778
|
+
appendDiscoveredBuiltinToolSelection(selectedToolNames: string[], mutationCorrelationId?: string): string;
|
|
725
779
|
/**
|
|
726
780
|
* Append a TTSR injection entry recording which rules were injected.
|
|
727
781
|
* @param ruleNames Names of rules that were injected
|
|
@@ -833,20 +887,24 @@ export declare class SessionManager {
|
|
|
833
887
|
* @param cwd Working directory (stored in session header)
|
|
834
888
|
* @param sessionDir Optional session directory. If omitted, uses default (~/.gjc/agent/sessions/<encoded-cwd>/).
|
|
835
889
|
*/
|
|
836
|
-
static
|
|
890
|
+
static nestedManagedDestination(authority: ManagedDirectoryRoot | ManagedSessionDescendantStore, directory: string): SessionDestination;
|
|
891
|
+
static managedDestination(cwd: string, agentDir?: string, storage?: SessionStorage): SessionDestination;
|
|
892
|
+
static explicitDestination(directory: string): SessionDestination;
|
|
893
|
+
static create(cwd: string, destinationInput?: SessionDestinationInput, storage?: SessionStorage): SessionManager;
|
|
837
894
|
/** Resolve a default-managed candidate through binding validation and copy-retain migration before mutation. */
|
|
838
895
|
static prepareManagedCandidateForWrite(filePath: string, migrationPolicy: SessionDirectoryMigrationPolicy): Promise<string>;
|
|
839
896
|
/**
|
|
840
897
|
* Fork a session into the current project directory.
|
|
841
898
|
* Copies history from another session file while creating a new session file in the current sessionDir.
|
|
842
899
|
*/
|
|
843
|
-
static forkFrom(sourcePath: string, cwd: string,
|
|
900
|
+
static forkFrom(sourcePath: string, cwd: string, destinationInput?: SessionDestinationInput, storage?: SessionStorage, migrationPolicy?: SessionDirectoryMigrationPolicy): Promise<SessionManager>;
|
|
844
901
|
/**
|
|
845
902
|
* Open a specific session file.
|
|
846
903
|
* @param path Path to session file
|
|
847
904
|
* @param sessionDir Optional session directory for /new or /branch. If omitted, derives from file's parent.
|
|
848
905
|
*/
|
|
849
|
-
static open(filePath: string,
|
|
906
|
+
static open(filePath: string, destinationInput?: SessionDestinationInput, storage?: SessionStorage, migrationPolicy?: SessionDirectoryMigrationPolicy): Promise<SessionManager>;
|
|
907
|
+
static openNestedManaged(filePath: string, destination: SessionDestination, store: ManagedSessionDescendantStore, storage?: SessionStorage): Promise<SessionManager>;
|
|
850
908
|
/**
|
|
851
909
|
* List sessions for the resume picker without recovery or other maintenance writes.
|
|
852
910
|
*/
|
|
@@ -860,21 +918,33 @@ export declare class SessionManager {
|
|
|
860
918
|
* revalidate captured authority before destination initialization and transcript
|
|
861
919
|
* persistence; destination history always comes from the captured bytes.
|
|
862
920
|
*/
|
|
863
|
-
static forkFromCaptured(snapshot: CapturedSessionTranscriptSnapshot, cwd: string,
|
|
921
|
+
static forkFromCaptured(snapshot: CapturedSessionTranscriptSnapshot, cwd: string, destinationInput?: SessionDestinationInput, _migrationPolicy?: SessionDirectoryMigrationPolicy): Promise<StrictSessionForkResult>;
|
|
864
922
|
/** Inspect a selected session without acquiring write-capable ownership. */
|
|
865
923
|
static inspectSessionTailReadOnly(filePath: string, storage?: SessionStorage): Promise<ResumeTailInspection>;
|
|
924
|
+
/**
|
|
925
|
+
* Hydrate an existing predecessor transcript for recovery without taking any
|
|
926
|
+
* write-capable action. The caller must retain the returned context and use
|
|
927
|
+
* the explicit promotion seam only after its ownership-ready fence and writer
|
|
928
|
+
* lease are durable.
|
|
929
|
+
*/
|
|
930
|
+
static openExistingForRecoveryHydrationStrict(identity: ResumeSessionIdentity, destinationInput?: SessionDestinationInput, storage?: SessionStorage): Promise<RecoveryHydrationOpenResult>;
|
|
931
|
+
/**
|
|
932
|
+
* Allows the normal post-open metadata sanitation only after the caller has
|
|
933
|
+
* fsynced its external ownership-ready fence and acquired the writer lease.
|
|
934
|
+
*/
|
|
935
|
+
promoteRecoveryHydrationAfterOwnershipReadyFence(context: RecoveryHydrationContext, fence: RecoveryHydrationPromotionFence): Promise<void>;
|
|
866
936
|
/**
|
|
867
937
|
* Main startup code MUST retain the consented inspection identity and branch on
|
|
868
938
|
* the returned discriminant; an error result never creates, rewrites, or adopts
|
|
869
939
|
* the selected path. Breadcrumb ownership begins only after `kind: "opened"`.
|
|
870
940
|
*/
|
|
871
|
-
static openExistingStrict(identity: ResumeSessionIdentity,
|
|
941
|
+
static openExistingStrict(identity: ResumeSessionIdentity, destinationInput?: SessionDestinationInput, storage?: SessionStorage, migrationPolicy?: SessionDirectoryMigrationPolicy): Promise<StrictSessionOpenResult>;
|
|
872
942
|
/**
|
|
873
943
|
* Continue the most recent session, or create new if none.
|
|
874
944
|
* @param cwd Working directory
|
|
875
945
|
* @param sessionDir Optional session directory. If omitted, uses default (~/.gjc/agent/sessions/<encoded-cwd>/).
|
|
876
946
|
*/
|
|
877
|
-
static continueRecent(cwd: string,
|
|
947
|
+
static continueRecent(cwd: string, destinationInput?: SessionDestinationInput, storage?: SessionStorage, migrationPolicy?: SessionDirectoryMigrationPolicy): Promise<SessionManager>;
|
|
878
948
|
/** Create an in-memory session (no file persistence) */
|
|
879
949
|
static inMemory(cwd?: string, storage?: SessionStorage): SessionManager;
|
|
880
950
|
/**
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as native from "@gajae-code/natives";
|
|
2
|
+
import { type ManagedDirectoryRoot } from "./internal/managed-session-storage";
|
|
1
3
|
export interface SessionStorageStat {
|
|
2
4
|
dev: bigint;
|
|
3
5
|
ino: bigint;
|
|
@@ -48,7 +50,31 @@ export interface SessionStorageWriterOpenOptions {
|
|
|
48
50
|
onError?: (err: Error) => void;
|
|
49
51
|
/** Injectable OS-close dispatcher; defaults to `fs.closeSync`. */
|
|
50
52
|
closeAdapter?: SessionStorageWriterCloseAdapter;
|
|
53
|
+
/** Opaque authority for default-computed managed destinations only. */
|
|
54
|
+
securityContext?: SessionStorageSecurityContext;
|
|
51
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Immutable authority attached only to a computed managed session destination.
|
|
58
|
+
* A caller-supplied pathname never receives this capability, even when it
|
|
59
|
+
* happens to equal the current default session directory.
|
|
60
|
+
*/
|
|
61
|
+
export interface ManagedSessionSecurityContext {
|
|
62
|
+
readonly kind: "managed";
|
|
63
|
+
readonly agentDir: string;
|
|
64
|
+
readonly sessionsRoot: string;
|
|
65
|
+
readonly sessionDir: string;
|
|
66
|
+
readonly rootAuthority: ManagedDirectoryRoot;
|
|
67
|
+
readonly retainedAuthority?: native.RecoveryFsRoot;
|
|
68
|
+
}
|
|
69
|
+
/** @internal Create the only accepted managed writer authority object. */
|
|
70
|
+
export declare function createManagedSessionSecurityContext(input: {
|
|
71
|
+
agentDir: string;
|
|
72
|
+
sessionsRoot: string;
|
|
73
|
+
sessionDir: string;
|
|
74
|
+
rootAuthority: ManagedDirectoryRoot;
|
|
75
|
+
retainedAuthority?: native.RecoveryFsRoot;
|
|
76
|
+
}): ManagedSessionSecurityContext;
|
|
77
|
+
export type SessionStorageSecurityContext = ManagedSessionSecurityContext | undefined;
|
|
52
78
|
export interface SessionStorageWriter {
|
|
53
79
|
writeLine(line: string): Promise<void>;
|
|
54
80
|
/**
|
|
@@ -205,6 +231,7 @@ type NativeDirectoryTreeEntry = {
|
|
|
205
231
|
ino: string;
|
|
206
232
|
size: string;
|
|
207
233
|
mtimeNs: string;
|
|
234
|
+
ctimeNs: string;
|
|
208
235
|
sha256?: string;
|
|
209
236
|
};
|
|
210
237
|
export type NativeDirectoryTreeSnapshot = {
|
|
@@ -24,6 +24,10 @@ export interface OutputSummary {
|
|
|
24
24
|
artifactTruncatedBytes?: number;
|
|
25
25
|
}
|
|
26
26
|
export interface OutputSinkOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Deprecated managed artifact pathname. Bare paths are deliberately ignored:
|
|
29
|
+
* streaming output must be terminally published through ArtifactManager.
|
|
30
|
+
*/
|
|
27
31
|
artifactPath?: string;
|
|
28
32
|
artifactId?: string;
|
|
29
33
|
/** Tail buffer budget (bytes). Default DEFAULT_MAX_BYTES. */
|
|
@@ -15,6 +15,7 @@ import { AgentRegistry } from "../registry/agent-registry";
|
|
|
15
15
|
import type { ForkContextSeed } from "../session/agent-session";
|
|
16
16
|
import type { ArtifactManager } from "../session/artifacts";
|
|
17
17
|
import type { AuthStorage } from "../session/auth-storage";
|
|
18
|
+
import { SessionManager } from "../session/session-manager";
|
|
18
19
|
import type { ContextFileEntry } from "../tools";
|
|
19
20
|
import type { EventBus } from "../utils/event-bus";
|
|
20
21
|
import type { WorkspaceTree } from "../workspace-tree";
|
|
@@ -80,6 +81,7 @@ export interface ExecutorOptions {
|
|
|
80
81
|
* artifacts directory (no per-subagent subdir).
|
|
81
82
|
*/
|
|
82
83
|
parentArtifactManager?: ArtifactManager;
|
|
84
|
+
managedPersistence?: ManagedTaskPersistence;
|
|
83
85
|
parentHindsightSessionState?: HindsightSessionState;
|
|
84
86
|
/**
|
|
85
87
|
* Parent agent's OpenTelemetry configuration. When defined, the subagent's
|
|
@@ -94,6 +96,13 @@ export interface ExecutorOptions {
|
|
|
94
96
|
autoloadSkills?: Skill[];
|
|
95
97
|
forkContextSeed?: ForkContextSeed;
|
|
96
98
|
}
|
|
99
|
+
export declare class ManagedTaskPersistence {
|
|
100
|
+
#private;
|
|
101
|
+
constructor(artifacts: ArtifactManager, taskId: string);
|
|
102
|
+
openSession(): Promise<SessionManager>;
|
|
103
|
+
publishOutput(rawOutput: string, metadata: Uint8Array): Promise<void>;
|
|
104
|
+
}
|
|
105
|
+
export declare function createManagedTaskPersistence(artifacts: ArtifactManager, taskId: string): ManagedTaskPersistence;
|
|
97
106
|
export declare function renderSubagentUserPrompt(assignment: string, independentMode: boolean): string;
|
|
98
107
|
export interface YieldItem {
|
|
99
108
|
data?: unknown;
|
|
@@ -36,6 +36,8 @@ export interface DiscoverableToolSearchResult {
|
|
|
36
36
|
score: number;
|
|
37
37
|
}
|
|
38
38
|
export declare function isMCPToolName(name: string): boolean;
|
|
39
|
+
/** Select persisted built-in discoveries that remain eligible in the current registry, allowlist, and baseline policy. */
|
|
40
|
+
export declare function selectRestorableDiscoveredBuiltinToolNames(toolNames: Iterable<string>, toolRegistry: ReadonlyMap<string, AgentTool>, allowedNames?: ReadonlySet<string>, excludedNames?: ReadonlySet<string>): string[];
|
|
39
41
|
export declare function isMCPBridgeTool(tool: {
|
|
40
42
|
name: string;
|
|
41
43
|
mcpServerName?: unknown;
|