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
union FromPeer {
  1 -> struct PeerUpdate {
    byte[][] updates;
    string id;
  }
  2 -> struct PeerAwareness {
    byte[] awareness;
  }
  3 -> struct PeerRequestSince {
    // We send a version vector instead of a frontier from the client to
    // request updates. This is because I could make updates while offline,
    // and then when I request updates I want to request updates up to a
    // point that doesn't exist on the server.
    byte[] vv;
  }
  4 -> struct PeerRequestSnapshot {}
  5 -> struct PeerRegisterId {
    uint64 peerid;
  }
  // Comment publication is validated even for editors. Older servers reject
  // this variant rather than accepting an unchecked structural text change.
  6 -> struct PeerCommentUpdate {
    byte[][] updates;
    string id;
  }
}

union FromRemote {
  1 -> struct RemoteInitialSync {
    byte[] snapshot;
    byte[] awareness;
  }
  2 -> struct RemoteUpdate {
    byte[] update;
  }
  3 -> struct RemoteAwareness {
    byte[] awareness;
  }
  4 -> struct RemoteSnapshot {
    byte[] snapshot;
  }
  5 -> struct RemoteUpdateAck {
    string id;
  }
  6 -> struct RemoteUpdateSince {
    byte[] update;
    byte[] vv;
  }
}

struct Operation {
  byte[] update;
  date timestamp;
}

struct OperationLog {
  Operation[] operations;
}

struct InitializeFromSnapshotRequest {
  byte[] snapshot;
}


/*
 * Multiplex envelope between the browser and the sync-router (rides the
 * dedicated DSS /sync/ws socket as binary frames). Inner payloads are the
 * existing FromPeer/FromRemote unions, already bebop-encoded — the router
 * forwards them without parsing.
 */
union ToRouter {
  1 -> struct RouterSubscribe {
    string docId;
    // DocumentPermissionToken; passed through to the downstream unverified
    // (the downstream authenticates, exactly as with a direct connection).
    string token;
  }
  2 -> struct RouterUnsubscribe {
    string docId;
  }
  3 -> struct RouterFrame {
    string docId;
    // A serialized FromPeer, untouched.
    byte[] payload;
  }
}

union FromRouter {
  1 -> struct RouterSubscribed {
    string docId;
  }
  2 -> struct RouterSubscribeFailed {
    string docId;
    string reason;
  }
  3 -> struct RouterDocFrame {
    string docId;
    // A serialized FromRemote, untouched.
    byte[] payload;
  }
  4 -> struct RouterDocClosed {
    string docId;
    string reason;
  }
}