okstra 0.234.1 → 0.236.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.
Files changed (171) hide show
  1. package/dist/cli-registry.mjs +7 -0
  2. package/dist/cli-registry.mjs.map +1 -1
  3. package/dist/commands/implementation-report/implementation-report.d.mts +1 -0
  4. package/dist/commands/implementation-report/implementation-report.mjs +73 -0
  5. package/dist/commands/implementation-report/implementation-report.mjs.map +1 -0
  6. package/dist/commands/trace/comparison.d.mts +39 -0
  7. package/dist/commands/trace/comparison.mjs +138 -0
  8. package/dist/commands/trace/comparison.mjs.map +1 -0
  9. package/dist/commands/trace/document.d.mts +8 -0
  10. package/dist/commands/trace/document.mjs +37 -0
  11. package/dist/commands/trace/document.mjs.map +1 -0
  12. package/dist/commands/trace/line-counts.d.mts +15 -0
  13. package/dist/commands/trace/line-counts.mjs +107 -0
  14. package/dist/commands/trace/line-counts.mjs.map +1 -0
  15. package/dist/commands/trace/model.d.mts +2 -1
  16. package/dist/commands/trace/model.mjs +13 -1
  17. package/dist/commands/trace/model.mjs.map +1 -1
  18. package/dist/commands/trace/progression.mjs +7 -3
  19. package/dist/commands/trace/progression.mjs.map +1 -1
  20. package/dist/commands/trace/task-link.d.mts +3 -0
  21. package/dist/commands/trace/task-link.mjs.map +1 -1
  22. package/dist/commands/trace/trace.mjs +64 -44
  23. package/dist/commands/trace/trace.mjs.map +1 -1
  24. package/dist/lib/host-registry-client.d.mts +9 -2
  25. package/dist/lib/host-registry-client.mjs +29 -3
  26. package/dist/lib/host-registry-client.mjs.map +1 -1
  27. package/dist/lib/python-helper.d.mts +1 -1
  28. package/dist/lib/python-helper.mjs +11 -5
  29. package/dist/lib/python-helper.mjs.map +1 -1
  30. package/dist/lib/runtime-payload.mjs +1 -0
  31. package/dist/lib/runtime-payload.mjs.map +1 -1
  32. package/dist/lib/types.d.mts +1 -0
  33. package/docs/architecture/storage-model.md +50 -0
  34. package/docs/architecture.md +1 -1
  35. package/docs/cli.md +37 -15
  36. package/docs/project-structure-overview.md +6 -1
  37. package/package.json +1 -1
  38. package/runtime/BUILD.json +2 -2
  39. package/runtime/agents/operations/trace-tests-review.json +6 -0
  40. package/runtime/bin/lib/okstra/usage.sh +8 -8
  41. package/runtime/bin/okstra-qwen-exec.sh +5 -0
  42. package/runtime/prompts/duties/test-reviewer.json +32 -0
  43. package/runtime/prompts/lead/convergence.md +4 -1
  44. package/runtime/prompts/lead/okstra-lead-contract.md +3 -3
  45. package/runtime/prompts/lead/report-writer.md +13 -1
  46. package/runtime/prompts/profiles/_common-contract.md +10 -1
  47. package/runtime/prompts/wizard/prompts.ko.json +16 -4
  48. package/runtime/python/okstra_ctl/adapters/providers/antigravity/adapter.py +10 -2
  49. package/runtime/python/okstra_ctl/adapters/providers/claude/adapter.py +16 -1
  50. package/runtime/python/okstra_ctl/adapters/providers/codex/adapter.py +20 -5
  51. package/runtime/python/okstra_ctl/adapters/providers/kimi/adapter.py +17 -9
  52. package/runtime/python/okstra_ctl/adapters/providers/qwen/adapter.py +88 -0
  53. package/runtime/python/okstra_ctl/adapters/providers/qwen/manifest.json +1 -0
  54. package/runtime/python/okstra_ctl/adapters/providers/qwen/settings.json +12 -0
  55. package/runtime/python/okstra_ctl/adapters/providers/zai/adapter.py +8 -2
  56. package/runtime/python/okstra_ctl/agent/invocation.py +109 -56
  57. package/runtime/python/okstra_ctl/agent/prompt_cli/materialize.py +17 -0
  58. package/runtime/python/okstra_ctl/attempt_evidence.py +5 -2
  59. package/runtime/python/okstra_ctl/business_flow/contracts.py +11 -0
  60. package/runtime/python/okstra_ctl/business_flow/engine.py +90 -32
  61. package/runtime/python/okstra_ctl/business_flow/hooks.py +4 -2
  62. package/runtime/python/okstra_ctl/business_flow/source.py +39 -7
  63. package/runtime/python/okstra_ctl/business_flow/store.py +94 -28
  64. package/runtime/python/okstra_ctl/code_review_census.py +38 -0
  65. package/runtime/python/okstra_ctl/code_review_coverage.py +15 -4
  66. package/runtime/python/okstra_ctl/code_review_prepare.py +15 -3
  67. package/runtime/python/okstra_ctl/code_review_scope.py +3 -2
  68. package/runtime/python/okstra_ctl/code_review_target.py +16 -6
  69. package/runtime/python/okstra_ctl/conformance_evidence.py +44 -21
  70. package/runtime/python/okstra_ctl/consumers.py +6 -1
  71. package/runtime/python/okstra_ctl/convergence.py +95 -5
  72. package/runtime/python/okstra_ctl/convergence_critic_verify_prompt.py +11 -10
  73. package/runtime/python/okstra_ctl/convergence_engine.py +30 -15
  74. package/runtime/python/okstra_ctl/convergence_reverify_prompt.py +9 -2
  75. package/runtime/python/okstra_ctl/coverage_census.py +75 -12
  76. package/runtime/python/okstra_ctl/design_review.py +6 -26
  77. package/runtime/python/okstra_ctl/design_review_evidence.py +6 -26
  78. package/runtime/python/okstra_ctl/dispatch_core.py +9 -2
  79. package/runtime/python/okstra_ctl/dispatch_state.py +5 -0
  80. package/runtime/python/okstra_ctl/domain/role.py +1 -0
  81. package/runtime/python/okstra_ctl/entrypoints/hosts.py +1 -1
  82. package/runtime/python/okstra_ctl/execution_manifest.py +8 -0
  83. package/runtime/python/okstra_ctl/implementation_comparison/__init__.py +12 -0
  84. package/runtime/python/okstra_ctl/implementation_comparison/__main__.py +129 -0
  85. package/runtime/python/okstra_ctl/implementation_comparison/assembly.py +340 -0
  86. package/runtime/python/okstra_ctl/implementation_comparison/baseline.py +254 -0
  87. package/runtime/python/okstra_ctl/implementation_comparison/business_reuse.py +118 -0
  88. package/runtime/python/okstra_ctl/implementation_comparison/commit_source.py +113 -0
  89. package/runtime/python/okstra_ctl/implementation_comparison/html.py +49 -0
  90. package/runtime/python/okstra_ctl/implementation_comparison/inputs.py +348 -0
  91. package/runtime/python/okstra_ctl/implementation_comparison/model.py +47 -0
  92. package/runtime/python/okstra_ctl/implementation_comparison/preparation.py +195 -0
  93. package/runtime/python/okstra_ctl/implementation_comparison/publication.py +317 -0
  94. package/runtime/python/okstra_ctl/implementation_comparison/run_evidence.py +208 -0
  95. package/runtime/python/okstra_ctl/implementation_comparison/run_integration.py +198 -0
  96. package/runtime/python/okstra_ctl/implementation_comparison/source.py +342 -0
  97. package/runtime/python/okstra_ctl/implementation_comparison/target.py +144 -0
  98. package/runtime/python/okstra_ctl/implementation_comparison/task_assembly.py +333 -0
  99. package/runtime/python/okstra_ctl/implementation_comparison/task_selection.py +309 -0
  100. package/runtime/python/okstra_ctl/implementation_generation_evidence.py +134 -0
  101. package/runtime/python/okstra_ctl/implementation_outcome.py +2 -2
  102. package/runtime/python/okstra_ctl/initial_prompt_materialization.py +1 -0
  103. package/runtime/python/okstra_ctl/json_boundary.py +28 -8
  104. package/runtime/python/okstra_ctl/lead_progress.py +1 -1
  105. package/runtime/python/okstra_ctl/model_discovery.py +1 -1
  106. package/runtime/python/okstra_ctl/models.py +2 -2
  107. package/runtime/python/okstra_ctl/paths.py +7 -4
  108. package/runtime/python/okstra_ctl/phases/discussion/profile.md +2 -2
  109. package/runtime/python/okstra_ctl/phases/error_analysis/profile.md +1 -1
  110. package/runtime/python/okstra_ctl/phases/implementation_option_selection/profile.md +1 -1
  111. package/runtime/python/okstra_ctl/phases/implementation_planning/authoring.py +2 -1
  112. package/runtime/python/okstra_ctl/phases/implementation_planning/instructions/plan-body-verification.md +1 -1
  113. package/runtime/python/okstra_ctl/phases/implementation_planning/profile.md +3 -3
  114. package/runtime/python/okstra_ctl/phases/requirements_discovery/profile.md +5 -5
  115. package/runtime/python/okstra_ctl/plan_run_root.py +8 -4
  116. package/runtime/python/okstra_ctl/qa_procedures.py +33 -2
  117. package/runtime/python/okstra_ctl/registry/provider_registry.py +1 -1
  118. package/runtime/python/okstra_ctl/render.py +4 -0
  119. package/runtime/python/okstra_ctl/render_final_report.py +1 -1
  120. package/runtime/python/okstra_ctl/report_execution_evidence.py +88 -15
  121. package/runtime/python/okstra_ctl/report_finalize.py +18 -4
  122. package/runtime/python/okstra_ctl/report_html/render.py +46 -7
  123. package/runtime/python/okstra_ctl/report_html/validation.py +32 -0
  124. package/runtime/python/okstra_ctl/report_synthesis_packet.py +37 -3
  125. package/runtime/python/okstra_ctl/report_view_artifacts.py +12 -0
  126. package/runtime/python/okstra_ctl/review_verdicts.py +9 -0
  127. package/runtime/python/okstra_ctl/run.py +17 -1
  128. package/runtime/python/okstra_ctl/run_context.py +18 -3
  129. package/runtime/python/okstra_ctl/schema_excerpt.py +14 -9
  130. package/runtime/python/okstra_ctl/stage_done.py +11 -3
  131. package/runtime/python/okstra_ctl/stage_ledger.py +2 -2
  132. package/runtime/python/okstra_ctl/stage_map.py +3 -3
  133. package/runtime/python/okstra_ctl/trace_review.py +1 -0
  134. package/runtime/python/okstra_ctl/trace_tasks.py +22 -7
  135. package/runtime/python/okstra_ctl/verdict_blocks.py +7 -2
  136. package/runtime/python/okstra_ctl/verification_dispatch.py +32 -0
  137. package/runtime/python/okstra_ctl/verification_evidence.py +23 -3
  138. package/runtime/python/okstra_ctl/verification_generation.py +3 -2
  139. package/runtime/python/okstra_ctl/verification_inputs.py +3 -2
  140. package/runtime/python/okstra_ctl/verification_invocation.py +7 -3
  141. package/runtime/python/okstra_ctl/wizard/engine.py +28 -1
  142. package/runtime/python/okstra_ctl/wizard/ids.py +8 -0
  143. package/runtime/python/okstra_ctl/wizard/picker_navigation.py +64 -2
  144. package/runtime/python/okstra_ctl/wizard/roles.py +194 -45
  145. package/runtime/python/okstra_ctl/wizard/sources.py +10 -1
  146. package/runtime/python/okstra_ctl/wizard/state.py +67 -20
  147. package/runtime/python/okstra_ctl/wizard/steps_roles.py +6 -3
  148. package/runtime/python/okstra_ctl/wizard/worker_settings.py +129 -25
  149. package/runtime/python/okstra_ctl/worker_audit_ledger.py +44 -8
  150. package/runtime/python/okstra_ctl/worker_prompt_body.py +26 -2
  151. package/runtime/python/okstra_ctl/worker_prompt_headers.py +12 -9
  152. package/runtime/python/okstra_token_usage/claude.py +5 -1
  153. package/runtime/python/okstra_token_usage/collect.py +3 -3
  154. package/runtime/python/okstra_token_usage/pricing.py +1 -0
  155. package/runtime/schemas/report-synthesis-packet-v1.0.schema.json +17 -0
  156. package/runtime/skills/_fragments/wizard-relay-protocol.md +1 -1
  157. package/runtime/skills/okstra-code-review/SKILL.md +1 -1
  158. package/runtime/skills/okstra-code-review/references/census-rules.md +1 -1
  159. package/runtime/skills/okstra-code-review/references/review-calibration.md +1 -1
  160. package/runtime/skills/okstra-discussion/SKILL.md +1 -1
  161. package/runtime/skills/okstra-run/SKILL.md +33 -2
  162. package/runtime/skills/okstra-tdd/SKILL.md +74 -13
  163. package/runtime/templates/reports/html/assets/implementation-comparison.css +39 -0
  164. package/runtime/templates/reports/html/assets/implementation-comparison.js +55 -0
  165. package/runtime/templates/reports/html/i18n/en.json +113 -0
  166. package/runtime/templates/reports/html/i18n/ko.json +113 -0
  167. package/runtime/templates/reports/html/implementation-comparison.template.html +77 -0
  168. package/runtime/templates/reports/implementation-comparison-notes.md +72 -0
  169. package/runtime/templates/trace/trace.template.md +2 -0
  170. package/runtime/templates/worker-prompt-preamble.md +12 -2
  171. package/runtime/validators/validate-report-views.py +4 -36
