Commit Graph
40 Commits
Author SHA1 Message Date
Mars-Sea 4a35799021 factory 0.1.32: a model's token multiplier reaches magpie as its rate (#158)
Every model in MODELS carries the tokenMultiplier droid 0.241.1's registry
has for it (testdata/droid-0.241.1-costs.txt, byte for byte). A promotion
running takes its discount off it, with the multiplier before it as rateWas;
one that has ended or not begun is no discount. The rate reaches magpie
through a provider hook (host.js reads rate/rateWas from its models; a
config hook's models carry no rate there). Fast Mode entries stay last.

Reviewed at 498b8723e5350657aa26f8f0e2bb1d859f59803b:
- each multiplier and promotion checked against the testdata excerpt;
  gpt-5.6-sol's expired M promotion is skipped and Pt (20%) applies, as
  droid's first-running-promotion rule gives
- host.js info(): the provider hook's list replaces the config list, and
  the request path strips temperature for OpenAI models in droidBody, so
  capabilities.temperature=true in providerModel changes nothing sent
- factory unchanged on main between the PR's base 7687314 and fe5631c

Run (HOME=$(mktemp -d), PR head merged with main fe5631c):
- bun test: 1620 pass, 2 fail; the two are cursor latency.test reds under
  the full run at load ~260, already filed as #159 and #162; packages/cursor
  alone: 267 pass, 0 fail
- bun test packages/factory: 149 pass, 0 fail
- packages/factory/rate.test.mjs against main's index.mjs: 5 fail
- bun scripts/check.mjs: passes
Not tried with a real Factory account here (the author did, 46 models).
2026-10-16 17:36:20 +08:00
yetone 4e64f2680c factory 0.1.31: an OpenAI model's request goes without temperature and top_p, not 400 (sweanng424, Nowledge Mem on gpt-6.1-sol, magpie's Discord)
OpenAI's reasoning models turn temperature and top_p away with a 400, and
droid sends neither. droidBody now takes both out of a Responses request
for a model whose upstream is openai, also when the body already opens
with droid's line. configModels says temperature: false for those models,
so OpenCode doesn't send it either. Grok and the chat-completions models
keep theirs.

