@agentconnect/cli 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.
- package/README.md +58 -0
- package/dist/fs-utils.d.ts +9 -0
- package/dist/fs-utils.js +43 -0
- package/dist/host.d.ts +7 -0
- package/dist/host.js +663 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3020 -0
- package/dist/manifest.d.ts +10 -0
- package/dist/manifest.js +34 -0
- package/dist/observed.d.ts +7 -0
- package/dist/observed.js +69 -0
- package/dist/paths.d.ts +2 -0
- package/dist/paths.js +36 -0
- package/dist/providers/claude.d.ts +10 -0
- package/dist/providers/claude.js +672 -0
- package/dist/providers/codex.d.ts +9 -0
- package/dist/providers/codex.js +509 -0
- package/dist/providers/index.d.ts +5 -0
- package/dist/providers/index.js +90 -0
- package/dist/providers/local.d.ts +8 -0
- package/dist/providers/local.js +111 -0
- package/dist/providers/utils.d.ts +32 -0
- package/dist/providers/utils.js +256 -0
- package/dist/registry-validate.d.ts +6 -0
- package/dist/registry-validate.js +209 -0
- package/dist/registry.d.ts +17 -0
- package/dist/registry.js +66 -0
- package/dist/types.d.ts +225 -0
- package/dist/types.js +1 -0
- package/dist/zip.d.ts +9 -0
- package/dist/zip.js +71 -0
- package/package.json +45 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ErrorObject } from 'ajv';
|
|
2
|
+
import type { AppManifest } from './types.js';
|
|
3
|
+
export declare function readManifestFromDir(appPath: string): Promise<AppManifest>;
|
|
4
|
+
export declare function readManifestFromZip(zipPath: string): Promise<AppManifest>;
|
|
5
|
+
export declare function loadManifestSchema(): Promise<object>;
|
|
6
|
+
export interface ManifestValidationResult {
|
|
7
|
+
valid: boolean;
|
|
8
|
+
errors: ErrorObject[];
|
|
9
|
+
}
|
|
10
|
+
export declare function validateManifest(manifest: unknown): Promise<ManifestValidationResult>;
|
package/dist/manifest.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import Ajv from 'ajv';
|
|
3
|
+
import { readJson, fileExists } from './fs-utils.js';
|
|
4
|
+
import { findSchemaDir } from './paths.js';
|
|
5
|
+
import { readZipEntry } from './zip.js';
|
|
6
|
+
export async function readManifestFromDir(appPath) {
|
|
7
|
+
const manifestPath = path.join(appPath, 'agentconnect.app.json');
|
|
8
|
+
if (!(await fileExists(manifestPath))) {
|
|
9
|
+
throw new Error('agentconnect.app.json not found in app directory.');
|
|
10
|
+
}
|
|
11
|
+
return readJson(manifestPath);
|
|
12
|
+
}
|
|
13
|
+
export async function readManifestFromZip(zipPath) {
|
|
14
|
+
const content = await readZipEntry(zipPath, 'agentconnect.app.json');
|
|
15
|
+
if (!content) {
|
|
16
|
+
throw new Error('agentconnect.app.json not found in zip.');
|
|
17
|
+
}
|
|
18
|
+
return JSON.parse(content);
|
|
19
|
+
}
|
|
20
|
+
export async function loadManifestSchema() {
|
|
21
|
+
const schemaDir = await findSchemaDir();
|
|
22
|
+
if (!schemaDir) {
|
|
23
|
+
throw new Error('Unable to locate schemas directory.');
|
|
24
|
+
}
|
|
25
|
+
const schemaPath = path.join(schemaDir, 'app-manifest.json');
|
|
26
|
+
return readJson(schemaPath);
|
|
27
|
+
}
|
|
28
|
+
export async function validateManifest(manifest) {
|
|
29
|
+
const schema = await loadManifestSchema();
|
|
30
|
+
const ajv = new Ajv({ allErrors: true, strict: false });
|
|
31
|
+
const validate = ajv.compile(schema);
|
|
32
|
+
const valid = validate(manifest);
|
|
33
|
+
return { valid: Boolean(valid), errors: validate.errors || [] };
|
|
34
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ObservedTracker } from './types.js';
|
|
2
|
+
export interface ObservedTrackerOptions {
|
|
3
|
+
basePath: string;
|
|
4
|
+
appId: string;
|
|
5
|
+
requested?: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function createObservedTracker({ basePath, appId, requested, }: ObservedTrackerOptions): ObservedTracker;
|
package/dist/observed.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
export function createObservedTracker({ basePath, appId, requested = [], }) {
|
|
4
|
+
const requestedList = Array.isArray(requested) ? requested.filter(Boolean) : [];
|
|
5
|
+
const dirPath = path.join(basePath, '.agentconnect');
|
|
6
|
+
const filePath = path.join(dirPath, 'observed-capabilities.json');
|
|
7
|
+
const observed = new Set();
|
|
8
|
+
let writeTimer = null;
|
|
9
|
+
function load() {
|
|
10
|
+
if (!fs.existsSync(filePath))
|
|
11
|
+
return;
|
|
12
|
+
try {
|
|
13
|
+
const raw = fs.readFileSync(filePath, 'utf8');
|
|
14
|
+
const parsed = JSON.parse(raw);
|
|
15
|
+
if (Array.isArray(parsed?.observed)) {
|
|
16
|
+
for (const entry of parsed.observed) {
|
|
17
|
+
if (typeof entry === 'string' && entry)
|
|
18
|
+
observed.add(entry);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
// ignore parse errors
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function snapshot() {
|
|
27
|
+
return {
|
|
28
|
+
appId,
|
|
29
|
+
requested: requestedList,
|
|
30
|
+
observed: Array.from(observed).sort(),
|
|
31
|
+
updatedAt: new Date().toISOString(),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function flush() {
|
|
35
|
+
if (writeTimer) {
|
|
36
|
+
clearTimeout(writeTimer);
|
|
37
|
+
writeTimer = null;
|
|
38
|
+
}
|
|
39
|
+
const payload = JSON.stringify(snapshot(), null, 2);
|
|
40
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
41
|
+
fs.writeFileSync(filePath, payload);
|
|
42
|
+
}
|
|
43
|
+
function scheduleFlush() {
|
|
44
|
+
if (writeTimer)
|
|
45
|
+
return;
|
|
46
|
+
writeTimer = setTimeout(() => {
|
|
47
|
+
flush();
|
|
48
|
+
}, 400);
|
|
49
|
+
}
|
|
50
|
+
function record(capability) {
|
|
51
|
+
const value = typeof capability === 'string' ? capability.trim() : '';
|
|
52
|
+
if (!value)
|
|
53
|
+
return;
|
|
54
|
+
if (observed.has(value))
|
|
55
|
+
return;
|
|
56
|
+
observed.add(value);
|
|
57
|
+
scheduleFlush();
|
|
58
|
+
}
|
|
59
|
+
function list() {
|
|
60
|
+
return Array.from(observed).sort();
|
|
61
|
+
}
|
|
62
|
+
load();
|
|
63
|
+
return {
|
|
64
|
+
record,
|
|
65
|
+
list,
|
|
66
|
+
snapshot,
|
|
67
|
+
flush,
|
|
68
|
+
};
|
|
69
|
+
}
|
package/dist/paths.d.ts
ADDED
package/dist/paths.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { promises as fs } from 'fs';
|
|
4
|
+
async function exists(target) {
|
|
5
|
+
try {
|
|
6
|
+
await fs.stat(target);
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function resolveAppPath(input) {
|
|
14
|
+
const candidate = input ? path.resolve(input) : process.cwd();
|
|
15
|
+
return candidate;
|
|
16
|
+
}
|
|
17
|
+
export async function findSchemaDir() {
|
|
18
|
+
const envDir = process.env.AGENTCONNECT_SCHEMA_DIR;
|
|
19
|
+
if (envDir && (await exists(envDir)))
|
|
20
|
+
return envDir;
|
|
21
|
+
const start = path.dirname(fileURLToPath(import.meta.url));
|
|
22
|
+
const roots = [start, process.cwd()];
|
|
23
|
+
for (const root of roots) {
|
|
24
|
+
let current = root;
|
|
25
|
+
for (let i = 0; i < 8; i += 1) {
|
|
26
|
+
const candidate = path.join(current, 'schemas');
|
|
27
|
+
if (await exists(candidate))
|
|
28
|
+
return candidate;
|
|
29
|
+
const parent = path.dirname(current);
|
|
30
|
+
if (parent === current)
|
|
31
|
+
break;
|
|
32
|
+
current = parent;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ProviderStatus, RunPromptOptions, RunPromptResult, InstallResult, ProviderLoginOptions, ModelInfo } from '../types.js';
|
|
2
|
+
export declare function getClaudeCommand(): string;
|
|
3
|
+
export declare function listClaudeModels(): Promise<ModelInfo[]>;
|
|
4
|
+
export declare function listClaudeRecentModels(): Promise<ModelInfo[]>;
|
|
5
|
+
export declare function ensureClaudeInstalled(): Promise<InstallResult>;
|
|
6
|
+
export declare function getClaudeStatus(): Promise<ProviderStatus>;
|
|
7
|
+
export declare function loginClaude(options?: ProviderLoginOptions): Promise<{
|
|
8
|
+
loggedIn: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function runClaudePrompt({ prompt, resumeSessionId, model, cwd, onEvent, signal, }: RunPromptOptions): Promise<RunPromptResult>;
|