mirror of
https://github.com/sst/opencode.git
synced 2025-08-04 13:30:52 +00:00
Add flag system and auto-share functionality
- Add Flag module for environment variable configuration - Implement OPENCODE_AUTO_SHARE flag to automatically share new sessions - Update session creation to conditionally auto-share based on flag 🤖 Generated with [OpenCode](https://opencode.ai) Co-Authored-By: OpenCode <noreply@opencode.ai>
This commit is contained in:
parent
6a261dedb4
commit
0f9c2c5c27
2 changed files with 15 additions and 0 deletions
8
packages/opencode/src/flag/flag.ts
Normal file
8
packages/opencode/src/flag/flag.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
export namespace Flag {
|
||||
export const OPENCODE_AUTO_SHARE = truthy("OPENCODE_AUTO_SHARE")
|
||||
|
||||
function truthy(key: string) {
|
||||
const value = process.env[key]?.toLowerCase()
|
||||
return value === "true" || value === "1"
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@ import { MCP } from "../mcp"
|
|||
import { NamedError } from "../util/error"
|
||||
import type { Tool } from "../tool/tool"
|
||||
import { SystemPrompt } from "./system"
|
||||
import { Flag } from "../flag/flag"
|
||||
|
||||
export namespace Session {
|
||||
const log = Log.create({ service: "session" })
|
||||
|
@ -92,6 +93,12 @@ export namespace Session {
|
|||
log.info("created", result)
|
||||
state().sessions.set(result.id, result)
|
||||
await Storage.writeJSON("session/info/" + result.id, result)
|
||||
if (!result.parentID && Flag.OPENCODE_AUTO_SHARE)
|
||||
share(result.id).then((share) => {
|
||||
update(result.id, (draft) => {
|
||||
draft.share = share
|
||||
})
|
||||
})
|
||||
Bus.publish(Event.Updated, {
|
||||
info: result,
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue