@geoffai/geoff 0.1.0

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.
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Coder type definitions
3
+ * Types for the GeoffCoder AI coding agent
4
+ */
5
+ type CoderSessionStatus = 'active' | 'completed' | 'aborted' | 'error';
6
+ interface CoderSession {
7
+ id: string;
8
+ workingDirectory: string;
9
+ status: CoderSessionStatus;
10
+ createdAt: string;
11
+ updatedAt?: string;
12
+ metrics: CoderMetrics;
13
+ sandboxId?: string;
14
+ }
15
+ interface CoderMetrics {
16
+ tokensUsed: number;
17
+ promptTokens: number;
18
+ completionTokens: number;
19
+ contextSize: number;
20
+ filesCreated: number;
21
+ filesModified: number;
22
+ linesAdded: number;
23
+ linesRemoved: number;
24
+ commandsExecuted: number;
25
+ toolCallsTotal: number;
26
+ apiCalls: number;
27
+ startTime: number;
28
+ endTime?: number;
29
+ modifiedFiles: string[];
30
+ createdFiles: string[];
31
+ }
32
+ interface CoderExecuteRequest {
33
+ /** The prompt/task for the coder agent */
34
+ prompt: string;
35
+ /** Working directory for file operations */
36
+ workingDirectory?: string;
37
+ /** Maximum iterations for the agent loop */
38
+ maxIterations?: number;
39
+ /** Model to use for completions */
40
+ model?: string;
41
+ /** Maximum tokens per response */
42
+ maxTokens?: number;
43
+ /** Temperature for generation */
44
+ temperature?: number;
45
+ /** Whether to stream the response */
46
+ stream?: boolean;
47
+ /** Existing session ID to continue */
48
+ sessionId?: string;
49
+ /** Existing sandbox ID to use (from frontend) */
50
+ sandboxId?: string;
51
+ /** E2B sandbox configuration */
52
+ sandbox?: CoderSandboxConfig;
53
+ }
54
+ interface CoderSandboxConfig {
55
+ /** Enable sandbox execution */
56
+ enabled: boolean;
57
+ /** Sandbox template (e.g., 'node', 'python', 'nextjs') */
58
+ template?: string;
59
+ /** Session timeout in seconds */
60
+ timeout?: number;
61
+ /** Environment variables */
62
+ env?: Record<string, string>;
63
+ /** Packages to pre-install */
64
+ packages?: string[];
65
+ }
66
+ interface CoderExecuteResponse {
67
+ sessionId: string;
68
+ status: CoderSessionStatus;
69
+ result?: string;
70
+ error?: string;
71
+ metrics: CoderMetrics;
72
+ }
73
+ type CoderStreamEventType = 'session_start' | 'thinking' | 'tool_call' | 'tool_result' | 'assistant_message' | 'progress' | 'metrics_update' | 'session_complete' | 'error';
74
+ interface CoderStreamEvent {
75
+ type: CoderStreamEventType;
76
+ data: unknown;
77
+ timestamp: number;
78
+ }
79
+ interface CoderThinkingEvent {
80
+ type: 'thinking';
81
+ data: {
82
+ content: string;
83
+ iteration: number;
84
+ };
85
+ }
86
+ interface CoderToolCallEvent {
87
+ type: 'tool_call';
88
+ data: {
89
+ toolName: string;
90
+ arguments: Record<string, unknown>;
91
+ toolCallId: string;
92
+ };
93
+ }
94
+ interface CoderToolResultEvent {
95
+ type: 'tool_result';
96
+ data: {
97
+ toolCallId: string;
98
+ toolName: string;
99
+ success: boolean;
100
+ output: string;
101
+ error?: string;
102
+ };
103
+ }
104
+ interface CoderProgressEvent {
105
+ type: 'progress';
106
+ data: {
107
+ iteration: number;
108
+ maxIterations: number;
109
+ currentAction: string;
110
+ };
111
+ }
112
+ interface CoderTool {
113
+ name: string;
114
+ description: string;
115
+ parameters: {
116
+ type: 'object';
117
+ properties: Record<string, CoderToolParameter>;
118
+ required?: string[];
119
+ };
120
+ }
121
+ interface CoderToolParameter {
122
+ type: string;
123
+ description: string;
124
+ enum?: string[];
125
+ }
126
+ interface CoderToolResult {
127
+ success: boolean;
128
+ output: string;
129
+ error?: string;
130
+ }
131
+ interface CoderFileInfo {
132
+ name: string;
133
+ path: string;
134
+ size: number;
135
+ isDirectory: boolean;
136
+ modified?: string;
137
+ children?: CoderFileInfo[];
138
+ }
139
+ interface CoderFileContent {
140
+ path: string;
141
+ content: string;
142
+ encoding?: 'utf8' | 'base64';
143
+ size: number;
144
+ }
145
+ interface CoderFileWriteInput {
146
+ path: string;
147
+ content: string;
148
+ encoding?: 'utf8' | 'base64';
149
+ createDirectories?: boolean;
150
+ }
151
+ interface CoderSearchResult {
152
+ file: string;
153
+ line: number;
154
+ content: string;
155
+ contextBefore?: string[];
156
+ contextAfter?: string[];
157
+ }
158
+ interface CoderDiffInput {
159
+ path: string;
160
+ original: string;
161
+ replacement: string;
162
+ replaceAll?: boolean;
163
+ }
164
+ interface CoderCommandResult {
165
+ stdout: string;
166
+ stderr: string;
167
+ exitCode: number;
168
+ executionTimeMs: number;
169
+ }
170
+ interface CoderCommandInput {
171
+ command: string;
172
+ timeout?: number;
173
+ cwd?: string;
174
+ }
175
+ interface CoderSandbox {
176
+ id: string;
177
+ status: 'creating' | 'ready' | 'busy' | 'stopped' | 'error';
178
+ template: string;
179
+ workingDirectory: string;
180
+ createdAt: string;
181
+ expiresAt?: string;
182
+ }
183
+ interface CoderSandboxCreateInput {
184
+ template?: string;
185
+ timeout?: number;
186
+ env?: Record<string, string>;
187
+ packages?: string[];
188
+ }
189
+ interface CoderSandboxExecInput {
190
+ command: string;
191
+ timeout?: number;
192
+ stream?: boolean;
193
+ }
194
+ interface CoderSandboxExecResult {
195
+ stdout: string;
196
+ stderr: string;
197
+ exitCode: number;
198
+ executionTimeMs: number;
199
+ }
200
+ interface CoderSessionResponse {
201
+ session: CoderSession;
202
+ }
203
+ interface CoderSessionsListResponse {
204
+ sessions: CoderSession[];
205
+ }
206
+ interface CoderToolsResponse {
207
+ tools: CoderTool[];
208
+ }
209
+ interface CoderFilesResponse {
210
+ files: CoderFileInfo[];
211
+ path: string;
212
+ }
213
+ interface CoderSandboxResponse {
214
+ sandbox: CoderSandbox;
215
+ }
216
+ interface CoderClientConfig {
217
+ /** Base URL for the task network API */
218
+ baseUrl?: string;
219
+ /** API key for authentication */
220
+ apiKey?: string;
221
+ /** Request timeout in milliseconds */
222
+ timeout?: number;
223
+ /** Default model for coder sessions */
224
+ defaultModel?: string;
225
+ /** Default max iterations */
226
+ defaultMaxIterations?: number;
227
+ }
228
+
229
+ export type { CoderSessionsListResponse as A, CoderToolsResponse as B, CoderSessionStatus as C, CoderFilesResponse as D, CoderSandboxResponse as E, CoderClientConfig as F, CoderSession as a, CoderMetrics as b, CoderExecuteRequest as c, CoderSandboxConfig as d, CoderExecuteResponse as e, CoderStreamEventType as f, CoderStreamEvent as g, CoderThinkingEvent as h, CoderToolCallEvent as i, CoderToolResultEvent as j, CoderProgressEvent as k, CoderTool as l, CoderToolParameter as m, CoderToolResult as n, CoderFileInfo as o, CoderFileContent as p, CoderFileWriteInput as q, CoderSearchResult as r, CoderDiffInput as s, CoderCommandResult as t, CoderCommandInput as u, CoderSandbox as v, CoderSandboxCreateInput as w, CoderSandboxExecInput as x, CoderSandboxExecResult as y, CoderSessionResponse as z };
@@ -0,0 +1,170 @@
1
+ /**
2
+ * Generic request forwarding utilities
3
+ */
4
+ interface ForwarderConfig {
5
+ baseUrl?: string;
6
+ defaultHeaders?: Record<string, string>;
7
+ timeout?: number;
8
+ }
9
+ interface RequestOptions {
10
+ method?: string;
11
+ headers?: Record<string, string>;
12
+ body?: unknown;
13
+ searchParams?: Record<string, string | undefined>;
14
+ stream?: boolean;
15
+ }
16
+ /**
17
+ * Forward a request to a backend URL
18
+ */
19
+ declare function forwardRequest(path: string, options?: RequestOptions, config?: ForwarderConfig): Promise<Response>;
20
+ /**
21
+ * Forward and return JSON response
22
+ */
23
+ declare function forwardJSON<T = unknown>(path: string, options?: RequestOptions, config?: ForwarderConfig): Promise<{
24
+ data: T;
25
+ status: number;
26
+ }>;
27
+ /**
28
+ * Create a proxy handler that forwards requests
29
+ */
30
+ declare function createProxyHandler(path: string | ((req: Request) => string), config?: ForwarderConfig): (request: Request) => Promise<Response>;
31
+
32
+ /**
33
+ * Next.js API Route Handler Factories
34
+ *
35
+ * Create pre-configured route handlers for common patterns
36
+ */
37
+
38
+ interface RouteHandlerConfig extends ForwarderConfig {
39
+ requireAuth?: boolean;
40
+ enrichResponse?: (data: unknown) => Promise<unknown>;
41
+ }
42
+ type RouteHandler = (request: Request, context?: {
43
+ params?: Record<string, string>;
44
+ }) => Promise<Response>;
45
+ interface CRUDRouteHandlers {
46
+ GET: RouteHandler;
47
+ POST: RouteHandler;
48
+ PUT?: RouteHandler;
49
+ DELETE?: RouteHandler;
50
+ }
51
+ /**
52
+ * Create agent route handlers
53
+ */
54
+ declare function createAgentRoutes(config?: RouteHandlerConfig): CRUDRouteHandlers;
55
+ /**
56
+ * Create agent detail route handlers (for [id] routes)
57
+ */
58
+ declare function createAgentDetailRoutes(config?: RouteHandlerConfig): CRUDRouteHandlers;
59
+ /**
60
+ * Create agent execute route handler
61
+ */
62
+ declare function createAgentExecuteRoute(config?: RouteHandlerConfig): {
63
+ POST: RouteHandler;
64
+ };
65
+ /**
66
+ * Create agent enable/disable route handlers
67
+ */
68
+ declare function createAgentToggleRoutes(config?: RouteHandlerConfig): {
69
+ enable: {
70
+ POST: RouteHandler;
71
+ };
72
+ disable: {
73
+ POST: RouteHandler;
74
+ };
75
+ };
76
+ /**
77
+ * Create skill route handlers
78
+ */
79
+ declare function createSkillRoutes(config?: RouteHandlerConfig): CRUDRouteHandlers;
80
+ /**
81
+ * Create skill detail route handlers
82
+ */
83
+ declare function createSkillDetailRoutes(config?: RouteHandlerConfig): CRUDRouteHandlers;
84
+ /**
85
+ * Create widget route handlers (same pattern as skills)
86
+ */
87
+ declare function createWidgetRoutes(config?: RouteHandlerConfig): CRUDRouteHandlers;
88
+ /**
89
+ * Create widget detail route handlers
90
+ */
91
+ declare function createWidgetDetailRoutes(config?: RouteHandlerConfig): CRUDRouteHandlers;
92
+ /**
93
+ * Create imagination route handlers
94
+ */
95
+ declare function createImaginationRoutes(config?: RouteHandlerConfig): CRUDRouteHandlers;
96
+ /**
97
+ * Create coder session route handlers
98
+ */
99
+ declare function createCoderSessionRoutes(config?: RouteHandlerConfig): CRUDRouteHandlers;
100
+ /**
101
+ * Create coder session detail route handlers
102
+ */
103
+ declare function createCoderSessionDetailRoutes(config?: RouteHandlerConfig): CRUDRouteHandlers & {
104
+ abort: {
105
+ POST: RouteHandler;
106
+ };
107
+ };
108
+ /**
109
+ * Create coder execute route handler (with streaming support)
110
+ */
111
+ declare function createCoderExecuteRoute(config?: RouteHandlerConfig): {
112
+ POST: RouteHandler;
113
+ };
114
+ /**
115
+ * Create coder tools route handlers
116
+ */
117
+ declare function createCoderToolsRoutes(config?: RouteHandlerConfig): {
118
+ GET: RouteHandler;
119
+ call: {
120
+ POST: RouteHandler;
121
+ };
122
+ };
123
+ /**
124
+ * Create coder file operation route handlers
125
+ */
126
+ declare function createCoderFilesRoutes(config?: RouteHandlerConfig): {
127
+ read: {
128
+ GET: RouteHandler;
129
+ };
130
+ write: {
131
+ POST: RouteHandler;
132
+ };
133
+ list: {
134
+ GET: RouteHandler;
135
+ };
136
+ search: {
137
+ GET: RouteHandler;
138
+ };
139
+ diff: {
140
+ POST: RouteHandler;
141
+ };
142
+ };
143
+ /**
144
+ * Create coder sandbox route handlers
145
+ */
146
+ declare function createCoderSandboxRoutes(config?: RouteHandlerConfig): {
147
+ create: {
148
+ POST: RouteHandler;
149
+ };
150
+ get: {
151
+ GET: RouteHandler;
152
+ };
153
+ exec: {
154
+ POST: RouteHandler;
155
+ };
156
+ destroy: {
157
+ DELETE: RouteHandler;
158
+ };
159
+ };
160
+ /**
161
+ * Create coder command execution route handlers
162
+ */
163
+ declare function createCoderExecRoutes(config?: RouteHandlerConfig): {
164
+ POST: RouteHandler;
165
+ stream: {
166
+ POST: RouteHandler;
167
+ };
168
+ };
169
+
170
+ export { type CRUDRouteHandlers as C, type ForwarderConfig as F, type RequestOptions as R, forwardJSON as a, createAgentRoutes as b, createProxyHandler as c, createAgentDetailRoutes as d, createAgentExecuteRoute as e, forwardRequest as f, createAgentToggleRoutes as g, createSkillRoutes as h, createSkillDetailRoutes as i, createWidgetRoutes as j, createWidgetDetailRoutes as k, createImaginationRoutes as l, createCoderSessionRoutes as m, createCoderSessionDetailRoutes as n, createCoderExecuteRoute as o, createCoderToolsRoutes as p, createCoderFilesRoutes as q, createCoderSandboxRoutes as r, createCoderExecRoutes as s, type RouteHandlerConfig as t, type RouteHandler as u };
@@ -0,0 +1,170 @@
1
+ /**
2
+ * Generic request forwarding utilities
3
+ */
4
+ interface ForwarderConfig {
5
+ baseUrl?: string;
6
+ defaultHeaders?: Record<string, string>;
7
+ timeout?: number;
8
+ }
9
+ interface RequestOptions {
10
+ method?: string;
11
+ headers?: Record<string, string>;
12
+ body?: unknown;
13
+ searchParams?: Record<string, string | undefined>;
14
+ stream?: boolean;
15
+ }
16
+ /**
17
+ * Forward a request to a backend URL
18
+ */
19
+ declare function forwardRequest(path: string, options?: RequestOptions, config?: ForwarderConfig): Promise<Response>;
20
+ /**
21
+ * Forward and return JSON response
22
+ */
23
+ declare function forwardJSON<T = unknown>(path: string, options?: RequestOptions, config?: ForwarderConfig): Promise<{
24
+ data: T;
25
+ status: number;
26
+ }>;
27
+ /**
28
+ * Create a proxy handler that forwards requests
29
+ */
30
+ declare function createProxyHandler(path: string | ((req: Request) => string), config?: ForwarderConfig): (request: Request) => Promise<Response>;
31
+
32
+ /**
33
+ * Next.js API Route Handler Factories
34
+ *
35
+ * Create pre-configured route handlers for common patterns
36
+ */
37
+
38
+ interface RouteHandlerConfig extends ForwarderConfig {
39
+ requireAuth?: boolean;
40
+ enrichResponse?: (data: unknown) => Promise<unknown>;
41
+ }
42
+ type RouteHandler = (request: Request, context?: {
43
+ params?: Record<string, string>;
44
+ }) => Promise<Response>;
45
+ interface CRUDRouteHandlers {
46
+ GET: RouteHandler;
47
+ POST: RouteHandler;
48
+ PUT?: RouteHandler;
49
+ DELETE?: RouteHandler;
50
+ }
51
+ /**
52
+ * Create agent route handlers
53
+ */
54
+ declare function createAgentRoutes(config?: RouteHandlerConfig): CRUDRouteHandlers;
55
+ /**
56
+ * Create agent detail route handlers (for [id] routes)
57
+ */
58
+ declare function createAgentDetailRoutes(config?: RouteHandlerConfig): CRUDRouteHandlers;
59
+ /**
60
+ * Create agent execute route handler
61
+ */
62
+ declare function createAgentExecuteRoute(config?: RouteHandlerConfig): {
63
+ POST: RouteHandler;
64
+ };
65
+ /**
66
+ * Create agent enable/disable route handlers
67
+ */
68
+ declare function createAgentToggleRoutes(config?: RouteHandlerConfig): {
69
+ enable: {
70
+ POST: RouteHandler;
71
+ };
72
+ disable: {
73
+ POST: RouteHandler;
74
+ };
75
+ };
76
+ /**
77
+ * Create skill route handlers
78
+ */
79
+ declare function createSkillRoutes(config?: RouteHandlerConfig): CRUDRouteHandlers;
80
+ /**
81
+ * Create skill detail route handlers
82
+ */
83
+ declare function createSkillDetailRoutes(config?: RouteHandlerConfig): CRUDRouteHandlers;
84
+ /**
85
+ * Create widget route handlers (same pattern as skills)
86
+ */
87
+ declare function createWidgetRoutes(config?: RouteHandlerConfig): CRUDRouteHandlers;
88
+ /**
89
+ * Create widget detail route handlers
90
+ */
91
+ declare function createWidgetDetailRoutes(config?: RouteHandlerConfig): CRUDRouteHandlers;
92
+ /**
93
+ * Create imagination route handlers
94
+ */
95
+ declare function createImaginationRoutes(config?: RouteHandlerConfig): CRUDRouteHandlers;
96
+ /**
97
+ * Create coder session route handlers
98
+ */
99
+ declare function createCoderSessionRoutes(config?: RouteHandlerConfig): CRUDRouteHandlers;
100
+ /**
101
+ * Create coder session detail route handlers
102
+ */
103
+ declare function createCoderSessionDetailRoutes(config?: RouteHandlerConfig): CRUDRouteHandlers & {
104
+ abort: {
105
+ POST: RouteHandler;
106
+ };
107
+ };
108
+ /**
109
+ * Create coder execute route handler (with streaming support)
110
+ */
111
+ declare function createCoderExecuteRoute(config?: RouteHandlerConfig): {
112
+ POST: RouteHandler;
113
+ };
114
+ /**
115
+ * Create coder tools route handlers
116
+ */
117
+ declare function createCoderToolsRoutes(config?: RouteHandlerConfig): {
118
+ GET: RouteHandler;
119
+ call: {
120
+ POST: RouteHandler;
121
+ };
122
+ };
123
+ /**
124
+ * Create coder file operation route handlers
125
+ */
126
+ declare function createCoderFilesRoutes(config?: RouteHandlerConfig): {
127
+ read: {
128
+ GET: RouteHandler;
129
+ };
130
+ write: {
131
+ POST: RouteHandler;
132
+ };
133
+ list: {
134
+ GET: RouteHandler;
135
+ };
136
+ search: {
137
+ GET: RouteHandler;
138
+ };
139
+ diff: {
140
+ POST: RouteHandler;
141
+ };
142
+ };
143
+ /**
144
+ * Create coder sandbox route handlers
145
+ */
146
+ declare function createCoderSandboxRoutes(config?: RouteHandlerConfig): {
147
+ create: {
148
+ POST: RouteHandler;
149
+ };
150
+ get: {
151
+ GET: RouteHandler;
152
+ };
153
+ exec: {
154
+ POST: RouteHandler;
155
+ };
156
+ destroy: {
157
+ DELETE: RouteHandler;
158
+ };
159
+ };
160
+ /**
161
+ * Create coder command execution route handlers
162
+ */
163
+ declare function createCoderExecRoutes(config?: RouteHandlerConfig): {
164
+ POST: RouteHandler;
165
+ stream: {
166
+ POST: RouteHandler;
167
+ };
168
+ };
169
+
170
+ export { type CRUDRouteHandlers as C, type ForwarderConfig as F, type RequestOptions as R, forwardJSON as a, createAgentRoutes as b, createProxyHandler as c, createAgentDetailRoutes as d, createAgentExecuteRoute as e, forwardRequest as f, createAgentToggleRoutes as g, createSkillRoutes as h, createSkillDetailRoutes as i, createWidgetRoutes as j, createWidgetDetailRoutes as k, createImaginationRoutes as l, createCoderSessionRoutes as m, createCoderSessionDetailRoutes as n, createCoderExecuteRoute as o, createCoderToolsRoutes as p, createCoderFilesRoutes as q, createCoderSandboxRoutes as r, createCoderExecRoutes as s, type RouteHandlerConfig as t, type RouteHandler as u };