Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

2.3 KB
Raw Blame
use super::{FormsToolContext, tool_error};
use crate::domain::authoring::{MutationResult, SetAccess, ports::FormsAuthoringService};
use ai_toolset::{
    AsyncTool, RequestContext, ServiceContext, ToolAnnotated, ToolAnnotations, ToolResult,
};
use async_trait::async_trait;
use schemars::JsonSchema;
use serde::Deserialize;

/// Share form through the owning domain workflow.
#[derive(Debug, Clone, Deserialize, JsonSchema)]
#[schemars(
    title = "SetFormAccess",
    description = "Open, close or share a saved form immediately. Requires Form Owner. Supply complete audience/status/deadline/tally settings and explicit channel grant deltas; empty deltas change no grants. Optional responsesVisible lets View holders read response rows; optional anonymous makes the form anonymous to everyone, its owner included (who responded is kept apart from the responses), and is refused once anyone has responded. Public allows anonymous responses and is needed only for people without a Macro account; members-only already admits everyone in the channels the form is shared with, people outside the team included. View allows responding without database access unless responses are shared; channel Edit grants editing of the entire backing database. Uses the existing Forms settings and sharing services without a review step. This never posts a message or sends invitations. Settings and channel grants are separate writes; inspect partial results before retrying. Returns actual access, canonical links and acceptingResponses; a URL alone does not mean the form is open."
)]
pub struct SetFormAccess {
    /// Flat workflow arguments shared with the domain service.
    #[serde(flatten)]
    pub intent: SetAccess,
}
impl ToolAnnotated for SetFormAccess {
    const ANNOTATIONS: ToolAnnotations = ToolAnnotations::destructive("Share form");
}
#[async_trait]
impl<Service: FormsAuthoringService> AsyncTool<FormsToolContext<Service>> for SetFormAccess {
    type Output = MutationResult;
    async fn call(
        &self,
        context: ServiceContext<FormsToolContext<Service>>,
        request: RequestContext,
    ) -> ToolResult<Self::Output> {
        context
            .service
            .set_form_access(context.viewer(request.user_id), self.intent.clone())
            .await
            .map_err(tool_error)
    }
}