Skip to content

Latest commit

 

History

History
206 lines (168 loc) · 12.5 KB

NATIVE_WORKSPACE_API.md

File metadata and controls

206 lines (168 loc) · 12.5 KB

Native workspace API

These routes extend stock authenticated hermes serve at /api/plugins/loopdy. They need no bighelp account or extra listener. Network/Tailscale/TLS configuration and host activation remain operator-owned. Stock Hermes REST and /api/ws still own native chat and workspace execution.

This is not full native parity. Optional room tool observations extend this foundation on supported main builds. iPhone tools use a short-lived phone channel on the same routes.

Authentication and context

GET /api/plugins/loopdy/native/context takes no query parameters or body:

{
  schemaVersion: 1,
  pluginVersion: string,
  runtimeId: string,
  servingProfileId: string|null,
  principal: {provider: string, userId: string, displayName: string|null}|null,
  features: string[],
  unavailable?: {[feature: string]: string}
}

features lists at most 64 names unless the request sends X-Bighelp-Features: all, because older app releases refuse a longer list. Features added after the list reached 64 (LATE_FEATURES in native_context.py) come last, so those are the ones left out; older apps don't know them. The ETag is the full context's either way. Every new feature goes in LATE_FEATURES.

unavailable is present only when a feature this plugin has can't work on this computer for a known reason. Each value is a fixed reason code, never free text, so the app can say what to do. Workflows use it (native-workflows-v1: not_posix, profile_helpers_missing, chat_runner_missing or store_unavailable; see Workflows). So do instant alerts and Quiet Hours (native-live-alerts-v1, native-notification-quiet-hours-v1) when the notification journal can't be opened: the value is a notification_* code, see Notifications. Apps that don't know the field ignore it.

Routes are mounted behind Hermes' own authentication middleware. With provider login enabled, a real verified dashboard_auth.base.Session is required, and its provider/user coordinates must match the app's verified account. Without provider login, Hermes' existing dashboard session-token middleware grants the host-wide session; principal is null and the app uses a separate dashboard scope. The plugin does not fabricate a user or accept credentials itself. Missing/wrong dashboard tokens are still rejected by Hermes before dispatch. No change to host authentication, URL or listening port is required.

Only provider (128 UTF-8 bytes), user ID (512) and optional display name (200) are copied. Credentials and Session objects are never returned or logged. Other native features use their existing context and operation preconditions. The app's local auth/connection generations reject stale callbacks. Native workspace access does not create a per-profile ACL or phone permission.

runtimeId identifies this loaded native plugin HTTP module lifetime, not installed source, release freshness, or a device. Process profile is obtained only with the public profile_name_for_home(get_process_hermes_home()) helpers, ignoring request-local home overrides. Missing/unproven profile is null, never inferred as default. The filesystem path is not exposed. Use this proof to gate process-scoped memory/logs/webhooks; an ignored ?profile is not scope selection.

Features are finite: native-context-v1, serving-profile-v1 when proven, and native-card-templates-v1 when the implemented routes' public profile helpers are available. native-room-activity-v1, native-room-typing-v1 and native-room-peer-typing-v1 are added only with an actual supported live public-hook registration. These are not universal Hermes capability or runtime health claims. native-project-git-read-v1 exposes the distinct fixed read-only Project Git contract using verified public Project/stored-session association and the existing content-token engine. See Native Project Git; this never creates or adopts a Workspace Files grant. Read failures remain visible. Context responses are at most 16 KiB.

Chats outlive a dropped connection

A phone loses its connection each time someone leaves bighelp. Hermes then reclaims the session's runtime after ws_orphan_reap_grace_s (20 seconds). For a desktop session it keeps the saved chat open and resumable; for any other app's it ends the row (end_reason ws_orphan_reap, ws_disconnect, idle_timeout or lru_evict). With sessions.auto_prune, Hermes deletes ended chats once they are idle past retention_days, so bighelp's chats were deleted where Desktop's are kept.

The plugin gives bighelp sessions Desktop's treatment for those automatic reasons only (durable_sessions.py). The first native context request in the process that serves the app installs it. It also reopens bighelp chats that Hermes ended for those reasons before. Closing, archiving and deleting a chat do not change. On a Hermes without this lifecycle, nothing changes.

Agents keep working with the app closed

message_agent runs the turn of the other agent in a background process and ends the turn that asked. The chat that asked is then idle while it waits for the reply. Hermes reclaimed an idle chat 20 seconds after the app's connection went. Closing its agent stopped the other agent's process (exit code -15, completion_reason killed), and the reply had no poller left to wake the chat. So agents could work together only while the app was open.

Hermes' reaper already waits while a chat has live delegate_task subagents (_session_has_active_delegations). For a bighelp session, the plugin adds the chat's background jobs that report back when they end (notify_on_complete), such as a message_agent delivery. The chat keeps its runtime until they end and their reply is handled, then the reaper reclaims it as before. Other apps' sessions, and background jobs that do not report back, are unchanged. An unreadable process registry never keeps a chat. Hosts that set dashboard.ws_orphan_reap_grace_s: 0 to work around this can remove that setting.

Card templates

