@gajae-code/coding-agent 0.5.4 → 0.6.1

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.
Files changed (155) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/types/cli/web-search-cli.d.ts +12 -0
  3. package/dist/types/commands/rlm.d.ts +10 -0
  4. package/dist/types/commands/web-search.d.ts +54 -0
  5. package/dist/types/config/keybindings.d.ts +10 -0
  6. package/dist/types/config/model-profiles.d.ts +2 -1
  7. package/dist/types/config/model-registry.d.ts +3 -0
  8. package/dist/types/config/models-config-schema.d.ts +3 -0
  9. package/dist/types/config/settings-schema.d.ts +61 -3
  10. package/dist/types/edit/notebook.d.ts +3 -0
  11. package/dist/types/eval/py/executor.d.ts +3 -0
  12. package/dist/types/eval/py/kernel.d.ts +3 -1
  13. package/dist/types/eval/py/runtime.d.ts +9 -1
  14. package/dist/types/exec/bash-executor.d.ts +4 -0
  15. package/dist/types/extensibility/custom-tools/types.d.ts +2 -0
  16. package/dist/types/extensibility/custom-tools/wrapper.d.ts +1 -0
  17. package/dist/types/extensibility/extensions/types.d.ts +2 -0
  18. package/dist/types/extensibility/extensions/wrapper.d.ts +1 -0
  19. package/dist/types/gjc-runtime/launch-tmux.d.ts +6 -0
  20. package/dist/types/gjc-runtime/session-state-sidecar.d.ts +14 -0
  21. package/dist/types/gjc-runtime/tmux-common.d.ts +6 -0
  22. package/dist/types/gjc-runtime/tmux-gc.d.ts +3 -3
  23. package/dist/types/gjc-runtime/tmux-sessions.d.ts +4 -0
  24. package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +18 -0
  25. package/dist/types/goals/state.d.ts +1 -1
  26. package/dist/types/goals/tools/goal-tool.d.ts +2 -0
  27. package/dist/types/main.d.ts +11 -0
  28. package/dist/types/modes/components/custom-editor.d.ts +4 -2
  29. package/dist/types/modes/components/custom-model-preset-wizard.d.ts +12 -0
  30. package/dist/types/modes/components/model-selector.d.ts +5 -2
  31. package/dist/types/modes/components/status-line.d.ts +4 -1
  32. package/dist/types/modes/controllers/input-controller.d.ts +3 -0
  33. package/dist/types/modes/controllers/selector-controller.d.ts +1 -0
  34. package/dist/types/modes/print-mode.d.ts +6 -0
  35. package/dist/types/modes/rpc/rpc-client.d.ts +21 -0
  36. package/dist/types/modes/rpc/rpc-socket-security.d.ts +7 -0
  37. package/dist/types/modes/rpc/rpc-types.d.ts +13 -0
  38. package/dist/types/modes/shared/agent-wire/command-dispatch.d.ts +2 -0
  39. package/dist/types/modes/shared/agent-wire/unattended-session.d.ts +1 -0
  40. package/dist/types/rlm/artifacts.d.ts +9 -0
  41. package/dist/types/rlm/complete-research-tool.d.ts +35 -0
  42. package/dist/types/rlm/data-context.d.ts +6 -0
  43. package/dist/types/rlm/index.d.ts +35 -0
  44. package/dist/types/rlm/notebook.d.ts +12 -0
  45. package/dist/types/rlm/preset.d.ts +23 -0
  46. package/dist/types/rlm/python-tool.d.ts +16 -0
  47. package/dist/types/rlm/report.d.ts +14 -0
  48. package/dist/types/rlm/types.d.ts +37 -0
  49. package/dist/types/sdk.d.ts +7 -0
  50. package/dist/types/session/agent-session.d.ts +21 -0
  51. package/dist/types/tools/bash-allowed-prefixes.d.ts +6 -1
  52. package/dist/types/tools/browser/attach.d.ts +19 -3
  53. package/dist/types/tools/browser/registry.d.ts +15 -0
  54. package/dist/types/tools/browser/render.d.ts +3 -0
  55. package/dist/types/tools/browser.d.ts +18 -1
  56. package/dist/types/tools/computer/render.d.ts +17 -0
  57. package/dist/types/tools/computer.d.ts +465 -0
  58. package/dist/types/tools/index.d.ts +24 -1
  59. package/dist/types/tools/job.d.ts +13 -0
  60. package/dist/types/tools/tool-timeouts.d.ts +5 -0
  61. package/dist/types/web/search/index.d.ts +32 -2
  62. package/dist/types/web/search/providers/base.d.ts +22 -0
  63. package/dist/types/web/search/providers/xai.d.ts +64 -0
  64. package/dist/types/web/search/types.d.ts +11 -3
  65. package/package.json +7 -7
  66. package/src/cli/web-search-cli.ts +123 -8
  67. package/src/cli.ts +2 -0
  68. package/src/commands/rlm.ts +19 -0
  69. package/src/commands/web-search.ts +66 -0
  70. package/src/config/keybindings.ts +11 -0
  71. package/src/config/model-profiles.ts +11 -3
  72. package/src/config/model-registry.ts +55 -1
  73. package/src/config/models-config-schema.ts +1 -0
  74. package/src/config/settings-schema.ts +67 -1
  75. package/src/edit/notebook.ts +6 -2
  76. package/src/eval/py/executor.ts +8 -1
  77. package/src/eval/py/kernel.ts +9 -4
  78. package/src/eval/py/runtime.ts +153 -32
  79. package/src/exec/bash-executor.ts +10 -4
  80. package/src/extensibility/custom-tools/types.ts +2 -0
  81. package/src/extensibility/custom-tools/wrapper.ts +2 -0
  82. package/src/extensibility/extensions/types.ts +2 -0
  83. package/src/extensibility/extensions/wrapper.ts +1 -0
  84. package/src/gjc-runtime/launch-tmux.ts +129 -1
  85. package/src/gjc-runtime/session-state-sidecar.ts +61 -1
  86. package/src/gjc-runtime/tmux-common.ts +26 -2
  87. package/src/gjc-runtime/tmux-gc.ts +40 -27
  88. package/src/gjc-runtime/tmux-sessions.ts +13 -1
  89. package/src/gjc-runtime/ultragoal-runtime.ts +340 -18
  90. package/src/goals/runtime.ts +4 -3
  91. package/src/goals/state.ts +1 -1
  92. package/src/goals/tools/goal-tool.ts +16 -3
  93. package/src/internal-urls/docs-index.generated.ts +13 -9
  94. package/src/main.ts +28 -3
  95. package/src/modes/components/custom-editor.ts +13 -4
  96. package/src/modes/components/custom-model-preset-wizard.ts +293 -0
  97. package/src/modes/components/hook-selector.ts +1 -1
  98. package/src/modes/components/model-selector.ts +72 -29
  99. package/src/modes/components/skill-message.ts +62 -8
  100. package/src/modes/components/status-line.ts +13 -1
  101. package/src/modes/controllers/input-controller.ts +60 -11
  102. package/src/modes/controllers/selector-controller.ts +39 -0
  103. package/src/modes/interactive-mode.ts +1 -1
  104. package/src/modes/print-mode.ts +14 -4
  105. package/src/modes/rpc/rpc-client.ts +250 -80
  106. package/src/modes/rpc/rpc-mode.ts +6 -12
  107. package/src/modes/rpc/rpc-socket-security.ts +103 -0
  108. package/src/modes/rpc/rpc-types.ts +10 -0
  109. package/src/modes/shared/agent-wire/command-dispatch.ts +7 -0
  110. package/src/modes/shared/agent-wire/command-validation.ts +1 -0
  111. package/src/modes/shared/agent-wire/scopes.ts +1 -0
  112. package/src/modes/shared/agent-wire/unattended-session.ts +9 -0
  113. package/src/modes/utils/hotkeys-markdown.ts +4 -2
  114. package/src/modes/utils/ui-helpers.ts +2 -2
  115. package/src/prompts/goals/goal-continuation.md +1 -0
  116. package/src/prompts/goals/goal-mode-active.md +1 -0
  117. package/src/prompts/system/rlm-report-command.md +1 -0
  118. package/src/prompts/system/rlm-research.md +23 -0
  119. package/src/prompts/tools/bash.md +23 -2
  120. package/src/prompts/tools/browser.md +7 -3
  121. package/src/prompts/tools/computer.md +74 -0
  122. package/src/prompts/tools/goal.md +3 -0
  123. package/src/prompts/tools/job.md +9 -1
  124. package/src/prompts/tools/web-search.md +7 -0
  125. package/src/rlm/artifacts.ts +60 -0
  126. package/src/rlm/complete-research-tool.ts +163 -0
  127. package/src/rlm/data-context.ts +26 -0
  128. package/src/rlm/index.ts +339 -0
  129. package/src/rlm/notebook.ts +108 -0
  130. package/src/rlm/preset.ts +76 -0
  131. package/src/rlm/python-tool.ts +68 -0
  132. package/src/rlm/report.ts +70 -0
  133. package/src/rlm/types.ts +40 -0
  134. package/src/sdk.ts +12 -0
  135. package/src/session/agent-session.ts +48 -3
  136. package/src/slash-commands/builtin-registry.ts +17 -0
  137. package/src/tools/bash-allowed-prefixes.ts +84 -1
  138. package/src/tools/bash.ts +80 -13
  139. package/src/tools/browser/attach.ts +103 -3
  140. package/src/tools/browser/registry.ts +176 -2
  141. package/src/tools/browser/render.ts +9 -1
  142. package/src/tools/browser.ts +33 -0
  143. package/src/tools/computer/render.ts +78 -0
  144. package/src/tools/computer.ts +640 -0
  145. package/src/tools/index.ts +41 -1
  146. package/src/tools/job.ts +88 -5
  147. package/src/tools/json-tree.ts +42 -29
  148. package/src/tools/renderers.ts +2 -0
  149. package/src/tools/tool-timeouts.ts +1 -0
  150. package/src/web/search/index.ts +27 -2
  151. package/src/web/search/provider.ts +16 -1
  152. package/src/web/search/providers/base.ts +22 -0
  153. package/src/web/search/providers/xai.ts +511 -0
  154. package/src/web/search/render.ts +7 -0
  155. package/src/web/search/types.ts +11 -1
