@gajae-code/coding-agent 0.11.5 → 0.11.7

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 (138) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/types/capability/index.d.ts +10 -20
  3. package/dist/types/capability/types.d.ts +3 -0
  4. package/dist/types/commands/daemon.d.ts +2 -2
  5. package/dist/types/commands/sdk.d.ts +20 -2
  6. package/dist/types/config/keybindings.d.ts +1 -1
  7. package/dist/types/config/settings-schema.d.ts +67 -7
  8. package/dist/types/eval/py/runner-artifact.d.ts +8 -0
  9. package/dist/types/gjc-runtime/ultragoal-guard.d.ts +5 -5
  10. package/dist/types/gjc-runtime/ultragoal-receipt-freshness.d.ts +20 -0
  11. package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +19 -5
  12. package/dist/types/main.d.ts +24 -1
  13. package/dist/types/modes/components/btw-panel.d.ts +1 -0
  14. package/dist/types/modes/components/model-selector.d.ts +2 -0
  15. package/dist/types/modes/components/tool-status-header.d.ts +1 -0
  16. package/dist/types/modes/controllers/btw-controller.d.ts +5 -0
  17. package/dist/types/modes/interactive-mode.d.ts +2 -0
  18. package/dist/types/modes/types.d.ts +1 -0
  19. package/dist/types/runtime-mcp/content-limits.d.ts +7 -0
  20. package/dist/types/sdk/bus/chat-daemon-control.d.ts +4 -0
  21. package/dist/types/sdk/bus/index.d.ts +1 -1
  22. package/dist/types/sdk/bus/lifecycle-commands.d.ts +5 -4
  23. package/dist/types/sdk/bus/notification-service.d.ts +34 -0
  24. package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +13 -3
  25. package/dist/types/sdk/bus/telegram-daemon.d.ts +61 -3
  26. package/dist/types/sdk/bus/topic-registry.d.ts +88 -2
  27. package/dist/types/sdk/client/discovery.d.ts +2 -0
  28. package/dist/types/sdk/client/liveness.d.ts +7 -0
  29. package/dist/types/sdk/transport/auth-preface.d.ts +9 -0
  30. package/dist/types/sdk/transport/index.d.ts +12 -0
  31. package/dist/types/sdk/transport/relay.d.ts +43 -0
  32. package/dist/types/sdk/transport/serve-cli.d.ts +4 -0
  33. package/dist/types/sdk/transport/socket.d.ts +7 -0
  34. package/dist/types/sdk/transport/stdio.d.ts +3 -0
  35. package/dist/types/session/agent-session.d.ts +28 -5
  36. package/dist/types/session/btw-contract.d.ts +16 -0
  37. package/dist/types/session/internal/managed-session-scope.d.ts +21 -7
  38. package/dist/types/session/internal/managed-session-storage.d.ts +10 -8
  39. package/dist/types/session/session-manager.d.ts +35 -4
  40. package/dist/types/session/yield-queue.d.ts +8 -0
  41. package/dist/types/setup/credential-import.d.ts +5 -1
  42. package/dist/types/setup/provider-onboarding.d.ts +2 -0
  43. package/dist/types/ssh/utils.d.ts +1 -0
  44. package/dist/types/task/discovery.d.ts +3 -1
  45. package/dist/types/tools/fetch.d.ts +5 -8
  46. package/dist/types/tools/image-gen.d.ts +16 -0
  47. package/dist/types/tools/skill-discovery.d.ts +7 -0
  48. package/dist/types/tools/sqlite-reader.d.ts +7 -0
  49. package/dist/types/utils/shell-snapshot.d.ts +12 -0
  50. package/dist/types/web/insane/bridge.d.ts +1 -0
  51. package/dist/types/web/insane/url-guard.d.ts +17 -0
  52. package/package.json +8 -8
  53. package/scripts/generate-sdk-operation-inventory.ts +3 -0
  54. package/src/capability/index.ts +50 -42
  55. package/src/capability/types.ts +3 -0
  56. package/src/cli/setup-cli.ts +10 -4
  57. package/src/cli.ts +34 -9
  58. package/src/commands/daemon.ts +22 -5
  59. package/src/commands/sdk.ts +42 -9
  60. package/src/config/keybindings.ts +1 -1
  61. package/src/config/model-profiles.ts +18 -0
  62. package/src/config/settings-schema.ts +71 -7
  63. package/src/defaults/gjc/skills/ultragoal/SKILL.md +42 -1
  64. package/src/discovery/ssh.ts +12 -1
  65. package/src/eval/py/kernel.ts +1 -21
  66. package/src/eval/py/runner-artifact.ts +84 -0
  67. package/src/extensibility/plugins/marketplace/fetcher.ts +191 -7
  68. package/src/gjc-runtime/ultragoal-guard.ts +88 -10
  69. package/src/gjc-runtime/ultragoal-receipt-freshness.ts +103 -0
  70. package/src/gjc-runtime/ultragoal-runtime.ts +275 -12
  71. package/src/gjc-runtime/workflow-manifest.generated.json +58 -0
  72. package/src/gjc-runtime/workflow-manifest.ts +23 -0
  73. package/src/internal-urls/docs-index.generated.ts +9 -8
  74. package/src/internal-urls/local-protocol.ts +32 -6
  75. package/src/main.ts +87 -28
  76. package/src/modes/action-registry.ts +1 -1
  77. package/src/modes/components/btw-panel.ts +82 -16
  78. package/src/modes/components/model-selector.ts +31 -3
  79. package/src/modes/components/tool-status-header.ts +6 -1
  80. package/src/modes/controllers/btw-controller.ts +119 -36
  81. package/src/modes/controllers/command-controller.ts +15 -0
  82. package/src/modes/controllers/extension-ui-controller.ts +14 -2
  83. package/src/modes/controllers/input-controller.ts +31 -0
  84. package/src/modes/controllers/selector-controller.ts +106 -12
  85. package/src/modes/interactive-mode.ts +16 -7
  86. package/src/modes/runtime-init.ts +16 -2
  87. package/src/modes/types.ts +1 -0
  88. package/src/prompts/system/btw-user.md +3 -8
  89. package/src/prompts/tools/skill-discovery.md +1 -0
  90. package/src/runtime-mcp/client.ts +41 -55
  91. package/src/runtime-mcp/content-limits.ts +71 -0
  92. package/src/runtime-mcp/json-rpc.ts +23 -9
  93. package/src/runtime-mcp/transports/http.ts +50 -16
  94. package/src/sdk/bus/chat-daemon-control.ts +20 -7
  95. package/src/sdk/bus/index.ts +8 -7
  96. package/src/sdk/bus/lifecycle-commands.ts +16 -7
  97. package/src/sdk/bus/notification-service.ts +41 -18
  98. package/src/sdk/bus/telegram-daemon-contract.ts +13 -3
  99. package/src/sdk/bus/telegram-daemon-control.ts +26 -8
  100. package/src/sdk/bus/telegram-daemon.ts +1736 -338
  101. package/src/sdk/bus/topic-registry.ts +451 -12
  102. package/src/sdk/client/discovery.ts +19 -3
  103. package/src/sdk/client/liveness.ts +49 -0
  104. package/src/sdk/host/control/dispatch.ts +14 -5
  105. package/src/sdk/protocol/operation-inventory.generated.json +29 -0
  106. package/src/sdk/session.ts +29 -5
  107. package/src/sdk/transport/auth-preface.ts +82 -0
  108. package/src/sdk/transport/index.ts +18 -0
  109. package/src/sdk/transport/relay.ts +252 -0
  110. package/src/sdk/transport/serve-cli.ts +105 -0
  111. package/src/sdk/transport/socket.ts +197 -0
  112. package/src/sdk/transport/stdio.ts +17 -0
  113. package/src/session/agent-session.ts +1212 -768
  114. package/src/session/blob-store.ts +19 -6
  115. package/src/session/btw-contract.ts +59 -0
  116. package/src/session/internal/managed-session-scope.ts +313 -57
  117. package/src/session/internal/managed-session-storage.ts +146 -35
  118. package/src/session/session-manager.ts +385 -85
  119. package/src/session/yield-queue.ts +20 -0
  120. package/src/setup/credential-import.ts +28 -3
  121. package/src/setup/provider-onboarding.ts +30 -1
  122. package/src/setup/provider-presets.json +2 -1
  123. package/src/slash-commands/builtin-registry.ts +37 -1
  124. package/src/ssh/utils.ts +14 -0
  125. package/src/task/discovery.ts +8 -2
  126. package/src/tools/ask-answer-registry.ts +15 -1
  127. package/src/tools/ask.ts +1 -1
  128. package/src/tools/fetch.ts +13 -131
  129. package/src/tools/image-gen.ts +301 -20
  130. package/src/tools/read.ts +2 -0
  131. package/src/tools/skill-discovery.ts +39 -3
  132. package/src/tools/sqlite-reader.ts +63 -5
  133. package/src/utils/pasted-image-path.ts +15 -6
  134. package/src/utils/shell-snapshot.ts +173 -63
  135. package/src/web/insane/bridge.ts +5 -1
  136. package/src/web/insane/url-guard.ts +138 -27
  137. package/src/web/scrapers/types.ts +19 -49
  138. package/src/web/scrapers/utils.ts +12 -26
