magimoire 0.3.0__tar.gz
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.
- magimoire-0.3.0/LICENSE +21 -0
- magimoire-0.3.0/NOTICE +58 -0
- magimoire-0.3.0/PKG-INFO +112 -0
- magimoire-0.3.0/README.md +99 -0
- magimoire-0.3.0/pyproject.toml +49 -0
- magimoire-0.3.0/pyproject.toml.orig +45 -0
- magimoire-0.3.0/src/magimoire/__init__.py +272 -0
- magimoire-0.3.0/src/magimoire/acp/__init__.py +1 -0
- magimoire-0.3.0/src/magimoire/acp/codec.py +22 -0
- magimoire-0.3.0/src/magimoire/acp/mcp.py +164 -0
- magimoire-0.3.0/src/magimoire/acp/protocol.py +43 -0
- magimoire-0.3.0/src/magimoire/acp/server.py +608 -0
- magimoire-0.3.0/src/magimoire/acp/startup.py +97 -0
- magimoire-0.3.0/src/magimoire/agent/__init__.py +120 -0
- magimoire-0.3.0/src/magimoire/agent/agent_loop.py +1002 -0
- magimoire-0.3.0/src/magimoire/agent/archive_admission.py +38 -0
- magimoire-0.3.0/src/magimoire/agent/assistant_stream.py +160 -0
- magimoire-0.3.0/src/magimoire/agent/cancellation.py +235 -0
- magimoire-0.3.0/src/magimoire/agent/constants.py +7 -0
- magimoire-0.3.0/src/magimoire/agent/consumed_work.py +58 -0
- magimoire-0.3.0/src/magimoire/agent/contracts.py +257 -0
- magimoire-0.3.0/src/magimoire/agent/default_model.py +61 -0
- magimoire-0.3.0/src/magimoire/agent/dispatch.py +111 -0
- magimoire-0.3.0/src/magimoire/agent/inbox.py +248 -0
- magimoire-0.3.0/src/magimoire/agent/model_selection.py +261 -0
- magimoire-0.3.0/src/magimoire/agent/preset.py +258 -0
- magimoire-0.3.0/src/magimoire/agent/preset_projection.py +38 -0
- magimoire-0.3.0/src/magimoire/agent/projection.py +97 -0
- magimoire-0.3.0/src/magimoire/agent/react_loop.py +1027 -0
- magimoire-0.3.0/src/magimoire/agent/registry.py +423 -0
- magimoire-0.3.0/src/magimoire/agent/runtime_context.py +111 -0
- magimoire-0.3.0/src/magimoire/agent/system_prompt.py +89 -0
- magimoire-0.3.0/src/magimoire/agent_instructions/__init__.py +8 -0
- magimoire-0.3.0/src/magimoire/agent_instructions/config.py +122 -0
- magimoire-0.3.0/src/magimoire/agent_instructions/digest.py +18 -0
- magimoire-0.3.0/src/magimoire/agent_instructions/files.py +238 -0
- magimoire-0.3.0/src/magimoire/agent_instructions/render.py +271 -0
- magimoire-0.3.0/src/magimoire/agent_instructions/service.py +178 -0
- magimoire-0.3.0/src/magimoire/agent_instructions/state.py +153 -0
- magimoire-0.3.0/src/magimoire/approval/__init__.py +9 -0
- magimoire-0.3.0/src/magimoire/approval/guard.py +56 -0
- magimoire-0.3.0/src/magimoire/approval/service.py +244 -0
- magimoire-0.3.0/src/magimoire/attachments/__init__.py +1 -0
- magimoire-0.3.0/src/magimoire/attachments/service.py +143 -0
- magimoire-0.3.0/src/magimoire/cli.py +887 -0
- magimoire-0.3.0/src/magimoire/commands/__init__.py +20 -0
- magimoire-0.3.0/src/magimoire/commands/service.py +385 -0
- magimoire-0.3.0/src/magimoire/commands/types.py +130 -0
- magimoire-0.3.0/src/magimoire/compaction/__init__.py +5 -0
- magimoire-0.3.0/src/magimoire/compaction/image_offload.py +216 -0
- magimoire-0.3.0/src/magimoire/compaction/pruner.py +250 -0
- magimoire-0.3.0/src/magimoire/compaction/service.py +98 -0
- magimoire-0.3.0/src/magimoire/components/__init__.py +12 -0
- magimoire-0.3.0/src/magimoire/components/discovery.py +35 -0
- magimoire-0.3.0/src/magimoire/components/layers.py +124 -0
- magimoire-0.3.0/src/magimoire/components/manifest.py +38 -0
- magimoire-0.3.0/src/magimoire/components/service.py +228 -0
- magimoire-0.3.0/src/magimoire/context/__init__.py +5 -0
- magimoire-0.3.0/src/magimoire/context/service.py +76 -0
- magimoire-0.3.0/src/magimoire/context/settings.py +173 -0
- magimoire-0.3.0/src/magimoire/context/user_questions.py +398 -0
- magimoire-0.3.0/src/magimoire/credentials/__init__.py +35 -0
- magimoire-0.3.0/src/magimoire/credentials/engine.py +287 -0
- magimoire-0.3.0/src/magimoire/feedback/__init__.py +18 -0
- magimoire-0.3.0/src/magimoire/feedback/service.py +108 -0
- magimoire-0.3.0/src/magimoire/feedback/types.py +70 -0
- magimoire-0.3.0/src/magimoire/fs/__init__.py +88 -0
- magimoire-0.3.0/src/magimoire/fs/local.py +978 -0
- magimoire-0.3.0/src/magimoire/fs/observation_policy.py +161 -0
- magimoire-0.3.0/src/magimoire/fs/patch.py +422 -0
- magimoire-0.3.0/src/magimoire/fs/service.py +309 -0
- magimoire-0.3.0/src/magimoire/fs/types.py +185 -0
- magimoire-0.3.0/src/magimoire/fs/workspace_path.py +93 -0
- magimoire-0.3.0/src/magimoire/goal/__init__.py +33 -0
- magimoire-0.3.0/src/magimoire/goal/command.py +140 -0
- magimoire-0.3.0/src/magimoire/goal/projection.py +244 -0
- magimoire-0.3.0/src/magimoire/goal/round_driver.py +506 -0
- magimoire-0.3.0/src/magimoire/goal/service.py +470 -0
- magimoire-0.3.0/src/magimoire/goal/tools.py +489 -0
- magimoire-0.3.0/src/magimoire/goal/types.py +545 -0
- magimoire-0.3.0/src/magimoire/headless_json.py +250 -0
- magimoire-0.3.0/src/magimoire/jobs/__init__.py +76 -0
- magimoire-0.3.0/src/magimoire/jobs/archive_admission.py +63 -0
- magimoire-0.3.0/src/magimoire/jobs/events.py +112 -0
- magimoire-0.3.0/src/magimoire/jobs/local.py +756 -0
- magimoire-0.3.0/src/magimoire/jobs/pump.py +87 -0
- magimoire-0.3.0/src/magimoire/jobs/ring.py +116 -0
- magimoire-0.3.0/src/magimoire/jobs/service.py +84 -0
- magimoire-0.3.0/src/magimoire/jobs/types.py +244 -0
- magimoire-0.3.0/src/magimoire/llm/__init__.py +585 -0
- magimoire-0.3.0/src/magimoire/llm/adapter_failure.py +208 -0
- magimoire-0.3.0/src/magimoire/llm/api_key.py +40 -0
- magimoire-0.3.0/src/magimoire/llm/assembler.py +184 -0
- magimoire-0.3.0/src/magimoire/llm/assistant_stream.py +518 -0
- magimoire-0.3.0/src/magimoire/llm/attribution.py +35 -0
- magimoire-0.3.0/src/magimoire/llm/brand.py +20 -0
- magimoire-0.3.0/src/magimoire/llm/call_config.py +88 -0
- magimoire-0.3.0/src/magimoire/llm/conduit/__init__.py +5 -0
- magimoire-0.3.0/src/magimoire/llm/conduit/adapter.py +184 -0
- magimoire-0.3.0/src/magimoire/llm/conduit/catalog.py +404 -0
- magimoire-0.3.0/src/magimoire/llm/conduit/component.py +211 -0
- magimoire-0.3.0/src/magimoire/llm/conduit/config.py +203 -0
- magimoire-0.3.0/src/magimoire/llm/conduit/data/anthropic.json +1 -0
- magimoire-0.3.0/src/magimoire/llm/conduit/data/google.json +1 -0
- magimoire-0.3.0/src/magimoire/llm/conduit/data/groq.json +1 -0
- magimoire-0.3.0/src/magimoire/llm/conduit/data/openai.json +1 -0
- magimoire-0.3.0/src/magimoire/llm/conduit/data/opencode.json +1 -0
- magimoire-0.3.0/src/magimoire/llm/conduit/data/openrouter.json +1 -0
- magimoire-0.3.0/src/magimoire/llm/conduit/data/pollinations.json +35 -0
- magimoire-0.3.0/src/magimoire/llm/conduit/data/xai.json +1 -0
- magimoire-0.3.0/src/magimoire/llm/conduit/protocols/__init__.py +31 -0
- magimoire-0.3.0/src/magimoire/llm/conduit/protocols/anthropic_messages.py +274 -0
- magimoire-0.3.0/src/magimoire/llm/conduit/protocols/common.py +342 -0
- magimoire-0.3.0/src/magimoire/llm/conduit/protocols/google_generative_ai.py +271 -0
- magimoire-0.3.0/src/magimoire/llm/conduit/protocols/openai_completions.py +247 -0
- magimoire-0.3.0/src/magimoire/llm/conduit/protocols/openai_responses.py +289 -0
- magimoire-0.3.0/src/magimoire/llm/conduit/provider_data.py +236 -0
- magimoire-0.3.0/src/magimoire/llm/content.py +474 -0
- magimoire-0.3.0/src/magimoire/llm/error.py +207 -0
- magimoire-0.3.0/src/magimoire/llm/listing_cache.py +288 -0
- magimoire-0.3.0/src/magimoire/llm/listing_config.py +75 -0
- magimoire-0.3.0/src/magimoire/llm/message.py +146 -0
- magimoire-0.3.0/src/magimoire/llm/retry.py +519 -0
- magimoire-0.3.0/src/magimoire/llm/retry_policy.py +195 -0
- magimoire-0.3.0/src/magimoire/llm/scripted.py +112 -0
- magimoire-0.3.0/src/magimoire/llm/service.py +1819 -0
- magimoire-0.3.0/src/magimoire/llm/slug.py +37 -0
- magimoire-0.3.0/src/magimoire/llm/token_meter.py +1633 -0
- magimoire-0.3.0/src/magimoire/llm/types.py +346 -0
- magimoire-0.3.0/src/magimoire/llm/values.py +347 -0
- magimoire-0.3.0/src/magimoire/mcp/client.py +43 -0
- magimoire-0.3.0/src/magimoire/permission/__init__.py +27 -0
- magimoire-0.3.0/src/magimoire/permission/service.py +669 -0
- magimoire-0.3.0/src/magimoire/plan/__init__.py +8 -0
- magimoire-0.3.0/src/magimoire/plan/fold.py +72 -0
- magimoire-0.3.0/src/magimoire/plan/service.py +268 -0
- magimoire-0.3.0/src/magimoire/plan/tools.py +256 -0
- magimoire-0.3.0/src/magimoire/plan/types.py +76 -0
- magimoire-0.3.0/src/magimoire/profiles/__init__.py +5 -0
- magimoire-0.3.0/src/magimoire/profiles/base.yaml +309 -0
- magimoire-0.3.0/src/magimoire/profiles/launcher.py +317 -0
- magimoire-0.3.0/src/magimoire/profiles/merge.py +94 -0
- magimoire-0.3.0/src/magimoire/profiles/templates/acp/animas.patch.yaml +4 -0
- magimoire-0.3.0/src/magimoire/profiles/templates/acp/pyproject.toml +7 -0
- magimoire-0.3.0/src/magimoire/profiles/templates/base/animas.patch.yaml +1 -0
- magimoire-0.3.0/src/magimoire/profiles/templates/base/pyproject.toml +7 -0
- magimoire-0.3.0/src/magimoire/profiles/templates/headless/animas.patch.yaml +1 -0
- magimoire-0.3.0/src/magimoire/profiles/templates/headless/pyproject.toml +7 -0
- magimoire-0.3.0/src/magimoire/profiles/templates/sdk/animas.patch.yaml +17 -0
- magimoire-0.3.0/src/magimoire/profiles/templates/sdk/pyproject.toml +7 -0
- magimoire-0.3.0/src/magimoire/profiles/templates/sdk-minimal/animas.patch.yaml +227 -0
- magimoire-0.3.0/src/magimoire/profiles/templates/sdk-minimal/pyproject.toml +7 -0
- magimoire-0.3.0/src/magimoire/profiles/templates/web/animas.patch.yaml +11 -0
- magimoire-0.3.0/src/magimoire/profiles/templates/web/pyproject.toml +7 -0
- magimoire-0.3.0/src/magimoire/profiles/translate.py +290 -0
- magimoire-0.3.0/src/magimoire/ptc/__init__.py +1 -0
- magimoire-0.3.0/src/magimoire/ptc/protocol.py +39 -0
- magimoire-0.3.0/src/magimoire/ptc/run_code.py +156 -0
- magimoire-0.3.0/src/magimoire/ptc/runtime.py +415 -0
- magimoire-0.3.0/src/magimoire/ptc/worker.js +232 -0
- magimoire-0.3.0/src/magimoire/ptc/workflow.py +310 -0
- magimoire-0.3.0/src/magimoire/py.typed +0 -0
- magimoire-0.3.0/src/magimoire/remote/__init__.py +1 -0
- magimoire-0.3.0/src/magimoire/remote/controllers.py +1807 -0
- magimoire-0.3.0/src/magimoire/runtime/__init__.py +1 -0
- magimoire-0.3.0/src/magimoire/runtime/carrier.py +232 -0
- magimoire-0.3.0/src/magimoire/sandbox/escalation.py +180 -0
- magimoire-0.3.0/src/magimoire/sandbox/policy.py +249 -0
- magimoire-0.3.0/src/magimoire/sandbox/roots.py +67 -0
- magimoire-0.3.0/src/magimoire/sandbox/service.py +183 -0
- magimoire-0.3.0/src/magimoire/sandbox/types.py +116 -0
- magimoire-0.3.0/src/magimoire/schedule/__init__.py +35 -0
- magimoire-0.3.0/src/magimoire/schedule/engine.py +327 -0
- magimoire-0.3.0/src/magimoire/scope/__init__.py +64 -0
- magimoire-0.3.0/src/magimoire/scope/_core.py +458 -0
- magimoire-0.3.0/src/magimoire/scope/store.py +244 -0
- magimoire-0.3.0/src/magimoire/sdk/__init__.py +1 -0
- magimoire-0.3.0/src/magimoire/sdk/client.py +486 -0
- magimoire-0.3.0/src/magimoire/sdk/launch.py +91 -0
- magimoire-0.3.0/src/magimoire/sdk/process_events.py +140 -0
- magimoire-0.3.0/src/magimoire/sdk/protocol.py +483 -0
- magimoire-0.3.0/src/magimoire/sdk/query_activity.py +183 -0
- magimoire-0.3.0/src/magimoire/sdk/server.py +1079 -0
- magimoire-0.3.0/src/magimoire/session/__init__.py +215 -0
- magimoire-0.3.0/src/magimoire/session/checkpoint_policy.py +135 -0
- magimoire-0.3.0/src/magimoire/session/events.py +302 -0
- magimoire-0.3.0/src/magimoire/session/fork.py +34 -0
- magimoire-0.3.0/src/magimoire/session/format.py +5959 -0
- magimoire-0.3.0/src/magimoire/session/lists.py +105 -0
- magimoire-0.3.0/src/magimoire/session/messages.py +86 -0
- magimoire-0.3.0/src/magimoire/session/pairing.py +66 -0
- magimoire-0.3.0/src/magimoire/session/persistence.py +296 -0
- magimoire-0.3.0/src/magimoire/session/persistence_jsonl.py +1903 -0
- magimoire-0.3.0/src/magimoire/session/projection_cache.py +784 -0
- magimoire-0.3.0/src/magimoire/session/projection_registry.py +680 -0
- magimoire-0.3.0/src/magimoire/session/projections.py +799 -0
- magimoire-0.3.0/src/magimoire/session/repair.py +250 -0
- magimoire-0.3.0/src/magimoire/session/request_header.py +144 -0
- magimoire-0.3.0/src/magimoire/session/service.py +585 -0
- magimoire-0.3.0/src/magimoire/session/store.py +1477 -0
- magimoire-0.3.0/src/magimoire/session/surface.py +874 -0
- magimoire-0.3.0/src/magimoire/session/title.py +1031 -0
- magimoire-0.3.0/src/magimoire/session/title_first_prompt.py +326 -0
- magimoire-0.3.0/src/magimoire/session/tool_history.py +149 -0
- magimoire-0.3.0/src/magimoire/session/working_directory.py +260 -0
- magimoire-0.3.0/src/magimoire/session_query/__init__.py +90 -0
- magimoire-0.3.0/src/magimoire/session_query/engine.py +678 -0
- magimoire-0.3.0/src/magimoire/session_query/errors.py +183 -0
- magimoire-0.3.0/src/magimoire/session_query/extraction.py +142 -0
- magimoire-0.3.0/src/magimoire/session_query/filters.py +414 -0
- magimoire-0.3.0/src/magimoire/session_query/service.py +74 -0
- magimoire-0.3.0/src/magimoire/session_query/tracing.py +250 -0
- magimoire-0.3.0/src/magimoire/session_query/types.py +432 -0
- magimoire-0.3.0/src/magimoire/shell/__init__.py +76 -0
- magimoire-0.3.0/src/magimoire/shell/_subprocess_base.py +552 -0
- magimoire-0.3.0/src/magimoire/shell/bash_local.py +45 -0
- magimoire-0.3.0/src/magimoire/shell/bash_sandbox.py +117 -0
- magimoire-0.3.0/src/magimoire/shell/executor.py +90 -0
- magimoire-0.3.0/src/magimoire/shell/pwsh_local.py +129 -0
- magimoire-0.3.0/src/magimoire/shell/render.py +34 -0
- magimoire-0.3.0/src/magimoire/shell/service.py +165 -0
- magimoire-0.3.0/src/magimoire/shell/terminal.py +170 -0
- magimoire-0.3.0/src/magimoire/shell/types.py +160 -0
- magimoire-0.3.0/src/magimoire/shell_env/__init__.py +37 -0
- magimoire-0.3.0/src/magimoire/shell_env/service.py +271 -0
- magimoire-0.3.0/src/magimoire/spill/__init__.py +45 -0
- magimoire-0.3.0/src/magimoire/spill/local.py +103 -0
- magimoire-0.3.0/src/magimoire/spill/notice.py +106 -0
- magimoire-0.3.0/src/magimoire/spill/policy.py +291 -0
- magimoire-0.3.0/src/magimoire/spill/retention.py +93 -0
- magimoire-0.3.0/src/magimoire/spill/service.py +125 -0
- magimoire-0.3.0/src/magimoire/spill/store.py +119 -0
- magimoire-0.3.0/src/magimoire/subagent/__init__.py +31 -0
- magimoire-0.3.0/src/magimoire/subagent/manager.py +440 -0
- magimoire-0.3.0/src/magimoire/subagent/providers.py +103 -0
- magimoire-0.3.0/src/magimoire/subagent/service.py +526 -0
- magimoire-0.3.0/src/magimoire/subagent/tools.py +449 -0
- magimoire-0.3.0/src/magimoire/subagent/types.py +77 -0
- magimoire-0.3.0/src/magimoire/subprocess/__init__.py +107 -0
- magimoire-0.3.0/src/magimoire/subprocess/local.py +691 -0
- magimoire-0.3.0/src/magimoire/subprocess/output.py +188 -0
- magimoire-0.3.0/src/magimoire/subprocess/retention.py +320 -0
- magimoire-0.3.0/src/magimoire/subprocess/service.py +100 -0
- magimoire-0.3.0/src/magimoire/subprocess/types.py +163 -0
- magimoire-0.3.0/src/magimoire/system_prompt/__init__.py +67 -0
- magimoire-0.3.0/src/magimoire/system_prompt/service.py +856 -0
- magimoire-0.3.0/src/magimoire/team/__init__.py +8 -0
- magimoire-0.3.0/src/magimoire/team/fold.py +235 -0
- magimoire-0.3.0/src/magimoire/team/service.py +517 -0
- magimoire-0.3.0/src/magimoire/team/task_graph.py +97 -0
- magimoire-0.3.0/src/magimoire/team/tools.py +334 -0
- magimoire-0.3.0/src/magimoire/team/types.py +119 -0
- magimoire-0.3.0/src/magimoire/telemetry/__init__.py +32 -0
- magimoire-0.3.0/src/magimoire/telemetry/engine.py +193 -0
- magimoire-0.3.0/src/magimoire/tools/__init__.py +162 -0
- magimoire-0.3.0/src/magimoire/tools/bash_tool.py +242 -0
- magimoire-0.3.0/src/magimoire/tools/contracts.py +357 -0
- magimoire-0.3.0/src/magimoire/tools/fs.py +689 -0
- magimoire-0.3.0/src/magimoire/tools/fs_apply_patch.py +768 -0
- magimoire-0.3.0/src/magimoire/tools/fs_observations.py +274 -0
- magimoire-0.3.0/src/magimoire/tools/fs_presentation.py +917 -0
- magimoire-0.3.0/src/magimoire/tools/fs_search.py +302 -0
- magimoire-0.3.0/src/magimoire/tools/jobs.py +299 -0
- magimoire-0.3.0/src/magimoire/tools/json_schema.py +511 -0
- magimoire-0.3.0/src/magimoire/tools/native_executor.py +81 -0
- magimoire-0.3.0/src/magimoire/tools/path_guard.py +28 -0
- magimoire-0.3.0/src/magimoire/tools/pipeline.py +1323 -0
- magimoire-0.3.0/src/magimoire/tools/presentation.py +219 -0
- magimoire-0.3.0/src/magimoire/tools/pwsh_tool.py +296 -0
- magimoire-0.3.0/src/magimoire/tools/repeat_guard.py +143 -0
- magimoire-0.3.0/src/magimoire/tools/schema.py +559 -0
- magimoire-0.3.0/src/magimoire/tools/service.py +636 -0
- magimoire-0.3.0/src/magimoire/tools/timeout_guard.py +61 -0
- magimoire-0.3.0/src/magimoire/tools/todo.py +248 -0
- magimoire-0.3.0/src/magimoire/web/__init__.py +23 -0
- magimoire-0.3.0/src/magimoire/web/service.py +476 -0
- magimoire-0.3.0/src/magimoire/web/tools.py +266 -0
magimoire-0.3.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Magitech
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
magimoire-0.3.0/NOTICE
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
Magimoire — Python agent runtime by Magitech
|
|
2
|
+
=============================================
|
|
3
|
+
|
|
4
|
+
Magimoire is licensed under the MIT License by Magitech (see LICENSE). Portions of
|
|
5
|
+
its design, model catalog data and provider conventions derive from MIT-licensed
|
|
6
|
+
upstream projects. Their copyright and permission notices are reproduced below.
|
|
7
|
+
|
|
8
|
+
--------------------------------------------------------------------------
|
|
9
|
+
DeepSeek Harness — https://github.com/deepseek-ai/deepseek-harness
|
|
10
|
+
--------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
MIT License
|
|
13
|
+
|
|
14
|
+
Copyright (c) 2026 DeepSeek
|
|
15
|
+
|
|
16
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
17
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
18
|
+
in the Software without restriction, including without limitation the rights
|
|
19
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
20
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
21
|
+
furnished to do so, subject to the following conditions:
|
|
22
|
+
|
|
23
|
+
The above copyright notice and this permission notice shall be included in all
|
|
24
|
+
copies or substantial portions of the Software.
|
|
25
|
+
|
|
26
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
27
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
28
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
29
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
30
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
31
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
32
|
+
SOFTWARE.
|
|
33
|
+
|
|
34
|
+
--------------------------------------------------------------------------
|
|
35
|
+
Pi (@earendil-works/pi-ai) — https://github.com/earendil-works/pi
|
|
36
|
+
--------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
MIT License
|
|
39
|
+
|
|
40
|
+
Copyright (c) 2026 Earendil Inc.
|
|
41
|
+
|
|
42
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
43
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
44
|
+
in the Software without restriction, including without limitation the rights
|
|
45
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
46
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
47
|
+
furnished to do so, subject to the following conditions:
|
|
48
|
+
|
|
49
|
+
The above copyright notice and this permission notice shall be included in all
|
|
50
|
+
copies or substantial portions of the Software.
|
|
51
|
+
|
|
52
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
53
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
54
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
55
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
56
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
57
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
58
|
+
SOFTWARE.
|
magimoire-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: magimoire
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Magimoire: Composable Agent Runtime by Magitech
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
License-File: NOTICE
|
|
7
|
+
Requires-Dist: animas>=2.1,<3
|
|
8
|
+
Requires-Dist: httpx>=0.27.0
|
|
9
|
+
Requires-Dist: pydantic>=2.14.3
|
|
10
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
11
|
+
Requires-Python: >=3.12
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<picture>
|
|
16
|
+
<source
|
|
17
|
+
media="(prefers-color-scheme: dark)"
|
|
18
|
+
srcset="https://raw.githubusercontent.com/magitech-ai/.github/main/brand/collateral/readme-banner-dark.svg"
|
|
19
|
+
/>
|
|
20
|
+
<source
|
|
21
|
+
media="(prefers-color-scheme: light)"
|
|
22
|
+
srcset="https://raw.githubusercontent.com/magitech-ai/.github/main/brand/collateral/readme-banner-light.svg"
|
|
23
|
+
/>
|
|
24
|
+
<img
|
|
25
|
+
alt="Magitech"
|
|
26
|
+
src="https://raw.githubusercontent.com/magitech-ai/.github/main/brand/collateral/readme-banner-light.svg"
|
|
27
|
+
width="100%"
|
|
28
|
+
/>
|
|
29
|
+
</picture>
|
|
30
|
+
</p>
|
|
31
|
+
|
|
32
|
+
# Magimoire (`magi`)
|
|
33
|
+
|
|
34
|
+
The composable autonomous agent runtime powering **Magitech**.
|
|
35
|
+
|
|
36
|
+
Built directly on top of **`animas`** ([`https://github.com/magitech-ai/animas`](https://github.com/magitech-ai/animas)), the micro-kernel.
|
|
37
|
+
|
|
38
|
+
[](tests/)
|
|
39
|
+
[](pyproject.toml)
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Architecture Overview
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
┌─────────────────────────┐
|
|
47
|
+
│ Animas Context │
|
|
48
|
+
└────────────┬────────────┘
|
|
49
|
+
┌───────────────┬───────┴───────┬───────────────┐
|
|
50
|
+
▼ ▼ ▼ ▼
|
|
51
|
+
ctx.sessions ctx.tools ctx.llm ctx.agent_loop
|
|
52
|
+
(Event-Sourced (Waterfall Tool (Streaming (Multi-Step
|
|
53
|
+
JSONL Log) Pipeline) Seam) State Machine)
|
|
54
|
+
│ │ │ │
|
|
55
|
+
└───────────────┴───────┬───────┴───────────────┘
|
|
56
|
+
▼
|
|
57
|
+
ctx.system_prompt / ctx.shell
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### The base bundle
|
|
61
|
+
|
|
62
|
+
The default composition ([`profiles/base.yaml`](src/magimoire/profiles/base.yaml))
|
|
63
|
+
mounts the reference's shared base: sessions and persistence, prompt assembly, the
|
|
64
|
+
tool registry and pipeline, model streaming and retry, filesystem and shell,
|
|
65
|
+
jobs, compaction, approvals, goals, and the base tool set (`bash`, `read_file`,
|
|
66
|
+
`write_file`, `edit_file`, `glob`, `grep`, `job_list`, `job_output`, `job_kill`,
|
|
67
|
+
`todo_write`, `get_goal`, `create_goal`, `update_goal`). Optional, on-demand, and
|
|
68
|
+
third-party capabilities live in
|
|
69
|
+
[`mth-components`](https://github.com/magitech-ai/mth-components).
|
|
70
|
+
|
|
71
|
+
Ownership and per-row evidence against the pinned reference (dsh
|
|
72
|
+
`4b399c39`, v0.2.3-alpha.2) are in [PARITY.md](PARITY.md); the decision is
|
|
73
|
+
[ADR 0022](docs/adr/0022-supersede-zero-builtin-domain-tools-base-bundle-in-harness.md).
|
|
74
|
+
|
|
75
|
+
### The 6 Core Capability Seams
|
|
76
|
+
* **`ctx.sessions`**: Append-only event log (`turn/*`, `step/*`, `user/message`, `assistant/message`, `tool/*`). Follows the principle: **Model-visible ⟺ Logged**.
|
|
77
|
+
* **`derive_messages()`**: Deterministic projection reconstructing conversation history from session logs.
|
|
78
|
+
* **`ctx.tools`**: Scoped tool registry + guarded waterfall pipeline (`tools/pre-execute` ➔ execute ➔ `tools/post-execute`).
|
|
79
|
+
* **`ctx.system_prompt`**: Modular section assembly.
|
|
80
|
+
* **`ctx.llm`**: Pluggable provider seam with built-in mock and async streaming hooks.
|
|
81
|
+
* **`ctx.agent_loop`**: Full multi-step agent driver handling tool execution cycles.
|
|
82
|
+
* **`ctx.shell`**: Local async shell execution provider.
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Quickstart
|
|
87
|
+
|
|
88
|
+
### Prerequisites
|
|
89
|
+
* Python 3.12+ (tested with `uv`)
|
|
90
|
+
* The `animas` micro-kernel at `../animas` (or added with `uv add animas`)
|
|
91
|
+
|
|
92
|
+
### Running the Test Suite
|
|
93
|
+
`magimoire` maintains strict **100% statement and 100% branch test coverage**:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
cd magimoire
|
|
97
|
+
|
|
98
|
+
# Run all unit and integration tests with coverage enforcement
|
|
99
|
+
uv run pytest
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Running the CLI
|
|
103
|
+
```bash
|
|
104
|
+
# Execute an agent turn using the magi CLI
|
|
105
|
+
uv run magi run "Calculate 15 * 8"
|
|
106
|
+
```
|
|
107
|
+
*(Session event logs persist to `.sessions/<session-id>.jsonl`)*
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## License
|
|
112
|
+
MIT
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source
|
|
4
|
+
media="(prefers-color-scheme: dark)"
|
|
5
|
+
srcset="https://raw.githubusercontent.com/magitech-ai/.github/main/brand/collateral/readme-banner-dark.svg"
|
|
6
|
+
/>
|
|
7
|
+
<source
|
|
8
|
+
media="(prefers-color-scheme: light)"
|
|
9
|
+
srcset="https://raw.githubusercontent.com/magitech-ai/.github/main/brand/collateral/readme-banner-light.svg"
|
|
10
|
+
/>
|
|
11
|
+
<img
|
|
12
|
+
alt="Magitech"
|
|
13
|
+
src="https://raw.githubusercontent.com/magitech-ai/.github/main/brand/collateral/readme-banner-light.svg"
|
|
14
|
+
width="100%"
|
|
15
|
+
/>
|
|
16
|
+
</picture>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
# Magimoire (`magi`)
|
|
20
|
+
|
|
21
|
+
The composable autonomous agent runtime powering **Magitech**.
|
|
22
|
+
|
|
23
|
+
Built directly on top of **`animas`** ([`https://github.com/magitech-ai/animas`](https://github.com/magitech-ai/animas)), the micro-kernel.
|
|
24
|
+
|
|
25
|
+
[](tests/)
|
|
26
|
+
[](pyproject.toml)
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Architecture Overview
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
┌─────────────────────────┐
|
|
34
|
+
│ Animas Context │
|
|
35
|
+
└────────────┬────────────┘
|
|
36
|
+
┌───────────────┬───────┴───────┬───────────────┐
|
|
37
|
+
▼ ▼ ▼ ▼
|
|
38
|
+
ctx.sessions ctx.tools ctx.llm ctx.agent_loop
|
|
39
|
+
(Event-Sourced (Waterfall Tool (Streaming (Multi-Step
|
|
40
|
+
JSONL Log) Pipeline) Seam) State Machine)
|
|
41
|
+
│ │ │ │
|
|
42
|
+
└───────────────┴───────┬───────┴───────────────┘
|
|
43
|
+
▼
|
|
44
|
+
ctx.system_prompt / ctx.shell
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### The base bundle
|
|
48
|
+
|
|
49
|
+
The default composition ([`profiles/base.yaml`](src/magimoire/profiles/base.yaml))
|
|
50
|
+
mounts the reference's shared base: sessions and persistence, prompt assembly, the
|
|
51
|
+
tool registry and pipeline, model streaming and retry, filesystem and shell,
|
|
52
|
+
jobs, compaction, approvals, goals, and the base tool set (`bash`, `read_file`,
|
|
53
|
+
`write_file`, `edit_file`, `glob`, `grep`, `job_list`, `job_output`, `job_kill`,
|
|
54
|
+
`todo_write`, `get_goal`, `create_goal`, `update_goal`). Optional, on-demand, and
|
|
55
|
+
third-party capabilities live in
|
|
56
|
+
[`mth-components`](https://github.com/magitech-ai/mth-components).
|
|
57
|
+
|
|
58
|
+
Ownership and per-row evidence against the pinned reference (dsh
|
|
59
|
+
`4b399c39`, v0.2.3-alpha.2) are in [PARITY.md](PARITY.md); the decision is
|
|
60
|
+
[ADR 0022](docs/adr/0022-supersede-zero-builtin-domain-tools-base-bundle-in-harness.md).
|
|
61
|
+
|
|
62
|
+
### The 6 Core Capability Seams
|
|
63
|
+
* **`ctx.sessions`**: Append-only event log (`turn/*`, `step/*`, `user/message`, `assistant/message`, `tool/*`). Follows the principle: **Model-visible ⟺ Logged**.
|
|
64
|
+
* **`derive_messages()`**: Deterministic projection reconstructing conversation history from session logs.
|
|
65
|
+
* **`ctx.tools`**: Scoped tool registry + guarded waterfall pipeline (`tools/pre-execute` ➔ execute ➔ `tools/post-execute`).
|
|
66
|
+
* **`ctx.system_prompt`**: Modular section assembly.
|
|
67
|
+
* **`ctx.llm`**: Pluggable provider seam with built-in mock and async streaming hooks.
|
|
68
|
+
* **`ctx.agent_loop`**: Full multi-step agent driver handling tool execution cycles.
|
|
69
|
+
* **`ctx.shell`**: Local async shell execution provider.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Quickstart
|
|
74
|
+
|
|
75
|
+
### Prerequisites
|
|
76
|
+
* Python 3.12+ (tested with `uv`)
|
|
77
|
+
* The `animas` micro-kernel at `../animas` (or added with `uv add animas`)
|
|
78
|
+
|
|
79
|
+
### Running the Test Suite
|
|
80
|
+
`magimoire` maintains strict **100% statement and 100% branch test coverage**:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
cd magimoire
|
|
84
|
+
|
|
85
|
+
# Run all unit and integration tests with coverage enforcement
|
|
86
|
+
uv run pytest
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Running the CLI
|
|
90
|
+
```bash
|
|
91
|
+
# Execute an agent turn using the magi CLI
|
|
92
|
+
uv run magi run "Calculate 15 * 8"
|
|
93
|
+
```
|
|
94
|
+
*(Session event logs persist to `.sessions/<session-id>.jsonl`)*
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## License
|
|
99
|
+
MIT
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "magimoire"
|
|
3
|
+
version = "0.3.0"
|
|
4
|
+
description = "Magimoire: Composable Agent Runtime by Magitech"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license-files = [
|
|
7
|
+
"LICENSE",
|
|
8
|
+
"NOTICE",
|
|
9
|
+
]
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"animas>=2.1,<3",
|
|
13
|
+
"httpx>=0.27.0",
|
|
14
|
+
"pydantic>=2.14.3",
|
|
15
|
+
"pyyaml>=6.0.3",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.scripts]
|
|
19
|
+
magi = "magimoire.cli:main"
|
|
20
|
+
magi-runtime = "magimoire.runtime.carrier:main"
|
|
21
|
+
|
|
22
|
+
[tool.uv.sources.animas]
|
|
23
|
+
path = "../animas"
|
|
24
|
+
editable = true
|
|
25
|
+
|
|
26
|
+
[tool.pytest.ini_options]
|
|
27
|
+
asyncio_mode = "auto"
|
|
28
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
29
|
+
addopts = "--import-mode=importlib --cov=magimoire --cov-branch --cov-report=term-missing --cov-fail-under=100"
|
|
30
|
+
|
|
31
|
+
[tool.mypy]
|
|
32
|
+
python_version = "3.12"
|
|
33
|
+
warn_return_any = true
|
|
34
|
+
warn_unused_configs = true
|
|
35
|
+
disallow_untyped_defs = true
|
|
36
|
+
|
|
37
|
+
[build-system]
|
|
38
|
+
requires = ["uv_build>=0.13.7,<0.14.0"]
|
|
39
|
+
build-backend = "uv_build"
|
|
40
|
+
|
|
41
|
+
[dependency-groups]
|
|
42
|
+
dev = [
|
|
43
|
+
"mypy>=1.15.0",
|
|
44
|
+
"pytest>=9.2.0",
|
|
45
|
+
"pytest-asyncio>=1.4.1.post1",
|
|
46
|
+
"pytest-cov>=7.1.0",
|
|
47
|
+
"ruff>=0.17.4",
|
|
48
|
+
"types-pyyaml>=6.0.12",
|
|
49
|
+
]
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "magimoire"
|
|
3
|
+
version = "0.3.0"
|
|
4
|
+
description = "Magimoire: Composable Agent Runtime by Magitech"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license-files = ["LICENSE", "NOTICE"]
|
|
7
|
+
requires-python = ">=3.12"
|
|
8
|
+
dependencies = [
|
|
9
|
+
"animas>=2.1,<3",
|
|
10
|
+
"httpx>=0.27.0",
|
|
11
|
+
"pydantic>=2.14.3",
|
|
12
|
+
"pyyaml>=6.0.3",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[project.scripts]
|
|
16
|
+
magi = "magimoire.cli:main"
|
|
17
|
+
magi-runtime = "magimoire.runtime.carrier:main"
|
|
18
|
+
|
|
19
|
+
[tool.uv.sources]
|
|
20
|
+
animas = { path = "../animas", editable = true }
|
|
21
|
+
|
|
22
|
+
[build-system]
|
|
23
|
+
requires = ["uv_build>=0.13.7,<0.14.0"]
|
|
24
|
+
build-backend = "uv_build"
|
|
25
|
+
|
|
26
|
+
[dependency-groups]
|
|
27
|
+
dev = [
|
|
28
|
+
"mypy>=1.15.0",
|
|
29
|
+
"pytest>=9.2.0",
|
|
30
|
+
"pytest-asyncio>=1.4.1.post1",
|
|
31
|
+
"pytest-cov>=7.1.0",
|
|
32
|
+
"ruff>=0.17.4",
|
|
33
|
+
"types-pyyaml>=6.0.12",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[tool.pytest.ini_options]
|
|
37
|
+
asyncio_mode = "auto"
|
|
38
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
39
|
+
addopts = "--import-mode=importlib --cov=magimoire --cov-branch --cov-report=term-missing --cov-fail-under=100"
|
|
40
|
+
|
|
41
|
+
[tool.mypy]
|
|
42
|
+
python_version = "3.12"
|
|
43
|
+
warn_return_any = true
|
|
44
|
+
warn_unused_configs = true
|
|
45
|
+
disallow_untyped_defs = true
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
"""Magimoire: Composable Agent Runtime by Magitech."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__version__ = "0.3.0"
|
|
6
|
+
|
|
7
|
+
import asyncio
|
|
8
|
+
import os
|
|
9
|
+
from collections.abc import Callable, Sequence
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
from animas import Context, FiberState
|
|
14
|
+
from animas.loader import LoaderService
|
|
15
|
+
from animas.profile_yaml import load_yaml
|
|
16
|
+
|
|
17
|
+
from magimoire.agent.agent_loop import AgentLoop, FactoryOwnership
|
|
18
|
+
from magimoire.agent.assistant_stream import AssistantStreamAttempt
|
|
19
|
+
from magimoire.agent.cancellation import AbortController, AbortError, AbortSignal
|
|
20
|
+
from magimoire.agent.constants import DEFAULT_MAX_PARALLEL_TOOL_CALLS
|
|
21
|
+
from magimoire.agent.react_loop import ReactLoopAgent
|
|
22
|
+
from magimoire.agent.registry import AgentRegistry
|
|
23
|
+
from magimoire.agent.runtime_context import RuntimeContextProjection
|
|
24
|
+
from magimoire.approval.service import (
|
|
25
|
+
ApprovalRequest,
|
|
26
|
+
ApprovalService,
|
|
27
|
+
calculate_argument_digest,
|
|
28
|
+
)
|
|
29
|
+
from magimoire.compaction.service import CompactionService
|
|
30
|
+
from magimoire.components.layers import ConfigLayer, LayerResolutionService
|
|
31
|
+
from magimoire.components.manifest import ComponentManifest
|
|
32
|
+
from magimoire.components.service import ComponentService
|
|
33
|
+
from magimoire.context.service import ContextService
|
|
34
|
+
from magimoire.fs.local import LocalFileSystem
|
|
35
|
+
from magimoire.fs.service import FileSystem
|
|
36
|
+
from magimoire.jobs.local import LocalJobRegistry
|
|
37
|
+
from magimoire.jobs.service import JobRegistry
|
|
38
|
+
from magimoire.llm.service import (
|
|
39
|
+
LLMProvider,
|
|
40
|
+
LLMService,
|
|
41
|
+
MockLLMProvider,
|
|
42
|
+
NoProviderError,
|
|
43
|
+
)
|
|
44
|
+
from magimoire.llm.slug import parse_model_slug
|
|
45
|
+
from magimoire.llm.types import ModelChunk, ModelResponse, UsageData
|
|
46
|
+
from magimoire.profiles.launcher import is_standalone
|
|
47
|
+
from magimoire.profiles.merge import merge_bundle_rows, profile_rows_from_source
|
|
48
|
+
from magimoire.session.events import (
|
|
49
|
+
EventType,
|
|
50
|
+
SessionEvent,
|
|
51
|
+
ToolCallData,
|
|
52
|
+
ToolResultData,
|
|
53
|
+
)
|
|
54
|
+
from magimoire.session.pairing import is_tool_pairing_balanced
|
|
55
|
+
from magimoire.session.service import SessionService
|
|
56
|
+
from magimoire.session.store import Session, derive_messages
|
|
57
|
+
from magimoire.session.working_directory import WorkingDirectoryService
|
|
58
|
+
from magimoire.shell.bash_local import LocalBashExecutor
|
|
59
|
+
from magimoire.shell.executor import ShellExecutor
|
|
60
|
+
from magimoire.shell.pwsh_local import LocalPwshExecutor
|
|
61
|
+
from magimoire.shell.service import LocalShellService, ShellResult
|
|
62
|
+
from magimoire.shell_env.service import ShellEnvRegistry
|
|
63
|
+
from magimoire.subprocess.local import LocalSubprocessRuntime
|
|
64
|
+
from magimoire.subprocess.service import SubprocessRuntime
|
|
65
|
+
from magimoire.system_prompt.service import SystemPromptService
|
|
66
|
+
from magimoire.tools.native_executor import NativeToolExecutor
|
|
67
|
+
from magimoire.tools.pipeline import ToolExecutionPipeline
|
|
68
|
+
from magimoire.tools.schema import define_tool
|
|
69
|
+
from magimoire.tools.service import ToolRuntime, ToolService, ToolsService
|
|
70
|
+
|
|
71
|
+
_BASE_BUNDLE_PATH = Path(__file__).resolve().parent / "profiles" / "base.yaml"
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _check_bundle_entries(loader: LoaderService) -> None:
|
|
75
|
+
"""Fail loud if any enabled bundle row did not mount.
|
|
76
|
+
|
|
77
|
+
A row that fails to mount never raises through load or flush: the
|
|
78
|
+
failure is visible only on the entry fiber's state, so it is
|
|
79
|
+
checked here. Zero entries (e.g. auditing before flushing a running
|
|
80
|
+
event loop) also fails loud instead of passing vacuously. Disabled
|
|
81
|
+
rows are intentionally unmounted and skipped.
|
|
82
|
+
"""
|
|
83
|
+
entries = list(loader.entries())
|
|
84
|
+
if not entries:
|
|
85
|
+
raise RuntimeError("default bundle failed to mount: no bundle entries loaded")
|
|
86
|
+
problems: list[str] = []
|
|
87
|
+
for entry in entries:
|
|
88
|
+
if entry.disabled:
|
|
89
|
+
continue
|
|
90
|
+
fiber = entry.fiber
|
|
91
|
+
if fiber is None:
|
|
92
|
+
problems.append(f"{entry.id}: no fiber mounted")
|
|
93
|
+
elif fiber.state is not FiberState.ACTIVE:
|
|
94
|
+
detail = f": {fiber.error}" if fiber.error is not None else ""
|
|
95
|
+
problems.append(f"{entry.id}: fiber {fiber.state.value}{detail}")
|
|
96
|
+
if problems:
|
|
97
|
+
raise RuntimeError("default bundle failed to mount: " + "; ".join(problems))
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def check_bundle_entries(ctx: Context) -> None:
|
|
101
|
+
"""Fail loud if any enabled default-bundle row did not activate.
|
|
102
|
+
|
|
103
|
+
Call after the bundle rows have settled -- after ``ctx.flush()`` when
|
|
104
|
+
a loop is running, as the CLI does after its own flush. The loader is
|
|
105
|
+
reachable from the context: loading the bundle registers it under
|
|
106
|
+
``loader``, and its entries carry the per-row fiber states.
|
|
107
|
+
"""
|
|
108
|
+
loader = ctx.get("loader", None, strict=False)
|
|
109
|
+
if not isinstance(loader, LoaderService):
|
|
110
|
+
raise TypeError("default bundle failed to mount: no loader on context")
|
|
111
|
+
_check_bundle_entries(loader)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def _settle_default_bundle(ctx: Context, loader: LoaderService) -> None:
|
|
115
|
+
"""Settle the default bundle rows and fail loud on any row that did not mount.
|
|
116
|
+
|
|
117
|
+
With no running event loop the rows settle here, so the returned
|
|
118
|
+
context has every bundle slot and the fiber check runs. With a running
|
|
119
|
+
loop the rows settle on the caller's flush, following the loader's
|
|
120
|
+
established load/flush contract; the caller then runs
|
|
121
|
+
:func:`check_bundle_entries` after that flush.
|
|
122
|
+
"""
|
|
123
|
+
try:
|
|
124
|
+
asyncio.get_running_loop()
|
|
125
|
+
except RuntimeError:
|
|
126
|
+
asyncio.run(ctx.flush())
|
|
127
|
+
_check_bundle_entries(loader)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def create_harness(
|
|
131
|
+
storage_dir: Path | str | None = None,
|
|
132
|
+
*,
|
|
133
|
+
profile: Path | str | list[Any] | dict[str, Any] | None = None,
|
|
134
|
+
prepare: Callable[[Context], None] | None = None,
|
|
135
|
+
patches: Sequence[Path | str | list[Any] | dict[str, Any]] | None = None,
|
|
136
|
+
) -> Context:
|
|
137
|
+
"""Factory creating a standard Context populated with core Harness services.
|
|
138
|
+
|
|
139
|
+
Every service mounts from the default bundle file: the six leaf
|
|
140
|
+
services (system prompt, tools, LLM, shell, approvals, layers),
|
|
141
|
+
components, sessions, the session internals, the agent loop, and
|
|
142
|
+
the first-prompt title provider. The sessions row reads its
|
|
143
|
+
storage dir from ``MAGITECH_SESSIONS_DIR`` in the environment
|
|
144
|
+
passed to the loader: ``storage_dir`` sets it, and
|
|
145
|
+
``storage_dir=None`` removes it, so an ambient value cannot turn a
|
|
146
|
+
memory-only boot into a persisted one. The persistence and
|
|
147
|
+
projection-cache rows read the same variable for their roots.
|
|
148
|
+
|
|
149
|
+
The optional ``prepare`` hook runs after the loader installs and
|
|
150
|
+
before the bundle loads: no bundle slot is reachable inside it, and
|
|
151
|
+
no direct mount has happened yet. With no running loop the rows
|
|
152
|
+
settle inside this call and a row that did not mount raises here;
|
|
153
|
+
with a running loop the rows settle on the caller's flush and the
|
|
154
|
+
caller fails loud by running :func:`check_bundle_entries` after it.
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
storage_dir: Optional base directory to persist session JSONL files.
|
|
158
|
+
profile: Optional profile overlay applied after the base bundle.
|
|
159
|
+
patches: Extra overlay sources applied after the profile, in order.
|
|
160
|
+
prepare: Optional host setup called with the context after the
|
|
161
|
+
loader installs and before the bundle loads, so before any
|
|
162
|
+
row activates.
|
|
163
|
+
|
|
164
|
+
Returns:
|
|
165
|
+
A configured Context instance.
|
|
166
|
+
"""
|
|
167
|
+
ctx = Context()
|
|
168
|
+
|
|
169
|
+
base_path = Path(storage_dir) if storage_dir else None
|
|
170
|
+
|
|
171
|
+
# The sessions row reads its storage dir from the environment: the
|
|
172
|
+
# loader interpolates ${MAGITECH_SESSIONS_DIR} from the mapping
|
|
173
|
+
# passed here, which replaces os.environ as the interpolation
|
|
174
|
+
# source for the bundle. A missing storage dir removes the
|
|
175
|
+
# variable, so an ambient value cannot persist a memory-only boot.
|
|
176
|
+
env = dict(os.environ)
|
|
177
|
+
if base_path is not None:
|
|
178
|
+
env["MAGITECH_SESSIONS_DIR"] = str(base_path)
|
|
179
|
+
else:
|
|
180
|
+
env.pop("MAGITECH_SESSIONS_DIR", None)
|
|
181
|
+
|
|
182
|
+
# Mount the default bundle rows. The loader installs here; the
|
|
183
|
+
# bundle loads after prepare, so the hook runs before any row
|
|
184
|
+
# activates on either the sync or the loop path. No service mounts
|
|
185
|
+
# directly: the kernel is the bare context, the loader, and the
|
|
186
|
+
# bundle.
|
|
187
|
+
loader = LoaderService(ctx, {"filename": _BASE_BUNDLE_PATH})
|
|
188
|
+
if prepare is not None:
|
|
189
|
+
prepare(ctx)
|
|
190
|
+
with open(_BASE_BUNDLE_PATH, encoding="utf-8") as base_stream:
|
|
191
|
+
base_rows = load_yaml(base_stream)
|
|
192
|
+
if profile is not None:
|
|
193
|
+
profile_rows = profile_rows_from_source(profile)
|
|
194
|
+
if is_standalone(profile_rows):
|
|
195
|
+
base_rows = []
|
|
196
|
+
base_rows = merge_bundle_rows(
|
|
197
|
+
base_rows,
|
|
198
|
+
[
|
|
199
|
+
row
|
|
200
|
+
for row in profile_rows
|
|
201
|
+
if not (isinstance(row, dict) and row.get("id") == "__standalone__")
|
|
202
|
+
],
|
|
203
|
+
)
|
|
204
|
+
# Extra patch overlays apply after the profile, in argv order: the
|
|
205
|
+
# default bundle -> profile -> --patch layers resolve deterministically.
|
|
206
|
+
for patch in patches or ():
|
|
207
|
+
base_rows = merge_bundle_rows(base_rows, profile_rows_from_source(patch))
|
|
208
|
+
loader.load(base_rows, env=env)
|
|
209
|
+
_settle_default_bundle(ctx, loader)
|
|
210
|
+
|
|
211
|
+
return ctx
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
__all__ = [
|
|
215
|
+
"DEFAULT_MAX_PARALLEL_TOOL_CALLS",
|
|
216
|
+
"AbortController",
|
|
217
|
+
"AbortError",
|
|
218
|
+
"AbortSignal",
|
|
219
|
+
"AgentLoop",
|
|
220
|
+
"AgentRegistry",
|
|
221
|
+
"ApprovalRequest",
|
|
222
|
+
"ApprovalService",
|
|
223
|
+
"AssistantStreamAttempt",
|
|
224
|
+
"CompactionService",
|
|
225
|
+
"ComponentManifest",
|
|
226
|
+
"ComponentService",
|
|
227
|
+
"ConfigLayer",
|
|
228
|
+
"ContextService",
|
|
229
|
+
"EventType",
|
|
230
|
+
"FactoryOwnership",
|
|
231
|
+
"FileSystem",
|
|
232
|
+
"JobRegistry",
|
|
233
|
+
"LLMProvider",
|
|
234
|
+
"LLMService",
|
|
235
|
+
"LayerResolutionService",
|
|
236
|
+
"LocalBashExecutor",
|
|
237
|
+
"LocalFileSystem",
|
|
238
|
+
"LocalJobRegistry",
|
|
239
|
+
"LocalPwshExecutor",
|
|
240
|
+
"LocalShellService",
|
|
241
|
+
"LocalSubprocessRuntime",
|
|
242
|
+
"MockLLMProvider",
|
|
243
|
+
"ModelChunk",
|
|
244
|
+
"ModelResponse",
|
|
245
|
+
"NativeToolExecutor",
|
|
246
|
+
"NoProviderError",
|
|
247
|
+
"ReactLoopAgent",
|
|
248
|
+
"RuntimeContextProjection",
|
|
249
|
+
"Session",
|
|
250
|
+
"SessionEvent",
|
|
251
|
+
"SessionService",
|
|
252
|
+
"ShellEnvRegistry",
|
|
253
|
+
"ShellExecutor",
|
|
254
|
+
"ShellResult",
|
|
255
|
+
"SubprocessRuntime",
|
|
256
|
+
"SystemPromptService",
|
|
257
|
+
"ToolCallData",
|
|
258
|
+
"ToolExecutionPipeline",
|
|
259
|
+
"ToolResultData",
|
|
260
|
+
"ToolRuntime",
|
|
261
|
+
"ToolService",
|
|
262
|
+
"ToolsService",
|
|
263
|
+
"UsageData",
|
|
264
|
+
"WorkingDirectoryService",
|
|
265
|
+
"calculate_argument_digest",
|
|
266
|
+
"check_bundle_entries",
|
|
267
|
+
"create_harness",
|
|
268
|
+
"define_tool",
|
|
269
|
+
"derive_messages",
|
|
270
|
+
"is_tool_pairing_balanced",
|
|
271
|
+
"parse_model_slug",
|
|
272
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Automation-only Agent Client Protocol surface."""
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""Pure turn-ending to ACP stop-reason mapping."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
_STOP_REASONS = {
|
|
8
|
+
"completed": "end_turn",
|
|
9
|
+
"max-tokens": "max_tokens",
|
|
10
|
+
"aborted": "end_turn",
|
|
11
|
+
"interrupted": "cancelled",
|
|
12
|
+
"blocked": "end_turn",
|
|
13
|
+
"error": "end_turn",
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def turn_end_to_stop_reason(reason: Any) -> str:
|
|
18
|
+
"""Map one committed harness turn reason to the ACP stop-reason vocabulary."""
|
|
19
|
+
kind = reason.get("kind") if isinstance(reason, dict) else None
|
|
20
|
+
if not isinstance(kind, str):
|
|
21
|
+
return "end_turn"
|
|
22
|
+
return _STOP_REASONS.get(kind, "end_turn")
|