@plotday/twister 0.47.0 → 0.48.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.
Files changed (72) hide show
  1. package/bin/commands/generate.js +5 -5
  2. package/bin/commands/generate.js.map +1 -1
  3. package/bin/utils/bundle.js +14 -0
  4. package/bin/utils/bundle.js.map +1 -1
  5. package/dist/docs/assets/hierarchy.js +1 -1
  6. package/dist/docs/assets/search.js +1 -1
  7. package/dist/docs/classes/index.Connector.html +1 -1
  8. package/dist/docs/classes/index.Imap.html +1 -1
  9. package/dist/docs/classes/index.Options.html +1 -1
  10. package/dist/docs/classes/index.Smtp.html +1 -1
  11. package/dist/docs/classes/tools_network.Network.html +1 -1
  12. package/dist/docs/classes/tools_plot.Plot.html +1 -1
  13. package/dist/docs/classes/tools_store.Store.html +1 -1
  14. package/dist/docs/classes/tools_tasks.Tasks.html +1 -1
  15. package/dist/docs/documents/CLI_Reference.html +6 -4
  16. package/dist/docs/enums/tools_integrations.AuthProvider.html +3 -1
  17. package/dist/docs/hierarchy.html +1 -1
  18. package/dist/docs/types/tools_integrations.AuthToken.html +4 -4
  19. package/dist/docs/types/tools_integrations.Authorization.html +4 -4
  20. package/dist/llm-docs/tools/integrations.d.ts +1 -1
  21. package/dist/llm-docs/tools/integrations.d.ts.map +1 -1
  22. package/dist/llm-docs/tools/integrations.js +1 -1
  23. package/dist/llm-docs/tools/integrations.js.map +1 -1
  24. package/dist/tools/integrations.d.ts +3 -1
  25. package/dist/tools/integrations.d.ts.map +1 -1
  26. package/dist/tools/integrations.js +2 -0
  27. package/dist/tools/integrations.js.map +1 -1
  28. package/package.json +2 -1
  29. package/src/connector.ts +366 -0
  30. package/src/creator-docs.ts +29 -0
  31. package/src/index.ts +10 -0
  32. package/src/llm-docs/connector.ts +8 -0
  33. package/src/llm-docs/index.ts +48 -0
  34. package/src/llm-docs/options.ts +8 -0
  35. package/src/llm-docs/plot.ts +8 -0
  36. package/src/llm-docs/schedule.ts +8 -0
  37. package/src/llm-docs/tag.ts +8 -0
  38. package/src/llm-docs/tool.ts +8 -0
  39. package/src/llm-docs/tools/ai.ts +8 -0
  40. package/src/llm-docs/tools/callbacks.ts +8 -0
  41. package/src/llm-docs/tools/imap.ts +8 -0
  42. package/src/llm-docs/tools/integrations.ts +8 -0
  43. package/src/llm-docs/tools/network.ts +8 -0
  44. package/src/llm-docs/tools/plot.ts +8 -0
  45. package/src/llm-docs/tools/smtp.ts +8 -0
  46. package/src/llm-docs/tools/store.ts +8 -0
  47. package/src/llm-docs/tools/tasks.ts +8 -0
  48. package/src/llm-docs/tools/twists.ts +8 -0
  49. package/src/llm-docs/twist-guide-template.ts +8 -0
  50. package/src/llm-docs/twist.ts +8 -0
  51. package/src/options.ts +115 -0
  52. package/src/plot.ts +1068 -0
  53. package/src/schedule.ts +203 -0
  54. package/src/tag.ts +44 -0
  55. package/src/tool.ts +377 -0
  56. package/src/tools/ai.ts +845 -0
  57. package/src/tools/callbacks.ts +134 -0
  58. package/src/tools/imap.ts +266 -0
  59. package/src/tools/index.ts +10 -0
  60. package/src/tools/integrations.ts +328 -0
  61. package/src/tools/network.ts +240 -0
  62. package/src/tools/plot.ts +692 -0
  63. package/src/tools/smtp.ts +166 -0
  64. package/src/tools/store.ts +149 -0
  65. package/src/tools/tasks.ts +137 -0
  66. package/src/tools/twists.ts +228 -0
  67. package/src/twist-guide.ts +9 -0
  68. package/src/twist.ts +435 -0
  69. package/src/utils/hash.ts +8 -0
  70. package/src/utils/serializable.ts +54 -0
  71. package/src/utils/types.ts +130 -0
  72. package/src/utils/uuid.ts +9 -0
