@synap-core/cli 1.6.1 → 1.8.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/dist/commands/agent-run.d.ts +47 -0
- package/dist/commands/agent-run.js +302 -0
- package/dist/commands/agent-run.js.map +1 -0
- package/dist/commands/artifact.d.ts +26 -0
- package/dist/commands/artifact.js +76 -0
- package/dist/commands/artifact.js.map +1 -0
- package/dist/commands/automation.d.ts +47 -0
- package/dist/commands/automation.js +600 -0
- package/dist/commands/automation.js.map +1 -0
- package/dist/commands/cell.d.ts +55 -0
- package/dist/commands/cell.js +277 -0
- package/dist/commands/cell.js.map +1 -0
- package/dist/commands/connect.js +41 -7
- package/dist/commands/connect.js.map +1 -1
- package/dist/commands/connections.js +0 -16
- package/dist/commands/connections.js.map +1 -1
- package/dist/commands/connectors.d.ts +31 -0
- package/dist/commands/connectors.js +276 -0
- package/dist/commands/connectors.js.map +1 -0
- package/dist/commands/context.d.ts +22 -0
- package/dist/commands/context.js +151 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/data-extra.d.ts +13 -0
- package/dist/commands/data-extra.js +161 -0
- package/dist/commands/data-extra.js.map +1 -0
- package/dist/commands/data.d.ts +13 -9
- package/dist/commands/data.js +220 -109
- package/dist/commands/data.js.map +1 -1
- package/dist/commands/discover.d.ts +18 -0
- package/dist/commands/discover.js +71 -0
- package/dist/commands/discover.js.map +1 -0
- package/dist/commands/doc.d.ts +39 -0
- package/dist/commands/doc.js +130 -0
- package/dist/commands/doc.js.map +1 -0
- package/dist/commands/events.d.ts +26 -0
- package/dist/commands/events.js +68 -0
- package/dist/commands/events.js.map +1 -0
- package/dist/commands/explain.d.ts +21 -0
- package/dist/commands/explain.js +248 -0
- package/dist/commands/explain.js.map +1 -0
- package/dist/commands/graph.d.ts +18 -0
- package/dist/commands/graph.js +73 -0
- package/dist/commands/graph.js.map +1 -0
- package/dist/commands/home.d.ts +12 -0
- package/dist/commands/home.js +54 -0
- package/dist/commands/home.js.map +1 -0
- package/dist/commands/init.d.ts +0 -2
- package/dist/commands/init.js +62 -102
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/keys.d.ts +9 -0
- package/dist/commands/keys.js +79 -0
- package/dist/commands/keys.js.map +1 -0
- package/dist/commands/knowledge.d.ts +32 -18
- package/dist/commands/knowledge.js +303 -53
- package/dist/commands/knowledge.js.map +1 -1
- package/dist/commands/observe.d.ts +9 -0
- package/dist/commands/observe.js +90 -0
- package/dist/commands/observe.js.map +1 -0
- package/dist/commands/open.d.ts +15 -0
- package/dist/commands/open.js +44 -0
- package/dist/commands/open.js.map +1 -0
- package/dist/commands/pods.d.ts +5 -0
- package/dist/commands/pods.js +85 -37
- package/dist/commands/pods.js.map +1 -1
- package/dist/commands/proposals-actions.d.ts +7 -0
- package/dist/commands/proposals-actions.js +40 -0
- package/dist/commands/proposals-actions.js.map +1 -0
- package/dist/commands/providers.d.ts +38 -0
- package/dist/commands/providers.js +170 -0
- package/dist/commands/providers.js.map +1 -0
- package/dist/commands/sessions.d.ts +31 -0
- package/dist/commands/sessions.js +224 -0
- package/dist/commands/sessions.js.map +1 -0
- package/dist/commands/skills-commands.d.ts +26 -0
- package/dist/commands/skills-commands.js +186 -0
- package/dist/commands/skills-commands.js.map +1 -0
- package/dist/commands/skills.d.ts +26 -0
- package/dist/commands/skills.js +195 -0
- package/dist/commands/skills.js.map +1 -0
- package/dist/commands/status.js +68 -30
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/subscribe.d.ts +19 -0
- package/dist/commands/subscribe.js +91 -0
- package/dist/commands/subscribe.js.map +1 -0
- package/dist/commands/view.d.ts +57 -0
- package/dist/commands/view.js +194 -0
- package/dist/commands/view.js.map +1 -0
- package/dist/index.d.ts +3 -4
- package/dist/index.js +823 -206
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-templates.d.ts +25 -0
- package/dist/lib/agent-templates.js +148 -0
- package/dist/lib/agent-templates.js.map +1 -0
- package/dist/lib/agents-config.d.ts +4 -1
- package/dist/lib/agents-config.js +19 -2
- package/dist/lib/agents-config.js.map +1 -1
- package/dist/lib/capture-lane.d.ts +49 -0
- package/dist/lib/capture-lane.js +79 -0
- package/dist/lib/capture-lane.js.map +1 -0
- package/dist/lib/hub-client.d.ts +14 -0
- package/dist/lib/hub-client.js +45 -3
- package/dist/lib/hub-client.js.map +1 -1
- package/dist/lib/pod.d.ts +22 -1
- package/dist/lib/pod.js +32 -2
- package/dist/lib/pod.js.map +1 -1
- package/dist/lib/skills-installer.d.ts +1 -1
- package/dist/lib/skills-installer.js +1 -1
- package/dist/lib/skills-installer.js.map +1 -1
- package/dist/lib/targets.d.ts +17 -1
- package/dist/lib/targets.js +744 -70
- package/dist/lib/targets.js.map +1 -1
- package/node_modules/@synap/hub-rest-client/dist/index.cjs +881 -0
- package/node_modules/@synap/hub-rest-client/dist/index.d.cts +907 -0
- package/node_modules/@synap/hub-rest-client/dist/index.d.ts +907 -0
- package/node_modules/@synap/hub-rest-client/dist/index.js +851 -0
- package/node_modules/@synap/hub-rest-client/package.json +45 -0
- package/node_modules/@synap/hub-rest-client/src/client.ts +1143 -0
- package/node_modules/@synap/hub-rest-client/src/errors.ts +30 -0
- package/node_modules/@synap/hub-rest-client/src/index.ts +111 -0
- package/node_modules/@synap/hub-rest-client/src/setup.ts +77 -0
- package/node_modules/@synap/hub-rest-client/src/types.ts +639 -0
- package/package.json +9 -2
- package/skills/synap/SKILL.md +374 -100
- package/skills/synap-ui/SKILL.md +12 -9
- package/dist/lib/templates.d.ts +0 -11
- package/dist/lib/templates.js +0 -13
- package/dist/lib/templates.js.map +0 -1
- package/dist/templates/agent-os.json +0 -3090
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* synap agent run / schedule / tick
|
|
3
|
+
*
|
|
4
|
+
* The CLI is a thin trigger. The IS handles all reasoning and tool execution
|
|
5
|
+
* server-side via MCP. The CLI's responsibilities are:
|
|
6
|
+
* 1. Resolve which agent (and its pod/workspace) to use
|
|
7
|
+
* 2. Send the goal to IS /v1/chat/completions
|
|
8
|
+
* 3. Store the final output as a `research` entity on the pod
|
|
9
|
+
* 4. Display the result
|
|
10
|
+
*
|
|
11
|
+
* Schedules are stored as `task` entities on the pod (not local files) so they
|
|
12
|
+
* are visible in pod-admin and shareable across machines.
|
|
13
|
+
* `synap agent tick` reads due schedules from the pod and fires them.
|
|
14
|
+
* Wire it to the pod server's crontab for autonomous execution.
|
|
15
|
+
*/
|
|
16
|
+
type Persona = "researcher" | "assistant" | "developer";
|
|
17
|
+
export interface RunOpts {
|
|
18
|
+
goal: string;
|
|
19
|
+
persona?: Persona;
|
|
20
|
+
model?: string;
|
|
21
|
+
workspace?: string;
|
|
22
|
+
maxTokens?: number;
|
|
23
|
+
dryRun?: boolean;
|
|
24
|
+
podUrl?: string;
|
|
25
|
+
apiKey?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ScheduleOpts {
|
|
28
|
+
goal?: string;
|
|
29
|
+
name?: string;
|
|
30
|
+
persona?: Persona;
|
|
31
|
+
model?: string;
|
|
32
|
+
workspace?: string;
|
|
33
|
+
every?: "hourly" | "daily" | "weekly";
|
|
34
|
+
list?: boolean;
|
|
35
|
+
remove?: string;
|
|
36
|
+
runNow?: boolean;
|
|
37
|
+
podUrl?: string;
|
|
38
|
+
apiKey?: string;
|
|
39
|
+
}
|
|
40
|
+
export declare function agentRun(opts: RunOpts): Promise<void>;
|
|
41
|
+
export declare function agentSchedule(opts: ScheduleOpts): Promise<void>;
|
|
42
|
+
export declare function agentTick(opts: {
|
|
43
|
+
dryRun?: boolean;
|
|
44
|
+
podUrl?: string;
|
|
45
|
+
apiKey?: string;
|
|
46
|
+
}): Promise<void>;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* synap agent run / schedule / tick
|
|
3
|
+
*
|
|
4
|
+
* The CLI is a thin trigger. The IS handles all reasoning and tool execution
|
|
5
|
+
* server-side via MCP. The CLI's responsibilities are:
|
|
6
|
+
* 1. Resolve which agent (and its pod/workspace) to use
|
|
7
|
+
* 2. Send the goal to IS /v1/chat/completions
|
|
8
|
+
* 3. Store the final output as a `research` entity on the pod
|
|
9
|
+
* 4. Display the result
|
|
10
|
+
*
|
|
11
|
+
* Schedules are stored as `task` entities on the pod (not local files) so they
|
|
12
|
+
* are visible in pod-admin and shareable across machines.
|
|
13
|
+
* `synap agent tick` reads due schedules from the pod and fires them.
|
|
14
|
+
* Wire it to the pod server's crontab for autonomous execution.
|
|
15
|
+
*/
|
|
16
|
+
import chalk from "chalk";
|
|
17
|
+
import ora from "ora";
|
|
18
|
+
import { resolveHubConfig, hubGet, hubPost, hubPatch } from "../lib/hub-client.js";
|
|
19
|
+
import { log } from "../utils/logger.js";
|
|
20
|
+
// ── Persona system prompts ────────────────────────────────────────────────────
|
|
21
|
+
// Injected as the system message. The IS handles tool use via MCP.
|
|
22
|
+
const PERSONAS = {
|
|
23
|
+
researcher: "You are a research agent. Investigate the given goal thoroughly using all available tools " +
|
|
24
|
+
"(web search, URL fetch, memory recall, entity search). Capture findings as you go. " +
|
|
25
|
+
"When you have a complete synthesis, produce a clear final answer.",
|
|
26
|
+
assistant: "You are a helpful assistant. Complete the given task using all available tools. " +
|
|
27
|
+
"Produce a clear, actionable final answer.",
|
|
28
|
+
developer: "You are a software engineering agent. Analyze the task, recall relevant knowledge, " +
|
|
29
|
+
"reason carefully, and produce a technical conclusion or recommendation.",
|
|
30
|
+
};
|
|
31
|
+
async function callIS(podUrl, apiKey, model, messages, maxTokens) {
|
|
32
|
+
const res = await fetch(`${podUrl}/v1/chat/completions`, {
|
|
33
|
+
method: "POST",
|
|
34
|
+
headers: {
|
|
35
|
+
Authorization: `Bearer ${apiKey}`,
|
|
36
|
+
"Content-Type": "application/json",
|
|
37
|
+
},
|
|
38
|
+
body: JSON.stringify({ model, messages, max_tokens: maxTokens }),
|
|
39
|
+
signal: AbortSignal.timeout(180_000),
|
|
40
|
+
});
|
|
41
|
+
if (!res.ok) {
|
|
42
|
+
const body = await res.text().catch(() => "");
|
|
43
|
+
throw new Error(`IS error (HTTP ${res.status}): ${body.slice(0, 300)}`);
|
|
44
|
+
}
|
|
45
|
+
return res.json();
|
|
46
|
+
}
|
|
47
|
+
async function storeResearch(title, content, tags, cfg) {
|
|
48
|
+
const res = await hubPost("/entities", {
|
|
49
|
+
userId: cfg.userId,
|
|
50
|
+
workspaceId: cfg.workspaceId,
|
|
51
|
+
profileSlug: "research",
|
|
52
|
+
name: title,
|
|
53
|
+
properties: { summary: content, tags, status: "concluded" },
|
|
54
|
+
}, cfg);
|
|
55
|
+
return res.id;
|
|
56
|
+
}
|
|
57
|
+
// ── Schedule helpers ──────────────────────────────────────────────────────────
|
|
58
|
+
const INTERVAL_MS = {
|
|
59
|
+
hourly: 60 * 60 * 1000,
|
|
60
|
+
daily: 24 * 60 * 60 * 1000,
|
|
61
|
+
weekly: 7 * 24 * 60 * 60 * 1000,
|
|
62
|
+
};
|
|
63
|
+
async function listScheduleEntities(cfg) {
|
|
64
|
+
const res = await hubGet("/entities", { q: "[agent-sched]", workspaceId: cfg.workspaceId, limit: "50" }, cfg);
|
|
65
|
+
const entities = (res.entities ?? res);
|
|
66
|
+
return Array.isArray(entities)
|
|
67
|
+
? entities.filter((e) => e.name?.startsWith("[agent-sched]"))
|
|
68
|
+
: [];
|
|
69
|
+
}
|
|
70
|
+
// ── Public: agentRun ──────────────────────────────────────────────────────────
|
|
71
|
+
export async function agentRun(opts) {
|
|
72
|
+
const goal = opts.goal?.trim();
|
|
73
|
+
if (!goal) {
|
|
74
|
+
log.error("--goal is required.");
|
|
75
|
+
log.dim('Example: synap agent run --goal "Research RAG architectures"');
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
const persona = opts.persona ?? "researcher";
|
|
79
|
+
const model = opts.model ?? "synap/balanced";
|
|
80
|
+
const maxTokens = opts.maxTokens ?? 4000;
|
|
81
|
+
let cfg;
|
|
82
|
+
try {
|
|
83
|
+
cfg = await resolveHubConfig({ podUrl: opts.podUrl, apiKey: opts.apiKey });
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
log.error(err.message);
|
|
87
|
+
log.dim("Run `synap pods add` to configure a pod, or pass --pod-url and --api-key.");
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
const workspaceId = opts.workspace ?? cfg.workspaceId;
|
|
91
|
+
const runCfg = { ...cfg, workspaceId };
|
|
92
|
+
if (opts.dryRun) {
|
|
93
|
+
log.heading("Agent run — dry run");
|
|
94
|
+
console.log();
|
|
95
|
+
console.log(` ${chalk.dim("goal")} ${chalk.bold(goal)}`);
|
|
96
|
+
console.log(` ${chalk.dim("persona")} ${chalk.cyan(persona)}`);
|
|
97
|
+
console.log(` ${chalk.dim("model")} ${chalk.cyan(model)}`);
|
|
98
|
+
console.log(` ${chalk.dim("pod")} ${chalk.underline(cfg.podUrl)}`);
|
|
99
|
+
console.log(` ${chalk.dim("workspace")} ${workspaceId ? chalk.underline(workspaceId) : chalk.yellow("none — entities will be pod-global")}`);
|
|
100
|
+
console.log();
|
|
101
|
+
log.dim(`Will POST to: ${cfg.podUrl}/v1/chat/completions`);
|
|
102
|
+
log.dim("Remove --dry-run to execute.");
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
log.heading(`Agent run — ${chalk.bold(persona)}`);
|
|
106
|
+
log.dim(`Goal: ${goal}`);
|
|
107
|
+
log.dim(`Model: ${model} · Pod: ${cfg.podUrl}`);
|
|
108
|
+
console.log();
|
|
109
|
+
const spinner = ora({ text: "Calling IS…", color: "cyan" }).start();
|
|
110
|
+
const start = Date.now();
|
|
111
|
+
let response;
|
|
112
|
+
try {
|
|
113
|
+
response = await callIS(cfg.podUrl, cfg.apiKey, model, [
|
|
114
|
+
{ role: "system", content: PERSONAS[persona] },
|
|
115
|
+
{ role: "user", content: goal },
|
|
116
|
+
], maxTokens);
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
const msg = err.message;
|
|
120
|
+
spinner.fail(chalk.red("IS call failed"));
|
|
121
|
+
console.log();
|
|
122
|
+
log.error(msg);
|
|
123
|
+
if (msg.includes("403") && msg.toLowerCase().includes("scope")) {
|
|
124
|
+
log.warn("Your CLI key is missing a required scope.");
|
|
125
|
+
log.dim("Fix: run synap connect to rotate your key with the updated scope list.");
|
|
126
|
+
log.dim("Or in pod-admin → Trust & Keys, delete your CLI key and reconnect.");
|
|
127
|
+
}
|
|
128
|
+
else if (msg.includes("IS error")) {
|
|
129
|
+
log.dim(`Verify the IS is running: curl ${cfg.podUrl}/v1/models -H "Authorization: Bearer <key>"`);
|
|
130
|
+
}
|
|
131
|
+
process.exit(1);
|
|
132
|
+
}
|
|
133
|
+
const content = response.choices?.[0]?.message?.content ?? "";
|
|
134
|
+
const elapsed = ((Date.now() - start) / 1000).toFixed(1);
|
|
135
|
+
spinner.text = "Storing result…";
|
|
136
|
+
let entityId;
|
|
137
|
+
try {
|
|
138
|
+
entityId = await storeResearch(`Agent run: ${goal.slice(0, 80)}`, content, ["agent-run", persona], runCfg);
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
// storage failure is non-fatal — still display the result
|
|
142
|
+
}
|
|
143
|
+
spinner.succeed(chalk.green(`Done · ${elapsed}s`));
|
|
144
|
+
console.log();
|
|
145
|
+
if (entityId) {
|
|
146
|
+
log.success(`Research stored → ${chalk.underline(`${cfg.podUrl}/admin/entities/${entityId}`)}`);
|
|
147
|
+
console.log();
|
|
148
|
+
}
|
|
149
|
+
if (content) {
|
|
150
|
+
log.heading("Result");
|
|
151
|
+
console.log(chalk.white(content.trim()));
|
|
152
|
+
console.log();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// ── Public: agentSchedule ─────────────────────────────────────────────────────
|
|
156
|
+
export async function agentSchedule(opts) {
|
|
157
|
+
let cfg;
|
|
158
|
+
try {
|
|
159
|
+
cfg = await resolveHubConfig({ podUrl: opts.podUrl, apiKey: opts.apiKey });
|
|
160
|
+
}
|
|
161
|
+
catch (err) {
|
|
162
|
+
log.error(err.message);
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
// List
|
|
166
|
+
if (opts.list) {
|
|
167
|
+
const schedules = await listScheduleEntities(cfg);
|
|
168
|
+
if (schedules.length === 0) {
|
|
169
|
+
log.warn("No schedules found on this pod/workspace.");
|
|
170
|
+
log.dim("Add one: synap agent schedule --goal '...' --name <name> --every daily");
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
log.heading(`Agent schedules (${schedules.length})`);
|
|
174
|
+
for (const s of schedules) {
|
|
175
|
+
const p = s.properties;
|
|
176
|
+
const badge = p.enabled ? chalk.green("●") : chalk.red("○");
|
|
177
|
+
const last = p.lastRunAt ? `last ran ${new Date(p.lastRunAt).toLocaleString()}` : "never ran";
|
|
178
|
+
const next = new Date(p.nextRunAt).toLocaleString();
|
|
179
|
+
console.log(` ${badge} ${chalk.bold(s.name.replace("[agent-sched] ", "").padEnd(24))} ${chalk.cyan(p.interval.padEnd(8))} ${chalk.dim(last)}`);
|
|
180
|
+
console.log(` next: ${chalk.dim(next)} | goal: ${chalk.dim(p.goal.slice(0, 70))}`);
|
|
181
|
+
}
|
|
182
|
+
console.log();
|
|
183
|
+
log.dim("Run due schedules now: synap agent tick");
|
|
184
|
+
log.dim("Crontab (daily at 09:00): 0 9 * * * synap agent tick");
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
// Remove
|
|
188
|
+
if (opts.remove) {
|
|
189
|
+
const schedules = await listScheduleEntities(cfg);
|
|
190
|
+
const target = schedules.find((s) => s.name === `[agent-sched] ${opts.remove}` || s.name === opts.remove);
|
|
191
|
+
if (!target) {
|
|
192
|
+
log.error(`No schedule named "${opts.remove}" found.`);
|
|
193
|
+
process.exit(1);
|
|
194
|
+
}
|
|
195
|
+
// Disable it (soft delete — PATCH enabled=false)
|
|
196
|
+
await hubPatch(`/entities/${target.id}`, { properties: { ...target.properties, enabled: false } }, cfg);
|
|
197
|
+
log.info(`Disabled schedule: ${chalk.bold(opts.remove)}`);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
// Add
|
|
201
|
+
const { goal, name, every } = opts;
|
|
202
|
+
if (!goal?.trim() || !name?.trim() || !every) {
|
|
203
|
+
log.error("Required: --goal, --name, --every (hourly|daily|weekly)");
|
|
204
|
+
log.dim('Example: synap agent schedule --goal "Research AI news" --name daily-ai --every daily');
|
|
205
|
+
process.exit(1);
|
|
206
|
+
}
|
|
207
|
+
const existing = await listScheduleEntities(cfg).catch(() => []);
|
|
208
|
+
if (existing.find((s) => s.name === `[agent-sched] ${name}`)) {
|
|
209
|
+
log.error(`A schedule named "${name}" already exists.`);
|
|
210
|
+
log.dim(`Remove it first: synap agent schedule --remove ${name}`);
|
|
211
|
+
process.exit(1);
|
|
212
|
+
}
|
|
213
|
+
const now = new Date().toISOString();
|
|
214
|
+
await hubPost("/entities", {
|
|
215
|
+
userId: cfg.userId,
|
|
216
|
+
workspaceId: cfg.workspaceId,
|
|
217
|
+
profileSlug: "task",
|
|
218
|
+
name: `[agent-sched] ${name}`,
|
|
219
|
+
properties: {
|
|
220
|
+
goal: goal.trim(),
|
|
221
|
+
persona: opts.persona ?? "researcher",
|
|
222
|
+
model: opts.model ?? "synap/balanced",
|
|
223
|
+
interval: every,
|
|
224
|
+
intervalMs: INTERVAL_MS[every],
|
|
225
|
+
nextRunAt: now,
|
|
226
|
+
enabled: true,
|
|
227
|
+
createdAt: now,
|
|
228
|
+
},
|
|
229
|
+
}, cfg);
|
|
230
|
+
log.info(`Schedule created: ${chalk.bold(name)} — runs ${chalk.cyan(every)}`);
|
|
231
|
+
console.log();
|
|
232
|
+
const cron = every === "hourly" ? "0 * * * *" : every === "daily" ? "0 9 * * *" : "0 9 * * 1";
|
|
233
|
+
log.dim(`Add to pod server crontab: ${cron} synap agent tick`);
|
|
234
|
+
if (opts.runNow) {
|
|
235
|
+
console.log();
|
|
236
|
+
await agentRun({
|
|
237
|
+
goal: goal.trim(),
|
|
238
|
+
persona: opts.persona,
|
|
239
|
+
model: opts.model,
|
|
240
|
+
workspace: opts.workspace ?? cfg.workspaceId,
|
|
241
|
+
podUrl: opts.podUrl,
|
|
242
|
+
apiKey: opts.apiKey,
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
// ── Public: agentTick ─────────────────────────────────────────────────────────
|
|
247
|
+
export async function agentTick(opts) {
|
|
248
|
+
let cfg;
|
|
249
|
+
try {
|
|
250
|
+
cfg = await resolveHubConfig({ podUrl: opts.podUrl, apiKey: opts.apiKey });
|
|
251
|
+
}
|
|
252
|
+
catch (err) {
|
|
253
|
+
log.error(err.message);
|
|
254
|
+
process.exit(1);
|
|
255
|
+
}
|
|
256
|
+
const schedules = await listScheduleEntities(cfg).catch(() => []);
|
|
257
|
+
const enabled = schedules.filter((s) => s.properties.enabled);
|
|
258
|
+
if (enabled.length === 0) {
|
|
259
|
+
log.dim("No enabled schedules on this pod.");
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const now = Date.now();
|
|
263
|
+
const due = enabled.filter((s) => {
|
|
264
|
+
const next = new Date(s.properties.nextRunAt).getTime();
|
|
265
|
+
return now >= next;
|
|
266
|
+
});
|
|
267
|
+
if (due.length === 0) {
|
|
268
|
+
const next = enabled
|
|
269
|
+
.map((s) => new Date(s.properties.nextRunAt).getTime())
|
|
270
|
+
.sort((a, b) => a - b)[0];
|
|
271
|
+
log.dim(`No schedules due. Next: ${new Date(next).toLocaleString()}`);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
log.heading(`Ticking ${due.length} due schedule(s)`);
|
|
275
|
+
for (const s of due) {
|
|
276
|
+
const p = s.properties;
|
|
277
|
+
log.info(`Running: ${chalk.bold(s.name.replace("[agent-sched] ", ""))}`);
|
|
278
|
+
if (opts.dryRun) {
|
|
279
|
+
log.dim(` [dry-run] goal: ${p.goal.slice(0, 70)}`);
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
try {
|
|
283
|
+
await agentRun({
|
|
284
|
+
goal: p.goal,
|
|
285
|
+
persona: p.persona,
|
|
286
|
+
model: p.model,
|
|
287
|
+
workspace: cfg.workspaceId,
|
|
288
|
+
podUrl: opts.podUrl,
|
|
289
|
+
apiKey: opts.apiKey,
|
|
290
|
+
});
|
|
291
|
+
const nextRunAt = new Date(now + p.intervalMs).toISOString();
|
|
292
|
+
await hubPatch(`/entities/${s.id}`, { properties: { ...p, lastRunAt: new Date(now).toISOString(), nextRunAt } }, cfg).catch(() => {
|
|
293
|
+
// non-fatal — schedule ran, just couldn't update nextRunAt
|
|
294
|
+
log.dim(` Warning: could not update nextRunAt for "${s.name}" on the pod.`);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
catch (err) {
|
|
298
|
+
log.error(`Schedule "${s.name}" failed: ${err.message}`);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
//# sourceMappingURL=agent-run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-run.js","sourceRoot":"","sources":["../../src/commands/agent-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AA+BzC,iFAAiF;AACjF,mEAAmE;AAEnE,MAAM,QAAQ,GAA4B;IACxC,UAAU,EACR,4FAA4F;QAC5F,qFAAqF;QACrF,mEAAmE;IAErE,SAAS,EACP,kFAAkF;QAClF,2CAA2C;IAE7C,SAAS,EACP,qFAAqF;QACrF,yEAAyE;CAC5E,CAAC;AAiBF,KAAK,U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ACb,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,SAAS,EAAE,GAAG,CAAC,WAAW;gBAC1B,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,MAAM,EAAE,IAAI,CAAC,MAAM;aACpB,CAAC,CAAC;YAEH,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;YAC7D,MAAM,QAAQ,CACZ,aAAa,CAAC,CAAC,EAAE,EAAE,EACnB,EAAE,UAAU,EAAE,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,EAAE,EAC3E,GAAG,CACJ,CAAC,KAAK,CAAC,GAAG,EAAE;gBACX,2DAA2D;gBAC3D,GAAG,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC;YAC/E,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,IAAI,aAAc,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* synap artifact
|
|
3
|
+
*
|
|
4
|
+
* Define AI-generated cells from local HTML/JS source.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* synap artifact create --html <file> [--name <name>] [--workspace <id>] [--open]
|
|
8
|
+
*
|
|
9
|
+
* API:
|
|
10
|
+
* POST /api/hub/cells/define — { name, rendererSource, workspaceId, typeKey?, description? }
|
|
11
|
+
*
|
|
12
|
+
* The cell is registered with rendererType:'frame' and trustLevel:'generated'.
|
|
13
|
+
* useRegisterFrameCells picks it up and makes it available in cellRegistry.
|
|
14
|
+
* Open it in the desktop app with:
|
|
15
|
+
* synap open cell <typeKey>
|
|
16
|
+
*/
|
|
17
|
+
export interface ArtifactCreateOpts {
|
|
18
|
+
html?: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
workspace?: string;
|
|
21
|
+
open?: boolean;
|
|
22
|
+
json?: boolean;
|
|
23
|
+
podUrl?: string;
|
|
24
|
+
apiKey?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare function artifactCreate(opts: ArtifactCreateOpts): Promise<void>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* synap artifact
|
|
3
|
+
*
|
|
4
|
+
* Define AI-generated cells from local HTML/JS source.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* synap artifact create --html <file> [--name <name>] [--workspace <id>] [--open]
|
|
8
|
+
*
|
|
9
|
+
* API:
|
|
10
|
+
* POST /api/hub/cells/define — { name, rendererSource, workspaceId, typeKey?, description? }
|
|
11
|
+
*
|
|
12
|
+
* The cell is registered with rendererType:'frame' and trustLevel:'generated'.
|
|
13
|
+
* useRegisterFrameCells picks it up and makes it available in cellRegistry.
|
|
14
|
+
* Open it in the desktop app with:
|
|
15
|
+
* synap open cell <typeKey>
|
|
16
|
+
*/
|
|
17
|
+
import { readFileSync } from "fs";
|
|
18
|
+
import { log } from "../utils/logger.js";
|
|
19
|
+
import { resolveHubConfig, resolveUserId, hubPost } from "../lib/hub-client.js";
|
|
20
|
+
import { openInBrowser } from "./open.js";
|
|
21
|
+
export async function artifactCreate(opts) {
|
|
22
|
+
try {
|
|
23
|
+
if (!opts.html) {
|
|
24
|
+
log.error("Provide an HTML file path: --html <file>");
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
let rendererSource;
|
|
28
|
+
try {
|
|
29
|
+
rendererSource = readFileSync(opts.html, "utf-8");
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
log.error(`Cannot read file: ${opts.html} — ${e.message}`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
const cfg = await resolveHubConfig(opts);
|
|
36
|
+
const userId = await resolveUserId(cfg);
|
|
37
|
+
const workspaceId = opts.workspace ?? cfg.workspaceId;
|
|
38
|
+
if (!workspaceId) {
|
|
39
|
+
log.error("Workspace ID required. Use --workspace <id> or set active workspace with: synap use <id>");
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
const name = opts.name ?? opts.html.split("/").pop()?.replace(/\.html?$/i, "") ?? "artifact";
|
|
43
|
+
const body = { userId, name, rendererSource, workspaceId };
|
|
44
|
+
const res = await hubPost("/cells/define", body, cfg);
|
|
45
|
+
const isProposed = res.status === "proposed" || Boolean(res.proposalId);
|
|
46
|
+
if (isProposed) {
|
|
47
|
+
log.warn(`Queued for approval (proposal: ${String(res.proposalId ?? "")})`);
|
|
48
|
+
if (res.reviewUrl)
|
|
49
|
+
log.dim(` Review: ${String(res.reviewUrl)}`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const typeKey = String(res.typeKey ?? "");
|
|
53
|
+
if (!typeKey) {
|
|
54
|
+
log.error("Cell defined but no typeKey returned");
|
|
55
|
+
if (opts.json)
|
|
56
|
+
console.log(JSON.stringify(res, null, 2));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (opts.json) {
|
|
60
|
+
console.log(JSON.stringify({ typeKey, name }, null, 2));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
log.success(`Cell defined: ${name}`);
|
|
64
|
+
log.dim(` typeKey: ${typeKey}`);
|
|
65
|
+
log.dim(` bento block: { kind: "${typeKey}", config: {} }`);
|
|
66
|
+
log.dim(` open in browser: synap open cell ${typeKey}`);
|
|
67
|
+
if (opts.open) {
|
|
68
|
+
await openInBrowser({ kind: "cell", id: typeKey });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
log.error("Error: " + e.message);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=artifact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact.js","sourceRoot":"","sources":["../../src/commands/artifact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAY1C,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAwB;IAC3D,IAAI,CAAC;QACH,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACf,GAAG,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;YACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,IAAI,cAAsB,CAAC;QAC3B,IAAI,CAAC;YACH,cAAc,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACpD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,GAAG,CAAC,KAAK,CAAC,qBAAqB,IAAI,CAAC,IAAI,MAAO,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;YACtE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC;QACxC,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC,WAAW,CAAC;QAEtD,IAAI,CAAC,WAAW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AG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACxD,OAAO;QACT,CAAC;QAED,GAAG,CAAC,OAAO,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;QACrC,GAAG,CAAC,GAAG,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC;QACjC,GAAG,CAAC,GAAG,CAAC,2BAA2B,OAAO,iBAAiB,CAAC,CAAC;QAC7D,GAAG,CAAC,GAAG,CAAC,sCAAsC,OAAO,EAAE,CAAC,CAAC;QAEzD,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,MAAM,aAAa,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,GAAG,CAAC,KAAK,CAAC,SAAS,GAAI,CAAW,CAAC,OAAO,CAAC,CAAC;QAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* synap automation — Create, manage, and inspect pod automations
|
|
3
|
+
*
|
|
4
|
+
* Subcommands: list, describe, create, enable, disable, delete, schema
|
|
5
|
+
*/
|
|
6
|
+
export interface ListOpts {
|
|
7
|
+
workspace?: string;
|
|
8
|
+
status?: string;
|
|
9
|
+
json?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function automationList(opts: ListOpts): Promise<void>;
|
|
12
|
+
export interface DescribeOpts {
|
|
13
|
+
workspace?: string;
|
|
14
|
+
json?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function automationDescribe(id: string, opts: DescribeOpts): Promise<void>;
|
|
17
|
+
export interface CreateOpts {
|
|
18
|
+
name?: string;
|
|
19
|
+
trigger?: string;
|
|
20
|
+
filter?: string[];
|
|
21
|
+
action?: string;
|
|
22
|
+
message?: string;
|
|
23
|
+
channel?: string;
|
|
24
|
+
status?: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
workspace?: string;
|
|
27
|
+
from?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare function automationCreate(opts: CreateOpts): Promise<void>;
|
|
30
|
+
export interface EnableOpts {
|
|
31
|
+
workspace?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare function automationEnable(id: string, opts: EnableOpts): Promise<void>;
|
|
34
|
+
export interface DisableOpts {
|
|
35
|
+
workspace?: string;
|
|
36
|
+
}
|
|
37
|
+
export declare function automationDisable(id: string, opts: DisableOpts): Promise<void>;
|
|
38
|
+
export interface DeleteOpts {
|
|
39
|
+
workspace?: string;
|
|
40
|
+
force?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export declare function automationDelete(id: string, opts: DeleteOpts): Promise<void>;
|
|
43
|
+
export interface SchemaOpts {
|
|
44
|
+
writeContext?: string | boolean;
|
|
45
|
+
json?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export declare function automationSchema(opts: SchemaOpts): Promise<void>;
|