Repository navigation
Fix crate keywords and add a sigit-agent README after 1.7.0 #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # sigit-agent | ||
|
|
||
| siGit Code as a library, for apps that embed the agent instead of launching the | ||
| [`sigit`](https://crates.io/crates/sigit) binary. | ||
|
|
||
| It is an [`ed-acp`](https://crates.io/crates/ed-acp) agent profile. A host serves it in | ||
| process over an in-memory channel and talks to it with an | ||
| [Agent Client Protocol](https://agentclientprotocol.com) client on the other end. That is | ||
| what lets a sandboxed app (a Mac App Store build, an iOS app) run the agent without spawning | ||
| a subprocess. | ||
|
|
||
| ## What is in the crate | ||
|
|
||
| - `SiGitCode`, the `ed_acp::Profile`: the system prompt, the workspace tools, the `/init` | ||
| command and the sign-in. `SiGitCode::new()` includes `run_command`. | ||
| `SiGitCode::without_shell()` is for a host that cannot start processes. It drops | ||
| `run_command` and tells the model so. | ||
| - `SiGitAuth`, the profile's `AuthProvider`. It runs the browser sign-in (a public OAuth | ||
| client with PKCE) and keeps the resulting session in the `credentials` module. | ||
| - `official_mcp_servers()`, the official siGit MCP server as a session server for the | ||
| signed-in user. It is empty when signed out. Pass it in `mcpServers` when you open a | ||
| session, so a sign-out does not leave a stale bearer behind in a shared server. | ||
| - `prompt`, which holds `SYSTEM_PROMPT` and `INIT_PROMPT`. The `sigit` binary uses the same | ||
| ones. | ||
|
|
||
| Inference goes to siGit Code Cloud (`https://sigit.si/api/v1`, or `SIGIT_CLOUD_URL`) with the | ||
| stored session token as the bearer. | ||
|
|
||
| ## Serving it | ||
|
|
||
| ```rust | ||
| use std::sync::Arc; | ||
|
|
||
| use agent_client_protocol::Channel; | ||
| use ed_acp::ServeOptions; | ||
| use sigit_agent::SiGitCode; | ||
|
|
||
| let (agent_end, client_end) = Channel::duplex(); | ||
|
setoelkahfi marked this conversation as resolved.
|
||
| let opts = ServeOptions { yolo: false, surface: "app" }; | ||
|
|
||
| tokio::spawn(ed_acp::serve(Arc::new(SiGitCode::without_shell()), opts, agent_end)); | ||
|
setoelkahfi marked this conversation as resolved.
|
||
| // Connect an ACP client to `client_end`, then initialize, authenticate and open a session. | ||
| ``` | ||
|
|
||
| `ed_acp::serve` is a future, so this runs inside the host's own async runtime. The example | ||
| assumes a `tokio` runtime, so the host needs `tokio` as a dependency. | ||
|
|
||
| `crates/sigit-agent/tests/embedded.rs` is a complete version of this against a mock | ||
| endpoint: it checks that the sign-in method is advertised, that a signed-out session is | ||
| refused, that a stored session reaches the endpoint as the bearer, and that signing out takes | ||
| it away again. | ||
|
|
||
| ## Where the session lives | ||
|
|
||
| Call `credentials::use_config_dir` with your app's own data directory before anything else. | ||
| In a sandboxed app that directory is inside the container, so the app and the `sigit` CLI | ||
| never share or overwrite each other's session. | ||
|
|
||
| ## Environment | ||
|
|
||
| | Variable | Effect | | ||
| | --- | --- | | ||
| | `SIGIT_CLOUD_URL` | Inference endpoint. Defaults to `https://sigit.si/api/v1`. | | ||
| | `SIGIT_CONFIG_DIR` | Where the session is stored. | | ||
| | `SIGIT_MCP_OFFICIAL` | `off` makes `official_mcp_servers()` return nothing. | | ||
| | `SIGIT_MCP_URL` | Overrides the official MCP server URL. | | ||
|
|
||
| ## License | ||
|
|
||
| Apache-2.0. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.