@tinycloud/operations 0.1.0-beta.1 → 0.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.
@@ -6528,9 +6528,9 @@ function evaluateAuthority(granted, required) {
6528
6528
  missing: canonicalizeCapabilities(result.missing)
6529
6529
  };
6530
6530
  }
6531
- function evaluateOperationAuthority(granted, required, resolveSpace) {
6532
- const canonicalGranted = canonicalizeOperationCapabilities(granted, resolveSpace);
6533
- const canonicalRequired = canonicalizeOperationCapabilities(required, resolveSpace);
6531
+ function evaluateOperationAuthority(granted, required, resolveSpace2) {
6532
+ const canonicalGranted = canonicalizeOperationCapabilities(granted, resolveSpace2);
6533
+ const canonicalRequired = canonicalizeOperationCapabilities(required, resolveSpace2);
6534
6534
  const missing = [];
6535
6535
  for (const requested of canonicalRequired) {
6536
6536
  const covered = canonicalGranted.some(
@@ -6543,21 +6543,21 @@ function evaluateOperationAuthority(granted, required, resolveSpace) {
6543
6543
  missing: canonicalizeCapabilities(missing)
6544
6544
  };
6545
6545
  }
6546
- function isExactCapabilityMemberSubset(hinted, planned, resolveSpace) {
6547
- const canonicalHinted = canonicalizeOperationCapabilities(hinted, resolveSpace);
6548
- const canonicalPlanned = canonicalizeOperationCapabilities(planned, resolveSpace);
6546
+ function isExactCapabilityMemberSubset(hinted, planned, resolveSpace2) {
6547
+ const canonicalHinted = canonicalizeOperationCapabilities(hinted, resolveSpace2);
6548
+ const canonicalPlanned = canonicalizeOperationCapabilities(planned, resolveSpace2);
6549
6549
  return canonicalHinted.length > 0 && canonicalHinted.every((hint) => canonicalPlanned.some(
6550
6550
  (plan) => JSON.stringify(hint) === JSON.stringify(plan)
6551
6551
  ));
6552
6552
  }
6553
- function canonicalizeOperationCapabilities(permissions, resolveSpace) {
6553
+ function canonicalizeOperationCapabilities(permissions, resolveSpace2) {
6554
6554
  return canonicalizeCapabilities(permissions.map((permission) => {
6555
6555
  const canonicalPath = canonicalizeOperationPath(permission);
6556
- if (permission.space === void 0 || resolveSpace === void 0) {
6556
+ if (permission.space === void 0 || resolveSpace2 === void 0) {
6557
6557
  return canonicalPath;
6558
6558
  }
6559
6559
  try {
6560
- return { ...canonicalPath, space: resolveSpace(permission.space) };
6560
+ return { ...canonicalPath, space: resolveSpace2(permission.space) };
6561
6561
  } catch {
6562
6562
  return canonicalPath;
6563
6563
  }
@@ -6611,7 +6611,7 @@ function isExactPermission(value) {
6611
6611
  if (!isExactRecord(value) || Object.getOwnPropertyNames(value).some((key) => !EXACT_PERMISSION_KEYS.has(key)) || Object.getOwnPropertySymbols(value).length > 0) {
6612
6612
  return false;
6613
6613
  }
6614
- if (!isExactText(value.service) || !isExactPath(value.path) || value.space !== void 0 && !isExactText(value.space) || !Array.isArray(value.actions) || value.actions.length === 0 || !value.actions.every(isExactText) || new Set(value.actions).size !== value.actions.length || value.skipPrefix === true || value.skipPrefix !== void 0 && value.skipPrefix !== false || value.expiry !== void 0 && !isExactText(value.expiry) || value.description !== void 0 && !isExactText(value.description)) {
6614
+ if (!isExactText(value.service) || !isExactPath(value.path, value.actions) || value.space !== void 0 && !isExactText(value.space) || !Array.isArray(value.actions) || value.actions.length === 0 || !value.actions.every(isExactText) || new Set(value.actions).size !== value.actions.length || value.skipPrefix === true || value.skipPrefix !== void 0 && value.skipPrefix !== false || value.expiry !== void 0 && !isExactText(value.expiry) || value.description !== void 0 && !isExactText(value.description)) {
6615
6615
  return false;
6616
6616
  }
6617
6617
  return !("caveats" in value);
@@ -6624,8 +6624,12 @@ function isExactRecord(value) {
6624
6624
  function isExactText(value) {
6625
6625
  return typeof value === "string" && value.length > 0 && !value.includes("*");
6626
6626
  }
6627
- function isExactPath(value) {
6628
- return isExactText(value) && value !== "/" && !value.endsWith("/");
6627
+ function isExactPath(value, actions) {
6628
+ if (typeof value !== "string" || value === "/" || value.includes("*")) return false;
6629
+ if (value === "" || value.endsWith("/")) {
6630
+ return Array.isArray(actions) && actions.includes("tinycloud.kv/list");
6631
+ }
6632
+ return true;
6629
6633
  }
6630
6634
  function canonicalizeCaveats(caveats) {
6631
6635
  return [...caveats].map((caveat) => ({
@@ -7126,8 +7130,8 @@ function permissionRequestArtifactIdentity(record) {
7126
7130
  missing: record.requested
7127
7131
  });
7128
7132
  }
7129
- function evaluateArtifactAuthority(granted, required, resolveSpace) {
7130
- return resolveSpace === void 0 ? evaluateAuthority(granted, required) : evaluateOperationAuthority(granted, required, resolveSpace);
7133
+ function evaluateArtifactAuthority(granted, required, resolveSpace2) {
7134
+ return resolveSpace2 === void 0 ? evaluateAuthority(granted, required) : evaluateOperationAuthority(granted, required, resolveSpace2);
7131
7135
  }
7132
7136
  function defaultRequestId(now) {
7133
7137
  return `req_${now.getTime().toString(36)}_${(0, import_node_crypto2.randomUUID)().replace(/-/g, "")}`;
@@ -7252,7 +7256,7 @@ function operationSpaceResolver(node, ownerSpace) {
7252
7256
  function resolveOperationSpace(space, node, ownerSpace) {
7253
7257
  if (space.startsWith("tinycloud:")) return canonicalizeSpaceUri(space);
7254
7258
  const ownerSpaceId = ownerSpace === void 0 ? void 0 : ownedSpaceForName(ownerSpace, space);
7255
- if (ownerSpaceId !== void 0) return ownerSpaceId;
7259
+ if (ownerSpaceId !== void 0) return canonicalizeSpaceUri(ownerSpaceId);
7256
7260
  const candidate = node;
7257
7261
  try {
7258
7262
  const resolved = candidate.resolveOwnedSpace?.(space);
@@ -7263,7 +7267,7 @@ function resolveOperationSpace(space, node, ownerSpace) {
7263
7267
  }
7264
7268
  if (typeof candidate.spaceId === "string") {
7265
7269
  const resolved = ownedSpaceForName(candidate.spaceId, space);
7266
- if (resolved !== void 0) return resolved;
7270
+ if (resolved !== void 0) return canonicalizeSpaceUri(resolved);
7267
7271
  }
7268
7272
  const did = typeof candidate.did === "string" ? candidate.did : void 0;
7269
7273
  const pkh = did === void 0 ? null : (0, import_node_sdk.parsePkhDid)(did);
@@ -7501,14 +7505,14 @@ async function importRequestBoundDelegation(context, input) {
7501
7505
  );
7502
7506
  }
7503
7507
  const effectivePermissions = canonicalizeCapabilities(activated.effectivePermissions);
7504
- const resolveSpace = operationSpaceResolver(
7508
+ const resolveSpace2 = operationSpaceResolver(
7505
7509
  context.runtime.node,
7506
7510
  context.summary.space
7507
7511
  );
7508
7512
  if (request.requested.length === 0 || !evaluateOperationAuthority(
7509
7513
  request.requested,
7510
7514
  effectivePermissions,
7511
- resolveSpace
7515
+ resolveSpace2
7512
7516
  ).satisfied) {
7513
7517
  return operationFailure(
7514
7518
  "DELEGATION_REJECTED",
@@ -7528,7 +7532,7 @@ async function importRequestBoundDelegation(context, input) {
7528
7532
  result: audienceMismatch(state.sessionDid, sessionDid)
7529
7533
  };
7530
7534
  }
7531
- if (state.request.profile !== context.summary.profile || !samePrincipal(state.request.sessionDid, sessionDid) || normalizeHost(state.request.host) !== normalizeHost(host) || JSON.stringify(canonicalizeOperationCapabilities(state.request.requested, resolveSpace)) !== JSON.stringify(canonicalizeOperationCapabilities(request.requested, resolveSpace))) {
7535
+ if (state.request.profile !== context.summary.profile || !samePrincipal(state.request.sessionDid, sessionDid) || normalizeHost(state.request.host) !== normalizeHost(host) || JSON.stringify(canonicalizeOperationCapabilities(state.request.requested, resolveSpace2)) !== JSON.stringify(canonicalizeOperationCapabilities(request.requested, resolveSpace2))) {
7532
7536
  return {
7533
7537
  records,
7534
7538
  result: operationFailure(
@@ -7806,6 +7810,374 @@ var init_auth = __esm({
7806
7810
  }
7807
7811
  });
7808
7812
 
7813
+ // src/operations/exploration.ts
7814
+ async function planAccountRegistryRead(context, path) {
7815
+ return [{
7816
+ service: "tinycloud.kv",
7817
+ space: resolveSpace(context, "account"),
7818
+ path,
7819
+ actions: ["tinycloud.kv/get", "tinycloud.kv/list"]
7820
+ }];
7821
+ }
7822
+ async function planKvList(context, input) {
7823
+ const space = resolveNonSecretSpace(context, input.space);
7824
+ return [{
7825
+ service: "tinycloud.kv",
7826
+ space,
7827
+ path: input.prefix ?? "",
7828
+ actions: ["tinycloud.kv/list"]
7829
+ }];
7830
+ }
7831
+ async function planKvGet(context, input) {
7832
+ const space = resolveNonSecretSpace(context, input.space);
7833
+ return [{
7834
+ service: "tinycloud.kv",
7835
+ space,
7836
+ path: input.key,
7837
+ actions: ["tinycloud.kv/get"]
7838
+ }];
7839
+ }
7840
+ async function executeAccountSpacesList(context, _input) {
7841
+ try {
7842
+ const entries = await readAccountRegistry(context, "spaces/");
7843
+ if (!entries.ok) return nodeFailure("list account spaces");
7844
+ const spaces = entries.records.map(({ key, value }) => projectAccountSpace(key, value)).sort((left, right) => left.name.localeCompare(right.name) || left.spaceId.localeCompare(right.spaceId));
7845
+ return { status: "ok", output: { spaces, count: spaces.length } };
7846
+ } catch {
7847
+ return nodeFailure("list account spaces");
7848
+ }
7849
+ }
7850
+ async function executeAccountApplicationsList(context, _input) {
7851
+ try {
7852
+ const entries = await readAccountRegistry(context, "applications/");
7853
+ if (!entries.ok) return nodeFailure("list account applications");
7854
+ const applications = entries.records.map(({ key, value }) => projectAccountApplication(key, value)).sort((left, right) => left.appId.localeCompare(right.appId));
7855
+ return { status: "ok", output: { applications, count: applications.length } };
7856
+ } catch {
7857
+ return nodeFailure("list account applications");
7858
+ }
7859
+ }
7860
+ async function executeKvList(context, input) {
7861
+ try {
7862
+ const runtime = runtimeContext(context);
7863
+ const space = resolveNonSecretSpace(runtime, input.space);
7864
+ const result = await runtimeNode(runtime).kvForSpace(space).list(
7865
+ input.prefix === void 0 ? void 0 : { prefix: input.prefix }
7866
+ );
7867
+ if (!result.ok) return nodeFailure("list KV keys");
7868
+ const keys = [...result.data.keys];
7869
+ return {
7870
+ status: "ok",
7871
+ output: { space, prefix: input.prefix ?? "", keys, count: keys.length }
7872
+ };
7873
+ } catch (error) {
7874
+ if (error instanceof OperationInvocationError) {
7875
+ return { status: "error", error: error.operationError };
7876
+ }
7877
+ return nodeFailure("list KV keys");
7878
+ }
7879
+ }
7880
+ async function executeKvGet(context, input) {
7881
+ try {
7882
+ const runtime = runtimeContext(context);
7883
+ const space = resolveNonSecretSpace(runtime, input.space);
7884
+ const result = await runtimeNode(runtime).kvForSpace(space).get(input.key);
7885
+ if (!result.ok) return nodeFailure("read the KV value");
7886
+ const encoded = encodeKvValue(result.data.data);
7887
+ return {
7888
+ status: "ok",
7889
+ output: {
7890
+ space,
7891
+ key: input.key,
7892
+ value: encoded.value,
7893
+ encoding: encoded.encoding,
7894
+ metadata: {
7895
+ ...result.data.headers.etag === void 0 ? {} : { etag: result.data.headers.etag },
7896
+ ...result.data.headers.contentType === void 0 ? {} : { contentType: result.data.headers.contentType },
7897
+ ...result.data.headers.lastModified === void 0 ? {} : { lastModified: result.data.headers.lastModified },
7898
+ ...result.data.headers.contentLength === void 0 ? {} : { contentLength: result.data.headers.contentLength }
7899
+ }
7900
+ }
7901
+ };
7902
+ } catch (error) {
7903
+ if (error instanceof OperationInvocationError) {
7904
+ return { status: "error", error: error.operationError };
7905
+ }
7906
+ return nodeFailure("read the KV value");
7907
+ }
7908
+ }
7909
+ function runtimeContext(context) {
7910
+ if (context.runtime === void 0) {
7911
+ throw new TypeError("Authenticated operation runtime is unavailable.");
7912
+ }
7913
+ return context;
7914
+ }
7915
+ function runtimeNode(context) {
7916
+ return runtimeContext(context).runtime.node;
7917
+ }
7918
+ function resolveSpace(context, space) {
7919
+ return operationSpaceResolver(context.runtime.node, context.summary.space)(space);
7920
+ }
7921
+ function resolveNonSecretSpace(context, space) {
7922
+ const resolved = resolveSpace(context, space);
7923
+ if (resolved.split(":").at(-1)?.toLowerCase() === "secrets") {
7924
+ throw new OperationInvocationError(operationError(
7925
+ "INPUT_INVALID",
7926
+ "Generic KV operations cannot access the TinyCloud secrets space; use tinycloud.secrets.get."
7927
+ ));
7928
+ }
7929
+ return resolved;
7930
+ }
7931
+ async function readAccountRegistry(context, prefix) {
7932
+ const runtime = runtimeContext(context);
7933
+ const accountSpace = resolveSpace(runtime, "account");
7934
+ const kv = runtimeNode(runtime).kvForSpace(accountSpace);
7935
+ const listed = await kv.list({ prefix });
7936
+ if (!listed.ok) return { ok: false };
7937
+ const records = [];
7938
+ for (const key of listed.data.keys) {
7939
+ const loaded = await kv.get(key);
7940
+ if (!loaded.ok || !isRecord2(loaded.data.data)) return { ok: false };
7941
+ records.push({ key, value: loaded.data.data });
7942
+ }
7943
+ return { ok: true, records };
7944
+ }
7945
+ function projectAccountSpace(key, record) {
7946
+ const suffix = key.startsWith("spaces/") ? key.slice("spaces/".length) : key;
7947
+ const rawSpaceId = stringField2(record, "space_id", "spaceId") ?? suffix;
7948
+ const rawName = stringField2(record, "name") ?? rawSpaceId.split(":").at(-1) ?? rawSpaceId;
7949
+ const rawType = stringField2(record, "type");
7950
+ const rawStatus = stringField2(record, "status");
7951
+ const rawExpiresAt = record.expires_at ?? record.expiresAt;
7952
+ const expiresAt = rawExpiresAt instanceof Date ? rawExpiresAt.toISOString() : typeof rawExpiresAt === "string" && !Number.isNaN(new Date(rawExpiresAt).getTime()) ? new Date(rawExpiresAt).toISOString() : void 0;
7953
+ return {
7954
+ spaceId: rawSpaceId,
7955
+ name: rawName,
7956
+ ownerDid: stringField2(record, "owner_did", "ownerDid", "owner") ?? "",
7957
+ type: rawType === "owned" || rawType === "delegated" ? rawType : "discovered",
7958
+ permissions: Array.isArray(record.permissions) ? record.permissions.filter((value) => typeof value === "string") : [],
7959
+ status: rawStatus === "archived" ? "archived" : "active",
7960
+ ...stringField2(record, "registered_at", "registeredAt") === void 0 ? {} : { registeredAt: stringField2(record, "registered_at", "registeredAt") },
7961
+ ...stringField2(record, "updated_at", "updatedAt") === void 0 ? {} : { updatedAt: stringField2(record, "updated_at", "updatedAt") },
7962
+ ...expiresAt === void 0 ? {} : { expiresAt }
7963
+ };
7964
+ }
7965
+ function projectAccountApplication(key, record) {
7966
+ const manifests = Array.isArray(record.manifests) ? record.manifests.filter(isRecord2) : [];
7967
+ const first = manifests[0];
7968
+ return {
7969
+ appId: stringField2(record, "app_id", "appId") ?? stringField2(first, "app_id") ?? (key.startsWith("applications/") ? key.slice("applications/".length) : key),
7970
+ manifests,
7971
+ ...stringField2(record, "updated_at", "updatedAt") === void 0 ? {} : { updatedAt: stringField2(record, "updated_at", "updatedAt") },
7972
+ ...stringField2(first, "name") === void 0 ? {} : { name: stringField2(first, "name") },
7973
+ ...stringField2(first, "description") === void 0 ? {} : { description: stringField2(first, "description") },
7974
+ ...stringField2(record, "manifest_hash", "manifestHash") === void 0 ? {} : { manifestHash: stringField2(record, "manifest_hash", "manifestHash") }
7975
+ };
7976
+ }
7977
+ function stringField2(record, ...keys) {
7978
+ if (record === void 0) return void 0;
7979
+ for (const key of keys) {
7980
+ if (typeof record[key] === "string") return record[key];
7981
+ }
7982
+ return void 0;
7983
+ }
7984
+ function isRecord2(value) {
7985
+ return typeof value === "object" && value !== null && !Array.isArray(value);
7986
+ }
7987
+ function encodeKvValue(value) {
7988
+ if (value instanceof Uint8Array) {
7989
+ return { value: Buffer.from(value).toString("base64"), encoding: "base64" };
7990
+ }
7991
+ return {
7992
+ value,
7993
+ encoding: typeof value === "string" ? "text" : "json"
7994
+ };
7995
+ }
7996
+ function nodeFailure(action) {
7997
+ return {
7998
+ status: "error",
7999
+ error: operationError(
8000
+ "NODE_ERROR",
8001
+ `The TinyCloud node could not ${action}.`,
8002
+ { retryable: true }
8003
+ )
8004
+ };
8005
+ }
8006
+ var import_zod4, EmptyInputSchema2, SpaceSchema, PrefixSchema, KeySchema, AccountSpaceSchema, AccountSpacesOutputSchema, AccountApplicationSchema, AccountApplicationsOutputSchema, KvListInputSchema, KvListOutputSchema, KvGetInputSchema, KvGetOutputSchema, AUTHENTICATED_POSTURES, EXPLORATION_EXPOSURE, ACCOUNT_SPACES_SENSITIVITY, ACCOUNT_APPLICATIONS_SENSITIVITY, KV_LIST_SENSITIVITY, KV_GET_SENSITIVITY, explorationOperationDefinitions;
8007
+ var init_exploration = __esm({
8008
+ "src/operations/exploration.ts"() {
8009
+ "use strict";
8010
+ import_zod4 = require("zod");
8011
+ init_errors();
8012
+ init_secrets();
8013
+ EmptyInputSchema2 = import_zod4.z.object({}).strict();
8014
+ SpaceSchema = import_zod4.z.string().min(1).refine(
8015
+ (space) => (/^[A-Za-z0-9_-]+$/.test(space) || space.startsWith("tinycloud:")) && !space.includes("*"),
8016
+ "Invalid TinyCloud space."
8017
+ );
8018
+ PrefixSchema = import_zod4.z.string().refine(
8019
+ (prefix) => prefix !== "/" && !prefix.includes("*"),
8020
+ "Invalid KV prefix."
8021
+ );
8022
+ KeySchema = import_zod4.z.string().min(1).refine(
8023
+ (key) => key !== "/" && !key.endsWith("/") && !key.includes("*"),
8024
+ "Invalid KV key."
8025
+ );
8026
+ AccountSpaceSchema = import_zod4.z.object({
8027
+ spaceId: import_zod4.z.string().min(1),
8028
+ name: import_zod4.z.string().min(1),
8029
+ ownerDid: import_zod4.z.string(),
8030
+ type: import_zod4.z.enum(["owned", "delegated", "discovered"]),
8031
+ permissions: import_zod4.z.array(import_zod4.z.string()),
8032
+ status: import_zod4.z.enum(["active", "archived"]),
8033
+ registeredAt: import_zod4.z.string().optional(),
8034
+ updatedAt: import_zod4.z.string().optional(),
8035
+ expiresAt: import_zod4.z.string().datetime({ offset: true }).optional()
8036
+ }).strict();
8037
+ AccountSpacesOutputSchema = import_zod4.z.object({
8038
+ spaces: import_zod4.z.array(AccountSpaceSchema),
8039
+ count: import_zod4.z.number().int().nonnegative()
8040
+ }).strict();
8041
+ AccountApplicationSchema = import_zod4.z.object({
8042
+ appId: import_zod4.z.string().min(1),
8043
+ manifests: import_zod4.z.array(import_zod4.z.record(import_zod4.z.unknown())),
8044
+ updatedAt: import_zod4.z.string().optional(),
8045
+ name: import_zod4.z.string().optional(),
8046
+ description: import_zod4.z.string().optional(),
8047
+ manifestHash: import_zod4.z.string().optional()
8048
+ }).strict();
8049
+ AccountApplicationsOutputSchema = import_zod4.z.object({
8050
+ applications: import_zod4.z.array(AccountApplicationSchema),
8051
+ count: import_zod4.z.number().int().nonnegative()
8052
+ }).strict();
8053
+ KvListInputSchema = import_zod4.z.object({
8054
+ space: SpaceSchema,
8055
+ prefix: PrefixSchema.optional()
8056
+ }).strict();
8057
+ KvListOutputSchema = import_zod4.z.object({
8058
+ space: import_zod4.z.string().min(1),
8059
+ prefix: import_zod4.z.string(),
8060
+ keys: import_zod4.z.array(import_zod4.z.string()),
8061
+ count: import_zod4.z.number().int().nonnegative()
8062
+ }).strict();
8063
+ KvGetInputSchema = import_zod4.z.object({
8064
+ space: SpaceSchema,
8065
+ key: KeySchema
8066
+ }).strict();
8067
+ KvGetOutputSchema = import_zod4.z.object({
8068
+ space: import_zod4.z.string().min(1),
8069
+ key: import_zod4.z.string().min(1),
8070
+ value: import_zod4.z.union([
8071
+ import_zod4.z.string(),
8072
+ import_zod4.z.number(),
8073
+ import_zod4.z.boolean(),
8074
+ import_zod4.z.null(),
8075
+ import_zod4.z.array(import_zod4.z.unknown()),
8076
+ import_zod4.z.record(import_zod4.z.unknown())
8077
+ ]),
8078
+ encoding: import_zod4.z.enum(["json", "text", "base64"]),
8079
+ metadata: import_zod4.z.object({
8080
+ etag: import_zod4.z.string().optional(),
8081
+ contentType: import_zod4.z.string().optional(),
8082
+ lastModified: import_zod4.z.string().optional(),
8083
+ contentLength: import_zod4.z.number().int().nonnegative().optional()
8084
+ }).strict()
8085
+ }).strict();
8086
+ AUTHENTICATED_POSTURES = [
8087
+ "owner-openkey",
8088
+ "delegate-session",
8089
+ "local-owner-key"
8090
+ ];
8091
+ EXPLORATION_EXPOSURE = {
8092
+ cli: {
8093
+ status: "excluded",
8094
+ reason: "Existing account and KV Commander commands remain the CLI surface."
8095
+ },
8096
+ mcp: { status: "required" },
8097
+ skill: { status: "required" },
8098
+ docs: { status: "required" }
8099
+ };
8100
+ ACCOUNT_SPACES_SENSITIVITY = {
8101
+ input: [],
8102
+ output: ["/spaces"]
8103
+ };
8104
+ ACCOUNT_APPLICATIONS_SENSITIVITY = {
8105
+ input: [],
8106
+ output: ["/applications"]
8107
+ };
8108
+ KV_LIST_SENSITIVITY = {
8109
+ input: ["/prefix"],
8110
+ output: ["/keys"]
8111
+ };
8112
+ KV_GET_SENSITIVITY = {
8113
+ input: ["/key"],
8114
+ output: ["/value"]
8115
+ };
8116
+ explorationOperationDefinitions = [
8117
+ {
8118
+ id: "tinycloud.account.spaces.list",
8119
+ version: 1,
8120
+ title: "List TinyCloud account spaces",
8121
+ description: "List the spaces registered in the selected owner's TinyCloud account.",
8122
+ input: EmptyInputSchema2,
8123
+ output: AccountSpacesOutputSchema,
8124
+ effects: ["read"],
8125
+ runtime: "authenticated",
8126
+ postures: AUTHENTICATED_POSTURES,
8127
+ exposure: EXPLORATION_EXPOSURE,
8128
+ sensitivity: ACCOUNT_SPACES_SENSITIVITY,
8129
+ authority: (context) => planAccountRegistryRead(context, "spaces/"),
8130
+ execute: executeAccountSpacesList
8131
+ },
8132
+ {
8133
+ id: "tinycloud.account.applications.list",
8134
+ version: 1,
8135
+ title: "List TinyCloud account applications",
8136
+ description: "List the application manifests registered in the selected owner's TinyCloud account.",
8137
+ input: EmptyInputSchema2,
8138
+ output: AccountApplicationsOutputSchema,
8139
+ effects: ["read"],
8140
+ runtime: "authenticated",
8141
+ postures: AUTHENTICATED_POSTURES,
8142
+ exposure: EXPLORATION_EXPOSURE,
8143
+ sensitivity: ACCOUNT_APPLICATIONS_SENSITIVITY,
8144
+ authority: (context) => planAccountRegistryRead(context, "applications/"),
8145
+ execute: executeAccountApplicationsList
8146
+ },
8147
+ {
8148
+ id: "tinycloud.kv.list",
8149
+ version: 1,
8150
+ title: "List TinyCloud KV keys",
8151
+ description: "List keys at one exact prefix in a delegated TinyCloud space.",
8152
+ input: KvListInputSchema,
8153
+ output: KvListOutputSchema,
8154
+ effects: ["read"],
8155
+ runtime: "authenticated",
8156
+ postures: AUTHENTICATED_POSTURES,
8157
+ exposure: EXPLORATION_EXPOSURE,
8158
+ sensitivity: KV_LIST_SENSITIVITY,
8159
+ authority: planKvList,
8160
+ execute: executeKvList
8161
+ },
8162
+ {
8163
+ id: "tinycloud.kv.get",
8164
+ version: 1,
8165
+ title: "Get a TinyCloud KV value",
8166
+ description: "Read one exact key from a delegated non-secrets TinyCloud space.",
8167
+ input: KvGetInputSchema,
8168
+ output: KvGetOutputSchema,
8169
+ effects: ["read"],
8170
+ runtime: "authenticated",
8171
+ postures: AUTHENTICATED_POSTURES,
8172
+ exposure: EXPLORATION_EXPOSURE,
8173
+ sensitivity: KV_GET_SENSITIVITY,
8174
+ authority: planKvGet,
8175
+ execute: executeKvGet
8176
+ }
8177
+ ];
8178
+ }
8179
+ });
8180
+
7809
8181
  // src/operations/secrets-get.ts
7810
8182
  async function planSecretGet(context, input) {
7811
8183
  const reference = resolveSecretReferenceForOperation(
@@ -7958,26 +8330,26 @@ function resolveEncryptionNetworkId(node, space) {
7958
8330
  )
7959
8331
  );
7960
8332
  }
7961
- var import_zod4, SecretsGetInputSchema, SecretsGetOutputSchema, SECRETS_GET_POSTURES, SECRETS_GET_EXPOSURE, SECRETS_GET_SENSITIVITY, secretsGetOperationDefinition, secretsGetOperationDefinitions;
8333
+ var import_zod5, SecretsGetInputSchema, SecretsGetOutputSchema, SECRETS_GET_POSTURES, SECRETS_GET_EXPOSURE, SECRETS_GET_SENSITIVITY, secretsGetOperationDefinition, secretsGetOperationDefinitions;
7962
8334
  var init_secrets_get = __esm({
7963
8335
  "src/operations/secrets-get.ts"() {
7964
8336
  "use strict";
7965
- import_zod4 = require("zod");
8337
+ import_zod5 = require("zod");
7966
8338
  init_errors();
7967
8339
  init_secrets();
7968
- SecretsGetInputSchema = import_zod4.z.object({
7969
- name: import_zod4.z.string(),
7970
- scope: import_zod4.z.string().optional(),
7971
- space: import_zod4.z.string().optional()
8340
+ SecretsGetInputSchema = import_zod5.z.object({
8341
+ name: import_zod5.z.string(),
8342
+ scope: import_zod5.z.string().optional(),
8343
+ space: import_zod5.z.string().optional()
7972
8344
  }).strict().superRefine((input, context) => {
7973
8345
  try {
7974
8346
  resolveSecretReference(input);
7975
8347
  } catch {
7976
- context.addIssue({ code: import_zod4.z.ZodIssueCode.custom, message: "Invalid secret reference." });
8348
+ context.addIssue({ code: import_zod5.z.ZodIssueCode.custom, message: "Invalid secret reference." });
7977
8349
  }
7978
8350
  }).transform(normalizeSecretsGetInput);
7979
- SecretsGetOutputSchema = import_zod4.z.object({
7980
- value: import_zod4.z.string()
8351
+ SecretsGetOutputSchema = import_zod5.z.object({
8352
+ value: import_zod5.z.string()
7981
8353
  }).strict();
7982
8354
  SECRETS_GET_POSTURES = [
7983
8355
  "owner-openkey",
@@ -8070,7 +8442,7 @@ async function inspectPinnedProfileStatus(context, _input) {
8070
8442
  async function pinnedProfileExists(profile) {
8071
8443
  try {
8072
8444
  const storedProfile = await readProfile(profile);
8073
- return isRecord2(storedProfile);
8445
+ return isRecord3(storedProfile);
8074
8446
  } catch {
8075
8447
  return false;
8076
8448
  }
@@ -8090,7 +8462,7 @@ async function countLiveAdditionalDelegations(profile) {
8090
8462
  }
8091
8463
  function summarizeSession(session) {
8092
8464
  if (session === null) return { present: false, expired: null, expiresAt: null };
8093
- if (!isRecord2(session)) throw new TypeError("Invalid session store.");
8465
+ if (!isRecord3(session)) throw new TypeError("Invalid session store.");
8094
8466
  const expiry = extractSessionExpiry(session);
8095
8467
  if (expiry === null) return { present: true, expired: null, expiresAt: null };
8096
8468
  return {
@@ -8100,7 +8472,7 @@ function summarizeSession(session) {
8100
8472
  };
8101
8473
  }
8102
8474
  function storedDelegationExpiry(entry) {
8103
- if (!isRecord2(entry) || !isRecord2(entry.delegation) || !("expiry" in entry.delegation)) {
8475
+ if (!isRecord3(entry) || !isRecord3(entry.delegation) || !("expiry" in entry.delegation)) {
8104
8476
  throw new TypeError("Invalid stored delegation.");
8105
8477
  }
8106
8478
  return parseExpiry(entry.delegation.expiry);
@@ -8129,37 +8501,37 @@ function profileNotFound(profile) {
8129
8501
  )
8130
8502
  };
8131
8503
  }
8132
- function isRecord2(value) {
8504
+ function isRecord3(value) {
8133
8505
  return typeof value === "object" && value !== null && !Array.isArray(value);
8134
8506
  }
8135
- var import_zod5, StatusInputSchema, StatusOutputSchema, STATUS_POSTURES, STATUS_EXPOSURE, STATUS_SENSITIVITY, statusOperationDefinitions;
8507
+ var import_zod6, StatusInputSchema, StatusOutputSchema, STATUS_POSTURES, STATUS_EXPOSURE, STATUS_SENSITIVITY, statusOperationDefinitions;
8136
8508
  var init_status = __esm({
8137
8509
  "src/operations/status.ts"() {
8138
8510
  "use strict";
8139
- import_zod5 = require("zod");
8511
+ import_zod6 = require("zod");
8140
8512
  init_errors();
8141
8513
  init_state();
8142
- StatusInputSchema = import_zod5.z.object({}).strict();
8143
- StatusOutputSchema = import_zod5.z.object({
8144
- profile: import_zod5.z.string().min(1),
8145
- host: import_zod5.z.string().min(1),
8146
- posture: import_zod5.z.enum([
8514
+ StatusInputSchema = import_zod6.z.object({}).strict();
8515
+ StatusOutputSchema = import_zod6.z.object({
8516
+ profile: import_zod6.z.string().min(1),
8517
+ host: import_zod6.z.string().min(1),
8518
+ posture: import_zod6.z.enum([
8147
8519
  "owner-openkey",
8148
8520
  "delegate-session",
8149
8521
  "local-owner-key",
8150
8522
  "unauthenticated"
8151
8523
  ]),
8152
- operatorType: import_zod5.z.enum(["human", "agent"]).optional(),
8153
- principalDid: import_zod5.z.string().min(1).optional(),
8154
- sessionDid: import_zod5.z.string().min(1).optional(),
8155
- ownerDid: import_zod5.z.string().min(1).optional(),
8156
- space: import_zod5.z.string().min(1).optional(),
8157
- session: import_zod5.z.object({
8158
- present: import_zod5.z.boolean(),
8159
- expired: import_zod5.z.boolean().nullable(),
8160
- expiresAt: import_zod5.z.string().datetime({ offset: true }).nullable()
8524
+ operatorType: import_zod6.z.enum(["human", "agent"]).optional(),
8525
+ principalDid: import_zod6.z.string().min(1).optional(),
8526
+ sessionDid: import_zod6.z.string().min(1).optional(),
8527
+ ownerDid: import_zod6.z.string().min(1).optional(),
8528
+ space: import_zod6.z.string().min(1).optional(),
8529
+ session: import_zod6.z.object({
8530
+ present: import_zod6.z.boolean(),
8531
+ expired: import_zod6.z.boolean().nullable(),
8532
+ expiresAt: import_zod6.z.string().datetime({ offset: true }).nullable()
8161
8533
  }).strict(),
8162
- liveAdditionalDelegationCount: import_zod5.z.number().int().nonnegative()
8534
+ liveAdditionalDelegationCount: import_zod6.z.number().int().nonnegative()
8163
8535
  }).strict();
8164
8536
  STATUS_POSTURES = [
8165
8537
  "owner-openkey",
@@ -8199,6 +8571,7 @@ function registeredOperationDefinitions() {
8199
8571
  operationDefinitions ?? (operationDefinitions = [
8200
8572
  ...statusOperationDefinitions,
8201
8573
  ...authOperationDefinitions,
8574
+ ...explorationOperationDefinitions,
8202
8575
  ...secretsGetOperationDefinitions
8203
8576
  ]);
8204
8577
  return operationDefinitions;
@@ -8229,6 +8602,7 @@ var init_registry = __esm({
8229
8602
  "src/registry.ts"() {
8230
8603
  "use strict";
8231
8604
  init_auth();
8605
+ init_exploration();
8232
8606
  init_secrets_get();
8233
8607
  init_status();
8234
8608
  }
@@ -8309,9 +8683,9 @@ function isOperatorType(value) {
8309
8683
  return value === "human" || value === "agent";
8310
8684
  }
8311
8685
  function isStoredProfile(value) {
8312
- return isRecord3(value) && isNonEmptyString(value.name) && isNonEmptyString(value.host) && typeof value.chainId === "number" && Number.isFinite(value.chainId) && isNonEmptyString(value.spaceName) && isNonEmptyString(value.did) && isNonEmptyString(value.createdAt) && isOptionalNonEmptyString(value.sessionDid) && isOptionalNonEmptyString(value.ownerDid) && isOptionalNonEmptyString(value.spaceId) && isOptionalPosture(value.posture) && isOptionalOperatorType(value.operatorType) && isOptionalAuthMethod(value.authMethod) && isOptionalNonEmptyString(value.defaultSpace) && isOptionalNonEmptyString(value.privateKey) && isOptionalNonEmptyString(value.address) && isOptionalNonEmptyString(value.openkeyHost);
8686
+ return isRecord4(value) && isNonEmptyString(value.name) && isNonEmptyString(value.host) && typeof value.chainId === "number" && Number.isFinite(value.chainId) && isNonEmptyString(value.spaceName) && isNonEmptyString(value.did) && isNonEmptyString(value.createdAt) && isOptionalNonEmptyString(value.sessionDid) && isOptionalNonEmptyString(value.ownerDid) && isOptionalNonEmptyString(value.spaceId) && isOptionalPosture(value.posture) && isOptionalOperatorType(value.operatorType) && isOptionalAuthMethod(value.authMethod) && isOptionalNonEmptyString(value.defaultSpace) && isOptionalNonEmptyString(value.privateKey) && isOptionalNonEmptyString(value.address) && isOptionalNonEmptyString(value.openkeyHost);
8313
8687
  }
8314
- function isRecord3(value) {
8688
+ function isRecord4(value) {
8315
8689
  return typeof value === "object" && value !== null && !Array.isArray(value);
8316
8690
  }
8317
8691
  function isNonEmptyString(value) {
@@ -8475,7 +8849,7 @@ function spaceForAuthenticatedPrincipal(principal2) {
8475
8849
  function normalizeSession(session, key) {
8476
8850
  const header = session.delegationHeader;
8477
8851
  const jwk = hasPrivateParameter(session.jwk) ? session.jwk : key;
8478
- if (!isRecord4(header) || typeof header.Authorization !== "string" || typeof session.delegationCid !== "string" || typeof session.spaceId !== "string" || !hasPrivateParameter(jwk) || typeof session.verificationMethod !== "string") {
8852
+ if (!isRecord5(header) || typeof header.Authorization !== "string" || typeof session.delegationCid !== "string" || typeof session.spaceId !== "string" || !hasPrivateParameter(jwk) || typeof session.verificationMethod !== "string") {
8479
8853
  return void 0;
8480
8854
  }
8481
8855
  return {
@@ -8493,7 +8867,7 @@ function normalizeSession(session, key) {
8493
8867
  }
8494
8868
  function normalizeStoredDelegation(entry) {
8495
8869
  const raw = entry.delegation;
8496
- if (!isRecord4(raw) || !isRecord4(raw.delegationHeader)) return void 0;
8870
+ if (!isRecord5(raw) || !isRecord5(raw.delegationHeader)) return void 0;
8497
8871
  const expiry = parseExpiry2(raw.expiry);
8498
8872
  if (expiry === void 0 || typeof raw.cid !== "string" || typeof raw.spaceId !== "string" || typeof raw.path !== "string" || !Array.isArray(raw.actions) || !raw.actions.every((action) => typeof action === "string") || typeof raw.delegateDID !== "string" || typeof raw.ownerAddress !== "string" || typeof raw.chainId !== "number" || typeof raw.delegationHeader.Authorization !== "string") {
8499
8873
  return void 0;
@@ -8505,13 +8879,13 @@ function parseExpiry2(value) {
8505
8879
  return expiry !== void 0 && !Number.isNaN(expiry.getTime()) ? expiry : void 0;
8506
8880
  }
8507
8881
  function hasPrivateParameter(value) {
8508
- return isRecord4(value) && typeof value.d === "string" && value.d.length > 0;
8882
+ return isRecord5(value) && typeof value.d === "string" && value.d.length > 0;
8509
8883
  }
8510
8884
  function normalizeDid(value) {
8511
8885
  if (typeof value !== "string" || value.length === 0) return void 0;
8512
8886
  return value.split("#", 1)[0];
8513
8887
  }
8514
- function isRecord4(value) {
8888
+ function isRecord5(value) {
8515
8889
  return typeof value === "object" && value !== null && !Array.isArray(value);
8516
8890
  }
8517
8891
  function failed(context, error) {
@@ -8921,9 +9295,9 @@ async function invokeOperationWithLocalAuthorityRetry(operationId, operationVers
8921
9295
  )
8922
9296
  );
8923
9297
  }
8924
- const runtimeContext = prepared.runtimeResolution.context;
8925
- if (runtimeContext.runtime === void 0) return internalOperationErrorResult(prepared);
8926
- const operationContext = runtimeContext;
9298
+ const runtimeContext2 = prepared.runtimeResolution.context;
9299
+ if (runtimeContext2.runtime === void 0) return internalOperationErrorResult(prepared);
9300
+ const operationContext = runtimeContext2;
8927
9301
  let planned;
8928
9302
  try {
8929
9303
  planned = exactCapabilities2(await prepared.definition.authority(
@@ -8980,7 +9354,7 @@ async function invokeOperationWithLocalAuthorityRetry(operationId, operationVers
8980
9354
  operationContext.runtime.node,
8981
9355
  first.missing
8982
9356
  );
8983
- const resolveSpace = operationSpaceResolver(
9357
+ const resolveSpace2 = operationSpaceResolver(
8984
9358
  operationContext.runtime.node,
8985
9359
  operationContext.summary.space
8986
9360
  );
@@ -8988,7 +9362,7 @@ async function invokeOperationWithLocalAuthorityRetry(operationId, operationVers
8988
9362
  operationContext.runtime.node,
8989
9363
  first.missing,
8990
9364
  planned,
8991
- resolveSpace
9365
+ resolveSpace2
8992
9366
  );
8993
9367
  if (refreshedGranted === void 0) {
8994
9368
  return localAuthorityFailure(prepared);
@@ -9128,14 +9502,14 @@ async function prepareInvocation(operationId, operationVersion, invocationTarget
9128
9502
  }
9129
9503
  async function executePreparedInvocation(prepared, options = {}) {
9130
9504
  const { operation, definition, parsedInput, runtimeResolution } = prepared;
9131
- const runtimeContext = runtimeResolution.context.runtime === void 0 ? void 0 : runtimeResolution.context;
9132
- const resolveSpace = runtimeContext === void 0 ? void 0 : operationSpaceResolver(
9133
- runtimeContext.runtime.node,
9134
- runtimeContext.summary.space
9505
+ const runtimeContext2 = runtimeResolution.context.runtime === void 0 ? void 0 : runtimeResolution.context;
9506
+ const resolveSpace2 = runtimeContext2 === void 0 ? void 0 : operationSpaceResolver(
9507
+ runtimeContext2.runtime.node,
9508
+ runtimeContext2.summary.space
9135
9509
  );
9136
9510
  try {
9137
9511
  const planned = await definition.authority(
9138
- runtimeContext ?? runtimeResolution.context,
9512
+ runtimeContext2 ?? runtimeResolution.context,
9139
9513
  parsedInput.data
9140
9514
  );
9141
9515
  const required = exactCapabilities2(planned);
@@ -9150,12 +9524,12 @@ async function executePreparedInvocation(prepared, options = {}) {
9150
9524
  );
9151
9525
  }
9152
9526
  const evaluation = evaluateOperationAuthority(
9153
- runtimeContext?.runtime.granted ?? [],
9527
+ runtimeContext2?.runtime.granted ?? [],
9154
9528
  required,
9155
- resolveSpace
9529
+ resolveSpace2
9156
9530
  );
9157
9531
  if (!evaluation.satisfied) {
9158
- if (runtimeContext === void 0) {
9532
+ if (runtimeContext2 === void 0) {
9159
9533
  return errorResult(
9160
9534
  operation,
9161
9535
  runtimeResolution.context.summary,
@@ -9165,13 +9539,13 @@ async function executePreparedInvocation(prepared, options = {}) {
9165
9539
  if (options.deferAuthorityRequest) {
9166
9540
  try {
9167
9541
  const request = buildPermissionRequestArtifact({
9168
- profile: runtimeContext.summary.profile,
9169
- host: runtimeContext.summary.host,
9170
- sessionDid: runtimeContext.summary.sessionDid,
9171
- posture: runtimeContext.summary.posture,
9172
- operatorType: runtimeContext.summary.operatorType ?? "human",
9173
- ...runtimeContext.summary.ownerDid === void 0 ? {} : { ownerDid: runtimeContext.summary.ownerDid },
9174
- ...runtimeContext.summary.space === void 0 ? {} : { spaceId: runtimeContext.summary.space },
9542
+ profile: runtimeContext2.summary.profile,
9543
+ host: runtimeContext2.summary.host,
9544
+ sessionDid: runtimeContext2.summary.sessionDid,
9545
+ posture: runtimeContext2.summary.posture,
9546
+ operatorType: runtimeContext2.summary.operatorType ?? "human",
9547
+ ...runtimeContext2.summary.ownerDid === void 0 ? {} : { ownerDid: runtimeContext2.summary.ownerDid },
9548
+ ...runtimeContext2.summary.space === void 0 ? {} : { spaceId: runtimeContext2.summary.space },
9175
9549
  missing: evaluation.missing
9176
9550
  });
9177
9551
  return authorityRequiredResult(
@@ -9180,7 +9554,7 @@ async function executePreparedInvocation(prepared, options = {}) {
9180
9554
  parsedInput.data,
9181
9555
  request,
9182
9556
  evaluation.missing,
9183
- runtimeContext.runtime.node
9557
+ runtimeContext2.runtime.node
9184
9558
  );
9185
9559
  } catch {
9186
9560
  return errorResult(
@@ -9191,7 +9565,7 @@ async function executePreparedInvocation(prepared, options = {}) {
9191
9565
  }
9192
9566
  }
9193
9567
  const authority = await persistAuthorityRequest(
9194
- runtimeContext,
9568
+ runtimeContext2,
9195
9569
  evaluation.missing
9196
9570
  );
9197
9571
  if (authority.status === "error") {
@@ -9207,7 +9581,7 @@ async function executePreparedInvocation(prepared, options = {}) {
9207
9581
  parsedInput.data,
9208
9582
  authority.request,
9209
9583
  authority.missing,
9210
- runtimeContext.runtime.node
9584
+ runtimeContext2.runtime.node
9211
9585
  );
9212
9586
  }
9213
9587
  const outcome = await definition.execute(
@@ -9239,7 +9613,7 @@ async function executePreparedInvocation(prepared, options = {}) {
9239
9613
  if (hinted === void 0 || !isExactCapabilityMemberSubset(
9240
9614
  hinted,
9241
9615
  required,
9242
- resolveSpace
9616
+ resolveSpace2
9243
9617
  )) {
9244
9618
  return errorResult(
9245
9619
  operation,
@@ -9250,7 +9624,7 @@ async function executePreparedInvocation(prepared, options = {}) {
9250
9624
  )
9251
9625
  );
9252
9626
  }
9253
- if (runtimeContext === void 0) {
9627
+ if (runtimeContext2 === void 0) {
9254
9628
  return errorResult(
9255
9629
  operation,
9256
9630
  runtimeResolution.context.summary,
@@ -9260,13 +9634,13 @@ async function executePreparedInvocation(prepared, options = {}) {
9260
9634
  if (options.deferAuthorityRequest) {
9261
9635
  try {
9262
9636
  const request = buildPermissionRequestArtifact({
9263
- profile: runtimeContext.summary.profile,
9264
- host: runtimeContext.summary.host,
9265
- sessionDid: runtimeContext.summary.sessionDid,
9266
- posture: runtimeContext.summary.posture,
9267
- operatorType: runtimeContext.summary.operatorType ?? "human",
9268
- ...runtimeContext.summary.ownerDid === void 0 ? {} : { ownerDid: runtimeContext.summary.ownerDid },
9269
- ...runtimeContext.summary.space === void 0 ? {} : { spaceId: runtimeContext.summary.space },
9637
+ profile: runtimeContext2.summary.profile,
9638
+ host: runtimeContext2.summary.host,
9639
+ sessionDid: runtimeContext2.summary.sessionDid,
9640
+ posture: runtimeContext2.summary.posture,
9641
+ operatorType: runtimeContext2.summary.operatorType ?? "human",
9642
+ ...runtimeContext2.summary.ownerDid === void 0 ? {} : { ownerDid: runtimeContext2.summary.ownerDid },
9643
+ ...runtimeContext2.summary.space === void 0 ? {} : { spaceId: runtimeContext2.summary.space },
9270
9644
  missing: hinted
9271
9645
  });
9272
9646
  return authorityRequiredResult(
@@ -9275,7 +9649,7 @@ async function executePreparedInvocation(prepared, options = {}) {
9275
9649
  parsedInput.data,
9276
9650
  request,
9277
9651
  hinted,
9278
- runtimeContext.runtime.node,
9652
+ runtimeContext2.runtime.node,
9279
9653
  outcome.requiresCallerInput ?? false
9280
9654
  );
9281
9655
  } catch {
@@ -9287,7 +9661,7 @@ async function executePreparedInvocation(prepared, options = {}) {
9287
9661
  }
9288
9662
  }
9289
9663
  const authority = await persistAuthorityRequest(
9290
- runtimeContext,
9664
+ runtimeContext2,
9291
9665
  hinted,
9292
9666
  true
9293
9667
  );
@@ -9304,7 +9678,7 @@ async function executePreparedInvocation(prepared, options = {}) {
9304
9678
  parsedInput.data,
9305
9679
  authority.request,
9306
9680
  authority.missing,
9307
- runtimeContext.runtime.node,
9681
+ runtimeContext2.runtime.node,
9308
9682
  outcome.requiresCallerInput ?? false
9309
9683
  );
9310
9684
  }
@@ -9407,12 +9781,12 @@ async function persistAuthorityRequest(context, missing, force = false) {
9407
9781
  };
9408
9782
  }
9409
9783
  try {
9410
- const resolveSpace = operationSpaceResolver(
9784
+ const resolveSpace2 = operationSpaceResolver(
9411
9785
  context.runtime.node,
9412
9786
  context.summary.space
9413
9787
  );
9414
- const canonicalMissing = canonicalizeOperationCapabilities(missing, resolveSpace);
9415
- const canonicalGranted = canonicalizeOperationCapabilities(context.runtime.granted, resolveSpace);
9788
+ const canonicalMissing = canonicalizeOperationCapabilities(missing, resolveSpace2);
9789
+ const canonicalGranted = canonicalizeOperationCapabilities(context.runtime.granted, resolveSpace2);
9416
9790
  const resolution = await createOrReusePermissionRequest({
9417
9791
  profile: context.summary.profile,
9418
9792
  posture: context.summary.posture,
@@ -9423,7 +9797,7 @@ async function persistAuthorityRequest(context, missing, force = false) {
9423
9797
  ...context.summary.space === void 0 ? {} : { spaceId: context.summary.space },
9424
9798
  missing: canonicalMissing,
9425
9799
  granted: force ? [] : canonicalGranted,
9426
- resolveSpace
9800
+ resolveSpace: resolveSpace2
9427
9801
  });
9428
9802
  if (resolution.status !== "created") {
9429
9803
  return {
@@ -9502,7 +9876,7 @@ function canonicalPkhOwner(space) {
9502
9876
  }
9503
9877
  function isExactLocalSecretsGetPlan(prepared, planned, context) {
9504
9878
  if (prepared.definition.id !== "tinycloud.secrets.get" || prepared.definition.version !== 1 || JSON.stringify(prepared.definition.effects) !== JSON.stringify(["read", "local_write"])) return "invalid";
9505
- const resolveSpace = operationSpaceResolver(context.runtime.node, context.summary.space);
9879
+ const resolveSpace2 = operationSpaceResolver(context.runtime.node, context.summary.space);
9506
9880
  let reference;
9507
9881
  try {
9508
9882
  reference = resolveSecretReferenceForOperation(
@@ -9515,7 +9889,7 @@ function isExactLocalSecretsGetPlan(prepared, planned, context) {
9515
9889
  }
9516
9890
  const canonicalPlan = canonicalizeOperationCapabilities(
9517
9891
  planned,
9518
- resolveSpace
9892
+ resolveSpace2
9519
9893
  );
9520
9894
  if (canonicalPlan.length !== 2) return "invalid";
9521
9895
  const kv = canonicalPlan.find((permission) => permission.service === "tinycloud.kv");
@@ -9528,7 +9902,7 @@ function isExactLocalSecretsGetPlan(prepared, planned, context) {
9528
9902
  }
9529
9903
  if (JSON.stringify(kv) !== JSON.stringify({
9530
9904
  service: "tinycloud.kv",
9531
- space: resolveSpace(reference.space),
9905
+ space: resolveSpace2(reference.space),
9532
9906
  path: reference.permissionPath,
9533
9907
  actions: ["tinycloud.kv/get"]
9534
9908
  })) return "invalid";
@@ -9539,7 +9913,7 @@ function isExactLocalSecretsGetPlan(prepared, planned, context) {
9539
9913
  }) || typeof decrypt.path !== "string" || !decrypt.path.startsWith("urn:tinycloud:encryption:")) return "invalid";
9540
9914
  return "valid";
9541
9915
  }
9542
- function refreshLiveRuntimeAuthority(node, requested, planned, resolveSpace) {
9916
+ function refreshLiveRuntimeAuthority(node, requested, planned, resolveSpace2) {
9543
9917
  const candidate = node;
9544
9918
  if (typeof candidate.hasRuntimePermissions !== "function") return void 0;
9545
9919
  if (candidate.hasRuntimePermissions([...requested]) !== true) return void 0;
@@ -9550,14 +9924,14 @@ function refreshLiveRuntimeAuthority(node, requested, planned, resolveSpace) {
9550
9924
  const exactActivated = validateExactCapabilities(activated);
9551
9925
  if (exactActivated === void 0) return void 0;
9552
9926
  const selectedActivated = exactActivated.filter(
9553
- (permission) => isExactCapabilityMemberSubset([permission], planned, resolveSpace)
9927
+ (permission) => isExactCapabilityMemberSubset([permission], planned, resolveSpace2)
9554
9928
  );
9555
- if (!isExactCapabilityMemberSubset(requested, selectedActivated, resolveSpace)) return void 0;
9929
+ if (!isExactCapabilityMemberSubset(requested, selectedActivated, resolveSpace2)) return void 0;
9556
9930
  const combined = canonicalizeOperationCapabilities(
9557
9931
  [...base, ...selectedActivated],
9558
- resolveSpace
9932
+ resolveSpace2
9559
9933
  );
9560
- return evaluateOperationAuthority(combined, planned, resolveSpace).satisfied ? combined : void 0;
9934
+ return evaluateOperationAuthority(combined, planned, resolveSpace2).satisfied ? combined : void 0;
9561
9935
  }
9562
9936
  function localAuthorityFailure(prepared) {
9563
9937
  return errorResult(