Successful context GET returns Cache-Control: no-store and an ETag of the form "sha256:<64 lowercase hex>" (including quotes). It hashes canonical JSON of the safe context above; it is a precondition, NOT a credential.

Every template POST requires that exact If-Match plus X-Loopdy-Request-ID: <canonical lowercase UUID>. Duplicate, missing or malformed headers fail. Success echoes both headers. Valid request IDs are also echoed on plugin validation/domain errors; errors do not issue a new ETag. Stock auth and disabled-plugin errors may originate before the plugin and have no echo.

All paths below start /api/plugins/loopdy/native/cards/templates/:

POST suffix Exact JSON body Successful result
list {agentId} {agentId,templates:[summary]}
install {agentId,template:bundle} {agentId,changed,template:summary}
remove {agentId,templateId,version,sha256} {agentId,changed,templateId}

An exact existing canonical profile ID is required. No fallback, arbitrary method/path, actor/device/host override or new remote template fetching is accepted. All three routes reuse the serving plugin's existing profile-keyed template store and summary projection.

Summary fields: id,version,name,summary,author,license,minimum_card_version,sha256. Bundle adds exactly parameters_schema,document; see loopdy-card-template-v1.schema.json. Native version fields are strict integers, card version is 1, the document hash must match, and the existing inert Card validator prohibits active data sources. Requests/responses are at most 196608 UTF-8 bytes, JSON depth at most 24 and catalogs at most 500 summaries. Oversized catalogs fail rather than silently truncate. Duplicate JSON fields, non-finite numbers and unknown fields fail.

Identical full-bundle reinstall is unchanged; same-version different content or downgrade conflicts. Remove compares exact version/hash; already absent is unchanged. These are existing domain outcomes, not a general request-ID receipt or exactly-once protocol. Cancel/disconnect/context change can race a committed transaction: reconcile by listing under a fresh context, never blindly retry a mutation or switch transports. Context is checked before/after body and worker awaits. Native auth revocation is enforced by stock middleware on new requests, not a new atomic revoke-versus-in-flight-transaction guarantee.

Plugin errors are {error:{code,message,retryable,details:{}}}. Statuses: 401 missing/invalid interactive identity; 404 missing profile; 422 invalid input; 428 missing If-Match; 412 changed context; 409 template conflict; 413 bound exceeded; 503 unavailable service. Errors are bounded and omit raw inputs, exceptions and paths. A 412 requires a fresh context; it never authorizes retry.

Existing services are separate contracts

Existing routes and older clients are unchanged; the new headers are not required by forms, attachments, provider/device management or Files:

  • Forms: /generative-ui/v2/forms/{request_id}/submit and /status, with existing stored profile/session binding and action-response envelope.
  • Attachments: /attachments/resolve and /attachments/{id}?profile=..., using existing Hermes delivery policy and opaque profile cache IDs. This is not a universal artifact catalog or authenticated-person/turn proof.
  • Files: /workspace-files/capabilities, /list, /read, /status, /diff. Explicit host-local root grants are required in addition to HTTP auth. The current serving-profile catalog is shared by its authenticated workspace callers, not a per-device ACL. See Workspace Files.

Plugin Files uses opaque IDs and relative paths, not native Files absolute locked_root paths. Its grant generation/inode checks are internal; wire revisions are file hashes or directory snapshots, not client-visible grant epochs. Retain the native owner and proven process profile over each await and re-probe roots after reconnect.

Routes that don't check their feature

Most native routes refuse a request when /native/context doesn't list their feature. These don't look at the feature list. The app should still check /native/context first, but the route itself is gated only by what the table says:

Routes Feature the app checks What the route checks
/native/voice/* native-voice-v1 The native session, the context ETag and that the agent exists. status reports whether the provider is set up.
/native/workspace-files/* native-workspace-files-v1 and the other native-workspace-* features The native session and context ETag, a known serving profile (501 workspace_identity_unavailable) and the agent in profile (404 agent_not_found).
/native/groups/activity/poll and /close native-room-activity-v1 Only open checks the feature. poll and close need a streamId that open gave out (410 activity_reset_required or 404 activity_not_found otherwise).
/native/agent-templates/* native-agent-templates-v1 The same check that lists the feature (agent_templates.available()), as 501 templates_unavailable.

Capability boundaries

Capability Current native boundary
Phone tools A phone channel is bound to one agent and session; Hermes' tool execution middleware routes iphone_* calls to it using Hermes' own turn and tool-call IDs. See iPhone tools.
Hosted person context Public pre-LLM hooks lack authoritative hosted room/member/discussion/task-generation/person binding. Generic native durable actor remains honest; no private/task-title/text inference.
Group activity Optional main-only public observer feeds are asynchronous, lossy and local-member-only; see the exact HTTP polling contract. No durable replay or completion-success inference.

Native auth is not a phone grant. Raw microphone transcription remains local to the phone, and provider credentials are never exposed by these routes.

Verification and activation

tests/test_native_api.py covers real Hermes auth middleware and stock serve plugin discovery in synthetic homes, not a substitute production auth provider. Focused groups, templates, forms, attachments and Files suites cover compatibility. Use the real Hermes Python with explicit source/candidate import paths and a credential-free temporary HOME/HERMES_HOME before any imports. No installation, restart, deployment, release or activation follows from these source changes or their passing tests.