Initial commit

This commit is contained in:
LZH-YS1998
2026-07-01 17:56:31 +08:00
commit d78931979d
731 changed files with 311088 additions and 0 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

+67
View File
@@ -0,0 +1,67 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1600" height="900" viewBox="0 0 1600 900" role="img" aria-labelledby="title desc">
<title id="title">VC Investment Research Package Preview</title>
<desc id="desc">A preview card for an AI Infrastructure investment research package with report pages, ranking table, and IC verdict labels.</desc>
<defs>
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stop-color="#f8fafc"/>
<stop offset="0.55" stop-color="#eef6f5"/>
<stop offset="1" stop-color="#fff7ed"/>
</linearGradient>
<filter id="shadow" x="-20%" y="-20%" width="140%" height="140%">
<feDropShadow dx="0" dy="18" stdDeviation="24" flood-color="#0f172a" flood-opacity="0.16"/>
</filter>
</defs>
<rect width="1600" height="900" fill="url(#bg)"/>
<path d="M96 730 C275 662, 374 742, 525 685 C683 626, 780 534, 958 577 C1147 623, 1275 755, 1504 664" fill="none" stroke="#14b8a6" stroke-width="6" stroke-linecap="round" opacity="0.28"/>
<path d="M126 188 H1474" stroke="#0f172a" stroke-width="2" opacity="0.08"/>
<path d="M126 716 H1474" stroke="#0f172a" stroke-width="2" opacity="0.08"/>
<g filter="url(#shadow)">
<rect x="142" y="118" width="676" height="664" rx="18" fill="#ffffff"/>
<rect x="142" y="118" width="676" height="90" rx="18" fill="#0f172a"/>
<path d="M142 190 H818" stroke="#0f172a" stroke-width="36"/>
<text x="190" y="176" font-family="Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif" font-size="34" font-weight="700" fill="#ffffff">AI Infra Investment Report</text>
<text x="190" y="260" font-family="Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif" font-size="22" fill="#475569">Evidence cut-off: 2026-05-10</text>
<text x="190" y="300" font-family="Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif" font-size="22" fill="#475569">Generated by OpenOPC</text>
<rect x="190" y="354" width="580" height="270" rx="12" fill="#f8fafc" stroke="#cbd5e1"/>
<text x="224" y="408" font-family="Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif" font-size="24" font-weight="700" fill="#0f172a">Final Top 3</text>
<line x1="224" y1="436" x2="736" y2="436" stroke="#94a3b8" stroke-width="2"/>
<text x="224" y="486" font-family="Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif" font-size="26" font-weight="700" fill="#0f172a">1</text>
<text x="276" y="486" font-family="Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif" font-size="26" fill="#0f172a">Baseten</text>
<rect x="604" y="456" width="132" height="42" rx="21" fill="#ccfbf1"/>
<text x="630" y="485" font-family="Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif" font-size="18" font-weight="700" fill="#0f766e">Recommend</text>
<text x="224" y="548" font-family="Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif" font-size="26" font-weight="700" fill="#0f172a">2</text>
<text x="276" y="548" font-family="Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif" font-size="26" fill="#0f172a">Galileo</text>
<rect x="604" y="518" width="132" height="42" rx="21" fill="#ccfbf1"/>
<text x="630" y="547" font-family="Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif" font-size="18" font-weight="700" fill="#0f766e">Recommend</text>
<text x="224" y="610" font-family="Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif" font-size="26" font-weight="700" fill="#0f172a">3</text>
<text x="276" y="610" font-family="Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif" font-size="26" fill="#0f172a">Together AI</text>
<rect x="628" y="580" width="108" height="42" rx="21" fill="#fed7aa"/>
<text x="657" y="609" font-family="Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif" font-size="18" font-weight="700" fill="#c2410c">Watch</text>
<rect x="190" y="676" width="220" height="28" rx="14" fill="#e2e8f0"/>
<rect x="190" y="724" width="460" height="18" rx="9" fill="#e2e8f0"/>
</g>
<g filter="url(#shadow)">
<rect x="902" y="176" width="456" height="590" rx="18" fill="#ffffff"/>
<rect x="950" y="238" width="360" height="44" rx="22" fill="#0f172a"/>
<text x="986" y="268" font-family="Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif" font-size="20" font-weight="700" fill="#ffffff">IC Decision Package</text>
<rect x="950" y="340" width="360" height="26" rx="13" fill="#cbd5e1"/>
<rect x="950" y="398" width="288" height="22" rx="11" fill="#e2e8f0"/>
<rect x="950" y="450" width="330" height="22" rx="11" fill="#e2e8f0"/>
<rect x="950" y="502" width="252" height="22" rx="11" fill="#e2e8f0"/>
<rect x="950" y="594" width="156" height="50" rx="25" fill="#14b8a6"/>
<text x="989" y="627" font-family="Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif" font-size="20" font-weight="700" fill="#ffffff">PDF</text>
<rect x="1130" y="594" width="156" height="50" rx="25" fill="#f97316"/>
<text x="1165" y="627" font-family="Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif" font-size="20" font-weight="700" fill="#ffffff">Deck</text>
</g>
<text x="142" y="844" font-family="Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif" font-size="28" font-weight="700" fill="#0f172a">VC Investment Research</text>
<text x="902" y="844" font-family="Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif" font-size="22" fill="#475569">Report, deck, IC package, and diligence gates</text>
</svg>

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 KiB