@@ -48,11 +48,22 @@ export declare function applyStartupModelProfilesOrExit(args: Parameters<typeof
48
48
  * tool registry and shadow the client-supplied servers (issue #1234).
49
49
  */
50
50
  export declare function createAcpSessionFactory(args: AcpSessionFactoryOptions): AcpSessionFactory;
51
+ /**
52
+ * Research-mode (RLM) preset hook. Lets `gjc rlm` augment the session options
53
+ * (system prompt, restricted toolset, custom python tool) and assert the tool
54
+ * boundary once the session's tool registry is fully assembled.
55
+ */
56
+ export interface RlmPreset {
57
+ applyOptions: (options: CreateAgentSessionOptions, settings: Settings) => void;
58
+ onSessionCreated?: (session: AgentSession) => void | Promise<void>;
59
+ }
51
60
  interface RunRootCommandDependencies {
52
61
  createAgentSession?: typeof createAgentSession;
53
62
  discoverAuthStorage?: typeof discoverAuthStorage;
54
63
  runAcpMode?: (createSession: AcpSessionFactory) => Promise<void>;
55
64
  settings?: Settings;
65
+ rlmPreset?: RlmPreset;
66
+ suppressProcessExit?: boolean;
56
67
  }
57
68
  export declare function runRootCommand(parsed: Args, rawArgs: string[], deps?: RunRootCommandDependencies): Promise<void>;
58
69
  export declare function main(args: string[]): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  import { Editor, type KeyId } from "@gajae-code/tui";
2
2
  import type { AppKeybinding } from "../../config/keybindings";
3
- type ConfigurableEditorAction = Extract<AppKeybinding, "app.interrupt" | "app.clear" | "app.exit" | "app.suspend" | "app.thinking.cycle" | "app.model.cycleForward" | "app.model.cycleBackward" | "app.model.select" | "app.model.selectTemporary" | "app.tools.expand" | "app.thinking.toggle" | "app.editor.external" | "app.history.search" | "app.message.dequeue" | "app.clipboard.pasteImage" | "app.clipboard.copyPrompt">;
3
+ type ConfigurableEditorAction = Extract<AppKeybinding, "app.interrupt" | "app.clear" | "app.exit" | "app.suspend" | "app.thinking.cycle" | "app.model.cycleForward" | "app.model.cycleBackward" | "app.model.select" | "app.model.selectTemporary" | "app.tools.expand" | "app.thinking.toggle" | "app.editor.external" | "app.history.search" | "app.message.dequeue" | "app.message.queue" | "app.clipboard.pasteImage" | "app.clipboard.copyPrompt">;
4
4
  type PastePendingClearReason = "timeout" | "queue-limit";
5
5
  /**
6
6
  * Custom editor that handles configurable app-level shortcuts for coding-agent.
@@ -39,13 +39,15 @@ export declare class CustomEditor extends Editor {
39
39
  onPastePendingInputCleared?: (reason: PastePendingClearReason, droppedInputCount: number) => void;
40
40
  /** Called when the configured dequeue shortcut is pressed. */
41
41
  onDequeue?: () => void;
42
+ /** Called when the configured queue shortcut is pressed. */
43
+ onQueue?: () => void;
42
44
  /** Called when Caps Lock is pressed. */
43
45
  onCapsLock?: () => void;
44
46
  setActionKeys(action: ConfigurableEditorAction, keys: KeyId[]): void;
45
47
  /**
46
48
  * Register a custom key handler. Extensions use this for shortcuts.
47
49
  */
48
- setCustomKeyHandler(key: KeyId, handler: () => void): void;
50
+ setCustomKeyHandler(key: KeyId, handler: () => boolean | undefined): void;
49
51
  /**
50
52
  * Remove a custom key handler.
51
53
  */
@@ -0,0 +1,12 @@
1
+ import { Container } from "@gajae-code/tui";
2
+ import type { ModelProfileConfig } from "../../config/models-config-schema";
3
+ export interface CustomModelPresetWizardSubmit {
4
+ name: string;
5
+ profile: ModelProfileConfig;
6
+ }
7
+ export declare class CustomModelPresetWizardComponent extends Container {
8
+ #private;
9
+ constructor(onSubmit: (input: CustomModelPresetWizardSubmit) => void, onCancel: () => void, onRender?: () => void);
10
+ setSubmitError(error: string): void;
11
+ handleInput(keyData: string): void;
12
+ }
@@ -15,12 +15,15 @@ export type ModelSelectorSelection = {
15
15
  kind: "profile";
16
16
  profileName: string;
17
17
  setDefault: boolean;
18
+ } | {
19
+ kind: "createProfile";
18
20
  };
19
21
  type RoleSelectCallback = (selection: ModelSelectorSelection) => void | Promise<void>;
20
22
  /**
21
23
  * Component that renders a canonical model selector with provider tabs.
22
- * - Tab/Arrow Left/Right: Switch between provider tabs
23
- * - Arrow Up/Down: Navigate model list
24
+ * - Preset landing Left/Right: Collapse/expand selected provider
25
+ * - Model browser Tab/Arrow Left/Right: Switch between provider tabs
26
+ * - Arrow Up/Down: Navigate rows
24
27
  * - Enter: Open assignment actions for default plus GJC role-agent models
25
28
  * - Escape: Close selector
26
29
  */
@@ -33,10 +33,13 @@ export interface StatusLineSettings {
33
33
  showSkillHud?: boolean;
34
34
  sessionAccent?: boolean;
35
35
  }
36
+ export interface StatusLineComponentOptions {
37
+ version?: string;
38
+ }
36
39
  export declare class StatusLineComponent implements Component {
37
40
  #private;
38
41
  private readonly session;
39
- constructor(session: AgentSession);
42
+ constructor(session: AgentSession, options?: StatusLineComponentOptions);
40
43
  updateSettings(settings: StatusLineSettings): void;
41
44
  setAutoCompactEnabled(enabled: boolean): void;
42
45
  setSubagentCount(count: number): void;
@@ -12,11 +12,14 @@ export declare class InputController {
12
12
  handleDequeue(): void;
13
13
  /** Send editor text as a follow-up message (queued behind current stream). */
14
14
  handleFollowUp(): Promise<void>;
15
+ /** Send editor text explicitly as a queued next-turn message. */
16
+ handleQueueSubmit(): Promise<void>;
15
17
  restoreQueuedMessagesToEditor(options?: {
16
18
  abort?: boolean;
17
19
  currentText?: string;
18
20
  }): number;
19
21
  handleBackgroundCommand(): void;
22
+ handleForegroundToolBackgroundFold(): boolean;
20
23
  handleTextPaste(text: string): boolean | Promise<boolean>;
21
24
  handleImagePaste(): Promise<boolean>;
22
25
  createAutocompleteProvider(commands: SlashCommand[], basePath: string): AutocompleteProvider;
@@ -15,6 +15,7 @@ export declare class SelectorController {
15
15
  focus: Component;
16
16
  }): void;
17
17
  showProviderOnboarding(): void;
18
+ showCustomModelPresetWizard(): void;
18
19
  showCustomProviderWizard(): void;
19
20
  showSettingsSelector(): void;
20
21
  showThemeSelector(): void;
@@ -19,6 +19,12 @@ export interface PrintModeOptions {
19
19
  initialMessage?: string;
20
20
  /** Images to attach to the initial message */
21
21
  initialImages?: ImageContent[];
22
+ /**
23
+ * When true, an assistant error/abort does not call process.exit(); print mode
24
+ * returns instead so the caller (e.g. RLM autonomous mode) can run its own
25
+ * finalization/cleanup before the process exits.
26
+ */
27
+ suppressProcessExit?: boolean;
22
28
  }
23
29
  /**
24
30
  * Run in print (single-shot) mode.
@@ -10,6 +10,14 @@ import type { BashResult } from "../../exec/bash-executor";
10
10
  import type { SessionStats } from "../../session/agent-session";
11
11
  import type { RpcExtensionUIRequest, RpcGetStateInclude, RpcHandoffResult, RpcHostToolDefinition, RpcSessionState, RpcUnattendedAccepted, RpcUnattendedDeclaration, RpcWorkflowGate, RpcWorkflowGateResolution } from "./rpc-types";
12
12
  export interface RpcClientOptions {
13
+ /** Dial an existing Unix-domain socket instead of spawning a stdio child. */
14
+ socketPath?: string;
15
+ /** Explicit transport selector; defaults to uds when socketPath is set, otherwise stdio. */
16
+ transport?: "stdio" | "uds";
17
+ /** Observe transport close/error state. */
18
+ onTransportClose?: (error?: Error) => void;
19
+ /** Alias for transport close/error observation. */
20
+ onTransportError?: (error: Error) => void;
13
21
  /** Path to the CLI entry point (default: searches for dist/cli.js) */
14
22
  cliPath?: string;
15
23
  /** Working directory for the agent */
@@ -40,6 +48,13 @@ export interface RpcClientCustomTool<TParams extends Record<string, unknown> = R
40
48
  execute(params: TParams, context: RpcClientToolContext<TDetails>): Promise<RpcClientToolResult<TDetails>> | RpcClientToolResult<TDetails>;
41
49
  }
42
50
  export declare function defineRpcClientTool<TParams extends Record<string, unknown> = Record<string, unknown>, TDetails = unknown>(tool: RpcClientCustomTool<TParams, TDetails>): RpcClientCustomTool<TParams, TDetails>;
51
+ export interface RpcTransport {
52
+ readonly kind: "stdio" | "uds";
53
+ start(onFrame: (frame: unknown) => void, onClose: (error?: Error) => void): Promise<void>;
54
+ write(frame: unknown): void;
55
+ stop(): void;
56
+ getStderr(): string;
57
+ }
43
58
  export declare class RpcClient {
44
59
  #private;
45
60
  private options;
@@ -73,6 +88,10 @@ export declare class RpcClient {
73
88
  * input / editor / confirm). Returns an unsubscribe function.
74
89
  */
75
90
  onExtensionUiRequest(listener: (req: RpcExtensionUIRequest) => void): () => void;
91
+ /** Respond to an extension UI request over the live transport. */
92
+ respondExtensionUi(response: import("./rpc-types").RpcExtensionUIResponse): void;
93
+ /** Observe transport close/error notifications. */
94
+ onTransportError(listener: (error: Error) => void): () => void;
76
95
  /**
77
96
  * Enter unattended mode by declaring budget + scopes + action allowlist.
78
97
  * Returns the accepted declaration, or rejects (fail-closed) on refusal.
@@ -116,6 +135,8 @@ export declare class RpcClient {
116
135
  * Get current session state.
117
136
  */
118
137
  getState(include?: RpcGetStateInclude[]): Promise<RpcSessionState>;
138
+ /** Return unresolved workflow gates persisted by the RPC session. */
139
+ getPendingWorkflowGates(): Promise<RpcWorkflowGate[]>;
119
140
  /**
120
141
  * Set model by provider and ID.
121
142
  */
@@ -0,0 +1,7 @@
1
+ export declare class RpcSocketSecurityError extends Error {
2
+ constructor(message: string);
3
+ }
4
+ export declare function prepareRpcSocketPath(socketPath: string): Promise<void>;
5
+ export declare function assertSafeClientSocket(socketPath: string): Promise<void>;
6
+ export declare function verifyRpcSocketAfterListen(socketPath: string): Promise<void>;
7
+ export declare function probeUnixSocketAlive(socketPath: string): Promise<boolean>;
@@ -56,6 +56,9 @@ export type RpcCommand = {
56
56
  id?: string;
57
57
  type: "set_host_uri_schemes";
58
58
  schemes: RpcHostUriSchemeDefinition[];
59
+ } | {
60
+ id?: string;
61
+ type: "get_pending_workflow_gates";
59
62
  } | {
60
63
  id?: string;
61
64
  type: "set_model";
@@ -247,6 +250,14 @@ export type RpcResponse = {
247
250
  data: {
248
251
  schemes: string[];
249
252
  };
253
+ } | {
254
+ id?: string;
255
+ type: "response";
256
+ command: "get_pending_workflow_gates";
257
+ success: true;
258
+ data: {
259
+ gates: RpcWorkflowGate[];
260
+ };
250
261
  } | {
251
262
  id?: string;
252
263
  type: "response";
@@ -647,6 +658,8 @@ export interface RpcWorkflowGateOption {
647
658
  }
648
659
  export interface RpcWorkflowGateContext {
649
660
  title?: string;
661
+ plan?: string;
662
+ source?: string;
650
663
  prompt?: string;
651
664
  summary?: string;
652
665
  stage_state?: Record<string, unknown>;
@@ -19,6 +19,8 @@ export interface RpcUnattendedControlPlane {
19
19
  negotiate(declaration: RpcUnattendedDeclaration): RpcUnattendedAccepted;
20
20
  /** Resolve a pending workflow gate with the agent's answer. */
21
21
  resolveGate(response: RpcWorkflowGateResponse): Promise<RpcWorkflowGateResolution>;
22
+ /** List unresolved durable workflow gates for reconnect replay. */
23
+ listPendingGates?(): import("../../rpc/rpc-types").RpcWorkflowGate[];
22
24
  isUnattended?(): boolean;
23
25
  preflightCommand?(command: RpcCommand): void;
24
26
  reconcileUsage?(phase?: string): void;
@@ -66,6 +66,7 @@ export declare class UnattendedSessionControlPlane implements RpcUnattendedContr
66
66
  preflightCommand(command: RpcCommand): void;
67
67
  reconcileUsage(phase?: string): void;
68
68
  resolveGate(response: RpcWorkflowGateResponse): Promise<RpcWorkflowGateResolution>;
69
+ listPendingGates(): import("../../rpc/rpc-types").RpcWorkflowGate[];
69
70
  emitGate(input: OpenGateInput): Promise<unknown>;
70
71
  recover(): Promise<void>;
71
72
  }
@@ -0,0 +1,9 @@
1
+ import type { RlmArtifactPaths } from "./types";
2
+ export declare const RLM_DIR_SEGMENT: string;
3
+ export declare function isValidRlmSessionId(sessionId: string): boolean;
4
+ /** Generate a filesystem-safe, sortable session id (timestamp + random suffix). */
5
+ export declare function generateRlmSessionId(now?: Date): string;
6
+ export declare function resolveRlmArtifactPaths(cwd: string, sessionId: string): RlmArtifactPaths;
7
+ export declare function ensureRlmSessionDir(paths: RlmArtifactPaths): Promise<void>;
8
+ export declare function rlmSessionExists(cwd: string, sessionId: string): Promise<boolean>;
9
+ export declare function readRlmNotebookIfPresent(cwd: string, sessionId: string): Promise<import("../edit/notebook").NotebookDocument | undefined>;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * RLM completion/report tool.
3
+ *
4
+ * This is the model-facing stop/report seam for autonomous research mode. It
5
+ * writes the deterministic report from the live notebook and, for final
6
+ * completion, marks the RLM controller complete so the existing agent loop can
7
+ * pause through CreateAgentSessionOptions.shouldPause.
8
+ */
9
+ import * as z from "zod/v4";
10
+ import type { NotebookDocument } from "../edit/notebook";
11
+ import type { CustomTool } from "../extensibility/custom-tools/types";
12
+ import type { RlmNotebookWriter } from "./notebook";
13
+ import type { RlmArtifactPaths } from "./types";
14
+ export declare const RLM_COMPLETE_RESEARCH_TOOL_NAME = "complete_research";
15
+ declare const paramsSchema: z.ZodObject<{
16
+ summary: z.ZodString;
17
+ final: z.ZodOptional<z.ZodBoolean>;
18
+ }, z.core.$strip>;
19
+ export interface RlmReportWriteInput {
20
+ paths: RlmArtifactPaths;
21
+ notebook: RlmNotebookWriter;
22
+ title: string;
23
+ summary?: string;
24
+ dataPath?: string | null;
25
+ }
26
+ export interface RlmCompleteResearchContext extends RlmReportWriteInput {
27
+ minSuccessfulRuns?: number;
28
+ getGoalStatus?: () => string | undefined;
29
+ markCompleted?: (summary: string) => void;
30
+ }
31
+ export declare function countSuccessfulNotebookRuns(notebook: NotebookDocument): number;
32
+ export declare function summarizeNotebookForReplay(notebook: NotebookDocument, maxChars?: number): string;
33
+ export declare function writeRlmReport(input: RlmReportWriteInput): Promise<string>;
34
+ export declare function createRlmCompleteResearchTool(context: RlmCompleteResearchContext): CustomTool<typeof paramsSchema>;
35
+ export {};
@@ -0,0 +1,6 @@
1
+ export interface RlmDataContext {
2
+ /** Absolute path the content was loaded from. */
3
+ path: string;
4
+ content: string;
5
+ }
6
+ export declare function loadRlmDataContext(cwd: string, dataFlag: string | undefined): Promise<RlmDataContext | null>;
@@ -0,0 +1,35 @@
1
+ import { type Args } from "../cli/args";
2
+ import type { CustomTool } from "../extensibility/custom-tools/types";
3
+ import { type RlmPreset } from "../main";
4
+ import type { AgentSession } from "../session/agent-session";
5
+ import { type RlmDataContext } from "./data-context";
6
+ interface ExtractedRlmFlags {
7
+ dataPath: string | undefined;
8
+ resumeSessionId: string | undefined;
9
+ minSuccessfulRuns: number;
10
+ rest: string[];
11
+ }
12
+ export interface RlmPresetOptions {
13
+ dataContext: RlmDataContext | null;
14
+ pythonTool: CustomTool;
15
+ completeResearchTool?: CustomTool;
16
+ objective?: string;
17
+ resumeContext?: string;
18
+ onSessionReady?: (session: AgentSession) => void;
19
+ }
20
+ /** Pull RLM-owned flags out of argv; the remainder is forwarded to the root command. */
21
+ export declare function extractRlmFlags(argv: string[]): ExtractedRlmFlags;
22
+ /** @deprecated use extractRlmFlags; retained for tests and compatibility. */
23
+ export declare function extractDataFlag(argv: string[]): {
24
+ dataPath: string | undefined;
25
+ rest: string[];
26
+ };
27
+ export declare function createRlmPreset({ dataContext, pythonTool, completeResearchTool, objective, resumeContext, onSessionReady }: RlmPresetOptions): RlmPreset;
28
+ export declare function buildRlmGoalObjective(input: {
29
+ messages: readonly string[];
30
+ dataContext: RlmDataContext | null;
31
+ }): string;
32
+ export declare function isRlmAutonomousRun(parsed: Pick<Args, "print" | "mode" | "messages">, pipedStdin: boolean): boolean;
33
+ export declare function prepareRlmLaunchMode(parsed: Args, pipedStdin: boolean): boolean;
34
+ export declare function runRlmCommand(argv: string[]): Promise<void>;
35
+ export {};
@@ -0,0 +1,12 @@
1
+ import { type NotebookDocument } from "../edit/notebook";
2
+ import type { RlmCellResult } from "./types";
3
+ export declare class RlmNotebookWriter {
4
+ #private;
5
+ constructor(notebookPath: string, initial?: NotebookDocument);
6
+ get document(): NotebookDocument;
7
+ get cellCount(): number;
8
+ appendMarkdown(source: string): Promise<void>;
9
+ appendCode(code: string, result: RlmCellResult): Promise<void>;
10
+ /** Resolve once all queued writes have flushed. */
11
+ flush(): Promise<void>;
12
+ }
@@ -0,0 +1,23 @@
1
+ import type { RlmDataContext } from "./data-context";
2
+ /**
3
+ * tool; `read` and `web_search` are the existing built-ins. `bash` is exposed
4
+ * through the read-only restriction profile below for inspection commands only,
5
+ * and `goal` is required so RLM sessions cannot finish without explicit goal
6
+ * completion. Everything else (edit, write, task, skill, browser, eval-js, ...) is excluded.
7
+ */
8
+ export declare const RLM_READ_ONLY_BASH_PREFIXES: readonly string[];
9
+ export declare const RLM_TOOL_ALLOWLIST: readonly string[];
10
+ export declare function isRlmToolAllowed(name: string): boolean;
11
+ /**
12
+ * Hard boundary: throws if any active tool is outside the allowlist. Call this
13
+ * after the session's tool registry is fully assembled and before running, so a
14
+ * tool leaked in by defaults/discovery/extensions fails the launch loudly.
15
+ */
16
+ export declare function assertRlmToolAllowlist(activeToolNames: readonly string[]): void;
17
+ /** The research prompt text (exported for testing / prompt assembly). */
18
+ export declare const RLM_RESEARCH_PROMPT: string;
19
+ /**
20
+ * Build the systemPrompt transform for createAgentSession: appends the research
21
+ * prompt, data context, and prior-notebook replay context to the default blocks.
22
+ */
23
+ export declare function buildRlmSystemPrompt(dataContext: RlmDataContext | null, resumeContext?: string): (defaultPrompt: string[]) => string[];
@@ -0,0 +1,16 @@
1
+ import { z } from "@gajae-code/ai";
2
+ import type { CustomTool } from "../extensibility/custom-tools/types";
3
+ import type { RlmNotebookWriter } from "./notebook";
4
+ export declare const RLM_PYTHON_TOOL_NAME = "python";
5
+ export interface RlmPythonToolContext {
6
+ cwd: string;
7
+ sessionId: string;
8
+ artifactsDir: string;
9
+ notebook: RlmNotebookWriter;
10
+ managedWorkspaceVenv?: boolean;
11
+ }
12
+ declare const paramsSchema: z.ZodObject<{
13
+ code: z.ZodString;
14
+ }, z.core.$strip>;
15
+ export declare function createRlmPythonTool(rlm: RlmPythonToolContext): CustomTool<typeof paramsSchema>;
16
+ export {};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Deterministic RLM report synthesis: turns the accumulated notebook (plus an
3
+ * optional model-provided summary) into a Markdown research report.
4
+ */
5
+ import type { NotebookDocument } from "../edit/notebook";
6
+ export interface RlmReportInput {
7
+ title: string;
8
+ summary?: string;
9
+ notebook: NotebookDocument;
10
+ dataPath?: string | null;
11
+ generatedAt?: string;
12
+ maxOutputChars?: number;
13
+ }
14
+ export declare function synthesizeRlmReport(input: RlmReportInput): string;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Shared types for RLM (research) mode.
3
+ */
4
+ import type { KernelDisplayOutput } from "../eval/py/kernel";
5
+ export interface RlmArtifactPaths {
6
+ /** Absolute session directory: <cwd>/.gjc/rlm/<sessionId>/ */
7
+ dir: string;
8
+ /** Absolute path to the live notebook.ipynb */
9
+ notebookPath: string;
10
+ /** Absolute path to the synthesized report.md */
11
+ reportPath: string;
12
+ /** Absolute path to the session metadata.json */
13
+ metadataPath: string;
14
+ /** Directory for the underlying GJC conversation session files. */
15
+ agentSessionDir: string;
16
+ }
17
+ /** Outcome of a single RLM python cell execution. */
18
+ export interface RlmCellResult {
19
+ output: string;
20
+ exitCode: number | undefined;
21
+ cancelled: boolean;
22
+ truncated: boolean;
23
+ displayOutputs: KernelDisplayOutput[];
24
+ }
25
+ export interface RlmSessionMetadata {
26
+ sessionId: string;
27
+ createdAt: string;
28
+ cwd: string;
29
+ dataPath: string | null;
30
+ cellCount: number;
31
+ mode?: "interactive" | "autonomous";
32
+ resumedFrom?: string | null;
33
+ completedAt?: string | null;
34
+ finalSummary?: string | null;
35
+ minSuccessfulRuns?: number;
36
+ successfulRuns?: number;
37
+ }
@@ -5,6 +5,7 @@ import { ModelRegistry } from "./config/model-registry";
5
5
  import { type ScopedModelSelection } from "./config/model-resolver";
6
6
  import { type PromptTemplate } from "./config/prompt-templates";
7
7
  import { Settings, type SkillsSettings } from "./config/settings";
8
+ import type { BashRestrictionProfile } from "./tools/bash-allowed-prefixes";
8
9
  import "./discovery";
9
10
  import type { CustomCommandsLoadResult } from "./extensibility/custom-commands";
10
11
  import type { CustomTool } from "./extensibility/custom-tools/types";
@@ -115,6 +116,12 @@ export interface CreateAgentSessionOptions {
115
116
  agentDisplayName?: string;
116
117
  /** Optional restricted bash command prefixes for read-only role agents. */
117
118
  bashAllowedPrefixes?: string[];
119
+ /** Restriction policy paired with bashAllowedPrefixes. */
120
+ bashRestrictionProfile?: BashRestrictionProfile;
121
+ /** Optional per-session restriction for goal tool operations. */
122
+ goalToolAllowedOps?: readonly ("create" | "get" | "complete" | "resume" | "drop" | "pause")[];
123
+ /** Optional per-session allowlist for tools exposed through search_tool_bm25. */
124
+ discoverableToolAllowedNames?: readonly string[];
118
125
  /** Optional shared agent registry for IRC routing. Default: AgentRegistry.global(). */
119
126
  agentRegistry?: AgentRegistry;
120
127
  /** Parent task ID prefix for nested artifact naming (e.g., "6-Extensions") */
@@ -197,6 +197,8 @@ export interface AgentSessionConfig {
197
197
  /** Rebuild the SSH tool from current capability discovery results. */
198
198
  reloadSshTool?: () => Promise<AgentTool | null>;
199
199
  requestedToolNames?: ReadonlySet<string>;
200
+ /** Optional per-session allowlist for tools exposed through search_tool_bm25. */
201
+ discoverableToolAllowedNames?: readonly string[];
200
202
  /**
201
203
  * Optional accessor for live MCP server instructions. Read by the session's
202
204
  * `rebuildSystemPrompt`-skip optimization to detect server-side instruction
@@ -450,6 +452,25 @@ export declare class AgentSession {
450
452
  * Get a tool by name from the registry.
451
453
  */
452
454
  getToolByName(name: string): AgentTool | undefined;
455
+ /**
456
+ * Register a UI/control-plane request handler for a currently foregrounded
457
+ * managed bash execution. This is intentionally narrower than generic
458
+ * process/job control: unsupported tool types simply do not register a
459
+ * handler, so Ctrl+B-style folding fails closed instead of aborting or
460
+ * shell-suspending arbitrary work.
461
+ */
462
+ registerForegroundBashBackgroundRequestHandler(handler: () => void): () => void;
463
+ /**
464
+ * Returns whether a managed foreground bash call is currently backgroundable.
465
+ * UI key handlers use this to avoid consuming normal editor shortcuts when
466
+ * no fold target exists.
467
+ */
468
+ hasForegroundBashBackgroundRequestHandler(): boolean;
469
+ /**
470
+ * Ask the active managed foreground bash call to return as a background job.
471
+ * Returns false when no supported foreground tool is currently backgroundable.
472
+ */
473
+ requestForegroundBashBackground(): boolean;
453
474
  /**
454
475
  * Get all configured tool names (built-in via --tools or default, plus custom tools).
455
476
  */
@@ -2,4 +2,9 @@ export interface BashAllowedPrefixesCheck {
2
2
  allowed: boolean;
3
3
  reason?: string;
4
4
  }
5
- export declare function checkBashAllowedPrefixes(command: string, allowedPrefixes: readonly string[] | undefined): BashAllowedPrefixesCheck;
5
+ export type BashRestrictionProfile = "workflow" | "read-only";
6
+ export interface BashRestrictionOptions {
7
+ profile?: BashRestrictionProfile;
8
+ }
9
+ export declare function normalizeReadOnlyBashCommand(command: string): string | undefined;
10
+ export declare function checkBashAllowedPrefixes(command: string, allowedPrefixes: readonly string[] | undefined, options?: BashRestrictionOptions): BashAllowedPrefixesCheck;
@@ -8,14 +8,30 @@ export declare function findFreeCdpPort(): Promise<number>;
8
8
  /** Poll `${cdpUrl}/json/version` until it responds with 200, with abort + timeout support. */
9
9
  export declare function waitForCdp(cdpUrl: string, timeoutMs: number, signal?: AbortSignal): Promise<void>;
10
10
  /**
11
- * If any running instance of `exe` was launched with `--remote-debugging-port`
12
- * and that endpoint actually answers, return it so attach can reuse it instead
13
- * of killing and respawning. Idempotent re-attaches are the common case.
11
+ * Pull a `--remote-debugging-port=<n>` value out of an argv array (Chromium
12
+ * accepts both `--flag=value` and `--flag value`). Returns null if absent or
13
+ * malformed.
14
14
  */
15
+ export declare function findCdpPortInArgsForTest(args: string[]): number | null;
16
+ export declare function findCdpAddressInArgsForTest(args: readonly string[]): string | null;
17
+ export declare function isSafeCdpAddressForTest(address: string | null): boolean;
18
+ export declare function argsMatchChromeProfileForTest(args: readonly string[], profile: {
19
+ userDataDir: string;
20
+ profileDirectory: string;
21
+ }): boolean;
15
22
  export declare function findReusableCdp(exe: string, signal?: AbortSignal): Promise<{
16
23
  cdpUrl: string;
17
24
  pid: number;
18
25
  } | null>;
26
+ export interface RunningChromeProfile {
27
+ pid: number;
28
+ cdpUrl: string | null;
29
+ unsafeCdpReason?: string;
30
+ }
31
+ export declare function findRunningChromeProfile(exe: string, profile: {
32
+ userDataDir: string;
33
+ profileDirectory: string;
34
+ }, signal?: AbortSignal): Promise<RunningChromeProfile | null>;
19
35
  /**
20
36
  * Pick the best page target on an attached browser. Without a matcher, prefer
21
37
  * a page that doesn't look like a helper window (devtools, request handler,
@@ -7,6 +7,14 @@ export type BrowserKind = {
7
7
  } | {
8
8
  kind: "spawned";
9
9
  path: string;
10
+ } | {
11
+ kind: "chrome-profile";
12
+ path: string;
13
+ userDataDir: string;
14
+ profileDirectory: string;
15
+ background: boolean;
16
+ noFocus: boolean;
17
+ cdpPort?: number;
10
18
  } | {
11
19
  kind: "connected";
12
20
  cdpUrl: string;
@@ -25,6 +33,9 @@ export interface BrowserHandle {
25
33
  override: UserAgentOverride | null;
26
34
  };
27
35
  }
36
+ type SpawnedChromeProfileKind = Extract<BrowserKind, {
37
+ kind: "chrome-profile";
38
+ }>;
28
39
  export interface AcquireBrowserOptions {
29
40
  cwd: string;
30
41
  viewport?: {
@@ -36,7 +47,11 @@ export interface AcquireBrowserOptions {
36
47
  signal?: AbortSignal;
37
48
  }
38
49
  export declare function acquireBrowser(kind: BrowserKind, opts: AcquireBrowserOptions): Promise<BrowserHandle>;
50
+ export declare function buildChromeProfileLaunchArgs(kind: SpawnedChromeProfileKind, appArgs: readonly string[] | undefined, port: number): string[];
51
+ export declare function buildChromeProfileLaunchArgsForTest(kind: SpawnedChromeProfileKind, appArgs: readonly string[] | undefined, port: number): string[];
52
+ export declare function openChromeProfileHandle(kind: SpawnedChromeProfileKind, opts: AcquireBrowserOptions): Promise<BrowserHandle>;
39
53
  export declare function holdBrowser(handle: BrowserHandle): void;
40
54
  export declare function releaseBrowser(handle: BrowserHandle, opts: {
41
55
  kill: boolean;
42
56
  }): Promise<void>;
57
+ export {};
@@ -19,6 +19,9 @@ interface BrowserRenderArgs {
19
19
  app?: {
20
20
  path?: string;
21
21
  cdp_url?: string;
22
+ browser?: string;
23
+ user_data_dir?: string;
24
+ profile_directory?: string;
22
25
  target?: string;
23
26
  };
24
27
  viewport?: {
@@ -1,7 +1,7 @@
1
1
  import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@gajae-code/agent-core";
2
2
  import * as z from "zod/v4";
3
3
  import type { ToolSession } from "../sdk";
4
- import { type BrowserKindTag } from "./browser/registry";
4
+ import { type BrowserKind, type BrowserKindTag } from "./browser/registry";
5
5
  import type { Observation, ScreenshotResult } from "./browser/tab-protocol";
6
6
  import type { OutputMeta } from "./output-meta";
7
7
  export { extractReadableFromHtml, type ReadableFormat, type ReadableResult } from "./browser/readable";
@@ -18,6 +18,14 @@ declare const browserSchema: z.ZodObject<{
18
18
  app: z.ZodOptional<z.ZodObject<{
19
19
  path: z.ZodOptional<z.ZodString>;
20
20
  cdp_url: z.ZodOptional<z.ZodString>;
21
+ browser: z.ZodOptional<z.ZodEnum<{
22
+ chrome: "chrome";
23
+ }>>;
24
+ user_data_dir: z.ZodOptional<z.ZodString>;
25
+ profile_directory: z.ZodOptional<z.ZodString>;
26
+ background: z.ZodOptional<z.ZodBoolean>;
27
+ no_focus: z.ZodOptional<z.ZodBoolean>;
28
+ cdp_port: z.ZodOptional<z.ZodNumber>;
21
29
  args: z.ZodOptional<z.ZodArray<z.ZodString>>;
22
30
  target: z.ZodOptional<z.ZodString>;
23
31
  }, z.core.$strip>>;
@@ -98,6 +106,7 @@ export interface BrowserToolDetails {
98
106
  result?: string;
99
107
  meta?: OutputMeta;
100
108
  }
109
+ export declare function resolveBrowserKindForTest(params: BrowserParams, session: ToolSession): BrowserKind;
101
110
  /**
102
111
  * Browser tool: stateful, multi-tab. Three actions:
103
112
  * - `open` → acquire/create a named tab on a browser kind (headless | spawned | connected) and optionally goto a url.
@@ -123,6 +132,14 @@ export declare class BrowserTool implements AgentTool<typeof browserSchema, Brow
123
132
  app: z.ZodOptional<z.ZodObject<{
124
133
  path: z.ZodOptional<z.ZodString>;
125
134
  cdp_url: z.ZodOptional<z.ZodString>;
135
+ browser: z.ZodOptional<z.ZodEnum<{
136
+ chrome: "chrome";
137
+ }>>;
138
+ user_data_dir: z.ZodOptional<z.ZodString>;
139
+ profile_directory: z.ZodOptional<z.ZodString>;
140
+ background: z.ZodOptional<z.ZodBoolean>;
141
+ no_focus: z.ZodOptional<z.ZodBoolean>;
142
+ cdp_port: z.ZodOptional<z.ZodNumber>;
126
143
  args: z.ZodOptional<z.ZodArray<z.ZodString>>;
127
144
  target: z.ZodOptional<z.ZodString>;
128
145
  }, z.core.$strip>>;