kimaki 0.4.27 → 0.4.28

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.
@@ -3,7 +3,7 @@
3
3
  // with Accept, Accept Always, and Deny options.
4
4
  import { StringSelectMenuBuilder, StringSelectMenuInteraction, ActionRowBuilder, } from 'discord.js';
5
5
  import crypto from 'node:crypto';
6
- import { initializeOpencodeForDirectory } from '../opencode.js';
6
+ import { getOpencodeClientV2 } from '../opencode.js';
7
7
  import { NOTIFY_MESSAGE_FLAGS } from '../discord-utils.js';
8
8
  import { createLogger } from '../logger.js';
9
9
  const logger = createLogger('PERMISSIONS');
@@ -76,13 +76,13 @@ export async function handlePermissionSelectMenu(interaction) {
76
76
  await interaction.deferUpdate();
77
77
  const response = interaction.values[0];
78
78
  try {
79
- const getClient = await initializeOpencodeForDirectory(context.directory);
80
- await getClient().postSessionIdPermissionsPermissionId({
81
- path: {
82
- id: context.permission.sessionID,
83
- permissionID: context.permission.id,
84
- },
85
- body: { response },
79
+ const clientV2 = getOpencodeClientV2(context.directory);
80
+ if (!clientV2) {
81
+ throw new Error('OpenCode server not found for directory');
82
+ }
83
+ await clientV2.permission.reply({
84
+ requestID: context.permission.id,
85
+ reply: response,
86
86
  });
87
87
  pendingPermissionContexts.delete(contextHash);
88
88
  // Update message: show result and remove dropdown
@@ -136,13 +136,13 @@ export async function handleOpencodeSession({ prompt, thread, projectDirectory,
136
136
  if (pendingPerm) {
137
137
  try {
138
138
  sessionLogger.log(`[PERMISSION] Auto-rejecting pending permission ${pendingPerm.permission.id} due to new message`);
139
- await getClient().postSessionIdPermissionsPermissionId({
140
- path: {
141
- id: pendingPerm.permission.sessionID,
142
- permissionID: pendingPerm.permission.id,
143
- },
144
- body: { response: 'reject' },
145
- });
139
+ const clientV2 = getOpencodeClientV2(directory);
140
+ if (clientV2) {
141
+ await clientV2.permission.reply({
142
+ requestID: pendingPerm.permission.id,
143
+ reply: 'reject',
144
+ });
145
+ }
146
146
  // Clean up both the pending permission and its dropdown context
147
147
  cleanupPermissionContext(pendingPerm.contextHash);
148
148
  pendingPermissions.delete(thread.id);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "kimaki",
3
3
  "module": "index.ts",
4
4
  "type": "module",
5
- "version": "0.4.27",
5
+ "version": "0.4.28",
6
6
  "scripts": {
7
7
  "dev": "tsx --env-file .env src/cli.ts",
8
8
  "prepublishOnly": "pnpm tsc",
@@ -10,7 +10,7 @@ import {
10
10
  } from 'discord.js'
11
11
  import crypto from 'node:crypto'
12
12
  import type { PermissionRequest } from '@opencode-ai/sdk/v2'
13
- import { initializeOpencodeForDirectory } from '../opencode.js'
13
+ import { getOpencodeClientV2 } from '../opencode.js'
14
14
  import { NOTIFY_MESSAGE_FLAGS } from '../discord-utils.js'
15
15
  import { createLogger } from '../logger.js'
16
16
 
@@ -120,13 +120,13 @@ export async function handlePermissionSelectMenu(
120
120
  const response = interaction.values[0] as 'once' | 'always' | 'reject'
121
121
 
122
122
  try {
123
- const getClient = await initializeOpencodeForDirectory(context.directory)
124
- await getClient().postSessionIdPermissionsPermissionId({
125
- path: {
126
- id: context.permission.sessionID,
127
- permissionID: context.permission.id,
128
- },
129
- body: { response },
123
+ const clientV2 = getOpencodeClientV2(context.directory)
124
+ if (!clientV2) {
125
+ throw new Error('OpenCode server not found for directory')
126
+ }
127
+ await clientV2.permission.reply({
128
+ requestID: context.permission.id,
129
+ reply: response,
130
130
  })
131
131
 
132
132
  pendingPermissionContexts.delete(contextHash)
@@ -221,13 +221,13 @@ export async function handleOpencodeSession({
221
221
  if (pendingPerm) {
222
222
  try {
223
223
  sessionLogger.log(`[PERMISSION] Auto-rejecting pending permission ${pendingPerm.permission.id} due to new message`)
224
- await getClient().postSessionIdPermissionsPermissionId({
225
- path: {
226
- id: pendingPerm.permission.sessionID,
227
- permissionID: pendingPerm.permission.id,
228
- },
229
- body: { response: 'reject' },
230
- })
224
+ const clientV2 = getOpencodeClientV2(directory)
225
+ if (clientV2) {
226
+ await clientV2.permission.reply({
227
+ requestID: pendingPerm.permission.id,
228
+ reply: 'reject',
229
+ })
230
+ }
231
231
  // Clean up both the pending permission and its dropdown context
232
232
  cleanupPermissionContext(pendingPerm.contextHash)
233
233
  pendingPermissions.delete(thread.id)