summaryrefslogtreecommitdiff
path: root/net-misc/airouter/airouter-0.1.2-r23.ebuild
blob: dcf8c30e571e772d03acd30ae65050d0034930a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
EAPI=8

RUST_MIN_VER="1.98.0"
inherit cargo

DESCRIPTION="Metadata-only routing plane for owned and frontier AI compute"
HOMEPAGE="https://trunkmasters.com/airouter"
SRC_URI="https://www.hedronfire.com/distfiles/airouter-0.1.2-r9.tar.zst https://www.hedronfire.com/distfiles/llmbridge-0.1.2-20260924.tar.zst https://static.crates.io/crates/mime_guess/mime_guess-2.0.5.crate"
S="${WORKDIR}/airouter"

# The archive contains AIRouter, its pinned LLMBridge path dependency, and a
# complete Cargo vendor tree. The package must build without /srv/airouter or
# network access.
LICENSE="MIT Apache-2.0"
SLOT="0"
KEYWORDS="~amd64"


# Independent native service is additive to the immutable r9 platform source.
PATCHES=( "${FILESDIR}/airouter-codex-runtime.patch" "${FILESDIR}/airouter-managed-task-outcomes.patch" "${FILESDIR}/airouter-session-service.patch" "${FILESDIR}/airouter-session-attachments.patch" "${FILESDIR}/airouter-session-consumer.patch" "${FILESDIR}/airouter-grok-service.patch" "${FILESDIR}/airouter-ai-ownership.patch" "${FILESDIR}/airouter-pre-start-cancel.patch" "${FILESDIR}/airouter-application-boundary.patch" "${FILESDIR}/airouter-package-closure.patch" "${FILESDIR}/airouter-administrator-assistance.patch" "${FILESDIR}/airouter-native-mcp-arguments.patch" "${FILESDIR}/airouter-rust-contexts.patch" "${FILESDIR}/airouter-warden-diagnostics-r23.patch" )

RDEPEND="
    acct-group/airouter
    acct-group/airouter-admin
    acct-group/airouter-framework
    acct-user/airouter
    acct-user/airouter-agent
    acct-group/airouter-tools
    acct-user/airouter-tools
    dev-db/postgresql:18
    =app-misc/graphify-0.9.64
    =dev-util/codegraph-1.6.0
    sys-auth/citadel
    >=dev-lang/python-3.11
    sys-apps/acl
    sys-apps/bubblewrap
    sys-apps/util-linux
"
BDEPEND="
    net-misc/rsync
    app-arch/zstd
    >=dev-lang/rust-1.98.0
"

src_unpack() {
    # Portage on the target profile does not unpack .tar.zst through the
    # generic helper; extract both immutable source inputs explicitly.
    tar --zstd -xf "${DISTDIR}/airouter-0.1.2-r9.tar.zst" -C "${WORKDIR}" || die
    tar --zstd -xf "${DISTDIR}/llmbridge-0.1.2-20260924.tar.zst" -C "${WORKDIR}" || die
    mv "${WORKDIR}/llmbridge-0.1.2-20260924" "${WORKDIR}/llmbridge" || die
    # The pinned multipart dependency is checksum-verified by Portage and Cargo.
    tar -xzf "${DISTDIR}/mime_guess-2.0.5.crate" -C "${S}/vendor" || die
}

src_compile() {
    cargo build --offline --release --workspace --locked \
        --features "airouter-catalog/skills-tools,airouter-catalog/workspace-tools,\
airouter-catalog/development-tools,airouter-catalog/release-tools,\
airouter-catalog/learning-tools,airouter-catalog/host-tools,\
airouter-catalog/control-tools,airouter-agent-client/executor" || die
}

src_test() {
    local -x TMPDIR
    TMPDIR=$(mktemp -d /tmp/airouter-tests.XXXXXXXX) || die
    addwrite "${TMPDIR}"
    cargo test --offline --release --locked -p airouter-tools --lib --test api --test store || die
    cargo test --offline --release --locked -p airouter-mcp --features stdio || die
    cargo test --offline --release --locked -p airouter-agent-client --features native --test native_adapters || die
    cargo test --offline --release --locked -p airouter-verification --lib --test rust_live || die
    rm -rf -- "${TMPDIR}" || die
    src_compile
}

