@hyperspell/openclaw-hyperspell 0.11.1 → 0.13.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 (50) hide show
  1. package/README.md +37 -1
  2. package/dist/client.js +341 -0
  3. package/dist/commands/setup.js +569 -0
  4. package/dist/commands/slash.js +159 -0
  5. package/dist/config.js +349 -0
  6. package/{graph/cron.ts → dist/graph/cron.js} +11 -15
  7. package/dist/graph/index.js +4 -0
  8. package/dist/graph/ops.js +221 -0
  9. package/dist/graph/state.js +68 -0
  10. package/dist/graph/tools.js +87 -0
  11. package/dist/hooks/auto-context.js +199 -0
  12. package/dist/hooks/auto-trace.js +141 -0
  13. package/dist/hooks/emotional-state.js +155 -0
  14. package/dist/hooks/memory-sync.js +54 -0
  15. package/dist/hooks/startup-orientation.js +156 -0
  16. package/dist/index.js +132 -0
  17. package/dist/lib/browser.js +29 -0
  18. package/dist/lib/sender.js +173 -0
  19. package/dist/lib/voice-id.js +22 -0
  20. package/dist/logger.js +32 -0
  21. package/dist/sync/markdown.js +151 -0
  22. package/dist/tools/remember.js +97 -0
  23. package/dist/tools/search.js +87 -0
  24. package/openclaw.plugin.json +17 -1
  25. package/package.json +7 -12
  26. package/client.ts +0 -566
  27. package/commands/setup.ts +0 -673
  28. package/commands/slash.ts +0 -198
  29. package/config.test.ts +0 -202
  30. package/config.ts +0 -497
  31. package/graph/index.ts +0 -5
  32. package/graph/ops.ts +0 -259
  33. package/graph/state.ts +0 -79
  34. package/graph/tools.ts +0 -117
  35. package/hooks/auto-context.ts +0 -272
  36. package/hooks/auto-trace.test.ts +0 -81
  37. package/hooks/auto-trace.ts +0 -197
  38. package/hooks/emotional-state.test.ts +0 -160
  39. package/hooks/emotional-state.ts +0 -179
  40. package/hooks/memory-sync.ts +0 -65
  41. package/index.ts +0 -152
  42. package/lib/browser.ts +0 -31
  43. package/lib/sender.test.ts +0 -234
  44. package/lib/sender.ts +0 -234
  45. package/lib/voice-id.ts +0 -39
  46. package/logger.ts +0 -41
  47. package/sync/markdown.ts +0 -186
  48. package/tools/remember.ts +0 -132
  49. package/tools/search.ts +0 -131
  50. package/types/openclaw.d.ts +0 -76
