Product Station · Productivity

Nextcloud

DemoPlayground

Nextcloud is a demo deployment of Nextcloud, by Convoy AI, for an agency. It holds the agency's files and shares, its Deck boards, and its people's status and absences.

Thanks to this station, any AI agent can also safely search its files and boards, share with colleagues and clients, and run the team's Deck cards. Only the agency's manager shares outside it, five shares a day at most and never the Finances folder, and nothing is shared without the person's own confirmation.

Opened to agents, through a station

Source

API operations

signin

  • sendVerificationCodewritemapped
  • checkVerificationCodewritemapped
  • sendManagerCodewritemapped
  • checkManagerCodewritemapped

core

  • unified_search-searchreadmapped

files

  • api-get-folder-treereadmapped

files_sharing

  • share_info-inforeadmapped
  • shareapi-get-sharesreadmapped
  • shareapi-create-sharewritemapped
  • shareapi-delete-sharewritemapped
  • shareesapi-searchreadmapped

dav

  • direct-get-urlreadmapped
  • out_of_office-get-current-out-of-office-datareadmapped
  • out_of_office-set-out-of-officewritemapped

files_reminders

  • api-setwritemapped

dashboard

  • dashboard_api-get-widget-items-v2readmapped

notifications

  • endpoint-list-notificationsreadmapped

user_status

  • statuses-findreadmapped
  • user_status-get-statusreadmapped
  • user_status-set-custom-messagewritemapped

deck

  • deck-board_api-indexreadmapped
  • deck-stack_api-indexreadmapped
  • deck-card_api-createwritemapped
  • deck-card_api-assign-userwritemapped
  • deck-card_api-reorderwritemapped
  • deck-card_api-archivewritemapped
  • deck-comments_api-createwritemapped
  • deck-search-searchreadmapped

provisioning_api

  • users-get-current-userreadmapped

Not mapped

  • core: 76 operationsnot mapped
  • files: 15 operationsnot mapped
  • files_sharing: 18 operationsnot mapped
  • dav: 3 operationsnot mapped
  • files_reminders: 2 operationsnot mapped
  • dashboard: 6 operationsnot mapped
  • notifications: 11 operationsnot mapped
  • user_status: 7 operationsnot mapped
  • deck: 51 operationsnot mapped
  • provisioning_api: 42 operationsnot mapped
  • theming: 11 operationsnot mapped
  • federatedfilesharing: 9 operationsnot mapped
  • federation: 7 operationsnot mapped
  • cloud_federation_api: 2 operationsnot mapped
  • webhook_listeners: 6 operationsnot mapped
  • user_ldap: 4 operationsnot mapped
  • oauth2: 2 operationsnot mapped
  • password_policy: 2 operationsnot mapped
  • settings: 3 operationsnot mapped
  • updatenotification: 2 operationsnot mapped
  • recommendations: 2 operationsnot mapped
  • weather_status: 7 operationsnot mapped
  • files_external: 1 operationnot mapped

An operation the station does not map is out of every agent's reach.

Capabilities

MCP
Skills and playbooks agents can call
  • public-folderskill

    Read the agency's public press folder: what anyone may see without an account.

    Calls · share_info-info

  • findskill

    Search the workspace: files, Deck cards, calendar events or comments, by words; answers with titles, paths, file ids and links.

    Calls · unified_search-search

  • downloadskill

    Give a one-hour download link for a file, by the file id find answered.

    Calls · direct-get-url

  • my-dayskill

    Say what the person has today and tomorrow: their Deck cards due, their next events, their favourite files.

    Calls · dashboard_api-get-widget-items-v2

  • colleagueskill

    Find a colleague or a group by name, with their user id.

    Calls · shareesapi-search

  • colleague-statusskill

    Say whether a colleague is available: their status and its message, by user id.

    Calls · statuses-find

  • colleague-absenceskill

    Say whether a colleague is away now, until when, and who replaces them, by user id.

    Calls · out_of_office-get-current-out-of-office-data

  • notificationsskill

    Read the person's notifications.

    Calls · endpoint-list-notifications

  • boardsskill

    List the Deck boards the person sees, with their ids.

    Calls · deck-board_api-index

  • filesskill

    Show the person's folders, to share one with a colleague or the team.

    Calls · api-get-folder-tree, shareapi-create-share

  • send-outsideskill

    Find a file to send to a client, then share it by link or by e-mail, with an expiry.

    Calls · unified_search-search, shareapi-create-share

  • sharesskill

    Show the shares the person made, to revoke one.

    Calls · shareapi-get-shares, shareapi-delete-share

  • remindskill

    Find a file and set a reminder on it for a date.

    Calls · unified_search-search, api-set

  • boardskill

    Show the stacks of a Deck board, to add a card to one.

    Calls · deck-stack_api-index, deck-card_api-create

  • move-cardskill

    Find a Deck card by words, to move it to another stack.

    Calls · deck-search-search, deck-card_api-reorder

  • comment-cardskill

    Find a Deck card by words, to comment on it.

    Calls · deck-search-search, deck-comments_api-create

  • assign-cardskill

    Find a Deck card by words, to assign it to a colleague.

    Calls · deck-search-search, deck-card_api-assign-user

  • archive-cardskill

    Find a Deck card by words, to archive it.

    Calls · deck-search-search, deck-card_api-archive

  • awayskill

    Set the person's out-of-office: the days, the message colleagues see, who replaces them.

    Calls · users-get-current-user, out_of_office-set-out-of-office

  • statusskill

    Show the person's status message, to set a new one.

    Calls · user_status-get-status, user_status-set-custom-message

  • send-to-clientplaybook

    Send a deliverable to a client: find it, share it by link or by e-mail, confirm.

    Steps · find, send-outside

  • plan-my-weekplaybook

    Plan the week: what is due, then move or comment on one's cards.

    Steps · my-day, move-card, comment-card

  • going-awayplaybook

    Go away: set the out-of-office, then hand one's open cards to a colleague.

    Steps · away, assign-card

Policies

Checked by the station

At each access

  • Not signed in: may read the agency's public folder only.anonymous
  • Signed in by an email code: may search, read their day, colleagues, notifications and boards, share with colleagues, set reminders, move and comment cards, set their status and their absence.member
  • The agency's manager, proved by a second code on the manager's address: may also share outside the agency, revoke shares, add, assign and archive cards.manager
  • Two one-time codes the app sends and checks itself: the person's email, then the manager's address; the agent never sees a password.identity

