@2kw/ai 4.0.0-dev.2

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.
Files changed (69) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +91 -0
  3. package/dist/commands/ai.d.ts +3 -0
  4. package/dist/commands/ai.js +72 -0
  5. package/dist/commands/analytics.d.ts +3 -0
  6. package/dist/commands/analytics.js +161 -0
  7. package/dist/commands/auth.d.ts +3 -0
  8. package/dist/commands/auth.js +134 -0
  9. package/dist/commands/billing.d.ts +3 -0
  10. package/dist/commands/billing.js +102 -0
  11. package/dist/commands/config.d.ts +3 -0
  12. package/dist/commands/config.js +90 -0
  13. package/dist/commands/context.d.ts +3 -0
  14. package/dist/commands/context.js +149 -0
  15. package/dist/commands/convert.d.ts +3 -0
  16. package/dist/commands/convert.js +291 -0
  17. package/dist/commands/dataset-versions.d.ts +3 -0
  18. package/dist/commands/dataset-versions.js +90 -0
  19. package/dist/commands/datasets.d.ts +3 -0
  20. package/dist/commands/datasets.js +150 -0
  21. package/dist/commands/docs.d.ts +3 -0
  22. package/dist/commands/docs.js +166 -0
  23. package/dist/commands/evaluators.d.ts +3 -0
  24. package/dist/commands/evaluators.js +124 -0
  25. package/dist/commands/experiments.d.ts +3 -0
  26. package/dist/commands/experiments.js +255 -0
  27. package/dist/commands/extractions.d.ts +3 -0
  28. package/dist/commands/extractions.js +134 -0
  29. package/dist/commands/prompt-labels.d.ts +3 -0
  30. package/dist/commands/prompt-labels.js +67 -0
  31. package/dist/commands/prompt-versions.d.ts +3 -0
  32. package/dist/commands/prompt-versions.js +65 -0
  33. package/dist/commands/prompts.d.ts +3 -0
  34. package/dist/commands/prompts.js +159 -0
  35. package/dist/commands/providers.d.ts +3 -0
  36. package/dist/commands/providers.js +115 -0
  37. package/dist/commands/schema-labels.d.ts +3 -0
  38. package/dist/commands/schema-labels.js +67 -0
  39. package/dist/commands/schema-versions.d.ts +3 -0
  40. package/dist/commands/schema-versions.js +66 -0
  41. package/dist/commands/schemas.d.ts +3 -0
  42. package/dist/commands/schemas.js +178 -0
  43. package/dist/commands/scores.d.ts +3 -0
  44. package/dist/commands/scores.js +31 -0
  45. package/dist/commands/tracing.d.ts +3 -0
  46. package/dist/commands/tracing.js +85 -0
  47. package/dist/commands/transcribe.d.ts +3 -0
  48. package/dist/commands/transcribe.js +65 -0
  49. package/dist/index.d.ts +3 -0
  50. package/dist/index.js +54 -0
  51. package/dist/lib/client.d.ts +12 -0
  52. package/dist/lib/client.js +52 -0
  53. package/dist/lib/config.d.ts +44 -0
  54. package/dist/lib/config.js +217 -0
  55. package/dist/lib/datasets.d.ts +6 -0
  56. package/dist/lib/datasets.js +10 -0
  57. package/dist/lib/errors.d.ts +14 -0
  58. package/dist/lib/errors.js +54 -0
  59. package/dist/lib/multipart.d.ts +10 -0
  60. package/dist/lib/multipart.js +59 -0
  61. package/dist/lib/output.d.ts +29 -0
  62. package/dist/lib/output.js +107 -0
  63. package/dist/lib/pagination.d.ts +21 -0
  64. package/dist/lib/pagination.js +21 -0
  65. package/dist/lib/schema-compat.d.ts +11 -0
  66. package/dist/lib/schema-compat.js +51 -0
  67. package/dist/lib/update-notifier.d.ts +9 -0
  68. package/dist/lib/update-notifier.js +96 -0
  69. package/package.json +49 -0
