@tinycloud/operations 0.7.11-beta.2 → 0.8.0-beta.3

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.
@@ -1,4 +1,4 @@
1
- import { I as InvocationTarget, a as OperationResult, e as OperationRef, R as RetryDescriptor } from './contract-DrtFhVsg.cjs';
1
+ import { I as InvocationTarget, a as OperationResult, e as OperationRef, R as RetryDescriptor } from './contract-BGJGxuGr.cjs';
2
2
 
3
3
  /** Value-free counters; the caller owns this optional diagnostic sink. */
4
4
  interface OperationMetrics {
@@ -1,4 +1,4 @@
1
- import { I as InvocationTarget, a as OperationResult, e as OperationRef, R as RetryDescriptor } from './contract-DrtFhVsg.js';
1
+ import { I as InvocationTarget, a as OperationResult, e as OperationRef, R as RetryDescriptor } from './contract-BGJGxuGr.js';
2
2
 
3
3
  /** Value-free counters; the caller owns this optional diagnostic sink. */
4
4
  interface OperationMetrics {
package/dist/index.cjs CHANGED
@@ -344,6 +344,8 @@ var init_errors2 = __esm({
344
344
  "SQL_EXECUTION_FAILED",
345
345
  "SQL_RESULT_LIMIT_EXCEEDED",
346
346
  "SQL_VALUE_UNSAFE",
347
+ "READ_SOURCE_CHANGED",
348
+ "READ_CONTEXT_MISMATCH",
347
349
  "SECRET_READ_FAILED",
348
350
  "SECRET_DECRYPT_FAILED",
349
351
  "OUTPUT_INVALID",
@@ -7807,10 +7809,20 @@ async function executeKvList(context, input) {
7807
7809
  const space = resolveGenericKvSpace(runtime, input.space);
7808
7810
  const result = await genericKv(runtime, space).list({
7809
7811
  ...input.prefix === void 0 ? {} : { prefix: input.prefix },
7812
+ ...input.cursor === void 0 ? {} : { cursor: input.cursor },
7810
7813
  limit: input.limit ?? DEFAULT_KV_LIST_LIMIT
7811
7814
  });
7812
- if (!result.ok) return kvFailure(result.error, "list KV keys");
7815
+ if (!result.ok) {
7816
+ if (input.cursor !== void 0 && result.error.meta?.status === 400) {
7817
+ return {
7818
+ status: "error",
7819
+ error: operationError("INPUT_INVALID", "The node rejected the KV listing cursor. Restart the listing without a cursor and discard earlier pages rather than combining different listings.")
7820
+ };
7821
+ }
7822
+ return kvFailure(result.error, "list KV keys");
7823
+ }
7813
7824
  const keys = [...result.data.keys];
7825
+ const nextCursor = result.data.nextCursor ?? null;
7814
7826
  return {
7815
7827
  status: "ok",
7816
7828
  output: {
@@ -7818,7 +7830,8 @@ async function executeKvList(context, input) {
7818
7830
  prefix: input.prefix ?? "",
7819
7831
  keys,
7820
7832
  count: keys.length,
7821
- truncated: result.data.truncated ?? false
7833
+ truncated: result.data.truncated === true || nextCursor !== null,
7834
+ nextCursor
7822
7835
  }
7823
7836
  };
7824
7837
  } catch (error) {
@@ -8233,14 +8246,16 @@ var init_exploration = __esm({
8233
8246
  KvListInputSchema = import_zod7.z.object({
8234
8247
  space: SpaceSchema2,
8235
8248
  prefix: PrefixSchema2.optional(),
8236
- limit: LimitSchema.optional()
8249
+ limit: LimitSchema.optional(),
8250
+ cursor: import_zod7.z.string().optional()
8237
8251
  }).strict();
8238
8252
  KvListOutputSchema = import_zod7.z.object({
8239
8253
  space: import_zod7.z.string().min(1),
8240
8254
  prefix: import_zod7.z.string(),
8241
8255
  keys: import_zod7.z.array(import_zod7.z.string()),
8242
8256
  count: import_zod7.z.number().int().nonnegative(),
8243
- truncated: import_zod7.z.boolean()
8257
+ truncated: import_zod7.z.boolean(),
8258
+ nextCursor: import_zod7.z.string().nullable()
8244
8259
  }).strict();
8245
8260
  KvGetInputSchema = import_zod7.z.object({
8246
8261
  space: SpaceSchema2,
@@ -8382,7 +8397,7 @@ var init_exploration = __esm({
8382
8397
  id: "tinycloud.kv.list",
8383
8398
  version: 1,
8384
8399
  title: "List TinyCloud KV keys",
8385
- description: "List keys at one exact prefix in a delegated TinyCloud space.",
8400
+ description: "List a bounded page of keys at the supplied prefix in one delegated TinyCloud space. Continue with nextCursor as cursor and the same space and prefix; cursors are opaque and scope-bound. nextCursor is null when unavailable. If truncated is true without a cursor, coverage is incomplete: narrow the prefix rather than guessing offsets.",
8386
8401
  input: KvListInputSchema,
8387
8402
  output: KvListOutputSchema,
8388
8403
  effects: ["read"],
@@ -8397,7 +8412,7 @@ var init_exploration = __esm({
8397
8412
  id: "tinycloud.kv.get",
8398
8413
  version: 1,
8399
8414
  title: "Get a TinyCloud KV value",
8400
- description: "Read one exact key with a node-enforced one MiB response limit.",
8415
+ description: "Read one exact key with a one MiB acquired-body limit in bytes. Hosted MCP separately caps the serialized response envelope at 100,000 UTF-16 code units; a value below one MiB can still exceed that cap. Use tinycloud_read for bounded, byte-preserving delivery within the acquisition limit.",
8401
8416
  input: KvGetInputSchema,
8402
8417
  output: KvGetOutputSchema,
8403
8418
  effects: ["read"],
@@ -8955,6 +8970,320 @@ var init_knowledge = __esm({
8955
8970
  }
8956
8971
  });
8957
8972
 
8973
+ // src/operations/read.ts
8974
+ async function planRead(context, input) {
8975
+ return input.resource.kind === "kv" ? planKvGet(context, input.resource) : planSqlRead(context, input.resource);
8976
+ }
8977
+ async function executeRead2(context, input) {
8978
+ try {
8979
+ const runtime = runtimeContext2(context);
8980
+ const requirements = await planRead(runtime, input);
8981
+ const space = requirements[0]?.space;
8982
+ if (typeof space !== "string") throw new TypeError("Read target space is unavailable.");
8983
+ const ownerDid = (0, import_node_sdk2.parseSpaceUri)(space)?.owner;
8984
+ if (ownerDid === void 0) return invalidInput2("The read target must resolve to an owner-scoped space.");
8985
+ const resource = resourceIdentity(input.resource, space);
8986
+ const expected = input.expected;
8987
+ const offset = input.offset ?? 0;
8988
+ if (offset > 0 && expected === void 0) {
8989
+ return invalidInput2("A nonzero byte offset requires the previous page's expected binding.");
8990
+ }
8991
+ if (expected !== void 0 && (expected.host !== context.summary.host || expected.ownerDid !== ownerDid || jcsCanonicalize(expected.resource) !== jcsCanonicalize(resource))) {
8992
+ return {
8993
+ status: "error",
8994
+ error: operationError("READ_CONTEXT_MISMATCH", "The expected read binding identifies a different host, owner, space, or resource.")
8995
+ };
8996
+ }
8997
+ let bytes;
8998
+ let etag = null;
8999
+ if (input.resource.kind === "kv") {
9000
+ const result = await genericKv(runtime, space).get(input.resource.key, {
9001
+ binary: true,
9002
+ maxResponseBytes: MAX_KV_VALUE_BYTES
9003
+ });
9004
+ if (!result.ok) return kvFailure(result.error, "read the KV value");
9005
+ bytes = result.data.data;
9006
+ if (bytes.byteLength > MAX_KV_VALUE_BYTES) {
9007
+ return kvFailure({ code: "KV_RESPONSE_TOO_LARGE" }, "read the KV value");
9008
+ }
9009
+ etag = result.data.headers.etag ?? null;
9010
+ } else {
9011
+ const result = await executeSqlQuery(context, input.resource);
9012
+ if (result.status !== "ok") return result;
9013
+ bytes = Buffer.from(JSON.stringify(result.output), "utf8");
9014
+ }
9015
+ const acquiredAt = (/* @__PURE__ */ new Date()).toISOString();
9016
+ const sha256 = (0, import_node_crypto3.createHash)("sha256").update(bytes).digest("hex");
9017
+ if (expected !== void 0 && (expected.sha256 !== sha256 || expected.totalBytes !== bytes.byteLength)) {
9018
+ return {
9019
+ status: "error",
9020
+ error: operationError("READ_SOURCE_CHANGED", "The acquired bytes no longer match the expected digest and byte length. Start a new read explicitly to accept a new source revision.")
9021
+ };
9022
+ }
9023
+ if (offset > bytes.byteLength) return invalidInput2("The byte offset exceeds the acquired body length.");
9024
+ const validUtf8 = input.encoding === "base64" ? false : (0, import_node_buffer.isUtf8)(bytes);
9025
+ const encoding = input.encoding ?? (validUtf8 ? "utf8" : "base64");
9026
+ if (encoding === "utf8" && !validUtf8) {
9027
+ return invalidInput2("The acquired body is not valid UTF-8. Request base64 to preserve its original bytes.");
9028
+ }
9029
+ if (encoding === "utf8" && isContinuationByte(bytes[offset])) {
9030
+ return invalidInput2("The byte offset is inside a UTF-8 character.");
9031
+ }
9032
+ const pageBytes = input.pageBytes ?? MAX_PAGE_BYTES;
9033
+ const binding = {
9034
+ host: context.summary.host,
9035
+ ownerDid,
9036
+ resource,
9037
+ sha256,
9038
+ totalBytes: bytes.byteLength
9039
+ };
9040
+ const provenance = {
9041
+ digestAlgorithm: "sha256",
9042
+ representation: input.resource.kind === "kv" ? "original-bytes" : "normalized-sql-result-json",
9043
+ acquiredAt,
9044
+ etag
9045
+ };
9046
+ let end = Math.min(offset + pageBytes, bytes.byteLength);
9047
+ for (; ; ) {
9048
+ if (encoding === "utf8") {
9049
+ while (end > offset && isContinuationByte(bytes[end])) end--;
9050
+ }
9051
+ if (end === offset && offset < bytes.byteLength) {
9052
+ return invalidInput2("The requested UTF-8 character or resource provenance cannot fit the bounded page. Use a larger pageBytes (at least 4 for UTF-8), base64, or a shorter locator.");
9053
+ }
9054
+ const value = Buffer.from(bytes.buffer, bytes.byteOffset + offset, end - offset).toString(
9055
+ encoding === "utf8" ? "utf8" : "base64"
9056
+ );
9057
+ const complete = end === bytes.byteLength;
9058
+ const output = {
9059
+ value,
9060
+ encoding,
9061
+ range: { unit: "bytes", start: offset, end },
9062
+ binding,
9063
+ provenance,
9064
+ complete,
9065
+ continuation: complete ? null : { offset: end, pageBytes, encoding, expected: binding }
9066
+ };
9067
+ if (Buffer.byteLength(JSON.stringify(output), "utf8") < MAX_PAGE_OUTPUT_BYTES) {
9068
+ return { status: "ok", output };
9069
+ }
9070
+ if (end === offset) {
9071
+ return invalidInput2("The resource provenance cannot fit the bounded page; use a shorter locator.");
9072
+ }
9073
+ end = offset + Math.floor((end - offset) / 2);
9074
+ }
9075
+ } catch (error) {
9076
+ if (error instanceof OperationInvocationError) return { status: "error", error: error.operationError };
9077
+ return caughtKvFailure(error, "read the resource");
9078
+ }
9079
+ }
9080
+ function resourceIdentity(resource, space) {
9081
+ if (resource.kind === "kv") return { kind: "kv", space, key: resource.key };
9082
+ const query = { database: resource.database, sql: resource.sql };
9083
+ if (resource.params !== void 0) query.params = resource.params;
9084
+ if (resource.maxRows !== void 0) query.maxRows = resource.maxRows;
9085
+ if (resource.maxBytes !== void 0) query.maxBytes = resource.maxBytes;
9086
+ return {
9087
+ kind: "sql",
9088
+ space,
9089
+ database: resource.database,
9090
+ querySha256: (0, import_node_crypto3.createHash)("sha256").update(jcsCanonicalize(query), "utf8").digest("hex")
9091
+ };
9092
+ }
9093
+ function isContinuationByte(byte) {
9094
+ return byte !== void 0 && (byte & 192) === 128;
9095
+ }
9096
+ function invalidInput2(message) {
9097
+ return { status: "error", error: operationError("INPUT_INVALID", message) };
9098
+ }
9099
+ var import_node_buffer, import_node_crypto3, import_node_sdk2, import_zod9, MAX_PAGE_BYTES, MAX_PAGE_OUTPUT_BYTES, Sha256Schema, ByteOffsetSchema, EncodingSchema, PageBytesSchema, ResourceSchema, ResourceIdentitySchema, ReadBindingSchema, ContinuationSchema, ReadInputSchema2, ReadOutputSchema2, readOperationDefinitions;
9100
+ var init_read = __esm({
9101
+ "src/operations/read.ts"() {
9102
+ "use strict";
9103
+ import_node_buffer = require("buffer");
9104
+ import_node_crypto3 = require("crypto");
9105
+ import_node_sdk2 = require("@tinycloud/node-sdk");
9106
+ init_jcs();
9107
+ import_zod9 = require("zod");
9108
+ init_errors2();
9109
+ init_exploration();
9110
+ init_sql();
9111
+ MAX_PAGE_BYTES = 12 * 1024;
9112
+ MAX_PAGE_OUTPUT_BYTES = 8e4;
9113
+ Sha256Schema = import_zod9.z.string().regex(/^[0-9a-f]{64}$/);
9114
+ ByteOffsetSchema = import_zod9.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
9115
+ EncodingSchema = import_zod9.z.enum(["utf8", "base64"]);
9116
+ PageBytesSchema = import_zod9.z.number().int().min(1).max(MAX_PAGE_BYTES);
9117
+ ResourceSchema = import_zod9.z.discriminatedUnion("kind", [
9118
+ KvGetInputSchema.omit({ representation: true }).extend({ kind: import_zod9.z.literal("kv") }),
9119
+ SqlQueryInputSchema.extend({ kind: import_zod9.z.literal("sql") })
9120
+ ]);
9121
+ ResourceIdentitySchema = import_zod9.z.discriminatedUnion("kind", [
9122
+ import_zod9.z.object({
9123
+ kind: import_zod9.z.literal("kv"),
9124
+ space: import_zod9.z.string().min(1),
9125
+ key: import_zod9.z.string().min(1)
9126
+ }).strict(),
9127
+ import_zod9.z.object({
9128
+ kind: import_zod9.z.literal("sql"),
9129
+ space: import_zod9.z.string().min(1),
9130
+ database: import_zod9.z.string().min(1),
9131
+ querySha256: Sha256Schema
9132
+ }).strict()
9133
+ ]);
9134
+ ReadBindingSchema = import_zod9.z.object({
9135
+ host: import_zod9.z.string().min(1),
9136
+ ownerDid: import_zod9.z.string().min(1),
9137
+ resource: ResourceIdentitySchema,
9138
+ sha256: Sha256Schema,
9139
+ totalBytes: ByteOffsetSchema
9140
+ }).strict();
9141
+ ContinuationSchema = import_zod9.z.object({
9142
+ offset: ByteOffsetSchema,
9143
+ pageBytes: PageBytesSchema,
9144
+ encoding: EncodingSchema,
9145
+ expected: ReadBindingSchema
9146
+ }).strict();
9147
+ ReadInputSchema2 = import_zod9.z.object({
9148
+ resource: ResourceSchema,
9149
+ offset: ByteOffsetSchema.optional(),
9150
+ pageBytes: PageBytesSchema.optional(),
9151
+ encoding: EncodingSchema.optional(),
9152
+ expected: ReadBindingSchema.optional()
9153
+ }).strict().superRefine((input, context) => {
9154
+ if ((input.offset ?? 0) > 0 && input.expected === void 0) {
9155
+ context.addIssue({
9156
+ code: import_zod9.z.ZodIssueCode.custom,
9157
+ path: ["expected"],
9158
+ message: "A nonzero byte offset requires the previous page's expected binding."
9159
+ });
9160
+ }
9161
+ });
9162
+ ReadOutputSchema2 = import_zod9.z.object({
9163
+ value: import_zod9.z.string(),
9164
+ encoding: EncodingSchema,
9165
+ range: import_zod9.z.object({
9166
+ unit: import_zod9.z.literal("bytes"),
9167
+ start: ByteOffsetSchema,
9168
+ end: ByteOffsetSchema
9169
+ }).strict(),
9170
+ binding: ReadBindingSchema,
9171
+ provenance: import_zod9.z.object({
9172
+ digestAlgorithm: import_zod9.z.literal("sha256"),
9173
+ representation: import_zod9.z.enum(["original-bytes", "normalized-sql-result-json"]),
9174
+ acquiredAt: import_zod9.z.string().datetime(),
9175
+ etag: import_zod9.z.string().nullable()
9176
+ }).strict(),
9177
+ complete: import_zod9.z.boolean(),
9178
+ continuation: ContinuationSchema.nullable()
9179
+ }).strict();
9180
+ readOperationDefinitions = [{
9181
+ id: "tinycloud.read",
9182
+ version: 1,
9183
+ title: "Read complete TinyCloud resource bytes in bounded pages",
9184
+ description: "Read original KV bytes or normalized read-only SQL result JSON in digest-bound byte pages. Every call reacquires the resource with current authority. Replay the original resource with continuation fields; a recipient can validate the first page with expected: binding. SQL locators require retaining the original query and parameters. Paging does not increase acquisition limits.",
9185
+ input: ReadInputSchema2,
9186
+ output: ReadOutputSchema2,
9187
+ effects: ["read"],
9188
+ runtime: "authenticated",
9189
+ postures: ["owner-openkey", "delegate-session", "local-owner-key"],
9190
+ exposure: {
9191
+ cli: { status: "excluded", reason: "Existing CLI KV and SQL reads remain the CLI surface." },
9192
+ mcp: { status: "required" },
9193
+ skill: { status: "required" },
9194
+ docs: { status: "required" }
9195
+ },
9196
+ sensitivity: { input: ["/resource", "/expected"], output: ["/value", "/binding", "/continuation"] },
9197
+ authority: planRead,
9198
+ execute: executeRead2
9199
+ }];
9200
+ }
9201
+ });
9202
+
9203
+ // src/operations/read-scope.ts
9204
+ function scopeSpace(context, input) {
9205
+ const space = resolveGenericKvSpace(context, input.space);
9206
+ const ownSpace = resolveGenericKvSpace(context, space.split(":").at(-1));
9207
+ if (space !== ownSpace) {
9208
+ throw new OperationInvocationError(operationError(
9209
+ "INPUT_INVALID",
9210
+ "Read-scope approval must target the selected owner's space."
9211
+ ));
9212
+ }
9213
+ return space;
9214
+ }
9215
+ async function planReadScope(context, input) {
9216
+ const space = scopeSpace(context, input);
9217
+ const permissions = [];
9218
+ for (const path of input.kvPrefixes ?? []) {
9219
+ permissions.push({
9220
+ service: "tinycloud.kv",
9221
+ space,
9222
+ path,
9223
+ actions: ["tinycloud.kv/get", "tinycloud.kv/metadata", "tinycloud.kv/list"]
9224
+ });
9225
+ }
9226
+ for (const path of input.databases ?? []) {
9227
+ permissions.push({ service: "tinycloud.sql", space, path, actions: ["tinycloud.sql/read"] });
9228
+ }
9229
+ return canonicalizeCapabilities(permissions);
9230
+ }
9231
+ var import_zod10, InputSchema, OutputSchema, readScopeOperationDefinitions;
9232
+ var init_read_scope = __esm({
9233
+ "src/operations/read-scope.ts"() {
9234
+ "use strict";
9235
+ import_zod10 = require("zod");
9236
+ init_artifacts();
9237
+ init_authority();
9238
+ init_errors2();
9239
+ init_exploration();
9240
+ init_sql();
9241
+ InputSchema = import_zod10.z.object({
9242
+ space: KvGetInputSchema.shape.space,
9243
+ kvPrefixes: import_zod10.z.array(import_zod10.z.string().max(2048).refine(
9244
+ (prefix) => (prefix === "" || prefix.endsWith("/")) && prefix !== "/" && !prefix.includes("*") && !/[\u0000-\u001f\u007f]/.test(prefix),
9245
+ "Select a recursive slash-ended KV prefix, or explicitly select the empty prefix for the whole space."
9246
+ )).min(1).max(20).optional(),
9247
+ databases: import_zod10.z.array(SqlQueryInputSchema.shape.database).min(1).max(20).optional()
9248
+ }).strict().superRefine((input, issue) => {
9249
+ if (input.kvPrefixes === void 0 && input.databases === void 0) {
9250
+ issue.addIssue({ code: import_zod10.z.ZodIssueCode.custom, message: "Select at least one KV prefix or exact database." });
9251
+ }
9252
+ });
9253
+ OutputSchema = import_zod10.z.object({
9254
+ space: import_zod10.z.string().min(1),
9255
+ permissions: import_zod10.z.array(PermissionEntrySchema).min(1),
9256
+ access: import_zod10.z.literal("not-tested")
9257
+ }).strict();
9258
+ readScopeOperationDefinitions = [{
9259
+ id: "tinycloud.auth.read_scope",
9260
+ version: 1,
9261
+ title: "Approve a reusable TinyCloud read scope",
9262
+ description: "Explicitly select recursive KV prefixes and/or exact read-only databases in one existing owner space. Missing authority uses the normal request-bound approval flow. Empty KV prefix explicitly requests the whole space. No write authority is requested; ordinary GET/HEAD requests stay exact. Future children are covered only until grant expiry/revocation. Success reports capability coverage, not a storage read; then use KV/SQL discovery or tinycloud_read.",
9263
+ input: InputSchema,
9264
+ output: OutputSchema,
9265
+ effects: ["read"],
9266
+ runtime: "authenticated",
9267
+ postures: ["owner-openkey", "delegate-session", "local-owner-key"],
9268
+ exposure: {
9269
+ cli: { status: "excluded", reason: "The CLI retains its explicit permission-manifest/request flow; SDK callers use invokeOperation." },
9270
+ mcp: { status: "required" },
9271
+ skill: { status: "required" },
9272
+ docs: { status: "required" }
9273
+ },
9274
+ sensitivity: { input: ["/kvPrefixes", "/databases"], output: ["/permissions"] },
9275
+ authority: planReadScope,
9276
+ execute: async (context, input) => {
9277
+ const runtime = runtimeContext2(context);
9278
+ return {
9279
+ status: "ok",
9280
+ output: { space: scopeSpace(runtime, input), permissions: await planReadScope(runtime, input), access: "not-tested" }
9281
+ };
9282
+ }
9283
+ }];
9284
+ }
9285
+ });
9286
+
8958
9287
  // src/secret-request.ts
8959
9288
  function canonicalSecretRequestOwner(did) {
8960
9289
  const match = typeof did === "string" ? OWNER_RE.exec(did) : null;
@@ -9321,28 +9650,28 @@ function resolveEncryptionNetworkId(node, space) {
9321
9650
  )
9322
9651
  );
9323
9652
  }
9324
- var import_zod9, SecretsGetInputSchema, SecretsGetOutputSchema, SECRETS_GET_POSTURES, SECRETS_GET_EXPOSURE, SECRETS_GET_SENSITIVITY, secretsGetOperationDefinition, secretsGetOperationDefinitions;
9653
+ var import_zod11, SecretsGetInputSchema, SecretsGetOutputSchema, SECRETS_GET_POSTURES, SECRETS_GET_EXPOSURE, SECRETS_GET_SENSITIVITY, secretsGetOperationDefinition, secretsGetOperationDefinitions;
9325
9654
  var init_secrets_get = __esm({
9326
9655
  "src/operations/secrets-get.ts"() {
9327
9656
  "use strict";
9328
- import_zod9 = require("zod");
9657
+ import_zod11 = require("zod");
9329
9658
  init_cli_name();
9330
9659
  init_errors2();
9331
9660
  init_secret_request();
9332
9661
  init_secrets();
9333
- SecretsGetInputSchema = import_zod9.z.object({
9334
- name: import_zod9.z.string(),
9335
- scope: import_zod9.z.string().optional(),
9336
- space: import_zod9.z.string().optional()
9662
+ SecretsGetInputSchema = import_zod11.z.object({
9663
+ name: import_zod11.z.string(),
9664
+ scope: import_zod11.z.string().optional(),
9665
+ space: import_zod11.z.string().optional()
9337
9666
  }).strict().superRefine((input, context) => {
9338
9667
  try {
9339
9668
  resolveSecretReference(input);
9340
9669
  } catch {
9341
- context.addIssue({ code: import_zod9.z.ZodIssueCode.custom, message: "Invalid secret reference." });
9670
+ context.addIssue({ code: import_zod11.z.ZodIssueCode.custom, message: "Invalid secret reference." });
9342
9671
  }
9343
9672
  }).transform(normalizeSecretsGetInput);
9344
- SecretsGetOutputSchema = import_zod9.z.object({
9345
- value: import_zod9.z.string()
9673
+ SecretsGetOutputSchema = import_zod11.z.object({
9674
+ value: import_zod11.z.string()
9346
9675
  }).strict();
9347
9676
  SECRETS_GET_POSTURES = [
9348
9677
  "owner-openkey",
@@ -9467,11 +9796,11 @@ async function executeSecretsStatus(context, input) {
9467
9796
  }
9468
9797
  };
9469
9798
  }
9470
- var import_zod10, nodeSdk4, PROBE_TIMEOUT_MS, SECRETS_STATUS_DEADLINE_MS, SecretsStatusInputSchema, SecretSetupSchema, SecretsStatusOutputSchema, SECRETS_STATUS_POSTURES, SECRETS_STATUS_EXPOSURE, SECRETS_STATUS_SENSITIVITY, secretsStatusOperationDefinition, secretsStatusOperationDefinitions;
9799
+ var import_zod12, nodeSdk4, PROBE_TIMEOUT_MS, SECRETS_STATUS_DEADLINE_MS, SecretsStatusInputSchema, SecretSetupSchema, SecretsStatusOutputSchema, SECRETS_STATUS_POSTURES, SECRETS_STATUS_EXPOSURE, SECRETS_STATUS_SENSITIVITY, secretsStatusOperationDefinition, secretsStatusOperationDefinitions;
9471
9800
  var init_secrets_status = __esm({
9472
9801
  "src/operations/secrets-status.ts"() {
9473
9802
  "use strict";
9474
- import_zod10 = require("zod");
9803
+ import_zod12 = require("zod");
9475
9804
  nodeSdk4 = __toESM(require("@tinycloud/node-sdk"), 1);
9476
9805
  init_errors2();
9477
9806
  init_kv_failure();
@@ -9480,27 +9809,27 @@ var init_secrets_status = __esm({
9480
9809
  init_secrets();
9481
9810
  PROBE_TIMEOUT_MS = 15e3;
9482
9811
  SECRETS_STATUS_DEADLINE_MS = 18e3;
9483
- SecretsStatusInputSchema = import_zod10.z.object({
9484
- names: import_zod10.z.array(import_zod10.z.string()),
9485
- scope: import_zod10.z.string().optional(),
9486
- owner: import_zod10.z.string().optional()
9812
+ SecretsStatusInputSchema = import_zod12.z.object({
9813
+ names: import_zod12.z.array(import_zod12.z.string()),
9814
+ scope: import_zod12.z.string().optional(),
9815
+ owner: import_zod12.z.string().optional()
9487
9816
  }).strict().superRefine((input, context) => {
9488
9817
  try {
9489
9818
  validSecretNames(input.names);
9490
9819
  } catch {
9491
- context.addIssue({ code: import_zod10.z.ZodIssueCode.custom, path: ["names"], message: "Invalid secret names." });
9820
+ context.addIssue({ code: import_zod12.z.ZodIssueCode.custom, path: ["names"], message: "Invalid secret names." });
9492
9821
  }
9493
9822
  try {
9494
9823
  const scope = canonicalizeSecretScope(input.scope);
9495
9824
  if (scope !== void 0 && !isValidSecretRequestScope(scope)) throw new Error("invalid scope");
9496
9825
  } catch {
9497
- context.addIssue({ code: import_zod10.z.ZodIssueCode.custom, path: ["scope"], message: "Invalid secret scope." });
9826
+ context.addIssue({ code: import_zod12.z.ZodIssueCode.custom, path: ["scope"], message: "Invalid secret scope." });
9498
9827
  }
9499
9828
  if (input.owner !== void 0) {
9500
9829
  try {
9501
9830
  canonicalSecretRequestOwner(input.owner);
9502
9831
  } catch {
9503
- context.addIssue({ code: import_zod10.z.ZodIssueCode.custom, path: ["owner"], message: "Invalid owner." });
9832
+ context.addIssue({ code: import_zod12.z.ZodIssueCode.custom, path: ["owner"], message: "Invalid owner." });
9504
9833
  }
9505
9834
  }
9506
9835
  }).transform((input) => {
@@ -9511,23 +9840,23 @@ var init_secrets_status = __esm({
9511
9840
  ...input.owner === void 0 ? {} : { owner: canonicalSecretRequestOwner(input.owner) }
9512
9841
  };
9513
9842
  });
9514
- SecretSetupSchema = import_zod10.z.object({
9515
- url: import_zod10.z.string().url(),
9516
- names: import_zod10.z.array(import_zod10.z.string()).min(1),
9517
- scope: import_zod10.z.string().optional(),
9518
- owner: import_zod10.z.string(),
9519
- action: import_zod10.z.literal("add_secret")
9843
+ SecretSetupSchema = import_zod12.z.object({
9844
+ url: import_zod12.z.string().url(),
9845
+ names: import_zod12.z.array(import_zod12.z.string()).min(1),
9846
+ scope: import_zod12.z.string().optional(),
9847
+ owner: import_zod12.z.string(),
9848
+ action: import_zod12.z.literal("add_secret")
9520
9849
  }).strict();
9521
- SecretsStatusOutputSchema = import_zod10.z.object({
9522
- status: import_zod10.z.enum(["ready", "pending", "consent_required"]),
9523
- owner: import_zod10.z.string(),
9524
- names: import_zod10.z.array(import_zod10.z.string()).min(1),
9525
- scope: import_zod10.z.string().optional(),
9526
- present: import_zod10.z.array(import_zod10.z.string()),
9527
- pending: import_zod10.z.array(import_zod10.z.string()),
9528
- denied: import_zod10.z.array(import_zod10.z.string()),
9850
+ SecretsStatusOutputSchema = import_zod12.z.object({
9851
+ status: import_zod12.z.enum(["ready", "pending", "consent_required"]),
9852
+ owner: import_zod12.z.string(),
9853
+ names: import_zod12.z.array(import_zod12.z.string()).min(1),
9854
+ scope: import_zod12.z.string().optional(),
9855
+ present: import_zod12.z.array(import_zod12.z.string()),
9856
+ pending: import_zod12.z.array(import_zod12.z.string()),
9857
+ denied: import_zod12.z.array(import_zod12.z.string()),
9529
9858
  setup: SecretSetupSchema.optional(),
9530
- hint: import_zod10.z.string().optional()
9859
+ hint: import_zod12.z.string().optional()
9531
9860
  }).strict();
9532
9861
  SECRETS_STATUS_POSTURES = [
9533
9862
  "owner-openkey",
@@ -9972,35 +10301,35 @@ function profileNotFound(profile) {
9972
10301
  function isRecord5(value) {
9973
10302
  return typeof value === "object" && value !== null && !Array.isArray(value);
9974
10303
  }
9975
- var import_zod11, StatusInputSchema, StatusOutputSchema, STATUS_POSTURES, STATUS_EXPOSURE, STATUS_SENSITIVITY, statusOperationDefinitions;
10304
+ var import_zod13, StatusInputSchema, StatusOutputSchema, STATUS_POSTURES, STATUS_EXPOSURE, STATUS_SENSITIVITY, statusOperationDefinitions;
9976
10305
  var init_status = __esm({
9977
10306
  "src/operations/status.ts"() {
9978
10307
  "use strict";
9979
- import_zod11 = require("zod");
10308
+ import_zod13 = require("zod");
9980
10309
  init_delegation_binding();
9981
10310
  init_errors2();
9982
10311
  init_state();
9983
- StatusInputSchema = import_zod11.z.object({}).strict();
9984
- StatusOutputSchema = import_zod11.z.object({
9985
- profile: import_zod11.z.string().min(1),
9986
- host: import_zod11.z.string().min(1),
9987
- posture: import_zod11.z.enum([
10312
+ StatusInputSchema = import_zod13.z.object({}).strict();
10313
+ StatusOutputSchema = import_zod13.z.object({
10314
+ profile: import_zod13.z.string().min(1),
10315
+ host: import_zod13.z.string().min(1),
10316
+ posture: import_zod13.z.enum([
9988
10317
  "owner-openkey",
9989
10318
  "delegate-session",
9990
10319
  "local-owner-key",
9991
10320
  "unauthenticated"
9992
10321
  ]),
9993
- operatorType: import_zod11.z.enum(["human", "agent"]).optional(),
9994
- principalDid: import_zod11.z.string().min(1).optional(),
9995
- sessionDid: import_zod11.z.string().min(1).optional(),
9996
- ownerDid: import_zod11.z.string().min(1).optional(),
9997
- space: import_zod11.z.string().min(1).optional(),
9998
- session: import_zod11.z.object({
9999
- present: import_zod11.z.boolean(),
10000
- expired: import_zod11.z.boolean().nullable(),
10001
- expiresAt: import_zod11.z.string().datetime({ offset: true }).nullable()
10322
+ operatorType: import_zod13.z.enum(["human", "agent"]).optional(),
10323
+ principalDid: import_zod13.z.string().min(1).optional(),
10324
+ sessionDid: import_zod13.z.string().min(1).optional(),
10325
+ ownerDid: import_zod13.z.string().min(1).optional(),
10326
+ space: import_zod13.z.string().min(1).optional(),
10327
+ session: import_zod13.z.object({
10328
+ present: import_zod13.z.boolean(),
10329
+ expired: import_zod13.z.boolean().nullable(),
10330
+ expiresAt: import_zod13.z.string().datetime({ offset: true }).nullable()
10002
10331
  }).strict(),
10003
- liveAdditionalDelegationCount: import_zod11.z.number().int().nonnegative().describe(
10332
+ liveAdditionalDelegationCount: import_zod13.z.number().int().nonnegative().describe(
10004
10333
  "Stored, unexpired compact-UCAN or signed-login delegations with a valid request binding. Each still requires local proof validation and node activation before it grants authority."
10005
10334
  )
10006
10335
  }).strict();
@@ -10042,6 +10371,8 @@ function registeredOperationDefinitions() {
10042
10371
  operationDefinitions ?? (operationDefinitions = [
10043
10372
  ...statusOperationDefinitions,
10044
10373
  ...authOperationDefinitions,
10374
+ ...readScopeOperationDefinitions,
10375
+ ...readOperationDefinitions,
10045
10376
  ...explorationOperationDefinitions,
10046
10377
  ...appsOperationDefinitions,
10047
10378
  ...sqlOperationDefinitions,
@@ -10080,6 +10411,8 @@ var init_registry = __esm({
10080
10411
  init_auth();
10081
10412
  init_exploration();
10082
10413
  init_knowledge();
10414
+ init_read();
10415
+ init_read_scope();
10083
10416
  init_secrets_get();
10084
10417
  init_secrets_status();
10085
10418
  init_sql();
@@ -10525,10 +10858,10 @@ __export(index_exports, {
10525
10858
  module.exports = __toCommonJS(index_exports);
10526
10859
 
10527
10860
  // src/invoke.ts
10528
- var import_node_crypto3 = require("crypto");
10861
+ var import_node_crypto4 = require("crypto");
10529
10862
  var import_node_path5 = require("path");
10530
10863
  init_cli_name();
10531
- var import_node_sdk2 = require("@tinycloud/node-sdk");
10864
+ var import_node_sdk3 = require("@tinycloud/node-sdk");
10532
10865
  init_jcs();
10533
10866
  init_errors2();
10534
10867
  init_authority();
@@ -11166,7 +11499,7 @@ function operationRetryDescriptor(operation, input, requiresCallerInput = false)
11166
11499
  return {
11167
11500
  operationId: operation.operationId,
11168
11501
  operationVersion: operation.operationVersion,
11169
- inputDigest: (0, import_node_crypto3.createHash)("sha256").update(jcsCanonicalize(input), "utf8").digest("hex"),
11502
+ inputDigest: (0, import_node_crypto4.createHash)("sha256").update(jcsCanonicalize(input), "utf8").digest("hex"),
11170
11503
  requiresCallerInput
11171
11504
  };
11172
11505
  }