@clwnd/opencode 0.3.2 → 0.4.0
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/dist/index.js +23 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -357,6 +357,15 @@ function extractText(prompt) {
|
|
|
357
357
|
}
|
|
358
358
|
return "";
|
|
359
359
|
}
|
|
360
|
+
async function getSessionPermissions(client, sessionId) {
|
|
361
|
+
if (!client) return [];
|
|
362
|
+
try {
|
|
363
|
+
const resp = await client.session.get({ path: { sessionID: sessionId } });
|
|
364
|
+
return resp.data?.permission ?? [];
|
|
365
|
+
} catch {
|
|
366
|
+
return [];
|
|
367
|
+
}
|
|
368
|
+
}
|
|
360
369
|
function parseNDJSON(buffer, sessionId) {
|
|
361
370
|
const messages = [];
|
|
362
371
|
const lines = buffer.split("\n");
|
|
@@ -385,6 +394,7 @@ var ClwndModel = class {
|
|
|
385
394
|
const text = extractText(opts.prompt);
|
|
386
395
|
const warnings = [];
|
|
387
396
|
const cwd = this.config.cwd ?? process.cwd();
|
|
397
|
+
const permissions = await getSessionPermissions(this.config.client, sid);
|
|
388
398
|
let reasoning = "";
|
|
389
399
|
let responseText = "";
|
|
390
400
|
const toolCalls = [];
|
|
@@ -402,7 +412,8 @@ var ClwndModel = class {
|
|
|
402
412
|
opencodeSessionId: sid,
|
|
403
413
|
cwd,
|
|
404
414
|
modelId: this.modelId,
|
|
405
|
-
text
|
|
415
|
+
text,
|
|
416
|
+
permissions
|
|
406
417
|
}).then(async (resp) => {
|
|
407
418
|
if (!resp.body) {
|
|
408
419
|
abort();
|
|
@@ -504,6 +515,7 @@ var ClwndModel = class {
|
|
|
504
515
|
const cwd = this.config.cwd ?? process.cwd();
|
|
505
516
|
const self = this;
|
|
506
517
|
const toolInputAccum = /* @__PURE__ */ new Map();
|
|
518
|
+
const permissions = await getSessionPermissions(this.config.client, sid);
|
|
507
519
|
const stream = new ReadableStream({
|
|
508
520
|
async start(controller) {
|
|
509
521
|
const textId = generateId();
|
|
@@ -542,7 +554,8 @@ var ClwndModel = class {
|
|
|
542
554
|
opencodeSessionId: sid,
|
|
543
555
|
cwd,
|
|
544
556
|
modelId: self.modelId,
|
|
545
|
-
text
|
|
557
|
+
text,
|
|
558
|
+
permissions
|
|
546
559
|
});
|
|
547
560
|
} catch (e) {
|
|
548
561
|
emit({ type: "error", error: new Error(String(e)) });
|
|
@@ -689,11 +702,14 @@ function createClwnd(config = {}) {
|
|
|
689
702
|
}
|
|
690
703
|
|
|
691
704
|
// index.ts
|
|
692
|
-
var clwndPlugin = async () =>
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
705
|
+
var clwndPlugin = async (input) => {
|
|
706
|
+
const provider = createClwnd({ client: input.client });
|
|
707
|
+
return {
|
|
708
|
+
models: {
|
|
709
|
+
clwnd: provider
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
};
|
|
697
713
|
export {
|
|
698
714
|
ClwndModel,
|
|
699
715
|
clwndPlugin,
|