dataiku-sdk 3.1.0 → 3.3.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.
Files changed (149) hide show
  1. package/README.md +253 -38
  2. package/dist/build-metadata.json +1 -1
  3. package/dist/packages/types/src/index.d.ts +102 -0
  4. package/dist/packages/types/src/index.js +76 -0
  5. package/dist/src/auth.js +1 -1
  6. package/dist/src/cli/coerce.js +11 -2
  7. package/dist/src/cli/commands/analysis.js +4 -3
  8. package/dist/src/cli/commands/api-service.js +5 -3
  9. package/dist/src/cli/commands/app.js +61 -18
  10. package/dist/src/cli/commands/bundle.js +3 -2
  11. package/dist/src/cli/commands/code-env.js +23 -16
  12. package/dist/src/cli/commands/connection.d.ts +9 -0
  13. package/dist/src/cli/commands/connection.js +267 -1
  14. package/dist/src/cli/commands/dashboard.js +7 -6
  15. package/dist/src/cli/commands/data-collection.d.ts +2 -0
  16. package/dist/src/cli/commands/data-collection.js +164 -0
  17. package/dist/src/cli/commands/data-quality.js +9 -8
  18. package/dist/src/cli/commands/dataset.js +170 -40
  19. package/dist/src/cli/commands/doctor.js +4 -2
  20. package/dist/src/cli/commands/flow-zone.js +9 -8
  21. package/dist/src/cli/commands/folder.js +9 -8
  22. package/dist/src/cli/commands/future.js +4 -3
  23. package/dist/src/cli/commands/group.d.ts +2 -0
  24. package/dist/src/cli/commands/group.js +109 -0
  25. package/dist/src/cli/commands/index.js +151 -78
  26. package/dist/src/cli/commands/insight.js +8 -7
  27. package/dist/src/cli/commands/job.js +4 -3
  28. package/dist/src/cli/commands/knowledge-bank.d.ts +2 -0
  29. package/dist/src/cli/commands/knowledge-bank.js +80 -0
  30. package/dist/src/cli/commands/llm.d.ts +2 -0
  31. package/dist/src/cli/commands/llm.js +93 -0
  32. package/dist/src/cli/commands/macro.d.ts +2 -0
  33. package/dist/src/cli/commands/macro.js +221 -0
  34. package/dist/src/cli/commands/meaning.js +5 -4
  35. package/dist/src/cli/commands/ml-task.js +21 -8
  36. package/dist/src/cli/commands/model-evaluation-store.js +4 -3
  37. package/dist/src/cli/commands/notebook.js +17 -12
  38. package/dist/src/cli/commands/plugin.d.ts +2 -0
  39. package/dist/src/cli/commands/plugin.js +799 -0
  40. package/dist/src/cli/commands/project-folder.d.ts +2 -0
  41. package/dist/src/cli/commands/project-folder.js +197 -0
  42. package/dist/src/cli/commands/project-git.js +14 -54
  43. package/dist/src/cli/commands/project-library.js +7 -6
  44. package/dist/src/cli/commands/project.js +55 -8
  45. package/dist/src/cli/commands/recipe.js +50 -14
  46. package/dist/src/cli/commands/saved-model.d.ts +5 -0
  47. package/dist/src/cli/commands/saved-model.js +392 -4
  48. package/dist/src/cli/commands/scenario.js +147 -9
  49. package/dist/src/cli/commands/sql.js +3 -2
  50. package/dist/src/cli/commands/statistics.js +7 -6
  51. package/dist/src/cli/commands/user.d.ts +8 -0
  52. package/dist/src/cli/commands/user.js +296 -0
  53. package/dist/src/cli/commands/variable.js +2 -1
  54. package/dist/src/cli/commands/webapp.js +2 -1
  55. package/dist/src/cli/commands/wiki.js +7 -6
  56. package/dist/src/cli/contract.d.ts +2 -3
  57. package/dist/src/cli/contract.js +1167 -163
  58. package/dist/src/cli/flags.d.ts +4 -0
  59. package/dist/src/cli/flags.js +50 -2
  60. package/dist/src/cli/helpers/app-successor.d.ts +19 -4
  61. package/dist/src/cli/helpers/app-successor.js +90 -30
  62. package/dist/src/cli/helpers/cleanup.js +3 -1
  63. package/dist/src/cli/helpers/flow-zone.js +1 -2
  64. package/dist/src/cli/output.d.ts +1 -1
  65. package/dist/src/cli/output.js +23 -10
  66. package/dist/src/cli/usage.d.ts +1 -0
  67. package/dist/src/cli/usage.js +47 -1
  68. package/dist/src/cli.js +225 -95
  69. package/dist/src/client.d.ts +86 -6
  70. package/dist/src/client.js +263 -50
  71. package/dist/src/errors.d.ts +3 -0
  72. package/dist/src/errors.js +4 -0
  73. package/dist/src/index.d.ts +16 -7
  74. package/dist/src/index.js +11 -2
  75. package/dist/src/resources/analyses.js +1 -8
  76. package/dist/src/resources/applications.d.ts +8 -6
  77. package/dist/src/resources/applications.js +21 -21
  78. package/dist/src/resources/base.d.ts +4 -0
  79. package/dist/src/resources/base.js +15 -0
  80. package/dist/src/resources/bundles.d.ts +9 -4
  81. package/dist/src/resources/bundles.js +10 -5
  82. package/dist/src/resources/connections.d.ts +78 -1
  83. package/dist/src/resources/connections.js +132 -1
  84. package/dist/src/resources/data-collections.d.ts +118 -0
  85. package/dist/src/resources/data-collections.js +49 -0
  86. package/dist/src/resources/datasets.d.ts +69 -0
  87. package/dist/src/resources/datasets.js +99 -1
  88. package/dist/src/resources/folders.js +2 -1
  89. package/dist/src/resources/futures.d.ts +4 -1
  90. package/dist/src/resources/futures.js +38 -6
  91. package/dist/src/resources/groups.d.ts +47 -0
  92. package/dist/src/resources/groups.js +56 -0
  93. package/dist/src/resources/jobs.d.ts +8 -13
  94. package/dist/src/resources/jobs.js +41 -16
  95. package/dist/src/resources/knowledge-banks.d.ts +58 -0
  96. package/dist/src/resources/knowledge-banks.js +61 -0
  97. package/dist/src/resources/llms.d.ts +92 -0
  98. package/dist/src/resources/llms.js +62 -0
  99. package/dist/src/resources/macros.d.ts +121 -0
  100. package/dist/src/resources/macros.js +231 -0
  101. package/dist/src/resources/ml-tasks.d.ts +37 -2
  102. package/dist/src/resources/ml-tasks.js +100 -20
  103. package/dist/src/resources/model-evaluation-stores.js +1 -8
  104. package/dist/src/resources/notebooks.d.ts +43 -7
  105. package/dist/src/resources/notebooks.js +53 -13
  106. package/dist/src/resources/plugins.d.ts +265 -0
  107. package/dist/src/resources/plugins.js +458 -0
  108. package/dist/src/resources/project-folders.d.ts +71 -0
  109. package/dist/src/resources/project-folders.js +57 -0
  110. package/dist/src/resources/project-git.d.ts +6 -0
  111. package/dist/src/resources/project-git.js +69 -42
  112. package/dist/src/resources/project-library.d.ts +0 -1
  113. package/dist/src/resources/project-library.js +1 -17
  114. package/dist/src/resources/projects.d.ts +19 -3
  115. package/dist/src/resources/projects.js +30 -18
  116. package/dist/src/resources/recipes.d.ts +15 -1
  117. package/dist/src/resources/recipes.js +73 -6
  118. package/dist/src/resources/saved-models.d.ts +134 -1
  119. package/dist/src/resources/saved-models.js +214 -6
  120. package/dist/src/resources/scenarios.d.ts +105 -0
  121. package/dist/src/resources/scenarios.js +232 -106
  122. package/dist/src/resources/sql.js +5 -1
  123. package/dist/src/resources/users.d.ts +129 -0
  124. package/dist/src/resources/users.js +128 -0
  125. package/dist/src/resources/webapps.d.ts +15 -2
  126. package/dist/src/resources/webapps.js +18 -4
  127. package/dist/src/schemas.d.ts +2 -2
  128. package/dist/src/schemas.js +1 -1
  129. package/dist/src/skill.d.ts +13 -4
  130. package/dist/src/skill.js +75 -24
  131. package/dist/src/utils/deep-merge.d.ts +1 -1
  132. package/dist/src/utils/polling.d.ts +20 -0
  133. package/dist/src/utils/polling.js +27 -0
  134. package/dist/src/utils/response-file.d.ts +2 -0
  135. package/dist/src/utils/response-file.js +34 -0
  136. package/dist/src/utils/secret-sanitize.d.ts +54 -0
  137. package/dist/src/utils/secret-sanitize.js +101 -0
  138. package/package.json +8 -5
  139. package/packages/types/dist/index.d.ts +102 -0
  140. package/packages/types/dist/index.js +76 -0
  141. package/plugin.json +1 -1
  142. package/skills/dataiku-dss/SKILL.md +47 -225
  143. package/skills/dataiku-dss/references/app-releases.md +28 -0
  144. package/skills/dataiku-dss/references/authentication.md +39 -0
  145. package/skills/dataiku-dss/references/coding.md +8 -0
  146. package/skills/dataiku-dss/references/discovery.md +30 -0
  147. package/skills/dataiku-dss/references/flow-maps.md +12 -0
  148. package/skills/dataiku-dss/references/mutations.md +33 -0
  149. package/skills/dataiku-dss/references/troubleshooting.md +29 -0
