@k9o/core 1.0.0 → 1.1.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 (49) hide show
  1. package/CHANGELOG.md +5 -71
  2. package/README.md +224 -32
  3. package/dist/{chunk-OE2MMUIG.js → chunk-2NDFTHUB.js} +2 -2
  4. package/dist/chunk-2NDFTHUB.js.map +1 -0
  5. package/dist/{chunk-2VSTF5UU.js → chunk-LJZ45UA2.js} +1 -1
  6. package/dist/chunk-LJZ45UA2.js.map +1 -0
  7. package/dist/{chunk-FVWKL5UQ.js → chunk-O2ZTV6YN.js} +2 -2
  8. package/dist/chunk-O2ZTV6YN.js.map +1 -0
  9. package/dist/envelope.d.ts +9 -9
  10. package/dist/http.d.ts +4 -4
  11. package/dist/http.js +2 -2
  12. package/dist/index.d.ts +163 -183
  13. package/dist/index.js +43 -44
  14. package/dist/index.js.map +1 -1
  15. package/dist/kerror.d.ts +2 -2
  16. package/dist/kerror.js +1 -1
  17. package/dist/types.d.ts +4 -6
  18. package/dist/url-grammar.d.ts +6 -6
  19. package/dist/url-grammar.js +2 -2
  20. package/package.json +4 -4
  21. package/src/audit.ts +6 -6
  22. package/src/compute/llms.ts +16 -16
  23. package/src/data/from.ts +12 -12
  24. package/src/envelope.ts +9 -9
  25. package/src/extensions-bridge.ts +7 -9
  26. package/src/functions.ts +8 -8
  27. package/src/gate-bridge.ts +2 -2
  28. package/src/http.ts +4 -4
  29. package/src/index.ts +17 -27
  30. package/src/internal/sse.ts +2 -2
  31. package/src/kerror.ts +2 -2
  32. package/src/me.ts +7 -8
  33. package/src/metadata.ts +13 -20
  34. package/src/migrations.ts +12 -12
  35. package/src/org.ts +19 -19
  36. package/src/orgs.ts +5 -5
  37. package/src/policies.ts +2 -2
  38. package/src/projects.ts +5 -5
  39. package/src/realtime.ts +16 -16
  40. package/src/retry.ts +1 -1
  41. package/src/storage-buckets.ts +1 -1
  42. package/src/studio/dashboards.ts +13 -13
  43. package/src/studio/index.ts +2 -2
  44. package/src/studio/workflows.ts +21 -21
  45. package/src/types.ts +4 -6
  46. package/src/url-grammar.ts +6 -6
  47. package/dist/chunk-2VSTF5UU.js.map +0 -1
  48. package/dist/chunk-FVWKL5UQ.js.map +0 -1
  49. package/dist/chunk-OE2MMUIG.js.map +0 -1
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import "./chunk-YEYRP6PG.js";
2
2
  import {
3
3
  request,
4
4
  requestStream
5
- } from "./chunk-FVWKL5UQ.js";
5
+ } from "./chunk-O2ZTV6YN.js";
6
6
  import {
7
7
  orgPath,
8
8
  platformPath,
@@ -10,11 +10,11 @@ import {
10
10
  resolveBaseUrl,
11
11
  validateBaseUrl,
12
12
  validateSlug
13
- } from "./chunk-OE2MMUIG.js";
13
+ } from "./chunk-2NDFTHUB.js";
14
14
  import {
15
15
  KError,
16
16
  kerrorFromWire
17
- } from "./chunk-2VSTF5UU.js";
17
+ } from "./chunk-LJZ45UA2.js";
18
18
 
19
19
  // src/data/from.ts
