@tinycloud/operations 0.5.2-beta.1 → 0.5.3-beta.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.
@@ -33,6 +33,16 @@ var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__
33
33
  ));
34
34
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
35
35
 
36
+ // src/cli-name.ts
37
+ import { basename } from "path";
38
+ var CLI_NAME;
39
+ var init_cli_name = __esm({
40
+ "src/cli-name.ts"() {
41
+ "use strict";
42
+ CLI_NAME = basename(process.argv[1] ?? "") === "tinycloud" ? "tinycloud" : "tc";
43
+ }
44
+ });
45
+
36
46
  // ../sdk-core/src/policy/errors.ts
37
47
  var SignedObjectProfileError, SignedObjectCanonicalizationError;
38
48
  var init_errors = __esm({
@@ -4252,7 +4262,7 @@ import {
4252
4262
  } from "fs/promises";
4253
4263
  import { connect, createServer } from "net";
4254
4264
  import { homedir } from "os";
4255
- import { basename, dirname, isAbsolute, join, relative, resolve } from "path";
4265
+ import { basename as basename2, dirname, isAbsolute, join, relative, resolve } from "path";
4256
4266
  function processWideContext(key) {
4257
4267
  var _a4;
4258
4268
  const registry = globalThis;
@@ -4321,7 +4331,7 @@ async function bindLiveness(directory) {
4321
4331
  await rename(pinned.path(`${socket}.new`), pinned.path(socket));
4322
4332
  const stats = await lstat(pinned.path(socket), { bigint: true });
4323
4333
  if (!stats.isSocket()) throw new Error(`${socket} is not a socket`);
4324
- await waitForTestBarrier(TEST_LOCK_LIVENESS_BARRIER_DIR, basename(directory));
4334
+ await waitForTestBarrier(TEST_LOCK_LIVENESS_BARRIER_DIR, basename2(directory));
4325
4335
  return { record: { socket, dev: String(stats.dev), ino: String(stats.ino) }, path: join(directory, socket), server };
4326
4336
  } catch {
4327
4337
  if (bound) {
@@ -4466,7 +4476,7 @@ async function replaceJson(filePath, value, durable) {
4466
4476
  const directory = dirname(filePath);
4467
4477
  const temporaryPath = join(
4468
4478
  directory,
4469
- `.${basename(filePath)}.${process.pid}.${randomUUID()}.tmp`
4479
+ `.${basename2(filePath)}.${process.pid}.${randomUUID()}.tmp`
4470
4480
  );
4471
4481
  const contents = `${JSON.stringify(value, null, 2)}
4472
4482
  `;
@@ -4788,7 +4798,7 @@ async function markTurn(path, token, kind) {
4788
4798
  async function createTurnDirectory(directory) {
4789
4799
  const token = randomUUID();
4790
4800
  const owner = { pid: process.pid, createdAt: (/* @__PURE__ */ new Date()).toISOString(), token, after: null, ...processOwner(null) };
4791
- await publishDirectory(join(dirname(directory), `.stage-${basename(directory)}-${process.pid}-${token}`), directory, {
4801
+ await publishDirectory(join(dirname(directory), `.stage-${basename2(directory)}-${process.pid}-${token}`), directory, {
4792
4802
  "0/owner.json": `${JSON.stringify(owner, null, 2)}
4793
4803
  `,
4794
4804
  [`0/${token}.held`]: "",
@@ -5455,7 +5465,7 @@ function isSafeRecovery(value, action) {
5455
5465
  if (!("command" in record)) return true;
5456
5466
  const command = record.command;
5457
5467
  if (typeof command !== "string") return false;
5458
- const profile = /^tc --profile (\S+) /.exec(command)?.[1];
5468
+ const profile = /^\S+ --profile (\S+) /.exec(command)?.[1];
5459
5469
  if (profile === void 0 || !SAFE_PROFILE_TOKEN.test(profile)) return false;
5460
5470
  return action === "sign_in" ? Object.values(SIGN_IN_TEMPLATES).some((template) => template(profile) === command) : migrationCommand(profile) === command;
5461
5471
  }
@@ -5463,14 +5473,15 @@ var SAFE_PROFILE_TOKEN, MIGRATION_OPERATION_ID, SIGN_IN_TEMPLATES, migrationComm
5463
5473
  var init_recovery = __esm({
5464
5474
  "src/recovery.ts"() {
5465
5475
  "use strict";
5476
+ init_cli_name();
5466
5477
  SAFE_PROFILE_TOKEN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
5467
5478
  MIGRATION_OPERATION_ID = "tinycloud.auth.capabilities";
5468
5479
  SIGN_IN_TEMPLATES = {
5469
- local: (profile) => `tc --profile ${profile} auth login --method local`,
5470
- openkey: (profile) => `tc --profile ${profile} auth login --method openkey`,
5471
- scoped: (profile) => `tc --profile ${profile} auth login --method openkey --paste --manifest <manifest.json>`
5480
+ local: (profile) => `${CLI_NAME} --profile ${profile} auth login --method local`,
5481
+ openkey: (profile) => `${CLI_NAME} --profile ${profile} auth login --method openkey`,
5482
+ scoped: (profile) => `${CLI_NAME} --profile ${profile} auth login --method openkey --paste --manifest <manifest.json>`
5472
5483
  };
5473
- migrationCommand = (profile) => `tc --profile ${profile} auth caps`;
5484
+ migrationCommand = (profile) => `${CLI_NAME} --profile ${profile} auth caps`;
5474
5485
  }
5475
5486
  });
5476
5487
 
@@ -6972,7 +6983,7 @@ function ownerOfSpace(space) {
6972
6983
  return ownerOrUndefined(`did:pkh:eip155:${match[1]}:${match[2].toLowerCase()}`);
6973
6984
  }
6974
6985
  function putCommands(names, scope) {
6975
- return dedupe(names).map((name) => `tc secrets put ${name}${scope === void 0 ? "" : ` --scope ${scope}`} --stdin`).join("; ");
6986
+ return dedupe(names).map((name) => `${CLI_NAME} secrets put ${name}${scope === void 0 ? "" : ` --scope ${scope}`} --stdin`).join("; ");
6976
6987
  }
6977
6988
  function dedupe(names) {
6978
6989
  return [...new Set(names)];
@@ -6984,6 +6995,7 @@ var SECRET_MANAGER_ORIGIN, SECRET_REQUEST_MAX_NAMES, SECRET_REQUEST_MAX_URL_LENG
6984
6995
  var init_secret_request = __esm({
6985
6996
  "src/secret-request.ts"() {
6986
6997
  "use strict";
6998
+ init_cli_name();
6987
6999
  SECRET_MANAGER_ORIGIN = "https://secrets.tinycloud.xyz";
6988
7000
  SECRET_REQUEST_MAX_NAMES = 10;
6989
7001
  SECRET_REQUEST_MAX_URL_LENGTH = 8192;
@@ -7093,7 +7105,7 @@ function classifySecretRead(reference, result, localOwner) {
7093
7105
  approval: {
7094
7106
  kind: "openkey",
7095
7107
  requestId: "runtime-hint",
7096
- fallback: "tc auth grant <request-artifact>"
7108
+ fallback: `${CLI_NAME} auth grant <request-artifact>`
7097
7109
  }
7098
7110
  };
7099
7111
  case "node_unreachable":
@@ -7195,6 +7207,7 @@ var SecretsGetInputSchema, SecretsGetOutputSchema, SECRETS_GET_POSTURES, SECRETS
7195
7207
  var init_secrets_get = __esm({
7196
7208
  "src/operations/secrets-get.ts"() {
7197
7209
  "use strict";
7210
+ init_cli_name();
7198
7211
  init_errors2();
7199
7212
  init_secret_request();
7200
7213
  init_secrets();
@@ -8824,7 +8837,7 @@ async function createRestoredRuntime(target, resolved) {
8824
8837
  )) {
8825
8838
  return failed(summary, operationError(
8826
8839
  "PROFILE_MIGRATION_REQUIRED",
8827
- `Profile "${profileName}" has a one-time stored-grant upgrade to finish. Run one authenticated command on it (tc --profile <profile> auth caps), then retry.`,
8840
+ `Profile "${profileName}" has a one-time stored-grant upgrade to finish. Run one authenticated command on it (${CLI_NAME} --profile <profile> auth caps), then retry.`,
8828
8841
  { retryable: false, details: { recovery: migrationRecovery(profileName) } }
8829
8842
  ));
8830
8843
  }
@@ -8934,6 +8947,7 @@ function unresolvedSummary(target) {
8934
8947
  var init_runtime = __esm({
8935
8948
  "src/runtime.ts"() {
8936
8949
  "use strict";
8950
+ init_cli_name();
8937
8951
  init_authority();
8938
8952
  init_errors2();
8939
8953
  init_profile();
@@ -8945,6 +8959,7 @@ var init_runtime = __esm({
8945
8959
  });
8946
8960
 
8947
8961
  // src/invoke.ts
8962
+ init_cli_name();
8948
8963
  init_jcs();
8949
8964
  init_errors2();
8950
8965
  init_authority();
@@ -9734,7 +9749,7 @@ function approvalAction(request, node) {
9734
9749
  kind: "openkey",
9735
9750
  requestId: request.requestId,
9736
9751
  ...url === void 0 ? {} : { url },
9737
- fallback: "tc auth grant <request-artifact>"
9752
+ fallback: `${CLI_NAME} auth grant <request-artifact>`
9738
9753
  };
9739
9754
  }
9740
9755
  function exactCapabilities2(value) {