@agentled/cli
Version:
CLI for Agentled — manage workflows, apps, and knowledge from the command line. Zero context-window cost for AI agents.
123 lines • 4.66 kB
JavaScript
import { AgentledClient } from '../client.js';
import { printError, printOutput } from '../utils/output.js';
function maybeJson(value) {
if (!value)
return undefined;
try {
return JSON.parse(value);
}
catch {
return value;
}
}
export function registerMemoryCommands(program) {
const memory = program.command('memory').description('Manage long-term memory');
memory
.command('store <key> <value>')
.description('Store or update a memory value')
.option('--category <category>', 'Memory category')
.option('--scope <scope>', 'Memory scope')
.option('--pipeline-id <id>', 'Pipeline ID scope')
.option('--confidence <n>', 'Confidence score', parseFloat)
.option('--merge <mode>', 'Merge mode')
.option('--format <fmt>', 'Output format', 'json')
.action(async (key, value, opts) => {
try {
const result = await new AgentledClient().storeMemory({
key,
value: maybeJson(value),
category: opts.category,
scope: opts.scope,
pipelineId: opts.pipelineId,
confidence: opts.confidence,
merge: opts.merge,
});
printOutput(result, opts.format);
}
catch (error) {
const message = error instanceof Error ? error.message : String(error);
printError(message);
}
});
memory
.command('recall <key>')
.description('Recall one memory by key')
.option('--scope <scope>', 'Memory scope')
.option('--pipeline-id <id>', 'Pipeline ID scope')
.option('--format <fmt>', 'Output format', 'json')
.action(async (key, opts) => {
try {
const result = await new AgentledClient().recallMemory({ key, scope: opts.scope, pipelineId: opts.pipelineId });
printOutput(result, opts.format);
}
catch (error) {
const message = error instanceof Error ? error.message : String(error);
printError(message);
}
});
memory
.command('search')
.description('Search memories')
.option('--query <text>', 'Search query')
.option('--category <category>', 'Filter by category')
.option('--scope <scope>', 'Filter by scope')
.option('--pipeline-id <id>', 'Filter by pipeline id')
.option('--limit <n>', 'Max rows', parseInt)
.option('--format <fmt>', 'Output format', 'json')
.action(async (opts) => {
try {
const result = await new AgentledClient().searchMemories({
query: opts.query,
category: opts.category,
scope: opts.scope,
pipelineId: opts.pipelineId,
limit: opts.limit,
});
printOutput(result, opts.format);
}
catch (error) {
const message = error instanceof Error ? error.message : String(error);
printError(message);
}
});
memory
.command('list')
.description('List memories')
.option('--category <category>', 'Filter by category')
.option('--scope <scope>', 'Filter by scope')
.option('--pipeline-id <id>', 'Filter by pipeline id')
.option('--limit <n>', 'Max rows', parseInt)
.option('--format <fmt>', 'Output format', 'json')
.action(async (opts) => {
try {
const result = await new AgentledClient().listMemories({
category: opts.category,
scope: opts.scope,
pipelineId: opts.pipelineId,
limit: opts.limit,
});
printOutput(result, opts.format);
}
catch (error) {
const message = error instanceof Error ? error.message : String(error);
printError(message);
}
});
memory
.command('delete <key>')
.description('Delete one memory by key')
.option('--scope <scope>', 'Memory scope')
.option('--pipeline-id <id>', 'Pipeline ID scope')
.option('--format <fmt>', 'Output format', 'json')
.action(async (key, opts) => {
try {
const result = await new AgentledClient().deleteMemory({ key, scope: opts.scope, pipelineId: opts.pipelineId });
printOutput(result, opts.format);
}
catch (error) {
const message = error instanceof Error ? error.message : String(error);
printError(message);
}
});
}
//# sourceMappingURL=memory.js.map