@almyty/agents 0.1.1 → 1.2.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 +12 -4
- package/dist/index.js +5 -3
- package/package.json +19 -4
- package/dist/client.d.ts +0 -50
- package/dist/client.js +0 -121
- package/dist/credentials.d.ts +0 -16
- package/dist/credentials.js +0 -34
package/README.md
CHANGED
|
@@ -27,8 +27,12 @@ $ npx @almyty/agents run my-agent --input '{"text": "hello"}' --watch
|
|
|
27
27
|
| Flag | Description |
|
|
28
28
|
|------|-------------|
|
|
29
29
|
| `--input '<json>'` | Input payload (object for workflow, string or object for autonomous) |
|
|
30
|
+
| `--resume <conversation-id>` | Resume a previous autonomous conversation |
|
|
30
31
|
| `--watch` | Stream steps as they arrive |
|
|
31
32
|
| `--json` | Print raw JSON output |
|
|
33
|
+
| `--max-steps <n>` | Autonomous: max steps (default 50) |
|
|
34
|
+
| `--max-cost-cents <n>` | Autonomous: max cost in cents (default 100) |
|
|
35
|
+
| `--max-duration-ms <ms>` | Autonomous: max wall time in ms (default 3600000) |
|
|
32
36
|
|
|
33
37
|
## Environment variables
|
|
34
38
|
|
|
@@ -41,10 +45,14 @@ $ npx @almyty/agents run my-agent --input '{"text": "hello"}' --watch
|
|
|
41
45
|
|
|
42
46
|
Requires `npx @almyty/auth login` first. Reads credentials from `~/.almyty/credentials.json`.
|
|
43
47
|
|
|
44
|
-
##
|
|
48
|
+
## About almyty
|
|
45
49
|
|
|
46
|
-
|
|
50
|
+
almyty is the full-stack platform for AI agents, agnostic by design: any LLM, any
|
|
51
|
+
API turned into tools, served over MCP, A2A, UTCP, and Agent Skills. Open source,
|
|
52
|
+
no lock-in.
|
|
47
53
|
|
|
48
|
-
|
|
54
|
+
- Website — https://almyty.com
|
|
55
|
+
- Docs — https://docs.almyty.com
|
|
56
|
+
- Source — https://github.com/almyty-inc/almyty
|
|
49
57
|
|
|
50
|
-
|
|
58
|
+
Apache-2.0 © Almyty Inc.
|
package/dist/index.js
CHANGED
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
* Reads credentials from ~/.almyty/credentials.json (created by
|
|
12
12
|
* `npx @almyty/auth login`).
|
|
13
13
|
*/
|
|
14
|
-
import { AlmytyClient } from '
|
|
15
|
-
import { resolveCredentialsOrExit } from './credentials.js';
|
|
14
|
+
import { AlmytyClient, resolveCredentialsOrExit } from '@almyty/client';
|
|
16
15
|
const VERSION = '0.1.0';
|
|
17
16
|
function printHelp() {
|
|
18
17
|
console.log(`
|
|
@@ -31,6 +30,7 @@ Commands:
|
|
|
31
30
|
|
|
32
31
|
Run options:
|
|
33
32
|
--input '<json>' Input payload (workflow: object; autonomous: string or object)
|
|
33
|
+
--resume <conversation-id> Resume a previous conversation
|
|
34
34
|
--max-steps <n> Autonomous: max steps (default 50)
|
|
35
35
|
--max-cost-cents <n> Autonomous: max cost in cents (default 100)
|
|
36
36
|
--max-duration-ms <ms> Autonomous: max wall time in ms (default 3600000)
|
|
@@ -188,7 +188,9 @@ async function cmdRun(args) {
|
|
|
188
188
|
limits.maxCostCents = Number(args.flags['max-cost-cents']);
|
|
189
189
|
if (args.flags['max-duration-ms'])
|
|
190
190
|
limits.maxDurationMs = Number(args.flags['max-duration-ms']);
|
|
191
|
-
|
|
191
|
+
if (typeof args.flags.resume === 'string')
|
|
192
|
+
limits.conversationId = args.flags.resume;
|
|
193
|
+
const runStub = await client.startRun(agent.id, rawInput ?? '', limits);
|
|
192
194
|
if (!args.flags.watch) {
|
|
193
195
|
if (args.flags.json) {
|
|
194
196
|
console.log(JSON.stringify(runStub, null, 2));
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@almyty/agents",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "Run and manage almyty agents from your terminal \u2014 list, invoke workflow or autonomous runs, stream steps, and inspect run history.",
|
|
5
8
|
"type": "module",
|
|
6
9
|
"main": "dist/index.js",
|
|
7
10
|
"bin": {
|
|
@@ -11,7 +14,7 @@
|
|
|
11
14
|
"dist"
|
|
12
15
|
],
|
|
13
16
|
"scripts": {
|
|
14
|
-
"build": "tsc",
|
|
17
|
+
"build": "tsc && chmod +x dist/index.js",
|
|
15
18
|
"dev": "tsx src/index.ts",
|
|
16
19
|
"test": "vitest run",
|
|
17
20
|
"test:watch": "vitest",
|
|
@@ -23,11 +26,23 @@
|
|
|
23
26
|
"cli"
|
|
24
27
|
],
|
|
25
28
|
"author": "almyty",
|
|
26
|
-
"license": "
|
|
29
|
+
"license": "Apache-2.0",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@almyty/client": "^1.2.0"
|
|
32
|
+
},
|
|
27
33
|
"devDependencies": {
|
|
28
34
|
"@types/node": "^25.4.0",
|
|
29
35
|
"tsx": "^4.7.0",
|
|
30
36
|
"typescript": "^5.3.0",
|
|
31
37
|
"vitest": "^4.1.0"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://almyty.com",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/almyty-inc/almyty.git",
|
|
43
|
+
"directory": "packages/agents-cli"
|
|
44
|
+
},
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/almyty-inc/almyty/issues"
|
|
32
47
|
}
|
|
33
48
|
}
|
package/dist/client.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tiny HTTP client for the almyty REST API, scoped to the surface
|
|
3
|
-
* needed by @almyty/agents (list / get / invoke / runs).
|
|
4
|
-
*/
|
|
5
|
-
export interface AgentInfo {
|
|
6
|
-
id: string;
|
|
7
|
-
name: string;
|
|
8
|
-
description?: string;
|
|
9
|
-
mode?: 'workflow' | 'autonomous';
|
|
10
|
-
status?: string;
|
|
11
|
-
}
|
|
12
|
-
export interface AgentRun {
|
|
13
|
-
id: string;
|
|
14
|
-
status: string;
|
|
15
|
-
output?: any;
|
|
16
|
-
error?: string;
|
|
17
|
-
steps?: any[];
|
|
18
|
-
totalCost?: number;
|
|
19
|
-
totalTokens?: number;
|
|
20
|
-
}
|
|
21
|
-
export declare class AlmytyClient {
|
|
22
|
-
private readonly baseUrl;
|
|
23
|
-
private readonly token;
|
|
24
|
-
constructor(baseUrl: string, token: string);
|
|
25
|
-
private request;
|
|
26
|
-
listAgents(): Promise<AgentInfo[]>;
|
|
27
|
-
findAgentByNameOrId(nameOrId: string): Promise<AgentInfo | null>;
|
|
28
|
-
invokeAgent(agentId: string, input: Record<string, any>): Promise<any>;
|
|
29
|
-
startAgentRun(agentId: string, input: any, limits?: {
|
|
30
|
-
maxSteps?: number;
|
|
31
|
-
maxCostCents?: number;
|
|
32
|
-
maxDurationMs?: number;
|
|
33
|
-
}): Promise<AgentRun>;
|
|
34
|
-
getRun(agentId: string, runId: string): Promise<AgentRun>;
|
|
35
|
-
listRuns(agentId: string, page?: number, limit?: number): Promise<{
|
|
36
|
-
data: AgentRun[];
|
|
37
|
-
total: number;
|
|
38
|
-
}>;
|
|
39
|
-
sendRunInput(agentId: string, runId: string, input: string): Promise<void>;
|
|
40
|
-
cancelRun(agentId: string, runId: string): Promise<void>;
|
|
41
|
-
/**
|
|
42
|
-
* Poll a run until it reaches a terminal status (or waiting_input).
|
|
43
|
-
* Calls onStep whenever new steps appear so callers can stream output.
|
|
44
|
-
*/
|
|
45
|
-
pollRun(agentId: string, runId: string, options?: {
|
|
46
|
-
intervalMs?: number;
|
|
47
|
-
timeoutMs?: number;
|
|
48
|
-
onStep?: (run: AgentRun) => void;
|
|
49
|
-
}): Promise<AgentRun>;
|
|
50
|
-
}
|
package/dist/client.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tiny HTTP client for the almyty REST API, scoped to the surface
|
|
3
|
-
* needed by @almyty/agents (list / get / invoke / runs).
|
|
4
|
-
*/
|
|
5
|
-
const TERMINAL_STATUSES = new Set(['completed', 'failed', 'cancelled', 'timeout']);
|
|
6
|
-
export class AlmytyClient {
|
|
7
|
-
baseUrl;
|
|
8
|
-
token;
|
|
9
|
-
constructor(baseUrl, token) {
|
|
10
|
-
this.baseUrl = baseUrl.replace(/\/$/, '');
|
|
11
|
-
this.token = token;
|
|
12
|
-
}
|
|
13
|
-
async request(path, init = {}) {
|
|
14
|
-
const url = `${this.baseUrl}${path}`;
|
|
15
|
-
const headers = {
|
|
16
|
-
Authorization: `Bearer ${this.token}`,
|
|
17
|
-
'Content-Type': 'application/json',
|
|
18
|
-
...(init.headers || {}),
|
|
19
|
-
};
|
|
20
|
-
const res = await fetch(url, { ...init, headers });
|
|
21
|
-
if (!res.ok) {
|
|
22
|
-
if (res.status === 401) {
|
|
23
|
-
throw new Error('Authentication failed. Run: npx @almyty/auth login');
|
|
24
|
-
}
|
|
25
|
-
const text = await res.text().catch(() => '');
|
|
26
|
-
throw new Error(`API error ${res.status}: ${text}`);
|
|
27
|
-
}
|
|
28
|
-
if (res.status === 204)
|
|
29
|
-
return null;
|
|
30
|
-
return res.json();
|
|
31
|
-
}
|
|
32
|
-
async listAgents() {
|
|
33
|
-
const data = await this.request('/agents');
|
|
34
|
-
const agents = data?.data?.data || data?.data || data || [];
|
|
35
|
-
return agents.map((a) => ({
|
|
36
|
-
id: a.id,
|
|
37
|
-
name: a.name,
|
|
38
|
-
description: a.description,
|
|
39
|
-
mode: a.mode,
|
|
40
|
-
status: a.status,
|
|
41
|
-
}));
|
|
42
|
-
}
|
|
43
|
-
async findAgentByNameOrId(nameOrId) {
|
|
44
|
-
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
45
|
-
if (uuidRegex.test(nameOrId)) {
|
|
46
|
-
try {
|
|
47
|
-
const data = await this.request(`/agents/${nameOrId}`);
|
|
48
|
-
const a = data?.data ?? data;
|
|
49
|
-
if (a?.id) {
|
|
50
|
-
return { id: a.id, name: a.name, description: a.description, mode: a.mode, status: a.status };
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
// fall through to name search
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
const all = await this.listAgents();
|
|
58
|
-
const lower = nameOrId.toLowerCase();
|
|
59
|
-
return (all.find((a) => a.name === nameOrId) ||
|
|
60
|
-
all.find((a) => a.name.toLowerCase() === lower) ||
|
|
61
|
-
all.find((a) => a.name.toLowerCase().replace(/\s+/g, '-') === lower) ||
|
|
62
|
-
null);
|
|
63
|
-
}
|
|
64
|
-
async invokeAgent(agentId, input) {
|
|
65
|
-
const data = await this.request(`/agents/${agentId}/invoke`, {
|
|
66
|
-
method: 'POST',
|
|
67
|
-
body: JSON.stringify({ input }),
|
|
68
|
-
});
|
|
69
|
-
return data?.data ?? data;
|
|
70
|
-
}
|
|
71
|
-
async startAgentRun(agentId, input, limits) {
|
|
72
|
-
const data = await this.request(`/agents/${agentId}/runs`, {
|
|
73
|
-
method: 'POST',
|
|
74
|
-
body: JSON.stringify({ input, ...(limits || {}) }),
|
|
75
|
-
});
|
|
76
|
-
const run = data?.data ?? data;
|
|
77
|
-
return { id: run.id, status: run.status };
|
|
78
|
-
}
|
|
79
|
-
async getRun(agentId, runId) {
|
|
80
|
-
const data = await this.request(`/agents/${agentId}/runs/${runId}`);
|
|
81
|
-
return (data?.data ?? data);
|
|
82
|
-
}
|
|
83
|
-
async listRuns(agentId, page = 1, limit = 20) {
|
|
84
|
-
const data = await this.request(`/agents/${agentId}/runs?page=${page}&limit=${limit}`);
|
|
85
|
-
return {
|
|
86
|
-
data: data?.data ?? [],
|
|
87
|
-
total: data?.pagination?.total ?? 0,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
async sendRunInput(agentId, runId, input) {
|
|
91
|
-
await this.request(`/agents/${agentId}/runs/${runId}/input`, {
|
|
92
|
-
method: 'POST',
|
|
93
|
-
body: JSON.stringify({ input }),
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
async cancelRun(agentId, runId) {
|
|
97
|
-
await this.request(`/agents/${agentId}/runs/${runId}/cancel`, { method: 'POST' });
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Poll a run until it reaches a terminal status (or waiting_input).
|
|
101
|
-
* Calls onStep whenever new steps appear so callers can stream output.
|
|
102
|
-
*/
|
|
103
|
-
async pollRun(agentId, runId, options = {}) {
|
|
104
|
-
const intervalMs = options.intervalMs ?? 1500;
|
|
105
|
-
const timeoutMs = options.timeoutMs ?? 5 * 60_000;
|
|
106
|
-
const deadline = Date.now() + timeoutMs;
|
|
107
|
-
let lastStepCount = -1;
|
|
108
|
-
while (Date.now() < deadline) {
|
|
109
|
-
const run = await this.getRun(agentId, runId);
|
|
110
|
-
if (Array.isArray(run.steps) && run.steps.length !== lastStepCount) {
|
|
111
|
-
lastStepCount = run.steps.length;
|
|
112
|
-
options.onStep?.(run);
|
|
113
|
-
}
|
|
114
|
-
if (run.status && (TERMINAL_STATUSES.has(run.status) || run.status === 'waiting_input')) {
|
|
115
|
-
return run;
|
|
116
|
-
}
|
|
117
|
-
await new Promise((r) => setTimeout(r, intervalMs));
|
|
118
|
-
}
|
|
119
|
-
throw new Error(`Run ${runId} did not finish within ${Math.round(timeoutMs / 1000)}s`);
|
|
120
|
-
}
|
|
121
|
-
}
|
package/dist/credentials.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Read shared almyty credentials from ~/.almyty/credentials.json.
|
|
3
|
-
*
|
|
4
|
-
* Identical to packages/auth-cli/src/credentials.ts (intentional copy
|
|
5
|
-
* to keep each CLI package self-contained — these few helpers don't
|
|
6
|
-
* justify a workspace dependency).
|
|
7
|
-
*/
|
|
8
|
-
export declare const CREDENTIALS_FILE: string;
|
|
9
|
-
export interface StoredCredentials {
|
|
10
|
-
url: string;
|
|
11
|
-
token: string;
|
|
12
|
-
email?: string;
|
|
13
|
-
frontendUrl?: string;
|
|
14
|
-
}
|
|
15
|
-
export declare function loadCredentials(): StoredCredentials | null;
|
|
16
|
-
export declare function resolveCredentialsOrExit(): StoredCredentials;
|
package/dist/credentials.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Read shared almyty credentials from ~/.almyty/credentials.json.
|
|
3
|
-
*
|
|
4
|
-
* Identical to packages/auth-cli/src/credentials.ts (intentional copy
|
|
5
|
-
* to keep each CLI package self-contained — these few helpers don't
|
|
6
|
-
* justify a workspace dependency).
|
|
7
|
-
*/
|
|
8
|
-
import { readFileSync, existsSync } from 'fs';
|
|
9
|
-
import { homedir } from 'os';
|
|
10
|
-
import { join } from 'path';
|
|
11
|
-
export const CREDENTIALS_FILE = join(homedir(), '.almyty', 'credentials.json');
|
|
12
|
-
export function loadCredentials() {
|
|
13
|
-
try {
|
|
14
|
-
if (!existsSync(CREDENTIALS_FILE))
|
|
15
|
-
return null;
|
|
16
|
-
return JSON.parse(readFileSync(CREDENTIALS_FILE, 'utf-8'));
|
|
17
|
-
}
|
|
18
|
-
catch {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export function resolveCredentialsOrExit() {
|
|
23
|
-
const envToken = process.env.ALMYTY_TOKEN;
|
|
24
|
-
const envUrl = process.env.ALMYTY_URL || 'https://api.almyty.com';
|
|
25
|
-
if (envToken)
|
|
26
|
-
return { url: envUrl, token: envToken };
|
|
27
|
-
const stored = loadCredentials();
|
|
28
|
-
if (stored?.token)
|
|
29
|
-
return stored;
|
|
30
|
-
console.error('Not authenticated. Run one of:');
|
|
31
|
-
console.error(' npx @almyty/auth login');
|
|
32
|
-
console.error(' export ALMYTY_TOKEN=<your-token>');
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|