At each action

  • The Finances folder is never shared outside the agency.never-finances
  • A share outside the agency never accepts uploads.no-upload-outside
  • A share by email needs the client's address.email-needs-address
  • Five shares outside the agency a day from the conversation; the rest in Nextcloud itself.external-shares-per-day

At the submit

  • Nothing is shared, assigned or changed without the signed-in person's own confirmation.submit_guard

The public folder, without an account

What you will see: An anonymous visitor reads only what the agency made public.

Agent connected to the station through MCP
  1. HumanWhat is in the agency's public folder?
  2. AgentI'll open the public press folder.
  3. MCP callpublic-folder()
  4. StationThe press folder's files, as anyone may see them. No sign-in needed.OKRule applied: profile anonymous

Connect your own agent to the station and test it live.

Try with
Convoy Station · NextcloudTo connect
Step 1: connect to Claude

Open settings, connectors section, add a custom connector and paste the station MCP address.

https://mcp-nextcloud-station.convoy-ai.com/mcp
Step 2: paste a request into Claude
What is in the agency's public folder?
What do I have to do today?
Send the Lumen deliverable to the client by email, [email protected].
Share the Finances folder with the client too.

Then watch the agent: the station refuses, limits or asks for a human, as in the replay.

The configuration in detail

station_config.yamlRead the docs →

Everything the station does fits in this file. The replay above applies it, and a copy starts from it. The values are examples to adapt, not a recommendation.

# Nextcloud: a station in front of a small agency's Nextcloud (Files, Deck, Calendar).
#
# The demo: https://nextcloud.convoy-ai.com, Studio Boréal, a fictional design agency. Léa
# ([email protected]) is on the team, Marc ([email protected]) runs it; a visitor without an account
# sees only the public press folder.
#
# What it shows:
#   · every operation Nextcloud documents (its own OpenAPI documents, as the server ships them) and
#     every Deck route (Deck publishes none: its routes are described from the server) is
#     DESCRIBED below, about 320; only the 29 the skills need are callable, and only for the
#     profiles granted them. User and group administration, app passwords, login flow, 2FA, remote
#     wipe, theming, federation, webhooks, LDAP, push, admin notifications, ownership transfer, the
#     editors and the AI providers are listed `exposed: false`: no agent ever calls them;
#   · every write is a submit the person confirms; the external share is the manager's only, never
#     from Finances, never with upload, five a day at most;
#   · each person signs in as themselves: Nextcloud answers for THEM (their files, their cards).
#
# Signing in. This demo signs people in with a code: the demo's `convoy_demo` app sends it (shown on
# /apps/convoy_demo/demo/inbox) and, on the right code, answers an app password of the account,
# which Convoy sends as `Authorization: Basic …` on that person's calls.

station:
  id: nextcloud   # Convoy sets this to your station's name when you publish
  name: "Nextcloud"
  identity:
    providers:
      # Who the person is: a code to their address, then Nextcloud's app password for them
      # (`access_token`), kept sealed with their sign-in and sent on their calls.
      email:
        mechanism: otp
        verifies: email
        type: email
        via: tenant
        send: sendVerificationCode
        check: checkVerificationCode
        credential: access_token
      # That they manage the agency: a second code, sent only to a member of Nextcloud's own
      # `direction` group. Convoy's profiles read which data were proved, never a role; so Nextcloud
      # decides who holds `manager`, and the station only reads the proof.
      manager:
        mechanism: otp
        verifies: manager_email
        type: email
        via: tenant
        send: sendManagerCode
        check: checkManagerCode

global:
  language: fr
  languages: [fr, en]
  locale: fr-FR

domain:
  domain_type: saas
  entity_name: file
  entity_name_plural: files

voice:
  tone: professional
  persona: "an agency's office manager: precise, brief, never shares more than asked"
  rules:
    - "Never share a file the person has not chosen, and never outside the agency unless they ask."
    - "Repeat Nextcloud's own sentence when it refuses, without rewording it."
    - "Name a file by its path, a card by its title and its board."
  emoji: false

