@hasna/assistants 0.6.16 → 0.6.18
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/index.js +211 -5
- package/dist/index.js.map +5 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -36133,6 +36133,25 @@ import { dirname, join as join2 } from "path";
|
|
|
36133
36133
|
// packages/core/src/config.ts
|
|
36134
36134
|
import { join } from "path";
|
|
36135
36135
|
import { homedir } from "os";
|
|
36136
|
+
var DEFAULT_SYSTEM_PROMPT = `You are a helpful AI assistant running in the terminal.
|
|
36137
|
+
|
|
36138
|
+
## Runtime Environment
|
|
36139
|
+
- Use **Bun** as the default runtime for JavaScript/TypeScript scripts
|
|
36140
|
+
- When creating scripts, use the shebang \`#!/usr/bin/env bun\`
|
|
36141
|
+
- Prefer Bun APIs (Bun.file, Bun.write, etc.) over Node.js equivalents when available
|
|
36142
|
+
- For package management, prefer \`bun install\` over \`npm install\`
|
|
36143
|
+
|
|
36144
|
+
## Code Style
|
|
36145
|
+
- Write clean, readable code with meaningful variable names
|
|
36146
|
+
- Add comments only when the logic isn't self-evident
|
|
36147
|
+
- Prefer simple solutions over complex abstractions
|
|
36148
|
+
- Use TypeScript when type safety is beneficial
|
|
36149
|
+
|
|
36150
|
+
## Communication
|
|
36151
|
+
- Be concise and direct in responses
|
|
36152
|
+
- Ask clarifying questions when requirements are ambiguous
|
|
36153
|
+
- Explain your reasoning when making architectural decisions
|
|
36154
|
+
`;
|
|
36136
36155
|
var DEFAULT_CONFIG = {
|
|
36137
36156
|
llm: {
|
|
36138
36157
|
provider: "anthropic",
|
|
@@ -36361,7 +36380,7 @@ async function loadSystemPrompt(cwd2 = process.cwd()) {
|
|
|
36361
36380
|
if (projectPrompt)
|
|
36362
36381
|
prompts.push(projectPrompt);
|
|
36363
36382
|
if (prompts.length === 0) {
|
|
36364
|
-
return
|
|
36383
|
+
return DEFAULT_SYSTEM_PROMPT;
|
|
36365
36384
|
}
|
|
36366
36385
|
return prompts.join(`
|
|
36367
36386
|
|
|
@@ -45715,7 +45734,24 @@ function getToolContext(toolCall) {
|
|
|
45715
45734
|
return truncate(String(input.pattern || ""), 20);
|
|
45716
45735
|
case "grep":
|
|
45717
45736
|
return truncate(String(input.pattern || ""), 20);
|
|
45737
|
+
case "schedule":
|
|
45738
|
+
return String(input.action || "");
|
|
45739
|
+
case "feedback":
|
|
45740
|
+
return String(input.type || "feedback");
|
|
45741
|
+
case "web_search":
|
|
45742
|
+
return truncate(String(input.query || ""), 20);
|
|
45743
|
+
case "web_fetch":
|
|
45744
|
+
case "curl":
|
|
45745
|
+
const url = String(input.url || "");
|
|
45746
|
+
try {
|
|
45747
|
+
return new URL(url).hostname;
|
|
45748
|
+
} catch {
|
|
45749
|
+
return truncate(url, 20);
|
|
45750
|
+
}
|
|
45718
45751
|
default:
|
|
45752
|
+
const action = input.action || input.command || input.operation;
|
|
45753
|
+
if (action)
|
|
45754
|
+
return truncate(String(action), 20);
|
|
45719
45755
|
return "";
|
|
45720
45756
|
}
|
|
45721
45757
|
}
|
|
@@ -45739,6 +45775,10 @@ function getToolDisplayName(toolCall) {
|
|
|
45739
45775
|
return "grep";
|
|
45740
45776
|
case "display_image":
|
|
45741
45777
|
return "image";
|
|
45778
|
+
case "schedule":
|
|
45779
|
+
return "schedule";
|
|
45780
|
+
case "feedback":
|
|
45781
|
+
return "feedback";
|
|
45742
45782
|
case "notion":
|
|
45743
45783
|
case "gmail":
|
|
45744
45784
|
case "googledrive":
|
|
@@ -45769,6 +45809,10 @@ function formatToolCall(toolCall) {
|
|
|
45769
45809
|
return `Finding: ${truncate(String(input.pattern || ""), 60)}`;
|
|
45770
45810
|
case "grep":
|
|
45771
45811
|
return `Searching: ${truncate(String(input.pattern || ""), 60)}`;
|
|
45812
|
+
case "schedule":
|
|
45813
|
+
return formatScheduleCall(input);
|
|
45814
|
+
case "feedback":
|
|
45815
|
+
return formatFeedbackCall(input);
|
|
45772
45816
|
case "notion":
|
|
45773
45817
|
return `Notion: ${truncate(String(input.command || input.action || ""), 60)}`;
|
|
45774
45818
|
case "gmail":
|
|
@@ -45782,9 +45826,44 @@ function formatToolCall(toolCall) {
|
|
|
45782
45826
|
case "slack":
|
|
45783
45827
|
return `Slack: ${truncate(String(input.command || input.action || ""), 60)}`;
|
|
45784
45828
|
default:
|
|
45785
|
-
|
|
45829
|
+
if (name.startsWith("connect_") || name.includes("_")) {
|
|
45830
|
+
const action = String(input.command || input.action || input.operation || "");
|
|
45831
|
+
if (action) {
|
|
45832
|
+
return `${formatToolDisplayName(name)}: ${truncate(action, 50)}`;
|
|
45833
|
+
}
|
|
45834
|
+
}
|
|
45835
|
+
return `${formatToolDisplayName(name)}: ${truncate(JSON.stringify(input), 50)}`;
|
|
45836
|
+
}
|
|
45837
|
+
}
|
|
45838
|
+
function formatToolDisplayName(name) {
|
|
45839
|
+
return name.replace(/^connect_/, "").replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
45840
|
+
}
|
|
45841
|
+
function formatScheduleCall(input) {
|
|
45842
|
+
const action = String(input.action || "");
|
|
45843
|
+
switch (action) {
|
|
45844
|
+
case "list":
|
|
45845
|
+
return "Listing scheduled tasks";
|
|
45846
|
+
case "create":
|
|
45847
|
+
const cmd = truncate(String(input.command || ""), 30);
|
|
45848
|
+
const schedule = String(input.schedule || "");
|
|
45849
|
+
return `Creating schedule: "${cmd}" (${schedule})`;
|
|
45850
|
+
case "update":
|
|
45851
|
+
return `Updating schedule: ${input.id || "unknown"}`;
|
|
45852
|
+
case "delete":
|
|
45853
|
+
return `Deleting schedule: ${input.id || "unknown"}`;
|
|
45854
|
+
case "pause":
|
|
45855
|
+
return `Pausing schedule: ${input.id || "unknown"}`;
|
|
45856
|
+
case "resume":
|
|
45857
|
+
return `Resuming schedule: ${input.id || "unknown"}`;
|
|
45858
|
+
default:
|
|
45859
|
+
return `Schedule: ${action || "unknown action"}`;
|
|
45786
45860
|
}
|
|
45787
45861
|
}
|
|
45862
|
+
function formatFeedbackCall(input) {
|
|
45863
|
+
const type = String(input.type || "feedback");
|
|
45864
|
+
const title = truncate(String(input.title || ""), 40);
|
|
45865
|
+
return `Submitting ${type}: ${title}`;
|
|
45866
|
+
}
|
|
45788
45867
|
function truncate(text, maxLength) {
|
|
45789
45868
|
if (text.length <= maxLength)
|
|
45790
45869
|
return text;
|
|
@@ -45792,8 +45871,12 @@ function truncate(text, maxLength) {
|
|
|
45792
45871
|
}
|
|
45793
45872
|
function truncateToolResult(toolResult, maxLines = 15, maxChars = 3000) {
|
|
45794
45873
|
const toolName = toolResult.toolName || "tool";
|
|
45795
|
-
const prefix = toolResult.isError ? `Error from ${toolName}: ` : `${toolName}: `;
|
|
45796
45874
|
let content = String(toolResult.content || "");
|
|
45875
|
+
const formatted = formatToolResultNicely(toolName, content, toolResult.isError);
|
|
45876
|
+
if (formatted) {
|
|
45877
|
+
return formatted;
|
|
45878
|
+
}
|
|
45879
|
+
const prefix = toolResult.isError ? `Error: ` : "";
|
|
45797
45880
|
content = content.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "");
|
|
45798
45881
|
content = content.replace(/\t/g, " ");
|
|
45799
45882
|
const lines = content.split(`
|
|
@@ -45808,6 +45891,129 @@ function truncateToolResult(toolResult, maxLines = 15, maxChars = 3000) {
|
|
|
45808
45891
|
}
|
|
45809
45892
|
return prefix + content.trim();
|
|
45810
45893
|
}
|
|
45894
|
+
function formatToolResultNicely(toolName, content, isError) {
|
|
45895
|
+
if (isError) {
|
|
45896
|
+
if (content.includes("ENOENT") || content.includes("no such file")) {
|
|
45897
|
+
return "\u26A0 File not found";
|
|
45898
|
+
}
|
|
45899
|
+
if (content.includes("EACCES") || content.includes("permission denied")) {
|
|
45900
|
+
return "\u26A0 Permission denied";
|
|
45901
|
+
}
|
|
45902
|
+
if (content.includes("ETIMEDOUT") || content.includes("timeout")) {
|
|
45903
|
+
return "\u26A0 Request timed out";
|
|
45904
|
+
}
|
|
45905
|
+
return null;
|
|
45906
|
+
}
|
|
45907
|
+
switch (toolName) {
|
|
45908
|
+
case "schedule":
|
|
45909
|
+
return formatScheduleResult(content);
|
|
45910
|
+
case "feedback":
|
|
45911
|
+
return formatFeedbackResult(content);
|
|
45912
|
+
case "read":
|
|
45913
|
+
return formatReadResult(content);
|
|
45914
|
+
case "write":
|
|
45915
|
+
return formatWriteResult(content);
|
|
45916
|
+
case "glob":
|
|
45917
|
+
return formatGlobResult(content);
|
|
45918
|
+
case "grep":
|
|
45919
|
+
return formatGrepResult(content);
|
|
45920
|
+
case "bash":
|
|
45921
|
+
return formatBashResult(content);
|
|
45922
|
+
case "web_search":
|
|
45923
|
+
return formatSearchResult(content);
|
|
45924
|
+
default:
|
|
45925
|
+
return null;
|
|
45926
|
+
}
|
|
45927
|
+
}
|
|
45928
|
+
function formatScheduleResult(content) {
|
|
45929
|
+
const trimmed = content.trim().toLowerCase();
|
|
45930
|
+
if (trimmed === "no schedules found." || trimmed.includes("no schedules")) {
|
|
45931
|
+
return "\uD83D\uDCC5 No scheduled tasks";
|
|
45932
|
+
}
|
|
45933
|
+
if (trimmed.includes("created") || trimmed.includes("scheduled")) {
|
|
45934
|
+
return "\u2713 Schedule created";
|
|
45935
|
+
}
|
|
45936
|
+
if (trimmed.includes("deleted") || trimmed.includes("removed")) {
|
|
45937
|
+
return "\u2713 Schedule deleted";
|
|
45938
|
+
}
|
|
45939
|
+
if (trimmed.includes("paused")) {
|
|
45940
|
+
return "\u23F8 Schedule paused";
|
|
45941
|
+
}
|
|
45942
|
+
if (trimmed.includes("resumed")) {
|
|
45943
|
+
return "\u25B6 Schedule resumed";
|
|
45944
|
+
}
|
|
45945
|
+
if (content.includes("id:") || content.includes("command:")) {
|
|
45946
|
+
const lines = content.split(`
|
|
45947
|
+
`).filter((l) => l.trim());
|
|
45948
|
+
return `\uD83D\uDCC5 ${lines.length} scheduled task${lines.length !== 1 ? "s" : ""}`;
|
|
45949
|
+
}
|
|
45950
|
+
return null;
|
|
45951
|
+
}
|
|
45952
|
+
function formatFeedbackResult(content) {
|
|
45953
|
+
if (content.includes("submitted") || content.includes("created")) {
|
|
45954
|
+
return "\u2713 Feedback submitted";
|
|
45955
|
+
}
|
|
45956
|
+
return null;
|
|
45957
|
+
}
|
|
45958
|
+
function formatReadResult(content) {
|
|
45959
|
+
const lines = content.split(`
|
|
45960
|
+
`).length;
|
|
45961
|
+
if (lines > 20) {
|
|
45962
|
+
return `\uD83D\uDCC4 Read ${lines} lines`;
|
|
45963
|
+
}
|
|
45964
|
+
return null;
|
|
45965
|
+
}
|
|
45966
|
+
function formatWriteResult(content) {
|
|
45967
|
+
if (content.includes("written") || content.includes("saved") || content.includes("created")) {
|
|
45968
|
+
return "\u2713 File saved";
|
|
45969
|
+
}
|
|
45970
|
+
return null;
|
|
45971
|
+
}
|
|
45972
|
+
function formatGlobResult(content) {
|
|
45973
|
+
const lines = content.split(`
|
|
45974
|
+
`).filter((l) => l.trim());
|
|
45975
|
+
if (lines.length === 0) {
|
|
45976
|
+
return "\uD83D\uDD0D No files found";
|
|
45977
|
+
}
|
|
45978
|
+
if (lines.length > 10) {
|
|
45979
|
+
return `\uD83D\uDD0D Found ${lines.length} files`;
|
|
45980
|
+
}
|
|
45981
|
+
return null;
|
|
45982
|
+
}
|
|
45983
|
+
function formatGrepResult(content) {
|
|
45984
|
+
const lines = content.split(`
|
|
45985
|
+
`).filter((l) => l.trim());
|
|
45986
|
+
if (lines.length === 0) {
|
|
45987
|
+
return "\uD83D\uDD0D No matches found";
|
|
45988
|
+
}
|
|
45989
|
+
if (lines.length > 10) {
|
|
45990
|
+
return `\uD83D\uDD0D Found ${lines.length} matches`;
|
|
45991
|
+
}
|
|
45992
|
+
return null;
|
|
45993
|
+
}
|
|
45994
|
+
function formatBashResult(content) {
|
|
45995
|
+
const trimmed = content.trim();
|
|
45996
|
+
if (!trimmed) {
|
|
45997
|
+
return "\u2713 Command completed";
|
|
45998
|
+
}
|
|
45999
|
+
if (trimmed.length < 100 && !trimmed.includes(`
|
|
46000
|
+
`)) {
|
|
46001
|
+
return null;
|
|
46002
|
+
}
|
|
46003
|
+
const lines = trimmed.split(`
|
|
46004
|
+
`).length;
|
|
46005
|
+
if (lines > 20) {
|
|
46006
|
+
return `\u2713 Output: ${lines} lines`;
|
|
46007
|
+
}
|
|
46008
|
+
return null;
|
|
46009
|
+
}
|
|
46010
|
+
function formatSearchResult(content) {
|
|
46011
|
+
const resultCount = (content.match(/https?:\/\//g) || []).length;
|
|
46012
|
+
if (resultCount > 0) {
|
|
46013
|
+
return `\uD83D\uDD0D Found ${resultCount} result${resultCount !== 1 ? "s" : ""}`;
|
|
46014
|
+
}
|
|
46015
|
+
return null;
|
|
46016
|
+
}
|
|
45811
46017
|
|
|
45812
46018
|
// packages/terminal/src/components/Status.tsx
|
|
45813
46019
|
var import_react25 = __toESM(require_react(), 1);
|
|
@@ -47315,7 +47521,7 @@ function formatStreamEvent(chunk) {
|
|
|
47315
47521
|
|
|
47316
47522
|
// packages/terminal/src/index.tsx
|
|
47317
47523
|
var jsx_dev_runtime11 = __toESM(require_jsx_dev_runtime(), 1);
|
|
47318
|
-
var VERSION3 = "0.6.
|
|
47524
|
+
var VERSION3 = "0.6.18";
|
|
47319
47525
|
function parseArgs(argv) {
|
|
47320
47526
|
const args = argv.slice(2);
|
|
47321
47527
|
const options = {
|
|
@@ -47478,4 +47684,4 @@ if (options.print !== null) {
|
|
|
47478
47684
|
});
|
|
47479
47685
|
}
|
|
47480
47686
|
|
|
47481
|
-
//# debugId=
|
|
47687
|
+
//# debugId=EED40350F624F85864756E2164756E21
|