@otto-assistant/otto 0.7.18 → 0.7.20
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.
|
@@ -57,7 +57,6 @@ function takePendingPermissionContext(contextHash) {
|
|
|
57
57
|
function renderPermissionContext(permission) {
|
|
58
58
|
const tool = permission.permission.toLowerCase();
|
|
59
59
|
const meta = permission.metadata ?? {};
|
|
60
|
-
// Read a string value from metadata, trying multiple key names
|
|
61
60
|
const getStr = (keys, fallback = '') => {
|
|
62
61
|
for (const key of keys) {
|
|
63
62
|
const val = meta[key];
|
|
@@ -66,7 +65,6 @@ function renderPermissionContext(permission) {
|
|
|
66
65
|
}
|
|
67
66
|
return fallback;
|
|
68
67
|
};
|
|
69
|
-
const truncate = (s, maxLen = 500) => s.length > maxLen ? s.slice(0, maxLen - 1) + '…' : s;
|
|
70
68
|
const clipBlock = (s, limit) => s.length > limit ? s.slice(0, limit - 1) + '…' : s;
|
|
71
69
|
switch (tool) {
|
|
72
70
|
case 'bash':
|
|
@@ -116,9 +114,8 @@ function renderPermissionContext(permission) {
|
|
|
116
114
|
const parts = [];
|
|
117
115
|
if (filePath)
|
|
118
116
|
parts.push(`**File:** \`${filePath}\``);
|
|
119
|
-
if (content)
|
|
117
|
+
if (content)
|
|
120
118
|
parts.push(`\`\`\`\n${clipBlock(content, 600)}\n\`\`\``);
|
|
121
|
-
}
|
|
122
119
|
return parts.join('\n');
|
|
123
120
|
}
|
|
124
121
|
case 'webfetch':
|
|
@@ -180,7 +177,6 @@ function renderPermissionContext(permission) {
|
|
|
180
177
|
return `> ${clipBlock(description, 300)}`;
|
|
181
178
|
}
|
|
182
179
|
default: {
|
|
183
|
-
// Generic: show description or first meaningful metadata field
|
|
184
180
|
const description = getStr(['description', 'action', 'operation', 'command']);
|
|
185
181
|
if (description)
|
|
186
182
|
return `> *${clipBlock(description, 300)}*`;
|
|
@@ -1000,7 +1000,12 @@ export class ThreadSessionRuntime {
|
|
|
1000
1000
|
})();
|
|
1001
1001
|
logger.log(`[EVENT] type=${event.type} eventSessionId=${eventSessionId || 'none'} activeSessionId=${sessionId || 'none'} ${this.formatRunStateForLog()}${eventDetails}`);
|
|
1002
1002
|
}
|
|
1003
|
-
|
|
1003
|
+
// permission.asked and question.asked must always reach the handler
|
|
1004
|
+
// so they get forwarded to Discord even when the requesting session
|
|
1005
|
+
// is a subagent whose metadata has been cleared from the buffer.
|
|
1006
|
+
const isGlobalEvent = event.type === 'tui.toast.show' ||
|
|
1007
|
+
event.type === 'permission.asked' ||
|
|
1008
|
+
event.type === 'question.asked';
|
|
1004
1009
|
const isScopedToastEvent = Boolean(toastSessionId);
|
|
1005
1010
|
// Drop events that don't match current session (stale events from
|
|
1006
1011
|
// previous sessions), unless it's a global event or a subtask session.
|
|
@@ -1818,8 +1823,11 @@ export class ThreadSessionRuntime {
|
|
|
1818
1823
|
const isMainSession = permission.sessionID === sessionId;
|
|
1819
1824
|
const isSubtaskSession = Boolean(subtaskInfo);
|
|
1820
1825
|
if (!isMainSession && !isSubtaskSession) {
|
|
1821
|
-
logger.log(`[PERMISSION
|
|
1822
|
-
return
|
|
1826
|
+
logger.log(`[PERMISSION] Permission for non-main session (expected: ${sessionId} or subtask, got: ${permission.sessionID}) — forwarding to Discord anyway`);
|
|
1827
|
+
// Do not return — still show buttons for the Discord thread.
|
|
1828
|
+
// The session mismatch usually happens when the event buffer has
|
|
1829
|
+
// been cleared and a subagent's permission.asked arrives without
|
|
1830
|
+
// subtask metadata in the buffer. The user needs to see these.
|
|
1823
1831
|
}
|
|
1824
1832
|
// Auto-deny external_directory permissions for paths that do not exist
|
|
1825
1833
|
// on the filesystem. There is no point asking the user to approve access
|
package/package.json
CHANGED
|
@@ -101,7 +101,6 @@ function renderPermissionContext(permission: PermissionRequest): string {
|
|
|
101
101
|
const tool = permission.permission.toLowerCase()
|
|
102
102
|
const meta = permission.metadata ?? {}
|
|
103
103
|
|
|
104
|
-
// Read a string value from metadata, trying multiple key names
|
|
105
104
|
const getStr = (keys: string[], fallback = ''): string => {
|
|
106
105
|
for (const key of keys) {
|
|
107
106
|
const val = meta[key]
|
|
@@ -110,9 +109,6 @@ function renderPermissionContext(permission: PermissionRequest): string {
|
|
|
110
109
|
return fallback
|
|
111
110
|
}
|
|
112
111
|
|
|
113
|
-
const truncate = (s: string, maxLen = 500): string =>
|
|
114
|
-
s.length > maxLen ? s.slice(0, maxLen - 1) + '…' : s
|
|
115
|
-
|
|
116
112
|
const clipBlock = (s: string, limit: number): string =>
|
|
117
113
|
s.length > limit ? s.slice(0, limit - 1) + '…' : s
|
|
118
114
|
|
|
@@ -158,9 +154,7 @@ function renderPermissionContext(permission: PermissionRequest): string {
|
|
|
158
154
|
if (!filePath && !content) return ''
|
|
159
155
|
const parts: string[] = []
|
|
160
156
|
if (filePath) parts.push(`**File:** \`${filePath}\``)
|
|
161
|
-
if (content) {
|
|
162
|
-
parts.push(`\`\`\`\n${clipBlock(content, 600)}\n\`\`\``)
|
|
163
|
-
}
|
|
157
|
+
if (content) parts.push(`\`\`\`\n${clipBlock(content, 600)}\n\`\`\``)
|
|
164
158
|
return parts.join('\n')
|
|
165
159
|
}
|
|
166
160
|
|
|
@@ -220,7 +214,6 @@ function renderPermissionContext(permission: PermissionRequest): string {
|
|
|
220
214
|
}
|
|
221
215
|
|
|
222
216
|
default: {
|
|
223
|
-
// Generic: show description or first meaningful metadata field
|
|
224
217
|
const description = getStr(['description', 'action', 'operation', 'command'])
|
|
225
218
|
if (description) return `> *${clipBlock(description, 300)}*`
|
|
226
219
|
const relevantKeys = Object.keys(meta).filter(
|
|
@@ -1452,7 +1452,13 @@ export class ThreadSessionRuntime {
|
|
|
1452
1452
|
)
|
|
1453
1453
|
}
|
|
1454
1454
|
|
|
1455
|
-
|
|
1455
|
+
// permission.asked and question.asked must always reach the handler
|
|
1456
|
+
// so they get forwarded to Discord even when the requesting session
|
|
1457
|
+
// is a subagent whose metadata has been cleared from the buffer.
|
|
1458
|
+
const isGlobalEvent =
|
|
1459
|
+
event.type === 'tui.toast.show' ||
|
|
1460
|
+
event.type === 'permission.asked' ||
|
|
1461
|
+
event.type === 'question.asked'
|
|
1456
1462
|
const isScopedToastEvent = Boolean(toastSessionId)
|
|
1457
1463
|
|
|
1458
1464
|
// Drop events that don't match current session (stale events from
|
|
@@ -2490,9 +2496,12 @@ export class ThreadSessionRuntime {
|
|
|
2490
2496
|
|
|
2491
2497
|
if (!isMainSession && !isSubtaskSession) {
|
|
2492
2498
|
logger.log(
|
|
2493
|
-
`[PERMISSION
|
|
2499
|
+
`[PERMISSION] Permission for non-main session (expected: ${sessionId} or subtask, got: ${permission.sessionID}) — forwarding to Discord anyway`,
|
|
2494
2500
|
)
|
|
2495
|
-
return
|
|
2501
|
+
// Do not return — still show buttons for the Discord thread.
|
|
2502
|
+
// The session mismatch usually happens when the event buffer has
|
|
2503
|
+
// been cleared and a subagent's permission.asked arrives without
|
|
2504
|
+
// subtask metadata in the buffer. The user needs to see these.
|
|
2496
2505
|
}
|
|
2497
2506
|
|
|
2498
2507
|
// Auto-deny external_directory permissions for paths that do not exist
|