@magpie-community/opencode-factory-auth 0.1.22 → 0.1.23
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 +9 -1
- package/index.mjs +19 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -139,6 +139,10 @@ Standalone skill updates can instead start with the generated skill-list
|
|
|
139
139
|
header and end with a token marker, for example when leaving auto mode.
|
|
140
140
|
That complete form receives the same adaptation while retaining the skill
|
|
141
141
|
descriptions and mode-change instructions.
|
|
142
|
+
The skill list can also come alone as a `system` message, with only its
|
|
143
|
+
entries: no header, no reminder wrapper and no token marker, as text blocks
|
|
144
|
+
or a string. A `system` message that opens with an entry gets the same
|
|
145
|
+
change to the known `update-config` line; everything else in it stays.
|
|
142
146
|
When runtime notifications precede the skill update, the adapter recognizes
|
|
143
147
|
the complete skill-header and bullet-list paragraphs inside a token-terminated
|
|
144
148
|
bundle. It preserves MCP connection errors, other notifications, mode updates
|
|
@@ -177,7 +181,11 @@ Use magpie's Claude Code integration to select the Factory provider.
|
|
|
177
181
|
magpie manages the provider-specific client settings, including capability
|
|
178
182
|
and permission configuration. Fields such as `safeguards` and
|
|
179
183
|
`context_management` are forwarded for Factory to validate; the request
|
|
180
|
-
adapter preserves them along with the other request options.
|
|
184
|
+
adapter preserves them along with the other request options. One exception:
|
|
185
|
+
Factory's streaming route refuses `context_management` ("Extra inputs are
|
|
186
|
+
not permitted") while its non-streaming route takes it, so a streamed
|
|
187
|
+
request is sent without it. The server then clears nothing from the
|
|
188
|
+
context; Claude Code's own compaction still runs.
|
|
181
189
|
|
|
182
190
|
The same metadata adaptation applies to `/messages` and
|
|
183
191
|
`/messages/count_tokens`, so token counting sees the prompt used for
|
package/index.mjs
CHANGED
|
@@ -658,6 +658,15 @@ const SKILL_REMINDER = /^<system-reminder>\nThe following skills are available f
|
|
|
658
658
|
const CONFIG_SKILL_METADATA = '- update-config: Use this skill to configure the Claude Code harness via settings.json. Automated behaviors ("from now on when X", "each time X", "whenever X", "before/after X") require hooks configured in settings.json - the harness executes these, not Claude, so memory/preferences cannot fulfill them.'
|
|
659
659
|
const CONFIG_SKILL_COMPAT = CONFIG_SKILL_METADATA.replace("not Claude", "not the assistant")
|
|
660
660
|
|
|
661
|
+
// Claude Code also sends the skill list alone as a system message: the
|
|
662
|
+
// entries only, no header, no <system-reminder> wrapper and no token tail,
|
|
663
|
+
// as text blocks or a string (#72). Only a system message that is such a
|
|
664
|
+
// list (it opens with an entry) changes, and in it only the known line.
|
|
665
|
+
function bareSkills(text) {
|
|
666
|
+
if (!text.startsWith("- ")) return text
|
|
667
|
+
return ("\n" + text).replace("\n" + CONFIG_SKILL_METADATA, "\n" + CONFIG_SKILL_COMPAT).slice(1)
|
|
668
|
+
}
|
|
669
|
+
|
|
661
670
|
// Claude 5 also sends its runtime metadata as a string-content system
|
|
662
671
|
// message, instead of user-message reminders. Preserve that role and all
|
|
663
672
|
// instructions. A model switch sends a separate update without the
|
|
@@ -975,7 +984,7 @@ function anthropicBody(body) {
|
|
|
975
984
|
|
|
976
985
|
for (const message of request.messages) {
|
|
977
986
|
if (message?.role === "system" && typeof message.content === "string") {
|
|
978
|
-
const adapted = clientOpening(systemContext(message.content))
|
|
987
|
+
const adapted = bareSkills(clientOpening(systemContext(message.content)))
|
|
979
988
|
if (adapted !== message.content) {
|
|
980
989
|
message.content = adapted
|
|
981
990
|
changed = true
|
|
@@ -988,7 +997,7 @@ function anthropicBody(body) {
|
|
|
988
997
|
if (message?.role === "system" && Array.isArray(message.content)) {
|
|
989
998
|
for (const block of message.content) {
|
|
990
999
|
if (block?.type !== "text" || typeof block.text !== "string") continue
|
|
991
|
-
const adapted = clientOpening(systemContext(block.text))
|
|
1000
|
+
const adapted = bareSkills(clientOpening(systemContext(block.text)))
|
|
992
1001
|
if (adapted !== block.text) {
|
|
993
1002
|
block.text = adapted
|
|
994
1003
|
changed = true
|
|
@@ -1060,6 +1069,14 @@ function anthropicBody(body) {
|
|
|
1060
1069
|
}
|
|
1061
1070
|
}
|
|
1062
1071
|
}
|
|
1072
|
+
// Factory's streaming route refuses context_management ("Extra inputs
|
|
1073
|
+
// are not permitted", #71) while its non-streaming route takes it. A
|
|
1074
|
+
// streamed request goes without it: the server then edits nothing out of
|
|
1075
|
+
// the context, and the client's own compaction still runs.
|
|
1076
|
+
if (request.stream === true && "context_management" in request) {
|
|
1077
|
+
delete request.context_management
|
|
1078
|
+
changed = true
|
|
1079
|
+
}
|
|
1063
1080
|
return changed ? JSON.stringify(request) : body
|
|
1064
1081
|
}
|
|
1065
1082
|
|