@gajae-code/coding-agent 0.17.4 → 0.17.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/dist/types/config/autorouting-tier-map.d.ts +1031 -3
  3. package/dist/types/config/file-lock.d.ts +4 -2
  4. package/dist/types/config/model-registry.d.ts +3 -1
  5. package/dist/types/config/model-resolver.d.ts +1 -1
  6. package/dist/types/exec/bash-executor.d.ts +2 -0
  7. package/dist/types/extensibility/gjc-plugins/runtime-adapters.d.ts +11 -2
  8. package/dist/types/gjc-runtime/state-writer.d.ts +14 -1
  9. package/dist/types/harness-control-plane/control-endpoint.d.ts +4 -1
  10. package/dist/types/harness-control-plane/finalize.d.ts +14 -3
  11. package/dist/types/main.d.ts +1 -1
  12. package/dist/types/runtime-mcp/loader.d.ts +2 -0
  13. package/dist/types/runtime-mcp/manager.d.ts +13 -6
  14. package/dist/types/sdk/broker/broker.d.ts +4 -2
  15. package/dist/types/sdk/broker/ensure.d.ts +3 -0
  16. package/dist/types/sdk/broker/identity.d.ts +2 -0
  17. package/dist/types/sdk/broker/managed-task-dag.d.ts +1335 -0
  18. package/dist/types/sdk/broker/managed-task-verification.d.ts +37 -0
  19. package/dist/types/sdk/broker/spawn-authority.d.ts +8 -0
  20. package/dist/types/sdk/broker/startup-failure.d.ts +4 -0
  21. package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +5 -1
  22. package/dist/types/sdk/prompt-deadline-flush.d.ts +2 -0
  23. package/dist/types/sdk/session.d.ts +3 -3
  24. package/dist/types/session/agent-session.d.ts +7 -2
  25. package/dist/types/task/types.d.ts +2 -0
  26. package/dist/types/tools/bash-interactive.d.ts +1 -0
  27. package/dist/types/tools/fetch.d.ts +10 -1
  28. package/dist/types/tools/subagent.d.ts +8 -1
  29. package/package.json +7 -7
  30. package/src/cli/public-command-registry.ts +8 -2
  31. package/src/cli/setup-cli.ts +1 -0
  32. package/src/cli/stats-cli.ts +11 -1
  33. package/src/config/autorouting-tier-map.ts +529 -3
  34. package/src/config/file-lock.ts +59 -14
  35. package/src/config/model-discovery-manager.ts +4 -4
  36. package/src/config/model-profile-activation.ts +83 -23
  37. package/src/config/model-registry.ts +72 -12
  38. package/src/config/model-resolver.ts +6 -1
  39. package/src/coordinator-mcp/question-state.ts +4 -1
  40. package/src/coordinator-mcp/server.ts +14 -6
  41. package/src/exec/bash-executor.ts +3 -0
  42. package/src/extensibility/gjc-plugins/runtime-adapters.ts +46 -8
  43. package/src/gjc-runtime/state-writer.ts +317 -6
  44. package/src/harness-control-plane/control-endpoint.ts +24 -6
  45. package/src/harness-control-plane/finalize.ts +312 -25
  46. package/src/harness-control-plane/owner.ts +323 -89
  47. package/src/internal-urls/docs-index.generated.ts +6 -4
  48. package/src/main.ts +69 -19
  49. package/src/modes/acp/acp-agent.ts +581 -37
  50. package/src/modes/components/gjc-bundle-settings.ts +21 -1
  51. package/src/modes/components/tool-status-header.ts +72 -6
  52. package/src/modes/controllers/runtime-mcp-command-controller.ts +1 -1
  53. package/src/runtime-mcp/loader.ts +6 -3
  54. package/src/runtime-mcp/manager.ts +177 -75
  55. package/src/sdk/broker/broker.ts +1057 -150
  56. package/src/sdk/broker/ensure.ts +21 -3
  57. package/src/sdk/broker/identity.ts +13 -0
  58. package/src/sdk/broker/managed-task-dag.ts +1927 -0
  59. package/src/sdk/broker/managed-task-verification.ts +642 -0
  60. package/src/sdk/broker/spawn-authority.ts +140 -7
  61. package/src/sdk/broker/startup-failure.ts +80 -1
  62. package/src/sdk/broker/transport.ts +1 -0
  63. package/src/sdk/bus/chat-daemon-control.ts +2 -2
  64. package/src/sdk/bus/index.ts +22 -6
  65. package/src/sdk/bus/telegram-daemon-contract.ts +5 -1
  66. package/src/sdk/cli/session-cli.ts +18 -0
  67. package/src/sdk/host/session-runtime.test.ts +46 -0
  68. package/src/sdk/host/session-runtime.ts +13 -6
  69. package/src/sdk/lifecycle/service.ts +2 -0
  70. package/src/sdk/prompt-deadline-flush.ts +26 -4
  71. package/src/sdk/session.ts +587 -115
  72. package/src/session/agent-session.ts +40 -12
  73. package/src/session/internal/managed-session-scope.ts +10 -0
  74. package/src/session/internal/managed-session-storage.ts +30 -1
  75. package/src/setup/provider-presets.json +2 -1
  76. package/src/slash-commands/builtin-registry.ts +1 -1
  77. package/src/task/executor.ts +46 -17
  78. package/src/task/types.ts +2 -0
  79. package/src/tools/bash-interactive.ts +2 -0
  80. package/src/tools/bash.ts +20 -0
  81. package/src/tools/fetch.ts +21 -5
  82. package/src/tools/subagent-render.ts +24 -1
  83. package/src/tools/subagent.ts +27 -1
  84. package/src/utils/mupdf.ts +11 -4
