@gajae-code/coding-agent 0.5.0 → 0.5.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.
- package/CHANGELOG.md +19 -0
- package/dist/types/async/job-manager.d.ts +26 -0
- package/dist/types/cli/args.d.ts +1 -0
- package/dist/types/cli/list-models.d.ts +6 -0
- package/dist/types/commands/gc.d.ts +26 -0
- package/dist/types/config/file-lock-gc.d.ts +5 -0
- package/dist/types/config/file-lock.d.ts +7 -0
- package/dist/types/coordinator/contract.d.ts +1 -1
- package/dist/types/defaults/gjc/extensions/grok-build/index.d.ts +1 -0
- package/dist/types/defaults/gjc/extensions/grok-cli-vendor/src/index.d.ts +1 -0
- package/dist/types/defaults/gjc/extensions/grok-cli-vendor/src/models/catalog.d.ts +25 -0
- package/dist/types/defaults/gjc/extensions/grok-cli-vendor/src/payload/sanitize.d.ts +27 -0
- package/dist/types/defaults/gjc/extensions/grok-cli-vendor/src/provider/billing.d.ts +8 -0
- package/dist/types/defaults/gjc/extensions/grok-cli-vendor/src/provider/register.d.ts +5 -0
- package/dist/types/defaults/gjc/extensions/grok-cli-vendor/src/provider/stream.d.ts +10 -0
- package/dist/types/defaults/gjc/extensions/grok-cli-vendor/src/provider/usage.d.ts +2 -0
- package/dist/types/defaults/gjc/extensions/grok-cli-vendor/src/shared/base-url.d.ts +2 -0
- package/dist/types/defaults/gjc/extensions/grok-cli-vendor/src/shared/errors.d.ts +38 -0
- package/dist/types/defaults/gjc-grok-cli.d.ts +5 -0
- package/dist/types/extensibility/extensions/index.d.ts +1 -0
- package/dist/types/extensibility/extensions/prefix-command-bridge.d.ts +35 -0
- package/dist/types/gjc-runtime/deep-interview-recorder.d.ts +103 -0
- package/dist/types/gjc-runtime/deep-interview-runtime.d.ts +2 -0
- package/dist/types/gjc-runtime/deep-interview-state.d.ts +112 -0
- package/dist/types/gjc-runtime/gc-render.d.ts +6 -0
- package/dist/types/gjc-runtime/gc-runtime.d.ts +134 -0
- package/dist/types/gjc-runtime/ledger-event-renderer.d.ts +68 -0
- package/dist/types/gjc-runtime/team-gc.d.ts +7 -0
- package/dist/types/gjc-runtime/team-runtime.d.ts +5 -0
- package/dist/types/gjc-runtime/tmux-common.d.ts +11 -0
- package/dist/types/gjc-runtime/tmux-gc.d.ts +7 -0
- package/dist/types/gjc-runtime/tmux-sessions.d.ts +13 -0
- package/dist/types/harness-control-plane/gc-adapter.d.ts +3 -0
- package/dist/types/harness-control-plane/owner.d.ts +7 -0
- package/dist/types/harness-control-plane/storage.d.ts +20 -0
- package/dist/types/modes/components/hook-selector.d.ts +7 -1
- package/dist/types/modes/controllers/command-controller.d.ts +1 -0
- package/dist/types/modes/rpc/rpc-mode.d.ts +16 -1
- package/dist/types/modes/shared/agent-wire/deep-interview-gate.d.ts +13 -0
- package/dist/types/modes/shared/agent-wire/session-registry.d.ts +25 -0
- package/dist/types/modes/shared/agent-wire/unattended-action-policy.d.ts +2 -0
- package/dist/types/session/agent-session.d.ts +1 -1
- package/dist/types/session/blob-store.d.ts +39 -3
- package/dist/types/skill-state/workflow-hud.d.ts +14 -0
- package/dist/types/tools/ask.d.ts +15 -1
- package/dist/types/tools/subagent.d.ts +6 -0
- package/package.json +7 -7
- package/src/async/job-manager.ts +52 -0
- package/src/cli/args.ts +3 -0
- package/src/cli/auth-broker-cli.ts +1 -0
- package/src/cli/list-models.ts +13 -1
- package/src/cli.ts +1 -0
- package/src/commands/gc.ts +22 -0
- package/src/commands/harness.ts +7 -3
- package/src/config/file-lock-gc.ts +181 -0
- package/src/config/file-lock.ts +14 -0
- package/src/config/model-profiles.ts +24 -15
- package/src/coordinator/contract.ts +1 -0
- package/src/coordinator-mcp/server.ts +459 -3
- package/src/defaults/gjc/agent.models.grok-cli.yml +36 -0
- package/src/defaults/gjc/extensions/grok-build/index.ts +1 -0
- package/src/defaults/gjc/extensions/grok-build/package.json +7 -0
- package/src/defaults/gjc/extensions/grok-cli-vendor/biome.json +39 -0
- package/src/defaults/gjc/extensions/grok-cli-vendor/package.json +8 -0
- package/src/defaults/gjc/extensions/grok-cli-vendor/src/index.ts +1 -0
- package/src/defaults/gjc/extensions/grok-cli-vendor/src/models/catalog.ts +155 -0
- package/src/defaults/gjc/extensions/grok-cli-vendor/src/payload/sanitize.ts +361 -0
- package/src/defaults/gjc/extensions/grok-cli-vendor/src/provider/billing.ts +57 -0
- package/src/defaults/gjc/extensions/grok-cli-vendor/src/provider/register.ts +99 -0
- package/src/defaults/gjc/extensions/grok-cli-vendor/src/provider/stream.ts +50 -0
- package/src/defaults/gjc/extensions/grok-cli-vendor/src/provider/usage.ts +56 -0
- package/src/defaults/gjc/extensions/grok-cli-vendor/src/shared/base-url.ts +36 -0
- package/src/defaults/gjc/extensions/grok-cli-vendor/src/shared/errors.ts +44 -0
- package/src/defaults/gjc/skills/deep-interview/SKILL.md +131 -113
- package/src/defaults/gjc/skills/deep-interview/lateral-review-panel.md +49 -0
- package/src/defaults/gjc-defaults.ts +7 -0
- package/src/defaults/gjc-grok-cli.ts +22 -0
- package/src/extensibility/extensions/index.ts +1 -0
- package/src/extensibility/extensions/prefix-command-bridge.ts +128 -0
- package/src/gjc-runtime/deep-interview-recorder.ts +417 -0
- package/src/gjc-runtime/deep-interview-runtime.ts +18 -26
- package/src/gjc-runtime/deep-interview-state.ts +324 -0
- package/src/gjc-runtime/gc-render.ts +70 -0
- package/src/gjc-runtime/gc-runtime.ts +403 -0
- package/src/gjc-runtime/ledger-event-renderer.ts +164 -0
- package/src/gjc-runtime/ralplan-runtime.ts +58 -7
- package/src/gjc-runtime/state-renderer.ts +12 -3
- package/src/gjc-runtime/state-runtime.ts +46 -29
- package/src/gjc-runtime/team-gc.ts +49 -0
- package/src/gjc-runtime/team-runtime.ts +179 -2
- package/src/gjc-runtime/tmux-common.ts +14 -0
- package/src/gjc-runtime/tmux-gc.ts +176 -0
- package/src/gjc-runtime/tmux-sessions.ts +49 -1
- package/src/gjc-runtime/ultragoal-runtime.ts +12 -0
- package/src/harness-control-plane/gc-adapter.ts +184 -0
- package/src/harness-control-plane/owner.ts +11 -0
- package/src/harness-control-plane/storage.ts +70 -0
- package/src/internal-urls/docs-index.generated.ts +14 -8
- package/src/main.ts +7 -2
- package/src/modes/components/hook-selector.ts +19 -0
- package/src/modes/components/model-selector.ts +25 -8
- package/src/modes/components/status-line/segments.ts +1 -1
- package/src/modes/controllers/command-controller.ts +25 -6
- package/src/modes/controllers/extension-ui-controller.ts +3 -0
- package/src/modes/controllers/selector-controller.ts +1 -0
- package/src/modes/rpc/rpc-mode.ts +151 -33
- package/src/modes/shared/agent-wire/command-dispatch.ts +278 -261
- package/src/modes/shared/agent-wire/deep-interview-gate.ts +30 -1
- package/src/modes/shared/agent-wire/session-registry.ts +109 -0
- package/src/modes/shared/agent-wire/unattended-action-policy.ts +24 -0
- package/src/modes/shared/agent-wire/unattended-run-controller.ts +23 -3
- package/src/modes/shared/agent-wire/unattended-session.ts +16 -1
- package/src/sdk.ts +17 -3
- package/src/session/agent-session.ts +77 -8
- package/src/session/blob-store.ts +59 -3
- package/src/session/session-manager.ts +4 -4
- package/src/setup/hermes/templates/operator-instructions.v1.md +7 -1
- package/src/skill-state/workflow-hud.ts +106 -10
- package/src/slash-commands/builtin-registry.ts +3 -2
- package/src/task/executor.ts +9 -0
- package/src/tools/ask.ts +56 -1
- package/src/tools/job.ts +3 -2
- package/src/tools/monitor.ts +36 -1
- package/src/tools/subagent-render.ts +9 -0
- package/src/tools/subagent.ts +26 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.5.1] - 2026-06-14
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `gjc --mode rpc` registers each live session in a cross-process registry (`<agent-dir>/rpc-sessions/<id>.json`) on start and removes it on shutdown, so other processes can enumerate running RPC sessions. The Python `gjc_rpc` client exposes `list_sessions()` / `RpcClient.list_sessions()` returning typed `SessionHandle`s and reaps records whose owning process is gone (issue 10; foundation for reattach/issue 09).
|
|
10
|
+
- `gjc --mode rpc --listen <socket-path>` runs a persistent Unix-domain-socket RPC server: the `AgentSession` outlives client disconnects (no stdin-EOF teardown) and a client can disconnect and reconnect to the same live session over the socket. The session is registered with `transport: "socket"` and the socket path as its `endpoint`, so it is discoverable/attachable via the registry. The stdio path is unchanged (frame output routes through a swappable sink shared by both transports) (issue 09).
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Subagent/job status panels now freeze a job's elapsed timer the moment it stops running (`completed`/`failed`/`cancelled`/`paused`) instead of counting up against `Date.now()` forever. `AsyncJob` records an `endTime` on the first terminal/pause transition and a shared `jobElapsedMs` helper backs the `subagent` panel, the `job` tool, `/jobs`, and the command-controller job line, so a finished subagent stops at its real duration while siblings keep ticking.
|
|
15
|
+
- RPC control-plane hardening (from dogfooding `gjc --mode rpc`): `dispatchRpcCommand` now wraps the command switch so failures return a correlated response carrying the request `id` and the real command name, instead of dropping the id and mislabeling handler exceptions as `parse`; `set_thinking_level`/`set_steering_mode`/`set_follow_up_mode`/`set_interrupt_mode` validate their inputs and reject out-of-contract values instead of silently corrupting session state; `negotiate_unattended` rejects unknown scopes/action classes with `invalid_unattended_declaration` and merges the mandatory `prompt` scope plus its `command.prompt` action floor into the accepted grant (so prompt/`workflow_gate_response` are never locked out); and read-only/control RPC commands no longer consume the unattended `max_tool_calls` budget while wall-time enforcement is preserved. `docs/rpc.md`'s first `workflow_gate` example now matches the canonical `RpcWorkflowGate` shape.
|
|
16
|
+
- RPC mode no longer head-of-line-blocks control/cancellation commands behind a long-running command: the stdin loop now dispatches ordered commands through a serial chain (so causal order is preserved — e.g. `get_state` after `bash` still observes the bash result) without blocking the reader, and routes `abort`/`abort_bash`/`abort_retry` on an immediate fast lane so they reach in-flight work. `abort_bash` can now cancel a running `bash`, and a slow `compact`/`handoff`/`login` no longer freezes the whole control plane. Shutdown drains in-flight commands (bounded) so their responses are still emitted on stdin EOF.
|
|
17
|
+
- Counted active prompts and agent-initiated custom messages in pre-prompt context maintenance so background task notifications trigger compaction before they can overflow the next model request.
|
|
18
|
+
- Bounded monitor task-notification payloads to a compact tail window while preserving full background job output for job inspection.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Expanded coordinator MCP coordination status into a canonical polling snapshot for sessions, session states, turns, questions, reports, and bounded event summaries, and documented that Hermes/coordinator consumption is polling/await rather than push subscription.
|
|
23
|
+
|
|
5
24
|
## [0.5.0] - 2026-06-13
|
|
6
25
|
|
|
7
26
|
### Fixed
|
|
@@ -4,6 +4,13 @@ export interface AsyncJob {
|
|
|
4
4
|
type: "bash" | "task";
|
|
5
5
|
status: "running" | "completed" | "failed" | "cancelled" | "paused";
|
|
6
6
|
startTime: number;
|
|
7
|
+
/**
|
|
8
|
+
* Wall-clock ms when the job left the `running` state (completed, failed,
|
|
9
|
+
* cancelled, or paused). Undefined while running. Frozen on the first
|
|
10
|
+
* terminal/pause transition so elapsed-time renderers stop counting once a
|
|
11
|
+
* job is no longer active instead of growing forever against `Date.now()`.
|
|
12
|
+
*/
|
|
13
|
+
endTime?: number;
|
|
7
14
|
label: string;
|
|
8
15
|
abortController: AbortController;
|
|
9
16
|
promise: Promise<void>;
|
|
@@ -18,6 +25,13 @@ export interface AsyncJob {
|
|
|
18
25
|
*/
|
|
19
26
|
ownerId?: string;
|
|
20
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Elapsed wall-clock ms for a job, frozen once it stops running. While the job
|
|
30
|
+
* is active (`endTime` undefined) this counts against `now`; after it stops it
|
|
31
|
+
* returns the fixed `endTime - startTime` span so status renderers do not keep
|
|
32
|
+
* incrementing a completed job's timer.
|
|
33
|
+
*/
|
|
34
|
+
export declare function jobElapsedMs(job: Pick<AsyncJob, "startTime" | "endTime">, now?: number): number;
|
|
21
35
|
export interface AsyncJobMetadata {
|
|
22
36
|
subagent?: {
|
|
23
37
|
id: string;
|
|
@@ -77,6 +91,12 @@ export interface SubagentRecord {
|
|
|
77
91
|
message?: string;
|
|
78
92
|
createdAt: number;
|
|
79
93
|
};
|
|
94
|
+
/** Resolved model the subagent was asked to use, e.g. "openai-codex/gpt-5.5". */
|
|
95
|
+
requestedModel?: string;
|
|
96
|
+
/** Model actually used after auth fallback (#985); equals requestedModel when no fallback. */
|
|
97
|
+
effectiveModel?: string;
|
|
98
|
+
/** True when the requested model lacked credentials and the subagent fell back to the parent model. */
|
|
99
|
+
modelFellBack?: boolean;
|
|
80
100
|
}
|
|
81
101
|
/** Lightweight, manager-owned resume payload. The async layer treats `data` as opaque. */
|
|
82
102
|
export interface ResumeDescriptor {
|
|
@@ -184,6 +204,12 @@ export declare class AsyncJobManager {
|
|
|
184
204
|
};
|
|
185
205
|
/** Register or replace the canonical record for a subagent. */
|
|
186
206
|
registerSubagentRecord(record: SubagentRecord): void;
|
|
207
|
+
/** Patch model metadata onto an existing subagent record (best-effort; no-op if unknown). */
|
|
208
|
+
updateSubagentModel(subagentId: string, model: {
|
|
209
|
+
requestedModel?: string;
|
|
210
|
+
effectiveModel?: string;
|
|
211
|
+
modelFellBack?: boolean;
|
|
212
|
+
}): void;
|
|
187
213
|
getSubagentRecord(subagentId: string, filter?: AsyncJobFilter): SubagentRecord | undefined;
|
|
188
214
|
getSubagentRecords(filter?: AsyncJobFilter): SubagentRecord[];
|
|
189
215
|
registerLiveHandle(subagentId: string, handle: SubagentLiveHandle): void;
|
package/dist/types/cli/args.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ModelRegistry } from "../config/model-registry";
|
|
2
|
+
import { type ExtensionFactory } from "../extensibility/extensions";
|
|
2
3
|
/**
|
|
3
4
|
* List available models, optionally filtered by search pattern
|
|
4
5
|
*/
|
|
@@ -11,6 +12,11 @@ export interface RunListModelsOptions {
|
|
|
11
12
|
cwd: string;
|
|
12
13
|
/** CLI-supplied extension paths (e.g. from `-e <path>`). */
|
|
13
14
|
additionalExtensionPaths?: string[];
|
|
15
|
+
/** In-process extension factories to load without filesystem discovery. */
|
|
16
|
+
extensionFactories?: Array<{
|
|
17
|
+
factory: ExtensionFactory;
|
|
18
|
+
name: string;
|
|
19
|
+
}>;
|
|
14
20
|
/** Extension paths configured under `extensions:` in user settings. */
|
|
15
21
|
settingsExtensions?: string[];
|
|
16
22
|
/** Disabled extension ids from settings (`disabledExtensions`). */
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Command } from "@gajae-code/utils/cli";
|
|
2
|
+
export default class Gc extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static strict: boolean;
|
|
5
|
+
static flags: {
|
|
6
|
+
json: import("@gajae-code/utils/cli").FlagDescriptor<"boolean"> & {
|
|
7
|
+
char: string;
|
|
8
|
+
description: string;
|
|
9
|
+
default: boolean;
|
|
10
|
+
};
|
|
11
|
+
prune: import("@gajae-code/utils/cli").FlagDescriptor<"boolean"> & {
|
|
12
|
+
description: string;
|
|
13
|
+
default: boolean;
|
|
14
|
+
};
|
|
15
|
+
force: import("@gajae-code/utils/cli").FlagDescriptor<"boolean"> & {
|
|
16
|
+
description: string;
|
|
17
|
+
default: boolean;
|
|
18
|
+
};
|
|
19
|
+
"dry-run": import("@gajae-code/utils/cli").FlagDescriptor<"boolean"> & {
|
|
20
|
+
description: string;
|
|
21
|
+
default: boolean;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
static examples: string[];
|
|
25
|
+
run(): Promise<void>;
|
|
26
|
+
}
|
|
@@ -3,4 +3,11 @@ export interface FileLockOptions {
|
|
|
3
3
|
retries?: number;
|
|
4
4
|
retryDelayMs?: number;
|
|
5
5
|
}
|
|
6
|
+
/** @internal */
|
|
7
|
+
export declare function readFileLockInfoForGc(lockDir: string): Promise<{
|
|
8
|
+
pid: number;
|
|
9
|
+
timestamp: number;
|
|
10
|
+
} | null>;
|
|
11
|
+
/** @internal */
|
|
12
|
+
export declare function removeFileLockDirForGc(lockDir: string): Promise<void>;
|
|
6
13
|
export declare function withFileLock<T>(filePath: string, fn: () => Promise<T>, options?: FileLockOptions): Promise<T>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const COORDINATOR_MCP_PROTOCOL_VERSION = "2024-11-05";
|
|
2
2
|
export declare const COORDINATOR_MCP_SERVER_NAME = "gjc-coordinator-mcp";
|
|
3
|
-
export declare const COORDINATOR_MCP_TOOL_NAMES: readonly ["gjc_coordinator_list_sessions", "gjc_coordinator_read_status", "gjc_coordinator_read_tail", "gjc_coordinator_list_questions", "gjc_coordinator_list_artifacts", "gjc_coordinator_read_artifact", "gjc_coordinator_read_coordination_status", "gjc_coordinator_register_session", "gjc_coordinator_start_session", "gjc_coordinator_send_prompt", "gjc_coordinator_submit_question_answer", "gjc_coordinator_read_turn", "gjc_coordinator_await_turn", "gjc_coordinator_report_status"];
|
|
3
|
+
export declare const COORDINATOR_MCP_TOOL_NAMES: readonly ["gjc_coordinator_list_sessions", "gjc_coordinator_read_status", "gjc_coordinator_read_tail", "gjc_coordinator_list_questions", "gjc_coordinator_list_artifacts", "gjc_coordinator_read_artifact", "gjc_coordinator_read_coordination_status", "gjc_coordinator_watch_events", "gjc_coordinator_register_session", "gjc_coordinator_start_session", "gjc_coordinator_send_prompt", "gjc_coordinator_submit_question_answer", "gjc_coordinator_read_turn", "gjc_coordinator_await_turn", "gjc_coordinator_report_status"];
|
|
4
4
|
export type CoordinatorToolName = (typeof COORDINATOR_MCP_TOOL_NAMES)[number];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "../grok-cli-vendor/src/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './provider/register.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model definitions for Grok CLI's API.
|
|
3
|
+
*/
|
|
4
|
+
export interface GrokCliModelConfig {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
reasoning: boolean;
|
|
8
|
+
input: ('text' | 'image')[];
|
|
9
|
+
cost: {
|
|
10
|
+
input: number;
|
|
11
|
+
output: number;
|
|
12
|
+
cacheRead: number;
|
|
13
|
+
cacheWrite: number;
|
|
14
|
+
};
|
|
15
|
+
contextWindow: number;
|
|
16
|
+
maxTokens: number;
|
|
17
|
+
/** Models that don't support reasoning.effort get a thinkingLevelMap. */
|
|
18
|
+
thinkingLevelMap?: Record<string, string | null>;
|
|
19
|
+
}
|
|
20
|
+
export declare function supportsReasoningEffort(modelId: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Resolve the active model list. If `GJC_GROK_CLI_MODELS` is set,
|
|
23
|
+
* it filters/reorders the fallback list; unknown IDs get sensible defaults.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveModels(): GrokCliModelConfig[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payload sanitization for xAI's Responses API via cli-chat-proxy.grok.com.
|
|
3
|
+
*
|
|
4
|
+
* xAI's endpoint has quirks compared to stock OpenAI:
|
|
5
|
+
* - Replayed or encrypted `reasoning` items in input cause 400 errors.
|
|
6
|
+
* - `reasoning.effort` is only supported on a subset of models.
|
|
7
|
+
* - Empty-string content items cause validation failures.
|
|
8
|
+
* - `function_call_output.output` cannot contain image arrays.
|
|
9
|
+
* - `image_url` parts must be normalized to `input_image` with data URIs.
|
|
10
|
+
* - Local image paths must be resolved to base64 data URIs.
|
|
11
|
+
* - xAI rejects `role: "developer"` and `role: "system"` in the input
|
|
12
|
+
* array; these must be moved to top-level `instructions`.
|
|
13
|
+
* - xAI uses `text.format` instead of OpenAI's `response_format`.
|
|
14
|
+
* - xAI uses `prompt_cache_key` for conversation caching.
|
|
15
|
+
* - xAI doesn't support `prompt_cache_retention`.
|
|
16
|
+
*
|
|
17
|
+
* Additional Grok CLI-specific behavior:
|
|
18
|
+
* - Adds x-grok-* headers for client identification
|
|
19
|
+
* - Uses prompt_cache_key for session affinity
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Sanitize a provider request payload for xAI's Responses API via
|
|
23
|
+
* cli-chat-proxy.grok.com.
|
|
24
|
+
*
|
|
25
|
+
* Returns the modified payload. Mutates the input in place for efficiency.
|
|
26
|
+
*/
|
|
27
|
+
export declare function sanitizePayload(params: Record<string, unknown>, modelId: string, sessionId: string | undefined, cwd: string): Record<string, unknown>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface BillingUsage {
|
|
2
|
+
monthlyLimit: number;
|
|
3
|
+
used: number;
|
|
4
|
+
billingPeriodEnd: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function fetchBillingUsage(token: string): Promise<BillingUsage>;
|
|
7
|
+
export declare function formatQuota(usage: BillingUsage | undefined): string[];
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Api, AssistantMessageEventStream, Context, Model, SimpleStreamOptions } from '@gajae-code/ai';
|
|
2
|
+
/**
|
|
3
|
+
* Stream function that adds Grok CLI-specific headers to requests.
|
|
4
|
+
*
|
|
5
|
+
* GJC Grok Build extension sends cli-chat-proxy headers (see agent.models.grok-cli.yml):
|
|
6
|
+
* - x-grok-conv-id: <session/conversation ID>
|
|
7
|
+
* - x-grok-model-override: <model ID>
|
|
8
|
+
* - x-xai-token-auth: xai-grok-cli
|
|
9
|
+
*/
|
|
10
|
+
export declare function streamGrokCli(model: Model<Api>, context: Context, options?: SimpleStreamOptions): AssistantMessageEventStream;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed error for xAI OAuth failures.
|
|
3
|
+
*
|
|
4
|
+
* Codes allow the login flow and stream handlers to distinguish
|
|
5
|
+
* retryable failures (network) from fatal ones (revoked refresh token).
|
|
6
|
+
*/
|
|
7
|
+
export declare class XaiOAuthError extends Error {
|
|
8
|
+
readonly code: string;
|
|
9
|
+
readonly reloginRequired: boolean;
|
|
10
|
+
constructor(message: string, code: string, reloginRequired?: boolean);
|
|
11
|
+
}
|
|
12
|
+
/** Well-known error codes. */
|
|
13
|
+
export declare const XaiErrorCode: {
|
|
14
|
+
/** OIDC discovery failed (network, invalid response). */
|
|
15
|
+
readonly DISCOVERY_FAILED: 'discovery_failed';
|
|
16
|
+
/** Discovery endpoint returned a non-xAI origin. */
|
|
17
|
+
readonly DISCOVERY_INVALID_ORIGIN: 'discovery_invalid_origin';
|
|
18
|
+
/** Authorization was denied or errored in the browser. */
|
|
19
|
+
readonly AUTHORIZATION_FAILED: 'authorization_failed';
|
|
20
|
+
/** CSRF state mismatch between request and callback. */
|
|
21
|
+
readonly STATE_MISMATCH: 'state_mismatch';
|
|
22
|
+
/** Callback did not include an authorization code. */
|
|
23
|
+
readonly CODE_MISSING: 'code_missing';
|
|
24
|
+
/** Token exchange failed (network, invalid response). */
|
|
25
|
+
readonly TOKEN_EXCHANGE_FAILED: 'token_exchange_failed';
|
|
26
|
+
/** Token exchange returned an invalid payload. */
|
|
27
|
+
readonly TOKEN_EXCHANGE_INVALID: 'token_exchange_invalid';
|
|
28
|
+
/** Refresh token is missing or empty. */
|
|
29
|
+
readonly REFRESH_MISSING: 'refresh_missing';
|
|
30
|
+
/** Token refresh failed (expired, revoked). */
|
|
31
|
+
readonly REFRESH_FAILED: 'refresh_failed';
|
|
32
|
+
/** No credentials stored. */
|
|
33
|
+
readonly AUTH_MISSING: 'auth_missing';
|
|
34
|
+
/** Loopback callback server could not bind. */
|
|
35
|
+
readonly CALLBACK_BIND_FAILED: 'callback_bind_failed';
|
|
36
|
+
/** Loopback callback timed out. */
|
|
37
|
+
readonly CALLBACK_TIMEOUT: 'callback_timeout';
|
|
38
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExtensionFactory } from "../extensibility/extensions/types";
|
|
2
|
+
export declare const BUNDLED_GROK_BUILD_EXTENSION_ID = "bundled:grok-build";
|
|
3
|
+
export declare function getBundledGrokBuildExtensionFactory(): ExtensionFactory;
|
|
4
|
+
export declare function getBundledGrokCliModelDefaults(): string;
|
|
5
|
+
export declare function assertBundledGrokCliDefaults(): Promise<void>;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export type { SlashCommandInfo, SlashCommandLocation, SlashCommandSource } from "../slash-commands";
|
|
5
5
|
export { discoverAndLoadExtensions, ExtensionRuntimeNotInitializedError, loadExtensionFromFactory, loadExtensions, } from "./loader";
|
|
6
|
+
export * from "./prefix-command-bridge";
|
|
6
7
|
export * from "./runner";
|
|
7
8
|
export * from "./types";
|
|
8
9
|
export * from "./wrapper";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ExecResult } from "../../exec/exec";
|
|
2
|
+
import type { ExtensionContext, InputEvent, InputEventResult } from "./types";
|
|
3
|
+
export declare const OOO_BRIDGE_RECURSION_ENV = "_OUROBOROS_GJC_BRIDGE_DEPTH";
|
|
4
|
+
export declare const OOO_BRIDGE_CONTINUE_EXIT_CODE = 78;
|
|
5
|
+
export declare const OOO_BRIDGE_TIMEOUT_ENV = "OUROBOROS_GJC_BRIDGE_TIMEOUT_MS";
|
|
6
|
+
export interface ExactPrefixCommandBridgeOptions {
|
|
7
|
+
/** Bare command prefix to intercept, without trailing whitespace. */
|
|
8
|
+
prefix: string;
|
|
9
|
+
/** Command executable to run when the prefix matches. */
|
|
10
|
+
command: string;
|
|
11
|
+
/** Arguments inserted before the intercepted input text. */
|
|
12
|
+
args?: string[];
|
|
13
|
+
/** Environment variable used as the recursion-depth guard. */
|
|
14
|
+
recursionEnv?: string;
|
|
15
|
+
/** Exit code that maps to extension pass-through instead of handled input. */
|
|
16
|
+
continueExitCode?: number;
|
|
17
|
+
/** Optional dispatch timeout in milliseconds. */
|
|
18
|
+
timeout?: number;
|
|
19
|
+
/** Dispatch implementation. Defaults to the shared command executor in the extension context cwd. */
|
|
20
|
+
dispatch?: (command: string, args: string[], ctx: ExtensionContext, options: {
|
|
21
|
+
timeout?: number;
|
|
22
|
+
}) => Promise<ExecResult>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Build an extension `input` handler for an exact-prefix command bridge.
|
|
26
|
+
*
|
|
27
|
+
* Matching input is passed to `command` as `args + [event.text]`. A zero exit code
|
|
28
|
+
* handles the input, `continueExitCode` returns pass-through, and any other
|
|
29
|
+
* non-zero exit code surfaces an error and handles the input so the failed
|
|
30
|
+
* command is not forwarded to the model. The recursion
|
|
31
|
+
* guard prevents extension-originated or nested dispatch from re-entering the
|
|
32
|
+
* bridge while the child command runs.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createExactPrefixCommandBridge(options: ExactPrefixCommandBridgeOptions): (event: InputEvent, ctx: ExtensionContext) => Promise<InputEventResult>;
|
|
35
|
+
export declare function createOuroborosOooBridge(): (event: InputEvent, ctx: ExtensionContext) => Promise<InputEventResult>;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { type DeepInterviewEstablishedFact, type DeepInterviewRoundRecord, type DeepInterviewStateEnvelope, type DeepInterviewTriggerMetadata } from "./deep-interview-state";
|
|
2
|
+
export * from "./deep-interview-state";
|
|
3
|
+
/**
|
|
4
|
+
* Runtime-owned deep-interview round recorder (conflict-aware scoring support).
|
|
5
|
+
*
|
|
6
|
+
* Ownership boundary (per the approved consensus plan): this module owns durable
|
|
7
|
+
* round-record semantics — stable identity, append-or-merge, lifecycle, compact
|
|
8
|
+
* reads, replay detection, and the pure scored-transition validator. Callers such
|
|
9
|
+
* as the `ask` tool only resolve an answer and invoke these helpers; they never
|
|
10
|
+
* compute state paths, merge records, or write `.gjc` files directly. All writes
|
|
11
|
+
* go through the sanctioned state-writer (`writeWorkflowEnvelopeAtomic`).
|
|
12
|
+
*/
|
|
13
|
+
export interface DeepInterviewAnswerInput {
|
|
14
|
+
interviewId?: string;
|
|
15
|
+
round: number;
|
|
16
|
+
round_id?: string;
|
|
17
|
+
questionId?: string;
|
|
18
|
+
questionText: string;
|
|
19
|
+
component?: string;
|
|
20
|
+
dimension?: string;
|
|
21
|
+
ambiguity?: number;
|
|
22
|
+
selectedOptions?: string[];
|
|
23
|
+
customInput?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface DeepInterviewScoringInput {
|
|
26
|
+
interviewId?: string;
|
|
27
|
+
round: number;
|
|
28
|
+
round_id?: string;
|
|
29
|
+
questionId?: string;
|
|
30
|
+
scores: Record<string, number>;
|
|
31
|
+
ambiguity: number;
|
|
32
|
+
triggers?: DeepInterviewTriggerMetadata[];
|
|
33
|
+
}
|
|
34
|
+
export type AppendOrMergeAction = "created" | "noop" | "replaced";
|
|
35
|
+
export interface AppendOrMergeResult {
|
|
36
|
+
rounds: DeepInterviewRoundRecord[];
|
|
37
|
+
action: AppendOrMergeAction;
|
|
38
|
+
record: DeepInterviewRoundRecord;
|
|
39
|
+
}
|
|
40
|
+
export interface DeepInterviewCompactState {
|
|
41
|
+
threshold?: number;
|
|
42
|
+
threshold_source?: string;
|
|
43
|
+
current_ambiguity?: number;
|
|
44
|
+
topology_summary?: {
|
|
45
|
+
active: number;
|
|
46
|
+
deferred: number;
|
|
47
|
+
components: string[];
|
|
48
|
+
};
|
|
49
|
+
established_facts: DeepInterviewEstablishedFact[];
|
|
50
|
+
unresolved_triggers: DeepInterviewTriggerMetadata[];
|
|
51
|
+
recent_scored_rounds: DeepInterviewRoundRecord[];
|
|
52
|
+
pending_shells: DeepInterviewRoundRecord[];
|
|
53
|
+
}
|
|
54
|
+
export interface TransitionValidationResult {
|
|
55
|
+
ok: boolean;
|
|
56
|
+
violations: string[];
|
|
57
|
+
}
|
|
58
|
+
export declare function buildAnswerShell(input: DeepInterviewAnswerInput, now?: string): DeepInterviewRoundRecord;
|
|
59
|
+
/**
|
|
60
|
+
* Append-or-merge by `round_key`. Exactly one record per key:
|
|
61
|
+
* - no existing record -> append (`created`);
|
|
62
|
+
* - identical question_hash + answer_hash -> deterministic no-op (`noop`);
|
|
63
|
+
* - same key, different hashes -> deterministic replacement of the prior shell
|
|
64
|
+
* (`replaced`); the prior answer for that key is superseded and lifecycle resets.
|
|
65
|
+
*/
|
|
66
|
+
export declare function appendOrMergeRound(rounds: readonly DeepInterviewRoundRecord[], shell: DeepInterviewRoundRecord): AppendOrMergeResult;
|
|
67
|
+
/**
|
|
68
|
+
* Merge scoring output into the existing record for the derived key, transitioning
|
|
69
|
+
* it to `scored`. Never appends a second record for the same key; if no shell exists
|
|
70
|
+
* yet (scoring without a prior ask), a scored record is created so data is not lost.
|
|
71
|
+
*/
|
|
72
|
+
export declare function enrichRoundWithScoring(rounds: readonly DeepInterviewRoundRecord[], input: DeepInterviewScoringInput, now?: string): {
|
|
73
|
+
rounds: DeepInterviewRoundRecord[];
|
|
74
|
+
record: DeepInterviewRoundRecord;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Bidirectional invariant: if `next` carries an `active` trigger, the affected
|
|
78
|
+
* dimension must not improve and overall ambiguity must rise vs the prior scored
|
|
79
|
+
* round. `disputed`/`unresolved` triggers are exempt but must carry a rationale.
|
|
80
|
+
*/
|
|
81
|
+
export declare function validateDeepInterviewScoredTransition(prior: DeepInterviewRoundRecord | undefined, next: DeepInterviewRoundRecord): TransitionValidationResult;
|
|
82
|
+
/** Back-compat wrapper: normalize a deep-interview envelope to its canonical nested shape. */
|
|
83
|
+
export declare function ensureDeepInterviewStateShape(value: unknown): DeepInterviewStateEnvelope;
|
|
84
|
+
export declare function projectCompactState(value: unknown, options?: {
|
|
85
|
+
lastN?: number;
|
|
86
|
+
}): DeepInterviewCompactState;
|
|
87
|
+
/** Record an `answered` shell for one round (append-or-merge by durable key). */
|
|
88
|
+
export declare function appendOrMergeDeepInterviewRound(cwd: string, statePath: string, input: DeepInterviewAnswerInput, options?: {
|
|
89
|
+
sessionId?: string;
|
|
90
|
+
}): Promise<{
|
|
91
|
+
action: AppendOrMergeAction;
|
|
92
|
+
record: DeepInterviewRoundRecord;
|
|
93
|
+
}>;
|
|
94
|
+
/** Merge scoring output into the same round record, transitioning to `scored`. */
|
|
95
|
+
export declare function enrichDeepInterviewRoundScoring(cwd: string, statePath: string, input: DeepInterviewScoringInput, options?: {
|
|
96
|
+
sessionId?: string;
|
|
97
|
+
}): Promise<{
|
|
98
|
+
record: DeepInterviewRoundRecord;
|
|
99
|
+
}>;
|
|
100
|
+
/** Compact projection so callers read a slice instead of the full transcript. */
|
|
101
|
+
export declare function readDeepInterviewStateCompact(statePath: string, options?: {
|
|
102
|
+
lastN?: number;
|
|
103
|
+
}): Promise<DeepInterviewCompactState>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from "./deep-interview-recorder";
|
|
1
2
|
/**
|
|
2
3
|
* Native implementation of `gjc deep-interview`.
|
|
3
4
|
*
|
|
@@ -12,6 +13,7 @@ export interface DeepInterviewCommandResult {
|
|
|
12
13
|
stdout?: string;
|
|
13
14
|
stderr?: string;
|
|
14
15
|
}
|
|
16
|
+
export declare function deepInterviewStatePath(cwd: string, sessionId: string | undefined): string;
|
|
15
17
|
export interface ResolvedDeepInterviewSpecWriteArgs {
|
|
16
18
|
stage: "final";
|
|
17
19
|
slug: string;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure, dependency-free foundation for deep-interview state shape.
|
|
3
|
+
*
|
|
4
|
+
* Ownership boundary (per the approved consensus plan): this leaf module owns the
|
|
5
|
+
* canonical persisted shape (interview data nested under `state`), durable round
|
|
6
|
+
* identity/hashing, lossless legacy normalization, and the deep-interview-specific
|
|
7
|
+
* envelope/round merge used by every writer (`deep-interview-recorder`,
|
|
8
|
+
* `state-runtime` write/reconcile, seed, and handoff). It MUST NOT import the
|
|
9
|
+
* active-state, state-writer, CLI runtime, or filesystem so it stays cycle-free and
|
|
10
|
+
* trivially testable.
|
|
11
|
+
*/
|
|
12
|
+
export type DeepInterviewRoundLifecycle = "answered" | "pending_scoring" | "scored";
|
|
13
|
+
export type DeepInterviewTriggerKind = "A" | "B" | "C" | "D";
|
|
14
|
+
/** `active` triggers must satisfy the bidirectional invariant; disputed/unresolved are exempt with rationale. */
|
|
15
|
+
export type DeepInterviewTriggerStatus = "active" | "disputed" | "unresolved";
|
|
16
|
+
export interface DeepInterviewEstablishedFact {
|
|
17
|
+
id: string;
|
|
18
|
+
statement: string;
|
|
19
|
+
round: number;
|
|
20
|
+
component?: string;
|
|
21
|
+
dimension?: string;
|
|
22
|
+
evidence?: string;
|
|
23
|
+
disputed: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface DeepInterviewTriggerMetadata {
|
|
26
|
+
kind: DeepInterviewTriggerKind;
|
|
27
|
+
name: string;
|
|
28
|
+
status: DeepInterviewTriggerStatus;
|
|
29
|
+
component: string;
|
|
30
|
+
dimension: string;
|
|
31
|
+
priorDimensionScore?: number;
|
|
32
|
+
newDimensionScore?: number;
|
|
33
|
+
priorAmbiguity?: number;
|
|
34
|
+
newAmbiguity?: number;
|
|
35
|
+
evidence?: string;
|
|
36
|
+
contradictedFactId?: string;
|
|
37
|
+
/** Required when status is `disputed` or `unresolved` to exempt the invariant. */
|
|
38
|
+
rationale?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface DeepInterviewRoundRecord {
|
|
41
|
+
round_key: string;
|
|
42
|
+
round_id?: string;
|
|
43
|
+
round: number;
|
|
44
|
+
question_id?: string;
|
|
45
|
+
question_text?: string;
|
|
46
|
+
question_hash: string;
|
|
47
|
+
answer_hash: string;
|
|
48
|
+
selected_options?: string[];
|
|
49
|
+
custom_input?: string;
|
|
50
|
+
component?: string;
|
|
51
|
+
dimension?: string;
|
|
52
|
+
ambiguity_at_ask?: number;
|
|
53
|
+
lifecycle: DeepInterviewRoundLifecycle;
|
|
54
|
+
answered_at: string;
|
|
55
|
+
scored_at?: string;
|
|
56
|
+
scores?: Record<string, number>;
|
|
57
|
+
ambiguity?: number;
|
|
58
|
+
triggers?: DeepInterviewTriggerMetadata[];
|
|
59
|
+
}
|
|
60
|
+
export interface DeepInterviewStateEnvelope {
|
|
61
|
+
threshold?: number;
|
|
62
|
+
threshold_source?: string;
|
|
63
|
+
state?: Record<string, unknown>;
|
|
64
|
+
[key: string]: unknown;
|
|
65
|
+
}
|
|
66
|
+
export declare function hashContent(value: string): string;
|
|
67
|
+
export declare function questionHash(questionText: string): string;
|
|
68
|
+
export declare function answerHash(selectedOptions: string[] | undefined, customInput: string | undefined): string;
|
|
69
|
+
/**
|
|
70
|
+
* Durable round identity. Prefer `interview_id + round_id`; fall back to
|
|
71
|
+
* `interview_id + round + question.id` when no caller-supplied `round_id` exists.
|
|
72
|
+
*/
|
|
73
|
+
export declare function deriveRoundKey(interviewId: string | undefined, input: {
|
|
74
|
+
round_id?: string;
|
|
75
|
+
round: number;
|
|
76
|
+
questionId?: string;
|
|
77
|
+
}): string;
|
|
78
|
+
/**
|
|
79
|
+
* Canonicalize a deep-interview envelope: interview data nested under `state`,
|
|
80
|
+
* legacy flattened fields hoisted in losslessly, transcript duplicates removed
|
|
81
|
+
* from the top level, and `rounds`/`established_facts` guaranteed to be arrays.
|
|
82
|
+
*
|
|
83
|
+
* Idempotent: a canonical envelope is returned unchanged in shape. Never deletes
|
|
84
|
+
* unknown envelope or nested fields, and never mutates the input.
|
|
85
|
+
*/
|
|
86
|
+
export declare function normalizeDeepInterviewEnvelope(value: unknown): DeepInterviewStateEnvelope;
|
|
87
|
+
/**
|
|
88
|
+
* Lossless, idempotent merge of two round arrays.
|
|
89
|
+
*
|
|
90
|
+
* - Records sharing a durable key (`round_key`, or synthesized from
|
|
91
|
+
* `round_id`/`question_id`) merge into one, preferring scored over answered.
|
|
92
|
+
* - Records without any durable identity are preserved verbatim; an exact
|
|
93
|
+
* duplicate is skipped so repeated writes stay idempotent, but distinct records
|
|
94
|
+
* are never collapsed.
|
|
95
|
+
*
|
|
96
|
+
* Deliberate refinement of the approved plan: rather than mutating opaque legacy
|
|
97
|
+
* records with synthetic `legacy:<index>` keys, they are preserved verbatim with
|
|
98
|
+
* exact-duplicate dedupe. This satisfies the plan's intent (lossless, idempotent,
|
|
99
|
+
* never collapse distinct rounds) without rewriting user-supplied round objects,
|
|
100
|
+
* and keeps free-form extension preservation intact. Recorder-produced records
|
|
101
|
+
* always carry a `round_key`, so the synthetic path is unnecessary in practice.
|
|
102
|
+
*/
|
|
103
|
+
export declare function mergeDeepInterviewRounds(existing: readonly Record<string, unknown>[], incoming: readonly Record<string, unknown>[]): Record<string, unknown>[];
|
|
104
|
+
/**
|
|
105
|
+
* Deep-interview-specific envelope merge. Unlike the generic shallow null-delete
|
|
106
|
+
* merge, this keeps interview data nested under `state`, never deletes `state`,
|
|
107
|
+
* and merges `rounds` losslessly by durable key so a partial write (e.g. a
|
|
108
|
+
* scoring update) cannot drop recorder-written transcript history.
|
|
109
|
+
*/
|
|
110
|
+
export declare function mergeDeepInterviewEnvelope(existing: unknown, incoming: unknown, options?: {
|
|
111
|
+
replace?: boolean;
|
|
112
|
+
}): DeepInterviewStateEnvelope;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text rendering for `gjc gc` reports. JSON output is produced directly in
|
|
3
|
+
* `gc-runtime.ts`; this module owns the human-readable grouped report.
|
|
4
|
+
*/
|
|
5
|
+
import type { GcReport } from "./gc-runtime";
|
|
6
|
+
export declare function buildGcReportText(report: GcReport): string;
|