@gajae-code/coding-agent 0.7.2 → 0.7.4

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 (154) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/bin/gjc.js +4 -0
  3. package/dist/types/cli/mcp-cli.d.ts +25 -0
  4. package/dist/types/cli/plugin-cli.d.ts +2 -0
  5. package/dist/types/cli.d.ts +6 -0
  6. package/dist/types/commands/mcp.d.ts +70 -0
  7. package/dist/types/commands/plugin.d.ts +6 -0
  8. package/dist/types/commands/session.d.ts +6 -0
  9. package/dist/types/config/keybindings.d.ts +2 -2
  10. package/dist/types/config/model-profile-activation.d.ts +8 -1
  11. package/dist/types/deep-interview/plaintext-gate-guard.d.ts +11 -0
  12. package/dist/types/extensibility/gjc-plugins/compiler.d.ts +19 -0
  13. package/dist/types/extensibility/gjc-plugins/constrained-hooks.d.ts +29 -0
  14. package/dist/types/extensibility/gjc-plugins/index.d.ts +9 -0
  15. package/dist/types/extensibility/gjc-plugins/injection.d.ts +9 -0
  16. package/dist/types/extensibility/gjc-plugins/installer.d.ts +13 -0
  17. package/dist/types/extensibility/gjc-plugins/mcp-policy.d.ts +26 -0
  18. package/dist/types/extensibility/gjc-plugins/observability.d.ts +27 -0
  19. package/dist/types/extensibility/gjc-plugins/prompt-appendix.d.ts +16 -0
  20. package/dist/types/extensibility/gjc-plugins/registry.d.ts +32 -0
  21. package/dist/types/extensibility/gjc-plugins/runtime-adapters.d.ts +64 -0
  22. package/dist/types/extensibility/gjc-plugins/session-validation.d.ts +42 -0
  23. package/dist/types/extensibility/gjc-plugins/types.d.ts +158 -2
  24. package/dist/types/extensibility/gjc-plugins/validation.d.ts +8 -1
  25. package/dist/types/gjc-runtime/launch-tmux.d.ts +1 -0
  26. package/dist/types/gjc-runtime/psmux-detect.d.ts +78 -0
  27. package/dist/types/gjc-runtime/team-runtime.d.ts +2 -0
  28. package/dist/types/gjc-runtime/tmux-common.d.ts +20 -1
  29. package/dist/types/gjc-runtime/tmux-sessions.d.ts +18 -0
  30. package/dist/types/main.d.ts +2 -0
  31. package/dist/types/modes/components/custom-editor.d.ts +1 -1
  32. package/dist/types/modes/components/model-selector.d.ts +8 -0
  33. package/dist/types/modes/components/status-line/git-utils.d.ts +6 -0
  34. package/dist/types/modes/theme/defaults/index.d.ts +99 -0
  35. package/dist/types/notifications/html-format.d.ts +11 -0
  36. package/dist/types/notifications/index.d.ts +149 -1
  37. package/dist/types/notifications/lifecycle-commands.d.ts +72 -0
  38. package/dist/types/notifications/lifecycle-control-runtime.d.ts +98 -0
  39. package/dist/types/notifications/lifecycle-orchestrator.d.ts +144 -0
  40. package/dist/types/notifications/operator-runtime.d.ts +52 -0
  41. package/dist/types/notifications/rate-limit-pool.d.ts +2 -0
  42. package/dist/types/notifications/recent-activity.d.ts +35 -0
  43. package/dist/types/notifications/telegram-daemon.d.ts +114 -16
  44. package/dist/types/notifications/telegram-reference.d.ts +3 -1
  45. package/dist/types/notifications/topic-registry.d.ts +12 -9
  46. package/dist/types/runtime-mcp/types.d.ts +7 -0
  47. package/dist/types/sdk.d.ts +2 -0
  48. package/dist/types/session/agent-session.d.ts +14 -4
  49. package/dist/types/session/blob-store.d.ts +25 -0
  50. package/dist/types/session/session-manager.d.ts +57 -0
  51. package/dist/types/slash-commands/helpers/fast-status-report.d.ts +6 -0
  52. package/dist/types/system-prompt.d.ts +2 -0
  53. package/dist/types/task/executor.d.ts +9 -1
  54. package/dist/types/tools/composer-bash-policy.d.ts +14 -0
  55. package/dist/types/tools/index.d.ts +3 -1
  56. package/dist/types/utils/changelog.d.ts +1 -0
  57. package/dist/types/web/insane/url-guard.d.ts +6 -3
  58. package/dist/types/web/scrapers/types.d.ts +5 -0
  59. package/dist/types/web/scrapers/utils.d.ts +7 -1
  60. package/package.json +11 -9
  61. package/scripts/g004-tmux-smoke.ts +100 -0
  62. package/scripts/g005-daemon-smoke.ts +181 -0
  63. package/scripts/g011-daemon-path-smoke.ts +153 -0
  64. package/src/cli/mcp-cli.ts +272 -0
  65. package/src/cli/plugin-cli.ts +66 -3
  66. package/src/cli.ts +27 -6
  67. package/src/commands/mcp.ts +117 -0
  68. package/src/commands/plugin.ts +4 -0
  69. package/src/commands/session.ts +18 -0
  70. package/src/config/keybindings.ts +2 -2
  71. package/src/config/model-profile-activation.ts +55 -7
  72. package/src/deep-interview/plaintext-gate-guard.ts +94 -0
  73. package/src/defaults/gjc/extensions/grok-cli-vendor/biome.json +1 -1
  74. package/src/defaults/gjc/skills/deep-interview/SKILL.md +7 -6
  75. package/src/defaults/gjc/skills/team/SKILL.md +5 -3
  76. package/src/defaults/gjc/skills/ultragoal/SKILL.md +41 -13
  77. package/src/export/html/index.ts +2 -2
  78. package/src/extensibility/extensions/runner.ts +1 -0
  79. package/src/extensibility/gjc-plugins/compiler.ts +351 -0
  80. package/src/extensibility/gjc-plugins/constrained-hooks.ts +170 -0
  81. package/src/extensibility/gjc-plugins/index.ts +9 -0
  82. package/src/extensibility/gjc-plugins/injection.ts +109 -0
  83. package/src/extensibility/gjc-plugins/installer.ts +434 -0
  84. package/src/extensibility/gjc-plugins/loader.ts +3 -1
  85. package/src/extensibility/gjc-plugins/mcp-policy.ts +239 -0
  86. package/src/extensibility/gjc-plugins/observability.ts +84 -0
  87. package/src/extensibility/gjc-plugins/paths.ts +1 -1
  88. package/src/extensibility/gjc-plugins/prompt-appendix.ts +109 -0
  89. package/src/extensibility/gjc-plugins/registry.ts +180 -0
  90. package/src/extensibility/gjc-plugins/runtime-adapters.ts +234 -0
  91. package/src/extensibility/gjc-plugins/schema.ts +250 -20
  92. package/src/extensibility/gjc-plugins/session-validation.ts +147 -0
  93. package/src/extensibility/gjc-plugins/types.ts +199 -3
  94. package/src/extensibility/gjc-plugins/validation.ts +80 -0
  95. package/src/extensibility/skills.ts +15 -0
  96. package/src/gjc-runtime/launch-tmux.ts +61 -7
  97. package/src/gjc-runtime/psmux-detect.ts +239 -0
  98. package/src/gjc-runtime/team-runtime.ts +56 -23
  99. package/src/gjc-runtime/tmux-common.ts +30 -3
  100. package/src/gjc-runtime/tmux-sessions.ts +51 -1
  101. package/src/gjc-runtime/ultragoal-guard.ts +25 -8
  102. package/src/gjc-runtime/ultragoal-runtime.ts +75 -15
  103. package/src/hooks/skill-state.ts +57 -0
  104. package/src/internal-urls/docs-index.generated.ts +12 -8
  105. package/src/main.ts +14 -3
  106. package/src/modes/bridge/bridge-mode.ts +11 -0
  107. package/src/modes/components/custom-editor.ts +2 -0
  108. package/src/modes/components/footer.ts +2 -3
  109. package/src/modes/components/hook-editor.ts +1 -1
  110. package/src/modes/components/hook-selector.ts +67 -43
  111. package/src/modes/components/model-selector.ts +56 -11
  112. package/src/modes/components/status-line/git-utils.ts +25 -0
  113. package/src/modes/components/status-line.ts +10 -11
  114. package/src/modes/components/welcome.ts +2 -3
  115. package/src/modes/controllers/extension-ui-controller.ts +0 -27
  116. package/src/modes/controllers/selector-controller.ts +53 -11
  117. package/src/modes/interactive-mode.ts +4 -1
  118. package/src/modes/shared/agent-wire/scopes.ts +1 -1
  119. package/src/modes/theme/defaults/gruvbox-dark.json +99 -0
  120. package/src/modes/theme/defaults/index.ts +2 -0
  121. package/src/modes/utils/hotkeys-markdown.ts +1 -1
  122. package/src/notifications/html-format.ts +38 -0
  123. package/src/notifications/index.ts +242 -12
  124. package/src/notifications/lifecycle-commands.ts +228 -0
  125. package/src/notifications/lifecycle-control-runtime.ts +400 -0
  126. package/src/notifications/lifecycle-orchestrator.ts +358 -0
  127. package/src/notifications/operator-runtime.ts +171 -0
  128. package/src/notifications/rate-limit-pool.ts +19 -0
  129. package/src/notifications/recent-activity.ts +132 -0
  130. package/src/notifications/telegram-daemon.ts +778 -257
  131. package/src/notifications/telegram-reference.ts +25 -7
  132. package/src/notifications/topic-registry.ts +23 -9
  133. package/src/prompts/agents/executor.md +2 -2
  134. package/src/runtime-mcp/transports/stdio.ts +38 -4
  135. package/src/runtime-mcp/types.ts +7 -0
  136. package/src/sdk.ts +157 -10
  137. package/src/session/agent-session.ts +166 -74
  138. package/src/session/blob-store.ts +196 -8
  139. package/src/session/session-manager.ts +678 -7
  140. package/src/slash-commands/builtin-registry.ts +23 -3
  141. package/src/slash-commands/helpers/fast-status-report.ts +13 -3
  142. package/src/slash-commands/helpers/parse.ts +2 -1
  143. package/src/system-prompt.ts +9 -0
  144. package/src/task/executor.ts +31 -7
  145. package/src/task/index.ts +2 -0
  146. package/src/tools/ask.ts +5 -1
  147. package/src/tools/bash.ts +9 -0
  148. package/src/tools/composer-bash-policy.ts +96 -0
  149. package/src/tools/fetch.ts +18 -2
  150. package/src/tools/index.ts +3 -1
  151. package/src/utils/changelog.ts +8 -0
  152. package/src/web/insane/url-guard.ts +18 -14
  153. package/src/web/scrapers/types.ts +143 -45
  154. package/src/web/scrapers/utils.ts +70 -19
