agentgui 1.0.273 → 1.0.275
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/CLAUDE.md +280 -280
- package/IPFS_DOWNLOADER.md +277 -277
- package/TASK_2C_COMPLETION.md +334 -334
- package/bin/gmgui.cjs +54 -54
- package/build-portable.js +111 -0
- package/database.js +1422 -1406
- package/lib/claude-runner.js +1130 -1130
- package/lib/ipfs-downloader.js +459 -459
- package/lib/speech.js +152 -152
- package/package.json +1 -1
- package/portable-entry.js +43 -0
- package/readme.md +76 -76
- package/scripts/inject-pe-section.py +185 -0
- package/server.js +3787 -3794
- package/setup-npm-token.sh +68 -68
- package/static/app.js +773 -773
- package/static/event-rendering-showcase.html +708 -708
- package/static/index.html +3178 -3180
- package/static/js/agent-auth.js +298 -298
- package/static/js/audio-recorder-processor.js +18 -18
- package/static/js/client.js +2656 -2656
- package/static/js/conversations.js +583 -583
- package/static/js/dialogs.js +267 -267
- package/static/js/event-consolidator.js +101 -101
- package/static/js/event-filter.js +311 -311
- package/static/js/event-processor.js +452 -452
- package/static/js/features.js +413 -413
- package/static/js/kalman-filter.js +67 -67
- package/static/js/progress-dialog.js +130 -130
- package/static/js/script-runner.js +219 -219
- package/static/js/streaming-renderer.js +2123 -2120
- package/static/js/syntax-highlighter.js +269 -269
- package/static/js/tts-websocket-handler.js +152 -152
- package/static/js/ui-components.js +431 -431
- package/static/js/voice.js +849 -849
- package/static/js/websocket-manager.js +596 -596
- package/static/templates/INDEX.html +465 -465
- package/static/templates/README.md +190 -190
- package/static/templates/agent-capabilities.html +56 -56
- package/static/templates/agent-metadata-panel.html +44 -44
- package/static/templates/agent-status-badge.html +30 -30
- package/static/templates/code-annotation-panel.html +155 -155
- package/static/templates/code-suggestion-panel.html +184 -184
- package/static/templates/command-header.html +77 -77
- package/static/templates/command-output-scrollable.html +118 -118
- package/static/templates/elapsed-time.html +54 -54
- package/static/templates/error-alert.html +106 -106
- package/static/templates/error-history-timeline.html +160 -160
- package/static/templates/error-recovery-options.html +109 -109
- package/static/templates/error-stack-trace.html +95 -95
- package/static/templates/error-summary.html +80 -80
- package/static/templates/event-counter.html +48 -48
- package/static/templates/execution-actions.html +97 -97
- package/static/templates/execution-progress-bar.html +80 -80
- package/static/templates/execution-stepper.html +120 -120
- package/static/templates/file-breadcrumb.html +118 -118
- package/static/templates/file-diff-viewer.html +121 -121
- package/static/templates/file-metadata.html +133 -133
- package/static/templates/file-read-panel.html +66 -66
- package/static/templates/file-write-panel.html +120 -120
- package/static/templates/git-branch-remote.html +107 -107
- package/static/templates/git-diff-list.html +101 -101
- package/static/templates/git-log-visualization.html +153 -153
- package/static/templates/git-status-panel.html +115 -115
- package/static/templates/quality-metrics-display.html +170 -170
- package/static/templates/terminal-output-panel.html +87 -87
- package/static/templates/test-results-display.html +144 -144
- package/static/theme.js +72 -72
- package/test-download-progress.js +223 -223
- package/test-websocket-broadcast.js +147 -147
- package/tests/ipfs-downloader.test.js +370 -370
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Injects a .bun section into a Windows PE executable (bun standalone format).
|
|
4
|
+
Usage: inject-pe-section.py <bun-exe> <bundle-bytes> <output-exe>
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import sys
|
|
8
|
+
import struct
|
|
9
|
+
import os
|
|
10
|
+
|
|
11
|
+
def align_up(value, alignment):
|
|
12
|
+
return (value + alignment - 1) & ~(alignment - 1)
|
|
13
|
+
|
|
14
|
+
def read_u16(data, offset): return struct.unpack_from('<H', data, offset)[0]
|
|
15
|
+
def read_u32(data, offset): return struct.unpack_from('<I', data, offset)[0]
|
|
16
|
+
def read_u64(data, offset): return struct.unpack_from('<Q', data, offset)[0]
|
|
17
|
+
def write_u16(data, offset, val): struct.pack_into('<H', data, offset, val)
|
|
18
|
+
def write_u32(data, offset, val): struct.pack_into('<I', data, offset, val)
|
|
19
|
+
def write_u64(data, offset, val): struct.pack_into('<Q', data, offset, val)
|
|
20
|
+
|
|
21
|
+
def add_bun_section(pe_bytes, bundle_bytes):
|
|
22
|
+
data = bytearray(pe_bytes)
|
|
23
|
+
|
|
24
|
+
# PE header offset at 0x3C
|
|
25
|
+
e_lfanew = read_u32(data, 0x3C)
|
|
26
|
+
pe_sig = data[e_lfanew:e_lfanew+4]
|
|
27
|
+
assert pe_sig == b'PE\0\0', f"Not a PE file: {pe_sig!r}"
|
|
28
|
+
|
|
29
|
+
coff_offset = e_lfanew + 4
|
|
30
|
+
machine = read_u16(data, coff_offset)
|
|
31
|
+
num_sections = read_u16(data, coff_offset + 2)
|
|
32
|
+
size_of_optional = read_u16(data, coff_offset + 16)
|
|
33
|
+
|
|
34
|
+
opt_offset = coff_offset + 20
|
|
35
|
+
magic = read_u16(data, opt_offset)
|
|
36
|
+
assert magic == 0x20B, f"Expected PE32+ (0x20B), got 0x{magic:X}"
|
|
37
|
+
|
|
38
|
+
# Optional header fields (PE32+)
|
|
39
|
+
file_alignment = read_u32(data, opt_offset + 36)
|
|
40
|
+
section_alignment = read_u32(data, opt_offset + 32)
|
|
41
|
+
size_of_image = read_u32(data, opt_offset + 56)
|
|
42
|
+
size_of_headers = read_u32(data, opt_offset + 60)
|
|
43
|
+
checksum_offset = opt_offset + 64
|
|
44
|
+
# Data directories start at opt_offset + 112 for PE32+
|
|
45
|
+
# Security directory is entry 4
|
|
46
|
+
security_dd_offset = opt_offset + 112 + 4 * 8 # entry 4, each entry 8 bytes
|
|
47
|
+
|
|
48
|
+
# Section headers follow the optional header
|
|
49
|
+
section_headers_offset = opt_offset + size_of_optional
|
|
50
|
+
SECTION_HEADER_SIZE = 40
|
|
51
|
+
|
|
52
|
+
# Parse existing sections
|
|
53
|
+
sections = []
|
|
54
|
+
for i in range(num_sections):
|
|
55
|
+
off = section_headers_offset + i * SECTION_HEADER_SIZE
|
|
56
|
+
name = data[off:off+8]
|
|
57
|
+
virtual_size = read_u32(data, off + 8)
|
|
58
|
+
virtual_addr = read_u32(data, off + 12)
|
|
59
|
+
raw_size = read_u32(data, off + 16)
|
|
60
|
+
raw_ptr = read_u32(data, off + 20)
|
|
61
|
+
chars = read_u32(data, off + 36)
|
|
62
|
+
sections.append({
|
|
63
|
+
'name': name, 'virtual_size': virtual_size, 'virtual_addr': virtual_addr,
|
|
64
|
+
'raw_size': raw_size, 'raw_ptr': raw_ptr, 'chars': chars, 'off': off
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
if name == b'.bun\0\0\0\0':
|
|
68
|
+
raise ValueError("PE already has a .bun section")
|
|
69
|
+
|
|
70
|
+
assert num_sections < 96, "Too many sections"
|
|
71
|
+
|
|
72
|
+
# Check header space
|
|
73
|
+
new_sh_off = section_headers_offset + num_sections * SECTION_HEADER_SIZE
|
|
74
|
+
new_sh_end = new_sh_off + SECTION_HEADER_SIZE
|
|
75
|
+
first_raw = min((s['raw_ptr'] for s in sections if s['raw_size'] > 0), default=len(data))
|
|
76
|
+
new_size_of_headers = align_up(new_sh_end, file_alignment)
|
|
77
|
+
assert new_size_of_headers <= first_raw, f"Insufficient header space: need {new_size_of_headers}, first_raw={first_raw}"
|
|
78
|
+
|
|
79
|
+
# Find last file end and last va end
|
|
80
|
+
last_file_end = max((s['raw_ptr'] + s['raw_size'] for s in sections), default=0)
|
|
81
|
+
last_va_end = max(
|
|
82
|
+
(s['virtual_addr'] + align_up(max(s['virtual_size'], s['raw_size']), section_alignment)
|
|
83
|
+
for s in sections),
|
|
84
|
+
default=0
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
payload_len = len(bundle_bytes) + 8 # 8-byte u64 LE length prefix
|
|
88
|
+
raw_size_new = align_up(payload_len, file_alignment)
|
|
89
|
+
new_va = align_up(last_va_end, section_alignment)
|
|
90
|
+
new_raw = align_up(last_file_end, file_alignment)
|
|
91
|
+
|
|
92
|
+
# Extend data buffer
|
|
93
|
+
new_file_size = new_raw + raw_size_new
|
|
94
|
+
if len(data) < new_file_size:
|
|
95
|
+
data.extend(b'\0' * (new_file_size - len(data)))
|
|
96
|
+
else:
|
|
97
|
+
# Zero the new section area
|
|
98
|
+
data[new_raw:new_file_size] = b'\0' * raw_size_new
|
|
99
|
+
|
|
100
|
+
# Write new section header
|
|
101
|
+
IMAGE_SCN_CNT_INITIALIZED_DATA = 0x00000040
|
|
102
|
+
IMAGE_SCN_MEM_READ = 0x40000000
|
|
103
|
+
sh = bytearray(SECTION_HEADER_SIZE)
|
|
104
|
+
sh[0:8] = b'.bun\0\0\0\0'
|
|
105
|
+
struct.pack_into('<I', sh, 8, payload_len) # VirtualSize
|
|
106
|
+
struct.pack_into('<I', sh, 12, new_va) # VirtualAddress
|
|
107
|
+
struct.pack_into('<I', sh, 16, raw_size_new) # SizeOfRawData
|
|
108
|
+
struct.pack_into('<I', sh, 20, new_raw) # PointerToRawData
|
|
109
|
+
struct.pack_into('<I', sh, 36, IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ)
|
|
110
|
+
data[new_sh_off:new_sh_off + SECTION_HEADER_SIZE] = sh
|
|
111
|
+
|
|
112
|
+
# Write payload: u64 LE length + bundle bytes
|
|
113
|
+
write_u64(data, new_raw, len(bundle_bytes))
|
|
114
|
+
data[new_raw + 8: new_raw + 8 + len(bundle_bytes)] = bundle_bytes
|
|
115
|
+
|
|
116
|
+
# Update COFF: number_of_sections
|
|
117
|
+
write_u16(data, coff_offset + 2, num_sections + 1)
|
|
118
|
+
|
|
119
|
+
# Update optional header
|
|
120
|
+
if size_of_headers < new_size_of_headers:
|
|
121
|
+
write_u32(data, opt_offset + 60, new_size_of_headers)
|
|
122
|
+
|
|
123
|
+
# size_of_image: aligned end of new section
|
|
124
|
+
new_size_of_image = align_up(new_va + payload_len, section_alignment)
|
|
125
|
+
write_u32(data, opt_offset + 56, new_size_of_image)
|
|
126
|
+
|
|
127
|
+
# Clear security directory (signature invalidated)
|
|
128
|
+
data[security_dd_offset:security_dd_offset + 8] = b'\0' * 8
|
|
129
|
+
|
|
130
|
+
# Recompute PE checksum
|
|
131
|
+
data = recompute_checksum(data, checksum_offset)
|
|
132
|
+
|
|
133
|
+
return bytes(data)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def recompute_checksum(data, checksum_offset):
|
|
137
|
+
# Zero out the checksum field first
|
|
138
|
+
write_u32(data, checksum_offset, 0)
|
|
139
|
+
|
|
140
|
+
checksum = 0
|
|
141
|
+
# Process data as u16 pairs
|
|
142
|
+
for i in range(0, len(data) - 1, 2):
|
|
143
|
+
val = struct.unpack_from('<H', data, i)[0]
|
|
144
|
+
checksum += val
|
|
145
|
+
if checksum > 0xFFFFFFFF:
|
|
146
|
+
checksum = (checksum & 0xFFFFFFFF) + (checksum >> 32)
|
|
147
|
+
|
|
148
|
+
if len(data) % 2:
|
|
149
|
+
checksum += data[-1]
|
|
150
|
+
|
|
151
|
+
# Fold to 32 bits
|
|
152
|
+
checksum = (checksum & 0xFFFF) + (checksum >> 16)
|
|
153
|
+
checksum += checksum >> 16
|
|
154
|
+
checksum &= 0xFFFF
|
|
155
|
+
checksum += len(data)
|
|
156
|
+
|
|
157
|
+
write_u32(data, checksum_offset, checksum)
|
|
158
|
+
return data
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
if __name__ == '__main__':
|
|
162
|
+
if len(sys.argv) != 4:
|
|
163
|
+
print(f"Usage: {sys.argv[0]} <bun-exe> <bundle-js> <output-exe>")
|
|
164
|
+
sys.exit(1)
|
|
165
|
+
|
|
166
|
+
bun_path, bundle_path, out_path = sys.argv[1], sys.argv[2], sys.argv[3]
|
|
167
|
+
|
|
168
|
+
with open(bun_path, 'rb') as f:
|
|
169
|
+
pe_bytes = f.read()
|
|
170
|
+
|
|
171
|
+
with open(bundle_path, 'rb') as f:
|
|
172
|
+
bundle_bytes = f.read()
|
|
173
|
+
|
|
174
|
+
print(f"Bun exe: {len(pe_bytes)//1024//1024}MB, Bundle: {len(bundle_bytes)//1024}KB")
|
|
175
|
+
|
|
176
|
+
result = add_bun_section(pe_bytes, bundle_bytes)
|
|
177
|
+
|
|
178
|
+
with open(out_path, 'wb') as f:
|
|
179
|
+
f.write(result)
|
|
180
|
+
|
|
181
|
+
try:
|
|
182
|
+
os.chmod(out_path, 0o755)
|
|
183
|
+
except (PermissionError, OSError):
|
|
184
|
+
pass
|
|
185
|
+
print(f"Output: {len(result)//1024//1024}MB -> {out_path}")
|