@jsonstudio/llms 0.6.1449 → 0.6.1643

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 (71) hide show
  1. package/dist/conversion/codecs/gemini-openai-codec.js +6 -1
  2. package/dist/conversion/compat/actions/anthropic-claude-code-system-prompt.d.ts +4 -6
  3. package/dist/conversion/compat/actions/anthropic-claude-code-system-prompt.js +179 -41
  4. package/dist/conversion/compat/actions/antigravity-thought-signature-cache.js +73 -14
  5. package/dist/conversion/compat/actions/antigravity-thought-signature-prepare.js +165 -10
  6. package/dist/conversion/compat/actions/gemini-cli-request.js +72 -13
  7. package/dist/conversion/compat/antigravity-session-signature.d.ts +68 -1
  8. package/dist/conversion/compat/antigravity-session-signature.js +833 -21
  9. package/dist/conversion/compat/profiles/anthropic-claude-code.json +17 -0
  10. package/dist/conversion/compat/profiles/chat-gemini-cli.json +1 -0
  11. package/dist/conversion/hub/operation-table/semantic-mappers/gemini-mapper.js +33 -8
  12. package/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.js +17 -1
  13. package/dist/conversion/hub/pipeline/compat/compat-profile-store.js +12 -3
  14. package/dist/conversion/hub/pipeline/hub-pipeline.d.ts +1 -0
  15. package/dist/conversion/hub/pipeline/hub-pipeline.js +24 -0
  16. package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/index.js +20 -0
  17. package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/index.js +26 -1
  18. package/dist/conversion/hub/process/chat-process.js +300 -67
  19. package/dist/conversion/hub/response/provider-response.js +4 -3
  20. package/dist/conversion/shared/gemini-tool-utils.js +134 -9
  21. package/dist/conversion/shared/text-markup-normalizer.js +90 -1
  22. package/dist/conversion/shared/thought-signature-validator.d.ts +1 -1
  23. package/dist/conversion/shared/thought-signature-validator.js +2 -1
  24. package/dist/quota/apikey-reset.d.ts +17 -0
  25. package/dist/quota/apikey-reset.js +43 -0
  26. package/dist/quota/index.d.ts +2 -0
  27. package/dist/quota/index.js +1 -0
  28. package/dist/quota/quota-manager.d.ts +44 -0
  29. package/dist/quota/quota-manager.js +491 -0
  30. package/dist/quota/quota-state.d.ts +6 -0
  31. package/dist/quota/quota-state.js +167 -0
  32. package/dist/quota/types.d.ts +61 -0
  33. package/dist/quota/types.js +1 -0
  34. package/dist/router/virtual-router/bootstrap.js +103 -6
  35. package/dist/router/virtual-router/engine-health.js +104 -0
  36. package/dist/router/virtual-router/engine-selection/selection-deps.d.ts +18 -0
  37. package/dist/router/virtual-router/engine-selection/tier-priority.d.ts +1 -2
  38. package/dist/router/virtual-router/engine-selection/tier-priority.js +2 -2
  39. package/dist/router/virtual-router/engine-selection/tier-selection-select.js +34 -10
  40. package/dist/router/virtual-router/engine-selection/tier-selection.js +250 -6
  41. package/dist/router/virtual-router/engine-selection.js +2 -2
  42. package/dist/router/virtual-router/engine.d.ts +16 -1
  43. package/dist/router/virtual-router/engine.js +320 -42
  44. package/dist/router/virtual-router/features.js +20 -2
  45. package/dist/router/virtual-router/success-center.d.ts +10 -0
  46. package/dist/router/virtual-router/success-center.js +32 -0
  47. package/dist/router/virtual-router/types.d.ts +48 -0
  48. package/dist/servertool/clock/config.d.ts +2 -0
  49. package/dist/servertool/clock/config.js +10 -2
  50. package/dist/servertool/clock/daemon.js +3 -0
  51. package/dist/servertool/clock/ntp.d.ts +18 -0
  52. package/dist/servertool/clock/ntp.js +318 -0
  53. package/dist/servertool/clock/paths.d.ts +1 -0
  54. package/dist/servertool/clock/paths.js +3 -0
  55. package/dist/servertool/clock/state.d.ts +2 -0
  56. package/dist/servertool/clock/state.js +15 -2
  57. package/dist/servertool/clock/tasks.d.ts +1 -0
  58. package/dist/servertool/clock/tasks.js +24 -1
  59. package/dist/servertool/clock/types.d.ts +21 -0
  60. package/dist/servertool/engine.js +105 -1
  61. package/dist/servertool/handlers/antigravity-thought-signature-bootstrap.d.ts +1 -0
  62. package/dist/servertool/handlers/antigravity-thought-signature-bootstrap.js +201 -0
  63. package/dist/servertool/handlers/clock-auto.js +39 -4
  64. package/dist/servertool/handlers/clock.js +145 -16
  65. package/dist/servertool/handlers/followup-request-builder.js +84 -0
  66. package/dist/servertool/handlers/stop-message-auto.js +1 -1
  67. package/dist/servertool/server-side-tools.d.ts +1 -0
  68. package/dist/servertool/server-side-tools.js +1 -0
  69. package/dist/servertool/types.d.ts +2 -0
  70. package/dist/tools/apply-patch/execution-capturer.js +24 -3
  71. package/package.json +3 -2
