@ottocode/server 0.1.237 → 0.1.242

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.
@@ -1,6 +1,6 @@
1
1
  import { publish } from '../../events/bus.ts';
2
2
 
3
- export type ToolApprovalMode = 'auto' | 'dangerous' | 'all';
3
+ export type ToolApprovalMode = 'auto' | 'dangerous' | 'all' | 'yolo';
4
4
 
5
5
  export const DANGEROUS_TOOLS = new Set([
6
6
  'bash',
@@ -36,12 +36,16 @@ export function requiresApproval(
36
36
  mode: ToolApprovalMode,
37
37
  ): boolean {
38
38
  if (SAFE_TOOLS.has(toolName)) return false;
39
- if (mode === 'auto') return false;
39
+ if (mode === 'auto' || mode === 'yolo') return false;
40
40
  if (mode === 'all') return true;
41
41
  if (mode === 'dangerous') return DANGEROUS_TOOLS.has(toolName);
42
42
  return false;
43
43
  }
44
44
 
45
+ export function skipsGuardApproval(mode?: ToolApprovalMode): boolean {
46
+ return mode === 'yolo';
47
+ }
48
+
45
49
  export async function requestApproval(
46
50
  sessionId: string,
47
51
  messageId: string,
@@ -16,6 +16,7 @@ import {
16
16
  import {
17
17
  requiresApproval,
18
18
  requestApproval,
19
+ skipsGuardApproval,
19
20
  } from '../runtime/tools/approval.ts';
20
21
  import { guardToolCall } from '../runtime/tools/guards.ts';
21
22
 
@@ -398,7 +399,11 @@ export function adaptTools(
398
399
  if (guard.type === 'block') {
399
400
  meta.blocked = true;
400
401
  meta.blockReason = guard.reason;
401
- } else if (guard.type === 'approve' && !meta.approvalPromise) {
402
+ } else if (
403
+ guard.type === 'approve' &&
404
+ !meta.approvalPromise &&
405
+ !skipsGuardApproval(ctx.toolApprovalMode)
406
+ ) {
402
407
  meta.approvalPromise = requestApproval(
403
408
  ctx.sessionId,
404
409
  ctx.messageId,
package/src/ws.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { createBunWebSocket } from 'hono/bun';
2
+
3
+ const { upgradeWebSocket, websocket } = createBunWebSocket();
4
+
5
+ export { upgradeWebSocket, websocket };