apis:
  # the demo's sign-in bridge (convoy_demo app): two proofs, no Nextcloud operation. 4 operations.
  - name: signin
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/convoy_demo.json"
    base_url: "https://nextcloud.convoy-ai.com"
    operations:
      - {id: sendVerificationCode, access: write}
      - {id: checkVerificationCode, access: write}
      - {id: sendManagerCode, access: write}
      - {id: checkManagerCode, access: write}
  # unified search, previews, avatars, profiles, app passwords, login flow, AI tasks. 77 operations.
  - name: core
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/core.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      - {id: unified_search-search, access: read}
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: app_password-get-app-password, access: read, exposed: false}
      - {id: app_password-delete-app-password, access: write, exposed: false}
      - {id: app_password-rotate-app-password, access: write, exposed: false}
      - {id: app_password-confirm-user-password, access: write, exposed: false}
      - {id: auto_complete-get, access: read, exposed: false}
      - {id: collaboration_resources-list-collection, access: read, exposed: false}
      - {id: collaboration_resources-add-resource, access: write, exposed: false}
      - {id: collaboration_resources-remove-resource, access: write, exposed: false}
      - {id: collaboration_resources-rename-collection, access: write, exposed: false}
      - {id: collaboration_resources-search-collections, access: read, exposed: false}
      - {id: collaboration_resources-get-collections-by-resource, access: read, exposed: false}
      - {id: collaboration_resources-create-collection-on-resource, access: write, exposed: false}
      - {id: hover_card-get-user, access: read, exposed: false}
      - {id: navigation-get-apps-navigation, access: read, exposed: false}
      - {id: navigation-get-settings-navigation, access: read, exposed: false}
      - {id: ocs-get-capabilities, access: read, exposed: false}
      - {id: profile_api-set-visibility, access: write, exposed: false}
      - {id: profile_api-get-profile-fields, access: read, exposed: false}
      - {id: reference_api-extract, access: write, exposed: false}
      - {id: reference_api-extract-public, access: write, exposed: false}
      - {id: reference_api-resolve-one, access: read, exposed: false}
      - {id: reference_api-resolve, access: write, exposed: false}
      - {id: reference_api-resolve-one-public, access: read, exposed: false}
      - {id: reference_api-resolve-public, access: write, exposed: false}
      - {id: reference_api-get-providers-info, access: read, exposed: false}
      - {id: reference_api-touch-provider, access: write, exposed: false}
      - {id: task_processing_api-task-types, access: read, exposed: false}
      - {id: task_processing_api-schedule, access: write, exposed: false}
      - {id: task_processing_api-get-task, access: read, exposed: false}
      - {id: task_processing_api-delete-task, access: write, exposed: false}
      - {id: task_processing_api-list-tasks-by-app, access: read, exposed: false}
      - {id: task_processing_api-list-tasks, access: read, exposed: false}
      - {id: task_processing_api-get-file-contents, access: read, exposed: false}
      - {id: task_processing_api-cancel-task, access: write, exposed: false}
      - {id: teams_api-resolve-one, access: read, exposed: false}
      - {id: teams_api-list-teams, access: read, exposed: false}
      - {id: text_processing_api-task-types, access: read, exposed: false}
      - {id: text_processing_api-schedule, access: write, exposed: false}
      - {id: text_processing_api-get-task, access: read, exposed: false}
      - {id: text_processing_api-delete-task, access: write, exposed: false}
      - {id: text_processing_api-list-tasks-by-app, access: read, exposed: false}
      - {id: text_to_image_api-is-available, access: read, exposed: false}
      - {id: text_to_image_api-schedule, access: write, exposed: false}
      - {id: text_to_image_api-get-task, access: read, exposed: false}
      - {id: text_to_image_api-delete-task, access: write, exposed: false}
      - {id: text_to_image_api-get-image, access: read, exposed: false}
      - {id: text_to_image_api-list-tasks-by-app, access: read, exposed: false}
      - {id: translation_api-languages, access: read, exposed: false}
      - {id: translation_api-translate, access: write, exposed: false}
      - {id: unified_search-get-providers, access: read, exposed: false}
      - {id: whats_new-get, access: read, exposed: false}
      - {id: whats_new-dismiss, access: write, exposed: false}
      - {id: avatar-get-avatar-dark, access: read, exposed: false}
      - {id: avatar-get-avatar, access: read, exposed: false}
      - {id: csrf_token-index, access: read, exposed: false}
      - {id: client_flow_login_v2-poll, access: write, exposed: false}
      - {id: client_flow_login_v2-init, access: write, exposed: false}
      - {id: guest_avatar-get-avatar, access: read, exposed: false}
      - {id: guest_avatar-get-avatar-dark, access: read, exposed: false}
      - {id: login-confirm-password, access: write, exposed: false}
      - {id: ocm-discovery, access: read, exposed: false}
      - {id: preview-get-preview, access: read, exposed: false}
      - {id: preview-get-preview-by-file-id, access: read, exposed: false}
      - {id: preview-get-mime-icon-url, access: read, exposed: false}
      - {id: reference-preview, access: read, exposed: false}
      - {id: wipe-check-wipe, access: write, exposed: false}
      - {id: wipe-wipe-done, access: write, exposed: false}
      - {id: get-status, access: read, exposed: false}
      - {id: task_processing_api-get-file-contents-ex-app, access: read, exposed: false}
      - {id: task_processing_api-set-file-contents-ex-app, access: write, exposed: false}
      - {id: task_processing_api-set-progress, access: write, exposed: false}
      - {id: task_processing_api-set-result, access: write, exposed: false}
      - {id: task_processing_api-get-next-scheduled-task, access: read, exposed: false}
      - {id: two_factor_api-state, access: read, exposed: false}
      - {id: two_factor_api-enable, access: write, exposed: false}
      - {id: two_factor_api-disable, access: write, exposed: false}
  # folder tree, templates, direct editing, ownership transfer, conversion. 16 operations.
  - name: files
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/files.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      - {id: api-get-folder-tree, access: read}
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: api-get-thumbnail, access: read, exposed: false}
      - {id: direct_editing-info, access: read, exposed: false}
      - {id: direct_editing-templates, access: read, exposed: false}
      - {id: direct_editing-open, access: write, exposed: false}
      - {id: direct_editing-create, access: write, exposed: false}
      - {id: template-list, access: read, exposed: false}
      - {id: template-list-template-fields, access: read, exposed: false}
      - {id: template-create, access: write, exposed: false}
      - {id: template-path, access: write, exposed: false}
      - {id: transfer_ownership-transfer, access: write, exposed: false}
      - {id: transfer_ownership-accept, access: write, exposed: false}
      - {id: transfer_ownership-reject, access: write, exposed: false}
      - {id: open_local_editor-create, access: write, exposed: false}
      - {id: open_local_editor-validate, access: write, exposed: false}
      - {id: conversion_api-convert, access: write, exposed: false}
  # shares: list, create, update, delete, sharees, public share info. 23 operations.
  - name: files_sharing
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/files_sharing.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      - {id: share_info-info, access: read}  # a POST that only reads: what a public link shows
      - {id: shareapi-get-shares, access: read}
      - {id: shareapi-create-share, access: write, reversible: shareapi-delete-share}
      - {id: shareapi-delete-share, access: write, reversible: false}
      - {id: shareesapi-search, access: read}
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: public_preview-direct-link, access: read, exposed: false}
      - {id: public_preview-get-preview, access: read, exposed: false}
      - {id: shareapi-get-inherited-shares, access: read, exposed: false}
      - {id: shareapi-pending-shares, access: read, exposed: false}
      - {id: shareapi-get-share, access: read, exposed: false}
      - {id: shareapi-update-share, access: write, exposed: false}
      - {id: shareapi-send-share-email, access: write, exposed: false}
      - {id: shareapi-accept-share, access: write, exposed: false}
      - {id: deleted_shareapi-index, access: read, exposed: false}
      - {id: deleted_shareapi-undelete, access: write, exposed: false}
      - {id: shareesapi-find-recommended, access: read, exposed: false}
      - {id: remote-get-shares, access: read, exposed: false}
      - {id: remote-get-open-shares, access: read, exposed: false}
      - {id: remote-accept-share, access: write, exposed: false}
      - {id: remote-decline-share, access: write, exposed: false}
      - {id: remote-get-share, access: read, exposed: false}
      - {id: remote-unshare, access: write, exposed: false}
      - {id: shareapi-generate-token, access: read, exposed: false}
  # upcoming events, out-of-office, direct download link. 6 operations.
  - name: dav
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/dav.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      - {id: direct-get-url, access: read}  # a POST that changes no file: it mints a one-hour download link
      - {id: out_of_office-get-current-out-of-office-data, access: read}
      - {id: out_of_office-set-out-of-office, access: write}
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: upcoming_events-get-events, access: read, exposed: false}
      - {id: out_of_office-get-out-of-office, access: read, exposed: false}
      - {id: out_of_office-clear-out-of-office, access: write, exposed: false}
  # reminders on a file. 3 operations.
  - name: files_reminders
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/files_reminders.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      - {id: api-set, access: write}
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: api-get, access: read, exposed: false}
      - {id: api-remove, access: write, exposed: false}
  # dashboard widgets and their items. 7 operations.
  - name: dashboard
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/dashboard.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      - {id: dashboard_api-get-widget-items-v2, access: read}
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: dashboard_api-get-widget-items, access: read, exposed: false}
      - {id: dashboard_api-get-widgets, access: read, exposed: false}
      - {id: dashboard_api-get-layout, access: read, exposed: false}
      - {id: dashboard_api-update-layout, access: write, exposed: false}
      - {id: dashboard_api-get-statuses, access: read, exposed: false}
      - {id: dashboard_api-update-statuses, access: write, exposed: false}
  # notifications; admin and push. 12 operations.
  - name: notifications
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/notifications.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      - {id: endpoint-list-notifications, access: read}
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: endpoint-delete-all-notifications, access: write, exposed: false}
      - {id: endpoint-get-notification, access: read, exposed: false}
      - {id: endpoint-delete-notification, access: write, exposed: false}
      - {id: endpoint-confirm-ids-for-user, access: write, exposed: false}
      - {id: settings-personal, access: write, exposed: false}
      - {id: api-generate-notification, access: write, exposed: false}
      - {id: api-generate-notification-v3, access: write, exposed: false}
      - {id: settings-admin, access: write, exposed: false}
      - {id: api-self-test-push, access: write, exposed: false}
      - {id: push-register-device, access: write, exposed: false}
      - {id: push-remove-device, access: write, exposed: false}
  # online status and status messages. 10 operations.
  - name: user_status
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/user_status.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      - {id: statuses-find, access: read}
      - {id: user_status-get-status, access: read}
      - {id: user_status-set-custom-message, access: write}
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: heartbeat-heartbeat, access: write, exposed: false}
      - {id: predefined_status-find-all, access: read, exposed: false}
      - {id: statuses-find-all, access: read, exposed: false}
      - {id: user_status-set-status, access: write, exposed: false}
      - {id: user_status-set-predefined-message, access: write, exposed: false}
      - {id: user_status-clear-message, access: write, exposed: false}
      - {id: user_status-revert-status, access: write, exposed: false}
  # Deck REST and OCS: Deck publishes no OpenAPI; its routes are described here. 59 operations.
  - name: deck
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/deck.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      - {id: deck-board_api-index, access: read}
      - {id: deck-stack_api-index, access: read}
      - {id: deck-card_api-create, access: write}
      - {id: deck-card_api-assign-user, access: write}
      - {id: deck-card_api-reorder, access: write}
      - {id: deck-card_api-archive, access: write}
      - {id: deck-comments_api-create, access: write}
      - {id: deck-search-search, access: read}
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: deck-board_api-create, access: write, exposed: false}
      - {id: deck-board_api-get, access: read, exposed: false}
      - {id: deck-board_api-delete, access: write, exposed: false}
      - {id: deck-board_api-update, access: write, exposed: false}
      - {id: deck-board_api-undo-delete, access: write, exposed: false}
      - {id: deck-board_api-add-acl, access: write, exposed: false}
      - {id: deck-board_api-delete-acl, access: write, exposed: false}
      - {id: deck-board_api-update-acl, access: write, exposed: false}
      - {id: deck-board_import_api-get-allowed-systems, access: read, exposed: false}
      - {id: deck-board_import_api-get-config-schema, access: read, exposed: false}
      - {id: deck-board_import_api-import, access: write, exposed: false}
      - {id: deck-stack_api-create, access: write, exposed: false}
      - {id: deck-stack_api-get-archived, access: read, exposed: false}
      - {id: deck-stack_api-get, access: read, exposed: false}
      - {id: deck-stack_api-update, access: write, exposed: false}
      - {id: deck-stack_api-delete, access: write, exposed: false}
      - {id: deck-card_api-get, access: read, exposed: false}
      - {id: deck-card_api-update, access: write, exposed: false}
      - {id: deck-card_api-delete, access: write, exposed: false}
      - {id: deck-card_api-assign-label, access: write, exposed: false}
      - {id: deck-card_api-remove-label, access: write, exposed: false}
      - {id: deck-card_api-unassign-user, access: write, exposed: false}
      - {id: deck-card_api-unarchive, access: write, exposed: false}
      - {id: deck-card_api-find-all-with-due, access: read, exposed: false}
      - {id: deck-label_api-get, access: read, exposed: false}
      - {id: deck-label_api-update, access: write, exposed: false}
      - {id: deck-label_api-delete, access: write, exposed: false}
      - {id: deck-label_api-create, access: write, exposed: false}
      - {id: deck-attachment_api-get-all, access: read, exposed: false}
      - {id: deck-attachment_api-create, access: write, exposed: false}
      - {id: deck-attachment_api-display, access: read, exposed: false}
      - {id: deck-attachment_api-update, access: write, exposed: false}
      - {id: deck-attachment_api-delete, access: write, exposed: false}
      - {id: deck-attachment_api-restore, access: write, exposed: false}
      - {id: deck-attachment_api_v11-get-all, access: read, exposed: false}
      - {id: deck-attachment_api_v11-create, access: write, exposed: false}
      - {id: deck-attachment_api_v11-display, access: read, exposed: false}
      - {id: deck-attachment_api_v11-update, access: write, exposed: false}
      - {id: deck-attachment_api_v11-delete, access: write, exposed: false}
      - {id: deck-attachment_api_v11-restore, access: write, exposed: false}
      - {id: deck-board_api-preflighted-cors, access: read, exposed: false}
      - {id: deck-config-get, access: read, exposed: false}
      - {id: deck-config-set-value, access: write, exposed: false}
      - {id: deck-comments_api-list, access: read, exposed: false}
      - {id: deck-comments_api-update, access: write, exposed: false}
      - {id: deck-comments_api-delete, access: write, exposed: false}
      - {id: deck-card-clone, access: write, exposed: false}
      - {id: deck-overview_api-upcoming-cards, access: read, exposed: false}
      - {id: deck-session-create, access: write, exposed: false}
      - {id: deck-session-sync, access: write, exposed: false}
      - {id: deck-session-close, access: write, exposed: false}
  # users and groups: never an agent's. 43 operations.
  - name: provisioning_api
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/provisioning_api.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      - {id: users-get-current-user, access: read}
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: apps-get-apps, access: read, exposed: false}
      - {id: apps-get-app-info, access: read, exposed: false}
      - {id: apps-enable, access: write, exposed: false}
      - {id: apps-disable, access: write, exposed: false}
      - {id: groups-get-sub-admins-of-group, access: read, exposed: false}
      - {id: groups-get-groups, access: read, exposed: false}
      - {id: groups-get-group, access: read, exposed: false}
      - {id: users-get-last-logged-in-users, access: read, exposed: false}
      - {id: users-get-user-sub-admin-groups, access: read, exposed: false}
      - {id: users-add-sub-admin, access: write, exposed: false}
      - {id: users-remove-sub-admin, access: write, exposed: false}
      - {id: app_config-get-apps, access: read, exposed: false}
      - {id: app_config-get-keys, access: read, exposed: false}
      - {id: app_config-set-value, access: write, exposed: false}
      - {id: groups-get-groups-details, access: read, exposed: false}
      - {id: groups-get-group-users, access: read, exposed: false}
      - {id: groups-get-group-users-details, access: read, exposed: false}
      - {id: users-get-users, access: read, exposed: false}
      - {id: users-add-user, access: write, exposed: false}
      - {id: users-get-users-details, access: read, exposed: false}
      - {id: users-get-disabled-users-details, access: read, exposed: false}
      - {id: users-search-by-phone-numbers, access: write, exposed: false}
      - {id: users-get-user, access: read, exposed: false}
      - {id: users-edit-user, access: write, exposed: false}
      - {id: users-delete-user, access: write, exposed: false}
      - {id: users-get-editable-fields, access: read, exposed: false}
      - {id: users-get-editable-fields-for-user, access: read, exposed: false}
      - {id: users-get-enabled-apps, access: read, exposed: false}
      - {id: users-edit-user-multi-value, access: write, exposed: false}
      - {id: users-wipe-user-devices, access: write, exposed: false}
      - {id: users-enable-user, access: write, exposed: false}
      - {id: users-disable-user, access: write, exposed: false}
      - {id: users-get-users-groups, access: read, exposed: false}
      - {id: users-add-to-group, access: write, exposed: false}
      - {id: users-remove-from-group, access: write, exposed: false}
      - {id: users-get-users-groups-details, access: read, exposed: false}
      - {id: users-get-user-sub-admin-groups-details, access: read, exposed: false}
      - {id: users-resend-welcome-message, access: write, exposed: false}
      - {id: preferences-set-preference, access: write, exposed: false}
      - {id: preferences-delete-preference, access: write, exposed: false}
      - {id: preferences-set-multiple-preferences, access: write, exposed: false}
      - {id: preferences-delete-multiple-preference, access: write, exposed: false}
  # theme and appearance. 11 operations.
  - name: theming
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/theming.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: theming-get-theme-stylesheet, access: read, exposed: false}
      - {id: theming-get-image, access: read, exposed: false}
      - {id: theming-get-manifest, access: read, exposed: false}
      - {id: icon-get-favicon, access: read, exposed: false}
      - {id: icon-get-touch-icon, access: read, exposed: false}
      - {id: icon-get-themed-icon, access: read, exposed: false}
      - {id: user_theme-get-background, access: read, exposed: false}
      - {id: user_theme-set-background, access: write, exposed: false}
      - {id: user_theme-delete-background, access: write, exposed: false}
      - {id: user_theme-enable-theme, access: write, exposed: false}
      - {id: user_theme-disable-theme, access: write, exposed: false}
  # federated share settings: never an agent's. 9 operations.
  - name: federatedfilesharing
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/federatedfilesharing.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: mount_public_link-create-federated-share, access: write, exposed: false}
      - {id: request_handler-create-share, access: write, exposed: false}
      - {id: request_handler-re-share, access: write, exposed: false}
      - {id: request_handler-update-permissions, access: write, exposed: false}
      - {id: request_handler-accept-share, access: write, exposed: false}
      - {id: request_handler-decline-share, access: write, exposed: false}
      - {id: request_handler-unshare, access: write, exposed: false}
      - {id: request_handler-revoke, access: write, exposed: false}
      - {id: request_handler-move, access: write, exposed: false}
  # trusted servers (admin): never an agent's. 7 operations.
  - name: federation
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/federation.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: ocs_authapi-get-shared-secret-legacy, access: read, exposed: false}
      - {id: ocs_authapi-request-shared-secret-legacy, access: write, exposed: false}
      - {id: ocs_authapi-get-shared-secret, access: read, exposed: false}
      - {id: ocs_authapi-request-shared-secret, access: write, exposed: false}
      - {id: settings-add-server, access: write, exposed: false}
      - {id: settings-get-servers, access: read, exposed: false}
      - {id: settings-remove-server, access: write, exposed: false}
  # federation protocol: never an agent's. 2 operations.
  - name: cloud_federation_api
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/cloud_federation_api.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: request_handler-add-share, access: write, exposed: false}
      - {id: request_handler-receive-notification, access: write, exposed: false}
  # webhooks (admin): never an agent's. 6 operations.
  - name: webhook_listeners
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/webhook_listeners.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: webhooks-index, access: read, exposed: false}
      - {id: webhooks-create, access: write, exposed: false}
      - {id: webhooks-show, access: read, exposed: false}
      - {id: webhooks-update, access: write, exposed: false}
      - {id: webhooks-destroy, access: write, exposed: false}
      - {id: webhooks-delete-by-app-id, access: write, exposed: false}
  # LDAP configuration (admin): never an agent's. 4 operations.
  - name: user_ldap
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/user_ldap.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: configapi-create, access: write, exposed: false}
      - {id: configapi-show, access: read, exposed: false}
      - {id: configapi-modify, access: write, exposed: false}
      - {id: configapi-delete, access: write, exposed: false}
  # OAuth2 clients (admin): never an agent's. 2 operations.
  - name: oauth2
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/oauth2.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: login_redirector-authorize, access: read, exposed: false}
      - {id: oauth_api-get-token, access: write, exposed: false}
  # password policy. 2 operations.
  - name: password_policy
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/password_policy.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: api-generate, access: read, exposed: false}
      - {id: api-validate, access: write, exposed: false}
  # settings helpers (admin). 3 operations.
  - name: settings
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/settings.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: log_settings-download, access: read, exposed: false}
      - {id: declarative_settings-set-value, access: write, exposed: false}
      - {id: declarative_settings-get-forms, access: read, exposed: false}
  # update notices (admin). 2 operations.
  - name: updatenotification
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/updatenotification.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: api-get-app-list, access: read, exposed: false}
      - {id: api-get-app-changelog-entry, access: read, exposed: false}
  # recommended files. 2 operations.
  - name: recommendations
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/recommendations.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: recommendation-always, access: read, exposed: false}
      - {id: recommendation-index, access: read, exposed: false}
  # the weather widget. 7 operations.
  - name: weather_status
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/weather_status.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: weather_status-set-mode, access: write, exposed: false}
      - {id: weather_status-use-personal-address, access: write, exposed: false}
      - {id: weather_status-get-location, access: read, exposed: false}
      - {id: weather_status-set-location, access: write, exposed: false}
      - {id: weather_status-get-forecast, access: read, exposed: false}
      - {id: weather_status-get-favorites, access: read, exposed: false}
      - {id: weather_status-set-favorites, access: write, exposed: false}
  # external storages. 1 operations.
  - name: files_external
    openapi_url: "https://nextcloud.convoy-ai.com/_openapi/files_external.json"
    base_url: "https://nextcloud.convoy-ai.com"
    auth: {person: {provider: email, scheme: Basic}}
    operations:
      # Described, never called: no skill, no grant (`exposed: false`).
      - {id: api-get-user-mounts, access: read, exposed: false}

