digital-tools 2.1.3 → 2.3.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.
- package/CHANGELOG.md +9 -0
- package/README.md +2 -0
- package/dist/client.d.ts +109 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +69 -0
- package/dist/client.js.map +1 -0
- package/dist/define.d.ts +2 -2
- package/dist/define.d.ts.map +1 -1
- package/dist/define.js +21 -11
- package/dist/define.js.map +1 -1
- package/dist/function-ref.d.ts +229 -0
- package/dist/function-ref.d.ts.map +1 -0
- package/dist/function-ref.js +28 -0
- package/dist/function-ref.js.map +1 -0
- package/dist/function-sugar.d.ts +57 -0
- package/dist/function-sugar.d.ts.map +1 -0
- package/dist/function-sugar.js +79 -0
- package/dist/function-sugar.js.map +1 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -4
- package/dist/index.js.map +1 -1
- package/dist/providers/analytics/mixpanel.d.ts.map +1 -1
- package/dist/providers/analytics/mixpanel.js +21 -18
- package/dist/providers/analytics/mixpanel.js.map +1 -1
- package/dist/providers/calendar/cal-com.d.ts.map +1 -1
- package/dist/providers/calendar/cal-com.js +10 -10
- package/dist/providers/calendar/cal-com.js.map +1 -1
- package/dist/providers/calendar/google-calendar.d.ts.map +1 -1
- package/dist/providers/calendar/google-calendar.js +4 -4
- package/dist/providers/calendar/google-calendar.js.map +1 -1
- package/dist/providers/crm/hubspot.d.ts.map +1 -1
- package/dist/providers/crm/hubspot.js +107 -85
- package/dist/providers/crm/hubspot.js.map +1 -1
- package/dist/providers/development/github.d.ts.map +1 -1
- package/dist/providers/development/github.js +40 -43
- package/dist/providers/development/github.js.map +1 -1
- package/dist/providers/ecommerce/shopify.d.ts.map +1 -1
- package/dist/providers/ecommerce/shopify.js +79 -62
- package/dist/providers/ecommerce/shopify.js.map +1 -1
- package/dist/providers/email/resend.d.ts.map +1 -1
- package/dist/providers/email/resend.js +20 -16
- package/dist/providers/email/resend.js.map +1 -1
- package/dist/providers/email/sendgrid.d.ts.map +1 -1
- package/dist/providers/email/sendgrid.js +12 -9
- package/dist/providers/email/sendgrid.js.map +1 -1
- package/dist/providers/finance/stripe.d.ts.map +1 -1
- package/dist/providers/finance/stripe.js +44 -42
- package/dist/providers/finance/stripe.js.map +1 -1
- package/dist/providers/forms/typeform.d.ts.map +1 -1
- package/dist/providers/forms/typeform.js +68 -58
- package/dist/providers/forms/typeform.js.map +1 -1
- package/dist/providers/knowledge/notion.d.ts.map +1 -1
- package/dist/providers/knowledge/notion.js +75 -41
- package/dist/providers/knowledge/notion.js.map +1 -1
- package/dist/providers/marketing/mailchimp.d.ts.map +1 -1
- package/dist/providers/marketing/mailchimp.js +74 -61
- package/dist/providers/marketing/mailchimp.js.map +1 -1
- package/dist/providers/media/cloudinary.d.ts.map +1 -1
- package/dist/providers/media/cloudinary.js +30 -28
- package/dist/providers/media/cloudinary.js.map +1 -1
- package/dist/providers/messaging/slack.d.ts.map +1 -1
- package/dist/providers/messaging/slack.js +75 -58
- package/dist/providers/messaging/slack.js.map +1 -1
- package/dist/providers/messaging/twilio-sms.d.ts.map +1 -1
- package/dist/providers/messaging/twilio-sms.js +33 -15
- package/dist/providers/messaging/twilio-sms.js.map +1 -1
- package/dist/providers/project-management/linear.d.ts.map +1 -1
- package/dist/providers/project-management/linear.js +31 -27
- package/dist/providers/project-management/linear.js.map +1 -1
- package/dist/providers/spreadsheet/google-sheets.d.ts.map +1 -1
- package/dist/providers/spreadsheet/google-sheets.js +21 -18
- package/dist/providers/spreadsheet/google-sheets.js.map +1 -1
- package/dist/providers/spreadsheet/xlsx.d.ts.map +1 -1
- package/dist/providers/spreadsheet/xlsx.js +4 -4
- package/dist/providers/spreadsheet/xlsx.js.map +1 -1
- package/dist/providers/storage/index.js +1 -0
- package/dist/providers/storage/index.js.map +1 -1
- package/dist/providers/storage/s3.d.ts.map +1 -1
- package/dist/providers/storage/s3.js +36 -27
- package/dist/providers/storage/s3.js.map +1 -1
- package/dist/providers/support/zendesk.d.ts.map +1 -1
- package/dist/providers/support/zendesk.js +24 -25
- package/dist/providers/support/zendesk.js.map +1 -1
- package/dist/providers/tasks/todoist.d.ts.map +1 -1
- package/dist/providers/tasks/todoist.js +18 -18
- package/dist/providers/tasks/todoist.js.map +1 -1
- package/dist/providers/video-conferencing/google-meet.d.ts.map +1 -1
- package/dist/providers/video-conferencing/google-meet.js +11 -11
- package/dist/providers/video-conferencing/google-meet.js.map +1 -1
- package/dist/providers/video-conferencing/jitsi.js +14 -14
- package/dist/providers/video-conferencing/jitsi.js.map +1 -1
- package/dist/providers/video-conferencing/teams.d.ts.map +1 -1
- package/dist/providers/video-conferencing/teams.js +9 -7
- package/dist/providers/video-conferencing/teams.js.map +1 -1
- package/dist/providers/video-conferencing/zoom.d.ts.map +1 -1
- package/dist/providers/video-conferencing/zoom.js +26 -24
- package/dist/providers/video-conferencing/zoom.js.map +1 -1
- package/dist/tools/data.d.ts.map +1 -1
- package/dist/tools/data.js +5 -12
- package/dist/tools/data.js.map +1 -1
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +1 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/system.d.ts +289 -0
- package/dist/tools/system.d.ts.map +1 -0
- package/dist/tools/system.js +752 -0
- package/dist/tools/system.js.map +1 -0
- package/dist/tools/web.d.ts.map +1 -1
- package/dist/tools/web.js +22 -10
- package/dist/tools/web.js.map +1 -1
- package/dist/track-record.d.ts +101 -0
- package/dist/track-record.d.ts.map +1 -0
- package/dist/track-record.js +17 -0
- package/dist/track-record.js.map +1 -0
- package/dist/types.d.ts +210 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/verb-registration.d.ts +122 -0
- package/dist/verb-registration.d.ts.map +1 -0
- package/dist/verb-registration.js +176 -0
- package/dist/verb-registration.js.map +1 -0
- package/dist/worker.d.ts +93 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +315 -0
- package/dist/worker.js.map +1 -0
- package/dist/wrap.d.ts +89 -0
- package/dist/wrap.d.ts.map +1 -0
- package/dist/wrap.js +225 -0
- package/dist/wrap.js.map +1 -0
- package/package.json +31 -14
- package/src/client.ts +136 -0
- package/src/define.ts +30 -24
- package/src/function-ref.ts +264 -0
- package/src/function-sugar.ts +134 -0
- package/src/index.ts +132 -10
- package/src/providers/analytics/mixpanel.ts +19 -18
- package/src/providers/calendar/cal-com.ts +29 -18
- package/src/providers/calendar/google-calendar.ts +20 -14
- package/src/providers/crm/hubspot.ts +225 -99
- package/src/providers/development/github.ts +206 -135
- package/src/providers/ecommerce/shopify.ts +250 -89
- package/src/providers/email/resend.ts +101 -28
- package/src/providers/email/sendgrid.ts +12 -9
- package/src/providers/finance/stripe.ts +128 -49
- package/src/providers/forms/typeform.ts +74 -58
- package/src/providers/knowledge/notion.ts +340 -88
- package/src/providers/marketing/mailchimp.ts +86 -70
- package/src/providers/media/cloudinary.ts +99 -41
- package/src/providers/messaging/slack.ts +283 -85
- package/src/providers/messaging/twilio-sms.ts +35 -15
- package/src/providers/project-management/linear.ts +143 -55
- package/src/providers/spreadsheet/google-sheets.ts +222 -56
- package/src/providers/spreadsheet/xlsx.ts +47 -16
- package/src/providers/storage/s3.ts +119 -47
- package/src/providers/support/zendesk.ts +196 -46
- package/src/providers/tasks/todoist.ts +20 -26
- package/src/providers/video-conferencing/google-meet.ts +17 -20
- package/src/providers/video-conferencing/jitsi.ts +14 -14
- package/src/providers/video-conferencing/teams.ts +14 -13
- package/src/providers/video-conferencing/zoom.ts +54 -49
- package/src/tools/data.ts +6 -16
- package/src/tools/index.ts +1 -0
- package/src/tools/system.ts +887 -0
- package/src/tools/web.ts +22 -10
- package/src/track-record.ts +106 -0
- package/src/types.ts +241 -13
- package/src/verb-registration.ts +197 -0
- package/src/worker.ts +370 -0
- package/src/wrap.ts +260 -0
- package/test/client.test.ts +146 -0
- package/test/communication-tools-extended.test.ts +734 -0
- package/test/data-tools-extended.test.ts +743 -0
- package/test/define-extended.test.ts +819 -0
- package/test/define.test.ts +150 -41
- package/test/entities.test.ts +623 -0
- package/test/extended-entities.test.ts +1228 -0
- package/test/provider-implementations.test.ts +725 -0
- package/test/provider-registry-extended.test.ts +583 -0
- package/test/providers/google-sheets.test.ts +851 -0
- package/test/providers/helpers.ts +554 -0
- package/test/providers/hubspot.test.ts +576 -0
- package/test/providers/slack.test.ts +932 -0
- package/test/providers/stripe.test.ts +701 -0
- package/test/providers.test.ts +578 -0
- package/test/system-tools-extended.test.ts +632 -0
- package/test/system.test.ts +673 -0
- package/test/tools.test.ts +15 -11
- package/test/types.test.ts +402 -0
- package/test/verb-registration.test.ts +395 -0
- package/test/web-tools.test.ts +553 -0
- package/test/worker-extended.test.ts +699 -0
- package/test/worker.test.ts +576 -0
- package/test/wrap.test.ts +366 -0
- package/tsconfig.json +3 -13
- package/vitest.config.ts +37 -0
- package/wrangler.jsonc +9 -0
- package/.turbo/turbo-build.log +0 -4
- package/LICENSE +0 -21
- package/dist/providers/voice/vapi.d.ts +0 -27
- package/dist/providers/voice/vapi.d.ts.map +0 -1
- package/dist/providers/voice/vapi.js +0 -440
- package/dist/providers/voice/vapi.js.map +0 -1
- package/src/define.js +0 -259
- package/src/entities/advertising.js +0 -999
- package/src/entities/ai.js +0 -756
- package/src/entities/analytics.js +0 -1588
- package/src/entities/automation.js +0 -601
- package/src/entities/communication.js +0 -1150
- package/src/entities/crm.js +0 -1386
- package/src/entities/design.js +0 -546
- package/src/entities/development.js +0 -2212
- package/src/entities/document.js +0 -874
- package/src/entities/ecommerce.js +0 -1429
- package/src/entities/experiment.js +0 -1039
- package/src/entities/finance.js +0 -3478
- package/src/entities/forms.js +0 -1892
- package/src/entities/hr.js +0 -661
- package/src/entities/identity.js +0 -997
- package/src/entities/index.js +0 -282
- package/src/entities/infrastructure.js +0 -1153
- package/src/entities/knowledge.js +0 -1438
- package/src/entities/marketing.js +0 -1610
- package/src/entities/media.js +0 -1634
- package/src/entities/notification.js +0 -1199
- package/src/entities/presentation.js +0 -1274
- package/src/entities/productivity.js +0 -1317
- package/src/entities/project-management.js +0 -1136
- package/src/entities/recruiting.js +0 -736
- package/src/entities/shipping.js +0 -509
- package/src/entities/signature.js +0 -1102
- package/src/entities/site.js +0 -222
- package/src/entities/spreadsheet.js +0 -1341
- package/src/entities/storage.js +0 -1198
- package/src/entities/support.js +0 -1166
- package/src/entities/video-conferencing.js +0 -1750
- package/src/entities/video.js +0 -950
- package/src/entities.js +0 -1663
- package/src/index.js +0 -74
- package/src/providers/analytics/index.js +0 -17
- package/src/providers/analytics/mixpanel.js +0 -255
- package/src/providers/calendar/cal-com.js +0 -303
- package/src/providers/calendar/google-calendar.js +0 -335
- package/src/providers/calendar/index.js +0 -20
- package/src/providers/crm/hubspot.js +0 -566
- package/src/providers/crm/index.js +0 -17
- package/src/providers/development/github.js +0 -472
- package/src/providers/development/index.js +0 -17
- package/src/providers/ecommerce/index.js +0 -17
- package/src/providers/ecommerce/shopify.js +0 -378
- package/src/providers/email/index.js +0 -20
- package/src/providers/email/resend.js +0 -258
- package/src/providers/email/sendgrid.js +0 -161
- package/src/providers/finance/index.js +0 -17
- package/src/providers/finance/stripe.js +0 -549
- package/src/providers/forms/index.js +0 -17
- package/src/providers/forms/typeform.js +0 -500
- package/src/providers/index.js +0 -123
- package/src/providers/knowledge/index.js +0 -17
- package/src/providers/knowledge/notion.js +0 -389
- package/src/providers/marketing/index.js +0 -17
- package/src/providers/marketing/mailchimp.js +0 -443
- package/src/providers/media/cloudinary.js +0 -318
- package/src/providers/media/index.js +0 -17
- package/src/providers/messaging/index.js +0 -20
- package/src/providers/messaging/slack.js +0 -393
- package/src/providers/messaging/twilio-sms.js +0 -249
- package/src/providers/project-management/index.js +0 -17
- package/src/providers/project-management/linear.js +0 -575
- package/src/providers/registry.js +0 -86
- package/src/providers/spreadsheet/google-sheets.js +0 -375
- package/src/providers/spreadsheet/index.js +0 -20
- package/src/providers/spreadsheet/xlsx.js +0 -423
- package/src/providers/storage/index.js +0 -24
- package/src/providers/storage/s3.js +0 -419
- package/src/providers/support/index.js +0 -17
- package/src/providers/support/zendesk.js +0 -373
- package/src/providers/tasks/index.js +0 -17
- package/src/providers/tasks/todoist.js +0 -286
- package/src/providers/types.js +0 -9
- package/src/providers/video-conferencing/google-meet.js +0 -286
- package/src/providers/video-conferencing/index.js +0 -31
- package/src/providers/video-conferencing/jitsi.js +0 -254
- package/src/providers/video-conferencing/teams.js +0 -270
- package/src/providers/video-conferencing/zoom.js +0 -332
- package/src/registry.js +0 -128
- package/src/tools/communication.js +0 -184
- package/src/tools/data.js +0 -205
- package/src/tools/index.js +0 -11
- package/src/tools/web.js +0 -137
- package/src/types.js +0 -10
- package/test/define.test.js +0 -306
- package/test/registry.test.js +0 -357
- package/test/tools.test.js +0 -363
|
@@ -0,0 +1,887 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System Tools - Filesystem, Git, and Shell operations
|
|
3
|
+
*
|
|
4
|
+
* Integrates fsx.do, gitx.do, and bashx.do primitives for the dotdo ecosystem.
|
|
5
|
+
* These tools provide edge-compatible filesystem, git, and bash operations
|
|
6
|
+
* that work in Cloudflare Workers and Durable Objects.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { defineTool } from '../define.js'
|
|
12
|
+
import type { AnyTool } from '../types.js'
|
|
13
|
+
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// Filesystem Tools (fsx.do integration)
|
|
16
|
+
// ============================================================================
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Read file contents from the virtual filesystem
|
|
20
|
+
*/
|
|
21
|
+
export const fsRead = defineTool<
|
|
22
|
+
{ path: string; encoding?: 'utf-8' | 'binary' | 'base64' },
|
|
23
|
+
{ content: string; size: number; encoding: string }
|
|
24
|
+
>({
|
|
25
|
+
id: 'system.fs.read',
|
|
26
|
+
name: 'Read File',
|
|
27
|
+
description: 'Read contents of a file from the virtual filesystem (fsx.do)',
|
|
28
|
+
category: 'system',
|
|
29
|
+
subcategory: 'filesystem',
|
|
30
|
+
input: {
|
|
31
|
+
type: 'object',
|
|
32
|
+
properties: {
|
|
33
|
+
path: { type: 'string', description: 'Path to the file to read' },
|
|
34
|
+
encoding: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
description: 'Encoding for the file content',
|
|
37
|
+
enum: ['utf-8', 'binary', 'base64'],
|
|
38
|
+
default: 'utf-8',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
required: ['path'],
|
|
42
|
+
},
|
|
43
|
+
handler: async (input) => {
|
|
44
|
+
// Placeholder - actual implementation will use @dotdo/fsx
|
|
45
|
+
// In production, this connects to the fsx.do Durable Object
|
|
46
|
+
const encoding = input.encoding || 'utf-8'
|
|
47
|
+
return {
|
|
48
|
+
content: `[fsx.do] Content of ${input.path}`,
|
|
49
|
+
size: 0,
|
|
50
|
+
encoding,
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
options: {
|
|
54
|
+
audience: 'both',
|
|
55
|
+
tags: ['fs', 'read', 'file', 'fsx'],
|
|
56
|
+
idempotent: true,
|
|
57
|
+
},
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Write content to a file in the virtual filesystem
|
|
62
|
+
*/
|
|
63
|
+
export const fsWrite = defineTool<
|
|
64
|
+
{ path: string; content: string; encoding?: 'utf-8' | 'binary' | 'base64'; createDirs?: boolean },
|
|
65
|
+
{ success: boolean; path: string; size: number }
|
|
66
|
+
>({
|
|
67
|
+
id: 'system.fs.write',
|
|
68
|
+
name: 'Write File',
|
|
69
|
+
description: 'Write content to a file in the virtual filesystem (fsx.do)',
|
|
70
|
+
category: 'system',
|
|
71
|
+
subcategory: 'filesystem',
|
|
72
|
+
input: {
|
|
73
|
+
type: 'object',
|
|
74
|
+
properties: {
|
|
75
|
+
path: { type: 'string', description: 'Path to write the file' },
|
|
76
|
+
content: { type: 'string', description: 'Content to write' },
|
|
77
|
+
encoding: {
|
|
78
|
+
type: 'string',
|
|
79
|
+
description: 'Encoding for the content',
|
|
80
|
+
enum: ['utf-8', 'binary', 'base64'],
|
|
81
|
+
default: 'utf-8',
|
|
82
|
+
},
|
|
83
|
+
createDirs: {
|
|
84
|
+
type: 'boolean',
|
|
85
|
+
description: 'Create parent directories if they do not exist',
|
|
86
|
+
default: true,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
required: ['path', 'content'],
|
|
90
|
+
},
|
|
91
|
+
handler: async (input) => {
|
|
92
|
+
// Placeholder - actual implementation will use @dotdo/fsx
|
|
93
|
+
return {
|
|
94
|
+
success: true,
|
|
95
|
+
path: input.path,
|
|
96
|
+
size: input.content.length,
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
options: {
|
|
100
|
+
audience: 'both',
|
|
101
|
+
tags: ['fs', 'write', 'file', 'fsx'],
|
|
102
|
+
permissions: [{ type: 'write', resource: 'filesystem' }],
|
|
103
|
+
},
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* List directory contents
|
|
108
|
+
*/
|
|
109
|
+
export const fsList = defineTool<
|
|
110
|
+
{ path: string; recursive?: boolean; pattern?: string },
|
|
111
|
+
{
|
|
112
|
+
entries: Array<{ name: string; type: 'file' | 'directory'; size?: number; modified?: string }>
|
|
113
|
+
count: number
|
|
114
|
+
}
|
|
115
|
+
>({
|
|
116
|
+
id: 'system.fs.list',
|
|
117
|
+
name: 'List Directory',
|
|
118
|
+
description: 'List contents of a directory in the virtual filesystem (fsx.do)',
|
|
119
|
+
category: 'system',
|
|
120
|
+
subcategory: 'filesystem',
|
|
121
|
+
input: {
|
|
122
|
+
type: 'object',
|
|
123
|
+
properties: {
|
|
124
|
+
path: { type: 'string', description: 'Directory path to list' },
|
|
125
|
+
recursive: { type: 'boolean', description: 'List recursively', default: false },
|
|
126
|
+
pattern: { type: 'string', description: 'Glob pattern to filter results' },
|
|
127
|
+
},
|
|
128
|
+
required: ['path'],
|
|
129
|
+
},
|
|
130
|
+
handler: async (input) => {
|
|
131
|
+
// Placeholder - actual implementation will use @dotdo/fsx
|
|
132
|
+
return {
|
|
133
|
+
entries: [],
|
|
134
|
+
count: 0,
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
options: {
|
|
138
|
+
audience: 'both',
|
|
139
|
+
tags: ['fs', 'list', 'directory', 'fsx'],
|
|
140
|
+
idempotent: true,
|
|
141
|
+
},
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Delete a file or directory
|
|
146
|
+
*/
|
|
147
|
+
export const fsDelete = defineTool<
|
|
148
|
+
{ path: string; recursive?: boolean },
|
|
149
|
+
{ success: boolean; path: string; deleted: number }
|
|
150
|
+
>({
|
|
151
|
+
id: 'system.fs.delete',
|
|
152
|
+
name: 'Delete File/Directory',
|
|
153
|
+
description: 'Delete a file or directory from the virtual filesystem (fsx.do)',
|
|
154
|
+
category: 'system',
|
|
155
|
+
subcategory: 'filesystem',
|
|
156
|
+
input: {
|
|
157
|
+
type: 'object',
|
|
158
|
+
properties: {
|
|
159
|
+
path: { type: 'string', description: 'Path to delete' },
|
|
160
|
+
recursive: { type: 'boolean', description: 'Delete directories recursively', default: false },
|
|
161
|
+
},
|
|
162
|
+
required: ['path'],
|
|
163
|
+
},
|
|
164
|
+
handler: async (input) => {
|
|
165
|
+
// Placeholder - actual implementation will use @dotdo/fsx
|
|
166
|
+
return {
|
|
167
|
+
success: true,
|
|
168
|
+
path: input.path,
|
|
169
|
+
deleted: 1,
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
options: {
|
|
173
|
+
audience: 'both',
|
|
174
|
+
tags: ['fs', 'delete', 'remove', 'fsx'],
|
|
175
|
+
permissions: [{ type: 'write', resource: 'filesystem' }],
|
|
176
|
+
requiresConfirmation: true,
|
|
177
|
+
},
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Search files using glob patterns
|
|
182
|
+
*/
|
|
183
|
+
export const fsGlob = defineTool<
|
|
184
|
+
{ pattern: string; cwd?: string },
|
|
185
|
+
{ matches: string[]; count: number }
|
|
186
|
+
>({
|
|
187
|
+
id: 'system.fs.glob',
|
|
188
|
+
name: 'Glob Search',
|
|
189
|
+
description: 'Search for files using glob patterns (fsx.do)',
|
|
190
|
+
category: 'system',
|
|
191
|
+
subcategory: 'filesystem',
|
|
192
|
+
input: {
|
|
193
|
+
type: 'object',
|
|
194
|
+
properties: {
|
|
195
|
+
pattern: { type: 'string', description: 'Glob pattern (e.g., "**/*.ts")' },
|
|
196
|
+
cwd: { type: 'string', description: 'Working directory for the search' },
|
|
197
|
+
},
|
|
198
|
+
required: ['pattern'],
|
|
199
|
+
},
|
|
200
|
+
handler: async (input) => {
|
|
201
|
+
// Placeholder - actual implementation will use @dotdo/fsx
|
|
202
|
+
return {
|
|
203
|
+
matches: [],
|
|
204
|
+
count: 0,
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
options: {
|
|
208
|
+
audience: 'both',
|
|
209
|
+
tags: ['fs', 'glob', 'search', 'fsx'],
|
|
210
|
+
idempotent: true,
|
|
211
|
+
},
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Search file contents using grep
|
|
216
|
+
*/
|
|
217
|
+
export const fsGrep = defineTool<
|
|
218
|
+
{ pattern: string; path?: string; recursive?: boolean; ignoreCase?: boolean },
|
|
219
|
+
{ matches: Array<{ file: string; line: number; content: string }>; count: number }
|
|
220
|
+
>({
|
|
221
|
+
id: 'system.fs.grep',
|
|
222
|
+
name: 'Grep Search',
|
|
223
|
+
description: 'Search file contents using regular expressions (fsx.do)',
|
|
224
|
+
category: 'system',
|
|
225
|
+
subcategory: 'filesystem',
|
|
226
|
+
input: {
|
|
227
|
+
type: 'object',
|
|
228
|
+
properties: {
|
|
229
|
+
pattern: { type: 'string', description: 'Search pattern (regex)' },
|
|
230
|
+
path: { type: 'string', description: 'Path to search in' },
|
|
231
|
+
recursive: { type: 'boolean', description: 'Search recursively', default: true },
|
|
232
|
+
ignoreCase: { type: 'boolean', description: 'Case-insensitive search', default: false },
|
|
233
|
+
},
|
|
234
|
+
required: ['pattern'],
|
|
235
|
+
},
|
|
236
|
+
handler: async (input) => {
|
|
237
|
+
// Placeholder - actual implementation will use @dotdo/fsx
|
|
238
|
+
return {
|
|
239
|
+
matches: [],
|
|
240
|
+
count: 0,
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
options: {
|
|
244
|
+
audience: 'both',
|
|
245
|
+
tags: ['fs', 'grep', 'search', 'regex', 'fsx'],
|
|
246
|
+
idempotent: true,
|
|
247
|
+
},
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
// ============================================================================
|
|
251
|
+
// Git Tools (gitx.do integration)
|
|
252
|
+
// ============================================================================
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Initialize a git repository
|
|
256
|
+
*/
|
|
257
|
+
export const gitInit = defineTool<
|
|
258
|
+
{ path?: string; bare?: boolean },
|
|
259
|
+
{ success: boolean; path: string }
|
|
260
|
+
>({
|
|
261
|
+
id: 'system.git.init',
|
|
262
|
+
name: 'Git Init',
|
|
263
|
+
description: 'Initialize a new git repository (gitx.do)',
|
|
264
|
+
category: 'development',
|
|
265
|
+
subcategory: 'git',
|
|
266
|
+
input: {
|
|
267
|
+
type: 'object',
|
|
268
|
+
properties: {
|
|
269
|
+
path: { type: 'string', description: 'Path for the repository' },
|
|
270
|
+
bare: { type: 'boolean', description: 'Create a bare repository', default: false },
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
handler: async (input) => {
|
|
274
|
+
// Placeholder - actual implementation will use @dotdo/gitx
|
|
275
|
+
return {
|
|
276
|
+
success: true,
|
|
277
|
+
path: input.path || '.',
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
options: {
|
|
281
|
+
audience: 'both',
|
|
282
|
+
tags: ['git', 'init', 'repository', 'gitx'],
|
|
283
|
+
permissions: [{ type: 'write', resource: 'git' }],
|
|
284
|
+
},
|
|
285
|
+
})
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Clone a git repository
|
|
289
|
+
*/
|
|
290
|
+
export const gitClone = defineTool<
|
|
291
|
+
{ url: string; path?: string; branch?: string; depth?: number },
|
|
292
|
+
{ success: boolean; path: string; branch: string }
|
|
293
|
+
>({
|
|
294
|
+
id: 'system.git.clone',
|
|
295
|
+
name: 'Git Clone',
|
|
296
|
+
description: 'Clone a git repository (gitx.do)',
|
|
297
|
+
category: 'development',
|
|
298
|
+
subcategory: 'git',
|
|
299
|
+
input: {
|
|
300
|
+
type: 'object',
|
|
301
|
+
properties: {
|
|
302
|
+
url: { type: 'string', description: 'Repository URL to clone' },
|
|
303
|
+
path: { type: 'string', description: 'Local path for the clone' },
|
|
304
|
+
branch: { type: 'string', description: 'Branch to checkout' },
|
|
305
|
+
depth: { type: 'number', description: 'Shallow clone depth' },
|
|
306
|
+
},
|
|
307
|
+
required: ['url'],
|
|
308
|
+
},
|
|
309
|
+
handler: async (input) => {
|
|
310
|
+
// Placeholder - actual implementation will use @dotdo/gitx
|
|
311
|
+
return {
|
|
312
|
+
success: true,
|
|
313
|
+
path: input.path || '.',
|
|
314
|
+
branch: input.branch || 'main',
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
options: {
|
|
318
|
+
audience: 'both',
|
|
319
|
+
tags: ['git', 'clone', 'repository', 'gitx'],
|
|
320
|
+
permissions: [{ type: 'write', resource: 'git' }],
|
|
321
|
+
},
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Get git repository status
|
|
326
|
+
*/
|
|
327
|
+
export const gitStatus = defineTool<
|
|
328
|
+
{ path?: string },
|
|
329
|
+
{
|
|
330
|
+
branch: string
|
|
331
|
+
clean: boolean
|
|
332
|
+
staged: string[]
|
|
333
|
+
modified: string[]
|
|
334
|
+
untracked: string[]
|
|
335
|
+
ahead: number
|
|
336
|
+
behind: number
|
|
337
|
+
}
|
|
338
|
+
>({
|
|
339
|
+
id: 'system.git.status',
|
|
340
|
+
name: 'Git Status',
|
|
341
|
+
description: 'Get the status of a git repository (gitx.do)',
|
|
342
|
+
category: 'development',
|
|
343
|
+
subcategory: 'git',
|
|
344
|
+
input: {
|
|
345
|
+
type: 'object',
|
|
346
|
+
properties: {
|
|
347
|
+
path: { type: 'string', description: 'Repository path' },
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
|
+
handler: async (input) => {
|
|
351
|
+
// Placeholder - actual implementation will use @dotdo/gitx
|
|
352
|
+
return {
|
|
353
|
+
branch: 'main',
|
|
354
|
+
clean: true,
|
|
355
|
+
staged: [],
|
|
356
|
+
modified: [],
|
|
357
|
+
untracked: [],
|
|
358
|
+
ahead: 0,
|
|
359
|
+
behind: 0,
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
options: {
|
|
363
|
+
audience: 'both',
|
|
364
|
+
tags: ['git', 'status', 'gitx'],
|
|
365
|
+
idempotent: true,
|
|
366
|
+
},
|
|
367
|
+
})
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Stage files for commit
|
|
371
|
+
*/
|
|
372
|
+
export const gitAdd = defineTool<
|
|
373
|
+
{ files: string[]; path?: string },
|
|
374
|
+
{ success: boolean; staged: string[] }
|
|
375
|
+
>({
|
|
376
|
+
id: 'system.git.add',
|
|
377
|
+
name: 'Git Add',
|
|
378
|
+
description: 'Stage files for commit (gitx.do)',
|
|
379
|
+
category: 'development',
|
|
380
|
+
subcategory: 'git',
|
|
381
|
+
input: {
|
|
382
|
+
type: 'object',
|
|
383
|
+
properties: {
|
|
384
|
+
files: {
|
|
385
|
+
type: 'array',
|
|
386
|
+
items: { type: 'string' },
|
|
387
|
+
description: 'Files to stage (use "." for all)',
|
|
388
|
+
},
|
|
389
|
+
path: { type: 'string', description: 'Repository path' },
|
|
390
|
+
},
|
|
391
|
+
required: ['files'],
|
|
392
|
+
},
|
|
393
|
+
handler: async (input) => {
|
|
394
|
+
// Placeholder - actual implementation will use @dotdo/gitx
|
|
395
|
+
return {
|
|
396
|
+
success: true,
|
|
397
|
+
staged: input.files,
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
options: {
|
|
401
|
+
audience: 'both',
|
|
402
|
+
tags: ['git', 'add', 'stage', 'gitx'],
|
|
403
|
+
permissions: [{ type: 'write', resource: 'git' }],
|
|
404
|
+
},
|
|
405
|
+
})
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Create a commit
|
|
409
|
+
*/
|
|
410
|
+
export const gitCommit = defineTool<
|
|
411
|
+
{ message: string; path?: string; author?: { name: string; email: string } },
|
|
412
|
+
{ success: boolean; sha: string; message: string }
|
|
413
|
+
>({
|
|
414
|
+
id: 'system.git.commit',
|
|
415
|
+
name: 'Git Commit',
|
|
416
|
+
description: 'Create a new commit (gitx.do)',
|
|
417
|
+
category: 'development',
|
|
418
|
+
subcategory: 'git',
|
|
419
|
+
input: {
|
|
420
|
+
type: 'object',
|
|
421
|
+
properties: {
|
|
422
|
+
message: { type: 'string', description: 'Commit message' },
|
|
423
|
+
path: { type: 'string', description: 'Repository path' },
|
|
424
|
+
author: {
|
|
425
|
+
type: 'object',
|
|
426
|
+
properties: {
|
|
427
|
+
name: { type: 'string' },
|
|
428
|
+
email: { type: 'string' },
|
|
429
|
+
},
|
|
430
|
+
description: 'Commit author',
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
required: ['message'],
|
|
434
|
+
},
|
|
435
|
+
handler: async (input) => {
|
|
436
|
+
// Placeholder - actual implementation will use @dotdo/gitx
|
|
437
|
+
return {
|
|
438
|
+
success: true,
|
|
439
|
+
sha: 'abc1234',
|
|
440
|
+
message: input.message,
|
|
441
|
+
}
|
|
442
|
+
},
|
|
443
|
+
options: {
|
|
444
|
+
audience: 'both',
|
|
445
|
+
tags: ['git', 'commit', 'gitx'],
|
|
446
|
+
permissions: [{ type: 'write', resource: 'git' }],
|
|
447
|
+
},
|
|
448
|
+
})
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Get commit log
|
|
452
|
+
*/
|
|
453
|
+
export const gitLog = defineTool<
|
|
454
|
+
{ path?: string; limit?: number; branch?: string },
|
|
455
|
+
{
|
|
456
|
+
commits: Array<{
|
|
457
|
+
sha: string
|
|
458
|
+
message: string
|
|
459
|
+
author: { name: string; email: string }
|
|
460
|
+
date: string
|
|
461
|
+
}>
|
|
462
|
+
}
|
|
463
|
+
>({
|
|
464
|
+
id: 'system.git.log',
|
|
465
|
+
name: 'Git Log',
|
|
466
|
+
description: 'Get commit history (gitx.do)',
|
|
467
|
+
category: 'development',
|
|
468
|
+
subcategory: 'git',
|
|
469
|
+
input: {
|
|
470
|
+
type: 'object',
|
|
471
|
+
properties: {
|
|
472
|
+
path: { type: 'string', description: 'Repository path' },
|
|
473
|
+
limit: { type: 'number', description: 'Maximum number of commits', default: 10 },
|
|
474
|
+
branch: { type: 'string', description: 'Branch to get log from' },
|
|
475
|
+
},
|
|
476
|
+
},
|
|
477
|
+
handler: async (input) => {
|
|
478
|
+
// Placeholder - actual implementation will use @dotdo/gitx
|
|
479
|
+
return {
|
|
480
|
+
commits: [],
|
|
481
|
+
}
|
|
482
|
+
},
|
|
483
|
+
options: {
|
|
484
|
+
audience: 'both',
|
|
485
|
+
tags: ['git', 'log', 'history', 'gitx'],
|
|
486
|
+
idempotent: true,
|
|
487
|
+
},
|
|
488
|
+
})
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Show diff between commits or working tree
|
|
492
|
+
*/
|
|
493
|
+
export const gitDiff = defineTool<
|
|
494
|
+
{ path?: string; from?: string; to?: string; file?: string },
|
|
495
|
+
{ diff: string; additions: number; deletions: number; files: string[] }
|
|
496
|
+
>({
|
|
497
|
+
id: 'system.git.diff',
|
|
498
|
+
name: 'Git Diff',
|
|
499
|
+
description: 'Show differences between commits or working tree (gitx.do)',
|
|
500
|
+
category: 'development',
|
|
501
|
+
subcategory: 'git',
|
|
502
|
+
input: {
|
|
503
|
+
type: 'object',
|
|
504
|
+
properties: {
|
|
505
|
+
path: { type: 'string', description: 'Repository path' },
|
|
506
|
+
from: { type: 'string', description: 'From commit/ref' },
|
|
507
|
+
to: { type: 'string', description: 'To commit/ref' },
|
|
508
|
+
file: { type: 'string', description: 'Specific file to diff' },
|
|
509
|
+
},
|
|
510
|
+
},
|
|
511
|
+
handler: async (input) => {
|
|
512
|
+
// Placeholder - actual implementation will use @dotdo/gitx
|
|
513
|
+
return {
|
|
514
|
+
diff: '',
|
|
515
|
+
additions: 0,
|
|
516
|
+
deletions: 0,
|
|
517
|
+
files: [],
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
options: {
|
|
521
|
+
audience: 'both',
|
|
522
|
+
tags: ['git', 'diff', 'gitx'],
|
|
523
|
+
idempotent: true,
|
|
524
|
+
},
|
|
525
|
+
})
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Checkout a branch or commit
|
|
529
|
+
*/
|
|
530
|
+
export const gitCheckout = defineTool<
|
|
531
|
+
{ ref: string; path?: string; create?: boolean },
|
|
532
|
+
{ success: boolean; ref: string }
|
|
533
|
+
>({
|
|
534
|
+
id: 'system.git.checkout',
|
|
535
|
+
name: 'Git Checkout',
|
|
536
|
+
description: 'Checkout a branch or commit (gitx.do)',
|
|
537
|
+
category: 'development',
|
|
538
|
+
subcategory: 'git',
|
|
539
|
+
input: {
|
|
540
|
+
type: 'object',
|
|
541
|
+
properties: {
|
|
542
|
+
ref: { type: 'string', description: 'Branch, tag, or commit to checkout' },
|
|
543
|
+
path: { type: 'string', description: 'Repository path' },
|
|
544
|
+
create: { type: 'boolean', description: 'Create new branch (-b flag)', default: false },
|
|
545
|
+
},
|
|
546
|
+
required: ['ref'],
|
|
547
|
+
},
|
|
548
|
+
handler: async (input) => {
|
|
549
|
+
// Placeholder - actual implementation will use @dotdo/gitx
|
|
550
|
+
return {
|
|
551
|
+
success: true,
|
|
552
|
+
ref: input.ref,
|
|
553
|
+
}
|
|
554
|
+
},
|
|
555
|
+
options: {
|
|
556
|
+
audience: 'both',
|
|
557
|
+
tags: ['git', 'checkout', 'branch', 'gitx'],
|
|
558
|
+
permissions: [{ type: 'write', resource: 'git' }],
|
|
559
|
+
},
|
|
560
|
+
})
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Push commits to remote
|
|
564
|
+
*/
|
|
565
|
+
export const gitPush = defineTool<
|
|
566
|
+
{ path?: string; remote?: string; branch?: string; force?: boolean },
|
|
567
|
+
{ success: boolean; remote: string; branch: string; commits: number }
|
|
568
|
+
>({
|
|
569
|
+
id: 'system.git.push',
|
|
570
|
+
name: 'Git Push',
|
|
571
|
+
description: 'Push commits to a remote repository (gitx.do)',
|
|
572
|
+
category: 'development',
|
|
573
|
+
subcategory: 'git',
|
|
574
|
+
input: {
|
|
575
|
+
type: 'object',
|
|
576
|
+
properties: {
|
|
577
|
+
path: { type: 'string', description: 'Repository path' },
|
|
578
|
+
remote: { type: 'string', description: 'Remote name', default: 'origin' },
|
|
579
|
+
branch: { type: 'string', description: 'Branch to push' },
|
|
580
|
+
force: { type: 'boolean', description: 'Force push', default: false },
|
|
581
|
+
},
|
|
582
|
+
},
|
|
583
|
+
handler: async (input) => {
|
|
584
|
+
// Placeholder - actual implementation will use @dotdo/gitx
|
|
585
|
+
return {
|
|
586
|
+
success: true,
|
|
587
|
+
remote: input.remote || 'origin',
|
|
588
|
+
branch: input.branch || 'main',
|
|
589
|
+
commits: 0,
|
|
590
|
+
}
|
|
591
|
+
},
|
|
592
|
+
options: {
|
|
593
|
+
audience: 'both',
|
|
594
|
+
tags: ['git', 'push', 'remote', 'gitx'],
|
|
595
|
+
permissions: [{ type: 'write', resource: 'git' }],
|
|
596
|
+
requiresConfirmation: true,
|
|
597
|
+
},
|
|
598
|
+
})
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Pull commits from remote
|
|
602
|
+
*/
|
|
603
|
+
export const gitPull = defineTool<
|
|
604
|
+
{ path?: string; remote?: string; branch?: string; rebase?: boolean },
|
|
605
|
+
{ success: boolean; remote: string; branch: string; commits: number; conflicts: string[] }
|
|
606
|
+
>({
|
|
607
|
+
id: 'system.git.pull',
|
|
608
|
+
name: 'Git Pull',
|
|
609
|
+
description: 'Pull commits from a remote repository (gitx.do)',
|
|
610
|
+
category: 'development',
|
|
611
|
+
subcategory: 'git',
|
|
612
|
+
input: {
|
|
613
|
+
type: 'object',
|
|
614
|
+
properties: {
|
|
615
|
+
path: { type: 'string', description: 'Repository path' },
|
|
616
|
+
remote: { type: 'string', description: 'Remote name', default: 'origin' },
|
|
617
|
+
branch: { type: 'string', description: 'Branch to pull' },
|
|
618
|
+
rebase: { type: 'boolean', description: 'Rebase instead of merge', default: false },
|
|
619
|
+
},
|
|
620
|
+
},
|
|
621
|
+
handler: async (input) => {
|
|
622
|
+
// Placeholder - actual implementation will use @dotdo/gitx
|
|
623
|
+
return {
|
|
624
|
+
success: true,
|
|
625
|
+
remote: input.remote || 'origin',
|
|
626
|
+
branch: input.branch || 'main',
|
|
627
|
+
commits: 0,
|
|
628
|
+
conflicts: [],
|
|
629
|
+
}
|
|
630
|
+
},
|
|
631
|
+
options: {
|
|
632
|
+
audience: 'both',
|
|
633
|
+
tags: ['git', 'pull', 'remote', 'gitx'],
|
|
634
|
+
permissions: [{ type: 'write', resource: 'git' }],
|
|
635
|
+
},
|
|
636
|
+
})
|
|
637
|
+
|
|
638
|
+
// ============================================================================
|
|
639
|
+
// Shell/Bash Tools (bashx.do integration)
|
|
640
|
+
// ============================================================================
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Execute a bash command with AI-enhanced safety
|
|
644
|
+
*/
|
|
645
|
+
export const bashExec = defineTool<
|
|
646
|
+
{
|
|
647
|
+
command: string
|
|
648
|
+
cwd?: string
|
|
649
|
+
env?: Record<string, string>
|
|
650
|
+
timeout?: number
|
|
651
|
+
stdin?: string
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
stdout: string
|
|
655
|
+
stderr: string
|
|
656
|
+
exitCode: number
|
|
657
|
+
duration: number
|
|
658
|
+
}
|
|
659
|
+
>({
|
|
660
|
+
id: 'system.bash.exec',
|
|
661
|
+
name: 'Execute Bash Command',
|
|
662
|
+
description: 'Execute a bash command with AI-enhanced safety and intent understanding (bashx.do)',
|
|
663
|
+
category: 'system',
|
|
664
|
+
subcategory: 'shell',
|
|
665
|
+
input: {
|
|
666
|
+
type: 'object',
|
|
667
|
+
properties: {
|
|
668
|
+
command: { type: 'string', description: 'Command to execute' },
|
|
669
|
+
cwd: { type: 'string', description: 'Working directory' },
|
|
670
|
+
env: {
|
|
671
|
+
type: 'object',
|
|
672
|
+
additionalProperties: { type: 'string' },
|
|
673
|
+
description: 'Environment variables',
|
|
674
|
+
},
|
|
675
|
+
timeout: { type: 'number', description: 'Timeout in milliseconds', default: 30000 },
|
|
676
|
+
stdin: { type: 'string', description: 'Standard input to provide' },
|
|
677
|
+
},
|
|
678
|
+
required: ['command'],
|
|
679
|
+
},
|
|
680
|
+
handler: async (input) => {
|
|
681
|
+
// Placeholder - actual implementation will use bashx.do
|
|
682
|
+
// bashx.do provides:
|
|
683
|
+
// - AI safety analysis (warns about destructive commands)
|
|
684
|
+
// - Intent understanding (suggests corrections)
|
|
685
|
+
// - Intelligent error recovery
|
|
686
|
+
return {
|
|
687
|
+
stdout: `[bashx.do] Would execute: ${input.command}`,
|
|
688
|
+
stderr: '',
|
|
689
|
+
exitCode: 0,
|
|
690
|
+
duration: 0,
|
|
691
|
+
}
|
|
692
|
+
},
|
|
693
|
+
options: {
|
|
694
|
+
audience: 'both',
|
|
695
|
+
tags: ['bash', 'shell', 'exec', 'command', 'bashx'],
|
|
696
|
+
permissions: [{ type: 'execute', resource: 'shell' }],
|
|
697
|
+
requiresConfirmation: true,
|
|
698
|
+
securityLevel: 'restricted',
|
|
699
|
+
},
|
|
700
|
+
})
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* Analyze command safety before execution
|
|
704
|
+
*/
|
|
705
|
+
export const bashAnalyze = defineTool<
|
|
706
|
+
{ command: string },
|
|
707
|
+
{
|
|
708
|
+
safe: boolean
|
|
709
|
+
riskLevel: 'low' | 'medium' | 'high' | 'critical'
|
|
710
|
+
warnings: string[]
|
|
711
|
+
suggestions: string[]
|
|
712
|
+
intent: string
|
|
713
|
+
}
|
|
714
|
+
>({
|
|
715
|
+
id: 'system.bash.analyze',
|
|
716
|
+
name: 'Analyze Bash Command',
|
|
717
|
+
description: 'Analyze a bash command for safety using AI (bashx.do)',
|
|
718
|
+
category: 'system',
|
|
719
|
+
subcategory: 'shell',
|
|
720
|
+
input: {
|
|
721
|
+
type: 'object',
|
|
722
|
+
properties: {
|
|
723
|
+
command: { type: 'string', description: 'Command to analyze' },
|
|
724
|
+
},
|
|
725
|
+
required: ['command'],
|
|
726
|
+
},
|
|
727
|
+
handler: async (input) => {
|
|
728
|
+
// Placeholder - actual implementation will use bashx.do AI analysis
|
|
729
|
+
// Detect patterns like:
|
|
730
|
+
// - rm -rf / (destructive)
|
|
731
|
+
// - chmod 777 (security risk)
|
|
732
|
+
// - curl | bash (execution risk)
|
|
733
|
+
const warnings: string[] = []
|
|
734
|
+
let riskLevel: 'low' | 'medium' | 'high' | 'critical' = 'low'
|
|
735
|
+
|
|
736
|
+
if (input.command.includes('rm -rf')) {
|
|
737
|
+
warnings.push('Recursive force delete detected')
|
|
738
|
+
riskLevel = 'high'
|
|
739
|
+
}
|
|
740
|
+
if (input.command.includes('chmod 777')) {
|
|
741
|
+
warnings.push('Overly permissive file permissions')
|
|
742
|
+
riskLevel = 'medium'
|
|
743
|
+
}
|
|
744
|
+
if (input.command.includes('| bash') || input.command.includes('| sh')) {
|
|
745
|
+
warnings.push('Pipe to shell execution detected')
|
|
746
|
+
riskLevel = 'high'
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
return {
|
|
750
|
+
safe: warnings.length === 0,
|
|
751
|
+
riskLevel,
|
|
752
|
+
warnings,
|
|
753
|
+
suggestions: [],
|
|
754
|
+
intent: `Execute: ${input.command}`,
|
|
755
|
+
}
|
|
756
|
+
},
|
|
757
|
+
options: {
|
|
758
|
+
audience: 'both',
|
|
759
|
+
tags: ['bash', 'safety', 'analyze', 'bashx'],
|
|
760
|
+
idempotent: true,
|
|
761
|
+
},
|
|
762
|
+
})
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* Execute a script file
|
|
766
|
+
*/
|
|
767
|
+
export const bashScript = defineTool<
|
|
768
|
+
{
|
|
769
|
+
script: string
|
|
770
|
+
args?: string[]
|
|
771
|
+
cwd?: string
|
|
772
|
+
env?: Record<string, string>
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
stdout: string
|
|
776
|
+
stderr: string
|
|
777
|
+
exitCode: number
|
|
778
|
+
}
|
|
779
|
+
>({
|
|
780
|
+
id: 'system.bash.script',
|
|
781
|
+
name: 'Execute Bash Script',
|
|
782
|
+
description: 'Execute a bash script with arguments (bashx.do)',
|
|
783
|
+
category: 'system',
|
|
784
|
+
subcategory: 'shell',
|
|
785
|
+
input: {
|
|
786
|
+
type: 'object',
|
|
787
|
+
properties: {
|
|
788
|
+
script: { type: 'string', description: 'Script content or path' },
|
|
789
|
+
args: {
|
|
790
|
+
type: 'array',
|
|
791
|
+
items: { type: 'string' },
|
|
792
|
+
description: 'Script arguments',
|
|
793
|
+
},
|
|
794
|
+
cwd: { type: 'string', description: 'Working directory' },
|
|
795
|
+
env: {
|
|
796
|
+
type: 'object',
|
|
797
|
+
additionalProperties: { type: 'string' },
|
|
798
|
+
description: 'Environment variables',
|
|
799
|
+
},
|
|
800
|
+
},
|
|
801
|
+
required: ['script'],
|
|
802
|
+
},
|
|
803
|
+
handler: async (input) => {
|
|
804
|
+
// Placeholder - actual implementation will use bashx.do
|
|
805
|
+
return {
|
|
806
|
+
stdout: `[bashx.do] Would execute script with args: ${input.args?.join(' ') || '(none)'}`,
|
|
807
|
+
stderr: '',
|
|
808
|
+
exitCode: 0,
|
|
809
|
+
}
|
|
810
|
+
},
|
|
811
|
+
options: {
|
|
812
|
+
audience: 'both',
|
|
813
|
+
tags: ['bash', 'script', 'execute', 'bashx'],
|
|
814
|
+
permissions: [{ type: 'execute', resource: 'shell' }],
|
|
815
|
+
requiresConfirmation: true,
|
|
816
|
+
securityLevel: 'restricted',
|
|
817
|
+
},
|
|
818
|
+
})
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* Get environment information
|
|
822
|
+
*/
|
|
823
|
+
export const bashEnv = defineTool<
|
|
824
|
+
{ filter?: string },
|
|
825
|
+
{ variables: Record<string, string>; shell: string; cwd: string; user: string }
|
|
826
|
+
>({
|
|
827
|
+
id: 'system.bash.env',
|
|
828
|
+
name: 'Get Environment',
|
|
829
|
+
description: 'Get shell environment information (bashx.do)',
|
|
830
|
+
category: 'system',
|
|
831
|
+
subcategory: 'shell',
|
|
832
|
+
input: {
|
|
833
|
+
type: 'object',
|
|
834
|
+
properties: {
|
|
835
|
+
filter: { type: 'string', description: 'Filter variables by prefix' },
|
|
836
|
+
},
|
|
837
|
+
},
|
|
838
|
+
handler: async (input) => {
|
|
839
|
+
// Placeholder - actual implementation will use bashx.do
|
|
840
|
+
return {
|
|
841
|
+
variables: {},
|
|
842
|
+
shell: '/bin/bash',
|
|
843
|
+
cwd: '/',
|
|
844
|
+
user: 'unknown',
|
|
845
|
+
}
|
|
846
|
+
},
|
|
847
|
+
options: {
|
|
848
|
+
audience: 'both',
|
|
849
|
+
tags: ['bash', 'environment', 'env', 'bashx'],
|
|
850
|
+
idempotent: true,
|
|
851
|
+
},
|
|
852
|
+
})
|
|
853
|
+
|
|
854
|
+
// ============================================================================
|
|
855
|
+
// Tool Collections
|
|
856
|
+
// ============================================================================
|
|
857
|
+
|
|
858
|
+
/**
|
|
859
|
+
* All filesystem tools (fsx.do)
|
|
860
|
+
*/
|
|
861
|
+
export const fsxTools: AnyTool[] = [fsRead, fsWrite, fsList, fsDelete, fsGlob, fsGrep]
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* All git tools (gitx.do)
|
|
865
|
+
*/
|
|
866
|
+
export const gitxTools: AnyTool[] = [
|
|
867
|
+
gitInit,
|
|
868
|
+
gitClone,
|
|
869
|
+
gitStatus,
|
|
870
|
+
gitAdd,
|
|
871
|
+
gitCommit,
|
|
872
|
+
gitLog,
|
|
873
|
+
gitDiff,
|
|
874
|
+
gitCheckout,
|
|
875
|
+
gitPush,
|
|
876
|
+
gitPull,
|
|
877
|
+
]
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* All bash tools (bashx.do)
|
|
881
|
+
*/
|
|
882
|
+
export const bashxTools: AnyTool[] = [bashExec, bashAnalyze, bashScript, bashEnv]
|
|
883
|
+
|
|
884
|
+
/**
|
|
885
|
+
* All system tools (fsx + gitx + bashx)
|
|
886
|
+
*/
|
|
887
|
+
export const systemTools: AnyTool[] = [...fsxTools, ...gitxTools, ...bashxTools]
|