@northflare/runner 0.0.12 → 0.0.13

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 (77) hide show
  1. package/package.json +2 -3
  2. package/coverage/base.css +0 -224
  3. package/coverage/block-navigation.js +0 -87
  4. package/coverage/coverage-final.json +0 -12
  5. package/coverage/favicon.png +0 -0
  6. package/coverage/index.html +0 -176
  7. package/coverage/lib/index.html +0 -116
  8. package/coverage/lib/preload-script.js.html +0 -964
  9. package/coverage/prettify.css +0 -1
  10. package/coverage/prettify.js +0 -2
  11. package/coverage/sort-arrow-sprite.png +0 -0
  12. package/coverage/sorter.js +0 -196
  13. package/coverage/src/collections/index.html +0 -116
  14. package/coverage/src/collections/runner-messages.ts.html +0 -312
  15. package/coverage/src/components/claude-manager.ts.html +0 -1290
  16. package/coverage/src/components/index.html +0 -146
  17. package/coverage/src/components/message-handler.ts.html +0 -730
  18. package/coverage/src/components/repository-manager.ts.html +0 -841
  19. package/coverage/src/index.html +0 -131
  20. package/coverage/src/index.ts.html +0 -448
  21. package/coverage/src/runner.ts.html +0 -1239
  22. package/coverage/src/utils/config.ts.html +0 -780
  23. package/coverage/src/utils/console.ts.html +0 -121
  24. package/coverage/src/utils/index.html +0 -161
  25. package/coverage/src/utils/logger.ts.html +0 -475
  26. package/coverage/src/utils/status-line.ts.html +0 -445
  27. package/exceptions.log +0 -24
  28. package/lib/codex-sdk/src/codex.ts +0 -38
  29. package/lib/codex-sdk/src/codexOptions.ts +0 -10
  30. package/lib/codex-sdk/src/events.ts +0 -80
  31. package/lib/codex-sdk/src/exec.ts +0 -336
  32. package/lib/codex-sdk/src/index.ts +0 -39
  33. package/lib/codex-sdk/src/items.ts +0 -127
  34. package/lib/codex-sdk/src/outputSchemaFile.ts +0 -40
  35. package/lib/codex-sdk/src/thread.ts +0 -155
  36. package/lib/codex-sdk/src/threadOptions.ts +0 -18
  37. package/lib/codex-sdk/src/turnOptions.ts +0 -6
  38. package/lib/codex-sdk/tests/abort.test.ts +0 -165
  39. package/lib/codex-sdk/tests/codexExecSpy.ts +0 -37
  40. package/lib/codex-sdk/tests/responsesProxy.ts +0 -225
  41. package/lib/codex-sdk/tests/run.test.ts +0 -687
  42. package/lib/codex-sdk/tests/runStreamed.test.ts +0 -211
  43. package/lib/codex-sdk/tsconfig.json +0 -24
  44. package/rejections.log +0 -68
  45. package/runner.log +0 -488
  46. package/src/components/claude-sdk-manager.ts +0 -1425
  47. package/src/components/codex-sdk-manager.ts +0 -1358
  48. package/src/components/enhanced-repository-manager.ts +0 -823
  49. package/src/components/message-handler-sse.ts +0 -1097
  50. package/src/components/repository-manager.ts +0 -337
  51. package/src/index.ts +0 -168
  52. package/src/runner-sse.ts +0 -917
  53. package/src/services/RunnerAPIClient.ts +0 -175
  54. package/src/services/SSEClient.ts +0 -258
  55. package/src/types/claude.ts +0 -66
  56. package/src/types/computer-name.d.ts +0 -4
  57. package/src/types/index.ts +0 -64
  58. package/src/types/messages.ts +0 -39
  59. package/src/types/runner-interface.ts +0 -36
  60. package/src/utils/StateManager.ts +0 -187
  61. package/src/utils/config.ts +0 -327
  62. package/src/utils/console.ts +0 -15
  63. package/src/utils/debug.ts +0 -18
  64. package/src/utils/expand-env.ts +0 -22
  65. package/src/utils/logger.ts +0 -134
  66. package/src/utils/model.ts +0 -29
  67. package/src/utils/status-line.ts +0 -122
  68. package/src/utils/tool-response-sanitizer.ts +0 -160
  69. package/test-debug.sh +0 -26
  70. package/tests/retry-strategies.test.ts +0 -410
  71. package/tests/sdk-integration.test.ts +0 -329
  72. package/tests/sdk-streaming.test.ts +0 -1180
  73. package/tests/setup.ts +0 -5
  74. package/tests/test-claude-manager.ts +0 -120
  75. package/tests/tool-response-sanitizer.test.ts +0 -63
  76. package/tsconfig.json +0 -36
  77. package/vitest.config.ts +0 -27
