package calls import ( access "amadan.net/oficina/agent-access.git" "encoding/json" ) func delegatedObject(props map[string]any, required ...string) json.RawMessage { b, _ := json.Marshal(map[string]any{"type": "object", "properties": props, "required": required, "additionalProperties": false}) return b } func delegatedString(max int) map[string]any { return map[string]any{"type": "string", "maxLength": max} } func delegatedInput(props map[string]any, required ...string) json.RawMessage { props["team"] = map[string]any{"type": "string", "minLength": 1, "maxLength": 64} return delegatedObject(props, append([]string{"team"}, required...)...) } var delegatedMeetingSchema = delegatedObject(map[string]any{"sqid": delegatedString(10), "title": delegatedString(200), "starts_at": map[string]any{"type": []string{"string", "null"}}, "ended_at": map[string]any{"type": []string{"string", "null"}}, "created_by": delegatedString(1024), "url": delegatedString(2048)}, "sqid", "title", "starts_at", "ended_at", "created_by", "url") func (a *app) delegatedOperations(team string) []access.Operation { return []access.Operation{ a.delegatedScheduleOperation(team), {Name: "calls_list_meetings", Description: "List this team's meetings visible to a current member. Page with after/next_after; has_more says whether more remain. No invitation tokens or call media are returned.", Scope: "calls:read", ReadOnly: true, Idempotent: true, Input: delegatedInput(map[string]any{"after": map[string]any{"type": "integer", "minimum": 0, "maximum": int64(9223372036854775807)}, "limit": map[string]any{"type": "integer", "minimum": 1, "maximum": 100}}), Output: delegatedObject(map[string]any{"meetings": map[string]any{"type": "array", "items": delegatedMeetingSchema}, "next_after": map[string]any{"type": "integer", "minimum": 0}, "has_more": map[string]any{"type": "boolean"}}, "meetings", "next_after", "has_more"), Invoke: a.delegatedGuard(team, "calls:read", a.delegatedList)}, {Name: "calls_get_meeting", Description: "Read a meeting and its member room URL. Does not disclose a guest invitation or grant access to call media.", Scope: "calls:read", ReadOnly: true, Idempotent: true, Input: delegatedInput(map[string]any{"sqid": delegatedString(10)}, "sqid"), Output: delegatedMeetingSchema, Invoke: a.delegatedGuard(team, "calls:read", a.delegatedGet)}, {Name: "calls_create_meeting", Description: "Create a meeting, optionally with an RFC3339 starts_at including an explicit offset. Reuse a nonzero UUID client_id only for retries with identical fields. Returns the member room URL; creates no Calendar event and sends no invitations.", Scope: "calls:write", Idempotent: true, Input: delegatedInput(map[string]any{"client_id": map[string]any{"type": "string", "minLength": 36, "maxLength": 36}, "title": delegatedString(200), "starts_at": delegatedString(35)}, "client_id", "title"), Output: delegatedObject(map[string]any{"sqid": delegatedString(10), "url": delegatedString(2048), "invitations_sent": map[string]any{"const": false}}, "sqid", "url", "invitations_sent"), Invoke: a.delegatedGuard(team, "calls:write", a.delegatedCreate)}, {Name: "calls_get_join_link", Description: "Retrieve an existing live guest invitation URL. This URL grants invitation access: share only with intended recipients. Requires calls:share. Never creates, replaces or sends a link; unavailable for ended meetings or old invitations without a recoverable token.", Scope: "calls:share", ReadOnly: true, Idempotent: true, Input: delegatedInput(map[string]any{"sqid": delegatedString(10)}, "sqid"), Output: delegatedObject(map[string]any{"sqid": delegatedString(10), "join_url": delegatedString(2048)}, "sqid", "join_url"), Invoke: a.delegatedGuard(team, "calls:share", a.delegatedJoinLink)}, } } func AgentContracts() ([]access.Operation, error) { a := &app{} ops := a.delegatedOperations("contract") scopes := []string{} for _, o := range ops { scopes = append(scopes, o.Scope) } r, err := access.NewRegistry(ops...) if err != nil { return nil, err } return r.List(access.Principal{Subject: "contract", Teams: []string{"contract"}, Scopes: scopes}), nil }