20
20
  var QueryBuilder = class {
@@ -92,7 +92,7 @@ var QueryBuilder = class {
92
92
  return this;
93
93
  }
94
94
  /**
95
- * Total-count behaviour per ch01 §6.4. `none` (default) skips the
95
+ * Total-count behaviour. `none` (default) skips the
96
96
  * count query (cheapest); `exact` runs `SELECT COUNT(*)` (most
97
97
  * expensive at scale); `estimated` reads from pg_stats (fast +
98
98
  * approximate).
@@ -134,7 +134,7 @@ var FromBuilder = class {
134
134
  }
135
135
  /**
136
136
  * Insert one record. Returns the inserted record (with platform-
137
- * generated `id` + `metadata`) per ch04 §6.4.
137
+ * generated `id` + `metadata`).
138
138
  */
139
139
  async insert(record) {
140
140
  return request(this.config, {
@@ -193,9 +193,9 @@ var UpdateBuilder = class extends QueryBuilder {
193
193
  if (idFilter === void 0) {
194
194
  throw new KError({
195
195
  code: "K9O_INVALID_FIELD_VALUE",
196
- message: "update() requires an `.eq('id', '...')` filter; row-mass update is not supported at v0.1.0",
196
+ message: "update() requires an `.eq('id', '...')` filter; changing many rows in one call is not supported",
197
197
  context: { collection: this.collection },
198
- recommendation: "Chain `.eq('id', 'rec_\u2026')` before awaiting the update; row-mass update lands in a v0.x sub-cycle."
198
+ recommendation: "Chain `.eq('id', 'rec_\u2026')` before awaiting the update; to change several rows, call update once per id."
199
199
  });
200
200
  }
201
201
  return request(this.config, {
@@ -221,9 +221,9 @@ var DeleteBuilder = class extends QueryBuilder {
221
221
  if (idFilter === void 0) {
222
222
  throw new KError({
223
223
  code: "K9O_INVALID_FIELD_VALUE",
224
- message: "delete() requires an `.eq('id', '...')` filter; row-mass delete is not supported at v0.1.0",
224
+ message: "delete() requires an `.eq('id', '...')` filter; deleting many rows in one call is not supported",
225
225
  context: { collection: this.collection },
226
- recommendation: "Chain `.eq('id', 'rec_\u2026')` before awaiting the delete; row-mass delete lands in a v0.x sub-cycle."
226
+ recommendation: "Chain `.eq('id', 'rec_\u2026')` before awaiting the delete; to delete several rows, call delete once per id."
227
227
  });
228
228
  }
229
229
  return request(this.config, {
@@ -266,7 +266,7 @@ function makeProjectsNamespace(config) {
266
266
  return {
267
267
  /**
268
268
  * List projects accessible to the caller. Requires authenticated
269
- * session; results are scoped by RBAC per ch06.
269
+ * session; results are scoped by RBAC.
270
270
  */
271
271
  async list() {
272
272
  return request(config, {
@@ -564,7 +564,7 @@ function requireProjectSlug3(config) {
564
564
  if (config.projectSlug === void 0 || config.projectSlug.length === 0) {
565
565
  throw new KError({
566
566
  code: "K9O_MISSING_PROJECT_CONTEXT",
567
- message: "client.metadata requires a bound projectSlug (project data-plane resource, ch14 \xA74)",
567
+ message: "client.metadata requires a bound projectSlug (project data-plane resource,)",
568
568
  context: {},
569
569
  recommendation: "Pass projectSlug when constructing the client."
570
570
  });
@@ -598,7 +598,7 @@ function makeBuilder(config, surfaces, where, limit, cursorValue) {
598
598
  }
599
599
  function makeMetadataNamespace(config) {
600
600
  return {
601
- /** Start a cross-surface metadata query against one or more surfaces (ch14 §3.1). */
601
+ /** Start a cross-surface metadata query against one or more surfaces. */
602
602
  from(surface) {
603
603
  const surfaces = Array.isArray(surface) ? surface : [surface];
604
604
  if (surfaces.length === 0) {
@@ -648,7 +648,7 @@ function makeMigrationsNamespace(config) {
648
648
  path: projectPath(slug, `migrations/${encodeURIComponent(String(version))}`)
649
649
  });
650
650
  },
651
- /** Queue migrations for maker-checker approval per ch06 §8. */
651
+ /** Queue migrations for maker-checker approval. */
652
652
  async queue(input) {
653
653
  const slug = requireProjectSlug4(config);
654
654
  return request(config, {
@@ -666,7 +666,7 @@ function makeMigrationsNamespace(config) {
666
666
  });
667
667
  },
668
668
  /**
669
- * Apply a queued migration by id (§2.6 same-actor fast path — floors at
669
+ * Apply a queued migration by id (same-actor fast path — floors at
670
670
  * PROJECT_ADMIN; a `pending_approval` row, i.e. a protected-collection
671
671
  * migration awaiting a distinct-admin's review, is refused here and
672
672
  * needs its own approval flow, not this call).
@@ -716,7 +716,7 @@ function makeFunctionsNamespace(config) {
716
716
  body: input
717
717
  });
718
718
  },
719
- /** List deployed functions (cursor pagination per ch01 §6.4). */
719
+ /** List deployed functions (cursor pagination). */
720
720
  async list(opts) {
721
721
  const slug = requireProjectSlug5(config);
722
722
  return request(config, {
@@ -733,7 +733,7 @@ function makeFunctionsNamespace(config) {
733
733
  path: projectPath(slug, `functions/${encodeURIComponent(name)}`)
734
734
  });
735
735
  },
736
- /** Retire a function. Returns confirmation; the function name enters a 24h cooldown per ch07 §3.1. */
736
+ /** Retire a function. Returns confirmation; the function name enters a 24h cooldown. */
737
737
  async delete(name) {
738
738
  const slug = requireProjectSlug5(config);
739
739
  return request(config, {
@@ -746,8 +746,8 @@ function makeFunctionsNamespace(config) {
746
746
  * verbatim; the gateway returns whatever the function returns wrapped
747
747
  * in the standard envelope.
748
748
  *
749
- * Per ch07 §3.3: invoke authority is per-function (declared in the
750
- * function manifest). Per ch07 §5: streaming responses use the
749
+ * Per: invoke authority is per-function (declared in the
750
+ * function manifest). Per: streaming responses use the
751
751
  * subscription/async-iterator pattern; this method covers the
752
752
  * request-response variant only.
753
753
  */
@@ -855,7 +855,7 @@ function makeAuditNamespace(config) {
855
855
  * Query the audit log. Returns reverse-chronological events matching
856
856
  * all supplied filters (AND composition).
857
857
  *
858
- * Per ch05 §4 RBAC: requires `AUDIT_READER` role minimum; Custodian-
858
+ * Per RBAC: requires `AUDIT_READER` role minimum; Custodian-
859
859
  * class roles inherit. Project-level audit is project-scoped (this
860
860
  * endpoint); platform-level audit is admin-only (separate surface).
861
861
  */
@@ -870,7 +870,7 @@ function makeAuditNamespace(config) {
870
870
  /**
871
871
  * Convenience: live-tail recent events. Currently single-shot read
872
872
  * with `since` defaulted to "1 minute ago"; subscription-mode tail
873
- * (SSE) lands when the streaming layer ships per ch04 §8 pattern.
873
+ * (SSE) lands when the streaming layer ships pattern.
874
874
  */
875
875
  async tail(opts) {
876
876
  const slug = requireProjectSlug7(config);
@@ -967,7 +967,7 @@ function makeOrgAuditLogNamespace(config) {
967
967
  * GET /audit-log (org-plane).
968
968
  * Distinct from project-plane `client.audit.query()` which routes to
969
969
  * `@<projectSlug>/audit-log`. Org-plane events cover the 6-event family
970
- * per ch05 §4.2 (member_invited/removed/role_granted/revoked/
970
+ * (member_invited/removed/role_granted/revoked/
971
971
  * idp_config_changed/settings_updated).
972
972
  */
973
973
  async query(opts) {
@@ -988,7 +988,7 @@ function makeOrgAuditLogNamespace(config) {
988
988
  function makeOrgGateNamespace(config) {
989
989
  return {
990
990
  roles: {
991
- /** GET /org-role-grants — list active grants per ch02 §6.5 ask 4. */
991
+ /** GET /org-role-grants — list active grants ask 4. */
992
992
  async list(opts) {
993
993
  return request(config, { method: "GET", path: orgPath("org-role-grants"), query: opts });
994
994
  },
@@ -1006,7 +1006,7 @@ function makeOrgGateNamespace(config) {
1006
1006
  }
1007
1007
  },
1008
1008
  idpProviders: {
1009
- /** GET /idp-providers — list configured org operator IdP providers per ch02 §6.5 ask 7. */
1009
+ /** GET /idp-providers — list configured org operator IdP providers ask 7. */
1010
1010
  async list() {
1011
1011
  return request(config, { method: "GET", path: orgPath("idp-providers") });
1012
1012
  },
@@ -1034,7 +1034,7 @@ function makeSmtpNamespace(config) {
1034
1034
  /**
1035
1035
  * GET /org/smtp — read current SMTP config.
1036
1036
  * Returns null when no org-level SMTP is configured (falls back to
1037
- * platform SMTP per ch02 §6.6 3-tier cascade).
1037
+ * platform SMTP 3-tier cascade).
1038
1038
  */
1039
1039
  async get() {
1040
1040
  return request(config, { method: "GET", path: orgPath("org/smtp") });
@@ -1065,17 +1065,17 @@ function makeSmtpNamespace(config) {
1065
1065
  function makeDefaultLlmNamespace(config) {
1066
1066
  return {
1067
1067
  /**
1068
- * GET /org/default-llm — read the org-default LLM model id per ch07
1069
- * §10.3. Returns `null` when no explicit default is set (gateway
1070
- * falls back to `mistral-7b` per §10.3). ORG_ADMIN read; tier-gated.
1068
+ * GET /org/default-llm — read the org-default LLM model id
1069
+ *. Returns `null` when no explicit default is set (gateway
1070
+ * falls back to `mistral-7b`). ORG_ADMIN read; tier-gated.
1071
1071
  */
1072
1072
  async get() {
1073
1073
  return request(config, { method: "GET", path: orgPath("org/default-llm") });
1074
1074
  },
1075
1075
  /**
1076
- * PATCH /org/default-llm — set the org-default LLM per ch07 §10.3.
1076
+ * PATCH /org/default-llm — set the org-default LLM.
1077
1077
  * ORG_ADMIN only. The model must be available to the org's tier per
1078
- * §10.1 or the gateway returns K9O_TIER_FEATURE_GATED.
1078
+ * or the gateway returns K9O_TIER_FEATURE_GATED.
1079
1079
  */
1080
1080
  async set(input) {
1081
1081
  return request(config, { method: "PATCH", path: orgPath("org/default-llm"), body: input });
@@ -1094,7 +1094,7 @@ function makeOrgNamespace(config) {
1094
1094
  gate: makeOrgGateNamespace(config),
1095
1095
  /** Org-level SMTP config — get / set / test / unset. */
1096
1096
  smtp: makeSmtpNamespace(config),
1097
- /** Org-default LLM — get / set per ch07 §10.3 (ORG_ADMIN). */
1097
+ /** Org-default LLM — get / set (ORG_ADMIN). */
1098
1098
  defaultLLM: makeDefaultLlmNamespace(config),
1099
1099
  /**
1100
1100
  * GET /org — read the current org (slug + name + status + settings).
@@ -1135,9 +1135,8 @@ function makeMeNamespace(config) {
1135
1135
  }
1136
1136
  },
1137
1137
  /**
1138
- * API tokens for personal scripting (forward-cycle surface per ch12
1139
- * §3.1 implicit; substrate not yet shipped per gateway routes audit).
1140
- * Methods will return K9O_NOT_FOUND until gateway lands the endpoints.
1138
+ * API tokens for personal scripting. The gateway endpoints are not available yet,
1139
+ * so these methods return K9O_NOT_FOUND until they ship.
1141
1140
  */
1142
1141
  apiTokens: {
1143
1142
  async list() {
@@ -1236,7 +1235,7 @@ function makeRunsNamespace(config) {
1236
1235
  }
1237
1236
  function makeWorkflowsNamespace(config) {
1238
1237
  return {
1239
- /** GET /@<slug>/workflows — list workflows (cursor pagination per ch01 §6.4). */
1238
+ /** GET /@<slug>/workflows — list workflows (cursor pagination). */
1240
1239
  async list(filters) {
1241
1240
  const slug = requireProjectSlug8(config);
1242
1241
  return request(config, { method: "GET", path: projectPath(slug, "workflows"), query: filters });
@@ -1273,7 +1272,7 @@ function makeWorkflowsNamespace(config) {
1273
1272
  },
1274
1273
  /**
1275
1274
  * POST /@<slug>/workflows/<wfl-id>/runs — manual-trigger a run.
1276
- * Valid only for `triggerType: 'manual'` workflows per ch07 §9.6.
1275
+ * Valid only for `triggerType: 'manual'` workflows.
1277
1276
  * Requires PROJECT_AUTHOR. Returns the materialised WorkflowRun.
1278
1277
  */
1279
1278
  async trigger(workflowId, triggerContext = {}) {
@@ -1302,7 +1301,7 @@ function requireProjectSlug9(config) {
1302
1301
  }
1303
1302
  function makeDashboardsNamespace(config) {
1304
1303
  return {
1305
- /** GET /@<slug>/dashboards — list dashboards (cursor pagination per ch01 §6.4). */
1304
+ /** GET /@<slug>/dashboards — list dashboards (cursor pagination). */
1306
1305
  async list(filters) {
1307
1306
  const slug = requireProjectSlug9(config);
1308
1307
  return request(config, { method: "GET", path: projectPath(slug, "dashboards"), query: filters });
@@ -1359,9 +1358,9 @@ function makeDashboardsNamespace(config) {
1359
1358
  // src/studio/index.ts
1360
1359
  function makeStudioNamespace(config) {
1361
1360
  return {
1362
- /** Workflow lifecycle + runs — `client.studio.workflows.*` (ch07 §9). */
1361
+ /** Workflow lifecycle + runs — `client.studio.workflows.*`. */
1363
1362
  workflows: makeWorkflowsNamespace(config),
1364
- /** Dashboard lifecycle + widget data — `client.studio.dashboards.*` (ch04 §3.10). */
1363
+ /** Dashboard lifecycle + widget data — `client.studio.dashboards.*`. */
1365
1364
  dashboards: makeDashboardsNamespace(config)
1366
1365
  };
1367
1366
  }
@@ -1436,7 +1435,7 @@ function requireProjectSlug10(config) {
1436
1435
  }
1437
1436
  function makeLlmsNamespace(config) {
1438
1437
  return {
1439
- /** GET /@<slug>/compute/llms — list models available to the project tier per ch10. */
1438
+ /** GET /@<slug>/compute/llms — list models available to the project tier. */
1440
1439
  async list(opts) {
1441
1440
  const slug = requireProjectSlug10(config);
1442
1441
  return request(config, { method: "GET", path: projectPath(slug, "compute/llms"), query: opts });
@@ -1451,7 +1450,7 @@ function makeLlmsNamespace(config) {
1451
1450
  },
1452
1451
  /**
1453
1452
  * POST /@<slug>/compute/llms/<model-id>/invoke — synchronous inference.
1454
- * Requires PROJECT_AUTHOR or PROJECT_ADMIN (LLM cost gate per §10.5).
1453
+ * Requires PROJECT_AUTHOR or PROJECT_ADMIN (LLM cost gate).
1455
1454
  */
1456
1455
  async invoke(modelId, input) {
1457
1456
  const slug = requireProjectSlug10(config);
@@ -1463,7 +1462,7 @@ function makeLlmsNamespace(config) {
1463
1462
  },
1464
1463
  /**
1465
1464
  * POST /@<slug>/compute/llms/<model-id>/invoke-stream — streaming
1466
- * inference (SSE; per-token delta for low-latency UX per §10.2).
1465
+ * inference (SSE; per-token delta for low-latency UX).
1467
1466
  * Returns an async iterable of `LLMStreamChunk` — caller writes
1468
1467
  * `for await (const chunk of client.compute.llms.invokeStream(...))`.
1469
1468
  * The SDK handles SSE framing internally per
@@ -1483,7 +1482,7 @@ function makeLlmsNamespace(config) {
1483
1482
  }
1484
1483
  function makeComputeNamespace(config) {
1485
1484
  return {
1486
- /** LLM registry + inference — `client.compute.llms.*` (ch07 §10). */
1485
+ /** LLM registry + inference — `client.compute.llms.*`. */
1487
1486
  llms: makeLlmsNamespace(config)
1488
1487
  };
1489
1488
  }
@@ -1647,7 +1646,7 @@ function makeRealtimeNamespace(config) {
1647
1646
  /**
1648
1647
  * Subscribe to a topic. Returns a `RealtimeSubscription` — an async
1649
1648
  * iterable of `RealtimeEvent`s. The SDK selects the richest available
1650
- * transport (WebSocket → SSE → poll) per ch07 §11.3; the caller's
1649
+ * transport (WebSocket → SSE → poll); the caller's
1651
1650
  * `for await` loop is transport-agnostic.
1652
1651
  *
1653
1652
  * ```ts
@@ -1688,7 +1687,7 @@ function makeRealtimeNamespace(config) {
1688
1687
  };
1689
1688
  },
1690
1689
  /**
1691
- * One-shot historical replay per ch07 §11.2 — catch up on missed
1690
+ * One-shot historical replay — catch up on missed
1692
1691
  * events from `fromSequence`. Capped at 10k events server-side;
1693
1692
  * paginate via the returned events' `sequence`. Use the highest
1694
1693
  * `sequence` you've seen as the next `fromSequence`.