Repository Public License
1# =============================================================================2# SP BOUCHER | SOURCE FILE3# =============================================================================4# Project : ORIX OS Automation5# File : Workflows/Examples/07-calendar-preparation.yaml6# Author : Simon-Pierre Boucher | https://spboucher.ai7# Contact : support@spboucher.ai8# Copyright : (c) 2026 Simon-Pierre Boucher9# License : Proprietary, all rights reserved (see license file)10# =============================================================================11# END OF SP BOUCHER SOURCE HEADER12# =============================================================================1314# ORIX OS Automation15# File: Workflows/Examples/07-calendar-preparation.yaml16# Description: Built-in automation: reads the coming events from Calendar (read-only, with Automation consent) and writes a preparation briefing.17#18# Author: Simon-Pierre Boucher19# Contact: contact@spboucher.ai20#21# Limitations22# - Reads Calendar through Apple Events: macOS asks once for Automation consent (ORIX → Calendar). ORIX never answers23# that prompt itself; when consent was refused the step ends BLOCKED_PERMISSION and nothing is written.24# - The script opens Calendar if it is not running (that is what `tell application` does).25# - Read-only: the script only reads start dates and titles. No event is created, changed or deleted.26# - Only start date and title are read (one line per event). Dates are formatted by AppleScript in the Mac's language;27# recurring events and time zones follow what Calendar reports.28# - Large calendars make the AppleScript query slow; the step has a 120 s timeout.29# - `daysAhead` is interpolated into the script text; it is declared as an integer parameter for that reason.30# - The notification needs the ORIX app (a command-line run has no application bundle): there the last step fails by31# itself and the run ends PARTIALLY_SUCCEEDED with the briefing written.32apiVersion: orix.ai/v133kind: Automation34metadata:35 id: calendar-preparation36 name: Calendar-based preparation37 description: >-38 Each weekday morning, reads the events of the coming days from the Calendar app (with the user's39 Automation consent) and writes a dated briefing with one preparation checklist line per event.40 tags: [calendar, applescript, briefing, schedule]41spec:42 triggers:43 - type: schedule44 cron: "30 7 * * MON-FRI"45 timezone: America/Toronto46 - type: manual47 parameters:48 - name: daysAhead49 type: integer50 default: 151 description: Number of days to look ahead, starting today at midnight.52 - name: outputFolder53 type: path54 default: ~/ORIX Samples/calendar-preparation/Briefings55 description: Folder that receives the briefing.56 permissions:57 filesystem:58 write: ["${{ params.outputFolder }}"]59 scripts: [applescript]60 apps:61 automation: [com.apple.iCal]62 notifications: true63 budget:64 maxDurationSeconds: 30065 maxToolCalls: 1066 steps:67 - id: paths68 set:69 briefing: ${{ params.outputFolder }}/briefing-${{ env.DATE }}.md70 - id: prepare71 tool: filesystem.mkdir72 with:73 path: ${{ params.outputFolder }}74 - id: events75 name: Read the coming events76 tool: applescript.run77 with:78 targets: [com.apple.iCal]79 timeoutSeconds: 12080 script: |81 set startDate to current date82 set time of startDate to 083 set endDate to startDate + (${{ params.daysAhead }} * days)84 set out to ""85 tell application id "com.apple.iCal"86 repeat with c in calendars87 repeat with e in (every event of c whose start date >= startDate and start date < endDate)88 set out to out & ((start date of e) as string) & tab & (summary of e) & linefeed89 end repeat90 end repeat91 end tell92 return out93 timeoutSeconds: 15094 - id: lines95 needs: [events]96 transform: ${{ filter(split(default(steps.events.output.value, ""), "\n"), l => len(trim(l)) > 0) }}97 - id: write98 name: Write the briefing99 needs: [paths, prepare, lines]100 tool: filesystem.write101 with:102 path: ${{ vars.briefing }}103 overwrite: true104 content: |105 # Briefing for ${{ env.DATE }}106107 Events in the next ${{ params.daysAhead }} day(s): ${{ len(steps.lines.output) }}108109 ${{ join(map(steps.lines.output, l => "- [ ] " + replace(l, "\t", " — ")), "\n") }}110 - id: check111 needs: [write]112 verify:113 - fileContains: ${{ vars.briefing }}114 text: "# Briefing for"115 - id: result116 needs: [check]117 output:118 briefing: ${{ vars.briefing }}119 events: ${{ len(steps.lines.output) }}120 artifacts:121 - ${{ vars.briefing }}122 - id: announce123 needs: [result]124 notify: ${{ len(steps.lines.output) }} event(s) to prepare.125 title: Calendar briefing126 continueOnError: true127