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.
- package/dist/hypha-debugger.js +39 -3
- package/dist/hypha-debugger.js.map +1 -1
- package/dist/hypha-debugger.min.js +2 -2
- package/dist/hypha-debugger.min.js.map +1 -1
- package/dist/hypha-debugger.mjs +39 -3
- package/dist/hypha-debugger.mjs.map +1 -1
- package/dist/utils/wrap-fn.d.ts +4 -0
- package/package.json +1 -1
package/dist/hypha-debugger.mjs
CHANGED
|
@@ -2802,6 +2802,10 @@ function generateSkillMd(serviceFunctions, serviceUrl) {
|
|
|
2802
2802
|
* This helper uses new Function() to create a wrapper whose parameter names
|
|
2803
2803
|
* are taken from the function's __schema__ property, so hypha-rpc always sees
|
|
2804
2804
|
* the real parameter names regardless of minification.
|
|
2805
|
+
*
|
|
2806
|
+
* Additionally, it handles the case where hypha-rpc passes kwargs as a single
|
|
2807
|
+
* object argument (e.g. `fn({url: "..."})` instead of `fn("...")`). The
|
|
2808
|
+
* wrapper detects this and destructures the kwargs object automatically.
|
|
2805
2809
|
*/
|
|
2806
2810
|
function wrapFn(fn) {
|
|
2807
2811
|
const schema = fn.__schema__;
|
|
@@ -2811,8 +2815,23 @@ function wrapFn(fn) {
|
|
|
2811
2815
|
if (paramNames.length === 0) {
|
|
2812
2816
|
return fn;
|
|
2813
2817
|
}
|
|
2818
|
+
// Create a wrapper that:
|
|
2819
|
+
// 1. Has correct, unminified parameter names (for hypha-rpc getParamNames)
|
|
2820
|
+
// 2. Detects when kwargs are passed as a single object and destructures them
|
|
2814
2821
|
const paramList = paramNames.join(", ");
|
|
2815
|
-
const wrapper = new Function("fn", `return async function(${paramList}) {
|
|
2822
|
+
const wrapper = new Function("fn", "paramNames", `return async function(${paramList}) {
|
|
2823
|
+
// Detect kwargs-as-object: single argument that is a plain object
|
|
2824
|
+
// whose keys match schema parameter names
|
|
2825
|
+
if (arguments.length === 1 && ${paramList} != null && typeof ${paramList} === "object" && !Array.isArray(${paramList}) && !(${paramList} instanceof Date)) {
|
|
2826
|
+
var _kw = ${paramList};
|
|
2827
|
+
var _firstKey = Object.keys(_kw)[0];
|
|
2828
|
+
if (_firstKey && paramNames.indexOf(_firstKey) !== -1) {
|
|
2829
|
+
var _args = paramNames.map(function(n) { return _kw[n]; });
|
|
2830
|
+
return fn.apply(null, _args);
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
return fn(${paramList});
|
|
2834
|
+
}`)(fn, paramNames);
|
|
2816
2835
|
if (schema)
|
|
2817
2836
|
wrapper.__schema__ = schema;
|
|
2818
2837
|
return wrapper;
|
|
@@ -5612,7 +5631,20 @@ class HyphaDebugger {
|
|
|
5612
5631
|
connectConfig.workspace = this.config.workspace;
|
|
5613
5632
|
if (this.config.token)
|
|
5614
5633
|
connectConfig.token = this.config.token;
|
|
5615
|
-
|
|
5634
|
+
try {
|
|
5635
|
+
this.server = await connect(connectConfig);
|
|
5636
|
+
}
|
|
5637
|
+
catch (connErr) {
|
|
5638
|
+
// If connecting to a saved workspace fails (e.g. expired/garbage-collected),
|
|
5639
|
+
// retry without the workspace to get a fresh one.
|
|
5640
|
+
if (this.config.workspace) {
|
|
5641
|
+
console.warn(`[hypha-debugger] Failed to rejoin workspace "${this.config.workspace}", getting a fresh one:`, connErr.message ?? connErr);
|
|
5642
|
+
this.server = await connect({ server_url: this.config.server_url });
|
|
5643
|
+
}
|
|
5644
|
+
else {
|
|
5645
|
+
throw connErr;
|
|
5646
|
+
}
|
|
5647
|
+
}
|
|
5616
5648
|
// Register debug service
|
|
5617
5649
|
this.serviceInfo = await this.server.registerService(this.buildServiceDefinition());
|
|
5618
5650
|
// Update overlay and build session
|
|
@@ -5687,10 +5719,14 @@ class HyphaDebugger {
|
|
|
5687
5719
|
*/
|
|
5688
5720
|
saveConfigToStorage() {
|
|
5689
5721
|
try {
|
|
5722
|
+
// Save workspace so we can rejoin the same one (keeps URL stable),
|
|
5723
|
+
// but never save the token — anonymous workspace tokens expire and
|
|
5724
|
+
// cause "Permission denied" on reconnect. For anonymous workspaces
|
|
5725
|
+
// no token is needed to rejoin; for authenticated workspaces the
|
|
5726
|
+
// user must provide a fresh token via data attributes or config.
|
|
5690
5727
|
const data = {
|
|
5691
5728
|
server_url: this.config.server_url,
|
|
5692
5729
|
workspace: this.server?.config?.workspace ?? this.config.workspace,
|
|
5693
|
-
token: this.config.token,
|
|
5694
5730
|
service_id: this.config.service_id,
|
|
5695
5731
|
service_name: this.config.service_name,
|
|
5696
5732
|
show_ui: this.config.show_ui,
|