@easynet/agent-tool-buildin 0.0.44 → 0.0.46
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/dist/core-tools-manifest.json +4845 -1222
- package/dist/src/calendar/calendarCreateEvent.d.ts +31 -0
- package/dist/src/calendar/calendarCreateEvent.d.ts.map +1 -0
- package/dist/src/calendar/calendarCreateEvent.js +67 -0
- package/dist/src/calendar/calendarCreateEvent.js.map +1 -0
- package/dist/src/calendar/calendarDeleteEvent.d.ts +22 -0
- package/dist/src/calendar/calendarDeleteEvent.d.ts.map +1 -0
- package/dist/src/calendar/calendarDeleteEvent.js +41 -0
- package/dist/src/calendar/calendarDeleteEvent.js.map +1 -0
- package/dist/src/calendar/calendarListEvents.d.ts +32 -0
- package/dist/src/calendar/calendarListEvents.d.ts.map +1 -0
- package/dist/src/calendar/calendarListEvents.js +95 -0
- package/dist/src/calendar/calendarListEvents.js.map +1 -0
- package/dist/src/calendar/calendarRescheduleEventByTitle.d.ts +30 -0
- package/dist/src/calendar/calendarRescheduleEventByTitle.d.ts.map +1 -0
- package/dist/src/calendar/calendarRescheduleEventByTitle.js +94 -0
- package/dist/src/calendar/calendarRescheduleEventByTitle.js.map +1 -0
- package/dist/src/calendar/calendarSearchEventsByTitle.d.ts +33 -0
- package/dist/src/calendar/calendarSearchEventsByTitle.d.ts.map +1 -0
- package/dist/src/calendar/calendarSearchEventsByTitle.js +95 -0
- package/dist/src/calendar/calendarSearchEventsByTitle.js.map +1 -0
- package/dist/src/calendar/calendarUpdateEvent.d.ts +27 -0
- package/dist/src/calendar/calendarUpdateEvent.d.ts.map +1 -0
- package/dist/src/calendar/calendarUpdateEvent.js +58 -0
- package/dist/src/calendar/calendarUpdateEvent.js.map +1 -0
- package/dist/src/cron/cronListEntries.d.ts +19 -0
- package/dist/src/cron/cronListEntries.d.ts.map +1 -0
- package/dist/src/cron/cronListEntries.js +33 -0
- package/dist/src/cron/cronListEntries.js.map +1 -0
- package/dist/src/cron/cronRemoveTaggedEntries.d.ts +21 -0
- package/dist/src/cron/cronRemoveTaggedEntries.d.ts.map +1 -0
- package/dist/src/cron/cronRemoveTaggedEntries.js +41 -0
- package/dist/src/cron/cronRemoveTaggedEntries.js.map +1 -0
- package/dist/src/cron/cronSetTaggedEntry.d.ts +24 -0
- package/dist/src/cron/cronSetTaggedEntry.d.ts.map +1 -0
- package/dist/src/cron/cronSetTaggedEntry.js +51 -0
- package/dist/src/cron/cronSetTaggedEntry.js.map +1 -0
- package/dist/src/exec/runCommand.d.ts +22 -6
- package/dist/src/exec/runCommand.d.ts.map +1 -1
- package/dist/src/exec/runCommand.js +22 -13
- package/dist/src/exec/runCommand.js.map +1 -1
- package/dist/src/fs/listDir.d.ts +2 -1
- package/dist/src/fs/listDir.d.ts.map +1 -1
- package/dist/src/fs/listDir.js +1 -4
- package/dist/src/fs/listDir.js.map +1 -1
- package/dist/src/git/common.d.ts +34 -0
- package/dist/src/git/common.d.ts.map +1 -0
- package/dist/src/git/common.js +119 -0
- package/dist/src/git/common.js.map +1 -0
- package/dist/src/git/defaults.d.ts +1 -0
- package/dist/src/git/defaults.d.ts.map +1 -1
- package/dist/src/git/defaults.js +15 -0
- package/dist/src/git/defaults.js.map +1 -1
- package/dist/src/git/ghRead.d.ts +29 -0
- package/dist/src/git/ghRead.d.ts.map +1 -0
- package/dist/src/git/ghRead.js +63 -0
- package/dist/src/git/ghRead.js.map +1 -0
- package/dist/src/git/gitAdd.d.ts +29 -0
- package/dist/src/git/gitAdd.d.ts.map +1 -0
- package/dist/src/git/gitAdd.js +57 -0
- package/dist/src/git/gitAdd.js.map +1 -0
- package/dist/src/git/gitCommit.d.ts +29 -0
- package/dist/src/git/gitCommit.d.ts.map +1 -0
- package/dist/src/git/gitCommit.js +56 -0
- package/dist/src/git/gitCommit.js.map +1 -0
- package/dist/src/git/gitDiff.d.ts +28 -0
- package/dist/src/git/gitDiff.d.ts.map +1 -0
- package/dist/src/git/gitDiff.js +54 -0
- package/dist/src/git/gitDiff.js.map +1 -0
- package/dist/src/git/gitLogHistory.d.ts +37 -0
- package/dist/src/git/gitLogHistory.d.ts.map +1 -0
- package/dist/src/git/gitLogHistory.js +85 -0
- package/dist/src/git/gitLogHistory.js.map +1 -0
- package/dist/src/git/gitPrView.d.ts +26 -0
- package/dist/src/git/gitPrView.d.ts.map +1 -0
- package/dist/src/git/gitPrView.js +66 -0
- package/dist/src/git/gitPrView.js.map +1 -0
- package/dist/src/git/gitPull.d.ts +31 -0
- package/dist/src/git/gitPull.d.ts.map +1 -0
- package/dist/src/git/gitPull.js +56 -0
- package/dist/src/git/gitPull.js.map +1 -0
- package/dist/src/git/gitRead.d.ts +28 -0
- package/dist/src/git/gitRead.d.ts.map +1 -0
- package/dist/src/git/gitRead.js +59 -0
- package/dist/src/git/gitRead.js.map +1 -0
- package/dist/src/git/gitStatus.d.ts +28 -0
- package/dist/src/git/gitStatus.d.ts.map +1 -0
- package/dist/src/git/gitStatus.js +55 -0
- package/dist/src/git/gitStatus.js.map +1 -0
- package/dist/src/git/gitSwitchBranch.d.ts +29 -0
- package/dist/src/git/gitSwitchBranch.d.ts.map +1 -0
- package/dist/src/git/gitSwitchBranch.js +57 -0
- package/dist/src/git/gitSwitchBranch.js.map +1 -0
- package/dist/src/git/gitTools.d.ts +10 -155
- package/dist/src/git/gitTools.d.ts.map +1 -1
- package/dist/src/git/gitTools.js +10 -396
- package/dist/src/git/gitTools.js.map +1 -1
- package/dist/src/http/downloadFile.d.ts +2 -2
- package/dist/src/http/downloadFile.d.ts.map +1 -1
- package/dist/src/http/fetchJson.d.ts +2 -2
- package/dist/src/http/fetchJson.d.ts.map +1 -1
- package/dist/src/http/fetchPageMainContent.d.ts +1 -1
- package/dist/src/http/fetchPageMainContent.d.ts.map +1 -1
- package/dist/src/http/fetchText.d.ts +2 -2
- package/dist/src/http/fetchText.d.ts.map +1 -1
- package/dist/src/http/head.d.ts +1 -1
- package/dist/src/http/head.d.ts.map +1 -1
- package/dist/src/http/yahooFinance.d.ts +5 -4
- package/dist/src/http/yahooFinance.d.ts.map +1 -1
- package/dist/src/http/yahooFinance.js +6 -6
- package/dist/src/http/yahooFinance.js.map +1 -1
- package/dist/src/iterm/common.d.ts +8 -0
- package/dist/src/iterm/common.d.ts.map +1 -1
- package/dist/src/iterm/common.js +28 -2
- package/dist/src/iterm/common.js.map +1 -1
- package/dist/src/iterm/itermCreateTab.d.ts +1 -1
- package/dist/src/iterm/itermCreateTab.d.ts.map +1 -1
- package/dist/src/iterm/itermCreateTab.js +18 -4
- package/dist/src/iterm/itermCreateTab.js.map +1 -1
- package/dist/src/iterm/itermCreateWindow.d.ts +1 -1
- package/dist/src/iterm/itermCreateWindow.d.ts.map +1 -1
- package/dist/src/iterm/itermCreateWindow.js +25 -9
- package/dist/src/iterm/itermCreateWindow.js.map +1 -1
- package/dist/src/iterm/itermGetSessionInfo.d.ts +1 -1
- package/dist/src/iterm/itermGetSessionInfo.js +2 -2
- package/dist/src/iterm/itermGetSessionInfo.js.map +1 -1
- package/dist/src/iterm/itermListCurrentWindowSessions.d.ts +14 -35
- package/dist/src/iterm/itermListCurrentWindowSessions.d.ts.map +1 -1
- package/dist/src/iterm/itermListCurrentWindowSessions.js +3 -3
- package/dist/src/iterm/itermListCurrentWindowSessions.js.map +1 -1
- package/dist/src/iterm/itermListWindows.d.ts +1 -1
- package/dist/src/iterm/itermListWindows.js +3 -3
- package/dist/src/iterm/itermListWindows.js.map +1 -1
- package/dist/src/iterm/itermRename.d.ts +1 -1
- package/dist/src/iterm/itermRename.js +3 -3
- package/dist/src/iterm/itermRename.js.map +1 -1
- package/dist/src/iterm/itermResizeWindow.d.ts +1 -1
- package/dist/src/iterm/itermResizeWindow.js +3 -3
- package/dist/src/iterm/itermResizeWindow.js.map +1 -1
- package/dist/src/iterm/itermRunCommandInSession.d.ts +13 -3
- package/dist/src/iterm/itermRunCommandInSession.d.ts.map +1 -1
- package/dist/src/iterm/itermRunCommandInSession.js +48 -6
- package/dist/src/iterm/itermRunCommandInSession.js.map +1 -1
- package/dist/src/iterm/itermSendText.d.ts +4 -1
- package/dist/src/iterm/itermSendText.d.ts.map +1 -1
- package/dist/src/iterm/itermSendText.js +23 -4
- package/dist/src/iterm/itermSendText.js.map +1 -1
- package/dist/src/iterm/itermSetBackgroundColor.d.ts +1 -1
- package/dist/src/iterm/itermSetBackgroundColor.js +2 -2
- package/dist/src/iterm/itermSetBackgroundColor.js.map +1 -1
- package/dist/src/iterm/itermSetSessionColors.d.ts +48 -0
- package/dist/src/iterm/itermSetSessionColors.d.ts.map +1 -0
- package/dist/src/iterm/itermSetSessionColors.js +71 -0
- package/dist/src/iterm/itermSetSessionColors.js.map +1 -0
- package/dist/src/iterm/itermSplitPane.d.ts +1 -1
- package/dist/src/iterm/itermSplitPane.d.ts.map +1 -1
- package/dist/src/iterm/itermSplitPane.js +21 -2
- package/dist/src/iterm/itermSplitPane.js.map +1 -1
- package/dist/src/iterm/itermTools.d.ts +1 -0
- package/dist/src/iterm/itermTools.d.ts.map +1 -1
- package/dist/src/iterm/itermTools.js +1 -0
- package/dist/src/iterm/itermTools.js.map +1 -1
- package/dist/src/messages/messagesFindChatsByParticipant.d.ts +27 -0
- package/dist/src/messages/messagesFindChatsByParticipant.d.ts.map +1 -0
- package/dist/src/messages/messagesFindChatsByParticipant.js +95 -0
- package/dist/src/messages/messagesFindChatsByParticipant.js.map +1 -0
- package/dist/src/messages/messagesListChats.d.ts +25 -0
- package/dist/src/messages/messagesListChats.d.ts.map +1 -0
- package/dist/src/messages/messagesListChats.js +69 -0
- package/dist/src/messages/messagesListChats.js.map +1 -0
- package/dist/src/messages/messagesReadChat.d.ts +28 -0
- package/dist/src/messages/messagesReadChat.d.ts.map +1 -0
- package/dist/src/messages/messagesReadChat.js +88 -0
- package/dist/src/messages/messagesReadChat.js.map +1 -0
- package/dist/src/messages/messagesSendByChatId.d.ts +22 -0
- package/dist/src/messages/messagesSendByChatId.d.ts.map +1 -0
- package/dist/src/messages/messagesSendByChatId.js +48 -0
- package/dist/src/messages/messagesSendByChatId.js.map +1 -0
- package/dist/src/messages/messagesSendByHandle.d.ts +26 -0
- package/dist/src/messages/messagesSendByHandle.d.ts.map +1 -0
- package/dist/src/messages/messagesSendByHandle.js +67 -0
- package/dist/src/messages/messagesSendByHandle.js.map +1 -0
- package/dist/src/messages/messagesSendByParticipantQuery.d.ts +26 -0
- package/dist/src/messages/messagesSendByParticipantQuery.d.ts.map +1 -0
- package/dist/src/messages/messagesSendByParticipantQuery.js +93 -0
- package/dist/src/messages/messagesSendByParticipantQuery.js.map +1 -0
- package/dist/src/notes/notesCreate.d.ts +23 -0
- package/dist/src/notes/notesCreate.d.ts.map +1 -0
- package/dist/src/notes/notesCreate.js +56 -0
- package/dist/src/notes/notesCreate.js.map +1 -0
- package/dist/src/notes/notesDelete.d.ts +20 -0
- package/dist/src/notes/notesDelete.d.ts.map +1 -0
- package/dist/src/notes/notesDelete.js +58 -0
- package/dist/src/notes/notesDelete.js.map +1 -0
- package/dist/src/notes/notesList.d.ts +26 -0
- package/dist/src/notes/notesList.d.ts.map +1 -0
- package/dist/src/notes/notesList.js +80 -0
- package/dist/src/notes/notesList.js.map +1 -0
- package/dist/src/notes/notesRead.d.ts +26 -0
- package/dist/src/notes/notesRead.d.ts.map +1 -0
- package/dist/src/notes/notesRead.js +82 -0
- package/dist/src/notes/notesRead.js.map +1 -0
- package/dist/src/notes/notesUpdate.d.ts +24 -0
- package/dist/src/notes/notesUpdate.d.ts.map +1 -0
- package/dist/src/notes/notesUpdate.js +75 -0
- package/dist/src/notes/notesUpdate.js.map +1 -0
- package/dist/src/osascript/common.d.ts +6 -0
- package/dist/src/osascript/common.d.ts.map +1 -0
- package/dist/src/osascript/common.js +52 -0
- package/dist/src/osascript/common.js.map +1 -0
- package/dist/src/platform/adapters/darwin.d.ts +3 -0
- package/dist/src/platform/adapters/darwin.d.ts.map +1 -0
- package/dist/src/platform/adapters/darwin.js +14 -0
- package/dist/src/platform/adapters/darwin.js.map +1 -0
- package/dist/src/platform/adapters/linux.d.ts +3 -0
- package/dist/src/platform/adapters/linux.d.ts.map +1 -0
- package/dist/src/platform/adapters/linux.js +8 -0
- package/dist/src/platform/adapters/linux.js.map +1 -0
- package/dist/src/platform/adapters/win32.d.ts +3 -0
- package/dist/src/platform/adapters/win32.d.ts.map +1 -0
- package/dist/src/platform/adapters/win32.js +8 -0
- package/dist/src/platform/adapters/win32.js.map +1 -0
- package/dist/src/platform/index.d.ts +4 -0
- package/dist/src/platform/index.d.ts.map +1 -0
- package/dist/src/platform/index.js +4 -0
- package/dist/src/platform/index.js.map +1 -0
- package/dist/src/platform/platformGetCapabilities.d.ts +23 -0
- package/dist/src/platform/platformGetCapabilities.d.ts.map +1 -0
- package/dist/src/platform/platformGetCapabilities.js +32 -0
- package/dist/src/platform/platformGetCapabilities.js.map +1 -0
- package/dist/src/platform/registry.d.ts +3 -0
- package/dist/src/platform/registry.d.ts.map +1 -0
- package/dist/src/platform/registry.js +16 -0
- package/dist/src/platform/registry.js.map +1 -0
- package/dist/src/platform/runtime.d.ts +15 -0
- package/dist/src/platform/runtime.d.ts.map +1 -0
- package/dist/src/platform/runtime.js +37 -0
- package/dist/src/platform/runtime.js.map +1 -0
- package/dist/src/platform/types.d.ts +10 -0
- package/dist/src/platform/types.d.ts.map +1 -0
- package/dist/src/platform/types.js +10 -0
- package/dist/src/platform/types.js.map +1 -0
- package/dist/src/reminders/remindersComplete.d.ts +22 -0
- package/dist/src/reminders/remindersComplete.d.ts.map +1 -0
- package/dist/src/reminders/remindersComplete.js +60 -0
- package/dist/src/reminders/remindersComplete.js.map +1 -0
- package/dist/src/reminders/remindersCreate.d.ts +24 -0
- package/dist/src/reminders/remindersCreate.d.ts.map +1 -0
- package/dist/src/reminders/remindersCreate.js +57 -0
- package/dist/src/reminders/remindersCreate.js.map +1 -0
- package/dist/src/reminders/remindersDelete.d.ts +22 -0
- package/dist/src/reminders/remindersDelete.d.ts.map +1 -0
- package/dist/src/reminders/remindersDelete.js +60 -0
- package/dist/src/reminders/remindersDelete.js.map +1 -0
- package/dist/src/reminders/remindersFind.d.ts +30 -0
- package/dist/src/reminders/remindersFind.d.ts.map +1 -0
- package/dist/src/reminders/remindersFind.js +85 -0
- package/dist/src/reminders/remindersFind.js.map +1 -0
- package/dist/src/reminders/remindersList.d.ts +28 -0
- package/dist/src/reminders/remindersList.d.ts.map +1 -0
- package/dist/src/reminders/remindersList.js +78 -0
- package/dist/src/reminders/remindersList.js.map +1 -0
- package/dist/src/reminders/remindersSyncFromCalendar.d.ts +31 -0
- package/dist/src/reminders/remindersSyncFromCalendar.d.ts.map +1 -0
- package/dist/src/reminders/remindersSyncFromCalendar.js +125 -0
- package/dist/src/reminders/remindersSyncFromCalendar.js.map +1 -0
- package/dist/src/safari/safariCloseTab.d.ts +22 -0
- package/dist/src/safari/safariCloseTab.d.ts.map +1 -0
- package/dist/src/safari/safariCloseTab.js +39 -0
- package/dist/src/safari/safariCloseTab.js.map +1 -0
- package/dist/src/safari/safariGetActiveTab.d.ts +18 -0
- package/dist/src/safari/safariGetActiveTab.d.ts.map +1 -0
- package/dist/src/safari/safariGetActiveTab.js +34 -0
- package/dist/src/safari/safariGetActiveTab.js.map +1 -0
- package/dist/src/safari/safariListTabs.d.ts +26 -0
- package/dist/src/safari/safariListTabs.d.ts.map +1 -0
- package/dist/src/safari/safariListTabs.js +71 -0
- package/dist/src/safari/safariListTabs.js.map +1 -0
- package/dist/src/safari/safariOpenWebUrl.d.ts +22 -0
- package/dist/src/safari/safariOpenWebUrl.d.ts.map +1 -0
- package/dist/src/safari/safariOpenWebUrl.js +49 -0
- package/dist/src/safari/safariOpenWebUrl.js.map +1 -0
- package/dist/src/safari/safariReadPageContent.d.ts +31 -0
- package/dist/src/safari/safariReadPageContent.d.ts.map +1 -0
- package/dist/src/safari/safariReadPageContent.js +69 -0
- package/dist/src/safari/safariReadPageContent.js.map +1 -0
- package/dist/src/safari/safariReadSelection.d.ts +26 -0
- package/dist/src/safari/safariReadSelection.d.ts.map +1 -0
- package/dist/src/safari/safariReadSelection.js +75 -0
- package/dist/src/safari/safariReadSelection.js.map +1 -0
- package/package.json +10 -3
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createTaggedError } from "@easynet/agent-tool";
|
|
2
|
+
import { quoteAppleScriptString, runOsaScript } from "../osascript/common.js";
|
|
3
|
+
/**
|
|
4
|
+
* Update calendar event by uid in specific calendar.
|
|
5
|
+
* @tool
|
|
6
|
+
* @effect local_write
|
|
7
|
+
*/
|
|
8
|
+
export async function calendarUpdateEvent(args) {
|
|
9
|
+
const id = args.id?.trim();
|
|
10
|
+
const calendar = args.calendar?.trim() || "Home";
|
|
11
|
+
if (!id)
|
|
12
|
+
throw createTaggedError("CALENDAR_INVALID", "id is required", {});
|
|
13
|
+
if (!args.title && !args.startDateText && !args.endDateText && !args.location && !args.notes) {
|
|
14
|
+
throw createTaggedError("CALENDAR_INVALID", "at least one field to update is required", {});
|
|
15
|
+
}
|
|
16
|
+
const lines = [
|
|
17
|
+
'tell application "Calendar"',
|
|
18
|
+
"activate",
|
|
19
|
+
`set calName to ${quoteAppleScriptString(calendar)}`,
|
|
20
|
+
`set wantedId to ${quoteAppleScriptString(id)}`,
|
|
21
|
+
"set targetCal to calendar calName",
|
|
22
|
+
"set targetEvent to first event of targetCal whose (uid as text) is wantedId",
|
|
23
|
+
...(args.title?.trim() ? [`set summary of targetEvent to ${quoteAppleScriptString(args.title.trim())}`] : []),
|
|
24
|
+
...(args.startDateText?.trim()
|
|
25
|
+
? [
|
|
26
|
+
`set stText to ${quoteAppleScriptString(args.startDateText.trim())}`,
|
|
27
|
+
"set start date of targetEvent to date stText",
|
|
28
|
+
]
|
|
29
|
+
: []),
|
|
30
|
+
...(args.endDateText?.trim()
|
|
31
|
+
? [
|
|
32
|
+
`set edText to ${quoteAppleScriptString(args.endDateText.trim())}`,
|
|
33
|
+
"set end date of targetEvent to date edText",
|
|
34
|
+
]
|
|
35
|
+
: []),
|
|
36
|
+
...(args.location?.trim() ? [`set location of targetEvent to ${quoteAppleScriptString(args.location.trim())}`] : []),
|
|
37
|
+
...(args.notes?.trim() ? [`set description of targetEvent to ${quoteAppleScriptString(args.notes.trim())}`] : []),
|
|
38
|
+
'return "updated"',
|
|
39
|
+
"end tell",
|
|
40
|
+
];
|
|
41
|
+
const output = await runOsaScript(lines, "CALENDAR");
|
|
42
|
+
return {
|
|
43
|
+
result: {
|
|
44
|
+
id,
|
|
45
|
+
calendar,
|
|
46
|
+
status: output || "updated",
|
|
47
|
+
},
|
|
48
|
+
evidence: [
|
|
49
|
+
{
|
|
50
|
+
type: "tool",
|
|
51
|
+
ref: "calendarUpdateEvent",
|
|
52
|
+
summary: `Updated calendar event ${id} in ${calendar}`,
|
|
53
|
+
createdAt: new Date().toISOString(),
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=calendarUpdateEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendarUpdateEvent.js","sourceRoot":"","sources":["../../../src/calendar/calendarUpdateEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE9E;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,IAQzC;IACC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC;IAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,MAAM,CAAC;IACjD,IAAI,CAAC,EAAE;QAAE,MAAM,iBAAiB,CAAC,kBAAkB,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAC3E,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,aAAa,IAAI,CA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AC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACjH,kBAAkB;QAClB,UAAU;KACX,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAErD,OAAO;QACL,MAAM,EAAE;YACN,EAAE;YACF,QAAQ;YACR,MAAM,EAAE,MAAM,IAAI,SAAS;SAC5B;QACD,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,GAAG,EAAE,qBAAqB;gBAC1B,OAAO,EAAE,0BAA0B,EAAE,OAAO,QAAQ,EAAE;gBACtD,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACpC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical name for listing cron entries.
|
|
3
|
+
* @tool
|
|
4
|
+
* @effect none
|
|
5
|
+
*/
|
|
6
|
+
export declare function cronListEntries(_?: {}): Promise<{
|
|
7
|
+
result: {
|
|
8
|
+
count: number;
|
|
9
|
+
entries: string[];
|
|
10
|
+
raw: string;
|
|
11
|
+
};
|
|
12
|
+
evidence: {
|
|
13
|
+
type: string;
|
|
14
|
+
ref: string;
|
|
15
|
+
summary: string;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
}[];
|
|
18
|
+
}>;
|
|
19
|
+
//# sourceMappingURL=cronListEntries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cronListEntries.d.ts","sourceRoot":"","sources":["../../../src/cron/cronListEntries.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,CAAC,GAAE,EAAO;;;;;;;;;;;;GA2B/C"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { runOsaScript } from "../osascript/common.js";
|
|
2
|
+
/**
|
|
3
|
+
* Canonical name for listing cron entries.
|
|
4
|
+
* @tool
|
|
5
|
+
* @effect none
|
|
6
|
+
*/
|
|
7
|
+
export async function cronListEntries(_ = {}) {
|
|
8
|
+
const lines = [
|
|
9
|
+
"set sh to \"crontab -l 2>/dev/null || true\"",
|
|
10
|
+
"return do shell script sh",
|
|
11
|
+
];
|
|
12
|
+
const output = await runOsaScript(lines, "CRON");
|
|
13
|
+
const linesOut = output
|
|
14
|
+
.split(/\r?\n/)
|
|
15
|
+
.map((line) => line.trim())
|
|
16
|
+
.filter((line) => line.length > 0);
|
|
17
|
+
return {
|
|
18
|
+
result: {
|
|
19
|
+
count: linesOut.length,
|
|
20
|
+
entries: linesOut,
|
|
21
|
+
raw: output,
|
|
22
|
+
},
|
|
23
|
+
evidence: [
|
|
24
|
+
{
|
|
25
|
+
type: "tool",
|
|
26
|
+
ref: "cronListEntries",
|
|
27
|
+
summary: `Listed ${linesOut.length} cron entries`,
|
|
28
|
+
createdAt: new Date().toISOString(),
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=cronListEntries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cronListEntries.js","sourceRoot":"","sources":["../../../src/cron/cronListEntries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAQ,EAAE;IAC9C,MAAM,KAAK,GAAG;QACZ,8CAA8C;QAC9C,2BAA2B;KAC5B,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACjD,MAAM,QAAQ,GAAG,MAAM;SACpB,KAAK,CAAC,OAAO,CAAC;SACd,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAErC,OAAO;QACL,MAAM,EAAE;YACN,KAAK,EAAE,QAAQ,CAAC,MAAM;YACtB,OAAO,EAAE,QAAQ;YACjB,GAAG,EAAE,MAAM;SACZ;QACD,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,GAAG,EAAE,iBAAiB;gBACtB,OAAO,EAAE,UAAU,QAAQ,CAAC,MAAM,eAAe;gBACjD,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACpC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical name for removing tagged cron entries.
|
|
3
|
+
* @tool
|
|
4
|
+
* @effect local_write
|
|
5
|
+
*/
|
|
6
|
+
export declare function cronRemoveTaggedEntries(args: {
|
|
7
|
+
tag: string;
|
|
8
|
+
}): Promise<{
|
|
9
|
+
result: {
|
|
10
|
+
tag: string;
|
|
11
|
+
marker: string;
|
|
12
|
+
status: string;
|
|
13
|
+
};
|
|
14
|
+
evidence: {
|
|
15
|
+
type: string;
|
|
16
|
+
ref: string;
|
|
17
|
+
summary: string;
|
|
18
|
+
createdAt: string;
|
|
19
|
+
}[];
|
|
20
|
+
}>;
|
|
21
|
+
//# sourceMappingURL=cronRemoveTaggedEntries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cronRemoveTaggedEntries.d.ts","sourceRoot":"","sources":["../../../src/cron/cronRemoveTaggedEntries.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;GA+BlE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createTaggedError } from "@easynet/agent-tool";
|
|
2
|
+
import { quoteAppleScriptString, runOsaScript } from "../osascript/common.js";
|
|
3
|
+
function b64(input) {
|
|
4
|
+
return Buffer.from(input, "utf-8").toString("base64");
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Canonical name for removing tagged cron entries.
|
|
8
|
+
* @tool
|
|
9
|
+
* @effect local_write
|
|
10
|
+
*/
|
|
11
|
+
export async function cronRemoveTaggedEntries(args) {
|
|
12
|
+
const tag = args.tag?.trim();
|
|
13
|
+
if (!tag)
|
|
14
|
+
throw createTaggedError("CRON_INVALID", "tag is required", {});
|
|
15
|
+
const marker = `# easynet:${tag}`;
|
|
16
|
+
const script = [
|
|
17
|
+
"set -e",
|
|
18
|
+
`marker=$(printf '%s' ${JSON.stringify(b64(marker))} | base64 -D)`,
|
|
19
|
+
"existing=$(crontab -l 2>/dev/null || true)",
|
|
20
|
+
"filtered=$(printf '%s\\n' \"$existing\" | grep -vF \"$marker\" || true)",
|
|
21
|
+
"printf '%s\\n' \"$filtered\" | sed '/^[[:space:]]*$/d' | crontab -",
|
|
22
|
+
"printf '%s' \"$marker\"",
|
|
23
|
+
].join("; ");
|
|
24
|
+
const output = await runOsaScript([`return do shell script ${quoteAppleScriptString(script)}`], "CRON");
|
|
25
|
+
return {
|
|
26
|
+
result: {
|
|
27
|
+
tag,
|
|
28
|
+
marker: output || marker,
|
|
29
|
+
status: "removed",
|
|
30
|
+
},
|
|
31
|
+
evidence: [
|
|
32
|
+
{
|
|
33
|
+
type: "tool",
|
|
34
|
+
ref: "cronRemoveTaggedEntries",
|
|
35
|
+
summary: `Removed cron entries with tag ${tag}`,
|
|
36
|
+
createdAt: new Date().toISOString(),
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=cronRemoveTaggedEntries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cronRemoveTaggedEntries.js","sourceRoot":"","sources":["../../../src/cron/cronRemoveTaggedEntries.ts"],"names":[],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|
2
|
+
* Canonical name for creating/updating a tagged cron entry.
|
|
3
|
+
* @tool
|
|
4
|
+
* @effect local_write
|
|
5
|
+
*/
|
|
6
|
+
export declare function cronSetTaggedEntry(args: {
|
|
7
|
+
expression: string;
|
|
8
|
+
command: string;
|
|
9
|
+
tag: string;
|
|
10
|
+
}): Promise<{
|
|
11
|
+
result: {
|
|
12
|
+
tag: string;
|
|
13
|
+
marker: string;
|
|
14
|
+
line: string;
|
|
15
|
+
status: string;
|
|
16
|
+
};
|
|
17
|
+
evidence: {
|
|
18
|
+
type: string;
|
|
19
|
+
ref: string;
|
|
20
|
+
summary: string;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
}[];
|
|
23
|
+
}>;
|
|
24
|
+
//# sourceMappingURL=cronSetTaggedEntry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cronSetTaggedEntry.d.ts","sourceRoot":"","sources":["../../../src/cron/cronSetTaggedEntry.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb;;;;;;;;;;;;;GAyCA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createTaggedError } from "@easynet/agent-tool";
|
|
2
|
+
import { quoteAppleScriptString, runOsaScript } from "../osascript/common.js";
|
|
3
|
+
function b64(input) {
|
|
4
|
+
return Buffer.from(input, "utf-8").toString("base64");
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Canonical name for creating/updating a tagged cron entry.
|
|
8
|
+
* @tool
|
|
9
|
+
* @effect local_write
|
|
10
|
+
*/
|
|
11
|
+
export async function cronSetTaggedEntry(args) {
|
|
12
|
+
const expression = args.expression?.trim();
|
|
13
|
+
const command = args.command?.trim();
|
|
14
|
+
const tag = args.tag?.trim();
|
|
15
|
+
if (!expression)
|
|
16
|
+
throw createTaggedError("CRON_INVALID", "expression is required", {});
|
|
17
|
+
if (!command)
|
|
18
|
+
throw createTaggedError("CRON_INVALID", "command is required", {});
|
|
19
|
+
if (!tag)
|
|
20
|
+
throw createTaggedError("CRON_INVALID", "tag is required", {});
|
|
21
|
+
const marker = `# easynet:${tag}`;
|
|
22
|
+
const newLine = `${expression} ${command} ${marker}`;
|
|
23
|
+
const script = [
|
|
24
|
+
"set -e",
|
|
25
|
+
`marker=$(printf '%s' ${JSON.stringify(b64(marker))} | base64 -D)`,
|
|
26
|
+
`new_line=$(printf '%s' ${JSON.stringify(b64(newLine))} | base64 -D)`,
|
|
27
|
+
"existing=$(crontab -l 2>/dev/null || true)",
|
|
28
|
+
"filtered=$(printf '%s\\n' \"$existing\" | grep -vF \"$marker\" || true)",
|
|
29
|
+
"next=$(printf '%s\\n%s\\n' \"$filtered\" \"$new_line\" | sed '/^[[:space:]]*$/d')",
|
|
30
|
+
"printf '%s\\n' \"$next\" | crontab -",
|
|
31
|
+
"printf '%s' \"$new_line\"",
|
|
32
|
+
].join("; ");
|
|
33
|
+
const output = await runOsaScript([`return do shell script ${quoteAppleScriptString(script)}`], "CRON");
|
|
34
|
+
return {
|
|
35
|
+
result: {
|
|
36
|
+
tag,
|
|
37
|
+
marker,
|
|
38
|
+
line: output || newLine,
|
|
39
|
+
status: "upserted",
|
|
40
|
+
},
|
|
41
|
+
evidence: [
|
|
42
|
+
{
|
|
43
|
+
type: "tool",
|
|
44
|
+
ref: "cronSetTaggedEntry",
|
|
45
|
+
summary: `Upserted cron entry with tag ${tag}`,
|
|
46
|
+
createdAt: new Date().toISOString(),
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=cronSetTaggedEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cronSetTaggedEntry.js","sourceRoot":"","sources":["../../../src/cron/cronSetTaggedEntry.ts"],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,CAAC,CAAC;IAEb,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,CAAC,0BAA0B,sBAAsB,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IAExG,OAAO;QACL,MAAM,EAAE;YACN,GAAG;YACH,MAAM;YACN,IAAI,EAAE,MAAM,IAAI,OAAO;YACvB,MAAM,EAAE,UAAU;SACnB;QACD,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,GAAG,EAAE,oBAAoB;gBACzB,OAAO,EAAE,gCAAgC,GAAG,EAAE;gBAC9C,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACpC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,20 +1,36 @@
|
|
|
1
|
+
type RunCommandOutput = {
|
|
2
|
+
result: {
|
|
3
|
+
stdout: string;
|
|
4
|
+
stderr: string;
|
|
5
|
+
exitCode: number | null;
|
|
6
|
+
timedOut: boolean;
|
|
7
|
+
signal?: string;
|
|
8
|
+
};
|
|
9
|
+
evidence: Array<{
|
|
10
|
+
type: string;
|
|
11
|
+
ref?: string;
|
|
12
|
+
summary: string;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
}>;
|
|
15
|
+
};
|
|
1
16
|
/**
|
|
2
17
|
* Run an allowlisted command in the sandbox via spawn (no shell), with timeout and output limits.
|
|
3
18
|
* Uses spawn (no shell) to avoid injection; command and args are separate.
|
|
19
|
+
* Accepts either command+args or cmd as array [executable, ...args] (e.g. ["bash", "-lc", "echo hi"]).
|
|
4
20
|
* @tool
|
|
5
21
|
* @effect local_write
|
|
6
22
|
*/
|
|
7
23
|
export declare function runCommand(args: {
|
|
8
|
-
command
|
|
9
|
-
/** Alias for command
|
|
24
|
+
command?: string;
|
|
25
|
+
/** Alias for command. */
|
|
10
26
|
cmd?: string;
|
|
27
|
+
/** Explicit array form: [executable, ...args]. */
|
|
28
|
+
cmdArray?: string[];
|
|
11
29
|
args?: string[];
|
|
12
30
|
/** Alias for args (accepted when agents send "arguments" instead of "args"). */
|
|
13
31
|
arguments?: string[];
|
|
14
32
|
cwd?: string;
|
|
15
33
|
timeoutMs?: number;
|
|
16
|
-
}): Promise<
|
|
17
|
-
|
|
18
|
-
evidence: unknown[];
|
|
19
|
-
}>;
|
|
34
|
+
}): Promise<RunCommandOutput>;
|
|
35
|
+
export {};
|
|
20
36
|
//# sourceMappingURL=runCommand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runCommand.d.ts","sourceRoot":"","sources":["../../../src/exec/runCommand.ts"],"names":[],"mappings":"AAYA
|
|
1
|
+
{"version":3,"file":"runCommand.d.ts","sourceRoot":"","sources":["../../../src/exec/runCommand.ts"],"names":[],"mappings":"AAYA,KAAK,gBAAgB,GAAG;IACtB,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,QAAQ,EAAE,OAAO,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,QAAQ,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;CACJ,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,gFAAgF;IAChF,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAyJ5B"}
|
|
@@ -8,6 +8,7 @@ import { overrideWithConfig } from "../util/overrideWithConfig.js";
|
|
|
8
8
|
/**
|
|
9
9
|
* Run an allowlisted command in the sandbox via spawn (no shell), with timeout and output limits.
|
|
10
10
|
* Uses spawn (no shell) to avoid injection; command and args are separate.
|
|
11
|
+
* Accepts either command+args or cmd as array [executable, ...args] (e.g. ["bash", "-lc", "echo hi"]).
|
|
11
12
|
* @tool
|
|
12
13
|
* @effect local_write
|
|
13
14
|
*/
|
|
@@ -26,15 +27,28 @@ export async function runCommand(args) {
|
|
|
26
27
|
const timeoutMs = typeof ctx.config?.timeoutMs === "number"
|
|
27
28
|
? ctx.config.timeoutMs
|
|
28
29
|
: commandTimeoutMs;
|
|
29
|
-
// Step 2:
|
|
30
|
+
// Step 2: Normalize command and args (support cmd as array [executable, ...args]).
|
|
31
|
+
let rawCommand;
|
|
32
|
+
let cmdArgs;
|
|
33
|
+
if (Array.isArray(args.cmdArray) && args.cmdArray.length > 0) {
|
|
34
|
+
rawCommand = String(args.cmdArray[0]).trim();
|
|
35
|
+
cmdArgs = args.cmdArray.slice(1).map(String);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
rawCommand = (args.command ?? args.cmd)?.trim() ?? "";
|
|
39
|
+
if (!rawCommand) {
|
|
40
|
+
throw createTaggedError("EXEC_INVALID", "command is required (pass 'command', 'cmd', or 'cmdArray')", {});
|
|
41
|
+
}
|
|
42
|
+
cmdArgs = Array.isArray(args.args)
|
|
43
|
+
? args.args
|
|
44
|
+
: Array.isArray(args.arguments)
|
|
45
|
+
? args.arguments
|
|
46
|
+
: [];
|
|
47
|
+
}
|
|
48
|
+
// Step 3: Validate exec is enabled and command input (single name, allowlist).
|
|
30
49
|
if (!allowedCommands.length) {
|
|
31
50
|
throw createTaggedError("EXEC_DISABLED", "Exec is disabled: allowedCommands is empty", {});
|
|
32
51
|
}
|
|
33
|
-
const rawCommand = (args.command ?? args.cmd)?.trim();
|
|
34
|
-
if (!rawCommand) {
|
|
35
|
-
throw createTaggedError("EXEC_INVALID", "command is required (pass 'command' or 'cmd')", {});
|
|
36
|
-
}
|
|
37
|
-
// Only allow bare command name (no path, no shell metacharacters)
|
|
38
52
|
const baseName = rawCommand.replace(/^.*\//, "").trim();
|
|
39
53
|
if (baseName !== rawCommand || /[;&|$`\s]/.test(rawCommand)) {
|
|
40
54
|
throw createTaggedError("EXEC_INVALID", "command must be a single executable name (no path, no shell chars)", { command: rawCommand });
|
|
@@ -42,18 +56,13 @@ export async function runCommand(args) {
|
|
|
42
56
|
if (!allowedCommands.includes(baseName)) {
|
|
43
57
|
throw createTaggedError("EXEC_NOT_ALLOWED", `Command "${baseName}" is not in allowedCommands`, { command: baseName, allowed: allowedCommands });
|
|
44
58
|
}
|
|
45
|
-
// Step
|
|
46
|
-
const cmdArgs = Array.isArray(args.args)
|
|
47
|
-
? args.args
|
|
48
|
-
: Array.isArray(args.arguments)
|
|
49
|
-
? args.arguments
|
|
50
|
-
: [];
|
|
59
|
+
// Step 4: Resolve cwd and spawn process with timeout and output limit.
|
|
51
60
|
const sandboxRoot = sandboxRootFromCfg ?? "";
|
|
52
61
|
let cwd = pathResolve(sandboxRoot);
|
|
53
62
|
if (args.cwd != null && args.cwd !== "") {
|
|
54
63
|
cwd = await resolveSandboxedPath(args.cwd, sandboxRoot);
|
|
55
64
|
}
|
|
56
|
-
// Step
|
|
65
|
+
// Step 5: Collect stdout/stderr and resolve with result and evidence.
|
|
57
66
|
return new Promise((resolvePromise, rejectPromise) => {
|
|
58
67
|
const proc = spawn(baseName, cmdArgs, {
|
|
59
68
|
cwd,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runCommand.js","sourceRoot":"","sources":["../../../src/exec/runCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE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AQ,qBAAqB,SAAS,IAAI;wBAC/D,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;qBACpC;iBACF;aACF,CAAC,CAAC;QACL,CAAC,EAAE,SAAS,CAAC,CAAC;QAEd,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACvB,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,aAAa,CACX,iBAAiB,CAAC,kBAAkB,EAAE,GAAG,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAC1E,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;YAChC,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,cAAc,CAAC;gBACb,MAAM,EAAE;oBACN,MAAM;oBACN,MAAM;oBACN,QAAQ,EAAE,IAAI;oBACd,QAAQ,EAAE,KAAK;oBACf,MAAM,EAAE,MAAM,IAAI,SAAS;iBAC5B;gBACD,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,MAAM;wBACZ,GAAG,EAAE,QAAQ;wBACb,OAAO,EAAE,OAAO,QAAQ,UAAU,IAAI,IAAI,MAAM,GAAG;wBACnD,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;qBACpC;iBACF;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/src/fs/listDir.d.ts
CHANGED
|
@@ -11,7 +11,8 @@ interface DirEntry {
|
|
|
11
11
|
* @effect none
|
|
12
12
|
*/
|
|
13
13
|
export declare function listDir(args: {
|
|
14
|
-
path
|
|
14
|
+
/** Directory path to list; defaults to "." when missing or empty. */
|
|
15
|
+
path?: string;
|
|
15
16
|
maxEntries?: number;
|
|
16
17
|
includeHidden?: boolean;
|
|
17
18
|
recursive?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listDir.d.ts","sourceRoot":"","sources":["../../../src/fs/listDir.ts"],"names":[],"mappings":"AAWA,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,4FAA4F;IAC5F,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE;IAClC,IAAI,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"listDir.d.ts","sourceRoot":"","sources":["../../../src/fs/listDir.ts"],"names":[],"mappings":"AAWA,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,4FAA4F;IAC5F,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE;IAClC,qEAAqE;IACrE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;;;;;;;;;;;;;GAiDA"}
|
package/dist/src/fs/listDir.js
CHANGED
|
@@ -19,10 +19,7 @@ export async function listDir(args) {
|
|
|
19
19
|
};
|
|
20
20
|
const ctx = getExtensionContext();
|
|
21
21
|
const cfg = overrideWithConfig(defaults, ctx.config);
|
|
22
|
-
const inputPath = args.path?.trim();
|
|
23
|
-
if (!inputPath) {
|
|
24
|
-
throw new Error("path is required");
|
|
25
|
-
}
|
|
22
|
+
const inputPath = args.path?.trim() || ".";
|
|
26
23
|
const sandboxRoot = cfg.sandboxRoot ?? "";
|
|
27
24
|
const maxEntries = args.maxEntries ?? cfg.maxEntries ?? defaults.maxEntries;
|
|
28
25
|
const includeHidden = args.includeHidden ?? false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listDir.js","sourceRoot":"","sources":["../../../src/fs/listDir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAUnE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"listDir.js","sourceRoot":"","sources":["../../../src/fs/listDir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAUnE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAO7B;IACC,8EAA8E;IAC9E,MAAM,QAAQ,GAAG;QACf,WAAW,EAAE,oBAAoB;QACjC,UAAU,EAAE,wBAAwB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AAE,EAAE,CAAC;YAC5B,IAAI,GAAG,SAAS,CAAC;QACnB,CAAC;aAAM,IAAI,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC;YAChC,IAAI,GAAG,WAAW,CAAC;QACrB,CAAC;aAAM,IAAI,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;YAC3B,IAAI,GAAG,MAAM,CAAC;QAChB,CAAC;aAAM,CAAC;YACN,IAAI,GAAG,OAAO,CAAC;QACjB,CAAC;QAED,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,CAAC;YACxC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC;YACtB,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QACxC,CAAC;QAAC,MAAM,CAAC;YACP,mBAAmB;QACrB,CAAC;QAED,OAAO,CAAC,IAAI,CAAC;YACX,IAAI,EAAE,aAAa;YACnB,IAAI;YACJ,IAAI;YACJ,KAAK;SACN,CAAC,CAAC;QAEH,2BAA2B;QAC3B,IACE,OAAO,CAAC,SAAS;YACjB,IAAI,KAAK,WAAW;YACpB,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,QAAQ,EACvC,CAAC;YACD,MAAM,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE;gBAC9C,GAAG,OAAO;gBACV,YAAY,EAAE,OAAO,CAAC,YAAY,GAAG,CAAC;aACvC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface GitExecResult {
|
|
2
|
+
stdout: string;
|
|
3
|
+
stderr: string;
|
|
4
|
+
exitCode: number;
|
|
5
|
+
}
|
|
6
|
+
export interface GitHistoryCommit {
|
|
7
|
+
hash: string;
|
|
8
|
+
authorName: string;
|
|
9
|
+
authorEmail: string;
|
|
10
|
+
date: string;
|
|
11
|
+
subject: string;
|
|
12
|
+
body: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function runProcess(args: {
|
|
15
|
+
bin: string;
|
|
16
|
+
cmdArgs: string[];
|
|
17
|
+
cwd: string;
|
|
18
|
+
timeoutMs: number;
|
|
19
|
+
maxOutputBytes: number;
|
|
20
|
+
}): Promise<GitExecResult>;
|
|
21
|
+
export declare function resolveRepoPath(inputPath: string, sandboxRoot: string): Promise<string>;
|
|
22
|
+
export declare function failOnNonZero(command: string, out: GitExecResult): void;
|
|
23
|
+
export declare function parseGitHistory(stdout: string): GitHistoryCommit[];
|
|
24
|
+
export declare function buildGitConfig(): {
|
|
25
|
+
sandboxRoot: string;
|
|
26
|
+
gitTimeoutMs: number;
|
|
27
|
+
gitMaxOutputBytes: number;
|
|
28
|
+
};
|
|
29
|
+
export declare function ensureGhAvailable(args: {
|
|
30
|
+
cwd: string;
|
|
31
|
+
timeoutMs: number;
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
export declare function resolveCwd(repoPath: string): string;
|
|
34
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/git/common.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB,GAAG,OAAO,CAAC,aAAa,CAAC,CA0EzB;AAED,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAK7F;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,GAAG,IAAI,CAQvE;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAiBlE;AAED,wBAAgB,cAAc;;;;EAQ7B;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,IAAI,CAAC,CAehB;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEnD"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { resolve as pathResolve } from "node:path";
|
|
3
|
+
import { createTaggedError, resolveSandboxedPath } from "@easynet/agent-tool";
|
|
4
|
+
import { getExtensionContext } from "../../index.js";
|
|
5
|
+
import { overrideWithConfig } from "../util/overrideWithConfig.js";
|
|
6
|
+
import { DEFAULT_GIT_MAX_OUTPUT_BYTES, DEFAULT_GIT_TIMEOUT_MS, } from "./defaults.js";
|
|
7
|
+
export async function runProcess(args) {
|
|
8
|
+
return new Promise((resolvePromise, rejectPromise) => {
|
|
9
|
+
const proc = spawn(args.bin, args.cmdArgs, {
|
|
10
|
+
cwd: args.cwd,
|
|
11
|
+
shell: false,
|
|
12
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
13
|
+
env: { ...process.env, GIT_PAGER: "cat" },
|
|
14
|
+
});
|
|
15
|
+
let stdout = "";
|
|
16
|
+
let stderr = "";
|
|
17
|
+
let totalBytes = 0;
|
|
18
|
+
let settled = false;
|
|
19
|
+
const failOnce = (err) => {
|
|
20
|
+
if (settled)
|
|
21
|
+
return;
|
|
22
|
+
settled = true;
|
|
23
|
+
rejectPromise(err);
|
|
24
|
+
};
|
|
25
|
+
const doneOnce = (value) => {
|
|
26
|
+
if (settled)
|
|
27
|
+
return;
|
|
28
|
+
settled = true;
|
|
29
|
+
resolvePromise(value);
|
|
30
|
+
};
|
|
31
|
+
const append = (chunk, dest) => {
|
|
32
|
+
const len = Buffer.byteLength(chunk, "utf-8");
|
|
33
|
+
if (totalBytes + len > args.maxOutputBytes) {
|
|
34
|
+
proc.kill("SIGKILL");
|
|
35
|
+
failOnce(createTaggedError("GIT_OUTPUT_TOO_LARGE", `Git command output exceeded ${args.maxOutputBytes} bytes`, { maxBytes: args.maxOutputBytes }));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
totalBytes += len;
|
|
39
|
+
if (dest === "stdout")
|
|
40
|
+
stdout += chunk;
|
|
41
|
+
else
|
|
42
|
+
stderr += chunk;
|
|
43
|
+
};
|
|
44
|
+
proc.stdout?.setEncoding("utf-8");
|
|
45
|
+
proc.stderr?.setEncoding("utf-8");
|
|
46
|
+
proc.stdout?.on("data", (chunk) => append(chunk, "stdout"));
|
|
47
|
+
proc.stderr?.on("data", (chunk) => append(chunk, "stderr"));
|
|
48
|
+
const timer = setTimeout(() => {
|
|
49
|
+
proc.kill("SIGKILL");
|
|
50
|
+
failOnce(createTaggedError("GIT_TIMEOUT", `${args.bin} ${args.cmdArgs.join(" ")} timed out after ${args.timeoutMs}ms`, { timeoutMs: args.timeoutMs }));
|
|
51
|
+
}, args.timeoutMs);
|
|
52
|
+
proc.on("error", (err) => {
|
|
53
|
+
clearTimeout(timer);
|
|
54
|
+
failOnce(createTaggedError("GIT_SPAWN_ERROR", err.message, { command: args.bin }));
|
|
55
|
+
});
|
|
56
|
+
proc.on("close", (code) => {
|
|
57
|
+
clearTimeout(timer);
|
|
58
|
+
doneOnce({
|
|
59
|
+
stdout,
|
|
60
|
+
stderr,
|
|
61
|
+
exitCode: code ?? 1,
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export async function resolveRepoPath(inputPath, sandboxRoot) {
|
|
67
|
+
if (!inputPath.trim()) {
|
|
68
|
+
throw createTaggedError("GIT_INVALID", "path is required", {});
|
|
69
|
+
}
|
|
70
|
+
return resolveSandboxedPath(inputPath, sandboxRoot);
|
|
71
|
+
}
|
|
72
|
+
export function failOnNonZero(command, out) {
|
|
73
|
+
if (out.exitCode !== 0) {
|
|
74
|
+
throw createTaggedError("GIT_COMMAND_FAILED", `git ${command} failed with exit ${out.exitCode}: ${(out.stderr || out.stdout).slice(0, 500)}`, { exitCode: out.exitCode });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export function parseGitHistory(stdout) {
|
|
78
|
+
return stdout
|
|
79
|
+
.split("\x1e")
|
|
80
|
+
.map((s) => s.trim())
|
|
81
|
+
.filter(Boolean)
|
|
82
|
+
.map((row) => {
|
|
83
|
+
const parts = row.split("\x1f");
|
|
84
|
+
return {
|
|
85
|
+
hash: parts[0] ?? "",
|
|
86
|
+
authorName: parts[1] ?? "",
|
|
87
|
+
authorEmail: parts[2] ?? "",
|
|
88
|
+
date: parts[3] ?? "",
|
|
89
|
+
subject: parts[4] ?? "",
|
|
90
|
+
body: parts[5] ?? "",
|
|
91
|
+
};
|
|
92
|
+
})
|
|
93
|
+
.filter((c) => c.hash !== "");
|
|
94
|
+
}
|
|
95
|
+
export function buildGitConfig() {
|
|
96
|
+
const defaults = {
|
|
97
|
+
sandboxRoot: "",
|
|
98
|
+
gitTimeoutMs: DEFAULT_GIT_TIMEOUT_MS,
|
|
99
|
+
gitMaxOutputBytes: DEFAULT_GIT_MAX_OUTPUT_BYTES,
|
|
100
|
+
};
|
|
101
|
+
const ctx = getExtensionContext();
|
|
102
|
+
return overrideWithConfig(defaults, ctx.config);
|
|
103
|
+
}
|
|
104
|
+
export async function ensureGhAvailable(args) {
|
|
105
|
+
const check = await runProcess({
|
|
106
|
+
bin: "gh",
|
|
107
|
+
cmdArgs: ["--version"],
|
|
108
|
+
cwd: pathResolve(args.cwd),
|
|
109
|
+
timeoutMs: args.timeoutMs,
|
|
110
|
+
maxOutputBytes: 1024 * 32,
|
|
111
|
+
}).catch((err) => {
|
|
112
|
+
throw createTaggedError("GIT_TOOL_MISSING", `GitHub CLI (gh) is required: ${err instanceof Error ? err.message : String(err)}`, {});
|
|
113
|
+
});
|
|
114
|
+
failOnNonZero("gh --version", check);
|
|
115
|
+
}
|
|
116
|
+
export function resolveCwd(repoPath) {
|
|
117
|
+
return pathResolve(repoPath);
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=common.js.map
|