Run: bun test in packages/factory, 144 pass. The new test fails on 0.1.30's
index.mjs (temperature still in the body). Not tried against Factory's API
with a real account.
2026-10-16 13:50:29 +08:00
yetone b8717aa860 factory 0.1.30: requests say droid 0.242.0, the current release (sky杨 on magpie's Discord: every model 403 "Factory: Forbidden" from Claude Code on 0.1.29)
sky杨, on magpie 0.1.1254 with this plugin at 0.1.29, got 403 "Factory:
Forbidden" from Claude Code on every model, GPT, Claude and Gemini alike.
Factory's body was a bare "Forbidden", not a phrase-specific refusal.

Header diff against droid 0.242.0 (npm droid and @factory/cli-darwin-arm64
0.242.0, unpacked with --ignore-scripts into an empty directory and read
with strings, never run). Its model requests carry: Authorization,
X-Factory-Client: cli, X-Client-Version, X-Factory-Org-Id, User-Agent
factory-cli/<ver>, x-session-id, x-assistant-message-id, x-api-provider,
x-provider-routing-source (registry_default without a routing claim),
OpenAI-Platform: org-bHuLtG1fGmYk5YaOihAAXFBw for openai/azure_openai,
and X-Api-Key "placeholder" from its Anthropic client. The plugin sends
each of these with the same value, apart from the release: 0.233.0, nine
releases behind. The WorkOS client id is unchanged. droid's binary still
reads a server-side min_cli_version flag and runs a forced auto-update.

0.1.16 was the same case (JL: every model 403 "Forbidden" from pi and
Claude Code while droid worked; the plugin said 0.231.0, two behind), and
JL's later reports (0.1.25) were about models, not refusals. Whether
Factory refuses an old release with a 403 is still not confirmed: there is
no Factory account to try with. This is the one header difference found.

Run: bun test in packages/factory, 143 pass. With VERSION put back to
0.233.0, droid.test.mjs goes red (Expected "0.242.0", Received
"0.233.0"). bun scripts/check.mjs factory: ok.
Not tried against Factory itself.

Full suite: bun test (packages/factory) 143 pass
2026-10-15 21:01:58 +08:00
yetone b015ee515e factory 0.1.29: Claude Code on GLM and other /api/llm/o models goes without the phrases Factory refuses, not "403 Factory: Forbidden" (Echoo on magpie's Discord)
Echoo, with Factory moved onto this plugin, got "API Error: 403 Factory:
Forbidden" from Claude Code on GLM-5.3-Flash, while Codex worked on the
same account and model. GLM is a chat model Factory serves on /api/llm/o,
so magpie translates Claude Code's Messages request into chat completions
(or Responses) before the plugin gets it. Only anthropicBody, the
/api/llm/a route, adapted Claude Code's fixed phrases Factory refuses (its
identity line, "You have been invoked in the following environment", "You
are powered by the model", update-config's "not Claude, so memory", tool
output quoting them). droidBody, for /api/llm/o, only added droid's line,
so all of them went to Factory as they were. The headers, the model and
the account are the same for both agents; Codex's prompt has none of the
phrases.

anthropicBody's per-text adapters are now functions of their own
(claudeIdentity, promptText, systemMessageText, userBlockText), and
droidBody applies them to chat completions and Responses:
- chat's first system message and Responses' instructions as a system
  prompt; other system and developer messages as system messages;
- user text as a user block; a chat user string, where magpie joins a
  turn's blocks with nothing between them, also reminder by reminder;
- chat's tool messages and Responses' function_call_output as tool output.
The Messages route is unchanged: the refactor kept every earlier test
green before the new code went in.

testdata/claude-code-2.1.300-glm-{chat,responses}.json are magpie's
translations of a real Claude Code 2.1.300 request, captured in a sandbox
HOME (paths changed to /Users/me, tools left out).

Run: bun test in packages/factory, 143 pass. With index.mjs at 0.1.28 the
new claude-chat.test.mjs fails 4 of 5 (the Codex one passes on both).
bun scripts/check.mjs factory: ok. Routed the captured request through the
plugin: each refused phrase is 0 in the chat and Responses bodies now, as
on /api/llm/a (1 each with 0.1.28).
Not tried against Factory itself: there is no Factory account to try with.
2026-10-15 12:53:14 +08:00
yetone 95af6cf375 factory 0.1.28: the Fast Mode models are listed last, so a provider with nothing picked shows GPT-5.3-Codex, Grok and GLM again (#119, psylch)
magpie shows a provider with no models picked only the first 24 of its
list. 0.1.27 placed each Fast Mode model beside its base model, which
pushed GPT-5.3-Codex, Grok 4.7, Grok 4.6, GLM-5.3 and GLM-5.3-Flash past
24 ("not exposed"). The six Fast Mode models now come after every other
model, so the first 24 are 0.1.26's again. Asking a base model for fast
still reaches its Fast Mode model (fastBody), and a Fast Mode model can
be picked by name.

Run: bun test packages/factory (138 pass), bun scripts/check.mjs (all
plugins pass). The new fast.test.mjs case fails on 0.1.27's order (put
back by hand: 3 pass, 1 fail) and passes with this one.
Not tried: a real Factory account; magpie's exposure was not run against
the published package, only the list order checked.
2026-10-14 22:12:00 +08:00
yetone 2170a3781e factory 0.1.27: droid's Fast Mode models, and fast asked of their base model goes to them (#119)
psylch on #119 (plugin 0.1.26): claude-opus-5-5-fast answered "Factory:
Not found.", and Opus 5.5 asked with speed "fast" was recorded as
tier_asked fast, tier_served standard, with nothing said.

The plugin now offers droid 0.240.0's Fast Mode models: Opus 5.5/5/4.8
Fast on Anthropic's API, GPT-5.5/5.4/5.3-Codex Fast on Responses, each
at its base model's limits and efforts. They go out as droid 0.240.0
sends them (read from its binary, saved in testdata/droid-0.240.0-fast.txt):
the Fast Mode id itself as the model, with speed "fast" and the
fast-mode-2026-02-01 beta for anthropicFastMode models, at service_tier
"priority" for the GPT ones (their apiRequest Ee). A request asking a base
model for fast (speed "fast" on Messages, service_tier "priority" on
Responses) is sent to its Fast Mode model, as droid's fast toggle
switches to it. A model with no Fast Mode model is sent as asked. Left
out: Opus 4.6/4.7 Fast and GPT-5.4 Mini Fast (base not offered), GPT-5.6
Sol Fast (unreleased:!0), GLM-5.2 Fast (feature flag, a Baseten id).

Run: the full bun test (1222 pass, 0 fail) with a sandbox HOME; the new
fast.test.mjs and the picker test fail on the old index.mjs (4 fail).
Not tried: a real Factory account (none signed in here), so whether
Factory serves the Fast Mode ids at fast speed to a plan, and what its
usage says about speed, is unverified. A non-stream request magpie
translates for a plugin account drops speed before the plugin sees it,
so there only the -fast ids reach fast.
2026-10-14 17:53:22 +08:00
yetone e7d37b0801 factory 0.1.26: Gemini 4 Argon and Gemini 3.x on Factory's Gemini route (yetone/magpie#2080), a 413 retried with older images left out and said as Factory's byte limit (yetone/magpie#2082) 2026-10-14 14:26:29 +08:00
yetone 1bd6d172c1 factory: a 413 is asked once more with older images left out, then said as Factory's byte limit (yetone/magpie#2082)
Ziqi-Cui's Codex session on Opus 5.5 gathered nine screenshots, ~4.5 MB
of data URLs, and Factory answered every request after with 413 "Request
Entity Too Large". The plugin passed the 413 on as it came, which reads
as the context window; it is Factory's limit on a body's bytes.

On a 413 from Factory the plugin now sends the request once more with
every image and file but the newest replaced, in place, by a line saying
it was left out (droid 0.239.0 removes older images/PDFs from large
requests the same way). Anthropic image/document blocks, Responses
input_image/input_file, chat image_url/file and Gemini inlineData/fileData
are found wherever they are, tool results included, so every tool call
keeps its result; a Gemini function response's parts, which take inline
data alone, drop the image instead. One retry, never more; none when
there is nothing older to leave out.

If the 413 stands, or nothing could be left out, the error (Anthropic's
request_too_large, else invalid_request_error) gives Factory's words,
says the limit is on the body's bytes and what was left out, and carries
magpie's gateway 413 hint word for word (compact, or start a new
session), so the gateway, finding it, doesn't add it twice and OpenCode
users get it too. The words avoid what the gateway reads as a context
overflow, so it stays a 413.

The caller's own session and files are untouched: only the body sent to
Factory changes, and only on the retry.

Run: bun test in packages/factory (134 pass), bun scripts/check.mjs.
Broken by hand: without the 413 branch, three of size.test.mjs's four
tests fail. Not tried: a real Factory account (none here) or Factory's
real limit, which neither droid's binary nor its changelog states; the
fake upstream refuses over a chosen size.
2026-10-14 14:26:08 +08:00
yetone 60c905410e factory: Gemini 4 Argon and Gemini 3.x reach Factory's own Gemini route (yetone/magpie#2080)
The plugin offered no Gemini model, so Gemini 4 Argon, new in droid
0.241.1's picker, and the Gemini 3.x models magpie's built-in has were
missing for everyone moved onto the plugin.

- Gemini 4 Argon, Gemini 3.1 Pro, Gemini 3.8/3.7/3.6/3.5 Flash and
  Gemini 3 Flash are offered on @ai-sdk/google at /api/llm/g/v1, with
  droid 0.241.1's names, total context 1M, output 65536, efforts and
  images. Each effort is a thinkingConfig thinkingLevel, as the zed
  plugin sends Gemini's.
- send() takes the Google package's models/<id>:streamGenerateContent
  to Factory's /api/llm/g/v1/generate, as the built-in does (pathOf
  Gemini, FactoryGemini): the model in the body, no stream field, the
  system instruction without a role and opened with droid's line like
  factoryDroidGoogle. x-api-provider is google; the Google package's
  x-goog-api-key is dropped. A rewritten body no longer keeps the
  caller's content-length.