@@ -5,6 +5,18 @@ import { isEnoent, logger } from "@gajae-code/utils";
5
5
 
6
6
  const BLOB_PREFIX = "blob:sha256:";
7
7
 
8
+ /**
9
+ * Owner-only permissions for on-disk blob directories and files.
10
+ *
11
+ * Blob stores can live inside a managed session scope (e.g. the resident-cache
12
+ * `EphemeralBlobStore` created on the explicit session path). The managed-tree
13
+ * snapshot fails closed unless every descendant is owner-only, so blobs and
14
+ * their directories MUST be created 0700/0600 rather than inheriting a
15
+ * group/other-readable mode from the process umask.
16
+ */
17
+ const BLOB_DIR_MODE = 0o700;
18
+ const BLOB_FILE_MODE = 0o600;
19
+
8
20
  export interface BlobPutResult {
9
21
  hash: string;
10
22
  path: string;
@@ -113,6 +125,7 @@ export class BlobStore {
113
125
  };
114
126
 
115
127
  await Bun.write(blobPath, data);
128
+ await fsp.chmod(blobPath, BLOB_FILE_MODE);
116
129
  return result;
117
130
  }
118
131
 
@@ -131,8 +144,8 @@ export class BlobStore {
131
144
  return `${BLOB_PREFIX}${hash}`;
132
145
  },
