hypha-debugger 0.1.6 → 0.1.8

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.
@@ -11259,6 +11259,10 @@
11259
11259
  * This helper uses new Function() to create a wrapper whose parameter names
11260
11260
  * are taken from the function's __schema__ property, so hypha-rpc always sees
11261
11261
  * the real parameter names regardless of minification.
11262
+ *
11263
+ * Additionally, it handles the case where hypha-rpc passes kwargs as a single
11264
+ * object argument (e.g. `fn({url: "..."})` instead of `fn("...")`). The
11265
+ * wrapper detects this and destructures the kwargs object automatically.
11262
11266
  */
11263
11267
  function wrapFn(fn) {
11264
11268
  const schema = fn.__schema__;
@@ -11268,8 +11272,23 @@
11268
11272
  if (paramNames.length === 0) {
11269
11273
  return fn;
11270
11274
  }
11275
+ // Create a wrapper that:
11276
+ // 1. Has correct, unminified parameter names (for hypha-rpc getParamNames)
11277
+ // 2. Detects when kwargs are passed as a single object and destructures them
11271
11278
  const paramList = paramNames.join(", ");
11272
- const wrapper = new Function("fn", `return async function(${paramList}) { return fn(${paramList}); }`)(fn);
11279
+ const wrapper = new Function("fn", "paramNames", `return async function(${paramList}) {
11280
+ // Detect kwargs-as-object: single argument that is a plain object
11281
+ // whose keys match schema parameter names
11282
+ if (arguments.length === 1 && ${paramList} != null && typeof ${paramList} === "object" && !Array.isArray(${paramList}) && !(${paramList} instanceof Date)) {
11283
+ var _kw = ${paramList};
11284
+ var _firstKey = Object.keys(_kw)[0];
11285
+ if (_firstKey && paramNames.indexOf(_firstKey) !== -1) {
11286
+ var _args = paramNames.map(function(n) { return _kw[n]; });
11287
+ return fn.apply(null, _args);
11288
+ }
11289
+ }
11290
+ return fn(${paramList});
11291
+ }`)(fn, paramNames);
11273
11292
  if (schema)
11274
11293
  wrapper.__schema__ = schema;
11275
11294
  return wrapper;
@@ -14069,7 +14088,20 @@
14069
14088
  connectConfig.workspace = this.config.workspace;
14070
14089
  if (this.config.token)
14071
14090
  connectConfig.token = this.config.token;
14072
- this.server = await connect(connectConfig);
14091
+ try {
14092
+ this.server = await connect(connectConfig);
14093
+ }
14094
+ catch (connErr) {
14095
+ // If connecting to a saved workspace fails (e.g. expired/garbage-collected),
14096
+ // retry without the workspace to get a fresh one.
14097
+ if (this.config.workspace) {
14098
+ console.warn(`[hypha-debugger] Failed to rejoin workspace "${this.config.workspace}", getting a fresh one:`, connErr.message ?? connErr);
14099
+ this.server = await connect({ server_url: this.config.server_url });
14100
+ }
14101
+ else {
14102
+ throw connErr;
14103
+ }
14104
+ }
14073
14105
  // Register debug service
14074
14106
  this.serviceInfo = await this.server.registerService(this.buildServiceDefinition());
14075
14107
  // Update overlay and build session
@@ -14144,10 +14176,14 @@
14144
14176
  */
14145
14177
  saveConfigToStorage() {
14146
14178
  try {
14179
+ // Save workspace so we can rejoin the same one (keeps URL stable),
14180
+ // but never save the token — anonymous workspace tokens expire and
14181
+ // cause "Permission denied" on reconnect. For anonymous workspaces
14182
+ // no token is needed to rejoin; for authenticated workspaces the
14183
+ // user must provide a fresh token via data attributes or config.
14147
14184
  const data = {
14148
14185
  server_url: this.config.server_url,
14149
14186
  workspace: this.server?.config?.workspace ?? this.config.workspace,
14150
- token: this.config.token,
14151
14187
  service_id: this.config.service_id,
14152
14188
  service_name: this.config.service_name,
14153
14189
  show_ui: this.config.show_ui,