@@ -18,13 +18,25 @@ import {
18
18
  resolveSdkInternalSpawnCommand,
19
19
  type SdkInternalSpawnCommand,
20
20
  } from "./runtime";
21
- import { BrokerStartupError, clearBrokerStartupFailureMarker, readBrokerStartupFailureMarker } from "./startup-failure";
21
+ import {
22
+ BrokerStartupError,
23
+ type BrokerStartupFailureMarker,
24
+ brokerStartupFailureCleanupTargetsLock,
25
+ clearBrokerStartupFailureMarker,
26
+ readBrokerStartupFailureMarker,
27
+ } from "./startup-failure";
22
28
 
23
29
  function resolveExpectedBrokerGeneration(): string {
24
30
  const v = (packageJson as { version?: unknown }).version;
25
31
  return typeof v === "string" && v.length > 0 ? v : "unknown";
26
32
  }
27
33
 
34
+ function brokerStartupFailureReason(marker: BrokerStartupFailureMarker | undefined): string {
35
+ if (!marker) return "Detached SDK broker exited before publishing discovery.";
36
+ if (marker.cleanupCommand && marker.reason.endsWith(": ")) return `${marker.reason}${marker.cleanupCommand}`;
37
+ return marker.reason;
38
+ }
39
+
28
40
  export function isBrokerGenerationCompatible(discovery: BrokerDiscovery | null): boolean {
29
41
  if (!discovery) return false;
30
42
  return discovery.packageGeneration === resolveExpectedBrokerGeneration();
@@ -712,7 +724,8 @@ async function ensureBrokerOnce(settings: EnsureBrokerSettings, initiator: Ensur
712
724
  const startupLockPath = path.join(settings.agentDir, "sdk", STARTUP_LOCK_TARGET_NAME);
713
725
  let startupFenceContention =
714
726
  exitedBeforeDiscovery &&
715
- trustedMarker?.reason.startsWith(`Failed to acquire lock for ${startupLockPath} after `) === true;
727
+ (trustedMarker?.reason.startsWith(`Failed to acquire lock for ${startupLockPath} after `) === true ||
728
+ brokerStartupFailureCleanupTargetsLock(trustedMarker, `${startupLockPath}.lock`));
716
729
  if (!startupFenceContention && exitedBeforeDiscovery && child.exitCode !== 0) {
717
730
  try {
718
731
  startupFenceContention = (await fs.stat(`${startupLockPath}.lock`)).isDirectory();
@@ -760,7 +773,7 @@ async function ensureBrokerOnce(settings: EnsureBrokerSettings, initiator: Ensur
760
773
  ? new BrokerStartupError({
761
774
  exitCode: child.exitCode,
762
775
  signal: child.signalCode,
763
- reason: trustedMarker?.reason ?? "Detached SDK broker exited before publishing discovery.",
776
+ reason: brokerStartupFailureReason(trustedMarker),
764
777
  stderrExcerpt: spawnLogTail.length > 0 ? spawnLogTail : undefined,
765
778
  })
766
779
  : discoveryError
@@ -889,3 +902,8 @@ export function registerBrokerOwnerForTest(
889
902
  ): BrokerOwner {
890
903
  return registerBrokerOwner(agentDir, child, timing);
891
904
  }
905
+
906
+ /** Test hook: exercises the same trusted-marker reason reconstruction used by ensureBroker. */
907
+ export function brokerStartupFailureReasonForTest(marker: BrokerStartupFailureMarker | undefined): string {
908
+ return brokerStartupFailureReason(marker);
909
+ }
@@ -51,6 +51,19 @@ export async function deriveIdempotencyIdentity(
51
51
  .digest("hex");
52
52
  }
53
53
 
54
+ /** Native identity for an idempotency key reserved inside one managed control root. */
55
+ export async function deriveScopedIdempotencyIdentity(
56
+ agentDir: string,
57
+ operation: string,
58
+ callerKey: string,
59
+ scope: string,
60
+ ): Promise<string> {
61
+ const key = await getBrokerIdentityKey(agentDir);
62
+ return createHmac("sha256", Buffer.from(key, "hex"))
63
+ .update(JSON.stringify(["managed-spawn-v1", operation, callerKey, scope]))
64
+ .digest("hex");
65
+ }
66
+
54
67
  /** Identity format used by lifecycle rows written before target binding. */
55
68
  export async function deriveLegacyIdentity(agentDir: string, operation: string, callerKey: string): Promise<string> {
56
69
  const key = await getBrokerIdentityKey(agentDir);