# Who may call what. Closed by default: the ~290 operations above that no profile is granted are
# called for no one. A member (anyone signed in) reads and makes the team's own writes; the manager
# adds the writes that leave the team or remove something.
profiles:
  anonymous:
    when: "$identity.authenticated == false"
    grants:
      - files_sharing.share_info-info
  member:
    when: "$identity.authenticated"
    grants:
      - files_sharing.share_info-info
      - core.unified_search-search
      - dav.direct-get-url
      - dashboard.dashboard_api-get-widget-items-v2
      - files_sharing.shareesapi-search
      - user_status.statuses-find
      - dav.out_of_office-get-current-out-of-office-data
      - notifications.endpoint-list-notifications
      - files.api-get-folder-tree
      - files_sharing.shareapi-create-share
      - files_sharing.shareapi-get-shares
      - files_reminders.api-set
      - deck.deck-board_api-index
      - deck.deck-search-search
      - deck.deck-card_api-reorder
      - deck.deck-comments_api-create
      - provisioning_api.users-get-current-user
      - dav.out_of_office-set-out-of-office
      - user_status.user_status-get-status
      - user_status.user_status-set-custom-message
  manager:
    when: "'manager_email' in $identity.verified"
    grants:
      - core.unified_search-search
      - files_sharing.shareapi-create-share
      - files_sharing.shareapi-get-shares
      - files_sharing.shareapi-delete-share
      - deck.deck-stack_api-index
      - deck.deck-card_api-create
      - deck.deck-search-search
      - deck.deck-card_api-assign-user
      - deck.deck-card_api-archive

