@openagentpack/cli 0.2.0-beta-ddef91c-20260720 → 0.3.0-beta-fb9e73b-20260721
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/bin/agents.js
CHANGED
|
@@ -670,9 +670,9 @@ async function initCommand() {
|
|
|
670
670
|
p4.log.success(`Created ${configPath}`, { output: process.stderr });
|
|
671
671
|
const gitignorePath = ".gitignore";
|
|
672
672
|
if (await fileExists(gitignorePath)) {
|
|
673
|
-
const
|
|
674
|
-
if (!
|
|
675
|
-
await writeFile(gitignorePath,
|
|
673
|
+
const content2 = await readFile(gitignorePath, "utf8");
|
|
674
|
+
if (!content2.includes("agents.state.json")) {
|
|
675
|
+
await writeFile(gitignorePath, content2 + GITIGNORE_ADDITIONS, "utf8");
|
|
676
676
|
p4.log.success("Updated .gitignore", { output: process.stderr });
|
|
677
677
|
}
|
|
678
678
|
} else {
|
|
@@ -685,15 +685,244 @@ async function initCommand() {
|
|
|
685
685
|
});
|
|
686
686
|
}
|
|
687
687
|
|
|
688
|
+
// src/commands/memory.ts
|
|
689
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
690
|
+
import {
|
|
691
|
+
archiveMemoryStore,
|
|
692
|
+
batchCreateMemories,
|
|
693
|
+
createMemory,
|
|
694
|
+
createMemoryStore,
|
|
695
|
+
deleteMemory,
|
|
696
|
+
deleteMemoryStore,
|
|
697
|
+
getMemory,
|
|
698
|
+
getMemoryStore,
|
|
699
|
+
getMemoryVersion,
|
|
700
|
+
listMemories,
|
|
701
|
+
listMemoryStores,
|
|
702
|
+
listMemoryVersions,
|
|
703
|
+
redactMemoryVersion,
|
|
704
|
+
UserError as UserError5,
|
|
705
|
+
updateMemory,
|
|
706
|
+
updateMemoryStore
|
|
707
|
+
} from "@openagentpack/sdk";
|
|
708
|
+
|
|
709
|
+
// src/runtime.ts
|
|
710
|
+
import { listProviderNames, UserError as UserError4 } from "@openagentpack/sdk";
|
|
711
|
+
import { Command, InvalidArgumentError, Option } from "commander";
|
|
712
|
+
var DEFAULT_CONFIG_FILE = "agents.yaml";
|
|
713
|
+
function isExplicitSource(source) {
|
|
714
|
+
return source !== void 0 && source !== "default";
|
|
715
|
+
}
|
|
716
|
+
function rootCommand(command) {
|
|
717
|
+
let current = command;
|
|
718
|
+
while (current.parent) current = current.parent;
|
|
719
|
+
return current;
|
|
720
|
+
}
|
|
721
|
+
function configFileArgs(args = process.argv.slice(2)) {
|
|
722
|
+
const values = [];
|
|
723
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
724
|
+
const arg = args[i];
|
|
725
|
+
if (!arg) continue;
|
|
726
|
+
if (arg === "--") break;
|
|
727
|
+
if (arg === "-f" || arg === "--file") {
|
|
728
|
+
const value = args[i + 1];
|
|
729
|
+
if (value) {
|
|
730
|
+
values.push(value);
|
|
731
|
+
i += 1;
|
|
732
|
+
continue;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
if (arg.startsWith("--file=")) {
|
|
736
|
+
values.push(arg.slice("--file=".length));
|
|
737
|
+
continue;
|
|
738
|
+
}
|
|
739
|
+
if (arg.startsWith("-f") && arg.length > 2) {
|
|
740
|
+
values.push(arg.slice(2));
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
return values;
|
|
744
|
+
}
|
|
745
|
+
function configFileOption() {
|
|
746
|
+
return new Option("-f, --file <path>", "Config file path");
|
|
747
|
+
}
|
|
748
|
+
function resolveConfigFile(command) {
|
|
749
|
+
const explicitFiles = [...new Set(configFileArgs())];
|
|
750
|
+
if (explicitFiles.length > 1) {
|
|
751
|
+
throw new UserError4(
|
|
752
|
+
`Conflicting config files supplied: ${explicitFiles.join(" and ")}. Use only one --file value.`
|
|
753
|
+
);
|
|
754
|
+
}
|
|
755
|
+
const root = rootCommand(command);
|
|
756
|
+
const rootFile = root.getOptionValue("file");
|
|
757
|
+
const rootSource = root.getOptionValueSource("file");
|
|
758
|
+
const localFile = command.getOptionValue("file");
|
|
759
|
+
const localSource = command.getOptionValueSource("file");
|
|
760
|
+
if (isExplicitSource(rootSource) && isExplicitSource(localSource) && rootFile && localFile && rootFile !== localFile) {
|
|
761
|
+
throw new UserError4(`Conflicting config files supplied: ${rootFile} and ${localFile}. Use only one --file value.`);
|
|
762
|
+
}
|
|
763
|
+
if (isExplicitSource(localSource) && localFile) return localFile;
|
|
764
|
+
if (rootFile) return rootFile;
|
|
765
|
+
return DEFAULT_CONFIG_FILE;
|
|
766
|
+
}
|
|
767
|
+
function withResolvedConfigFile(handler) {
|
|
768
|
+
return async (...args) => {
|
|
769
|
+
const command = args[args.length - 1];
|
|
770
|
+
if (!(command instanceof Command)) {
|
|
771
|
+
await handler(...args);
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
774
|
+
const handlerArgs = args.slice(0, -1);
|
|
775
|
+
const options = handlerArgs[handlerArgs.length - 1];
|
|
776
|
+
if (options && typeof options === "object") {
|
|
777
|
+
options.file = resolveConfigFile(command);
|
|
778
|
+
}
|
|
779
|
+
await handler(...handlerArgs);
|
|
780
|
+
};
|
|
781
|
+
}
|
|
782
|
+
function registeredProviderNames() {
|
|
783
|
+
return listProviderNames();
|
|
784
|
+
}
|
|
785
|
+
function providerOption(description, opts = {}) {
|
|
786
|
+
const choices = opts.allowAll ? ["all", ...registeredProviderNames()] : registeredProviderNames();
|
|
787
|
+
const option = new Option("--provider <name>", description).choices(choices);
|
|
788
|
+
if (opts.defaultValue !== void 0) option.default(opts.defaultValue);
|
|
789
|
+
return option;
|
|
790
|
+
}
|
|
791
|
+
function parsePositiveInteger(value) {
|
|
792
|
+
if (!/^\d+$/.test(value)) {
|
|
793
|
+
throw new InvalidArgumentError("must be a positive integer");
|
|
794
|
+
}
|
|
795
|
+
const parsed = Number(value);
|
|
796
|
+
if (!Number.isSafeInteger(parsed) || parsed <= 0) {
|
|
797
|
+
throw new InvalidArgumentError("must be a positive integer");
|
|
798
|
+
}
|
|
799
|
+
return parsed;
|
|
800
|
+
}
|
|
801
|
+
function parseBooleanOption(value) {
|
|
802
|
+
if (value === "true") return true;
|
|
803
|
+
if (value === "false") return false;
|
|
804
|
+
throw new InvalidArgumentError("must be true or false");
|
|
805
|
+
}
|
|
806
|
+
function writeJson(value) {
|
|
807
|
+
process.stdout.write(`${JSON.stringify(value, null, 2)}
|
|
808
|
+
`);
|
|
809
|
+
}
|
|
810
|
+
function writeJsonLine(value) {
|
|
811
|
+
process.stdout.write(`${JSON.stringify(value)}
|
|
812
|
+
`);
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
// src/commands/memory.ts
|
|
816
|
+
async function runtime(options) {
|
|
817
|
+
const ctx = await buildCliRuntime(options.file);
|
|
818
|
+
const provider = options.provider ?? (ctx.providers.size === 1 ? ctx.providers.keys().next().value : void 0);
|
|
819
|
+
if (!provider) throw new UserError5("Select a provider with --provider when multiple providers are configured.");
|
|
820
|
+
return { ctx, provider };
|
|
821
|
+
}
|
|
822
|
+
async function content(options) {
|
|
823
|
+
if (options.content !== void 0 && options.contentFile)
|
|
824
|
+
throw new UserError5("Use either --content or --content-file, not both.");
|
|
825
|
+
if (options.contentFile) return readFile2(options.contentFile, "utf8");
|
|
826
|
+
if (options.content !== void 0) return options.content;
|
|
827
|
+
throw new UserError5("Memory content is required; use --content or --content-file.");
|
|
828
|
+
}
|
|
829
|
+
async function memoryStoreListCommand(options) {
|
|
830
|
+
const { ctx, provider } = await runtime(options);
|
|
831
|
+
writeJson(await listMemoryStores(ctx.providers, provider, options));
|
|
832
|
+
}
|
|
833
|
+
async function memoryStoreCreateCommand(name, options) {
|
|
834
|
+
const { ctx, provider } = await runtime(options);
|
|
835
|
+
writeJson(await createMemoryStore(ctx.providers, provider, { name, description: options.description }));
|
|
836
|
+
}
|
|
837
|
+
async function memoryStoreDeleteCommand(id, options) {
|
|
838
|
+
const { ctx, provider } = await runtime(options);
|
|
839
|
+
await deleteMemoryStore(ctx.providers, provider, id);
|
|
840
|
+
writeJson({ id, type: "memory_store_deleted" });
|
|
841
|
+
}
|
|
842
|
+
async function memoryStoreGetCommand(id, options) {
|
|
843
|
+
const { ctx, provider } = await runtime(options);
|
|
844
|
+
writeJson(await getMemoryStore(ctx.providers, provider, id));
|
|
845
|
+
}
|
|
846
|
+
async function memoryStoreUpdateCommand(id, options) {
|
|
847
|
+
const { ctx, provider } = await runtime(options);
|
|
848
|
+
writeJson(
|
|
849
|
+
await updateMemoryStore(ctx.providers, provider, id, { name: options.name, description: options.description })
|
|
850
|
+
);
|
|
851
|
+
}
|
|
852
|
+
async function memoryStoreArchiveCommand(id, options) {
|
|
853
|
+
const { ctx, provider } = await runtime(options);
|
|
854
|
+
writeJson(await archiveMemoryStore(ctx.providers, provider, id));
|
|
855
|
+
}
|
|
856
|
+
async function memoryCreateCommand(storeId, path, options) {
|
|
857
|
+
const { ctx, provider } = await runtime(options);
|
|
858
|
+
writeJson(await createMemory(ctx.providers, provider, storeId, { path, content: await content(options) }));
|
|
859
|
+
}
|
|
860
|
+
async function memoryBatchCreateCommand(storeId, inputFile, options) {
|
|
861
|
+
const { ctx, provider } = await runtime(options);
|
|
862
|
+
const parsed = JSON.parse(await readFile2(inputFile, "utf8"));
|
|
863
|
+
if (!Array.isArray(parsed)) throw new UserError5("Batch input must be a JSON array of {path, content} objects.");
|
|
864
|
+
const items = parsed.map((item) => {
|
|
865
|
+
if (!item || typeof item !== "object" || typeof item.path !== "string" || typeof item.content !== "string") {
|
|
866
|
+
throw new UserError5("Every batch item must contain string path and content fields.");
|
|
867
|
+
}
|
|
868
|
+
return item;
|
|
869
|
+
});
|
|
870
|
+
writeJson(await batchCreateMemories(ctx.providers, provider, storeId, { items, on_conflict: options.onConflict }));
|
|
871
|
+
}
|
|
872
|
+
async function memoryListCommand(storeId, options) {
|
|
873
|
+
const { ctx, provider } = await runtime(options);
|
|
874
|
+
writeJson(
|
|
875
|
+
await listMemories(ctx.providers, provider, storeId, { ...options, view: options.full ? "full" : "basic" })
|
|
876
|
+
);
|
|
877
|
+
}
|
|
878
|
+
async function memoryGetCommand(storeId, memoryId, options) {
|
|
879
|
+
const { ctx, provider } = await runtime(options);
|
|
880
|
+
writeJson(await getMemory(ctx.providers, provider, storeId, memoryId));
|
|
881
|
+
}
|
|
882
|
+
async function memoryUpdateCommand(storeId, memoryId, options) {
|
|
883
|
+
const { ctx, provider } = await runtime(options);
|
|
884
|
+
const nextContent = options.content !== void 0 || options.contentFile ? await content(options) : void 0;
|
|
885
|
+
writeJson(
|
|
886
|
+
await updateMemory(ctx.providers, provider, storeId, memoryId, {
|
|
887
|
+
path: options.path,
|
|
888
|
+
content: nextContent,
|
|
889
|
+
expected_content_sha256: options.expectedSha256
|
|
890
|
+
})
|
|
891
|
+
);
|
|
892
|
+
}
|
|
893
|
+
async function memoryDeleteCommand(storeId, memoryId, options) {
|
|
894
|
+
const { ctx, provider } = await runtime(options);
|
|
895
|
+
await deleteMemory(ctx.providers, provider, storeId, memoryId, options.expectedSha256);
|
|
896
|
+
writeJson({ id: memoryId, type: "memory_deleted" });
|
|
897
|
+
}
|
|
898
|
+
async function memoryVersionListCommand(storeId, options) {
|
|
899
|
+
const { ctx, provider } = await runtime(options);
|
|
900
|
+
writeJson(
|
|
901
|
+
await listMemoryVersions(ctx.providers, provider, storeId, {
|
|
902
|
+
...options,
|
|
903
|
+
memory_id: options.memoryId,
|
|
904
|
+
view: options.full ? "full" : "basic"
|
|
905
|
+
})
|
|
906
|
+
);
|
|
907
|
+
}
|
|
908
|
+
async function memoryVersionGetCommand(storeId, versionId, options) {
|
|
909
|
+
const { ctx, provider } = await runtime(options);
|
|
910
|
+
writeJson(await getMemoryVersion(ctx.providers, provider, storeId, versionId));
|
|
911
|
+
}
|
|
912
|
+
async function memoryVersionRedactCommand(storeId, versionId, options) {
|
|
913
|
+
const { ctx, provider } = await runtime(options);
|
|
914
|
+
writeJson(await redactMemoryVersion(ctx.providers, provider, storeId, versionId));
|
|
915
|
+
}
|
|
916
|
+
|
|
688
917
|
// src/commands/migrate.ts
|
|
689
918
|
import { writeFile as writeFile2 } from "fs/promises";
|
|
690
|
-
import { migrateConfig, UserError as
|
|
919
|
+
import { migrateConfig, UserError as UserError6 } from "@openagentpack/sdk";
|
|
691
920
|
async function migrateCommand(options) {
|
|
692
921
|
const fromPath = options.from ?? "agents.synced.yaml";
|
|
693
922
|
const toPath = options.to ?? "agents.yaml";
|
|
694
923
|
const toExists = await fileExists(toPath);
|
|
695
924
|
if (!toExists) {
|
|
696
|
-
throw new
|
|
925
|
+
throw new UserError6(
|
|
697
926
|
`Target file '${toPath}' not found. Create a agents.yaml first (e.g. \`agents init\`), then run migrate.`
|
|
698
927
|
);
|
|
699
928
|
}
|
|
@@ -806,116 +1035,8 @@ function formatPrice(factor) {
|
|
|
806
1035
|
}
|
|
807
1036
|
|
|
808
1037
|
// src/commands/plan.ts
|
|
809
|
-
import { UserError as
|
|
1038
|
+
import { UserError as UserError7 } from "@openagentpack/sdk";
|
|
810
1039
|
import chalk8 from "chalk";
|
|
811
|
-
|
|
812
|
-
// src/runtime.ts
|
|
813
|
-
import { listProviderNames, UserError as UserError5 } from "@openagentpack/sdk";
|
|
814
|
-
import { Command, InvalidArgumentError, Option } from "commander";
|
|
815
|
-
var DEFAULT_CONFIG_FILE = "agents.yaml";
|
|
816
|
-
function isExplicitSource(source) {
|
|
817
|
-
return source !== void 0 && source !== "default";
|
|
818
|
-
}
|
|
819
|
-
function rootCommand(command) {
|
|
820
|
-
let current = command;
|
|
821
|
-
while (current.parent) current = current.parent;
|
|
822
|
-
return current;
|
|
823
|
-
}
|
|
824
|
-
function configFileArgs(args = process.argv.slice(2)) {
|
|
825
|
-
const values = [];
|
|
826
|
-
for (let i = 0; i < args.length; i += 1) {
|
|
827
|
-
const arg = args[i];
|
|
828
|
-
if (!arg) continue;
|
|
829
|
-
if (arg === "--") break;
|
|
830
|
-
if (arg === "-f" || arg === "--file") {
|
|
831
|
-
const value = args[i + 1];
|
|
832
|
-
if (value) {
|
|
833
|
-
values.push(value);
|
|
834
|
-
i += 1;
|
|
835
|
-
continue;
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
if (arg.startsWith("--file=")) {
|
|
839
|
-
values.push(arg.slice("--file=".length));
|
|
840
|
-
continue;
|
|
841
|
-
}
|
|
842
|
-
if (arg.startsWith("-f") && arg.length > 2) {
|
|
843
|
-
values.push(arg.slice(2));
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
return values;
|
|
847
|
-
}
|
|
848
|
-
function configFileOption() {
|
|
849
|
-
return new Option("-f, --file <path>", "Config file path");
|
|
850
|
-
}
|
|
851
|
-
function resolveConfigFile(command) {
|
|
852
|
-
const explicitFiles = [...new Set(configFileArgs())];
|
|
853
|
-
if (explicitFiles.length > 1) {
|
|
854
|
-
throw new UserError5(
|
|
855
|
-
`Conflicting config files supplied: ${explicitFiles.join(" and ")}. Use only one --file value.`
|
|
856
|
-
);
|
|
857
|
-
}
|
|
858
|
-
const root = rootCommand(command);
|
|
859
|
-
const rootFile = root.getOptionValue("file");
|
|
860
|
-
const rootSource = root.getOptionValueSource("file");
|
|
861
|
-
const localFile = command.getOptionValue("file");
|
|
862
|
-
const localSource = command.getOptionValueSource("file");
|
|
863
|
-
if (isExplicitSource(rootSource) && isExplicitSource(localSource) && rootFile && localFile && rootFile !== localFile) {
|
|
864
|
-
throw new UserError5(`Conflicting config files supplied: ${rootFile} and ${localFile}. Use only one --file value.`);
|
|
865
|
-
}
|
|
866
|
-
if (isExplicitSource(localSource) && localFile) return localFile;
|
|
867
|
-
if (rootFile) return rootFile;
|
|
868
|
-
return DEFAULT_CONFIG_FILE;
|
|
869
|
-
}
|
|
870
|
-
function withResolvedConfigFile(handler) {
|
|
871
|
-
return async (...args) => {
|
|
872
|
-
const command = args[args.length - 1];
|
|
873
|
-
if (!(command instanceof Command)) {
|
|
874
|
-
await handler(...args);
|
|
875
|
-
return;
|
|
876
|
-
}
|
|
877
|
-
const handlerArgs = args.slice(0, -1);
|
|
878
|
-
const options = handlerArgs[handlerArgs.length - 1];
|
|
879
|
-
if (options && typeof options === "object") {
|
|
880
|
-
options.file = resolveConfigFile(command);
|
|
881
|
-
}
|
|
882
|
-
await handler(...handlerArgs);
|
|
883
|
-
};
|
|
884
|
-
}
|
|
885
|
-
function registeredProviderNames() {
|
|
886
|
-
return listProviderNames();
|
|
887
|
-
}
|
|
888
|
-
function providerOption(description, opts = {}) {
|
|
889
|
-
const choices = opts.allowAll ? ["all", ...registeredProviderNames()] : registeredProviderNames();
|
|
890
|
-
const option = new Option("--provider <name>", description).choices(choices);
|
|
891
|
-
if (opts.defaultValue !== void 0) option.default(opts.defaultValue);
|
|
892
|
-
return option;
|
|
893
|
-
}
|
|
894
|
-
function parsePositiveInteger(value) {
|
|
895
|
-
if (!/^\d+$/.test(value)) {
|
|
896
|
-
throw new InvalidArgumentError("must be a positive integer");
|
|
897
|
-
}
|
|
898
|
-
const parsed = Number(value);
|
|
899
|
-
if (!Number.isSafeInteger(parsed) || parsed <= 0) {
|
|
900
|
-
throw new InvalidArgumentError("must be a positive integer");
|
|
901
|
-
}
|
|
902
|
-
return parsed;
|
|
903
|
-
}
|
|
904
|
-
function parseBooleanOption(value) {
|
|
905
|
-
if (value === "true") return true;
|
|
906
|
-
if (value === "false") return false;
|
|
907
|
-
throw new InvalidArgumentError("must be true or false");
|
|
908
|
-
}
|
|
909
|
-
function writeJson(value) {
|
|
910
|
-
process.stdout.write(`${JSON.stringify(value, null, 2)}
|
|
911
|
-
`);
|
|
912
|
-
}
|
|
913
|
-
function writeJsonLine(value) {
|
|
914
|
-
process.stdout.write(`${JSON.stringify(value)}
|
|
915
|
-
`);
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
// src/commands/plan.ts
|
|
919
1040
|
async function planCommand(options) {
|
|
920
1041
|
const ctx = await buildCliRuntime(options.file);
|
|
921
1042
|
assertProviderConfigured(ctx, options.provider);
|
|
@@ -927,13 +1048,13 @@ async function planCommand(options) {
|
|
|
927
1048
|
if (options.json) {
|
|
928
1049
|
writeJson(plan);
|
|
929
1050
|
if (plan.diagnostics.some((d) => d.severity === "error")) {
|
|
930
|
-
throw new
|
|
1051
|
+
throw new UserError7("Plan contains errors.");
|
|
931
1052
|
}
|
|
932
1053
|
return;
|
|
933
1054
|
}
|
|
934
1055
|
renderDiagnostics(plan.diagnostics);
|
|
935
1056
|
if (diagnosticsHaveErrors(plan.diagnostics)) {
|
|
936
|
-
throw new
|
|
1057
|
+
throw new UserError7("Plan contains errors.");
|
|
937
1058
|
}
|
|
938
1059
|
const creates = plan.actions.filter((a) => a.action === "create");
|
|
939
1060
|
const updates = plan.actions.filter((a) => a.action === "update");
|
|
@@ -1137,7 +1258,7 @@ import {
|
|
|
1137
1258
|
sendSessionMessageStreaming,
|
|
1138
1259
|
startSessionRun,
|
|
1139
1260
|
startSessionRunPolling,
|
|
1140
|
-
UserError as
|
|
1261
|
+
UserError as UserError8
|
|
1141
1262
|
} from "@openagentpack/sdk";
|
|
1142
1263
|
import { sanitizeSessionEvent, sanitizeSessionEvents } from "@openagentpack/sdk/session-events";
|
|
1143
1264
|
import chalk9 from "chalk";
|
|
@@ -1179,7 +1300,7 @@ async function sessionCreateCommand(agentNameOrOptions, maybeOptions) {
|
|
|
1179
1300
|
const options = maybeOptions ?? agentNameOrOptions;
|
|
1180
1301
|
const positionalAgent = typeof agentNameOrOptions === "string" ? agentNameOrOptions : void 0;
|
|
1181
1302
|
if (positionalAgent && options.agent && positionalAgent !== options.agent) {
|
|
1182
|
-
throw new
|
|
1303
|
+
throw new UserError8("Specify agent either positionally or with --agent, not both.");
|
|
1183
1304
|
}
|
|
1184
1305
|
const ctx = await buildCliRuntime(options.file);
|
|
1185
1306
|
const run = await createSessionForAgent(ctx, {
|
|
@@ -1336,7 +1457,7 @@ async function sessionRunCommand(promptOrAgent, promptOrOptions, maybeOptions) {
|
|
|
1336
1457
|
const prompt = hasPositionalAgent ? promptOrOptions : promptOrAgent;
|
|
1337
1458
|
const options = hasPositionalAgent ? maybeOptions : promptOrOptions ?? maybeOptions;
|
|
1338
1459
|
if (positionalAgent && options.agent && positionalAgent !== options.agent) {
|
|
1339
|
-
throw new
|
|
1460
|
+
throw new UserError8("Specify agent either positionally or with --agent, not both.");
|
|
1340
1461
|
}
|
|
1341
1462
|
const runOptions = {
|
|
1342
1463
|
agent: positionalAgent ?? options.agent,
|
|
@@ -1422,7 +1543,7 @@ function parseMemoryStores(value) {
|
|
|
1422
1543
|
}
|
|
1423
1544
|
|
|
1424
1545
|
// src/commands/state.ts
|
|
1425
|
-
import { importResource, parseStateAddress, UserError as
|
|
1546
|
+
import { importResource, parseStateAddress, UserError as UserError9 } from "@openagentpack/sdk";
|
|
1426
1547
|
import chalk10 from "chalk";
|
|
1427
1548
|
async function stateListCommand(options) {
|
|
1428
1549
|
const ctx = await buildCliRuntime(options.file);
|
|
@@ -1446,14 +1567,14 @@ async function stateShowCommand(address, options) {
|
|
|
1446
1567
|
const ctx = await buildCliRuntime(options.file);
|
|
1447
1568
|
const parsed = parseStateAddress(address, { requireProvider: false });
|
|
1448
1569
|
const found = ctx.state.findResource(parsed);
|
|
1449
|
-
if (!found) throw new
|
|
1570
|
+
if (!found) throw new UserError9(`Resource not found: ${address}`);
|
|
1450
1571
|
console.log(JSON.stringify(found, null, 2));
|
|
1451
1572
|
}
|
|
1452
1573
|
async function stateRemoveCommand(address, options) {
|
|
1453
1574
|
const ctx = await buildCliRuntime(options.file);
|
|
1454
1575
|
const parsed = parseStateAddress(address, { requireProvider: false });
|
|
1455
1576
|
const found = ctx.state.findResource(parsed);
|
|
1456
|
-
if (!found) throw new
|
|
1577
|
+
if (!found) throw new UserError9(`Resource not found: ${address}`);
|
|
1457
1578
|
ctx.state.removeResource(found.address);
|
|
1458
1579
|
await ctx.state.save();
|
|
1459
1580
|
log.success(`Removed ${address} from state (remote resource not deleted).`);
|
|
@@ -1474,14 +1595,14 @@ import {
|
|
|
1474
1595
|
resolveSyncProvider,
|
|
1475
1596
|
syncProviderResourcesFromContext,
|
|
1476
1597
|
syncProviderResourcesFromEnv,
|
|
1477
|
-
UserError as
|
|
1598
|
+
UserError as UserError10
|
|
1478
1599
|
} from "@openagentpack/sdk";
|
|
1479
1600
|
import { stringify as stringifyYaml } from "yaml";
|
|
1480
1601
|
var DEFAULT_SYNC_OUTPUT = "agents.synced.yaml";
|
|
1481
1602
|
function ensureSyncOutputWritable(outPath, force) {
|
|
1482
1603
|
if (force) return;
|
|
1483
1604
|
if (fileExistsSync(outPath)) {
|
|
1484
|
-
throw new
|
|
1605
|
+
throw new UserError10(
|
|
1485
1606
|
`Output file '${outPath}' already exists. Use --force to overwrite, or -o/--out to write elsewhere.`
|
|
1486
1607
|
);
|
|
1487
1608
|
}
|
|
@@ -1543,7 +1664,7 @@ async function syncFromConfig(configPath, explicitProvider) {
|
|
|
1543
1664
|
}
|
|
1544
1665
|
async function syncFromEnv(explicitProvider) {
|
|
1545
1666
|
if (!explicitProvider) {
|
|
1546
|
-
throw new
|
|
1667
|
+
throw new UserError10(
|
|
1547
1668
|
"agents sync requires --provider when no config file exists, e.g. `agents sync --provider claude`."
|
|
1548
1669
|
);
|
|
1549
1670
|
}
|
|
@@ -1590,8 +1711,8 @@ async function promptSecretValues(placeholders) {
|
|
|
1590
1711
|
function loadExistingEnv(path) {
|
|
1591
1712
|
const keys = /* @__PURE__ */ new Set();
|
|
1592
1713
|
if (!fileExistsSync(path)) return keys;
|
|
1593
|
-
const
|
|
1594
|
-
for (const line of
|
|
1714
|
+
const content2 = readFileSync2(path, "utf8");
|
|
1715
|
+
for (const line of content2.split("\n")) {
|
|
1595
1716
|
const trimmed = line.trim();
|
|
1596
1717
|
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
1597
1718
|
const eqIdx = trimmed.indexOf("=");
|
|
@@ -1602,16 +1723,16 @@ function loadExistingEnv(path) {
|
|
|
1602
1723
|
return keys;
|
|
1603
1724
|
}
|
|
1604
1725
|
function appendEnvLine(path, key, value) {
|
|
1605
|
-
let
|
|
1726
|
+
let content2 = "";
|
|
1606
1727
|
if (fileExistsSync(path)) {
|
|
1607
|
-
|
|
1608
|
-
if (
|
|
1609
|
-
|
|
1728
|
+
content2 = readFileSync2(path, "utf8");
|
|
1729
|
+
if (content2.length > 0 && !content2.endsWith("\n")) {
|
|
1730
|
+
content2 += "\n";
|
|
1610
1731
|
}
|
|
1611
1732
|
}
|
|
1612
|
-
|
|
1733
|
+
content2 += `${key}=${value}
|
|
1613
1734
|
`;
|
|
1614
|
-
writeFileSync(path,
|
|
1735
|
+
writeFileSync(path, content2);
|
|
1615
1736
|
}
|
|
1616
1737
|
async function promptCustomSkillFiles(config, baseDir) {
|
|
1617
1738
|
const skills = config.skills ?? {};
|
|
@@ -1755,7 +1876,7 @@ async function serializeConfig(config) {
|
|
|
1755
1876
|
|
|
1756
1877
|
// src/commands/validate.ts
|
|
1757
1878
|
import { resolve as resolve4 } from "path";
|
|
1758
|
-
import { resolveProjectConfig as resolveProjectConfig2, UserError as
|
|
1879
|
+
import { resolveProjectConfig as resolveProjectConfig2, UserError as UserError11, validateProjectConfig } from "@openagentpack/sdk";
|
|
1759
1880
|
async function validateCommand(options) {
|
|
1760
1881
|
ensureCredentials();
|
|
1761
1882
|
const configPath = resolve4(options.file);
|
|
@@ -1770,7 +1891,7 @@ async function validateCommand(options) {
|
|
|
1770
1891
|
}
|
|
1771
1892
|
const errorCount = diagnostics.filter((d) => d.severity === "error").length;
|
|
1772
1893
|
if (errorCount > 0) {
|
|
1773
|
-
throw new
|
|
1894
|
+
throw new UserError11(`Validation failed with ${errorCount} error(s).`);
|
|
1774
1895
|
}
|
|
1775
1896
|
log.success("Configuration is valid.");
|
|
1776
1897
|
}
|
|
@@ -1858,6 +1979,24 @@ var deploymentCmd = program.command("deployment").description("Manage agent depl
|
|
|
1858
1979
|
deploymentCmd.command("list").description("List deployments tracked in state").addOption(configFileOption()).addOption(providerOption("Filter by provider")).action(withResolvedConfigFile(deploymentListCommand));
|
|
1859
1980
|
deploymentCmd.command("get <name>").description("Show a deployment's status and resolved bindings").addOption(configFileOption()).addOption(providerOption("Target provider")).action(withResolvedConfigFile(deploymentGetCommand));
|
|
1860
1981
|
deploymentCmd.command("run <name>").description("Trigger a deployment run (native on Claude, emulated as a session on Qoder)").addOption(configFileOption()).addOption(providerOption("Target provider")).action(withResolvedConfigFile(deploymentRunCommand));
|
|
1982
|
+
var memoryStoreCmd = program.command("memory-store").description("Manage persistent memory stores");
|
|
1983
|
+
memoryStoreCmd.command("create <name>").addOption(configFileOption()).addOption(providerOption("Target provider")).option("--description <description>").action(withResolvedConfigFile(memoryStoreCreateCommand));
|
|
1984
|
+
memoryStoreCmd.command("list").addOption(configFileOption()).addOption(providerOption("Target provider")).option("--limit <n>", "Page size", parsePositiveInteger).option("--cursor <cursor>").option("--include-archived").action(withResolvedConfigFile(memoryStoreListCommand));
|
|
1985
|
+
memoryStoreCmd.command("get <store-id>").addOption(configFileOption()).addOption(providerOption("Target provider")).action(withResolvedConfigFile(memoryStoreGetCommand));
|
|
1986
|
+
memoryStoreCmd.command("update <store-id>").addOption(configFileOption()).addOption(providerOption("Target provider")).option("--name <name>").option("--description <description>").action(withResolvedConfigFile(memoryStoreUpdateCommand));
|
|
1987
|
+
memoryStoreCmd.command("archive <store-id>").addOption(configFileOption()).addOption(providerOption("Target provider")).action(withResolvedConfigFile(memoryStoreArchiveCommand));
|
|
1988
|
+
memoryStoreCmd.command("delete <store-id>").addOption(configFileOption()).addOption(providerOption("Target provider")).action(withResolvedConfigFile(memoryStoreDeleteCommand));
|
|
1989
|
+
var memoryCmd = program.command("memory").description("Manage memories inside a store");
|
|
1990
|
+
memoryCmd.command("create <store-id> <path>").addOption(configFileOption()).addOption(providerOption("Target provider")).option("--content <text>").option("--content-file <path>").action(withResolvedConfigFile(memoryCreateCommand));
|
|
1991
|
+
memoryCmd.command("batch-create <store-id> <json-file>").addOption(configFileOption()).addOption(providerOption("Target provider")).addOption(new Option2("--on-conflict <mode>", "Conflict handling (Ark)").choices(["overwrite", "fail"])).action(withResolvedConfigFile(memoryBatchCreateCommand));
|
|
1992
|
+
memoryCmd.command("list <store-id>").addOption(configFileOption()).addOption(providerOption("Target provider")).option("--limit <n>", "Page size", parsePositiveInteger).option("--cursor <cursor>").option("--prefix <path>").option("--depth <n>", "Hierarchy depth", parsePositiveInteger).option("--full", "Include content").action(withResolvedConfigFile(memoryListCommand));
|
|
1993
|
+
memoryCmd.command("get <store-id> <memory-id>").addOption(configFileOption()).addOption(providerOption("Target provider")).action(withResolvedConfigFile(memoryGetCommand));
|
|
1994
|
+
memoryCmd.command("update <store-id> <memory-id>").addOption(configFileOption()).addOption(providerOption("Target provider")).option("--path <path>").option("--content <text>").option("--content-file <path>").option("--expected-sha256 <sha256>", "Optimistic concurrency precondition").action(withResolvedConfigFile(memoryUpdateCommand));
|
|
1995
|
+
memoryCmd.command("delete <store-id> <memory-id>").addOption(configFileOption()).addOption(providerOption("Target provider")).option("--expected-sha256 <sha256>", "Optimistic concurrency precondition").action(withResolvedConfigFile(memoryDeleteCommand));
|
|
1996
|
+
var memoryVersionCmd = memoryCmd.command("version").description("Inspect immutable memory history");
|
|
1997
|
+
memoryVersionCmd.command("list <store-id>").addOption(configFileOption()).addOption(providerOption("Target provider")).option("--limit <n>", "Page size", parsePositiveInteger).option("--cursor <cursor>").option("--memory-id <id>").option("--full", "Include version content").action(withResolvedConfigFile(memoryVersionListCommand));
|
|
1998
|
+
memoryVersionCmd.command("get <store-id> <version-id>").addOption(configFileOption()).addOption(providerOption("Target provider")).action(withResolvedConfigFile(memoryVersionGetCommand));
|
|
1999
|
+
memoryVersionCmd.command("redact <store-id> <version-id>").addOption(configFileOption()).addOption(providerOption("Target provider")).action(withResolvedConfigFile(memoryVersionRedactCommand));
|
|
1861
2000
|
var modelsCmd = program.command("models").description("Discover available models from providers");
|
|
1862
2001
|
modelsCmd.command("list").description("List models available on the configured provider(s)").addOption(configFileOption()).addOption(providerOption("Target provider")).option("--json", "Output as JSON").action(withResolvedConfigFile(modelsListCommand));
|
|
1863
2002
|
|
package/dist/src/program.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openagentpack/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-beta-fb9e73b-20260721",
|
|
4
4
|
"description": "Open Agent Pack — Declaratively manage AI agent infrastructure",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
"typecheck": "tsc --noEmit"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@openagentpack/playground": "0.
|
|
52
|
+
"@openagentpack/playground": "0.3.0-beta-fb9e73b-20260721",
|
|
53
53
|
"@types/bun": "^1.3.14",
|
|
54
54
|
"typescript": "^6.0.3"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@openagentpack/sdk": "0.
|
|
57
|
+
"@openagentpack/sdk": "0.3.0-beta-fb9e73b-20260721",
|
|
58
58
|
"@clack/prompts": "^1.5.1",
|
|
59
59
|
"chalk": "^5.6.2",
|
|
60
60
|
"commander": "^14.0.3",
|