Skip to content

Commit 579a1e1

Browse files
authored
feat(console): expose environment commands and refresh lathe v0.4.4 codegen (#62)
1 parent a659c49 commit 579a1e1

10 files changed

Lines changed: 317 additions & 15 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/langgenius/mosoo-connector
33
go 1.25.7
44

55
require (
6-
github.com/lathe-cli/lathe v0.4.4-0.20260627231917-297788512b95
6+
github.com/lathe-cli/lathe v0.4.4
77
github.com/samzong/kitup/go v0.1.1
88
github.com/samzong/kitup/go-cobra v0.1.1
99
github.com/spf13/cobra v1.10.2

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
1717
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
1818
github.com/lathe-cli/lathe v0.4.4-0.20260627231917-297788512b95 h1:MsnLlERtZ4Wwc0PJZpyrPAUhFNtZfB5wROajSnAB/TU=
1919
github.com/lathe-cli/lathe v0.4.4-0.20260627231917-297788512b95/go.mod h1:R7LnEOMjrGHDutF3l2VyY5yc7AAoKLsFSj4JeSuLJRc=
20+
github.com/lathe-cli/lathe v0.4.4 h1:5TNnLpLccH7YAxt3n1Lv5GOrf4i+U264BGvb3v2Haws=
21+
github.com/lathe-cli/lathe v0.4.4/go.mod h1:R7LnEOMjrGHDutF3l2VyY5yc7AAoKLsFSj4JeSuLJRc=
2022
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
2123
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2224
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=

internal/generated/console/console_gen.go

Lines changed: 154 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/generated/consolerest/consolerest_gen.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/generated/threads/threads_gen.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

overlays/console.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,14 @@ commands:
306306
known_errors:
307307
- status: 401
308308
cause: "Missing, invalid, or revoked personal access token."
309+
create-environment:
310+
short: "Create an environment"
311+
long: "Create an environment via the Mosoo Console GraphQL API (Environments surface). Requires a personal access token logged in to the /api host."
312+
notes:
313+
- "Uses POST /graphql on the console default hostname (/api)."
314+
known_errors:
315+
- status: 401
316+
cause: "Missing, invalid, or revoked personal access token."
309317
create-environment-fork:
310318
short: "Create an environment fork"
311319
long: "Create an environment fork via the Mosoo Console GraphQL API (Environments surface). Requires a personal access token logged in to the /api host."
@@ -835,6 +843,14 @@ commands:
835843
known_errors:
836844
- status: 401
837845
cause: "Missing, invalid, or revoked personal access token."
846+
update-environment:
847+
short: "Update an environment"
848+
long: "Update an environment via the Mosoo Console GraphQL API (Environments surface). Requires a personal access token logged in to the /api host."
849+
notes:
850+
- "Uses POST /graphql on the console default hostname (/api)."
851+
known_errors:
852+
- status: 401
853+
cause: "Missing, invalid, or revoked personal access token."
838854
update-profile:
839855
short: "Update a profile"
840856
long: "Update a profile via the Mosoo Console GraphQL API (User surface). Requires a personal access token logged in to the /api host."

publish/skills/mosoo/references/cli.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ Carry these handoff values between workflow sections: `appId`, `agentId`,
5151
`threadId`, `fileId`, env file path, and manifest file path. If any value is
5252
missing, return to the section that produces it instead of guessing.
5353

54+
For deploying a public GitHub repository as an Agent app (Mosoo pulls the repo's
55+
default-branch HEAD, hosts it on a Mosoo-owned Cloudflare URL, and binds the
56+
App's Agents into the deployed app's env): use `Deploy App From Public Repo
57+
Workflow`. It reuses `Agent App Provisioning Workflow` for App/Agent resolution
58+
and adds the manifest, lock file, deploy, and status steps.
59+
5460
## Public API Tokens
5561

5662
`MOSOO_API_TOKEN` is a server-side credential for application backends or
@@ -107,6 +113,90 @@ bodies. If a step fails or times out, inspect state with `console apps app-list`
107113
`console agents accessible-agent-list`, or `console agents agent` before
108114
retrying; do not recreate resources until the current remote state is known.
109115

116+
## Deploy App From Public Repo Workflow
117+
118+
Use this workflow to deploy a public GitHub repository as a Mosoo Agent app.
119+
Mosoo clones the repo's default-branch HEAD, builds and hosts it on a
120+
Mosoo-owned Cloudflare URL, and binds the App's Agents so the deployed app calls
121+
them through injected env vars with no secret in code. v0 deploys public GitHub
122+
repositories only; the deployed commit is always the default-branch HEAD.
123+
124+
The repository carries two files. `.mosoo.toml` is the human-readable product
125+
manifest (committed); `mosoo.lock` is machine-written and stores the resolved
126+
ids so re-deploys reuse the same App and Agents. Commit both.
127+
128+
`.mosoo.toml` (schema v1; names only, never ids):
129+
130+
```toml
131+
schema = 1
132+
name = "roadmap-board"
133+
134+
[deploy]
135+
adapter = "cloudflare-workers"
136+
wrangler = "wrangler.toml"
137+
138+
[[agents]]
139+
name = "roadmap"
140+
expose = "public_thread"
141+
env = "MOSOO_AGENT_ROADMAP_URL"
142+
```
143+
144+
`mosoo.lock` (machine-written; resolved ids):
145+
146+
```toml
147+
schema = 1
148+
app_id = "<resolved-app-id>"
149+
150+
[[agents]]
151+
name = "roadmap"
152+
agent_id = "<resolved-agent-id>"
153+
```
154+
155+
Run the steps in order and save each returned id:
156+
157+
1. Read `.mosoo.toml` for the App `name` and the `[[agents]]` bindings. If
158+
`mosoo.lock` already has an `app_id` or a per-agent `agent_id`, prefer it and
159+
skip resolution for ids already present.
160+
2. Resolve or create the App and each named Agent, and publish each Agent, with
161+
`Agent App Provisioning Workflow` — resolve by name first
162+
(`console apps app-list`, `console agents accessible-agent-list`) and create
163+
only when missing. Every bound Agent must be published before deploy; deploy
164+
fails fast on an unpublished binding.
165+
3. Write `mosoo.lock` with the resolved `app_id` and the `name → agent_id`
166+
mapping. Leave `.mosoo.toml` unchanged (names only).
167+
4. Deploy the repo's default-branch HEAD:
168+
169+
```sh
170+
mosoo console apps deploy-app --input-app-id <app-id> --input-repo-url <https-public-github-url> -o json
171+
```
172+
173+
5. Poll until the run reaches a terminal status (`success` or `failed`):
174+
175+
```sh
176+
mosoo console apps app-deployment-status --app-id <app-id> -o json
177+
```
178+
179+
6. Read the result and report the live URL, deployed commit, bound Agents, and
180+
injected env keys:
181+
182+
```sh
183+
mosoo console apps app-overview --app-id <app-id> -o json
184+
```
185+
186+
`appOverview.deployment` carries the repo, commit, status, and live URL.
187+
`appOverview.boundAgents` carries each bound Agent's `name`, `agentId`,
188+
`expose`, and `envVar` — the env var name only, never the URL value. Print the
189+
live URL, the commit, and the `name → envVar` pairs.
190+
191+
Use `mosoo commands show <path...> --json` before each generated command to
192+
confirm flags and body shape. The two common deploy rejections are a non-public
193+
repo and an unpublished bound Agent; fix the cause, then re-run `deploy-app`
194+
(retry redeploys the default-branch HEAD, it does not roll back). Remove a
195+
deployment with `console apps delete-app-deployment`.
196+
197+
Carry these handoff values: `appId`, per-Agent `agentId`, `.mosoo.toml` path,
198+
`mosoo.lock` path, deploy run status, and the live URL.
199+
110200
## Public Thread File Upload Workflow
111201

112202
For Public Thread file uploads, run the generated commands in order and save the

publish/skills/mosoo/references/cli/modules/console.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
- Pinned tag: `local-snapshot`
99
- Schema: `docs/graphql/console.graphql`
1010
- Expose queries: `accessibleAgentList`, `agent`, `agentChannelBindingList`, `agentCostCard`, `agentEditorState`, `agentManifest`, `agentSessionDiagnostics`, `agentSessionList`, `agentSessionRetrieve`, `appCostCard`, `appDeploymentStatus`, `appEnvironmentList`, `appInfo`, `appList`, `appOverview`, `appSkillList`, `availableAgentModels`, `controlPlaneOverview`, `environment`, `exportAgentPackage`, `fileList`, `listSessionResources`, `mcpOAuthFlowStatus`, `mcpRegistry`, `organizationBillingCostCard`, `session`, `sessionList`, `sessionMessages`, `sessionProcessEvents`, `skillDetail`, `threadAgentSessionList`, `threadAgentSessionRetrieve`, `threadSessionMessages`, `threadSessionProcessEvents`, `vendorCredentialList`, `viewer`
11-
- Expose mutations: `addSessionResource`, `archiveAgentSession`, `autoTitleSession`, `connectMcpBearer`, `createAgent`, `createAgentFork`, `createAgentSession`, `createApp`, `createAppMcpServer`, `createDiscordAgentChannelBinding`, `createEnvironmentFork`, `createLarkAgentChannelBinding`, `createSkillFork`, `createSlackAgentChannelBinding`, `createTelegramAgentChannelBinding`, `createVendorCredential`, `deleteAgent`, `deleteAgentChannelBinding`, `deleteAgentSession`, `deleteAppDeployment`, `deleteEnvironment`, `deleteMcpServer`, `deleteOwnedSkill`, `deleteVendorCredential`, `deployApp`, `importAgentPackage`, `onboardingBootstrap`, `pollLarkAgentChannelRegistration`, `pollWeChatAgentChannelPairing`, `prewarmAgentSession`, `publishAgent`, `recreateSandbox`, `removeSessionResource`, `renameApp`, `renameSession`, `resetAgentState`, `restartDriver`, `revokeMcpCredential`, `setAppDefaultEnvironment`, `setDefaultVendorCredential`, `setEnvironmentVariableValue`, `setMcpServerEnabled`, `setSystemAgentModel`, `startAgentRun`, `startLarkAgentChannelRegistration`, `startMcpOAuth`, `startWeChatAgentChannelPairing`, `testVendorCredential`, `unarchiveAgentSession`, `unpublishAgent`, `updateAgentConfig`, `updateProfile`, `updateVendorCredential`
11+
- Expose mutations: `addSessionResource`, `archiveAgentSession`, `autoTitleSession`, `connectMcpBearer`, `createAgent`, `createAgentFork`, `createAgentSession`, `createApp`, `createAppMcpServer`, `createDiscordAgentChannelBinding`, `createEnvironment`, `createEnvironmentFork`, `createLarkAgentChannelBinding`, `createSkillFork`, `createSlackAgentChannelBinding`, `createTelegramAgentChannelBinding`, `createVendorCredential`, `deleteAgent`, `deleteAgentChannelBinding`, `deleteAgentSession`, `deleteAppDeployment`, `deleteEnvironment`, `deleteMcpServer`, `deleteOwnedSkill`, `deleteVendorCredential`, `deployApp`, `importAgentPackage`, `onboardingBootstrap`, `pollLarkAgentChannelRegistration`, `pollWeChatAgentChannelPairing`, `prewarmAgentSession`, `publishAgent`, `recreateSandbox`, `removeSessionResource`, `renameApp`, `renameSession`, `resetAgentState`, `restartDriver`, `revokeMcpCredential`, `setAppDefaultEnvironment`, `setDefaultVendorCredential`, `setEnvironmentVariableValue`, `setMcpServerEnabled`, `setSystemAgentModel`, `startAgentRun`, `startLarkAgentChannelRegistration`, `startMcpOAuth`, `startWeChatAgentChannelPairing`, `testVendorCredential`, `unarchiveAgentSession`, `unpublishAgent`, `updateAgentConfig`, `updateEnvironment`, `updateProfile`, `updateVendorCredential`
1212
- Group policies: `13`
1313
- Selection policy: max depth `5`
1414
- Resolved SHA: `local-snapshot`
@@ -733,6 +733,26 @@
733733
- Known errors:
734734
- HTTP 401: Missing, invalid, or revoked personal access token.
735735

736+
### `mosoo console environments create-environment`
737+
738+
- Summary: Create an environment
739+
- HTTP: `POST /graphql`
740+
- Auth: required
741+
- Body: required; templated body, set inputs under `variables` with --set/--set-str/--file
742+
- Flags:
743+
- `--input-allow-mcp-servers` (variable, required): input.allowMcpServers
744+
- `--input-allow-package-managers` (variable, required): input.allowPackageManagers
745+
- `--input-allowed-hosts` (variable, required): input.allowedHosts
746+
- `--input-description` (variable): input.description
747+
- `--input-name` (variable, required): input.name
748+
- `--input-network-policy` (variable, required, one of: full|limited): input.networkPolicy
749+
- `--input-app-id` (variable, required): input.appId
750+
- `--input-setup-script` (variable, required): input.setupScript
751+
- Notes:
752+
- Uses POST /graphql on the console default hostname (/api).
753+
- Known errors:
754+
- HTTP 401: Missing, invalid, or revoked personal access token.
755+
736756
### `mosoo console environments create-environment-fork`
737757

738758
- Summary: Create an environment fork
@@ -805,6 +825,27 @@
805825
- Known errors:
806826
- HTTP 401: Missing, invalid, or revoked personal access token.
807827

828+
### `mosoo console environments update-environment`
829+
830+
- Summary: Update an environment
831+
- HTTP: `POST /graphql`
832+
- Auth: required
833+
- Body: required; templated body, set inputs under `variables` with --set/--set-str/--file
834+
- Flags:
835+
- `--input-allow-mcp-servers` (variable, required): input.allowMcpServers
836+
- `--input-allow-package-managers` (variable, required): input.allowPackageManagers
837+
- `--input-allowed-hosts` (variable, required): input.allowedHosts
838+
- `--input-description` (variable): input.description
839+
- `--input-environment-id` (variable, required): input.environmentId
840+
- `--input-name` (variable, required): input.name
841+
- `--input-network-policy` (variable, required, one of: full|limited): input.networkPolicy
842+
- `--input-app-id` (variable, required): input.appId
843+
- `--input-setup-script` (variable, required): input.setupScript
844+
- Notes:
845+
- Uses POST /graphql on the console default hostname (/api).
846+
- Known errors:
847+
- HTTP 401: Missing, invalid, or revoked personal access token.
848+
808849
## Files
809850

810851
### `mosoo console files file-list`

scripts/console-graphql-sources.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import {
1515
} from "../.cache/mosoo/apps/api/src/adapters/graphql/graphql-module-specs.ts";
1616

1717
export const excludedMutations = new Set([
18-
"createEnvironment",
19-
"updateEnvironment",
2018
"sendAgentSessionEvents",
2119
]);
2220

specs/sources.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ sources:
6565
- createApp
6666
- createAppMcpServer
6767
- createDiscordAgentChannelBinding
68+
- createEnvironment
6869
- createEnvironmentFork
6970
- createLarkAgentChannelBinding
7071
- createSkillFork
@@ -106,6 +107,7 @@ sources:
106107
- unarchiveAgentSession
107108
- unpublishAgent
108109
- updateAgentConfig
110+
- updateEnvironment
109111
- updateProfile
110112
- updateVendorCredential
111113
groups:
@@ -149,10 +151,12 @@ sources:
149151
- match:
150152
- environment
151153
- appEnvironmentList
154+
- createEnvironment
152155
- createEnvironmentFork
153156
- deleteEnvironment
154157
- setEnvironmentVariableValue
155158
- setAppDefaultEnvironment
159+
- updateEnvironment
156160
group: Environments
157161
- match:
158162
- fileList

0 commit comments

Comments
 (0)