@swifty.js/swifty 0.0.21 → 0.0.22
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/{agent-ZCMBUWLZ.js → agent-5T7KNC7V.js} +1 -1
- package/dist/{anthropic-4ZVG7AMA.js → anthropic-P2R4GW6F.js} +1 -1
- package/dist/{chunk-Y5WGBAGP.js → chunk-HJIGA37J.js} +1 -1
- package/dist/{chunk-DDBH5AEN.js → chunk-L73IHJF4.js} +53 -53
- package/dist/{chunk-S6ZADC7C.js → chunk-NEAR6YPZ.js} +1 -1
- package/dist/{chunk-MUPVOATV.js → chunk-NLNH3IRT.js} +1 -1
- package/dist/{chunk-6E6UA7MT.js → chunk-YQQVB6VB.js} +9 -8
- package/dist/lib/agent-2AGRYN3R.js +9 -0
- package/dist/lib/anthropic-GFWP3ORB.js +22 -0
- package/dist/lib/bwrap-QRGPUP4J.js +6 -0
- package/dist/lib/checker-IIXJXQCB.js +19 -0
- package/dist/lib/chunk-6GOWRPYS.js +339 -0
- package/dist/lib/chunk-7URDLWQN.js +426 -0
- package/dist/lib/chunk-C7IHCJZ3.js +849 -0
- package/dist/lib/chunk-EJLGB2EJ.js +377 -0
- package/dist/lib/chunk-GHF2PSEW.js +8 -0
- package/dist/lib/chunk-GNBXECZN.js +243 -0
- package/dist/lib/chunk-HK2Z6WP4.js +223 -0
- package/dist/lib/chunk-LUEP4JMF.js +549 -0
- package/dist/lib/chunk-ORSYNBMM.js +38 -0
- package/dist/lib/chunk-RR2CZ6CY.js +598 -0
- package/dist/lib/chunk-UHVO63Y7.js +1246 -0
- package/dist/lib/chunk-UMFNTXKA.js +88 -0
- package/dist/lib/chunk-VUD72RTY.js +39 -0
- package/dist/lib/glob.wasm +0 -0
- package/dist/lib/index.d.ts +5350 -0
- package/dist/lib/index.js +12002 -0
- package/dist/lib/openai-HXRMPNB7.js +15 -0
- package/dist/lib/seatbelt-FT5IY73W.js +6 -0
- package/dist/lib/tool-filter-VF7TZRE5.js +19 -0
- package/dist/main.js +225 -225
- package/dist/{openai-HXD52MZB.js → openai-TVUUHRG7.js} +1 -1
- package/dist/{server-VMHWEO2Y.js → server-ZTLHJWEQ.js} +14 -14
- package/package.json +14 -2
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// src/conversation/pairing.ts
|
|
2
|
+
var INTERRUPTED_TOOL_RESULT = "Tool execution was interrupted. The tool may or may not have completed; verify before relying on its effects.";
|
|
3
|
+
var REJECTED_TOOL_RESULT = "The user rejected this tool use. Nothing was changed (for file edits, the new content was NOT written).";
|
|
4
|
+
function ensureToolPairing(messages) {
|
|
5
|
+
const resolved = /* @__PURE__ */ new Set();
|
|
6
|
+
const issued = /* @__PURE__ */ new Set();
|
|
7
|
+
for (const m of messages) {
|
|
8
|
+
for (const tr of m.toolResults ?? []) {
|
|
9
|
+
resolved.add(tr.toolUseId);
|
|
10
|
+
}
|
|
11
|
+
for (const tu of m.toolUses ?? []) {
|
|
12
|
+
issued.add(tu.toolUseId);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const out = [];
|
|
16
|
+
for (const m of messages) {
|
|
17
|
+
let current = m;
|
|
18
|
+
if ((m.toolResults?.length ?? 0) > 0) {
|
|
19
|
+
const kept = (m.toolResults ?? []).filter((tr) => issued.has(tr.toolUseId));
|
|
20
|
+
if (kept.length === 0 && !m.content && !(m.toolUses?.length ?? 0)) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
current = { ...m, toolResults: kept };
|
|
24
|
+
}
|
|
25
|
+
out.push(current);
|
|
26
|
+
const missing = [];
|
|
27
|
+
for (const tu of m.toolUses ?? []) {
|
|
28
|
+
if (resolved.has(tu.toolUseId)) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
missing.push({
|
|
32
|
+
toolUseId: tu.toolUseId,
|
|
33
|
+
content: INTERRUPTED_TOOL_RESULT,
|
|
34
|
+
isError: true
|
|
35
|
+
});
|
|
36
|
+
resolved.add(tu.toolUseId);
|
|
37
|
+
}
|
|
38
|
+
if (missing.length > 0) {
|
|
39
|
+
out.push({ role: "user", content: "", toolResults: missing });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/llm/errors.ts
|
|
46
|
+
var LLMError = class extends Error {
|
|
47
|
+
constructor(message) {
|
|
48
|
+
super(message);
|
|
49
|
+
this.name = "LLMError";
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var AuthenticationError = class extends LLMError {
|
|
53
|
+
constructor(message) {
|
|
54
|
+
super(message);
|
|
55
|
+
this.name = "AuthenticationError";
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var RateLimitError = class extends LLMError {
|
|
59
|
+
retryAfter;
|
|
60
|
+
constructor(message, retryAfter) {
|
|
61
|
+
super(message);
|
|
62
|
+
this.name = "RateLimitError";
|
|
63
|
+
this.retryAfter = retryAfter;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var NetworkError = class extends LLMError {
|
|
67
|
+
constructor(message) {
|
|
68
|
+
super(message);
|
|
69
|
+
this.name = "NetworkError";
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var ContextTooLongError = class extends LLMError {
|
|
73
|
+
constructor(message) {
|
|
74
|
+
super(message);
|
|
75
|
+
this.name = "ContextTooLongError";
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
INTERRUPTED_TOOL_RESULT,
|
|
81
|
+
REJECTED_TOOL_RESULT,
|
|
82
|
+
ensureToolPairing,
|
|
83
|
+
LLMError,
|
|
84
|
+
AuthenticationError,
|
|
85
|
+
RateLimitError,
|
|
86
|
+
NetworkError,
|
|
87
|
+
ContextTooLongError
|
|
88
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/sandbox/seatbelt.ts
|
|
2
|
+
import { existsSync, statSync } from "fs";
|
|
3
|
+
var SANDBOX_EXEC_PATH = "/usr/bin/sandbox-exec";
|
|
4
|
+
var SeatbeltSandbox = class {
|
|
5
|
+
available() {
|
|
6
|
+
return existsSync(SANDBOX_EXEC_PATH);
|
|
7
|
+
}
|
|
8
|
+
wrap(command, config) {
|
|
9
|
+
const profile = buildProfile(config);
|
|
10
|
+
const escaped = command.replace(/'/g, "'\\''");
|
|
11
|
+
return `${SANDBOX_EXEC_PATH} -p '${profile}' bash -c '${escaped}'`;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
function buildProfile(config) {
|
|
15
|
+
const lines = [];
|
|
16
|
+
lines.push("(version 1)");
|
|
17
|
+
lines.push("(deny default)");
|
|
18
|
+
lines.push("(allow process-exec)");
|
|
19
|
+
lines.push("(allow process-fork)");
|
|
20
|
+
lines.push("(allow sysctl-read)");
|
|
21
|
+
lines.push('(allow file-read* (subpath "/"))');
|
|
22
|
+
for (const path of config.allowWrite) {
|
|
23
|
+
lines.push(`(allow file-write* (subpath "${path}"))`);
|
|
24
|
+
}
|
|
25
|
+
for (const path of config.denyWrite) {
|
|
26
|
+
const matcher = existsSync(path) && statSync(path).isDirectory() ? "subpath" : "literal";
|
|
27
|
+
lines.push(`(deny file-write* (${matcher} "${path}"))`);
|
|
28
|
+
}
|
|
29
|
+
if (config.networkEnabled) {
|
|
30
|
+
lines.push("(allow network*)");
|
|
31
|
+
} else {
|
|
32
|
+
lines.push("(deny network*)");
|
|
33
|
+
}
|
|
34
|
+
return lines.join("\n");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
SeatbeltSandbox
|
|
39
|
+
};
|
|
Binary file
|