@gitterm/sdk 0.2.1 → 0.2.2
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/README.md +4 -0
- package/dist/direct/index.js +33 -3
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -520,6 +520,10 @@ remain. The exported types are `AgentPermissionRequest`, `AgentQuestionRequest`,
|
|
|
520
520
|
`custom` defaults to true, matching OpenCode; false only when the agent sets it.
|
|
521
521
|
Questions with `options: []` accept free-text answers when `custom` is true.
|
|
522
522
|
|
|
523
|
+
Question options are normalised at the runtime boundary: labels and descriptions are trimmed,
|
|
524
|
+
OpenCode's copied "Type your own answer" entry is removed and enables `custom: true`, and
|
|
525
|
+
duplicate and blank labels are dropped. Hosted users need the API redeployed for this to take effect.
|
|
526
|
+
|
|
523
527
|
The quick start above shows a complete relay. Rejecting a permission or dismissing a question
|
|
524
528
|
ends the turn: OpenCode records a failed tool call and the run finishes. A run left
|
|
525
529
|
`awaiting_input` does not keep its workspace awake; if nobody answers before the workspace's
|
package/dist/direct/index.js
CHANGED
|
@@ -2,6 +2,36 @@
|
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { createOpencodeClient as createOpencodeClient2 } from "@opencode-ai/sdk";
|
|
4
4
|
|
|
5
|
+
// ../agent-runtime/src/normalize.ts
|
|
6
|
+
var OPENCODE_CUSTOM_OPTION_LABEL = /^type your own answer\W*$/i;
|
|
7
|
+
function normalizeQuestion(question) {
|
|
8
|
+
const options = [];
|
|
9
|
+
const labels = new Set;
|
|
10
|
+
let changed = false;
|
|
11
|
+
let custom = question.custom;
|
|
12
|
+
for (const option of question.options) {
|
|
13
|
+
const label = option.label.trim();
|
|
14
|
+
const description = option.description.trim();
|
|
15
|
+
if (OPENCODE_CUSTOM_OPTION_LABEL.test(label)) {
|
|
16
|
+
custom = true;
|
|
17
|
+
changed = true;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (!label || labels.has(label)) {
|
|
21
|
+
changed = true;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
labels.add(label);
|
|
25
|
+
if (label !== option.label || description !== option.description) {
|
|
26
|
+
changed = true;
|
|
27
|
+
options.push({ ...option, label, description });
|
|
28
|
+
} else {
|
|
29
|
+
options.push(option);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return changed ? { ...question, options, custom } : question;
|
|
33
|
+
}
|
|
34
|
+
|
|
5
35
|
// ../agent-runtime/src/opencode.ts
|
|
6
36
|
import { createOpencodeClient } from "@opencode-ai/sdk";
|
|
7
37
|
|
|
@@ -426,7 +456,7 @@ function questionRequest(raw) {
|
|
|
426
456
|
kind: "question",
|
|
427
457
|
createdAt: null,
|
|
428
458
|
toolCallId: asString(tool.callID),
|
|
429
|
-
questions: questions.map((question, index) => ({
|
|
459
|
+
questions: questions.map((question, index) => normalizeQuestion({
|
|
430
460
|
key: `q${index}`,
|
|
431
461
|
header: asString(question.header) ?? `Question ${index + 1}`,
|
|
432
462
|
question: asString(question.question) ?? "",
|
|
@@ -714,7 +744,7 @@ function formRequest(raw) {
|
|
|
714
744
|
toolCallId: asString(tool.id) ?? asString(tool.callID),
|
|
715
745
|
questions: fields.map((field, index) => {
|
|
716
746
|
const key = asString(field.key) ?? `q${index}`;
|
|
717
|
-
return {
|
|
747
|
+
return normalizeQuestion({
|
|
718
748
|
key,
|
|
719
749
|
header: asString(field.title) ?? key,
|
|
720
750
|
question: asString(field.description) ?? asString(field.title) ?? key,
|
|
@@ -729,7 +759,7 @@ function formRequest(raw) {
|
|
|
729
759
|
}),
|
|
730
760
|
multiple: field.type === "multiselect",
|
|
731
761
|
custom: field.custom !== false
|
|
732
|
-
};
|
|
762
|
+
});
|
|
733
763
|
})
|
|
734
764
|
};
|
|
735
765
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -309,6 +309,7 @@ export type AgentQuestionOption = {
|
|
|
309
309
|
label: string;
|
|
310
310
|
description: string;
|
|
311
311
|
};
|
|
312
|
+
/** Options are normalised: OpenCode's own type-your-own entry, duplicates and blank labels never appear. */
|
|
312
313
|
export type AgentQuestion = {
|
|
313
314
|
/** Identifies this question in `AgentRunReply.answers`. Unique within a request. */
|
|
314
315
|
key: string;
|