package/src/options.ts ADDED
@@ -0,0 +1,115 @@
1
+ import { ITool } from "./tool";
2
+
3
+ /**
4
+ * A select option definition for twist configuration.
5
+ * Renders as a dropdown in the Flutter UI.
6
+ */
7
+ export type SelectDef = {
8
+ type: "select";
9
+ label: string;
10
+ description?: string;
11
+ choices: ReadonlyArray<{ value: string; label: string }>;
12
+ default: string;
13
+ };
14
+
15
+ /**
16
+ * A text input option definition for twist configuration.
17
+ * Renders as a text field in the Flutter UI.
18
+ */
19
+ export type TextDef = {
20
+ type: "text";
21
+ label: string;
22
+ description?: string;
23
+ default: string;
24
+ placeholder?: string;
25
+ secure?: boolean; // Encrypted at rest, masked in UI, never returned to clients
26
+ helpText?: string; // Help text displayed below the input field
27
+ helpUrl?: string; // URL for a "Learn more" link shown after helpText
28
+ };
29
+
30
+ /**
31
+ * A number input option definition for twist configuration.
32
+ * Renders as a number field in the Flutter UI.
33
+ */
34
+ export type NumberDef = {
35
+ type: "number";
36
+ label: string;
37
+ description?: string;
38
+ default: number;
39
+ min?: number;
40
+ max?: number;
41
+ };
42
+
43
+ /**
44
+ * A boolean toggle option definition for twist configuration.
45
+ * Renders as a switch in the Flutter UI.
46
+ */
47
+ export type BooleanDef = {
48
+ type: "boolean";
49
+ label: string;
50
+ description?: string;
51
+ default: boolean;
52
+ };
53
+
54
+ /**
55
+ * Union of all option definition types.
56
+ */
57
+ export type OptionDef = SelectDef | TextDef | NumberDef | BooleanDef;
58
+
59
+ /**
60
+ * Schema defining all configurable options for a twist.
61
+ * Each key maps to an option definition that describes its type, label, and default value.
62
+ */
63
+ export type OptionsSchema = Record<string, OptionDef>;
64
+
65
+ /**
66
+ * Infers the resolved value types from an options schema.
67
+ * Boolean options resolve to `boolean`, number options to `number`,
68
+ * and select/text options to `string`.
69
+ */
70
+ export type ResolvedOptions<T extends OptionsSchema> = {
71
+ [K in keyof T]: T[K] extends BooleanDef
72
+ ? boolean
73
+ : T[K] extends NumberDef
74
+ ? number
75
+ : string;
76
+ };
77
+
78
+ /**
79
+ * Built-in marker class for twist configuration options.
80
+ *
81
+ * Declare options in your twist's `build()` method to expose configurable
82
+ * settings to users. The schema is introspected at deploy time and stored
83
+ * alongside permissions. At runtime, user values are merged with defaults.
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * import { Options, type OptionsSchema } from "@plotday/twister/options";
88
+ *
89
+ * export default class MyTwist extends Twist<MyTwist> {
90
+ * build(build: ToolBuilder) {
91
+ * return {
92
+ * options: build(Options, {
93
+ * model: {
94
+ * type: 'select',
95
+ * label: 'AI Model',
96
+ * choices: [
97
+ * { value: 'fast', label: 'Fast' },
98
+ * { value: 'smart', label: 'Smart' },
99
+ * ],
100
+ * default: 'fast',
101
+ * },
102
+ * }),
103
+ * // ... other tools
104
+ * };
105
+ * }
106
+ *
107
+ * async respond(note: Note) {
108
+ * const model = this.tools.options.model; // typed as string
109
+ * }
110
+ * }
111
+ * ```
112
+ */
113
+ export abstract class Options extends ITool {
114
+ static readonly toolId = "Options";
115
+ }