@gitterm/sdk 0.2.0 → 0.2.1
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 +2 -0
- package/dist/direct/index.js +5 -2
- package/dist/types.d.ts +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -517,6 +517,8 @@ remain. The exported types are `AgentPermissionRequest`, `AgentQuestionRequest`,
|
|
|
517
517
|
**labels** keyed by question `key`, or one free-text string when `custom` is true:
|
|
518
518
|
`{ type: "question", answers: { [question.key]: string[] } }`. Every question needs an entry.
|
|
519
519
|
Or dismiss all of them with `{ type: "question", reject: true }`.
|
|
520
|
+
`custom` defaults to true, matching OpenCode; false only when the agent sets it.
|
|
521
|
+
Questions with `options: []` accept free-text answers when `custom` is true.
|
|
520
522
|
|
|
521
523
|
The quick start above shows a complete relay. Rejecting a permission or dismissing a question
|
|
522
524
|
ends the turn: OpenCode records a failed tool call and the run finishes. A run left
|
package/dist/direct/index.js
CHANGED
|
@@ -435,7 +435,7 @@ function questionRequest(raw) {
|
|
|
435
435
|
description: asString(option.description) ?? ""
|
|
436
436
|
})),
|
|
437
437
|
multiple: question.multiple === true,
|
|
438
|
-
custom: question.custom
|
|
438
|
+
custom: question.custom !== false
|
|
439
439
|
}))
|
|
440
440
|
};
|
|
441
441
|
}
|
|
@@ -728,7 +728,7 @@ function formRequest(raw) {
|
|
|
728
728
|
};
|
|
729
729
|
}),
|
|
730
730
|
multiple: field.type === "multiselect",
|
|
731
|
-
custom: field.custom
|
|
731
|
+
custom: field.custom !== false
|
|
732
732
|
};
|
|
733
733
|
})
|
|
734
734
|
};
|
|
@@ -842,6 +842,9 @@ function questionAnswers(request, answers) {
|
|
|
842
842
|
throw new Error(`Answers must cover exactly the question keys ${JSON.stringify(keys)}`);
|
|
843
843
|
}
|
|
844
844
|
return request.questions.map((question) => {
|
|
845
|
+
if (!question.options.length && !question.custom) {
|
|
846
|
+
throw new Error(`Question "${question.key}" has no options and does not accept custom answers`);
|
|
847
|
+
}
|
|
845
848
|
const selected = answers[question.key];
|
|
846
849
|
if (!Array.isArray(selected) || !selected.length || !question.multiple && selected.length !== 1) {
|
|
847
850
|
throw new Error(`Question "${question.key}" requires ${question.multiple ? "at least one answer" : "one answer"}`);
|
package/dist/types.d.ts
CHANGED
|
@@ -317,7 +317,10 @@ export type AgentQuestion = {
|
|
|
317
317
|
options: AgentQuestionOption[];
|
|
318
318
|
/** More than one option may be selected. */
|
|
319
319
|
multiple: boolean;
|
|
320
|
-
/**
|
|
320
|
+
/**
|
|
321
|
+
* A free-text answer outside `options` is accepted.
|
|
322
|
+
* Defaults to true, matching OpenCode; false only when the agent sets it.
|
|
323
|
+
*/
|
|
321
324
|
custom: boolean;
|
|
322
325
|
};
|
|
323
326
|
/** The agent called OpenCode's `question` tool. Answer every question in one reply. */
|