src_install() {
    dosbin target/release/airouterd
    dosbin target/release/airouter-agentd
    dosbin target/release/airouter-sessiond
    dosbin target/release/airouterctl
    dosbin target/release/airouter-catalog
    dosbin target/release/airouter-host
    dosbin target/release/airouter-release
    dosbin target/release/airouter-verify
    dosbin target/release/airouter-permissions
    dosbin target/release/airouter-toolsd
    dobin target/release/airouter-smoke
    dobin target/release/airouter-tool
    dobin target/release/airouter-authority target/release/airouter-browser
    dobin target/release/airouter-codegraph target/release/airouter-command
    dobin target/release/airouter-coordination target/release/airouter-learning
    dobin target/release/airouter-models target/release/airouter-rust
    dobin target/release/airouter-skills target/release/airouter-workspace
    dobin target/release/airouter-edit
    dobin crates/airouter-graphify/runtime/airouter-graphify
    # Preserve existing application registrations while making these helpers
    # package-owned aliases of the canonical implementations.
    dosym /usr/sbin/airouter-catalog /usr/local/bin/airouter-catalog
    dosym /usr/sbin/airouter-permissions /usr/local/libexec/airouter/airouter-permissions
    dosym /usr/bin/airouter-graphify /usr/local/bin/airouter-graphify
    exeinto /usr/libexec/airouter
    doexe target/release/airouter-codex
    doexe target/release/airouter-native-exec
    doexe target/release/airouter-review-exec
    newexe scripts/codex-provider/codex airouter-codex-adapter
    doexe target/release/enroll-node
    doexe packaging/scripts/airouter-renew-node-server
    doexe packaging/scripts/airouter-capability-refresh
    doexe packaging/scripts/airouter-framework-backup
    doexe packaging/scripts/airouter-tools-launch
    doexe target/release/airouter-desktop-worker
    # The Workbench selector invokes this stable top-level helper directly.
    # Keep it beside the AIRouter executables; catalog helpers belong below
    # /usr/libexec/airouter/catalog.
    exeinto /usr/libexec/airouter
    newexe scripts/airouter-route.py airouter-route
    exeinto /usr/libexec/airouter/catalog
    doexe target/release/airouter-skills-catalog
    doexe target/release/airouter-workspace-catalog
    doexe target/release/airouter-development-catalog
    doexe target/release/airouter-release-catalog
    doexe target/release/airouter-learning-catalog
    doexe target/release/airouter-host-catalog
    doexe target/release/airouter-control-catalog
    exeinto /usr/libexec/airouter/qualification
    doexe scripts/qualify-citadel-session.py
    doexe scripts/qualify-context-lifecycle.py
    doexe scripts/qualify-native-session-service.py
    insinto /etc/cron.d
    doins packaging/cron/airouter-server-cert-renew
    doins packaging/cron/airouter-capability-refresh
    doins packaging/cron/airouter-framework-backup
    insinto /etc/airouter
    newins config/codex-runtime.example.json codex-runtime.json
    doins config/airouter.toml
    newins config/framework.example.toml framework.toml
    doins config/tools.example.toml config/tools-client.example.toml
    newins config/routing.example.json routing.json
    insinto /etc/airouter-capabilities
    newins packaging/capabilities.sources.example.json sources.json
    # Native Workbench qualification needs its separately versioned fixture
    # bundle. Do not install a profile referencing absent host-local executors.
    diropts -o airouter -g airouter -m 0700
    keepdir /etc/airouter/secrets
    newinitd packaging/openrc/airouterd airouterd
    newinitd packaging/openrc/airouter-frameworkd airouter-frameworkd
    newinitd packaging/openrc/airouter-sessiond airouter-sessiond
    newinitd packaging/openrc/airouter-catalog-refresh airouter-catalog-refresh
    newinitd packaging/openrc/airouter-qualification airouter-qualification
    newinitd packaging/openrc/airouter-toolsd airouter-toolsd
    # Reset the private /etc/airouter/secrets directory policy before recursive
    # public assets; consumers run under their own application accounts.
    diropts -o root -g root -m 0755
    insinto /usr/share/airouter
    newins packaging/README.md README.md
    doins -r skills
    local component
    for component in crates/*/README.md; do
        local component_name=${component#crates/}
        component_name=${component_name%/README.md}
        insinto "/usr/share/airouter/docs/${component_name}"
        doins "${component}"
    done
    insinto /usr/share/airouter/setup/router
    doins schema/bootstrap.sql
    insinto /usr/share/airouter/setup/framework
    doins crates/airouter-agentd/setup/*.sql
    insinto /usr/share/airouter/examples
    doins config/*.example.* packaging/system-map.example.json
    insinto /usr/share/airouter/sets
    newins packaging/gentoo/sets/airouter-tools airouter-tools.example
    insinto /usr/share/airouter/patches
    doins packaging/gentoo/patches/piper-worker-limit.patch
    docinto tools
    dodoc config/tools.example.toml config/tools-client.example.toml crates/airouter-tools/README.md crates/airouter-tools/DESKTOPS.md
    docinto /
    dodoc README.md
    docinto schema
    dodoc schema/README.md
    docinto framework
    dodoc crates/airouter-agentd/README.md crates/airouter-agentd/AI_POLICIES.md crates/airouter-agentd/CONTEXT_LIFECYCLE.md crates/airouter-agentd/TASKS.md
    docinto sessions
    dodoc crates/airouter-agentd/SESSION_SERVICE.md config/session-service.example.toml
    docinto host
    dodoc crates/airouter-host/README.md
    docinto graphify
    dodoc crates/airouter-graphify/README.md
    diropts -o airouter -g airouter -m 0750
    keepdir /var/lib/airouter
    keepdir /var/backups/airouter-framework
    diropts -o root -g root -m 0711
    keepdir /var/lib/airouter-native/codex
    keepdir /var/lib/airouter-native/sessions
}

pkg_postinst() {
    elog "Deployment/bootstrap inputs: /usr/share/airouter/README.md and /usr/share/airouter/setup/."
    elog "Session service: configure an independent per-app instance before enabling it; see sessions/SESSION_SERVICE.md."
    elog "Codex/Claude/Grok service adapters are available; register exact profiles and existing login paths before consumer activation."
    elog "Codex service state: register UID/home entries in /etc/airouter/codex-runtime.json."
    elog "Provision private service state and login before selecting airouter-codex; see the host README."
    elog "Context v2: retain compatible runtime/configuration once writer minimum 2 is enabled."
    elog "Keep the context-input receipt API available until pending application inputs settle."
    elog "This package does not migrate, enroll or restart services automatically."
    elog "Create the signing key with: airouterctl generate-signing-key"
    elog "Apply migrations with the restricted airouter_migrate role before starting airouterd."
}