@khotan/cli 1.2.0 → 1.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 (2) hide show
  1. package/dist/khotan.js +606 -111
  2. package/package.json +1 -1
package/dist/khotan.js CHANGED
@@ -19,7 +19,7 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
19
19
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
20
20
 
21
21
  // ../khotan-core/src/version.ts
22
- var CATALOG_SCHEMA_VERSION = 2, CATALOG_VERSION = "2026-10-11", KHOTAN_ADAPTER_NAME = "khotan", KHOTAN_ADAPTER_VERSION = "0.10.0", SUPPORTED_CATALOG_SCHEMA_VERSIONS;
22
+ var CATALOG_SCHEMA_VERSION = 2, CATALOG_VERSION = "2026-10-28", KHOTAN_ADAPTER_NAME = "khotan", KHOTAN_ADAPTER_VERSION = "0.10.0", SUPPORTED_CATALOG_SCHEMA_VERSIONS;
23
23
  var init_version = __esm(() => {
24
24
  SUPPORTED_CATALOG_SCHEMA_VERSIONS = [
25
25
  CATALOG_SCHEMA_VERSION
@@ -165,7 +165,9 @@ function platformDomain(config) {
165
165
  input: [
166
166
  { name: "name", location: "body", type: "string", required: true, description: `The ${noun} name.` },
167
167
  { name: "regionPreference", location: "body", type: "string", description: "Optional region id; omit for the default region." },
168
- { name: "environmentVariables", location: "body", type: "json", description: "Optional initial env vars: array of { key, value }. They are not stored, so a dashboard Retry after a failed setup does not re-apply them; set them again if setup failed." },
168
+ { name: "environmentVariables", location: "body", type: "json", acceptsSecrets: true, description: "Optional initial env vars: array of { key, value }. They are not stored, so a dashboard Retry after a failed setup does not re-apply them; set them again if setup failed." },
169
+ { name: "database", location: "body", type: "json", description: "Optional managed Postgres selection: { mode: existing, databaseId } or { mode: create, displayName, regionId }." },
170
+ { name: "redis", location: "body", type: "json", description: "Optional managed Redis selection: { mode: existing, databaseId } or { mode: create, displayName, primaryRegion }." },
169
171
  { name: "idempotencyKey", location: "body", type: "string", description: "Optional retry token; repeating returns the existing resource." }
170
172
  ],
171
173
  http: { method: "POST", path: base, operationId: operationIds.create, bodyMode: "json" },
@@ -252,7 +254,7 @@ function platformDomain(config) {
252
254
  description: `Create or update many env vars in one request. Writes every environment unless you pass target.`,
253
255
  input: [
254
256
  idArg,
255
- { name: "variables", location: "body", type: "json", required: true, description: "Array of { key, value } to upsert." },
257
+ { name: "variables", location: "body", type: "json", required: true, acceptsSecrets: true, description: "Array of { key, value } to upsert." },
256
258
  envWriteTargetField
257
259
  ],
258
260
  http: { method: "POST", path: `${base}/{${resourceParam}}/env`, operationId: operationIds.envBulkSet, bodyMode: "json" },
@@ -288,7 +290,7 @@ function platformDomain(config) {
288
290
  input: [
289
291
  idArg,
290
292
  idField("key", "The env var key."),
291
- { name: "value", location: "body", type: "string", required: true, secret: true, description: "The env var value." },
293
+ { name: "value", location: "body", type: "string", required: true, secret: true, acceptsSecrets: true, description: "The env var value." },
292
294
  envWriteTargetField
293
295
  ],
294
296
  http: { method: "PUT", path: `${base}/{${resourceParam}}/env/{key}`, operationId: operationIds.envSet, bodyMode: "json" },
@@ -484,7 +486,7 @@ var idField = (name, description) => ({
484
486
  type: "string",
485
487
  required: true,
486
488
  description
487
- }), article = (noun) => /^[aeiou]/i.test(noun) ? "an" : "a", tagsDescription = "Full tag list, comma-separated or repeatable; it replaces the stored list, and an empty value clears it. The server lowercases each tag and turns spaces into hyphens. Up to 10 tags of 1-32 lowercase letters, digits, or single hyphens.", identityCapabilities, databaseCapabilities, redisCapabilities, bucketCapabilities, fileCapabilities, folderCapabilities, contextCapabilities, appsCapabilities, pipelinesCapabilities, oauthLifecycleCapabilities, integrationsCapabilities, emailSubscriptionCapabilities, projectCapabilities, organizationCapabilities, capabilities, khotanCatalog, capabilitiesById;
489
+ }), article = (noun) => /^[aeiou]/i.test(noun) ? "an" : "a", tagsDescription = "Full tag list, comma-separated or repeatable; it replaces the stored list, and an empty value clears it. The server lowercases each tag and turns spaces into hyphens. Up to 10 tags of 1-32 lowercase letters, digits, or single hyphens.", identityCapabilities, databaseCapabilities, redisCapabilities, bucketCapabilities, fileCapabilities, folderCapabilities, contextCapabilities, appsCapabilities, pipelinesCapabilities, oauthLifecycleCapabilities, integrationsCapabilities, emailSubscriptionCapabilities, projectCapabilities, organizationCapabilities, feedbackCapabilities, capabilities, khotanCatalog, capabilitiesById;
488
490
  var init_catalog = __esm(() => {
489
491
  init_version();
490
492
  identityCapabilities = [
@@ -583,7 +585,7 @@ var init_catalog = __esm(() => {
583
585
  safety: "secret",
584
586
  auth: true,
585
587
  title: "Rotate database credentials (secret)",
586
- description: "Rotate a database's credentials and return the new connection. Secret-bearing.",
588
+ description: "Rotate a database's credentials and return the new connection as { connectionUri }. Secret-bearing.",
587
589
  input: [idField("databaseId", "The database id.")],
588
590
  http: { method: "POST", path: "/api/v1/databases/{databaseId}/rotate-credentials", operationId: "rotateDatabaseCredentials", bodyMode: "none" },
589
591
  cli: { command: ["databases", "rotate-credentials"], summary: "Rotate credentials (secret)", defaultOutput: "raw" }
@@ -673,7 +675,7 @@ var init_catalog = __esm(() => {
673
675
  safety: "secret",
674
676
  auth: true,
675
677
  title: "Rotate branch credentials (secret)",
676
- description: "Rotate a branch's credentials and return the new connection. Secret-bearing.",
678
+ description: "Rotate a branch's credentials and return the new connection as { connectionUri }. Secret-bearing.",
677
679
  input: [
678
680
  idField("databaseId", "The database id."),
679
681
  idField("branchId", "The branch id.")
@@ -855,7 +857,7 @@ var init_catalog = __esm(() => {
855
857
  safety: "secret",
856
858
  auth: true,
857
859
  title: "Issue storage bucket credentials (secret)",
858
- description: "Issue a folder-scoped API key for the bucket and return its secret once. The key acts only through the Files API and only within the bucket's folder subtree. Each call rotates the credential: any previously issued key for this bucket is revoked. Secret-bearing; explicit-only.",
860
+ description: "Issue a folder-scoped API key for the bucket and return its secret once. The key acts only through the Files API and only within the bucket's folder subtree. Each call rotates the credential: any previously issued key for this bucket is revoked. Returns { apiKey, keyId, prefix, filesApiBaseUrl }. Secret-bearing; explicit-only.",
859
861
  input: [idField("bucketId", "The bucket id.")],
860
862
  http: {
861
863
  method: "POST",
@@ -1739,6 +1741,47 @@ var init_catalog = __esm(() => {
1739
1741
  cli: { command: ["organization", "brand", "app-theme", "set"], summary: "Save the brand's app theme" }
1740
1742
  }
1741
1743
  ];
1744
+ feedbackCapabilities = [
1745
+ {
1746
+ id: "feedback.submit",
1747
+ domain: "feedback",
1748
+ safety: "write",
1749
+ openToAnyCaller: true,
1750
+ auth: true,
1751
+ title: "Send feedback to the Khotan team",
1752
+ description: [
1753
+ "Send the Khotan team a feature request, a product direction, a docs gap, or a bug. Any authenticated caller can send it, read-only members and the code sandbox included, because it changes nothing on the platform.",
1754
+ "Send one when Khotan lacks something you needed, when you see a better way for Khotan, its templates, skills, or design docs to work, when the docs did not answer your question, or when a person asks you to. Send it even when a workaround got the job done.",
1755
+ "Cover one topic in each submission. Explain the situation (your task, its goal, and what you tried) and your reason (what you had to do instead, and what the change would let you or your user do). Set origin to user when a person asked you to send it, and agent when you decided to.",
1756
+ "Replace names, emails, credentials, and customer data with placeholders such as <customer>. Submitting does not end your task: carry on with it afterwards.",
1757
+ `Example: kind feature_request, title "Append a section to DESIGN.md", proposal "An action that appends a section to a repository's DESIGN.md", situation "A user asked me to document empty states; I had no append action", reason "I rewrote the whole file, which risks losing their edits", origin agent.`
1758
+ ].join(" "),
1759
+ input: [
1760
+ { name: "kind", location: "body", type: "string", required: true, description: "feature_request, direction, docs_gap, bug, or other." },
1761
+ { name: "title", location: "body", type: "string", required: true, description: "One line, up to 200 characters." },
1762
+ { name: "proposal", location: "body", type: "string", required: true, description: "What should be added or changed, up to 4,000 characters." },
1763
+ { name: "situation", location: "body", type: "string", required: true, description: "What you were doing: the task, its goal, and what you tried. Up to 4,000 characters." },
1764
+ { name: "reason", location: "body", type: "string", required: true, description: "Why you are sending it: what you had to do instead, and what the change would let you or your user do. Up to 4,000 characters." },
1765
+ { name: "origin", location: "body", type: "string", required: true, description: "user when a person asked you to send it, or agent when you decided to." },
1766
+ { name: "workaround", location: "body", type: "string", description: "What you did instead, up to 4,000 characters." },
1767
+ { name: "impact", location: "body", type: "string", description: "blocked, workaround, or nice_to_have." },
1768
+ { name: "area", location: "body", type: "string", description: "api, cli, mcp, slack_agent, dashboard, templates, skills, docs, or other." },
1769
+ { name: "capabilityIds", location: "body", type: "string[]", description: "Up to 10 Khotan action ids this is about, such as context.create. A requested action may not exist yet." },
1770
+ { name: "threadId", location: "body", type: "string", description: "Your own conversation or session id, such as a Cursor chat id." },
1771
+ { name: "model", location: "body", type: "string", description: "The model you are running as." },
1772
+ { name: "client", location: "body", type: "string", description: "The agent product you run in, such as cursor or claude-code." }
1773
+ ],
1774
+ http: { method: "POST", path: "/api/v1/feedback", operationId: "submitAgentFeedback", bodyMode: "json" },
1775
+ cli: {
1776
+ command: ["feedback", "submit"],
1777
+ summary: "Send feedback to the Khotan team",
1778
+ defaultOutput: "detail",
1779
+ examples: [
1780
+ 'khotan feedback submit --kind feature_request --origin agent --title "Append a section to DESIGN.md" --proposal "..." --situation "..." --reason "..."'
1781
+ ]
1782
+ }
1783
+ }
1784
+ ];
1742
1785
  capabilities = [
1743
1786
  ...identityCapabilities,
1744
1787
  ...appsCapabilities,
@@ -1754,7 +1797,8 @@ var init_catalog = __esm(() => {
1754
1797
  ...folderCapabilities,
1755
1798
  ...projectCapabilities,
1756
1799
  ...emailSubscriptionCapabilities,
1757
- ...organizationCapabilities
1800
+ ...organizationCapabilities,
1801
+ ...feedbackCapabilities
1758
1802
  ];
1759
1803
  khotanCatalog = {
1760
1804
  schemaVersion: CATALOG_SCHEMA_VERSION,
@@ -1891,7 +1935,8 @@ var init_reference = __esm(() => {
1891
1935
  context: "Context documents",
1892
1936
  projects: "Projects",
1893
1937
  integrations: "Integrations",
1894
- organization: "Organization"
1938
+ organization: "Organization",
1939
+ feedback: "Feedback"
1895
1940
  };
1896
1941
  DOMAIN_LABELS = {
1897
1942
  identity: "identity",
@@ -1906,7 +1951,8 @@ var init_reference = __esm(() => {
1906
1951
  context: "context documents",
1907
1952
  projects: "projects",
1908
1953
  integrations: "integrations",
1909
- organization: "organization brand"
1954
+ organization: "organization brand",
1955
+ feedback: "feedback to the Khotan team"
1910
1956
  };
1911
1957
  });
1912
1958
 
@@ -1957,6 +2003,12 @@ function validateCatalogStructure(catalog = khotanCatalog) {
1957
2003
  message: 'Has body inputs but does not declare bodyMode: "json".'
1958
2004
  });
1959
2005
  }
2006
+ if (capability.openToAnyCaller && (capability.safety === "destructive" || capability.safety === "secret")) {
2007
+ errors.push({
2008
+ capabilityId: capability.id,
2009
+ message: `A ${capability.safety} capability cannot be open to every caller.`
2010
+ });
2011
+ }
1960
2012
  }
1961
2013
  return { ok: errors.length === 0, errors };
1962
2014
  }
@@ -9080,6 +9132,106 @@ var init_spec = __esm(() => {
9080
9132
  ]
9081
9133
  }
9082
9134
  },
9135
+ database: {
9136
+ oneOf: [
9137
+ {
9138
+ type: "object",
9139
+ properties: {
9140
+ mode: {
9141
+ type: "string",
9142
+ enum: [
9143
+ "existing"
9144
+ ]
9145
+ },
9146
+ databaseId: {
9147
+ type: "string",
9148
+ minLength: 1
9149
+ }
9150
+ },
9151
+ required: [
9152
+ "mode",
9153
+ "databaseId"
9154
+ ],
9155
+ additionalProperties: false
9156
+ },
9157
+ {
9158
+ type: "object",
9159
+ properties: {
9160
+ mode: {
9161
+ type: "string",
9162
+ enum: [
9163
+ "create"
9164
+ ]
9165
+ },
9166
+ displayName: {
9167
+ type: "string",
9168
+ minLength: 1,
9169
+ maxLength: 63
9170
+ },
9171
+ regionId: {
9172
+ type: "string",
9173
+ minLength: 1
9174
+ }
9175
+ },
9176
+ required: [
9177
+ "mode",
9178
+ "displayName",
9179
+ "regionId"
9180
+ ],
9181
+ additionalProperties: false
9182
+ }
9183
+ ]
9184
+ },
9185
+ redis: {
9186
+ oneOf: [
9187
+ {
9188
+ type: "object",
9189
+ properties: {
9190
+ mode: {
9191
+ type: "string",
9192
+ enum: [
9193
+ "existing"
9194
+ ]
9195
+ },
9196
+ databaseId: {
9197
+ type: "string",
9198
+ minLength: 1
9199
+ }
9200
+ },
9201
+ required: [
9202
+ "mode",
9203
+ "databaseId"
9204
+ ],
9205
+ additionalProperties: false
9206
+ },
9207
+ {
9208
+ type: "object",
9209
+ properties: {
9210
+ mode: {
9211
+ type: "string",
9212
+ enum: [
9213
+ "create"
9214
+ ]
9215
+ },
9216
+ displayName: {
9217
+ type: "string",
9218
+ minLength: 1,
9219
+ maxLength: 63
9220
+ },
9221
+ primaryRegion: {
9222
+ type: "string",
9223
+ minLength: 1
9224
+ }
9225
+ },
9226
+ required: [
9227
+ "mode",
9228
+ "displayName",
9229
+ "primaryRegion"
9230
+ ],
9231
+ additionalProperties: false
9232
+ }
9233
+ ]
9234
+ },
9083
9235
  idempotencyKey: {
9084
9236
  type: "string",
9085
9237
  minLength: 1,
@@ -15634,6 +15786,106 @@ var init_spec = __esm(() => {
15634
15786
  ]
15635
15787
  }
15636
15788
  },
15789
+ database: {
15790
+ oneOf: [
15791
+ {
15792
+ type: "object",
15793
+ properties: {
15794
+ mode: {
15795
+ type: "string",
15796
+ enum: [
15797
+ "existing"
15798
+ ]
15799
+ },
15800
+ databaseId: {
15801
+ type: "string",
15802
+ minLength: 1
15803
+ }
15804
+ },
15805
+ required: [
15806
+ "mode",
15807
+ "databaseId"
15808
+ ],
15809
+ additionalProperties: false
15810
+ },
15811
+ {
15812
+ type: "object",
15813
+ properties: {
15814
+ mode: {
15815
+ type: "string",
15816
+ enum: [
15817
+ "create"
15818
+ ]
15819
+ },
15820
+ displayName: {
15821
+ type: "string",
15822
+ minLength: 1,
15823
+ maxLength: 63
15824
+ },
15825
+ regionId: {
15826
+ type: "string",
15827
+ minLength: 1
15828
+ }
15829
+ },
15830
+ required: [
15831
+ "mode",
15832
+ "displayName",
15833
+ "regionId"
15834
+ ],
15835
+ additionalProperties: false
15836
+ }
15837
+ ]
15838
+ },
15839
+ redis: {
15840
+ oneOf: [
15841
+ {
15842
+ type: "object",
15843
+ properties: {
15844
+ mode: {
15845
+ type: "string",
15846
+ enum: [
15847
+ "existing"
15848
+ ]
15849
+ },
15850
+ databaseId: {
15851
+ type: "string",
15852
+ minLength: 1
15853
+ }
15854
+ },
15855
+ required: [
15856
+ "mode",
15857
+ "databaseId"
15858
+ ],
15859
+ additionalProperties: false
15860
+ },
15861
+ {
15862
+ type: "object",
15863
+ properties: {
15864
+ mode: {
15865
+ type: "string",
15866
+ enum: [
15867
+ "create"
15868
+ ]
15869
+ },
15870
+ displayName: {
15871
+ type: "string",
15872
+ minLength: 1,
15873
+ maxLength: 63
15874
+ },
15875
+ primaryRegion: {
15876
+ type: "string",
15877
+ minLength: 1
15878
+ }
15879
+ },
15880
+ required: [
15881
+ "mode",
15882
+ "displayName",
15883
+ "primaryRegion"
15884
+ ],
15885
+ additionalProperties: false
15886
+ }
15887
+ ]
15888
+ },
15637
15889
  idempotencyKey: {
15638
15890
  type: "string",
15639
15891
  minLength: 1,
@@ -35515,6 +35767,243 @@ var init_spec = __esm(() => {
35515
35767
  }
35516
35768
  ]
35517
35769
  }
35770
+ },
35771
+ "/api/v1/feedback": {
35772
+ post: {
35773
+ responses: {
35774
+ "201": {
35775
+ description: "The stored submission's id and time, and a note to carry on.",
35776
+ content: {
35777
+ "application/json": {
35778
+ schema: {
35779
+ type: "object",
35780
+ properties: {
35781
+ id: {
35782
+ type: "string"
35783
+ },
35784
+ createdAt: {
35785
+ type: "string",
35786
+ description: "ISO 8601 timestamp."
35787
+ },
35788
+ message: {
35789
+ type: "string"
35790
+ }
35791
+ },
35792
+ required: [
35793
+ "id",
35794
+ "createdAt",
35795
+ "message"
35796
+ ],
35797
+ additionalProperties: false
35798
+ }
35799
+ }
35800
+ },
35801
+ headers: {
35802
+ "RateLimit-Limit": {
35803
+ description: "Configured request quota for this route's rate-limit window (decimal integer).",
35804
+ schema: {
35805
+ type: "integer"
35806
+ }
35807
+ },
35808
+ "RateLimit-Remaining": {
35809
+ description: "Requests remaining in the current window after this response (decimal integer, never negative).",
35810
+ schema: {
35811
+ type: "integer"
35812
+ }
35813
+ },
35814
+ "RateLimit-Reset": {
35815
+ description: "Whole seconds until the caller may expect capacity to free in the sliding window.",
35816
+ schema: {
35817
+ type: "integer"
35818
+ }
35819
+ }
35820
+ }
35821
+ },
35822
+ "400": {
35823
+ description: "The request was malformed or failed validation.",
35824
+ content: {
35825
+ "application/json": {
35826
+ schema: {
35827
+ $ref: "#/components/schemas/Error"
35828
+ }
35829
+ }
35830
+ }
35831
+ },
35832
+ "401": {
35833
+ description: "Authentication is missing or invalid.",
35834
+ content: {
35835
+ "application/json": {
35836
+ schema: {
35837
+ $ref: "#/components/schemas/Error"
35838
+ }
35839
+ }
35840
+ }
35841
+ },
35842
+ "429": {
35843
+ description: "Too many requests; retry after the indicated delay.",
35844
+ content: {
35845
+ "application/json": {
35846
+ schema: {
35847
+ $ref: "#/components/schemas/Error"
35848
+ }
35849
+ }
35850
+ },
35851
+ headers: {
35852
+ "RateLimit-Limit": {
35853
+ description: "Configured request quota for this route's rate-limit window (decimal integer).",
35854
+ schema: {
35855
+ type: "integer"
35856
+ }
35857
+ },
35858
+ "RateLimit-Remaining": {
35859
+ description: "Requests remaining in the current window after this response (decimal integer, never negative).",
35860
+ schema: {
35861
+ type: "integer"
35862
+ }
35863
+ },
35864
+ "RateLimit-Reset": {
35865
+ description: "Whole seconds until the caller may expect capacity to free in the sliding window.",
35866
+ schema: {
35867
+ type: "integer"
35868
+ }
35869
+ },
35870
+ "Retry-After": {
35871
+ description: "Whole seconds until the caller may retry after a rate-limit rejection.",
35872
+ schema: {
35873
+ type: "integer"
35874
+ }
35875
+ }
35876
+ }
35877
+ }
35878
+ },
35879
+ summary: "Send feedback to the Khotan team",
35880
+ description: "Stores a feature request, product direction, docs gap, or bug from an agent. The agent states its proposal, the situation it was in, its reason, and whether a person asked it to send it. The server attributes the submission from the API key; for the Slack agent it also records the conversation and the member who asked. Every authenticated caller can send feedback, including the code sandbox's read-only key. Nothing reads submissions back over the API.",
35881
+ tags: [
35882
+ "Feedback"
35883
+ ],
35884
+ operationId: "submitAgentFeedback",
35885
+ requestBody: {
35886
+ required: true,
35887
+ content: {
35888
+ "application/json": {
35889
+ schema: {
35890
+ type: "object",
35891
+ properties: {
35892
+ kind: {
35893
+ type: "string",
35894
+ enum: [
35895
+ "feature_request",
35896
+ "direction",
35897
+ "docs_gap",
35898
+ "bug",
35899
+ "other"
35900
+ ],
35901
+ description: "What kind of feedback this is."
35902
+ },
35903
+ title: {
35904
+ type: "string",
35905
+ minLength: 1,
35906
+ maxLength: 200,
35907
+ description: "One line."
35908
+ },
35909
+ proposal: {
35910
+ type: "string",
35911
+ minLength: 1,
35912
+ maxLength: 4000,
35913
+ description: "What should be added or changed."
35914
+ },
35915
+ situation: {
35916
+ type: "string",
35917
+ minLength: 1,
35918
+ maxLength: 4000,
35919
+ description: "What the agent was doing: the task, its goal, and what it tried."
35920
+ },
35921
+ reason: {
35922
+ type: "string",
35923
+ minLength: 1,
35924
+ maxLength: 4000,
35925
+ description: "Why the agent sent it: what it had to do instead, and what the change would let it or its user do."
35926
+ },
35927
+ origin: {
35928
+ type: "string",
35929
+ enum: [
35930
+ "agent",
35931
+ "user"
35932
+ ],
35933
+ description: "user when a person asked the agent to send it; agent when the agent decided to."
35934
+ },
35935
+ workaround: {
35936
+ type: "string",
35937
+ maxLength: 4000
35938
+ },
35939
+ impact: {
35940
+ type: "string",
35941
+ enum: [
35942
+ "blocked",
35943
+ "workaround",
35944
+ "nice_to_have"
35945
+ ]
35946
+ },
35947
+ area: {
35948
+ type: "string",
35949
+ enum: [
35950
+ "api",
35951
+ "cli",
35952
+ "mcp",
35953
+ "slack_agent",
35954
+ "dashboard",
35955
+ "templates",
35956
+ "skills",
35957
+ "docs",
35958
+ "other"
35959
+ ]
35960
+ },
35961
+ capabilityIds: {
35962
+ description: "Khotan action ids this is about. A requested action may not exist yet.",
35963
+ maxItems: 10,
35964
+ type: "array",
35965
+ items: {
35966
+ type: "string",
35967
+ minLength: 1,
35968
+ maxLength: 200
35969
+ }
35970
+ },
35971
+ threadId: {
35972
+ description: "The caller's own conversation or session id.",
35973
+ type: "string",
35974
+ maxLength: 200
35975
+ },
35976
+ model: {
35977
+ type: "string",
35978
+ maxLength: 200
35979
+ },
35980
+ client: {
35981
+ description: "The agent product, such as cursor or claude-code.",
35982
+ type: "string",
35983
+ maxLength: 200
35984
+ }
35985
+ },
35986
+ required: [
35987
+ "kind",
35988
+ "title",
35989
+ "proposal",
35990
+ "situation",
35991
+ "reason",
35992
+ "origin"
35993
+ ]
35994
+ }
35995
+ }
35996
+ }
35997
+ },
35998
+ security: [
35999
+ {
36000
+ bearerAuth: []
36001
+ },
36002
+ {
36003
+ apiKeyHeader: []
36004
+ }
36005
+ ]
36006
+ }
35518
36007
  }
35519
36008
  },
35520
36009
  components: {
@@ -35829,6 +36318,9 @@ var init_reference2 = __esm(() => {
35829
36318
  });
35830
36319
 
35831
36320
  // ../khotan-core/src/client/api-client.ts
36321
+ function contextHeaders(context) {
36322
+ return context.client ? { ...context.headers, [KHOTAN_CLIENT_HEADER]: `${context.client.name}/${context.client.version}` } : { ...context.headers };
36323
+ }
35832
36324
  function resolveCapability(capabilityOrId) {
35833
36325
  if (typeof capabilityOrId !== "string") {
35834
36326
  return capabilityOrId;
@@ -35875,7 +36367,7 @@ function buildHttpRequest(capabilityOrId, input, context) {
35875
36367
  const queryString = query.toString();
35876
36368
  const url = `${normalizeApiUrl(context.apiUrl)}${path}${queryString ? `?${queryString}` : ""}`;
35877
36369
  const headers = {
35878
- ...context.headers,
36370
+ ...contextHeaders(context),
35879
36371
  accept: "application/json"
35880
36372
  };
35881
36373
  if (capability.auth) {
@@ -35921,7 +36413,7 @@ function createApiClient(context) {
35921
36413
  throw new KhotanClientError("not_authenticated", `${method} ${path} requires authentication but no API key is configured.`);
35922
36414
  }
35923
36415
  const headers = {
35924
- ...context.headers,
36416
+ ...contextHeaders(context),
35925
36417
  accept: "application/json",
35926
36418
  "x-api-key": context.apiKey
35927
36419
  };
@@ -35982,6 +36474,7 @@ function createApiClient(context) {
35982
36474
  }
35983
36475
  };
35984
36476
  }
36477
+ var KHOTAN_CLIENT_HEADER = "x-khotan-client";
35985
36478
  var init_api_client = __esm(() => {
35986
36479
  init_catalog();
35987
36480
  init_errors();
@@ -36612,6 +37105,7 @@ __export(exports_src, {
36612
37105
  KhotanCatalogVersionError: () => KhotanCatalogVersionError,
36613
37106
  KhotanApiError: () => KhotanApiError,
36614
37107
  KHOTAN_CONFIG_KEY: () => KHOTAN_CONFIG_KEY,
37108
+ KHOTAN_CLIENT_HEADER: () => KHOTAN_CLIENT_HEADER,
36615
37109
  KHOTAN_ADAPTER_VERSION: () => KHOTAN_ADAPTER_VERSION,
36616
37110
  KHOTAN_ADAPTER_NAME: () => KHOTAN_ADAPTER_NAME,
36617
37111
  ENV_PROFILE: () => ENV_PROFILE,
@@ -36854,6 +37348,94 @@ function renderResult(io, result, options) {
36854
37348
  outLine(io, scalar(result));
36855
37349
  }
36856
37350
 
37351
+ // src/cli/session.ts
37352
+ init_src();
37353
+
37354
+ // src/cli/assert-org.ts
37355
+ init_src();
37356
+ import { createHash } from "node:crypto";
37357
+ import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync5, writeFileSync as writeFileSync2 } from "node:fs";
37358
+ import { homedir as homedir2 } from "node:os";
37359
+ import { dirname as dirname4, join as join5 } from "node:path";
37360
+ var CACHE_TTL_MS = 5 * 60 * 1000;
37361
+ function cacheDir(env) {
37362
+ const xdg = env.XDG_CACHE_HOME;
37363
+ const base = xdg && xdg.trim() ? xdg : join5(homedir2(), ".cache");
37364
+ return join5(base, "khotan");
37365
+ }
37366
+ function cacheFilePath(env, apiUrl, orgId) {
37367
+ const hash = createHash("sha256").update(`${apiUrl}
37368
+ ${orgId}`).digest("hex").slice(0, 32);
37369
+ return join5(cacheDir(env), `org-assert-${hash}.json`);
37370
+ }
37371
+ function readAssertionCache(path, expectedOrgId) {
37372
+ if (!existsSync4(path))
37373
+ return false;
37374
+ try {
37375
+ const parsed = JSON.parse(readFileSync5(path, "utf8"));
37376
+ if (parsed.organizationId !== expectedOrgId)
37377
+ return false;
37378
+ if (Date.now() - parsed.verifiedAt > CACHE_TTL_MS)
37379
+ return false;
37380
+ return true;
37381
+ } catch {
37382
+ return false;
37383
+ }
37384
+ }
37385
+ function writeAssertionCache(path, organizationId) {
37386
+ try {
37387
+ mkdirSync2(dirname4(path), { recursive: true });
37388
+ const payload = { organizationId, verifiedAt: Date.now() };
37389
+ writeFileSync2(path, `${JSON.stringify(payload)}
37390
+ `);
37391
+ } catch {}
37392
+ }
37393
+ async function assertOrg(session, expectedOrgId, options = {}) {
37394
+ const expected = expectedOrgId.trim();
37395
+ if (!expected)
37396
+ return;
37397
+ const env = options.env ?? process.env;
37398
+ const cachePath = cacheFilePath(env, session.apiUrl, expected);
37399
+ if (!options.skipCache && readAssertionCache(cachePath, expected)) {
37400
+ return;
37401
+ }
37402
+ const principal = await session.client.execute("identity.whoami");
37403
+ const actual = String(principal.organizationId ?? "");
37404
+ if (actual !== expected) {
37405
+ throw new KhotanClientError("org_mismatch", `Khotan org mismatch: expected organizationId=${expected} (KHOTAN_ORG_ID / --assert-org), ` + `but whoami returned organizationId=${actual || "(empty)"}. ` + `You may be authenticated to a different customer's org. ` + `Fix credentials in .env.khotan.local, pass --assert-org, or select a per-customer profile.`);
37406
+ }
37407
+ writeAssertionCache(cachePath, actual);
37408
+ }
37409
+
37410
+ // src/cli/session.ts
37411
+ var CLI_CLIENT = { name: "khotan-cli", version: KHOTAN_ADAPTER_VERSION };
37412
+ function resolveSession(options) {
37413
+ const resolved = resolveProfile({
37414
+ env: options.env,
37415
+ profileName: options.profileName,
37416
+ ...options.storeOptions
37417
+ });
37418
+ const apiUrl = options.apiUrlOverride ?? resolved.apiUrl;
37419
+ const apiKey = options.apiKeyOverride ?? resolved.apiKey;
37420
+ if (!apiUrl) {
37421
+ throw new KhotanClientError("no_api_url", "No Khotan API URL configured. Set one with `khotan auth set-key --api-url <url> --api-key <key>`, or export KHOTAN_API_URL.");
37422
+ }
37423
+ return {
37424
+ client: createApiClient({ apiUrl, apiKey, fetch: options.fetch, client: CLI_CLIENT }),
37425
+ resolved,
37426
+ apiUrl,
37427
+ apiKey
37428
+ };
37429
+ }
37430
+ async function resolveSessionAsserted(options) {
37431
+ const session = resolveSession(options);
37432
+ const expectedOrgId = options.assertOrgOverride?.trim() || options.env[ENV_ORG_ID]?.trim();
37433
+ if (expectedOrgId) {
37434
+ await assertOrg(session, expectedOrgId, { env: options.env });
37435
+ }
37436
+ return session;
37437
+ }
37438
+
36857
37439
  // src/cli/commands/auth.ts
36858
37440
  async function promptIfMissing(io, value, question) {
36859
37441
  if (value !== undefined) {
@@ -36876,7 +37458,7 @@ async function authSetKey(ctx) {
36876
37458
  if (!apiKey) {
36877
37459
  throw new KhotanClientError("missing_argument", "Provide --api-key (an organization API key).");
36878
37460
  }
36879
- const client = createApiClient({ apiUrl, apiKey, fetch: ctx.fetch });
37461
+ const client = createApiClient({ apiUrl, apiKey, fetch: ctx.fetch, client: CLI_CLIENT });
36880
37462
  const principal = await client.execute("identity.whoami");
36881
37463
  setProfile(profileName, { apiUrl, apiKey, defaultOutput: json ? "json" : "human" }, storeOptions);
36882
37464
  selectProfile(profileName, storeOptions);
@@ -36907,11 +37489,11 @@ async function authLogin(ctx) {
36907
37489
  input.role = role;
36908
37490
  if (expiresInRaw)
36909
37491
  input.expiresInDays = Number(expiresInRaw);
36910
- const bootstrapClient = createApiClient({ apiUrl, fetch: ctx.fetch });
37492
+ const bootstrapClient = createApiClient({ apiUrl, fetch: ctx.fetch, client: CLI_CLIENT });
36911
37493
  const minted = await bootstrapClient.execute("api-keys.create-from-credentials", input);
36912
37494
  setProfile(profileName, { apiUrl, apiKey: minted.key, defaultOutput: json ? "json" : "human" }, storeOptions);
36913
37495
  selectProfile(profileName, storeOptions);
36914
- const client = createApiClient({ apiUrl, apiKey: minted.key, fetch: ctx.fetch });
37496
+ const client = createApiClient({ apiUrl, apiKey: minted.key, fetch: ctx.fetch, client: CLI_CLIENT });
36915
37497
  const principal = await client.execute("identity.whoami");
36916
37498
  errLine(io, `Minted an API key (id ${minted.id}) and saved it to profile "${profileName}".`);
36917
37499
  renderResult(io, principal, { json });
@@ -36944,7 +37526,7 @@ async function whoami(ctx) {
36944
37526
  if (!apiUrl || !apiKey) {
36945
37527
  throw new KhotanClientError("not_authenticated", "No credentials configured. Run `khotan auth set-key` or set KHOTAN_API_URL and KHOTAN_API_KEY.");
36946
37528
  }
36947
- const client = createApiClient({ apiUrl, apiKey, fetch: ctx.fetch });
37529
+ const client = createApiClient({ apiUrl, apiKey, fetch: ctx.fetch, client: CLI_CLIENT });
36948
37530
  const principal = await client.execute("identity.whoami");
36949
37531
  renderResult(ctx.io, principal, { json: ctx.json });
36950
37532
  return 0;
@@ -37187,7 +37769,7 @@ async function setAppThemeFromCss(deps, options) {
37187
37769
 
37188
37770
  // src/cli/commands/spec-commit.ts
37189
37771
  init_src();
37190
- import { readFileSync as readFileSync5 } from "node:fs";
37772
+ import { readFileSync as readFileSync6 } from "node:fs";
37191
37773
  async function specCommit(deps, options) {
37192
37774
  const { session, io, json } = deps;
37193
37775
  const raw = readCommitDocument(options.file);
@@ -37220,10 +37802,10 @@ async function specCommit(deps, options) {
37220
37802
  }
37221
37803
  function readCommitDocument(file) {
37222
37804
  if (file === "-") {
37223
- return readFileSync5(0, "utf8");
37805
+ return readFileSync6(0, "utf8");
37224
37806
  }
37225
37807
  try {
37226
- return readFileSync5(file, "utf8");
37808
+ return readFileSync6(file, "utf8");
37227
37809
  } catch (error) {
37228
37810
  throw new KhotanClientError("not_found", `Could not read ${file}: ${error instanceof Error ? error.message : String(error)}`);
37229
37811
  }
@@ -37242,8 +37824,8 @@ function parseCommitDocument(raw) {
37242
37824
  }
37243
37825
 
37244
37826
  // src/cli/commands/status.ts
37245
- import { writeFileSync as writeFileSync2 } from "node:fs";
37246
- import { join as join5, relative } from "node:path";
37827
+ import { writeFileSync as writeFileSync3 } from "node:fs";
37828
+ import { join as join6, relative } from "node:path";
37247
37829
  function str(value) {
37248
37830
  return typeof value === "string" && value.length > 0 ? value : null;
37249
37831
  }
@@ -37523,8 +38105,8 @@ async function runStatus(options) {
37523
38105
  const { session, io, json, writeDir } = options;
37524
38106
  const topology = await loadTopology(session);
37525
38107
  if (writeDir) {
37526
- const target = join5(writeDir, "WORKSPACE.md");
37527
- writeFileSync2(target, buildWorkspaceManifest(topology));
38108
+ const target = join6(writeDir, "WORKSPACE.md");
38109
+ writeFileSync3(target, buildWorkspaceManifest(topology));
37528
38110
  const shown = relative(process.cwd(), target) || target;
37529
38111
  if (json) {
37530
38112
  outLine(io, JSON.stringify({ wrote: shown, topology }, null, 2));
@@ -37751,93 +38333,6 @@ function buildCapabilityInput(capability, positionals, args) {
37751
38333
  return input;
37752
38334
  }
37753
38335
 
37754
- // src/cli/session.ts
37755
- init_src();
37756
-
37757
- // src/cli/assert-org.ts
37758
- init_src();
37759
- import { createHash } from "node:crypto";
37760
- import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync6, writeFileSync as writeFileSync3 } from "node:fs";
37761
- import { homedir as homedir2 } from "node:os";
37762
- import { dirname as dirname4, join as join6 } from "node:path";
37763
- var CACHE_TTL_MS = 5 * 60 * 1000;
37764
- function cacheDir(env) {
37765
- const xdg = env.XDG_CACHE_HOME;
37766
- const base = xdg && xdg.trim() ? xdg : join6(homedir2(), ".cache");
37767
- return join6(base, "khotan");
37768
- }
37769
- function cacheFilePath(env, apiUrl, orgId) {
37770
- const hash = createHash("sha256").update(`${apiUrl}
37771
- ${orgId}`).digest("hex").slice(0, 32);
37772
- return join6(cacheDir(env), `org-assert-${hash}.json`);
37773
- }
37774
- function readAssertionCache(path, expectedOrgId) {
37775
- if (!existsSync4(path))
37776
- return false;
37777
- try {
37778
- const parsed = JSON.parse(readFileSync6(path, "utf8"));
37779
- if (parsed.organizationId !== expectedOrgId)
37780
- return false;
37781
- if (Date.now() - parsed.verifiedAt > CACHE_TTL_MS)
37782
- return false;
37783
- return true;
37784
- } catch {
37785
- return false;
37786
- }
37787
- }
37788
- function writeAssertionCache(path, organizationId) {
37789
- try {
37790
- mkdirSync2(dirname4(path), { recursive: true });
37791
- const payload = { organizationId, verifiedAt: Date.now() };
37792
- writeFileSync3(path, `${JSON.stringify(payload)}
37793
- `);
37794
- } catch {}
37795
- }
37796
- async function assertOrg(session, expectedOrgId, options = {}) {
37797
- const expected = expectedOrgId.trim();
37798
- if (!expected)
37799
- return;
37800
- const env = options.env ?? process.env;
37801
- const cachePath = cacheFilePath(env, session.apiUrl, expected);
37802
- if (!options.skipCache && readAssertionCache(cachePath, expected)) {
37803
- return;
37804
- }
37805
- const principal = await session.client.execute("identity.whoami");
37806
- const actual = String(principal.organizationId ?? "");
37807
- if (actual !== expected) {
37808
- throw new KhotanClientError("org_mismatch", `Khotan org mismatch: expected organizationId=${expected} (KHOTAN_ORG_ID / --assert-org), ` + `but whoami returned organizationId=${actual || "(empty)"}. ` + `You may be authenticated to a different customer's org. ` + `Fix credentials in .env.khotan.local, pass --assert-org, or select a per-customer profile.`);
37809
- }
37810
- writeAssertionCache(cachePath, actual);
37811
- }
37812
-
37813
- // src/cli/session.ts
37814
- function resolveSession(options) {
37815
- const resolved = resolveProfile({
37816
- env: options.env,
37817
- profileName: options.profileName,
37818
- ...options.storeOptions
37819
- });
37820
- const apiUrl = options.apiUrlOverride ?? resolved.apiUrl;
37821
- const apiKey = options.apiKeyOverride ?? resolved.apiKey;
37822
- if (!apiUrl) {
37823
- throw new KhotanClientError("no_api_url", "No Khotan API URL configured. Set one with `khotan auth set-key --api-url <url> --api-key <key>`, or export KHOTAN_API_URL.");
37824
- }
37825
- return {
37826
- client: createApiClient({ apiUrl, apiKey, fetch: options.fetch }),
37827
- resolved,
37828
- apiUrl,
37829
- apiKey
37830
- };
37831
- }
37832
- async function resolveSessionAsserted(options) {
37833
- const session = resolveSession(options);
37834
- const expectedOrgId = options.assertOrgOverride?.trim() || options.env[ENV_ORG_ID]?.trim();
37835
- if (expectedOrgId) {
37836
- await assertOrg(session, expectedOrgId, { env: options.env });
37837
- }
37838
- return session;
37839
- }
37840
-
37841
38336
  // src/cli/workspace-check.ts
37842
38337
  init_src();
37843
38338
  import { spawnSync } from "node:child_process";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khotan/cli",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "description": "Khotan CLI: a human- and agent-facing adapter over the Khotan /api/v1 surface.",
6
6
  "license": "SEE LICENSE IN LICENSE.md",