@atbash/sdk 0.10.4-dev.0 → 0.10.6-dev.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.
package/dist/index.mjs CHANGED
@@ -3446,11 +3446,15 @@ var Atbash = class _Atbash {
3446
3446
  * response bytes via the Rust core's `verifySignature`.
3447
3447
  */
3448
3448
  async judgeAction(action, context = "", options = {}) {
3449
- return this.track(
3450
- "judgeAction",
3451
- this.auth.pubkey,
3452
- () => this._judgeAction(action, context, options)
3453
- );
3449
+ return this.track("judgeAction", this.auth.pubkey, async () => {
3450
+ try {
3451
+ return await this._judgeAction(action, context, options);
3452
+ } catch (err) {
3453
+ if (!isEncryptionStateMismatch(err)) throw err;
3454
+ this._orgKeyFromChain = null;
3455
+ return await this._judgeAction(action, context, options);
3456
+ }
3457
+ });
3454
3458
  }
3455
3459
  async _judgeAction(action, context, options) {
3456
3460
  if (!action?.trim()) {
@@ -3497,6 +3501,7 @@ var Atbash = class _Atbash {
3497
3501
  if (context) body.context = context;
3498
3502
  if (options.provider) body.provider = options.provider;
3499
3503
  if (options.toolName) body.tool_name = options.toolName;
3504
+ if (options.toolArgsJson) body.tool_args_json = options.toolArgsJson;
3500
3505
  if (options.model) body.model = options.model;
3501
3506
  if (options.resolved) body.resolved = options.resolved;
3502
3507
  if (options.mode) body.mode = options.mode;
@@ -4123,6 +4128,10 @@ async function safeText(resp) {
4123
4128
  function errorMessage(err) {
4124
4129
  return err instanceof Error ? err.message : String(err);
4125
4130
  }
4131
+ function isEncryptionStateMismatch(err) {
4132
+ const msg = errorMessage(err);
4133
+ return msg.includes("must be a valid encryption envelope") || msg.includes("must be plaintext");
4134
+ }
4126
4135
  function stringifyArgs(args) {
4127
4136
  if (args === null || args === void 0) return "";
4128
4137
  if (typeof args === "string") return args;