@mulmoclaude/google-plugin 0.3.4 → 1.0.1

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.js CHANGED
@@ -1,5 +1,52 @@
1
1
  import { DEFAULT_LIST_MAX_RESULTS, MAX_LIST_RESULTS, clearCalendarSyncToken, clientSecretPresence, completeTask, createCalendarEvent, createDriveFile, createTask, getCalendarColors, getGoogleAccessToken, isIsoDateTimeWithOffset, listCalendarEvents, listCalendars, listDriveFiles, listTaskLists, listTasks, loadCalendarSyncToken, loadGoogleTokens, readDriveFile, saveCalendarSyncToken, syncCalendarEvents } from "@mulmoclaude/core/google";
2
2
  //#region ../../../node_modules/gui-chat-protocol/dist/index.js
3
+ /**
4
+ * Identity function for type inference. Same philosophy as
5
+ * `defineComponent` in Vue: it does nothing at runtime, just lets
6
+ * TypeScript thread the runtime/result types so the plugin author
7
+ * gets full IntelliSense on `runtime.X` without manual annotations.
8
+ *
9
+ * Generic placement (T inferred from setup's return) lets
10
+ * `StrictPluginResult<T>` extract `TOOL_DEFINITION.name` and require
11
+ * a matching named handler — Codex review #10 iter-2 caught that an
12
+ * earlier `<N extends string, T extends PluginFactoryResult<N>>`
13
+ * shape would not actually narrow `N` at the call site.
14
+ *
15
+ * Plugin authors should declare `name` as a literal (`as const`) so
16
+ * the strict handler check fires:
17
+ *
18
+ * TOOL_DEFINITION: { type: "function" as const, name: "myTool" as const, ... }
19
+ *
20
+ * Without `as const`, `N` widens to `string` and the strict check
21
+ * gracefully degrades to the loose runtime warn (see
22
+ * `StrictPluginResult` above).
23
+ *
24
+ * **Annotate the handler parameter explicitly** as `args: unknown`.
25
+ * TypeScript can't propagate the contextual type into the method
26
+ * parameter when it's still inferring `T` from the same return value
27
+ * (circular), so leaving `args` un-annotated trips `noImplicitAny`.
28
+ * Always:
29
+ *
30
+ * async myTool(args: unknown) { ... }
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * export default definePlugin(({ pubsub, files, locale }) => ({
35
+ * TOOL_DEFINITION: {
36
+ * type: "function" as const,
37
+ * name: "myTool" as const,
38
+ * description: "...",
39
+ * parameters: { type: "object", properties: {}, required: [] },
40
+ * },
41
+ * async myTool(args: unknown) {
42
+ * // narrow `args` here — typically with Zod
43
+ * await files.data.write("state.json", JSON.stringify(args));
44
+ * pubsub.publish("changed", {});
45
+ * return { ok: true };
46
+ * },
47
+ * }));
48
+ * ```
49
+ */
3
50
  function definePlugin(setup) {
4
51
  return setup;
5
52
  }