@@ -30,9 +30,17 @@ import okstra_ctl.model_discovery as model_discovery
30
30
  # normalizer through ProviderSpec so assignment resolution does not branch on
31
31
  # provider names.
32
32
  ANTIGRAVITY = {
33
+ "gemini-4-carbon": ModelSpec(
34
+ "gemini-4-carbon", "Gemini 4 Carbon", "gemini-4-carbon",
35
+ aliases=("gemini 4 carbon",),
36
+ ),
37
+ "gemini-4-hydrogen": ModelSpec(
38
+ "gemini-4-hydrogen", "Gemini 4 Hydrogen", "gemini-4-hydrogen",
39
+ aliases=("gemini 4 hydrogen",),
40
+ ),
33
41
  "gemini-3.1-pro": ModelSpec(
34
42
  "gemini-3.1-pro", "Gemini 3.1 Pro", "gemini-3.1-pro",
35
- aliases=("gemini 3.1 pro",),
43
+ aliases=("gemini 3.1 pro",), selectable=False,
36
44
  ),
37
45
  "gemini-4-argon": ModelSpec(
38
46
  "gemini-4-argon", "Gemini 4 Argon", "gemini-4-argon",
@@ -326,7 +334,7 @@ def create_provider() -> ProviderSpec:
326
334
  display_label="Antigravity",
327
335
  models=ANTIGRAVITY,
328
336
  default_models={
329
- role: "gemini-3.1-pro"
337
+ role: "gemini-4-argon"
330
338
  for role in (
331
339
  "lead", "analyser", "critic", "designer", "planner", "executor",
332
340
  "verifier", "report-writer",
@@ -18,6 +18,10 @@ from okstra_ctl.domain.worker_stream import content_block_events
18
18
 
19
19
 
20
20
  CLAUDE = {
21
+ "fable-5-2": ModelSpec(
22
+ "fable-5-2", "fable-5-2", "claude-fable-5-2", aliases=("claude-fable-5-2",),
23
+ channel_family="fable", selectable=False,
24
+ ),
21
25
  "fable": ModelSpec(
22
26
  "fable", "fable", "fable", version_kind="channel", channel_family="fable"
23
27
  ),
@@ -108,6 +112,14 @@ def observe_served_model(event: Mapping[str, Any]) -> str | None:
108
112
  # observed end to end, which is why policy_support claims no write boundary.
109
113
  _APPROVAL_ARGS = ("--permission-mode", "bypassPermissions")
110
114
 
115
+ # The user's own ~/.claude (CLAUDE.md, rules, skills, settings such as an answer
116
+ # language) would otherwise load into every worker and compete with the worker
117
+ # prompt. Project and local sources stay: they carry the target project's own
118
+ # CLAUDE.md, settings and project-scope MCP servers. User-scope MCP servers drop
119
+ # out with the user source, so the MCP inventory below is listed under the same
120
+ # sources to report only what a worker can reach.
121
+ _SETTING_SOURCE_ARGS = ("--setting-sources", "project,local")
122
+
111
123
 
112
124
  class ClaudeExecution:
113
125
  """claude CLI invocation.
@@ -131,6 +143,7 @@ class ClaudeExecution:
131
143
  argv += list(_APPROVAL_ARGS)
132
144
  if request.reasoning_effort:
133
145
  argv += ["--effort", request.reasoning_effort]
146
+ argv += list(_SETTING_SOURCE_ARGS)
134
147
  # `--verbose` is mandatory, not cosmetic: Claude Code rejects `--print`
135
148
  # combined with `--output-format=stream-json` without it and exits 1 in
136
149
  # under a second.
@@ -176,7 +189,9 @@ def parse_mcp_list(stdout: str) -> McpInventory:
176
189
  return McpInventory(listed=True, servers=tuple(servers))
177
190
 
178
191
 
179
- MCP_INVENTORY = McpInventoryProbe(argv=("claude", "mcp", "list"), parse=parse_mcp_list)
192
+ MCP_INVENTORY = McpInventoryProbe(
193
+ argv=("claude", *_SETTING_SOURCE_ARGS, "mcp", "list"), parse=parse_mcp_list,
194
+ )
180
195
 
181
196
 
182
197
  def create_provider() -> ProviderSpec:
@@ -20,6 +20,10 @@ import okstra_ctl.model_discovery as model_discovery
20
20
 
21
21
 
22
22
  CODEX = {
23
+ "gpt-6.1-terra": ModelSpec(
24
+ "gpt-6.1-terra", "gpt-6.1-terra", "gpt-6.1-terra", pricing=(1.0, 0.05, 5.0),
25
+ cli_args=("-c", "model_reasoning_effort=high"),
26
+ ),
23
27
  # 비용은 계정이 구독이든 API 든 공개 API 단가(입력·캐시 입력·출력 USD/1M)로
24
28
  # 추정한다 — 리포트가 답하는 것은 "얼마나 썼는가" 이지 "청구서에 얼마가
25
29
  # 찍히는가" 가 아니다. 단가를 비우면 그 워커의 비용이 `--` 로 빠지고, 접두어
@@ -29,12 +33,23 @@ CODEX = {
29
33
  # layer3labs.io/guides/gpt-6-astra-api-pricing).
30
34
  # gpt-6 단가는 OpenAI 모델 문서의 표준 등급(2026-09-23 확인):
31
35
  # developers.openai.com/api/docs/models/gpt-6-sol, .../gpt-6-luna, .../gpt-6.1-sol
32
- # (gpt-6.1-sol 은 2026-09-30 확인: 캐시 입력만 $0.10 으로 gpt-6-sol 과 다르다).
33
- "gpt-6-astra": ModelSpec("gpt-6-astra", "gpt-6-astra", "gpt-6-astra", pricing=(10.0, 1.0, 50.0)),
34
- # 카탈로그 기본 effort 는 low 라, config.toml 에 값이 없는 기계에서는 low 로 돈다.
36
+ # (gpt-6.1-sol 은 2026-09-30 확인: 캐시 입력만 $0.10 으로 gpt-6-sol 과 다르다;
37
+ # gpt-6.2-sol 은 2026-11-19 확인: gpt-6.1-sol 과 같은 단가).
38
+ # gpt-6.2-astra 는 2026-11-19 확인: developers.openai.com/api/docs/models/gpt-6.2-astra.
39
+ # gpt-6.2-astra·gpt-6.2-sol 의 카탈로그 기본 effort 는 low 라, config.toml 에 값이
40
+ # 없는 기계에서는 low 로 돈다. 그래서 두 행 모두 high 를 고정한다.
41
+ "gpt-6.2-astra": ModelSpec(
42
+ "gpt-6.2-astra", "gpt-6.2-astra", "gpt-6.2-astra", pricing=(8.0, 0.40, 40.0),
43
+ cli_args=("-c", "model_reasoning_effort=high"),
44
+ ),
45
+ "gpt-6-astra": ModelSpec("gpt-6-astra", "gpt-6-astra", "gpt-6-astra", pricing=(10.0, 1.0, 50.0), selectable=False),
46
+ "gpt-6.2-sol": ModelSpec(
47
+ "gpt-6.2-sol", "gpt-6.2-sol", "gpt-6.2-sol", pricing=(2.0, 0.10, 10.0),
48
+ cli_args=("-c", "model_reasoning_effort=high"),
49
+ ),
35
50
  "gpt-6.1-sol": ModelSpec(
36
51
  "gpt-6.1-sol", "gpt-6.1-sol", "gpt-6.1-sol", pricing=(2.0, 0.10, 10.0),
37
- cli_args=("-c", "model_reasoning_effort=high"),
52
+ cli_args=("-c", "model_reasoning_effort=high"), selectable=False,
38
53
  ),
39
54
  "gpt-6-sol": ModelSpec("gpt-6-sol", "gpt-6-sol", "gpt-6-sol", pricing=(2.0, 0.20, 10.0), selectable=False),
40
55
  "gpt-6-luna": ModelSpec("gpt-6-luna", "gpt-6-luna", "gpt-6-luna", pricing=(0.10, 0.01, 0.50)),
@@ -162,7 +177,7 @@ def create_provider() -> ProviderSpec:
162
177
  display_label="Codex",
163
178
  models=CODEX,
164
179
  default_models={
165
- role: "gpt-6.1-sol"
180
+ role: "gpt-6.2-sol"
166
181
  for role in ("lead", "analyser", "critic", "designer", "planner", "executor", "verifier", "report-writer")
167
182
  },
168
183
  wrapper="okstra-codex-exec.sh",
@@ -17,7 +17,15 @@ from okstra_ctl.domain.worker_stream import content_block_events
17
17
 
18
18
 
19
19
  KIMI = {
20
- "kimi-k3": ModelSpec("kimi-k3", "Kimi K3", "kimi-k3", aliases=("kimi k3",), pricing=(3.00, 0.30, 15.00)),
20
+ "k3.1-pro": ModelSpec(
21
+ "k3.1-pro", "Kimi K3.1 Pro", "k3.1-pro",
22
+ aliases=("kimi-k3.1-pro",), pricing=(2.0, 0.20, 10.0),
23
+ ),
24
+ "k3.1-pro-highspeed": ModelSpec(
25
+ "k3.1-pro-highspeed", "Kimi K3.1 Pro Highspeed", "k3.1-pro-highspeed",
26
+ aliases=("kimi-k3.1-pro-highspeed",), pricing=(4.0, 0.20, 20.0),
27
+ ),
28
+ "kimi-k3": ModelSpec("kimi-k3", "Kimi K3", "kimi-k3", aliases=("kimi k3",), pricing=(3.00, 0.30, 15.00), selectable=False),
21
29
  # picker 에서는 감춘다: kimi-k3 와 표시명·실체가 같아 목록에 두 줄로 뜬다.
22
30
  # 단가는 kimi-k3 와 같다 — 같은 모델의 다른 슬러그이고, `_match_pricing` 은
23
31
  # `kimi-k3` 키를 `k3` 관측값에 맞추지 못하므로 행마다 값을 둔다. k3-256k 는
@@ -96,14 +104,14 @@ def create_provider() -> ProviderSpec:
96
104
  display_label="Kimi",
97
105
  models=KIMI,
98
106
  default_models={
99
- "lead": "kimi-k3",
100
- "analyser": "kimi-k3",
101
- "critic": "kimi-k3",
102
- "designer": "kimi-k3",
103
- "planner": "kimi-k3",
104
- "executor": "kimi-k3",
105
- "verifier": "kimi-k3",
106
- "report-writer": "kimi-k3",
107
+ "lead": "k3.1-pro",
108
+ "analyser": "k3.1-pro",
109
+ "critic": "k3.1-pro",
110
+ "designer": "k3.1-pro",
111
+ "planner": "k3.1-pro",
112
+ "executor": "k3.1-pro",
113
+ "verifier": "k3.1-pro",
114
+ "report-writer": "k3.1-pro",
107
115
  },
108
116
  wrapper="okstra-kimi-exec.sh",
109
117
  supported_roles=ALL_ROLE_TOKENS,
@@ -0,0 +1,88 @@
1
+ """Qwen Code workers using a regional Model Studio API endpoint."""
2
+ import os
3
+ import re
4
+ from collections.abc import Mapping
5
+ from pathlib import Path
6
+ from typing import Any
7
+ from urllib.parse import urlsplit
8
+
9
+ from okstra_ctl.domain.provider import ModelSpec, ProviderSpec
10
+ from okstra_ctl.domain.role import ROLE_DEFINITIONS
11
+ from okstra_ctl.domain.worker_exec import ExecCommand, PolicySupport, WorkerExecRequest
12
+ from okstra_ctl.domain.worker_presentation import JsonEvents
13
+ from okstra_ctl.domain.worker_stream import content_block_events
14
+
15
+
16
+ def observe_usage(event: Mapping[str, Any]) -> Mapping[str, Any] | None:
17
+ usage = event.get("usage") if event.get("type") == "result" else None
18
+ return usage if isinstance(usage, Mapping) and usage else None
19
+
20
+
21
+ class QwenExecution:
22
+ def build_command(self, request: WorkerExecRequest) -> ExecCommand:
23
+ api_key = os.environ.get("DASHSCOPE_API_KEY", "").strip()
24
+ endpoint = os.environ.get("OKSTRA_QWEN_BASE_URL", "").strip()
25
+ if not api_key:
26
+ raise OSError("DASHSCOPE_API_KEY is required for Qwen workers")
27
+ if not endpoint:
28
+ raise OSError("OKSTRA_QWEN_BASE_URL is required for Qwen workers")
29
+ try:
30
+ parsed = urlsplit(endpoint)
31
+ port = parsed.port
32
+ except ValueError:
33
+ raise OSError("OKSTRA_QWEN_BASE_URL is not a valid Model Studio URL") from None
34
+ host = parsed.hostname or ""
35
+ if parsed.username is not None or parsed.password is not None:
36
+ raise OSError("OKSTRA_QWEN_BASE_URL must not embed credentials")
37
+ regional = re.fullmatch(r"[a-z0-9-]+\.[a-z0-9-]+\.maas\.aliyuncs\.com", host)
38
+ legacy = host in {"dashscope.aliyuncs.com", "dashscope-intl.aliyuncs.com", "cn-hongkong.dashscope.aliyuncs.com"}
39
+ if (parsed.scheme != "https" or not (regional or legacy)
40
+ or port not in (None, 443) or parsed.query or parsed.fragment
41
+ or parsed.path.rstrip("/") != "/compatible-mode/v1"):
42
+ raise OSError("OKSTRA_QWEN_BASE_URL must be an HTTPS Model Studio /compatible-mode/v1 URL without credentials, query or fragment")
43
+ argv = [
44
+ "qwen", "--auth-type", "openai", "--openai-base-url", endpoint,
45
+ "--model", request.model, "--output-format", "stream-json",
46
+ ]
47
+ if request.policy.auto_approve:
48
+ argv += ["--approval-mode", "yolo"]
49
+ if request.session_id:
50
+ argv += ["--session-id", request.session_id]
51
+ for directory in request.policy.write_scope:
52
+ argv += ["--include-directories", str(directory)]
53
+ return ExecCommand(
54
+ argv=tuple(argv), stdin_text=request.prompt_text,
55
+ cwd=request.worktree_path or request.project_root,
56
+ environment={
57
+ "OPENAI_API_KEY": api_key, "OPENAI_MODEL": request.model,
58
+ "OKSTRA_QWEN_API_KEY": api_key, "OKSTRA_QWEN_ENDPOINT": endpoint,
59
+ "QWEN_CODE_SYSTEM_SETTINGS_PATH": str(Path(__file__).with_name("settings.json")),
60
+ },
61
+ presentation=JsonEvents(
62
+ normalise=content_block_events,
63
+ # Qwen Code copies config.getModel() into message.model.
64
+ observe=lambda _event: None,
65
+ observe_usage=observe_usage,
66
+ ),
67
+ )
68
+
69
+ def policy_support(self) -> PolicySupport:
70
+ return PolicySupport(
71
+ can_auto_approve=True, can_bound_write_scope=False,
72
+ note="Qwen Code approval mode does not enforce filesystem write boundaries",
73
+ )
74
+
75
+
76
+ def create_provider() -> ProviderSpec:
77
+ roles = frozenset(role.id for role in ROLE_DEFINITIONS if role.id != "leader")
78
+ return ProviderSpec(
79
+ provider="qwen", display_label="Qwen Code",
80
+ models={"qwen4-max": ModelSpec("qwen4-max", "Qwen4 Max", "qwen4-max")},
81
+ default_models={role: "qwen4-max" for role in roles},
82
+ wrapper="okstra-qwen-exec.sh", supported_roles=roles,
83
+ execution_capabilities=frozenset({
84
+ "worker-artifact-io", "source-readonly",
85
+ "extended-artifact-authoring", "project-mutation",
86
+ }),
87
+ exec_strategy=QwenExecution(),
88
+ )
@@ -0,0 +1 @@
1
+ {"schemaVersion": 1, "id": "qwen", "factory": "adapter.py:create_provider"}
@@ -0,0 +1,12 @@
1
+ {
2
+ "modelProviders": {
3
+ "openai": [
4
+ {
5
+ "id": "qwen4-max",
6
+ "envKey": "OKSTRA_QWEN_API_KEY",
7
+ "baseUrl": "${OKSTRA_QWEN_ENDPOINT}"
8
+ }
9
+ ]
10
+ },
11
+ "$version": 4
12
+ }
@@ -25,6 +25,8 @@ ZAI_MODELS = {
25
25
  for name, label, pricing in (
26
26
  ("glm-5.3", "GLM-5.3", (1.40, 0.26, 4.40)),
27
27
  ("glm-5.3-flash", "GLM-5.3 Flash", (0.15, 0.03, 0.50)),
28
+ ("glm-5.3-flashx", "GLM-5.3 FlashX", (0.37, 0.075, 1.25)),
29
+ ("glm-5.3-flashx-legal", "GLM-5.3 FlashX Legal", (0.37, 0.075, 1.25)),
28
30
  )
29
31
  }
30
32
 
@@ -88,10 +90,14 @@ class ZaiExecution:
88
90
  command = ClaudeExecution().build_command(
89
91
  replace(request, reasoning_effort="")
90
92
  )
93
+ argv = list(command.argv)
94
+ index = argv.index("--setting-sources")
95
+ # No setting source at all, so a settings file's env cannot override the
96
+ # child environment below.
97
+ argv[index + 1] = ""
91
98
  return replace(
92
99
  command,
93
- # 설정 파일의 env 가 자식 환경을 다시 덮어쓰지 않게 한다.
94
- argv=(*command.argv, "--setting-sources", ""),
100
+ argv=tuple(argv),
95
101
  environment={
96
102
  "ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
97
103
  "ANTHROPIC_AUTH_TOKEN": api_key,