- Gemini counts in standard's windows, not Droid Core's, as the
  built-in's factoryCore has it.
- Gemini 4 Argon is behind a Factory feature flag (featureFlag
  Gemini4Argon, unreleased) in droid 0.241.1; an account it isn't on for
  may be refused it.

testdata/droid-0.241.1-gemini.txt is droid 0.241.1's picker and Gemini
entries, byte for byte from @factory/cli-darwin-arm64@0.241.1 bin/droid
(each line checked present in the binary). muse-spark-1.2, also new in
that picker, is not added here.

Run: bun test in packages/factory (130 pass), bun scripts/check.mjs.
Broken by hand: without the route rewrite the three gemini.test.mjs
tests fail; without google in CORE's exclusion usage.test.mjs fails.
Not tried: a real Factory account (none signed in here), so neither
Factory's answer to these bodies nor Gemini 4 Argon's flag was seen.
2026-10-14 14:25:43 +08:00
yetone e4023d9912 factory 0.1.25: Haiku 5.5 and Mistral Large 4, in droid 0.240.0's picker, reach Factory through magpie (JL on Discord)
JL (Windows, droid 0.240.0, Factory desktop 0.197.1, magpie 0.1.1226,
plugin 0.1.24): droid and Factory desktop offer claude-haiku-5-5, droid
through magpie didn't, as the plugin's model table didn't have it.