+43
View File
@@ -0,0 +1,43 @@
# Channel Bridge Providers
Some channel providers need a companion bridge service in addition to the OpenOPC Python runtime. OpenOPC connects to these bridges through the provider adapter; it does not start or manage the external bridge process for you.
## WhatsApp
- Install: `pip install -e .[channels-whatsapp]`
- Runtime mode: WebSocket bridge
- Required config:
- `bridge_url`
- `allow_from`
- Optional config:
- `bridge_token`
- Expected flow:
1. Start the companion WhatsApp bridge service.
2. Complete QR/device pairing in the bridge environment.
3. Set `channels.whatsapp.bridge_url` in `.opc/config/channel_config.yaml`.
4. Run `opc channels status`.
5. Start OpenOPC with `opc channels start -p <project>` or `opc run -p <project>`.
## Mochat
- Install: `pip install -e .[channels-mochat]`
- Runtime mode: bridge
- Required config:
- `base_url`
- `claw_token`
- `agent_user_id`
- Optional config:
- `socket_url`
- `socket_path`
- `sessions`
- `panels`
- Notes:
- Socket mode is attempted first when available.
- HTTP watch/poll fallback is used if socket startup fails.
- Panel targets are treated as bridge/group-style destinations.
## Convenience Install
```bash
pip install -e .[channels-bridges]
```
+48
View File
@@ -0,0 +1,48 @@
# OpenOPC Channels
OpenOPC has a channel runtime in `opc/channels/` for routing external messages into the engine and sending replies back through configured providers. Feishu is the primary documented setup in the README; the other providers are optional adapters with different dependency, credential, and bridge requirements.
Provider metadata is defined in `opc/channels/provider_registry.py`.
## Providers
| Provider | Runtime | Extra | Required config |
|---|---|---|---|
| `telegram` | polling | `channels-telegram` | `token` |
| `whatsapp` | bridge | `channels-whatsapp` | `bridge_url` |
| `discord` | socket | `channels-discord` | `token` |
| `feishu` | socket | `channels-feishu` | `app_id`, `app_secret` |
| `mochat` | bridge | `channels-mochat` | `base_url`, `claw_token`, `agent_user_id` |
| `dingtalk` | socket | `channels-dingtalk` | `client_id`, `client_secret` |
| `email` | polling | `channels-email` | IMAP/SMTP fields, `consent_granted` |
| `slack` | socket | `channels-slack` | `bot_token`, `app_token` |
| `qq` | socket | `channels-qq` | `app_id`, `secret` |
| `matrix` | polling | `channels-matrix` | `homeserver`, `access_token`, `user_id` |
## Setup Flow
1. Run `opc init`.
2. Install the extra for the provider you plan to enable.
3. Edit `.opc/config/channel_config.yaml`, or `$OPC_HOME/config/channel_config.yaml` if `OPC_HOME` is set.
4. Set `allow_from` explicitly. Empty lists deny all inbound senders.
5. Run `opc channels login <provider>` for provider-specific setup guidance.
6. Run `opc channels status` and confirm the provider is enabled, available, and configured.
7. Start channels in the foreground with `opc channels start -p <project>`, or start the engine and channel runtime together with `opc run -p <project>`.
## Commands
```bash
opc channels status
opc channels login feishu
opc channels start -p demo
opc channels stop
opc run -p demo
```
## Messaging Semantics
- Channel events are normalized into `UserMessage`.
- Outbound replies are sent as `SystemMessage`.
- Sender allow-lists are enforced before inbound messages are accepted.
- Session ids are derived from provider chat/thread context when available.
- Bridge providers require a separate companion service; see [channel-bridges.md](channel-bridges.md).
+64
View File
@@ -0,0 +1,64 @@
# OPC Chat Slash Commands
`opc chat` includes an interactive slash console for managing context, sessions, runtime visibility, company work items, organization assets, and diagnostics without opening the Office UI.
The source of truth for this table is `_SLASH_COMMANDS` in `opc/cli/app.py`.
## Chat And Context
- `/help` shows the command table.
- `/quit` exits interactive chat.
- `/queue list|drop|clear` inspects or edits queued prompts while a turn is running.
- `/status` shows project, session, mode, agent, domains, model, cost, and external agent availability.
- `/mode [task|company] [corporate|custom]` changes how future natural-language messages run.
- `/agent [native|codex|claude_code|cursor|opencode|none]` sets or clears the preferred execution agent.
- `/domains [domain ...|clear]` sets or clears domain hints.
- Aliases: `/p` is `/project`, `/s` is `/session`, `/t` is `/task`, `/checkpoint` is `/checkpoints`, `/recovery` is `/recover`.
## Project And Session
- `/project` shows current project info and project command usage.
- `/project list|create|switch|rename|delete` manages project ids through the shared Office service.
- `/stop [task_id|session_id]` stops the current or selected runtime and preserves history.
- `/continue [task_id|session_id] [message]` continues a stopped runtime without re-planning.
- `/session` shows current session info and session command usage.
- `/session list|new|create|resume|show|config|send|rename|delete|stop|continue|complete` manages task-backed and plain chat sessions.
- `/session create [title] [--mode task|company|org] [--agent ...]` creates a task-backed session. `org` is a compatibility selector for Company Mode with a saved org architecture.
## Tasks And Runtime
- `/tasks [status] [--limit N] [--full]` lists project tasks.
- `/task show|move|done|rename|delete` inspects and updates persisted tasks.
- `/runtime [--limit N] [--full]` shows live runtime, active tasks, external sessions, and checkpoints.
- `/recover [--limit N] [--full]` lists interrupted runtimes and resumable checkpoints.
- `/recover resume|cancel|retry <parent_task_id>` acts on interrupted company runtimes.
- `/logs <task_id|session_id> [--limit N] [--full]` shows execution logs, runtime events, tools, and transcript.
- `/comms <task_id> [--limit N] [--full]` shows company-mode messages, handoffs, review notes, and handoff context.
- `/attachments [--limit N] [--full]` lists current-session attachment references.
- `/checkpoints [--limit N] [--full]` lists pending execution checkpoints.
## Company Work And Board
- `/staffing [context]` opens the pending company staffing editor or role context preview.
- `/kanban [once|stop|all]` shows current-session work-item status inline and can watch live updates.
- `/board kanban|pipeline|work-item|role|logs` opens the CLI board inspector in read-only mode.
- `/work-items list|show|logs|role-status` inspects company work items and role progress.
## Organization, Talent, And Market
- `/org` shows or edits organization config.
- `/org role add|update|delete|bulk-add` manages roles.
- `/org policy update --payload ...` updates runtime policy.
- `/org strategy update --final-decider <role>` updates organization strategy.
- `/org saved list|save|load|delete` manages saved organization architectures.
- `/agent list|detail|create|delete|move|import-employee` manages visual office agents.
- `/talent list|employees|scan|import|import-repo|hire|employee|import-agent` manages talent templates and hired employees.
- `/market browse|preview|list|presets|apply-preset|install|uninstall|export` manages architecture presets and `.opcpkg` packages.
- `/reorg list|show|approve|deny|apply` manages reorganization proposals.
## Diagnostics And Display
- `/cost` shows token and cost counters.
- `--limit N` caps list output between 1 and 100 rows.
- `--full` expands long text that is otherwise shortened for compact terminal display.
- Destructive commands require `--yes`.
+26
View File
@@ -0,0 +1,26 @@
# Company Mode Metadata Ownership
Company Mode keeps two different records with different responsibilities:
- `DelegationWorkItem` owns business, collaboration, board, review, report, and user-visible progress facts.
- Runtime `Task` owns execution envelopes, sessions, external-agent state, locks, runtime audit, stdout/result records, and replay.
The executable owner matrix lives in `opc/layer2_organization/metadata_ownership.py`. Treat this document as the human-readable summary; the code is the contract used by tests and runtime diagnostics.
## Owner Groups
| Owner | Examples | Rule |
|---|---|---|
| `work_item` | `work_kind`, `current_turn_mode`, dependency/waiting ids, handoff/context preview, prompt contracts, progress logs, role and employee context, review/report metadata, verification fields, delivery package, self-evolution fields | Scheduling, board projection, collaboration, review/report, and user-visible progress reads should use `DelegationWorkItem.metadata`. |
| `runtime_task` | `runtime_v2`, `runtime_verification*`, `member_session_state`, `external_resume_*`, `working_memory`, `interrupted_recovery`, `last_stop_reason`, `peer_wait`, comms reactivation audit, `runtime_control_state`, runtime session team/seat ids | Execution infrastructure should store these only on runtime `Task.metadata`. They must not become WorkItem business facts. |
| `execution_copy` | `mode`, `execution_mode`, `runtime_model`, `company_profile`, organization/runtime topology, delegation ids, seat/role routing, execution-agent selection, workspace/comms roots, parent session id | Runtime `Task` may carry these as immutable routing and UI envelope copies. They are not the authoritative business facts. |
WorkItem-to-runtime-Task linkage is not metadata. It is owned by the `work_item_runtime_links` table. UI payloads may expose this relation as `runtime_task_id` or `execution_turn_id`.
## Migration And Diagnostics
- New Company Mode writes WorkItem-owned fields to `DelegationWorkItem.metadata`.
- Runtime Task metadata is stripped of WorkItem-owned fields that are not allowed execution copies.
- `migrate_work_item_owned_metadata_from_linked_tasks` can dry-run or backfill missing WorkItem-owned values from linked legacy Tasks.
- Conflicts are not silently repaired. WorkItem wins, and diagnostics report `metadata_ownership_conflict`.
- Runtime invariants are validated by `opc/layer2_organization/work_item_runtime_invariants.py` and related tests.