@@ -5,9 +5,13 @@ import { createHash } from 'crypto';
5
5
  /**
6
6
  * Captures apply_patch execution failures (tool role message contents) into errorsamples.
7
7
  *
8
- * These failures are not schema/shape failures; they happen when the tool is executed
9
- * (e.g. file missing, context mismatch). We capture for debugging and compatibility
10
- * tracking, but do NOT attempt semantic repair.
8
+ * IMPORTANT (RouteCodex policy):
9
+ * - Only keep apply_patch "shape" failures in errorsamples.
10
+ * - Context/execution failures (file missing, context mismatch, expected lines mismatch)
11
+ * are noisy and not actionable, so they are NOT captured by default.
12
+ *
13
+ * Explicit opt-in for debugging:
14
+ * ROUTECODEX_ERRORSAMPLES_APPLY_PATCH_EXEC=1
11
15
  *
12
16
  * Default destination:
13
17
  * ~/.routecodex/errorsamples/apply_patch_exec/<error-type>/
@@ -18,6 +22,7 @@ import { createHash } from 'crypto';
18
22
  * Note: if ROUTECODEX_ERRORSAMPLES_DIR is set, it is used as the base root.
19
23
  */
20
24
  const MAX_SAMPLES_PER_TYPE = 250;
25
+ const EXEC_ERRORSAMPLES_ENABLED = String(process?.env?.ROUTECODEX_ERRORSAMPLES_APPLY_PATCH_EXEC || '').trim() === '1';
21
26
  function resolveSamplesRoot() {
22
27
  const explicit = String(process?.env?.ROUTECODEX_APPLY_PATCH_EXEC_DIR || '').trim();
23
28
  if (explicit)
@@ -47,6 +52,13 @@ function classifyExecutionFailure(content) {
47
52
  return { errorType: 'parse_failed', message: msg };
48
53
  return { errorType: 'unknown', message: msg };
49
54
  }
55
+ function isContextExecutionFailureType(errorType) {
56
+ const t = String(errorType || '').trim().toLowerCase();
57
+ return (t === 'read_file_failed' ||
58
+ t === 'file_not_found' ||
59
+ t === 'context_not_found' ||
60
+ t === 'expected_lines_not_found');
61
+ }
50
62
  function stableSampleId(fields) {
51
63
  const key = `${String(fields.errorType || 'unknown')}:${String(fields.errorMessage || '')}:` +
52
64
  `${String(fields.toolCallId || '')}:${String(fields.toolCallArgs || '')}:${String(fields.requestId || '')}:${String(fields.mode || '')}`;
@@ -54,7 +66,14 @@ function stableSampleId(fields) {
54
66
  }
55
67
  export function captureApplyPatchExecutionFailure(content, context) {
56
68
  try {
69
+ if (!EXEC_ERRORSAMPLES_ENABLED)
70
+ return;
57
71
  const { errorType, message } = classifyExecutionFailure(content);
72
+ // Keep only non-context types (i.e. parse/format issues). Context mismatches are not captured.
73
+ if (isContextExecutionFailureType(errorType))
74
+ return;
75
+ if (String(errorType || '').trim().toLowerCase() === 'unknown')
76
+ return;
58
77
  const root = resolveSamplesRoot();
59
78
  const safeType = String(errorType || 'unknown').replace(/[^a-z0-9-]/gi, '_');
60
79
  const typeDir = path.join(root, safeType);
@@ -103,6 +122,8 @@ export function captureApplyPatchExecutionFailure(content, context) {
103
122
  }
104
123
  export function captureApplyPatchExecutionFailuresFromProcessedRequest(processedRequest) {
105
124
  try {
125
+ if (!EXEC_ERRORSAMPLES_ENABLED)
126
+ return;
106
127
  const anyReq = processedRequest;
107
128
  const messages = Array.isArray(anyReq?.messages) ? anyReq.messages : [];
108
129
  if (!messages.length)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsonstudio/llms",
3
- "version": "0.6.1449",
3
+ "version": "0.6.1643",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -27,7 +27,8 @@
27
27
  "test:looprt:gemini": "npm run build && node scripts/tests/loop-rt-gemini.mjs",
28
28
  "replay:responses:chat-sse": "node scripts/exp3-responses-sse-to-chat-sse.mjs",
29
29
  "replay:responses:loop": "node scripts/exp4-responses-sse-loop.mjs",
30
- "test:virtual-router": "npm run build:dev && node scripts/tests/virtual-router-prefer-autoclear.mjs && node scripts/tests/virtual-router-dry-run.mjs && node scripts/tests/virtual-router-context.mjs && node scripts/tests/virtual-router-antigravity-alias-pin.mjs && node scripts/tests/virtual-router-antigravity-auth-verify.mjs",
30
+ "test:quota-manager": "npm run build:dev && node scripts/tests/quota-manager-402-reset.mjs",
31
+ "test:virtual-router": "npm run build:dev && node scripts/tests/virtual-router-prefer-autoclear.mjs && node scripts/tests/virtual-router-dry-run.mjs && node scripts/tests/virtual-router-context.mjs && node scripts/tests/virtual-router-antigravity-alias-pin.mjs && node scripts/tests/virtual-router-antigravity-session-binding.mjs && node scripts/tests/virtual-router-antigravity-auth-verify.mjs",
31
32
  "test:virtual-router-health": "npm run build:dev && node scripts/tests/virtual-router-health.mjs",
32
33
  "test:golden": "npm run build:ci && node scripts/tests/chat-golden-roundtrip.mjs && node scripts/tests/anthropic-golden-roundtrip.mjs",
33
34
  "test:coverage": "node scripts/run-ci-coverage.mjs"