@@ -1,29 +0,0 @@
1
- export type ModelReasoningEffort = "low" | "medium" | "high";
2
-
3
- const REASONING_VALUES: readonly ModelReasoningEffort[] = [
4
- "low",
5
- "medium",
6
- "high",
7
- ];
8
-
9
- export function parseModelValue(value?: string | null): {
10
- baseModel?: string;
11
- reasoningEffort?: ModelReasoningEffort;
12
- } {
13
- if (!value) {
14
- return {};
15
- }
16
-
17
- const [model, possibleEffort] = value.split(":");
18
- if (
19
- possibleEffort &&
20
- REASONING_VALUES.includes(possibleEffort as ModelReasoningEffort)
21
- ) {
22
- return {
23
- baseModel: model,
24
- reasoningEffort: possibleEffort as ModelReasoningEffort,
25
- };
26
- }
27
-
28
- return { baseModel: value };
29
- }
@@ -1,122 +0,0 @@
1
- /**
2
- * StatusLineManager - Manages persistent status line output for active agent processes
3
- *
4
- * This component maintains a single-line status output that updates every minute to show
5
- * the count of active agent processes. It prevents the machine from entering idle
6
- * state while processes are running and provides clear visual feedback without cluttering
7
- * the terminal with multiple log lines.
8
- */
9
- import { isRunnerDebugEnabled } from "./debug";
10
-
11
- export class StatusLineManager {
12
- private intervalId?: NodeJS.Timeout;
13
- private activeCount: number = 0;
14
- private lastLine: string = "";
15
- private isEnabled: boolean = true;
16
-
17
- constructor() {
18
- // Only enable status line when not in debug mode
19
- this.isEnabled = !isRunnerDebugEnabled();
20
- }
21
-
22
- /**
23
- * Updates the count of active conversations
24
- */
25
- updateActiveCount(count: number): void {
26
- const wasZero = this.activeCount === 0;
27
- const isZero = count === 0;
28
- this.activeCount = count;
29
-
30
- // Start interval when transitioning from 0 to active
31
- if (wasZero && !isZero) {
32
- this.startInterval();
33
- }
34
- // Stop interval when transitioning to 0
35
- else if (!wasZero && isZero) {
36
- this.stopInterval();
37
- }
38
- }
39
-
40
- /**
41
- * Starts the status line interval
42
- */
43
- private startInterval(): void {
44
- if (!this.isEnabled || this.intervalId) return;
45
-
46
- // Show initial status immediately
47
- this.showStatus();
48
-
49
- // Update every minute on the minute
50
- const now = new Date();
51
- const msUntilNextMinute = (60 - now.getSeconds()) * 1000 - now.getMilliseconds();
52
-
53
- // First timeout to align with the minute
54
- setTimeout(() => {
55
- this.showStatus();
56
-
57
- // Then set up regular interval
58
- this.intervalId = setInterval(() => {
59
- this.showStatus();
60
- }, 60000); // Every 60 seconds
61
- }, msUntilNextMinute);
62
- }
63
-
64
- /**
65
- * Stops the status line interval
66
- */
67
- private stopInterval(): void {
68
- if (this.intervalId) {
69
- clearInterval(this.intervalId);
70
- this.intervalId = undefined;
71
- }
72
-
73
- // Show final "No active" message
74
- this.showStatus();
75
- }
76
-
77
- /**
78
- * Shows the current status
79
- */
80
- private showStatus(): void {
81
- if (!this.isEnabled) return;
82
-
83
- const now = new Date();
84
- const timeStr = now.toTimeString().slice(0, 5); // HH:MM format
85
-
86
- let newLine: string;
87
- if (this.activeCount === 0) {
88
- newLine = "No active agent processes";
89
- } else if (this.activeCount === 1) {
90
- newLine = `${timeStr} 1 active agent process`;
91
- } else {
92
- newLine = `${timeStr} ${this.activeCount} active agent processes`;
93
- }
94
-
95
- // If this is the first status line, position it
96
- if (!this.lastLine) {
97
- // Move to start of line and save cursor position
98
- process.stdout.write('\r');
99
- } else {
100
- // Clear the current line
101
- process.stdout.write('\r' + ' '.repeat(this.lastLine.length) + '\r');
102
- }
103
-
104
- // Write the new status without newline
105
- process.stdout.write(newLine);
106
- this.lastLine = newLine;
107
- }
108
-
109
- /**
110
- * Cleans up the status line manager
111
- */
112
- dispose(): void {
113
- this.stopInterval();
114
- // Add a newline to ensure next output starts on a new line
115
- if (this.lastLine) {
116
- process.stdout.write('\n');
117
- }
118
- }
119
- }
120
-
121
- // Singleton instance
122
- export const statusLineManager = new StatusLineManager();
@@ -1,160 +0,0 @@
1
- export const TOOL_RESPONSE_BYTE_LIMIT = 500 * 1024; // 500 KiB cap per tool response payload
2
- export const TOOL_RESPONSE_SUFFIX = "... [truncated]";
3
-
4
- export interface ToolResponseSanitizationResult {
5
- params: any;
6
- truncated: boolean;
7
- toolUseId?: string;
8
- }
9
-
10
- interface TruncationContext {
11
- bytesRemaining: number;
12
- truncated: boolean;
13
- }
14
-
15
- export function sanitizeToolResponsePayload(
16
- method: string | undefined,
17
- params: any
18
- ): ToolResponseSanitizationResult {
19
- if (method !== "message.agent" || !params) {
20
- return { params, truncated: false };
21
- }
22
-
23
- if (!isToolResultPayload(params)) {
24
- return { params, truncated: false };
25
- }
26
-
27
- const context: TruncationContext = {
28
- bytesRemaining: TOOL_RESPONSE_BYTE_LIMIT,
29
- truncated: false,
30
- };
31
-
32
- const [sanitized, changed] = truncateStringsRecursively(params, context);
33
-
34
- if (!changed && !context.truncated) {
35
- return { params, truncated: false };
36
- }
37
-
38
- return {
39
- params: sanitized,
40
- truncated: true,
41
- toolUseId: extractToolUseId(params),
42
- };
43
- }
44
-
45
- function isToolResultPayload(payload: any): boolean {
46
- if (!payload) {
47
- return false;
48
- }
49
- if (payload.type === "tool_result" || payload.subtype === "tool_result") {
50
- return true;
51
- }
52
- if (Array.isArray(payload.content)) {
53
- return payload.content.some((entry: any) => isToolResultBlock(entry));
54
- }
55
- return isToolResultBlock(payload.content);
56
- }
57
-
58
- function isToolResultBlock(block: any): boolean {
59
- if (!block) {
60
- return false;
61
- }
62
- return (
63
- block.type === "tool_result" ||
64
- block.subtype === "tool_result" ||
65
- typeof block.tool_use_id === "string"
66
- );
67
- }
68
-
69
- function extractToolUseId(payload: any): string | undefined {
70
- if (!payload) {
71
- return undefined;
72
- }
73
- if (typeof payload.tool_use_id === "string") {
74
- return payload.tool_use_id;
75
- }
76
- if (Array.isArray(payload.content)) {
77
- const match = payload.content.find(
78
- (entry: any) => entry && typeof entry.tool_use_id === "string"
79
- );
80
- if (match) {
81
- return match.tool_use_id;
82
- }
83
- }
84
- if (payload.content && typeof payload.content === "object") {
85
- return extractToolUseId(payload.content);
86
- }
87
- return undefined;
88
- }
89
-
90
- function truncateStringsRecursively(
91
- value: any,
92
- context: TruncationContext
93
- ): [any, boolean] {
94
- if (typeof value === "string") {
95
- return truncateStringValue(value, context);
96
- }
97
-
98
- if (Array.isArray(value)) {
99
- let mutated = false;
100
- let result: any[] = value;
101
- for (let i = 0; i < value.length; i++) {
102
- const [newItem, changed] = truncateStringsRecursively(value[i], context);
103
- if (changed) {
104
- if (!mutated) {
105
- result = value.slice();
106
- mutated = true;
107
- }
108
- result[i] = newItem;
109
- }
110
- }
111
- return [result, mutated];
112
- }
113
-
114
- if (value && typeof value === "object") {
115
- let mutated = false;
116
- let result: Record<string, any> = value;
117
- for (const key of Object.keys(value)) {
118
- const [newVal, changed] = truncateStringsRecursively(
119
- value[key],
120
- context
121
- );
122
- if (changed) {
123
- if (!mutated) {
124
- result = { ...value };
125
- mutated = true;
126
- }
127
- result[key] = newVal;
128
- }
129
- }
130
- return [result, mutated];
131
- }
132
-
133
- return [value, false];
134
- }
135
-
136
- function truncateStringValue(
137
- value: string,
138
- context: TruncationContext
139
- ): [string, boolean] {
140
- if (context.bytesRemaining <= 0) {
141
- if (value.length === 0) {
142
- return [value, false];
143
- }
144
- context.truncated = true;
145
- return ["", true];
146
- }
147
-
148
- const byteLength = Buffer.byteLength(value, "utf8");
149
- if (byteLength <= context.bytesRemaining) {
150
- context.bytesRemaining -= byteLength;
151
- return [value, false];
152
- }
153
-
154
- const suffixBytes = Buffer.byteLength(TOOL_RESPONSE_SUFFIX, "utf8");
155
- const maxBytes = Math.max(0, context.bytesRemaining - suffixBytes);
156
- const truncatedBuffer = Buffer.from(value, "utf8").subarray(0, maxBytes);
157
- context.bytesRemaining = 0;
158
- context.truncated = true;
159
- return [truncatedBuffer.toString("utf8") + TOOL_RESPONSE_SUFFIX, true];
160
- }
package/test-debug.sh DELETED
@@ -1,26 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Test script to demonstrate debug logging in the runner
4
-
5
- echo "Starting runner in debug mode to demonstrate enhanced logging..."
6
- echo "This will show:"
7
- echo " - runnerUid on initialization"
8
- echo " - lastProcessedAt state for ElectricSQL connection"
9
- echo " - ElectricSQL connection details"
10
- echo " - Message processing decisions with ownership info"
11
- echo ""
12
- echo "Set DEBUG=true to enable verbose logging"
13
- echo ""
14
-
15
- # Run the runner with debug mode enabled
16
- DEBUG=true npm run start -- --config ./config.json 2>&1 | head -100
17
-
18
- echo ""
19
- echo "Note: The runner will display debug logs including:"
20
- echo " - Runner UID and ownership details during registration"
21
- echo " - LastProcessedAt watermark for message filtering"
22
- echo " - ElectricSQL collection creation with connection details"
23
- echo " - Message processing decisions with reasons"
24
- echo ""
25
- echo "To run the runner with debug logging enabled, use:"
26
- echo " DEBUG=true npm run start"