tradingcodex 0.1.0__py3-none-any.whl
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.
- apps/__init__.py +1 -0
- apps/audit/__init__.py +1 -0
- apps/audit/admin.py +6 -0
- apps/audit/apps.py +8 -0
- apps/audit/migrations/0001_initial.py +35 -0
- apps/audit/migrations/__init__.py +0 -0
- apps/audit/models.py +22 -0
- apps/harness/__init__.py +1 -0
- apps/harness/admin.py +6 -0
- apps/harness/apps.py +8 -0
- apps/harness/migrations/0001_initial.py +35 -0
- apps/harness/migrations/__init__.py +0 -0
- apps/harness/models.py +22 -0
- apps/harness/templatetags/__init__.py +1 -0
- apps/integrations/__init__.py +1 -0
- apps/integrations/admin.py +6 -0
- apps/integrations/apps.py +8 -0
- apps/integrations/migrations/0001_initial.py +29 -0
- apps/integrations/migrations/__init__.py +0 -0
- apps/integrations/models.py +16 -0
- apps/integrations/services.py +31 -0
- apps/mcp/__init__.py +1 -0
- apps/mcp/admin.py +20 -0
- apps/mcp/apps.py +8 -0
- apps/mcp/migrations/0001_initial.py +168 -0
- apps/mcp/migrations/__init__.py +0 -0
- apps/mcp/models.py +154 -0
- apps/mcp/services.py +327 -0
- apps/orders/__init__.py +1 -0
- apps/orders/admin.py +6 -0
- apps/orders/apps.py +8 -0
- apps/orders/migrations/0001_initial.py +79 -0
- apps/orders/migrations/__init__.py +0 -0
- apps/orders/models.py +66 -0
- apps/orders/services.py +107 -0
- apps/policy/__init__.py +1 -0
- apps/policy/admin.py +6 -0
- apps/policy/apps.py +8 -0
- apps/policy/migrations/0001_initial.py +75 -0
- apps/policy/migrations/__init__.py +0 -0
- apps/policy/models.py +61 -0
- apps/policy/services.py +110 -0
- apps/portfolio/__init__.py +1 -0
- apps/portfolio/admin.py +6 -0
- apps/portfolio/apps.py +8 -0
- apps/portfolio/migrations/0001_initial.py +67 -0
- apps/portfolio/migrations/__init__.py +0 -0
- apps/portfolio/models.py +53 -0
- apps/research/__init__.py +1 -0
- apps/research/admin.py +1 -0
- apps/research/apps.py +8 -0
- apps/research/migrations/__init__.py +0 -0
- apps/research/models.py +1 -0
- apps/workflows/__init__.py +1 -0
- apps/workflows/admin.py +6 -0
- apps/workflows/apps.py +8 -0
- apps/workflows/migrations/0001_initial.py +51 -0
- apps/workflows/migrations/__init__.py +0 -0
- apps/workflows/models.py +44 -0
- tradingcodex-0.1.0.dist-info/METADATA +337 -0
- tradingcodex-0.1.0.dist-info/RECORD +254 -0
- tradingcodex-0.1.0.dist-info/WHEEL +5 -0
- tradingcodex-0.1.0.dist-info/entry_points.txt +2 -0
- tradingcodex-0.1.0.dist-info/licenses/LICENSE +202 -0
- tradingcodex-0.1.0.dist-info/licenses/NOTICE +24 -0
- tradingcodex-0.1.0.dist-info/top_level.txt +4 -0
- tradingcodex_cli/__init__.py +1 -0
- tradingcodex_cli/__main__.py +124 -0
- tradingcodex_cli/commands/__init__.py +2 -0
- tradingcodex_cli/commands/bootstrap.py +157 -0
- tradingcodex_cli/commands/db.py +36 -0
- tradingcodex_cli/commands/doctor.py +230 -0
- tradingcodex_cli/commands/mcp.py +186 -0
- tradingcodex_cli/commands/orders.py +89 -0
- tradingcodex_cli/commands/policy.py +21 -0
- tradingcodex_cli/commands/profile.py +110 -0
- tradingcodex_cli/commands/research.py +76 -0
- tradingcodex_cli/commands/skills.py +93 -0
- tradingcodex_cli/commands/strategies.py +67 -0
- tradingcodex_cli/commands/subagents.py +106 -0
- tradingcodex_cli/commands/utils.py +134 -0
- tradingcodex_cli/commands/workspaces.py +53 -0
- tradingcodex_cli/generator.py +234 -0
- tradingcodex_cli/mcp_stdio.py +26 -0
- tradingcodex_cli/service_autostart.py +127 -0
- tradingcodex_service/__init__.py +5 -0
- tradingcodex_service/admin.py +1 -0
- tradingcodex_service/api.py +486 -0
- tradingcodex_service/application/__init__.py +2 -0
- tradingcodex_service/application/agents.py +1470 -0
- tradingcodex_service/application/audit.py +71 -0
- tradingcodex_service/application/common.py +88 -0
- tradingcodex_service/application/components.py +299 -0
- tradingcodex_service/application/harness.py +747 -0
- tradingcodex_service/application/markdown_preview.py +179 -0
- tradingcodex_service/application/orders.py +404 -0
- tradingcodex_service/application/policy.py +150 -0
- tradingcodex_service/application/portfolio.py +166 -0
- tradingcodex_service/application/research.py +356 -0
- tradingcodex_service/application/runtime.py +321 -0
- tradingcodex_service/asgi.py +6 -0
- tradingcodex_service/mcp_http.py +59 -0
- tradingcodex_service/mcp_runtime.py +565 -0
- tradingcodex_service/settings.py +91 -0
- tradingcodex_service/templates/web/activity.html +24 -0
- tradingcodex_service/templates/web/agent_skills.html +111 -0
- tradingcodex_service/templates/web/agents.html +121 -0
- tradingcodex_service/templates/web/base.html +150 -0
- tradingcodex_service/templates/web/dashboard.html +109 -0
- tradingcodex_service/templates/web/fragments/role_inspector.html +81 -0
- tradingcodex_service/templates/web/fragments/starter_prompt.html +24 -0
- tradingcodex_service/templates/web/fragments/topology_canvas.html +85 -0
- tradingcodex_service/templates/web/harness.html +87 -0
- tradingcodex_service/templates/web/mcp_router.html +250 -0
- tradingcodex_service/templates/web/orders.html +68 -0
- tradingcodex_service/templates/web/policy.html +81 -0
- tradingcodex_service/templates/web/portfolio.html +52 -0
- tradingcodex_service/templates/web/research.html +73 -0
- tradingcodex_service/templates/web/starter_prompt.html +40 -0
- tradingcodex_service/templates/web/strategies.html +74 -0
- tradingcodex_service/urls.py +42 -0
- tradingcodex_service/version.py +1 -0
- tradingcodex_service/web.py +885 -0
- tradingcodex_service/wsgi.py +6 -0
- workspace_templates/__init__.py +1 -0
- workspace_templates/modules/audit/files/.tradingcodex/audit/README.md +5 -0
- workspace_templates/modules/audit/files/trading/audit/.gitkeep +1 -0
- workspace_templates/modules/audit/module.json +16 -0
- workspace_templates/modules/codex-base/files/.codex/config.toml +272 -0
- workspace_templates/modules/codex-base/files/.codex/hooks/tradingcodex_hook.py +173 -0
- workspace_templates/modules/codex-base/files/.codex/hooks.json +105 -0
- workspace_templates/modules/codex-base/files/.codex/prompts/base_instructions/head-manager.md +129 -0
- workspace_templates/modules/codex-base/files/.codex/rules/tradingcodex.rules +50 -0
- workspace_templates/modules/codex-base/files/.tradingcodex/capabilities.yaml +56 -0
- workspace_templates/modules/codex-base/files/.tradingcodex/cli.py +16 -0
- workspace_templates/modules/codex-base/files/.tradingcodex/config.yaml +53 -0
- workspace_templates/modules/codex-base/files/.tradingcodex/policies/policy-bindings.yaml +16 -0
- workspace_templates/modules/codex-base/files/.tradingcodex/policies/principals.yaml +17 -0
- workspace_templates/modules/codex-base/files/.tradingcodex/policies/roles.yaml +27 -0
- workspace_templates/modules/codex-base/files/AGENTS.md +56 -0
- workspace_templates/modules/codex-base/files/pyproject.toml +13 -0
- workspace_templates/modules/codex-base/files/tcx +35 -0
- workspace_templates/modules/codex-base/module.json +17 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/policies/access-policies.yaml +39 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/policies/restricted-list.yaml +6 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/approval_receipt.schema.json +14 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/audit_event.schema.json +11 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/evidence_pack.schema.json +16 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/execution_result.schema.json +12 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/fundamental_report.schema.json +15 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/news_report.schema.json +15 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/order_intent.schema.json +30 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/portfolio_review.schema.json +15 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/postmortem_report.schema.json +14 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/risk_report.schema.json +15 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/technical_report.schema.json +15 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/thesis.schema.json +15 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/schemas/valuation.schema.json +15 -0
- workspace_templates/modules/enforcement-guardrails/files/.tradingcodex/scripts/validate-order-intent.py +15 -0
- workspace_templates/modules/enforcement-guardrails/module.json +19 -0
- workspace_templates/modules/fixed-subagents/files/.codex/agents/execution-operator.toml +71 -0
- workspace_templates/modules/fixed-subagents/files/.codex/agents/fundamental-analyst.toml +62 -0
- workspace_templates/modules/fixed-subagents/files/.codex/agents/instrument-analyst.toml +64 -0
- workspace_templates/modules/fixed-subagents/files/.codex/agents/macro-analyst.toml +64 -0
- workspace_templates/modules/fixed-subagents/files/.codex/agents/news-analyst.toml +63 -0
- workspace_templates/modules/fixed-subagents/files/.codex/agents/portfolio-manager.toml +62 -0
- workspace_templates/modules/fixed-subagents/files/.codex/agents/risk-manager.toml +65 -0
- workspace_templates/modules/fixed-subagents/files/.codex/agents/technical-analyst.toml +63 -0
- workspace_templates/modules/fixed-subagents/files/.codex/agents/valuation-analyst.toml +59 -0
- workspace_templates/modules/fixed-subagents/files/.tradingcodex/mainagent/head-manager.yaml +66 -0
- workspace_templates/modules/fixed-subagents/files/.tradingcodex/mainagent/skill-change-proposals/.gitkeep +1 -0
- workspace_templates/modules/fixed-subagents/files/.tradingcodex/mainagent/subagent-registry.yaml +56 -0
- workspace_templates/modules/fixed-subagents/module.json +23 -0
- workspace_templates/modules/guidance-guardrails/files/.tradingcodex/guidance/guardrails.md +17 -0
- workspace_templates/modules/guidance-guardrails/files/.tradingcodex/guidance/task-quality-checklist.md +37 -0
- workspace_templates/modules/guidance-guardrails/module.json +18 -0
- workspace_templates/modules/information-barriers/files/.tradingcodex/policies/information-barriers.yaml +211 -0
- workspace_templates/modules/information-barriers/files/.tradingcodex/secrets.md +9 -0
- workspace_templates/modules/information-barriers/files/trading/approvals/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/market-data/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/orders/approved/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/orders/draft/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/orders/executed/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/orders/rejected/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/portfolio/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/reports/fundamental/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/reports/instrument/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/reports/macro/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/reports/news/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/reports/policy/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/reports/portfolio/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/reports/postmortem/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/reports/risk/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/reports/technical/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/reports/valuation/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/files/trading/research/.gitkeep +1 -0
- workspace_templates/modules/information-barriers/module.json +19 -0
- workspace_templates/modules/paper-trading/files/.tradingcodex/mcp/adapters/paper-trading.py +4 -0
- workspace_templates/modules/paper-trading/module.json +16 -0
- workspace_templates/modules/postmortem/files/.tradingcodex/workflows/postmortem.yaml +12 -0
- workspace_templates/modules/postmortem/module.json +16 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/investment-workflow-map/SKILL.md +106 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/investment-workflow-map/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/manage-optional-skills/SKILL.md +101 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/manage-optional-skills/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/manage-subagents/SKILL.md +140 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/manage-subagents/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/orchestrate-workflow/SKILL.md +140 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/orchestrate-workflow/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/postmortem/SKILL.md +31 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/postmortem/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/scenario-quality-gates/SKILL.md +138 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/scenario-quality-gates/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/strategy-creator/SKILL.md +109 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/strategy-creator/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/synthesize-decision/SKILL.md +54 -0
- workspace_templates/modules/repo-skills/files/.agents/skills/synthesize-decision/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/execution-operator/execute-paper-order/SKILL.md +35 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/execution-operator/execute-paper-order/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/fundamental-analyst/fundamental-analysis/SKILL.md +46 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/fundamental-analyst/fundamental-analysis/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/instrument-analyst/instrument-analysis/SKILL.md +40 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/instrument-analyst/instrument-analysis/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/macro-analyst/macro-analysis/SKILL.md +40 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/macro-analyst/macro-analysis/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/news-analyst/news-analysis/SKILL.md +43 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/news-analyst/news-analysis/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/portfolio-manager/create-order-intent/SKILL.md +46 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/portfolio-manager/create-order-intent/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/portfolio-manager/portfolio-review/SKILL.md +44 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/portfolio-manager/portfolio-review/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/risk-manager/approve-order/SKILL.md +38 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/risk-manager/approve-order/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/risk-manager/policy-review/SKILL.md +43 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/risk-manager/policy-review/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/risk-manager/review-risk/SKILL.md +45 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/risk-manager/review-risk/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/shared/collect-evidence/SKILL.md +46 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/shared/collect-evidence/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/shared/external-data-source-gate/SKILL.md +66 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/shared/external-data-source-gate/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/technical-analyst/technical-analysis/SKILL.md +43 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/technical-analyst/technical-analysis/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/valuation-analyst/valuation-review/SKILL.md +47 -0
- workspace_templates/modules/repo-skills/files/.tradingcodex/subagents/skills/valuation-analyst/valuation-review/agents/openai.yaml +6 -0
- workspace_templates/modules/repo-skills/module.json +37 -0
- workspace_templates/modules/stub-execution/files/.tradingcodex/mcp/adapters/stub-execution.py +4 -0
- workspace_templates/modules/stub-execution/module.json +15 -0
- workspace_templates/modules/tradingcodex-mcp/files/.tradingcodex/mcp/adapters/live-adapter.contract.md +25 -0
- workspace_templates/modules/tradingcodex-mcp/files/.tradingcodex/mcp/enforcer/README.md +5 -0
- workspace_templates/modules/tradingcodex-mcp/files/.tradingcodex/mcp/gateway/README.md +8 -0
- workspace_templates/modules/tradingcodex-mcp/files/.tradingcodex/mcp/server.py +27 -0
- workspace_templates/modules/tradingcodex-mcp/files/.tradingcodex/mcp/smoke-call.py +18 -0
- workspace_templates/modules/tradingcodex-mcp/module.json +24 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "audit",
|
|
3
|
+
"description": "Audit directories and append-only event conventions.",
|
|
4
|
+
"requires": {
|
|
5
|
+
"modules": [
|
|
6
|
+
"codex-base"
|
|
7
|
+
]
|
|
8
|
+
},
|
|
9
|
+
"provides": {
|
|
10
|
+
"capabilities": [
|
|
11
|
+
"audit.write",
|
|
12
|
+
"audit.review"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"conflicts": []
|
|
16
|
+
}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
sandbox_mode = "workspace-write"
|
|
2
|
+
approval_policy = { granular = { sandbox_approval = true, rules = true, mcp_elicitations = true, request_permissions = false, skill_approval = false } }
|
|
3
|
+
approvals_reviewer = "user"
|
|
4
|
+
allow_login_shell = false
|
|
5
|
+
default_permissions = "tradingcodex"
|
|
6
|
+
model_instructions_file = "prompts/base_instructions/head-manager.md"
|
|
7
|
+
|
|
8
|
+
[agents]
|
|
9
|
+
max_threads = {{SUBAGENT_COUNT}}
|
|
10
|
+
max_depth = 1
|
|
11
|
+
|
|
12
|
+
[[skills.config]]
|
|
13
|
+
path = "{{PROJECT_DIR}}/.agents/skills/strategy-creator/SKILL.md"
|
|
14
|
+
enabled = true
|
|
15
|
+
|
|
16
|
+
# BEGIN TradingCodex strategy skills
|
|
17
|
+
# END TradingCodex strategy skills
|
|
18
|
+
|
|
19
|
+
[permissions.tradingcodex]
|
|
20
|
+
description = "TradingCodex workspace profile with secret and broker credential paths denied."
|
|
21
|
+
extends = ":workspace"
|
|
22
|
+
|
|
23
|
+
[permissions.tradingcodex.filesystem.":workspace_roots"]
|
|
24
|
+
"**/*.env" = "deny"
|
|
25
|
+
".tradingcodex/secrets/**" = "deny"
|
|
26
|
+
".tradingcodex/secrets.md" = "deny"
|
|
27
|
+
"**/*broker*credential*" = "deny"
|
|
28
|
+
|
|
29
|
+
[permissions.tradingcodex.network]
|
|
30
|
+
enabled = false
|
|
31
|
+
|
|
32
|
+
[permissions.tradingcodex-fundamental]
|
|
33
|
+
description = "TradingCodex fundamental analyst profile."
|
|
34
|
+
extends = "tradingcodex"
|
|
35
|
+
|
|
36
|
+
[permissions.tradingcodex-fundamental.filesystem.":workspace_roots"]
|
|
37
|
+
".tradingcodex/strategies/**" = "deny"
|
|
38
|
+
".tradingcodex/subagents/skills/technical-analyst/**" = "deny"
|
|
39
|
+
".tradingcodex/subagents/skills/news-analyst/**" = "deny"
|
|
40
|
+
".tradingcodex/subagents/skills/macro-analyst/**" = "deny"
|
|
41
|
+
".tradingcodex/subagents/skills/instrument-analyst/**" = "deny"
|
|
42
|
+
".tradingcodex/subagents/skills/valuation-analyst/**" = "deny"
|
|
43
|
+
".tradingcodex/subagents/skills/portfolio-manager/**" = "deny"
|
|
44
|
+
".tradingcodex/subagents/skills/risk-manager/**" = "deny"
|
|
45
|
+
".tradingcodex/subagents/skills/execution-operator/**" = "deny"
|
|
46
|
+
"trading/reports/technical/**" = "deny"
|
|
47
|
+
"trading/reports/news/**" = "deny"
|
|
48
|
+
"trading/reports/macro/**" = "deny"
|
|
49
|
+
"trading/reports/instrument/**" = "deny"
|
|
50
|
+
"trading/approvals/**" = "deny"
|
|
51
|
+
"trading/orders/approved/**" = "deny"
|
|
52
|
+
"trading/orders/executed/**" = "deny"
|
|
53
|
+
"trading/audit/**" = "deny"
|
|
54
|
+
".tradingcodex/policies/**" = "deny"
|
|
55
|
+
|
|
56
|
+
[permissions.tradingcodex-technical]
|
|
57
|
+
description = "TradingCodex technical analyst profile."
|
|
58
|
+
extends = "tradingcodex"
|
|
59
|
+
|
|
60
|
+
[permissions.tradingcodex-technical.filesystem.":workspace_roots"]
|
|
61
|
+
".tradingcodex/strategies/**" = "deny"
|
|
62
|
+
".tradingcodex/subagents/skills/fundamental-analyst/**" = "deny"
|
|
63
|
+
".tradingcodex/subagents/skills/news-analyst/**" = "deny"
|
|
64
|
+
".tradingcodex/subagents/skills/macro-analyst/**" = "deny"
|
|
65
|
+
".tradingcodex/subagents/skills/instrument-analyst/**" = "deny"
|
|
66
|
+
".tradingcodex/subagents/skills/valuation-analyst/**" = "deny"
|
|
67
|
+
".tradingcodex/subagents/skills/portfolio-manager/**" = "deny"
|
|
68
|
+
".tradingcodex/subagents/skills/risk-manager/**" = "deny"
|
|
69
|
+
".tradingcodex/subagents/skills/execution-operator/**" = "deny"
|
|
70
|
+
"trading/reports/fundamental/**" = "deny"
|
|
71
|
+
"trading/reports/news/**" = "deny"
|
|
72
|
+
"trading/reports/macro/**" = "deny"
|
|
73
|
+
"trading/reports/instrument/**" = "deny"
|
|
74
|
+
"trading/approvals/**" = "deny"
|
|
75
|
+
"trading/orders/approved/**" = "deny"
|
|
76
|
+
"trading/orders/executed/**" = "deny"
|
|
77
|
+
"trading/audit/**" = "deny"
|
|
78
|
+
".tradingcodex/policies/**" = "deny"
|
|
79
|
+
|
|
80
|
+
[permissions.tradingcodex-news]
|
|
81
|
+
description = "TradingCodex news analyst profile."
|
|
82
|
+
extends = "tradingcodex"
|
|
83
|
+
|
|
84
|
+
[permissions.tradingcodex-news.filesystem.":workspace_roots"]
|
|
85
|
+
".tradingcodex/strategies/**" = "deny"
|
|
86
|
+
".tradingcodex/subagents/skills/fundamental-analyst/**" = "deny"
|
|
87
|
+
".tradingcodex/subagents/skills/technical-analyst/**" = "deny"
|
|
88
|
+
".tradingcodex/subagents/skills/macro-analyst/**" = "deny"
|
|
89
|
+
".tradingcodex/subagents/skills/instrument-analyst/**" = "deny"
|
|
90
|
+
".tradingcodex/subagents/skills/valuation-analyst/**" = "deny"
|
|
91
|
+
".tradingcodex/subagents/skills/portfolio-manager/**" = "deny"
|
|
92
|
+
".tradingcodex/subagents/skills/risk-manager/**" = "deny"
|
|
93
|
+
".tradingcodex/subagents/skills/execution-operator/**" = "deny"
|
|
94
|
+
"trading/reports/fundamental/**" = "deny"
|
|
95
|
+
"trading/reports/technical/**" = "deny"
|
|
96
|
+
"trading/reports/macro/**" = "deny"
|
|
97
|
+
"trading/reports/instrument/**" = "deny"
|
|
98
|
+
"trading/approvals/**" = "deny"
|
|
99
|
+
"trading/orders/approved/**" = "deny"
|
|
100
|
+
"trading/orders/executed/**" = "deny"
|
|
101
|
+
"trading/audit/**" = "deny"
|
|
102
|
+
".tradingcodex/policies/**" = "deny"
|
|
103
|
+
|
|
104
|
+
[permissions.tradingcodex-macro]
|
|
105
|
+
description = "TradingCodex macro analyst profile."
|
|
106
|
+
extends = "tradingcodex"
|
|
107
|
+
|
|
108
|
+
[permissions.tradingcodex-macro.filesystem.":workspace_roots"]
|
|
109
|
+
".tradingcodex/strategies/**" = "deny"
|
|
110
|
+
".tradingcodex/subagents/skills/fundamental-analyst/**" = "deny"
|
|
111
|
+
".tradingcodex/subagents/skills/technical-analyst/**" = "deny"
|
|
112
|
+
".tradingcodex/subagents/skills/news-analyst/**" = "deny"
|
|
113
|
+
".tradingcodex/subagents/skills/instrument-analyst/**" = "deny"
|
|
114
|
+
".tradingcodex/subagents/skills/valuation-analyst/**" = "deny"
|
|
115
|
+
".tradingcodex/subagents/skills/portfolio-manager/**" = "deny"
|
|
116
|
+
".tradingcodex/subagents/skills/risk-manager/**" = "deny"
|
|
117
|
+
".tradingcodex/subagents/skills/execution-operator/**" = "deny"
|
|
118
|
+
"trading/reports/fundamental/**" = "deny"
|
|
119
|
+
"trading/reports/technical/**" = "deny"
|
|
120
|
+
"trading/reports/news/**" = "deny"
|
|
121
|
+
"trading/reports/instrument/**" = "deny"
|
|
122
|
+
"trading/approvals/**" = "deny"
|
|
123
|
+
"trading/orders/approved/**" = "deny"
|
|
124
|
+
"trading/orders/executed/**" = "deny"
|
|
125
|
+
"trading/audit/**" = "deny"
|
|
126
|
+
".tradingcodex/policies/**" = "deny"
|
|
127
|
+
|
|
128
|
+
[permissions.tradingcodex-instrument]
|
|
129
|
+
description = "TradingCodex instrument analyst profile."
|
|
130
|
+
extends = "tradingcodex"
|
|
131
|
+
|
|
132
|
+
[permissions.tradingcodex-instrument.filesystem.":workspace_roots"]
|
|
133
|
+
".tradingcodex/strategies/**" = "deny"
|
|
134
|
+
".tradingcodex/subagents/skills/fundamental-analyst/**" = "deny"
|
|
135
|
+
".tradingcodex/subagents/skills/technical-analyst/**" = "deny"
|
|
136
|
+
".tradingcodex/subagents/skills/news-analyst/**" = "deny"
|
|
137
|
+
".tradingcodex/subagents/skills/macro-analyst/**" = "deny"
|
|
138
|
+
".tradingcodex/subagents/skills/valuation-analyst/**" = "deny"
|
|
139
|
+
".tradingcodex/subagents/skills/portfolio-manager/**" = "deny"
|
|
140
|
+
".tradingcodex/subagents/skills/risk-manager/**" = "deny"
|
|
141
|
+
".tradingcodex/subagents/skills/execution-operator/**" = "deny"
|
|
142
|
+
"trading/reports/fundamental/**" = "deny"
|
|
143
|
+
"trading/reports/technical/**" = "deny"
|
|
144
|
+
"trading/reports/news/**" = "deny"
|
|
145
|
+
"trading/reports/macro/**" = "deny"
|
|
146
|
+
"trading/approvals/**" = "deny"
|
|
147
|
+
"trading/orders/approved/**" = "deny"
|
|
148
|
+
"trading/orders/executed/**" = "deny"
|
|
149
|
+
"trading/audit/**" = "deny"
|
|
150
|
+
".tradingcodex/policies/**" = "deny"
|
|
151
|
+
|
|
152
|
+
[permissions.tradingcodex-valuation]
|
|
153
|
+
description = "TradingCodex valuation analyst profile."
|
|
154
|
+
extends = "tradingcodex"
|
|
155
|
+
|
|
156
|
+
[permissions.tradingcodex-valuation.filesystem.":workspace_roots"]
|
|
157
|
+
".tradingcodex/strategies/**" = "deny"
|
|
158
|
+
".tradingcodex/subagents/skills/fundamental-analyst/**" = "deny"
|
|
159
|
+
".tradingcodex/subagents/skills/technical-analyst/**" = "deny"
|
|
160
|
+
".tradingcodex/subagents/skills/news-analyst/**" = "deny"
|
|
161
|
+
".tradingcodex/subagents/skills/macro-analyst/**" = "deny"
|
|
162
|
+
".tradingcodex/subagents/skills/instrument-analyst/**" = "deny"
|
|
163
|
+
".tradingcodex/subagents/skills/portfolio-manager/**" = "deny"
|
|
164
|
+
".tradingcodex/subagents/skills/risk-manager/**" = "deny"
|
|
165
|
+
".tradingcodex/subagents/skills/execution-operator/**" = "deny"
|
|
166
|
+
"trading/approvals/**" = "deny"
|
|
167
|
+
"trading/orders/approved/**" = "deny"
|
|
168
|
+
"trading/orders/executed/**" = "deny"
|
|
169
|
+
"trading/audit/**" = "deny"
|
|
170
|
+
".tradingcodex/policies/**" = "deny"
|
|
171
|
+
|
|
172
|
+
[permissions.tradingcodex-portfolio]
|
|
173
|
+
description = "TradingCodex portfolio manager profile."
|
|
174
|
+
extends = "tradingcodex"
|
|
175
|
+
|
|
176
|
+
[permissions.tradingcodex-portfolio.filesystem.":workspace_roots"]
|
|
177
|
+
".tradingcodex/strategies/**" = "deny"
|
|
178
|
+
".tradingcodex/subagents/skills/fundamental-analyst/**" = "deny"
|
|
179
|
+
".tradingcodex/subagents/skills/technical-analyst/**" = "deny"
|
|
180
|
+
".tradingcodex/subagents/skills/news-analyst/**" = "deny"
|
|
181
|
+
".tradingcodex/subagents/skills/macro-analyst/**" = "deny"
|
|
182
|
+
".tradingcodex/subagents/skills/instrument-analyst/**" = "deny"
|
|
183
|
+
".tradingcodex/subagents/skills/valuation-analyst/**" = "deny"
|
|
184
|
+
".tradingcodex/subagents/skills/risk-manager/**" = "deny"
|
|
185
|
+
".tradingcodex/subagents/skills/execution-operator/**" = "deny"
|
|
186
|
+
"trading/approvals/**" = "deny"
|
|
187
|
+
"trading/orders/approved/**" = "deny"
|
|
188
|
+
"trading/orders/executed/**" = "deny"
|
|
189
|
+
"trading/audit/**" = "deny"
|
|
190
|
+
".tradingcodex/policies/**" = "deny"
|
|
191
|
+
|
|
192
|
+
[permissions.tradingcodex-risk]
|
|
193
|
+
description = "TradingCodex risk manager profile."
|
|
194
|
+
extends = "tradingcodex"
|
|
195
|
+
|
|
196
|
+
[permissions.tradingcodex-risk.filesystem.":workspace_roots"]
|
|
197
|
+
".tradingcodex/strategies/**" = "deny"
|
|
198
|
+
".tradingcodex/subagents/skills/fundamental-analyst/**" = "deny"
|
|
199
|
+
".tradingcodex/subagents/skills/technical-analyst/**" = "deny"
|
|
200
|
+
".tradingcodex/subagents/skills/news-analyst/**" = "deny"
|
|
201
|
+
".tradingcodex/subagents/skills/macro-analyst/**" = "deny"
|
|
202
|
+
".tradingcodex/subagents/skills/instrument-analyst/**" = "deny"
|
|
203
|
+
".tradingcodex/subagents/skills/valuation-analyst/**" = "deny"
|
|
204
|
+
".tradingcodex/subagents/skills/portfolio-manager/**" = "deny"
|
|
205
|
+
".tradingcodex/subagents/skills/execution-operator/**" = "deny"
|
|
206
|
+
"trading/orders/executed/**" = "deny"
|
|
207
|
+
".tradingcodex/secrets.md" = "deny"
|
|
208
|
+
|
|
209
|
+
[permissions.tradingcodex-execution]
|
|
210
|
+
description = "TradingCodex execution operator profile."
|
|
211
|
+
extends = "tradingcodex"
|
|
212
|
+
|
|
213
|
+
[permissions.tradingcodex-execution.filesystem.":workspace_roots"]
|
|
214
|
+
".tradingcodex/strategies/**" = "deny"
|
|
215
|
+
".tradingcodex/subagents/skills/fundamental-analyst/**" = "deny"
|
|
216
|
+
".tradingcodex/subagents/skills/technical-analyst/**" = "deny"
|
|
217
|
+
".tradingcodex/subagents/skills/news-analyst/**" = "deny"
|
|
218
|
+
".tradingcodex/subagents/skills/macro-analyst/**" = "deny"
|
|
219
|
+
".tradingcodex/subagents/skills/instrument-analyst/**" = "deny"
|
|
220
|
+
".tradingcodex/subagents/skills/valuation-analyst/**" = "deny"
|
|
221
|
+
".tradingcodex/subagents/skills/portfolio-manager/**" = "deny"
|
|
222
|
+
".tradingcodex/subagents/skills/risk-manager/**" = "deny"
|
|
223
|
+
"trading/research/**" = "deny"
|
|
224
|
+
"trading/reports/fundamental/**" = "deny"
|
|
225
|
+
"trading/reports/technical/**" = "deny"
|
|
226
|
+
"trading/reports/news/**" = "deny"
|
|
227
|
+
"trading/reports/macro/**" = "deny"
|
|
228
|
+
"trading/reports/instrument/**" = "deny"
|
|
229
|
+
"trading/reports/valuation/**" = "deny"
|
|
230
|
+
"trading/reports/portfolio/**" = "deny"
|
|
231
|
+
"trading/reports/risk/**" = "deny"
|
|
232
|
+
"trading/reports/policy/**" = "deny"
|
|
233
|
+
".tradingcodex/policies/**" = "deny"
|
|
234
|
+
|
|
235
|
+
[mcp_servers.tradingcodex]
|
|
236
|
+
command = "uvx"
|
|
237
|
+
args = ["--refresh", "--python", "3.14", "--from", "{{TRADINGCODEX_MCP_PACKAGE_SPEC}}", "python", "-m", "tradingcodex_cli", "mcp", "stdio"]
|
|
238
|
+
enabled = true
|
|
239
|
+
env = { TRADINGCODEX_MCP_AUTOSTART_SERVICE = "1", TRADINGCODEX_SERVICE_ADDR = "127.0.0.1:48267", TRADINGCODEX_WORKSPACE_ROOT = "{{PROJECT_DIR}}" }
|
|
240
|
+
enabled_tools = [
|
|
241
|
+
"get_tradingcodex_status",
|
|
242
|
+
"simulate_policy",
|
|
243
|
+
"get_order_status",
|
|
244
|
+
"get_positions",
|
|
245
|
+
"get_portfolio_snapshot",
|
|
246
|
+
"list_workflow_artifacts",
|
|
247
|
+
"create_research_artifact",
|
|
248
|
+
"get_research_artifact",
|
|
249
|
+
"list_research_artifacts",
|
|
250
|
+
"search_research_artifacts",
|
|
251
|
+
"append_research_artifact_version",
|
|
252
|
+
"export_research_artifact_md",
|
|
253
|
+
"record_source_snapshot",
|
|
254
|
+
"record_audit_event"
|
|
255
|
+
]
|
|
256
|
+
default_tools_approval_mode = "prompt"
|
|
257
|
+
startup_timeout_sec = 20
|
|
258
|
+
tool_timeout_sec = 30
|
|
259
|
+
|
|
260
|
+
[shell_environment_policy]
|
|
261
|
+
inherit = "core"
|
|
262
|
+
set = {}
|
|
263
|
+
exclude = [
|
|
264
|
+
"*API_KEY*",
|
|
265
|
+
"*SECRET*",
|
|
266
|
+
"*TOKEN*",
|
|
267
|
+
"BROKER_*",
|
|
268
|
+
"BROKER_API_KEY",
|
|
269
|
+
"BROKER_API_SECRET",
|
|
270
|
+
"TRADING_API_KEY",
|
|
271
|
+
"TRADING_API_SECRET"
|
|
272
|
+
]
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import json
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
from datetime import datetime, timezone
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
RECORDED_PYTHON = "{{PYTHON_EXECUTABLE}}"
|
|
9
|
+
if (
|
|
10
|
+
RECORDED_PYTHON
|
|
11
|
+
and os.path.exists(RECORDED_PYTHON)
|
|
12
|
+
and os.path.realpath(sys.executable) != os.path.realpath(RECORDED_PYTHON)
|
|
13
|
+
and os.environ.get("TRADINGCODEX_HOOK_REEXEC") != "1"
|
|
14
|
+
):
|
|
15
|
+
os.environ["TRADINGCODEX_HOOK_REEXEC"] = "1"
|
|
16
|
+
os.execv(RECORDED_PYTHON, [RECORDED_PYTHON, __file__, *sys.argv[1:]])
|
|
17
|
+
|
|
18
|
+
SOURCE_ROOT = "{{SOURCE_ROOT}}"
|
|
19
|
+
if SOURCE_ROOT not in sys.path:
|
|
20
|
+
sys.path.insert(0, SOURCE_ROOT)
|
|
21
|
+
|
|
22
|
+
os.environ.setdefault("TRADINGCODEX_WORKSPACE_ROOT", "{{PROJECT_DIR}}")
|
|
23
|
+
|
|
24
|
+
from tradingcodex_service.application.agents import EXPECTED_SUBAGENTS
|
|
25
|
+
from tradingcodex_service.application.harness import (
|
|
26
|
+
build_subagent_starter_prompt,
|
|
27
|
+
classify_starter_request,
|
|
28
|
+
is_investment_workflow_request,
|
|
29
|
+
is_secret_only_request,
|
|
30
|
+
is_secret_warning_request,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
ROOT = Path("{{PROJECT_DIR}}")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def main() -> None:
|
|
37
|
+
event = sys.argv[1] if len(sys.argv) > 1 else "unknown"
|
|
38
|
+
try:
|
|
39
|
+
payload = json.loads(sys.stdin.read() or "{}")
|
|
40
|
+
except Exception:
|
|
41
|
+
payload = {}
|
|
42
|
+
if event == "session-start":
|
|
43
|
+
session_start(payload)
|
|
44
|
+
elif event == "user-prompt-submit":
|
|
45
|
+
user_prompt_submit(payload)
|
|
46
|
+
elif event in {"subagent-start", "subagent-stop"}:
|
|
47
|
+
subagent_session_state(event, payload)
|
|
48
|
+
elif event in {"pre-tool-use", "permission-request"}:
|
|
49
|
+
policy_gate(event, payload)
|
|
50
|
+
elif event == "post-tool-use":
|
|
51
|
+
append_hook_audit({"event": event, "payload": payload})
|
|
52
|
+
elif event == "stop":
|
|
53
|
+
return
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def session_start(payload: dict) -> None:
|
|
57
|
+
readiness = {
|
|
58
|
+
"spawn_requested": False,
|
|
59
|
+
"natural_language_investment_routing": True,
|
|
60
|
+
"explicit_user_request_required": False,
|
|
61
|
+
"subagents": EXPECTED_SUBAGENTS,
|
|
62
|
+
"local_cli": {
|
|
63
|
+
"command": "./tcx",
|
|
64
|
+
"plan_all": "./tcx subagents plan --all",
|
|
65
|
+
},
|
|
66
|
+
"spawn_tool_notes": [
|
|
67
|
+
"use spawn_agent agent_type only when the active schema can select the exact fixed role",
|
|
68
|
+
"treat missing fixed-role selection as routing-unverified and fail closed",
|
|
69
|
+
"do not pass model, reasoning, or service-tier overrides for fixed roles",
|
|
70
|
+
],
|
|
71
|
+
}
|
|
72
|
+
write_json(ROOT / ".tradingcodex" / "mainagent" / "session-start.json", readiness)
|
|
73
|
+
append_hook_audit({"event": "session-start", "readiness": readiness})
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def user_prompt_submit(payload: dict) -> None:
|
|
77
|
+
prompt = payload.get("prompt") or payload.get("user_prompt") or payload.get("message") or ""
|
|
78
|
+
if not prompt:
|
|
79
|
+
return
|
|
80
|
+
agent_type = payload.get("agent_type") or payload.get("subagent_type")
|
|
81
|
+
if agent_type in EXPECTED_SUBAGENTS:
|
|
82
|
+
return
|
|
83
|
+
secret_warning = is_secret_warning_request(prompt)
|
|
84
|
+
secret_only = is_secret_only_request(prompt)
|
|
85
|
+
investment_request = is_investment_workflow_request(prompt) and not secret_only
|
|
86
|
+
if not investment_request and not secret_warning:
|
|
87
|
+
return
|
|
88
|
+
plan = classify_starter_request(prompt) if investment_request else {"lane": "secret_warning", "subagents": []}
|
|
89
|
+
explicit = any(token in prompt.lower() for token in ["subagent", "parallel", "delegated", "$orchestrate-workflow", "서브에이전트"])
|
|
90
|
+
activation_source = "explicit_subagent" if explicit else "auto_routed_investment_request"
|
|
91
|
+
if not investment_request:
|
|
92
|
+
activation_source = "secret_warning_only"
|
|
93
|
+
gate = {
|
|
94
|
+
"marker": "tradingcodex-workflow-gate",
|
|
95
|
+
"workflow_run_id": f"workflow-{datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%S%fZ')}",
|
|
96
|
+
"requires_subagent_dispatch": investment_request,
|
|
97
|
+
"auto_dispatch_allowed": investment_request,
|
|
98
|
+
"confirmation_required": False,
|
|
99
|
+
"explicit_subagent_request": explicit,
|
|
100
|
+
"activation_source": activation_source,
|
|
101
|
+
"workflow_lane": plan["lane"],
|
|
102
|
+
"required_subagents": plan["subagents"],
|
|
103
|
+
"starter_prompt": build_subagent_starter_prompt(prompt) if investment_request else "",
|
|
104
|
+
"secret_warning": secret_warning,
|
|
105
|
+
}
|
|
106
|
+
write_json(ROOT / ".tradingcodex" / "mainagent" / "latest-user-prompt-gate.json", gate)
|
|
107
|
+
output = {
|
|
108
|
+
"hookSpecificOutput": {
|
|
109
|
+
"hookEventName": "UserPromptSubmit",
|
|
110
|
+
"additionalContext": json.dumps(gate, ensure_ascii=False),
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
print(json.dumps(output, ensure_ascii=False))
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def subagent_session_state(event: str, payload: dict) -> None:
|
|
117
|
+
state_path = ROOT / ".tradingcodex" / "mainagent" / "subagent-session-state.json"
|
|
118
|
+
state = read_json(state_path, {"updated_at": None, "active": {}, "completed": [], "events": []})
|
|
119
|
+
gate = read_json(ROOT / ".tradingcodex" / "mainagent" / "latest-user-prompt-gate.json", {})
|
|
120
|
+
role = payload.get("agent_type") or payload.get("subagent_type") or payload.get("subagent") or payload.get("agent") or payload.get("task_name", "").split(" ")[0]
|
|
121
|
+
record = {
|
|
122
|
+
"event": event,
|
|
123
|
+
"role": role,
|
|
124
|
+
"task_name": payload.get("task_name"),
|
|
125
|
+
"run_id": gate.get("workflow_run_id"),
|
|
126
|
+
"ts": now(),
|
|
127
|
+
}
|
|
128
|
+
if event == "subagent-start":
|
|
129
|
+
state.setdefault("active", {})[role] = record
|
|
130
|
+
else:
|
|
131
|
+
state.setdefault("active", {}).pop(role, None)
|
|
132
|
+
state.setdefault("completed", []).append(record)
|
|
133
|
+
state.setdefault("events", []).append(record)
|
|
134
|
+
state["updated_at"] = now()
|
|
135
|
+
write_json(state_path, state)
|
|
136
|
+
append_jsonl(ROOT / "trading" / "audit" / "subagent-session-events.jsonl", record)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def policy_gate(event: str, payload: dict) -> None:
|
|
140
|
+
text = json.dumps(payload, ensure_ascii=False).lower()
|
|
141
|
+
forbidden = ["broker api", "api_key", "secret.read", "cash.withdraw", "policy.write"]
|
|
142
|
+
if any(item in text for item in forbidden):
|
|
143
|
+
print(json.dumps({"decision": "block", "reason": "TradingCodex policy gate blocked sensitive request"}))
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def append_hook_audit(record: dict) -> None:
|
|
147
|
+
append_jsonl(ROOT / "trading" / "audit" / "codex-hooks.jsonl", {"ts": now(), **record})
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def now() -> str:
|
|
151
|
+
return datetime.now(timezone.utc).isoformat().replace("+00:00", "Z")
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def read_json(path: Path, default):
|
|
155
|
+
try:
|
|
156
|
+
return json.loads(path.read_text(encoding="utf-8"))
|
|
157
|
+
except Exception:
|
|
158
|
+
return default
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def write_json(path: Path, value) -> None:
|
|
162
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
163
|
+
path.write_text(json.dumps(value, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def append_jsonl(path: Path, value) -> None:
|
|
167
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
168
|
+
with path.open("a", encoding="utf-8") as handle:
|
|
169
|
+
handle.write(json.dumps(value, ensure_ascii=False) + "\n")
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
if __name__ == "__main__":
|
|
173
|
+
main()
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"SessionStart": [
|
|
4
|
+
{
|
|
5
|
+
"hooks": [
|
|
6
|
+
{
|
|
7
|
+
"type": "command",
|
|
8
|
+
"command": "{{PYTHON_EXECUTABLE}} \"{{PROJECT_DIR}}/.codex/hooks/tradingcodex_hook.py\" session-start",
|
|
9
|
+
"timeout": 10,
|
|
10
|
+
"statusMessage": "Preparing TradingCodex subagent roster"
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"PreToolUse": [
|
|
16
|
+
{
|
|
17
|
+
"matcher": "Bash|mcp__.*",
|
|
18
|
+
"hooks": [
|
|
19
|
+
{
|
|
20
|
+
"type": "command",
|
|
21
|
+
"command": "{{PYTHON_EXECUTABLE}} \"{{PROJECT_DIR}}/.codex/hooks/tradingcodex_hook.py\" pre-tool-use",
|
|
22
|
+
"timeout": 10,
|
|
23
|
+
"statusMessage": "Checking TradingCodex tool policy"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"PermissionRequest": [
|
|
29
|
+
{
|
|
30
|
+
"matcher": "Bash|mcp__.*|apply_patch|Edit|Write",
|
|
31
|
+
"hooks": [
|
|
32
|
+
{
|
|
33
|
+
"type": "command",
|
|
34
|
+
"command": "{{PYTHON_EXECUTABLE}} \"{{PROJECT_DIR}}/.codex/hooks/tradingcodex_hook.py\" permission-request",
|
|
35
|
+
"timeout": 10,
|
|
36
|
+
"statusMessage": "Reviewing TradingCodex permission request"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"PostToolUse": [
|
|
42
|
+
{
|
|
43
|
+
"matcher": "Bash|mcp__.*|apply_patch|Edit|Write",
|
|
44
|
+
"hooks": [
|
|
45
|
+
{
|
|
46
|
+
"type": "command",
|
|
47
|
+
"command": "{{PYTHON_EXECUTABLE}} \"{{PROJECT_DIR}}/.codex/hooks/tradingcodex_hook.py\" post-tool-use",
|
|
48
|
+
"timeout": 10,
|
|
49
|
+
"statusMessage": "Recording TradingCodex audit event"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"UserPromptSubmit": [
|
|
55
|
+
{
|
|
56
|
+
"hooks": [
|
|
57
|
+
{
|
|
58
|
+
"type": "command",
|
|
59
|
+
"command": "{{PYTHON_EXECUTABLE}} \"{{PROJECT_DIR}}/.codex/hooks/tradingcodex_hook.py\" user-prompt-submit",
|
|
60
|
+
"timeout": 10,
|
|
61
|
+
"statusMessage": "Scanning prompt for TradingCodex secrets"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"SubagentStart": [
|
|
67
|
+
{
|
|
68
|
+
"matcher": "fundamental-analyst|technical-analyst|news-analyst|macro-analyst|instrument-analyst|valuation-analyst|portfolio-manager|risk-manager|execution-operator",
|
|
69
|
+
"hooks": [
|
|
70
|
+
{
|
|
71
|
+
"type": "command",
|
|
72
|
+
"command": "{{PYTHON_EXECUTABLE}} \"{{PROJECT_DIR}}/.codex/hooks/tradingcodex_hook.py\" subagent-start",
|
|
73
|
+
"timeout": 10,
|
|
74
|
+
"statusMessage": "Recording TradingCodex subagent start"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"SubagentStop": [
|
|
80
|
+
{
|
|
81
|
+
"matcher": "fundamental-analyst|technical-analyst|news-analyst|macro-analyst|instrument-analyst|valuation-analyst|portfolio-manager|risk-manager|execution-operator",
|
|
82
|
+
"hooks": [
|
|
83
|
+
{
|
|
84
|
+
"type": "command",
|
|
85
|
+
"command": "{{PYTHON_EXECUTABLE}} \"{{PROJECT_DIR}}/.codex/hooks/tradingcodex_hook.py\" subagent-stop",
|
|
86
|
+
"timeout": 10,
|
|
87
|
+
"statusMessage": "Recording TradingCodex subagent stop"
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"Stop": [
|
|
93
|
+
{
|
|
94
|
+
"hooks": [
|
|
95
|
+
{
|
|
96
|
+
"type": "command",
|
|
97
|
+
"command": "{{PYTHON_EXECUTABLE}} \"{{PROJECT_DIR}}/.codex/hooks/tradingcodex_hook.py\" stop",
|
|
98
|
+
"timeout": 30,
|
|
99
|
+
"statusMessage": "Validating TradingCodex artifacts"
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
}
|