weread-export 0.1.10 → 0.1.12

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/lib/index.js CHANGED
@@ -2007,7 +2007,7 @@ async function apiFor(store) {
2007
2007
  * @returns the route list.
2008
2008
  */
2009
2009
  function makeRoutes(deps) {
2010
- const { store, directoryPicker } = deps;
2010
+ const { store, getPicker } = deps;
2011
2011
  const guard = (req, res, method) => {
2012
2012
  if (!isLoopbackRequest(req)) {
2013
2013
  writeJson(res, 403, { error: "forbidden: loopback-only" });
@@ -2130,7 +2130,7 @@ function makeRoutes(deps) {
2130
2130
  handler: async (req, res) => {
2131
2131
  if (!guard(req, res, "POST")) return;
2132
2132
  try {
2133
- const capability = directoryPicker?.capability();
2133
+ const capability = getPicker?.()?.capability();
2134
2134
  if (capability === void 0) {
2135
2135
  writeJson(res, 200, {
2136
2136
  ok: false,
@@ -2354,7 +2354,8 @@ const name = "weread";
2354
2354
  const inject = [
2355
2355
  "tools",
2356
2356
  "systemPrompt",
2357
- "webServer"
2357
+ "webServer",
2358
+ "directoryPicker"
2358
2359
  ];
2359
2360
  /** Order of the announcement section within the tool-guidance band. */
2360
2361
  const SECTION_ORDER = 160;
@@ -2394,15 +2395,17 @@ function apply(ctx, config) {
2394
2395
  };
2395
2396
  }, "weread-export: tools");
2396
2397
  disposeRoutes = ctx.effect(() => {
2397
- let picker;
2398
- try {
2399
- picker = ctx.directoryPicker;
2400
- } catch {
2401
- picker = void 0;
2402
- }
2398
+ const getPicker = () => {
2399
+ try {
2400
+ return ctx.directoryPicker;
2401
+ } catch (error) {
2402
+ console.error("[weread-export] directoryPicker access failed:", error);
2403
+ return;
2404
+ }
2405
+ };
2403
2406
  const disposers = makeRoutes({
2404
2407
  store,
2405
- directoryPicker: picker
2408
+ getPicker
2406
2409
  }).map((route) => ctx.webServer.register(route));
2407
2410
  return () => {
2408
2411
  for (const dispose of disposers) dispose();
@@ -32,8 +32,11 @@ export declare const WEREAD_API: {
32
32
  /** Route handler context. */
33
33
  export interface RouteContext {
34
34
  store: WereadStore;
35
- /** Host directory picker (native = OS folder chooser); optional. */
36
- directoryPicker?: NativeDirectoryPicker | undefined;
35
+ /**
36
+ * Lazily resolve the host directory picker at request time (by then every
37
+ * plugin is loaded, so the picker service is guaranteed registered).
38
+ */
39
+ getPicker?: () => NativeDirectoryPicker | undefined;
37
40
  }
38
41
  /**
39
42
  * Build every /api/weread-export route (exact paths).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weread-export",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "微信读书 (WeChat Reading) integration for DeepSeek Harness: connect the official WeRead Skills Agent Gateway with a wrk- API key, then browse your bookshelf, export highlights & thoughts, query reading stats, and send highlights to flomo — agent tools plus a web settings panel",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",