How droid gets its models: its npm package (@factory/cli 0.240.0, the
platform binary @factory/cli-darwin-arm64) bundles the model registry in
bin/droid; the picker lists that registry (order `y`), gated by
availableInCLI, unreleased, feature flags and legacy grouping. Diffing the
registry of 0.233.0 (the release the plugin's table was last matched to)
against 0.240.0 gives three new models: claude-haiku-5-5, mistral-large-4
and gpt-6-astra-ultrafast.

- Haiku 5.5: Anthropic Messages, x-api-provider anthropic, context
  872000 / output 128000 (contextLimits ce, as Sonnet 5.5 and Opus 5.5),
  efforts low..max (droid's "off" is the request without a level).
- Mistral Large 4: generic chat completions, x-api-provider mistral, Droid
  Core (billingPool core), 524288 / 64000, images, effort high.
- GPT-6 Astra Ultra Fast stays out: droid offers it only once the user has
  accepted Factory's high-cost terms (explicitOptInRequirement high_cost).

models.test.mjs is new; its fixture (testdata/droid-0.240.0-models.txt) is
the registry's own bytes: the picker order, the context helper and the three
entries. It checks the two models as droid has them and that every model in
droid's picker is offered or on a named list left out (router, Gemini,
unreleased, opt-in, the older generations the plugin never offered). With
the Haiku 5.5 line removed both tests fail. usage.test.mjs's Core list
gains Mistral Large 4.

Run: bun test in packages/factory (126 pass), bun scripts/check.mjs factory;
a fake Factory saw /api/llm/a/v1/messages with x-api-provider anthropic for
claude-haiku-5-5 and /api/llm/o/v1/chat/completions with mistral for
mistral-large-4. Not tried against Factory itself (no Factory account here);
droid itself was not run.
2026-10-13 23:29:44 +08:00
86b4760f55 factory 0.1.24: a session continued after Claude Code compaction reaches Factory (#66)
* factory 0.1.23: a resumed turn's restored skills reach Factory wherever they sit

#68 took 0.1.22, so this moves to 0.1.23.

Claude Code 2.1.292 session 1a2063e5 is the turn Factory answered 403.
Its transcript renders the post-compaction attachments, in order, as system
reminders: a token marker, a restored Read and its result, an omitted-file
note, the invoked-skills reminder, the agent-type list, MCP server
instructions, the environment paragraph and the model line. No token marker
follows the skills reminder. The snapshot's contextRendering is "announced",
so the same paragraphs also travel unwrapped in one system turn. The request
bytes were not in the routing log; the fixture is those rendered paragraphs,
unwrapped, in that order.

announcedContext used to reassemble the reminder only when a token marker
came right after it, and then treated everything up to that marker as skill
text. A reminder at the end of the turn, or followed by a Read, the
environment or a hook, kept the refused opening. A reminder with other
attachments and a later token swallowed those attachments into the skill
encoding.

The refused part is the fixed opening plus the complete IMPORTANT paragraph.
That complete reminder is rephrased wherever it sits. Skill text now ends at
the next paragraph the adapter already knows (token marker, hook, restored
Read, omitted-file note, Read result, environment, model line, skill-list
header, changed-file note, agent-type list, MCP instructions) or at the end
of the turn. Those following paragraphs stay themselves and are adapted on
their own. A second pass is byte-for-byte. Quoted fragments, an incomplete
IMPORTANT paragraph, a hook that owns the reminder and assistant content stay
untouched.

0.1.22 was not tried against Factory: the installed copy stayed 0.1.21, and
this change was not sent to Factory either.

Run: HOME set to an empty temp dir, bun test packages/factory: 120 pass,
0 fail. node --check packages/factory/index.mjs, bun scripts/check.mjs
factory, and git diff --check are clean. The new test covers the captured
order plus a reminder at the end of the turn, a reminder followed by Read,
environment and a hook, and a quoted skill body. Fetch is stubbed.

* factory 0.1.23: restored skills open a resumed turn without token metadata

A resumed turn can start with the complete invoked-skills reminder when no
files were restored and totalTokensReminder is off. restoredContext now
recognizes its exact opening and IMPORTANT paragraph through the existing
invokedSkillsMatch and attachment boundaries. A restored-file opening can
also use the complete skills reminder as evidence when it ends the turn.
Adapted openings, incomplete reminders, quotations and hook-owned output
retain their existing behavior.

Cover no-token system turns and folded user text on inference and token
counting, including standalone reminders, trailing tokens, omitted-file and
Read prefixes, exact skill decoding, cache metadata and byte-for-byte second
passes. Each of the six boundaries missing independent regression coverage
now follows a quoted skill directly. README documents the no-token forms.

Run with HOME set to an empty temporary directory: bun test packages/factory,
121 pass, 0 fail. node --check packages/factory/index.mjs,
bun scripts/check.mjs factory and git diff --check pass.
Removing each of the omitted-note, Read-result, model, skill-list, MCP and
changed-file boundaries makes the new independent regression test fail.
The whole-project test suite is left to CI. Fetch is stubbed; no request was
sent to a real Factory account.

* factory 0.1.24: main already published 0.1.23 (#71), so this change takes the next version

#71 shipped factory 0.1.23 while this PR waited, so npm has 0.1.23. This
only moves the version, so the squash publishes as 0.1.24.

Run: merged onto main a885a16, HOME=<scratch> bun test packages/factory:
124 pass, 0 fail; bun scripts/check.mjs: all pass.

---------

Co-authored-by: chenguoqing <chenguoqing@kemai.cn>
Co-authored-by: yetone <yetoneful@gmail.com>
2026-10-13 09:05:49 +08:00
yetone 07897c8c58 factory 0.1.23: a streamed Claude Code request with context management is no longer refused (#71, Vigilans)
Claude Code with the context-management beta sends context_management
(here clear_thinking_20251015, keep all). Factory's streaming route
answers it with 400 "context_management: Extra inputs are not permitted";
the same body with stream false, or without the field, gets 200 (the
reporter's three cases). A streamed /messages request now goes without
the field; an unstreamed one keeps it. The server then clears nothing,
and Claude Code's own compaction still runs.

The version bump also releases the previous commit's #72 fix.

Run: HOME=<tmp> bun test in packages/factory, 119 pass (1 new from the
reporter's body; the existing all-fields test now expects the field gone
on its streamed request). With the deletion disabled by hand both go red.
Not sent to Factory: no Factory account here.
2026-10-10 17:55:54 +08:00
yetone 9d4bc83400 factory: a skill list Claude Code sends alone as a system message is no longer refused over update-config's "not Claude" (#72, Vigilans)
Claude Code also sends the skill list as a standalone system message with
only its entries: no header, no <system-reminder> wrapper, no
<total_tokens> tail, as text blocks and (later in the same session) as a
plain string. The adapter only knew the headed and token-terminated forms,
so the update-config line went through unchanged and Factory answered
403; the reporter got 200 with only "not Claude" -> "not the assistant".

bareSkills applies that same known-line change to a system message that
opens with a "- " entry, both content shapes. User messages, quoted lists
and other skills' lines are left alone.

Run: HOME=<tmp> bun test in packages/factory, 118 pass (2 new, the
reporter's body byte for byte as fixture). With bareSkills made a no-op
by hand the new test goes red. Not sent to Factory: no Factory account
here.
2026-10-10 17:55:26 +08:00
yetone 0437abbe30 factory 0.1.22: Claude Code's restored-context turn after /compact reaches Factory adapted (#68, Vigilans)
After /compact, Claude Code 2.1.280 sends the files it restores and the
session's runtime context as one system text block with no reminder
wrappers and no opening token marker: restored-file notes ("Note: <path> was
read before the last conversation was summarized…"), "Called the Read tool
with the following input: {…}" and its result, "# Environment\nYou have been
invoked in the following environment:", the model line, token and date.
The reporter's bisect shows Factory 403s on each of those fixed fragments,
and 0.1.21 matched none of them: SYSTEM_ENV_CONTEXT is anchored at the
block's start, COMPACT_READ / COMPACT_FILE need a standalone wrapped
reminder, and the token-prefixed bundle path needs a leading token marker.

restoredContext recognizes the complete turn: its first paragraph is a
generated restored-file note or Read call (as COMPACT_FILE / COMPACT_READ
would match it wrapped), and a later paragraph, before any hook output, is
the generated environment paragraph or a token marker. Then
announcedContext adapts every paragraph from the first on, with the
existing compat spellings (Previously read file…, # Runtime context / The
session environment is:, Current model name / Model ID / Model knowledge
cutoff) and the lossless JSON encoding of Read results; everything else
stays byte-for-byte. It runs for system-role strings and text blocks and
for the same block folded into user text. An adapted turn no longer opens
with the generated note, so a second pass is byte-for-byte.

Quoted, incomplete (no environment or token), hook-owned and assistant
forms are left untouched.

Run: bun test (packages/factory: 116 pass; repo: 1010 pass, 0 fail),
bun scripts/check.mjs (all pass). The two new tests use the issue's literal
fragments (several notes, Read call + result, environment, model line with
claude-opus-5-5[1m], token, date); the adapting one fails on 0.1.21's
index.mjs, and removing the env/token requirement, the hook guard, the
user-text path or starting at paragraph 1 each turns a test red. PR #66
applied on top passes too (119 factory tests). Stubbed fetch only; no
request was sent to Factory (no Factory account here).
2026-10-10 03:37:05 +08:00
yetone f4c0d96c9c factory 0.1.21: pi's compaction summary reaches Factory without its fixed opening sentence (yetone/magpie#1316, Eriice)
After pi compacted a session, every turn on factory/claude-opus-5-5 was 403
"Factory: Forbidden". The reporter's replays through magpie found the
refused part: the sentence pi opens its summary message with,
"The conversation history before this point was compacted into the
following summary:" (pi-coding-agent dist/core/messages.js
COMPACTION_SUMMARY_PREFIX, the same in 1.0.4 and 1.1.0), whole; with it
removed, reworded or halved the request was answered.

A user text that is pi's whole summary message (the sentence, a blank line,
<summary>, and </summary> last) now opens "Earlier conversation context is
summarized below:", the summary itself unchanged. pi's other fixed summary
opening, BRANCH_SUMMARY_PREFIX ("The following is a summary of a branch
that this conversation came back from:"), is reworded the same way; that
Factory refuses it is not confirmed. On Messages (string content and text
blocks), chat completions and Responses user messages alike. The sentence
quoted by a user, without pi's summary around it, or in an assistant turn
goes on as it is.

pi.test.mjs: 3 new tests; the two adaptation tests fail on 0.1.20
(Expected/Received differ on the summary text), the third checks what is
left alone. bun test (114 pass) and bun scripts/check.mjs factory pass.
Not tried against Factory itself (no Factory account here).
2026-10-08 21:03:04 +08:00
SadWood ce9755092b fix(factory): quote repeated summaries and changed-file context (#42)
* fix(factory): 无损适配摘要引用和文件变更通知

* fix(factory): 保留 hook 后元数据适配并补齐编码边界
2026-10-08 12:46:47 +08:00
SadWood 3a9533aacb fix(factory): adapt Claude Code compaction and runtime metadata (#37)
* fix(factory): adapt Claude Code compaction and runtime metadata

* fix(factory): adapt standalone skill updates with trailing token context

* fix(factory): adapt runtime context after subagent startup hooks

* fix(factory): adapt skill paragraphs after runtime notifications

* fix(factory): encode compaction quotes in tool results for 0.1.19

* fix(factory): cover provenance summaries and restored Read content
2026-10-08 09:49:30 +08:00
yetone 4d6dcca173 factory 0.1.18: pi's opening sentence reaches Factory as its first half (yetone/magpie#952, mxzs123) — pi 1.0.4 got 403 "Factory: Forbidden" on DeepSeek (chat completions) and Claude (Messages) for "hi"; the reporter's replays through magpie found the refused part: "You are an expert coding assistant operating inside pi, a coding agent harness." whole (either half passes, and pi's full request with it cut to "You are an expert coding assistant." is answered on both routes). That sentence, at the start of a line of a system or developer prompt (chat completions' messages, Responses' instructions and input, Messages' system blocks and system messages), is cut so; the rest of pi's prompt, its tools and a user quoting the sentence go on as they are. pi.test.mjs is new (pi's two captured shapes; 3 of its 4 fail on 0.1.17, the 4th checks what is left alone); bun test (85 pass) and check.mjs factory pass. Not tried against Factory itself (no Factory account here). 2026-10-06 08:08:15 +08:00
yetone 5d2621db88 factory 0.1.17: DeepSeek V4.1 Flash, Kimi K3 and GLM-5.2 offer none, so a request turning reasoning off stops their thinking (yetone/magpie#899, tedestar) — they offered only low/high/max (GLM-5.2 high/max), so magpie asked for low and they thought anyway. droid 0.231.0 lists off for them and sends reasoning_effort "none"; Fireworks (via OpenRouter, pinned) answered none with 0 reasoning tokens on DeepSeek V4.1 Flash (2 completion tokens, 19 at default) and Kimi K3 (8, 71 at default), and turns none away on GLM-5.3 and GLM-5.3-Flash ("Reasoning is mandatory"), whose least stays low. effort.test.mjs is new (the levels fail on 0.1.16); bun test and check.mjs pass. 2026-10-05 19:54:33 +08:00
yetone 9fefe75f15 factory 0.1.16: requests say droid 0.233.0, the current release (Discord, JL on magpie 0.1.824 with plugin 0.1.15: every model 403 "Factory: Forbidden" from pi and Claude Code, while droid itself works) — droid 0.233.0's model requests carry the same headers, paths and body shape as 0.231.0's apart from its version (X-Client-Version, User-Agent factory-cli/<ver>), and its binary reads a server-side min_cli_version; the plugin said 0.231.0, two releases behind. Whether Factory refuses an old version with a 403 is not confirmed (no Factory account to try with); this is the one difference found. bun test (79 pass) and bun scripts/check.mjs factory pass. 2026-10-04 18:26:33 +08:00
Mars-Sea 4a368481b0 factory 0.1.15: GPT-6.1 Sol, in droid 0.233.0's picker, reaches Factory through magpie (#15)
MODELS predated GPT-6.1 Sol, so a droid account whose policy allows the
model could not reach it through the plugin. droid's built-in picker, read
by giving "droid exec -m" an id it rejects (it prints the whole list),
names it gpt-6.1-sol — droid spells the minor with a dot, as it does
gpt-5.6-sol, not the gpt-6-1-sol other providers' plugins carry.

It goes on RESPONSES with openai as its vendor, 1050000 context and
128000 output like the rest of the GPT-6 family, images on. Factory's
docs list low, medium, high, xhigh and max for it and no none (gpt-6-sol
and gpt-6-luna have one), so it takes E5 rather than E6. The same docs
were read against the other 30 entries: their efforts are correct.

The picker also offers 19 models this list lacks: Claude Opus 4.5, 4.6
and 4.7, Claude Sonnet 4.5, GPT-5.2, GPT-5.4 Mini, GPT-5.5 Pro, Grok
4.5, DeepSeek V4 Pro, the DeepSeek V4 Flash 0731 snapshot, Inkling, and
nine -fast variants. The superseded ones were left out, and the rest
carry no context or output figure from Factory, from the picker or from
the other plugins here — writing a guessed limit would mislead. The list
stays what droid offers, not what one organization's policy allows: of
the entries already here, 21 are blocked by the account this was checked
on.

Tests: bun test (458 pass) and bun scripts/check.mjs factory pass. The id
was confirmed against droid 0.233.0's picker and passes that account's
policy and effort validation; no inference request was sent.
2026-10-04 11:52:44 +08:00
yetone 16ec1b8ba9 factory 0.1.14: Claude Code 2.1.288's runtime context sent as a system message of text blocks is adapted as the string one is (yetone/magpie#658)
anthropicBody adapted a role:"system" message only when its content was a
string, so Claude Code 2.1.288's context as [{type:"text",...}] reached
Factory unadapted and was refused (403). Each text block of such a message now
goes through systemContext, its other fields and non-text blocks kept; a user
text block opening with the generated environment context (a system message
folded into the user's turn) is adapted too. The top-level system already
treats a string and an array alike, and the OpenAI route adapts no context.
Tests: the #658 shape (fails on 0.1.13), string/array parity, idempotence;
two tests that asserted array content was left alone now use text outside the
generated shape. Not tried with a live Factory account.
2026-10-03 16:30:42 +08:00
yetone b541aaa766 factory 0.1.13: tools whose schema is a root anyOf/oneOf/allOf reach Factory's Claude models, nested under one argument and unwrapped on the way back (#12, yetone/magpie#646) 2026-10-03 14:56:46 +08:00
SadWood 7a504148cf fix(factory): 保留联合工具 schema 的参数约束 (#12)
Factory 的 Anthropic 接口拒绝顶层联合工具 schema,导致 Codex 请求返回 400。
通过内部参数包装、响应解包及历史转换兼容该接口,保留分支约束、引用作用域和参数精度。

新增 21 项回归测试,覆盖流式分片、多轮调用、异常、并发和精度。
全库 420 项测试通过,并以 Factory Opus 5.5 验证三种联合 schema、流式调用及第二轮对话。
2026-10-03 14:56:38 +08:00
yetone f28aac332d factory 0.1.12: Claude Code with a global CLAUDE.md or a SessionStart hook, and Claude Desktop, reach Factory again (yetone/magpie#634)
Factory refused three generated phrases the adapter left as they were:
- the instructions reminder's "(user's private global instructions for all
  projects)" naming ~/.claude/CLAUDE.md, now "(global instructions)" in that
  reminder only;
- Claude 5's runtime context after a SessionStart hook's output, as a system
  message or folded into the user's turn: the context after the hook is
  adapted as it is alone, the hook's output left as it is;
- the model line inside a system prompt (Claude Desktop's), adapted as in a
  reminder.
Three tests cover them and fail without the change; bun test passes.
2026-10-03 13:29:17 +08:00
yetone 9b434a5ed3 factory 0.1.11: magpie renews the sign-in ahead of time through auth.refresh
auth.refresh with refreshLead 3 minutes (in-fetch: 2). It renews under
the lock the request path and mendOrg already share, asks whoami again as
droid does, and gives the tokens and org fields. A renewed map (spent
refresh token → what it gave) lets a request that read the old sign-in
before magpie saved go on with the new one, and keeps rotated tokens when a
save fails. WorkOS refusing the refresh token is signIn "expired" (as the
request path's lapse already was); 429 and 5xx throw and are retried.

The check before each request stays for OpenCode, which doesn't call the
hook (magpie 0.1.684+ does). refresh.test.mjs fails without the change;
HOME=$(mktemp -d) bun test passes (396 across the repo).
2026-10-03 12:07:22 +08:00
XIQI ef68e7c7c0 factory: handle quoted tool metadata and directory model updates (#10) 2026-10-03 00:34:10 +08:00
yetone 8f25b63718 publish from GitHub Actions with npm's trusted publishing, no one-time password [skip ci]
.github/workflows/publish.yml runs the tests (in a throwaway HOME) and
scripts/publish.sh on each package.json change pushed to main, or by hand;
npm's OIDC exchange stands in for a token and an OTP. Every package now
names magpie-community/plugins' publish.yml as its trusted publisher on
npmjs.com, and gets the repository field npm checks it against.
2026-10-03 00:00:23 +08:00
XIQI d7d8d61c42 factory: adapt Claude Code's standalone model-switch system updates (#9)
After /model, Claude Code 2.1.287 sends a separate string-content system message that opens with the new model paragraph and carries <total_tokens> metadata but no environment block; Factory refused it with 403, so continuing a conversation after a model switch failed. systemContext now also adapts that shape: only when the message starts with the model paragraph and has a complete generated <total_tokens>N tokens left</total_tokens> paragraph, it rewrites each whole model paragraph (named or not, routing-group ids, accumulated switches) to Current model / Model ID / Model knowledge cutoff, leaving every other byte, role and order as sent; inference and count_tokens share it, and a second pass is byte-identical. Tests cover accumulated switches across both endpoints with idempotence, and pass-through for incomplete markers, quoted text, array content and non-system roles. Factory bumped to 0.1.9.
2026-10-02 23:22:21 +08:00
XIQI a51d4d2ec7 factory: adapt Claude 5 system-role runtime metadata (#8) 2026-10-02 23:03:32 +08:00
XIQI bcfb867635 factory: adapt built-in configuration skill metadata (#7) 2026-10-02 22:03:31 +08:00
XIQI 6f061c5c60 factory: support Claude Code on the Anthropic Messages route (#3)
* factory: adapt Claude Code Anthropic request bodies

* factory: address Anthropic compatibility review

* factory: handle additional directories and refresh 403 guidance
2026-10-02 21:36:33 +08:00
yetone 427947eadc factory 0.1.5: another agent's request to /api/llm/o opens as Droid's does, and a Factory API key can be added (yetone/magpie#506: factory-plugin/glm-5.3-flash answered 403 "Factory refused this account the request; check that droid…" on magpie v0.1.641) — the plugin had none of the built-in's fixes after 30 Sep. As the built-in's factoryDroidBody (e413dd84, magpie v0.1.630) has it, Responses' instructions, or chat completions' first system message (text parts joined with "\n"), open with droid 0.231.0's "You are Droid, an AI software engineering agent built by Factory." and "\n" before the agent's own; with none, the line alone goes first; droid's own requests and everything on /api/llm/a go on byte for byte, and a rewritten body drops the old Content-Length. The requests say droid 0.231.0, GLM-5.3-Flash takes images, and a 403 says what the built-in's factoryExplain says (5523eb17). A Factory API key (fk-…), droid's FACTORY_API_KEY, is an "api" sign-in method as factory_key.go (bb5e8a2b) keeps one: the bearer with droid's headers, never renewed, no X-Factory-Org-Id, not mended on a 403; whoami asked once with the key gives its region/host and whose it is, kept in the key's metadata. No request was made to Factory. droid.test.mjs (the built-in's TestFactoryOpensAsDroid cases, images, key requests and usage) fails against 0.1.4; bun test and scripts/check.mjs factory pass. 2026-10-02 16:33:14 +08:00
yetone 01aee5da28 all: a usage read says what it means for the sign-in, and a renewal clears the mark whatever follows, as the built-ins did (要保证插件跟内置的所有逻辑都要一模一样) — auth.usage returns signIn on every path: expired where the built-in's quota read marked the account (Zed's /users/me 401, Factory's and MiMo's refused renewals, Qoder's refused job refresh), renewed after a renewal, which took the mark off, kept everywhere else, so magpie no longer guesses from the words 'sign in again' (Kiro's, Devin's and ZCode's usage errors marked accounts their built-ins never did) nor clears on a clean read. A request after a renewal says renewed on any status; one without says kept, as the built-ins cleared only on renewal. Kiro, Cursor, Devin, Command Code, WorkBuddy, Grok and ZCode, whose built-ins never marked an account, say kept on every answer. New tests fail against 85d7dd0's index.mjs. 2026-10-01 04:53:29 +08:00
yetone 85d7dd0d0a all: each plugin fails with its built-in's status and marks the sign-in as it did, through X-Magpie-Sign-In (要保证插件跟内置的所有逻辑都要一模一样) — Factory's and MiMo's refused renewals are the built-ins' 502 marked expired, not 401s; Qoder's vendor 403 is the built-in's 401 kept, its model list's failure a 400, its job refresh refused marked expired; Zed's retried 401 is a 401 kept, not a 403; Kiro's unreachable refresh a 401 kept; Cursor's expired trial a 401 kept; a vendor 401 WorkBuddy, Grok, Devin, Command Code and ZCode passed on no longer marks the account, as their built-ins never did, and Grok and MiMo no longer retry what their built-ins sent once. Messages take the built-ins' words. New tests fail against the previous index.mjs. 2026-10-01 04:47:03 +08:00
yetone 23a580b6aa factory 0.1.3: a refusal says what to do after an em dash ("<Factory's message> — Factory refused this account…"), as the built-in's Provider.Explain joins them, where it used ": "; an empty 403 reads "403 Forbidden", the status Go falls back to 2026-10-01 03:21:02 +08:00
yetone c8f4d448df Parity with magpie's built-ins: a failed sign-in says why, CLI-backed Command Code and Devin accounts follow the CLI's key, Factory's refused renewal is a 401 in the caller's API shape
- every {type:"failed"} carries an error reason magpie shows
- commandcode/devin: accounts taken from the CLI are marked metadata.cli and re-read its credentials on each request, usage and models
- factory: a refused refresh answers 401 authentication_error (Anthropic shape on /llm/a/, OpenAI's elsewhere) instead of throwing; the whoami back-off is per account; 403 hints name the account to sign in again
- versions: factory/devin/commandcode/cursor/kiro/mimo/zed/zcode 0.1.2, workbuddy 0.1.3
2026-10-01 00:55:50 +08:00
yetone 40a495f321 factory 0.1.1: usage shows as magpie's built-in did — plan, period, windows and what they count, balancefactory 2026-09-30 23:03:08 +08:00
yetone 5a18bbdac4 Name the scope @magpie-community (the org's name, spelled right) 2026-09-30 17:04:47 +08:00
yetone 56e0f46896 factory: Factory (Droid) — WorkOS device-code sign-in with droid's client, org chosen and refreshed as droid does, EU and org hosts, droid's headers, 30 models each on its own API (Messages, Responses, chat completions) 2026-09-30 17:00:35 +08:00