133
146
  };
134
- fs.mkdirSync(this.dir, { recursive: true });
135
- fs.writeFileSync(blobPath, data);
147
+ fs.mkdirSync(this.dir, { recursive: true, mode: BLOB_DIR_MODE });
148
+ fs.writeFileSync(blobPath, data, { mode: BLOB_FILE_MODE });
136
149
  return result;
137
150
  }
138
151
 
@@ -147,7 +160,7 @@ export class BlobStore {
147
160
  const hash = sha256Hex(data);
148
161
  const blobPath = path.join(this.dir, hash);
149
162
  const result = makeBlobPutResult(hash, blobPath, data.byteLength);
150
- fs.mkdirSync(this.dir, { recursive: true });
163
+ fs.mkdirSync(this.dir, { recursive: true, mode: BLOB_DIR_MODE });
151
164
 
152
165
  if (fs.existsSync(blobPath)) {
153
166
  verifyBlobFileSync(hash, blobPath);
@@ -156,7 +169,7 @@ export class BlobStore {
156
169
 
157
170
  const tempPath = uniqueTempBlobPath(this.dir, hash);
158
171
  try {
159
- const fd = fs.openSync(tempPath, "wx");
172
+ const fd = fs.openSync(tempPath, "wx", BLOB_FILE_MODE);
160
173
  try {
161
174
  fs.writeFileSync(fd, data);
162
175
  fs.fsyncSync(fd);
@@ -274,7 +287,7 @@ export class EphemeralBlobStore extends BlobStore {
274
287
  constructor(dir: string) {
275
288
  super(dir);
276
289
  fs.rmSync(dir, { recursive: true, force: true });
277
- fs.mkdirSync(dir, { recursive: true });
290
+ fs.mkdirSync(dir, { recursive: true, mode: BLOB_DIR_MODE });
278
291
  }
279
292
 
280
293
  #cachePut(hash: string, data: Buffer): void {
@@ -333,7 +346,7 @@ export class EphemeralBlobStore extends BlobStore {
333
346
  this.#bufferCache.clear();
334
347
  this.#bufferCacheBytes = 0;
335
348
  fs.rmSync(this.dir, { recursive: true, force: true });
336
- fs.mkdirSync(this.dir, { recursive: true });
349
+ fs.mkdirSync(this.dir, { recursive: true, mode: BLOB_DIR_MODE });
337
350
  }
338
351
 
339
352
  dispose(): void {
@@ -0,0 +1,59 @@
1
+ export const BTW_MAX_CONTEXT_TURNS = 12;
2
+ export const BTW_MAX_CONTEXT_UTF8_BYTES = 64 * 1024;
3
+ export const BTW_MAX_QUESTION_UTF8_BYTES = 16 * 1024;
4
+ export const BTW_MAX_ANSWER_UTF8_BYTES = 32 * 1024;
5
+ export const BTW_MAX_ERROR_UTF8_BYTES = 4 * 1024;
6
+ export const BTW_STREAM_IDLE_TIMEOUT_MS = 30_000;
7
+ export const BTW_STREAM_TOTAL_TIMEOUT_MS = 120_000;
8
+
9
+ export interface BtwTextExchange {
10
+ question: string;
11
+ answer: string;
12
+ }
13
+
14
+ export function utf8ByteLength(text: string): number {
15
+ return Buffer.byteLength(text, "utf8");
16
+ }
17
+
18
+ export function truncateUtf8(text: string, maxBytes: number): string {
19
+ if (utf8ByteLength(text) <= maxBytes) return text;
20
+ let bytes = 0;
21
+ let result = "";
22
+ for (const character of text) {
23
+ const characterBytes = utf8ByteLength(character);
24
+ if (bytes + characterBytes > maxBytes) break;
25
+ result += character;
26
+ bytes += characterBytes;
27
+ }
28
+ return result;
29
+ }
30
+
31
+ export function sanitizeBtwError(text: string): string {
32
+ const sanitized = text
33
+ .replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g, " ")
34
+ .replace(/[\u202A-\u202E\u2066-\u2069]/g, "")
35
+ .replace(/\s+/g, " ")
36
+ .trim();
37
+ return truncateUtf8(sanitized || "Side-chat request failed.", BTW_MAX_ERROR_UTF8_BYTES);
38
+ }
39
+ export function exchangeUtf8Bytes(exchange: BtwTextExchange): number {
40
+ return utf8ByteLength(exchange.question) + utf8ByteLength(exchange.answer);
41
+ }
42
+
43
+ export function boundBtwExchanges(exchanges: readonly BtwTextExchange[]): BtwTextExchange[] {
44
+ const bounded: BtwTextExchange[] = [];
45
+ let totalBytes = 0;
46
+ for (let index = exchanges.length - 1; index >= 0 && bounded.length < BTW_MAX_CONTEXT_TURNS; index -= 1) {
47
+ const exchange = exchanges[index];
48
+ if (!exchange) continue;
49
+ const normalized = {
50
+ question: truncateUtf8(exchange.question, BTW_MAX_QUESTION_UTF8_BYTES),
51
+ answer: truncateUtf8(exchange.answer, BTW_MAX_ANSWER_UTF8_BYTES),
52
+ };
53
+ const bytes = exchangeUtf8Bytes(normalized);
54
+ if (bytes > BTW_MAX_CONTEXT_UTF8_BYTES - totalBytes) break;
55
+ bounded.unshift(normalized);
56
+ totalBytes += bytes;
57
+ }
58
+ return bounded;
59
+ }