@drisp/cli 0.3.39
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/LICENSE +21 -0
- package/README.md +284 -0
- package/dist/WorkflowInstallWizard-5JWVHIVJ.js +93 -0
- package/dist/athena-gateway.js +3998 -0
- package/dist/chunk-3FVULBV4.js +839 -0
- package/dist/chunk-LPG5WBPV.js +2621 -0
- package/dist/chunk-PSD3WBN4.js +150 -0
- package/dist/cli.js +29284 -0
- package/dist/hook-forwarder.js +142 -0
- package/package.json +118 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// src/harnesses/claude/runtime/socketPath.ts
|
|
2
|
+
import os from "os";
|
|
3
|
+
import path from "path";
|
|
4
|
+
var ATHENA_HOOK_SOCKET_ENV = "ATHENA_HOOK_SOCKET";
|
|
5
|
+
var MAX_UNIX_SOCKET_PATH_BYTES = {
|
|
6
|
+
darwin: 103,
|
|
7
|
+
default: 107
|
|
8
|
+
};
|
|
9
|
+
function getUid() {
|
|
10
|
+
if (typeof process.getuid === "function") {
|
|
11
|
+
return String(process.getuid());
|
|
12
|
+
}
|
|
13
|
+
return os.userInfo().username;
|
|
14
|
+
}
|
|
15
|
+
function getSocketPathLimit() {
|
|
16
|
+
return process.platform === "darwin" ? MAX_UNIX_SOCKET_PATH_BYTES.darwin : MAX_UNIX_SOCKET_PATH_BYTES.default;
|
|
17
|
+
}
|
|
18
|
+
function resolveAthenaRuntimeDir() {
|
|
19
|
+
const explicit = process.env["ATHENA_RUNTIME_DIR"];
|
|
20
|
+
if (explicit) return explicit;
|
|
21
|
+
const xdgRuntimeDir = process.env["XDG_RUNTIME_DIR"];
|
|
22
|
+
if (xdgRuntimeDir) return path.join(xdgRuntimeDir, "athena");
|
|
23
|
+
return path.join("/tmp", `athena-${getUid()}`);
|
|
24
|
+
}
|
|
25
|
+
function resolveHookSocketPath(instanceId) {
|
|
26
|
+
return path.join(resolveAthenaRuntimeDir(), "run", `ink-${instanceId}.sock`);
|
|
27
|
+
}
|
|
28
|
+
function isSocketPathTooLong(socketPath) {
|
|
29
|
+
return Buffer.byteLength(socketPath) > getSocketPathLimit();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// src/harnesses/claude/protocol/envelope.ts
|
|
33
|
+
function isValidHookEventEnvelope(obj) {
|
|
34
|
+
if (typeof obj !== "object" || obj === null) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const envelope = obj;
|
|
38
|
+
return typeof envelope["request_id"] === "string" && envelope["request_id"].length > 0 && typeof envelope["ts"] === "number" && typeof envelope["session_id"] === "string" && typeof envelope["hook_event_name"] === "string" && envelope["hook_event_name"].length > 0 && // Accept unknown event names for forward compatibility
|
|
39
|
+
typeof envelope["payload"] === "object" && envelope["payload"] !== null;
|
|
40
|
+
}
|
|
41
|
+
function generateId() {
|
|
42
|
+
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/harnesses/claude/protocol/events.ts
|
|
46
|
+
function isSubagentStartEvent(event) {
|
|
47
|
+
return event.hook_event_name === "SubagentStart";
|
|
48
|
+
}
|
|
49
|
+
function isSubagentStopEvent(event) {
|
|
50
|
+
return event.hook_event_name === "SubagentStop";
|
|
51
|
+
}
|
|
52
|
+
function isToolEvent(event) {
|
|
53
|
+
return event.hook_event_name === "PreToolUse" || event.hook_event_name === "PermissionRequest" || event.hook_event_name === "PermissionDenied" || event.hook_event_name === "PostToolUse" || event.hook_event_name === "PostToolUseFailure";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/harnesses/claude/protocol/result.ts
|
|
57
|
+
function createPreToolUseAllowResult() {
|
|
58
|
+
return {
|
|
59
|
+
action: "json_output",
|
|
60
|
+
stdout_json: {
|
|
61
|
+
hookSpecificOutput: {
|
|
62
|
+
hookEventName: "PreToolUse",
|
|
63
|
+
permissionDecision: "allow"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function createPreToolUseDenyResult(reason) {
|
|
69
|
+
return {
|
|
70
|
+
action: "json_output",
|
|
71
|
+
stdout_json: {
|
|
72
|
+
hookSpecificOutput: {
|
|
73
|
+
hookEventName: "PreToolUse",
|
|
74
|
+
permissionDecision: "deny",
|
|
75
|
+
permissionDecisionReason: reason
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function createAskUserQuestionResult(answers) {
|
|
81
|
+
const formatted = Object.entries(answers).map(([q, a]) => `Q: ${q}
|
|
82
|
+
A: ${a}`).join("\n");
|
|
83
|
+
return {
|
|
84
|
+
action: "json_output",
|
|
85
|
+
stdout_json: {
|
|
86
|
+
hookSpecificOutput: {
|
|
87
|
+
hookEventName: "PreToolUse",
|
|
88
|
+
permissionDecision: "allow",
|
|
89
|
+
updatedInput: {
|
|
90
|
+
answers
|
|
91
|
+
},
|
|
92
|
+
additionalContext: `User answered via athena-cli:
|
|
93
|
+
${formatted}`
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function createPermissionRequestAllowResult(updatedInput) {
|
|
99
|
+
const decision = {
|
|
100
|
+
behavior: "allow"
|
|
101
|
+
};
|
|
102
|
+
if (updatedInput) decision.updatedInput = updatedInput;
|
|
103
|
+
return {
|
|
104
|
+
action: "json_output",
|
|
105
|
+
stdout_json: {
|
|
106
|
+
hookSpecificOutput: {
|
|
107
|
+
hookEventName: "PermissionRequest",
|
|
108
|
+
decision
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function createPermissionRequestDenyResult(reason) {
|
|
114
|
+
return {
|
|
115
|
+
action: "json_output",
|
|
116
|
+
stdout_json: {
|
|
117
|
+
hookSpecificOutput: {
|
|
118
|
+
hookEventName: "PermissionRequest",
|
|
119
|
+
decision: { behavior: "deny", reason }
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function createStopBlockResult(reason) {
|
|
125
|
+
return {
|
|
126
|
+
action: "json_output",
|
|
127
|
+
stdout_json: {
|
|
128
|
+
decision: "block",
|
|
129
|
+
reason
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export {
|
|
135
|
+
ATHENA_HOOK_SOCKET_ENV,
|
|
136
|
+
resolveHookSocketPath,
|
|
137
|
+
isSocketPathTooLong,
|
|
138
|
+
isValidHookEventEnvelope,
|
|
139
|
+
generateId,
|
|
140
|
+
isSubagentStartEvent,
|
|
141
|
+
isSubagentStopEvent,
|
|
142
|
+
isToolEvent,
|
|
143
|
+
createPreToolUseAllowResult,
|
|
144
|
+
createPreToolUseDenyResult,
|
|
145
|
+
createAskUserQuestionResult,
|
|
146
|
+
createPermissionRequestAllowResult,
|
|
147
|
+
createPermissionRequestDenyResult,
|
|
148
|
+
createStopBlockResult
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=chunk-PSD3WBN4.js.map
|