@@ -1,80 +1,153 @@
1
- import { analysisCommands, } from "./analysis.js";
2
- import { apiDeployerCommands, } from "./api-deployer.js";
3
- import { apiServiceCommands, } from "./api-service.js";
4
- import { appCommands, } from "./app.js";
5
- import { bundleCommands, } from "./bundle.js";
6
- import { businessAppCommands, } from "./business-app.js";
7
- import { codeEnvCommands, } from "./code-env.js";
8
- import { codeCommands, } from "./code.js";
9
- import { connectionCommands, } from "./connection.js";
10
- import { continuousActivityCommands, } from "./continuous-activity.js";
11
- import { dashboardCommands, } from "./dashboard.js";
12
- import { dataQualityCommands, } from "./data-quality.js";
13
- import { datasetCommands, } from "./dataset.js";
14
- import { discussionCommands, } from "./discussion.js";
15
- import { doctorCommands, } from "./doctor.js";
16
- import { flowZoneCommands, } from "./flow-zone.js";
17
- import { folderCommands, } from "./folder.js";
18
- import { futureCommands, } from "./future.js";
19
- import { insightCommands, } from "./insight.js";
20
- import { jobCommands, } from "./job.js";
21
- import { meaningCommands, } from "./meaning.js";
22
- import { metricsCommands, } from "./metrics.js";
23
- import { mlTaskCommands, } from "./ml-task.js";
24
- import { modelEvaluationStoreCommands, } from "./model-evaluation-store.js";
25
- import { notebookCommands, } from "./notebook.js";
26
- import { projectDeployerCommands, } from "./project-deployer.js";
27
- import { projectGitCommands, } from "./project-git.js";
28
- import { projectLibraryCommands, } from "./project-library.js";
29
- import { projectCommands, } from "./project.js";
30
- import { recipeCommands, } from "./recipe.js";
31
- import { savedModelCommands, } from "./saved-model.js";
32
- import { scenarioCommands, } from "./scenario.js";
33
- import { sqlCommands, } from "./sql.js";
34
- import { statisticsCommands, } from "./statistics.js";
35
- import { streamingEndpointCommands, } from "./streaming-endpoint.js";
36
- import { variableCommands, } from "./variable.js";
37
- import { webappCommands, } from "./webapp.js";
38
- import { wikiCommands, } from "./wiki.js";
39
- import { workspaceCommands, } from "./workspace.js";
1
+ // Bun caches these synchronous module loads. Enumerating resource names stays
2
+ // cheap; looking up one resource loads only its command definitions.
40
3
  export const commands = {
41
- project: projectCommands,
42
- analysis: analysisCommands,
43
- "ml-task": mlTaskCommands,
44
- "saved-model": savedModelCommands,
45
- "model-evaluation-store": modelEvaluationStoreCommands,
46
- app: appCommands,
47
- "business-app": businessAppCommands,
48
- webapp: webappCommands,
49
- "api-service": apiServiceCommands,
50
- "api-deployer": apiDeployerCommands,
51
- bundle: bundleCommands,
52
- "project-deployer": projectDeployerCommands,
53
- "project-git": projectGitCommands,
54
- "project-library": projectLibraryCommands,
55
- "streaming-endpoint": streamingEndpointCommands,
56
- "continuous-activity": continuousActivityCommands,
57
- statistics: statisticsCommands,
58
- discussion: discussionCommands,
59
- meaning: meaningCommands,
60
- workspace: workspaceCommands,
61
- metrics: metricsCommands,
62
- doctor: doctorCommands,
63
- wiki: wikiCommands,
64
- dashboard: dashboardCommands,
65
- insight: insightCommands,
66
- "data-quality": dataQualityCommands,
67
- future: futureCommands,
68
- "flow-zone": flowZoneCommands,
69
- dataset: datasetCommands,
70
- recipe: recipeCommands,
71
- job: jobCommands,
72
- scenario: scenarioCommands,
73
- folder: folderCommands,
74
- variable: variableCommands,
75
- connection: connectionCommands,
76
- "code-env": codeEnvCommands,
77
- sql: sqlCommands,
78
- code: codeCommands,
79
- notebook: notebookCommands,
4
+ get "project"() {
5
+ return require("./project.js").projectCommands;
6
+ },
7
+ get "analysis"() {
8
+ return require("./analysis.js").analysisCommands;
9
+ },
10
+ get "ml-task"() {
11
+ return require("./ml-task.js").mlTaskCommands;
12
+ },
13
+ get "saved-model"() {
14
+ return require("./saved-model.js").savedModelCommands;
15
+ },
16
+ get "model-evaluation-store"() {
17
+ return require("./model-evaluation-store.js")
18
+ .modelEvaluationStoreCommands;
19
+ },
20
+ get "app"() {
21
+ return require("./app.js").appCommands;
22
+ },
23
+ get "business-app"() {
24
+ return require("./business-app.js").businessAppCommands;
25
+ },
26
+ get "webapp"() {
27
+ return require("./webapp.js").webappCommands;
28
+ },
29
+ get "api-service"() {
30
+ return require("./api-service.js").apiServiceCommands;
31
+ },
32
+ get "api-deployer"() {
33
+ return require("./api-deployer.js").apiDeployerCommands;
34
+ },
35
+ get "bundle"() {
36
+ return require("./bundle.js").bundleCommands;
37
+ },
38
+ get "project-deployer"() {
39
+ return require("./project-deployer.js")
40
+ .projectDeployerCommands;
41
+ },
42
+ get "project-git"() {
43
+ return require("./project-git.js").projectGitCommands;
44
+ },
45
+ get "project-folder"() {
46
+ return require("./project-folder.js")
47
+ .projectFolderCommands;
48
+ },
49
+ get "project-library"() {
50
+ return require("./project-library.js")
51
+ .projectLibraryCommands;
52
+ },
53
+ get "streaming-endpoint"() {
54
+ return require("./streaming-endpoint.js")
55
+ .streamingEndpointCommands;
56
+ },
57
+ get "continuous-activity"() {
58
+ return require("./continuous-activity.js")
59
+ .continuousActivityCommands;
60
+ },
61
+ get "statistics"() {
62
+ return require("./statistics.js").statisticsCommands;
63
+ },
64
+ get "discussion"() {
65
+ return require("./discussion.js").discussionCommands;
66
+ },
67
+ get "meaning"() {
68
+ return require("./meaning.js").meaningCommands;
69
+ },
70
+ get "workspace"() {
71
+ return require("./workspace.js").workspaceCommands;
72
+ },
73
+ get "metrics"() {
74
+ return require("./metrics.js").metricsCommands;
75
+ },
76
+ get "doctor"() {
77
+ return require("./doctor.js").doctorCommands;
78
+ },
79
+ get "wiki"() {
80
+ return require("./wiki.js").wikiCommands;
81
+ },
82
+ get "dashboard"() {
83
+ return require("./dashboard.js").dashboardCommands;
84
+ },
85
+ get "insight"() {
86
+ return require("./insight.js").insightCommands;
87
+ },
88
+ get "data-quality"() {
89
+ return require("./data-quality.js").dataQualityCommands;
90
+ },
91
+ get "future"() {
92
+ return require("./future.js").futureCommands;
93
+ },
94
+ get "flow-zone"() {
95
+ return require("./flow-zone.js").flowZoneCommands;
96
+ },
97
+ get "dataset"() {
98
+ return require("./dataset.js").datasetCommands;
99
+ },
100
+ get "recipe"() {
101
+ return require("./recipe.js").recipeCommands;
102
+ },
103
+ get "job"() {
104
+ return require("./job.js").jobCommands;
105
+ },
106
+ get "scenario"() {
107
+ return require("./scenario.js").scenarioCommands;
108
+ },
109
+ get "folder"() {
110
+ return require("./folder.js").folderCommands;
111
+ },
112
+ get "variable"() {
113
+ return require("./variable.js").variableCommands;
114
+ },
115
+ get "connection"() {
116
+ return require("./connection.js").connectionCommands;
117
+ },
118
+ get "code-env"() {
119
+ return require("./code-env.js").codeEnvCommands;
120
+ },
121
+ get "sql"() {
122
+ return require("./sql.js").sqlCommands;
123
+ },
124
+ get "code"() {
125
+ return require("./code.js").codeCommands;
126
+ },
127
+ get "notebook"() {
128
+ return require("./notebook.js").notebookCommands;
129
+ },
130
+ get "user"() {
131
+ return require("./user.js").userCommands;
132
+ },
133
+ get "group"() {
134
+ return require("./group.js").groupCommands;
135
+ },
136
+ get "plugin"() {
137
+ return require("./plugin.js").pluginCommands;
138
+ },
139
+ get "llm"() {
140
+ return require("./llm.js").llmCommands;
141
+ },
142
+ get "knowledge-bank"() {
143
+ return require("./knowledge-bank.js")
144
+ .knowledgeBankCommands;
145
+ },
146
+ get "macro"() {
147
+ return require("./macro.js").macroCommands;
148
+ },
149
+ get "data-collection"() {
150
+ return require("./data-collection.js")
151
+ .dataCollectionCommands;
152
+ },
80
153
  };
