@agi-cli/server 0.1.166 → 0.1.168
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agi-cli/server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.168",
|
|
4
4
|
"description": "HTTP API server for AGI CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"typecheck": "tsc --noEmit"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@agi-cli/sdk": "0.1.
|
|
33
|
-
"@agi-cli/database": "0.1.
|
|
32
|
+
"@agi-cli/sdk": "0.1.168",
|
|
33
|
+
"@agi-cli/database": "0.1.168",
|
|
34
34
|
"drizzle-orm": "^0.44.5",
|
|
35
35
|
"hono": "^4.9.9",
|
|
36
36
|
"zod": "^4.1.8"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Hono } from 'hono';
|
|
2
2
|
import {
|
|
3
3
|
resolveApproval,
|
|
4
|
+
getPendingApproval,
|
|
4
5
|
getPendingApprovalsForSession,
|
|
5
6
|
} from '../runtime/tools/approval.ts';
|
|
6
7
|
|
|
@@ -20,6 +21,21 @@ export function registerSessionApprovalRoute(app: Hono) {
|
|
|
20
21
|
return c.json({ ok: false, error: 'approved must be a boolean' }, 400);
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
const pending = getPendingApproval(body.callId);
|
|
25
|
+
if (!pending) {
|
|
26
|
+
return c.json(
|
|
27
|
+
{ ok: false, error: 'No pending approval found for this callId' },
|
|
28
|
+
404,
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (pending.sessionId !== sessionId) {
|
|
33
|
+
return c.json(
|
|
34
|
+
{ ok: false, error: 'Approval does not belong to this session' },
|
|
35
|
+
403,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
23
39
|
const result = resolveApproval(body.callId, body.approved);
|
|
24
40
|
|
|
25
41
|
if (!result.ok) {
|
package/src/routes/setu.ts
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
type TopupMethod,
|
|
20
20
|
} from '../runtime/topup/manager.ts';
|
|
21
21
|
|
|
22
|
-
const SETU_BASE_URL = process.env.SETU_BASE_URL || 'https://setu.
|
|
22
|
+
const SETU_BASE_URL = process.env.SETU_BASE_URL || 'https://api.setu.nitish.sh';
|
|
23
23
|
|
|
24
24
|
function getSetuBaseUrl(): string {
|
|
25
25
|
return SETU_BASE_URL.endsWith('/')
|
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
import { getHomeDir } from '@agi-cli/sdk';
|
|
2
2
|
|
|
3
|
+
async function detectProjectTooling(
|
|
4
|
+
projectRoot: string,
|
|
5
|
+
): Promise<{ packageManager?: string; runtime?: string; language?: string }> {
|
|
6
|
+
const { existsSync } = await import('node:fs');
|
|
7
|
+
const { join } = await import('node:path');
|
|
8
|
+
const result: {
|
|
9
|
+
packageManager?: string;
|
|
10
|
+
runtime?: string;
|
|
11
|
+
language?: string;
|
|
12
|
+
} = {};
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
const pkgPath = join(projectRoot, 'package.json');
|
|
16
|
+
if (existsSync(pkgPath)) {
|
|
17
|
+
const pkg = await Bun.file(pkgPath).json();
|
|
18
|
+
if (pkg.packageManager) {
|
|
19
|
+
const match = String(pkg.packageManager).match(/^(bun|npm|yarn|pnpm)/);
|
|
20
|
+
if (match) result.packageManager = match[1];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
} catch {}
|
|
24
|
+
|
|
25
|
+
if (!result.packageManager) {
|
|
26
|
+
if (
|
|
27
|
+
existsSync(join(projectRoot, 'bun.lockb')) ||
|
|
28
|
+
existsSync(join(projectRoot, 'bun.lock'))
|
|
29
|
+
) {
|
|
30
|
+
result.packageManager = 'bun';
|
|
31
|
+
} else if (existsSync(join(projectRoot, 'yarn.lock'))) {
|
|
32
|
+
result.packageManager = 'yarn';
|
|
33
|
+
} else if (existsSync(join(projectRoot, 'pnpm-lock.yaml'))) {
|
|
34
|
+
result.packageManager = 'pnpm';
|
|
35
|
+
} else if (existsSync(join(projectRoot, 'package-lock.json'))) {
|
|
36
|
+
result.packageManager = 'npm';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (existsSync(join(projectRoot, 'package.json'))) {
|
|
41
|
+
result.runtime = result.packageManager === 'bun' ? 'bun' : 'node';
|
|
42
|
+
} else if (existsSync(join(projectRoot, 'Cargo.toml'))) {
|
|
43
|
+
result.language = 'rust';
|
|
44
|
+
} else if (existsSync(join(projectRoot, 'go.mod'))) {
|
|
45
|
+
result.language = 'go';
|
|
46
|
+
} else if (
|
|
47
|
+
existsSync(join(projectRoot, 'pyproject.toml')) ||
|
|
48
|
+
existsSync(join(projectRoot, 'requirements.txt'))
|
|
49
|
+
) {
|
|
50
|
+
result.language = 'python';
|
|
51
|
+
} else if (existsSync(join(projectRoot, 'Gemfile'))) {
|
|
52
|
+
result.language = 'ruby';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
|
|
3
58
|
export async function getEnvironmentContext(
|
|
4
59
|
projectRoot: string,
|
|
5
60
|
): Promise<string> {
|
|
@@ -21,6 +76,22 @@ export async function getEnvironmentContext(
|
|
|
21
76
|
|
|
22
77
|
parts.push(` Platform: ${process.platform}`);
|
|
23
78
|
parts.push(` Today's date: ${new Date().toDateString()}`);
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
const tooling = await detectProjectTooling(projectRoot);
|
|
82
|
+
if (tooling.packageManager) {
|
|
83
|
+
parts.push(
|
|
84
|
+
` Package manager: ${tooling.packageManager} (ALWAYS use this for install/run/build commands)`,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
if (tooling.runtime) {
|
|
88
|
+
parts.push(` Runtime: ${tooling.runtime}`);
|
|
89
|
+
}
|
|
90
|
+
if (tooling.language) {
|
|
91
|
+
parts.push(` Primary language: ${tooling.language}`);
|
|
92
|
+
}
|
|
93
|
+
} catch {}
|
|
94
|
+
|
|
24
95
|
parts.push('</env>');
|
|
25
96
|
|
|
26
97
|
return parts.join('\n');
|
|
@@ -18,7 +18,6 @@ export const CANONICAL_TO_PASCAL: Record<string, string> = {
|
|
|
18
18
|
// File system operations
|
|
19
19
|
read: 'Read',
|
|
20
20
|
write: 'Write',
|
|
21
|
-
edit: 'Edit',
|
|
22
21
|
ls: 'Ls',
|
|
23
22
|
tree: 'Tree',
|
|
24
23
|
cd: 'Cd',
|
|
@@ -58,7 +57,6 @@ export const PASCAL_TO_CANONICAL: Record<string, string> = {
|
|
|
58
57
|
// File system operations
|
|
59
58
|
Read: 'read',
|
|
60
59
|
Write: 'write',
|
|
61
|
-
Edit: 'edit',
|
|
62
60
|
Ls: 'ls',
|
|
63
61
|
Tree: 'tree',
|
|
64
62
|
Cd: 'cd',
|