@try-works/dsh-righthand 0.1.18 → 0.1.20

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 (63) hide show
  1. package/lib/cards.d.ts +16 -0
  2. package/lib/cards.d.ts.map +1 -0
  3. package/lib/cards.js +18 -0
  4. package/lib/cards.js.map +1 -0
  5. package/lib/client/index.d.ts +14 -0
  6. package/lib/client/index.d.ts.map +1 -0
  7. package/lib/client/index.js +118 -0
  8. package/lib/client/index.js.map +1 -0
  9. package/lib/client.js +373 -0
  10. package/lib/client.js.map +1 -0
  11. package/lib/events-tools.d.ts.map +1 -1
  12. package/lib/events-tools.js +11 -0
  13. package/lib/events-tools.js.map +1 -1
  14. package/lib/exec-tools.d.ts.map +1 -1
  15. package/lib/exec-tools.js +9 -0
  16. package/lib/exec-tools.js.map +1 -1
  17. package/lib/files-tools.d.ts.map +1 -1
  18. package/lib/files-tools.js +11 -0
  19. package/lib/files-tools.js.map +1 -1
  20. package/lib/gui.d.ts +12 -0
  21. package/lib/gui.d.ts.map +1 -0
  22. package/lib/gui.js +160 -0
  23. package/lib/gui.js.map +1 -0
  24. package/lib/index.d.ts +3 -1
  25. package/lib/index.d.ts.map +1 -1
  26. package/lib/index.js +4 -1
  27. package/lib/index.js.map +1 -1
  28. package/lib/notify-tools.d.ts.map +1 -1
  29. package/lib/notify-tools.js +3 -0
  30. package/lib/notify-tools.js.map +1 -1
  31. package/lib/places-tools.d.ts.map +1 -1
  32. package/lib/places-tools.js +9 -0
  33. package/lib/places-tools.js.map +1 -1
  34. package/lib/secrets-tools.d.ts.map +1 -1
  35. package/lib/secrets-tools.js +11 -0
  36. package/lib/secrets-tools.js.map +1 -1
  37. package/lib/store-tools.d.ts.map +1 -1
  38. package/lib/store-tools.js +8 -0
  39. package/lib/store-tools.js.map +1 -1
  40. package/lib/task-tools.d.ts.map +1 -1
  41. package/lib/task-tools.js +11 -0
  42. package/lib/task-tools.js.map +1 -1
  43. package/lib/text-tools.d.ts.map +1 -1
  44. package/lib/text-tools.js +9 -0
  45. package/lib/text-tools.js.map +1 -1
  46. package/lib/weather-tools.d.ts.map +1 -1
  47. package/lib/weather-tools.js +5 -0
  48. package/lib/weather-tools.js.map +1 -1
  49. package/package.json +24 -3
  50. package/src/cards.ts +23 -0
  51. package/src/client/index.ts +184 -0
  52. package/src/events-tools.ts +11 -0
  53. package/src/exec-tools.ts +10 -0
  54. package/src/files-tools.ts +11 -0
  55. package/src/gui.ts +157 -0
  56. package/src/index.ts +4 -1
  57. package/src/notify-tools.ts +3 -0
  58. package/src/places-tools.ts +9 -0
  59. package/src/secrets-tools.ts +11 -0
  60. package/src/store-tools.ts +9 -0
  61. package/src/task-tools.ts +11 -0
  62. package/src/text-tools.ts +9 -0
  63. package/src/weather-tools.ts +5 -0
package/src/task-tools.ts CHANGED
@@ -12,6 +12,7 @@ import { defineTool } from '@deepseek-ai/dsh-tools'
12
12
  import { defineDomain, domainTable } from '@deepseek-ai/dsh-storage-domain'
13
13
  import type { Domain } from '@deepseek-ai/dsh-storage-domain'
14
14
  import { z } from 'zod'
15
+ import { genCall, genResult } from './cards.ts'
15
16
 
