Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/openbee/ctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func applyCtlTranslations() {
ctlCmd.Short = m.Cmd.Ctl.Short
ctlWorkerCmd.Short = m.Cmd.CtlWorker.Short
ctlTaskCmd.Short = m.Cmd.CtlTask.Short
ctlMemoryCmd.Short = m.Cmd.CtlMemory.Short
ctlConstraintCmd.Short = m.Cmd.CtlConstraint.Short
ctlSessionCmd.Short = m.Cmd.CtlSession.Short
ctlSystemCmd.Short = m.Cmd.CtlSystem.Short
ctlMessageCmd.Short = m.Cmd.CtlMessage.Short
Expand Down
80 changes: 80 additions & 0 deletions cmd/openbee/ctl_constraint.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package main

import (
"github.com/spf13/cobra"
"github.com/theopenbee/openbee/internal/infra/utils"
)

var ctlConstraintCmd = &cobra.Command{Use: "constraint", Short: ""}

var (
constraintGetScope string
constraintGetKey string
)

var ctlConstraintGetCmd = &cobra.Command{
Use: "get",
Short: "Read constraint entries (omit --key to list all in scope)",
RunE: func(cmd *cobra.Command, args []string) error {
a := map[string]any{"scope": constraintGetScope}
if constraintGetKey != "" {
a["key"] = constraintGetKey
}
return ctlRun(utils.GetConstraint, a)
},
}

var (
constraintSaveScope string
constraintSaveKey string
constraintSaveValue string
)

var ctlConstraintSaveCmd = &cobra.Command{
Use: "save",
Short: "Save or update a constraint entry",
RunE: func(cmd *cobra.Command, args []string) error {
return ctlRun(utils.SaveConstraint, map[string]any{
"scope": constraintSaveScope,
"key": constraintSaveKey,
"value": constraintSaveValue,
})
},
}

var (
constraintDeleteScope string
constraintDeleteKey string
)

var ctlConstraintDeleteCmd = &cobra.Command{
Use: "delete",
Short: "Delete a constraint entry",
RunE: func(cmd *cobra.Command, args []string) error {
return ctlRun(utils.DeleteConstraint, map[string]any{
"scope": constraintDeleteScope,
"key": constraintDeleteKey,
})
},
}

func init() {
ctlConstraintGetCmd.Flags().StringVar(&constraintGetScope, "scope", "", "Constraint scope: 'global' or session_key (required)")
ctlConstraintGetCmd.Flags().StringVar(&constraintGetKey, "key", "", "Constraint key (omit to list all in scope)")
ctlConstraintGetCmd.MarkFlagRequired("scope")

ctlConstraintSaveCmd.Flags().StringVar(&constraintSaveScope, "scope", "", "Constraint scope: 'global' or session_key (required)")
ctlConstraintSaveCmd.Flags().StringVar(&constraintSaveKey, "key", "", "Constraint key (required)")
ctlConstraintSaveCmd.Flags().StringVar(&constraintSaveValue, "value", "", "Constraint value (required)")
ctlConstraintSaveCmd.MarkFlagRequired("scope")
ctlConstraintSaveCmd.MarkFlagRequired("key")
ctlConstraintSaveCmd.MarkFlagRequired("value")

ctlConstraintDeleteCmd.Flags().StringVar(&constraintDeleteScope, "scope", "", "Constraint scope: 'global' or session_key (required)")
ctlConstraintDeleteCmd.Flags().StringVar(&constraintDeleteKey, "key", "", "Constraint key (required)")
ctlConstraintDeleteCmd.MarkFlagRequired("scope")
ctlConstraintDeleteCmd.MarkFlagRequired("key")

ctlConstraintCmd.AddCommand(ctlConstraintGetCmd, ctlConstraintSaveCmd, ctlConstraintDeleteCmd)
ctlCmd.AddCommand(ctlConstraintCmd)
}
80 changes: 0 additions & 80 deletions cmd/openbee/ctl_memory.go

This file was deleted.

6 changes: 3 additions & 3 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func BuildApp(cfg config.Config) (*App, error) {
msgingest.WithBotNames(botNames))
localIngest := msgingest.New(s.msgStore, 100*time.Millisecond, cmdChain)

beeMCPSrv := mcp.NewBeeServer(s.workerStore, mgr, s.taskStore, s.msgStore, s.outboundMsgStore, sendersByPlatform, mgr, disp, s.execStore, s.memoryStore, s.sessionStore, s.departmentStore)
beeMCPSrv := mcp.NewBeeServer(s.workerStore, mgr, s.taskStore, s.msgStore, s.outboundMsgStore, sendersByPlatform, mgr, disp, s.execStore, s.constraintStore, s.sessionStore, s.departmentStore)

// Synchronous startup recovery — must run before goroutines start
feeder.RecoverFeeding(context.Background())
Expand Down Expand Up @@ -226,7 +226,7 @@ type appStores struct {
taskStore *store.TaskStore
sessionStore *store.SessionStore
outboundMsgStore *store.OutboundMessageStore
memoryStore *store.MemoryStore
constraintStore *store.ConstraintStore
departmentStore *store.DepartmentStore
statsStore *store.StatsStore
}
Expand All @@ -245,7 +245,7 @@ func buildStores(cfg config.DatabaseConfig) (*sql.DB, appStores, error) {
taskStore: store.NewTaskStore(db),
sessionStore: store.NewSessionStore(db),
outboundMsgStore: store.NewOutboundMessageStore(db),
memoryStore: store.NewMemoryStore(db),
constraintStore: store.NewConstraintStore(db),
departmentStore: store.NewDepartmentStore(db),
statsStore: store.NewStatsStore(db),
}, nil
Expand Down
4 changes: 2 additions & 2 deletions internal/infra/i18n/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ cmd:
short: "Manage workers"
ctl_task:
short: "Manage tasks"
ctl_memory:
short: "Manage memory entries"
ctl_constraint:
short: "Manage constraint entries"
ctl_session:
short: "Manage session contexts"
ctl_system:
Expand Down
4 changes: 2 additions & 2 deletions internal/infra/i18n/locales/zh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ cmd:
short: "管理员工"
ctl_task:
short: "管理任务"
ctl_memory:
short: "管理记忆条目"
ctl_constraint:
short: "管理约束条目"
ctl_session:
short: "管理会话上下文"
ctl_system:
Expand Down
2 changes: 1 addition & 1 deletion internal/infra/i18n/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type CmdMessages struct {
Ctl CmdEntry `yaml:"ctl"`
CtlWorker CmdEntry `yaml:"ctl_worker"`
CtlTask CmdEntry `yaml:"ctl_task"`
CtlMemory CmdEntry `yaml:"ctl_memory"`
CtlConstraint CmdEntry `yaml:"ctl_constraint"`
CtlSession CmdEntry `yaml:"ctl_session"`
CtlSystem CmdEntry `yaml:"ctl_system"`
CtlMessage CmdEntry `yaml:"ctl_message"`
Expand Down
4 changes: 2 additions & 2 deletions internal/infra/skillinstall/skills/openbee-bee/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The user's actual message content
```

- `from` — the platform the message came from (e.g. `feishu`, `telegram`, `local`)
- `session_key` — the session identifier; use this when calling `openbee ctl session list --session-key` or `openbee ctl memory get --scope`
- `session_key` — the session identifier; use this when calling `openbee ctl session list --session-key` or `openbee ctl constraint get --scope`
- `message_id` — use this when calling `openbee ctl message send --message-id` to reply to the user
- The actual user text is inside `<message_content>` — this is what you analyze for task delegation

Expand Down Expand Up @@ -178,7 +178,7 @@ Read these sub-documents on demand when the scenario arises — they are not nee
|-----------------|------|
| Full CLI command syntax, all parameters and examples | `references/cli-reference.md` |
| Handling session clear / context reset operations | `references/session-management.md` |
| Reading or saving memory across sessions | `references/memory-management.md` |
| Reading or saving constraints across sessions | `references/constraint-management.md` |
| Viewing system status, worker load, or execution history | `references/system-status.md` |
| Understanding entity relationships (Message / Task / Execution / Worker) | `references/entity-relationships.md` |
| Creating scheduled / countdown tasks, or filtering tasks by type | `references/task-scheduling.md` |
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ openbee ctl task create --message-id <id> --worker-id <id> --instruction <instru
openbee ctl task cancel <id>
```

## memory subcommand
## constraint subcommand

```bash
openbee ctl memory get --scope <global|session_key> [--key <key>]
openbee ctl memory save --scope <global|session_key> --key <key> --value <value>
openbee ctl memory delete --scope <global|session_key> --key <key>
openbee ctl constraint get --scope <global|session_key> [--key <key>]
openbee ctl constraint save --scope <global|session_key> --key <key> --value <value>
openbee ctl constraint delete --scope <global|session_key> --key <key>
```

## session subcommand
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Constraint Management

You have a persistent constraint system that can accumulate experience and remember user preferences across sessions.

## Usage Rules

- Before processing a message, load relevant constraints:

```bash
openbee ctl constraint get --scope <session_key> # Get user preferences
openbee ctl constraint get --scope global # Get global experience
```

- When you discover user preferences, proactively save them:

```bash
openbee ctl constraint save --scope <scope> --key <key> --value <value>
```

- When reflecting, store conclusions as global constraints; delete stale constraints:

```bash
openbee ctl constraint delete --scope <scope> --key <key>
```

- Use descriptive keys, such as `user_language_preference`, `task_assignment_insight`
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ External Platform

## Practical Implications for the Bee

- Use `session_key` from the incoming `<message_meta>` to scope memory, session, and task queries to the current conversation
- Use `session_key` from the incoming `<message_meta>` to scope constraint, session, and task queries to the current conversation
- When querying task history for a conversation, filter by `--session-key` on `openbee ctl task list`
- When querying outbound message history, use `--source-type worker --source-id <id>` to isolate a specific worker's replies
- `openbee ctl execution list` lets you inspect runtime details (logs, timing, status) for any Worker's executions
Expand Down

This file was deleted.

Loading