@@ -1,5 +1,6 @@
1
1
  import { deepMerge, } from "../../utils/deep-merge.js";
2
2
  import { json, jsonInput, parseBooleanOption, textInput, } from "../coerce.js";
3
+ import { executionMode, } from "../flags.js";
3
4
  import { readIfExists, skipResult, } from "../output.js";
4
5
  import { requireArgs, UsageError, } from "../usage.js";
5
6
  export const insightCommands = {
@@ -40,17 +41,17 @@ export const insightCommands = {
40
41
  if (params !== undefined)
41
42
  prototype.params = params;
42
43
  const pk = f["project-key"];
43
- if (f["if-not-exists"] === true || f["dry-run"] === true) {
44
+ if (f["if-not-exists"] === true || executionMode(f).dryRun) {
44
45
  const existing = name
45
46
  ? (await c.insights.list(pk)).find((insight) => insight.name === name)
46
47
  : undefined;
47
- if (existing && f["if-not-exists"] === true && f["dry-run"] !== true) {
48
+ if (existing && f["if-not-exists"] === true && !executionMode(f).dryRun) {
48
49
  return skipResult("insight", existing.id, "exists", { current: existing, });
49
50
  }
50
- if (f["if-not-exists"] === true && !name && f["dry-run"] !== true) {
51
+ if (f["if-not-exists"] === true && !name && !executionMode(f).dryRun) {
51
52
  throw new UsageError("--if-not-exists requires --name for insight create.");
52
53
  }
53
- if (f["dry-run"] === true) {
54
+ if (executionMode(f).dryRun) {
54
55
  return {
55
56
  dryRun: true,
56
57
  action: "create",
@@ -95,7 +96,7 @@ export const insightCommands = {
95
96
  && contentType === undefined && payload === undefined) {
96
97
  throw new UsageError("--name, --listed, --params, --content, --file, --data, --data-file, or --stdin is required.");
97
98
  }
98
- if (f["dry-run"] === true) {
99
+ if (executionMode(f).dryRun) {
99
100
  const current = await c.insights.get(a[0], f["project-key"]);
100
101
  const next = deepMerge(current, data ?? {});
101
102
  if (name !== undefined)
@@ -138,11 +139,11 @@ export const insightCommands = {
138
139
  handler: async (c, a, f) => {
139
140
  requireArgs(a, 1, "dss insight delete <id>");
140
141
  const pk = f["project-key"];
141
- if (f["dry-run"] === true || f["if-exists"] === true) {
142
+ if (executionMode(f).dryRun || f["if-exists"] === true) {
142
143
  const current = await readIfExists(() => c.insights.get(a[0], pk));
143
144
  if (!current)
144
145
  return skipResult("insight", a[0], "missing");
145
- if (f["dry-run"] === true) {
146
+ if (executionMode(f).dryRun) {
146
147
  return { dryRun: true, action: "delete", resource: "insight", id: a[0], current, };
147
148
  }
148
149
  }
@@ -2,6 +2,7 @@ import { mkdir, writeFile, } from "node:fs/promises";
2
2
  import { dirname, resolve, } from "node:path";
3
3
  import { parseJobLogProgress, } from "../../resources/jobs.js";
4
4
  import { jobBuildTargetTypeFromFlags, jobLogFilterFromFlag, maxLogLinesFromFlags, num, plainRecord, } from "../coerce.js";
5
+ import { executionMode, } from "../flags.js";
5
6
  import { encodedProjectEndpoint, } from "../output.js";
6
7
  import { requireArgs, UsageError, } from "../usage.js";
7
8
  // ---------------------------------------------------------------------------
@@ -276,7 +277,7 @@ export const jobCommands = {
276
277
  targetType: jobBuildTargetTypeFromFlags(f),
277
278
  timeoutMs: num(f["timeout"], "--timeout"),
278
279
  };
279
- if (f["dry-run"] === true) {
280
+ if (executionMode(f).dryRun) {
280
281
  return {
281
282
  dryRun: true,
282
283
  action: "build",
@@ -315,7 +316,7 @@ export const jobCommands = {
315
316
  summary: f["summary"] === true,
316
317
  targetType: jobBuildTargetTypeFromFlags(f),
317
318
  };
318
- if (f["dry-run"] === true) {
319
+ if (executionMode(f).dryRun) {
319
320
  return {
320
321
  dryRun: true,
321
322
  action: "build-and-wait",
@@ -399,7 +400,7 @@ export const jobCommands = {
399
400
  handler: async (c, a, f) => {
400
401
  requireArgs(a, 1, "dss job abort <id>");
401
402
  const pk = f["project-key"];
402
- if (f["dry-run"] === true) {
403
+ if (executionMode(f).dryRun) {
403
404
  return {
404
405
  dryRun: true,
405
406
  action: "abort",
@@ -0,0 +1,2 @@
1
+ import type { CommandMeta } from "../types.js";
2
+ export declare const knowledgeBankCommands: Record<string, CommandMeta>;
@@ -0,0 +1,80 @@
1
+ import { requiredJsonInput, } from "../coerce.js";
2
+ import { executionMode, } from "../flags.js";
3
+ import { planResult, } from "../output.js";
4
+ import { requireArgs, UsageError, } from "../usage.js";
5
+ const KB_PLAN_EXIT_CODES = { usage: 1, error: 2, transient: 3, };
6
+ const KB_SEARCH_USAGE = "dss knowledge-bank search <knowledgeBankId> (--data JSON|--data-file PATH|--stdin) [--dry-run] [--project-key KEY]";
7
+ const KB_CLEAR_USAGE = "dss knowledge-bank clear <knowledgeBankId> [--dry-run] [--project-key KEY]";
8
+ /**
9
+ * Validate a search body before any execution mode: the same check runs for
10
+ * live, --plan, and --dry-run so planning can never succeed for a body the
11
+ * live call would reject.
12
+ */
13
+ function requireKnowledgeBankSearchBody(flags) {
14
+ const body = requiredJsonInput(flags, "--data, --data-file, or --stdin is required (search body with a query string).");
15
+ const query = body["query"];
16
+ if (typeof query !== "string" || query.trim().length === 0) {
17
+ throw new UsageError(`query is required and must be a non-empty string.\nUsage: ${KB_SEARCH_USAGE}`, "invalid_flag_value");
18
+ }
19
+ return body;
20
+ }
21
+ function requireNonEmptyPositional(value, usage) {
22
+ if (value.trim().length === 0) {
23
+ throw new UsageError(`knowledgeBankId must be a non-empty string.\nUsage: ${usage}`, "invalid_flag_value");
24
+ }
25
+ return value;
26
+ }
27
+ export const knowledgeBankCommands = {
28
+ search: {
29
+ handler: async (c, a, f) => {
30
+ const knowledgeBankId = requireNonEmptyPositional(a[0], KB_SEARCH_USAGE);
31
+ const body = requireKnowledgeBankSearchBody(f);
32
+ const projectKey = f["project-key"];
33
+ if (executionMode(f).dryRun) {
34
+ return planResult("knowledge-bank", "search", {
35
+ asyncKind: "none",
36
+ method: "POST",
37
+ endpoint: `/public/api/projects/${encodeURIComponent(projectKey ?? c.resolveProjectKey(undefined))}/knowledge-banks/${encodeURIComponent(knowledgeBankId)}/search`,
38
+ identifiers: { knowledgeBankId, },
39
+ payload: body,
40
+ idempotency: "none",
41
+ exitCodesOnFailure: KB_PLAN_EXIT_CODES,
42
+ plannedAndDryRun: true,
43
+ });
44
+ }
45
+ return c.knowledgeBanks.search(knowledgeBankId, body, projectKey);
46
+ },
47
+ usage: KB_SEARCH_USAGE,
48
+ description: "Search a knowledge bank for documents matching a query. Runs retrieval against the backing vector store. Body: { query, params?: { maxDocuments, searchType, similarityThreshold, mmrK, mmrDiversity, useAdvancedReranking, rrfRankConstant, rrfRankWindowSize } }.",
49
+ examples: [
50
+ 'dss knowledge-bank search my-kb --data \'{"query":"Hello, world!"}\'',
51
+ 'dss knowledge-bank search my-kb --data \'{"query":"refund policy","params":{"maxDocuments":5,"searchType":"SIMILARITY"}}\' --dry-run',
52
+ ],
53
+ },
54
+ clear: {
55
+ handler: async (c, a, f) => {
56
+ requireArgs(a, 1, KB_CLEAR_USAGE);
57
+ const knowledgeBankId = requireNonEmptyPositional(a[0], KB_CLEAR_USAGE);
58
+ const projectKey = f["project-key"];
59
+ if (executionMode(f).dryRun) {
60
+ return planResult("knowledge-bank", "clear", {
61
+ asyncKind: "none",
62
+ method: "POST",
63
+ endpoint: `/public/api/projects/${encodeURIComponent(projectKey ?? c.resolveProjectKey(undefined))}/knowledge-banks/${encodeURIComponent(knowledgeBankId)}/clear`,
64
+ identifiers: { knowledgeBankId, },
65
+ idempotency: "convergent",
66
+ exitCodesOnFailure: KB_PLAN_EXIT_CODES,
67
+ plannedAndDryRun: true,
68
+ });
69
+ }
70
+ await c.knowledgeBanks.clear(knowledgeBankId, projectKey);
71
+ return { cleared: knowledgeBankId, resource: "knowledge-bank", };
72
+ },
73
+ usage: KB_CLEAR_USAGE,
74
+ description: "DESTRUCTIVE: clear all data from a knowledge bank. The stored content is removed and cannot be recovered from this command.",
75
+ examples: [
76
+ "dss knowledge-bank clear my-kb --dry-run",
77
+ "dss knowledge-bank clear my-kb",
78
+ ],
79
+ },
80
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandMeta } from "../types.js";
2
+ export declare const llmCommands: Record<string, CommandMeta>;
@@ -0,0 +1,93 @@
1
+ import { requiredJsonInput, } from "../coerce.js";
2
+ import { executionMode, } from "../flags.js";
3
+ import { planResult, } from "../output.js";
4
+ import { UsageError, } from "../usage.js";
5
+ const LLM_PLAN_EXIT_CODES = { usage: 1, error: 2, transient: 3, };
6
+ const LLM_LIST_USAGE = "dss llm list [--purpose GENERIC_COMPLETION|TEXT_EMBEDDING_EXTRACTION|IMAGE_GENERATION|NAME] [--project-key KEY]";
7
+ const LLM_COMPLETIONS_USAGE = "dss llm completions (--data JSON|--data-file PATH|--stdin) [--dry-run] [--project-key KEY]";
8
+ const LLM_EMBEDDINGS_USAGE = "dss llm embeddings (--data JSON|--data-file PATH|--stdin) [--dry-run] [--project-key KEY]";
9
+ /**
10
+ * Validate a completions/embeddings payload before any execution mode: the
11
+ * same check runs for live, --plan, and --dry-run so planning can never
12
+ * succeed for a body the live call would reject.
13
+ */
14
+ function requireLlmInferenceBody(flags, usage) {
15
+ const body = requiredJsonInput(flags, "--data, --data-file, or --stdin is required (LLM request body with llmId and queries).");
16
+ const llmId = body["llmId"];
17
+ if (typeof llmId !== "string" || llmId.trim().length === 0) {
18
+ throw new UsageError(`llmId is required and must be a non-empty string (e.g. "openai:openai1:gpt-4").\nUsage: ${usage}`, "invalid_flag_value");
19
+ }
20
+ const queries = body["queries"];
21
+ if (!Array.isArray(queries) || queries.length === 0) {
22
+ throw new UsageError(`queries is required and must be a non-empty array of query objects.\nUsage: ${usage}`, "invalid_flag_value");
23
+ }
24
+ return body;
25
+ }
26
+ export const llmCommands = {
27
+ list: {
28
+ handler: (c, _a, f) => {
29
+ const purpose = f["purpose"];
30
+ return c.llms.list({
31
+ purpose,
32
+ projectKey: f["project-key"],
33
+ });
34
+ },
35
+ usage: LLM_LIST_USAGE,
36
+ description: "List LLMs available in a project (includes Retrieval-Augmented Generation ones). Does not invoke any LLM.",
37
+ examples: ["dss llm list", "dss llm list --purpose TEXT_EMBEDDING_EXTRACTION",],
38
+ },
39
+ completions: {
40
+ handler: async (c, _a, f) => {
41
+ const body = requireLlmInferenceBody(f, LLM_COMPLETIONS_USAGE);
42
+ const projectKey = f["project-key"];
43
+ if (executionMode(f).dryRun) {
44
+ return planResult("llm", "completions", {
45
+ asyncKind: "none",
46
+ method: "POST",
47
+ endpoint: `/public/api/projects/${encodeURIComponent(projectKey ?? c.resolveProjectKey(undefined))}/llms/completions`,
48
+ identifiers: {
49
+ llmId: typeof body["llmId"] === "string" ? body["llmId"] : undefined,
50
+ },
51
+ payload: body,
52
+ idempotency: "none",
53
+ exitCodesOnFailure: LLM_PLAN_EXIT_CODES,
54
+ plannedAndDryRun: true,
55
+ });
56
+ }
57
+ return c.llms.completions(body, projectKey);
58
+ },
59
+ usage: LLM_COMPLETIONS_USAGE,
60
+ description: "Perform completions on an LLM. COST-BEARING: invokes the LLM provider and may incur charges. Body: { llmId, queries: [{ messages: [...] }], settings?: {...} }.",
61
+ examples: [
62
+ 'dss llm completions --data \'{"llmId":"openai:openai1:gpt-4","queries":[{"messages":[{"role":"user","content":"Hello"}]}]}\'',
63
+ 'dss llm completions --data \'{"llmId":"openai:openai1:gpt-4","queries":[...],"settings":{"temperature":0.9}}\' --dry-run',
64
+ ],
65
+ },
66
+ embeddings: {
67
+ handler: async (c, _a, f) => {
68
+ const body = requireLlmInferenceBody(f, LLM_EMBEDDINGS_USAGE);
69
+ const projectKey = f["project-key"];
70
+ if (executionMode(f).dryRun) {
71
+ return planResult("llm", "embeddings", {
72
+ asyncKind: "none",
73
+ method: "POST",
74
+ endpoint: `/public/api/projects/${encodeURIComponent(projectKey ?? c.resolveProjectKey(undefined))}/llms/embeddings`,
75
+ identifiers: {
76
+ llmId: typeof body["llmId"] === "string" ? body["llmId"] : undefined,
77
+ },
78
+ payload: body,
79
+ idempotency: "none",
80
+ exitCodesOnFailure: LLM_PLAN_EXIT_CODES,
81
+ plannedAndDryRun: true,
82
+ });
83
+ }
84
+ return c.llms.embeddings(body, projectKey);
85
+ },
86
+ usage: LLM_EMBEDDINGS_USAGE,
87
+ description: 'Perform embeddings on an LLM. COST-BEARING: invokes the LLM provider and may incur charges. Body: { llmId, queries: [{ text: "..." }] }.',
88
+ examples: [
89
+ 'dss llm embeddings --data \'{"llmId":"openai:openai1:ada002-text-embedding","queries":[{"text":"Who wrote Beethoven 9th?"}]}\'',
90
+ 'dss llm embeddings --data \'{"llmId":"x","queries":[{"text":"y"}]}\' --dry-run',
91
+ ],
92
+ },
93
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandMeta } from "../types.js";
2
+ export declare const macroCommands: Record<string, CommandMeta>;