16
17
  export const name = 'righthand-task'
17
18
  export const inject = ['tools', 'storageDomain']
@@ -96,6 +97,8 @@ export function apply(ctx: Context): void {
96
97
  },
97
98
  render: (_args, value) => [{ type: 'text', text: 'task ' + value.id + ' created: ' + value.title + ' (open)' }],
98
99
  },
100
+ presentCall: (args: any) => genCall('New task: ' + args.title, 'edit'),
101
+ presentResult: (_args, result) => genResult(result),
99
102
  async execute(args) {
100
103
  const d = await ensure()
101
104
  const now = new Date().toISOString()
@@ -136,6 +139,8 @@ ctx.tools.register(defineTool({
136
139
  },
137
140
  render: (_args, tasks) => [{ type: 'text', text: tasks.length === 0 ? '(no tasks)' : tasks.map((t: any) => '[' + t.state + '] ' + t.title).join(' / ') }],
138
141
  },
142
+ presentCall: () => genCall('Task board', 'read'),
143
+ presentResult: (_args, result) => genResult(result),
139
144
  async execute(args) {
140
145
  const tasks = await all()
141
146
  const wanted = args.state ?? null
@@ -164,6 +169,8 @@ ctx.tools.register(defineTool({
164
169
  },
165
170
  render: (_args, value) => [{ type: 'text', text: value.found ? 'next: ' + value.title : '(nothing open)' }],
166
171
  },
172
+ presentCall: () => genCall('Next task', 'read'),
173
+ presentResult: (_args, result) => genResult(result),
167
174
  async execute() {
168
175
  const tasks = await all()
169
176
  const open = tasks.filter(t => t.state === 'open').sort((a, b) => a.createdAt.localeCompare(b.createdAt))
@@ -192,6 +199,8 @@ ctx.tools.register(defineTool({
192
199
  },
193
200
  render: (_args, value) => [{ type: 'text', text: value.found ? 'task ' + value.id + ' -> ' + value.state : 'task ' + value.id + ' not found' }],
194
201
  },
202
+ presentCall: (args: any) => genCall('Update task ' + args.id, 'edit'),
203
+ presentResult: (_args, result) => genResult(result),
195
204
  async execute(args) {
196
205
  const d = await ensure()
197
206
  const task = d.table('tasks').get(args.id)
@@ -224,6 +233,8 @@ ctx.tools.register(defineTool({
224
233
  },
225
234
  render: (_args, value) => [{ type: 'text', text: 'deleted ' + value.id + ': ' + value.existed }],
226
235
  },
236
+ presentCall: (args: any) => genCall('Delete task ' + args.id, 'delete'),
237
+ presentResult: (_args, result) => genResult(result),
227
238
  async execute(args) {
228
239
  const d = await ensure()
229
240
  const existed = await d.table('tasks').delete(args.id)
package/src/text-tools.ts CHANGED
@@ -11,6 +11,7 @@ import type { Context } from '@deepseek-ai/cordis'
11
11
  import { defineTool } from '@deepseek-ai/dsh-tools'
12
12
  import { BlockAssembler, createUserMessage, deepFreeze } from '@deepseek-ai/dsh-llm'
13
13
  import type { GenerateOptions } from '@deepseek-ai/dsh-llm'
14
+ import { genCall, genResult } from './cards.ts'
14
15
 
15
16
  export const name = 'righthand-text'
16
17
  export const inject = ['tools', 'llm']
@@ -84,6 +85,8 @@ export function apply(ctx: Context, config: TextConfig = {}): void {
84
85
  },
85
86
  render: (_args, value) => [{ type: 'text', text: value.summary }],
86
87
  },
88
+ presentCall: () => genCall('Summarise text', 'execute'),
89
+ presentResult: (_args, result) => genResult(result),
87
90
  async execute(args, exec) {
88
91
  const n = args.sentences ?? 3
89
92
  const summary = await ask(ctx, cfg, SUMMARISE_SYSTEM, 'Summarise this in about ' + n + ' sentences:\n\n' + args.text, 600, exec.signal)
@@ -107,6 +110,8 @@ export function apply(ctx: Context, config: TextConfig = {}): void {
107
110
  },
108
111
  render: (_args, value) => [{ type: 'text', text: JSON.stringify(value.extracted) }],
109
112
  },
113
+ presentCall: () => genCall('Extract per JSON Schema', 'execute'),
114
+ presentResult: (_args, result) => genResult(result),
110
115
  async execute(args, exec) {
111
116
  const framed = 'Schema:\n' + JSON.stringify(args.schema) + '\n\nText:\n' + args.text
112
117
  const raw = await ask(ctx, cfg, EXTRACT_SYSTEM, framed, 800, exec.signal)
@@ -131,6 +136,8 @@ export function apply(ctx: Context, config: TextConfig = {}): void {
131
136
  },
132
137
  render: (_args, value) => [{ type: 'text', text: value.label + ' (' + value.confidence + ')' }],
133
138
  },
139
+ presentCall: () => genCall('Classify text', 'execute'),
140
+ presentResult: (_args, result) => genResult(result),
134
141
  async execute(args, exec) {
135
142
  if (args.labels.length === 0) throw new Error('classify needs at least one label')
136
143
  const framed = 'Labels: ' + JSON.stringify(args.labels) + '\n\nText:\n' + args.text
@@ -159,6 +166,8 @@ export function apply(ctx: Context, config: TextConfig = {}): void {
159
166
  },
160
167
  render: (_args, value) => [{ type: 'text', text: value.translation }],
161
168
  },
169
+ presentCall: (args: any) => genCall('Translate to ' + args.language, 'execute'),
170
+ presentResult: (_args, result) => genResult(result),
162
171
  async execute(args, exec) {
163
172
  const framed = 'Translate the following into ' + args.language + ':\n\n' + args.text
164
173
  const translation = await ask(ctx, cfg, TRANSLATE_SYSTEM, framed, 800, exec.signal)
@@ -15,6 +15,7 @@ import type { Context } from '@deepseek-ai/cordis'
15
15
  import { defineTool } from '@deepseek-ai/dsh-tools'
16
16
  import { lookup } from 'node:dns/promises'
17
17
  import { isIP } from 'node:net'
18
+ import { genCall, genResult } from './cards.ts'
18
19
 
19
20
  export const name = 'righthand-weather'
20
21
  export const inject = ['tools']
@@ -188,6 +189,8 @@ export function apply(ctx: Context, config: WeatherConfig = {}): void {
188
189
  },
189
190
  render: (_args, value) => { const c = value.current as any; return [{ type: 'text', text: c ? (value.timezone + ': ' + c.temperature + ' C, wind ' + c.windspeed + ' km/h') : value.timezone + ': current conditions unavailable' }] },
190
191
  },
192
+ presentCall: (args: any) => genCall('Weather at ' + args.latitude + ', ' + args.longitude, 'fetch'),
193
+ presentResult: (_args, result) => genResult(result),
191
194
  async execute(args) {
192
195
  const url = cfg.forecastUrl
193
196
  + '?latitude=' + args.latitude
@@ -220,6 +223,8 @@ export function apply(ctx: Context, config: WeatherConfig = {}): void {
220
223
  },
221
224
  render: (_args, value) => [{ type: 'text', text: 'PM2.5 ' + value.pm2_5 + ', PM10 ' + value.pm10 + ', AQI ' + value.aqi }],
222
225
  },
226
+ presentCall: (args: any) => genCall('Air quality at ' + args.latitude + ', ' + args.longitude, 'fetch'),
227
+ presentResult: (_args, result) => genResult(result),
223
228
  async execute(args) {
224
229
  const url = cfg.airUrl
225
230
  + '?latitude=' + args.latitude