@@ -6,6 +6,7 @@ import { getOAuthProviders } from "@gajae-code/ai/utils/oauth";
6
6
  import { Spacer, Text } from "@gajae-code/tui";
7
7
  import { setProjectDir } from "@gajae-code/utils";
8
8
  import { jobElapsedMs } from "../async";
9
+ import { materializeActiveModelProfileAssignment } from "../config/model-profile-activation";
9
10
  import {
10
11
  GJC_MODEL_ASSIGNMENT_TARGET_IDS,
11
12
  GJC_MODEL_ASSIGNMENT_TARGETS,
@@ -298,6 +299,12 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<SlashCommandSpec> = [
298
299
  selector: selection.selector,
299
300
  thinkingLevel: selection.thinkingLevel,
300
301
  });
302
+ materializeActiveModelProfileAssignment({
303
+ session: runtime.session,
304
+ settings: runtime.settings,
305
+ role: parsedArgs.targetId,
306
+ selector: persistedSelector,
307
+ });
301
308
  if (selection.thinkingLevel) {
302
309
  runtime.session.setThinkingLevel(selection.thinkingLevel);
303
310
  }
@@ -316,10 +323,23 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<SlashCommandSpec> = [
316
323
  selection.thinkingLevel ??
317
324
  extractExplicitThinkingSelector(overrides[parsedArgs.targetId], runtime.settings);
318
325
  const roleSelector = formatModelSelectorValue(selection.selector, thinkingLevel);
319
- runtime.settings.set("task.agentModelOverrides", {
320
- ...overrides,
321
- [parsedArgs.targetId]: roleSelector,
326
+ const materializedProfile = materializeActiveModelProfileAssignment({
327
+ session: runtime.session,
328
+ settings: runtime.settings,
329
+ role: parsedArgs.targetId,
330
+ selector: roleSelector,
322
331
  });
332
+ if (!materializedProfile) {
333
+ const target = GJC_MODEL_ASSIGNMENT_TARGETS[parsedArgs.targetId];
334
+ if (target.settingsPath === "modelRoles") {
335
+ runtime.settings.setModelRole(parsedArgs.targetId, roleSelector);
336
+ } else {
337
+ runtime.settings.set("task.agentModelOverrides", {
338
+ ...overrides,
339
+ [parsedArgs.targetId]: roleSelector,
340
+ });
341
+ }
342
+ }
323
343
  runtime.settings.getStorage()?.recordModelUsage(`${selection.model.provider}/${selection.model.id}`);
324
344
  await runtime.output(`${parsedArgs.targetId} agent model set to ${roleSelector}.`);
325
345
  }
@@ -56,6 +56,12 @@ export interface FastStatusSessionLike {
56
56
  readonly model?: Model;
57
57
  /** Fast predicate against the main session tier (current model + `modelRoles`). */
58
58
  isFastForProvider(provider?: string): boolean;
59
+ /**
60
+ * Current-model EFFECTIVE fast state (intent minus any provider auto-disable).
61
+ * Used for the current-model row so it matches what the next request does.
62
+ * Optional so lightweight fakes can omit it; falls back to `isFastForProvider`.
63
+ */
64
+ isFastModeActive?(): boolean;
59
65
  /** Fast predicate against the effective subagent tier (`task.agentModelOverrides` roles). */
60
66
  isFastForSubagentProvider(provider?: string): boolean;
61
67
  resolveRoleModelWithThinking(role: string): { model?: Model };
@@ -95,9 +101,13 @@ export interface BuildFastStatusReportArgs {
95
101
  */
96
102
  export function buildFastStatusReport(args: BuildFastStatusReportArgs): string {
97
103
  const { session, roleTargets, iconFast, formatInactive } = args;
98
- const rows: FastStatusRow[] = [
99
- { label: "현재 모델", model: session.model, fast: session.isFastForProvider(session.model?.provider) },
100
- ];
104
+ // Current-model row uses the EFFECTIVE predicate (intent minus any provider
105
+ // auto-disable) so it matches the next request; `modelRoles` rows below stay
106
+ // on pure intent. Fall back to intent when a fake omits `isFastModeActive`.
107
+ const currentFast = session.isFastModeActive
108
+ ? session.isFastModeActive()
109
+ : session.isFastForProvider(session.model?.provider);
110
+ const rows: FastStatusRow[] = [{ label: "현재 모델", model: session.model, fast: currentFast }];
101
111
  for (const target of roleTargets) {
102
112
  const resolved = session.resolveRoleModelWithThinking(target.id);
103
113
  if (resolved.model) {
@@ -1,3 +1,4 @@
1
+ import { parseCommandArgs } from "../../utils/command-args";
1
2
  import type { ParsedSlashCommand, SlashCommandResult, SlashCommandRuntime } from "../types";
2
3
 
3
4
  export interface ParsedSubcommand {
@@ -65,7 +66,7 @@ export function errorMessage(error: unknown): string {
65
66
  * "name required" diagnostics with their own messaging.
66
67
  */
67
68
  export function parseNamedScopeArgs(rest: string, invalidScopeMessage: string): NamedScopeArgs {
68
- const tokens = rest.split(/\s+/).filter(Boolean);
69
+ const tokens = parseCommandArgs(rest);
69
70
  let name: string | undefined;
70
71
  let scope: ConfigScope = "project";
71
72
  let i = 0;
@@ -336,6 +336,8 @@ export interface BuildSystemPromptOptions {
336
336
  toolNames?: string[];
337
337
  /** Text to append to system prompt. */
338
338
  appendSystemPrompt?: string;
339
+ /** Rendered GJC plugin system-appendix blocks (lower-authority, appended last). */
340
+ pluginAppendices?: string;
339
341
  /** Repeat full tool descriptions in system prompt. Default: false */
340
342
  repeatToolDescriptions?: boolean;
341
343
  /** Skills settings for discovery. */
@@ -380,6 +382,7 @@ export async function buildSystemPrompt(options: BuildSystemPromptOptions = {}):
380
382
  customPrompt,
381
383
  tools,
382
384
  appendSystemPrompt,
385
+ pluginAppendices,
383
386
  repeatToolDescriptions = false,
384
387
  skillsSettings,
385
388
  toolNames: providedToolNames,
@@ -579,5 +582,11 @@ export async function buildSystemPrompt(options: BuildSystemPromptOptions = {}):
579
582
  systemPrompt.push(projectPrompt);
580
583
  }
581
584
 
585
+ // Plugin system appendices are appended last as a lower-authority block; they
586
+ // can never override base/project/developer instructions above them.
587
+ if (pluginAppendices?.trim()) {
588
+ systemPrompt.push(pluginAppendices.trim());
589
+ }
590
+
582
591
  return { systemPrompt };
583
592
  }
@@ -9,6 +9,7 @@ import * as fs from "node:fs/promises";
9
9
  import path from "node:path";
10
10
  import type { AgentEvent, AgentIdentity, AgentTelemetryConfig, ThinkingLevel } from "@gajae-code/agent-core";
11
11
  import { recordHandoff, resolveTelemetry } from "@gajae-code/agent-core";
12
+ import type { ServiceTier } from "@gajae-code/ai";
12
13
  import { type JsonSchemaValidationIssue, validateJsonSchemaValue } from "@gajae-code/ai/utils/schema";
13
14
  import { logger, prompt, untilAborted } from "@gajae-code/utils";
14
15
  import { AsyncJobManager } from "../async";
@@ -19,7 +20,7 @@ import { Settings } from "../config/settings";
19
20
  import { SETTINGS_SCHEMA, type SettingPath } from "../config/settings-schema";
20
21
  import { runExtensionCompact, runExtensionSetModel } from "../extensibility/extensions/compact-handler";
21
22
  import { getSessionSlashCommands } from "../extensibility/extensions/get-commands-handler";
22
- import { buildAgentSubskillInjection } from "../extensibility/gjc-plugins";
23
+ import { buildAgentSubskillInjection, renderAgentPromptAdditions } from "../extensibility/gjc-plugins";
23
24
  import { buildSkillPromptMessage, type Skill } from "../extensibility/skills";
24
25
  import type { HindsightSessionState } from "../hindsight/state";
25
26
  import type { LocalProtocolOptions } from "../internal-urls";
@@ -146,6 +147,13 @@ export interface ExecutorOptions {
146
147
  authStorage?: AuthStorage;
147
148
  modelRegistry?: ModelRegistry;
148
149
  settings?: Settings;
150
+ /**
151
+ * Live service-tier intent of the parent session (`AgentSession.serviceTier`),
152
+ * used as the inherited tier when `task.serviceTier === "inherit"`. Passing the
153
+ * live value (not the stale settings snapshot) lets a runtime `/fast on` reach
154
+ * subagents, and a main-model fast-mode auto-disable does not clobber it.
155
+ */
156
+ inheritedServiceTier?: ServiceTier;
149
157
  /** Override local:// protocol options so subagent shares parent's local:// root */
150
158
  localProtocolOptions?: LocalProtocolOptions;
151
159
  /**
@@ -482,15 +490,19 @@ function getUsageTokens(usage: unknown): number {
482
490
  return firstNumberField(record, ["totalTokens", "total_tokens"]) ?? 0;
483
491
  }
484
492
 
485
- export function createSubagentSettings(baseSettings: Settings): Settings {
493
+ export function createSubagentSettings(baseSettings: Settings, inheritedServiceTier?: ServiceTier): Settings {
486
494
  const snapshot: Partial<Record<SettingPath, unknown>> = {};
487
495
  for (const key of Object.keys(SETTINGS_SCHEMA) as SettingPath[]) {
488
496
  snapshot[key] = baseSettings.get(key);
489
497
  }
490
- // Subagent-scoped service-tier override: "inherit" keeps the snapshotted main
491
- // session tier; any explicit value applies only to subagent sessions.
498
+ // Subagent-scoped service-tier override: "inherit" uses the parent session's
499
+ // LIVE intent (so a runtime `/fast on` reaches subagents and a main-model
500
+ // fast-mode auto-disable never clobbers it); any explicit value applies only
501
+ // to subagent sessions and wins over inherited intent.
492
502
  const taskServiceTier = baseSettings.get("task.serviceTier");
493
- if (taskServiceTier !== "inherit") {
503
+ if (taskServiceTier === "inherit") {
504
+ snapshot.serviceTier = inheritedServiceTier ?? "none";
505
+ } else {
494
506
  snapshot.serviceTier = taskServiceTier;
495
507
  }
496
508
  return Settings.isolated({
@@ -571,7 +583,7 @@ export async function runSubprocess(options: ExecutorOptions): Promise<SingleRes
571
583
  }
572
584
 
573
585
  const settings = options.settings ?? Settings.isolated();
574
- const subagentSettings = createSubagentSettings(settings);
586
+ const subagentSettings = createSubagentSettings(settings, options.inheritedServiceTier);
575
587
  const maxRecursionDepth = settings.get("task.maxRecursionDepth") ?? 2;
576
588
  const maxRuntimeMs = Math.max(0, Math.trunc(Number(settings.get("task.maxRuntimeMs") ?? 0) || 0));
577
589
  const parentDepth = options.taskDepth ?? 0;
@@ -1229,6 +1241,13 @@ export async function runSubprocess(options: ExecutorOptions): Promise<SingleRes
1229
1241
  agentName: agent.name,
1230
1242
  });
1231
1243
 
1244
+ let agentPromptAdditions = { appendix: "", advertisement: "" };
1245
+ try {
1246
+ agentPromptAdditions = await renderAgentPromptAdditions({ cwd, agentName: agent.name });
1247
+ } catch (error) {
1248
+ logger.warn("Failed to render GJC plugin agent prompt additions", { error });
1249
+ }
1250
+
1232
1251
  const { session } = await awaitAbortable(
1233
1252
  createAgentSession({
1234
1253
  cwd: worktree ?? cwd,
@@ -1259,7 +1278,12 @@ export async function runSubprocess(options: ExecutorOptions): Promise<SingleRes
1259
1278
  ircSelfId: ircEnabled ? id : "",
1260
1279
  forkContext: forkContextNotice,
1261
1280
  });
1262
- const promptWithSubskills = `${subagentPrompt}${agentSubskillBlock}`;
1281
+ // Order: base agent prompt -> agent appendix -> Tier-1 advertisement -> Tier-2 body.
1282
+ const appendixPart = agentPromptAdditions.appendix ? `\n\n${agentPromptAdditions.appendix}` : "";
1283
+ const advertPart = agentPromptAdditions.advertisement
1284
+ ? `\n\n${agentPromptAdditions.advertisement}`
1285
+ : "";
1286
+ const promptWithSubskills = `${subagentPrompt}${appendixPart}${advertPart}${agentSubskillBlock}`;
1263
1287
  return defaultPrompt.length === 0
1264
1288
  ? [promptWithSubskills]
1265
1289
  : [...defaultPrompt.slice(0, -1), promptWithSubskills, defaultPrompt[defaultPrompt.length - 1]];
package/src/task/index.ts CHANGED
@@ -1311,6 +1311,7 @@ export class TaskTool implements AgentTool<TaskToolSchemaInstance, TaskToolDetai
1311
1311
  authStorage: this.session.authStorage,
1312
1312
  modelRegistry: this.session.modelRegistry,
1313
1313
  settings: this.session.settings,
1314
+ inheritedServiceTier: this.session.serviceTier,
1314
1315
  contextFiles,
1315
1316
  skills: availableSkills,
1316
1317
  autoloadSkills: resolvedAutoloadSkills,
@@ -1372,6 +1373,7 @@ export class TaskTool implements AgentTool<TaskToolSchemaInstance, TaskToolDetai
1372
1373
  authStorage: this.session.authStorage,
1373
1374
  modelRegistry: this.session.modelRegistry,
1374
1375
  settings: this.session.settings,
1376
+ inheritedServiceTier: this.session.serviceTier,
1375
1377
  contextFiles,
1376
1378
  skills: availableSkills,
1377
1379
  autoloadSkills: resolvedAutoloadSkills,
package/src/tools/ask.ts CHANGED
@@ -260,7 +260,11 @@ async function askSingleQuestion(
260
260
  ? "up/down navigate enter select ←/→ question esc cancel"
261
261
  : "up/down navigate enter select esc cancel";
262
262
  const helpText =
263
- scrollTitleRows === undefined ? baseHelpText : `${baseHelpText} wheel/PgUp/PgDn scroll question`;
263
+ scrollTitleRows === undefined
264
+ ? baseHelpText
265
+ : navigation
266
+ ? "↑/↓ select enter ←/→ question esc PgUp/PgDn/Ctrl+u/d: question · Wheel: transcript"
267
+ : "↑/↓ select enter esc PgUp/PgDn/Ctrl+u/d: question · Wheel: transcript";
264
268
  const dialogOptions = {
265
269
  initialIndex,
266
270
  timeout,
package/src/tools/bash.ts CHANGED
@@ -25,6 +25,7 @@ import { type BashInteractiveResult, runInteractiveBashPty } from "./bash-intera
25
25
  import { checkBashInterception } from "./bash-interceptor";
26
26
  import { canUseInteractiveBashPty } from "./bash-pty-selection";
27
27
  import { expandInternalUrls, type InternalUrlExpansionOptions } from "./bash-skill-urls";
28
+ import { checkComposerBashPolicy } from "./composer-bash-policy";
28
29
  import { formatStyledTruncationWarning, type OutputMeta, stripOutputNotice } from "./output-meta";
29
30
  import { resolveToCwd } from "./path-utils";
30
31
  import { formatToolWorkingDirectory, replaceTabs } from "./render-utils";
@@ -570,6 +571,14 @@ export class BashTool implements AgentTool<BashToolSchema, BashToolDetails> {
570
571
  }
571
572
  }
572
573
 
574
+ const composerPolicy = checkComposerBashPolicy({
575
+ modelId: this.session.getActiveModelString?.() ?? this.session.getModelString?.() ?? this.session.model?.id,
576
+ commands: rawCommand === command ? [command] : [rawCommand, command],
577
+ });
578
+ if (!composerPolicy.allowed) {
579
+ throw new ToolError(composerPolicy.message);
580
+ }
581
+
573
582
  const internalUrlOptions: InternalUrlExpansionOptions = {
574
583
  skills: this.session.skills ?? [],
575
584
  internalRouter: InternalUrlRouter.instance(),
@@ -0,0 +1,96 @@
1
+ import { isComposerHarnessModel } from "@gajae-code/ai/providers/composer-discipline";
2
+
3
+ export const COMPOSER_BASH_POLICY_ERROR =
4
+ "Composer bash policy blocked repository file I/O. Use find, search, read, and edit tools for file discovery, file inspection, and file mutation.";
5
+
6
+ type ComposerBashPolicyResult =
7
+ | { allowed: true }
8
+ | {
9
+ allowed: false;
10
+ reason: string;
11
+ message: string;
12
+ };
13
+
14
+ const BLOCK_PATTERNS: Array<{ id: string; pattern: RegExp }> = [
15
+ { id: "pipe", pattern: /\|/ },
16
+ { id: "process-substitution", pattern: /<[>(]/ },
17
+ { id: "heredoc", pattern: /<<[-~]?/ },
18
+ { id: "command-substitution", pattern: /\$\(|`/ },
19
+ { id: "redirection", pattern: /(^|[^<>])(?:>>?|<)(?!=)/ },
20
+ { id: "tee", pattern: /(?:^|[;&|\s])tee(?:\s|$)/ },
21
+ {
22
+ id: "shell-file-read-discovery",
23
+ pattern: /(?:^|[;&|()\s])(?:\S*\/)?(?:cat|head|tail|less|more|grep|rg|find|fd|tree|ls)\b/,
24
+ },
25
+ {
26
+ id: "shell-file-mutation",
27
+ pattern: /(?:^|[;&|()\s])(?:\S*\/)?(?:cp|mv|rm|touch|mkdir|chmod|chown|ln)\b/,
28
+ },
29
+ { id: "sed-print", pattern: /(?:^|[;&|()\s])sed\s+(?:-[^\s]*n\b|.*\bp\b)/ },
30
+ { id: "awk-print", pattern: /(?:^|[;&|()\s])awk\b/ },
31
+ { id: "git-ls-files", pattern: /(?:^|[;&|()\s])git(?:\s+-C\s+\S+)?\s+ls-files\b/ },
32
+ { id: "git-grep", pattern: /(?:^|[;&|()\s])git(?:\s+-C\s+\S+)?\s+grep\b/ },
33
+ { id: "git-show-path", pattern: /(?:^|[;&|()\s])git(?:\s+-C\s+\S+)?\s+show\s+\S+:\S+/ },
34
+ { id: "git-diff", pattern: /(?:^|[;&|()\s])git(?:\s+-C\s+\S+)?\s+diff(?:\s|$)/ },
35
+ { id: "git-cat-file", pattern: /(?:^|[;&|()\s])git(?:\s+-C\s+\S+)?\s+cat-file\b/ },
36
+ {
37
+ id: "git-show-discovery",
38
+ pattern: /(?:^|[;&|()\s])git(?:\s+-C\s+\S+)?\s+show\b.*(?:--name-only|--name-status|--stat)/,
39
+ },
40
+ {
41
+ id: "git-log-path-discovery",
42
+ pattern: /(?:^|[;&|()\s])git(?:\s+-C\s+\S+)?\s+log\b.*(?:--name-only|--name-status|--stat)/,
43
+ },
44
+ { id: "sed-in-place", pattern: /(?:^|[;&|()\s])sed\s+-[^\s]*i\b/ },
45
+ { id: "perl-in-place", pattern: /(?:^|[;&|()\s])perl\s+-[^\s]*p[^\s]*i\b/ },
46
+ {
47
+ id: "script-file-io",
48
+ pattern:
49
+ /(?:^|[;&|()\s])(?:python3?|node|bun)\s+(?:-\s*<<|-c\b|-e\b|--eval\b).*?(?:read_text|read_bytes|write_text|iterdir|listdir|glob\.glob|readFile|readFileSync|writeFile|writeFileSync|readdir|readdirSync|stat|statSync|cpSync|rmSync|mkdirSync|createReadStream|createWriteStream|Bun\.file|Bun\.write|fs\.readFile|fs\.writeFile|fs\.readdir|fs\.stat|fs\.cp|fs\.rm|fs\.mkdir|open\s*\()/s,
50
+ },
51
+ {
52
+ id: "contaminated-command",
53
+ pattern: /```|^\s*(?:I\s+(?:will|need|am going)|We\s+(?:need|will)|First[, ]|Now[, ]|Let's)\b/im,
54
+ },
55
+ ];
56
+
57
+ const ALLOWED_TERMINAL_PATTERNS: RegExp[] = [
58
+ /^bun\s+test(?:\s+[\w./:@=-]+)*$/,
59
+ /^bun\s+run\s+(?:check(?::[\w-]+)?|test(?::[\w-]+)?|build(?::[\w-]+)?)(?:\s+[\w./:@=-]+)*$/,
60
+ /^bun\s+--version$/,
61
+ /^mise\s+x\s+bun@\d+\.\d+\.\d+\s+--\s+bun\s+test(?:\s+[\w./:@=-]+)*$/,
62
+ /^mise\s+x\s+bun@\d+\.\d+\.\d+\s+--\s+bun\s+run\s+(?:check(?::[\w-]+)?|test(?::[\w-]+)?|build(?::[\w-]+)?)(?:\s+[\w./:@=-]+)*$/,
63
+ /^cargo\s+(?:test|check|build)(?:\s+[\w./:@=-]+)*$/,
64
+ /^git\s+status(?:\s+--short)?(?:\s+--branch)?$/,
65
+ /^git\s+rev-parse\s+HEAD$/,
66
+ /^npm\s+--version$/,
67
+ /^pnpm\s+--version$/,
68
+ /^yarn\s+--version$/,
69
+ ];
70
+
71
+ function isAllowedComposerTerminalCommand(command: string): boolean {
72
+ const normalized = command.trim().replace(/\s+/g, " ");
73
+ return ALLOWED_TERMINAL_PATTERNS.some(pattern => pattern.test(normalized));
74
+ }
75
+
76
+ export function isComposerBashPolicyModel(modelId: string | undefined): boolean {
77
+ return Boolean(modelId && isComposerHarnessModel(modelId));
78
+ }
79
+
80
+ export function checkComposerBashPolicy(input: {
81
+ modelId?: string;
82
+ commands: readonly string[];
83
+ }): ComposerBashPolicyResult {
84
+ if (!isComposerBashPolicyModel(input.modelId)) return { allowed: true };
85
+ for (const command of input.commands) {
86
+ for (const block of BLOCK_PATTERNS) {
87
+ if (block.pattern.test(command)) {
88
+ return { allowed: false, reason: block.id, message: COMPOSER_BASH_POLICY_ERROR };
89
+ }
90
+ }
91
+ if (!isAllowedComposerTerminalCommand(command)) {
92
+ return { allowed: false, reason: "not-allowlisted", message: COMPOSER_BASH_POLICY_ERROR };
93
+ }
94
+ }
95
+ return { allowed: true };
96
+ }
@@ -17,7 +17,7 @@ import { CachedOutputBlock } from "../tui/output-block";
17
17
  import { formatDimensionNote, resizeImage } from "../utils/image-resize";
18
18
  import { ensureTool } from "../utils/tools-manager";
19
19
  import { INSANE_NOTES, tryInsaneFetch } from "../web/insane/bridge";
20
- import { validatePublicHttpUrlForInsane } from "../web/insane/url-guard";
20
+ import { validatePublicHttpUrl, validatePublicHttpUrlForInsane } from "../web/insane/url-guard";
21
21
  import { extractWithParallel, findParallelApiKey, getParallelExtractContent } from "../web/parallel";
22
22
  import { specialHandlers } from "../web/scrapers";
23
23
  import type { RenderResult } from "../web/scrapers/types";
@@ -789,6 +789,21 @@ async function renderUrl(
789
789
 
790
790
  // Step 0: Normalize URL (ensure scheme for special handlers)
791
791
  url = normalizeUrl(url);
792
+ const publicUrl = await validatePublicHttpUrl(url);
793
+ if (!publicUrl.ok) {
794
+ notes.push(`Blocked URL fetch: target URL is not public HTTP(S): ${publicUrl.reason}`);
795
+ return {
796
+ url,
797
+ finalUrl: url,
798
+ contentType: "unknown",
799
+ method: "failed",
800
+ content: "",
801
+ fetchedAt,
802
+ truncated: false,
803
+ notes,
804
+ };
805
+ }
806
+ url = publicUrl.url.toString();
792
807
 
793
808
  // Step 1: Try special handlers for known sites (unless raw mode)
794
809
  if (!raw) {
@@ -802,7 +817,8 @@ async function renderUrl(
802
817
  throw new ToolAbortError();
803
818
  }
804
819
  if (!response.ok) {
805
- const failureNote = response.status ? `Failed to fetch URL (HTTP ${response.status})` : "Failed to fetch URL";
820
+ const failureNote =
821
+ response.error ?? (response.status ? `Failed to fetch URL (HTTP ${response.status})` : "Failed to fetch URL");
806
822
  notes.push(failureNote);
807
823
  const insane = await tryInsaneFallback({
808
824
  url,
@@ -1,5 +1,5 @@
1
1
  import type { AgentTelemetryConfig, AgentTool } from "@gajae-code/agent-core";
2
- import type { Model, ToolChoice } from "@gajae-code/ai";
2
+ import type { Model, ServiceTier, ToolChoice } from "@gajae-code/ai";
3
3
  import { $env, $flag, logger } from "@gajae-code/utils";
4
4
  import type { PromptTemplate } from "../config/prompt-templates";
5
5
  import type { Settings } from "../config/settings";
@@ -222,6 +222,8 @@ export interface ToolSession {
222
222
  agentOutputManager?: AgentOutputManager;
223
223
  /** Settings instance for passing to subagents */
224
224
  settings: Settings;
225
+ /** Live service-tier intent of the parent session, inherited by `inherit` subagents. */
226
+ serviceTier?: ServiceTier;
225
227
  /** Plan mode state (if active) */
226
228
  getPlanModeState?: () => PlanModeState | undefined;
227
229
  /** Goal mode state (if active or paused) */
@@ -92,6 +92,14 @@ export function getDisplayChangelogEntries(): ChangelogEntry[] {
92
92
  return parseChangelogContent(CHANGELOG_TEXT);
93
93
  }
94
94
 
95
+ export function getInstalledVersionChangelogEntry(
96
+ entries: readonly ChangelogEntry[],
97
+ installedVersion: string,
98
+ ): ChangelogEntry | undefined {
99
+ const [major = 0, minor = 0, patch = 0] = installedVersion.split(".").map(Number);
100
+ return entries.find(entry => entry.major === major && entry.minor === minor && entry.patch === patch) ?? entries[0];
101
+ }
102
+
95
103
  /**
96
104
  * Compare versions. Returns: -1 if v1 < v2, 0 if v1 === v2, 1 if v1 > v2
97
105
  */
@@ -1,16 +1,13 @@
1
1
  /**
2
- * Public HTTP(S) URL guard for the insane-search read fallback.
2
+ * Public HTTP(S) URL guard for user-supplied web fetch targets.
3
3
  *
4
- * The vendored insane-search engine performs its own network requests (curl_cffi,
5
- * a real browser) entirely outside the TypeScript fetch path, so the normal
6
- * `loadPage()` flow cannot protect against SSRF. This guard MUST run before any
7
- * dependency probe or engine subprocess is spawned. It is fail-closed: anything
8
- * it cannot prove is a public, non-credentialed http/https target is rejected.
4
+ * Network-capable URL readers MUST run this guard before the first request and
5
+ * before following any redirect target. It is fail-closed: anything it cannot
6
+ * prove is a public, non-credentialed http/https target is rejected.
9
7
  *
10
- * It does NOT follow or re-validate redirects the engine may follow redirects
11
- * internally that this guard never sees. That residual risk is documented in the
12
- * plan and mitigated by validating the input target and keeping the feature
13
- * opt-in (default off).
8
+ * The vendored insane-search engine performs its own redirects outside the
9
+ * TypeScript fetch path, so its fallback remains opt-in and is guarded before
10
+ * any dependency probe or engine subprocess is spawned.
14
11
  */
15
12
  import * as dns from "node:dns/promises";
16
13
  import * as net from "node:net";
@@ -105,11 +102,11 @@ export function isPrivateOrSpecialAddress(address: string): boolean {
105
102
  }
106
103
 
107
104
  /**
108
- * Validate that `rawUrl` is a public http/https target safe to hand to the
109
- * insane-search engine. Resolves DNS names and rejects any that map to a
110
- * private/special address. Never throws; returns a discriminated result.
105
+ * Validate that `rawUrl` is a public http/https target. Resolves DNS names and
106
+ * rejects any that map to a private/special address. Never throws; returns a
107
+ * discriminated result.
111
108
  */
112
- export async function validatePublicHttpUrlForInsane(
109
+ export async function validatePublicHttpUrl(
113
110
  rawUrl: string,
114
111
  options: { resolver?: AddressResolver } = {},
115
112
  ): Promise<PublicUrlResult> {
@@ -153,3 +150,10 @@ export async function validatePublicHttpUrlForInsane(
153
150
  }
154
151
  return { ok: true, url, addresses };
155
152
  }
153
+
154
+ export async function validatePublicHttpUrlForInsane(
155
+ rawUrl: string,
156
+ options: { resolver?: AddressResolver } = {},
157
+ ): Promise<PublicUrlResult> {
158
+ return validatePublicHttpUrl(rawUrl, options);
159
+ }