# Reusable policies, cited where they apply (the `send-outside` skill). Rules Convoy applies whatever
# the model says, journalled by name.
policies:
  # Finances never leaves the agency, whatever is asked.
  never-finances:
    require: "'/finances' not in $item.fields.path"
    reason: "the Finances folder is never shared outside the agency"
  # A share outside never takes uploads: the client reads, nothing comes back in.
  no-upload-outside:
    require: "$item.fields.allow_upload != true"
    reason: "a share outside the agency never accepts uploads"
  # By e-mail needs the address.
  email-needs-address:
    require: "$item.fields.share_type == 3 or $item.fields.share_with != null"
    reason: "a share by e-mail needs the client's address"
  # Five external shares a day per signed-in person (`scope: identity`, one per share).
  external-shares-per-day:
    budget: {count: true, per: day, scope: identity, max: 5}
    reason: "five shares outside the agency a day from the conversation; the rest in Nextcloud itself"
  # The expiry: the form asks for one (required); its 7-day ceiling is Nextcloud's own setting
  # (shareapi_enforce_expire_date, 7 days).

skills:
  # --- reads that answer: nothing to choose, the model says the answer -------------------------

  - name: public-folder
    cognitive:
      objective: "read the agency's public press folder: what anyone may see without an account"
    invoke:
      method: share_info-info
      args: {body.t: agencepresse, body.depth: 2}

  - name: find
    cognitive:
      objective: "search the workspace: files, Deck cards, calendar events or comments, by words; answers with titles, paths, file ids and links"
      diagnose: [what to look for, where (files, cards, events or comments)]
    params:
      where: {type: text, set_by: [agent]}
      words: {type: text, set_by: [agent]}
    invoke:
      method: unified_search-search
      args: {providerId: "$params.where", term: "$params.words", limit: 10}

  - name: download
    cognitive:
      objective: "give a one-hour download link for a file, by the file id `find` answered"
    params:
      file_id: {type: integer, set_by: [agent]}
    invoke:
      method: direct-get-url
      args: {body.fileId: "$params.file_id", body.expirationTime: 3600}

  - name: my-day
    cognitive:
      objective: "say what the person has today and tomorrow: their Deck cards due, their next events, their favourite files"
    # Every widget's items (Deck today and tomorrow, calendar, favourite files, …): a config sends
    # no list literal, so `widgets[]` is left to its default, all of them.
    invoke:
      method: dashboard_api-get-widget-items-v2

  - name: colleague
    cognitive:
      objective: "find a colleague or a group by name, with their user id"
    params:
      who: {type: text, set_by: [agent]}
    invoke:
      method: shareesapi-search
      args: {search: "$params.who", itemType: file, perPage: 10}

  - name: colleague-status
    cognitive:
      objective: "say whether a colleague is available: their status and its message, by user id"
    params:
      user: {type: text, set_by: [agent]}
    invoke:
      method: statuses-find
      args: {userId: "$params.user"}

  - name: colleague-absence
    cognitive:
      objective: "say whether a colleague is away now, until when, and who replaces them, by user id"
    params:
      user: {type: text, set_by: [agent]}
    invoke:
      method: out_of_office-get-current-out-of-office-data
      args: {userId: "$params.user"}

  - name: notifications
    cognitive:
      objective: "read the person's notifications"
    invoke:
      method: endpoint-list-notifications
      args: {apiVersion: v2}

  - name: boards
    cognitive:
      objective: "list the Deck boards the person sees, with their ids"
    invoke:
      method: deck-board_api-index

  # --- reads the person chooses from, each filing one write on their confirmation --------------

  # Share a folder inside the team: with a colleague (0) or a group (1).
  - name: files
    cognitive:
      objective: "show the person's folders, to share one with a colleague or the team"
    params:
      path: {type: text, set_by: [agent], required: false}
    invoke:
      method: api-get-folder-tree
      args: {path: "$params.path", depth: 2}
    kinds: {folder: {}}
    present:
      fields:
        name: {from: basename, type: text, role: title}
        children: {from: children, type: text, display: tree}
    select:
      max_items: 1
      quantity: {max: 1}
      guards:
        - form:
            share_with: {type: text, required: true, label: "With whom: a colleague's user id, or the group agence"}
            share_type: {type: integer, required: true, enum: [0, 1], label: "0: a colleague, 1: a group"}
    submit:
      - name: share-in-team
        tool: shareapi-create-share
        args:
          body.path: "$item.fields.name"
          body.shareType: "$item.fields.share_type"
          body.shareWith: "$item.fields.share_with"
    render: {component: cards}

  # The manager's only: a file to a client, by link (3) or by e-mail (4).
  - name: send-outside
    cognitive:
      objective: "find a file to send to a client, then share it by link or by e-mail, with an expiry"
      diagnose: [the file, the client, by link or by e-mail]
    params:
      words: {type: text, set_by: [agent]}
    invoke:
      method: unified_search-search
      args: {providerId: files, term: "$params.words", limit: 10}
    kinds: {outside-share: {}}
    present:
      fields:
        name: {from: title, type: text, role: title}
        place: {from: subline, type: text, role: meta}
        path: {from: attributes.path, type: text}
        link: {from: resourceUrl, type: url}
    select:
      max_items: 1
      quantity: {max: 1}
      guards:
        - permission: {profiles: [manager]}
          reason: "only the agency's manager shares outside the agency"
        - {policy: never-finances}
        - form:
            share_type: {type: integer, required: true, enum: [3, 4], label: "3: a public link, 4: by e-mail"}
            share_with: {type: email, required: false, label: "The client's e-mail (by e-mail only)"}
            expire_date: {type: datetime, required: true, label: "Expires on (YYYY-MM-DD, within 7 days)"}
            allow_upload: {type: boolean, required: false, label: "Let them upload"}
        - {policy: no-upload-outside}
        - {policy: email-needs-address}
        - {policy: external-shares-per-day}
    submit:
      - name: share-outside
        tool: shareapi-create-share
        args:
          body.path: "$item.fields.path"
          body.shareType: "$item.fields.share_type"
          body.shareWith: "$item.fields.share_with"
          body.expireDate: "$item.fields.expire_date"
          body.permissions: "1"
          body.publicUpload: "false"
    render: {component: cards}

  # The manager revokes a share.
  - name: shares
    cognitive:
      objective: "show the shares the person made, to revoke one"
    invoke:
      method: shareapi-get-shares
    kinds: {share: {}}
    present:
      fields:
        name: {from: path, type: text, role: title}
        with: {from: share_with_displayname, type: text, role: meta}
        expires: {from: expiration, type: text}
        link: {from: url, type: url}
    select:
      max_items: 1
      quantity: {max: 1}
      guards:
        - permission: {profiles: [manager]}
          reason: "only the agency's manager revokes a share"
    submit:
      - name: revoke
        tool: shareapi-delete-share
        args: {id: "$item.fields.id"}
    render: {component: cards}

  - name: remind
    cognitive:
      objective: "find a file and set a reminder on it for a date"
    params:
      words: {type: text, set_by: [agent]}
    invoke:
      method: unified_search-search
      args: {providerId: files, term: "$params.words", limit: 10}
    kinds: {reminder: {}}
    present:
      fields:
        name: {from: title, type: text, role: title}
        place: {from: subline, type: text, role: meta}
        file_id: {from: attributes.fileId, type: id}
    select:
      max_items: 1
      quantity: {max: 1}
      guards:
        - form:
            due_date: {type: datetime, required: true, label: "Remind me on (ISO 8601 date and time)"}
    submit:
      - name: set-reminder
        tool: api-set
        args: {version: "1", fileId: "$item.fields.file_id", body.dueDate: "$item.fields.due_date"}
    render: {component: cards}

  # The manager adds a card to a stack of a board.
  - name: board
    cognitive:
      objective: "show the stacks of a Deck board, to add a card to one"
    params:
      board_id: {type: integer, set_by: [agent]}
    invoke:
      method: deck-stack_api-index
      args: {boardId: "$params.board_id"}
    kinds: {stack: {}}
    present:
      fields:
        name: {from: title, type: text, role: title}
    select:
      max_items: 1
      quantity: {max: 1}
      guards:
        - permission: {profiles: [manager]}
          reason: "only the agency's manager adds cards"
        - form:
            card_title: {type: text, required: true, label: "The card's title"}
            card_description: {type: text, required: false, multiline: true, label: "What to do"}
            card_due: {type: datetime, required: false, label: "Due on"}
    submit:
      - name: create-card
        tool: deck-card_api-create
        args:
          boardId: "$params.board_id"
          stackId: "$item.fields.id"
          body.title: "$item.fields.card_title"
          body.description: "$item.fields.card_description"
          body.duedate: "$item.fields.card_due"
    render: {component: cards}

  # Four writes on a card, one skill each: Convoy files one write per chosen card.
  - name: move-card
    cognitive:
      objective: "find a Deck card by words, to move it to another stack"
    params:
      words: {type: text, set_by: [agent]}
    invoke:
      method: deck-search-search
      args: {term: "$params.words"}
    kinds: {card-move: {}}
    present: &card
      fields:
        name: {from: title, type: text, role: title}
        board: {from: board.title, type: text, role: eyebrow}
        due: {from: duedate, type: text, role: meta}
        board_id: {from: boardId, type: id}
        stack_id: {from: stackId, type: id}
    select:
      max_items: 1
      quantity: {max: 1}
      guards:
        - form:
            to_stack: {type: integer, required: true, label: "Move to the stack (its id, from `board`)"}
    submit:
      - name: move
        tool: deck-card_api-reorder
        args:
          boardId: "$item.fields.board_id"
          stackId: "$item.fields.stack_id"
          cardId: "$item.fields.id"
          body.stackId: "$item.fields.to_stack"
          body.order: "0"
    render: {component: cards}

  - name: comment-card
    cognitive:
      objective: "find a Deck card by words, to comment on it"
    params:
      words: {type: text, set_by: [agent]}
    invoke:
      method: deck-search-search
      args: {term: "$params.words"}
    kinds: {card-comment: {}}
    present: *card
    select:
      max_items: 1
      quantity: {max: 1}
      guards:
        - form:
            message: {type: text, required: true, multiline: true, label: "Your comment"}
    submit:
      - name: comment
        tool: deck-comments_api-create
        args: {cardId: "$item.fields.id", body.message: "$item.fields.message"}
    render: {component: cards}

  - name: assign-card
    cognitive:
      objective: "find a Deck card by words, to assign it to a colleague"
    params:
      words: {type: text, set_by: [agent]}
    invoke:
      method: deck-search-search
      args: {term: "$params.words"}
    kinds: {card-assign: {}}
    present: *card
    select:
      max_items: 1
      quantity: {max: 1}
      guards:
        - permission: {profiles: [manager]}
          reason: "only the agency's manager assigns cards"
        - form:
            assignee: {type: text, required: true, label: "Assign to (user id: lea or marc)"}
    submit:
      - name: assign
        tool: deck-card_api-assign-user
        args:
          boardId: "$item.fields.board_id"
          stackId: "$item.fields.stack_id"
          cardId: "$item.fields.id"
          body.userId: "$item.fields.assignee"
    render: {component: cards}

  - name: archive-card
    cognitive:
      objective: "find a Deck card by words, to archive it"
    params:
      words: {type: text, set_by: [agent]}
    invoke:
      method: deck-search-search
      args: {term: "$params.words"}
    kinds: {card-archive: {}}
    present: *card
    select:
      max_items: 1
      quantity: {max: 1}
      guards:
        - permission: {profiles: [manager]}
          reason: "only the agency's manager archives cards"
    submit:
      - name: archive
        tool: deck-card_api-archive
        args: {boardId: "$item.fields.board_id", stackId: "$item.fields.stack_id", cardId: "$item.fields.id"}
    render: {component: cards}

  # The person's own out-of-office, and their status message. One answer each (an OCS object,
  # read under `ocs.data`), chosen to be changed.
  - name: away
    cognitive:
      objective: "set the person's out-of-office: the days, the message colleagues see, who replaces them"
    invoke:
      method: users-get-current-user
    kinds: {absence: {}}
    present:
      fields:
        name: {from: ocs.data.displayname, type: text, role: title}
        uid: {from: ocs.data.id, type: id}
    select:
      max_items: 1
      quantity: {max: 1}
      guards:
        - form:
            first_day: {type: datetime, required: true, label: "First day away (YYYY-MM-DD)"}
            last_day: {type: datetime, required: true, label: "Last day away (YYYY-MM-DD)"}
            status: {type: text, required: true, label: "Status while away"}
            message: {type: text, required: true, multiline: true, label: "Message to colleagues"}
            replacement: {type: text, required: false, label: "Who replaces you (user id)"}
    submit:
      - name: set-absence
        tool: out_of_office-set-out-of-office
        args:
          userId: "$item.fields.uid"
          body.firstDay: "$item.fields.first_day"
          body.lastDay: "$item.fields.last_day"
          body.status: "$item.fields.status"
          body.message: "$item.fields.message"
          body.replacementUserId: "$item.fields.replacement"
    render: {component: cards}

  - name: status
    cognitive:
      objective: "show the person's status message, to set a new one"
    invoke:
      method: user_status-get-status
    kinds: {my-status: {}}
    present:
      fields:
        name: {from: ocs.data.userId, type: text, role: title}
        current: {from: ocs.data.message, type: text, role: meta}
    select:
      max_items: 1
      quantity: {max: 1}
      guards:
        - form:
            new_message: {type: text, required: true, label: "Your new status message"}
    submit:
      - name: set-status
        tool: user_status-set-custom-message
        args: {body.message: "$item.fields.new_message"}
    render: {component: cards}

playbooks:
  - name: send-to-client
    goal: "send a deliverable to a client: find it, share it by link or by e-mail, confirm"
    activation:
      when: "'manager' in $profiles"
      intent: "send a file to a client"
    tasks:
      look: {skill: find, required: false, label: "Find the deliverable"}
      share: {skill: send-outside, label: "Share it with the client"}

  - name: plan-my-week
    goal: "plan the week: what is due, then move or comment on one's cards"
    activation:
      when: "$identity.authenticated"
      intent: "plan my week"
    tasks:
      day: {skill: my-day, required: false, label: "Today and tomorrow"}
      move: {skill: move-card, required: false, label: "Move a card"}
      comment: {skill: comment-card, required: false, label: "Comment on a card"}

  - name: going-away
    goal: "go away: set the out-of-office, then hand one's open cards to a colleague"
    activation:
      when: "'manager' in $profiles"
      intent: "I am going away"
    tasks:
      away: {skill: away, label: "Out-of-office"}
      handover: {skill: assign-card, after: [away], label: "Hand over a card"}

# Every write waits for the person's yes, and only the room's owner, signed in, may give it.
submit_guard:
  confirm: true
  submitted_by: [{who: owner}]