@try-works/dsh-righthand 0.1.18 → 0.1.19
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/cards.d.ts +16 -0
- package/lib/cards.d.ts.map +1 -0
- package/lib/cards.js +18 -0
- package/lib/cards.js.map +1 -0
- package/lib/events-tools.d.ts.map +1 -1
- package/lib/events-tools.js +11 -0
- package/lib/events-tools.js.map +1 -1
- package/lib/exec-tools.d.ts.map +1 -1
- package/lib/exec-tools.js +9 -0
- package/lib/exec-tools.js.map +1 -1
- package/lib/files-tools.d.ts.map +1 -1
- package/lib/files-tools.js +11 -0
- package/lib/files-tools.js.map +1 -1
- package/lib/notify-tools.d.ts.map +1 -1
- package/lib/notify-tools.js +3 -0
- package/lib/notify-tools.js.map +1 -1
- package/lib/places-tools.d.ts.map +1 -1
- package/lib/places-tools.js +9 -0
- package/lib/places-tools.js.map +1 -1
- package/lib/secrets-tools.d.ts.map +1 -1
- package/lib/secrets-tools.js +11 -0
- package/lib/secrets-tools.js.map +1 -1
- package/lib/store-tools.d.ts.map +1 -1
- package/lib/store-tools.js +8 -0
- package/lib/store-tools.js.map +1 -1
- package/lib/task-tools.d.ts.map +1 -1
- package/lib/task-tools.js +11 -0
- package/lib/task-tools.js.map +1 -1
- package/lib/text-tools.d.ts.map +1 -1
- package/lib/text-tools.js +9 -0
- package/lib/text-tools.js.map +1 -1
- package/lib/weather-tools.d.ts.map +1 -1
- package/lib/weather-tools.js +5 -0
- package/lib/weather-tools.js.map +1 -1
- package/package.json +1 -1
- package/src/cards.ts +23 -0
- package/src/events-tools.ts +11 -0
- package/src/exec-tools.ts +10 -0
- package/src/files-tools.ts +11 -0
- package/src/notify-tools.ts +3 -0
- package/src/places-tools.ts +9 -0
- package/src/secrets-tools.ts +11 -0
- package/src/store-tools.ts +9 -0
- package/src/task-tools.ts +11 -0
- package/src/text-tools.ts +9 -0
- package/src/weather-tools.ts +5 -0
package/src/store-tools.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import type { Context } from '@deepseek-ai/cordis'
|
|
10
10
|
import { defineTool } from '@deepseek-ai/dsh-tools'
|
|
11
|
+
import type { ToolCallView, ToolResultView } from '@deepseek-ai/dsh-tools'
|
|
11
12
|
import { defineDomain, domainTable } from '@deepseek-ai/dsh-storage-domain'
|
|
12
13
|
import type { Domain } from '@deepseek-ai/dsh-storage-domain'
|
|
13
14
|
import { z } from 'zod'
|
|
@@ -110,6 +111,8 @@ export function apply(ctx: Context): void {
|
|
|
110
111
|
},
|
|
111
112
|
render: (_args, value) => [{ type: 'text', text: `stored ${value.key} (writes=${value.writes})` }],
|
|
112
113
|
},
|
|
114
|
+
presentCall: (args: any): ToolCallView => ({ card: 'generic', title: 'Store ' + args.key, kind: 'edit' }),
|
|
115
|
+
presentResult: (_args, result): ToolResultView => ({ card: 'generic', content: result.content }),
|
|
113
116
|
async execute(args) {
|
|
114
117
|
const s = await ensure()
|
|
115
118
|
const row = await s.put(args.key, args.value)
|
|
@@ -136,6 +139,8 @@ export function apply(ctx: Context): void {
|
|
|
136
139
|
},
|
|
137
140
|
render: (_args, value) => [{ type: 'text', text: value.found ? `${value.key} = ${JSON.stringify(value.value)}` : `${value.key} (absent)` }],
|
|
138
141
|
},
|
|
142
|
+
presentCall: (args: any): ToolCallView => ({ card: 'generic', title: 'Read ' + args.key, kind: 'read' }),
|
|
143
|
+
presentResult: (_args, result): ToolResultView => ({ card: 'generic', content: result.content }),
|
|
139
144
|
async execute(args) {
|
|
140
145
|
const s = await ensure()
|
|
141
146
|
const row = await s.get(args.key)
|
|
@@ -161,6 +166,8 @@ export function apply(ctx: Context): void {
|
|
|
161
166
|
},
|
|
162
167
|
render: (_args, value) => [{ type: 'text', text: `deleted ${value.key}: ${value.existed}` }],
|
|
163
168
|
},
|
|
169
|
+
presentCall: (args: any): ToolCallView => ({ card: 'generic', title: 'Delete ' + args.key, kind: 'delete' }),
|
|
170
|
+
presentResult: (_args, result): ToolResultView => ({ card: 'generic', content: result.content }),
|
|
164
171
|
async execute(args) {
|
|
165
172
|
const s = await ensure()
|
|
166
173
|
const existed = await s.delete(args.key)
|
|
@@ -176,6 +183,8 @@ export function apply(ctx: Context): void {
|
|
|
176
183
|
schema: { type: 'array', items: { type: 'string' } },
|
|
177
184
|
render: (_args, keys) => [{ type: 'text', text: keys.length === 0 ? '(empty)' : keys.join('\n') }],
|
|
178
185
|
},
|
|
186
|
+
presentCall: (): ToolCallView => ({ card: 'generic', title: 'List store keys', kind: 'read' }),
|
|
187
|
+
presentResult: (_args, result): ToolResultView => ({ card: 'generic', content: result.content }),
|
|
179
188
|
async execute() {
|
|
180
189
|
const s = await ensure()
|
|
181
190
|
return s.list()
|
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)
|
package/src/weather-tools.ts
CHANGED
|
@@ -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
|