package/tools/search.ts DELETED
@@ -1,131 +0,0 @@
1
- import { Type } from "@sinclair/typebox"
2
- import type { HyperspellClient } from "../client.ts"
3
- import type { CanReadScope, HyperspellConfig } from "../config.ts"
4
- import { buildScopeFilter, getCanReadScopes, resolveUser } from "../lib/sender.ts"
5
- import { log } from "../logger.ts"
6
-
7
- export function createSearchToolFactory(
8
- client: HyperspellClient,
9
- cfg: HyperspellConfig,
10
- ) {
11
- const scopingEnabled = !!cfg.multiUser?.scoping
12
- const availableScopes = cfg.multiUser?.scoping?.scopes ?? []
13
- const scopeDescription = scopingEnabled
14
- ? `Narrow search to a single privacy scope. Available: ${availableScopes.join(", ")}. Omit to search all scopes visible to the caller's role.`
15
- : "Privacy scope (only used when scoping is enabled in config)."
16
-
17
- return (ctx: Record<string, unknown>) => ({
18
- name: "hyperspell_search",
19
- label: "Memory Search",
20
- description:
21
- "Search through the user's connected sources (Notion, Slack, Gmail, Google Drive, etc.) for relevant information.",
22
- parameters: Type.Object({
23
- query: Type.String({ description: "Search query" }),
24
- limit: Type.Optional(
25
- Type.Number({ description: "Max results (default: 5)" }),
26
- ),
27
- after: Type.Optional(
28
- Type.String({ description: "Only return memories created on or after this date (ISO 8601 or YYYY-MM-DD)" }),
29
- ),
30
- before: Type.Optional(
31
- Type.String({ description: "Only return memories created before this date (ISO 8601 or YYYY-MM-DD)" }),
32
- ),
33
- userId: Type.Optional(
34
- Type.String({
35
- description:
36
- "Search as a specific user (e.g. 'ben', 'shared'). Omit to search as current sender.",
37
- }),
38
- ),
39
- scope: Type.Optional(Type.String({ description: scopeDescription })),
40
- }),
41
- async execute(
42
- _toolCallId: string,
43
- params: {
44
- query: string
45
- limit?: number
46
- after?: string
47
- before?: string
48
- userId?: string
49
- scope?: string
50
- },
51
- ) {
52
- const limit = params.limit ?? 5
53
- const resolved = resolveUser(ctx, cfg)
54
- const userId = params.userId ?? resolved?.userId
55
-
56
- // Build scope filter: intersect requested scope (if any) with caller's canRead
57
- let filter: Record<string, unknown> | undefined
58
- if (scopingEnabled) {
59
- const canRead = getCanReadScopes(resolved, cfg)
60
- const allowed: CanReadScope[] = params.scope
61
- ? canRead.includes("*")
62
- ? [params.scope]
63
- : canRead.includes(params.scope)
64
- ? [params.scope]
65
- : [] // requested scope not allowed → match nothing
66
- : canRead
67
- filter = buildScopeFilter(allowed, resolved?.userId ?? "")
68
- }
69
-
70
- log.debug(
71
- `search tool: query="${params.query}" limit=${limit} after=${params.after ?? "none"} before=${params.before ?? "none"} userId=${userId} scope=${params.scope ?? "any"}`,
72
- )
73
-
74
- try {
75
- const response = await client.searchRaw(params.query, {
76
- limit,
77
- after: params.after,
78
- before: params.before,
79
- userId,
80
- filter,
81
- })
82
- const documents = (response.documents ?? []) as Array<{
83
- source: string
84
- resource_id: string
85
- score?: number
86
- summary?: string
87
- title?: string
88
- metadata?: Record<string, unknown>
89
- highlights?: Array<{ text: string }>
90
- data?: Array<{ text: string }>
91
- }>
92
-
93
- if (documents.length === 0) {
94
- return {
95
- content: [
96
- { type: "text" as const, text: "No relevant memories found." },
97
- ],
98
- }
99
- }
100
-
101
- const formattedDocs = documents
102
- .map((doc, i) => {
103
- const relevance = doc.score
104
- ? `${Math.round(doc.score * 100)}%`
105
- : "N/A"
106
- const title = doc.title || "(untitled)"
107
- const summary = doc.summary || "(no summary)"
108
- return `${i + 1}. Source: ${doc.source}\n Title: ${title}\n Summary: ${summary}\n Relevance: ${relevance}`
109
- })
110
- .join("\n\n")
111
-
112
- const text = `Found ${documents.length} memories:\n\n${formattedDocs}`
113
-
114
- return {
115
- content: [{ type: "text" as const, text }],
116
- details: { count: documents.length, documents },
117
- }
118
- } catch (err) {
119
- log.error("search tool failed", err)
120
- return {
121
- content: [
122
- {
123
- type: "text" as const,
124
- text: `Search failed: ${err instanceof Error ? err.message : String(err)}`,
125
- },
126
- ],
127
- }
128
- }
129
- },
130
- })
131
- }
@@ -1,76 +0,0 @@
1
- declare module "openclaw/plugin-sdk" {
2
- import type { Command } from "commander"
3
-
4
- export interface OpenClawPluginCliContext {
5
- program: Command
6
- config: unknown
7
- workspaceDir?: string
8
- logger: {
9
- info: (message: string, ...args: unknown[]) => void
10
- warn: (message: string, ...args: unknown[]) => void
11
- error: (message: string, ...args: unknown[]) => void
12
- debug: (message: string, ...args: unknown[]) => void
13
- }
14
- }
15
-
16
- export type OpenClawPluginCliRegistrar = (ctx: OpenClawPluginCliContext) => void | Promise<void>
17
-
18
- export interface OpenClawPluginApi {
19
- pluginConfig: unknown
20
- workspaceDir?: string
21
- logger: {
22
- info: (message: string, ...args: unknown[]) => void
23
- warn: (message: string, ...args: unknown[]) => void
24
- error: (message: string, ...args: unknown[]) => void
25
- debug: (message: string, ...args: unknown[]) => void
26
- }
27
- registerCommand(options: {
28
- name: string
29
- description: string
30
- acceptsArgs: boolean
31
- requireAuth: boolean
32
- handler: (ctx: { args?: string; senderId?: string; channel?: string }) => Promise<{ text: string }>
33
- }): void
34
- registerCli(registrar: OpenClawPluginCliRegistrar, opts?: { commands?: string[] }): void
35
- registerTool<T = unknown>(
36
- options: {
37
- name: string
38
- label: string
39
- description: string
40
- parameters: unknown
41
- execute: (
42
- toolCallId: string,
43
- params: T,
44
- ) => Promise<{
45
- content: Array<{ type: "text"; text: string }>
46
- details?: Record<string, unknown>
47
- }>
48
- },
49
- meta: { name: string },
50
- ): void
51
- registerTool<T = unknown>(
52
- factory: (ctx: Record<string, unknown>) => {
53
- name: string
54
- label: string
55
- description: string
56
- parameters: unknown
57
- execute: (
58
- toolCallId: string,
59
- params: T,
60
- ) => Promise<{
61
- content: Array<{ type: "text"; text: string }>
62
- details?: Record<string, unknown>
63
- }>
64
- },
65
- meta: { name: string },
66
- ): void
67
- on(event: string, handler: (event: Record<string, unknown>, ctx?: Record<string, unknown>) => Promise<{ prependContext?: string } | void> | void): void
68
- registerService(options: {
69
- id: string
70
- start: () => void
71
- stop: () => void
72
- }): void
73
- }
74
-
75
- export function stringEnum<T extends string>(values: readonly T[]): unknown
76
- }