@@ -0,0 +1,159 @@
1
+ import { Command } from "commander";
2
+ import { getClient, runAction } from "../lib/client.js";
3
+ import { formatPage, formatDetail, formatSuccess } from "../lib/output.js";
4
+ import { addPaginationOptions, paginationParams } from "../lib/pagination.js";
5
+ import { makePromptVersionsCommand } from "./prompt-versions.js";
6
+ import { makePromptLabelsCommand } from "./prompt-labels.js";
7
+ export function makePromptsCommand() {
8
+ const cmd = new Command("prompts").description("Manage prompts");
9
+ const list = new Command("list").description("List prompts");
10
+ addPaginationOptions(list);
11
+ list.option("-s, --search <term>", "Filter by name");
12
+ list.option("--type <type>", "Filter by type");
13
+ list.action(async (opts, command) => {
14
+ await runAction(command, async () => {
15
+ const client = getClient(command);
16
+ const { data } = await client.GET("/v1/prompts", {
17
+ params: {
18
+ query: { search: opts.search, type: opts.type, ...paginationParams(opts) },
19
+ },
20
+ });
21
+ formatPage(data, command, ["id", "name", "type", "description", "activeVersionId", "createdAt"]);
22
+ });
23
+ });
24
+ cmd.addCommand(list);
25
+ cmd
26
+ .command("get")
27
+ .description("Get a prompt by ID")
28
+ .argument("<id>", "Prompt ID")
29
+ .action(async (id, _opts, command) => {
30
+ await runAction(command, async () => {
31
+ const client = getClient(command);
32
+ const { data } = await client.GET("/v1/prompts/{id}", {
33
+ params: { path: { id } },
34
+ });
35
+ formatDetail(data, command);
36
+ });
37
+ });
38
+ cmd
39
+ .command("create")
40
+ .description("Create a new prompt")
41
+ .requiredOption("-n, --name <name>", "Prompt name")
42
+ .option("-d, --description <text>", "Prompt description")
43
+ .option("--type <type>", "Prompt type (TEXT or CHAT)", "TEXT")
44
+ .action(async (opts, command) => {
45
+ await runAction(command, async () => {
46
+ const client = getClient(command);
47
+ const { data } = await client.POST("/v1/prompts", {
48
+ body: { name: opts.name, description: opts.description, type: opts.type },
49
+ });
50
+ formatDetail(data, command);
51
+ });
52
+ });
53
+ cmd
54
+ .command("update")
55
+ .description("Update a prompt")
56
+ .argument("<id>", "Prompt ID")
57
+ .option("-n, --name <name>", "New name")
58
+ .option("-d, --description <text>", "New description")
59
+ .option("--type <type>", "New type")
60
+ .action(async (id, opts, command) => {
61
+ await runAction(command, async () => {
62
+ const client = getClient(command);
63
+ const body = {};
64
+ if (opts.name)
65
+ body.name = opts.name;
66
+ if (opts.description !== undefined)
67
+ body.description = opts.description;
68
+ if (opts.type !== undefined)
69
+ body.type = opts.type;
70
+ const { data } = await client.PUT("/v1/prompts/{id}", {
71
+ params: { path: { id } },
72
+ body: body,
73
+ });
74
+ formatDetail(data, command);
75
+ });
76
+ });
77
+ cmd
78
+ .command("delete")
79
+ .description("Delete a prompt")
80
+ .argument("<id>", "Prompt ID")
81
+ .action(async (id, _opts, command) => {
82
+ await runAction(command, async () => {
83
+ const client = getClient(command);
84
+ await client.DELETE("/v1/prompts/{id}", {
85
+ params: { path: { id } },
86
+ });
87
+ formatSuccess(`Prompt ${id} deleted.`, command);
88
+ });
89
+ });
90
+ cmd
91
+ .command("resolve")
92
+ .description("Resolve prompt content (latest or by label)")
93
+ .argument("<promptId>", "Prompt ID")
94
+ .option("-l, --label <name>", "Label to resolve")
95
+ .action(async (promptId, opts, command) => {
96
+ await runAction(command, async () => {
97
+ const client = getClient(command);
98
+ const { data } = await client.GET("/v1/prompts/{promptId}/resolve", {
99
+ params: {
100
+ path: { promptId },
101
+ query: { label: opts.label },
102
+ },
103
+ });
104
+ formatDetail(data, command);
105
+ });
106
+ });
107
+ cmd
108
+ .command("compile")
109
+ .description("Compile a prompt with variable substitution")
110
+ .argument("<promptId>", "Prompt ID")
111
+ .option("--vars <json>", "Variables as JSON object")
112
+ .option("--version-id <id>", "Specific version ID")
113
+ .option("-l, --label <name>", "Label to use")
114
+ .action(async (promptId, opts, command) => {
115
+ await runAction(command, async () => {
116
+ const client = getClient(command);
117
+ const variables = opts.vars ? JSON.parse(opts.vars) : undefined;
118
+ const { data } = await client.POST("/v1/prompts/{promptId}/compile", {
119
+ params: { path: { promptId } },
120
+ body: {
121
+ variables,
122
+ versionId: opts.versionId,
123
+ label: opts.label,
124
+ },
125
+ });
126
+ formatDetail(data, command);
127
+ });
128
+ });
129
+ cmd
130
+ .command("test")
131
+ .description("Test a prompt with an LLM")
132
+ .argument("<promptId>", "Prompt ID")
133
+ .requiredOption("-m, --model <model>", "Model to use (provider/model)")
134
+ .option("-t, --text <text>", "Input text")
135
+ .option("--vars <json>", "Variables as JSON object")
136
+ .option("--version-id <id>", "Specific version ID")
137
+ .option("-l, --label <name>", "Label to use")
138
+ .action(async (promptId, opts, command) => {
139
+ await runAction(command, async () => {
140
+ const client = getClient(command);
141
+ const variables = opts.vars ? JSON.parse(opts.vars) : undefined;
142
+ const { data } = await client.POST("/v1/prompts/{promptId}/test", {
143
+ params: { path: { promptId } },
144
+ body: {
145
+ model: opts.model,
146
+ content: opts.text,
147
+ variables,
148
+ versionId: opts.versionId,
149
+ label: opts.label,
150
+ },
151
+ });
152
+ formatDetail(data, command);
153
+ });
154
+ });
155
+ cmd.addCommand(makePromptVersionsCommand());
156
+ cmd.addCommand(makePromptLabelsCommand());
157
+ return cmd;
158
+ }
159
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function makeProvidersCommand(): Command;
3
+ //# sourceMappingURL=providers.d.ts.map
@@ -0,0 +1,115 @@
1
+ import { Command } from "commander";
2
+ import { getClient, runAction } from "../lib/client.js";
3
+ import { isJsonOutput } from "../lib/config.js";
4
+ import { formatPage, formatDetail, formatList, formatSuccess } from "../lib/output.js";
5
+ import { addPaginationOptions, paginationParams } from "../lib/pagination.js";
6
+ export function makeProvidersCommand() {
7
+ const cmd = new Command("providers").description("Manage AI providers");
8
+ const list = new Command("list").description("List providers");
9
+ addPaginationOptions(list);
10
+ list.option("-s, --search <term>", "Filter by name");
11
+ list.action(async (opts, command) => {
12
+ await runAction(command, async () => {
13
+ const client = getClient(command);
14
+ const { data } = await client.GET("/v1/providers", {
15
+ params: { query: { search: opts.search, ...paginationParams(opts) } },
16
+ });
17
+ formatPage(data, command, ["id", "name", "type", "enabled", "createdAt"]);
18
+ });
19
+ });
20
+ cmd.addCommand(list);
21
+ cmd
22
+ .command("get")
23
+ .description("Get a provider by ID")
24
+ .argument("<id>", "Provider ID")
25
+ .action(async (id, _opts, command) => {
26
+ await runAction(command, async () => {
27
+ const client = getClient(command);
28
+ const { data } = await client.GET("/v1/providers/{id}", {
29
+ params: { path: { id } },
30
+ });
31
+ formatDetail(data, command);
32
+ });
33
+ });
34
+ cmd
35
+ .command("create")
36
+ .description("Create a new provider")
37
+ .requiredOption("-n, --name <name>", "Provider name")
38
+ .requiredOption("--type <type>", "Provider type (openai, azure_openai, anthropic, xai, mistral, vertex_ai, ollama)")
39
+ .requiredOption("--provider-api-key <key>", "API key for the AI provider")
40
+ .option("-c, --config <json>", "Provider config as JSON")
41
+ .action(async (opts, command) => {
42
+ await runAction(command, async () => {
43
+ const client = getClient(command);
44
+ const config = opts.config ? JSON.parse(opts.config) : {};
45
+ const { data } = await client.POST("/v1/providers", {
46
+ body: { name: opts.name, provider: opts.type.toUpperCase(), apiKey: opts.providerApiKey, config },
47
+ });
48
+ formatDetail(data, command);
49
+ });
50
+ });
51
+ cmd
52
+ .command("update")
53
+ .description("Update a provider")
54
+ .argument("<id>", "Provider ID")
55
+ .option("-n, --name <name>", "New name")
56
+ .option("--type <type>", "New type")
57
+ .option("--enabled <bool>", "Enable/disable")
58
+ .option("-c, --config <json>", "New config as JSON")
59
+ .action(async (id, opts, command) => {
60
+ await runAction(command, async () => {
61
+ const client = getClient(command);
62
+ const body = {};
63
+ if (opts.name)
64
+ body.name = opts.name;
65
+ if (opts.type)
66
+ body.provider = opts.type.toUpperCase();
67
+ if (opts.enabled !== undefined)
68
+ body.enabled = opts.enabled === "true";
69
+ if (opts.config)
70
+ body.config = JSON.parse(opts.config);
71
+ const { data } = await client.PATCH("/v1/providers/{id}", {
72
+ params: { path: { id } },
73
+ body: body,
74
+ });
75
+ formatDetail(data, command);
76
+ });
77
+ });
78
+ cmd
79
+ .command("delete")
80
+ .description("Delete a provider")
81
+ .argument("<id>", "Provider ID")
82
+ .action(async (id, _opts, command) => {
83
+ await runAction(command, async () => {
84
+ const client = getClient(command);
85
+ await client.DELETE("/v1/providers/{id}", {
86
+ params: { path: { id } },
87
+ });
88
+ formatSuccess(`Provider ${id} deleted.`, command);
89
+ });
90
+ });
91
+ cmd
92
+ .command("models")
93
+ .description("List available models across all providers")
94
+ .action(async (_opts, command) => {
95
+ await runAction(command, async () => {
96
+ const client = getClient(command);
97
+ const { data } = await client.GET("/v1/providers/models");
98
+ const json = isJsonOutput(command);
99
+ if (json) {
100
+ console.log(JSON.stringify(data, null, 2));
101
+ }
102
+ else {
103
+ const models = data?.data ?? [];
104
+ formatList(models, command, [
105
+ "id",
106
+ "provider",
107
+ "name",
108
+ "capabilities",
109
+ ]);
110
+ }
111
+ });
112
+ });
113
+ return cmd;
114
+ }
115
+ //# sourceMappingURL=providers.js.map
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function makeSchemaLabelsCommand(): Command;
3
+ //# sourceMappingURL=schema-labels.d.ts.map
@@ -0,0 +1,67 @@
1
+ import { Command } from "commander";
2
+ import { getClient, runAction } from "../lib/client.js";
3
+ import { formatList, formatDetail, formatSuccess } from "../lib/output.js";
4
+ export function makeSchemaLabelsCommand() {
5
+ const cmd = new Command("labels").description("Manage schema labels");
6
+ cmd
7
+ .command("list")
8
+ .description("List labels for a schema")
9
+ .requiredOption("--schema <id>", "Schema ID")
10
+ .action(async (opts, command) => {
11
+ await runAction(command, async () => {
12
+ const client = getClient(command);
13
+ const { data } = await client.GET("/v1/schemas/{schemaId}/labels", { params: { path: { schemaId: opts.schema } } });
14
+ formatList(data, command, [
15
+ "name",
16
+ "schemaVersionId",
17
+ "createdAt",
18
+ ]);
19
+ });
20
+ });
21
+ cmd
22
+ .command("create")
23
+ .description("Create a label for a schema version")
24
+ .requiredOption("--schema <id>", "Schema ID")
25
+ .requiredOption("-n, --name <name>", "Label name")
26
+ .requiredOption("--version-id <id>", "Schema version ID to label")
27
+ .action(async (opts, command) => {
28
+ await runAction(command, async () => {
29
+ const client = getClient(command);
30
+ const { data } = await client.POST("/v1/schemas/{schemaId}/labels", {
31
+ params: { path: { schemaId: opts.schema } },
32
+ body: { name: opts.name, schemaVersionId: opts.versionId },
33
+ });
34
+ formatDetail(data, command);
35
+ });
36
+ });
37
+ cmd
38
+ .command("update")
39
+ .description("Update a label to point to a different version")
40
+ .argument("<labelName>", "Label name")
41
+ .requiredOption("--schema <id>", "Schema ID")
42
+ .requiredOption("--version-id <id>", "New schema version ID")
43
+ .action(async (labelName, opts, command) => {
44
+ await runAction(command, async () => {
45
+ const client = getClient(command);
46
+ const { data } = await client.PUT("/v1/schemas/{schemaId}/labels/{labelName}", {
47
+ params: { path: { schemaId: opts.schema, labelName } },
48
+ body: { schemaVersionId: opts.versionId },
49
+ });
50
+ formatDetail(data, command);
51
+ });
52
+ });
53
+ cmd
54
+ .command("delete")
55
+ .description("Delete a schema label")
56
+ .argument("<labelName>", "Label name")
57
+ .requiredOption("--schema <id>", "Schema ID")
58
+ .action(async (labelName, opts, command) => {
59
+ await runAction(command, async () => {
60
+ const client = getClient(command);
61
+ await client.DELETE("/v1/schemas/{schemaId}/labels/{labelName}", { params: { path: { schemaId: opts.schema, labelName } } });
62
+ formatSuccess(`Label "${labelName}" deleted.`, command);
63
+ });
64
+ });
65
+ return cmd;
66
+ }
67
+ //# sourceMappingURL=schema-labels.js.map
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function makeSchemaVersionsCommand(): Command;
3
+ //# sourceMappingURL=schema-versions.d.ts.map
@@ -0,0 +1,66 @@
1
+ import { Command } from "commander";
2
+ import { getClient, runAction } from "../lib/client.js";
3
+ import { formatPage, formatDetail } from "../lib/output.js";
4
+ import { addPaginationOptions, paginationParams } from "../lib/pagination.js";
5
+ export function makeSchemaVersionsCommand() {
6
+ const cmd = new Command("versions").description("Manage schema versions");
7
+ const list = new Command("list").description("List versions of a schema");
8
+ addPaginationOptions(list);
9
+ list.requiredOption("--schema <id>", "Schema ID");
10
+ list.action(async (opts, command) => {
11
+ await runAction(command, async () => {
12
+ const client = getClient(command);
13
+ const { data } = await client.GET("/v1/schemas/{schemaId}/versions", {
14
+ params: {
15
+ path: { schemaId: opts.schema },
16
+ query: paginationParams(opts),
17
+ },
18
+ });
19
+ formatPage(data, command, ["id", "version", "active", "changeDescription", "createdAt"]);
20
+ });
21
+ });
22
+ cmd.addCommand(list);
23
+ cmd
24
+ .command("get")
25
+ .description("Get a specific schema version")
26
+ .argument("<versionId>", "Version ID")
27
+ .requiredOption("--schema <id>", "Schema ID")
28
+ .action(async (versionId, opts, command) => {
29
+ await runAction(command, async () => {
30
+ const client = getClient(command);
31
+ const { data } = await client.GET("/v1/schemas/{schemaId}/versions/{versionId}", { params: { path: { schemaId: opts.schema, versionId } } });
32
+ formatDetail(data, command);
33
+ });
34
+ });
35
+ cmd
36
+ .command("create")
37
+ .description("Create a new schema version")
38
+ .requiredOption("--schema <id>", "Schema ID")
39
+ .requiredOption("-c, --content <json>", "JSON Schema content")
40
+ .option("-m, --message <text>", "Change description")
41
+ .action(async (opts, command) => {
42
+ await runAction(command, async () => {
43
+ const client = getClient(command);
44
+ const content = JSON.parse(opts.content);
45
+ const { data } = await client.POST("/v1/schemas/{schemaId}/versions", {
46
+ params: { path: { schemaId: opts.schema } },
47
+ body: { jsonSchema: content, changeDescription: opts.message },
48
+ });
49
+ formatDetail(data, command);
50
+ });
51
+ });
52
+ cmd
53
+ .command("activate")
54
+ .description("Activate a schema version")
55
+ .argument("<versionId>", "Version ID")
56
+ .requiredOption("--schema <id>", "Schema ID")
57
+ .action(async (versionId, opts, command) => {
58
+ await runAction(command, async () => {
59
+ const client = getClient(command);
60
+ const { data } = await client.PUT("/v1/schemas/{schemaId}/versions/{versionId}/activate", { params: { path: { schemaId: opts.schema, versionId } } });
61
+ formatDetail(data, command);
62
+ });
63
+ });
64
+ return cmd;
65
+ }
66
+ //# sourceMappingURL=schema-versions.js.map
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function makeSchemasCommand(): Command;
3
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1,178 @@
1
+ import { Command } from "commander";
2
+ import { getClient, runAction } from "../lib/client.js";
3
+ import { isJsonOutput } from "../lib/config.js";
4
+ import { formatPage, formatDetail, formatSuccess } from "../lib/output.js";
5
+ import { addPaginationOptions, paginationParams } from "../lib/pagination.js";
6
+ import { ensureOpenAiCompatible } from "../lib/schema-compat.js";
7
+ import { makeSchemaVersionsCommand } from "./schema-versions.js";
8
+ import { makeSchemaLabelsCommand } from "./schema-labels.js";
9
+ export function makeSchemasCommand() {
10
+ const cmd = new Command("schemas").description("Manage schemas");
11
+ const list = new Command("list").description("List schemas");
12
+ addPaginationOptions(list);
13
+ list.option("-s, --search <term>", "Filter by name");
14
+ list.action(async (opts, command) => {
15
+ await runAction(command, async () => {
16
+ const client = getClient(command);
17
+ const { data } = await client.GET("/v1/schemas", {
18
+ params: {
19
+ query: { search: opts.search, ...paginationParams(opts) },
20
+ },
21
+ });
22
+ formatPage(data, command, ["id", "name", "description", "activeVersionId", "createdAt"]);
23
+ });
24
+ });
25
+ cmd.addCommand(list);
26
+ cmd
27
+ .command("get")
28
+ .description("Get a schema by ID")
29
+ .argument("<id>", "Schema ID")
30
+ .action(async (id, _opts, command) => {
31
+ await runAction(command, async () => {
32
+ const client = getClient(command);
33
+ const { data } = await client.GET("/v1/schemas/{id}", {
34
+ params: { path: { id } },
35
+ });
36
+ formatDetail(data, command);
37
+ });
38
+ });
39
+ cmd
40
+ .command("create")
41
+ .description("Create a new schema")
42
+ .requiredOption("-n, --name <name>", "Schema name")
43
+ .option("-d, --description <text>", "Schema description")
44
+ .action(async (opts, command) => {
45
+ await runAction(command, async () => {
46
+ const client = getClient(command);
47
+ const { data } = await client.POST("/v1/schemas", {
48
+ body: { name: opts.name, description: opts.description },
49
+ });
50
+ formatDetail(data, command);
51
+ });
52
+ });
53
+ cmd
54
+ .command("update")
55
+ .description("Update a schema")
56
+ .argument("<id>", "Schema ID")
57
+ .option("-n, --name <name>", "New name")
58
+ .option("-d, --description <text>", "New description")
59
+ .action(async (id, opts, command) => {
60
+ await runAction(command, async () => {
61
+ const client = getClient(command);
62
+ const body = {};
63
+ if (opts.name)
64
+ body.name = opts.name;
65
+ if (opts.description !== undefined)
66
+ body.description = opts.description;
67
+ const { data } = await client.PUT("/v1/schemas/{id}", {
68
+ params: { path: { id } },
69
+ body: body,
70
+ });
71
+ formatDetail(data, command);
72
+ });
73
+ });
74
+ cmd
75
+ .command("delete")
76
+ .description("Delete a schema")
77
+ .argument("<id>", "Schema ID")
78
+ .action(async (id, _opts, command) => {
79
+ await runAction(command, async () => {
80
+ const client = getClient(command);
81
+ await client.DELETE("/v1/schemas/{id}", {
82
+ params: { path: { id } },
83
+ });
84
+ formatSuccess(`Schema ${id} deleted.`, command);
85
+ });
86
+ });
87
+ cmd
88
+ .command("validate")
89
+ .description("Validate a JSON schema without saving")
90
+ .argument("<schemaId>", "Schema ID")
91
+ .requiredOption("-c, --content <json>", "JSON Schema content")
92
+ .action(async (schemaId, opts, command) => {
93
+ await runAction(command, async () => {
94
+ const client = getClient(command);
95
+ const content = JSON.parse(opts.content);
96
+ const { data } = await client.POST("/v1/schemas/{schemaId}/validate", {
97
+ params: { path: { schemaId } },
98
+ body: { jsonSchema: content },
99
+ });
100
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
101
+ const result = data;
102
+ if (isJsonOutput(command)) {
103
+ console.log(JSON.stringify(result, null, 2));
104
+ }
105
+ else if (result?.valid) {
106
+ formatSuccess("Schema is valid.", command);
107
+ if (result.warnings?.length) {
108
+ console.log(`Warnings: ${result.warnings.join(", ")}`);
109
+ }
110
+ }
111
+ else {
112
+ console.error("Schema is invalid:");
113
+ for (const err of result?.errors ?? [])
114
+ console.error(` - ${err}`);
115
+ }
116
+ });
117
+ });
118
+ cmd
119
+ .command("test")
120
+ .description("Test a schema with sample text")
121
+ .argument("<schemaId>", "Schema ID")
122
+ .requiredOption("-t, --text <text>", "Sample text to extract from")
123
+ .requiredOption("-m, --model <model>", "Model to use (provider/model)")
124
+ .option("-c, --content <json>", "JSON Schema content (overrides stored version)")
125
+ .option("-l, --label <name>", "Schema label to resolve")
126
+ .action(async (schemaId, opts, command) => {
127
+ await runAction(command, async () => {
128
+ const client = getClient(command);
129
+ let jsonSchema;
130
+ if (opts.content) {
131
+ jsonSchema = JSON.parse(opts.content);
132
+ }
133
+ else {
134
+ // Resolve the schema content from the active version (or by label)
135
+ const { data: resolved } = await client.GET("/v1/schemas/{schemaId}/resolve", {
136
+ params: {
137
+ path: { schemaId },
138
+ query: { label: opts.label },
139
+ },
140
+ });
141
+ jsonSchema = resolved?.jsonSchema;
142
+ if (!jsonSchema) {
143
+ throw new Error("No active schema version found. Create a version first or pass --content.");
144
+ }
145
+ }
146
+ const { data } = await client.POST("/v1/schemas/{schemaId}/test", {
147
+ params: { path: { schemaId } },
148
+ body: {
149
+ jsonSchema: ensureOpenAiCompatible(jsonSchema),
150
+ sampleText: opts.text,
151
+ model: opts.model,
152
+ },
153
+ });
154
+ formatDetail(data, command);
155
+ });
156
+ });
157
+ cmd
158
+ .command("resolve")
159
+ .description("Resolve schema content (latest or by label)")
160
+ .argument("<schemaId>", "Schema ID")
161
+ .option("-l, --label <name>", "Label to resolve")
162
+ .action(async (schemaId, opts, command) => {
163
+ await runAction(command, async () => {
164
+ const client = getClient(command);
165
+ const { data } = await client.GET("/v1/schemas/{schemaId}/resolve", {
166
+ params: {
167
+ path: { schemaId },
168
+ query: { label: opts.label },
169
+ },
170
+ });
171
+ formatDetail(data, command);
172
+ });
173
+ });
174
+ cmd.addCommand(makeSchemaVersionsCommand());
175
+ cmd.addCommand(makeSchemaLabelsCommand());
176
+ return cmd;
177
+ }
178
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function makeScoresCommand(): Command;
3
+ //# sourceMappingURL=scores.d.ts.map
@@ -0,0 +1,31 @@
1
+ import { Command } from "commander";
2
+ import { getClient, runAction } from "../lib/client.js";
3
+ import { formatDetail } from "../lib/output.js";
4
+ export function makeScoresCommand() {
5
+ const cmd = new Command("scores").description("Record evaluation scores on experiment run results");
6
+ cmd
7
+ .command("human")
8
+ .description("Record a human score for a run result. Upserts by (runResultId, evaluatorId, annotatorId).")
9
+ .requiredOption("--run-result <id>", "Run result ID")
10
+ .requiredOption("--evaluator <id>", "Evaluator identifier (e.g. 'helpfulness' or a template id)")
11
+ .requiredOption("--score <number>", "Score between 0.0 and 1.0", parseFloat)
12
+ .option("--label <text>", "Short label (e.g. 'pass', 'fail', 'good')")
13
+ .option("--comment <text>", "Optional reviewer note")
14
+ .action(async (opts, command) => {
15
+ await runAction(command, async () => {
16
+ const client = getClient(command);
17
+ const { data } = await client.POST("/v1/evaluation-scores/human", {
18
+ body: {
19
+ runResultId: opts.runResult,
20
+ evaluatorId: opts.evaluator,
21
+ score: opts.score,
22
+ label: opts.label,
23
+ comment: opts.comment,
24
+ },
25
+ });
26
+ formatDetail(data, command);
27
+ });
28
+ });
29
+ return cmd;
30
+ }
31
+ //# sourceMappingURL=scores.js.map
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function makeTracingCommand(): Command;
3
+ //# sourceMappingURL=tracing.d.ts.map