feat: IPC additions for reminders/events/routines, ack tracking, tool management
- Extend IPC wire protocol: add ListReminders, ListEvents, ListProposedRoutines, DismissProposedRoutine, AcceptProposedRoutine IPC methods with request/response types. Update wire.go with new message kinds. - Add ack_sends table (migration #5): tracks sev4 telegram repeat-til-ack delivery state with rule name + timestamp, indexed for dedup. - Add Store.DeleteTool: permanently removes a tool row (for dismissing proposed tools), idempotent on missing tool. - Update tick.go: wire new IPC handlers into daemon tick.
This commit is contained in:
@@ -199,6 +199,10 @@ func (a *storeAPI) RevertFact(ctx context.Context, key string) (int64, error) {
|
||||
return newID, mapErr(err)
|
||||
}
|
||||
|
||||
func (a *storeAPI) Chat(ctx context.Context, text string) (string, error) {
|
||||
return "", errors.New("store: chat not available via direct store API")
|
||||
}
|
||||
|
||||
func (a *storeAPI) TickTrace(ctx context.Context) (TickTrace, error) {
|
||||
return TickTrace{}, errors.New("store: tick trace not available via direct store API")
|
||||
}
|
||||
@@ -215,6 +219,36 @@ func (a *storeAPI) ListTools(ctx context.Context, status string) ([]Tool, error)
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (a *storeAPI) DeleteTool(ctx context.Context, name string) error {
|
||||
return mapErr(a.s.DeleteTool(ctx, name))
|
||||
}
|
||||
|
||||
func (a *storeAPI) ListProposedRoutines(ctx context.Context) ([]ProposedRoutine, error) {
|
||||
rs, err := a.s.ListProposedRoutines(ctx)
|
||||
if err != nil {
|
||||
return nil, mapErr(err)
|
||||
}
|
||||
out := make([]ProposedRoutine, len(rs))
|
||||
for i, r := range rs {
|
||||
out[i] = ProposedRoutine{
|
||||
ID: r.ID,
|
||||
Action: r.Action,
|
||||
Object: r.Object,
|
||||
IntervalDays: r.IntervalDays,
|
||||
Status: r.Status,
|
||||
CreatedTs: r.CreatedTs.UnixMilli(),
|
||||
}
|
||||
if r.ReminderID != nil {
|
||||
out[i].ReminderID = r.ReminderID
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (a *storeAPI) DismissProposedRoutine(ctx context.Context, id int64) error {
|
||||
return mapErr(a.s.DismissProposedRoutine(ctx, id))
|
||||
}
|
||||
|
||||
func toTool(t store.Tool) Tool {
|
||||
return Tool{
|
||||
Name: t.Name, Scope: t.Scope, Cmd: t.Cmd, Destructive: t.Destructive,
|
||||
@@ -712,6 +746,30 @@ func (s *Server) dispatch(ctx context.Context, req Request) (json.RawMessage, er
|
||||
}
|
||||
return marshalResult(listToolsResp{Tools: out}), nil
|
||||
|
||||
case MethodDeleteTool:
|
||||
var p disableToolReq
|
||||
if err := unmarshalParams(req.Params, &p); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return marshalResult(nil), api.DeleteTool(ctx, p.Name)
|
||||
|
||||
case MethodListProposedRoutines:
|
||||
out, err := api.ListProposedRoutines(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if out == nil {
|
||||
out = []ProposedRoutine{}
|
||||
}
|
||||
return marshalResult(listProposedRoutinesResp{Routines: out}), nil
|
||||
|
||||
case MethodDismissProposedRoutine:
|
||||
var p dismissProposedRoutineReq
|
||||
if err := unmarshalParams(req.Params, &p); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return marshalResult(nil), api.DismissProposedRoutine(ctx, p.ID)
|
||||
|
||||
case MethodRevertFact:
|
||||
var p struct {
|
||||
Key string `json:"key"`
|
||||
@@ -725,6 +783,17 @@ func (s *Server) dispatch(ctx context.Context, req Request) (json.RawMessage, er
|
||||
}
|
||||
return marshalResult(map[string]int64{"new_id": newID}), nil
|
||||
|
||||
case MethodChat:
|
||||
var p chatReq
|
||||
if err := unmarshalParams(req.Params, &p); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reply, err := api.Chat(ctx, p.Text)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return marshalResult(chatResp{Reply: reply}), nil
|
||||
|
||||
case MethodTickTrace:
|
||||
t, err := api.TickTrace(ctx)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user